pi-tps-web 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -235,9 +235,9 @@ Error generating stack: `+e.message+`
235
235
  A`,`,`,`,0,`,`,`,`,`,`,`,`
236
236
  A`,`,`,`,0,0,`,`,`,`,`,`Z`]),C.x,C.y,a,a,+(u<0),S.x,S.y,r,r,+(T>180),+(u>0),y.x,y.y,a,a,+(u<0),b.x,b.y)}else v+=VS(Hk||=Wk([`L`,`,`,`Z`]),t,n);return v},Yk={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},Xk=e=>{var t=dC(e,Yk),{cx:n,cy:r,innerRadius:i,outerRadius:a,cornerRadius:o,forceCornerRadius:s,cornerIsExternal:c,startAngle:l,endAngle:u,className:d}=t;if(a<i||l===u)return null;var f=Px(`recharts-sector`,d),p=a-i,m=JS(o,p,0,!0),h=m>0&&Math.abs(l-u)<360?Jk({cx:n,cy:r,innerRadius:i,outerRadius:a,cornerRadius:Math.min(m,p/2),forceCornerRadius:s,cornerIsExternal:c,startAngle:l,endAngle:u}):qk({cx:n,cy:r,innerRadius:i,outerRadius:a,startAngle:l,endAngle:u});return b.createElement(`path`,Uk({},Bx(t),{className:f,d:h}))};function Zk(e,t,n){if(e===`horizontal`)return[{x:t.x,y:n.top},{x:t.x,y:n.top+n.height}];if(e===`vertical`)return[{x:n.left,y:t.y},{x:n.left+n.width,y:t.y}];if(sC(t)){if(e===`centric`){var{cx:r,cy:i,innerRadius:a,outerRadius:o,angle:s}=t,c=Ok(r,i,a,s),l=Ok(r,i,o,s);return[{x:c.x,y:c.y},{x:l.x,y:l.y}]}return Fk(t)}}var Qk=s((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=sw();function n(e){return t.isSymbol(e)?NaN:Number(e)}e.toNumber=n})),$k=s((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=Qk();function n(e){return e?(e=t.toNumber(e),e===1/0||e===-1/0?(e<0?-1:1)*Number.MAX_VALUE:e===e?e:0):e===0?e:0}e.toFinite=n})),eA=s((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=dw(),n=$k();function r(e,r,i){i&&typeof i!=`number`&&t.isIterateeCall(e,r,i)&&(r=i=void 0),e=n.toFinite(e),r===void 0?(r=e,e=0):r=n.toFinite(r),i=i===void 0?e<r?1:-1:n.toFinite(i);let a=Math.max(Math.ceil((r-e)/(i||1)),0),o=Array(a);for(let t=0;t<a;t++)o[t]=e,e+=i;return o}e.range=r})),tA=s(((e,t)=>{t.exports=eA().range})),nA=e=>e.chartData,rA=W([nA],e=>{var t=e.chartData==null?0:e.chartData.length-1;return{chartData:e.chartData,computedData:e.computedData,dataEndIndex:t,dataStartIndex:0}}),iA=(e,t,n,r)=>r?rA(e):nA(e),aA=(e,t,n)=>n?rA(e):nA(e),oA=W([iA],e=>{var{chartData:t,dataStartIndex:n,dataEndIndex:r}=e;return t==null?[]:t.slice(n,r+1)}),sA=W([rA],e=>{var{chartData:t,dataStartIndex:n,dataEndIndex:r}=e;return t==null?[]:t.slice(n,r+1)}),cA=W([nA],e=>{var{chartData:t,dataStartIndex:n,dataEndIndex:r}=e;return t==null?[]:t.slice(n,r+1)});function lA(e){if(Array.isArray(e)&&e.length===2){var[t,n]=e;if(PE(t)&&PE(n))return!0}return!1}function uA(e,t,n){return n?e:[Math.min(e[0],t[0]),Math.max(e[1],t[1])]}function dA(e,t){if(t&&typeof e!=`function`&&Array.isArray(e)&&e.length===2){var[n,r]=e,i,a;if(PE(n))i=n;else if(typeof n==`function`)return;if(PE(r))a=r;else if(typeof r==`function`)return;var o=[i,a];if(lA(o))return o}}function fA(e,t,n){if(!(!n&&t==null)){if(typeof e==`function`&&t!=null)try{var r=e(t,n);if(lA(r))return uA(r,t,n)}catch{}if(Array.isArray(e)&&e.length===2){var[i,a]=e,o,s;if(i===`auto`)t!=null&&(o=Math.min(...t));else if(H(i))o=i;else if(typeof i==`function`)try{t!=null&&(o=i(t?.[0]))}catch{}else if(typeof i==`string`&&GE.test(i)){var c=GE.exec(i);if(c==null||c[1]==null||t==null)o=void 0;else{var l=+c[1];o=t[0]-l}}else o=t?.[0];if(a===`auto`)t!=null&&(s=Math.max(...t));else if(H(a))s=a;else if(typeof a==`function`)try{t!=null&&(s=a(t?.[1]))}catch{}else if(typeof a==`string`&&KE.test(a)){var u=KE.exec(a);if(u==null||u[1]==null||t==null)s=void 0;else{var d=+u[1];s=t[1]+d}}else s=t?.[1];var f=[o,s];if(lA(f))return t==null?f:uA(f,t,n)}}}var pA=u(s(((e,t)=>{(function(e){var n=1e9,r={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:`2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286`},i=!0,a=`[DecimalError] `,o=a+`Invalid argument: `,s=a+`Exponent out of range: `,c=Math.floor,l=Math.pow,u=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,d,f=1e7,p=7,m=9007199254740991,h=c(m/p),g={};g.absoluteValue=g.abs=function(){var e=new this.constructor(this);return e.s&&=1,e},g.comparedTo=g.cmp=function(e){var t,n,r,i,a=this;if(e=new a.constructor(e),a.s!==e.s)return a.s||-e.s;if(a.e!==e.e)return a.e>e.e^a.s<0?1:-1;for(r=a.d.length,i=e.d.length,t=0,n=r<i?r:i;t<n;++t)if(a.d[t]!==e.d[t])return a.d[t]>e.d[t]^a.s<0?1:-1;return r===i?0:r>i^a.s<0?1:-1},g.decimalPlaces=g.dp=function(){var e=this,t=e.d.length-1,n=(t-e.e)*p;if(t=e.d[t],t)for(;t%10==0;t/=10)n--;return n<0?0:n},g.dividedBy=g.div=function(e){return b(this,new this.constructor(e))},g.dividedToIntegerBy=g.idiv=function(e){var t=this,n=t.constructor;return D(b(t,new n(e),0,1),n.precision)},g.equals=g.eq=function(e){return!this.cmp(e)},g.exponent=function(){return S(this)},g.greaterThan=g.gt=function(e){return this.cmp(e)>0},g.greaterThanOrEqualTo=g.gte=function(e){return this.cmp(e)>=0},g.isInteger=g.isint=function(){return this.e>this.d.length-2},g.isNegative=g.isneg=function(){return this.s<0},g.isPositive=g.ispos=function(){return this.s>0},g.isZero=function(){return this.s===0},g.lessThan=g.lt=function(e){return this.cmp(e)<0},g.lessThanOrEqualTo=g.lte=function(e){return this.cmp(e)<1},g.logarithm=g.log=function(e){var t,n=this,r=n.constructor,o=r.precision,s=o+5;if(e===void 0)e=new r(10);else if(e=new r(e),e.s<1||e.eq(d))throw Error(a+`NaN`);if(n.s<1)throw Error(a+(n.s?`NaN`:`-Infinity`));return n.eq(d)?new r(0):(i=!1,t=b(T(n,s),T(e,s),s),i=!0,D(t,o))},g.minus=g.sub=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?O(t,e):_(t,(e.s=-e.s,e))},g.modulo=g.mod=function(e){var t,n=this,r=n.constructor,o=r.precision;if(e=new r(e),!e.s)throw Error(a+`NaN`);return n.s?(i=!1,t=b(n,e,0,1).times(e),i=!0,n.minus(t)):D(new r(n),o)},g.naturalExponential=g.exp=function(){return x(this)},g.naturalLogarithm=g.ln=function(){return T(this)},g.negated=g.neg=function(){var e=new this.constructor(this);return e.s=-e.s||0,e},g.plus=g.add=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?_(t,e):O(t,(e.s=-e.s,e))},g.precision=g.sd=function(e){var t,n,r,i=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(o+e);if(t=S(i)+1,r=i.d.length-1,n=r*p+1,r=i.d[r],r){for(;r%10==0;r/=10)n--;for(r=i.d[0];r>=10;r/=10)n++}return e&&t>n?t:n},g.squareRoot=g.sqrt=function(){var e,t,n,r,o,s,l,u=this,d=u.constructor;if(u.s<1){if(!u.s)return new d(0);throw Error(a+`NaN`)}for(e=S(u),i=!1,o=Math.sqrt(+u),o==0||o==1/0?(t=y(u.d),(t.length+e)%2==0&&(t+=`0`),o=Math.sqrt(t),e=c((e+1)/2)-(e<0||e%2),o==1/0?t=`5e`+e:(t=o.toExponential(),t=t.slice(0,t.indexOf(`e`)+1)+e),r=new d(t)):r=new d(o.toString()),n=d.precision,o=l=n+3;;)if(s=r,r=s.plus(b(u,s,l+2)).times(.5),y(s.d).slice(0,l)===(t=y(r.d)).slice(0,l)){if(t=t.slice(l-3,l+1),o==l&&t==`4999`){if(D(s,n+1,0),s.times(s).eq(u)){r=s;break}}else if(t!=`9999`)break;l+=4}return i=!0,D(r,n)},g.times=g.mul=function(e){var t,n,r,a,o,s,c,l,u,d=this,p=d.constructor,m=d.d,h=(e=new p(e)).d;if(!d.s||!e.s)return new p(0);for(e.s*=d.s,n=d.e+e.e,l=m.length,u=h.length,l<u&&(o=m,m=h,h=o,s=l,l=u,u=s),o=[],s=l+u,r=s;r--;)o.push(0);for(r=u;--r>=0;){for(t=0,a=l+r;a>r;)c=o[a]+h[r]*m[a-r-1]+t,o[a--]=c%f|0,t=c/f|0;o[a]=(o[a]+t)%f|0}for(;!o[--s];)o.pop();return t?++n:o.shift(),e.d=o,e.e=n,i?D(e,p.precision):e},g.toDecimalPlaces=g.todp=function(e,t){var r=this,i=r.constructor;return r=new i(r),e===void 0?r:(v(e,0,n),t===void 0?t=i.rounding:v(t,0,8),D(r,e+S(r)+1,t))},g.toExponential=function(e,t){var r,i=this,a=i.constructor;return e===void 0?r=k(i,!0):(v(e,0,n),t===void 0?t=a.rounding:v(t,0,8),i=D(new a(i),e+1,t),r=k(i,!0,e+1)),r},g.toFixed=function(e,t){var r,i,a=this,o=a.constructor;return e===void 0?k(a):(v(e,0,n),t===void 0?t=o.rounding:v(t,0,8),i=D(new o(a),e+S(a)+1,t),r=k(i.abs(),!1,e+S(i)+1),a.isneg()&&!a.isZero()?`-`+r:r)},g.toInteger=g.toint=function(){var e=this,t=e.constructor;return D(new t(e),S(e)+1,t.rounding)},g.toNumber=function(){return+this},g.toPower=g.pow=function(e){var t,n,r,o,s,l,u=this,f=u.constructor,h=12,g=+(e=new f(e));if(!e.s)return new f(d);if(u=new f(u),!u.s){if(e.s<1)throw Error(a+`Infinity`);return u}if(u.eq(d))return u;if(r=f.precision,e.eq(d))return D(u,r);if(t=e.e,n=e.d.length-1,l=t>=n,s=u.s,!l){if(s<0)throw Error(a+`NaN`)}else if((n=g<0?-g:g)<=m){for(o=new f(d),t=Math.ceil(r/p+4),i=!1;n%2&&(o=o.times(u),ee(o.d,t)),n=c(n/2),n!==0;)u=u.times(u),ee(u.d,t);return i=!0,e.s<0?new f(d).div(o):D(o,r)}return s=s<0&&e.d[Math.max(t,n)]&1?-1:1,u.s=1,i=!1,o=e.times(T(u,r+h)),i=!0,o=x(o),o.s=s,o},g.toPrecision=function(e,t){var r,i,a=this,o=a.constructor;return e===void 0?(r=S(a),i=k(a,r<=o.toExpNeg||r>=o.toExpPos)):(v(e,1,n),t===void 0?t=o.rounding:v(t,0,8),a=D(new o(a),e,t),r=S(a),i=k(a,e<=r||r<=o.toExpNeg,e)),i},g.toSignificantDigits=g.tosd=function(e,t){var r=this,i=r.constructor;return e===void 0?(e=i.precision,t=i.rounding):(v(e,1,n),t===void 0?t=i.rounding:v(t,0,8)),D(new i(r),e,t)},g.toString=g.valueOf=g.val=g.toJSON=function(){var e=this,t=S(e),n=e.constructor;return k(e,t<=n.toExpNeg||t>=n.toExpPos)};function _(e,t){var n,r,a,o,s,c,l,u,d=e.constructor,m=d.precision;if(!e.s||!t.s)return t.s||(t=new d(e)),i?D(t,m):t;if(l=e.d,u=t.d,s=e.e,a=t.e,l=l.slice(),o=s-a,o){for(o<0?(r=l,o=-o,c=u.length):(r=u,a=s,c=l.length),s=Math.ceil(m/p),c=s>c?s+1:c+1,o>c&&(o=c,r.length=1),r.reverse();o--;)r.push(0);r.reverse()}for(c=l.length,o=u.length,c-o<0&&(o=c,r=u,u=l,l=r),n=0;o;)n=(l[--o]=l[o]+u[o]+n)/f|0,l[o]%=f;for(n&&(l.unshift(n),++a),c=l.length;l[--c]==0;)l.pop();return t.d=l,t.e=a,i?D(t,m):t}function v(e,t,n){if(e!==~~e||e<t||e>n)throw Error(o+e)}function y(e){var t,n,r,i=e.length-1,a=``,o=e[0];if(i>0){for(a+=o,t=1;t<i;t++)r=e[t]+``,n=p-r.length,n&&(a+=w(n)),a+=r;o=e[t],r=o+``,n=p-r.length,n&&(a+=w(n))}else if(o===0)return`0`;for(;o%10==0;)o/=10;return a+o}var b=(function(){function e(e,t){var n,r=0,i=e.length;for(e=e.slice();i--;)n=e[i]*t+r,e[i]=n%f|0,r=n/f|0;return r&&e.unshift(r),e}function t(e,t,n,r){var i,a;if(n!=r)a=n>r?1:-1;else for(i=a=0;i<n;i++)if(e[i]!=t[i]){a=e[i]>t[i]?1:-1;break}return a}function n(e,t,n){for(var r=0;n--;)e[n]-=r,r=+(e[n]<t[n]),e[n]=r*f+e[n]-t[n];for(;!e[0]&&e.length>1;)e.shift()}return function(r,i,o,s){var c,l,u,d,m,h,g,_,v,y,b,x,C,w,T,E,O,k,ee=r.constructor,te=r.s==i.s?1:-1,ne=r.d,re=i.d;if(!r.s)return new ee(r);if(!i.s)throw Error(a+`Division by zero`);for(l=r.e-i.e,O=re.length,T=ne.length,g=new ee(te),_=g.d=[],u=0;re[u]==(ne[u]||0);)++u;if(re[u]>(ne[u]||0)&&--l,x=o==null?o=ee.precision:s?o+(S(r)-S(i))+1:o,x<0)return new ee(0);if(x=x/p+2|0,u=0,O==1)for(d=0,re=re[0],x++;(u<T||d)&&x--;u++)C=d*f+(ne[u]||0),_[u]=C/re|0,d=C%re|0;else{for(d=f/(re[0]+1)|0,d>1&&(re=e(re,d),ne=e(ne,d),O=re.length,T=ne.length),w=O,v=ne.slice(0,O),y=v.length;y<O;)v[y++]=0;k=re.slice(),k.unshift(0),E=re[0],re[1]>=f/2&&++E;do d=0,c=t(re,v,O,y),c<0?(b=v[0],O!=y&&(b=b*f+(v[1]||0)),d=b/E|0,d>1?(d>=f&&(d=f-1),m=e(re,d),h=m.length,y=v.length,c=t(m,v,h,y),c==1&&(d--,n(m,O<h?k:re,h))):(d==0&&(c=d=1),m=re.slice()),h=m.length,h<y&&m.unshift(0),n(v,m,y),c==-1&&(y=v.length,c=t(re,v,O,y),c<1&&(d++,n(v,O<y?k:re,y))),y=v.length):c===0&&(d++,v=[0]),_[u++]=d,c&&v[0]?v[y++]=ne[w]||0:(v=[ne[w]],y=1);while((w++<T||v[0]!==void 0)&&x--)}return _[0]||_.shift(),g.e=l,D(g,s?o+S(g)+1:o)}})();function x(e,t){var n,r,a,o,c,u,f=0,p=0,m=e.constructor,h=m.precision;if(S(e)>16)throw Error(s+S(e));if(!e.s)return new m(d);for(t==null?(i=!1,u=h):u=t,c=new m(.03125);e.abs().gte(.1);)e=e.times(c),p+=5;for(r=Math.log(l(2,p))/Math.LN10*2+5|0,u+=r,n=a=o=new m(d),m.precision=u;;){if(a=D(a.times(e),u),n=n.times(++f),c=o.plus(b(a,n,u)),y(c.d).slice(0,u)===y(o.d).slice(0,u)){for(;p--;)o=D(o.times(o),u);return m.precision=h,t==null?(i=!0,D(o,h)):o}o=c}}function S(e){for(var t=e.e*p,n=e.d[0];n>=10;n/=10)t++;return t}function C(e,t,n){if(t>e.LN10.sd())throw i=!0,n&&(e.precision=n),Error(a+`LN10 precision limit exceeded`);return D(new e(e.LN10),t)}function w(e){for(var t=``;e--;)t+=`0`;return t}function T(e,t){var n,r,o,s,c,l,u,f,p,m=1,h=10,g=e,_=g.d,v=g.constructor,x=v.precision;if(g.s<1)throw Error(a+(g.s?`NaN`:`-Infinity`));if(g.eq(d))return new v(0);if(t==null?(i=!1,f=x):f=t,g.eq(10))return t??(i=!0),C(v,f);if(f+=h,v.precision=f,n=y(_),r=n.charAt(0),s=S(g),Math.abs(s)<0x5543df729c000){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)g=g.times(e),n=y(g.d),r=n.charAt(0),m++;s=S(g),r>1?(g=new v(`0.`+n),s++):g=new v(r+`.`+n.slice(1))}else return u=C(v,f+2,x).times(s+``),g=T(new v(r+`.`+n.slice(1)),f-h).plus(u),v.precision=x,t==null?(i=!0,D(g,x)):g;for(l=c=g=b(g.minus(d),g.plus(d),f),p=D(g.times(g),f),o=3;;){if(c=D(c.times(p),f),u=l.plus(b(c,new v(o),f)),y(u.d).slice(0,f)===y(l.d).slice(0,f))return l=l.times(2),s!==0&&(l=l.plus(C(v,f+2,x).times(s+``))),l=b(l,new v(m),f),v.precision=x,t==null?(i=!0,D(l,x)):l;l=u,o+=2}}function E(e,t){var n,r,a;for((n=t.indexOf(`.`))>-1&&(t=t.replace(`.`,``)),(r=t.search(/e/i))>0?(n<0&&(n=r),n+=+t.slice(r+1),t=t.substring(0,r)):n<0&&(n=t.length),r=0;t.charCodeAt(r)===48;)++r;for(a=t.length;t.charCodeAt(a-1)===48;)--a;if(t=t.slice(r,a),t){if(a-=r,n=n-r-1,e.e=c(n/p),e.d=[],r=(n+1)%p,n<0&&(r+=p),r<a){for(r&&e.d.push(+t.slice(0,r)),a-=p;r<a;)e.d.push(+t.slice(r,r+=p));t=t.slice(r),r=p-t.length}else r-=a;for(;r--;)t+=`0`;if(e.d.push(+t),i&&(e.e>h||e.e<-h))throw Error(s+n)}else e.s=0,e.e=0,e.d=[0];return e}function D(e,t,n){var r,a,o,u,d,m,g,_,v=e.d;for(u=1,o=v[0];o>=10;o/=10)u++;if(r=t-u,r<0)r+=p,a=t,g=v[_=0];else{if(_=Math.ceil((r+1)/p),o=v.length,_>=o)return e;for(g=o=v[_],u=1;o>=10;o/=10)u++;r%=p,a=r-p+u}if(n!==void 0&&(o=l(10,u-a-1),d=g/o%10|0,m=t<0||v[_+1]!==void 0||g%o,m=n<4?(d||m)&&(n==0||n==(e.s<0?3:2)):d>5||d==5&&(n==4||m||n==6&&(r>0?a>0?g/l(10,u-a):0:v[_-1])%10&1||n==(e.s<0?8:7))),t<1||!v[0])return m?(o=S(e),v.length=1,t=t-o-1,v[0]=l(10,(p-t%p)%p),e.e=c(-t/p)||0):(v.length=1,v[0]=e.e=e.s=0),e;if(r==0?(v.length=_,o=1,_--):(v.length=_+1,o=l(10,p-r),v[_]=a>0?(g/l(10,u-a)%l(10,a)|0)*o:0),m)for(;;)if(_==0){(v[0]+=o)==f&&(v[0]=1,++e.e);break}else{if(v[_]+=o,v[_]!=f)break;v[_--]=0,o=1}for(r=v.length;v[--r]===0;)v.pop();if(i&&(e.e>h||e.e<-h))throw Error(s+S(e));return e}function O(e,t){var n,r,a,o,s,c,l,u,d,m,h=e.constructor,g=h.precision;if(!e.s||!t.s)return t.s?t.s=-t.s:t=new h(e),i?D(t,g):t;if(l=e.d,m=t.d,r=t.e,u=e.e,l=l.slice(),s=u-r,s){for(d=s<0,d?(n=l,s=-s,c=m.length):(n=m,r=u,c=l.length),a=Math.max(Math.ceil(g/p),c)+2,s>a&&(s=a,n.length=1),n.reverse(),a=s;a--;)n.push(0);n.reverse()}else{for(a=l.length,c=m.length,d=a<c,d&&(c=a),a=0;a<c;a++)if(l[a]!=m[a]){d=l[a]<m[a];break}s=0}for(d&&(n=l,l=m,m=n,t.s=-t.s),c=l.length,a=m.length-c;a>0;--a)l[c++]=0;for(a=m.length;a>s;){if(l[--a]<m[a]){for(o=a;o&&l[--o]===0;)l[o]=f-1;--l[o],l[a]+=f}l[a]-=m[a]}for(;l[--c]===0;)l.pop();for(;l[0]===0;l.shift())--r;return l[0]?(t.d=l,t.e=r,i?D(t,g):t):new h(0)}function k(e,t,n){var r,i=S(e),a=y(e.d),o=a.length;return t?(n&&(r=n-o)>0?a=a.charAt(0)+`.`+a.slice(1)+w(r):o>1&&(a=a.charAt(0)+`.`+a.slice(1)),a=a+(i<0?`e`:`e+`)+i):i<0?(a=`0.`+w(-i-1)+a,n&&(r=n-o)>0&&(a+=w(r))):i>=o?(a+=w(i+1-o),n&&(r=n-i-1)>0&&(a=a+`.`+w(r))):((r=i+1)<o&&(a=a.slice(0,r)+`.`+a.slice(r)),n&&(r=n-o)>0&&(i+1===o&&(a+=`.`),a+=w(r))),e.s<0?`-`+a:a}function ee(e,t){if(e.length>t)return e.length=t,!0}function te(e){var t,n,r;function i(e){var t=this;if(!(t instanceof i))return new i(e);if(t.constructor=i,e instanceof i){t.s=e.s,t.e=e.e,t.d=(e=e.d)?e.slice():e;return}if(typeof e==`number`){if(e*0!=0)throw Error(o+e);if(e>0)t.s=1;else if(e<0)e=-e,t.s=-1;else{t.s=0,t.e=0,t.d=[0];return}if(e===~~e&&e<1e7){t.e=0,t.d=[e];return}return E(t,e.toString())}else if(typeof e!=`string`)throw Error(o+e);if(e.charCodeAt(0)===45?(e=e.slice(1),t.s=-1):t.s=1,u.test(e))E(t,e);else throw Error(o+e)}if(i.prototype=g,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.clone=te,i.config=i.set=ne,e===void 0&&(e={}),e)for(r=[`precision`,`rounding`,`toExpNeg`,`toExpPos`,`LN10`],t=0;t<r.length;)e.hasOwnProperty(n=r[t++])||(e[n]=this[n]);return i.config(e),i}function ne(e){if(!e||typeof e!=`object`)throw Error(a+`Object expected`);var t,r,i,s=[`precision`,1,n,`rounding`,0,8,`toExpNeg`,-1/0,0,`toExpPos`,0,1/0];for(t=0;t<s.length;t+=3)if((i=e[r=s[t]])!==void 0)if(c(i)===i&&i>=s[t+1]&&i<=s[t+2])this[r]=i;else throw Error(o+r+`: `+i);if((i=e[r=`LN10`])!==void 0)if(i==Math.LN10)this[r]=new this(i);else throw Error(o+r+`: `+i);return this}r=te(r),r.default=r.Decimal=r,d=new r(1),typeof define==`function`&&define.amd?define(function(){return r}):t!==void 0&&t.exports?t.exports=r:(e||=typeof self<`u`&&self&&self.self==self?self:Function(`return this`)(),e.Decimal=r)})(e)}))());function mA(e){return e===0?1:Math.floor(new pA.default(e).abs().log(10).toNumber())+1}function hA(e,t,n){for(var r=new pA.default(e),i=0,a=[];r.lt(t)&&i<1e5;)a.push(r.toNumber()),r=r.add(n),i++;return a}var gA=e=>{var[t,n]=e,[r,i]=[t,n];return t>n&&([r,i]=[n,t]),[r,i]},_A=(e,t,n)=>{if(e.lte(0))return new pA.default(0);var r=mA(e.toNumber()),i=new pA.default(10).pow(r),a=e.div(i),o=r===1?.1:.05,s=new pA.default(Math.ceil(a.div(o).toNumber())).add(n).mul(o).mul(i);return t?new pA.default(s.toNumber()):new pA.default(Math.ceil(s.toNumber()))},vA=(e,t,n)=>{if(e.lte(0))return new pA.default(0);var r=[1,2,2.5,5],i=e.toNumber(),a=Math.floor(new pA.default(i).abs().log(10).toNumber()),o=new pA.default(10).pow(a),s=e.div(o).toNumber(),c=r.findIndex(e=>e>=s-1e-10);if(c===-1&&(o=o.mul(10),c=0),c+=n,c>=r.length){var l=Math.floor(c/r.length);c%=r.length,o=o.mul(new pA.default(10).pow(l))}var u=new pA.default(r[c]??1).mul(o);return t?u:new pA.default(Math.ceil(u.toNumber()))},yA=(e,t,n)=>{var r=new pA.default(1),i=new pA.default(e);if(!i.isint()&&n){var a=Math.abs(e);a<1?(r=new pA.default(10).pow(mA(e)-1),i=new pA.default(Math.floor(i.div(r).toNumber())).mul(r)):a>1&&(i=new pA.default(Math.floor(e)))}else e===0?i=new pA.default(Math.floor((t-1)/2)):n||(i=new pA.default(Math.floor(e)));for(var o=Math.floor((t-1)/2),s=[],c=0;c<t;c++)s.push(i.add(new pA.default(c-o).mul(r)).toNumber());return s},bA=function(e,t,n,r){var i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:0,a=arguments.length>5&&arguments[5]!==void 0?arguments[5]:_A;if(!Number.isFinite((t-e)/(n-1)))return{step:new pA.default(0),tickMin:new pA.default(0),tickMax:new pA.default(0)};var o=a(new pA.default(t).sub(e).div(n-1),r,i),s;e<=0&&t>=0?s=new pA.default(0):(s=new pA.default(e).add(t).div(2),s=s.sub(new pA.default(s).mod(o)));var c=Math.ceil(s.sub(e).div(o).toNumber()),l=Math.ceil(new pA.default(t).sub(s).div(o).toNumber()),u=c+l+1;return u>n?bA(e,t,n,r,i+1,a):(u<n&&(l=t>0?l+(n-u):l,c=t>0?c:c+(n-u)),{step:o,tickMin:s.sub(new pA.default(c).mul(o)),tickMax:s.add(new pA.default(l).mul(o))})},xA=function(e){var[t,n]=e,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:6,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:`auto`,o=Math.max(r,2),[s,c]=gA([t,n]);if(s===-1/0||c===1/0){var l=c===1/0?[s,...Array(r-1).fill(1/0)]:[...Array(r-1).fill(-1/0),c];return t>n?l.reverse():l}if(s===c)return yA(s,r,i);var{step:u,tickMin:d,tickMax:f}=bA(s,c,o,i,0,a===`snap125`?vA:_A),p=hA(d,f.add(new pA.default(.1).mul(u)),u);return t>n?p.reverse():p},SA=function(e,t){var[n,r]=e,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:`auto`,[o,s]=gA([n,r]);if(o===-1/0||s===1/0)return[n,r];if(o===s)return[o];var c=a===`snap125`?vA:_A,l=Math.max(t,2),u=c(new pA.default(s).sub(o).div(l-1),i,0),d=[...hA(new pA.default(o),new pA.default(s),u),s];return i===!1&&(d=d.map(e=>Math.round(e))),n>r?d.reverse():d},CA=e=>e.rootProps.maxBarSize,wA=e=>e.rootProps.barGap,TA=e=>e.rootProps.barCategoryGap,EA=e=>e.rootProps.barSize,DA=e=>e.rootProps.stackOffset,OA=e=>e.rootProps.reverseStackOrder,kA=e=>e.options.chartName,AA=e=>e.rootProps.syncId,jA=e=>e.rootProps.syncMethod,MA=e=>e.options.eventEmitter,NA=e=>e.rootProps.baseValue,PA={grid:-100,barBackground:-50,area:100,cursorRectangle:200,bar:300,line:400,axis:500,scatter:600,activeBar:1e3,cursorLine:1100,activeDot:1200,label:2e3},FA={allowDecimals:!1,allowDuplicatedCategory:!0,allowDataOverflow:!1,angle:0,angleAxisId:0,axisLine:!0,axisLineType:`polygon`,cx:0,cy:0,hide:!1,includeHidden:!1,label:!1,niceTicks:`auto`,orientation:`outer`,reversed:!1,scale:`auto`,tick:!0,tickLine:!0,tickSize:8,type:`auto`,zIndex:PA.axis},IA={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:!0,angle:0,axisLine:!0,includeHidden:!1,hide:!1,niceTicks:`auto`,label:!1,orientation:`right`,radiusAxisId:0,reversed:!1,scale:`auto`,stroke:`#ccc`,tick:!0,tickCount:5,tickLine:!0,type:`auto`,zIndex:PA.axis},LA=(e,t)=>{if(!(!e||!t))return e!=null&&e.reversed?[t[1],t[0]]:t};function RA(e,t,n){if(n!==`auto`)return n;if(e!=null)return zE(e,t)?`category`:`number`}function zA(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function BA(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?zA(Object(n),!0).forEach(function(t){VA(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):zA(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function VA(e,t,n){return(t=HA(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function HA(e){var t=UA(e,`string`);return typeof t==`symbol`?t:t+``}function UA(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var WA={allowDataOverflow:FA.allowDataOverflow,allowDecimals:FA.allowDecimals,allowDuplicatedCategory:!1,dataKey:void 0,domain:void 0,id:FA.angleAxisId,includeHidden:!1,name:void 0,reversed:FA.reversed,scale:FA.scale,tick:FA.tick,tickCount:void 0,ticks:void 0,type:FA.type,unit:void 0,niceTicks:`auto`},GA={allowDataOverflow:IA.allowDataOverflow,allowDecimals:IA.allowDecimals,allowDuplicatedCategory:IA.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:IA.radiusAxisId,includeHidden:IA.includeHidden,name:void 0,reversed:IA.reversed,scale:IA.scale,tick:IA.tick,tickCount:IA.tickCount,ticks:void 0,type:IA.type,unit:void 0,niceTicks:`auto`},KA=W([(e,t)=>{if(t!=null)return e.polarAxis.angleAxis[t]},OD],(e,t)=>{if(e!=null)return e;var n=RA(t,`angleAxis`,WA.type)??`category`;return BA(BA({},WA),{},{type:n})}),qA=W([(e,t)=>e.polarAxis.radiusAxis[t],OD],(e,t)=>{if(e!=null)return e;var n=RA(t,`radiusAxis`,GA.type)??`category`;return BA(BA({},GA),{},{type:n})}),JA=e=>e.polarOptions,YA=W([XE,ZE,aD],kk),XA=W([JA,YA],(e,t)=>{if(e!=null)return JS(e.innerRadius,t,0)}),ZA=W([JA,YA],(e,t)=>{if(e!=null)return JS(e.outerRadius,t,t*.8)}),QA=W([JA],e=>{if(e==null)return[0,0];var{startAngle:t,endAngle:n}=e;return[t,n]});W([KA,QA],LA);var $A=W([YA,XA,ZA],(e,t,n)=>{if(!(e==null||t==null||n==null))return[t,n]});W([qA,$A],LA);var ej=W([TD,JA,XA,ZA,XE,ZE],(e,t,n,r,i,a)=>{if(!(e!==`centric`&&e!==`radial`||t==null||n==null||r==null)){var{cx:o,cy:s,startAngle:c,endAngle:l}=t;return{cx:JS(o,i,i/2),cy:JS(s,a,a/2),innerRadius:n,outerRadius:r,startAngle:c,endAngle:l,clockWise:!1}}}),tj=(e,t)=>t,nj=(e,t,n)=>n;function rj(e){return e?.id}function ij(e,t,n){var{chartData:r=[]}=t,{allowDuplicatedCategory:i,dataKey:a}=n,o=new Map;return e.forEach(e=>{var t=e.data??r;if(!(t==null||t.length===0)){var n=rj(e);t.forEach((t,r)=>{var s=a==null||i?r:String(RE(t,a,null)),c=RE(t,e.dataKey,0),l=o.has(s)?o.get(s):{};Object.assign(l,{[n]:c}),o.set(s,l)})}}),Array.from(o.values())}function aj(e){return`stackId`in e&&e.stackId!=null&&e.dataKey!=null}var oj=(e,t)=>e===t?!0:e==null||t==null?!1:e[0]===t[0]&&e[1]===t[1];function sj(e,t){return Array.isArray(e)&&Array.isArray(t)&&e.length===0&&t.length===0?!0:e===t}function cj(e,t){if(e.length===t.length){for(var n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}return!1}var lj=e=>{var t=TD(e);return t===`horizontal`?`xAxis`:t===`vertical`?`yAxis`:t===`centric`?`angleAxis`:`radiusAxis`},uj=e=>e.tooltip.settings.axisId;function dj(e){if(e!=null){var t=e.ticks,n=e.bandwidth,r=e.range(),i=[Math.min(...r),Math.max(...r)];return{domain:()=>e.domain(),range:function(e){function t(){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}(()=>i),rangeMin:()=>i[0],rangeMax:()=>i[1],isInRange(e){var t=i[0],n=i[1];return t<=n?e>=t&&e<=n:e>=n&&e<=t},bandwidth:n?()=>n.call(e):void 0,ticks:t?n=>t.call(e,n):void 0,map:(t,n)=>{var r=e(t);if(r!=null){if(e.bandwidth&&n!=null&&n.position){var i=e.bandwidth();switch(n.position){case`middle`:r+=i/2;break;case`end`:r+=i;break;default:break}}return r}}}}}var fj=(e,t)=>{if(t!=null)switch(e){case`linear`:if(!lA(t)){for(var n,r,i=0;i<t.length;i++){var a=t[i];PE(a)&&((n===void 0||a<n)&&(n=a),(r===void 0||a>r)&&(r=a))}return n!==void 0&&r!==void 0?[n,r]:void 0}return t;default:return t}};function pj(e,t){return e==null||t==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function mj(e,t){return e==null||t==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function hj(e){let t,n,r;e.length===2?(t=e===pj||e===mj?e:gj,n=e,r=e):(t=pj,n=(t,n)=>pj(e(t),n),r=(t,n)=>e(t)-n);function i(e,r,i=0,a=e.length){if(i<a){if(t(r,r)!==0)return a;do{let t=i+a>>>1;n(e[t],r)<0?i=t+1:a=t}while(i<a)}return i}function a(e,r,i=0,a=e.length){if(i<a){if(t(r,r)!==0)return a;do{let t=i+a>>>1;n(e[t],r)<=0?i=t+1:a=t}while(i<a)}return i}function o(e,t,n=0,a=e.length){let o=i(e,t,n,a-1);return o>n&&r(e[o-1],t)>-r(e[o],t)?o-1:o}return{left:i,center:o,right:a}}function gj(){return 0}function _j(e){return e===null?NaN:+e}function*vj(e,t){if(t===void 0)for(let t of e)t!=null&&(t=+t)>=t&&(yield t);else{let n=-1;for(let r of e)(r=t(r,++n,e))!=null&&(r=+r)>=r&&(yield r)}}var yj=hj(pj),bj=yj.right;yj.left,hj(_j).center;var xj=class extends Map{constructor(e,t=Tj){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:t}}),e!=null)for(let[t,n]of e)this.set(t,n)}get(e){return super.get(Sj(this,e))}has(e){return super.has(Sj(this,e))}set(e,t){return super.set(Cj(this,e),t)}delete(e){return super.delete(wj(this,e))}};function Sj({_intern:e,_key:t},n){let r=t(n);return e.has(r)?e.get(r):n}function Cj({_intern:e,_key:t},n){let r=t(n);return e.has(r)?e.get(r):(e.set(r,n),n)}function wj({_intern:e,_key:t},n){let r=t(n);return e.has(r)&&(n=e.get(r),e.delete(r)),n}function Tj(e){return typeof e==`object`&&e?e.valueOf():e}function Ej(e=pj){if(e===pj)return Dj;if(typeof e!=`function`)throw TypeError(`compare is not a function`);return(t,n)=>{let r=e(t,n);return r||r===0?r:(e(n,n)===0)-(e(t,t)===0)}}function Dj(e,t){return(e==null||!(e>=e))-(t==null||!(t>=t))||(e<t?-1:+(e>t))}var Oj=Math.sqrt(50),kj=Math.sqrt(10),Aj=Math.sqrt(2);function jj(e,t,n){let r=(t-e)/Math.max(0,n),i=Math.floor(Math.log10(r)),a=r/10**i,o=a>=Oj?10:a>=kj?5:a>=Aj?2:1,s,c,l;return i<0?(l=10**-i/o,s=Math.round(e*l),c=Math.round(t*l),s/l<e&&++s,c/l>t&&--c,l=-l):(l=10**i*o,s=Math.round(e/l),c=Math.round(t/l),s*l<e&&++s,c*l>t&&--c),c<s&&.5<=n&&n<2?jj(e,t,n*2):[s,c,l]}function Mj(e,t,n){if(t=+t,e=+e,n=+n,!(n>0))return[];if(e===t)return[e];let r=t<e,[i,a,o]=r?jj(t,e,n):jj(e,t,n);if(!(a>=i))return[];let s=a-i+1,c=Array(s);if(r)if(o<0)for(let e=0;e<s;++e)c[e]=(a-e)/-o;else for(let e=0;e<s;++e)c[e]=(a-e)*o;else if(o<0)for(let e=0;e<s;++e)c[e]=(i+e)/-o;else for(let e=0;e<s;++e)c[e]=(i+e)*o;return c}function Nj(e,t,n){return t=+t,e=+e,n=+n,jj(e,t,n)[2]}function Pj(e,t,n){t=+t,e=+e,n=+n;let r=t<e,i=r?Nj(t,e,n):Nj(e,t,n);return(r?-1:1)*(i<0?1/-i:i)}function Fj(e,t){let n;if(t===void 0)for(let t of e)t!=null&&(n<t||n===void 0&&t>=t)&&(n=t);else{let r=-1;for(let i of e)(i=t(i,++r,e))!=null&&(n<i||n===void 0&&i>=i)&&(n=i)}return n}function Ij(e,t){let n;if(t===void 0)for(let t of e)t!=null&&(n>t||n===void 0&&t>=t)&&(n=t);else{let r=-1;for(let i of e)(i=t(i,++r,e))!=null&&(n>i||n===void 0&&i>=i)&&(n=i)}return n}function Lj(e,t,n=0,r=1/0,i){if(t=Math.floor(t),n=Math.floor(Math.max(0,n)),r=Math.floor(Math.min(e.length-1,r)),!(n<=t&&t<=r))return e;for(i=i===void 0?Dj:Ej(i);r>n;){if(r-n>600){let a=r-n+1,o=t-n+1,s=Math.log(a),c=.5*Math.exp(2*s/3),l=.5*Math.sqrt(s*c*(a-c)/a)*(o-a/2<0?-1:1),u=Math.max(n,Math.floor(t-o*c/a+l)),d=Math.min(r,Math.floor(t+(a-o)*c/a+l));Lj(e,t,u,d,i)}let a=e[t],o=n,s=r;for(Rj(e,n,t),i(e[r],a)>0&&Rj(e,n,r);o<s;){for(Rj(e,o,s),++o,--s;i(e[o],a)<0;)++o;for(;i(e[s],a)>0;)--s}i(e[n],a)===0?Rj(e,n,s):(++s,Rj(e,s,r)),s<=t&&(n=s+1),t<=s&&(r=s-1)}return e}function Rj(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}function zj(e,t,n){if(e=Float64Array.from(vj(e,n)),!(!(r=e.length)||isNaN(t=+t))){if(t<=0||r<2)return Ij(e);if(t>=1)return Fj(e);var r,i=(r-1)*t,a=Math.floor(i),o=Fj(Lj(e,a).subarray(0,a+1));return o+(Ij(e.subarray(a+1))-o)*(i-a)}}function Bj(e,t,n=_j){if(!(!(r=e.length)||isNaN(t=+t))){if(t<=0||r<2)return+n(e[0],0,e);if(t>=1)return+n(e[r-1],r-1,e);var r,i=(r-1)*t,a=Math.floor(i),o=+n(e[a],a,e);return o+(+n(e[a+1],a+1,e)-o)*(i-a)}}function Vj(e,t,n){e=+e,t=+t,n=(i=arguments.length)<2?(t=e,e=0,1):i<3?1:+n;for(var r=-1,i=Math.max(0,Math.ceil((t-e)/n))|0,a=Array(i);++r<i;)a[r]=e+r*n;return a}function Hj(e,t){switch(arguments.length){case 0:break;case 1:this.range(e);break;default:this.range(t).domain(e);break}return this}function Uj(e,t){switch(arguments.length){case 0:break;case 1:typeof e==`function`?this.interpolator(e):this.range(e);break;default:this.domain(e),typeof t==`function`?this.interpolator(t):this.range(t);break}return this}var Wj=Symbol(`implicit`);function Gj(){var e=new xj,t=[],n=[],r=Wj;function i(i){let a=e.get(i);if(a===void 0){if(r!==Wj)return r;e.set(i,a=t.push(i)-1)}return n[a%n.length]}return i.domain=function(n){if(!arguments.length)return t.slice();t=[],e=new xj;for(let r of n)e.has(r)||e.set(r,t.push(r)-1);return i},i.range=function(e){return arguments.length?(n=Array.from(e),i):n.slice()},i.unknown=function(e){return arguments.length?(r=e,i):r},i.copy=function(){return Gj(t,n).unknown(r)},Hj.apply(i,arguments),i}function Kj(){var e=Gj().unknown(void 0),t=e.domain,n=e.range,r=0,i=1,a,o,s=!1,c=0,l=0,u=.5;delete e.unknown;function d(){var e=t().length,d=i<r,f=d?i:r,p=d?r:i;a=(p-f)/Math.max(1,e-c+l*2),s&&(a=Math.floor(a)),f+=(p-f-a*(e-c))*u,o=a*(1-c),s&&(f=Math.round(f),o=Math.round(o));var m=Vj(e).map(function(e){return f+a*e});return n(d?m.reverse():m)}return e.domain=function(e){return arguments.length?(t(e),d()):t()},e.range=function(e){return arguments.length?([r,i]=e,r=+r,i=+i,d()):[r,i]},e.rangeRound=function(e){return[r,i]=e,r=+r,i=+i,s=!0,d()},e.bandwidth=function(){return o},e.step=function(){return a},e.round=function(e){return arguments.length?(s=!!e,d()):s},e.padding=function(e){return arguments.length?(c=Math.min(1,l=+e),d()):c},e.paddingInner=function(e){return arguments.length?(c=Math.min(1,e),d()):c},e.paddingOuter=function(e){return arguments.length?(l=+e,d()):l},e.align=function(e){return arguments.length?(u=Math.max(0,Math.min(1,e)),d()):u},e.copy=function(){return Kj(t(),[r,i]).round(s).paddingInner(c).paddingOuter(l).align(u)},Hj.apply(d(),arguments)}function qj(e){var t=e.copy;return e.padding=e.paddingOuter,delete e.paddingInner,delete e.paddingOuter,e.copy=function(){return qj(t())},e}function Jj(){return qj(Kj.apply(null,arguments).paddingInner(1))}function Yj(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Xj(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function Zj(){}var Qj=.7,$j=1/Qj,eM=`\\s*([+-]?\\d+)\\s*`,tM=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*`,nM=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*`,rM=/^#([0-9a-f]{3,8})$/,iM=RegExp(`^rgb\\(${eM},${eM},${eM}\\)$`),aM=RegExp(`^rgb\\(${nM},${nM},${nM}\\)$`),oM=RegExp(`^rgba\\(${eM},${eM},${eM},${tM}\\)$`),sM=RegExp(`^rgba\\(${nM},${nM},${nM},${tM}\\)$`),cM=RegExp(`^hsl\\(${tM},${nM},${nM}\\)$`),lM=RegExp(`^hsla\\(${tM},${nM},${nM},${tM}\\)$`),uM={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Yj(Zj,hM,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:dM,formatHex:dM,formatHex8:fM,formatHsl:pM,formatRgb:mM,toString:mM});function dM(){return this.rgb().formatHex()}function fM(){return this.rgb().formatHex8()}function pM(){return OM(this).formatHsl()}function mM(){return this.rgb().formatRgb()}function hM(e){var t,n;return e=(e+``).trim().toLowerCase(),(t=rM.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?gM(t):n===3?new bM(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?_M(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?_M(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=iM.exec(e))?new bM(t[1],t[2],t[3],1):(t=aM.exec(e))?new bM(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=oM.exec(e))?_M(t[1],t[2],t[3],t[4]):(t=sM.exec(e))?_M(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=cM.exec(e))?DM(t[1],t[2]/100,t[3]/100,1):(t=lM.exec(e))?DM(t[1],t[2]/100,t[3]/100,t[4]):uM.hasOwnProperty(e)?gM(uM[e]):e===`transparent`?new bM(NaN,NaN,NaN,0):null}function gM(e){return new bM(e>>16&255,e>>8&255,e&255,1)}function _M(e,t,n,r){return r<=0&&(e=t=n=NaN),new bM(e,t,n,r)}function vM(e){return e instanceof Zj||(e=hM(e)),e?(e=e.rgb(),new bM(e.r,e.g,e.b,e.opacity)):new bM}function yM(e,t,n,r){return arguments.length===1?vM(e):new bM(e,t,n,r??1)}function bM(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Yj(bM,yM,Xj(Zj,{brighter(e){return e=e==null?$j:$j**+e,new bM(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Qj:Qj**+e,new bM(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new bM(TM(this.r),TM(this.g),TM(this.b),wM(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:xM,formatHex:xM,formatHex8:SM,formatRgb:CM,toString:CM}));function xM(){return`#${EM(this.r)}${EM(this.g)}${EM(this.b)}`}function SM(){return`#${EM(this.r)}${EM(this.g)}${EM(this.b)}${EM((isNaN(this.opacity)?1:this.opacity)*255)}`}function CM(){let e=wM(this.opacity);return`${e===1?`rgb(`:`rgba(`}${TM(this.r)}, ${TM(this.g)}, ${TM(this.b)}${e===1?`)`:`, ${e})`}`}function wM(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function TM(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function EM(e){return e=TM(e),(e<16?`0`:``)+e.toString(16)}function DM(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new AM(e,t,n,r)}function OM(e){if(e instanceof AM)return new AM(e.h,e.s,e.l,e.opacity);if(e instanceof Zj||(e=hM(e)),!e)return new AM;if(e instanceof AM)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=NaN,s=a-i,c=(a+i)/2;return s?(o=t===a?(n-r)/s+(n<r)*6:n===a?(r-t)/s+2:(t-n)/s+4,s/=c<.5?a+i:2-a-i,o*=60):s=c>0&&c<1?0:o,new AM(o,s,c,e.opacity)}function kM(e,t,n,r){return arguments.length===1?OM(e):new AM(e,t,n,r??1)}function AM(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Yj(AM,kM,Xj(Zj,{brighter(e){return e=e==null?$j:$j**+e,new AM(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Qj:Qj**+e,new AM(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new bM(NM(e>=240?e-240:e+120,i,r),NM(e,i,r),NM(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new AM(jM(this.h),MM(this.s),MM(this.l),wM(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let e=wM(this.opacity);return`${e===1?`hsl(`:`hsla(`}${jM(this.h)}, ${MM(this.s)*100}%, ${MM(this.l)*100}%${e===1?`)`:`, ${e})`}`}}));function jM(e){return e=(e||0)%360,e<0?e+360:e}function MM(e){return Math.max(0,Math.min(1,e||0))}function NM(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}var PM=e=>()=>e;function FM(e,t){return function(n){return e+n*t}}function IM(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function LM(e){return(e=+e)==1?RM:function(t,n){return n-t?IM(t,n,e):PM(isNaN(t)?n:t)}}function RM(e,t){var n=t-e;return n?FM(e,n):PM(isNaN(e)?t:e)}var zM=(function e(t){var n=LM(t);function r(e,t){var r=n((e=yM(e)).r,(t=yM(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=RM(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=a(t),e.opacity=o(t),e+``}}return r.gamma=e,r})(1);function BM(e,t){t||=[];var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(a){for(i=0;i<n;++i)r[i]=e[i]*(1-a)+t[i]*a;return r}}function VM(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function HM(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,i=Array(r),a=Array(n),o;for(o=0;o<r;++o)i[o]=ZM(e[o],t[o]);for(;o<n;++o)a[o]=t[o];return function(e){for(o=0;o<r;++o)a[o]=i[o](e);return a}}function UM(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function WM(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function GM(e,t){var n={},r={},i;for(i in(typeof e!=`object`||!e)&&(e={}),(typeof t!=`object`||!t)&&(t={}),t)i in e?n[i]=ZM(e[i],t[i]):r[i]=t[i];return function(e){for(i in n)r[i]=n[i](e);return r}}var KM=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,qM=new RegExp(KM.source,`g`);function JM(e){return function(){return e}}function YM(e){return function(t){return e(t)+``}}function XM(e,t){var n=KM.lastIndex=qM.lastIndex=0,r,i,a,o=-1,s=[],c=[];for(e+=``,t+=``;(r=KM.exec(e))&&(i=qM.exec(t));)(a=i.index)>n&&(a=t.slice(n,a),s[o]?s[o]+=a:s[++o]=a),(r=r[0])===(i=i[0])?s[o]?s[o]+=i:s[++o]=i:(s[++o]=null,c.push({i:o,x:WM(r,i)})),n=qM.lastIndex;return n<t.length&&(a=t.slice(n),s[o]?s[o]+=a:s[++o]=a),s.length<2?c[0]?YM(c[0].x):JM(t):(t=c.length,function(e){for(var n=0,r;n<t;++n)s[(r=c[n]).i]=r.x(e);return s.join(``)})}function ZM(e,t){var n=typeof t,r;return t==null||n===`boolean`?PM(t):(n===`number`?WM:n===`string`?(r=hM(t))?(t=r,zM):XM:t instanceof hM?zM:t instanceof Date?UM:VM(t)?BM:Array.isArray(t)?HM:typeof t.valueOf!=`function`&&typeof t.toString!=`function`||isNaN(t)?GM:WM)(e,t)}function QM(e,t){return e=+e,t=+t,function(n){return Math.round(e*(1-n)+t*n)}}function $M(e,t){t===void 0&&(t=e,e=ZM);for(var n=0,r=t.length-1,i=t[0],a=Array(r<0?0:r);n<r;)a[n]=e(i,i=t[++n]);return function(e){var t=Math.max(0,Math.min(r-1,Math.floor(e*=r)));return a[t](e-t)}}function eN(e){return function(){return e}}function tN(e){return+e}var nN=[0,1];function rN(e){return e}function iN(e,t){return(t-=e=+e)?function(n){return(n-e)/t}:eN(isNaN(t)?NaN:.5)}function aN(e,t){var n;return e>t&&(n=e,e=t,t=n),function(n){return Math.max(e,Math.min(t,n))}}function oN(e,t,n){var r=e[0],i=e[1],a=t[0],o=t[1];return i<r?(r=iN(i,r),a=n(o,a)):(r=iN(r,i),a=n(a,o)),function(e){return a(r(e))}}function Foe(e,t,n){var r=Math.min(e.length,t.length)-1,i=Array(r),a=Array(r),o=-1;for(e[r]<e[0]&&(e=e.slice().reverse(),t=t.slice().reverse());++o<r;)i[o]=iN(e[o],e[o+1]),a[o]=n(t[o],t[o+1]);return function(t){var n=bj(e,t,1,r)-1;return a[n](i[n](t))}}function sN(e,t){return t.domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown())}function cN(){var e=nN,t=nN,n=ZM,r,i,a,o=rN,s,c,l;function u(){var n=Math.min(e.length,t.length);return o!==rN&&(o=aN(e[0],e[n-1])),s=n>2?Foe:oN,c=l=null,d}function d(i){return i==null||isNaN(i=+i)?a:(c||=s(e.map(r),t,n))(r(o(i)))}return d.invert=function(n){return o(i((l||=s(t,e.map(r),WM))(n)))},d.domain=function(t){return arguments.length?(e=Array.from(t,tN),u()):e.slice()},d.range=function(e){return arguments.length?(t=Array.from(e),u()):t.slice()},d.rangeRound=function(e){return t=Array.from(e),n=QM,u()},d.clamp=function(e){return arguments.length?(o=e?!0:rN,u()):o!==rN},d.interpolate=function(e){return arguments.length?(n=e,u()):n},d.unknown=function(e){return arguments.length?(a=e,d):a},function(e,t){return r=e,i=t,u()}}function lN(){return cN()(rN,rN)}function Ioe(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString(`en`).replace(/,/g,``):e.toString(10)}function uN(e,t){if(!isFinite(e)||e===0)return null;var n=(e=t?e.toExponential(t-1):e.toExponential()).indexOf(`e`),r=e.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+e.slice(n+1)]}function dN(e){return e=uN(Math.abs(e)),e?e[1]:NaN}function Loe(e,t){return function(n,r){for(var i=n.length,a=[],o=0,s=e[0],c=0;i>0&&s>0&&(c+s+1>r&&(s=Math.max(1,r-c)),a.push(n.substring(i-=s,i+s)),!((c+=s+1)>r));)s=e[o=(o+1)%e.length];return a.reverse().join(t)}}function Roe(e){return function(t){return t.replace(/[0-9]/g,function(t){return e[+t]})}}var zoe=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function fN(e){if(!(t=zoe.exec(e)))throw Error(`invalid format: `+e);var t;return new pN({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}fN.prototype=pN.prototype;function pN(e){this.fill=e.fill===void 0?` `:e.fill+``,this.align=e.align===void 0?`>`:e.align+``,this.sign=e.sign===void 0?`-`:e.sign+``,this.symbol=e.symbol===void 0?``:e.symbol+``,this.zero=!!e.zero,this.width=e.width===void 0?void 0:+e.width,this.comma=!!e.comma,this.precision=e.precision===void 0?void 0:+e.precision,this.trim=!!e.trim,this.type=e.type===void 0?``:e.type+``}pN.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?`0`:``)+(this.width===void 0?``:Math.max(1,this.width|0))+(this.comma?`,`:``)+(this.precision===void 0?``:`.`+Math.max(0,this.precision|0))+(this.trim?`~`:``)+this.type};function Boe(e){out:for(var t=e.length,n=1,r=-1,i;n<t;++n)switch(e[n]){case`.`:r=i=n;break;case`0`:r===0&&(r=n),i=n;break;default:if(!+e[n])break out;r>0&&(r=0);break}return r>0?e.slice(0,r)+e.slice(i+1):e}var mN;function Voe(e,t){var n=uN(e,t);if(!n)return mN=void 0,e.toPrecision(t);var r=n[0],i=n[1],a=i-(mN=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,o=r.length;return a===o?r:a>o?r+Array(a-o+1).join(`0`):a>0?r.slice(0,a)+`.`+r.slice(a):`0.`+Array(1-a).join(`0`)+uN(e,Math.max(0,t+a-1))[0]}function hN(e,t){var n=uN(e,t);if(!n)return e+``;var r=n[0],i=n[1];return i<0?`0.`+Array(-i).join(`0`)+r:r.length>i+1?r.slice(0,i+1)+`.`+r.slice(i+1):r+Array(i-r.length+2).join(`0`)}var gN={"%":(e,t)=>(e*100).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+``,d:Ioe,e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>hN(e*100,t),r:hN,s:Voe,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function _N(e){return e}var vN=Array.prototype.map,yN=[`y`,`z`,`a`,`f`,`p`,`n`,`µ`,`m`,``,`k`,`M`,`G`,`T`,`P`,`E`,`Z`,`Y`];function Hoe(e){var t=e.grouping===void 0||e.thousands===void 0?_N:Loe(vN.call(e.grouping,Number),e.thousands+``),n=e.currency===void 0?``:e.currency[0]+``,r=e.currency===void 0?``:e.currency[1]+``,i=e.decimal===void 0?`.`:e.decimal+``,a=e.numerals===void 0?_N:Roe(vN.call(e.numerals,String)),o=e.percent===void 0?`%`:e.percent+``,s=e.minus===void 0?`−`:e.minus+``,c=e.nan===void 0?`NaN`:e.nan+``;function l(e,l){e=fN(e);var u=e.fill,d=e.align,f=e.sign,p=e.symbol,m=e.zero,h=e.width,g=e.comma,_=e.precision,v=e.trim,y=e.type;y===`n`?(g=!0,y=`g`):gN[y]||(_===void 0&&(_=12),v=!0,y=`g`),(m||u===`0`&&d===`=`)&&(m=!0,u=`0`,d=`=`);var b=(l&&l.prefix!==void 0?l.prefix:``)+(p===`$`?n:p===`#`&&/[boxX]/.test(y)?`0`+y.toLowerCase():``),x=(p===`$`?r:/[%p]/.test(y)?o:``)+(l&&l.suffix!==void 0?l.suffix:``),S=gN[y],C=/[defgprs%]/.test(y);_=_===void 0?6:/[gprs]/.test(y)?Math.max(1,Math.min(21,_)):Math.max(0,Math.min(20,_));function w(e){var n=b,r=x,o,l,p;if(y===`c`)r=S(e)+r,e=``;else{e=+e;var w=e<0||1/e<0;if(e=isNaN(e)?c:S(Math.abs(e),_),v&&(e=Boe(e)),w&&+e==0&&f!==`+`&&(w=!1),n=(w?f===`(`?f:s:f===`-`||f===`(`?``:f)+n,r=(y===`s`&&!isNaN(e)&&mN!==void 0?yN[8+mN/3]:``)+r+(w&&f===`(`?`)`:``),C){for(o=-1,l=e.length;++o<l;)if(p=e.charCodeAt(o),48>p||p>57){r=(p===46?i+e.slice(o+1):e.slice(o))+r,e=e.slice(0,o);break}}}g&&!m&&(e=t(e,1/0));var T=n.length+e.length+r.length,E=T<h?Array(h-T+1).join(u):``;switch(g&&m&&(e=t(E+e,E.length?h-r.length:1/0),E=``),d){case`<`:e=n+e+r+E;break;case`=`:e=n+E+e+r;break;case`^`:e=E.slice(0,T=E.length>>1)+n+e+r+E.slice(T);break;default:e=E+n+e+r;break}return a(e)}return w.toString=function(){return e+``},w}function u(e,t){var n=Math.max(-8,Math.min(8,Math.floor(dN(t)/3)))*3,r=10**-n,i=l((e=fN(e),e.type=`f`,e),{suffix:yN[8+n/3]});return function(e){return i(r*e)}}return{format:l,formatPrefix:u}}var bN,xN,SN;Uoe({thousands:`,`,grouping:[3],currency:[`$`,``]});function Uoe(e){return bN=Hoe(e),xN=bN.format,SN=bN.formatPrefix,bN}function Woe(e){return Math.max(0,-dN(Math.abs(e)))}function Goe(e,t){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(dN(t)/3)))*3-dN(Math.abs(e)))}function Koe(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,dN(t)-dN(e))+1}function CN(e,t,n,r){var i=Pj(e,t,n),a;switch(r=fN(r??`,f`),r.type){case`s`:var o=Math.max(Math.abs(e),Math.abs(t));return r.precision==null&&!isNaN(a=Goe(i,o))&&(r.precision=a),SN(r,o);case``:case`e`:case`g`:case`p`:case`r`:r.precision==null&&!isNaN(a=Koe(i,Math.max(Math.abs(e),Math.abs(t))))&&(r.precision=a-(r.type===`e`));break;case`f`:case`%`:r.precision==null&&!isNaN(a=Woe(i))&&(r.precision=a-(r.type===`%`)*2);break}return xN(r)}function wN(e){var t=e.domain;return e.ticks=function(e){var n=t();return Mj(n[0],n[n.length-1],e??10)},e.tickFormat=function(e,n){var r=t();return CN(r[0],r[r.length-1],e??10,n)},e.nice=function(n){n??=10;var r=t(),i=0,a=r.length-1,o=r[i],s=r[a],c,l,u=10;for(s<o&&(l=o,o=s,s=l,l=i,i=a,a=l);u-- >0;){if(l=Nj(o,s,n),l===c)return r[i]=o,r[a]=s,t(r);if(l>0)o=Math.floor(o/l)*l,s=Math.ceil(s/l)*l;else if(l<0)o=Math.ceil(o*l)/l,s=Math.floor(s*l)/l;else break;c=l}return e},e}function TN(){var e=lN();return e.copy=function(){return sN(e,TN())},Hj.apply(e,arguments),wN(e)}function EN(e){var t;function n(e){return e==null||isNaN(e=+e)?t:e}return n.invert=n,n.domain=n.range=function(t){return arguments.length?(e=Array.from(t,tN),n):e.slice()},n.unknown=function(e){return arguments.length?(t=e,n):t},n.copy=function(){return EN(e).unknown(t)},e=arguments.length?Array.from(e,tN):[0,1],wN(n)}function DN(e,t){e=e.slice();var n=0,r=e.length-1,i=e[n],a=e[r],o;return a<i&&(o=n,n=r,r=o,o=i,i=a,a=o),e[n]=t.floor(i),e[r]=t.ceil(a),e}function ON(e){return Math.log(e)}function kN(e){return Math.exp(e)}function qoe(e){return-Math.log(-e)}function Joe(e){return-Math.exp(-e)}function Yoe(e){return isFinite(e)?+(`1e`+e):e<0?0:e}function Xoe(e){return e===10?Yoe:e===Math.E?Math.exp:t=>e**+t}function Zoe(e){return e===Math.E?Math.log:e===10&&Math.log10||e===2&&Math.log2||(e=Math.log(e),t=>Math.log(t)/e)}function AN(e){return(t,n)=>-e(-t,n)}function jN(e){let t=e(ON,kN),n=t.domain,r=10,i,a;function o(){return i=Zoe(r),a=Xoe(r),n()[0]<0?(i=AN(i),a=AN(a),e(qoe,Joe)):e(ON,kN),t}return t.base=function(e){return arguments.length?(r=+e,o()):r},t.domain=function(e){return arguments.length?(n(e),o()):n()},t.ticks=e=>{let t=n(),o=t[0],s=t[t.length-1],c=s<o;c&&([o,s]=[s,o]);let l=i(o),u=i(s),d,f,p=e==null?10:+e,m=[];if(!(r%1)&&u-l<p){if(l=Math.floor(l),u=Math.ceil(u),o>0){for(;l<=u;++l)for(d=1;d<r;++d)if(f=l<0?d/a(-l):d*a(l),!(f<o)){if(f>s)break;m.push(f)}}else for(;l<=u;++l)for(d=r-1;d>=1;--d)if(f=l>0?d/a(-l):d*a(l),!(f<o)){if(f>s)break;m.push(f)}m.length*2<p&&(m=Mj(o,s,p))}else m=Mj(l,u,Math.min(u-l,p)).map(a);return c?m.reverse():m},t.tickFormat=(e,n)=>{if(e??=10,n??=r===10?`s`:`,`,typeof n!=`function`&&(!(r%1)&&(n=fN(n)).precision==null&&(n.trim=!0),n=xN(n)),e===1/0)return n;let o=Math.max(1,r*e/t.ticks().length);return e=>{let t=e/a(Math.round(i(e)));return t*r<r-.5&&(t*=r),t<=o?n(e):``}},t.nice=()=>n(DN(n(),{floor:e=>a(Math.floor(i(e))),ceil:e=>a(Math.ceil(i(e)))})),t}function MN(){let e=jN(cN()).domain([1,10]);return e.copy=()=>sN(e,MN()).base(e.base()),Hj.apply(e,arguments),e}function NN(e){return function(t){return Math.sign(t)*Math.log1p(Math.abs(t/e))}}function PN(e){return function(t){return Math.sign(t)*Math.expm1(Math.abs(t))*e}}function FN(e){var t=1,n=e(NN(t),PN(t));return n.constant=function(n){return arguments.length?e(NN(t=+n),PN(t)):t},wN(n)}function IN(){var e=FN(cN());return e.copy=function(){return sN(e,IN()).constant(e.constant())},Hj.apply(e,arguments)}function LN(e){return function(t){return t<0?-((-t)**+e):t**+e}}function Qoe(e){return e<0?-Math.sqrt(-e):Math.sqrt(e)}function $oe(e){return e<0?-e*e:e*e}function RN(e){var t=e(rN,rN),n=1;function r(){return n===1?e(rN,rN):n===.5?e(Qoe,$oe):e(LN(n),LN(1/n))}return t.exponent=function(e){return arguments.length?(n=+e,r()):n},wN(t)}function zN(){var e=RN(cN());return e.copy=function(){return sN(e,zN()).exponent(e.exponent())},Hj.apply(e,arguments),e}function ese(){return zN.apply(null,arguments).exponent(.5)}function BN(e){return Math.sign(e)*e*e}function tse(e){return Math.sign(e)*Math.sqrt(Math.abs(e))}function VN(){var e=lN(),t=[0,1],n=!1,r;function i(t){var i=tse(e(t));return isNaN(i)?r:n?Math.round(i):i}return i.invert=function(t){return e.invert(BN(t))},i.domain=function(t){return arguments.length?(e.domain(t),i):e.domain()},i.range=function(n){return arguments.length?(e.range((t=Array.from(n,tN)).map(BN)),i):t.slice()},i.rangeRound=function(e){return i.range(e).round(!0)},i.round=function(e){return arguments.length?(n=!!e,i):n},i.clamp=function(t){return arguments.length?(e.clamp(t),i):e.clamp()},i.unknown=function(e){return arguments.length?(r=e,i):r},i.copy=function(){return VN(e.domain(),t).round(n).clamp(e.clamp()).unknown(r)},Hj.apply(i,arguments),wN(i)}function HN(){var e=[],t=[],n=[],r;function i(){var r=0,i=Math.max(1,t.length);for(n=Array(i-1);++r<i;)n[r-1]=Bj(e,r/i);return a}function a(e){return e==null||isNaN(e=+e)?r:t[bj(n,e)]}return a.invertExtent=function(r){var i=t.indexOf(r);return i<0?[NaN,NaN]:[i>0?n[i-1]:e[0],i<n.length?n[i]:e[e.length-1]]},a.domain=function(t){if(!arguments.length)return e.slice();e=[];for(let n of t)n!=null&&!isNaN(n=+n)&&e.push(n);return e.sort(pj),i()},a.range=function(e){return arguments.length?(t=Array.from(e),i()):t.slice()},a.unknown=function(e){return arguments.length?(r=e,a):r},a.quantiles=function(){return n.slice()},a.copy=function(){return HN().domain(e).range(t).unknown(r)},Hj.apply(a,arguments)}function UN(){var e=0,t=1,n=1,r=[.5],i=[0,1],a;function o(e){return e!=null&&e<=e?i[bj(r,e,0,n)]:a}function s(){var i=-1;for(r=Array(n);++i<n;)r[i]=((i+1)*t-(i-n)*e)/(n+1);return o}return o.domain=function(n){return arguments.length?([e,t]=n,e=+e,t=+t,s()):[e,t]},o.range=function(e){return arguments.length?(n=(i=Array.from(e)).length-1,s()):i.slice()},o.invertExtent=function(a){var o=i.indexOf(a);return o<0?[NaN,NaN]:o<1?[e,r[0]]:o>=n?[r[n-1],t]:[r[o-1],r[o]]},o.unknown=function(e){return arguments.length&&(a=e),o},o.thresholds=function(){return r.slice()},o.copy=function(){return UN().domain([e,t]).range(i).unknown(a)},Hj.apply(wN(o),arguments)}function WN(){var e=[.5],t=[0,1],n,r=1;function i(i){return i!=null&&i<=i?t[bj(e,i,0,r)]:n}return i.domain=function(n){return arguments.length?(e=Array.from(n),r=Math.min(e.length,t.length-1),i):e.slice()},i.range=function(n){return arguments.length?(t=Array.from(n),r=Math.min(e.length,t.length-1),i):t.slice()},i.invertExtent=function(n){var r=t.indexOf(n);return[e[r-1],e[r]]},i.unknown=function(e){return arguments.length?(n=e,i):n},i.copy=function(){return WN().domain(e).range(t).unknown(n)},Hj.apply(i,arguments)}var GN=new Date,KN=new Date;function qN(e,t,n,r){function i(t){return e(t=arguments.length===0?new Date:new Date(+t)),t}return i.floor=t=>(e(t=new Date(+t)),t),i.ceil=n=>(e(n=new Date(n-1)),t(n,1),e(n),n),i.round=e=>{let t=i(e),n=i.ceil(e);return e-t<n-e?t:n},i.offset=(e,n)=>(t(e=new Date(+e),n==null?1:Math.floor(n)),e),i.range=(n,r,a)=>{let o=[];if(n=i.ceil(n),a=a==null?1:Math.floor(a),!(n<r)||!(a>0))return o;let s;do o.push(s=new Date(+n)),t(n,a),e(n);while(s<n&&n<r);return o},i.filter=n=>qN(t=>{if(t>=t)for(;e(t),!n(t);)t.setTime(t-1)},(e,r)=>{if(e>=e)if(r<0)for(;++r<=0;)for(;t(e,-1),!n(e););else for(;--r>=0;)for(;t(e,1),!n(e););}),n&&(i.count=(t,r)=>(GN.setTime(+t),KN.setTime(+r),e(GN),e(KN),Math.floor(n(GN,KN))),i.every=e=>(e=Math.floor(e),!isFinite(e)||!(e>0)?null:e>1?i.filter(r?t=>r(t)%e===0:t=>i.count(0,t)%e===0):i)),i}var JN=qN(()=>{},(e,t)=>{e.setTime(+e+t)},(e,t)=>t-e);JN.every=e=>(e=Math.floor(e),!isFinite(e)||!(e>0)?null:e>1?qN(t=>{t.setTime(Math.floor(t/e)*e)},(t,n)=>{t.setTime(+t+n*e)},(t,n)=>(n-t)/e):JN),JN.range;var YN=1e3,XN=YN*60,ZN=XN*60,QN=ZN*24,$N=QN*7,eP=QN*30,tP=QN*365,nP=qN(e=>{e.setTime(e-e.getMilliseconds())},(e,t)=>{e.setTime(+e+t*YN)},(e,t)=>(t-e)/YN,e=>e.getUTCSeconds());nP.range;var rP=qN(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*YN)},(e,t)=>{e.setTime(+e+t*XN)},(e,t)=>(t-e)/XN,e=>e.getMinutes());rP.range;var iP=qN(e=>{e.setUTCSeconds(0,0)},(e,t)=>{e.setTime(+e+t*XN)},(e,t)=>(t-e)/XN,e=>e.getUTCMinutes());iP.range;var aP=qN(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*YN-e.getMinutes()*XN)},(e,t)=>{e.setTime(+e+t*ZN)},(e,t)=>(t-e)/ZN,e=>e.getHours());aP.range;var oP=qN(e=>{e.setUTCMinutes(0,0,0)},(e,t)=>{e.setTime(+e+t*ZN)},(e,t)=>(t-e)/ZN,e=>e.getUTCHours());oP.range;var sP=qN(e=>e.setHours(0,0,0,0),(e,t)=>e.setDate(e.getDate()+t),(e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*XN)/QN,e=>e.getDate()-1);sP.range;var cP=qN(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/QN,e=>e.getUTCDate()-1);cP.range;var lP=qN(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/QN,e=>Math.floor(e/QN));lP.range;function uP(e){return qN(t=>{t.setDate(t.getDate()-(t.getDay()+7-e)%7),t.setHours(0,0,0,0)},(e,t)=>{e.setDate(e.getDate()+t*7)},(e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*XN)/$N)}var dP=uP(0),fP=uP(1),nse=uP(2),rse=uP(3),pP=uP(4),ise=uP(5),ase=uP(6);dP.range,fP.range,nse.range,rse.range,pP.range,ise.range,ase.range;function mP(e){return qN(t=>{t.setUTCDate(t.getUTCDate()-(t.getUTCDay()+7-e)%7),t.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t*7)},(e,t)=>(t-e)/$N)}var hP=mP(0),gP=mP(1),ose=mP(2),sse=mP(3),_P=mP(4),cse=mP(5),lse=mP(6);hP.range,gP.range,ose.range,sse.range,_P.range,cse.range,lse.range;var vP=qN(e=>{e.setDate(1),e.setHours(0,0,0,0)},(e,t)=>{e.setMonth(e.getMonth()+t)},(e,t)=>t.getMonth()-e.getMonth()+(t.getFullYear()-e.getFullYear())*12,e=>e.getMonth());vP.range;var yP=qN(e=>{e.setUTCDate(1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCMonth(e.getUTCMonth()+t)},(e,t)=>t.getUTCMonth()-e.getUTCMonth()+(t.getUTCFullYear()-e.getUTCFullYear())*12,e=>e.getUTCMonth());yP.range;var bP=qN(e=>{e.setMonth(0,1),e.setHours(0,0,0,0)},(e,t)=>{e.setFullYear(e.getFullYear()+t)},(e,t)=>t.getFullYear()-e.getFullYear(),e=>e.getFullYear());bP.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:qN(t=>{t.setFullYear(Math.floor(t.getFullYear()/e)*e),t.setMonth(0,1),t.setHours(0,0,0,0)},(t,n)=>{t.setFullYear(t.getFullYear()+n*e)}),bP.range;var xP=qN(e=>{e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCFullYear(e.getUTCFullYear()+t)},(e,t)=>t.getUTCFullYear()-e.getUTCFullYear(),e=>e.getUTCFullYear());xP.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:qN(t=>{t.setUTCFullYear(Math.floor(t.getUTCFullYear()/e)*e),t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,n)=>{t.setUTCFullYear(t.getUTCFullYear()+n*e)}),xP.range;function SP(e,t,n,r,i,a){let o=[[nP,1,YN],[nP,5,5*YN],[nP,15,15*YN],[nP,30,30*YN],[a,1,XN],[a,5,5*XN],[a,15,15*XN],[a,30,30*XN],[i,1,ZN],[i,3,3*ZN],[i,6,6*ZN],[i,12,12*ZN],[r,1,QN],[r,2,2*QN],[n,1,$N],[t,1,eP],[t,3,3*eP],[e,1,tP]];function s(e,t,n){let r=t<e;r&&([e,t]=[t,e]);let i=n&&typeof n.range==`function`?n:c(e,t,n),a=i?i.range(e,+t+1):[];return r?a.reverse():a}function c(t,n,r){let i=Math.abs(n-t)/r,a=hj(([,,e])=>e).right(o,i);if(a===o.length)return e.every(Pj(t/tP,n/tP,r));if(a===0)return JN.every(Math.max(Pj(t,n,r),1));let[s,c]=o[i/o[a-1][2]<o[a][2]/i?a-1:a];return s.every(c)}return[s,c]}var[use,dse]=SP(xP,yP,hP,lP,oP,iP),[fse,pse]=SP(bP,vP,dP,sP,aP,rP);function CP(e){if(0<=e.y&&e.y<100){var t=new Date(-1,e.m,e.d,e.H,e.M,e.S,e.L);return t.setFullYear(e.y),t}return new Date(e.y,e.m,e.d,e.H,e.M,e.S,e.L)}function wP(e){if(0<=e.y&&e.y<100){var t=new Date(Date.UTC(-1,e.m,e.d,e.H,e.M,e.S,e.L));return t.setUTCFullYear(e.y),t}return new Date(Date.UTC(e.y,e.m,e.d,e.H,e.M,e.S,e.L))}function TP(e,t,n){return{y:e,m:t,d:n,H:0,M:0,S:0,L:0}}function mse(e){var t=e.dateTime,n=e.date,r=e.time,i=e.periods,a=e.days,o=e.shortDays,s=e.months,c=e.shortMonths,l=kP(i),u=AP(i),d=kP(a),f=AP(a),p=kP(o),m=AP(o),h=kP(s),g=AP(s),_=kP(c),v=AP(c),y={a:re,A,b:ie,B:j,c:null,d:FP,e:FP,f:Lse,g:qse,G:Yse,H:Pse,I:Fse,j:Ise,L:IP,m:Rse,M:zse,p:M,q:ae,Q:HP,s:UP,S:Bse,u:Vse,U:Hse,V:Use,w:Wse,W:Gse,x:null,X:null,y:Kse,Y:Jse,Z:Xse,"%":VP},b={a:oe,A:se,b:N,B:ce,c:null,d:RP,e:RP,f:ece,g:uce,G:fce,H:Zse,I:Qse,j:$se,L:zP,m:tce,M:nce,p:le,q:ue,Q:HP,s:UP,S:rce,u:ice,U:ace,V:oce,w:sce,W:cce,x:null,X:null,y:lce,Y:dce,Z:pce,"%":VP},x={a:E,A:D,b:O,B:k,c:ee,d:NP,e:NP,f:Ase,g:MP,G:jP,H:PP,I:PP,j:Ese,L:kse,m:Tse,M:Dse,p:T,q:wse,Q:Mse,s:Nse,S:Ose,u:yse,U:bse,V:xse,w:vse,W:Sse,x:te,X:ne,y:MP,Y:jP,Z:Cse,"%":jse};y.x=S(n,y),y.X=S(r,y),y.c=S(t,y),b.x=S(n,b),b.X=S(r,b),b.c=S(t,b);function S(e,t){return function(n){var r=[],i=-1,a=0,o=e.length,s,c,l;for(n instanceof Date||(n=new Date(+n));++i<o;)e.charCodeAt(i)===37&&(r.push(e.slice(a,i)),(c=EP[s=e.charAt(++i)])==null?c=s===`e`?` `:`0`:s=e.charAt(++i),(l=t[s])&&(s=l(n,c)),r.push(s),a=i+1);return r.push(e.slice(a,i)),r.join(``)}}function C(e,t){return function(n){var r=TP(1900,void 0,1),i=w(r,e,n+=``,0),a,o;if(i!=n.length)return null;if(`Q`in r)return new Date(r.Q);if(`s`in r)return new Date(r.s*1e3+(`L`in r?r.L:0));if(t&&!(`Z`in r)&&(r.Z=0),`p`in r&&(r.H=r.H%12+r.p*12),r.m===void 0&&(r.m=`q`in r?r.q:0),`V`in r){if(r.V<1||r.V>53)return null;`w`in r||(r.w=1),`Z`in r?(a=wP(TP(r.y,0,1)),o=a.getUTCDay(),a=o>4||o===0?gP.ceil(a):gP(a),a=cP.offset(a,(r.V-1)*7),r.y=a.getUTCFullYear(),r.m=a.getUTCMonth(),r.d=a.getUTCDate()+(r.w+6)%7):(a=CP(TP(r.y,0,1)),o=a.getDay(),a=o>4||o===0?fP.ceil(a):fP(a),a=sP.offset(a,(r.V-1)*7),r.y=a.getFullYear(),r.m=a.getMonth(),r.d=a.getDate()+(r.w+6)%7)}else (`W`in r||`U`in r)&&(`w`in r||(r.w=`u`in r?r.u%7:+(`W`in r)),o=`Z`in r?wP(TP(r.y,0,1)).getUTCDay():CP(TP(r.y,0,1)).getDay(),r.m=0,r.d=`W`in r?(r.w+6)%7+r.W*7-(o+5)%7:r.w+r.U*7-(o+6)%7);return`Z`in r?(r.H+=r.Z/100|0,r.M+=r.Z%100,wP(r)):CP(r)}}function w(e,t,n,r){for(var i=0,a=t.length,o=n.length,s,c;i<a;){if(r>=o)return-1;if(s=t.charCodeAt(i++),s===37){if(s=t.charAt(i++),c=x[s in EP?t.charAt(i++):s],!c||(r=c(e,n,r))<0)return-1}else if(s!=n.charCodeAt(r++))return-1}return r}function T(e,t,n){var r=l.exec(t.slice(n));return r?(e.p=u.get(r[0].toLowerCase()),n+r[0].length):-1}function E(e,t,n){var r=p.exec(t.slice(n));return r?(e.w=m.get(r[0].toLowerCase()),n+r[0].length):-1}function D(e,t,n){var r=d.exec(t.slice(n));return r?(e.w=f.get(r[0].toLowerCase()),n+r[0].length):-1}function O(e,t,n){var r=_.exec(t.slice(n));return r?(e.m=v.get(r[0].toLowerCase()),n+r[0].length):-1}function k(e,t,n){var r=h.exec(t.slice(n));return r?(e.m=g.get(r[0].toLowerCase()),n+r[0].length):-1}function ee(e,n,r){return w(e,t,n,r)}function te(e,t,r){return w(e,n,t,r)}function ne(e,t,n){return w(e,r,t,n)}function re(e){return o[e.getDay()]}function A(e){return a[e.getDay()]}function ie(e){return c[e.getMonth()]}function j(e){return s[e.getMonth()]}function M(e){return i[+(e.getHours()>=12)]}function ae(e){return 1+~~(e.getMonth()/3)}function oe(e){return o[e.getUTCDay()]}function se(e){return a[e.getUTCDay()]}function N(e){return c[e.getUTCMonth()]}function ce(e){return s[e.getUTCMonth()]}function le(e){return i[+(e.getUTCHours()>=12)]}function ue(e){return 1+~~(e.getUTCMonth()/3)}return{format:function(e){var t=S(e+=``,y);return t.toString=function(){return e},t},parse:function(e){var t=C(e+=``,!1);return t.toString=function(){return e},t},utcFormat:function(e){var t=S(e+=``,b);return t.toString=function(){return e},t},utcParse:function(e){var t=C(e+=``,!0);return t.toString=function(){return e},t}}}var EP={"-":``,_:` `,0:`0`},DP=/^\s*\d+/,hse=/^%/,gse=/[\\^$*+?|[\]().{}]/g;function OP(e,t,n){var r=e<0?`-`:``,i=(r?-e:e)+``,a=i.length;return r+(a<n?Array(n-a+1).join(t)+i:i)}function _se(e){return e.replace(gse,`\\$&`)}function kP(e){return RegExp(`^(?:`+e.map(_se).join(`|`)+`)`,`i`)}function AP(e){return new Map(e.map((e,t)=>[e.toLowerCase(),t]))}function vse(e,t,n){var r=DP.exec(t.slice(n,n+1));return r?(e.w=+r[0],n+r[0].length):-1}function yse(e,t,n){var r=DP.exec(t.slice(n,n+1));return r?(e.u=+r[0],n+r[0].length):-1}function bse(e,t,n){var r=DP.exec(t.slice(n,n+2));return r?(e.U=+r[0],n+r[0].length):-1}function xse(e,t,n){var r=DP.exec(t.slice(n,n+2));return r?(e.V=+r[0],n+r[0].length):-1}function Sse(e,t,n){var r=DP.exec(t.slice(n,n+2));return r?(e.W=+r[0],n+r[0].length):-1}function jP(e,t,n){var r=DP.exec(t.slice(n,n+4));return r?(e.y=+r[0],n+r[0].length):-1}function MP(e,t,n){var r=DP.exec(t.slice(n,n+2));return r?(e.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function Cse(e,t,n){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(t.slice(n,n+6));return r?(e.Z=r[1]?0:-(r[2]+(r[3]||`00`)),n+r[0].length):-1}function wse(e,t,n){var r=DP.exec(t.slice(n,n+1));return r?(e.q=r[0]*3-3,n+r[0].length):-1}function Tse(e,t,n){var r=DP.exec(t.slice(n,n+2));return r?(e.m=r[0]-1,n+r[0].length):-1}function NP(e,t,n){var r=DP.exec(t.slice(n,n+2));return r?(e.d=+r[0],n+r[0].length):-1}function Ese(e,t,n){var r=DP.exec(t.slice(n,n+3));return r?(e.m=0,e.d=+r[0],n+r[0].length):-1}function PP(e,t,n){var r=DP.exec(t.slice(n,n+2));return r?(e.H=+r[0],n+r[0].length):-1}function Dse(e,t,n){var r=DP.exec(t.slice(n,n+2));return r?(e.M=+r[0],n+r[0].length):-1}function Ose(e,t,n){var r=DP.exec(t.slice(n,n+2));return r?(e.S=+r[0],n+r[0].length):-1}function kse(e,t,n){var r=DP.exec(t.slice(n,n+3));return r?(e.L=+r[0],n+r[0].length):-1}function Ase(e,t,n){var r=DP.exec(t.slice(n,n+6));return r?(e.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function jse(e,t,n){var r=hse.exec(t.slice(n,n+1));return r?n+r[0].length:-1}function Mse(e,t,n){var r=DP.exec(t.slice(n));return r?(e.Q=+r[0],n+r[0].length):-1}function Nse(e,t,n){var r=DP.exec(t.slice(n));return r?(e.s=+r[0],n+r[0].length):-1}function FP(e,t){return OP(e.getDate(),t,2)}function Pse(e,t){return OP(e.getHours(),t,2)}function Fse(e,t){return OP(e.getHours()%12||12,t,2)}function Ise(e,t){return OP(1+sP.count(bP(e),e),t,3)}function IP(e,t){return OP(e.getMilliseconds(),t,3)}function Lse(e,t){return IP(e,t)+`000`}function Rse(e,t){return OP(e.getMonth()+1,t,2)}function zse(e,t){return OP(e.getMinutes(),t,2)}function Bse(e,t){return OP(e.getSeconds(),t,2)}function Vse(e){var t=e.getDay();return t===0?7:t}function Hse(e,t){return OP(dP.count(bP(e)-1,e),t,2)}function LP(e){var t=e.getDay();return t>=4||t===0?pP(e):pP.ceil(e)}function Use(e,t){return e=LP(e),OP(pP.count(bP(e),e)+(bP(e).getDay()===4),t,2)}function Wse(e){return e.getDay()}function Gse(e,t){return OP(fP.count(bP(e)-1,e),t,2)}function Kse(e,t){return OP(e.getFullYear()%100,t,2)}function qse(e,t){return e=LP(e),OP(e.getFullYear()%100,t,2)}function Jse(e,t){return OP(e.getFullYear()%1e4,t,4)}function Yse(e,t){var n=e.getDay();return e=n>=4||n===0?pP(e):pP.ceil(e),OP(e.getFullYear()%1e4,t,4)}function Xse(e){var t=e.getTimezoneOffset();return(t>0?`-`:(t*=-1,`+`))+OP(t/60|0,`0`,2)+OP(t%60,`0`,2)}function RP(e,t){return OP(e.getUTCDate(),t,2)}function Zse(e,t){return OP(e.getUTCHours(),t,2)}function Qse(e,t){return OP(e.getUTCHours()%12||12,t,2)}function $se(e,t){return OP(1+cP.count(xP(e),e),t,3)}function zP(e,t){return OP(e.getUTCMilliseconds(),t,3)}function ece(e,t){return zP(e,t)+`000`}function tce(e,t){return OP(e.getUTCMonth()+1,t,2)}function nce(e,t){return OP(e.getUTCMinutes(),t,2)}function rce(e,t){return OP(e.getUTCSeconds(),t,2)}function ice(e){var t=e.getUTCDay();return t===0?7:t}function ace(e,t){return OP(hP.count(xP(e)-1,e),t,2)}function BP(e){var t=e.getUTCDay();return t>=4||t===0?_P(e):_P.ceil(e)}function oce(e,t){return e=BP(e),OP(_P.count(xP(e),e)+(xP(e).getUTCDay()===4),t,2)}function sce(e){return e.getUTCDay()}function cce(e,t){return OP(gP.count(xP(e)-1,e),t,2)}function lce(e,t){return OP(e.getUTCFullYear()%100,t,2)}function uce(e,t){return e=BP(e),OP(e.getUTCFullYear()%100,t,2)}function dce(e,t){return OP(e.getUTCFullYear()%1e4,t,4)}function fce(e,t){var n=e.getUTCDay();return e=n>=4||n===0?_P(e):_P.ceil(e),OP(e.getUTCFullYear()%1e4,t,4)}function pce(){return`+0000`}function VP(){return`%`}function HP(e){return+e}function UP(e){return Math.floor(e/1e3)}var WP,GP,KP;mce({dateTime:`%x, %X`,date:`%-m/%-d/%Y`,time:`%-I:%M:%S %p`,periods:[`AM`,`PM`],days:[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`],shortDays:[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],months:[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],shortMonths:[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`]});function mce(e){return WP=mse(e),GP=WP.format,WP.parse,KP=WP.utcFormat,WP.utcParse,WP}function hce(e){return new Date(e)}function gce(e){return e instanceof Date?+e:+new Date(+e)}function qP(e,t,n,r,i,a,o,s,c,l){var u=lN(),d=u.invert,f=u.domain,p=l(`.%L`),m=l(`:%S`),h=l(`%I:%M`),g=l(`%I %p`),_=l(`%a %d`),v=l(`%b %d`),y=l(`%B`),b=l(`%Y`);function x(e){return(c(e)<e?p:s(e)<e?m:o(e)<e?h:a(e)<e?g:r(e)<e?i(e)<e?_:v:n(e)<e?y:b)(e)}return u.invert=function(e){return new Date(d(e))},u.domain=function(e){return arguments.length?f(Array.from(e,gce)):f().map(hce)},u.ticks=function(t){var n=f();return e(n[0],n[n.length-1],t??10)},u.tickFormat=function(e,t){return t==null?x:l(t)},u.nice=function(e){var n=f();return(!e||typeof e.range!=`function`)&&(e=t(n[0],n[n.length-1],e??10)),e?f(DN(n,e)):u},u.copy=function(){return sN(u,qP(e,t,n,r,i,a,o,s,c,l))},u}function _ce(){return Hj.apply(qP(fse,pse,bP,vP,dP,sP,aP,rP,nP,GP).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function vce(){return Hj.apply(qP(use,dse,xP,yP,hP,cP,oP,iP,nP,KP).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)}function JP(){var e=0,t=1,n,r,i,a,o=rN,s=!1,c;function l(e){return e==null||isNaN(e=+e)?c:o(i===0?.5:(e=(a(e)-n)*i,s?Math.max(0,Math.min(1,e)):e))}l.domain=function(o){return arguments.length?([e,t]=o,n=a(e=+e),r=a(t=+t),i=n===r?0:1/(r-n),l):[e,t]},l.clamp=function(e){return arguments.length?(s=!!e,l):s},l.interpolator=function(e){return arguments.length?(o=e,l):o};function u(e){return function(t){var n,r;return arguments.length?([n,r]=t,o=e(n,r),l):[o(0),o(1)]}}return l.range=u(ZM),l.rangeRound=u(QM),l.unknown=function(e){return arguments.length?(c=e,l):c},function(o){return a=o,n=o(e),r=o(t),i=n===r?0:1/(r-n),l}}function YP(e,t){return t.domain(e.domain()).interpolator(e.interpolator()).clamp(e.clamp()).unknown(e.unknown())}function XP(){var e=wN(JP()(rN));return e.copy=function(){return YP(e,XP())},Uj.apply(e,arguments)}function ZP(){var e=jN(JP()).domain([1,10]);return e.copy=function(){return YP(e,ZP()).base(e.base())},Uj.apply(e,arguments)}function QP(){var e=FN(JP());return e.copy=function(){return YP(e,QP()).constant(e.constant())},Uj.apply(e,arguments)}function $P(){var e=RN(JP());return e.copy=function(){return YP(e,$P()).exponent(e.exponent())},Uj.apply(e,arguments)}function yce(){return $P.apply(null,arguments).exponent(.5)}function eF(){var e=[],t=rN;function n(n){if(n!=null&&!isNaN(n=+n))return t((bj(e,n,1)-1)/(e.length-1))}return n.domain=function(t){if(!arguments.length)return e.slice();e=[];for(let n of t)n!=null&&!isNaN(n=+n)&&e.push(n);return e.sort(pj),n},n.interpolator=function(e){return arguments.length?(t=e,n):t},n.range=function(){return e.map((n,r)=>t(r/(e.length-1)))},n.quantiles=function(t){return Array.from({length:t+1},(n,r)=>zj(e,r/t))},n.copy=function(){return eF(t).domain(e)},Uj.apply(n,arguments)}function tF(){var e=0,t=.5,n=1,r=1,i,a,o,s,c,l=rN,u,d=!1,f;function p(e){return isNaN(e=+e)?f:(e=.5+((e=+u(e))-a)*(r*e<r*a?s:c),l(d?Math.max(0,Math.min(1,e)):e))}p.domain=function(l){return arguments.length?([e,t,n]=l,i=u(e=+e),a=u(t=+t),o=u(n=+n),s=i===a?0:.5/(a-i),c=a===o?0:.5/(o-a),r=a<i?-1:1,p):[e,t,n]},p.clamp=function(e){return arguments.length?(d=!!e,p):d},p.interpolator=function(e){return arguments.length?(l=e,p):l};function m(e){return function(t){var n,r,i;return arguments.length?([n,r,i]=t,l=$M(e,[n,r,i]),p):[l(0),l(.5),l(1)]}}return p.range=m(ZM),p.rangeRound=m(QM),p.unknown=function(e){return arguments.length?(f=e,p):f},function(l){return u=l,i=l(e),a=l(t),o=l(n),s=i===a?0:.5/(a-i),c=a===o?0:.5/(o-a),r=a<i?-1:1,p}}function nF(){var e=wN(tF()(rN));return e.copy=function(){return YP(e,nF())},Uj.apply(e,arguments)}function rF(){var e=jN(tF()).domain([.1,1,10]);return e.copy=function(){return YP(e,rF()).base(e.base())},Uj.apply(e,arguments)}function iF(){var e=FN(tF());return e.copy=function(){return YP(e,iF()).constant(e.constant())},Uj.apply(e,arguments)}function aF(){var e=RN(tF());return e.copy=function(){return YP(e,aF()).exponent(e.exponent())},Uj.apply(e,arguments)}function bce(){return aF.apply(null,arguments).exponent(.5)}var oF=c({scaleBand:()=>Kj,scaleDiverging:()=>nF,scaleDivergingLog:()=>rF,scaleDivergingPow:()=>aF,scaleDivergingSqrt:()=>bce,scaleDivergingSymlog:()=>iF,scaleIdentity:()=>EN,scaleImplicit:()=>Wj,scaleLinear:()=>TN,scaleLog:()=>MN,scaleOrdinal:()=>Gj,scalePoint:()=>Jj,scalePow:()=>zN,scaleQuantile:()=>HN,scaleQuantize:()=>UN,scaleRadial:()=>VN,scaleSequential:()=>XP,scaleSequentialLog:()=>ZP,scaleSequentialPow:()=>$P,scaleSequentialQuantile:()=>eF,scaleSequentialSqrt:()=>yce,scaleSequentialSymlog:()=>QP,scaleSqrt:()=>ese,scaleSymlog:()=>IN,scaleThreshold:()=>WN,scaleTime:()=>_ce,scaleUtc:()=>vce,tickFormat:()=>CN});function xce(e){var t=oF;if(e in t&&typeof t[e]==`function`)return t[e]();var n=`scale${$S(e)}`;if(n in t&&typeof t[n]==`function`)return t[n]()}function sF(e,t,n){if(typeof e==`function`)return e.copy().domain(t).range(n);if(e!=null){var r=xce(e);if(r!=null)return r.domain(t).range(n),r}}function cF(e,t,n,r){if(!(n==null||r==null))return typeof e.scale==`function`?sF(e.scale,n,r):sF(t,n,r)}function Sce(e){return`scale${$S(e)}`}function Cce(e){return Sce(e)in oF}var lF=(e,t,n)=>{if(e!=null){var{scale:r,type:i}=e;if(r===`auto`)return i===`category`&&n&&(n.indexOf(`LineChart`)>=0||n.indexOf(`AreaChart`)>=0||n.indexOf(`ComposedChart`)>=0&&!t)?`point`:i===`category`?`band`:`linear`;if(typeof r==`string`)return Cce(r)?r:`point`}};function wce(e,t){for(var n=0,r=e.length,i=e[0]<e[e.length-1];n<r;){var a=Math.floor((n+r)/2);(i?e[a]<t:e[a]>t)?n=a+1:r=a}return n}function uF(e,t){if(e){var n=t??e.domain(),r=n.map(t=>e(t)??0),i=e.range();if(!(n.length===0||i.length<2))return e=>{var t=wce(r,e);if(t<=0)return n[0];if(t>=n.length)return n[n.length-1];var i=r[t-1]??0,a=r[t]??0;return Math.abs(e-i)<=Math.abs(e-a)?n[t-1]:n[t]}}}function Tce(e){if(e!=null)return`invert`in e&&typeof e.invert==`function`?e.invert.bind(e):uF(e,void 0)}var dF=u(tA());function fF(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function pF(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?fF(Object(n),!0).forEach(function(t){Ece(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):fF(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ece(e,t,n){return(t=Dce(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Dce(e){var t=Oce(e,`string`);return typeof t==`symbol`?t:t+``}function Oce(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var mF=[0,`auto`],hF={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:void 0,height:30,hide:!0,id:0,includeHidden:!1,interval:`preserveEnd`,minTickGap:5,mirror:!1,name:void 0,orientation:`bottom`,padding:{left:0,right:0},reversed:!1,scale:`auto`,tick:!0,tickCount:5,tickFormatter:void 0,ticks:void 0,type:`category`,unit:void 0,niceTicks:`auto`},gF=(e,t)=>e.cartesianAxis.xAxis[t],_F=(e,t)=>gF(e,t)??hF,vF={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:mF,hide:!0,id:0,includeHidden:!1,interval:`preserveEnd`,minTickGap:5,mirror:!1,name:void 0,orientation:`left`,padding:{top:0,bottom:0},reversed:!1,scale:`auto`,tick:!0,tickCount:5,tickFormatter:void 0,ticks:void 0,type:`number`,unit:void 0,niceTicks:`auto`,width:60},yF=(e,t)=>e.cartesianAxis.yAxis[t],bF=(e,t)=>yF(e,t)??vF,xF={domain:[0,`auto`],includeHidden:!1,reversed:!1,allowDataOverflow:!1,allowDuplicatedCategory:!1,dataKey:void 0,id:0,name:``,range:[64,64],scale:`auto`,type:`number`,unit:``},SF=(e,t)=>e.cartesianAxis.zAxis[t]??xF,CF=(e,t,n)=>{switch(t){case`xAxis`:return _F(e,n);case`yAxis`:return bF(e,n);case`zAxis`:return SF(e,n);case`angleAxis`:return KA(e,n);case`radiusAxis`:return qA(e,n);default:throw Error(`Unexpected axis type: ${t}`)}},kce=(e,t,n)=>{switch(t){case`xAxis`:return _F(e,n);case`yAxis`:return bF(e,n);default:throw Error(`Unexpected axis type: ${t}`)}},wF=(e,t,n)=>{switch(t){case`xAxis`:return _F(e,n);case`yAxis`:return bF(e,n);case`angleAxis`:return KA(e,n);case`radiusAxis`:return qA(e,n);default:throw Error(`Unexpected axis type: ${t}`)}},TF=e=>e.graphicalItems.cartesianItems.some(e=>e.type===`bar`)||e.graphicalItems.polarItems.some(e=>e.type===`radialBar`);function EF(e,t){return n=>{switch(e){case`xAxis`:return`xAxisId`in n&&n.xAxisId===t;case`yAxis`:return`yAxisId`in n&&n.yAxisId===t;case`zAxis`:return`zAxisId`in n&&n.zAxisId===t;case`angleAxis`:return`angleAxisId`in n&&n.angleAxisId===t;case`radiusAxis`:return`radiusAxisId`in n&&n.radiusAxisId===t;default:return!1}}}var DF=e=>e.graphicalItems.cartesianItems,Ace=W([tj,nj],EF),OF=(e,t,n)=>e.filter(n).filter(e=>t?.includeHidden===!0?!0:!e.hide),kF=W([DF,CF,Ace],OF,{memoizeOptions:{resultEqualityCheck:sj}}),AF=W([kF],e=>e.filter(e=>e.type===`area`||e.type===`bar`).filter(aj)),jF=e=>e.filter(e=>!(`stackId`in e)||e.stackId===void 0),jce=W([kF],jF),MF=e=>e.map(e=>e.data).filter(Boolean).flat(1),Mce=W([kF],e=>e.some(e=>!e.data)),NF=W([kF],MF,{memoizeOptions:{resultEqualityCheck:sj}}),PF=(e,t)=>{var{chartData:n=[],dataStartIndex:r,dataEndIndex:i}=t;return e.length>0?e:n.slice(r,i+1)},FF=W([NF,iA],PF),IF=(e,t,n)=>t?.dataKey==null?n.length>0?n.map(e=>e.dataKey).flatMap(t=>e.map(e=>({value:RE(e,t)}))):e.map(e=>({value:e})):e.map(e=>({value:RE(e,t.dataKey)})),LF=(e,t,n,r,i,a)=>{var{chartData:o=[],dataStartIndex:s,dataEndIndex:c}=r,l=IF(e,t,n);return i&&t?.dataKey!=null&&a.length>0?[...o.slice(s,c+1).map(e=>({value:RE(e,t.dataKey)})).filter(e=>e.value!=null),...l]:l},RF=W([FF,CF,kF,iA,Mce,NF],LF);function zF(e){if(KS(e)||e instanceof Date){var t=Number(e);if(PE(t))return t}}function BF(e){if(Array.isArray(e)){var t=[zF(e[0]),zF(e[1])];return lA(t)?t:void 0}var n=zF(e);if(n!=null)return[n,n]}function VF(e){return e.map(zF).filter(eC)}function Nce(e,t){var n=zF(e),r=zF(t);return n==null&&r==null?0:n==null?-1:r==null?1:n-r}var Pce=W([RF],e=>e?.map(e=>e.value).sort(Nce));function HF(e,t){switch(e){case`xAxis`:return t.direction===`x`;case`yAxis`:return t.direction===`y`;default:return!1}}function Fce(e,t,n){if(!n||!n.length)return[];var r;if(typeof t==`number`&&!WS(t))r=t;else if(Array.isArray(t)){var i=VF(t);i.length>0&&(r=Math.max(...i))}return r==null?[]:VF(n.flatMap(t=>{var n=RE(e,t.dataKey),i,a;if(Array.isArray(n)?[i,a]=n:i=a=n,!(!PE(i)||!PE(a)))return[r-i,r+a]}))}var UF=e=>wF(e,lj(e),uj(e)),WF=W([UF],e=>e?.dataKey),Ice=W([AF,iA,UF],ij),GF=(e,t,n,r)=>{var i=t.reduce((e,t)=>{if(t.stackId==null)return e;var n=e[t.stackId];return n??=[],n.push(t),e[t.stackId]=n,e},{});return Object.fromEntries(Object.entries(i).map(t=>{var[i,a]=t,o=r?[...a].reverse():a;return[i,{stackedData:die(e,o.map(rj),n),graphicalItems:o}]}))},KF=W([Ice,AF,DA,OA],GF),qF=(e,t,n,r)=>{var{dataStartIndex:i,dataEndIndex:a}=t;if(r==null&&n!==`zAxis`){var o=hie(e,i,a);if(!(o!=null&&o[0]===0&&o[1]===0))return o}},Lce=W([CF],e=>e.allowDataOverflow),JF=e=>{if(e==null||!(`domain`in e))return mF;if(e.domain!=null)return e.domain;if(`ticks`in e&&e.ticks!=null){if(e.type===`number`){var t=VF(e.ticks);return[Math.min(...t),Math.max(...t)]}if(e.type===`category`)return e.ticks.map(String)}return e?.domain??mF},YF=W([CF],JF),XF=W([YF,Lce],dA),Rce=W([KF,nA,tj,XF],qF,{memoizeOptions:{resultEqualityCheck:oj}}),ZF=e=>e.errorBars,zce=(e,t,n)=>e.flatMap(e=>t[e.id]).filter(Boolean).filter(e=>HF(n,e)),QF=function(){var e=[...arguments].filter(Boolean);if(e.length!==0){var t=e.flat();return[Math.min(...t),Math.max(...t)]}},$F=function(e,t,n,r,i){var a=arguments.length>5&&arguments[5]!==void 0?arguments[5]:[],o,s;if(n.length>0&&n.forEach(e=>{var n=e.data==null?a:[...e.data],c=r[e.id]?.filter(e=>HF(i,e));n.forEach(n=>{var r=RE(n,t.dataKey??e.dataKey),i=Fce(n,r,c);if(i.length>=2){var a=Math.min(...i),l=Math.max(...i);(o==null||a<o)&&(o=a),(s==null||l>s)&&(s=l)}var u=BF(r);u!=null&&(o=o==null?u[0]:Math.min(o,u[0]),s=s==null?u[1]:Math.max(s,u[1]))})}),t?.dataKey!=null&&n.length===0&&e.forEach(e=>{var n=BF(RE(e,t.dataKey));n!=null&&(o=o==null?n[0]:Math.min(o,n[0]),s=s==null?n[1]:Math.max(s,n[1]))}),PE(o)&&PE(s))return[o,s]},Bce=W([FF,CF,jce,ZF,tj,oA],$F,{memoizeOptions:{resultEqualityCheck:oj}});function Vce(e){var{value:t}=e;if(KS(t)||t instanceof Date)return t}var Hce=(e,t,n)=>{var r=e.map(Vce).filter(e=>e!=null);return n&&(t.dataKey==null||t.allowDuplicatedCategory&&YS(r))?(0,dF.default)(0,e.length):t.allowDuplicatedCategory?r:Array.from(new Set(r))},eI=e=>e.referenceElements.dots,tI=(e,t,n)=>e.filter(e=>e.ifOverflow===`extendDomain`).filter(e=>t===`xAxis`?e.xAxisId===n:e.yAxisId===n),Uce=W([eI,tj,nj],tI),nI=e=>e.referenceElements.areas,Wce=W([nI,tj,nj],tI),rI=e=>e.referenceElements.lines,Gce=W([rI,tj,nj],tI),iI=(e,t)=>{if(e!=null){var n=VF(e.map(e=>t===`xAxis`?e.x:e.y));if(n.length!==0)return[Math.min(...n),Math.max(...n)]}},Kce=W(Uce,tj,iI),aI=(e,t)=>{if(e!=null){var n=VF(e.flatMap(e=>[t===`xAxis`?e.x1:e.y1,t===`xAxis`?e.x2:e.y2]));if(n.length!==0)return[Math.min(...n),Math.max(...n)]}},qce=W([Wce,tj],aI);function Jce(e){if(e.x!=null)return VF([e.x]);var t=e.segment?.map(e=>e.x);return t==null||t.length===0?[]:VF(t)}function Yce(e){if(e.y!=null)return VF([e.y]);var t=e.segment?.map(e=>e.y);return t==null||t.length===0?[]:VF(t)}var oI=(e,t)=>{if(e!=null){var n=e.flatMap(e=>t===`xAxis`?Jce(e):Yce(e));if(n.length!==0)return[Math.min(...n),Math.max(...n)]}},Xce=W(Kce,W([Gce,tj],oI),qce,(e,t,n)=>QF(e,n,t)),sI=(e,t,n,r,i,a,o,s)=>n??fA(t,o===`vertical`&&s===`xAxis`||o===`horizontal`&&s===`yAxis`?QF(r,a,i):QF(a,i),e.allowDataOverflow),Zce=W([CF,YF,XF,Rce,Bce,Xce,TD,tj],sI,{memoizeOptions:{resultEqualityCheck:oj}}),Qce=[0,1],cI=(e,t,n,r,i,a,o)=>{if(!((e==null||n==null||n.length===0)&&o===void 0)){var{dataKey:s,type:c}=e,l=zE(t,a);return l&&s==null?(0,dF.default)(0,n?.length??0):c===`category`?Hce(r,e,l):i===`expand`&&!l?Qce:o}},lI=W([CF,TD,FF,RF,DA,tj,Zce],cI),uI=W([CF,TF,kA],lF),dI=(e,t,n)=>{var{niceTicks:r}=t;if(r!==`none`){var i=JF(t),a=Array.isArray(i)&&(i[0]===`auto`||i[1]===`auto`);if((r===`snap125`||r===`adaptive`)&&t!=null&&t.tickCount&&lA(e)){if(a)return xA(e,t.tickCount,t.allowDecimals,r);if(t.type===`number`)return SA(e,t.tickCount,t.allowDecimals,r)}if(r===`auto`&&n===`linear`&&t!=null&&t.tickCount){if(a&&lA(e))return xA(e,t.tickCount,t.allowDecimals,`adaptive`);if(t.type===`number`&&lA(e))return SA(e,t.tickCount,t.allowDecimals,`adaptive`)}}},fI=W([lI,wF,uI],dI),pI=(e,t,n,r)=>{if(r!==`angleAxis`&&e?.type===`number`&&lA(t)&&Array.isArray(n)&&n.length>0){var i=t[0],a=n[0]??0,o=t[1],s=n[n.length-1]??0;return[Math.min(i,a),Math.max(o,s)]}return t},$ce=W([CF,lI,fI,tj],pI),mI=W(W(RF,CF,(e,t)=>{if(!(!t||t.type!==`number`)){var n=1/0,r=Array.from(VF(e.map(e=>e.value))).sort((e,t)=>e-t),i=r[0],a=r[r.length-1];if(i==null||a==null)return 1/0;var o=a-i;if(o===0)return 1/0;for(var s=0;s<r.length-1;s++){var c=r[s],l=r[s+1];if(!(c==null||l==null)){var u=l-c;n=Math.min(n,u)}}return n/o}}),TD,TA,aD,(e,t,n,r,i)=>i,(e,t,n,r,i)=>{if(!PE(e))return 0;var a=t===`vertical`?r.height:r.width;if(i===`gap`)return e*a/2;if(i===`no-gap`){var o=JS(n,e*a),s=e*a/2;return s-o-(s-o)/a*o}return 0}),ele=(e,t,n)=>{var r=_F(e,t);return r==null||typeof r.padding!=`string`?0:mI(e,`xAxis`,t,n,r.padding)},tle=(e,t,n)=>{var r=bF(e,t);return r==null||typeof r.padding!=`string`?0:mI(e,`yAxis`,t,n,r.padding)},nle=W(_F,ele,(e,t)=>{if(e==null)return{left:0,right:0};var{padding:n}=e;return typeof n==`string`?{left:t,right:t}:{left:(n.left??0)+t,right:(n.right??0)+t}}),rle=W(bF,tle,(e,t)=>{if(e==null)return{top:0,bottom:0};var{padding:n}=e;return typeof n==`string`?{top:t,bottom:t}:{top:(n.top??0)+t,bottom:(n.bottom??0)+t}}),ile=W([aD,nle,lD,cD,(e,t,n)=>n],(e,t,n,r,i)=>{var{padding:a}=r;return i?[a.left,n.width-a.right]:[e.left+t.left,e.left+e.width-t.right]}),ale=W([aD,TD,rle,lD,cD,(e,t,n)=>n],(e,t,n,r,i,a)=>{var{padding:o}=i;return a?[r.height-o.bottom,o.top]:t===`horizontal`?[e.top+e.height-n.bottom,e.top+n.top]:[e.top+n.top,e.top+e.height-n.bottom]}),hI=(e,t,n,r)=>{switch(t){case`xAxis`:return ile(e,n,r);case`yAxis`:return ale(e,n,r);case`zAxis`:return SF(e,n)?.range;case`angleAxis`:return QA(e);case`radiusAxis`:return $A(e,n);default:return}},gI=W([CF,hI],LA),_I=W([CF,uI,W([uI,$ce],fj),gI],cF),vI=(e,t,n,r)=>{if(!(n==null||n.dataKey==null)){var{type:i,scale:a}=n;if(zE(e,r)&&(i===`number`||a!==`auto`))return t.map(e=>e.value)}},yI=W([TD,RF,wF,tj],vI),bI=W([_I],dj);W([_I],Tce),W([_I,Pce],uF),W([kF,ZF,tj],zce);function xI(e,t){return e.id<t.id?-1:+(e.id>t.id)}var SI=(e,t)=>t,CI=(e,t,n)=>n,ole=W($E,SI,CI,(e,t,n)=>e.filter(e=>e.orientation===t).filter(e=>e.mirror===n).sort(xI)),sle=W(eD,SI,CI,(e,t,n)=>e.filter(e=>e.orientation===t).filter(e=>e.mirror===n).sort(xI)),wI=(e,t)=>({width:e.width,height:t.height}),cle=(e,t)=>({width:typeof t.width==`number`?t.width:60,height:e.height}),TI=W(aD,_F,wI),lle=(e,t,n)=>{switch(t){case`top`:return e.top;case`bottom`:return n-e.bottom;default:return 0}},ule=(e,t,n)=>{switch(t){case`left`:return e.left;case`right`:return n-e.right;default:return 0}},dle=W(ZE,aD,ole,SI,CI,(e,t,n,r,i)=>{var a={},o;return n.forEach(n=>{var s=wI(t,n);o??=lle(t,r,e);var c=r===`top`&&!i||r===`bottom`&&i;a[n.id]=o-Number(c)*s.height,o+=(c?-1:1)*s.height}),a}),fle=W(XE,aD,sle,SI,CI,(e,t,n,r,i)=>{var a={},o;return n.forEach(n=>{var s=cle(t,n);o??=ule(t,r,e);var c=r===`left`&&!i||r===`right`&&i;a[n.id]=o-Number(c)*s.width,o+=(c?-1:1)*s.width}),a}),ple=W([aD,_F,(e,t)=>{var n=_F(e,t);if(n!=null)return dle(e,n.orientation,n.mirror)},(e,t)=>t],(e,t,n,r)=>{if(t!=null){var i=n?.[r];return i==null?{x:e.left,y:0}:{x:e.left,y:i}}}),mle=W([aD,bF,(e,t)=>{var n=bF(e,t);if(n!=null)return fle(e,n.orientation,n.mirror)},(e,t)=>t],(e,t,n,r)=>{if(t!=null){var i=n?.[r];return i==null?{x:0,y:e.top}:{x:i,y:e.top}}}),EI=W(aD,bF,(e,t)=>({width:typeof t.width==`number`?t.width:60,height:e.height})),DI=(e,t,n)=>{switch(t){case`xAxis`:return TI(e,n).width;case`yAxis`:return EI(e,n).height;default:return}},OI=(e,t,n,r)=>{if(n!=null){var{allowDuplicatedCategory:i,type:a,dataKey:o}=n,s=zE(e,r),c=t.map(e=>e.value),l=c.filter(e=>e!=null);if(o&&s&&a===`category`&&i&&YS(l))return c}},kI=W([TD,RF,CF,tj],OI),AI=W([TD,kce,uI,bI,kI,yI,hI,fI,tj],(e,t,n,r,i,a,o,s,c)=>{if(t!=null){var l=zE(e,c);return{angle:t.angle,interval:t.interval,minTickGap:t.minTickGap,orientation:t.orientation,tick:t.tick,tickCount:t.tickCount,tickFormatter:t.tickFormatter,ticks:t.ticks,type:t.type,unit:t.unit,axisType:c,categoricalDomain:a,duplicateDomain:i,isCategorical:l,niceTicks:s,range:o,realScaleType:n,scale:r}}}),jI=W([TD,wF,uI,bI,fI,hI,kI,yI,tj],(e,t,n,r,i,a,o,s,c)=>{if(!(t==null||r==null)){var l=zE(e,c),{type:u,ticks:d,tickCount:f}=t,p=n===`scaleBand`&&typeof r.bandwidth==`function`?r.bandwidth()/2:2,m=u===`category`&&r.bandwidth?r.bandwidth()/p:0;m=c===`angleAxis`&&a!=null&&a.length>=2?US(a[0]-a[1])*2*m:m;var h=d||i;return h?h.map((e,t)=>{var n=o?o.indexOf(e):e,i=r.map(n);return PE(i)?{index:t,coordinate:i+m,value:e,offset:m}:null}).filter(eC):l&&s?s.map((e,t)=>{var n=r.map(e);return PE(n)?{coordinate:n+m,value:e,index:t,offset:m}:null}).filter(eC):r.ticks?r.ticks(f).map((e,t)=>{var n=r.map(e);return PE(n)?{coordinate:n+m,value:e,index:t,offset:m}:null}).filter(eC):r.domain().map((e,t)=>{var n=r.map(e);return PE(n)?{coordinate:n+m,value:o?o[e]:e,index:t,offset:m}:null}).filter(eC)}}),MI=W([TD,wF,bI,hI,kI,yI,tj],(e,t,n,r,i,a,o)=>{if(!(t==null||n==null||r==null||r[0]===r[1])){var s=zE(e,o),{tickCount:c}=t,l=0;return l=o===`angleAxis`&&r?.length>=2?US(r[0]-r[1])*2*l:l,s&&a?a.map((e,t)=>{var r=n.map(e);return PE(r)?{coordinate:r+l,value:e,index:t,offset:l}:null}).filter(eC):n.ticks?n.ticks(c).map((e,t)=>{var r=n.map(e);return PE(r)?{coordinate:r+l,value:e,index:t,offset:l}:null}).filter(eC):n.domain().map((e,t)=>{var r=n.map(e);return PE(r)?{coordinate:r+l,value:i?i[e]:e,index:t,offset:l}:null}).filter(eC)}}),NI=W(CF,bI,(e,t)=>{if(!(e==null||t==null))return pF(pF({},e),{},{scale:t})}),hle=W((e,t,n)=>SF(e,n),W([W([CF,uI,lI,gI],cF)],dj),(e,t)=>{if(!(e==null||t==null))return pF(pF({},e),{},{scale:t})}),gle=W([TD,$E,eD],(e,t,n)=>{switch(e){case`horizontal`:return t.some(e=>e.reversed)?`right-to-left`:`left-to-right`;case`vertical`:return n.some(e=>e.reversed)?`bottom-to-top`:`top-to-bottom`;case`centric`:case`radial`:return`left-to-right`;default:return}});W([(e,t,n)=>e.renderedTicks[t]?.[n]],e=>{if(!(!e||e.length===0))return t=>{var n=1/0,r=e[0];for(var i of e){var a=Math.abs(i.coordinate-t);a<n&&(n=a,r=i)}return r?.value}});var PI=e=>e.options.defaultTooltipEventType,FI=e=>e.options.validateTooltipEventTypes;function II(e,t,n){if(e==null)return t;var r=e?`axis`:`item`;return n==null?t:n.includes(r)?r:t}function LI(e,t){return II(t,PI(e),FI(e))}function _le(e){return U(t=>LI(t,e))}var RI=(e,t)=>{var n,r=Number(t);if(!(WS(r)||t==null))return r>=0?e==null||(n=e[r])==null?void 0:n.value:void 0},vle=e=>e.tooltip.settings,zI={active:!1,index:null,dataKey:void 0,graphicalItemId:void 0,coordinate:void 0},BI=aE({name:`tooltip`,initialState:{itemInteraction:{click:zI,hover:zI},axisInteraction:{click:zI,hover:zI},keyboardInteraction:zI,syncInteraction:{active:!1,index:null,dataKey:void 0,label:void 0,coordinate:void 0,sourceViewBox:void 0,graphicalItemId:void 0},tooltipItemPayloads:[],settings:{shared:void 0,trigger:`hover`,axisId:0,active:!1,defaultIndex:void 0}},reducers:{addTooltipEntrySettings:{reducer(e,t){e.tooltipItemPayloads.push(hO(t.payload))},prepare:tE()},replaceTooltipEntrySettings:{reducer(e,t){var{prev:n,next:r}=t.payload,i=KT(e).tooltipItemPayloads.indexOf(hO(n));i>-1&&(e.tooltipItemPayloads[i]=hO(r))},prepare:tE()},removeTooltipEntrySettings:{reducer(e,t){var n=KT(e).tooltipItemPayloads.indexOf(hO(t.payload));n>-1&&e.tooltipItemPayloads.splice(n,1)},prepare:tE()},setTooltipSettingsState(e,t){e.settings=t.payload},setActiveMouseOverItemIndex(e,t){e.syncInteraction.active=!1,e.syncInteraction.sourceViewBox=void 0,e.keyboardInteraction.active=!1,e.itemInteraction.hover.active=!0,e.itemInteraction.hover.index=t.payload.activeIndex,e.itemInteraction.hover.dataKey=t.payload.activeDataKey,e.itemInteraction.hover.graphicalItemId=t.payload.activeGraphicalItemId,e.itemInteraction.hover.coordinate=t.payload.activeCoordinate},mouseLeaveChart(e){e.itemInteraction.hover.active=!1,e.axisInteraction.hover.active=!1},mouseLeaveItem(e){e.itemInteraction.hover.active=!1},setActiveClickItemIndex(e,t){e.syncInteraction.active=!1,e.syncInteraction.sourceViewBox=void 0,e.itemInteraction.click.active=!0,e.keyboardInteraction.active=!1,e.itemInteraction.click.index=t.payload.activeIndex,e.itemInteraction.click.dataKey=t.payload.activeDataKey,e.itemInteraction.click.graphicalItemId=t.payload.activeGraphicalItemId,e.itemInteraction.click.coordinate=t.payload.activeCoordinate},setMouseOverAxisIndex(e,t){e.syncInteraction.active=!1,e.syncInteraction.sourceViewBox=void 0,e.axisInteraction.hover.active=!0,e.keyboardInteraction.active=!1,e.axisInteraction.hover.index=t.payload.activeIndex,e.axisInteraction.hover.dataKey=t.payload.activeDataKey,e.axisInteraction.hover.coordinate=t.payload.activeCoordinate},setMouseClickAxisIndex(e,t){e.syncInteraction.active=!1,e.syncInteraction.sourceViewBox=void 0,e.keyboardInteraction.active=!1,e.axisInteraction.click.active=!0,e.axisInteraction.click.index=t.payload.activeIndex,e.axisInteraction.click.dataKey=t.payload.activeDataKey,e.axisInteraction.click.coordinate=t.payload.activeCoordinate},setSyncInteraction(e,t){e.syncInteraction=t.payload},setKeyboardInteraction(e,t){e.keyboardInteraction.active=t.payload.active,e.keyboardInteraction.index=t.payload.activeIndex,e.keyboardInteraction.coordinate=t.payload.activeCoordinate}}}),{addTooltipEntrySettings:yle,replaceTooltipEntrySettings:ble,removeTooltipEntrySettings:xle,setTooltipSettingsState:Sle,setActiveMouseOverItemIndex:VI,mouseLeaveItem:Cle,mouseLeaveChart:HI,setActiveClickItemIndex:wle,setMouseOverAxisIndex:UI,setMouseClickAxisIndex:Tle,setSyncInteraction:WI,setKeyboardInteraction:GI}=BI.actions,Ele=BI.reducer;function KI(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function qI(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?KI(Object(n),!0).forEach(function(t){Dle(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):KI(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Dle(e,t,n){return(t=Ole(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ole(e){var t=kle(e,`string`);return typeof t==`symbol`?t:t+``}function kle(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Ale(e,t,n){return t===`axis`?n===`click`?e.axisInteraction.click:e.axisInteraction.hover:n===`click`?e.itemInteraction.click:e.itemInteraction.hover}function jle(e){return e.index!=null}var JI=(e,t,n,r)=>{if(t==null)return zI;var i=Ale(e,t,n);if(i==null)return zI;if(i.active)return i;if(e.keyboardInteraction.active)return e.keyboardInteraction;if(e.syncInteraction.active&&e.syncInteraction.index!=null)return e.syncInteraction;var a=e.settings.active===!0;if(jle(i)){if(a)return qI(qI({},i),{},{active:!0})}else if(r!=null)return{active:!0,coordinate:void 0,dataKey:void 0,index:r,graphicalItemId:void 0};return qI(qI({},zI),{},{coordinate:i.coordinate})};function Mle(e){if(typeof e==`number`)return Number.isFinite(e)?e:void 0;if(e instanceof Date){var t=e.valueOf();return Number.isFinite(t)?t:void 0}var n=Number(e);return Number.isFinite(n)?n:void 0}function Nle(e,t){var n=Mle(e),r=t[0],i=t[1];return n===void 0?!1:n>=Math.min(r,i)&&n<=Math.max(r,i)}function Ple(e,t,n){if(n==null||t==null)return!0;var r=RE(e,t);return r==null||!lA(n)?!0:Nle(r,n)}var YI=(e,t,n,r)=>{var i=e?.index;if(i==null)return null;var a=Number(i);if(!PE(a))return i;var o=0,s=1/0;t.length>0&&(s=t.length-1);var c=Math.max(o,Math.min(a,s)),l=t[c];return l==null||Ple(l,n,r)?String(c):null},XI=(e,t,n,r,i,a,o)=>{if(a!=null){var s=o[0]?.getPosition(a);if(s!=null)return s;var c=i?.[Number(a)];if(c)switch(n){case`horizontal`:return{x:c.coordinate,y:(r.top+t)/2};default:return{x:(r.left+e)/2,y:c.coordinate}}}},ZI=(e,t,n,r)=>{if(t===`axis`)return e.tooltipItemPayloads;if(e.tooltipItemPayloads.length===0)return[];var i=n===`hover`?e.itemInteraction.hover.graphicalItemId:e.itemInteraction.click.graphicalItemId;if(e.syncInteraction.active&&i==null)return e.tooltipItemPayloads;if(i==null&&(r!=null||e.keyboardInteraction.active)){var a=e.tooltipItemPayloads[0];return a==null?[]:[a]}return e.tooltipItemPayloads.filter(e=>e.settings?.graphicalItemId===i)},QI=e=>e.options.tooltipPayloadSearcher,$I=e=>e.tooltip;function eL(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function tL(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?eL(Object(n),!0).forEach(function(t){Fle(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):eL(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Fle(e,t,n){return(t=Ile(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ile(e){var t=Lle(e,`string`);return typeof t==`symbol`?t:t+``}function Lle(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Rle(e){if(typeof e==`string`||typeof e==`number`)return e}function zle(e){if(typeof e==`string`||typeof e==`number`||typeof e==`boolean`)return e}function Ble(e){if(typeof e==`string`||typeof e==`number`)return e;if(typeof e==`function`)return t=>e(t)}function nL(e){if(typeof e==`string`)return e}function Vle(e){if(!(typeof e!=`object`||!e))return{name:`name`in e?Rle(e.name):void 0,unit:`unit`in e?zle(e.unit):void 0,dataKey:`dataKey`in e?Ble(e.dataKey):void 0,payload:`payload`in e?e.payload:void 0,color:`color`in e?nL(e.color):void 0,fill:`fill`in e?nL(e.fill):void 0}}function Hle(e,t){return e??t}var rL=(e,t,n,r,i,a,o)=>{if(!(t==null||a==null)){var{chartData:s,computedData:c,dataStartIndex:l,dataEndIndex:u}=n;return e.reduce((e,n)=>{var{dataDefinedOnItem:d,settings:f}=n,p=Hle(d,s),m=Array.isArray(p)?NE(p,l,u):p,h=f?.dataKey??r,g=f?.nameKey,_=r&&Array.isArray(m)&&!Array.isArray(m[0])&&o===`axis`?ZS(m,r,i):a(m,t,c,g);return Array.isArray(_)?_.forEach(t=>{var n=Vle(t),r=n?.name,i=n?.dataKey,a=n?.payload,o=tL(tL({},f),{},{name:r,unit:n?.unit,color:n?.color??f?.color,fill:n?.fill??f?.fill});e.push(JE({tooltipEntrySettings:o,dataKey:i,payload:a,value:RE(a,i),name:r==null?void 0:String(r)}))}):e.push(JE({tooltipEntrySettings:f,dataKey:h,payload:_,value:RE(_,h),name:RE(_,g)??f?.name})),e},[])}},iL=W([UF,TF,kA],lF),aL=W([W([e=>e.graphicalItems.cartesianItems,e=>e.graphicalItems.polarItems],(e,t)=>[...e,...t]),UF,W([lj,uj],EF)],OF,{memoizeOptions:{resultEqualityCheck:sj}}),Ule=W([aL],e=>e.filter(aj)),oL=W([aL],MF,{memoizeOptions:{resultEqualityCheck:sj}}),Wle=W([aL],e=>e.some(e=>!e.data)),sL=W([oL,nA],PF),Gle=W([Ule,nA,UF],ij),cL=W([sL,UF,aL,nA,Wle,oL],LF),lL=W([UF],JF),uL=W([lL,W([UF],e=>e.allowDataOverflow)],dA),Kle=W([W([Gle,W([aL],e=>e.filter(aj)),DA,OA],GF),nA,lj,uL],qF),qle=W([sL,UF,W([aL],jF),ZF,lj,cA],$F,{memoizeOptions:{resultEqualityCheck:oj}}),Jle=W([W([eI,lj,uj],tI),lj],iI),Yle=W([W([nI,lj,uj],tI),lj],aI),dL=W([UF,TD,sL,cL,DA,lj,W([UF,lL,uL,Kle,qle,W([Jle,W([W([rI,lj,uj],tI),lj],oI),Yle],QF),TD,lj],sI)],cI),Xle=W([UF,dL,W([dL,UF,iL],dI),lj],pI),fL=e=>hI(e,lj(e),uj(e),!1),pL=W([UF,fL],LA),mL=W([W([UF,iL,Xle,pL],cF)],dj),hL=W([TD,UF,iL,mL,fL,W([TD,cL,UF,lj],OI),W([TD,cL,UF,lj],vI),lj],(e,t,n,r,i,a,o,s)=>{if(t){var{type:c}=t,l=zE(e,s);if(r){var u=n===`scaleBand`&&r.bandwidth?r.bandwidth()/2:2,d=c===`category`&&r.bandwidth?r.bandwidth()/u:0;return d=s===`angleAxis`&&i!=null&&i?.length>=2?US(i[0]-i[1])*2*d:d,l&&o?o.map((e,t)=>{var n=r.map(e);return PE(n)?{coordinate:n+d,value:e,index:t,offset:d}:null}).filter(eC):r.domain().map((e,t)=>{var n=r.map(e);return PE(n)?{coordinate:n+d,value:a?a[e]:e,index:t,offset:d}:null}).filter(eC)}}}),gL=W([PI,FI,vle],(e,t,n)=>II(n.shared,e,t)),_L=e=>e.tooltip.settings.trigger,vL=e=>e.tooltip.settings.defaultIndex,yL=W([$I,gL,_L,vL],JI),bL=W([yL,sL,WF,dL],YI),xL=W([hL,bL],RI),SL=W([yL],e=>{if(e)return e.dataKey}),CL=W([yL],e=>{if(e)return e.graphicalItemId}),wL=W([$I,gL,_L,vL],ZI),Zle=W([yL,W([XE,ZE,TD,aD,hL,vL,wL],XI)],(e,t)=>e!=null&&e.coordinate?e.coordinate:t),Qle=W([yL],e=>e?.active??!1),$le=W([W([wL,bL,nA,WF,xL,QI,gL],rL)],e=>{if(e!=null){var t=e.map(e=>e.payload).filter(e=>e!=null);return Array.from(new Set(t))}});function TL(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function EL(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?TL(Object(n),!0).forEach(function(t){eue(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):TL(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function eue(e,t,n){return(t=tue(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function tue(e){var t=nue(e,`string`);return typeof t==`symbol`?t:t+``}function nue(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var rue=()=>U(UF),iue=()=>{var e=rue(),t=U(hL),n=U(mL);return qE(!e||!n?void 0:EL(EL({},e),{},{scale:n}),t)};function DL(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function OL(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?DL(Object(n),!0).forEach(function(t){aue(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):DL(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function aue(e,t,n){return(t=oue(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function oue(e){var t=sue(e,`string`);return typeof t==`symbol`?t:t+``}function sue(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var cue=(e,t,n,r)=>{var i=t.find(e=>e&&e.index===n);if(i){if(e===`horizontal`)return{x:i.coordinate,y:r.relativeY};if(e===`vertical`)return{x:r.relativeX,y:i.coordinate}}return{x:0,y:0}},lue=(e,t,n,r)=>{var i=t.find(e=>e&&e.index===n);if(i){if(e===`centric`){var a=i.coordinate,{radius:o}=r;return OL(OL(OL({},r),Ok(r.cx,r.cy,o,a)),{},{angle:a,radius:o})}var s=i.coordinate,{angle:c}=r;return OL(OL(OL({},r),Ok(r.cx,r.cy,s,c)),{},{angle:c,radius:s})}return{angle:0,clockWise:!1,cx:0,cy:0,endAngle:0,innerRadius:0,outerRadius:0,radius:0,startAngle:0,x:0,y:0}};function uue(e,t){var{relativeX:n,relativeY:r}=e;return n>=t.left&&n<=t.left+t.width&&r>=t.top&&r<=t.top+t.height}var kL=(e,t,n,r,i)=>{var a=t?.length??0;if(a<=1||e==null)return 0;if(r===`angleAxis`&&i!=null&&Math.abs(Math.abs(i[1]-i[0])-360)<=1e-6)for(var o=0;o<a;o++){var s=o>0?n[o-1]?.coordinate:n[a-1]?.coordinate,c=n[o]?.coordinate,l=o>=a-1?n[0]?.coordinate:n[o+1]?.coordinate,u=void 0;if(!(s==null||c==null||l==null))if(US(c-s)!==US(l-c)){var d=[];if(US(l-c)===US(i[1]-i[0])){u=l;var f=c+i[1]-i[0];d[0]=Math.min(f,(f+s)/2),d[1]=Math.max(f,(f+s)/2)}else{u=s;var p=l+i[1]-i[0];d[0]=Math.min(c,(p+c)/2),d[1]=Math.max(c,(p+c)/2)}var m=[Math.min(c,(u+c)/2),Math.max(c,(u+c)/2)];if(e>m[0]&&e<=m[1]||e>=d[0]&&e<=d[1])return n[o]?.index}else{var h=Math.min(s,l),g=Math.max(s,l);if(e>(h+c)/2&&e<=(g+c)/2)return n[o]?.index}}else if(t)for(var _=0;_<a;_++){var v=t[_];if(v!=null){var y=t[_+1],b=t[_-1];if(_===0&&y!=null&&e<=(v.coordinate+y.coordinate)/2||_===a-1&&b!=null&&e>(v.coordinate+b.coordinate)/2||_>0&&_<a-1&&b!=null&&y!=null&&e>(v.coordinate+b.coordinate)/2&&e<=(v.coordinate+y.coordinate)/2)return v.index}}return-1},AL=()=>U(kA),jL=(e,t)=>t,ML=(e,t,n)=>n,NL=(e,t,n,r)=>r,due=W(hL,e=>(0,pw.default)(e,e=>e.coordinate)),PL=W([$I,jL,ML,NL],JI),FL=W([PL,sL,WF,dL],YI),fue=(e,t,n)=>{if(t!=null){var r=$I(e);return t===`axis`?n===`hover`?r.axisInteraction.hover.dataKey:r.axisInteraction.click.dataKey:n===`hover`?r.itemInteraction.hover.dataKey:r.itemInteraction.click.dataKey}},IL=W([$I,jL,ML,NL],ZI),LL=W([XE,ZE,TD,aD,hL,NL,IL],XI),pue=W([PL,LL],(e,t)=>e.coordinate??t),RL=W([hL,FL],RI),mue=W([IL,FL,nA,WF,RL,QI,jL],rL),hue=W([PL,FL],(e,t)=>({isActive:e.active&&t!=null,activeIndex:t})),gue=(e,t,n,r,i,a,o)=>{if(!(!e||!n||!r||!i)&&uue(e,o)){var s=kL(gie(e,t),a,i,n,r),c=cue(t,i,s,e);return{activeIndex:String(s),activeCoordinate:c}}},_ue=(e,t,n,r,i,a,o)=>{if(!(!e||!r||!i||!a||!n)){var s=Pk(e,n);if(s){var c=kL(_ie(s,t),o,a,r,i),l=lue(t,a,c,s);return{activeIndex:String(c),activeCoordinate:l}}}},vue=(e,t,n,r,i,a,o,s)=>{if(!(!e||!t||!r||!i||!a))return t===`horizontal`||t===`vertical`?gue(e,t,r,i,a,o,s):_ue(e,t,n,r,i,a,o)},yue=W(e=>e.zIndex.zIndexMap,(e,t)=>t,(e,t,n)=>n,(e,t,n)=>{if(t!=null){var r=e[t];if(r!=null)return n?r.panoramaElement:r.element}}),bue=W(e=>e.zIndex.zIndexMap,e=>{var t=Object.keys(e).map(e=>parseInt(e,10)).concat(Object.values(PA));return Array.from(new Set(t)).sort((e,t)=>e-t)},{memoizeOptions:{resultEqualityCheck:cj}});function zL(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function BL(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?zL(Object(n),!0).forEach(function(t){xue(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):zL(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function xue(e,t,n){return(t=Sue(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Sue(e){var t=Cue(e,`string`);return typeof t==`symbol`?t:t+``}function Cue(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var wue={zIndexMap:Object.values(PA).reduce((e,t)=>BL(BL({},e),{},{[t]:{element:void 0,panoramaElement:void 0,consumers:0}}),{})},Tue=new Set(Object.values(PA));function Eue(e){return Tue.has(e)}var VL=aE({name:`zIndex`,initialState:wue,reducers:{registerZIndexPortal:{reducer:(e,t)=>{var{zIndex:n}=t.payload;e.zIndexMap[n]?e.zIndexMap[n].consumers+=1:e.zIndexMap[n]={consumers:1,element:void 0,panoramaElement:void 0}},prepare:tE()},unregisterZIndexPortal:{reducer:(e,t)=>{var{zIndex:n}=t.payload;e.zIndexMap[n]&&(--e.zIndexMap[n].consumers,e.zIndexMap[n].consumers<=0&&!Eue(n)&&delete e.zIndexMap[n])},prepare:tE()},registerZIndexPortalElement:{reducer:(e,t)=>{var{zIndex:n,element:r,isPanorama:i}=t.payload;e.zIndexMap[n]?i?e.zIndexMap[n].panoramaElement=hO(r):e.zIndexMap[n].element=hO(r):e.zIndexMap[n]={consumers:0,element:i?void 0:hO(r),panoramaElement:i?hO(r):void 0}},prepare:tE()},unregisterZIndexPortalElement:{reducer:(e,t)=>{var{zIndex:n}=t.payload;e.zIndexMap[n]&&(t.payload.isPanorama?e.zIndexMap[n].panoramaElement=void 0:e.zIndexMap[n].element=void 0)},prepare:tE()}}}),{registerZIndexPortal:Due,unregisterZIndexPortal:HL,registerZIndexPortalElement:Oue,unregisterZIndexPortalElement:kue}=VL.actions,Aue=VL.reducer,UL=_();function WL(e){var{zIndex:t,children:n}=e,r=qie()&&t!==void 0&&t!==0,i=sD(),a=(0,b.useRef)(void 0),o=(0,b.useRef)(new Set),s=HC(),c=U(e=>yue(e,t,i));if((0,b.useLayoutEffect)(()=>{if(!r){var e=o.current;e.forEach(e=>{s(HL({zIndex:e}))}),e.clear(),a.current=void 0;return}if(o.current.has(t)||(s(Due({zIndex:t})),o.current.add(t)),c){a.current=c;var n=o.current;n.forEach(e=>{e!==t&&(s(HL({zIndex:e})),n.delete(e))})}},[s,t,r,c]),(0,b.useLayoutEffect)(()=>{var e=o.current;return()=>{e.forEach(e=>{s(HL({zIndex:e}))}),e.clear()}},[s]),!r)return n;var l=c??a.current;return l?(0,UL.createPortal)(n,l):null}function GL(){return GL=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},GL.apply(null,arguments)}function KL(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function qL(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?KL(Object(n),!0).forEach(function(t){jue(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):KL(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function jue(e,t,n){return(t=Mue(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Mue(e){var t=Nue(e,`string`);return typeof t==`symbol`?t:t+``}function Nue(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Pue(e){var{cursor:t,cursorComp:n,cursorProps:r}=e;return(0,b.isValidElement)(t)?(0,b.cloneElement)(t,r):(0,b.createElement)(n,r)}function Fue(e){var{coordinate:t,payload:n,index:r,offset:i,tooltipAxisBandSize:a,layout:o,cursor:s,tooltipEventType:c,chartName:l}=e,u=t,d=n,f=r;if(!s||!u||l!==`ScatterChart`&&c!==`axis`)return null;var p,m,h;if(l===`ScatterChart`)p=u,m=Qae,h=PA.cursorLine;else if(l===`BarChart`)p=$ae(o,u,i,a),m=bk,h=PA.cursorRectangle;else if(o===`radial`&&sC(u)){var{cx:g,cy:_,radius:v,startAngle:y,endAngle:x}=Fk(u);p={cx:g,cy:_,startAngle:y,endAngle:x,innerRadius:v,outerRadius:v},m=Xk,h=PA.cursorLine}else p={points:Zk(o,u,i)},m=UO,h=PA.cursorLine;var S=typeof s==`object`&&`className`in s?s.className:void 0,C=qL(qL(qL(qL({stroke:`#ccc`,pointerEvents:`none`},i),p),zx(s)),{},{payload:d,payloadIndex:f,className:Px(`recharts-tooltip-cursor`,S)});return b.createElement(WL,{zIndex:e.zIndex??h},b.createElement(Pue,{cursor:s,cursorComp:m,cursorProps:C}))}function Iue(e){var t=iue(),n=SD(),r=ED(),i=AL();return t==null||n==null||r==null||i==null?null:b.createElement(Fue,GL({},e,{offset:n,layout:r,tooltipAxisBandSize:t,chartName:i}))}var JL=(0,b.createContext)(null),Lue=()=>(0,b.useContext)(JL),Rue=u(s(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=`~`;function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(r=!1));function a(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(e,t,n,i,o){if(typeof n!=`function`)throw TypeError(`The listener must be a function`);var s=new a(n,i||e,o),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function s(e,t){--e._eventsCount===0?e._events=new i:delete e._events[t]}function c(){this._events=new i,this._eventsCount=0}c.prototype.eventNames=function(){var e=[],t,i;if(this._eventsCount===0)return e;for(i in t=this._events)n.call(t,i)&&e.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e},c.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,a=n.length,o=Array(a);i<a;i++)o[i]=n[i].fn;return o},c.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},c.prototype.emit=function(e,t,n,i,a,o){var s=r?r+e:e;if(!this._events[s])return!1;var c=this._events[s],l=arguments.length,u,d;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,i),!0;case 5:return c.fn.call(c.context,t,n,i,a),!0;case 6:return c.fn.call(c.context,t,n,i,a,o),!0}for(d=1,u=Array(l-1);d<l;d++)u[d-1]=arguments[d];c.fn.apply(c.context,u)}else{var f=c.length,p;for(d=0;d<f;d++)switch(c[d].once&&this.removeListener(e,c[d].fn,void 0,!0),l){case 1:c[d].fn.call(c[d].context);break;case 2:c[d].fn.call(c[d].context,t);break;case 3:c[d].fn.call(c[d].context,t,n);break;case 4:c[d].fn.call(c[d].context,t,n,i);break;default:if(!u)for(p=1,u=Array(l-1);p<l;p++)u[p-1]=arguments[p];c[d].fn.apply(c[d].context,u)}}return!0},c.prototype.on=function(e,t,n){return o(this,e,t,n,!1)},c.prototype.once=function(e,t,n){return o(this,e,t,n,!0)},c.prototype.removeListener=function(e,t,n,i){var a=r?r+e:e;if(!this._events[a])return this;if(!t)return s(this,a),this;var o=this._events[a];if(o.fn)o.fn===t&&(!i||o.once)&&(!n||o.context===n)&&s(this,a);else{for(var c=0,l=[],u=o.length;c<u;c++)(o[c].fn!==t||i&&!o[c].once||n&&o[c].context!==n)&&l.push(o[c]);l.length?this._events[a]=l.length===1?l[0]:l:s(this,a)}return this},c.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&s(this,t)):(this._events=new i,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=r,c.EventEmitter=c,t!==void 0&&(t.exports=c)}))(),1).default,YL=new Rue,XL=`recharts.syncEvent.tooltip`,ZL=`recharts.syncEvent.brush`,QL=(e,t)=>{if(t&&Array.isArray(e)){var n=Number.parseInt(t,10);if(!WS(n))return e[n]}},$L=aE({name:`options`,initialState:{chartName:``,tooltipPayloadSearcher:()=>void 0,eventEmitter:void 0,defaultTooltipEventType:`axis`},reducers:{createEventEmitter:e=>{e.eventEmitter??=Symbol(`rechartsEventEmitter`)}}}),zue=$L.reducer,{createEventEmitter:Bue}=$L.actions;function Vue(e){return e.tooltip.syncInteraction}var eR=aE({name:`chartData`,initialState:{chartData:void 0,computedData:void 0,dataStartIndex:0,dataEndIndex:0},reducers:{setChartData(e,t){if(e.chartData=hO(t.payload),t.payload==null){e.dataStartIndex=0,e.dataEndIndex=0;return}t.payload.length>0&&e.dataEndIndex!==t.payload.length-1&&(e.dataEndIndex=t.payload.length-1)},setComputedData(e,t){e.computedData=t.payload},setDataStartEndIndexes(e,t){var{startIndex:n,endIndex:r}=t.payload;n!=null&&(e.dataStartIndex=n),r!=null&&(e.dataEndIndex=r)}}}),{setChartData:tR,setDataStartEndIndexes:Hue,setComputedData:Uue}=eR.actions,Wue=eR.reducer,Gue=[`x`,`y`];function nR(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function rR(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?nR(Object(n),!0).forEach(function(t){Kue(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):nR(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Kue(e,t,n){return(t=que(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function que(e){var t=Jue(e,`string`);return typeof t==`symbol`?t:t+``}function Jue(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Yue(e,t){if(e==null)return{};var n,r,i=Xue(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Xue(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Zue(){var e=U(AA),t=U(MA),n=HC(),r=U(jA),i=U(hL),a=ED(),o=xD();(0,b.useEffect)(()=>{if(e==null)return tC;var s=(s,c,l)=>{if(t!==l&&e===s){if(c.payload.active===!1){n(WI({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:void 0,graphicalItemId:void 0}));return}if(r===`index`){var u;if(o&&c!=null&&(u=c.payload)!=null&&u.coordinate&&c.payload.sourceViewBox){var d=c.payload.coordinate,{x:f,y:p}=d,m=Yue(d,Gue),{x:h,y:g,width:_,height:v}=c.payload.sourceViewBox,y=rR(rR({},m),{},{x:o.x+(_?(f-h)/_:0)*o.width,y:o.y+(v?(p-g)/v:0)*o.height});n(rR(rR({},c),{},{payload:rR(rR({},c.payload),{},{coordinate:y})}))}else n(c);return}if(i!=null){var b;typeof r==`function`?b=i[r(i,{activeTooltipIndex:c.payload.index==null?void 0:Number(c.payload.index),isTooltipActive:c.payload.active,activeIndex:c.payload.index==null?void 0:Number(c.payload.index),activeLabel:c.payload.label,activeDataKey:c.payload.dataKey,activeCoordinate:c.payload.coordinate})]:r===`value`&&(b=i.find(e=>String(e.value)===c.payload.label));var{coordinate:x}=c.payload;if(x==null||o==null){n(WI({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:void 0,graphicalItemId:void 0}));return}if(b==null){n(WI({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:c.payload.sourceViewBox,graphicalItemId:void 0}));return}var{x:S,y:C}=x,w=Math.min(S,o.x+o.width),T=Math.min(C,o.y+o.height),E={x:a===`horizontal`?b.coordinate:w,y:a===`horizontal`?T:b.coordinate};n(WI({active:c.payload.active,coordinate:E,dataKey:c.payload.dataKey,index:String(b.index),label:c.payload.label,sourceViewBox:c.payload.sourceViewBox,graphicalItemId:c.payload.graphicalItemId}))}}};return YL.on(XL,s),()=>{YL.off(XL,s)}},[U(e=>e.rootProps.className),n,t,e,r,i,a,o])}function Que(){var e=U(AA),t=U(MA),n=HC();(0,b.useEffect)(()=>{if(e==null)return tC;var r=(r,i,a)=>{t!==a&&e===r&&n(Hue(i))};return YL.on(ZL,r),()=>{YL.off(ZL,r)}},[n,t,e])}function $ue(){var e=HC();(0,b.useEffect)(()=>{e(Bue())},[e]),Zue(),Que()}function ede(e,t,n,r,i,a){var o=U(n=>fue(n,e,t)),s=U(CL),c=U(MA),l=U(AA),u=U(jA),d=U(Vue)?.sourceViewBox!=null,f=xD();(0,b.useEffect)(()=>{if(!d&&l!=null&&c!=null){var e=WI({active:a,coordinate:n,dataKey:o,index:i,label:typeof r==`number`?String(r):r,sourceViewBox:f,graphicalItemId:s});YL.emit(XL,l,e,c)}},[d,n,o,s,i,r,c,l,u,a,f])}function iR(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function aR(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?iR(Object(n),!0).forEach(function(t){tde(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):iR(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function tde(e,t,n){return(t=nde(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function nde(e){var t=rde(e,`string`);return typeof t==`symbol`?t:t+``}function rde(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function ide(e){return e.dataKey}function ade(e,t){return b.isValidElement(e)?b.cloneElement(e,t):typeof e==`function`?b.createElement(e,t):b.createElement(Oae,t)}var oR=[],ode={allowEscapeViewBox:{x:!1,y:!1},animationDuration:400,animationEasing:`ease`,axisId:0,contentStyle:{},cursor:!0,filterNull:!0,includeHidden:!1,isAnimationActive:`auto`,itemSorter:`name`,itemStyle:{},labelStyle:{},offset:10,reverseDirection:{x:!1,y:!1},separator:` : `,trigger:`hover`,useTranslate3d:!1,wrapperStyle:{}};function sR(e){var t=dC(e,ode),{active:n,allowEscapeViewBox:r,animationDuration:i,animationEasing:a,content:o,filterNull:s,isAnimationActive:c,offset:l,payloadUniqBy:u,position:d,reverseDirection:f,useTranslate3d:p,wrapperStyle:m,cursor:h,shared:g,trigger:_,defaultIndex:v,portal:y,axisId:x}=t,S=HC(),C=typeof v==`number`?String(v):v;(0,b.useEffect)(()=>{S(Sle({shared:g,trigger:_,axisId:x,active:n,defaultIndex:C}))},[S,g,_,x,n,C]);var w=xD(),T=NO(),E=_le(g),{activeIndex:D,isActive:O}=U(e=>hue(e,E,_,C))??{},k=U(e=>mue(e,E,_,C)),ee=U(e=>RL(e,E,_,C)),te=U(e=>pue(e,E,_,C)),ne=k,re=Lue(),A=n??O??!1,[ie,j]=_w([ne,A]),M=E===`axis`?ee:void 0;ede(E,_,te,M,D,A);var ae=y??re;if(ae==null||w==null||E==null)return null;var oe=ne??oR;A||(oe=oR),s&&oe.length&&(oe=PC(oe.filter(e=>e.value!=null&&(e.hide!==!0||t.includeHidden)),u,ide));var se=oe.length>0,N=aR(aR({},t),{},{payload:oe,label:M,active:A,activeIndex:D,coordinate:te,accessibilityLayer:T}),ce=b.createElement(Rae,{allowEscapeViewBox:r,animationDuration:i,animationEasing:a,isAnimationActive:c,active:A,coordinate:te,hasPayload:se,offset:l,position:d,reverseDirection:f,useTranslate3d:p,viewBox:w,wrapperStyle:m,lastBoundingBox:ie,innerRef:j,hasPortalFromProps:!!y},ade(o,N));return b.createElement(b.Fragment,null,(0,UL.createPortal)(ce,ae),A&&b.createElement(Iue,{cursor:h,tooltipEventType:E,coordinate:te,payload:oe,index:D}))}var cR=e=>null;cR.displayName=`Cell`;function sde(e,t,n){return(t=cde(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function cde(e){var t=lde(e,`string`);return typeof t==`symbol`?t:t+``}function lde(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var ude=class{constructor(e){sde(this,`cache`,new Map),this.maxSize=e}get(e){var t=this.cache.get(e);return t!==void 0&&(this.cache.delete(e),this.cache.set(e,t)),t}set(e,t){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.maxSize){var n=this.cache.keys().next().value;n!=null&&this.cache.delete(n)}this.cache.set(e,t)}clear(){this.cache.clear()}size(){return this.cache.size}};function lR(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function dde(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?lR(Object(n),!0).forEach(function(t){fde(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):lR(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function fde(e,t,n){return(t=pde(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function pde(e){var t=mde(e,`string`);return typeof t==`symbol`?t:t+``}function mde(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var uR=dde({},{cacheSize:2e3,enableCache:!0}),dR=new ude(uR.cacheSize),hde={position:`absolute`,top:`-20000px`,left:0,padding:0,margin:0,border:`none`,whiteSpace:`pre`},fR=`recharts_measurement_span`;function gde(e,t){return`${e}|${t.fontSize||``}|${t.fontFamily||``}|${t.fontWeight||``}|${t.fontStyle||``}|${t.letterSpacing||``}|${t.textTransform||``}`}var pR=(e,t)=>{try{var n=document.getElementById(fR);n||(n=document.createElement(`span`),n.setAttribute(`id`,fR),n.setAttribute(`aria-hidden`,`true`),document.body.appendChild(n)),Object.assign(n.style,hde,t),n.textContent=`${e}`;var r=n.getBoundingClientRect();return{width:r.width,height:r.height}}catch{return{width:0,height:0}}},mR=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e==null||kO.isSsr)return{width:0,height:0};if(!uR.enableCache)return pR(e,t);var n=gde(e,t),r=dR.get(n);if(r)return r;var i=pR(e,t);return dR.set(n,i),i},hR;function _de(e,t,n){return(t=vde(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function vde(e){var t=yde(e,`string`);return typeof t==`symbol`?t:t+``}function yde(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var gR=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([*/])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,_R=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([+-])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,bde=/^(px|cm|vh|vw|em|rem|%|mm|in|pt|pc|ex|ch|vmin|vmax|Q)$/,xde=/(-?\d+(?:\.\d+)?)([a-zA-Z%]+)?/,Sde={cm:96/2.54,mm:96/25.4,pt:96/72,pc:96/6,in:96,Q:96/(2.54*40),px:1},Cde=[`cm`,`mm`,`pt`,`pc`,`in`,`Q`,`px`];function wde(e){return Cde.includes(e)}var vR=`NaN`;function Tde(e,t){return e*Sde[t]}var yR=class e{static parse(t){var[,n,r]=xde.exec(t)??[];return n==null?e.NaN:new e(parseFloat(n),r??``)}constructor(e,t){this.num=e,this.unit=t,this.num=e,this.unit=t,WS(e)&&(this.unit=``),t!==``&&!bde.test(t)&&(this.num=NaN,this.unit=``),wde(t)&&(this.num=Tde(e,t),this.unit=`px`)}add(t){return this.unit===t.unit?new e(this.num+t.num,this.unit):new e(NaN,``)}subtract(t){return this.unit===t.unit?new e(this.num-t.num,this.unit):new e(NaN,``)}multiply(t){return this.unit!==``&&t.unit!==``&&this.unit!==t.unit?new e(NaN,``):new e(this.num*t.num,this.unit||t.unit)}divide(t){return this.unit!==``&&t.unit!==``&&this.unit!==t.unit?new e(NaN,``):new e(this.num/t.num,this.unit||t.unit)}toString(){return`${this.num}${this.unit}`}isNaN(){return WS(this.num)}};hR=yR,_de(yR,`NaN`,new hR(NaN,``));function bR(e){if(e==null||e.includes(vR))return vR;for(var t=e;t.includes(`*`)||t.includes(`/`);){var[,n,r,i]=gR.exec(t)??[],a=yR.parse(n??``),o=yR.parse(i??``),s=r===`*`?a.multiply(o):a.divide(o);if(s.isNaN())return vR;t=t.replace(gR,s.toString())}for(;t.includes(`+`)||/.-\d+(?:\.\d+)?/.test(t);){var[,c,l,u]=_R.exec(t)??[],d=yR.parse(c??``),f=yR.parse(u??``),p=l===`+`?d.add(f):d.subtract(f);if(p.isNaN())return vR;t=t.replace(_R,p.toString())}return t}var xR=/\(([^()]*)\)/;function Ede(e){for(var t=e,n;(n=xR.exec(t))!=null;){var[,r]=n;t=t.replace(xR,bR(r))}return t}function Dde(e){var t=e.replace(/\s+/g,``);return t=Ede(t),t=bR(t),t}function Ode(e){try{return Dde(e)}catch{return vR}}function SR(e){var t=Ode(e.slice(5,-1));return t===vR?``:t}var kde=[`x`,`y`,`lineHeight`,`capHeight`,`fill`,`scaleToFit`,`textAnchor`,`verticalAnchor`],Ade=[`dx`,`dy`,`angle`,`className`,`breakAll`];function CR(){return CR=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},CR.apply(null,arguments)}function wR(e,t){if(e==null)return{};var n,r,i=jde(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function jde(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var TR=/[ \f\n\r\t\v\u2028\u2029]+/,ER=e=>{var{children:t,breakAll:n,style:r}=e;try{var i=[];return QS(t)||(i=n?t.toString().split(``):t.toString().split(TR)),{wordsWithComputedWidth:i.map(e=>({word:e,width:mR(e,r).width})),spaceWidth:n?0:mR(`\xA0`,r).width}}catch{return null}};function DR(e){return e===`start`||e===`middle`||e===`end`||e===`inherit`}function Mde(e){return QS(e)||typeof e==`string`||typeof e==`number`||typeof e==`boolean`}var OR=(e,t,n,r)=>e.reduce((e,i)=>{var{word:a,width:o}=i,s=e[e.length-1];if(s&&o!=null&&(t==null||r||s.width+o+n<Number(t)))s.words.push(a),s.width+=o+n;else{var c={words:[a],width:o};e.push(c)}return e},[]),kR=e=>e.reduce((e,t)=>e.width>t.width?e:t),Nde=`…`,AR=(e,t,n,r,i,a,o,s)=>{var c=ER({breakAll:n,style:r,children:e.slice(0,t)+Nde});if(!c)return[!1,[]];var l=OR(c.wordsWithComputedWidth,a,o,s);return[l.length>i||kR(l).width>Number(a),l]},Pde=(e,t,n,r,i)=>{var{maxLines:a,children:o,style:s,breakAll:c}=e,l=H(a),u=String(o),d=OR(t,r,n,i);if(!l||i||!(d.length>a||kR(d).width>Number(r)))return d;for(var f=0,p=u.length-1,m=0,h;f<=p&&m<=u.length-1;){var g=Math.floor((f+p)/2),[_,v]=AR(u,g-1,c,s,a,r,n,i),[y]=AR(u,g,c,s,a,r,n,i);if(!_&&!y&&(f=g+1),_&&y&&(p=g-1),!_&&y){h=v;break}m++}return h||d},jR=e=>[{words:QS(e)?[]:e.toString().split(TR),width:void 0}],Fde=e=>{var{width:t,scaleToFit:n,children:r,style:i,breakAll:a,maxLines:o}=e;if((t||n)&&!kO.isSsr){var s,c,l=ER({breakAll:a,children:r,style:i});if(l){var{wordsWithComputedWidth:u,spaceWidth:d}=l;s=u,c=d}else return jR(r);return Pde({breakAll:a,children:r,maxLines:o,style:i},s,c,t,!!n)}return jR(r)},MR=`#808080`,Ide={angle:0,breakAll:!1,capHeight:`0.71em`,fill:MR,lineHeight:`1em`,scaleToFit:!1,textAnchor:`start`,verticalAnchor:`end`,x:0,y:0},NR=(0,b.forwardRef)((e,t)=>{var n=dC(e,Ide),{x:r,y:i,lineHeight:a,capHeight:o,fill:s,scaleToFit:c,textAnchor:l,verticalAnchor:u}=n,d=wR(n,kde),f=(0,b.useMemo)(()=>Fde({breakAll:d.breakAll,children:d.children,maxLines:d.maxLines,scaleToFit:c,style:d.style,width:d.width}),[d.breakAll,d.children,d.maxLines,c,d.style,d.width]),{dx:p,dy:m,angle:h,className:g,breakAll:_}=d,v=wR(d,Ade);if(!KS(r)||!KS(i)||f.length===0)return null;var y=Number(r)+(H(p)?p:0),x=Number(i)+(H(m)?m:0);if(!PE(y)||!PE(x))return null;var S;switch(u){case`start`:S=SR(`calc(${o})`);break;case`middle`:S=SR(`calc(${(f.length-1)/2} * -${a} + (${o} / 2))`);break;default:S=SR(`calc(${f.length-1} * -${a})`);break}var C=[],w=f[0];if(c&&w!=null){var T=w.width,{width:E}=d;C.push(`scale(${H(E)&&H(T)?E/T:1})`)}return h&&C.push(`rotate(${h}, ${y}, ${x})`),C.length&&(v.transform=C.join(` `)),b.createElement(`text`,CR({},Bx(v),{ref:t,x:y,y:x,className:Px(`recharts-text`,g),textAnchor:l,fill:s.includes(`url`)?MR:s}),f.map((e,t)=>{var n=e.words.join(_?``:` `);return b.createElement(`tspan`,{x:y,dy:t===0?S:a,key:`${n}-${t}`},n)}))});NR.displayName=`Text`;function PR(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function FR(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?PR(Object(n),!0).forEach(function(t){Lde(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):PR(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Lde(e,t,n){return(t=Rde(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Rde(e){var t=zde(e,`string`);return typeof t==`symbol`?t:t+``}function zde(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var Bde=e=>{var{viewBox:t,position:n,offset:r=0,parentViewBox:i,clamp:a}=e,{x:o,y:s,height:c,upperWidth:l,lowerWidth:u}=bD(t),d=o,f=o+(l-u)/2,p=(d+f)/2,m=(l+u)/2,h=d+l/2,g=c>=0?1:-1,_=g*r,v=g>0?`end`:`start`,y=g>0?`start`:`end`,b=l>=0?1:-1,x=b*r,S=b>0?`end`:`start`,C=b>0?`start`:`end`,w=i;if(n===`top`){var T={x:d+l/2,y:s-_,horizontalAnchor:`middle`,verticalAnchor:v};return a&&w&&(T.height=Math.max(s-w.y,0),T.width=l),T}if(n===`bottom`){var E={x:f+u/2,y:s+c+_,horizontalAnchor:`middle`,verticalAnchor:y};return a&&w&&(E.height=Math.max(w.y+w.height-(s+c),0),E.width=u),E}if(n===`left`){var D={x:p-x,y:s+c/2,horizontalAnchor:S,verticalAnchor:`middle`};return a&&w&&(D.width=Math.max(D.x-w.x,0),D.height=c),D}if(n===`right`){var O={x:p+m+x,y:s+c/2,horizontalAnchor:C,verticalAnchor:`middle`};return a&&w&&(O.width=Math.max(w.x+w.width-O.x,0),O.height=c),O}var k=a&&w?{width:m,height:c}:{};return n===`insideLeft`?FR({x:p+x,y:s+c/2,horizontalAnchor:C,verticalAnchor:`middle`},k):n===`insideRight`?FR({x:p+m-x,y:s+c/2,horizontalAnchor:S,verticalAnchor:`middle`},k):n===`insideTop`?FR({x:d+l/2,y:s+_,horizontalAnchor:`middle`,verticalAnchor:y},k):n===`insideBottom`?FR({x:f+u/2,y:s+c-_,horizontalAnchor:`middle`,verticalAnchor:v},k):n===`insideTopLeft`?FR({x:d+x,y:s+_,horizontalAnchor:C,verticalAnchor:y},k):n===`insideTopRight`?FR({x:d+l-x,y:s+_,horizontalAnchor:S,verticalAnchor:y},k):n===`insideBottomLeft`?FR({x:f+x,y:s+c-_,horizontalAnchor:C,verticalAnchor:v},k):n===`insideBottomRight`?FR({x:f+u-x,y:s+c-_,horizontalAnchor:S,verticalAnchor:v},k):n&&typeof n==`object`&&(H(n.x)||GS(n.x))&&(H(n.y)||GS(n.y))?FR({x:o+JS(n.x,m),y:s+JS(n.y,c),horizontalAnchor:`end`,verticalAnchor:`end`},k):FR({x:h,y:s+c/2,horizontalAnchor:`middle`,verticalAnchor:`middle`},k)},Vde=[`labelRef`],Hde=[`content`];function IR(e,t){if(e==null)return{};var n,r,i=Ude(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Ude(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function LR(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function RR(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?LR(Object(n),!0).forEach(function(t){Wde(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):LR(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Wde(e,t,n){return(t=Gde(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Gde(e){var t=Kde(e,`string`);return typeof t==`symbol`?t:t+``}function Kde(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function zR(){return zR=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},zR.apply(null,arguments)}var BR=(0,b.createContext)(null),VR=e=>{var{x:t,y:n,upperWidth:r,lowerWidth:i,width:a,height:o,children:s}=e,c=(0,b.useMemo)(()=>({x:t,y:n,upperWidth:r,lowerWidth:i,width:a,height:o}),[t,n,r,i,a,o]);return b.createElement(BR.Provider,{value:c},s)},HR=()=>{var e=(0,b.useContext)(BR),t=xD();return e||(t?bD(t):void 0)},qde=(0,b.createContext)(null),Jde=()=>{var e=(0,b.useContext)(qde),t=U(ej);return e||t},Yde=e=>{var{value:t,formatter:n}=e,r=QS(e.children)?t:e.children;return typeof n==`function`?n(r):r},UR=e=>e!=null&&typeof e==`function`,Xde=(e,t)=>US(t-e)*Math.min(Math.abs(t-e),360),Zde=(e,t,n,r,i)=>{var{offset:a,className:o}=e,{cx:s,cy:c,innerRadius:l,outerRadius:u,startAngle:d,endAngle:f,clockWise:p}=i,m=(l+u)/2,h=Xde(d,f),g=h>=0?1:-1,_,v;switch(t){case`insideStart`:_=d+g*a,v=p;break;case`insideEnd`:_=f-g*a,v=!p;break;case`end`:_=f+g*a,v=p;break;default:throw Error(`Unsupported position ${t}`)}v=h<=0?v:!v;var y=Ok(s,c,m,_),x=Ok(s,c,m,_+(v?1:-1)*359),S=`M${y.x},${y.y}
237
237
  A${m},${m},0,1,${+!v},
238
- ${x.x},${x.y}`,C=QS(e.id)?qS(`recharts-radial-line-`):e.id;return b.createElement(`text`,zR({},r,{dominantBaseline:`central`,className:Px(`recharts-radial-bar-label`,o)}),b.createElement(`defs`,null,b.createElement(`path`,{id:C,d:S})),b.createElement(`textPath`,{xlinkHref:`#${C}`},n))},Qde=(e,t,n)=>{var{cx:r,cy:i,innerRadius:a,outerRadius:o,startAngle:s,endAngle:c}=e,l=(s+c)/2;if(n===`outside`){var{x:u,y:d}=Ok(r,i,o+t,l);return{x:u,y:d,textAnchor:u>=r?`start`:`end`,verticalAnchor:`middle`}}if(n===`center`)return{x:r,y:i,textAnchor:`middle`,verticalAnchor:`middle`};if(n===`centerTop`)return{x:r,y:i,textAnchor:`middle`,verticalAnchor:`start`};if(n===`centerBottom`)return{x:r,y:i,textAnchor:`middle`,verticalAnchor:`end`};var{x:f,y:p}=Ok(r,i,(a+o)/2,l);return{x:f,y:p,textAnchor:`middle`,verticalAnchor:`middle`}},WR=e=>e!=null&&`cx`in e&&H(e.cx),$de={angle:0,offset:5,zIndex:PA.label,position:`middle`,textBreakAll:!1};function efe(e){if(!WR(e))return e;var{cx:t,cy:n,outerRadius:r}=e,i=r*2;return{x:t-r,y:n-r,width:i,upperWidth:i,lowerWidth:i,height:i}}function GR(e){var t=dC(e,$de),{viewBox:n,parentViewBox:r,position:i,value:a,children:o,content:s,className:c=``,textBreakAll:l,labelRef:u}=t,d=Jde(),f=HR(),p=n==null?i===`center`?f:d??f:WR(n)?n:bD(n),m,h,g=efe(p);if(!p||QS(a)&&QS(o)&&!(0,b.isValidElement)(s)&&typeof s!=`function`)return null;var _=RR(RR({},t),{},{viewBox:p});if((0,b.isValidElement)(s)){var{labelRef:v}=_;return(0,b.cloneElement)(s,IR(_,Vde))}if(typeof s==`function`){var{content:y}=_;if(m=(0,b.createElement)(s,IR(_,Hde)),(0,b.isValidElement)(m))return m}else m=Yde(t);var x=Bx(t);if(WR(p)){if(i===`insideStart`||i===`insideEnd`||i===`end`)return Zde(t,i,m,x,p);h=Qde(p,t.offset,t.position)}else{if(!g)return null;var S=Bde({viewBox:g,position:i,offset:t.offset,parentViewBox:WR(r)?void 0:r,clamp:!0});h=RR(RR({x:S.x,y:S.y,textAnchor:S.horizontalAnchor,verticalAnchor:S.verticalAnchor},S.width===void 0?{}:{width:S.width}),S.height===void 0?{}:{height:S.height})}return b.createElement(WL,{zIndex:t.zIndex},b.createElement(NR,zR({ref:u,className:Px(`recharts-label`,c)},x,h,{textAnchor:DR(x.textAnchor)?x.textAnchor:h.textAnchor,breakAll:l}),m))}GR.displayName=`Label`;var tfe=(e,t,n)=>{if(!e)return null;var r={viewBox:t,labelRef:n};return e===!0?b.createElement(GR,zR({key:`label-implicit`},r)):KS(e)?b.createElement(GR,zR({key:`label-implicit`,value:e},r)):(0,b.isValidElement)(e)?e.type===GR?(0,b.cloneElement)(e,RR({key:`label-implicit`},r)):b.createElement(GR,zR({key:`label-implicit`,content:e},r)):UR(e)?b.createElement(GR,zR({key:`label-implicit`,content:e},r)):e&&typeof e==`object`?b.createElement(GR,zR({},e,{key:`label-implicit`},r)):null};function KR(e){var{label:t,labelRef:n}=e;return tfe(t,HR(),n)||null}var nfe=[`valueAccessor`],rfe=[`dataKey`,`clockWise`,`id`,`textBreakAll`,`zIndex`];function qR(){return qR=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},qR.apply(null,arguments)}function JR(e,t){if(e==null)return{};var n,r,i=ife(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function ife(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var afe=e=>{var t=Array.isArray(e.value)?e.value[e.value.length-1]:e.value;if(Mde(t))return t},YR=(0,b.createContext)(void 0),XR=YR.Provider,ZR=(0,b.createContext)(void 0),ofe=ZR.Provider;function sfe(){return(0,b.useContext)(YR)}function cfe(){return(0,b.useContext)(ZR)}function QR(e){var{valueAccessor:t=afe}=e,n=JR(e,nfe),{dataKey:r,clockWise:i,id:a,textBreakAll:o,zIndex:s}=n,c=JR(n,rfe),l=sfe(),u=cfe(),d=l||u;return!d||!d.length?null:b.createElement(WL,{zIndex:s??PA.label},b.createElement(Wx,{className:`recharts-label-list`},d.map((e,i)=>{var s=QS(r)?t(e,i):RE(e.payload,r),l=QS(a)?{}:{id:`${a}-${i}`};return b.createElement(GR,qR({key:`label-${i}`},Bx(e),c,l,{fill:n.fill??e.fill,parentViewBox:e.parentViewBox,value:s,textBreakAll:o,viewBox:e.viewBox,index:i,zIndex:0}))})))}QR.displayName=`LabelList`;function $R(e){var{label:t}=e;return t?t===!0?b.createElement(QR,{key:`labelList-implicit`}):b.isValidElement(t)||UR(t)?b.createElement(QR,{key:`labelList-implicit`,content:t}):typeof t==`object`?b.createElement(QR,qR({key:`labelList-implicit`},t,{type:String(t.type)})):null:null}function ez(){return ez=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},ez.apply(null,arguments)}var tz=e=>{var{cx:t,cy:n,r,className:i}=e,a=Px(`recharts-dot`,i);return H(t)&&H(n)&&H(r)?b.createElement(`circle`,ez({},Rx(e),cC(e),{className:a,cx:t,cy:n,r})):null},nz=e=>e.graphicalItems.polarItems,rz=W([nz,CF,W([tj,nj],EF)],OF),iz=W([W([rz],MF),rA],PF),lfe=W([iz,CF,rz],IF);W([iz,CF,rz],(e,t,n)=>n.length>0?e.flatMap(e=>n.flatMap(n=>({value:RE(e,t.dataKey??n.dataKey),errorDomain:[]}))).filter(Boolean):t?.dataKey==null?e.map(e=>({value:e,errorDomain:[]})):e.map(e=>({value:RE(e,t.dataKey),errorDomain:[]})));var az=()=>void 0,oz=W([CF,TD,iz,lfe,DA,tj,W([CF,YF,XF,az,W([iz,CF,rz,ZF,tj,sA],$F),az,TD,tj],sI)],cI);W([uI,W([CF,oz,W([oz,wF,uI],dI),tj],pI)],fj);var sz=aE({name:`polarAxis`,initialState:{radiusAxis:{},angleAxis:{}},reducers:{addRadiusAxis(e,t){e.radiusAxis[t.payload.id]=hO(t.payload)},removeRadiusAxis(e,t){delete e.radiusAxis[t.payload.id]},addAngleAxis(e,t){e.angleAxis[t.payload.id]=hO(t.payload)},removeAngleAxis(e,t){delete e.angleAxis[t.payload.id]}}}),{addRadiusAxis:ufe,removeRadiusAxis:dfe,addAngleAxis:ffe,removeAngleAxis:pfe}=sz.actions,mfe=sz.reducer;function cz(e){return e&&typeof e==`object`&&`className`in e&&typeof e.className==`string`?e.className:``}function lz(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function uz(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?lz(Object(n),!0).forEach(function(t){hfe(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):lz(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function hfe(e,t,n){return(t=gfe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function gfe(e){var t=_fe(e,`string`);return typeof t==`symbol`?t:t+``}function _fe(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var dz=W([nz,(e,t)=>t],(e,t)=>e.filter(e=>e.type===`pie`).find(e=>e.id===t)),vfe=[],fz=(e,t,n)=>n?.length===0?vfe:n,pz=W([rA,dz,fz],(e,t,n)=>{var{chartData:r}=e;if(t!=null){var i=t?.data!=null&&t.data.length>0?t.data:r;if((!i||!i.length)&&n!=null&&(i=n.map(e=>uz(uz({},t.presentationProps),e.props))),i!=null)return i}}),yfe=W([pz,dz,fz],(e,t,n)=>{if(!(e==null||t==null))return e.map((e,r)=>{var i,a=RE(e,t.nameKey,t.name),o=n!=null&&(i=n[r])!=null&&(i=i.props)!=null&&i.fill?n[r].props.fill:typeof e==`object`&&e&&`fill`in e?e.fill:t.fill;return{value:YE(a,t.dataKey),color:o,payload:e,type:t.legendType}})}),bfe=W([pz,dz,fz,aD],(e,t,n,r)=>{if(!(t==null||e==null))return Cpe({offset:r,pieSettings:t,displayedData:e,cells:n})}),xfe=s((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.suspense_list`),d=Symbol.for(`react.memo`),f=Symbol.for(`react.lazy`),p=Symbol.for(`react.view_transition`);function m(e){if(typeof e==`object`&&e){var m=e.$$typeof;switch(m){case t:switch(e=e.type,e){case r:case a:case i:case l:case u:case p:return e;default:switch(e&&=e.$$typeof,e){case s:case c:case f:case d:return e;case o:return e;default:return m}}case n:return m}}}e.isFragment=function(e){return m(e)===r}})),Sfe=s(((e,t)=>{t.exports=xfe()}))(),mz=e=>typeof e==`string`?e:e?e.displayName||e.name||`Component`:``,hz=null,gz=null,_z=e=>{if(e===hz&&Array.isArray(gz))return gz;var t=[];return b.Children.forEach(e,e=>{QS(e)||((0,Sfe.isFragment)(e)?t=t.concat(_z(e.props.children)):t.push(e))}),gz=t,hz=e,t};function vz(e,t){var n=[],r=[];return r=Array.isArray(t)?t.map(e=>mz(e)):[mz(t)],_z(e).forEach(e=>{var t=(0,HS.default)(e,`type.displayName`)||(0,HS.default)(e,`type.name`);t&&r.indexOf(t)!==-1&&n.push(e)}),n}var yz=e=>e&&typeof e==`object`&&`clipDot`in e?!!e.clipDot:!0,Cfe=s((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e){if(typeof e!=`object`||!e)return!1;if(Object.getPrototypeOf(e)===null)return!0;if(Object.prototype.toString.call(e)!==`[object Object]`){let t=e[Symbol.toStringTag];return t==null||!Object.getOwnPropertyDescriptor(e,Symbol.toStringTag)?.writable?!1:e.toString()===`[object ${t}]`}let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}e.isPlainObject=t})),wfe=s(((e,t)=>{t.exports=Cfe().isPlainObject})),Tfe,Efe,Dfe,Ofe,kfe;function bz(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function xz(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?bz(Object(n),!0).forEach(function(t){Afe(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):bz(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Afe(e,t,n){return(t=jfe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function jfe(e){var t=Mfe(e,`string`);return typeof t==`symbol`?t:t+``}function Mfe(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Sz(){return Sz=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Sz.apply(null,arguments)}function Cz(e,t){return t||=e.slice(0),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}var wz=(e,t,n,r,i)=>{var a=n-r,o=VS(Tfe||=Cz([`M `,`,`,``]),e,t);return o+=VS(Efe||=Cz([`L `,`,`,``]),e+n,t),o+=VS(Dfe||=Cz([`L `,`,`,``]),e+n-a/2,t+i),o+=VS(Ofe||=Cz([`L `,`,`,``]),e+n-a/2-r,t+i),o+=VS(kfe||=Cz([`L `,`,`,` Z`]),e,t),o},Nfe={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:`ease`},Pfe=e=>{var t=dC(e,Nfe),{x:n,y:r,upperWidth:i,lowerWidth:a,height:o,className:s}=t,{animationEasing:c,animationDuration:l,animationBegin:u,isUpdateAnimationActive:d}=t,f=(0,b.useRef)(null),[p,m]=(0,b.useState)(-1),h=(0,b.useRef)(i),g=(0,b.useRef)(a),_=(0,b.useRef)(o),v=(0,b.useRef)(n),y=(0,b.useRef)(r),x=ck(e,`trapezoid-`);if((0,b.useEffect)(()=>{if(f.current&&f.current.getTotalLength)try{var e=f.current.getTotalLength();e&&m(e)}catch{}},[]),n!==+n||r!==+r||i!==+i||a!==+a||o!==+o||i===0&&a===0||o===0)return null;var S=Px(`recharts-trapezoid`,s);if(!d)return b.createElement(`g`,null,b.createElement(`path`,Sz({},Bx(t),{className:S,d:wz(n,r,i,a,o)})));var C=h.current,w=g.current,T=_.current,E=v.current,D=y.current,O=`0px ${p===-1?1:p}px`,k=`${p}px ${p}px`,ee=JO([`strokeDasharray`],l,c);return b.createElement(sk,{animationId:x,key:x,canBegin:p>0,duration:l,easing:c,isActive:d,begin:u},e=>{var s=XS(C,i,e),c=XS(w,a,e),l=XS(T,o,e),u=XS(E,n,e),d=XS(D,r,e);f.current&&(h.current=s,g.current=c,_.current=l,v.current=u,y.current=d);var p=e>0?{transition:ee,strokeDasharray:k}:{strokeDasharray:O};return b.createElement(`path`,Sz({},Bx(t),{className:S,d:wz(u,d,s,c,l),ref:f,style:xz(xz({},p),t.style)}))})},Ffe=u(wfe()),Ife=[`option`,`shapeType`,`activeClassName`,`inActiveClassName`];function Lfe(e,t){if(e==null)return{};var n,r,i=Rfe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Rfe(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Tz(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Ez(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Tz(Object(n),!0).forEach(function(t){zfe(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Tz(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function zfe(e,t,n){return(t=Bfe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Bfe(e){var t=Vfe(e,`string`);return typeof t==`symbol`?t:t+``}function Vfe(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Hfe(e,t){return Ez(Ez({},t),e)}function Ufe(e,t){return e===`symbols`}function Dz(e){var{shapeType:t,elementProps:n}=e;switch(t){case`rectangle`:return b.createElement(bk,n);case`trapezoid`:return b.createElement(Pfe,n);case`sector`:return b.createElement(Xk,n);case`symbols`:if(Ufe(t,n))return b.createElement(oC,n);break;case`curve`:return b.createElement(UO,n);default:return null}}function Wfe(e){return(0,b.isValidElement)(e)?e.props:e}function Oz(e){var{option:t,shapeType:n,activeClassName:r=`recharts-active-shape`,inActiveClassName:i=`recharts-shape`}=e,a=Lfe(e,Ife),o;if((0,b.isValidElement)(t))o=(0,b.cloneElement)(t,Ez(Ez({},a),Wfe(t)));else if(typeof t==`function`)o=t(a,a.index);else if((0,Ffe.default)(t)&&typeof t!=`boolean`){var s=Hfe(t,a);o=b.createElement(Dz,{shapeType:n,elementProps:s})}else{var c=a;o=b.createElement(Dz,{shapeType:n,elementProps:c})}return a.isActive?b.createElement(Wx,{className:r},o):b.createElement(Wx,{className:i},o)}var kz=(e,t,n)=>{var r=HC();return(i,a)=>o=>{e?.(i,a,o),r(VI({activeIndex:String(a),activeDataKey:t,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}},Az=e=>{var t=HC();return(n,r)=>i=>{e?.(n,r,i),t(Cle())}},jz=(e,t,n)=>{var r=HC();return(i,a)=>o=>{e?.(i,a,o),r(wle({activeIndex:String(a),activeDataKey:t,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}};function Mz(e){var{tooltipEntrySettings:t}=e,n=HC(),r=sD(),i=(0,b.useRef)(null);return(0,b.useLayoutEffect)(()=>{r||(i.current===null?n(yle(t)):i.current!==t&&n(ble({prev:i.current,next:t})),i.current=t)},[t,n,r]),(0,b.useLayoutEffect)(()=>()=>{i.current&&=(n(xle(i.current)),null)},[n]),null}function Nz(e){var{legendPayload:t}=e,n=HC(),r=sD(),i=(0,b.useRef)(null);return(0,b.useLayoutEffect)(()=>{r||(i.current===null?n(_O(t)):i.current!==t&&n(vO({prev:i.current,next:t})),i.current=t)},[n,r,t]),(0,b.useLayoutEffect)(()=>()=>{i.current&&=(n(yO(i.current)),null)},[n]),null}function Gfe(e){var{legendPayload:t}=e,n=HC(),r=U(TD),i=(0,b.useRef)(null);return(0,b.useLayoutEffect)(()=>{r!==`centric`&&r!==`radial`||(i.current===null?n(_O(t)):i.current!==t&&n(vO({prev:i.current,next:t})),i.current=t)},[n,r,t]),(0,b.useLayoutEffect)(()=>()=>{i.current&&=(n(yO(i.current)),null)},[n]),null}var Kfe=b.useId??(()=>{var[e]=b.useState(()=>qS(`uid-`));return e});function qfe(e,t){var n=Kfe();return t||(e?`${e}-${n}`:n)}var Jfe=(0,b.createContext)(void 0),Pz=e=>{var{id:t,type:n,children:r}=e,i=qfe(`recharts-${n}`,t);return b.createElement(Jfe.Provider,{value:i},r(i))},Fz=aE({name:`graphicalItems`,initialState:{cartesianItems:[],polarItems:[]},reducers:{addCartesianGraphicalItem:{reducer(e,t){e.cartesianItems.push(hO(t.payload))},prepare:tE()},replaceCartesianGraphicalItem:{reducer(e,t){var{prev:n,next:r}=t.payload,i=KT(e).cartesianItems.indexOf(hO(n));i>-1&&(e.cartesianItems[i]=hO(r))},prepare:tE()},removeCartesianGraphicalItem:{reducer(e,t){var n=KT(e).cartesianItems.indexOf(hO(t.payload));n>-1&&e.cartesianItems.splice(n,1)},prepare:tE()},addPolarGraphicalItem:{reducer(e,t){e.polarItems.push(hO(t.payload))},prepare:tE()},removePolarGraphicalItem:{reducer(e,t){var n=KT(e).polarItems.indexOf(hO(t.payload));n>-1&&e.polarItems.splice(n,1)},prepare:tE()},replacePolarGraphicalItem:{reducer(e,t){var{prev:n,next:r}=t.payload,i=KT(e).polarItems.indexOf(hO(n));i>-1&&(e.polarItems[i]=hO(r))},prepare:tE()}}}),{addCartesianGraphicalItem:Yfe,replaceCartesianGraphicalItem:Xfe,removeCartesianGraphicalItem:Zfe,addPolarGraphicalItem:Qfe,removePolarGraphicalItem:$fe,replacePolarGraphicalItem:epe}=Fz.actions,tpe=Fz.reducer,Iz=(0,b.memo)(e=>{var t=HC(),n=(0,b.useRef)(null);return(0,b.useLayoutEffect)(()=>{n.current===null?t(Yfe(e)):n.current!==e&&t(Xfe({prev:n.current,next:e})),n.current=e},[t,e]),(0,b.useLayoutEffect)(()=>()=>{n.current&&=(t(Zfe(n.current)),null)},[t]),null}),npe=(0,b.memo)(e=>{var t=HC(),n=(0,b.useRef)(null);return(0,b.useLayoutEffect)(()=>{n.current===null?t(Qfe(e)):n.current!==e&&t(epe({prev:n.current,next:e})),n.current=e},[t,e]),(0,b.useLayoutEffect)(()=>()=>{n.current&&=(t($fe(n.current)),null)},[t]),null}),rpe=[`key`],ipe=[`onMouseEnter`,`onClick`,`onMouseLeave`],ape=[`id`],ope=[`id`];function Lz(){return Lz=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Lz.apply(null,arguments)}function Rz(e,t){if(e==null)return{};var n,r,i=spe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function spe(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function zz(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Bz(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?zz(Object(n),!0).forEach(function(t){cpe(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):zz(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function cpe(e,t,n){return(t=lpe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function lpe(e){var t=upe(e,`string`);return typeof t==`symbol`?t:t+``}function upe(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function dpe(e){var t=(0,b.useMemo)(()=>vz(e.children,cR),[e.children]),n=U(n=>yfe(n,e.id,t));return n==null?null:b.createElement(Gfe,{legendPayload:n})}function fpe(e){if(!(e==null||typeof e==`boolean`||typeof e==`function`)){if(b.isValidElement(e)){var t=e.props?.fill;return typeof t==`string`?t:void 0}var{fill:n}=e;return typeof n==`string`?n:void 0}}var ppe=b.memo(e=>{var{dataKey:t,nameKey:n,sectors:r,stroke:i,strokeWidth:a,fill:o,name:s,hide:c,tooltipType:l,id:u,activeShape:d}=e,f=fpe(d),p={dataDefinedOnItem:r.map(e=>{var t=e.tooltipPayload;return f==null||t==null?t:t.map(e=>Bz(Bz({},e),{},{color:f,fill:f}))}),getPosition:e=>r[Number(e)]?.tooltipPosition,settings:{stroke:i,strokeWidth:a,fill:o,dataKey:t,nameKey:n,name:YE(s,t),hide:c,type:l,color:o,unit:``,graphicalItemId:u}};return b.createElement(Mz,{tooltipEntrySettings:p})}),mpe=(e,t)=>e>t?`start`:e<t?`end`:`middle`,hpe=(e,t,n)=>JS(typeof t==`function`?t(e):t,n,n*.8),gpe=(e,t,n)=>{var{top:r,left:i,width:a,height:o}=t,s=kk(a,o);return{cx:i+JS(e.cx,a,a/2),cy:r+JS(e.cy,o,o/2),innerRadius:JS(e.innerRadius,s,0),outerRadius:hpe(n,e.outerRadius,s),maxRadius:e.maxRadius||Math.sqrt(a*a+o*o)/2}},_pe=(e,t)=>US(t-e)*Math.min(Math.abs(t-e),360),vpe=(e,t)=>{if(b.isValidElement(e))return b.cloneElement(e,t);if(typeof e==`function`)return e(t);var n=Px(`recharts-pie-label-line`,typeof e==`boolean`?``:e.className),{key:r}=t,i=Rz(t,rpe);return b.createElement(UO,Lz({},i,{type:`linear`,className:n}))},ype=(e,t,n)=>{if(b.isValidElement(e))return b.cloneElement(e,t);var r=n;if(typeof e==`function`&&(r=e(t),b.isValidElement(r)))return r;var i=Px(`recharts-pie-label-text`,cz(e));return b.createElement(NR,Lz({},t,{alignmentBaseline:`middle`,className:i}),r)};function bpe(e){var{sectors:t,props:n,showLabels:r}=e,{label:i,labelLine:a,dataKey:o}=n;if(!r||!i||!t)return null;var s=Rx(n),c=zx(i),l=zx(a),u=typeof i==`object`&&`offsetRadius`in i&&typeof i.offsetRadius==`number`&&i.offsetRadius||20,d=t.map((e,t)=>{var n=(e.startAngle+e.endAngle)/2,r=Ok(e.cx,e.cy,e.outerRadius+u,n),d=Bz(Bz(Bz(Bz({},s),e),{},{stroke:`none`},c),{},{index:t,textAnchor:mpe(r.x,e.cx)},r),f=Bz(Bz(Bz(Bz({},s),e),{},{fill:`none`,stroke:e.fill},l),{},{index:t,points:[Ok(e.cx,e.cy,e.outerRadius,n),r],key:`line`});return b.createElement(WL,{zIndex:PA.label,key:`label-${e.startAngle}-${e.endAngle}-${e.midAngle}-${t}`},b.createElement(Wx,null,a&&vpe(a,f),ype(i,d,RE(e,o))))});return b.createElement(Wx,{className:`recharts-pie-labels`},d)}function xpe(e){var{sectors:t,props:n,showLabels:r}=e,{label:i}=n;return typeof i==`object`&&i&&`position`in i?b.createElement($R,{label:i}):b.createElement(bpe,{sectors:t,props:n,showLabels:r})}function Spe(e){var{sectors:t,activeShape:n,inactiveShape:r,allOtherPieProps:i,shape:a,id:o}=e,s=U(bL),c=U(SL),l=U(CL),{onMouseEnter:u,onClick:d,onMouseLeave:f}=i,p=Rz(i,ipe),m=kz(u,i.dataKey,o),h=Az(f),g=jz(d,i.dataKey,o);return t==null||t.length===0?null:b.createElement(b.Fragment,null,t.map((e,u)=>{if(e?.startAngle===0&&e?.endAngle===0&&t.length!==1)return null;var d=l==null||l===o,f=String(u)===s&&(c==null||i.dataKey===c)&&d,_=n&&f?n:s?r:null,v=Bz(Bz({},e),{},{stroke:e.stroke,tabIndex:-1,[tD]:u,[nD]:o});return b.createElement(Wx,Lz({key:`sector-${e?.startAngle}-${e?.endAngle}-${e.midAngle}-${u}`,tabIndex:-1,className:`recharts-pie-sector`},lC(p,e,u),{onMouseEnter:m(e,u),onMouseLeave:h(e,u),onClick:g(e,u)}),b.createElement(Oz,Lz({option:a??_,index:u,shapeType:`sector`,isActive:f},v)))}))}function Cpe(e){var{pieSettings:t,displayedData:n,cells:r,offset:i}=e,{cornerRadius:a,startAngle:o,endAngle:s,dataKey:c,nameKey:l,tooltipType:u}=t,d=Math.abs(t.minAngle),f=_pe(o,s),p=Math.abs(f),m=n.length<=1?0:t.paddingAngle??0,h=n.filter(e=>RE(e,c,0)!==0).length,g=(p>=360?h:h-1)*m,_=n.reduce((e,t)=>{var n=RE(t,c,0);return e+(H(n)?n:0)},0),v=d>0&&_>0&&n.some(e=>{var t=RE(e,c,0),n=(H(t)?t:0)/_;return t!==0&&n*p<d})?d:0,y=p-h*v-g,b;if(_>0){var x;b=n.map((e,n)=>{var s=RE(e,c,0),d=RE(e,l,n),p=gpe(t,i,e),h=(H(s)?s:0)/_,g,b=Bz(Bz({},e),r&&r[n]&&r[n].props),S=b!=null&&`fill`in b&&typeof b.fill==`string`?b.fill:t.fill;g=n?x.endAngle+US(f)*m*(s===0?0:1):o;var C=g+US(f)*((s===0?0:v)+h*y),w=(g+C)/2,T=(p.innerRadius+p.outerRadius)/2,E=[{name:d,value:s,payload:b,dataKey:c,type:u,color:S,fill:S,graphicalItemId:t.id}],D=Ok(p.cx,p.cy,T,w);return x=Bz(Bz(Bz(Bz({},t.presentationProps),{},{percent:h,cornerRadius:typeof a==`string`?parseFloat(a):a,name:d,tooltipPayload:E,midAngle:w,middleRadius:T,tooltipPosition:D},b),p),{},{value:s,dataKey:c,startAngle:g,endAngle:C,payload:b,paddingAngle:s===0?0:US(f)*m}),x})}return b}function wpe(e){var{showLabels:t,sectors:n,children:r}=e,i=(0,b.useMemo)(()=>!t||!n?[]:n.map(e=>({value:e.value,payload:e.payload,clockWise:!1,parentViewBox:void 0,viewBox:{cx:e.cx,cy:e.cy,innerRadius:e.innerRadius,outerRadius:e.outerRadius,startAngle:e.startAngle,endAngle:e.endAngle,clockWise:!1},fill:e.fill})),[n,t]);return b.createElement(ofe,{value:t?i:void 0},r)}function Tpe(e){var{props:t,previousSectorsRef:n,id:r}=e,{sectors:i,isAnimationActive:a,animationBegin:o,animationDuration:s,animationEasing:c,activeShape:l,inactiveShape:u,onAnimationStart:d,onAnimationEnd:f}=t,p=ck(t,`recharts-pie-`),m=n.current,[h,g]=(0,b.useState)(!1),_=(0,b.useCallback)(()=>{typeof f==`function`&&f(),g(!1)},[f]),v=(0,b.useCallback)(()=>{typeof d==`function`&&d(),g(!0)},[d]);return b.createElement(wpe,{showLabels:!h,sectors:i},b.createElement(sk,{animationId:p,begin:o,duration:s,isActive:a,easing:c,onAnimationStart:v,onAnimationEnd:_,key:p},e=>{var a=[],o=(i&&i[0])?.startAngle??0;return i?.forEach((t,n)=>{var r=m&&m[n],i=n>0?(0,HS.default)(t,`paddingAngle`,0):0;if(r){var s=XS(r.endAngle-r.startAngle,t.endAngle-t.startAngle,e),c=Bz(Bz({},t),{},{startAngle:o+i,endAngle:o+s+i});a.push(c),o=c.endAngle}else{var{endAngle:l,startAngle:u}=t,d=XS(0,l-u,e),f=Bz(Bz({},t),{},{startAngle:o+i,endAngle:o+d+i});a.push(f),o=f.endAngle}}),n.current=a,b.createElement(Wx,null,b.createElement(Spe,{sectors:a,activeShape:l,inactiveShape:u,allOtherPieProps:t,shape:t.shape,id:r}))}),b.createElement(xpe,{showLabels:!h,sectors:i,props:t}),t.children)}var Epe={animationBegin:400,animationDuration:1500,animationEasing:`ease`,cx:`50%`,cy:`50%`,dataKey:`value`,endAngle:360,fill:`#808080`,hide:!1,innerRadius:0,isAnimationActive:`auto`,label:!1,labelLine:!0,legendType:`rect`,minAngle:0,nameKey:`name`,outerRadius:`80%`,paddingAngle:0,rootTabIndex:0,startAngle:0,stroke:`#fff`,zIndex:PA.area};function Dpe(e){var{id:t}=e,n=Rz(e,ape),{hide:r,className:i,rootTabIndex:a}=e,o=(0,b.useMemo)(()=>vz(e.children,cR),[e.children]),s=U(e=>bfe(e,t,o)),c=(0,b.useRef)(null),l=Px(`recharts-pie`,i);return r||s==null?(c.current=null,b.createElement(Wx,{tabIndex:a,className:l})):b.createElement(WL,{zIndex:e.zIndex},b.createElement(ppe,{dataKey:e.dataKey,nameKey:e.nameKey,sectors:s,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,tooltipType:e.tooltipType,id:t,activeShape:e.activeShape}),b.createElement(Wx,{tabIndex:a,className:l},b.createElement(Tpe,{props:Bz(Bz({},n),{},{sectors:s}),previousSectorsRef:c,id:t})))}function Ope(e){var t=dC(e,Epe),{id:n}=t,r=Rz(t,ope),i=Rx(r);return b.createElement(Pz,{id:n,type:`pie`},e=>b.createElement(b.Fragment,null,b.createElement(npe,{type:`pie`,id:e,data:r.data,dataKey:r.dataKey,hide:r.hide,angleAxisId:0,radiusAxisId:0,name:r.name,nameKey:r.nameKey,tooltipType:r.tooltipType,legendType:r.legendType,fill:r.fill,cx:r.cx,cy:r.cy,startAngle:r.startAngle,endAngle:r.endAngle,paddingAngle:r.paddingAngle,minAngle:r.minAngle,innerRadius:r.innerRadius,outerRadius:r.outerRadius,cornerRadius:r.cornerRadius,presentationProps:i,maxRadius:t.maxRadius}),b.createElement(dpe,Lz({},r,{id:e})),b.createElement(Dpe,Lz({},r,{id:e}))))}var Vz=Ope;Vz.displayName=`Pie`;var Hz=[`points`];function Uz(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Wz(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Uz(Object(n),!0).forEach(function(t){Gz(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Uz(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Gz(e,t,n){return(t=Kz(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Kz(e){var t=qz(e,`string`);return typeof t==`symbol`?t:t+``}function qz(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Jz(){return Jz=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Jz.apply(null,arguments)}function Yz(e,t){if(e==null)return{};var n,r,i=Xz(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Xz(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Zz(e){var{option:t,dotProps:n,className:r}=e;if((0,b.isValidElement)(t))return(0,b.cloneElement)(t,n);if(typeof t==`function`)return t(n);var i=Px(r,typeof t==`boolean`?``:t.className),a=n??{},{points:o}=a,s=Yz(a,Hz);return b.createElement(tz,Jz({},s,{className:i}))}function Qz(e,t){return e==null?!1:t?!0:e.length===1}function $z(e){var{points:t,dot:n,className:r,dotClassName:i,dataKey:a,baseProps:o,needClip:s,clipPathId:c,zIndex:l=PA.scatter}=e;if(!Qz(t,n))return null;var u=yz(n),d=ine(n),f=t.map((e,r)=>{var s=Wz(Wz(Wz({r:3},o),d),{},{index:r,cx:e.x??void 0,cy:e.y??void 0,dataKey:a,value:e.value,payload:e.payload,points:t});return b.createElement(Zz,{key:`dot-${r}`,option:n,dotProps:s,className:i})}),p={};return s&&c!=null&&(p.clipPath=`url(#clipPath-${u?``:`dots-`}${c})`),b.createElement(WL,{zIndex:l},b.createElement(Wx,Jz({className:r},p),f))}function eB(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function tB(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?eB(Object(n),!0).forEach(function(t){nB(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):eB(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function nB(e,t,n){return(t=rB(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function rB(e){var t=iB(e,`string`);return typeof t==`symbol`?t:t+``}function iB(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var aB=aE({name:`cartesianAxis`,initialState:{xAxis:{},yAxis:{},zAxis:{}},reducers:{addXAxis:{reducer(e,t){e.xAxis[t.payload.id]=hO(t.payload)},prepare:tE()},replaceXAxis:{reducer(e,t){var{prev:n,next:r}=t.payload;e.xAxis[n.id]!==void 0&&(n.id!==r.id&&delete e.xAxis[n.id],e.xAxis[r.id]=hO(r))},prepare:tE()},removeXAxis:{reducer(e,t){delete e.xAxis[t.payload.id]},prepare:tE()},addYAxis:{reducer(e,t){e.yAxis[t.payload.id]=hO(t.payload)},prepare:tE()},replaceYAxis:{reducer(e,t){var{prev:n,next:r}=t.payload;e.yAxis[n.id]!==void 0&&(n.id!==r.id&&delete e.yAxis[n.id],e.yAxis[r.id]=hO(r))},prepare:tE()},removeYAxis:{reducer(e,t){delete e.yAxis[t.payload.id]},prepare:tE()},addZAxis:{reducer(e,t){e.zAxis[t.payload.id]=hO(t.payload)},prepare:tE()},replaceZAxis:{reducer(e,t){var{prev:n,next:r}=t.payload;e.zAxis[n.id]!==void 0&&(n.id!==r.id&&delete e.zAxis[n.id],e.zAxis[r.id]=hO(r))},prepare:tE()},removeZAxis:{reducer(e,t){delete e.zAxis[t.payload.id]},prepare:tE()},updateYAxisWidth(e,t){var{id:n,width:r}=t.payload,i=e.yAxis[n];if(i){var a=i.widthHistory||[];if(a.length===3&&a[0]===a[2]&&r===a[1]&&r!==i.width&&Math.abs(r-(a[0]??0))<=1)return;var o=[...a,r].slice(-3);e.yAxis[n]=tB(tB({},i),{},{width:r,widthHistory:o})}}}}),{addXAxis:oB,replaceXAxis:sB,removeXAxis:cB,addYAxis:lB,replaceYAxis:uB,removeYAxis:dB,addZAxis:fB,replaceZAxis:pB,removeZAxis:mB,updateYAxisWidth:hB}=aB.actions,gB=aB.reducer,_B=W([W([aD],e=>({top:e.top,bottom:e.bottom,left:e.left,right:e.right})),XE,ZE],(e,t,n)=>{if(!(!e||t==null||n==null))return{x:e.left,y:e.top,width:Math.max(0,t-e.left-e.right),height:Math.max(0,n-e.top-e.bottom)}}),vB=()=>U(_B),yB=()=>U($le);function bB(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function xB(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?bB(Object(n),!0).forEach(function(t){SB(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):bB(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function SB(e,t,n){return(t=CB(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function CB(e){var t=wB(e,`string`);return typeof t==`symbol`?t:t+``}function wB(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var TB=e=>{var{point:t,childIndex:n,mainColor:r,activeDot:i,dataKey:a,clipPath:o}=e;if(i===!1||t.x==null||t.y==null)return null;var s=xB(xB(xB({},{index:n,dataKey:a,cx:t.x,cy:t.y,r:4,fill:r??`none`,strokeWidth:2,stroke:`#fff`,payload:t.payload,value:t.value}),zx(i)),cC(i)),c=(0,b.isValidElement)(i)?(0,b.cloneElement)(i,s):typeof i==`function`?i(s):b.createElement(tz,s);return b.createElement(Wx,{className:`recharts-active-dot`,clipPath:o},c)};function EB(e){var{points:t,mainColor:n,activeDot:r,itemDataKey:i,clipPath:a,zIndex:o=PA.activeDot}=e,s=U(bL),c=yB();if(t==null||c==null)return null;var l=t.find(e=>c.includes(e.payload));return QS(l)?null:b.createElement(WL,{zIndex:o},b.createElement(TB,{point:l,childIndex:Number(s),mainColor:n,dataKey:i,activeDot:r,clipPath:a}))}var DB=(e,t,n)=>{var r=n??e;if(!QS(r))return JS(r,t,0)},OB=(e,t,n)=>{var r={},i=e.filter(aj),a=e.filter(e=>e.stackId==null),o=i.reduce((e,t)=>{var n=e[t.stackId];return n??=[],n.push(t),e[t.stackId]=n,e},r),s=Object.entries(o).map(e=>{var[r,i]=e;return{stackId:r,dataKeys:i.map(e=>e.dataKey),barSize:DB(t,n,i[0]?.barSize)}}),c=a.map(e=>({stackId:void 0,dataKeys:[e.dataKey].filter(e=>e!=null),barSize:DB(t,n,e.barSize)}));return[...s,...c]};function kB(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function AB(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?kB(Object(n),!0).forEach(function(t){jB(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):kB(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function jB(e,t,n){return(t=MB(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function MB(e){var t=NB(e,`string`);return typeof t==`symbol`?t:t+``}function NB(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function PB(e,t,n,r,i){var a=r.length;if(!(a<1)){var o=JS(e,n,0,!0),s,c=[];if(PE(r[0]?.barSize)){var l=!1,u=n/a,d=r.reduce((e,t)=>e+(t.barSize||0),0);d+=(a-1)*o,d>=n&&(d-=(a-1)*o,o=0),d>=n&&u>0&&(l=!0,u*=.9,d=a*u);var f={offset:((n-d)/2>>0)-o,size:0};s=r.reduce((e,t)=>{var n={stackId:t.stackId,dataKeys:t.dataKeys,position:{offset:f.offset+f.size+o,size:l?u:t.barSize??0}},r=[...e,n];return f=n.position,r},c)}else{var p=JS(t,n,0,!0);n-2*p-(a-1)*o<=0&&(o=0);var m=(n-2*p-(a-1)*o)/a;m>1&&(m>>=0);var h=PE(i)?Math.min(m,i):m;s=r.reduce((e,t,n)=>[...e,{stackId:t.stackId,dataKeys:t.dataKeys,position:{offset:p+(m+o)*n+(m-h)/2,size:h}}],c)}return s}}var FB=(e,t,n,r,i,a,o)=>{var s=QS(o)?t:o,c=PB(n,r,i===a?a:i,e,s);return i!==a&&c!=null&&(c=c.map(e=>AB(AB({},e),{},{position:AB(AB({},e.position),{},{offset:e.position.offset-i/2})}))),c},IB=(e,t)=>{var n=rj(t);if(!(!e||n==null||t==null)){var{stackId:r}=t;if(r!=null){var i=e[r];if(i){var{stackedData:a}=i;if(a)return a.find(e=>e.key===n)}}}},LB=(e,t)=>{if(!(e==null||t==null)){var n=e.find(e=>e.stackId===t.stackId&&t.dataKey!=null&&e.dataKeys.includes(t.dataKey));if(n!=null)return n.position}};function RB(e,t){return e&&typeof e==`object`&&`zIndex`in e&&typeof e.zIndex==`number`&&PE(e.zIndex)?e.zIndex:t}var zB=e=>{var{chartData:t}=e,n=HC(),r=sD();return(0,b.useEffect)(()=>r?()=>{}:(n(tR(t)),()=>{n(tR(void 0))}),[t,n,r]),null},BB={x:0,y:0,width:0,height:0,padding:{top:0,right:0,bottom:0,left:0}},VB=aE({name:`brush`,initialState:BB,reducers:{setBrushSettings(e,t){return t.payload==null?BB:t.payload}}}),{setBrushSettings:kpe}=VB.actions,HB=VB.reducer,UB=(e,t)=>{var{x:n,y:r}=e,{x:i,y:a}=t;return{x:Math.min(n,i),y:Math.min(r,a),width:Math.abs(i-n),height:Math.abs(a-r)}},WB=e=>{var{x1:t,y1:n,x2:r,y2:i}=e;return UB({x:t,y:n},{x:r,y:i})};function GB(e){return(e%180+180)%180}var KB=function(e){var{width:t,height:n}=e,r=GB(arguments.length>1&&arguments[1]!==void 0?arguments[1]:0)*Math.PI/180,i=Math.atan(n/t),a=r>i&&r<Math.PI-i?n/Math.sin(r):t/Math.cos(r);return Math.abs(a)},qB=aE({name:`referenceElements`,initialState:{dots:[],areas:[],lines:[]},reducers:{addDot:(e,t)=>{e.dots.push(t.payload)},removeDot:(e,t)=>{var n=KT(e).dots.findIndex(e=>e===t.payload);n!==-1&&e.dots.splice(n,1)},addArea:(e,t)=>{e.areas.push(t.payload)},removeArea:(e,t)=>{var n=KT(e).areas.findIndex(e=>e===t.payload);n!==-1&&e.areas.splice(n,1)},addLine:(e,t)=>{e.lines.push(hO(t.payload))},removeLine:(e,t)=>{var n=KT(e).lines.findIndex(e=>e===t.payload);n!==-1&&e.lines.splice(n,1)}}}),{addDot:Ape,removeDot:jpe,addArea:Mpe,removeArea:Npe,addLine:JB,removeLine:YB}=qB.actions,XB=qB.reducer,ZB=(0,b.createContext)(void 0),QB=e=>{var{children:t}=e,[n]=(0,b.useState)(`${qS(`recharts`)}-clip`),r=vB();if(r==null)return null;var{x:i,y:a,width:o,height:s}=r;return b.createElement(ZB.Provider,{value:n},b.createElement(`defs`,null,b.createElement(`clipPath`,{id:n},b.createElement(`rect`,{x:i,y:a,height:s,width:o}))),t)},$B=()=>(0,b.useContext)(ZB),eV=class{constructor(e){var{x:t,y:n}=e;this.xAxisScale=t,this.yAxisScale=n}map(e,t){var{position:n}=t;return{x:this.xAxisScale.map(e.x,{position:n})??0,y:this.yAxisScale.map(e.y,{position:n})??0}}mapWithFallback(e,t){var{position:n,fallback:r}=t,i=r===`rangeMin`?this.yAxisScale.rangeMin():r===`rangeMax`?this.yAxisScale.rangeMax():0,a=r===`rangeMin`?this.xAxisScale.rangeMin():r===`rangeMax`?this.xAxisScale.rangeMax():0;return{x:this.xAxisScale.map(e.x,{position:n})??a,y:this.yAxisScale.map(e.y,{position:n})??i}}isInRange(e){var{x:t,y:n}=e,r=t==null||this.xAxisScale.isInRange(t),i=n==null||this.yAxisScale.isInRange(n);return r&&i}};function tV(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function nV(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?tV(Object(n),!0).forEach(function(t){rV(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):tV(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function rV(e,t,n){return(t=iV(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function iV(e){var t=aV(e,`string`);return typeof t==`symbol`?t:t+``}function aV(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function oV(){return oV=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},oV.apply(null,arguments)}var sV=(e,t)=>{var n;if(b.isValidElement(e))n=b.cloneElement(e,t);else if(typeof e==`function`)n=e(t);else{if(!PE(t.x1)||!PE(t.y1)||!PE(t.x2)||!PE(t.y2))return null;n=b.createElement(`line`,oV({},t,{className:`recharts-reference-line-line`}))}return n},cV=(e,t,n,r,i,a)=>{var{x:o,width:s}=a,c=i.map(e,{position:n});if(!PE(c)||t===`discard`&&!i.isInRange(c))return null;var l=[{x:o+s,y:c},{x:o,y:c}];return r===`left`?l.reverse():l},lV=(e,t,n,r,i,a)=>{var{y:o,height:s}=a,c=i.map(e,{position:n});if(!PE(c)||t===`discard`&&!i.isInRange(c))return null;var l=[{x:c,y:o+s},{x:c,y:o}];return r===`top`?l.reverse():l},uV=(e,t,n,r)=>{var i=[r.mapWithFallback(e[0],{position:n,fallback:`rangeMin`}),r.mapWithFallback(e[1],{position:n,fallback:`rangeMax`})];return t===`discard`&&i.some(e=>!r.isInRange(e))?null:i},dV=(e,t,n,r,i,a,o)=>{var{x:s,y:c,segment:l,ifOverflow:u}=o,d=KS(s);return KS(c)?cV(c,u,r,a,t,n):d?lV(s,u,r,i,e,n):l!=null&&l.length===2?uV(l,u,r,new eV({x:e,y:t})):null};function fV(e){var t=HC();return(0,b.useEffect)(()=>(t(JB(e)),()=>{t(YB(e))})),null}function pV(e){var{xAxisId:t,yAxisId:n,shape:r,className:i,ifOverflow:a}=e,o=sD(),s=$B(),c=U(e=>_F(e,t)),l=U(e=>bF(e,n)),u=U(e=>bI(e,`xAxis`,t,o)),d=U(e=>bI(e,`yAxis`,n,o)),f=xD();if(!s||!f||c==null||l==null||u==null||d==null)return null;var p=dV(u,d,f,e.position,c.orientation,l.orientation,e);if(!p)return null;var m=p[0],h=p[1];if(m==null||h==null)return null;var{x:g,y:_}=m,{x:v,y}=h,x=nV(nV({clipPath:a===`hidden`?`url(#${s})`:void 0},Bx(e)),{},{x1:g,y1:_,x2:v,y2:y}),S=WB({x1:g,y1:_,x2:v,y2:y});return b.createElement(WL,{zIndex:e.zIndex},b.createElement(Wx,{className:Px(`recharts-reference-line`,i)},sV(r,x),b.createElement(VR,oV({},S,{lowerWidth:S.width,upperWidth:S.width}),b.createElement(KR,{label:e.label}),e.children)))}var mV={ifOverflow:`discard`,xAxisId:0,yAxisId:0,fill:`none`,label:!1,stroke:`#ccc`,fillOpacity:1,strokeWidth:1,position:`middle`,zIndex:PA.line};function hV(e){var t=dC(e,mV);return b.createElement(b.Fragment,null,b.createElement(fV,{yAxisId:t.yAxisId,xAxisId:t.xAxisId,ifOverflow:t.ifOverflow,x:t.x,y:t.y,segment:t.segment}),b.createElement(pV,t))}hV.displayName=`ReferenceLine`;function gV(e,t){if(t<1)return[];if(t===1)return e;for(var n=[],r=0;r<e.length;r+=t){var i=e[r];i!==void 0&&n.push(i)}return n}function _V(e,t,n){return KB({width:e.width+t.width,height:e.height+t.height},n)}function vV(e,t,n){var r=n===`width`,{x:i,y:a,width:o,height:s}=e;return t===1?{start:r?i:a,end:r?i+o:a+s}:{start:r?i+o:a+s,end:r?i:a}}function yV(e,t,n,r,i){if(e*t<e*r||e*t>e*i)return!1;var a=n();return e*(t-e*a/2-r)>=0&&e*(t+e*a/2-i)<=0}function bV(e,t){return gV(e,t+1)}function xV(e,t,n,r,i){for(var a=(r||[]).slice(),{start:o,end:s}=t,c=0,l=1,u=o,d=function(){var t=r?.[c];if(t===void 0)return{v:gV(r,l)};var a=c,d,f=()=>(d===void 0&&(d=n(t,a)),d),p=t.coordinate,m=c===0||yV(e,p,f,u,s);m||(c=0,u=o,l+=1),m&&(u=p+e*(f()/2+i),c+=l)},f;l<=a.length;)if(f=d(),f)return f.v;return[]}function SV(e,t,n,r,i){var a=(r||[]).slice().length;if(a===0)return[];for(var{start:o,end:s}=t,c=1;c<=a;c++){for(var l=(a-1)%c,u=o,d=!0,f=function(){var t=r[m];if(t==null)return 0;var a=m,o,c=()=>(o===void 0&&(o=n(t,a)),o),f=t.coordinate,p=m===l||yV(e,f,c,u,s);if(!p)return d=!1,1;p&&(u=f+e*(c()/2+i))},p,m=l;m<a&&(p=f(),!(p!==0&&p===1));m+=c);if(d){for(var h=[],g=l;g<a;g+=c){var _=r[g];_!=null&&h.push(_)}return h}}return[]}function CV(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function wV(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?CV(Object(n),!0).forEach(function(t){TV(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):CV(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function TV(e,t,n){return(t=EV(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function EV(e){var t=DV(e,`string`);return typeof t==`symbol`?t:t+``}function DV(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function OV(e,t,n,r,i){for(var a=(r||[]).slice(),o=a.length,{start:s}=t,{end:c}=t,l=function(t){var r=a[t];if(r==null)return 1;var l=r,u,d=()=>(u===void 0&&(u=n(r,t)),u);if(t===o-1){var f=e*(l.coordinate+e*d()/2-c);a[t]=l=wV(wV({},l),{},{tickCoord:f>0?l.coordinate-f*e:l.coordinate})}else a[t]=l=wV(wV({},l),{},{tickCoord:l.coordinate});l.tickCoord!=null&&yV(e,l.tickCoord,d,s,c)&&(c=l.tickCoord-e*(d()/2+i),a[t]=wV(wV({},l),{},{isShow:!0}))},u=o-1;u>=0;u--)if(l(u))continue;return a}function kV(e,t,n,r,i,a){var o=(r||[]).slice(),s=o.length,{start:c,end:l}=t;if(a){var u=r[s-1];if(u!=null){var d=n(u,s-1),f=e*(u.coordinate+e*d/2-l);o[s-1]=u=wV(wV({},u),{},{tickCoord:f>0?u.coordinate-f*e:u.coordinate}),u.tickCoord!=null&&yV(e,u.tickCoord,()=>d,c,l)&&(l=u.tickCoord-e*(d/2+i),o[s-1]=wV(wV({},u),{},{isShow:!0}))}}for(var p=a?s-1:s,m=function(t){var r=o[t];if(r==null)return 1;var a=r,s,u=()=>(s===void 0&&(s=n(r,t)),s);if(t===0){var d=e*(a.coordinate-e*u()/2-c);o[t]=a=wV(wV({},a),{},{tickCoord:d<0?a.coordinate-d*e:a.coordinate})}else o[t]=a=wV(wV({},a),{},{tickCoord:a.coordinate});a.tickCoord!=null&&yV(e,a.tickCoord,u,c,l)&&(c=a.tickCoord+e*(u()/2+i),o[t]=wV(wV({},a),{},{isShow:!0}))},h=0;h<p;h++)if(m(h))continue;return o}function AV(e,t,n){var{tick:r,ticks:i,viewBox:a,minTickGap:o,orientation:s,interval:c,tickFormatter:l,unit:u,angle:d}=e;if(!i||!i.length||!r)return[];if(H(c)||kO.isSsr)return bV(i,H(c)?c:0)??[];var f=[],p=s===`top`||s===`bottom`?`width`:`height`,m=u&&p===`width`?mR(u,{fontSize:t,letterSpacing:n}):{width:0,height:0},h=(e,r)=>{var i=typeof l==`function`?l(e.value,r):e.value;return p===`width`?_V(mR(i,{fontSize:t,letterSpacing:n}),m,d):mR(i,{fontSize:t,letterSpacing:n})[p]},g=i[0],_=i[1],v=i.length>=2&&g!=null&&_!=null?US(_.coordinate-g.coordinate):1,y=vV(a,v,p);return c===`equidistantPreserveStart`?xV(v,y,h,i,o):c===`equidistantPreserveEnd`?SV(v,y,h,i,o):(f=c===`preserveStart`||c===`preserveStartEnd`?kV(v,y,h,i,o,c===`preserveStartEnd`):OV(v,y,h,i,o),f.filter(e=>e.isShow))}var jV=e=>{var{ticks:t,label:n,labelGapWithTick:r=5,tickSize:i=0,tickMargin:a=0}=e,o=0;if(t){Array.from(t).forEach(e=>{if(e){var t=e.getBoundingClientRect();t.width>o&&(o=t.width)}});var s=n?n.getBoundingClientRect().width:0,c=i+a,l=o+c+s+(n?r:0);return Math.round(l)}return 0},MV=aE({name:`renderedTicks`,initialState:{xAxis:{},yAxis:{}},reducers:{setRenderedTicks:(e,t)=>{var{axisType:n,axisId:r,ticks:i}=t.payload;e[n][r]=hO(i)},removeRenderedTicks:(e,t)=>{var{axisType:n,axisId:r}=t.payload;delete e[n][r]}}}),{setRenderedTicks:NV,removeRenderedTicks:PV}=MV.actions,FV=MV.reducer,IV=[`axisLine`,`width`,`height`,`className`,`hide`,`ticks`,`axisType`,`axisId`];function LV(e,t){if(e==null)return{};var n,r,i=RV(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function RV(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function zV(){return zV=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},zV.apply(null,arguments)}function BV(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function VV(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?BV(Object(n),!0).forEach(function(t){HV(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):BV(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function HV(e,t,n){return(t=UV(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function UV(e){var t=WV(e,`string`);return typeof t==`symbol`?t:t+``}function WV(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var GV={x:0,y:0,width:0,height:0,viewBox:{x:0,y:0,width:0,height:0},orientation:`bottom`,ticks:[],stroke:`#666`,tickLine:!0,axisLine:!0,tick:!0,mirror:!1,minTickGap:5,tickSize:6,tickMargin:2,interval:`preserveEnd`,zIndex:PA.axis};function KV(e){var{x:t,y:n,width:r,height:i,orientation:a,mirror:o,axisLine:s,otherSvgProps:c}=e;if(!s)return null;var l=VV(VV(VV({},c),Rx(s)),{},{fill:`none`});if(a===`top`||a===`bottom`){var u=+(a===`top`&&!o||a===`bottom`&&o);l=VV(VV({},l),{},{x1:t,y1:n+u*i,x2:t+r,y2:n+u*i})}else{var d=+(a===`left`&&!o||a===`right`&&o);l=VV(VV({},l),{},{x1:t+d*r,y1:n,x2:t+d*r,y2:n+i})}return b.createElement(`line`,zV({},l,{className:Px(`recharts-cartesian-axis-line`,(0,HS.default)(s,`className`))}))}function qV(e,t,n,r,i,a,o,s,c){var l,u,d,f,p,m,h=s?-1:1,g=e.tickSize||o,_=H(e.tickCoord)?e.tickCoord:e.coordinate;switch(a){case`top`:l=u=e.coordinate,f=n+ +!s*i,d=f-h*g,m=d-h*c,p=_;break;case`left`:d=f=e.coordinate,u=t+ +!s*r,l=u-h*g,p=l-h*c,m=_;break;case`right`:d=f=e.coordinate,u=t+ +s*r,l=u+h*g,p=l+h*c,m=_;break;default:l=u=e.coordinate,f=n+ +s*i,d=f+h*g,m=d+h*c,p=_;break}return{line:{x1:l,y1:d,x2:u,y2:f},tick:{x:p,y:m}}}function JV(e,t){switch(e){case`left`:return t?`start`:`end`;case`right`:return t?`end`:`start`;default:return`middle`}}function YV(e,t){switch(e){case`left`:case`right`:return`middle`;case`top`:return t?`start`:`end`;default:return t?`end`:`start`}}function XV(e){var{option:t,tickProps:n,value:r}=e,i,a=Px(n.className,`recharts-cartesian-axis-tick-value`);if(b.isValidElement(t))i=b.cloneElement(t,VV(VV({},n),{},{className:a}));else if(typeof t==`function`)i=t(VV(VV({},n),{},{className:a}));else{var o=`recharts-cartesian-axis-tick-value`;typeof t!=`boolean`&&(o=Px(o,cz(t))),i=b.createElement(NR,zV({},n,{className:o}),r)}return i}function ZV(e){var{ticks:t,axisType:n,axisId:r}=e,i=HC();return(0,b.useEffect)(()=>r==null||n==null?tC:(i(NV({ticks:t.map(e=>({value:e.value,coordinate:e.coordinate,offset:e.offset,index:e.index})),axisId:r,axisType:n})),()=>{i(PV({axisId:r,axisType:n}))}),[i,t,r,n]),null}var QV=(0,b.forwardRef)((e,t)=>{var{ticks:n=[],tick:r,tickLine:i,stroke:a,tickFormatter:o,unit:s,padding:c,tickTextProps:l,orientation:u,mirror:d,x:f,y:p,width:m,height:h,tickSize:g,tickMargin:_,fontSize:v,letterSpacing:y,getTicksConfig:x,events:S,axisType:C,axisId:w}=e,T=AV(VV(VV({},x),{},{ticks:n}),v,y),E=Rx(x),D=zx(r),O=DR(E.textAnchor)?E.textAnchor:JV(u,d),k=YV(u,d),ee={};typeof i==`object`&&(ee=i);var te=VV(VV({},E),{},{fill:`none`},ee),ne=T.map(e=>VV({entry:e},qV(e,f,p,m,h,u,g,d,_))),re=ne.map(e=>{var{entry:t,line:n}=e;return b.createElement(Wx,{className:`recharts-cartesian-axis-tick`,key:`tick-${t.value}-${t.coordinate}-${t.tickCoord}`},i&&b.createElement(`line`,zV({},te,n,{className:Px(`recharts-cartesian-axis-tick-line`,(0,HS.default)(i,`className`))})))}),A=ne.map((e,t)=>{var{entry:n,tick:i}=e,u=VV(VV({},VV(VV(VV(VV({verticalAnchor:k},E),{},{textAnchor:O,stroke:`none`,fill:a},i),{},{index:t,payload:n,visibleTicksCount:T.length,tickFormatter:o,padding:c},l),{},{angle:l?.angle??E.angle??0})),D);return b.createElement(Wx,zV({className:`recharts-cartesian-axis-tick-label`,key:`tick-label-${n.value}-${n.coordinate}-${n.tickCoord}`},lC(S,n,t)),r&&b.createElement(XV,{option:r,tickProps:u,value:`${typeof o==`function`?o(n.value,t):n.value}${s||``}`}))});return b.createElement(`g`,{className:`recharts-cartesian-axis-ticks recharts-${C}-ticks`},b.createElement(ZV,{ticks:T,axisId:w,axisType:C}),A.length>0&&b.createElement(WL,{zIndex:PA.label},b.createElement(`g`,{className:`recharts-cartesian-axis-tick-labels recharts-${C}-tick-labels`,ref:t},A)),re.length>0&&b.createElement(`g`,{className:`recharts-cartesian-axis-tick-lines recharts-${C}-tick-lines`},re))}),$V=(0,b.forwardRef)((e,t)=>{var{axisLine:n,width:r,height:i,className:a,hide:o,ticks:s,axisType:c,axisId:l}=e,u=LV(e,IV),[d,f]=(0,b.useState)(``),[p,m]=(0,b.useState)(``),h=(0,b.useRef)(null);(0,b.useImperativeHandle)(t,()=>({getCalculatedWidth:()=>jV({ticks:h.current,label:e.labelRef?.current,labelGapWithTick:5,tickSize:e.tickSize,tickMargin:e.tickMargin})}));var g=(0,b.useCallback)(e=>{if(e){var t=e.getElementsByClassName(`recharts-cartesian-axis-tick-value`);h.current=t;var n=t[0];if(n){var r=window.getComputedStyle(n),i=r.fontSize,a=r.letterSpacing;(i!==d||a!==p)&&(f(i),m(a))}}},[d,p]);return o||r!=null&&r<=0||i!=null&&i<=0?null:b.createElement(WL,{zIndex:e.zIndex},b.createElement(Wx,{className:Px(`recharts-cartesian-axis`,a)},b.createElement(KV,{x:e.x,y:e.y,width:r,height:i,orientation:e.orientation,mirror:e.mirror,axisLine:n,otherSvgProps:Rx(e)}),b.createElement(QV,{ref:g,axisType:c,events:u,fontSize:d,getTicksConfig:e,height:e.height,letterSpacing:p,mirror:e.mirror,orientation:e.orientation,padding:e.padding,stroke:e.stroke,tick:e.tick,tickFormatter:e.tickFormatter,tickLine:e.tickLine,tickMargin:e.tickMargin,tickSize:e.tickSize,tickTextProps:e.tickTextProps,ticks:s,unit:e.unit,width:e.width,x:e.x,y:e.y,axisId:l}),b.createElement(VR,{x:e.x,y:e.y,width:e.width,height:e.height,lowerWidth:e.width,upperWidth:e.width},b.createElement(KR,{label:e.label,labelRef:e.labelRef}),e.children)))}),eH=b.forwardRef((e,t)=>{var n=dC(e,GV);return b.createElement($V,zV({},n,{ref:t}))});eH.displayName=`CartesianAxis`;var tH=[`x1`,`y1`,`x2`,`y2`,`key`],nH=[`offset`],rH=[`xAxisId`,`yAxisId`],iH=[`xAxisId`,`yAxisId`];function aH(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function oH(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?aH(Object(n),!0).forEach(function(t){sH(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):aH(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function sH(e,t,n){return(t=cH(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function cH(e){var t=lH(e,`string`);return typeof t==`symbol`?t:t+``}function lH(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function uH(){return uH=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},uH.apply(null,arguments)}function dH(e,t){if(e==null)return{};var n,r,i=fH(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function fH(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var pH=e=>{var{fill:t}=e;if(!t||t===`none`)return null;var{fillOpacity:n,x:r,y:i,width:a,height:o,ry:s}=e;return b.createElement(`rect`,{x:r,y:i,ry:s,width:a,height:o,stroke:`none`,fill:t,fillOpacity:n,className:`recharts-cartesian-grid-bg`})};function mH(e){var{option:t,lineItemProps:n}=e,r;if(b.isValidElement(t))r=b.cloneElement(t,n);else if(typeof t==`function`)r=t(n);else{var{x1:i,y1:a,x2:o,y2:s,key:c}=n,l=Rx(dH(n,tH))??{},{offset:u}=l,d=dH(l,nH);r=b.createElement(`line`,uH({},d,{x1:i,y1:a,x2:o,y2:s,fill:`none`,key:c}))}return r}function hH(e){var{x:t,width:n,horizontal:r=!0,horizontalPoints:i}=e;if(!r||!i||!i.length)return null;var{xAxisId:a,yAxisId:o}=e,s=dH(e,rH),c=i.map((e,i)=>{var a=oH(oH({},s),{},{x1:t,y1:e,x2:t+n,y2:e,key:`line-${i}`,index:i});return b.createElement(mH,{key:`line-${i}`,option:r,lineItemProps:a})});return b.createElement(`g`,{className:`recharts-cartesian-grid-horizontal`},c)}function gH(e){var{y:t,height:n,vertical:r=!0,verticalPoints:i}=e;if(!r||!i||!i.length)return null;var{xAxisId:a,yAxisId:o}=e,s=dH(e,iH),c=i.map((e,i)=>{var a=oH(oH({},s),{},{x1:e,y1:t,x2:e,y2:t+n,key:`line-${i}`,index:i});return b.createElement(mH,{option:r,lineItemProps:a,key:`line-${i}`})});return b.createElement(`g`,{className:`recharts-cartesian-grid-vertical`},c)}function _H(e){var{horizontalFill:t,fillOpacity:n,x:r,y:i,width:a,height:o,horizontalPoints:s,horizontal:c=!0}=e;if(!c||!t||!t.length||s==null)return null;var l=s.map(e=>Math.round(e+i-i)).sort((e,t)=>e-t);i!==l[0]&&l.unshift(0);var u=l.map((e,s)=>{var c=l[s+1],u=c==null?i+o-e:c-e;if(u<=0)return null;var d=s%t.length;return b.createElement(`rect`,{key:`react-${s}`,y:e,x:r,height:u,width:a,stroke:`none`,fill:t[d],fillOpacity:n,className:`recharts-cartesian-grid-bg`})});return b.createElement(`g`,{className:`recharts-cartesian-gridstripes-horizontal`},u)}function vH(e){var{vertical:t=!0,verticalFill:n,fillOpacity:r,x:i,y:a,width:o,height:s,verticalPoints:c}=e;if(!t||!n||!n.length)return null;var l=c.map(e=>Math.round(e+i-i)).sort((e,t)=>e-t);i!==l[0]&&l.unshift(0);var u=l.map((e,t)=>{var c=l[t+1],u=c==null?i+o-e:c-e;if(u<=0)return null;var d=t%n.length;return b.createElement(`rect`,{key:`react-${t}`,x:e,y:a,width:u,height:s,stroke:`none`,fill:n[d],fillOpacity:r,className:`recharts-cartesian-grid-bg`})});return b.createElement(`g`,{className:`recharts-cartesian-gridstripes-vertical`},u)}var yH=(e,t)=>{var{xAxis:n,width:r,height:i,offset:a}=e;return BE(AV(oH(oH(oH({},GV),n),{},{ticks:VE(n,!0),viewBox:{x:0,y:0,width:r,height:i}})),a.left,a.left+a.width,t)},bH=(e,t)=>{var{yAxis:n,width:r,height:i,offset:a}=e;return BE(AV(oH(oH(oH({},GV),n),{},{ticks:VE(n,!0),viewBox:{x:0,y:0,width:r,height:i}})),a.top,a.top+a.height,t)},xH={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:`#ccc`,fill:`none`,verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:PA.grid};function SH(e){var t=CD(),n=wD(),r=SD(),i=oH(oH({},dC(e,xH)),{},{x:H(e.x)?e.x:r.left,y:H(e.y)?e.y:r.top,width:H(e.width)?e.width:r.width,height:H(e.height)?e.height:r.height}),{xAxisId:a,yAxisId:o,x:s,y:c,width:l,height:u,syncWithTicks:d,horizontalValues:f,verticalValues:p}=i,m=sD(),h=U(e=>AI(e,`xAxis`,a,m)),g=U(e=>AI(e,`yAxis`,o,m));if(!FE(l)||!FE(u)||!H(s)||!H(c))return null;var _=i.verticalCoordinatesGenerator||yH,v=i.horizontalCoordinatesGenerator||bH,{horizontalPoints:y,verticalPoints:x}=i;if((!y||!y.length)&&typeof v==`function`){var S=f&&f.length,C=v({yAxis:g?oH(oH({},g),{},{ticks:S?f:g.ticks}):void 0,width:t??l,height:n??u,offset:r},S?!0:d);uD(Array.isArray(C),`horizontalCoordinatesGenerator should return Array but instead it returned [${typeof C}]`),Array.isArray(C)&&(y=C)}if((!x||!x.length)&&typeof _==`function`){var w=p&&p.length,T=_({xAxis:h?oH(oH({},h),{},{ticks:w?p:h.ticks}):void 0,width:t??l,height:n??u,offset:r},w?!0:d);uD(Array.isArray(T),`verticalCoordinatesGenerator should return Array but instead it returned [${typeof T}]`),Array.isArray(T)&&(x=T)}return b.createElement(WL,{zIndex:i.zIndex},b.createElement(`g`,{className:`recharts-cartesian-grid`},b.createElement(pH,{fill:i.fill,fillOpacity:i.fillOpacity,x:i.x,y:i.y,width:i.width,height:i.height,ry:i.ry}),b.createElement(_H,uH({},i,{horizontalPoints:y})),b.createElement(vH,uH({},i,{verticalPoints:x})),b.createElement(hH,uH({},i,{offset:r,horizontalPoints:y,xAxis:h,yAxis:g})),b.createElement(gH,uH({},i,{offset:r,verticalPoints:x,xAxis:h,yAxis:g}))))}SH.displayName=`CartesianGrid`;var CH=aE({name:`errorBars`,initialState:{},reducers:{addErrorBar:(e,t)=>{var{itemId:n,errorBar:r}=t.payload;e[n]||(e[n]=[]),e[n].push(r)},replaceErrorBar:(e,t)=>{var{itemId:n,prev:r,next:i}=t.payload;e[n]&&(e[n]=e[n].map(e=>e.dataKey===r.dataKey&&e.direction===r.direction?i:e))},removeErrorBar:(e,t)=>{var{itemId:n,errorBar:r}=t.payload;e[n]&&(e[n]=e[n].filter(e=>e.dataKey!==r.dataKey||e.direction!==r.direction))}}}),{addErrorBar:Ppe,replaceErrorBar:Fpe,removeErrorBar:Ipe}=CH.actions,wH=CH.reducer,TH=[`children`];function EH(e,t){if(e==null)return{};var n,r,i=DH(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function DH(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var OH=(0,b.createContext)({data:[],xAxisId:`xAxis-0`,yAxisId:`yAxis-0`,dataPointFormatter:()=>({x:0,y:0,value:0}),errorBarOffset:0});function kH(e){var{children:t}=e,n=EH(e,TH);return b.createElement(OH.Provider,{value:n},t)}function AH(e,t){var n=U(t=>_F(t,e)),r=U(e=>bF(e,t)),i=n?.allowDataOverflow??hF.allowDataOverflow,a=r?.allowDataOverflow??vF.allowDataOverflow;return{needClip:i||a,needClipX:i,needClipY:a}}function jH(e){var{xAxisId:t,yAxisId:n,clipPathId:r}=e,i=vB(),{needClipX:a,needClipY:o,needClip:s}=AH(t,n);if(!s||!i)return null;var{x:c,y:l,width:u,height:d}=i;return b.createElement(`clipPath`,{id:`clipPath-${r}`},b.createElement(`rect`,{x:a?c:c-u/2,y:o?l:l-d/2,width:a?u:u*2,height:o?d:d*2}))}function MH(e){var t=zx(e),n=3,r=2;if(t!=null){var{r:i,strokeWidth:a}=t,o=Number(i),s=Number(a);return(Number.isNaN(o)||o<0)&&(o=n),(Number.isNaN(s)||s<0)&&(s=r),{r:o,strokeWidth:s}}return{r:n,strokeWidth:r}}function NH(e,t){return e.graphicalItems.cartesianItems.find(e=>e.id===t)?.xAxisId??0}function PH(e,t){return e.graphicalItems.cartesianItems.find(e=>e.id===t)?.yAxisId??0}var FH=(e,t,n)=>NI(e,`xAxis`,NH(e,t),n),IH=(e,t,n)=>MI(e,`xAxis`,NH(e,t),n),LH=(e,t,n)=>NI(e,`yAxis`,PH(e,t),n),RH=(e,t,n)=>MI(e,`yAxis`,PH(e,t),n),zH=W([TD,FH,LH,IH,RH],(e,t,n,r,i)=>zE(e,`xAxis`)?qE(t,r,!1):qE(n,i,!1)),BH=W([DF,(e,t)=>t],(e,t)=>e.filter(e=>e.type===`area`).find(e=>e.id===t)),VH=e=>zE(TD(e),`xAxis`)?`yAxis`:`xAxis`,HH=(e,t)=>VH(e)===`yAxis`?PH(e,t):NH(e,t),UH=W([TD,FH,LH,IH,RH,W([BH,(e,t,n)=>KF(e,VH(e),HH(e,t),n)],(e,t)=>{if(!(e==null||t==null)){var{stackId:n}=e,r=rj(e);if(!(n==null||r==null)){var i=(t[n]?.stackedData)?.find(e=>e.key===r);if(i!=null)return i.map(e=>[e[0],e[1]])}}}),aA,zH,BH,NA],(e,t,n,r,i,a,o,s,c,l)=>{var{chartData:u,dataStartIndex:d,dataEndIndex:f}=o;if(!(c==null||e!==`horizontal`&&e!==`vertical`||t==null||n==null||r==null||i==null||r.length===0||i.length===0||s==null)){var{data:p}=c,m=p&&p.length>0?p:u?.slice(d,f+1);if(m!=null)return hU({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:d,areaSettings:c,stackedData:a,displayedData:m,chartBaseValue:l,bandSize:s})}}),WH=[`id`],GH=[`activeDot`,`animationBegin`,`animationDuration`,`animationEasing`,`connectNulls`,`dot`,`fill`,`fillOpacity`,`hide`,`isAnimationActive`,`legendType`,`stroke`,`xAxisId`,`yAxisId`];function KH(){return KH=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},KH.apply(null,arguments)}function qH(e,t){if(e==null)return{};var n,r,i=JH(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function JH(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function YH(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function XH(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?YH(Object(n),!0).forEach(function(t){ZH(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):YH(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ZH(e,t,n){return(t=QH(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function QH(e){var t=$H(e,`string`);return typeof t==`symbol`?t:t+``}function $H(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function eU(e,t){return e&&e!==`none`?e:t}var tU=e=>{var{dataKey:t,name:n,stroke:r,fill:i,legendType:a,hide:o}=e;return[{inactive:o,dataKey:t,type:a,color:eU(r,i),value:YE(n,t),payload:e}]},nU=b.memo(e=>{var{dataKey:t,data:n,stroke:r,strokeWidth:i,fill:a,name:o,hide:s,unit:c,tooltipType:l,id:u}=e,d={dataDefinedOnItem:n,getPosition:tC,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:t,nameKey:void 0,name:YE(o,t),hide:s,type:l,color:eU(r,a),unit:c,graphicalItemId:u}};return b.createElement(Mz,{tooltipEntrySettings:d})});function rU(e){var{clipPathId:t,points:n,props:r}=e,{needClip:i,dot:a,dataKey:o}=r,s=Rx(r);return b.createElement($z,{points:n,dot:a,className:`recharts-area-dots`,dotClassName:`recharts-area-dot`,dataKey:o,baseProps:s,needClip:i,clipPathId:t})}function iU(e){var{showLabels:t,children:n,points:r}=e,i=r.map(e=>{var t={x:e.x??0,y:e.y??0,width:0,lowerWidth:0,upperWidth:0,height:0};return XH(XH({},t),{},{value:e.value,payload:e.payload,parentViewBox:void 0,viewBox:t,fill:void 0})});return b.createElement(XR,{value:t?i:void 0},n)}function aU(e){var{points:t,baseLine:n,needClip:r,clipPathId:i,props:a}=e,{layout:o,type:s,stroke:c,connectNulls:l,isRange:u}=a,{id:d}=a,f=qH(a,WH),p=Rx(f),m=Bx(f);return b.createElement(b.Fragment,null,t?.length>1&&b.createElement(Wx,{clipPath:r?`url(#clipPath-${i})`:void 0},b.createElement(UO,KH({},m,{id:d,points:t,connectNulls:l,type:s,baseLine:n,layout:o,stroke:`none`,className:`recharts-area-area`})),c!==`none`&&b.createElement(UO,KH({},p,{className:`recharts-area-curve`,layout:o,type:s,connectNulls:l,fill:`none`,points:t})),c!==`none`&&u&&Array.isArray(n)&&b.createElement(UO,KH({},p,{className:`recharts-area-curve`,layout:o,type:s,connectNulls:l,fill:`none`,points:n}))),b.createElement(rU,{points:t,props:f,clipPathId:i}))}function oU(e){var{alpha:t,baseLine:n,points:r,strokeWidth:i}=e,a=r[0]?.y,o=r[r.length-1]?.y;if(!PE(a)||!PE(o))return null;var s=t*Math.abs(a-o),c=Math.max(...r.map(e=>e.x||0));return H(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(e=>e.x||0),c)),H(c)?b.createElement(`rect`,{x:0,y:a<o?a:a-s,width:c+(i?parseInt(`${i}`,10):1),height:Math.floor(s)}):null}function sU(e){var{alpha:t,baseLine:n,points:r,strokeWidth:i}=e,a=r[0]?.x,o=r[r.length-1]?.x;if(!PE(a)||!PE(o))return null;var s=t*Math.abs(a-o),c=Math.max(...r.map(e=>e.y||0));return H(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(e=>e.y||0),c)),H(c)?b.createElement(`rect`,{x:a<o?a:a-s,y:0,width:s,height:Math.floor(c+(i?parseInt(`${i}`,10):1))}):null}function cU(e){var{alpha:t,layout:n,points:r,baseLine:i,strokeWidth:a}=e;return n===`vertical`?b.createElement(oU,{alpha:t,points:r,baseLine:i,strokeWidth:a}):b.createElement(sU,{alpha:t,points:r,baseLine:i,strokeWidth:a})}function lU(e){var{needClip:t,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a}=e,{points:o,baseLine:s,isAnimationActive:c,animationBegin:l,animationDuration:u,animationEasing:d,onAnimationStart:f,onAnimationEnd:p}=r,m=ck((0,b.useMemo)(()=>({points:o,baseLine:s}),[o,s]),`recharts-area-`),h=DD(),[g,_]=(0,b.useState)(!1),v=!g,y=(0,b.useCallback)(()=>{typeof p==`function`&&p(),_(!1)},[p]),x=(0,b.useCallback)(()=>{typeof f==`function`&&f(),_(!0)},[f]);if(h==null)return null;var S=i.current,C=a.current;return b.createElement(iU,{showLabels:v,points:o},r.children,b.createElement(sk,{animationId:m,begin:l,duration:u,isActive:c,easing:d,onAnimationEnd:y,onAnimationStart:x,key:m},e=>{if(S){var l=S.length/o.length,u=e===1?o:o.map((t,n)=>{var r=Math.floor(n*l);if(S[r]){var i=S[r];return XH(XH({},t),{},{x:XS(i.x,t.x,e),y:XS(i.y,t.y,e)})}return t}),d=H(s)?XS(C,s,e):QS(s)||WS(s)?XS(C,0,e):s.map((t,n)=>{var r=Math.floor(n*l);if(Array.isArray(C)&&C[r]){var i=C[r];return XH(XH({},t),{},{x:XS(i.x,t.x,e),y:XS(i.y,t.y,e)})}return t});return e>0&&(i.current=u,a.current=d),b.createElement(aU,{points:u,baseLine:d,needClip:t,clipPathId:n,props:r})}return e>0&&(i.current=o,a.current=s),b.createElement(Wx,null,c&&b.createElement(`defs`,null,b.createElement(`clipPath`,{id:`animationClipPath-${n}`},b.createElement(cU,{alpha:e,points:o,baseLine:s,layout:h,strokeWidth:r.strokeWidth}))),b.createElement(Wx,{clipPath:`url(#animationClipPath-${n})`},b.createElement(aU,{points:o,baseLine:s,needClip:t,clipPathId:n,props:r})))}),b.createElement($R,{label:r.label}))}function uU(e){var{needClip:t,clipPathId:n,props:r}=e,i=(0,b.useRef)(null),a=(0,b.useRef)();return b.createElement(lU,{needClip:t,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a})}var dU=class extends b.PureComponent{render(){var{hide:e,dot:t,points:n,className:r,top:i,left:a,needClip:o,xAxisId:s,yAxisId:c,width:l,height:u,id:d,baseLine:f,zIndex:p}=this.props;if(e)return null;var m=Px(`recharts-area`,r),h=d,{r:g,strokeWidth:_}=MH(t),v=yz(t),y=g*2+_,x=o?`url(#clipPath-${v?``:`dots-`}${h})`:void 0;return b.createElement(WL,{zIndex:p},b.createElement(Wx,{className:m},o&&b.createElement(`defs`,null,b.createElement(jH,{clipPathId:h,xAxisId:s,yAxisId:c}),!v&&b.createElement(`clipPath`,{id:`clipPath-dots-${h}`},b.createElement(`rect`,{x:a-y/2,y:i-y/2,width:l+y,height:u+y}))),b.createElement(uU,{needClip:o,clipPathId:h,props:this.props})),b.createElement(EB,{points:n,mainColor:eU(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:x}),this.props.isRange&&Array.isArray(f)&&b.createElement(EB,{points:f,mainColor:eU(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:x}))}},fU={activeDot:!0,animationBegin:0,animationDuration:1500,animationEasing:`ease`,connectNulls:!1,dot:!1,fill:`#3182bd`,fillOpacity:.6,hide:!1,isAnimationActive:`auto`,legendType:`line`,stroke:`#3182bd`,strokeWidth:1,type:`linear`,label:!1,xAxisId:0,yAxisId:0,zIndex:PA.area};function pU(e){var{activeDot:t,animationBegin:n,animationDuration:r,animationEasing:i,connectNulls:a,dot:o,fill:s,fillOpacity:c,hide:l,isAnimationActive:u,legendType:d,stroke:f,xAxisId:p,yAxisId:m}=e,h=qH(e,GH),g=ED(),_=AL(),{needClip:v}=AH(p,m),y=sD(),{points:x,isRange:S,baseLine:C}=U(t=>UH(t,e.id,y))??{},w=vB();if(g!==`horizontal`&&g!==`vertical`||w==null||_!==`AreaChart`&&_!==`ComposedChart`)return null;var{height:T,width:E,x:D,y:O}=w;return!x||!x.length?null:b.createElement(dU,KH({},h,{activeDot:t,animationBegin:n,animationDuration:r,animationEasing:i,baseLine:C,connectNulls:a,dot:o,fill:s,fillOpacity:c,height:T,hide:l,layout:g,isAnimationActive:u,isRange:S,legendType:d,needClip:v,points:x,stroke:f,width:E,left:D,top:O,xAxisId:p,yAxisId:m}))}var mU=(e,t,n,r,i)=>{var a=n??t;if(H(a))return a;var o=e===`horizontal`?i:r,s=o.scale.domain();if(o.type===`number`){var c=Math.max(s[0],s[1]),l=Math.min(s[0],s[1]);return a===`dataMin`?l:a===`dataMax`||c<0?c:Math.max(Math.min(s[0],s[1]),0)}return a===`dataMin`?s[0]:a===`dataMax`?s[1]:s[0]};function hU(e){var{areaSettings:{connectNulls:t,baseValue:n,dataKey:r},stackedData:i,layout:a,chartBaseValue:o,xAxis:s,yAxis:c,displayedData:l,dataStartIndex:u,xAxisTicks:d,yAxisTicks:f,bandSize:p}=e,m=i&&i.length,h=mU(a,o,n,s,c),g=a===`horizontal`,_=!1,v=l.map((e,n)=>{var a;if(m)a=i[u+n];else{var o=RE(e,r);Array.isArray(o)?(a=o,_=!0):a=[h,o]}var l=a?.[1]??null,v=l==null||m&&!t&&RE(e,r)==null;return g?{x:UE({axis:s,ticks:d,bandSize:p,entry:e,index:n}),y:v?null:c.scale.map(l)??null,value:a,payload:e}:{x:v?null:s.scale.map(l)??null,y:UE({axis:c,ticks:f,bandSize:p,entry:e,index:n}),value:a,payload:e}});return{points:v,baseLine:(m||_?v.map(e=>{var t=Array.isArray(e.value)?e.value[0]:null;return g?{x:e.x,y:t!=null&&e.y!=null?c.scale.map(t)??null:null,payload:e.payload}:{x:t==null?null:s.scale.map(t)??null,y:e.y,payload:e.payload}}):g?c.scale.map(h):s.scale.map(h))??0,isRange:_}}function gU(e){var t=dC(e,fU),n=sD();return b.createElement(Pz,{id:t.id,type:`area`},e=>b.createElement(b.Fragment,null,b.createElement(Nz,{legendPayload:tU(t)}),b.createElement(nU,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:e}),b.createElement(Iz,{type:`area`,id:e,data:t.data,dataKey:t.dataKey,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,stackId:HE(t.stackId),hide:t.hide,barSize:void 0,baseValue:t.baseValue,isPanorama:n,connectNulls:t.connectNulls}),b.createElement(pU,KH({},t,{id:e}))))}var _U=b.memo(gU,SO);_U.displayName=`Area`;var vU=!0,yU=`Invariant failed`;function bU(e,t){if(!e){if(vU)throw Error(yU);var n=typeof t==`function`?t():t,r=n?`${yU}: ${n}`:yU;throw Error(r)}}function xU(){return xU=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},xU.apply(null,arguments)}function SU(e){return b.createElement(Oz,xU({shapeType:`rectangle`,activeClassName:`recharts-active-bar`,inActiveClassName:`recharts-inactive-bar`},e))}var CU=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(n,r)=>{if(H(e))return e;var i=H(n)||QS(n);return i?e(n,r):(!i&&bU(!1,`minPointSize callback function received a value with type of ${typeof n}. Currently only numbers or null/undefined are supported.`),t)}},wU=(e,t,n)=>n,TU=W([DF,(e,t)=>t],(e,t)=>e.filter(e=>e.type===`bar`).find(e=>e.id===t)),EU=W([TU],e=>e?.maxBarSize),DU=(e,t,n,r)=>r,OU=W([TD,DF,NH,PH,wU],(e,t,n,r,i)=>t.filter(t=>e===`horizontal`?t.xAxisId===n:t.yAxisId===r).filter(e=>e.isPanorama===i).filter(e=>e.hide===!1).filter(e=>e.type===`bar`)),kU=(e,t,n)=>{var r=TD(e),i=NH(e,t),a=PH(e,t);if(!(i==null||a==null))return r===`horizontal`?KF(e,`yAxis`,a,n):KF(e,`xAxis`,i,n)},AU=W([OU,EA,(e,t)=>{var n=TD(e),r=NH(e,t),i=PH(e,t);if(!(r==null||i==null))return n===`horizontal`?DI(e,`xAxis`,r):DI(e,`yAxis`,i)}],OB),jU=(e,t,n)=>{var r=TU(e,t);if(r==null)return 0;var i=NH(e,t),a=PH(e,t);if(i==null||a==null)return 0;var o=TD(e),s=CA(e),{maxBarSize:c}=r,l=QS(c)?s:c,u,d;return o===`horizontal`?(u=NI(e,`xAxis`,i,n),d=MI(e,`xAxis`,i,n)):(u=NI(e,`yAxis`,a,n),d=MI(e,`yAxis`,a,n)),qE(u,d,!0)??l??0},MU=(e,t,n)=>{var r=TD(e),i=NH(e,t),a=PH(e,t);if(!(i==null||a==null)){var o,s;return r===`horizontal`?(o=NI(e,`xAxis`,i,n),s=MI(e,`xAxis`,i,n)):(o=NI(e,`yAxis`,a,n),s=MI(e,`yAxis`,a,n)),qE(o,s)}},NU=W([aD,oD,(e,t,n)=>{var r=NH(e,t);if(r!=null)return NI(e,`xAxis`,r,n)},(e,t,n)=>{var r=PH(e,t);if(r!=null)return NI(e,`yAxis`,r,n)},(e,t,n)=>{var r=NH(e,t);if(r!=null)return MI(e,`xAxis`,r,n)},(e,t,n)=>{var r=PH(e,t);if(r!=null)return MI(e,`yAxis`,r,n)},W([W([AU,CA,wA,TA,jU,MU,EU],FB),TU],LB),TD,aA,MU,W([kU,TU],IB),TU,DU],(e,t,n,r,i,a,o,s,c,l,u,d,f)=>{var{chartData:p,dataStartIndex:m,dataEndIndex:h}=c;if(!(d==null||o==null||t==null||s!==`horizontal`&&s!==`vertical`||n==null||r==null||i==null||a==null||l==null)){var{data:g}=d,_=g!=null&&g.length>0?g:p?.slice(m,h+1);if(_!=null)return hW({layout:s,barSettings:d,pos:o,parentViewBox:t,bandSize:l,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,stackedData:u,displayedData:_,offset:e,cells:f,dataStartIndex:m})}}),PU=[`index`];function FU(){return FU=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},FU.apply(null,arguments)}function IU(e,t){if(e==null)return{};var n,r,i=LU(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function LU(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var RU=(0,b.createContext)(void 0),zU=e=>{var t=(0,b.useContext)(RU);if(t!=null)return t.stackId;if(e!=null)return HE(e)},BU=(e,t)=>`recharts-bar-stack-clip-path-${e}-${t}`,VU=e=>{var t=(0,b.useContext)(RU);if(t!=null){var{stackId:n}=t;return`url(#${BU(n,e)})`}},HU=e=>{var{index:t}=e,n=IU(e,PU),r=VU(t);return b.createElement(Wx,FU({className:`recharts-bar-stack-layer`,clipPath:r},n))},UU=[`onMouseEnter`,`onMouseLeave`,`onClick`],WU=[`value`,`background`,`tooltipPosition`],GU=[`id`],KU=[`onMouseEnter`,`onClick`,`onMouseLeave`];function qU(){return qU=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},qU.apply(null,arguments)}function JU(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function YU(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?JU(Object(n),!0).forEach(function(t){XU(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):JU(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function XU(e,t,n){return(t=ZU(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ZU(e){var t=QU(e,`string`);return typeof t==`symbol`?t:t+``}function QU(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function $U(e,t){if(e==null)return{};var n,r,i=eW(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function eW(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var tW=e=>{var{dataKey:t,name:n,fill:r,legendType:i,hide:a}=e;return[{inactive:a,dataKey:t,type:i,color:r,value:YE(n,t),payload:e}]},nW=b.memo(e=>{var{dataKey:t,stroke:n,strokeWidth:r,fill:i,name:a,hide:o,unit:s,tooltipType:c,id:l}=e,u={dataDefinedOnItem:void 0,getPosition:tC,settings:{stroke:n,strokeWidth:r,fill:i,dataKey:t,nameKey:void 0,name:YE(a,t),hide:o,type:c,color:i,unit:s,graphicalItemId:l}};return b.createElement(Mz,{tooltipEntrySettings:u})});function rW(e){var t=U(bL),{data:n,dataKey:r,background:i,allOtherBarProps:a}=e,{onMouseEnter:o,onMouseLeave:s,onClick:c}=a,l=$U(a,UU),u=kz(o,r,a.id),d=Az(s),f=jz(c,r,a.id);if(!i||n==null)return null;var p=zx(i);return b.createElement(WL,{zIndex:RB(i,PA.barBackground)},n.map((e,n)=>{var{value:a,background:o,tooltipPosition:s}=e,c=$U(e,WU);if(!o)return null;var m=u(e,n),h=d(e,n),g=f(e,n),_=YU(YU(YU(YU(YU({option:i,isActive:String(n)===t},c),{},{fill:`#eee`},o),p),lC(l,e,n)),{},{onMouseEnter:m,onMouseLeave:h,onClick:g,dataKey:r,index:n,className:`recharts-bar-background-rectangle`});return b.createElement(SU,qU({key:`background-bar-${n}`},_))}))}function iW(e){var{showLabels:t,children:n,rects:r}=e,i=r?.map(e=>{var t={x:e.x,y:e.y,width:e.width,lowerWidth:e.width,upperWidth:e.width,height:e.height};return YU(YU({},t),{},{value:e.value,payload:e.payload,parentViewBox:e.parentViewBox,viewBox:t,fill:e.fill})});return b.createElement(XR,{value:t?i:void 0},n)}function aW(e){var{shape:t,activeBar:n,baseProps:r,entry:i,index:a,dataKey:o}=e,s=U(bL),c=U(SL),l=n&&String(i.originalDataIndex)===s&&(c==null||o===c),[u,d]=(0,b.useState)(!1),[f,p]=(0,b.useState)(!1);(0,b.useEffect)(()=>{var e;return l?(d(!0),e=requestAnimationFrame(()=>{p(!0)})):p(!1),()=>{cancelAnimationFrame(e)}},[l]);var m=(0,b.useCallback)(()=>{l||d(!1)},[l]),h=l&&f,g=l||u,_=l?n===!0?t:n:t,v=b.createElement(SU,qU({},r,{name:String(r.name)},i,{isActive:h,option:_,index:a,dataKey:o,onTransitionEnd:m}));return g?b.createElement(WL,{zIndex:PA.activeBar},b.createElement(HU,{index:i.originalDataIndex},v)):v}function oW(e){var{shape:t,baseProps:n,entry:r,index:i,dataKey:a}=e;return b.createElement(SU,qU({},n,{name:String(n.name)},r,{isActive:!1,option:t,index:i,dataKey:a}))}function sW(e){var{data:t,props:n}=e,r=Rx(n)??{},{id:i}=r,a=$U(r,GU),{shape:o,dataKey:s,activeBar:c}=n,{onMouseEnter:l,onClick:u,onMouseLeave:d}=n,f=$U(n,KU),p=kz(l,s,i),m=Az(d),h=jz(u,s,i);return t?b.createElement(b.Fragment,null,t.map((e,t)=>b.createElement(HU,qU({index:e.originalDataIndex,key:`rectangle-${e?.x}-${e?.y}-${e?.value}-${t}`,className:`recharts-bar-rectangle`},lC(f,e,t),{onMouseEnter:p(e,t),onMouseLeave:m(e,t),onClick:h(e,t)}),c?b.createElement(aW,{shape:o,activeBar:c,baseProps:a,entry:e,index:t,dataKey:s}):b.createElement(oW,{shape:o,baseProps:a,entry:e,index:t,dataKey:s})))):null}function cW(e){var{props:t,previousRectanglesRef:n}=e,{data:r,layout:i,isAnimationActive:a,animationBegin:o,animationDuration:s,animationEasing:c,onAnimationEnd:l,onAnimationStart:u}=t,d=n.current,f=ck(t,`recharts-bar-`),[p,m]=(0,b.useState)(!1),h=!p,g=(0,b.useCallback)(()=>{typeof l==`function`&&l(),m(!1)},[l]),_=(0,b.useCallback)(()=>{typeof u==`function`&&u(),m(!0)},[u]);return b.createElement(iW,{showLabels:h,rects:r},b.createElement(sk,{animationId:f,begin:o,duration:s,isActive:a,easing:c,onAnimationEnd:g,onAnimationStart:_,key:f},e=>{var a=e===1?r:r?.map((t,n)=>{var r=d&&d[n];if(r)return YU(YU({},t),{},{x:XS(r.x,t.x,e),y:XS(r.y,t.y,e),width:XS(r.width,t.width,e),height:XS(r.height,t.height,e)});if(i===`horizontal`){var a=XS(0,t.height,e),o=XS(t.stackedBarStart,t.y,e);return YU(YU({},t),{},{y:o,height:a})}var s=XS(0,t.width,e),c=XS(t.stackedBarStart,t.x,e);return YU(YU({},t),{},{width:s,x:c})});return e>0&&(n.current=a??null),a==null?null:b.createElement(Wx,null,b.createElement(sW,{props:t,data:a}))}),b.createElement($R,{label:t.label}),t.children)}function lW(e){var t=(0,b.useRef)(null);return b.createElement(cW,{previousRectanglesRef:t,props:e})}var uW=0,dW=(e,t)=>{var n=Array.isArray(e.value)?e.value[1]:e.value;return{x:e.x,y:e.y,value:n,errorVal:RE(e,t)}},fW=class extends b.PureComponent{render(){var{hide:e,data:t,dataKey:n,className:r,xAxisId:i,yAxisId:a,needClip:o,background:s,id:c}=this.props;if(e||t==null)return null;var l=Px(`recharts-bar`,r),u=c;return b.createElement(Wx,{className:l,id:c},o&&b.createElement(`defs`,null,b.createElement(jH,{clipPathId:u,xAxisId:i,yAxisId:a})),b.createElement(Wx,{className:`recharts-bar-rectangles`,clipPath:o?`url(#clipPath-${u})`:void 0},b.createElement(rW,{data:t,dataKey:n,background:s,allOtherBarProps:this.props}),b.createElement(lW,this.props)))}},pW={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:`ease`,background:!1,hide:!1,isAnimationActive:`auto`,label:!1,legendType:`rect`,minPointSize:uW,xAxisId:0,yAxisId:0,zIndex:PA.bar};function mW(e){var{xAxisId:t,yAxisId:n,hide:r,legendType:i,minPointSize:a,activeBar:o,animationBegin:s,animationDuration:c,animationEasing:l,isAnimationActive:u}=e,{needClip:d}=AH(t,n),f=ED(),p=sD(),m=vz(e.children,cR),h=U(t=>NU(t,e.id,p,m));if(f!==`vertical`&&f!==`horizontal`)return null;var g,_=h?.[0];return g=_==null||_.height==null||_.width==null?0:f===`vertical`?_.height/2:_.width/2,b.createElement(kH,{xAxisId:t,yAxisId:n,data:h,dataPointFormatter:dW,errorBarOffset:g},b.createElement(fW,qU({},e,{layout:f,needClip:d,data:h,xAxisId:t,yAxisId:n,hide:r,legendType:i,minPointSize:a,activeBar:o,animationBegin:s,animationDuration:c,animationEasing:l,isAnimationActive:u})))}function hW(e){var{layout:t,barSettings:{dataKey:n,minPointSize:r,hasCustomShape:i},pos:a,bandSize:o,xAxis:s,yAxis:c,xAxisTicks:l,yAxisTicks:u,stackedData:d,displayedData:f,offset:p,cells:m,parentViewBox:h,dataStartIndex:g}=e,_=t===`horizontal`?c:s,v=d?_.scale.domain():null,y=fie({numericAxis:_}),b=_.scale.map(y);return f.map((e,f)=>{var _,x,S,C,w,T;if(d){var E=d[f+g];if(E==null)return null;_=lie(E,v)}else _=RE(e,n),Array.isArray(_)||(_=[y,_]);var D=CU(r,uW)(_[1],f);if(t===`horizontal`){var O=c.scale.map(_[0]),k=c.scale.map(_[1]);if(O==null||k==null)return null;x=WE({axis:s,ticks:l,bandSize:o,offset:a.offset,entry:e,index:f}),S=k??O??void 0,C=a.size;var ee=O-k;if(w=WS(ee)?0:ee,T={x,y:p.top,width:C,height:p.height},Math.abs(D)>0&&Math.abs(w)<Math.abs(D)){var te=US(w||D)*(Math.abs(D)-Math.abs(w));S-=te,w+=te}}else{var ne=s.scale.map(_[0]),re=s.scale.map(_[1]);if(ne==null||re==null)return null;if(x=ne,S=WE({axis:c,ticks:u,bandSize:o,offset:a.offset,entry:e,index:f}),C=re-ne,w=a.size,T={x:p.left,y:S,width:p.width,height:w},Math.abs(D)>0&&Math.abs(C)<Math.abs(D)){var A=US(C||D)*(Math.abs(D)-Math.abs(C));C+=A}}return x==null||S==null||C==null||w==null||!i&&(C===0||w===0)?null:YU(YU({},e),{},{stackedBarStart:b,x,y:S,width:C,height:w,value:d?_:_[1],payload:e,background:T,tooltipPosition:{x:x+C/2,y:S+w/2},parentViewBox:h,originalDataIndex:f},m&&m[f]&&m[f].props)}).filter(Boolean)}function gW(e){var t=dC(e,pW),n=zU(t.stackId),r=sD();return b.createElement(Pz,{id:t.id,type:`bar`},e=>b.createElement(b.Fragment,null,b.createElement(Nz,{legendPayload:tW(t)}),b.createElement(nW,{dataKey:t.dataKey,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:e}),b.createElement(Iz,{type:`bar`,id:e,data:void 0,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,stackId:n,hide:t.hide,barSize:t.barSize,minPointSize:t.minPointSize,maxBarSize:t.maxBarSize,isPanorama:r,hasCustomShape:t.shape!=null}),b.createElement(WL,{zIndex:t.zIndex},b.createElement(mW,qU({},t,{id:e})))))}var _W=b.memo(gW,SO);_W.displayName=`Bar`;var vW=[`option`,`isActive`];function yW(){return yW=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},yW.apply(null,arguments)}function bW(e,t){if(e==null)return{};var n,r,i=xW(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function xW(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function SW(e){var{option:t,isActive:n}=e,r=bW(e,vW);return typeof t==`string`?b.createElement(Oz,yW({option:b.createElement(oC,yW({type:t},r)),isActive:n,shapeType:`symbols`},r)):b.createElement(Oz,yW({option:t,isActive:n,shapeType:`symbols`},r))}var CW=W([(e,t,n,r,i,a,o)=>iA(e,void 0,void 0,o),(e,t,n,r,i,a,o)=>NI(e,`xAxis`,t,o),(e,t,n,r,i,a,o)=>MI(e,`xAxis`,t,o),(e,t,n,r,i,a,o)=>NI(e,`yAxis`,n,o),(e,t,n,r,i,a,o)=>MI(e,`yAxis`,n,o),(e,t,n,r)=>hle(e,`zAxis`,r,!1),W([DF,(e,t,n,r,i)=>i],(e,t)=>e.filter(e=>e.type===`scatter`).find(e=>e.id===t)),(e,t,n,r,i,a)=>a],(e,t,n,r,i,a,o,s)=>{var{chartData:c,dataStartIndex:l,dataEndIndex:u}=e;if(o!=null){var d=o?.data!=null&&o.data.length>0?o.data:c?.slice(l,u+1);if(!(d==null||t==null||r==null||n==null||i==null||n?.length===0||i?.length===0))return VW({displayedData:d,xAxis:t,yAxis:r,zAxis:a,scatterSettings:o,xAxisTicks:n,yAxisTicks:i,cells:s})}}),wW=[`id`],TW=[`onMouseEnter`,`onClick`,`onMouseLeave`],EW=[`animationBegin`,`animationDuration`,`animationEasing`,`hide`,`isAnimationActive`,`legendType`,`lineJointType`,`lineType`,`shape`,`xAxisId`,`yAxisId`,`zAxisId`];function DW(e,t){if(e==null)return{};var n,r,i=OW(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function OW(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function kW(){return kW=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},kW.apply(null,arguments)}function AW(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function jW(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?AW(Object(n),!0).forEach(function(t){MW(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):AW(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function MW(e,t,n){return(t=NW(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function NW(e){var t=PW(e,`string`);return typeof t==`symbol`?t:t+``}function PW(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var FW=e=>{var{dataKey:t,name:n,fill:r,legendType:i,hide:a}=e;return[{inactive:a,dataKey:t,type:i,color:r,value:YE(n,t),payload:e}]},IW=b.memo(e=>{var{dataKey:t,points:n,stroke:r,strokeWidth:i,fill:a,name:o,hide:s,tooltipType:c,id:l}=e,u={dataDefinedOnItem:n?.map(e=>e.tooltipPayload),getPosition:e=>{var t;return n==null||(t=n[Number(e)])==null?void 0:t.tooltipPosition},settings:{stroke:r,strokeWidth:i,fill:a,nameKey:void 0,dataKey:t,name:YE(o,t),hide:s,type:c,color:a,unit:``,graphicalItemId:l}};return b.createElement(Mz,{tooltipEntrySettings:u})});function LW(e){var{points:t,props:n}=e,{line:r,lineType:i,lineJointType:a}=n;if(!r)return null;var o=Rx(n),s=zx(r),c,l;if(i===`joint`)c=t.map(e=>({x:e.cx??null,y:e.cy??null}));else if(i===`fitting`){var{xmin:u,xmax:d,a:f,b:p}=Xne(t),m=e=>f*e+p;c=[{x:u,y:m(u)},{x:d,y:m(d)}]}var h=jW(jW(jW({},o),{},{fill:`none`,stroke:o&&o.fill},s),{},{points:c});return l=b.isValidElement(r)?b.cloneElement(r,h):typeof r==`function`?r(h):b.createElement(UO,kW({},h,{type:a})),b.createElement(Wx,{className:`recharts-scatter-line`,key:`recharts-scatter-line`},l)}function RW(e){var{showLabels:t,points:n,children:r}=e,i=xD(),a=(0,b.useMemo)(()=>n?.map(e=>{var t={x:e.x??0,y:e.y??0,width:e.width,height:e.height,lowerWidth:e.width,upperWidth:e.width};return jW(jW({},t),{},{value:void 0,payload:e.payload,viewBox:t,parentViewBox:i,fill:void 0})}),[i,n]);return b.createElement(XR,{value:t?a:void 0},r)}function zW(e){var{points:t,allOtherScatterProps:n}=e,{shape:r,activeShape:i,dataKey:a}=n,{id:o}=n,s=DW(n,wW),c=U(bL),{onMouseEnter:l,onClick:u,onMouseLeave:d}=n,f=DW(n,TW),p=kz(l,a,o),m=Az(d),h=jz(u,a,o);if(!cre(t))return null;var g=Rx(s);return b.createElement(b.Fragment,null,b.createElement(LW,{points:t,props:s}),t.map((e,t)=>{var n=i!=null&&i!==!1,a=n&&c===String(t),s=n&&a?i:r,l=jW(jW(jW({},g),e),{},{index:t,[nD]:String(o)});return b.createElement(WL,{key:`symbol-${e?.cx}-${e?.cy}-${e?.size}-${t}`,zIndex:a?PA.activeDot:void 0},b.createElement(Wx,kW({className:`recharts-scatter-symbol`},lC(f,e,t),{onMouseEnter:p(e,t),onMouseLeave:m(e,t),onClick:h(e,t)}),b.createElement(SW,kW({option:s,isActive:a},l))))}))}function BW(e){var{previousPointsRef:t,props:n}=e,{points:r,isAnimationActive:i,animationBegin:a,animationDuration:o,animationEasing:s}=n,c=t.current,l=ck(n,`recharts-scatter-`),[u,d]=(0,b.useState)(!1),f=(0,b.useCallback)(()=>{d(!1)},[]),p=(0,b.useCallback)(()=>{d(!0)},[]),m=!u;return b.createElement(RW,{showLabels:m,points:r},n.children,b.createElement(sk,{animationId:l,begin:a,duration:o,isActive:i,easing:s,onAnimationEnd:f,onAnimationStart:p,key:l},e=>{var i=e===1?r:r?.map((t,n)=>{var r=c&&c[n];return r?jW(jW({},t),{},{cx:t.cx==null?void 0:XS(r.cx,t.cx,e),cy:t.cy==null?void 0:XS(r.cy,t.cy,e),size:XS(r.size,t.size,e)}):jW(jW({},t),{},{size:XS(0,t.size,e)})});return e>0&&(t.current=i),b.createElement(Wx,null,b.createElement(zW,{points:i,allOtherScatterProps:n,showLabels:m}))}),b.createElement($R,{label:n.label}))}function VW(e){var{displayedData:t,xAxis:n,yAxis:r,zAxis:i,scatterSettings:a,xAxisTicks:o,yAxisTicks:s,cells:c}=e,l=QS(n.dataKey)?a.dataKey:n.dataKey,u=QS(r.dataKey)?a.dataKey:r.dataKey,d=i&&i.dataKey,f=i?i.range:xF.range,p=f&&f[0],m=n.scale.bandwidth?n.scale.bandwidth():0,h=r.scale.bandwidth?r.scale.bandwidth():0;return t.map((e,t)=>{var f=RE(e,l),g=RE(e,u),_=!QS(d)&&RE(e,d)||`-`,v=[{name:QS(n.dataKey)?a.name:n.name||String(n.dataKey),unit:n.unit||``,value:f,payload:e,dataKey:l,type:a.tooltipType,graphicalItemId:a.id},{name:QS(r.dataKey)?a.name:r.name||String(r.dataKey),unit:r.unit||``,value:g,payload:e,dataKey:u,type:a.tooltipType,graphicalItemId:a.id}];_!==`-`&&i!=null&&v.push({name:i.name||i.dataKey,unit:i.unit||``,value:_,payload:e,dataKey:d,type:a.tooltipType,graphicalItemId:a.id});var y=UE({axis:n,ticks:o,bandSize:m,entry:e,index:t,dataKey:l}),b=UE({axis:r,ticks:s,bandSize:h,entry:e,index:t,dataKey:u}),x=_!==`-`&&i!=null?i.scale.map(_):p,S=x==null?0:Math.sqrt(Math.max(x,0)/Math.PI);return jW(jW({},e),{},{cx:y,cy:b,x:y==null?void 0:y-S,y:b==null?void 0:b-S,width:2*S,height:2*S,size:x,node:{x:f,y:g,z:_},tooltipPayload:v,tooltipPosition:{x:y,y:b},payload:e},c&&c[t]&&c[t].props)})}var HW=(e,t,n)=>({x:e.cx,y:e.cy,value:Number(n===`x`?e.node.x:e.node.y),errorVal:RE(e,t)});function UW(e){var{hide:t,points:n,className:r,needClip:i,xAxisId:a,yAxisId:o,id:s}=e,c=(0,b.useRef)(null);if(t)return null;var l=Px(`recharts-scatter`,r),u=s;return b.createElement(WL,{zIndex:e.zIndex},b.createElement(Wx,{className:l,clipPath:i?`url(#clipPath-${u})`:void 0,id:s},i&&b.createElement(`defs`,null,b.createElement(jH,{clipPathId:u,xAxisId:a,yAxisId:o})),b.createElement(kH,{xAxisId:a,yAxisId:o,data:n,dataPointFormatter:HW,errorBarOffset:0},b.createElement(Wx,{key:`recharts-scatter-symbols`},b.createElement(BW,{props:e,previousPointsRef:c})))))}var WW={xAxisId:0,yAxisId:0,zAxisId:0,label:!1,line:!1,legendType:`circle`,lineType:`joint`,lineJointType:`linear`,shape:`circle`,hide:!1,isAnimationActive:`auto`,animationBegin:0,animationDuration:400,animationEasing:`linear`,zIndex:PA.scatter};function GW(e){var t=dC(e,WW),{animationBegin:n,animationDuration:r,animationEasing:i,hide:a,isAnimationActive:o,legendType:s,lineJointType:c,lineType:l,shape:u,xAxisId:d,yAxisId:f,zAxisId:p}=t,m=DW(t,EW),{needClip:h}=AH(d,f),g=(0,b.useMemo)(()=>vz(e.children,cR),[e.children]),_=sD(),v=U(t=>CW(t,d,f,p,e.id,g,_));return h==null||v==null?null:b.createElement(b.Fragment,null,b.createElement(IW,{dataKey:e.dataKey,points:v,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,tooltipType:e.tooltipType,id:e.id}),b.createElement(UW,kW({},m,{xAxisId:d,yAxisId:f,zAxisId:p,lineType:l,lineJointType:c,legendType:s,shape:u,hide:a,isAnimationActive:o,animationBegin:n,animationDuration:r,animationEasing:i,points:v,needClip:h})))}function KW(e){var t=dC(e,WW),n=sD();return b.createElement(Pz,{id:t.id,type:`scatter`},e=>b.createElement(b.Fragment,null,b.createElement(Nz,{legendPayload:FW(t)}),b.createElement(Iz,{type:`scatter`,id:e,data:t.data,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:t.zAxisId,dataKey:t.dataKey,hide:t.hide,name:t.name,tooltipType:t.tooltipType,isPanorama:n}),b.createElement(GW,kW({},t,{id:e}))))}var qW=b.memo(KW,SO);qW.displayName=`Scatter`;var JW=[`domain`,`range`],YW=[`domain`,`range`];function XW(e,t){if(e==null)return{};var n,r,i=ZW(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function ZW(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function QW(e,t){return e===t?!0:Array.isArray(e)&&e.length===2&&Array.isArray(t)&&t.length===2?e[0]===t[0]&&e[1]===t[1]:!1}function $W(e,t){if(e===t)return!0;var{domain:n,range:r}=e,i=XW(e,JW),{domain:a,range:o}=t,s=XW(t,YW);return!QW(n,a)||!QW(r,o)?!1:SO(i,s)}var eG=[`type`],tG=[`dangerouslySetInnerHTML`,`ticks`,`scale`],nG=[`id`,`scale`];function rG(){return rG=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},rG.apply(null,arguments)}function iG(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function aG(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?iG(Object(n),!0).forEach(function(t){oG(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):iG(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function oG(e,t,n){return(t=sG(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function sG(e){var t=cG(e,`string`);return typeof t==`symbol`?t:t+``}function cG(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function lG(e,t){if(e==null)return{};var n,r,i=uG(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function uG(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function dG(e){var t=HC(),n=(0,b.useRef)(null),r=DD(),{type:i}=e,a=lG(e,eG),o=RA(r,`xAxis`,i),s=(0,b.useMemo)(()=>{if(o!=null)return aG(aG({},a),{},{type:o})},[a,o]);return(0,b.useLayoutEffect)(()=>{s!=null&&(n.current===null?t(oB(s)):n.current!==s&&t(sB({prev:n.current,next:s})),n.current=s)},[s,t]),(0,b.useLayoutEffect)(()=>()=>{n.current&&=(t(cB(n.current)),null)},[t]),null}var fG=e=>{var{xAxisId:t,className:n}=e,r=U(oD),i=sD(),a=`xAxis`,o=U(e=>jI(e,a,t,i)),s=U(e=>TI(e,t)),c=U(e=>ple(e,t)),l=U(e=>gF(e,t));if(s==null||c==null||l==null)return null;var{dangerouslySetInnerHTML:u,ticks:d,scale:f}=e,p=lG(e,tG),{id:m,scale:h}=l,g=lG(l,nG);return b.createElement(eH,rG({},p,g,{x:c.x,y:c.y,width:s.width,height:s.height,className:Px(`recharts-${a} ${a}`,n),viewBox:r,ticks:o,axisType:a,axisId:t}))},pG={allowDataOverflow:hF.allowDataOverflow,allowDecimals:hF.allowDecimals,allowDuplicatedCategory:hF.allowDuplicatedCategory,angle:hF.angle,axisLine:GV.axisLine,height:hF.height,hide:!1,includeHidden:hF.includeHidden,interval:hF.interval,label:!1,minTickGap:hF.minTickGap,mirror:hF.mirror,orientation:hF.orientation,padding:hF.padding,reversed:hF.reversed,scale:hF.scale,tick:hF.tick,tickCount:hF.tickCount,tickLine:GV.tickLine,tickSize:GV.tickSize,type:hF.type,niceTicks:hF.niceTicks,xAxisId:0},mG=b.memo(e=>{var t=dC(e,pG);return b.createElement(b.Fragment,null,b.createElement(dG,{allowDataOverflow:t.allowDataOverflow,allowDecimals:t.allowDecimals,allowDuplicatedCategory:t.allowDuplicatedCategory,angle:t.angle,dataKey:t.dataKey,domain:t.domain,height:t.height,hide:t.hide,id:t.xAxisId,includeHidden:t.includeHidden,interval:t.interval,minTickGap:t.minTickGap,mirror:t.mirror,name:t.name,orientation:t.orientation,padding:t.padding,reversed:t.reversed,scale:t.scale,tick:t.tick,tickCount:t.tickCount,tickFormatter:t.tickFormatter,ticks:t.ticks,type:t.type,unit:t.unit,niceTicks:t.niceTicks}),b.createElement(fG,t))},$W);mG.displayName=`XAxis`;var hG=[`type`],gG=[`dangerouslySetInnerHTML`,`ticks`,`scale`],_G=[`id`,`scale`];function vG(){return vG=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},vG.apply(null,arguments)}function yG(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function bG(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?yG(Object(n),!0).forEach(function(t){xG(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):yG(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function xG(e,t,n){return(t=SG(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function SG(e){var t=CG(e,`string`);return typeof t==`symbol`?t:t+``}function CG(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function wG(e,t){if(e==null)return{};var n,r,i=TG(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function TG(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function EG(e){var t=HC(),n=(0,b.useRef)(null),r=DD(),{type:i}=e,a=wG(e,hG),o=RA(r,`yAxis`,i),s=(0,b.useMemo)(()=>{if(o!=null)return bG(bG({},a),{},{type:o})},[o,a]);return(0,b.useLayoutEffect)(()=>{s!=null&&(n.current===null?t(lB(s)):n.current!==s&&t(uB({prev:n.current,next:s})),n.current=s)},[s,t]),(0,b.useLayoutEffect)(()=>()=>{n.current&&=(t(dB(n.current)),null)},[t]),null}function DG(e){var{yAxisId:t,className:n,width:r,label:i}=e,a=(0,b.useRef)(null),o=(0,b.useRef)(null),s=U(oD),c=sD(),l=HC(),u=`yAxis`,d=U(e=>EI(e,t)),f=U(e=>mle(e,t)),p=U(e=>jI(e,u,t,c)),m=U(e=>yF(e,t));if((0,b.useLayoutEffect)(()=>{if(!(r!==`auto`||!d||UR(i)||(0,b.isValidElement)(i)||m==null)){var e=a.current;if(e){var n=e.getCalculatedWidth();Math.round(d.width)!==Math.round(n)&&l(hB({id:t,width:n}))}}},[p,d,l,i,t,r,m]),d==null||f==null||m==null)return null;var{dangerouslySetInnerHTML:h,ticks:g,scale:_}=e,v=wG(e,gG),{id:y,scale:x}=m,S=wG(m,_G);return b.createElement(eH,vG({},v,S,{ref:a,labelRef:o,x:f.x,y:f.y,tickTextProps:r===`auto`?{width:void 0}:{width:r},width:d.width,height:d.height,className:Px(`recharts-${u} ${u}`,n),viewBox:s,ticks:p,axisType:u,axisId:t}))}var OG={allowDataOverflow:vF.allowDataOverflow,allowDecimals:vF.allowDecimals,allowDuplicatedCategory:vF.allowDuplicatedCategory,angle:vF.angle,axisLine:GV.axisLine,hide:!1,includeHidden:vF.includeHidden,interval:vF.interval,label:!1,minTickGap:vF.minTickGap,mirror:vF.mirror,orientation:vF.orientation,padding:vF.padding,reversed:vF.reversed,scale:vF.scale,tick:vF.tick,tickCount:vF.tickCount,tickLine:GV.tickLine,tickSize:GV.tickSize,type:vF.type,niceTicks:vF.niceTicks,width:vF.width,yAxisId:0},kG=b.memo(e=>{var t=dC(e,OG);return b.createElement(b.Fragment,null,b.createElement(EG,{interval:t.interval,id:t.yAxisId,scale:t.scale,type:t.type,domain:t.domain,allowDataOverflow:t.allowDataOverflow,dataKey:t.dataKey,allowDuplicatedCategory:t.allowDuplicatedCategory,allowDecimals:t.allowDecimals,tickCount:t.tickCount,padding:t.padding,includeHidden:t.includeHidden,reversed:t.reversed,ticks:t.ticks,width:t.width,orientation:t.orientation,mirror:t.mirror,hide:t.hide,unit:t.unit,name:t.name,angle:t.angle,minTickGap:t.minTickGap,tick:t.tick,tickFormatter:t.tickFormatter,niceTicks:t.niceTicks}),b.createElement(DG,t))},$W);kG.displayName=`YAxis`;function AG(e){var t=HC(),n=(0,b.useRef)(null);return(0,b.useLayoutEffect)(()=>{n.current===null?t(fB(e)):n.current!==e&&t(pB({prev:n.current,next:e})),n.current=e},[e,t]),(0,b.useLayoutEffect)(()=>()=>{n.current&&=(t(mB(n.current)),null)},[t]),null}var jG={zAxisId:0,range:xF.range,scale:xF.scale,type:xF.type};function MG(e){var t=dC(e,jG);return b.createElement(AG,{domain:t.domain,id:t.zAxisId,dataKey:t.dataKey,name:t.name,unit:t.unit,range:t.range,scale:t.scale,type:t.type,allowDuplicatedCategory:xF.allowDuplicatedCategory,allowDataOverflow:xF.allowDataOverflow,reversed:xF.reversed,includeHidden:xF.includeHidden})}MG.displayName=`ZAxis`;var NG=W([(e,t)=>t,TD,ej,lj,pL,hL,due,aD],vue);function PG(e){return`getBBox`in e.currentTarget&&typeof e.currentTarget.getBBox==`function`}function FG(e){var t=e.currentTarget.getBoundingClientRect(),n,r;if(PG(e)){var i=e.currentTarget.getBBox();n=i.width>0?t.width/i.width:1,r=i.height>0?t.height/i.height:1}else{var a=e.currentTarget;n=a.offsetWidth>0?t.width/a.offsetWidth:1,r=a.offsetHeight>0?t.height/a.offsetHeight:1}var o=(e,i)=>({relativeX:Math.round((e-t.left)/n),relativeY:Math.round((i-t.top)/r)});return`touches`in e?Array.from(e.touches).map(e=>o(e.clientX,e.clientY)):o(e.clientX,e.clientY)}var IG=XT(`mouseClick`),LG=AE();LG.startListening({actionCreator:IG,effect:(e,t)=>{var n=e.payload,r=NG(t.getState(),FG(n));r?.activeIndex!=null&&t.dispatch(Tle({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}});var RG=XT(`mouseMove`),zG=AE(),BG=null,VG=null,HG=null;zG.startListening({actionCreator:RG,effect:(e,t)=>{var n=e.payload,{throttleDelay:r,throttledEvents:i}=t.getState().eventSettings,a=i===`all`||i?.includes(`mousemove`);BG!==null&&(cancelAnimationFrame(BG),BG=null),VG!==null&&(typeof r!=`number`||!a)&&(clearTimeout(VG),VG=null),HG=FG(n);var o=()=>{var e=t.getState(),n=LI(e,e.tooltip.settings.shared);if(!HG){BG=null,VG=null;return}if(n===`axis`){var r=NG(e,HG);r?.activeIndex==null?t.dispatch(HI()):t.dispatch(UI({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}BG=null,VG=null};if(!a){o();return}r===`raf`?BG=requestAnimationFrame(o):typeof r==`number`&&VG===null&&(VG=setTimeout(o,r))}});function UG(e,t){return t instanceof HTMLElement?`HTMLElement <${t.tagName} class="${t.className}">`:t===window?`global.window`:e===`children`&&typeof t==`object`&&t?`<<CHILDREN>>`:t}var WG={accessibilityLayer:!0,barCategoryGap:`10%`,barGap:4,barSize:void 0,className:void 0,maxBarSize:void 0,stackOffset:`none`,syncId:void 0,syncMethod:`index`,baseValue:void 0,reverseStackOrder:!1},GG=aE({name:`rootProps`,initialState:WG,reducers:{updateOptions:(e,t)=>{e.accessibilityLayer=t.payload.accessibilityLayer,e.barCategoryGap=t.payload.barCategoryGap,e.barGap=t.payload.barGap??WG.barGap,e.barSize=t.payload.barSize,e.maxBarSize=t.payload.maxBarSize,e.stackOffset=t.payload.stackOffset,e.syncId=t.payload.syncId,e.syncMethod=t.payload.syncMethod,e.className=t.payload.className,e.baseValue=t.payload.baseValue,e.reverseStackOrder=t.payload.reverseStackOrder}}}),KG=GG.reducer,{updateOptions:qG}=GG.actions,JG=aE({name:`polarOptions`,initialState:null,reducers:{updatePolarOptions:(e,t)=>e===null?t.payload:(e.startAngle=t.payload.startAngle,e.endAngle=t.payload.endAngle,e.cx=t.payload.cx,e.cy=t.payload.cy,e.innerRadius=t.payload.innerRadius,e.outerRadius=t.payload.outerRadius,e)}}),{updatePolarOptions:YG}=JG.actions,XG=JG.reducer,ZG=XT(`keyDown`),QG=XT(`focus`),$G=XT(`blur`),eK=AE(),tK=null,nK=null,rK=null;eK.startListening({actionCreator:ZG,effect:(e,t)=>{rK=e.payload,tK!==null&&(cancelAnimationFrame(tK),tK=null);var{throttleDelay:n,throttledEvents:r}=t.getState().eventSettings,i=r===`all`||r.includes(`keydown`);nK!==null&&(typeof n!=`number`||!i)&&(clearTimeout(nK),nK=null);var a=()=>{try{var e=t.getState();if(e.rootProps.accessibilityLayer===!1)return;var{keyboardInteraction:n}=e.tooltip,r=rK;if(r!==`ArrowRight`&&r!==`ArrowLeft`&&r!==`Enter`)return;var i=YI(n,sL(e),WF(e),dL(e)),a=i==null?-1:Number(i),o=!Number.isFinite(a)||a<0,s=hL(e),c=sL(e),l=LI(e,e.tooltip.settings.shared);if(r===`Enter`){if(o)return;var u=LL(e,l,`hover`,String(n.index));t.dispatch(GI({active:!n.active,activeIndex:n.index,activeCoordinate:u}));return}var d=gle(e)===`left-to-right`?1:-1,f=r===`ArrowRight`?1:-1,p;if(o){var m=WF(e),h=dL(e),g=f*d,_=e=>({active:!1,index:String(e),dataKey:void 0,graphicalItemId:void 0,coordinate:void 0});if(p=-1,g>0){for(var v=0;v<c.length;v++)if(YI(_(v),c,m,h)!=null){p=v;break}}else for(var y=c.length-1;y>=0;y--)if(YI(_(y),c,m,h)!=null){p=y;break}if(p<0)return}else{p=a+f*d;var b=s?.length||c.length;if(b===0||p>=b||p<0)return}var x=LL(e,l,`hover`,String(p));t.dispatch(GI({active:!0,activeIndex:p.toString(),activeCoordinate:x}))}finally{tK=null,nK=null}};if(!i){a();return}n===`raf`?tK=requestAnimationFrame(a):typeof n==`number`&&nK===null&&(a(),rK=null,nK=setTimeout(()=>{rK?a():(nK=null,tK=null)},n))}}),eK.startListening({actionCreator:QG,effect:(e,t)=>{var n=t.getState();if(n.rootProps.accessibilityLayer!==!1){var{keyboardInteraction:r}=n.tooltip;if(!r.active&&r.index==null){var i=`0`,a=LL(n,LI(n,n.tooltip.settings.shared),`hover`,String(i));t.dispatch(GI({active:!0,activeIndex:i,activeCoordinate:a}))}}}}),eK.startListening({actionCreator:$G,effect:(e,t)=>{var n=t.getState();if(n.rootProps.accessibilityLayer!==!1){var{keyboardInteraction:r}=n.tooltip;r.active&&t.dispatch(GI({active:!1,activeIndex:r.index,activeCoordinate:r.coordinate}))}}});function iK(e){e.persist();var{currentTarget:t}=e;return new Proxy(e,{get:(e,n)=>{if(n===`currentTarget`)return t;var r=Reflect.get(e,n);return typeof r==`function`?r.bind(e):r}})}var aK=XT(`externalEvent`),oK=AE(),sK=new Map,cK=new Map,lK=new Map;oK.startListening({actionCreator:aK,effect:(e,t)=>{var{handler:n,reactEvent:r}=e.payload;if(n!=null){var i=r.type,a=iK(r);lK.set(i,{handler:n,reactEvent:a});var o=sK.get(i);o!==void 0&&(cancelAnimationFrame(o),sK.delete(i));var{throttleDelay:s,throttledEvents:c}=t.getState().eventSettings,l=c,u=l===`all`||l?.includes(i),d=cK.get(i);d!==void 0&&(typeof s!=`number`||!u)&&(clearTimeout(d),cK.delete(i));var f=()=>{var e=lK.get(i);try{if(!e)return;var{handler:n,reactEvent:r}=e,a=t.getState(),o={activeCoordinate:Zle(a),activeDataKey:SL(a),activeIndex:bL(a),activeLabel:xL(a),activeTooltipIndex:bL(a),isTooltipActive:Qle(a)};n&&n(o,r)}finally{sK.delete(i),cK.delete(i),lK.delete(i)}};if(!u){f();return}if(s===`raf`){var p=requestAnimationFrame(f);sK.set(i,p)}else if(typeof s==`number`){if(!cK.has(i)){f();var m=setTimeout(f,s);cK.set(i,m)}}else f()}}});var uK=W([W([$I],e=>e.tooltipItemPayloads),(e,t)=>t,(e,t,n)=>n],(e,t,n)=>{if(t!=null){var r=e.find(e=>e.settings.graphicalItemId===n);if(r!=null){var{getPosition:i}=r;if(i!=null)return i(t)}}}),dK=XT(`touchMove`),fK=AE(),pK=null,mK=null,hK=null,gK=null;fK.startListening({actionCreator:dK,effect:(e,t)=>{var n=e.payload;if(!(n.touches==null||n.touches.length===0)){gK=iK(n);var{throttleDelay:r,throttledEvents:i}=t.getState().eventSettings,a=i===`all`||i.includes(`touchmove`);pK!==null&&(cancelAnimationFrame(pK),pK=null),mK!==null&&(typeof r!=`number`||!a)&&(clearTimeout(mK),mK=null),hK=Array.from(n.touches).map(e=>FG({clientX:e.clientX,clientY:e.clientY,currentTarget:n.currentTarget}));var o=()=>{if(gK!=null){var e=t.getState(),n=LI(e,e.tooltip.settings.shared);if(n===`axis`){var r=hK?.[0];if(r==null){pK=null,mK=null;return}var i=NG(e,r);i?.activeIndex!=null&&t.dispatch(UI({activeIndex:i.activeIndex,activeDataKey:void 0,activeCoordinate:i.activeCoordinate}))}else if(n===`item`){var a=gK.touches[0];if(document.elementFromPoint==null||a==null)return;var o=document.elementFromPoint(a.clientX,a.clientY);if(!o||!o.getAttribute)return;var s=o.getAttribute(tD),c=o.getAttribute(`data-recharts-item-id`)??void 0,l=aL(e).find(e=>e.id===c);if(s==null||l==null||c==null)return;var{dataKey:u}=l,d=uK(e,s,c);t.dispatch(VI({activeDataKey:u,activeIndex:s,activeCoordinate:d,activeGraphicalItemId:c}))}pK=null,mK=null}};if(!a){o();return}r===`raf`?pK=requestAnimationFrame(o):typeof r==`number`&&mK===null&&(o(),gK=null,mK=setTimeout(()=>{gK?o():(mK=null,pK=null)},r))}}});var _K={throttleDelay:`raf`,throttledEvents:[`mousemove`,`touchmove`,`pointermove`,`scroll`,`wheel`]},vK=aE({name:`eventSettings`,initialState:_K,reducers:{setEventSettings:(e,t)=>{t.payload.throttleDelay!=null&&(e.throttleDelay=t.payload.throttleDelay),t.payload.throttledEvents!=null&&(e.throttledEvents=hO(t.payload.throttledEvents))}}}),{setEventSettings:yK}=vK.actions,bK=vK.reducer,xK=Tw({brush:HB,cartesianAxis:gB,chartData:Wue,errorBars:wH,eventSettings:bK,graphicalItems:tpe,layout:iie,legend:oae,options:zue,polarAxis:mfe,polarOptions:XG,referenceElements:XB,renderedTicks:FV,rootProps:KG,tooltip:Ele,zIndex:Aue}),SK=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:`Chart`;return Are({reducer:xK,preloadedState:e,middleware:e=>e({serializableCheck:!1,immutableCheck:![`commonjs`,`es6`,`production`].includes(`es6`)}).concat([LG.middleware,zG.middleware,eK.middleware,oK.middleware,fK.middleware]),enhancers:e=>{var t=e;return typeof e==`function`&&(t=e()),t.concat(rE({type:`raf`}))},devTools:kO.devToolsEnabled&&{serialize:{replacer:UG},name:`recharts-${t}`}})};function CK(e){var{preloadedState:t,children:n,reduxStoreName:r}=e,i=sD(),a=(0,b.useRef)(null);if(i)return n;a.current??=SK(t,r);var o=zC;return b.createElement(bae,{context:o,store:a.current},n)}function wK(e){var{layout:t,margin:n}=e,r=HC(),i=sD();return(0,b.useEffect)(()=>{i||(r(tie(t)),r(eie(n)))},[r,i,t,n]),null}var TK=(0,b.memo)(wK,SO);function EK(e){var t=HC();return(0,b.useEffect)(()=>{t(qG(e))},[t,e]),null}var DK=(0,b.memo)(e=>{var t=HC();return(0,b.useEffect)(()=>{t(yK(e))},[t,e]),null},SO);function OK(e){var{zIndex:t,isPanorama:n}=e,r=(0,b.useRef)(null),i=HC();return(0,b.useLayoutEffect)(()=>(r.current&&i(Oue({zIndex:t,element:r.current,isPanorama:n})),()=>{i(kue({zIndex:t,isPanorama:n}))}),[i,t,n]),b.createElement(`g`,{tabIndex:-1,ref:r,className:`recharts-zIndex-layer_${t}`})}function kK(e){var{children:t,isPanorama:n}=e,r=U(bue);if(!r||r.length===0)return t;var i=r.filter(e=>e<0),a=r.filter(e=>e>0);return b.createElement(b.Fragment,null,i.map(e=>b.createElement(OK,{key:e,zIndex:e,isPanorama:n})),t,a.map(e=>b.createElement(OK,{key:e,zIndex:e,isPanorama:n})))}var AK=[`children`];function jK(e,t){if(e==null)return{};var n,r,i=MK(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function MK(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function NK(){return NK=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},NK.apply(null,arguments)}var PK={width:`100%`,height:`100%`,display:`block`},FK=(0,b.forwardRef)((e,t)=>{var n=CD(),r=wD(),i=NO();if(!FE(n)||!FE(r))return null;var{children:a,otherAttributes:o,title:s,desc:c}=e,l,u;return o!=null&&(l=typeof o.tabIndex==`number`?o.tabIndex:i?0:void 0,u=typeof o.role==`string`?o.role:i?`application`:void 0),b.createElement(Hx,NK({},o,{title:s,desc:c,role:u,tabIndex:l,width:n,height:r,style:PK,ref:t}),a)}),IK=e=>{var{children:t}=e,n=U(lD);if(!n)return null;var{width:r,height:i,y:a,x:o}=n;return b.createElement(Hx,{width:r,height:i,x:o,y:a},t)},LK=(0,b.forwardRef)((e,t)=>{var{children:n}=e,r=jK(e,AK);return sD()?b.createElement(IK,null,b.createElement(kK,{isPanorama:!0},n)):b.createElement(FK,NK({ref:t},r),b.createElement(kK,{isPanorama:!1},n))});function RK(){var e=HC(),[t,n]=(0,b.useState)(null),r=U(vie);return(0,b.useEffect)(()=>{if(t!=null){var n=t.getBoundingClientRect().width/t.offsetWidth;PE(n)&&n!==r&&e(rie(n))}},[t,e,r]),n}function zK(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function BK(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?zK(Object(n),!0).forEach(function(t){VK(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):zK(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function VK(e,t,n){return(t=HK(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function HK(e){var t=UK(e,`string`);return typeof t==`symbol`?t:t+``}function UK(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function WK(){return WK=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},WK.apply(null,arguments)}var GK=()=>($ue(),null);function KK(e){if(typeof e==`number`)return e;if(typeof e==`string`){var t=parseFloat(e);if(!Number.isNaN(t))return t}return 0}var qK=(0,b.forwardRef)((e,t)=>{var n=(0,b.useRef)(null),[r,i]=(0,b.useState)({containerWidth:KK(e.style?.width),containerHeight:KK(e.style?.height)}),a=(0,b.useCallback)((e,t)=>{i(n=>{var r=Math.round(e),i=Math.round(t);return n.containerWidth===r&&n.containerHeight===i?n:{containerWidth:r,containerHeight:i}})},[]),o=(0,b.useCallback)(e=>{if(typeof t==`function`&&t(e),n.current!=null&&(n.current.disconnect(),n.current=null),e!=null&&typeof ResizeObserver<`u`){var{width:r,height:i}=e.getBoundingClientRect();a(r,i);var o=new ResizeObserver(e=>{var t=e[0];if(t!=null){var{width:n,height:r}=t.contentRect;a(n,r)}});o.observe(e),n.current=o}},[t,a]);return(0,b.useEffect)(()=>()=>{n.current?.disconnect()},[a]),b.createElement(b.Fragment,null,b.createElement(kD,{width:r.containerWidth,height:r.containerHeight}),b.createElement(`div`,WK({ref:o},e)))}),JK=(0,b.forwardRef)((e,t)=>{var{width:n,height:r}=e,[i,a]=(0,b.useState)({containerWidth:KK(n),containerHeight:KK(r)}),o=(0,b.useCallback)((e,t)=>{a(n=>{var r=Math.round(e),i=Math.round(t);return n.containerWidth===r&&n.containerHeight===i?n:{containerWidth:r,containerHeight:i}})},[]),s=(0,b.useCallback)(e=>{if(typeof t==`function`&&t(e),e!=null){var{width:n,height:r}=e.getBoundingClientRect();o(n,r)}},[t,o]);return b.createElement(b.Fragment,null,b.createElement(kD,{width:i.containerWidth,height:i.containerHeight}),b.createElement(`div`,WK({ref:s},e)))}),YK=(0,b.forwardRef)((e,t)=>{var{width:n,height:r}=e;return b.createElement(b.Fragment,null,b.createElement(kD,{width:n,height:r}),b.createElement(`div`,WK({ref:t},e)))}),XK=(0,b.forwardRef)((e,t)=>{var{width:n,height:r}=e;return typeof n==`string`||typeof r==`string`?b.createElement(JK,WK({},e,{ref:t})):typeof n==`number`&&typeof r==`number`?b.createElement(YK,WK({},e,{width:n,height:r,ref:t})):b.createElement(b.Fragment,null,b.createElement(kD,{width:n,height:r}),b.createElement(`div`,WK({ref:t},e)))});function ZK(e){return e?qK:XK}var QK=(0,b.forwardRef)((e,t)=>{var{children:n,className:r,height:i,onClick:a,onContextMenu:o,onDoubleClick:s,onMouseDown:c,onMouseEnter:l,onMouseLeave:u,onMouseMove:d,onMouseUp:f,onTouchEnd:p,onTouchMove:m,onTouchStart:h,style:g,width:_,responsive:v,dispatchTouchEvents:y=!0}=e,x=(0,b.useRef)(null),S=HC(),[C,w]=(0,b.useState)(null),[T,E]=(0,b.useState)(null),D=RK(),O=vD(),k=O?.width>0?O.width:_,ee=O?.height>0?O.height:i,te=(0,b.useCallback)(e=>{D(e),typeof t==`function`&&t(e),w(e),E(e),e!=null&&(x.current=e)},[D,t,w,E]),ne=(0,b.useCallback)(e=>{S(IG(e)),S(aK({handler:a,reactEvent:e}))},[S,a]),re=(0,b.useCallback)(e=>{S(RG(e)),S(aK({handler:l,reactEvent:e}))},[S,l]),A=(0,b.useCallback)(e=>{S(HI()),S(aK({handler:u,reactEvent:e}))},[S,u]),ie=(0,b.useCallback)(e=>{S(RG(e)),S(aK({handler:d,reactEvent:e}))},[S,d]),j=(0,b.useCallback)(()=>{S(QG())},[S]),M=(0,b.useCallback)(()=>{S($G())},[S]),ae=(0,b.useCallback)(e=>{S(ZG(e.key))},[S]),oe=(0,b.useCallback)(e=>{S(aK({handler:o,reactEvent:e}))},[S,o]),se=(0,b.useCallback)(e=>{S(aK({handler:s,reactEvent:e}))},[S,s]),N=(0,b.useCallback)(e=>{S(aK({handler:c,reactEvent:e}))},[S,c]),ce=(0,b.useCallback)(e=>{S(aK({handler:f,reactEvent:e}))},[S,f]),le=(0,b.useCallback)(e=>{S(aK({handler:h,reactEvent:e}))},[S,h]),ue=(0,b.useCallback)(e=>{y&&S(dK(e)),S(aK({handler:m,reactEvent:e}))},[S,y,m]),de=(0,b.useCallback)(e=>{S(aK({handler:p,reactEvent:e}))},[S,p]),fe=ZK(v);return b.createElement(JL.Provider,{value:C},b.createElement(dne.Provider,{value:T},b.createElement(fe,{width:k??g?.width,height:ee??g?.height,className:Px(`recharts-wrapper`,r),style:BK({position:`relative`,cursor:`default`,width:k,height:ee},g),onClick:ne,onContextMenu:oe,onDoubleClick:se,onFocus:j,onBlur:M,onKeyDown:ae,onMouseDown:N,onMouseEnter:re,onMouseLeave:A,onMouseMove:ie,onMouseUp:ce,onTouchEnd:de,onTouchMove:ue,onTouchStart:le,ref:te},b.createElement(GK,null),n)))}),$K=[`width`,`height`,`responsive`,`children`,`className`,`style`,`compact`,`title`,`desc`];function eq(e,t){if(e==null)return{};var n,r,i=tq(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function tq(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var nq=(0,b.forwardRef)((e,t)=>{var{width:n,height:r,responsive:i,children:a,className:o,style:s,compact:c,title:l,desc:u}=e,d=Rx(eq(e,$K));return c?b.createElement(b.Fragment,null,b.createElement(kD,{width:n,height:r}),b.createElement(LK,{otherAttributes:d,title:l,desc:u},a)):b.createElement(QK,{className:o,style:s,width:n,height:r,responsive:i??!1,onClick:e.onClick,onMouseLeave:e.onMouseLeave,onMouseEnter:e.onMouseEnter,onMouseMove:e.onMouseMove,onMouseDown:e.onMouseDown,onMouseUp:e.onMouseUp,onContextMenu:e.onContextMenu,onDoubleClick:e.onDoubleClick,onTouchStart:e.onTouchStart,onTouchMove:e.onTouchMove,onTouchEnd:e.onTouchEnd},b.createElement(LK,{otherAttributes:d,title:l,desc:u,ref:t},b.createElement(QB,null,a)))});function rq(){return rq=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},rq.apply(null,arguments)}function iq(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function aq(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?iq(Object(n),!0).forEach(function(t){oq(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):iq(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function oq(e,t,n){return(t=sq(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function sq(e){var t=cq(e,`string`);return typeof t==`symbol`?t:t+``}function cq(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var lq=aq({accessibilityLayer:!0,barCategoryGap:`10%`,barGap:4,layout:`horizontal`,margin:{top:5,right:5,bottom:5,left:5},responsive:!1,reverseStackOrder:!1,stackOffset:`none`,syncMethod:`index`},_K),uq=(0,b.forwardRef)(function(e,t){var n=dC(e.categoricalChartProps,lq),{chartName:r,defaultTooltipEventType:i,validateTooltipEventTypes:a,tooltipPayloadSearcher:o,categoricalChartProps:s}=e,c={chartName:r,defaultTooltipEventType:i,validateTooltipEventTypes:a,tooltipPayloadSearcher:o,eventEmitter:void 0};return b.createElement(CK,{preloadedState:{options:c},reduxStoreName:s.id??r},b.createElement(zB,{chartData:s.data}),b.createElement(TK,{layout:n.layout,margin:n.margin}),b.createElement(DK,{throttleDelay:n.throttleDelay,throttledEvents:n.throttledEvents}),b.createElement(EK,{baseValue:n.baseValue,accessibilityLayer:n.accessibilityLayer,barCategoryGap:n.barCategoryGap,maxBarSize:n.maxBarSize,stackOffset:n.stackOffset,barGap:n.barGap,barSize:n.barSize,syncId:n.syncId,syncMethod:n.syncMethod,className:n.className,reverseStackOrder:n.reverseStackOrder}),b.createElement(nq,rq({},n,{ref:t})))}),dq=[`axis`,`item`],fq=(0,b.forwardRef)((e,t)=>b.createElement(uq,{chartName:`BarChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:dq,tooltipPayloadSearcher:QL,categoricalChartProps:e,ref:t}));function pq(e){var t=HC();return(0,b.useEffect)(()=>{t(YG(e))},[t,e]),null}var mq=[`layout`];function hq(){return hq=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},hq.apply(null,arguments)}function gq(e,t){if(e==null)return{};var n,r,i=_q(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function _q(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function vq(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function yq(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?vq(Object(n),!0).forEach(function(t){bq(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):vq(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function bq(e,t,n){return(t=xq(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function xq(e){var t=Sq(e,`string`);return typeof t==`symbol`?t:t+``}function Sq(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var Cq=yq({accessibilityLayer:!0,stackOffset:`none`,barCategoryGap:`10%`,barGap:4,margin:{top:5,right:5,bottom:5,left:5},reverseStackOrder:!1,syncMethod:`index`,layout:`radial`,responsive:!1,cx:`50%`,cy:`50%`,innerRadius:0,outerRadius:`80%`},_K),wq=(0,b.forwardRef)(function(e,t){var n=dC(e.categoricalChartProps,Cq),{layout:r}=n,i=gq(n,mq),{chartName:a,defaultTooltipEventType:o,validateTooltipEventTypes:s,tooltipPayloadSearcher:c}=e,l={chartName:a,defaultTooltipEventType:o,validateTooltipEventTypes:s,tooltipPayloadSearcher:c,eventEmitter:void 0};return b.createElement(CK,{preloadedState:{options:l},reduxStoreName:n.id??a},b.createElement(zB,{chartData:n.data}),b.createElement(TK,{layout:r,margin:n.margin}),b.createElement(DK,{throttleDelay:n.throttleDelay,throttledEvents:n.throttledEvents}),b.createElement(EK,{baseValue:void 0,accessibilityLayer:n.accessibilityLayer,barCategoryGap:n.barCategoryGap,maxBarSize:n.maxBarSize,stackOffset:n.stackOffset,barGap:n.barGap,barSize:n.barSize,syncId:n.syncId,syncMethod:n.syncMethod,className:n.className,reverseStackOrder:n.reverseStackOrder}),b.createElement(pq,{cx:n.cx,cy:n.cy,startAngle:n.startAngle,endAngle:n.endAngle,innerRadius:n.innerRadius,outerRadius:n.outerRadius}),b.createElement(nq,hq({},i,{ref:t})))});function Tq(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Eq(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Tq(Object(n),!0).forEach(function(t){Dq(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Tq(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Dq(e,t,n){return(t=Oq(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Oq(e){var t=kq(e,`string`);return typeof t==`symbol`?t:t+``}function kq(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var Aq=[`item`],jq=Eq(Eq({},Cq),{},{layout:`centric`,startAngle:0,endAngle:360}),Mq=(0,b.forwardRef)((e,t)=>{var n=dC(e,jq);return b.createElement(wq,{chartName:`PieChart`,defaultTooltipEventType:`item`,validateTooltipEventTypes:Aq,tooltipPayloadSearcher:QL,categoricalChartProps:n,ref:t})}),Nq=[`item`],Pq=(0,b.forwardRef)((e,t)=>b.createElement(uq,{chartName:`ScatterChart`,defaultTooltipEventType:`item`,validateTooltipEventTypes:Nq,tooltipPayloadSearcher:QL,categoricalChartProps:e,ref:t})),Fq=[`axis`],Iq=(0,b.forwardRef)((e,t)=>b.createElement(uq,{chartName:`AreaChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:Fq,tooltipPayloadSearcher:QL,categoricalChartProps:e,ref:t})),Lq=[`axis`],Rq=(0,b.forwardRef)((e,t)=>b.createElement(uq,{chartName:`ComposedChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:Lq,tooltipPayloadSearcher:QL,categoricalChartProps:e,ref:t})),zq={ttft:{label:`TTFT`,color:`#0891b2`,fill:`rgba(8,145,178,0.08)`,unit:`ms`},total:{label:`Total Time`,color:`#dc2626`,fill:`rgba(220,38,38,0.06)`,unit:`ms`},tps:{label:`Speed`,color:`#059669`,fill:`rgba(5,150,105,0.08)`,unit:`t/s`}};function Bq({active:e,payload:t,metric:n}){if(!e||!t?.length)return null;let r=t[0].payload,i=zq[n],a=n===`tps`,o=r.avgTps>0?r.avgWallTps/r.avgTps*100:0;return(0,F.jsxs)(`div`,{className:`glass-panel rounded-2xl px-4 py-3 text-sm`,style:{minWidth:240},children:[(0,F.jsx)(`p`,{className:`text-[11px] font-semibold uppercase tracking-wider text-zinc-400 dark:text-zinc-400 mb-1`,children:String(r.label)}),(0,F.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,F.jsx)(`span`,{className:`metric-mono text-lg font-bold text-zinc-800 dark:text-zinc-300`,children:String(r[n])}),(0,F.jsxs)(`span`,{className:`text-xs text-zinc-400 dark:text-zinc-400`,children:[i.unit,` `,a?`· Active TPS`:``]})]}),a&&(0,F.jsxs)(`div`,{className:`mt-2 space-y-1`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between text-[11px]`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Active`}),(0,F.jsxs)(`span`,{className:`metric-mono font-semibold text-moss`,children:[String(r.avgTps),` tok/s`]})]}),(0,F.jsxs)(`div`,{className:`flex items-center justify-between text-[11px]`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Wall`}),(0,F.jsxs)(`span`,{className:`metric-mono font-semibold text-zinc-500 dark:text-zinc-400`,children:[String(r.tpsWall),` tok/s`]})]}),(0,F.jsxs)(`div`,{className:`flex items-center justify-between text-[11px]`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Loss`}),(0,F.jsxs)(`span`,{className:`metric-mono font-semibold ${r.tpsLoss>50?`text-ember`:r.tpsLoss>20?`text-amber`:`text-zinc-500 dark:text-zinc-400`}`,children:[r.tpsLoss.toFixed(1),`%`]})]}),(0,F.jsxs)(`div`,{className:`h-1.5 rounded-full overflow-hidden flex bg-zinc-100 dark:bg-white/[0.06]`,children:[(0,F.jsx)(`div`,{className:`h-full bg-moss`,style:{width:`${Math.max(0,Math.min(100,o))}%`}}),(0,F.jsx)(`div`,{className:`h-full bg-ember`,style:{width:`${Math.max(0,Math.min(100,100-o))}%`}})]})]}),(0,F.jsxs)(`div`,{className:`pt-1.5 border-t border-zinc-200/50 dark:border-white/[0.06] grid grid-cols-3 gap-3 text-[11px] mt-1.5`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Calls`}),(0,F.jsx)(`p`,{className:`metric-mono font-semibold text-zinc-700 dark:text-zinc-300`,children:String(r.count)})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Tokens`}),(0,F.jsxs)(`p`,{className:`metric-mono font-semibold text-zinc-700 dark:text-zinc-300`,children:[(r.totalTokens/1e3).toFixed(1),`k`]})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Avg TPS`}),(0,F.jsx)(`p`,{className:`metric-mono font-semibold text-zinc-700 dark:text-zinc-300`,children:String(r.avgTps)})]})]})]})}function Vq({buckets:e}){let[t,n]=(0,b.useState)(`ttft`),r=(0,b.useMemo)(()=>e.map(e=>({...e,ttft:e.avgTtft,total:e.avgTotal,tps:e.avgTps,tpsWall:e.avgWallTps,tpsLoss:e.avgTpsLoss})),[e]),i=zq[t];return(0,F.jsxs)(Pu.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.2},className:`card-surface p-6`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between mb-6`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight text-zinc-800 dark:text-zinc-300`,children:`Conversation Timeline`}),(0,F.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-400 mt-0.5`,children:`Performance patterns across the session`})]}),(0,F.jsx)(`div`,{className:`flex items-center gap-1.5 bg-zinc-100/80 dark:bg-white/[0.06] rounded-xl p-1`,children:[`ttft`,`total`,`tps`].map(e=>(0,F.jsx)(`button`,{onClick:()=>n(e),className:`px-3 py-1.5 text-xs font-medium rounded-lg transition-all ${t===e?`bg-white dark:bg-zinc-600 text-zinc-800 dark:text-zinc-300 shadow-sm`:`text-zinc-400 dark:text-zinc-400 hover:text-zinc-600 dark:hover:text-zinc-200`}`,children:zq[e].label},e))})]}),(0,F.jsx)(`div`,{className:`h-64`,children:(0,F.jsx)(yD,{width:`100%`,height:`100%`,children:(0,F.jsxs)(Iq,{data:r,margin:{top:5,right:5,left:0,bottom:0},children:[(0,F.jsx)(`defs`,{children:(0,F.jsxs)(`linearGradient`,{id:`fill-${t}`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,F.jsx)(`stop`,{offset:`5%`,stopColor:i.color,stopOpacity:.15}),(0,F.jsx)(`stop`,{offset:`95%`,stopColor:i.color,stopOpacity:0})]})}),(0,F.jsx)(SH,{strokeDasharray:`3 3`,stroke:`var(--border)`,className:`dark:opacity-40`,vertical:!1}),(0,F.jsx)(mG,{dataKey:`label`,tick:{fontSize:11,fill:`var(--text-tertiary)`},axisLine:!1,tickLine:!1,dy:8}),(0,F.jsx)(kG,{tick:{fontSize:11,fill:`var(--text-tertiary)`},axisLine:!1,tickLine:!1,dx:-4,tickFormatter:e=>e>=1e3?`${(e/1e3).toFixed(1)}k`:`${e}`}),(0,F.jsx)(sR,{content:(0,F.jsx)(Bq,{metric:t})}),(0,F.jsx)(_U,{type:`monotone`,dataKey:t,stroke:i.color,strokeWidth:2,fill:`url(#fill-${t})`,animationDuration:400})]})})})]})}var Hq=(0,b.memo)(Vq);function Uq({active:e,payload:t}){if(!e||!t?.length)return null;let n=t[0].payload,r=Number(n.effectiveTps??n.tps),i=Number(n.wallTps),a=r>0?(r-i)/r*100:0,o=r>0?i/r*100:0;return(0,F.jsxs)(`div`,{className:`glass-panel rounded-2xl px-4 py-3 text-sm`,style:{minWidth:220},children:[(0,F.jsxs)(`p`,{className:`text-[11px] font-semibold uppercase tracking-wider text-zinc-400 dark:text-zinc-400 mb-2`,children:[`Request #`,Number(n.index)+1]}),(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsxs)(`div`,{className:`flex justify-between gap-2 text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Total tokens`}),(0,F.jsx)(`span`,{className:`metric-mono font-semibold text-zinc-700 dark:text-zinc-300`,children:Number(n.tokensTotal).toLocaleString()})]}),(0,F.jsxs)(`div`,{className:`flex justify-between gap-2 text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`TTFT`}),(0,F.jsx)(`span`,{className:`metric-mono font-semibold text-zinc-700 dark:text-zinc-300`,children:Jf(Number(n.ttftMs??n.y))})]}),(0,F.jsxs)(`div`,{className:`flex justify-between gap-2 text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Cache hit`}),(0,F.jsxs)(`span`,{className:`metric-mono font-semibold text-zinc-700 dark:text-zinc-300`,children:[(Number(n.cacheRatio)*100).toFixed(0),`%`]})]}),(0,F.jsxs)(`div`,{className:`flex justify-between gap-2 text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`New input`}),(0,F.jsx)(`span`,{className:`metric-mono font-semibold text-zinc-700 dark:text-zinc-300`,children:Number(n.input).toLocaleString()})]})]}),(0,F.jsxs)(`div`,{className:`mt-2 pt-2 border-t border-zinc-200/50 dark:border-white/[0.06]`,children:[(0,F.jsx)(`p`,{className:`text-[10px] font-semibold uppercase tracking-wider text-zinc-400 dark:text-zinc-400 mb-1.5`,children:`Speed`}),(0,F.jsxs)(`div`,{className:`space-y-1`,children:[(0,F.jsxs)(`div`,{className:`flex justify-between text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Active`}),(0,F.jsxs)(`span`,{className:`metric-mono font-semibold text-moss`,children:[r.toFixed(1),` tok/s`]})]}),(0,F.jsxs)(`div`,{className:`flex justify-between text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Wall`}),(0,F.jsxs)(`span`,{className:`metric-mono font-semibold text-accent`,children:[i.toFixed(1),` tok/s`]})]}),(0,F.jsxs)(`div`,{className:`flex justify-between text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Loss`}),(0,F.jsxs)(`span`,{className:`metric-mono font-semibold ${a>50?`text-ember`:a>20?`text-amber`:`text-zinc-500 dark:text-zinc-400`}`,children:[a.toFixed(1),`%`]})]}),(0,F.jsxs)(`div`,{className:`h-1.5 rounded-full overflow-hidden flex bg-zinc-100 dark:bg-white/[0.06]`,children:[(0,F.jsx)(`div`,{className:`h-full bg-moss`,style:{width:`${Math.max(0,Math.min(100,o))}%`}}),(0,F.jsx)(`div`,{className:`h-full bg-ember`,style:{width:`${Math.max(0,Math.min(100,100-o))}%`}})]})]})]}),Number(n.stallCount)>0&&(0,F.jsx)(`div`,{className:`mt-1.5 pt-1.5 border-t border-zinc-200/50 dark:border-white/[0.06]`,children:(0,F.jsxs)(`div`,{className:`flex justify-between text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-ember`,children:`Stalls`}),(0,F.jsxs)(`span`,{className:`metric-mono font-semibold text-ember`,children:[String(n.stallCount),` · `,Jf(Number(n.stallMs))]})]})})]})}function Wq({data:e,onPointClick:t,thresholds:n}){let[r,i]=(0,b.useState)(`log`),{cacheThreshold:a,lowContext:o}=n,s=(0,b.useMemo)(()=>e.map((e,t)=>({x:e.tokensTotal,y:e.ttftMs,z:e.totalMs,cacheRatio:e.cacheRatio,newRatio:e.newRatio,category:e.category,index:t,id:e.id,input:e.input,output:e.output,cacheRead:e.cacheRead,tps:e.effectiveTps,wallTps:e.wallTps,stallCount:e.stallCount,stallMs:e.stallMs,effectiveTps:e.effectiveTps,ttftMs:e.ttftMs,tokensTotal:e.tokensTotal})),[e]),c={fast:`#059669`,normal:`#0891b2`,slow:`#dc2626`,anomaly:`#d97706`},l=(0,b.useMemo)(()=>{if(s.length<=100)return s;let e=s.length/100;return s.filter((t,n)=>Math.floor(n/e)!==Math.floor((n+1)/e))},[s]),u=(0,b.useMemo)(()=>{let e=s.map(e=>e.x),t=Math.min(...e),n=Math.max(...e);return r===`log`?[Math.max(1,t*.8),n*1.1]:[0,n*1.05]},[s,r]),d=(0,b.useMemo)(()=>{let e=s.map(e=>e.y),t=Math.min(...e),n=Math.max(...e);return r===`log`?[Math.max(100,t*.8),n*1.1]:[0,n*1.05]},[s,r]);return(0,F.jsxs)(Pu.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.2},className:`card-surface p-6`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between mb-6`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight text-zinc-800 dark:text-zinc-300`,children:`TTFT vs Context Size`}),(0,F.jsxs)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-400 mt-0.5`,children:[`Color indicates cache efficiency category derived from data.`,s.length>100?` Showing ${l.length} of ${s.length} points.`:``]})]}),(0,F.jsx)(`div`,{className:`flex items-center gap-1.5 bg-zinc-100/80 dark:bg-white/[0.06] rounded-xl p-1`,children:[`log`,`linear`].map(e=>(0,F.jsx)(`button`,{onClick:()=>i(e),className:`px-3 py-1.5 text-xs font-medium rounded-lg transition-all ${r===e?`bg-white dark:bg-zinc-600 text-zinc-800 dark:text-zinc-300 shadow-sm`:`text-zinc-400 dark:text-zinc-400 hover:text-zinc-600 dark:hover:text-zinc-200`}`,children:e===`log`?`Log Scale`:`Linear`},e))})]}),(0,F.jsx)(`div`,{className:`h-72`,children:(0,F.jsx)(yD,{width:`100%`,height:`100%`,children:(0,F.jsxs)(Pq,{margin:{top:5,right:5,left:0,bottom:0},children:[(0,F.jsx)(SH,{strokeDasharray:`3 3`,stroke:`var(--border)`,className:`dark:opacity-40`}),(0,F.jsx)(mG,{type:`number`,dataKey:`x`,name:`Total Tokens`,scale:r,domain:u,tick:{fontSize:11,fill:`var(--text-tertiary)`},axisLine:!1,tickLine:!1,dy:8,tickFormatter:e=>e>=1e3?`${(e/1e3).toFixed(0)}k`:`${e}`}),(0,F.jsx)(kG,{type:`number`,dataKey:`y`,name:`TTFT (ms)`,scale:r,domain:d,tick:{fontSize:11,fill:`var(--text-tertiary)`},axisLine:!1,tickLine:!1,dx:-4,tickFormatter:e=>e>=1e3?`${(e/1e3).toFixed(1)}k`:`${e}`}),(0,F.jsx)(MG,{type:`number`,dataKey:`z`,range:[40,200]}),(0,F.jsx)(sR,{content:(0,F.jsx)(Uq,{}),cursor:{strokeDasharray:`3 3`}}),(0,F.jsx)(qW,{data:l,onClick:e=>t(e.payload.id),children:l.map((e,t)=>(0,F.jsx)(cR,{fill:c[e.category],fillOpacity:.7,cursor:`pointer`},`cell-${t}`))})]})})}),(0,F.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-x-5 gap-y-2 text-[11px]`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-moss`}),(0,F.jsxs)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:[`Fast (cached, >`,$f(a),`)`]})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-accent`}),(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Normal`})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-ember`}),(0,F.jsxs)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:[`Slow zone (`,$f(o),`–`,$f(a),`)`]})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-amber`}),(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Anomaly (massive new input)`})]})]})]})}var Gq=(0,b.memo)(Wq);function Kq({active:e,payload:t}){if(!e||!t?.length)return null;let n=t[0].payload;return(0,F.jsxs)(`div`,{className:`glass-panel rounded-2xl px-4 py-3 text-sm`,children:[(0,F.jsxs)(`p`,{className:`text-[11px] font-semibold uppercase tracking-wider text-zinc-400 dark:text-zinc-400 mb-2`,children:[`Request #`,String(n.index)]}),(0,F.jsx)(`div`,{className:`space-y-1`,children:t.map(e=>(0,F.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,F.jsx)(`div`,{className:`w-2 h-2 rounded-sm`,style:{background:e.color}}),(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400 w-20`,children:e.name}),(0,F.jsx)(`span`,{className:`metric-mono font-semibold text-zinc-700 dark:text-zinc-300`,children:e.value?.toLocaleString()})]},e.dataKey))})]})}function qq({data:e}){return(0,F.jsxs)(Pu.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.2},className:`card-surface p-6`,children:[(0,F.jsx)(`div`,{className:`flex items-center justify-between mb-6`,children:(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight text-zinc-800 dark:text-zinc-300`,children:`Token Composition — Last 30 Requests`}),(0,F.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-400 mt-0.5`,children:`How cache, new input, and output compose each request`})]})}),(0,F.jsx)(`div`,{className:`h-60`,children:(0,F.jsx)(yD,{width:`100%`,height:`100%`,children:(0,F.jsxs)(fq,{data:e,margin:{top:5,right:5,left:0,bottom:0},barCategoryGap:`20%`,children:[(0,F.jsx)(SH,{strokeDasharray:`3 3`,stroke:`var(--border)`,className:`dark:opacity-40`,vertical:!1}),(0,F.jsx)(mG,{dataKey:`index`,tick:{fontSize:10,fill:`var(--text-tertiary)`},axisLine:!1,tickLine:!1,dy:8,interval:4}),(0,F.jsx)(kG,{tick:{fontSize:11,fill:`var(--text-tertiary)`},axisLine:!1,tickLine:!1,dx:-4,tickFormatter:e=>e>=1e3?`${(e/1e3).toFixed(0)}k`:`${e}`}),(0,F.jsx)(sR,{content:(0,F.jsx)(Kq,{})}),(0,F.jsx)(_W,{dataKey:`cacheRead`,name:`Cache Read`,stackId:`a`,fill:`#0891b2`,fillOpacity:.8,radius:[0,0,0,0]}),(0,F.jsx)(_W,{dataKey:`input`,name:`New Input`,stackId:`a`,fill:`#3f3f46`,fillOpacity:.8,radius:[0,0,0,0]}),(0,F.jsx)(_W,{dataKey:`output`,name:`Output`,stackId:`a`,fill:`#059669`,fillOpacity:.7,radius:[2,2,0,0]})]})})}),(0,F.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-x-5 gap-y-2 text-[11px]`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(`div`,{className:`w-2.5 h-2.5 rounded-sm bg-accent`}),(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Cache Read`})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(`div`,{className:`w-2.5 h-2.5 rounded-sm bg-zinc-700 dark:bg-zinc-400`}),(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`New Input`})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(`div`,{className:`w-2.5 h-2.5 rounded-sm bg-moss`}),(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Output`})]})]})]})}var Jq=(0,b.memo)(qq);function Yq({stats:e}){let t=e.filter(e=>e.ttftDelta<0&&e.above.count>0&&e.below.count>0).reduce((e,t)=>!e||t.ttftDelta<e.ttftDelta?t:e,null);return(0,F.jsxs)(Pu.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.2},className:`card-surface p-6`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 mb-5`,children:[(0,F.jsx)(rf,{size:18,className:`text-accent`,weight:`bold`}),(0,F.jsx)(`h2`,{className:`text-base font-semibold tracking-tight text-zinc-800 dark:text-zinc-300`,children:`Threshold Crossings`})]}),(0,F.jsx)(`div`,{className:`space-y-4`,children:e.map(e=>{let t=e.below.count/(e.below.count+e.above.count);return(0,F.jsxs)(`div`,{className:`group`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,F.jsxs)(`span`,{className:`text-[11px] font-semibold uppercase tracking-wider text-zinc-400 dark:text-zinc-400`,children:[`At `,$f(e.threshold),` tokens`]}),(0,F.jsxs)(`span`,{className:`text-[11px] metric-mono text-zinc-400 dark:text-zinc-400`,children:[e.above.count,` above`]})]}),(0,F.jsx)(`div`,{className:`h-1.5 bg-zinc-100 dark:bg-white/[0.06] rounded-full overflow-hidden mb-3`,children:(0,F.jsx)(Pu.div,{className:`h-full rounded-full bg-accent`,initial:{width:0},animate:{width:`${t*100}%`},transition:{duration:.4,ease:`easeOut`}})}),(0,F.jsxs)(`div`,{className:`grid grid-cols-3 gap-3`,children:[(0,F.jsxs)(`div`,{className:`text-center`,children:[(0,F.jsx)(`p`,{className:`metric-mono text-sm font-bold text-zinc-700 dark:text-zinc-300`,children:Jf(Math.round(e.below.avgTtft))}),(0,F.jsx)(`p`,{className:`text-[10px] text-zinc-400 dark:text-zinc-400 mt-0.5`,children:`Below`})]}),(0,F.jsx)(`div`,{className:`flex items-center justify-center`,children:(0,F.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded-full ${e.ttftDelta>0?`bg-ember/10 text-ember`:e.ttftDelta<0?`bg-moss/10 text-moss`:`bg-zinc-100 dark:bg-white/[0.04] text-zinc-400 dark:text-zinc-400`}`,children:[e.ttftDelta>0?(0,F.jsx)(Rf,{size:10}):e.ttftDelta<0?(0,F.jsx)(If,{size:10}):(0,F.jsx)(vf,{size:10}),e.ttftDelta!==0&&(0,F.jsx)(`span`,{className:`metric-mono`,children:Jf(Math.abs(Math.round(e.ttftDelta)))})]})}),(0,F.jsxs)(`div`,{className:`text-center`,children:[(0,F.jsx)(`p`,{className:`metric-mono text-sm font-bold text-zinc-700 dark:text-zinc-300`,children:Jf(Math.round(e.above.avgTtft))}),(0,F.jsx)(`p`,{className:`text-[10px] text-zinc-400 dark:text-zinc-400 mt-0.5`,children:`Above`})]})]})]},e.threshold)})}),(0,F.jsx)(`div`,{className:`mt-5 pt-4 border-t border-zinc-100 dark:border-white/[0.06]`,children:t?(0,F.jsxs)(`p`,{className:`text-xs leading-relaxed text-zinc-500 dark:text-zinc-400`,children:[`The `,(0,F.jsxs)(`span`,{className:`metric-mono font-semibold text-zinc-700 dark:text-zinc-300`,children:[$f(t.threshold),` threshold`]}),` shows the strongest improvement signal — TTFT drops by`,` `,(0,F.jsx)(`span`,{className:`metric-mono font-semibold text-moss`,children:Jf(Math.abs(Math.round(t.ttftDelta)))}),` `,`once requests cross it, indicating a meaningful TTFT shift at this boundary.`]}):(0,F.jsx)(`p`,{className:`text-xs leading-relaxed text-zinc-500 dark:text-zinc-400`,children:`No threshold shows a significant TTFT improvement above it. Requests remain consistently timed across token counts.`})})]})}var Xq=b.memo(Yq);function Zq({anomalies:e}){if(e.length===0)return(0,F.jsxs)(Pu.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.2},className:`card-surface p-6`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 mb-4`,children:[(0,F.jsx)(`div`,{className:`p-1.5 bg-moss/10 rounded-lg`,children:(0,F.jsx)(mf,{size:16,className:`text-moss`,weight:`bold`})}),(0,F.jsx)(`h2`,{className:`text-base font-semibold tracking-tight text-zinc-800 dark:text-zinc-300`,children:`Anomaly Detector`})]}),(0,F.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-400`,children:`No anomalies detected in this session.`})]});let t=e=>{switch(e){case`high`:return`bg-ember/8 border-ember/20 text-ember`;case`medium`:return`bg-amber/8 border-amber/20 text-amber`;default:return`bg-zinc-100 border-zinc-200 dark:bg-white/[0.06] dark:border-white/[0.08] text-zinc-500 dark:text-zinc-400`}};return(0,F.jsxs)(Pu.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.2},className:`card-surface p-6`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between mb-5`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`div`,{className:`p-1.5 bg-amber/10 rounded-lg`,children:(0,F.jsx)(Wf,{size:16,className:`text-amber`,weight:`bold`})}),(0,F.jsx)(`h2`,{className:`text-base font-semibold tracking-tight text-zinc-800 dark:text-zinc-300`,children:`Anomaly Detector`})]}),(0,F.jsxs)(`span`,{className:`text-[11px] metric-mono font-semibold text-zinc-400 dark:text-zinc-400`,children:[e.length,` found`]})]}),(0,F.jsx)(`div`,{className:`space-y-2.5 max-h-80 overflow-y-auto scrollbar-thin`,children:e.map(e=>(0,F.jsx)(`div`,{className:`p-3 rounded-xl border ${t(e.severity)}`,children:(0,F.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,F.jsxs)(`div`,{className:`mt-0.5`,children:[e.type===`cache-drop`&&(0,F.jsx)(mf,{size:14,weight:`bold`}),e.type===`slow-zone`&&(0,F.jsx)(Wf,{size:14,weight:`bold`}),e.type===`high-new-input`&&(0,F.jsx)(Wf,{size:14,weight:`bold`}),e.type===`stall-spike`&&(0,F.jsx)(Wf,{size:14,weight:`bold`})]}),(0,F.jsxs)(`div`,{className:`min-w-0`,children:[(0,F.jsx)(`p`,{className:`text-xs font-medium text-zinc-700 dark:text-zinc-300`,children:e.description}),(0,F.jsxs)(`p`,{className:`text-[10px] metric-mono text-zinc-400 dark:text-zinc-400 mt-1`,children:[`#`,e.index+1,` · total=`,e.tokensTotal.toLocaleString(),e.energyCostUsd!==null&&` · ${(e.energyCostUsd*100).toFixed(2)}c`,e.energyCostUsd===null&&e.tokenCostUsd!==null&&` · ~${(e.tokenCostUsd*100).toFixed(2)}c`]})]})]})},`${e.eventId}-${e.type}`))})]})}var Qq=b.memo(Zq);function $q(e,t,n){let r=Array(e);return new Proxy(r,{get(r,i,a){if(typeof i==`string`){let a=i.charCodeAt(0);if(a>=48&&a<=57){let a=+i;if(Number.isInteger(a)&&a>=0&&a<e){let e=r[a];if(!e){let i=t[a*2];e=r[a]={index:a,key:n(a),start:i,size:t[a*2+1],end:i+t[a*2+1],lane:0}}return e}}if(i===`length`)return e}return Reflect.get(r,i,a)}})}function eJ(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o=e();return o.length!==r.length||o.some((e,t)=>r[t]!==e)?(r=o,i=t(...o),n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i):i}return o.updateDeps=e=>{r=e},o}function tJ(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var nJ=(e,t)=>Math.abs(e-t)<1.01,rJ=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},iJ,aJ=()=>{if(iJ!==void 0)return iJ;if(typeof navigator>`u`)return iJ=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return iJ=!0;let e=navigator.maxTouchPoints;return iJ=navigator.platform===`MacIntel`&&e!==void 0&&e>0},oJ=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},sJ=e=>e,cJ=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,r=Array(n);for(let e=0;e<n;e++)r[e]=t+e;return r},lJ=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(oJ(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(oJ(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},uJ={passive:!0},dJ=typeof window>`u`?!0:`onscrollend`in window,fJ=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&dJ,o=0,s=a?null:rJ(i,()=>t(o,!1),e.options.isScrollingResetDelay),c=e=>()=>{o=n(r),s?.(),t(o,e)},l=c(!0),u=c(!1);return r.addEventListener(`scroll`,l,uJ),a&&r.addEventListener(`scrollend`,u,uJ),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u)}},pJ=(e,t)=>fJ(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),mJ=(e,t,n)=>{if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},hJ=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:e+t,behavior:n})},gJ=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);for(let[e,n]of this.elementsCache)if(n===t){this.elementsCache.delete(e);break}return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{let t={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:sJ,rangeExtractor:cJ,onChange:()=>{},measureElement:mJ,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:`estimate`};for(let n in e){let r=e[n];r!==void 0&&(t[n]=r)}this.options=t},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=eJ(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}if(this.scrollElement=e,this.scrollElement&&`ownerDocument`in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{this._intendedScrollOffset!==null&&Math.abs(e-this._intendedScrollOffset)<1.5&&(e=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0,this.scrollDirection=t?this.getScrollOffset()<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),`addEventListener`in this.scrollElement){let e=this.scrollElement,t=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},n=()=>{this._iosTouching=!1,!(!aJ()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener(`touchstart`,t,uJ),e.addEventListener(`touchend`,n,uJ),this.unsubs.push(()=>{e.removeEventListener(`touchstart`,t),e.removeEventListener(`touchend`,n),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;let e=this.getScrollOffset(),t=this.getMaxScrollOffset();if(e<0||e>t)return;let n=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(e,{adjustments:this.scrollAdjustments+=n,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,t)=>{let n=new Map,r=new Map;for(let i=t-1;i>=0;i--){let t=e[i];if(n.has(t.lane))continue;let a=r.get(t.lane);if(a==null||t.end>a.end?r.set(t.lane,t):t.end<a.end&&n.set(t.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((e,t)=>e.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=eJ(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode],(e,t,n,r,i,a,o)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o}),{key:!1}),this.getMeasurements=eJ(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o},s)=>{let c=this.itemSizeCache;if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let l=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1),a===1){let i=this.options.gap,a=e*2,o=this._flatMeasurements;if(!o||o.length<a){let e=new Float64Array(a);o&&l>0&&e.set(o.subarray(0,l*2)),o=e,this._flatMeasurements=o}let s;if(l===0)s=t+n;else{let e=l-1;s=o[e*2]+o[e*2+1]+i}for(let t=l;t<e;t++){let e=r(t),n=c.get(e),a=typeof n==`number`?n:this.options.estimateSize(t);o[t*2]=s,o[t*2+1]=a,s+=a+i}let u=$q(e,o,r);return this.measurementsCache=u,u}let u=this.measurementsCache.slice(0,l),d=Array(a).fill(void 0);for(let e=0;e<l;e++){let t=u[e];t&&(d[t.lane]=e)}for(let i=l;i<e;i++){let e=r(i),a=this.laneAssignments.get(i),s,l,f=o===`estimate`||c.has(e);if(a!==void 0&&this.options.lanes>1){s=a;let e=d[s],r=e===void 0?void 0:u[e];l=r?r.end+this.options.gap:t+n}else{let e=this.options.lanes===1?u[i-1]:this.getFurthestMeasurement(u,i);l=e?e.end+this.options.gap:t+n,s=e?e.lane:i%this.options.lanes,this.options.lanes>1&&f&&this.laneAssignments.set(i,s)}let p=c.get(e),m=typeof p==`number`?p:this.options.estimateSize(i),h=l+m;u[i]={index:i,start:l,size:m,end:h,key:e,lane:s},d[s]=i}return this.measurementsCache=u,u},{key:!1,debug:()=>this.options.debug}),this.calculateRange=eJ(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?vJ({measurements:e,outerSize:t,scrollOffset:n,lanes:r,flat:r===1&&this._flatMeasurements!=null?this._flatMeasurements:null}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=eJ(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{if(e<0||e>=this.options.count)return;let n,r,i,a=this._flatMeasurements;if(this.options.lanes===1&&a!==null)i=this.options.getItemKey(e),r=a[e*2],n=a[e*2+1];else{let t=this.measurementsCache[e];if(!t)return;i=t.key,r=t.start,n=t.size}let o=t-(this.itemSizeCache.get(i)??n);o!==0&&(this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?r<this.getScrollOffset()+this.scrollAdjustments&&this.scrollDirection!==`backward`:this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:i,start:r,size:n,end:r+n,lane:0},o,this))&&(aJ()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=o:this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=o,behavior:void 0})),(this.pendingMin===null||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(i,t),this.itemSizeCacheVersion++,this.notify(!1))},this.getVirtualItems=eJ(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length===0)return;let n=this._flatMeasurements,r=this.options.lanes===1&&n!=null;return tJ(t[_J(0,t.length-1,r?e=>n[e*2]:e=>tJ(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`)if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{let r=this.getOffsetForAlignment(e,t),i=this.now();this.scrollState={index:null,align:t,behavior:n,startedAt:i,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e,r=this.now();this.scrollState={index:null,align:`start`,behavior:t,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1){let n=e.length-1,r=this._flatMeasurements;t=r==null?e[n]?.end??0:r[n*2]+r[n*2+1]}else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{let e=[];if(this.itemSizeCache.size===0)return e;let t=this.getMeasurements();for(let n of t)n&&this.itemSizeCache.has(n.key)&&e.push({index:n.index,key:n.key,start:n.start,size:n.size,end:n.end,lane:n.lane});return e},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this._intendedScrollOffset=e+(t??0),this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&nJ(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.getScrollOffset()!==t&&this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,n){let e=this.getSize()||600,n=Math.abs(t-this.getScrollOffset()),r=this.scrollState.behavior===`smooth`&&n>e;this.scrollState.lastTargetOffset=t,r||(this.scrollState.behavior=`auto`),this._scrollToOffset(t,{adjustments:void 0,behavior:r?`smooth`:`auto`})}this.scheduleScrollReconcile()}},_J=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function vJ({measurements:e,outerSize:t,scrollOffset:n,lanes:r,flat:i}){let a=e.length-1,o=i?e=>i[e*2]:t=>e[t].start,s=i?e=>i[e*2]+i[e*2+1]:t=>e[t].end;if(e.length<=r)return{startIndex:0,endIndex:a};let c=_J(0,a,o,n),l=c;if(r===1)for(;l<a&&s(l)<n+t;)l++;else if(r>1){let i=Array(r).fill(0);for(;l<a&&i.some(e=>e<n+t);){let t=e[l];i[t.lane]=t.end,l++}let o=Array(r).fill(n+t);for(;c>=0&&o.some(e=>e>=n);){let t=e[c];o[t.lane]=t.start,c--}c=Math.max(0,c-c%r),l=Math.min(a,l+(r-1-l%r))}return{startIndex:c,endIndex:l}}var yJ=typeof document<`u`?b.useLayoutEffect:b.useEffect;function bJ({useFlushSync:e=!0,...t}){let n=b.useReducer(e=>e+1,0)[1],r={...t,onChange:(r,i)=>{var a;e&&i?(0,UL.flushSync)(n):n(),(a=t.onChange)==null||a.call(t,r,i)}},[i]=b.useState(()=>new gJ(r));return i.setOptions(r),yJ(()=>i._didMount(),[]),yJ(()=>i._willUpdate()),i}function xJ(e){return bJ({observeElementRect:lJ,observeElementOffset:pJ,scrollToFn:hJ,...e})}var SJ=e=>e.substring(11,19),CJ=e=>{let t=new Date(e);return`${t.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`})} · ${t.toLocaleTimeString(`en-US`,{hour12:!1,hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}`};function wJ(e){return e.type===`tps`}var TJ=60;function EJ({timeline:e,selectedId:t,onSelect:n,thresholds:r}){let i=(0,b.useMemo)(()=>e.filter(wJ),[e]),a=(0,b.useMemo)(()=>i.map(e=>{let t=e.tokensTotal||1;return e.tokensCacheRead/t*100}),[i]),o=(0,b.useMemo)(()=>a.length===0?0:a.reduce((e,t)=>e+t,0)/a.length,[a]),s=(0,b.useMemo)(()=>t?i.findIndex(e=>e.id===t):-1,[t,i]),c=(0,b.useMemo)(()=>{if(a.length<=TJ)return a.map((e,t)=>({rate:e,startIndex:t,count:1}));let e=Math.ceil(a.length/TJ),t=[];for(let n=0;n<a.length;n+=e){let r=a.slice(n,Math.min(n+e,a.length)),i=r.reduce((e,t)=>e+t,0)/r.length;t.push({rate:i,startIndex:n,count:r.length})}return t},[a]),l=e,u=(0,b.useRef)(null),d=(0,b.useCallback)(e=>{n(e)},[n]),f=t?l.find(e=>e.id===t):null,p=e=>{let t=e.tokensTotal,n=e.ttftMs,i=e.tokensInput/t;return e.tokensInput>r.anomalyInputThreshold?{label:`anomaly`,color:`text-amber bg-amber/5 border-amber/20`}:n>r.slowTtft&&t<r.cacheThreshold?{label:`slow`,color:`text-ember bg-ember/5 border-ember/20`}:t>r.cacheThreshold&&n<r.fastTtft&&i<r.highNewInputRatio?{label:`fast`,color:`text-moss bg-moss/5 border-moss/20`}:{label:`normal`,color:`text-zinc-400 bg-zinc-50/50 dark:bg-white/[0.04] border-zinc-100 dark:border-white/[0.08]`}},m=e=>e.split(`/`).pop()??e,h=f&&wJ(f)?f:null;return(0,F.jsxs)(Pu.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.2},className:`card-surface p-0 overflow-hidden flex flex-col`,style:{maxHeight:`750px`},children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between p-5 pb-4 border-b border-zinc-100 dark:border-white/[0.06]`,children:[(0,F.jsx)(`h2`,{className:`text-base font-semibold tracking-tight text-zinc-800 dark:text-zinc-300`,children:`Request Inspector`}),(0,F.jsxs)(`span`,{className:`text-[11px] metric-mono font-semibold text-zinc-400 dark:text-zinc-400`,children:[i.length,` calls`]})]}),(0,F.jsxs)(`div`,{className:`px-5 pt-4 pb-3 border-b border-zinc-100 dark:border-white/[0.06]`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(kd,{size:12,className:`text-accent`,weight:`bold`}),(0,F.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-wider text-zinc-400 dark:text-zinc-400`,children:`Cache Hit Rate`})]}),(0,F.jsxs)(`span`,{className:`metric-mono text-[11px] font-semibold text-zinc-500 dark:text-zinc-400`,children:[o.toFixed(0),`% avg`]})]}),(0,F.jsx)(`div`,{className:`relative flex h-8 overflow-hidden gap-px`,title:`Cache hit rate · avg ${o.toFixed(0)}%${a.length>TJ?` · aggregated into ${c.length} bins`:``}`,children:c.map((e,t)=>{let n=Math.max(4,e.rate/100*100),r=e.rate>=80?`bg-moss`:e.rate>=50?`bg-accent`:e.rate>=20?`bg-amber`:`bg-ember`,a=s>=e.startIndex&&s<e.startIndex+e.count;return(0,F.jsxs)(`button`,{onClick:()=>d(i[e.startIndex].id),className:`flex-1 relative group cursor-pointer focus:outline-none focus-visible:ring-1 focus-visible:ring-accent ${a?`z-10`:``}`,title:e.count===1?`#${e.startIndex+1} · ${e.rate.toFixed(0)}% cache hit`:`#${e.startIndex+1}–${e.startIndex+e.count} · avg ${e.rate.toFixed(0)}% cache hit`,children:[(0,F.jsx)(`div`,{className:`absolute inset-0 rounded-sm transition-colors ${a?`bg-accent/10`:`group-hover:bg-accent/[0.07]`}`}),(0,F.jsx)(`div`,{className:`absolute inset-0 flex items-end`,children:(0,F.jsx)(`div`,{className:`w-full rounded-sm ${r} transition-opacity ${a?`opacity-100`:`opacity-70 group-hover:opacity-90`}`,style:{height:`${n}%`}})})]},t)})}),(0,F.jsxs)(`div`,{className:`flex items-center justify-between mt-1.5 text-[9px] metric-mono text-zinc-400 dark:text-zinc-400`,children:[(0,F.jsxs)(`span`,{children:[`#`,1]}),(0,F.jsxs)(`span`,{children:[`#`,a.length]})]})]}),(0,F.jsx)(`div`,{className:`flex-1 overflow-hidden`,style:{minHeight:`400px`},children:h?(0,F.jsxs)(`div`,{className:`h-full w-full overflow-y-auto scrollbar-thin p-5 space-y-5`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`p`,{className:`text-[11px] font-semibold uppercase tracking-wider text-zinc-400 dark:text-zinc-400`,children:`Request Detail`}),(0,F.jsxs)(`p`,{className:`metric-mono text-lg font-bold text-zinc-800 dark:text-zinc-300 mt-0.5`,children:[`#`,s+1,` of `,i.length]})]}),(0,F.jsx)(`button`,{onClick:()=>d(null),className:`p-2 rounded-xl bg-zinc-100 dark:bg-white/[0.04] hover:bg-zinc-200 dark:hover:bg-white/[0.08] transition-colors active:scale-[0.95]`,children:(0,F.jsx)(Kf,{size:16,className:`text-zinc-500 dark:text-zinc-400`})})]}),(0,F.jsx)(`div`,{className:`inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-[11px] font-semibold uppercase tracking-wider border ${p(h).color}`,children:p(h).label}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,F.jsx)(PJ,{icon:zd,label:`Timestamp`,value:CJ(h.timestamp)}),(0,F.jsx)(PJ,{icon:cf,label:`ID`,value:h.id.substring(0,8)})]}),(0,F.jsxs)(`div`,{className:`space-y-3`,children:[(0,F.jsx)(`p`,{className:`text-[11px] font-semibold uppercase tracking-wider text-zinc-400 dark:text-zinc-400`,children:`Model`}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:[(0,F.jsx)(FJ,{label:`Provider`,value:h.provider}),(0,F.jsx)(FJ,{label:`Model`,value:m(h.modelId),fullValue:h.modelId})]})]}),(0,F.jsxs)(`div`,{className:`space-y-3`,children:[(0,F.jsx)(`p`,{className:`text-[11px] font-semibold uppercase tracking-wider text-zinc-400 dark:text-zinc-400`,children:`Token Breakdown`}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:[(0,F.jsx)(IJ,{label:`Total`,value:h.tokensTotal,color:`bg-zinc-800 dark:bg-zinc-300`}),(0,F.jsx)(IJ,{label:`New Input`,value:h.tokensInput,color:`bg-zinc-600 dark:bg-zinc-400`}),(0,F.jsx)(IJ,{label:`Cache Read`,value:h.tokensCacheRead,color:`bg-accent`}),(0,F.jsx)(IJ,{label:`Output`,value:h.tokensOutput,color:`bg-moss`})]}),(0,F.jsx)(`div`,{className:`h-2 bg-zinc-100 dark:bg-white/[0.06] rounded-full overflow-hidden flex`,children:h.tokensTotal>0&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`div`,{className:`h-full bg-accent`,style:{width:`${h.tokensCacheRead/h.tokensTotal*100}%`}}),(0,F.jsx)(`div`,{className:`h-full bg-zinc-600 dark:bg-zinc-400`,style:{width:`${h.tokensInput/h.tokensTotal*100}%`}}),(0,F.jsx)(`div`,{className:`h-full bg-moss`,style:{width:`${h.tokensOutput/h.tokensTotal*100}%`}})]})}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3 text-[10px]`,children:[(0,F.jsxs)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:[`Cache: `,(h.tokensCacheRead/h.tokensTotal*100).toFixed(0),`%`]}),(0,F.jsxs)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:[`New: `,(h.tokensInput/h.tokensTotal*100).toFixed(0),`%`]}),(0,F.jsxs)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:[`Out: `,(h.tokensOutput/h.tokensTotal*100).toFixed(0),`%`]})]})]}),(0,F.jsxs)(`div`,{className:`space-y-3`,children:[(0,F.jsx)(`p`,{className:`text-[11px] font-semibold uppercase tracking-wider text-zinc-400 dark:text-zinc-400`,children:`Timing`}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:[(0,F.jsx)(LJ,{label:`TTFT`,value:Jf(h.ttftMs),highlight:!0}),(0,F.jsx)(LJ,{label:`Total`,value:Jf(h.totalMs)}),(0,F.jsx)(LJ,{label:`Generation`,value:Jf(h.generationMs)}),(0,F.jsx)(LJ,{label:`Stall`,value:Jf(h.stallMs),warn:h.stallMs>0})]})]}),(0,F.jsxs)(`div`,{className:`space-y-3`,children:[(0,F.jsx)(`p`,{className:`text-[11px] font-semibold uppercase tracking-wider text-zinc-400 dark:text-zinc-400`,children:`Speed Breakdown`}),(()=>{let e=h.effectiveTps,t=h.wallTps,n=e>0?(e-t)/e*100:0,r=e>0?t/e*100:0,i=h.generationMs>0?h.stallMs/h.generationMs*100:0;return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,F.jsxs)(`div`,{className:`bg-moss/5 dark:bg-moss/10 rounded-xl px-2 sm:px-3 py-2.5 text-center`,children:[(0,F.jsx)(`p`,{className:`text-[9px] font-medium uppercase tracking-wider text-zinc-400 dark:text-zinc-400`,children:`Active`}),(0,F.jsx)(`p`,{className:`metric-mono text-sm font-bold text-moss mt-0.5`,children:Zf(e)}),(0,F.jsx)(`p`,{className:`text-[9px] text-zinc-400 dark:text-zinc-500`,children:`tok/s`})]}),(0,F.jsxs)(`div`,{className:`bg-accent/5 dark:bg-accent/10 rounded-xl px-2 sm:px-3 py-2.5 text-center`,children:[(0,F.jsx)(`p`,{className:`text-[9px] font-medium uppercase tracking-wider text-zinc-400 dark:text-zinc-400`,children:`Wall`}),(0,F.jsx)(`p`,{className:`metric-mono text-sm font-bold text-accent mt-0.5`,children:Zf(t)}),(0,F.jsx)(`p`,{className:`text-[9px] text-zinc-400 dark:text-zinc-500`,children:`tok/s`})]}),(0,F.jsxs)(`div`,{className:`bg-ember/5 dark:bg-ember/10 rounded-xl px-2 sm:px-3 py-2.5 text-center`,children:[(0,F.jsx)(`p`,{className:`text-[9px] font-medium uppercase tracking-wider text-zinc-400 dark:text-zinc-400`,children:`Loss`}),(0,F.jsxs)(`p`,{className:`metric-mono text-sm font-bold mt-0.5 ${n>50?`text-ember`:n>20?`text-amber`:`text-zinc-500 dark:text-zinc-400`}`,children:[n.toFixed(1),`%`]}),(0,F.jsx)(`p`,{className:`text-[9px] text-zinc-400 dark:text-zinc-500`,children:`of active`})]})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between text-[10px] mb-1`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Throughput retention`}),(0,F.jsxs)(`span`,{className:`metric-mono text-zinc-500 dark:text-zinc-400`,children:[r.toFixed(0),`%`]})]}),(0,F.jsxs)(`div`,{className:`h-2 rounded-full overflow-hidden flex bg-zinc-100 dark:bg-white/[0.06]`,children:[(0,F.jsx)(`div`,{className:`h-full bg-moss`,style:{width:`${Math.max(0,Math.min(100,r))}%`}}),(0,F.jsx)(`div`,{className:`h-full bg-ember`,style:{width:`${Math.max(0,Math.min(100,100-r))}%`}})]})]}),h.stallMs>0&&(0,F.jsxs)(`div`,{className:`flex items-center justify-between text-[10px] bg-amber/5 dark:bg-amber/10 rounded-lg px-3 py-2`,children:[(0,F.jsx)(`span`,{className:`text-amber`,children:`Stalls`}),(0,F.jsxs)(`span`,{className:`metric-mono text-amber`,children:[h.stallCount,` · `,Jf(h.stallMs),` · `,i.toFixed(0),`% gen time`]})]}),h.tps!==h.effectiveTps&&h.tps>0&&(0,F.jsxs)(`p`,{className:`text-[10px] text-zinc-400 dark:text-zinc-500`,title:`Stored TPS from extension (computed before stall-guard fix, may include inflation)`,children:[`Stored raw TPS: `,Zf(h.tps)]})]})})()]}),(0,F.jsxs)(`div`,{className:`space-y-3`,children:[(0,F.jsx)(`p`,{className:`text-[11px] font-semibold uppercase tracking-wider text-zinc-400 dark:text-zinc-400`,children:`Energy & Cost`}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:[(0,F.jsx)(LJ,{label:`Energy`,value:h.energyJoules===null?`-`:`${h.energyJoules.toFixed(1)}J`}),(0,F.jsx)(LJ,{label:h.costTotal===null?`Cost`:`Cost (est.)`,value:h.energyCostUsd===null?h.costTotal===null?`-`:`$${h.costTotal.toFixed(4)}`:`$${h.energyCostUsd.toFixed(4)}`})]})]})]},`detail`):(0,F.jsx)(NJ,{sorted:l,tpsEvents:i,thresholds:r,selectedId:t,selectedRef:u,onSelect:d,shortModel:m,isTpsRow:wJ})})]})}var DJ=b.memo(function({event:e,tpsIndex:t,thresholds:n,onSelect:r,shortModel:i}){let a=(0,b.useMemo)(()=>{let t=e.tokensTotal,r=e.ttftMs,i=e.tokensInput/t;return e.tokensInput>n.anomalyInputThreshold?{label:`anomaly`,color:`text-amber bg-amber/5 border-amber/20`}:r>n.slowTtft&&t<n.cacheThreshold?{label:`slow`,color:`text-ember bg-ember/5 border-ember/20`}:t>n.cacheThreshold&&r<n.fastTtft&&i<n.highNewInputRatio?{label:`fast`,color:`text-moss bg-moss/5 border-moss/20`}:{label:`normal`,color:`text-zinc-400 bg-zinc-50/50 dark:bg-white/[0.04] border-zinc-100 dark:border-white/[0.08]`}},[e,n]);return(0,F.jsxs)(`div`,{onClick:()=>r(e.id),className:`flex items-center gap-3 px-5 py-3 hover:bg-zinc-50/80 dark:hover:bg-white/[0.04] cursor-pointer active:bg-zinc-100 dark:active:bg-white/[0.08]`,children:[(0,F.jsx)(`div`,{className:`w-7 h-7 flex items-center justify-center rounded-lg bg-zinc-100 dark:bg-white/[0.06] metric-mono text-[10px] font-bold text-zinc-500 dark:text-zinc-400 shrink-0`,children:t+1}),(0,F.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`metric-mono text-xs font-semibold text-zinc-700 dark:text-zinc-300`,children:e.tokensTotal.toLocaleString()}),(0,F.jsx)(`span`,{className:`text-[10px] text-zinc-400 dark:text-zinc-400`,children:`tokens`}),(0,F.jsx)(`span`,{className:`text-[10px] text-zinc-300 dark:text-zinc-700`,children:`·`}),(0,F.jsx)(`span`,{className:`text-[10px] font-medium text-accent`,title:`${e.provider}/${e.modelId}`,children:i(e.modelId)})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5`,children:[(0,F.jsx)(`span`,{className:`text-[10px] metric-mono text-zinc-400 dark:text-zinc-400`,children:SJ(e.timestamp)}),(0,F.jsx)(`span`,{className:`text-[10px] text-zinc-300 dark:text-zinc-700`,children:`·`}),(0,F.jsxs)(`span`,{className:`text-[10px] font-medium ${e.ttftMs>n.slowTtft?`text-ember`:e.ttftMs<n.fastTtft?`text-moss`:`text-zinc-400 dark:text-zinc-400`}`,children:[`ttft `,Jf(e.ttftMs)]}),(0,F.jsx)(`span`,{className:`text-[10px] text-zinc-300 dark:text-zinc-700`,children:`·`}),(0,F.jsxs)(`span`,{className:`text-[10px] font-medium ${e.effectiveTps>40?`text-moss`:e.effectiveTps>20?`text-accent`:`text-ember`}`,children:[Zf(e.effectiveTps),` tps`]}),(0,F.jsx)(`span`,{className:`text-[10px] text-zinc-300 dark:text-zinc-700`,children:`·`}),(0,F.jsxs)(`span`,{className:`text-[10px] text-zinc-400 dark:text-zinc-400`,children:[(e.tokensCacheRead/e.tokensTotal*100).toFixed(0),`% cache`]})]})]}),(0,F.jsx)(`div`,{className:`w-1.5 h-1.5 rounded-full ${a.color.split(` `)[0].replace(`text-`,`bg-`)}`})]})});function OJ({event:e}){return e.type===`model_change`?(0,F.jsxs)(`div`,{className:`flex items-center gap-2.5 px-5 py-2 bg-accent/[0.03] dark:bg-accent/[0.06]`,children:[(0,F.jsx)(`div`,{className:`w-7 h-7 flex items-center justify-center shrink-0`,children:(0,F.jsx)(Td,{size:14,className:`text-accent`,weight:`bold`})}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,F.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wider text-accent`,children:`model →`}),(0,F.jsx)(`span`,{className:`text-[11px] font-medium text-zinc-600 dark:text-zinc-300 truncate`,title:`${e.provider}/${e.modelId}`,children:e.modelId.split(`/`).pop()}),(0,F.jsx)(`span`,{className:`text-[10px] text-zinc-400 dark:text-zinc-400`,children:e.provider}),(0,F.jsx)(`span`,{className:`text-[10px] text-zinc-300 dark:text-zinc-700 ml-auto metric-mono`,children:SJ(e.timestamp)})]})]}):e.type===`rewind`?(0,F.jsxs)(`div`,{className:`flex items-center gap-2.5 px-5 py-2 bg-ember/[0.03] dark:bg-ember/[0.06]`,children:[(0,F.jsx)(`div`,{className:`w-7 h-7 flex items-center justify-center shrink-0`,children:(0,F.jsx)(Cd,{size:14,className:`text-ember`,weight:`bold`})}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,F.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wider text-ember`,children:`rewind`}),(0,F.jsx)(`span`,{className:`text-[10px] text-zinc-400 dark:text-zinc-400`,children:`navigated`}),(0,F.jsx)(`span`,{className:`text-[10px] text-zinc-300 dark:text-zinc-700 ml-auto metric-mono`,children:SJ(e.timestamp)})]})]}):e.type===`branch_summary`?(0,F.jsxs)(`div`,{className:`flex items-center gap-2.5 px-5 py-2 bg-moss/[0.03] dark:bg-moss/[0.06]`,children:[(0,F.jsx)(`div`,{className:`w-7 h-7 flex items-center justify-center shrink-0`,children:(0,F.jsx)(Pf,{size:14,className:`text-moss`,weight:`bold`})}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,F.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wider text-moss`,children:`branch`}),(0,F.jsx)(`span`,{className:`text-[10px] text-zinc-400 dark:text-zinc-400 truncate max-w-[200px]`,children:e.summary.length>60?e.summary.substring(0,60)+`…`:e.summary}),(0,F.jsx)(`span`,{className:`text-[10px] text-zinc-300 dark:text-zinc-700 ml-auto metric-mono`,children:SJ(e.timestamp)})]})]}):null}var kJ=b.memo(EJ),AJ=60,jJ=44;function MJ(e){return wJ(e)?AJ:jJ}function NJ({sorted:e,tpsEvents:t,thresholds:n,selectedId:r,selectedRef:i,onSelect:a,shortModel:o,isTpsRow:s}){let c=(0,b.useRef)(null),l=xJ({count:e.length,getScrollElement:()=>c.current,estimateSize:t=>MJ(e[t]),overscan:8});return(0,F.jsx)(`div`,{ref:c,className:`h-full w-full overflow-y-auto scrollbar-thin`,style:{contain:`content`},children:(0,F.jsx)(`div`,{style:{height:l.getTotalSize(),width:`100%`,position:`relative`},children:l.getVirtualItems().map(c=>{let l=e[c.index];if(s(l)){let e=t.findIndex(e=>e.id===l.id);return(0,F.jsx)(`div`,{"data-index":c.index,ref:r===l.id?i:void 0,style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${c.start}px)`},children:(0,F.jsx)(DJ,{event:l,tpsIndex:e,thresholds:n,onSelect:e=>a(e),shortModel:o})},l.id)}return(0,F.jsx)(`div`,{"data-index":c.index,style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${c.start}px)`},children:(0,F.jsx)(OJ,{event:l})},l.id)})})})}function PJ({icon:e,label:t,value:n}){return(0,F.jsxs)(`div`,{className:`bg-zinc-50/80 dark:bg-white/[0.04] rounded-xl p-3`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1`,children:[(0,F.jsx)(e,{size:12,className:`text-zinc-400 dark:text-zinc-400`,weight:`bold`}),(0,F.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-wider text-zinc-400 dark:text-zinc-400`,children:t})]}),(0,F.jsx)(`p`,{className:`metric-mono text-sm font-bold text-zinc-800 dark:text-zinc-300`,children:n})]})}function FJ({label:e,value:t,fullValue:n}){return(0,F.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 bg-accent/[0.04] dark:bg-accent/[0.08] rounded-xl`,children:[(0,F.jsx)(`span`,{className:`text-[10px] font-medium text-zinc-400 dark:text-zinc-400`,children:e}),(0,F.jsx)(`span`,{className:`metric-mono text-xs font-bold text-accent truncate ml-2`,title:n??t,children:t})]})}function IJ({label:e,value:t,color:n}){return(0,F.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 bg-zinc-50/80 dark:bg-white/[0.04] rounded-xl`,children:[(0,F.jsx)(`span`,{className:`text-[10px] font-medium text-zinc-400 dark:text-zinc-400`,children:e}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(`div`,{className:`w-1.5 h-1.5 rounded-full ${n}`}),(0,F.jsx)(`span`,{className:`metric-mono text-xs font-bold text-zinc-700 dark:text-zinc-300`,children:t.toLocaleString()})]})]})}function LJ({label:e,value:t,highlight:n,warn:r}){return(0,F.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 rounded-xl ${n?`bg-accent/5`:r?`bg-ember/5`:`bg-zinc-50/80 dark:bg-white/[0.04]`}`,children:[(0,F.jsx)(`span`,{className:`text-[10px] font-medium text-zinc-400 dark:text-zinc-400`,children:e}),(0,F.jsx)(`span`,{className:`metric-mono text-xs font-bold ${n?`text-accent`:r?`text-ember`:`text-zinc-700 dark:text-zinc-300`}`,children:t})]})}function RJ({active:e,payload:t}){if(!e||!t?.length)return null;let n=t[0];return(0,F.jsxs)(`div`,{className:`glass-panel rounded-xl px-3 py-2 text-xs`,children:[(0,F.jsxs)(`span`,{className:`font-semibold text-zinc-700 dark:text-zinc-300`,children:[n.name,`:`]}),` `,(0,F.jsx)(`span`,{className:`metric-mono`,children:n.value?.toLocaleString()})]})}function zJ({overall:e,overTime:t,hitRate:n}){return(0,F.jsxs)(Pu.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.2},className:`card-surface p-6 flex flex-col`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 mb-5`,children:[(0,F.jsx)(`div`,{className:`p-1.5 bg-accent/10 dark:bg-accent/15 rounded-lg`,children:(0,F.jsx)(of,{size:16,className:`text-accent`,weight:`bold`})}),(0,F.jsx)(`h2`,{className:`text-base font-semibold tracking-tight text-zinc-800 dark:text-zinc-300`,children:`Cache Efficiency`})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-4`,children:[(0,F.jsxs)(`div`,{className:`relative`,children:[(0,F.jsx)(yD,{width:`100%`,height:160,children:(0,F.jsxs)(Mq,{children:[(0,F.jsx)(Vz,{data:e,cx:`50%`,cy:`50%`,innerRadius:45,outerRadius:65,paddingAngle:2,dataKey:`value`,strokeWidth:0,children:e.map((e,t)=>(0,F.jsx)(cR,{fill:e.color,fillOpacity:.85},`cell-${t}`))}),(0,F.jsx)(sR,{content:(0,F.jsx)(RJ,{}),wrapperStyle:{zIndex:10}})]})}),(0,F.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center pointer-events-none z-0`,children:[(0,F.jsxs)(`span`,{className:`metric-mono text-2xl font-bold text-zinc-800 dark:text-zinc-300`,children:[n.toFixed(0),`%`]}),(0,F.jsx)(`span`,{className:`text-[10px] text-zinc-400 dark:text-zinc-400 font-medium uppercase tracking-wider`,children:`cache hit`})]})]}),(0,F.jsx)(`div`,{className:`flex flex-col justify-center gap-2.5`,children:e.map(t=>{let n=e.reduce((e,t)=>e+t.value,0),r=n>0?t.value/n*100:0;return(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between text-xs mb-1`,children:[(0,F.jsx)(`span`,{className:`text-zinc-500 dark:text-zinc-400 font-medium`,children:t.name}),(0,F.jsxs)(`span`,{className:`metric-mono text-zinc-700 dark:text-zinc-300 font-semibold`,children:[r.toFixed(0),`%`]})]}),(0,F.jsx)(`div`,{className:`h-1.5 bg-zinc-100 dark:bg-white/[0.06] rounded-full overflow-hidden`,children:(0,F.jsx)(Pu.div,{className:`h-full rounded-full`,style:{backgroundColor:t.color},initial:{width:0},animate:{width:`${r}%`},transition:{duration:.4,ease:`easeOut`}})})]},t.name)})})]}),(0,F.jsxs)(`div`,{className:`mt-5 pt-4 border-t border-zinc-100 dark:border-white/[0.06]`,children:[(0,F.jsx)(`p`,{className:`text-[10px] font-semibold uppercase tracking-wider text-zinc-400 dark:text-zinc-400 mb-3`,children:`Cache hit rate over time (by request range)`}),(0,F.jsx)(`div`,{className:`space-y-1.5`,children:t.map((e,t)=>{let n=e.hitRate>=80?`bg-moss`:e.hitRate>=50?`bg-accent`:e.hitRate>=20?`bg-amber`:`bg-ember`,r=e.hitRate>=80?`text-moss`:e.hitRate>=50?`text-accent`:e.hitRate>=20?`text-amber`:`text-ember`;return(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`text-[9px] metric-mono text-zinc-400 dark:text-zinc-400 w-10 shrink-0 text-right`,children:e.label}),(0,F.jsxs)(`div`,{className:`flex-1 h-4 bg-zinc-50 dark:bg-white/[0.04] rounded-sm overflow-hidden relative`,children:[(0,F.jsx)(Pu.div,{className:`h-full ${n} rounded-sm`,initial:{width:0},animate:{width:`${e.hitRate}%`},transition:{duration:.4,ease:`easeOut`}}),(0,F.jsxs)(`span`,{className:`absolute inset-y-0 right-1.5 flex items-center text-[9px] metric-mono font-semibold ${r} mix-blend-difference`,children:[e.hitRate,`%`]})]})]},t)})})]})]})}var BJ=(0,b.memo)(zJ);function VJ(e){return e.replace(/'/g,`''`)}function HJ(e,t){let n=[];return e&&n.push(`session_id = '${VJ(e)}'`),t&&n.push(`model_id = '${VJ(t)}'`),n.length===0?`WHERE 1=1`:`WHERE 1=1 AND ${n.join(` AND `)}`}function UJ(e,t,n){let r=e.columns.indexOf(n);if(r!==-1)return e.rows[t]?.[r]}function WJ(e,t,n){return UJ(e,t,n)??``}function G(e,t,n){let r=UJ(e,t,n);return r==null?0:Number(r)}function GJ(e,t,n){let r=UJ(e,t,n);return r==null?null:Number(r)}async function KJ(e,t){let n=await yx(`
238
+ ${x.x},${x.y}`,C=QS(e.id)?qS(`recharts-radial-line-`):e.id;return b.createElement(`text`,zR({},r,{dominantBaseline:`central`,className:Px(`recharts-radial-bar-label`,o)}),b.createElement(`defs`,null,b.createElement(`path`,{id:C,d:S})),b.createElement(`textPath`,{xlinkHref:`#${C}`},n))},Qde=(e,t,n)=>{var{cx:r,cy:i,innerRadius:a,outerRadius:o,startAngle:s,endAngle:c}=e,l=(s+c)/2;if(n===`outside`){var{x:u,y:d}=Ok(r,i,o+t,l);return{x:u,y:d,textAnchor:u>=r?`start`:`end`,verticalAnchor:`middle`}}if(n===`center`)return{x:r,y:i,textAnchor:`middle`,verticalAnchor:`middle`};if(n===`centerTop`)return{x:r,y:i,textAnchor:`middle`,verticalAnchor:`start`};if(n===`centerBottom`)return{x:r,y:i,textAnchor:`middle`,verticalAnchor:`end`};var{x:f,y:p}=Ok(r,i,(a+o)/2,l);return{x:f,y:p,textAnchor:`middle`,verticalAnchor:`middle`}},WR=e=>e!=null&&`cx`in e&&H(e.cx),$de={angle:0,offset:5,zIndex:PA.label,position:`middle`,textBreakAll:!1};function efe(e){if(!WR(e))return e;var{cx:t,cy:n,outerRadius:r}=e,i=r*2;return{x:t-r,y:n-r,width:i,upperWidth:i,lowerWidth:i,height:i}}function GR(e){var t=dC(e,$de),{viewBox:n,parentViewBox:r,position:i,value:a,children:o,content:s,className:c=``,textBreakAll:l,labelRef:u}=t,d=Jde(),f=HR(),p=n==null?i===`center`?f:d??f:WR(n)?n:bD(n),m,h,g=efe(p);if(!p||QS(a)&&QS(o)&&!(0,b.isValidElement)(s)&&typeof s!=`function`)return null;var _=RR(RR({},t),{},{viewBox:p});if((0,b.isValidElement)(s)){var{labelRef:v}=_;return(0,b.cloneElement)(s,IR(_,Vde))}if(typeof s==`function`){var{content:y}=_;if(m=(0,b.createElement)(s,IR(_,Hde)),(0,b.isValidElement)(m))return m}else m=Yde(t);var x=Bx(t);if(WR(p)){if(i===`insideStart`||i===`insideEnd`||i===`end`)return Zde(t,i,m,x,p);h=Qde(p,t.offset,t.position)}else{if(!g)return null;var S=Bde({viewBox:g,position:i,offset:t.offset,parentViewBox:WR(r)?void 0:r,clamp:!0});h=RR(RR({x:S.x,y:S.y,textAnchor:S.horizontalAnchor,verticalAnchor:S.verticalAnchor},S.width===void 0?{}:{width:S.width}),S.height===void 0?{}:{height:S.height})}return b.createElement(WL,{zIndex:t.zIndex},b.createElement(NR,zR({ref:u,className:Px(`recharts-label`,c)},x,h,{textAnchor:DR(x.textAnchor)?x.textAnchor:h.textAnchor,breakAll:l}),m))}GR.displayName=`Label`;var tfe=(e,t,n)=>{if(!e)return null;var r={viewBox:t,labelRef:n};return e===!0?b.createElement(GR,zR({key:`label-implicit`},r)):KS(e)?b.createElement(GR,zR({key:`label-implicit`,value:e},r)):(0,b.isValidElement)(e)?e.type===GR?(0,b.cloneElement)(e,RR({key:`label-implicit`},r)):b.createElement(GR,zR({key:`label-implicit`,content:e},r)):UR(e)?b.createElement(GR,zR({key:`label-implicit`,content:e},r)):e&&typeof e==`object`?b.createElement(GR,zR({},e,{key:`label-implicit`},r)):null};function KR(e){var{label:t,labelRef:n}=e;return tfe(t,HR(),n)||null}var nfe=[`valueAccessor`],rfe=[`dataKey`,`clockWise`,`id`,`textBreakAll`,`zIndex`];function qR(){return qR=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},qR.apply(null,arguments)}function JR(e,t){if(e==null)return{};var n,r,i=ife(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function ife(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var afe=e=>{var t=Array.isArray(e.value)?e.value[e.value.length-1]:e.value;if(Mde(t))return t},YR=(0,b.createContext)(void 0),XR=YR.Provider,ZR=(0,b.createContext)(void 0),ofe=ZR.Provider;function sfe(){return(0,b.useContext)(YR)}function cfe(){return(0,b.useContext)(ZR)}function QR(e){var{valueAccessor:t=afe}=e,n=JR(e,nfe),{dataKey:r,clockWise:i,id:a,textBreakAll:o,zIndex:s}=n,c=JR(n,rfe),l=sfe(),u=cfe(),d=l||u;return!d||!d.length?null:b.createElement(WL,{zIndex:s??PA.label},b.createElement(Wx,{className:`recharts-label-list`},d.map((e,i)=>{var s=QS(r)?t(e,i):RE(e.payload,r),l=QS(a)?{}:{id:`${a}-${i}`};return b.createElement(GR,qR({key:`label-${i}`},Bx(e),c,l,{fill:n.fill??e.fill,parentViewBox:e.parentViewBox,value:s,textBreakAll:o,viewBox:e.viewBox,index:i,zIndex:0}))})))}QR.displayName=`LabelList`;function $R(e){var{label:t}=e;return t?t===!0?b.createElement(QR,{key:`labelList-implicit`}):b.isValidElement(t)||UR(t)?b.createElement(QR,{key:`labelList-implicit`,content:t}):typeof t==`object`?b.createElement(QR,qR({key:`labelList-implicit`},t,{type:String(t.type)})):null:null}function ez(){return ez=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},ez.apply(null,arguments)}var tz=e=>{var{cx:t,cy:n,r,className:i}=e,a=Px(`recharts-dot`,i);return H(t)&&H(n)&&H(r)?b.createElement(`circle`,ez({},Rx(e),cC(e),{className:a,cx:t,cy:n,r})):null},nz=e=>e.graphicalItems.polarItems,rz=W([nz,CF,W([tj,nj],EF)],OF),iz=W([W([rz],MF),rA],PF),lfe=W([iz,CF,rz],IF);W([iz,CF,rz],(e,t,n)=>n.length>0?e.flatMap(e=>n.flatMap(n=>({value:RE(e,t.dataKey??n.dataKey),errorDomain:[]}))).filter(Boolean):t?.dataKey==null?e.map(e=>({value:e,errorDomain:[]})):e.map(e=>({value:RE(e,t.dataKey),errorDomain:[]})));var az=()=>void 0,oz=W([CF,TD,iz,lfe,DA,tj,W([CF,YF,XF,az,W([iz,CF,rz,ZF,tj,sA],$F),az,TD,tj],sI)],cI);W([uI,W([CF,oz,W([oz,wF,uI],dI),tj],pI)],fj);var sz=aE({name:`polarAxis`,initialState:{radiusAxis:{},angleAxis:{}},reducers:{addRadiusAxis(e,t){e.radiusAxis[t.payload.id]=hO(t.payload)},removeRadiusAxis(e,t){delete e.radiusAxis[t.payload.id]},addAngleAxis(e,t){e.angleAxis[t.payload.id]=hO(t.payload)},removeAngleAxis(e,t){delete e.angleAxis[t.payload.id]}}}),{addRadiusAxis:ufe,removeRadiusAxis:dfe,addAngleAxis:ffe,removeAngleAxis:pfe}=sz.actions,mfe=sz.reducer;function cz(e){return e&&typeof e==`object`&&`className`in e&&typeof e.className==`string`?e.className:``}function lz(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function uz(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?lz(Object(n),!0).forEach(function(t){hfe(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):lz(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function hfe(e,t,n){return(t=gfe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function gfe(e){var t=_fe(e,`string`);return typeof t==`symbol`?t:t+``}function _fe(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var dz=W([nz,(e,t)=>t],(e,t)=>e.filter(e=>e.type===`pie`).find(e=>e.id===t)),vfe=[],fz=(e,t,n)=>n?.length===0?vfe:n,pz=W([rA,dz,fz],(e,t,n)=>{var{chartData:r}=e;if(t!=null){var i=t?.data!=null&&t.data.length>0?t.data:r;if((!i||!i.length)&&n!=null&&(i=n.map(e=>uz(uz({},t.presentationProps),e.props))),i!=null)return i}}),yfe=W([pz,dz,fz],(e,t,n)=>{if(!(e==null||t==null))return e.map((e,r)=>{var i,a=RE(e,t.nameKey,t.name),o=n!=null&&(i=n[r])!=null&&(i=i.props)!=null&&i.fill?n[r].props.fill:typeof e==`object`&&e&&`fill`in e?e.fill:t.fill;return{value:YE(a,t.dataKey),color:o,payload:e,type:t.legendType}})}),bfe=W([pz,dz,fz,aD],(e,t,n,r)=>{if(!(t==null||e==null))return Cpe({offset:r,pieSettings:t,displayedData:e,cells:n})}),xfe=s((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.suspense_list`),d=Symbol.for(`react.memo`),f=Symbol.for(`react.lazy`),p=Symbol.for(`react.view_transition`);function m(e){if(typeof e==`object`&&e){var m=e.$$typeof;switch(m){case t:switch(e=e.type,e){case r:case a:case i:case l:case u:case p:return e;default:switch(e&&=e.$$typeof,e){case s:case c:case f:case d:return e;case o:return e;default:return m}}case n:return m}}}e.isFragment=function(e){return m(e)===r}})),Sfe=s(((e,t)=>{t.exports=xfe()}))(),mz=e=>typeof e==`string`?e:e?e.displayName||e.name||`Component`:``,hz=null,gz=null,_z=e=>{if(e===hz&&Array.isArray(gz))return gz;var t=[];return b.Children.forEach(e,e=>{QS(e)||((0,Sfe.isFragment)(e)?t=t.concat(_z(e.props.children)):t.push(e))}),gz=t,hz=e,t};function vz(e,t){var n=[],r=[];return r=Array.isArray(t)?t.map(e=>mz(e)):[mz(t)],_z(e).forEach(e=>{var t=(0,HS.default)(e,`type.displayName`)||(0,HS.default)(e,`type.name`);t&&r.indexOf(t)!==-1&&n.push(e)}),n}var yz=e=>e&&typeof e==`object`&&`clipDot`in e?!!e.clipDot:!0,Cfe=s((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e){if(typeof e!=`object`||!e)return!1;if(Object.getPrototypeOf(e)===null)return!0;if(Object.prototype.toString.call(e)!==`[object Object]`){let t=e[Symbol.toStringTag];return t==null||!Object.getOwnPropertyDescriptor(e,Symbol.toStringTag)?.writable?!1:e.toString()===`[object ${t}]`}let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}e.isPlainObject=t})),wfe=s(((e,t)=>{t.exports=Cfe().isPlainObject})),Tfe,Efe,Dfe,Ofe,kfe;function bz(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function xz(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?bz(Object(n),!0).forEach(function(t){Afe(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):bz(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Afe(e,t,n){return(t=jfe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function jfe(e){var t=Mfe(e,`string`);return typeof t==`symbol`?t:t+``}function Mfe(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Sz(){return Sz=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Sz.apply(null,arguments)}function Cz(e,t){return t||=e.slice(0),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}var wz=(e,t,n,r,i)=>{var a=n-r,o=VS(Tfe||=Cz([`M `,`,`,``]),e,t);return o+=VS(Efe||=Cz([`L `,`,`,``]),e+n,t),o+=VS(Dfe||=Cz([`L `,`,`,``]),e+n-a/2,t+i),o+=VS(Ofe||=Cz([`L `,`,`,``]),e+n-a/2-r,t+i),o+=VS(kfe||=Cz([`L `,`,`,` Z`]),e,t),o},Nfe={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:`ease`},Pfe=e=>{var t=dC(e,Nfe),{x:n,y:r,upperWidth:i,lowerWidth:a,height:o,className:s}=t,{animationEasing:c,animationDuration:l,animationBegin:u,isUpdateAnimationActive:d}=t,f=(0,b.useRef)(null),[p,m]=(0,b.useState)(-1),h=(0,b.useRef)(i),g=(0,b.useRef)(a),_=(0,b.useRef)(o),v=(0,b.useRef)(n),y=(0,b.useRef)(r),x=ck(e,`trapezoid-`);if((0,b.useEffect)(()=>{if(f.current&&f.current.getTotalLength)try{var e=f.current.getTotalLength();e&&m(e)}catch{}},[]),n!==+n||r!==+r||i!==+i||a!==+a||o!==+o||i===0&&a===0||o===0)return null;var S=Px(`recharts-trapezoid`,s);if(!d)return b.createElement(`g`,null,b.createElement(`path`,Sz({},Bx(t),{className:S,d:wz(n,r,i,a,o)})));var C=h.current,w=g.current,T=_.current,E=v.current,D=y.current,O=`0px ${p===-1?1:p}px`,k=`${p}px ${p}px`,ee=JO([`strokeDasharray`],l,c);return b.createElement(sk,{animationId:x,key:x,canBegin:p>0,duration:l,easing:c,isActive:d,begin:u},e=>{var s=XS(C,i,e),c=XS(w,a,e),l=XS(T,o,e),u=XS(E,n,e),d=XS(D,r,e);f.current&&(h.current=s,g.current=c,_.current=l,v.current=u,y.current=d);var p=e>0?{transition:ee,strokeDasharray:k}:{strokeDasharray:O};return b.createElement(`path`,Sz({},Bx(t),{className:S,d:wz(u,d,s,c,l),ref:f,style:xz(xz({},p),t.style)}))})},Ffe=u(wfe()),Ife=[`option`,`shapeType`,`activeClassName`,`inActiveClassName`];function Lfe(e,t){if(e==null)return{};var n,r,i=Rfe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Rfe(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Tz(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Ez(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Tz(Object(n),!0).forEach(function(t){zfe(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Tz(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function zfe(e,t,n){return(t=Bfe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Bfe(e){var t=Vfe(e,`string`);return typeof t==`symbol`?t:t+``}function Vfe(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Hfe(e,t){return Ez(Ez({},t),e)}function Ufe(e,t){return e===`symbols`}function Dz(e){var{shapeType:t,elementProps:n}=e;switch(t){case`rectangle`:return b.createElement(bk,n);case`trapezoid`:return b.createElement(Pfe,n);case`sector`:return b.createElement(Xk,n);case`symbols`:if(Ufe(t,n))return b.createElement(oC,n);break;case`curve`:return b.createElement(UO,n);default:return null}}function Wfe(e){return(0,b.isValidElement)(e)?e.props:e}function Oz(e){var{option:t,shapeType:n,activeClassName:r=`recharts-active-shape`,inActiveClassName:i=`recharts-shape`}=e,a=Lfe(e,Ife),o;if((0,b.isValidElement)(t))o=(0,b.cloneElement)(t,Ez(Ez({},a),Wfe(t)));else if(typeof t==`function`)o=t(a,a.index);else if((0,Ffe.default)(t)&&typeof t!=`boolean`){var s=Hfe(t,a);o=b.createElement(Dz,{shapeType:n,elementProps:s})}else{var c=a;o=b.createElement(Dz,{shapeType:n,elementProps:c})}return a.isActive?b.createElement(Wx,{className:r},o):b.createElement(Wx,{className:i},o)}var kz=(e,t,n)=>{var r=HC();return(i,a)=>o=>{e?.(i,a,o),r(VI({activeIndex:String(a),activeDataKey:t,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}},Az=e=>{var t=HC();return(n,r)=>i=>{e?.(n,r,i),t(Cle())}},jz=(e,t,n)=>{var r=HC();return(i,a)=>o=>{e?.(i,a,o),r(wle({activeIndex:String(a),activeDataKey:t,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}};function Mz(e){var{tooltipEntrySettings:t}=e,n=HC(),r=sD(),i=(0,b.useRef)(null);return(0,b.useLayoutEffect)(()=>{r||(i.current===null?n(yle(t)):i.current!==t&&n(ble({prev:i.current,next:t})),i.current=t)},[t,n,r]),(0,b.useLayoutEffect)(()=>()=>{i.current&&=(n(xle(i.current)),null)},[n]),null}function Nz(e){var{legendPayload:t}=e,n=HC(),r=sD(),i=(0,b.useRef)(null);return(0,b.useLayoutEffect)(()=>{r||(i.current===null?n(_O(t)):i.current!==t&&n(vO({prev:i.current,next:t})),i.current=t)},[n,r,t]),(0,b.useLayoutEffect)(()=>()=>{i.current&&=(n(yO(i.current)),null)},[n]),null}function Gfe(e){var{legendPayload:t}=e,n=HC(),r=U(TD),i=(0,b.useRef)(null);return(0,b.useLayoutEffect)(()=>{r!==`centric`&&r!==`radial`||(i.current===null?n(_O(t)):i.current!==t&&n(vO({prev:i.current,next:t})),i.current=t)},[n,r,t]),(0,b.useLayoutEffect)(()=>()=>{i.current&&=(n(yO(i.current)),null)},[n]),null}var Kfe=b.useId??(()=>{var[e]=b.useState(()=>qS(`uid-`));return e});function qfe(e,t){var n=Kfe();return t||(e?`${e}-${n}`:n)}var Jfe=(0,b.createContext)(void 0),Pz=e=>{var{id:t,type:n,children:r}=e,i=qfe(`recharts-${n}`,t);return b.createElement(Jfe.Provider,{value:i},r(i))},Fz=aE({name:`graphicalItems`,initialState:{cartesianItems:[],polarItems:[]},reducers:{addCartesianGraphicalItem:{reducer(e,t){e.cartesianItems.push(hO(t.payload))},prepare:tE()},replaceCartesianGraphicalItem:{reducer(e,t){var{prev:n,next:r}=t.payload,i=KT(e).cartesianItems.indexOf(hO(n));i>-1&&(e.cartesianItems[i]=hO(r))},prepare:tE()},removeCartesianGraphicalItem:{reducer(e,t){var n=KT(e).cartesianItems.indexOf(hO(t.payload));n>-1&&e.cartesianItems.splice(n,1)},prepare:tE()},addPolarGraphicalItem:{reducer(e,t){e.polarItems.push(hO(t.payload))},prepare:tE()},removePolarGraphicalItem:{reducer(e,t){var n=KT(e).polarItems.indexOf(hO(t.payload));n>-1&&e.polarItems.splice(n,1)},prepare:tE()},replacePolarGraphicalItem:{reducer(e,t){var{prev:n,next:r}=t.payload,i=KT(e).polarItems.indexOf(hO(n));i>-1&&(e.polarItems[i]=hO(r))},prepare:tE()}}}),{addCartesianGraphicalItem:Yfe,replaceCartesianGraphicalItem:Xfe,removeCartesianGraphicalItem:Zfe,addPolarGraphicalItem:Qfe,removePolarGraphicalItem:$fe,replacePolarGraphicalItem:epe}=Fz.actions,tpe=Fz.reducer,Iz=(0,b.memo)(e=>{var t=HC(),n=(0,b.useRef)(null);return(0,b.useLayoutEffect)(()=>{n.current===null?t(Yfe(e)):n.current!==e&&t(Xfe({prev:n.current,next:e})),n.current=e},[t,e]),(0,b.useLayoutEffect)(()=>()=>{n.current&&=(t(Zfe(n.current)),null)},[t]),null}),npe=(0,b.memo)(e=>{var t=HC(),n=(0,b.useRef)(null);return(0,b.useLayoutEffect)(()=>{n.current===null?t(Qfe(e)):n.current!==e&&t(epe({prev:n.current,next:e})),n.current=e},[t,e]),(0,b.useLayoutEffect)(()=>()=>{n.current&&=(t($fe(n.current)),null)},[t]),null}),rpe=[`key`],ipe=[`onMouseEnter`,`onClick`,`onMouseLeave`],ape=[`id`],ope=[`id`];function Lz(){return Lz=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Lz.apply(null,arguments)}function Rz(e,t){if(e==null)return{};var n,r,i=spe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function spe(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function zz(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Bz(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?zz(Object(n),!0).forEach(function(t){cpe(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):zz(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function cpe(e,t,n){return(t=lpe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function lpe(e){var t=upe(e,`string`);return typeof t==`symbol`?t:t+``}function upe(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function dpe(e){var t=(0,b.useMemo)(()=>vz(e.children,cR),[e.children]),n=U(n=>yfe(n,e.id,t));return n==null?null:b.createElement(Gfe,{legendPayload:n})}function fpe(e){if(!(e==null||typeof e==`boolean`||typeof e==`function`)){if(b.isValidElement(e)){var t=e.props?.fill;return typeof t==`string`?t:void 0}var{fill:n}=e;return typeof n==`string`?n:void 0}}var ppe=b.memo(e=>{var{dataKey:t,nameKey:n,sectors:r,stroke:i,strokeWidth:a,fill:o,name:s,hide:c,tooltipType:l,id:u,activeShape:d}=e,f=fpe(d),p={dataDefinedOnItem:r.map(e=>{var t=e.tooltipPayload;return f==null||t==null?t:t.map(e=>Bz(Bz({},e),{},{color:f,fill:f}))}),getPosition:e=>r[Number(e)]?.tooltipPosition,settings:{stroke:i,strokeWidth:a,fill:o,dataKey:t,nameKey:n,name:YE(s,t),hide:c,type:l,color:o,unit:``,graphicalItemId:u}};return b.createElement(Mz,{tooltipEntrySettings:p})}),mpe=(e,t)=>e>t?`start`:e<t?`end`:`middle`,hpe=(e,t,n)=>JS(typeof t==`function`?t(e):t,n,n*.8),gpe=(e,t,n)=>{var{top:r,left:i,width:a,height:o}=t,s=kk(a,o);return{cx:i+JS(e.cx,a,a/2),cy:r+JS(e.cy,o,o/2),innerRadius:JS(e.innerRadius,s,0),outerRadius:hpe(n,e.outerRadius,s),maxRadius:e.maxRadius||Math.sqrt(a*a+o*o)/2}},_pe=(e,t)=>US(t-e)*Math.min(Math.abs(t-e),360),vpe=(e,t)=>{if(b.isValidElement(e))return b.cloneElement(e,t);if(typeof e==`function`)return e(t);var n=Px(`recharts-pie-label-line`,typeof e==`boolean`?``:e.className),{key:r}=t,i=Rz(t,rpe);return b.createElement(UO,Lz({},i,{type:`linear`,className:n}))},ype=(e,t,n)=>{if(b.isValidElement(e))return b.cloneElement(e,t);var r=n;if(typeof e==`function`&&(r=e(t),b.isValidElement(r)))return r;var i=Px(`recharts-pie-label-text`,cz(e));return b.createElement(NR,Lz({},t,{alignmentBaseline:`middle`,className:i}),r)};function bpe(e){var{sectors:t,props:n,showLabels:r}=e,{label:i,labelLine:a,dataKey:o}=n;if(!r||!i||!t)return null;var s=Rx(n),c=zx(i),l=zx(a),u=typeof i==`object`&&`offsetRadius`in i&&typeof i.offsetRadius==`number`&&i.offsetRadius||20,d=t.map((e,t)=>{var n=(e.startAngle+e.endAngle)/2,r=Ok(e.cx,e.cy,e.outerRadius+u,n),d=Bz(Bz(Bz(Bz({},s),e),{},{stroke:`none`},c),{},{index:t,textAnchor:mpe(r.x,e.cx)},r),f=Bz(Bz(Bz(Bz({},s),e),{},{fill:`none`,stroke:e.fill},l),{},{index:t,points:[Ok(e.cx,e.cy,e.outerRadius,n),r],key:`line`});return b.createElement(WL,{zIndex:PA.label,key:`label-${e.startAngle}-${e.endAngle}-${e.midAngle}-${t}`},b.createElement(Wx,null,a&&vpe(a,f),ype(i,d,RE(e,o))))});return b.createElement(Wx,{className:`recharts-pie-labels`},d)}function xpe(e){var{sectors:t,props:n,showLabels:r}=e,{label:i}=n;return typeof i==`object`&&i&&`position`in i?b.createElement($R,{label:i}):b.createElement(bpe,{sectors:t,props:n,showLabels:r})}function Spe(e){var{sectors:t,activeShape:n,inactiveShape:r,allOtherPieProps:i,shape:a,id:o}=e,s=U(bL),c=U(SL),l=U(CL),{onMouseEnter:u,onClick:d,onMouseLeave:f}=i,p=Rz(i,ipe),m=kz(u,i.dataKey,o),h=Az(f),g=jz(d,i.dataKey,o);return t==null||t.length===0?null:b.createElement(b.Fragment,null,t.map((e,u)=>{if(e?.startAngle===0&&e?.endAngle===0&&t.length!==1)return null;var d=l==null||l===o,f=String(u)===s&&(c==null||i.dataKey===c)&&d,_=n&&f?n:s?r:null,v=Bz(Bz({},e),{},{stroke:e.stroke,tabIndex:-1,[tD]:u,[nD]:o});return b.createElement(Wx,Lz({key:`sector-${e?.startAngle}-${e?.endAngle}-${e.midAngle}-${u}`,tabIndex:-1,className:`recharts-pie-sector`},lC(p,e,u),{onMouseEnter:m(e,u),onMouseLeave:h(e,u),onClick:g(e,u)}),b.createElement(Oz,Lz({option:a??_,index:u,shapeType:`sector`,isActive:f},v)))}))}function Cpe(e){var{pieSettings:t,displayedData:n,cells:r,offset:i}=e,{cornerRadius:a,startAngle:o,endAngle:s,dataKey:c,nameKey:l,tooltipType:u}=t,d=Math.abs(t.minAngle),f=_pe(o,s),p=Math.abs(f),m=n.length<=1?0:t.paddingAngle??0,h=n.filter(e=>RE(e,c,0)!==0).length,g=(p>=360?h:h-1)*m,_=n.reduce((e,t)=>{var n=RE(t,c,0);return e+(H(n)?n:0)},0),v=d>0&&_>0&&n.some(e=>{var t=RE(e,c,0),n=(H(t)?t:0)/_;return t!==0&&n*p<d})?d:0,y=p-h*v-g,b;if(_>0){var x;b=n.map((e,n)=>{var s=RE(e,c,0),d=RE(e,l,n),p=gpe(t,i,e),h=(H(s)?s:0)/_,g,b=Bz(Bz({},e),r&&r[n]&&r[n].props),S=b!=null&&`fill`in b&&typeof b.fill==`string`?b.fill:t.fill;g=n?x.endAngle+US(f)*m*(s===0?0:1):o;var C=g+US(f)*((s===0?0:v)+h*y),w=(g+C)/2,T=(p.innerRadius+p.outerRadius)/2,E=[{name:d,value:s,payload:b,dataKey:c,type:u,color:S,fill:S,graphicalItemId:t.id}],D=Ok(p.cx,p.cy,T,w);return x=Bz(Bz(Bz(Bz({},t.presentationProps),{},{percent:h,cornerRadius:typeof a==`string`?parseFloat(a):a,name:d,tooltipPayload:E,midAngle:w,middleRadius:T,tooltipPosition:D},b),p),{},{value:s,dataKey:c,startAngle:g,endAngle:C,payload:b,paddingAngle:s===0?0:US(f)*m}),x})}return b}function wpe(e){var{showLabels:t,sectors:n,children:r}=e,i=(0,b.useMemo)(()=>!t||!n?[]:n.map(e=>({value:e.value,payload:e.payload,clockWise:!1,parentViewBox:void 0,viewBox:{cx:e.cx,cy:e.cy,innerRadius:e.innerRadius,outerRadius:e.outerRadius,startAngle:e.startAngle,endAngle:e.endAngle,clockWise:!1},fill:e.fill})),[n,t]);return b.createElement(ofe,{value:t?i:void 0},r)}function Tpe(e){var{props:t,previousSectorsRef:n,id:r}=e,{sectors:i,isAnimationActive:a,animationBegin:o,animationDuration:s,animationEasing:c,activeShape:l,inactiveShape:u,onAnimationStart:d,onAnimationEnd:f}=t,p=ck(t,`recharts-pie-`),m=n.current,[h,g]=(0,b.useState)(!1),_=(0,b.useCallback)(()=>{typeof f==`function`&&f(),g(!1)},[f]),v=(0,b.useCallback)(()=>{typeof d==`function`&&d(),g(!0)},[d]);return b.createElement(wpe,{showLabels:!h,sectors:i},b.createElement(sk,{animationId:p,begin:o,duration:s,isActive:a,easing:c,onAnimationStart:v,onAnimationEnd:_,key:p},e=>{var a=[],o=(i&&i[0])?.startAngle??0;return i?.forEach((t,n)=>{var r=m&&m[n],i=n>0?(0,HS.default)(t,`paddingAngle`,0):0;if(r){var s=XS(r.endAngle-r.startAngle,t.endAngle-t.startAngle,e),c=Bz(Bz({},t),{},{startAngle:o+i,endAngle:o+s+i});a.push(c),o=c.endAngle}else{var{endAngle:l,startAngle:u}=t,d=XS(0,l-u,e),f=Bz(Bz({},t),{},{startAngle:o+i,endAngle:o+d+i});a.push(f),o=f.endAngle}}),n.current=a,b.createElement(Wx,null,b.createElement(Spe,{sectors:a,activeShape:l,inactiveShape:u,allOtherPieProps:t,shape:t.shape,id:r}))}),b.createElement(xpe,{showLabels:!h,sectors:i,props:t}),t.children)}var Epe={animationBegin:400,animationDuration:1500,animationEasing:`ease`,cx:`50%`,cy:`50%`,dataKey:`value`,endAngle:360,fill:`#808080`,hide:!1,innerRadius:0,isAnimationActive:`auto`,label:!1,labelLine:!0,legendType:`rect`,minAngle:0,nameKey:`name`,outerRadius:`80%`,paddingAngle:0,rootTabIndex:0,startAngle:0,stroke:`#fff`,zIndex:PA.area};function Dpe(e){var{id:t}=e,n=Rz(e,ape),{hide:r,className:i,rootTabIndex:a}=e,o=(0,b.useMemo)(()=>vz(e.children,cR),[e.children]),s=U(e=>bfe(e,t,o)),c=(0,b.useRef)(null),l=Px(`recharts-pie`,i);return r||s==null?(c.current=null,b.createElement(Wx,{tabIndex:a,className:l})):b.createElement(WL,{zIndex:e.zIndex},b.createElement(ppe,{dataKey:e.dataKey,nameKey:e.nameKey,sectors:s,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,tooltipType:e.tooltipType,id:t,activeShape:e.activeShape}),b.createElement(Wx,{tabIndex:a,className:l},b.createElement(Tpe,{props:Bz(Bz({},n),{},{sectors:s}),previousSectorsRef:c,id:t})))}function Ope(e){var t=dC(e,Epe),{id:n}=t,r=Rz(t,ope),i=Rx(r);return b.createElement(Pz,{id:n,type:`pie`},e=>b.createElement(b.Fragment,null,b.createElement(npe,{type:`pie`,id:e,data:r.data,dataKey:r.dataKey,hide:r.hide,angleAxisId:0,radiusAxisId:0,name:r.name,nameKey:r.nameKey,tooltipType:r.tooltipType,legendType:r.legendType,fill:r.fill,cx:r.cx,cy:r.cy,startAngle:r.startAngle,endAngle:r.endAngle,paddingAngle:r.paddingAngle,minAngle:r.minAngle,innerRadius:r.innerRadius,outerRadius:r.outerRadius,cornerRadius:r.cornerRadius,presentationProps:i,maxRadius:t.maxRadius}),b.createElement(dpe,Lz({},r,{id:e})),b.createElement(Dpe,Lz({},r,{id:e}))))}var Vz=Ope;Vz.displayName=`Pie`;var kpe=[`points`];function Hz(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Uz(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Hz(Object(n),!0).forEach(function(t){Wz(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Hz(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Wz(e,t,n){return(t=Gz(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Gz(e){var t=Kz(e,`string`);return typeof t==`symbol`?t:t+``}function Kz(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function qz(){return qz=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},qz.apply(null,arguments)}function Jz(e,t){if(e==null)return{};var n,r,i=Yz(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Yz(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Xz(e){var{option:t,dotProps:n,className:r}=e;if((0,b.isValidElement)(t))return(0,b.cloneElement)(t,n);if(typeof t==`function`)return t(n);var i=Px(r,typeof t==`boolean`?``:t.className),a=n??{},{points:o}=a,s=Jz(a,kpe);return b.createElement(tz,qz({},s,{className:i}))}function Zz(e,t){return e==null?!1:t?!0:e.length===1}function Qz(e){var{points:t,dot:n,className:r,dotClassName:i,dataKey:a,baseProps:o,needClip:s,clipPathId:c,zIndex:l=PA.scatter}=e;if(!Zz(t,n))return null;var u=yz(n),d=ine(n),f=t.map((e,r)=>{var s=Uz(Uz(Uz({r:3},o),d),{},{index:r,cx:e.x??void 0,cy:e.y??void 0,dataKey:a,value:e.value,payload:e.payload,points:t});return b.createElement(Xz,{key:`dot-${r}`,option:n,dotProps:s,className:i})}),p={};return s&&c!=null&&(p.clipPath=`url(#clipPath-${u?``:`dots-`}${c})`),b.createElement(WL,{zIndex:l},b.createElement(Wx,qz({className:r},p),f))}function $z(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function eB(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?$z(Object(n),!0).forEach(function(t){tB(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):$z(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function tB(e,t,n){return(t=nB(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function nB(e){var t=rB(e,`string`);return typeof t==`symbol`?t:t+``}function rB(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var iB=aE({name:`cartesianAxis`,initialState:{xAxis:{},yAxis:{},zAxis:{}},reducers:{addXAxis:{reducer(e,t){e.xAxis[t.payload.id]=hO(t.payload)},prepare:tE()},replaceXAxis:{reducer(e,t){var{prev:n,next:r}=t.payload;e.xAxis[n.id]!==void 0&&(n.id!==r.id&&delete e.xAxis[n.id],e.xAxis[r.id]=hO(r))},prepare:tE()},removeXAxis:{reducer(e,t){delete e.xAxis[t.payload.id]},prepare:tE()},addYAxis:{reducer(e,t){e.yAxis[t.payload.id]=hO(t.payload)},prepare:tE()},replaceYAxis:{reducer(e,t){var{prev:n,next:r}=t.payload;e.yAxis[n.id]!==void 0&&(n.id!==r.id&&delete e.yAxis[n.id],e.yAxis[r.id]=hO(r))},prepare:tE()},removeYAxis:{reducer(e,t){delete e.yAxis[t.payload.id]},prepare:tE()},addZAxis:{reducer(e,t){e.zAxis[t.payload.id]=hO(t.payload)},prepare:tE()},replaceZAxis:{reducer(e,t){var{prev:n,next:r}=t.payload;e.zAxis[n.id]!==void 0&&(n.id!==r.id&&delete e.zAxis[n.id],e.zAxis[r.id]=hO(r))},prepare:tE()},removeZAxis:{reducer(e,t){delete e.zAxis[t.payload.id]},prepare:tE()},updateYAxisWidth(e,t){var{id:n,width:r}=t.payload,i=e.yAxis[n];if(i){var a=i.widthHistory||[];if(a.length===3&&a[0]===a[2]&&r===a[1]&&r!==i.width&&Math.abs(r-(a[0]??0))<=1)return;var o=[...a,r].slice(-3);e.yAxis[n]=eB(eB({},i),{},{width:r,widthHistory:o})}}}}),{addXAxis:aB,replaceXAxis:oB,removeXAxis:sB,addYAxis:cB,replaceYAxis:lB,removeYAxis:uB,addZAxis:dB,replaceZAxis:fB,removeZAxis:pB,updateYAxisWidth:mB}=iB.actions,hB=iB.reducer,gB=W([W([aD],e=>({top:e.top,bottom:e.bottom,left:e.left,right:e.right})),XE,ZE],(e,t,n)=>{if(!(!e||t==null||n==null))return{x:e.left,y:e.top,width:Math.max(0,t-e.left-e.right),height:Math.max(0,n-e.top-e.bottom)}}),_B=()=>U(gB),vB=()=>U($le);function yB(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function bB(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?yB(Object(n),!0).forEach(function(t){xB(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):yB(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function xB(e,t,n){return(t=SB(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function SB(e){var t=CB(e,`string`);return typeof t==`symbol`?t:t+``}function CB(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var wB=e=>{var{point:t,childIndex:n,mainColor:r,activeDot:i,dataKey:a,clipPath:o}=e;if(i===!1||t.x==null||t.y==null)return null;var s=bB(bB(bB({},{index:n,dataKey:a,cx:t.x,cy:t.y,r:4,fill:r??`none`,strokeWidth:2,stroke:`#fff`,payload:t.payload,value:t.value}),zx(i)),cC(i)),c=(0,b.isValidElement)(i)?(0,b.cloneElement)(i,s):typeof i==`function`?i(s):b.createElement(tz,s);return b.createElement(Wx,{className:`recharts-active-dot`,clipPath:o},c)};function TB(e){var{points:t,mainColor:n,activeDot:r,itemDataKey:i,clipPath:a,zIndex:o=PA.activeDot}=e,s=U(bL),c=vB();if(t==null||c==null)return null;var l=t.find(e=>c.includes(e.payload));return QS(l)?null:b.createElement(WL,{zIndex:o},b.createElement(wB,{point:l,childIndex:Number(s),mainColor:n,dataKey:i,activeDot:r,clipPath:a}))}var EB=(e,t,n)=>{var r=n??e;if(!QS(r))return JS(r,t,0)},DB=(e,t,n)=>{var r={},i=e.filter(aj),a=e.filter(e=>e.stackId==null),o=i.reduce((e,t)=>{var n=e[t.stackId];return n??=[],n.push(t),e[t.stackId]=n,e},r),s=Object.entries(o).map(e=>{var[r,i]=e;return{stackId:r,dataKeys:i.map(e=>e.dataKey),barSize:EB(t,n,i[0]?.barSize)}}),c=a.map(e=>({stackId:void 0,dataKeys:[e.dataKey].filter(e=>e!=null),barSize:EB(t,n,e.barSize)}));return[...s,...c]};function OB(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function kB(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?OB(Object(n),!0).forEach(function(t){AB(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):OB(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function AB(e,t,n){return(t=jB(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function jB(e){var t=MB(e,`string`);return typeof t==`symbol`?t:t+``}function MB(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function NB(e,t,n,r,i){var a=r.length;if(!(a<1)){var o=JS(e,n,0,!0),s,c=[];if(PE(r[0]?.barSize)){var l=!1,u=n/a,d=r.reduce((e,t)=>e+(t.barSize||0),0);d+=(a-1)*o,d>=n&&(d-=(a-1)*o,o=0),d>=n&&u>0&&(l=!0,u*=.9,d=a*u);var f={offset:((n-d)/2>>0)-o,size:0};s=r.reduce((e,t)=>{var n={stackId:t.stackId,dataKeys:t.dataKeys,position:{offset:f.offset+f.size+o,size:l?u:t.barSize??0}},r=[...e,n];return f=n.position,r},c)}else{var p=JS(t,n,0,!0);n-2*p-(a-1)*o<=0&&(o=0);var m=(n-2*p-(a-1)*o)/a;m>1&&(m>>=0);var h=PE(i)?Math.min(m,i):m;s=r.reduce((e,t,n)=>[...e,{stackId:t.stackId,dataKeys:t.dataKeys,position:{offset:p+(m+o)*n+(m-h)/2,size:h}}],c)}return s}}var PB=(e,t,n,r,i,a,o)=>{var s=QS(o)?t:o,c=NB(n,r,i===a?a:i,e,s);return i!==a&&c!=null&&(c=c.map(e=>kB(kB({},e),{},{position:kB(kB({},e.position),{},{offset:e.position.offset-i/2})}))),c},FB=(e,t)=>{var n=rj(t);if(!(!e||n==null||t==null)){var{stackId:r}=t;if(r!=null){var i=e[r];if(i){var{stackedData:a}=i;if(a)return a.find(e=>e.key===n)}}}},IB=(e,t)=>{if(!(e==null||t==null)){var n=e.find(e=>e.stackId===t.stackId&&t.dataKey!=null&&e.dataKeys.includes(t.dataKey));if(n!=null)return n.position}};function LB(e,t){return e&&typeof e==`object`&&`zIndex`in e&&typeof e.zIndex==`number`&&PE(e.zIndex)?e.zIndex:t}var RB=e=>{var{chartData:t}=e,n=HC(),r=sD();return(0,b.useEffect)(()=>r?()=>{}:(n(tR(t)),()=>{n(tR(void 0))}),[t,n,r]),null},zB={x:0,y:0,width:0,height:0,padding:{top:0,right:0,bottom:0,left:0}},BB=aE({name:`brush`,initialState:zB,reducers:{setBrushSettings(e,t){return t.payload==null?zB:t.payload}}}),{setBrushSettings:Ape}=BB.actions,VB=BB.reducer,HB=(e,t)=>{var{x:n,y:r}=e,{x:i,y:a}=t;return{x:Math.min(n,i),y:Math.min(r,a),width:Math.abs(i-n),height:Math.abs(a-r)}},UB=e=>{var{x1:t,y1:n,x2:r,y2:i}=e;return HB({x:t,y:n},{x:r,y:i})};function WB(e){return(e%180+180)%180}var GB=function(e){var{width:t,height:n}=e,r=WB(arguments.length>1&&arguments[1]!==void 0?arguments[1]:0)*Math.PI/180,i=Math.atan(n/t),a=r>i&&r<Math.PI-i?n/Math.sin(r):t/Math.cos(r);return Math.abs(a)},KB=aE({name:`referenceElements`,initialState:{dots:[],areas:[],lines:[]},reducers:{addDot:(e,t)=>{e.dots.push(t.payload)},removeDot:(e,t)=>{var n=KT(e).dots.findIndex(e=>e===t.payload);n!==-1&&e.dots.splice(n,1)},addArea:(e,t)=>{e.areas.push(t.payload)},removeArea:(e,t)=>{var n=KT(e).areas.findIndex(e=>e===t.payload);n!==-1&&e.areas.splice(n,1)},addLine:(e,t)=>{e.lines.push(hO(t.payload))},removeLine:(e,t)=>{var n=KT(e).lines.findIndex(e=>e===t.payload);n!==-1&&e.lines.splice(n,1)}}}),{addDot:jpe,removeDot:Mpe,addArea:Npe,removeArea:Ppe,addLine:qB,removeLine:JB}=KB.actions,YB=KB.reducer,XB=(0,b.createContext)(void 0),ZB=e=>{var{children:t}=e,[n]=(0,b.useState)(`${qS(`recharts`)}-clip`),r=_B();if(r==null)return null;var{x:i,y:a,width:o,height:s}=r;return b.createElement(XB.Provider,{value:n},b.createElement(`defs`,null,b.createElement(`clipPath`,{id:n},b.createElement(`rect`,{x:i,y:a,height:s,width:o}))),t)},QB=()=>(0,b.useContext)(XB),$B=class{constructor(e){var{x:t,y:n}=e;this.xAxisScale=t,this.yAxisScale=n}map(e,t){var{position:n}=t;return{x:this.xAxisScale.map(e.x,{position:n})??0,y:this.yAxisScale.map(e.y,{position:n})??0}}mapWithFallback(e,t){var{position:n,fallback:r}=t,i=r===`rangeMin`?this.yAxisScale.rangeMin():r===`rangeMax`?this.yAxisScale.rangeMax():0,a=r===`rangeMin`?this.xAxisScale.rangeMin():r===`rangeMax`?this.xAxisScale.rangeMax():0;return{x:this.xAxisScale.map(e.x,{position:n})??a,y:this.yAxisScale.map(e.y,{position:n})??i}}isInRange(e){var{x:t,y:n}=e,r=t==null||this.xAxisScale.isInRange(t),i=n==null||this.yAxisScale.isInRange(n);return r&&i}};function eV(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function tV(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?eV(Object(n),!0).forEach(function(t){nV(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):eV(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function nV(e,t,n){return(t=rV(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function rV(e){var t=iV(e,`string`);return typeof t==`symbol`?t:t+``}function iV(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function aV(){return aV=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},aV.apply(null,arguments)}var oV=(e,t)=>{var n;if(b.isValidElement(e))n=b.cloneElement(e,t);else if(typeof e==`function`)n=e(t);else{if(!PE(t.x1)||!PE(t.y1)||!PE(t.x2)||!PE(t.y2))return null;n=b.createElement(`line`,aV({},t,{className:`recharts-reference-line-line`}))}return n},sV=(e,t,n,r,i,a)=>{var{x:o,width:s}=a,c=i.map(e,{position:n});if(!PE(c)||t===`discard`&&!i.isInRange(c))return null;var l=[{x:o+s,y:c},{x:o,y:c}];return r===`left`?l.reverse():l},cV=(e,t,n,r,i,a)=>{var{y:o,height:s}=a,c=i.map(e,{position:n});if(!PE(c)||t===`discard`&&!i.isInRange(c))return null;var l=[{x:c,y:o+s},{x:c,y:o}];return r===`top`?l.reverse():l},lV=(e,t,n,r)=>{var i=[r.mapWithFallback(e[0],{position:n,fallback:`rangeMin`}),r.mapWithFallback(e[1],{position:n,fallback:`rangeMax`})];return t===`discard`&&i.some(e=>!r.isInRange(e))?null:i},uV=(e,t,n,r,i,a,o)=>{var{x:s,y:c,segment:l,ifOverflow:u}=o,d=KS(s);return KS(c)?sV(c,u,r,a,t,n):d?cV(s,u,r,i,e,n):l!=null&&l.length===2?lV(l,u,r,new $B({x:e,y:t})):null};function dV(e){var t=HC();return(0,b.useEffect)(()=>(t(qB(e)),()=>{t(JB(e))})),null}function fV(e){var{xAxisId:t,yAxisId:n,shape:r,className:i,ifOverflow:a}=e,o=sD(),s=QB(),c=U(e=>_F(e,t)),l=U(e=>bF(e,n)),u=U(e=>bI(e,`xAxis`,t,o)),d=U(e=>bI(e,`yAxis`,n,o)),f=xD();if(!s||!f||c==null||l==null||u==null||d==null)return null;var p=uV(u,d,f,e.position,c.orientation,l.orientation,e);if(!p)return null;var m=p[0],h=p[1];if(m==null||h==null)return null;var{x:g,y:_}=m,{x:v,y}=h,x=tV(tV({clipPath:a===`hidden`?`url(#${s})`:void 0},Bx(e)),{},{x1:g,y1:_,x2:v,y2:y}),S=UB({x1:g,y1:_,x2:v,y2:y});return b.createElement(WL,{zIndex:e.zIndex},b.createElement(Wx,{className:Px(`recharts-reference-line`,i)},oV(r,x),b.createElement(VR,aV({},S,{lowerWidth:S.width,upperWidth:S.width}),b.createElement(KR,{label:e.label}),e.children)))}var pV={ifOverflow:`discard`,xAxisId:0,yAxisId:0,fill:`none`,label:!1,stroke:`#ccc`,fillOpacity:1,strokeWidth:1,position:`middle`,zIndex:PA.line};function mV(e){var t=dC(e,pV);return b.createElement(b.Fragment,null,b.createElement(dV,{yAxisId:t.yAxisId,xAxisId:t.xAxisId,ifOverflow:t.ifOverflow,x:t.x,y:t.y,segment:t.segment}),b.createElement(fV,t))}mV.displayName=`ReferenceLine`;function hV(e,t){if(t<1)return[];if(t===1)return e;for(var n=[],r=0;r<e.length;r+=t){var i=e[r];i!==void 0&&n.push(i)}return n}function gV(e,t,n){return GB({width:e.width+t.width,height:e.height+t.height},n)}function _V(e,t,n){var r=n===`width`,{x:i,y:a,width:o,height:s}=e;return t===1?{start:r?i:a,end:r?i+o:a+s}:{start:r?i+o:a+s,end:r?i:a}}function vV(e,t,n,r,i){if(e*t<e*r||e*t>e*i)return!1;var a=n();return e*(t-e*a/2-r)>=0&&e*(t+e*a/2-i)<=0}function yV(e,t){return hV(e,t+1)}function bV(e,t,n,r,i){for(var a=(r||[]).slice(),{start:o,end:s}=t,c=0,l=1,u=o,d=function(){var t=r?.[c];if(t===void 0)return{v:hV(r,l)};var a=c,d,f=()=>(d===void 0&&(d=n(t,a)),d),p=t.coordinate,m=c===0||vV(e,p,f,u,s);m||(c=0,u=o,l+=1),m&&(u=p+e*(f()/2+i),c+=l)},f;l<=a.length;)if(f=d(),f)return f.v;return[]}function xV(e,t,n,r,i){var a=(r||[]).slice().length;if(a===0)return[];for(var{start:o,end:s}=t,c=1;c<=a;c++){for(var l=(a-1)%c,u=o,d=!0,f=function(){var t=r[m];if(t==null)return 0;var a=m,o,c=()=>(o===void 0&&(o=n(t,a)),o),f=t.coordinate,p=m===l||vV(e,f,c,u,s);if(!p)return d=!1,1;p&&(u=f+e*(c()/2+i))},p,m=l;m<a&&(p=f(),!(p!==0&&p===1));m+=c);if(d){for(var h=[],g=l;g<a;g+=c){var _=r[g];_!=null&&h.push(_)}return h}}return[]}function SV(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function CV(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?SV(Object(n),!0).forEach(function(t){wV(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):SV(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function wV(e,t,n){return(t=TV(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function TV(e){var t=EV(e,`string`);return typeof t==`symbol`?t:t+``}function EV(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function DV(e,t,n,r,i){for(var a=(r||[]).slice(),o=a.length,{start:s}=t,{end:c}=t,l=function(t){var r=a[t];if(r==null)return 1;var l=r,u,d=()=>(u===void 0&&(u=n(r,t)),u);if(t===o-1){var f=e*(l.coordinate+e*d()/2-c);a[t]=l=CV(CV({},l),{},{tickCoord:f>0?l.coordinate-f*e:l.coordinate})}else a[t]=l=CV(CV({},l),{},{tickCoord:l.coordinate});l.tickCoord!=null&&vV(e,l.tickCoord,d,s,c)&&(c=l.tickCoord-e*(d()/2+i),a[t]=CV(CV({},l),{},{isShow:!0}))},u=o-1;u>=0;u--)if(l(u))continue;return a}function OV(e,t,n,r,i,a){var o=(r||[]).slice(),s=o.length,{start:c,end:l}=t;if(a){var u=r[s-1];if(u!=null){var d=n(u,s-1),f=e*(u.coordinate+e*d/2-l);o[s-1]=u=CV(CV({},u),{},{tickCoord:f>0?u.coordinate-f*e:u.coordinate}),u.tickCoord!=null&&vV(e,u.tickCoord,()=>d,c,l)&&(l=u.tickCoord-e*(d/2+i),o[s-1]=CV(CV({},u),{},{isShow:!0}))}}for(var p=a?s-1:s,m=function(t){var r=o[t];if(r==null)return 1;var a=r,s,u=()=>(s===void 0&&(s=n(r,t)),s);if(t===0){var d=e*(a.coordinate-e*u()/2-c);o[t]=a=CV(CV({},a),{},{tickCoord:d<0?a.coordinate-d*e:a.coordinate})}else o[t]=a=CV(CV({},a),{},{tickCoord:a.coordinate});a.tickCoord!=null&&vV(e,a.tickCoord,u,c,l)&&(c=a.tickCoord+e*(u()/2+i),o[t]=CV(CV({},a),{},{isShow:!0}))},h=0;h<p;h++)if(m(h))continue;return o}function kV(e,t,n){var{tick:r,ticks:i,viewBox:a,minTickGap:o,orientation:s,interval:c,tickFormatter:l,unit:u,angle:d}=e;if(!i||!i.length||!r)return[];if(H(c)||kO.isSsr)return yV(i,H(c)?c:0)??[];var f=[],p=s===`top`||s===`bottom`?`width`:`height`,m=u&&p===`width`?mR(u,{fontSize:t,letterSpacing:n}):{width:0,height:0},h=(e,r)=>{var i=typeof l==`function`?l(e.value,r):e.value;return p===`width`?gV(mR(i,{fontSize:t,letterSpacing:n}),m,d):mR(i,{fontSize:t,letterSpacing:n})[p]},g=i[0],_=i[1],v=i.length>=2&&g!=null&&_!=null?US(_.coordinate-g.coordinate):1,y=_V(a,v,p);return c===`equidistantPreserveStart`?bV(v,y,h,i,o):c===`equidistantPreserveEnd`?xV(v,y,h,i,o):(f=c===`preserveStart`||c===`preserveStartEnd`?OV(v,y,h,i,o,c===`preserveStartEnd`):DV(v,y,h,i,o),f.filter(e=>e.isShow))}var AV=e=>{var{ticks:t,label:n,labelGapWithTick:r=5,tickSize:i=0,tickMargin:a=0}=e,o=0;if(t){Array.from(t).forEach(e=>{if(e){var t=e.getBoundingClientRect();t.width>o&&(o=t.width)}});var s=n?n.getBoundingClientRect().width:0,c=i+a,l=o+c+s+(n?r:0);return Math.round(l)}return 0},jV=aE({name:`renderedTicks`,initialState:{xAxis:{},yAxis:{}},reducers:{setRenderedTicks:(e,t)=>{var{axisType:n,axisId:r,ticks:i}=t.payload;e[n][r]=hO(i)},removeRenderedTicks:(e,t)=>{var{axisType:n,axisId:r}=t.payload;delete e[n][r]}}}),{setRenderedTicks:MV,removeRenderedTicks:NV}=jV.actions,PV=jV.reducer,FV=[`axisLine`,`width`,`height`,`className`,`hide`,`ticks`,`axisType`,`axisId`];function IV(e,t){if(e==null)return{};var n,r,i=LV(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function LV(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function RV(){return RV=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},RV.apply(null,arguments)}function zV(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function BV(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?zV(Object(n),!0).forEach(function(t){VV(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):zV(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function VV(e,t,n){return(t=HV(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function HV(e){var t=UV(e,`string`);return typeof t==`symbol`?t:t+``}function UV(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var WV={x:0,y:0,width:0,height:0,viewBox:{x:0,y:0,width:0,height:0},orientation:`bottom`,ticks:[],stroke:`#666`,tickLine:!0,axisLine:!0,tick:!0,mirror:!1,minTickGap:5,tickSize:6,tickMargin:2,interval:`preserveEnd`,zIndex:PA.axis};function GV(e){var{x:t,y:n,width:r,height:i,orientation:a,mirror:o,axisLine:s,otherSvgProps:c}=e;if(!s)return null;var l=BV(BV(BV({},c),Rx(s)),{},{fill:`none`});if(a===`top`||a===`bottom`){var u=+(a===`top`&&!o||a===`bottom`&&o);l=BV(BV({},l),{},{x1:t,y1:n+u*i,x2:t+r,y2:n+u*i})}else{var d=+(a===`left`&&!o||a===`right`&&o);l=BV(BV({},l),{},{x1:t+d*r,y1:n,x2:t+d*r,y2:n+i})}return b.createElement(`line`,RV({},l,{className:Px(`recharts-cartesian-axis-line`,(0,HS.default)(s,`className`))}))}function KV(e,t,n,r,i,a,o,s,c){var l,u,d,f,p,m,h=s?-1:1,g=e.tickSize||o,_=H(e.tickCoord)?e.tickCoord:e.coordinate;switch(a){case`top`:l=u=e.coordinate,f=n+ +!s*i,d=f-h*g,m=d-h*c,p=_;break;case`left`:d=f=e.coordinate,u=t+ +!s*r,l=u-h*g,p=l-h*c,m=_;break;case`right`:d=f=e.coordinate,u=t+ +s*r,l=u+h*g,p=l+h*c,m=_;break;default:l=u=e.coordinate,f=n+ +s*i,d=f+h*g,m=d+h*c,p=_;break}return{line:{x1:l,y1:d,x2:u,y2:f},tick:{x:p,y:m}}}function qV(e,t){switch(e){case`left`:return t?`start`:`end`;case`right`:return t?`end`:`start`;default:return`middle`}}function JV(e,t){switch(e){case`left`:case`right`:return`middle`;case`top`:return t?`start`:`end`;default:return t?`end`:`start`}}function YV(e){var{option:t,tickProps:n,value:r}=e,i,a=Px(n.className,`recharts-cartesian-axis-tick-value`);if(b.isValidElement(t))i=b.cloneElement(t,BV(BV({},n),{},{className:a}));else if(typeof t==`function`)i=t(BV(BV({},n),{},{className:a}));else{var o=`recharts-cartesian-axis-tick-value`;typeof t!=`boolean`&&(o=Px(o,cz(t))),i=b.createElement(NR,RV({},n,{className:o}),r)}return i}function XV(e){var{ticks:t,axisType:n,axisId:r}=e,i=HC();return(0,b.useEffect)(()=>r==null||n==null?tC:(i(MV({ticks:t.map(e=>({value:e.value,coordinate:e.coordinate,offset:e.offset,index:e.index})),axisId:r,axisType:n})),()=>{i(NV({axisId:r,axisType:n}))}),[i,t,r,n]),null}var ZV=(0,b.forwardRef)((e,t)=>{var{ticks:n=[],tick:r,tickLine:i,stroke:a,tickFormatter:o,unit:s,padding:c,tickTextProps:l,orientation:u,mirror:d,x:f,y:p,width:m,height:h,tickSize:g,tickMargin:_,fontSize:v,letterSpacing:y,getTicksConfig:x,events:S,axisType:C,axisId:w}=e,T=kV(BV(BV({},x),{},{ticks:n}),v,y),E=Rx(x),D=zx(r),O=DR(E.textAnchor)?E.textAnchor:qV(u,d),k=JV(u,d),ee={};typeof i==`object`&&(ee=i);var te=BV(BV({},E),{},{fill:`none`},ee),ne=T.map(e=>BV({entry:e},KV(e,f,p,m,h,u,g,d,_))),re=ne.map(e=>{var{entry:t,line:n}=e;return b.createElement(Wx,{className:`recharts-cartesian-axis-tick`,key:`tick-${t.value}-${t.coordinate}-${t.tickCoord}`},i&&b.createElement(`line`,RV({},te,n,{className:Px(`recharts-cartesian-axis-tick-line`,(0,HS.default)(i,`className`))})))}),A=ne.map((e,t)=>{var{entry:n,tick:i}=e,u=BV(BV({},BV(BV(BV(BV({verticalAnchor:k},E),{},{textAnchor:O,stroke:`none`,fill:a},i),{},{index:t,payload:n,visibleTicksCount:T.length,tickFormatter:o,padding:c},l),{},{angle:l?.angle??E.angle??0})),D);return b.createElement(Wx,RV({className:`recharts-cartesian-axis-tick-label`,key:`tick-label-${n.value}-${n.coordinate}-${n.tickCoord}`},lC(S,n,t)),r&&b.createElement(YV,{option:r,tickProps:u,value:`${typeof o==`function`?o(n.value,t):n.value}${s||``}`}))});return b.createElement(`g`,{className:`recharts-cartesian-axis-ticks recharts-${C}-ticks`},b.createElement(XV,{ticks:T,axisId:w,axisType:C}),A.length>0&&b.createElement(WL,{zIndex:PA.label},b.createElement(`g`,{className:`recharts-cartesian-axis-tick-labels recharts-${C}-tick-labels`,ref:t},A)),re.length>0&&b.createElement(`g`,{className:`recharts-cartesian-axis-tick-lines recharts-${C}-tick-lines`},re))}),QV=(0,b.forwardRef)((e,t)=>{var{axisLine:n,width:r,height:i,className:a,hide:o,ticks:s,axisType:c,axisId:l}=e,u=IV(e,FV),[d,f]=(0,b.useState)(``),[p,m]=(0,b.useState)(``),h=(0,b.useRef)(null);(0,b.useImperativeHandle)(t,()=>({getCalculatedWidth:()=>AV({ticks:h.current,label:e.labelRef?.current,labelGapWithTick:5,tickSize:e.tickSize,tickMargin:e.tickMargin})}));var g=(0,b.useCallback)(e=>{if(e){var t=e.getElementsByClassName(`recharts-cartesian-axis-tick-value`);h.current=t;var n=t[0];if(n){var r=window.getComputedStyle(n),i=r.fontSize,a=r.letterSpacing;(i!==d||a!==p)&&(f(i),m(a))}}},[d,p]);return o||r!=null&&r<=0||i!=null&&i<=0?null:b.createElement(WL,{zIndex:e.zIndex},b.createElement(Wx,{className:Px(`recharts-cartesian-axis`,a)},b.createElement(GV,{x:e.x,y:e.y,width:r,height:i,orientation:e.orientation,mirror:e.mirror,axisLine:n,otherSvgProps:Rx(e)}),b.createElement(ZV,{ref:g,axisType:c,events:u,fontSize:d,getTicksConfig:e,height:e.height,letterSpacing:p,mirror:e.mirror,orientation:e.orientation,padding:e.padding,stroke:e.stroke,tick:e.tick,tickFormatter:e.tickFormatter,tickLine:e.tickLine,tickMargin:e.tickMargin,tickSize:e.tickSize,tickTextProps:e.tickTextProps,ticks:s,unit:e.unit,width:e.width,x:e.x,y:e.y,axisId:l}),b.createElement(VR,{x:e.x,y:e.y,width:e.width,height:e.height,lowerWidth:e.width,upperWidth:e.width},b.createElement(KR,{label:e.label,labelRef:e.labelRef}),e.children)))}),$V=b.forwardRef((e,t)=>{var n=dC(e,WV);return b.createElement(QV,RV({},n,{ref:t}))});$V.displayName=`CartesianAxis`;var eH=[`x1`,`y1`,`x2`,`y2`,`key`],tH=[`offset`],nH=[`xAxisId`,`yAxisId`],rH=[`xAxisId`,`yAxisId`];function iH(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function aH(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?iH(Object(n),!0).forEach(function(t){oH(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):iH(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function oH(e,t,n){return(t=sH(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function sH(e){var t=cH(e,`string`);return typeof t==`symbol`?t:t+``}function cH(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function lH(){return lH=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},lH.apply(null,arguments)}function uH(e,t){if(e==null)return{};var n,r,i=dH(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function dH(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var fH=e=>{var{fill:t}=e;if(!t||t===`none`)return null;var{fillOpacity:n,x:r,y:i,width:a,height:o,ry:s}=e;return b.createElement(`rect`,{x:r,y:i,ry:s,width:a,height:o,stroke:`none`,fill:t,fillOpacity:n,className:`recharts-cartesian-grid-bg`})};function pH(e){var{option:t,lineItemProps:n}=e,r;if(b.isValidElement(t))r=b.cloneElement(t,n);else if(typeof t==`function`)r=t(n);else{var{x1:i,y1:a,x2:o,y2:s,key:c}=n,l=Rx(uH(n,eH))??{},{offset:u}=l,d=uH(l,tH);r=b.createElement(`line`,lH({},d,{x1:i,y1:a,x2:o,y2:s,fill:`none`,key:c}))}return r}function mH(e){var{x:t,width:n,horizontal:r=!0,horizontalPoints:i}=e;if(!r||!i||!i.length)return null;var{xAxisId:a,yAxisId:o}=e,s=uH(e,nH),c=i.map((e,i)=>{var a=aH(aH({},s),{},{x1:t,y1:e,x2:t+n,y2:e,key:`line-${i}`,index:i});return b.createElement(pH,{key:`line-${i}`,option:r,lineItemProps:a})});return b.createElement(`g`,{className:`recharts-cartesian-grid-horizontal`},c)}function hH(e){var{y:t,height:n,vertical:r=!0,verticalPoints:i}=e;if(!r||!i||!i.length)return null;var{xAxisId:a,yAxisId:o}=e,s=uH(e,rH),c=i.map((e,i)=>{var a=aH(aH({},s),{},{x1:e,y1:t,x2:e,y2:t+n,key:`line-${i}`,index:i});return b.createElement(pH,{option:r,lineItemProps:a,key:`line-${i}`})});return b.createElement(`g`,{className:`recharts-cartesian-grid-vertical`},c)}function gH(e){var{horizontalFill:t,fillOpacity:n,x:r,y:i,width:a,height:o,horizontalPoints:s,horizontal:c=!0}=e;if(!c||!t||!t.length||s==null)return null;var l=s.map(e=>Math.round(e+i-i)).sort((e,t)=>e-t);i!==l[0]&&l.unshift(0);var u=l.map((e,s)=>{var c=l[s+1],u=c==null?i+o-e:c-e;if(u<=0)return null;var d=s%t.length;return b.createElement(`rect`,{key:`react-${s}`,y:e,x:r,height:u,width:a,stroke:`none`,fill:t[d],fillOpacity:n,className:`recharts-cartesian-grid-bg`})});return b.createElement(`g`,{className:`recharts-cartesian-gridstripes-horizontal`},u)}function _H(e){var{vertical:t=!0,verticalFill:n,fillOpacity:r,x:i,y:a,width:o,height:s,verticalPoints:c}=e;if(!t||!n||!n.length)return null;var l=c.map(e=>Math.round(e+i-i)).sort((e,t)=>e-t);i!==l[0]&&l.unshift(0);var u=l.map((e,t)=>{var c=l[t+1],u=c==null?i+o-e:c-e;if(u<=0)return null;var d=t%n.length;return b.createElement(`rect`,{key:`react-${t}`,x:e,y:a,width:u,height:s,stroke:`none`,fill:n[d],fillOpacity:r,className:`recharts-cartesian-grid-bg`})});return b.createElement(`g`,{className:`recharts-cartesian-gridstripes-vertical`},u)}var vH=(e,t)=>{var{xAxis:n,width:r,height:i,offset:a}=e;return BE(kV(aH(aH(aH({},WV),n),{},{ticks:VE(n,!0),viewBox:{x:0,y:0,width:r,height:i}})),a.left,a.left+a.width,t)},yH=(e,t)=>{var{yAxis:n,width:r,height:i,offset:a}=e;return BE(kV(aH(aH(aH({},WV),n),{},{ticks:VE(n,!0),viewBox:{x:0,y:0,width:r,height:i}})),a.top,a.top+a.height,t)},bH={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:`#ccc`,fill:`none`,verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:PA.grid};function xH(e){var t=CD(),n=wD(),r=SD(),i=aH(aH({},dC(e,bH)),{},{x:H(e.x)?e.x:r.left,y:H(e.y)?e.y:r.top,width:H(e.width)?e.width:r.width,height:H(e.height)?e.height:r.height}),{xAxisId:a,yAxisId:o,x:s,y:c,width:l,height:u,syncWithTicks:d,horizontalValues:f,verticalValues:p}=i,m=sD(),h=U(e=>AI(e,`xAxis`,a,m)),g=U(e=>AI(e,`yAxis`,o,m));if(!FE(l)||!FE(u)||!H(s)||!H(c))return null;var _=i.verticalCoordinatesGenerator||vH,v=i.horizontalCoordinatesGenerator||yH,{horizontalPoints:y,verticalPoints:x}=i;if((!y||!y.length)&&typeof v==`function`){var S=f&&f.length,C=v({yAxis:g?aH(aH({},g),{},{ticks:S?f:g.ticks}):void 0,width:t??l,height:n??u,offset:r},S?!0:d);uD(Array.isArray(C),`horizontalCoordinatesGenerator should return Array but instead it returned [${typeof C}]`),Array.isArray(C)&&(y=C)}if((!x||!x.length)&&typeof _==`function`){var w=p&&p.length,T=_({xAxis:h?aH(aH({},h),{},{ticks:w?p:h.ticks}):void 0,width:t??l,height:n??u,offset:r},w?!0:d);uD(Array.isArray(T),`verticalCoordinatesGenerator should return Array but instead it returned [${typeof T}]`),Array.isArray(T)&&(x=T)}return b.createElement(WL,{zIndex:i.zIndex},b.createElement(`g`,{className:`recharts-cartesian-grid`},b.createElement(fH,{fill:i.fill,fillOpacity:i.fillOpacity,x:i.x,y:i.y,width:i.width,height:i.height,ry:i.ry}),b.createElement(gH,lH({},i,{horizontalPoints:y})),b.createElement(_H,lH({},i,{verticalPoints:x})),b.createElement(mH,lH({},i,{offset:r,horizontalPoints:y,xAxis:h,yAxis:g})),b.createElement(hH,lH({},i,{offset:r,verticalPoints:x,xAxis:h,yAxis:g}))))}xH.displayName=`CartesianGrid`;var SH=aE({name:`errorBars`,initialState:{},reducers:{addErrorBar:(e,t)=>{var{itemId:n,errorBar:r}=t.payload;e[n]||(e[n]=[]),e[n].push(r)},replaceErrorBar:(e,t)=>{var{itemId:n,prev:r,next:i}=t.payload;e[n]&&(e[n]=e[n].map(e=>e.dataKey===r.dataKey&&e.direction===r.direction?i:e))},removeErrorBar:(e,t)=>{var{itemId:n,errorBar:r}=t.payload;e[n]&&(e[n]=e[n].filter(e=>e.dataKey!==r.dataKey||e.direction!==r.direction))}}}),{addErrorBar:Fpe,replaceErrorBar:Ipe,removeErrorBar:Lpe}=SH.actions,CH=SH.reducer,wH=[`children`];function TH(e,t){if(e==null)return{};var n,r,i=EH(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function EH(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var DH=(0,b.createContext)({data:[],xAxisId:`xAxis-0`,yAxisId:`yAxis-0`,dataPointFormatter:()=>({x:0,y:0,value:0}),errorBarOffset:0});function OH(e){var{children:t}=e,n=TH(e,wH);return b.createElement(DH.Provider,{value:n},t)}function kH(e,t){var n=U(t=>_F(t,e)),r=U(e=>bF(e,t)),i=n?.allowDataOverflow??hF.allowDataOverflow,a=r?.allowDataOverflow??vF.allowDataOverflow;return{needClip:i||a,needClipX:i,needClipY:a}}function AH(e){var{xAxisId:t,yAxisId:n,clipPathId:r}=e,i=_B(),{needClipX:a,needClipY:o,needClip:s}=kH(t,n);if(!s||!i)return null;var{x:c,y:l,width:u,height:d}=i;return b.createElement(`clipPath`,{id:`clipPath-${r}`},b.createElement(`rect`,{x:a?c:c-u/2,y:o?l:l-d/2,width:a?u:u*2,height:o?d:d*2}))}function jH(e){var t=zx(e),n=3,r=2;if(t!=null){var{r:i,strokeWidth:a}=t,o=Number(i),s=Number(a);return(Number.isNaN(o)||o<0)&&(o=n),(Number.isNaN(s)||s<0)&&(s=r),{r:o,strokeWidth:s}}return{r:n,strokeWidth:r}}function MH(e,t){return e.graphicalItems.cartesianItems.find(e=>e.id===t)?.xAxisId??0}function NH(e,t){return e.graphicalItems.cartesianItems.find(e=>e.id===t)?.yAxisId??0}var PH=(e,t,n)=>NI(e,`xAxis`,MH(e,t),n),FH=(e,t,n)=>MI(e,`xAxis`,MH(e,t),n),IH=(e,t,n)=>NI(e,`yAxis`,NH(e,t),n),LH=(e,t,n)=>MI(e,`yAxis`,NH(e,t),n),RH=W([TD,PH,IH,FH,LH],(e,t,n,r,i)=>zE(e,`xAxis`)?qE(t,r,!1):qE(n,i,!1)),zH=W([DF,(e,t)=>t],(e,t)=>e.filter(e=>e.type===`area`).find(e=>e.id===t)),BH=e=>zE(TD(e),`xAxis`)?`yAxis`:`xAxis`,VH=(e,t)=>BH(e)===`yAxis`?NH(e,t):MH(e,t),HH=W([TD,PH,IH,FH,LH,W([zH,(e,t,n)=>KF(e,BH(e),VH(e,t),n)],(e,t)=>{if(!(e==null||t==null)){var{stackId:n}=e,r=rj(e);if(!(n==null||r==null)){var i=(t[n]?.stackedData)?.find(e=>e.key===r);if(i!=null)return i.map(e=>[e[0],e[1]])}}}),aA,RH,zH,NA],(e,t,n,r,i,a,o,s,c,l)=>{var{chartData:u,dataStartIndex:d,dataEndIndex:f}=o;if(!(c==null||e!==`horizontal`&&e!==`vertical`||t==null||n==null||r==null||i==null||r.length===0||i.length===0||s==null)){var{data:p}=c,m=p&&p.length>0?p:u?.slice(d,f+1);if(m!=null)return mU({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:d,areaSettings:c,stackedData:a,displayedData:m,chartBaseValue:l,bandSize:s})}}),UH=[`id`],WH=[`activeDot`,`animationBegin`,`animationDuration`,`animationEasing`,`connectNulls`,`dot`,`fill`,`fillOpacity`,`hide`,`isAnimationActive`,`legendType`,`stroke`,`xAxisId`,`yAxisId`];function GH(){return GH=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},GH.apply(null,arguments)}function KH(e,t){if(e==null)return{};var n,r,i=qH(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function qH(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function JH(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function YH(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?JH(Object(n),!0).forEach(function(t){XH(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):JH(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function XH(e,t,n){return(t=ZH(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ZH(e){var t=QH(e,`string`);return typeof t==`symbol`?t:t+``}function QH(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function $H(e,t){return e&&e!==`none`?e:t}var eU=e=>{var{dataKey:t,name:n,stroke:r,fill:i,legendType:a,hide:o}=e;return[{inactive:o,dataKey:t,type:a,color:$H(r,i),value:YE(n,t),payload:e}]},tU=b.memo(e=>{var{dataKey:t,data:n,stroke:r,strokeWidth:i,fill:a,name:o,hide:s,unit:c,tooltipType:l,id:u}=e,d={dataDefinedOnItem:n,getPosition:tC,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:t,nameKey:void 0,name:YE(o,t),hide:s,type:l,color:$H(r,a),unit:c,graphicalItemId:u}};return b.createElement(Mz,{tooltipEntrySettings:d})});function nU(e){var{clipPathId:t,points:n,props:r}=e,{needClip:i,dot:a,dataKey:o}=r,s=Rx(r);return b.createElement(Qz,{points:n,dot:a,className:`recharts-area-dots`,dotClassName:`recharts-area-dot`,dataKey:o,baseProps:s,needClip:i,clipPathId:t})}function rU(e){var{showLabels:t,children:n,points:r}=e,i=r.map(e=>{var t={x:e.x??0,y:e.y??0,width:0,lowerWidth:0,upperWidth:0,height:0};return YH(YH({},t),{},{value:e.value,payload:e.payload,parentViewBox:void 0,viewBox:t,fill:void 0})});return b.createElement(XR,{value:t?i:void 0},n)}function iU(e){var{points:t,baseLine:n,needClip:r,clipPathId:i,props:a}=e,{layout:o,type:s,stroke:c,connectNulls:l,isRange:u}=a,{id:d}=a,f=KH(a,UH),p=Rx(f),m=Bx(f);return b.createElement(b.Fragment,null,t?.length>1&&b.createElement(Wx,{clipPath:r?`url(#clipPath-${i})`:void 0},b.createElement(UO,GH({},m,{id:d,points:t,connectNulls:l,type:s,baseLine:n,layout:o,stroke:`none`,className:`recharts-area-area`})),c!==`none`&&b.createElement(UO,GH({},p,{className:`recharts-area-curve`,layout:o,type:s,connectNulls:l,fill:`none`,points:t})),c!==`none`&&u&&Array.isArray(n)&&b.createElement(UO,GH({},p,{className:`recharts-area-curve`,layout:o,type:s,connectNulls:l,fill:`none`,points:n}))),b.createElement(nU,{points:t,props:f,clipPathId:i}))}function aU(e){var{alpha:t,baseLine:n,points:r,strokeWidth:i}=e,a=r[0]?.y,o=r[r.length-1]?.y;if(!PE(a)||!PE(o))return null;var s=t*Math.abs(a-o),c=Math.max(...r.map(e=>e.x||0));return H(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(e=>e.x||0),c)),H(c)?b.createElement(`rect`,{x:0,y:a<o?a:a-s,width:c+(i?parseInt(`${i}`,10):1),height:Math.floor(s)}):null}function oU(e){var{alpha:t,baseLine:n,points:r,strokeWidth:i}=e,a=r[0]?.x,o=r[r.length-1]?.x;if(!PE(a)||!PE(o))return null;var s=t*Math.abs(a-o),c=Math.max(...r.map(e=>e.y||0));return H(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(e=>e.y||0),c)),H(c)?b.createElement(`rect`,{x:a<o?a:a-s,y:0,width:s,height:Math.floor(c+(i?parseInt(`${i}`,10):1))}):null}function sU(e){var{alpha:t,layout:n,points:r,baseLine:i,strokeWidth:a}=e;return n===`vertical`?b.createElement(aU,{alpha:t,points:r,baseLine:i,strokeWidth:a}):b.createElement(oU,{alpha:t,points:r,baseLine:i,strokeWidth:a})}function cU(e){var{needClip:t,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a}=e,{points:o,baseLine:s,isAnimationActive:c,animationBegin:l,animationDuration:u,animationEasing:d,onAnimationStart:f,onAnimationEnd:p}=r,m=ck((0,b.useMemo)(()=>({points:o,baseLine:s}),[o,s]),`recharts-area-`),h=DD(),[g,_]=(0,b.useState)(!1),v=!g,y=(0,b.useCallback)(()=>{typeof p==`function`&&p(),_(!1)},[p]),x=(0,b.useCallback)(()=>{typeof f==`function`&&f(),_(!0)},[f]);if(h==null)return null;var S=i.current,C=a.current;return b.createElement(rU,{showLabels:v,points:o},r.children,b.createElement(sk,{animationId:m,begin:l,duration:u,isActive:c,easing:d,onAnimationEnd:y,onAnimationStart:x,key:m},e=>{if(S){var l=S.length/o.length,u=e===1?o:o.map((t,n)=>{var r=Math.floor(n*l);if(S[r]){var i=S[r];return YH(YH({},t),{},{x:XS(i.x,t.x,e),y:XS(i.y,t.y,e)})}return t}),d=H(s)?XS(C,s,e):QS(s)||WS(s)?XS(C,0,e):s.map((t,n)=>{var r=Math.floor(n*l);if(Array.isArray(C)&&C[r]){var i=C[r];return YH(YH({},t),{},{x:XS(i.x,t.x,e),y:XS(i.y,t.y,e)})}return t});return e>0&&(i.current=u,a.current=d),b.createElement(iU,{points:u,baseLine:d,needClip:t,clipPathId:n,props:r})}return e>0&&(i.current=o,a.current=s),b.createElement(Wx,null,c&&b.createElement(`defs`,null,b.createElement(`clipPath`,{id:`animationClipPath-${n}`},b.createElement(sU,{alpha:e,points:o,baseLine:s,layout:h,strokeWidth:r.strokeWidth}))),b.createElement(Wx,{clipPath:`url(#animationClipPath-${n})`},b.createElement(iU,{points:o,baseLine:s,needClip:t,clipPathId:n,props:r})))}),b.createElement($R,{label:r.label}))}function lU(e){var{needClip:t,clipPathId:n,props:r}=e,i=(0,b.useRef)(null),a=(0,b.useRef)();return b.createElement(cU,{needClip:t,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a})}var uU=class extends b.PureComponent{render(){var{hide:e,dot:t,points:n,className:r,top:i,left:a,needClip:o,xAxisId:s,yAxisId:c,width:l,height:u,id:d,baseLine:f,zIndex:p}=this.props;if(e)return null;var m=Px(`recharts-area`,r),h=d,{r:g,strokeWidth:_}=jH(t),v=yz(t),y=g*2+_,x=o?`url(#clipPath-${v?``:`dots-`}${h})`:void 0;return b.createElement(WL,{zIndex:p},b.createElement(Wx,{className:m},o&&b.createElement(`defs`,null,b.createElement(AH,{clipPathId:h,xAxisId:s,yAxisId:c}),!v&&b.createElement(`clipPath`,{id:`clipPath-dots-${h}`},b.createElement(`rect`,{x:a-y/2,y:i-y/2,width:l+y,height:u+y}))),b.createElement(lU,{needClip:o,clipPathId:h,props:this.props})),b.createElement(TB,{points:n,mainColor:$H(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:x}),this.props.isRange&&Array.isArray(f)&&b.createElement(TB,{points:f,mainColor:$H(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:x}))}},dU={activeDot:!0,animationBegin:0,animationDuration:1500,animationEasing:`ease`,connectNulls:!1,dot:!1,fill:`#3182bd`,fillOpacity:.6,hide:!1,isAnimationActive:`auto`,legendType:`line`,stroke:`#3182bd`,strokeWidth:1,type:`linear`,label:!1,xAxisId:0,yAxisId:0,zIndex:PA.area};function fU(e){var{activeDot:t,animationBegin:n,animationDuration:r,animationEasing:i,connectNulls:a,dot:o,fill:s,fillOpacity:c,hide:l,isAnimationActive:u,legendType:d,stroke:f,xAxisId:p,yAxisId:m}=e,h=KH(e,WH),g=ED(),_=AL(),{needClip:v}=kH(p,m),y=sD(),{points:x,isRange:S,baseLine:C}=U(t=>HH(t,e.id,y))??{},w=_B();if(g!==`horizontal`&&g!==`vertical`||w==null||_!==`AreaChart`&&_!==`ComposedChart`)return null;var{height:T,width:E,x:D,y:O}=w;return!x||!x.length?null:b.createElement(uU,GH({},h,{activeDot:t,animationBegin:n,animationDuration:r,animationEasing:i,baseLine:C,connectNulls:a,dot:o,fill:s,fillOpacity:c,height:T,hide:l,layout:g,isAnimationActive:u,isRange:S,legendType:d,needClip:v,points:x,stroke:f,width:E,left:D,top:O,xAxisId:p,yAxisId:m}))}var pU=(e,t,n,r,i)=>{var a=n??t;if(H(a))return a;var o=e===`horizontal`?i:r,s=o.scale.domain();if(o.type===`number`){var c=Math.max(s[0],s[1]),l=Math.min(s[0],s[1]);return a===`dataMin`?l:a===`dataMax`||c<0?c:Math.max(Math.min(s[0],s[1]),0)}return a===`dataMin`?s[0]:a===`dataMax`?s[1]:s[0]};function mU(e){var{areaSettings:{connectNulls:t,baseValue:n,dataKey:r},stackedData:i,layout:a,chartBaseValue:o,xAxis:s,yAxis:c,displayedData:l,dataStartIndex:u,xAxisTicks:d,yAxisTicks:f,bandSize:p}=e,m=i&&i.length,h=pU(a,o,n,s,c),g=a===`horizontal`,_=!1,v=l.map((e,n)=>{var a;if(m)a=i[u+n];else{var o=RE(e,r);Array.isArray(o)?(a=o,_=!0):a=[h,o]}var l=a?.[1]??null,v=l==null||m&&!t&&RE(e,r)==null;return g?{x:UE({axis:s,ticks:d,bandSize:p,entry:e,index:n}),y:v?null:c.scale.map(l)??null,value:a,payload:e}:{x:v?null:s.scale.map(l)??null,y:UE({axis:c,ticks:f,bandSize:p,entry:e,index:n}),value:a,payload:e}});return{points:v,baseLine:(m||_?v.map(e=>{var t=Array.isArray(e.value)?e.value[0]:null;return g?{x:e.x,y:t!=null&&e.y!=null?c.scale.map(t)??null:null,payload:e.payload}:{x:t==null?null:s.scale.map(t)??null,y:e.y,payload:e.payload}}):g?c.scale.map(h):s.scale.map(h))??0,isRange:_}}function hU(e){var t=dC(e,dU),n=sD();return b.createElement(Pz,{id:t.id,type:`area`},e=>b.createElement(b.Fragment,null,b.createElement(Nz,{legendPayload:eU(t)}),b.createElement(tU,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:e}),b.createElement(Iz,{type:`area`,id:e,data:t.data,dataKey:t.dataKey,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,stackId:HE(t.stackId),hide:t.hide,barSize:void 0,baseValue:t.baseValue,isPanorama:n,connectNulls:t.connectNulls}),b.createElement(fU,GH({},t,{id:e}))))}var gU=b.memo(hU,SO);gU.displayName=`Area`;var _U=!0,vU=`Invariant failed`;function yU(e,t){if(!e){if(_U)throw Error(vU);var n=typeof t==`function`?t():t,r=n?`${vU}: ${n}`:vU;throw Error(r)}}function bU(){return bU=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},bU.apply(null,arguments)}function xU(e){return b.createElement(Oz,bU({shapeType:`rectangle`,activeClassName:`recharts-active-bar`,inActiveClassName:`recharts-inactive-bar`},e))}var SU=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(n,r)=>{if(H(e))return e;var i=H(n)||QS(n);return i?e(n,r):(!i&&yU(!1,`minPointSize callback function received a value with type of ${typeof n}. Currently only numbers or null/undefined are supported.`),t)}},CU=(e,t,n)=>n,wU=W([DF,(e,t)=>t],(e,t)=>e.filter(e=>e.type===`bar`).find(e=>e.id===t)),TU=W([wU],e=>e?.maxBarSize),EU=(e,t,n,r)=>r,DU=W([TD,DF,MH,NH,CU],(e,t,n,r,i)=>t.filter(t=>e===`horizontal`?t.xAxisId===n:t.yAxisId===r).filter(e=>e.isPanorama===i).filter(e=>e.hide===!1).filter(e=>e.type===`bar`)),OU=(e,t,n)=>{var r=TD(e),i=MH(e,t),a=NH(e,t);if(!(i==null||a==null))return r===`horizontal`?KF(e,`yAxis`,a,n):KF(e,`xAxis`,i,n)},kU=W([DU,EA,(e,t)=>{var n=TD(e),r=MH(e,t),i=NH(e,t);if(!(r==null||i==null))return n===`horizontal`?DI(e,`xAxis`,r):DI(e,`yAxis`,i)}],DB),AU=(e,t,n)=>{var r=wU(e,t);if(r==null)return 0;var i=MH(e,t),a=NH(e,t);if(i==null||a==null)return 0;var o=TD(e),s=CA(e),{maxBarSize:c}=r,l=QS(c)?s:c,u,d;return o===`horizontal`?(u=NI(e,`xAxis`,i,n),d=MI(e,`xAxis`,i,n)):(u=NI(e,`yAxis`,a,n),d=MI(e,`yAxis`,a,n)),qE(u,d,!0)??l??0},jU=(e,t,n)=>{var r=TD(e),i=MH(e,t),a=NH(e,t);if(!(i==null||a==null)){var o,s;return r===`horizontal`?(o=NI(e,`xAxis`,i,n),s=MI(e,`xAxis`,i,n)):(o=NI(e,`yAxis`,a,n),s=MI(e,`yAxis`,a,n)),qE(o,s)}},MU=W([aD,oD,(e,t,n)=>{var r=MH(e,t);if(r!=null)return NI(e,`xAxis`,r,n)},(e,t,n)=>{var r=NH(e,t);if(r!=null)return NI(e,`yAxis`,r,n)},(e,t,n)=>{var r=MH(e,t);if(r!=null)return MI(e,`xAxis`,r,n)},(e,t,n)=>{var r=NH(e,t);if(r!=null)return MI(e,`yAxis`,r,n)},W([W([kU,CA,wA,TA,AU,jU,TU],PB),wU],IB),TD,aA,jU,W([OU,wU],FB),wU,EU],(e,t,n,r,i,a,o,s,c,l,u,d,f)=>{var{chartData:p,dataStartIndex:m,dataEndIndex:h}=c;if(!(d==null||o==null||t==null||s!==`horizontal`&&s!==`vertical`||n==null||r==null||i==null||a==null||l==null)){var{data:g}=d,_=g!=null&&g.length>0?g:p?.slice(m,h+1);if(_!=null)return mW({layout:s,barSettings:d,pos:o,parentViewBox:t,bandSize:l,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,stackedData:u,displayedData:_,offset:e,cells:f,dataStartIndex:m})}}),NU=[`index`];function PU(){return PU=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},PU.apply(null,arguments)}function FU(e,t){if(e==null)return{};var n,r,i=IU(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function IU(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var LU=(0,b.createContext)(void 0),RU=e=>{var t=(0,b.useContext)(LU);if(t!=null)return t.stackId;if(e!=null)return HE(e)},zU=(e,t)=>`recharts-bar-stack-clip-path-${e}-${t}`,BU=e=>{var t=(0,b.useContext)(LU);if(t!=null){var{stackId:n}=t;return`url(#${zU(n,e)})`}},VU=e=>{var{index:t}=e,n=FU(e,NU),r=BU(t);return b.createElement(Wx,PU({className:`recharts-bar-stack-layer`,clipPath:r},n))},HU=[`onMouseEnter`,`onMouseLeave`,`onClick`],UU=[`value`,`background`,`tooltipPosition`],WU=[`id`],GU=[`onMouseEnter`,`onClick`,`onMouseLeave`];function KU(){return KU=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},KU.apply(null,arguments)}function qU(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function JU(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?qU(Object(n),!0).forEach(function(t){YU(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):qU(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function YU(e,t,n){return(t=XU(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function XU(e){var t=ZU(e,`string`);return typeof t==`symbol`?t:t+``}function ZU(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function QU(e,t){if(e==null)return{};var n,r,i=$U(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function $U(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var eW=e=>{var{dataKey:t,name:n,fill:r,legendType:i,hide:a}=e;return[{inactive:a,dataKey:t,type:i,color:r,value:YE(n,t),payload:e}]},tW=b.memo(e=>{var{dataKey:t,stroke:n,strokeWidth:r,fill:i,name:a,hide:o,unit:s,tooltipType:c,id:l}=e,u={dataDefinedOnItem:void 0,getPosition:tC,settings:{stroke:n,strokeWidth:r,fill:i,dataKey:t,nameKey:void 0,name:YE(a,t),hide:o,type:c,color:i,unit:s,graphicalItemId:l}};return b.createElement(Mz,{tooltipEntrySettings:u})});function nW(e){var t=U(bL),{data:n,dataKey:r,background:i,allOtherBarProps:a}=e,{onMouseEnter:o,onMouseLeave:s,onClick:c}=a,l=QU(a,HU),u=kz(o,r,a.id),d=Az(s),f=jz(c,r,a.id);if(!i||n==null)return null;var p=zx(i);return b.createElement(WL,{zIndex:LB(i,PA.barBackground)},n.map((e,n)=>{var{value:a,background:o,tooltipPosition:s}=e,c=QU(e,UU);if(!o)return null;var m=u(e,n),h=d(e,n),g=f(e,n),_=JU(JU(JU(JU(JU({option:i,isActive:String(n)===t},c),{},{fill:`#eee`},o),p),lC(l,e,n)),{},{onMouseEnter:m,onMouseLeave:h,onClick:g,dataKey:r,index:n,className:`recharts-bar-background-rectangle`});return b.createElement(xU,KU({key:`background-bar-${n}`},_))}))}function rW(e){var{showLabels:t,children:n,rects:r}=e,i=r?.map(e=>{var t={x:e.x,y:e.y,width:e.width,lowerWidth:e.width,upperWidth:e.width,height:e.height};return JU(JU({},t),{},{value:e.value,payload:e.payload,parentViewBox:e.parentViewBox,viewBox:t,fill:e.fill})});return b.createElement(XR,{value:t?i:void 0},n)}function iW(e){var{shape:t,activeBar:n,baseProps:r,entry:i,index:a,dataKey:o}=e,s=U(bL),c=U(SL),l=n&&String(i.originalDataIndex)===s&&(c==null||o===c),[u,d]=(0,b.useState)(!1),[f,p]=(0,b.useState)(!1);(0,b.useEffect)(()=>{var e;return l?(d(!0),e=requestAnimationFrame(()=>{p(!0)})):p(!1),()=>{cancelAnimationFrame(e)}},[l]);var m=(0,b.useCallback)(()=>{l||d(!1)},[l]),h=l&&f,g=l||u,_=l?n===!0?t:n:t,v=b.createElement(xU,KU({},r,{name:String(r.name)},i,{isActive:h,option:_,index:a,dataKey:o,onTransitionEnd:m}));return g?b.createElement(WL,{zIndex:PA.activeBar},b.createElement(VU,{index:i.originalDataIndex},v)):v}function aW(e){var{shape:t,baseProps:n,entry:r,index:i,dataKey:a}=e;return b.createElement(xU,KU({},n,{name:String(n.name)},r,{isActive:!1,option:t,index:i,dataKey:a}))}function oW(e){var{data:t,props:n}=e,r=Rx(n)??{},{id:i}=r,a=QU(r,WU),{shape:o,dataKey:s,activeBar:c}=n,{onMouseEnter:l,onClick:u,onMouseLeave:d}=n,f=QU(n,GU),p=kz(l,s,i),m=Az(d),h=jz(u,s,i);return t?b.createElement(b.Fragment,null,t.map((e,t)=>b.createElement(VU,KU({index:e.originalDataIndex,key:`rectangle-${e?.x}-${e?.y}-${e?.value}-${t}`,className:`recharts-bar-rectangle`},lC(f,e,t),{onMouseEnter:p(e,t),onMouseLeave:m(e,t),onClick:h(e,t)}),c?b.createElement(iW,{shape:o,activeBar:c,baseProps:a,entry:e,index:t,dataKey:s}):b.createElement(aW,{shape:o,baseProps:a,entry:e,index:t,dataKey:s})))):null}function sW(e){var{props:t,previousRectanglesRef:n}=e,{data:r,layout:i,isAnimationActive:a,animationBegin:o,animationDuration:s,animationEasing:c,onAnimationEnd:l,onAnimationStart:u}=t,d=n.current,f=ck(t,`recharts-bar-`),[p,m]=(0,b.useState)(!1),h=!p,g=(0,b.useCallback)(()=>{typeof l==`function`&&l(),m(!1)},[l]),_=(0,b.useCallback)(()=>{typeof u==`function`&&u(),m(!0)},[u]);return b.createElement(rW,{showLabels:h,rects:r},b.createElement(sk,{animationId:f,begin:o,duration:s,isActive:a,easing:c,onAnimationEnd:g,onAnimationStart:_,key:f},e=>{var a=e===1?r:r?.map((t,n)=>{var r=d&&d[n];if(r)return JU(JU({},t),{},{x:XS(r.x,t.x,e),y:XS(r.y,t.y,e),width:XS(r.width,t.width,e),height:XS(r.height,t.height,e)});if(i===`horizontal`){var a=XS(0,t.height,e),o=XS(t.stackedBarStart,t.y,e);return JU(JU({},t),{},{y:o,height:a})}var s=XS(0,t.width,e),c=XS(t.stackedBarStart,t.x,e);return JU(JU({},t),{},{width:s,x:c})});return e>0&&(n.current=a??null),a==null?null:b.createElement(Wx,null,b.createElement(oW,{props:t,data:a}))}),b.createElement($R,{label:t.label}),t.children)}function cW(e){var t=(0,b.useRef)(null);return b.createElement(sW,{previousRectanglesRef:t,props:e})}var lW=0,uW=(e,t)=>{var n=Array.isArray(e.value)?e.value[1]:e.value;return{x:e.x,y:e.y,value:n,errorVal:RE(e,t)}},dW=class extends b.PureComponent{render(){var{hide:e,data:t,dataKey:n,className:r,xAxisId:i,yAxisId:a,needClip:o,background:s,id:c}=this.props;if(e||t==null)return null;var l=Px(`recharts-bar`,r),u=c;return b.createElement(Wx,{className:l,id:c},o&&b.createElement(`defs`,null,b.createElement(AH,{clipPathId:u,xAxisId:i,yAxisId:a})),b.createElement(Wx,{className:`recharts-bar-rectangles`,clipPath:o?`url(#clipPath-${u})`:void 0},b.createElement(nW,{data:t,dataKey:n,background:s,allOtherBarProps:this.props}),b.createElement(cW,this.props)))}},fW={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:`ease`,background:!1,hide:!1,isAnimationActive:`auto`,label:!1,legendType:`rect`,minPointSize:lW,xAxisId:0,yAxisId:0,zIndex:PA.bar};function pW(e){var{xAxisId:t,yAxisId:n,hide:r,legendType:i,minPointSize:a,activeBar:o,animationBegin:s,animationDuration:c,animationEasing:l,isAnimationActive:u}=e,{needClip:d}=kH(t,n),f=ED(),p=sD(),m=vz(e.children,cR),h=U(t=>MU(t,e.id,p,m));if(f!==`vertical`&&f!==`horizontal`)return null;var g,_=h?.[0];return g=_==null||_.height==null||_.width==null?0:f===`vertical`?_.height/2:_.width/2,b.createElement(OH,{xAxisId:t,yAxisId:n,data:h,dataPointFormatter:uW,errorBarOffset:g},b.createElement(dW,KU({},e,{layout:f,needClip:d,data:h,xAxisId:t,yAxisId:n,hide:r,legendType:i,minPointSize:a,activeBar:o,animationBegin:s,animationDuration:c,animationEasing:l,isAnimationActive:u})))}function mW(e){var{layout:t,barSettings:{dataKey:n,minPointSize:r,hasCustomShape:i},pos:a,bandSize:o,xAxis:s,yAxis:c,xAxisTicks:l,yAxisTicks:u,stackedData:d,displayedData:f,offset:p,cells:m,parentViewBox:h,dataStartIndex:g}=e,_=t===`horizontal`?c:s,v=d?_.scale.domain():null,y=fie({numericAxis:_}),b=_.scale.map(y);return f.map((e,f)=>{var _,x,S,C,w,T;if(d){var E=d[f+g];if(E==null)return null;_=lie(E,v)}else _=RE(e,n),Array.isArray(_)||(_=[y,_]);var D=SU(r,lW)(_[1],f);if(t===`horizontal`){var O=c.scale.map(_[0]),k=c.scale.map(_[1]);if(O==null||k==null)return null;x=WE({axis:s,ticks:l,bandSize:o,offset:a.offset,entry:e,index:f}),S=k??O??void 0,C=a.size;var ee=O-k;if(w=WS(ee)?0:ee,T={x,y:p.top,width:C,height:p.height},Math.abs(D)>0&&Math.abs(w)<Math.abs(D)){var te=US(w||D)*(Math.abs(D)-Math.abs(w));S-=te,w+=te}}else{var ne=s.scale.map(_[0]),re=s.scale.map(_[1]);if(ne==null||re==null)return null;if(x=ne,S=WE({axis:c,ticks:u,bandSize:o,offset:a.offset,entry:e,index:f}),C=re-ne,w=a.size,T={x:p.left,y:S,width:p.width,height:w},Math.abs(D)>0&&Math.abs(C)<Math.abs(D)){var A=US(C||D)*(Math.abs(D)-Math.abs(C));C+=A}}return x==null||S==null||C==null||w==null||!i&&(C===0||w===0)?null:JU(JU({},e),{},{stackedBarStart:b,x,y:S,width:C,height:w,value:d?_:_[1],payload:e,background:T,tooltipPosition:{x:x+C/2,y:S+w/2},parentViewBox:h,originalDataIndex:f},m&&m[f]&&m[f].props)}).filter(Boolean)}function hW(e){var t=dC(e,fW),n=RU(t.stackId),r=sD();return b.createElement(Pz,{id:t.id,type:`bar`},e=>b.createElement(b.Fragment,null,b.createElement(Nz,{legendPayload:eW(t)}),b.createElement(tW,{dataKey:t.dataKey,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:e}),b.createElement(Iz,{type:`bar`,id:e,data:void 0,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,stackId:n,hide:t.hide,barSize:t.barSize,minPointSize:t.minPointSize,maxBarSize:t.maxBarSize,isPanorama:r,hasCustomShape:t.shape!=null}),b.createElement(WL,{zIndex:t.zIndex},b.createElement(pW,KU({},t,{id:e})))))}var gW=b.memo(hW,SO);gW.displayName=`Bar`;var _W=[`option`,`isActive`];function vW(){return vW=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},vW.apply(null,arguments)}function yW(e,t){if(e==null)return{};var n,r,i=bW(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function bW(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function xW(e){var{option:t,isActive:n}=e,r=yW(e,_W);return typeof t==`string`?b.createElement(Oz,vW({option:b.createElement(oC,vW({type:t},r)),isActive:n,shapeType:`symbols`},r)):b.createElement(Oz,vW({option:t,isActive:n,shapeType:`symbols`},r))}var SW=W([(e,t,n,r,i,a,o)=>iA(e,void 0,void 0,o),(e,t,n,r,i,a,o)=>NI(e,`xAxis`,t,o),(e,t,n,r,i,a,o)=>MI(e,`xAxis`,t,o),(e,t,n,r,i,a,o)=>NI(e,`yAxis`,n,o),(e,t,n,r,i,a,o)=>MI(e,`yAxis`,n,o),(e,t,n,r)=>hle(e,`zAxis`,r,!1),W([DF,(e,t,n,r,i)=>i],(e,t)=>e.filter(e=>e.type===`scatter`).find(e=>e.id===t)),(e,t,n,r,i,a)=>a],(e,t,n,r,i,a,o,s)=>{var{chartData:c,dataStartIndex:l,dataEndIndex:u}=e;if(o!=null){var d=o?.data!=null&&o.data.length>0?o.data:c?.slice(l,u+1);if(!(d==null||t==null||r==null||n==null||i==null||n?.length===0||i?.length===0))return BW({displayedData:d,xAxis:t,yAxis:r,zAxis:a,scatterSettings:o,xAxisTicks:n,yAxisTicks:i,cells:s})}}),CW=[`id`],wW=[`onMouseEnter`,`onClick`,`onMouseLeave`],TW=[`animationBegin`,`animationDuration`,`animationEasing`,`hide`,`isAnimationActive`,`legendType`,`lineJointType`,`lineType`,`shape`,`xAxisId`,`yAxisId`,`zAxisId`];function EW(e,t){if(e==null)return{};var n,r,i=DW(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function DW(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function OW(){return OW=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},OW.apply(null,arguments)}function kW(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function AW(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?kW(Object(n),!0).forEach(function(t){jW(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):kW(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function jW(e,t,n){return(t=MW(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function MW(e){var t=NW(e,`string`);return typeof t==`symbol`?t:t+``}function NW(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var PW=e=>{var{dataKey:t,name:n,fill:r,legendType:i,hide:a}=e;return[{inactive:a,dataKey:t,type:i,color:r,value:YE(n,t),payload:e}]},FW=b.memo(e=>{var{dataKey:t,points:n,stroke:r,strokeWidth:i,fill:a,name:o,hide:s,tooltipType:c,id:l}=e,u={dataDefinedOnItem:n?.map(e=>e.tooltipPayload),getPosition:e=>{var t;return n==null||(t=n[Number(e)])==null?void 0:t.tooltipPosition},settings:{stroke:r,strokeWidth:i,fill:a,nameKey:void 0,dataKey:t,name:YE(o,t),hide:s,type:c,color:a,unit:``,graphicalItemId:l}};return b.createElement(Mz,{tooltipEntrySettings:u})});function IW(e){var{points:t,props:n}=e,{line:r,lineType:i,lineJointType:a}=n;if(!r)return null;var o=Rx(n),s=zx(r),c,l;if(i===`joint`)c=t.map(e=>({x:e.cx??null,y:e.cy??null}));else if(i===`fitting`){var{xmin:u,xmax:d,a:f,b:p}=Xne(t),m=e=>f*e+p;c=[{x:u,y:m(u)},{x:d,y:m(d)}]}var h=AW(AW(AW({},o),{},{fill:`none`,stroke:o&&o.fill},s),{},{points:c});return l=b.isValidElement(r)?b.cloneElement(r,h):typeof r==`function`?r(h):b.createElement(UO,OW({},h,{type:a})),b.createElement(Wx,{className:`recharts-scatter-line`,key:`recharts-scatter-line`},l)}function LW(e){var{showLabels:t,points:n,children:r}=e,i=xD(),a=(0,b.useMemo)(()=>n?.map(e=>{var t={x:e.x??0,y:e.y??0,width:e.width,height:e.height,lowerWidth:e.width,upperWidth:e.width};return AW(AW({},t),{},{value:void 0,payload:e.payload,viewBox:t,parentViewBox:i,fill:void 0})}),[i,n]);return b.createElement(XR,{value:t?a:void 0},r)}function RW(e){var{points:t,allOtherScatterProps:n}=e,{shape:r,activeShape:i,dataKey:a}=n,{id:o}=n,s=EW(n,CW),c=U(bL),{onMouseEnter:l,onClick:u,onMouseLeave:d}=n,f=EW(n,wW),p=kz(l,a,o),m=Az(d),h=jz(u,a,o);if(!cre(t))return null;var g=Rx(s);return b.createElement(b.Fragment,null,b.createElement(IW,{points:t,props:s}),t.map((e,t)=>{var n=i!=null&&i!==!1,a=n&&c===String(t),s=n&&a?i:r,l=AW(AW(AW({},g),e),{},{index:t,[nD]:String(o)});return b.createElement(WL,{key:`symbol-${e?.cx}-${e?.cy}-${e?.size}-${t}`,zIndex:a?PA.activeDot:void 0},b.createElement(Wx,OW({className:`recharts-scatter-symbol`},lC(f,e,t),{onMouseEnter:p(e,t),onMouseLeave:m(e,t),onClick:h(e,t)}),b.createElement(xW,OW({option:s,isActive:a},l))))}))}function zW(e){var{previousPointsRef:t,props:n}=e,{points:r,isAnimationActive:i,animationBegin:a,animationDuration:o,animationEasing:s}=n,c=t.current,l=ck(n,`recharts-scatter-`),[u,d]=(0,b.useState)(!1),f=(0,b.useCallback)(()=>{d(!1)},[]),p=(0,b.useCallback)(()=>{d(!0)},[]),m=!u;return b.createElement(LW,{showLabels:m,points:r},n.children,b.createElement(sk,{animationId:l,begin:a,duration:o,isActive:i,easing:s,onAnimationEnd:f,onAnimationStart:p,key:l},e=>{var i=e===1?r:r?.map((t,n)=>{var r=c&&c[n];return r?AW(AW({},t),{},{cx:t.cx==null?void 0:XS(r.cx,t.cx,e),cy:t.cy==null?void 0:XS(r.cy,t.cy,e),size:XS(r.size,t.size,e)}):AW(AW({},t),{},{size:XS(0,t.size,e)})});return e>0&&(t.current=i),b.createElement(Wx,null,b.createElement(RW,{points:i,allOtherScatterProps:n,showLabels:m}))}),b.createElement($R,{label:n.label}))}function BW(e){var{displayedData:t,xAxis:n,yAxis:r,zAxis:i,scatterSettings:a,xAxisTicks:o,yAxisTicks:s,cells:c}=e,l=QS(n.dataKey)?a.dataKey:n.dataKey,u=QS(r.dataKey)?a.dataKey:r.dataKey,d=i&&i.dataKey,f=i?i.range:xF.range,p=f&&f[0],m=n.scale.bandwidth?n.scale.bandwidth():0,h=r.scale.bandwidth?r.scale.bandwidth():0;return t.map((e,t)=>{var f=RE(e,l),g=RE(e,u),_=!QS(d)&&RE(e,d)||`-`,v=[{name:QS(n.dataKey)?a.name:n.name||String(n.dataKey),unit:n.unit||``,value:f,payload:e,dataKey:l,type:a.tooltipType,graphicalItemId:a.id},{name:QS(r.dataKey)?a.name:r.name||String(r.dataKey),unit:r.unit||``,value:g,payload:e,dataKey:u,type:a.tooltipType,graphicalItemId:a.id}];_!==`-`&&i!=null&&v.push({name:i.name||i.dataKey,unit:i.unit||``,value:_,payload:e,dataKey:d,type:a.tooltipType,graphicalItemId:a.id});var y=UE({axis:n,ticks:o,bandSize:m,entry:e,index:t,dataKey:l}),b=UE({axis:r,ticks:s,bandSize:h,entry:e,index:t,dataKey:u}),x=_!==`-`&&i!=null?i.scale.map(_):p,S=x==null?0:Math.sqrt(Math.max(x,0)/Math.PI);return AW(AW({},e),{},{cx:y,cy:b,x:y==null?void 0:y-S,y:b==null?void 0:b-S,width:2*S,height:2*S,size:x,node:{x:f,y:g,z:_},tooltipPayload:v,tooltipPosition:{x:y,y:b},payload:e},c&&c[t]&&c[t].props)})}var VW=(e,t,n)=>({x:e.cx,y:e.cy,value:Number(n===`x`?e.node.x:e.node.y),errorVal:RE(e,t)});function HW(e){var{hide:t,points:n,className:r,needClip:i,xAxisId:a,yAxisId:o,id:s}=e,c=(0,b.useRef)(null);if(t)return null;var l=Px(`recharts-scatter`,r),u=s;return b.createElement(WL,{zIndex:e.zIndex},b.createElement(Wx,{className:l,clipPath:i?`url(#clipPath-${u})`:void 0,id:s},i&&b.createElement(`defs`,null,b.createElement(AH,{clipPathId:u,xAxisId:a,yAxisId:o})),b.createElement(OH,{xAxisId:a,yAxisId:o,data:n,dataPointFormatter:VW,errorBarOffset:0},b.createElement(Wx,{key:`recharts-scatter-symbols`},b.createElement(zW,{props:e,previousPointsRef:c})))))}var UW={xAxisId:0,yAxisId:0,zAxisId:0,label:!1,line:!1,legendType:`circle`,lineType:`joint`,lineJointType:`linear`,shape:`circle`,hide:!1,isAnimationActive:`auto`,animationBegin:0,animationDuration:400,animationEasing:`linear`,zIndex:PA.scatter};function WW(e){var t=dC(e,UW),{animationBegin:n,animationDuration:r,animationEasing:i,hide:a,isAnimationActive:o,legendType:s,lineJointType:c,lineType:l,shape:u,xAxisId:d,yAxisId:f,zAxisId:p}=t,m=EW(t,TW),{needClip:h}=kH(d,f),g=(0,b.useMemo)(()=>vz(e.children,cR),[e.children]),_=sD(),v=U(t=>SW(t,d,f,p,e.id,g,_));return h==null||v==null?null:b.createElement(b.Fragment,null,b.createElement(FW,{dataKey:e.dataKey,points:v,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,tooltipType:e.tooltipType,id:e.id}),b.createElement(HW,OW({},m,{xAxisId:d,yAxisId:f,zAxisId:p,lineType:l,lineJointType:c,legendType:s,shape:u,hide:a,isAnimationActive:o,animationBegin:n,animationDuration:r,animationEasing:i,points:v,needClip:h})))}function GW(e){var t=dC(e,UW),n=sD();return b.createElement(Pz,{id:t.id,type:`scatter`},e=>b.createElement(b.Fragment,null,b.createElement(Nz,{legendPayload:PW(t)}),b.createElement(Iz,{type:`scatter`,id:e,data:t.data,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:t.zAxisId,dataKey:t.dataKey,hide:t.hide,name:t.name,tooltipType:t.tooltipType,isPanorama:n}),b.createElement(WW,OW({},t,{id:e}))))}var KW=b.memo(GW,SO);KW.displayName=`Scatter`;var qW=[`domain`,`range`],JW=[`domain`,`range`];function YW(e,t){if(e==null)return{};var n,r,i=XW(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function XW(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function ZW(e,t){return e===t?!0:Array.isArray(e)&&e.length===2&&Array.isArray(t)&&t.length===2?e[0]===t[0]&&e[1]===t[1]:!1}function QW(e,t){if(e===t)return!0;var{domain:n,range:r}=e,i=YW(e,qW),{domain:a,range:o}=t,s=YW(t,JW);return!ZW(n,a)||!ZW(r,o)?!1:SO(i,s)}var $W=[`type`],eG=[`dangerouslySetInnerHTML`,`ticks`,`scale`],tG=[`id`,`scale`];function nG(){return nG=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},nG.apply(null,arguments)}function rG(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function iG(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?rG(Object(n),!0).forEach(function(t){aG(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):rG(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function aG(e,t,n){return(t=oG(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function oG(e){var t=sG(e,`string`);return typeof t==`symbol`?t:t+``}function sG(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function cG(e,t){if(e==null)return{};var n,r,i=lG(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function lG(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function uG(e){var t=HC(),n=(0,b.useRef)(null),r=DD(),{type:i}=e,a=cG(e,$W),o=RA(r,`xAxis`,i),s=(0,b.useMemo)(()=>{if(o!=null)return iG(iG({},a),{},{type:o})},[a,o]);return(0,b.useLayoutEffect)(()=>{s!=null&&(n.current===null?t(aB(s)):n.current!==s&&t(oB({prev:n.current,next:s})),n.current=s)},[s,t]),(0,b.useLayoutEffect)(()=>()=>{n.current&&=(t(sB(n.current)),null)},[t]),null}var dG=e=>{var{xAxisId:t,className:n}=e,r=U(oD),i=sD(),a=`xAxis`,o=U(e=>jI(e,a,t,i)),s=U(e=>TI(e,t)),c=U(e=>ple(e,t)),l=U(e=>gF(e,t));if(s==null||c==null||l==null)return null;var{dangerouslySetInnerHTML:u,ticks:d,scale:f}=e,p=cG(e,eG),{id:m,scale:h}=l,g=cG(l,tG);return b.createElement($V,nG({},p,g,{x:c.x,y:c.y,width:s.width,height:s.height,className:Px(`recharts-${a} ${a}`,n),viewBox:r,ticks:o,axisType:a,axisId:t}))},fG={allowDataOverflow:hF.allowDataOverflow,allowDecimals:hF.allowDecimals,allowDuplicatedCategory:hF.allowDuplicatedCategory,angle:hF.angle,axisLine:WV.axisLine,height:hF.height,hide:!1,includeHidden:hF.includeHidden,interval:hF.interval,label:!1,minTickGap:hF.minTickGap,mirror:hF.mirror,orientation:hF.orientation,padding:hF.padding,reversed:hF.reversed,scale:hF.scale,tick:hF.tick,tickCount:hF.tickCount,tickLine:WV.tickLine,tickSize:WV.tickSize,type:hF.type,niceTicks:hF.niceTicks,xAxisId:0},pG=b.memo(e=>{var t=dC(e,fG);return b.createElement(b.Fragment,null,b.createElement(uG,{allowDataOverflow:t.allowDataOverflow,allowDecimals:t.allowDecimals,allowDuplicatedCategory:t.allowDuplicatedCategory,angle:t.angle,dataKey:t.dataKey,domain:t.domain,height:t.height,hide:t.hide,id:t.xAxisId,includeHidden:t.includeHidden,interval:t.interval,minTickGap:t.minTickGap,mirror:t.mirror,name:t.name,orientation:t.orientation,padding:t.padding,reversed:t.reversed,scale:t.scale,tick:t.tick,tickCount:t.tickCount,tickFormatter:t.tickFormatter,ticks:t.ticks,type:t.type,unit:t.unit,niceTicks:t.niceTicks}),b.createElement(dG,t))},QW);pG.displayName=`XAxis`;var mG=[`type`],hG=[`dangerouslySetInnerHTML`,`ticks`,`scale`],gG=[`id`,`scale`];function _G(){return _G=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},_G.apply(null,arguments)}function vG(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function yG(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?vG(Object(n),!0).forEach(function(t){bG(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):vG(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function bG(e,t,n){return(t=xG(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function xG(e){var t=SG(e,`string`);return typeof t==`symbol`?t:t+``}function SG(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function CG(e,t){if(e==null)return{};var n,r,i=wG(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function wG(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function TG(e){var t=HC(),n=(0,b.useRef)(null),r=DD(),{type:i}=e,a=CG(e,mG),o=RA(r,`yAxis`,i),s=(0,b.useMemo)(()=>{if(o!=null)return yG(yG({},a),{},{type:o})},[o,a]);return(0,b.useLayoutEffect)(()=>{s!=null&&(n.current===null?t(cB(s)):n.current!==s&&t(lB({prev:n.current,next:s})),n.current=s)},[s,t]),(0,b.useLayoutEffect)(()=>()=>{n.current&&=(t(uB(n.current)),null)},[t]),null}function EG(e){var{yAxisId:t,className:n,width:r,label:i}=e,a=(0,b.useRef)(null),o=(0,b.useRef)(null),s=U(oD),c=sD(),l=HC(),u=`yAxis`,d=U(e=>EI(e,t)),f=U(e=>mle(e,t)),p=U(e=>jI(e,u,t,c)),m=U(e=>yF(e,t));if((0,b.useLayoutEffect)(()=>{if(!(r!==`auto`||!d||UR(i)||(0,b.isValidElement)(i)||m==null)){var e=a.current;if(e){var n=e.getCalculatedWidth();Math.round(d.width)!==Math.round(n)&&l(mB({id:t,width:n}))}}},[p,d,l,i,t,r,m]),d==null||f==null||m==null)return null;var{dangerouslySetInnerHTML:h,ticks:g,scale:_}=e,v=CG(e,hG),{id:y,scale:x}=m,S=CG(m,gG);return b.createElement($V,_G({},v,S,{ref:a,labelRef:o,x:f.x,y:f.y,tickTextProps:r===`auto`?{width:void 0}:{width:r},width:d.width,height:d.height,className:Px(`recharts-${u} ${u}`,n),viewBox:s,ticks:p,axisType:u,axisId:t}))}var DG={allowDataOverflow:vF.allowDataOverflow,allowDecimals:vF.allowDecimals,allowDuplicatedCategory:vF.allowDuplicatedCategory,angle:vF.angle,axisLine:WV.axisLine,hide:!1,includeHidden:vF.includeHidden,interval:vF.interval,label:!1,minTickGap:vF.minTickGap,mirror:vF.mirror,orientation:vF.orientation,padding:vF.padding,reversed:vF.reversed,scale:vF.scale,tick:vF.tick,tickCount:vF.tickCount,tickLine:WV.tickLine,tickSize:WV.tickSize,type:vF.type,niceTicks:vF.niceTicks,width:vF.width,yAxisId:0},OG=b.memo(e=>{var t=dC(e,DG);return b.createElement(b.Fragment,null,b.createElement(TG,{interval:t.interval,id:t.yAxisId,scale:t.scale,type:t.type,domain:t.domain,allowDataOverflow:t.allowDataOverflow,dataKey:t.dataKey,allowDuplicatedCategory:t.allowDuplicatedCategory,allowDecimals:t.allowDecimals,tickCount:t.tickCount,padding:t.padding,includeHidden:t.includeHidden,reversed:t.reversed,ticks:t.ticks,width:t.width,orientation:t.orientation,mirror:t.mirror,hide:t.hide,unit:t.unit,name:t.name,angle:t.angle,minTickGap:t.minTickGap,tick:t.tick,tickFormatter:t.tickFormatter,niceTicks:t.niceTicks}),b.createElement(EG,t))},QW);OG.displayName=`YAxis`;function kG(e){var t=HC(),n=(0,b.useRef)(null);return(0,b.useLayoutEffect)(()=>{n.current===null?t(dB(e)):n.current!==e&&t(fB({prev:n.current,next:e})),n.current=e},[e,t]),(0,b.useLayoutEffect)(()=>()=>{n.current&&=(t(pB(n.current)),null)},[t]),null}var AG={zAxisId:0,range:xF.range,scale:xF.scale,type:xF.type};function jG(e){var t=dC(e,AG);return b.createElement(kG,{domain:t.domain,id:t.zAxisId,dataKey:t.dataKey,name:t.name,unit:t.unit,range:t.range,scale:t.scale,type:t.type,allowDuplicatedCategory:xF.allowDuplicatedCategory,allowDataOverflow:xF.allowDataOverflow,reversed:xF.reversed,includeHidden:xF.includeHidden})}jG.displayName=`ZAxis`;var MG=W([(e,t)=>t,TD,ej,lj,pL,hL,due,aD],vue);function NG(e){return`getBBox`in e.currentTarget&&typeof e.currentTarget.getBBox==`function`}function PG(e){var t=e.currentTarget.getBoundingClientRect(),n,r;if(NG(e)){var i=e.currentTarget.getBBox();n=i.width>0?t.width/i.width:1,r=i.height>0?t.height/i.height:1}else{var a=e.currentTarget;n=a.offsetWidth>0?t.width/a.offsetWidth:1,r=a.offsetHeight>0?t.height/a.offsetHeight:1}var o=(e,i)=>({relativeX:Math.round((e-t.left)/n),relativeY:Math.round((i-t.top)/r)});return`touches`in e?Array.from(e.touches).map(e=>o(e.clientX,e.clientY)):o(e.clientX,e.clientY)}var FG=XT(`mouseClick`),IG=AE();IG.startListening({actionCreator:FG,effect:(e,t)=>{var n=e.payload,r=MG(t.getState(),PG(n));r?.activeIndex!=null&&t.dispatch(Tle({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}});var LG=XT(`mouseMove`),RG=AE(),zG=null,BG=null,VG=null;RG.startListening({actionCreator:LG,effect:(e,t)=>{var n=e.payload,{throttleDelay:r,throttledEvents:i}=t.getState().eventSettings,a=i===`all`||i?.includes(`mousemove`);zG!==null&&(cancelAnimationFrame(zG),zG=null),BG!==null&&(typeof r!=`number`||!a)&&(clearTimeout(BG),BG=null),VG=PG(n);var o=()=>{var e=t.getState(),n=LI(e,e.tooltip.settings.shared);if(!VG){zG=null,BG=null;return}if(n===`axis`){var r=MG(e,VG);r?.activeIndex==null?t.dispatch(HI()):t.dispatch(UI({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}zG=null,BG=null};if(!a){o();return}r===`raf`?zG=requestAnimationFrame(o):typeof r==`number`&&BG===null&&(BG=setTimeout(o,r))}});function HG(e,t){return t instanceof HTMLElement?`HTMLElement <${t.tagName} class="${t.className}">`:t===window?`global.window`:e===`children`&&typeof t==`object`&&t?`<<CHILDREN>>`:t}var UG={accessibilityLayer:!0,barCategoryGap:`10%`,barGap:4,barSize:void 0,className:void 0,maxBarSize:void 0,stackOffset:`none`,syncId:void 0,syncMethod:`index`,baseValue:void 0,reverseStackOrder:!1},WG=aE({name:`rootProps`,initialState:UG,reducers:{updateOptions:(e,t)=>{e.accessibilityLayer=t.payload.accessibilityLayer,e.barCategoryGap=t.payload.barCategoryGap,e.barGap=t.payload.barGap??UG.barGap,e.barSize=t.payload.barSize,e.maxBarSize=t.payload.maxBarSize,e.stackOffset=t.payload.stackOffset,e.syncId=t.payload.syncId,e.syncMethod=t.payload.syncMethod,e.className=t.payload.className,e.baseValue=t.payload.baseValue,e.reverseStackOrder=t.payload.reverseStackOrder}}}),GG=WG.reducer,{updateOptions:KG}=WG.actions,qG=aE({name:`polarOptions`,initialState:null,reducers:{updatePolarOptions:(e,t)=>e===null?t.payload:(e.startAngle=t.payload.startAngle,e.endAngle=t.payload.endAngle,e.cx=t.payload.cx,e.cy=t.payload.cy,e.innerRadius=t.payload.innerRadius,e.outerRadius=t.payload.outerRadius,e)}}),{updatePolarOptions:JG}=qG.actions,YG=qG.reducer,XG=XT(`keyDown`),ZG=XT(`focus`),QG=XT(`blur`),$G=AE(),eK=null,tK=null,nK=null;$G.startListening({actionCreator:XG,effect:(e,t)=>{nK=e.payload,eK!==null&&(cancelAnimationFrame(eK),eK=null);var{throttleDelay:n,throttledEvents:r}=t.getState().eventSettings,i=r===`all`||r.includes(`keydown`);tK!==null&&(typeof n!=`number`||!i)&&(clearTimeout(tK),tK=null);var a=()=>{try{var e=t.getState();if(e.rootProps.accessibilityLayer===!1)return;var{keyboardInteraction:n}=e.tooltip,r=nK;if(r!==`ArrowRight`&&r!==`ArrowLeft`&&r!==`Enter`)return;var i=YI(n,sL(e),WF(e),dL(e)),a=i==null?-1:Number(i),o=!Number.isFinite(a)||a<0,s=hL(e),c=sL(e),l=LI(e,e.tooltip.settings.shared);if(r===`Enter`){if(o)return;var u=LL(e,l,`hover`,String(n.index));t.dispatch(GI({active:!n.active,activeIndex:n.index,activeCoordinate:u}));return}var d=gle(e)===`left-to-right`?1:-1,f=r===`ArrowRight`?1:-1,p;if(o){var m=WF(e),h=dL(e),g=f*d,_=e=>({active:!1,index:String(e),dataKey:void 0,graphicalItemId:void 0,coordinate:void 0});if(p=-1,g>0){for(var v=0;v<c.length;v++)if(YI(_(v),c,m,h)!=null){p=v;break}}else for(var y=c.length-1;y>=0;y--)if(YI(_(y),c,m,h)!=null){p=y;break}if(p<0)return}else{p=a+f*d;var b=s?.length||c.length;if(b===0||p>=b||p<0)return}var x=LL(e,l,`hover`,String(p));t.dispatch(GI({active:!0,activeIndex:p.toString(),activeCoordinate:x}))}finally{eK=null,tK=null}};if(!i){a();return}n===`raf`?eK=requestAnimationFrame(a):typeof n==`number`&&tK===null&&(a(),nK=null,tK=setTimeout(()=>{nK?a():(tK=null,eK=null)},n))}}),$G.startListening({actionCreator:ZG,effect:(e,t)=>{var n=t.getState();if(n.rootProps.accessibilityLayer!==!1){var{keyboardInteraction:r}=n.tooltip;if(!r.active&&r.index==null){var i=`0`,a=LL(n,LI(n,n.tooltip.settings.shared),`hover`,String(i));t.dispatch(GI({active:!0,activeIndex:i,activeCoordinate:a}))}}}}),$G.startListening({actionCreator:QG,effect:(e,t)=>{var n=t.getState();if(n.rootProps.accessibilityLayer!==!1){var{keyboardInteraction:r}=n.tooltip;r.active&&t.dispatch(GI({active:!1,activeIndex:r.index,activeCoordinate:r.coordinate}))}}});function rK(e){e.persist();var{currentTarget:t}=e;return new Proxy(e,{get:(e,n)=>{if(n===`currentTarget`)return t;var r=Reflect.get(e,n);return typeof r==`function`?r.bind(e):r}})}var iK=XT(`externalEvent`),aK=AE(),oK=new Map,sK=new Map,cK=new Map;aK.startListening({actionCreator:iK,effect:(e,t)=>{var{handler:n,reactEvent:r}=e.payload;if(n!=null){var i=r.type,a=rK(r);cK.set(i,{handler:n,reactEvent:a});var o=oK.get(i);o!==void 0&&(cancelAnimationFrame(o),oK.delete(i));var{throttleDelay:s,throttledEvents:c}=t.getState().eventSettings,l=c,u=l===`all`||l?.includes(i),d=sK.get(i);d!==void 0&&(typeof s!=`number`||!u)&&(clearTimeout(d),sK.delete(i));var f=()=>{var e=cK.get(i);try{if(!e)return;var{handler:n,reactEvent:r}=e,a=t.getState(),o={activeCoordinate:Zle(a),activeDataKey:SL(a),activeIndex:bL(a),activeLabel:xL(a),activeTooltipIndex:bL(a),isTooltipActive:Qle(a)};n&&n(o,r)}finally{oK.delete(i),sK.delete(i),cK.delete(i)}};if(!u){f();return}if(s===`raf`){var p=requestAnimationFrame(f);oK.set(i,p)}else if(typeof s==`number`){if(!sK.has(i)){f();var m=setTimeout(f,s);sK.set(i,m)}}else f()}}});var lK=W([W([$I],e=>e.tooltipItemPayloads),(e,t)=>t,(e,t,n)=>n],(e,t,n)=>{if(t!=null){var r=e.find(e=>e.settings.graphicalItemId===n);if(r!=null){var{getPosition:i}=r;if(i!=null)return i(t)}}}),uK=XT(`touchMove`),dK=AE(),fK=null,pK=null,mK=null,hK=null;dK.startListening({actionCreator:uK,effect:(e,t)=>{var n=e.payload;if(!(n.touches==null||n.touches.length===0)){hK=rK(n);var{throttleDelay:r,throttledEvents:i}=t.getState().eventSettings,a=i===`all`||i.includes(`touchmove`);fK!==null&&(cancelAnimationFrame(fK),fK=null),pK!==null&&(typeof r!=`number`||!a)&&(clearTimeout(pK),pK=null),mK=Array.from(n.touches).map(e=>PG({clientX:e.clientX,clientY:e.clientY,currentTarget:n.currentTarget}));var o=()=>{if(hK!=null){var e=t.getState(),n=LI(e,e.tooltip.settings.shared);if(n===`axis`){var r=mK?.[0];if(r==null){fK=null,pK=null;return}var i=MG(e,r);i?.activeIndex!=null&&t.dispatch(UI({activeIndex:i.activeIndex,activeDataKey:void 0,activeCoordinate:i.activeCoordinate}))}else if(n===`item`){var a=hK.touches[0];if(document.elementFromPoint==null||a==null)return;var o=document.elementFromPoint(a.clientX,a.clientY);if(!o||!o.getAttribute)return;var s=o.getAttribute(tD),c=o.getAttribute(`data-recharts-item-id`)??void 0,l=aL(e).find(e=>e.id===c);if(s==null||l==null||c==null)return;var{dataKey:u}=l,d=lK(e,s,c);t.dispatch(VI({activeDataKey:u,activeIndex:s,activeCoordinate:d,activeGraphicalItemId:c}))}fK=null,pK=null}};if(!a){o();return}r===`raf`?fK=requestAnimationFrame(o):typeof r==`number`&&pK===null&&(o(),hK=null,pK=setTimeout(()=>{hK?o():(pK=null,fK=null)},r))}}});var gK={throttleDelay:`raf`,throttledEvents:[`mousemove`,`touchmove`,`pointermove`,`scroll`,`wheel`]},_K=aE({name:`eventSettings`,initialState:gK,reducers:{setEventSettings:(e,t)=>{t.payload.throttleDelay!=null&&(e.throttleDelay=t.payload.throttleDelay),t.payload.throttledEvents!=null&&(e.throttledEvents=hO(t.payload.throttledEvents))}}}),{setEventSettings:vK}=_K.actions,yK=_K.reducer,bK=Tw({brush:VB,cartesianAxis:hB,chartData:Wue,errorBars:CH,eventSettings:yK,graphicalItems:tpe,layout:iie,legend:oae,options:zue,polarAxis:mfe,polarOptions:YG,referenceElements:YB,renderedTicks:PV,rootProps:GG,tooltip:Ele,zIndex:Aue}),xK=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:`Chart`;return Are({reducer:bK,preloadedState:e,middleware:e=>e({serializableCheck:!1,immutableCheck:![`commonjs`,`es6`,`production`].includes(`es6`)}).concat([IG.middleware,RG.middleware,$G.middleware,aK.middleware,dK.middleware]),enhancers:e=>{var t=e;return typeof e==`function`&&(t=e()),t.concat(rE({type:`raf`}))},devTools:kO.devToolsEnabled&&{serialize:{replacer:HG},name:`recharts-${t}`}})};function SK(e){var{preloadedState:t,children:n,reduxStoreName:r}=e,i=sD(),a=(0,b.useRef)(null);if(i)return n;a.current??=xK(t,r);var o=zC;return b.createElement(bae,{context:o,store:a.current},n)}function CK(e){var{layout:t,margin:n}=e,r=HC(),i=sD();return(0,b.useEffect)(()=>{i||(r(tie(t)),r(eie(n)))},[r,i,t,n]),null}var wK=(0,b.memo)(CK,SO);function TK(e){var t=HC();return(0,b.useEffect)(()=>{t(KG(e))},[t,e]),null}var EK=(0,b.memo)(e=>{var t=HC();return(0,b.useEffect)(()=>{t(vK(e))},[t,e]),null},SO);function DK(e){var{zIndex:t,isPanorama:n}=e,r=(0,b.useRef)(null),i=HC();return(0,b.useLayoutEffect)(()=>(r.current&&i(Oue({zIndex:t,element:r.current,isPanorama:n})),()=>{i(kue({zIndex:t,isPanorama:n}))}),[i,t,n]),b.createElement(`g`,{tabIndex:-1,ref:r,className:`recharts-zIndex-layer_${t}`})}function OK(e){var{children:t,isPanorama:n}=e,r=U(bue);if(!r||r.length===0)return t;var i=r.filter(e=>e<0),a=r.filter(e=>e>0);return b.createElement(b.Fragment,null,i.map(e=>b.createElement(DK,{key:e,zIndex:e,isPanorama:n})),t,a.map(e=>b.createElement(DK,{key:e,zIndex:e,isPanorama:n})))}var kK=[`children`];function AK(e,t){if(e==null)return{};var n,r,i=jK(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function jK(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function MK(){return MK=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},MK.apply(null,arguments)}var NK={width:`100%`,height:`100%`,display:`block`},PK=(0,b.forwardRef)((e,t)=>{var n=CD(),r=wD(),i=NO();if(!FE(n)||!FE(r))return null;var{children:a,otherAttributes:o,title:s,desc:c}=e,l,u;return o!=null&&(l=typeof o.tabIndex==`number`?o.tabIndex:i?0:void 0,u=typeof o.role==`string`?o.role:i?`application`:void 0),b.createElement(Hx,MK({},o,{title:s,desc:c,role:u,tabIndex:l,width:n,height:r,style:NK,ref:t}),a)}),FK=e=>{var{children:t}=e,n=U(lD);if(!n)return null;var{width:r,height:i,y:a,x:o}=n;return b.createElement(Hx,{width:r,height:i,x:o,y:a},t)},IK=(0,b.forwardRef)((e,t)=>{var{children:n}=e,r=AK(e,kK);return sD()?b.createElement(FK,null,b.createElement(OK,{isPanorama:!0},n)):b.createElement(PK,MK({ref:t},r),b.createElement(OK,{isPanorama:!1},n))});function LK(){var e=HC(),[t,n]=(0,b.useState)(null),r=U(vie);return(0,b.useEffect)(()=>{if(t!=null){var n=t.getBoundingClientRect().width/t.offsetWidth;PE(n)&&n!==r&&e(rie(n))}},[t,e,r]),n}function RK(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function zK(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?RK(Object(n),!0).forEach(function(t){BK(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):RK(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function BK(e,t,n){return(t=VK(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function VK(e){var t=HK(e,`string`);return typeof t==`symbol`?t:t+``}function HK(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function UK(){return UK=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},UK.apply(null,arguments)}var WK=()=>($ue(),null);function GK(e){if(typeof e==`number`)return e;if(typeof e==`string`){var t=parseFloat(e);if(!Number.isNaN(t))return t}return 0}var KK=(0,b.forwardRef)((e,t)=>{var n=(0,b.useRef)(null),[r,i]=(0,b.useState)({containerWidth:GK(e.style?.width),containerHeight:GK(e.style?.height)}),a=(0,b.useCallback)((e,t)=>{i(n=>{var r=Math.round(e),i=Math.round(t);return n.containerWidth===r&&n.containerHeight===i?n:{containerWidth:r,containerHeight:i}})},[]),o=(0,b.useCallback)(e=>{if(typeof t==`function`&&t(e),n.current!=null&&(n.current.disconnect(),n.current=null),e!=null&&typeof ResizeObserver<`u`){var{width:r,height:i}=e.getBoundingClientRect();a(r,i);var o=new ResizeObserver(e=>{var t=e[0];if(t!=null){var{width:n,height:r}=t.contentRect;a(n,r)}});o.observe(e),n.current=o}},[t,a]);return(0,b.useEffect)(()=>()=>{n.current?.disconnect()},[a]),b.createElement(b.Fragment,null,b.createElement(kD,{width:r.containerWidth,height:r.containerHeight}),b.createElement(`div`,UK({ref:o},e)))}),qK=(0,b.forwardRef)((e,t)=>{var{width:n,height:r}=e,[i,a]=(0,b.useState)({containerWidth:GK(n),containerHeight:GK(r)}),o=(0,b.useCallback)((e,t)=>{a(n=>{var r=Math.round(e),i=Math.round(t);return n.containerWidth===r&&n.containerHeight===i?n:{containerWidth:r,containerHeight:i}})},[]),s=(0,b.useCallback)(e=>{if(typeof t==`function`&&t(e),e!=null){var{width:n,height:r}=e.getBoundingClientRect();o(n,r)}},[t,o]);return b.createElement(b.Fragment,null,b.createElement(kD,{width:i.containerWidth,height:i.containerHeight}),b.createElement(`div`,UK({ref:s},e)))}),JK=(0,b.forwardRef)((e,t)=>{var{width:n,height:r}=e;return b.createElement(b.Fragment,null,b.createElement(kD,{width:n,height:r}),b.createElement(`div`,UK({ref:t},e)))}),YK=(0,b.forwardRef)((e,t)=>{var{width:n,height:r}=e;return typeof n==`string`||typeof r==`string`?b.createElement(qK,UK({},e,{ref:t})):typeof n==`number`&&typeof r==`number`?b.createElement(JK,UK({},e,{width:n,height:r,ref:t})):b.createElement(b.Fragment,null,b.createElement(kD,{width:n,height:r}),b.createElement(`div`,UK({ref:t},e)))});function XK(e){return e?KK:YK}var ZK=(0,b.forwardRef)((e,t)=>{var{children:n,className:r,height:i,onClick:a,onContextMenu:o,onDoubleClick:s,onMouseDown:c,onMouseEnter:l,onMouseLeave:u,onMouseMove:d,onMouseUp:f,onTouchEnd:p,onTouchMove:m,onTouchStart:h,style:g,width:_,responsive:v,dispatchTouchEvents:y=!0}=e,x=(0,b.useRef)(null),S=HC(),[C,w]=(0,b.useState)(null),[T,E]=(0,b.useState)(null),D=LK(),O=vD(),k=O?.width>0?O.width:_,ee=O?.height>0?O.height:i,te=(0,b.useCallback)(e=>{D(e),typeof t==`function`&&t(e),w(e),E(e),e!=null&&(x.current=e)},[D,t,w,E]),ne=(0,b.useCallback)(e=>{S(FG(e)),S(iK({handler:a,reactEvent:e}))},[S,a]),re=(0,b.useCallback)(e=>{S(LG(e)),S(iK({handler:l,reactEvent:e}))},[S,l]),A=(0,b.useCallback)(e=>{S(HI()),S(iK({handler:u,reactEvent:e}))},[S,u]),ie=(0,b.useCallback)(e=>{S(LG(e)),S(iK({handler:d,reactEvent:e}))},[S,d]),j=(0,b.useCallback)(()=>{S(ZG())},[S]),M=(0,b.useCallback)(()=>{S(QG())},[S]),ae=(0,b.useCallback)(e=>{S(XG(e.key))},[S]),oe=(0,b.useCallback)(e=>{S(iK({handler:o,reactEvent:e}))},[S,o]),se=(0,b.useCallback)(e=>{S(iK({handler:s,reactEvent:e}))},[S,s]),N=(0,b.useCallback)(e=>{S(iK({handler:c,reactEvent:e}))},[S,c]),ce=(0,b.useCallback)(e=>{S(iK({handler:f,reactEvent:e}))},[S,f]),le=(0,b.useCallback)(e=>{S(iK({handler:h,reactEvent:e}))},[S,h]),ue=(0,b.useCallback)(e=>{y&&S(uK(e)),S(iK({handler:m,reactEvent:e}))},[S,y,m]),de=(0,b.useCallback)(e=>{S(iK({handler:p,reactEvent:e}))},[S,p]),fe=XK(v);return b.createElement(JL.Provider,{value:C},b.createElement(dne.Provider,{value:T},b.createElement(fe,{width:k??g?.width,height:ee??g?.height,className:Px(`recharts-wrapper`,r),style:zK({position:`relative`,cursor:`default`,width:k,height:ee},g),onClick:ne,onContextMenu:oe,onDoubleClick:se,onFocus:j,onBlur:M,onKeyDown:ae,onMouseDown:N,onMouseEnter:re,onMouseLeave:A,onMouseMove:ie,onMouseUp:ce,onTouchEnd:de,onTouchMove:ue,onTouchStart:le,ref:te},b.createElement(WK,null),n)))}),QK=[`width`,`height`,`responsive`,`children`,`className`,`style`,`compact`,`title`,`desc`];function $K(e,t){if(e==null)return{};var n,r,i=eq(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function eq(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var tq=(0,b.forwardRef)((e,t)=>{var{width:n,height:r,responsive:i,children:a,className:o,style:s,compact:c,title:l,desc:u}=e,d=Rx($K(e,QK));return c?b.createElement(b.Fragment,null,b.createElement(kD,{width:n,height:r}),b.createElement(IK,{otherAttributes:d,title:l,desc:u},a)):b.createElement(ZK,{className:o,style:s,width:n,height:r,responsive:i??!1,onClick:e.onClick,onMouseLeave:e.onMouseLeave,onMouseEnter:e.onMouseEnter,onMouseMove:e.onMouseMove,onMouseDown:e.onMouseDown,onMouseUp:e.onMouseUp,onContextMenu:e.onContextMenu,onDoubleClick:e.onDoubleClick,onTouchStart:e.onTouchStart,onTouchMove:e.onTouchMove,onTouchEnd:e.onTouchEnd},b.createElement(IK,{otherAttributes:d,title:l,desc:u,ref:t},b.createElement(ZB,null,a)))});function nq(){return nq=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},nq.apply(null,arguments)}function rq(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function iq(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?rq(Object(n),!0).forEach(function(t){aq(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):rq(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function aq(e,t,n){return(t=oq(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function oq(e){var t=sq(e,`string`);return typeof t==`symbol`?t:t+``}function sq(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var cq=iq({accessibilityLayer:!0,barCategoryGap:`10%`,barGap:4,layout:`horizontal`,margin:{top:5,right:5,bottom:5,left:5},responsive:!1,reverseStackOrder:!1,stackOffset:`none`,syncMethod:`index`},gK),lq=(0,b.forwardRef)(function(e,t){var n=dC(e.categoricalChartProps,cq),{chartName:r,defaultTooltipEventType:i,validateTooltipEventTypes:a,tooltipPayloadSearcher:o,categoricalChartProps:s}=e,c={chartName:r,defaultTooltipEventType:i,validateTooltipEventTypes:a,tooltipPayloadSearcher:o,eventEmitter:void 0};return b.createElement(SK,{preloadedState:{options:c},reduxStoreName:s.id??r},b.createElement(RB,{chartData:s.data}),b.createElement(wK,{layout:n.layout,margin:n.margin}),b.createElement(EK,{throttleDelay:n.throttleDelay,throttledEvents:n.throttledEvents}),b.createElement(TK,{baseValue:n.baseValue,accessibilityLayer:n.accessibilityLayer,barCategoryGap:n.barCategoryGap,maxBarSize:n.maxBarSize,stackOffset:n.stackOffset,barGap:n.barGap,barSize:n.barSize,syncId:n.syncId,syncMethod:n.syncMethod,className:n.className,reverseStackOrder:n.reverseStackOrder}),b.createElement(tq,nq({},n,{ref:t})))}),uq=[`axis`,`item`],dq=(0,b.forwardRef)((e,t)=>b.createElement(lq,{chartName:`BarChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:uq,tooltipPayloadSearcher:QL,categoricalChartProps:e,ref:t}));function fq(e){var t=HC();return(0,b.useEffect)(()=>{t(JG(e))},[t,e]),null}var pq=[`layout`];function mq(){return mq=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},mq.apply(null,arguments)}function hq(e,t){if(e==null)return{};var n,r,i=gq(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function gq(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function _q(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function vq(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?_q(Object(n),!0).forEach(function(t){yq(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):_q(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function yq(e,t,n){return(t=bq(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function bq(e){var t=xq(e,`string`);return typeof t==`symbol`?t:t+``}function xq(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var Sq=vq({accessibilityLayer:!0,stackOffset:`none`,barCategoryGap:`10%`,barGap:4,margin:{top:5,right:5,bottom:5,left:5},reverseStackOrder:!1,syncMethod:`index`,layout:`radial`,responsive:!1,cx:`50%`,cy:`50%`,innerRadius:0,outerRadius:`80%`},gK),Cq=(0,b.forwardRef)(function(e,t){var n=dC(e.categoricalChartProps,Sq),{layout:r}=n,i=hq(n,pq),{chartName:a,defaultTooltipEventType:o,validateTooltipEventTypes:s,tooltipPayloadSearcher:c}=e,l={chartName:a,defaultTooltipEventType:o,validateTooltipEventTypes:s,tooltipPayloadSearcher:c,eventEmitter:void 0};return b.createElement(SK,{preloadedState:{options:l},reduxStoreName:n.id??a},b.createElement(RB,{chartData:n.data}),b.createElement(wK,{layout:r,margin:n.margin}),b.createElement(EK,{throttleDelay:n.throttleDelay,throttledEvents:n.throttledEvents}),b.createElement(TK,{baseValue:void 0,accessibilityLayer:n.accessibilityLayer,barCategoryGap:n.barCategoryGap,maxBarSize:n.maxBarSize,stackOffset:n.stackOffset,barGap:n.barGap,barSize:n.barSize,syncId:n.syncId,syncMethod:n.syncMethod,className:n.className,reverseStackOrder:n.reverseStackOrder}),b.createElement(fq,{cx:n.cx,cy:n.cy,startAngle:n.startAngle,endAngle:n.endAngle,innerRadius:n.innerRadius,outerRadius:n.outerRadius}),b.createElement(tq,mq({},i,{ref:t})))});function wq(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Tq(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?wq(Object(n),!0).forEach(function(t){Eq(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):wq(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Eq(e,t,n){return(t=Dq(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Dq(e){var t=Oq(e,`string`);return typeof t==`symbol`?t:t+``}function Oq(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var kq=[`item`],Aq=Tq(Tq({},Sq),{},{layout:`centric`,startAngle:0,endAngle:360}),jq=(0,b.forwardRef)((e,t)=>{var n=dC(e,Aq);return b.createElement(Cq,{chartName:`PieChart`,defaultTooltipEventType:`item`,validateTooltipEventTypes:kq,tooltipPayloadSearcher:QL,categoricalChartProps:n,ref:t})}),Mq=[`item`],Nq=(0,b.forwardRef)((e,t)=>b.createElement(lq,{chartName:`ScatterChart`,defaultTooltipEventType:`item`,validateTooltipEventTypes:Mq,tooltipPayloadSearcher:QL,categoricalChartProps:e,ref:t})),Pq=[`axis`],Fq=(0,b.forwardRef)((e,t)=>b.createElement(lq,{chartName:`AreaChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:Pq,tooltipPayloadSearcher:QL,categoricalChartProps:e,ref:t})),Iq=[`axis`],Lq=(0,b.forwardRef)((e,t)=>b.createElement(lq,{chartName:`ComposedChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:Iq,tooltipPayloadSearcher:QL,categoricalChartProps:e,ref:t})),Rq={ttft:{label:`TTFT`,color:`#0891b2`,fill:`rgba(8,145,178,0.08)`,unit:`ms`},total:{label:`Total Time`,color:`#dc2626`,fill:`rgba(220,38,38,0.06)`,unit:`ms`},tps:{label:`Speed`,color:`#059669`,fill:`rgba(5,150,105,0.08)`,unit:`t/s`}};function zq({active:e,payload:t,metric:n}){if(!e||!t?.length)return null;let r=t[0].payload,i=Rq[n],a=n===`tps`,o=r.avgTps>0?r.avgWallTps/r.avgTps*100:0;return(0,F.jsxs)(`div`,{className:`glass-panel rounded-2xl px-4 py-3 text-sm`,style:{minWidth:240},children:[(0,F.jsx)(`p`,{className:`text-[11px] font-semibold uppercase tracking-wider text-zinc-400 dark:text-zinc-400 mb-1`,children:String(r.label)}),(0,F.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,F.jsx)(`span`,{className:`metric-mono text-lg font-bold text-zinc-800 dark:text-zinc-300`,children:String(r[n])}),(0,F.jsxs)(`span`,{className:`text-xs text-zinc-400 dark:text-zinc-400`,children:[i.unit,` `,a?`· Active TPS`:``]})]}),a&&(0,F.jsxs)(`div`,{className:`mt-2 space-y-1`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between text-[11px]`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Active`}),(0,F.jsxs)(`span`,{className:`metric-mono font-semibold text-moss`,children:[String(r.avgTps),` tok/s`]})]}),(0,F.jsxs)(`div`,{className:`flex items-center justify-between text-[11px]`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Wall`}),(0,F.jsxs)(`span`,{className:`metric-mono font-semibold text-zinc-500 dark:text-zinc-400`,children:[String(r.tpsWall),` tok/s`]})]}),(0,F.jsxs)(`div`,{className:`flex items-center justify-between text-[11px]`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Loss`}),(0,F.jsxs)(`span`,{className:`metric-mono font-semibold ${r.tpsLoss>50?`text-ember`:r.tpsLoss>20?`text-amber`:`text-zinc-500 dark:text-zinc-400`}`,children:[r.tpsLoss.toFixed(1),`%`]})]}),(0,F.jsxs)(`div`,{className:`h-1.5 rounded-full overflow-hidden flex bg-zinc-100 dark:bg-white/[0.06]`,children:[(0,F.jsx)(`div`,{className:`h-full bg-moss`,style:{width:`${Math.max(0,Math.min(100,o))}%`}}),(0,F.jsx)(`div`,{className:`h-full bg-ember`,style:{width:`${Math.max(0,Math.min(100,100-o))}%`}})]})]}),(0,F.jsxs)(`div`,{className:`pt-1.5 border-t border-zinc-200/50 dark:border-white/[0.06] grid grid-cols-3 gap-3 text-[11px] mt-1.5`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Calls`}),(0,F.jsx)(`p`,{className:`metric-mono font-semibold text-zinc-700 dark:text-zinc-300`,children:String(r.count)})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Tokens`}),(0,F.jsxs)(`p`,{className:`metric-mono font-semibold text-zinc-700 dark:text-zinc-300`,children:[(r.totalTokens/1e3).toFixed(1),`k`]})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Avg TPS`}),(0,F.jsx)(`p`,{className:`metric-mono font-semibold text-zinc-700 dark:text-zinc-300`,children:String(r.avgTps)})]})]})]})}function Bq({buckets:e}){let[t,n]=(0,b.useState)(`ttft`),r=(0,b.useMemo)(()=>e.map(e=>({...e,ttft:e.avgTtft,total:e.avgTotal,tps:e.avgTps,tpsWall:e.avgWallTps,tpsLoss:e.avgTpsLoss})),[e]),i=Rq[t];return(0,F.jsxs)(Pu.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.2},className:`card-surface p-6`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between mb-6`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight text-zinc-800 dark:text-zinc-300`,children:`Conversation Timeline`}),(0,F.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-400 mt-0.5`,children:`Performance patterns across the session`})]}),(0,F.jsx)(`div`,{className:`flex items-center gap-1.5 bg-zinc-100/80 dark:bg-white/[0.06] rounded-xl p-1`,children:[`ttft`,`total`,`tps`].map(e=>(0,F.jsx)(`button`,{onClick:()=>n(e),className:`px-3 py-1.5 text-xs font-medium rounded-lg transition-all ${t===e?`bg-white dark:bg-zinc-600 text-zinc-800 dark:text-zinc-300 shadow-sm`:`text-zinc-400 dark:text-zinc-400 hover:text-zinc-600 dark:hover:text-zinc-200`}`,children:Rq[e].label},e))})]}),(0,F.jsx)(`div`,{className:`h-64`,children:(0,F.jsx)(yD,{width:`100%`,height:`100%`,children:(0,F.jsxs)(Fq,{data:r,margin:{top:5,right:5,left:0,bottom:0},children:[(0,F.jsx)(`defs`,{children:(0,F.jsxs)(`linearGradient`,{id:`fill-${t}`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,F.jsx)(`stop`,{offset:`5%`,stopColor:i.color,stopOpacity:.15}),(0,F.jsx)(`stop`,{offset:`95%`,stopColor:i.color,stopOpacity:0})]})}),(0,F.jsx)(xH,{strokeDasharray:`3 3`,stroke:`var(--border)`,className:`dark:opacity-40`,vertical:!1}),(0,F.jsx)(pG,{dataKey:`label`,tick:{fontSize:11,fill:`var(--text-tertiary)`},axisLine:!1,tickLine:!1,dy:8}),(0,F.jsx)(OG,{tick:{fontSize:11,fill:`var(--text-tertiary)`},axisLine:!1,tickLine:!1,dx:-4,tickFormatter:e=>e>=1e3?`${(e/1e3).toFixed(1)}k`:`${e}`}),(0,F.jsx)(sR,{content:(0,F.jsx)(zq,{metric:t})}),(0,F.jsx)(gU,{type:`monotone`,dataKey:t,stroke:i.color,strokeWidth:2,fill:`url(#fill-${t})`,animationDuration:400})]})})})]})}var Vq=(0,b.memo)(Bq);function Hq({active:e,payload:t}){if(!e||!t?.length)return null;let n=t[0].payload,r=Number(n.effectiveTps??n.tps),i=Number(n.wallTps),a=r>0?(r-i)/r*100:0,o=r>0?i/r*100:0;return(0,F.jsxs)(`div`,{className:`glass-panel rounded-2xl px-4 py-3 text-sm`,style:{minWidth:220},children:[(0,F.jsxs)(`p`,{className:`text-[11px] font-semibold uppercase tracking-wider text-zinc-400 dark:text-zinc-400 mb-2`,children:[`Request #`,Number(n.index)+1]}),(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsxs)(`div`,{className:`flex justify-between gap-2 text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Total tokens`}),(0,F.jsx)(`span`,{className:`metric-mono font-semibold text-zinc-700 dark:text-zinc-300`,children:Number(n.tokensTotal).toLocaleString()})]}),(0,F.jsxs)(`div`,{className:`flex justify-between gap-2 text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`TTFT`}),(0,F.jsx)(`span`,{className:`metric-mono font-semibold text-zinc-700 dark:text-zinc-300`,children:Jf(Number(n.ttftMs??n.y))})]}),(0,F.jsxs)(`div`,{className:`flex justify-between gap-2 text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Cache hit`}),(0,F.jsxs)(`span`,{className:`metric-mono font-semibold text-zinc-700 dark:text-zinc-300`,children:[(Number(n.cacheRatio)*100).toFixed(0),`%`]})]}),(0,F.jsxs)(`div`,{className:`flex justify-between gap-2 text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`New input`}),(0,F.jsx)(`span`,{className:`metric-mono font-semibold text-zinc-700 dark:text-zinc-300`,children:Number(n.input).toLocaleString()})]})]}),(0,F.jsxs)(`div`,{className:`mt-2 pt-2 border-t border-zinc-200/50 dark:border-white/[0.06]`,children:[(0,F.jsx)(`p`,{className:`text-[10px] font-semibold uppercase tracking-wider text-zinc-400 dark:text-zinc-400 mb-1.5`,children:`Speed`}),(0,F.jsxs)(`div`,{className:`space-y-1`,children:[(0,F.jsxs)(`div`,{className:`flex justify-between text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Active`}),(0,F.jsxs)(`span`,{className:`metric-mono font-semibold text-moss`,children:[r.toFixed(1),` tok/s`]})]}),(0,F.jsxs)(`div`,{className:`flex justify-between text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Wall`}),(0,F.jsxs)(`span`,{className:`metric-mono font-semibold text-accent`,children:[i.toFixed(1),` tok/s`]})]}),(0,F.jsxs)(`div`,{className:`flex justify-between text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Loss`}),(0,F.jsxs)(`span`,{className:`metric-mono font-semibold ${a>50?`text-ember`:a>20?`text-amber`:`text-zinc-500 dark:text-zinc-400`}`,children:[a.toFixed(1),`%`]})]}),(0,F.jsxs)(`div`,{className:`h-1.5 rounded-full overflow-hidden flex bg-zinc-100 dark:bg-white/[0.06]`,children:[(0,F.jsx)(`div`,{className:`h-full bg-moss`,style:{width:`${Math.max(0,Math.min(100,o))}%`}}),(0,F.jsx)(`div`,{className:`h-full bg-ember`,style:{width:`${Math.max(0,Math.min(100,100-o))}%`}})]})]})]}),Number(n.stallCount)>0&&(0,F.jsx)(`div`,{className:`mt-1.5 pt-1.5 border-t border-zinc-200/50 dark:border-white/[0.06]`,children:(0,F.jsxs)(`div`,{className:`flex justify-between text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-ember`,children:`Stalls`}),(0,F.jsxs)(`span`,{className:`metric-mono font-semibold text-ember`,children:[String(n.stallCount),` · `,Jf(Number(n.stallMs))]})]})})]})}function Uq({data:e,onPointClick:t,thresholds:n}){let[r,i]=(0,b.useState)(`log`),{cacheThreshold:a,lowContext:o}=n,s=(0,b.useMemo)(()=>e.map((e,t)=>({x:e.tokensTotal,y:e.ttftMs,z:e.totalMs,cacheRatio:e.cacheRatio,newRatio:e.newRatio,category:e.category,index:t,id:e.id,input:e.input,output:e.output,cacheRead:e.cacheRead,tps:e.effectiveTps,wallTps:e.wallTps,stallCount:e.stallCount,stallMs:e.stallMs,effectiveTps:e.effectiveTps,ttftMs:e.ttftMs,tokensTotal:e.tokensTotal})),[e]),c={fast:`#059669`,normal:`#0891b2`,slow:`#dc2626`,anomaly:`#d97706`},l=(0,b.useMemo)(()=>{if(s.length<=100)return s;let e=s.length/100;return s.filter((t,n)=>Math.floor(n/e)!==Math.floor((n+1)/e))},[s]),u=(0,b.useMemo)(()=>{let e=s.map(e=>e.x),t=Math.min(...e),n=Math.max(...e);return r===`log`?[Math.max(1,t*.8),n*1.1]:[0,n*1.05]},[s,r]),d=(0,b.useMemo)(()=>{let e=s.map(e=>e.y),t=Math.min(...e),n=Math.max(...e);return r===`log`?[Math.max(100,t*.8),n*1.1]:[0,n*1.05]},[s,r]);return(0,F.jsxs)(Pu.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.2},className:`card-surface p-6`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between mb-6`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight text-zinc-800 dark:text-zinc-300`,children:`TTFT vs Context Size`}),(0,F.jsxs)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-400 mt-0.5`,children:[`Color indicates cache efficiency category derived from data.`,s.length>100?` Showing ${l.length} of ${s.length} points.`:``]})]}),(0,F.jsx)(`div`,{className:`flex items-center gap-1.5 bg-zinc-100/80 dark:bg-white/[0.06] rounded-xl p-1`,children:[`log`,`linear`].map(e=>(0,F.jsx)(`button`,{onClick:()=>i(e),className:`px-3 py-1.5 text-xs font-medium rounded-lg transition-all ${r===e?`bg-white dark:bg-zinc-600 text-zinc-800 dark:text-zinc-300 shadow-sm`:`text-zinc-400 dark:text-zinc-400 hover:text-zinc-600 dark:hover:text-zinc-200`}`,children:e===`log`?`Log Scale`:`Linear`},e))})]}),(0,F.jsx)(`div`,{className:`h-72`,children:(0,F.jsx)(yD,{width:`100%`,height:`100%`,children:(0,F.jsxs)(Nq,{margin:{top:5,right:5,left:0,bottom:0},children:[(0,F.jsx)(xH,{strokeDasharray:`3 3`,stroke:`var(--border)`,className:`dark:opacity-40`}),(0,F.jsx)(pG,{type:`number`,dataKey:`x`,name:`Total Tokens`,scale:r,domain:u,tick:{fontSize:11,fill:`var(--text-tertiary)`},axisLine:!1,tickLine:!1,dy:8,tickFormatter:e=>e>=1e3?`${(e/1e3).toFixed(0)}k`:`${e}`}),(0,F.jsx)(OG,{type:`number`,dataKey:`y`,name:`TTFT (ms)`,scale:r,domain:d,tick:{fontSize:11,fill:`var(--text-tertiary)`},axisLine:!1,tickLine:!1,dx:-4,tickFormatter:e=>e>=1e3?`${(e/1e3).toFixed(1)}k`:`${e}`}),(0,F.jsx)(jG,{type:`number`,dataKey:`z`,range:[40,200]}),(0,F.jsx)(sR,{content:(0,F.jsx)(Hq,{}),cursor:{strokeDasharray:`3 3`}}),(0,F.jsx)(KW,{data:l,onClick:e=>t(e.payload.id),children:l.map((e,t)=>(0,F.jsx)(cR,{fill:c[e.category],fillOpacity:.7,cursor:`pointer`},`cell-${t}`))})]})})}),(0,F.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-x-5 gap-y-2 text-[11px]`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-moss`}),(0,F.jsxs)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:[`Fast (cached, >`,$f(a),`)`]})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-accent`}),(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Normal`})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-ember`}),(0,F.jsxs)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:[`Slow zone (`,$f(o),`–`,$f(a),`)`]})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-amber`}),(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Anomaly (massive new input)`})]})]})]})}var Wq=(0,b.memo)(Uq);function Gq({active:e,payload:t}){if(!e||!t?.length)return null;let n=t[0].payload;return(0,F.jsxs)(`div`,{className:`glass-panel rounded-2xl px-4 py-3 text-sm`,children:[(0,F.jsxs)(`p`,{className:`text-[11px] font-semibold uppercase tracking-wider text-zinc-400 dark:text-zinc-400 mb-2`,children:[`Request #`,String(n.index)]}),(0,F.jsx)(`div`,{className:`space-y-1`,children:t.map(e=>(0,F.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,F.jsx)(`div`,{className:`w-2 h-2 rounded-sm`,style:{background:e.color}}),(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400 w-20`,children:e.name}),(0,F.jsx)(`span`,{className:`metric-mono font-semibold text-zinc-700 dark:text-zinc-300`,children:e.value?.toLocaleString()})]},e.dataKey))})]})}function Kq({data:e}){return(0,F.jsxs)(Pu.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.2},className:`card-surface p-6`,children:[(0,F.jsx)(`div`,{className:`flex items-center justify-between mb-6`,children:(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight text-zinc-800 dark:text-zinc-300`,children:`Token Composition — Last 30 Requests`}),(0,F.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-400 mt-0.5`,children:`How cache, new input, and output compose each request`})]})}),(0,F.jsx)(`div`,{className:`h-60`,children:(0,F.jsx)(yD,{width:`100%`,height:`100%`,children:(0,F.jsxs)(dq,{data:e,margin:{top:5,right:5,left:0,bottom:0},barCategoryGap:`20%`,children:[(0,F.jsx)(xH,{strokeDasharray:`3 3`,stroke:`var(--border)`,className:`dark:opacity-40`,vertical:!1}),(0,F.jsx)(pG,{dataKey:`index`,tick:{fontSize:10,fill:`var(--text-tertiary)`},axisLine:!1,tickLine:!1,dy:8,interval:4}),(0,F.jsx)(OG,{tick:{fontSize:11,fill:`var(--text-tertiary)`},axisLine:!1,tickLine:!1,dx:-4,tickFormatter:e=>e>=1e3?`${(e/1e3).toFixed(0)}k`:`${e}`}),(0,F.jsx)(sR,{content:(0,F.jsx)(Gq,{})}),(0,F.jsx)(gW,{dataKey:`cacheRead`,name:`Cache Read`,stackId:`a`,fill:`#0891b2`,fillOpacity:.8,radius:[0,0,0,0]}),(0,F.jsx)(gW,{dataKey:`input`,name:`New Input`,stackId:`a`,fill:`#3f3f46`,fillOpacity:.8,radius:[0,0,0,0]}),(0,F.jsx)(gW,{dataKey:`output`,name:`Output`,stackId:`a`,fill:`#059669`,fillOpacity:.7,radius:[2,2,0,0]})]})})}),(0,F.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-x-5 gap-y-2 text-[11px]`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(`div`,{className:`w-2.5 h-2.5 rounded-sm bg-accent`}),(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Cache Read`})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(`div`,{className:`w-2.5 h-2.5 rounded-sm bg-zinc-700 dark:bg-zinc-400`}),(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`New Input`})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(`div`,{className:`w-2.5 h-2.5 rounded-sm bg-moss`}),(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Output`})]})]})]})}var qq=(0,b.memo)(Kq);function Jq({stats:e}){let t=e.filter(e=>e.ttftDelta<0&&e.above.count>0&&e.below.count>0).reduce((e,t)=>!e||t.ttftDelta<e.ttftDelta?t:e,null);return(0,F.jsxs)(Pu.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.2},className:`card-surface p-6`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 mb-5`,children:[(0,F.jsx)(rf,{size:18,className:`text-accent`,weight:`bold`}),(0,F.jsx)(`h2`,{className:`text-base font-semibold tracking-tight text-zinc-800 dark:text-zinc-300`,children:`Threshold Crossings`})]}),(0,F.jsx)(`div`,{className:`space-y-4`,children:e.map(e=>{let t=e.below.count/(e.below.count+e.above.count);return(0,F.jsxs)(`div`,{className:`group`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,F.jsxs)(`span`,{className:`text-[11px] font-semibold uppercase tracking-wider text-zinc-400 dark:text-zinc-400`,children:[`At `,$f(e.threshold),` tokens`]}),(0,F.jsxs)(`span`,{className:`text-[11px] metric-mono text-zinc-400 dark:text-zinc-400`,children:[e.above.count,` above`]})]}),(0,F.jsx)(`div`,{className:`h-1.5 bg-zinc-100 dark:bg-white/[0.06] rounded-full overflow-hidden mb-3`,children:(0,F.jsx)(Pu.div,{className:`h-full rounded-full bg-accent`,initial:{width:0},animate:{width:`${t*100}%`},transition:{duration:.4,ease:`easeOut`}})}),(0,F.jsxs)(`div`,{className:`grid grid-cols-3 gap-3`,children:[(0,F.jsxs)(`div`,{className:`text-center`,children:[(0,F.jsx)(`p`,{className:`metric-mono text-sm font-bold text-zinc-700 dark:text-zinc-300`,children:Jf(Math.round(e.below.avgTtft))}),(0,F.jsx)(`p`,{className:`text-[10px] text-zinc-400 dark:text-zinc-400 mt-0.5`,children:`Below`})]}),(0,F.jsx)(`div`,{className:`flex items-center justify-center`,children:(0,F.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded-full ${e.ttftDelta>0?`bg-ember/10 text-ember`:e.ttftDelta<0?`bg-moss/10 text-moss`:`bg-zinc-100 dark:bg-white/[0.04] text-zinc-400 dark:text-zinc-400`}`,children:[e.ttftDelta>0?(0,F.jsx)(Rf,{size:10}):e.ttftDelta<0?(0,F.jsx)(If,{size:10}):(0,F.jsx)(vf,{size:10}),e.ttftDelta!==0&&(0,F.jsx)(`span`,{className:`metric-mono`,children:Jf(Math.abs(Math.round(e.ttftDelta)))})]})}),(0,F.jsxs)(`div`,{className:`text-center`,children:[(0,F.jsx)(`p`,{className:`metric-mono text-sm font-bold text-zinc-700 dark:text-zinc-300`,children:Jf(Math.round(e.above.avgTtft))}),(0,F.jsx)(`p`,{className:`text-[10px] text-zinc-400 dark:text-zinc-400 mt-0.5`,children:`Above`})]})]})]},e.threshold)})}),(0,F.jsx)(`div`,{className:`mt-5 pt-4 border-t border-zinc-100 dark:border-white/[0.06]`,children:t?(0,F.jsxs)(`p`,{className:`text-xs leading-relaxed text-zinc-500 dark:text-zinc-400`,children:[`The `,(0,F.jsxs)(`span`,{className:`metric-mono font-semibold text-zinc-700 dark:text-zinc-300`,children:[$f(t.threshold),` threshold`]}),` shows the strongest improvement signal — TTFT drops by`,` `,(0,F.jsx)(`span`,{className:`metric-mono font-semibold text-moss`,children:Jf(Math.abs(Math.round(t.ttftDelta)))}),` `,`once requests cross it, indicating a meaningful TTFT shift at this boundary.`]}):(0,F.jsx)(`p`,{className:`text-xs leading-relaxed text-zinc-500 dark:text-zinc-400`,children:`No threshold shows a significant TTFT improvement above it. Requests remain consistently timed across token counts.`})})]})}var Yq=b.memo(Jq);function Xq({anomalies:e}){if(e.length===0)return(0,F.jsxs)(Pu.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.2},className:`card-surface p-6`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 mb-4`,children:[(0,F.jsx)(`div`,{className:`p-1.5 bg-moss/10 rounded-lg`,children:(0,F.jsx)(mf,{size:16,className:`text-moss`,weight:`bold`})}),(0,F.jsx)(`h2`,{className:`text-base font-semibold tracking-tight text-zinc-800 dark:text-zinc-300`,children:`Anomaly Detector`})]}),(0,F.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-400`,children:`No anomalies detected in this session.`})]});let t=e=>{switch(e){case`high`:return`bg-ember/8 border-ember/20 text-ember`;case`medium`:return`bg-amber/8 border-amber/20 text-amber`;default:return`bg-zinc-100 border-zinc-200 dark:bg-white/[0.06] dark:border-white/[0.08] text-zinc-500 dark:text-zinc-400`}};return(0,F.jsxs)(Pu.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.2},className:`card-surface p-6`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between mb-5`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`div`,{className:`p-1.5 bg-amber/10 rounded-lg`,children:(0,F.jsx)(Wf,{size:16,className:`text-amber`,weight:`bold`})}),(0,F.jsx)(`h2`,{className:`text-base font-semibold tracking-tight text-zinc-800 dark:text-zinc-300`,children:`Anomaly Detector`})]}),(0,F.jsxs)(`span`,{className:`text-[11px] metric-mono font-semibold text-zinc-400 dark:text-zinc-400`,children:[e.length,` found`]})]}),(0,F.jsx)(`div`,{className:`space-y-2.5 max-h-80 overflow-y-auto scrollbar-thin`,children:e.map(e=>(0,F.jsx)(`div`,{className:`p-3 rounded-xl border ${t(e.severity)}`,children:(0,F.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,F.jsxs)(`div`,{className:`mt-0.5`,children:[e.type===`cache-drop`&&(0,F.jsx)(mf,{size:14,weight:`bold`}),e.type===`slow-zone`&&(0,F.jsx)(Wf,{size:14,weight:`bold`}),e.type===`high-new-input`&&(0,F.jsx)(Wf,{size:14,weight:`bold`}),e.type===`stall-spike`&&(0,F.jsx)(Wf,{size:14,weight:`bold`})]}),(0,F.jsxs)(`div`,{className:`min-w-0`,children:[(0,F.jsx)(`p`,{className:`text-xs font-medium text-zinc-700 dark:text-zinc-300`,children:e.description}),(0,F.jsxs)(`p`,{className:`text-[10px] metric-mono text-zinc-400 dark:text-zinc-400 mt-1`,children:[`#`,e.index+1,` · total=`,e.tokensTotal.toLocaleString(),e.energyCostUsd!==null&&` · ${(e.energyCostUsd*100).toFixed(2)}c`,e.energyCostUsd===null&&e.tokenCostUsd!==null&&` · ~${(e.tokenCostUsd*100).toFixed(2)}c`]})]})]})},`${e.eventId}-${e.type}`))})]})}var Zq=b.memo(Xq);function Qq(e,t,n){let r=Array(e);return new Proxy(r,{get(r,i,a){if(typeof i==`string`){let a=i.charCodeAt(0);if(a>=48&&a<=57){let a=+i;if(Number.isInteger(a)&&a>=0&&a<e){let e=r[a];if(!e){let i=t[a*2];e=r[a]={index:a,key:n(a),start:i,size:t[a*2+1],end:i+t[a*2+1],lane:0}}return e}}if(i===`length`)return e}return Reflect.get(r,i,a)}})}function $q(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o=e();return o.length!==r.length||o.some((e,t)=>r[t]!==e)?(r=o,i=t(...o),n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i):i}return o.updateDeps=e=>{r=e},o}function eJ(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var tJ=(e,t)=>Math.abs(e-t)<1.01,nJ=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},rJ,iJ=()=>{if(rJ!==void 0)return rJ;if(typeof navigator>`u`)return rJ=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return rJ=!0;let e=navigator.maxTouchPoints;return rJ=navigator.platform===`MacIntel`&&e!==void 0&&e>0},aJ=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},oJ=e=>e,sJ=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,r=Array(n);for(let e=0;e<n;e++)r[e]=t+e;return r},cJ=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(aJ(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(aJ(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},lJ={passive:!0},uJ=typeof window>`u`?!0:`onscrollend`in window,dJ=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&uJ,o=0,s=a?null:nJ(i,()=>t(o,!1),e.options.isScrollingResetDelay),c=e=>()=>{o=n(r),s?.(),t(o,e)},l=c(!0),u=c(!1);return r.addEventListener(`scroll`,l,lJ),a&&r.addEventListener(`scrollend`,u,lJ),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u)}},fJ=(e,t)=>dJ(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),pJ=(e,t,n)=>{if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},mJ=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:e+t,behavior:n})},hJ=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);for(let[e,n]of this.elementsCache)if(n===t){this.elementsCache.delete(e);break}return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{let t={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:oJ,rangeExtractor:sJ,onChange:()=>{},measureElement:pJ,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:`estimate`};for(let n in e){let r=e[n];r!==void 0&&(t[n]=r)}this.options=t},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=$q(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}if(this.scrollElement=e,this.scrollElement&&`ownerDocument`in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{this._intendedScrollOffset!==null&&Math.abs(e-this._intendedScrollOffset)<1.5&&(e=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0,this.scrollDirection=t?this.getScrollOffset()<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),`addEventListener`in this.scrollElement){let e=this.scrollElement,t=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},n=()=>{this._iosTouching=!1,!(!iJ()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener(`touchstart`,t,lJ),e.addEventListener(`touchend`,n,lJ),this.unsubs.push(()=>{e.removeEventListener(`touchstart`,t),e.removeEventListener(`touchend`,n),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;let e=this.getScrollOffset(),t=this.getMaxScrollOffset();if(e<0||e>t)return;let n=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(e,{adjustments:this.scrollAdjustments+=n,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,t)=>{let n=new Map,r=new Map;for(let i=t-1;i>=0;i--){let t=e[i];if(n.has(t.lane))continue;let a=r.get(t.lane);if(a==null||t.end>a.end?r.set(t.lane,t):t.end<a.end&&n.set(t.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((e,t)=>e.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=$q(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode],(e,t,n,r,i,a,o)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o}),{key:!1}),this.getMeasurements=$q(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o},s)=>{let c=this.itemSizeCache;if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let l=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1),a===1){let i=this.options.gap,a=e*2,o=this._flatMeasurements;if(!o||o.length<a){let e=new Float64Array(a);o&&l>0&&e.set(o.subarray(0,l*2)),o=e,this._flatMeasurements=o}let s;if(l===0)s=t+n;else{let e=l-1;s=o[e*2]+o[e*2+1]+i}for(let t=l;t<e;t++){let e=r(t),n=c.get(e),a=typeof n==`number`?n:this.options.estimateSize(t);o[t*2]=s,o[t*2+1]=a,s+=a+i}let u=Qq(e,o,r);return this.measurementsCache=u,u}let u=this.measurementsCache.slice(0,l),d=Array(a).fill(void 0);for(let e=0;e<l;e++){let t=u[e];t&&(d[t.lane]=e)}for(let i=l;i<e;i++){let e=r(i),a=this.laneAssignments.get(i),s,l,f=o===`estimate`||c.has(e);if(a!==void 0&&this.options.lanes>1){s=a;let e=d[s],r=e===void 0?void 0:u[e];l=r?r.end+this.options.gap:t+n}else{let e=this.options.lanes===1?u[i-1]:this.getFurthestMeasurement(u,i);l=e?e.end+this.options.gap:t+n,s=e?e.lane:i%this.options.lanes,this.options.lanes>1&&f&&this.laneAssignments.set(i,s)}let p=c.get(e),m=typeof p==`number`?p:this.options.estimateSize(i),h=l+m;u[i]={index:i,start:l,size:m,end:h,key:e,lane:s},d[s]=i}return this.measurementsCache=u,u},{key:!1,debug:()=>this.options.debug}),this.calculateRange=$q(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?_J({measurements:e,outerSize:t,scrollOffset:n,lanes:r,flat:r===1&&this._flatMeasurements!=null?this._flatMeasurements:null}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=$q(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{if(e<0||e>=this.options.count)return;let n,r,i,a=this._flatMeasurements;if(this.options.lanes===1&&a!==null)i=this.options.getItemKey(e),r=a[e*2],n=a[e*2+1];else{let t=this.measurementsCache[e];if(!t)return;i=t.key,r=t.start,n=t.size}let o=t-(this.itemSizeCache.get(i)??n);o!==0&&(this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?r<this.getScrollOffset()+this.scrollAdjustments&&this.scrollDirection!==`backward`:this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:i,start:r,size:n,end:r+n,lane:0},o,this))&&(iJ()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=o:this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=o,behavior:void 0})),(this.pendingMin===null||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(i,t),this.itemSizeCacheVersion++,this.notify(!1))},this.getVirtualItems=$q(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length===0)return;let n=this._flatMeasurements,r=this.options.lanes===1&&n!=null;return eJ(t[gJ(0,t.length-1,r?e=>n[e*2]:e=>eJ(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`)if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{let r=this.getOffsetForAlignment(e,t),i=this.now();this.scrollState={index:null,align:t,behavior:n,startedAt:i,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e,r=this.now();this.scrollState={index:null,align:`start`,behavior:t,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1){let n=e.length-1,r=this._flatMeasurements;t=r==null?e[n]?.end??0:r[n*2]+r[n*2+1]}else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{let e=[];if(this.itemSizeCache.size===0)return e;let t=this.getMeasurements();for(let n of t)n&&this.itemSizeCache.has(n.key)&&e.push({index:n.index,key:n.key,start:n.start,size:n.size,end:n.end,lane:n.lane});return e},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this._intendedScrollOffset=e+(t??0),this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&tJ(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.getScrollOffset()!==t&&this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,n){let e=this.getSize()||600,n=Math.abs(t-this.getScrollOffset()),r=this.scrollState.behavior===`smooth`&&n>e;this.scrollState.lastTargetOffset=t,r||(this.scrollState.behavior=`auto`),this._scrollToOffset(t,{adjustments:void 0,behavior:r?`smooth`:`auto`})}this.scheduleScrollReconcile()}},gJ=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function _J({measurements:e,outerSize:t,scrollOffset:n,lanes:r,flat:i}){let a=e.length-1,o=i?e=>i[e*2]:t=>e[t].start,s=i?e=>i[e*2]+i[e*2+1]:t=>e[t].end;if(e.length<=r)return{startIndex:0,endIndex:a};let c=gJ(0,a,o,n),l=c;if(r===1)for(;l<a&&s(l)<n+t;)l++;else if(r>1){let i=Array(r).fill(0);for(;l<a&&i.some(e=>e<n+t);){let t=e[l];i[t.lane]=t.end,l++}let o=Array(r).fill(n+t);for(;c>=0&&o.some(e=>e>=n);){let t=e[c];o[t.lane]=t.start,c--}c=Math.max(0,c-c%r),l=Math.min(a,l+(r-1-l%r))}return{startIndex:c,endIndex:l}}var vJ=typeof document<`u`?b.useLayoutEffect:b.useEffect;function yJ({useFlushSync:e=!0,...t}){let n=b.useReducer(e=>e+1,0)[1],r={...t,onChange:(r,i)=>{var a;e&&i?(0,UL.flushSync)(n):n(),(a=t.onChange)==null||a.call(t,r,i)}},[i]=b.useState(()=>new hJ(r));return i.setOptions(r),vJ(()=>i._didMount(),[]),vJ(()=>i._willUpdate()),i}function bJ(e){return yJ({observeElementRect:cJ,observeElementOffset:fJ,scrollToFn:mJ,...e})}var xJ=e=>e.substring(11,19),SJ=e=>{let t=new Date(e);return`${t.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`})} · ${t.toLocaleTimeString(`en-US`,{hour12:!1,hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}`};function CJ(e){return e.type===`tps`}var wJ=60;function TJ({timeline:e,selectedId:t,onSelect:n,thresholds:r}){let i=(0,b.useMemo)(()=>e.filter(CJ),[e]),a=(0,b.useMemo)(()=>i.map(e=>{let t=e.tokensTotal||1;return e.tokensCacheRead/t*100}),[i]),o=(0,b.useMemo)(()=>a.length===0?0:a.reduce((e,t)=>e+t,0)/a.length,[a]),s=(0,b.useMemo)(()=>t?i.findIndex(e=>e.id===t):-1,[t,i]),c=(0,b.useMemo)(()=>{if(a.length<=wJ)return a.map((e,t)=>({rate:e,startIndex:t,count:1}));let e=Math.ceil(a.length/wJ),t=[];for(let n=0;n<a.length;n+=e){let r=a.slice(n,Math.min(n+e,a.length)),i=r.reduce((e,t)=>e+t,0)/r.length;t.push({rate:i,startIndex:n,count:r.length})}return t},[a]),l=e,u=(0,b.useRef)(null),d=(0,b.useCallback)(e=>{n(e)},[n]),f=t?l.find(e=>e.id===t):null,p=e=>{let t=e.tokensTotal,n=e.ttftMs,i=e.tokensInput/t;return e.tokensInput>r.anomalyInputThreshold?{label:`anomaly`,color:`text-amber bg-amber/5 border-amber/20`}:n>r.slowTtft&&t<r.cacheThreshold?{label:`slow`,color:`text-ember bg-ember/5 border-ember/20`}:t>r.cacheThreshold&&n<r.fastTtft&&i<r.highNewInputRatio?{label:`fast`,color:`text-moss bg-moss/5 border-moss/20`}:{label:`normal`,color:`text-zinc-400 bg-zinc-50/50 dark:bg-white/[0.04] border-zinc-100 dark:border-white/[0.08]`}},m=e=>e.split(`/`).pop()??e,h=f&&CJ(f)?f:null;return(0,F.jsxs)(Pu.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.2},className:`card-surface p-0 overflow-hidden flex flex-col`,style:{maxHeight:`750px`},children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between p-5 pb-4 border-b border-zinc-100 dark:border-white/[0.06]`,children:[(0,F.jsx)(`h2`,{className:`text-base font-semibold tracking-tight text-zinc-800 dark:text-zinc-300`,children:`Request Inspector`}),(0,F.jsxs)(`span`,{className:`text-[11px] metric-mono font-semibold text-zinc-400 dark:text-zinc-400`,children:[i.length,` calls`]})]}),(0,F.jsxs)(`div`,{className:`px-5 pt-4 pb-3 border-b border-zinc-100 dark:border-white/[0.06]`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(kd,{size:12,className:`text-accent`,weight:`bold`}),(0,F.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-wider text-zinc-400 dark:text-zinc-400`,children:`Cache Hit Rate`})]}),(0,F.jsxs)(`span`,{className:`metric-mono text-[11px] font-semibold text-zinc-500 dark:text-zinc-400`,children:[o.toFixed(0),`% avg`]})]}),(0,F.jsx)(`div`,{className:`relative flex h-8 overflow-hidden gap-px`,title:`Cache hit rate · avg ${o.toFixed(0)}%${a.length>wJ?` · aggregated into ${c.length} bins`:``}`,children:c.map((e,t)=>{let n=Math.max(4,e.rate/100*100),r=e.rate>=80?`bg-moss`:e.rate>=50?`bg-accent`:e.rate>=20?`bg-amber`:`bg-ember`,a=s>=e.startIndex&&s<e.startIndex+e.count;return(0,F.jsxs)(`button`,{onClick:()=>d(i[e.startIndex].id),className:`flex-1 relative group cursor-pointer focus:outline-none focus-visible:ring-1 focus-visible:ring-accent ${a?`z-10`:``}`,title:e.count===1?`#${e.startIndex+1} · ${e.rate.toFixed(0)}% cache hit`:`#${e.startIndex+1}–${e.startIndex+e.count} · avg ${e.rate.toFixed(0)}% cache hit`,children:[(0,F.jsx)(`div`,{className:`absolute inset-0 rounded-sm transition-colors ${a?`bg-accent/10`:`group-hover:bg-accent/[0.07]`}`}),(0,F.jsx)(`div`,{className:`absolute inset-0 flex items-end`,children:(0,F.jsx)(`div`,{className:`w-full rounded-sm ${r} transition-opacity ${a?`opacity-100`:`opacity-70 group-hover:opacity-90`}`,style:{height:`${n}%`}})})]},t)})}),(0,F.jsxs)(`div`,{className:`flex items-center justify-between mt-1.5 text-[9px] metric-mono text-zinc-400 dark:text-zinc-400`,children:[(0,F.jsxs)(`span`,{children:[`#`,1]}),(0,F.jsxs)(`span`,{children:[`#`,a.length]})]})]}),(0,F.jsx)(`div`,{className:`flex-1 overflow-hidden`,style:{minHeight:`400px`},children:h?(0,F.jsxs)(`div`,{className:`h-full w-full overflow-y-auto scrollbar-thin p-5 space-y-5`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`p`,{className:`text-[11px] font-semibold uppercase tracking-wider text-zinc-400 dark:text-zinc-400`,children:`Request Detail`}),(0,F.jsxs)(`p`,{className:`metric-mono text-lg font-bold text-zinc-800 dark:text-zinc-300 mt-0.5`,children:[`#`,s+1,` of `,i.length]})]}),(0,F.jsx)(`button`,{onClick:()=>d(null),className:`p-2 rounded-xl bg-zinc-100 dark:bg-white/[0.04] hover:bg-zinc-200 dark:hover:bg-white/[0.08] transition-colors active:scale-[0.95]`,children:(0,F.jsx)(Kf,{size:16,className:`text-zinc-500 dark:text-zinc-400`})})]}),(0,F.jsx)(`div`,{className:`inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-[11px] font-semibold uppercase tracking-wider border ${p(h).color}`,children:p(h).label}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,F.jsx)(NJ,{icon:zd,label:`Timestamp`,value:SJ(h.timestamp)}),(0,F.jsx)(NJ,{icon:cf,label:`ID`,value:h.id.substring(0,8)})]}),(0,F.jsxs)(`div`,{className:`space-y-3`,children:[(0,F.jsx)(`p`,{className:`text-[11px] font-semibold uppercase tracking-wider text-zinc-400 dark:text-zinc-400`,children:`Model`}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:[(0,F.jsx)(PJ,{label:`Provider`,value:h.provider}),(0,F.jsx)(PJ,{label:`Model`,value:m(h.modelId),fullValue:h.modelId})]})]}),(0,F.jsxs)(`div`,{className:`space-y-3`,children:[(0,F.jsx)(`p`,{className:`text-[11px] font-semibold uppercase tracking-wider text-zinc-400 dark:text-zinc-400`,children:`Token Breakdown`}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:[(0,F.jsx)(FJ,{label:`Total`,value:h.tokensTotal,color:`bg-zinc-800 dark:bg-zinc-300`}),(0,F.jsx)(FJ,{label:`New Input`,value:h.tokensInput,color:`bg-zinc-600 dark:bg-zinc-400`}),(0,F.jsx)(FJ,{label:`Cache Read`,value:h.tokensCacheRead,color:`bg-accent`}),(0,F.jsx)(FJ,{label:`Output`,value:h.tokensOutput,color:`bg-moss`})]}),(0,F.jsx)(`div`,{className:`h-2 bg-zinc-100 dark:bg-white/[0.06] rounded-full overflow-hidden flex`,children:h.tokensTotal>0&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`div`,{className:`h-full bg-accent`,style:{width:`${h.tokensCacheRead/h.tokensTotal*100}%`}}),(0,F.jsx)(`div`,{className:`h-full bg-zinc-600 dark:bg-zinc-400`,style:{width:`${h.tokensInput/h.tokensTotal*100}%`}}),(0,F.jsx)(`div`,{className:`h-full bg-moss`,style:{width:`${h.tokensOutput/h.tokensTotal*100}%`}})]})}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3 text-[10px]`,children:[(0,F.jsxs)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:[`Cache: `,(h.tokensCacheRead/h.tokensTotal*100).toFixed(0),`%`]}),(0,F.jsxs)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:[`New: `,(h.tokensInput/h.tokensTotal*100).toFixed(0),`%`]}),(0,F.jsxs)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:[`Out: `,(h.tokensOutput/h.tokensTotal*100).toFixed(0),`%`]})]})]}),(0,F.jsxs)(`div`,{className:`space-y-3`,children:[(0,F.jsx)(`p`,{className:`text-[11px] font-semibold uppercase tracking-wider text-zinc-400 dark:text-zinc-400`,children:`Timing`}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:[(0,F.jsx)(IJ,{label:`TTFT`,value:Jf(h.ttftMs),highlight:!0}),(0,F.jsx)(IJ,{label:`Total`,value:Jf(h.totalMs)}),(0,F.jsx)(IJ,{label:`Generation`,value:Jf(h.generationMs)}),(0,F.jsx)(IJ,{label:`Stall`,value:Jf(h.stallMs),warn:h.stallMs>0})]})]}),(0,F.jsxs)(`div`,{className:`space-y-3`,children:[(0,F.jsx)(`p`,{className:`text-[11px] font-semibold uppercase tracking-wider text-zinc-400 dark:text-zinc-400`,children:`Speed Breakdown`}),(()=>{let e=h.effectiveTps,t=h.wallTps,n=e>0?(e-t)/e*100:0,r=e>0?t/e*100:0,i=h.generationMs>0?h.stallMs/h.generationMs*100:0;return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,F.jsxs)(`div`,{className:`bg-moss/5 dark:bg-moss/10 rounded-xl px-2 sm:px-3 py-2.5 text-center`,children:[(0,F.jsx)(`p`,{className:`text-[9px] font-medium uppercase tracking-wider text-zinc-400 dark:text-zinc-400`,children:`Active`}),(0,F.jsx)(`p`,{className:`metric-mono text-sm font-bold text-moss mt-0.5`,children:Zf(e)}),(0,F.jsx)(`p`,{className:`text-[9px] text-zinc-400 dark:text-zinc-500`,children:`tok/s`})]}),(0,F.jsxs)(`div`,{className:`bg-accent/5 dark:bg-accent/10 rounded-xl px-2 sm:px-3 py-2.5 text-center`,children:[(0,F.jsx)(`p`,{className:`text-[9px] font-medium uppercase tracking-wider text-zinc-400 dark:text-zinc-400`,children:`Wall`}),(0,F.jsx)(`p`,{className:`metric-mono text-sm font-bold text-accent mt-0.5`,children:Zf(t)}),(0,F.jsx)(`p`,{className:`text-[9px] text-zinc-400 dark:text-zinc-500`,children:`tok/s`})]}),(0,F.jsxs)(`div`,{className:`bg-ember/5 dark:bg-ember/10 rounded-xl px-2 sm:px-3 py-2.5 text-center`,children:[(0,F.jsx)(`p`,{className:`text-[9px] font-medium uppercase tracking-wider text-zinc-400 dark:text-zinc-400`,children:`Loss`}),(0,F.jsxs)(`p`,{className:`metric-mono text-sm font-bold mt-0.5 ${n>50?`text-ember`:n>20?`text-amber`:`text-zinc-500 dark:text-zinc-400`}`,children:[n.toFixed(1),`%`]}),(0,F.jsx)(`p`,{className:`text-[9px] text-zinc-400 dark:text-zinc-500`,children:`of active`})]})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between text-[10px] mb-1`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Throughput retention`}),(0,F.jsxs)(`span`,{className:`metric-mono text-zinc-500 dark:text-zinc-400`,children:[r.toFixed(0),`%`]})]}),(0,F.jsxs)(`div`,{className:`h-2 rounded-full overflow-hidden flex bg-zinc-100 dark:bg-white/[0.06]`,children:[(0,F.jsx)(`div`,{className:`h-full bg-moss`,style:{width:`${Math.max(0,Math.min(100,r))}%`}}),(0,F.jsx)(`div`,{className:`h-full bg-ember`,style:{width:`${Math.max(0,Math.min(100,100-r))}%`}})]})]}),h.stallMs>0&&(0,F.jsxs)(`div`,{className:`flex items-center justify-between text-[10px] bg-amber/5 dark:bg-amber/10 rounded-lg px-3 py-2`,children:[(0,F.jsx)(`span`,{className:`text-amber`,children:`Stalls`}),(0,F.jsxs)(`span`,{className:`metric-mono text-amber`,children:[h.stallCount,` · `,Jf(h.stallMs),` · `,i.toFixed(0),`% gen time`]})]}),h.tps!==h.effectiveTps&&h.tps>0&&(0,F.jsxs)(`p`,{className:`text-[10px] text-zinc-400 dark:text-zinc-500`,title:`Stored TPS from extension (computed before stall-guard fix, may include inflation)`,children:[`Stored raw TPS: `,Zf(h.tps)]})]})})()]}),(0,F.jsxs)(`div`,{className:`space-y-3`,children:[(0,F.jsx)(`p`,{className:`text-[11px] font-semibold uppercase tracking-wider text-zinc-400 dark:text-zinc-400`,children:`Energy & Cost`}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:[(0,F.jsx)(IJ,{label:`Energy`,value:h.energyJoules===null?`-`:`${h.energyJoules.toFixed(1)}J`}),(0,F.jsx)(IJ,{label:h.costTotal===null?`Cost`:`Cost (est.)`,value:h.energyCostUsd===null?h.costTotal===null?`-`:`$${h.costTotal.toFixed(4)}`:`$${h.energyCostUsd.toFixed(4)}`})]})]})]},`detail`):(0,F.jsx)(MJ,{sorted:l,tpsEvents:i,thresholds:r,selectedId:t,selectedRef:u,onSelect:d,shortModel:m,isTpsRow:CJ})})]})}var EJ=b.memo(function({event:e,tpsIndex:t,thresholds:n,onSelect:r,shortModel:i}){let a=(0,b.useMemo)(()=>{let t=e.tokensTotal,r=e.ttftMs,i=e.tokensInput/t;return e.tokensInput>n.anomalyInputThreshold?{label:`anomaly`,color:`text-amber bg-amber/5 border-amber/20`}:r>n.slowTtft&&t<n.cacheThreshold?{label:`slow`,color:`text-ember bg-ember/5 border-ember/20`}:t>n.cacheThreshold&&r<n.fastTtft&&i<n.highNewInputRatio?{label:`fast`,color:`text-moss bg-moss/5 border-moss/20`}:{label:`normal`,color:`text-zinc-400 bg-zinc-50/50 dark:bg-white/[0.04] border-zinc-100 dark:border-white/[0.08]`}},[e,n]);return(0,F.jsxs)(`div`,{onClick:()=>r(e.id),className:`flex items-center gap-3 px-5 py-3 hover:bg-zinc-50/80 dark:hover:bg-white/[0.04] cursor-pointer active:bg-zinc-100 dark:active:bg-white/[0.08]`,children:[(0,F.jsx)(`div`,{className:`w-7 h-7 flex items-center justify-center rounded-lg bg-zinc-100 dark:bg-white/[0.06] metric-mono text-[10px] font-bold text-zinc-500 dark:text-zinc-400 shrink-0`,children:t+1}),(0,F.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`metric-mono text-xs font-semibold text-zinc-700 dark:text-zinc-300`,children:e.tokensTotal.toLocaleString()}),(0,F.jsx)(`span`,{className:`text-[10px] text-zinc-400 dark:text-zinc-400`,children:`tokens`}),(0,F.jsx)(`span`,{className:`text-[10px] text-zinc-300 dark:text-zinc-700`,children:`·`}),(0,F.jsx)(`span`,{className:`text-[10px] font-medium text-accent`,title:`${e.provider}/${e.modelId}`,children:i(e.modelId)})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5`,children:[(0,F.jsx)(`span`,{className:`text-[10px] metric-mono text-zinc-400 dark:text-zinc-400`,children:xJ(e.timestamp)}),(0,F.jsx)(`span`,{className:`text-[10px] text-zinc-300 dark:text-zinc-700`,children:`·`}),(0,F.jsxs)(`span`,{className:`text-[10px] font-medium ${e.ttftMs>n.slowTtft?`text-ember`:e.ttftMs<n.fastTtft?`text-moss`:`text-zinc-400 dark:text-zinc-400`}`,children:[`ttft `,Jf(e.ttftMs)]}),(0,F.jsx)(`span`,{className:`text-[10px] text-zinc-300 dark:text-zinc-700`,children:`·`}),(0,F.jsxs)(`span`,{className:`text-[10px] font-medium ${e.effectiveTps>40?`text-moss`:e.effectiveTps>20?`text-accent`:`text-ember`}`,children:[Zf(e.effectiveTps),` tps`]}),(0,F.jsx)(`span`,{className:`text-[10px] text-zinc-300 dark:text-zinc-700`,children:`·`}),(0,F.jsxs)(`span`,{className:`text-[10px] text-zinc-400 dark:text-zinc-400`,children:[(e.tokensCacheRead/e.tokensTotal*100).toFixed(0),`% cache`]})]})]}),(0,F.jsx)(`div`,{className:`w-1.5 h-1.5 rounded-full ${a.color.split(` `)[0].replace(`text-`,`bg-`)}`})]})});function DJ({event:e}){return e.type===`model_change`?(0,F.jsxs)(`div`,{className:`flex items-center gap-2.5 px-5 py-2 bg-accent/[0.03] dark:bg-accent/[0.06]`,children:[(0,F.jsx)(`div`,{className:`w-7 h-7 flex items-center justify-center shrink-0`,children:(0,F.jsx)(Td,{size:14,className:`text-accent`,weight:`bold`})}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,F.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wider text-accent`,children:`model →`}),(0,F.jsx)(`span`,{className:`text-[11px] font-medium text-zinc-600 dark:text-zinc-300 truncate`,title:`${e.provider}/${e.modelId}`,children:e.modelId.split(`/`).pop()}),(0,F.jsx)(`span`,{className:`text-[10px] text-zinc-400 dark:text-zinc-400`,children:e.provider}),(0,F.jsx)(`span`,{className:`text-[10px] text-zinc-300 dark:text-zinc-700 ml-auto metric-mono`,children:xJ(e.timestamp)})]})]}):e.type===`rewind`?(0,F.jsxs)(`div`,{className:`flex items-center gap-2.5 px-5 py-2 bg-ember/[0.03] dark:bg-ember/[0.06]`,children:[(0,F.jsx)(`div`,{className:`w-7 h-7 flex items-center justify-center shrink-0`,children:(0,F.jsx)(Cd,{size:14,className:`text-ember`,weight:`bold`})}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,F.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wider text-ember`,children:`rewind`}),(0,F.jsx)(`span`,{className:`text-[10px] text-zinc-400 dark:text-zinc-400`,children:`navigated`}),(0,F.jsx)(`span`,{className:`text-[10px] text-zinc-300 dark:text-zinc-700 ml-auto metric-mono`,children:xJ(e.timestamp)})]})]}):e.type===`branch_summary`?(0,F.jsxs)(`div`,{className:`flex items-center gap-2.5 px-5 py-2 bg-moss/[0.03] dark:bg-moss/[0.06]`,children:[(0,F.jsx)(`div`,{className:`w-7 h-7 flex items-center justify-center shrink-0`,children:(0,F.jsx)(Pf,{size:14,className:`text-moss`,weight:`bold`})}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,F.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wider text-moss`,children:`branch`}),(0,F.jsx)(`span`,{className:`text-[10px] text-zinc-400 dark:text-zinc-400 truncate max-w-[200px]`,children:e.summary.length>60?e.summary.substring(0,60)+`…`:e.summary}),(0,F.jsx)(`span`,{className:`text-[10px] text-zinc-300 dark:text-zinc-700 ml-auto metric-mono`,children:xJ(e.timestamp)})]})]}):null}var OJ=b.memo(TJ),kJ=60,AJ=44;function jJ(e){return CJ(e)?kJ:AJ}function MJ({sorted:e,tpsEvents:t,thresholds:n,selectedId:r,selectedRef:i,onSelect:a,shortModel:o,isTpsRow:s}){let c=(0,b.useRef)(null),l=bJ({count:e.length,getScrollElement:()=>c.current,estimateSize:t=>jJ(e[t]),overscan:8});return(0,F.jsx)(`div`,{ref:c,className:`h-full w-full overflow-y-auto scrollbar-thin`,style:{contain:`content`},children:(0,F.jsx)(`div`,{style:{height:l.getTotalSize(),width:`100%`,position:`relative`},children:l.getVirtualItems().map(c=>{let l=e[c.index];if(s(l)){let e=t.findIndex(e=>e.id===l.id);return(0,F.jsx)(`div`,{"data-index":c.index,ref:r===l.id?i:void 0,style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${c.start}px)`},children:(0,F.jsx)(EJ,{event:l,tpsIndex:e,thresholds:n,onSelect:e=>a(e),shortModel:o})},l.id)}return(0,F.jsx)(`div`,{"data-index":c.index,style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${c.start}px)`},children:(0,F.jsx)(DJ,{event:l})},l.id)})})})}function NJ({icon:e,label:t,value:n}){return(0,F.jsxs)(`div`,{className:`bg-zinc-50/80 dark:bg-white/[0.04] rounded-xl p-3`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1`,children:[(0,F.jsx)(e,{size:12,className:`text-zinc-400 dark:text-zinc-400`,weight:`bold`}),(0,F.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-wider text-zinc-400 dark:text-zinc-400`,children:t})]}),(0,F.jsx)(`p`,{className:`metric-mono text-sm font-bold text-zinc-800 dark:text-zinc-300`,children:n})]})}function PJ({label:e,value:t,fullValue:n}){return(0,F.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 bg-accent/[0.04] dark:bg-accent/[0.08] rounded-xl`,children:[(0,F.jsx)(`span`,{className:`text-[10px] font-medium text-zinc-400 dark:text-zinc-400`,children:e}),(0,F.jsx)(`span`,{className:`metric-mono text-xs font-bold text-accent truncate ml-2`,title:n??t,children:t})]})}function FJ({label:e,value:t,color:n}){return(0,F.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 bg-zinc-50/80 dark:bg-white/[0.04] rounded-xl`,children:[(0,F.jsx)(`span`,{className:`text-[10px] font-medium text-zinc-400 dark:text-zinc-400`,children:e}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(`div`,{className:`w-1.5 h-1.5 rounded-full ${n}`}),(0,F.jsx)(`span`,{className:`metric-mono text-xs font-bold text-zinc-700 dark:text-zinc-300`,children:t.toLocaleString()})]})]})}function IJ({label:e,value:t,highlight:n,warn:r}){return(0,F.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 rounded-xl ${n?`bg-accent/5`:r?`bg-ember/5`:`bg-zinc-50/80 dark:bg-white/[0.04]`}`,children:[(0,F.jsx)(`span`,{className:`text-[10px] font-medium text-zinc-400 dark:text-zinc-400`,children:e}),(0,F.jsx)(`span`,{className:`metric-mono text-xs font-bold ${n?`text-accent`:r?`text-ember`:`text-zinc-700 dark:text-zinc-300`}`,children:t})]})}function LJ({active:e,payload:t}){if(!e||!t?.length)return null;let n=t[0];return(0,F.jsxs)(`div`,{className:`glass-panel rounded-xl px-3 py-2 text-xs`,children:[(0,F.jsxs)(`span`,{className:`font-semibold text-zinc-700 dark:text-zinc-300`,children:[n.name,`:`]}),` `,(0,F.jsx)(`span`,{className:`metric-mono`,children:n.value?.toLocaleString()})]})}function RJ({overall:e,overTime:t,hitRate:n}){return(0,F.jsxs)(Pu.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.2},className:`card-surface p-6 flex flex-col`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 mb-5`,children:[(0,F.jsx)(`div`,{className:`p-1.5 bg-accent/10 dark:bg-accent/15 rounded-lg`,children:(0,F.jsx)(of,{size:16,className:`text-accent`,weight:`bold`})}),(0,F.jsx)(`h2`,{className:`text-base font-semibold tracking-tight text-zinc-800 dark:text-zinc-300`,children:`Cache Efficiency`})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-4`,children:[(0,F.jsxs)(`div`,{className:`relative`,children:[(0,F.jsx)(yD,{width:`100%`,height:160,children:(0,F.jsxs)(jq,{children:[(0,F.jsx)(Vz,{data:e,cx:`50%`,cy:`50%`,innerRadius:45,outerRadius:65,paddingAngle:2,dataKey:`value`,strokeWidth:0,children:e.map((e,t)=>(0,F.jsx)(cR,{fill:e.color,fillOpacity:.85},`cell-${t}`))}),(0,F.jsx)(sR,{content:(0,F.jsx)(LJ,{}),wrapperStyle:{zIndex:10}})]})}),(0,F.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center pointer-events-none z-0`,children:[(0,F.jsxs)(`span`,{className:`metric-mono text-2xl font-bold text-zinc-800 dark:text-zinc-300`,children:[n.toFixed(0),`%`]}),(0,F.jsx)(`span`,{className:`text-[10px] text-zinc-400 dark:text-zinc-400 font-medium uppercase tracking-wider`,children:`cache hit`})]})]}),(0,F.jsx)(`div`,{className:`flex flex-col justify-center gap-2.5`,children:e.map(t=>{let n=e.reduce((e,t)=>e+t.value,0),r=n>0?t.value/n*100:0;return(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between text-xs mb-1`,children:[(0,F.jsx)(`span`,{className:`text-zinc-500 dark:text-zinc-400 font-medium`,children:t.name}),(0,F.jsxs)(`span`,{className:`metric-mono text-zinc-700 dark:text-zinc-300 font-semibold`,children:[r.toFixed(0),`%`]})]}),(0,F.jsx)(`div`,{className:`h-1.5 bg-zinc-100 dark:bg-white/[0.06] rounded-full overflow-hidden`,children:(0,F.jsx)(Pu.div,{className:`h-full rounded-full`,style:{backgroundColor:t.color},initial:{width:0},animate:{width:`${r}%`},transition:{duration:.4,ease:`easeOut`}})})]},t.name)})})]}),(0,F.jsxs)(`div`,{className:`mt-5 pt-4 border-t border-zinc-100 dark:border-white/[0.06]`,children:[(0,F.jsx)(`p`,{className:`text-[10px] font-semibold uppercase tracking-wider text-zinc-400 dark:text-zinc-400 mb-3`,children:`Cache hit rate over time (by request range)`}),(0,F.jsx)(`div`,{className:`space-y-1.5`,children:t.map((e,t)=>{let n=e.hitRate>=80?`bg-moss`:e.hitRate>=50?`bg-accent`:e.hitRate>=20?`bg-amber`:`bg-ember`,r=e.hitRate>=80?`text-moss`:e.hitRate>=50?`text-accent`:e.hitRate>=20?`text-amber`:`text-ember`;return(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`text-[9px] metric-mono text-zinc-400 dark:text-zinc-400 w-10 shrink-0 text-right`,children:e.label}),(0,F.jsxs)(`div`,{className:`flex-1 h-4 bg-zinc-50 dark:bg-white/[0.04] rounded-sm overflow-hidden relative`,children:[(0,F.jsx)(Pu.div,{className:`h-full ${n} rounded-sm`,initial:{width:0},animate:{width:`${e.hitRate}%`},transition:{duration:.4,ease:`easeOut`}}),(0,F.jsxs)(`span`,{className:`absolute inset-y-0 right-1.5 flex items-center text-[9px] metric-mono font-semibold ${r} mix-blend-difference`,children:[e.hitRate,`%`]})]})]},t)})})]})]})}var zJ=(0,b.memo)(RJ);function BJ(e){return e.replace(/'/g,`''`)}function VJ(e,t){let n=[];return e&&n.push(`session_id = '${BJ(e)}'`),t&&n.push(`model_id = '${BJ(t)}'`),n.length===0?`WHERE 1=1`:`WHERE 1=1 AND ${n.join(` AND `)}`}function HJ(e,t,n){let r=e.columns.indexOf(n);if(r!==-1)return e.rows[t]?.[r]}function UJ(e,t,n){return HJ(e,t,n)??``}function G(e,t,n){let r=HJ(e,t,n);return r==null?0:Number(r)}function WJ(e,t,n){let r=HJ(e,t,n);return r==null?null:Number(r)}async function GJ(e,t){let n=await yx(`
239
239
  WITH tps AS (
240
- SELECT * FROM tps_paired ${HJ(e,t)}
240
+ SELECT * FROM tps_paired ${VJ(e,t)}
241
241
  ),
242
242
  aggregated AS (
243
243
  SELECT
@@ -346,7 +346,7 @@ Error generating stack: `+e.message+`
346
346
  0 AS rewind_count,
347
347
  0 AS model_change_count
348
348
  FROM aggregated
349
- `);return n.rowCount===0?null:{totalCalls:G(n,0,`total_calls`),totalTokens:G(n,0,`total_tokens`),totalInput:G(n,0,`total_input`),totalOutput:G(n,0,`total_output`),totalCacheRead:G(n,0,`total_cache_read`),totalCacheWrite:G(n,0,`total_cache_write`),wallClockMs:G(n,0,`wall_clock_ms`),totalTimeMs:G(n,0,`total_time_ms`),totalGenerationMs:G(n,0,`total_generation_ms`),totalStallMs:G(n,0,`total_stall_ms`),totalStallCount:G(n,0,`total_stall_count`),avgTps:G(n,0,`avg_tps`),weightedTps:G(n,0,`weighted_tps`),avgWallTps:G(n,0,`avg_wall_tps`),weightedWallTps:G(n,0,`weighted_wall_tps`),tpsLoss:G(n,0,`tps_loss`),weightedTpsLoss:G(n,0,`weighted_tps_loss`),avgTtft:G(n,0,`avg_ttft`),ttftP50:G(n,0,`ttft_p50`),ttftP75:G(n,0,`ttft_p75`),ttftP90:G(n,0,`ttft_p90`),ttftP99:G(n,0,`ttft_p99`),totalCostUsd:GJ(n,0,`total_cost_usd`),costSource:UJ(n,0,`cost_source`),energyCostUsd:GJ(n,0,`energy_cost_usd`),totalEnergyJoules:GJ(n,0,`total_energy_joules`),avgTokensPerCall:G(n,0,`avg_tokens_per_call`),stalledCalls:G(n,0,`stalled_calls`),cachedCalls:G(n,0,`cached_calls`),fastCalls:G(n,0,`fast_calls`),minTtft:G(n,0,`min_ttft`),maxTtft:G(n,0,`max_ttft`),model:WJ(n,0,`model`),provider:WJ(n,0,`provider`),timeRangeStart:WJ(n,0,`time_range_start`),timeRangeEnd:WJ(n,0,`time_range_end`),rewindCount:G(n,0,`rewind_count`),modelChangeCount:G(n,0,`model_change_count`)}}async function qJ(e,t){let n=await yx(`
349
+ `);return n.rowCount===0?null:{totalCalls:G(n,0,`total_calls`),totalTokens:G(n,0,`total_tokens`),totalInput:G(n,0,`total_input`),totalOutput:G(n,0,`total_output`),totalCacheRead:G(n,0,`total_cache_read`),totalCacheWrite:G(n,0,`total_cache_write`),wallClockMs:G(n,0,`wall_clock_ms`),totalTimeMs:G(n,0,`total_time_ms`),totalGenerationMs:G(n,0,`total_generation_ms`),totalStallMs:G(n,0,`total_stall_ms`),totalStallCount:G(n,0,`total_stall_count`),avgTps:G(n,0,`avg_tps`),weightedTps:G(n,0,`weighted_tps`),avgWallTps:G(n,0,`avg_wall_tps`),weightedWallTps:G(n,0,`weighted_wall_tps`),tpsLoss:G(n,0,`tps_loss`),weightedTpsLoss:G(n,0,`weighted_tps_loss`),avgTtft:G(n,0,`avg_ttft`),ttftP50:G(n,0,`ttft_p50`),ttftP75:G(n,0,`ttft_p75`),ttftP90:G(n,0,`ttft_p90`),ttftP99:G(n,0,`ttft_p99`),totalCostUsd:WJ(n,0,`total_cost_usd`),costSource:HJ(n,0,`cost_source`),energyCostUsd:WJ(n,0,`energy_cost_usd`),totalEnergyJoules:WJ(n,0,`total_energy_joules`),avgTokensPerCall:G(n,0,`avg_tokens_per_call`),stalledCalls:G(n,0,`stalled_calls`),cachedCalls:G(n,0,`cached_calls`),fastCalls:G(n,0,`fast_calls`),minTtft:G(n,0,`min_ttft`),maxTtft:G(n,0,`max_ttft`),model:UJ(n,0,`model`),provider:UJ(n,0,`provider`),timeRangeStart:UJ(n,0,`time_range_start`),timeRangeEnd:UJ(n,0,`time_range_end`),rewindCount:G(n,0,`rewind_count`),modelChangeCount:G(n,0,`model_change_count`)}}async function KJ(e,t){let n=await yx(`
350
350
  SELECT
351
351
  model_id,
352
352
  provider,
@@ -361,10 +361,10 @@ Error generating stack: `+e.message+`
361
361
  max(CASE WHEN energy_cost_usd IS NOT NULL THEN 1 ELSE 0 END) AS has_energy,
362
362
  max(CASE WHEN cost_total IS NOT NULL AND energy_cost_usd IS NULL THEN 1 ELSE 0 END) AS has_token_cost
363
363
  FROM tps_paired
364
- ${HJ(e,t)}
364
+ ${VJ(e,t)}
365
365
  GROUP BY model_id, provider
366
366
  ORDER BY blended_cost_usd DESC
367
- `),r=[];for(let e=0;e<n.rowCount;e++){let t=G(n,e,`has_energy`)>0,i=G(n,e,`has_token_cost`)>0;r.push({modelId:WJ(n,e,`model_id`),provider:WJ(n,e,`provider`),callCount:G(n,e,`call_count`),totalTokens:G(n,e,`total_tokens`),energyCostUsd:t?G(n,e,`energy_cost_usd`):null,energyJoules:t?GJ(n,e,`energy_joules`):null,blendedCostUsd:t||i?G(n,e,`blended_cost_usd`):null,costSource:t?`neuralwatt`:i?`tps`:null})}return r}async function JJ(e,t,n){let r=HJ(t,n),i=await yx(`
367
+ `),r=[];for(let e=0;e<n.rowCount;e++){let t=G(n,e,`has_energy`)>0,i=G(n,e,`has_token_cost`)>0;r.push({modelId:UJ(n,e,`model_id`),provider:UJ(n,e,`provider`),callCount:G(n,e,`call_count`),totalTokens:G(n,e,`total_tokens`),energyCostUsd:t?G(n,e,`energy_cost_usd`):null,energyJoules:t?WJ(n,e,`energy_joules`):null,blendedCostUsd:t||i?G(n,e,`blended_cost_usd`):null,costSource:t?`neuralwatt`:i?`tps`:null})}return r}async function qJ(e,t,n){let r=VJ(t,n),i=await yx(`
368
368
  SELECT
369
369
  id,
370
370
  session_id,
@@ -391,12 +391,12 @@ Error generating stack: `+e.message+`
391
391
  FROM tps_paired
392
392
  ${r}
393
393
  ORDER BY timestamp
394
- `),a=[];for(let e=0;e<i.rowCount;e++){let t=G(i,e,`tokens_total`);a.push({id:WJ(i,e,`id`),sessionId:WJ(i,e,`session_id`),timestamp:WJ(i,e,`timestamp`),tokensTotal:t,ttftMs:G(i,e,`ttft_ms`),totalMs:G(i,e,`total_ms`),cacheRatio:t>0?G(i,e,`tokens_cache_read`)/t:0,newRatio:t>0?G(i,e,`tokens_input`)/t:0,input:G(i,e,`tokens_input`),output:G(i,e,`tokens_output`),cacheRead:G(i,e,`tokens_cache_read`),effectiveTps:G(i,e,`effective_tps`),wallTps:G(i,e,`wall_tps`),stallCount:G(i,e,`stall_count`),stallMs:G(i,e,`stall_ms`),category:UJ(i,e,`category`),energyJoules:GJ(i,e,`energy_joules`),energyCostUsd:GJ(i,e,`energy_cost_usd`)})}return a}async function YJ(e,t){let n=await yx(`
394
+ `),a=[];for(let e=0;e<i.rowCount;e++){let t=G(i,e,`tokens_total`);a.push({id:UJ(i,e,`id`),sessionId:UJ(i,e,`session_id`),timestamp:UJ(i,e,`timestamp`),tokensTotal:t,ttftMs:G(i,e,`ttft_ms`),totalMs:G(i,e,`total_ms`),cacheRatio:t>0?G(i,e,`tokens_cache_read`)/t:0,newRatio:t>0?G(i,e,`tokens_input`)/t:0,input:G(i,e,`tokens_input`),output:G(i,e,`tokens_output`),cacheRead:G(i,e,`tokens_cache_read`),effectiveTps:G(i,e,`effective_tps`),wallTps:G(i,e,`wall_tps`),stallCount:G(i,e,`stall_count`),stallMs:G(i,e,`stall_ms`),category:HJ(i,e,`category`),energyJoules:WJ(i,e,`energy_joules`),energyCostUsd:WJ(i,e,`energy_cost_usd`)})}return a}async function JJ(e,t){let n=await yx(`
395
395
  WITH ranked AS (
396
396
  SELECT *,
397
397
  ntile(20) OVER (ORDER BY timestamp) AS bucket
398
398
  FROM tps_paired
399
- ${HJ(e,t)}
399
+ ${VJ(e,t)}
400
400
  )
401
401
  SELECT
402
402
  min(timestamp)::varchar || '-' || max(timestamp)::varchar AS range,
@@ -413,7 +413,7 @@ Error generating stack: `+e.message+`
413
413
  FROM ranked
414
414
  GROUP BY bucket
415
415
  ORDER BY min(timestamp)
416
- `),r=[];for(let e=0;e<n.rowCount;e++)r.push({range:WJ(n,e,`range`),label:WJ(n,e,`label`),count:G(n,e,`count`),avgTtft:G(n,e,`avg_ttft`),avgTotal:G(n,e,`avg_total`),avgTps:G(n,e,`avg_tps`),avgWallTps:G(n,e,`avg_wall_tps`),avgTpsLoss:G(n,e,`avg_tps_loss`),totalTokens:G(n,e,`total_tokens`)});return r}async function XJ(e,t){let n=await yx(`
416
+ `),r=[];for(let e=0;e<n.rowCount;e++)r.push({range:UJ(n,e,`range`),label:UJ(n,e,`label`),count:G(n,e,`count`),avgTtft:G(n,e,`avg_ttft`),avgTotal:G(n,e,`avg_total`),avgTps:G(n,e,`avg_tps`),avgWallTps:G(n,e,`avg_wall_tps`),avgTpsLoss:G(n,e,`avg_tps_loss`),totalTokens:G(n,e,`total_tokens`)});return r}async function YJ(e,t){let n=await yx(`
417
417
  SELECT
418
418
  tokens_input AS input,
419
419
  tokens_output AS output,
@@ -422,10 +422,10 @@ Error generating stack: `+e.message+`
422
422
  tokens_total AS total,
423
423
  ttft_ms AS ttft
424
424
  FROM tps_paired
425
- ${HJ(e,t)}
425
+ ${VJ(e,t)}
426
426
  ORDER BY timestamp
427
427
  LIMIT 30
428
- `),r=[];for(let e=0;e<n.rowCount;e++)r.push({index:e+1,input:G(n,e,`input`),output:G(n,e,`output`),cacheRead:G(n,e,`cache_read`),cacheWrite:G(n,e,`cache_write`),total:G(n,e,`total`),ttft:G(n,e,`ttft`)});return r}async function ZJ(e,t){let n=HJ(e,t),r=await yx(`
428
+ `),r=[];for(let e=0;e<n.rowCount;e++)r.push({index:e+1,input:G(n,e,`input`),output:G(n,e,`output`),cacheRead:G(n,e,`cache_read`),cacheWrite:G(n,e,`cache_write`),total:G(n,e,`total`),ttft:G(n,e,`ttft`)});return r}async function XJ(e,t){let n=VJ(e,t),r=await yx(`
429
429
  SELECT
430
430
  COALESCE(sum(tokens_cache_read), 0) AS cache_read,
431
431
  COALESCE(sum(tokens_input), 0) AS new_input,
@@ -448,7 +448,7 @@ Error generating stack: `+e.message+`
448
448
  FROM ranked
449
449
  GROUP BY bucket
450
450
  ORDER BY min(rn)
451
- `);for(let e=0;e<d.rowCount;e++)u.push({label:WJ(d,e,`label`),hitRate:G(d,e,`hit_rate`)});return{overall:l,overTime:u,hitRate:c}}async function QJ(e,t){let n=HJ(e,t),r=await yx(`
451
+ `);for(let e=0;e<d.rowCount;e++)u.push({label:UJ(d,e,`label`),hitRate:G(d,e,`hit_rate`)});return{overall:l,overTime:u,hitRate:c}}async function ZJ(e,t){let n=VJ(e,t),r=await yx(`
452
452
  SELECT
453
453
  CASE
454
454
  WHEN ttft_ms <= 1000 THEN '<1s'
@@ -473,7 +473,7 @@ Error generating stack: `+e.message+`
473
473
  ${n}
474
474
  GROUP BY label, bin_order
475
475
  ORDER BY bin_order
476
- `),i=[`bg-moss`,`bg-moss/70`,`bg-accent`,`bg-accent/70`,`bg-amber`,`bg-ember/70`,`bg-ember`],a=[],o=0,s=[];for(let e=0;e<r.rowCount;e++){let t=G(r,e,`cnt`);s.push(t),o+=t}let c=Math.max(...s,1);for(let e=0;e<r.rowCount;e++){let t=G(r,e,`bin_order`),n=s[e];a.push({label:WJ(r,e,`label`),count:n,pct:o>0?n/o*100:0,barPct:n/c*100,color:i[t]??`bg-zinc-400`})}let l=await yx(`
476
+ `),i=[`bg-moss`,`bg-moss/70`,`bg-accent`,`bg-accent/70`,`bg-amber`,`bg-ember/70`,`bg-ember`],a=[],o=0,s=[];for(let e=0;e<r.rowCount;e++){let t=G(r,e,`cnt`);s.push(t),o+=t}let c=Math.max(...s,1);for(let e=0;e<r.rowCount;e++){let t=G(r,e,`bin_order`),n=s[e];a.push({label:UJ(r,e,`label`),count:n,pct:o>0?n/o*100:0,barPct:n/c*100,color:i[t]??`bg-zinc-400`})}let l=await yx(`
477
477
  SELECT
478
478
  percentile_cont(0.50) WITHIN GROUP (ORDER BY ttft_ms) AS p50,
479
479
  percentile_cont(0.75) WITHIN GROUP (ORDER BY ttft_ms) AS p75,
@@ -487,7 +487,7 @@ Error generating stack: `+e.message+`
487
487
  count(*) FILTER (WHERE ttft_ms > 15000) AS slow_count
488
488
  FROM tps_paired
489
489
  ${n}
490
- `);return{bins:a,fastCount:G(d,0,`fast_count`),slowCount:G(d,0,`slow_count`),percentiles:u}}async function $J(e,t,n){let r=HJ(t,n),i=G(await yx(`SELECT COALESCE(max(tokens_total), 80000) AS max_tokens FROM tps_paired ${r}`),0,`max_tokens`),a=[Math.round(e.lowContext*.5/1e3)*1e3,e.lowContext,e.cacheThreshold,Math.round((e.cacheThreshold+(i-e.cacheThreshold)*.5)/1e3)*1e3].map(e=>yx(`
490
+ `);return{bins:a,fastCount:G(d,0,`fast_count`),slowCount:G(d,0,`slow_count`),percentiles:u}}async function QJ(e,t,n){let r=VJ(t,n),i=G(await yx(`SELECT COALESCE(max(tokens_total), 80000) AS max_tokens FROM tps_paired ${r}`),0,`max_tokens`),a=[Math.round(e.lowContext*.5/1e3)*1e3,e.lowContext,e.cacheThreshold,Math.round((e.cacheThreshold+(i-e.cacheThreshold)*.5)/1e3)*1e3].map(e=>yx(`
491
491
  SELECT
492
492
  count(*) FILTER (WHERE tokens_total >= ${e}) AS above_count,
493
493
  count(*) FILTER (WHERE tokens_total < ${e}) AS below_count,
@@ -499,7 +499,7 @@ Error generating stack: `+e.message+`
499
499
  avg(tokens_cache_read::double / NULLIF(tokens_total, 0)) FILTER (WHERE tokens_total < ${e}) AS below_avg_cache_ratio
500
500
  FROM tps_paired
501
501
  ${r}
502
- `).then(t=>{let n=G(t,0,`above_avg_ttft`)||0,r=G(t,0,`below_avg_ttft`)||0;return{threshold:e,above:{count:G(t,0,`above_count`),avgTtft:n,avgTps:G(t,0,`above_avg_tps`)||0,avgCacheRatio:G(t,0,`above_avg_cache_ratio`)||0},below:{count:G(t,0,`below_count`),avgTtft:r,avgTps:G(t,0,`below_avg_tps`)||0,avgCacheRatio:G(t,0,`below_avg_cache_ratio`)||0},ttftDelta:n-r}}));return Promise.all(a)}async function eY(e,t){let n=await yx(`
502
+ `).then(t=>{let n=G(t,0,`above_avg_ttft`)||0,r=G(t,0,`below_avg_ttft`)||0;return{threshold:e,above:{count:G(t,0,`above_count`),avgTtft:n,avgTps:G(t,0,`above_avg_tps`)||0,avgCacheRatio:G(t,0,`above_avg_cache_ratio`)||0},below:{count:G(t,0,`below_count`),avgTtft:r,avgTps:G(t,0,`below_avg_tps`)||0,avgCacheRatio:G(t,0,`below_avg_cache_ratio`)||0},ttftDelta:n-r}}));return Promise.all(a)}async function $J(e,t){let n=await yx(`
503
503
  WITH stats AS (
504
504
  SELECT
505
505
  min(tokens_total) AS min_tokens,
@@ -512,7 +512,7 @@ Error generating stack: `+e.message+`
512
512
  avg(stall_count) FILTER (WHERE stall_count > 0) AS avg_stall_count,
513
513
  avg(stall_ms) FILTER (WHERE stall_ms > 0) AS avg_stall_ms
514
514
  FROM tps_paired
515
- ${HJ(e,t)}
515
+ ${VJ(e,t)}
516
516
  )
517
517
  SELECT
518
518
  round(((min_tokens + (max_tokens - min_tokens) * 0.66)) / 1000) * 1000 AS cache_threshold,
@@ -528,7 +528,7 @@ Error generating stack: `+e.message+`
528
528
  greatest(2, round(avg_stall_count)) AS stall_count_threshold,
529
529
  round(avg_stall_ms) AS stall_ms_severity
530
530
  FROM stats
531
- `);return n.rowCount===0?{cacheThreshold:65e3,lowContext:32e3,slowTtft:15e3,fastTtft:3e3,highNewInputRatio:.15,anomalyInputThreshold:1e4,cacheDropMinTotal:1e4,cacheDropMinInput:5e3,highInputRatio:.5,highInputSeverityToken:2e4,stallCountThreshold:3,stallMsSeverity:5e3}:{cacheThreshold:G(n,0,`cache_threshold`),lowContext:G(n,0,`low_context`),slowTtft:G(n,0,`slow_ttft`),fastTtft:G(n,0,`fast_ttft`),highNewInputRatio:G(n,0,`high_new_input_ratio`),anomalyInputThreshold:G(n,0,`anomaly_input_threshold`),cacheDropMinTotal:G(n,0,`cache_drop_min_total`),cacheDropMinInput:G(n,0,`cache_drop_min_input`),highInputRatio:G(n,0,`high_input_ratio`),highInputSeverityToken:G(n,0,`high_input_severity_token`),stallCountThreshold:G(n,0,`stall_count_threshold`),stallMsSeverity:G(n,0,`stall_ms_severity`)}}async function tY(e,t,n){let r=HJ(t,n),{slowTtft:i,cacheThreshold:a,cacheDropMinTotal:o,cacheDropMinInput:s,highInputRatio:c,highInputSeverityToken:l,stallCountThreshold:u,stallMsSeverity:d,lowContext:f}=e,p=await yx(`
531
+ `);return n.rowCount===0?{cacheThreshold:65e3,lowContext:32e3,slowTtft:15e3,fastTtft:3e3,highNewInputRatio:.15,anomalyInputThreshold:1e4,cacheDropMinTotal:1e4,cacheDropMinInput:5e3,highInputRatio:.5,highInputSeverityToken:2e4,stallCountThreshold:3,stallMsSeverity:5e3}:{cacheThreshold:G(n,0,`cache_threshold`),lowContext:G(n,0,`low_context`),slowTtft:G(n,0,`slow_ttft`),fastTtft:G(n,0,`fast_ttft`),highNewInputRatio:G(n,0,`high_new_input_ratio`),anomalyInputThreshold:G(n,0,`anomaly_input_threshold`),cacheDropMinTotal:G(n,0,`cache_drop_min_total`),cacheDropMinInput:G(n,0,`cache_drop_min_input`),highInputRatio:G(n,0,`high_input_ratio`),highInputSeverityToken:G(n,0,`high_input_severity_token`),stallCountThreshold:G(n,0,`stall_count_threshold`),stallMsSeverity:G(n,0,`stall_ms_severity`)}}async function eY(e,t,n){let r=VJ(t,n),{slowTtft:i,cacheThreshold:a,cacheDropMinTotal:o,cacheDropMinInput:s,highInputRatio:c,highInputSeverityToken:l,stallCountThreshold:u,stallMsSeverity:d,lowContext:f}=e,p=await yx(`
532
532
  WITH ordered AS (
533
533
  SELECT
534
534
  id, session_id, timestamp,
@@ -599,7 +599,7 @@ Error generating stack: `+e.message+`
599
599
  ORDER BY
600
600
  CASE severity WHEN 'high' THEN 3 WHEN 'medium' THEN 2 ELSE 1 END DESC,
601
601
  idx
602
- `),m=[];for(let e=0;e<p.rowCount;e++)m.push({eventId:WJ(p,e,`id`),sessionId:WJ(p,e,`session_id`),type:UJ(p,e,`anomaly_type`),index:G(p,e,`idx`),description:WJ(p,e,`description`),severity:UJ(p,e,`severity`),tokensTotal:G(p,e,`tokens_total`),energyCostUsd:GJ(p,e,`energy_cost_usd`),tokenCostUsd:GJ(p,e,`cost_total`)});return m}async function nY(e,t){let n=await yx(`
602
+ `),m=[];for(let e=0;e<p.rowCount;e++)m.push({eventId:UJ(p,e,`id`),sessionId:UJ(p,e,`session_id`),type:HJ(p,e,`anomaly_type`),index:G(p,e,`idx`),description:UJ(p,e,`description`),severity:HJ(p,e,`severity`),tokensTotal:G(p,e,`tokens_total`),energyCostUsd:WJ(p,e,`energy_cost_usd`),tokenCostUsd:WJ(p,e,`cost_total`)});return m}async function tY(e,t){let n=await yx(`
603
603
  SELECT
604
604
  id, session_id, timestamp, 'tps' AS type,
605
605
  provider, model_id,
@@ -612,7 +612,7 @@ Error generating stack: `+e.message+`
612
612
  NULL::varchar AS from_id,
613
613
  NULL::varchar AS summary
614
614
  FROM tps_paired
615
- ${HJ(e,t)}
615
+ ${VJ(e,t)}
616
616
 
617
617
  UNION ALL
618
618
 
@@ -631,7 +631,7 @@ Error generating stack: `+e.message+`
631
631
  WHERE type IN ('model_change', 'rewind', 'branch_summary')
632
632
 
633
633
  ORDER BY timestamp
634
- `),r=[];for(let e=0;e<n.rowCount;e++){let t=WJ(n,e,`type`),i={id:WJ(n,e,`id`),sessionId:WJ(n,e,`session_id`),timestamp:WJ(n,e,`timestamp`),type:t};t===`tps`?r.push({...i,type:`tps`,provider:WJ(n,e,`provider`),modelId:WJ(n,e,`model_id`),tokensInput:G(n,e,`tokens_input`),tokensOutput:G(n,e,`tokens_output`),tokensCacheRead:G(n,e,`tokens_cache_read`),tokensCacheWrite:G(n,e,`tokens_cache_write`),tokensTotal:G(n,e,`tokens_total`),ttftMs:G(n,e,`ttft_ms`),totalMs:G(n,e,`total_ms`),generationMs:G(n,e,`generation_ms`),stallMs:G(n,e,`stall_ms`),stallCount:G(n,e,`stall_count`),effectiveTps:G(n,e,`effective_tps`),wallTps:G(n,e,`wall_tps`),tps:G(n,e,`tps`),costTotal:GJ(n,e,`cost_total`),energyJoules:GJ(n,e,`energy_joules`),energyCostUsd:GJ(n,e,`energy_cost_usd`),cacheRatio:G(n,e,`cache_ratio`)}):t===`model_change`?r.push({...i,type:`model_change`,provider:WJ(n,e,`provider`),modelId:WJ(n,e,`model_id`)}):t===`rewind`?r.push({...i,type:`rewind`,rewindV:G(n,e,`rewind_v`)}):r.push({...i,type:`branch_summary`,fromId:WJ(n,e,`from_id`),summary:WJ(n,e,`summary`)})}return r}async function rY(e){let t=await yx(`
634
+ `),r=[];for(let e=0;e<n.rowCount;e++){let t=UJ(n,e,`type`),i={id:UJ(n,e,`id`),sessionId:UJ(n,e,`session_id`),timestamp:UJ(n,e,`timestamp`),type:t};t===`tps`?r.push({...i,type:`tps`,provider:UJ(n,e,`provider`),modelId:UJ(n,e,`model_id`),tokensInput:G(n,e,`tokens_input`),tokensOutput:G(n,e,`tokens_output`),tokensCacheRead:G(n,e,`tokens_cache_read`),tokensCacheWrite:G(n,e,`tokens_cache_write`),tokensTotal:G(n,e,`tokens_total`),ttftMs:G(n,e,`ttft_ms`),totalMs:G(n,e,`total_ms`),generationMs:G(n,e,`generation_ms`),stallMs:G(n,e,`stall_ms`),stallCount:G(n,e,`stall_count`),effectiveTps:G(n,e,`effective_tps`),wallTps:G(n,e,`wall_tps`),tps:G(n,e,`tps`),costTotal:WJ(n,e,`cost_total`),energyJoules:WJ(n,e,`energy_joules`),energyCostUsd:WJ(n,e,`energy_cost_usd`),cacheRatio:G(n,e,`cache_ratio`)}):t===`model_change`?r.push({...i,type:`model_change`,provider:UJ(n,e,`provider`),modelId:UJ(n,e,`model_id`)}):t===`rewind`?r.push({...i,type:`rewind`,rewindV:G(n,e,`rewind_v`)}):r.push({...i,type:`branch_summary`,fromId:UJ(n,e,`from_id`),summary:UJ(n,e,`summary`)})}return r}async function nY(e){let t=await yx(`
635
635
  SELECT
636
636
  session_id,
637
637
  count(*) AS total_calls,
@@ -654,7 +654,7 @@ Error generating stack: `+e.message+`
654
654
  FROM tps_paired
655
655
  GROUP BY session_id
656
656
  ORDER BY min(timestamp)
657
- `);if(t.rowCount===0)return null;let n=[],r=0,i=0,a=0,o=0,s=0,c=!1,l=!1,u=``,d=``;for(let f=0;f<t.rowCount;f++){let p=WJ(t,f,`session_id`),m=GJ(t,f,`total_cost`),h=GJ(t,f,`total_energy_joules`);n.push({sessionId:p,fileName:e.get(p)??null,totalCalls:G(t,f,`total_calls`),totalTokens:G(t,f,`total_tokens`),totalOutput:G(t,f,`total_output`),wallClockMs:G(t,f,`wall_clock_ms`),avgTps:G(t,f,`avg_tps`),weightedTps:G(t,f,`weighted_tps`),avgTtft:G(t,f,`avg_ttft`),totalCostUsd:m,totalEnergyJoules:h,model:WJ(t,f,`last_model`),provider:WJ(t,f,`last_provider`),stalledCalls:G(t,f,`stalled_calls`),timeRangeStart:WJ(t,f,`time_range_start`),timeRangeEnd:WJ(t,f,`time_range_end`)}),r+=G(t,f,`total_calls`),i+=G(t,f,`total_tokens`),a+=G(t,f,`total_output`),m!==null&&(o+=m,c=!0),h!==null&&(s+=h,l=!0);let g=WJ(t,f,`time_range_start`),_=WJ(t,f,`time_range_end`);g&&(!u||g<u)&&(u=g),_&&(!d||_>d)&&(d=_)}let f=await qJ(),p=n.reduce((e,t)=>e+t.weightedTps*t.totalOutput,0),m=n.reduce((e,t)=>e+t.totalOutput,0),h=n.reduce((e,t)=>e+t.avgTtft*t.totalCalls,0),g=n.reduce((e,t)=>e+t.avgTps*t.totalCalls,0);return{sessionCount:n.length,totalCalls:r,totalTokens:i,totalOutput:a,totalCostUsd:c?o:null,totalEnergyJoules:l?s:null,sessions:n,models:f,avgTps:r>0?g/r:0,weightedTps:m>0?p/m:0,avgTtft:r>0?h/r:0,timeRangeStart:u,timeRangeEnd:d}}async function iY(e,t){let n=HJ(e,t),r=await yx(`
657
+ `);if(t.rowCount===0)return null;let n=[],r=0,i=0,a=0,o=0,s=0,c=!1,l=!1,u=``,d=``;for(let f=0;f<t.rowCount;f++){let p=UJ(t,f,`session_id`),m=WJ(t,f,`total_cost`),h=WJ(t,f,`total_energy_joules`);n.push({sessionId:p,fileName:e.get(p)??null,totalCalls:G(t,f,`total_calls`),totalTokens:G(t,f,`total_tokens`),totalOutput:G(t,f,`total_output`),wallClockMs:G(t,f,`wall_clock_ms`),avgTps:G(t,f,`avg_tps`),weightedTps:G(t,f,`weighted_tps`),avgTtft:G(t,f,`avg_ttft`),totalCostUsd:m,totalEnergyJoules:h,model:UJ(t,f,`last_model`),provider:UJ(t,f,`last_provider`),stalledCalls:G(t,f,`stalled_calls`),timeRangeStart:UJ(t,f,`time_range_start`),timeRangeEnd:UJ(t,f,`time_range_end`)}),r+=G(t,f,`total_calls`),i+=G(t,f,`total_tokens`),a+=G(t,f,`total_output`),m!==null&&(o+=m,c=!0),h!==null&&(s+=h,l=!0);let g=UJ(t,f,`time_range_start`),_=UJ(t,f,`time_range_end`);g&&(!u||g<u)&&(u=g),_&&(!d||_>d)&&(d=_)}let f=await KJ(),p=n.reduce((e,t)=>e+t.weightedTps*t.totalOutput,0),m=n.reduce((e,t)=>e+t.totalOutput,0),h=n.reduce((e,t)=>e+t.avgTtft*t.totalCalls,0),g=n.reduce((e,t)=>e+t.avgTps*t.totalCalls,0);return{sessionCount:n.length,totalCalls:r,totalTokens:i,totalOutput:a,totalCostUsd:c?o:null,totalEnergyJoules:l?s:null,sessions:n,models:f,avgTps:r>0?g/r:0,weightedTps:m>0?p/m:0,avgTtft:r>0?h/r:0,timeRangeStart:u,timeRangeEnd:d}}async function rY(e,t){let n=VJ(e,t),r=await yx(`
658
658
  SELECT
659
659
  row_number() OVER (ORDER BY timestamp) AS idx,
660
660
  timestamp,
@@ -686,7 +686,7 @@ Error generating stack: `+e.message+`
686
686
  ${n}
687
687
  AND (carbon_g_co2eq IS NOT NULL OR avg_power_watts IS NOT NULL OR apc_hit_rate IS NOT NULL OR context_tokens IS NOT NULL)
688
688
  ORDER BY timestamp
689
- `),i=[],a=0;for(let e=0;e<r.rowCount;e++){let t=GJ(r,e,`carbon_g_co2eq`)??0;a+=t,i.push({index:G(r,e,`idx`),timestamp:WJ(r,e,`timestamp`),joules:G(r,e,`joules`),costUsd:G(r,e,`cost_usd`),ttftMs:G(r,e,`ttft_ms`),totalMs:G(r,e,`total_ms`),generationMs:G(r,e,`generation_ms`),outputTokens:G(r,e,`output_tokens`),avgPowerWatts:GJ(r,e,`avg_power_watts`),carbonGCo2eq:GJ(r,e,`carbon_g_co2eq`),gridCarbonIntensity:GJ(r,e,`grid_carbon_intensity`),gridId:WJ(r,e,`grid_id`)||null,apcHitRate:GJ(r,e,`apc_hit_rate`),apcHitTokens:GJ(r,e,`apc_hit_tokens`),apcMissTokens:GJ(r,e,`apc_miss_tokens`),contextTokens:GJ(r,e,`context_tokens`),compactionTriggered:UJ(r,e,`compaction_triggered`),compactionEnergyJoules:GJ(r,e,`compaction_energy_joules`),mcrMode:WJ(r,e,`mcr_mode`)||null,mcrOriginalTokens:GJ(r,e,`mcr_original_tokens`),mcrCompactedTokens:GJ(r,e,`mcr_compacted_tokens`),currentTurnNewTokens:GJ(r,e,`current_turn_new_tokens`),uncappedEnergyJoules:GJ(r,e,`uncapped_energy_joules`),attributionMethod:WJ(r,e,`attribution_method`)||null,ratioWasCapped:UJ(r,e,`ratio_was_capped`),attributionRatio:GJ(r,e,`attribution_ratio`)})}let o=await yx(`
689
+ `),i=[],a=0;for(let e=0;e<r.rowCount;e++){let t=WJ(r,e,`carbon_g_co2eq`)??0;a+=t,i.push({index:G(r,e,`idx`),timestamp:UJ(r,e,`timestamp`),joules:G(r,e,`joules`),costUsd:G(r,e,`cost_usd`),ttftMs:G(r,e,`ttft_ms`),totalMs:G(r,e,`total_ms`),generationMs:G(r,e,`generation_ms`),outputTokens:G(r,e,`output_tokens`),avgPowerWatts:WJ(r,e,`avg_power_watts`),carbonGCo2eq:WJ(r,e,`carbon_g_co2eq`),gridCarbonIntensity:WJ(r,e,`grid_carbon_intensity`),gridId:UJ(r,e,`grid_id`)||null,apcHitRate:WJ(r,e,`apc_hit_rate`),apcHitTokens:WJ(r,e,`apc_hit_tokens`),apcMissTokens:WJ(r,e,`apc_miss_tokens`),contextTokens:WJ(r,e,`context_tokens`),compactionTriggered:HJ(r,e,`compaction_triggered`),compactionEnergyJoules:WJ(r,e,`compaction_energy_joules`),mcrMode:UJ(r,e,`mcr_mode`)||null,mcrOriginalTokens:WJ(r,e,`mcr_original_tokens`),mcrCompactedTokens:WJ(r,e,`mcr_compacted_tokens`),currentTurnNewTokens:WJ(r,e,`current_turn_new_tokens`),uncappedEnergyJoules:WJ(r,e,`uncapped_energy_joules`),attributionMethod:UJ(r,e,`attribution_method`)||null,ratioWasCapped:HJ(r,e,`ratio_was_capped`),attributionRatio:WJ(r,e,`attribution_ratio`)})}let o=await yx(`
690
690
  SELECT
691
691
  COALESCE(sum(carbon_g_co2eq), 0) AS total_carbon,
692
692
  COALESCE(sum(energy_joules), 0) AS total_joules,
@@ -709,46 +709,46 @@ Error generating stack: `+e.message+`
709
709
  FROM tps_paired
710
710
  ${n}
711
711
  AND (carbon_g_co2eq IS NOT NULL OR avg_power_watts IS NOT NULL OR apc_hit_rate IS NOT NULL OR context_tokens IS NOT NULL)
712
- `);return{details:i,aggregates:o.rowCount>0?{totalCarbon:G(o,0,`total_carbon`),totalJoules:G(o,0,`total_joules`),avgApcHitRate:GJ(o,0,`avg_apc_hit_rate`),avgPowerWatts:GJ(o,0,`avg_power_watts`),primaryGridId:WJ(o,0,`primary_grid_id`)||null,avgGridIntensity:GJ(o,0,`avg_grid_intensity`),compactionCount:G(o,0,`compaction_count`),compactionEnergy:G(o,0,`compaction_energy`),hasCarbonData:G(o,0,`has_carbon`)>0,hasApcData:G(o,0,`has_apc`)>0,hasPowerData:G(o,0,`has_power`)>0,hasMcrData:G(o,0,`has_mcr`)>0,hasAnySseData:G(o,0,`has_any_sse`)>0}:{totalCarbon:0,totalJoules:0,avgApcHitRate:null,avgPowerWatts:null,primaryGridId:null,avgGridIntensity:null,compactionCount:0,compactionEnergy:0,hasCarbonData:!1,hasApcData:!1,hasPowerData:!1,hasMcrData:!1,hasAnySseData:!1}}}function aY({active:e,payload:t}){if(!e||!t?.length)return null;let n=t[0].payload;return(0,F.jsxs)(`div`,{className:`glass-panel rounded-2xl px-4 py-3 text-sm`,style:{minWidth:200},children:[(0,F.jsxs)(`p`,{className:`text-[11px] font-semibold uppercase tracking-wider text-zinc-400 dark:text-zinc-400 mb-2`,children:[`Request #`,String(n.index)]}),(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsxs)(`div`,{className:`flex justify-between gap-3 text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`CO₂`}),(0,F.jsx)(`span`,{className:`metric-mono font-semibold text-moss`,children:lY(Number(n.carbonGCo2eq))})]}),(0,F.jsxs)(`div`,{className:`flex justify-between gap-3 text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Cumulative`}),(0,F.jsx)(`span`,{className:`metric-mono font-semibold text-zinc-700 dark:text-zinc-300`,children:lY(Number(n.cumulativeCarbonG))})]}),!!n.gridId&&(0,F.jsxs)(`div`,{className:`flex justify-between gap-3 text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Grid`}),(0,F.jsx)(`span`,{className:`metric-mono font-semibold text-zinc-700 dark:text-zinc-300`,children:String(n.gridId)})]}),(0,F.jsxs)(`div`,{className:`flex justify-between gap-3 text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Energy`}),(0,F.jsx)(`span`,{className:`metric-mono font-semibold text-zinc-700 dark:text-zinc-300`,children:Qf(Number(n.joules))})]})]})]})}function oY({active:e,payload:t}){if(!e||!t?.length)return null;let n=t[0].payload,r=Number(n.apcHitRate);return(0,F.jsxs)(`div`,{className:`glass-panel rounded-2xl px-4 py-3 text-sm`,style:{minWidth:200},children:[(0,F.jsxs)(`p`,{className:`text-[11px] font-semibold uppercase tracking-wider text-zinc-400 dark:text-zinc-400 mb-2`,children:[`APC Stats · Request #`,String(n.index)]}),(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsxs)(`div`,{className:`flex justify-between gap-3 text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Hit rate`}),(0,F.jsxs)(`span`,{className:`metric-mono font-semibold ${r>=.8?`text-moss`:r>=.5?`text-accent`:`text-amber`}`,children:[(r*100).toFixed(1),`%`]})]}),(0,F.jsxs)(`div`,{className:`flex justify-between gap-3 text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Hit tokens`}),(0,F.jsx)(`span`,{className:`metric-mono font-semibold text-moss`,children:Yf(Number(n.apcHitTokens))})]}),(0,F.jsxs)(`div`,{className:`flex justify-between gap-3 text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Miss tokens`}),(0,F.jsx)(`span`,{className:`metric-mono font-semibold text-amber`,children:Yf(Number(n.apcMissTokens))})]}),(0,F.jsxs)(`div`,{className:`flex justify-between gap-3 text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Context`}),(0,F.jsxs)(`span`,{className:`metric-mono font-semibold text-zinc-700 dark:text-zinc-300`,children:[Yf(Number(n.contextTokens)),` tok`]})]})]})]})}function sY({active:e,payload:t}){if(!e||!t?.length)return null;let n=t[0].payload;return(0,F.jsxs)(`div`,{className:`glass-panel rounded-2xl px-4 py-3 text-sm`,style:{minWidth:200},children:[(0,F.jsxs)(`p`,{className:`text-[11px] font-semibold uppercase tracking-wider text-zinc-400 dark:text-zinc-400 mb-2`,children:[`Request #`,String(n.index)]}),(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsxs)(`div`,{className:`flex justify-between gap-3 text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Avg power`}),(0,F.jsx)(`span`,{className:`metric-mono font-semibold text-accent`,children:dY(Number(n.avgPowerWatts))})]}),(0,F.jsxs)(`div`,{className:`flex justify-between gap-3 text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Energy`}),(0,F.jsx)(`span`,{className:`metric-mono font-semibold text-zinc-700 dark:text-zinc-300`,children:Qf(Number(n.joules))})]}),(0,F.jsxs)(`div`,{className:`flex justify-between gap-3 text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Duration`}),(0,F.jsxs)(`span`,{className:`metric-mono font-semibold text-zinc-700 dark:text-zinc-300`,children:[(Number(n.totalMs)/1e3).toFixed(1),`s`]})]})]})]})}function cY({active:e,payload:t}){if(!e||!t?.length)return null;let n=t[0].payload;return(0,F.jsxs)(`div`,{className:`glass-panel rounded-2xl px-4 py-3 text-sm`,style:{minWidth:220},children:[(0,F.jsxs)(`p`,{className:`text-[11px] font-semibold uppercase tracking-wider text-zinc-400 dark:text-zinc-400 mb-2`,children:[`MCR · Request #`,String(n.index)]}),(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsxs)(`div`,{className:`flex justify-between gap-3 text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Context`}),(0,F.jsxs)(`span`,{className:`metric-mono font-semibold text-zinc-700 dark:text-zinc-300`,children:[Yf(Number(n.contextTokens)),` tok`]})]}),(0,F.jsxs)(`div`,{className:`flex justify-between gap-3 text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Output`}),(0,F.jsxs)(`span`,{className:`metric-mono font-semibold text-zinc-700 dark:text-zinc-300`,children:[Yf(Number(n.outputTokens)),` tok`]})]}),!!n.mcrMode&&(0,F.jsxs)(`div`,{className:`flex justify-between gap-3 text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Mode`}),(0,F.jsx)(`span`,{className:`metric-mono font-semibold text-accent`,children:String(n.mcrMode)})]}),Number(n.compactionEnergyJoules)>0&&(0,F.jsxs)(`div`,{className:`flex justify-between gap-3 text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Compaction`}),(0,F.jsx)(`span`,{className:`metric-mono font-semibold text-amber`,children:Qf(Number(n.compactionEnergyJoules))})]})]})]})}function lY(e){return e===null?`-`:e<.001?`${(e*1e3).toFixed(2)} μg`:e<1?`${(e*1e3).toFixed(1)} mg`:e<1e3?`${e.toFixed(3)} g`:`${(e/1e3).toFixed(3)} kg`}function uY(e){return e===null?`-`:e<.01?`<0.01g`:e<1?`${e.toFixed(2)}g`:e<1e3?`${e.toFixed(1)}g`:`${(e/1e3).toFixed(2)}kg`}function dY(e){return e===null?`-`:e<1?`${(e*1e3).toFixed(0)} mW`:e<1e3?`${e.toFixed(1)} W`:`${(e/1e3).toFixed(2)} kW`}function fY({dbVersion:e,activeSessionId:t,selectedModel:n}){let{data:r}=wx(()=>iY(t,n),[e,t,n]),i=r?.details??[],a=r?.aggregates??null,{hasCarbonData:o,hasApcData:s,hasPowerData:c,hasMcrData:l,hasAnySseData:u}=a??{hasCarbonData:!1,hasApcData:!1,hasPowerData:!1,hasMcrData:!1,hasAnySseData:!1},d=(0,b.useMemo)(()=>{let e=0;return i.map(t=>({...t,timeLabel:new Date(t.timestamp).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`}),cumulativeCarbonG:(e+=t.carbonGCo2eq??0,e)}))},[i]);if(!a||!u||i.length===0)return null;let f=a,p=d.filter(e=>e.carbonGCo2eq!==null),m=d.filter(e=>e.apcHitRate!==null),h=d.filter(e=>e.avgPowerWatts!==null),g=d.filter(e=>e.contextTokens!==null);return(0,F.jsxs)(Pu.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.25},className:`space-y-6`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,F.jsx)(`div`,{className:`p-2 bg-moss/10 dark:bg-moss/15 rounded-xl`,children:(0,F.jsx)(ff,{size:20,className:`text-moss`,weight:`bold`})}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight text-zinc-800 dark:text-zinc-300`,children:`Energy & Sustainability`}),(0,F.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-400`,children:`Carbon footprint, power profile, and prompt caching efficiency`})]})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 lg:grid-cols-4 gap-2`,children:[o&&(0,F.jsx)(jx,{icon:ff,label:`CO₂ Emissions`,color:`moss`,value:uY(f.totalCarbon),subLabel:`/req`,subValue:uY(f.totalCarbon/(p.length||1)),tooltip:(0,F.jsxs)(`div`,{className:`glass-panel rounded-2xl px-4 py-3 text-xs`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,F.jsx)(`p`,{className:`text-[10px] font-bold uppercase tracking-wider text-zinc-400 dark:text-zinc-400`,children:`Carbon Footprint`}),(0,F.jsx)(ff,{size:12,weight:`bold`,className:`text-moss`})]}),(0,F.jsxs)(`div`,{className:`flex items-baseline gap-2 mb-2.5`,children:[(0,F.jsx)(`p`,{className:`metric-mono text-xl font-bold text-zinc-800 dark:text-zinc-200`,children:uY(f.totalCarbon)}),(0,F.jsx)(`span`,{className:`text-[10px] text-zinc-400 dark:text-zinc-500`,children:`CO₂ equivalent`})]}),(0,F.jsxs)(`div`,{className:`flex gap-2 mb-3`,children:[(0,F.jsxs)(`div`,{className:`flex-1 min-w-0 rounded-lg bg-moss/5 dark:bg-moss/10 p-1.5 text-center`,children:[(0,F.jsx)(`p`,{className:`text-[8px] font-semibold uppercase tracking-wider text-moss`,children:`Per request`}),(0,F.jsx)(`p`,{className:`metric-mono text-[13px] font-bold text-zinc-800 dark:text-zinc-200 mt-0.5`,children:uY(f.totalCarbon/(p.length||1))})]}),(0,F.jsxs)(`div`,{className:`flex-1 min-w-0 rounded-lg bg-zinc-100 dark:bg-white/[0.06] p-1.5 text-center`,children:[(0,F.jsx)(`p`,{className:`text-[8px] font-semibold uppercase tracking-wider text-zinc-400`,children:`Requests`}),(0,F.jsx)(`p`,{className:`metric-mono text-[13px] font-bold text-zinc-800 dark:text-zinc-200 mt-0.5`,children:p.length})]}),(0,F.jsxs)(`div`,{className:`flex-1 min-w-0 rounded-lg bg-zinc-100 dark:bg-white/[0.06] p-1.5 text-center`,children:[(0,F.jsx)(`p`,{className:`text-[8px] font-semibold uppercase tracking-wider text-zinc-400`,children:`Total energy`}),(0,F.jsx)(`p`,{className:`metric-mono text-[13px] font-bold text-zinc-800 dark:text-zinc-200 mt-0.5`,children:Qf(f.totalJoules)})]})]}),(()=>{let e=f.totalCarbon/170,t=f.totalCarbon/8.22,n=f.totalCarbon/((f.avgGridIntensity??475)*9/36e5);return(0,F.jsxs)(`div`,{className:`space-y-1 mb-3`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between text-[10px]`,children:[(0,F.jsxs)(`span`,{className:`flex items-center gap-1.5 text-zinc-500 dark:text-zinc-400`,children:[(0,F.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-ember`}),`Car distance`]}),(0,F.jsx)(`span`,{className:`metric-mono font-medium text-zinc-800 dark:text-zinc-200`,children:e>=1?`${e.toFixed(1)} km`:`${(e*1e3).toFixed(0)} m`})]}),(0,F.jsxs)(`div`,{className:`flex items-center justify-between text-[10px]`,children:[(0,F.jsxs)(`span`,{className:`flex items-center gap-1.5 text-zinc-500 dark:text-zinc-400`,children:[(0,F.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-accent`}),`Phone charges`]}),(0,F.jsx)(`span`,{className:`metric-mono font-medium text-zinc-800 dark:text-zinc-200`,children:t.toFixed(1)})]}),(0,F.jsxs)(`div`,{className:`flex items-center justify-between text-[10px]`,children:[(0,F.jsxs)(`span`,{className:`flex items-center gap-1.5 text-zinc-500 dark:text-zinc-400`,children:[(0,F.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-moss`}),`9W LED hours`]}),(0,F.jsxs)(`span`,{className:`metric-mono font-medium text-zinc-800 dark:text-zinc-200`,children:[n.toFixed(1),`h`]})]})]})})(),f.avgGridIntensity!==null&&(0,F.jsxs)(`div`,{className:`flex items-center justify-between text-[10px] mb-2`,children:[(0,F.jsx)(`span`,{className:`text-zinc-500 dark:text-zinc-400`,children:`Grid carbon intensity`}),(0,F.jsxs)(`span`,{className:`metric-mono font-medium text-zinc-800 dark:text-zinc-200`,children:[Math.round(f.avgGridIntensity),` gCO₂/kWh`]})]}),(0,F.jsx)(`p`,{className:`text-[9px] leading-relaxed text-zinc-400 dark:text-zinc-500 pt-2 border-t border-zinc-200/50 dark:border-white/[0.06]`,children:`Carbon emissions calculated from measured inference energy × grid carbon intensity. Equivalencies use EPA standards: ~170g CO₂/km (avg car), ~8.22g per smartphone charge.`})]})}),s&&f.avgApcHitRate!==null&&(0,F.jsx)(jx,{icon:Fd,label:`APC Hit Rate`,color:`accent`,value:`${(f.avgApcHitRate*100).toFixed(1)}%`,tooltip:(0,F.jsxs)(`div`,{className:`glass-panel rounded-2xl px-4 py-3 text-xs`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,F.jsx)(`p`,{className:`text-[10px] font-bold uppercase tracking-wider text-zinc-400 dark:text-zinc-400`,children:`Automatic Prompt Caching`}),(0,F.jsx)(Fd,{size:12,weight:`bold`,className:`text-accent`})]}),(0,F.jsxs)(`div`,{className:`flex items-baseline gap-2 mb-2.5`,children:[(0,F.jsxs)(`p`,{className:`metric-mono text-xl font-bold text-zinc-800 dark:text-zinc-200`,children:[(f.avgApcHitRate*100).toFixed(1),`%`]}),(0,F.jsx)(`span`,{className:`text-[10px] text-zinc-400 dark:text-zinc-500`,children:`avg hit rate`})]}),(()=>{let e=m.reduce((e,t)=>e+(t.apcHitTokens??0),0),t=m.reduce((e,t)=>e+(t.apcMissTokens??0),0),n=e+t,r=Math.max(...m.map(e=>e.apcHitRate??0)),i=Math.min(...m.map(e=>e.apcHitRate??1));return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`flex gap-2 mb-3`,children:[(0,F.jsxs)(`div`,{className:`flex-1 min-w-0 rounded-lg bg-moss/5 dark:bg-moss/10 p-1.5 text-center`,children:[(0,F.jsx)(`p`,{className:`text-[8px] font-semibold uppercase tracking-wider text-moss`,children:`Hits`}),(0,F.jsx)(`p`,{className:`metric-mono text-[13px] font-bold text-zinc-800 dark:text-zinc-200 mt-0.5`,children:Yf(e)})]}),(0,F.jsxs)(`div`,{className:`flex-1 min-w-0 rounded-lg bg-amber/5 dark:bg-amber/10 p-1.5 text-center`,children:[(0,F.jsx)(`p`,{className:`text-[8px] font-semibold uppercase tracking-wider text-amber`,children:`Misses`}),(0,F.jsx)(`p`,{className:`metric-mono text-[13px] font-bold text-zinc-800 dark:text-zinc-200 mt-0.5`,children:Yf(t)})]}),(0,F.jsxs)(`div`,{className:`flex-1 min-w-0 rounded-lg bg-zinc-100 dark:bg-white/[0.06] p-1.5 text-center`,children:[(0,F.jsx)(`p`,{className:`text-[8px] font-semibold uppercase tracking-wider text-zinc-400`,children:`Requests`}),(0,F.jsx)(`p`,{className:`metric-mono text-[13px] font-bold text-zinc-800 dark:text-zinc-200 mt-0.5`,children:m.length})]})]}),n>0&&(0,F.jsxs)(`div`,{className:`mb-3`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between text-[9px] text-zinc-400 mb-1`,children:[(0,F.jsx)(`span`,{children:`Cache retention`}),(0,F.jsxs)(`span`,{className:`metric-mono font-medium text-moss`,children:[(e/n*100).toFixed(0),`%`]})]}),(0,F.jsxs)(`div`,{className:`h-1.5 rounded-full overflow-hidden flex bg-zinc-100 dark:bg-white/[0.06]`,children:[(0,F.jsx)(`div`,{className:`h-full bg-moss`,style:{width:`${e/n*100}%`}}),(0,F.jsx)(`div`,{className:`h-full bg-amber`,style:{width:`${t/n*100}%`}})]})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-1 mb-2`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between text-[10px]`,children:[(0,F.jsx)(`span`,{className:`text-zinc-500 dark:text-zinc-400`,children:`Best`}),(0,F.jsxs)(`span`,{className:`metric-mono font-medium text-moss`,children:[(r*100).toFixed(0),`%`]})]}),(0,F.jsxs)(`div`,{className:`flex items-center justify-between text-[10px]`,children:[(0,F.jsx)(`span`,{className:`text-zinc-500 dark:text-zinc-400`,children:`Worst`}),(0,F.jsxs)(`span`,{className:`metric-mono font-medium text-ember`,children:[(i*100).toFixed(0),`%`]})]})]})]})})(),(0,F.jsx)(`p`,{className:`text-[9px] leading-relaxed text-zinc-400 dark:text-zinc-500 pt-2 border-t border-zinc-200/50 dark:border-white/[0.06]`,children:`APC (Automatic Prompt Caching) reuses previously processed prompt tokens, avoiding redundant computation. A higher hit rate means fewer tokens need reprocessing, reducing both latency and energy.`})]})}),c&&f.avgPowerWatts!==null&&(0,F.jsx)(jx,{icon:mf,label:`Avg Power Draw`,color:`amber`,value:dY(f.avgPowerWatts),subLabel:`/req`,subValue:Qf(f.totalJoules/(h.length||1)),tooltip:(0,F.jsxs)(`div`,{className:`glass-panel rounded-2xl px-4 py-3 text-xs`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,F.jsx)(`p`,{className:`text-[10px] font-bold uppercase tracking-wider text-zinc-400 dark:text-zinc-400`,children:`Power Profile`}),(0,F.jsx)(mf,{size:12,weight:`bold`,className:`text-amber`})]}),(0,F.jsxs)(`div`,{className:`flex items-baseline gap-2 mb-2.5`,children:[(0,F.jsx)(`p`,{className:`metric-mono text-xl font-bold text-zinc-800 dark:text-zinc-200`,children:dY(f.avgPowerWatts)}),(0,F.jsx)(`span`,{className:`text-[10px] text-zinc-400 dark:text-zinc-500`,children:`avg across requests`})]}),(0,F.jsxs)(`div`,{className:`flex gap-2 mb-3`,children:[(0,F.jsxs)(`div`,{className:`flex-1 min-w-0 rounded-lg bg-amber/5 dark:bg-amber/10 p-1.5 text-center`,children:[(0,F.jsx)(`p`,{className:`text-[8px] font-semibold uppercase tracking-wider text-amber`,children:`Total energy`}),(0,F.jsx)(`p`,{className:`metric-mono text-[13px] font-bold text-zinc-800 dark:text-zinc-200 mt-0.5`,children:Qf(f.totalJoules)})]}),(0,F.jsxs)(`div`,{className:`flex-1 min-w-0 rounded-lg bg-zinc-100 dark:bg-white/[0.06] p-1.5 text-center`,children:[(0,F.jsx)(`p`,{className:`text-[8px] font-semibold uppercase tracking-wider text-zinc-400`,children:`Energy/req`}),(0,F.jsx)(`p`,{className:`metric-mono text-[13px] font-bold text-zinc-800 dark:text-zinc-200 mt-0.5`,children:Qf(f.totalJoules/(h.length||1))})]}),(0,F.jsxs)(`div`,{className:`flex-1 min-w-0 rounded-lg bg-zinc-100 dark:bg-white/[0.06] p-1.5 text-center`,children:[(0,F.jsx)(`p`,{className:`text-[8px] font-semibold uppercase tracking-wider text-zinc-400`,children:`Peak`}),(0,F.jsx)(`p`,{className:`metric-mono text-[13px] font-bold text-zinc-800 dark:text-zinc-200 mt-0.5`,children:dY(Math.max(...h.map(e=>e.avgPowerWatts??0)))})]})]}),(()=>{let e=h.map(e=>e.avgPowerWatts??0),t=Math.min(...e),n=Math.max(...e),r=f.totalJoules/36e5,i=f.totalJoules/18e3,a=f.totalJoules/(9*3600);return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-1 mb-2`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between text-[10px]`,children:[(0,F.jsx)(`span`,{className:`text-zinc-500 dark:text-zinc-400`,children:`Min power`}),(0,F.jsx)(`span`,{className:`metric-mono font-medium text-moss`,children:dY(t)})]}),(0,F.jsxs)(`div`,{className:`flex items-center justify-between text-[10px]`,children:[(0,F.jsx)(`span`,{className:`text-zinc-500 dark:text-zinc-400`,children:`Max power`}),(0,F.jsx)(`span`,{className:`metric-mono font-medium text-ember`,children:dY(n)})]}),(0,F.jsxs)(`div`,{className:`flex items-center justify-between text-[10px]`,children:[(0,F.jsx)(`span`,{className:`text-zinc-500 dark:text-zinc-400`,children:`kWh`}),(0,F.jsx)(`span`,{className:`metric-mono font-medium text-zinc-800 dark:text-zinc-200`,children:r.toFixed(4)})]}),(0,F.jsxs)(`div`,{className:`flex items-center justify-between text-[10px]`,children:[(0,F.jsx)(`span`,{className:`text-zinc-500 dark:text-zinc-400`,children:`Phone charges`}),(0,F.jsx)(`span`,{className:`metric-mono font-medium text-accent`,children:i.toFixed(1)})]})]}),a>0&&(0,F.jsxs)(`div`,{className:`flex items-center justify-between text-[10px] mb-2`,children:[(0,F.jsx)(`span`,{className:`text-zinc-500 dark:text-zinc-400`,children:`9W LED bulb`}),(0,F.jsxs)(`span`,{className:`metric-mono font-medium text-zinc-800 dark:text-zinc-200`,children:[a.toFixed(1),`h`]})]})]})})(),(()=>{let e=i.filter(e=>e.ratioWasCapped===!0).length;return e===0?null:(0,F.jsxs)(`div`,{className:`flex items-center justify-between text-[10px] mb-2`,children:[(0,F.jsx)(`span`,{className:`text-zinc-500 dark:text-zinc-400`,children:`Ratio-capped requests`}),(0,F.jsxs)(`span`,{className:`metric-mono font-medium text-amber`,children:[e,`/`,i.length]})]})})(),(0,F.jsx)(`p`,{className:`text-[9px] leading-relaxed text-zinc-400 dark:text-zinc-500 pt-2 border-t border-zinc-200/50 dark:border-white/[0.06]`,children:`Average power draw during inference. Energy per request includes all GPU, memory, and overhead costs attributed by NeuralWatt profiling.`})]})}),f.primaryGridId&&(0,F.jsx)(jx,{icon:gf,label:`Grid Region`,value:f.primaryGridId,subValue:f.avgGridIntensity===null?void 0:`${Math.round(f.avgGridIntensity)} gCO₂/kWh`,tooltip:(0,F.jsxs)(`div`,{className:`glass-panel rounded-2xl px-4 py-3 text-xs`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,F.jsx)(`p`,{className:`text-[10px] font-bold uppercase tracking-wider text-zinc-400 dark:text-zinc-400`,children:`Grid Region`}),(0,F.jsx)(gf,{size:12,weight:`bold`,className:`text-accent`})]}),(0,F.jsx)(`div`,{className:`flex items-baseline gap-2 mb-2.5`,children:(0,F.jsx)(`p`,{className:`metric-mono text-xl font-bold text-zinc-800 dark:text-zinc-200`,children:f.primaryGridId})}),(0,F.jsxs)(`div`,{className:`flex gap-2 mb-3`,children:[f.avgGridIntensity!==null&&(0,F.jsxs)(`div`,{className:`flex-1 min-w-0 rounded-lg bg-accent/5 dark:bg-accent/10 p-1.5 text-center`,children:[(0,F.jsx)(`p`,{className:`text-[8px] font-semibold uppercase tracking-wider text-accent`,children:`Carbon intensity`}),(0,F.jsxs)(`p`,{className:`metric-mono text-[13px] font-bold text-zinc-800 dark:text-zinc-200 mt-0.5`,children:[Math.round(f.avgGridIntensity),` g/kWh`]})]}),(0,F.jsxs)(`div`,{className:`flex-1 min-w-0 rounded-lg bg-zinc-100 dark:bg-white/[0.06] p-1.5 text-center`,children:[(0,F.jsx)(`p`,{className:`text-[8px] font-semibold uppercase tracking-wider text-zinc-400`,children:`Total CO₂`}),(0,F.jsx)(`p`,{className:`metric-mono text-[13px] font-bold text-zinc-800 dark:text-zinc-200 mt-0.5`,children:uY(f.totalCarbon)})]}),(0,F.jsxs)(`div`,{className:`flex-1 min-w-0 rounded-lg bg-zinc-100 dark:bg-white/[0.06] p-1.5 text-center`,children:[(0,F.jsx)(`p`,{className:`text-[8px] font-semibold uppercase tracking-wider text-zinc-400`,children:`Total energy`}),(0,F.jsx)(`p`,{className:`metric-mono text-[13px] font-bold text-zinc-800 dark:text-zinc-200 mt-0.5`,children:Qf(f.totalJoules)})]})]}),(()=>{let e=new Map;for(let t of p){if(!t.gridId||t.carbonGCo2eq===null)continue;let n=t.gridCarbonIntensity??0,r=e.get(t.gridId);r?(r.count++,r.carbon+=t.carbonGCo2eq):e.set(t.gridId,{count:1,carbon:t.carbonGCo2eq,intensity:n})}if(e.size<=1)return null;let t=Array.from(e.values()).reduce((e,t)=>e+t.carbon,0);return(0,F.jsxs)(`div`,{className:`space-y-1.5 mb-3 pt-2 border-t border-zinc-200/50 dark:border-white/[0.06]`,children:[(0,F.jsx)(`p`,{className:`text-[9px] font-bold uppercase tracking-wider text-zinc-400 dark:text-zinc-400 mb-1`,children:`Emissions by Grid`}),Array.from(e.entries()).sort((e,t)=>t[1].carbon-e[1].carbon).map(([e,n])=>{let r=t>0?n.carbon/t*100:0;return(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between text-[10px]`,children:[(0,F.jsxs)(`span`,{className:`text-zinc-500 dark:text-zinc-400`,children:[e,` `,(0,F.jsxs)(`span`,{className:`text-zinc-400`,children:[`(`,n.intensity,`g/kWh)`]})]}),(0,F.jsx)(`span`,{className:`metric-mono font-medium text-zinc-800 dark:text-zinc-200`,children:uY(n.carbon)})]}),(0,F.jsx)(`div`,{className:`h-1 rounded-full overflow-hidden bg-zinc-100 dark:bg-white/[0.06] mt-0.5`,children:(0,F.jsx)(`div`,{className:`h-full bg-moss/70`,style:{width:`${r}%`}})})]},e)})]})})(),(0,F.jsx)(`p`,{className:`text-[9px] leading-relaxed text-zinc-400 dark:text-zinc-500 pt-2 border-t border-zinc-200/50 dark:border-white/[0.06]`,children:`The electrical grid region determines the carbon intensity used to convert energy measurements into CO₂ emissions. Lower carbon intensity = greener energy. Data from NeuralWatt grid mapping.`})]})})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-6`,children:[o&&p.length>0&&(0,F.jsxs)(Pu.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.2},className:`card-surface p-6`,children:[(0,F.jsxs)(`div`,{className:`mb-4`,children:[(0,F.jsx)(`h3`,{className:`text-base font-semibold tracking-tight text-zinc-800 dark:text-zinc-300`,children:`Carbon Emissions`}),(0,F.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-400 mt-0.5`,children:`Cumulative CO₂ per request and individual contribution`})]}),(0,F.jsx)(`div`,{className:`h-64`,children:(0,F.jsx)(yD,{width:`100%`,height:`100%`,children:(0,F.jsxs)(Rq,{data:p,margin:{top:5,right:5,left:0,bottom:0},children:[(0,F.jsx)(`defs`,{children:(0,F.jsxs)(`linearGradient`,{id:`co2Fill`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,F.jsx)(`stop`,{offset:`5%`,stopColor:`#059669`,stopOpacity:.15}),(0,F.jsx)(`stop`,{offset:`95%`,stopColor:`#059669`,stopOpacity:0})]})}),(0,F.jsx)(SH,{strokeDasharray:`3 3`,stroke:`var(--border)`,className:`dark:opacity-40`,vertical:!1}),(0,F.jsx)(mG,{dataKey:`index`,tick:{fontSize:10,fill:`var(--text-tertiary)`},axisLine:!1,tickLine:!1,dy:8,interval:`preserveStartEnd`}),(0,F.jsx)(kG,{yAxisId:`cumulative`,tick:{fontSize:11,fill:`var(--text-tertiary)`},axisLine:!1,tickLine:!1,dx:-4,tickFormatter:e=>e<1?`${(e*1e3).toFixed(0)}mg`:`${e.toFixed(2)}g`}),(0,F.jsx)(kG,{yAxisId:`perRequest`,orientation:`right`,tick:{fontSize:11,fill:`var(--text-tertiary)`},axisLine:!1,tickLine:!1,dx:4,tickFormatter:e=>e<.01?`${(e*1e3).toFixed(0)}mg`:`${e.toFixed(2)}g`}),(0,F.jsx)(sR,{content:(0,F.jsx)(aY,{})}),(0,F.jsx)(_U,{yAxisId:`cumulative`,type:`monotone`,dataKey:`cumulativeCarbonG`,stroke:`#059669`,strokeWidth:2,fill:`url(#co2Fill)`,animationDuration:400,name:`Cumulative`}),(0,F.jsx)(_W,{yAxisId:`perRequest`,dataKey:`carbonGCo2eq`,fill:`#059669`,fillOpacity:.35,radius:[2,2,0,0],animationDuration:400,name:`Per-request`,barSize:Math.max(2,Math.min(12,200/p.length))})]})})}),(0,F.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-5 gap-y-2 text-[11px]`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(`div`,{className:`w-5 h-2 rounded-sm bg-moss/30`}),(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Per-request`})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(`div`,{className:`w-5 h-0.5 bg-moss rounded-full`}),(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Cumulative`})]})]}),f.totalCarbon>0&&(0,F.jsxs)(`div`,{className:`mt-4 pt-3 border-t border-zinc-100 dark:border-white/[0.06]`,children:[(0,F.jsx)(`p`,{className:`text-[9px] font-semibold uppercase tracking-wider text-zinc-400 dark:text-zinc-400 mb-2`,children:`Equivalencies`}),(0,F.jsx)(`div`,{className:`grid grid-cols-3 gap-3`,children:(()=>{let e=f.totalCarbon/170,t=f.totalCarbon/8.22,n=f.totalCarbon/(f.avgGridIntensity??475)*1e3/9,r=[];return e>=.01&&r.push({label:`Car driven`,value:e>=1?`${e.toFixed(1)} km`:`${(e*1e3).toFixed(0)} m`,color:`text-ember`}),t>=.1&&r.push({label:`Phone charges`,value:t.toFixed(1),color:`text-accent`}),n>=.01&&r.push({label:`9W LED hours`,value:n.toFixed(1)+`h`,color:`text-moss`}),r.map(e=>(0,F.jsxs)(`div`,{className:`text-center`,children:[(0,F.jsx)(`p`,{className:`text-[9px] text-zinc-400 dark:text-zinc-500`,children:e.label}),(0,F.jsx)(`p`,{className:`metric-mono text-sm font-semibold ${e.color} mt-0.5`,children:e.value})]},e.label))})()})]}),(()=>{let e=new Map;for(let t of p){if(!t.gridId||t.carbonGCo2eq===null)continue;let n=t.gridCarbonIntensity??0,r=e.get(t.gridId);r?(r.count++,r.carbon+=t.carbonGCo2eq):e.set(t.gridId,{count:1,carbon:t.carbonGCo2eq,intensity:n})}if(e.size<=1)return null;let t=Array.from(e.values()).reduce((e,t)=>e+t.carbon,0);return(0,F.jsxs)(`div`,{className:`mt-4 pt-3 border-t border-zinc-100 dark:border-white/[0.06]`,children:[(0,F.jsx)(`p`,{className:`text-[9px] font-semibold uppercase tracking-wider text-zinc-400 dark:text-zinc-400 mb-2`,children:`Emissions by Grid Region`}),(0,F.jsx)(`div`,{className:`space-y-1.5`,children:Array.from(e.entries()).sort((e,t)=>t[1].carbon-e[1].carbon).map(([e,n])=>{let r=t>0?n.carbon/t*100:0,i=n.intensity>300?`text-ember`:n.intensity>150?`text-amber`:`text-moss`;return(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`text-[9px] metric-mono text-zinc-500 dark:text-zinc-400 w-16 shrink-0`,children:e}),(0,F.jsx)(`div`,{className:`flex-1 h-3 bg-zinc-50 dark:bg-white/[0.04] rounded-sm overflow-hidden`,children:(0,F.jsx)(Pu.div,{className:`h-full bg-moss/70 rounded-sm`,initial:{width:0},animate:{width:`${r}%`},transition:{duration:.4,ease:`easeOut`}})}),(0,F.jsx)(`span`,{className:`text-[9px] metric-mono font-medium w-14 shrink-0 text-right text-zinc-500 dark:text-zinc-400`,children:uY(n.carbon)}),(0,F.jsxs)(`span`,{className:`text-[8px] metric-mono ${i} w-20 shrink-0 text-right`,children:[n.intensity,`g/kWh`]})]},e)})})]})})()]}),s&&m.length>0&&(0,F.jsxs)(Pu.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.2,delay:.05},className:`card-surface p-6`,children:[(0,F.jsxs)(`div`,{className:`mb-4`,children:[(0,F.jsx)(`h3`,{className:`text-base font-semibold tracking-tight text-zinc-800 dark:text-zinc-300`,children:`APC Efficiency`}),(0,F.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-400 mt-0.5`,children:`Automatic Prompt Caching hit rate across requests`})]}),(0,F.jsx)(`div`,{className:`h-56`,children:(0,F.jsx)(yD,{width:`100%`,height:`100%`,children:(0,F.jsxs)(Iq,{data:m,margin:{top:5,right:5,left:0,bottom:0},children:[(0,F.jsx)(`defs`,{children:(0,F.jsxs)(`linearGradient`,{id:`apcFill`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,F.jsx)(`stop`,{offset:`5%`,stopColor:`#0891b2`,stopOpacity:.2}),(0,F.jsx)(`stop`,{offset:`95%`,stopColor:`#0891b2`,stopOpacity:0})]})}),(0,F.jsx)(SH,{strokeDasharray:`3 3`,stroke:`var(--border)`,className:`dark:opacity-40`,vertical:!1}),(0,F.jsx)(mG,{dataKey:`index`,tick:{fontSize:10,fill:`var(--text-tertiary)`},axisLine:!1,tickLine:!1,dy:8,interval:`preserveStartEnd`}),(0,F.jsx)(kG,{tick:{fontSize:11,fill:`var(--text-tertiary)`},axisLine:!1,tickLine:!1,dx:-4,domain:[0,1.05],tickFormatter:e=>`${(e*100).toFixed(0)}%`}),(0,F.jsx)(sR,{content:(0,F.jsx)(oY,{})}),(0,F.jsx)(hV,{y:1,stroke:`#059669`,strokeDasharray:`4 4`,strokeOpacity:.4}),(0,F.jsx)(_U,{type:`monotone`,dataKey:`apcHitRate`,stroke:`#0891b2`,strokeWidth:2,fill:`url(#apcFill)`,animationDuration:400})]})})}),(0,F.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-5 gap-y-2 text-[11px]`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(`div`,{className:`w-5 h-0.5 bg-accent rounded-full`}),(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`APC hit rate`})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(`div`,{className:`w-5 h-0.5 bg-moss rounded-full opacity-40`,style:{borderStyle:`dashed`}}),(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`100% reference`})]})]}),m.length>0&&(()=>{let e=m.reduce((e,t)=>e+(t.apcHitTokens??0),0),t=m.reduce((e,t)=>e+(t.apcMissTokens??0),0),n=e+t,r=m.slice(-8);return(0,F.jsx)(`div`,{className:`mt-4 pt-3 border-t border-zinc-100 dark:border-white/[0.06]`,children:(0,F.jsxs)(`div`,{className:`flex gap-6 items-start`,children:[(0,F.jsxs)(`div`,{className:`shrink-0 w-24`,children:[(0,F.jsxs)(`div`,{className:`h-24 relative`,children:[(0,F.jsx)(yD,{width:`100%`,height:`100%`,children:(0,F.jsx)(Mq,{children:(0,F.jsxs)(Vz,{data:[{name:`Hit`,value:e||0},{name:`Miss`,value:t||0}],dataKey:`value`,innerRadius:28,outerRadius:40,strokeWidth:0,animationBegin:0,animationDuration:600,children:[(0,F.jsx)(cR,{fill:`#059669`}),(0,F.jsx)(cR,{fill:`#d97706`})]})})}),(0,F.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,F.jsxs)(`div`,{className:`text-center`,children:[(0,F.jsxs)(`p`,{className:`metric-mono text-sm font-bold text-zinc-800 dark:text-zinc-300 leading-none`,children:[n>0?(e/n*100).toFixed(0):`0`,`%`]}),(0,F.jsx)(`p`,{className:`text-[7px] text-zinc-400 dark:text-zinc-500 mt-0.5`,children:`hit rate`})]})})]}),(0,F.jsxs)(`div`,{className:`mt-1 flex justify-center gap-3 text-[8px]`,children:[(0,F.jsxs)(`span`,{className:`flex items-center gap-0.5`,children:[(0,F.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-moss`}),Yf(e)]}),(0,F.jsxs)(`span`,{className:`flex items-center gap-0.5`,children:[(0,F.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-amber`}),Yf(t)]})]})]}),(0,F.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,F.jsx)(`p`,{className:`text-[9px] font-semibold uppercase tracking-wider text-zinc-400 dark:text-zinc-400 mb-2`,children:`Per-Request`}),(0,F.jsx)(`div`,{className:`grid grid-cols-4 gap-2`,children:r.map(e=>{let t=e.apcHitRate??0,n=t*100,r=Math.PI*2*14,i=`${t*r} ${r}`,a=e.apcHitTokens??0,o=a+(e.apcMissTokens??0),s=n>=90,c=n<50,l=s?`#059669`:c?`#ef4444`:`#0891b2`;return(0,F.jsxs)(`div`,{className:`flex flex-col items-center`,children:[(0,F.jsxs)(`svg`,{width:`40`,height:`40`,viewBox:`0 0 36 36`,children:[(0,F.jsx)(`circle`,{cx:`18`,cy:`18`,r:`14`,fill:`none`,stroke:`var(--border)`,strokeWidth:`3`,opacity:`0.5`}),(0,F.jsx)(Pu.circle,{cx:`18`,cy:`18`,r:`14`,fill:`none`,stroke:l,strokeWidth:`3`,strokeLinecap:`round`,strokeDasharray:i,transform:`rotate(-90 18 18)`,initial:{strokeDasharray:`0 ${r}`},animate:{strokeDasharray:i},transition:{duration:.6,ease:`easeOut`}})]}),(0,F.jsxs)(`p`,{className:`metric-mono text-[10px] font-semibold leading-none mt-0.5 ${s?`text-moss`:c?`text-ember`:`text-accent`}`,children:[n.toFixed(0),`%`]}),(0,F.jsxs)(`p`,{className:`text-[7px] metric-mono text-zinc-300 dark:text-zinc-600`,children:[`#`,e.index]}),o>0&&(0,F.jsxs)(`p`,{className:`text-[6px] metric-mono text-zinc-300 dark:text-zinc-600 leading-tight mt-0.5 text-center`,children:[Yf(a),`/`,Yf(o),` tok`]})]},e.index)})})]})]})})})()]}),c&&h.length>0&&(0,F.jsxs)(Pu.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.2,delay:.1},className:`card-surface p-6`,children:[(0,F.jsxs)(`div`,{className:`mb-4`,children:[(0,F.jsx)(`h3`,{className:`text-base font-semibold tracking-tight text-zinc-800 dark:text-zinc-300`,children:`Power Profile`}),(0,F.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-400 mt-0.5`,children:`Average power draw per inference request`})]}),(0,F.jsx)(`div`,{className:`h-56`,children:(0,F.jsx)(yD,{width:`100%`,height:`100%`,children:(0,F.jsxs)(Iq,{data:h,margin:{top:5,right:5,left:0,bottom:0},children:[(0,F.jsx)(`defs`,{children:(0,F.jsxs)(`linearGradient`,{id:`powerFill`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,F.jsx)(`stop`,{offset:`5%`,stopColor:`#d97706`,stopOpacity:.2}),(0,F.jsx)(`stop`,{offset:`95%`,stopColor:`#d97706`,stopOpacity:0})]})}),(0,F.jsx)(SH,{strokeDasharray:`3 3`,stroke:`var(--border)`,className:`dark:opacity-40`,vertical:!1}),(0,F.jsx)(mG,{dataKey:`index`,tick:{fontSize:10,fill:`var(--text-tertiary)`},axisLine:!1,tickLine:!1,dy:8,interval:`preserveStartEnd`}),(0,F.jsx)(kG,{tick:{fontSize:11,fill:`var(--text-tertiary)`},axisLine:!1,tickLine:!1,dx:-4,tickFormatter:e=>e>=1e3?`${(e/1e3).toFixed(1)}kW`:`${e.toFixed(0)}W`}),(0,F.jsx)(sR,{content:(0,F.jsx)(sY,{})}),(0,F.jsx)(_U,{type:`monotone`,dataKey:`avgPowerWatts`,stroke:`#d97706`,strokeWidth:2,fill:`url(#powerFill)`,animationDuration:400})]})})}),(0,F.jsx)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-5 gap-y-2 text-[11px]`,children:(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(`div`,{className:`w-5 h-0.5 bg-amber rounded-full`}),(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Avg power (W)`})]})}),h.length>1&&(0,F.jsxs)(`div`,{className:`mt-4 pt-3 border-t border-zinc-100 dark:border-white/[0.06]`,children:[(0,F.jsx)(`p`,{className:`text-[9px] font-semibold uppercase tracking-wider text-zinc-400 dark:text-zinc-400 mb-2`,children:`Power Distribution`}),(0,F.jsx)(`div`,{className:`space-y-1.5`,children:(()=>{let e=h.map(e=>e.avgPowerWatts??0),t=[{label:`<1kW`,max:1e3,color:`bg-moss`},{label:`1-2kW`,max:2e3,color:`bg-accent`},{label:`2-3kW`,max:3e3,color:`bg-amber`},{label:`3-5kW`,max:5e3,color:`bg-ember/70`},{label:`>5kW`,max:1/0,color:`bg-ember`}];return t.map(n=>{let r=t[t.indexOf(n)-1]?.max??0,i=e.filter(e=>e>r&&e<=n.max).length,a=e.length>0?i/e.length*100:0,o=Math.max(...t.map(n=>e.filter(e=>e>(t[t.indexOf(n)-1]?.max??0)&&e<=n.max).length),1);return(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`text-[9px] metric-mono text-zinc-400 dark:text-zinc-400 w-10 shrink-0 text-right`,children:n.label}),(0,F.jsx)(`div`,{className:`flex-1 h-3 bg-zinc-50 dark:bg-white/[0.04] rounded-sm overflow-hidden`,children:(0,F.jsx)(Pu.div,{className:`h-full ${n.color} rounded-sm`,initial:{width:0},animate:{width:`${i/o*100}%`},transition:{duration:.4,ease:`easeOut`}})}),(0,F.jsxs)(`span`,{className:`text-[9px] metric-mono font-medium w-12 shrink-0 text-right text-zinc-500 dark:text-zinc-400`,children:[i,` `,i>0?`(${a.toFixed(0)}%)`:``]})]},n.label)})})()})]}),(()=>{let e=i.filter(e=>e.ratioWasCapped===!0).length,t=i.reduce((e,t)=>e+(t.uncappedEnergyJoules??0),0),n=new Map;for(let e of i)e.attributionMethod&&n.set(e.attributionMethod,(n.get(e.attributionMethod)??0)+1);return e===0&&t===0&&n.size===0?null:(0,F.jsxs)(`div`,{className:`mt-4 pt-3 border-t border-zinc-100 dark:border-white/[0.06] flex flex-wrap items-center gap-x-4 gap-y-2 text-[10px] text-zinc-400 dark:text-zinc-500`,children:[e>0&&(0,F.jsxs)(`span`,{children:[`Ratio-capped: `,(0,F.jsxs)(`span`,{className:`metric-mono font-semibold text-amber`,children:[e,`/`,i.length]}),` reqs`]}),t>0&&f.totalJoules>0&&(0,F.jsxs)(`span`,{children:[`Uncapped: `,(0,F.jsx)(`span`,{className:`metric-mono font-semibold text-amber`,children:Qf(t)}),(0,F.jsxs)(`span`,{className:`text-zinc-300 dark:text-zinc-600 ml-1`,children:[`(`,(t/f.totalJoules).toFixed(1),`×)`]})]}),n.size>0&&(0,F.jsxs)(`span`,{children:[`Method: `,Array.from(n.entries()).map(([e,t])=>(0,F.jsxs)(`span`,{className:`metric-mono font-semibold text-zinc-500 dark:text-zinc-400`,children:[e,`(`,t,`)`]},e)).reduce((e,t)=>(0,F.jsxs)(F.Fragment,{children:[e,` `,t]}))]})]})})()]}),l&&g.length>0&&(0,F.jsxs)(Pu.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.2,delay:.15},className:`card-surface p-6`,children:[(0,F.jsxs)(`div`,{className:`mb-4`,children:[(0,F.jsx)(`h3`,{className:`text-base font-semibold tracking-tight text-zinc-800 dark:text-zinc-300`,children:`Context Growth (MCR)`}),(0,F.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-400 mt-0.5`,children:`How the context window expands across the conversation`})]}),(0,F.jsx)(`div`,{className:`h-64`,children:(0,F.jsx)(yD,{width:`100%`,height:`100%`,children:(0,F.jsxs)(Iq,{data:g,margin:{top:5,right:5,left:0,bottom:0},children:[(0,F.jsxs)(`defs`,{children:[(0,F.jsxs)(`linearGradient`,{id:`ctxFill`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,F.jsx)(`stop`,{offset:`5%`,stopColor:`#0891b2`,stopOpacity:.15}),(0,F.jsx)(`stop`,{offset:`95%`,stopColor:`#0891b2`,stopOpacity:0})]}),(0,F.jsxs)(`linearGradient`,{id:`outputFill`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,F.jsx)(`stop`,{offset:`5%`,stopColor:`#059669`,stopOpacity:.12}),(0,F.jsx)(`stop`,{offset:`95%`,stopColor:`#059669`,stopOpacity:0})]})]}),(0,F.jsx)(SH,{strokeDasharray:`3 3`,stroke:`var(--border)`,className:`dark:opacity-40`,vertical:!1}),(0,F.jsx)(mG,{dataKey:`index`,tick:{fontSize:10,fill:`var(--text-tertiary)`},axisLine:!1,tickLine:!1,dy:8,interval:`preserveStartEnd`}),(0,F.jsx)(kG,{tick:{fontSize:11,fill:`var(--text-tertiary)`},axisLine:!1,tickLine:!1,dx:-4,tickFormatter:e=>e>=1e3?`${(e/1e3).toFixed(1)}k`:`${e}`}),(0,F.jsx)(sR,{content:(0,F.jsx)(cY,{})}),(0,F.jsx)(_U,{type:`monotone`,dataKey:`outputTokens`,stroke:`#059669`,strokeWidth:1.5,fill:`url(#outputFill)`,animationDuration:400}),(0,F.jsx)(_U,{type:`monotone`,dataKey:`contextTokens`,stroke:`#0891b2`,strokeWidth:2,fill:`url(#ctxFill)`,animationDuration:400})]})})}),(0,F.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-5 gap-y-2 text-[11px]`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(`div`,{className:`w-5 h-0.5 bg-accent rounded-full`}),(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Context tokens (MCR)`})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(`div`,{className:`w-5 h-0.5 bg-moss rounded-full`}),(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Output tokens`})]})]}),(f.compactionCount>0||f.compactionEnergy>0)&&(0,F.jsxs)(`div`,{className:`mt-4 pt-3 border-t border-zinc-100 dark:border-white/[0.06] flex items-center gap-4 text-[10px]`,children:[(0,F.jsxs)(`span`,{className:`text-zinc-400 dark:text-zinc-500`,children:[`Compactions: `,(0,F.jsx)(`span`,{className:`metric-mono font-semibold text-amber`,children:f.compactionCount})]}),f.compactionEnergy>0&&(0,F.jsxs)(`span`,{className:`text-zinc-400 dark:text-zinc-500`,children:[`Compaction energy: `,(0,F.jsx)(`span`,{className:`metric-mono font-semibold text-amber`,children:Qf(f.compactionEnergy)})]})]}),(()=>{let e=new Set(g.map(e=>e.mcrMode).filter(Boolean));return e.size>0?(0,F.jsxs)(`div`,{className:`mt-3 pt-3 border-t border-zinc-100 dark:border-white/[0.06]`,children:[(0,F.jsx)(`p`,{className:`text-[9px] font-semibold uppercase tracking-wider text-zinc-400 dark:text-zinc-400 mb-1.5`,children:`Context Mode`}),(0,F.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Array.from(e).map(e=>{let t=g.filter(t=>t.mcrMode===e).length;return(0,F.jsxs)(`span`,{className:`px-2 py-0.5 rounded-lg text-[10px] font-medium bg-accent/10 text-accent dark:bg-accent/15`,children:[e,` `,(0,F.jsxs)(`span`,{className:`text-accent/60`,children:[`(`,t,`)`]})]},e)})})]}):null})(),g.length>0&&(0,F.jsxs)(`div`,{className:`mt-4 pt-3 border-t border-zinc-100 dark:border-white/[0.06]`,children:[(0,F.jsx)(`p`,{className:`text-[9px] font-semibold uppercase tracking-wider text-zinc-400 dark:text-zinc-400 mb-2`,children:`Token Flow`}),(0,F.jsx)(`div`,{className:`space-y-1`,children:g.slice(-8).map(e=>{let t=e.mcrOriginalTokens??e.contextTokens??0,n=e.mcrCompactedTokens??0,r=e.currentTurnNewTokens??0,i=Math.max(t,r,1);return(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsxs)(`span`,{className:`text-[9px] metric-mono text-zinc-400 dark:text-zinc-400 w-6 shrink-0 text-right`,children:[`#`,e.index]}),(0,F.jsxs)(`div`,{className:`flex-1 h-3 bg-zinc-50 dark:bg-white/[0.04] rounded-sm overflow-hidden flex`,children:[(0,F.jsx)(Pu.div,{className:`h-full bg-accent/60 rounded-l-sm`,initial:{width:0},animate:{width:`${t/i*100}%`},transition:{duration:.4,ease:`easeOut`}}),n>0&&(0,F.jsx)(Pu.div,{className:`h-full bg-amber/60`,initial:{width:0},animate:{width:`${n/i*100}%`},transition:{duration:.4,ease:`easeOut`}}),(0,F.jsx)(Pu.div,{className:`h-full bg-moss/60 rounded-r-sm`,initial:{width:0},animate:{width:`${r/i*100}%`},transition:{duration:.4,ease:`easeOut`}})]}),(0,F.jsx)(`span`,{className:`text-[9px] metric-mono font-medium w-10 shrink-0 text-right text-zinc-500 dark:text-zinc-400`,children:Yf(e.contextTokens)})]},e.index)})}),(0,F.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-4 gap-y-1 text-[9px]`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(`div`,{className:`w-2 h-2 rounded-sm bg-accent/60`}),(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-500`,children:`Original`})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(`div`,{className:`w-2 h-2 rounded-sm bg-amber/60`}),(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-500`,children:`Compacted`})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(`div`,{className:`w-2 h-2 rounded-sm bg-moss/60`}),(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-500`,children:`New tokens`})]})]})]})]})]}),o&&(0,F.jsx)(Pu.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.2,delay:.2},className:`card-surface p-4`,children:(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-6 gap-y-2 text-[10px] text-zinc-400 dark:text-zinc-500`,children:[(0,F.jsxs)(`span`,{children:[`Total energy: `,(0,F.jsx)(`span`,{className:`metric-mono font-semibold text-zinc-600 dark:text-zinc-300`,children:Qf(f.totalJoules)})]}),f.avgGridIntensity!==null&&(0,F.jsxs)(`span`,{children:[`Grid intensity: `,(0,F.jsxs)(`span`,{className:`metric-mono font-semibold text-zinc-600 dark:text-zinc-300`,children:[Math.round(f.avgGridIntensity),` gCO₂/kWh`]})]}),f.primaryGridId&&(0,F.jsxs)(`span`,{children:[`Region: `,(0,F.jsx)(`span`,{className:`metric-mono font-semibold text-accent`,children:f.primaryGridId})]}),(0,F.jsx)(`span`,{className:`ml-auto text-zinc-300 dark:text-zinc-600`,children:`Powered by NeuralWatt inference profiling`})]})})]})}var pY=(0,b.memo)(fY);function mY({bins:e,fastCount:t,slowCount:n,percentiles:r}){return(0,F.jsxs)(Pu.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.2},className:`card-surface p-6`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between mb-5`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`div`,{className:`p-1.5 bg-accent/10 dark:bg-accent/15 rounded-lg`,children:(0,F.jsx)(Mf,{size:16,className:`text-accent`,weight:`bold`})}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight text-zinc-800 dark:text-zinc-300`,children:`TTFT Distribution`}),(0,F.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-400`,children:`Where time is spent across all calls`})]})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px]`,children:[(0,F.jsxs)(`span`,{className:`metric-mono font-semibold text-moss`,children:[t,` fast`]}),(0,F.jsx)(`span`,{className:`text-zinc-300 dark:text-zinc-700`,children:`·`}),(0,F.jsxs)(`span`,{className:`metric-mono font-semibold text-ember`,children:[n,` slow`]})]})]}),(0,F.jsx)(`div`,{className:`space-y-3`,children:e.map(e=>(0,F.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,F.jsx)(`span`,{className:`text-[11px] metric-mono text-zinc-500 dark:text-zinc-400 w-14 shrink-0 text-right`,children:e.label}),(0,F.jsxs)(`div`,{className:`flex-1 h-7 bg-zinc-50 dark:bg-white/[0.04] rounded-lg overflow-hidden relative`,children:[(0,F.jsx)(Pu.div,{className:`h-full ${e.color} rounded-lg`,initial:{width:0},animate:{width:`${e.barPct}%`},transition:{duration:.4,ease:`easeOut`}}),e.count>0&&(0,F.jsx)(`span`,{className:`absolute inset-y-0 flex items-center text-[11px] metric-mono font-semibold drop-shadow-[0_1px_2px_rgba(0,0,0,0.45)] ${e.barPct>15?`left-2 text-white`:`left-1 text-zinc-600 dark:text-zinc-300`}`,children:e.count})]}),(0,F.jsxs)(`span`,{className:`text-[11px] metric-mono text-zinc-400 dark:text-zinc-400 w-10 shrink-0`,children:[e.pct.toFixed(0),`%`]})]},e.label))}),(0,F.jsx)(`div`,{className:`mt-4 pt-3 border-t border-zinc-100 dark:border-white/[0.06]`,children:(0,F.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-0 divide-x divide-zinc-100 dark:divide-white/[0.06]`,children:r.map(({label:e,value:t})=>(0,F.jsxs)(`div`,{className:`text-center px-3 py-2 first:pl-0 last:pr-0`,children:[(0,F.jsx)(`p`,{className:`text-[10px] font-medium uppercase tracking-wider text-zinc-400 dark:text-zinc-400`,children:e}),(0,F.jsx)(`p`,{className:`metric-mono text-sm font-semibold ${e===`P50`?`text-zinc-700 dark:text-zinc-300`:e===`P75`?`text-amber`:e===`P90`?`text-accent`:`text-ember`} mt-0.5`,children:Jf(t)})]},e))})})]})}var hY=b.memo(mY);function gY({active:e,payload:t,hasCost:n}){if(!e||!t?.length)return null;let r=t[0].payload;return(0,F.jsxs)(`div`,{className:`glass-panel rounded-2xl px-4 py-3 text-sm`,style:{minWidth:240},children:[(0,F.jsx)(`p`,{className:`text-[11px] font-semibold uppercase tracking-wider text-zinc-400 dark:text-zinc-400 mb-2`,children:String(r.fileName||String(r.sessionId).slice(0,24))}),(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsxs)(`div`,{className:`flex justify-between gap-3 text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Requests`}),(0,F.jsx)(`span`,{className:`metric-mono font-semibold text-zinc-700 dark:text-zinc-300`,children:String(r.totalCalls)})]}),(0,F.jsxs)(`div`,{className:`flex justify-between gap-3 text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Tokens`}),(0,F.jsx)(`span`,{className:`metric-mono font-semibold text-zinc-700 dark:text-zinc-300`,children:Number(r.totalTokens).toLocaleString()})]}),(0,F.jsxs)(`div`,{className:`flex justify-between gap-3 text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Wtd TPS`}),(0,F.jsx)(`span`,{className:`metric-mono font-semibold text-accent`,children:Zf(Number(r.weightedTps))})]}),(0,F.jsxs)(`div`,{className:`flex justify-between gap-3 text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Avg TPS`}),(0,F.jsx)(`span`,{className:`metric-mono font-semibold text-zinc-700 dark:text-zinc-300`,children:Zf(Number(r.avgTps))})]}),(0,F.jsxs)(`div`,{className:`flex justify-between gap-3 text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Avg TTFT`}),(0,F.jsx)(`span`,{className:`metric-mono font-semibold text-zinc-700 dark:text-zinc-300`,children:Jf(Math.round(Number(r.avgTtft)))})]}),n&&(0,F.jsxs)(`div`,{className:`flex justify-between gap-3 text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Cost`}),(0,F.jsx)(`span`,{className:`metric-mono font-semibold text-zinc-700 dark:text-zinc-300`,children:Xf(Number(r.y))})]}),r.energy!==null&&(0,F.jsxs)(`div`,{className:`flex justify-between gap-3 text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Energy`}),(0,F.jsx)(`span`,{className:`metric-mono font-semibold text-zinc-700 dark:text-zinc-300`,children:Qf(Number(r.energy))})]}),(0,F.jsxs)(`div`,{className:`flex justify-between gap-3 text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Model`}),(0,F.jsx)(`span`,{className:`text-zinc-600 dark:text-zinc-300 truncate max-w-[10rem]`,children:String(r.model).split(`/`).pop()})]})]}),(0,F.jsx)(`p`,{className:`text-[9px] text-zinc-400 dark:text-zinc-500 mt-2 pt-1.5 border-t border-zinc-200/50 dark:border-white/[0.06]`,children:`Click to focus on this session`})]})}function _Y({multiSummary:e,onSessionClick:t}){let n=e.sessions.some(e=>e.totalCostUsd!==null),r=(0,b.useMemo)(()=>e.sessions.map(e=>({x:e.weightedTps,y:n?e.totalCostUsd??0:e.wallClockMs,z:e.totalCalls,sessionId:e.sessionId,fileName:e.fileName,totalTokens:e.totalTokens,totalOutput:e.totalOutput,totalCalls:e.totalCalls,avgTtft:e.avgTtft,avgTps:e.avgTps,weightedTps:e.weightedTps,model:e.model,energy:e.totalEnergyJoules,wallClockMs:e.wallClockMs})),[e,n]),i=n?`Cost (USD)`:`Wall-clock Duration`,a=n?e=>Xf(e):e=>Jf(e),o=(0,b.useMemo)(()=>{if(r.length===0)return[0,100];let e=r.map(e=>e.x),t=Math.min(...e),n=Math.max(...e),i=Math.max((n-t)*.1,1);return[Math.max(0,t-i),n+i]},[r]),s=(0,b.useMemo)(()=>{if(r.length===0)return[0,1];let e=r.map(e=>e.y),t=Math.min(...e),i=Math.max(...e),a=Math.max((i-t)*.1,n?.001:1e3);return[Math.max(0,t-a),i+a]},[r,n]);if(r.length<2)return null;let c=[`#0891b2`,`#059669`,`#d97706`,`#dc2626`,`#7c3aed`,`#db2777`,`#0284c7`,`#65a30d`,`#ea580c`,`#6d28d9`],l=new Map,u=0;for(let t of e.sessions)l.has(t.model)||(l.set(t.model,c[u%c.length]),u++);return(0,F.jsxs)(Pu.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.2},className:`card-surface p-6`,children:[(0,F.jsx)(`div`,{className:`flex items-center justify-between mb-6`,children:(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight text-zinc-800 dark:text-zinc-300`,children:`Session Comparison`}),(0,F.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-400 mt-0.5`,children:`Each dot is one session. Bubble size = request count. Color = model.`})]})}),(0,F.jsx)(`div`,{className:`h-72`,children:(0,F.jsx)(yD,{width:`100%`,height:`100%`,children:(0,F.jsxs)(Pq,{margin:{top:5,right:5,left:0,bottom:0},children:[(0,F.jsx)(SH,{strokeDasharray:`3 3`,stroke:`var(--border)`,className:`dark:opacity-40`}),(0,F.jsx)(mG,{type:`number`,dataKey:`x`,name:`Weighted TPS`,domain:o,tick:{fontSize:11,fill:`var(--text-tertiary)`},axisLine:!1,tickLine:!1,dy:8}),(0,F.jsx)(kG,{type:`number`,dataKey:`y`,name:i,domain:s,tick:{fontSize:11,fill:`var(--text-tertiary)`},axisLine:!1,tickLine:!1,dx:-4,tickFormatter:a}),(0,F.jsx)(MG,{type:`number`,dataKey:`z`,range:[60,400]}),(0,F.jsx)(sR,{content:(0,F.jsx)(gY,{hasCost:n}),cursor:{strokeDasharray:`3 3`}}),(0,F.jsx)(qW,{data:r,onClick:e=>t(e.payload.sessionId),children:r.map((e,t)=>(0,F.jsx)(cR,{fill:l.get(e.model)??`#0891b2`,fillOpacity:.65,stroke:l.get(e.model)??`#0891b2`,strokeWidth:1.5,cursor:`pointer`},`cell-${t}`))})]})})}),(0,F.jsx)(`div`,{className:`mt-4 flex flex-wrap items-center gap-x-5 gap-y-2 text-[11px]`,children:Array.from(l.entries()).map(([e,t])=>(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(`div`,{className:`w-2 h-2 rounded-full`,style:{background:t}}),(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:e.split(`/`).pop()})]},e))})]})}var vY=(0,b.memo)(_Y);function yY({models:e,avgTps:t,weightedTps:n,totalCalls:r}){let i=(0,b.useMemo)(()=>{if(e.length===0)return[];let t=e.map(e=>{e.callCount;let t=e.blendedCostUsd!==null&&e.totalTokens>0?e.blendedCostUsd/(e.totalTokens/1e6):null,n=e.energyJoules!==null&&e.callCount>0?e.energyJoules/e.callCount:null;return{modelId:e.modelId,provider:e.provider,callCount:e.callCount,totalTokens:e.totalTokens,tpsPerToken:null,blendedCostPer1MTokens:t,energyPerCall:n,blendedCostTotal:e.blendedCostUsd,costSource:e.costSource,rank:null}});if(t.length>1){let e=t.filter(e=>e.blendedCostPer1MTokens!==null);if(e.length>0){let t=e.reduce((e,t)=>(e.blendedCostPer1MTokens??1/0)<(t.blendedCostPer1MTokens??1/0)?e:t);t.rank=`cheapest`}let n=t.reduce((e,t)=>e.callCount>t.callCount?e:t);n.rank===null&&(n.rank=`fastest`)}return t},[e]);return i.length===0||i.length===1?null:(0,F.jsxs)(Pu.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.2},className:`card-surface p-6`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 mb-4`,children:[(0,F.jsx)(Bf,{size:16,className:`text-accent`,weight:`bold`}),(0,F.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight text-zinc-800 dark:text-zinc-300`,children:`Model Performance`}),(0,F.jsxs)(`span`,{className:`ml-auto text-[10px] metric-mono text-zinc-400 dark:text-zinc-500`,children:[i.length,` models · `,Yf(r,0),` calls`]})]}),(0,F.jsx)(`div`,{className:`overflow-x-auto`,children:(0,F.jsxs)(`table`,{className:`w-full text-[11px]`,children:[(0,F.jsx)(`thead`,{children:(0,F.jsxs)(`tr`,{className:`text-[9px] uppercase tracking-wider text-zinc-400 dark:text-zinc-500 border-b border-zinc-200/40 dark:border-white/[0.06]`,children:[(0,F.jsx)(`th`,{className:`text-left px-3 py-2 font-medium`,children:`Model`}),(0,F.jsx)(`th`,{className:`text-right px-3 py-2 font-medium`,children:`Provider`}),(0,F.jsx)(`th`,{className:`text-right px-3 py-2 font-medium`,children:`Calls`}),(0,F.jsx)(`th`,{className:`text-right px-3 py-2 font-medium`,children:`Tokens`}),(0,F.jsx)(`th`,{className:`text-right px-3 py-2 font-medium`,children:`Cost/1M tok`}),(0,F.jsx)(`th`,{className:`text-right px-3 py-2 font-medium`,children:`Total Cost`}),(0,F.jsx)(`th`,{className:`text-right px-3 py-2 font-medium`,children:`Energy/call`}),(0,F.jsx)(`th`,{className:`text-right px-3 py-2 font-medium`,children:`Source`})]})}),(0,F.jsx)(`tbody`,{children:i.map((e,t)=>(0,F.jsxs)(`tr`,{className:`border-b border-zinc-200/20 dark:border-white/[0.03] ${t%2==0?`bg-zinc-50/30 dark:bg-white/[0.01]`:``} ${e.rank?`bg-accent/[0.03] dark:bg-accent/[0.05]`:``}`,children:[(0,F.jsx)(`td`,{className:`px-3 py-2.5 font-medium text-zinc-700 dark:text-zinc-300`,children:(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[e.rank&&(0,F.jsx)(`span`,{className:`text-[8px] font-bold uppercase tracking-wider px-1.5 py-0.5 rounded ${e.rank===`fastest`?`bg-moss/10 text-moss`:`bg-accent/10 text-accent`}`,children:e.rank===`fastest`?`Most used`:`Cheapest`}),(0,F.jsx)(`span`,{className:`truncate max-w-[12rem]`,children:e.modelId.split(`/`).pop()})]})}),(0,F.jsx)(`td`,{className:`px-3 py-2.5 text-right text-zinc-500 dark:text-zinc-400`,children:e.provider}),(0,F.jsx)(`td`,{className:`px-3 py-2.5 text-right metric-mono text-zinc-600 dark:text-zinc-300`,children:Yf(e.callCount,0)}),(0,F.jsx)(`td`,{className:`px-3 py-2.5 text-right metric-mono text-zinc-600 dark:text-zinc-300`,children:Yf(e.totalTokens)}),(0,F.jsx)(`td`,{className:`px-3 py-2.5 text-right metric-mono text-zinc-600 dark:text-zinc-300`,children:e.blendedCostPer1MTokens===null?`-`:`$${e.blendedCostPer1MTokens.toFixed(4)}`}),(0,F.jsx)(`td`,{className:`px-3 py-2.5 text-right metric-mono text-zinc-600 dark:text-zinc-300`,children:e.blendedCostTotal===null?`-`:Xf(e.blendedCostTotal)}),(0,F.jsx)(`td`,{className:`px-3 py-2.5 text-right metric-mono text-zinc-600 dark:text-zinc-300`,children:e.energyPerCall===null?`-`:Qf(e.energyPerCall)}),(0,F.jsx)(`td`,{className:`px-3 py-2.5 text-right text-zinc-500 dark:text-zinc-400`,children:e.costSource===`neuralwatt`?(0,F.jsx)(`span`,{className:`text-accent`,children:`energy`}):e.costSource===`tps`?(0,F.jsx)(`span`,{className:`text-amber`,children:`token`}):`-`})]},e.modelId))})]})}),(0,F.jsxs)(`div`,{className:`mt-3 pt-3 border-t border-zinc-200/40 dark:border-white/[0.06] flex items-center gap-4 text-[10px] text-zinc-400 dark:text-zinc-500`,children:[(0,F.jsxs)(`span`,{children:[`Avg TPS: `,(0,F.jsx)(`span`,{className:`metric-mono font-medium text-zinc-600 dark:text-zinc-300`,children:Zf(t)})]}),(0,F.jsxs)(`span`,{children:[`Wtd TPS: `,(0,F.jsx)(`span`,{className:`metric-mono font-medium text-accent`,children:Zf(n)})]})]})]})}var bY=b.memo(yY),xY=[{value:`light`,icon:Of,label:`Light`},{value:`dark`,icon:bf,label:`Dark`},{value:`system`,icon:Gd,label:`System`}];function SY({theme:e,setTheme:t}){return(0,F.jsx)(`div`,{className:`flex items-center gap-1 bg-white/60 dark:bg-zinc-800/40 border border-zinc-200/60 dark:border-white/[0.06] rounded-lg p-0.5`,children:xY.map(({value:n,icon:r,label:i})=>(0,F.jsxs)(`button`,{onClick:()=>t(n),className:`relative flex items-center justify-center h-7 px-2 text-[11px] font-medium rounded-md transition-all ${e===n?`text-zinc-800 dark:text-zinc-300`:`text-zinc-400 dark:text-zinc-400 hover:text-zinc-600 dark:hover:text-zinc-200`}`,title:i,children:[e===n&&(0,F.jsx)(Pu.div,{layoutId:`theme-toggle-bg`,className:`absolute inset-0 bg-white dark:bg-zinc-700/60 rounded-md shadow-sm`,transition:{type:`spring`,stiffness:400,damping:30}}),(0,F.jsx)(r,{size:14,weight:`bold`,className:`relative z-10`})]},n))})}function CY(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var wY=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,TY=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,EY={};function DY(e,t){return((t||EY).jsx?TY:wY).test(e)}var OY=/[ \t\n\f\r]/g;function kY(e){return typeof e==`object`?e.type===`text`?AY(e.value):!1:AY(e)}function AY(e){return e.replace(OY,``)===``}var jY=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};jY.prototype.normal={},jY.prototype.property={},jY.prototype.space=void 0;function MY(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new jY(n,r,t)}function NY(e){return e.toLowerCase()}var PY=class{constructor(e,t){this.attribute=t,this.property=e}};PY.prototype.attribute=``,PY.prototype.booleanish=!1,PY.prototype.boolean=!1,PY.prototype.commaOrSpaceSeparated=!1,PY.prototype.commaSeparated=!1,PY.prototype.defined=!1,PY.prototype.mustUseProperty=!1,PY.prototype.number=!1,PY.prototype.overloadedBoolean=!1,PY.prototype.property=``,PY.prototype.spaceSeparated=!1,PY.prototype.space=void 0;var FY=c({boolean:()=>LY,booleanish:()=>RY,commaOrSpaceSeparated:()=>HY,commaSeparated:()=>VY,number:()=>K,overloadedBoolean:()=>zY,spaceSeparated:()=>BY}),IY=0,LY=UY(),RY=UY(),zY=UY(),K=UY(),BY=UY(),VY=UY(),HY=UY();function UY(){return 2**++IY}var WY=Object.keys(FY),GY=class extends PY{constructor(e,t,n,r){let i=-1;if(super(e,t),KY(this,`space`,r),typeof n==`number`)for(;++i<WY.length;){let e=WY[i];KY(this,WY[i],(n&FY[e])===FY[e])}}};GY.prototype.defined=!0;function KY(e,t,n){n&&(e[t]=n)}function qY(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new GY(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[NY(r)]=r,n[NY(a.attribute)]=r}return new jY(t,n,e.space)}var JY=qY({properties:{ariaActiveDescendant:null,ariaAtomic:RY,ariaAutoComplete:null,ariaBusy:RY,ariaChecked:RY,ariaColCount:K,ariaColIndex:K,ariaColSpan:K,ariaControls:BY,ariaCurrent:null,ariaDescribedBy:BY,ariaDetails:null,ariaDisabled:RY,ariaDropEffect:BY,ariaErrorMessage:null,ariaExpanded:RY,ariaFlowTo:BY,ariaGrabbed:RY,ariaHasPopup:null,ariaHidden:RY,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:BY,ariaLevel:K,ariaLive:null,ariaModal:RY,ariaMultiLine:RY,ariaMultiSelectable:RY,ariaOrientation:null,ariaOwns:BY,ariaPlaceholder:null,ariaPosInSet:K,ariaPressed:RY,ariaReadOnly:RY,ariaRelevant:null,ariaRequired:RY,ariaRoleDescription:BY,ariaRowCount:K,ariaRowIndex:K,ariaRowSpan:K,ariaSelected:RY,ariaSetSize:K,ariaSort:null,ariaValueMax:K,ariaValueMin:K,ariaValueNow:K,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function YY(e,t){return t in e?e[t]:t}function XY(e,t){return YY(e,t.toLowerCase())}var ZY=qY({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:VY,acceptCharset:BY,accessKey:BY,action:null,allow:null,allowFullScreen:LY,allowPaymentRequest:LY,allowUserMedia:LY,alpha:LY,alt:null,as:null,async:LY,autoCapitalize:null,autoComplete:BY,autoFocus:LY,autoPlay:LY,blocking:BY,capture:null,charSet:null,checked:LY,cite:null,className:BY,closedBy:null,colorSpace:null,cols:K,colSpan:K,command:null,commandFor:null,content:null,contentEditable:RY,controls:LY,controlsList:BY,coords:K|VY,crossOrigin:null,data:null,dateTime:null,decoding:null,default:LY,defer:LY,dir:null,dirName:null,disabled:LY,download:zY,draggable:RY,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:LY,formTarget:null,headers:BY,height:K,hidden:zY,high:K,href:null,hrefLang:null,htmlFor:BY,httpEquiv:BY,id:null,imageSizes:null,imageSrcSet:null,inert:LY,inputMode:null,integrity:null,is:null,isMap:LY,itemId:null,itemProp:BY,itemRef:BY,itemScope:LY,itemType:BY,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:LY,low:K,manifest:null,max:null,maxLength:K,media:null,method:null,min:null,minLength:K,multiple:LY,muted:LY,name:null,nonce:null,noModule:LY,noValidate:LY,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:LY,optimum:K,pattern:null,ping:BY,placeholder:null,playsInline:LY,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:LY,referrerPolicy:null,rel:BY,required:LY,reversed:LY,rows:K,rowSpan:K,sandbox:BY,scope:null,scoped:LY,seamless:LY,selected:LY,shadowRootClonable:LY,shadowRootCustomElementRegistry:LY,shadowRootDelegatesFocus:LY,shadowRootMode:null,shadowRootSerializable:LY,shape:null,size:K,sizes:null,slot:null,span:K,spellCheck:RY,src:null,srcDoc:null,srcLang:null,srcSet:null,start:K,step:null,style:null,tabIndex:K,target:null,title:null,translate:null,type:null,typeMustMatch:LY,useMap:null,value:RY,width:K,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:BY,axis:null,background:null,bgColor:null,border:K,borderColor:null,bottomMargin:K,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:LY,declare:LY,event:null,face:null,frame:null,frameBorder:null,hSpace:K,leftMargin:K,link:null,longDesc:null,lowSrc:null,marginHeight:K,marginWidth:K,noResize:LY,noHref:LY,noShade:LY,noWrap:LY,object:null,profile:null,prompt:null,rev:null,rightMargin:K,rules:null,scheme:null,scrolling:RY,standby:null,summary:null,text:null,topMargin:K,valueType:null,version:null,vAlign:null,vLink:null,vSpace:K,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:LY,disablePictureInPicture:LY,disableRemotePlayback:LY,exportParts:VY,part:BY,prefix:null,property:null,results:K,security:null,unselectable:null},space:`html`,transform:XY}),QY=qY({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,maskType:`mask-type`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:HY,accentHeight:K,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:K,amplitude:K,arabicForm:null,ascent:K,attributeName:null,attributeType:null,azimuth:K,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:K,by:null,calcMode:null,capHeight:K,className:BY,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:K,diffuseConstant:K,direction:null,display:null,dur:null,divisor:K,dominantBaseline:null,download:LY,dx:null,dy:null,edgeMode:null,editable:null,elevation:K,enableBackground:null,end:null,event:null,exponent:K,externalResourcesRequired:null,fill:null,fillOpacity:K,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:VY,g2:VY,glyphName:VY,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:K,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:K,horizOriginX:K,horizOriginY:K,id:null,ideographic:K,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:K,k:K,k1:K,k2:K,k3:K,k4:K,kernelMatrix:HY,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:K,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:K,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:K,overlineThickness:K,paintOrder:null,panose1:null,path:null,pathLength:K,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:BY,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:K,pointsAtY:K,pointsAtZ:K,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:HY,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:HY,rev:HY,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:HY,requiredFeatures:HY,requiredFonts:HY,requiredFormats:HY,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:K,specularExponent:K,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:K,strikethroughThickness:K,string:null,stroke:null,strokeDashArray:HY,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:K,strokeOpacity:K,strokeWidth:null,style:null,surfaceScale:K,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:HY,tabIndex:K,tableValues:null,target:null,targetX:K,targetY:K,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:HY,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:K,underlineThickness:K,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:K,values:null,vAlphabetic:K,vMathematical:K,vectorEffect:null,vHanging:K,vIdeographic:K,version:null,vertAdvY:K,vertOriginX:K,vertOriginY:K,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:K,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:YY}),$Y=qY({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),eX=qY({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:XY}),tX=qY({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),nX={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},rX=/[A-Z]/g,iX=/-[a-z]/g,aX=/^data[-\w.:]+$/i;function oX(e,t){let n=NY(t),r=t,i=PY;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&aX.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(iX,cX);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!iX.test(e)){let n=e.replace(rX,sX);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=GY}return new i(r,t)}function sX(e){return`-`+e.toLowerCase()}function cX(e){return e.charAt(1).toUpperCase()}var lX=MY([JY,ZY,$Y,eX,tX],`html`),uX=MY([JY,QY,$Y,eX,tX],`svg`);function dX(e){return e.join(` `).trim()}var fX=s(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g,u=`
713
- `,d=`/`,f=`*`,p=``,m=`comment`,h=`declaration`;function g(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,g=1;function v(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(u);g=~n?e.length-n:g+e.length}function y(){var e={line:l,column:g};return function(t){return t.position=new b(e),C(),t}}function b(e){this.start=e,this.end={line:l,column:g},this.source=t.source}b.prototype.content=e;function x(n){var r=Error(t.source+`:`+l+`:`+g+`: `+n);if(r.reason=n,r.filename=t.source,r.line=l,r.column=g,r.source=e,!t.silent)throw r}function S(t){var n=t.exec(e);if(n){var r=n[0];return v(r),e=e.slice(r.length),n}}function C(){S(i)}function w(e){var t;for(e||=[];t=T();)t!==!1&&e.push(t);return e}function T(){var t=y();if(!(d!=e.charAt(0)||f!=e.charAt(1))){for(var n=2;p!=e.charAt(n)&&(f!=e.charAt(n)||d!=e.charAt(n+1));)++n;if(n+=2,p===e.charAt(n-1))return x(`End of comment missing`);var r=e.slice(2,n-2);return g+=2,v(r),e=e.slice(n),g+=2,t({type:m,comment:r})}}function E(){var e=y(),t=S(a);if(t){if(T(),!S(o))return x(`property missing ':'`);var r=S(s),i=e({type:h,property:_(t[0].replace(n,p)),value:r?_(r[0].replace(n,p)):p});return S(c),i}}function D(){var e=[];w(e);for(var t;t=E();)t!==!1&&(e.push(t),w(e));return e}return C(),D()}function _(e){return e?e.replace(l,p):p}t.exports=g})),pX=s((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.default=r;var n=t(fX());function r(e,t){let r=null;if(!e||typeof e!=`string`)return r;let i=(0,n.default)(e),a=typeof t==`function`;return i.forEach(e=>{if(e.type!==`declaration`)return;let{property:n,value:i}=e;a?t(n,i,e):i&&(r||={},r[n]=i)}),r}})),mX=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(e){return!e||r.test(e)||t.test(e)},s=function(e,t){return t.toUpperCase()},c=function(e,t){return`${t}-`};e.camelCase=function(e,t){return t===void 0&&(t={}),o(e)?e:(e=e.toLowerCase(),e=t.reactCompat?e.replace(a,c):e.replace(i,c),e.replace(n,s))}})),hX=s(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(pX()),r=mX();function i(e,t){var i={};return!e||typeof e!=`string`||(0,n.default)(e,function(e,n){e&&n&&(i[(0,r.camelCase)(e,t)]=n)}),i}i.default=i,t.exports=i})),gX=vX(`end`),_X=vX(`start`);function vX(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function yX(e){let t=_X(e),n=gX(e);if(t&&n)return{start:t,end:n}}function bX(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?SX(e.position):`start`in e||`end`in e?SX(e):`line`in e||`column`in e?xX(e):``}function xX(e){return CX(e&&e.line)+`:`+CX(e&&e.column)}function SX(e){return xX(e&&e.start)+`-`+xX(e&&e.end)}function CX(e){return e&&typeof e==`number`?e:1}var wX=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=bX(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};wX.prototype.file=``,wX.prototype.name=``,wX.prototype.reason=``,wX.prototype.message=``,wX.prototype.stack=``,wX.prototype.column=void 0,wX.prototype.line=void 0,wX.prototype.ancestors=void 0,wX.prototype.cause=void 0,wX.prototype.fatal=void 0,wX.prototype.place=void 0,wX.prototype.ruleId=void 0,wX.prototype.source=void 0;var TX=u(hX(),1),EX={}.hasOwnProperty,DX=new Map,OX=/[A-Z]/g,kX=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),AX=new Set([`td`,`th`]);function jX(e,t){if(!t||t.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=Wpe(n,t.jsxDEV)}else{if(typeof t.jsx!=`function`)throw TypeError("Expected `jsx` in production options");if(typeof t.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");r=Upe(n,t.jsx,t.jsxs)}let i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||`react`,evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space===`svg`?uX:lX,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=MX(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function MX(e,t,n){if(t.type===`element`)return Lpe(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return Rpe(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return Bpe(e,t,n);if(t.type===`mdxjsEsm`)return zpe(e,t);if(t.type===`root`)return Vpe(e,t,n);if(t.type===`text`)return Hpe(e,t)}function Lpe(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=uX,e.schema=i),e.ancestors.push(t);let a=IX(e,t.tagName,!1),o=Gpe(e,t),s=FX(e,t);return kX.has(t.tagName)&&(s=s.filter(function(e){return typeof e==`string`?!kY(e):!0})),NX(e,o,a,t),PX(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function Rpe(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}LX(e,t.position)}function zpe(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);LX(e,t.position)}function Bpe(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=uX,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:IX(e,t.name,!0),o=Kpe(e,t),s=FX(e,t);return NX(e,o,a,t),PX(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function Vpe(e,t,n){let r={};return PX(r,FX(e,t)),e.create(t,e.Fragment,r,n)}function Hpe(e,t){return t.value}function NX(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function PX(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function Upe(e,t,n){return r;function r(e,r,i,a){let o=Array.isArray(i.children)?n:t;return a?o(r,i,a):o(r,i)}}function Wpe(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=_X(n);return t(r,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function Gpe(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&EX.call(t.properties,i)){let a=qpe(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&AX.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||={};t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function Kpe(e,t){let n={};for(let r of t.attributes)if(r.type===`mdxJsxExpressionAttribute`)if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else LX(e,t.position);else{let i=r.name,a;if(r.value&&typeof r.value==`object`)if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else LX(e,t.position);else a=r.value===null?!0:r.value;n[i]=a}return n}function FX(e,t){let n=[],r=-1,i=e.passKeys?new Map:DX;for(;++r<t.children.length;){let a=t.children[r],o;if(e.passKeys){let e=a.type===`element`?a.tagName:a.type===`mdxJsxFlowElement`||a.type===`mdxJsxTextElement`?a.name:void 0;if(e){let t=i.get(e)||0;o=e+`-`+t,i.set(e,t+1)}}let s=MX(e,a,o);s!==void 0&&n.push(s)}return n}function qpe(e,t,n){let r=oX(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?CY(n):dX(n)),r.property===`style`){let t=typeof n==`object`?n:Jpe(e,String(n));return e.stylePropertyNameCase===`css`&&(t=Ype(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?nX[r.property]||r.property:r.attribute,n]}}function Jpe(e,t){try{return(0,TX.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new wX("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:`style`,source:`hast-util-to-jsx-runtime`});throw r.file=e.filePath||void 0,r.url=`https://github.com/syntax-tree/hast-util-to-jsx-runtime#cannot-parse-style-attribute`,r}}function IX(e,t,n){let r;if(!n)r={type:`Literal`,value:t};else if(t.includes(`.`)){let e=t.split(`.`),n=-1,i;for(;++n<e.length;){let t=DY(e[n])?{type:`Identifier`,name:e[n]}:{type:`Literal`,value:e[n]};i=i?{type:`MemberExpression`,object:i,property:t,computed:!!(n&&t.type===`Literal`),optional:!1}:t}r=i}else r=DY(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return EX.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);LX(e)}function LX(e,t){let n=new wX("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:`mdx-estree`,source:`hast-util-to-jsx-runtime`});throw n.file=e.filePath||void 0,n.url=`https://github.com/syntax-tree/hast-util-to-jsx-runtime#cannot-handle-mdx-estrees-without-createevaluater`,n}function Ype(e){let t={},n;for(n in e)EX.call(e,n)&&(t[Xpe(n)]=e[n]);return t}function Xpe(e){let t=e.replace(OX,Zpe);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function Zpe(e){return`-`+e.toLowerCase()}var RX={action:[`form`],cite:[`blockquote`,`del`,`ins`,`q`],data:[`object`],formAction:[`button`,`input`],href:[`a`,`area`,`base`,`link`],icon:[`menuitem`],itemId:null,manifest:[`html`],ping:[`a`,`area`],poster:[`video`],src:[`audio`,`embed`,`iframe`,`img`,`input`,`script`,`source`,`track`,`video`]},Qpe={};function zX(e,t){let n=t||Qpe;return BX(e,typeof n.includeImageAlt==`boolean`?n.includeImageAlt:!0,typeof n.includeHtml==`boolean`?n.includeHtml:!0)}function BX(e,t,n){if($pe(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return VX(e.children,t,n)}return Array.isArray(e)?VX(e,t,n):``}function VX(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=BX(e[i],t,n);return r.join(``)}function $pe(e){return!!(e&&typeof e==`object`)}var HX=document.createElement(`i`);function UX(e){let t=`&`+e+`;`;HX.innerHTML=t;let n=HX.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`||n===t?!1:n}function WX(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function GX(e,t){return e.length>0?(WX(e,e.length,0,t),e):t}var KX={}.hasOwnProperty;function qX(e){let t={},n=-1;for(;++n<e.length;)eme(t,e[n]);return t}function eme(e,t){let n;for(n in t){let r=(KX.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){KX.call(r,a)||(r[a]=[]);let e=i[a];tme(r[a],Array.isArray(e)?e:e?[e]:[])}}}function tme(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);WX(e,0,0,r)}function JX(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)==65535||(n&65535)==65534||n>1114111?`�`:String.fromCodePoint(n)}function YX(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var XX=iZ(/[A-Za-z]/),ZX=iZ(/[\dA-Za-z]/),nme=iZ(/[#-'*+\--9=?A-Z^-~]/);function QX(e){return e!==null&&(e<32||e===127)}var $X=iZ(/\d/),rme=iZ(/[\dA-Fa-f]/),ime=iZ(/[!-/:-@[-`{-~]/);function q(e){return e!==null&&e<-2}function eZ(e){return e!==null&&(e<0||e===32)}function tZ(e){return e===-2||e===-1||e===32}var nZ=iZ(/\p{P}|\p{S}/u),rZ=iZ(/\s/);function iZ(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function aZ(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&ZX(e.charCodeAt(n+1))&&ZX(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&=(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,``),i&&=(n+=i,0)}return t.join(``)+e.slice(r)}function oZ(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return tZ(r)?(e.enter(n),s(r)):t(r)}function s(r){return tZ(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var ame={tokenize:ome};function ome(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null){e.consume(n);return}return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),oZ(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null){e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);return}return q(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var sme={tokenize:cme},sZ={tokenize:lme};function cme(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;return WX(t.events,a+1,0,t.events.slice(n)),t.events.length=s,l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(sZ,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(sZ,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null){i&&v(),_(0),e.consume(n);return}return i||=t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null){g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);return}return q(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;WX(t.events,a+1,0,t.events.slice(n)),t.events.length=e}}function _(r){let i=n.length;for(;i-- >r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function lme(e,t,n){return oZ(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function cZ(e){if(e===null||eZ(e)||rZ(e))return 1;if(nZ(e))return 2}function lZ(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}var uZ={name:`attention`,resolveAll:ume,tokenize:dme};function ume(e,t){let n=-1,r,i,a,o,s,c,l,u;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===`exit`&&e[r][1].type===`attentionSequence`&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},f={...e[n][1].start};dZ(d,-c),dZ(f,c),o={type:c>1?`strongSequence`:`emphasisSequence`,start:d,end:{...e[r][1].end}},s={type:c>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:f},a={type:c>1?`strongText`:`emphasisText`,start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?`strong`:`emphasis`,start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=GX(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=GX(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=GX(l,lZ(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=GX(l,[[`exit`,a,t],[`enter`,s,t],[`exit`,s,t],[`exit`,i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,l=GX(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,WX(e,r-1,n-r+3,l),n=r+l.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function dme(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=cZ(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=cZ(o),u=!l||l===2&&i||n.includes(o),d=!i||i===2&&l||n.includes(r);return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function dZ(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var fme={name:`autolink`,tokenize:pme};function pme(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return XX(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||ZX(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||ZX(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||QX(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):nme(t)?(e.consume(t),l):n(t)}function u(e){return ZX(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||ZX(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var fZ={partial:!0,tokenize:mme};function mme(e,t,n){return r;function r(t){return tZ(t)?oZ(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||q(e)?t(e):n(e)}}var pZ={continuation:{tokenize:gme},exit:_me,name:`blockQuote`,tokenize:hme};function hme(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return tZ(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function gme(e,t,n){let r=this;return i;function i(t){return tZ(t)?oZ(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(pZ,t,n)(r)}}function _me(e){e.exit(`blockQuote`)}var mZ={name:`characterEscape`,tokenize:vme};function vme(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return ime(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var hZ={name:`characterReference`,tokenize:yme};function yme(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=ZX,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=rme,u):(e.enter(`characterReferenceValue`),a=7,o=$X,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===ZX&&!UX(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}var gZ={partial:!0,tokenize:xme},_Z={concrete:!0,name:`codeFenced`,tokenize:bme};function bme(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),tZ(t)?oZ(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||q(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(gZ,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||q(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):tZ(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),oZ(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||q(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||q(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&tZ(t)?oZ(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||q(t)?e.check(gZ,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||q(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),tZ(t)?oZ(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),tZ(t)?oZ(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||q(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function xme(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var vZ={name:`codeIndented`,tokenize:Cme},Sme={partial:!0,tokenize:wme};function Cme(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),oZ(e,a,`linePrefix`,5)(t)}function a(e){let t=r.events[r.events.length-1];return t&&t[1].type===`linePrefix`&&t[2].sliceSerialize(t[1],!0).length>=4?o(e):n(e)}function o(t){return t===null?c(t):q(t)?e.attempt(Sme,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||q(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function wme(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):q(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):oZ(e,a,`linePrefix`,5)(t)}function a(e){let a=r.events[r.events.length-1];return a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):q(e)?i(e):n(e)}}var Tme={name:`codeText`,previous:Dme,resolve:Eme,tokenize:Ome};function Eme(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function Dme(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function Ome(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):q(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||q(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var kme=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&yZ(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),yZ(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),yZ(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e<this.left.length){let t=this.left.splice(e,1/0);yZ(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);yZ(this.left,t.reverse())}}};function yZ(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function bZ(e){let t={},n=-1,r,i,a,o,s,c,l,u=new kme(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,Ame(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(!(o[1].type===`linePrefix`||o[1].type===`listItemIndent`))break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return WX(e,0,1/0,u.slice(0)),!l}function Ame(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}var jme={resolve:Nme,tokenize:Pme},Mme={partial:!0,tokenize:Fme};function Nme(e){return bZ(e),e}function Pme(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):q(t)?e.check(Mme,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function Fme(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),oZ(e,a,`linePrefix`)}function a(i){if(i===null||q(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function xZ(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||QX(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||q(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||eZ(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||QX(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function SZ(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):q(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||q(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!tZ(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function CZ(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):q(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),oZ(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||q(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function wZ(e,t){let n;return r;function r(i){return q(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):tZ(i)?oZ(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var Ime={name:`definition`,tokenize:Rme},Lme={partial:!0,tokenize:zme};function Rme(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return SZ.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=YX(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return eZ(t)?wZ(e,l)(t):l(t)}function l(t){return xZ(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(Lme,d,d)(t)}function d(t){return tZ(t)?oZ(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||q(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function zme(e,t,n){return r;function r(t){return eZ(t)?wZ(e,i)(t):n(t)}function i(t){return CZ(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return tZ(t)?oZ(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||q(e)?t(e):n(e)}}var Bme={name:`hardBreakEscape`,tokenize:Vme};function Vme(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return q(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var Hme={name:`headingAtx`,resolve:Ume,tokenize:Wme};function Ume(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type===`whitespace`&&(r+=2),n-2>r&&e[n][1].type===`whitespace`&&(n-=2),e[n][1].type===`atxHeadingSequence`&&(r===n-1||n-4>r&&e[n-2][1].type===`whitespace`)&&(n-=r+1===n?2:4),n>r&&(i={type:`atxHeadingText`,start:e[r][1].start,end:e[n][1].end},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`},WX(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function Wme(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||eZ(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||q(n)?(e.exit(`atxHeading`),t(n)):tZ(n)?oZ(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||eZ(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var Gme=`address.article.aside.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),TZ=[`pre`,`script`,`style`,`textarea`],Kme={concrete:!0,name:`htmlFlow`,resolveTo:Yme,tokenize:Xme},qme={partial:!0,tokenize:Qme},Jme={partial:!0,tokenize:Zme};function Yme(e){let t=e.length;for(;t--&&!(e[t][0]===`enter`&&e[t][1].type===`htmlFlow`););return t>1&&e[t-2][1].type===`linePrefix`&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function Xme(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:j):XX(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):XX(a)?(e.consume(a),i=4,r.interrupt?t:j):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:j):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:O:m):n(i)}function h(t){return XX(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||eZ(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&TZ.includes(l)?(i=1,r.interrupt?t(s):O(s)):Gme.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):O(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||ZX(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:O):n(i)}function v(t){return tZ(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||XX(t)?(e.consume(t),b):tZ(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||ZX(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):tZ(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):tZ(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||q(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||eZ(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||tZ(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||q(t)?O(t):tZ(t)?(e.consume(t),D):n(t)}function O(t){return t===45&&i===2?(e.consume(t),ne):t===60&&i===1?(e.consume(t),re):t===62&&i===4?(e.consume(t),M):t===63&&i===3?(e.consume(t),j):t===93&&i===5?(e.consume(t),ie):q(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(qme,ae,k)(t)):t===null||q(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(Jme,ee,ae)(t)}function ee(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),te}function te(t){return t===null||q(t)?k(t):(e.enter(`htmlFlowData`),O(t))}function ne(t){return t===45?(e.consume(t),j):O(t)}function re(t){return t===47?(e.consume(t),o=``,A):O(t)}function A(t){if(t===62){let n=o.toLowerCase();return TZ.includes(n)?(e.consume(t),M):O(t)}return XX(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),A):O(t)}function ie(t){return t===93?(e.consume(t),j):O(t)}function j(t){return t===62?(e.consume(t),M):t===45&&i===2?(e.consume(t),j):O(t)}function M(t){return t===null||q(t)?(e.exit(`htmlFlowData`),ae(t)):(e.consume(t),M)}function ae(n){return e.exit(`htmlFlow`),t(n)}}function Zme(e,t,n){let r=this;return i;function i(t){return q(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a):n(t)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function Qme(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(fZ,t,n)}}var $me={name:`htmlText`,tokenize:ehe};function ehe(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):XX(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):XX(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):q(t)?(o=d,re(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?ne(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):q(t)?(o=h,re(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?ne(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?ne(t):q(t)?(o=v,re(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):q(t)?(o=y,re(t)):(e.consume(t),y)}function b(e){return e===62?ne(e):y(e)}function x(t){return XX(t)?(e.consume(t),S):n(t)}function S(t){return t===45||ZX(t)?(e.consume(t),S):C(t)}function C(t){return q(t)?(o=C,re(t)):tZ(t)?(e.consume(t),C):ne(t)}function w(t){return t===45||ZX(t)?(e.consume(t),w):t===47||t===62||eZ(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),ne):t===58||t===95||XX(t)?(e.consume(t),E):q(t)?(o=T,re(t)):tZ(t)?(e.consume(t),T):ne(t)}function E(t){return t===45||t===46||t===58||t===95||ZX(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):q(t)?(o=D,re(t)):tZ(t)?(e.consume(t),D):T(t)}function O(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,k):q(t)?(o=O,re(t)):tZ(t)?(e.consume(t),O):(e.consume(t),ee)}function k(t){return t===i?(e.consume(t),i=void 0,te):t===null?n(t):q(t)?(o=k,re(t)):(e.consume(t),k)}function ee(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||eZ(t)?T(t):(e.consume(t),ee)}function te(e){return e===47||e===62||eZ(e)?T(e):n(e)}function ne(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function re(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),A}function A(t){return tZ(t)?oZ(e,ie,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):ie(t)}function ie(t){return e.enter(`htmlTextData`),o(t)}}var EZ={name:`labelEnd`,resolveAll:ihe,resolveTo:ahe,tokenize:ohe},the={tokenize:she},nhe={tokenize:che},rhe={tokenize:lhe};function ihe(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&WX(e,0,e.length,n),e}function ahe(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type===`link`||i.type===`labelLink`&&i._inactive)break;e[n][0]===`enter`&&i.type===`labelLink`&&(i._inactive=!0)}else if(o){if(e[n][0]===`enter`&&(i.type===`labelImage`||i.type===`labelLink`)&&!i._balanced&&(a=n,i.type!==`labelLink`)){r=2;break}}else i.type===`labelEnd`&&(o=n);let c={type:e[a][1].type===`labelLink`?`link`:`image`,start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:`label`,start:{...e[a][1].start},end:{...e[o][1].end}},u={type:`labelText`,start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[`enter`,c,t],[`enter`,l,t]],s=GX(s,e.slice(a+1,a+r+3)),s=GX(s,[[`enter`,u,t]]),s=GX(s,lZ(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=GX(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=GX(s,e.slice(o+1)),s=GX(s,[[`exit`,c,t]]),WX(e,a,e.length,s),e}function ohe(e,t,n){let r=this,i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type===`labelImage`||r.events[i][1].type===`labelLink`)&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(YX(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(the,u,o?u:d)(t):t===91?e.attempt(nhe,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(rhe,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function she(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return eZ(t)?wZ(e,a)(t):a(t)}function a(t){return t===41?u(t):xZ(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return eZ(t)?wZ(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?CZ(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return eZ(t)?wZ(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function che(e,t,n){let r=this;return i;function i(t){return SZ.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(YX(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function lhe(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}var uhe={name:`labelStartImage`,resolveAll:EZ.resolveAll,tokenize:dhe};function dhe(e,t,n){let r=this;return i;function i(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),a}function a(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelImage`),o):n(t)}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var fhe={name:`labelStartLink`,resolveAll:EZ.resolveAll,tokenize:phe};function phe(e,t,n){let r=this;return i;function i(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelLink`),a}function a(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var DZ={name:`lineEnding`,tokenize:mhe};function mhe(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),oZ(e,t,`linePrefix`)}}var OZ={name:`thematicBreak`,tokenize:hhe};function hhe(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||q(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),tZ(t)?oZ(e,s,`whitespace`)(t):s(t))}}var kZ={continuation:{tokenize:yhe},exit:xhe,name:`list`,tokenize:vhe},ghe={partial:!0,tokenize:She},_he={partial:!0,tokenize:bhe};function vhe(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:$X(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(OZ,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return $X(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check(fZ,r.interrupt?n:u,e.attempt(ghe,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return tZ(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function yhe(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(fZ,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,oZ(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!tZ(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(_he,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,oZ(e,e.attempt(kZ,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function bhe(e,t,n){let r=this;return oZ(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function xhe(e){e.exit(this.containerState.type)}function She(e,t,n){let r=this;return oZ(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!tZ(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var AZ={name:`setextUnderline`,resolveTo:Che,tokenize:whe};function Che(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]===`enter`){if(e[n][1].type===`content`){r=n;break}e[n][1].type===`paragraph`&&(i=n)}else e[n][1].type===`content`&&e.splice(n,1),!a&&e[n][1].type===`definition`&&(a=n);let o={type:`setextHeading`,start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=`setextHeadingText`,a?(e.splice(i,0,[`enter`,o,t]),e.splice(a+1,0,[`exit`,e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push([`exit`,o,t]),e}function whe(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),tZ(t)?oZ(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||q(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var The={tokenize:Ehe};function Ehe(e){let t=this,n=e.attempt(fZ,r,e.attempt(this.parser.constructs.flowInitial,i,oZ(e,e.attempt(this.parser.constructs.flow,i,e.attempt(jme,i)),`linePrefix`)));return n;function r(r){if(r===null){e.consume(r);return}return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null){e.consume(r);return}return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var Dhe={resolveAll:MZ()},Ohe=jZ(`string`),khe=jZ(`text`);function jZ(e){return{resolveAll:MZ(e===`text`?Ahe:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null){t.consume(e);return}return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function MZ(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):(!t[r]||t[r][1].type!==`data`)&&(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function Ahe(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===`lineEnding`)&&e[n-1][1].type===`data`){let r=e[n-1][1],i=t.sliceStream(r),a=i.length,o=-1,s=0,c;for(;a--;){let e=i[a];if(typeof e==`string`){for(o=e.length;e.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(e===-2)c=!0,s++;else if(e!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){let i={type:n===e.length||c||s<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...i.start},r.start.offset===r.end.offset?Object.assign(r,i):(e.splice(n,0,[`enter`,i,t],[`exit`,i,t]),n+=2)}n++}return e}var jhe=c({attentionMarkers:()=>zhe,contentInitial:()=>Nhe,disable:()=>Bhe,document:()=>Mhe,flow:()=>Fhe,flowInitial:()=>Phe,insideSpan:()=>Rhe,string:()=>Ihe,text:()=>Lhe}),Mhe={42:kZ,43:kZ,45:kZ,48:kZ,49:kZ,50:kZ,51:kZ,52:kZ,53:kZ,54:kZ,55:kZ,56:kZ,57:kZ,62:pZ},Nhe={91:Ime},Phe={[-2]:vZ,[-1]:vZ,32:vZ},Fhe={35:Hme,42:OZ,45:[AZ,OZ],60:Kme,61:AZ,95:OZ,96:_Z,126:_Z},Ihe={38:hZ,92:mZ},Lhe={[-5]:DZ,[-4]:DZ,[-3]:DZ,33:uhe,38:hZ,42:uZ,60:[fme,$me],91:fhe,92:[Bme,mZ],93:EZ,95:uZ,96:Tme},Rhe={null:[uZ,Dhe]},zhe={null:[42,95]},Bhe={null:[]};function Vhe(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=GX(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=lZ(a,l.events,l),l.events):[]}function f(e,t){return Uhe(p(e),t)}function p(e){return Hhe(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,E()}function g(){let e;for(;r._index<o.length;){let t=o[r._index];if(typeof t==`string`)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)_(t.charCodeAt(r._bufferIndex));else _(t)}}function _(e){u=u(e)}function v(e){q(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,E()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&WX(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function Hhe(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function Uhe(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\r`;break;case-4:o=`
712
+ `);return{details:i,aggregates:o.rowCount>0?{totalCarbon:G(o,0,`total_carbon`),totalJoules:G(o,0,`total_joules`),avgApcHitRate:WJ(o,0,`avg_apc_hit_rate`),avgPowerWatts:WJ(o,0,`avg_power_watts`),primaryGridId:UJ(o,0,`primary_grid_id`)||null,avgGridIntensity:WJ(o,0,`avg_grid_intensity`),compactionCount:G(o,0,`compaction_count`),compactionEnergy:G(o,0,`compaction_energy`),hasCarbonData:G(o,0,`has_carbon`)>0,hasApcData:G(o,0,`has_apc`)>0,hasPowerData:G(o,0,`has_power`)>0,hasMcrData:G(o,0,`has_mcr`)>0,hasAnySseData:G(o,0,`has_any_sse`)>0}:{totalCarbon:0,totalJoules:0,avgApcHitRate:null,avgPowerWatts:null,primaryGridId:null,avgGridIntensity:null,compactionCount:0,compactionEnergy:0,hasCarbonData:!1,hasApcData:!1,hasPowerData:!1,hasMcrData:!1,hasAnySseData:!1}}}function iY({active:e,payload:t}){if(!e||!t?.length)return null;let n=t[0].payload;return(0,F.jsxs)(`div`,{className:`glass-panel rounded-2xl px-4 py-3 text-sm`,style:{minWidth:200},children:[(0,F.jsxs)(`p`,{className:`text-[11px] font-semibold uppercase tracking-wider text-zinc-400 dark:text-zinc-400 mb-2`,children:[`Request #`,String(n.index)]}),(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsxs)(`div`,{className:`flex justify-between gap-3 text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`CO₂`}),(0,F.jsx)(`span`,{className:`metric-mono font-semibold text-moss`,children:cY(Number(n.carbonGCo2eq))})]}),(0,F.jsxs)(`div`,{className:`flex justify-between gap-3 text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Cumulative`}),(0,F.jsx)(`span`,{className:`metric-mono font-semibold text-zinc-700 dark:text-zinc-300`,children:cY(Number(n.cumulativeCarbonG))})]}),!!n.gridId&&(0,F.jsxs)(`div`,{className:`flex justify-between gap-3 text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Grid`}),(0,F.jsx)(`span`,{className:`metric-mono font-semibold text-zinc-700 dark:text-zinc-300`,children:String(n.gridId)})]}),(0,F.jsxs)(`div`,{className:`flex justify-between gap-3 text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Energy`}),(0,F.jsx)(`span`,{className:`metric-mono font-semibold text-zinc-700 dark:text-zinc-300`,children:Qf(Number(n.joules))})]})]})]})}function aY({active:e,payload:t}){if(!e||!t?.length)return null;let n=t[0].payload,r=Number(n.apcHitRate);return(0,F.jsxs)(`div`,{className:`glass-panel rounded-2xl px-4 py-3 text-sm`,style:{minWidth:200},children:[(0,F.jsxs)(`p`,{className:`text-[11px] font-semibold uppercase tracking-wider text-zinc-400 dark:text-zinc-400 mb-2`,children:[`APC Stats · Request #`,String(n.index)]}),(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsxs)(`div`,{className:`flex justify-between gap-3 text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Hit rate`}),(0,F.jsxs)(`span`,{className:`metric-mono font-semibold ${r>=.8?`text-moss`:r>=.5?`text-accent`:`text-amber`}`,children:[(r*100).toFixed(1),`%`]})]}),(0,F.jsxs)(`div`,{className:`flex justify-between gap-3 text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Hit tokens`}),(0,F.jsx)(`span`,{className:`metric-mono font-semibold text-moss`,children:Yf(Number(n.apcHitTokens))})]}),(0,F.jsxs)(`div`,{className:`flex justify-between gap-3 text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Miss tokens`}),(0,F.jsx)(`span`,{className:`metric-mono font-semibold text-amber`,children:Yf(Number(n.apcMissTokens))})]}),(0,F.jsxs)(`div`,{className:`flex justify-between gap-3 text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Context`}),(0,F.jsxs)(`span`,{className:`metric-mono font-semibold text-zinc-700 dark:text-zinc-300`,children:[Yf(Number(n.contextTokens)),` tok`]})]})]})]})}function oY({active:e,payload:t}){if(!e||!t?.length)return null;let n=t[0].payload;return(0,F.jsxs)(`div`,{className:`glass-panel rounded-2xl px-4 py-3 text-sm`,style:{minWidth:200},children:[(0,F.jsxs)(`p`,{className:`text-[11px] font-semibold uppercase tracking-wider text-zinc-400 dark:text-zinc-400 mb-2`,children:[`Request #`,String(n.index)]}),(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsxs)(`div`,{className:`flex justify-between gap-3 text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Avg power`}),(0,F.jsx)(`span`,{className:`metric-mono font-semibold text-accent`,children:uY(Number(n.avgPowerWatts))})]}),(0,F.jsxs)(`div`,{className:`flex justify-between gap-3 text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Energy`}),(0,F.jsx)(`span`,{className:`metric-mono font-semibold text-zinc-700 dark:text-zinc-300`,children:Qf(Number(n.joules))})]}),(0,F.jsxs)(`div`,{className:`flex justify-between gap-3 text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Duration`}),(0,F.jsxs)(`span`,{className:`metric-mono font-semibold text-zinc-700 dark:text-zinc-300`,children:[(Number(n.totalMs)/1e3).toFixed(1),`s`]})]})]})]})}function sY({active:e,payload:t}){if(!e||!t?.length)return null;let n=t[0].payload;return(0,F.jsxs)(`div`,{className:`glass-panel rounded-2xl px-4 py-3 text-sm`,style:{minWidth:220},children:[(0,F.jsxs)(`p`,{className:`text-[11px] font-semibold uppercase tracking-wider text-zinc-400 dark:text-zinc-400 mb-2`,children:[`MCR · Request #`,String(n.index)]}),(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsxs)(`div`,{className:`flex justify-between gap-3 text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Context`}),(0,F.jsxs)(`span`,{className:`metric-mono font-semibold text-zinc-700 dark:text-zinc-300`,children:[Yf(Number(n.contextTokens)),` tok`]})]}),(0,F.jsxs)(`div`,{className:`flex justify-between gap-3 text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Output`}),(0,F.jsxs)(`span`,{className:`metric-mono font-semibold text-zinc-700 dark:text-zinc-300`,children:[Yf(Number(n.outputTokens)),` tok`]})]}),!!n.mcrMode&&(0,F.jsxs)(`div`,{className:`flex justify-between gap-3 text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Mode`}),(0,F.jsx)(`span`,{className:`metric-mono font-semibold text-accent`,children:String(n.mcrMode)})]}),Number(n.compactionEnergyJoules)>0&&(0,F.jsxs)(`div`,{className:`flex justify-between gap-3 text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Compaction`}),(0,F.jsx)(`span`,{className:`metric-mono font-semibold text-amber`,children:Qf(Number(n.compactionEnergyJoules))})]})]})]})}function cY(e){return e===null?`-`:e<.001?`${(e*1e3).toFixed(2)} μg`:e<1?`${(e*1e3).toFixed(1)} mg`:e<1e3?`${e.toFixed(3)} g`:`${(e/1e3).toFixed(3)} kg`}function lY(e){return e===null?`-`:e<.01?`<0.01g`:e<1?`${e.toFixed(2)}g`:e<1e3?`${e.toFixed(1)}g`:`${(e/1e3).toFixed(2)}kg`}function uY(e){return e===null?`-`:e<1?`${(e*1e3).toFixed(0)} mW`:e<1e3?`${e.toFixed(1)} W`:`${(e/1e3).toFixed(2)} kW`}function dY({dbVersion:e,activeSessionId:t,selectedModel:n}){let{data:r}=wx(()=>rY(t,n),[e,t,n]),i=r?.details??[],a=r?.aggregates??null,{hasCarbonData:o,hasApcData:s,hasPowerData:c,hasMcrData:l,hasAnySseData:u}=a??{hasCarbonData:!1,hasApcData:!1,hasPowerData:!1,hasMcrData:!1,hasAnySseData:!1},d=(0,b.useMemo)(()=>{let e=0;return i.map(t=>({...t,timeLabel:new Date(t.timestamp).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`}),cumulativeCarbonG:(e+=t.carbonGCo2eq??0,e)}))},[i]);if(!a||!u||i.length===0)return null;let f=a,p=d.filter(e=>e.carbonGCo2eq!==null),m=d.filter(e=>e.apcHitRate!==null),h=d.filter(e=>e.avgPowerWatts!==null),g=d.filter(e=>e.contextTokens!==null);return(0,F.jsxs)(Pu.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.25},className:`space-y-6`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,F.jsx)(`div`,{className:`p-2 bg-moss/10 dark:bg-moss/15 rounded-xl`,children:(0,F.jsx)(ff,{size:20,className:`text-moss`,weight:`bold`})}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight text-zinc-800 dark:text-zinc-300`,children:`Energy & Sustainability`}),(0,F.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-400`,children:`Carbon footprint, power profile, and prompt caching efficiency`})]})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 lg:grid-cols-4 gap-2`,children:[o&&(0,F.jsx)(jx,{icon:ff,label:`CO₂ Emissions`,color:`moss`,value:lY(f.totalCarbon),subLabel:`/req`,subValue:lY(f.totalCarbon/(p.length||1)),tooltip:(0,F.jsxs)(`div`,{className:`glass-panel rounded-2xl px-4 py-3 text-xs`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,F.jsx)(`p`,{className:`text-[10px] font-bold uppercase tracking-wider text-zinc-400 dark:text-zinc-400`,children:`Carbon Footprint`}),(0,F.jsx)(ff,{size:12,weight:`bold`,className:`text-moss`})]}),(0,F.jsxs)(`div`,{className:`flex items-baseline gap-2 mb-2.5`,children:[(0,F.jsx)(`p`,{className:`metric-mono text-xl font-bold text-zinc-800 dark:text-zinc-200`,children:lY(f.totalCarbon)}),(0,F.jsx)(`span`,{className:`text-[10px] text-zinc-400 dark:text-zinc-500`,children:`CO₂ equivalent`})]}),(0,F.jsxs)(`div`,{className:`flex gap-2 mb-3`,children:[(0,F.jsxs)(`div`,{className:`flex-1 min-w-0 rounded-lg bg-moss/5 dark:bg-moss/10 p-1.5 text-center`,children:[(0,F.jsx)(`p`,{className:`text-[8px] font-semibold uppercase tracking-wider text-moss`,children:`Per request`}),(0,F.jsx)(`p`,{className:`metric-mono text-[13px] font-bold text-zinc-800 dark:text-zinc-200 mt-0.5`,children:lY(f.totalCarbon/(p.length||1))})]}),(0,F.jsxs)(`div`,{className:`flex-1 min-w-0 rounded-lg bg-zinc-100 dark:bg-white/[0.06] p-1.5 text-center`,children:[(0,F.jsx)(`p`,{className:`text-[8px] font-semibold uppercase tracking-wider text-zinc-400`,children:`Requests`}),(0,F.jsx)(`p`,{className:`metric-mono text-[13px] font-bold text-zinc-800 dark:text-zinc-200 mt-0.5`,children:p.length})]}),(0,F.jsxs)(`div`,{className:`flex-1 min-w-0 rounded-lg bg-zinc-100 dark:bg-white/[0.06] p-1.5 text-center`,children:[(0,F.jsx)(`p`,{className:`text-[8px] font-semibold uppercase tracking-wider text-zinc-400`,children:`Total energy`}),(0,F.jsx)(`p`,{className:`metric-mono text-[13px] font-bold text-zinc-800 dark:text-zinc-200 mt-0.5`,children:Qf(f.totalJoules)})]})]}),(()=>{let e=f.totalCarbon/170,t=f.totalCarbon/8.22,n=f.totalCarbon/((f.avgGridIntensity??475)*9/36e5);return(0,F.jsxs)(`div`,{className:`space-y-1 mb-3`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between text-[10px]`,children:[(0,F.jsxs)(`span`,{className:`flex items-center gap-1.5 text-zinc-500 dark:text-zinc-400`,children:[(0,F.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-ember`}),`Car distance`]}),(0,F.jsx)(`span`,{className:`metric-mono font-medium text-zinc-800 dark:text-zinc-200`,children:e>=1?`${e.toFixed(1)} km`:`${(e*1e3).toFixed(0)} m`})]}),(0,F.jsxs)(`div`,{className:`flex items-center justify-between text-[10px]`,children:[(0,F.jsxs)(`span`,{className:`flex items-center gap-1.5 text-zinc-500 dark:text-zinc-400`,children:[(0,F.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-accent`}),`Phone charges`]}),(0,F.jsx)(`span`,{className:`metric-mono font-medium text-zinc-800 dark:text-zinc-200`,children:t.toFixed(1)})]}),(0,F.jsxs)(`div`,{className:`flex items-center justify-between text-[10px]`,children:[(0,F.jsxs)(`span`,{className:`flex items-center gap-1.5 text-zinc-500 dark:text-zinc-400`,children:[(0,F.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-moss`}),`9W LED hours`]}),(0,F.jsxs)(`span`,{className:`metric-mono font-medium text-zinc-800 dark:text-zinc-200`,children:[n.toFixed(1),`h`]})]})]})})(),f.avgGridIntensity!==null&&(0,F.jsxs)(`div`,{className:`flex items-center justify-between text-[10px] mb-2`,children:[(0,F.jsx)(`span`,{className:`text-zinc-500 dark:text-zinc-400`,children:`Grid carbon intensity`}),(0,F.jsxs)(`span`,{className:`metric-mono font-medium text-zinc-800 dark:text-zinc-200`,children:[Math.round(f.avgGridIntensity),` gCO₂/kWh`]})]}),(0,F.jsx)(`p`,{className:`text-[9px] leading-relaxed text-zinc-400 dark:text-zinc-500 pt-2 border-t border-zinc-200/50 dark:border-white/[0.06]`,children:`Carbon emissions calculated from measured inference energy × grid carbon intensity. Equivalencies use EPA standards: ~170g CO₂/km (avg car), ~8.22g per smartphone charge.`})]})}),s&&f.avgApcHitRate!==null&&(0,F.jsx)(jx,{icon:Fd,label:`APC Hit Rate`,color:`accent`,value:`${(f.avgApcHitRate*100).toFixed(1)}%`,tooltip:(0,F.jsxs)(`div`,{className:`glass-panel rounded-2xl px-4 py-3 text-xs`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,F.jsx)(`p`,{className:`text-[10px] font-bold uppercase tracking-wider text-zinc-400 dark:text-zinc-400`,children:`Automatic Prompt Caching`}),(0,F.jsx)(Fd,{size:12,weight:`bold`,className:`text-accent`})]}),(0,F.jsxs)(`div`,{className:`flex items-baseline gap-2 mb-2.5`,children:[(0,F.jsxs)(`p`,{className:`metric-mono text-xl font-bold text-zinc-800 dark:text-zinc-200`,children:[(f.avgApcHitRate*100).toFixed(1),`%`]}),(0,F.jsx)(`span`,{className:`text-[10px] text-zinc-400 dark:text-zinc-500`,children:`avg hit rate`})]}),(()=>{let e=m.reduce((e,t)=>e+(t.apcHitTokens??0),0),t=m.reduce((e,t)=>e+(t.apcMissTokens??0),0),n=e+t,r=Math.max(...m.map(e=>e.apcHitRate??0)),i=Math.min(...m.map(e=>e.apcHitRate??1));return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`flex gap-2 mb-3`,children:[(0,F.jsxs)(`div`,{className:`flex-1 min-w-0 rounded-lg bg-moss/5 dark:bg-moss/10 p-1.5 text-center`,children:[(0,F.jsx)(`p`,{className:`text-[8px] font-semibold uppercase tracking-wider text-moss`,children:`Hits`}),(0,F.jsx)(`p`,{className:`metric-mono text-[13px] font-bold text-zinc-800 dark:text-zinc-200 mt-0.5`,children:Yf(e)})]}),(0,F.jsxs)(`div`,{className:`flex-1 min-w-0 rounded-lg bg-amber/5 dark:bg-amber/10 p-1.5 text-center`,children:[(0,F.jsx)(`p`,{className:`text-[8px] font-semibold uppercase tracking-wider text-amber`,children:`Misses`}),(0,F.jsx)(`p`,{className:`metric-mono text-[13px] font-bold text-zinc-800 dark:text-zinc-200 mt-0.5`,children:Yf(t)})]}),(0,F.jsxs)(`div`,{className:`flex-1 min-w-0 rounded-lg bg-zinc-100 dark:bg-white/[0.06] p-1.5 text-center`,children:[(0,F.jsx)(`p`,{className:`text-[8px] font-semibold uppercase tracking-wider text-zinc-400`,children:`Requests`}),(0,F.jsx)(`p`,{className:`metric-mono text-[13px] font-bold text-zinc-800 dark:text-zinc-200 mt-0.5`,children:m.length})]})]}),n>0&&(0,F.jsxs)(`div`,{className:`mb-3`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between text-[9px] text-zinc-400 mb-1`,children:[(0,F.jsx)(`span`,{children:`Cache retention`}),(0,F.jsxs)(`span`,{className:`metric-mono font-medium text-moss`,children:[(e/n*100).toFixed(0),`%`]})]}),(0,F.jsxs)(`div`,{className:`h-1.5 rounded-full overflow-hidden flex bg-zinc-100 dark:bg-white/[0.06]`,children:[(0,F.jsx)(`div`,{className:`h-full bg-moss`,style:{width:`${e/n*100}%`}}),(0,F.jsx)(`div`,{className:`h-full bg-amber`,style:{width:`${t/n*100}%`}})]})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-1 mb-2`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between text-[10px]`,children:[(0,F.jsx)(`span`,{className:`text-zinc-500 dark:text-zinc-400`,children:`Best`}),(0,F.jsxs)(`span`,{className:`metric-mono font-medium text-moss`,children:[(r*100).toFixed(0),`%`]})]}),(0,F.jsxs)(`div`,{className:`flex items-center justify-between text-[10px]`,children:[(0,F.jsx)(`span`,{className:`text-zinc-500 dark:text-zinc-400`,children:`Worst`}),(0,F.jsxs)(`span`,{className:`metric-mono font-medium text-ember`,children:[(i*100).toFixed(0),`%`]})]})]})]})})(),(0,F.jsx)(`p`,{className:`text-[9px] leading-relaxed text-zinc-400 dark:text-zinc-500 pt-2 border-t border-zinc-200/50 dark:border-white/[0.06]`,children:`APC (Automatic Prompt Caching) reuses previously processed prompt tokens, avoiding redundant computation. A higher hit rate means fewer tokens need reprocessing, reducing both latency and energy.`})]})}),c&&f.avgPowerWatts!==null&&(0,F.jsx)(jx,{icon:mf,label:`Avg Power Draw`,color:`amber`,value:uY(f.avgPowerWatts),subLabel:`/req`,subValue:Qf(f.totalJoules/(h.length||1)),tooltip:(0,F.jsxs)(`div`,{className:`glass-panel rounded-2xl px-4 py-3 text-xs`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,F.jsx)(`p`,{className:`text-[10px] font-bold uppercase tracking-wider text-zinc-400 dark:text-zinc-400`,children:`Power Profile`}),(0,F.jsx)(mf,{size:12,weight:`bold`,className:`text-amber`})]}),(0,F.jsxs)(`div`,{className:`flex items-baseline gap-2 mb-2.5`,children:[(0,F.jsx)(`p`,{className:`metric-mono text-xl font-bold text-zinc-800 dark:text-zinc-200`,children:uY(f.avgPowerWatts)}),(0,F.jsx)(`span`,{className:`text-[10px] text-zinc-400 dark:text-zinc-500`,children:`avg across requests`})]}),(0,F.jsxs)(`div`,{className:`flex gap-2 mb-3`,children:[(0,F.jsxs)(`div`,{className:`flex-1 min-w-0 rounded-lg bg-amber/5 dark:bg-amber/10 p-1.5 text-center`,children:[(0,F.jsx)(`p`,{className:`text-[8px] font-semibold uppercase tracking-wider text-amber`,children:`Total energy`}),(0,F.jsx)(`p`,{className:`metric-mono text-[13px] font-bold text-zinc-800 dark:text-zinc-200 mt-0.5`,children:Qf(f.totalJoules)})]}),(0,F.jsxs)(`div`,{className:`flex-1 min-w-0 rounded-lg bg-zinc-100 dark:bg-white/[0.06] p-1.5 text-center`,children:[(0,F.jsx)(`p`,{className:`text-[8px] font-semibold uppercase tracking-wider text-zinc-400`,children:`Energy/req`}),(0,F.jsx)(`p`,{className:`metric-mono text-[13px] font-bold text-zinc-800 dark:text-zinc-200 mt-0.5`,children:Qf(f.totalJoules/(h.length||1))})]}),(0,F.jsxs)(`div`,{className:`flex-1 min-w-0 rounded-lg bg-zinc-100 dark:bg-white/[0.06] p-1.5 text-center`,children:[(0,F.jsx)(`p`,{className:`text-[8px] font-semibold uppercase tracking-wider text-zinc-400`,children:`Peak`}),(0,F.jsx)(`p`,{className:`metric-mono text-[13px] font-bold text-zinc-800 dark:text-zinc-200 mt-0.5`,children:uY(Math.max(...h.map(e=>e.avgPowerWatts??0)))})]})]}),(()=>{let e=h.map(e=>e.avgPowerWatts??0),t=Math.min(...e),n=Math.max(...e),r=f.totalJoules/36e5,i=f.totalJoules/18e3,a=f.totalJoules/(9*3600);return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-1 mb-2`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between text-[10px]`,children:[(0,F.jsx)(`span`,{className:`text-zinc-500 dark:text-zinc-400`,children:`Min power`}),(0,F.jsx)(`span`,{className:`metric-mono font-medium text-moss`,children:uY(t)})]}),(0,F.jsxs)(`div`,{className:`flex items-center justify-between text-[10px]`,children:[(0,F.jsx)(`span`,{className:`text-zinc-500 dark:text-zinc-400`,children:`Max power`}),(0,F.jsx)(`span`,{className:`metric-mono font-medium text-ember`,children:uY(n)})]}),(0,F.jsxs)(`div`,{className:`flex items-center justify-between text-[10px]`,children:[(0,F.jsx)(`span`,{className:`text-zinc-500 dark:text-zinc-400`,children:`kWh`}),(0,F.jsx)(`span`,{className:`metric-mono font-medium text-zinc-800 dark:text-zinc-200`,children:r.toFixed(4)})]}),(0,F.jsxs)(`div`,{className:`flex items-center justify-between text-[10px]`,children:[(0,F.jsx)(`span`,{className:`text-zinc-500 dark:text-zinc-400`,children:`Phone charges`}),(0,F.jsx)(`span`,{className:`metric-mono font-medium text-accent`,children:i.toFixed(1)})]})]}),a>0&&(0,F.jsxs)(`div`,{className:`flex items-center justify-between text-[10px] mb-2`,children:[(0,F.jsx)(`span`,{className:`text-zinc-500 dark:text-zinc-400`,children:`9W LED bulb`}),(0,F.jsxs)(`span`,{className:`metric-mono font-medium text-zinc-800 dark:text-zinc-200`,children:[a.toFixed(1),`h`]})]})]})})(),(()=>{let e=i.filter(e=>e.ratioWasCapped===!0).length;return e===0?null:(0,F.jsxs)(`div`,{className:`flex items-center justify-between text-[10px] mb-2`,children:[(0,F.jsx)(`span`,{className:`text-zinc-500 dark:text-zinc-400`,children:`Ratio-capped requests`}),(0,F.jsxs)(`span`,{className:`metric-mono font-medium text-amber`,children:[e,`/`,i.length]})]})})(),(0,F.jsx)(`p`,{className:`text-[9px] leading-relaxed text-zinc-400 dark:text-zinc-500 pt-2 border-t border-zinc-200/50 dark:border-white/[0.06]`,children:`Average power draw during inference. Energy per request includes all GPU, memory, and overhead costs attributed by NeuralWatt profiling.`})]})}),f.primaryGridId&&(0,F.jsx)(jx,{icon:gf,label:`Grid Region`,value:f.primaryGridId,subValue:f.avgGridIntensity===null?void 0:`${Math.round(f.avgGridIntensity)} gCO₂/kWh`,tooltip:(0,F.jsxs)(`div`,{className:`glass-panel rounded-2xl px-4 py-3 text-xs`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,F.jsx)(`p`,{className:`text-[10px] font-bold uppercase tracking-wider text-zinc-400 dark:text-zinc-400`,children:`Grid Region`}),(0,F.jsx)(gf,{size:12,weight:`bold`,className:`text-accent`})]}),(0,F.jsx)(`div`,{className:`flex items-baseline gap-2 mb-2.5`,children:(0,F.jsx)(`p`,{className:`metric-mono text-xl font-bold text-zinc-800 dark:text-zinc-200`,children:f.primaryGridId})}),(0,F.jsxs)(`div`,{className:`flex gap-2 mb-3`,children:[f.avgGridIntensity!==null&&(0,F.jsxs)(`div`,{className:`flex-1 min-w-0 rounded-lg bg-accent/5 dark:bg-accent/10 p-1.5 text-center`,children:[(0,F.jsx)(`p`,{className:`text-[8px] font-semibold uppercase tracking-wider text-accent`,children:`Carbon intensity`}),(0,F.jsxs)(`p`,{className:`metric-mono text-[13px] font-bold text-zinc-800 dark:text-zinc-200 mt-0.5`,children:[Math.round(f.avgGridIntensity),` g/kWh`]})]}),(0,F.jsxs)(`div`,{className:`flex-1 min-w-0 rounded-lg bg-zinc-100 dark:bg-white/[0.06] p-1.5 text-center`,children:[(0,F.jsx)(`p`,{className:`text-[8px] font-semibold uppercase tracking-wider text-zinc-400`,children:`Total CO₂`}),(0,F.jsx)(`p`,{className:`metric-mono text-[13px] font-bold text-zinc-800 dark:text-zinc-200 mt-0.5`,children:lY(f.totalCarbon)})]}),(0,F.jsxs)(`div`,{className:`flex-1 min-w-0 rounded-lg bg-zinc-100 dark:bg-white/[0.06] p-1.5 text-center`,children:[(0,F.jsx)(`p`,{className:`text-[8px] font-semibold uppercase tracking-wider text-zinc-400`,children:`Total energy`}),(0,F.jsx)(`p`,{className:`metric-mono text-[13px] font-bold text-zinc-800 dark:text-zinc-200 mt-0.5`,children:Qf(f.totalJoules)})]})]}),(()=>{let e=new Map;for(let t of p){if(!t.gridId||t.carbonGCo2eq===null)continue;let n=t.gridCarbonIntensity??0,r=e.get(t.gridId);r?(r.count++,r.carbon+=t.carbonGCo2eq):e.set(t.gridId,{count:1,carbon:t.carbonGCo2eq,intensity:n})}if(e.size<=1)return null;let t=Array.from(e.values()).reduce((e,t)=>e+t.carbon,0);return(0,F.jsxs)(`div`,{className:`space-y-1.5 mb-3 pt-2 border-t border-zinc-200/50 dark:border-white/[0.06]`,children:[(0,F.jsx)(`p`,{className:`text-[9px] font-bold uppercase tracking-wider text-zinc-400 dark:text-zinc-400 mb-1`,children:`Emissions by Grid`}),Array.from(e.entries()).sort((e,t)=>t[1].carbon-e[1].carbon).map(([e,n])=>{let r=t>0?n.carbon/t*100:0;return(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between text-[10px]`,children:[(0,F.jsxs)(`span`,{className:`text-zinc-500 dark:text-zinc-400`,children:[e,` `,(0,F.jsxs)(`span`,{className:`text-zinc-400`,children:[`(`,n.intensity,`g/kWh)`]})]}),(0,F.jsx)(`span`,{className:`metric-mono font-medium text-zinc-800 dark:text-zinc-200`,children:lY(n.carbon)})]}),(0,F.jsx)(`div`,{className:`h-1 rounded-full overflow-hidden bg-zinc-100 dark:bg-white/[0.06] mt-0.5`,children:(0,F.jsx)(`div`,{className:`h-full bg-moss/70`,style:{width:`${r}%`}})})]},e)})]})})(),(0,F.jsx)(`p`,{className:`text-[9px] leading-relaxed text-zinc-400 dark:text-zinc-500 pt-2 border-t border-zinc-200/50 dark:border-white/[0.06]`,children:`The electrical grid region determines the carbon intensity used to convert energy measurements into CO₂ emissions. Lower carbon intensity = greener energy. Data from NeuralWatt grid mapping.`})]})})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-6`,children:[o&&p.length>0&&(0,F.jsxs)(Pu.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.2},className:`card-surface p-6`,children:[(0,F.jsxs)(`div`,{className:`mb-4`,children:[(0,F.jsx)(`h3`,{className:`text-base font-semibold tracking-tight text-zinc-800 dark:text-zinc-300`,children:`Carbon Emissions`}),(0,F.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-400 mt-0.5`,children:`Cumulative CO₂ per request and individual contribution`})]}),(0,F.jsx)(`div`,{className:`h-64`,children:(0,F.jsx)(yD,{width:`100%`,height:`100%`,children:(0,F.jsxs)(Lq,{data:p,margin:{top:5,right:5,left:0,bottom:0},children:[(0,F.jsx)(`defs`,{children:(0,F.jsxs)(`linearGradient`,{id:`co2Fill`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,F.jsx)(`stop`,{offset:`5%`,stopColor:`#059669`,stopOpacity:.15}),(0,F.jsx)(`stop`,{offset:`95%`,stopColor:`#059669`,stopOpacity:0})]})}),(0,F.jsx)(xH,{strokeDasharray:`3 3`,stroke:`var(--border)`,className:`dark:opacity-40`,vertical:!1}),(0,F.jsx)(pG,{dataKey:`index`,tick:{fontSize:10,fill:`var(--text-tertiary)`},axisLine:!1,tickLine:!1,dy:8,interval:`preserveStartEnd`}),(0,F.jsx)(OG,{yAxisId:`cumulative`,tick:{fontSize:11,fill:`var(--text-tertiary)`},axisLine:!1,tickLine:!1,dx:-4,tickFormatter:e=>e<1?`${(e*1e3).toFixed(0)}mg`:`${e.toFixed(2)}g`}),(0,F.jsx)(OG,{yAxisId:`perRequest`,orientation:`right`,tick:{fontSize:11,fill:`var(--text-tertiary)`},axisLine:!1,tickLine:!1,dx:4,tickFormatter:e=>e<.01?`${(e*1e3).toFixed(0)}mg`:`${e.toFixed(2)}g`}),(0,F.jsx)(sR,{content:(0,F.jsx)(iY,{})}),(0,F.jsx)(gU,{yAxisId:`cumulative`,type:`monotone`,dataKey:`cumulativeCarbonG`,stroke:`#059669`,strokeWidth:2,fill:`url(#co2Fill)`,animationDuration:400,name:`Cumulative`}),(0,F.jsx)(gW,{yAxisId:`perRequest`,dataKey:`carbonGCo2eq`,fill:`#059669`,fillOpacity:.35,radius:[2,2,0,0],animationDuration:400,name:`Per-request`,barSize:Math.max(2,Math.min(12,200/p.length))})]})})}),(0,F.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-5 gap-y-2 text-[11px]`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(`div`,{className:`w-5 h-2 rounded-sm bg-moss/30`}),(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Per-request`})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(`div`,{className:`w-5 h-0.5 bg-moss rounded-full`}),(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Cumulative`})]})]}),f.totalCarbon>0&&(0,F.jsxs)(`div`,{className:`mt-4 pt-3 border-t border-zinc-100 dark:border-white/[0.06]`,children:[(0,F.jsx)(`p`,{className:`text-[9px] font-semibold uppercase tracking-wider text-zinc-400 dark:text-zinc-400 mb-2`,children:`Equivalencies`}),(0,F.jsx)(`div`,{className:`grid grid-cols-3 gap-3`,children:(()=>{let e=f.totalCarbon/170,t=f.totalCarbon/8.22,n=f.totalCarbon/(f.avgGridIntensity??475)*1e3/9,r=[];return e>=.01&&r.push({label:`Car driven`,value:e>=1?`${e.toFixed(1)} km`:`${(e*1e3).toFixed(0)} m`,color:`text-ember`}),t>=.1&&r.push({label:`Phone charges`,value:t.toFixed(1),color:`text-accent`}),n>=.01&&r.push({label:`9W LED hours`,value:n.toFixed(1)+`h`,color:`text-moss`}),r.map(e=>(0,F.jsxs)(`div`,{className:`text-center`,children:[(0,F.jsx)(`p`,{className:`text-[9px] text-zinc-400 dark:text-zinc-500`,children:e.label}),(0,F.jsx)(`p`,{className:`metric-mono text-sm font-semibold ${e.color} mt-0.5`,children:e.value})]},e.label))})()})]}),(()=>{let e=new Map;for(let t of p){if(!t.gridId||t.carbonGCo2eq===null)continue;let n=t.gridCarbonIntensity??0,r=e.get(t.gridId);r?(r.count++,r.carbon+=t.carbonGCo2eq):e.set(t.gridId,{count:1,carbon:t.carbonGCo2eq,intensity:n})}if(e.size<=1)return null;let t=Array.from(e.values()).reduce((e,t)=>e+t.carbon,0);return(0,F.jsxs)(`div`,{className:`mt-4 pt-3 border-t border-zinc-100 dark:border-white/[0.06]`,children:[(0,F.jsx)(`p`,{className:`text-[9px] font-semibold uppercase tracking-wider text-zinc-400 dark:text-zinc-400 mb-2`,children:`Emissions by Grid Region`}),(0,F.jsx)(`div`,{className:`space-y-1.5`,children:Array.from(e.entries()).sort((e,t)=>t[1].carbon-e[1].carbon).map(([e,n])=>{let r=t>0?n.carbon/t*100:0,i=n.intensity>300?`text-ember`:n.intensity>150?`text-amber`:`text-moss`;return(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`text-[9px] metric-mono text-zinc-500 dark:text-zinc-400 w-16 shrink-0`,children:e}),(0,F.jsx)(`div`,{className:`flex-1 h-3 bg-zinc-50 dark:bg-white/[0.04] rounded-sm overflow-hidden`,children:(0,F.jsx)(Pu.div,{className:`h-full bg-moss/70 rounded-sm`,initial:{width:0},animate:{width:`${r}%`},transition:{duration:.4,ease:`easeOut`}})}),(0,F.jsx)(`span`,{className:`text-[9px] metric-mono font-medium w-14 shrink-0 text-right text-zinc-500 dark:text-zinc-400`,children:lY(n.carbon)}),(0,F.jsxs)(`span`,{className:`text-[8px] metric-mono ${i} w-20 shrink-0 text-right`,children:[n.intensity,`g/kWh`]})]},e)})})]})})()]}),s&&m.length>0&&(0,F.jsxs)(Pu.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.2,delay:.05},className:`card-surface p-6`,children:[(0,F.jsxs)(`div`,{className:`mb-4`,children:[(0,F.jsx)(`h3`,{className:`text-base font-semibold tracking-tight text-zinc-800 dark:text-zinc-300`,children:`APC Efficiency`}),(0,F.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-400 mt-0.5`,children:`Automatic Prompt Caching hit rate across requests`})]}),(0,F.jsx)(`div`,{className:`h-56`,children:(0,F.jsx)(yD,{width:`100%`,height:`100%`,children:(0,F.jsxs)(Fq,{data:m,margin:{top:5,right:5,left:0,bottom:0},children:[(0,F.jsx)(`defs`,{children:(0,F.jsxs)(`linearGradient`,{id:`apcFill`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,F.jsx)(`stop`,{offset:`5%`,stopColor:`#0891b2`,stopOpacity:.2}),(0,F.jsx)(`stop`,{offset:`95%`,stopColor:`#0891b2`,stopOpacity:0})]})}),(0,F.jsx)(xH,{strokeDasharray:`3 3`,stroke:`var(--border)`,className:`dark:opacity-40`,vertical:!1}),(0,F.jsx)(pG,{dataKey:`index`,tick:{fontSize:10,fill:`var(--text-tertiary)`},axisLine:!1,tickLine:!1,dy:8,interval:`preserveStartEnd`}),(0,F.jsx)(OG,{tick:{fontSize:11,fill:`var(--text-tertiary)`},axisLine:!1,tickLine:!1,dx:-4,domain:[0,1.05],tickFormatter:e=>`${(e*100).toFixed(0)}%`}),(0,F.jsx)(sR,{content:(0,F.jsx)(aY,{})}),(0,F.jsx)(mV,{y:1,stroke:`#059669`,strokeDasharray:`4 4`,strokeOpacity:.4}),(0,F.jsx)(gU,{type:`monotone`,dataKey:`apcHitRate`,stroke:`#0891b2`,strokeWidth:2,fill:`url(#apcFill)`,animationDuration:400})]})})}),(0,F.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-5 gap-y-2 text-[11px]`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(`div`,{className:`w-5 h-0.5 bg-accent rounded-full`}),(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`APC hit rate`})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(`div`,{className:`w-5 h-0.5 bg-moss rounded-full opacity-40`,style:{borderStyle:`dashed`}}),(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`100% reference`})]})]}),m.length>0&&(()=>{let e=m.reduce((e,t)=>e+(t.apcHitTokens??0),0),t=m.reduce((e,t)=>e+(t.apcMissTokens??0),0),n=e+t,r=m.slice(-8);return(0,F.jsx)(`div`,{className:`mt-4 pt-3 border-t border-zinc-100 dark:border-white/[0.06]`,children:(0,F.jsxs)(`div`,{className:`flex gap-6 items-start`,children:[(0,F.jsxs)(`div`,{className:`shrink-0 w-24`,children:[(0,F.jsxs)(`div`,{className:`h-24 relative`,children:[(0,F.jsx)(yD,{width:`100%`,height:`100%`,children:(0,F.jsx)(jq,{children:(0,F.jsxs)(Vz,{data:[{name:`Hit`,value:e||0},{name:`Miss`,value:t||0}],dataKey:`value`,innerRadius:28,outerRadius:40,strokeWidth:0,animationBegin:0,animationDuration:600,children:[(0,F.jsx)(cR,{fill:`#059669`}),(0,F.jsx)(cR,{fill:`#d97706`})]})})}),(0,F.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,F.jsxs)(`div`,{className:`text-center`,children:[(0,F.jsxs)(`p`,{className:`metric-mono text-sm font-bold text-zinc-800 dark:text-zinc-300 leading-none`,children:[n>0?(e/n*100).toFixed(0):`0`,`%`]}),(0,F.jsx)(`p`,{className:`text-[7px] text-zinc-400 dark:text-zinc-500 mt-0.5`,children:`hit rate`})]})})]}),(0,F.jsxs)(`div`,{className:`mt-1 flex justify-center gap-3 text-[8px]`,children:[(0,F.jsxs)(`span`,{className:`flex items-center gap-0.5`,children:[(0,F.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-moss`}),Yf(e)]}),(0,F.jsxs)(`span`,{className:`flex items-center gap-0.5`,children:[(0,F.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-amber`}),Yf(t)]})]})]}),(0,F.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,F.jsx)(`p`,{className:`text-[9px] font-semibold uppercase tracking-wider text-zinc-400 dark:text-zinc-400 mb-2`,children:`Per-Request`}),(0,F.jsx)(`div`,{className:`grid grid-cols-4 gap-2`,children:r.map(e=>{let t=e.apcHitRate??0,n=t*100,r=Math.PI*2*14,i=`${t*r} ${r}`,a=e.apcHitTokens??0,o=a+(e.apcMissTokens??0),s=n>=90,c=n<50,l=s?`#059669`:c?`#ef4444`:`#0891b2`;return(0,F.jsxs)(`div`,{className:`flex flex-col items-center`,children:[(0,F.jsxs)(`svg`,{width:`40`,height:`40`,viewBox:`0 0 36 36`,children:[(0,F.jsx)(`circle`,{cx:`18`,cy:`18`,r:`14`,fill:`none`,stroke:`var(--border)`,strokeWidth:`3`,opacity:`0.5`}),(0,F.jsx)(Pu.circle,{cx:`18`,cy:`18`,r:`14`,fill:`none`,stroke:l,strokeWidth:`3`,strokeLinecap:`round`,strokeDasharray:i,transform:`rotate(-90 18 18)`,initial:{strokeDasharray:`0 ${r}`},animate:{strokeDasharray:i},transition:{duration:.6,ease:`easeOut`}})]}),(0,F.jsxs)(`p`,{className:`metric-mono text-[10px] font-semibold leading-none mt-0.5 ${s?`text-moss`:c?`text-ember`:`text-accent`}`,children:[n.toFixed(0),`%`]}),(0,F.jsxs)(`p`,{className:`text-[7px] metric-mono text-zinc-300 dark:text-zinc-600`,children:[`#`,e.index]}),o>0&&(0,F.jsxs)(`p`,{className:`text-[6px] metric-mono text-zinc-300 dark:text-zinc-600 leading-tight mt-0.5 text-center`,children:[Yf(a),`/`,Yf(o),` tok`]})]},e.index)})})]})]})})})()]}),c&&h.length>0&&(0,F.jsxs)(Pu.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.2,delay:.1},className:`card-surface p-6`,children:[(0,F.jsxs)(`div`,{className:`mb-4`,children:[(0,F.jsx)(`h3`,{className:`text-base font-semibold tracking-tight text-zinc-800 dark:text-zinc-300`,children:`Power Profile`}),(0,F.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-400 mt-0.5`,children:`Average power draw per inference request`})]}),(0,F.jsx)(`div`,{className:`h-56`,children:(0,F.jsx)(yD,{width:`100%`,height:`100%`,children:(0,F.jsxs)(Fq,{data:h,margin:{top:5,right:5,left:0,bottom:0},children:[(0,F.jsx)(`defs`,{children:(0,F.jsxs)(`linearGradient`,{id:`powerFill`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,F.jsx)(`stop`,{offset:`5%`,stopColor:`#d97706`,stopOpacity:.2}),(0,F.jsx)(`stop`,{offset:`95%`,stopColor:`#d97706`,stopOpacity:0})]})}),(0,F.jsx)(xH,{strokeDasharray:`3 3`,stroke:`var(--border)`,className:`dark:opacity-40`,vertical:!1}),(0,F.jsx)(pG,{dataKey:`index`,tick:{fontSize:10,fill:`var(--text-tertiary)`},axisLine:!1,tickLine:!1,dy:8,interval:`preserveStartEnd`}),(0,F.jsx)(OG,{tick:{fontSize:11,fill:`var(--text-tertiary)`},axisLine:!1,tickLine:!1,dx:-4,tickFormatter:e=>e>=1e3?`${(e/1e3).toFixed(1)}kW`:`${e.toFixed(0)}W`}),(0,F.jsx)(sR,{content:(0,F.jsx)(oY,{})}),(0,F.jsx)(gU,{type:`monotone`,dataKey:`avgPowerWatts`,stroke:`#d97706`,strokeWidth:2,fill:`url(#powerFill)`,animationDuration:400})]})})}),(0,F.jsx)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-5 gap-y-2 text-[11px]`,children:(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(`div`,{className:`w-5 h-0.5 bg-amber rounded-full`}),(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Avg power (W)`})]})}),h.length>1&&(0,F.jsxs)(`div`,{className:`mt-4 pt-3 border-t border-zinc-100 dark:border-white/[0.06]`,children:[(0,F.jsx)(`p`,{className:`text-[9px] font-semibold uppercase tracking-wider text-zinc-400 dark:text-zinc-400 mb-2`,children:`Power Distribution`}),(0,F.jsx)(`div`,{className:`space-y-1.5`,children:(()=>{let e=h.map(e=>e.avgPowerWatts??0),t=[{label:`<1kW`,max:1e3,color:`bg-moss`},{label:`1-2kW`,max:2e3,color:`bg-accent`},{label:`2-3kW`,max:3e3,color:`bg-amber`},{label:`3-5kW`,max:5e3,color:`bg-ember/70`},{label:`>5kW`,max:1/0,color:`bg-ember`}];return t.map(n=>{let r=t[t.indexOf(n)-1]?.max??0,i=e.filter(e=>e>r&&e<=n.max).length,a=e.length>0?i/e.length*100:0,o=Math.max(...t.map(n=>e.filter(e=>e>(t[t.indexOf(n)-1]?.max??0)&&e<=n.max).length),1);return(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`text-[9px] metric-mono text-zinc-400 dark:text-zinc-400 w-10 shrink-0 text-right`,children:n.label}),(0,F.jsx)(`div`,{className:`flex-1 h-3 bg-zinc-50 dark:bg-white/[0.04] rounded-sm overflow-hidden`,children:(0,F.jsx)(Pu.div,{className:`h-full ${n.color} rounded-sm`,initial:{width:0},animate:{width:`${i/o*100}%`},transition:{duration:.4,ease:`easeOut`}})}),(0,F.jsxs)(`span`,{className:`text-[9px] metric-mono font-medium w-12 shrink-0 text-right text-zinc-500 dark:text-zinc-400`,children:[i,` `,i>0?`(${a.toFixed(0)}%)`:``]})]},n.label)})})()})]}),(()=>{let e=i.filter(e=>e.ratioWasCapped===!0).length,t=i.reduce((e,t)=>e+(t.uncappedEnergyJoules??0),0),n=new Map;for(let e of i)e.attributionMethod&&n.set(e.attributionMethod,(n.get(e.attributionMethod)??0)+1);return e===0&&t===0&&n.size===0?null:(0,F.jsxs)(`div`,{className:`mt-4 pt-3 border-t border-zinc-100 dark:border-white/[0.06] flex flex-wrap items-center gap-x-4 gap-y-2 text-[10px] text-zinc-400 dark:text-zinc-500`,children:[e>0&&(0,F.jsxs)(`span`,{children:[`Ratio-capped: `,(0,F.jsxs)(`span`,{className:`metric-mono font-semibold text-amber`,children:[e,`/`,i.length]}),` reqs`]}),t>0&&f.totalJoules>0&&(0,F.jsxs)(`span`,{children:[`Uncapped: `,(0,F.jsx)(`span`,{className:`metric-mono font-semibold text-amber`,children:Qf(t)}),(0,F.jsxs)(`span`,{className:`text-zinc-300 dark:text-zinc-600 ml-1`,children:[`(`,(t/f.totalJoules).toFixed(1),`×)`]})]}),n.size>0&&(0,F.jsxs)(`span`,{children:[`Method: `,Array.from(n.entries()).map(([e,t])=>(0,F.jsxs)(`span`,{className:`metric-mono font-semibold text-zinc-500 dark:text-zinc-400`,children:[e,`(`,t,`)`]},e)).reduce((e,t)=>(0,F.jsxs)(F.Fragment,{children:[e,` `,t]}))]})]})})()]}),l&&g.length>0&&(0,F.jsxs)(Pu.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.2,delay:.15},className:`card-surface p-6`,children:[(0,F.jsxs)(`div`,{className:`mb-4`,children:[(0,F.jsx)(`h3`,{className:`text-base font-semibold tracking-tight text-zinc-800 dark:text-zinc-300`,children:`Context Growth (MCR)`}),(0,F.jsx)(`p`,{className:`text-xs text-zinc-400 dark:text-zinc-400 mt-0.5`,children:`How the context window expands across the conversation`})]}),(0,F.jsx)(`div`,{className:`h-64`,children:(0,F.jsx)(yD,{width:`100%`,height:`100%`,children:(0,F.jsxs)(Fq,{data:g,margin:{top:5,right:5,left:0,bottom:0},children:[(0,F.jsxs)(`defs`,{children:[(0,F.jsxs)(`linearGradient`,{id:`ctxFill`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,F.jsx)(`stop`,{offset:`5%`,stopColor:`#0891b2`,stopOpacity:.15}),(0,F.jsx)(`stop`,{offset:`95%`,stopColor:`#0891b2`,stopOpacity:0})]}),(0,F.jsxs)(`linearGradient`,{id:`outputFill`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,F.jsx)(`stop`,{offset:`5%`,stopColor:`#059669`,stopOpacity:.12}),(0,F.jsx)(`stop`,{offset:`95%`,stopColor:`#059669`,stopOpacity:0})]})]}),(0,F.jsx)(xH,{strokeDasharray:`3 3`,stroke:`var(--border)`,className:`dark:opacity-40`,vertical:!1}),(0,F.jsx)(pG,{dataKey:`index`,tick:{fontSize:10,fill:`var(--text-tertiary)`},axisLine:!1,tickLine:!1,dy:8,interval:`preserveStartEnd`}),(0,F.jsx)(OG,{tick:{fontSize:11,fill:`var(--text-tertiary)`},axisLine:!1,tickLine:!1,dx:-4,tickFormatter:e=>e>=1e3?`${(e/1e3).toFixed(1)}k`:`${e}`}),(0,F.jsx)(sR,{content:(0,F.jsx)(sY,{})}),(0,F.jsx)(gU,{type:`monotone`,dataKey:`outputTokens`,stroke:`#059669`,strokeWidth:1.5,fill:`url(#outputFill)`,animationDuration:400}),(0,F.jsx)(gU,{type:`monotone`,dataKey:`contextTokens`,stroke:`#0891b2`,strokeWidth:2,fill:`url(#ctxFill)`,animationDuration:400})]})})}),(0,F.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-5 gap-y-2 text-[11px]`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(`div`,{className:`w-5 h-0.5 bg-accent rounded-full`}),(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Context tokens (MCR)`})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(`div`,{className:`w-5 h-0.5 bg-moss rounded-full`}),(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Output tokens`})]})]}),(f.compactionCount>0||f.compactionEnergy>0)&&(0,F.jsxs)(`div`,{className:`mt-4 pt-3 border-t border-zinc-100 dark:border-white/[0.06] flex items-center gap-4 text-[10px]`,children:[(0,F.jsxs)(`span`,{className:`text-zinc-400 dark:text-zinc-500`,children:[`Compactions: `,(0,F.jsx)(`span`,{className:`metric-mono font-semibold text-amber`,children:f.compactionCount})]}),f.compactionEnergy>0&&(0,F.jsxs)(`span`,{className:`text-zinc-400 dark:text-zinc-500`,children:[`Compaction energy: `,(0,F.jsx)(`span`,{className:`metric-mono font-semibold text-amber`,children:Qf(f.compactionEnergy)})]})]}),(()=>{let e=new Set(g.map(e=>e.mcrMode).filter(Boolean));return e.size>0?(0,F.jsxs)(`div`,{className:`mt-3 pt-3 border-t border-zinc-100 dark:border-white/[0.06]`,children:[(0,F.jsx)(`p`,{className:`text-[9px] font-semibold uppercase tracking-wider text-zinc-400 dark:text-zinc-400 mb-1.5`,children:`Context Mode`}),(0,F.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Array.from(e).map(e=>{let t=g.filter(t=>t.mcrMode===e).length;return(0,F.jsxs)(`span`,{className:`px-2 py-0.5 rounded-lg text-[10px] font-medium bg-accent/10 text-accent dark:bg-accent/15`,children:[e,` `,(0,F.jsxs)(`span`,{className:`text-accent/60`,children:[`(`,t,`)`]})]},e)})})]}):null})(),g.length>0&&(0,F.jsxs)(`div`,{className:`mt-4 pt-3 border-t border-zinc-100 dark:border-white/[0.06]`,children:[(0,F.jsx)(`p`,{className:`text-[9px] font-semibold uppercase tracking-wider text-zinc-400 dark:text-zinc-400 mb-2`,children:`Token Flow`}),(0,F.jsx)(`div`,{className:`space-y-1`,children:g.slice(-8).map(e=>{let t=e.mcrOriginalTokens??e.contextTokens??0,n=e.mcrCompactedTokens??0,r=e.currentTurnNewTokens??0,i=Math.max(t,r,1);return(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsxs)(`span`,{className:`text-[9px] metric-mono text-zinc-400 dark:text-zinc-400 w-6 shrink-0 text-right`,children:[`#`,e.index]}),(0,F.jsxs)(`div`,{className:`flex-1 h-3 bg-zinc-50 dark:bg-white/[0.04] rounded-sm overflow-hidden flex`,children:[(0,F.jsx)(Pu.div,{className:`h-full bg-accent/60 rounded-l-sm`,initial:{width:0},animate:{width:`${t/i*100}%`},transition:{duration:.4,ease:`easeOut`}}),n>0&&(0,F.jsx)(Pu.div,{className:`h-full bg-amber/60`,initial:{width:0},animate:{width:`${n/i*100}%`},transition:{duration:.4,ease:`easeOut`}}),(0,F.jsx)(Pu.div,{className:`h-full bg-moss/60 rounded-r-sm`,initial:{width:0},animate:{width:`${r/i*100}%`},transition:{duration:.4,ease:`easeOut`}})]}),(0,F.jsx)(`span`,{className:`text-[9px] metric-mono font-medium w-10 shrink-0 text-right text-zinc-500 dark:text-zinc-400`,children:Yf(e.contextTokens)})]},e.index)})}),(0,F.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-4 gap-y-1 text-[9px]`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(`div`,{className:`w-2 h-2 rounded-sm bg-accent/60`}),(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-500`,children:`Original`})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(`div`,{className:`w-2 h-2 rounded-sm bg-amber/60`}),(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-500`,children:`Compacted`})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,F.jsx)(`div`,{className:`w-2 h-2 rounded-sm bg-moss/60`}),(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-500`,children:`New tokens`})]})]})]})]})]}),o&&(0,F.jsx)(Pu.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.2,delay:.2},className:`card-surface p-4`,children:(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-6 gap-y-2 text-[10px] text-zinc-400 dark:text-zinc-500`,children:[(0,F.jsxs)(`span`,{children:[`Total energy: `,(0,F.jsx)(`span`,{className:`metric-mono font-semibold text-zinc-600 dark:text-zinc-300`,children:Qf(f.totalJoules)})]}),f.avgGridIntensity!==null&&(0,F.jsxs)(`span`,{children:[`Grid intensity: `,(0,F.jsxs)(`span`,{className:`metric-mono font-semibold text-zinc-600 dark:text-zinc-300`,children:[Math.round(f.avgGridIntensity),` gCO₂/kWh`]})]}),f.primaryGridId&&(0,F.jsxs)(`span`,{children:[`Region: `,(0,F.jsx)(`span`,{className:`metric-mono font-semibold text-accent`,children:f.primaryGridId})]}),(0,F.jsx)(`span`,{className:`ml-auto text-zinc-300 dark:text-zinc-600`,children:`Powered by NeuralWatt inference profiling`})]})})]})}var fY=(0,b.memo)(dY);function pY({bins:e,fastCount:t,slowCount:n,percentiles:r}){return(0,F.jsxs)(Pu.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.2},className:`card-surface p-6`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between mb-5`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`div`,{className:`p-1.5 bg-accent/10 dark:bg-accent/15 rounded-lg`,children:(0,F.jsx)(Mf,{size:16,className:`text-accent`,weight:`bold`})}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight text-zinc-800 dark:text-zinc-300`,children:`TTFT Distribution`}),(0,F.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-400`,children:`Where time is spent across all calls`})]})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px]`,children:[(0,F.jsxs)(`span`,{className:`metric-mono font-semibold text-moss`,children:[t,` fast`]}),(0,F.jsx)(`span`,{className:`text-zinc-300 dark:text-zinc-700`,children:`·`}),(0,F.jsxs)(`span`,{className:`metric-mono font-semibold text-ember`,children:[n,` slow`]})]})]}),(0,F.jsx)(`div`,{className:`space-y-3`,children:e.map(e=>(0,F.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,F.jsx)(`span`,{className:`text-[11px] metric-mono text-zinc-500 dark:text-zinc-400 w-14 shrink-0 text-right`,children:e.label}),(0,F.jsxs)(`div`,{className:`flex-1 h-7 bg-zinc-50 dark:bg-white/[0.04] rounded-lg overflow-hidden relative`,children:[(0,F.jsx)(Pu.div,{className:`h-full ${e.color} rounded-lg`,initial:{width:0},animate:{width:`${e.barPct}%`},transition:{duration:.4,ease:`easeOut`}}),e.count>0&&(0,F.jsx)(`span`,{className:`absolute inset-y-0 flex items-center text-[11px] metric-mono font-semibold drop-shadow-[0_1px_2px_rgba(0,0,0,0.45)] ${e.barPct>15?`left-2 text-white`:`left-1 text-zinc-600 dark:text-zinc-300`}`,children:e.count})]}),(0,F.jsxs)(`span`,{className:`text-[11px] metric-mono text-zinc-400 dark:text-zinc-400 w-10 shrink-0`,children:[e.pct.toFixed(0),`%`]})]},e.label))}),(0,F.jsx)(`div`,{className:`mt-4 pt-3 border-t border-zinc-100 dark:border-white/[0.06]`,children:(0,F.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-0 divide-x divide-zinc-100 dark:divide-white/[0.06]`,children:r.map(({label:e,value:t})=>(0,F.jsxs)(`div`,{className:`text-center px-3 py-2 first:pl-0 last:pr-0`,children:[(0,F.jsx)(`p`,{className:`text-[10px] font-medium uppercase tracking-wider text-zinc-400 dark:text-zinc-400`,children:e}),(0,F.jsx)(`p`,{className:`metric-mono text-sm font-semibold ${e===`P50`?`text-zinc-700 dark:text-zinc-300`:e===`P75`?`text-amber`:e===`P90`?`text-accent`:`text-ember`} mt-0.5`,children:Jf(t)})]},e))})})]})}var mY=b.memo(pY);function hY({active:e,payload:t,hasCost:n}){if(!e||!t?.length)return null;let r=t[0].payload;return(0,F.jsxs)(`div`,{className:`glass-panel rounded-2xl px-4 py-3 text-sm`,style:{minWidth:240},children:[(0,F.jsx)(`p`,{className:`text-[11px] font-semibold uppercase tracking-wider text-zinc-400 dark:text-zinc-400 mb-2`,children:String(r.fileName||String(r.sessionId).slice(0,24))}),(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsxs)(`div`,{className:`flex justify-between gap-3 text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Requests`}),(0,F.jsx)(`span`,{className:`metric-mono font-semibold text-zinc-700 dark:text-zinc-300`,children:String(r.totalCalls)})]}),(0,F.jsxs)(`div`,{className:`flex justify-between gap-3 text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Tokens`}),(0,F.jsx)(`span`,{className:`metric-mono font-semibold text-zinc-700 dark:text-zinc-300`,children:Number(r.totalTokens).toLocaleString()})]}),(0,F.jsxs)(`div`,{className:`flex justify-between gap-3 text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Wtd TPS`}),(0,F.jsx)(`span`,{className:`metric-mono font-semibold text-accent`,children:Zf(Number(r.weightedTps))})]}),(0,F.jsxs)(`div`,{className:`flex justify-between gap-3 text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Avg TPS`}),(0,F.jsx)(`span`,{className:`metric-mono font-semibold text-zinc-700 dark:text-zinc-300`,children:Zf(Number(r.avgTps))})]}),(0,F.jsxs)(`div`,{className:`flex justify-between gap-3 text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Avg TTFT`}),(0,F.jsx)(`span`,{className:`metric-mono font-semibold text-zinc-700 dark:text-zinc-300`,children:Jf(Math.round(Number(r.avgTtft)))})]}),n&&(0,F.jsxs)(`div`,{className:`flex justify-between gap-3 text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Cost`}),(0,F.jsx)(`span`,{className:`metric-mono font-semibold text-zinc-700 dark:text-zinc-300`,children:Xf(Number(r.y))})]}),r.energy!==null&&(0,F.jsxs)(`div`,{className:`flex justify-between gap-3 text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Energy`}),(0,F.jsx)(`span`,{className:`metric-mono font-semibold text-zinc-700 dark:text-zinc-300`,children:Qf(Number(r.energy))})]}),(0,F.jsxs)(`div`,{className:`flex justify-between gap-3 text-xs whitespace-nowrap`,children:[(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:`Model`}),(0,F.jsx)(`span`,{className:`text-zinc-600 dark:text-zinc-300 truncate max-w-[10rem]`,children:String(r.model).split(`/`).pop()})]})]}),(0,F.jsx)(`p`,{className:`text-[9px] text-zinc-400 dark:text-zinc-500 mt-2 pt-1.5 border-t border-zinc-200/50 dark:border-white/[0.06]`,children:`Click to focus on this session`})]})}function gY({multiSummary:e,onSessionClick:t}){let n=e.sessions.some(e=>e.totalCostUsd!==null),r=(0,b.useMemo)(()=>e.sessions.map(e=>({x:e.weightedTps,y:n?e.totalCostUsd??0:e.wallClockMs,z:e.totalCalls,sessionId:e.sessionId,fileName:e.fileName,totalTokens:e.totalTokens,totalOutput:e.totalOutput,totalCalls:e.totalCalls,avgTtft:e.avgTtft,avgTps:e.avgTps,weightedTps:e.weightedTps,model:e.model,energy:e.totalEnergyJoules,wallClockMs:e.wallClockMs})),[e,n]),i=n?`Cost (USD)`:`Wall-clock Duration`,a=n?e=>Xf(e):e=>Jf(e),o=(0,b.useMemo)(()=>{if(r.length===0)return[0,100];let e=r.map(e=>e.x),t=Math.min(...e),n=Math.max(...e),i=Math.max((n-t)*.1,1);return[Math.max(0,t-i),n+i]},[r]),s=(0,b.useMemo)(()=>{if(r.length===0)return[0,1];let e=r.map(e=>e.y),t=Math.min(...e),i=Math.max(...e),a=Math.max((i-t)*.1,n?.001:1e3);return[Math.max(0,t-a),i+a]},[r,n]);if(r.length<2)return null;let c=[`#0891b2`,`#059669`,`#d97706`,`#dc2626`,`#7c3aed`,`#db2777`,`#0284c7`,`#65a30d`,`#ea580c`,`#6d28d9`],l=new Map,u=0;for(let t of e.sessions)l.has(t.model)||(l.set(t.model,c[u%c.length]),u++);return(0,F.jsxs)(Pu.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.2},className:`card-surface p-6`,children:[(0,F.jsx)(`div`,{className:`flex items-center justify-between mb-6`,children:(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight text-zinc-800 dark:text-zinc-300`,children:`Session Comparison`}),(0,F.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-400 mt-0.5`,children:`Each dot is one session. Bubble size = request count. Color = model.`})]})}),(0,F.jsx)(`div`,{className:`h-72`,children:(0,F.jsx)(yD,{width:`100%`,height:`100%`,children:(0,F.jsxs)(Nq,{margin:{top:5,right:5,left:0,bottom:0},children:[(0,F.jsx)(xH,{strokeDasharray:`3 3`,stroke:`var(--border)`,className:`dark:opacity-40`}),(0,F.jsx)(pG,{type:`number`,dataKey:`x`,name:`Weighted TPS`,domain:o,tick:{fontSize:11,fill:`var(--text-tertiary)`},axisLine:!1,tickLine:!1,dy:8}),(0,F.jsx)(OG,{type:`number`,dataKey:`y`,name:i,domain:s,tick:{fontSize:11,fill:`var(--text-tertiary)`},axisLine:!1,tickLine:!1,dx:-4,tickFormatter:a}),(0,F.jsx)(jG,{type:`number`,dataKey:`z`,range:[60,400]}),(0,F.jsx)(sR,{content:(0,F.jsx)(hY,{hasCost:n}),cursor:{strokeDasharray:`3 3`}}),(0,F.jsx)(KW,{data:r,onClick:e=>t(e.payload.sessionId),children:r.map((e,t)=>(0,F.jsx)(cR,{fill:l.get(e.model)??`#0891b2`,fillOpacity:.65,stroke:l.get(e.model)??`#0891b2`,strokeWidth:1.5,cursor:`pointer`},`cell-${t}`))})]})})}),(0,F.jsx)(`div`,{className:`mt-4 flex flex-wrap items-center gap-x-5 gap-y-2 text-[11px]`,children:Array.from(l.entries()).map(([e,t])=>(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,F.jsx)(`div`,{className:`w-2 h-2 rounded-full`,style:{background:t}}),(0,F.jsx)(`span`,{className:`text-zinc-400 dark:text-zinc-400`,children:e.split(`/`).pop()})]},e))})]})}var _Y=(0,b.memo)(gY);function vY({models:e,avgTps:t,weightedTps:n,totalCalls:r}){let i=(0,b.useMemo)(()=>{if(e.length===0)return[];let t=e.map(e=>{e.callCount;let t=e.blendedCostUsd!==null&&e.totalTokens>0?e.blendedCostUsd/(e.totalTokens/1e6):null,n=e.energyJoules!==null&&e.callCount>0?e.energyJoules/e.callCount:null;return{modelId:e.modelId,provider:e.provider,callCount:e.callCount,totalTokens:e.totalTokens,tpsPerToken:null,blendedCostPer1MTokens:t,energyPerCall:n,blendedCostTotal:e.blendedCostUsd,costSource:e.costSource,rank:null}});if(t.length>1){let e=t.filter(e=>e.blendedCostPer1MTokens!==null);if(e.length>0){let t=e.reduce((e,t)=>(e.blendedCostPer1MTokens??1/0)<(t.blendedCostPer1MTokens??1/0)?e:t);t.rank=`cheapest`}let n=t.reduce((e,t)=>e.callCount>t.callCount?e:t);n.rank===null&&(n.rank=`fastest`)}return t},[e]);return i.length===0||i.length===1?null:(0,F.jsxs)(Pu.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.2},className:`card-surface p-6`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 mb-4`,children:[(0,F.jsx)(Bf,{size:16,className:`text-accent`,weight:`bold`}),(0,F.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight text-zinc-800 dark:text-zinc-300`,children:`Model Performance`}),(0,F.jsxs)(`span`,{className:`ml-auto text-[10px] metric-mono text-zinc-400 dark:text-zinc-500`,children:[i.length,` models · `,Yf(r,0),` calls`]})]}),(0,F.jsx)(`div`,{className:`overflow-x-auto`,children:(0,F.jsxs)(`table`,{className:`w-full text-[11px]`,children:[(0,F.jsx)(`thead`,{children:(0,F.jsxs)(`tr`,{className:`text-[9px] uppercase tracking-wider text-zinc-400 dark:text-zinc-500 border-b border-zinc-200/40 dark:border-white/[0.06]`,children:[(0,F.jsx)(`th`,{className:`text-left px-3 py-2 font-medium`,children:`Model`}),(0,F.jsx)(`th`,{className:`text-right px-3 py-2 font-medium`,children:`Provider`}),(0,F.jsx)(`th`,{className:`text-right px-3 py-2 font-medium`,children:`Calls`}),(0,F.jsx)(`th`,{className:`text-right px-3 py-2 font-medium`,children:`Tokens`}),(0,F.jsx)(`th`,{className:`text-right px-3 py-2 font-medium`,children:`Cost/1M tok`}),(0,F.jsx)(`th`,{className:`text-right px-3 py-2 font-medium`,children:`Total Cost`}),(0,F.jsx)(`th`,{className:`text-right px-3 py-2 font-medium`,children:`Energy/call`}),(0,F.jsx)(`th`,{className:`text-right px-3 py-2 font-medium`,children:`Source`})]})}),(0,F.jsx)(`tbody`,{children:i.map((e,t)=>(0,F.jsxs)(`tr`,{className:`border-b border-zinc-200/20 dark:border-white/[0.03] ${t%2==0?`bg-zinc-50/30 dark:bg-white/[0.01]`:``} ${e.rank?`bg-accent/[0.03] dark:bg-accent/[0.05]`:``}`,children:[(0,F.jsx)(`td`,{className:`px-3 py-2.5 font-medium text-zinc-700 dark:text-zinc-300`,children:(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[e.rank&&(0,F.jsx)(`span`,{className:`text-[8px] font-bold uppercase tracking-wider px-1.5 py-0.5 rounded ${e.rank===`fastest`?`bg-moss/10 text-moss`:`bg-accent/10 text-accent`}`,children:e.rank===`fastest`?`Most used`:`Cheapest`}),(0,F.jsx)(`span`,{className:`truncate max-w-[12rem]`,children:e.modelId.split(`/`).pop()})]})}),(0,F.jsx)(`td`,{className:`px-3 py-2.5 text-right text-zinc-500 dark:text-zinc-400`,children:e.provider}),(0,F.jsx)(`td`,{className:`px-3 py-2.5 text-right metric-mono text-zinc-600 dark:text-zinc-300`,children:Yf(e.callCount,0)}),(0,F.jsx)(`td`,{className:`px-3 py-2.5 text-right metric-mono text-zinc-600 dark:text-zinc-300`,children:Yf(e.totalTokens)}),(0,F.jsx)(`td`,{className:`px-3 py-2.5 text-right metric-mono text-zinc-600 dark:text-zinc-300`,children:e.blendedCostPer1MTokens===null?`-`:`$${e.blendedCostPer1MTokens.toFixed(4)}`}),(0,F.jsx)(`td`,{className:`px-3 py-2.5 text-right metric-mono text-zinc-600 dark:text-zinc-300`,children:e.blendedCostTotal===null?`-`:Xf(e.blendedCostTotal)}),(0,F.jsx)(`td`,{className:`px-3 py-2.5 text-right metric-mono text-zinc-600 dark:text-zinc-300`,children:e.energyPerCall===null?`-`:Qf(e.energyPerCall)}),(0,F.jsx)(`td`,{className:`px-3 py-2.5 text-right text-zinc-500 dark:text-zinc-400`,children:e.costSource===`neuralwatt`?(0,F.jsx)(`span`,{className:`text-accent`,children:`energy`}):e.costSource===`tps`?(0,F.jsx)(`span`,{className:`text-amber`,children:`token`}):`-`})]},e.modelId))})]})}),(0,F.jsxs)(`div`,{className:`mt-3 pt-3 border-t border-zinc-200/40 dark:border-white/[0.06] flex items-center gap-4 text-[10px] text-zinc-400 dark:text-zinc-500`,children:[(0,F.jsxs)(`span`,{children:[`Avg TPS: `,(0,F.jsx)(`span`,{className:`metric-mono font-medium text-zinc-600 dark:text-zinc-300`,children:Zf(t)})]}),(0,F.jsxs)(`span`,{children:[`Wtd TPS: `,(0,F.jsx)(`span`,{className:`metric-mono font-medium text-accent`,children:Zf(n)})]})]})]})}var yY=b.memo(vY),bY=[{value:`light`,icon:Of,label:`Light`},{value:`dark`,icon:bf,label:`Dark`},{value:`system`,icon:Gd,label:`System`}];function xY({theme:e,setTheme:t}){return(0,F.jsx)(`div`,{className:`flex items-center gap-1 bg-white/60 dark:bg-zinc-800/40 border border-zinc-200/60 dark:border-white/[0.06] rounded-lg p-0.5`,children:bY.map(({value:n,icon:r,label:i})=>(0,F.jsxs)(`button`,{onClick:()=>t(n),className:`relative flex items-center justify-center h-7 px-2 text-[11px] font-medium rounded-md transition-all ${e===n?`text-zinc-800 dark:text-zinc-300`:`text-zinc-400 dark:text-zinc-400 hover:text-zinc-600 dark:hover:text-zinc-200`}`,title:i,children:[e===n&&(0,F.jsx)(Pu.div,{layoutId:`theme-toggle-bg`,className:`absolute inset-0 bg-white dark:bg-zinc-700/60 rounded-md shadow-sm`,transition:{type:`spring`,stiffness:400,damping:30}}),(0,F.jsx)(r,{size:14,weight:`bold`,className:`relative z-10`})]},n))})}function SY(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var CY=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,wY=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,TY={};function EY(e,t){return((t||TY).jsx?wY:CY).test(e)}var DY=/[ \t\n\f\r]/g;function OY(e){return typeof e==`object`?e.type===`text`?kY(e.value):!1:kY(e)}function kY(e){return e.replace(DY,``)===``}var AY=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};AY.prototype.normal={},AY.prototype.property={},AY.prototype.space=void 0;function jY(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new AY(n,r,t)}function MY(e){return e.toLowerCase()}var NY=class{constructor(e,t){this.attribute=t,this.property=e}};NY.prototype.attribute=``,NY.prototype.booleanish=!1,NY.prototype.boolean=!1,NY.prototype.commaOrSpaceSeparated=!1,NY.prototype.commaSeparated=!1,NY.prototype.defined=!1,NY.prototype.mustUseProperty=!1,NY.prototype.number=!1,NY.prototype.overloadedBoolean=!1,NY.prototype.property=``,NY.prototype.spaceSeparated=!1,NY.prototype.space=void 0;var PY=c({boolean:()=>IY,booleanish:()=>LY,commaOrSpaceSeparated:()=>VY,commaSeparated:()=>BY,number:()=>K,overloadedBoolean:()=>RY,spaceSeparated:()=>zY}),FY=0,IY=HY(),LY=HY(),RY=HY(),K=HY(),zY=HY(),BY=HY(),VY=HY();function HY(){return 2**++FY}var UY=Object.keys(PY),WY=class extends NY{constructor(e,t,n,r){let i=-1;if(super(e,t),GY(this,`space`,r),typeof n==`number`)for(;++i<UY.length;){let e=UY[i];GY(this,UY[i],(n&PY[e])===PY[e])}}};WY.prototype.defined=!0;function GY(e,t,n){n&&(e[t]=n)}function KY(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new WY(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[MY(r)]=r,n[MY(a.attribute)]=r}return new AY(t,n,e.space)}var qY=KY({properties:{ariaActiveDescendant:null,ariaAtomic:LY,ariaAutoComplete:null,ariaBusy:LY,ariaChecked:LY,ariaColCount:K,ariaColIndex:K,ariaColSpan:K,ariaControls:zY,ariaCurrent:null,ariaDescribedBy:zY,ariaDetails:null,ariaDisabled:LY,ariaDropEffect:zY,ariaErrorMessage:null,ariaExpanded:LY,ariaFlowTo:zY,ariaGrabbed:LY,ariaHasPopup:null,ariaHidden:LY,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:zY,ariaLevel:K,ariaLive:null,ariaModal:LY,ariaMultiLine:LY,ariaMultiSelectable:LY,ariaOrientation:null,ariaOwns:zY,ariaPlaceholder:null,ariaPosInSet:K,ariaPressed:LY,ariaReadOnly:LY,ariaRelevant:null,ariaRequired:LY,ariaRoleDescription:zY,ariaRowCount:K,ariaRowIndex:K,ariaRowSpan:K,ariaSelected:LY,ariaSetSize:K,ariaSort:null,ariaValueMax:K,ariaValueMin:K,ariaValueNow:K,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function JY(e,t){return t in e?e[t]:t}function YY(e,t){return JY(e,t.toLowerCase())}var XY=KY({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:BY,acceptCharset:zY,accessKey:zY,action:null,allow:null,allowFullScreen:IY,allowPaymentRequest:IY,allowUserMedia:IY,alpha:IY,alt:null,as:null,async:IY,autoCapitalize:null,autoComplete:zY,autoFocus:IY,autoPlay:IY,blocking:zY,capture:null,charSet:null,checked:IY,cite:null,className:zY,closedBy:null,colorSpace:null,cols:K,colSpan:K,command:null,commandFor:null,content:null,contentEditable:LY,controls:IY,controlsList:zY,coords:K|BY,crossOrigin:null,data:null,dateTime:null,decoding:null,default:IY,defer:IY,dir:null,dirName:null,disabled:IY,download:RY,draggable:LY,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:IY,formTarget:null,headers:zY,height:K,hidden:RY,high:K,href:null,hrefLang:null,htmlFor:zY,httpEquiv:zY,id:null,imageSizes:null,imageSrcSet:null,inert:IY,inputMode:null,integrity:null,is:null,isMap:IY,itemId:null,itemProp:zY,itemRef:zY,itemScope:IY,itemType:zY,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:IY,low:K,manifest:null,max:null,maxLength:K,media:null,method:null,min:null,minLength:K,multiple:IY,muted:IY,name:null,nonce:null,noModule:IY,noValidate:IY,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:IY,optimum:K,pattern:null,ping:zY,placeholder:null,playsInline:IY,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:IY,referrerPolicy:null,rel:zY,required:IY,reversed:IY,rows:K,rowSpan:K,sandbox:zY,scope:null,scoped:IY,seamless:IY,selected:IY,shadowRootClonable:IY,shadowRootCustomElementRegistry:IY,shadowRootDelegatesFocus:IY,shadowRootMode:null,shadowRootSerializable:IY,shape:null,size:K,sizes:null,slot:null,span:K,spellCheck:LY,src:null,srcDoc:null,srcLang:null,srcSet:null,start:K,step:null,style:null,tabIndex:K,target:null,title:null,translate:null,type:null,typeMustMatch:IY,useMap:null,value:LY,width:K,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:zY,axis:null,background:null,bgColor:null,border:K,borderColor:null,bottomMargin:K,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:IY,declare:IY,event:null,face:null,frame:null,frameBorder:null,hSpace:K,leftMargin:K,link:null,longDesc:null,lowSrc:null,marginHeight:K,marginWidth:K,noResize:IY,noHref:IY,noShade:IY,noWrap:IY,object:null,profile:null,prompt:null,rev:null,rightMargin:K,rules:null,scheme:null,scrolling:LY,standby:null,summary:null,text:null,topMargin:K,valueType:null,version:null,vAlign:null,vLink:null,vSpace:K,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:IY,disablePictureInPicture:IY,disableRemotePlayback:IY,exportParts:BY,part:zY,prefix:null,property:null,results:K,security:null,unselectable:null},space:`html`,transform:YY}),ZY=KY({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,maskType:`mask-type`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:VY,accentHeight:K,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:K,amplitude:K,arabicForm:null,ascent:K,attributeName:null,attributeType:null,azimuth:K,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:K,by:null,calcMode:null,capHeight:K,className:zY,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:K,diffuseConstant:K,direction:null,display:null,dur:null,divisor:K,dominantBaseline:null,download:IY,dx:null,dy:null,edgeMode:null,editable:null,elevation:K,enableBackground:null,end:null,event:null,exponent:K,externalResourcesRequired:null,fill:null,fillOpacity:K,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:BY,g2:BY,glyphName:BY,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:K,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:K,horizOriginX:K,horizOriginY:K,id:null,ideographic:K,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:K,k:K,k1:K,k2:K,k3:K,k4:K,kernelMatrix:VY,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:K,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:K,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:K,overlineThickness:K,paintOrder:null,panose1:null,path:null,pathLength:K,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:zY,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:K,pointsAtY:K,pointsAtZ:K,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:VY,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:VY,rev:VY,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:VY,requiredFeatures:VY,requiredFonts:VY,requiredFormats:VY,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:K,specularExponent:K,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:K,strikethroughThickness:K,string:null,stroke:null,strokeDashArray:VY,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:K,strokeOpacity:K,strokeWidth:null,style:null,surfaceScale:K,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:VY,tabIndex:K,tableValues:null,target:null,targetX:K,targetY:K,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:VY,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:K,underlineThickness:K,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:K,values:null,vAlphabetic:K,vMathematical:K,vectorEffect:null,vHanging:K,vIdeographic:K,version:null,vertAdvY:K,vertOriginX:K,vertOriginY:K,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:K,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:JY}),QY=KY({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),$Y=KY({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:YY}),eX=KY({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),tX={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},nX=/[A-Z]/g,rX=/-[a-z]/g,iX=/^data[-\w.:]+$/i;function aX(e,t){let n=MY(t),r=t,i=NY;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&iX.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(rX,sX);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!rX.test(e)){let n=e.replace(nX,oX);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=WY}return new i(r,t)}function oX(e){return`-`+e.toLowerCase()}function sX(e){return e.charAt(1).toUpperCase()}var cX=jY([qY,XY,QY,$Y,eX],`html`),lX=jY([qY,ZY,QY,$Y,eX],`svg`);function uX(e){return e.join(` `).trim()}var dX=s(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g,u=`
713
+ `,d=`/`,f=`*`,p=``,m=`comment`,h=`declaration`;function g(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,g=1;function v(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(u);g=~n?e.length-n:g+e.length}function y(){var e={line:l,column:g};return function(t){return t.position=new b(e),C(),t}}function b(e){this.start=e,this.end={line:l,column:g},this.source=t.source}b.prototype.content=e;function x(n){var r=Error(t.source+`:`+l+`:`+g+`: `+n);if(r.reason=n,r.filename=t.source,r.line=l,r.column=g,r.source=e,!t.silent)throw r}function S(t){var n=t.exec(e);if(n){var r=n[0];return v(r),e=e.slice(r.length),n}}function C(){S(i)}function w(e){var t;for(e||=[];t=T();)t!==!1&&e.push(t);return e}function T(){var t=y();if(!(d!=e.charAt(0)||f!=e.charAt(1))){for(var n=2;p!=e.charAt(n)&&(f!=e.charAt(n)||d!=e.charAt(n+1));)++n;if(n+=2,p===e.charAt(n-1))return x(`End of comment missing`);var r=e.slice(2,n-2);return g+=2,v(r),e=e.slice(n),g+=2,t({type:m,comment:r})}}function E(){var e=y(),t=S(a);if(t){if(T(),!S(o))return x(`property missing ':'`);var r=S(s),i=e({type:h,property:_(t[0].replace(n,p)),value:r?_(r[0].replace(n,p)):p});return S(c),i}}function D(){var e=[];w(e);for(var t;t=E();)t!==!1&&(e.push(t),w(e));return e}return C(),D()}function _(e){return e?e.replace(l,p):p}t.exports=g})),fX=s((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.default=r;var n=t(dX());function r(e,t){let r=null;if(!e||typeof e!=`string`)return r;let i=(0,n.default)(e),a=typeof t==`function`;return i.forEach(e=>{if(e.type!==`declaration`)return;let{property:n,value:i}=e;a?t(n,i,e):i&&(r||={},r[n]=i)}),r}})),pX=s((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(e){return!e||r.test(e)||t.test(e)},s=function(e,t){return t.toUpperCase()},c=function(e,t){return`${t}-`};e.camelCase=function(e,t){return t===void 0&&(t={}),o(e)?e:(e=e.toLowerCase(),e=t.reactCompat?e.replace(a,c):e.replace(i,c),e.replace(n,s))}})),mX=s(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(fX()),r=pX();function i(e,t){var i={};return!e||typeof e!=`string`||(0,n.default)(e,function(e,n){e&&n&&(i[(0,r.camelCase)(e,t)]=n)}),i}i.default=i,t.exports=i})),hX=_X(`end`),gX=_X(`start`);function _X(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function vX(e){let t=gX(e),n=hX(e);if(t&&n)return{start:t,end:n}}function yX(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?xX(e.position):`start`in e||`end`in e?xX(e):`line`in e||`column`in e?bX(e):``}function bX(e){return SX(e&&e.line)+`:`+SX(e&&e.column)}function xX(e){return bX(e&&e.start)+`-`+bX(e&&e.end)}function SX(e){return e&&typeof e==`number`?e:1}var CX=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=yX(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};CX.prototype.file=``,CX.prototype.name=``,CX.prototype.reason=``,CX.prototype.message=``,CX.prototype.stack=``,CX.prototype.column=void 0,CX.prototype.line=void 0,CX.prototype.ancestors=void 0,CX.prototype.cause=void 0,CX.prototype.fatal=void 0,CX.prototype.place=void 0,CX.prototype.ruleId=void 0,CX.prototype.source=void 0;var wX=u(mX(),1),TX={}.hasOwnProperty,EX=new Map,DX=/[A-Z]/g,OX=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),kX=new Set([`td`,`th`]);function AX(e,t){if(!t||t.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=Gpe(n,t.jsxDEV)}else{if(typeof t.jsx!=`function`)throw TypeError("Expected `jsx` in production options");if(typeof t.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");r=Wpe(n,t.jsx,t.jsxs)}let i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||`react`,evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space===`svg`?lX:cX,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=jX(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function jX(e,t,n){if(t.type===`element`)return Rpe(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return zpe(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return Vpe(e,t,n);if(t.type===`mdxjsEsm`)return Bpe(e,t);if(t.type===`root`)return Hpe(e,t,n);if(t.type===`text`)return Upe(e,t)}function Rpe(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=lX,e.schema=i),e.ancestors.push(t);let a=FX(e,t.tagName,!1),o=Kpe(e,t),s=PX(e,t);return OX.has(t.tagName)&&(s=s.filter(function(e){return typeof e==`string`?!OY(e):!0})),MX(e,o,a,t),NX(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function zpe(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}IX(e,t.position)}function Bpe(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);IX(e,t.position)}function Vpe(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=lX,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:FX(e,t.name,!0),o=qpe(e,t),s=PX(e,t);return MX(e,o,a,t),NX(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function Hpe(e,t,n){let r={};return NX(r,PX(e,t)),e.create(t,e.Fragment,r,n)}function Upe(e,t){return t.value}function MX(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function NX(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function Wpe(e,t,n){return r;function r(e,r,i,a){let o=Array.isArray(i.children)?n:t;return a?o(r,i,a):o(r,i)}}function Gpe(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=gX(n);return t(r,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function Kpe(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&TX.call(t.properties,i)){let a=Jpe(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&kX.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||={};t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function qpe(e,t){let n={};for(let r of t.attributes)if(r.type===`mdxJsxExpressionAttribute`)if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else IX(e,t.position);else{let i=r.name,a;if(r.value&&typeof r.value==`object`)if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else IX(e,t.position);else a=r.value===null?!0:r.value;n[i]=a}return n}function PX(e,t){let n=[],r=-1,i=e.passKeys?new Map:EX;for(;++r<t.children.length;){let a=t.children[r],o;if(e.passKeys){let e=a.type===`element`?a.tagName:a.type===`mdxJsxFlowElement`||a.type===`mdxJsxTextElement`?a.name:void 0;if(e){let t=i.get(e)||0;o=e+`-`+t,i.set(e,t+1)}}let s=jX(e,a,o);s!==void 0&&n.push(s)}return n}function Jpe(e,t,n){let r=aX(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?SY(n):uX(n)),r.property===`style`){let t=typeof n==`object`?n:Ype(e,String(n));return e.stylePropertyNameCase===`css`&&(t=Xpe(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?tX[r.property]||r.property:r.attribute,n]}}function Ype(e,t){try{return(0,wX.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new CX("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:`style`,source:`hast-util-to-jsx-runtime`});throw r.file=e.filePath||void 0,r.url=`https://github.com/syntax-tree/hast-util-to-jsx-runtime#cannot-parse-style-attribute`,r}}function FX(e,t,n){let r;if(!n)r={type:`Literal`,value:t};else if(t.includes(`.`)){let e=t.split(`.`),n=-1,i;for(;++n<e.length;){let t=EY(e[n])?{type:`Identifier`,name:e[n]}:{type:`Literal`,value:e[n]};i=i?{type:`MemberExpression`,object:i,property:t,computed:!!(n&&t.type===`Literal`),optional:!1}:t}r=i}else r=EY(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return TX.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);IX(e)}function IX(e,t){let n=new CX("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:`mdx-estree`,source:`hast-util-to-jsx-runtime`});throw n.file=e.filePath||void 0,n.url=`https://github.com/syntax-tree/hast-util-to-jsx-runtime#cannot-handle-mdx-estrees-without-createevaluater`,n}function Xpe(e){let t={},n;for(n in e)TX.call(e,n)&&(t[Zpe(n)]=e[n]);return t}function Zpe(e){let t=e.replace(DX,Qpe);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function Qpe(e){return`-`+e.toLowerCase()}var LX={action:[`form`],cite:[`blockquote`,`del`,`ins`,`q`],data:[`object`],formAction:[`button`,`input`],href:[`a`,`area`,`base`,`link`],icon:[`menuitem`],itemId:null,manifest:[`html`],ping:[`a`,`area`],poster:[`video`],src:[`audio`,`embed`,`iframe`,`img`,`input`,`script`,`source`,`track`,`video`]},$pe={};function RX(e,t){let n=t||$pe;return zX(e,typeof n.includeImageAlt==`boolean`?n.includeImageAlt:!0,typeof n.includeHtml==`boolean`?n.includeHtml:!0)}function zX(e,t,n){if(eme(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return BX(e.children,t,n)}return Array.isArray(e)?BX(e,t,n):``}function BX(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=zX(e[i],t,n);return r.join(``)}function eme(e){return!!(e&&typeof e==`object`)}var VX=document.createElement(`i`);function HX(e){let t=`&`+e+`;`;VX.innerHTML=t;let n=VX.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`||n===t?!1:n}function UX(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function WX(e,t){return e.length>0?(UX(e,e.length,0,t),e):t}var GX={}.hasOwnProperty;function KX(e){let t={},n=-1;for(;++n<e.length;)tme(t,e[n]);return t}function tme(e,t){let n;for(n in t){let r=(GX.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){GX.call(r,a)||(r[a]=[]);let e=i[a];nme(r[a],Array.isArray(e)?e:e?[e]:[])}}}function nme(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);UX(e,0,0,r)}function qX(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)==65535||(n&65535)==65534||n>1114111?`�`:String.fromCodePoint(n)}function JX(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var YX=rZ(/[A-Za-z]/),XX=rZ(/[\dA-Za-z]/),rme=rZ(/[#-'*+\--9=?A-Z^-~]/);function ZX(e){return e!==null&&(e<32||e===127)}var QX=rZ(/\d/),ime=rZ(/[\dA-Fa-f]/),ame=rZ(/[!-/:-@[-`{-~]/);function q(e){return e!==null&&e<-2}function $X(e){return e!==null&&(e<0||e===32)}function eZ(e){return e===-2||e===-1||e===32}var tZ=rZ(/\p{P}|\p{S}/u),nZ=rZ(/\s/);function rZ(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function iZ(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&XX(e.charCodeAt(n+1))&&XX(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&=(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,``),i&&=(n+=i,0)}return t.join(``)+e.slice(r)}function aZ(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return eZ(r)?(e.enter(n),s(r)):t(r)}function s(r){return eZ(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var ome={tokenize:sme};function sme(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null){e.consume(n);return}return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),aZ(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null){e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);return}return q(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var cme={tokenize:lme},oZ={tokenize:ume};function lme(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;return UX(t.events,a+1,0,t.events.slice(n)),t.events.length=s,l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(oZ,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(oZ,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null){i&&v(),_(0),e.consume(n);return}return i||=t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null){g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);return}return q(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;UX(t.events,a+1,0,t.events.slice(n)),t.events.length=e}}function _(r){let i=n.length;for(;i-- >r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function ume(e,t,n){return aZ(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function sZ(e){if(e===null||$X(e)||nZ(e))return 1;if(tZ(e))return 2}function cZ(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}var lZ={name:`attention`,resolveAll:dme,tokenize:fme};function dme(e,t){let n=-1,r,i,a,o,s,c,l,u;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===`exit`&&e[r][1].type===`attentionSequence`&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},f={...e[n][1].start};uZ(d,-c),uZ(f,c),o={type:c>1?`strongSequence`:`emphasisSequence`,start:d,end:{...e[r][1].end}},s={type:c>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:f},a={type:c>1?`strongText`:`emphasisText`,start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?`strong`:`emphasis`,start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=WX(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=WX(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=WX(l,cZ(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=WX(l,[[`exit`,a,t],[`enter`,s,t],[`exit`,s,t],[`exit`,i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,l=WX(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,UX(e,r-1,n-r+3,l),n=r+l.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function fme(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=sZ(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=sZ(o),u=!l||l===2&&i||n.includes(o),d=!i||i===2&&l||n.includes(r);return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function uZ(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var pme={name:`autolink`,tokenize:mme};function mme(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return YX(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||XX(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||XX(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||ZX(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):rme(t)?(e.consume(t),l):n(t)}function u(e){return XX(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||XX(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var dZ={partial:!0,tokenize:hme};function hme(e,t,n){return r;function r(t){return eZ(t)?aZ(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||q(e)?t(e):n(e)}}var fZ={continuation:{tokenize:_me},exit:vme,name:`blockQuote`,tokenize:gme};function gme(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return eZ(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function _me(e,t,n){let r=this;return i;function i(t){return eZ(t)?aZ(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(fZ,t,n)(r)}}function vme(e){e.exit(`blockQuote`)}var pZ={name:`characterEscape`,tokenize:yme};function yme(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return ame(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var mZ={name:`characterReference`,tokenize:bme};function bme(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=XX,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=ime,u):(e.enter(`characterReferenceValue`),a=7,o=QX,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===XX&&!HX(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}var hZ={partial:!0,tokenize:Sme},gZ={concrete:!0,name:`codeFenced`,tokenize:xme};function xme(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),eZ(t)?aZ(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||q(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(hZ,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||q(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):eZ(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),aZ(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||q(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||q(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&eZ(t)?aZ(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||q(t)?e.check(hZ,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||q(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),eZ(t)?aZ(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),eZ(t)?aZ(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||q(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function Sme(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var _Z={name:`codeIndented`,tokenize:wme},Cme={partial:!0,tokenize:Tme};function wme(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),aZ(e,a,`linePrefix`,5)(t)}function a(e){let t=r.events[r.events.length-1];return t&&t[1].type===`linePrefix`&&t[2].sliceSerialize(t[1],!0).length>=4?o(e):n(e)}function o(t){return t===null?c(t):q(t)?e.attempt(Cme,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||q(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function Tme(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):q(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):aZ(e,a,`linePrefix`,5)(t)}function a(e){let a=r.events[r.events.length-1];return a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):q(e)?i(e):n(e)}}var Eme={name:`codeText`,previous:Ome,resolve:Dme,tokenize:kme};function Dme(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function Ome(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function kme(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):q(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||q(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var Ame=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&vZ(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),vZ(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),vZ(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e<this.left.length){let t=this.left.splice(e,1/0);vZ(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);vZ(this.left,t.reverse())}}};function vZ(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function yZ(e){let t={},n=-1,r,i,a,o,s,c,l,u=new Ame(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,jme(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(!(o[1].type===`linePrefix`||o[1].type===`listItemIndent`))break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return UX(e,0,1/0,u.slice(0)),!l}function jme(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}var Mme={resolve:Pme,tokenize:Fme},Nme={partial:!0,tokenize:Ime};function Pme(e){return yZ(e),e}function Fme(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):q(t)?e.check(Nme,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function Ime(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),aZ(e,a,`linePrefix`)}function a(i){if(i===null||q(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function bZ(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||ZX(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||q(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||$X(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||ZX(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function xZ(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):q(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||q(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!eZ(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function SZ(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):q(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),aZ(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||q(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function CZ(e,t){let n;return r;function r(i){return q(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):eZ(i)?aZ(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var Lme={name:`definition`,tokenize:zme},Rme={partial:!0,tokenize:Bme};function zme(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return xZ.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=JX(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return $X(t)?CZ(e,l)(t):l(t)}function l(t){return bZ(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(Rme,d,d)(t)}function d(t){return eZ(t)?aZ(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||q(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function Bme(e,t,n){return r;function r(t){return $X(t)?CZ(e,i)(t):n(t)}function i(t){return SZ(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return eZ(t)?aZ(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||q(e)?t(e):n(e)}}var Vme={name:`hardBreakEscape`,tokenize:Hme};function Hme(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return q(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var Ume={name:`headingAtx`,resolve:Wme,tokenize:Gme};function Wme(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type===`whitespace`&&(r+=2),n-2>r&&e[n][1].type===`whitespace`&&(n-=2),e[n][1].type===`atxHeadingSequence`&&(r===n-1||n-4>r&&e[n-2][1].type===`whitespace`)&&(n-=r+1===n?2:4),n>r&&(i={type:`atxHeadingText`,start:e[r][1].start,end:e[n][1].end},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`},UX(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function Gme(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||$X(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||q(n)?(e.exit(`atxHeading`),t(n)):eZ(n)?aZ(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||$X(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var Kme=`address.article.aside.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),wZ=[`pre`,`script`,`style`,`textarea`],qme={concrete:!0,name:`htmlFlow`,resolveTo:Xme,tokenize:Zme},Jme={partial:!0,tokenize:$me},Yme={partial:!0,tokenize:Qme};function Xme(e){let t=e.length;for(;t--&&!(e[t][0]===`enter`&&e[t][1].type===`htmlFlow`););return t>1&&e[t-2][1].type===`linePrefix`&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function Zme(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:j):YX(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):YX(a)?(e.consume(a),i=4,r.interrupt?t:j):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:j):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:O:m):n(i)}function h(t){return YX(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||$X(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&wZ.includes(l)?(i=1,r.interrupt?t(s):O(s)):Kme.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):O(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||XX(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:O):n(i)}function v(t){return eZ(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||YX(t)?(e.consume(t),b):eZ(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||XX(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):eZ(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):eZ(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||q(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||$X(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||eZ(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||q(t)?O(t):eZ(t)?(e.consume(t),D):n(t)}function O(t){return t===45&&i===2?(e.consume(t),ne):t===60&&i===1?(e.consume(t),re):t===62&&i===4?(e.consume(t),M):t===63&&i===3?(e.consume(t),j):t===93&&i===5?(e.consume(t),ie):q(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(Jme,ae,k)(t)):t===null||q(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(Yme,ee,ae)(t)}function ee(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),te}function te(t){return t===null||q(t)?k(t):(e.enter(`htmlFlowData`),O(t))}function ne(t){return t===45?(e.consume(t),j):O(t)}function re(t){return t===47?(e.consume(t),o=``,A):O(t)}function A(t){if(t===62){let n=o.toLowerCase();return wZ.includes(n)?(e.consume(t),M):O(t)}return YX(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),A):O(t)}function ie(t){return t===93?(e.consume(t),j):O(t)}function j(t){return t===62?(e.consume(t),M):t===45&&i===2?(e.consume(t),j):O(t)}function M(t){return t===null||q(t)?(e.exit(`htmlFlowData`),ae(t)):(e.consume(t),M)}function ae(n){return e.exit(`htmlFlow`),t(n)}}function Qme(e,t,n){let r=this;return i;function i(t){return q(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a):n(t)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function $me(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(dZ,t,n)}}var ehe={name:`htmlText`,tokenize:the};function the(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):YX(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):YX(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):q(t)?(o=d,re(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?ne(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):q(t)?(o=h,re(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?ne(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?ne(t):q(t)?(o=v,re(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):q(t)?(o=y,re(t)):(e.consume(t),y)}function b(e){return e===62?ne(e):y(e)}function x(t){return YX(t)?(e.consume(t),S):n(t)}function S(t){return t===45||XX(t)?(e.consume(t),S):C(t)}function C(t){return q(t)?(o=C,re(t)):eZ(t)?(e.consume(t),C):ne(t)}function w(t){return t===45||XX(t)?(e.consume(t),w):t===47||t===62||$X(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),ne):t===58||t===95||YX(t)?(e.consume(t),E):q(t)?(o=T,re(t)):eZ(t)?(e.consume(t),T):ne(t)}function E(t){return t===45||t===46||t===58||t===95||XX(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):q(t)?(o=D,re(t)):eZ(t)?(e.consume(t),D):T(t)}function O(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,k):q(t)?(o=O,re(t)):eZ(t)?(e.consume(t),O):(e.consume(t),ee)}function k(t){return t===i?(e.consume(t),i=void 0,te):t===null?n(t):q(t)?(o=k,re(t)):(e.consume(t),k)}function ee(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||$X(t)?T(t):(e.consume(t),ee)}function te(e){return e===47||e===62||$X(e)?T(e):n(e)}function ne(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function re(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),A}function A(t){return eZ(t)?aZ(e,ie,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):ie(t)}function ie(t){return e.enter(`htmlTextData`),o(t)}}var TZ={name:`labelEnd`,resolveAll:ahe,resolveTo:ohe,tokenize:she},nhe={tokenize:che},rhe={tokenize:lhe},ihe={tokenize:uhe};function ahe(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&UX(e,0,e.length,n),e}function ohe(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type===`link`||i.type===`labelLink`&&i._inactive)break;e[n][0]===`enter`&&i.type===`labelLink`&&(i._inactive=!0)}else if(o){if(e[n][0]===`enter`&&(i.type===`labelImage`||i.type===`labelLink`)&&!i._balanced&&(a=n,i.type!==`labelLink`)){r=2;break}}else i.type===`labelEnd`&&(o=n);let c={type:e[a][1].type===`labelLink`?`link`:`image`,start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:`label`,start:{...e[a][1].start},end:{...e[o][1].end}},u={type:`labelText`,start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[`enter`,c,t],[`enter`,l,t]],s=WX(s,e.slice(a+1,a+r+3)),s=WX(s,[[`enter`,u,t]]),s=WX(s,cZ(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=WX(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=WX(s,e.slice(o+1)),s=WX(s,[[`exit`,c,t]]),UX(e,a,e.length,s),e}function she(e,t,n){let r=this,i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type===`labelImage`||r.events[i][1].type===`labelLink`)&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(JX(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(nhe,u,o?u:d)(t):t===91?e.attempt(rhe,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(ihe,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function che(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return $X(t)?CZ(e,a)(t):a(t)}function a(t){return t===41?u(t):bZ(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return $X(t)?CZ(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?SZ(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return $X(t)?CZ(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function lhe(e,t,n){let r=this;return i;function i(t){return xZ.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(JX(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function uhe(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}var dhe={name:`labelStartImage`,resolveAll:TZ.resolveAll,tokenize:fhe};function fhe(e,t,n){let r=this;return i;function i(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),a}function a(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelImage`),o):n(t)}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var phe={name:`labelStartLink`,resolveAll:TZ.resolveAll,tokenize:mhe};function mhe(e,t,n){let r=this;return i;function i(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelLink`),a}function a(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var EZ={name:`lineEnding`,tokenize:hhe};function hhe(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),aZ(e,t,`linePrefix`)}}var DZ={name:`thematicBreak`,tokenize:ghe};function ghe(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||q(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),eZ(t)?aZ(e,s,`whitespace`)(t):s(t))}}var OZ={continuation:{tokenize:bhe},exit:She,name:`list`,tokenize:yhe},_he={partial:!0,tokenize:Che},vhe={partial:!0,tokenize:xhe};function yhe(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:QX(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(DZ,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return QX(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check(dZ,r.interrupt?n:u,e.attempt(_he,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return eZ(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function bhe(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(dZ,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,aZ(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!eZ(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(vhe,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,aZ(e,e.attempt(OZ,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function xhe(e,t,n){let r=this;return aZ(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function She(e){e.exit(this.containerState.type)}function Che(e,t,n){let r=this;return aZ(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!eZ(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var kZ={name:`setextUnderline`,resolveTo:whe,tokenize:The};function whe(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]===`enter`){if(e[n][1].type===`content`){r=n;break}e[n][1].type===`paragraph`&&(i=n)}else e[n][1].type===`content`&&e.splice(n,1),!a&&e[n][1].type===`definition`&&(a=n);let o={type:`setextHeading`,start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=`setextHeadingText`,a?(e.splice(i,0,[`enter`,o,t]),e.splice(a+1,0,[`exit`,e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push([`exit`,o,t]),e}function The(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),eZ(t)?aZ(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||q(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var Ehe={tokenize:Dhe};function Dhe(e){let t=this,n=e.attempt(dZ,r,e.attempt(this.parser.constructs.flowInitial,i,aZ(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Mme,i)),`linePrefix`)));return n;function r(r){if(r===null){e.consume(r);return}return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null){e.consume(r);return}return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var Ohe={resolveAll:jZ()},khe=AZ(`string`),Ahe=AZ(`text`);function AZ(e){return{resolveAll:jZ(e===`text`?jhe:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null){t.consume(e);return}return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function jZ(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):(!t[r]||t[r][1].type!==`data`)&&(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function jhe(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===`lineEnding`)&&e[n-1][1].type===`data`){let r=e[n-1][1],i=t.sliceStream(r),a=i.length,o=-1,s=0,c;for(;a--;){let e=i[a];if(typeof e==`string`){for(o=e.length;e.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(e===-2)c=!0,s++;else if(e!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){let i={type:n===e.length||c||s<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...i.start},r.start.offset===r.end.offset?Object.assign(r,i):(e.splice(n,0,[`enter`,i,t],[`exit`,i,t]),n+=2)}n++}return e}var Mhe=c({attentionMarkers:()=>Bhe,contentInitial:()=>Phe,disable:()=>Vhe,document:()=>Nhe,flow:()=>Ihe,flowInitial:()=>Fhe,insideSpan:()=>zhe,string:()=>Lhe,text:()=>Rhe}),Nhe={42:OZ,43:OZ,45:OZ,48:OZ,49:OZ,50:OZ,51:OZ,52:OZ,53:OZ,54:OZ,55:OZ,56:OZ,57:OZ,62:fZ},Phe={91:Lme},Fhe={[-2]:_Z,[-1]:_Z,32:_Z},Ihe={35:Ume,42:DZ,45:[kZ,DZ],60:qme,61:kZ,95:DZ,96:gZ,126:gZ},Lhe={38:mZ,92:pZ},Rhe={[-5]:EZ,[-4]:EZ,[-3]:EZ,33:dhe,38:mZ,42:lZ,60:[pme,ehe],91:phe,92:[Vme,pZ],93:TZ,95:lZ,96:Eme},zhe={null:[lZ,Ohe]},Bhe={null:[42,95]},Vhe={null:[]};function Hhe(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=WX(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=cZ(a,l.events,l),l.events):[]}function f(e,t){return Whe(p(e),t)}function p(e){return Uhe(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,E()}function g(){let e;for(;r._index<o.length;){let t=o[r._index];if(typeof t==`string`)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)_(t.charCodeAt(r._bufferIndex));else _(t)}}function _(e){u=u(e)}function v(e){q(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,E()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&UX(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function Uhe(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function Whe(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\r`;break;case-4:o=`
714
714
  `;break;case-3:o=`\r
715
- `;break;case-2:o=t?` `:` `;break;case-1:if(!t&&i)continue;o=` `;break;default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(``)}function Whe(e){let t={constructs:qX([jhe,...(e||{}).extensions||[]]),content:n(ame),defined:[],document:n(sme),flow:n(The),lazy:{},string:n(Ohe),text:n(khe)};return t;function n(e){return n;function n(n){return Vhe(t,e,n)}}}function Ghe(e){for(;!bZ(e););return e}var NZ=/[\0\t\n\r]/g;function Khe(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){let s=[],c,l,u,d,f;for(i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i)),u=0,t=``,n&&=(i.charCodeAt(0)===65279&&u++,void 0);u<i.length;){if(NZ.lastIndex=u,c=NZ.exec(i),d=c&&c.index!==void 0?c.index:i.length,f=i.charCodeAt(d),!c){t=i.slice(u);break}if(f===10&&u===d&&r)s.push(-3),r=void 0;else switch(r&&=(s.push(-5),void 0),u<d&&(s.push(i.slice(u,d)),e+=d-u),f){case 0:s.push(65533),e++;break;case 9:for(l=Math.ceil(e/4)*4,s.push(-2);e++<l;)s.push(-1);break;case 10:s.push(-4),e=1;break;default:r=!0,e=1}u=d+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}var qhe=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Jhe(e){return e.replace(qhe,Yhe)}function Yhe(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return JX(n.slice(t?2:1),t?16:10)}return UX(n)||e}var PZ={}.hasOwnProperty;function Xhe(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),Zhe(n)(Ghe(Whe(n).document().write(Khe()(e,t,!0))))}function Zhe(e){let t={transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:a(xe),autolinkProtocol:T,autolinkEmail:T,atxHeading:a(_e),blockQuote:a(fe),characterEscape:T,characterReference:T,codeFenced:a(pe),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(pe,o),codeText:a(me,o),codeTextData:T,data:T,codeFlowValue:T,definition:a(he),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(ge),hardBreakEscape:a(ve),hardBreakTrailing:a(ve),htmlFlow:a(ye,o),htmlFlowData:T,htmlText:a(ye,o),htmlTextData:T,image:a(be),label:o,link:a(xe),listItem:a(Ce),listItemValue:f,listOrdered:a(Se,d),listUnordered:a(Se),paragraph:a(we),reference:oe,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(_e),strong:a(Te),thematicBreak:a(De)},exit:{atxHeading:c(),atxHeadingSequence:x,autolink:c(),autolinkEmail:de,autolinkProtocol:ue,blockQuote:c(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:N,characterReferenceMarkerNumeric:N,characterReferenceValue:ce,characterReference:le,codeFenced:c(g),codeFencedFence:h,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:E,codeIndented:c(_),codeText:c(te),codeTextData:E,data:E,definition:c(),definitionDestinationString:b,definitionLabelString:v,definitionTitleString:y,emphasis:c(),hardBreakEscape:c(O),hardBreakTrailing:c(O),htmlFlow:c(k),htmlFlowData:E,htmlText:c(ee),htmlTextData:E,image:c(re),label:ie,labelText:A,lineEnding:D,link:c(ne),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:se,resourceDestinationString:j,resourceTitleString:M,resource:ae,setextHeading:c(w),setextHeadingLineSequence:C,setextHeadingText:S,strong:c(),thematicBreak:c()}};IZ(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(e){let r={type:`root`,children:[]},a={stack:[r],tokenStack:[],config:t,enter:s,exit:l,buffer:o,resume:u,data:n},c=[],d=-1;for(;++d<e.length;)(e[d][1].type===`listOrdered`||e[d][1].type===`listUnordered`)&&(e[d][0]===`enter`?c.push(d):d=i(e,c.pop(),d));for(d=-1;++d<e.length;){let n=t[e[d][0]];PZ.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},a),e[d][1])}if(a.tokenStack.length>0){let e=a.tokenStack[a.tokenStack.length-1];(e[1]||LZ).call(a,void 0,e[0])}for(r.position={start:FZ(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:FZ(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)r=t.transforms[d](r)||r;return r}function i(e,t,n){let r=t-1,i=-1,a=!1,o,s,c,l;for(;++r<=n;){let t=e[r];switch(t[1].type){case`listUnordered`:case`listOrdered`:case`blockQuote`:t[0]===`enter`?i++:i--,l=void 0;break;case`lineEndingBlank`:t[0]===`enter`&&(o&&!l&&!i&&!c&&(c=r),l=void 0);break;case`linePrefix`:case`listItemValue`:case`listItemMarker`:case`listItemPrefix`:case`listItemPrefixWhitespace`:break;default:l=void 0}if(!i&&t[0]===`enter`&&t[1].type===`listItemPrefix`||i===-1&&t[0]===`exit`&&(t[1].type===`listUnordered`||t[1].type===`listOrdered`)){if(o){let i=r;for(s=void 0;i--;){let t=e[i];if(t[1].type===`lineEnding`||t[1].type===`lineEndingBlank`){if(t[0]===`exit`)continue;s&&(e[s][1].type=`lineEndingBlank`,a=!0),t[1].type=`lineEnding`,s=i}else if(!(t[1].type===`linePrefix`||t[1].type===`blockQuotePrefix`||t[1].type===`blockQuotePrefixWhitespace`||t[1].type===`blockQuoteMarker`||t[1].type===`listItemIndent`))break}c&&(!s||c<s)&&(o._spread=!0),o.end=Object.assign({},s?e[s][1].start:t[1].end),e.splice(s||r,0,[`exit`,o,t[2]]),r++,n++}if(t[1].type===`listItemPrefix`){let i={type:`listItem`,_spread:!1,start:Object.assign({},t[1].start),end:void 0};o=i,e.splice(r,0,[`enter`,i,t[2]]),r++,n++,c=void 0,l=!0}}}return e[t][1]._spread=a,n}function a(e,t){return n;function n(n){s.call(this,e(n),n),t&&t.call(this,n)}}function o(){this.stack.push({type:`fragment`,children:[]})}function s(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:FZ(t.start),end:void 0}}function c(e){return t;function t(t){e&&e.call(this,t),l.call(this,t)}}function l(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||LZ).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+bX({start:e.start,end:e.end})+`): it’s not open`);n.position.end=FZ(e.end)}function u(){return zX(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(e){if(this.data.expectingFirstListItemValue){let t=this.stack[this.stack.length-2];t.start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function p(){let e=this.resume(),t=this.stack[this.stack.length-1];t.lang=e}function m(){let e=this.resume(),t=this.stack[this.stack.length-1];t.meta=e}function h(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``),this.data.flowCodeInside=void 0}function _(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/(\r?\n|\r)$/g,``)}function v(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=YX(this.sliceSerialize(e)).toLowerCase()}function y(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function b(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function x(e){let t=this.stack[this.stack.length-1];t.depth||=this.sliceSerialize(e).length}function S(){this.data.setextHeadingSlurpLineEnding=!0}function C(e){let t=this.stack[this.stack.length-1];t.depth=this.sliceSerialize(e).codePointAt(0)===61?1:2}function w(){this.data.setextHeadingSlurpLineEnding=void 0}function T(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];(!n||n.type!==`text`)&&(n=Ee(),n.position={start:FZ(e.start),end:void 0},t.push(n)),this.stack.push(n)}function E(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=FZ(e.end)}function D(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){let t=n.children[n.children.length-1];t.position.end=FZ(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(T.call(this,e),E.call(this,e))}function O(){this.data.atHardBreak=!0}function k(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function ee(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function te(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function ne(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function re(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function A(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=Jhe(t),n.identifier=YX(t).toLowerCase()}function ie(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,n.type===`link`?n.children=e.children:n.alt=t}function j(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function M(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function ae(){this.data.inReference=void 0}function oe(){this.data.referenceType=`collapsed`}function se(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=YX(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function N(e){this.data.characterReferenceType=e.type}function ce(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=JX(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=UX(t);let i=this.stack[this.stack.length-1];i.value+=r}function le(e){let t=this.stack.pop();t.position.end=FZ(e.end)}function ue(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function de(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function fe(){return{type:`blockquote`,children:[]}}function pe(){return{type:`code`,lang:null,meta:null,value:``}}function me(){return{type:`inlineCode`,value:``}}function he(){return{type:`definition`,identifier:``,label:null,title:null,url:``}}function ge(){return{type:`emphasis`,children:[]}}function _e(){return{type:`heading`,depth:0,children:[]}}function ve(){return{type:`break`}}function ye(){return{type:`html`,value:``}}function be(){return{type:`image`,title:null,url:``,alt:null}}function xe(){return{type:`link`,title:null,url:``,children:[]}}function Se(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[]}}function Ce(e){return{type:`listItem`,spread:e._spread,checked:null,children:[]}}function we(){return{type:`paragraph`,children:[]}}function Te(){return{type:`strong`,children:[]}}function Ee(){return{type:`text`,value:``}}function De(){return{type:`thematicBreak`}}}function FZ(e){return{line:e.line,column:e.column,offset:e.offset}}function IZ(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?IZ(e,r):Qhe(e,r)}}function Qhe(e,t){let n;for(n in t)if(PZ.call(t,n))switch(n){case`canContainEols`:{let r=t[n];r&&e[n].push(...r);break}case`transforms`:{let r=t[n];r&&e[n].push(...r);break}case`enter`:case`exit`:{let r=t[n];r&&Object.assign(e[n],r);break}}}function LZ(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+bX({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+bX({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+bX({start:t.start,end:t.end})+`) is still open`)}function $he(e){let t=this;t.parser=n;function n(n){return Xhe(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function ege(e,t){let n={type:`element`,tagName:`blockquote`,properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function tge(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
716
- `}]}function nge(e,t){let n=t.value?t.value+`
717
- `:``,r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=[`language-`+i[0]]);let a={type:`element`,tagName:`code`,properties:r,children:[{type:`text`,value:n}]};return t.meta&&(a.data={meta:t.meta}),e.patch(t,a),a=e.applyData(t,a),a={type:`element`,tagName:`pre`,properties:{},children:[a]},e.patch(t,a),a}function rge(e,t){let n={type:`element`,tagName:`del`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function ige(e,t){let n={type:`element`,tagName:`em`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function age(e,t){let n=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,r=String(t.identifier).toUpperCase(),i=aZ(r.toLowerCase()),a=e.footnoteOrder.indexOf(r),o,s=e.footnoteCounts.get(r);s===void 0?(s=0,e.footnoteOrder.push(r),o=e.footnoteOrder.length):o=a+1,s+=1,e.footnoteCounts.set(r,s);let c={type:`element`,tagName:`a`,properties:{href:`#`+n+`fn-`+i,id:n+`fnref-`+i+(s>1?`-`+s:``),dataFootnoteRef:!0,ariaDescribedBy:[`footnote-label`]},children:[{type:`text`,value:String(o)}]};e.patch(t,c);let l={type:`element`,tagName:`sup`,properties:{},children:[c]};return e.patch(t,l),e.applyData(t,l)}function oge(e,t){let n={type:`element`,tagName:`h`+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function sge(e,t){if(e.options.allowDangerousHtml){let n={type:`raw`,value:t.value};return e.patch(t,n),e.applyData(t,n)}}function RZ(e,t){let n=t.referenceType,r=`]`;if(n===`collapsed`?r+=`[]`:n===`full`&&(r+=`[`+(t.label||t.identifier)+`]`),t.type===`imageReference`)return[{type:`text`,value:`![`+t.alt+r}];let i=e.all(t),a=i[0];a&&a.type===`text`?a.value=`[`+a.value:i.unshift({type:`text`,value:`[`});let o=i[i.length-1];return o&&o.type===`text`?o.value+=r:i.push({type:`text`,value:r}),i}function cge(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return RZ(e,t);let i={src:aZ(r.url||``),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`img`,properties:i,children:[]};return e.patch(t,a),e.applyData(t,a)}function lge(e,t){let n={src:aZ(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`img`,properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function uge(e,t){let n={type:`text`,value:t.value.replace(/\r?\n|\r/g,` `)};e.patch(t,n);let r={type:`element`,tagName:`code`,properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function dge(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return RZ(e,t);let i={href:aZ(r.url||``)};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`a`,properties:i,children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}function fge(e,t){let n={href:aZ(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`a`,properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function pge(e,t,n){let r=e.all(t),i=n?mge(n):zZ(t),a={},o=[];if(typeof t.checked==`boolean`){let e=r[0],n;e&&e.type===`element`&&e.tagName===`p`?n=e:(n={type:`element`,tagName:`p`,properties:{},children:[]},r.unshift(n)),n.children.length>0&&n.children.unshift({type:`text`,value:` `}),n.children.unshift({type:`element`,tagName:`input`,properties:{type:`checkbox`,checked:t.checked,disabled:!0},children:[]}),a.className=[`task-list-item`]}let s=-1;for(;++s<r.length;){let e=r[s];(i||s!==0||e.type!==`element`||e.tagName!==`p`)&&o.push({type:`text`,value:`
715
+ `;break;case-2:o=t?` `:` `;break;case-1:if(!t&&i)continue;o=` `;break;default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(``)}function Ghe(e){let t={constructs:KX([Mhe,...(e||{}).extensions||[]]),content:n(ome),defined:[],document:n(cme),flow:n(Ehe),lazy:{},string:n(khe),text:n(Ahe)};return t;function n(e){return n;function n(n){return Hhe(t,e,n)}}}function Khe(e){for(;!yZ(e););return e}var MZ=/[\0\t\n\r]/g;function qhe(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){let s=[],c,l,u,d,f;for(i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i)),u=0,t=``,n&&=(i.charCodeAt(0)===65279&&u++,void 0);u<i.length;){if(MZ.lastIndex=u,c=MZ.exec(i),d=c&&c.index!==void 0?c.index:i.length,f=i.charCodeAt(d),!c){t=i.slice(u);break}if(f===10&&u===d&&r)s.push(-3),r=void 0;else switch(r&&=(s.push(-5),void 0),u<d&&(s.push(i.slice(u,d)),e+=d-u),f){case 0:s.push(65533),e++;break;case 9:for(l=Math.ceil(e/4)*4,s.push(-2);e++<l;)s.push(-1);break;case 10:s.push(-4),e=1;break;default:r=!0,e=1}u=d+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}var Jhe=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Yhe(e){return e.replace(Jhe,Xhe)}function Xhe(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return qX(n.slice(t?2:1),t?16:10)}return HX(n)||e}var NZ={}.hasOwnProperty;function Zhe(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),Qhe(n)(Khe(Ghe(n).document().write(qhe()(e,t,!0))))}function Qhe(e){let t={transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:a(xe),autolinkProtocol:T,autolinkEmail:T,atxHeading:a(_e),blockQuote:a(fe),characterEscape:T,characterReference:T,codeFenced:a(pe),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(pe,o),codeText:a(me,o),codeTextData:T,data:T,codeFlowValue:T,definition:a(he),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(ge),hardBreakEscape:a(ve),hardBreakTrailing:a(ve),htmlFlow:a(ye,o),htmlFlowData:T,htmlText:a(ye,o),htmlTextData:T,image:a(be),label:o,link:a(xe),listItem:a(Ce),listItemValue:f,listOrdered:a(Se,d),listUnordered:a(Se),paragraph:a(we),reference:oe,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(_e),strong:a(Te),thematicBreak:a(De)},exit:{atxHeading:c(),atxHeadingSequence:x,autolink:c(),autolinkEmail:de,autolinkProtocol:ue,blockQuote:c(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:N,characterReferenceMarkerNumeric:N,characterReferenceValue:ce,characterReference:le,codeFenced:c(g),codeFencedFence:h,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:E,codeIndented:c(_),codeText:c(te),codeTextData:E,data:E,definition:c(),definitionDestinationString:b,definitionLabelString:v,definitionTitleString:y,emphasis:c(),hardBreakEscape:c(O),hardBreakTrailing:c(O),htmlFlow:c(k),htmlFlowData:E,htmlText:c(ee),htmlTextData:E,image:c(re),label:ie,labelText:A,lineEnding:D,link:c(ne),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:se,resourceDestinationString:j,resourceTitleString:M,resource:ae,setextHeading:c(w),setextHeadingLineSequence:C,setextHeadingText:S,strong:c(),thematicBreak:c()}};FZ(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(e){let r={type:`root`,children:[]},a={stack:[r],tokenStack:[],config:t,enter:s,exit:l,buffer:o,resume:u,data:n},c=[],d=-1;for(;++d<e.length;)(e[d][1].type===`listOrdered`||e[d][1].type===`listUnordered`)&&(e[d][0]===`enter`?c.push(d):d=i(e,c.pop(),d));for(d=-1;++d<e.length;){let n=t[e[d][0]];NZ.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},a),e[d][1])}if(a.tokenStack.length>0){let e=a.tokenStack[a.tokenStack.length-1];(e[1]||IZ).call(a,void 0,e[0])}for(r.position={start:PZ(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:PZ(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)r=t.transforms[d](r)||r;return r}function i(e,t,n){let r=t-1,i=-1,a=!1,o,s,c,l;for(;++r<=n;){let t=e[r];switch(t[1].type){case`listUnordered`:case`listOrdered`:case`blockQuote`:t[0]===`enter`?i++:i--,l=void 0;break;case`lineEndingBlank`:t[0]===`enter`&&(o&&!l&&!i&&!c&&(c=r),l=void 0);break;case`linePrefix`:case`listItemValue`:case`listItemMarker`:case`listItemPrefix`:case`listItemPrefixWhitespace`:break;default:l=void 0}if(!i&&t[0]===`enter`&&t[1].type===`listItemPrefix`||i===-1&&t[0]===`exit`&&(t[1].type===`listUnordered`||t[1].type===`listOrdered`)){if(o){let i=r;for(s=void 0;i--;){let t=e[i];if(t[1].type===`lineEnding`||t[1].type===`lineEndingBlank`){if(t[0]===`exit`)continue;s&&(e[s][1].type=`lineEndingBlank`,a=!0),t[1].type=`lineEnding`,s=i}else if(!(t[1].type===`linePrefix`||t[1].type===`blockQuotePrefix`||t[1].type===`blockQuotePrefixWhitespace`||t[1].type===`blockQuoteMarker`||t[1].type===`listItemIndent`))break}c&&(!s||c<s)&&(o._spread=!0),o.end=Object.assign({},s?e[s][1].start:t[1].end),e.splice(s||r,0,[`exit`,o,t[2]]),r++,n++}if(t[1].type===`listItemPrefix`){let i={type:`listItem`,_spread:!1,start:Object.assign({},t[1].start),end:void 0};o=i,e.splice(r,0,[`enter`,i,t[2]]),r++,n++,c=void 0,l=!0}}}return e[t][1]._spread=a,n}function a(e,t){return n;function n(n){s.call(this,e(n),n),t&&t.call(this,n)}}function o(){this.stack.push({type:`fragment`,children:[]})}function s(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:PZ(t.start),end:void 0}}function c(e){return t;function t(t){e&&e.call(this,t),l.call(this,t)}}function l(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||IZ).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+yX({start:e.start,end:e.end})+`): it’s not open`);n.position.end=PZ(e.end)}function u(){return RX(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(e){if(this.data.expectingFirstListItemValue){let t=this.stack[this.stack.length-2];t.start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function p(){let e=this.resume(),t=this.stack[this.stack.length-1];t.lang=e}function m(){let e=this.resume(),t=this.stack[this.stack.length-1];t.meta=e}function h(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``),this.data.flowCodeInside=void 0}function _(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/(\r?\n|\r)$/g,``)}function v(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=JX(this.sliceSerialize(e)).toLowerCase()}function y(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function b(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function x(e){let t=this.stack[this.stack.length-1];t.depth||=this.sliceSerialize(e).length}function S(){this.data.setextHeadingSlurpLineEnding=!0}function C(e){let t=this.stack[this.stack.length-1];t.depth=this.sliceSerialize(e).codePointAt(0)===61?1:2}function w(){this.data.setextHeadingSlurpLineEnding=void 0}function T(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];(!n||n.type!==`text`)&&(n=Ee(),n.position={start:PZ(e.start),end:void 0},t.push(n)),this.stack.push(n)}function E(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=PZ(e.end)}function D(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){let t=n.children[n.children.length-1];t.position.end=PZ(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(T.call(this,e),E.call(this,e))}function O(){this.data.atHardBreak=!0}function k(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function ee(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function te(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function ne(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function re(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function A(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=Yhe(t),n.identifier=JX(t).toLowerCase()}function ie(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,n.type===`link`?n.children=e.children:n.alt=t}function j(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function M(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function ae(){this.data.inReference=void 0}function oe(){this.data.referenceType=`collapsed`}function se(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=JX(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function N(e){this.data.characterReferenceType=e.type}function ce(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=qX(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=HX(t);let i=this.stack[this.stack.length-1];i.value+=r}function le(e){let t=this.stack.pop();t.position.end=PZ(e.end)}function ue(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function de(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function fe(){return{type:`blockquote`,children:[]}}function pe(){return{type:`code`,lang:null,meta:null,value:``}}function me(){return{type:`inlineCode`,value:``}}function he(){return{type:`definition`,identifier:``,label:null,title:null,url:``}}function ge(){return{type:`emphasis`,children:[]}}function _e(){return{type:`heading`,depth:0,children:[]}}function ve(){return{type:`break`}}function ye(){return{type:`html`,value:``}}function be(){return{type:`image`,title:null,url:``,alt:null}}function xe(){return{type:`link`,title:null,url:``,children:[]}}function Se(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[]}}function Ce(e){return{type:`listItem`,spread:e._spread,checked:null,children:[]}}function we(){return{type:`paragraph`,children:[]}}function Te(){return{type:`strong`,children:[]}}function Ee(){return{type:`text`,value:``}}function De(){return{type:`thematicBreak`}}}function PZ(e){return{line:e.line,column:e.column,offset:e.offset}}function FZ(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?FZ(e,r):$he(e,r)}}function $he(e,t){let n;for(n in t)if(NZ.call(t,n))switch(n){case`canContainEols`:{let r=t[n];r&&e[n].push(...r);break}case`transforms`:{let r=t[n];r&&e[n].push(...r);break}case`enter`:case`exit`:{let r=t[n];r&&Object.assign(e[n],r);break}}}function IZ(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+yX({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+yX({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+yX({start:t.start,end:t.end})+`) is still open`)}function ege(e){let t=this;t.parser=n;function n(n){return Zhe(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function tge(e,t){let n={type:`element`,tagName:`blockquote`,properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function nge(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
716
+ `}]}function rge(e,t){let n=t.value?t.value+`
717
+ `:``,r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=[`language-`+i[0]]);let a={type:`element`,tagName:`code`,properties:r,children:[{type:`text`,value:n}]};return t.meta&&(a.data={meta:t.meta}),e.patch(t,a),a=e.applyData(t,a),a={type:`element`,tagName:`pre`,properties:{},children:[a]},e.patch(t,a),a}function ige(e,t){let n={type:`element`,tagName:`del`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function age(e,t){let n={type:`element`,tagName:`em`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function oge(e,t){let n=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,r=String(t.identifier).toUpperCase(),i=iZ(r.toLowerCase()),a=e.footnoteOrder.indexOf(r),o,s=e.footnoteCounts.get(r);s===void 0?(s=0,e.footnoteOrder.push(r),o=e.footnoteOrder.length):o=a+1,s+=1,e.footnoteCounts.set(r,s);let c={type:`element`,tagName:`a`,properties:{href:`#`+n+`fn-`+i,id:n+`fnref-`+i+(s>1?`-`+s:``),dataFootnoteRef:!0,ariaDescribedBy:[`footnote-label`]},children:[{type:`text`,value:String(o)}]};e.patch(t,c);let l={type:`element`,tagName:`sup`,properties:{},children:[c]};return e.patch(t,l),e.applyData(t,l)}function sge(e,t){let n={type:`element`,tagName:`h`+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function cge(e,t){if(e.options.allowDangerousHtml){let n={type:`raw`,value:t.value};return e.patch(t,n),e.applyData(t,n)}}function LZ(e,t){let n=t.referenceType,r=`]`;if(n===`collapsed`?r+=`[]`:n===`full`&&(r+=`[`+(t.label||t.identifier)+`]`),t.type===`imageReference`)return[{type:`text`,value:`![`+t.alt+r}];let i=e.all(t),a=i[0];a&&a.type===`text`?a.value=`[`+a.value:i.unshift({type:`text`,value:`[`});let o=i[i.length-1];return o&&o.type===`text`?o.value+=r:i.push({type:`text`,value:r}),i}function lge(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return LZ(e,t);let i={src:iZ(r.url||``),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`img`,properties:i,children:[]};return e.patch(t,a),e.applyData(t,a)}function uge(e,t){let n={src:iZ(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`img`,properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function dge(e,t){let n={type:`text`,value:t.value.replace(/\r?\n|\r/g,` `)};e.patch(t,n);let r={type:`element`,tagName:`code`,properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function fge(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return LZ(e,t);let i={href:iZ(r.url||``)};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`a`,properties:i,children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}function pge(e,t){let n={href:iZ(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`a`,properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function mge(e,t,n){let r=e.all(t),i=n?hge(n):RZ(t),a={},o=[];if(typeof t.checked==`boolean`){let e=r[0],n;e&&e.type===`element`&&e.tagName===`p`?n=e:(n={type:`element`,tagName:`p`,properties:{},children:[]},r.unshift(n)),n.children.length>0&&n.children.unshift({type:`text`,value:` `}),n.children.unshift({type:`element`,tagName:`input`,properties:{type:`checkbox`,checked:t.checked,disabled:!0},children:[]}),a.className=[`task-list-item`]}let s=-1;for(;++s<r.length;){let e=r[s];(i||s!==0||e.type!==`element`||e.tagName!==`p`)&&o.push({type:`text`,value:`
718
718
  `}),e.type===`element`&&e.tagName===`p`&&!i?o.push(...e.children):o.push(e)}let c=r[r.length-1];c&&(i||c.type!==`element`||c.tagName!==`p`)&&o.push({type:`text`,value:`
719
- `});let l={type:`element`,tagName:`li`,properties:a,children:o};return e.patch(t,l),e.applyData(t,l)}function mge(e){let t=!1;if(e.type===`list`){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=zZ(n[r])}return t}function zZ(e){return e.spread??e.children.length>1}function hge(e,t){let n={},r=e.all(t),i=-1;for(typeof t.start==`number`&&t.start!==1&&(n.start=t.start);++i<r.length;){let e=r[i];if(e.type===`element`&&e.tagName===`li`&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes(`task-list-item`)){n.className=[`contains-task-list`];break}}let a={type:`element`,tagName:t.ordered?`ol`:`ul`,properties:n,children:e.wrap(r,!0)};return e.patch(t,a),e.applyData(t,a)}function gge(e,t){let n={type:`element`,tagName:`p`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function _ge(e,t){let n={type:`root`,children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function vge(e,t){let n={type:`element`,tagName:`strong`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function yge(e,t){let n=e.all(t),r=n.shift(),i=[];if(r){let n={type:`element`,tagName:`thead`,properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],n),i.push(n)}if(n.length>0){let r={type:`element`,tagName:`tbody`,properties:{},children:e.wrap(n,!0)},a=_X(t.children[1]),o=gX(t.children[t.children.length-1]);a&&o&&(r.position={start:a,end:o}),i.push(r)}let a={type:`element`,tagName:`table`,properties:{},children:e.wrap(i,!0)};return e.patch(t,a),e.applyData(t,a)}function bge(e,t,n){let r=n?n.children:void 0,i=(r?r.indexOf(t):1)===0?`th`:`td`,a=n&&n.type===`table`?n.align:void 0,o=a?a.length:t.children.length,s=-1,c=[];for(;++s<o;){let n=t.children[s],r={},o=a?a[s]:void 0;o&&(r.align=o);let l={type:`element`,tagName:i,properties:r,children:[]};n&&(l.children=e.all(n),e.patch(n,l),l=e.applyData(n,l)),c.push(l)}let l={type:`element`,tagName:`tr`,properties:{},children:e.wrap(c,!0)};return e.patch(t,l),e.applyData(t,l)}function xge(e,t){let n={type:`element`,tagName:`td`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}var BZ=9,VZ=32;function Sge(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),i=0,a=[];for(;r;)a.push(HZ(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return a.push(HZ(t.slice(i),i>0,!1)),a.join(``)}function HZ(e,t,n){let r=0,i=e.length;if(t){let t=e.codePointAt(r);for(;t===BZ||t===VZ;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(i-1);for(;t===BZ||t===VZ;)i--,t=e.codePointAt(i-1)}return i>r?e.slice(r,i):``}function Cge(e,t){let n={type:`text`,value:Sge(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function wge(e,t){let n={type:`element`,tagName:`hr`,properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}var Tge={blockquote:ege,break:tge,code:nge,delete:rge,emphasis:ige,footnoteReference:age,heading:oge,html:sge,imageReference:cge,image:lge,inlineCode:uge,linkReference:dge,link:fge,listItem:pge,list:hge,paragraph:gge,root:_ge,strong:vge,table:yge,tableCell:xge,tableRow:bge,text:Cge,thematicBreak:wge,toml:UZ,yaml:UZ,definition:UZ,footnoteDefinition:UZ};function UZ(){}var Ege=typeof self==`object`?self:globalThis,WZ=(e,t)=>{switch(e){case`Function`:case`SharedWorker`:case`Worker`:case`eval`:case`setInterval`:case`setTimeout`:throw TypeError(`unable to deserialize `+e)}return new Ege[e](t)},Dge=(e,t)=>{let n=(t,n)=>(e.set(n,t),t),r=i=>{if(e.has(i))return e.get(i);let[a,o]=t[i];switch(a){case 0:case-1:return n(o,i);case 1:{let e=n([],i);for(let t of o)e.push(r(t));return e}case 2:{let e=n({},i);for(let[t,n]of o)e[r(t)]=r(n);return e}case 3:return n(new Date(o),i);case 4:{let{source:e,flags:t}=o;return n(new RegExp(e,t),i)}case 5:{let e=n(new Map,i);for(let[t,n]of o)e.set(r(t),r(n));return e}case 6:{let e=n(new Set,i);for(let t of o)e.add(r(t));return e}case 7:{let{name:e,message:t}=o;return n(WZ(e,t),i)}case 8:return n(BigInt(o),i);case`BigInt`:return n(Object(BigInt(o)),i);case`ArrayBuffer`:return n(new Uint8Array(o).buffer,o);case`DataView`:{let{buffer:e}=new Uint8Array(o);return n(new DataView(e),o)}}return n(WZ(a,o),i)};return r},GZ=e=>Dge(new Map,e)(0),KZ=``,{toString:Oge}={},{keys:kge}=Object,qZ=e=>{let t=typeof e;if(t!==`object`||!e)return[0,t];let n=Oge.call(e).slice(8,-1);switch(n){case`Array`:return[1,KZ];case`Object`:return[2,KZ];case`Date`:return[3,KZ];case`RegExp`:return[4,KZ];case`Map`:return[5,KZ];case`Set`:return[6,KZ];case`DataView`:return[1,n]}return n.includes(`Array`)?[1,n]:n.includes(`Error`)?[7,n]:[2,n]},JZ=([e,t])=>e===0&&(t===`function`||t===`symbol`),Age=(e,t,n,r)=>{let i=(e,t)=>{let i=r.push(e)-1;return n.set(t,i),i},a=r=>{if(n.has(r))return n.get(r);let[o,s]=qZ(r);switch(o){case 0:{let t=r;switch(s){case`bigint`:o=8,t=r.toString();break;case`function`:case`symbol`:if(e)throw TypeError(`unable to serialize `+s);t=null;break;case`undefined`:return i([-1],r)}return i([o,t],r)}case 1:{if(s){let e=r;return s===`DataView`?e=new Uint8Array(r.buffer):s===`ArrayBuffer`&&(e=new Uint8Array(r)),i([s,[...e]],r)}let e=[],t=i([o,e],r);for(let t of r)e.push(a(t));return t}case 2:{if(s)switch(s){case`BigInt`:return i([s,r.toString()],r);case`Boolean`:case`Number`:case`String`:return i([s,r.valueOf()],r)}if(t&&`toJSON`in r)return a(r.toJSON());let n=[],c=i([o,n],r);for(let t of kge(r))(e||!JZ(qZ(r[t])))&&n.push([a(t),a(r[t])]);return c}case 3:return i([o,r.toISOString()],r);case 4:{let{source:e,flags:t}=r;return i([o,{source:e,flags:t}],r)}case 5:{let t=[],n=i([o,t],r);for(let[n,i]of r)(e||!(JZ(qZ(n))||JZ(qZ(i))))&&t.push([a(n),a(i)]);return n}case 6:{let t=[],n=i([o,t],r);for(let n of r)(e||!JZ(qZ(n)))&&t.push(a(n));return n}}let{message:c}=r;return i([o,{name:s,message:c}],r)};return a},YZ=(e,{json:t,lossy:n}={})=>{let r=[];return Age(!(t||n),!!t,new Map,r)(e),r},XZ=typeof structuredClone==`function`?(e,t)=>t&&(`json`in t||`lossy`in t)?GZ(YZ(e,t)):structuredClone(e):(e,t)=>GZ(YZ(e,t));function jge(e,t){let n=[{type:`text`,value:`↩`}];return t>1&&n.push({type:`element`,tagName:`sup`,properties:{},children:[{type:`text`,value:String(t)}]}),n}function Mge(e,t){return`Back to reference `+(e+1)+(t>1?`-`+t:``)}function Nge(e){let t=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,n=e.options.footnoteBackContent||jge,r=e.options.footnoteBackLabel||Mge,i=e.options.footnoteLabel||`Footnotes`,a=e.options.footnoteLabelTagName||`h2`,o=e.options.footnoteLabelProperties||{className:[`sr-only`]},s=[],c=-1;for(;++c<e.footnoteOrder.length;){let i=e.footnoteById.get(e.footnoteOrder[c]);if(!i)continue;let a=e.all(i),o=String(i.identifier).toUpperCase(),l=aZ(o.toLowerCase()),u=0,d=[],f=e.footnoteCounts.get(o);for(;f!==void 0&&++u<=f;){d.length>0&&d.push({type:`text`,value:` `});let e=typeof n==`string`?n:n(c,u);typeof e==`string`&&(e={type:`text`,value:e}),d.push({type:`element`,tagName:`a`,properties:{href:`#`+t+`fnref-`+l+(u>1?`-`+u:``),dataFootnoteBackref:``,ariaLabel:typeof r==`string`?r:r(c,u),className:[`data-footnote-backref`]},children:Array.isArray(e)?e:[e]})}let p=a[a.length-1];if(p&&p.type===`element`&&p.tagName===`p`){let e=p.children[p.children.length-1];e&&e.type===`text`?e.value+=` `:p.children.push({type:`text`,value:` `}),p.children.push(...d)}else a.push(...d);let m={type:`element`,tagName:`li`,properties:{id:t+`fn-`+l},children:e.wrap(a,!0)};e.patch(i,m),s.push(m)}if(s.length!==0)return{type:`element`,tagName:`section`,properties:{dataFootnotes:!0,className:[`footnotes`]},children:[{type:`element`,tagName:a,properties:{...XZ(o),id:`footnote-label`},children:[{type:`text`,value:i}]},{type:`text`,value:`
719
+ `});let l={type:`element`,tagName:`li`,properties:a,children:o};return e.patch(t,l),e.applyData(t,l)}function hge(e){let t=!1;if(e.type===`list`){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=RZ(n[r])}return t}function RZ(e){return e.spread??e.children.length>1}function gge(e,t){let n={},r=e.all(t),i=-1;for(typeof t.start==`number`&&t.start!==1&&(n.start=t.start);++i<r.length;){let e=r[i];if(e.type===`element`&&e.tagName===`li`&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes(`task-list-item`)){n.className=[`contains-task-list`];break}}let a={type:`element`,tagName:t.ordered?`ol`:`ul`,properties:n,children:e.wrap(r,!0)};return e.patch(t,a),e.applyData(t,a)}function _ge(e,t){let n={type:`element`,tagName:`p`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function vge(e,t){let n={type:`root`,children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function yge(e,t){let n={type:`element`,tagName:`strong`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function bge(e,t){let n=e.all(t),r=n.shift(),i=[];if(r){let n={type:`element`,tagName:`thead`,properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],n),i.push(n)}if(n.length>0){let r={type:`element`,tagName:`tbody`,properties:{},children:e.wrap(n,!0)},a=gX(t.children[1]),o=hX(t.children[t.children.length-1]);a&&o&&(r.position={start:a,end:o}),i.push(r)}let a={type:`element`,tagName:`table`,properties:{},children:e.wrap(i,!0)};return e.patch(t,a),e.applyData(t,a)}function xge(e,t,n){let r=n?n.children:void 0,i=(r?r.indexOf(t):1)===0?`th`:`td`,a=n&&n.type===`table`?n.align:void 0,o=a?a.length:t.children.length,s=-1,c=[];for(;++s<o;){let n=t.children[s],r={},o=a?a[s]:void 0;o&&(r.align=o);let l={type:`element`,tagName:i,properties:r,children:[]};n&&(l.children=e.all(n),e.patch(n,l),l=e.applyData(n,l)),c.push(l)}let l={type:`element`,tagName:`tr`,properties:{},children:e.wrap(c,!0)};return e.patch(t,l),e.applyData(t,l)}function Sge(e,t){let n={type:`element`,tagName:`td`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}var zZ=9,BZ=32;function Cge(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),i=0,a=[];for(;r;)a.push(VZ(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return a.push(VZ(t.slice(i),i>0,!1)),a.join(``)}function VZ(e,t,n){let r=0,i=e.length;if(t){let t=e.codePointAt(r);for(;t===zZ||t===BZ;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(i-1);for(;t===zZ||t===BZ;)i--,t=e.codePointAt(i-1)}return i>r?e.slice(r,i):``}function wge(e,t){let n={type:`text`,value:Cge(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function Tge(e,t){let n={type:`element`,tagName:`hr`,properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}var Ege={blockquote:tge,break:nge,code:rge,delete:ige,emphasis:age,footnoteReference:oge,heading:sge,html:cge,imageReference:lge,image:uge,inlineCode:dge,linkReference:fge,link:pge,listItem:mge,list:gge,paragraph:_ge,root:vge,strong:yge,table:bge,tableCell:Sge,tableRow:xge,text:wge,thematicBreak:Tge,toml:HZ,yaml:HZ,definition:HZ,footnoteDefinition:HZ};function HZ(){}var Dge=typeof self==`object`?self:globalThis,UZ=(e,t)=>{switch(e){case`Function`:case`SharedWorker`:case`Worker`:case`eval`:case`setInterval`:case`setTimeout`:throw TypeError(`unable to deserialize `+e)}return new Dge[e](t)},Oge=(e,t)=>{let n=(t,n)=>(e.set(n,t),t),r=i=>{if(e.has(i))return e.get(i);let[a,o]=t[i];switch(a){case 0:case-1:return n(o,i);case 1:{let e=n([],i);for(let t of o)e.push(r(t));return e}case 2:{let e=n({},i);for(let[t,n]of o)e[r(t)]=r(n);return e}case 3:return n(new Date(o),i);case 4:{let{source:e,flags:t}=o;return n(new RegExp(e,t),i)}case 5:{let e=n(new Map,i);for(let[t,n]of o)e.set(r(t),r(n));return e}case 6:{let e=n(new Set,i);for(let t of o)e.add(r(t));return e}case 7:{let{name:e,message:t}=o;return n(UZ(e,t),i)}case 8:return n(BigInt(o),i);case`BigInt`:return n(Object(BigInt(o)),i);case`ArrayBuffer`:return n(new Uint8Array(o).buffer,o);case`DataView`:{let{buffer:e}=new Uint8Array(o);return n(new DataView(e),o)}}return n(UZ(a,o),i)};return r},WZ=e=>Oge(new Map,e)(0),GZ=``,{toString:kge}={},{keys:Age}=Object,KZ=e=>{let t=typeof e;if(t!==`object`||!e)return[0,t];let n=kge.call(e).slice(8,-1);switch(n){case`Array`:return[1,GZ];case`Object`:return[2,GZ];case`Date`:return[3,GZ];case`RegExp`:return[4,GZ];case`Map`:return[5,GZ];case`Set`:return[6,GZ];case`DataView`:return[1,n]}return n.includes(`Array`)?[1,n]:n.includes(`Error`)?[7,n]:[2,n]},qZ=([e,t])=>e===0&&(t===`function`||t===`symbol`),jge=(e,t,n,r)=>{let i=(e,t)=>{let i=r.push(e)-1;return n.set(t,i),i},a=r=>{if(n.has(r))return n.get(r);let[o,s]=KZ(r);switch(o){case 0:{let t=r;switch(s){case`bigint`:o=8,t=r.toString();break;case`function`:case`symbol`:if(e)throw TypeError(`unable to serialize `+s);t=null;break;case`undefined`:return i([-1],r)}return i([o,t],r)}case 1:{if(s){let e=r;return s===`DataView`?e=new Uint8Array(r.buffer):s===`ArrayBuffer`&&(e=new Uint8Array(r)),i([s,[...e]],r)}let e=[],t=i([o,e],r);for(let t of r)e.push(a(t));return t}case 2:{if(s)switch(s){case`BigInt`:return i([s,r.toString()],r);case`Boolean`:case`Number`:case`String`:return i([s,r.valueOf()],r)}if(t&&`toJSON`in r)return a(r.toJSON());let n=[],c=i([o,n],r);for(let t of Age(r))(e||!qZ(KZ(r[t])))&&n.push([a(t),a(r[t])]);return c}case 3:return i([o,r.toISOString()],r);case 4:{let{source:e,flags:t}=r;return i([o,{source:e,flags:t}],r)}case 5:{let t=[],n=i([o,t],r);for(let[n,i]of r)(e||!(qZ(KZ(n))||qZ(KZ(i))))&&t.push([a(n),a(i)]);return n}case 6:{let t=[],n=i([o,t],r);for(let n of r)(e||!qZ(KZ(n)))&&t.push(a(n));return n}}let{message:c}=r;return i([o,{name:s,message:c}],r)};return a},JZ=(e,{json:t,lossy:n}={})=>{let r=[];return jge(!(t||n),!!t,new Map,r)(e),r},YZ=typeof structuredClone==`function`?(e,t)=>t&&(`json`in t||`lossy`in t)?WZ(JZ(e,t)):structuredClone(e):(e,t)=>WZ(JZ(e,t));function Mge(e,t){let n=[{type:`text`,value:`↩`}];return t>1&&n.push({type:`element`,tagName:`sup`,properties:{},children:[{type:`text`,value:String(t)}]}),n}function Nge(e,t){return`Back to reference `+(e+1)+(t>1?`-`+t:``)}function Pge(e){let t=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,n=e.options.footnoteBackContent||Mge,r=e.options.footnoteBackLabel||Nge,i=e.options.footnoteLabel||`Footnotes`,a=e.options.footnoteLabelTagName||`h2`,o=e.options.footnoteLabelProperties||{className:[`sr-only`]},s=[],c=-1;for(;++c<e.footnoteOrder.length;){let i=e.footnoteById.get(e.footnoteOrder[c]);if(!i)continue;let a=e.all(i),o=String(i.identifier).toUpperCase(),l=iZ(o.toLowerCase()),u=0,d=[],f=e.footnoteCounts.get(o);for(;f!==void 0&&++u<=f;){d.length>0&&d.push({type:`text`,value:` `});let e=typeof n==`string`?n:n(c,u);typeof e==`string`&&(e={type:`text`,value:e}),d.push({type:`element`,tagName:`a`,properties:{href:`#`+t+`fnref-`+l+(u>1?`-`+u:``),dataFootnoteBackref:``,ariaLabel:typeof r==`string`?r:r(c,u),className:[`data-footnote-backref`]},children:Array.isArray(e)?e:[e]})}let p=a[a.length-1];if(p&&p.type===`element`&&p.tagName===`p`){let e=p.children[p.children.length-1];e&&e.type===`text`?e.value+=` `:p.children.push({type:`text`,value:` `}),p.children.push(...d)}else a.push(...d);let m={type:`element`,tagName:`li`,properties:{id:t+`fn-`+l},children:e.wrap(a,!0)};e.patch(i,m),s.push(m)}if(s.length!==0)return{type:`element`,tagName:`section`,properties:{dataFootnotes:!0,className:[`footnotes`]},children:[{type:`element`,tagName:a,properties:{...YZ(o),id:`footnote-label`},children:[{type:`text`,value:i}]},{type:`text`,value:`
720
720
  `},{type:`element`,tagName:`ol`,properties:{},children:e.wrap(s,!0)},{type:`text`,value:`
721
- `}]}}var ZZ=(function(e){if(e==null)return Lge;if(typeof e==`function`)return QZ(e);if(typeof e==`object`)return Array.isArray(e)?Pge(e):Fge(e);if(typeof e==`string`)return Ige(e);throw Error(`Expected function, string, or object as test`)});function Pge(e){let t=[],n=-1;for(;++n<e.length;)t[n]=ZZ(e[n]);return QZ(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function Fge(e){let t=e;return QZ(n);function n(n){let r=n,i;for(i in e)if(r[i]!==t[i])return!1;return!0}}function Ige(e){return QZ(t);function t(t){return t&&t.type===e}}function QZ(e){return t;function t(t,n,r){return!!(Rge(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function Lge(){return!0}function Rge(e){return typeof e==`object`&&!!e&&`type`in e}function zge(e){return e}var $Z=[];function eQ(e,t,n,r){let i;typeof t==`function`&&typeof n!=`function`?(r=n,n=t):i=t;let a=ZZ(i),o=r?-1:1;s(e,void 0,[])();function s(e,i,c){let l=e&&typeof e==`object`?e:{};if(typeof l.type==`string`){let t=typeof l.tagName==`string`?l.tagName:typeof l.name==`string`?l.name:void 0;Object.defineProperty(u,"name",{value:`node (`+zge(e.type+(t?`<`+t+`>`:``))+`)`})}return u;function u(){let l=$Z,u,d,f;if((!t||a(e,i,c[c.length-1]||void 0))&&(l=Bge(n(e,c)),l[0]===!1))return l;if(`children`in e&&e.children){let t=e;if(t.children&&l[0]!==`skip`)for(d=(r?t.children.length:-1)+o,f=c.concat(t);d>-1&&d<t.children.length;){let e=t.children[d];if(u=s(e,d,f)(),u[0]===!1)return u;d=typeof u[1]==`number`?u[1]:d+o}}return l}}}function Bge(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:e==null?$Z:[e]}function tQ(e,t,n,r){let i,a,o;typeof t==`function`&&typeof n!=`function`?(a=void 0,o=t,i=n):(a=t,o=n,i=r),eQ(e,a,s,i);function s(e,t){let n=t[t.length-1],r=n?n.children.indexOf(e):void 0;return o(e,r,n)}}var nQ={}.hasOwnProperty,Vge={};function Hge(e,t){let n=t||Vge,r=new Map,i=new Map,a={all:s,applyData:Wge,definitionById:r,footnoteById:i,footnoteCounts:new Map,footnoteOrder:[],handlers:{...Tge,...n.handlers},one:o,options:n,patch:Uge,wrap:Kge};return tQ(e,function(e){if(e.type===`definition`||e.type===`footnoteDefinition`){let t=e.type===`definition`?r:i,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}}),a;function o(e,t){let n=e.type,r=a.handlers[n];if(nQ.call(a.handlers,n)&&r)return r(a,e,t);if(a.options.passThrough&&a.options.passThrough.includes(n)){if(`children`in e){let{children:t,...n}=e,r=XZ(n);return r.children=a.all(e),r}return XZ(e)}return(a.options.unknownHandler||Gge)(a,e,t)}function s(e){let t=[];if(`children`in e){let n=e.children,r=-1;for(;++r<n.length;){let i=a.one(n[r],e);if(i){if(r&&n[r-1].type===`break`&&(!Array.isArray(i)&&i.type===`text`&&(i.value=rQ(i.value)),!Array.isArray(i)&&i.type===`element`)){let e=i.children[0];e&&e.type===`text`&&(e.value=rQ(e.value))}Array.isArray(i)?t.push(...i):t.push(i)}}}return t}}function Uge(e,t){e.position&&(t.position=yX(e))}function Wge(e,t){let n=t;if(e&&e.data){let t=e.data.hName,r=e.data.hChildren,i=e.data.hProperties;typeof t==`string`&&(n.type===`element`?n.tagName=t:n={type:`element`,tagName:t,properties:{},children:`children`in n?n.children:[n]}),n.type===`element`&&i&&Object.assign(n.properties,XZ(i)),`children`in n&&n.children&&r!=null&&(n.children=r)}return n}function Gge(e,t){let n=t.data||{},r=`value`in t&&!(nQ.call(n,`hProperties`)||nQ.call(n,`hChildren`))?{type:`text`,value:t.value}:{type:`element`,tagName:`div`,properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function Kge(e,t){let n=[],r=-1;for(t&&n.push({type:`text`,value:`
721
+ `}]}}var XZ=(function(e){if(e==null)return Rge;if(typeof e==`function`)return ZZ(e);if(typeof e==`object`)return Array.isArray(e)?Fge(e):Ige(e);if(typeof e==`string`)return Lge(e);throw Error(`Expected function, string, or object as test`)});function Fge(e){let t=[],n=-1;for(;++n<e.length;)t[n]=XZ(e[n]);return ZZ(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function Ige(e){let t=e;return ZZ(n);function n(n){let r=n,i;for(i in e)if(r[i]!==t[i])return!1;return!0}}function Lge(e){return ZZ(t);function t(t){return t&&t.type===e}}function ZZ(e){return t;function t(t,n,r){return!!(zge(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function Rge(){return!0}function zge(e){return typeof e==`object`&&!!e&&`type`in e}function Bge(e){return e}var QZ=[];function $Z(e,t,n,r){let i;typeof t==`function`&&typeof n!=`function`?(r=n,n=t):i=t;let a=XZ(i),o=r?-1:1;s(e,void 0,[])();function s(e,i,c){let l=e&&typeof e==`object`?e:{};if(typeof l.type==`string`){let t=typeof l.tagName==`string`?l.tagName:typeof l.name==`string`?l.name:void 0;Object.defineProperty(u,"name",{value:`node (`+Bge(e.type+(t?`<`+t+`>`:``))+`)`})}return u;function u(){let l=QZ,u,d,f;if((!t||a(e,i,c[c.length-1]||void 0))&&(l=Vge(n(e,c)),l[0]===!1))return l;if(`children`in e&&e.children){let t=e;if(t.children&&l[0]!==`skip`)for(d=(r?t.children.length:-1)+o,f=c.concat(t);d>-1&&d<t.children.length;){let e=t.children[d];if(u=s(e,d,f)(),u[0]===!1)return u;d=typeof u[1]==`number`?u[1]:d+o}}return l}}}function Vge(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:e==null?QZ:[e]}function eQ(e,t,n,r){let i,a,o;typeof t==`function`&&typeof n!=`function`?(a=void 0,o=t,i=n):(a=t,o=n,i=r),$Z(e,a,s,i);function s(e,t){let n=t[t.length-1],r=n?n.children.indexOf(e):void 0;return o(e,r,n)}}var tQ={}.hasOwnProperty,Hge={};function Uge(e,t){let n=t||Hge,r=new Map,i=new Map,a={all:s,applyData:Gge,definitionById:r,footnoteById:i,footnoteCounts:new Map,footnoteOrder:[],handlers:{...Ege,...n.handlers},one:o,options:n,patch:Wge,wrap:qge};return eQ(e,function(e){if(e.type===`definition`||e.type===`footnoteDefinition`){let t=e.type===`definition`?r:i,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}}),a;function o(e,t){let n=e.type,r=a.handlers[n];if(tQ.call(a.handlers,n)&&r)return r(a,e,t);if(a.options.passThrough&&a.options.passThrough.includes(n)){if(`children`in e){let{children:t,...n}=e,r=YZ(n);return r.children=a.all(e),r}return YZ(e)}return(a.options.unknownHandler||Kge)(a,e,t)}function s(e){let t=[];if(`children`in e){let n=e.children,r=-1;for(;++r<n.length;){let i=a.one(n[r],e);if(i){if(r&&n[r-1].type===`break`&&(!Array.isArray(i)&&i.type===`text`&&(i.value=nQ(i.value)),!Array.isArray(i)&&i.type===`element`)){let e=i.children[0];e&&e.type===`text`&&(e.value=nQ(e.value))}Array.isArray(i)?t.push(...i):t.push(i)}}}return t}}function Wge(e,t){e.position&&(t.position=vX(e))}function Gge(e,t){let n=t;if(e&&e.data){let t=e.data.hName,r=e.data.hChildren,i=e.data.hProperties;typeof t==`string`&&(n.type===`element`?n.tagName=t:n={type:`element`,tagName:t,properties:{},children:`children`in n?n.children:[n]}),n.type===`element`&&i&&Object.assign(n.properties,YZ(i)),`children`in n&&n.children&&r!=null&&(n.children=r)}return n}function Kge(e,t){let n=t.data||{},r=`value`in t&&!(tQ.call(n,`hProperties`)||tQ.call(n,`hChildren`))?{type:`text`,value:t.value}:{type:`element`,tagName:`div`,properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function qge(e,t){let n=[],r=-1;for(t&&n.push({type:`text`,value:`
722
722
  `});++r<e.length;)r&&n.push({type:`text`,value:`
723
723
  `}),n.push(e[r]);return t&&e.length>0&&n.push({type:`text`,value:`
724
- `}),n}function rQ(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function iQ(e,t){let n=Hge(e,t),r=n.one(e,void 0),i=Nge(n),a=Array.isArray(r)?{type:`root`,children:r}:r||{type:`root`,children:[]};return i&&(`children`in a,a.children.push({type:`text`,value:`
725
- `},i)),a}function qge(e,t){return e&&`run`in e?async function(n,r){let i=iQ(n,{file:r,...t});await e.run(i,r)}:function(n,r){return iQ(n,{file:r,...e||t})}}function aQ(e){if(e)throw e}var Jge=s(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=Object.prototype.toString,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=function(e){return typeof Array.isArray==`function`?Array.isArray(e):r.call(e)===`[object Array]`},s=function(e){if(!e||r.call(e)!==`[object Object]`)return!1;var t=n.call(e,`constructor`),i=e.constructor&&e.constructor.prototype&&n.call(e.constructor.prototype,`isPrototypeOf`);if(e.constructor&&!t&&!i)return!1;for(var a in e);return a===void 0||n.call(e,a)},c=function(e,t){i&&t.name===`__proto__`?i(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},l=function(e,t){if(t===`__proto__`){if(!n.call(e,t))return;if(a)return a(e,t).value}return e[t]};t.exports=function e(){var t,n,r,i,a,u,d=arguments[0],f=1,p=arguments.length,m=!1;for(typeof d==`boolean`&&(m=d,d=arguments[1]||{},f=2),(d==null||typeof d!=`object`&&typeof d!=`function`)&&(d={});f<p;++f)if(t=arguments[f],t!=null)for(n in t)r=l(d,n),i=l(t,n),d!==i&&(m&&i&&(s(i)||(a=o(i)))?(a?(a=!1,u=r&&o(r)?r:[]):u=r&&s(r)?r:{},c(d,{name:n,newValue:e(m,u,i)})):i!==void 0&&c(d,{name:n,newValue:i}));return d}}));function oQ(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function Yge(){let e=[],t={run:n,use:r};return t;function n(...t){let n=-1,r=t.pop();if(typeof r!=`function`)throw TypeError(`Expected function as last argument, not `+r);i(null,...t);function i(a,...o){let s=e[++n],c=-1;if(a){r(a);return}for(;++c<t.length;)(o[c]===null||o[c]===void 0)&&(o[c]=t[c]);t=o,s?Xge(s,i)(...o):r(null,...o)}}function r(n){if(typeof n!=`function`)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}}function Xge(e,t){let n;return r;function r(...t){let r=e.length>t.length,o;r&&t.push(i);try{o=e.apply(this,t)}catch(e){let t=e;if(r&&n)throw t;return i(t)}r||(o&&o.then&&typeof o.then==`function`?o.then(a,i):o instanceof Error?i(o):a(o))}function i(e,...r){n||(n=!0,t(e,...r))}function a(e){i(null,e)}}var sQ={basename:Zge,dirname:Qge,extname:$ge,join:e_e,sep:`/`};function Zge(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);cQ(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?``:e.slice(n,r)}if(t===e)return``;let o=-1,s=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),s>-1&&(e.codePointAt(i)===t.codePointAt(s--)?s<0&&(r=i):(s=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function Qge(e){if(cQ(e),e.length===0)return`.`;let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||=!0;return t<0?e.codePointAt(0)===47?`/`:`.`:t===1&&e.codePointAt(0)===47?`//`:e.slice(0,t)}function $ge(e){cQ(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){let s=e.codePointAt(t);if(s===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),s===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?``:e.slice(i,n)}function e_e(...e){let t=-1,n;for(;++t<e.length;)cQ(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:t_e(n)}function t_e(e){cQ(e);let t=e.codePointAt(0)===47,n=n_e(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function n_e(e,t){let n=``,r=0,i=-1,a=0,o=-1,s,c;for(;++o<=e.length;){if(o<e.length)s=e.codePointAt(o);else if(s===47)break;else s=47;if(s===47){if(!(i===o-1||a===1))if(i!==o-1&&a===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf(`/`),c!==n.length-1){c<0?(n=``,r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf(`/`)),i=o,a=0;continue}}else if(n.length>0){n=``,r=0,i=o,a=0;continue}}t&&(n=n.length>0?n+`/..`:`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1;i=o,a=0}else s===46&&a>-1?a++:a=-1}return n}function cQ(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var r_e={cwd:i_e};function i_e(){return`/`}function lQ(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function a_e(e){if(typeof e==`string`)e=new URL(e);else if(!lQ(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code=`ERR_INVALID_ARG_TYPE`,t}if(e.protocol!==`file:`){let e=TypeError(`The URL must be of scheme file`);throw e.code=`ERR_INVALID_URL_SCHEME`,e}return o_e(e)}function o_e(e){if(e.hostname!==``){let e=TypeError(`File URL host must be "localhost" or empty on darwin`);throw e.code=`ERR_INVALID_FILE_URL_HOST`,e}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let e=t.codePointAt(n+2);if(e===70||e===102){let e=TypeError(`File URL path must not include encoded / characters`);throw e.code=`ERR_INVALID_FILE_URL_PATH`,e}}return decodeURIComponent(t)}var uQ=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],dQ=class{constructor(e){let t;t=e?lQ(e)?{path:e}:typeof e==`string`||s_e(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:r_e.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<uQ.length;){let e=uQ[n];e in t&&t[e]!==void 0&&t[e]!==null&&(this[e]=e===`history`?[...t[e]]:t[e])}let r;for(r in t)uQ.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?sQ.basename(this.path):void 0}set basename(e){pQ(e,`basename`),fQ(e,`basename`),this.path=sQ.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?sQ.dirname(this.path):void 0}set dirname(e){mQ(this.basename,`dirname`),this.path=sQ.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?sQ.extname(this.path):void 0}set extname(e){if(fQ(e,`extname`),mQ(this.dirname,`extname`),e){if(e.codePointAt(0)!==46)throw Error("`extname` must start with `.`");if(e.includes(`.`,1))throw Error("`extname` cannot contain multiple dots")}this.path=sQ.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){lQ(e)&&(e=a_e(e)),pQ(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?sQ.basename(this.path,this.extname):void 0}set stem(e){pQ(e,`stem`),fQ(e,`stem`),this.path=sQ.join(this.dirname||``,e+(this.extname||``))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new wX(e,t,n);return this.path&&(r.name=this.path+`:`+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return this.value===void 0?``:typeof this.value==`string`?this.value:new TextDecoder(e||void 0).decode(this.value)}};function fQ(e,t){if(e&&e.includes(sQ.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+sQ.sep+"`")}function pQ(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function mQ(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function s_e(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var c_e=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),hQ=u(Jge(),1),l_e={}.hasOwnProperty,u_e=new class e extends c_e{constructor(){super(`copy`),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=Yge()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,hQ.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(vQ(`data`,this.frozen),this.namespace[e]=t,this):l_e.call(this.namespace,e)&&this.namespace[e]||void 0:e?(vQ(`data`,this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;let e=this;for(;++this.freezeIndex<this.attachers.length;){let[t,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);let r=t.call(e,...n);typeof r==`function`&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=xQ(e),n=this.parser||this.Parser;return gQ(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),gQ(`process`,this.parser||this.Parser),_Q(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=xQ(e),o=n.parse(a);n.run(o,a,function(e,t,r){if(e||!t||!r)return s(e);let i=t,a=n.stringify(i,r);f_e(a)?r.value=a:r.result=a,s(e,r)});function s(e,n){e||!n?i(e):r?r(n):t(void 0,n)}}}processSync(e){let t=!1,n;return this.freeze(),gQ(`processSync`,this.parser||this.Parser),_Q(`processSync`,this.compiler||this.Compiler),this.process(e,r),bQ(`processSync`,`process`,t),n;function r(e,r){t=!0,aQ(e),n=r}}run(e,t,n){yQ(e),this.freeze();let r=this.transformers;return!n&&typeof t==`function`&&(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,a){let o=xQ(t);r.run(e,o,s);function s(t,r,o){let s=r||e;t?a(t):i?i(s):n(void 0,s,o)}}}runSync(e,t){let n=!1,r;return this.run(e,t,i),bQ(`runSync`,`run`,n),r;function i(e,t){aQ(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=xQ(t),r=this.compiler||this.Compiler;return _Q(`stringify`,r),yQ(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(vQ(`use`,this.frozen),e!=null)if(typeof e==`function`)s(e,t);else if(typeof e==`object`)Array.isArray(e)?o(e):a(e);else throw TypeError("Expected usable value, not `"+e+"`");return this;function i(e){if(typeof e==`function`)s(e,[]);else if(typeof e==`object`)if(Array.isArray(e)){let[t,...n]=e;s(t,n)}else a(e);else throw TypeError("Expected usable value, not `"+e+"`")}function a(e){if(!(`plugins`in e)&&!(`settings`in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(e.plugins),e.settings&&(r.settings=(0,hQ.default)(!0,r.settings,e.settings))}function o(e){let t=-1;if(e!=null)if(Array.isArray(e))for(;++t<e.length;){let n=e[t];i(n)}else throw TypeError("Expected a list of plugins, not `"+e+"`")}function s(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(i===-1)n.push([e,...t]);else if(t.length>0){let[r,...a]=t,o=n[i][1];oQ(o)&&oQ(r)&&(r=(0,hQ.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function gQ(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function _Q(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function vQ(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function yQ(e){if(!oQ(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function bQ(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function xQ(e){return d_e(e)?e:new dQ(e)}function d_e(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function f_e(e){return typeof e==`string`||p_e(e)}function p_e(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var SQ=[],CQ={allowDangerousHtml:!0},m_e=/^(https?|ircs?|mailto|xmpp)$/i,h_e=[{from:`astPlugins`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowDangerousHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowNode`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowElement`},{from:`allowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowedElements`},{from:`className`,id:`remove-classname`},{from:`disallowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`disallowedElements`},{from:`escapeHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`includeElementIndex`,id:`#remove-includeelementindex`},{from:`includeNodeIndex`,id:`change-includenodeindex-to-includeelementindex`},{from:`linkTarget`,id:`remove-linktarget`},{from:`plugins`,id:`change-plugins-to-remarkplugins`,to:`remarkPlugins`},{from:`rawSourcePos`,id:`#remove-rawsourcepos`},{from:`renderers`,id:`change-renderers-to-components`,to:`components`},{from:`source`,id:`change-source-to-children`,to:`children`},{from:`sourcePos`,id:`#remove-sourcepos`},{from:`transformImageUri`,id:`#add-urltransform`,to:`urlTransform`},{from:`transformLinkUri`,id:`#add-urltransform`,to:`urlTransform`}];function g_e(e){let t=__e(e),n=v_e(e);return y_e(t.runSync(t.parse(n),n),e)}function __e(e){let t=e.rehypePlugins||SQ,n=e.remarkPlugins||SQ,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...CQ}:CQ;return u_e().use($he).use(n).use(qge,r).use(t)}function v_e(e){let t=e.children||``,n=new dQ;return typeof t==`string`?n.value=t:``+t,n}function y_e(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||b_e;for(let e of h_e)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return tQ(e,l),jX(e,{Fragment:F.Fragment,components:i,ignoreInvalidStyle:!0,jsx:F.jsx,jsxs:F.jsxs,passKeys:!0,passNode:!0});function l(e,t,i){if(e.type===`raw`&&i&&typeof t==`number`)return o?i.children.splice(t,1):i.children[t]={type:`text`,value:e.value},t;if(e.type===`element`){let t;for(t in RX)if(Object.hasOwn(RX,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=RX[t];(r===null||r.includes(e.tagName))&&(e.properties[t]=c(String(n||``),t,e))}}if(e.type===`element`){let o=n?!n.includes(e.tagName):a?a.includes(e.tagName):!1;if(!o&&r&&typeof t==`number`&&(o=!r(e,t,i)),o&&i&&typeof t==`number`)return s&&e.children?i.children.splice(t,1,...e.children):i.children.splice(t,1),t}}}function b_e(e){let t=e.indexOf(`:`),n=e.indexOf(`?`),r=e.indexOf(`#`),i=e.indexOf(`/`);return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||m_e.test(e.slice(0,t))?e:``}function wQ(e,t){let n=String(e);if(typeof t!=`string`)throw TypeError(`Expected character`);let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function x_e(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function S_e(e,t,n){let r=ZZ((n||{}).ignore||[]),i=C_e(t),a=-1;for(;++a<i.length;)eQ(e,`text`,o);function o(e,t){let n=-1,i;for(;++n<t.length;){let e=t[n],a=i?i.children:void 0;if(r(e,a?a.indexOf(e):void 0,i))return;i=e}if(i)return s(e,t)}function s(e,t){let n=t[t.length-1],r=i[a][0],o=i[a][1],s=0,c=n.children.indexOf(e),l=!1,u=[];r.lastIndex=0;let d=r.exec(e.value);for(;d;){let n=d.index,i={index:d.index,input:d.input,stack:[...t,e]},a=o(...d,i);if(typeof a==`string`&&(a=a.length>0?{type:`text`,value:a}:void 0),a===!1?r.lastIndex=n+1:(s!==n&&u.push({type:`text`,value:e.value.slice(s,n)}),Array.isArray(a)?u.push(...a):a&&u.push(a),s=n+d[0].length,l=!0),!r.global)break;d=r.exec(e.value)}return l?(s<e.value.length&&u.push({type:`text`,value:e.value.slice(s)}),n.children.splice(c,1,...u)):u=[e],c+u.length}}function C_e(e){let t=[];if(!Array.isArray(e))throw TypeError(`Expected find and replace tuple or list of tuples`);let n=!e[0]||Array.isArray(e[0])?e:[e],r=-1;for(;++r<n.length;){let e=n[r];t.push([w_e(e[0]),T_e(e[1])])}return t}function w_e(e){return typeof e==`string`?new RegExp(x_e(e),`g`):e}function T_e(e){return typeof e==`function`?e:function(){return e}}var TQ=`phrasing`,EQ=[`autolink`,`link`,`image`,`label`];function E_e(){return{transforms:[N_e],enter:{literalAutolink:O_e,literalAutolinkEmail:DQ,literalAutolinkHttp:DQ,literalAutolinkWww:DQ},exit:{literalAutolink:M_e,literalAutolinkEmail:j_e,literalAutolinkHttp:k_e,literalAutolinkWww:A_e}}}function D_e(){return{unsafe:[{character:`@`,before:`[+\\-.\\w]`,after:`[\\-.\\w]`,inConstruct:TQ,notInConstruct:EQ},{character:`.`,before:`[Ww]`,after:`[\\-.\\w]`,inConstruct:TQ,notInConstruct:EQ},{character:`:`,before:`[ps]`,after:`\\/`,inConstruct:TQ,notInConstruct:EQ}]}}function O_e(e){this.enter({type:`link`,title:null,url:``,children:[]},e)}function DQ(e){this.config.enter.autolinkProtocol.call(this,e)}function k_e(e){this.config.exit.autolinkProtocol.call(this,e)}function A_e(e){this.config.exit.data.call(this,e);let t=this.stack[this.stack.length-1];t.type,t.url=`http://`+this.sliceSerialize(e)}function j_e(e){this.config.exit.autolinkEmail.call(this,e)}function M_e(e){this.exit(e)}function N_e(e){S_e(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,P_e],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,F_e]],{ignore:[`link`,`linkReference`]})}function P_e(e,t,n,r,i){let a=``;if(!OQ(i)||(/^w/i.test(t)&&(n=t+n,t=``,a=`http://`),!I_e(n)))return!1;let o=L_e(n+r);if(!o[0])return!1;let s={type:`link`,title:null,url:a+t+o[0],children:[{type:`text`,value:t+o[0]}]};return o[1]?[s,{type:`text`,value:o[1]}]:s}function F_e(e,t,n,r){return!OQ(r,!0)||/[-\d_]$/.test(n)?!1:{type:`link`,title:null,url:`mailto:`+t+`@`+n,children:[{type:`text`,value:t+`@`+n}]}}function I_e(e){let t=e.split(`.`);return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function L_e(e){let t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(`)`),i=wQ(e,`(`),a=wQ(e,`)`);for(;r!==-1&&i>a;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(`)`),a++;return[e,n]}function OQ(e,t){let n=e.input.charCodeAt(e.index-1);return(e.index===0||rZ(n)||nZ(n))&&(!t||n!==47)}kQ.peek=K_e;function R_e(){this.buffer()}function z_e(e){this.enter({type:`footnoteReference`,identifier:``,label:``},e)}function B_e(){this.buffer()}function V_e(e){this.enter({type:`footnoteDefinition`,identifier:``,label:``,children:[]},e)}function H_e(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=YX(this.sliceSerialize(e)).toLowerCase(),n.label=t}function U_e(e){this.exit(e)}function W_e(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=YX(this.sliceSerialize(e)).toLowerCase(),n.label=t}function G_e(e){this.exit(e)}function K_e(){return`[`}function kQ(e,t,n,r){let i=n.createTracker(r),a=i.move(`[^`),o=n.enter(`footnoteReference`),s=n.enter(`reference`);return a+=i.move(n.safe(n.associationId(e),{after:`]`,before:a})),s(),o(),a+=i.move(`]`),a}function q_e(){return{enter:{gfmFootnoteCallString:R_e,gfmFootnoteCall:z_e,gfmFootnoteDefinitionLabelString:B_e,gfmFootnoteDefinition:V_e},exit:{gfmFootnoteCallString:H_e,gfmFootnoteCall:U_e,gfmFootnoteDefinitionLabelString:W_e,gfmFootnoteDefinition:G_e}}}function J_e(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:kQ},unsafe:[{character:`[`,inConstruct:[`label`,`phrasing`,`reference`]}]};function n(e,n,r,i){let a=r.createTracker(i),o=a.move(`[^`),s=r.enter(`footnoteDefinition`),c=r.enter(`label`);return o+=a.move(r.safe(r.associationId(e),{before:o,after:`]`})),c(),o+=a.move(`]:`),e.children&&e.children.length>0&&(a.shift(4),o+=a.move((t?`
726
- `:` `)+r.indentLines(r.containerFlow(e,a.current()),t?AQ:Y_e))),s(),o}}function Y_e(e,t,n){return t===0?e:AQ(e,t,n)}function AQ(e,t,n){return(n?``:` `)+e}var X_e=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`];jQ.peek=tve;function Z_e(){return{canContainEols:[`delete`],enter:{strikethrough:$_e},exit:{strikethrough:eve}}}function Q_e(){return{unsafe:[{character:`~`,inConstruct:`phrasing`,notInConstruct:X_e}],handlers:{delete:jQ}}}function $_e(e){this.enter({type:`delete`,children:[]},e)}function eve(e){this.exit(e)}function jQ(e,t,n,r){let i=n.createTracker(r),a=n.enter(`strikethrough`),o=i.move(`~~`);return o+=n.containerPhrasing(e,{...i.current(),before:o,after:`~`}),o+=i.move(`~~`),a(),o}function tve(){return`~`}function nve(e){return e.length}function rve(e,t){let n=t||{},r=(n.align||[]).concat(),i=n.stringLength||nve,a=[],o=[],s=[],c=[],l=0,u=-1;for(;++u<e.length;){let t=[],r=[],a=-1;for(e[u].length>l&&(l=e[u].length);++a<e[u].length;){let o=ive(e[u][a]);if(n.alignDelimiters!==!1){let e=i(o);r[a]=e,(c[a]===void 0||e>c[a])&&(c[a]=e)}t.push(o)}o[u]=t,s[u]=r}let d=-1;if(typeof r==`object`&&`length`in r)for(;++d<l;)a[d]=MQ(r[d]);else{let e=MQ(r);for(;++d<l;)a[d]=e}d=-1;let f=[],p=[];for(;++d<l;){let e=a[d],t=``,r=``;e===99?(t=`:`,r=`:`):e===108?t=`:`:e===114&&(r=`:`);let i=n.alignDelimiters===!1?1:Math.max(1,c[d]-t.length-r.length),o=t+`-`.repeat(i)+r;n.alignDelimiters!==!1&&(i=t.length+i+r.length,i>c[d]&&(c[d]=i),p[d]=i),f[d]=o}o.splice(1,0,f),s.splice(1,0,p),u=-1;let m=[];for(;++u<o.length;){let e=o[u],t=s[u];d=-1;let r=[];for(;++d<l;){let i=e[d]||``,o=``,s=``;if(n.alignDelimiters!==!1){let e=c[d]-(t[d]||0),n=a[d];n===114?o=` `.repeat(e):n===99?e%2?(o=` `.repeat(e/2+.5),s=` `.repeat(e/2-.5)):(o=` `.repeat(e/2),s=o):s=` `.repeat(e)}n.delimiterStart!==!1&&!d&&r.push(`|`),n.padding!==!1&&!(n.alignDelimiters===!1&&i===``)&&(n.delimiterStart!==!1||d)&&r.push(` `),n.alignDelimiters!==!1&&r.push(o),r.push(i),n.alignDelimiters!==!1&&r.push(s),n.padding!==!1&&r.push(` `),(n.delimiterEnd!==!1||d!==l-1)&&r.push(`|`)}m.push(n.delimiterEnd===!1?r.join(``).replace(/ +$/,``):r.join(``))}return m.join(`
727
- `)}function ive(e){return e==null?``:String(e)}function MQ(e){let t=typeof e==`string`?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function ave(e,t,n,r){let i=n.enter(`blockquote`),a=n.createTracker(r);a.move(`> `),a.shift(2);let o=n.indentLines(n.containerFlow(e,a.current()),ove);return i(),o}function ove(e,t,n){return`>`+(n?``:` `)+e}function sve(e,t){return NQ(e,t.inConstruct,!0)&&!NQ(e,t.notInConstruct,!1)}function NQ(e,t,n){if(typeof t==`string`&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function PQ(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
728
- `&&sve(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?``:` `;return`\\
729
- `}function cve(e,t){let n=String(e),r=n.indexOf(t),i=r,a=0,o=0;if(typeof t!=`string`)throw TypeError(`Expected substring`);for(;r!==-1;)r===i?++a>o&&(o=a):a=1,i=r+t.length,r=n.indexOf(t,i);return o}function lve(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function uve(e){let t=e.options.fence||"`";if(t!=="`"&&t!==`~`)throw Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function dve(e,t,n,r){let i=uve(n),a=e.value||``,o=i==="`"?`GraveAccent`:`Tilde`;if(lve(e,n)){let e=n.enter(`codeIndented`),t=n.indentLines(a,fve);return e(),t}let s=n.createTracker(r),c=i.repeat(Math.max(cve(a,i)+1,3)),l=n.enter(`codeFenced`),u=s.move(c);if(e.lang){let t=n.enter(`codeFencedLang${o}`);u+=s.move(n.safe(e.lang,{before:u,after:` `,encode:["`"],...s.current()})),t()}if(e.lang&&e.meta){let t=n.enter(`codeFencedMeta${o}`);u+=s.move(` `),u+=s.move(n.safe(e.meta,{before:u,after:`
724
+ `}),n}function nQ(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function rQ(e,t){let n=Uge(e,t),r=n.one(e,void 0),i=Pge(n),a=Array.isArray(r)?{type:`root`,children:r}:r||{type:`root`,children:[]};return i&&(`children`in a,a.children.push({type:`text`,value:`
725
+ `},i)),a}function Jge(e,t){return e&&`run`in e?async function(n,r){let i=rQ(n,{file:r,...t});await e.run(i,r)}:function(n,r){return rQ(n,{file:r,...e||t})}}function iQ(e){if(e)throw e}var Yge=s(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=Object.prototype.toString,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=function(e){return typeof Array.isArray==`function`?Array.isArray(e):r.call(e)===`[object Array]`},s=function(e){if(!e||r.call(e)!==`[object Object]`)return!1;var t=n.call(e,`constructor`),i=e.constructor&&e.constructor.prototype&&n.call(e.constructor.prototype,`isPrototypeOf`);if(e.constructor&&!t&&!i)return!1;for(var a in e);return a===void 0||n.call(e,a)},c=function(e,t){i&&t.name===`__proto__`?i(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},l=function(e,t){if(t===`__proto__`){if(!n.call(e,t))return;if(a)return a(e,t).value}return e[t]};t.exports=function e(){var t,n,r,i,a,u,d=arguments[0],f=1,p=arguments.length,m=!1;for(typeof d==`boolean`&&(m=d,d=arguments[1]||{},f=2),(d==null||typeof d!=`object`&&typeof d!=`function`)&&(d={});f<p;++f)if(t=arguments[f],t!=null)for(n in t)r=l(d,n),i=l(t,n),d!==i&&(m&&i&&(s(i)||(a=o(i)))?(a?(a=!1,u=r&&o(r)?r:[]):u=r&&s(r)?r:{},c(d,{name:n,newValue:e(m,u,i)})):i!==void 0&&c(d,{name:n,newValue:i}));return d}}));function aQ(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function Xge(){let e=[],t={run:n,use:r};return t;function n(...t){let n=-1,r=t.pop();if(typeof r!=`function`)throw TypeError(`Expected function as last argument, not `+r);i(null,...t);function i(a,...o){let s=e[++n],c=-1;if(a){r(a);return}for(;++c<t.length;)(o[c]===null||o[c]===void 0)&&(o[c]=t[c]);t=o,s?Zge(s,i)(...o):r(null,...o)}}function r(n){if(typeof n!=`function`)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}}function Zge(e,t){let n;return r;function r(...t){let r=e.length>t.length,o;r&&t.push(i);try{o=e.apply(this,t)}catch(e){let t=e;if(r&&n)throw t;return i(t)}r||(o&&o.then&&typeof o.then==`function`?o.then(a,i):o instanceof Error?i(o):a(o))}function i(e,...r){n||(n=!0,t(e,...r))}function a(e){i(null,e)}}var oQ={basename:Qge,dirname:$ge,extname:e_e,join:t_e,sep:`/`};function Qge(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);sQ(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?``:e.slice(n,r)}if(t===e)return``;let o=-1,s=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),s>-1&&(e.codePointAt(i)===t.codePointAt(s--)?s<0&&(r=i):(s=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function $ge(e){if(sQ(e),e.length===0)return`.`;let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||=!0;return t<0?e.codePointAt(0)===47?`/`:`.`:t===1&&e.codePointAt(0)===47?`//`:e.slice(0,t)}function e_e(e){sQ(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){let s=e.codePointAt(t);if(s===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),s===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?``:e.slice(i,n)}function t_e(...e){let t=-1,n;for(;++t<e.length;)sQ(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:n_e(n)}function n_e(e){sQ(e);let t=e.codePointAt(0)===47,n=r_e(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function r_e(e,t){let n=``,r=0,i=-1,a=0,o=-1,s,c;for(;++o<=e.length;){if(o<e.length)s=e.codePointAt(o);else if(s===47)break;else s=47;if(s===47){if(!(i===o-1||a===1))if(i!==o-1&&a===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf(`/`),c!==n.length-1){c<0?(n=``,r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf(`/`)),i=o,a=0;continue}}else if(n.length>0){n=``,r=0,i=o,a=0;continue}}t&&(n=n.length>0?n+`/..`:`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1;i=o,a=0}else s===46&&a>-1?a++:a=-1}return n}function sQ(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var i_e={cwd:a_e};function a_e(){return`/`}function cQ(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function o_e(e){if(typeof e==`string`)e=new URL(e);else if(!cQ(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code=`ERR_INVALID_ARG_TYPE`,t}if(e.protocol!==`file:`){let e=TypeError(`The URL must be of scheme file`);throw e.code=`ERR_INVALID_URL_SCHEME`,e}return s_e(e)}function s_e(e){if(e.hostname!==``){let e=TypeError(`File URL host must be "localhost" or empty on darwin`);throw e.code=`ERR_INVALID_FILE_URL_HOST`,e}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let e=t.codePointAt(n+2);if(e===70||e===102){let e=TypeError(`File URL path must not include encoded / characters`);throw e.code=`ERR_INVALID_FILE_URL_PATH`,e}}return decodeURIComponent(t)}var lQ=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],uQ=class{constructor(e){let t;t=e?cQ(e)?{path:e}:typeof e==`string`||c_e(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:i_e.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<lQ.length;){let e=lQ[n];e in t&&t[e]!==void 0&&t[e]!==null&&(this[e]=e===`history`?[...t[e]]:t[e])}let r;for(r in t)lQ.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?oQ.basename(this.path):void 0}set basename(e){fQ(e,`basename`),dQ(e,`basename`),this.path=oQ.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?oQ.dirname(this.path):void 0}set dirname(e){pQ(this.basename,`dirname`),this.path=oQ.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?oQ.extname(this.path):void 0}set extname(e){if(dQ(e,`extname`),pQ(this.dirname,`extname`),e){if(e.codePointAt(0)!==46)throw Error("`extname` must start with `.`");if(e.includes(`.`,1))throw Error("`extname` cannot contain multiple dots")}this.path=oQ.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){cQ(e)&&(e=o_e(e)),fQ(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?oQ.basename(this.path,this.extname):void 0}set stem(e){fQ(e,`stem`),dQ(e,`stem`),this.path=oQ.join(this.dirname||``,e+(this.extname||``))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new CX(e,t,n);return this.path&&(r.name=this.path+`:`+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return this.value===void 0?``:typeof this.value==`string`?this.value:new TextDecoder(e||void 0).decode(this.value)}};function dQ(e,t){if(e&&e.includes(oQ.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+oQ.sep+"`")}function fQ(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function pQ(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function c_e(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var l_e=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),mQ=u(Yge(),1),u_e={}.hasOwnProperty,d_e=new class e extends l_e{constructor(){super(`copy`),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=Xge()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,mQ.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(_Q(`data`,this.frozen),this.namespace[e]=t,this):u_e.call(this.namespace,e)&&this.namespace[e]||void 0:e?(_Q(`data`,this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;let e=this;for(;++this.freezeIndex<this.attachers.length;){let[t,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);let r=t.call(e,...n);typeof r==`function`&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=bQ(e),n=this.parser||this.Parser;return hQ(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),hQ(`process`,this.parser||this.Parser),gQ(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=bQ(e),o=n.parse(a);n.run(o,a,function(e,t,r){if(e||!t||!r)return s(e);let i=t,a=n.stringify(i,r);p_e(a)?r.value=a:r.result=a,s(e,r)});function s(e,n){e||!n?i(e):r?r(n):t(void 0,n)}}}processSync(e){let t=!1,n;return this.freeze(),hQ(`processSync`,this.parser||this.Parser),gQ(`processSync`,this.compiler||this.Compiler),this.process(e,r),yQ(`processSync`,`process`,t),n;function r(e,r){t=!0,iQ(e),n=r}}run(e,t,n){vQ(e),this.freeze();let r=this.transformers;return!n&&typeof t==`function`&&(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,a){let o=bQ(t);r.run(e,o,s);function s(t,r,o){let s=r||e;t?a(t):i?i(s):n(void 0,s,o)}}}runSync(e,t){let n=!1,r;return this.run(e,t,i),yQ(`runSync`,`run`,n),r;function i(e,t){iQ(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=bQ(t),r=this.compiler||this.Compiler;return gQ(`stringify`,r),vQ(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(_Q(`use`,this.frozen),e!=null)if(typeof e==`function`)s(e,t);else if(typeof e==`object`)Array.isArray(e)?o(e):a(e);else throw TypeError("Expected usable value, not `"+e+"`");return this;function i(e){if(typeof e==`function`)s(e,[]);else if(typeof e==`object`)if(Array.isArray(e)){let[t,...n]=e;s(t,n)}else a(e);else throw TypeError("Expected usable value, not `"+e+"`")}function a(e){if(!(`plugins`in e)&&!(`settings`in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(e.plugins),e.settings&&(r.settings=(0,mQ.default)(!0,r.settings,e.settings))}function o(e){let t=-1;if(e!=null)if(Array.isArray(e))for(;++t<e.length;){let n=e[t];i(n)}else throw TypeError("Expected a list of plugins, not `"+e+"`")}function s(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(i===-1)n.push([e,...t]);else if(t.length>0){let[r,...a]=t,o=n[i][1];aQ(o)&&aQ(r)&&(r=(0,mQ.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function hQ(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function gQ(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function _Q(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function vQ(e){if(!aQ(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function yQ(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function bQ(e){return f_e(e)?e:new uQ(e)}function f_e(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function p_e(e){return typeof e==`string`||m_e(e)}function m_e(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var xQ=[],SQ={allowDangerousHtml:!0},h_e=/^(https?|ircs?|mailto|xmpp)$/i,g_e=[{from:`astPlugins`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowDangerousHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowNode`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowElement`},{from:`allowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowedElements`},{from:`className`,id:`remove-classname`},{from:`disallowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`disallowedElements`},{from:`escapeHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`includeElementIndex`,id:`#remove-includeelementindex`},{from:`includeNodeIndex`,id:`change-includenodeindex-to-includeelementindex`},{from:`linkTarget`,id:`remove-linktarget`},{from:`plugins`,id:`change-plugins-to-remarkplugins`,to:`remarkPlugins`},{from:`rawSourcePos`,id:`#remove-rawsourcepos`},{from:`renderers`,id:`change-renderers-to-components`,to:`components`},{from:`source`,id:`change-source-to-children`,to:`children`},{from:`sourcePos`,id:`#remove-sourcepos`},{from:`transformImageUri`,id:`#add-urltransform`,to:`urlTransform`},{from:`transformLinkUri`,id:`#add-urltransform`,to:`urlTransform`}];function __e(e){let t=v_e(e),n=y_e(e);return b_e(t.runSync(t.parse(n),n),e)}function v_e(e){let t=e.rehypePlugins||xQ,n=e.remarkPlugins||xQ,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...SQ}:SQ;return d_e().use(ege).use(n).use(Jge,r).use(t)}function y_e(e){let t=e.children||``,n=new uQ;return typeof t==`string`?n.value=t:``+t,n}function b_e(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||x_e;for(let e of g_e)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return eQ(e,l),AX(e,{Fragment:F.Fragment,components:i,ignoreInvalidStyle:!0,jsx:F.jsx,jsxs:F.jsxs,passKeys:!0,passNode:!0});function l(e,t,i){if(e.type===`raw`&&i&&typeof t==`number`)return o?i.children.splice(t,1):i.children[t]={type:`text`,value:e.value},t;if(e.type===`element`){let t;for(t in LX)if(Object.hasOwn(LX,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=LX[t];(r===null||r.includes(e.tagName))&&(e.properties[t]=c(String(n||``),t,e))}}if(e.type===`element`){let o=n?!n.includes(e.tagName):a?a.includes(e.tagName):!1;if(!o&&r&&typeof t==`number`&&(o=!r(e,t,i)),o&&i&&typeof t==`number`)return s&&e.children?i.children.splice(t,1,...e.children):i.children.splice(t,1),t}}}function x_e(e){let t=e.indexOf(`:`),n=e.indexOf(`?`),r=e.indexOf(`#`),i=e.indexOf(`/`);return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||h_e.test(e.slice(0,t))?e:``}function CQ(e,t){let n=String(e);if(typeof t!=`string`)throw TypeError(`Expected character`);let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function S_e(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function C_e(e,t,n){let r=XZ((n||{}).ignore||[]),i=w_e(t),a=-1;for(;++a<i.length;)$Z(e,`text`,o);function o(e,t){let n=-1,i;for(;++n<t.length;){let e=t[n],a=i?i.children:void 0;if(r(e,a?a.indexOf(e):void 0,i))return;i=e}if(i)return s(e,t)}function s(e,t){let n=t[t.length-1],r=i[a][0],o=i[a][1],s=0,c=n.children.indexOf(e),l=!1,u=[];r.lastIndex=0;let d=r.exec(e.value);for(;d;){let n=d.index,i={index:d.index,input:d.input,stack:[...t,e]},a=o(...d,i);if(typeof a==`string`&&(a=a.length>0?{type:`text`,value:a}:void 0),a===!1?r.lastIndex=n+1:(s!==n&&u.push({type:`text`,value:e.value.slice(s,n)}),Array.isArray(a)?u.push(...a):a&&u.push(a),s=n+d[0].length,l=!0),!r.global)break;d=r.exec(e.value)}return l?(s<e.value.length&&u.push({type:`text`,value:e.value.slice(s)}),n.children.splice(c,1,...u)):u=[e],c+u.length}}function w_e(e){let t=[];if(!Array.isArray(e))throw TypeError(`Expected find and replace tuple or list of tuples`);let n=!e[0]||Array.isArray(e[0])?e:[e],r=-1;for(;++r<n.length;){let e=n[r];t.push([T_e(e[0]),E_e(e[1])])}return t}function T_e(e){return typeof e==`string`?new RegExp(S_e(e),`g`):e}function E_e(e){return typeof e==`function`?e:function(){return e}}var wQ=`phrasing`,TQ=[`autolink`,`link`,`image`,`label`];function D_e(){return{transforms:[P_e],enter:{literalAutolink:k_e,literalAutolinkEmail:EQ,literalAutolinkHttp:EQ,literalAutolinkWww:EQ},exit:{literalAutolink:N_e,literalAutolinkEmail:M_e,literalAutolinkHttp:A_e,literalAutolinkWww:j_e}}}function O_e(){return{unsafe:[{character:`@`,before:`[+\\-.\\w]`,after:`[\\-.\\w]`,inConstruct:wQ,notInConstruct:TQ},{character:`.`,before:`[Ww]`,after:`[\\-.\\w]`,inConstruct:wQ,notInConstruct:TQ},{character:`:`,before:`[ps]`,after:`\\/`,inConstruct:wQ,notInConstruct:TQ}]}}function k_e(e){this.enter({type:`link`,title:null,url:``,children:[]},e)}function EQ(e){this.config.enter.autolinkProtocol.call(this,e)}function A_e(e){this.config.exit.autolinkProtocol.call(this,e)}function j_e(e){this.config.exit.data.call(this,e);let t=this.stack[this.stack.length-1];t.type,t.url=`http://`+this.sliceSerialize(e)}function M_e(e){this.config.exit.autolinkEmail.call(this,e)}function N_e(e){this.exit(e)}function P_e(e){C_e(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,F_e],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,I_e]],{ignore:[`link`,`linkReference`]})}function F_e(e,t,n,r,i){let a=``;if(!DQ(i)||(/^w/i.test(t)&&(n=t+n,t=``,a=`http://`),!L_e(n)))return!1;let o=R_e(n+r);if(!o[0])return!1;let s={type:`link`,title:null,url:a+t+o[0],children:[{type:`text`,value:t+o[0]}]};return o[1]?[s,{type:`text`,value:o[1]}]:s}function I_e(e,t,n,r){return!DQ(r,!0)||/[-\d_]$/.test(n)?!1:{type:`link`,title:null,url:`mailto:`+t+`@`+n,children:[{type:`text`,value:t+`@`+n}]}}function L_e(e){let t=e.split(`.`);return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function R_e(e){let t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(`)`),i=CQ(e,`(`),a=CQ(e,`)`);for(;r!==-1&&i>a;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(`)`),a++;return[e,n]}function DQ(e,t){let n=e.input.charCodeAt(e.index-1);return(e.index===0||nZ(n)||tZ(n))&&(!t||n!==47)}OQ.peek=q_e;function z_e(){this.buffer()}function B_e(e){this.enter({type:`footnoteReference`,identifier:``,label:``},e)}function V_e(){this.buffer()}function H_e(e){this.enter({type:`footnoteDefinition`,identifier:``,label:``,children:[]},e)}function U_e(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=JX(this.sliceSerialize(e)).toLowerCase(),n.label=t}function W_e(e){this.exit(e)}function G_e(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=JX(this.sliceSerialize(e)).toLowerCase(),n.label=t}function K_e(e){this.exit(e)}function q_e(){return`[`}function OQ(e,t,n,r){let i=n.createTracker(r),a=i.move(`[^`),o=n.enter(`footnoteReference`),s=n.enter(`reference`);return a+=i.move(n.safe(n.associationId(e),{after:`]`,before:a})),s(),o(),a+=i.move(`]`),a}function J_e(){return{enter:{gfmFootnoteCallString:z_e,gfmFootnoteCall:B_e,gfmFootnoteDefinitionLabelString:V_e,gfmFootnoteDefinition:H_e},exit:{gfmFootnoteCallString:U_e,gfmFootnoteCall:W_e,gfmFootnoteDefinitionLabelString:G_e,gfmFootnoteDefinition:K_e}}}function Y_e(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:OQ},unsafe:[{character:`[`,inConstruct:[`label`,`phrasing`,`reference`]}]};function n(e,n,r,i){let a=r.createTracker(i),o=a.move(`[^`),s=r.enter(`footnoteDefinition`),c=r.enter(`label`);return o+=a.move(r.safe(r.associationId(e),{before:o,after:`]`})),c(),o+=a.move(`]:`),e.children&&e.children.length>0&&(a.shift(4),o+=a.move((t?`
726
+ `:` `)+r.indentLines(r.containerFlow(e,a.current()),t?kQ:X_e))),s(),o}}function X_e(e,t,n){return t===0?e:kQ(e,t,n)}function kQ(e,t,n){return(n?``:` `)+e}var Z_e=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`];AQ.peek=nve;function Q_e(){return{canContainEols:[`delete`],enter:{strikethrough:eve},exit:{strikethrough:tve}}}function $_e(){return{unsafe:[{character:`~`,inConstruct:`phrasing`,notInConstruct:Z_e}],handlers:{delete:AQ}}}function eve(e){this.enter({type:`delete`,children:[]},e)}function tve(e){this.exit(e)}function AQ(e,t,n,r){let i=n.createTracker(r),a=n.enter(`strikethrough`),o=i.move(`~~`);return o+=n.containerPhrasing(e,{...i.current(),before:o,after:`~`}),o+=i.move(`~~`),a(),o}function nve(){return`~`}function rve(e){return e.length}function ive(e,t){let n=t||{},r=(n.align||[]).concat(),i=n.stringLength||rve,a=[],o=[],s=[],c=[],l=0,u=-1;for(;++u<e.length;){let t=[],r=[],a=-1;for(e[u].length>l&&(l=e[u].length);++a<e[u].length;){let o=ave(e[u][a]);if(n.alignDelimiters!==!1){let e=i(o);r[a]=e,(c[a]===void 0||e>c[a])&&(c[a]=e)}t.push(o)}o[u]=t,s[u]=r}let d=-1;if(typeof r==`object`&&`length`in r)for(;++d<l;)a[d]=jQ(r[d]);else{let e=jQ(r);for(;++d<l;)a[d]=e}d=-1;let f=[],p=[];for(;++d<l;){let e=a[d],t=``,r=``;e===99?(t=`:`,r=`:`):e===108?t=`:`:e===114&&(r=`:`);let i=n.alignDelimiters===!1?1:Math.max(1,c[d]-t.length-r.length),o=t+`-`.repeat(i)+r;n.alignDelimiters!==!1&&(i=t.length+i+r.length,i>c[d]&&(c[d]=i),p[d]=i),f[d]=o}o.splice(1,0,f),s.splice(1,0,p),u=-1;let m=[];for(;++u<o.length;){let e=o[u],t=s[u];d=-1;let r=[];for(;++d<l;){let i=e[d]||``,o=``,s=``;if(n.alignDelimiters!==!1){let e=c[d]-(t[d]||0),n=a[d];n===114?o=` `.repeat(e):n===99?e%2?(o=` `.repeat(e/2+.5),s=` `.repeat(e/2-.5)):(o=` `.repeat(e/2),s=o):s=` `.repeat(e)}n.delimiterStart!==!1&&!d&&r.push(`|`),n.padding!==!1&&!(n.alignDelimiters===!1&&i===``)&&(n.delimiterStart!==!1||d)&&r.push(` `),n.alignDelimiters!==!1&&r.push(o),r.push(i),n.alignDelimiters!==!1&&r.push(s),n.padding!==!1&&r.push(` `),(n.delimiterEnd!==!1||d!==l-1)&&r.push(`|`)}m.push(n.delimiterEnd===!1?r.join(``).replace(/ +$/,``):r.join(``))}return m.join(`
727
+ `)}function ave(e){return e==null?``:String(e)}function jQ(e){let t=typeof e==`string`?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function ove(e,t,n,r){let i=n.enter(`blockquote`),a=n.createTracker(r);a.move(`> `),a.shift(2);let o=n.indentLines(n.containerFlow(e,a.current()),sve);return i(),o}function sve(e,t,n){return`>`+(n?``:` `)+e}function cve(e,t){return MQ(e,t.inConstruct,!0)&&!MQ(e,t.notInConstruct,!1)}function MQ(e,t,n){if(typeof t==`string`&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function NQ(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
728
+ `&&cve(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?``:` `;return`\\
729
+ `}function lve(e,t){let n=String(e),r=n.indexOf(t),i=r,a=0,o=0;if(typeof t!=`string`)throw TypeError(`Expected substring`);for(;r!==-1;)r===i?++a>o&&(o=a):a=1,i=r+t.length,r=n.indexOf(t,i);return o}function uve(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function dve(e){let t=e.options.fence||"`";if(t!=="`"&&t!==`~`)throw Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function fve(e,t,n,r){let i=dve(n),a=e.value||``,o=i==="`"?`GraveAccent`:`Tilde`;if(uve(e,n)){let e=n.enter(`codeIndented`),t=n.indentLines(a,pve);return e(),t}let s=n.createTracker(r),c=i.repeat(Math.max(lve(a,i)+1,3)),l=n.enter(`codeFenced`),u=s.move(c);if(e.lang){let t=n.enter(`codeFencedLang${o}`);u+=s.move(n.safe(e.lang,{before:u,after:` `,encode:["`"],...s.current()})),t()}if(e.lang&&e.meta){let t=n.enter(`codeFencedMeta${o}`);u+=s.move(` `),u+=s.move(n.safe(e.meta,{before:u,after:`
730
730
  `,encode:["`"],...s.current()})),t()}return u+=s.move(`
731
731
  `),a&&(u+=s.move(a+`
732
- `)),u+=s.move(c),l(),u}function fve(e,t,n){return(n?``:` `)+e}function FQ(e){let t=e.options.quote||`"`;if(t!==`"`&&t!==`'`)throw Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function pve(e,t,n,r){let i=FQ(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`definition`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`[`);return l+=c.move(n.safe(n.associationId(e),{before:l,after:`]`,...c.current()})),l+=c.move(`]: `),s(),!e.url||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`
733
- `,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),o(),l}function mve(e){let t=e.options.emphasis||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function IQ(e){return`&#x`+e.toString(16).toUpperCase()+`;`}function LQ(e,t,n){let r=cZ(e),i=cZ(t);return r===void 0?i===void 0?n===`_`?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}RQ.peek=hve;function RQ(e,t,n,r){let i=mve(n),a=n.enter(`emphasis`),o=n.createTracker(r),s=o.move(i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=LQ(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=IQ(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=LQ(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+IQ(d));let p=o.move(i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function hve(e,t,n){return n.options.emphasis||`*`}function gve(e,t){let n=!1;return tQ(e,function(e){if(`value`in e&&/\r?\n|\r/.test(e.value)||e.type===`break`)return n=!0,!1}),!!((!e.depth||e.depth<3)&&zX(e)&&(t.options.setext||n))}function _ve(e,t,n,r){let i=Math.max(Math.min(6,e.depth||1),1),a=n.createTracker(r);if(gve(e,n)){let t=n.enter(`headingSetext`),r=n.enter(`phrasing`),o=n.containerPhrasing(e,{...a.current(),before:`
732
+ `)),u+=s.move(c),l(),u}function pve(e,t,n){return(n?``:` `)+e}function PQ(e){let t=e.options.quote||`"`;if(t!==`"`&&t!==`'`)throw Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function mve(e,t,n,r){let i=PQ(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`definition`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`[`);return l+=c.move(n.safe(n.associationId(e),{before:l,after:`]`,...c.current()})),l+=c.move(`]: `),s(),!e.url||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`
733
+ `,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),o(),l}function hve(e){let t=e.options.emphasis||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function FQ(e){return`&#x`+e.toString(16).toUpperCase()+`;`}function IQ(e,t,n){let r=sZ(e),i=sZ(t);return r===void 0?i===void 0?n===`_`?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}LQ.peek=gve;function LQ(e,t,n,r){let i=hve(n),a=n.enter(`emphasis`),o=n.createTracker(r),s=o.move(i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=IQ(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=FQ(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=IQ(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+FQ(d));let p=o.move(i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function gve(e,t,n){return n.options.emphasis||`*`}function _ve(e,t){let n=!1;return eQ(e,function(e){if(`value`in e&&/\r?\n|\r/.test(e.value)||e.type===`break`)return n=!0,!1}),!!((!e.depth||e.depth<3)&&RX(e)&&(t.options.setext||n))}function vve(e,t,n,r){let i=Math.max(Math.min(6,e.depth||1),1),a=n.createTracker(r);if(_ve(e,n)){let t=n.enter(`headingSetext`),r=n.enter(`phrasing`),o=n.containerPhrasing(e,{...a.current(),before:`
734
734
  `,after:`
735
735
  `});return r(),t(),o+`
736
736
  `+(i===1?`=`:`-`).repeat(o.length-(Math.max(o.lastIndexOf(`\r`),o.lastIndexOf(`
737
737
  `))+1))}let o=`#`.repeat(i),s=n.enter(`headingAtx`),c=n.enter(`phrasing`);a.move(o+` `);let l=n.containerPhrasing(e,{before:`# `,after:`
738
- `,...a.current()});return/^[\t ]/.test(l)&&(l=IQ(l.charCodeAt(0))+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}zQ.peek=vve;function zQ(e){return e.value||``}function vve(){return`<`}BQ.peek=yve;function BQ(e,t,n,r){let i=FQ(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`image`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`![`);return l+=c.move(n.safe(e.alt,{before:l,after:`]`,...c.current()})),l+=c.move(`](`),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),l+=c.move(`)`),o(),l}function yve(){return`!`}VQ.peek=bve;function VQ(e,t,n,r){let i=e.referenceType,a=n.enter(`imageReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`![`),l=n.safe(e.alt,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function bve(){return`!`}HQ.peek=xve;function HQ(e,t,n){let r=e.value||``,i="`",a=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=` `+r+` `);++a<n.unsafe.length;){let e=n.unsafe[a],t=n.compilePattern(e),i;if(e.atBreak)for(;i=t.exec(r);){let e=i.index;r.charCodeAt(e)===10&&r.charCodeAt(e-1)===13&&e--,r=r.slice(0,e)+` `+r.slice(i.index+1)}}return i+r+i}function xve(){return"`"}function UQ(e,t){let n=zX(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type===`text`&&(n===e.url||`mailto:`+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}WQ.peek=Sve;function WQ(e,t,n,r){let i=FQ(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r),s,c;if(UQ(e,n)){let t=n.stack;n.stack=[],s=n.enter(`autolink`);let r=o.move(`<`);return r+=o.move(n.containerPhrasing(e,{before:r,after:`>`,...o.current()})),r+=o.move(`>`),s(),n.stack=t,r}s=n.enter(`link`),c=n.enter(`label`);let l=o.move(`[`);return l+=o.move(n.containerPhrasing(e,{before:l,after:`](`,...o.current()})),l+=o.move(`](`),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter(`destinationLiteral`),l+=o.move(`<`),l+=o.move(n.safe(e.url,{before:l,after:`>`,...o.current()})),l+=o.move(`>`)):(c=n.enter(`destinationRaw`),l+=o.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...o.current()}))),c(),e.title&&(c=n.enter(`title${a}`),l+=o.move(` `+i),l+=o.move(n.safe(e.title,{before:l,after:i,...o.current()})),l+=o.move(i),c()),l+=o.move(`)`),s(),l}function Sve(e,t,n){return UQ(e,n)?`<`:`[`}GQ.peek=Cve;function GQ(e,t,n,r){let i=e.referenceType,a=n.enter(`linkReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`[`),l=n.containerPhrasing(e,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function Cve(){return`[`}function KQ(e){let t=e.options.bullet||`*`;if(t!==`*`&&t!==`+`&&t!==`-`)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function wve(e){let t=KQ(e),n=e.options.bulletOther;if(!n)return t===`*`?`-`:`*`;if(n!==`*`&&n!==`+`&&n!==`-`)throw Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function Tve(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function qQ(e){let t=e.options.rule||`*`;if(t!==`*`&&t!==`-`&&t!==`_`)throw Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function Eve(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?Tve(n):KQ(n),s=e.ordered?o===`.`?`)`:`.`:wve(n),c=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){let t=e.children?e.children[0]:void 0;if((o===`*`||o===`-`)&&t&&(!t.children||!t.children[0])&&n.stack[n.stack.length-1]===`list`&&n.stack[n.stack.length-2]===`listItem`&&n.stack[n.stack.length-3]===`list`&&n.stack[n.stack.length-4]===`listItem`&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),qQ(n)===o&&t){let t=-1;for(;++t<e.children.length;){let n=e.children[t];if(n&&n.type===`listItem`&&n.children&&n.children[0]&&n.children[0].type===`thematicBreak`){c=!0;break}}}}c&&(o=s),n.bulletCurrent=o;let l=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),l}function Dve(e){let t=e.options.listItemIndent||`one`;if(t!==`tab`&&t!==`one`&&t!==`mixed`)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function Ove(e,t,n,r){let i=Dve(n),a=n.bulletCurrent||KQ(n);t&&t.type===`list`&&t.ordered&&(a=(typeof t.start==`number`&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i===`tab`||i===`mixed`&&(t&&t.type===`list`&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);let s=n.createTracker(r);s.move(a+` `.repeat(o-a.length)),s.shift(o);let c=n.enter(`listItem`),l=n.indentLines(n.containerFlow(e,s.current()),u);return c(),l;function u(e,t,n){return t?(n?``:` `.repeat(o))+e:(n?a:a+` `.repeat(o-a.length))+e}}function kve(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}var Ave=ZZ([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]);function jve(e,t,n,r){return(e.children.some(function(e){return Ave(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function Mve(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}JQ.peek=Nve;function JQ(e,t,n,r){let i=Mve(n),a=n.enter(`strong`),o=n.createTracker(r),s=o.move(i+i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=LQ(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=IQ(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=LQ(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+IQ(d));let p=o.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function Nve(e,t,n){return n.options.strong||`*`}function Pve(e,t,n,r){return n.safe(e.value,r)}function Fve(e){let t=e.options.ruleRepetition||3;if(t<3)throw Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function Ive(e,t,n){let r=(qQ(n)+(n.options.ruleSpaces?` `:``)).repeat(Fve(n));return n.options.ruleSpaces?r.slice(0,-1):r}var YQ={blockquote:ave,break:PQ,code:dve,definition:pve,emphasis:RQ,hardBreak:PQ,heading:_ve,html:zQ,image:BQ,imageReference:VQ,inlineCode:HQ,link:WQ,linkReference:GQ,list:Eve,listItem:Ove,paragraph:kve,root:jve,strong:JQ,text:Pve,thematicBreak:Ive};function Lve(){return{enter:{table:Rve,tableData:ZQ,tableHeader:ZQ,tableRow:Bve},exit:{codeText:Vve,table:zve,tableData:XQ,tableHeader:XQ,tableRow:XQ}}}function Rve(e){let t=e._align;this.enter({type:`table`,align:t.map(function(e){return e===`none`?null:e}),children:[]},e),this.data.inTable=!0}function zve(e){this.exit(e),this.data.inTable=void 0}function Bve(e){this.enter({type:`tableRow`,children:[]},e)}function XQ(e){this.exit(e)}function ZQ(e){this.enter({type:`tableCell`,children:[]},e)}function Vve(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,Hve));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function Hve(e,t){return t===`|`?t:e}function Uve(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
738
+ `,...a.current()});return/^[\t ]/.test(l)&&(l=FQ(l.charCodeAt(0))+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}RQ.peek=yve;function RQ(e){return e.value||``}function yve(){return`<`}zQ.peek=bve;function zQ(e,t,n,r){let i=PQ(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`image`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`![`);return l+=c.move(n.safe(e.alt,{before:l,after:`]`,...c.current()})),l+=c.move(`](`),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),l+=c.move(`)`),o(),l}function bve(){return`!`}BQ.peek=xve;function BQ(e,t,n,r){let i=e.referenceType,a=n.enter(`imageReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`![`),l=n.safe(e.alt,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function xve(){return`!`}VQ.peek=Sve;function VQ(e,t,n){let r=e.value||``,i="`",a=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=` `+r+` `);++a<n.unsafe.length;){let e=n.unsafe[a],t=n.compilePattern(e),i;if(e.atBreak)for(;i=t.exec(r);){let e=i.index;r.charCodeAt(e)===10&&r.charCodeAt(e-1)===13&&e--,r=r.slice(0,e)+` `+r.slice(i.index+1)}}return i+r+i}function Sve(){return"`"}function HQ(e,t){let n=RX(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type===`text`&&(n===e.url||`mailto:`+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}UQ.peek=Cve;function UQ(e,t,n,r){let i=PQ(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r),s,c;if(HQ(e,n)){let t=n.stack;n.stack=[],s=n.enter(`autolink`);let r=o.move(`<`);return r+=o.move(n.containerPhrasing(e,{before:r,after:`>`,...o.current()})),r+=o.move(`>`),s(),n.stack=t,r}s=n.enter(`link`),c=n.enter(`label`);let l=o.move(`[`);return l+=o.move(n.containerPhrasing(e,{before:l,after:`](`,...o.current()})),l+=o.move(`](`),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter(`destinationLiteral`),l+=o.move(`<`),l+=o.move(n.safe(e.url,{before:l,after:`>`,...o.current()})),l+=o.move(`>`)):(c=n.enter(`destinationRaw`),l+=o.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...o.current()}))),c(),e.title&&(c=n.enter(`title${a}`),l+=o.move(` `+i),l+=o.move(n.safe(e.title,{before:l,after:i,...o.current()})),l+=o.move(i),c()),l+=o.move(`)`),s(),l}function Cve(e,t,n){return HQ(e,n)?`<`:`[`}WQ.peek=wve;function WQ(e,t,n,r){let i=e.referenceType,a=n.enter(`linkReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`[`),l=n.containerPhrasing(e,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function wve(){return`[`}function GQ(e){let t=e.options.bullet||`*`;if(t!==`*`&&t!==`+`&&t!==`-`)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function Tve(e){let t=GQ(e),n=e.options.bulletOther;if(!n)return t===`*`?`-`:`*`;if(n!==`*`&&n!==`+`&&n!==`-`)throw Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function Eve(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function KQ(e){let t=e.options.rule||`*`;if(t!==`*`&&t!==`-`&&t!==`_`)throw Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function Dve(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?Eve(n):GQ(n),s=e.ordered?o===`.`?`)`:`.`:Tve(n),c=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){let t=e.children?e.children[0]:void 0;if((o===`*`||o===`-`)&&t&&(!t.children||!t.children[0])&&n.stack[n.stack.length-1]===`list`&&n.stack[n.stack.length-2]===`listItem`&&n.stack[n.stack.length-3]===`list`&&n.stack[n.stack.length-4]===`listItem`&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),KQ(n)===o&&t){let t=-1;for(;++t<e.children.length;){let n=e.children[t];if(n&&n.type===`listItem`&&n.children&&n.children[0]&&n.children[0].type===`thematicBreak`){c=!0;break}}}}c&&(o=s),n.bulletCurrent=o;let l=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),l}function Ove(e){let t=e.options.listItemIndent||`one`;if(t!==`tab`&&t!==`one`&&t!==`mixed`)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function kve(e,t,n,r){let i=Ove(n),a=n.bulletCurrent||GQ(n);t&&t.type===`list`&&t.ordered&&(a=(typeof t.start==`number`&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i===`tab`||i===`mixed`&&(t&&t.type===`list`&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);let s=n.createTracker(r);s.move(a+` `.repeat(o-a.length)),s.shift(o);let c=n.enter(`listItem`),l=n.indentLines(n.containerFlow(e,s.current()),u);return c(),l;function u(e,t,n){return t?(n?``:` `.repeat(o))+e:(n?a:a+` `.repeat(o-a.length))+e}}function Ave(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}var jve=XZ([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]);function Mve(e,t,n,r){return(e.children.some(function(e){return jve(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function Nve(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}qQ.peek=Pve;function qQ(e,t,n,r){let i=Nve(n),a=n.enter(`strong`),o=n.createTracker(r),s=o.move(i+i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=IQ(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=FQ(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=IQ(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+FQ(d));let p=o.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function Pve(e,t,n){return n.options.strong||`*`}function Fve(e,t,n,r){return n.safe(e.value,r)}function Ive(e){let t=e.options.ruleRepetition||3;if(t<3)throw Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function Lve(e,t,n){let r=(KQ(n)+(n.options.ruleSpaces?` `:``)).repeat(Ive(n));return n.options.ruleSpaces?r.slice(0,-1):r}var JQ={blockquote:ove,break:NQ,code:fve,definition:mve,emphasis:LQ,hardBreak:NQ,heading:vve,html:RQ,image:zQ,imageReference:BQ,inlineCode:VQ,link:UQ,linkReference:WQ,list:Dve,listItem:kve,paragraph:Ave,root:Mve,strong:qQ,text:Fve,thematicBreak:Lve};function Rve(){return{enter:{table:zve,tableData:XQ,tableHeader:XQ,tableRow:Vve},exit:{codeText:Hve,table:Bve,tableData:YQ,tableHeader:YQ,tableRow:YQ}}}function zve(e){let t=e._align;this.enter({type:`table`,align:t.map(function(e){return e===`none`?null:e}),children:[]},e),this.data.inTable=!0}function Bve(e){this.exit(e),this.data.inTable=void 0}function Vve(e){this.enter({type:`tableRow`,children:[]},e)}function YQ(e){this.exit(e)}function XQ(e){this.enter({type:`tableCell`,children:[]},e)}function Hve(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,Uve));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function Uve(e,t){return t===`|`?t:e}function Wve(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
739
739
  `,inConstruct:`tableCell`},{atBreak:!0,character:`|`,after:`[ :-]`},{character:`|`,inConstruct:`tableCell`},{atBreak:!0,character:`:`,after:`-`},{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{inlineCode:f,table:o,tableCell:c,tableRow:s}};function o(e,t,n,r){return l(u(e,n,r),e.align)}function s(e,t,n,r){let i=l([d(e,n,r)]);return i.slice(0,i.indexOf(`
740
- `))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return rve(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=YQ.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function Wve(){return{exit:{taskListCheckValueChecked:QQ,taskListCheckValueUnchecked:QQ,paragraph:Kve}}}function Gve(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:qve}}}function QQ(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function Kve(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function qve(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=YQ.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function Jve(){return[E_e(),q_e(),Z_e(),Lve(),Wve()]}function Yve(e){return{extensions:[D_e(),J_e(e),Q_e(),Uve(e),Gve()]}}var Xve={tokenize:nye,partial:!0},$Q={tokenize:rye,partial:!0},e$={tokenize:iye,partial:!0},t$={tokenize:aye,partial:!0},Zve={tokenize:oye,partial:!0},n$={name:`wwwAutolink`,tokenize:eye,previous:s$},r$={name:`protocolAutolink`,tokenize:tye,previous:c$},i$={name:`emailAutolink`,tokenize:$ve,previous:l$},a$={};function Qve(){return{text:a$}}for(var o$=48;o$<123;)a$[o$]=i$,o$++,o$===58?o$=65:o$===91&&(o$=97);a$[43]=i$,a$[45]=i$,a$[46]=i$,a$[95]=i$,a$[72]=[i$,r$],a$[104]=[i$,r$],a$[87]=[i$,n$],a$[119]=[i$,n$];function $ve(e,t,n){let r=this,i,a;return o;function o(t){return!u$(t)||!l$.call(r,r.previous)||d$(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return u$(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(Zve,u,l)(t):t===45||t===95||ZX(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&XX(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function eye(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!s$.call(r,r.previous)||d$(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(Xve,e.attempt($Q,e.attempt(e$,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function tye(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&c$.call(r,r.previous)&&!d$(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(XX(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||QX(t)||eZ(t)||rZ(t)||nZ(t)?n(t):e.attempt($Q,e.attempt(e$,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function nye(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function rye(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(t$,c,s)(t):t===null||eZ(t)||rZ(t)||t!==45&&nZ(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function iye(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(t$,t,a)(o):o===null||eZ(o)||rZ(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function aye(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||eZ(o)||rZ(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||eZ(e)||rZ(e)?t(e):r(e)}function a(e){return XX(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):XX(t)?(e.consume(t),o):n(t)}}function oye(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return ZX(e)?n(e):t(e)}}function s$(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||eZ(e)}function c$(e){return!XX(e)}function l$(e){return!(e===47||u$(e))}function u$(e){return e===43||e===45||e===46||e===95||ZX(e)}function d$(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var sye={tokenize:hye,partial:!0};function cye(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:fye,continuation:{tokenize:pye},exit:mye}},text:{91:{name:`gfmFootnoteCall`,tokenize:dye},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:lye,resolveTo:uye}}}}function lye(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=YX(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function uye(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function dye(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||eZ(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(YX(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return eZ(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function fye(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||eZ(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=YX(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return eZ(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),oZ(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function pye(e,t,n){return e.check(fZ,t,e.attempt(sye,t,n))}function mye(e){e.exit(`gfmFootnoteDefinition`)}function hye(e,t,n){let r=this;return oZ(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function gye(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&WX(o,o.length,0,lZ(s,e.slice(r+1,n),t)),WX(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),WX(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=cZ(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=cZ(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var _ye=class{constructor(){this.map=[]}add(e,t,n){vye(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function vye(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function yye(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function bye(){return{flow:{null:{name:`table`,tokenize:xye,resolveAll:Sye}}}}function xye(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):q(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):tZ(t)?oZ(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||eZ(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,tZ(t)?oZ(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return tZ(t)?oZ(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||q(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return tZ(t)?oZ(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||q(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||q(n)?(e.exit(`tableRow`),t(n)):tZ(n)?oZ(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||eZ(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function Sye(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new _ye;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(p$(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=f$(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=f$(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=f$(f,t,o,i,n,d)):(o[0]=o[1],d=f$(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&p$(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=yye(t.events,n))}return e}function f$(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},m$(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=m$(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=m$(t.events,n[2]),a=m$(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},m$(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function p$(e,t,n,r,i){let a=[],o=m$(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function m$(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var Cye={name:`tasklistCheck`,tokenize:Tye};function wye(){return{text:{91:Cye}}}function Tye(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return eZ(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return q(r)?t(r):tZ(r)?e.check({tokenize:Eye},t,n)(r):n(r)}}function Eye(e,t,n){return oZ(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function Dye(e){return qX([Qve(),cye(),gye(e),bye(),wye()])}var Oye={};function kye(e){let t=this,n=e||Oye,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(Dye(n)),a.push(Jve()),o.push(Yve(n))}var h$=[],g$=[];(()=>{let e=`lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o`.split(`,`).map(e=>e?parseInt(e,36):1);for(let t=0,n=0;t<e.length;t++)(t%2?g$:h$).push(n+=e[t])})();function Aye(e){if(e<768)return!1;for(let t=0,n=h$.length;;){let r=t+n>>1;if(e<h$[r])n=r;else if(e>=g$[r])t=r+1;else return!0;if(t==n)return!1}}function _$(e){return e>=127462&&e<=127487}var v$=8205;function jye(e,t,n=!0,r=!0){return(n?y$:Mye)(e,t,r)}function y$(e,t,n){if(t==e.length)return t;t&&x$(e.charCodeAt(t))&&S$(e.charCodeAt(t-1))&&t--;let r=b$(e,t);for(t+=C$(r);t<e.length;){let i=b$(e,t);if(r==v$||i==v$||n&&Aye(i))t+=C$(i),r=i;else if(_$(i)){let n=0,r=t-2;for(;r>=0&&_$(b$(e,r));)n++,r-=2;if(n%2==0)break;t+=2}else break}return t}function Mye(e,t,n){for(;t>0;){let r=y$(e,t-2,n);if(r<t)return r;t--}return 0}function b$(e,t){let n=e.charCodeAt(t);if(!S$(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return x$(r)?(n-55296<<10)+(r-56320)+65536:n}function x$(e){return e>=56320&&e<57344}function S$(e){return e>=55296&&e<56320}function C$(e){return e<65536?1:2}var w$=class e{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]=M$(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),E$.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]=M$(this,e,t);let n=[];return this.decompose(e,t,n,0),E$.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 k$(this),i=new k$(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 k$(this,e)}iterRange(e,t=this.length){return new A$(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{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 j$(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(t){if(t.length==0)throw RangeError(`A document must have at least one line`);return t.length==1&&!t[0]?e.empty:t.length<=32?new T$(t):E$.from(T$.split(t,[]))}},T$=class e extends w${constructor(e,t=Nye(e)){super(),this.text=e,this.length=t}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 Pye(r,o,n,a);r=o+1,n++}}decompose(t,n,r,i){let a=t<=0&&n>=this.length?this:new e(O$(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(i&1){let t=r.pop(),n=D$(a.text,t.text.slice(),0,a.length);if(n.length<=32)r.push(new e(n,t.length+a.length));else{let t=n.length>>1;r.push(new e(n.slice(0,t)),new e(n.slice(t)))}}else r.push(a)}replace(t,n,r){if(!(r instanceof e))return super.replace(t,n,r);[t,n]=M$(this,t,n);let i=D$(this.text,D$(r.text,O$(this.text,0,t)),n),a=this.length+r.length-(n-t);return i.length<=32?new e(i,a):E$.from(e.split(i,[]),a)}sliceString(e,t=this.length,n=`
741
- `){[e,t]=M$(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(t,n){let r=[],i=-1;for(let a of t)r.push(a),i+=a.length+1,r.length==32&&(n.push(new e(r,i)),r=[],i=-1);return i>-1&&n.push(new e(r,i)),n}},E$=class e extends w${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(t,n,r){if([t,n]=M$(this,t,n),r.lines<this.lines)for(let i=0,a=0;i<this.children.length;i++){let o=this.children[i],s=a+o.length;if(t>=a&&n<=s){let c=o.replace(t-a,n-a,r),l=this.lines-o.lines+c.lines;if(c.lines<l>>4&&c.lines>l>>6){let a=this.children.slice();return a[i]=c,new e(a,this.length-(n-t)+r.length)}return super.replace(a,s,c)}a=s+1}return super.replace(t,n,r)}sliceString(e,t=this.length,n=`
742
- `){[e,t]=M$(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(t,n){if(!(t instanceof e))return 0;let r=0,[i,a,o,s]=n>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;i+=n,a+=n){if(i==o||a==s)return r;let e=this.children[i],c=t.children[a];if(e!=c)return r+e.scanIdentical(c,n);r+=e.length+1}}static from(t,n=t.reduce((e,t)=>e+t.length+1,-1)){let r=0;for(let e of t)r+=e.lines;if(r<32){let e=[];for(let n of t)n.flatten(e);return new T$(e,n)}let i=Math.max(32,r>>5),a=i<<1,o=i>>1,s=[],c=0,l=-1,u=[];function d(t){let n;if(t.lines>a&&t instanceof e)for(let e of t.children)d(e);else t.lines>o&&(c>o||!c)?(f(),s.push(t)):t instanceof T$&&c&&(n=u[u.length-1])instanceof T$&&t.lines+n.lines<=32?(c+=t.lines,l+=t.length+1,u[u.length-1]=new T$(n.text.concat(t.text),n.length+1+t.length)):(c+t.lines>i&&f(),c+=t.lines,l+=t.length+1,u.push(t))}function f(){c!=0&&(s.push(u.length==1?u[0]:e.from(u,l)),l=-1,c=u.length=0)}for(let e of t)d(e);return f(),s.length==1?s[0]:new e(s,n)}};w$.empty=new T$([``],0);function Nye(e){let t=-1;for(let n of e)t+=n.length+1;return t}function D$(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 O$(e,t,n){return D$(e,[``],t,n)}var k$=class{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 T$?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 T$?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=`
743
- `,this;e--}else if(r instanceof T$){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 T$?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)}},A$=class{constructor(e,t,n){this.value=``,this.done=!1,this.cursor=new k$(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!=``}},j$=class{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`&&(w$.prototype[Symbol.iterator]=function(){return this.iter()},k$.prototype[Symbol.iterator]=A$.prototype[Symbol.iterator]=j$.prototype[Symbol.iterator]=function(){return this});var Pye=class{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 M$(e,t,n){return t=Math.max(0,Math.min(e.length,t)),[t,Math.max(t,Math.min(e.length,n))]}function N$(e,t,n=!0,r=!0){return jye(e,t,n,r)}function Fye(e){return e>=56320&&e<57344}function Iye(e){return e>=55296&&e<56320}function P$(e,t){let n=e.charCodeAt(t);if(!Iye(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return Fye(r)?(n-55296<<10)+(r-56320)+65536:n}function F$(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}function I$(e){return e<65536?1:2}var L$=/\r\n?|\n/,R$=(function(e){return e[e.Simple=0]=`Simple`,e[e.TrackDel=1]=`TrackDel`,e[e.TrackBefore=2]=`TrackBefore`,e[e.TrackAfter=3]=`TrackAfter`,e})(R$||={}),z$=class e{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){U$(this,e,t)}get invertedDesc(){let t=[];for(let e=0;e<this.sections.length;){let n=this.sections[e++],r=this.sections[e++];r<0?t.push(n,r):t.push(r,n)}return new e(t)}composeDesc(e){return this.empty?e:e.empty?this:G$(this,e)}mapDesc(e,t=!1){return e.empty?this:W$(this,e,t)}mapPos(e,t=-1,n=R$.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!=R$.Simple&&c>=e&&(n==R$.TrackDel&&r<e&&c>e||n==R$.TrackBefore&&r<e||n==R$.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(t){if(!Array.isArray(t)||t.length%2||t.some(e=>typeof e!=`number`))throw RangeError(`Invalid JSON representation of ChangeDesc`);return new e(t)}static create(t){return new e(t)}},B$=class e extends z${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 U$(this,(t,n,r,i,a)=>e=e.replace(r,r+(n-t),a),!1),e}mapDesc(e,t=!1){return W$(this,e,t,!0)}invert(t){let n=this.sections.slice(),r=[];for(let e=0,i=0;e<n.length;e+=2){let a=n[e],o=n[e+1];if(o>=0){n[e]=o,n[e+1]=a;let s=e>>1;for(;r.length<s;)r.push(w$.empty);r.push(a?t.slice(i,i+a):w$.empty)}i+=a}return new e(n,r)}compose(e){return this.empty?e:e.empty?this:G$(this,e,!0)}map(e,t=!1){return e.empty?this:W$(this,e,t,!0)}iterChanges(e,t=!1){U$(this,e,t)}get desc(){return z$.create(this.sections)}filter(t){let n=[],r=[],i=[],a=new K$(this);done:for(let e=0,o=0;;){let s=e==t.length?1e9:t[e++];for(;o<s||o==s&&a.len==0;){if(a.done)break done;let e=Math.min(a.len,s-o);V$(i,e,-1);let t=a.ins==-1?-1:a.off==0?a.ins:0;V$(n,e,t),t>0&&H$(r,n,a.text),a.forward(e),o+=e}let c=t[e++];for(;o<c;){if(a.done)break done;let e=Math.min(a.len,c-o);V$(n,e,-1),V$(i,e,a.ins==-1?-1:a.off==0?a.ins:0),a.forward(e),o+=e}}return{changes:new e(n,r),filtered:z$.create(i)}}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(t,n,r){let i=[],a=[],o=0,s=null;function c(t=!1){if(!t&&!i.length)return;o<n&&V$(i,n-o,-1);let r=new e(i,a);s=s?s.compose(r.map(s)):r,i=[],a=[],o=0}function l(t){if(Array.isArray(t))for(let e of t)l(e);else if(t instanceof e){if(t.length!=n)throw RangeError(`Mismatched change set length (got ${t.length}, expected ${n})`);c(),s=s?s.compose(t.map(s)):t}else{let{from:e,to:s=e,insert:l}=t;if(e>s||e<0||s>n)throw RangeError(`Invalid change range ${e} to ${s} (in doc of length ${n})`);let u=l?typeof l==`string`?w$.of(l.split(r||L$)):l:w$.empty,d=u.length;if(e==s&&d==0)return;e<o&&c(),e>o&&V$(i,e-o,-1),V$(i,s-e,d),H$(a,i,u),o=s}}return l(t),c(!s),s}static empty(t){return new e(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw RangeError(`Invalid JSON representation of ChangeSet`);let n=[],r=[];for(let e=0;e<t.length;e++){let i=t[e];if(typeof i==`number`)n.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)n.push(i[0],0);else{for(;r.length<e;)r.push(w$.empty);r[e]=w$.of(i.slice(1)),n.push(i[0],r[e].length)}}return new e(n,r)}static createSet(t,n){return new e(t,n)}};function V$(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 H$(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(w$.empty);e.push(n)}}function U$(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=w$.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 W$(e,t,n,r=!1){let i=[],a=r?[]:null,o=new K$(e),s=new K$(t);for(let e=-1;;)if(o.done&&s.len||s.done&&o.len)throw Error(`Mismatched change set lengths`);else if(o.ins==-1&&s.ins==-1){let e=Math.min(o.len,s.len);V$(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(V$(i,s.ins,-1);t;){let n=Math.min(o.len,t);o.ins>=0&&e<o.i&&o.len<=n&&(V$(i,0,o.ins),a&&H$(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;V$(i,t,e<o.i?o.ins:0),a&&e<o.i&&H$(a,i,o.text),e=o.i,o.forward(o.len-n)}else if(o.done&&s.done)return a?B$.createSet(i,a):z$.create(i);else throw Error(`Mismatched change set lengths`)}function G$(e,t,n=!1){let r=[],i=n?[]:null,a=new K$(e),o=new K$(t);for(let e=!1;;)if(a.done&&o.done)return i?B$.createSet(r,i):z$.create(r);else if(a.ins==0)V$(r,a.len,0,e),a.next();else if(o.len==0&&!o.done)V$(r,0,o.ins,e),i&&H$(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;V$(r,t,n,e),i&&n&&H$(i,r,o.text)}else o.ins==-1?(V$(r,a.off?0:a.len,t,e),i&&H$(i,r,a.textBit(t))):(V$(r,a.off?0:a.len,o.off?0:o.ins,e),i&&!o.off&&H$(i,r,o.text));e=(a.ins>t||o.ins>=0&&o.len>t)&&(e||r.length>n),a.forward2(t),o.forward(t)}}var K$=class{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?w$.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?w$.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)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}},q$=class e{constructor(e,t,n){this.from=e,this.to=t,this.flags=n}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 bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(t,n=-1){let r,i;return this.empty?r=i=t.mapPos(this.from,n):(r=t.mapPos(this.from,1),i=t.mapPos(this.to,-1)),r==this.from&&i==this.to?this:new e(r,i,this.flags)}extend(e,t=e,n=0){if(e<=this.anchor&&t>=this.anchor)return J.range(e,t,void 0,void 0,n);let r=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return J.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 J.range(e.anchor,e.head)}static create(t,n,r){return new e(t,n,r)}},J=class e{constructor(e,t){this.ranges=e,this.mainIndex=t}map(t,n=-1){return t.empty?this:e.create(this.ranges.map(e=>e.map(t,n)),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 e([this.main],0)}addRange(t,n=!0){return e.create([t].concat(this.ranges),n?0:this.mainIndex+1)}replaceRange(t,n=this.mainIndex){let r=this.ranges.slice();return r[n]=t,e.create(r,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||typeof t.main!=`number`||t.main>=t.ranges.length)throw RangeError(`Invalid JSON representation for EditorSelection`);return new e(t.ranges.map(e=>q$.fromJSON(e)),t.main)}static single(t,n=t){return new e([e.range(t,n)],0)}static create(t,n=0){if(t.length==0)throw RangeError(`A selection needs at least one range`);for(let r=0,i=0;i<t.length;i++){let a=t[i];if(a.empty?a.from<=r:a.from<r)return e.normalized(t.slice(),n);r=a.to}return new e(t,n)}static cursor(e,t=0,n,r){return q$.create(e,e,(t==0?0:t<0?8:16)|(n==null?7:Math.min(6,n))|(r??16777215)<<6)}static range(e,t,n,r,i){let a=(n??16777215)<<6|(r==null?7:Math.min(6,r));return!i&&e!=t&&(i=t<e?1:-1),t<e?q$.create(t,e,48|a):q$.create(e,t,(i?i<0?8:16:0)|a)}static normalized(t,n=0){let r=t[n];t.sort((e,t)=>e.from-t.from),n=t.indexOf(r);for(let r=1;r<t.length;r++){let i=t[r],a=t[r-1];if(i.empty?i.from<=a.to:i.from<a.to){let o=a.from,s=Math.max(i.to,a.to);r<=n&&n--,t.splice(--r,2,i.anchor>i.head?e.range(s,o):e.range(o,s))}}return new e(t,n)}};function J$(e,t){for(let n of e.ranges)if(n.to>t)throw RangeError(`Selection points outside of document`)}var Y$=0,Y=class e{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(t={}){return new e(t.combine||(e=>e),t.compareInput||((e,t)=>e===t),t.compare||(t.combine?(e,t)=>e===t:X$),!!t.static,t.enables)}of(e){return new Z$([],this,0,e)}compute(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new Z$(e,this,1,t)}computeN(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new Z$(e,this,2,t)}from(e,t){return t||=e=>e,this.compute([e],n=>t(n.field(e)))}};function X$(e,t){return e==t||e.length==t.length&&e.every((e,n)=>e===t[n])}var Z$=class{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=Y$++}dynamicSlot(e){let t=this.value,n=this.facet.compareInput,r=this.id,i=e[r]>>1,a=this.type==2,o=!1,s=!1,c=[];for(let t of this.dependencies)t==`doc`?o=!0:t==`selection`?s=!0:(e[t.id]??1)&1||c.push(e[t.id]);return{create(e){return e.values[i]=t(e),1},update(e,r){if(o&&r.docChanged||s&&(r.docChanged||r.selection)||$$(e,c)){let r=t(e);if(a?!Q$(r,e.values[i],n):!n(r,e.values[i]))return e.values[i]=r,1}return 0},reconfigure:(e,o)=>{let s,c=o.config.address[r];if(c!=null){let r=u1(o,c);if(this.dependencies.every(t=>t instanceof Y?o.facet(t)===e.facet(t):t instanceof t1?o.field(t,!1)==e.field(t,!1):!0)||(a?Q$(s=t(e),r,n):n(s=t(e),r)))return e.values[i]=r,0}else s=t(e);return e.values[i]=s,1}}}};function Q$(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 $$(e,t){let n=!1;for(let r of t)l1(e,r)&1&&(n=!0);return n}function Lye(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=u1(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)l1(e,t);return e.values[o]=s(e),1},update(e,n){if(!$$(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=$$(e,r),c=i.config.facets[t.id],l=i.facet(t);if(c&&!a&&X$(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)}}}var e1=Y.define({static:!0}),t1=class e{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(t){let n=new e(Y$++,t.create,t.update,t.compare||((e,t)=>e===t),t);return t.provide&&(n.provides=t.provide(n)),n}create(e){return(e.facet(e1).find(e=>e.field==this)?.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(e1),i=n.facet(e1),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,e1.of({field:this,create:e})]}get extension(){return this}},n1={lowest:4,low:3,default:2,high:1,highest:0};function r1(e){return t=>new a1(t,e)}var i1={highest:r1(n1.highest),high:r1(n1.high),default:r1(n1.default),low:r1(n1.low),lowest:r1(n1.lowest)},a1=class{constructor(e,t){this.inner=e,this.prec=t}},o1=class e{of(e){return new s1(this,e)}reconfigure(t){return e.reconfigure.of({compartment:this,extension:t})}get(e){return e.config.compartments.get(this)}},s1=class{constructor(e,t){this.compartment=e,this.inner=t}},c1=class e{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(t,n,r){let i=[],a=Object.create(null),o=new Map;for(let e of Rye(t,n,o))e instanceof t1?i.push(e):(a[e.facet.id]||(a[e.facet.id]=[])).push(e);let s=Object.create(null),c=[],l=[];for(let e of i)s[e.id]=l.length<<1,l.push(t=>e.slot(t));let u=r?.config.facets;for(let e in a){let t=a[e],n=t[0].facet,i=u&&u[e]||[];if(t.every(e=>e.type==0))if(s[n.id]=c.length<<1|1,X$(i,t))c.push(r.facet(n));else{let e=n.combine(t.map(e=>e.value));c.push(r&&n.compare(e,r.facet(n))?r.facet(n):e)}else{for(let e of t)e.type==0?(s[e.id]=c.length<<1|1,c.push(e.value)):(s[e.id]=l.length<<1,l.push(t=>e.dynamicSlot(t)));s[n.id]=l.length<<1,l.push(e=>Lye(e,n,t))}}return new e(t,o,l.map(e=>e(s)),s,c,a)}};function Rye(e,t,n){let r=[[],[],[],[],[]],i=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 s1&&n.delete(e.compartment)}if(i.set(e,o),Array.isArray(e))for(let t of e)a(t,o);else if(e instanceof s1){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 a1)a(e.inner,e.prec);else if(e instanceof t1)r[o].push(e),e.provides&&a(e.provides,o);else if(e instanceof Z$)r[o].push(e),e.facet.extensions&&a(e.facet.extensions,n1.default);else{let t=e.extension;if(!t)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,n1.default),r.reduce((e,t)=>e.concat(t))}function l1(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 u1(e,t){return t&1?e.config.staticValues[t>>1]:e.values[t>>1]}var d1=Y.define(),f1=Y.define({combine:e=>e.some(e=>e),static:!0}),p1=Y.define({combine:e=>e.length?e[0]:void 0,static:!0}),m1=Y.define(),h1=Y.define(),g1=Y.define(),_1=Y.define({combine:e=>e.length?e[0]:!1}),v1=class{constructor(e,t){this.type=e,this.value=t}static define(){return new zye}},zye=class{of(e){return new v1(this,e)}},Bye=class{constructor(e){this.map=e}of(e){return new y1(this,e)}},y1=class e{constructor(e,t){this.type=e,this.value=t}map(t){let n=this.type.map(this.value,t);return n===void 0?void 0:n==this.value?this:new e(this.type,n)}is(e){return this.type==e}static define(e={}){return new Bye(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}};y1.reconfigure=y1.define(),y1.appendConfig=y1.define();var b1=class e{constructor(t,n,r,i,a,o){this.startState=t,this.changes=n,this.selection=r,this.effects=i,this.annotations=a,this.scrollIntoView=o,this._doc=null,this._state=null,r&&J$(r,n.newLength),a.some(t=>t.type==e.time)||(this.annotations=a.concat(e.time.of(Date.now())))}static create(t,n,r,i,a,o){return new e(t,n,r,i,a,o)}get newDoc(){return 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(t){let n=this.annotation(e.userEvent);return!!(n&&(n==t||n.length>t.length&&n.slice(0,t.length)==t&&n[t.length]==`.`))}};b1.time=v1.define(),b1.userEvent=v1.define(),b1.addToHistory=v1.define(),b1.remote=v1.define();function Vye(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 x1(e,t,n){let r,i,a;return n?(r=t.changes,i=B$.empty(t.changes.length),a=e.changes.compose(t.changes)):(r=t.changes.map(e.changes),i=e.changes.mapDesc(t.changes,!0),a=e.changes.compose(r)),{changes:a,selection:t.selection?t.selection.map(i):e.selection?.map(r),effects:y1.mapEffects(e.effects,r).concat(y1.mapEffects(t.effects,i)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function S1(e,t,n){let r=t.selection,i=w1(t.annotations);return t.userEvent&&(i=i.concat(b1.userEvent.of(t.userEvent))),{changes:t.changes instanceof B$?t.changes:B$.of(t.changes||[],n,e.facet(p1)),selection:r&&(r instanceof J?r:J.single(r.anchor,r.head)),effects:w1(t.effects),annotations:i,scrollIntoView:!!t.scrollIntoView}}function C1(e,t,n){let r=S1(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=x1(r,S1(e,t[i],a?r.changes.newLength:e.doc.length),a)}let i=b1.create(e,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return Uye(n?Hye(i):i)}function Hye(e){let t=e.startState,n=!0;for(let r of t.facet(m1)){let t=r(e);if(t===!1){n=!1;break}Array.isArray(t)&&(n=n===!0?t:Vye(n,t))}if(n!==!0){let r,i;if(n===!1)i=e.changes.invertedDesc,r=B$.empty(t.doc.length);else{let t=e.changes.filter(n);r=t.changes,i=t.filtered.mapDesc(t.changes).invertedDesc}e=b1.create(t,r,e.selection&&e.selection.map(i),y1.mapEffects(e.effects,i),e.annotations,e.scrollIntoView)}let r=t.facet(h1);for(let n=r.length-1;n>=0;n--){let i=r[n](e);e=i instanceof b1?i:Array.isArray(i)&&i.length==1&&i[0]instanceof b1?i[0]:C1(t,w1(i),!1)}return e}function Uye(e){let t=e.startState,n=t.facet(g1),r=e;for(let i=n.length-1;i>=0;i--){let a=n[i](e);a&&Object.keys(a).length&&(r=x1(r,S1(t,a,e.changes.newLength),!0))}return r==e?e:b1.create(t,e.changes,e.selection,r.effects,r.annotations,r.scrollIntoView)}var Wye=[];function w1(e){return e==null?Wye:Array.isArray(e)?e:[e]}var T1=(function(e){return e[e.Word=0]=`Word`,e[e.Space=1]=`Space`,e[e.Other=2]=`Other`,e})(T1||={}),Gye=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,E1;try{E1=RegExp(`[\\p{Alphabetic}\\p{Number}_]`,`u`)}catch{}function Kye(e){if(E1)return E1.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>`€`&&(n.toUpperCase()!=n.toLowerCase()||Gye.test(n)))return!0}return!1}function qye(e){return t=>{if(!/\S/.test(t))return T1.Space;if(Kye(t))return T1.Word;for(let n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return T1.Word;return T1.Other}}var D1=class e{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++)l1(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 l1(this,n),u1(this,n)}update(...e){return C1(this,e,!0)}applyTransaction(t){let n=this.config,{base:r,compartments:i}=n;for(let e of t.effects)e.is(o1.reconfigure)?(n&&=(i=new Map,n.compartments.forEach((e,t)=>i.set(t,e)),null),i.set(e.value.compartment,e.value.extension)):e.is(y1.reconfigure)?(n=null,r=e.value):e.is(y1.appendConfig)&&(n=null,r=w1(r).concat(e.value));let a;n?a=t.startState.values.slice():(n=c1.resolve(r,i,this),a=new e(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(e,t)=>t.reconfigure(e,this),null).values);let o=t.startState.facet(f1)?t.newSelection:t.newSelection.asSingle();new e(n,t.newDoc,o,a,(e,n)=>n.update(e,t),t)}replaceSelection(e){return typeof e==`string`&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:J.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=w1(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=y1.mapEffects(a,c).concat(y1.mapEffects(w1(o.effects),l))}return{changes:r,selection:J.create(i,t.mainIndex),effects:a}}changes(t=[]){return t instanceof B$?t:B$.of(t,this.doc.length,this.facet(e.lineSeparator))}toText(t){return w$.of(t.split(this.facet(e.lineSeparator)||L$))}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:(l1(this,t),u1(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 t1&&this.config.address[r.id]!=null&&(t[n]=r.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(t,n={},r){if(!t||typeof t.doc!=`string`)throw RangeError(`Invalid JSON representation for EditorState`);let i=[];if(r){for(let e in r)if(Object.prototype.hasOwnProperty.call(t,e)){let n=r[e],a=t[e];i.push(n.init(e=>n.spec.fromJSON(a,e)))}}return e.create({doc:t.doc,selection:J.fromJSON(t.selection),extensions:n.extensions?i.concat([n.extensions]):i})}static create(t={}){let n=c1.resolve(t.extensions||[],new Map),r=t.doc instanceof w$?t.doc:w$.of((t.doc||``).split(n.staticFacet(e.lineSeparator)||L$)),i=t.selection?t.selection instanceof J?t.selection:J.single(t.selection.anchor,t.selection.head):J.single(0);return J$(i,r.length),n.staticFacet(f1)||(i=i.asSingle()),new e(n,r,i,n.dynamicSlots.map(()=>null),(e,t)=>t.create(e),null)}get tabSize(){return this.facet(e.tabSize)}get lineBreak(){return this.facet(e.lineSeparator)||`
744
- `}get readOnly(){return this.facet(_1)}phrase(t,...n){for(let n of this.facet(e.phrases))if(Object.prototype.hasOwnProperty.call(n,t)){t=n[t];break}return n.length&&(t=t.replace(/\$(\$|\d*)/g,(e,t)=>{if(t==`$`)return`$`;let r=+(t||1);return!r||r>n.length?e:n[r-1]})),t}languageDataAt(e,t,n=-1){let r=[];for(let i of this.facet(d1))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 qye(t.length?t[0]:``)}wordAt(e){let{text:t,from:n,length:r}=this.doc.lineAt(e),i=this.charCategorizer(e),a=e-n,o=e-n;for(;a>0;){let e=N$(t,a,!1);if(i(t.slice(e,a))!=T1.Word)break;a=e}for(;o<r;){let e=N$(t,o);if(i(t.slice(o,e))!=T1.Word)break;o=e}return a==o?null:J.range(a+n,o+n)}};D1.allowMultipleSelections=f1,D1.tabSize=Y.define({combine:e=>e.length?e[0]:4}),D1.lineSeparator=p1,D1.readOnly=_1,D1.phrases=Y.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])}}),D1.languageData=d1,D1.changeFilter=m1,D1.transactionFilter=h1,D1.transactionExtender=g1,o1.reconfigure=y1.define();function O1(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}var k1=class{eq(e){return this==e}range(e,t=e){return j1.create(e,t,this)}};k1.prototype.startSide=k1.prototype.endSide=0,k1.prototype.point=!1,k1.prototype.mapMode=R$.TrackDel;function A1(e,t){return e==t||e.constructor==t.constructor&&e.eq(t)}var j1=class e{constructor(e,t,n){this.from=e,this.to=t,this.value=n}static create(t,n,r){return new e(t,n,r)}};function M1(e,t){return e.from-t.from||e.value.startSide-t.value.startSide}var Jye=class e{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(t,n){let r=[],i=[],a=[],o=-1,s=-1;for(let e=0;e<this.value.length;e++){let c=this.value[e],l=this.from[e]+t,u=this.to[e]+t,d,f;if(l==u){let e=n.mapPos(l,c.startSide,c.mapMode);if(e==null||(d=f=e,c.startSide!=c.endSide&&(f=n.mapPos(l,c.endSide),f<d)))continue}else if(d=n.mapPos(l,c.startSide),f=n.mapPos(u,c.endSide),d>f||d==f&&c.startSide>0&&c.endSide<=0)continue;(f-d||c.endSide-c.startSide)<0||(o<0&&(o=d),c.point&&(s=Math.max(s,f-d)),r.push(c),i.push(d-o),a.push(f-o))}return{mapped:r.length?new e(i,a,r,s):null,pos:o}}},N1=class e{constructor(e,t,n,r){this.chunkPos=e,this.chunk=t,this.nextLayer=n,this.maxPoint=r}static create(t,n,r,i){return new e(t,n,r,i)}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(t){let{add:n=[],sort:r=!1,filterFrom:i=0,filterTo:a=this.length}=t,o=t.filter;if(n.length==0&&!o)return this;if(r&&(n=n.slice().sort(M1)),this.isEmpty)return n.length?e.of(n):this;let s=new I1(this,null,-1).goto(0),c=0,l=[],u=new P1;for(;s.value||c<n.length;)if(c<n.length&&(s.from-n[c].from||s.startSide-n[c].value.startSide)>=0){let e=n[c++];u.addInner(e.from,e.to,e.value)||l.push(e)}else s.rangeIndex==1&&s.chunkIndex<this.chunk.length&&(c==n.length||this.chunkEnd(s.chunkIndex)<n[c].from)&&(!o||i>this.chunkEnd(s.chunkIndex)||a<this.chunkPos[s.chunkIndex])&&u.addChunk(this.chunkPos[s.chunkIndex],this.chunk[s.chunkIndex])?s.nextChunk():((!o||i>s.to||a<s.from||o(s.from,s.to,s.value))&&(u.addInner(s.from,s.to,s.value)||l.push(j1.create(s.from,s.to,s.value))),s.next());return u.finishInner(this.nextLayer.isEmpty&&!l.length?e.empty:this.nextLayer.update({add:l,filter:o,filterFrom:i,filterTo:a}))}map(t){if(t.empty||this.isEmpty)return this;let n=[],r=[],i=-1;for(let e=0;e<this.chunk.length;e++){let a=this.chunkPos[e],o=this.chunk[e],s=t.touchesRange(a,a+o.length);if(s===!1)i=Math.max(i,o.maxPoint),n.push(o),r.push(t.mapPos(a));else if(s===!0){let{mapped:e,pos:s}=o.map(a,t);e&&(i=Math.max(i,e.maxPoint),n.push(e),r.push(s))}}let a=this.nextLayer.map(t);return n.length==0?a:new e(r,n,a||e.empty,i)}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 L1.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return L1.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=F1(a,o,n),c=new z1(a,s,i),l=new z1(o,s,i);n.iterGaps((e,t,n)=>B1(c,e,l,t,n,r)),n.empty&&n.length==0&&B1(c,0,l,0,0,r)}static eq(e,t,n=0,r){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=F1(i,a),s=new z1(i,o,0).goto(n),c=new z1(a,o,0).goto(n);for(;;){if(s.to!=c.to||!V1(s.active,c.active)||s.point&&(!c.point||!A1(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 z1(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 P1;for(let r of e instanceof j1?[e]:t?Yye(e):e)n.add(r.from,r.to,r.value);return n.finish()}static join(t){if(!t.length)return e.empty;let n=t[t.length-1];for(let r=t.length-2;r>=0;r--)for(let i=t[r];i!=e.empty;i=i.nextLayer)n=new e(i.chunkPos,i.chunk,n,Math.max(i.maxPoint,n.maxPoint));return n}};N1.empty=new N1([],[],null,-1);function Yye(e){if(e.length>1)for(let t=e[0],n=1;n<e.length;n++){let r=e[n];if(M1(t,r)>0)return e.slice().sort(M1);t=r}return e}N1.empty.nextLayer=N1.empty;var P1=class e{finishChunk(e){this.chunks.push(new Jye(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(t,n,r){this.addInner(t,n,r)||(this.nextLayer||=new e).add(t,n,r)}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(N1.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=N1.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}};function F1(e,t,n){let r=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=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?.touchesRange(a,a+e.chunk[t].length)&&i.add(e.chunk[t])}return i}var I1=class{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}},L1=class e{constructor(e){this.heap=e}static from(t,n=null,r=-1){let i=[];for(let e=0;e<t.length;e++)for(let a=t[e];!a.isEmpty;a=a.nextLayer)a.maxPoint>=r&&i.push(new I1(a,n,r,e));return i.length==1?i[0]:new e(i)}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--)R1(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--)R1(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(),R1(this.heap,0)}}};function R1(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}}var z1=class{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=L1.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){H1(this.active,e),H1(this.activeTo,e),H1(this.activeRank,e),this.minActive=W1(this.active,this.activeTo)}addActive(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++;U1(this.active,t,n),U1(this.activeTo,t,r),U1(this.activeRank,t,i),e&&U1(e,t,this.cursor.from),this.minActive=W1(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&&H1(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 B1(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&&A1(e.point,n.point)&&V1(e.activeForPoint(e.to),n.activeForPoint(n.to))||a.comparePoint(s,d,e.point,n.point),t=!1):(t&&a.boundChange(s),d>s&&!V1(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 V1(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n]&&!A1(e[n],t[n]))return!1;return!0}function H1(e,t){for(let n=t,r=e.length-1;n<r;n++)e[n]=e[n+1];e.pop()}function U1(e,t,n){for(let n=e.length-1;n>=t;n--)e[n+1]=e[n];e[t]=n}function W1(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 G1(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=N$(e,i));return r}function Xye(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=N$(e,r)}return r===!0?-1:e.length}for(var K1=`ͼ`,q1=typeof Symbol>`u`?`__ͼ`:Symbol.for(K1),J1=typeof Symbol>`u`?`__styleSet`+Math.floor(Math.random()*1e8):Symbol(`styleSet`),Y1=typeof globalThis<`u`?globalThis:typeof window<`u`?window:{},X1=class{constructor(e,t){this.rules=[];let{finish:n}=t||{};function r(e){return/^@/.test(e)?[e]:e.split(/,\s*/)}function i(e,t,a,o){let s=[],c=/^@(\w+)\b/.exec(e[0]),l=c&&c[1]==`keyframes`;if(c&&t==null)return a.push(e[0]+`;`);for(let n in t){let o=t[n];if(/&/.test(n))i(n.split(/,\s*/).map(t=>e.map(e=>t.replace(/&/,e))).reduce((e,t)=>e.concat(t)),o,a);else if(o&&typeof o==`object`){if(!c)throw RangeError(`The value of a property (`+n+`) should be a primitive value.`);i(r(n),o,s,l)}else o!=null&&s.push(n.replace(/_.*/,``).replace(/[A-Z]/g,e=>`-`+e.toLowerCase())+`: `+o+`;`)}(s.length||l)&&a.push((n&&!c&&!o?e.map(n):e).join(`, `)+` {`+s.join(` `)+`}`)}for(let t in e)i(r(t),e[t],this.rules)}getRules(){return this.rules.join(`
745
- `)}static newName(){let e=Y1[q1]||1;return Y1[q1]=e+1,K1+e.toString(36)}static mount(e,t,n){let r=e[J1],i=n&&n.nonce;r?i&&r.setNonce(i):r=new Zye(e,i),r.mount(Array.isArray(t)?t:[t],e)}},Z1=new Map,Zye=class{constructor(e,t){let n=e.ownerDocument||e,r=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let t=Z1.get(n);if(t)return e[J1]=t;this.sheet=new r.CSSStyleSheet,Z1.set(n,this)}else this.styleTag=n.createElement(`style`),t&&this.styleTag.setAttribute(`nonce`,t);this.modules=[],e[J1]=this}mount(e,t){let n=this.sheet,r=0,i=0;for(let t=0;t<e.length;t++){let a=e[t],o=this.modules.indexOf(a);if(o<i&&o>-1&&(this.modules.splice(o,1),i--,o=-1),o==-1){if(this.modules.splice(i++,0,a),n)for(let e=0;e<a.rules.length;e++)n.insertRule(a.rules[e],r++)}else{for(;i<o;)r+=this.modules[i++].rules.length;r+=a.rules.length,i++}}if(n)t.adoptedStyleSheets.indexOf(this.sheet)<0&&(t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets]);else{let e=``;for(let t=0;t<this.modules.length;t++)e+=this.modules[t].getRules()+`
746
- `;this.styleTag.textContent=e;let n=t.head||t;this.styleTag.parentNode!=n&&n.insertBefore(this.styleTag,n.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute(`nonce`)!=e&&this.styleTag.setAttribute(`nonce`,e)}},Q1={8:`Backspace`,9:`Tab`,10:`Enter`,12:`NumLock`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,44:`PrintScreen`,45:`Insert`,46:`Delete`,59:`;`,61:`=`,91:`Meta`,92:`Meta`,106:`*`,107:`+`,108:`,`,109:`-`,110:`.`,111:`/`,144:`NumLock`,145:`ScrollLock`,160:`Shift`,161:`Shift`,162:`Control`,163:`Control`,164:`Alt`,165:`Alt`,173:`-`,186:`;`,187:`=`,188:`,`,189:`-`,190:`.`,191:`/`,192:"`",219:`[`,220:`\\`,221:`]`,222:`'`},$1={48:`)`,49:`!`,50:`@`,51:`#`,52:`$`,53:`%`,54:`^`,55:`&`,56:`*`,57:`(`,59:`:`,61:`+`,173:`_`,186:`:`,187:`+`,188:`<`,189:`_`,190:`>`,191:`?`,192:`~`,219:`{`,220:`|`,221:`}`,222:`"`},Qye=typeof navigator<`u`&&/Mac/.test(navigator.platform),$ye=typeof navigator<`u`&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),e0=0;e0<10;e0++)Q1[48+e0]=Q1[96+e0]=String(e0);for(var e0=1;e0<=24;e0++)Q1[e0+111]=`F`+e0;for(var e0=65;e0<=90;e0++)Q1[e0]=String.fromCharCode(e0+32),$1[e0]=String.fromCharCode(e0);for(var t0 in Q1)$1.hasOwnProperty(t0)||($1[t0]=Q1[t0]);function ebe(e){var t=!(Qye&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||$ye&&e.shiftKey&&e.key&&e.key.length==1||e.key==`Unidentified`)&&e.key||(e.shiftKey?$1:Q1)[e.keyCode]||e.key||`Unidentified`;return t==`Esc`&&(t=`Escape`),t==`Del`&&(t=`Delete`),t==`Left`&&(t=`ArrowLeft`),t==`Up`&&(t=`ArrowUp`),t==`Right`&&(t=`ArrowRight`),t==`Down`&&(t=`ArrowDown`),t}function n0(){var e=arguments[0];typeof e==`string`&&(e=document.createElement(e));var t=1,n=arguments[1];if(n&&typeof n==`object`&&n.nodeType==null&&!Array.isArray(n)){for(var r in n)if(Object.prototype.hasOwnProperty.call(n,r)){var i=n[r];typeof i==`string`?e.setAttribute(r,i):i!=null&&(e[r]=i)}t++}for(;t<arguments.length;t++)r0(e,arguments[t]);return e}function r0(e,t){if(typeof t==`string`)e.appendChild(document.createTextNode(t));else if(t!=null)if(t.nodeType!=null)e.appendChild(t);else if(Array.isArray(t))for(var n=0;n<t.length;n++)r0(e,t[n]);else throw RangeError(`Unsupported child node: `+t)}var i0=typeof navigator<`u`?navigator:{userAgent:``,vendor:``,platform:``},a0=typeof document<`u`?document:{documentElement:{style:{}}},o0=/Edge\/(\d+)/.exec(i0.userAgent),s0=/MSIE \d/.test(i0.userAgent),c0=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(i0.userAgent),l0=!!(s0||c0||o0),u0=!l0&&/gecko\/(\d+)/i.test(i0.userAgent),d0=!l0&&/Chrome\/(\d+)/.exec(i0.userAgent),f0=`webkitFontSmoothing`in a0.documentElement.style,p0=!l0&&/Apple Computer/.test(i0.vendor),m0=p0&&(/Mobile\/\w+/.test(i0.userAgent)||i0.maxTouchPoints>2),X={mac:m0||/Mac/.test(i0.platform),windows:/Win/.test(i0.platform),linux:/Linux|X11/.test(i0.platform),ie:l0,ie_version:s0?a0.documentMode||6:c0?+c0[1]:o0?+o0[1]:0,gecko:u0,gecko_version:u0?+(/Firefox\/(\d+)/.exec(i0.userAgent)||[0,0])[1]:0,chrome:!!d0,chrome_version:d0?+d0[1]:0,ios:m0,android:/Android\b/.test(i0.userAgent),webkit:f0,webkit_version:f0?+(/\bAppleWebKit\/(\d+)/.exec(i0.userAgent)||[0,0])[1]:0,safari:p0,safari_version:p0?+(/\bVersion\/(\d+(\.\d+)?)/.exec(i0.userAgent)||[0,0])[1]:0,tabSize:a0.documentElement.style.tabSize==null?`-moz-tab-size`:`tab-size`};function h0(e,t){for(let n in e)n==`class`&&t.class?t.class+=` `+e.class:n==`style`&&t.style?t.style+=`;`+e.style:t[n]=e[n];return t}var g0=Object.create(null);function _0(e,t,n){if(e==t)return!0;e||=g0,t||=g0;let r=Object.keys(e),i=Object.keys(t);if(r.length-(n&&r.indexOf(n)>-1?1:0)!=i.length-(n&&i.indexOf(n)>-1?1:0))return!1;for(let a of r)if(a!=n&&(i.indexOf(a)==-1||e[a]!==t[a]))return!1;return!0}function tbe(e,t){for(let n=e.attributes.length-1;n>=0;n--){let r=e.attributes[n].name;t[r]??e.removeAttribute(r)}for(let n in t){let r=t[n];n==`style`?e.style.cssText=r:e.getAttribute(n)!=r&&e.setAttribute(n,r)}}function v0(e,t,n){let r=!1;if(t)for(let i in t)n&&i in n||(r=!0,i==`style`?e.style.cssText=``:e.removeAttribute(i));if(n)for(let i in n)t&&t[i]==n[i]||(r=!0,i==`style`?e.style.cssText=n[i]:e.setAttribute(i,n[i]));return r}function nbe(e){let t=Object.create(null);for(let n=0;n<e.attributes.length;n++){let r=e.attributes[n];t[r.name]=r.value}return t}var y0=class{eq(e){return!1}updateDOM(e,t,n){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,n){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}},b0=(function(e){return e[e.Text=0]=`Text`,e[e.WidgetBefore=1]=`WidgetBefore`,e[e.WidgetAfter=2]=`WidgetAfter`,e[e.WidgetRange=3]=`WidgetRange`,e})(b0||={}),x0=class extends k1{constructor(e,t,n,r){super(),this.startSide=e,this.endSide=t,this.widget=n,this.spec=r}get heightRelevant(){return!1}static mark(e){return new S0(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),n=!!e.block;return t+=n&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new w0(e,t,t,n,e.widget||null,!1)}static replace(e){let t=!!e.block,n,r;if(e.isBlockGap)n=-5e8,r=4e8;else{let{start:i,end:a}=T0(e,t);n=(i?t?-3e8:-1:5e8)-1,r=(a?t?2e8:1:-6e8)+1}return new w0(e,n,r,t,e.widget||null,!0)}static line(e){return new C0(e)}static set(e,t=!1){return N1.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};x0.none=N1.empty;var S0=class e extends x0{constructor(e){let{start:t,end:n}=T0(e);super(t?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||`span`,this.attrs=e.class&&e.attributes?h0(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||g0}eq(t){return this==t||t instanceof e&&this.tagName==t.tagName&&_0(this.attrs,t.attrs)}range(e,t=e){if(e>=t)throw RangeError(`Mark decorations may not be empty`);return super.range(e,t)}};S0.prototype.point=!1;var C0=class e extends x0{constructor(e){super(-2e8,-2e8,null,e)}eq(t){return t instanceof e&&this.spec.class==t.spec.class&&_0(this.spec.attributes,t.spec.attributes)}range(e,t=e){if(t!=e)throw RangeError(`Line decoration ranges must be zero-length`);return super.range(e,t)}};C0.prototype.mapMode=R$.TrackBefore,C0.prototype.point=!0;var w0=class e extends x0{constructor(e,t,n,r,i,a){super(t,n,i,e),this.block=r,this.isReplace=a,this.mapMode=r?t<=0?R$.TrackBefore:R$.TrackAfter:R$.TrackDel}get type(){return this.startSide==this.endSide?this.startSide<=0?b0.WidgetBefore:b0.WidgetAfter:b0.WidgetRange}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof e&&rbe(this.widget,t.widget)&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw RangeError(`Invalid range for replacement decoration`);if(!this.isReplace&&t!=e)throw RangeError(`Widget decorations can only have zero-length ranges`);return super.range(e,t)}};w0.prototype.point=!0;function T0(e,t=!1){let{inclusiveStart:n,inclusiveEnd:r}=e;return n??=e.inclusive,r??=e.inclusive,{start:n??t,end:r??t}}function rbe(e,t){return e==t||!!(e&&t&&e.compare(t))}function E0(e,t,n,r=0){let i=n.length-1;i>=0&&n[i]+r>=e?n[i]=Math.max(n[i],t):n.push(e,t)}var D0=class e extends k1{constructor(e,t,n){super(),this.tagName=e,this.attributes=t,this.rank=n}eq(t){return t==this||t instanceof e&&this.tagName==t.tagName&&_0(this.attributes,t.attributes)}static create(t){return new e(t.tagName,t.attributes||g0,t.rank==null?50:Math.max(0,Math.min(t.rank,100)))}static set(e,t=!1){return N1.of(e,t)}};D0.prototype.startSide=D0.prototype.endSide=-1;function O0(e){let t;return t=e.nodeType==11?e.getSelection?e:e.ownerDocument:e,t.getSelection()}function k0(e,t){return t?e==t||e.contains(t.nodeType==1?t:t.parentNode):!1}function A0(e,t){if(!t.anchorNode)return!1;try{return k0(e,t.anchorNode)}catch{return!1}}function j0(e){return e.nodeType==3?H0(e,0,e.nodeValue.length).getClientRects():e.nodeType==1?e.getClientRects():[]}function M0(e,t,n,r){return n?F0(e,t,n,r,-1)||F0(e,t,n,r,1):!1}function N0(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t}function P0(e){return e.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(e.nodeName)}function F0(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:I0(e))){if(e.nodeName==`DIV`)return!1;let n=e.parentNode;if(!n||n.nodeType!=1)return!1;t=N0(e)+(i<0?0:1),e=n}else if(e.nodeType==1){if(e=e.childNodes[t+(i<0?-1:0)],e.nodeType==1&&e.contentEditable==`false`)return!1;t=i<0?I0(e):0}else return!1}}function I0(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function L0(e,t){let n=t?e.left:e.right;return{left:n,right:n,top:e.top,bottom:e.bottom}}function ibe(e){let t=e.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.innerWidth,top:0,bottom:e.innerHeight}}function R0(e,t){let n=t.width/e.offsetWidth,r=t.height/e.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(t.width-e.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(t.height-e.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}function abe(e,t,n,r,i,a,o,s){let c=e.ownerDocument,l=c.defaultView||window;for(let u=e,d=!1;u&&!d;)if(u.nodeType==1){let e,f=u==c.body,p=1,m=1;if(f)e=ibe(l);else{if(/^(fixed|sticky)$/.test(getComputedStyle(u).position)&&(d=!0),u.scrollHeight<=u.clientHeight&&u.scrollWidth<=u.clientWidth){u=u.assignedSlot||u.parentNode;continue}let t=u.getBoundingClientRect();({scaleX:p,scaleY:m}=R0(u,t)),e={left:t.left,right:t.left+u.clientWidth*p,top:t.top,bottom:t.top+u.clientHeight*m}}let h=0,g=0;if(i==`nearest`)t.top<e.top+o?(g=t.top-(e.top+o),n>0&&t.bottom>e.bottom+g&&(g=t.bottom-e.bottom+o)):t.bottom>e.bottom-o&&(g=t.bottom-e.bottom+o,n<0&&t.top-g<e.top&&(g=t.top-(e.top+o)));else{let r=t.bottom-t.top,a=e.bottom-e.top;g=(i==`center`&&r<=a?t.top+r/2-a/2:i==`start`||i==`center`&&n<0?t.top-o:t.bottom-a+o)-e.top}if(r==`nearest`?t.left<e.left+a?(h=t.left-(e.left+a),n>0&&t.right>e.right+h&&(h=t.right-e.right+a)):t.right>e.right-a&&(h=t.right-e.right+a,n<0&&t.left<e.left+h&&(h=t.left-(e.left+a))):h=(r==`center`?t.left+(t.right-t.left)/2-(e.right-e.left)/2:r==`start`==s?t.left-a:t.right-(e.right-e.left)+a)-e.left,h||g)if(f)l.scrollBy(h,g);else{let e=0,n=0;if(g){let e=u.scrollTop;u.scrollTop+=g/m,n=(u.scrollTop-e)*m}if(h){let t=u.scrollLeft;u.scrollLeft+=h/p,e=(u.scrollLeft-t)*p}t={left:t.left-e,top:t.top-n,right:t.right-e,bottom:t.bottom-n},e&&Math.abs(e-h)<1&&(r=`nearest`),n&&Math.abs(n-g)<1&&(i=`nearest`)}if(f)break;(t.top<e.top||t.bottom>e.bottom||t.left<e.left||t.right>e.right)&&(t={left:Math.max(t.left,e.left),right:Math.min(t.right,e.right),top:Math.max(t.top,e.top),bottom:Math.min(t.bottom,e.bottom)}),u=u.assignedSlot||u.parentNode}else if(u.nodeType==11)u=u.host;else break}function z0(e,t=!0){let n=e.ownerDocument,r=null,i=null;for(let a=e.parentNode;a&&!(a==n.body||(!t||r)&&i);)if(a.nodeType==1)!i&&a.scrollHeight>a.clientHeight&&(i=a),t&&!r&&a.scrollWidth>a.clientWidth&&(r=a),a=a.assignedSlot||a.parentNode;else if(a.nodeType==11)a=a.host;else break;return{x:r,y:i}}var obe=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:n}=e;this.set(t,Math.min(e.anchorOffset,t?I0(t):0),n,Math.min(e.focusOffset,n?I0(n):0))}set(e,t,n,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=r}},B0=null;X.safari&&X.safari_version>=26&&(B0=!1);function V0(e){if(e.setActive)return e.setActive();if(B0)return e.focus(B0);let t=[];for(let n=e;n&&(t.push(n,n.scrollTop,n.scrollLeft),n!=n.ownerDocument);n=n.parentNode);if(e.focus(B0==null?{get preventScroll(){return B0={preventScroll:!0},!0}}:void 0),!B0){B0=!1;for(let e=0;e<t.length;){let n=t[e++],r=t[e++],i=t[e++];n.scrollTop!=r&&(n.scrollTop=r),n.scrollLeft!=i&&(n.scrollLeft=i)}}}var sbe;function H0(e,t,n=t){let r=sbe||=document.createRange();return r.setEnd(e,n),r.setStart(e,t),r}function U0(e,t,n,r){let i={key:t,code:t,keyCode:n,which:n,cancelable:!0};r&&({altKey:i.altKey,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,metaKey:i.metaKey}=r);let a=new KeyboardEvent(`keydown`,i);a.synthetic=!0,e.dispatchEvent(a);let o=new KeyboardEvent(`keyup`,i);return o.synthetic=!0,e.dispatchEvent(o),a.defaultPrevented||o.defaultPrevented}function cbe(e){for(;e;){if(e&&(e.nodeType==9||e.nodeType==11&&e.host))return e;e=e.assignedSlot||e.parentNode}return null}function lbe(e,t){let n=t.focusNode,r=t.focusOffset;if(!n||t.anchorNode!=n||t.anchorOffset!=r)return!1;for(r=Math.min(r,I0(n));;)if(r){if(n.nodeType!=1)return!1;let e=n.childNodes[r-1];e.contentEditable==`false`?r--:(n=e,r=I0(n))}else if(n==e)return!0;else r=N0(n),n=n.parentNode}function W0(e){return e instanceof Window?e.pageYOffset>Math.max(0,e.document.documentElement.scrollHeight-e.innerHeight-4):e.scrollTop>Math.max(1,e.scrollHeight-e.clientHeight-4)}function G0(e,t){for(let n=e,r=t;;)if(n.nodeType==3&&r>0)return{node:n,offset:r};else if(n.nodeType==1&&r>0){if(n.contentEditable==`false`)return null;n=n.childNodes[r-1],r=I0(n)}else if(n.parentNode&&!P0(n))r=N0(n),n=n.parentNode;else return null}function K0(e,t){for(let n=e,r=t;;)if(n.nodeType==3&&r<n.nodeValue.length)return{node:n,offset:r};else if(n.nodeType==1&&r<n.childNodes.length){if(n.contentEditable==`false`)return null;n=n.childNodes[r],r=0}else if(n.parentNode&&!P0(n))r=N0(n)+1,n=n.parentNode;else return null}var q0=class e{constructor(e,t,n=!0){this.node=e,this.offset=t,this.precise=n}static before(t,n){return new e(t.parentNode,N0(t),n)}static after(t,n){return new e(t.parentNode,N0(t)+1,n)}},J0=(function(e){return e[e.LTR=0]=`LTR`,e[e.RTL=1]=`RTL`,e})(J0||={}),Y0=J0.LTR,X0=J0.RTL;function Z0(e){let t=[];for(let n=0;n<e.length;n++)t.push(1<<e[n]);return t}var ube=Z0(`88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008`),dbe=Z0(`4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333`),Q0=Object.create(null),$0=[];for(let e of[`()`,`[]`,`{}`]){let t=e.charCodeAt(0),n=e.charCodeAt(1);Q0[t]=n,Q0[n]=-t}function e2(e){return e<=247?ube[e]:1424<=e&&e<=1524?2:1536<=e&&e<=1785?dbe[e-1536]:1774<=e&&e<=2220?4:8192<=e&&e<=8204?256:64336<=e&&e<=65023?4:1}var fbe=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/,t2=class{get dir(){return this.level%2?X0:Y0}constructor(e,t,n){this.from=e,this.to=t,this.level=n}side(e,t){return this.dir==t==e?this.to:this.from}forward(e,t){return e==(this.dir==t)}static find(e,t,n,r){let i=-1;for(let a=0;a<e.length;a++){let o=e[a];if(o.from<=t&&o.to>=t){if(o.level==n)return a;(i<0||(r==0?e[i].level>o.level:r<0?o.from<t:o.to>t))&&(i=a)}}if(i<0)throw RangeError(`Index out of range`);return i}};function n2(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r.from!=i.from||r.to!=i.to||r.direction!=i.direction||!n2(r.inner,i.inner))return!1}return!0}var r2=[];function pbe(e,t,n,r,i){for(let a=0;a<=r.length;a++){let o=a?r[a-1].to:t,s=a<r.length?r[a].from:n,c=a?256:i;for(let t=o,n=c,r=c;t<s;t++){let i=e2(e.charCodeAt(t));i==512?i=n:i==8&&r==4&&(i=16),r2[t]=i==4?2:i,i&7&&(r=i),n=i}for(let e=o,t=c,r=c;e<s;e++){let i=r2[e];if(i==128)e<s-1&&t==r2[e+1]&&t&24?i=r2[e]=t:r2[e]=256;else if(i==64){let i=e+1;for(;i<s&&r2[i]==64;)i++;let a=e&&t==8||i<n&&r2[i]==8?r==1?1:8:256;for(let t=e;t<i;t++)r2[t]=a;e=i-1}else i==8&&r==1&&(r2[e]=1);t=i,i&7&&(r=i)}}}function mbe(e,t,n,r,i){let a=i==1?2:1;for(let o=0,s=0,c=0;o<=r.length;o++){let l=o?r[o-1].to:t,u=o<r.length?r[o].from:n;for(let t=l,n,r,o;t<u;t++)if(r=Q0[n=e.charCodeAt(t)])if(r<0){for(let e=s-3;e>=0;e-=3)if($0[e+1]==-r){let n=$0[e+2],r=n&2?i:n&4?n&1?a:i:0;r&&(r2[t]=r2[$0[e]]=r),s=e;break}}else if($0.length==189)break;else $0[s++]=t,$0[s++]=n,$0[s++]=c;else if((o=r2[t])==2||o==1){let e=o==i;c=+!e;for(let t=s-3;t>=0;t-=3){let n=$0[t+2];if(n&2)break;if(e)$0[t+2]|=2;else{if(n&4)break;$0[t+2]|=4}}}}}function hbe(e,t,n,r){for(let i=0,a=r;i<=n.length;i++){let o=i?n[i-1].to:e,s=i<n.length?n[i].from:t;for(let c=o;c<s;){let o=r2[c];if(o==256){let o=c+1;for(;;)if(o==s){if(i==n.length)break;o=n[i++].to,s=i<n.length?n[i].from:t}else if(r2[o]==256)o++;else break;let l=a==1,u=l==((o<t?r2[o]:r)==1)?l?1:2:r;for(let t=o,r=i,a=r?n[r-1].to:e;t>c;)t==a&&(t=n[--r].from,a=r?n[r-1].to:e),r2[--t]=u;c=o}else a=o,c++}}}function i2(e,t,n,r,i,a,o){let s=r%2?2:1;if(r%2==i%2)for(let c=t,l=0;c<n;){let t=!0,u=!1;if(l==a.length||c<a[l].from){let e=r2[c];e!=s&&(t=!1,u=e==16)}let d=!t&&s==1?[]:null,f=t?r:r+1,p=c;run:for(;;)if(l<a.length&&p==a[l].from){if(u)break run;let m=a[l];if(!t)for(let e=m.to,t=l+1;;){if(e==n)break run;if(t<a.length&&a[t].from==e)e=a[t++].to;else if(r2[e]==s)break run;else break}l++,d?d.push(m):(m.from>c&&o.push(new t2(c,m.from,f)),a2(e,m.direction==Y0==!(f%2)?r:r+1,i,m.inner,m.from,m.to,o),c=m.to),p=m.to}else if(p==n||(t?r2[p]!=s:r2[p]==s))break;else p++;d?i2(e,c,p,r+1,i,d,o):c<p&&o.push(new t2(c,p,f)),c=p}else for(let c=n,l=a.length;c>t;){let n=!0,u=!1;if(!l||c>a[l-1].to){let e=r2[c-1];e!=s&&(n=!1,u=e==16)}let d=!n&&s==1?[]:null,f=n?r:r+1,p=c;run:for(;;)if(l&&p==a[l-1].to){if(u)break run;let m=a[--l];if(!n)for(let e=m.from,n=l;;){if(e==t)break run;if(n&&a[n-1].to==e)e=a[--n].from;else if(r2[e-1]==s)break run;else break}d?d.push(m):(m.to<c&&o.push(new t2(m.to,c,f)),a2(e,m.direction==Y0==!(f%2)?r:r+1,i,m.inner,m.from,m.to,o),c=m.from),p=m.from}else if(p==t||(n?r2[p-1]!=s:r2[p-1]==s))break;else p--;d?i2(e,p,c,r+1,i,d,o):p<c&&o.push(new t2(p,c,f)),c=p}}function a2(e,t,n,r,i,a,o){let s=t%2?2:1;pbe(e,i,a,r,s),mbe(e,i,a,r,s),hbe(i,a,r,s),i2(e,i,a,t,n,r,o)}function gbe(e,t,n){if(!e)return[new t2(0,0,+(t==X0))];if(t==Y0&&!n.length&&!fbe.test(e))return o2(e.length);if(n.length)for(;e.length>r2.length;)r2[r2.length]=256;let r=[],i=t==Y0?0:1;return a2(e,i,i,n,0,e.length,r),r}function o2(e){return[new t2(0,e,0)]}var s2=``;function _be(e,t,n,r,i){let a=r.head-e.from,o=t2.find(t,a,r.bidiLevel??-1,r.assoc),s=t[o],c=s.side(i,n);if(a==c){let e=o+=i?1:-1;if(e<0||e>=t.length)return null;s=t[o=e],a=s.side(!i,n),c=s.side(i,n)}let l=N$(e.text,a,s.forward(i,n));(l<s.from||l>s.to)&&(l=c),s2=e.text.slice(Math.min(a,l),Math.max(a,l));let u=o==(i?t.length-1:0)?null:t[o+(i?1:-1)];return u&&l==c&&u.level+ +!i<s.level?J.cursor(u.side(!i,n)+e.from,u.forward(i,n)?1:-1,u.level):J.cursor(l+e.from,s.forward(i,n)?-1:1,s.level)}function vbe(e,t,n){for(let r=t;r<n;r++){let t=e2(e.charCodeAt(r));if(t==1)return Y0;if(t==2||t==4)return X0}return Y0}var c2=Y.define(),l2=Y.define(),u2=Y.define(),d2=Y.define(),f2=Y.define(),p2=Y.define(),m2=Y.define(),h2=Y.define(),g2=Y.define(),_2=Y.define({combine:e=>e.some(e=>e)}),ybe=Y.define({combine:e=>e.some(e=>e)}),v2=Y.define(),y2=class e{constructor(e,t,n,r,i,a=!1){this.range=e,this.y=t,this.x=n,this.yMargin=r,this.xMargin=i,this.isSnapshot=a}map(t){return t.empty?this:new e(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(t){return this.range.to<=t.doc.length?this:new e(J.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}},b2=y1.define({map:(e,t)=>e.map(t)}),x2=y1.define();function S2(e,t,n){let r=e.facet(d2);r.length?r[0](t):window.onerror&&window.onerror(String(t),n,void 0,void 0,t)||(n?console.error(n+`:`,t):console.error(t))}var C2=Y.define({combine:e=>e.length?e[0]:!0}),bbe=0,w2=Y.define({combine(e){return e.filter((t,n)=>{for(let r=0;r<n;r++)if(e[r].plugin==t.plugin)return!1;return!0})}}),T2=class e{constructor(e,t,n,r,i){this.id=e,this.create=t,this.domEventHandlers=n,this.domEventObservers=r,this.baseExtensions=i(this),this.extension=this.baseExtensions.concat(w2.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(w2.of({plugin:this,arg:e}))}static define(t,n){let{eventHandlers:r,eventObservers:i,provide:a,decorations:o}=n||{};return new e(bbe++,t,r,i,e=>{let t=[];return o&&t.push(k2.of(t=>{let n=t.plugin(e);return n?o(n):x0.none})),a&&t.push(a(e)),t})}static fromClass(t,n){return e.define((e,n)=>new t(e,n),n)}},E2=class{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(!this.value){if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){S2(e.state,t,`CodeMirror plugin crashed`),this.deactivate()}}else if(this.mustUpdate){let e=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(e)}catch(t){if(S2(e.state,t,`CodeMirror plugin crashed`),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}return this}destroy(e){if(this.value?.destroy)try{this.value.destroy()}catch(t){S2(e.state,t,`CodeMirror plugin crashed`)}}deactivate(){this.spec=this.value=null}},D2=Y.define(),O2=Y.define(),k2=Y.define(),A2=Y.define(),j2=Y.define(),M2=Y.define(),N2=Y.define();function P2(e,t){let n=e.state.facet(N2);if(!n.length)return n;let r=n.map(t=>t instanceof Function?t(e):t),i=[];return N1.spans(r,t.from,t.to,{point(){},span(e,n,r,a){let o=e-t.from,s=n-t.from,c=i;for(let e=r.length-1;e>=0;e--,a--){let n=r[e].spec.bidiIsolate,i;if(n??=vbe(t.text,o,s),a>0&&c.length&&(i=c[c.length-1]).to==o&&i.direction==n)i.to=s,c=i.inner;else{let e={from:o,to:s,direction:n,inner:[]};c.push(e),c=e.inner}}}}),i}var F2=Y.define();function I2(e){let t=0,n=0,r=0,i=0;for(let a of e.state.facet(F2)){let o=a(e);o&&(o.left!=null&&(t=Math.max(t,o.left)),o.right!=null&&(n=Math.max(n,o.right)),o.top!=null&&(r=Math.max(r,o.top)),o.bottom!=null&&(i=Math.max(i,o.bottom)))}return{left:t,right:n,top:r,bottom:i}}var L2=Y.define(),R2=class e{constructor(e,t,n,r){this.fromA=e,this.toA=t,this.fromB=n,this.toB=r}join(t){return new e(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}addToSet(e){let t=e.length,n=this;for(;t>0;t--){let r=e[t-1];if(!(r.fromA>n.toA)){if(r.toA<n.fromA)break;n=n.join(r),e.splice(t-1,1)}}return e.splice(t,0,n),e}static extendWithRanges(t,n){if(n.length==0)return t;let r=[];for(let i=0,a=0,o=0;;){let s=i<t.length?t[i].fromB:1e9,c=a<n.length?n[a]:1e9,l=Math.min(s,c);if(l==1e9)break;let u=l+o,d=l,f=u;for(;;)if(a<n.length&&n[a]<=d){let e=n[a+1];a+=2,d=Math.max(d,e);for(let e=i;e<t.length&&t[e].fromB<=d;e++)o=t[e].toA-t[e].toB;f=Math.max(f,e+o)}else if(i<t.length&&t[i].fromB<=d){let e=t[i++];d=Math.max(d,e.toB),f=Math.max(f,e.toA),o=e.toA-e.toB}else break;r.push(new e(u,f,l,d))}return r}},z2=class e{constructor(e,t,n){this.view=e,this.state=t,this.transactions=n,this.flags=0,this.startState=e.state,this.changes=B$.empty(this.startState.doc.length);for(let e of n)this.changes=this.changes.compose(e.changes);let r=[];this.changes.iterChangedRanges((e,t,n,i)=>r.push(new R2(e,t,n,i))),this.changedRanges=r}static create(t,n,r){return new e(t,n,r)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}},xbe=[],B2=class{constructor(e,t,n=0){this.dom=e,this.length=t,this.flags=n,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return xbe}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let e=this.domAttrs;e&&tbe(this.dom,e)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:``)+(this.breakAfter?`#`:``)}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,t=this.posAtStart){let n=t;for(let t of this.children){if(t==e)return n;n+=t.length+t.breakAfter}throw RangeError(`Invalid child in posBefore`)}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t){return null}domPosFor(e,t){let n=N0(this.dom),r=this.length?e>0:t>0;return new q0(this.parent.dom,n+ +!!r,e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof U2)return e;return null}static get(e){return e.cmTile}},V2=class extends B2{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let t=this.dom,n=null,r,i=e?.node==t?e:null,a=0;for(let o of this.children){if(o.sync(e),a+=o.length+o.breakAfter,r=n?n.nextSibling:t.firstChild,i&&r!=o.dom&&(i.written=!0),o.dom.parentNode==t)for(;r&&r!=o.dom;)r=H2(r);else t.insertBefore(o.dom,r);n=o.dom}for(r=n?n.nextSibling:t.firstChild,i&&r&&(i.written=!0);r;)r=H2(r);this.length=a}};function H2(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}var U2=class extends V2{constructor(e,t){super(t),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let t=B2.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],n=this,r=0,i=0;;)if(r==n.children.length){if(!t.length)return;n=n.parent,n.breakAfter&&i++,r=t.pop()}else{let a=n.children[r++];if(a instanceof W2)t.push(r),n=a,r=0;else{let t=i+a.length,n=e(a,i);if(n!==void 0)return n;i=t+a.breakAfter}}}resolveBlock(e,t){let n,r=-1,i,a=-1;if(this.blockTiles((o,s)=>{let c=s+o.length;if(e>=s&&e<=c){if(o.isWidget()&&t>=-1&&t<=1){if(o.flags&32)return!0;o.flags&16&&(n=void 0)}(s<e||e==c&&(t<-1?o.length:o.covers(1)))&&(!n||!o.isWidget()&&n.isWidget())&&(n=o,r=e-s),(c>e||e==s&&(t>1?o.length:o.covers(-1)))&&(!i||!o.isWidget()&&i.isWidget())&&(i=o,a=e-s)}}),!n&&!i)throw Error(`No tile at position `+e);return n&&t<0||!i?{tile:n,offset:r}:{tile:i,offset:a}}},W2=class e extends V2{constructor(e,t){super(e),this.wrapper=t}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(t,n){let r=new e(n||document.createElement(t.tagName),t);return n||(r.flags|=4),r}},G2=class e extends V2{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(t,n,r){let i=new e(n||document.createElement(`div`),t);return(!n||!r)&&(i.flags|=4),i}get domAttrs(){return this.attrs}resolveInline(e,t,n){let r=null,i=-1,a=null,o=-1;function s(e,c){for(let l=0,u=0;l<e.children.length&&u<=c;l++){let d=e.children[l],f=u+d.length;f>=c&&(d.isComposite()?s(d,c-u):(!a||a.isHidden&&(t>0||n&&Cbe(a,d)))&&(f>c||d.flags&32)?(a=d,o=c-u):(u<c||d.flags&16&&!d.isHidden)&&(r=d,i=c-u)),u=f}}s(this,e);let c=(t<0?r:a)||r||a;return c?{tile:c,offset:c==r?i:o}:null}coordsIn(e,t){let n=this.resolveInline(e,t,!0);return n?n.tile.coordsIn(Math.max(0,n.offset),t):Sbe(this)}domIn(e,t){let n=this.resolveInline(e,t);if(n){let{tile:e,offset:r}=n;if(this.dom.contains(e.dom))return e.isText()?new q0(e.dom,Math.min(e.dom.nodeValue.length,r)):e.domPosFor(r,e.flags&16?1:e.flags&32?-1:t);let i=n.tile.parent,a=!1;for(let e of i.children){if(a)return new q0(e.dom,0);e==n.tile&&(a=!0)}}return new q0(this.dom,0)}};function Sbe(e){let t=e.dom.lastChild;if(!t)return e.dom.getBoundingClientRect();let n=j0(t);return n[n.length-1]||null}function Cbe(e,t){let n=e.coordsIn(0,1),r=t.coordsIn(0,1);return n&&r&&r.top<n.bottom}var K2=class e extends V2{constructor(e,t){super(e),this.mark=t}get domAttrs(){return this.mark.attrs}static of(t,n){let r=new e(n||document.createElement(t.tagName),t);return n||(r.flags|=4),r}},q2=class e extends B2{constructor(e,t){super(e,t.length),this.text=t}sync(e){this.flags&2||(super.sync(e),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(e,t){let n=this.dom.nodeValue.length;e>n&&(e=n);let r=e,i=e,a=0;e==0&&t<0||e==n&&t>=0?X.chrome||X.gecko||(e?(r--,a=1):i<n&&(i++,a=-1)):t<0?r--:i<n&&i++;let o=H0(this.dom,r,i).getClientRects();if(!o.length)return null;let s=o[(a?a<0:t>=0)?0:o.length-1];return X.safari&&!a&&s.width==0&&(s=Array.prototype.find.call(o,e=>e.width)||s),a?L0(s,a<0):s||null}static of(t,n){let r=new e(n||document.createTextNode(t),t);return n||(r.flags|=2),r}},J2=class e extends B2{constructor(e,t,n,r){super(e,t,r),this.widget=n}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,t){return this.coordsInWidget(e,t,!1)}coordsInWidget(e,t,n){let r=this.widget.coordsAt(this.dom,e,t);if(r)return r;if(n)return L0(this.dom.getBoundingClientRect(),this.length?e==0:t<=0);{let t=this.dom.getClientRects(),n=null;if(!t.length)return null;let r=this.flags&16?!0:this.flags&32?!1:e>0;for(let i=r?t.length-1:0;n=t[i],!(e>0?i==0:i==t.length-1||n.top<n.bottom);i+=r?-1:1);return L0(n,!r)}}get overrideDOMText(){if(!this.length)return w$.empty;let{root:e}=this;if(!e)return w$.empty;let t=this.posAtStart;return e.view.state.doc.slice(t,t+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(t,n,r,i,a){return a||(a=t.toDOM(n),t.editable||(a.contentEditable=`false`)),new e(a,r,t,i)}},Y2=class extends B2{constructor(e){let t=document.createElement(`img`);t.className=`cm-widgetBuffer`,t.setAttribute(`aria-hidden`,`true`),super(t,0,e)}get isHidden(){return!0}get overrideDOMText(){return w$.empty}coordsIn(e){return this.dom.getBoundingClientRect()}},wbe=class{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,n){let{tile:r,index:i,beforeBreak:a,parents:o}=this;for(;e||t>0;)if(!r.isComposite())if(i==r.length)a=!!r.breakAfter,{tile:r,index:i}=o.pop(),i++;else if(e){let t=Math.min(e,r.length-i);n&&n.skip(r,i,i+t),e-=t,i+=t}else break;else if(a){if(!e)break;n&&n.break(),e--,a=!1}else if(i==r.children.length){if(!e&&!o.length)break;n&&n.leave(r),a=!!r.breakAfter,{tile:r,index:i}=o.pop(),i++}else{let s=r.children[i],c=s.breakAfter;(t>0?s.length<=e:s.length<e)&&(!n||n.skip(s,0,s.length)!==!1||!s.isComposite)?(a=!!c,i++,e-=s.length):(o.push({tile:r,index:i}),r=s,i=0,n&&s.isComposite()&&n.enter(s))}return this.tile=r,this.index=i,this.beforeBreak=a,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}},Tbe=class{constructor(e,t,n,r){this.from=e,this.to=t,this.wrapper=n,this.rank=r}},Ebe=class{constructor(e,t,n){this.cache=e,this.root=t,this.blockWrappers=n,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(e,t,n,r){this.flushBuffer();let i=this.ensureMarks(t,n),a=i.lastChild;if(a&&a.isText()&&!(a.flags&8)&&a.length+e.length<512){this.cache.reused.set(a,2);let t=i.children[i.children.length-1]=new q2(a.dom,a.text+e);t.parent=i}else i.append(r||q2.of(e,this.cache.find(q2)?.dom));this.pos+=e.length,this.afterWidget=null}addComposition(e,t){let n=this.curLine;n.dom!=t.line.dom&&(n.setDOM(this.cache.reused.has(t.line)?$2(t.line.dom):t.line.dom),this.cache.reused.set(t.line,2));let r=n;for(let e=t.marks.length-1;e>=0;e--){let n=t.marks[e],i=r.lastChild;if(i instanceof K2&&i.mark.eq(n.mark))i.dom!=n.dom&&i.setDOM($2(n.dom)),r=i;else{if(this.cache.reused.get(n)){let e=B2.get(n.dom);e&&e.setDOM($2(n.dom))}let e=K2.of(n.mark,n.dom);r.append(e),r=e}this.cache.reused.set(n,2)}let i=B2.get(e.text);i&&this.cache.reused.set(i,2);let a=new q2(e.text,e.text.nodeValue);a.flags|=8,this.pos=e.range.toB,r.append(a)}addInlineWidget(e,t,n){let r=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);r||this.flushBuffer();let i=this.ensureMarks(t,n);!r&&!(e.flags&16)&&i.append(this.getBuffer(1)),i.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,n){this.flushBuffer(),this.ensureMarks(t,n).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let t=this.afterWidget||this.lastBlock;t.length+=e,this.pos+=e}addLineStart(e,t){e||=Q2;let n=G2.start(e,t||this.cache.find(G2)?.dom,!!t);this.getBlockPos().append(this.lastBlock=this.curLine=n)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,t){let n=this.curLine;for(let r=e.length-1;r>=0;r--){let i=e[r],a;if(t>0&&(a=n.lastChild)&&a instanceof K2&&a.mark.eq(i))n=a,t--;else{let e=K2.of(i,this.cache.find(K2,e=>e.mark.eq(i))?.dom);n.append(e),n=e,t=0}}return n}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!Z2(this.curLine,!1)||e.dom.nodeName!=`BR`&&e.isWidget()&&!(X.ios&&Z2(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(t4,0,32)||new J2(t4.toDOM(),0,t4,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to<this.pos&&this.wrappers.splice(e,1);for(let e=this.blockWrappers;e.value&&e.from<=this.pos;e.next())if(e.to>=this.pos){let t=e.rank*102+e.value.rank,n=new Tbe(e.from,e.to,e.value,t),r=this.wrappers.length;for(;r>0&&(this.wrappers[r-1].rank-n.rank||this.wrappers[r-1].to-n.to)<0;)r--;this.wrappers.splice(r,0,n)}this.wrapperPos=this.pos}getBlockPos(){this.updateBlockWrappers();let e=this.root;for(let t of this.wrappers){let n=e.lastChild;if(t.from<this.pos&&n instanceof W2&&n.wrapper.eq(t.wrapper))e=n;else{let n=W2.of(t.wrapper,this.cache.find(W2,e=>e.wrapper.eq(t.wrapper))?.dom);e.append(n),e=n}}return e}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let t=2|(e<0?16:32),n=this.cache.find(Y2,void 0,1);return n&&(n.flags=t),n||new Y2(t)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}},Dbe=class{constructor(e){this.skipCount=0,this.text=``,this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text=``,this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:t,lineBreak:n,done:r}=this.cursor.next(this.skipCount);if(this.skipCount=0,r)throw Error(`Ran out of text content when drawing inline views`);this.text=t;let i=this.textOff=Math.min(e,t.length);return n?null:t.slice(0,i)}let t=Math.min(this.text.length,this.textOff+e),n=this.text.slice(this.textOff,t);return this.textOff=t,n}},X2=[J2,G2,q2,K2,Y2,W2,U2];for(let e=0;e<X2.length;e++)X2[e].bucket=e;var Obe=class{constructor(e){this.view=e,this.buckets=X2.map(()=>[]),this.index=X2.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,n=this.buckets[t];n.length<6?n.push(e):n[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,n=2){let r=e.bucket,i=this.buckets[r],a=this.index[r];for(let e=i.length-1;e>=0;e--){let o=(e+a)%i.length,s=i[o];if((!t||t(s))&&!this.reused.has(s))return i.splice(o,1),o<a&&this.index[r]--,this.reused.set(s,n),s}return null}findWidget(e,t,n){let r=this.buckets[0];if(r.length)for(let i=0,a=0;;i++){if(i==r.length){if(a)return null;a=1,i=0}let o=r[i];if(!this.reused.has(o)&&(a==0?o.widget.compare(e):o.widget.constructor==e.constructor&&e.updateDOM(o.dom,this.view,o.widget)))return r.splice(i,1),i<this.index[0]&&this.index[0]--,o.widget==e&&o.length==t&&(o.flags&497)==n?(this.reused.set(o,1),o):(this.reused.set(o,2),new J2(o.dom,t,e,o.flags&-498|n))}}reuse(e){return this.reused.set(e,1),e}maybeReuse(e,t=2){if(!this.reused.has(e))return this.reused.set(e,t),e.dom}clear(){for(let e=0;e<this.buckets.length;e++)this.buckets[e].length=this.index[e]=0}},kbe=class{constructor(e,t,n,r,i){this.view=e,this.decorations=r,this.disallowBlockEffectsFor=i,this.openWidget=!1,this.openMarks=0,this.cache=new Obe(e),this.text=new Dbe(e.state.doc),this.builder=new Ebe(this.cache,new U2(e,e.contentDOM),N1.iter(n)),this.cache.reused.set(t,2),this.old=new wbe(t),this.reuseWalker={skip:(e,t,n)=>{if(this.cache.add(e),e.isComposite())return!1},enter:e=>this.cache.add(e),leave:()=>{},break:()=>{}}}run(e,t){let n=t&&this.getCompositionContext(t.text);for(let r=0,i=0,a=0;;){let o=a<e.length?e[a++]:null,s=o?o.fromA:this.old.root.length;if(s>r){let e=s-r;this.preserve(e,!a,!o),r=s,i+=e}if(!o)break;t&&o.fromA<=t.range.fromA&&o.toA>=t.range.toA?(this.forward(o.fromA,t.range.fromA,t.range.fromA<t.range.toA?1:-1),this.emit(i,t.range.fromB),this.cache.clear(),this.builder.addComposition(t,n),this.text.skip(t.range.toB-t.range.fromB),this.forward(t.range.fromA,o.toA),this.emit(t.range.toB,o.toB)):(this.forward(o.fromA,o.toA),this.emit(i,o.toB)),i=o.toB,r=o.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(e,t,n){let r=Mbe(this.old),i=this.openMarks;this.old.advance(e,n?1:-1,{skip:(e,t,n)=>{if(e.isWidget())if(this.openWidget)this.builder.continueWidget(n-t);else{let a=n>0||t<e.length?J2.of(e.widget,this.view,n-t,e.flags&496,this.cache.maybeReuse(e)):this.cache.reuse(e);a.flags&256?(a.flags&=-2,this.builder.addBlockWidget(a)):(this.builder.ensureLine(null),this.builder.addInlineWidget(a,r,i),i=r.length)}else if(e.isText())this.builder.ensureLine(null),!t&&n==e.length&&!this.cache.reused.has(e)?this.builder.addText(e.text,r,i,this.cache.reuse(e)):(this.cache.add(e),this.builder.addText(e.text.slice(t,n),r,i)),i=r.length;else if(e.isLine())e.flags&=-2,this.cache.reused.set(e,1),this.builder.addLine(e);else if(e instanceof Y2)this.cache.add(e);else if(e instanceof K2)this.builder.ensureLine(null),this.builder.addMark(e,r,i),this.cache.reused.set(e,1),i=r.length;else return!1;this.openWidget=!1},enter:e=>{e.isLine()?this.builder.addLineStart(e.attrs,this.cache.maybeReuse(e)):(this.cache.add(e),e instanceof K2&&r.unshift(e.mark)),this.openWidget=!1},leave:e=>{e.isLine()?r.length&&=i=0:e instanceof K2&&(r.shift(),i=Math.min(i,r.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let n=null,r=this.builder,i=0,a=N1.spans(this.decorations,e,t,{point:(e,t,a,o,s,c)=>{if(a instanceof w0){if(this.disallowBlockEffectsFor[c]){if(a.block)throw RangeError(`Block decorations may not be specified via plugins`);if(t>this.view.state.doc.lineAt(e).to)throw RangeError(`Decorations that replace line breaks may not be specified via plugins`)}if(i=o.length,s>o.length)r.continueWidget(t-e);else{let i=a.widget||(a.block?e4.block:e4.inline),c=Abe(a),l=this.cache.findWidget(i,t-e,c)||J2.of(i,this.view,t-e,c);a.block?(a.startSide>0&&r.addLineStartIfNotCovered(n),r.addBlockWidget(l)):(r.ensureLine(n),r.addInlineWidget(l,o,s))}n=null}else n=jbe(n,a);t>e&&this.text.skip(t-e)},span:(e,t,i,a)=>{for(let o=e;o<t;){let s=this.text.next(Math.min(512,t-o));s==null?(r.addLineStartIfNotCovered(n),r.addBreak(),o++):(r.ensureLine(n),r.addText(s,i,o==e?a:i.length),o+=s.length),n=null}}});r.addLineStartIfNotCovered(n),this.openWidget=a>i,this.openMarks=a}forward(e,t,n=1){t-e<=10?this.old.advance(t-e,n,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,n,this.reuseWalker))}getCompositionContext(e){let t=[],n=null;for(let r=e.parentNode;;r=r.parentNode){let e=B2.get(r);if(r==this.view.contentDOM)break;e instanceof K2?t.push(e):e?.isLine()?n=e:e instanceof W2||(r.nodeName==`DIV`&&!n&&r!=this.view.contentDOM?n=new G2(r,Q2):n||t.push(K2.of(new S0({tagName:r.nodeName.toLowerCase(),attributes:nbe(r)}),r)))}return{line:n,marks:t}}};function Z2(e,t){let n=e=>{for(let r of e.children)if((t?r.isText():r.length)||n(r))return!0;return!1};return n(e)}function Abe(e){let t=e.isReplace?(e.startSide<0?64:0)|(e.endSide>0?128:0):e.startSide>0?32:16;return e.block&&(t|=256),t}var Q2={class:`cm-line`};function jbe(e,t){let n=t.spec.attributes,r=t.spec.class;return!n&&!r?e:(e||={class:`cm-line`},n&&h0(n,e),r&&(e.class+=` `+r),e)}function Mbe(e){let t=[];for(let n=e.parents.length;n>1;n--){let r=n==e.parents.length?e.tile:e.parents[n].tile;r instanceof K2&&t.push(r.mark)}return t}function $2(e){let t=B2.get(e);return t&&t.setDOM(e.cloneNode()),e}var e4=class extends y0{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}};e4.inline=new e4(`span`),e4.block=new e4(`div`);var t4=new class extends y0{toDOM(){return document.createElement(`br`)}get isHidden(){return!0}get editable(){return!0}},n4=class{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=x0.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new U2(e,e.contentDOM),this.updateInner([new R2(0,0,0,e.state.doc.length)],null)}update(e){let t=e.changedRanges;this.minWidth>0&&t.length&&(t.every(({fromA:e,toA:t})=>t<this.minWidthFrom||e>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let n=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(this.domChanged?.newSel?n=this.domChanged.newSel.head:!Vbe(e.changes,this.hasComposition)&&!e.selectionSet&&(n=e.state.selection.main.head));let r=n>-1?Pbe(this.view,e.changes,n):null;if(this.domChanged=null,this.hasComposition){let{from:n,to:r}=this.hasComposition;t=new R2(n,r,e.changes.mapPos(n,-1),e.changes.mapPos(r,1)).addToSet(t.slice())}this.hasComposition=r?{from:r.range.fromB,to:r.range.toB}:null,(X.ie||X.chrome)&&!r&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let i=this.decorations,a=this.blockWrappers;this.updateDeco();let o=Lbe(i,this.decorations,e.changes);o.length&&(t=R2.extendWithRanges(t,o));let s=zbe(a,this.blockWrappers,e.changes);return s.length&&(t=R2.extendWithRanges(t,s)),r&&!t.some(e=>e.fromA<=r.range.fromA&&e.toA>=r.range.toA)&&(t=r.range.addToSet(t.slice())),this.tile.flags&2&&t.length==0?!1:(this.updateInner(t,r),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:n}=this.view;n.ignore(()=>{if(t||e.length){let n=this.tile,r=new kbe(this.view,n,this.blockWrappers,this.decorations,this.dynamicDecorationMap);t&&B2.get(t.text)&&r.cache.reused.set(B2.get(t.text),2),this.tile=r.run(e,t),r4(n,r.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+`px`,this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+`px`:``;let r=X.chrome||X.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(r),r&&(r.written||n.selectionRange.focusNode!=r.node||!this.tile.dom.contains(r.node))&&(this.forceSelection=!0),this.tile.dom.style.height=``});let r=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let e of this.tile.children)e.isWidget()&&e.widget instanceof a4&&r.push(e.dom);n.updateGaps(r)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let t of e.transactions)for(let e of t.effects)e.is(x2)&&(this.editContextFormatting=e.value)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let{dom:n}=this.tile,r=this.view.root.activeElement,i=r==n,a=!i&&!(this.view.state.facet(C2)||n.tabIndex>-1)&&A0(n,this.view.observer.selectionRange)&&!(r&&n.contains(r));if(!(i||t||a))return;let o=this.forceSelection;this.forceSelection=!1;let s=this.view.state.selection.main,c,l;if(s.empty?l=c=this.inlineDOMNearPos(s.anchor,s.assoc||1):(l=this.inlineDOMNearPos(s.head,s.head==s.from?1:-1),c=this.inlineDOMNearPos(s.anchor,s.anchor==s.from?1:-1)),X.gecko&&s.empty&&!this.hasComposition&&Nbe(c)){let e=document.createTextNode(``);this.view.observer.ignore(()=>c.node.insertBefore(e,c.node.childNodes[c.offset]||null)),c=l=new q0(e,0),o=!0}let u=this.view.observer.selectionRange;(o||!u.focusNode||(!M0(c.node,c.offset,u.anchorNode,u.anchorOffset)||!M0(l.node,l.offset,u.focusNode,u.focusOffset))&&!this.suppressWidgetCursorChange(u,s))&&(this.view.observer.ignore(()=>{X.android&&X.chrome&&n.contains(u.focusNode)&&Bbe(u.focusNode,n)&&(n.blur(),n.focus({preventScroll:!0}));let e=O0(this.view.root);if(e)if(s.empty){if(X.gecko){let e=Fbe(c.node,c.offset);if(e&&e!=3){let t=(e==1?G0:K0)(c.node,c.offset);t&&(c=new q0(t.node,t.offset))}}e.collapse(c.node,c.offset),s.bidiLevel!=null&&e.caretBidiLevel!==void 0&&(e.caretBidiLevel=s.bidiLevel)}else if(e.extend){e.collapse(c.node,c.offset);try{e.extend(l.node,l.offset)}catch{}}else{let t=document.createRange();s.anchor>s.head&&([c,l]=[l,c]),t.setEnd(l.node,l.offset),t.setStart(c.node,c.offset),e.removeAllRanges(),e.addRange(t)}a&&this.view.root.activeElement==n&&(n.blur(),r&&r.focus())}),this.view.observer.setSelectionRange(c,l)),this.impreciseAnchor=c.precise?null:new q0(u.anchorNode,u.anchorOffset),this.impreciseHead=l.precise?null:new q0(u.focusNode,u.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&M0(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,n=O0(e.root),{anchorNode:r,anchorOffset:i}=e.observer.selectionRange;if(!n||!t.empty||!t.assoc||!n.modify)return;let a=this.lineAt(t.head,t.assoc);if(!a)return;let o=a.posAtStart;if(t.head==o||t.head==o+a.length)return;let s=this.coordsAt(t.head,-1),c=this.coordsAt(t.head,1);if(!s||!c||s.bottom>c.top)return;let l=this.domAtPos(t.head+t.assoc,t.assoc);n.collapse(l.node,l.offset),n.modify(`move`,t.assoc<0?`forward`:`backward`,`lineboundary`),e.observer.readSelectionRange();let u=e.observer.selectionRange;e.docView.posFromDOM(u.anchorNode,u.anchorOffset)!=t.from&&n.collapse(r,i)}posFromDOM(e,t){let n=this.tile.nearest(e);if(!n)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let r=n.posAtStart;if(n.isComposite()){let i;if(e==n.dom)i=n.dom.childNodes[t];else{let r=I0(e)==0?0:t==0?-1:1;for(;;){let t=e.parentNode;if(t==n.dom)break;r==0&&t.firstChild!=t.lastChild&&(r=e==t.firstChild?-1:1),e=t}i=r<0?e:e.nextSibling}if(i==n.dom.firstChild)return r;for(;i&&!B2.get(i);)i=i.nextSibling;if(!i)return r+n.length;for(let e=0,t=r;;e++){let r=n.children[e];if(r.dom==i)return t;t+=r.length+r.breakAfter}}else if(n.isText())return e==n.dom?r+t:r+(t?n.length:0);else return r}domAtPos(e,t){let{tile:n,offset:r}=this.tile.resolveBlock(e,t);return n.isWidget()?n.domPosFor(e,t):n.domIn(r,t)}inlineDOMNearPos(e,t){let n,r=-1,i=!1,a,o=-1,s=!1;return this.tile.blockTiles((t,c)=>{if(t.isWidget()){if(t.flags&32&&c>=e)return!0;t.flags&16&&(i=!0)}else{let l=c+t.length;if(c<=e&&(n=t,r=e-c,i=l<e),l>=e&&!a&&(a=t,o=e-c,s=c>e),c>e&&a)return!0}}),!n&&!a?this.domAtPos(e,t):(i&&a?n=null:s&&n&&(a=null),n&&t<0||!a?n.domIn(r,t):a.domIn(o,t))}coordsAt(e,t){let{tile:n,offset:r}=this.tile.resolveBlock(e,t);return n.isWidget()?n.widget instanceof a4?null:n.coordsInWidget(r,t,!0):n.coordsIn(r,t)}lineAt(e,t){let{tile:n}=this.tile.resolveBlock(e,t);return n.isLine()?n:null}coordsForChar(e){let{tile:t,offset:n}=this.tile.resolveBlock(e,1);if(!t.isLine())return null;function r(e,t){if(e.isComposite())for(let n of e.children){if(n.length>=t){let e=r(n,t);if(e)return e}if(t-=n.length,t<0)break}else if(e.isText()&&t<e.length){let n=N$(e.text,t);if(n==t)return null;let r=H0(e.dom,t,n).getClientRects();for(let e=0;e<r.length;e++){let t=r[e];if(e==r.length-1||t.top<t.bottom&&t.left<t.right)return t}}return null}return r(t,n)}measureVisibleLineHeights(e){let t=[],{from:n,to:r}=e,i=this.view.contentDOM.clientWidth,a=i>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,o=-1,s=this.view.textDirection==J0.LTR,c=0,l=(e,u,d)=>{for(let f=0;f<e.children.length&&!(u>r);f++){let r=e.children[f],p=u+r.length,m=r.dom.getBoundingClientRect(),{height:h}=m;if(d&&!f&&(c+=m.top-d.top),r instanceof W2)p>n&&l(r,u,m);else if(u>=n&&(c>0&&t.push(-c),t.push(h+c),c=0,a)){let e=r.dom.lastChild,t=e?j0(e):[];if(t.length){let e=t[t.length-1],n=s?e.right-m.left:m.right-e.left;n>o&&(o=n,this.minWidth=i,this.minWidthFrom=u,this.minWidthTo=p)}}d&&f==e.children.length-1&&(c+=d.bottom-m.bottom),u=p+r.breakAfter}};return l(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return getComputedStyle(t.dom).direction==`rtl`?J0.RTL:J0.LTR}measureTextSize(){let e=this.tile.blockTiles(e=>{if(e.isLine()&&e.children.length&&e.length<=20){let t=0,n;for(let r of e.children){if(!r.isText()||/[^ -~]/.test(r.text))return;let e=j0(r.dom);if(e.length!=1)return;t+=e[0].width,n=e[0].height}if(t)return{lineHeight:e.dom.getBoundingClientRect().height,charWidth:t/e.length,textHeight:n}}});if(e)return e;let t=document.createElement(`div`),n,r,i;return t.className=`cm-line`,t.style.width=`99999px`,t.style.position=`absolute`,t.textContent=`abc def ghi jkl mno pqr stu`,this.view.observer.ignore(()=>{this.tile.dom.appendChild(t);let e=j0(t.firstChild)[0];n=t.getBoundingClientRect().height,r=e&&e.width?e.width/27:7,i=e&&e.height?e.height:n,t.remove()}),{lineHeight:n,charWidth:r,textHeight:i}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let n=0,r=0;;r++){let i=r==t.viewports.length?null:t.viewports[r],a=i?i.from-1:this.view.state.doc.length;if(a>n){let r=(t.lineBlockAt(a).bottom-t.lineBlockAt(n).top)/this.view.scaleY;e.push(x0.replace({widget:new a4(r),block:!0,inclusive:!0,isBlockGap:!0}).range(n,a))}if(!i)break;n=i.to+1}return x0.set(e)}updateDeco(){let e=1,t=this.view.state.facet(k2).map(t=>(this.dynamicDecorationMap[e++]=typeof t==`function`)?t(this.view):t),n=!1,r=this.view.state.facet(j2).map((e,t)=>{let r=typeof e==`function`;return r&&(n=!0),r?e(this.view):e});for(r.length&&(this.dynamicDecorationMap[e++]=n,t.push(N1.join(r))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;this.blockWrappers=this.view.state.facet(A2).map(e=>typeof e==`function`?e(this.view):e)}scrollIntoView(e){if(e.isSnapshot){let t=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=t.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let t of this.view.state.facet(v2))try{if(t(this.view,e.range,e))return!0}catch(e){S2(this.view.state,e,`scroll handler`)}let{range:t}=e,n=this.coordsAt(t.head,t.assoc??(t.empty?0:t.head>t.anchor?-1:1)),r;if(!n)return;!t.empty&&(r=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(n={left:Math.min(n.left,r.left),top:Math.min(n.top,r.top),right:Math.max(n.right,r.right),bottom:Math.max(n.bottom,r.bottom)});let i=I2(this.view),a={left:n.left-i.left,top:n.top-i.top,right:n.right+i.right,bottom:n.bottom+i.bottom},{offsetWidth:o,offsetHeight:s}=this.view.scrollDOM;if(abe(this.view.scrollDOM,a,t.head<t.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,o),-o),Math.max(Math.min(e.yMargin,s),-s),this.view.textDirection==J0.LTR),window.visualViewport&&window.innerHeight-window.visualViewport.height>1&&(n.top>window.pageYOffset+window.visualViewport.offsetTop+window.visualViewport.height||n.bottom<window.pageYOffset+window.visualViewport.offsetTop)){let e=this.view.docView.lineAt(t.head,1);e&&e.dom.scrollIntoView({block:`nearest`})}}lineHasWidget(e){let t=e=>e.isWidget()||e.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){r4(this.tile)}};function r4(e,t){let n=t?.get(e);if(n!=1){n??e.destroy();for(let n of e.children)r4(n,t)}}function Nbe(e){return e.node.nodeType==1&&e.node.firstChild&&(e.offset==0||e.node.childNodes[e.offset-1].contentEditable==`false`)&&(e.offset==e.node.childNodes.length||e.node.childNodes[e.offset].contentEditable==`false`)}function i4(e,t){let n=e.observer.selectionRange;if(!n.focusNode)return null;let r=G0(n.focusNode,n.focusOffset),i=K0(n.focusNode,n.focusOffset),a=r||i;if(i&&r&&i.node!=r.node){let t=B2.get(i.node);if(!t||t.isText()&&t.text!=i.node.nodeValue)a=i;else if(e.docView.lastCompositionAfterCursor){let e=B2.get(r.node);!e||e.isText()&&e.text!=r.node.nodeValue||(a=i)}}if(e.docView.lastCompositionAfterCursor=a!=r,!a)return null;let o=t-a.offset;return{from:o,to:o+a.node.nodeValue.length,node:a.node}}function Pbe(e,t,n){let r=i4(e,n);if(!r)return null;let{node:i,from:a,to:o}=r,s=i.nodeValue;if(/[\n\r]/.test(s)||e.state.doc.sliceString(r.from,r.to)!=s)return null;let c=t.invertedDesc;return{range:new R2(c.mapPos(a),c.mapPos(o),a,o),text:i}}function Fbe(e,t){return e.nodeType==1?(t&&e.childNodes[t-1].contentEditable==`false`?1:0)|(t<e.childNodes.length&&e.childNodes[t].contentEditable==`false`?2:0):0}var Ibe=class{constructor(){this.changes=[]}compareRange(e,t){E0(e,t,this.changes)}comparePoint(e,t){E0(e,t,this.changes)}boundChange(e){E0(e,e,this.changes)}};function Lbe(e,t,n){let r=new Ibe;return N1.compare(e,t,n,r),r.changes}var Rbe=class{constructor(){this.changes=[]}compareRange(e,t){E0(e,t,this.changes)}comparePoint(){}boundChange(e){E0(e,e,this.changes)}};function zbe(e,t,n){let r=new Rbe;return N1.compare(e,t,n,r),r.changes}function Bbe(e,t){for(let n=e;n&&n!=t;n=n.assignedSlot||n.parentNode)if(n.nodeType==1&&n.contentEditable==`false`)return!0;return!1}function Vbe(e,t){let n=!1;return t&&e.iterChangedRanges((e,r)=>{e<t.to&&r>t.from&&(n=!0)}),n}var a4=class extends y0{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement(`div`);return e.className=`cm-gap`,this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+`px`,!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}};function Hbe(e,t,n=1){let r=e.charCategorizer(t),i=e.doc.lineAt(t),a=t-i.from;if(i.length==0)return J.cursor(t);a==0?n=1:a==i.length&&(n=-1);let o=a,s=a;n<0?o=N$(i.text,a,!1):s=N$(i.text,a);let c=r(i.text.slice(o,s));for(;o>0;){let e=N$(i.text,o,!1);if(r(i.text.slice(e,o))!=c)break;o=e}for(;s<i.length;){let e=N$(i.text,s);if(r(i.text.slice(s,e))!=c)break;s=e}return J.range(o+i.from,s+i.from)}function Ube(e,t,n,r,i){let a=Math.round((r-t.left)*e.defaultCharacterWidth);if(e.lineWrapping&&n.height>e.defaultLineHeight*1.5){let t=e.viewState.heightOracle.textHeight,r=Math.floor((i-n.top-(e.defaultLineHeight-t)*.5)/t);a+=r*e.viewState.heightOracle.lineLength}let o=e.state.sliceDoc(n.from,n.to);return n.from+Xye(o,a,e.state.tabSize)}function Wbe(e,t,n){let r=e.lineBlockAt(t);if(Array.isArray(r.type)){let e;for(let i of r.type){if(i.from>t)break;if(!(i.to<t)){if(i.from<t&&i.to>t)return i;(!e||i.type==b0.Text&&(e.type!=i.type||(n<0?i.from<t:i.to>t)))&&(e=i)}}return e||r}return r}function Gbe(e,t,n,r){let i=Wbe(e,t.head,t.assoc||-1),a=!r||i.type!=b0.Text||!(e.lineWrapping||i.widgetLineBreaks)?null:e.coordsAtPos(t.assoc<0&&t.head>i.from?t.head-1:t.head);if(a){let t=e.dom.getBoundingClientRect(),r=e.textDirectionAt(i.from),o=e.posAtCoords({x:n==(r==J0.LTR)?t.right-1:t.left+1,y:(a.top+a.bottom)/2});if(o!=null)return J.cursor(o,n?-1:1)}return J.cursor(n?i.to:i.from,n?-1:1)}function o4(e,t,n,r){let i=e.state.doc.lineAt(t.head),a=e.bidiSpans(i),o=e.textDirectionAt(i.from);for(let s=t,c=null;;){let t=_be(i,a,o,s,n),l=s2;if(!t){if(i.number==(n?e.state.doc.lines:1))return s;l=`
747
- `,i=e.state.doc.line(i.number+(n?1:-1)),a=e.bidiSpans(i),t=e.visualLineSide(i,!n)}if(!c){if(!r)return t;c=r(l)}else if(!c(l))return s;s=t}}function Kbe(e,t,n){let r=e.state.charCategorizer(t),i=r(n);return e=>{let t=r(e);return i==T1.Space&&(i=t),i==t}}function qbe(e,t,n,r){let i=t.head,a=n?1:-1;if(i==(n?e.state.doc.length:0))return J.cursor(i,t.assoc);let o=t.goalColumn,s,c=e.contentDOM.getBoundingClientRect(),l=e.coordsAtPos(i,t.assoc||((t.empty?n:t.head==t.from)?1:-1)),u=e.documentTop;if(l)o??=l.left-c.left,s=a<0?l.top:l.bottom;else{let t=e.viewState.lineBlockAt(i);o??=Math.min(c.right-c.left,e.defaultCharacterWidth*(i-t.from)),s=(a<0?t.top:t.bottom)+u}let d=c.left+o,f=e.viewState.heightOracle.textHeight>>1,p=r??f;for(let t=0;;t+=f){let r=s+(p+t)*a,i=d4(e,{x:d,y:r},!1,a);if(n?r>c.bottom:r<c.top)return J.cursor(i.pos,i.assoc);let l=e.coordsAtPos(i.pos,i.assoc),u=l?(l.top+l.bottom)/2:0;if(!l||(n?u>s:u<s))return J.cursor(i.pos,i.assoc,void 0,o)}}function s4(e,t,n){for(;;){let r=0;for(let i of e)i.between(t-1,t+1,(e,i,a)=>{if(t>e&&t<i){let a=r||n||(t-e<i-t?-1:1);t=a<0?e:i,r=a}});if(!r)return t}}function c4(e,t){let n=null;for(let r=0;r<t.ranges.length;r++){let i=t.ranges[r],a=null;if(i.empty){let t=s4(e,i.from,0);t!=i.from&&(a=J.cursor(t,-1))}else{let t=s4(e,i.from,-1),n=s4(e,i.to,1);(t!=i.from||n!=i.to)&&(a=J.range(i.from==i.anchor?t:n,i.from==i.head?t:n))}a&&(n||=t.ranges.slice(),n[r]=a)}return n?J.create(n,t.mainIndex):t}function l4(e,t,n){let r=s4(e.state.facet(M2).map(t=>t(e)),n.from,t.head>n.from?-1:1);return r==n.from?n:J.cursor(r,r<n.from?1:-1)}var u4=class{constructor(e,t){this.pos=e,this.assoc=t}};function d4(e,t,n,r){let i=e.contentDOM.getBoundingClientRect(),a=i.top+e.viewState.paddingTop,{x:o,y:s}=t,c=s-a,l;for(;;){if(c<0)return new u4(0,1);if(c>e.viewState.docHeight)return new u4(e.state.doc.length,-1);if(l=e.elementAtHeight(c),r==null)break;if(l.type==b0.Text){if(r<0?l.to<e.viewport.from:l.from>e.viewport.to)break;let t=e.docView.coordsAt(r<0?l.from:l.to,r>0?-1:1);if(t&&(r<0?t.top<=c+a:t.bottom>=c+a))break}let t=e.viewState.heightOracle.textHeight/2;c=r>0?l.bottom+t:l.top-t}if(e.viewport.from>=l.to||e.viewport.to<=l.from){if(n)return null;if(l.type==b0.Text){let t=Ube(e,i,l,o,s);return new u4(t,t==l.from?1:-1)}}if(l.type!=b0.Text)return c<(l.top+l.bottom)/2?new u4(l.from,1):new u4(l.to,-1);let u=e.docView.lineAt(l.from,2);return(!u||u.length!=l.length)&&(u=e.docView.lineAt(l.from,-2)),new Jbe(e,o,s,e.textDirectionAt(l.from)).scanTile(u,l.from)}var Jbe=class{constructor(e,t,n,r){this.view=e,this.x=t,this.y=n,this.baseDir=r,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to<e)&&(this.line=this.view.state.doc.lineAt(e),this.spans=this.view.bidiSpans(this.line)),this}baseDirAt(e,t){let{line:n,spans:r}=this.bidiSpansAt(e);return r[t2.find(r,e-n.from,-1,t)].level==this.baseDir}dirAt(e,t){let{line:n,spans:r}=this.bidiSpansAt(e);return r[t2.find(r,e-n.from,-1,t)].dir}bidiIn(e,t){let{spans:n,line:r}=this.bidiSpansAt(e);return n.length>1||n.length&&(n[0].level!=this.baseDir||n[0].to+r.from<t)}scan(e,t,n=!1){let r=0,i=e.length-1,a=new Set,o=this.bidiIn(e[0],e[i]),s,c,l=-1,u=1e9,d;search:for(;r<i;){let n=i-r,f=r+i>>1;adjust:if(a.has(f)){let e=r+Math.floor(Math.random()*n);for(let t=0;t<n;t++){if(!a.has(e)){f=e;break adjust}e++,e==i&&(e=r)}break search}a.add(f);let p=t(f);if(p)for(let t=0;t<p.length;t++){let n=p[t],a=0;if(!(n.width==0&&p.length>1)){if(n.bottom<this.y)(!s||s.bottom<n.bottom)&&(s=n),a=1;else if(n.top>this.y)(!c||c.top>n.top)&&(c=n),a=-1;else{let e=n.left>this.x?this.x-n.left:n.right<this.x?this.x-n.right:0,t=Math.abs(e);t<u&&(l=f,u=t,d=n),e&&(a=e<0==(this.baseDir==J0.LTR)?-1:1)}a==-1&&(!o||this.baseDirAt(e[f],1))?i=f:a==1&&(!o||this.baseDirAt(e[f+1],-1))&&(r=f+1)}}}if(!d){let n=s&&(!c||this.y-s.bottom<c.top-this.y)?s:c;return this.y=(n.top+n.bottom)/2,this.scan(e,t,!0)}if(u&&!n){let{top:n,bottom:r}=d;if(s&&s.bottom>(n+n+r)/3)return this.y=s.bottom-1,this.scan(e,t,!0);if(c&&c.top<(n+r+r)/3)return this.y=c.top+1,this.scan(e,t,!0)}let f=(o?this.dirAt(e[l],1):this.baseDir)==J0.LTR;return{i:l,after:this.x>(d.left+d.right)/2==f}}scanText(e,t){let n=[];for(let r=0;r<e.length;r=N$(e.text,r))n.push(t+r);n.push(t+e.length);let r=this.scan(n,r=>{let i=n[r]-t,a=n[r+1]-t;return H0(e.dom,i,a).getClientRects()});return r.after?new u4(n[r.i+1],-1):new u4(n[r.i],1)}scanTile(e,t){if(!e.length)return new u4(t,1);if(e.children.length==1){let n=e.children[0];if(n.isText())return this.scanText(n,t);if(n.isComposite())return this.scanTile(n,t)}let n=[t];for(let r=0,i=t;r<e.children.length;r++)n.push(i+=e.children[r].length);let r=this.scan(n,t=>{let n=e.children[t];return n.flags&48?null:(n.dom.nodeType==1?n.dom:H0(n.dom,0,n.length)).getClientRects()}),i=e.children[r.i],a=n[r.i];return i.isText()?this.scanText(i,a):i.isComposite()?this.scanTile(i,a):r.after?new u4(n[r.i+1],-1):new u4(a,1)}},f4=`￿`,Ybe=class{constructor(e,t){this.points=e,this.view=t,this.text=``,this.lineSeparator=t.state.facet(D1.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=f4}readRange(e,t){if(!e)return this;let n=e.parentNode;for(let r=e;;){this.findPointBefore(n,r);let e=this.text.length;this.readNode(r);let i=B2.get(r),a=r.nextSibling;if(a==t){i?.breakAfter&&!a&&n!=this.view.contentDOM&&this.lineBreak();break}let o=B2.get(a);(i&&o?i.breakAfter:(i?i.breakAfter:P0(r))||P0(a)&&(r.nodeName!=`BR`||i?.isWidget())&&this.text.length>e)&&!Zbe(a,t)&&this.lineBreak(),r=a}return this.findPointBefore(n,t),this}readTextNode(e){let t=e.nodeValue;for(let n of this.points)n.node==e&&(n.pos=this.text.length+Math.min(n.offset,t.length));for(let n=0,r=this.lineSeparator?null:/\r\n?|\n/g;;){let i=-1,a=1,o;if(this.lineSeparator?(i=t.indexOf(this.lineSeparator,n),a=this.lineSeparator.length):(o=r.exec(t))&&(i=o.index,a=o[0].length),this.append(t.slice(n,i<0?t.length:i)),i<0)break;if(this.lineBreak(),a>1)for(let t of this.points)t.node==e&&t.pos>this.text.length&&(t.pos-=a-1);n=i+a}}readNode(e){let t=B2.get(e),n=t&&t.overrideDOMText;if(n!=null){this.findPointInside(e,n.length);for(let e=n.iter();!e.next().done;)e.lineBreak?this.lineBreak():this.append(e.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName==`BR`?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let n of this.points)n.node==e&&e.childNodes[n.offset]==t&&(n.pos=this.text.length)}findPointInside(e,t){for(let n of this.points)(e.nodeType==3?n.node==e:e.contains(n.node))&&(n.pos=this.text.length+(Xbe(e,n.node,n.offset)?t:0))}};function Xbe(e,t,n){for(;;){if(!t||n<I0(t))return!1;if(t==e)return!0;n=N0(t)+1,t=t.parentNode}}function Zbe(e,t){let n;for(;!(e==t||!e);e=e.nextSibling){let t=B2.get(e);if(!t?.isWidget())return!1;t&&(n||=[]).push(t)}if(n){for(let e of n)if(e.overrideDOMText?.length)return!1}return!0}var p4=class{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}},Qbe=class{constructor(e,t,n,r){this.typeOver=r,this.bounds=null,this.text=``,this.domChanged=t>-1;let{impreciseHead:i,impreciseAnchor:a}=e.docView,o=e.state.selection;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=m4(e.docView.tile,t,n,0))){let t=i||a?[]:exe(e),n=new Ybe(t,e);n.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=n.text,this.newSel=txe(t,this.bounds.from)}else{let t=e.observer.selectionRange,n=i&&i.node==t.focusNode&&i.offset==t.focusOffset||!k0(e.contentDOM,t.focusNode)?o.main.head:e.docView.posFromDOM(t.focusNode,t.focusOffset),r=a&&a.node==t.anchorNode&&a.offset==t.anchorOffset||!k0(e.contentDOM,t.anchorNode)?o.main.anchor:e.docView.posFromDOM(t.anchorNode,t.anchorOffset),s=e.viewport;if((X.ios||X.chrome)&&o.main.empty&&n!=r&&(s.from>0||s.to<e.state.doc.length)){let t=Math.min(n,r),i=Math.max(n,r),a=s.from-t,o=s.to-i;(a==0||a==1||t==0)&&(o==0||o==-1||i==e.state.doc.length)&&(n=0,r=e.state.doc.length)}if(e.inputState.composing>-1&&o.ranges.length>1)this.newSel=o.replaceRange(J.range(r,n));else if(e.lineWrapping&&r==n&&!(o.main.empty&&o.main.head==n)&&e.inputState.lastTouchTime>Date.now()-100){let t=e.coordsAtPos(n,-1),r=0;t&&(r=e.inputState.lastTouchY<=t.bottom?-1:1),this.newSel=J.create([J.cursor(n,r)])}else this.newSel=J.single(r,n)}}};function m4(e,t,n,r){if(e.isComposite()){let i=-1,a=-1,o=-1,s=-1;for(let c=0,l=r,u=r;c<e.children.length;c++){let r=e.children[c],d=l+r.length;if(l<t&&d>n)return m4(r,t,n,l);if(d>=t&&i==-1&&(i=c,a=l),l>n&&r.dom.parentNode==e.dom){o=c,s=u;break}u=d,l=d+r.breakAfter}return{from:a,to:s<0?r+e.length:s,startDOM:(i?e.children[i-1].dom.nextSibling:null)||e.dom.firstChild,endDOM:o<e.children.length&&o>=0?e.children[o].dom:null}}else if(e.isText())return{from:r,to:r+e.length,startDOM:e.dom,endDOM:e.dom.nextSibling};else return null}function h4(e,t){let n,{newSel:r}=t,{state:i}=e,a=i.selection.main,o=e.inputState.lastKeyTime>Date.now()-100?e.inputState.lastKeyCode:-1;if(t.bounds){let{from:e,to:r}=t.bounds,s=a.from,c=null;(o===8||X.android&&t.text.length<r-e)&&(s=a.to,c=`end`);let l=i.doc.sliceString(e,r,f4),u,d;!a.empty&&a.from>=e&&a.to<=r&&(t.typeOver||l!=t.text)&&l.slice(0,a.from-e)==t.text.slice(0,a.from-e)&&l.slice(a.to-e)==t.text.slice(u=t.text.length-(l.length-(a.to-e)))?n={from:a.from,to:a.to,insert:w$.of(t.text.slice(a.from-e,u).split(f4))}:(d=_4(l,t.text,s-e,c))&&(X.chrome&&o==13&&d.toB==d.from+2&&t.text.slice(d.from,d.toB)==`￿￿`&&d.toB--,n={from:e+d.from,to:e+d.toA,insert:w$.of(t.text.slice(d.from,d.toB).split(f4))})}else r&&(!e.hasFocus&&i.facet(C2)||v4(r,a))&&(r=null);if(!n&&!r)return!1;if((X.mac||X.android)&&n&&n.from==n.to&&n.from==a.head-1&&/^\. ?$/.test(n.insert.toString())&&e.contentDOM.getAttribute(`autocorrect`)==`off`?(r&&n.insert.length==2&&(r=J.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:w$.of([n.insert.toString().replace(`.`,` `)])}):i.doc.lineAt(a.from).to<a.to&&e.docView.lineHasWidget(a.to)&&e.inputState.insertingTextAt>Date.now()-50?n={from:a.from,to:a.to,insert:i.toText(e.inputState.insertingText)}:X.chrome&&n&&n.from==n.to&&n.from==a.head&&n.insert.toString()==`
748
- `&&e.lineWrapping&&(r&&=J.single(r.main.anchor-1,r.main.head-1),n={from:a.from,to:a.to,insert:w$.of([` `])}),n)return g4(e,n,r,o);if(r&&!v4(r,a)){let t=!1,n=`select`;return e.inputState.lastSelectionTime>Date.now()-50&&(e.inputState.lastSelectionOrigin==`select`&&(t=!0),n=e.inputState.lastSelectionOrigin,n==`select.pointer`&&(r=c4(i.facet(M2).map(t=>t(e)),r))),e.dispatch({selection:r,scrollIntoView:t,userEvent:n}),!0}else return!1}function g4(e,t,n,r=-1){if(X.ios&&e.inputState.flushIOSKey(t))return!0;let i=e.state.selection.main;if(X.android&&(t.to==i.to&&(t.from==i.from||t.from==i.from-1&&e.state.sliceDoc(t.from,i.from)==` `)&&t.insert.length==1&&t.insert.lines==2&&U0(e.contentDOM,`Enter`,13)||(t.from==i.from-1&&t.to==i.to&&t.insert.length==0||r==8&&t.insert.length<t.to-t.from&&t.to>i.head)&&U0(e.contentDOM,`Backspace`,8)||t.from==i.from&&t.to==i.to+1&&t.insert.length==0&&U0(e.contentDOM,`Delete`,46)))return!0;let a=t.insert.toString();e.inputState.composing>=0&&e.inputState.composing++;let o,s=()=>o||=$be(e,t,n);return e.state.facet(p2).some(n=>n(e,t.from,t.to,a,s))||e.dispatch(s()),!0}function $be(e,t,n){let r,i=e.state,a=i.selection.main,o=-1;if(t.from==t.to&&t.from<a.from||t.from>a.to){let n=t.from<a.from?-1:1,r=n<0?a.from:a.to,s=s4(i.facet(M2).map(t=>t(e)),r,n);t.from==s&&(o=s)}if(o>-1)r={changes:t,selection:J.cursor(t.from+t.insert.length,-1)};else if(t.from>=a.from&&t.to<=a.to&&t.to-t.from>=(a.to-a.from)/3&&(!n||n.main.empty&&n.main.from==t.from+t.insert.length)&&e.inputState.composing<0){let n=a.from<t.from?i.sliceDoc(a.from,t.from):``,o=a.to>t.to?i.sliceDoc(t.to,a.to):``;r=i.replaceSelection(e.state.toText(n+t.insert.sliceString(0,void 0,e.state.lineBreak)+o))}else{let o=i.changes(t),s=n&&n.main.to<=o.newLength?n.main:void 0;if(i.selection.ranges.length>1&&(e.inputState.composing>=0||e.inputState.compositionPendingChange)&&t.to<=a.to+10&&t.to>=a.to-10){let c=e.state.sliceDoc(t.from,t.to),l,u=n&&i4(e,n.main.head);if(u){let e=t.insert.length-(t.to-t.from);l={from:u.from,to:u.to-e}}else l=e.state.doc.lineAt(a.head);let d=a.to-t.to;r=i.changeByRange(n=>{if(n.from==a.from&&n.to==a.to)return{changes:o,range:s||n.map(o)};let r=n.to-d,u=r-c.length;if(e.state.sliceDoc(u,r)!=c||r>=l.from&&u<=l.to)return{range:n};let f=i.changes({from:u,to:r,insert:t.insert}),p=n.to-a.to;return{changes:f,range:s?J.range(Math.max(0,s.anchor+p),Math.max(0,s.head+p)):n.map(f)}})}else r={changes:o,selection:s&&i.selection.replaceRange(s)}}let s=`input.type`;return(e.composing||e.inputState.compositionPendingChange&&e.inputState.compositionEndedAt>Date.now()-50)&&(e.inputState.compositionPendingChange=!1,s+=`.compose`,e.inputState.compositionFirstChange&&(s+=`.start`,e.inputState.compositionFirstChange=!1)),i.update(r,{userEvent:s,scrollIntoView:!0})}function _4(e,t,n,r){let i=Math.min(e.length,t.length),a=0;for(;a<i&&e.charCodeAt(a)==t.charCodeAt(a);)a++;if(a==i&&e.length==t.length)return null;let o=e.length,s=t.length;for(;o>0&&s>0&&e.charCodeAt(o-1)==t.charCodeAt(s-1);)o--,s--;if(r==`end`){let e=Math.max(0,a-Math.min(o,s));n-=o+e-a}if(o<a&&e.length<t.length){let e=n<=a&&n>=o?a-n:0;a-=e,s=a+(s-o),o=a}else if(s<a){let e=n<=a&&n>=s?a-n:0;a-=e,o=a+(o-s),s=a}return{from:a,toA:o,toB:s}}function exe(e){let t=[];if(e.root.activeElement!=e.contentDOM)return t;let{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}=e.observer.selectionRange;return n&&(t.push(new p4(n,r)),(i!=n||a!=r)&&t.push(new p4(i,a))),t}function txe(e,t){if(e.length==0)return null;let n=e[0].pos,r=e.length==2?e[1].pos:n;return n>-1&&r>-1?J.single(n+t,r+t):null}function v4(e,t){return t.head==e.main.head&&t.anchor==e.main.anchor}var nxe=class{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText=``,this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,X.safari&&e.contentDOM.addEventListener(`input`,()=>null),X.gecko&&_xe(e.contentDOM.ownerDocument)}handleEvent(e){!uxe(this.view,e)||this.ignoreDuringComposition(e)||e.type==`keydown`&&this.keydown(e)||(this.view.updateState==0?this.runHandlers(e.type,e):Promise.resolve().then(()=>this.runHandlers(e.type,e)))}runHandlers(e,t){let n=this.handlers[e];if(n){for(let e of n.observers)e(this.view,t);for(let e of n.handlers){if(t.defaultPrevented)break;if(e(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=rxe(e),n=this.handlers,r=this.view.contentDOM;for(let e in t)if(e!=`scroll`){let i=!t[e].handlers.length,a=n[e];a&&i!=!a.handlers.length&&(r.removeEventListener(e,this.handleEvent),a=null),a||r.addEventListener(e,this.handleEvent,{passive:i})}for(let e in n)e!=`scroll`&&!t[e]&&r.removeEventListener(e,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&x4.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),X.android&&X.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return X.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&!e.shiftKey&&((t=b4.find(t=>t.keyCode==e.keyCode))&&!e.ctrlKey||ixe.indexOf(e.key)>-1&&e.ctrlKey)?(this.pendingIOSKey=t||e,setTimeout(()=>this.flushIOSKey(),250),!0):(e.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(e){let t=this.pendingIOSKey;return!t||t.key==`Enter`&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString())?!1:(this.pendingIOSKey=void 0,U0(this.view.contentDOM,t.key,t.keyCode,t instanceof KeyboardEvent?t:void 0))}ignoreDuringComposition(e){return!/^key/.test(e.type)||e.synthetic?!1:this.composing>0?!0:X.safari&&!X.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}};function y4(e,t){return(n,r)=>{try{return t.call(e,r,n)}catch(e){S2(n.state,e)}}}function rxe(e){let t=Object.create(null);function n(e){return t[e]||(t[e]={observers:[],handlers:[]})}for(let t of e){let e=t.spec,r=e&&e.plugin.domEventHandlers,i=e&&e.plugin.domEventObservers;if(r)for(let e in r){let i=r[e];i&&n(e).handlers.push(y4(t.value,i))}if(i)for(let e in i){let r=i[e];r&&n(e).observers.push(y4(t.value,r))}}for(let e in w4)n(e).handlers.push(w4[e]);for(let e in T4)n(e).observers.push(T4[e]);return t}var b4=[{key:`Backspace`,keyCode:8,inputType:`deleteContentBackward`},{key:`Enter`,keyCode:13,inputType:`insertParagraph`},{key:`Enter`,keyCode:13,inputType:`insertLineBreak`},{key:`Delete`,keyCode:46,inputType:`deleteContentForward`}],ixe=`dthko`,x4=[16,17,18,20,91,92,224,225],S4=6;function C4(e){return Math.max(0,e)*.7+8}function axe(e,t){return Math.max(Math.abs(e.clientX-t.clientX),Math.abs(e.clientY-t.clientY))}var oxe=class{constructor(e,t,n,r){this.view=e,this.startEvent=t,this.style=n,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=z0(e.contentDOM),this.atoms=e.state.facet(M2).map(t=>t(e));let i=e.contentDOM.ownerDocument;i.addEventListener(`mousemove`,this.move=this.move.bind(this)),i.addEventListener(`mouseup`,this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(D1.allowMultipleSelections)&&sxe(e,t),this.dragging=lxe(e,t)&&N4(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&axe(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,n=0,r=0,i=0,a=this.view.win.innerWidth,o=this.view.win.innerHeight;this.scrollParents.x&&({left:r,right:a}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:i,bottom:o}=this.scrollParents.y.getBoundingClientRect());let s=I2(this.view);e.clientX-s.left<=r+S4?t=-C4(r-e.clientX):e.clientX+s.right>=a-S4&&(t=C4(e.clientX-a)),e.clientY-s.top<=i+S4?n=-C4(i-e.clientY):e.clientY+s.bottom>=o-S4&&(n=C4(e.clientY-o)),this.setScrollSpeed(t,n)}up(e){this.dragging??this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener(`mousemove`,this.move),e.removeEventListener(`mouseup`,this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:t}=this,n=c4(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!n.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:n,userEvent:`select.pointer`}),this.mustSelect=!1}update(e){e.transactions.some(e=>e.isUserEvent(`input.type`))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}};function sxe(e,t){let n=e.state.facet(c2);return n.length?n[0](t):X.mac?t.metaKey:t.ctrlKey}function cxe(e,t){let n=e.state.facet(l2);return n.length?n[0](t):X.mac?!t.altKey:!t.ctrlKey}function lxe(e,t){let{main:n}=e.state.selection;if(n.empty)return!1;let r=O0(e.root);if(!r||r.rangeCount==0)return!0;let i=r.getRangeAt(0).getClientRects();for(let e=0;e<i.length;e++){let n=i[e];if(n.left<=t.clientX&&n.right>=t.clientX&&n.top<=t.clientY&&n.bottom>=t.clientY)return!0}return!1}function uxe(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target,r;n!=e.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(r=B2.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(t))return!1;return!0}var w4=Object.create(null),T4=Object.create(null),E4=X.ie&&X.ie_version<15||X.ios&&X.webkit_version<604;function dxe(e){let t=e.dom.parentNode;if(!t)return;let n=t.appendChild(document.createElement(`textarea`));n.style.cssText=`position: fixed; left: -10000px; top: 10px`,n.focus(),setTimeout(()=>{e.focus(),n.remove(),O4(e,n.value)},50)}function D4(e,t,n){for(let r of e.facet(t))n=r(n,e);return n}function O4(e,t){t=D4(e.state,h2,t);let{state:n}=e,r,i=1,a=n.toText(t),o=a.lines==n.selection.ranges.length;if(F4!=null&&n.selection.ranges.every(e=>e.empty)&&F4==a.toString()){let e=-1;r=n.changeByRange(r=>{let s=n.doc.lineAt(r.from);if(s.from==e)return{range:r};e=s.from;let c=n.toText((o?a.line(i++).text:t)+n.lineBreak);return{changes:{from:s.from,insert:c},range:J.cursor(r.from+c.length)}})}else r=o?n.changeByRange(e=>{let t=a.line(i++);return{changes:{from:e.from,to:e.to,insert:t.text},range:J.cursor(e.from+t.length)}}):n.replaceSelection(a);e.dispatch(r,{userEvent:`input.paste`,scrollIntoView:!0})}T4.scroll=e=>{e.inputState.lastScrollTop=e.scrollDOM.scrollTop,e.inputState.lastScrollLeft=e.scrollDOM.scrollLeft},T4.wheel=T4.mousewheel=e=>{e.inputState.lastWheelEvent=Date.now()},w4.keydown=(e,t)=>(e.inputState.setSelectionOrigin(`select`),t.keyCode==27&&e.inputState.tabFocusMode!=0&&(e.inputState.tabFocusMode=Date.now()+2e3),!1),T4.touchstart=(e,t)=>{let n=e.inputState,r=t.targetTouches[0];n.lastTouchTime=Date.now(),r&&(n.lastTouchX=r.clientX,n.lastTouchY=r.clientY),n.setSelectionOrigin(`select.pointer`)},T4.touchmove=e=>{e.inputState.setSelectionOrigin(`select.pointer`)},w4.mousedown=(e,t)=>{if(e.observer.flush(),e.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of e.state.facet(u2))if(n=r(e,t),n)break;if(!n&&t.button==0&&(n=pxe(e,t)),n){let r=!e.hasFocus;e.inputState.startMouseSelection(new oxe(e,t,n,r)),r&&e.observer.ignore(()=>{V0(e.contentDOM);let t=e.root.activeElement;t&&!t.contains(e.contentDOM)&&t.blur()});let i=e.inputState.mouseSelection;if(i)return i.start(t),i.dragging===!1}else e.inputState.setSelectionOrigin(`select.pointer`);return!1};function k4(e,t,n,r){if(r==1)return J.cursor(t,n);if(r==2)return Hbe(e.state,t,n);{let r=e.docView.lineAt(t,n),i=e.state.doc.lineAt(r?r.posAtEnd:t),a=r?r.posAtStart:i.from,o=r?r.posAtEnd:i.to;return o<e.state.doc.length&&o==i.to&&o++,J.range(a,o)}}var fxe=X.ie&&X.ie_version<=11,A4=null,j4=0,M4=0;function N4(e){if(!fxe)return e.detail;let t=A4,n=M4;return A4=e,M4=Date.now(),j4=!t||n>Date.now()-400&&Math.abs(t.clientX-e.clientX)<2&&Math.abs(t.clientY-e.clientY)<2?(j4+1)%3:1}function pxe(e,t){let n=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),r=N4(t),i=e.state.selection;return{update(e){e.docChanged&&(n.pos=e.changes.mapPos(n.pos),i=i.map(e.changes))},get(t,a,o){let s=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),c,l=k4(e,s.pos,s.assoc,r);if(n.pos!=s.pos&&!a){let t=k4(e,n.pos,n.assoc,r),i=Math.min(t.from,l.from),a=Math.max(t.to,l.to);l=i<l.from?J.range(i,a,l.assoc):J.range(a,i,l.assoc)}return a?i.replaceRange(i.main.extend(l.from,l.to,l.assoc)):o&&r==1&&i.ranges.length>1&&(c=mxe(i,s.pos))?c:o?i.addRange(l):J.create([l])}}}function mxe(e,t){for(let n=0;n<e.ranges.length;n++){let{from:r,to:i}=e.ranges[n];if(r<=t&&i>=t)return J.create(e.ranges.slice(0,n).concat(e.ranges.slice(n+1)),e.mainIndex==n?0:e.mainIndex-+(e.mainIndex>n))}return null}w4.dragstart=(e,t)=>{let{selection:{main:n}}=e.state;if(t.target.draggable){let r=e.docView.tile.nearest(t.target);if(r&&r.isWidget()){let e=r.posAtStart,t=e+r.length;(e>=n.to||t<=n.from)&&(n=J.range(e,t))}}let{inputState:r}=e;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,t.dataTransfer&&(t.dataTransfer.setData(`Text`,D4(e.state,g2,e.state.sliceDoc(n.from,n.to))),t.dataTransfer.effectAllowed=`copyMove`),!1},w4.dragend=e=>(e.inputState.draggedContent=null,!1);function P4(e,t,n,r){if(n=D4(e.state,h2,n),!n)return;let i=e.posAtCoords({x:t.clientX,y:t.clientY},!1),{draggedContent:a}=e.inputState,o=r&&a&&cxe(e,t)?{from:a.from,to:a.to}:null,s={from:i,insert:n},c=e.state.changes(o?[o,s]:s);e.focus(),e.dispatch({changes:c,selection:{anchor:c.mapPos(i,-1),head:c.mapPos(i,1)},userEvent:o?`move.drop`:`input.drop`}),e.inputState.draggedContent=null}w4.drop=(e,t)=>{if(!t.dataTransfer)return!1;if(e.state.readOnly)return!0;let n=t.dataTransfer.files;if(n&&n.length){let r=Array(n.length),i=0,a=()=>{++i==n.length&&P4(e,t,r.filter(e=>e!=null).join(e.state.lineBreak),!1)};for(let e=0;e<n.length;e++){let t=new FileReader;t.onerror=a,t.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(t.result)||(r[e]=t.result),a()},t.readAsText(n[e])}return!0}else{let n=t.dataTransfer.getData(`Text`);if(n)return P4(e,t,n,!0),!0}return!1},w4.paste=(e,t)=>{if(e.state.readOnly)return!0;e.observer.flush();let n=E4?null:t.clipboardData;return n?(O4(e,n.getData(`text/plain`)||n.getData(`text/uri-list`)),!0):(dxe(e),!1)};function hxe(e,t){let n=e.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement(`textarea`));r.style.cssText=`position: fixed; left: -10000px; top: 10px`,r.value=t,r.focus(),r.selectionEnd=t.length,r.selectionStart=0,setTimeout(()=>{r.remove(),e.focus()},50)}function gxe(e){let t=[],n=[],r=!1;for(let r of e.selection.ranges)r.empty||(t.push(e.sliceDoc(r.from,r.to)),n.push(r));if(!t.length){let i=-1;for(let{from:r}of e.selection.ranges){let a=e.doc.lineAt(r);a.number>i&&(t.push(a.text),n.push({from:a.from,to:Math.min(e.doc.length,a.to+1)})),i=a.number}r=!0}return{text:D4(e,g2,t.join(e.lineBreak)),ranges:n,linewise:r}}var F4=null;w4.copy=w4.cut=(e,t)=>{if(!A0(e.contentDOM,e.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:i}=gxe(e.state);if(!n&&!i)return!1;F4=i?n:null,t.type==`cut`&&!e.state.readOnly&&e.dispatch({changes:r,scrollIntoView:!0,userEvent:`delete.cut`});let a=E4?null:t.clipboardData;return a?(a.clearData(),a.setData(`text/plain`,n),!0):(hxe(e,n),!1)};var I4=v1.define();function L4(e,t){let n=[];for(let r of e.facet(m2)){let i=r(e,t);i&&n.push(i)}return n.length?e.update({effects:n,annotations:I4.of(!0)}):null}function R4(e){setTimeout(()=>{let t=e.hasFocus;if(t!=e.inputState.notifiedFocused){let n=L4(e.state,t);n?e.dispatch(n):e.update([])}},10)}T4.focus=e=>{e.inputState.lastFocusTime=Date.now(),!e.scrollDOM.scrollTop&&(e.inputState.lastScrollTop||e.inputState.lastScrollLeft)&&(e.scrollDOM.scrollTop=e.inputState.lastScrollTop,e.scrollDOM.scrollLeft=e.inputState.lastScrollLeft),R4(e)},T4.blur=e=>{e.observer.clearSelectionRange(),R4(e)},T4.compositionstart=T4.compositionupdate=e=>{e.observer.editContext||(e.inputState.compositionFirstChange??(e.inputState.compositionFirstChange=!0),e.inputState.composing<0&&(e.inputState.composing=0))},T4.compositionend=e=>{e.observer.editContext||(e.inputState.composing=-1,e.inputState.compositionEndedAt=Date.now(),e.inputState.compositionPendingKey=!0,e.inputState.compositionPendingChange=e.observer.pendingRecords().length>0,e.inputState.compositionFirstChange=null,X.chrome&&X.android?e.observer.flushSoon():e.inputState.compositionPendingChange?Promise.resolve().then(()=>e.observer.flush()):setTimeout(()=>{e.inputState.composing<0&&e.docView.hasComposition&&e.update([])},50))},T4.contextmenu=e=>{e.inputState.lastContextMenu=Date.now()},w4.beforeinput=(e,t)=>{if((t.inputType==`insertText`||t.inputType==`insertCompositionText`)&&(e.inputState.insertingText=t.data,e.inputState.insertingTextAt=Date.now()),t.inputType==`insertReplacementText`&&e.observer.editContext){let n=t.dataTransfer?.getData(`text/plain`),r=t.getTargetRanges();if(n&&r.length){let t=r[0];return g4(e,{from:e.posAtDOM(t.startContainer,t.startOffset),to:e.posAtDOM(t.endContainer,t.endOffset),insert:e.state.toText(n)},null),!0}}let n;if(X.chrome&&X.android&&(n=b4.find(e=>e.inputType==t.inputType))&&(e.observer.delayAndroidKey(n.key,n.keyCode),n.key==`Backspace`||n.key==`Delete`)){let t=window.visualViewport?.height||0;setTimeout(()=>{(window.visualViewport?.height||0)>t+10&&e.hasFocus&&(e.contentDOM.blur(),e.focus())},100)}return X.ios&&t.inputType==`deleteContentForward`&&e.observer.flushSoon(),X.safari&&t.inputType==`insertText`&&e.inputState.composing>=0&&setTimeout(()=>T4.compositionend(e,t),20),!1};var z4=new Set;function _xe(e){z4.has(e)||(z4.add(e),e.addEventListener(`copy`,()=>{}),e.addEventListener(`cut`,()=>{}))}var B4=[`pre-wrap`,`normal`,`pre-line`,`break-spaces`],V4=!1;function H4(){V4=!1}var vxe=class{constructor(e){this.lineWrapping=e,this.doc=w$.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let n=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(n+=Math.max(0,Math.ceil((t-e-n*this.lineLength*.5)/this.lineLength))),this.lineHeight*n}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return B4.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let n=0;n<e.length;n++){let r=e[n];r<0?n++:this.heightSamples[Math.floor(r*10)]||(t=!0,this.heightSamples[Math.floor(r*10)]=!0)}return t}refresh(e,t,n,r,i,a){let o=B4.indexOf(e)>-1,s=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=o;if(this.lineWrapping=o,this.lineHeight=t,this.charWidth=n,this.textHeight=r,this.lineLength=i,s){this.heightSamples={};for(let e=0;e<a.length;e++){let t=a[e];t<0?e++:this.heightSamples[Math.floor(t*10)]=!0}}return s}},yxe=class{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}},U4=class e{constructor(e,t,n,r,i){this.from=e,this.length=t,this.top=n,this.height=r,this._content=i}get type(){return typeof this._content==`number`?b0.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof w0?this._content.widget:null}get widgetLineBreaks(){return typeof this._content==`number`?this._content:0}join(t){let n=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(t._content)?t._content:[t]);return new e(this.from,this.length+t.length,this.top,this.height+t.height,n)}},W4=(function(e){return e[e.ByPos=0]=`ByPos`,e[e.ByHeight=1]=`ByHeight`,e[e.ByPosNoHeight=2]=`ByPosNoHeight`,e})(W4||={}),G4=.001,K4=class e{constructor(e,t,n=2){this.length=e,this.height=t,this.flags=n}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>G4&&(V4=!0),this.height=e)}replace(t,n,r){return e.of(r)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,n,r){let i=this,a=n.doc;for(let o=r.length-1;o>=0;o--){let{fromA:s,toA:c,fromB:l,toB:u}=r[o],d=i.lineAt(s,W4.ByPosNoHeight,n.setDoc(t),0,0),f=d.to>=c?d:i.lineAt(c,W4.ByPosNoHeight,n,0,0);for(u+=f.to-c,c=f.to;o>0&&d.from<=r[o-1].toA;)s=r[o-1].fromA,l=r[o-1].fromB,o--,s<d.from&&(d=i.lineAt(s,W4.ByPosNoHeight,n,0,0));l+=d.from-s,s=d.from;let p=Cxe.build(n.setDoc(a),e,l,u);i=q4(i,i.replace(s,c,p))}return i.updateHeight(n,0)}static empty(){return new Y4(0,0,0)}static of(t){if(t.length==1)return t[0];let n=0,r=t.length,i=0,a=0;for(;;)if(n==r)if(i>a*2){let e=t[n-1];e.break?t.splice(--n,1,e.left,null,e.right):t.splice(--n,1,e.left,e.right),r+=1+e.break,i-=e.size}else if(a>i*2){let e=t[r];e.break?t.splice(r,1,e.left,null,e.right):t.splice(r,1,e.left,e.right),r+=2+e.break,a-=e.size}else break;else if(i<a){let e=t[n++];e&&(i+=e.size)}else{let e=t[--r];e&&(a+=e.size)}let o=0;return t[n-1]==null?(o=1,n--):t[n]??(o=1,r++),new xxe(e.of(t.slice(0,n)),o,e.of(t.slice(r)))}};function q4(e,t){return e==t?e:(e.constructor!=t.constructor&&(V4=!0),t)}K4.prototype.size=1;var bxe=x0.replace({}),J4=class extends K4{constructor(e,t,n){super(e,t),this.deco=n,this.spaceAbove=0}mainBlock(e,t){return new U4(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(e,t,n,r){return this.spaceAbove&&e<n+this.spaceAbove?new U4(r,0,n,this.spaceAbove,bxe):this.mainBlock(n,r)}lineAt(e,t,n,r,i){let a=this.mainBlock(r,i);return this.spaceAbove?this.blockAt(0,n,r,i).join(a):a}forEachLine(e,t,n,r,i,a){e<=i+this.length&&t>=i&&a(this.lineAt(0,W4.ByPos,n,r,i))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more&&this.setMeasuredHeight(r),this.outdated=!1,this}toString(){return`block(${this.length})`}},Y4=class e extends J4{constructor(e,t,n){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=n}mainBlock(e,t){return new U4(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(t,n,r){let i=r[0];return r.length==1&&(i instanceof e||i instanceof X4&&i.flags&4)&&Math.abs(this.length-i.length)<10?(i instanceof X4?i=new e(i.length,this.height,this.spaceAbove):i.height=this.height,this.outdated||(i.outdated=!1),i):K4.of(r)}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more?this.setMeasuredHeight(r):(n||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:``}${this.widgetHeight?`:`+this.widgetHeight:``})`}},X4=class e extends K4{constructor(e){super(e,0)}heightMetrics(e,t){let n=e.doc.lineAt(t).number,r=e.doc.lineAt(t+this.length).number,i=r-n+1,a,o=0;if(e.lineWrapping){let t=Math.min(this.height,e.lineHeight*i);a=t/i,this.length>i+1&&(o=(this.height-t)/(this.length-i-1))}else a=this.height/i;return{firstLine:n,lastLine:r,perLine:a,perChar:o}}blockAt(e,t,n,r){let{firstLine:i,lastLine:a,perLine:o,perChar:s}=this.heightMetrics(t,r);if(t.lineWrapping){let i=r+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-n)/this.height))*this.length)),a=t.doc.lineAt(i),c=o+a.length*s,l=Math.max(n,e-c/2);return new U4(a.from,a.length,l,c,0)}else{let r=Math.max(0,Math.min(a-i,Math.floor((e-n)/o))),{from:s,length:c}=t.doc.line(i+r);return new U4(s,c,n+o*r,o,0)}}lineAt(e,t,n,r,i){if(t==W4.ByHeight)return this.blockAt(e,n,r,i);if(t==W4.ByPosNoHeight){let{from:t,to:r}=n.doc.lineAt(e);return new U4(t,r-t,0,0,0)}let{firstLine:a,perLine:o,perChar:s}=this.heightMetrics(n,i),c=n.doc.lineAt(e),l=o+c.length*s,u=c.number-a,d=r+o*u+s*(c.from-i-u);return new U4(c.from,c.length,Math.max(r,Math.min(d,r+this.height-l)),l,0)}forEachLine(e,t,n,r,i,a){e=Math.max(e,i),t=Math.min(t,i+this.length);let{firstLine:o,perLine:s,perChar:c}=this.heightMetrics(n,i);for(let l=e,u=r;l<=t;){let t=n.doc.lineAt(l);if(l==e){let n=t.number-o;u+=s*n+c*(e-i-n)}let r=s+c*t.length;a(new U4(t.from,t.length,u,r,0)),u+=r,l=t.to+1}}replace(t,n,r){let i=this.length-n;if(i>0){let t=r[r.length-1];t instanceof e?r[r.length-1]=new e(t.length+i):r.push(null,new e(i-1))}if(t>0){let n=r[0];n instanceof e?r[0]=new e(t+n.length):r.unshift(new e(t-1),null)}return K4.of(r)}decomposeLeft(t,n){n.push(new e(t-1),null)}decomposeRight(t,n){n.push(null,new e(this.length-t-1))}updateHeight(t,n=0,r=!1,i){let a=n+this.length;if(i&&i.from<=n+this.length&&i.more){let r=[],o=Math.max(n,i.from),s=-1;for(i.from>n&&r.push(new e(i.from-n-1).updateHeight(t,n));o<=a&&i.more;){let e=t.doc.lineAt(o).length;r.length&&r.push(null);let n=i.heights[i.index++],a=0;n<0&&(a=-n,n=i.heights[i.index++]),s==-1?s=n:Math.abs(n-s)>=G4&&(s=-2);let c=new Y4(e,n,a);c.outdated=!1,r.push(c),o+=e+1}o<=a&&r.push(null,new e(a-o).updateHeight(t,o));let c=K4.of(r);return(s<0||Math.abs(c.height-this.height)>=G4||Math.abs(s-this.heightMetrics(t,n).perLine)>=G4)&&(V4=!0),q4(this,c)}else (r||this.outdated)&&(this.setHeight(t.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}},xxe=class extends K4{constructor(e,t,n){super(e.length+t+n.length,e.height+n.height,t|(e.outdated||n.outdated?2:0)),this.left=e,this.right=n,this.size=e.size+n.size}get break(){return this.flags&1}blockAt(e,t,n,r){let i=n+this.left.height;return e<i?this.left.blockAt(e,t,n,r):this.right.blockAt(e,t,i,r+this.left.length+this.break)}lineAt(e,t,n,r,i){let a=r+this.left.height,o=i+this.left.length+this.break,s=t==W4.ByHeight?e<a:e<o,c=s?this.left.lineAt(e,t,n,r,i):this.right.lineAt(e,t,n,a,o);if(this.break||(s?c.to<o:c.from>o))return c;let l=t==W4.ByPosNoHeight?W4.ByPosNoHeight:W4.ByPos;return s?c.join(this.right.lineAt(o,l,n,a,o)):this.left.lineAt(o,l,n,r,i).join(c)}forEachLine(e,t,n,r,i,a){let o=r+this.left.height,s=i+this.left.length+this.break;if(this.break)e<s&&this.left.forEachLine(e,t,n,r,i,a),t>=s&&this.right.forEachLine(e,t,n,o,s,a);else{let c=this.lineAt(s,W4.ByPos,n,r,i);e<c.from&&this.left.forEachLine(e,c.from-1,n,r,i,a),c.to>=e&&c.from<=t&&a(c),t>c.to&&this.right.forEachLine(c.to+1,t,n,o,s,a)}}replace(e,t,n){let r=this.left.length+this.break;if(t<r)return this.balanced(this.left.replace(e,t,n),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-r,t-r,n));let i=[];e>0&&this.decomposeLeft(e,i);let a=i.length;for(let e of n)i.push(e);if(e>0&&Z4(i,a-1),t<this.length){let e=i.length;this.decomposeRight(t,i),Z4(i,e)}return K4.of(i)}decomposeLeft(e,t){let n=this.left.length;if(e<=n)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(n++,e>=n&&t.push(null)),e>n&&this.right.decomposeLeft(e-n,t)}decomposeRight(e,t){let n=this.left.length,r=n+this.break;if(e>=r)return this.right.decomposeRight(e-r,t);e<n&&this.left.decomposeRight(e,t),this.break&&e<r&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?K4.of(this.break?[e,null,t]:[e,t]):(this.left=q4(this.left,e),this.right=q4(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,n=!1,r){let{left:i,right:a}=this,o=t+i.length+this.break,s=null;return r&&r.from<=t+i.length&&r.more?s=i=i.updateHeight(e,t,n,r):i.updateHeight(e,t,n),r&&r.from<=o+a.length&&r.more?s=a=a.updateHeight(e,o,n,r):a.updateHeight(e,o,n),s?this.balanced(i,a):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?` `:`-`)+this.right}};function Z4(e,t){let n,r;e[t]==null&&(n=e[t-1])instanceof X4&&(r=e[t+1])instanceof X4&&e.splice(t-1,3,new X4(n.length+1+r.length))}var Sxe=5,Cxe=class e{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let e=Math.min(t,this.lineEnd),n=this.nodes[this.nodes.length-1];n instanceof Y4?n.length+=e-this.pos:(e>this.pos||!this.isCovered)&&this.nodes.push(new Y4(e-this.pos,-1,0)),this.writtenTo=e,t>e&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,n){if(e<t||n.heightRelevant){let r=n.widget?n.widget.estimatedHeight:0,i=n.widget?n.widget.lineBreaks:0;r<0&&(r=this.oracle.lineHeight);let a=t-e;n.block?this.addBlock(new J4(a,r,n)):(a||i||r>=Sxe)&&this.addLineDeco(r,i,a)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new Y4(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let n=new X4(t-e);return this.oracle.doc.lineAt(e).to==t&&(n.flags|=4),n}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Y4)return e;let t=new Y4(0,-1,0);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos+=e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,n){let r=this.ensureLine();r.length+=n,r.collapsed+=n,r.widgetHeight=Math.max(r.widgetHeight,e),r.breaks+=t,this.writtenTo=this.pos+=n}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof Y4)&&!this.isCovered?this.nodes.push(new Y4(0,-1,0)):(this.writtenTo<this.pos||t==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let n=e;for(let e of this.nodes)e instanceof Y4&&e.updateHeight(this.oracle,n),n+=e?e.length:1;return this.nodes}static build(t,n,r,i){let a=new e(r,t);return N1.spans(n,r,i,a,0),a.finish(r)}};function wxe(e,t,n){let r=new Txe;return N1.compare(e,t,n,r,0),r.changes}var Txe=class{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,n,r){(e<t||n&&n.heightRelevant||r&&r.heightRelevant)&&E0(e,t,this.changes,5)}};function Exe(e,t){let n=e.getBoundingClientRect(),r=e.ownerDocument,i=r.defaultView||window,a=Math.max(0,n.left),o=Math.min(i.innerWidth,n.right),s=Math.max(0,n.top),c=Math.min(i.innerHeight,n.bottom);for(let t=e.parentNode;t&&t!=r.body;)if(t.nodeType==1){let n=t,r=window.getComputedStyle(n);if((n.scrollHeight>n.clientHeight||n.scrollWidth>n.clientWidth)&&r.overflow!=`visible`){let r=n.getBoundingClientRect();a=Math.max(a,r.left),o=Math.min(o,r.right),s=Math.max(s,r.top),c=Math.min(t==e.parentNode?i.innerHeight:c,r.bottom)}t=r.position==`absolute`||r.position==`fixed`?n.offsetParent:n.parentNode}else if(t.nodeType==11)t=t.host;else break;return{left:a-n.left,right:Math.max(a,o)-n.left,top:s-(n.top+t),bottom:Math.max(s,c)-(n.top+t)}}function Dxe(e){let t=e.getBoundingClientRect(),n=e.ownerDocument.defaultView||window;return t.left<n.innerWidth&&t.right>0&&t.top<n.innerHeight&&t.bottom>0}function Oxe(e,t){let n=e.getBoundingClientRect();return{left:0,right:n.right-n.left,top:t,bottom:n.bottom-(n.top+t)}}var Q4=class{constructor(e,t,n,r){this.from=e,this.to=t,this.size=n,this.displaySize=r}static same(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r.from!=i.from||r.to!=i.to||r.size!=i.size)return!1}return!0}draw(e,t){return x0.replace({widget:new kxe(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}},kxe=class extends y0{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement(`div`);return this.vertical?e.style.height=this.size+`px`:(e.style.width=this.size+`px`,e.style.height=`2px`,e.style.display=`inline-block`),e}get estimatedHeight(){return this.vertical?this.size:-1}},$4=class{constructor(e,t){this.view=e,this.state=t,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scaleX=1,this.scaleY=1,this.scrollOffset=0,this.scrolledToBottom=!1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=r3,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=J0.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let n=t.facet(O2).some(e=>typeof e!=`function`&&e.class==`cm-lineWrapping`);this.heightOracle=new vxe(n),this.stateDeco=i3(t),this.heightMap=K4.empty().applyChanges(this.stateDeco,w$.empty,this.heightOracle.setDoc(t.doc),[new R2(0,0,0,t.doc.length)]);for(let e=0;e<2&&(this.viewport=this.getViewport(0,null),this.updateForViewport());e++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=x0.set(this.lineGaps.map(e=>e.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let n=0;n<=1;n++){let r=n?t.head:t.anchor;if(!e.some(({from:e,to:t})=>r>=e&&r<=t)){let{from:t,to:n}=this.lineBlockAt(r);e.push(new e3(t,n))}}return this.viewports=e.sort((e,t)=>e.from-t.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?r3:new Mxe(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(a3(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=i3(this.state);let r=e.changedRanges,i=R2.extendWithRanges(r,wxe(n,this.stateDeco,e?e.changes:B$.empty(this.state.doc.length))),a=this.heightMap.height,o=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);H4(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),i),(this.heightMap.height!=a||V4)&&(e.flags|=2),o?(this.scrollAnchorPos=e.changes.mapPos(o.from,-1),this.scrollAnchorHeight=o.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=a);let s=i.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<s.from||t.range.head>s.to)||!this.viewportIsAppropriate(s))&&(s=this.getViewport(0,t));let c=s.from!=this.viewport.from||s.to!=this.viewport.to;this.viewport=s,e.flags|=this.updateForViewport(),(c||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(ybe)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,t=e.contentDOM,n=window.getComputedStyle(t),r=this.heightOracle,i=n.whiteSpace;this.defaultTextDirection=n.direction==`rtl`?J0.RTL:J0.LTR;let a=this.heightOracle.mustRefreshForWrapping(i)||this.mustMeasureContent===`refresh`,o=t.getBoundingClientRect(),s=a||this.mustMeasureContent||this.contentDOMHeight!=o.height;this.contentDOMHeight=o.height,this.mustMeasureContent=!1;let c=0,l=0;if(o.width&&o.height){let{scaleX:e,scaleY:n}=R0(t,o);(e>.005&&Math.abs(this.scaleX-e)>.005||n>.005&&Math.abs(this.scaleY-n)>.005)&&(this.scaleX=e,this.scaleY=n,c|=16,a=s=!0)}let u=(parseInt(n.paddingTop)||0)*this.scaleY,d=(parseInt(n.paddingBottom)||0)*this.scaleY;(this.paddingTop!=u||this.paddingBottom!=d)&&(this.paddingTop=u,this.paddingBottom=d,c|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(s=!0),this.editorWidth=e.scrollDOM.clientWidth,c|=16);let f=z0(this.view.contentDOM,!1).y;f!=this.scrollParent&&(this.scrollParent=f,this.scrollAnchorHeight=-1,this.scrollOffset=0);let p=this.getScrollOffset();this.scrollOffset!=p&&(this.scrollAnchorHeight=-1,this.scrollOffset=p),this.scrolledToBottom=W0(this.scrollParent||e.win);let m=(this.printing?Oxe:Exe)(t,this.paddingTop),h=m.top-this.pixelViewport.top,g=m.bottom-this.pixelViewport.bottom;this.pixelViewport=m;let _=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(_!=this.inView&&(this.inView=_,_&&(s=!0)),!this.inView&&!this.scrollTarget&&!Dxe(e.dom))return 0;let v=o.width;if((this.contentDOMWidth!=v||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=o.width,this.editorHeight=e.scrollDOM.clientHeight,c|=16),s){let t=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(t)&&(a=!0),a||r.lineWrapping&&Math.abs(v-this.contentDOMWidth)>r.charWidth){let{lineHeight:n,charWidth:o,textHeight:s}=e.docView.measureTextSize();a=n>0&&r.refresh(i,n,o,s,Math.max(5,v/o),t),a&&(e.docView.minWidth=0,c|=16)}h>0&&g>0?l=Math.max(h,g):h<0&&g<0&&(l=Math.min(h,g)),H4();for(let n of this.viewports){let i=n.from==this.viewport.from?t:e.docView.measureVisibleLineHeights(n);this.heightMap=(a?K4.empty().applyChanges(this.stateDeco,w$.empty,this.heightOracle,[new R2(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,a,new yxe(n.from,i))}V4&&(c|=2)}let y=!this.viewportIsAppropriate(this.viewport,l)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return y&&(c&2&&(c|=this.updateScaler()),this.viewport=this.getViewport(l,this.scrollTarget),c|=this.updateForViewport()),(c&2||y)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(a?[]:this.lineGaps,e)),c|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),c}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let n=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),r=this.heightMap,i=this.heightOracle,{visibleTop:a,visibleBottom:o}=this,s=new e3(r.lineAt(a-n*1e3,W4.ByHeight,i,0,0).from,r.lineAt(o+(1-n)*1e3,W4.ByHeight,i,0,0).to);if(t){let{head:e}=t.range;if(e<s.from||e>s.to){let n=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),a=r.lineAt(e,W4.ByPos,i,0,0),o;o=t.y==`center`?(a.top+a.bottom)/2-n/2:t.y==`start`||t.y==`nearest`&&e<s.from?a.top:a.bottom-n,s=new e3(r.lineAt(o-1e3/2,W4.ByHeight,i,0,0).from,r.lineAt(o+n+1e3/2,W4.ByHeight,i,0,0).to)}}return s}mapViewport(e,t){let n=t.mapPos(e.from,-1),r=t.mapPos(e.to,1);return new e3(this.heightMap.lineAt(n,W4.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(r,W4.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},n=0){if(!this.inView)return!0;let{top:r}=this.heightMap.lineAt(e,W4.ByPos,this.heightOracle,0,0),{bottom:i}=this.heightMap.lineAt(t,W4.ByPos,this.heightOracle,0,0),{visibleTop:a,visibleBottom:o}=this;return(e==0||r<=a-Math.max(10,Math.min(-n,250)))&&(t==this.state.doc.length||i>=o+Math.max(10,Math.min(n,250)))&&r>a-2*1e3&&i<o+2*1e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let n=[];for(let r of e)t.touchesRange(r.from,r.to)||n.push(new Q4(t.mapPos(r.from),t.mapPos(r.to),r.size,r.displaySize));return n}ensureLineGaps(e,t){let n=this.heightOracle.lineWrapping,r=n?1e4:2e3,i=r>>1,a=r<<1;if(this.defaultTextDirection!=J0.LTR&&!n)return[];let o=[],s=(r,a,c,l)=>{if(a-r<i)return;let u=this.state.selection.main,d=[u.from];u.empty||d.push(u.to);for(let e of d)if(e>r&&e<a){s(r,e-10,c,l),s(e+10,a,c,l);return}let f=jxe(e,e=>e.from>=c.from&&e.to<=c.to&&Math.abs(e.from-r)<i&&Math.abs(e.to-a)<i&&!d.some(t=>e.from<t&&e.to>t));if(!f){if(a<c.to&&t&&n&&t.visibleRanges.some(e=>e.from<=a&&e.to>=a)){let e=t.moveToLineBoundary(J.cursor(a),!1,!0).head;e>r&&(a=e)}let e=this.gapSize(c,r,a,l);f=new Q4(r,a,e,n||e<2e6?e:2e6)}o.push(f)},c=t=>{if(t.length<a||t.type!=b0.Text)return;let i=Axe(t.from,t.to,this.stateDeco);if(i.total<a)return;let o=this.scrollTarget?this.scrollTarget.range.head:null,c,l;if(n){let e=r/this.heightOracle.lineLength*this.heightOracle.lineHeight,n,a;if(o!=null){let r=n3(i,o),s=((this.visibleBottom-this.visibleTop)/2+e)/t.height;n=r-s,a=r+s}else n=(this.visibleTop-t.top-e)/t.height,a=(this.visibleBottom-t.top+e)/t.height;c=t3(i,n),l=t3(i,a)}else{let n=i.total*this.heightOracle.charWidth,a=r*this.heightOracle.charWidth,s=0;if(n>2e6)for(let n of e)n.from>=t.from&&n.from<t.to&&n.size!=n.displaySize&&n.from*this.heightOracle.charWidth+s<this.pixelViewport.left&&(s=n.size-n.displaySize);let u=this.pixelViewport.left+s,d=this.pixelViewport.right+s,f,p;if(o!=null){let e=n3(i,o),t=((d-u)/2+a)/n;f=e-t,p=e+t}else f=(u-a)/n,p=(d+a)/n;c=t3(i,f),l=t3(i,p)}c>t.from&&s(t.from,c,t,i),l<t.to&&s(l,t.to,t,i)};for(let e of this.viewportLines)Array.isArray(e.type)?e.type.forEach(c):c(e);return o}gapSize(e,t,n,r){let i=n3(r,n)-n3(r,t);return this.heightOracle.lineWrapping?e.height*i:r.total*this.heightOracle.charWidth*i}updateLineGaps(e){Q4.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=x0.set(e.map(e=>e.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let n=[];N1.spans(t,this.viewport.from,this.viewport.to,{span(e,t){n.push({from:e,to:t})},point(){}},20);let r=0;if(n.length!=this.visibleRanges.length)r=12;else for(let t=0;t<n.length&&!(r&8);t++){let i=this.visibleRanges[t],a=n[t];(i.from!=a.from||i.to!=a.to)&&(r|=4,e&&e.mapPos(i.from,-1)==a.from&&e.mapPos(i.to,1)==a.to||(r|=8))}return this.visibleRanges=n,r}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||a3(this.heightMap.lineAt(e,W4.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||a3(this.heightMap.lineAt(this.scaler.fromDOM(e),W4.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return(this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top)*this.scaleY}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return a3(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}},e3=class{constructor(e,t){this.from=e,this.to=t}};function Axe(e,t,n){let r=[],i=e,a=0;return N1.spans(n,e,t,{span(){},point(e,t){e>i&&(r.push({from:i,to:e}),a+=e-i),i=t}},20),i<t&&(r.push({from:i,to:t}),a+=t-i),{total:a,ranges:r}}function t3({total:e,ranges:t},n){if(n<=0)return t[0].from;if(n>=1)return t[t.length-1].to;let r=Math.floor(e*n);for(let e=0;;e++){let{from:n,to:i}=t[e],a=i-n;if(r<=a)return n+r;r-=a}}function n3(e,t){let n=0;for(let{from:r,to:i}of e.ranges){if(t<=i){n+=t-r;break}n+=i-r}return n/e.total}function jxe(e,t){for(let n of e)if(t(n))return n}var r3={toDOM(e){return e},fromDOM(e){return e},scale:1,eq(e){return e==this}};function i3(e){let t=e.facet(k2).filter(e=>typeof e!=`function`),n=e.facet(j2).filter(e=>typeof e!=`function`);return n.length&&t.push(N1.join(n)),t}var Mxe=class e{constructor(e,t,n){let r=0,i=0,a=0;this.viewports=n.map(({from:n,to:i})=>{let a=t.lineAt(n,W4.ByPos,e,0,0).top,o=t.lineAt(i,W4.ByPos,e,0,0).bottom;return r+=o-a,{from:n,to:i,top:a,bottom:o,domTop:0,domBottom:0}}),this.scale=(7e6-r)/(t.height-r);for(let e of this.viewports)e.domTop=a+(e.top-i)*this.scale,a=e.domBottom=e.domTop+(e.bottom-e.top),i=e.bottom}toDOM(e){for(let t=0,n=0,r=0;;t++){let i=t<this.viewports.length?this.viewports[t]:null;if(!i||e<i.top)return r+(e-n)*this.scale;if(e<=i.bottom)return i.domTop+(e-i.top);n=i.bottom,r=i.domBottom}}fromDOM(e){for(let t=0,n=0,r=0;;t++){let i=t<this.viewports.length?this.viewports[t]:null;if(!i||e<i.domTop)return n+(e-r)/this.scale;if(e<=i.domBottom)return i.top+(e-i.domTop);n=i.bottom,r=i.domBottom}}eq(t){return t instanceof e?this.scale==t.scale&&this.viewports.length==t.viewports.length&&this.viewports.every((e,n)=>e.from==t.viewports[n].from&&e.to==t.viewports[n].to):!1}};function a3(e,t){if(t.scale==1)return e;let n=t.toDOM(e.top),r=t.toDOM(e.bottom);return new U4(e.from,e.length,n,r-n,Array.isArray(e._content)?e._content.map(e=>a3(e,t)):e._content)}var o3=Y.define({combine:e=>e.join(` `)}),s3=Y.define({combine:e=>e.indexOf(!0)>-1}),c3=X1.newName(),l3=X1.newName(),u3=X1.newName(),d3={"&light":`.`+l3,"&dark":`.`+u3};function f3(e,t,n){return new X1(t,{finish(t){return/&/.test(t)?t.replace(/&\w*/,t=>{if(t==`&`)return e;if(!n||!n[t])throw RangeError(`Unsupported selector: ${t}`);return n[t]}):e+` `+t}})}var Nxe=f3(`.`+c3,{"&":{position:`relative !important`,boxSizing:`border-box`,"&.cm-focused":{outline:`1px dotted #212121`},display:`flex !important`,flexDirection:`column`},".cm-scroller":{display:`flex !important`,alignItems:`flex-start !important`,fontFamily:`monospace`,lineHeight:1.4,height:`100%`,overflowX:`auto`,position:`relative`,zIndex:0,overflowAnchor:`none`},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:`block`,whiteSpace:`pre`,wordWrap:`normal`,boxSizing:`border-box`,minHeight:`100%`,padding:`4px 0`,outline:`none`,"&[contenteditable=true]":{WebkitUserModify:`read-write-plaintext-only`}},".cm-lineWrapping":{whiteSpace_fallback:`pre-wrap`,whiteSpace:`break-spaces`,wordBreak:`break-word`,overflowWrap:`anywhere`,flexShrink:1},"&light .cm-content":{caretColor:`black`},"&dark .cm-content":{caretColor:`white`},".cm-line":{display:`block`,padding:`0 2px 0 6px`},".cm-layer":{position:`absolute`,left:0,top:0,contain:`size style`,"& > *":{position:`absolute`}},"&light .cm-selectionBackground":{background:`#d9d9d9`},"&dark .cm-selectionBackground":{background:`#222`},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:`#d7d4f0`},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:`#233`},".cm-cursorLayer":{pointerEvents:`none`},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:`steps(1) cm-blink 1.2s infinite`},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:`1.2px solid black`,marginLeft:`-0.6px`,pointerEvents:`none`},".cm-cursor":{display:`none`},"&dark .cm-cursor":{borderLeftColor:`#ddd`},".cm-selectionHandle":{backgroundColor:`currentColor`,width:`1.5px`},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:`""`,backgroundColor:`inherit`,borderRadius:`50%`,width:`8px`,height:`8px`,position:`absolute`,left:`-3.25px`},".cm-selectionHandle-start::before":{top:`-8px`},".cm-selectionHandle-end::before":{bottom:`-8px`},".cm-dropCursor":{position:`absolute`},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:`block`},".cm-iso":{unicodeBidi:`isolate`},".cm-announced":{position:`fixed`,top:`-10000px`},"@media print":{".cm-announced":{display:`none`}},"&light .cm-activeLine":{backgroundColor:`#cceeff44`},"&dark .cm-activeLine":{backgroundColor:`#99eeff33`},"&light .cm-specialChar":{color:`red`},"&dark .cm-specialChar":{color:`#f78`},".cm-gutters":{flexShrink:0,display:`flex`,height:`100%`,boxSizing:`border-box`,zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:`#f5f5f5`,color:`#6c6c6c`,border:`0px solid #ddd`,"&.cm-gutters-before":{borderRightWidth:`1px`},"&.cm-gutters-after":{borderLeftWidth:`1px`}},"&dark .cm-gutters":{backgroundColor:`#333338`,color:`#ccc`},".cm-gutter":{display:`flex !important`,flexDirection:`column`,flexShrink:0,boxSizing:`border-box`,minHeight:`100%`,overflow:`hidden`},".cm-gutterElement":{boxSizing:`border-box`},".cm-lineNumbers .cm-gutterElement":{padding:`0 3px 0 5px`,minWidth:`20px`,textAlign:`right`,whiteSpace:`nowrap`},"&light .cm-activeLineGutter":{backgroundColor:`#e2f2ff`},"&dark .cm-activeLineGutter":{backgroundColor:`#222227`},".cm-panels":{boxSizing:`border-box`,position:`sticky`,left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:`#f5f5f5`,color:`black`},"&light .cm-panels-top":{borderBottom:`1px solid #ddd`},"&light .cm-panels-bottom":{borderTop:`1px solid #ddd`},"&dark .cm-panels":{backgroundColor:`#333338`,color:`white`},".cm-dialog":{padding:`2px 19px 4px 6px`,position:`relative`,"& label":{fontSize:`80%`}},".cm-dialog-close":{position:`absolute`,top:`3px`,right:`4px`,backgroundColor:`inherit`,border:`none`,font:`inherit`,fontSize:`14px`,padding:`0`},".cm-tab":{display:`inline-block`,overflow:`hidden`,verticalAlign:`bottom`},".cm-widgetBuffer":{verticalAlign:`text-top`,height:`1em`,width:0,display:`inline`},".cm-placeholder":{color:`#888`,display:`inline-block`,verticalAlign:`top`,userSelect:`none`},".cm-highlightSpace":{backgroundImage:`radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)`,backgroundPosition:`center`},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:`auto 100%`,backgroundPosition:`right 90%`,backgroundRepeat:`no-repeat`},".cm-trailingSpace":{backgroundColor:`#ff332255`},".cm-button":{verticalAlign:`middle`,color:`inherit`,fontSize:`70%`,padding:`.2em 1em`,borderRadius:`1px`},"&light .cm-button":{backgroundImage:`linear-gradient(#eff1f5, #d9d9df)`,border:`1px solid #888`,"&:active":{backgroundImage:`linear-gradient(#b4b4b4, #d0d3d6)`}},"&dark .cm-button":{backgroundImage:`linear-gradient(#393939, #111)`,border:`1px solid #888`,"&:active":{backgroundImage:`linear-gradient(#111, #333)`}},".cm-textfield":{verticalAlign:`middle`,color:`inherit`,fontSize:`70%`,border:`1px solid silver`,padding:`.2em .5em`},"&light .cm-textfield":{backgroundColor:`white`},"&dark .cm-textfield":{border:`1px solid #555`,backgroundColor:`inherit`}},d3),Pxe={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},p3=X.ie&&X.ie_version<=11,Fxe=class{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new obe,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let e of t)this.queue.push(e);(X.ie&&X.ie_version<=11||X.ios&&e.composing)&&t.some(e=>e.type==`childList`&&e.removedNodes.length||e.type==`characterData`&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&X.android&&e.constructor.EDIT_CONTEXT!==!1&&!(X.chrome&&X.chrome_version<126)&&(this.editContext=new Lxe(e),e.state.facet(C2)&&(e.contentDOM.editContext=this.editContext.editContext)),p3&&(this.onCharData=e=>{this.queue.push({target:e.target,type:`characterData`,oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia(`print`)),typeof ResizeObserver==`function`&&(this.resizeScroll=new ResizeObserver(()=>{this.view.docView?.lastUpdate<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver==`function`&&(this.intersection=new IntersectionObserver(e=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),e.length>0&&e[e.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent(`Event`)))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(e=>{e.length>0&&e[e.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent(`Event`))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers(`scroll`,e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type==`change`||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,n)=>t!=e[n]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:n}=this,r=this.selectionRange;if(n.state.facet(C2)?n.root.activeElement!=this.dom:!A0(this.dom,r))return;let i=r.anchorNode&&n.docView.tile.nearest(r.anchorNode);if(i&&i.isWidget()&&i.widget.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(X.ie&&X.ie_version<=11||X.android&&X.chrome)&&!n.state.selection.main.empty&&r.focusNode&&M0(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=O0(e.root);if(!t)return!1;let n=X.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&Ixe(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;let r=A0(this.dom,n);return r&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&lbe(this.dom,n)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(n),r&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let n=this.dom;n;)if(n.nodeType==1)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==n?e++:t||=this.scrollTargets.slice(0,e),t&&t.push(n),n=n.assignedSlot||n.parentNode;else if(n.nodeType==11)n=n.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let e of this.scrollTargets)e.removeEventListener(`scroll`,this.onScroll);for(let e of this.scrollTargets=t)e.addEventListener(`scroll`,this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||=(this.observer.observe(this.dom,Pxe),p3&&this.dom.addEventListener(`DOMCharacterDataModified`,this.onCharData),!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),p3&&this.dom.removeEventListener(`DOMCharacterDataModified`,this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){if(!this.delayedAndroidKey){let e=()=>{let e=this.delayedAndroidKey;e&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=e.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&e.force&&U0(this.dom,e.key,e.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(e)}(!this.delayedAndroidKey||e==`Enter`)&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!this.delayedAndroidKey?.force})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,n=-1,r=!1;for(let i of e){let e=this.readMutation(i);e&&(e.typeOver&&(r=!0),t==-1?{from:t,to:n}=e:(t=Math.min(e.from,t),n=Math.max(e.to,n)))}return{from:t,to:n,typeOver:r}}readChange(){let{from:e,to:t,typeOver:n}=this.processRecords(),r=this.selectionChanged&&A0(this.dom,this.selectionRange);if(e<0&&!r)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let i=new Qbe(this.view,e,t,n);return this.view.docView.domChanged={newSel:i.newSel?i.newSel.main:null},i}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let n=this.view.state,r=h4(this.view,t);return this.view.state==n&&(t.domChanged||t.newSel&&!v4(this.view.state.selection,t.newSel.main))&&this.view.update([]),r}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty(e.type==`attributes`),e.type==`childList`){let n=m3(t,e.previousSibling||e.target.previousSibling,-1),r=m3(t,e.nextSibling||e.target.nextSibling,1);return{from:n?t.posAfter(n):t.posAtStart,to:r?t.posBefore(r):t.posAtEnd,typeOver:!1}}else if(e.type==`characterData`)return{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue};else return null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener(`resize`,this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener(`change`,this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener(`beforeprint`,this.onPrint),e.addEventListener(`scroll`,this.onScroll),e.document.addEventListener(`selectionchange`,this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener(`scroll`,this.onScroll),e.removeEventListener(`resize`,this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener(`change`,this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener(`beforeprint`,this.onPrint),e.document.removeEventListener(`selectionchange`,this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(C2)!=e.state.facet(C2)&&(e.view.contentDOM.editContext=e.state.facet(C2)?this.editContext.editContext:null))}destroy(){var e,t,n;this.stop(),(e=this.intersection)==null||e.disconnect(),(t=this.gapIntersection)==null||t.disconnect(),(n=this.resizeScroll)==null||n.disconnect();for(let e of this.scrollTargets)e.removeEventListener(`scroll`,this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}};function m3(e,t,n){for(;t;){let r=B2.get(t);if(r&&r.parent==e)return r;let i=t.parentNode;t=i==e.dom?n>0?t.nextSibling:t.previousSibling:i}return null}function h3(e,t){let n=t.startContainer,r=t.startOffset,i=t.endContainer,a=t.endOffset,o=e.docView.domAtPos(e.state.selection.main.anchor,1);return M0(o.node,o.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function Ixe(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return h3(e,n)}let n=null;function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.contentDOM.addEventListener(`beforeinput`,r,!0),e.dom.ownerDocument.execCommand(`indent`),e.contentDOM.removeEventListener(`beforeinput`,r,!0),n?h3(e,n):null}var Lxe=class{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=n=>{let r=e.state.selection.main,{anchor:i,head:a}=r,o=this.toEditorPos(n.updateRangeStart),s=this.toEditorPos(n.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:n.updateRangeStart,editorBase:o,drifted:!1});let c=s-o>n.text.length;o==this.from&&i<this.from?o=i:s==this.to&&i>this.to&&(s=i);let l=_4(e.state.sliceDoc(o,s),n.text,(c?r.from:r.to)-o,c?`end`:null);if(!l){let t=J.single(this.toEditorPos(n.selectionStart),this.toEditorPos(n.selectionEnd));v4(t,r)||e.dispatch({selection:t,userEvent:`select`});return}let u={from:l.from+o,to:l.toA+o,insert:w$.of(n.text.slice(l.from,l.toB).split(`
749
- `))};if((X.mac||X.android)&&u.from==a-1&&/^\. ?$/.test(n.text)&&e.contentDOM.getAttribute(`autocorrect`)==`off`&&(u={from:o,to:s,insert:w$.of([n.text.replace(`.`,` `)])}),this.pendingContextChange=u,!e.state.readOnly){let t=this.to-this.from+(u.to-u.from+u.insert.length);g4(e,u,J.single(this.toEditorPos(n.selectionStart,t),this.toEditorPos(n.selectionEnd,t)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),u.from<u.to&&!u.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,n.updateRangeStart-1),Math.min(t.text.length,n.updateRangeStart+1)))&&this.handlers.compositionend(n)},this.handlers.characterboundsupdate=n=>{let r=[],i=null;for(let t=this.toEditorPos(n.rangeStart),a=this.toEditorPos(n.rangeEnd);t<a;t++){let n=e.coordsForChar(t);i=n&&new DOMRect(n.left,n.top,n.right-n.left,n.bottom-n.top)||i||new DOMRect,r.push(i)}t.updateCharacterBounds(n.rangeStart,r)},this.handlers.textformatupdate=t=>{let n=[];for(let e of t.getTextFormats()){let t=e.underlineStyle,r=e.underlineThickness;if(!/none/i.test(t)&&!/none/i.test(r)){let i=this.toEditorPos(e.rangeStart),a=this.toEditorPos(e.rangeEnd);if(i<a){let e=`text-decoration: underline ${/^[a-z]/.test(t)?t+` `:t==`Dashed`?`dashed `:t==`Squiggle`?`wavy `:``}${/thin/i.test(r)?1:2}px`;n.push(x0.mark({attributes:{style:e}}).range(i,a))}}}e.dispatch({effects:x2.of(x0.set(n))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:t}=this.composing;this.composing=null,t&&this.reset(e.state)}};for(let e in this.handlers)t.addEventListener(e,this.handlers[e]);this.measureReq={read:e=>{this.editContext.updateControlBounds(e.contentDOM.getBoundingClientRect());let t=O0(e.root);t&&t.rangeCount&&this.editContext.updateSelectionBounds(t.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,n=!1,r=this.pendingContextChange;return e.changes.iterChanges((i,a,o,s,c)=>{if(n)return;let l=c.length-(a-i);if(r&&a>=r.to)if(r.from==i&&r.to==a&&r.insert.eq(c)){r=this.pendingContextChange=null,t+=l,this.to+=l;return}else r=null,this.revertPending(e.state);if(i+=t,a+=t,a<=this.from)this.from+=l,this.to+=l;else if(i<this.to){if(i<this.from||a>this.to||this.to-this.from+c.length>3e4){n=!0;return}this.editContext.updateText(this.toContextPos(i),this.toContextPos(a),c.toString()),this.to+=l}t+=l}),r&&!n&&this.revertPending(e.state),!n}update(e){let t=this.pendingContextChange,n=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(n.from,n.to)&&e.transactions.some(e=>!e.isUserEvent(`input.type`)&&e.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,n=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),r=this.toContextPos(t.head);(this.editContext.selectionStart!=n||this.editContext.selectionEnd!=r)&&this.editContext.updateSelection(n,r)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>1e4*3)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let n=this.composing;return n&&n.drifted?n.editorBase+(e-n.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}},Z=class e{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement(`div`),this.scrollDOM=document.createElement(`div`),this.scrollDOM.tabIndex=-1,this.scrollDOM.className=`cm-scroller`,this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement(`div`),this.announceDOM.className=`cm-announced`,this.announceDOM.setAttribute(`aria-live`,`polite`),this.dom=document.createElement(`div`),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:t}=e;this.dispatchTransactions=e.dispatchTransactions||t&&(e=>e.forEach(e=>t(e,this)))||(e=>this.update(e)),this.dispatch=this.dispatch.bind(this),this._root=e.root||cbe(e.parent)||document,this.viewState=new $4(this,e.state||D1.create(e)),e.scrollTo&&e.scrollTo.is(b2)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(w2).map(e=>new E2(e));for(let e of this.plugins)e.update(this);this.observer=new Fxe(this),this.inputState=new nxe(this),this.inputState.ensureHandlers(this.plugins),this.docView=new n4(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),document.fonts?.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent=`refresh`,this.requestMeasure()})}dispatch(...e){let t=e.length==1&&e[0]instanceof b1?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(t){if(this.updateState!=0)throw Error(`Calls to EditorView.update are not allowed while an update is in progress`);let n=!1,r=!1,i,a=this.state;for(let e of t){if(e.startState!=a)throw RangeError(`Trying to update state with a transaction that doesn't start from the previous state.`);a=e.state}if(this.destroyed){this.viewState.state=a;return}let o=this.hasFocus,s=0,c=null;t.some(e=>e.annotation(I4))?(this.inputState.notifiedFocused=o,s=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,c=L4(a,o),c||(s=1));let l=this.observer.delayedAndroidKey,u=null;if(l?(this.observer.clearDelayedAndroidKey(),u=this.observer.readChange(),(u&&!this.state.doc.eq(a.doc)||!this.state.selection.eq(a.selection))&&(u=null)):this.observer.clear(),a.facet(D1.phrases)!=this.state.facet(D1.phrases))return this.setState(a);i=z2.create(this,a,t),i.flags|=s;let d=this.viewState.scrollTarget;try{this.updateState=2;for(let n of t){if(d&&=d.map(n.changes),n.scrollIntoView){let{main:t}=n.state.selection,{x:r,y:i}=this.state.facet(e.cursorScrollMargin);d=new y2(t.empty?t:J.cursor(t.head,t.head>t.anchor?-1:1),`nearest`,`nearest`,i,r)}for(let e of n.effects)e.is(b2)&&(d=e.value.clip(this.state))}this.viewState.update(i,d),this.bidiCache=_3.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),n=this.docView.update(i),this.state.facet(L2)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(n,t.some(e=>e.isUserEvent(`select.pointer`)))}finally{this.updateState=0}if(i.startState.facet(o3)!=i.state.facet(o3)&&(this.viewState.mustMeasureContent=!0),(n||r||d||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!i.empty)for(let e of this.state.facet(f2))try{e(i)}catch(e){S2(this.state,e,`update listener`)}(c||u)&&Promise.resolve().then(()=>{c&&this.state==c.startState&&this.dispatch(c),u&&!h4(this,u)&&l.force&&U0(this.contentDOM,l.key,l.keyCode)})}setState(e){if(this.updateState!=0)throw Error(`Calls to EditorView.setState are not allowed while an update is in progress`);if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let e of this.plugins)e.destroy(this);this.viewState=new $4(this,e),this.plugins=e.facet(w2).map(e=>new E2(e)),this.pluginMap.clear();for(let e of this.plugins)e.update(this);this.docView.destroy(),this.docView=new n4(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(w2),n=e.state.facet(w2);if(t!=n){let r=[];for(let i of n){let n=t.indexOf(i);if(n<0)r.push(new E2(i));else{let t=this.plugins[n];t.mustUpdate=e,r.push(t)}}for(let t of this.plugins)t.mustUpdate!=e&&t.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let t of this.plugins)t.mustUpdate=e;for(let e=0;e<this.plugins.length;e++)this.plugins[e].update(this);t!=n&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(e){S2(this.state,e,`doc view update listener`)}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,n=this.viewState.scrollParent,r=this.viewState.getScrollOffset(),{scrollAnchorPos:i,scrollAnchorHeight:a}=this.viewState;Math.abs(r-this.viewState.scrollOffset)>1&&(a=-1),this.viewState.scrollAnchorHeight=-1;try{for(let e=0;;e++){if(a<0)if(W0(n||this.win))i=-1,a=this.viewState.heightMap.height;else{let e=this.viewState.scrollAnchorAt(r);i=e.from,a=e.top}this.updateState=1;let o=this.viewState.measure();if(!o&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(e>5){console.warn(this.measureRequests.length?`Measure loop restarted more than 5 times`:`Viewport failed to stabilize`);break}let s=[];o&4||([this.measureRequests,s]=[s,this.measureRequests]);let c=s.map(e=>{try{return e.read(this)}catch(e){return S2(this.state,e),g3}}),l=z2.create(this,this.state,[]),u=!1;l.flags|=o,t?t.flags|=o:t=l,this.updateState=2,l.empty||(this.updatePlugins(l),this.inputState.update(l),this.updateAttrs(),u=this.docView.update(l),u&&this.docViewUpdate());for(let e=0;e<s.length;e++)if(c[e]!=g3)try{let t=s[e];t.write&&t.write(c[e],this)}catch(e){S2(this.state,e)}if(u&&this.docView.updateSelection(!0),!l.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,a=-1;continue}else{let e=((i<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(i).top)-a)/this.scaleY;if((e>1||e<-1)&&(n==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){r+=e,n?n.scrollTop+=e:this.win.scrollBy(0,e),a=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let e of this.state.facet(f2))e(t)}get themeClasses(){return c3+` `+(this.state.facet(s3)?u3:l3)+` `+this.state.facet(o3)}updateAttrs(){let e=v3(this,D2,{class:`cm-editor`+(this.hasFocus?` cm-focused `:` `)+this.themeClasses}),t={spellcheck:`false`,autocorrect:`off`,autocapitalize:`off`,writingsuggestions:`false`,translate:`no`,contenteditable:this.state.facet(C2)?`true`:`false`,class:`cm-content`,style:`${X.tabSize}: ${this.state.tabSize}`,role:`textbox`,"aria-multiline":`true`};this.state.readOnly&&(t[`aria-readonly`]=`true`),v3(this,O2,t);let n=this.observer.ignore(()=>{let n=v0(this.contentDOM,this.contentAttrs,t),r=v0(this.dom,this.editorAttrs,e);return n||r});return this.editorAttrs=e,this.contentAttrs=t,n}showAnnouncements(t){let n=!0;for(let r of t)for(let t of r.effects)if(t.is(e.announce)){n&&(this.announceDOM.textContent=``),n=!1;let e=this.announceDOM.appendChild(document.createElement(`div`));e.textContent=t.value}}mountStyles(){this.styleModules=this.state.facet(L2);let t=this.state.facet(e.cspNonce);X1.mount(this.root,this.styleModules.concat(Nxe).reverse(),t?{nonce:t}:void 0)}readMeasured(){if(this.updateState==2)throw Error(`Reading the editor layout isn't allowed during an update`);this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(t===void 0||t&&t.plugin!=e)&&this.pluginMap.set(e,t=this.plugins.find(t=>t.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,n){return l4(this,e,o4(this,e,t,n))}moveByGroup(e,t){return l4(this,e,o4(this,e,t,t=>Kbe(this,e.head,t)))}visualLineSide(e,t){let n=this.bidiSpans(e),r=this.textDirectionAt(e.from),i=n[t?n.length-1:0];return J.cursor(i.side(t,r)+e.from,i.forward(!t,r)?1:-1)}moveToLineBoundary(e,t,n=!0){return Gbe(this,e,t,n)}moveVertically(e,t,n){return l4(this,e,qbe(this,e,t,n))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let n=d4(this,e,t);return n&&n.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),d4(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let n=this.docView.coordsAt(e,t);if(!n||n.left==n.right)return n;let r=this.state.doc.lineAt(e),i=this.bidiSpans(r),a=i[t2.find(i,e-r.from,-1,t)];return L0(n,a.dir==J0.LTR==t>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(_2)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Rxe)return o2(e.length);let t=this.textDirectionAt(e.from),n;for(let r of this.bidiCache)if(r.from==e.from&&r.dir==t&&(r.fresh||n2(r.isolates,n=P2(this,e))))return r.order;n||=P2(this,e);let r=gbe(e.text,t,n);return this.bidiCache.push(new _3(e.from,e.to,t,n,!0,r)),r}get hasFocus(){return(this.dom.ownerDocument.hasFocus()||X.safari&&this.inputState?.lastContextMenu>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{V0(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return b2.of(new y2(typeof e==`number`?J.cursor(e):e,t.y??`nearest`,t.x??`nearest`,t.yMargin??5,t.xMargin??5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,n=this.viewState.scrollAnchorAt(e);return b2.of(new y2(J.cursor(n.from),`start`,`start`,n.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e==`boolean`?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return T2.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return T2.define(()=>({}),{eventObservers:e})}static theme(e,t){let n=X1.newName(),r=[o3.of(n),L2.of(f3(`.${n}`,e))];return t&&t.dark&&r.push(s3.of(!0)),r}static baseTheme(e){return i1.lowest(L2.of(f3(`.`+c3,e,d3)))}static findFromDOM(e){let t=e.querySelector(`.cm-content`);return(t&&B2.get(t)||B2.get(e))?.root?.view||null}};Z.styleModule=L2,Z.inputHandler=p2,Z.clipboardInputFilter=h2,Z.clipboardOutputFilter=g2,Z.scrollHandler=v2,Z.focusChangeEffect=m2,Z.perLineTextDirection=_2,Z.exceptionSink=d2,Z.updateListener=f2,Z.editable=C2,Z.mouseSelectionStyle=u2,Z.dragMovesSelection=l2,Z.clickAddsSelectionRange=c2,Z.decorations=k2,Z.blockWrappers=A2,Z.outerDecorations=j2,Z.atomicRanges=M2,Z.bidiIsolatedRanges=N2,Z.cursorScrollMargin=Y.define({combine:e=>{let t=5,n=5;for(let r of e)typeof r==`number`?t=n=r:{x:t,y:n}=r;return{x:t,y:n}}}),Z.scrollMargins=F2,Z.darkTheme=s3,Z.cspNonce=Y.define({combine:e=>e.length?e[0]:``}),Z.contentAttributes=O2,Z.editorAttributes=D2,Z.lineWrapping=Z.contentAttributes.of({class:`cm-lineWrapping`}),Z.announce=y1.define();var Rxe=4096,g3={},_3=class e{constructor(e,t,n,r,i,a){this.from=e,this.to=t,this.dir=n,this.isolates=r,this.fresh=i,this.order=a}static update(t,n){if(n.empty&&!t.some(e=>e.fresh))return t;let r=[],i=t.length?t[t.length-1].dir:J0.LTR;for(let a=Math.max(0,t.length-10);a<t.length;a++){let o=t[a];o.dir==i&&!n.touchesRange(o.from,o.to)&&r.push(new e(n.mapPos(o.from,1),n.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return r}};function v3(e,t,n){for(let r=e.state.facet(t),i=r.length-1;i>=0;i--){let t=r[i],a=typeof t==`function`?t(e):t;a&&h0(a,n)}return n}var zxe=X.mac?`mac`:X.windows?`win`:X.linux?`linux`:`key`;function Bxe(e,t){let n=e.split(/-(?!$)/),r=n[n.length-1];r==`Space`&&(r=` `);let i,a,o,s;for(let e=0;e<n.length-1;++e){let r=n[e];if(/^(cmd|meta|m)$/i.test(r))s=!0;else if(/^a(lt)?$/i.test(r))i=!0;else if(/^(c|ctrl|control)$/i.test(r))a=!0;else if(/^s(hift)?$/i.test(r))o=!0;else if(/^mod$/i.test(r))t==`mac`?s=!0:a=!0;else throw Error(`Unrecognized modifier name: `+r)}return i&&(r=`Alt-`+r),a&&(r=`Ctrl-`+r),s&&(r=`Meta-`+r),o&&(r=`Shift-`+r),r}function y3(e,t,n){return t.altKey&&(e=`Alt-`+e),t.ctrlKey&&(e=`Ctrl-`+e),t.metaKey&&(e=`Meta-`+e),n!==!1&&t.shiftKey&&(e=`Shift-`+e),e}var Vxe=i1.default(Z.domEventHandlers({keydown(e,t){return T3(S3(t.state),e,t,`editor`)}})),b3=Y.define({enables:Vxe}),x3=new WeakMap;function S3(e){let t=e.facet(b3),n=x3.get(t);return n||x3.set(t,n=Wxe(t.reduce((e,t)=>e.concat(t),[]))),n}function Hxe(e,t,n){return T3(S3(e.state),t,e,n)}var C3=null,Uxe=4e3;function Wxe(e,t=zxe){let n=Object.create(null),r=Object.create(null),i=(e,t)=>{let n=r[e];if(n==null)r[e]=t;else if(n!=t)throw Error(`Key binding `+e+` is used both as a regular binding and as a multi-stroke prefix`)},a=(e,r,a,o,s)=>{let c=n[e]||(n[e]=Object.create(null)),l=r.split(/ (?!$)/).map(e=>Bxe(e,t));for(let t=1;t<l.length;t++){let n=l.slice(0,t).join(` `);i(n,!0),c[n]||(c[n]={preventDefault:!0,stopPropagation:!1,run:[t=>{let r=C3={view:t,prefix:n,scope:e};return setTimeout(()=>{C3==r&&(C3=null)},Uxe),!0}]})}let u=l.join(` `);i(u,!1);let d=c[u]||(c[u]={preventDefault:!1,stopPropagation:!1,run:(c._any?.run)?.slice()||[]});a&&d.run.push(a),o&&(d.preventDefault=!0),s&&(d.stopPropagation=!0)};for(let r of e){let e=r.scope?r.scope.split(` `):[`editor`];if(r.any)for(let t of e){let e=n[t]||(n[t]=Object.create(null));e._any||={preventDefault:!1,stopPropagation:!1,run:[]};let{any:i}=r;for(let t in e)e[t].run.push(e=>i(e,w3))}let i=r[t]||r.key;if(i)for(let t of e)a(t,i,r.run,r.preventDefault,r.stopPropagation),r.shift&&a(t,`Shift-`+i,r.shift,r.preventDefault,r.stopPropagation)}return n}var w3=null;function T3(e,t,n,r){w3=t;let i=ebe(t),a=I$(P$(i,0))==i.length&&i!=` `,o=``,s=!1,c=!1,l=!1;C3&&C3.view==n&&C3.scope==r&&(o=C3.prefix+` `,x4.indexOf(t.keyCode)<0&&(c=!0,C3=null));let u=new Set,d=e=>{if(e){for(let t of e.run)if(!u.has(t)&&(u.add(t),t(n)))return e.stopPropagation&&(l=!0),!0;e.preventDefault&&(e.stopPropagation&&(l=!0),c=!0)}return!1},f=e[r],p,m;return f&&(d(f[o+y3(i,t,!a)])?s=!0:a&&(t.altKey||t.metaKey||t.ctrlKey)&&!(X.windows&&t.ctrlKey&&t.altKey)&&!(X.mac&&t.altKey&&!(t.ctrlKey||t.metaKey))&&(p=Q1[t.keyCode])&&p!=i?(d(f[o+y3(p,t,!0)])||t.shiftKey&&(m=$1[t.keyCode])!=i&&m!=p&&d(f[o+y3(m,t,!1)]))&&(s=!0):a&&t.shiftKey&&d(f[o+y3(i,t,!0)])&&(s=!0),!s&&d(f._any)&&(s=!0)),c&&(s=!0),s&&l&&t.stopPropagation(),w3=null,s}/x/.unicode;function Gxe(){return qxe}var Kxe=x0.line({class:`cm-activeLine`}),qxe=T2.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.docChanged||e.selectionSet)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=-1,n=[];for(let r of e.state.selection.ranges){let i=e.lineBlockAt(r.head);i.from>t&&(n.push(Kxe.range(i.from)),t=i.from)}return x0.set(n)}},{decorations:e=>e.decorations}),E3=`-10000px`,Jxe=class{constructor(e,t,n,r){this.facet=t,this.createTooltipView=n,this.removeTooltipView=r,this.input=e.state.facet(t),this.tooltips=this.input.filter(e=>e);let i=null;this.tooltipViews=this.tooltips.map(e=>i=n(e,i))}update(e,t){var n;let r=e.state.facet(this.facet),i=r.filter(e=>e);if(r===this.input){for(let t of this.tooltipViews)t.update&&t.update(e);return!1}let a=[],o=t?[]:null;for(let n=0;n<i.length;n++){let r=i[n],s=-1;if(r){for(let e=0;e<this.tooltips.length;e++){let t=this.tooltips[e];t&&t.create==r.create&&(s=e)}if(s<0)a[n]=this.createTooltipView(r,n?a[n-1]:null),o&&(o[n]=!!r.above);else{let r=a[n]=this.tooltipViews[s];o&&(o[n]=t[s]),r.update&&r.update(e)}}}for(let e of this.tooltipViews)a.indexOf(e)<0&&(this.removeTooltipView(e),(n=e.destroy)==null||n.call(e));return t&&(o.forEach((e,n)=>t[n]=e),t.length=o.length),this.input=r,this.tooltips=i,this.tooltipViews=a,!0}};function Yxe(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}var D3=Y.define({combine:e=>({position:X.ios?`absolute`:e.find(e=>e.position)?.position||`fixed`,parent:e.find(e=>e.parent)?.parent||null,tooltipSpace:e.find(e=>e.tooltipSpace)?.tooltipSpace||Yxe})}),O3=new WeakMap,k3=T2.fromClass(class{constructor(e){this.view=e,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let t=e.state.facet(D3);this.position=t.position,this.parent=t.parent,this.classes=e.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver==`function`?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new Jxe(e,j3,(e,t)=>this.createTooltip(e,t),e=>{this.resizeObserver&&this.resizeObserver.unobserve(e.dom),e.dom.remove()}),this.above=this.manager.tooltips.map(e=>!!e.above),this.intersectionObserver=typeof IntersectionObserver==`function`?new IntersectionObserver(e=>{Date.now()>this.lastTransaction-50&&e.length>0&&e[e.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),e.win.addEventListener(`resize`,this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement(`div`),this.container.style.position=`relative`,this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let e of this.manager.tooltipViews)this.intersectionObserver.observe(e.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(e){e.transactions.length&&(this.lastTransaction=Date.now());let t=this.manager.update(e,this.above);t&&this.observeIntersection();let n=t||e.geometryChanged,r=e.state.facet(D3);if(r.position!=this.position&&!this.madeAbsolute){this.position=r.position;for(let e of this.manager.tooltipViews)e.dom.style.position=this.position;n=!0}if(r.parent!=this.parent){this.parent&&this.container.remove(),this.parent=r.parent,this.createContainer();for(let e of this.manager.tooltipViews)this.container.appendChild(e.dom);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(e,t){let n=e.create(this.view),r=t?t.dom:null;if(n.dom.classList.add(`cm-tooltip`),e.arrow&&!n.dom.querySelector(`.cm-tooltip > .cm-tooltip-arrow`)){let e=document.createElement(`div`);e.className=`cm-tooltip-arrow`,n.dom.appendChild(e)}return n.dom.style.position=this.position,n.dom.style.top=E3,n.dom.style.left=`0px`,this.container.insertBefore(n.dom,r),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var e,t,n;this.view.win.removeEventListener(`resize`,this.measureSoon);for(let t of this.manager.tooltipViews)t.dom.remove(),(e=t.destroy)==null||e.call(t);this.parent&&this.container.remove(),(t=this.resizeObserver)==null||t.disconnect(),(n=this.intersectionObserver)==null||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let e=1,t=1,n=!1;if(this.position==`fixed`&&this.manager.tooltipViews.length){let{dom:e}=this.manager.tooltipViews[0];if(X.safari){let t=e.getBoundingClientRect();n=Math.abs(t.top+1e4)>1||Math.abs(t.left)>1}else n=!!e.offsetParent&&e.offsetParent!=this.container.ownerDocument.body}if(n||this.position==`absolute`)if(this.parent){let n=this.parent.getBoundingClientRect();n.width&&n.height&&(e=n.width/this.parent.offsetWidth,t=n.height/this.parent.offsetHeight)}else ({scaleX:e,scaleY:t}=this.view.viewState);let r=this.view.scrollDOM.getBoundingClientRect(),i=I2(this.view);return{visible:{left:r.left+i.left,top:r.top+i.top,right:r.right-i.right,bottom:r.bottom-i.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((e,t)=>{let n=this.manager.tooltipViews[t];return n.getCoords?n.getCoords(e.pos):this.view.coordsAtPos(e.pos)}),size:this.manager.tooltipViews.map(({dom:e})=>e.getBoundingClientRect()),space:this.view.state.facet(D3).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:n}}writeMeasure(e){if(e.makeAbsolute){this.madeAbsolute=!0,this.position=`absolute`;for(let e of this.manager.tooltipViews)e.dom.style.position=`absolute`}let{visible:t,space:n,scaleX:r,scaleY:i}=e,a=[];for(let o=0;o<this.manager.tooltips.length;o++){let s=this.manager.tooltips[o],c=this.manager.tooltipViews[o],{dom:l}=c,u=e.pos[o],d=e.size[o];if(!u||s.clip!==!1&&(u.bottom<=Math.max(t.top,n.top)||u.top>=Math.min(t.bottom,n.bottom)||u.right<Math.max(t.left,n.left)-.1||u.left>Math.min(t.right,n.right)+.1)){l.style.top=E3;continue}let f=s.arrow?c.dom.querySelector(`.cm-tooltip-arrow`):null,p=f?7:0,m=d.right-d.left,h=O3.get(c)??d.bottom-d.top,g=c.offset||Zxe,_=this.view.textDirection==J0.LTR,v=d.width>n.right-n.left?_?n.left:n.right-d.width:_?Math.max(n.left,Math.min(u.left-(f?14:0)+g.x,n.right-m)):Math.min(Math.max(n.left,u.left-m+(f?14:0)-g.x),n.right-m),y=this.above[o];!s.strictSide&&(y?u.top-h-p-g.y<n.top:u.bottom+h+p+g.y>n.bottom)&&y==n.bottom-u.bottom>u.top-n.top&&(y=this.above[o]=!y);let b=(y?u.top-n.top:n.bottom-u.bottom)-p;if(b<h&&c.resize!==!1){if(b<this.view.defaultLineHeight){l.style.top=E3;continue}O3.set(c,h),l.style.height=(h=b)/i+`px`}else l.style.height&&(l.style.height=``);let x=y?u.top-h-p-g.y:u.bottom+p+g.y,S=v+m;if(c.overlap!==!0)for(let e of a)e.left<S&&e.right>v&&e.top<x+h&&e.bottom>x&&(x=y?e.top-h-2-p:e.bottom+p+2);if(this.position==`absolute`?(l.style.top=(x-e.parent.top)/i+`px`,A3(l,(v-e.parent.left)/r)):(l.style.top=x/i+`px`,A3(l,v/r)),f){let e=u.left+(_?g.x:-g.x)-(v+14-7);f.style.left=e/r+`px`}c.overlap!==!0&&a.push({left:v,top:x,right:S,bottom:x+h}),l.classList.toggle(`cm-tooltip-above`,y),l.classList.toggle(`cm-tooltip-below`,!y),c.positioned&&c.positioned(e.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let e of this.manager.tooltipViews)e.dom.style.top=E3}},{eventObservers:{scroll(){this.maybeMeasure()}}});function A3(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+`px`)}var Xxe=Z.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:`border-box`},"&light .cm-tooltip":{border:`1px solid #bbb`,backgroundColor:`#f5f5f5`},"&light .cm-tooltip-section:not(:first-child)":{borderTop:`1px solid #bbb`},"&dark .cm-tooltip":{backgroundColor:`#333338`,color:`white`},".cm-tooltip-arrow":{height:`7px`,width:`14px`,position:`absolute`,zIndex:-1,overflow:`hidden`,"&:before, &:after":{content:`''`,position:`absolute`,width:0,height:0,borderLeft:`7px solid transparent`,borderRight:`7px solid transparent`},".cm-tooltip-above &":{bottom:`-7px`,"&:before":{borderTop:`7px solid #bbb`},"&:after":{borderTop:`7px solid #f5f5f5`,bottom:`1px`}},".cm-tooltip-below &":{top:`-7px`,"&:before":{borderBottom:`7px solid #bbb`},"&:after":{borderBottom:`7px solid #f5f5f5`,top:`1px`}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:`#333338`,borderBottomColor:`#333338`},"&:after":{borderTopColor:`transparent`,borderBottomColor:`transparent`}}}),Zxe={x:0,y:0},j3=Y.define({enables:[k3,Xxe]});function M3(e,t){let n=e.plugin(k3);if(!n)return null;let r=n.manager.tooltips.indexOf(t);return r<0?null:n.manager.tooltipViews[r]}var N3=Y.define({combine(e){let t,n;for(let r of e)t||=r.topContainer,n||=r.bottomContainer;return{topContainer:t,bottomContainer:n}}});function P3(e,t){let n=e.plugin(F3),r=n?n.specs.indexOf(t):-1;return r>-1?n.panels[r]:null}var F3=T2.fromClass(class{constructor(e){this.input=e.state.facet(R3),this.specs=this.input.filter(e=>e),this.panels=this.specs.map(t=>t(e));let t=e.state.facet(N3);this.top=new I3(e,!0,t.topContainer),this.bottom=new I3(e,!1,t.bottomContainer),this.top.sync(this.panels.filter(e=>e.top)),this.bottom.sync(this.panels.filter(e=>!e.top));for(let e of this.panels)e.dom.classList.add(`cm-panel`),e.mount&&e.mount()}update(e){let t=e.state.facet(N3);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new I3(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new I3(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(R3);if(n!=this.input){let t=n.filter(e=>e),r=[],i=[],a=[],o=[];for(let n of t){let t=this.specs.indexOf(n),s;t<0?(s=n(e.view),o.push(s)):(s=this.panels[t],s.update&&s.update(e)),r.push(s),(s.top?i:a).push(s)}this.specs=t,this.panels=r,this.top.sync(i),this.bottom.sync(a);for(let e of o)e.dom.classList.add(`cm-panel`),e.mount&&e.mount()}else for(let t of this.panels)t.update&&t.update(e)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:e=>Z.scrollMargins.of(t=>{let n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})}),I3=class{constructor(e,t,n){this.view=e,this.top=t,this.container=n,this.dom=void 0,this.classes=``,this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&=(this.dom.remove(),void 0);return}if(!this.dom){this.dom=document.createElement(`div`),this.dom.className=this.top?`cm-panels cm-panels-top`:`cm-panels cm-panels-bottom`,this.dom.style[this.top?`top`:`bottom`]=`0`;let e=this.container||this.view.dom;e.insertBefore(this.dom,this.top?e.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=L3(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=L3(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(` `))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(` `))e&&this.container.classList.add(e)}}};function L3(e){let t=e.nextSibling;return e.remove(),t}var R3=Y.define({enables:F3});function Qxe(e,t){let n,r=new Promise(e=>n=e),i=e=>$xe(e,t,n);e.state.field(z3,!1)?e.dispatch({effects:B3.of(i)}):e.dispatch({effects:y1.appendConfig.of(z3.init(()=>[i]))});let a=V3.of(i);return{close:a,result:r.then(t=>((e.win.queueMicrotask||(t=>e.win.setTimeout(t,10)))(()=>{e.state.field(z3).indexOf(i)>-1&&e.dispatch({effects:a})}),t))}}var z3=t1.define({create(){return[]},update(e,t){for(let n of t.effects)n.is(B3)?e=[n.value].concat(e):n.is(V3)&&(e=e.filter(e=>e!=n.value));return e},provide:e=>R3.computeN([e],t=>t.field(e))}),B3=y1.define(),V3=y1.define();function $xe(e,t,n){let r=t.content?t.content(e,()=>o(null)):null;if(!r){if(r=n0(`form`),t.input){let e=n0(`input`,t.input);/^(text|password|number|email|tel|url)$/.test(e.type)&&e.classList.add(`cm-textfield`),e.name||=`input`,r.appendChild(n0(`label`,(t.label||``)+`: `,e))}else r.appendChild(document.createTextNode(t.label||``));r.appendChild(document.createTextNode(` `)),r.appendChild(n0(`button`,{class:`cm-button`,type:`submit`},t.submitLabel||`OK`))}let i=r.nodeName==`FORM`?[r]:r.querySelectorAll(`form`);for(let e=0;e<i.length;e++){let t=i[e];t.addEventListener(`keydown`,e=>{e.keyCode==27?(e.preventDefault(),o(null)):e.keyCode==13&&(e.preventDefault(),o(t))}),t.addEventListener(`submit`,e=>{e.preventDefault(),o(t)})}let a=n0(`div`,r,n0(`button`,{onclick:()=>o(null),"aria-label":e.state.phrase(`close`),class:`cm-dialog-close`,type:`button`},[`×`]));t.class&&(a.className=t.class),a.classList.add(`cm-dialog`);function o(t){a.contains(a.ownerDocument.activeElement)&&e.focus(),n(t)}return{dom:a,top:t.top,mount:()=>{if(t.focus){let e;e=typeof t.focus==`string`?r.querySelector(t.focus):r.querySelector(`input`)||r.querySelector(`button`),e&&`select`in e?e.select():e&&`focus`in e&&e.focus()}}}}var H3=class extends k1{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};H3.prototype.elementClass=``,H3.prototype.toDOM=void 0,H3.prototype.mapMode=R$.TrackBefore,H3.prototype.startSide=H3.prototype.endSide=-1,H3.prototype.point=!0;var U3=Y.define(),eSe=Y.define(),W3=Y.define(),G3=Y.define({combine:e=>e.some(e=>e)});function tSe(e){let t=[nSe];return e&&e.fixed===!1&&t.push(G3.of(!0)),t}var nSe=T2.fromClass(class{constructor(e){this.view=e,this.domAfter=null,this.prevViewport=e.viewport,this.dom=document.createElement(`div`),this.dom.className=`cm-gutters cm-gutters-before`,this.dom.setAttribute(`aria-hidden`,`true`),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+`px`,this.gutters=e.state.facet(W3).map(t=>new J3(e,t)),this.fixed=!e.state.facet(G3);for(let e of this.gutters)e.config.side==`after`?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position=`sticky`),this.syncGutters(!1),e.scrollDOM.insertBefore(this.dom,e.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement(`div`),this.domAfter.className=`cm-gutters cm-gutters-after`,this.domAfter.setAttribute(`aria-hidden`,`true`),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+`px`,this.domAfter.style.position=this.fixed?`sticky`:``,this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(e){if(this.updateGutters(e)){let t=this.prevViewport,n=e.view.viewport,r=Math.min(t.to,n.to)-Math.max(t.from,n.from);this.syncGutters(r<(n.to-n.from)*.8)}if(e.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+`px`;this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(G3)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?`sticky`:``,this.domAfter&&(this.domAfter.style.position=this.fixed?`sticky`:``)),this.prevViewport=e.view.viewport}syncGutters(e){let t=this.dom.nextSibling;e&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=N1.iter(this.view.state.facet(U3),this.view.viewport.from),r=[],i=this.gutters.map(e=>new rSe(e,this.view.viewport,-this.view.documentPadding.top));for(let e of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(e.type)){let t=!0;for(let a of e.type)if(a.type==b0.Text&&t){q3(n,r,a.from);for(let e of i)e.line(this.view,a,r);t=!1}else if(a.widget)for(let e of i)e.widget(this.view,a)}else if(e.type==b0.Text){q3(n,r,e.from);for(let t of i)t.line(this.view,e,r)}else if(e.widget)for(let t of i)t.widget(this.view,e);for(let e of i)e.finish();e&&(this.view.scrollDOM.insertBefore(this.dom,t),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(e){let t=e.startState.facet(W3),n=e.state.facet(W3),r=e.docChanged||e.heightChanged||e.viewportChanged||!N1.eq(e.startState.facet(U3),e.state.facet(U3),e.view.viewport.from,e.view.viewport.to);if(t==n)for(let t of this.gutters)t.update(e)&&(r=!0);else{r=!0;let i=[];for(let r of n){let n=t.indexOf(r);n<0?i.push(new J3(this.view,r)):(this.gutters[n].update(e),i.push(this.gutters[n]))}for(let e of this.gutters)e.dom.remove(),i.indexOf(e)<0&&e.destroy();for(let e of i)e.config.side==`after`?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.gutters=i}return r}destroy(){for(let e of this.gutters)e.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:e=>Z.scrollMargins.of(t=>{let n=t.plugin(e);if(!n||n.gutters.length==0||!n.fixed)return null;let r=n.dom.offsetWidth*t.scaleX,i=n.domAfter?n.domAfter.offsetWidth*t.scaleX:0;return t.textDirection==J0.LTR?{left:r,right:i}:{right:r,left:i}})});function K3(e){return Array.isArray(e)?e:[e]}function q3(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}var rSe=class{constructor(e,t,n){this.gutter=e,this.height=n,this.i=0,this.cursor=N1.iter(e.markers,t.from)}addElement(e,t,n){let{gutter:r}=this,i=(t.top-this.height)/e.scaleY,a=t.height/e.scaleY;if(this.i==r.elements.length){let t=new Y3(e,a,i,n);r.elements.push(t),r.dom.appendChild(t.dom)}else r.elements[this.i].update(e,a,i,n);this.height=t.bottom,this.i++}line(e,t,n){let r=[];q3(this.cursor,r,t.from),n.length&&(r=r.concat(n));let i=this.gutter.config.lineMarker(e,t,r);i&&r.unshift(i);let a=this.gutter;r.length==0&&!a.config.renderEmptyElements||this.addElement(e,t,r)}widget(e,t){let n=this.gutter.config.widgetMarker(e,t.widget,t),r=n?[n]:null;for(let n of e.state.facet(eSe)){let i=n(e,t.widget,t);i&&(r||=[]).push(i)}r&&this.addElement(e,t,r)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}},J3=class{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement(`div`),this.dom.className=`cm-gutter`+(this.config.class?` `+this.config.class:``);for(let n in t.domEventHandlers)this.dom.addEventListener(n,r=>{let i=r.target,a;if(i!=this.dom&&this.dom.contains(i)){for(;i.parentNode!=this.dom;)i=i.parentNode;let e=i.getBoundingClientRect();a=(e.top+e.bottom)/2}else a=r.clientY;let o=e.lineBlockAtHeight(a-e.documentTop);t.domEventHandlers[n](e,o,r)&&r.preventDefault()});this.markers=K3(t.markers(e)),t.initialSpacer&&(this.spacer=new Y3(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+=`visibility: hidden; pointer-events: none`)}update(e){let t=this.markers;if(this.markers=K3(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let t=this.config.updateSpacer(this.spacer.markers[0],e);t!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[t])}let n=e.view.viewport;return!N1.eq(this.markers,t,n.from,n.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}},Y3=class{constructor(e,t,n,r){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement(`div`),this.dom.className=`cm-gutterElement`,this.update(e,t,n,r)}update(e,t,n,r){this.height!=t&&(this.height=t,this.dom.style.height=t+`px`),this.above!=n&&(this.dom.style.marginTop=(this.above=n)?n+`px`:``),iSe(this.markers,r)||this.setMarkers(e,r)}setMarkers(e,t){let n=`cm-gutterElement`,r=this.dom.firstChild;for(let i=0,a=0;;){let o=a,s=i<t.length?t[i++]:null,c=!1;if(s){let e=s.elementClass;e&&(n+=` `+e);for(let e=a;e<this.markers.length;e++)if(this.markers[e].compare(s)){o=e,c=!0;break}}else o=this.markers.length;for(;a<o;){let e=this.markers[a++];if(e.toDOM){e.destroy(r);let t=r.nextSibling;r.remove(),r=t}}if(!s)break;s.toDOM&&(c?r=r.nextSibling:this.dom.insertBefore(s.toDOM(e),r)),c&&a++}this.dom.className=n,this.markers=t}destroy(){this.setMarkers(null,[])}};function iSe(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].compare(t[n]))return!1;return!0}var aSe=Y.define(),oSe=Y.define(),X3=Y.define({combine(e){return O1(e,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let n=Object.assign({},e);for(let e in t){let r=n[e],i=t[e];n[e]=r?(e,t,n)=>r(e,t,n)||i(e,t,n):i}return n}})}}),Z3=class extends H3{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}};function Q3(e,t){return e.state.facet(X3).formatNumber(t,e.state)}var sSe=W3.compute([X3],e=>({class:`cm-lineNumbers`,renderEmptyElements:!1,markers(e){return e.state.facet(aSe)},lineMarker(e,t,n){return n.some(e=>e.toDOM)?null:new Z3(Q3(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,n)=>{for(let r of e.state.facet(oSe)){let i=r(e,t,n);if(i)return i}return null},lineMarkerChange:e=>e.startState.facet(X3)!=e.state.facet(X3),initialSpacer(e){return new Z3(Q3(e,$3(e.state.doc.lines)))},updateSpacer(e,t){let n=Q3(t.view,$3(t.view.state.doc.lines));return n==e.number?e:new Z3(n)},domEventHandlers:e.facet(X3).domEventHandlers,side:`before`}));function cSe(e={}){return[X3.of(e),tSe(),sSe]}function $3(e){let t=9;for(;t<e;)t=t*10+9;return t}var lSe=new class extends H3{constructor(){super(...arguments),this.elementClass=`cm-activeLineGutter`}},uSe=U3.compute([`selection`],e=>{let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.head).from;i>n&&(n=i,t.push(lSe.range(i)))}return N1.of(t)});function dSe(){return uSe}var e6=1024,fSe=0,t6=class{constructor(e,t){this.from=e,this.to=t}},n6=class{constructor(e={}){this.id=fSe++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw Error(`This node type doesn't define a deserialize function`)}),this.combine=e.combine||null}add(e){if(this.perNode)throw RangeError(`Can't add per-node props to node types`);return typeof e!=`function`&&(e=i6.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}};n6.closedBy=new n6({deserialize:e=>e.split(` `)}),n6.openedBy=new n6({deserialize:e=>e.split(` `)}),n6.group=new n6({deserialize:e=>e.split(` `)}),n6.isolate=new n6({deserialize:e=>{if(e&&e!=`rtl`&&e!=`ltr`&&e!=`auto`)throw RangeError(`Invalid value for isolate: `+e);return e||`auto`}}),n6.contextHash=new n6({perNode:!0}),n6.lookAhead=new n6({perNode:!0}),n6.mounted=new n6({perNode:!0});var r6=class{constructor(e,t,n,r=!1){this.tree=e,this.overlay=t,this.parser=n,this.bracketed=r}static get(e){return e&&e.props&&e.props[n6.mounted.id]}},pSe=Object.create(null),i6=class e{constructor(e,t,n,r=0){this.name=e,this.props=t,this.id=n,this.flags=r}static define(t){let n=t.props&&t.props.length?Object.create(null):pSe,r=!!t.top|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),i=new e(t.name||``,n,t.id,r);if(t.props){for(let e of t.props)if(Array.isArray(e)||(e=e(i)),e){if(e[0].perNode)throw RangeError(`Can't store a per-node prop on a node type`);n[e[0].id]=e[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(n6.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let r of n.split(` `))t[r]=e[n];return e=>{for(let n=e.prop(n6.group),r=-1;r<(n?n.length:0);r++){let i=t[r<0?e.name:n[r]];if(i)return i}}}};i6.none=new i6(``,Object.create(null),0,8);var mSe=class e{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw RangeError(`Node type ids should correspond to array positions when creating a node set`)}extend(...t){let n=[];for(let e of this.types){let r=null;for(let n of t){let t=n(e);if(t){r||=Object.assign({},e.props);let n=t[1],i=t[0];i.combine&&i.id in r&&(n=i.combine(r[i.id],n)),r[i.id]=n}}n.push(r?new i6(e.name,r,e.id,e.flags):e)}return new e(n)}},a6=new WeakMap,o6=new WeakMap,s6;(function(e){e[e.ExcludeBuffers=1]=`ExcludeBuffers`,e[e.IncludeAnonymous=2]=`IncludeAnonymous`,e[e.IgnoreMounts=4]=`IgnoreMounts`,e[e.IgnoreOverlays=8]=`IgnoreOverlays`,e[e.EnterBracketed=16]=`EnterBracketed`})(s6||={});var c6=class e{constructor(e,t,n,r,i){if(this.type=e,this.children=t,this.positions=n,this.length=r,this.props=null,i&&i.length){this.props=Object.create(null);for(let[e,t]of i)this.props[typeof e==`number`?e:e.id]=t}}toString(){let e=r6.get(this);if(e&&!e.overlay)return e.tree.toString();let t=``;for(let e of this.children){let n=e.toString();n&&(t&&(t+=`,`),t+=n)}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 v6(this.topNode,e)}cursorAt(e,t=0,n=0){let r=new v6(a6.get(this)||this.topNode);return r.moveTo(e,t),a6.set(this,r._tree),r}get topNode(){return new p6(this,0,0,null)}resolve(e,t=0){let n=d6(a6.get(this)||this.topNode,e,t,!1);return a6.set(this,n),n}resolveInner(e,t=0){let n=d6(o6.get(this)||this.topNode,e,t,!0);return o6.set(this,n),n}resolveStack(e,t=0){return vSe(this,e,t)}iterate(e){let{enter:t,leave:n,from:r=0,to:i=this.length}=e,a=e.mode||0,o=(a&s6.IncludeAnonymous)>0;for(let e=this.cursor(a|s6.IncludeAnonymous);;){let a=!1;if(e.from<=i&&e.to>=r&&(!o&&e.type.isAnonymous||t(e)!==!1)){if(e.firstChild())continue;a=!0}for(;a&&n&&(o||!e.type.isAnonymous)&&n(e),!e.nextSibling();){if(!e.parent())return;a=!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(t={}){return this.children.length<=8?this:S6(i6.none,this.children,this.positions,0,this.children.length,0,this.length,(t,n,r)=>new e(this.type,t,n,r,this.propValues),t.makeTree||((t,n,r)=>new e(i6.none,t,n,r)))}static build(e){return ySe(e)}};c6.empty=new c6(i6.none,[],[],0);var hSe=class e{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 e(this.buffer,this.index)}},l6=class e{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return i6.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],n=this.buffer[e+3],r=this.set.types[t],i=r.name;if(/\W/.test(i)&&!r.isError&&(i=JSON.stringify(i)),e+=4,n==e)return i;let a=[];for(;e<n;)a.push(this.childString(e)),e=this.buffer[e+3];return i+`(`+a.join(`,`)+`)`}findChild(e,t,n,r,i){let{buffer:a}=this,o=-1;for(let s=e;s!=t&&!(u6(i,r,a[s+1],a[s+2])&&(o=s,n>0));s=a[s+3]);return o}slice(t,n,r){let i=this.buffer,a=new Uint16Array(n-t),o=0;for(let e=t,s=0;e<n;){a[s++]=i[e++],a[s++]=i[e++]-r;let n=a[s++]=i[e++]-r;a[s++]=i[e++]-t,o=Math.max(o,n)}return new e(a,o,this.set)}};function u6(e,t,n,r){switch(e){case-2:return n<t;case-1:return r>=t&&n<t;case 0:return n<t&&r>t;case 1:return n<=t&&r>t;case 2:return r>t;case 4:return!0}}function d6(e,t,n,r){for(;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to<t);){let t=!r&&e instanceof p6&&e.index<0?null:e.parent;if(!t)return e;e=t}let i=r?0:s6.IgnoreOverlays;if(r)for(let r=e,a=r.parent;a;r=a,a=r.parent)r instanceof p6&&r.index<0&&a.enter(t,n,i)?.from!=r.from&&(e=a);for(;;){let r=e.enter(t,n,i);if(!r)return e;e=r}}var f6=class{cursor(e=0){return new v6(this,e)}getChild(e,t=null,n=null){let r=m6(this,e,t,n);return r.length?r[0]:null}getChildren(e,t=null,n=null){return m6(this,e,t,n)}resolve(e,t=0){return d6(this,e,t,!1)}resolveInner(e,t=0){return d6(this,e,t,!0)}matchContext(e){return h6(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),n=this;for(;t;){let e=t.lastChild;if(!e||e.to!=t.to)break;e.type.isError&&e.from==e.to?(n=t,t=e.prevSibling):t=e}return n}get node(){return this}get next(){return this.parent}},p6=class e extends f6{constructor(e,t,n,r){super(),this._tree=e,this.from=t,this.index=n,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,n,r,i,a=0){for(let o=this;;){for(let{children:s,positions:c}=o._tree,l=n>0?s.length:-1;t!=l;t+=n){let l=s[t],u=c[t]+o.from,d;if(!(!(a&s6.EnterBracketed&&l instanceof c6&&(d=r6.get(l))&&!d.overlay&&d.bracketed&&r>=u&&r<=u+l.length)&&!u6(i,r,u,u+l.length))){if(l instanceof l6){if(a&s6.ExcludeBuffers)continue;let e=l.findChild(0,l.buffer.length,n,r-u,i);if(e>-1)return new g6(new gSe(o,l,t,u),null,e)}else if(a&s6.IncludeAnonymous||!l.type.isAnonymous||y6(l)){let s;if(!(a&s6.IgnoreMounts)&&(s=r6.get(l))&&!s.overlay)return new e(s.tree,u,t,o);let c=new e(l,u,t,o);return a&s6.IncludeAnonymous||!c.type.isAnonymous?c:c.nextChild(n<0?l.children.length-1:0,n,r,i,a)}}}if(a&s6.IncludeAnonymous||!o.type.isAnonymous||(t=o.index>=0?o.index+n:n<0?-1:o._parent._tree.children.length,o=o._parent,!o))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)}prop(e){return this._tree.prop(e)}enter(t,n,r=0){let i;if(!(r&s6.IgnoreOverlays)&&(i=r6.get(this._tree))&&i.overlay){let a=t-this.from,o=r&s6.EnterBracketed&&i.bracketed;for(let{from:t,to:r}of i.overlay)if((n>0||o?t<=a:t<a)&&(n<0||o?r>=a:r>a))return new e(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,n,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}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}};function m6(e,t,n,r){let i=e.cursor(),a=[];if(!i.firstChild())return a;if(n!=null){for(let e=!1;!e;)if(e=i.type.is(n),!i.nextSibling())return a}for(;;){if(r!=null&&i.type.is(r))return a;if(i.type.is(t)&&a.push(i.node),!i.nextSibling())return r==null?a:[]}}function h6(e,t,n=t.length-1){for(let r=e;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}var gSe=class{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}},g6=class e extends f6{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,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(t,n,r){let{buffer:i}=this.context,a=i.findChild(this.index+4,i.buffer[this.index+3],t,n-this.context.start,r);return a<0?null:new e(this.context,this,a)}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)}prop(e){return this.type.prop(e)}enter(t,n,r=0){if(r&s6.ExcludeBuffers)return null;let{buffer:i}=this.context,a=i.findChild(this.index+4,i.buffer[this.index+3],n>0?1:-1,t-this.context.start,n);return a<0?null:new e(this.context,this,a)}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:t}=this.context,n=t.buffer[this.index+3];return n<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new e(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new e(this.context,this._parent,t.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,r=this.index+4,i=n.buffer[this.index+3];if(i>r){let a=n.buffer[this.index+1];e.push(n.slice(r,i,a)),t.push(0)}return new c6(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function _6(e){if(!e.length)return null;let t=0,n=e[0];for(let r=1;r<e.length;r++){let i=e[r];(i.from>n.from||i.to<n.to)&&(n=i,t=r)}let r=n instanceof p6&&n.index<0?null:n.parent,i=e.slice();return r?i[t]=r:i.splice(t,1),new _Se(i,n)}var _Se=class{constructor(e,t){this.heads=e,this.node=t}get next(){return _6(this.heads)}};function vSe(e,t,n){let r=e.resolveInner(t,n),i=null;for(let e=r instanceof p6?r:r.context.parent;e;e=e.parent)if(e.index<0){let a=e.parent;(i||=[r]).push(a.resolve(t,n)),e=a}else{let a=r6.get(e.tree);if(a&&a.overlay&&a.overlay[0].from<=t&&a.overlay[a.overlay.length-1].to>=t){let o=new p6(a.tree,a.overlay[0].from+e.from,-1,e);(i||=[r]).push(d6(o,t,n,!1))}}return i?_6(i):r}var v6=class{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~s6.EnterBracketed,e instanceof p6)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.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:n,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=n+r.buffer[e+1],this.to=n+r.buffer[e+2],!0}yield(e){return e?e instanceof p6?(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,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:r}=this.buffer,i=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,n);return i<0?!1:(this.stack.push(this.index),this.yieldBuf(i))}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,n=this.mode){return this.buffer?n&s6.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&s6.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&s6.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,n=this.stack.length-1;if(e<0){let e=n<0?0:this.stack[n]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(e)}return n<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,n,{buffer:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let e=0;e<this.index;e++)if(r.buffer.buffer[e+3]<this.index)return!1;({index:t,parent:n}=r)}else ({index:t,_parent:n}=this._tree);for(;n;{index:t,_parent:n}=n)if(t>-1)for(let r=t+e,i=e<0?-1:n._tree.children.length;r!=i;r+=e){let e=n._tree.children[r];if(this.mode&s6.IncludeAnonymous||e instanceof l6||!e.type.isAnonymous||y6(e))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,n=0;if(e&&e.context==this.buffer)scan:for(let r=this.index,i=this.stack.length;i>=0;){for(let a=e;a;a=a._parent)if(a.index==r){if(r==this.index)return a;t=a,n=i+1;break scan}r=this.stack[--i]}for(let e=n;e<this.stack.length;e++)t=new g6(this.buffer,t,this.stack[e]);return this.bufferNode=new g6(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let r=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){n++;continue}this.type.isAnonymous||(r=!0)}for(;;){if(r&&t&&t(this),r=this.type.isAnonymous,!n)return;if(this.nextSibling())break;this.parent(),n--,r=!0}}}matchContext(e){if(!this.buffer)return h6(this.node.parent,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let r=e.length-1,i=this.stack.length-1;r>=0;i--){if(i<0)return h6(this._tree,e,r);let a=n[t.buffer[this.stack[i]]];if(!a.isAnonymous){if(e[r]&&e[r]!=a.name)return!1;r--}}return!0}};function y6(e){return e.children.some(e=>e instanceof l6||!e.type.isAnonymous||y6(e))}function ySe(e){let{buffer:t,nodeSet:n,maxBufferLength:r=e6,reused:i=[],minRepeatType:a=n.types.length}=e,o=Array.isArray(t)?new hSe(t,t.length):t,s=n.types,c=0,l=0;function u(e,t,_,v,y,b){let{id:x,start:S,end:C,size:w}=o,T=l,E=c;if(w<0)if(o.next(),w==-1){let t=i[x];_.push(t),v.push(S-e);return}else if(w==-3){c=x;return}else if(w==-4){l=x;return}else throw RangeError(`Unrecognized record size: ${w}`);let D=s[x],O,k,ee=S-e;if(C-S<=r&&(k=h(o.pos-t,y))){let t=new Uint16Array(k.size-k.skip),r=o.pos-k.size,i=t.length;for(;o.pos>r;)i=g(k.start,t,i);O=new l6(t,C-k.start,n),ee=k.start-e}else{let e=o.pos-w;o.next();let t=[],n=[],i=x>=a?x:-1,s=0,c=C;for(;o.pos>e;)i>=0&&o.id==i&&o.size>=0?(o.end<=c-r&&(p(t,n,S,s,o.end,c,i,T,E),s=t.length,c=o.end),o.next()):b>2500?d(S,e,t,n):u(S,e,t,n,i,b+1);if(i>=0&&s>0&&s<t.length&&p(t,n,S,s,S,c,i,T,E),t.reverse(),n.reverse(),i>-1&&s>0){let e=f(D,E);O=S6(D,t,n,0,t.length,0,C-S,e,e)}else O=m(D,t,n,C-S,T-C,E)}_.push(O),v.push(ee)}function d(e,t,i,a){let s=[],c=0,l=-1;for(;o.pos>t;){let{id:e,start:t,end:n,size:i}=o;if(i>4)o.next();else if(l>-1&&t<l)break;else l<0&&(l=n-r),s.push(e,t,n),c++,o.next()}if(c){let t=new Uint16Array(c*4),r=s[s.length-2];for(let e=s.length-3,n=0;e>=0;e-=3)t[n++]=s[e],t[n++]=s[e+1]-r,t[n++]=s[e+2]-r,t[n++]=n;i.push(new l6(t,s[2]-r,n)),a.push(r-e)}}function f(e,t){return(n,r,i)=>{let a=0,o=n.length-1,s,c;if(o>=0&&(s=n[o])instanceof c6){if(!o&&s.type==e&&s.length==i)return s;(c=s.prop(n6.lookAhead))&&(a=r[o]+s.length+c)}return m(e,n,r,i,a,t)}}function p(e,t,r,i,a,o,s,c,l){let u=[],d=[];for(;e.length>i;)u.push(e.pop()),d.push(t.pop()+r-a);e.push(m(n.types[s],u,d,o-a,c-o,l)),t.push(a-r)}function m(e,t,n,r,i,a,o){if(a){let e=[n6.contextHash,a];o=o?[e].concat(o):[e]}if(i>25){let e=[n6.lookAhead,i];o=o?[e].concat(o):[e]}return new c6(e,t,n,r,o)}function h(e,t){let n=o.fork(),i=0,s=0,c=0,l=n.end-r,u={size:0,start:0,skip:0};scan:for(let r=n.pos-e;n.pos>r;){let e=n.size;if(n.id==t&&e>=0){u.size=i,u.start=s,u.skip=c,c+=4,i+=4,n.next();continue}let o=n.pos-e;if(e<0||o<r||n.start<l)break;let d=n.id>=a?4:0,f=n.start;for(n.next();n.pos>o;){if(n.size<0)if(n.size==-3||n.size==-4)d+=4;else break scan;else n.id>=a&&(d+=4);n.next()}s=f,i+=e,c+=d}return(t<0||i==e)&&(u.size=i,u.start=s,u.skip=c),u.size>4?u:void 0}function g(e,t,n){let{id:r,start:i,end:s,size:u}=o;if(o.next(),u>=0&&r<a){let a=n;if(u>4){let r=o.pos-(u-4);for(;o.pos>r;)n=g(e,t,n)}t[--n]=a,t[--n]=s-e,t[--n]=i-e,t[--n]=r}else u==-3?c=r:u==-4&&(l=r);return n}let _=[],v=[];for(;o.pos>0;)u(e.start||0,e.bufferStart||0,_,v,-1,0);let y=e.length??(_.length?v[0]+_[0].length:0);return new c6(s[e.topID],_.reverse(),v.reverse(),y)}var b6=new WeakMap;function x6(e,t){if(!e.isAnonymous||t instanceof l6||t.type!=e)return 1;let n=b6.get(t);if(n==null){n=1;for(let r of t.children){if(r.type!=e||!(r instanceof c6)){n=1;break}n+=x6(e,r)}b6.set(t,n)}return n}function S6(e,t,n,r,i,a,o,s,c){let l=0;for(let n=r;n<i;n++)l+=x6(e,t[n]);let u=Math.ceil(l*1.5/8),d=[],f=[];function p(t,n,r,i,o){for(let s=r;s<i;){let r=s,l=n[s],m=x6(e,t[s]);for(s++;s<i;s++){let n=x6(e,t[s]);if(m+n>=u)break;m+=n}if(s==r+1){if(m>u){let e=t[r];p(e.children,e.positions,0,e.children.length,n[r]+o);continue}d.push(t[r])}else{let i=n[s-1]+t[s-1].length-l;d.push(S6(e,t,n,r,s,l,i,null,c))}f.push(l+o-a)}}return p(t,n,r,i,0),(s||c)(d,f,o)}var C6=class e{constructor(e,t,n,r,i=!1,a=!1){this.from=e,this.to=t,this.tree=n,this.offset=r,this.open=!!i|(a?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(t,n=[],r=!1){let i=[new e(0,t.length,t,0,!1,r)];for(let e of n)e.to>t.length&&i.push(e);return i}static applyChanges(t,n,r=128){if(!n.length)return t;let i=[],a=1,o=t.length?t[0]:null;for(let s=0,c=0,l=0;;s++){let u=s<n.length?n[s]:null,d=u?u.fromA:1e9;if(d-c>=r)for(;o&&o.from<d;){let n=o;if(c>=n.from||d<=n.to||l){let t=Math.max(n.from,c)-l,r=Math.min(n.to,d)-l;n=t>=r?null:new e(t,r,n.tree,n.offset+l,s>0,!!u)}if(n&&i.push(n),o.to>d)break;o=a<t.length?t[a++]:null}if(!u)break;c=u.toA,l=u.toA-u.toB}return i}},w6=class{startParse(e,t,n){return typeof e==`string`&&(e=new bSe(e)),n=n?n.length?n.map(e=>new t6(e.from,e.to)):[new t6(0,0)]:[new t6(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let r=this.startParse(e,t,n);for(;;){let e=r.advance();if(e)return e}}},bSe=class{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)}};new n6({perNode:!0});var xSe=0,T6=class e{constructor(e,t,n,r){this.name=e,this.set=t,this.base=n,this.modified=r,this.id=xSe++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(t,n){let r=typeof t==`string`?t:`?`;if(t instanceof e&&(n=t),n?.base)throw Error(`Can not derive from a modified tag`);let i=new e(r,[],null,[]);if(i.set.push(i),n)for(let e of n.set)i.set.push(e);return i}static defineModifier(e){let t=new E6(e);return e=>e.modified.indexOf(t)>-1?e:E6.get(e.base||e,e.modified.concat(t).sort((e,t)=>e.id-t.id))}},SSe=0,E6=class e{constructor(e){this.name=e,this.instances=[],this.id=SSe++}static get(t,n){if(!n.length)return t;let r=n[0].instances.find(e=>e.base==t&&CSe(n,e.modified));if(r)return r;let i=[],a=new T6(t.name,i,t,n);for(let e of n)e.instances.push(a);let o=wSe(n);for(let n of t.set)if(!n.modified.length)for(let t of o)i.push(e.get(n,t));return a}};function CSe(e,t){return e.length==t.length&&e.every((e,n)=>e==t[n])}function wSe(e){let t=[[]];for(let n=0;n<e.length;n++)for(let r=0,i=t.length;r<i;r++)t.push(t[r].concat(e[n]));return t.sort((e,t)=>t.length-e.length)}function D6(e){let t=Object.create(null);for(let n in e){let r=e[n];Array.isArray(r)||(r=[r]);for(let e of n.split(` `))if(e){let n=[],i=2,a=e;for(let t=0;;){if(a==`...`&&t>0&&t+3==e.length){i=1;break}let r=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!r)throw RangeError(`Invalid path: `+e);if(n.push(r[0]==`*`?``:r[0][0]==`"`?JSON.parse(r[0]):r[0]),t+=r[0].length,t==e.length)break;let o=e[t++];if(t==e.length&&o==`!`){i=0;break}if(o!=`/`)throw RangeError(`Invalid path: `+e);a=e.slice(t)}let o=n.length-1,s=n[o];if(!s)throw RangeError(`Invalid path: `+e);t[s]=new k6(r,i,o>0?n.slice(0,o):null).sort(t[s])}}return O6.add(t)}var O6=new n6({combine(e,t){let n,r,i;for(;e||t;){if(!e||t&&e.depth>=t.depth?(i=t,t=t.next):(i=e,e=e.next),n&&n.mode==i.mode&&!i.context&&!n.context)continue;let a=new k6(i.tags,i.mode,i.context);n?n.next=a:r=a,n=a}return r}}),k6=class{constructor(e,t,n,r){this.tags=e,this.mode=t,this.context=n,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}};k6.empty=new k6([],2,null);function A6(e,t){let n=Object.create(null);for(let t of e)if(!Array.isArray(t.tag))n[t.tag.id]=t.class;else for(let e of t.tag)n[e.id]=t.class;let{scope:r,all:i=null}=t||{};return{style:e=>{let t=i;for(let r of e)for(let e of r.set){let r=n[e.id];if(r){t=t?t+` `+r:r;break}}return t},scope:r}}function TSe(e,t){let n=null;for(let r of e){let e=r.style(t);e&&(n=n?n+` `+e:e)}return n}function ESe(e,t,n,r=0,i=e.length){let a=new DSe(r,Array.isArray(t)?t:[t],n);a.highlightRange(e.cursor(),r,i,``,a.highlighters),a.flush(i)}var DSe=class{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=``}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,n,r,i){let{type:a,from:o,to:s}=e;if(o>=n||s<=t)return;a.isTop&&(i=this.highlighters.filter(e=>!e.scope||e.scope(a)));let c=r,l=OSe(e)||k6.empty,u=TSe(i,l.tags);if(u&&(c&&(c+=` `),c+=u,l.mode==1&&(r+=(r?` `:``)+u)),this.startSpan(Math.max(t,o),c),l.opaque)return;let d=e.tree&&e.tree.prop(n6.mounted);if(d&&d.overlay){let a=e.node.enter(d.overlay[0].from+o,1),l=this.highlighters.filter(e=>!e.scope||e.scope(d.tree.type)),u=e.firstChild();for(let f=0,p=o;;f++){let m=f<d.overlay.length?d.overlay[f]:null,h=m?m.from+o:s,g=Math.max(t,p),_=Math.min(n,h);if(g<_&&u)for(;e.from<_&&(this.highlightRange(e,g,_,r,i),this.startSpan(Math.min(_,e.to),c),!(e.to>=h||!e.nextSibling())););if(!m||h>n)break;p=m.to+o,p>t&&(this.highlightRange(a.cursor(),Math.max(t,m.from+o),Math.min(n,p),``,l),this.startSpan(Math.min(n,p),c))}u&&e.parent()}else if(e.firstChild()){d&&(r=``);do{if(e.to<=t)continue;if(e.from>=n)break;this.highlightRange(e,t,n,r,i),this.startSpan(Math.min(n,e.to),c)}while(e.nextSibling());e.parent()}}};function OSe(e){let t=e.type.prop(O6);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}var Q=T6.define,j6=Q(),M6=Q(),N6=Q(M6),P6=Q(M6),F6=Q(),I6=Q(F6),L6=Q(F6),R6=Q(),z6=Q(R6),B6=Q(),V6=Q(),H6=Q(),U6=Q(H6),W6=Q(),$={comment:j6,lineComment:Q(j6),blockComment:Q(j6),docComment:Q(j6),name:M6,variableName:Q(M6),typeName:N6,tagName:Q(N6),propertyName:P6,attributeName:Q(P6),className:Q(M6),labelName:Q(M6),namespace:Q(M6),macroName:Q(M6),literal:F6,string:I6,docString:Q(I6),character:Q(I6),attributeValue:Q(I6),number:L6,integer:Q(L6),float:Q(L6),bool:Q(F6),regexp:Q(F6),escape:Q(F6),color:Q(F6),url:Q(F6),keyword:B6,self:Q(B6),null:Q(B6),atom:Q(B6),unit:Q(B6),modifier:Q(B6),operatorKeyword:Q(B6),controlKeyword:Q(B6),definitionKeyword:Q(B6),moduleKeyword:Q(B6),operator:V6,derefOperator:Q(V6),arithmeticOperator:Q(V6),logicOperator:Q(V6),bitwiseOperator:Q(V6),compareOperator:Q(V6),updateOperator:Q(V6),definitionOperator:Q(V6),typeOperator:Q(V6),controlOperator:Q(V6),punctuation:H6,separator:Q(H6),bracket:U6,angleBracket:Q(U6),squareBracket:Q(U6),paren:Q(U6),brace:Q(U6),content:R6,heading:z6,heading1:Q(z6),heading2:Q(z6),heading3:Q(z6),heading4:Q(z6),heading5:Q(z6),heading6:Q(z6),contentSeparator:Q(R6),list:Q(R6),quote:Q(R6),emphasis:Q(R6),strong:Q(R6),link:Q(R6),monospace:Q(R6),strikethrough:Q(R6),inserted:Q(),deleted:Q(),changed:Q(),invalid:Q(),meta:W6,documentMeta:Q(W6),annotation:Q(W6),processingInstruction:Q(W6),definition:T6.defineModifier(`definition`),constant:T6.defineModifier(`constant`),function:T6.defineModifier(`function`),standard:T6.defineModifier(`standard`),local:T6.defineModifier(`local`),special:T6.defineModifier(`special`)};for(let e in $){let t=$[e];t instanceof T6&&(t.name=e)}A6([{tag:$.link,class:`tok-link`},{tag:$.heading,class:`tok-heading`},{tag:$.emphasis,class:`tok-emphasis`},{tag:$.strong,class:`tok-strong`},{tag:$.keyword,class:`tok-keyword`},{tag:$.atom,class:`tok-atom`},{tag:$.bool,class:`tok-bool`},{tag:$.url,class:`tok-url`},{tag:$.labelName,class:`tok-labelName`},{tag:$.inserted,class:`tok-inserted`},{tag:$.deleted,class:`tok-deleted`},{tag:$.literal,class:`tok-literal`},{tag:$.string,class:`tok-string`},{tag:$.number,class:`tok-number`},{tag:[$.regexp,$.escape,$.special($.string)],class:`tok-string2`},{tag:$.variableName,class:`tok-variableName`},{tag:$.local($.variableName),class:`tok-variableName tok-local`},{tag:$.definition($.variableName),class:`tok-variableName tok-definition`},{tag:$.special($.variableName),class:`tok-variableName2`},{tag:$.definition($.propertyName),class:`tok-propertyName tok-definition`},{tag:$.typeName,class:`tok-typeName`},{tag:$.namespace,class:`tok-namespace`},{tag:$.className,class:`tok-className`},{tag:$.macroName,class:`tok-macroName`},{tag:$.propertyName,class:`tok-propertyName`},{tag:$.operator,class:`tok-operator`},{tag:$.comment,class:`tok-comment`},{tag:$.meta,class:`tok-meta`},{tag:$.invalid,class:`tok-invalid`},{tag:$.punctuation,class:`tok-punctuation`}]);var G6=new n6;function kSe(e){return Y.define({combine:e?t=>t.concat(e):void 0})}var ASe=new n6,K6=class{constructor(e,t,n=[],r=``){this.data=e,this.name=r,D1.prototype.hasOwnProperty(`tree`)||Object.defineProperty(D1.prototype,"tree",{get(){return J6(this)}}),this.parser=t,this.extension=[e8.of(this),D1.languageData.of((e,t,n)=>{let r=q6(e,t,n),i=r.type.prop(G6);if(!i)return[];let a=e.facet(i),o=r.type.prop(ASe);if(o){let i=r.resolve(t-r.from,n);for(let t of o)if(t.test(i,e)){let n=e.facet(t.facet);return t.type==`replace`?n:n.concat(a)}}return a})].concat(n)}isActiveAt(e,t,n=-1){return q6(e,t,n).type.prop(G6)==this.data}findRegions(e){let t=e.facet(e8);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],r=(e,t)=>{if(e.prop(G6)==this.data){n.push({from:t,to:t+e.length});return}let i=e.prop(n6.mounted);if(i){if(i.tree.prop(G6)==this.data){if(i.overlay)for(let e of i.overlay)n.push({from:e.from+t,to:e.to+t});else n.push({from:t,to:t+e.length});return}else if(i.overlay){let e=n.length;if(r(i.tree,i.overlay[0].from+t),n.length>e)return}}for(let n=0;n<e.children.length;n++){let i=e.children[n];i instanceof c6&&r(i,e.positions[n]+t)}};return r(J6(e),0),n}get allowsNesting(){return!0}};K6.setState=y1.define();function q6(e,t,n){let r=e.facet(e8),i=J6(e).topNode;if(!r||r.allowsNesting)for(let e=i;e;e=e.enter(t,n,s6.ExcludeBuffers|s6.EnterBracketed))e.type.isTop&&(i=e);return i}var jSe=class e extends K6{constructor(e,t,n){super(e,t,[],n),this.parser=t}static define(t){let n=kSe(t.languageData);return new e(n,t.parser.configure({props:[G6.add(e=>e.isTop?n:void 0)]}),t.name)}configure(t,n){return new e(this.data,this.parser.configure(t),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}};function J6(e){let t=e.field(K6.state,!1);return t?t.tree:c6.empty}var MSe=class{constructor(e){this.doc=e,this.cursorPos=0,this.string=``,this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let n=this.cursorPos-this.string.length;return e<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}},Y6=null,NSe=class e{constructor(e,t,n=[],r,i,a,o,s){this.parser=e,this.state=t,this.fragments=n,this.tree=r,this.treeLen=i,this.viewport=a,this.skipped=o,this.scheduleOn=s,this.parse=null,this.tempSkipped=[]}static create(t,n,r){return new e(t,n,[],c6.empty,0,r,[],null)}startParse(){return this.parser.startParse(new MSe(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=c6.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{if(typeof e==`number`){let t=Date.now()+e;e=()=>Date.now()>t}for(this.parse||=this.startParse(),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let n=this.parse.advance();if(n)if(this.fragments=this.withoutTempSkipped(C6.addTree(n,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=this.parse.stoppedAt??this.state.doc.length,this.tree=n,this.parse=null,this.treeLen<(t??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(C6.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=Y6;Y6=this;try{return e()}finally{Y6=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=X6(e,t.from,t.to);return e}changes(t,n){let{fragments:r,tree:i,treeLen:a,viewport:o,skipped:s}=this;if(this.takeTree(),!t.empty){let e=[];if(t.iterChangedRanges((t,n,r,i)=>e.push({fromA:t,toA:n,fromB:r,toB:i})),r=C6.applyChanges(r,e),i=c6.empty,a=0,o={from:t.mapPos(o.from,-1),to:t.mapPos(o.to,1)},this.skipped.length){s=[];for(let e of this.skipped){let n=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);n<r&&s.push({from:n,to:r})}}}return new e(this.parser,n,r,i,a,o,s,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let t=0;t<this.skipped.length;t++){let{from:n,to:r}=this.skipped[t];n<e.to&&r>e.from&&(this.fragments=X6(this.fragments,n,r),this.skipped.splice(t--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&=(this.takeTree(),null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends w6{createParse(t,n,r){let i=r[0].from,a=r[r.length-1].to;return{parsedPos:i,advance(){let t=Y6;if(t){for(let e of r)t.tempSkipped.push(e);e&&(t.scheduleOn=t.scheduleOn?Promise.all([t.scheduleOn,e]):e)}return this.parsedPos=a,new c6(i6.none,[],[],a-i)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return Y6}};function X6(e,t,n){return C6.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}var Z6=class e{constructor(e){this.context=e,this.tree=e.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(t.changes,t.state),r=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new e(n)}static init(t){let n=Math.min(3e3,t.doc.length),r=NSe.create(t.facet(e8).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new e(r)}};K6.state=t1.define({create:Z6.init,update(e,t){for(let e of t.effects)if(e.is(K6.setState))return e.value;return t.startState.facet(e8)==t.state.facet(e8)?e.apply(t):Z6.init(t.state)}});var Q6=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<`u`&&(Q6=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});var $6=typeof navigator<`u`&&navigator.scheduling?.isInputPending?()=>navigator.scheduling.isInputPending():null,PSe=T2.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(K6.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(K6.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=Q6(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:r}}=this.view,i=n.field(K6.state);if(i.tree==i.context.tree&&i.context.isDone(r+1e5))return;let a=Date.now()+Math.min(this.chunkBudget,100,e&&!$6?Math.max(25,e.timeRemaining()-5):1e9),o=i.context.treeLen<r&&n.doc.length>r+1e3,s=i.context.work(()=>$6&&$6()||Date.now()>a,r+(o?0:1e5));this.chunkBudget-=Date.now()-t,(s||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:K6.setState.of(new Z6(i.context))})),this.chunkBudget>0&&!(s&&!o)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(e){e.scheduleOn&&=(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(e=>S2(this.view.state,e)).then(()=>this.workScheduled--),null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),e8=Y.define({combine(e){return e.length?e[0]:null},enables:e=>[K6.state,PSe,Z.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]}),FSe=class{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}},ISe=Y.define(),t8=Y.define({combine:e=>{if(!e.length)return` `;let t=e[0];if(!t||/\S/.test(t)||Array.from(t).some(e=>e!=t[0]))throw Error(`Invalid indent unit: `+JSON.stringify(e[0]));return t}});function n8(e){let t=e.facet(t8);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function r8(e,t){let n=``,r=e.tabSize,i=e.facet(t8)[0];if(i==` `){for(;t>=r;)n+=` `,t-=r;i=` `}for(let e=0;e<t;e++)n+=i;return n}function i8(e,t){e instanceof D1&&(e=new a8(e));for(let n of e.state.facet(ISe)){let r=n(e,t);if(r!==void 0)return r}let n=J6(e.state);return n.length>=t?LSe(e,n,t):null}var a8=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=n8(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:i}=this.options;return r!=null&&r>=n.from&&r<=n.to?i&&r==e?{text:``,from:e}:(t<0?r<e:r<=e)?{text:n.text.slice(r-n.from),from:r}:{text:n.text.slice(0,r-n.from),from:n.from}:n}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return``;let{text:n,from:r}=this.lineAt(e,t);return n.slice(e-r,Math.min(n.length,e+100-r))}column(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.countColumn(n,e-r),a=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return a>-1&&(i+=a-this.countColumn(n,n.search(/\S|$/))),i}countColumn(e,t=e.length){return G1(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.options.overrideIndentation;if(i){let e=i(r);if(e>-1)return e}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},o8=new n6;function LSe(e,t,n){let r=t.resolveStack(n),i=t.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(i!=r.node){let e=[];for(let t=i;t&&!(t.from<r.node.from||t.to>r.node.to||t.from==r.node.from&&t.type==r.node.type);t=t.parent)e.push(t);for(let t=e.length-1;t>=0;t--)r={node:e[t],next:r}}return s8(r,e,n)}function s8(e,t,n){for(let r=e;r;r=r.next){let e=zSe(r.node);if(e)return e(VSe.create(t,n,r))}return 0}function RSe(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function zSe(e){let t=e.type.prop(o8);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(n6.closedBy))){let t=e.lastChild,n=t&&r.indexOf(t.name)>-1;return e=>WSe(e,!0,1,void 0,n&&!RSe(e)?t.from:void 0)}return e.parent==null?BSe:null}function BSe(){return 0}var VSe=class e extends a8{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.context=n}get node(){return this.context.node}static create(t,n,r){return new e(t,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let n=e.resolve(t.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(HSe(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return s8(this.context.next,this.base,this.pos)}};function HSe(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function USe(e){let t=e.node,n=t.childAfter(t.from),r=t.lastChild;if(!n)return null;let i=e.options.simulateBreak,a=e.state.doc.lineAt(n.from),o=i==null||i<=a.from?a.to:Math.min(a.to,i);for(let e=n.to;;){let i=t.childAfter(e);if(!i||i==r)return null;if(!i.type.isSkipped){if(i.from>=o)return null;let e=/^ */.exec(a.text.slice(n.to-a.from))[0].length;return{from:n.from,to:n.to+e}}e=i.to}}function WSe(e,t,n,r,i){let a=e.textAfter,o=a.match(/^\s*/)[0].length,s=r&&a.slice(o,o+r.length)==r||i==e.pos+o,c=t?USe(e):null;return c?s?e.column(c.from):e.column(c.to):e.baseIndent+(s?0:e.unit*n)}function GSe({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}var KSe=new n6,c8=class e{constructor(e,t){this.specs=e;let n;function r(e){let t=X1.newName();return(n||=Object.create(null))[`.`+t]=e,t}let i=typeof t.all==`string`?t.all:t.all?r(t.all):void 0,a=t.scope;this.scope=a instanceof K6?e=>e.prop(G6)==a.data:a?e=>e==a:void 0,this.style=A6(e.map(e=>({tag:e.tag,class:e.class||r(Object.assign({},e,{tag:null}))})),{all:i}).style,this.module=n?new X1(n):null,this.themeType=t.themeType}static define(t,n){return new e(t,n||{})}},l8=Y.define(),u8=Y.define({combine(e){return e.length?[e[0]]:null}});function d8(e){let t=e.facet(l8);return t.length?t:e.facet(u8)}function f8(e,t){let n=[JSe],r;return e instanceof c8&&(e.module&&n.push(Z.styleModule.of(e.module)),r=e.themeType),t?.fallback?n.push(u8.of(e)):r?n.push(l8.computeN([Z.darkTheme],t=>t.facet(Z.darkTheme)==(r==`dark`)?[e]:[])):n.push(l8.of(e)),n}var qSe=class{constructor(e){this.markCache=Object.create(null),this.tree=J6(e.state),this.decorations=this.buildDeco(e,d8(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=J6(e.state),n=d8(e.state),r=n!=d8(e.startState),{viewport:i}=e.view,a=e.changes.mapPos(this.decoratedTo,1);t.length<i.to&&!r&&t.type==this.tree.type&&a>=i.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=a):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=i.to)}buildDeco(e,t){if(!t||!this.tree.length)return x0.none;let n=new P1;for(let{from:r,to:i}of e.visibleRanges)ESe(this.tree,t,(e,t,r)=>{n.add(e,t,this.markCache[r]||(this.markCache[r]=x0.mark({class:r})))},r,i);return n.finish()}},JSe=i1.high(T2.fromClass(qSe,{decorations:e=>e.decorations}));$.meta,$.link,$.heading,$.emphasis,$.strong,$.strikethrough,$.keyword,$.atom,$.bool,$.url,$.contentSeparator,$.labelName,$.literal,$.inserted,$.string,$.deleted,$.regexp,$.escape,$.string,$.variableName,$.variableName,$.typeName,$.namespace,$.className,$.variableName,$.macroName,$.propertyName,$.comment,$.invalid;var YSe=Z.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:`#328c8252`},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:`#bb555544`}}),p8=1e4,m8=`()[]{}`,h8=Y.define({combine(e){return O1(e,{afterCursor:!0,brackets:m8,maxScanDistance:p8,renderMatch:QSe})}}),XSe=x0.mark({class:`cm-matchingBracket`}),ZSe=x0.mark({class:`cm-nonmatchingBracket`});function QSe(e){let t=[],n=e.matched?XSe:ZSe;return t.push(n.range(e.start.from,e.start.to)),e.end&&t.push(n.range(e.end.from,e.end.to)),t}function g8(e){let t=[],n=e.facet(h8);for(let r of e.selection.ranges){if(!r.empty)continue;let i=y8(e,r.head,-1,n)||r.head>0&&y8(e,r.head-1,1,n)||n.afterCursor&&(y8(e,r.head,1,n)||r.head<e.doc.length&&y8(e,r.head+1,-1,n));i&&(t=t.concat(n.renderMatch(i,e)))}return x0.set(t,!0)}var $Se=[T2.fromClass(class{constructor(e){this.paused=!1,this.decorations=g8(e.state)}update(e){(e.docChanged||e.selectionSet||this.paused)&&(e.view.composing?(this.decorations=this.decorations.map(e.changes),this.paused=!0):(this.decorations=g8(e.state),this.paused=!1))}},{decorations:e=>e.decorations}),YSe];function eCe(e={}){return[h8.of(e),$Se]}var tCe=new n6;function _8(e,t,n){let r=e.prop(t<0?n6.openedBy:n6.closedBy);if(r)return r;if(e.name.length==1){let r=n.indexOf(e.name);if(r>-1&&r%2==+(t<0))return[n[r+t]]}return null}function v8(e){let t=e.type.prop(tCe);return t?t(e.node):e}function y8(e,t,n,r={}){let i=r.maxScanDistance||p8,a=r.brackets||m8,o=J6(e),s=o.resolveInner(t,n);for(let r=s;r;r=r.parent){let i=_8(r.type,n,a);if(i&&r.from<r.to){let o=v8(r);if(o&&(n>0?t>=o.from&&t<o.to:t>o.from&&t<=o.to))return nCe(e,t,n,r,o,i,a)}}return rCe(e,t,n,o,s.type,i,a)}function nCe(e,t,n,r,i,a,o){let s=r.parent,c={from:i.from,to:i.to},l=0,u=s?.cursor();if(u&&(n<0?u.childBefore(r.from):u.childAfter(r.to)))do if(n<0?u.to<=r.from:u.from>=r.to){if(l==0&&a.indexOf(u.type.name)>-1&&u.from<u.to){let e=v8(u);return{start:c,end:e?{from:e.from,to:e.to}:void 0,matched:!0}}else if(_8(u.type,n,o))l++;else if(_8(u.type,-n,o)){if(l==0){let e=v8(u);return{start:c,end:e&&e.from<e.to?{from:e.from,to:e.to}:void 0,matched:!1}}l--}}while(n<0?u.prevSibling():u.nextSibling());return{start:c,matched:!1}}function rCe(e,t,n,r,i,a,o){if(n<0?!t:t==e.doc.length)return null;let s=n<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),c=o.indexOf(s);if(c<0||c%2==0!=n>0)return null;let l={from:n<0?t-1:t,to:n>0?t+1:t},u=e.doc.iterRange(t,n>0?e.doc.length:0),d=0;for(let e=0;!u.next().done&&e<=a;){let a=u.value;n<0&&(e+=a.length);let s=t+e*n;for(let e=n>0?0:a.length-1,t=n>0?a.length:-1;e!=t;e+=n){let t=o.indexOf(a[e]);if(!(t<0||r.resolveInner(s+e,1).type!=i))if(t%2==0==n>0)d++;else if(d==1)return{start:l,end:{from:s+e,to:s+e+1},matched:t>>1==c>>1};else d--}n>0&&(e+=a.length)}return u.done?{start:l,matched:!1}:null}var iCe=Object.create(null),b8=[i6.none],x8=[],S8=Object.create(null),aCe=Object.create(null);for(let[e,t]of[[`variable`,`variableName`],[`variable-2`,`variableName.special`],[`string-2`,`string.special`],[`def`,`variableName.definition`],[`tag`,`tagName`],[`attribute`,`attributeName`],[`type`,`typeName`],[`builtin`,`variableName.standard`],[`qualifier`,`modifier`],[`error`,`invalid`],[`header`,`heading`],[`property`,`propertyName`]])aCe[e]=oCe(iCe,t);function C8(e,t){x8.indexOf(e)>-1||(x8.push(e),console.warn(t))}function oCe(e,t){let n=[];for(let r of t.split(` `)){let t=[];for(let n of r.split(`.`)){let r=e[n]||$[n];r?typeof r==`function`?t.length?t=t.map(r):C8(n,`Modifier ${n} used at start of tag`):t.length?C8(n,`Tag ${n} used as modifier`):t=Array.isArray(r)?r:[r]:C8(n,`Unknown highlighting tag ${n}`)}for(let e of t)n.push(e)}if(!n.length)return 0;let r=t.replace(/ /g,`_`),i=r+` `+n.map(e=>e.id),a=S8[i];if(a)return a.id;let o=S8[i]=i6.define({id:b8.length,name:r,props:[D6({[r]:n})]});return b8.push(o),o.id}J0.RTL,J0.LTR;var sCe=class e{constructor(e,t,n,r,i,a,o,s,c,l=0,u){this.p=e,this.stack=t,this.state=n,this.reducePos=r,this.pos=i,this.score=a,this.buffer=o,this.bufferBase=s,this.curContext=c,this.lookAhead=l,this.parent=u}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?`!`+this.score:``}`}static start(t,n,r=0){let i=t.parser.context;return new e(t,[],n,r,r,0,[],0,i?new w8(i,i.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){let t=e>>19,n=e&65535,{parser:r}=this.p,i=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),a=r.dynamicPrecedence(n);if(a&&(this.score+=a),t==0){n<r.minRepeatTerm&&this.reducePos<this.pos&&(this.reducePos=this.pos),this.pushState(r.getGoto(this.state,n,!0),this.reducePos),n<r.minRepeatTerm&&this.storeNode(n,this.reducePos,this.reducePos,i?8:4,!0),this.reduceContext(n,this.reducePos);return}let o=this.stack.length-(t-1)*3-(e&262144?6:0),s=o?this.stack[o-2]:this.p.ranges[0].from;n<r.minRepeatTerm&&s==this.reducePos&&this.reducePos<this.pos&&(this.reducePos=this.pos);let c=this.reducePos-s;c>=2e3&&!this.p.parser.nodeSet.types[n]?.isAnonymous&&(s==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSize<c&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=s,this.p.lastBigReductionSize=c));let l=o?this.stack[o-1]:0,u=this.bufferBase+this.buffer.length-l;if(n<r.minRepeatTerm||e&131072){let e=r.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(n,s,e,u+4,!0)}if(e&262144)this.state=this.stack[o];else{let e=this.stack[o-3];this.state=r.getGoto(e,n,!0)}for(;this.stack.length>o;)this.stack.pop();this.reduceContext(n,s)}storeNode(e,t,n,r=4,i=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let e=this.buffer.length;if(e>0&&this.buffer[e-4]==0&&this.buffer[e-1]>-1){if(t==n)return;if(this.buffer[e-2]>=t){this.buffer[e-2]=n;return}}}if(!i||this.pos==n)this.buffer.push(e,t,n,r);else{let i=this.buffer.length;if(i>0&&(this.buffer[i-4]!=0||this.buffer[i-1]<0)){let e=!1;for(let t=i;t>0&&this.buffer[t-2]>n;t-=4)if(this.buffer[t-1]>=0){e=!0;break}if(e)for(;i>0&&this.buffer[i-2]>n;)this.buffer[i]=this.buffer[i-4],this.buffer[i+1]=this.buffer[i-3],this.buffer[i+2]=this.buffer[i-2],this.buffer[i+3]=this.buffer[i-1],i-=4,r>4&&(r-=4)}this.buffer[i]=e,this.buffer[i+1]=t,this.buffer[i+2]=n,this.buffer[i+3]=r}}shift(e,t,n,r){if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=r,this.shiftContext(t,n),t<=this.p.parser.maxNode&&this.buffer.push(t,n,r,4);else{let i=e,{parser:a}=this.p;this.pos=r;let o=a.stateFlag(i,1);!o&&(r>n||t<=a.maxNode)&&(this.reducePos=r),this.pushState(i,o?n:Math.min(n,this.reducePos)),this.shiftContext(t,n),t<=a.maxNode&&this.buffer.push(t,n,r,4)}}apply(e,t,n,r){e&65536?this.reduce(e):this.shift(e,t,n,r)}useNode(e,t){let n=this.p.reused.length-1;(n<0||this.p.reused[n]!=e)&&(this.p.reused.push(e),n++);let r=this.pos;this.reducePos=this.pos=r+e.length,this.pushState(t,r),this.buffer.push(n,r,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let t=this,n=t.buffer.length;for(n&&t.buffer[n-4]==0&&(n-=4);n>0&&t.buffer[n-2]>t.reducePos;)n-=4;let r=t.buffer.slice(n),i=t.bufferBase+n;for(;t&&i==t.bufferBase;)t=t.parent;return new e(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,r,i,this.curContext,this.lookAhead,t)}recoverByDelete(e,t){let n=e<=this.p.parser.maxNode;n&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,n?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new cCe(this);;){let n=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(n==0)return!1;if(!(n&65536))return!0;t.reduce(n)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let n=[];for(let r=0,i;r<t.length;r+=2)(i=t[r+1])!=this.state&&this.p.parser.hasAction(i,e)&&n.push(t[r],i);if(this.stack.length<120)for(let e=0;n.length<8&&e<t.length;e+=2){let r=t[e+1];n.some((e,t)=>t&1&&e==r)||n.push(t[e],r)}t=n}let n=[];for(let e=0;e<t.length&&n.length<4;e+=2){let r=t[e+1];if(r==this.state)continue;let i=this.split();i.pushState(r,this.pos),i.storeNode(0,i.pos,i.pos,4,!0),i.shiftContext(t[e],this.pos),i.reducePos=this.pos,i.score-=200,n.push(i)}return n}forceReduce(){let{parser:e}=this.p,t=e.stateSlot(this.state,5);if(!(t&65536))return!1;if(!e.validAction(this.state,t)){let n=t>>19,r=t&65535,i=this.stack.length-n*3;if(i<0||e.getGoto(this.stack[i],r,!1)<0){let e=this.findForcedReduction();if(e==null)return!1;t=e}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],n=(r,i)=>{if(!t.includes(r))return t.push(r),e.allActions(r,t=>{if(!(t&393216))if(t&65536){let n=(t>>19)-i;if(n>1){let r=t&65535,i=this.stack.length-n*3;if(i>=0&&e.getGoto(this.stack[i],r,!1)>=0)return n<<19|65536|r}}else{let e=n(t,i+1);if(e!=null)return e}})};return n(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t<this.stack.length;t+=3)if(this.stack[t]!=e.stack[t])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(t)))}reduceContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(t)))}emitContext(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let t=new w8(this.curContext.tracker,e);t.hash!=this.curContext.hash&&this.emitContext(),this.curContext=t}}setLookAhead(e){return e<=this.lookAhead?!1:(this.emitLookAhead(),this.lookAhead=e,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}},w8=class{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}},cCe=class{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,n=e>>19;n==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(n-1)*3;let r=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=r}},lCe=class e{constructor(e,t,n){this.stack=e,this.pos=t,this.index=n,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(t,n=t.bufferBase+t.buffer.length){return new e(t,n,n-t.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}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]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new e(this.stack,this.pos,this.index)}};function T8(e,t=Uint16Array){if(typeof e!=`string`)return e;let n=null;for(let r=0,i=0;r<e.length;){let a=0;for(;;){let t=e.charCodeAt(r++),n=!1;if(t==126){a=65535;break}t>=92&&t--,t>=34&&t--;let i=t-32;if(i>=46&&(i-=46,n=!0),a+=i,n)break;a*=46}n?n[i++]=a:n=new t(a)}return n}var E8=class{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}},D8=new E8,uCe=class{constructor(e,t){this.input=e,this.ranges=t,this.chunk=``,this.chunkOff=0,this.chunk2=``,this.chunk2Pos=0,this.next=-1,this.token=D8,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let n=this.range,r=this.rangeIndex,i=this.pos+e;for(;i<n.from;){if(!r)return null;let e=this.ranges[--r];i-=n.from-e.to,n=e}for(;t<0?i>n.to:i>=n.to;){if(r==this.ranges.length-1)return null;let e=this.ranges[++r];i+=e.from-n.to,n=e}return i}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let t of this.ranges)if(t.to>e)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,n,r;if(t>=0&&t<this.chunk.length)n=this.pos+e,r=this.chunk.charCodeAt(t);else{let t=this.resolveOffset(e,1);if(t==null)return-1;if(n=t,n>=this.chunk2Pos&&n<this.chunk2Pos+this.chunk2.length)r=this.chunk2.charCodeAt(n-this.chunk2Pos);else{let e=this.rangeIndex,t=this.range;for(;t.to<=n;)t=this.ranges[++e];this.chunk2=this.input.chunk(this.chunk2Pos=n),n+this.chunk2.length>t.to&&(this.chunk2=this.chunk2.slice(0,t.to-n)),r=this.chunk2.charCodeAt(0)}}return n>=this.token.lookAhead&&(this.token.lookAhead=n+1),r}acceptToken(e,t=0){let n=t?this.resolveOffset(t,-1):this.pos;if(n==null||n<this.token.start)throw RangeError(`Token end out of bounds`);this.token.value=e,this.token.end=n}acceptTokenTo(e,t){this.token.value=e,this.token.end=t}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:t}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=t,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),t=this.pos+e.length;this.chunk=t>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk=``,this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=D8,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk=``,this.chunkOff=0),this.readNext()}return this}read(e,t){if(e>=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let n=``;for(let r of this.ranges){if(r.from>=t)break;r.to>e&&(n+=this.input.read(Math.max(r.from,e),Math.min(r.to,t)))}return n}},O8=class{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:n}=t.p;k8(this.data,e,t,this.id,n.data,n.tokenPrecTable)}};O8.prototype.contextual=O8.prototype.fallback=O8.prototype.extend=!1;var dCe=class{constructor(e,t,n){this.precTable=t,this.elseToken=n,this.data=typeof e==`string`?T8(e):e}token(e,t){let n=e.pos,r=0;for(;;){let n=e.next<0,i=e.resolveOffset(1,1);if(k8(this.data,e,t,0,this.data,this.precTable),e.token.value>-1)break;if(this.elseToken==null)return;if(n||r++,i==null)break;e.reset(i,e.token)}r&&(e.reset(n,e.token),e.acceptToken(this.elseToken,r))}};dCe.prototype.contextual=O8.prototype.fallback=O8.prototype.extend=!1;var fCe=class{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}};function k8(e,t,n,r,i,a){let o=0,s=1<<r,{dialect:c}=n.p.parser;scan:for(;(s&e[o])!=0;){let n=e[o+1];for(let r=o+3;r<n;r+=2)if((e[r+1]&s)>0){let n=e[r];if(c.allows(n)&&(t.token.value==-1||t.token.value==n||pCe(n,t.token.value,i,a))){t.acceptToken(n);break}}let r=t.next,l=0,u=e[o+2];if(t.next<0&&u>l&&e[n+u*3-3]==65535){o=e[n+u*3-1];continue scan}for(;l<u;){let i=l+u>>1,a=n+i+(i<<1),s=e[a],c=e[a+1]||65536;if(r<s)u=i;else if(r>=c)l=i+1;else{o=e[a+2],t.advance();continue scan}}break}}function A8(e,t,n){for(let r=t,i;(i=e[r])!=65535;r++)if(i==n)return r-t;return-1}function pCe(e,t,n,r){let i=A8(n,r,t);return i<0||A8(n,r,e)<i}var j8=typeof process<`u`&&/\bparse\b/.test({}.LOG),M8=null;function N8(e,t,n){let r=e.cursor(s6.IncludeAnonymous);for(r.moveTo(t);;)if(!(n<0?r.childBefore(t):r.childAfter(t)))for(;;){if((n<0?r.to<t:r.from>t)&&!r.type.isError)return n<0?Math.max(0,Math.min(r.to-1,t-25)):Math.min(e.length,Math.max(r.from+1,t+25));if(n<0?r.prevSibling():r.nextSibling())break;if(!r.parent())return n<0?0:e.length}}var mCe=class{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?N8(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?N8(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let t=this.trees.length-1;if(t<0)return this.nextFragment(),null;let n=this.trees[t],r=this.index[t];if(r==n.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let i=n.children[r],a=this.start[t]+n.positions[r];if(a>e)return this.nextStart=a,null;if(i instanceof c6){if(a==e){if(a<this.safeFrom)return null;let e=a+i.length;if(e<=this.safeTo){let t=i.prop(n6.lookAhead);if(!t||e+t<this.fragment.to)return i}}this.index[t]++,a+i.length>=Math.max(this.safeFrom,e)&&(this.trees.push(i),this.start.push(a),this.index.push(0))}else this.index[t]++,this.nextStart=a+i.length}}},hCe=class{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(e=>new E8)}getActions(e){let t=0,n=null,{parser:r}=e.p,{tokenizers:i}=r,a=r.stateSlot(e.state,3),o=e.curContext?e.curContext.hash:0,s=0;for(let r=0;r<i.length;r++){if(!(1<<r&a))continue;let c=i[r],l=this.tokens[r];if(!(n&&!c.fallback)&&((c.contextual||l.start!=e.pos||l.mask!=a||l.context!=o)&&(this.updateCachedToken(l,c,e),l.mask=a,l.context=o),l.lookAhead>l.end+25&&(s=Math.max(l.lookAhead,s)),l.value!=0)){let r=t;if(l.extended>-1&&(t=this.addActions(e,l.extended,l.end,t)),t=this.addActions(e,l.value,l.end,t),!c.extend&&(n=l,t>r))break}}for(;this.actions.length>t;)this.actions.pop();return s&&e.setLookAhead(s),!n&&e.pos==this.stream.end&&(n=new E8,n.value=e.p.parser.eofTerm,n.start=n.end=e.pos,t=this.addActions(e,n.value,n.end,t)),this.mainToken=n,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new E8,{pos:n,p:r}=e;return t.start=n,t.end=Math.min(n+1,r.stream.end),t.value=n==r.stream.end?r.parser.eofTerm:0,t}updateCachedToken(e,t,n){let r=this.stream.clipPos(n.pos);if(t.token(this.stream.reset(r,e),n),e.value>-1){let{parser:t}=n.p;for(let r=0;r<t.specialized.length;r++)if(t.specialized[r]==e.value){let i=t.specializers[r](this.stream.read(e.start,e.end),n);if(i>=0&&n.p.parser.dialect.allows(i>>1)){i&1?e.extended=i>>1:e.value=i>>1;break}}}else e.value=0,e.end=this.stream.clipPos(r+1)}putAction(e,t,n,r){for(let t=0;t<r;t+=3)if(this.actions[t]==e)return r;return this.actions[r++]=e,this.actions[r++]=t,this.actions[r++]=n,r}addActions(e,t,n,r){let{state:i}=e,{parser:a}=e.p,{data:o}=a;for(let e=0;e<2;e++)for(let s=a.stateSlot(i,e?2:1);;s+=3){if(o[s]==65535)if(o[s+1]==1)s=F8(o,s+2);else{r==0&&o[s+1]==2&&(r=this.putAction(F8(o,s+2),t,n,r));break}o[s]==t&&(r=this.putAction(F8(o,s+1),t,n,r))}return r}},gCe=class{constructor(e,t,n,r){this.parser=e,this.input=t,this.ranges=r,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new uCe(t,r),this.tokens=new hCe(e,this.stream),this.topTerm=e.top[1];let{from:i}=r[0];this.stacks=[sCe.start(this,e.top[0],i)],this.fragments=n.length&&this.stream.end-i>e.bufferLength*4?new mCe(n,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,n=this.stacks=[],r,i;if(this.bigReductionCount>300&&e.length==1){let[t]=e;for(;t.forceReduce()&&t.stack.length&&t.stack[t.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let a=0;a<e.length;a++){let o=e[a];for(;;){if(this.tokens.mainToken=null,o.pos>t)n.push(o);else if(this.advanceStack(o,n,e))continue;else{r||(r=[],i=[]),r.push(o);let e=this.tokens.getMainToken(o);i.push(e.value,e.end)}break}}if(!n.length){let e=r&&yCe(r);if(e)return j8&&console.log(`Finish with `+this.stackID(e)),this.stackToTree(e);if(this.parser.strict)throw j8&&r&&console.log(`Stuck with token `+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):`none`)),SyntaxError(`No parse at `+t);this.recovering||=5}if(this.recovering&&r){let e=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,i,n);if(e)return j8&&console.log(`Force-finish `+this.stackID(e)),this.stackToTree(e.forceAll())}if(this.recovering){let e=this.recovering==1?1:this.recovering*3;if(n.length>e)for(n.sort((e,t)=>t.score-e.score);n.length>e;)n.pop();n.some(e=>e.reducePos>t)&&this.recovering--}else if(n.length>1){outer:for(let e=0;e<n.length-1;e++){let t=n[e];for(let r=e+1;r<n.length;r++){let i=n[r];if(t.sameState(i)||t.buffer.length>500&&i.buffer.length>500)if((t.score-i.score||t.buffer.length-i.buffer.length)>0)n.splice(r--,1);else{n.splice(e--,1);continue outer}}}n.length>12&&(n.sort((e,t)=>t.score-e.score),n.splice(12,n.length-12))}this.minStackPos=n[0].pos;for(let e=1;e<n.length;e++)n[e].pos<this.minStackPos&&(this.minStackPos=n[e].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw RangeError(`Can't move stoppedAt forward`);this.stoppedAt=e}advanceStack(e,t,n){let r=e.pos,{parser:i}=this,a=j8?this.stackID(e)+` -> `:``;if(this.stoppedAt!=null&&r>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let t=e.curContext&&e.curContext.tracker.strict,n=t?e.curContext.hash:0;for(let o=this.fragments.nodeAt(r);o;){let r=this.parser.nodeSet.types[o.type.id]==o.type?i.getGoto(e.state,o.type.id):-1;if(r>-1&&o.length&&(!t||(o.prop(n6.contextHash)||0)==n))return e.useNode(o,r),j8&&console.log(a+this.stackID(e)+` (via reuse of ${i.getName(o.type.id)})`),!0;if(!(o instanceof c6)||o.children.length==0||o.positions[0]>0)break;let s=o.children[0];if(s instanceof c6&&o.positions[0]==0)o=s;else break}}let o=i.stateSlot(e.state,4);if(o>0)return e.reduce(o),j8&&console.log(a+this.stackID(e)+` (via always-reduce ${i.getName(o&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let s=this.tokens.getActions(e);for(let o=0;o<s.length;){let c=s[o++],l=s[o++],u=s[o++],d=o==s.length||!n,f=d?e:e.split(),p=this.tokens.mainToken;if(f.apply(c,l,p?p.start:f.pos,u),j8&&console.log(a+this.stackID(f)+` (via ${c&65536?`reduce of ${i.getName(c&65535)}`:`shift`} for ${i.getName(l)} @ ${r}${f==e?``:`, split`})`),d)return!0;f.pos>r?t.push(f):n.push(f)}return!1}advanceFully(e,t){let n=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>n)return P8(e,t),!0}}runRecovery(e,t,n){let r=null,i=!1;for(let a=0;a<e.length;a++){let o=e[a],s=t[a<<1],c=t[(a<<1)+1],l=j8?this.stackID(o)+` -> `:``;if(o.deadEnd&&(i||(i=!0,o.restart(),j8&&console.log(l+this.stackID(o)+` (restarted)`),this.advanceFully(o,n))))continue;let u=o.split(),d=l;for(let e=0;e<10&&u.forceReduce()&&(j8&&console.log(d+this.stackID(u)+` (via force-reduce)`),!this.advanceFully(u,n));e++)j8&&(d=this.stackID(u)+` -> `);for(let e of o.recoverByInsert(s))j8&&console.log(l+this.stackID(e)+` (via recover-insert)`),this.advanceFully(e,n);this.stream.end>o.pos?(c==o.pos&&(c++,s=0),o.recoverByDelete(s,c),j8&&console.log(l+this.stackID(o)+` (via recover-delete ${this.parser.getName(s)})`),P8(o,n)):(!r||r.score<u.score)&&(r=u)}return r}stackToTree(e){return e.close(),c6.build({buffer:lCe.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let t=(M8||=new WeakMap).get(e);return t||M8.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}};function P8(e,t){for(let n=0;n<t.length;n++){let r=t[n];if(r.pos==e.pos&&r.sameState(e)){t[n].score<e.score&&(t[n]=e);return}}t.push(e)}var _Ce=class{constructor(e,t,n){this.source=e,this.flags=t,this.disabled=n}allows(e){return!this.disabled||this.disabled[e]==0}},vCe=class e extends w6{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(` `);this.minRepeatTerm=t.length;for(let n=0;n<e.repeatNodeCount;n++)t.push(``);let n=Object.keys(e.topRules).map(t=>e.topRules[t][1]),r=[];for(let e=0;e<t.length;e++)r.push([]);function i(e,t,n){r[e].push([t,t.deserialize(String(n))])}if(e.nodeProps)for(let t of e.nodeProps){let e=t[0];typeof e==`string`&&(e=n6[e]);for(let n=1;n<t.length;){let r=t[n++];if(r>=0)i(r,e,t[n++]);else{let a=t[n+-r];for(let o=-r;o>0;o--)i(t[n++],e,a);n++}}}this.nodeSet=new mSe(t.map((t,i)=>i6.define({name:i>=this.minRepeatTerm?void 0:t,id:i,props:r[i],top:n.indexOf(i)>-1,error:i==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(i)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=e6;let a=T8(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let e=0;e<this.specializerSpecs.length;e++)this.specialized[e]=this.specializerSpecs[e].term;this.specializers=this.specializerSpecs.map(I8),this.states=T8(e.states,Uint32Array),this.data=T8(e.stateData),this.goto=T8(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(e=>typeof e==`number`?new O8(a,e):e),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,n){let r=new gCe(this,e,t,n);for(let i of this.wrappers)r=i(r,e,t,n);return r}getGoto(e,t,n=!1){let r=this.goto;if(t>=r[0])return-1;for(let i=r[t+1];;){let t=r[i++],a=t&1,o=r[i++];if(a&&n)return o;for(let n=i+(t>>1);i<n;i++)if(r[i]==e)return o;if(a)return-1}}hasAction(e,t){let n=this.data;for(let r=0;r<2;r++)for(let i=this.stateSlot(e,r?2:1),a;;i+=3){if((a=n[i])==65535)if(n[i+1]==1)a=n[i=F8(n,i+2)];else if(n[i+1]==2)return F8(n,i+2);else break;if(a==t||a==0)return F8(n,i+1)}return 0}stateSlot(e,t){return this.states[e*6+t]}stateFlag(e,t){return(this.stateSlot(e,0)&t)>0}validAction(e,t){return!!this.allActions(e,e=>e==t?!0:null)}allActions(e,t){let n=this.stateSlot(e,4),r=n?t(n):void 0;for(let n=this.stateSlot(e,1);r==null;n+=3){if(this.data[n]==65535)if(this.data[n+1]==1)n=F8(this.data,n+2);else break;r=t(F8(this.data,n+1))}return r}nextStates(e){let t=[];for(let n=this.stateSlot(e,1);;n+=3){if(this.data[n]==65535)if(this.data[n+1]==1)n=F8(this.data,n+2);else break;if(!(this.data[n+2]&1)){let e=this.data[n+1];t.some((t,n)=>n&1&&t==e)||t.push(this.data[n],e)}}return t}configure(t){let n=Object.assign(Object.create(e.prototype),this);if(t.props&&(n.nodeSet=this.nodeSet.extend(...t.props)),t.top){let e=this.topRules[t.top];if(!e)throw RangeError(`Invalid top rule name ${t.top}`);n.top=e}return t.tokenizers&&(n.tokenizers=this.tokenizers.map(e=>{let n=t.tokenizers.find(t=>t.from==e);return n?n.to:e})),t.specializers&&(n.specializers=this.specializers.slice(),n.specializerSpecs=this.specializerSpecs.map((e,r)=>{let i=t.specializers.find(t=>t.from==e.external);if(!i)return e;let a=Object.assign(Object.assign({},e),{external:i.to});return n.specializers[r]=I8(a),a})),t.contextTracker&&(n.context=t.contextTracker),t.dialect&&(n.dialect=this.parseDialect(t.dialect)),t.strict!=null&&(n.strict=t.strict),t.wrap&&(n.wrappers=n.wrappers.concat(t.wrap)),t.bufferLength!=null&&(n.bufferLength=t.bufferLength),n}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),n=t.map(()=>!1);if(e)for(let r of e.split(` `)){let e=t.indexOf(r);e>=0&&(n[e]=!0)}let r=null;for(let e=0;e<t.length;e++)if(!n[e])for(let n=this.dialects[t[e]],i;(i=this.data[n++])!=65535;)(r||=new Uint8Array(this.maxTerm+1))[i]=1;return new _Ce(e,n,r)}static deserialize(t){return new e(t)}};function F8(e,t){return e[t]|e[t+1]<<16}function yCe(e){let t=null;for(let n of e){let e=n.p.stoppedAt;(n.pos==n.p.stream.end||e!=null&&n.pos>e)&&n.p.parser.stateFlag(n.state,2)&&(!t||t.score<n.score)&&(t=n)}return t}function I8(e){if(e.external){let t=+!!e.extend;return(n,r)=>e.external(n,r)<<1|t}return e.get}var L8=class{constructor(e,t,n,r){this.state=e,this.pos=t,this.explicit=n,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=J6(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),r=t.text.slice(n-t.from,this.pos-t.from),i=r.search(H8(e,!1));return i<0?null:{from:n+i,to:this.pos,text:r.slice(i)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,n){e==`abort`&&this.abortListeners&&(this.abortListeners.push(t),n&&n.onDocChange&&(this.abortOnDocChange=!0))}};function R8(e){let t=Object.keys(e).join(``),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,``)),`[${n?`\\w`:``}${t.replace(/[^\w\s]/g,`\\$&`)}]`}function bCe(e){let t=Object.create(null),n=Object.create(null);for(let{label:r}of e){t[r[0]]=!0;for(let e=1;e<r.length;e++)n[r[e]]=!0}let r=R8(t)+R8(n)+`*$`;return[RegExp(`^`+r),new RegExp(r)]}function z8(e){let t=e.map(e=>typeof e==`string`?{label:e}:e),[n,r]=t.every(e=>/^\w+$/.test(e.label))?[/\w*$/,/\w+$/]:bCe(t);return e=>{let i=e.matchBefore(r);return i||e.explicit?{from:i?i.from:e.pos,options:t,validFor:n}:null}}function xCe(e,t){return n=>{for(let t=J6(n.state).resolveInner(n.pos,-1);t;t=t.parent){if(e.indexOf(t.name)>-1)return null;if(t.type.isTop)break}return t(n)}}var B8=class{constructor(e,t,n,r){this.completion=e,this.source=t,this.match=n,this.score=r}};function V8(e){return e.selection.main.from}function H8(e,t){let{source:n}=e,r=t&&n[0]!=`^`,i=n[n.length-1]!=`$`;return!r&&!i?e:RegExp(`${r?`^`:``}(?:${n})${i?`$`:``}`,e.flags??(e.ignoreCase?`i`:``))}var U8=v1.define();function SCe(e,t,n,r){let{main:i}=e.selection,a=n-i.from,o=r-i.from;return{...e.changeByRange(s=>{if(s!=i&&n!=r&&e.sliceDoc(s.from+a,s.from+o)!=e.sliceDoc(n,r))return{range:s};let c=e.toText(t);return{changes:{from:s.from+a,to:r==i.from?s.to:s.from+o,insert:c},range:J.cursor(s.from+a+c.length)}}),scrollIntoView:!0,userEvent:`input.complete`}}var W8=new WeakMap;function CCe(e){if(!Array.isArray(e))return e;let t=W8.get(e);return t||W8.set(e,t=z8(e)),t}var G8=y1.define(),K8=y1.define(),wCe=class{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let n=P$(e,t),r=I$(n);this.chars.push(n);let i=e.slice(t,t+r),a=i.toUpperCase();this.folded.push(P$(a==i?i.toLowerCase():a,0)),t+=r}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:n,any:r,precise:i,byWord:a}=this;if(t.length==1){let r=P$(e,0),i=I$(r),a=i==e.length?0:-100;if(r!=t[0])if(r==n[0])a+=-200;else return null;return this.ret(a,[0,i])}let o=e.indexOf(this.pattern);if(o==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let s=t.length,c=0;if(o<0){for(let i=0,a=Math.min(e.length,200);i<a&&c<s;){let a=P$(e,i);(a==t[c]||a==n[c])&&(r[c++]=i),i+=I$(a)}if(c<s)return null}let l=0,u=0,d=!1,f=0,p=-1,m=-1,h=/[a-z]/.test(e),g=!0;for(let r=0,c=Math.min(e.length,200),_=0;r<c&&u<s;){let c=P$(e,r);o<0&&(l<s&&c==t[l]&&(i[l++]=r),f<s&&(c==t[f]||c==n[f]?(f==0&&(p=r),m=r+1,f++):f=0));let v,y=c<255?c>=48&&c<=57||c>=97&&c<=122?2:+(c>=65&&c<=90):(v=F$(c))==v.toLowerCase()?v==v.toUpperCase()?0:2:1;(!r||y==1&&h||_==0&&y!=0)&&(t[u]==c||n[u]==c&&(d=!0)?a[u++]=r:a.length&&(g=!1)),_=y,r+=I$(c)}return u==s&&a[0]==0&&g?this.result(-100+(d?-200:0),a,e):f==s&&p==0?this.ret(-200-e.length+(m==e.length?0:-100),[0,m]):o>-1?this.ret(-700-e.length,[o,o+this.pattern.length]):f==s?this.ret(-900-e.length,[p,m]):u==s?this.result(-100+(d?-200:0)+-700+(g?0:-1100),a,e):t.length==2?null:this.result((r[0]?-700:0)+-200+-1100,r,e)}result(e,t,n){let r=[],i=0;for(let e of t){let t=e+(this.astral?I$(P$(n,e)):1);i&&r[i-1]==e?r[i-1]=t:(r[i++]=e,r[i++]=t)}return this.ret(e-n.length,r)}},TCe=class{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let t=e.slice(0,this.pattern.length),n=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return n==null?null:(this.matched=[0,t.length],this.score=n+(e.length==this.pattern.length?0:-100),this)}},q8=Y.define({combine(e){return O1(e,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>``,optionClass:()=>``,aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:ECe,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>n=>J8(e(n),t(n)),optionClass:(e,t)=>n=>J8(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function J8(e,t){return e?t?e+` `+t:e:t}function ECe(e,t,n,r,i,a){let o=e.textDirection==J0.RTL,s=o,c=!1,l=`top`,u,d,f=t.left-i.left,p=i.right-t.right,m=r.right-r.left,h=r.bottom-r.top;if(s&&f<Math.min(m,p)?s=!1:!s&&p<Math.min(m,f)&&(s=!0),m<=(s?f:p))u=Math.max(i.top,Math.min(n.top,i.bottom-h))-t.top,d=Math.min(400,s?f:p);else{c=!0,d=Math.min(400,(o?t.right:i.right-t.left)-30);let e=i.bottom-t.bottom;e>=h||e>t.top?u=n.bottom-t.top:(l=`bottom`,u=t.bottom-n.top)}let g=(t.bottom-t.top)/a.offsetHeight,_=(t.right-t.left)/a.offsetWidth;return{style:`${l}: ${u/g}px; max-width: ${d/_}px`,class:`cm-completionInfo-`+(c?o?`left-narrow`:`right-narrow`:s?`left`:`right`)}}var Y8=y1.define();function DCe(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(e){let t=document.createElement(`div`);return t.classList.add(`cm-completionIcon`),e.type&&t.classList.add(...e.type.split(/\s+/g).map(e=>`cm-completionIcon-`+e)),t.setAttribute(`aria-hidden`,`true`),t},position:20}),t.push({render(e,t,n,r){let i=document.createElement(`span`);i.className=`cm-completionLabel`;let a=e.displayLabel||e.label,o=0;for(let e=0;e<r.length;){let t=r[e++],n=r[e++];t>o&&i.appendChild(document.createTextNode(a.slice(o,t)));let s=i.appendChild(document.createElement(`span`));s.appendChild(document.createTextNode(a.slice(t,n))),s.className=`cm-completionMatchedText`,o=n}return o<a.length&&i.appendChild(document.createTextNode(a.slice(o))),i},position:50},{render(e){if(!e.detail)return null;let t=document.createElement(`span`);return t.className=`cm-completionDetail`,t.textContent=e.detail,t},position:80}),t.sort((e,t)=>e.position-t.position).map(e=>e.render)}function X8(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let e=Math.floor(t/n);return{from:e*n,to:(e+1)*n}}let r=Math.ceil((e-t)/n);return{from:e-r*n,to:e-(r-1)*n}}var OCe=class{constructor(e,t,n){this.view=e,this.stateField=t,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:e=>this.placeInfo(e),key:this},this.space=null,this.currentClass=``;let r=e.state.field(t),{options:i,selected:a}=r.open,o=e.state.facet(q8);this.optionContent=DCe(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=X8(i.length,a,o.maxRenderedOptions),this.dom=document.createElement(`div`),this.dom.className=`cm-tooltip-autocomplete`,this.updateTooltipClass(e.state),this.dom.addEventListener(`mousedown`,n=>{let{options:r}=e.state.field(t).open;for(let t=n.target,i;t&&t!=this.dom;t=t.parentNode)if(t.nodeName==`LI`&&(i=/-(\d+)$/.exec(t.id))&&+i[1]<r.length){this.applyCompletion(e,r[+i[1]]),n.preventDefault();return}if(n.target==this.list){let t=this.list.classList.contains(`cm-completionListIncompleteTop`)&&n.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains(`cm-completionListIncompleteBottom`)&&n.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;t!=null&&(e.dispatch({effects:Y8.of(t)}),n.preventDefault())}}),this.dom.addEventListener(`focusout`,t=>{let n=e.state.field(this.stateField,!1);n&&n.tooltip&&e.state.facet(q8).closeOnBlur&&t.relatedTarget!=e.contentDOM&&e.dispatch({effects:K8.of(null)})}),this.showOptions(i,r.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener(`scroll`,()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){let t=e.state.field(this.stateField),n=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),t!=n){let{options:r,selected:i,disabled:a}=t.open;(!n.open||n.open.options!=r)&&(this.range=X8(r.length,i,e.state.facet(q8).maxRenderedOptions),this.showOptions(r,t.id)),this.updateSel(),a!=n.open?.disabled&&this.dom.classList.toggle(`cm-tooltip-autocomplete-disabled`,!!a)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let e of this.currentClass.split(` `))e&&this.dom.classList.remove(e);for(let e of t.split(` `))e&&this.dom.classList.add(e);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=X8(t.options.length,t.selected,this.view.state.facet(q8).maxRenderedOptions),this.showOptions(t.options,e.id));let n=this.updateSelectedOption(t.selected);if(n){this.destroyInfo();let{completion:r}=t.options[t.selected],{info:i}=r;if(!i)return;let a=typeof i==`string`?document.createTextNode(i):i(r);if(!a)return;`then`in a?a.then(t=>{t&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(t,r)}).catch(e=>S2(this.view.state,e,`completion info`)):(this.addInfoPane(a,r),n.setAttribute(`aria-describedby`,this.info.id))}}addInfoPane(e,t){this.destroyInfo();let n=this.info=document.createElement(`div`);if(n.className=`cm-tooltip cm-completionInfo`,n.id=`cm-completionInfo-`+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)n.appendChild(e),this.infoDestroy=null;else{let{dom:t,destroy:r}=e;n.appendChild(t),this.infoDestroy=r||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let n=this.list.firstChild,r=this.range.from;n;n=n.nextSibling,r++)n.nodeName!=`LI`||!n.id?r--:r==e?n.hasAttribute(`aria-selected`)||(n.setAttribute(`aria-selected`,`true`),t=n):n.hasAttribute(`aria-selected`)&&(n.removeAttribute(`aria-selected`),n.removeAttribute(`aria-describedby`));return t&&ACe(this.list,t),t}measureInfo(){let e=this.dom.querySelector(`[aria-selected]`);if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),r=e.getBoundingClientRect(),i=this.space;if(!i){let e=this.dom.ownerDocument.documentElement;i={left:0,top:0,right:e.clientWidth,bottom:e.clientHeight}}return r.top>Math.min(i.bottom,t.bottom)-10||r.bottom<Math.max(i.top,t.top)+10?null:this.view.state.facet(q8).positionInfo(this.view,t,r,n,i,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className=`cm-tooltip cm-completionInfo `+(e.class||``)):this.info.style.cssText=`top: -1e6px`)}createListBox(e,t,n){let r=document.createElement(`ul`);r.id=t,r.setAttribute(`role`,`listbox`),r.setAttribute(`aria-expanded`,`true`),r.setAttribute(`aria-label`,this.view.state.phrase(`Completions`)),r.addEventListener(`mousedown`,e=>{e.target==r&&e.preventDefault()});let i=null;for(let a=n.from;a<n.to;a++){let{completion:o,match:s}=e[a],{section:c}=o;if(c){let e=typeof c==`string`?c:c.name;if(e!=i&&(a>n.from||n.from==0))if(i=e,typeof c!=`string`&&c.header)r.appendChild(c.header(c));else{let t=r.appendChild(document.createElement(`completion-section`));t.textContent=e}}let l=r.appendChild(document.createElement(`li`));l.id=t+`-`+a,l.setAttribute(`role`,`option`);let u=this.optionClass(o);u&&(l.className=u);for(let e of this.optionContent){let t=e(o,this.view.state,this.view,s);t&&l.appendChild(t)}}return n.from&&r.classList.add(`cm-completionListIncompleteTop`),n.to<e.length&&r.classList.add(`cm-completionListIncompleteBottom`),r}destroyInfo(){this.info&&=(this.infoDestroy&&this.infoDestroy(),this.info.remove(),null)}destroy(){this.destroyInfo()}};function kCe(e,t){return n=>new OCe(n,e,t)}function ACe(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=n.height/e.offsetHeight;r.top<n.top?e.scrollTop-=(n.top-r.top)/i:r.bottom>n.bottom&&(e.scrollTop+=(r.bottom-n.bottom)/i)}function Z8(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+ +!!e.type}function jCe(e,t){let n=[],r=null,i=null,a=e=>{n.push(e);let{section:t}=e.completion;if(t){r||=[];let e=typeof t==`string`?t:t.name;r.some(t=>t.name==e)||r.push(typeof t==`string`?{name:e}:t)}},o=t.facet(q8);for(let r of e)if(r.hasResult()){let e=r.result.getMatch;if(r.result.filter===!1)for(let t of r.result.options)a(new B8(t,r.source,e?e(t):[],1e9-n.length));else{let n=t.sliceDoc(r.from,r.to),s,c=o.filterStrict?new TCe(n):new wCe(n);for(let t of r.result.options)if(s=c.match(t.label)){let n=t.displayLabel?e?e(t,s.matched):[]:s.matched,o=s.score+(t.boost||0);if(a(new B8(t,r.source,n,o)),typeof t.section==`object`&&t.section.rank===`dynamic`){let{name:e}=t.section;i||=Object.create(null),i[e]=Math.max(o,i[e]||-1e9)}}}}if(r){let e=Object.create(null),t=0,a=(e,t)=>(e.rank===`dynamic`&&t.rank===`dynamic`?i[t.name]-i[e.name]:0)||(typeof e.rank==`number`?e.rank:1e9)-(typeof t.rank==`number`?t.rank:1e9)||(e.name<t.name?-1:1);for(let n of r.sort(a))t-=1e5,e[n.name]=t;for(let t of n){let{section:n}=t.completion;n&&(t.score+=e[typeof n==`string`?n:n.name])}}let s=[],c=null,l=o.compareCompletions;for(let e of n.sort((e,t)=>t.score-e.score||l(e.completion,t.completion))){let t=e.completion;!c||c.label!=t.label||c.detail!=t.detail||c.type!=null&&t.type!=null&&c.type!=t.type||c.apply!=t.apply||c.boost!=t.boost?s.push(e):Z8(e.completion)>Z8(c)&&(s[s.length-1]=e),c=e.completion}return s}var MCe=class e{constructor(e,t,n,r,i,a){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=r,this.selected=i,this.disabled=a}setSelected(t,n){return t==this.selected||t>=this.options.length?this:new e(this.options,Q8(n,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,n,r,i,a,o){if(i&&!o&&t.some(e=>e.isPending))return i.setDisabled();let s=jCe(t,n);if(!s.length)return i&&t.some(e=>e.isPending)?i.setDisabled():null;let c=n.facet(q8).selectOnOpen?0:-1;if(i&&i.selected!=c&&i.selected!=-1){let e=i.options[i.selected].completion;for(let t=0;t<s.length;t++)if(s[t].completion==e){c=t;break}}return new e(s,Q8(r,c),{pos:t.reduce((e,t)=>t.hasResult()?Math.min(e,t.from):e,1e8),create:zCe,above:a.aboveCursor},i?i.timestamp:Date.now(),c,!1)}map(t){return new e(this.options,this.attrs,{...this.tooltip,pos:t.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new e(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}},NCe=class e{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new e(LCe,`cm-ac-`+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(q8),i=(r.override||n.languageDataAt(`autocomplete`,V8(n)).map(CCe)).map(e=>(this.active.find(t=>t.source==e)||new e5(e,+!!this.active.some(e=>e.state!=0))).update(t,r));i.length==this.active.length&&i.every((e,t)=>e==this.active[t])&&(i=this.active);let a=this.open,o=t.effects.some(e=>e.is(n5));a&&t.docChanged&&(a=a.map(t.changes)),t.selection||i.some(e=>e.hasResult()&&t.changes.touchesRange(e.from,e.to))||!PCe(i,this.active)||o?a=MCe.build(i,n,this.id,a,r,o):a&&a.disabled&&!i.some(e=>e.isPending)&&(a=null),!a&&i.every(e=>!e.isPending)&&i.some(e=>e.hasResult())&&(i=i.map(e=>e.hasResult()?new e5(e.source,0):e));for(let e of t.effects)e.is(Y8)&&(a&&=a.setSelected(e.value,this.id));return i==this.active&&a==this.open?this:new e(i,this.id,a)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?FCe:ICe}};function PCe(e,t){if(e==t)return!0;for(let n=0,r=0;;){for(;n<e.length&&!e[n].hasResult();)n++;for(;r<t.length&&!t[r].hasResult();)r++;let i=n==e.length,a=r==t.length;if(i||a)return i==a;if(e[n++].result!=t[r++].result)return!1}}var FCe={"aria-autocomplete":`list`},ICe={};function Q8(e,t){let n={"aria-autocomplete":`list`,"aria-haspopup":`listbox`,"aria-controls":e};return t>-1&&(n[`aria-activedescendant`]=e+`-`+t),n}var LCe=[];function $8(e,t){if(e.isUserEvent(`input.complete`)){let n=e.annotation(U8);if(n&&t.activateOnCompletion(n))return 12}let n=e.isUserEvent(`input.type`);return n&&t.activateOnTyping?5:n?1:e.isUserEvent(`delete.backward`)?2:e.selection?8:e.docChanged?16:0}var e5=class e{constructor(e,t,n=!1){this.source=e,this.state=t,this.explicit=n}hasResult(){return!1}get isPending(){return this.state==1}update(t,n){let r=$8(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new e(i.source,0)),r&4&&i.state==0&&(i=new e(this.source,1)),i=i.updateFor(t,r);for(let n of t.effects)if(n.is(G8))i=new e(i.source,1,n.value);else if(n.is(K8))i=new e(i.source,0);else if(n.is(n5))for(let e of n.value)e.source==i.source&&(i=e);return i}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(V8(e.state))}},t5=class e extends e5{constructor(e,t,n,r,i,a){super(e,3,t),this.limit=n,this.result=r,this.from=i,this.to=a}hasResult(){return!0}updateFor(t,n){if(!(n&3))return this.map(t.changes);let r=this.result;r.map&&!t.changes.empty&&(r=r.map(r,t.changes));let i=t.changes.mapPos(this.from),a=t.changes.mapPos(this.to,1),o=V8(t.state);if(o>a||!r||n&2&&(V8(t.startState)==this.from||o<this.limit))return new e5(this.source,n&4?1:0);let s=t.changes.mapPos(this.limit);return RCe(r.validFor,t.state,i,a)?new e(this.source,this.explicit,s,r,i,a):r.update&&(r=r.update(r,i,a,new L8(t.state,o,!1)))?new e(this.source,this.explicit,s,r,r.from,r.to??V8(t.state)):new e5(this.source,1,this.explicit)}map(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new e(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new e5(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}};function RCe(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e==`function`?e(i,n,r,t):H8(e,!0).test(i)}var n5=y1.define({map(e,t){return e.map(e=>e.map(t))}}),r5=t1.define({create(){return NCe.start()},update(e,t){return e.update(t)},provide:e=>[j3.from(e,e=>e.tooltip),Z.contentAttributes.from(e,e=>e.attrs)]});function i5(e,t){let n=t.completion.apply||t.completion.label,r=e.state.field(r5).active.find(e=>e.source==t.source);return r instanceof t5?(typeof n==`string`?e.dispatch({...SCe(e.state,n,r.from,r.to),annotations:U8.of(t.completion)}):n(e,t.completion,r.from,r.to),!0):!1}var zCe=kCe(r5,i5);function a5(e,t=`option`){return n=>{let r=n.state.field(r5,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(q8).interactionDelay)return!1;let i=1,a;t==`page`&&(a=M3(n,r.open.tooltip))&&(i=Math.max(2,Math.floor(a.dom.offsetHeight/a.dom.querySelector(`li`).offsetHeight)-1));let{length:o}=r.open.options,s=r.open.selected>-1?r.open.selected+i*(e?1:-1):e?0:o-1;return s<0?s=t==`page`?0:o-1:s>=o&&(s=t==`page`?o-1:0),n.dispatch({effects:Y8.of(s)}),!0}}var BCe=e=>{let t=e.state.field(r5,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(q8).interactionDelay?!1:i5(e,t.open.options[t.open.selected])},o5=e=>e.state.field(r5,!1)?(e.dispatch({effects:G8.of(!0)}),!0):!1,VCe=e=>{let t=e.state.field(r5,!1);return!t||!t.active.some(e=>e.state!=0)?!1:(e.dispatch({effects:K8.of(null)}),!0)},HCe=class{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}},UCe=50,WCe=1e3,GCe=T2.fromClass(class{constructor(e){this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let t of e.state.field(r5).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(r5),n=e.state.facet(q8);if(!e.selectionSet&&!e.docChanged&&e.startState.field(r5)==t)return;let r=e.transactions.some(e=>{let t=$8(e,n);return t&8||(e.selection||e.docChanged)&&!(t&3)});for(let t=0;t<this.running.length;t++){let n=this.running[t];if(r||n.context.abortOnDocChange&&e.docChanged||n.updates.length+e.transactions.length>UCe&&Date.now()-n.time>WCe){for(let e of n.context.abortListeners)try{e()}catch(e){S2(this.view.state,e)}n.context.abortListeners=null,this.running.splice(t--,1)}else n.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(e=>e.effects.some(e=>e.is(G8)))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(e=>e.isPending&&!this.running.some(t=>t.active.source==e.source))?setTimeout(()=>this.startUpdate(),i):-1,this.composing!=0)for(let t of e.transactions)t.isUserEvent(`input.type`)?this.composing=2:this.composing==2&&t.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(r5);for(let e of t.active)e.isPending&&!this.running.some(t=>t.active.source==e.source)&&this.startQuery(e);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(q8).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=new L8(t,V8(t),e.explicit,this.view),r=new HCe(e,n);this.running.push(r),Promise.resolve(e.source(n)).then(e=>{r.context.aborted||(r.done=e||null,this.scheduleAccept())},e=>{this.view.dispatch({effects:K8.of(null)}),S2(this.view.state,e)})}scheduleAccept(){this.running.every(e=>e.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(q8).updateSyncTime))}accept(){this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(q8),n=this.view.state.field(r5);for(let r=0;r<this.running.length;r++){let i=this.running[r];if(i.done===void 0)continue;if(this.running.splice(r--,1),i.done){let n=V8(i.updates.length?i.updates[0].startState:this.view.state),r=Math.min(n,i.done.from+ +!i.active.explicit),a=new t5(i.active.source,i.active.explicit,r,i.done,i.done.from,i.done.to??n);for(let e of i.updates)a=a.update(e,t);if(a.hasResult()){e.push(a);continue}}let a=n.active.find(e=>e.source==i.active.source);if(a&&a.isPending)if(i.done==null){let n=new e5(i.active.source,0);for(let e of i.updates)n=n.update(e,t);n.isPending||e.push(n)}else this.startQuery(a)}(e.length||n.open&&n.open.disabled)&&this.view.dispatch({effects:n5.of(e)})}},{eventHandlers:{blur(e){let t=this.view.state.field(r5,!1);if(t&&t.tooltip&&this.view.state.facet(q8).closeOnBlur){let n=t.open&&M3(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:K8.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:G8.of(!1)}),20),this.composing=0}}}),KCe=typeof navigator==`object`&&/Win/.test(navigator.platform),qCe=i1.highest(Z.domEventHandlers({keydown(e,t){let n=t.state.field(r5,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(KCe&&e.altKey)||e.metaKey)return!1;let r=n.open.options[n.open.selected],i=n.active.find(e=>e.source==r.source),a=r.completion.commitCharacters||i.result.commitCharacters;return a&&a.indexOf(e.key)>-1&&i5(t,r),!1}})),JCe=Z.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:`monospace`,whiteSpace:`nowrap`,overflow:`hidden auto`,maxWidth_fallback:`700px`,maxWidth:`min(700px, 95vw)`,minWidth:`250px`,maxHeight:`10em`,height:`100%`,listStyle:`none`,margin:0,padding:0,"& > li, & > completion-section":{padding:`1px 3px`,lineHeight:1.2},"& > li":{overflowX:`hidden`,textOverflow:`ellipsis`,cursor:`pointer`},"& > completion-section":{display:`list-item`,borderBottom:`1px solid silver`,paddingLeft:`0.5em`,opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:`#17c`,color:`white`},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:`#777`},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:`#347`,color:`white`},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:`#444`},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:`"···"`,opacity:.5,display:`block`,textAlign:`center`,cursor:`pointer`},".cm-tooltip.cm-completionInfo":{position:`absolute`,padding:`3px 9px`,width:`max-content`,maxWidth:`400px`,boxSizing:`border-box`,whiteSpace:`pre-line`},".cm-completionInfo.cm-completionInfo-left":{right:`100%`},".cm-completionInfo.cm-completionInfo-right":{left:`100%`},".cm-completionInfo.cm-completionInfo-left-narrow":{right:`30px`},".cm-completionInfo.cm-completionInfo-right-narrow":{left:`30px`},"&light .cm-snippetField":{backgroundColor:`#00000022`},"&dark .cm-snippetField":{backgroundColor:`#ffffff22`},".cm-snippetFieldPosition":{verticalAlign:`text-top`,width:0,height:`1.15em`,display:`inline-block`,margin:`0 -0.7px -.7em`,borderLeft:`1.4px dotted #888`},".cm-completionMatchedText":{textDecoration:`underline`},".cm-completionDetail":{marginLeft:`0.5em`,fontStyle:`italic`},".cm-completionIcon":{fontSize:`90%`,width:`.8em`,display:`inline-block`,textAlign:`center`,paddingRight:`.6em`,opacity:`0.6`,boxSizing:`content-box`},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:`'ƒ'`}},".cm-completionIcon-class":{"&:after":{content:`'○'`}},".cm-completionIcon-interface":{"&:after":{content:`'◌'`}},".cm-completionIcon-variable":{"&:after":{content:`'𝑥'`}},".cm-completionIcon-constant":{"&:after":{content:`'𝐶'`}},".cm-completionIcon-type":{"&:after":{content:`'𝑡'`}},".cm-completionIcon-enum":{"&:after":{content:`'∪'`}},".cm-completionIcon-property":{"&:after":{content:`'□'`}},".cm-completionIcon-keyword":{"&:after":{content:`'🔑︎'`}},".cm-completionIcon-namespace":{"&:after":{content:`'▢'`}},".cm-completionIcon-text":{"&:after":{content:`'abc'`,fontSize:`50%`,verticalAlign:`middle`}}}),s5={brackets:[`(`,`[`,`{`,`'`,`"`],before:`)]}:;>`,stringPrefixes:[]},c5=y1.define({map(e,t){return t.mapPos(e,-1,R$.TrackAfter)??void 0}}),l5=new class extends k1{};l5.startSide=1,l5.endSide=-1;var u5=t1.define({create(){return N1.empty},update(e,t){if(e=e.map(t.changes),t.selection){let n=t.state.doc.lineAt(t.selection.main.head);e=e.update({filter:e=>e>=n.from&&e<=n.to})}for(let n of t.effects)n.is(c5)&&(e=e.update({add:[l5.range(n.value,n.value+1)]}));return e}});function YCe(){return[ZCe,u5]}var d5=`()[]{}<>«»»«[]{}`;function f5(e){for(let t=0;t<16;t+=2)if(d5.charCodeAt(t)==e)return d5.charAt(t+1);return F$(e<128?e:e+1)}function p5(e,t){return e.languageDataAt(`closeBrackets`,t)[0]||s5}var XCe=typeof navigator==`object`&&/Android\b/.test(navigator.userAgent),ZCe=Z.inputHandler.of((e,t,n,r)=>{if((XCe?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&I$(P$(r,0))==1||t!=i.from||n!=i.to)return!1;let a=$Ce(e.state,r);return a?(e.dispatch(a),!0):!1}),QCe=[{key:`Backspace`,run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=p5(e,e.selection.main.head).brackets||s5.brackets,r=null,i=e.changeByRange(t=>{if(t.empty){let r=ewe(e.doc,t.head);for(let i of n)if(i==r&&h5(e.doc,t.head)==f5(P$(i,0)))return{changes:{from:t.head-i.length,to:t.head+i.length},range:J.cursor(t.head-i.length)}}return{range:r=t}});return r||t(e.update(i,{scrollIntoView:!0,userEvent:`delete.backward`})),!r}}];function $Ce(e,t){let n=p5(e,e.selection.main.head),r=n.brackets||s5.brackets;for(let i of r){let a=f5(P$(i,0));if(t==i)return a==i?rwe(e,i,r.indexOf(i+i+i)>-1,n):twe(e,i,a,n.before||s5.before);if(t==a&&m5(e,e.selection.main.from))return nwe(e,i,a)}return null}function m5(e,t){let n=!1;return e.field(u5).between(0,e.doc.length,e=>{e==t&&(n=!0)}),n}function h5(e,t){let n=e.sliceString(t,t+2);return n.slice(0,I$(P$(n,0)))}function ewe(e,t){let n=e.sliceString(t-2,t);return I$(P$(n,0))==n.length?n:n.slice(1)}function twe(e,t,n,r){let i=null,a=e.changeByRange(a=>{if(!a.empty)return{changes:[{insert:t,from:a.from},{insert:n,from:a.to}],effects:c5.of(a.to+t.length),range:J.range(a.anchor+t.length,a.head+t.length)};let o=h5(e.doc,a.head);return!o||/\s/.test(o)||r.indexOf(o)>-1?{changes:{insert:t+n,from:a.head},effects:c5.of(a.head+t.length),range:J.cursor(a.head+t.length)}:{range:i=a}});return i?null:e.update(a,{scrollIntoView:!0,userEvent:`input.type`})}function nwe(e,t,n){let r=null,i=e.changeByRange(t=>t.empty&&h5(e.doc,t.head)==n?{changes:{from:t.head,to:t.head+n.length,insert:n},range:J.cursor(t.head+n.length)}:r={range:t});return r?null:e.update(i,{scrollIntoView:!0,userEvent:`input.type`})}function rwe(e,t,n,r){let i=r.stringPrefixes||s5.stringPrefixes,a=null,o=e.changeByRange(r=>{if(!r.empty)return{changes:[{insert:t,from:r.from},{insert:t,from:r.to}],effects:c5.of(r.to+t.length),range:J.range(r.anchor+t.length,r.head+t.length)};let o=r.head,s=h5(e.doc,o),c;if(s==t){if(g5(e,o))return{changes:{insert:t+t,from:o},effects:c5.of(o+t.length),range:J.cursor(o+t.length)};if(m5(e,o)){let r=n&&e.sliceDoc(o,o+t.length*3)==t+t+t?t+t+t:t;return{changes:{from:o,to:o+r.length,insert:r},range:J.cursor(o+r.length)}}}else if(n&&e.sliceDoc(o-2*t.length,o)==t+t&&(c=_5(e,o-2*t.length,i))>-1&&g5(e,c))return{changes:{insert:t+t+t+t,from:o},effects:c5.of(o+t.length),range:J.cursor(o+t.length)};else if(e.charCategorizer(o)(s)!=T1.Word&&_5(e,o,i)>-1&&!iwe(e,o,t,i))return{changes:{insert:t+t,from:o},effects:c5.of(o+t.length),range:J.cursor(o+t.length)};return{range:a=r}});return a?null:e.update(o,{scrollIntoView:!0,userEvent:`input.type`})}function g5(e,t){let n=J6(e).resolveInner(t+1);return n.parent&&n.from==t}function iwe(e,t,n,r){let i=J6(e).resolveInner(t,-1),a=r.reduce((e,t)=>Math.max(e,t.length),0);for(let o=0;o<5;o++){let o=e.sliceDoc(i.from,Math.min(i.to,i.from+n.length+a)),s=o.indexOf(n);if(!s||s>-1&&r.indexOf(o.slice(0,s))>-1){let t=i.firstChild;for(;t&&t.from==i.from&&t.to-t.from>n.length+s;){if(e.sliceDoc(t.to-n.length,t.to)==n)return!1;t=t.firstChild}return!0}let c=i.to==t&&i.parent;if(!c)break;i=c}return!1}function _5(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=T1.Word)return t;for(let i of n){let n=t-i.length;if(e.sliceDoc(n,t)==i&&r(e.sliceDoc(n-1,n))!=T1.Word)return n}return-1}function v5(e={}){return[qCe,r5,q8.of(e),GCe,owe,JCe]}var awe=[{key:`Ctrl-Space`,run:o5},{mac:"Alt-`",run:o5},{mac:`Alt-i`,run:o5},{key:`Escape`,run:VCe},{key:`ArrowDown`,run:a5(!0)},{key:`ArrowUp`,run:a5(!1)},{key:`PageDown`,run:a5(!0,`page`)},{key:`PageUp`,run:a5(!1,`page`)},{key:`Enter`,run:BCe}],owe=i1.highest(b3.computeN([q8],e=>e.facet(q8).defaultKeymap?[awe]:[])),swe=36,y5=1,cwe=2,b5=3,x5=4,lwe=5,uwe=6,dwe=7,fwe=8,pwe=9,mwe=10,hwe=11,gwe=12,_we=13,vwe=14,ywe=15,bwe=16,xwe=17,S5=18,Swe=19,C5=20,w5=21,T5=22,Cwe=23,wwe=24;function E5(e){return e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57}function Twe(e){return e>=48&&e<=57||e>=97&&e<=102||e>=65&&e<=70}function D5(e,t,n){for(let r=!1;;){if(e.next<0)return;if(e.next==t&&!r){e.advance();return}r=n&&!r&&e.next==92,e.advance()}}function O5(e,t){scan:for(;;){if(e.next<0)return;if(e.next==36){e.advance();for(let n=0;n<t.length;n++){if(e.next!=t.charCodeAt(n))continue scan;e.advance()}if(e.next==36){e.advance();return}}else e.advance()}}function Ewe(e,t){let n=`[{<(`.indexOf(String.fromCharCode(t)),r=n<0?t:`]}>)`.charCodeAt(n);for(;;){if(e.next<0)return;if(e.next==r&&e.peek(1)==39){e.advance(2);return}e.advance()}}function k5(e,t){for(;!(e.next!=95&&!E5(e.next));)t!=null&&(t+=String.fromCharCode(e.next)),e.advance();return t}function Dwe(e){if(e.next==39||e.next==34||e.next==96){let t=e.next;e.advance(),D5(e,t,!1)}else k5(e)}function A5(e,t){for(;e.next==48||e.next==49;)e.advance();t&&e.next==t&&e.advance()}function j5(e,t){for(;;){if(e.next==46){if(t)break;t=!0}else if(e.next<48||e.next>57)break;e.advance()}if(e.next==69||e.next==101)for(e.advance(),(e.next==43||e.next==45)&&e.advance();e.next>=48&&e.next<=57;)e.advance()}function M5(e){for(;!(e.next<0||e.next==10);)e.advance()}function N5(e,t){for(let n=0;n<t.length;n++)if(t.charCodeAt(n)==e)return!0;return!1}var P5=` \r
750
- `;function F5(e,t,n){let r=Object.create(null);r.true=r.false=lwe,r.null=r.unknown=uwe;for(let t of e.split(` `))t&&(r[t]=C5);for(let e of t.split(` `))e&&(r[e]=w5);for(let e of(n||``).split(` `))e&&(r[e]=wwe);return r}var I5={backslashEscapes:!1,hashComments:!1,spaceAfterDashes:!1,slashComments:!1,doubleQuotedStrings:!1,doubleDollarQuotedStrings:!1,unquotedBitLiterals:!1,treatBitsAsBytes:!1,charSetCasts:!1,plsqlQuotingMechanism:!1,operatorChars:`*+-%<>!=&|~^/`,specialVar:`?`,identifierQuotes:`"`,caseInsensitiveIdentifiers:!1,words:F5(`absolute action add after all allocate alter and any are as asc assertion at authorization before begin between both breadth by call cascade cascaded case cast catalog check close collate collation column commit condition connect connection constraint constraints constructor continue corresponding count create cross cube current current_date current_default_transform_group current_transform_group_for_type current_path current_role current_time current_timestamp current_user cursor cycle data day deallocate declare default deferrable deferred delete depth deref desc describe descriptor deterministic diagnostics disconnect distinct do domain drop dynamic each else elseif end end-exec equals escape except exception exec execute exists exit external fetch first for foreign found from free full function general get global go goto grant group grouping handle having hold hour identity if immediate in indicator initially inner inout input insert intersect into is isolation join key language last lateral leading leave left level like limit local localtime localtimestamp locator loop map match method minute modifies module month names natural nesting new next no none not of old on only open option or order ordinality out outer output overlaps pad parameter partial path prepare preserve primary prior privileges procedure public read reads recursive redo ref references referencing relative release repeat resignal restrict result return returns revoke right role rollback rollup routine row rows savepoint schema scroll search second section select session session_user set sets signal similar size some space specific specifictype sql sqlexception sqlstate sqlwarning start state static system_user table temporary then timezone_hour timezone_minute to trailing transaction translation treat trigger under undo union unique unnest until update usage user using value values view when whenever where while with without work write year zone `,`array binary bit boolean char character clob date decimal double float int integer interval large national nchar nclob numeric object precision real smallint time timestamp varchar varying `)};function Owe(e,t,n,r){let i={};for(let t in I5)i[t]=(e.hasOwnProperty(t)?e:I5)[t];return t&&(i.words=F5(t,n||``,r)),i}function L5(e){return new fCe(t=>{let{next:n}=t;if(t.advance(),N5(n,P5)){for(;N5(t.next,P5);)t.advance();t.acceptToken(swe)}else if(n==36&&e.doubleDollarQuotedStrings){let e=k5(t,``);t.next==36&&(t.advance(),O5(t,e),t.acceptToken(b5))}else if(n==39||n==34&&e.doubleQuotedStrings)D5(t,n,e.backslashEscapes),t.acceptToken(b5);else if(n==35&&e.hashComments||n==47&&t.next==47&&e.slashComments)M5(t),t.acceptToken(y5);else if(n==45&&t.next==45&&(!e.spaceAfterDashes||t.peek(1)==32))M5(t),t.acceptToken(y5);else if(n==47&&t.next==42){t.advance();for(let e=1;;){let n=t.next;if(t.next<0)break;if(t.advance(),n==42&&t.next==47){if(e--,t.advance(),!e)break}else n==47&&t.next==42&&(e++,t.advance())}t.acceptToken(cwe)}else if((n==101||n==69)&&t.next==39)t.advance(),D5(t,39,!0),t.acceptToken(b5);else if((n==110||n==78)&&t.next==39&&e.charSetCasts)t.advance(),D5(t,39,e.backslashEscapes),t.acceptToken(b5);else if(n==95&&e.charSetCasts)for(let n=0;;n++){if(t.next==39&&n>1){t.advance(),D5(t,39,e.backslashEscapes),t.acceptToken(b5);break}if(!E5(t.next))break;t.advance()}else if(e.plsqlQuotingMechanism&&(n==113||n==81)&&t.next==39&&t.peek(1)>0&&!N5(t.peek(1),P5)){let e=t.peek(1);t.advance(2),Ewe(t,e),t.acceptToken(b5)}else if(N5(n,e.identifierQuotes))D5(t,n==91?93:n,!1),t.acceptToken(Swe);else if(n==40)t.acceptToken(dwe);else if(n==41)t.acceptToken(fwe);else if(n==123)t.acceptToken(pwe);else if(n==125)t.acceptToken(mwe);else if(n==91)t.acceptToken(hwe);else if(n==93)t.acceptToken(gwe);else if(n==59)t.acceptToken(_we);else if(e.unquotedBitLiterals&&n==48&&t.next==98)t.advance(),A5(t),t.acceptToken(T5);else if((n==98||n==66)&&(t.next==39||t.next==34)){let n=t.next;t.advance(),e.treatBitsAsBytes?(D5(t,n,e.backslashEscapes),t.acceptToken(Cwe)):(A5(t,n),t.acceptToken(T5))}else if(n==48&&(t.next==120||t.next==88)||(n==120||n==88)&&t.next==39){let e=t.next==39;for(t.advance();Twe(t.next);)t.advance();e&&t.next==39&&t.advance(),t.acceptToken(x5)}else if(n==46&&t.next>=48&&t.next<=57)j5(t,!0),t.acceptToken(x5);else if(n==46)t.acceptToken(vwe);else if(n>=48&&n<=57)j5(t,!1),t.acceptToken(x5);else if(N5(n,e.operatorChars)){for(;N5(t.next,e.operatorChars);)t.advance();t.acceptToken(ywe)}else if(N5(n,e.specialVar))t.next==n&&t.advance(),Dwe(t),t.acceptToken(xwe);else if(n==58||n==44)t.acceptToken(bwe);else if(E5(n)){let r=k5(t,String.fromCharCode(n));t.acceptToken(t.next==46||t.peek(-r.length-1)==46?S5:e.words[r.toLowerCase()]??S5)}})}var R5=L5(I5),kwe=vCe.deserialize({version:14,states:"%vQ]QQOOO#wQRO'#DSO$OQQO'#CwO%eQQO'#CxO%lQQO'#CyO%sQQO'#CzOOQQ'#DS'#DSOOQQ'#C}'#C}O'UQRO'#C{OOQQ'#Cv'#CvOOQQ'#C|'#C|Q]QQOOQOQQOOO'`QQO'#DOO(xQRO,59cO)PQQO,59cO)UQQO'#DSOOQQ,59d,59dO)cQQO,59dOOQQ,59e,59eO)jQQO,59eOOQQ,59f,59fO)qQQO,59fOOQQ-E6{-E6{OOQQ,59b,59bOOQQ-E6z-E6zOOQQ,59j,59jOOQQ-E6|-E6|O+VQRO1G.}O+^QQO,59cOOQQ1G/O1G/OOOQQ1G/P1G/POOQQ1G/Q1G/QP+kQQO'#C}O+rQQO1G.}O)PQQO,59cO,PQQO'#Cw",stateData:",[~OtOSPOSQOS~ORUOSUOTUOUUOVROXSOZTO]XO^QO_UO`UOaPObPOcPOdUOeUOfUOgUOhUO~O^]ORvXSvXTvXUvXVvXXvXZvX]vX_vX`vXavXbvXcvXdvXevXfvXgvXhvX~OsvX~P!jOa_Ob_Oc_O~ORUOSUOTUOUUOVROXSOZTO^tO_UO`UOa`Ob`Oc`OdUOeUOfUOgUOhUO~OWaO~P$ZOYcO~P$ZO[eO~P$ZORUOSUOTUOUUOVROXSOZTO^QO_UO`UOaPObPOcPOdUOeUOfUOgUOhUO~O]hOsoX~P%zOajObjOcjO~O^]ORkaSkaTkaUkaVkaXkaZka]ka_ka`kaakabkackadkaekafkagkahka~Oska~P'kO^]O~OWvXYvX[vX~P!jOWnO~P$ZOYoO~P$ZO[pO~P$ZO^]ORkiSkiTkiUkiVkiXkiZki]ki_ki`kiakibkickidkiekifkigkihki~Oski~P)xOWkaYka[ka~P'kO]hO~P$ZOWkiYki[ki~P)xOasObsOcsO~O",goto:"#hwPPPPPPPPPPPPPPPPPPPPPPPPPPx||||!Y!^!d!xPPP#[TYOZeUORSTWZbdfqT[OZQZORiZSWOZQbRQdSQfTZgWbdfqQ^PWk^lmrQl_Qm`RrseVORSTWZbdfq",nodeNames:`⚠ LineComment BlockComment String Number Bool Null ( ) { } [ ] ; . Operator Punctuation SpecialVar Identifier QuotedIdentifier Keyword Type Bits Bytes Builtin Script Statement CompositeIdentifier Parens Braces Brackets Statement`,maxTerm:38,nodeProps:[[`isolate`,-4,1,2,3,19,``]],skippedNodes:[0,1,2],repeatNodeCount:3,tokenData:`RORO`,tokenizers:[0,R5],topRules:{Script:[0,25]},tokenPrec:0});function z5(e){let t=e.cursor().moveTo(e.from,-1);for(;/Comment/.test(t.name);)t.moveTo(t.from,-1);return t.node}function B5(e,t){let n=e.sliceString(t.from,t.to),r=/^([`'"\[])(.*)([`'"\]])$/.exec(n);return r?r[2]:n}function V5(e){return e&&(e.name==`Identifier`||e.name==`QuotedIdentifier`)}function Awe(e,t){if(t.name==`CompositeIdentifier`){let n=[];for(let r=t.firstChild;r;r=r.nextSibling)V5(r)&&n.push(B5(e,r));return n}return[B5(e,t)]}function H5(e,t){for(let n=[];;){if(!t||t.name!=`.`)return n;let r=z5(t);if(!V5(r))return n;n.unshift(B5(e,r)),t=z5(r)}}function jwe(e,t){let n=J6(e).resolveInner(t,-1),r=Nwe(e.doc,n);return n.name==`Identifier`||n.name==`QuotedIdentifier`||n.name==`Keyword`?{from:n.from,quoted:n.name==`QuotedIdentifier`?e.doc.sliceString(n.from,n.from+1):null,parents:H5(e.doc,z5(n)),aliases:r}:n.name==`.`?{from:t,quoted:null,parents:H5(e.doc,n),aliases:r}:{from:t,quoted:null,parents:[],empty:!0,aliases:r}}var Mwe=new Set(`where group having order union intersect except all distinct limit offset fetch for`.split(` `));function Nwe(e,t){let n;for(let e=t;!n;e=e.parent){if(!e)return null;e.name==`Statement`&&(n=e)}let r=null;for(let t=n.firstChild,i=!1,a=null;t;t=t.nextSibling){let n=t.name==`Keyword`?e.sliceString(t.from,t.to).toLowerCase():null,o=null;if(!i)i=n==`from`;else if(n==`as`&&a&&V5(t.nextSibling))o=B5(e,t.nextSibling);else if(n&&Mwe.has(n))break;else a&&V5(t)&&(o=B5(e,t));o&&(r||=Object.create(null),r[o]=Awe(e,a)),a=/Identifier$/.test(t.name)?t:null}return r}function Pwe(e,t,n){return n.map(n=>({...n,label:n.label[0]==e?n.label:e+n.label+t,apply:void 0}))}var Fwe=/^\w*$/,Iwe=/^[`'"\[]?\w*[`'"\]]?$/;function U5(e){return e.self&&typeof e.self.label==`string`}var Lwe=class e{constructor(e,t){this.idQuote=e,this.idCaseInsensitive=t,this.list=[],this.children=void 0}child(t){let n=this.children||=Object.create(null);return n[t]||(t&&!this.list.some(e=>e.label==t)&&this.list.push(W5(t,`type`,this.idQuote,this.idCaseInsensitive)),n[t]=new e(this.idQuote,this.idCaseInsensitive))}maybeChild(e){return this.children?this.children[e]:null}addCompletion(e){let t=this.list.findIndex(t=>t.label==e.label);t>-1?this.list[t]=e:this.list.push(e)}addCompletions(e){for(let t of e)this.addCompletion(typeof t==`string`?W5(t,`property`,this.idQuote,this.idCaseInsensitive):t)}addNamespace(e){Array.isArray(e)?this.addCompletions(e):U5(e)?this.addNamespace(e.children):this.addNamespaceObject(e)}addNamespaceObject(e){for(let t of Object.keys(e)){let n=e[t],r=null,i=t.replace(/\\?\./g,e=>e==`.`?`\0`:e).split(`\0`),a=this;U5(n)&&(r=n.self,n=n.children);for(let e=0;e<i.length;e++)r&&e==i.length-1&&a.addCompletion(r),a=a.child(i[e].replace(/\\\./g,`.`));a.addNamespace(n)}}};function W5(e,t,n,r){return RegExp(`^[a-z_][a-z_\\d]*$`,r?`i`:``).test(e)?{label:e,type:t}:{label:e,type:t,apply:n+e+G5(n)}}function G5(e){return e===`[`?`]`:e}function Rwe(e,t,n,r,i,a){let o=new Lwe(a?.spec.identifierQuotes?.[0]||`"`,!!a?.spec.caseInsensitiveIdentifiers),s=i?o.child(i):null;return o.addNamespace(e),t&&(s||o).addCompletions(t),n&&o.addCompletions(n),s&&o.addCompletions(s.list),r&&o.addCompletions((s||o).child(r).list),e=>{let{parents:t,from:n,quoted:i,empty:a,aliases:c}=jwe(e.state,e.pos);if(a&&!e.explicit)return null;c&&t.length==1&&(t=c[t[0]]||t);let l=o;for(let e of t){for(;!l.children||!l.children[e];)if(l==o&&s)l=s;else if(l==s&&r)l=l.child(r);else return null;let t=l.maybeChild(e);if(!t)return null;l=t}let u=l.list;if(l==o&&c&&(u=u.concat(Object.keys(c).map(e=>({label:e,type:`constant`})))),i){let t=i[0],r=G5(t);return{from:n,to:e.state.sliceDoc(e.pos,e.pos+1)==r?e.pos+1:void 0,options:Pwe(t,r,u),validFor:Iwe}}else return{from:n,options:u,validFor:Fwe}}}function zwe(e){return e==w5?`type`:e==C5?`keyword`:`variable`}function Bwe(e,t,n){return xCe([`QuotedIdentifier`,`String`,`LineComment`,`BlockComment`,`.`],z8(Object.keys(e).map(r=>n(t?r.toUpperCase():r,zwe(e[r])))))}var Vwe=kwe.configure({props:[o8.add({Statement:GSe()}),KSe.add({Statement(e,t){return{from:Math.min(e.from+100,t.doc.lineAt(e.from).to),to:e.to}},BlockComment(e){return{from:e.from+2,to:e.to-2}}}),D6({Keyword:$.keyword,Type:$.typeName,Builtin:$.standard($.name),Bits:$.number,Bytes:$.string,Bool:$.bool,Null:$.null,Number:$.number,String:$.string,Identifier:$.name,QuotedIdentifier:$.special($.string),SpecialVar:$.special($.name),LineComment:$.lineComment,BlockComment:$.blockComment,Operator:$.operator,"Semi Punctuation":$.punctuation,"( )":$.paren,"{ }":$.brace,"[ ]":$.squareBracket})]}),K5=class e{constructor(e,t,n){this.dialect=e,this.language=t,this.spec=n}get extension(){return this.language.extension}configureLanguage(t,n){return new e(this.dialect,this.language.configure(t,n),this.spec)}static define(t){let n=Owe(t,t.keywords,t.types,t.builtin);return new e(n,jSe.define({name:`sql`,parser:Vwe.configure({tokenizers:[{from:R5,to:L5(n)}]}),languageData:{commentTokens:{line:`--`,block:{open:`/*`,close:`*/`}},closeBrackets:{brackets:[`(`,`[`,`{`,`'`,`"`,"`"]}}}),t)}};function Hwe(e,t){return{label:e,type:t,boost:-1}}function Uwe(e,t=!1,n){return Bwe(e.dialect.words,t,n||Hwe)}function Wwe(e){return e.schema?Rwe(e.schema,e.tables,e.schemas,e.defaultTable,e.defaultSchema,e.dialect||q5):()=>null}function Gwe(e){return e.schema?(e.dialect||q5).language.data.of({autocomplete:Wwe(e)}):[]}function Kwe(e={}){let t=e.dialect||q5;return new FSe(t.language,[Gwe(e),t.language.data.of({autocomplete:Uwe(t,e.upperCaseKeywords,e.keywordCompletion)})])}var q5=K5.define({}),qwe=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=Y5(e.state,n.from);return r.line?Jwe(e):r.block?Xwe(e):!1};function J5(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return i?(r(n.update(i)),!0):!1}}var Jwe=J5($we,0),Ywe=J5(Z5,0),Xwe=J5((e,t)=>Z5(e,t,Qwe(t)),0);function Y5(e,t){let n=e.languageDataAt(`commentTokens`,t,1);return n.length?n[0]:{}}var X5=50;function Zwe(e,{open:t,close:n},r,i){let a=e.sliceDoc(r-X5,r),o=e.sliceDoc(i,i+X5),s=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(o)[0].length,l=a.length-s;if(a.slice(l-t.length,l)==t&&o.slice(c,c+n.length)==n)return{open:{pos:r-s,margin:s&&1},close:{pos:i+c,margin:c&&1}};let u,d;i-r<=2*X5?u=d=e.sliceDoc(r,i):(u=e.sliceDoc(r,r+X5),d=e.sliceDoc(i-X5,i));let f=/^\s*/.exec(u)[0].length,p=/\s*$/.exec(d)[0].length,m=d.length-p-n.length;return u.slice(f,f+t.length)==t&&d.slice(m,m+n.length)==n?{open:{pos:r+f+t.length,margin:+!!/\s/.test(u.charAt(f+t.length))},close:{pos:i-p-n.length,margin:+!!/\s/.test(d.charAt(m-1))}}:null}function Qwe(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let a=t.length-1;a>=0&&t[a].to>r.from?t[a].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}function Z5(e,t,n=t.selection.ranges){let r=n.map(e=>Y5(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>Zwe(t,r[n],e.from,e.to));if(e!=2&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+` `},{from:e.to,insert:` `+r[t].close}]))};if(e!=1&&i.some(e=>e)){let e=[];for(let t=0,n;t<i.length;t++)if(n=i[t]){let i=r[t],{open:a,close:o}=n;e.push({from:a.pos-i.open.length,to:a.pos+a.margin},{from:o.pos-o.margin,to:o.pos+i.close.length})}return{changes:e}}return null}function $we(e,t,n=t.selection.ranges){let r=[],i=-1;ranges:for(let{from:e,to:a}of n){let n=r.length,o=1e9,s;for(let n=e;n<=a;){let c=t.doc.lineAt(n);if(s==null&&(s=Y5(t,c.from).line,!s))continue ranges;if(c.from>i&&(e==a||a>c.from)){i=c.from;let e=/^\s*/.exec(c.text)[0].length,t=e==c.length,n=c.text.slice(e,e+s.length)==s?e:-1;e<c.text.length&&e<o&&(o=e),r.push({line:c,comment:n,token:s,indent:e,empty:t,single:!1})}n=c.to+1}if(o<1e9)for(let e=n;e<r.length;e++)r[e].indent<r[e].line.text.length&&(r[e].indent=o);r.length==n+1&&(r[n].single=!0)}if(e!=2&&r.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:a,single:o}of r)(o||!a)&&e.push({from:t.from+i,insert:n+` `});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}else if(e!=1&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,a=r+i.length;t.text[a-t.from]==` `&&a++,e.push({from:r,to:a})}return{changes:e}}return null}var Q5=v1.define(),eTe=v1.define(),tTe=Y.define(),$5=Y.define({combine(e){return O1(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}}),e7=t1.define({create(){return u7.empty},update(e,t){let n=t.state.facet($5),r=t.annotation(Q5);if(r){let i=i7.fromTransaction(t,r.selection),a=r.side,o=a==0?e.undone:e.done;return o=i?a7(o,o.length,n.minDepth,i):c7(o,t.startState.selection),new u7(a==0?r.rest:o,a==0?o:r.rest)}let i=t.annotation(eTe);if((i==`full`||i==`before`)&&(e=e.isolate()),t.annotation(b1.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=i7.fromTransaction(t),o=t.annotation(b1.time),s=t.annotation(b1.userEvent);return a?e=e.addChanges(a,o,s,n,t):t.selection&&(e=e.addSelection(t.startState.selection,o,s,n.newGroupDelay)),(i==`full`||i==`after`)&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}},fromJSON(e){return new u7(e.done.map(i7.fromJSON),e.undone.map(i7.fromJSON))}});function nTe(e={}){return[e7,$5.of(e),Z.domEventHandlers({beforeinput(e,t){let n=e.inputType==`historyUndo`?n7:e.inputType==`historyRedo`?r7:null;return n?(e.preventDefault(),n(t)):!1}})]}function t7(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(e7,!1);if(!i)return!1;let a=i.pop(e,n,t);return a?(r(a),!0):!1}}var n7=t7(0,!1),r7=t7(1,!1),rTe=t7(0,!0),iTe=t7(1,!0),i7=class e{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(t){return new e(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){return{changes:this.changes?.toJSON(),mapped:this.mapped?.toJSON(),startSelection:this.startSelection?.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(t){return new e(t.changes&&B$.fromJSON(t.changes),[],t.mapped&&z$.fromJSON(t.mapped),t.startSelection&&J.fromJSON(t.startSelection),t.selectionsAfter.map(J.fromJSON))}static fromTransaction(t,n){let r=s7;for(let e of t.startState.facet(tTe)){let n=e(t);n.length&&(r=r.concat(n))}return!r.length&&t.changes.empty?null:new e(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,s7)}static selection(t){return new e(void 0,s7,void 0,void 0,t)}};function a7(e,t,n,r){let i=t+1>n+20?t-n-1:0,a=e.slice(i,t);return a.push(r),a}function aTe(e,t){let n=[],r=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,i,a)=>{for(let e=0;e<n.length;){let t=n[e++],o=n[e++];a>=t&&i<=o&&(r=!0)}}),r}function oTe(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function o7(e,t){return e.length?t.length?e.concat(t):e:t}var s7=[],sTe=200;function c7(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-sTe));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),a7(e,e.length-1,1e9,n.setSelAfter(r)))}else return[i7.selection([t])]}function cTe(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 l7(e,t){if(!e.length)return e;let n=e.length,r=s7;for(;n;){let i=lTe(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}else t=i.mapped,n--,r=i.selectionsAfter}return r.length?[i7.selection(r)]:s7}function lTe(e,t,n){let r=o7(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):s7,n);if(!e.changes)return i7.selection(r);let i=e.changes.map(t),a=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(a):a;return new i7(i,y1.mapEffects(e.effects,t),o,e.startSelection.map(a),r)}var uTe=/^(input\.type|delete)($|\.)/,u7=class e{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new e(this.done,this.undone):this}addChanges(t,n,r,i,a){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&t.changes&&(!r||uTe.test(r))&&(!s.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(a,aTe(s.changes,t.changes))||r==`input.type.compose`)?a7(o,o.length-1,i.minDepth,new i7(t.changes.compose(s.changes),o7(y1.mapEffects(t.effects,s.changes),s.effects),s.mapped,s.startSelection,s7)):a7(o,o.length,i.minDepth,t),new e(o,s7,n,r)}addSelection(t,n,r,i){let a=this.done.length?this.done[this.done.length-1].selectionsAfter:s7;return a.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&oTe(a[a.length-1],t)?this:new e(c7(this.done,t),this.undone,n,r)}addMapping(t){return new e(l7(this.done,t),l7(this.undone,t),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=e==0?this.done:this.undone;if(r.length==0)return null;let i=r[r.length-1],a=i.selectionsAfter[0]||(i.startSelection?i.startSelection.map(i.changes.invertedDesc,1):t.selection);if(n&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:Q5.of({side:e,rest:cTe(r),selection:a}),userEvent:e==0?`select.undo`:`select.redo`,scrollIntoView:!0});if(i.changes){let n=r.length==1?s7:r.slice(0,r.length-1);return i.mapped&&(n=l7(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:Q5.of({side:e,rest:n,selection:a}),filter:!1,userEvent:e==0?`undo`:`redo`,scrollIntoView:!0})}else return null}};u7.empty=new u7(s7,s7);var dTe=[{key:`Mod-z`,run:n7,preventDefault:!0},{key:`Mod-y`,mac:`Mod-Shift-z`,run:r7,preventDefault:!0},{linux:`Ctrl-Shift-z`,run:r7,preventDefault:!0},{key:`Mod-u`,run:rTe,preventDefault:!0},{key:`Alt-u`,mac:`Mod-Shift-u`,run:iTe,preventDefault:!0}];function d7(e,t){return J.create(e.ranges.map(t),e.mainIndex)}function f7(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:`select`})}function p7({state:e,dispatch:t},n){let r=d7(e.selection,n);return r.eq(e.selection,!0)?!1:(t(f7(e,r)),!0)}function m7(e,t){return J.cursor(t?e.to:e.from)}function h7(e,t){return p7(e,n=>n.empty?e.moveByChar(n,t):m7(n,t))}function g7(e){return e.textDirectionAt(e.state.selection.main.head)==J0.LTR}var _7=e=>h7(e,!g7(e)),v7=e=>h7(e,g7(e));function y7(e,t){return p7(e,n=>n.empty?e.moveByGroup(n,t):m7(n,t))}var fTe=e=>y7(e,!g7(e)),pTe=e=>y7(e,g7(e));typeof Intl<`u`&&Intl.Segmenter;function mTe(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 b7(e,t,n){let r=J6(e).resolveInner(t.head),i=n?n6.closedBy:n6.openedBy;for(let a=t.head;;){let t=n?r.childAfter(a):r.childBefore(a);if(!t)break;mTe(e,t,i)?r=t:a=n?t.to:t.from}let a=r.type.prop(i),o,s;return s=a&&(o=n?y8(e,r.from,1):y8(e,r.to,-1))&&o.matched?n?o.end.to:o.end.from:n?r.to:r.from,J.cursor(s,n?-1:1)}var hTe=e=>p7(e,t=>b7(e.state,t,!g7(e))),gTe=e=>p7(e,t=>b7(e.state,t,g7(e)));function x7(e,t){return p7(e,n=>{if(!n.empty)return m7(n,t);let r=e.moveVertically(n,t);return r.head==n.head?e.moveToLineBoundary(n,t):r})}var S7=e=>x7(e,!1),C7=e=>x7(e,!0);function w7(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,i;if(t){for(let t of e.state.facet(Z.scrollMargins)){let i=t(e);i?.top&&(n=Math.max(i?.top,n)),i?.bottom&&(r=Math.max(i?.bottom,r))}i=e.scrollDOM.clientHeight-n-r}else i=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,i-5)}}function T7(e,t){let n=w7(e),{state:r}=e,i=d7(r.selection,r=>r.empty?e.moveVertically(r,t,n.height):m7(r,t));if(i.eq(r.selection))return!1;let a;if(n.selfScroll){let t=e.coordsAtPos(r.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),s=o.top+n.marginTop,c=o.bottom-n.marginBottom;t&&t.top>s&&t.bottom<c&&(a=Z.scrollIntoView(i.main.head,{y:`start`,yMargin:t.top-s}))}return e.dispatch(f7(r,i),{effects:a}),!0}var E7=e=>T7(e,!1),D7=e=>T7(e,!0);function O7(e,t,n){let r=e.lineBlockAt(t.head),i=e.moveToLineBoundary(t,n);if(i.head==t.head&&i.head!=(n?r.to:r.from)&&(i=e.moveToLineBoundary(t,n,!1)),!n&&i.head==r.from&&r.length){let n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(i=J.cursor(r.from+n))}return i}var _Te=e=>p7(e,t=>O7(e,t,!0)),vTe=e=>p7(e,t=>O7(e,t,!1)),yTe=e=>p7(e,t=>O7(e,t,!g7(e))),bTe=e=>p7(e,t=>O7(e,t,g7(e))),xTe=e=>p7(e,t=>J.cursor(e.lineBlockAt(t.head).from,1)),STe=e=>p7(e,t=>J.cursor(e.lineBlockAt(t.head).to,-1));function CTe(e,t,n){let r=!1,i=d7(e.selection,t=>{let i=y8(e,t.head,-1)||y8(e,t.head,1)||t.head>0&&y8(e,t.head-1,1)||t.head<e.doc.length&&y8(e,t.head+1,-1);if(!i||!i.end)return t;r=!0;let a=i.start.from==t.head?i.end.to:i.end.from;return n?J.range(t.anchor,a):J.cursor(a)});return r?(t(f7(e,i)),!0):!1}var wTe=({state:e,dispatch:t})=>CTe(e,t,!1);function k7(e,t){let n=d7(e.state.selection,e=>{let n=t(e);return J.range(e.anchor,n.head,n.goalColumn,n.bidiLevel||void 0,n.assoc)});return n.eq(e.state.selection)?!1:(e.dispatch(f7(e.state,n)),!0)}function A7(e,t){return k7(e,n=>e.moveByChar(n,t))}var j7=e=>A7(e,!g7(e)),M7=e=>A7(e,g7(e));function N7(e,t){return k7(e,n=>e.moveByGroup(n,t))}var TTe=e=>N7(e,!g7(e)),ETe=e=>N7(e,g7(e)),DTe=e=>k7(e,t=>b7(e.state,t,!g7(e))),OTe=e=>k7(e,t=>b7(e.state,t,g7(e)));function P7(e,t){return k7(e,n=>e.moveVertically(n,t))}var F7=e=>P7(e,!1),I7=e=>P7(e,!0);function L7(e,t){return k7(e,n=>e.moveVertically(n,t,w7(e).height))}var R7=e=>L7(e,!1),z7=e=>L7(e,!0),kTe=e=>k7(e,t=>O7(e,t,!0)),ATe=e=>k7(e,t=>O7(e,t,!1)),jTe=e=>k7(e,t=>O7(e,t,!g7(e))),MTe=e=>k7(e,t=>O7(e,t,g7(e))),NTe=e=>k7(e,t=>J.cursor(e.lineBlockAt(t.head).from)),PTe=e=>k7(e,t=>J.cursor(e.lineBlockAt(t.head).to)),B7=({state:e,dispatch:t})=>(t(f7(e,{anchor:0})),!0),V7=({state:e,dispatch:t})=>(t(f7(e,{anchor:e.doc.length})),!0),H7=({state:e,dispatch:t})=>(t(f7(e,{anchor:e.selection.main.anchor,head:0})),!0),U7=({state:e,dispatch:t})=>(t(f7(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),FTe=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:`select`})),!0),ITe=({state:e,dispatch:t})=>{let n=Q7(e).map(({from:t,to:n})=>J.range(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:J.create(n),userEvent:`select`})),!0},LTe=({state:e,dispatch:t})=>{let n=d7(e.selection,t=>{let n=J6(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from<t.from&&n.to>=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return J.range(n.to,n.from)}return t});return n.eq(e.selection)?!1:(t(f7(e,n)),!0)};function W7(e,t){let{state:n}=e,r=n.selection,i=n.selection.ranges.slice();for(let r of n.selection.ranges){let a=n.doc.lineAt(r.head);if(t?a.to<e.state.doc.length:a.from>0)for(let n=r;;){let r=e.moveVertically(n,t);if(r.head<a.from||r.head>a.to){i.some(e=>e.head==r.head)||i.push(r);break}else if(r.head==n.head)break;else n=r}}return i.length==r.ranges.length?!1:(e.dispatch(f7(n,J.create(i,i.length-1))),!0)}var RTe=e=>W7(e,!1),zTe=e=>W7(e,!0),BTe=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=J.create([n.main]):n.main.empty||(r=J.create([J.cursor(n.main.head)])),r?(t(f7(e,r)),!0):!1};function G7(e,t){if(e.state.readOnly)return!1;let n=`delete.selection`,{state:r}=e,i=r.changeByRange(r=>{let{from:i,to:a}=r;if(i==a){let o=t(r);o<i?(n=`delete.backward`,o=K7(e,o,!1)):o>i&&(n=`delete.forward`,o=K7(e,o,!0)),i=Math.min(i,o),a=Math.max(a,o)}else i=K7(e,i,!1),a=K7(e,a,!0);return i==a?{range:r}:{changes:{from:i,to:a},range:J.cursor(i,i<r.head?-1:1)}});return i.changes.empty?!1:(e.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:n==`delete.selection`?Z.announce.of(r.phrase(`Selection deleted`)):void 0})),!0)}function K7(e,t,n){if(e instanceof Z)for(let r of e.state.facet(Z.atomicRanges).map(t=>t(e)))r.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}var q7=(e,t,n)=>G7(e,r=>{let i=r.from,{state:a}=e,o=a.doc.lineAt(i),s,c;if(n&&!t&&i>o.from&&i<o.from+200&&!/[^ \t]/.test(s=o.text.slice(0,i-o.from))){if(s[s.length-1]==` `)return i-1;let e=G1(s,a.tabSize)%n8(a)||n8(a);for(let t=0;t<e&&s[s.length-1-t]==` `;t++)i--;c=i}else c=N$(o.text,i-o.from,t,t)+o.from,c==i&&o.number!=(t?a.doc.lines:1)?c+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(c-o.from,i-o.from))&&(c=N$(o.text,c-o.from,!1,!1)+o.from);return c}),J7=e=>q7(e,!1,!0),Y7=e=>q7(e,!0,!1),X7=(e,t)=>G7(e,n=>{let r=n.head,{state:i}=e,a=i.doc.lineAt(r),o=i.charCategorizer(r);for(let e=null;;){if(r==(t?a.to:a.from)){r==n.head&&a.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}let s=N$(a.text,r-a.from,t)+a.from,c=a.text.slice(Math.min(r,s)-a.from,Math.max(r,s)-a.from),l=o(c);if(e!=null&&l!=e)break;(c!=` `||r!=n.head)&&(e=l),r=s}return r}),Z7=e=>X7(e,!1),VTe=e=>X7(e,!0),HTe=e=>G7(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),UTe=e=>G7(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),WTe=e=>G7(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),GTe=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:w$.of([``,``])},range:J.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:`input`})),!0},KTe=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||t.from==0||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n),i=n==r.from?n-1:N$(r.text,n-r.from,!1)+r.from,a=n==r.to?n+1:N$(r.text,n-r.from,!0)+r.from;return{changes:{from:i,to:a,insert:e.doc.slice(n,a).append(e.doc.slice(i,n))},range:J.cursor(a)}});return n.changes.empty?!1:(t(e.update(n,{scrollIntoView:!0,userEvent:`move.character`})),!0)};function Q7(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),a=e.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=a.to,e.ranges.push(r)}else t.push({from:i.from,to:a.to,ranges:[r]});n=a.number+1}return t}function $7(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of Q7(e)){if(n?t.to==e.doc.length:t.from==0)continue;let a=e.doc.lineAt(n?t.to+1:t.from-1),o=a.length+1;if(n){r.push({from:t.to,to:a.to},{from:t.from,insert:a.text+e.lineBreak});for(let n of t.ranges)i.push(J.range(Math.min(e.doc.length,n.anchor+o),Math.min(e.doc.length,n.head+o)))}else{r.push({from:a.from,to:t.from},{from:t.to,insert:e.lineBreak+a.text});for(let e of t.ranges)i.push(J.range(e.anchor-o,e.head-o))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:J.create(i,e.selection.mainIndex),userEvent:`move.line`})),!0):!1}var qTe=({state:e,dispatch:t})=>$7(e,t,!1),JTe=({state:e,dispatch:t})=>$7(e,t,!0);function e9(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of Q7(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:`input.copyline`})),!0}var YTe=({state:e,dispatch:t})=>e9(e,t,!1),XTe=({state:e,dispatch:t})=>e9(e,t,!0),ZTe=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(Q7(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=d7(t.selection,t=>{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:`delete.line`}),!0};function QTe(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=J6(e).resolveInner(t),r=n.childBefore(t),i=n.childAfter(t),a;return r&&i&&r.to<=t&&i.from>=t&&(a=r.type.prop(n6.closedBy))&&a.indexOf(i.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(i.from).from&&!/\S/.test(e.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}var t9=n9(!1),$Te=n9(!0);function n9(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{let{from:r,to:i}=n,a=t.doc.lineAt(r),o=!e&&r==i&&QTe(t,r);e&&(r=i=(i<=a.to?a:t.doc.lineAt(i)).to);let s=new a8(t,{simulateBreak:r,simulateDoubleBreak:!!o}),c=i8(s,r);for(c??=G1(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize);i<a.to&&/\s/.test(a.text[i-a.from]);)i++;o?{from:r,to:i}=o:r>a.from&&r<a.from+100&&!/\S/.test(a.text.slice(0,r))&&(r=a.from);let l=[``,r8(t,c)];return o&&l.push(r8(t,s.lineIndent(a.from,-1))),{changes:{from:r,to:i,insert:w$.of(l)},range:J.cursor(r+1+l[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:`input`})),!0}}function r9(e,t){let n=-1;return e.changeByRange(r=>{let i=[];for(let a=r.from;a<=r.to;){let o=e.doc.lineAt(a);o.number>n&&(r.empty||r.to>o.from)&&(t(o,i,r),n=o.number),a=o.to+1}let a=e.changes(i);return{changes:i,range:J.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}var eEe=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new a8(e,{overrideIndentation:e=>n[e]??-1}),i=r9(e,(t,i,a)=>{let o=i8(r,t.from);if(o==null)return;/\S/.test(t.text)||(o=0);let s=/^\s*/.exec(t.text)[0],c=r8(e,o);(s!=c||a.from<t.from+s.length)&&(n[t.from]=o,i.push({from:t.from,to:t.from+s.length,insert:c}))});return i.changes.empty||t(e.update(i,{userEvent:`indent`})),!0},tEe=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(r9(e,(t,n)=>{n.push({from:t.from,insert:e.facet(t8)})}),{userEvent:`input.indent`})),!0),nEe=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(r9(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=G1(r,e.tabSize),a=0,o=r8(e,Math.max(0,i-n8(e)));for(;a<r.length&&a<o.length&&r.charCodeAt(a)==o.charCodeAt(a);)a++;n.push({from:t.from+a,to:t.from+r.length,insert:o.slice(a)})}),{userEvent:`delete.dedent`})),!0),rEe=e=>(e.setTabFocusMode(),!0),iEe=[{key:`Ctrl-b`,run:_7,shift:j7,preventDefault:!0},{key:`Ctrl-f`,run:v7,shift:M7},{key:`Ctrl-p`,run:S7,shift:F7},{key:`Ctrl-n`,run:C7,shift:I7},{key:`Ctrl-a`,run:xTe,shift:NTe},{key:`Ctrl-e`,run:STe,shift:PTe},{key:`Ctrl-d`,run:Y7},{key:`Ctrl-h`,run:J7},{key:`Ctrl-k`,run:HTe},{key:`Ctrl-Alt-h`,run:Z7},{key:`Ctrl-o`,run:GTe},{key:`Ctrl-t`,run:KTe},{key:`Ctrl-v`,run:D7}],aEe=[{key:`ArrowLeft`,run:_7,shift:j7,preventDefault:!0},{key:`Mod-ArrowLeft`,mac:`Alt-ArrowLeft`,run:fTe,shift:TTe,preventDefault:!0},{mac:`Cmd-ArrowLeft`,run:yTe,shift:jTe,preventDefault:!0},{key:`ArrowRight`,run:v7,shift:M7,preventDefault:!0},{key:`Mod-ArrowRight`,mac:`Alt-ArrowRight`,run:pTe,shift:ETe,preventDefault:!0},{mac:`Cmd-ArrowRight`,run:bTe,shift:MTe,preventDefault:!0},{key:`ArrowUp`,run:S7,shift:F7,preventDefault:!0},{mac:`Cmd-ArrowUp`,run:B7,shift:H7},{mac:`Ctrl-ArrowUp`,run:E7,shift:R7},{key:`ArrowDown`,run:C7,shift:I7,preventDefault:!0},{mac:`Cmd-ArrowDown`,run:V7,shift:U7},{mac:`Ctrl-ArrowDown`,run:D7,shift:z7},{key:`PageUp`,run:E7,shift:R7},{key:`PageDown`,run:D7,shift:z7},{key:`Home`,run:vTe,shift:ATe,preventDefault:!0},{key:`Mod-Home`,run:B7,shift:H7},{key:`End`,run:_Te,shift:kTe,preventDefault:!0},{key:`Mod-End`,run:V7,shift:U7},{key:`Enter`,run:t9,shift:t9},{key:`Mod-a`,run:FTe},{key:`Backspace`,run:J7,shift:J7,preventDefault:!0},{key:`Delete`,run:Y7,preventDefault:!0},{key:`Mod-Backspace`,mac:`Alt-Backspace`,run:Z7,preventDefault:!0},{key:`Mod-Delete`,mac:`Alt-Delete`,run:VTe,preventDefault:!0},{mac:`Mod-Backspace`,run:UTe,preventDefault:!0},{mac:`Mod-Delete`,run:WTe,preventDefault:!0}].concat(iEe.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),oEe=[{key:`Alt-ArrowLeft`,mac:`Ctrl-ArrowLeft`,run:hTe,shift:DTe},{key:`Alt-ArrowRight`,mac:`Ctrl-ArrowRight`,run:gTe,shift:OTe},{key:`Alt-ArrowUp`,run:qTe},{key:`Shift-Alt-ArrowUp`,run:YTe},{key:`Alt-ArrowDown`,run:JTe},{key:`Shift-Alt-ArrowDown`,run:XTe},{key:`Mod-Alt-ArrowUp`,run:RTe},{key:`Mod-Alt-ArrowDown`,run:zTe},{key:`Escape`,run:BTe},{key:`Mod-Enter`,run:$Te},{key:`Alt-l`,mac:`Ctrl-l`,run:ITe},{key:`Mod-i`,run:LTe,preventDefault:!0},{key:`Mod-[`,run:nEe},{key:`Mod-]`,run:tEe},{key:`Mod-Alt-\\`,run:eEe},{key:`Shift-Mod-k`,run:ZTe},{key:`Shift-Mod-\\`,run:wTe},{key:`Mod-/`,run:qwe},{key:`Alt-A`,run:Ywe},{key:`Ctrl-m`,mac:`Shift-Alt-m`,run:rEe}].concat(aEe),i9=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFKD`):e=>e,a9=class{constructor(e,t,n=0,r=e.length,i,a){this.test=a,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer=``,this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=i?e=>i(i9(e)):i9,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return P$(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=F$(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=I$(e);let r=this.normalize(t);if(r.length)for(let e=0,i=n,a=!0;;e++){let n=r.charCodeAt(e),o=this.match(n,i,a,this.bufferPos+this.bufferStart,e==r.length-1);if(o)return this.value=o,this;if(e==r.length-1)break;a&&e<t.length&&t.charCodeAt(e)==n?i++:a=!1}}}match(e,t,n,r,i){let a=null;for(let t=0;t<this.matches.length;){let n=this.matches[t],o=!1;this.query.charCodeAt(n.index)==e&&(n.index==this.query.length-1?a={from:n.from,to:r,precise:i&&n.precise}:(n.index++,o=!0)),o?t++:this.matches.splice(t,1)}return this.query.charCodeAt(0)==e&&(this.query.length==1?a={from:t,to:r,precise:n&&i}:this.matches.push({from:t,index:1,precise:n})),a&&this.test&&!this.test(a.from,a.to,this.buffer,this.bufferStart)&&(a=null),a}};typeof Symbol<`u`&&(a9.prototype[Symbol.iterator]=function(){return this});var o9={from:-1,to:-1,match:/.*/.exec(``),precise:!0},s9=`gm`+(/x/.unicode==null?``:`u`),c9=class{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine=``,this.done=!1,this.value=o9,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new d9(e,t,n,r,i);this.re=new RegExp(t,s9+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.iter=e.iter();let a=e.lineAt(r);this.curLineStart=a.from,this.matchPos=f9(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine=``:(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine=``:this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=f9(this.text,r+ +(n==r)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,precise:!0,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},l9=new WeakMap,u9=class e{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(t,n,r){let i=l9.get(t);if(!i||i.from>=r||i.to<=n){let i=new e(n,t.sliceString(n,r));return l9.set(t,i),i}if(i.from==n&&i.to==r)return i;let{text:a,from:o}=i;return o>n&&(a=t.sliceString(n,o)+a,o=n),i.to<r&&(a+=t.sliceString(i.to,r)),l9.set(t,new e(o,a)),new e(n,a.slice(n-o,r-o))}},d9=class{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=o9,this.matchPos=f9(e,r),this.re=new RegExp(t,s9+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.flat=u9.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,precise:!0,match:t},this.matchPos=f9(this.text,n+ +(e==n)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=u9.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<`u`&&(c9.prototype[Symbol.iterator]=d9.prototype[Symbol.iterator]=function(){return this});function sEe(e){try{return new RegExp(e,s9),!0}catch{return!1}}function f9(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;for(;t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344;)t++;return t}var cEe=e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:i}=Qxe(e,{label:t.phrase(`Go to line`),input:{type:`text`,name:`line`,value:n},focus:!0,submitLabel:t.phrase(`go`)});return i.then(n=>{let i=n&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.elements.line.value);if(!i){e.dispatch({effects:r});return}let a=t.doc.lineAt(t.selection.main.head),[,o,s,c,l]=i,u=c?+c.slice(1):0,d=s?+s:a.number;if(s&&l){let e=d/100;o&&(e=e*(o==`-`?-1:1)+a.number/t.doc.lines),d=Math.round(t.doc.lines*e)}else s&&o&&(d=d*(o==`-`?-1:1)+a.number);let f=t.doc.line(Math.max(1,Math.min(t.doc.lines,d))),p=J.cursor(f.from+Math.max(0,Math.min(u,f.length)));e.dispatch({effects:[r,Z.scrollIntoView(p.from,{y:`center`})],selection:p})}),!0},lEe={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},p9=Y.define({combine(e){return O1(e,lEe,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function uEe(e){let t=[hEe,mEe];return e&&t.push(p9.of(e)),t}var dEe=x0.mark({class:`cm-selectionMatch`}),fEe=x0.mark({class:`cm-selectionMatch cm-selectionMatch-main`});function m9(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=T1.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=T1.Word)}function pEe(e,t,n,r){return e(t.sliceDoc(n,n+1))==T1.Word&&e(t.sliceDoc(r-1,r))==T1.Word}var mEe=T2.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(p9),{state:n}=e,r=n.selection;if(r.ranges.length>1)return x0.none;let i=r.main,a,o=null;if(i.empty){if(!t.highlightWordAroundCursor)return x0.none;let e=n.wordAt(i.head);if(!e)return x0.none;o=n.charCategorizer(i.head),a=n.sliceDoc(e.from,e.to)}else{let e=i.to-i.from;if(e<t.minSelectionLength||e>200)return x0.none;if(t.wholeWords){if(a=n.sliceDoc(i.from,i.to),o=n.charCategorizer(i.head),!(m9(o,n,i.from,i.to)&&pEe(o,n,i.from,i.to)))return x0.none}else if(a=n.sliceDoc(i.from,i.to),!a)return x0.none}let s=[];for(let r of e.visibleRanges){let e=new a9(n.doc,a,r.from,r.to);for(;!e.next().done;){let{from:r,to:a}=e.value;if((!o||m9(o,n,r,a))&&(i.empty&&r<=i.from&&a>=i.to?s.push(fEe.range(r,a)):(r>=i.to||a<=i.from)&&s.push(dEe.range(r,a)),s.length>t.maxMatches))return x0.none}}return x0.set(s)}},{decorations:e=>e.decorations}),hEe=Z.baseTheme({".cm-selectionMatch":{backgroundColor:`#99ff7780`},".cm-searchMatch .cm-selectionMatch":{backgroundColor:`transparent`}}),gEe=({state:e,dispatch:t})=>{let{selection:n}=e,r=J.create(n.ranges.map(t=>e.wordAt(t.head)||J.cursor(t.head)),n.mainIndex);return r.eq(n)?!1:(t(e.update({selection:r})),!0)};function _Ee(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),a=i&&i.from==n.from&&i.to==n.to;for(let n=!1,i=new a9(e.doc,t,r[r.length-1].to);;)if(i.next(),i.done){if(n)return null;i=new a9(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),n=!0}else{if(n&&r.some(e=>e.from==i.value.from))continue;if(a){let t=e.wordAt(i.value.from);if(!t||t.from!=i.value.from||t.to!=i.value.to)continue}return i.value}}var vEe=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return gEe({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=r))return!1;let i=_Ee(e,r);return i?(t(e.update({selection:e.selection.addRange(J.range(i.from,i.to),!1),effects:Z.scrollIntoView(i.to)})),!0):!1},h9=Y.define({combine(e){return O1(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new MEe(e),scrollToMatch:e=>Z.scrollIntoView(e)})}}),g9=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||``,this.valid=!!this.search&&(!this.regexp||sEe(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>t==`n`?`
751
- `:t==`r`?`\r`:t==`t`?` `:`\\`)}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new wEe(this):new xEe(this)}getCursor(e,t=0,n){let r=e.doc?e:D1.create({doc:e});return n??=r.doc.length,this.regexp?y9(this,r,t,n):v9(this,r,t,n)}},_9=class{constructor(e){this.spec=e}};function yEe(e,t,n){return(r,i,a,o)=>n&&!n(r,i,a,o)?!1:e(r>=o&&i<=o+a.length?a.slice(r-o,i-o):t.doc.sliceString(r,i),t,r,i)}function v9(e,t,n,r){let i;return e.wholeWord&&(i=bEe(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=yEe(e.test,t,i)),new a9(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}function bEe(e,t){return(n,r,i,a)=>((a>n||a+i.length<r)&&(a=Math.max(0,n-2),i=e.sliceString(a,Math.min(e.length,r+2))),(t(b9(i,n-a))!=T1.Word||t(x9(i,n-a))!=T1.Word)&&(t(x9(i,r-a))!=T1.Word||t(b9(i,r-a))!=T1.Word))}var xEe=class extends _9{constructor(e){super(e)}nextMatch(e,t,n){let r=v9(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=v9(this.spec,e,0,n).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==n?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let n=Math.max(t,r-1e4-this.spec.unquoted.length),i=v9(this.spec,e,n,r),a=null;for(;!i.nextOverlapping().done;)a=i.value;if(a)return a;if(n==t)return null;r-=1e4}}prevMatch(e,t,n){let r=this.prevMatchInRange(e,0,t);return r||=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length),r&&(r.from!=t||r.to!=n)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=v9(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=v9(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}};function SEe(e,t,n){return(r,i,a)=>(!n||n(r,i,a))&&e(a[0],t,r,i)}function y9(e,t,n,r){let i;return e.wholeWord&&(i=CEe(t.charCategorizer(t.selection.main.head))),e.test&&(i=SEe(e.test,t,i)),new c9(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function b9(e,t){return e.slice(N$(e,t,!1),t)}function x9(e,t){return e.slice(t,N$(e,t))}function CEe(e){return(t,n,r)=>!r[0].length||(e(b9(r.input,r.index))!=T1.Word||e(x9(r.input,r.index))!=T1.Word)&&(e(x9(r.input,r.index+r[0].length))!=T1.Word||e(b9(r.input,r.index+r[0].length))!=T1.Word)}var wEe=class extends _9{nextMatch(e,t,n){let r=y9(this.spec,e,n,e.doc.length).next();return r.done&&(r=y9(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let i=Math.max(t,n-r*1e4),a=y9(this.spec,e,i,n),o=null;for(;!a.next().done;)o=a.value;if(o&&(i==t||o.from>i+10))return o;if(i==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if(n==`&`)return e.match[0];if(n==`$`)return`$`;for(let t=n.length;t>0;t--){let r=+n.slice(0,t);if(r>0&&r<e.match.length)return e.match[r]+n.slice(t)}return t})}matchAll(e,t){let n=y9(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=y9(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}},S9=y1.define(),C9=y1.define(),w9=t1.define({create(e){return new T9(j9(e).create(),null)},update(e,t){for(let n of t.effects)n.is(S9)?e=new T9(n.value.create(),e.panel):n.is(C9)&&(e=new T9(e.query,n.value?A9:null));return e},provide:e=>R3.from(e,e=>e.panel)}),T9=class{constructor(e,t){this.query=e,this.panel=t}},TEe=x0.mark({class:`cm-searchMatch`}),EEe=x0.mark({class:`cm-searchMatch cm-searchMatch-selected`}),DEe=T2.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(w9))}update(e){let t=e.state.field(w9);(t!=e.startState.field(w9)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return x0.none;let{view:n}=this,r=new P1;for(let t=0,i=n.visibleRanges,a=i.length;t<a;t++){let{from:o,to:s}=i[t];for(;t<a-1&&s>i[t+1].from-500;)s=i[++t].to;e.highlight(n.state,o,s,(e,t)=>{let i=n.state.selection.ranges.some(n=>n.from==e&&n.to==t);r.add(e,t,i?EEe:TEe)})}return r.finish()}},{decorations:e=>e.decorations});function E9(e){return t=>{let n=t.state.field(w9,!1);return n&&n.query.spec.valid?e(t,n):P9(t)}}var D9=E9((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let i=J.single(r.from,r.to),a=e.state.facet(h9);return e.dispatch({selection:i,effects:[z9(e,r),a.scrollToMatch(i.main,e)],userEvent:`select.search`}),N9(e),!0}),O9=E9((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,i=t.prevMatch(n,r,r);if(!i)return!1;let a=J.single(i.from,i.to),o=e.state.facet(h9);return e.dispatch({selection:a,effects:[z9(e,i),o.scrollToMatch(a.main,e)],userEvent:`select.search`}),N9(e),!0}),OEe=E9((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:J.create(n.map(e=>J.range(e.from,e.to))),userEvent:`select.search.matches`}),!0)}),kEe=({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:i}=n.main,a=[],o=0;for(let t=new a9(e.doc,e.sliceDoc(r,i));!t.next().done;){if(a.length>1e3)return!1;t.value.from==r&&(o=a.length),a.push(J.range(t.value.from,t.value.to))}return t(e.update({selection:J.create(a,o),userEvent:`select.search.matches`})),!0},k9=E9((e,{query:t})=>{let{state:n}=e,{from:r,to:i}=n.selection.main;if(n.readOnly)return!1;let a=t.nextMatch(n,r,r);if(!a)return!1;let o=a,s=[],c,l,u=[];o.precise?o.from==r&&o.to==i&&(l=n.toText(t.getReplacement(o)),s.push({from:o.from,to:o.to,insert:l}),u.push(Z.announce.of(n.phrase(`replaced match on line $`,n.doc.lineAt(r).number)+`.`))):o=t.nextMatch(n,o.from,o.to);let d=e.state.changes(s);return o&&(c=J.single(o.from,o.to).map(d),u.push(z9(e,o)),u.push(n.facet(h9).scrollToMatch(c.main,e))),e.dispatch({changes:d,selection:c,effects:u,userEvent:`input.replace`}),!0}),AEe=E9((e,{query:t})=>{if(e.state.readOnly)return!1;let n=[];for(let r of t.matchAll(e.state,1e9)){let{from:e,to:i,precise:a}=r;a&&n.push({from:e,to:i,insert:t.getReplacement(r)})}if(!n.length)return!1;let r=e.state.phrase(`replaced $ matches`,n.length)+`.`;return e.dispatch({changes:n,effects:Z.announce.of(r),userEvent:`input.replace.all`}),!0});function A9(e){return e.state.facet(h9).createPanel(e)}function j9(e,t){let n=e.selection.main,r=n.empty||n.to>n.from+100?``:e.sliceDoc(n.from,n.to);if(t&&!r)return t;let i=e.facet(h9);return new g9({search:t?.literal??i.literal?r:r.replace(/\n/g,`\\n`),caseSensitive:t?.caseSensitive??i.caseSensitive,literal:t?.literal??i.literal,regexp:t?.regexp??i.regexp,wholeWord:t?.wholeWord??i.wholeWord})}function M9(e){let t=P3(e,A9);return t&&t.dom.querySelector(`[main-field]`)}function N9(e){let t=M9(e);t&&t==e.root.activeElement&&t.select()}var P9=e=>{let t=e.state.field(w9,!1);if(t&&t.panel){let n=M9(e);if(n&&n!=e.root.activeElement){let r=j9(e.state,t.query.spec);r.valid&&e.dispatch({effects:S9.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[C9.of(!0),t?S9.of(j9(e.state,t.query.spec)):y1.appendConfig.of(PEe)]});return!0},F9=e=>{let t=e.state.field(w9,!1);if(!t||!t.panel)return!1;let n=P3(e,A9);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:C9.of(!1)}),!0},jEe=[{key:`Mod-f`,run:P9,scope:`editor search-panel`},{key:`F3`,run:D9,shift:O9,scope:`editor search-panel`,preventDefault:!0},{key:`Mod-g`,run:D9,shift:O9,scope:`editor search-panel`,preventDefault:!0},{key:`Escape`,run:F9,scope:`editor search-panel`},{key:`Mod-Shift-l`,run:kEe},{key:`Mod-Alt-g`,run:cEe},{key:`Mod-d`,run:vEe,preventDefault:!0}],MEe=class{constructor(e){this.view=e;let t=this.query=e.state.field(w9).query.spec;this.commit=this.commit.bind(this),this.searchField=n0(`input`,{value:t.search,placeholder:I9(e,`Find`),"aria-label":I9(e,`Find`),class:`cm-textfield`,name:`search`,form:``,"main-field":`true`,onchange:this.commit,onkeyup:this.commit}),this.replaceField=n0(`input`,{value:t.replace,placeholder:I9(e,`Replace`),"aria-label":I9(e,`Replace`),class:`cm-textfield`,name:`replace`,form:``,onchange:this.commit,onkeyup:this.commit}),this.caseField=n0(`input`,{type:`checkbox`,name:`case`,form:``,checked:t.caseSensitive,onchange:this.commit}),this.reField=n0(`input`,{type:`checkbox`,name:`re`,form:``,checked:t.regexp,onchange:this.commit}),this.wordField=n0(`input`,{type:`checkbox`,name:`word`,form:``,checked:t.wholeWord,onchange:this.commit});function n(e,t,n){return n0(`button`,{class:`cm-button`,name:e,onclick:t,type:`button`},n)}this.dom=n0(`div`,{onkeydown:e=>this.keydown(e),class:`cm-search`},[this.searchField,n(`next`,()=>D9(e),[I9(e,`next`)]),n(`prev`,()=>O9(e),[I9(e,`previous`)]),n(`select`,()=>OEe(e),[I9(e,`all`)]),n0(`label`,null,[this.caseField,I9(e,`match case`)]),n0(`label`,null,[this.reField,I9(e,`regexp`)]),n0(`label`,null,[this.wordField,I9(e,`by word`)]),...e.state.readOnly?[]:[n0(`br`),this.replaceField,n(`replace`,()=>k9(e),[I9(e,`replace`)]),n(`replaceAll`,()=>AEe(e),[I9(e,`replace all`)])],n0(`button`,{name:`close`,onclick:()=>F9(e),"aria-label":I9(e,`close`),type:`button`},[`×`])])}commit(){let e=new g9({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:S9.of(e)}))}keydown(e){Hxe(this.view,e,`search-panel`)?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?O9:D9)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),k9(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(S9)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(h9).top}};function I9(e,t){return e.state.phrase(t)}var L9=30,R9=/[\s\.,:;?!]/;function z9(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),i=e.state.doc.lineAt(n).to,a=Math.max(r.from,t-L9),o=Math.min(i,n+L9),s=e.state.sliceDoc(a,o);if(a!=r.from){for(let e=0;e<L9;e++)if(!R9.test(s[e+1])&&R9.test(s[e])){s=s.slice(e);break}}if(o!=i){for(let e=s.length-1;e>s.length-L9;e--)if(!R9.test(s[e-1])&&R9.test(s[e])){s=s.slice(0,e);break}}return Z.announce.of(`${e.state.phrase(`current match`)}. ${s} ${e.state.phrase(`on line`)} ${r.number}.`)}var NEe=Z.baseTheme({".cm-panel.cm-search":{padding:`2px 6px 4px`,position:`relative`,"& [name=close]":{position:`absolute`,top:`0`,right:`4px`,backgroundColor:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0},"& input, & button, & label":{margin:`.2em .6em .2em 0`},"& input[type=checkbox]":{marginRight:`.2em`},"& label":{fontSize:`80%`,whiteSpace:`pre`}},"&light .cm-searchMatch":{backgroundColor:`#ffff0054`},"&dark .cm-searchMatch":{backgroundColor:`#00ffff8a`},"&light .cm-searchMatch-selected":{backgroundColor:`#ff6a0054`},"&dark .cm-searchMatch-selected":{backgroundColor:`#ff00ff8a`}}),PEe=[w9,i1.low(DEe),NEe],FEe=`modulepreload`,IEe=function(e){return`/`+e},B9={},LEe=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=IEe(t,n),t in B9)return;B9[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:FEe,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},REe=[{label:`All TPS events`,sql:`SELECT * FROM tps_flat ORDER BY timestamp`},{label:`Per-model aggregates`,sql:`SELECT
740
+ `))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return ive(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=JQ.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function Gve(){return{exit:{taskListCheckValueChecked:ZQ,taskListCheckValueUnchecked:ZQ,paragraph:qve}}}function Kve(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:Jve}}}function ZQ(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function qve(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function Jve(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=JQ.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function Yve(){return[D_e(),J_e(),Q_e(),Rve(),Gve()]}function Xve(e){return{extensions:[O_e(),Y_e(e),$_e(),Wve(e),Kve()]}}var Zve={tokenize:rye,partial:!0},QQ={tokenize:iye,partial:!0},$Q={tokenize:aye,partial:!0},e$={tokenize:oye,partial:!0},Qve={tokenize:sye,partial:!0},t$={name:`wwwAutolink`,tokenize:tye,previous:o$},n$={name:`protocolAutolink`,tokenize:nye,previous:s$},r$={name:`emailAutolink`,tokenize:eye,previous:c$},i$={};function $ve(){return{text:i$}}for(var a$=48;a$<123;)i$[a$]=r$,a$++,a$===58?a$=65:a$===91&&(a$=97);i$[43]=r$,i$[45]=r$,i$[46]=r$,i$[95]=r$,i$[72]=[r$,n$],i$[104]=[r$,n$],i$[87]=[r$,t$],i$[119]=[r$,t$];function eye(e,t,n){let r=this,i,a;return o;function o(t){return!l$(t)||!c$.call(r,r.previous)||u$(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return l$(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(Qve,u,l)(t):t===45||t===95||XX(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&YX(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function tye(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!o$.call(r,r.previous)||u$(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(Zve,e.attempt(QQ,e.attempt($Q,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function nye(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&s$.call(r,r.previous)&&!u$(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(YX(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||ZX(t)||$X(t)||nZ(t)||tZ(t)?n(t):e.attempt(QQ,e.attempt($Q,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function rye(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function iye(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(e$,c,s)(t):t===null||$X(t)||nZ(t)||t!==45&&tZ(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function aye(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(e$,t,a)(o):o===null||$X(o)||nZ(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function oye(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||$X(o)||nZ(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||$X(e)||nZ(e)?t(e):r(e)}function a(e){return YX(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):YX(t)?(e.consume(t),o):n(t)}}function sye(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return XX(e)?n(e):t(e)}}function o$(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||$X(e)}function s$(e){return!YX(e)}function c$(e){return!(e===47||l$(e))}function l$(e){return e===43||e===45||e===46||e===95||XX(e)}function u$(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var cye={tokenize:gye,partial:!0};function lye(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:pye,continuation:{tokenize:mye},exit:hye}},text:{91:{name:`gfmFootnoteCall`,tokenize:fye},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:uye,resolveTo:dye}}}}function uye(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=JX(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function dye(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function fye(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||$X(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(JX(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return $X(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function pye(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||$X(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=JX(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return $X(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),aZ(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function mye(e,t,n){return e.check(dZ,t,e.attempt(cye,t,n))}function hye(e){e.exit(`gfmFootnoteDefinition`)}function gye(e,t,n){let r=this;return aZ(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function _ye(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&UX(o,o.length,0,cZ(s,e.slice(r+1,n),t)),UX(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),UX(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=sZ(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=sZ(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var vye=class{constructor(){this.map=[]}add(e,t,n){yye(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function yye(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function bye(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function xye(){return{flow:{null:{name:`table`,tokenize:Sye,resolveAll:Cye}}}}function Sye(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):q(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):eZ(t)?aZ(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||$X(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,eZ(t)?aZ(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return eZ(t)?aZ(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||q(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return eZ(t)?aZ(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||q(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||q(n)?(e.exit(`tableRow`),t(n)):eZ(n)?aZ(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||$X(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function Cye(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new vye;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(f$(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=d$(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=d$(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=d$(f,t,o,i,n,d)):(o[0]=o[1],d=d$(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&f$(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=bye(t.events,n))}return e}function d$(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},p$(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=p$(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=p$(t.events,n[2]),a=p$(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},p$(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function f$(e,t,n,r,i){let a=[],o=p$(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function p$(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var wye={name:`tasklistCheck`,tokenize:Eye};function Tye(){return{text:{91:wye}}}function Eye(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return $X(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return q(r)?t(r):eZ(r)?e.check({tokenize:Dye},t,n)(r):n(r)}}function Dye(e,t,n){return aZ(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function Oye(e){return KX([$ve(),lye(),_ye(e),xye(),Tye()])}var kye={};function Aye(e){let t=this,n=e||kye,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(Oye(n)),a.push(Yve()),o.push(Xve(n))}var m$=[],h$=[];(()=>{let e=`lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o`.split(`,`).map(e=>e?parseInt(e,36):1);for(let t=0,n=0;t<e.length;t++)(t%2?h$:m$).push(n+=e[t])})();function jye(e){if(e<768)return!1;for(let t=0,n=m$.length;;){let r=t+n>>1;if(e<m$[r])n=r;else if(e>=h$[r])t=r+1;else return!0;if(t==n)return!1}}function g$(e){return e>=127462&&e<=127487}var _$=8205;function Mye(e,t,n=!0,r=!0){return(n?v$:Nye)(e,t,r)}function v$(e,t,n){if(t==e.length)return t;t&&b$(e.charCodeAt(t))&&x$(e.charCodeAt(t-1))&&t--;let r=y$(e,t);for(t+=S$(r);t<e.length;){let i=y$(e,t);if(r==_$||i==_$||n&&jye(i))t+=S$(i),r=i;else if(g$(i)){let n=0,r=t-2;for(;r>=0&&g$(y$(e,r));)n++,r-=2;if(n%2==0)break;t+=2}else break}return t}function Nye(e,t,n){for(;t>0;){let r=v$(e,t-2,n);if(r<t)return r;t--}return 0}function y$(e,t){let n=e.charCodeAt(t);if(!x$(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return b$(r)?(n-55296<<10)+(r-56320)+65536:n}function b$(e){return e>=56320&&e<57344}function x$(e){return e>=55296&&e<56320}function S$(e){return e<65536?1:2}var C$=class e{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]=j$(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),T$.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]=j$(this,e,t);let n=[];return this.decompose(e,t,n,0),T$.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 O$(this),i=new O$(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 O$(this,e)}iterRange(e,t=this.length){return new k$(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{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 A$(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(t){if(t.length==0)throw RangeError(`A document must have at least one line`);return t.length==1&&!t[0]?e.empty:t.length<=32?new w$(t):T$.from(w$.split(t,[]))}},w$=class e extends C${constructor(e,t=Pye(e)){super(),this.text=e,this.length=t}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 Fye(r,o,n,a);r=o+1,n++}}decompose(t,n,r,i){let a=t<=0&&n>=this.length?this:new e(D$(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(i&1){let t=r.pop(),n=E$(a.text,t.text.slice(),0,a.length);if(n.length<=32)r.push(new e(n,t.length+a.length));else{let t=n.length>>1;r.push(new e(n.slice(0,t)),new e(n.slice(t)))}}else r.push(a)}replace(t,n,r){if(!(r instanceof e))return super.replace(t,n,r);[t,n]=j$(this,t,n);let i=E$(this.text,E$(r.text,D$(this.text,0,t)),n),a=this.length+r.length-(n-t);return i.length<=32?new e(i,a):T$.from(e.split(i,[]),a)}sliceString(e,t=this.length,n=`
741
+ `){[e,t]=j$(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(t,n){let r=[],i=-1;for(let a of t)r.push(a),i+=a.length+1,r.length==32&&(n.push(new e(r,i)),r=[],i=-1);return i>-1&&n.push(new e(r,i)),n}},T$=class e extends C${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(t,n,r){if([t,n]=j$(this,t,n),r.lines<this.lines)for(let i=0,a=0;i<this.children.length;i++){let o=this.children[i],s=a+o.length;if(t>=a&&n<=s){let c=o.replace(t-a,n-a,r),l=this.lines-o.lines+c.lines;if(c.lines<l>>4&&c.lines>l>>6){let a=this.children.slice();return a[i]=c,new e(a,this.length-(n-t)+r.length)}return super.replace(a,s,c)}a=s+1}return super.replace(t,n,r)}sliceString(e,t=this.length,n=`
742
+ `){[e,t]=j$(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(t,n){if(!(t instanceof e))return 0;let r=0,[i,a,o,s]=n>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;i+=n,a+=n){if(i==o||a==s)return r;let e=this.children[i],c=t.children[a];if(e!=c)return r+e.scanIdentical(c,n);r+=e.length+1}}static from(t,n=t.reduce((e,t)=>e+t.length+1,-1)){let r=0;for(let e of t)r+=e.lines;if(r<32){let e=[];for(let n of t)n.flatten(e);return new w$(e,n)}let i=Math.max(32,r>>5),a=i<<1,o=i>>1,s=[],c=0,l=-1,u=[];function d(t){let n;if(t.lines>a&&t instanceof e)for(let e of t.children)d(e);else t.lines>o&&(c>o||!c)?(f(),s.push(t)):t instanceof w$&&c&&(n=u[u.length-1])instanceof w$&&t.lines+n.lines<=32?(c+=t.lines,l+=t.length+1,u[u.length-1]=new w$(n.text.concat(t.text),n.length+1+t.length)):(c+t.lines>i&&f(),c+=t.lines,l+=t.length+1,u.push(t))}function f(){c!=0&&(s.push(u.length==1?u[0]:e.from(u,l)),l=-1,c=u.length=0)}for(let e of t)d(e);return f(),s.length==1?s[0]:new e(s,n)}};C$.empty=new w$([``],0);function Pye(e){let t=-1;for(let n of e)t+=n.length+1;return t}function E$(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 D$(e,t,n){return E$(e,[``],t,n)}var O$=class{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 w$?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 w$?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=`
743
+ `,this;e--}else if(r instanceof w$){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 w$?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)}},k$=class{constructor(e,t,n){this.value=``,this.done=!1,this.cursor=new O$(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!=``}},A$=class{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`&&(C$.prototype[Symbol.iterator]=function(){return this.iter()},O$.prototype[Symbol.iterator]=k$.prototype[Symbol.iterator]=A$.prototype[Symbol.iterator]=function(){return this});var Fye=class{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 j$(e,t,n){return t=Math.max(0,Math.min(e.length,t)),[t,Math.max(t,Math.min(e.length,n))]}function M$(e,t,n=!0,r=!0){return Mye(e,t,n,r)}function Iye(e){return e>=56320&&e<57344}function Lye(e){return e>=55296&&e<56320}function N$(e,t){let n=e.charCodeAt(t);if(!Lye(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return Iye(r)?(n-55296<<10)+(r-56320)+65536:n}function P$(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}function F$(e){return e<65536?1:2}var I$=/\r\n?|\n/,L$=(function(e){return e[e.Simple=0]=`Simple`,e[e.TrackDel=1]=`TrackDel`,e[e.TrackBefore=2]=`TrackBefore`,e[e.TrackAfter=3]=`TrackAfter`,e})(L$||={}),R$=class e{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 t=[];for(let e=0;e<this.sections.length;){let n=this.sections[e++],r=this.sections[e++];r<0?t.push(n,r):t.push(r,n)}return new e(t)}composeDesc(e){return this.empty?e:e.empty?this:W$(this,e)}mapDesc(e,t=!1){return e.empty?this:U$(this,e,t)}mapPos(e,t=-1,n=L$.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!=L$.Simple&&c>=e&&(n==L$.TrackDel&&r<e&&c>e||n==L$.TrackBefore&&r<e||n==L$.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(t){if(!Array.isArray(t)||t.length%2||t.some(e=>typeof e!=`number`))throw RangeError(`Invalid JSON representation of ChangeDesc`);return new e(t)}static create(t){return new e(t)}},z$=class e extends R${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}mapDesc(e,t=!1){return U$(this,e,t,!0)}invert(t){let n=this.sections.slice(),r=[];for(let e=0,i=0;e<n.length;e+=2){let a=n[e],o=n[e+1];if(o>=0){n[e]=o,n[e+1]=a;let s=e>>1;for(;r.length<s;)r.push(C$.empty);r.push(a?t.slice(i,i+a):C$.empty)}i+=a}return new e(n,r)}compose(e){return this.empty?e:e.empty?this:W$(this,e,!0)}map(e,t=!1){return e.empty?this:U$(this,e,t,!0)}iterChanges(e,t=!1){H$(this,e,t)}get desc(){return R$.create(this.sections)}filter(t){let n=[],r=[],i=[],a=new G$(this);done:for(let e=0,o=0;;){let s=e==t.length?1e9:t[e++];for(;o<s||o==s&&a.len==0;){if(a.done)break done;let e=Math.min(a.len,s-o);B$(i,e,-1);let t=a.ins==-1?-1:a.off==0?a.ins:0;B$(n,e,t),t>0&&V$(r,n,a.text),a.forward(e),o+=e}let c=t[e++];for(;o<c;){if(a.done)break done;let e=Math.min(a.len,c-o);B$(n,e,-1),B$(i,e,a.ins==-1?-1:a.off==0?a.ins:0),a.forward(e),o+=e}}return{changes:new e(n,r),filtered:R$.create(i)}}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(t,n,r){let i=[],a=[],o=0,s=null;function c(t=!1){if(!t&&!i.length)return;o<n&&B$(i,n-o,-1);let r=new e(i,a);s=s?s.compose(r.map(s)):r,i=[],a=[],o=0}function l(t){if(Array.isArray(t))for(let e of t)l(e);else if(t instanceof e){if(t.length!=n)throw RangeError(`Mismatched change set length (got ${t.length}, expected ${n})`);c(),s=s?s.compose(t.map(s)):t}else{let{from:e,to:s=e,insert:l}=t;if(e>s||e<0||s>n)throw RangeError(`Invalid change range ${e} to ${s} (in doc of length ${n})`);let u=l?typeof l==`string`?C$.of(l.split(r||I$)):l:C$.empty,d=u.length;if(e==s&&d==0)return;e<o&&c(),e>o&&B$(i,e-o,-1),B$(i,s-e,d),V$(a,i,u),o=s}}return l(t),c(!s),s}static empty(t){return new e(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw RangeError(`Invalid JSON representation of ChangeSet`);let n=[],r=[];for(let e=0;e<t.length;e++){let i=t[e];if(typeof i==`number`)n.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)n.push(i[0],0);else{for(;r.length<e;)r.push(C$.empty);r[e]=C$.of(i.slice(1)),n.push(i[0],r[e].length)}}return new e(n,r)}static createSet(t,n){return new e(t,n)}};function B$(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 V$(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(C$.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=C$.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 U$(e,t,n,r=!1){let i=[],a=r?[]:null,o=new G$(e),s=new G$(t);for(let e=-1;;)if(o.done&&s.len||s.done&&o.len)throw Error(`Mismatched change set lengths`);else if(o.ins==-1&&s.ins==-1){let e=Math.min(o.len,s.len);B$(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(B$(i,s.ins,-1);t;){let n=Math.min(o.len,t);o.ins>=0&&e<o.i&&o.len<=n&&(B$(i,0,o.ins),a&&V$(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;B$(i,t,e<o.i?o.ins:0),a&&e<o.i&&V$(a,i,o.text),e=o.i,o.forward(o.len-n)}else if(o.done&&s.done)return a?z$.createSet(i,a):R$.create(i);else throw Error(`Mismatched change set lengths`)}function W$(e,t,n=!1){let r=[],i=n?[]:null,a=new G$(e),o=new G$(t);for(let e=!1;;)if(a.done&&o.done)return i?z$.createSet(r,i):R$.create(r);else if(a.ins==0)B$(r,a.len,0,e),a.next();else if(o.len==0&&!o.done)B$(r,0,o.ins,e),i&&V$(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;B$(r,t,n,e),i&&n&&V$(i,r,o.text)}else o.ins==-1?(B$(r,a.off?0:a.len,t,e),i&&V$(i,r,a.textBit(t))):(B$(r,a.off?0:a.len,o.off?0:o.ins,e),i&&!o.off&&V$(i,r,o.text));e=(a.ins>t||o.ins>=0&&o.len>t)&&(e||r.length>n),a.forward2(t),o.forward(t)}}var G$=class{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?C$.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?C$.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)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}},K$=class e{constructor(e,t,n){this.from=e,this.to=t,this.flags=n}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 bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(t,n=-1){let r,i;return this.empty?r=i=t.mapPos(this.from,n):(r=t.mapPos(this.from,1),i=t.mapPos(this.to,-1)),r==this.from&&i==this.to?this:new e(r,i,this.flags)}extend(e,t=e,n=0){if(e<=this.anchor&&t>=this.anchor)return J.range(e,t,void 0,void 0,n);let r=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return J.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 J.range(e.anchor,e.head)}static create(t,n,r){return new e(t,n,r)}},J=class e{constructor(e,t){this.ranges=e,this.mainIndex=t}map(t,n=-1){return t.empty?this:e.create(this.ranges.map(e=>e.map(t,n)),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 e([this.main],0)}addRange(t,n=!0){return e.create([t].concat(this.ranges),n?0:this.mainIndex+1)}replaceRange(t,n=this.mainIndex){let r=this.ranges.slice();return r[n]=t,e.create(r,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||typeof t.main!=`number`||t.main>=t.ranges.length)throw RangeError(`Invalid JSON representation for EditorSelection`);return new e(t.ranges.map(e=>K$.fromJSON(e)),t.main)}static single(t,n=t){return new e([e.range(t,n)],0)}static create(t,n=0){if(t.length==0)throw RangeError(`A selection needs at least one range`);for(let r=0,i=0;i<t.length;i++){let a=t[i];if(a.empty?a.from<=r:a.from<r)return e.normalized(t.slice(),n);r=a.to}return new e(t,n)}static cursor(e,t=0,n,r){return K$.create(e,e,(t==0?0:t<0?8:16)|(n==null?7:Math.min(6,n))|(r??16777215)<<6)}static range(e,t,n,r,i){let a=(n??16777215)<<6|(r==null?7:Math.min(6,r));return!i&&e!=t&&(i=t<e?1:-1),t<e?K$.create(t,e,48|a):K$.create(e,t,(i?i<0?8:16:0)|a)}static normalized(t,n=0){let r=t[n];t.sort((e,t)=>e.from-t.from),n=t.indexOf(r);for(let r=1;r<t.length;r++){let i=t[r],a=t[r-1];if(i.empty?i.from<=a.to:i.from<a.to){let o=a.from,s=Math.max(i.to,a.to);r<=n&&n--,t.splice(--r,2,i.anchor>i.head?e.range(s,o):e.range(o,s))}}return new e(t,n)}};function q$(e,t){for(let n of e.ranges)if(n.to>t)throw RangeError(`Selection points outside of document`)}var J$=0,Y=class e{constructor(e,t,n,r,i){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=r,this.id=J$++,this.default=e([]),this.extensions=typeof i==`function`?i(this):i}get reader(){return this}static define(t={}){return new e(t.combine||(e=>e),t.compareInput||((e,t)=>e===t),t.compare||(t.combine?(e,t)=>e===t:Y$),!!t.static,t.enables)}of(e){return new X$([],this,0,e)}compute(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new X$(e,this,1,t)}computeN(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new X$(e,this,2,t)}from(e,t){return t||=e=>e,this.compute([e],n=>t(n.field(e)))}};function Y$(e,t){return e==t||e.length==t.length&&e.every((e,n)=>e===t[n])}var X$=class{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=J$++}dynamicSlot(e){let t=this.value,n=this.facet.compareInput,r=this.id,i=e[r]>>1,a=this.type==2,o=!1,s=!1,c=[];for(let t of this.dependencies)t==`doc`?o=!0:t==`selection`?s=!0:(e[t.id]??1)&1||c.push(e[t.id]);return{create(e){return e.values[i]=t(e),1},update(e,r){if(o&&r.docChanged||s&&(r.docChanged||r.selection)||Q$(e,c)){let r=t(e);if(a?!Z$(r,e.values[i],n):!n(r,e.values[i]))return e.values[i]=r,1}return 0},reconfigure:(e,o)=>{let s,c=o.config.address[r];if(c!=null){let r=l1(o,c);if(this.dependencies.every(t=>t instanceof Y?o.facet(t)===e.facet(t):t instanceof e1?o.field(t,!1)==e.field(t,!1):!0)||(a?Z$(s=t(e),r,n):n(s=t(e),r)))return e.values[i]=r,0}else s=t(e);return e.values[i]=s,1}}}};function Z$(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 Q$(e,t){let n=!1;for(let r of t)c1(e,r)&1&&(n=!0);return n}function Rye(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=l1(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)c1(e,t);return e.values[o]=s(e),1},update(e,n){if(!Q$(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=Q$(e,r),c=i.config.facets[t.id],l=i.facet(t);if(c&&!a&&Y$(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)}}}var $$=Y.define({static:!0}),e1=class e{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(t){let n=new e(J$++,t.create,t.update,t.compare||((e,t)=>e===t),t);return t.provide&&(n.provides=t.provide(n)),n}create(e){return(e.facet($$).find(e=>e.field==this)?.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($$),i=n.facet($$),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,$$.of({field:this,create:e})]}get extension(){return this}},t1={lowest:4,low:3,default:2,high:1,highest:0};function n1(e){return t=>new i1(t,e)}var r1={highest:n1(t1.highest),high:n1(t1.high),default:n1(t1.default),low:n1(t1.low),lowest:n1(t1.lowest)},i1=class{constructor(e,t){this.inner=e,this.prec=t}},a1=class e{of(e){return new o1(this,e)}reconfigure(t){return e.reconfigure.of({compartment:this,extension:t})}get(e){return e.config.compartments.get(this)}},o1=class{constructor(e,t){this.compartment=e,this.inner=t}},s1=class e{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(t,n,r){let i=[],a=Object.create(null),o=new Map;for(let e of zye(t,n,o))e instanceof e1?i.push(e):(a[e.facet.id]||(a[e.facet.id]=[])).push(e);let s=Object.create(null),c=[],l=[];for(let e of i)s[e.id]=l.length<<1,l.push(t=>e.slot(t));let u=r?.config.facets;for(let e in a){let t=a[e],n=t[0].facet,i=u&&u[e]||[];if(t.every(e=>e.type==0))if(s[n.id]=c.length<<1|1,Y$(i,t))c.push(r.facet(n));else{let e=n.combine(t.map(e=>e.value));c.push(r&&n.compare(e,r.facet(n))?r.facet(n):e)}else{for(let e of t)e.type==0?(s[e.id]=c.length<<1|1,c.push(e.value)):(s[e.id]=l.length<<1,l.push(t=>e.dynamicSlot(t)));s[n.id]=l.length<<1,l.push(e=>Rye(e,n,t))}}return new e(t,o,l.map(e=>e(s)),s,c,a)}};function zye(e,t,n){let r=[[],[],[],[],[]],i=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 o1&&n.delete(e.compartment)}if(i.set(e,o),Array.isArray(e))for(let t of e)a(t,o);else if(e instanceof o1){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 i1)a(e.inner,e.prec);else if(e instanceof e1)r[o].push(e),e.provides&&a(e.provides,o);else if(e instanceof X$)r[o].push(e),e.facet.extensions&&a(e.facet.extensions,t1.default);else{let t=e.extension;if(!t)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,t1.default),r.reduce((e,t)=>e.concat(t))}function c1(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 l1(e,t){return t&1?e.config.staticValues[t>>1]:e.values[t>>1]}var u1=Y.define(),d1=Y.define({combine:e=>e.some(e=>e),static:!0}),f1=Y.define({combine:e=>e.length?e[0]:void 0,static:!0}),p1=Y.define(),m1=Y.define(),h1=Y.define(),g1=Y.define({combine:e=>e.length?e[0]:!1}),_1=class{constructor(e,t){this.type=e,this.value=t}static define(){return new Bye}},Bye=class{of(e){return new _1(this,e)}},Vye=class{constructor(e){this.map=e}of(e){return new v1(this,e)}},v1=class e{constructor(e,t){this.type=e,this.value=t}map(t){let n=this.type.map(this.value,t);return n===void 0?void 0:n==this.value?this:new e(this.type,n)}is(e){return this.type==e}static define(e={}){return new Vye(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}};v1.reconfigure=v1.define(),v1.appendConfig=v1.define();var y1=class e{constructor(t,n,r,i,a,o){this.startState=t,this.changes=n,this.selection=r,this.effects=i,this.annotations=a,this.scrollIntoView=o,this._doc=null,this._state=null,r&&q$(r,n.newLength),a.some(t=>t.type==e.time)||(this.annotations=a.concat(e.time.of(Date.now())))}static create(t,n,r,i,a,o){return new e(t,n,r,i,a,o)}get newDoc(){return 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(t){let n=this.annotation(e.userEvent);return!!(n&&(n==t||n.length>t.length&&n.slice(0,t.length)==t&&n[t.length]==`.`))}};y1.time=_1.define(),y1.userEvent=_1.define(),y1.addToHistory=_1.define(),y1.remote=_1.define();function Hye(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 b1(e,t,n){let r,i,a;return n?(r=t.changes,i=z$.empty(t.changes.length),a=e.changes.compose(t.changes)):(r=t.changes.map(e.changes),i=e.changes.mapDesc(t.changes,!0),a=e.changes.compose(r)),{changes:a,selection:t.selection?t.selection.map(i):e.selection?.map(r),effects:v1.mapEffects(e.effects,r).concat(v1.mapEffects(t.effects,i)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function x1(e,t,n){let r=t.selection,i=C1(t.annotations);return t.userEvent&&(i=i.concat(y1.userEvent.of(t.userEvent))),{changes:t.changes instanceof z$?t.changes:z$.of(t.changes||[],n,e.facet(f1)),selection:r&&(r instanceof J?r:J.single(r.anchor,r.head)),effects:C1(t.effects),annotations:i,scrollIntoView:!!t.scrollIntoView}}function S1(e,t,n){let r=x1(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=b1(r,x1(e,t[i],a?r.changes.newLength:e.doc.length),a)}let i=y1.create(e,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return Wye(n?Uye(i):i)}function Uye(e){let t=e.startState,n=!0;for(let r of t.facet(p1)){let t=r(e);if(t===!1){n=!1;break}Array.isArray(t)&&(n=n===!0?t:Hye(n,t))}if(n!==!0){let r,i;if(n===!1)i=e.changes.invertedDesc,r=z$.empty(t.doc.length);else{let t=e.changes.filter(n);r=t.changes,i=t.filtered.mapDesc(t.changes).invertedDesc}e=y1.create(t,r,e.selection&&e.selection.map(i),v1.mapEffects(e.effects,i),e.annotations,e.scrollIntoView)}let r=t.facet(m1);for(let n=r.length-1;n>=0;n--){let i=r[n](e);e=i instanceof y1?i:Array.isArray(i)&&i.length==1&&i[0]instanceof y1?i[0]:S1(t,C1(i),!1)}return e}function Wye(e){let t=e.startState,n=t.facet(h1),r=e;for(let i=n.length-1;i>=0;i--){let a=n[i](e);a&&Object.keys(a).length&&(r=b1(r,x1(t,a,e.changes.newLength),!0))}return r==e?e:y1.create(t,e.changes,e.selection,r.effects,r.annotations,r.scrollIntoView)}var Gye=[];function C1(e){return e==null?Gye:Array.isArray(e)?e:[e]}var w1=(function(e){return e[e.Word=0]=`Word`,e[e.Space=1]=`Space`,e[e.Other=2]=`Other`,e})(w1||={}),Kye=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,T1;try{T1=RegExp(`[\\p{Alphabetic}\\p{Number}_]`,`u`)}catch{}function qye(e){if(T1)return T1.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>`€`&&(n.toUpperCase()!=n.toLowerCase()||Kye.test(n)))return!0}return!1}function Jye(e){return t=>{if(!/\S/.test(t))return w1.Space;if(qye(t))return w1.Word;for(let n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return w1.Word;return w1.Other}}var E1=class e{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++)c1(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 c1(this,n),l1(this,n)}update(...e){return S1(this,e,!0)}applyTransaction(t){let n=this.config,{base:r,compartments:i}=n;for(let e of t.effects)e.is(a1.reconfigure)?(n&&=(i=new Map,n.compartments.forEach((e,t)=>i.set(t,e)),null),i.set(e.value.compartment,e.value.extension)):e.is(v1.reconfigure)?(n=null,r=e.value):e.is(v1.appendConfig)&&(n=null,r=C1(r).concat(e.value));let a;n?a=t.startState.values.slice():(n=s1.resolve(r,i,this),a=new e(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(e,t)=>t.reconfigure(e,this),null).values);let o=t.startState.facet(d1)?t.newSelection:t.newSelection.asSingle();new e(n,t.newDoc,o,a,(e,n)=>n.update(e,t),t)}replaceSelection(e){return typeof e==`string`&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:J.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=C1(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=v1.mapEffects(a,c).concat(v1.mapEffects(C1(o.effects),l))}return{changes:r,selection:J.create(i,t.mainIndex),effects:a}}changes(t=[]){return t instanceof z$?t:z$.of(t,this.doc.length,this.facet(e.lineSeparator))}toText(t){return C$.of(t.split(this.facet(e.lineSeparator)||I$))}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:(c1(this,t),l1(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 e1&&this.config.address[r.id]!=null&&(t[n]=r.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(t,n={},r){if(!t||typeof t.doc!=`string`)throw RangeError(`Invalid JSON representation for EditorState`);let i=[];if(r){for(let e in r)if(Object.prototype.hasOwnProperty.call(t,e)){let n=r[e],a=t[e];i.push(n.init(e=>n.spec.fromJSON(a,e)))}}return e.create({doc:t.doc,selection:J.fromJSON(t.selection),extensions:n.extensions?i.concat([n.extensions]):i})}static create(t={}){let n=s1.resolve(t.extensions||[],new Map),r=t.doc instanceof C$?t.doc:C$.of((t.doc||``).split(n.staticFacet(e.lineSeparator)||I$)),i=t.selection?t.selection instanceof J?t.selection:J.single(t.selection.anchor,t.selection.head):J.single(0);return q$(i,r.length),n.staticFacet(d1)||(i=i.asSingle()),new e(n,r,i,n.dynamicSlots.map(()=>null),(e,t)=>t.create(e),null)}get tabSize(){return this.facet(e.tabSize)}get lineBreak(){return this.facet(e.lineSeparator)||`
744
+ `}get readOnly(){return this.facet(g1)}phrase(t,...n){for(let n of this.facet(e.phrases))if(Object.prototype.hasOwnProperty.call(n,t)){t=n[t];break}return n.length&&(t=t.replace(/\$(\$|\d*)/g,(e,t)=>{if(t==`$`)return`$`;let r=+(t||1);return!r||r>n.length?e:n[r-1]})),t}languageDataAt(e,t,n=-1){let r=[];for(let i of this.facet(u1))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 Jye(t.length?t[0]:``)}wordAt(e){let{text:t,from:n,length:r}=this.doc.lineAt(e),i=this.charCategorizer(e),a=e-n,o=e-n;for(;a>0;){let e=M$(t,a,!1);if(i(t.slice(e,a))!=w1.Word)break;a=e}for(;o<r;){let e=M$(t,o);if(i(t.slice(o,e))!=w1.Word)break;o=e}return a==o?null:J.range(a+n,o+n)}};E1.allowMultipleSelections=d1,E1.tabSize=Y.define({combine:e=>e.length?e[0]:4}),E1.lineSeparator=f1,E1.readOnly=g1,E1.phrases=Y.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])}}),E1.languageData=u1,E1.changeFilter=p1,E1.transactionFilter=m1,E1.transactionExtender=h1,a1.reconfigure=v1.define();function D1(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}var O1=class{eq(e){return this==e}range(e,t=e){return A1.create(e,t,this)}};O1.prototype.startSide=O1.prototype.endSide=0,O1.prototype.point=!1,O1.prototype.mapMode=L$.TrackDel;function k1(e,t){return e==t||e.constructor==t.constructor&&e.eq(t)}var A1=class e{constructor(e,t,n){this.from=e,this.to=t,this.value=n}static create(t,n,r){return new e(t,n,r)}};function j1(e,t){return e.from-t.from||e.value.startSide-t.value.startSide}var Yye=class e{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(t,n){let r=[],i=[],a=[],o=-1,s=-1;for(let e=0;e<this.value.length;e++){let c=this.value[e],l=this.from[e]+t,u=this.to[e]+t,d,f;if(l==u){let e=n.mapPos(l,c.startSide,c.mapMode);if(e==null||(d=f=e,c.startSide!=c.endSide&&(f=n.mapPos(l,c.endSide),f<d)))continue}else if(d=n.mapPos(l,c.startSide),f=n.mapPos(u,c.endSide),d>f||d==f&&c.startSide>0&&c.endSide<=0)continue;(f-d||c.endSide-c.startSide)<0||(o<0&&(o=d),c.point&&(s=Math.max(s,f-d)),r.push(c),i.push(d-o),a.push(f-o))}return{mapped:r.length?new e(i,a,r,s):null,pos:o}}},M1=class e{constructor(e,t,n,r){this.chunkPos=e,this.chunk=t,this.nextLayer=n,this.maxPoint=r}static create(t,n,r,i){return new e(t,n,r,i)}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(t){let{add:n=[],sort:r=!1,filterFrom:i=0,filterTo:a=this.length}=t,o=t.filter;if(n.length==0&&!o)return this;if(r&&(n=n.slice().sort(j1)),this.isEmpty)return n.length?e.of(n):this;let s=new F1(this,null,-1).goto(0),c=0,l=[],u=new N1;for(;s.value||c<n.length;)if(c<n.length&&(s.from-n[c].from||s.startSide-n[c].value.startSide)>=0){let e=n[c++];u.addInner(e.from,e.to,e.value)||l.push(e)}else s.rangeIndex==1&&s.chunkIndex<this.chunk.length&&(c==n.length||this.chunkEnd(s.chunkIndex)<n[c].from)&&(!o||i>this.chunkEnd(s.chunkIndex)||a<this.chunkPos[s.chunkIndex])&&u.addChunk(this.chunkPos[s.chunkIndex],this.chunk[s.chunkIndex])?s.nextChunk():((!o||i>s.to||a<s.from||o(s.from,s.to,s.value))&&(u.addInner(s.from,s.to,s.value)||l.push(A1.create(s.from,s.to,s.value))),s.next());return u.finishInner(this.nextLayer.isEmpty&&!l.length?e.empty:this.nextLayer.update({add:l,filter:o,filterFrom:i,filterTo:a}))}map(t){if(t.empty||this.isEmpty)return this;let n=[],r=[],i=-1;for(let e=0;e<this.chunk.length;e++){let a=this.chunkPos[e],o=this.chunk[e],s=t.touchesRange(a,a+o.length);if(s===!1)i=Math.max(i,o.maxPoint),n.push(o),r.push(t.mapPos(a));else if(s===!0){let{mapped:e,pos:s}=o.map(a,t);e&&(i=Math.max(i,e.maxPoint),n.push(e),r.push(s))}}let a=this.nextLayer.map(t);return n.length==0?a:new e(r,n,a||e.empty,i)}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 I1.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return I1.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=P1(a,o,n),c=new R1(a,s,i),l=new R1(o,s,i);n.iterGaps((e,t,n)=>z1(c,e,l,t,n,r)),n.empty&&n.length==0&&z1(c,0,l,0,0,r)}static eq(e,t,n=0,r){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=P1(i,a),s=new R1(i,o,0).goto(n),c=new R1(a,o,0).goto(n);for(;;){if(s.to!=c.to||!B1(s.active,c.active)||s.point&&(!c.point||!k1(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 R1(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 N1;for(let r of e instanceof A1?[e]:t?Xye(e):e)n.add(r.from,r.to,r.value);return n.finish()}static join(t){if(!t.length)return e.empty;let n=t[t.length-1];for(let r=t.length-2;r>=0;r--)for(let i=t[r];i!=e.empty;i=i.nextLayer)n=new e(i.chunkPos,i.chunk,n,Math.max(i.maxPoint,n.maxPoint));return n}};M1.empty=new M1([],[],null,-1);function Xye(e){if(e.length>1)for(let t=e[0],n=1;n<e.length;n++){let r=e[n];if(j1(t,r)>0)return e.slice().sort(j1);t=r}return e}M1.empty.nextLayer=M1.empty;var N1=class e{finishChunk(e){this.chunks.push(new Yye(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(t,n,r){this.addInner(t,n,r)||(this.nextLayer||=new e).add(t,n,r)}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(M1.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=M1.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}};function P1(e,t,n){let r=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=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?.touchesRange(a,a+e.chunk[t].length)&&i.add(e.chunk[t])}return i}var F1=class{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}},I1=class e{constructor(e){this.heap=e}static from(t,n=null,r=-1){let i=[];for(let e=0;e<t.length;e++)for(let a=t[e];!a.isEmpty;a=a.nextLayer)a.maxPoint>=r&&i.push(new F1(a,n,r,e));return i.length==1?i[0]:new e(i)}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--)L1(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--)L1(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(),L1(this.heap,0)}}};function L1(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}}var R1=class{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=I1.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){V1(this.active,e),V1(this.activeTo,e),V1(this.activeRank,e),this.minActive=U1(this.active,this.activeTo)}addActive(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++;H1(this.active,t,n),H1(this.activeTo,t,r),H1(this.activeRank,t,i),e&&H1(e,t,this.cursor.from),this.minActive=U1(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&&V1(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 z1(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&&k1(e.point,n.point)&&B1(e.activeForPoint(e.to),n.activeForPoint(n.to))||a.comparePoint(s,d,e.point,n.point),t=!1):(t&&a.boundChange(s),d>s&&!B1(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 B1(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n]&&!k1(e[n],t[n]))return!1;return!0}function V1(e,t){for(let n=t,r=e.length-1;n<r;n++)e[n]=e[n+1];e.pop()}function H1(e,t,n){for(let n=e.length-1;n>=t;n--)e[n+1]=e[n];e[t]=n}function U1(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 W1(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=M$(e,i));return r}function Zye(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=M$(e,r)}return r===!0?-1:e.length}for(var G1=`ͼ`,K1=typeof Symbol>`u`?`__ͼ`:Symbol.for(G1),q1=typeof Symbol>`u`?`__styleSet`+Math.floor(Math.random()*1e8):Symbol(`styleSet`),J1=typeof globalThis<`u`?globalThis:typeof window<`u`?window:{},Y1=class{constructor(e,t){this.rules=[];let{finish:n}=t||{};function r(e){return/^@/.test(e)?[e]:e.split(/,\s*/)}function i(e,t,a,o){let s=[],c=/^@(\w+)\b/.exec(e[0]),l=c&&c[1]==`keyframes`;if(c&&t==null)return a.push(e[0]+`;`);for(let n in t){let o=t[n];if(/&/.test(n))i(n.split(/,\s*/).map(t=>e.map(e=>t.replace(/&/,e))).reduce((e,t)=>e.concat(t)),o,a);else if(o&&typeof o==`object`){if(!c)throw RangeError(`The value of a property (`+n+`) should be a primitive value.`);i(r(n),o,s,l)}else o!=null&&s.push(n.replace(/_.*/,``).replace(/[A-Z]/g,e=>`-`+e.toLowerCase())+`: `+o+`;`)}(s.length||l)&&a.push((n&&!c&&!o?e.map(n):e).join(`, `)+` {`+s.join(` `)+`}`)}for(let t in e)i(r(t),e[t],this.rules)}getRules(){return this.rules.join(`
745
+ `)}static newName(){let e=J1[K1]||1;return J1[K1]=e+1,G1+e.toString(36)}static mount(e,t,n){let r=e[q1],i=n&&n.nonce;r?i&&r.setNonce(i):r=new Qye(e,i),r.mount(Array.isArray(t)?t:[t],e)}},X1=new Map,Qye=class{constructor(e,t){let n=e.ownerDocument||e,r=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let t=X1.get(n);if(t)return e[q1]=t;this.sheet=new r.CSSStyleSheet,X1.set(n,this)}else this.styleTag=n.createElement(`style`),t&&this.styleTag.setAttribute(`nonce`,t);this.modules=[],e[q1]=this}mount(e,t){let n=this.sheet,r=0,i=0;for(let t=0;t<e.length;t++){let a=e[t],o=this.modules.indexOf(a);if(o<i&&o>-1&&(this.modules.splice(o,1),i--,o=-1),o==-1){if(this.modules.splice(i++,0,a),n)for(let e=0;e<a.rules.length;e++)n.insertRule(a.rules[e],r++)}else{for(;i<o;)r+=this.modules[i++].rules.length;r+=a.rules.length,i++}}if(n)t.adoptedStyleSheets.indexOf(this.sheet)<0&&(t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets]);else{let e=``;for(let t=0;t<this.modules.length;t++)e+=this.modules[t].getRules()+`
746
+ `;this.styleTag.textContent=e;let n=t.head||t;this.styleTag.parentNode!=n&&n.insertBefore(this.styleTag,n.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute(`nonce`)!=e&&this.styleTag.setAttribute(`nonce`,e)}},Z1={8:`Backspace`,9:`Tab`,10:`Enter`,12:`NumLock`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,44:`PrintScreen`,45:`Insert`,46:`Delete`,59:`;`,61:`=`,91:`Meta`,92:`Meta`,106:`*`,107:`+`,108:`,`,109:`-`,110:`.`,111:`/`,144:`NumLock`,145:`ScrollLock`,160:`Shift`,161:`Shift`,162:`Control`,163:`Control`,164:`Alt`,165:`Alt`,173:`-`,186:`;`,187:`=`,188:`,`,189:`-`,190:`.`,191:`/`,192:"`",219:`[`,220:`\\`,221:`]`,222:`'`},Q1={48:`)`,49:`!`,50:`@`,51:`#`,52:`$`,53:`%`,54:`^`,55:`&`,56:`*`,57:`(`,59:`:`,61:`+`,173:`_`,186:`:`,187:`+`,188:`<`,189:`_`,190:`>`,191:`?`,192:`~`,219:`{`,220:`|`,221:`}`,222:`"`},$ye=typeof navigator<`u`&&/Mac/.test(navigator.platform),ebe=typeof navigator<`u`&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),$1=0;$1<10;$1++)Z1[48+$1]=Z1[96+$1]=String($1);for(var $1=1;$1<=24;$1++)Z1[$1+111]=`F`+$1;for(var $1=65;$1<=90;$1++)Z1[$1]=String.fromCharCode($1+32),Q1[$1]=String.fromCharCode($1);for(var e0 in Z1)Q1.hasOwnProperty(e0)||(Q1[e0]=Z1[e0]);function tbe(e){var t=!($ye&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||ebe&&e.shiftKey&&e.key&&e.key.length==1||e.key==`Unidentified`)&&e.key||(e.shiftKey?Q1:Z1)[e.keyCode]||e.key||`Unidentified`;return t==`Esc`&&(t=`Escape`),t==`Del`&&(t=`Delete`),t==`Left`&&(t=`ArrowLeft`),t==`Up`&&(t=`ArrowUp`),t==`Right`&&(t=`ArrowRight`),t==`Down`&&(t=`ArrowDown`),t}function t0(){var e=arguments[0];typeof e==`string`&&(e=document.createElement(e));var t=1,n=arguments[1];if(n&&typeof n==`object`&&n.nodeType==null&&!Array.isArray(n)){for(var r in n)if(Object.prototype.hasOwnProperty.call(n,r)){var i=n[r];typeof i==`string`?e.setAttribute(r,i):i!=null&&(e[r]=i)}t++}for(;t<arguments.length;t++)n0(e,arguments[t]);return e}function n0(e,t){if(typeof t==`string`)e.appendChild(document.createTextNode(t));else if(t!=null)if(t.nodeType!=null)e.appendChild(t);else if(Array.isArray(t))for(var n=0;n<t.length;n++)n0(e,t[n]);else throw RangeError(`Unsupported child node: `+t)}var r0=typeof navigator<`u`?navigator:{userAgent:``,vendor:``,platform:``},i0=typeof document<`u`?document:{documentElement:{style:{}}},a0=/Edge\/(\d+)/.exec(r0.userAgent),o0=/MSIE \d/.test(r0.userAgent),s0=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(r0.userAgent),c0=!!(o0||s0||a0),l0=!c0&&/gecko\/(\d+)/i.test(r0.userAgent),u0=!c0&&/Chrome\/(\d+)/.exec(r0.userAgent),d0=`webkitFontSmoothing`in i0.documentElement.style,f0=!c0&&/Apple Computer/.test(r0.vendor),p0=f0&&(/Mobile\/\w+/.test(r0.userAgent)||r0.maxTouchPoints>2),X={mac:p0||/Mac/.test(r0.platform),windows:/Win/.test(r0.platform),linux:/Linux|X11/.test(r0.platform),ie:c0,ie_version:o0?i0.documentMode||6:s0?+s0[1]:a0?+a0[1]:0,gecko:l0,gecko_version:l0?+(/Firefox\/(\d+)/.exec(r0.userAgent)||[0,0])[1]:0,chrome:!!u0,chrome_version:u0?+u0[1]:0,ios:p0,android:/Android\b/.test(r0.userAgent),webkit:d0,webkit_version:d0?+(/\bAppleWebKit\/(\d+)/.exec(r0.userAgent)||[0,0])[1]:0,safari:f0,safari_version:f0?+(/\bVersion\/(\d+(\.\d+)?)/.exec(r0.userAgent)||[0,0])[1]:0,tabSize:i0.documentElement.style.tabSize==null?`-moz-tab-size`:`tab-size`};function m0(e,t){for(let n in e)n==`class`&&t.class?t.class+=` `+e.class:n==`style`&&t.style?t.style+=`;`+e.style:t[n]=e[n];return t}var h0=Object.create(null);function g0(e,t,n){if(e==t)return!0;e||=h0,t||=h0;let r=Object.keys(e),i=Object.keys(t);if(r.length-(n&&r.indexOf(n)>-1?1:0)!=i.length-(n&&i.indexOf(n)>-1?1:0))return!1;for(let a of r)if(a!=n&&(i.indexOf(a)==-1||e[a]!==t[a]))return!1;return!0}function nbe(e,t){for(let n=e.attributes.length-1;n>=0;n--){let r=e.attributes[n].name;t[r]??e.removeAttribute(r)}for(let n in t){let r=t[n];n==`style`?e.style.cssText=r:e.getAttribute(n)!=r&&e.setAttribute(n,r)}}function _0(e,t,n){let r=!1;if(t)for(let i in t)n&&i in n||(r=!0,i==`style`?e.style.cssText=``:e.removeAttribute(i));if(n)for(let i in n)t&&t[i]==n[i]||(r=!0,i==`style`?e.style.cssText=n[i]:e.setAttribute(i,n[i]));return r}function rbe(e){let t=Object.create(null);for(let n=0;n<e.attributes.length;n++){let r=e.attributes[n];t[r.name]=r.value}return t}var v0=class{eq(e){return!1}updateDOM(e,t,n){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,n){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}},y0=(function(e){return e[e.Text=0]=`Text`,e[e.WidgetBefore=1]=`WidgetBefore`,e[e.WidgetAfter=2]=`WidgetAfter`,e[e.WidgetRange=3]=`WidgetRange`,e})(y0||={}),b0=class extends O1{constructor(e,t,n,r){super(),this.startSide=e,this.endSide=t,this.widget=n,this.spec=r}get heightRelevant(){return!1}static mark(e){return new x0(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),n=!!e.block;return t+=n&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new C0(e,t,t,n,e.widget||null,!1)}static replace(e){let t=!!e.block,n,r;if(e.isBlockGap)n=-5e8,r=4e8;else{let{start:i,end:a}=w0(e,t);n=(i?t?-3e8:-1:5e8)-1,r=(a?t?2e8:1:-6e8)+1}return new C0(e,n,r,t,e.widget||null,!0)}static line(e){return new S0(e)}static set(e,t=!1){return M1.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};b0.none=M1.empty;var x0=class e extends b0{constructor(e){let{start:t,end:n}=w0(e);super(t?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||`span`,this.attrs=e.class&&e.attributes?m0(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||h0}eq(t){return this==t||t instanceof e&&this.tagName==t.tagName&&g0(this.attrs,t.attrs)}range(e,t=e){if(e>=t)throw RangeError(`Mark decorations may not be empty`);return super.range(e,t)}};x0.prototype.point=!1;var S0=class e extends b0{constructor(e){super(-2e8,-2e8,null,e)}eq(t){return t instanceof e&&this.spec.class==t.spec.class&&g0(this.spec.attributes,t.spec.attributes)}range(e,t=e){if(t!=e)throw RangeError(`Line decoration ranges must be zero-length`);return super.range(e,t)}};S0.prototype.mapMode=L$.TrackBefore,S0.prototype.point=!0;var C0=class e extends b0{constructor(e,t,n,r,i,a){super(t,n,i,e),this.block=r,this.isReplace=a,this.mapMode=r?t<=0?L$.TrackBefore:L$.TrackAfter:L$.TrackDel}get type(){return this.startSide==this.endSide?this.startSide<=0?y0.WidgetBefore:y0.WidgetAfter:y0.WidgetRange}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof e&&ibe(this.widget,t.widget)&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw RangeError(`Invalid range for replacement decoration`);if(!this.isReplace&&t!=e)throw RangeError(`Widget decorations can only have zero-length ranges`);return super.range(e,t)}};C0.prototype.point=!0;function w0(e,t=!1){let{inclusiveStart:n,inclusiveEnd:r}=e;return n??=e.inclusive,r??=e.inclusive,{start:n??t,end:r??t}}function ibe(e,t){return e==t||!!(e&&t&&e.compare(t))}function T0(e,t,n,r=0){let i=n.length-1;i>=0&&n[i]+r>=e?n[i]=Math.max(n[i],t):n.push(e,t)}var E0=class e extends O1{constructor(e,t,n){super(),this.tagName=e,this.attributes=t,this.rank=n}eq(t){return t==this||t instanceof e&&this.tagName==t.tagName&&g0(this.attributes,t.attributes)}static create(t){return new e(t.tagName,t.attributes||h0,t.rank==null?50:Math.max(0,Math.min(t.rank,100)))}static set(e,t=!1){return M1.of(e,t)}};E0.prototype.startSide=E0.prototype.endSide=-1;function D0(e){let t;return t=e.nodeType==11?e.getSelection?e:e.ownerDocument:e,t.getSelection()}function O0(e,t){return t?e==t||e.contains(t.nodeType==1?t:t.parentNode):!1}function k0(e,t){if(!t.anchorNode)return!1;try{return O0(e,t.anchorNode)}catch{return!1}}function A0(e){return e.nodeType==3?V0(e,0,e.nodeValue.length).getClientRects():e.nodeType==1?e.getClientRects():[]}function j0(e,t,n,r){return n?P0(e,t,n,r,-1)||P0(e,t,n,r,1):!1}function M0(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t}function N0(e){return e.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(e.nodeName)}function P0(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:F0(e))){if(e.nodeName==`DIV`)return!1;let n=e.parentNode;if(!n||n.nodeType!=1)return!1;t=M0(e)+(i<0?0:1),e=n}else if(e.nodeType==1){if(e=e.childNodes[t+(i<0?-1:0)],e.nodeType==1&&e.contentEditable==`false`)return!1;t=i<0?F0(e):0}else return!1}}function F0(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function I0(e,t){let n=t?e.left:e.right;return{left:n,right:n,top:e.top,bottom:e.bottom}}function abe(e){let t=e.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.innerWidth,top:0,bottom:e.innerHeight}}function L0(e,t){let n=t.width/e.offsetWidth,r=t.height/e.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(t.width-e.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(t.height-e.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}function obe(e,t,n,r,i,a,o,s){let c=e.ownerDocument,l=c.defaultView||window;for(let u=e,d=!1;u&&!d;)if(u.nodeType==1){let e,f=u==c.body,p=1,m=1;if(f)e=abe(l);else{if(/^(fixed|sticky)$/.test(getComputedStyle(u).position)&&(d=!0),u.scrollHeight<=u.clientHeight&&u.scrollWidth<=u.clientWidth){u=u.assignedSlot||u.parentNode;continue}let t=u.getBoundingClientRect();({scaleX:p,scaleY:m}=L0(u,t)),e={left:t.left,right:t.left+u.clientWidth*p,top:t.top,bottom:t.top+u.clientHeight*m}}let h=0,g=0;if(i==`nearest`)t.top<e.top+o?(g=t.top-(e.top+o),n>0&&t.bottom>e.bottom+g&&(g=t.bottom-e.bottom+o)):t.bottom>e.bottom-o&&(g=t.bottom-e.bottom+o,n<0&&t.top-g<e.top&&(g=t.top-(e.top+o)));else{let r=t.bottom-t.top,a=e.bottom-e.top;g=(i==`center`&&r<=a?t.top+r/2-a/2:i==`start`||i==`center`&&n<0?t.top-o:t.bottom-a+o)-e.top}if(r==`nearest`?t.left<e.left+a?(h=t.left-(e.left+a),n>0&&t.right>e.right+h&&(h=t.right-e.right+a)):t.right>e.right-a&&(h=t.right-e.right+a,n<0&&t.left<e.left+h&&(h=t.left-(e.left+a))):h=(r==`center`?t.left+(t.right-t.left)/2-(e.right-e.left)/2:r==`start`==s?t.left-a:t.right-(e.right-e.left)+a)-e.left,h||g)if(f)l.scrollBy(h,g);else{let e=0,n=0;if(g){let e=u.scrollTop;u.scrollTop+=g/m,n=(u.scrollTop-e)*m}if(h){let t=u.scrollLeft;u.scrollLeft+=h/p,e=(u.scrollLeft-t)*p}t={left:t.left-e,top:t.top-n,right:t.right-e,bottom:t.bottom-n},e&&Math.abs(e-h)<1&&(r=`nearest`),n&&Math.abs(n-g)<1&&(i=`nearest`)}if(f)break;(t.top<e.top||t.bottom>e.bottom||t.left<e.left||t.right>e.right)&&(t={left:Math.max(t.left,e.left),right:Math.min(t.right,e.right),top:Math.max(t.top,e.top),bottom:Math.min(t.bottom,e.bottom)}),u=u.assignedSlot||u.parentNode}else if(u.nodeType==11)u=u.host;else break}function R0(e,t=!0){let n=e.ownerDocument,r=null,i=null;for(let a=e.parentNode;a&&!(a==n.body||(!t||r)&&i);)if(a.nodeType==1)!i&&a.scrollHeight>a.clientHeight&&(i=a),t&&!r&&a.scrollWidth>a.clientWidth&&(r=a),a=a.assignedSlot||a.parentNode;else if(a.nodeType==11)a=a.host;else break;return{x:r,y:i}}var sbe=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:n}=e;this.set(t,Math.min(e.anchorOffset,t?F0(t):0),n,Math.min(e.focusOffset,n?F0(n):0))}set(e,t,n,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=r}},z0=null;X.safari&&X.safari_version>=26&&(z0=!1);function B0(e){if(e.setActive)return e.setActive();if(z0)return e.focus(z0);let t=[];for(let n=e;n&&(t.push(n,n.scrollTop,n.scrollLeft),n!=n.ownerDocument);n=n.parentNode);if(e.focus(z0==null?{get preventScroll(){return z0={preventScroll:!0},!0}}:void 0),!z0){z0=!1;for(let e=0;e<t.length;){let n=t[e++],r=t[e++],i=t[e++];n.scrollTop!=r&&(n.scrollTop=r),n.scrollLeft!=i&&(n.scrollLeft=i)}}}var cbe;function V0(e,t,n=t){let r=cbe||=document.createRange();return r.setEnd(e,n),r.setStart(e,t),r}function H0(e,t,n,r){let i={key:t,code:t,keyCode:n,which:n,cancelable:!0};r&&({altKey:i.altKey,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,metaKey:i.metaKey}=r);let a=new KeyboardEvent(`keydown`,i);a.synthetic=!0,e.dispatchEvent(a);let o=new KeyboardEvent(`keyup`,i);return o.synthetic=!0,e.dispatchEvent(o),a.defaultPrevented||o.defaultPrevented}function lbe(e){for(;e;){if(e&&(e.nodeType==9||e.nodeType==11&&e.host))return e;e=e.assignedSlot||e.parentNode}return null}function ube(e,t){let n=t.focusNode,r=t.focusOffset;if(!n||t.anchorNode!=n||t.anchorOffset!=r)return!1;for(r=Math.min(r,F0(n));;)if(r){if(n.nodeType!=1)return!1;let e=n.childNodes[r-1];e.contentEditable==`false`?r--:(n=e,r=F0(n))}else if(n==e)return!0;else r=M0(n),n=n.parentNode}function U0(e){return e instanceof Window?e.pageYOffset>Math.max(0,e.document.documentElement.scrollHeight-e.innerHeight-4):e.scrollTop>Math.max(1,e.scrollHeight-e.clientHeight-4)}function W0(e,t){for(let n=e,r=t;;)if(n.nodeType==3&&r>0)return{node:n,offset:r};else if(n.nodeType==1&&r>0){if(n.contentEditable==`false`)return null;n=n.childNodes[r-1],r=F0(n)}else if(n.parentNode&&!N0(n))r=M0(n),n=n.parentNode;else return null}function G0(e,t){for(let n=e,r=t;;)if(n.nodeType==3&&r<n.nodeValue.length)return{node:n,offset:r};else if(n.nodeType==1&&r<n.childNodes.length){if(n.contentEditable==`false`)return null;n=n.childNodes[r],r=0}else if(n.parentNode&&!N0(n))r=M0(n)+1,n=n.parentNode;else return null}var K0=class e{constructor(e,t,n=!0){this.node=e,this.offset=t,this.precise=n}static before(t,n){return new e(t.parentNode,M0(t),n)}static after(t,n){return new e(t.parentNode,M0(t)+1,n)}},q0=(function(e){return e[e.LTR=0]=`LTR`,e[e.RTL=1]=`RTL`,e})(q0||={}),J0=q0.LTR,Y0=q0.RTL;function X0(e){let t=[];for(let n=0;n<e.length;n++)t.push(1<<e[n]);return t}var dbe=X0(`88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008`),fbe=X0(`4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333`),Z0=Object.create(null),Q0=[];for(let e of[`()`,`[]`,`{}`]){let t=e.charCodeAt(0),n=e.charCodeAt(1);Z0[t]=n,Z0[n]=-t}function $0(e){return e<=247?dbe[e]:1424<=e&&e<=1524?2:1536<=e&&e<=1785?fbe[e-1536]:1774<=e&&e<=2220?4:8192<=e&&e<=8204?256:64336<=e&&e<=65023?4:1}var pbe=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/,e2=class{get dir(){return this.level%2?Y0:J0}constructor(e,t,n){this.from=e,this.to=t,this.level=n}side(e,t){return this.dir==t==e?this.to:this.from}forward(e,t){return e==(this.dir==t)}static find(e,t,n,r){let i=-1;for(let a=0;a<e.length;a++){let o=e[a];if(o.from<=t&&o.to>=t){if(o.level==n)return a;(i<0||(r==0?e[i].level>o.level:r<0?o.from<t:o.to>t))&&(i=a)}}if(i<0)throw RangeError(`Index out of range`);return i}};function t2(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r.from!=i.from||r.to!=i.to||r.direction!=i.direction||!t2(r.inner,i.inner))return!1}return!0}var n2=[];function mbe(e,t,n,r,i){for(let a=0;a<=r.length;a++){let o=a?r[a-1].to:t,s=a<r.length?r[a].from:n,c=a?256:i;for(let t=o,n=c,r=c;t<s;t++){let i=$0(e.charCodeAt(t));i==512?i=n:i==8&&r==4&&(i=16),n2[t]=i==4?2:i,i&7&&(r=i),n=i}for(let e=o,t=c,r=c;e<s;e++){let i=n2[e];if(i==128)e<s-1&&t==n2[e+1]&&t&24?i=n2[e]=t:n2[e]=256;else if(i==64){let i=e+1;for(;i<s&&n2[i]==64;)i++;let a=e&&t==8||i<n&&n2[i]==8?r==1?1:8:256;for(let t=e;t<i;t++)n2[t]=a;e=i-1}else i==8&&r==1&&(n2[e]=1);t=i,i&7&&(r=i)}}}function hbe(e,t,n,r,i){let a=i==1?2:1;for(let o=0,s=0,c=0;o<=r.length;o++){let l=o?r[o-1].to:t,u=o<r.length?r[o].from:n;for(let t=l,n,r,o;t<u;t++)if(r=Z0[n=e.charCodeAt(t)])if(r<0){for(let e=s-3;e>=0;e-=3)if(Q0[e+1]==-r){let n=Q0[e+2],r=n&2?i:n&4?n&1?a:i:0;r&&(n2[t]=n2[Q0[e]]=r),s=e;break}}else if(Q0.length==189)break;else Q0[s++]=t,Q0[s++]=n,Q0[s++]=c;else if((o=n2[t])==2||o==1){let e=o==i;c=+!e;for(let t=s-3;t>=0;t-=3){let n=Q0[t+2];if(n&2)break;if(e)Q0[t+2]|=2;else{if(n&4)break;Q0[t+2]|=4}}}}}function gbe(e,t,n,r){for(let i=0,a=r;i<=n.length;i++){let o=i?n[i-1].to:e,s=i<n.length?n[i].from:t;for(let c=o;c<s;){let o=n2[c];if(o==256){let o=c+1;for(;;)if(o==s){if(i==n.length)break;o=n[i++].to,s=i<n.length?n[i].from:t}else if(n2[o]==256)o++;else break;let l=a==1,u=l==((o<t?n2[o]:r)==1)?l?1:2:r;for(let t=o,r=i,a=r?n[r-1].to:e;t>c;)t==a&&(t=n[--r].from,a=r?n[r-1].to:e),n2[--t]=u;c=o}else a=o,c++}}}function r2(e,t,n,r,i,a,o){let s=r%2?2:1;if(r%2==i%2)for(let c=t,l=0;c<n;){let t=!0,u=!1;if(l==a.length||c<a[l].from){let e=n2[c];e!=s&&(t=!1,u=e==16)}let d=!t&&s==1?[]:null,f=t?r:r+1,p=c;run:for(;;)if(l<a.length&&p==a[l].from){if(u)break run;let m=a[l];if(!t)for(let e=m.to,t=l+1;;){if(e==n)break run;if(t<a.length&&a[t].from==e)e=a[t++].to;else if(n2[e]==s)break run;else break}l++,d?d.push(m):(m.from>c&&o.push(new e2(c,m.from,f)),i2(e,m.direction==J0==!(f%2)?r:r+1,i,m.inner,m.from,m.to,o),c=m.to),p=m.to}else if(p==n||(t?n2[p]!=s:n2[p]==s))break;else p++;d?r2(e,c,p,r+1,i,d,o):c<p&&o.push(new e2(c,p,f)),c=p}else for(let c=n,l=a.length;c>t;){let n=!0,u=!1;if(!l||c>a[l-1].to){let e=n2[c-1];e!=s&&(n=!1,u=e==16)}let d=!n&&s==1?[]:null,f=n?r:r+1,p=c;run:for(;;)if(l&&p==a[l-1].to){if(u)break run;let m=a[--l];if(!n)for(let e=m.from,n=l;;){if(e==t)break run;if(n&&a[n-1].to==e)e=a[--n].from;else if(n2[e-1]==s)break run;else break}d?d.push(m):(m.to<c&&o.push(new e2(m.to,c,f)),i2(e,m.direction==J0==!(f%2)?r:r+1,i,m.inner,m.from,m.to,o),c=m.from),p=m.from}else if(p==t||(n?n2[p-1]!=s:n2[p-1]==s))break;else p--;d?r2(e,p,c,r+1,i,d,o):p<c&&o.push(new e2(p,c,f)),c=p}}function i2(e,t,n,r,i,a,o){let s=t%2?2:1;mbe(e,i,a,r,s),hbe(e,i,a,r,s),gbe(i,a,r,s),r2(e,i,a,t,n,r,o)}function _be(e,t,n){if(!e)return[new e2(0,0,+(t==Y0))];if(t==J0&&!n.length&&!pbe.test(e))return a2(e.length);if(n.length)for(;e.length>n2.length;)n2[n2.length]=256;let r=[],i=t==J0?0:1;return i2(e,i,i,n,0,e.length,r),r}function a2(e){return[new e2(0,e,0)]}var o2=``;function vbe(e,t,n,r,i){let a=r.head-e.from,o=e2.find(t,a,r.bidiLevel??-1,r.assoc),s=t[o],c=s.side(i,n);if(a==c){let e=o+=i?1:-1;if(e<0||e>=t.length)return null;s=t[o=e],a=s.side(!i,n),c=s.side(i,n)}let l=M$(e.text,a,s.forward(i,n));(l<s.from||l>s.to)&&(l=c),o2=e.text.slice(Math.min(a,l),Math.max(a,l));let u=o==(i?t.length-1:0)?null:t[o+(i?1:-1)];return u&&l==c&&u.level+ +!i<s.level?J.cursor(u.side(!i,n)+e.from,u.forward(i,n)?1:-1,u.level):J.cursor(l+e.from,s.forward(i,n)?-1:1,s.level)}function ybe(e,t,n){for(let r=t;r<n;r++){let t=$0(e.charCodeAt(r));if(t==1)return J0;if(t==2||t==4)return Y0}return J0}var s2=Y.define(),c2=Y.define(),l2=Y.define(),u2=Y.define(),d2=Y.define(),f2=Y.define(),p2=Y.define(),m2=Y.define(),h2=Y.define(),g2=Y.define({combine:e=>e.some(e=>e)}),bbe=Y.define({combine:e=>e.some(e=>e)}),_2=Y.define(),v2=class e{constructor(e,t,n,r,i,a=!1){this.range=e,this.y=t,this.x=n,this.yMargin=r,this.xMargin=i,this.isSnapshot=a}map(t){return t.empty?this:new e(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(t){return this.range.to<=t.doc.length?this:new e(J.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}},y2=v1.define({map:(e,t)=>e.map(t)}),b2=v1.define();function x2(e,t,n){let r=e.facet(u2);r.length?r[0](t):window.onerror&&window.onerror(String(t),n,void 0,void 0,t)||(n?console.error(n+`:`,t):console.error(t))}var S2=Y.define({combine:e=>e.length?e[0]:!0}),xbe=0,C2=Y.define({combine(e){return e.filter((t,n)=>{for(let r=0;r<n;r++)if(e[r].plugin==t.plugin)return!1;return!0})}}),w2=class e{constructor(e,t,n,r,i){this.id=e,this.create=t,this.domEventHandlers=n,this.domEventObservers=r,this.baseExtensions=i(this),this.extension=this.baseExtensions.concat(C2.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(C2.of({plugin:this,arg:e}))}static define(t,n){let{eventHandlers:r,eventObservers:i,provide:a,decorations:o}=n||{};return new e(xbe++,t,r,i,e=>{let t=[];return o&&t.push(O2.of(t=>{let n=t.plugin(e);return n?o(n):b0.none})),a&&t.push(a(e)),t})}static fromClass(t,n){return e.define((e,n)=>new t(e,n),n)}},T2=class{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(!this.value){if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){x2(e.state,t,`CodeMirror plugin crashed`),this.deactivate()}}else if(this.mustUpdate){let e=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(e)}catch(t){if(x2(e.state,t,`CodeMirror plugin crashed`),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}return this}destroy(e){if(this.value?.destroy)try{this.value.destroy()}catch(t){x2(e.state,t,`CodeMirror plugin crashed`)}}deactivate(){this.spec=this.value=null}},E2=Y.define(),D2=Y.define(),O2=Y.define(),k2=Y.define(),A2=Y.define(),j2=Y.define(),M2=Y.define();function N2(e,t){let n=e.state.facet(M2);if(!n.length)return n;let r=n.map(t=>t instanceof Function?t(e):t),i=[];return M1.spans(r,t.from,t.to,{point(){},span(e,n,r,a){let o=e-t.from,s=n-t.from,c=i;for(let e=r.length-1;e>=0;e--,a--){let n=r[e].spec.bidiIsolate,i;if(n??=ybe(t.text,o,s),a>0&&c.length&&(i=c[c.length-1]).to==o&&i.direction==n)i.to=s,c=i.inner;else{let e={from:o,to:s,direction:n,inner:[]};c.push(e),c=e.inner}}}}),i}var P2=Y.define();function F2(e){let t=0,n=0,r=0,i=0;for(let a of e.state.facet(P2)){let o=a(e);o&&(o.left!=null&&(t=Math.max(t,o.left)),o.right!=null&&(n=Math.max(n,o.right)),o.top!=null&&(r=Math.max(r,o.top)),o.bottom!=null&&(i=Math.max(i,o.bottom)))}return{left:t,right:n,top:r,bottom:i}}var I2=Y.define(),L2=class e{constructor(e,t,n,r){this.fromA=e,this.toA=t,this.fromB=n,this.toB=r}join(t){return new e(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}addToSet(e){let t=e.length,n=this;for(;t>0;t--){let r=e[t-1];if(!(r.fromA>n.toA)){if(r.toA<n.fromA)break;n=n.join(r),e.splice(t-1,1)}}return e.splice(t,0,n),e}static extendWithRanges(t,n){if(n.length==0)return t;let r=[];for(let i=0,a=0,o=0;;){let s=i<t.length?t[i].fromB:1e9,c=a<n.length?n[a]:1e9,l=Math.min(s,c);if(l==1e9)break;let u=l+o,d=l,f=u;for(;;)if(a<n.length&&n[a]<=d){let e=n[a+1];a+=2,d=Math.max(d,e);for(let e=i;e<t.length&&t[e].fromB<=d;e++)o=t[e].toA-t[e].toB;f=Math.max(f,e+o)}else if(i<t.length&&t[i].fromB<=d){let e=t[i++];d=Math.max(d,e.toB),f=Math.max(f,e.toA),o=e.toA-e.toB}else break;r.push(new e(u,f,l,d))}return r}},R2=class e{constructor(e,t,n){this.view=e,this.state=t,this.transactions=n,this.flags=0,this.startState=e.state,this.changes=z$.empty(this.startState.doc.length);for(let e of n)this.changes=this.changes.compose(e.changes);let r=[];this.changes.iterChangedRanges((e,t,n,i)=>r.push(new L2(e,t,n,i))),this.changedRanges=r}static create(t,n,r){return new e(t,n,r)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}},Sbe=[],z2=class{constructor(e,t,n=0){this.dom=e,this.length=t,this.flags=n,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return Sbe}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let e=this.domAttrs;e&&nbe(this.dom,e)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:``)+(this.breakAfter?`#`:``)}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,t=this.posAtStart){let n=t;for(let t of this.children){if(t==e)return n;n+=t.length+t.breakAfter}throw RangeError(`Invalid child in posBefore`)}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t){return null}domPosFor(e,t){let n=M0(this.dom),r=this.length?e>0:t>0;return new K0(this.parent.dom,n+ +!!r,e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof H2)return e;return null}static get(e){return e.cmTile}},B2=class extends z2{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let t=this.dom,n=null,r,i=e?.node==t?e:null,a=0;for(let o of this.children){if(o.sync(e),a+=o.length+o.breakAfter,r=n?n.nextSibling:t.firstChild,i&&r!=o.dom&&(i.written=!0),o.dom.parentNode==t)for(;r&&r!=o.dom;)r=V2(r);else t.insertBefore(o.dom,r);n=o.dom}for(r=n?n.nextSibling:t.firstChild,i&&r&&(i.written=!0);r;)r=V2(r);this.length=a}};function V2(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}var H2=class extends B2{constructor(e,t){super(t),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let t=z2.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],n=this,r=0,i=0;;)if(r==n.children.length){if(!t.length)return;n=n.parent,n.breakAfter&&i++,r=t.pop()}else{let a=n.children[r++];if(a instanceof U2)t.push(r),n=a,r=0;else{let t=i+a.length,n=e(a,i);if(n!==void 0)return n;i=t+a.breakAfter}}}resolveBlock(e,t){let n,r=-1,i,a=-1;if(this.blockTiles((o,s)=>{let c=s+o.length;if(e>=s&&e<=c){if(o.isWidget()&&t>=-1&&t<=1){if(o.flags&32)return!0;o.flags&16&&(n=void 0)}(s<e||e==c&&(t<-1?o.length:o.covers(1)))&&(!n||!o.isWidget()&&n.isWidget())&&(n=o,r=e-s),(c>e||e==s&&(t>1?o.length:o.covers(-1)))&&(!i||!o.isWidget()&&i.isWidget())&&(i=o,a=e-s)}}),!n&&!i)throw Error(`No tile at position `+e);return n&&t<0||!i?{tile:n,offset:r}:{tile:i,offset:a}}},U2=class e extends B2{constructor(e,t){super(e),this.wrapper=t}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(t,n){let r=new e(n||document.createElement(t.tagName),t);return n||(r.flags|=4),r}},W2=class e extends B2{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(t,n,r){let i=new e(n||document.createElement(`div`),t);return(!n||!r)&&(i.flags|=4),i}get domAttrs(){return this.attrs}resolveInline(e,t,n){let r=null,i=-1,a=null,o=-1;function s(e,c){for(let l=0,u=0;l<e.children.length&&u<=c;l++){let d=e.children[l],f=u+d.length;f>=c&&(d.isComposite()?s(d,c-u):(!a||a.isHidden&&(t>0||n&&wbe(a,d)))&&(f>c||d.flags&32)?(a=d,o=c-u):(u<c||d.flags&16&&!d.isHidden)&&(r=d,i=c-u)),u=f}}s(this,e);let c=(t<0?r:a)||r||a;return c?{tile:c,offset:c==r?i:o}:null}coordsIn(e,t){let n=this.resolveInline(e,t,!0);return n?n.tile.coordsIn(Math.max(0,n.offset),t):Cbe(this)}domIn(e,t){let n=this.resolveInline(e,t);if(n){let{tile:e,offset:r}=n;if(this.dom.contains(e.dom))return e.isText()?new K0(e.dom,Math.min(e.dom.nodeValue.length,r)):e.domPosFor(r,e.flags&16?1:e.flags&32?-1:t);let i=n.tile.parent,a=!1;for(let e of i.children){if(a)return new K0(e.dom,0);e==n.tile&&(a=!0)}}return new K0(this.dom,0)}};function Cbe(e){let t=e.dom.lastChild;if(!t)return e.dom.getBoundingClientRect();let n=A0(t);return n[n.length-1]||null}function wbe(e,t){let n=e.coordsIn(0,1),r=t.coordsIn(0,1);return n&&r&&r.top<n.bottom}var G2=class e extends B2{constructor(e,t){super(e),this.mark=t}get domAttrs(){return this.mark.attrs}static of(t,n){let r=new e(n||document.createElement(t.tagName),t);return n||(r.flags|=4),r}},K2=class e extends z2{constructor(e,t){super(e,t.length),this.text=t}sync(e){this.flags&2||(super.sync(e),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(e,t){let n=this.dom.nodeValue.length;e>n&&(e=n);let r=e,i=e,a=0;e==0&&t<0||e==n&&t>=0?X.chrome||X.gecko||(e?(r--,a=1):i<n&&(i++,a=-1)):t<0?r--:i<n&&i++;let o=V0(this.dom,r,i).getClientRects();if(!o.length)return null;let s=o[(a?a<0:t>=0)?0:o.length-1];return X.safari&&!a&&s.width==0&&(s=Array.prototype.find.call(o,e=>e.width)||s),a?I0(s,a<0):s||null}static of(t,n){let r=new e(n||document.createTextNode(t),t);return n||(r.flags|=2),r}},q2=class e extends z2{constructor(e,t,n,r){super(e,t,r),this.widget=n}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,t){return this.coordsInWidget(e,t,!1)}coordsInWidget(e,t,n){let r=this.widget.coordsAt(this.dom,e,t);if(r)return r;if(n)return I0(this.dom.getBoundingClientRect(),this.length?e==0:t<=0);{let t=this.dom.getClientRects(),n=null;if(!t.length)return null;let r=this.flags&16?!0:this.flags&32?!1:e>0;for(let i=r?t.length-1:0;n=t[i],!(e>0?i==0:i==t.length-1||n.top<n.bottom);i+=r?-1:1);return I0(n,!r)}}get overrideDOMText(){if(!this.length)return C$.empty;let{root:e}=this;if(!e)return C$.empty;let t=this.posAtStart;return e.view.state.doc.slice(t,t+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(t,n,r,i,a){return a||(a=t.toDOM(n),t.editable||(a.contentEditable=`false`)),new e(a,r,t,i)}},J2=class extends z2{constructor(e){let t=document.createElement(`img`);t.className=`cm-widgetBuffer`,t.setAttribute(`aria-hidden`,`true`),super(t,0,e)}get isHidden(){return!0}get overrideDOMText(){return C$.empty}coordsIn(e){return this.dom.getBoundingClientRect()}},Tbe=class{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,n){let{tile:r,index:i,beforeBreak:a,parents:o}=this;for(;e||t>0;)if(!r.isComposite())if(i==r.length)a=!!r.breakAfter,{tile:r,index:i}=o.pop(),i++;else if(e){let t=Math.min(e,r.length-i);n&&n.skip(r,i,i+t),e-=t,i+=t}else break;else if(a){if(!e)break;n&&n.break(),e--,a=!1}else if(i==r.children.length){if(!e&&!o.length)break;n&&n.leave(r),a=!!r.breakAfter,{tile:r,index:i}=o.pop(),i++}else{let s=r.children[i],c=s.breakAfter;(t>0?s.length<=e:s.length<e)&&(!n||n.skip(s,0,s.length)!==!1||!s.isComposite)?(a=!!c,i++,e-=s.length):(o.push({tile:r,index:i}),r=s,i=0,n&&s.isComposite()&&n.enter(s))}return this.tile=r,this.index=i,this.beforeBreak=a,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}},Ebe=class{constructor(e,t,n,r){this.from=e,this.to=t,this.wrapper=n,this.rank=r}},Dbe=class{constructor(e,t,n){this.cache=e,this.root=t,this.blockWrappers=n,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(e,t,n,r){this.flushBuffer();let i=this.ensureMarks(t,n),a=i.lastChild;if(a&&a.isText()&&!(a.flags&8)&&a.length+e.length<512){this.cache.reused.set(a,2);let t=i.children[i.children.length-1]=new K2(a.dom,a.text+e);t.parent=i}else i.append(r||K2.of(e,this.cache.find(K2)?.dom));this.pos+=e.length,this.afterWidget=null}addComposition(e,t){let n=this.curLine;n.dom!=t.line.dom&&(n.setDOM(this.cache.reused.has(t.line)?Q2(t.line.dom):t.line.dom),this.cache.reused.set(t.line,2));let r=n;for(let e=t.marks.length-1;e>=0;e--){let n=t.marks[e],i=r.lastChild;if(i instanceof G2&&i.mark.eq(n.mark))i.dom!=n.dom&&i.setDOM(Q2(n.dom)),r=i;else{if(this.cache.reused.get(n)){let e=z2.get(n.dom);e&&e.setDOM(Q2(n.dom))}let e=G2.of(n.mark,n.dom);r.append(e),r=e}this.cache.reused.set(n,2)}let i=z2.get(e.text);i&&this.cache.reused.set(i,2);let a=new K2(e.text,e.text.nodeValue);a.flags|=8,this.pos=e.range.toB,r.append(a)}addInlineWidget(e,t,n){let r=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);r||this.flushBuffer();let i=this.ensureMarks(t,n);!r&&!(e.flags&16)&&i.append(this.getBuffer(1)),i.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,n){this.flushBuffer(),this.ensureMarks(t,n).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let t=this.afterWidget||this.lastBlock;t.length+=e,this.pos+=e}addLineStart(e,t){e||=Z2;let n=W2.start(e,t||this.cache.find(W2)?.dom,!!t);this.getBlockPos().append(this.lastBlock=this.curLine=n)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,t){let n=this.curLine;for(let r=e.length-1;r>=0;r--){let i=e[r],a;if(t>0&&(a=n.lastChild)&&a instanceof G2&&a.mark.eq(i))n=a,t--;else{let e=G2.of(i,this.cache.find(G2,e=>e.mark.eq(i))?.dom);n.append(e),n=e,t=0}}return n}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!X2(this.curLine,!1)||e.dom.nodeName!=`BR`&&e.isWidget()&&!(X.ios&&X2(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(e4,0,32)||new q2(e4.toDOM(),0,e4,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to<this.pos&&this.wrappers.splice(e,1);for(let e=this.blockWrappers;e.value&&e.from<=this.pos;e.next())if(e.to>=this.pos){let t=e.rank*102+e.value.rank,n=new Ebe(e.from,e.to,e.value,t),r=this.wrappers.length;for(;r>0&&(this.wrappers[r-1].rank-n.rank||this.wrappers[r-1].to-n.to)<0;)r--;this.wrappers.splice(r,0,n)}this.wrapperPos=this.pos}getBlockPos(){this.updateBlockWrappers();let e=this.root;for(let t of this.wrappers){let n=e.lastChild;if(t.from<this.pos&&n instanceof U2&&n.wrapper.eq(t.wrapper))e=n;else{let n=U2.of(t.wrapper,this.cache.find(U2,e=>e.wrapper.eq(t.wrapper))?.dom);e.append(n),e=n}}return e}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let t=2|(e<0?16:32),n=this.cache.find(J2,void 0,1);return n&&(n.flags=t),n||new J2(t)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}},Obe=class{constructor(e){this.skipCount=0,this.text=``,this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text=``,this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:t,lineBreak:n,done:r}=this.cursor.next(this.skipCount);if(this.skipCount=0,r)throw Error(`Ran out of text content when drawing inline views`);this.text=t;let i=this.textOff=Math.min(e,t.length);return n?null:t.slice(0,i)}let t=Math.min(this.text.length,this.textOff+e),n=this.text.slice(this.textOff,t);return this.textOff=t,n}},Y2=[q2,W2,K2,G2,J2,U2,H2];for(let e=0;e<Y2.length;e++)Y2[e].bucket=e;var kbe=class{constructor(e){this.view=e,this.buckets=Y2.map(()=>[]),this.index=Y2.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,n=this.buckets[t];n.length<6?n.push(e):n[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,n=2){let r=e.bucket,i=this.buckets[r],a=this.index[r];for(let e=i.length-1;e>=0;e--){let o=(e+a)%i.length,s=i[o];if((!t||t(s))&&!this.reused.has(s))return i.splice(o,1),o<a&&this.index[r]--,this.reused.set(s,n),s}return null}findWidget(e,t,n){let r=this.buckets[0];if(r.length)for(let i=0,a=0;;i++){if(i==r.length){if(a)return null;a=1,i=0}let o=r[i];if(!this.reused.has(o)&&(a==0?o.widget.compare(e):o.widget.constructor==e.constructor&&e.updateDOM(o.dom,this.view,o.widget)))return r.splice(i,1),i<this.index[0]&&this.index[0]--,o.widget==e&&o.length==t&&(o.flags&497)==n?(this.reused.set(o,1),o):(this.reused.set(o,2),new q2(o.dom,t,e,o.flags&-498|n))}}reuse(e){return this.reused.set(e,1),e}maybeReuse(e,t=2){if(!this.reused.has(e))return this.reused.set(e,t),e.dom}clear(){for(let e=0;e<this.buckets.length;e++)this.buckets[e].length=this.index[e]=0}},Abe=class{constructor(e,t,n,r,i){this.view=e,this.decorations=r,this.disallowBlockEffectsFor=i,this.openWidget=!1,this.openMarks=0,this.cache=new kbe(e),this.text=new Obe(e.state.doc),this.builder=new Dbe(this.cache,new H2(e,e.contentDOM),M1.iter(n)),this.cache.reused.set(t,2),this.old=new Tbe(t),this.reuseWalker={skip:(e,t,n)=>{if(this.cache.add(e),e.isComposite())return!1},enter:e=>this.cache.add(e),leave:()=>{},break:()=>{}}}run(e,t){let n=t&&this.getCompositionContext(t.text);for(let r=0,i=0,a=0;;){let o=a<e.length?e[a++]:null,s=o?o.fromA:this.old.root.length;if(s>r){let e=s-r;this.preserve(e,!a,!o),r=s,i+=e}if(!o)break;t&&o.fromA<=t.range.fromA&&o.toA>=t.range.toA?(this.forward(o.fromA,t.range.fromA,t.range.fromA<t.range.toA?1:-1),this.emit(i,t.range.fromB),this.cache.clear(),this.builder.addComposition(t,n),this.text.skip(t.range.toB-t.range.fromB),this.forward(t.range.fromA,o.toA),this.emit(t.range.toB,o.toB)):(this.forward(o.fromA,o.toA),this.emit(i,o.toB)),i=o.toB,r=o.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(e,t,n){let r=Nbe(this.old),i=this.openMarks;this.old.advance(e,n?1:-1,{skip:(e,t,n)=>{if(e.isWidget())if(this.openWidget)this.builder.continueWidget(n-t);else{let a=n>0||t<e.length?q2.of(e.widget,this.view,n-t,e.flags&496,this.cache.maybeReuse(e)):this.cache.reuse(e);a.flags&256?(a.flags&=-2,this.builder.addBlockWidget(a)):(this.builder.ensureLine(null),this.builder.addInlineWidget(a,r,i),i=r.length)}else if(e.isText())this.builder.ensureLine(null),!t&&n==e.length&&!this.cache.reused.has(e)?this.builder.addText(e.text,r,i,this.cache.reuse(e)):(this.cache.add(e),this.builder.addText(e.text.slice(t,n),r,i)),i=r.length;else if(e.isLine())e.flags&=-2,this.cache.reused.set(e,1),this.builder.addLine(e);else if(e instanceof J2)this.cache.add(e);else if(e instanceof G2)this.builder.ensureLine(null),this.builder.addMark(e,r,i),this.cache.reused.set(e,1),i=r.length;else return!1;this.openWidget=!1},enter:e=>{e.isLine()?this.builder.addLineStart(e.attrs,this.cache.maybeReuse(e)):(this.cache.add(e),e instanceof G2&&r.unshift(e.mark)),this.openWidget=!1},leave:e=>{e.isLine()?r.length&&=i=0:e instanceof G2&&(r.shift(),i=Math.min(i,r.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let n=null,r=this.builder,i=0,a=M1.spans(this.decorations,e,t,{point:(e,t,a,o,s,c)=>{if(a instanceof C0){if(this.disallowBlockEffectsFor[c]){if(a.block)throw RangeError(`Block decorations may not be specified via plugins`);if(t>this.view.state.doc.lineAt(e).to)throw RangeError(`Decorations that replace line breaks may not be specified via plugins`)}if(i=o.length,s>o.length)r.continueWidget(t-e);else{let i=a.widget||(a.block?$2.block:$2.inline),c=jbe(a),l=this.cache.findWidget(i,t-e,c)||q2.of(i,this.view,t-e,c);a.block?(a.startSide>0&&r.addLineStartIfNotCovered(n),r.addBlockWidget(l)):(r.ensureLine(n),r.addInlineWidget(l,o,s))}n=null}else n=Mbe(n,a);t>e&&this.text.skip(t-e)},span:(e,t,i,a)=>{for(let o=e;o<t;){let s=this.text.next(Math.min(512,t-o));s==null?(r.addLineStartIfNotCovered(n),r.addBreak(),o++):(r.ensureLine(n),r.addText(s,i,o==e?a:i.length),o+=s.length),n=null}}});r.addLineStartIfNotCovered(n),this.openWidget=a>i,this.openMarks=a}forward(e,t,n=1){t-e<=10?this.old.advance(t-e,n,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,n,this.reuseWalker))}getCompositionContext(e){let t=[],n=null;for(let r=e.parentNode;;r=r.parentNode){let e=z2.get(r);if(r==this.view.contentDOM)break;e instanceof G2?t.push(e):e?.isLine()?n=e:e instanceof U2||(r.nodeName==`DIV`&&!n&&r!=this.view.contentDOM?n=new W2(r,Z2):n||t.push(G2.of(new x0({tagName:r.nodeName.toLowerCase(),attributes:rbe(r)}),r)))}return{line:n,marks:t}}};function X2(e,t){let n=e=>{for(let r of e.children)if((t?r.isText():r.length)||n(r))return!0;return!1};return n(e)}function jbe(e){let t=e.isReplace?(e.startSide<0?64:0)|(e.endSide>0?128:0):e.startSide>0?32:16;return e.block&&(t|=256),t}var Z2={class:`cm-line`};function Mbe(e,t){let n=t.spec.attributes,r=t.spec.class;return!n&&!r?e:(e||={class:`cm-line`},n&&m0(n,e),r&&(e.class+=` `+r),e)}function Nbe(e){let t=[];for(let n=e.parents.length;n>1;n--){let r=n==e.parents.length?e.tile:e.parents[n].tile;r instanceof G2&&t.push(r.mark)}return t}function Q2(e){let t=z2.get(e);return t&&t.setDOM(e.cloneNode()),e}var $2=class extends v0{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}};$2.inline=new $2(`span`),$2.block=new $2(`div`);var e4=new class extends v0{toDOM(){return document.createElement(`br`)}get isHidden(){return!0}get editable(){return!0}},t4=class{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=b0.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new H2(e,e.contentDOM),this.updateInner([new L2(0,0,0,e.state.doc.length)],null)}update(e){let t=e.changedRanges;this.minWidth>0&&t.length&&(t.every(({fromA:e,toA:t})=>t<this.minWidthFrom||e>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let n=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(this.domChanged?.newSel?n=this.domChanged.newSel.head:!Hbe(e.changes,this.hasComposition)&&!e.selectionSet&&(n=e.state.selection.main.head));let r=n>-1?Fbe(this.view,e.changes,n):null;if(this.domChanged=null,this.hasComposition){let{from:n,to:r}=this.hasComposition;t=new L2(n,r,e.changes.mapPos(n,-1),e.changes.mapPos(r,1)).addToSet(t.slice())}this.hasComposition=r?{from:r.range.fromB,to:r.range.toB}:null,(X.ie||X.chrome)&&!r&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let i=this.decorations,a=this.blockWrappers;this.updateDeco();let o=Rbe(i,this.decorations,e.changes);o.length&&(t=L2.extendWithRanges(t,o));let s=Bbe(a,this.blockWrappers,e.changes);return s.length&&(t=L2.extendWithRanges(t,s)),r&&!t.some(e=>e.fromA<=r.range.fromA&&e.toA>=r.range.toA)&&(t=r.range.addToSet(t.slice())),this.tile.flags&2&&t.length==0?!1:(this.updateInner(t,r),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:n}=this.view;n.ignore(()=>{if(t||e.length){let n=this.tile,r=new Abe(this.view,n,this.blockWrappers,this.decorations,this.dynamicDecorationMap);t&&z2.get(t.text)&&r.cache.reused.set(z2.get(t.text),2),this.tile=r.run(e,t),n4(n,r.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+`px`,this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+`px`:``;let r=X.chrome||X.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(r),r&&(r.written||n.selectionRange.focusNode!=r.node||!this.tile.dom.contains(r.node))&&(this.forceSelection=!0),this.tile.dom.style.height=``});let r=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let e of this.tile.children)e.isWidget()&&e.widget instanceof i4&&r.push(e.dom);n.updateGaps(r)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let t of e.transactions)for(let e of t.effects)e.is(b2)&&(this.editContextFormatting=e.value)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let{dom:n}=this.tile,r=this.view.root.activeElement,i=r==n,a=!i&&!(this.view.state.facet(S2)||n.tabIndex>-1)&&k0(n,this.view.observer.selectionRange)&&!(r&&n.contains(r));if(!(i||t||a))return;let o=this.forceSelection;this.forceSelection=!1;let s=this.view.state.selection.main,c,l;if(s.empty?l=c=this.inlineDOMNearPos(s.anchor,s.assoc||1):(l=this.inlineDOMNearPos(s.head,s.head==s.from?1:-1),c=this.inlineDOMNearPos(s.anchor,s.anchor==s.from?1:-1)),X.gecko&&s.empty&&!this.hasComposition&&Pbe(c)){let e=document.createTextNode(``);this.view.observer.ignore(()=>c.node.insertBefore(e,c.node.childNodes[c.offset]||null)),c=l=new K0(e,0),o=!0}let u=this.view.observer.selectionRange;(o||!u.focusNode||(!j0(c.node,c.offset,u.anchorNode,u.anchorOffset)||!j0(l.node,l.offset,u.focusNode,u.focusOffset))&&!this.suppressWidgetCursorChange(u,s))&&(this.view.observer.ignore(()=>{X.android&&X.chrome&&n.contains(u.focusNode)&&Vbe(u.focusNode,n)&&(n.blur(),n.focus({preventScroll:!0}));let e=D0(this.view.root);if(e)if(s.empty){if(X.gecko){let e=Ibe(c.node,c.offset);if(e&&e!=3){let t=(e==1?W0:G0)(c.node,c.offset);t&&(c=new K0(t.node,t.offset))}}e.collapse(c.node,c.offset),s.bidiLevel!=null&&e.caretBidiLevel!==void 0&&(e.caretBidiLevel=s.bidiLevel)}else if(e.extend){e.collapse(c.node,c.offset);try{e.extend(l.node,l.offset)}catch{}}else{let t=document.createRange();s.anchor>s.head&&([c,l]=[l,c]),t.setEnd(l.node,l.offset),t.setStart(c.node,c.offset),e.removeAllRanges(),e.addRange(t)}a&&this.view.root.activeElement==n&&(n.blur(),r&&r.focus())}),this.view.observer.setSelectionRange(c,l)),this.impreciseAnchor=c.precise?null:new K0(u.anchorNode,u.anchorOffset),this.impreciseHead=l.precise?null:new K0(u.focusNode,u.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&j0(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,n=D0(e.root),{anchorNode:r,anchorOffset:i}=e.observer.selectionRange;if(!n||!t.empty||!t.assoc||!n.modify)return;let a=this.lineAt(t.head,t.assoc);if(!a)return;let o=a.posAtStart;if(t.head==o||t.head==o+a.length)return;let s=this.coordsAt(t.head,-1),c=this.coordsAt(t.head,1);if(!s||!c||s.bottom>c.top)return;let l=this.domAtPos(t.head+t.assoc,t.assoc);n.collapse(l.node,l.offset),n.modify(`move`,t.assoc<0?`forward`:`backward`,`lineboundary`),e.observer.readSelectionRange();let u=e.observer.selectionRange;e.docView.posFromDOM(u.anchorNode,u.anchorOffset)!=t.from&&n.collapse(r,i)}posFromDOM(e,t){let n=this.tile.nearest(e);if(!n)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let r=n.posAtStart;if(n.isComposite()){let i;if(e==n.dom)i=n.dom.childNodes[t];else{let r=F0(e)==0?0:t==0?-1:1;for(;;){let t=e.parentNode;if(t==n.dom)break;r==0&&t.firstChild!=t.lastChild&&(r=e==t.firstChild?-1:1),e=t}i=r<0?e:e.nextSibling}if(i==n.dom.firstChild)return r;for(;i&&!z2.get(i);)i=i.nextSibling;if(!i)return r+n.length;for(let e=0,t=r;;e++){let r=n.children[e];if(r.dom==i)return t;t+=r.length+r.breakAfter}}else if(n.isText())return e==n.dom?r+t:r+(t?n.length:0);else return r}domAtPos(e,t){let{tile:n,offset:r}=this.tile.resolveBlock(e,t);return n.isWidget()?n.domPosFor(e,t):n.domIn(r,t)}inlineDOMNearPos(e,t){let n,r=-1,i=!1,a,o=-1,s=!1;return this.tile.blockTiles((t,c)=>{if(t.isWidget()){if(t.flags&32&&c>=e)return!0;t.flags&16&&(i=!0)}else{let l=c+t.length;if(c<=e&&(n=t,r=e-c,i=l<e),l>=e&&!a&&(a=t,o=e-c,s=c>e),c>e&&a)return!0}}),!n&&!a?this.domAtPos(e,t):(i&&a?n=null:s&&n&&(a=null),n&&t<0||!a?n.domIn(r,t):a.domIn(o,t))}coordsAt(e,t){let{tile:n,offset:r}=this.tile.resolveBlock(e,t);return n.isWidget()?n.widget instanceof i4?null:n.coordsInWidget(r,t,!0):n.coordsIn(r,t)}lineAt(e,t){let{tile:n}=this.tile.resolveBlock(e,t);return n.isLine()?n:null}coordsForChar(e){let{tile:t,offset:n}=this.tile.resolveBlock(e,1);if(!t.isLine())return null;function r(e,t){if(e.isComposite())for(let n of e.children){if(n.length>=t){let e=r(n,t);if(e)return e}if(t-=n.length,t<0)break}else if(e.isText()&&t<e.length){let n=M$(e.text,t);if(n==t)return null;let r=V0(e.dom,t,n).getClientRects();for(let e=0;e<r.length;e++){let t=r[e];if(e==r.length-1||t.top<t.bottom&&t.left<t.right)return t}}return null}return r(t,n)}measureVisibleLineHeights(e){let t=[],{from:n,to:r}=e,i=this.view.contentDOM.clientWidth,a=i>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,o=-1,s=this.view.textDirection==q0.LTR,c=0,l=(e,u,d)=>{for(let f=0;f<e.children.length&&!(u>r);f++){let r=e.children[f],p=u+r.length,m=r.dom.getBoundingClientRect(),{height:h}=m;if(d&&!f&&(c+=m.top-d.top),r instanceof U2)p>n&&l(r,u,m);else if(u>=n&&(c>0&&t.push(-c),t.push(h+c),c=0,a)){let e=r.dom.lastChild,t=e?A0(e):[];if(t.length){let e=t[t.length-1],n=s?e.right-m.left:m.right-e.left;n>o&&(o=n,this.minWidth=i,this.minWidthFrom=u,this.minWidthTo=p)}}d&&f==e.children.length-1&&(c+=d.bottom-m.bottom),u=p+r.breakAfter}};return l(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return getComputedStyle(t.dom).direction==`rtl`?q0.RTL:q0.LTR}measureTextSize(){let e=this.tile.blockTiles(e=>{if(e.isLine()&&e.children.length&&e.length<=20){let t=0,n;for(let r of e.children){if(!r.isText()||/[^ -~]/.test(r.text))return;let e=A0(r.dom);if(e.length!=1)return;t+=e[0].width,n=e[0].height}if(t)return{lineHeight:e.dom.getBoundingClientRect().height,charWidth:t/e.length,textHeight:n}}});if(e)return e;let t=document.createElement(`div`),n,r,i;return t.className=`cm-line`,t.style.width=`99999px`,t.style.position=`absolute`,t.textContent=`abc def ghi jkl mno pqr stu`,this.view.observer.ignore(()=>{this.tile.dom.appendChild(t);let e=A0(t.firstChild)[0];n=t.getBoundingClientRect().height,r=e&&e.width?e.width/27:7,i=e&&e.height?e.height:n,t.remove()}),{lineHeight:n,charWidth:r,textHeight:i}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let n=0,r=0;;r++){let i=r==t.viewports.length?null:t.viewports[r],a=i?i.from-1:this.view.state.doc.length;if(a>n){let r=(t.lineBlockAt(a).bottom-t.lineBlockAt(n).top)/this.view.scaleY;e.push(b0.replace({widget:new i4(r),block:!0,inclusive:!0,isBlockGap:!0}).range(n,a))}if(!i)break;n=i.to+1}return b0.set(e)}updateDeco(){let e=1,t=this.view.state.facet(O2).map(t=>(this.dynamicDecorationMap[e++]=typeof t==`function`)?t(this.view):t),n=!1,r=this.view.state.facet(A2).map((e,t)=>{let r=typeof e==`function`;return r&&(n=!0),r?e(this.view):e});for(r.length&&(this.dynamicDecorationMap[e++]=n,t.push(M1.join(r))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;this.blockWrappers=this.view.state.facet(k2).map(e=>typeof e==`function`?e(this.view):e)}scrollIntoView(e){if(e.isSnapshot){let t=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=t.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let t of this.view.state.facet(_2))try{if(t(this.view,e.range,e))return!0}catch(e){x2(this.view.state,e,`scroll handler`)}let{range:t}=e,n=this.coordsAt(t.head,t.assoc??(t.empty?0:t.head>t.anchor?-1:1)),r;if(!n)return;!t.empty&&(r=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(n={left:Math.min(n.left,r.left),top:Math.min(n.top,r.top),right:Math.max(n.right,r.right),bottom:Math.max(n.bottom,r.bottom)});let i=F2(this.view),a={left:n.left-i.left,top:n.top-i.top,right:n.right+i.right,bottom:n.bottom+i.bottom},{offsetWidth:o,offsetHeight:s}=this.view.scrollDOM;if(obe(this.view.scrollDOM,a,t.head<t.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,o),-o),Math.max(Math.min(e.yMargin,s),-s),this.view.textDirection==q0.LTR),window.visualViewport&&window.innerHeight-window.visualViewport.height>1&&(n.top>window.pageYOffset+window.visualViewport.offsetTop+window.visualViewport.height||n.bottom<window.pageYOffset+window.visualViewport.offsetTop)){let e=this.view.docView.lineAt(t.head,1);e&&e.dom.scrollIntoView({block:`nearest`})}}lineHasWidget(e){let t=e=>e.isWidget()||e.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){n4(this.tile)}};function n4(e,t){let n=t?.get(e);if(n!=1){n??e.destroy();for(let n of e.children)n4(n,t)}}function Pbe(e){return e.node.nodeType==1&&e.node.firstChild&&(e.offset==0||e.node.childNodes[e.offset-1].contentEditable==`false`)&&(e.offset==e.node.childNodes.length||e.node.childNodes[e.offset].contentEditable==`false`)}function r4(e,t){let n=e.observer.selectionRange;if(!n.focusNode)return null;let r=W0(n.focusNode,n.focusOffset),i=G0(n.focusNode,n.focusOffset),a=r||i;if(i&&r&&i.node!=r.node){let t=z2.get(i.node);if(!t||t.isText()&&t.text!=i.node.nodeValue)a=i;else if(e.docView.lastCompositionAfterCursor){let e=z2.get(r.node);!e||e.isText()&&e.text!=r.node.nodeValue||(a=i)}}if(e.docView.lastCompositionAfterCursor=a!=r,!a)return null;let o=t-a.offset;return{from:o,to:o+a.node.nodeValue.length,node:a.node}}function Fbe(e,t,n){let r=r4(e,n);if(!r)return null;let{node:i,from:a,to:o}=r,s=i.nodeValue;if(/[\n\r]/.test(s)||e.state.doc.sliceString(r.from,r.to)!=s)return null;let c=t.invertedDesc;return{range:new L2(c.mapPos(a),c.mapPos(o),a,o),text:i}}function Ibe(e,t){return e.nodeType==1?(t&&e.childNodes[t-1].contentEditable==`false`?1:0)|(t<e.childNodes.length&&e.childNodes[t].contentEditable==`false`?2:0):0}var Lbe=class{constructor(){this.changes=[]}compareRange(e,t){T0(e,t,this.changes)}comparePoint(e,t){T0(e,t,this.changes)}boundChange(e){T0(e,e,this.changes)}};function Rbe(e,t,n){let r=new Lbe;return M1.compare(e,t,n,r),r.changes}var zbe=class{constructor(){this.changes=[]}compareRange(e,t){T0(e,t,this.changes)}comparePoint(){}boundChange(e){T0(e,e,this.changes)}};function Bbe(e,t,n){let r=new zbe;return M1.compare(e,t,n,r),r.changes}function Vbe(e,t){for(let n=e;n&&n!=t;n=n.assignedSlot||n.parentNode)if(n.nodeType==1&&n.contentEditable==`false`)return!0;return!1}function Hbe(e,t){let n=!1;return t&&e.iterChangedRanges((e,r)=>{e<t.to&&r>t.from&&(n=!0)}),n}var i4=class extends v0{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement(`div`);return e.className=`cm-gap`,this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+`px`,!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}};function Ube(e,t,n=1){let r=e.charCategorizer(t),i=e.doc.lineAt(t),a=t-i.from;if(i.length==0)return J.cursor(t);a==0?n=1:a==i.length&&(n=-1);let o=a,s=a;n<0?o=M$(i.text,a,!1):s=M$(i.text,a);let c=r(i.text.slice(o,s));for(;o>0;){let e=M$(i.text,o,!1);if(r(i.text.slice(e,o))!=c)break;o=e}for(;s<i.length;){let e=M$(i.text,s);if(r(i.text.slice(s,e))!=c)break;s=e}return J.range(o+i.from,s+i.from)}function Wbe(e,t,n,r,i){let a=Math.round((r-t.left)*e.defaultCharacterWidth);if(e.lineWrapping&&n.height>e.defaultLineHeight*1.5){let t=e.viewState.heightOracle.textHeight,r=Math.floor((i-n.top-(e.defaultLineHeight-t)*.5)/t);a+=r*e.viewState.heightOracle.lineLength}let o=e.state.sliceDoc(n.from,n.to);return n.from+Zye(o,a,e.state.tabSize)}function Gbe(e,t,n){let r=e.lineBlockAt(t);if(Array.isArray(r.type)){let e;for(let i of r.type){if(i.from>t)break;if(!(i.to<t)){if(i.from<t&&i.to>t)return i;(!e||i.type==y0.Text&&(e.type!=i.type||(n<0?i.from<t:i.to>t)))&&(e=i)}}return e||r}return r}function Kbe(e,t,n,r){let i=Gbe(e,t.head,t.assoc||-1),a=!r||i.type!=y0.Text||!(e.lineWrapping||i.widgetLineBreaks)?null:e.coordsAtPos(t.assoc<0&&t.head>i.from?t.head-1:t.head);if(a){let t=e.dom.getBoundingClientRect(),r=e.textDirectionAt(i.from),o=e.posAtCoords({x:n==(r==q0.LTR)?t.right-1:t.left+1,y:(a.top+a.bottom)/2});if(o!=null)return J.cursor(o,n?-1:1)}return J.cursor(n?i.to:i.from,n?-1:1)}function a4(e,t,n,r){let i=e.state.doc.lineAt(t.head),a=e.bidiSpans(i),o=e.textDirectionAt(i.from);for(let s=t,c=null;;){let t=vbe(i,a,o,s,n),l=o2;if(!t){if(i.number==(n?e.state.doc.lines:1))return s;l=`
747
+ `,i=e.state.doc.line(i.number+(n?1:-1)),a=e.bidiSpans(i),t=e.visualLineSide(i,!n)}if(!c){if(!r)return t;c=r(l)}else if(!c(l))return s;s=t}}function qbe(e,t,n){let r=e.state.charCategorizer(t),i=r(n);return e=>{let t=r(e);return i==w1.Space&&(i=t),i==t}}function Jbe(e,t,n,r){let i=t.head,a=n?1:-1;if(i==(n?e.state.doc.length:0))return J.cursor(i,t.assoc);let o=t.goalColumn,s,c=e.contentDOM.getBoundingClientRect(),l=e.coordsAtPos(i,t.assoc||((t.empty?n:t.head==t.from)?1:-1)),u=e.documentTop;if(l)o??=l.left-c.left,s=a<0?l.top:l.bottom;else{let t=e.viewState.lineBlockAt(i);o??=Math.min(c.right-c.left,e.defaultCharacterWidth*(i-t.from)),s=(a<0?t.top:t.bottom)+u}let d=c.left+o,f=e.viewState.heightOracle.textHeight>>1,p=r??f;for(let t=0;;t+=f){let r=s+(p+t)*a,i=u4(e,{x:d,y:r},!1,a);if(n?r>c.bottom:r<c.top)return J.cursor(i.pos,i.assoc);let l=e.coordsAtPos(i.pos,i.assoc),u=l?(l.top+l.bottom)/2:0;if(!l||(n?u>s:u<s))return J.cursor(i.pos,i.assoc,void 0,o)}}function o4(e,t,n){for(;;){let r=0;for(let i of e)i.between(t-1,t+1,(e,i,a)=>{if(t>e&&t<i){let a=r||n||(t-e<i-t?-1:1);t=a<0?e:i,r=a}});if(!r)return t}}function s4(e,t){let n=null;for(let r=0;r<t.ranges.length;r++){let i=t.ranges[r],a=null;if(i.empty){let t=o4(e,i.from,0);t!=i.from&&(a=J.cursor(t,-1))}else{let t=o4(e,i.from,-1),n=o4(e,i.to,1);(t!=i.from||n!=i.to)&&(a=J.range(i.from==i.anchor?t:n,i.from==i.head?t:n))}a&&(n||=t.ranges.slice(),n[r]=a)}return n?J.create(n,t.mainIndex):t}function c4(e,t,n){let r=o4(e.state.facet(j2).map(t=>t(e)),n.from,t.head>n.from?-1:1);return r==n.from?n:J.cursor(r,r<n.from?1:-1)}var l4=class{constructor(e,t){this.pos=e,this.assoc=t}};function u4(e,t,n,r){let i=e.contentDOM.getBoundingClientRect(),a=i.top+e.viewState.paddingTop,{x:o,y:s}=t,c=s-a,l;for(;;){if(c<0)return new l4(0,1);if(c>e.viewState.docHeight)return new l4(e.state.doc.length,-1);if(l=e.elementAtHeight(c),r==null)break;if(l.type==y0.Text){if(r<0?l.to<e.viewport.from:l.from>e.viewport.to)break;let t=e.docView.coordsAt(r<0?l.from:l.to,r>0?-1:1);if(t&&(r<0?t.top<=c+a:t.bottom>=c+a))break}let t=e.viewState.heightOracle.textHeight/2;c=r>0?l.bottom+t:l.top-t}if(e.viewport.from>=l.to||e.viewport.to<=l.from){if(n)return null;if(l.type==y0.Text){let t=Wbe(e,i,l,o,s);return new l4(t,t==l.from?1:-1)}}if(l.type!=y0.Text)return c<(l.top+l.bottom)/2?new l4(l.from,1):new l4(l.to,-1);let u=e.docView.lineAt(l.from,2);return(!u||u.length!=l.length)&&(u=e.docView.lineAt(l.from,-2)),new Ybe(e,o,s,e.textDirectionAt(l.from)).scanTile(u,l.from)}var Ybe=class{constructor(e,t,n,r){this.view=e,this.x=t,this.y=n,this.baseDir=r,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to<e)&&(this.line=this.view.state.doc.lineAt(e),this.spans=this.view.bidiSpans(this.line)),this}baseDirAt(e,t){let{line:n,spans:r}=this.bidiSpansAt(e);return r[e2.find(r,e-n.from,-1,t)].level==this.baseDir}dirAt(e,t){let{line:n,spans:r}=this.bidiSpansAt(e);return r[e2.find(r,e-n.from,-1,t)].dir}bidiIn(e,t){let{spans:n,line:r}=this.bidiSpansAt(e);return n.length>1||n.length&&(n[0].level!=this.baseDir||n[0].to+r.from<t)}scan(e,t,n=!1){let r=0,i=e.length-1,a=new Set,o=this.bidiIn(e[0],e[i]),s,c,l=-1,u=1e9,d;search:for(;r<i;){let n=i-r,f=r+i>>1;adjust:if(a.has(f)){let e=r+Math.floor(Math.random()*n);for(let t=0;t<n;t++){if(!a.has(e)){f=e;break adjust}e++,e==i&&(e=r)}break search}a.add(f);let p=t(f);if(p)for(let t=0;t<p.length;t++){let n=p[t],a=0;if(!(n.width==0&&p.length>1)){if(n.bottom<this.y)(!s||s.bottom<n.bottom)&&(s=n),a=1;else if(n.top>this.y)(!c||c.top>n.top)&&(c=n),a=-1;else{let e=n.left>this.x?this.x-n.left:n.right<this.x?this.x-n.right:0,t=Math.abs(e);t<u&&(l=f,u=t,d=n),e&&(a=e<0==(this.baseDir==q0.LTR)?-1:1)}a==-1&&(!o||this.baseDirAt(e[f],1))?i=f:a==1&&(!o||this.baseDirAt(e[f+1],-1))&&(r=f+1)}}}if(!d){let n=s&&(!c||this.y-s.bottom<c.top-this.y)?s:c;return this.y=(n.top+n.bottom)/2,this.scan(e,t,!0)}if(u&&!n){let{top:n,bottom:r}=d;if(s&&s.bottom>(n+n+r)/3)return this.y=s.bottom-1,this.scan(e,t,!0);if(c&&c.top<(n+r+r)/3)return this.y=c.top+1,this.scan(e,t,!0)}let f=(o?this.dirAt(e[l],1):this.baseDir)==q0.LTR;return{i:l,after:this.x>(d.left+d.right)/2==f}}scanText(e,t){let n=[];for(let r=0;r<e.length;r=M$(e.text,r))n.push(t+r);n.push(t+e.length);let r=this.scan(n,r=>{let i=n[r]-t,a=n[r+1]-t;return V0(e.dom,i,a).getClientRects()});return r.after?new l4(n[r.i+1],-1):new l4(n[r.i],1)}scanTile(e,t){if(!e.length)return new l4(t,1);if(e.children.length==1){let n=e.children[0];if(n.isText())return this.scanText(n,t);if(n.isComposite())return this.scanTile(n,t)}let n=[t];for(let r=0,i=t;r<e.children.length;r++)n.push(i+=e.children[r].length);let r=this.scan(n,t=>{let n=e.children[t];return n.flags&48?null:(n.dom.nodeType==1?n.dom:V0(n.dom,0,n.length)).getClientRects()}),i=e.children[r.i],a=n[r.i];return i.isText()?this.scanText(i,a):i.isComposite()?this.scanTile(i,a):r.after?new l4(n[r.i+1],-1):new l4(a,1)}},d4=`￿`,Xbe=class{constructor(e,t){this.points=e,this.view=t,this.text=``,this.lineSeparator=t.state.facet(E1.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=d4}readRange(e,t){if(!e)return this;let n=e.parentNode;for(let r=e;;){this.findPointBefore(n,r);let e=this.text.length;this.readNode(r);let i=z2.get(r),a=r.nextSibling;if(a==t){i?.breakAfter&&!a&&n!=this.view.contentDOM&&this.lineBreak();break}let o=z2.get(a);(i&&o?i.breakAfter:(i?i.breakAfter:N0(r))||N0(a)&&(r.nodeName!=`BR`||i?.isWidget())&&this.text.length>e)&&!Qbe(a,t)&&this.lineBreak(),r=a}return this.findPointBefore(n,t),this}readTextNode(e){let t=e.nodeValue;for(let n of this.points)n.node==e&&(n.pos=this.text.length+Math.min(n.offset,t.length));for(let n=0,r=this.lineSeparator?null:/\r\n?|\n/g;;){let i=-1,a=1,o;if(this.lineSeparator?(i=t.indexOf(this.lineSeparator,n),a=this.lineSeparator.length):(o=r.exec(t))&&(i=o.index,a=o[0].length),this.append(t.slice(n,i<0?t.length:i)),i<0)break;if(this.lineBreak(),a>1)for(let t of this.points)t.node==e&&t.pos>this.text.length&&(t.pos-=a-1);n=i+a}}readNode(e){let t=z2.get(e),n=t&&t.overrideDOMText;if(n!=null){this.findPointInside(e,n.length);for(let e=n.iter();!e.next().done;)e.lineBreak?this.lineBreak():this.append(e.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName==`BR`?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let n of this.points)n.node==e&&e.childNodes[n.offset]==t&&(n.pos=this.text.length)}findPointInside(e,t){for(let n of this.points)(e.nodeType==3?n.node==e:e.contains(n.node))&&(n.pos=this.text.length+(Zbe(e,n.node,n.offset)?t:0))}};function Zbe(e,t,n){for(;;){if(!t||n<F0(t))return!1;if(t==e)return!0;n=M0(t)+1,t=t.parentNode}}function Qbe(e,t){let n;for(;!(e==t||!e);e=e.nextSibling){let t=z2.get(e);if(!t?.isWidget())return!1;t&&(n||=[]).push(t)}if(n){for(let e of n)if(e.overrideDOMText?.length)return!1}return!0}var f4=class{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}},$be=class{constructor(e,t,n,r){this.typeOver=r,this.bounds=null,this.text=``,this.domChanged=t>-1;let{impreciseHead:i,impreciseAnchor:a}=e.docView,o=e.state.selection;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=p4(e.docView.tile,t,n,0))){let t=i||a?[]:txe(e),n=new Xbe(t,e);n.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=n.text,this.newSel=nxe(t,this.bounds.from)}else{let t=e.observer.selectionRange,n=i&&i.node==t.focusNode&&i.offset==t.focusOffset||!O0(e.contentDOM,t.focusNode)?o.main.head:e.docView.posFromDOM(t.focusNode,t.focusOffset),r=a&&a.node==t.anchorNode&&a.offset==t.anchorOffset||!O0(e.contentDOM,t.anchorNode)?o.main.anchor:e.docView.posFromDOM(t.anchorNode,t.anchorOffset),s=e.viewport;if((X.ios||X.chrome)&&o.main.empty&&n!=r&&(s.from>0||s.to<e.state.doc.length)){let t=Math.min(n,r),i=Math.max(n,r),a=s.from-t,o=s.to-i;(a==0||a==1||t==0)&&(o==0||o==-1||i==e.state.doc.length)&&(n=0,r=e.state.doc.length)}if(e.inputState.composing>-1&&o.ranges.length>1)this.newSel=o.replaceRange(J.range(r,n));else if(e.lineWrapping&&r==n&&!(o.main.empty&&o.main.head==n)&&e.inputState.lastTouchTime>Date.now()-100){let t=e.coordsAtPos(n,-1),r=0;t&&(r=e.inputState.lastTouchY<=t.bottom?-1:1),this.newSel=J.create([J.cursor(n,r)])}else this.newSel=J.single(r,n)}}};function p4(e,t,n,r){if(e.isComposite()){let i=-1,a=-1,o=-1,s=-1;for(let c=0,l=r,u=r;c<e.children.length;c++){let r=e.children[c],d=l+r.length;if(l<t&&d>n)return p4(r,t,n,l);if(d>=t&&i==-1&&(i=c,a=l),l>n&&r.dom.parentNode==e.dom){o=c,s=u;break}u=d,l=d+r.breakAfter}return{from:a,to:s<0?r+e.length:s,startDOM:(i?e.children[i-1].dom.nextSibling:null)||e.dom.firstChild,endDOM:o<e.children.length&&o>=0?e.children[o].dom:null}}else if(e.isText())return{from:r,to:r+e.length,startDOM:e.dom,endDOM:e.dom.nextSibling};else return null}function m4(e,t){let n,{newSel:r}=t,{state:i}=e,a=i.selection.main,o=e.inputState.lastKeyTime>Date.now()-100?e.inputState.lastKeyCode:-1;if(t.bounds){let{from:e,to:r}=t.bounds,s=a.from,c=null;(o===8||X.android&&t.text.length<r-e)&&(s=a.to,c=`end`);let l=i.doc.sliceString(e,r,d4),u,d;!a.empty&&a.from>=e&&a.to<=r&&(t.typeOver||l!=t.text)&&l.slice(0,a.from-e)==t.text.slice(0,a.from-e)&&l.slice(a.to-e)==t.text.slice(u=t.text.length-(l.length-(a.to-e)))?n={from:a.from,to:a.to,insert:C$.of(t.text.slice(a.from-e,u).split(d4))}:(d=g4(l,t.text,s-e,c))&&(X.chrome&&o==13&&d.toB==d.from+2&&t.text.slice(d.from,d.toB)==`￿￿`&&d.toB--,n={from:e+d.from,to:e+d.toA,insert:C$.of(t.text.slice(d.from,d.toB).split(d4))})}else r&&(!e.hasFocus&&i.facet(S2)||_4(r,a))&&(r=null);if(!n&&!r)return!1;if((X.mac||X.android)&&n&&n.from==n.to&&n.from==a.head-1&&/^\. ?$/.test(n.insert.toString())&&e.contentDOM.getAttribute(`autocorrect`)==`off`?(r&&n.insert.length==2&&(r=J.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:C$.of([n.insert.toString().replace(`.`,` `)])}):i.doc.lineAt(a.from).to<a.to&&e.docView.lineHasWidget(a.to)&&e.inputState.insertingTextAt>Date.now()-50?n={from:a.from,to:a.to,insert:i.toText(e.inputState.insertingText)}:X.chrome&&n&&n.from==n.to&&n.from==a.head&&n.insert.toString()==`
748
+ `&&e.lineWrapping&&(r&&=J.single(r.main.anchor-1,r.main.head-1),n={from:a.from,to:a.to,insert:C$.of([` `])}),n)return h4(e,n,r,o);if(r&&!_4(r,a)){let t=!1,n=`select`;return e.inputState.lastSelectionTime>Date.now()-50&&(e.inputState.lastSelectionOrigin==`select`&&(t=!0),n=e.inputState.lastSelectionOrigin,n==`select.pointer`&&(r=s4(i.facet(j2).map(t=>t(e)),r))),e.dispatch({selection:r,scrollIntoView:t,userEvent:n}),!0}else return!1}function h4(e,t,n,r=-1){if(X.ios&&e.inputState.flushIOSKey(t))return!0;let i=e.state.selection.main;if(X.android&&(t.to==i.to&&(t.from==i.from||t.from==i.from-1&&e.state.sliceDoc(t.from,i.from)==` `)&&t.insert.length==1&&t.insert.lines==2&&H0(e.contentDOM,`Enter`,13)||(t.from==i.from-1&&t.to==i.to&&t.insert.length==0||r==8&&t.insert.length<t.to-t.from&&t.to>i.head)&&H0(e.contentDOM,`Backspace`,8)||t.from==i.from&&t.to==i.to+1&&t.insert.length==0&&H0(e.contentDOM,`Delete`,46)))return!0;let a=t.insert.toString();e.inputState.composing>=0&&e.inputState.composing++;let o,s=()=>o||=exe(e,t,n);return e.state.facet(f2).some(n=>n(e,t.from,t.to,a,s))||e.dispatch(s()),!0}function exe(e,t,n){let r,i=e.state,a=i.selection.main,o=-1;if(t.from==t.to&&t.from<a.from||t.from>a.to){let n=t.from<a.from?-1:1,r=n<0?a.from:a.to,s=o4(i.facet(j2).map(t=>t(e)),r,n);t.from==s&&(o=s)}if(o>-1)r={changes:t,selection:J.cursor(t.from+t.insert.length,-1)};else if(t.from>=a.from&&t.to<=a.to&&t.to-t.from>=(a.to-a.from)/3&&(!n||n.main.empty&&n.main.from==t.from+t.insert.length)&&e.inputState.composing<0){let n=a.from<t.from?i.sliceDoc(a.from,t.from):``,o=a.to>t.to?i.sliceDoc(t.to,a.to):``;r=i.replaceSelection(e.state.toText(n+t.insert.sliceString(0,void 0,e.state.lineBreak)+o))}else{let o=i.changes(t),s=n&&n.main.to<=o.newLength?n.main:void 0;if(i.selection.ranges.length>1&&(e.inputState.composing>=0||e.inputState.compositionPendingChange)&&t.to<=a.to+10&&t.to>=a.to-10){let c=e.state.sliceDoc(t.from,t.to),l,u=n&&r4(e,n.main.head);if(u){let e=t.insert.length-(t.to-t.from);l={from:u.from,to:u.to-e}}else l=e.state.doc.lineAt(a.head);let d=a.to-t.to;r=i.changeByRange(n=>{if(n.from==a.from&&n.to==a.to)return{changes:o,range:s||n.map(o)};let r=n.to-d,u=r-c.length;if(e.state.sliceDoc(u,r)!=c||r>=l.from&&u<=l.to)return{range:n};let f=i.changes({from:u,to:r,insert:t.insert}),p=n.to-a.to;return{changes:f,range:s?J.range(Math.max(0,s.anchor+p),Math.max(0,s.head+p)):n.map(f)}})}else r={changes:o,selection:s&&i.selection.replaceRange(s)}}let s=`input.type`;return(e.composing||e.inputState.compositionPendingChange&&e.inputState.compositionEndedAt>Date.now()-50)&&(e.inputState.compositionPendingChange=!1,s+=`.compose`,e.inputState.compositionFirstChange&&(s+=`.start`,e.inputState.compositionFirstChange=!1)),i.update(r,{userEvent:s,scrollIntoView:!0})}function g4(e,t,n,r){let i=Math.min(e.length,t.length),a=0;for(;a<i&&e.charCodeAt(a)==t.charCodeAt(a);)a++;if(a==i&&e.length==t.length)return null;let o=e.length,s=t.length;for(;o>0&&s>0&&e.charCodeAt(o-1)==t.charCodeAt(s-1);)o--,s--;if(r==`end`){let e=Math.max(0,a-Math.min(o,s));n-=o+e-a}if(o<a&&e.length<t.length){let e=n<=a&&n>=o?a-n:0;a-=e,s=a+(s-o),o=a}else if(s<a){let e=n<=a&&n>=s?a-n:0;a-=e,o=a+(o-s),s=a}return{from:a,toA:o,toB:s}}function txe(e){let t=[];if(e.root.activeElement!=e.contentDOM)return t;let{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}=e.observer.selectionRange;return n&&(t.push(new f4(n,r)),(i!=n||a!=r)&&t.push(new f4(i,a))),t}function nxe(e,t){if(e.length==0)return null;let n=e[0].pos,r=e.length==2?e[1].pos:n;return n>-1&&r>-1?J.single(n+t,r+t):null}function _4(e,t){return t.head==e.main.head&&t.anchor==e.main.anchor}var rxe=class{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText=``,this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,X.safari&&e.contentDOM.addEventListener(`input`,()=>null),X.gecko&&vxe(e.contentDOM.ownerDocument)}handleEvent(e){!dxe(this.view,e)||this.ignoreDuringComposition(e)||e.type==`keydown`&&this.keydown(e)||(this.view.updateState==0?this.runHandlers(e.type,e):Promise.resolve().then(()=>this.runHandlers(e.type,e)))}runHandlers(e,t){let n=this.handlers[e];if(n){for(let e of n.observers)e(this.view,t);for(let e of n.handlers){if(t.defaultPrevented)break;if(e(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=ixe(e),n=this.handlers,r=this.view.contentDOM;for(let e in t)if(e!=`scroll`){let i=!t[e].handlers.length,a=n[e];a&&i!=!a.handlers.length&&(r.removeEventListener(e,this.handleEvent),a=null),a||r.addEventListener(e,this.handleEvent,{passive:i})}for(let e in n)e!=`scroll`&&!t[e]&&r.removeEventListener(e,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&b4.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),X.android&&X.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return X.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&!e.shiftKey&&((t=y4.find(t=>t.keyCode==e.keyCode))&&!e.ctrlKey||axe.indexOf(e.key)>-1&&e.ctrlKey)?(this.pendingIOSKey=t||e,setTimeout(()=>this.flushIOSKey(),250),!0):(e.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(e){let t=this.pendingIOSKey;return!t||t.key==`Enter`&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString())?!1:(this.pendingIOSKey=void 0,H0(this.view.contentDOM,t.key,t.keyCode,t instanceof KeyboardEvent?t:void 0))}ignoreDuringComposition(e){return!/^key/.test(e.type)||e.synthetic?!1:this.composing>0?!0:X.safari&&!X.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}};function v4(e,t){return(n,r)=>{try{return t.call(e,r,n)}catch(e){x2(n.state,e)}}}function ixe(e){let t=Object.create(null);function n(e){return t[e]||(t[e]={observers:[],handlers:[]})}for(let t of e){let e=t.spec,r=e&&e.plugin.domEventHandlers,i=e&&e.plugin.domEventObservers;if(r)for(let e in r){let i=r[e];i&&n(e).handlers.push(v4(t.value,i))}if(i)for(let e in i){let r=i[e];r&&n(e).observers.push(v4(t.value,r))}}for(let e in C4)n(e).handlers.push(C4[e]);for(let e in w4)n(e).observers.push(w4[e]);return t}var y4=[{key:`Backspace`,keyCode:8,inputType:`deleteContentBackward`},{key:`Enter`,keyCode:13,inputType:`insertParagraph`},{key:`Enter`,keyCode:13,inputType:`insertLineBreak`},{key:`Delete`,keyCode:46,inputType:`deleteContentForward`}],axe=`dthko`,b4=[16,17,18,20,91,92,224,225],x4=6;function S4(e){return Math.max(0,e)*.7+8}function oxe(e,t){return Math.max(Math.abs(e.clientX-t.clientX),Math.abs(e.clientY-t.clientY))}var sxe=class{constructor(e,t,n,r){this.view=e,this.startEvent=t,this.style=n,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=R0(e.contentDOM),this.atoms=e.state.facet(j2).map(t=>t(e));let i=e.contentDOM.ownerDocument;i.addEventListener(`mousemove`,this.move=this.move.bind(this)),i.addEventListener(`mouseup`,this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(E1.allowMultipleSelections)&&cxe(e,t),this.dragging=uxe(e,t)&&M4(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&oxe(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,n=0,r=0,i=0,a=this.view.win.innerWidth,o=this.view.win.innerHeight;this.scrollParents.x&&({left:r,right:a}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:i,bottom:o}=this.scrollParents.y.getBoundingClientRect());let s=F2(this.view);e.clientX-s.left<=r+x4?t=-S4(r-e.clientX):e.clientX+s.right>=a-x4&&(t=S4(e.clientX-a)),e.clientY-s.top<=i+x4?n=-S4(i-e.clientY):e.clientY+s.bottom>=o-x4&&(n=S4(e.clientY-o)),this.setScrollSpeed(t,n)}up(e){this.dragging??this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener(`mousemove`,this.move),e.removeEventListener(`mouseup`,this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:t}=this,n=s4(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!n.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:n,userEvent:`select.pointer`}),this.mustSelect=!1}update(e){e.transactions.some(e=>e.isUserEvent(`input.type`))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}};function cxe(e,t){let n=e.state.facet(s2);return n.length?n[0](t):X.mac?t.metaKey:t.ctrlKey}function lxe(e,t){let n=e.state.facet(c2);return n.length?n[0](t):X.mac?!t.altKey:!t.ctrlKey}function uxe(e,t){let{main:n}=e.state.selection;if(n.empty)return!1;let r=D0(e.root);if(!r||r.rangeCount==0)return!0;let i=r.getRangeAt(0).getClientRects();for(let e=0;e<i.length;e++){let n=i[e];if(n.left<=t.clientX&&n.right>=t.clientX&&n.top<=t.clientY&&n.bottom>=t.clientY)return!0}return!1}function dxe(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target,r;n!=e.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(r=z2.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(t))return!1;return!0}var C4=Object.create(null),w4=Object.create(null),T4=X.ie&&X.ie_version<15||X.ios&&X.webkit_version<604;function fxe(e){let t=e.dom.parentNode;if(!t)return;let n=t.appendChild(document.createElement(`textarea`));n.style.cssText=`position: fixed; left: -10000px; top: 10px`,n.focus(),setTimeout(()=>{e.focus(),n.remove(),D4(e,n.value)},50)}function E4(e,t,n){for(let r of e.facet(t))n=r(n,e);return n}function D4(e,t){t=E4(e.state,m2,t);let{state:n}=e,r,i=1,a=n.toText(t),o=a.lines==n.selection.ranges.length;if(P4!=null&&n.selection.ranges.every(e=>e.empty)&&P4==a.toString()){let e=-1;r=n.changeByRange(r=>{let s=n.doc.lineAt(r.from);if(s.from==e)return{range:r};e=s.from;let c=n.toText((o?a.line(i++).text:t)+n.lineBreak);return{changes:{from:s.from,insert:c},range:J.cursor(r.from+c.length)}})}else r=o?n.changeByRange(e=>{let t=a.line(i++);return{changes:{from:e.from,to:e.to,insert:t.text},range:J.cursor(e.from+t.length)}}):n.replaceSelection(a);e.dispatch(r,{userEvent:`input.paste`,scrollIntoView:!0})}w4.scroll=e=>{e.inputState.lastScrollTop=e.scrollDOM.scrollTop,e.inputState.lastScrollLeft=e.scrollDOM.scrollLeft},w4.wheel=w4.mousewheel=e=>{e.inputState.lastWheelEvent=Date.now()},C4.keydown=(e,t)=>(e.inputState.setSelectionOrigin(`select`),t.keyCode==27&&e.inputState.tabFocusMode!=0&&(e.inputState.tabFocusMode=Date.now()+2e3),!1),w4.touchstart=(e,t)=>{let n=e.inputState,r=t.targetTouches[0];n.lastTouchTime=Date.now(),r&&(n.lastTouchX=r.clientX,n.lastTouchY=r.clientY),n.setSelectionOrigin(`select.pointer`)},w4.touchmove=e=>{e.inputState.setSelectionOrigin(`select.pointer`)},C4.mousedown=(e,t)=>{if(e.observer.flush(),e.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of e.state.facet(l2))if(n=r(e,t),n)break;if(!n&&t.button==0&&(n=mxe(e,t)),n){let r=!e.hasFocus;e.inputState.startMouseSelection(new sxe(e,t,n,r)),r&&e.observer.ignore(()=>{B0(e.contentDOM);let t=e.root.activeElement;t&&!t.contains(e.contentDOM)&&t.blur()});let i=e.inputState.mouseSelection;if(i)return i.start(t),i.dragging===!1}else e.inputState.setSelectionOrigin(`select.pointer`);return!1};function O4(e,t,n,r){if(r==1)return J.cursor(t,n);if(r==2)return Ube(e.state,t,n);{let r=e.docView.lineAt(t,n),i=e.state.doc.lineAt(r?r.posAtEnd:t),a=r?r.posAtStart:i.from,o=r?r.posAtEnd:i.to;return o<e.state.doc.length&&o==i.to&&o++,J.range(a,o)}}var pxe=X.ie&&X.ie_version<=11,k4=null,A4=0,j4=0;function M4(e){if(!pxe)return e.detail;let t=k4,n=j4;return k4=e,j4=Date.now(),A4=!t||n>Date.now()-400&&Math.abs(t.clientX-e.clientX)<2&&Math.abs(t.clientY-e.clientY)<2?(A4+1)%3:1}function mxe(e,t){let n=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),r=M4(t),i=e.state.selection;return{update(e){e.docChanged&&(n.pos=e.changes.mapPos(n.pos),i=i.map(e.changes))},get(t,a,o){let s=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),c,l=O4(e,s.pos,s.assoc,r);if(n.pos!=s.pos&&!a){let t=O4(e,n.pos,n.assoc,r),i=Math.min(t.from,l.from),a=Math.max(t.to,l.to);l=i<l.from?J.range(i,a,l.assoc):J.range(a,i,l.assoc)}return a?i.replaceRange(i.main.extend(l.from,l.to,l.assoc)):o&&r==1&&i.ranges.length>1&&(c=hxe(i,s.pos))?c:o?i.addRange(l):J.create([l])}}}function hxe(e,t){for(let n=0;n<e.ranges.length;n++){let{from:r,to:i}=e.ranges[n];if(r<=t&&i>=t)return J.create(e.ranges.slice(0,n).concat(e.ranges.slice(n+1)),e.mainIndex==n?0:e.mainIndex-+(e.mainIndex>n))}return null}C4.dragstart=(e,t)=>{let{selection:{main:n}}=e.state;if(t.target.draggable){let r=e.docView.tile.nearest(t.target);if(r&&r.isWidget()){let e=r.posAtStart,t=e+r.length;(e>=n.to||t<=n.from)&&(n=J.range(e,t))}}let{inputState:r}=e;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,t.dataTransfer&&(t.dataTransfer.setData(`Text`,E4(e.state,h2,e.state.sliceDoc(n.from,n.to))),t.dataTransfer.effectAllowed=`copyMove`),!1},C4.dragend=e=>(e.inputState.draggedContent=null,!1);function N4(e,t,n,r){if(n=E4(e.state,m2,n),!n)return;let i=e.posAtCoords({x:t.clientX,y:t.clientY},!1),{draggedContent:a}=e.inputState,o=r&&a&&lxe(e,t)?{from:a.from,to:a.to}:null,s={from:i,insert:n},c=e.state.changes(o?[o,s]:s);e.focus(),e.dispatch({changes:c,selection:{anchor:c.mapPos(i,-1),head:c.mapPos(i,1)},userEvent:o?`move.drop`:`input.drop`}),e.inputState.draggedContent=null}C4.drop=(e,t)=>{if(!t.dataTransfer)return!1;if(e.state.readOnly)return!0;let n=t.dataTransfer.files;if(n&&n.length){let r=Array(n.length),i=0,a=()=>{++i==n.length&&N4(e,t,r.filter(e=>e!=null).join(e.state.lineBreak),!1)};for(let e=0;e<n.length;e++){let t=new FileReader;t.onerror=a,t.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(t.result)||(r[e]=t.result),a()},t.readAsText(n[e])}return!0}else{let n=t.dataTransfer.getData(`Text`);if(n)return N4(e,t,n,!0),!0}return!1},C4.paste=(e,t)=>{if(e.state.readOnly)return!0;e.observer.flush();let n=T4?null:t.clipboardData;return n?(D4(e,n.getData(`text/plain`)||n.getData(`text/uri-list`)),!0):(fxe(e),!1)};function gxe(e,t){let n=e.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement(`textarea`));r.style.cssText=`position: fixed; left: -10000px; top: 10px`,r.value=t,r.focus(),r.selectionEnd=t.length,r.selectionStart=0,setTimeout(()=>{r.remove(),e.focus()},50)}function _xe(e){let t=[],n=[],r=!1;for(let r of e.selection.ranges)r.empty||(t.push(e.sliceDoc(r.from,r.to)),n.push(r));if(!t.length){let i=-1;for(let{from:r}of e.selection.ranges){let a=e.doc.lineAt(r);a.number>i&&(t.push(a.text),n.push({from:a.from,to:Math.min(e.doc.length,a.to+1)})),i=a.number}r=!0}return{text:E4(e,h2,t.join(e.lineBreak)),ranges:n,linewise:r}}var P4=null;C4.copy=C4.cut=(e,t)=>{if(!k0(e.contentDOM,e.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:i}=_xe(e.state);if(!n&&!i)return!1;P4=i?n:null,t.type==`cut`&&!e.state.readOnly&&e.dispatch({changes:r,scrollIntoView:!0,userEvent:`delete.cut`});let a=T4?null:t.clipboardData;return a?(a.clearData(),a.setData(`text/plain`,n),!0):(gxe(e,n),!1)};var F4=_1.define();function I4(e,t){let n=[];for(let r of e.facet(p2)){let i=r(e,t);i&&n.push(i)}return n.length?e.update({effects:n,annotations:F4.of(!0)}):null}function L4(e){setTimeout(()=>{let t=e.hasFocus;if(t!=e.inputState.notifiedFocused){let n=I4(e.state,t);n?e.dispatch(n):e.update([])}},10)}w4.focus=e=>{e.inputState.lastFocusTime=Date.now(),!e.scrollDOM.scrollTop&&(e.inputState.lastScrollTop||e.inputState.lastScrollLeft)&&(e.scrollDOM.scrollTop=e.inputState.lastScrollTop,e.scrollDOM.scrollLeft=e.inputState.lastScrollLeft),L4(e)},w4.blur=e=>{e.observer.clearSelectionRange(),L4(e)},w4.compositionstart=w4.compositionupdate=e=>{e.observer.editContext||(e.inputState.compositionFirstChange??(e.inputState.compositionFirstChange=!0),e.inputState.composing<0&&(e.inputState.composing=0))},w4.compositionend=e=>{e.observer.editContext||(e.inputState.composing=-1,e.inputState.compositionEndedAt=Date.now(),e.inputState.compositionPendingKey=!0,e.inputState.compositionPendingChange=e.observer.pendingRecords().length>0,e.inputState.compositionFirstChange=null,X.chrome&&X.android?e.observer.flushSoon():e.inputState.compositionPendingChange?Promise.resolve().then(()=>e.observer.flush()):setTimeout(()=>{e.inputState.composing<0&&e.docView.hasComposition&&e.update([])},50))},w4.contextmenu=e=>{e.inputState.lastContextMenu=Date.now()},C4.beforeinput=(e,t)=>{if((t.inputType==`insertText`||t.inputType==`insertCompositionText`)&&(e.inputState.insertingText=t.data,e.inputState.insertingTextAt=Date.now()),t.inputType==`insertReplacementText`&&e.observer.editContext){let n=t.dataTransfer?.getData(`text/plain`),r=t.getTargetRanges();if(n&&r.length){let t=r[0];return h4(e,{from:e.posAtDOM(t.startContainer,t.startOffset),to:e.posAtDOM(t.endContainer,t.endOffset),insert:e.state.toText(n)},null),!0}}let n;if(X.chrome&&X.android&&(n=y4.find(e=>e.inputType==t.inputType))&&(e.observer.delayAndroidKey(n.key,n.keyCode),n.key==`Backspace`||n.key==`Delete`)){let t=window.visualViewport?.height||0;setTimeout(()=>{(window.visualViewport?.height||0)>t+10&&e.hasFocus&&(e.contentDOM.blur(),e.focus())},100)}return X.ios&&t.inputType==`deleteContentForward`&&e.observer.flushSoon(),X.safari&&t.inputType==`insertText`&&e.inputState.composing>=0&&setTimeout(()=>w4.compositionend(e,t),20),!1};var R4=new Set;function vxe(e){R4.has(e)||(R4.add(e),e.addEventListener(`copy`,()=>{}),e.addEventListener(`cut`,()=>{}))}var z4=[`pre-wrap`,`normal`,`pre-line`,`break-spaces`],B4=!1;function V4(){B4=!1}var yxe=class{constructor(e){this.lineWrapping=e,this.doc=C$.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let n=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(n+=Math.max(0,Math.ceil((t-e-n*this.lineLength*.5)/this.lineLength))),this.lineHeight*n}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return z4.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let n=0;n<e.length;n++){let r=e[n];r<0?n++:this.heightSamples[Math.floor(r*10)]||(t=!0,this.heightSamples[Math.floor(r*10)]=!0)}return t}refresh(e,t,n,r,i,a){let o=z4.indexOf(e)>-1,s=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=o;if(this.lineWrapping=o,this.lineHeight=t,this.charWidth=n,this.textHeight=r,this.lineLength=i,s){this.heightSamples={};for(let e=0;e<a.length;e++){let t=a[e];t<0?e++:this.heightSamples[Math.floor(t*10)]=!0}}return s}},bxe=class{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}},H4=class e{constructor(e,t,n,r,i){this.from=e,this.length=t,this.top=n,this.height=r,this._content=i}get type(){return typeof this._content==`number`?y0.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof C0?this._content.widget:null}get widgetLineBreaks(){return typeof this._content==`number`?this._content:0}join(t){let n=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(t._content)?t._content:[t]);return new e(this.from,this.length+t.length,this.top,this.height+t.height,n)}},U4=(function(e){return e[e.ByPos=0]=`ByPos`,e[e.ByHeight=1]=`ByHeight`,e[e.ByPosNoHeight=2]=`ByPosNoHeight`,e})(U4||={}),W4=.001,G4=class e{constructor(e,t,n=2){this.length=e,this.height=t,this.flags=n}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>W4&&(B4=!0),this.height=e)}replace(t,n,r){return e.of(r)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,n,r){let i=this,a=n.doc;for(let o=r.length-1;o>=0;o--){let{fromA:s,toA:c,fromB:l,toB:u}=r[o],d=i.lineAt(s,U4.ByPosNoHeight,n.setDoc(t),0,0),f=d.to>=c?d:i.lineAt(c,U4.ByPosNoHeight,n,0,0);for(u+=f.to-c,c=f.to;o>0&&d.from<=r[o-1].toA;)s=r[o-1].fromA,l=r[o-1].fromB,o--,s<d.from&&(d=i.lineAt(s,U4.ByPosNoHeight,n,0,0));l+=d.from-s,s=d.from;let p=wxe.build(n.setDoc(a),e,l,u);i=K4(i,i.replace(s,c,p))}return i.updateHeight(n,0)}static empty(){return new J4(0,0,0)}static of(t){if(t.length==1)return t[0];let n=0,r=t.length,i=0,a=0;for(;;)if(n==r)if(i>a*2){let e=t[n-1];e.break?t.splice(--n,1,e.left,null,e.right):t.splice(--n,1,e.left,e.right),r+=1+e.break,i-=e.size}else if(a>i*2){let e=t[r];e.break?t.splice(r,1,e.left,null,e.right):t.splice(r,1,e.left,e.right),r+=2+e.break,a-=e.size}else break;else if(i<a){let e=t[n++];e&&(i+=e.size)}else{let e=t[--r];e&&(a+=e.size)}let o=0;return t[n-1]==null?(o=1,n--):t[n]??(o=1,r++),new Sxe(e.of(t.slice(0,n)),o,e.of(t.slice(r)))}};function K4(e,t){return e==t?e:(e.constructor!=t.constructor&&(B4=!0),t)}G4.prototype.size=1;var xxe=b0.replace({}),q4=class extends G4{constructor(e,t,n){super(e,t),this.deco=n,this.spaceAbove=0}mainBlock(e,t){return new H4(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(e,t,n,r){return this.spaceAbove&&e<n+this.spaceAbove?new H4(r,0,n,this.spaceAbove,xxe):this.mainBlock(n,r)}lineAt(e,t,n,r,i){let a=this.mainBlock(r,i);return this.spaceAbove?this.blockAt(0,n,r,i).join(a):a}forEachLine(e,t,n,r,i,a){e<=i+this.length&&t>=i&&a(this.lineAt(0,U4.ByPos,n,r,i))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more&&this.setMeasuredHeight(r),this.outdated=!1,this}toString(){return`block(${this.length})`}},J4=class e extends q4{constructor(e,t,n){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=n}mainBlock(e,t){return new H4(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(t,n,r){let i=r[0];return r.length==1&&(i instanceof e||i instanceof Y4&&i.flags&4)&&Math.abs(this.length-i.length)<10?(i instanceof Y4?i=new e(i.length,this.height,this.spaceAbove):i.height=this.height,this.outdated||(i.outdated=!1),i):G4.of(r)}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more?this.setMeasuredHeight(r):(n||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:``}${this.widgetHeight?`:`+this.widgetHeight:``})`}},Y4=class e extends G4{constructor(e){super(e,0)}heightMetrics(e,t){let n=e.doc.lineAt(t).number,r=e.doc.lineAt(t+this.length).number,i=r-n+1,a,o=0;if(e.lineWrapping){let t=Math.min(this.height,e.lineHeight*i);a=t/i,this.length>i+1&&(o=(this.height-t)/(this.length-i-1))}else a=this.height/i;return{firstLine:n,lastLine:r,perLine:a,perChar:o}}blockAt(e,t,n,r){let{firstLine:i,lastLine:a,perLine:o,perChar:s}=this.heightMetrics(t,r);if(t.lineWrapping){let i=r+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-n)/this.height))*this.length)),a=t.doc.lineAt(i),c=o+a.length*s,l=Math.max(n,e-c/2);return new H4(a.from,a.length,l,c,0)}else{let r=Math.max(0,Math.min(a-i,Math.floor((e-n)/o))),{from:s,length:c}=t.doc.line(i+r);return new H4(s,c,n+o*r,o,0)}}lineAt(e,t,n,r,i){if(t==U4.ByHeight)return this.blockAt(e,n,r,i);if(t==U4.ByPosNoHeight){let{from:t,to:r}=n.doc.lineAt(e);return new H4(t,r-t,0,0,0)}let{firstLine:a,perLine:o,perChar:s}=this.heightMetrics(n,i),c=n.doc.lineAt(e),l=o+c.length*s,u=c.number-a,d=r+o*u+s*(c.from-i-u);return new H4(c.from,c.length,Math.max(r,Math.min(d,r+this.height-l)),l,0)}forEachLine(e,t,n,r,i,a){e=Math.max(e,i),t=Math.min(t,i+this.length);let{firstLine:o,perLine:s,perChar:c}=this.heightMetrics(n,i);for(let l=e,u=r;l<=t;){let t=n.doc.lineAt(l);if(l==e){let n=t.number-o;u+=s*n+c*(e-i-n)}let r=s+c*t.length;a(new H4(t.from,t.length,u,r,0)),u+=r,l=t.to+1}}replace(t,n,r){let i=this.length-n;if(i>0){let t=r[r.length-1];t instanceof e?r[r.length-1]=new e(t.length+i):r.push(null,new e(i-1))}if(t>0){let n=r[0];n instanceof e?r[0]=new e(t+n.length):r.unshift(new e(t-1),null)}return G4.of(r)}decomposeLeft(t,n){n.push(new e(t-1),null)}decomposeRight(t,n){n.push(null,new e(this.length-t-1))}updateHeight(t,n=0,r=!1,i){let a=n+this.length;if(i&&i.from<=n+this.length&&i.more){let r=[],o=Math.max(n,i.from),s=-1;for(i.from>n&&r.push(new e(i.from-n-1).updateHeight(t,n));o<=a&&i.more;){let e=t.doc.lineAt(o).length;r.length&&r.push(null);let n=i.heights[i.index++],a=0;n<0&&(a=-n,n=i.heights[i.index++]),s==-1?s=n:Math.abs(n-s)>=W4&&(s=-2);let c=new J4(e,n,a);c.outdated=!1,r.push(c),o+=e+1}o<=a&&r.push(null,new e(a-o).updateHeight(t,o));let c=G4.of(r);return(s<0||Math.abs(c.height-this.height)>=W4||Math.abs(s-this.heightMetrics(t,n).perLine)>=W4)&&(B4=!0),K4(this,c)}else (r||this.outdated)&&(this.setHeight(t.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}},Sxe=class extends G4{constructor(e,t,n){super(e.length+t+n.length,e.height+n.height,t|(e.outdated||n.outdated?2:0)),this.left=e,this.right=n,this.size=e.size+n.size}get break(){return this.flags&1}blockAt(e,t,n,r){let i=n+this.left.height;return e<i?this.left.blockAt(e,t,n,r):this.right.blockAt(e,t,i,r+this.left.length+this.break)}lineAt(e,t,n,r,i){let a=r+this.left.height,o=i+this.left.length+this.break,s=t==U4.ByHeight?e<a:e<o,c=s?this.left.lineAt(e,t,n,r,i):this.right.lineAt(e,t,n,a,o);if(this.break||(s?c.to<o:c.from>o))return c;let l=t==U4.ByPosNoHeight?U4.ByPosNoHeight:U4.ByPos;return s?c.join(this.right.lineAt(o,l,n,a,o)):this.left.lineAt(o,l,n,r,i).join(c)}forEachLine(e,t,n,r,i,a){let o=r+this.left.height,s=i+this.left.length+this.break;if(this.break)e<s&&this.left.forEachLine(e,t,n,r,i,a),t>=s&&this.right.forEachLine(e,t,n,o,s,a);else{let c=this.lineAt(s,U4.ByPos,n,r,i);e<c.from&&this.left.forEachLine(e,c.from-1,n,r,i,a),c.to>=e&&c.from<=t&&a(c),t>c.to&&this.right.forEachLine(c.to+1,t,n,o,s,a)}}replace(e,t,n){let r=this.left.length+this.break;if(t<r)return this.balanced(this.left.replace(e,t,n),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-r,t-r,n));let i=[];e>0&&this.decomposeLeft(e,i);let a=i.length;for(let e of n)i.push(e);if(e>0&&X4(i,a-1),t<this.length){let e=i.length;this.decomposeRight(t,i),X4(i,e)}return G4.of(i)}decomposeLeft(e,t){let n=this.left.length;if(e<=n)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(n++,e>=n&&t.push(null)),e>n&&this.right.decomposeLeft(e-n,t)}decomposeRight(e,t){let n=this.left.length,r=n+this.break;if(e>=r)return this.right.decomposeRight(e-r,t);e<n&&this.left.decomposeRight(e,t),this.break&&e<r&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?G4.of(this.break?[e,null,t]:[e,t]):(this.left=K4(this.left,e),this.right=K4(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,n=!1,r){let{left:i,right:a}=this,o=t+i.length+this.break,s=null;return r&&r.from<=t+i.length&&r.more?s=i=i.updateHeight(e,t,n,r):i.updateHeight(e,t,n),r&&r.from<=o+a.length&&r.more?s=a=a.updateHeight(e,o,n,r):a.updateHeight(e,o,n),s?this.balanced(i,a):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?` `:`-`)+this.right}};function X4(e,t){let n,r;e[t]==null&&(n=e[t-1])instanceof Y4&&(r=e[t+1])instanceof Y4&&e.splice(t-1,3,new Y4(n.length+1+r.length))}var Cxe=5,wxe=class e{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let e=Math.min(t,this.lineEnd),n=this.nodes[this.nodes.length-1];n instanceof J4?n.length+=e-this.pos:(e>this.pos||!this.isCovered)&&this.nodes.push(new J4(e-this.pos,-1,0)),this.writtenTo=e,t>e&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,n){if(e<t||n.heightRelevant){let r=n.widget?n.widget.estimatedHeight:0,i=n.widget?n.widget.lineBreaks:0;r<0&&(r=this.oracle.lineHeight);let a=t-e;n.block?this.addBlock(new q4(a,r,n)):(a||i||r>=Cxe)&&this.addLineDeco(r,i,a)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new J4(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let n=new Y4(t-e);return this.oracle.doc.lineAt(e).to==t&&(n.flags|=4),n}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof J4)return e;let t=new J4(0,-1,0);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos+=e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,n){let r=this.ensureLine();r.length+=n,r.collapsed+=n,r.widgetHeight=Math.max(r.widgetHeight,e),r.breaks+=t,this.writtenTo=this.pos+=n}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof J4)&&!this.isCovered?this.nodes.push(new J4(0,-1,0)):(this.writtenTo<this.pos||t==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let n=e;for(let e of this.nodes)e instanceof J4&&e.updateHeight(this.oracle,n),n+=e?e.length:1;return this.nodes}static build(t,n,r,i){let a=new e(r,t);return M1.spans(n,r,i,a,0),a.finish(r)}};function Txe(e,t,n){let r=new Exe;return M1.compare(e,t,n,r,0),r.changes}var Exe=class{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,n,r){(e<t||n&&n.heightRelevant||r&&r.heightRelevant)&&T0(e,t,this.changes,5)}};function Dxe(e,t){let n=e.getBoundingClientRect(),r=e.ownerDocument,i=r.defaultView||window,a=Math.max(0,n.left),o=Math.min(i.innerWidth,n.right),s=Math.max(0,n.top),c=Math.min(i.innerHeight,n.bottom);for(let t=e.parentNode;t&&t!=r.body;)if(t.nodeType==1){let n=t,r=window.getComputedStyle(n);if((n.scrollHeight>n.clientHeight||n.scrollWidth>n.clientWidth)&&r.overflow!=`visible`){let r=n.getBoundingClientRect();a=Math.max(a,r.left),o=Math.min(o,r.right),s=Math.max(s,r.top),c=Math.min(t==e.parentNode?i.innerHeight:c,r.bottom)}t=r.position==`absolute`||r.position==`fixed`?n.offsetParent:n.parentNode}else if(t.nodeType==11)t=t.host;else break;return{left:a-n.left,right:Math.max(a,o)-n.left,top:s-(n.top+t),bottom:Math.max(s,c)-(n.top+t)}}function Oxe(e){let t=e.getBoundingClientRect(),n=e.ownerDocument.defaultView||window;return t.left<n.innerWidth&&t.right>0&&t.top<n.innerHeight&&t.bottom>0}function kxe(e,t){let n=e.getBoundingClientRect();return{left:0,right:n.right-n.left,top:t,bottom:n.bottom-(n.top+t)}}var Z4=class{constructor(e,t,n,r){this.from=e,this.to=t,this.size=n,this.displaySize=r}static same(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r.from!=i.from||r.to!=i.to||r.size!=i.size)return!1}return!0}draw(e,t){return b0.replace({widget:new Axe(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}},Axe=class extends v0{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement(`div`);return this.vertical?e.style.height=this.size+`px`:(e.style.width=this.size+`px`,e.style.height=`2px`,e.style.display=`inline-block`),e}get estimatedHeight(){return this.vertical?this.size:-1}},Q4=class{constructor(e,t){this.view=e,this.state=t,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scaleX=1,this.scaleY=1,this.scrollOffset=0,this.scrolledToBottom=!1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=n3,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=q0.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let n=t.facet(D2).some(e=>typeof e!=`function`&&e.class==`cm-lineWrapping`);this.heightOracle=new yxe(n),this.stateDeco=r3(t),this.heightMap=G4.empty().applyChanges(this.stateDeco,C$.empty,this.heightOracle.setDoc(t.doc),[new L2(0,0,0,t.doc.length)]);for(let e=0;e<2&&(this.viewport=this.getViewport(0,null),this.updateForViewport());e++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=b0.set(this.lineGaps.map(e=>e.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let n=0;n<=1;n++){let r=n?t.head:t.anchor;if(!e.some(({from:e,to:t})=>r>=e&&r<=t)){let{from:t,to:n}=this.lineBlockAt(r);e.push(new $4(t,n))}}return this.viewports=e.sort((e,t)=>e.from-t.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?n3:new Nxe(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(i3(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=r3(this.state);let r=e.changedRanges,i=L2.extendWithRanges(r,Txe(n,this.stateDeco,e?e.changes:z$.empty(this.state.doc.length))),a=this.heightMap.height,o=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);V4(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),i),(this.heightMap.height!=a||B4)&&(e.flags|=2),o?(this.scrollAnchorPos=e.changes.mapPos(o.from,-1),this.scrollAnchorHeight=o.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=a);let s=i.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<s.from||t.range.head>s.to)||!this.viewportIsAppropriate(s))&&(s=this.getViewport(0,t));let c=s.from!=this.viewport.from||s.to!=this.viewport.to;this.viewport=s,e.flags|=this.updateForViewport(),(c||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(bbe)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,t=e.contentDOM,n=window.getComputedStyle(t),r=this.heightOracle,i=n.whiteSpace;this.defaultTextDirection=n.direction==`rtl`?q0.RTL:q0.LTR;let a=this.heightOracle.mustRefreshForWrapping(i)||this.mustMeasureContent===`refresh`,o=t.getBoundingClientRect(),s=a||this.mustMeasureContent||this.contentDOMHeight!=o.height;this.contentDOMHeight=o.height,this.mustMeasureContent=!1;let c=0,l=0;if(o.width&&o.height){let{scaleX:e,scaleY:n}=L0(t,o);(e>.005&&Math.abs(this.scaleX-e)>.005||n>.005&&Math.abs(this.scaleY-n)>.005)&&(this.scaleX=e,this.scaleY=n,c|=16,a=s=!0)}let u=(parseInt(n.paddingTop)||0)*this.scaleY,d=(parseInt(n.paddingBottom)||0)*this.scaleY;(this.paddingTop!=u||this.paddingBottom!=d)&&(this.paddingTop=u,this.paddingBottom=d,c|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(s=!0),this.editorWidth=e.scrollDOM.clientWidth,c|=16);let f=R0(this.view.contentDOM,!1).y;f!=this.scrollParent&&(this.scrollParent=f,this.scrollAnchorHeight=-1,this.scrollOffset=0);let p=this.getScrollOffset();this.scrollOffset!=p&&(this.scrollAnchorHeight=-1,this.scrollOffset=p),this.scrolledToBottom=U0(this.scrollParent||e.win);let m=(this.printing?kxe:Dxe)(t,this.paddingTop),h=m.top-this.pixelViewport.top,g=m.bottom-this.pixelViewport.bottom;this.pixelViewport=m;let _=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(_!=this.inView&&(this.inView=_,_&&(s=!0)),!this.inView&&!this.scrollTarget&&!Oxe(e.dom))return 0;let v=o.width;if((this.contentDOMWidth!=v||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=o.width,this.editorHeight=e.scrollDOM.clientHeight,c|=16),s){let t=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(t)&&(a=!0),a||r.lineWrapping&&Math.abs(v-this.contentDOMWidth)>r.charWidth){let{lineHeight:n,charWidth:o,textHeight:s}=e.docView.measureTextSize();a=n>0&&r.refresh(i,n,o,s,Math.max(5,v/o),t),a&&(e.docView.minWidth=0,c|=16)}h>0&&g>0?l=Math.max(h,g):h<0&&g<0&&(l=Math.min(h,g)),V4();for(let n of this.viewports){let i=n.from==this.viewport.from?t:e.docView.measureVisibleLineHeights(n);this.heightMap=(a?G4.empty().applyChanges(this.stateDeco,C$.empty,this.heightOracle,[new L2(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,a,new bxe(n.from,i))}B4&&(c|=2)}let y=!this.viewportIsAppropriate(this.viewport,l)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return y&&(c&2&&(c|=this.updateScaler()),this.viewport=this.getViewport(l,this.scrollTarget),c|=this.updateForViewport()),(c&2||y)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(a?[]:this.lineGaps,e)),c|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),c}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let n=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),r=this.heightMap,i=this.heightOracle,{visibleTop:a,visibleBottom:o}=this,s=new $4(r.lineAt(a-n*1e3,U4.ByHeight,i,0,0).from,r.lineAt(o+(1-n)*1e3,U4.ByHeight,i,0,0).to);if(t){let{head:e}=t.range;if(e<s.from||e>s.to){let n=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),a=r.lineAt(e,U4.ByPos,i,0,0),o;o=t.y==`center`?(a.top+a.bottom)/2-n/2:t.y==`start`||t.y==`nearest`&&e<s.from?a.top:a.bottom-n,s=new $4(r.lineAt(o-1e3/2,U4.ByHeight,i,0,0).from,r.lineAt(o+n+1e3/2,U4.ByHeight,i,0,0).to)}}return s}mapViewport(e,t){let n=t.mapPos(e.from,-1),r=t.mapPos(e.to,1);return new $4(this.heightMap.lineAt(n,U4.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(r,U4.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},n=0){if(!this.inView)return!0;let{top:r}=this.heightMap.lineAt(e,U4.ByPos,this.heightOracle,0,0),{bottom:i}=this.heightMap.lineAt(t,U4.ByPos,this.heightOracle,0,0),{visibleTop:a,visibleBottom:o}=this;return(e==0||r<=a-Math.max(10,Math.min(-n,250)))&&(t==this.state.doc.length||i>=o+Math.max(10,Math.min(n,250)))&&r>a-2*1e3&&i<o+2*1e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let n=[];for(let r of e)t.touchesRange(r.from,r.to)||n.push(new Z4(t.mapPos(r.from),t.mapPos(r.to),r.size,r.displaySize));return n}ensureLineGaps(e,t){let n=this.heightOracle.lineWrapping,r=n?1e4:2e3,i=r>>1,a=r<<1;if(this.defaultTextDirection!=q0.LTR&&!n)return[];let o=[],s=(r,a,c,l)=>{if(a-r<i)return;let u=this.state.selection.main,d=[u.from];u.empty||d.push(u.to);for(let e of d)if(e>r&&e<a){s(r,e-10,c,l),s(e+10,a,c,l);return}let f=Mxe(e,e=>e.from>=c.from&&e.to<=c.to&&Math.abs(e.from-r)<i&&Math.abs(e.to-a)<i&&!d.some(t=>e.from<t&&e.to>t));if(!f){if(a<c.to&&t&&n&&t.visibleRanges.some(e=>e.from<=a&&e.to>=a)){let e=t.moveToLineBoundary(J.cursor(a),!1,!0).head;e>r&&(a=e)}let e=this.gapSize(c,r,a,l);f=new Z4(r,a,e,n||e<2e6?e:2e6)}o.push(f)},c=t=>{if(t.length<a||t.type!=y0.Text)return;let i=jxe(t.from,t.to,this.stateDeco);if(i.total<a)return;let o=this.scrollTarget?this.scrollTarget.range.head:null,c,l;if(n){let e=r/this.heightOracle.lineLength*this.heightOracle.lineHeight,n,a;if(o!=null){let r=t3(i,o),s=((this.visibleBottom-this.visibleTop)/2+e)/t.height;n=r-s,a=r+s}else n=(this.visibleTop-t.top-e)/t.height,a=(this.visibleBottom-t.top+e)/t.height;c=e3(i,n),l=e3(i,a)}else{let n=i.total*this.heightOracle.charWidth,a=r*this.heightOracle.charWidth,s=0;if(n>2e6)for(let n of e)n.from>=t.from&&n.from<t.to&&n.size!=n.displaySize&&n.from*this.heightOracle.charWidth+s<this.pixelViewport.left&&(s=n.size-n.displaySize);let u=this.pixelViewport.left+s,d=this.pixelViewport.right+s,f,p;if(o!=null){let e=t3(i,o),t=((d-u)/2+a)/n;f=e-t,p=e+t}else f=(u-a)/n,p=(d+a)/n;c=e3(i,f),l=e3(i,p)}c>t.from&&s(t.from,c,t,i),l<t.to&&s(l,t.to,t,i)};for(let e of this.viewportLines)Array.isArray(e.type)?e.type.forEach(c):c(e);return o}gapSize(e,t,n,r){let i=t3(r,n)-t3(r,t);return this.heightOracle.lineWrapping?e.height*i:r.total*this.heightOracle.charWidth*i}updateLineGaps(e){Z4.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=b0.set(e.map(e=>e.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let n=[];M1.spans(t,this.viewport.from,this.viewport.to,{span(e,t){n.push({from:e,to:t})},point(){}},20);let r=0;if(n.length!=this.visibleRanges.length)r=12;else for(let t=0;t<n.length&&!(r&8);t++){let i=this.visibleRanges[t],a=n[t];(i.from!=a.from||i.to!=a.to)&&(r|=4,e&&e.mapPos(i.from,-1)==a.from&&e.mapPos(i.to,1)==a.to||(r|=8))}return this.visibleRanges=n,r}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||i3(this.heightMap.lineAt(e,U4.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||i3(this.heightMap.lineAt(this.scaler.fromDOM(e),U4.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return(this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top)*this.scaleY}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return i3(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}},$4=class{constructor(e,t){this.from=e,this.to=t}};function jxe(e,t,n){let r=[],i=e,a=0;return M1.spans(n,e,t,{span(){},point(e,t){e>i&&(r.push({from:i,to:e}),a+=e-i),i=t}},20),i<t&&(r.push({from:i,to:t}),a+=t-i),{total:a,ranges:r}}function e3({total:e,ranges:t},n){if(n<=0)return t[0].from;if(n>=1)return t[t.length-1].to;let r=Math.floor(e*n);for(let e=0;;e++){let{from:n,to:i}=t[e],a=i-n;if(r<=a)return n+r;r-=a}}function t3(e,t){let n=0;for(let{from:r,to:i}of e.ranges){if(t<=i){n+=t-r;break}n+=i-r}return n/e.total}function Mxe(e,t){for(let n of e)if(t(n))return n}var n3={toDOM(e){return e},fromDOM(e){return e},scale:1,eq(e){return e==this}};function r3(e){let t=e.facet(O2).filter(e=>typeof e!=`function`),n=e.facet(A2).filter(e=>typeof e!=`function`);return n.length&&t.push(M1.join(n)),t}var Nxe=class e{constructor(e,t,n){let r=0,i=0,a=0;this.viewports=n.map(({from:n,to:i})=>{let a=t.lineAt(n,U4.ByPos,e,0,0).top,o=t.lineAt(i,U4.ByPos,e,0,0).bottom;return r+=o-a,{from:n,to:i,top:a,bottom:o,domTop:0,domBottom:0}}),this.scale=(7e6-r)/(t.height-r);for(let e of this.viewports)e.domTop=a+(e.top-i)*this.scale,a=e.domBottom=e.domTop+(e.bottom-e.top),i=e.bottom}toDOM(e){for(let t=0,n=0,r=0;;t++){let i=t<this.viewports.length?this.viewports[t]:null;if(!i||e<i.top)return r+(e-n)*this.scale;if(e<=i.bottom)return i.domTop+(e-i.top);n=i.bottom,r=i.domBottom}}fromDOM(e){for(let t=0,n=0,r=0;;t++){let i=t<this.viewports.length?this.viewports[t]:null;if(!i||e<i.domTop)return n+(e-r)/this.scale;if(e<=i.domBottom)return i.top+(e-i.domTop);n=i.bottom,r=i.domBottom}}eq(t){return t instanceof e?this.scale==t.scale&&this.viewports.length==t.viewports.length&&this.viewports.every((e,n)=>e.from==t.viewports[n].from&&e.to==t.viewports[n].to):!1}};function i3(e,t){if(t.scale==1)return e;let n=t.toDOM(e.top),r=t.toDOM(e.bottom);return new H4(e.from,e.length,n,r-n,Array.isArray(e._content)?e._content.map(e=>i3(e,t)):e._content)}var a3=Y.define({combine:e=>e.join(` `)}),o3=Y.define({combine:e=>e.indexOf(!0)>-1}),s3=Y1.newName(),c3=Y1.newName(),l3=Y1.newName(),u3={"&light":`.`+c3,"&dark":`.`+l3};function d3(e,t,n){return new Y1(t,{finish(t){return/&/.test(t)?t.replace(/&\w*/,t=>{if(t==`&`)return e;if(!n||!n[t])throw RangeError(`Unsupported selector: ${t}`);return n[t]}):e+` `+t}})}var Pxe=d3(`.`+s3,{"&":{position:`relative !important`,boxSizing:`border-box`,"&.cm-focused":{outline:`1px dotted #212121`},display:`flex !important`,flexDirection:`column`},".cm-scroller":{display:`flex !important`,alignItems:`flex-start !important`,fontFamily:`monospace`,lineHeight:1.4,height:`100%`,overflowX:`auto`,position:`relative`,zIndex:0,overflowAnchor:`none`},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:`block`,whiteSpace:`pre`,wordWrap:`normal`,boxSizing:`border-box`,minHeight:`100%`,padding:`4px 0`,outline:`none`,"&[contenteditable=true]":{WebkitUserModify:`read-write-plaintext-only`}},".cm-lineWrapping":{whiteSpace_fallback:`pre-wrap`,whiteSpace:`break-spaces`,wordBreak:`break-word`,overflowWrap:`anywhere`,flexShrink:1},"&light .cm-content":{caretColor:`black`},"&dark .cm-content":{caretColor:`white`},".cm-line":{display:`block`,padding:`0 2px 0 6px`},".cm-layer":{position:`absolute`,left:0,top:0,contain:`size style`,"& > *":{position:`absolute`}},"&light .cm-selectionBackground":{background:`#d9d9d9`},"&dark .cm-selectionBackground":{background:`#222`},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:`#d7d4f0`},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:`#233`},".cm-cursorLayer":{pointerEvents:`none`},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:`steps(1) cm-blink 1.2s infinite`},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:`1.2px solid black`,marginLeft:`-0.6px`,pointerEvents:`none`},".cm-cursor":{display:`none`},"&dark .cm-cursor":{borderLeftColor:`#ddd`},".cm-selectionHandle":{backgroundColor:`currentColor`,width:`1.5px`},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:`""`,backgroundColor:`inherit`,borderRadius:`50%`,width:`8px`,height:`8px`,position:`absolute`,left:`-3.25px`},".cm-selectionHandle-start::before":{top:`-8px`},".cm-selectionHandle-end::before":{bottom:`-8px`},".cm-dropCursor":{position:`absolute`},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:`block`},".cm-iso":{unicodeBidi:`isolate`},".cm-announced":{position:`fixed`,top:`-10000px`},"@media print":{".cm-announced":{display:`none`}},"&light .cm-activeLine":{backgroundColor:`#cceeff44`},"&dark .cm-activeLine":{backgroundColor:`#99eeff33`},"&light .cm-specialChar":{color:`red`},"&dark .cm-specialChar":{color:`#f78`},".cm-gutters":{flexShrink:0,display:`flex`,height:`100%`,boxSizing:`border-box`,zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:`#f5f5f5`,color:`#6c6c6c`,border:`0px solid #ddd`,"&.cm-gutters-before":{borderRightWidth:`1px`},"&.cm-gutters-after":{borderLeftWidth:`1px`}},"&dark .cm-gutters":{backgroundColor:`#333338`,color:`#ccc`},".cm-gutter":{display:`flex !important`,flexDirection:`column`,flexShrink:0,boxSizing:`border-box`,minHeight:`100%`,overflow:`hidden`},".cm-gutterElement":{boxSizing:`border-box`},".cm-lineNumbers .cm-gutterElement":{padding:`0 3px 0 5px`,minWidth:`20px`,textAlign:`right`,whiteSpace:`nowrap`},"&light .cm-activeLineGutter":{backgroundColor:`#e2f2ff`},"&dark .cm-activeLineGutter":{backgroundColor:`#222227`},".cm-panels":{boxSizing:`border-box`,position:`sticky`,left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:`#f5f5f5`,color:`black`},"&light .cm-panels-top":{borderBottom:`1px solid #ddd`},"&light .cm-panels-bottom":{borderTop:`1px solid #ddd`},"&dark .cm-panels":{backgroundColor:`#333338`,color:`white`},".cm-dialog":{padding:`2px 19px 4px 6px`,position:`relative`,"& label":{fontSize:`80%`}},".cm-dialog-close":{position:`absolute`,top:`3px`,right:`4px`,backgroundColor:`inherit`,border:`none`,font:`inherit`,fontSize:`14px`,padding:`0`},".cm-tab":{display:`inline-block`,overflow:`hidden`,verticalAlign:`bottom`},".cm-widgetBuffer":{verticalAlign:`text-top`,height:`1em`,width:0,display:`inline`},".cm-placeholder":{color:`#888`,display:`inline-block`,verticalAlign:`top`,userSelect:`none`},".cm-highlightSpace":{backgroundImage:`radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)`,backgroundPosition:`center`},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:`auto 100%`,backgroundPosition:`right 90%`,backgroundRepeat:`no-repeat`},".cm-trailingSpace":{backgroundColor:`#ff332255`},".cm-button":{verticalAlign:`middle`,color:`inherit`,fontSize:`70%`,padding:`.2em 1em`,borderRadius:`1px`},"&light .cm-button":{backgroundImage:`linear-gradient(#eff1f5, #d9d9df)`,border:`1px solid #888`,"&:active":{backgroundImage:`linear-gradient(#b4b4b4, #d0d3d6)`}},"&dark .cm-button":{backgroundImage:`linear-gradient(#393939, #111)`,border:`1px solid #888`,"&:active":{backgroundImage:`linear-gradient(#111, #333)`}},".cm-textfield":{verticalAlign:`middle`,color:`inherit`,fontSize:`70%`,border:`1px solid silver`,padding:`.2em .5em`},"&light .cm-textfield":{backgroundColor:`white`},"&dark .cm-textfield":{border:`1px solid #555`,backgroundColor:`inherit`}},u3),Fxe={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},f3=X.ie&&X.ie_version<=11,Ixe=class{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new sbe,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let e of t)this.queue.push(e);(X.ie&&X.ie_version<=11||X.ios&&e.composing)&&t.some(e=>e.type==`childList`&&e.removedNodes.length||e.type==`characterData`&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&X.android&&e.constructor.EDIT_CONTEXT!==!1&&!(X.chrome&&X.chrome_version<126)&&(this.editContext=new Rxe(e),e.state.facet(S2)&&(e.contentDOM.editContext=this.editContext.editContext)),f3&&(this.onCharData=e=>{this.queue.push({target:e.target,type:`characterData`,oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia(`print`)),typeof ResizeObserver==`function`&&(this.resizeScroll=new ResizeObserver(()=>{this.view.docView?.lastUpdate<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver==`function`&&(this.intersection=new IntersectionObserver(e=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),e.length>0&&e[e.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent(`Event`)))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(e=>{e.length>0&&e[e.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent(`Event`))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers(`scroll`,e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type==`change`||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,n)=>t!=e[n]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:n}=this,r=this.selectionRange;if(n.state.facet(S2)?n.root.activeElement!=this.dom:!k0(this.dom,r))return;let i=r.anchorNode&&n.docView.tile.nearest(r.anchorNode);if(i&&i.isWidget()&&i.widget.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(X.ie&&X.ie_version<=11||X.android&&X.chrome)&&!n.state.selection.main.empty&&r.focusNode&&j0(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=D0(e.root);if(!t)return!1;let n=X.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&Lxe(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;let r=k0(this.dom,n);return r&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&ube(this.dom,n)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(n),r&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let n=this.dom;n;)if(n.nodeType==1)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==n?e++:t||=this.scrollTargets.slice(0,e),t&&t.push(n),n=n.assignedSlot||n.parentNode;else if(n.nodeType==11)n=n.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let e of this.scrollTargets)e.removeEventListener(`scroll`,this.onScroll);for(let e of this.scrollTargets=t)e.addEventListener(`scroll`,this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||=(this.observer.observe(this.dom,Fxe),f3&&this.dom.addEventListener(`DOMCharacterDataModified`,this.onCharData),!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),f3&&this.dom.removeEventListener(`DOMCharacterDataModified`,this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){if(!this.delayedAndroidKey){let e=()=>{let e=this.delayedAndroidKey;e&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=e.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&e.force&&H0(this.dom,e.key,e.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(e)}(!this.delayedAndroidKey||e==`Enter`)&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!this.delayedAndroidKey?.force})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,n=-1,r=!1;for(let i of e){let e=this.readMutation(i);e&&(e.typeOver&&(r=!0),t==-1?{from:t,to:n}=e:(t=Math.min(e.from,t),n=Math.max(e.to,n)))}return{from:t,to:n,typeOver:r}}readChange(){let{from:e,to:t,typeOver:n}=this.processRecords(),r=this.selectionChanged&&k0(this.dom,this.selectionRange);if(e<0&&!r)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let i=new $be(this.view,e,t,n);return this.view.docView.domChanged={newSel:i.newSel?i.newSel.main:null},i}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let n=this.view.state,r=m4(this.view,t);return this.view.state==n&&(t.domChanged||t.newSel&&!_4(this.view.state.selection,t.newSel.main))&&this.view.update([]),r}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty(e.type==`attributes`),e.type==`childList`){let n=p3(t,e.previousSibling||e.target.previousSibling,-1),r=p3(t,e.nextSibling||e.target.nextSibling,1);return{from:n?t.posAfter(n):t.posAtStart,to:r?t.posBefore(r):t.posAtEnd,typeOver:!1}}else if(e.type==`characterData`)return{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue};else return null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener(`resize`,this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener(`change`,this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener(`beforeprint`,this.onPrint),e.addEventListener(`scroll`,this.onScroll),e.document.addEventListener(`selectionchange`,this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener(`scroll`,this.onScroll),e.removeEventListener(`resize`,this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener(`change`,this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener(`beforeprint`,this.onPrint),e.document.removeEventListener(`selectionchange`,this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(S2)!=e.state.facet(S2)&&(e.view.contentDOM.editContext=e.state.facet(S2)?this.editContext.editContext:null))}destroy(){var e,t,n;this.stop(),(e=this.intersection)==null||e.disconnect(),(t=this.gapIntersection)==null||t.disconnect(),(n=this.resizeScroll)==null||n.disconnect();for(let e of this.scrollTargets)e.removeEventListener(`scroll`,this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}};function p3(e,t,n){for(;t;){let r=z2.get(t);if(r&&r.parent==e)return r;let i=t.parentNode;t=i==e.dom?n>0?t.nextSibling:t.previousSibling:i}return null}function m3(e,t){let n=t.startContainer,r=t.startOffset,i=t.endContainer,a=t.endOffset,o=e.docView.domAtPos(e.state.selection.main.anchor,1);return j0(o.node,o.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function Lxe(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return m3(e,n)}let n=null;function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.contentDOM.addEventListener(`beforeinput`,r,!0),e.dom.ownerDocument.execCommand(`indent`),e.contentDOM.removeEventListener(`beforeinput`,r,!0),n?m3(e,n):null}var Rxe=class{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=n=>{let r=e.state.selection.main,{anchor:i,head:a}=r,o=this.toEditorPos(n.updateRangeStart),s=this.toEditorPos(n.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:n.updateRangeStart,editorBase:o,drifted:!1});let c=s-o>n.text.length;o==this.from&&i<this.from?o=i:s==this.to&&i>this.to&&(s=i);let l=g4(e.state.sliceDoc(o,s),n.text,(c?r.from:r.to)-o,c?`end`:null);if(!l){let t=J.single(this.toEditorPos(n.selectionStart),this.toEditorPos(n.selectionEnd));_4(t,r)||e.dispatch({selection:t,userEvent:`select`});return}let u={from:l.from+o,to:l.toA+o,insert:C$.of(n.text.slice(l.from,l.toB).split(`
749
+ `))};if((X.mac||X.android)&&u.from==a-1&&/^\. ?$/.test(n.text)&&e.contentDOM.getAttribute(`autocorrect`)==`off`&&(u={from:o,to:s,insert:C$.of([n.text.replace(`.`,` `)])}),this.pendingContextChange=u,!e.state.readOnly){let t=this.to-this.from+(u.to-u.from+u.insert.length);h4(e,u,J.single(this.toEditorPos(n.selectionStart,t),this.toEditorPos(n.selectionEnd,t)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),u.from<u.to&&!u.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,n.updateRangeStart-1),Math.min(t.text.length,n.updateRangeStart+1)))&&this.handlers.compositionend(n)},this.handlers.characterboundsupdate=n=>{let r=[],i=null;for(let t=this.toEditorPos(n.rangeStart),a=this.toEditorPos(n.rangeEnd);t<a;t++){let n=e.coordsForChar(t);i=n&&new DOMRect(n.left,n.top,n.right-n.left,n.bottom-n.top)||i||new DOMRect,r.push(i)}t.updateCharacterBounds(n.rangeStart,r)},this.handlers.textformatupdate=t=>{let n=[];for(let e of t.getTextFormats()){let t=e.underlineStyle,r=e.underlineThickness;if(!/none/i.test(t)&&!/none/i.test(r)){let i=this.toEditorPos(e.rangeStart),a=this.toEditorPos(e.rangeEnd);if(i<a){let e=`text-decoration: underline ${/^[a-z]/.test(t)?t+` `:t==`Dashed`?`dashed `:t==`Squiggle`?`wavy `:``}${/thin/i.test(r)?1:2}px`;n.push(b0.mark({attributes:{style:e}}).range(i,a))}}}e.dispatch({effects:b2.of(b0.set(n))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:t}=this.composing;this.composing=null,t&&this.reset(e.state)}};for(let e in this.handlers)t.addEventListener(e,this.handlers[e]);this.measureReq={read:e=>{this.editContext.updateControlBounds(e.contentDOM.getBoundingClientRect());let t=D0(e.root);t&&t.rangeCount&&this.editContext.updateSelectionBounds(t.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,n=!1,r=this.pendingContextChange;return e.changes.iterChanges((i,a,o,s,c)=>{if(n)return;let l=c.length-(a-i);if(r&&a>=r.to)if(r.from==i&&r.to==a&&r.insert.eq(c)){r=this.pendingContextChange=null,t+=l,this.to+=l;return}else r=null,this.revertPending(e.state);if(i+=t,a+=t,a<=this.from)this.from+=l,this.to+=l;else if(i<this.to){if(i<this.from||a>this.to||this.to-this.from+c.length>3e4){n=!0;return}this.editContext.updateText(this.toContextPos(i),this.toContextPos(a),c.toString()),this.to+=l}t+=l}),r&&!n&&this.revertPending(e.state),!n}update(e){let t=this.pendingContextChange,n=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(n.from,n.to)&&e.transactions.some(e=>!e.isUserEvent(`input.type`)&&e.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,n=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),r=this.toContextPos(t.head);(this.editContext.selectionStart!=n||this.editContext.selectionEnd!=r)&&this.editContext.updateSelection(n,r)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>1e4*3)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let n=this.composing;return n&&n.drifted?n.editorBase+(e-n.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}},Z=class e{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement(`div`),this.scrollDOM=document.createElement(`div`),this.scrollDOM.tabIndex=-1,this.scrollDOM.className=`cm-scroller`,this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement(`div`),this.announceDOM.className=`cm-announced`,this.announceDOM.setAttribute(`aria-live`,`polite`),this.dom=document.createElement(`div`),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:t}=e;this.dispatchTransactions=e.dispatchTransactions||t&&(e=>e.forEach(e=>t(e,this)))||(e=>this.update(e)),this.dispatch=this.dispatch.bind(this),this._root=e.root||lbe(e.parent)||document,this.viewState=new Q4(this,e.state||E1.create(e)),e.scrollTo&&e.scrollTo.is(y2)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(C2).map(e=>new T2(e));for(let e of this.plugins)e.update(this);this.observer=new Ixe(this),this.inputState=new rxe(this),this.inputState.ensureHandlers(this.plugins),this.docView=new t4(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),document.fonts?.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent=`refresh`,this.requestMeasure()})}dispatch(...e){let t=e.length==1&&e[0]instanceof y1?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(t){if(this.updateState!=0)throw Error(`Calls to EditorView.update are not allowed while an update is in progress`);let n=!1,r=!1,i,a=this.state;for(let e of t){if(e.startState!=a)throw RangeError(`Trying to update state with a transaction that doesn't start from the previous state.`);a=e.state}if(this.destroyed){this.viewState.state=a;return}let o=this.hasFocus,s=0,c=null;t.some(e=>e.annotation(F4))?(this.inputState.notifiedFocused=o,s=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,c=I4(a,o),c||(s=1));let l=this.observer.delayedAndroidKey,u=null;if(l?(this.observer.clearDelayedAndroidKey(),u=this.observer.readChange(),(u&&!this.state.doc.eq(a.doc)||!this.state.selection.eq(a.selection))&&(u=null)):this.observer.clear(),a.facet(E1.phrases)!=this.state.facet(E1.phrases))return this.setState(a);i=R2.create(this,a,t),i.flags|=s;let d=this.viewState.scrollTarget;try{this.updateState=2;for(let n of t){if(d&&=d.map(n.changes),n.scrollIntoView){let{main:t}=n.state.selection,{x:r,y:i}=this.state.facet(e.cursorScrollMargin);d=new v2(t.empty?t:J.cursor(t.head,t.head>t.anchor?-1:1),`nearest`,`nearest`,i,r)}for(let e of n.effects)e.is(y2)&&(d=e.value.clip(this.state))}this.viewState.update(i,d),this.bidiCache=g3.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),n=this.docView.update(i),this.state.facet(I2)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(n,t.some(e=>e.isUserEvent(`select.pointer`)))}finally{this.updateState=0}if(i.startState.facet(a3)!=i.state.facet(a3)&&(this.viewState.mustMeasureContent=!0),(n||r||d||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!i.empty)for(let e of this.state.facet(d2))try{e(i)}catch(e){x2(this.state,e,`update listener`)}(c||u)&&Promise.resolve().then(()=>{c&&this.state==c.startState&&this.dispatch(c),u&&!m4(this,u)&&l.force&&H0(this.contentDOM,l.key,l.keyCode)})}setState(e){if(this.updateState!=0)throw Error(`Calls to EditorView.setState are not allowed while an update is in progress`);if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let e of this.plugins)e.destroy(this);this.viewState=new Q4(this,e),this.plugins=e.facet(C2).map(e=>new T2(e)),this.pluginMap.clear();for(let e of this.plugins)e.update(this);this.docView.destroy(),this.docView=new t4(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(C2),n=e.state.facet(C2);if(t!=n){let r=[];for(let i of n){let n=t.indexOf(i);if(n<0)r.push(new T2(i));else{let t=this.plugins[n];t.mustUpdate=e,r.push(t)}}for(let t of this.plugins)t.mustUpdate!=e&&t.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let t of this.plugins)t.mustUpdate=e;for(let e=0;e<this.plugins.length;e++)this.plugins[e].update(this);t!=n&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(e){x2(this.state,e,`doc view update listener`)}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,n=this.viewState.scrollParent,r=this.viewState.getScrollOffset(),{scrollAnchorPos:i,scrollAnchorHeight:a}=this.viewState;Math.abs(r-this.viewState.scrollOffset)>1&&(a=-1),this.viewState.scrollAnchorHeight=-1;try{for(let e=0;;e++){if(a<0)if(U0(n||this.win))i=-1,a=this.viewState.heightMap.height;else{let e=this.viewState.scrollAnchorAt(r);i=e.from,a=e.top}this.updateState=1;let o=this.viewState.measure();if(!o&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(e>5){console.warn(this.measureRequests.length?`Measure loop restarted more than 5 times`:`Viewport failed to stabilize`);break}let s=[];o&4||([this.measureRequests,s]=[s,this.measureRequests]);let c=s.map(e=>{try{return e.read(this)}catch(e){return x2(this.state,e),h3}}),l=R2.create(this,this.state,[]),u=!1;l.flags|=o,t?t.flags|=o:t=l,this.updateState=2,l.empty||(this.updatePlugins(l),this.inputState.update(l),this.updateAttrs(),u=this.docView.update(l),u&&this.docViewUpdate());for(let e=0;e<s.length;e++)if(c[e]!=h3)try{let t=s[e];t.write&&t.write(c[e],this)}catch(e){x2(this.state,e)}if(u&&this.docView.updateSelection(!0),!l.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,a=-1;continue}else{let e=((i<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(i).top)-a)/this.scaleY;if((e>1||e<-1)&&(n==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){r+=e,n?n.scrollTop+=e:this.win.scrollBy(0,e),a=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let e of this.state.facet(d2))e(t)}get themeClasses(){return s3+` `+(this.state.facet(o3)?l3:c3)+` `+this.state.facet(a3)}updateAttrs(){let e=_3(this,E2,{class:`cm-editor`+(this.hasFocus?` cm-focused `:` `)+this.themeClasses}),t={spellcheck:`false`,autocorrect:`off`,autocapitalize:`off`,writingsuggestions:`false`,translate:`no`,contenteditable:this.state.facet(S2)?`true`:`false`,class:`cm-content`,style:`${X.tabSize}: ${this.state.tabSize}`,role:`textbox`,"aria-multiline":`true`};this.state.readOnly&&(t[`aria-readonly`]=`true`),_3(this,D2,t);let n=this.observer.ignore(()=>{let n=_0(this.contentDOM,this.contentAttrs,t),r=_0(this.dom,this.editorAttrs,e);return n||r});return this.editorAttrs=e,this.contentAttrs=t,n}showAnnouncements(t){let n=!0;for(let r of t)for(let t of r.effects)if(t.is(e.announce)){n&&(this.announceDOM.textContent=``),n=!1;let e=this.announceDOM.appendChild(document.createElement(`div`));e.textContent=t.value}}mountStyles(){this.styleModules=this.state.facet(I2);let t=this.state.facet(e.cspNonce);Y1.mount(this.root,this.styleModules.concat(Pxe).reverse(),t?{nonce:t}:void 0)}readMeasured(){if(this.updateState==2)throw Error(`Reading the editor layout isn't allowed during an update`);this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(t===void 0||t&&t.plugin!=e)&&this.pluginMap.set(e,t=this.plugins.find(t=>t.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,n){return c4(this,e,a4(this,e,t,n))}moveByGroup(e,t){return c4(this,e,a4(this,e,t,t=>qbe(this,e.head,t)))}visualLineSide(e,t){let n=this.bidiSpans(e),r=this.textDirectionAt(e.from),i=n[t?n.length-1:0];return J.cursor(i.side(t,r)+e.from,i.forward(!t,r)?1:-1)}moveToLineBoundary(e,t,n=!0){return Kbe(this,e,t,n)}moveVertically(e,t,n){return c4(this,e,Jbe(this,e,t,n))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let n=u4(this,e,t);return n&&n.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),u4(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let n=this.docView.coordsAt(e,t);if(!n||n.left==n.right)return n;let r=this.state.doc.lineAt(e),i=this.bidiSpans(r),a=i[e2.find(i,e-r.from,-1,t)];return I0(n,a.dir==q0.LTR==t>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(g2)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>zxe)return a2(e.length);let t=this.textDirectionAt(e.from),n;for(let r of this.bidiCache)if(r.from==e.from&&r.dir==t&&(r.fresh||t2(r.isolates,n=N2(this,e))))return r.order;n||=N2(this,e);let r=_be(e.text,t,n);return this.bidiCache.push(new g3(e.from,e.to,t,n,!0,r)),r}get hasFocus(){return(this.dom.ownerDocument.hasFocus()||X.safari&&this.inputState?.lastContextMenu>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{B0(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return y2.of(new v2(typeof e==`number`?J.cursor(e):e,t.y??`nearest`,t.x??`nearest`,t.yMargin??5,t.xMargin??5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,n=this.viewState.scrollAnchorAt(e);return y2.of(new v2(J.cursor(n.from),`start`,`start`,n.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e==`boolean`?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return w2.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return w2.define(()=>({}),{eventObservers:e})}static theme(e,t){let n=Y1.newName(),r=[a3.of(n),I2.of(d3(`.${n}`,e))];return t&&t.dark&&r.push(o3.of(!0)),r}static baseTheme(e){return r1.lowest(I2.of(d3(`.`+s3,e,u3)))}static findFromDOM(e){let t=e.querySelector(`.cm-content`);return(t&&z2.get(t)||z2.get(e))?.root?.view||null}};Z.styleModule=I2,Z.inputHandler=f2,Z.clipboardInputFilter=m2,Z.clipboardOutputFilter=h2,Z.scrollHandler=_2,Z.focusChangeEffect=p2,Z.perLineTextDirection=g2,Z.exceptionSink=u2,Z.updateListener=d2,Z.editable=S2,Z.mouseSelectionStyle=l2,Z.dragMovesSelection=c2,Z.clickAddsSelectionRange=s2,Z.decorations=O2,Z.blockWrappers=k2,Z.outerDecorations=A2,Z.atomicRanges=j2,Z.bidiIsolatedRanges=M2,Z.cursorScrollMargin=Y.define({combine:e=>{let t=5,n=5;for(let r of e)typeof r==`number`?t=n=r:{x:t,y:n}=r;return{x:t,y:n}}}),Z.scrollMargins=P2,Z.darkTheme=o3,Z.cspNonce=Y.define({combine:e=>e.length?e[0]:``}),Z.contentAttributes=D2,Z.editorAttributes=E2,Z.lineWrapping=Z.contentAttributes.of({class:`cm-lineWrapping`}),Z.announce=v1.define();var zxe=4096,h3={},g3=class e{constructor(e,t,n,r,i,a){this.from=e,this.to=t,this.dir=n,this.isolates=r,this.fresh=i,this.order=a}static update(t,n){if(n.empty&&!t.some(e=>e.fresh))return t;let r=[],i=t.length?t[t.length-1].dir:q0.LTR;for(let a=Math.max(0,t.length-10);a<t.length;a++){let o=t[a];o.dir==i&&!n.touchesRange(o.from,o.to)&&r.push(new e(n.mapPos(o.from,1),n.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return r}};function _3(e,t,n){for(let r=e.state.facet(t),i=r.length-1;i>=0;i--){let t=r[i],a=typeof t==`function`?t(e):t;a&&m0(a,n)}return n}var Bxe=X.mac?`mac`:X.windows?`win`:X.linux?`linux`:`key`;function Vxe(e,t){let n=e.split(/-(?!$)/),r=n[n.length-1];r==`Space`&&(r=` `);let i,a,o,s;for(let e=0;e<n.length-1;++e){let r=n[e];if(/^(cmd|meta|m)$/i.test(r))s=!0;else if(/^a(lt)?$/i.test(r))i=!0;else if(/^(c|ctrl|control)$/i.test(r))a=!0;else if(/^s(hift)?$/i.test(r))o=!0;else if(/^mod$/i.test(r))t==`mac`?s=!0:a=!0;else throw Error(`Unrecognized modifier name: `+r)}return i&&(r=`Alt-`+r),a&&(r=`Ctrl-`+r),s&&(r=`Meta-`+r),o&&(r=`Shift-`+r),r}function v3(e,t,n){return t.altKey&&(e=`Alt-`+e),t.ctrlKey&&(e=`Ctrl-`+e),t.metaKey&&(e=`Meta-`+e),n!==!1&&t.shiftKey&&(e=`Shift-`+e),e}var Hxe=r1.default(Z.domEventHandlers({keydown(e,t){return w3(x3(t.state),e,t,`editor`)}})),y3=Y.define({enables:Hxe}),b3=new WeakMap;function x3(e){let t=e.facet(y3),n=b3.get(t);return n||b3.set(t,n=Gxe(t.reduce((e,t)=>e.concat(t),[]))),n}function Uxe(e,t,n){return w3(x3(e.state),t,e,n)}var S3=null,Wxe=4e3;function Gxe(e,t=Bxe){let n=Object.create(null),r=Object.create(null),i=(e,t)=>{let n=r[e];if(n==null)r[e]=t;else if(n!=t)throw Error(`Key binding `+e+` is used both as a regular binding and as a multi-stroke prefix`)},a=(e,r,a,o,s)=>{let c=n[e]||(n[e]=Object.create(null)),l=r.split(/ (?!$)/).map(e=>Vxe(e,t));for(let t=1;t<l.length;t++){let n=l.slice(0,t).join(` `);i(n,!0),c[n]||(c[n]={preventDefault:!0,stopPropagation:!1,run:[t=>{let r=S3={view:t,prefix:n,scope:e};return setTimeout(()=>{S3==r&&(S3=null)},Wxe),!0}]})}let u=l.join(` `);i(u,!1);let d=c[u]||(c[u]={preventDefault:!1,stopPropagation:!1,run:(c._any?.run)?.slice()||[]});a&&d.run.push(a),o&&(d.preventDefault=!0),s&&(d.stopPropagation=!0)};for(let r of e){let e=r.scope?r.scope.split(` `):[`editor`];if(r.any)for(let t of e){let e=n[t]||(n[t]=Object.create(null));e._any||={preventDefault:!1,stopPropagation:!1,run:[]};let{any:i}=r;for(let t in e)e[t].run.push(e=>i(e,C3))}let i=r[t]||r.key;if(i)for(let t of e)a(t,i,r.run,r.preventDefault,r.stopPropagation),r.shift&&a(t,`Shift-`+i,r.shift,r.preventDefault,r.stopPropagation)}return n}var C3=null;function w3(e,t,n,r){C3=t;let i=tbe(t),a=F$(N$(i,0))==i.length&&i!=` `,o=``,s=!1,c=!1,l=!1;S3&&S3.view==n&&S3.scope==r&&(o=S3.prefix+` `,b4.indexOf(t.keyCode)<0&&(c=!0,S3=null));let u=new Set,d=e=>{if(e){for(let t of e.run)if(!u.has(t)&&(u.add(t),t(n)))return e.stopPropagation&&(l=!0),!0;e.preventDefault&&(e.stopPropagation&&(l=!0),c=!0)}return!1},f=e[r],p,m;return f&&(d(f[o+v3(i,t,!a)])?s=!0:a&&(t.altKey||t.metaKey||t.ctrlKey)&&!(X.windows&&t.ctrlKey&&t.altKey)&&!(X.mac&&t.altKey&&!(t.ctrlKey||t.metaKey))&&(p=Z1[t.keyCode])&&p!=i?(d(f[o+v3(p,t,!0)])||t.shiftKey&&(m=Q1[t.keyCode])!=i&&m!=p&&d(f[o+v3(m,t,!1)]))&&(s=!0):a&&t.shiftKey&&d(f[o+v3(i,t,!0)])&&(s=!0),!s&&d(f._any)&&(s=!0)),c&&(s=!0),s&&l&&t.stopPropagation(),C3=null,s}/x/.unicode;function Kxe(){return Jxe}var qxe=b0.line({class:`cm-activeLine`}),Jxe=w2.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.docChanged||e.selectionSet)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=-1,n=[];for(let r of e.state.selection.ranges){let i=e.lineBlockAt(r.head);i.from>t&&(n.push(qxe.range(i.from)),t=i.from)}return b0.set(n)}},{decorations:e=>e.decorations}),T3=`-10000px`,Yxe=class{constructor(e,t,n,r){this.facet=t,this.createTooltipView=n,this.removeTooltipView=r,this.input=e.state.facet(t),this.tooltips=this.input.filter(e=>e);let i=null;this.tooltipViews=this.tooltips.map(e=>i=n(e,i))}update(e,t){var n;let r=e.state.facet(this.facet),i=r.filter(e=>e);if(r===this.input){for(let t of this.tooltipViews)t.update&&t.update(e);return!1}let a=[],o=t?[]:null;for(let n=0;n<i.length;n++){let r=i[n],s=-1;if(r){for(let e=0;e<this.tooltips.length;e++){let t=this.tooltips[e];t&&t.create==r.create&&(s=e)}if(s<0)a[n]=this.createTooltipView(r,n?a[n-1]:null),o&&(o[n]=!!r.above);else{let r=a[n]=this.tooltipViews[s];o&&(o[n]=t[s]),r.update&&r.update(e)}}}for(let e of this.tooltipViews)a.indexOf(e)<0&&(this.removeTooltipView(e),(n=e.destroy)==null||n.call(e));return t&&(o.forEach((e,n)=>t[n]=e),t.length=o.length),this.input=r,this.tooltips=i,this.tooltipViews=a,!0}};function Xxe(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}var E3=Y.define({combine:e=>({position:X.ios?`absolute`:e.find(e=>e.position)?.position||`fixed`,parent:e.find(e=>e.parent)?.parent||null,tooltipSpace:e.find(e=>e.tooltipSpace)?.tooltipSpace||Xxe})}),D3=new WeakMap,O3=w2.fromClass(class{constructor(e){this.view=e,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let t=e.state.facet(E3);this.position=t.position,this.parent=t.parent,this.classes=e.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver==`function`?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new Yxe(e,A3,(e,t)=>this.createTooltip(e,t),e=>{this.resizeObserver&&this.resizeObserver.unobserve(e.dom),e.dom.remove()}),this.above=this.manager.tooltips.map(e=>!!e.above),this.intersectionObserver=typeof IntersectionObserver==`function`?new IntersectionObserver(e=>{Date.now()>this.lastTransaction-50&&e.length>0&&e[e.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),e.win.addEventListener(`resize`,this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement(`div`),this.container.style.position=`relative`,this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let e of this.manager.tooltipViews)this.intersectionObserver.observe(e.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(e){e.transactions.length&&(this.lastTransaction=Date.now());let t=this.manager.update(e,this.above);t&&this.observeIntersection();let n=t||e.geometryChanged,r=e.state.facet(E3);if(r.position!=this.position&&!this.madeAbsolute){this.position=r.position;for(let e of this.manager.tooltipViews)e.dom.style.position=this.position;n=!0}if(r.parent!=this.parent){this.parent&&this.container.remove(),this.parent=r.parent,this.createContainer();for(let e of this.manager.tooltipViews)this.container.appendChild(e.dom);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(e,t){let n=e.create(this.view),r=t?t.dom:null;if(n.dom.classList.add(`cm-tooltip`),e.arrow&&!n.dom.querySelector(`.cm-tooltip > .cm-tooltip-arrow`)){let e=document.createElement(`div`);e.className=`cm-tooltip-arrow`,n.dom.appendChild(e)}return n.dom.style.position=this.position,n.dom.style.top=T3,n.dom.style.left=`0px`,this.container.insertBefore(n.dom,r),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var e,t,n;this.view.win.removeEventListener(`resize`,this.measureSoon);for(let t of this.manager.tooltipViews)t.dom.remove(),(e=t.destroy)==null||e.call(t);this.parent&&this.container.remove(),(t=this.resizeObserver)==null||t.disconnect(),(n=this.intersectionObserver)==null||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let e=1,t=1,n=!1;if(this.position==`fixed`&&this.manager.tooltipViews.length){let{dom:e}=this.manager.tooltipViews[0];if(X.safari){let t=e.getBoundingClientRect();n=Math.abs(t.top+1e4)>1||Math.abs(t.left)>1}else n=!!e.offsetParent&&e.offsetParent!=this.container.ownerDocument.body}if(n||this.position==`absolute`)if(this.parent){let n=this.parent.getBoundingClientRect();n.width&&n.height&&(e=n.width/this.parent.offsetWidth,t=n.height/this.parent.offsetHeight)}else ({scaleX:e,scaleY:t}=this.view.viewState);let r=this.view.scrollDOM.getBoundingClientRect(),i=F2(this.view);return{visible:{left:r.left+i.left,top:r.top+i.top,right:r.right-i.right,bottom:r.bottom-i.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((e,t)=>{let n=this.manager.tooltipViews[t];return n.getCoords?n.getCoords(e.pos):this.view.coordsAtPos(e.pos)}),size:this.manager.tooltipViews.map(({dom:e})=>e.getBoundingClientRect()),space:this.view.state.facet(E3).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:n}}writeMeasure(e){if(e.makeAbsolute){this.madeAbsolute=!0,this.position=`absolute`;for(let e of this.manager.tooltipViews)e.dom.style.position=`absolute`}let{visible:t,space:n,scaleX:r,scaleY:i}=e,a=[];for(let o=0;o<this.manager.tooltips.length;o++){let s=this.manager.tooltips[o],c=this.manager.tooltipViews[o],{dom:l}=c,u=e.pos[o],d=e.size[o];if(!u||s.clip!==!1&&(u.bottom<=Math.max(t.top,n.top)||u.top>=Math.min(t.bottom,n.bottom)||u.right<Math.max(t.left,n.left)-.1||u.left>Math.min(t.right,n.right)+.1)){l.style.top=T3;continue}let f=s.arrow?c.dom.querySelector(`.cm-tooltip-arrow`):null,p=f?7:0,m=d.right-d.left,h=D3.get(c)??d.bottom-d.top,g=c.offset||Qxe,_=this.view.textDirection==q0.LTR,v=d.width>n.right-n.left?_?n.left:n.right-d.width:_?Math.max(n.left,Math.min(u.left-(f?14:0)+g.x,n.right-m)):Math.min(Math.max(n.left,u.left-m+(f?14:0)-g.x),n.right-m),y=this.above[o];!s.strictSide&&(y?u.top-h-p-g.y<n.top:u.bottom+h+p+g.y>n.bottom)&&y==n.bottom-u.bottom>u.top-n.top&&(y=this.above[o]=!y);let b=(y?u.top-n.top:n.bottom-u.bottom)-p;if(b<h&&c.resize!==!1){if(b<this.view.defaultLineHeight){l.style.top=T3;continue}D3.set(c,h),l.style.height=(h=b)/i+`px`}else l.style.height&&(l.style.height=``);let x=y?u.top-h-p-g.y:u.bottom+p+g.y,S=v+m;if(c.overlap!==!0)for(let e of a)e.left<S&&e.right>v&&e.top<x+h&&e.bottom>x&&(x=y?e.top-h-2-p:e.bottom+p+2);if(this.position==`absolute`?(l.style.top=(x-e.parent.top)/i+`px`,k3(l,(v-e.parent.left)/r)):(l.style.top=x/i+`px`,k3(l,v/r)),f){let e=u.left+(_?g.x:-g.x)-(v+14-7);f.style.left=e/r+`px`}c.overlap!==!0&&a.push({left:v,top:x,right:S,bottom:x+h}),l.classList.toggle(`cm-tooltip-above`,y),l.classList.toggle(`cm-tooltip-below`,!y),c.positioned&&c.positioned(e.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let e of this.manager.tooltipViews)e.dom.style.top=T3}},{eventObservers:{scroll(){this.maybeMeasure()}}});function k3(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+`px`)}var Zxe=Z.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:`border-box`},"&light .cm-tooltip":{border:`1px solid #bbb`,backgroundColor:`#f5f5f5`},"&light .cm-tooltip-section:not(:first-child)":{borderTop:`1px solid #bbb`},"&dark .cm-tooltip":{backgroundColor:`#333338`,color:`white`},".cm-tooltip-arrow":{height:`7px`,width:`14px`,position:`absolute`,zIndex:-1,overflow:`hidden`,"&:before, &:after":{content:`''`,position:`absolute`,width:0,height:0,borderLeft:`7px solid transparent`,borderRight:`7px solid transparent`},".cm-tooltip-above &":{bottom:`-7px`,"&:before":{borderTop:`7px solid #bbb`},"&:after":{borderTop:`7px solid #f5f5f5`,bottom:`1px`}},".cm-tooltip-below &":{top:`-7px`,"&:before":{borderBottom:`7px solid #bbb`},"&:after":{borderBottom:`7px solid #f5f5f5`,top:`1px`}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:`#333338`,borderBottomColor:`#333338`},"&:after":{borderTopColor:`transparent`,borderBottomColor:`transparent`}}}),Qxe={x:0,y:0},A3=Y.define({enables:[O3,Zxe]});function j3(e,t){let n=e.plugin(O3);if(!n)return null;let r=n.manager.tooltips.indexOf(t);return r<0?null:n.manager.tooltipViews[r]}var M3=Y.define({combine(e){let t,n;for(let r of e)t||=r.topContainer,n||=r.bottomContainer;return{topContainer:t,bottomContainer:n}}});function N3(e,t){let n=e.plugin(P3),r=n?n.specs.indexOf(t):-1;return r>-1?n.panels[r]:null}var P3=w2.fromClass(class{constructor(e){this.input=e.state.facet(L3),this.specs=this.input.filter(e=>e),this.panels=this.specs.map(t=>t(e));let t=e.state.facet(M3);this.top=new F3(e,!0,t.topContainer),this.bottom=new F3(e,!1,t.bottomContainer),this.top.sync(this.panels.filter(e=>e.top)),this.bottom.sync(this.panels.filter(e=>!e.top));for(let e of this.panels)e.dom.classList.add(`cm-panel`),e.mount&&e.mount()}update(e){let t=e.state.facet(M3);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new F3(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new F3(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(L3);if(n!=this.input){let t=n.filter(e=>e),r=[],i=[],a=[],o=[];for(let n of t){let t=this.specs.indexOf(n),s;t<0?(s=n(e.view),o.push(s)):(s=this.panels[t],s.update&&s.update(e)),r.push(s),(s.top?i:a).push(s)}this.specs=t,this.panels=r,this.top.sync(i),this.bottom.sync(a);for(let e of o)e.dom.classList.add(`cm-panel`),e.mount&&e.mount()}else for(let t of this.panels)t.update&&t.update(e)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:e=>Z.scrollMargins.of(t=>{let n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})}),F3=class{constructor(e,t,n){this.view=e,this.top=t,this.container=n,this.dom=void 0,this.classes=``,this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&=(this.dom.remove(),void 0);return}if(!this.dom){this.dom=document.createElement(`div`),this.dom.className=this.top?`cm-panels cm-panels-top`:`cm-panels cm-panels-bottom`,this.dom.style[this.top?`top`:`bottom`]=`0`;let e=this.container||this.view.dom;e.insertBefore(this.dom,this.top?e.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=I3(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=I3(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(` `))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(` `))e&&this.container.classList.add(e)}}};function I3(e){let t=e.nextSibling;return e.remove(),t}var L3=Y.define({enables:P3});function $xe(e,t){let n,r=new Promise(e=>n=e),i=e=>eSe(e,t,n);e.state.field(R3,!1)?e.dispatch({effects:z3.of(i)}):e.dispatch({effects:v1.appendConfig.of(R3.init(()=>[i]))});let a=B3.of(i);return{close:a,result:r.then(t=>((e.win.queueMicrotask||(t=>e.win.setTimeout(t,10)))(()=>{e.state.field(R3).indexOf(i)>-1&&e.dispatch({effects:a})}),t))}}var R3=e1.define({create(){return[]},update(e,t){for(let n of t.effects)n.is(z3)?e=[n.value].concat(e):n.is(B3)&&(e=e.filter(e=>e!=n.value));return e},provide:e=>L3.computeN([e],t=>t.field(e))}),z3=v1.define(),B3=v1.define();function eSe(e,t,n){let r=t.content?t.content(e,()=>o(null)):null;if(!r){if(r=t0(`form`),t.input){let e=t0(`input`,t.input);/^(text|password|number|email|tel|url)$/.test(e.type)&&e.classList.add(`cm-textfield`),e.name||=`input`,r.appendChild(t0(`label`,(t.label||``)+`: `,e))}else r.appendChild(document.createTextNode(t.label||``));r.appendChild(document.createTextNode(` `)),r.appendChild(t0(`button`,{class:`cm-button`,type:`submit`},t.submitLabel||`OK`))}let i=r.nodeName==`FORM`?[r]:r.querySelectorAll(`form`);for(let e=0;e<i.length;e++){let t=i[e];t.addEventListener(`keydown`,e=>{e.keyCode==27?(e.preventDefault(),o(null)):e.keyCode==13&&(e.preventDefault(),o(t))}),t.addEventListener(`submit`,e=>{e.preventDefault(),o(t)})}let a=t0(`div`,r,t0(`button`,{onclick:()=>o(null),"aria-label":e.state.phrase(`close`),class:`cm-dialog-close`,type:`button`},[`×`]));t.class&&(a.className=t.class),a.classList.add(`cm-dialog`);function o(t){a.contains(a.ownerDocument.activeElement)&&e.focus(),n(t)}return{dom:a,top:t.top,mount:()=>{if(t.focus){let e;e=typeof t.focus==`string`?r.querySelector(t.focus):r.querySelector(`input`)||r.querySelector(`button`),e&&`select`in e?e.select():e&&`focus`in e&&e.focus()}}}}var V3=class extends O1{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};V3.prototype.elementClass=``,V3.prototype.toDOM=void 0,V3.prototype.mapMode=L$.TrackBefore,V3.prototype.startSide=V3.prototype.endSide=-1,V3.prototype.point=!0;var H3=Y.define(),tSe=Y.define(),U3=Y.define(),W3=Y.define({combine:e=>e.some(e=>e)});function nSe(e){let t=[rSe];return e&&e.fixed===!1&&t.push(W3.of(!0)),t}var rSe=w2.fromClass(class{constructor(e){this.view=e,this.domAfter=null,this.prevViewport=e.viewport,this.dom=document.createElement(`div`),this.dom.className=`cm-gutters cm-gutters-before`,this.dom.setAttribute(`aria-hidden`,`true`),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+`px`,this.gutters=e.state.facet(U3).map(t=>new q3(e,t)),this.fixed=!e.state.facet(W3);for(let e of this.gutters)e.config.side==`after`?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position=`sticky`),this.syncGutters(!1),e.scrollDOM.insertBefore(this.dom,e.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement(`div`),this.domAfter.className=`cm-gutters cm-gutters-after`,this.domAfter.setAttribute(`aria-hidden`,`true`),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+`px`,this.domAfter.style.position=this.fixed?`sticky`:``,this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(e){if(this.updateGutters(e)){let t=this.prevViewport,n=e.view.viewport,r=Math.min(t.to,n.to)-Math.max(t.from,n.from);this.syncGutters(r<(n.to-n.from)*.8)}if(e.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+`px`;this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(W3)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?`sticky`:``,this.domAfter&&(this.domAfter.style.position=this.fixed?`sticky`:``)),this.prevViewport=e.view.viewport}syncGutters(e){let t=this.dom.nextSibling;e&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=M1.iter(this.view.state.facet(H3),this.view.viewport.from),r=[],i=this.gutters.map(e=>new iSe(e,this.view.viewport,-this.view.documentPadding.top));for(let e of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(e.type)){let t=!0;for(let a of e.type)if(a.type==y0.Text&&t){K3(n,r,a.from);for(let e of i)e.line(this.view,a,r);t=!1}else if(a.widget)for(let e of i)e.widget(this.view,a)}else if(e.type==y0.Text){K3(n,r,e.from);for(let t of i)t.line(this.view,e,r)}else if(e.widget)for(let t of i)t.widget(this.view,e);for(let e of i)e.finish();e&&(this.view.scrollDOM.insertBefore(this.dom,t),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(e){let t=e.startState.facet(U3),n=e.state.facet(U3),r=e.docChanged||e.heightChanged||e.viewportChanged||!M1.eq(e.startState.facet(H3),e.state.facet(H3),e.view.viewport.from,e.view.viewport.to);if(t==n)for(let t of this.gutters)t.update(e)&&(r=!0);else{r=!0;let i=[];for(let r of n){let n=t.indexOf(r);n<0?i.push(new q3(this.view,r)):(this.gutters[n].update(e),i.push(this.gutters[n]))}for(let e of this.gutters)e.dom.remove(),i.indexOf(e)<0&&e.destroy();for(let e of i)e.config.side==`after`?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.gutters=i}return r}destroy(){for(let e of this.gutters)e.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:e=>Z.scrollMargins.of(t=>{let n=t.plugin(e);if(!n||n.gutters.length==0||!n.fixed)return null;let r=n.dom.offsetWidth*t.scaleX,i=n.domAfter?n.domAfter.offsetWidth*t.scaleX:0;return t.textDirection==q0.LTR?{left:r,right:i}:{right:r,left:i}})});function G3(e){return Array.isArray(e)?e:[e]}function K3(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}var iSe=class{constructor(e,t,n){this.gutter=e,this.height=n,this.i=0,this.cursor=M1.iter(e.markers,t.from)}addElement(e,t,n){let{gutter:r}=this,i=(t.top-this.height)/e.scaleY,a=t.height/e.scaleY;if(this.i==r.elements.length){let t=new J3(e,a,i,n);r.elements.push(t),r.dom.appendChild(t.dom)}else r.elements[this.i].update(e,a,i,n);this.height=t.bottom,this.i++}line(e,t,n){let r=[];K3(this.cursor,r,t.from),n.length&&(r=r.concat(n));let i=this.gutter.config.lineMarker(e,t,r);i&&r.unshift(i);let a=this.gutter;r.length==0&&!a.config.renderEmptyElements||this.addElement(e,t,r)}widget(e,t){let n=this.gutter.config.widgetMarker(e,t.widget,t),r=n?[n]:null;for(let n of e.state.facet(tSe)){let i=n(e,t.widget,t);i&&(r||=[]).push(i)}r&&this.addElement(e,t,r)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}},q3=class{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement(`div`),this.dom.className=`cm-gutter`+(this.config.class?` `+this.config.class:``);for(let n in t.domEventHandlers)this.dom.addEventListener(n,r=>{let i=r.target,a;if(i!=this.dom&&this.dom.contains(i)){for(;i.parentNode!=this.dom;)i=i.parentNode;let e=i.getBoundingClientRect();a=(e.top+e.bottom)/2}else a=r.clientY;let o=e.lineBlockAtHeight(a-e.documentTop);t.domEventHandlers[n](e,o,r)&&r.preventDefault()});this.markers=G3(t.markers(e)),t.initialSpacer&&(this.spacer=new J3(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+=`visibility: hidden; pointer-events: none`)}update(e){let t=this.markers;if(this.markers=G3(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let t=this.config.updateSpacer(this.spacer.markers[0],e);t!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[t])}let n=e.view.viewport;return!M1.eq(this.markers,t,n.from,n.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}},J3=class{constructor(e,t,n,r){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement(`div`),this.dom.className=`cm-gutterElement`,this.update(e,t,n,r)}update(e,t,n,r){this.height!=t&&(this.height=t,this.dom.style.height=t+`px`),this.above!=n&&(this.dom.style.marginTop=(this.above=n)?n+`px`:``),aSe(this.markers,r)||this.setMarkers(e,r)}setMarkers(e,t){let n=`cm-gutterElement`,r=this.dom.firstChild;for(let i=0,a=0;;){let o=a,s=i<t.length?t[i++]:null,c=!1;if(s){let e=s.elementClass;e&&(n+=` `+e);for(let e=a;e<this.markers.length;e++)if(this.markers[e].compare(s)){o=e,c=!0;break}}else o=this.markers.length;for(;a<o;){let e=this.markers[a++];if(e.toDOM){e.destroy(r);let t=r.nextSibling;r.remove(),r=t}}if(!s)break;s.toDOM&&(c?r=r.nextSibling:this.dom.insertBefore(s.toDOM(e),r)),c&&a++}this.dom.className=n,this.markers=t}destroy(){this.setMarkers(null,[])}};function aSe(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].compare(t[n]))return!1;return!0}var oSe=Y.define(),sSe=Y.define(),Y3=Y.define({combine(e){return D1(e,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let n=Object.assign({},e);for(let e in t){let r=n[e],i=t[e];n[e]=r?(e,t,n)=>r(e,t,n)||i(e,t,n):i}return n}})}}),X3=class extends V3{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}};function Z3(e,t){return e.state.facet(Y3).formatNumber(t,e.state)}var cSe=U3.compute([Y3],e=>({class:`cm-lineNumbers`,renderEmptyElements:!1,markers(e){return e.state.facet(oSe)},lineMarker(e,t,n){return n.some(e=>e.toDOM)?null:new X3(Z3(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,n)=>{for(let r of e.state.facet(sSe)){let i=r(e,t,n);if(i)return i}return null},lineMarkerChange:e=>e.startState.facet(Y3)!=e.state.facet(Y3),initialSpacer(e){return new X3(Z3(e,Q3(e.state.doc.lines)))},updateSpacer(e,t){let n=Z3(t.view,Q3(t.view.state.doc.lines));return n==e.number?e:new X3(n)},domEventHandlers:e.facet(Y3).domEventHandlers,side:`before`}));function lSe(e={}){return[Y3.of(e),nSe(),cSe]}function Q3(e){let t=9;for(;t<e;)t=t*10+9;return t}var uSe=new class extends V3{constructor(){super(...arguments),this.elementClass=`cm-activeLineGutter`}},dSe=H3.compute([`selection`],e=>{let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.head).from;i>n&&(n=i,t.push(uSe.range(i)))}return M1.of(t)});function fSe(){return dSe}var $3=1024,pSe=0,e6=class{constructor(e,t){this.from=e,this.to=t}},t6=class{constructor(e={}){this.id=pSe++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw Error(`This node type doesn't define a deserialize function`)}),this.combine=e.combine||null}add(e){if(this.perNode)throw RangeError(`Can't add per-node props to node types`);return typeof e!=`function`&&(e=r6.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}};t6.closedBy=new t6({deserialize:e=>e.split(` `)}),t6.openedBy=new t6({deserialize:e=>e.split(` `)}),t6.group=new t6({deserialize:e=>e.split(` `)}),t6.isolate=new t6({deserialize:e=>{if(e&&e!=`rtl`&&e!=`ltr`&&e!=`auto`)throw RangeError(`Invalid value for isolate: `+e);return e||`auto`}}),t6.contextHash=new t6({perNode:!0}),t6.lookAhead=new t6({perNode:!0}),t6.mounted=new t6({perNode:!0});var n6=class{constructor(e,t,n,r=!1){this.tree=e,this.overlay=t,this.parser=n,this.bracketed=r}static get(e){return e&&e.props&&e.props[t6.mounted.id]}},mSe=Object.create(null),r6=class e{constructor(e,t,n,r=0){this.name=e,this.props=t,this.id=n,this.flags=r}static define(t){let n=t.props&&t.props.length?Object.create(null):mSe,r=!!t.top|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),i=new e(t.name||``,n,t.id,r);if(t.props){for(let e of t.props)if(Array.isArray(e)||(e=e(i)),e){if(e[0].perNode)throw RangeError(`Can't store a per-node prop on a node type`);n[e[0].id]=e[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(t6.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let r of n.split(` `))t[r]=e[n];return e=>{for(let n=e.prop(t6.group),r=-1;r<(n?n.length:0);r++){let i=t[r<0?e.name:n[r]];if(i)return i}}}};r6.none=new r6(``,Object.create(null),0,8);var hSe=class e{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw RangeError(`Node type ids should correspond to array positions when creating a node set`)}extend(...t){let n=[];for(let e of this.types){let r=null;for(let n of t){let t=n(e);if(t){r||=Object.assign({},e.props);let n=t[1],i=t[0];i.combine&&i.id in r&&(n=i.combine(r[i.id],n)),r[i.id]=n}}n.push(r?new r6(e.name,r,e.id,e.flags):e)}return new e(n)}},i6=new WeakMap,a6=new WeakMap,o6;(function(e){e[e.ExcludeBuffers=1]=`ExcludeBuffers`,e[e.IncludeAnonymous=2]=`IncludeAnonymous`,e[e.IgnoreMounts=4]=`IgnoreMounts`,e[e.IgnoreOverlays=8]=`IgnoreOverlays`,e[e.EnterBracketed=16]=`EnterBracketed`})(o6||={});var s6=class e{constructor(e,t,n,r,i){if(this.type=e,this.children=t,this.positions=n,this.length=r,this.props=null,i&&i.length){this.props=Object.create(null);for(let[e,t]of i)this.props[typeof e==`number`?e:e.id]=t}}toString(){let e=n6.get(this);if(e&&!e.overlay)return e.tree.toString();let t=``;for(let e of this.children){let n=e.toString();n&&(t&&(t+=`,`),t+=n)}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 _6(this.topNode,e)}cursorAt(e,t=0,n=0){let r=new _6(i6.get(this)||this.topNode);return r.moveTo(e,t),i6.set(this,r._tree),r}get topNode(){return new f6(this,0,0,null)}resolve(e,t=0){let n=u6(i6.get(this)||this.topNode,e,t,!1);return i6.set(this,n),n}resolveInner(e,t=0){let n=u6(a6.get(this)||this.topNode,e,t,!0);return a6.set(this,n),n}resolveStack(e,t=0){return ySe(this,e,t)}iterate(e){let{enter:t,leave:n,from:r=0,to:i=this.length}=e,a=e.mode||0,o=(a&o6.IncludeAnonymous)>0;for(let e=this.cursor(a|o6.IncludeAnonymous);;){let a=!1;if(e.from<=i&&e.to>=r&&(!o&&e.type.isAnonymous||t(e)!==!1)){if(e.firstChild())continue;a=!0}for(;a&&n&&(o||!e.type.isAnonymous)&&n(e),!e.nextSibling();){if(!e.parent())return;a=!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(t={}){return this.children.length<=8?this:x6(r6.none,this.children,this.positions,0,this.children.length,0,this.length,(t,n,r)=>new e(this.type,t,n,r,this.propValues),t.makeTree||((t,n,r)=>new e(r6.none,t,n,r)))}static build(e){return bSe(e)}};s6.empty=new s6(r6.none,[],[],0);var gSe=class e{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 e(this.buffer,this.index)}},c6=class e{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return r6.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],n=this.buffer[e+3],r=this.set.types[t],i=r.name;if(/\W/.test(i)&&!r.isError&&(i=JSON.stringify(i)),e+=4,n==e)return i;let a=[];for(;e<n;)a.push(this.childString(e)),e=this.buffer[e+3];return i+`(`+a.join(`,`)+`)`}findChild(e,t,n,r,i){let{buffer:a}=this,o=-1;for(let s=e;s!=t&&!(l6(i,r,a[s+1],a[s+2])&&(o=s,n>0));s=a[s+3]);return o}slice(t,n,r){let i=this.buffer,a=new Uint16Array(n-t),o=0;for(let e=t,s=0;e<n;){a[s++]=i[e++],a[s++]=i[e++]-r;let n=a[s++]=i[e++]-r;a[s++]=i[e++]-t,o=Math.max(o,n)}return new e(a,o,this.set)}};function l6(e,t,n,r){switch(e){case-2:return n<t;case-1:return r>=t&&n<t;case 0:return n<t&&r>t;case 1:return n<=t&&r>t;case 2:return r>t;case 4:return!0}}function u6(e,t,n,r){for(;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to<t);){let t=!r&&e instanceof f6&&e.index<0?null:e.parent;if(!t)return e;e=t}let i=r?0:o6.IgnoreOverlays;if(r)for(let r=e,a=r.parent;a;r=a,a=r.parent)r instanceof f6&&r.index<0&&a.enter(t,n,i)?.from!=r.from&&(e=a);for(;;){let r=e.enter(t,n,i);if(!r)return e;e=r}}var d6=class{cursor(e=0){return new _6(this,e)}getChild(e,t=null,n=null){let r=p6(this,e,t,n);return r.length?r[0]:null}getChildren(e,t=null,n=null){return p6(this,e,t,n)}resolve(e,t=0){return u6(this,e,t,!1)}resolveInner(e,t=0){return u6(this,e,t,!0)}matchContext(e){return m6(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),n=this;for(;t;){let e=t.lastChild;if(!e||e.to!=t.to)break;e.type.isError&&e.from==e.to?(n=t,t=e.prevSibling):t=e}return n}get node(){return this}get next(){return this.parent}},f6=class e extends d6{constructor(e,t,n,r){super(),this._tree=e,this.from=t,this.index=n,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,n,r,i,a=0){for(let o=this;;){for(let{children:s,positions:c}=o._tree,l=n>0?s.length:-1;t!=l;t+=n){let l=s[t],u=c[t]+o.from,d;if(!(!(a&o6.EnterBracketed&&l instanceof s6&&(d=n6.get(l))&&!d.overlay&&d.bracketed&&r>=u&&r<=u+l.length)&&!l6(i,r,u,u+l.length))){if(l instanceof c6){if(a&o6.ExcludeBuffers)continue;let e=l.findChild(0,l.buffer.length,n,r-u,i);if(e>-1)return new h6(new _Se(o,l,t,u),null,e)}else if(a&o6.IncludeAnonymous||!l.type.isAnonymous||v6(l)){let s;if(!(a&o6.IgnoreMounts)&&(s=n6.get(l))&&!s.overlay)return new e(s.tree,u,t,o);let c=new e(l,u,t,o);return a&o6.IncludeAnonymous||!c.type.isAnonymous?c:c.nextChild(n<0?l.children.length-1:0,n,r,i,a)}}}if(a&o6.IncludeAnonymous||!o.type.isAnonymous||(t=o.index>=0?o.index+n:n<0?-1:o._parent._tree.children.length,o=o._parent,!o))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)}prop(e){return this._tree.prop(e)}enter(t,n,r=0){let i;if(!(r&o6.IgnoreOverlays)&&(i=n6.get(this._tree))&&i.overlay){let a=t-this.from,o=r&o6.EnterBracketed&&i.bracketed;for(let{from:t,to:r}of i.overlay)if((n>0||o?t<=a:t<a)&&(n<0||o?r>=a:r>a))return new e(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,n,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}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}};function p6(e,t,n,r){let i=e.cursor(),a=[];if(!i.firstChild())return a;if(n!=null){for(let e=!1;!e;)if(e=i.type.is(n),!i.nextSibling())return a}for(;;){if(r!=null&&i.type.is(r))return a;if(i.type.is(t)&&a.push(i.node),!i.nextSibling())return r==null?a:[]}}function m6(e,t,n=t.length-1){for(let r=e;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}var _Se=class{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}},h6=class e extends d6{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,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(t,n,r){let{buffer:i}=this.context,a=i.findChild(this.index+4,i.buffer[this.index+3],t,n-this.context.start,r);return a<0?null:new e(this.context,this,a)}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)}prop(e){return this.type.prop(e)}enter(t,n,r=0){if(r&o6.ExcludeBuffers)return null;let{buffer:i}=this.context,a=i.findChild(this.index+4,i.buffer[this.index+3],n>0?1:-1,t-this.context.start,n);return a<0?null:new e(this.context,this,a)}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:t}=this.context,n=t.buffer[this.index+3];return n<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new e(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new e(this.context,this._parent,t.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,r=this.index+4,i=n.buffer[this.index+3];if(i>r){let a=n.buffer[this.index+1];e.push(n.slice(r,i,a)),t.push(0)}return new s6(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function g6(e){if(!e.length)return null;let t=0,n=e[0];for(let r=1;r<e.length;r++){let i=e[r];(i.from>n.from||i.to<n.to)&&(n=i,t=r)}let r=n instanceof f6&&n.index<0?null:n.parent,i=e.slice();return r?i[t]=r:i.splice(t,1),new vSe(i,n)}var vSe=class{constructor(e,t){this.heads=e,this.node=t}get next(){return g6(this.heads)}};function ySe(e,t,n){let r=e.resolveInner(t,n),i=null;for(let e=r instanceof f6?r:r.context.parent;e;e=e.parent)if(e.index<0){let a=e.parent;(i||=[r]).push(a.resolve(t,n)),e=a}else{let a=n6.get(e.tree);if(a&&a.overlay&&a.overlay[0].from<=t&&a.overlay[a.overlay.length-1].to>=t){let o=new f6(a.tree,a.overlay[0].from+e.from,-1,e);(i||=[r]).push(u6(o,t,n,!1))}}return i?g6(i):r}var _6=class{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~o6.EnterBracketed,e instanceof f6)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.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:n,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=n+r.buffer[e+1],this.to=n+r.buffer[e+2],!0}yield(e){return e?e instanceof f6?(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,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:r}=this.buffer,i=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,n);return i<0?!1:(this.stack.push(this.index),this.yieldBuf(i))}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,n=this.mode){return this.buffer?n&o6.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&o6.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&o6.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,n=this.stack.length-1;if(e<0){let e=n<0?0:this.stack[n]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(e)}return n<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,n,{buffer:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let e=0;e<this.index;e++)if(r.buffer.buffer[e+3]<this.index)return!1;({index:t,parent:n}=r)}else ({index:t,_parent:n}=this._tree);for(;n;{index:t,_parent:n}=n)if(t>-1)for(let r=t+e,i=e<0?-1:n._tree.children.length;r!=i;r+=e){let e=n._tree.children[r];if(this.mode&o6.IncludeAnonymous||e instanceof c6||!e.type.isAnonymous||v6(e))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,n=0;if(e&&e.context==this.buffer)scan:for(let r=this.index,i=this.stack.length;i>=0;){for(let a=e;a;a=a._parent)if(a.index==r){if(r==this.index)return a;t=a,n=i+1;break scan}r=this.stack[--i]}for(let e=n;e<this.stack.length;e++)t=new h6(this.buffer,t,this.stack[e]);return this.bufferNode=new h6(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let r=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){n++;continue}this.type.isAnonymous||(r=!0)}for(;;){if(r&&t&&t(this),r=this.type.isAnonymous,!n)return;if(this.nextSibling())break;this.parent(),n--,r=!0}}}matchContext(e){if(!this.buffer)return m6(this.node.parent,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let r=e.length-1,i=this.stack.length-1;r>=0;i--){if(i<0)return m6(this._tree,e,r);let a=n[t.buffer[this.stack[i]]];if(!a.isAnonymous){if(e[r]&&e[r]!=a.name)return!1;r--}}return!0}};function v6(e){return e.children.some(e=>e instanceof c6||!e.type.isAnonymous||v6(e))}function bSe(e){let{buffer:t,nodeSet:n,maxBufferLength:r=$3,reused:i=[],minRepeatType:a=n.types.length}=e,o=Array.isArray(t)?new gSe(t,t.length):t,s=n.types,c=0,l=0;function u(e,t,_,v,y,b){let{id:x,start:S,end:C,size:w}=o,T=l,E=c;if(w<0)if(o.next(),w==-1){let t=i[x];_.push(t),v.push(S-e);return}else if(w==-3){c=x;return}else if(w==-4){l=x;return}else throw RangeError(`Unrecognized record size: ${w}`);let D=s[x],O,k,ee=S-e;if(C-S<=r&&(k=h(o.pos-t,y))){let t=new Uint16Array(k.size-k.skip),r=o.pos-k.size,i=t.length;for(;o.pos>r;)i=g(k.start,t,i);O=new c6(t,C-k.start,n),ee=k.start-e}else{let e=o.pos-w;o.next();let t=[],n=[],i=x>=a?x:-1,s=0,c=C;for(;o.pos>e;)i>=0&&o.id==i&&o.size>=0?(o.end<=c-r&&(p(t,n,S,s,o.end,c,i,T,E),s=t.length,c=o.end),o.next()):b>2500?d(S,e,t,n):u(S,e,t,n,i,b+1);if(i>=0&&s>0&&s<t.length&&p(t,n,S,s,S,c,i,T,E),t.reverse(),n.reverse(),i>-1&&s>0){let e=f(D,E);O=x6(D,t,n,0,t.length,0,C-S,e,e)}else O=m(D,t,n,C-S,T-C,E)}_.push(O),v.push(ee)}function d(e,t,i,a){let s=[],c=0,l=-1;for(;o.pos>t;){let{id:e,start:t,end:n,size:i}=o;if(i>4)o.next();else if(l>-1&&t<l)break;else l<0&&(l=n-r),s.push(e,t,n),c++,o.next()}if(c){let t=new Uint16Array(c*4),r=s[s.length-2];for(let e=s.length-3,n=0;e>=0;e-=3)t[n++]=s[e],t[n++]=s[e+1]-r,t[n++]=s[e+2]-r,t[n++]=n;i.push(new c6(t,s[2]-r,n)),a.push(r-e)}}function f(e,t){return(n,r,i)=>{let a=0,o=n.length-1,s,c;if(o>=0&&(s=n[o])instanceof s6){if(!o&&s.type==e&&s.length==i)return s;(c=s.prop(t6.lookAhead))&&(a=r[o]+s.length+c)}return m(e,n,r,i,a,t)}}function p(e,t,r,i,a,o,s,c,l){let u=[],d=[];for(;e.length>i;)u.push(e.pop()),d.push(t.pop()+r-a);e.push(m(n.types[s],u,d,o-a,c-o,l)),t.push(a-r)}function m(e,t,n,r,i,a,o){if(a){let e=[t6.contextHash,a];o=o?[e].concat(o):[e]}if(i>25){let e=[t6.lookAhead,i];o=o?[e].concat(o):[e]}return new s6(e,t,n,r,o)}function h(e,t){let n=o.fork(),i=0,s=0,c=0,l=n.end-r,u={size:0,start:0,skip:0};scan:for(let r=n.pos-e;n.pos>r;){let e=n.size;if(n.id==t&&e>=0){u.size=i,u.start=s,u.skip=c,c+=4,i+=4,n.next();continue}let o=n.pos-e;if(e<0||o<r||n.start<l)break;let d=n.id>=a?4:0,f=n.start;for(n.next();n.pos>o;){if(n.size<0)if(n.size==-3||n.size==-4)d+=4;else break scan;else n.id>=a&&(d+=4);n.next()}s=f,i+=e,c+=d}return(t<0||i==e)&&(u.size=i,u.start=s,u.skip=c),u.size>4?u:void 0}function g(e,t,n){let{id:r,start:i,end:s,size:u}=o;if(o.next(),u>=0&&r<a){let a=n;if(u>4){let r=o.pos-(u-4);for(;o.pos>r;)n=g(e,t,n)}t[--n]=a,t[--n]=s-e,t[--n]=i-e,t[--n]=r}else u==-3?c=r:u==-4&&(l=r);return n}let _=[],v=[];for(;o.pos>0;)u(e.start||0,e.bufferStart||0,_,v,-1,0);let y=e.length??(_.length?v[0]+_[0].length:0);return new s6(s[e.topID],_.reverse(),v.reverse(),y)}var y6=new WeakMap;function b6(e,t){if(!e.isAnonymous||t instanceof c6||t.type!=e)return 1;let n=y6.get(t);if(n==null){n=1;for(let r of t.children){if(r.type!=e||!(r instanceof s6)){n=1;break}n+=b6(e,r)}y6.set(t,n)}return n}function x6(e,t,n,r,i,a,o,s,c){let l=0;for(let n=r;n<i;n++)l+=b6(e,t[n]);let u=Math.ceil(l*1.5/8),d=[],f=[];function p(t,n,r,i,o){for(let s=r;s<i;){let r=s,l=n[s],m=b6(e,t[s]);for(s++;s<i;s++){let n=b6(e,t[s]);if(m+n>=u)break;m+=n}if(s==r+1){if(m>u){let e=t[r];p(e.children,e.positions,0,e.children.length,n[r]+o);continue}d.push(t[r])}else{let i=n[s-1]+t[s-1].length-l;d.push(x6(e,t,n,r,s,l,i,null,c))}f.push(l+o-a)}}return p(t,n,r,i,0),(s||c)(d,f,o)}var S6=class e{constructor(e,t,n,r,i=!1,a=!1){this.from=e,this.to=t,this.tree=n,this.offset=r,this.open=!!i|(a?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(t,n=[],r=!1){let i=[new e(0,t.length,t,0,!1,r)];for(let e of n)e.to>t.length&&i.push(e);return i}static applyChanges(t,n,r=128){if(!n.length)return t;let i=[],a=1,o=t.length?t[0]:null;for(let s=0,c=0,l=0;;s++){let u=s<n.length?n[s]:null,d=u?u.fromA:1e9;if(d-c>=r)for(;o&&o.from<d;){let n=o;if(c>=n.from||d<=n.to||l){let t=Math.max(n.from,c)-l,r=Math.min(n.to,d)-l;n=t>=r?null:new e(t,r,n.tree,n.offset+l,s>0,!!u)}if(n&&i.push(n),o.to>d)break;o=a<t.length?t[a++]:null}if(!u)break;c=u.toA,l=u.toA-u.toB}return i}},C6=class{startParse(e,t,n){return typeof e==`string`&&(e=new xSe(e)),n=n?n.length?n.map(e=>new e6(e.from,e.to)):[new e6(0,0)]:[new e6(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let r=this.startParse(e,t,n);for(;;){let e=r.advance();if(e)return e}}},xSe=class{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)}};new t6({perNode:!0});var SSe=0,w6=class e{constructor(e,t,n,r){this.name=e,this.set=t,this.base=n,this.modified=r,this.id=SSe++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(t,n){let r=typeof t==`string`?t:`?`;if(t instanceof e&&(n=t),n?.base)throw Error(`Can not derive from a modified tag`);let i=new e(r,[],null,[]);if(i.set.push(i),n)for(let e of n.set)i.set.push(e);return i}static defineModifier(e){let t=new T6(e);return e=>e.modified.indexOf(t)>-1?e:T6.get(e.base||e,e.modified.concat(t).sort((e,t)=>e.id-t.id))}},CSe=0,T6=class e{constructor(e){this.name=e,this.instances=[],this.id=CSe++}static get(t,n){if(!n.length)return t;let r=n[0].instances.find(e=>e.base==t&&wSe(n,e.modified));if(r)return r;let i=[],a=new w6(t.name,i,t,n);for(let e of n)e.instances.push(a);let o=TSe(n);for(let n of t.set)if(!n.modified.length)for(let t of o)i.push(e.get(n,t));return a}};function wSe(e,t){return e.length==t.length&&e.every((e,n)=>e==t[n])}function TSe(e){let t=[[]];for(let n=0;n<e.length;n++)for(let r=0,i=t.length;r<i;r++)t.push(t[r].concat(e[n]));return t.sort((e,t)=>t.length-e.length)}function E6(e){let t=Object.create(null);for(let n in e){let r=e[n];Array.isArray(r)||(r=[r]);for(let e of n.split(` `))if(e){let n=[],i=2,a=e;for(let t=0;;){if(a==`...`&&t>0&&t+3==e.length){i=1;break}let r=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!r)throw RangeError(`Invalid path: `+e);if(n.push(r[0]==`*`?``:r[0][0]==`"`?JSON.parse(r[0]):r[0]),t+=r[0].length,t==e.length)break;let o=e[t++];if(t==e.length&&o==`!`){i=0;break}if(o!=`/`)throw RangeError(`Invalid path: `+e);a=e.slice(t)}let o=n.length-1,s=n[o];if(!s)throw RangeError(`Invalid path: `+e);t[s]=new O6(r,i,o>0?n.slice(0,o):null).sort(t[s])}}return D6.add(t)}var D6=new t6({combine(e,t){let n,r,i;for(;e||t;){if(!e||t&&e.depth>=t.depth?(i=t,t=t.next):(i=e,e=e.next),n&&n.mode==i.mode&&!i.context&&!n.context)continue;let a=new O6(i.tags,i.mode,i.context);n?n.next=a:r=a,n=a}return r}}),O6=class{constructor(e,t,n,r){this.tags=e,this.mode=t,this.context=n,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}};O6.empty=new O6([],2,null);function k6(e,t){let n=Object.create(null);for(let t of e)if(!Array.isArray(t.tag))n[t.tag.id]=t.class;else for(let e of t.tag)n[e.id]=t.class;let{scope:r,all:i=null}=t||{};return{style:e=>{let t=i;for(let r of e)for(let e of r.set){let r=n[e.id];if(r){t=t?t+` `+r:r;break}}return t},scope:r}}function ESe(e,t){let n=null;for(let r of e){let e=r.style(t);e&&(n=n?n+` `+e:e)}return n}function DSe(e,t,n,r=0,i=e.length){let a=new OSe(r,Array.isArray(t)?t:[t],n);a.highlightRange(e.cursor(),r,i,``,a.highlighters),a.flush(i)}var OSe=class{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=``}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,n,r,i){let{type:a,from:o,to:s}=e;if(o>=n||s<=t)return;a.isTop&&(i=this.highlighters.filter(e=>!e.scope||e.scope(a)));let c=r,l=kSe(e)||O6.empty,u=ESe(i,l.tags);if(u&&(c&&(c+=` `),c+=u,l.mode==1&&(r+=(r?` `:``)+u)),this.startSpan(Math.max(t,o),c),l.opaque)return;let d=e.tree&&e.tree.prop(t6.mounted);if(d&&d.overlay){let a=e.node.enter(d.overlay[0].from+o,1),l=this.highlighters.filter(e=>!e.scope||e.scope(d.tree.type)),u=e.firstChild();for(let f=0,p=o;;f++){let m=f<d.overlay.length?d.overlay[f]:null,h=m?m.from+o:s,g=Math.max(t,p),_=Math.min(n,h);if(g<_&&u)for(;e.from<_&&(this.highlightRange(e,g,_,r,i),this.startSpan(Math.min(_,e.to),c),!(e.to>=h||!e.nextSibling())););if(!m||h>n)break;p=m.to+o,p>t&&(this.highlightRange(a.cursor(),Math.max(t,m.from+o),Math.min(n,p),``,l),this.startSpan(Math.min(n,p),c))}u&&e.parent()}else if(e.firstChild()){d&&(r=``);do{if(e.to<=t)continue;if(e.from>=n)break;this.highlightRange(e,t,n,r,i),this.startSpan(Math.min(n,e.to),c)}while(e.nextSibling());e.parent()}}};function kSe(e){let t=e.type.prop(D6);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}var Q=w6.define,A6=Q(),j6=Q(),M6=Q(j6),N6=Q(j6),P6=Q(),F6=Q(P6),I6=Q(P6),L6=Q(),R6=Q(L6),z6=Q(),B6=Q(),V6=Q(),H6=Q(V6),U6=Q(),$={comment:A6,lineComment:Q(A6),blockComment:Q(A6),docComment:Q(A6),name:j6,variableName:Q(j6),typeName:M6,tagName:Q(M6),propertyName:N6,attributeName:Q(N6),className:Q(j6),labelName:Q(j6),namespace:Q(j6),macroName:Q(j6),literal:P6,string:F6,docString:Q(F6),character:Q(F6),attributeValue:Q(F6),number:I6,integer:Q(I6),float:Q(I6),bool:Q(P6),regexp:Q(P6),escape:Q(P6),color:Q(P6),url:Q(P6),keyword:z6,self:Q(z6),null:Q(z6),atom:Q(z6),unit:Q(z6),modifier:Q(z6),operatorKeyword:Q(z6),controlKeyword:Q(z6),definitionKeyword:Q(z6),moduleKeyword:Q(z6),operator:B6,derefOperator:Q(B6),arithmeticOperator:Q(B6),logicOperator:Q(B6),bitwiseOperator:Q(B6),compareOperator:Q(B6),updateOperator:Q(B6),definitionOperator:Q(B6),typeOperator:Q(B6),controlOperator:Q(B6),punctuation:V6,separator:Q(V6),bracket:H6,angleBracket:Q(H6),squareBracket:Q(H6),paren:Q(H6),brace:Q(H6),content:L6,heading:R6,heading1:Q(R6),heading2:Q(R6),heading3:Q(R6),heading4:Q(R6),heading5:Q(R6),heading6:Q(R6),contentSeparator:Q(L6),list:Q(L6),quote:Q(L6),emphasis:Q(L6),strong:Q(L6),link:Q(L6),monospace:Q(L6),strikethrough:Q(L6),inserted:Q(),deleted:Q(),changed:Q(),invalid:Q(),meta:U6,documentMeta:Q(U6),annotation:Q(U6),processingInstruction:Q(U6),definition:w6.defineModifier(`definition`),constant:w6.defineModifier(`constant`),function:w6.defineModifier(`function`),standard:w6.defineModifier(`standard`),local:w6.defineModifier(`local`),special:w6.defineModifier(`special`)};for(let e in $){let t=$[e];t instanceof w6&&(t.name=e)}k6([{tag:$.link,class:`tok-link`},{tag:$.heading,class:`tok-heading`},{tag:$.emphasis,class:`tok-emphasis`},{tag:$.strong,class:`tok-strong`},{tag:$.keyword,class:`tok-keyword`},{tag:$.atom,class:`tok-atom`},{tag:$.bool,class:`tok-bool`},{tag:$.url,class:`tok-url`},{tag:$.labelName,class:`tok-labelName`},{tag:$.inserted,class:`tok-inserted`},{tag:$.deleted,class:`tok-deleted`},{tag:$.literal,class:`tok-literal`},{tag:$.string,class:`tok-string`},{tag:$.number,class:`tok-number`},{tag:[$.regexp,$.escape,$.special($.string)],class:`tok-string2`},{tag:$.variableName,class:`tok-variableName`},{tag:$.local($.variableName),class:`tok-variableName tok-local`},{tag:$.definition($.variableName),class:`tok-variableName tok-definition`},{tag:$.special($.variableName),class:`tok-variableName2`},{tag:$.definition($.propertyName),class:`tok-propertyName tok-definition`},{tag:$.typeName,class:`tok-typeName`},{tag:$.namespace,class:`tok-namespace`},{tag:$.className,class:`tok-className`},{tag:$.macroName,class:`tok-macroName`},{tag:$.propertyName,class:`tok-propertyName`},{tag:$.operator,class:`tok-operator`},{tag:$.comment,class:`tok-comment`},{tag:$.meta,class:`tok-meta`},{tag:$.invalid,class:`tok-invalid`},{tag:$.punctuation,class:`tok-punctuation`}]);var W6=new t6;function ASe(e){return Y.define({combine:e?t=>t.concat(e):void 0})}var jSe=new t6,G6=class{constructor(e,t,n=[],r=``){this.data=e,this.name=r,E1.prototype.hasOwnProperty(`tree`)||Object.defineProperty(E1.prototype,"tree",{get(){return q6(this)}}),this.parser=t,this.extension=[$6.of(this),E1.languageData.of((e,t,n)=>{let r=K6(e,t,n),i=r.type.prop(W6);if(!i)return[];let a=e.facet(i),o=r.type.prop(jSe);if(o){let i=r.resolve(t-r.from,n);for(let t of o)if(t.test(i,e)){let n=e.facet(t.facet);return t.type==`replace`?n:n.concat(a)}}return a})].concat(n)}isActiveAt(e,t,n=-1){return K6(e,t,n).type.prop(W6)==this.data}findRegions(e){let t=e.facet($6);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],r=(e,t)=>{if(e.prop(W6)==this.data){n.push({from:t,to:t+e.length});return}let i=e.prop(t6.mounted);if(i){if(i.tree.prop(W6)==this.data){if(i.overlay)for(let e of i.overlay)n.push({from:e.from+t,to:e.to+t});else n.push({from:t,to:t+e.length});return}else if(i.overlay){let e=n.length;if(r(i.tree,i.overlay[0].from+t),n.length>e)return}}for(let n=0;n<e.children.length;n++){let i=e.children[n];i instanceof s6&&r(i,e.positions[n]+t)}};return r(q6(e),0),n}get allowsNesting(){return!0}};G6.setState=v1.define();function K6(e,t,n){let r=e.facet($6),i=q6(e).topNode;if(!r||r.allowsNesting)for(let e=i;e;e=e.enter(t,n,o6.ExcludeBuffers|o6.EnterBracketed))e.type.isTop&&(i=e);return i}var MSe=class e extends G6{constructor(e,t,n){super(e,t,[],n),this.parser=t}static define(t){let n=ASe(t.languageData);return new e(n,t.parser.configure({props:[W6.add(e=>e.isTop?n:void 0)]}),t.name)}configure(t,n){return new e(this.data,this.parser.configure(t),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}};function q6(e){let t=e.field(G6.state,!1);return t?t.tree:s6.empty}var NSe=class{constructor(e){this.doc=e,this.cursorPos=0,this.string=``,this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let n=this.cursorPos-this.string.length;return e<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}},J6=null,PSe=class e{constructor(e,t,n=[],r,i,a,o,s){this.parser=e,this.state=t,this.fragments=n,this.tree=r,this.treeLen=i,this.viewport=a,this.skipped=o,this.scheduleOn=s,this.parse=null,this.tempSkipped=[]}static create(t,n,r){return new e(t,n,[],s6.empty,0,r,[],null)}startParse(){return this.parser.startParse(new NSe(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=s6.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{if(typeof e==`number`){let t=Date.now()+e;e=()=>Date.now()>t}for(this.parse||=this.startParse(),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let n=this.parse.advance();if(n)if(this.fragments=this.withoutTempSkipped(S6.addTree(n,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=this.parse.stoppedAt??this.state.doc.length,this.tree=n,this.parse=null,this.treeLen<(t??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(S6.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=J6;J6=this;try{return e()}finally{J6=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=Y6(e,t.from,t.to);return e}changes(t,n){let{fragments:r,tree:i,treeLen:a,viewport:o,skipped:s}=this;if(this.takeTree(),!t.empty){let e=[];if(t.iterChangedRanges((t,n,r,i)=>e.push({fromA:t,toA:n,fromB:r,toB:i})),r=S6.applyChanges(r,e),i=s6.empty,a=0,o={from:t.mapPos(o.from,-1),to:t.mapPos(o.to,1)},this.skipped.length){s=[];for(let e of this.skipped){let n=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);n<r&&s.push({from:n,to:r})}}}return new e(this.parser,n,r,i,a,o,s,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let t=0;t<this.skipped.length;t++){let{from:n,to:r}=this.skipped[t];n<e.to&&r>e.from&&(this.fragments=Y6(this.fragments,n,r),this.skipped.splice(t--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&=(this.takeTree(),null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends C6{createParse(t,n,r){let i=r[0].from,a=r[r.length-1].to;return{parsedPos:i,advance(){let t=J6;if(t){for(let e of r)t.tempSkipped.push(e);e&&(t.scheduleOn=t.scheduleOn?Promise.all([t.scheduleOn,e]):e)}return this.parsedPos=a,new s6(r6.none,[],[],a-i)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return J6}};function Y6(e,t,n){return S6.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}var X6=class e{constructor(e){this.context=e,this.tree=e.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(t.changes,t.state),r=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new e(n)}static init(t){let n=Math.min(3e3,t.doc.length),r=PSe.create(t.facet($6).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new e(r)}};G6.state=e1.define({create:X6.init,update(e,t){for(let e of t.effects)if(e.is(G6.setState))return e.value;return t.startState.facet($6)==t.state.facet($6)?e.apply(t):X6.init(t.state)}});var Z6=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<`u`&&(Z6=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});var Q6=typeof navigator<`u`&&navigator.scheduling?.isInputPending?()=>navigator.scheduling.isInputPending():null,FSe=w2.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(G6.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(G6.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=Z6(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:r}}=this.view,i=n.field(G6.state);if(i.tree==i.context.tree&&i.context.isDone(r+1e5))return;let a=Date.now()+Math.min(this.chunkBudget,100,e&&!Q6?Math.max(25,e.timeRemaining()-5):1e9),o=i.context.treeLen<r&&n.doc.length>r+1e3,s=i.context.work(()=>Q6&&Q6()||Date.now()>a,r+(o?0:1e5));this.chunkBudget-=Date.now()-t,(s||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:G6.setState.of(new X6(i.context))})),this.chunkBudget>0&&!(s&&!o)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(e){e.scheduleOn&&=(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(e=>x2(this.view.state,e)).then(()=>this.workScheduled--),null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),$6=Y.define({combine(e){return e.length?e[0]:null},enables:e=>[G6.state,FSe,Z.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]}),ISe=class{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}},LSe=Y.define(),e8=Y.define({combine:e=>{if(!e.length)return` `;let t=e[0];if(!t||/\S/.test(t)||Array.from(t).some(e=>e!=t[0]))throw Error(`Invalid indent unit: `+JSON.stringify(e[0]));return t}});function t8(e){let t=e.facet(e8);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function n8(e,t){let n=``,r=e.tabSize,i=e.facet(e8)[0];if(i==` `){for(;t>=r;)n+=` `,t-=r;i=` `}for(let e=0;e<t;e++)n+=i;return n}function r8(e,t){e instanceof E1&&(e=new i8(e));for(let n of e.state.facet(LSe)){let r=n(e,t);if(r!==void 0)return r}let n=q6(e.state);return n.length>=t?RSe(e,n,t):null}var i8=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=t8(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:i}=this.options;return r!=null&&r>=n.from&&r<=n.to?i&&r==e?{text:``,from:e}:(t<0?r<e:r<=e)?{text:n.text.slice(r-n.from),from:r}:{text:n.text.slice(0,r-n.from),from:n.from}:n}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return``;let{text:n,from:r}=this.lineAt(e,t);return n.slice(e-r,Math.min(n.length,e+100-r))}column(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.countColumn(n,e-r),a=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return a>-1&&(i+=a-this.countColumn(n,n.search(/\S|$/))),i}countColumn(e,t=e.length){return W1(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.options.overrideIndentation;if(i){let e=i(r);if(e>-1)return e}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},a8=new t6;function RSe(e,t,n){let r=t.resolveStack(n),i=t.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(i!=r.node){let e=[];for(let t=i;t&&!(t.from<r.node.from||t.to>r.node.to||t.from==r.node.from&&t.type==r.node.type);t=t.parent)e.push(t);for(let t=e.length-1;t>=0;t--)r={node:e[t],next:r}}return o8(r,e,n)}function o8(e,t,n){for(let r=e;r;r=r.next){let e=BSe(r.node);if(e)return e(HSe.create(t,n,r))}return 0}function zSe(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function BSe(e){let t=e.type.prop(a8);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(t6.closedBy))){let t=e.lastChild,n=t&&r.indexOf(t.name)>-1;return e=>GSe(e,!0,1,void 0,n&&!zSe(e)?t.from:void 0)}return e.parent==null?VSe:null}function VSe(){return 0}var HSe=class e extends i8{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.context=n}get node(){return this.context.node}static create(t,n,r){return new e(t,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let n=e.resolve(t.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(USe(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return o8(this.context.next,this.base,this.pos)}};function USe(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function WSe(e){let t=e.node,n=t.childAfter(t.from),r=t.lastChild;if(!n)return null;let i=e.options.simulateBreak,a=e.state.doc.lineAt(n.from),o=i==null||i<=a.from?a.to:Math.min(a.to,i);for(let e=n.to;;){let i=t.childAfter(e);if(!i||i==r)return null;if(!i.type.isSkipped){if(i.from>=o)return null;let e=/^ */.exec(a.text.slice(n.to-a.from))[0].length;return{from:n.from,to:n.to+e}}e=i.to}}function GSe(e,t,n,r,i){let a=e.textAfter,o=a.match(/^\s*/)[0].length,s=r&&a.slice(o,o+r.length)==r||i==e.pos+o,c=t?WSe(e):null;return c?s?e.column(c.from):e.column(c.to):e.baseIndent+(s?0:e.unit*n)}function KSe({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}var qSe=new t6,s8=class e{constructor(e,t){this.specs=e;let n;function r(e){let t=Y1.newName();return(n||=Object.create(null))[`.`+t]=e,t}let i=typeof t.all==`string`?t.all:t.all?r(t.all):void 0,a=t.scope;this.scope=a instanceof G6?e=>e.prop(W6)==a.data:a?e=>e==a:void 0,this.style=k6(e.map(e=>({tag:e.tag,class:e.class||r(Object.assign({},e,{tag:null}))})),{all:i}).style,this.module=n?new Y1(n):null,this.themeType=t.themeType}static define(t,n){return new e(t,n||{})}},c8=Y.define(),l8=Y.define({combine(e){return e.length?[e[0]]:null}});function u8(e){let t=e.facet(c8);return t.length?t:e.facet(l8)}function d8(e,t){let n=[YSe],r;return e instanceof s8&&(e.module&&n.push(Z.styleModule.of(e.module)),r=e.themeType),t?.fallback?n.push(l8.of(e)):r?n.push(c8.computeN([Z.darkTheme],t=>t.facet(Z.darkTheme)==(r==`dark`)?[e]:[])):n.push(c8.of(e)),n}var JSe=class{constructor(e){this.markCache=Object.create(null),this.tree=q6(e.state),this.decorations=this.buildDeco(e,u8(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=q6(e.state),n=u8(e.state),r=n!=u8(e.startState),{viewport:i}=e.view,a=e.changes.mapPos(this.decoratedTo,1);t.length<i.to&&!r&&t.type==this.tree.type&&a>=i.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=a):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=i.to)}buildDeco(e,t){if(!t||!this.tree.length)return b0.none;let n=new N1;for(let{from:r,to:i}of e.visibleRanges)DSe(this.tree,t,(e,t,r)=>{n.add(e,t,this.markCache[r]||(this.markCache[r]=b0.mark({class:r})))},r,i);return n.finish()}},YSe=r1.high(w2.fromClass(JSe,{decorations:e=>e.decorations}));$.meta,$.link,$.heading,$.emphasis,$.strong,$.strikethrough,$.keyword,$.atom,$.bool,$.url,$.contentSeparator,$.labelName,$.literal,$.inserted,$.string,$.deleted,$.regexp,$.escape,$.string,$.variableName,$.variableName,$.typeName,$.namespace,$.className,$.variableName,$.macroName,$.propertyName,$.comment,$.invalid;var XSe=Z.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:`#328c8252`},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:`#bb555544`}}),f8=1e4,p8=`()[]{}`,m8=Y.define({combine(e){return D1(e,{afterCursor:!0,brackets:p8,maxScanDistance:f8,renderMatch:$Se})}}),ZSe=b0.mark({class:`cm-matchingBracket`}),QSe=b0.mark({class:`cm-nonmatchingBracket`});function $Se(e){let t=[],n=e.matched?ZSe:QSe;return t.push(n.range(e.start.from,e.start.to)),e.end&&t.push(n.range(e.end.from,e.end.to)),t}function h8(e){let t=[],n=e.facet(m8);for(let r of e.selection.ranges){if(!r.empty)continue;let i=v8(e,r.head,-1,n)||r.head>0&&v8(e,r.head-1,1,n)||n.afterCursor&&(v8(e,r.head,1,n)||r.head<e.doc.length&&v8(e,r.head+1,-1,n));i&&(t=t.concat(n.renderMatch(i,e)))}return b0.set(t,!0)}var eCe=[w2.fromClass(class{constructor(e){this.paused=!1,this.decorations=h8(e.state)}update(e){(e.docChanged||e.selectionSet||this.paused)&&(e.view.composing?(this.decorations=this.decorations.map(e.changes),this.paused=!0):(this.decorations=h8(e.state),this.paused=!1))}},{decorations:e=>e.decorations}),XSe];function tCe(e={}){return[m8.of(e),eCe]}var nCe=new t6;function g8(e,t,n){let r=e.prop(t<0?t6.openedBy:t6.closedBy);if(r)return r;if(e.name.length==1){let r=n.indexOf(e.name);if(r>-1&&r%2==+(t<0))return[n[r+t]]}return null}function _8(e){let t=e.type.prop(nCe);return t?t(e.node):e}function v8(e,t,n,r={}){let i=r.maxScanDistance||f8,a=r.brackets||p8,o=q6(e),s=o.resolveInner(t,n);for(let r=s;r;r=r.parent){let i=g8(r.type,n,a);if(i&&r.from<r.to){let o=_8(r);if(o&&(n>0?t>=o.from&&t<o.to:t>o.from&&t<=o.to))return rCe(e,t,n,r,o,i,a)}}return iCe(e,t,n,o,s.type,i,a)}function rCe(e,t,n,r,i,a,o){let s=r.parent,c={from:i.from,to:i.to},l=0,u=s?.cursor();if(u&&(n<0?u.childBefore(r.from):u.childAfter(r.to)))do if(n<0?u.to<=r.from:u.from>=r.to){if(l==0&&a.indexOf(u.type.name)>-1&&u.from<u.to){let e=_8(u);return{start:c,end:e?{from:e.from,to:e.to}:void 0,matched:!0}}else if(g8(u.type,n,o))l++;else if(g8(u.type,-n,o)){if(l==0){let e=_8(u);return{start:c,end:e&&e.from<e.to?{from:e.from,to:e.to}:void 0,matched:!1}}l--}}while(n<0?u.prevSibling():u.nextSibling());return{start:c,matched:!1}}function iCe(e,t,n,r,i,a,o){if(n<0?!t:t==e.doc.length)return null;let s=n<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),c=o.indexOf(s);if(c<0||c%2==0!=n>0)return null;let l={from:n<0?t-1:t,to:n>0?t+1:t},u=e.doc.iterRange(t,n>0?e.doc.length:0),d=0;for(let e=0;!u.next().done&&e<=a;){let a=u.value;n<0&&(e+=a.length);let s=t+e*n;for(let e=n>0?0:a.length-1,t=n>0?a.length:-1;e!=t;e+=n){let t=o.indexOf(a[e]);if(!(t<0||r.resolveInner(s+e,1).type!=i))if(t%2==0==n>0)d++;else if(d==1)return{start:l,end:{from:s+e,to:s+e+1},matched:t>>1==c>>1};else d--}n>0&&(e+=a.length)}return u.done?{start:l,matched:!1}:null}var aCe=Object.create(null),y8=[r6.none],b8=[],x8=Object.create(null),oCe=Object.create(null);for(let[e,t]of[[`variable`,`variableName`],[`variable-2`,`variableName.special`],[`string-2`,`string.special`],[`def`,`variableName.definition`],[`tag`,`tagName`],[`attribute`,`attributeName`],[`type`,`typeName`],[`builtin`,`variableName.standard`],[`qualifier`,`modifier`],[`error`,`invalid`],[`header`,`heading`],[`property`,`propertyName`]])oCe[e]=sCe(aCe,t);function S8(e,t){b8.indexOf(e)>-1||(b8.push(e),console.warn(t))}function sCe(e,t){let n=[];for(let r of t.split(` `)){let t=[];for(let n of r.split(`.`)){let r=e[n]||$[n];r?typeof r==`function`?t.length?t=t.map(r):S8(n,`Modifier ${n} used at start of tag`):t.length?S8(n,`Tag ${n} used as modifier`):t=Array.isArray(r)?r:[r]:S8(n,`Unknown highlighting tag ${n}`)}for(let e of t)n.push(e)}if(!n.length)return 0;let r=t.replace(/ /g,`_`),i=r+` `+n.map(e=>e.id),a=x8[i];if(a)return a.id;let o=x8[i]=r6.define({id:y8.length,name:r,props:[E6({[r]:n})]});return y8.push(o),o.id}q0.RTL,q0.LTR;var cCe=class e{constructor(e,t,n,r,i,a,o,s,c,l=0,u){this.p=e,this.stack=t,this.state=n,this.reducePos=r,this.pos=i,this.score=a,this.buffer=o,this.bufferBase=s,this.curContext=c,this.lookAhead=l,this.parent=u}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?`!`+this.score:``}`}static start(t,n,r=0){let i=t.parser.context;return new e(t,[],n,r,r,0,[],0,i?new C8(i,i.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){let t=e>>19,n=e&65535,{parser:r}=this.p,i=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),a=r.dynamicPrecedence(n);if(a&&(this.score+=a),t==0){n<r.minRepeatTerm&&this.reducePos<this.pos&&(this.reducePos=this.pos),this.pushState(r.getGoto(this.state,n,!0),this.reducePos),n<r.minRepeatTerm&&this.storeNode(n,this.reducePos,this.reducePos,i?8:4,!0),this.reduceContext(n,this.reducePos);return}let o=this.stack.length-(t-1)*3-(e&262144?6:0),s=o?this.stack[o-2]:this.p.ranges[0].from;n<r.minRepeatTerm&&s==this.reducePos&&this.reducePos<this.pos&&(this.reducePos=this.pos);let c=this.reducePos-s;c>=2e3&&!this.p.parser.nodeSet.types[n]?.isAnonymous&&(s==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSize<c&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=s,this.p.lastBigReductionSize=c));let l=o?this.stack[o-1]:0,u=this.bufferBase+this.buffer.length-l;if(n<r.minRepeatTerm||e&131072){let e=r.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(n,s,e,u+4,!0)}if(e&262144)this.state=this.stack[o];else{let e=this.stack[o-3];this.state=r.getGoto(e,n,!0)}for(;this.stack.length>o;)this.stack.pop();this.reduceContext(n,s)}storeNode(e,t,n,r=4,i=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let e=this.buffer.length;if(e>0&&this.buffer[e-4]==0&&this.buffer[e-1]>-1){if(t==n)return;if(this.buffer[e-2]>=t){this.buffer[e-2]=n;return}}}if(!i||this.pos==n)this.buffer.push(e,t,n,r);else{let i=this.buffer.length;if(i>0&&(this.buffer[i-4]!=0||this.buffer[i-1]<0)){let e=!1;for(let t=i;t>0&&this.buffer[t-2]>n;t-=4)if(this.buffer[t-1]>=0){e=!0;break}if(e)for(;i>0&&this.buffer[i-2]>n;)this.buffer[i]=this.buffer[i-4],this.buffer[i+1]=this.buffer[i-3],this.buffer[i+2]=this.buffer[i-2],this.buffer[i+3]=this.buffer[i-1],i-=4,r>4&&(r-=4)}this.buffer[i]=e,this.buffer[i+1]=t,this.buffer[i+2]=n,this.buffer[i+3]=r}}shift(e,t,n,r){if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=r,this.shiftContext(t,n),t<=this.p.parser.maxNode&&this.buffer.push(t,n,r,4);else{let i=e,{parser:a}=this.p;this.pos=r;let o=a.stateFlag(i,1);!o&&(r>n||t<=a.maxNode)&&(this.reducePos=r),this.pushState(i,o?n:Math.min(n,this.reducePos)),this.shiftContext(t,n),t<=a.maxNode&&this.buffer.push(t,n,r,4)}}apply(e,t,n,r){e&65536?this.reduce(e):this.shift(e,t,n,r)}useNode(e,t){let n=this.p.reused.length-1;(n<0||this.p.reused[n]!=e)&&(this.p.reused.push(e),n++);let r=this.pos;this.reducePos=this.pos=r+e.length,this.pushState(t,r),this.buffer.push(n,r,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let t=this,n=t.buffer.length;for(n&&t.buffer[n-4]==0&&(n-=4);n>0&&t.buffer[n-2]>t.reducePos;)n-=4;let r=t.buffer.slice(n),i=t.bufferBase+n;for(;t&&i==t.bufferBase;)t=t.parent;return new e(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,r,i,this.curContext,this.lookAhead,t)}recoverByDelete(e,t){let n=e<=this.p.parser.maxNode;n&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,n?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new lCe(this);;){let n=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(n==0)return!1;if(!(n&65536))return!0;t.reduce(n)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let n=[];for(let r=0,i;r<t.length;r+=2)(i=t[r+1])!=this.state&&this.p.parser.hasAction(i,e)&&n.push(t[r],i);if(this.stack.length<120)for(let e=0;n.length<8&&e<t.length;e+=2){let r=t[e+1];n.some((e,t)=>t&1&&e==r)||n.push(t[e],r)}t=n}let n=[];for(let e=0;e<t.length&&n.length<4;e+=2){let r=t[e+1];if(r==this.state)continue;let i=this.split();i.pushState(r,this.pos),i.storeNode(0,i.pos,i.pos,4,!0),i.shiftContext(t[e],this.pos),i.reducePos=this.pos,i.score-=200,n.push(i)}return n}forceReduce(){let{parser:e}=this.p,t=e.stateSlot(this.state,5);if(!(t&65536))return!1;if(!e.validAction(this.state,t)){let n=t>>19,r=t&65535,i=this.stack.length-n*3;if(i<0||e.getGoto(this.stack[i],r,!1)<0){let e=this.findForcedReduction();if(e==null)return!1;t=e}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],n=(r,i)=>{if(!t.includes(r))return t.push(r),e.allActions(r,t=>{if(!(t&393216))if(t&65536){let n=(t>>19)-i;if(n>1){let r=t&65535,i=this.stack.length-n*3;if(i>=0&&e.getGoto(this.stack[i],r,!1)>=0)return n<<19|65536|r}}else{let e=n(t,i+1);if(e!=null)return e}})};return n(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t<this.stack.length;t+=3)if(this.stack[t]!=e.stack[t])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(t)))}reduceContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(t)))}emitContext(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let t=new C8(this.curContext.tracker,e);t.hash!=this.curContext.hash&&this.emitContext(),this.curContext=t}}setLookAhead(e){return e<=this.lookAhead?!1:(this.emitLookAhead(),this.lookAhead=e,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}},C8=class{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}},lCe=class{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,n=e>>19;n==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(n-1)*3;let r=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=r}},uCe=class e{constructor(e,t,n){this.stack=e,this.pos=t,this.index=n,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(t,n=t.bufferBase+t.buffer.length){return new e(t,n,n-t.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}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]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new e(this.stack,this.pos,this.index)}};function w8(e,t=Uint16Array){if(typeof e!=`string`)return e;let n=null;for(let r=0,i=0;r<e.length;){let a=0;for(;;){let t=e.charCodeAt(r++),n=!1;if(t==126){a=65535;break}t>=92&&t--,t>=34&&t--;let i=t-32;if(i>=46&&(i-=46,n=!0),a+=i,n)break;a*=46}n?n[i++]=a:n=new t(a)}return n}var T8=class{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}},E8=new T8,dCe=class{constructor(e,t){this.input=e,this.ranges=t,this.chunk=``,this.chunkOff=0,this.chunk2=``,this.chunk2Pos=0,this.next=-1,this.token=E8,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let n=this.range,r=this.rangeIndex,i=this.pos+e;for(;i<n.from;){if(!r)return null;let e=this.ranges[--r];i-=n.from-e.to,n=e}for(;t<0?i>n.to:i>=n.to;){if(r==this.ranges.length-1)return null;let e=this.ranges[++r];i+=e.from-n.to,n=e}return i}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let t of this.ranges)if(t.to>e)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,n,r;if(t>=0&&t<this.chunk.length)n=this.pos+e,r=this.chunk.charCodeAt(t);else{let t=this.resolveOffset(e,1);if(t==null)return-1;if(n=t,n>=this.chunk2Pos&&n<this.chunk2Pos+this.chunk2.length)r=this.chunk2.charCodeAt(n-this.chunk2Pos);else{let e=this.rangeIndex,t=this.range;for(;t.to<=n;)t=this.ranges[++e];this.chunk2=this.input.chunk(this.chunk2Pos=n),n+this.chunk2.length>t.to&&(this.chunk2=this.chunk2.slice(0,t.to-n)),r=this.chunk2.charCodeAt(0)}}return n>=this.token.lookAhead&&(this.token.lookAhead=n+1),r}acceptToken(e,t=0){let n=t?this.resolveOffset(t,-1):this.pos;if(n==null||n<this.token.start)throw RangeError(`Token end out of bounds`);this.token.value=e,this.token.end=n}acceptTokenTo(e,t){this.token.value=e,this.token.end=t}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:t}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=t,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),t=this.pos+e.length;this.chunk=t>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk=``,this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=E8,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk=``,this.chunkOff=0),this.readNext()}return this}read(e,t){if(e>=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let n=``;for(let r of this.ranges){if(r.from>=t)break;r.to>e&&(n+=this.input.read(Math.max(r.from,e),Math.min(r.to,t)))}return n}},D8=class{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:n}=t.p;O8(this.data,e,t,this.id,n.data,n.tokenPrecTable)}};D8.prototype.contextual=D8.prototype.fallback=D8.prototype.extend=!1;var fCe=class{constructor(e,t,n){this.precTable=t,this.elseToken=n,this.data=typeof e==`string`?w8(e):e}token(e,t){let n=e.pos,r=0;for(;;){let n=e.next<0,i=e.resolveOffset(1,1);if(O8(this.data,e,t,0,this.data,this.precTable),e.token.value>-1)break;if(this.elseToken==null)return;if(n||r++,i==null)break;e.reset(i,e.token)}r&&(e.reset(n,e.token),e.acceptToken(this.elseToken,r))}};fCe.prototype.contextual=D8.prototype.fallback=D8.prototype.extend=!1;var pCe=class{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}};function O8(e,t,n,r,i,a){let o=0,s=1<<r,{dialect:c}=n.p.parser;scan:for(;(s&e[o])!=0;){let n=e[o+1];for(let r=o+3;r<n;r+=2)if((e[r+1]&s)>0){let n=e[r];if(c.allows(n)&&(t.token.value==-1||t.token.value==n||mCe(n,t.token.value,i,a))){t.acceptToken(n);break}}let r=t.next,l=0,u=e[o+2];if(t.next<0&&u>l&&e[n+u*3-3]==65535){o=e[n+u*3-1];continue scan}for(;l<u;){let i=l+u>>1,a=n+i+(i<<1),s=e[a],c=e[a+1]||65536;if(r<s)u=i;else if(r>=c)l=i+1;else{o=e[a+2],t.advance();continue scan}}break}}function k8(e,t,n){for(let r=t,i;(i=e[r])!=65535;r++)if(i==n)return r-t;return-1}function mCe(e,t,n,r){let i=k8(n,r,t);return i<0||k8(n,r,e)<i}var A8=typeof process<`u`&&/\bparse\b/.test({}.LOG),j8=null;function M8(e,t,n){let r=e.cursor(o6.IncludeAnonymous);for(r.moveTo(t);;)if(!(n<0?r.childBefore(t):r.childAfter(t)))for(;;){if((n<0?r.to<t:r.from>t)&&!r.type.isError)return n<0?Math.max(0,Math.min(r.to-1,t-25)):Math.min(e.length,Math.max(r.from+1,t+25));if(n<0?r.prevSibling():r.nextSibling())break;if(!r.parent())return n<0?0:e.length}}var hCe=class{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?M8(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?M8(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let t=this.trees.length-1;if(t<0)return this.nextFragment(),null;let n=this.trees[t],r=this.index[t];if(r==n.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let i=n.children[r],a=this.start[t]+n.positions[r];if(a>e)return this.nextStart=a,null;if(i instanceof s6){if(a==e){if(a<this.safeFrom)return null;let e=a+i.length;if(e<=this.safeTo){let t=i.prop(t6.lookAhead);if(!t||e+t<this.fragment.to)return i}}this.index[t]++,a+i.length>=Math.max(this.safeFrom,e)&&(this.trees.push(i),this.start.push(a),this.index.push(0))}else this.index[t]++,this.nextStart=a+i.length}}},gCe=class{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(e=>new T8)}getActions(e){let t=0,n=null,{parser:r}=e.p,{tokenizers:i}=r,a=r.stateSlot(e.state,3),o=e.curContext?e.curContext.hash:0,s=0;for(let r=0;r<i.length;r++){if(!(1<<r&a))continue;let c=i[r],l=this.tokens[r];if(!(n&&!c.fallback)&&((c.contextual||l.start!=e.pos||l.mask!=a||l.context!=o)&&(this.updateCachedToken(l,c,e),l.mask=a,l.context=o),l.lookAhead>l.end+25&&(s=Math.max(l.lookAhead,s)),l.value!=0)){let r=t;if(l.extended>-1&&(t=this.addActions(e,l.extended,l.end,t)),t=this.addActions(e,l.value,l.end,t),!c.extend&&(n=l,t>r))break}}for(;this.actions.length>t;)this.actions.pop();return s&&e.setLookAhead(s),!n&&e.pos==this.stream.end&&(n=new T8,n.value=e.p.parser.eofTerm,n.start=n.end=e.pos,t=this.addActions(e,n.value,n.end,t)),this.mainToken=n,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new T8,{pos:n,p:r}=e;return t.start=n,t.end=Math.min(n+1,r.stream.end),t.value=n==r.stream.end?r.parser.eofTerm:0,t}updateCachedToken(e,t,n){let r=this.stream.clipPos(n.pos);if(t.token(this.stream.reset(r,e),n),e.value>-1){let{parser:t}=n.p;for(let r=0;r<t.specialized.length;r++)if(t.specialized[r]==e.value){let i=t.specializers[r](this.stream.read(e.start,e.end),n);if(i>=0&&n.p.parser.dialect.allows(i>>1)){i&1?e.extended=i>>1:e.value=i>>1;break}}}else e.value=0,e.end=this.stream.clipPos(r+1)}putAction(e,t,n,r){for(let t=0;t<r;t+=3)if(this.actions[t]==e)return r;return this.actions[r++]=e,this.actions[r++]=t,this.actions[r++]=n,r}addActions(e,t,n,r){let{state:i}=e,{parser:a}=e.p,{data:o}=a;for(let e=0;e<2;e++)for(let s=a.stateSlot(i,e?2:1);;s+=3){if(o[s]==65535)if(o[s+1]==1)s=P8(o,s+2);else{r==0&&o[s+1]==2&&(r=this.putAction(P8(o,s+2),t,n,r));break}o[s]==t&&(r=this.putAction(P8(o,s+1),t,n,r))}return r}},_Ce=class{constructor(e,t,n,r){this.parser=e,this.input=t,this.ranges=r,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new dCe(t,r),this.tokens=new gCe(e,this.stream),this.topTerm=e.top[1];let{from:i}=r[0];this.stacks=[cCe.start(this,e.top[0],i)],this.fragments=n.length&&this.stream.end-i>e.bufferLength*4?new hCe(n,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,n=this.stacks=[],r,i;if(this.bigReductionCount>300&&e.length==1){let[t]=e;for(;t.forceReduce()&&t.stack.length&&t.stack[t.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let a=0;a<e.length;a++){let o=e[a];for(;;){if(this.tokens.mainToken=null,o.pos>t)n.push(o);else if(this.advanceStack(o,n,e))continue;else{r||(r=[],i=[]),r.push(o);let e=this.tokens.getMainToken(o);i.push(e.value,e.end)}break}}if(!n.length){let e=r&&bCe(r);if(e)return A8&&console.log(`Finish with `+this.stackID(e)),this.stackToTree(e);if(this.parser.strict)throw A8&&r&&console.log(`Stuck with token `+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):`none`)),SyntaxError(`No parse at `+t);this.recovering||=5}if(this.recovering&&r){let e=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,i,n);if(e)return A8&&console.log(`Force-finish `+this.stackID(e)),this.stackToTree(e.forceAll())}if(this.recovering){let e=this.recovering==1?1:this.recovering*3;if(n.length>e)for(n.sort((e,t)=>t.score-e.score);n.length>e;)n.pop();n.some(e=>e.reducePos>t)&&this.recovering--}else if(n.length>1){outer:for(let e=0;e<n.length-1;e++){let t=n[e];for(let r=e+1;r<n.length;r++){let i=n[r];if(t.sameState(i)||t.buffer.length>500&&i.buffer.length>500)if((t.score-i.score||t.buffer.length-i.buffer.length)>0)n.splice(r--,1);else{n.splice(e--,1);continue outer}}}n.length>12&&(n.sort((e,t)=>t.score-e.score),n.splice(12,n.length-12))}this.minStackPos=n[0].pos;for(let e=1;e<n.length;e++)n[e].pos<this.minStackPos&&(this.minStackPos=n[e].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw RangeError(`Can't move stoppedAt forward`);this.stoppedAt=e}advanceStack(e,t,n){let r=e.pos,{parser:i}=this,a=A8?this.stackID(e)+` -> `:``;if(this.stoppedAt!=null&&r>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let t=e.curContext&&e.curContext.tracker.strict,n=t?e.curContext.hash:0;for(let o=this.fragments.nodeAt(r);o;){let r=this.parser.nodeSet.types[o.type.id]==o.type?i.getGoto(e.state,o.type.id):-1;if(r>-1&&o.length&&(!t||(o.prop(t6.contextHash)||0)==n))return e.useNode(o,r),A8&&console.log(a+this.stackID(e)+` (via reuse of ${i.getName(o.type.id)})`),!0;if(!(o instanceof s6)||o.children.length==0||o.positions[0]>0)break;let s=o.children[0];if(s instanceof s6&&o.positions[0]==0)o=s;else break}}let o=i.stateSlot(e.state,4);if(o>0)return e.reduce(o),A8&&console.log(a+this.stackID(e)+` (via always-reduce ${i.getName(o&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let s=this.tokens.getActions(e);for(let o=0;o<s.length;){let c=s[o++],l=s[o++],u=s[o++],d=o==s.length||!n,f=d?e:e.split(),p=this.tokens.mainToken;if(f.apply(c,l,p?p.start:f.pos,u),A8&&console.log(a+this.stackID(f)+` (via ${c&65536?`reduce of ${i.getName(c&65535)}`:`shift`} for ${i.getName(l)} @ ${r}${f==e?``:`, split`})`),d)return!0;f.pos>r?t.push(f):n.push(f)}return!1}advanceFully(e,t){let n=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>n)return N8(e,t),!0}}runRecovery(e,t,n){let r=null,i=!1;for(let a=0;a<e.length;a++){let o=e[a],s=t[a<<1],c=t[(a<<1)+1],l=A8?this.stackID(o)+` -> `:``;if(o.deadEnd&&(i||(i=!0,o.restart(),A8&&console.log(l+this.stackID(o)+` (restarted)`),this.advanceFully(o,n))))continue;let u=o.split(),d=l;for(let e=0;e<10&&u.forceReduce()&&(A8&&console.log(d+this.stackID(u)+` (via force-reduce)`),!this.advanceFully(u,n));e++)A8&&(d=this.stackID(u)+` -> `);for(let e of o.recoverByInsert(s))A8&&console.log(l+this.stackID(e)+` (via recover-insert)`),this.advanceFully(e,n);this.stream.end>o.pos?(c==o.pos&&(c++,s=0),o.recoverByDelete(s,c),A8&&console.log(l+this.stackID(o)+` (via recover-delete ${this.parser.getName(s)})`),N8(o,n)):(!r||r.score<u.score)&&(r=u)}return r}stackToTree(e){return e.close(),s6.build({buffer:uCe.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let t=(j8||=new WeakMap).get(e);return t||j8.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}};function N8(e,t){for(let n=0;n<t.length;n++){let r=t[n];if(r.pos==e.pos&&r.sameState(e)){t[n].score<e.score&&(t[n]=e);return}}t.push(e)}var vCe=class{constructor(e,t,n){this.source=e,this.flags=t,this.disabled=n}allows(e){return!this.disabled||this.disabled[e]==0}},yCe=class e extends C6{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(` `);this.minRepeatTerm=t.length;for(let n=0;n<e.repeatNodeCount;n++)t.push(``);let n=Object.keys(e.topRules).map(t=>e.topRules[t][1]),r=[];for(let e=0;e<t.length;e++)r.push([]);function i(e,t,n){r[e].push([t,t.deserialize(String(n))])}if(e.nodeProps)for(let t of e.nodeProps){let e=t[0];typeof e==`string`&&(e=t6[e]);for(let n=1;n<t.length;){let r=t[n++];if(r>=0)i(r,e,t[n++]);else{let a=t[n+-r];for(let o=-r;o>0;o--)i(t[n++],e,a);n++}}}this.nodeSet=new hSe(t.map((t,i)=>r6.define({name:i>=this.minRepeatTerm?void 0:t,id:i,props:r[i],top:n.indexOf(i)>-1,error:i==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(i)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=$3;let a=w8(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let e=0;e<this.specializerSpecs.length;e++)this.specialized[e]=this.specializerSpecs[e].term;this.specializers=this.specializerSpecs.map(F8),this.states=w8(e.states,Uint32Array),this.data=w8(e.stateData),this.goto=w8(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(e=>typeof e==`number`?new D8(a,e):e),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,n){let r=new _Ce(this,e,t,n);for(let i of this.wrappers)r=i(r,e,t,n);return r}getGoto(e,t,n=!1){let r=this.goto;if(t>=r[0])return-1;for(let i=r[t+1];;){let t=r[i++],a=t&1,o=r[i++];if(a&&n)return o;for(let n=i+(t>>1);i<n;i++)if(r[i]==e)return o;if(a)return-1}}hasAction(e,t){let n=this.data;for(let r=0;r<2;r++)for(let i=this.stateSlot(e,r?2:1),a;;i+=3){if((a=n[i])==65535)if(n[i+1]==1)a=n[i=P8(n,i+2)];else if(n[i+1]==2)return P8(n,i+2);else break;if(a==t||a==0)return P8(n,i+1)}return 0}stateSlot(e,t){return this.states[e*6+t]}stateFlag(e,t){return(this.stateSlot(e,0)&t)>0}validAction(e,t){return!!this.allActions(e,e=>e==t?!0:null)}allActions(e,t){let n=this.stateSlot(e,4),r=n?t(n):void 0;for(let n=this.stateSlot(e,1);r==null;n+=3){if(this.data[n]==65535)if(this.data[n+1]==1)n=P8(this.data,n+2);else break;r=t(P8(this.data,n+1))}return r}nextStates(e){let t=[];for(let n=this.stateSlot(e,1);;n+=3){if(this.data[n]==65535)if(this.data[n+1]==1)n=P8(this.data,n+2);else break;if(!(this.data[n+2]&1)){let e=this.data[n+1];t.some((t,n)=>n&1&&t==e)||t.push(this.data[n],e)}}return t}configure(t){let n=Object.assign(Object.create(e.prototype),this);if(t.props&&(n.nodeSet=this.nodeSet.extend(...t.props)),t.top){let e=this.topRules[t.top];if(!e)throw RangeError(`Invalid top rule name ${t.top}`);n.top=e}return t.tokenizers&&(n.tokenizers=this.tokenizers.map(e=>{let n=t.tokenizers.find(t=>t.from==e);return n?n.to:e})),t.specializers&&(n.specializers=this.specializers.slice(),n.specializerSpecs=this.specializerSpecs.map((e,r)=>{let i=t.specializers.find(t=>t.from==e.external);if(!i)return e;let a=Object.assign(Object.assign({},e),{external:i.to});return n.specializers[r]=F8(a),a})),t.contextTracker&&(n.context=t.contextTracker),t.dialect&&(n.dialect=this.parseDialect(t.dialect)),t.strict!=null&&(n.strict=t.strict),t.wrap&&(n.wrappers=n.wrappers.concat(t.wrap)),t.bufferLength!=null&&(n.bufferLength=t.bufferLength),n}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),n=t.map(()=>!1);if(e)for(let r of e.split(` `)){let e=t.indexOf(r);e>=0&&(n[e]=!0)}let r=null;for(let e=0;e<t.length;e++)if(!n[e])for(let n=this.dialects[t[e]],i;(i=this.data[n++])!=65535;)(r||=new Uint8Array(this.maxTerm+1))[i]=1;return new vCe(e,n,r)}static deserialize(t){return new e(t)}};function P8(e,t){return e[t]|e[t+1]<<16}function bCe(e){let t=null;for(let n of e){let e=n.p.stoppedAt;(n.pos==n.p.stream.end||e!=null&&n.pos>e)&&n.p.parser.stateFlag(n.state,2)&&(!t||t.score<n.score)&&(t=n)}return t}function F8(e){if(e.external){let t=+!!e.extend;return(n,r)=>e.external(n,r)<<1|t}return e.get}var I8=class{constructor(e,t,n,r){this.state=e,this.pos=t,this.explicit=n,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=q6(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),r=t.text.slice(n-t.from,this.pos-t.from),i=r.search(V8(e,!1));return i<0?null:{from:n+i,to:this.pos,text:r.slice(i)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,n){e==`abort`&&this.abortListeners&&(this.abortListeners.push(t),n&&n.onDocChange&&(this.abortOnDocChange=!0))}};function L8(e){let t=Object.keys(e).join(``),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,``)),`[${n?`\\w`:``}${t.replace(/[^\w\s]/g,`\\$&`)}]`}function xCe(e){let t=Object.create(null),n=Object.create(null);for(let{label:r}of e){t[r[0]]=!0;for(let e=1;e<r.length;e++)n[r[e]]=!0}let r=L8(t)+L8(n)+`*$`;return[RegExp(`^`+r),new RegExp(r)]}function R8(e){let t=e.map(e=>typeof e==`string`?{label:e}:e),[n,r]=t.every(e=>/^\w+$/.test(e.label))?[/\w*$/,/\w+$/]:xCe(t);return e=>{let i=e.matchBefore(r);return i||e.explicit?{from:i?i.from:e.pos,options:t,validFor:n}:null}}function SCe(e,t){return n=>{for(let t=q6(n.state).resolveInner(n.pos,-1);t;t=t.parent){if(e.indexOf(t.name)>-1)return null;if(t.type.isTop)break}return t(n)}}var z8=class{constructor(e,t,n,r){this.completion=e,this.source=t,this.match=n,this.score=r}};function B8(e){return e.selection.main.from}function V8(e,t){let{source:n}=e,r=t&&n[0]!=`^`,i=n[n.length-1]!=`$`;return!r&&!i?e:RegExp(`${r?`^`:``}(?:${n})${i?`$`:``}`,e.flags??(e.ignoreCase?`i`:``))}var H8=_1.define();function CCe(e,t,n,r){let{main:i}=e.selection,a=n-i.from,o=r-i.from;return{...e.changeByRange(s=>{if(s!=i&&n!=r&&e.sliceDoc(s.from+a,s.from+o)!=e.sliceDoc(n,r))return{range:s};let c=e.toText(t);return{changes:{from:s.from+a,to:r==i.from?s.to:s.from+o,insert:c},range:J.cursor(s.from+a+c.length)}}),scrollIntoView:!0,userEvent:`input.complete`}}var U8=new WeakMap;function wCe(e){if(!Array.isArray(e))return e;let t=U8.get(e);return t||U8.set(e,t=R8(e)),t}var W8=v1.define(),G8=v1.define(),TCe=class{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let n=N$(e,t),r=F$(n);this.chars.push(n);let i=e.slice(t,t+r),a=i.toUpperCase();this.folded.push(N$(a==i?i.toLowerCase():a,0)),t+=r}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:n,any:r,precise:i,byWord:a}=this;if(t.length==1){let r=N$(e,0),i=F$(r),a=i==e.length?0:-100;if(r!=t[0])if(r==n[0])a+=-200;else return null;return this.ret(a,[0,i])}let o=e.indexOf(this.pattern);if(o==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let s=t.length,c=0;if(o<0){for(let i=0,a=Math.min(e.length,200);i<a&&c<s;){let a=N$(e,i);(a==t[c]||a==n[c])&&(r[c++]=i),i+=F$(a)}if(c<s)return null}let l=0,u=0,d=!1,f=0,p=-1,m=-1,h=/[a-z]/.test(e),g=!0;for(let r=0,c=Math.min(e.length,200),_=0;r<c&&u<s;){let c=N$(e,r);o<0&&(l<s&&c==t[l]&&(i[l++]=r),f<s&&(c==t[f]||c==n[f]?(f==0&&(p=r),m=r+1,f++):f=0));let v,y=c<255?c>=48&&c<=57||c>=97&&c<=122?2:+(c>=65&&c<=90):(v=P$(c))==v.toLowerCase()?v==v.toUpperCase()?0:2:1;(!r||y==1&&h||_==0&&y!=0)&&(t[u]==c||n[u]==c&&(d=!0)?a[u++]=r:a.length&&(g=!1)),_=y,r+=F$(c)}return u==s&&a[0]==0&&g?this.result(-100+(d?-200:0),a,e):f==s&&p==0?this.ret(-200-e.length+(m==e.length?0:-100),[0,m]):o>-1?this.ret(-700-e.length,[o,o+this.pattern.length]):f==s?this.ret(-900-e.length,[p,m]):u==s?this.result(-100+(d?-200:0)+-700+(g?0:-1100),a,e):t.length==2?null:this.result((r[0]?-700:0)+-200+-1100,r,e)}result(e,t,n){let r=[],i=0;for(let e of t){let t=e+(this.astral?F$(N$(n,e)):1);i&&r[i-1]==e?r[i-1]=t:(r[i++]=e,r[i++]=t)}return this.ret(e-n.length,r)}},ECe=class{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let t=e.slice(0,this.pattern.length),n=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return n==null?null:(this.matched=[0,t.length],this.score=n+(e.length==this.pattern.length?0:-100),this)}},K8=Y.define({combine(e){return D1(e,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>``,optionClass:()=>``,aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:DCe,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>n=>q8(e(n),t(n)),optionClass:(e,t)=>n=>q8(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function q8(e,t){return e?t?e+` `+t:e:t}function DCe(e,t,n,r,i,a){let o=e.textDirection==q0.RTL,s=o,c=!1,l=`top`,u,d,f=t.left-i.left,p=i.right-t.right,m=r.right-r.left,h=r.bottom-r.top;if(s&&f<Math.min(m,p)?s=!1:!s&&p<Math.min(m,f)&&(s=!0),m<=(s?f:p))u=Math.max(i.top,Math.min(n.top,i.bottom-h))-t.top,d=Math.min(400,s?f:p);else{c=!0,d=Math.min(400,(o?t.right:i.right-t.left)-30);let e=i.bottom-t.bottom;e>=h||e>t.top?u=n.bottom-t.top:(l=`bottom`,u=t.bottom-n.top)}let g=(t.bottom-t.top)/a.offsetHeight,_=(t.right-t.left)/a.offsetWidth;return{style:`${l}: ${u/g}px; max-width: ${d/_}px`,class:`cm-completionInfo-`+(c?o?`left-narrow`:`right-narrow`:s?`left`:`right`)}}var J8=v1.define();function OCe(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(e){let t=document.createElement(`div`);return t.classList.add(`cm-completionIcon`),e.type&&t.classList.add(...e.type.split(/\s+/g).map(e=>`cm-completionIcon-`+e)),t.setAttribute(`aria-hidden`,`true`),t},position:20}),t.push({render(e,t,n,r){let i=document.createElement(`span`);i.className=`cm-completionLabel`;let a=e.displayLabel||e.label,o=0;for(let e=0;e<r.length;){let t=r[e++],n=r[e++];t>o&&i.appendChild(document.createTextNode(a.slice(o,t)));let s=i.appendChild(document.createElement(`span`));s.appendChild(document.createTextNode(a.slice(t,n))),s.className=`cm-completionMatchedText`,o=n}return o<a.length&&i.appendChild(document.createTextNode(a.slice(o))),i},position:50},{render(e){if(!e.detail)return null;let t=document.createElement(`span`);return t.className=`cm-completionDetail`,t.textContent=e.detail,t},position:80}),t.sort((e,t)=>e.position-t.position).map(e=>e.render)}function Y8(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let e=Math.floor(t/n);return{from:e*n,to:(e+1)*n}}let r=Math.ceil((e-t)/n);return{from:e-r*n,to:e-(r-1)*n}}var kCe=class{constructor(e,t,n){this.view=e,this.stateField=t,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:e=>this.placeInfo(e),key:this},this.space=null,this.currentClass=``;let r=e.state.field(t),{options:i,selected:a}=r.open,o=e.state.facet(K8);this.optionContent=OCe(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=Y8(i.length,a,o.maxRenderedOptions),this.dom=document.createElement(`div`),this.dom.className=`cm-tooltip-autocomplete`,this.updateTooltipClass(e.state),this.dom.addEventListener(`mousedown`,n=>{let{options:r}=e.state.field(t).open;for(let t=n.target,i;t&&t!=this.dom;t=t.parentNode)if(t.nodeName==`LI`&&(i=/-(\d+)$/.exec(t.id))&&+i[1]<r.length){this.applyCompletion(e,r[+i[1]]),n.preventDefault();return}if(n.target==this.list){let t=this.list.classList.contains(`cm-completionListIncompleteTop`)&&n.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains(`cm-completionListIncompleteBottom`)&&n.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;t!=null&&(e.dispatch({effects:J8.of(t)}),n.preventDefault())}}),this.dom.addEventListener(`focusout`,t=>{let n=e.state.field(this.stateField,!1);n&&n.tooltip&&e.state.facet(K8).closeOnBlur&&t.relatedTarget!=e.contentDOM&&e.dispatch({effects:G8.of(null)})}),this.showOptions(i,r.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener(`scroll`,()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){let t=e.state.field(this.stateField),n=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),t!=n){let{options:r,selected:i,disabled:a}=t.open;(!n.open||n.open.options!=r)&&(this.range=Y8(r.length,i,e.state.facet(K8).maxRenderedOptions),this.showOptions(r,t.id)),this.updateSel(),a!=n.open?.disabled&&this.dom.classList.toggle(`cm-tooltip-autocomplete-disabled`,!!a)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let e of this.currentClass.split(` `))e&&this.dom.classList.remove(e);for(let e of t.split(` `))e&&this.dom.classList.add(e);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=Y8(t.options.length,t.selected,this.view.state.facet(K8).maxRenderedOptions),this.showOptions(t.options,e.id));let n=this.updateSelectedOption(t.selected);if(n){this.destroyInfo();let{completion:r}=t.options[t.selected],{info:i}=r;if(!i)return;let a=typeof i==`string`?document.createTextNode(i):i(r);if(!a)return;`then`in a?a.then(t=>{t&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(t,r)}).catch(e=>x2(this.view.state,e,`completion info`)):(this.addInfoPane(a,r),n.setAttribute(`aria-describedby`,this.info.id))}}addInfoPane(e,t){this.destroyInfo();let n=this.info=document.createElement(`div`);if(n.className=`cm-tooltip cm-completionInfo`,n.id=`cm-completionInfo-`+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)n.appendChild(e),this.infoDestroy=null;else{let{dom:t,destroy:r}=e;n.appendChild(t),this.infoDestroy=r||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let n=this.list.firstChild,r=this.range.from;n;n=n.nextSibling,r++)n.nodeName!=`LI`||!n.id?r--:r==e?n.hasAttribute(`aria-selected`)||(n.setAttribute(`aria-selected`,`true`),t=n):n.hasAttribute(`aria-selected`)&&(n.removeAttribute(`aria-selected`),n.removeAttribute(`aria-describedby`));return t&&jCe(this.list,t),t}measureInfo(){let e=this.dom.querySelector(`[aria-selected]`);if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),r=e.getBoundingClientRect(),i=this.space;if(!i){let e=this.dom.ownerDocument.documentElement;i={left:0,top:0,right:e.clientWidth,bottom:e.clientHeight}}return r.top>Math.min(i.bottom,t.bottom)-10||r.bottom<Math.max(i.top,t.top)+10?null:this.view.state.facet(K8).positionInfo(this.view,t,r,n,i,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className=`cm-tooltip cm-completionInfo `+(e.class||``)):this.info.style.cssText=`top: -1e6px`)}createListBox(e,t,n){let r=document.createElement(`ul`);r.id=t,r.setAttribute(`role`,`listbox`),r.setAttribute(`aria-expanded`,`true`),r.setAttribute(`aria-label`,this.view.state.phrase(`Completions`)),r.addEventListener(`mousedown`,e=>{e.target==r&&e.preventDefault()});let i=null;for(let a=n.from;a<n.to;a++){let{completion:o,match:s}=e[a],{section:c}=o;if(c){let e=typeof c==`string`?c:c.name;if(e!=i&&(a>n.from||n.from==0))if(i=e,typeof c!=`string`&&c.header)r.appendChild(c.header(c));else{let t=r.appendChild(document.createElement(`completion-section`));t.textContent=e}}let l=r.appendChild(document.createElement(`li`));l.id=t+`-`+a,l.setAttribute(`role`,`option`);let u=this.optionClass(o);u&&(l.className=u);for(let e of this.optionContent){let t=e(o,this.view.state,this.view,s);t&&l.appendChild(t)}}return n.from&&r.classList.add(`cm-completionListIncompleteTop`),n.to<e.length&&r.classList.add(`cm-completionListIncompleteBottom`),r}destroyInfo(){this.info&&=(this.infoDestroy&&this.infoDestroy(),this.info.remove(),null)}destroy(){this.destroyInfo()}};function ACe(e,t){return n=>new kCe(n,e,t)}function jCe(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=n.height/e.offsetHeight;r.top<n.top?e.scrollTop-=(n.top-r.top)/i:r.bottom>n.bottom&&(e.scrollTop+=(r.bottom-n.bottom)/i)}function X8(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+ +!!e.type}function MCe(e,t){let n=[],r=null,i=null,a=e=>{n.push(e);let{section:t}=e.completion;if(t){r||=[];let e=typeof t==`string`?t:t.name;r.some(t=>t.name==e)||r.push(typeof t==`string`?{name:e}:t)}},o=t.facet(K8);for(let r of e)if(r.hasResult()){let e=r.result.getMatch;if(r.result.filter===!1)for(let t of r.result.options)a(new z8(t,r.source,e?e(t):[],1e9-n.length));else{let n=t.sliceDoc(r.from,r.to),s,c=o.filterStrict?new ECe(n):new TCe(n);for(let t of r.result.options)if(s=c.match(t.label)){let n=t.displayLabel?e?e(t,s.matched):[]:s.matched,o=s.score+(t.boost||0);if(a(new z8(t,r.source,n,o)),typeof t.section==`object`&&t.section.rank===`dynamic`){let{name:e}=t.section;i||=Object.create(null),i[e]=Math.max(o,i[e]||-1e9)}}}}if(r){let e=Object.create(null),t=0,a=(e,t)=>(e.rank===`dynamic`&&t.rank===`dynamic`?i[t.name]-i[e.name]:0)||(typeof e.rank==`number`?e.rank:1e9)-(typeof t.rank==`number`?t.rank:1e9)||(e.name<t.name?-1:1);for(let n of r.sort(a))t-=1e5,e[n.name]=t;for(let t of n){let{section:n}=t.completion;n&&(t.score+=e[typeof n==`string`?n:n.name])}}let s=[],c=null,l=o.compareCompletions;for(let e of n.sort((e,t)=>t.score-e.score||l(e.completion,t.completion))){let t=e.completion;!c||c.label!=t.label||c.detail!=t.detail||c.type!=null&&t.type!=null&&c.type!=t.type||c.apply!=t.apply||c.boost!=t.boost?s.push(e):X8(e.completion)>X8(c)&&(s[s.length-1]=e),c=e.completion}return s}var NCe=class e{constructor(e,t,n,r,i,a){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=r,this.selected=i,this.disabled=a}setSelected(t,n){return t==this.selected||t>=this.options.length?this:new e(this.options,Z8(n,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,n,r,i,a,o){if(i&&!o&&t.some(e=>e.isPending))return i.setDisabled();let s=MCe(t,n);if(!s.length)return i&&t.some(e=>e.isPending)?i.setDisabled():null;let c=n.facet(K8).selectOnOpen?0:-1;if(i&&i.selected!=c&&i.selected!=-1){let e=i.options[i.selected].completion;for(let t=0;t<s.length;t++)if(s[t].completion==e){c=t;break}}return new e(s,Z8(r,c),{pos:t.reduce((e,t)=>t.hasResult()?Math.min(e,t.from):e,1e8),create:BCe,above:a.aboveCursor},i?i.timestamp:Date.now(),c,!1)}map(t){return new e(this.options,this.attrs,{...this.tooltip,pos:t.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new e(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}},PCe=class e{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new e(RCe,`cm-ac-`+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(K8),i=(r.override||n.languageDataAt(`autocomplete`,B8(n)).map(wCe)).map(e=>(this.active.find(t=>t.source==e)||new $8(e,+!!this.active.some(e=>e.state!=0))).update(t,r));i.length==this.active.length&&i.every((e,t)=>e==this.active[t])&&(i=this.active);let a=this.open,o=t.effects.some(e=>e.is(t5));a&&t.docChanged&&(a=a.map(t.changes)),t.selection||i.some(e=>e.hasResult()&&t.changes.touchesRange(e.from,e.to))||!FCe(i,this.active)||o?a=NCe.build(i,n,this.id,a,r,o):a&&a.disabled&&!i.some(e=>e.isPending)&&(a=null),!a&&i.every(e=>!e.isPending)&&i.some(e=>e.hasResult())&&(i=i.map(e=>e.hasResult()?new $8(e.source,0):e));for(let e of t.effects)e.is(J8)&&(a&&=a.setSelected(e.value,this.id));return i==this.active&&a==this.open?this:new e(i,this.id,a)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?ICe:LCe}};function FCe(e,t){if(e==t)return!0;for(let n=0,r=0;;){for(;n<e.length&&!e[n].hasResult();)n++;for(;r<t.length&&!t[r].hasResult();)r++;let i=n==e.length,a=r==t.length;if(i||a)return i==a;if(e[n++].result!=t[r++].result)return!1}}var ICe={"aria-autocomplete":`list`},LCe={};function Z8(e,t){let n={"aria-autocomplete":`list`,"aria-haspopup":`listbox`,"aria-controls":e};return t>-1&&(n[`aria-activedescendant`]=e+`-`+t),n}var RCe=[];function Q8(e,t){if(e.isUserEvent(`input.complete`)){let n=e.annotation(H8);if(n&&t.activateOnCompletion(n))return 12}let n=e.isUserEvent(`input.type`);return n&&t.activateOnTyping?5:n?1:e.isUserEvent(`delete.backward`)?2:e.selection?8:e.docChanged?16:0}var $8=class e{constructor(e,t,n=!1){this.source=e,this.state=t,this.explicit=n}hasResult(){return!1}get isPending(){return this.state==1}update(t,n){let r=Q8(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new e(i.source,0)),r&4&&i.state==0&&(i=new e(this.source,1)),i=i.updateFor(t,r);for(let n of t.effects)if(n.is(W8))i=new e(i.source,1,n.value);else if(n.is(G8))i=new e(i.source,0);else if(n.is(t5))for(let e of n.value)e.source==i.source&&(i=e);return i}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(B8(e.state))}},e5=class e extends $8{constructor(e,t,n,r,i,a){super(e,3,t),this.limit=n,this.result=r,this.from=i,this.to=a}hasResult(){return!0}updateFor(t,n){if(!(n&3))return this.map(t.changes);let r=this.result;r.map&&!t.changes.empty&&(r=r.map(r,t.changes));let i=t.changes.mapPos(this.from),a=t.changes.mapPos(this.to,1),o=B8(t.state);if(o>a||!r||n&2&&(B8(t.startState)==this.from||o<this.limit))return new $8(this.source,n&4?1:0);let s=t.changes.mapPos(this.limit);return zCe(r.validFor,t.state,i,a)?new e(this.source,this.explicit,s,r,i,a):r.update&&(r=r.update(r,i,a,new I8(t.state,o,!1)))?new e(this.source,this.explicit,s,r,r.from,r.to??B8(t.state)):new $8(this.source,1,this.explicit)}map(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new e(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new $8(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}};function zCe(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e==`function`?e(i,n,r,t):V8(e,!0).test(i)}var t5=v1.define({map(e,t){return e.map(e=>e.map(t))}}),n5=e1.define({create(){return PCe.start()},update(e,t){return e.update(t)},provide:e=>[A3.from(e,e=>e.tooltip),Z.contentAttributes.from(e,e=>e.attrs)]});function r5(e,t){let n=t.completion.apply||t.completion.label,r=e.state.field(n5).active.find(e=>e.source==t.source);return r instanceof e5?(typeof n==`string`?e.dispatch({...CCe(e.state,n,r.from,r.to),annotations:H8.of(t.completion)}):n(e,t.completion,r.from,r.to),!0):!1}var BCe=ACe(n5,r5);function i5(e,t=`option`){return n=>{let r=n.state.field(n5,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(K8).interactionDelay)return!1;let i=1,a;t==`page`&&(a=j3(n,r.open.tooltip))&&(i=Math.max(2,Math.floor(a.dom.offsetHeight/a.dom.querySelector(`li`).offsetHeight)-1));let{length:o}=r.open.options,s=r.open.selected>-1?r.open.selected+i*(e?1:-1):e?0:o-1;return s<0?s=t==`page`?0:o-1:s>=o&&(s=t==`page`?o-1:0),n.dispatch({effects:J8.of(s)}),!0}}var VCe=e=>{let t=e.state.field(n5,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(K8).interactionDelay?!1:r5(e,t.open.options[t.open.selected])},a5=e=>e.state.field(n5,!1)?(e.dispatch({effects:W8.of(!0)}),!0):!1,HCe=e=>{let t=e.state.field(n5,!1);return!t||!t.active.some(e=>e.state!=0)?!1:(e.dispatch({effects:G8.of(null)}),!0)},UCe=class{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}},WCe=50,GCe=1e3,KCe=w2.fromClass(class{constructor(e){this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let t of e.state.field(n5).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(n5),n=e.state.facet(K8);if(!e.selectionSet&&!e.docChanged&&e.startState.field(n5)==t)return;let r=e.transactions.some(e=>{let t=Q8(e,n);return t&8||(e.selection||e.docChanged)&&!(t&3)});for(let t=0;t<this.running.length;t++){let n=this.running[t];if(r||n.context.abortOnDocChange&&e.docChanged||n.updates.length+e.transactions.length>WCe&&Date.now()-n.time>GCe){for(let e of n.context.abortListeners)try{e()}catch(e){x2(this.view.state,e)}n.context.abortListeners=null,this.running.splice(t--,1)}else n.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(e=>e.effects.some(e=>e.is(W8)))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(e=>e.isPending&&!this.running.some(t=>t.active.source==e.source))?setTimeout(()=>this.startUpdate(),i):-1,this.composing!=0)for(let t of e.transactions)t.isUserEvent(`input.type`)?this.composing=2:this.composing==2&&t.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(n5);for(let e of t.active)e.isPending&&!this.running.some(t=>t.active.source==e.source)&&this.startQuery(e);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(K8).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=new I8(t,B8(t),e.explicit,this.view),r=new UCe(e,n);this.running.push(r),Promise.resolve(e.source(n)).then(e=>{r.context.aborted||(r.done=e||null,this.scheduleAccept())},e=>{this.view.dispatch({effects:G8.of(null)}),x2(this.view.state,e)})}scheduleAccept(){this.running.every(e=>e.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(K8).updateSyncTime))}accept(){this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(K8),n=this.view.state.field(n5);for(let r=0;r<this.running.length;r++){let i=this.running[r];if(i.done===void 0)continue;if(this.running.splice(r--,1),i.done){let n=B8(i.updates.length?i.updates[0].startState:this.view.state),r=Math.min(n,i.done.from+ +!i.active.explicit),a=new e5(i.active.source,i.active.explicit,r,i.done,i.done.from,i.done.to??n);for(let e of i.updates)a=a.update(e,t);if(a.hasResult()){e.push(a);continue}}let a=n.active.find(e=>e.source==i.active.source);if(a&&a.isPending)if(i.done==null){let n=new $8(i.active.source,0);for(let e of i.updates)n=n.update(e,t);n.isPending||e.push(n)}else this.startQuery(a)}(e.length||n.open&&n.open.disabled)&&this.view.dispatch({effects:t5.of(e)})}},{eventHandlers:{blur(e){let t=this.view.state.field(n5,!1);if(t&&t.tooltip&&this.view.state.facet(K8).closeOnBlur){let n=t.open&&j3(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:G8.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:W8.of(!1)}),20),this.composing=0}}}),qCe=typeof navigator==`object`&&/Win/.test(navigator.platform),JCe=r1.highest(Z.domEventHandlers({keydown(e,t){let n=t.state.field(n5,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(qCe&&e.altKey)||e.metaKey)return!1;let r=n.open.options[n.open.selected],i=n.active.find(e=>e.source==r.source),a=r.completion.commitCharacters||i.result.commitCharacters;return a&&a.indexOf(e.key)>-1&&r5(t,r),!1}})),YCe=Z.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:`monospace`,whiteSpace:`nowrap`,overflow:`hidden auto`,maxWidth_fallback:`700px`,maxWidth:`min(700px, 95vw)`,minWidth:`250px`,maxHeight:`10em`,height:`100%`,listStyle:`none`,margin:0,padding:0,"& > li, & > completion-section":{padding:`1px 3px`,lineHeight:1.2},"& > li":{overflowX:`hidden`,textOverflow:`ellipsis`,cursor:`pointer`},"& > completion-section":{display:`list-item`,borderBottom:`1px solid silver`,paddingLeft:`0.5em`,opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:`#17c`,color:`white`},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:`#777`},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:`#347`,color:`white`},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:`#444`},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:`"···"`,opacity:.5,display:`block`,textAlign:`center`,cursor:`pointer`},".cm-tooltip.cm-completionInfo":{position:`absolute`,padding:`3px 9px`,width:`max-content`,maxWidth:`400px`,boxSizing:`border-box`,whiteSpace:`pre-line`},".cm-completionInfo.cm-completionInfo-left":{right:`100%`},".cm-completionInfo.cm-completionInfo-right":{left:`100%`},".cm-completionInfo.cm-completionInfo-left-narrow":{right:`30px`},".cm-completionInfo.cm-completionInfo-right-narrow":{left:`30px`},"&light .cm-snippetField":{backgroundColor:`#00000022`},"&dark .cm-snippetField":{backgroundColor:`#ffffff22`},".cm-snippetFieldPosition":{verticalAlign:`text-top`,width:0,height:`1.15em`,display:`inline-block`,margin:`0 -0.7px -.7em`,borderLeft:`1.4px dotted #888`},".cm-completionMatchedText":{textDecoration:`underline`},".cm-completionDetail":{marginLeft:`0.5em`,fontStyle:`italic`},".cm-completionIcon":{fontSize:`90%`,width:`.8em`,display:`inline-block`,textAlign:`center`,paddingRight:`.6em`,opacity:`0.6`,boxSizing:`content-box`},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:`'ƒ'`}},".cm-completionIcon-class":{"&:after":{content:`'○'`}},".cm-completionIcon-interface":{"&:after":{content:`'◌'`}},".cm-completionIcon-variable":{"&:after":{content:`'𝑥'`}},".cm-completionIcon-constant":{"&:after":{content:`'𝐶'`}},".cm-completionIcon-type":{"&:after":{content:`'𝑡'`}},".cm-completionIcon-enum":{"&:after":{content:`'∪'`}},".cm-completionIcon-property":{"&:after":{content:`'□'`}},".cm-completionIcon-keyword":{"&:after":{content:`'🔑︎'`}},".cm-completionIcon-namespace":{"&:after":{content:`'▢'`}},".cm-completionIcon-text":{"&:after":{content:`'abc'`,fontSize:`50%`,verticalAlign:`middle`}}}),o5={brackets:[`(`,`[`,`{`,`'`,`"`],before:`)]}:;>`,stringPrefixes:[]},s5=v1.define({map(e,t){return t.mapPos(e,-1,L$.TrackAfter)??void 0}}),c5=new class extends O1{};c5.startSide=1,c5.endSide=-1;var l5=e1.define({create(){return M1.empty},update(e,t){if(e=e.map(t.changes),t.selection){let n=t.state.doc.lineAt(t.selection.main.head);e=e.update({filter:e=>e>=n.from&&e<=n.to})}for(let n of t.effects)n.is(s5)&&(e=e.update({add:[c5.range(n.value,n.value+1)]}));return e}});function XCe(){return[QCe,l5]}var u5=`()[]{}<>«»»«[]{}`;function d5(e){for(let t=0;t<16;t+=2)if(u5.charCodeAt(t)==e)return u5.charAt(t+1);return P$(e<128?e:e+1)}function f5(e,t){return e.languageDataAt(`closeBrackets`,t)[0]||o5}var ZCe=typeof navigator==`object`&&/Android\b/.test(navigator.userAgent),QCe=Z.inputHandler.of((e,t,n,r)=>{if((ZCe?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&F$(N$(r,0))==1||t!=i.from||n!=i.to)return!1;let a=ewe(e.state,r);return a?(e.dispatch(a),!0):!1}),$Ce=[{key:`Backspace`,run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=f5(e,e.selection.main.head).brackets||o5.brackets,r=null,i=e.changeByRange(t=>{if(t.empty){let r=twe(e.doc,t.head);for(let i of n)if(i==r&&m5(e.doc,t.head)==d5(N$(i,0)))return{changes:{from:t.head-i.length,to:t.head+i.length},range:J.cursor(t.head-i.length)}}return{range:r=t}});return r||t(e.update(i,{scrollIntoView:!0,userEvent:`delete.backward`})),!r}}];function ewe(e,t){let n=f5(e,e.selection.main.head),r=n.brackets||o5.brackets;for(let i of r){let a=d5(N$(i,0));if(t==i)return a==i?iwe(e,i,r.indexOf(i+i+i)>-1,n):nwe(e,i,a,n.before||o5.before);if(t==a&&p5(e,e.selection.main.from))return rwe(e,i,a)}return null}function p5(e,t){let n=!1;return e.field(l5).between(0,e.doc.length,e=>{e==t&&(n=!0)}),n}function m5(e,t){let n=e.sliceString(t,t+2);return n.slice(0,F$(N$(n,0)))}function twe(e,t){let n=e.sliceString(t-2,t);return F$(N$(n,0))==n.length?n:n.slice(1)}function nwe(e,t,n,r){let i=null,a=e.changeByRange(a=>{if(!a.empty)return{changes:[{insert:t,from:a.from},{insert:n,from:a.to}],effects:s5.of(a.to+t.length),range:J.range(a.anchor+t.length,a.head+t.length)};let o=m5(e.doc,a.head);return!o||/\s/.test(o)||r.indexOf(o)>-1?{changes:{insert:t+n,from:a.head},effects:s5.of(a.head+t.length),range:J.cursor(a.head+t.length)}:{range:i=a}});return i?null:e.update(a,{scrollIntoView:!0,userEvent:`input.type`})}function rwe(e,t,n){let r=null,i=e.changeByRange(t=>t.empty&&m5(e.doc,t.head)==n?{changes:{from:t.head,to:t.head+n.length,insert:n},range:J.cursor(t.head+n.length)}:r={range:t});return r?null:e.update(i,{scrollIntoView:!0,userEvent:`input.type`})}function iwe(e,t,n,r){let i=r.stringPrefixes||o5.stringPrefixes,a=null,o=e.changeByRange(r=>{if(!r.empty)return{changes:[{insert:t,from:r.from},{insert:t,from:r.to}],effects:s5.of(r.to+t.length),range:J.range(r.anchor+t.length,r.head+t.length)};let o=r.head,s=m5(e.doc,o),c;if(s==t){if(h5(e,o))return{changes:{insert:t+t,from:o},effects:s5.of(o+t.length),range:J.cursor(o+t.length)};if(p5(e,o)){let r=n&&e.sliceDoc(o,o+t.length*3)==t+t+t?t+t+t:t;return{changes:{from:o,to:o+r.length,insert:r},range:J.cursor(o+r.length)}}}else if(n&&e.sliceDoc(o-2*t.length,o)==t+t&&(c=g5(e,o-2*t.length,i))>-1&&h5(e,c))return{changes:{insert:t+t+t+t,from:o},effects:s5.of(o+t.length),range:J.cursor(o+t.length)};else if(e.charCategorizer(o)(s)!=w1.Word&&g5(e,o,i)>-1&&!awe(e,o,t,i))return{changes:{insert:t+t,from:o},effects:s5.of(o+t.length),range:J.cursor(o+t.length)};return{range:a=r}});return a?null:e.update(o,{scrollIntoView:!0,userEvent:`input.type`})}function h5(e,t){let n=q6(e).resolveInner(t+1);return n.parent&&n.from==t}function awe(e,t,n,r){let i=q6(e).resolveInner(t,-1),a=r.reduce((e,t)=>Math.max(e,t.length),0);for(let o=0;o<5;o++){let o=e.sliceDoc(i.from,Math.min(i.to,i.from+n.length+a)),s=o.indexOf(n);if(!s||s>-1&&r.indexOf(o.slice(0,s))>-1){let t=i.firstChild;for(;t&&t.from==i.from&&t.to-t.from>n.length+s;){if(e.sliceDoc(t.to-n.length,t.to)==n)return!1;t=t.firstChild}return!0}let c=i.to==t&&i.parent;if(!c)break;i=c}return!1}function g5(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=w1.Word)return t;for(let i of n){let n=t-i.length;if(e.sliceDoc(n,t)==i&&r(e.sliceDoc(n-1,n))!=w1.Word)return n}return-1}function _5(e={}){return[JCe,n5,K8.of(e),KCe,swe,YCe]}var owe=[{key:`Ctrl-Space`,run:a5},{mac:"Alt-`",run:a5},{mac:`Alt-i`,run:a5},{key:`Escape`,run:HCe},{key:`ArrowDown`,run:i5(!0)},{key:`ArrowUp`,run:i5(!1)},{key:`PageDown`,run:i5(!0,`page`)},{key:`PageUp`,run:i5(!1,`page`)},{key:`Enter`,run:VCe}],swe=r1.highest(y3.computeN([K8],e=>e.facet(K8).defaultKeymap?[owe]:[])),cwe=36,v5=1,lwe=2,y5=3,b5=4,uwe=5,dwe=6,fwe=7,pwe=8,mwe=9,hwe=10,gwe=11,_we=12,vwe=13,ywe=14,bwe=15,xwe=16,Swe=17,x5=18,Cwe=19,S5=20,C5=21,w5=22,wwe=23,Twe=24;function T5(e){return e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57}function Ewe(e){return e>=48&&e<=57||e>=97&&e<=102||e>=65&&e<=70}function E5(e,t,n){for(let r=!1;;){if(e.next<0)return;if(e.next==t&&!r){e.advance();return}r=n&&!r&&e.next==92,e.advance()}}function D5(e,t){scan:for(;;){if(e.next<0)return;if(e.next==36){e.advance();for(let n=0;n<t.length;n++){if(e.next!=t.charCodeAt(n))continue scan;e.advance()}if(e.next==36){e.advance();return}}else e.advance()}}function Dwe(e,t){let n=`[{<(`.indexOf(String.fromCharCode(t)),r=n<0?t:`]}>)`.charCodeAt(n);for(;;){if(e.next<0)return;if(e.next==r&&e.peek(1)==39){e.advance(2);return}e.advance()}}function O5(e,t){for(;!(e.next!=95&&!T5(e.next));)t!=null&&(t+=String.fromCharCode(e.next)),e.advance();return t}function Owe(e){if(e.next==39||e.next==34||e.next==96){let t=e.next;e.advance(),E5(e,t,!1)}else O5(e)}function k5(e,t){for(;e.next==48||e.next==49;)e.advance();t&&e.next==t&&e.advance()}function A5(e,t){for(;;){if(e.next==46){if(t)break;t=!0}else if(e.next<48||e.next>57)break;e.advance()}if(e.next==69||e.next==101)for(e.advance(),(e.next==43||e.next==45)&&e.advance();e.next>=48&&e.next<=57;)e.advance()}function j5(e){for(;!(e.next<0||e.next==10);)e.advance()}function M5(e,t){for(let n=0;n<t.length;n++)if(t.charCodeAt(n)==e)return!0;return!1}var N5=` \r
750
+ `;function P5(e,t,n){let r=Object.create(null);r.true=r.false=uwe,r.null=r.unknown=dwe;for(let t of e.split(` `))t&&(r[t]=S5);for(let e of t.split(` `))e&&(r[e]=C5);for(let e of(n||``).split(` `))e&&(r[e]=Twe);return r}var F5={backslashEscapes:!1,hashComments:!1,spaceAfterDashes:!1,slashComments:!1,doubleQuotedStrings:!1,doubleDollarQuotedStrings:!1,unquotedBitLiterals:!1,treatBitsAsBytes:!1,charSetCasts:!1,plsqlQuotingMechanism:!1,operatorChars:`*+-%<>!=&|~^/`,specialVar:`?`,identifierQuotes:`"`,caseInsensitiveIdentifiers:!1,words:P5(`absolute action add after all allocate alter and any are as asc assertion at authorization before begin between both breadth by call cascade cascaded case cast catalog check close collate collation column commit condition connect connection constraint constraints constructor continue corresponding count create cross cube current current_date current_default_transform_group current_transform_group_for_type current_path current_role current_time current_timestamp current_user cursor cycle data day deallocate declare default deferrable deferred delete depth deref desc describe descriptor deterministic diagnostics disconnect distinct do domain drop dynamic each else elseif end end-exec equals escape except exception exec execute exists exit external fetch first for foreign found from free full function general get global go goto grant group grouping handle having hold hour identity if immediate in indicator initially inner inout input insert intersect into is isolation join key language last lateral leading leave left level like limit local localtime localtimestamp locator loop map match method minute modifies module month names natural nesting new next no none not of old on only open option or order ordinality out outer output overlaps pad parameter partial path prepare preserve primary prior privileges procedure public read reads recursive redo ref references referencing relative release repeat resignal restrict result return returns revoke right role rollback rollup routine row rows savepoint schema scroll search second section select session session_user set sets signal similar size some space specific specifictype sql sqlexception sqlstate sqlwarning start state static system_user table temporary then timezone_hour timezone_minute to trailing transaction translation treat trigger under undo union unique unnest until update usage user using value values view when whenever where while with without work write year zone `,`array binary bit boolean char character clob date decimal double float int integer interval large national nchar nclob numeric object precision real smallint time timestamp varchar varying `)};function kwe(e,t,n,r){let i={};for(let t in F5)i[t]=(e.hasOwnProperty(t)?e:F5)[t];return t&&(i.words=P5(t,n||``,r)),i}function I5(e){return new pCe(t=>{let{next:n}=t;if(t.advance(),M5(n,N5)){for(;M5(t.next,N5);)t.advance();t.acceptToken(cwe)}else if(n==36&&e.doubleDollarQuotedStrings){let e=O5(t,``);t.next==36&&(t.advance(),D5(t,e),t.acceptToken(y5))}else if(n==39||n==34&&e.doubleQuotedStrings)E5(t,n,e.backslashEscapes),t.acceptToken(y5);else if(n==35&&e.hashComments||n==47&&t.next==47&&e.slashComments)j5(t),t.acceptToken(v5);else if(n==45&&t.next==45&&(!e.spaceAfterDashes||t.peek(1)==32))j5(t),t.acceptToken(v5);else if(n==47&&t.next==42){t.advance();for(let e=1;;){let n=t.next;if(t.next<0)break;if(t.advance(),n==42&&t.next==47){if(e--,t.advance(),!e)break}else n==47&&t.next==42&&(e++,t.advance())}t.acceptToken(lwe)}else if((n==101||n==69)&&t.next==39)t.advance(),E5(t,39,!0),t.acceptToken(y5);else if((n==110||n==78)&&t.next==39&&e.charSetCasts)t.advance(),E5(t,39,e.backslashEscapes),t.acceptToken(y5);else if(n==95&&e.charSetCasts)for(let n=0;;n++){if(t.next==39&&n>1){t.advance(),E5(t,39,e.backslashEscapes),t.acceptToken(y5);break}if(!T5(t.next))break;t.advance()}else if(e.plsqlQuotingMechanism&&(n==113||n==81)&&t.next==39&&t.peek(1)>0&&!M5(t.peek(1),N5)){let e=t.peek(1);t.advance(2),Dwe(t,e),t.acceptToken(y5)}else if(M5(n,e.identifierQuotes))E5(t,n==91?93:n,!1),t.acceptToken(Cwe);else if(n==40)t.acceptToken(fwe);else if(n==41)t.acceptToken(pwe);else if(n==123)t.acceptToken(mwe);else if(n==125)t.acceptToken(hwe);else if(n==91)t.acceptToken(gwe);else if(n==93)t.acceptToken(_we);else if(n==59)t.acceptToken(vwe);else if(e.unquotedBitLiterals&&n==48&&t.next==98)t.advance(),k5(t),t.acceptToken(w5);else if((n==98||n==66)&&(t.next==39||t.next==34)){let n=t.next;t.advance(),e.treatBitsAsBytes?(E5(t,n,e.backslashEscapes),t.acceptToken(wwe)):(k5(t,n),t.acceptToken(w5))}else if(n==48&&(t.next==120||t.next==88)||(n==120||n==88)&&t.next==39){let e=t.next==39;for(t.advance();Ewe(t.next);)t.advance();e&&t.next==39&&t.advance(),t.acceptToken(b5)}else if(n==46&&t.next>=48&&t.next<=57)A5(t,!0),t.acceptToken(b5);else if(n==46)t.acceptToken(ywe);else if(n>=48&&n<=57)A5(t,!1),t.acceptToken(b5);else if(M5(n,e.operatorChars)){for(;M5(t.next,e.operatorChars);)t.advance();t.acceptToken(bwe)}else if(M5(n,e.specialVar))t.next==n&&t.advance(),Owe(t),t.acceptToken(Swe);else if(n==58||n==44)t.acceptToken(xwe);else if(T5(n)){let r=O5(t,String.fromCharCode(n));t.acceptToken(t.next==46||t.peek(-r.length-1)==46?x5:e.words[r.toLowerCase()]??x5)}})}var L5=I5(F5),Awe=yCe.deserialize({version:14,states:"%vQ]QQOOO#wQRO'#DSO$OQQO'#CwO%eQQO'#CxO%lQQO'#CyO%sQQO'#CzOOQQ'#DS'#DSOOQQ'#C}'#C}O'UQRO'#C{OOQQ'#Cv'#CvOOQQ'#C|'#C|Q]QQOOQOQQOOO'`QQO'#DOO(xQRO,59cO)PQQO,59cO)UQQO'#DSOOQQ,59d,59dO)cQQO,59dOOQQ,59e,59eO)jQQO,59eOOQQ,59f,59fO)qQQO,59fOOQQ-E6{-E6{OOQQ,59b,59bOOQQ-E6z-E6zOOQQ,59j,59jOOQQ-E6|-E6|O+VQRO1G.}O+^QQO,59cOOQQ1G/O1G/OOOQQ1G/P1G/POOQQ1G/Q1G/QP+kQQO'#C}O+rQQO1G.}O)PQQO,59cO,PQQO'#Cw",stateData:",[~OtOSPOSQOS~ORUOSUOTUOUUOVROXSOZTO]XO^QO_UO`UOaPObPOcPOdUOeUOfUOgUOhUO~O^]ORvXSvXTvXUvXVvXXvXZvX]vX_vX`vXavXbvXcvXdvXevXfvXgvXhvX~OsvX~P!jOa_Ob_Oc_O~ORUOSUOTUOUUOVROXSOZTO^tO_UO`UOa`Ob`Oc`OdUOeUOfUOgUOhUO~OWaO~P$ZOYcO~P$ZO[eO~P$ZORUOSUOTUOUUOVROXSOZTO^QO_UO`UOaPObPOcPOdUOeUOfUOgUOhUO~O]hOsoX~P%zOajObjOcjO~O^]ORkaSkaTkaUkaVkaXkaZka]ka_ka`kaakabkackadkaekafkagkahka~Oska~P'kO^]O~OWvXYvX[vX~P!jOWnO~P$ZOYoO~P$ZO[pO~P$ZO^]ORkiSkiTkiUkiVkiXkiZki]ki_ki`kiakibkickidkiekifkigkihki~Oski~P)xOWkaYka[ka~P'kO]hO~P$ZOWkiYki[ki~P)xOasObsOcsO~O",goto:"#hwPPPPPPPPPPPPPPPPPPPPPPPPPPx||||!Y!^!d!xPPP#[TYOZeUORSTWZbdfqT[OZQZORiZSWOZQbRQdSQfTZgWbdfqQ^PWk^lmrQl_Qm`RrseVORSTWZbdfq",nodeNames:`⚠ LineComment BlockComment String Number Bool Null ( ) { } [ ] ; . Operator Punctuation SpecialVar Identifier QuotedIdentifier Keyword Type Bits Bytes Builtin Script Statement CompositeIdentifier Parens Braces Brackets Statement`,maxTerm:38,nodeProps:[[`isolate`,-4,1,2,3,19,``]],skippedNodes:[0,1,2],repeatNodeCount:3,tokenData:`RORO`,tokenizers:[0,L5],topRules:{Script:[0,25]},tokenPrec:0});function R5(e){let t=e.cursor().moveTo(e.from,-1);for(;/Comment/.test(t.name);)t.moveTo(t.from,-1);return t.node}function z5(e,t){let n=e.sliceString(t.from,t.to),r=/^([`'"\[])(.*)([`'"\]])$/.exec(n);return r?r[2]:n}function B5(e){return e&&(e.name==`Identifier`||e.name==`QuotedIdentifier`)}function jwe(e,t){if(t.name==`CompositeIdentifier`){let n=[];for(let r=t.firstChild;r;r=r.nextSibling)B5(r)&&n.push(z5(e,r));return n}return[z5(e,t)]}function V5(e,t){for(let n=[];;){if(!t||t.name!=`.`)return n;let r=R5(t);if(!B5(r))return n;n.unshift(z5(e,r)),t=R5(r)}}function Mwe(e,t){let n=q6(e).resolveInner(t,-1),r=Pwe(e.doc,n);return n.name==`Identifier`||n.name==`QuotedIdentifier`||n.name==`Keyword`?{from:n.from,quoted:n.name==`QuotedIdentifier`?e.doc.sliceString(n.from,n.from+1):null,parents:V5(e.doc,R5(n)),aliases:r}:n.name==`.`?{from:t,quoted:null,parents:V5(e.doc,n),aliases:r}:{from:t,quoted:null,parents:[],empty:!0,aliases:r}}var Nwe=new Set(`where group having order union intersect except all distinct limit offset fetch for`.split(` `));function Pwe(e,t){let n;for(let e=t;!n;e=e.parent){if(!e)return null;e.name==`Statement`&&(n=e)}let r=null;for(let t=n.firstChild,i=!1,a=null;t;t=t.nextSibling){let n=t.name==`Keyword`?e.sliceString(t.from,t.to).toLowerCase():null,o=null;if(!i)i=n==`from`;else if(n==`as`&&a&&B5(t.nextSibling))o=z5(e,t.nextSibling);else if(n&&Nwe.has(n))break;else a&&B5(t)&&(o=z5(e,t));o&&(r||=Object.create(null),r[o]=jwe(e,a)),a=/Identifier$/.test(t.name)?t:null}return r}function Fwe(e,t,n){return n.map(n=>({...n,label:n.label[0]==e?n.label:e+n.label+t,apply:void 0}))}var Iwe=/^\w*$/,Lwe=/^[`'"\[]?\w*[`'"\]]?$/;function H5(e){return e.self&&typeof e.self.label==`string`}var Rwe=class e{constructor(e,t){this.idQuote=e,this.idCaseInsensitive=t,this.list=[],this.children=void 0}child(t){let n=this.children||=Object.create(null);return n[t]||(t&&!this.list.some(e=>e.label==t)&&this.list.push(U5(t,`type`,this.idQuote,this.idCaseInsensitive)),n[t]=new e(this.idQuote,this.idCaseInsensitive))}maybeChild(e){return this.children?this.children[e]:null}addCompletion(e){let t=this.list.findIndex(t=>t.label==e.label);t>-1?this.list[t]=e:this.list.push(e)}addCompletions(e){for(let t of e)this.addCompletion(typeof t==`string`?U5(t,`property`,this.idQuote,this.idCaseInsensitive):t)}addNamespace(e){Array.isArray(e)?this.addCompletions(e):H5(e)?this.addNamespace(e.children):this.addNamespaceObject(e)}addNamespaceObject(e){for(let t of Object.keys(e)){let n=e[t],r=null,i=t.replace(/\\?\./g,e=>e==`.`?`\0`:e).split(`\0`),a=this;H5(n)&&(r=n.self,n=n.children);for(let e=0;e<i.length;e++)r&&e==i.length-1&&a.addCompletion(r),a=a.child(i[e].replace(/\\\./g,`.`));a.addNamespace(n)}}};function U5(e,t,n,r){return RegExp(`^[a-z_][a-z_\\d]*$`,r?`i`:``).test(e)?{label:e,type:t}:{label:e,type:t,apply:n+e+W5(n)}}function W5(e){return e===`[`?`]`:e}function zwe(e,t,n,r,i,a){let o=new Rwe(a?.spec.identifierQuotes?.[0]||`"`,!!a?.spec.caseInsensitiveIdentifiers),s=i?o.child(i):null;return o.addNamespace(e),t&&(s||o).addCompletions(t),n&&o.addCompletions(n),s&&o.addCompletions(s.list),r&&o.addCompletions((s||o).child(r).list),e=>{let{parents:t,from:n,quoted:i,empty:a,aliases:c}=Mwe(e.state,e.pos);if(a&&!e.explicit)return null;c&&t.length==1&&(t=c[t[0]]||t);let l=o;for(let e of t){for(;!l.children||!l.children[e];)if(l==o&&s)l=s;else if(l==s&&r)l=l.child(r);else return null;let t=l.maybeChild(e);if(!t)return null;l=t}let u=l.list;if(l==o&&c&&(u=u.concat(Object.keys(c).map(e=>({label:e,type:`constant`})))),i){let t=i[0],r=W5(t);return{from:n,to:e.state.sliceDoc(e.pos,e.pos+1)==r?e.pos+1:void 0,options:Fwe(t,r,u),validFor:Lwe}}else return{from:n,options:u,validFor:Iwe}}}function Bwe(e){return e==C5?`type`:e==S5?`keyword`:`variable`}function Vwe(e,t,n){return SCe([`QuotedIdentifier`,`String`,`LineComment`,`BlockComment`,`.`],R8(Object.keys(e).map(r=>n(t?r.toUpperCase():r,Bwe(e[r])))))}var Hwe=Awe.configure({props:[a8.add({Statement:KSe()}),qSe.add({Statement(e,t){return{from:Math.min(e.from+100,t.doc.lineAt(e.from).to),to:e.to}},BlockComment(e){return{from:e.from+2,to:e.to-2}}}),E6({Keyword:$.keyword,Type:$.typeName,Builtin:$.standard($.name),Bits:$.number,Bytes:$.string,Bool:$.bool,Null:$.null,Number:$.number,String:$.string,Identifier:$.name,QuotedIdentifier:$.special($.string),SpecialVar:$.special($.name),LineComment:$.lineComment,BlockComment:$.blockComment,Operator:$.operator,"Semi Punctuation":$.punctuation,"( )":$.paren,"{ }":$.brace,"[ ]":$.squareBracket})]}),G5=class e{constructor(e,t,n){this.dialect=e,this.language=t,this.spec=n}get extension(){return this.language.extension}configureLanguage(t,n){return new e(this.dialect,this.language.configure(t,n),this.spec)}static define(t){let n=kwe(t,t.keywords,t.types,t.builtin);return new e(n,MSe.define({name:`sql`,parser:Hwe.configure({tokenizers:[{from:L5,to:I5(n)}]}),languageData:{commentTokens:{line:`--`,block:{open:`/*`,close:`*/`}},closeBrackets:{brackets:[`(`,`[`,`{`,`'`,`"`,"`"]}}}),t)}};function Uwe(e,t){return{label:e,type:t,boost:-1}}function Wwe(e,t=!1,n){return Vwe(e.dialect.words,t,n||Uwe)}function Gwe(e){return e.schema?zwe(e.schema,e.tables,e.schemas,e.defaultTable,e.defaultSchema,e.dialect||K5):()=>null}function Kwe(e){return e.schema?(e.dialect||K5).language.data.of({autocomplete:Gwe(e)}):[]}function qwe(e={}){let t=e.dialect||K5;return new ISe(t.language,[Kwe(e),t.language.data.of({autocomplete:Wwe(t,e.upperCaseKeywords,e.keywordCompletion)})])}var K5=G5.define({}),Jwe=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=J5(e.state,n.from);return r.line?Ywe(e):r.block?Zwe(e):!1};function q5(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return i?(r(n.update(i)),!0):!1}}var Ywe=q5(eTe,0),Xwe=q5(X5,0),Zwe=q5((e,t)=>X5(e,t,$we(t)),0);function J5(e,t){let n=e.languageDataAt(`commentTokens`,t,1);return n.length?n[0]:{}}var Y5=50;function Qwe(e,{open:t,close:n},r,i){let a=e.sliceDoc(r-Y5,r),o=e.sliceDoc(i,i+Y5),s=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(o)[0].length,l=a.length-s;if(a.slice(l-t.length,l)==t&&o.slice(c,c+n.length)==n)return{open:{pos:r-s,margin:s&&1},close:{pos:i+c,margin:c&&1}};let u,d;i-r<=2*Y5?u=d=e.sliceDoc(r,i):(u=e.sliceDoc(r,r+Y5),d=e.sliceDoc(i-Y5,i));let f=/^\s*/.exec(u)[0].length,p=/\s*$/.exec(d)[0].length,m=d.length-p-n.length;return u.slice(f,f+t.length)==t&&d.slice(m,m+n.length)==n?{open:{pos:r+f+t.length,margin:+!!/\s/.test(u.charAt(f+t.length))},close:{pos:i-p-n.length,margin:+!!/\s/.test(d.charAt(m-1))}}:null}function $we(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let a=t.length-1;a>=0&&t[a].to>r.from?t[a].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}function X5(e,t,n=t.selection.ranges){let r=n.map(e=>J5(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>Qwe(t,r[n],e.from,e.to));if(e!=2&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+` `},{from:e.to,insert:` `+r[t].close}]))};if(e!=1&&i.some(e=>e)){let e=[];for(let t=0,n;t<i.length;t++)if(n=i[t]){let i=r[t],{open:a,close:o}=n;e.push({from:a.pos-i.open.length,to:a.pos+a.margin},{from:o.pos-o.margin,to:o.pos+i.close.length})}return{changes:e}}return null}function eTe(e,t,n=t.selection.ranges){let r=[],i=-1;ranges:for(let{from:e,to:a}of n){let n=r.length,o=1e9,s;for(let n=e;n<=a;){let c=t.doc.lineAt(n);if(s==null&&(s=J5(t,c.from).line,!s))continue ranges;if(c.from>i&&(e==a||a>c.from)){i=c.from;let e=/^\s*/.exec(c.text)[0].length,t=e==c.length,n=c.text.slice(e,e+s.length)==s?e:-1;e<c.text.length&&e<o&&(o=e),r.push({line:c,comment:n,token:s,indent:e,empty:t,single:!1})}n=c.to+1}if(o<1e9)for(let e=n;e<r.length;e++)r[e].indent<r[e].line.text.length&&(r[e].indent=o);r.length==n+1&&(r[n].single=!0)}if(e!=2&&r.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:a,single:o}of r)(o||!a)&&e.push({from:t.from+i,insert:n+` `});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}else if(e!=1&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,a=r+i.length;t.text[a-t.from]==` `&&a++,e.push({from:r,to:a})}return{changes:e}}return null}var Z5=_1.define(),tTe=_1.define(),nTe=Y.define(),Q5=Y.define({combine(e){return D1(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}}),$5=e1.define({create(){return l7.empty},update(e,t){let n=t.state.facet(Q5),r=t.annotation(Z5);if(r){let i=r7.fromTransaction(t,r.selection),a=r.side,o=a==0?e.undone:e.done;return o=i?i7(o,o.length,n.minDepth,i):s7(o,t.startState.selection),new l7(a==0?r.rest:o,a==0?o:r.rest)}let i=t.annotation(tTe);if((i==`full`||i==`before`)&&(e=e.isolate()),t.annotation(y1.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=r7.fromTransaction(t),o=t.annotation(y1.time),s=t.annotation(y1.userEvent);return a?e=e.addChanges(a,o,s,n,t):t.selection&&(e=e.addSelection(t.startState.selection,o,s,n.newGroupDelay)),(i==`full`||i==`after`)&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}},fromJSON(e){return new l7(e.done.map(r7.fromJSON),e.undone.map(r7.fromJSON))}});function rTe(e={}){return[$5,Q5.of(e),Z.domEventHandlers({beforeinput(e,t){let n=e.inputType==`historyUndo`?t7:e.inputType==`historyRedo`?n7:null;return n?(e.preventDefault(),n(t)):!1}})]}function e7(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field($5,!1);if(!i)return!1;let a=i.pop(e,n,t);return a?(r(a),!0):!1}}var t7=e7(0,!1),n7=e7(1,!1),iTe=e7(0,!0),aTe=e7(1,!0),r7=class e{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(t){return new e(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){return{changes:this.changes?.toJSON(),mapped:this.mapped?.toJSON(),startSelection:this.startSelection?.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(t){return new e(t.changes&&z$.fromJSON(t.changes),[],t.mapped&&R$.fromJSON(t.mapped),t.startSelection&&J.fromJSON(t.startSelection),t.selectionsAfter.map(J.fromJSON))}static fromTransaction(t,n){let r=o7;for(let e of t.startState.facet(nTe)){let n=e(t);n.length&&(r=r.concat(n))}return!r.length&&t.changes.empty?null:new e(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,o7)}static selection(t){return new e(void 0,o7,void 0,void 0,t)}};function i7(e,t,n,r){let i=t+1>n+20?t-n-1:0,a=e.slice(i,t);return a.push(r),a}function oTe(e,t){let n=[],r=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,i,a)=>{for(let e=0;e<n.length;){let t=n[e++],o=n[e++];a>=t&&i<=o&&(r=!0)}}),r}function sTe(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function a7(e,t){return e.length?t.length?e.concat(t):e:t}var o7=[],cTe=200;function s7(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-cTe));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),i7(e,e.length-1,1e9,n.setSelAfter(r)))}else return[r7.selection([t])]}function lTe(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 c7(e,t){if(!e.length)return e;let n=e.length,r=o7;for(;n;){let i=uTe(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}else t=i.mapped,n--,r=i.selectionsAfter}return r.length?[r7.selection(r)]:o7}function uTe(e,t,n){let r=a7(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):o7,n);if(!e.changes)return r7.selection(r);let i=e.changes.map(t),a=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(a):a;return new r7(i,v1.mapEffects(e.effects,t),o,e.startSelection.map(a),r)}var dTe=/^(input\.type|delete)($|\.)/,l7=class e{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new e(this.done,this.undone):this}addChanges(t,n,r,i,a){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&t.changes&&(!r||dTe.test(r))&&(!s.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(a,oTe(s.changes,t.changes))||r==`input.type.compose`)?i7(o,o.length-1,i.minDepth,new r7(t.changes.compose(s.changes),a7(v1.mapEffects(t.effects,s.changes),s.effects),s.mapped,s.startSelection,o7)):i7(o,o.length,i.minDepth,t),new e(o,o7,n,r)}addSelection(t,n,r,i){let a=this.done.length?this.done[this.done.length-1].selectionsAfter:o7;return a.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&sTe(a[a.length-1],t)?this:new e(s7(this.done,t),this.undone,n,r)}addMapping(t){return new e(c7(this.done,t),c7(this.undone,t),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=e==0?this.done:this.undone;if(r.length==0)return null;let i=r[r.length-1],a=i.selectionsAfter[0]||(i.startSelection?i.startSelection.map(i.changes.invertedDesc,1):t.selection);if(n&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:Z5.of({side:e,rest:lTe(r),selection:a}),userEvent:e==0?`select.undo`:`select.redo`,scrollIntoView:!0});if(i.changes){let n=r.length==1?o7:r.slice(0,r.length-1);return i.mapped&&(n=c7(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:Z5.of({side:e,rest:n,selection:a}),filter:!1,userEvent:e==0?`undo`:`redo`,scrollIntoView:!0})}else return null}};l7.empty=new l7(o7,o7);var fTe=[{key:`Mod-z`,run:t7,preventDefault:!0},{key:`Mod-y`,mac:`Mod-Shift-z`,run:n7,preventDefault:!0},{linux:`Ctrl-Shift-z`,run:n7,preventDefault:!0},{key:`Mod-u`,run:iTe,preventDefault:!0},{key:`Alt-u`,mac:`Mod-Shift-u`,run:aTe,preventDefault:!0}];function u7(e,t){return J.create(e.ranges.map(t),e.mainIndex)}function d7(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:`select`})}function f7({state:e,dispatch:t},n){let r=u7(e.selection,n);return r.eq(e.selection,!0)?!1:(t(d7(e,r)),!0)}function p7(e,t){return J.cursor(t?e.to:e.from)}function m7(e,t){return f7(e,n=>n.empty?e.moveByChar(n,t):p7(n,t))}function h7(e){return e.textDirectionAt(e.state.selection.main.head)==q0.LTR}var g7=e=>m7(e,!h7(e)),_7=e=>m7(e,h7(e));function v7(e,t){return f7(e,n=>n.empty?e.moveByGroup(n,t):p7(n,t))}var pTe=e=>v7(e,!h7(e)),mTe=e=>v7(e,h7(e));typeof Intl<`u`&&Intl.Segmenter;function hTe(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 y7(e,t,n){let r=q6(e).resolveInner(t.head),i=n?t6.closedBy:t6.openedBy;for(let a=t.head;;){let t=n?r.childAfter(a):r.childBefore(a);if(!t)break;hTe(e,t,i)?r=t:a=n?t.to:t.from}let a=r.type.prop(i),o,s;return s=a&&(o=n?v8(e,r.from,1):v8(e,r.to,-1))&&o.matched?n?o.end.to:o.end.from:n?r.to:r.from,J.cursor(s,n?-1:1)}var gTe=e=>f7(e,t=>y7(e.state,t,!h7(e))),_Te=e=>f7(e,t=>y7(e.state,t,h7(e)));function b7(e,t){return f7(e,n=>{if(!n.empty)return p7(n,t);let r=e.moveVertically(n,t);return r.head==n.head?e.moveToLineBoundary(n,t):r})}var x7=e=>b7(e,!1),S7=e=>b7(e,!0);function C7(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,i;if(t){for(let t of e.state.facet(Z.scrollMargins)){let i=t(e);i?.top&&(n=Math.max(i?.top,n)),i?.bottom&&(r=Math.max(i?.bottom,r))}i=e.scrollDOM.clientHeight-n-r}else i=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,i-5)}}function w7(e,t){let n=C7(e),{state:r}=e,i=u7(r.selection,r=>r.empty?e.moveVertically(r,t,n.height):p7(r,t));if(i.eq(r.selection))return!1;let a;if(n.selfScroll){let t=e.coordsAtPos(r.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),s=o.top+n.marginTop,c=o.bottom-n.marginBottom;t&&t.top>s&&t.bottom<c&&(a=Z.scrollIntoView(i.main.head,{y:`start`,yMargin:t.top-s}))}return e.dispatch(d7(r,i),{effects:a}),!0}var T7=e=>w7(e,!1),E7=e=>w7(e,!0);function D7(e,t,n){let r=e.lineBlockAt(t.head),i=e.moveToLineBoundary(t,n);if(i.head==t.head&&i.head!=(n?r.to:r.from)&&(i=e.moveToLineBoundary(t,n,!1)),!n&&i.head==r.from&&r.length){let n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(i=J.cursor(r.from+n))}return i}var vTe=e=>f7(e,t=>D7(e,t,!0)),yTe=e=>f7(e,t=>D7(e,t,!1)),bTe=e=>f7(e,t=>D7(e,t,!h7(e))),xTe=e=>f7(e,t=>D7(e,t,h7(e))),STe=e=>f7(e,t=>J.cursor(e.lineBlockAt(t.head).from,1)),CTe=e=>f7(e,t=>J.cursor(e.lineBlockAt(t.head).to,-1));function wTe(e,t,n){let r=!1,i=u7(e.selection,t=>{let i=v8(e,t.head,-1)||v8(e,t.head,1)||t.head>0&&v8(e,t.head-1,1)||t.head<e.doc.length&&v8(e,t.head+1,-1);if(!i||!i.end)return t;r=!0;let a=i.start.from==t.head?i.end.to:i.end.from;return n?J.range(t.anchor,a):J.cursor(a)});return r?(t(d7(e,i)),!0):!1}var TTe=({state:e,dispatch:t})=>wTe(e,t,!1);function O7(e,t){let n=u7(e.state.selection,e=>{let n=t(e);return J.range(e.anchor,n.head,n.goalColumn,n.bidiLevel||void 0,n.assoc)});return n.eq(e.state.selection)?!1:(e.dispatch(d7(e.state,n)),!0)}function k7(e,t){return O7(e,n=>e.moveByChar(n,t))}var A7=e=>k7(e,!h7(e)),j7=e=>k7(e,h7(e));function M7(e,t){return O7(e,n=>e.moveByGroup(n,t))}var ETe=e=>M7(e,!h7(e)),DTe=e=>M7(e,h7(e)),OTe=e=>O7(e,t=>y7(e.state,t,!h7(e))),kTe=e=>O7(e,t=>y7(e.state,t,h7(e)));function N7(e,t){return O7(e,n=>e.moveVertically(n,t))}var P7=e=>N7(e,!1),F7=e=>N7(e,!0);function I7(e,t){return O7(e,n=>e.moveVertically(n,t,C7(e).height))}var L7=e=>I7(e,!1),R7=e=>I7(e,!0),ATe=e=>O7(e,t=>D7(e,t,!0)),jTe=e=>O7(e,t=>D7(e,t,!1)),MTe=e=>O7(e,t=>D7(e,t,!h7(e))),NTe=e=>O7(e,t=>D7(e,t,h7(e))),PTe=e=>O7(e,t=>J.cursor(e.lineBlockAt(t.head).from)),FTe=e=>O7(e,t=>J.cursor(e.lineBlockAt(t.head).to)),z7=({state:e,dispatch:t})=>(t(d7(e,{anchor:0})),!0),B7=({state:e,dispatch:t})=>(t(d7(e,{anchor:e.doc.length})),!0),V7=({state:e,dispatch:t})=>(t(d7(e,{anchor:e.selection.main.anchor,head:0})),!0),H7=({state:e,dispatch:t})=>(t(d7(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),ITe=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:`select`})),!0),LTe=({state:e,dispatch:t})=>{let n=Z7(e).map(({from:t,to:n})=>J.range(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:J.create(n),userEvent:`select`})),!0},RTe=({state:e,dispatch:t})=>{let n=u7(e.selection,t=>{let n=q6(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from<t.from&&n.to>=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return J.range(n.to,n.from)}return t});return n.eq(e.selection)?!1:(t(d7(e,n)),!0)};function U7(e,t){let{state:n}=e,r=n.selection,i=n.selection.ranges.slice();for(let r of n.selection.ranges){let a=n.doc.lineAt(r.head);if(t?a.to<e.state.doc.length:a.from>0)for(let n=r;;){let r=e.moveVertically(n,t);if(r.head<a.from||r.head>a.to){i.some(e=>e.head==r.head)||i.push(r);break}else if(r.head==n.head)break;else n=r}}return i.length==r.ranges.length?!1:(e.dispatch(d7(n,J.create(i,i.length-1))),!0)}var zTe=e=>U7(e,!1),BTe=e=>U7(e,!0),VTe=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=J.create([n.main]):n.main.empty||(r=J.create([J.cursor(n.main.head)])),r?(t(d7(e,r)),!0):!1};function W7(e,t){if(e.state.readOnly)return!1;let n=`delete.selection`,{state:r}=e,i=r.changeByRange(r=>{let{from:i,to:a}=r;if(i==a){let o=t(r);o<i?(n=`delete.backward`,o=G7(e,o,!1)):o>i&&(n=`delete.forward`,o=G7(e,o,!0)),i=Math.min(i,o),a=Math.max(a,o)}else i=G7(e,i,!1),a=G7(e,a,!0);return i==a?{range:r}:{changes:{from:i,to:a},range:J.cursor(i,i<r.head?-1:1)}});return i.changes.empty?!1:(e.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:n==`delete.selection`?Z.announce.of(r.phrase(`Selection deleted`)):void 0})),!0)}function G7(e,t,n){if(e instanceof Z)for(let r of e.state.facet(Z.atomicRanges).map(t=>t(e)))r.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}var K7=(e,t,n)=>W7(e,r=>{let i=r.from,{state:a}=e,o=a.doc.lineAt(i),s,c;if(n&&!t&&i>o.from&&i<o.from+200&&!/[^ \t]/.test(s=o.text.slice(0,i-o.from))){if(s[s.length-1]==` `)return i-1;let e=W1(s,a.tabSize)%t8(a)||t8(a);for(let t=0;t<e&&s[s.length-1-t]==` `;t++)i--;c=i}else c=M$(o.text,i-o.from,t,t)+o.from,c==i&&o.number!=(t?a.doc.lines:1)?c+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(c-o.from,i-o.from))&&(c=M$(o.text,c-o.from,!1,!1)+o.from);return c}),q7=e=>K7(e,!1,!0),J7=e=>K7(e,!0,!1),Y7=(e,t)=>W7(e,n=>{let r=n.head,{state:i}=e,a=i.doc.lineAt(r),o=i.charCategorizer(r);for(let e=null;;){if(r==(t?a.to:a.from)){r==n.head&&a.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}let s=M$(a.text,r-a.from,t)+a.from,c=a.text.slice(Math.min(r,s)-a.from,Math.max(r,s)-a.from),l=o(c);if(e!=null&&l!=e)break;(c!=` `||r!=n.head)&&(e=l),r=s}return r}),X7=e=>Y7(e,!1),HTe=e=>Y7(e,!0),UTe=e=>W7(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),WTe=e=>W7(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),GTe=e=>W7(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),KTe=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:C$.of([``,``])},range:J.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:`input`})),!0},qTe=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||t.from==0||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n),i=n==r.from?n-1:M$(r.text,n-r.from,!1)+r.from,a=n==r.to?n+1:M$(r.text,n-r.from,!0)+r.from;return{changes:{from:i,to:a,insert:e.doc.slice(n,a).append(e.doc.slice(i,n))},range:J.cursor(a)}});return n.changes.empty?!1:(t(e.update(n,{scrollIntoView:!0,userEvent:`move.character`})),!0)};function Z7(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),a=e.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=a.to,e.ranges.push(r)}else t.push({from:i.from,to:a.to,ranges:[r]});n=a.number+1}return t}function Q7(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of Z7(e)){if(n?t.to==e.doc.length:t.from==0)continue;let a=e.doc.lineAt(n?t.to+1:t.from-1),o=a.length+1;if(n){r.push({from:t.to,to:a.to},{from:t.from,insert:a.text+e.lineBreak});for(let n of t.ranges)i.push(J.range(Math.min(e.doc.length,n.anchor+o),Math.min(e.doc.length,n.head+o)))}else{r.push({from:a.from,to:t.from},{from:t.to,insert:e.lineBreak+a.text});for(let e of t.ranges)i.push(J.range(e.anchor-o,e.head-o))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:J.create(i,e.selection.mainIndex),userEvent:`move.line`})),!0):!1}var JTe=({state:e,dispatch:t})=>Q7(e,t,!1),YTe=({state:e,dispatch:t})=>Q7(e,t,!0);function $7(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of Z7(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:`input.copyline`})),!0}var XTe=({state:e,dispatch:t})=>$7(e,t,!1),ZTe=({state:e,dispatch:t})=>$7(e,t,!0),QTe=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(Z7(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=u7(t.selection,t=>{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:`delete.line`}),!0};function $Te(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=q6(e).resolveInner(t),r=n.childBefore(t),i=n.childAfter(t),a;return r&&i&&r.to<=t&&i.from>=t&&(a=r.type.prop(t6.closedBy))&&a.indexOf(i.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(i.from).from&&!/\S/.test(e.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}var e9=t9(!1),eEe=t9(!0);function t9(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{let{from:r,to:i}=n,a=t.doc.lineAt(r),o=!e&&r==i&&$Te(t,r);e&&(r=i=(i<=a.to?a:t.doc.lineAt(i)).to);let s=new i8(t,{simulateBreak:r,simulateDoubleBreak:!!o}),c=r8(s,r);for(c??=W1(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize);i<a.to&&/\s/.test(a.text[i-a.from]);)i++;o?{from:r,to:i}=o:r>a.from&&r<a.from+100&&!/\S/.test(a.text.slice(0,r))&&(r=a.from);let l=[``,n8(t,c)];return o&&l.push(n8(t,s.lineIndent(a.from,-1))),{changes:{from:r,to:i,insert:C$.of(l)},range:J.cursor(r+1+l[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:`input`})),!0}}function n9(e,t){let n=-1;return e.changeByRange(r=>{let i=[];for(let a=r.from;a<=r.to;){let o=e.doc.lineAt(a);o.number>n&&(r.empty||r.to>o.from)&&(t(o,i,r),n=o.number),a=o.to+1}let a=e.changes(i);return{changes:i,range:J.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}var tEe=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new i8(e,{overrideIndentation:e=>n[e]??-1}),i=n9(e,(t,i,a)=>{let o=r8(r,t.from);if(o==null)return;/\S/.test(t.text)||(o=0);let s=/^\s*/.exec(t.text)[0],c=n8(e,o);(s!=c||a.from<t.from+s.length)&&(n[t.from]=o,i.push({from:t.from,to:t.from+s.length,insert:c}))});return i.changes.empty||t(e.update(i,{userEvent:`indent`})),!0},nEe=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(n9(e,(t,n)=>{n.push({from:t.from,insert:e.facet(e8)})}),{userEvent:`input.indent`})),!0),rEe=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(n9(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=W1(r,e.tabSize),a=0,o=n8(e,Math.max(0,i-t8(e)));for(;a<r.length&&a<o.length&&r.charCodeAt(a)==o.charCodeAt(a);)a++;n.push({from:t.from+a,to:t.from+r.length,insert:o.slice(a)})}),{userEvent:`delete.dedent`})),!0),iEe=e=>(e.setTabFocusMode(),!0),aEe=[{key:`Ctrl-b`,run:g7,shift:A7,preventDefault:!0},{key:`Ctrl-f`,run:_7,shift:j7},{key:`Ctrl-p`,run:x7,shift:P7},{key:`Ctrl-n`,run:S7,shift:F7},{key:`Ctrl-a`,run:STe,shift:PTe},{key:`Ctrl-e`,run:CTe,shift:FTe},{key:`Ctrl-d`,run:J7},{key:`Ctrl-h`,run:q7},{key:`Ctrl-k`,run:UTe},{key:`Ctrl-Alt-h`,run:X7},{key:`Ctrl-o`,run:KTe},{key:`Ctrl-t`,run:qTe},{key:`Ctrl-v`,run:E7}],oEe=[{key:`ArrowLeft`,run:g7,shift:A7,preventDefault:!0},{key:`Mod-ArrowLeft`,mac:`Alt-ArrowLeft`,run:pTe,shift:ETe,preventDefault:!0},{mac:`Cmd-ArrowLeft`,run:bTe,shift:MTe,preventDefault:!0},{key:`ArrowRight`,run:_7,shift:j7,preventDefault:!0},{key:`Mod-ArrowRight`,mac:`Alt-ArrowRight`,run:mTe,shift:DTe,preventDefault:!0},{mac:`Cmd-ArrowRight`,run:xTe,shift:NTe,preventDefault:!0},{key:`ArrowUp`,run:x7,shift:P7,preventDefault:!0},{mac:`Cmd-ArrowUp`,run:z7,shift:V7},{mac:`Ctrl-ArrowUp`,run:T7,shift:L7},{key:`ArrowDown`,run:S7,shift:F7,preventDefault:!0},{mac:`Cmd-ArrowDown`,run:B7,shift:H7},{mac:`Ctrl-ArrowDown`,run:E7,shift:R7},{key:`PageUp`,run:T7,shift:L7},{key:`PageDown`,run:E7,shift:R7},{key:`Home`,run:yTe,shift:jTe,preventDefault:!0},{key:`Mod-Home`,run:z7,shift:V7},{key:`End`,run:vTe,shift:ATe,preventDefault:!0},{key:`Mod-End`,run:B7,shift:H7},{key:`Enter`,run:e9,shift:e9},{key:`Mod-a`,run:ITe},{key:`Backspace`,run:q7,shift:q7,preventDefault:!0},{key:`Delete`,run:J7,preventDefault:!0},{key:`Mod-Backspace`,mac:`Alt-Backspace`,run:X7,preventDefault:!0},{key:`Mod-Delete`,mac:`Alt-Delete`,run:HTe,preventDefault:!0},{mac:`Mod-Backspace`,run:WTe,preventDefault:!0},{mac:`Mod-Delete`,run:GTe,preventDefault:!0}].concat(aEe.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),sEe=[{key:`Alt-ArrowLeft`,mac:`Ctrl-ArrowLeft`,run:gTe,shift:OTe},{key:`Alt-ArrowRight`,mac:`Ctrl-ArrowRight`,run:_Te,shift:kTe},{key:`Alt-ArrowUp`,run:JTe},{key:`Shift-Alt-ArrowUp`,run:XTe},{key:`Alt-ArrowDown`,run:YTe},{key:`Shift-Alt-ArrowDown`,run:ZTe},{key:`Mod-Alt-ArrowUp`,run:zTe},{key:`Mod-Alt-ArrowDown`,run:BTe},{key:`Escape`,run:VTe},{key:`Mod-Enter`,run:eEe},{key:`Alt-l`,mac:`Ctrl-l`,run:LTe},{key:`Mod-i`,run:RTe,preventDefault:!0},{key:`Mod-[`,run:rEe},{key:`Mod-]`,run:nEe},{key:`Mod-Alt-\\`,run:tEe},{key:`Shift-Mod-k`,run:QTe},{key:`Shift-Mod-\\`,run:TTe},{key:`Mod-/`,run:Jwe},{key:`Alt-A`,run:Xwe},{key:`Ctrl-m`,mac:`Shift-Alt-m`,run:iEe}].concat(oEe),r9=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFKD`):e=>e,i9=class{constructor(e,t,n=0,r=e.length,i,a){this.test=a,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer=``,this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=i?e=>i(r9(e)):r9,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return N$(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=P$(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=F$(e);let r=this.normalize(t);if(r.length)for(let e=0,i=n,a=!0;;e++){let n=r.charCodeAt(e),o=this.match(n,i,a,this.bufferPos+this.bufferStart,e==r.length-1);if(o)return this.value=o,this;if(e==r.length-1)break;a&&e<t.length&&t.charCodeAt(e)==n?i++:a=!1}}}match(e,t,n,r,i){let a=null;for(let t=0;t<this.matches.length;){let n=this.matches[t],o=!1;this.query.charCodeAt(n.index)==e&&(n.index==this.query.length-1?a={from:n.from,to:r,precise:i&&n.precise}:(n.index++,o=!0)),o?t++:this.matches.splice(t,1)}return this.query.charCodeAt(0)==e&&(this.query.length==1?a={from:t,to:r,precise:n&&i}:this.matches.push({from:t,index:1,precise:n})),a&&this.test&&!this.test(a.from,a.to,this.buffer,this.bufferStart)&&(a=null),a}};typeof Symbol<`u`&&(i9.prototype[Symbol.iterator]=function(){return this});var a9={from:-1,to:-1,match:/.*/.exec(``),precise:!0},o9=`gm`+(/x/.unicode==null?``:`u`),s9=class{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine=``,this.done=!1,this.value=a9,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new u9(e,t,n,r,i);this.re=new RegExp(t,o9+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.iter=e.iter();let a=e.lineAt(r);this.curLineStart=a.from,this.matchPos=d9(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine=``:(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine=``:this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=d9(this.text,r+ +(n==r)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,precise:!0,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},c9=new WeakMap,l9=class e{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(t,n,r){let i=c9.get(t);if(!i||i.from>=r||i.to<=n){let i=new e(n,t.sliceString(n,r));return c9.set(t,i),i}if(i.from==n&&i.to==r)return i;let{text:a,from:o}=i;return o>n&&(a=t.sliceString(n,o)+a,o=n),i.to<r&&(a+=t.sliceString(i.to,r)),c9.set(t,new e(o,a)),new e(n,a.slice(n-o,r-o))}},u9=class{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=a9,this.matchPos=d9(e,r),this.re=new RegExp(t,o9+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.flat=l9.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,precise:!0,match:t},this.matchPos=d9(this.text,n+ +(e==n)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=l9.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<`u`&&(s9.prototype[Symbol.iterator]=u9.prototype[Symbol.iterator]=function(){return this});function cEe(e){try{return new RegExp(e,o9),!0}catch{return!1}}function d9(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;for(;t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344;)t++;return t}var lEe=e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:i}=$xe(e,{label:t.phrase(`Go to line`),input:{type:`text`,name:`line`,value:n},focus:!0,submitLabel:t.phrase(`go`)});return i.then(n=>{let i=n&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.elements.line.value);if(!i){e.dispatch({effects:r});return}let a=t.doc.lineAt(t.selection.main.head),[,o,s,c,l]=i,u=c?+c.slice(1):0,d=s?+s:a.number;if(s&&l){let e=d/100;o&&(e=e*(o==`-`?-1:1)+a.number/t.doc.lines),d=Math.round(t.doc.lines*e)}else s&&o&&(d=d*(o==`-`?-1:1)+a.number);let f=t.doc.line(Math.max(1,Math.min(t.doc.lines,d))),p=J.cursor(f.from+Math.max(0,Math.min(u,f.length)));e.dispatch({effects:[r,Z.scrollIntoView(p.from,{y:`center`})],selection:p})}),!0},uEe={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},f9=Y.define({combine(e){return D1(e,uEe,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function dEe(e){let t=[gEe,hEe];return e&&t.push(f9.of(e)),t}var fEe=b0.mark({class:`cm-selectionMatch`}),pEe=b0.mark({class:`cm-selectionMatch cm-selectionMatch-main`});function p9(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=w1.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=w1.Word)}function mEe(e,t,n,r){return e(t.sliceDoc(n,n+1))==w1.Word&&e(t.sliceDoc(r-1,r))==w1.Word}var hEe=w2.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(f9),{state:n}=e,r=n.selection;if(r.ranges.length>1)return b0.none;let i=r.main,a,o=null;if(i.empty){if(!t.highlightWordAroundCursor)return b0.none;let e=n.wordAt(i.head);if(!e)return b0.none;o=n.charCategorizer(i.head),a=n.sliceDoc(e.from,e.to)}else{let e=i.to-i.from;if(e<t.minSelectionLength||e>200)return b0.none;if(t.wholeWords){if(a=n.sliceDoc(i.from,i.to),o=n.charCategorizer(i.head),!(p9(o,n,i.from,i.to)&&mEe(o,n,i.from,i.to)))return b0.none}else if(a=n.sliceDoc(i.from,i.to),!a)return b0.none}let s=[];for(let r of e.visibleRanges){let e=new i9(n.doc,a,r.from,r.to);for(;!e.next().done;){let{from:r,to:a}=e.value;if((!o||p9(o,n,r,a))&&(i.empty&&r<=i.from&&a>=i.to?s.push(pEe.range(r,a)):(r>=i.to||a<=i.from)&&s.push(fEe.range(r,a)),s.length>t.maxMatches))return b0.none}}return b0.set(s)}},{decorations:e=>e.decorations}),gEe=Z.baseTheme({".cm-selectionMatch":{backgroundColor:`#99ff7780`},".cm-searchMatch .cm-selectionMatch":{backgroundColor:`transparent`}}),_Ee=({state:e,dispatch:t})=>{let{selection:n}=e,r=J.create(n.ranges.map(t=>e.wordAt(t.head)||J.cursor(t.head)),n.mainIndex);return r.eq(n)?!1:(t(e.update({selection:r})),!0)};function vEe(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),a=i&&i.from==n.from&&i.to==n.to;for(let n=!1,i=new i9(e.doc,t,r[r.length-1].to);;)if(i.next(),i.done){if(n)return null;i=new i9(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),n=!0}else{if(n&&r.some(e=>e.from==i.value.from))continue;if(a){let t=e.wordAt(i.value.from);if(!t||t.from!=i.value.from||t.to!=i.value.to)continue}return i.value}}var yEe=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return _Ee({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=r))return!1;let i=vEe(e,r);return i?(t(e.update({selection:e.selection.addRange(J.range(i.from,i.to),!1),effects:Z.scrollIntoView(i.to)})),!0):!1},m9=Y.define({combine(e){return D1(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new NEe(e),scrollToMatch:e=>Z.scrollIntoView(e)})}}),h9=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||``,this.valid=!!this.search&&(!this.regexp||cEe(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>t==`n`?`
751
+ `:t==`r`?`\r`:t==`t`?` `:`\\`)}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new TEe(this):new SEe(this)}getCursor(e,t=0,n){let r=e.doc?e:E1.create({doc:e});return n??=r.doc.length,this.regexp?v9(this,r,t,n):_9(this,r,t,n)}},g9=class{constructor(e){this.spec=e}};function bEe(e,t,n){return(r,i,a,o)=>n&&!n(r,i,a,o)?!1:e(r>=o&&i<=o+a.length?a.slice(r-o,i-o):t.doc.sliceString(r,i),t,r,i)}function _9(e,t,n,r){let i;return e.wholeWord&&(i=xEe(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=bEe(e.test,t,i)),new i9(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}function xEe(e,t){return(n,r,i,a)=>((a>n||a+i.length<r)&&(a=Math.max(0,n-2),i=e.sliceString(a,Math.min(e.length,r+2))),(t(y9(i,n-a))!=w1.Word||t(b9(i,n-a))!=w1.Word)&&(t(b9(i,r-a))!=w1.Word||t(y9(i,r-a))!=w1.Word))}var SEe=class extends g9{constructor(e){super(e)}nextMatch(e,t,n){let r=_9(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=_9(this.spec,e,0,n).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==n?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let n=Math.max(t,r-1e4-this.spec.unquoted.length),i=_9(this.spec,e,n,r),a=null;for(;!i.nextOverlapping().done;)a=i.value;if(a)return a;if(n==t)return null;r-=1e4}}prevMatch(e,t,n){let r=this.prevMatchInRange(e,0,t);return r||=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length),r&&(r.from!=t||r.to!=n)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=_9(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=_9(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}};function CEe(e,t,n){return(r,i,a)=>(!n||n(r,i,a))&&e(a[0],t,r,i)}function v9(e,t,n,r){let i;return e.wholeWord&&(i=wEe(t.charCategorizer(t.selection.main.head))),e.test&&(i=CEe(e.test,t,i)),new s9(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function y9(e,t){return e.slice(M$(e,t,!1),t)}function b9(e,t){return e.slice(t,M$(e,t))}function wEe(e){return(t,n,r)=>!r[0].length||(e(y9(r.input,r.index))!=w1.Word||e(b9(r.input,r.index))!=w1.Word)&&(e(b9(r.input,r.index+r[0].length))!=w1.Word||e(y9(r.input,r.index+r[0].length))!=w1.Word)}var TEe=class extends g9{nextMatch(e,t,n){let r=v9(this.spec,e,n,e.doc.length).next();return r.done&&(r=v9(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let i=Math.max(t,n-r*1e4),a=v9(this.spec,e,i,n),o=null;for(;!a.next().done;)o=a.value;if(o&&(i==t||o.from>i+10))return o;if(i==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if(n==`&`)return e.match[0];if(n==`$`)return`$`;for(let t=n.length;t>0;t--){let r=+n.slice(0,t);if(r>0&&r<e.match.length)return e.match[r]+n.slice(t)}return t})}matchAll(e,t){let n=v9(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=v9(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}},x9=v1.define(),S9=v1.define(),C9=e1.define({create(e){return new w9(A9(e).create(),null)},update(e,t){for(let n of t.effects)n.is(x9)?e=new w9(n.value.create(),e.panel):n.is(S9)&&(e=new w9(e.query,n.value?k9:null));return e},provide:e=>L3.from(e,e=>e.panel)}),w9=class{constructor(e,t){this.query=e,this.panel=t}},EEe=b0.mark({class:`cm-searchMatch`}),DEe=b0.mark({class:`cm-searchMatch cm-searchMatch-selected`}),OEe=w2.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(C9))}update(e){let t=e.state.field(C9);(t!=e.startState.field(C9)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return b0.none;let{view:n}=this,r=new N1;for(let t=0,i=n.visibleRanges,a=i.length;t<a;t++){let{from:o,to:s}=i[t];for(;t<a-1&&s>i[t+1].from-500;)s=i[++t].to;e.highlight(n.state,o,s,(e,t)=>{let i=n.state.selection.ranges.some(n=>n.from==e&&n.to==t);r.add(e,t,i?DEe:EEe)})}return r.finish()}},{decorations:e=>e.decorations});function T9(e){return t=>{let n=t.state.field(C9,!1);return n&&n.query.spec.valid?e(t,n):N9(t)}}var E9=T9((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let i=J.single(r.from,r.to),a=e.state.facet(m9);return e.dispatch({selection:i,effects:[R9(e,r),a.scrollToMatch(i.main,e)],userEvent:`select.search`}),M9(e),!0}),D9=T9((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,i=t.prevMatch(n,r,r);if(!i)return!1;let a=J.single(i.from,i.to),o=e.state.facet(m9);return e.dispatch({selection:a,effects:[R9(e,i),o.scrollToMatch(a.main,e)],userEvent:`select.search`}),M9(e),!0}),kEe=T9((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:J.create(n.map(e=>J.range(e.from,e.to))),userEvent:`select.search.matches`}),!0)}),AEe=({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:i}=n.main,a=[],o=0;for(let t=new i9(e.doc,e.sliceDoc(r,i));!t.next().done;){if(a.length>1e3)return!1;t.value.from==r&&(o=a.length),a.push(J.range(t.value.from,t.value.to))}return t(e.update({selection:J.create(a,o),userEvent:`select.search.matches`})),!0},O9=T9((e,{query:t})=>{let{state:n}=e,{from:r,to:i}=n.selection.main;if(n.readOnly)return!1;let a=t.nextMatch(n,r,r);if(!a)return!1;let o=a,s=[],c,l,u=[];o.precise?o.from==r&&o.to==i&&(l=n.toText(t.getReplacement(o)),s.push({from:o.from,to:o.to,insert:l}),u.push(Z.announce.of(n.phrase(`replaced match on line $`,n.doc.lineAt(r).number)+`.`))):o=t.nextMatch(n,o.from,o.to);let d=e.state.changes(s);return o&&(c=J.single(o.from,o.to).map(d),u.push(R9(e,o)),u.push(n.facet(m9).scrollToMatch(c.main,e))),e.dispatch({changes:d,selection:c,effects:u,userEvent:`input.replace`}),!0}),jEe=T9((e,{query:t})=>{if(e.state.readOnly)return!1;let n=[];for(let r of t.matchAll(e.state,1e9)){let{from:e,to:i,precise:a}=r;a&&n.push({from:e,to:i,insert:t.getReplacement(r)})}if(!n.length)return!1;let r=e.state.phrase(`replaced $ matches`,n.length)+`.`;return e.dispatch({changes:n,effects:Z.announce.of(r),userEvent:`input.replace.all`}),!0});function k9(e){return e.state.facet(m9).createPanel(e)}function A9(e,t){let n=e.selection.main,r=n.empty||n.to>n.from+100?``:e.sliceDoc(n.from,n.to);if(t&&!r)return t;let i=e.facet(m9);return new h9({search:t?.literal??i.literal?r:r.replace(/\n/g,`\\n`),caseSensitive:t?.caseSensitive??i.caseSensitive,literal:t?.literal??i.literal,regexp:t?.regexp??i.regexp,wholeWord:t?.wholeWord??i.wholeWord})}function j9(e){let t=N3(e,k9);return t&&t.dom.querySelector(`[main-field]`)}function M9(e){let t=j9(e);t&&t==e.root.activeElement&&t.select()}var N9=e=>{let t=e.state.field(C9,!1);if(t&&t.panel){let n=j9(e);if(n&&n!=e.root.activeElement){let r=A9(e.state,t.query.spec);r.valid&&e.dispatch({effects:x9.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[S9.of(!0),t?x9.of(A9(e.state,t.query.spec)):v1.appendConfig.of(FEe)]});return!0},P9=e=>{let t=e.state.field(C9,!1);if(!t||!t.panel)return!1;let n=N3(e,k9);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:S9.of(!1)}),!0},MEe=[{key:`Mod-f`,run:N9,scope:`editor search-panel`},{key:`F3`,run:E9,shift:D9,scope:`editor search-panel`,preventDefault:!0},{key:`Mod-g`,run:E9,shift:D9,scope:`editor search-panel`,preventDefault:!0},{key:`Escape`,run:P9,scope:`editor search-panel`},{key:`Mod-Shift-l`,run:AEe},{key:`Mod-Alt-g`,run:lEe},{key:`Mod-d`,run:yEe,preventDefault:!0}],NEe=class{constructor(e){this.view=e;let t=this.query=e.state.field(C9).query.spec;this.commit=this.commit.bind(this),this.searchField=t0(`input`,{value:t.search,placeholder:F9(e,`Find`),"aria-label":F9(e,`Find`),class:`cm-textfield`,name:`search`,form:``,"main-field":`true`,onchange:this.commit,onkeyup:this.commit}),this.replaceField=t0(`input`,{value:t.replace,placeholder:F9(e,`Replace`),"aria-label":F9(e,`Replace`),class:`cm-textfield`,name:`replace`,form:``,onchange:this.commit,onkeyup:this.commit}),this.caseField=t0(`input`,{type:`checkbox`,name:`case`,form:``,checked:t.caseSensitive,onchange:this.commit}),this.reField=t0(`input`,{type:`checkbox`,name:`re`,form:``,checked:t.regexp,onchange:this.commit}),this.wordField=t0(`input`,{type:`checkbox`,name:`word`,form:``,checked:t.wholeWord,onchange:this.commit});function n(e,t,n){return t0(`button`,{class:`cm-button`,name:e,onclick:t,type:`button`},n)}this.dom=t0(`div`,{onkeydown:e=>this.keydown(e),class:`cm-search`},[this.searchField,n(`next`,()=>E9(e),[F9(e,`next`)]),n(`prev`,()=>D9(e),[F9(e,`previous`)]),n(`select`,()=>kEe(e),[F9(e,`all`)]),t0(`label`,null,[this.caseField,F9(e,`match case`)]),t0(`label`,null,[this.reField,F9(e,`regexp`)]),t0(`label`,null,[this.wordField,F9(e,`by word`)]),...e.state.readOnly?[]:[t0(`br`),this.replaceField,n(`replace`,()=>O9(e),[F9(e,`replace`)]),n(`replaceAll`,()=>jEe(e),[F9(e,`replace all`)])],t0(`button`,{name:`close`,onclick:()=>P9(e),"aria-label":F9(e,`close`),type:`button`},[`×`])])}commit(){let e=new h9({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:x9.of(e)}))}keydown(e){Uxe(this.view,e,`search-panel`)?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?D9:E9)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),O9(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(x9)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(m9).top}};function F9(e,t){return e.state.phrase(t)}var I9=30,L9=/[\s\.,:;?!]/;function R9(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),i=e.state.doc.lineAt(n).to,a=Math.max(r.from,t-I9),o=Math.min(i,n+I9),s=e.state.sliceDoc(a,o);if(a!=r.from){for(let e=0;e<I9;e++)if(!L9.test(s[e+1])&&L9.test(s[e])){s=s.slice(e);break}}if(o!=i){for(let e=s.length-1;e>s.length-I9;e--)if(!L9.test(s[e-1])&&L9.test(s[e])){s=s.slice(0,e);break}}return Z.announce.of(`${e.state.phrase(`current match`)}. ${s} ${e.state.phrase(`on line`)} ${r.number}.`)}var PEe=Z.baseTheme({".cm-panel.cm-search":{padding:`2px 6px 4px`,position:`relative`,"& [name=close]":{position:`absolute`,top:`0`,right:`4px`,backgroundColor:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0},"& input, & button, & label":{margin:`.2em .6em .2em 0`},"& input[type=checkbox]":{marginRight:`.2em`},"& label":{fontSize:`80%`,whiteSpace:`pre`}},"&light .cm-searchMatch":{backgroundColor:`#ffff0054`},"&dark .cm-searchMatch":{backgroundColor:`#00ffff8a`},"&light .cm-searchMatch-selected":{backgroundColor:`#ff6a0054`},"&dark .cm-searchMatch-selected":{backgroundColor:`#ff00ff8a`}}),FEe=[C9,r1.low(OEe),PEe],IEe=`modulepreload`,LEe=function(e){return`/`+e},z9={},REe=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=LEe(t,n),t in z9)return;z9[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:IEe,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},B9=[{label:`All TPS events`,sql:`SELECT * FROM tps_flat ORDER BY timestamp`},{label:`Per-model aggregates`,sql:`SELECT
752
752
  provider,
753
753
  model_id,
754
754
  COUNT(*) AS calls,
@@ -846,5 +846,5 @@ LIMIT 100`},{label:`Energy & CO₂ detail`,sql:`SELECT
846
846
  ratio_was_capped
847
847
  FROM tps_paired
848
848
  WHERE energy_joules IS NOT NULL
849
- ORDER BY timestamp`}],V9=``,H9=/^_grp_count_(\d+)$/,U9={id:`ID`,usd:`USD`,ms:`MS`,cwd:`CWD`,url:`URL`,uri:`URI`,api:`API`,http:`HTTP`,https:`HTTPS`,ip:`IP`,db:`DB`,sql:`SQL`,jwt:`JWT`,csv:`CSV`,html:`HTML`,css:`CSS`,js:`JS`,ts:`TS`,json:`JSON`,xml:`XML`,os:`OS`,cpu:`CPU`,ram:`RAM`,gpu:`GPU`,ai:`AI`,llm:`LLM`,tps:`TPS`,ttft:`TTFT`,pct:`PCT`,avg:`AVG`};function W9(e){let t=e.match(H9);if(t)return`Count (L${t[1]})`;let n=e.replace(/_/g,` `);return n=n.replace(/([a-z0-9])([A-Z])/g,`$1 $2`),n.split(/\s+/).filter(Boolean).map(e=>{let t=e.toLowerCase();return U9[t]?U9[t]:e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}).join(` `)}function zEe(e){let t=e.toLowerCase();return t===`timestamp`||t===`time`||t===`createdat`||t===`updatedat`||t===`created_at`||t===`updated_at`||t===`session_start`||t===`session_end`}function BEe(e,t){let n=new Set;for(let r=0;r<e.length;r++){let i=e[r];for(let e=0;e<t.length;e++){let a=t[e][r];if(typeof a==`string`&&a.length>60){n.add(i);break}}}return n}var VEe=/[*_`>[\]#~|]/,HEe=/^[>|#*\-+] |^\d+\. |^```/m;function UEe(e){return VEe.test(e)?HEe.test(e)||/\|/.test(e)&&/\n/.test(e)?2:1:0}var WEe=/(\*\*[^*]+?\*\*|__[^_]+?__|~~[^~]+?~~|\*[^*]+?\*|_[^_]+?_|`[^`]+?`|\[.+?\]\(.+?\))/g,GEe=(0,b.memo)(function({text:e}){return(0,F.jsx)(`span`,{className:`text-zinc-600 dark:text-zinc-300`,children:e.split(WEe).filter(Boolean).map((e,t)=>{if(e.startsWith(`**`)||e.startsWith(`__`))return(0,F.jsx)(`strong`,{className:`font-semibold text-zinc-800 dark:text-zinc-200`,children:e.slice(2,-2)},t);if(e.startsWith(`~~`))return(0,F.jsx)(`del`,{children:e.slice(2,-2)},t);if(e.startsWith(`*`)||e.startsWith(`_`))return(0,F.jsx)(`em`,{className:`italic`,children:e.slice(1,-1)},t);if(e.startsWith("`"))return(0,F.jsx)(`code`,{className:`bg-zinc-100 dark:bg-zinc-900 rounded px-1 font-mono text-[11px]`,children:e.slice(1,-1)},t);if(e.startsWith(`[`)){let n=e.match(/\[(.+?)\]\((.+?)\)/);if(n)return(0,F.jsx)(`a`,{href:n[2],className:`text-accent underline`,target:`_blank`,rel:`noopener noreferrer`,children:n[1]},t)}return(0,F.jsx)(`span`,{children:e},t)})})}),G9=(0,b.memo)(function({text:e}){let t=UEe(e);return t===0?(0,F.jsx)(`span`,{className:`text-zinc-600 dark:text-zinc-300`,children:e}):t===1?(0,F.jsx)(GEe,{text:e}):(0,F.jsx)(g_e,{remarkPlugins:[kye],disallowedElements:[`h1`,`h2`,`h3`,`h4`,`h5`,`h6`,`hr`,`img`],unwrapDisallowed:!0,components:{p:({children:e})=>(0,F.jsx)(`span`,{children:e}),a:({href:e,children:t})=>(0,F.jsx)(`a`,{href:e,className:`text-accent underline`,target:`_blank`,rel:`noopener noreferrer`,children:t}),strong:({children:e})=>(0,F.jsx)(`strong`,{className:`font-semibold text-zinc-800 dark:text-zinc-200`,children:e}),em:({children:e})=>(0,F.jsx)(`em`,{className:`italic`,children:e}),code:({className:e,children:t})=>{if(!e||!e.startsWith(`language-`))return(0,F.jsx)(`code`,{className:`bg-zinc-100 dark:bg-zinc-900 rounded px-1 font-mono text-[11px]`,children:t});let n=e.replace(`language-`,``);return(0,F.jsxs)(`pre`,{className:`bg-zinc-100 dark:bg-zinc-900 rounded px-1.5 py-0.5 my-0.5 overflow-x-auto`,children:[n&&(0,F.jsx)(`div`,{className:`text-[9px] uppercase tracking-wider text-zinc-400 dark:text-zinc-500 mb-0.5`,children:n}),(0,F.jsx)(`code`,{className:`font-mono text-[11px]`,children:t})]})},blockquote:({children:e})=>(0,F.jsx)(`blockquote`,{className:`border-l-2 border-zinc-300 dark:border-zinc-600 pl-2 italic text-zinc-500 dark:text-zinc-400 my-0.5`,children:e}),ul:({children:e})=>(0,F.jsx)(`ul`,{className:`list-disc pl-4 my-0.5`,children:e}),ol:({children:e})=>(0,F.jsx)(`ol`,{className:`list-decimal pl-4 my-0.5`,children:e}),li:({children:e})=>(0,F.jsx)(`li`,{children:e}),table:({children:e})=>(0,F.jsx)(`table`,{className:`border-collapse text-[11px] my-1 w-full`,children:e}),thead:({children:e})=>(0,F.jsx)(`thead`,{className:`bg-zinc-100 dark:bg-zinc-900 border-b border-zinc-200/60 dark:border-white/[0.06]`,children:e}),tbody:({children:e})=>(0,F.jsx)(`tbody`,{children:e}),tr:({children:e})=>(0,F.jsx)(`tr`,{className:`border-b border-zinc-200/40 dark:border-white/[0.04]`,children:e}),th:({children:e})=>(0,F.jsx)(`th`,{className:`px-2 py-1 text-left font-medium text-zinc-600 dark:text-zinc-300`,children:e}),td:({children:e})=>(0,F.jsx)(`td`,{className:`px-2 py-1 text-zinc-600 dark:text-zinc-300`,children:e}),br:()=>(0,F.jsx)(`br`,{})},children:e})});function K9(e,t){return e==null?`NULL`:typeof e==`number`&&zEe(t)&&Number.isFinite(e)&&e>0xe8d4a51000?new Date(e).toISOString().replace(`T`,` `).slice(0,19):typeof e==`number`?e%1==0?e.toLocaleString():e.toFixed(4):String(e)}function KEe(e,t,n){let r=t.length<=500?1:Math.ceil(t.length/500),i=new Set([`timestamp`,`time`,`createdat`,`updatedat`,`created_at`,`updated_at`,`session_start`,`session_end`]);return e.map((e,a)=>{let o=e.toLowerCase(),s=e.replace(/_/g,` `).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).split(/\s+/).filter(Boolean),c=s.reduce((e,t)=>e+(U9[t.toLowerCase()]||t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).length,s.length-1)*7+24,l=i.has(o);for(let i=0;i<t.length;i+=r){let r=t[i][a],o;o=r==null?4:typeof r==`number`?l&&Number.isFinite(r)&&r>0xe8d4a51000?19:r%1==0?r.toLocaleString().length:r.toFixed(4).length:String(r).length;let s=n.has(e)?520:300;c=Math.max(c,Math.min(o*7+24,s))}return c})}function qEe(e,t){if(t.length===0)return null;let n=e.replace(/;+\s*$/,``).trim();return`SELECT _sub.*, ${t.map((e,t)=>`COUNT(*) OVER (PARTITION BY ${e}) AS _grp_count_${t+1}`).join(`, `)} FROM (${n}) AS _sub`}function JEe(e,t){let n=[],r=/COUNT\(\*\)\s+OVER\s+\(\s*PARTITION\s+BY\s+([^)]+)\)\s+AS\s+_grp_count_(\d+)/gi,i;for(;(i=r.exec(e))!==null;){let e=i[1].trim().split(`.`).pop(),t=parseInt(i[2],10)-1;for(;n.length<=t;)n.push(``);n[t]=e}return n.filter(e=>e&&t.includes(e))}function YEe(e,t){let n=e.replace(/--[^\n]*\n?/g,` `).replace(/\/\*[\s\S]*?\*\//g,` `),r=JEe(n,t);if(r.length>0)return r;let i=n.match(/GROUP\s+BY\s+([^)]+?)(?:\s+ORDER\s+BY|\s+LIMIT|\s+HAVING|\s+WINDOW|\s+QUALIFY|$)/i);if(!i)return[];let a=i[1].split(`,`).map(e=>e.trim()).filter(Boolean),o=n.match(/SELECT\s+(.*?)\s+FROM\s+/is),s=[];if(o){let e=o[1].split(`,`).map(e=>e.trim());for(let t of e){let e=t.match(/\s+AS\s+(\w+)$/i);if(e)s.push(e[1]);else{let e=t.split(/\s+/),n=e[e.length-1].replace(/[^a-zA-Z0-9_]/g,``);n&&s.push(n)}}}return a.map(e=>{let t=parseInt(e,10);return!isNaN(t)&&t>0&&t<=s.length?s[t-1]:e.split(`.`).pop()}).filter(e=>t.includes(e))}function XEe(e,t,n){if(n.length===0||e.length===0)return[];let r=n.map(e=>t.indexOf(e));if(r.some(e=>e===-1))return[];let i=n.map((e,n)=>t.indexOf(`_grp_count_${n+1}`)),a=new Map;for(let t of e){let e=r.map(e=>String(t[e]??``));for(let r=0;r<n.length;r++){let n=e.slice(0,r+1).join(V9),o=i[r],s=o===-1?0:Number(t[o]);a.has(n)||a.set(n,s)}}let o=0;function s(e,t){let r=[];for(let[i,c]of a){let a=i.split(V9);if(a.length!==t+1||t>0&&a.slice(0,t).join(V9)!==e)continue;let l=a[t],u=a.join(V9);if(t===n.length-1)r.push({id:o++,value:l||null,depth:t,groupCount:c,children:[],path:u});else{let e=s(u,t+1),n=e.reduce((e,t)=>e+t.groupCount,0);r.push({id:o++,value:l||null,depth:t,groupCount:n,children:e,path:u})}}return r.sort((e,t)=>t.groupCount-e.groupCount),r}return s(``,0)}function ZEe(e,t,n){let r=e.map(e=>t.indexOf(e)),i=new Map;for(let t=0;t<n.length;t++){let a=n[t],o=r.map(e=>String(a[e]??``));for(let n=0;n<e.length;n++){let e=o.slice(0,n+1).join(V9),r=i.get(e);r||(r=[],i.set(e,r)),r.push(t)}}return i}var q9={group:36,detail:30,flat:36};function J9(e,t,n,r,i){let a=[];for(let o of e){let e=o.children.length>0;if(a.push({type:`group`,nodeId:o.id,depth:i}),e&&t.has(o.id))a.push(...J9(o.children,t,n,r,i+1));else if(!e&&n.has(o.id)){let e=r.get(o.path),t=e?e.length:0;for(let e=0;e<t;e++)a.push({type:`detail`,nodeId:o.id,depth:i,rowIndex:e})}}return a}function QEe(e){return e.filter(e=>!H9.test(e))}function $Ee({cols:e}){return(0,F.jsx)(`div`,{className:`flex items-center gap-3 px-3 py-2 border-b border-zinc-200/40 dark:border-white/[0.04]`,children:Array.from({length:e}).map((e,t)=>(0,F.jsx)(`div`,{className:`h-3 rounded bg-zinc-200/60 dark:bg-zinc-700/40 animate-pulse`,style:{width:`${60+t*17%30}px`}},t))})}var Y9=[`events`,`tps_flat`,`energy_flat`,`messages_flat`],X9={events:`session_id.id.parent_id.timestamp.type.provider.model_id.tokens_input.tokens_output.tokens_cache_read.tokens_cache_write.tokens_total.ttft_ms.total_ms.generation_ms.stream_ms.stall_ms.stall_count.tps.cost_input.cost_output.cost_cache_read.cost_cache_write.cost_total.energy_joules.energy_cost_usd.rewind_v.from_id.summary.message_role.message_content.message_model`.split(`.`),tps_flat:[`session_id`,`id`,`parent_id`,`timestamp`,`provider`,`model_id`,`tokens_input`,`tokens_output`,`tokens_cache_read`,`tokens_cache_write`,`tokens_total`,`ttft_ms`,`total_ms`,`generation_ms`,`stream_ms`,`stall_ms`,`stall_count`,`tps`,`cost_input`,`cost_output`,`cost_cache_read`,`cost_cache_write`,`cost_total`],energy_flat:[`session_id`,`id`,`parent_id`,`timestamp`,`energy_joules`,`energy_cost_usd`],messages_flat:[`session_id`,`id`,`parent_id`,`timestamp`,`message_role`,`message_content`,`message_model`]},eDe=K5.define({keywords:`select from where group by order having limit offset as and or not in is null like between exists case when then else end insert into values create table view drop if alter set join on left right inner outer cross union all distinct asc desc over partition window function cast coalesce nullif true false with recursive using natural full fetch next rows range unbounded preceding following current row exclude`,types:`varchar bigint double int boolean float date timestamp`,builtin:`count sum avg min max round abs ceil floor row_number rank dense_rank lag lead first_value last_value list unnest struct_extract array_agg string_agg concat coalesce nullif cast try_cast date_trunc now extract interval generate_series read_csv read_parquet count_if`}),Z9=Z.theme({"&":{fontSize:`12px`,fontFamily:`'Geist Mono', 'JetBrains Mono', monospace`},".cm-content":{padding:`12px 16px`,caretColor:`#0891b2`},".cm-focused":{outline:`none`},".cm-gutters":{backgroundColor:`transparent`,border:`none`,color:`#a1a1aa`,paddingRight:`4px`},".cm-activeLineGutter":{backgroundColor:`rgba(8, 145, 178, 0.05)`,color:`#71717a`},".cm-activeLine":{backgroundColor:`rgba(8, 145, 178, 0.04)`},".cm-selectionBackground":{backgroundColor:`rgba(8, 145, 178, 0.15) !important`},".cm-cursor":{borderLeftColor:`#0891b2`,borderLeftWidth:`2px`},".cm-matchingBracket":{backgroundColor:`rgba(8, 145, 178, 0.2)`,outline:`1px solid rgba(8, 145, 178, 0.4)`},"&.cm-focused .cm-selectionBackground":{backgroundColor:`rgba(8, 145, 178, 0.2) !important`}}),Q9=Z.theme({"&":{fontSize:`12px`,fontFamily:`'Geist Mono', 'JetBrains Mono', monospace`,color:`#d4d4d8`,backgroundColor:`transparent`},".cm-content":{padding:`12px 16px`,caretColor:`#06b6d4`},".cm-focused":{outline:`none`},".cm-gutters":{backgroundColor:`transparent`,border:`none`,color:`#52525b`,paddingRight:`4px`},".cm-activeLineGutter":{backgroundColor:`rgba(6, 182, 212, 0.05)`,color:`#71717a`},".cm-activeLine":{backgroundColor:`rgba(6, 182, 212, 0.04)`},".cm-selectionBackground":{backgroundColor:`rgba(6, 182, 212, 0.15) !important`},".cm-cursor":{borderLeftColor:`#06b6d4`,borderLeftWidth:`2px`},".cm-matchingBracket":{backgroundColor:`rgba(6, 182, 212, 0.2)`,outline:`1px solid rgba(6, 182, 212, 0.4)`},"&.cm-focused .cm-selectionBackground":{backgroundColor:`rgba(6, 182, 212, 0.2) !important`}},{dark:!0}),tDe=c8.define([{tag:$.keyword,color:`#0e7490`,fontWeight:`600`},{tag:$.controlKeyword,color:`#0e7490`,fontWeight:`600`},{tag:$.definitionKeyword,color:`#0e7490`,fontWeight:`600`},{tag:$.operatorKeyword,color:`#0e7490`,fontWeight:`600`},{tag:$.moduleKeyword,color:`#0e7490`,fontWeight:`600`},{tag:$.string,color:`#b45309`},{tag:$.docString,color:`#b45309`},{tag:$.character,color:`#b45309`},{tag:$.number,color:`#9333ea`},{tag:$.integer,color:`#9333ea`},{tag:$.float,color:`#9333ea`},{tag:$.bool,color:`#0e7490`,fontStyle:`italic`},{tag:$.null,color:`#0e7490`,fontStyle:`italic`},{tag:$.atom,color:`#0e7490`,fontStyle:`italic`},{tag:$.typeName,color:`#15803d`},{tag:$.variableName,color:`#09090b`},{tag:$.propertyName,color:`#7c3aed`},{tag:$.function($.variableName),color:`#0e7490`},{tag:$.labelName,color:`#7c3aed`},{tag:$.operator,color:`#52525b`},{tag:$.arithmeticOperator,color:`#52525b`},{tag:$.compareOperator,color:`#52525b`},{tag:$.logicOperator,color:`#0e7490`},{tag:$.punctuation,color:`#a1a1aa`},{tag:$.bracket,color:`#a1a1aa`},{tag:$.separator,color:`#a1a1aa`},{tag:$.comment,color:`#a1a1aa`,fontStyle:`italic`},{tag:$.lineComment,color:`#a1a1aa`,fontStyle:`italic`},{tag:$.blockComment,color:`#a1a1aa`,fontStyle:`italic`},{tag:$.special($.string),color:`#0e7490`},{tag:$.escape,color:`#0e7490`},{tag:$.meta,color:`#71717a`},{tag:$.invalid,color:`#dc2626`}],{themeType:`light`}),nDe=c8.define([{tag:$.keyword,color:`#22d3ee`,fontWeight:`600`},{tag:$.controlKeyword,color:`#22d3ee`,fontWeight:`600`},{tag:$.definitionKeyword,color:`#22d3ee`,fontWeight:`600`},{tag:$.operatorKeyword,color:`#22d3ee`,fontWeight:`600`},{tag:$.moduleKeyword,color:`#22d3ee`,fontWeight:`600`},{tag:$.string,color:`#fbbf24`},{tag:$.docString,color:`#fbbf24`},{tag:$.character,color:`#fbbf24`},{tag:$.number,color:`#c084fc`},{tag:$.integer,color:`#c084fc`},{tag:$.float,color:`#c084fc`},{tag:$.bool,color:`#22d3ee`,fontStyle:`italic`},{tag:$.null,color:`#22d3ee`,fontStyle:`italic`},{tag:$.atom,color:`#22d3ee`,fontStyle:`italic`},{tag:$.typeName,color:`#4ade80`},{tag:$.variableName,color:`#d4d4d8`},{tag:$.propertyName,color:`#c084fc`},{tag:$.function($.variableName),color:`#22d3ee`},{tag:$.labelName,color:`#c084fc`},{tag:$.operator,color:`#a1a1aa`},{tag:$.arithmeticOperator,color:`#a1a1aa`},{tag:$.compareOperator,color:`#a1a1aa`},{tag:$.logicOperator,color:`#22d3ee`},{tag:$.punctuation,color:`#71717a`},{tag:$.bracket,color:`#71717a`},{tag:$.separator,color:`#71717a`},{tag:$.comment,color:`#52525b`,fontStyle:`italic`},{tag:$.lineComment,color:`#52525b`,fontStyle:`italic`},{tag:$.blockComment,color:`#52525b`,fontStyle:`italic`},{tag:$.special($.string),color:`#22d3ee`},{tag:$.escape,color:`#22d3ee`},{tag:$.meta,color:`#71717a`},{tag:$.invalid,color:`#f87171`}],{themeType:`dark`}),rDe=`SELECT.FROM.WHERE.GROUP.BY.ORDER.HAVING.LIMIT.OFFSET.AS.AND.OR.NOT.IN.IS.NULL.LIKE.BETWEEN.EXISTS.CASE.WHEN.THEN.ELSE.END.INSERT.INTO.VALUES.CREATE.TABLE.VIEW.DROP.IF.ALTER.SET.JOIN.ON.LEFT.RIGHT.INNER.OUTER.CROSS.UNION.ALL.DISTINCT.ASC.DESC.OVER.PARTITION.WINDOW.FUNCTION.CAST.COALESCE.NULLIF.TRUE.FALSE.WITH.RECURSIVE.USING.NATURAL.FULL.FETCH.NEXT.ROWS.RANGE.UNBOUNDED.PRECEDING.FOLLOWING.CURRENT.ROW.EXCLUDE`.split(`.`),iDe=`COUNT.SUM.AVG.MIN.MAX.ROUND.ABS.CEIL.FLOOR.ROW_NUMBER.RANK.DENSE_RANK.LAG.LEAD.FIRST_VALUE.LAST_VALUE.LIST.UNNEST.STRUCT_EXTRACT.ARRAY_AGG.STRING_AGG.CONCAT.COALESCE.NULLIF.CAST.TRY_CAST.DATE_TRUNC.NOW.EXTRACT.INTERVAL.GENERATE_SERIES.READ_CSV.READ_PARQUET.COUNT_IF`.split(`.`),aDe=[`VARCHAR`,`BIGINT`,`DOUBLE`,`INTEGER`,`BOOLEAN`,`FLOAT`,`DATE`,`TIMESTAMP`];function $9(e){let t=e.matchBefore(/[\w.]+/),n=t?t.from:e.pos;if(!t&&!e.explicit)return null;let r=[];for(let e of rDe)r.push({label:e,type:`keyword`,detail:`keyword`});for(let e of iDe)r.push({label:e,type:`function`,detail:`function`});for(let e of aDe)r.push({label:e,type:`type`,detail:`type`});for(let e of Y9)r.push({label:e,type:`class`,detail:`table`});for(let[e,t]of Object.entries(X9))for(let n of t)r.push({label:n,type:`property`,detail:e});return{from:n,options:r,filter:!0}}function oDe({dbVersion:e,activeSessionId:t}){let{theme:n}=_p(),[r,i]=(0,b.useState)(``),[a,o]=(0,b.useState)(``),[s,c]=(0,b.useState)(null),[l,u]=(0,b.useState)(!1),[d,f]=(0,b.useState)(!1),[p,m]=(0,b.useState)(null),[h,g]=(0,b.useState)([]),[_,v]=(0,b.useState)([]),[y,x]=(0,b.useState)(new Set),[S,C]=(0,b.useState)(new Set),w=_.length>0?_:h,[T,E]=(0,b.useState)(!1),[D,O]=(0,b.useState)(null),[k,ee]=(0,b.useState)(1),[te,ne]=(0,b.useState)(!1),[re,A]=(0,b.useState)(0),ie=(0,b.useRef)(null),j=(0,b.useRef)(null),M=(0,b.useRef)(null),ae=(0,b.useRef)(null),[oe,se]=(0,b.useState)(33),N=(0,b.useRef)(new o1),ce=(0,b.useRef)(new o1),le=(0,b.useRef)(()=>{}),ue=(0,b.useCallback)(async()=>{if(d)return;let{getDuckDB:e}=await LEe(async()=>{let{getDuckDB:e}=await Promise.resolve().then(()=>dx);return{getDuckDB:e}},void 0);await e(),f(!0)},[]),de=(0,b.useCallback)(async(e,t)=>{let n=e??r;if(n.trim()){u(!0),m(null);try{await ue();let e=await _x(),r=n.replace(/;+\s*$/,``);t&&(r=`SELECT * FROM (${r}) AS _q WHERE session_id = '${t.replace(/'/g,`''`)}'`);let i=`SELECT * FROM (${r}) AS _q LIMIT 50000`,a=await e.query(i),o=a.schema.fields.map(e=>e.name),s=[];for(let e of a.batches){let t=o.map(t=>e.getChild(t));for(let n=0;n<e.numRows;n++)s.push(t.map(e=>{let t=e?.get(n);return typeof t==`bigint`?Number(t):t??null}))}let l={columns:o,rows:s,rowCount:s.length};(l.rowCount>0||o.length>0)&&(c(l),g(YEe(n,l.columns)),ne(!0))}catch(e){m(e instanceof Error?e.message:`Query failed`)}finally{u(!1)}}},[r,ue]),fe=(0,b.useCallback)(()=>{h.length===0&&o(r),de(r,t)},[r,de,h,t]);(0,b.useEffect)(()=>{le.current=fe},[fe]),(0,b.useEffect)(()=>{e>0&&s&&r.trim()&&de(r,t)},[e]),(0,b.useEffect)(()=>{s&&r.trim()&&de(r,t)},[t]);let pe=(0,b.useCallback)(async e=>{if(!a.trim())return;if(e.length===0){v([]),i(a),M.current&&M.current.dispatch({changes:{from:0,to:M.current.state.doc.length,insert:a}}),de(a,t);return}let n=qEe(a,e);n&&(i(n),M.current&&M.current.dispatch({changes:{from:0,to:M.current.state.doc.length,insert:n}}),v(e),de(n,t),x(new Set),C(new Set))},[a,de,t]);(0,b.useEffect)(()=>{if(!ie.current)return;let e=n===`dark`,t=new Z({state:D1.create({doc:r,extensions:[cSe(),dSe(),Gxe(),nTe(),eCe(),YCe(),uEe(),Kwe({dialect:eDe,tables:Y9.map(e=>({label:e,type:`table`,columns:X9[e]?.map(e=>({label:e,type:`column`}))??[]}))}),ce.current.of(v5({override:[$9],activateOnTyping:!0,tooltipClass:()=>`cm-tps-autocomplete`})),N.current.of(e?Q9:Z9),f8(tDe),f8(nDe),b3.of([{key:`Mod-Enter`,run:()=>(le.current(),!0)},...QCe,...oEe,...jEe,...dTe]),Z.updateListener.of(e=>{e.docChanged&&(i(e.state.doc.toString()),ee(e.state.doc.lines))}),Z.lineWrapping]}),parent:ie.current});return M.current=t,()=>{t.destroy(),M.current=null}},[]),(0,b.useEffect)(()=>{if(!M.current)return;let e=n===`dark`;M.current.dispatch({effects:[ce.current.reconfigure(v5({override:[$9],activateOnTyping:!0,tooltipClass:()=>`cm-tps-autocomplete`})),N.current.reconfigure(e?Q9:Z9)]})},[n]),(0,b.useEffect)(()=>{let e=ae.current;if(!e)return;let t=()=>{let t=e.getBoundingClientRect().height;t>0&&se(t)};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[s]),(0,b.useEffect)(()=>{let e=j.current;if(!e)return;let t=()=>{let t=e.getBoundingClientRect().height;t>0&&A(t)};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[r,s,k,p,h,T]);let me=(0,b.useCallback)((e,t)=>{O(t),e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,t)},[]),he=(0,b.useCallback)(()=>{O(null)},[]),ge=(0,b.useCallback)(e=>{e.preventDefault(),E(!1);let t=e.dataTransfer.getData(`text/plain`);!t||h.includes(t)||(pe([...h,t]),O(null))},[h,pe]),_e=(0,b.useCallback)(e=>{pe(h.filter(t=>t!==e))},[h,pe]),ve=(0,b.useCallback)(e=>{x(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),ye=(0,b.useCallback)(e=>{C(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),be=(0,b.useMemo)(()=>s&&h.length>0&&s.rows.length>0?XEe(s.rows,s.columns,h):null,[s,h]),xe=(0,b.useMemo)(()=>{if(!be)return!1;function e(t){for(let n of t)if(n.children.length>0){if(!e(n.children))return!1}else if(n.groupCount>1)return!1;return!0}return e(be)},[be]),Se=(0,b.useMemo)(()=>s?s.columns.filter(e=>!H9.test(e)):[],[s]),Ce=(0,b.useMemo)(()=>s&&h.length>0?ZEe(h,s.columns,s.rows):new Map,[s,h]),we=(0,b.useMemo)(()=>{if(!be)return new Map;let e=new Map;function t(n){for(let r of n)e.set(r.id,r),r.children.length>0&&t(r.children)}return t(be),e},[be]),Te=(0,b.useMemo)(()=>be&&be.length>0&&h.length>0&&!xe?J9(be,y,S,Ce,0):s?s.rows.map((e,t)=>({type:`flat`,rowIndex:t})):[],[be,h,xe,y,S,Ce,s]),Ee=(0,b.useMemo)(()=>s?QEe(s.columns):[],[s]),De=(0,b.useMemo)(()=>Ee.map(e=>s?s.columns.indexOf(e):-1),[Ee,s]),Oe=(0,b.useMemo)(()=>Se.map(e=>s?s.columns.indexOf(e):-1),[Se,s]),ke=(0,b.useRef)(null),Ae=xJ({count:Te.length,getScrollElement:()=>ke.current,estimateSize:e=>{let t=Te[e];return t?t.type===`group`?q9.group:q9[t.type]:36},measureElement:e=>e.getBoundingClientRect().height,overscan:20}),je=Ae.getVirtualItems(),Me=Ae.scrollOffset??0,Ne=null;if(be&&be.length>0&&h.length>0&&!xe&&je.length>0){let e=-1;for(let t of je){let n=Te[t.index];if(n){if(n.type!==`group`){e=t.index;break}if(t.start+t.size<=Me)Ne={nodeId:n.nodeId,depth:n.depth};else{Ne=null;break}}}if(e>=0&&!Ne)for(let t=e-1;t>=0;t--){let e=Te[t];if(e&&e.type===`group`){Ne={nodeId:e.nodeId,depth:e.depth};break}}}let Pe=(0,b.useCallback)(()=>{if(!s)return;let e=Ee,t=[e.map(W9).join(`,`),...s.rows.map(t=>e.map(e=>{let n=s.columns.indexOf(e),r=n===-1?null:t[n],i=r==null?``:String(r);return/[",\r\n]/.test(i)?`"${i.replace(/"/g,`""`)}"`:i}).join(`,`))].join(`
850
- `),n=new Blob([t],{type:`text/csv;charset=utf-8`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`query-result-${new Date().toISOString().slice(0,19).replace(/[T:]/g,`-`)}.csv`,i.click(),URL.revokeObjectURL(r)},[s,Ee]),Fe=(0,b.useCallback)(()=>{i(``),o(``),c(null),m(null),g([]),x(new Set),C(new Set),ee(1),ne(!1),M.current&&M.current.dispatch({changes:{from:0,to:M.current.state.doc.length,insert:``}})},[]),Ie=(0,b.useCallback)(e=>{i(e),M.current&&M.current.dispatch({changes:{from:0,to:M.current.state.doc.length,insert:e}})},[]),Le=(0,b.useMemo)(()=>{if(!r.trim())return``;let e=r.replace(/\n+/g,` `).replace(/\s+/g,` `).trim();return e.length>80?e.slice(0,77)+`...`:e},[r]),Re=(0,b.useCallback)(()=>ne(!1),[]),ze=(0,b.useCallback)(()=>ne(!0),[]),{colWidths:Be,longTextCols:Ve}=(0,b.useMemo)(()=>{if(!s)return{colWidths:[],longTextCols:new Set};let e=s.rows.length<=500?1:Math.ceil(s.rows.length/500),t=Se.map(e=>s.columns.indexOf(e)),n=[];for(let r=0;r<s.rows.length;r+=e){let e=s.rows[r];n.push(t.map(t=>t===-1?null:e[t]))}let r=BEe(Se,n),i=KEe(Se,n,r);if(be&&be.length>0&&h.length>0&&!xe&&i.length>0){let e=0;function t(n,r){for(let i of n){let n=r*16,a=(i.value===null?`NULL`:String(i.value)).length*8+8;e=Math.max(e,n+48+a),i.children.length>0&&t(i.children,r+1)}}t(be,0),i[0]=Math.max(i[0],e)}return{colWidths:i,longTextCols:r}},[s,Se,be,h,xe]);return(0,F.jsxs)(`div`,{className:`bg-white/80 dark:bg-zinc-800/40 border border-zinc-200/60 dark:border-white/[0.06] rounded-2xl overflow-hidden flex flex-col min-h-0 h-full`,children:[(0,F.jsxs)(`div`,{onClick:()=>te?Re():s?ze():void 0,className:`flex items-center gap-2 px-4 py-3 border-b border-zinc-200/60 dark:border-white/[0.06] shrink-0 transition-colors duration-150 ${s?`cursor-pointer hover:bg-zinc-50 dark:hover:bg-white/[0.04]`:``}`,children:[(0,F.jsx)(Ud,{size:16,className:`text-accent shrink-0`,weight:`bold`}),(0,F.jsx)(`h2`,{className:`text-sm font-semibold text-zinc-800 dark:text-zinc-300 shrink-0`,children:`SQL Playground`}),(0,F.jsx)(`span`,{className:`text-[10px] metric-mono text-zinc-400 dark:text-zinc-500 shrink-0`,children:`DuckDB WASM · in-browser`}),te&&Le&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{className:`text-zinc-300 dark:text-zinc-600 shrink-0`,children:`·`}),(0,F.jsx)(`code`,{className:`text-[11px] font-mono text-zinc-500 dark:text-zinc-400 truncate min-w-0`,children:Le})]}),(0,F.jsxs)(`div`,{className:`ml-auto flex items-center gap-1.5 shrink-0`,children:[te&&(0,F.jsx)(`button`,{onClick:Re,className:`p-1 rounded-md transition-colors hover:bg-zinc-100 dark:hover:bg-white/[0.06] text-zinc-400 hover:text-zinc-600 dark:hover:text-zinc-300`,title:`Expand editor`,children:(0,F.jsx)(jd,{size:14})}),!te&&s&&(0,F.jsx)(`button`,{onClick:ze,className:`p-1 rounded-md transition-colors hover:bg-zinc-100 dark:hover:bg-white/[0.06] text-zinc-400 hover:text-zinc-600 dark:hover:text-zinc-300`,title:`Collapse editor`,children:(0,F.jsx)(jd,{size:14,className:`rotate-180`})})]})]}),(0,F.jsx)(Pu.div,{initial:!1,animate:te?{height:0,opacity:0}:{height:re,opacity:1},transition:{duration:.25,ease:[.4,0,.2,1]},className:`overflow-hidden shrink-0`,children:(0,F.jsxs)(`div`,{ref:j,className:`px-4 pt-3 space-y-2`,children:[(0,F.jsxs)(`div`,{className:`relative rounded-2xl border border-zinc-200/60 dark:border-white/[0.06] bg-white/60 dark:bg-zinc-800/40 overflow-hidden transition-colors focus-within:border-accent/40 dark:focus-within:border-accent/40`,children:[(0,F.jsx)(`div`,{ref:ie,className:`min-h-[120px] max-h-[280px] overflow-auto`}),(0,F.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 border-t border-zinc-100 dark:border-white/[0.04]`,children:[(0,F.jsxs)(`span`,{className:`text-[10px] metric-mono text-zinc-400 dark:text-zinc-500`,children:[k,`L`]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[r.trim()&&!s&&(0,F.jsx)(`button`,{onClick:Fe,className:`p-1.5 rounded-lg transition-colors hover:bg-zinc-100 dark:hover:bg-white/[0.06] active:scale-[0.97] text-zinc-400 hover:text-zinc-600 dark:hover:text-zinc-300`,title:`Clear`,children:(0,F.jsx)(Kf,{size:12})}),(0,F.jsxs)(`button`,{onClick:()=>le.current(),disabled:l||!r.trim(),className:`inline-flex items-center justify-center gap-1 px-2.5 py-1 rounded-lg text-[10px] font-medium transition-all duration-200 active:scale-[0.97] disabled:opacity-30 disabled:cursor-not-allowed bg-accent text-white hover:bg-accent/90`,children:[l?(0,F.jsx)(`span`,{className:`inline-block w-3 h-3 rounded-full border-2 border-current border-t-transparent animate-spin`}):(0,F.jsx)(Sf,{size:12,weight:`fill`}),`Run`]}),(0,F.jsx)(`span`,{className:`text-[10px] metric-mono text-zinc-400 dark:text-zinc-500 ml-1`,children:`⌘↵`})]})]})]}),(0,F.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:REe.map(e=>(0,F.jsx)(`button`,{onClick:()=>{Ie(e.sql),o(e.sql),g([]),x(new Set),C(new Set),m(null),de(e.sql,t)},className:`px-3 py-1.5 text-[11px] font-medium rounded-lg border border-zinc-200/60 dark:border-white/[0.06] bg-white/60 dark:bg-zinc-800/40 text-zinc-500 dark:text-zinc-400 hover:border-accent/30 hover:text-accent dark:hover:border-accent/40 dark:hover:text-accent-light transition-all duration-200 active:scale-[0.97]`,children:e.label},e.label))}),(0,F.jsx)(`div`,{onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`,T||E(!0)},onDragLeave:e=>{let t=e.currentTarget.getBoundingClientRect();(e.clientX<t.left||e.clientX>t.right||e.clientY<t.top||e.clientY>t.bottom)&&E(!1)},onDrop:ge,className:`rounded-xl border-2 border-dashed h-[36px] overflow-hidden transition-all duration-200 ${T?`scale-[1.005]`:``} ${w.length>0||T?`border-accent/40 bg-accent/5 dark:bg-accent/10`:`border-zinc-200/60 dark:border-white/[0.06] bg-white/40 dark:bg-zinc-800/20`}`,children:(0,F.jsxs)(`div`,{className:`flex items-center gap-2 px-3 h-full`,children:[(0,F.jsx)(qd,{size:12,className:w.length>0?`text-accent/60`:`text-zinc-400 dark:text-zinc-500 opacity-40`}),w.length>0?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{className:`text-[10px] font-medium shrink-0 text-accent`,children:`Grouped by`}),(0,F.jsx)(Rc,{children:w.map(e=>(0,F.jsxs)(Pu.span,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},className:`inline-flex items-center gap-1 px-2 py-0.5 rounded text-[10px] border border-accent/30 bg-accent/10 text-accent font-mono`,children:[W9(e),(0,F.jsx)(`button`,{onClick:()=>_e(e),className:`rounded p-0.5 opacity-50 hover:opacity-100 transition-opacity`,children:(0,F.jsx)(Kf,{size:10})})]},e))})]}):(0,F.jsx)(`span`,{className:`text-[10px] text-zinc-400 dark:text-zinc-500`,children:s?`Drag column headers here to group and aggregate`:`Run a query, then drag column headers into this zone to group`})]})}),p&&(0,F.jsx)(Pu.div,{initial:{opacity:0,y:-4},animate:{opacity:1,y:0},className:`p-3 rounded-xl border border-red-200/40 dark:border-red-500/20 bg-red-50/50 dark:bg-red-500/5`,children:(0,F.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,F.jsx)(`div`,{className:`w-5 h-5 rounded-full flex items-center justify-center shrink-0 mt-0.5 bg-red-500/10`,children:(0,F.jsx)(Kf,{size:12,weight:`bold`,className:`text-red-500`})}),(0,F.jsxs)(`div`,{className:`min-w-0`,children:[(0,F.jsx)(`p`,{className:`text-xs font-medium mb-0.5 text-red-600 dark:text-red-400`,children:`Query Error`}),(0,F.jsx)(`pre`,{className:`text-[11px] whitespace-pre-wrap break-all font-mono text-zinc-600 dark:text-zinc-300`,children:p})]})]})})]})}),te&&s&&(0,F.jsx)(`div`,{onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`,T||E(!0)},onDragLeave:e=>{let t=e.currentTarget.getBoundingClientRect();(e.clientX<t.left||e.clientX>t.right||e.clientY<t.top||e.clientY>t.bottom)&&E(!1)},onDrop:ge,className:`rounded-xl border-2 border-dashed mx-4 mt-2 mb-2 h-[36px] overflow-hidden transition-all duration-200 ${T?`scale-[1.005]`:``} ${w.length>0||T?`border-accent/40 bg-accent/5 dark:bg-accent/10`:`border-zinc-200/60 dark:border-white/[0.06] bg-white/40 dark:bg-zinc-800/20`}`,children:(0,F.jsxs)(`div`,{className:`flex items-center gap-2 px-3 h-full`,children:[(0,F.jsx)(qd,{size:12,className:w.length>0?`text-accent/60`:`text-zinc-400 dark:text-zinc-500 opacity-40`}),w.length>0?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{className:`text-[10px] font-medium shrink-0 text-accent`,children:`Grouped by`}),w.map(e=>(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded text-[10px] border border-accent/30 bg-accent/10 text-accent font-mono`,children:[W9(e),(0,F.jsx)(`button`,{onClick:()=>_e(e),className:`rounded p-0.5 opacity-50 hover:opacity-100 transition-opacity`,children:(0,F.jsx)(Kf,{size:10})})]},e))]}):(0,F.jsx)(`span`,{className:`text-[10px] text-zinc-400 dark:text-zinc-500`,children:`Drag column headers here to group and aggregate`})]})}),l&&!s&&(0,F.jsxs)(`div`,{className:`m-4 rounded-2xl overflow-hidden border border-zinc-200/60 dark:border-white/[0.06] flex-1 min-h-0`,children:[(0,F.jsx)(`div`,{className:`px-3 py-2 border-b border-zinc-200/40 dark:border-white/[0.04] bg-white dark:bg-zinc-800`,children:(0,F.jsx)(`div`,{className:`h-3 w-32 rounded bg-zinc-200/60 dark:bg-zinc-700/40 animate-pulse`})}),Array.from({length:5}).map((e,t)=>(0,F.jsx)($Ee,{cols:4},t))]}),!s&&!l&&!p&&!te&&(0,F.jsx)(`div`,{className:`m-4 rounded-2xl border border-zinc-200/60 dark:border-white/[0.06] p-10 flex-1 min-h-0 flex flex-col items-center justify-center bg-white/40 dark:bg-zinc-800/20`,children:(0,F.jsxs)(`div`,{className:`flex flex-col items-center justify-center text-center`,children:[(0,F.jsx)(`div`,{className:`w-10 h-10 rounded-xl flex items-center justify-center mb-3 bg-zinc-100 dark:bg-white/[0.04]`,children:(0,F.jsx)(Af,{size:20,className:`text-zinc-400 dark:text-zinc-500`})}),(0,F.jsx)(`p`,{className:`text-sm font-medium mb-0.5 text-zinc-600 dark:text-zinc-300`,children:`No data yet`}),(0,F.jsx)(`p`,{className:`text-xs max-w-sm text-zinc-400 dark:text-zinc-500`,children:`Write a SQL query and hit run, or pick an example query to explore your telemetry data with DuckDB.`})]})}),s&&(0,F.jsxs)(Pu.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},className:`relative mx-4 mb-4 `+(te?`mt-0 `:`mt-2 `)+`rounded-2xl border border-zinc-200/60 dark:border-white/[0.06] flex-1 min-h-0 flex flex-col bg-white dark:bg-zinc-800 overflow-hidden`,children:[(0,F.jsx)(`div`,{ref:ke,className:`overflow-auto flex-1 min-h-0 max-h-full custom-scrollbar`,style:{overscrollBehavior:`none`},children:(0,F.jsxs)(`table`,{className:`text-left`,style:{tableLayout:`fixed`,width:`100%`},children:[(0,F.jsx)(`colgroup`,{children:Se.map((e,t)=>{let n=Be[t];return(0,F.jsx)(`col`,{style:{width:n+`px`,minWidth:n+`px`}},e)})}),(0,F.jsx)(`thead`,{ref:ae,className:`sticky top-0 z-30 bg-white dark:bg-zinc-800`,children:(0,F.jsx)(`tr`,{className:`border-b border-zinc-200/60 dark:border-white/[0.06]`,children:Se.map(e=>(0,F.jsx)(`th`,{draggable:!0,onDragStart:t=>me(t,e),onDragEnd:he,className:`px-3 py-2 text-[10px] font-medium tracking-wider cursor-grab active:cursor-grabbing select-none transition-colors hover:text-accent whitespace-nowrap`+(D===e?` text-accent`:` text-zinc-400 dark:text-zinc-500`),children:(0,F.jsx)(`span`,{className:`truncate`,children:W9(e)})},e))})}),(0,F.jsx)(`tbody`,{children:(()=>{let e=Ae.getVirtualItems();if(e.length===0)return null;let t=e[0].start,n=e[e.length-1],r=Ae.getTotalSize()-(n.start+n.size);return(0,F.jsxs)(F.Fragment,{children:[t>0&&(0,F.jsx)(`tr`,{children:(0,F.jsx)(`td`,{colSpan:Se.length,style:{height:t,padding:0,border:`none`}})}),e.map(e=>{let t=Te[e.index];if(!t)return null;if(t.type===`group`){let n=we.get(t.nodeId);if(!n)return null;let r=n.children.length>0,i=y.has(n.id)||S.has(n.id);return(0,F.jsxs)(`tr`,{"data-index":e.index,className:`group/row cursor-pointer transition-colors duration-150 bg-white dark:bg-zinc-800 hover:bg-zinc-50 dark:hover:bg-[#28282d] border-b border-zinc-200/40 dark:border-white/[0.04]`,onClick:()=>{r?ve(n.id):ye(n.id)},children:[(0,F.jsx)(`td`,{className:`py-2 px-3 transition-colors duration-150 group-hover/row:bg-zinc-50 dark:group-hover/row:bg-[#28282d]`,children:(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,style:{paddingLeft:t.depth*16+`px`},children:[(0,F.jsx)(`div`,{className:`shrink-0 flex items-center justify-center w-4`,children:(0,F.jsx)(`div`,{className:`transition-transform duration-200`+(i?` rotate-90`:``),children:(0,F.jsx)(Nd,{size:12,className:`text-zinc-400 dark:text-zinc-500`})})}),(0,F.jsx)(`div`,{className:`text-xs font-medium truncate text-zinc-600 dark:text-zinc-300 min-w-0`,children:n.value===null?(0,F.jsx)(`span`,{className:`italic text-zinc-400 dark:text-zinc-500`,children:`NULL`}):String(n.value)})]})}),Se.slice(1).map((e,t)=>(0,F.jsx)(`td`,{className:`py-2 border-b border-zinc-200/40 dark:border-white/[0.04] transition-colors duration-150 group-hover/row:bg-zinc-50 dark:group-hover/row:bg-[#28282d]`},t))]},e.key)}if(t.type===`detail`){let n=we.get(t.nodeId);if(!n)return null;let r=Ce.get(n.path)?.[t.rowIndex];if(r===void 0)return null;let i=s.rows[r];return i?(0,F.jsx)(`tr`,{"data-index":e.index,ref:Ae.measureElement,className:`group/row border-b border-zinc-200/40 dark:border-white/[0.04] transition-colors duration-150 hover:bg-zinc-50 dark:hover:bg-[#28282d]`,children:De.map((e,n)=>{let r=e===-1?null:i[e],a=Ee[n],o=typeof r==`number`,s=n===0,c=Ve.has(a);return(0,F.jsx)(`td`,{className:`py-1.5 px-3 text-[11px] align-top`+(c?` whitespace-pre-wrap break-words leading-relaxed`:` whitespace-nowrap`)+(o?` metric-mono tabular-nums`:``)+(s?` transition-colors duration-150 group-hover/row:bg-zinc-50 dark:group-hover/row:bg-[#28282d]`:``),children:(0,F.jsxs)(`div`,{className:c?``:`flex items-center truncate`,children:[s&&(0,F.jsx)(`span`,{style:{display:`inline-block`,width:(t.depth+1)*16+28+`px`,flexShrink:0}}),r==null?(0,F.jsx)(`span`,{className:`italic text-zinc-400 dark:text-zinc-500`,children:`NULL`}):c&&typeof r==`string`?(0,F.jsx)(G9,{text:r}):(0,F.jsx)(`span`,{className:o?`text-zinc-800 dark:text-zinc-200`:`text-zinc-600 dark:text-zinc-300`,children:K9(r,a)})]})},n)})},e.key):null}if(t.type===`flat`){let n=s.rows[t.rowIndex];return n?(0,F.jsx)(`tr`,{"data-index":e.index,ref:Ae.measureElement,className:`group/row border-b border-zinc-200/40 dark:border-white/[0.04] transition-colors duration-150 hover:bg-zinc-50 dark:hover:bg-[#28282d]`,children:Oe.map((e,t)=>{let r=e===-1?null:n[e],i=Se[t],a=typeof r==`number`,o=Ve.has(i);return(0,F.jsx)(`td`,{className:`py-2 px-3 text-xs align-top`+(o?` whitespace-pre-wrap break-words leading-relaxed`:` whitespace-nowrap`)+(a?` metric-mono tabular-nums`:``)+(t===0?` transition-colors duration-150 group-hover/row:bg-zinc-50 dark:group-hover/row:bg-[#28282d]`:``),children:(0,F.jsx)(`div`,{className:o?``:`truncate max-w-[240px]`,children:r==null?(0,F.jsx)(`span`,{className:`italic text-[10px] text-zinc-400 dark:text-zinc-500`,children:`NULL`}):o&&typeof r==`string`?(0,F.jsx)(G9,{text:r}):(0,F.jsx)(`span`,{className:a?`text-zinc-800 dark:text-zinc-200`:`text-zinc-600 dark:text-zinc-300`,children:K9(r,i)})})},t)})},e.key):null}return null}),r>0&&(0,F.jsx)(`tr`,{children:(0,F.jsx)(`td`,{colSpan:Se.length,style:{height:r,padding:0,border:`none`}})})]})})()})]})}),(0,F.jsx)(Rc,{children:Ne&&(()=>{let e=we.get(Ne.nodeId);if(!e)return null;let t=e.children.length>0,n=y.has(e.id)||S.has(e.id),r=e.path.split(V9).map((e,t)=>({value:e||null,depth:t}));return(0,F.jsx)(Pu.div,{initial:{opacity:0,y:-8},animate:{opacity:1,y:0},exit:{opacity:0,y:-8},transition:{duration:.15,ease:[.4,0,.2,1]},className:`absolute left-0 right-0 z-20 cursor-pointer bg-white/95 dark:bg-zinc-800/95 backdrop-blur-sm border-t border-zinc-200/60 dark:border-white/[0.06] border-b border-zinc-200/60 dark:border-white/[0.06] shadow-sm shadow-zinc-200/40 dark:shadow-black/20`,style:{top:oe-1},onClick:()=>{t?ve(e.id):ye(e.id)},children:(0,F.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2`,style:{paddingLeft:Ne.depth*16+13+`px`},children:[(0,F.jsx)(`div`,{className:`shrink-0 flex items-center justify-center w-4`,children:(0,F.jsx)(`div`,{className:`transition-transform duration-200`+(n?` rotate-90`:``),children:(0,F.jsx)(Nd,{size:12,className:`text-zinc-400 dark:text-zinc-500`})})}),r.length>1?(0,F.jsx)(`div`,{className:`flex items-center gap-1 min-w-0 text-xs font-medium truncate`,children:r.map((e,t)=>(0,F.jsxs)(`span`,{className:`contents`,children:[t>0&&(0,F.jsx)(Nd,{size:8,className:`text-zinc-300 dark:text-zinc-600 shrink-0`}),(0,F.jsx)(`span`,{className:t===r.length-1?`text-zinc-600 dark:text-zinc-300`:`text-zinc-400 dark:text-zinc-500`,children:e.value===null?(0,F.jsx)(`span`,{className:`italic text-zinc-400 dark:text-zinc-500`,children:`NULL`}):String(e.value)})]},t))}):(0,F.jsx)(`div`,{className:`text-xs font-medium truncate text-zinc-600 dark:text-zinc-300 min-w-0`,children:e.value===null?(0,F.jsx)(`span`,{className:`italic text-zinc-400 dark:text-zinc-500`,children:`NULL`}):String(e.value)})]})},Ne.nodeId)})()}),(0,F.jsx)(`div`,{className:`border-t border-zinc-200/60 dark:border-white/[0.06] px-4 py-2 bg-white dark:bg-zinc-800`,children:(0,F.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,F.jsxs)(`span`,{className:`text-[10px] tabular-nums flex items-center gap-1.5 metric-mono text-zinc-400 dark:text-zinc-500`,children:[l&&(0,F.jsx)(`span`,{className:`inline-block w-3 h-3 rounded-full border-2 border-current border-t-transparent animate-spin`}),s.rowCount.toLocaleString(),` rows`,be&&be.length>0&&h.length>0&&!xe?` · `+h.length+` level`+(h.length>1?`s`:``):``]}),(0,F.jsxs)(`button`,{onClick:Pe,className:`shrink-0 px-2 py-1 rounded-lg text-[10px] font-medium text-zinc-400 dark:text-zinc-500 hover:text-accent hover:bg-accent/5 dark:hover:bg-accent/10 transition-colors flex items-center gap-1`,title:`Download current result as CSV`,children:[(0,F.jsx)(Yd,{size:10,weight:`bold`}),`CSV`]})]})})]})]})}function sDe(){let{theme:e,setTheme:t}=_p(),[n,r]=(0,b.useState)(!1),[i,a]=(0,b.useState)(null),[o,s]=(0,b.useState)(null),[c,l]=(0,b.useState)(`dashboard`),u=(0,b.useRef)(null),[d,f]=(0,b.useState)(0),{sessions:p,activeSessionId:m,setActiveSessionId:h,dbLoading:g,hasLoaded:_,dbVersion:v,addSession:y,removeSession:x,clearSessions:S}=xx(r),C=(0,b.useCallback)((e,t)=>{y(e,t),s(null),a(null)},[y]),w=(0,b.useCallback)(()=>{S(),s(null),a(null)},[S]),T=Sx(C,r);Cx(C,r);let{dragOver:E,pasteFlash:D,fileInputRef:O,handleDrop:k,handleDragOver:ee,handleDragLeave:te,handleFileSelect:ne,loadSample:re}=T,{data:A}=wx(()=>KJ(m,o),[v,m,o],{skip:c===`sql`}),{data:ie}=wx(()=>qJ(m),[v,m],{skip:c===`sql`}),j=ie??[],M=(0,b.useMemo)(()=>ie?.map(e=>({modelId:e.modelId,provider:e.provider,callCount:e.callCount,totalTokens:e.totalTokens,energyCostUsd:e.energyCostUsd,energyJoules:e.energyJoules,blendedCostUsd:e.blendedCostUsd,costSource:e.costSource}))??[],[ie]),{data:ae}=wx(()=>eY(m,o),[v,m,o],{skip:c===`sql`}),oe=(0,b.useMemo)(()=>ae?{cacheThreshold:ae.cacheThreshold,lowContext:ae.lowContext,slowTtft:ae.slowTtft,fastTtft:ae.fastTtft,highNewInputRatio:ae.highNewInputRatio,anomalyInputThreshold:ae.anomalyInputThreshold,cacheDropMinTotal:ae.cacheDropMinTotal,cacheDropMinInput:ae.cacheDropMinInput,highInputRatio:ae.highInputRatio,highInputSeverityToken:ae.highInputSeverityToken,stallCountThreshold:ae.stallCountThreshold,stallMsSeverity:ae.stallMsSeverity}:void 0,[ae]),{data:se}=wx(()=>YJ(m,o),[v,m,o],{skip:c===`sql`}),{data:N}=wx(()=>{if(p.size<=1||m)return Promise.resolve(null);let e=new Map;for(let[t,n]of p.entries())e.set(t,n.fileName??null);return rY(e)},[v,p.size,m],{skip:c===`sql`}),{data:ce}=wx(()=>ZJ(m,o),[v,m,o],{skip:c===`sql`}),{data:le}=wx(()=>XJ(m,o),[v,m,o],{skip:c===`sql`}),{data:ue}=wx(()=>QJ(m,o),[v,m,o],{skip:c===`sql`}),{data:de}=wx(()=>ae?$J(ae,m,o):Promise.resolve([]),[v,m,o,ae],{skip:c===`sql`||!ae}),{data:fe}=wx(()=>ae?tY(ae,m,o):Promise.resolve([]),[v,m,o,ae],{skip:c===`sql`||!ae}),{data:pe}=wx(()=>ae?JJ(ae,m,o):Promise.resolve([]),[v,m,o,ae],{skip:c===`sql`||!ae}),{data:me}=wx(()=>nY(m,o),[v,m,o],{skip:c===`sql`}),he=(0,b.useCallback)(()=>{if(!N)return;let e=np({...N,sessions:N.sessions.map(e=>({...e,models:[],timeRange:{start:e.timeRangeStart,end:e.timeRangeEnd}})),timeRange:{start:N.timeRangeStart,end:N.timeRangeEnd}}),t=new Blob([e],{type:`text/csv;charset=utf-8`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`pi-tps-sessions-${new Date().toISOString().slice(0,10)}.csv`,r.click(),setTimeout(()=>URL.revokeObjectURL(n),1e3)},[N]),ge=(0,b.useCallback)(e=>a(e),[]),_e=(0,b.useCallback)(e=>h(e),[h]),ve=(0,b.useCallback)(()=>{},[]);(0,b.useEffect)(()=>{let e=u.current;if(!e)return;let t=new ResizeObserver(([e])=>{f(Math.round(e.borderBoxSize?.[0]?.blockSize??e.contentRect.height))});return t.observe(e),()=>t.disconnect()},[]);let ye=(0,b.useCallback)(e=>up(p.get(e)?.events??[]).length,[p]);return(0,F.jsxs)(`div`,{className:`h-dvh flex flex-col overflow-hidden bg-[#fafafa] dark:bg-[#18181b]`,onDrop:k,onDragOver:ee,onDragLeave:te,children:[(0,F.jsx)(`input`,{ref:O,type:`file`,accept:`.jsonl,.json,text/plain`,multiple:!0,className:`hidden`,onChange:ne}),(0,F.jsx)(`header`,{ref:u,className:`sticky top-0 z-40 bg-[#fafafa] dark:bg-[#18181b] border-b border-zinc-200/60 dark:border-white/[0.08]`,children:(0,F.jsxs)(`div`,{className:`max-w-[1600px] mx-auto px-4 sm:px-6 py-3 sm:py-4 flex flex-wrap items-center justify-between gap-y-2`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0`,children:[(0,F.jsx)(`div`,{className:`p-2 bg-accent/10 dark:bg-accent/15 rounded-xl`,children:(0,F.jsx)(rf,{weight:`bold`,size:22,className:`text-accent`})}),(0,F.jsxs)(`div`,{className:`hidden sm:block`,children:[(0,F.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-zinc-900 dark:text-zinc-300 leading-none`,children:`pi-tps`}),(0,F.jsx)(`p`,{className:`text-[11px] text-zinc-400 dark:text-zinc-400 font-medium tracking-wide mt-0.5`,children:`TELEMETRY INSPECTOR`})]})]}),(0,F.jsxs)(`div`,{className:`flex flex-row items-center gap-1.5 min-w-0`,children:[p.size>0&&(0,F.jsxs)(`div`,{className:`flex items-center gap-1 bg-white/60 dark:bg-zinc-800/40 border border-zinc-200/60 dark:border-white/[0.06] rounded-lg p-0.5`,children:[(0,F.jsx)(`button`,{onClick:()=>l(`dashboard`),className:`px-2.5 py-1.5 rounded-md text-[11px] font-medium transition-all duration-200 ${c===`dashboard`?`bg-accent/10 text-accent dark:bg-accent/15`:`text-zinc-400 dark:text-zinc-500 hover:text-zinc-600 dark:hover:text-zinc-300`}`,children:`Dashboard`}),(0,F.jsxs)(`button`,{onClick:()=>l(`sql`),className:`flex items-center gap-1 px-2.5 py-1.5 rounded-md text-[11px] font-medium transition-all duration-200 ${c===`sql`?`bg-accent/10 text-accent dark:bg-accent/15`:`text-zinc-400 dark:text-zinc-500 hover:text-zinc-600 dark:hover:text-zinc-300`}`,children:[(0,F.jsx)(Ud,{size:11,weight:`bold`}),`SQL`]})]}),(0,F.jsx)(`div`,{className:`flex items-center gap-1 bg-white/60 dark:bg-zinc-800/40 border border-zinc-200/60 dark:border-white/[0.06] rounded-lg p-0.5`,children:(0,F.jsxs)(`button`,{onClick:()=>O.current?.click(),className:`flex items-center gap-1 px-2.5 py-1.5 rounded-md text-[11px] font-medium transition-all duration-200 text-zinc-400 dark:text-zinc-500 hover:text-zinc-600 dark:hover:text-zinc-300 hover:bg-zinc-100 dark:hover:bg-white/[0.06]`,title:`Upload telemetry files`,children:[(0,F.jsx)(Hf,{size:12,weight:`bold`}),`Upload`]})}),(0,F.jsx)(SY,{theme:e,setTheme:t}),j.length>0&&(0,F.jsx)(`div`,{className:`flex items-center bg-white/60 dark:bg-zinc-800/40 border border-zinc-200/60 dark:border-white/[0.06] rounded-lg p-0.5 min-w-0`,children:(0,F.jsxs)(`div`,{className:`relative min-w-0`,children:[(0,F.jsxs)(`select`,{value:o??``,onChange:e=>s(e.target.value||null),className:`appearance-none bg-transparent dark:bg-transparent border-0 rounded-md pl-2 pr-5 py-1.5 text-[11px] font-medium text-zinc-600 dark:text-zinc-300 focus:outline-none focus:ring-1 focus:ring-accent/30 max-w-[10rem] truncate`,children:[(0,F.jsx)(`option`,{value:``,children:`All models`}),j.map(e=>(0,F.jsxs)(`option`,{value:e.modelId,children:[`(`,e.provider,`) `,e.modelId.split(`/`)?.pop()]},e.modelId))]}),(0,F.jsx)(`svg`,{className:`absolute right-1.5 top-1/2 -translate-y-1/2 w-2.5 h-2.5 text-zinc-400 dark:text-zinc-500 pointer-events-none`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,viewBox:`0 0 24 24`,children:(0,F.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M19 9l-7 7-7-7`})})]})})]})]})}),p.size>0&&(0,F.jsx)(`div`,{style:{top:d?`${d}px`:0},className:`sticky z-30 bg-[#fafafa] dark:bg-[#18181b] border-b border-zinc-200/40 dark:border-white/[0.06]`,children:(0,F.jsxs)(`div`,{className:`max-w-[1600px] mx-auto px-4 sm:px-6 flex items-center gap-2`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 overflow-x-auto scrollbar-hide py-2 flex-1 min-w-0`,children:[(0,F.jsx)(tf,{size:14,className:`text-zinc-400 dark:text-zinc-500 shrink-0`,weight:`bold`}),(0,F.jsxs)(`button`,{onClick:()=>h(null),className:`shrink-0 px-2 py-1 rounded-lg text-[11px] font-medium ${m===null?`bg-accent/10 text-accent dark:bg-accent/15`:`text-zinc-500 dark:text-zinc-400 hover:text-zinc-700 dark:hover:text-zinc-300 hover:bg-zinc-100 dark:hover:bg-white/[0.06]`}`,children:[`All (`,p.size,`)`]}),Array.from(p.entries()).map(([e,t])=>{let n=ye(e),r=t.fileName?t.fileName.replace(/\.(jsonl|json)$/,``):e.length>16?e.slice(0,16)+`…`:e;return(0,F.jsxs)(`div`,{className:`shrink-0 flex items-center gap-1 px-2 py-1 rounded-lg text-[11px] font-medium cursor-pointer ${m===e?`bg-accent/10 text-accent dark:bg-accent/15`:`text-zinc-500 dark:text-zinc-400 hover:text-zinc-700 dark:hover:text-zinc-300 hover:bg-zinc-100 dark:hover:bg-white/[0.06]`}`,onClick:()=>h(m===e?null:e),children:[(0,F.jsx)(`span`,{className:`truncate max-w-[12rem]`,children:r}),(0,F.jsxs)(`span`,{className:`text-[9px] metric-mono text-zinc-400 dark:text-zinc-500`,children:[n,` req`]}),(0,F.jsx)(`button`,{onClick:t=>{t.stopPropagation(),x(e)},className:`ml-0.5 p-0.5 rounded hover:bg-zinc-200/60 dark:hover:bg-white/[0.08] text-zinc-400 hover:text-zinc-600 dark:hover:text-zinc-300 transition-colors`,title:`Remove session`,children:(0,F.jsx)(Kf,{size:10,weight:`bold`})})]},e)})]}),(0,F.jsx)(`div`,{className:`shrink-0 flex items-center gap-1.5 py-2 border-l border-zinc-200/40 dark:border-white/[0.06] pl-3 ml-1`,children:(0,F.jsx)(`button`,{onClick:w,className:`shrink-0 px-2 py-1 rounded-lg text-[10px] font-medium text-zinc-400 dark:text-zinc-500 hover:text-ember hover:bg-ember/5 dark:hover:bg-ember/10 transition-colors`,children:`Clear all`})})]})}),(0,F.jsx)(`div`,{className:`flex-1 min-h-0 flex flex-col px-4 sm:px-6 py-6 ${c===`sql`&&p.size>0?``:`hidden`}`,children:(0,F.jsx)(oDe,{dbVersion:v,activeSessionId:m})}),(0,F.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto ${c===`sql`&&p.size>0?`hidden`:``}`,children:(_||g||n)&&!A?(0,F.jsx)(`div`,{className:`flex items-center justify-center min-h-[60dvh]`,children:(0,F.jsxs)(`div`,{className:`flex flex-col items-center gap-4`,children:[(0,F.jsx)(`div`,{className:`w-10 h-10 border-2 border-zinc-200 dark:border-white/[0.06] border-t-accent rounded-full animate-spin`}),(0,F.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-400 font-medium`,children:`Loading telemetry…`})]})}):!_&&!A?(0,F.jsx)(Pu.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`flex items-center justify-center min-h-[70dvh] px-4 sm:px-6`,children:(0,F.jsxs)(`div`,{className:`max-w-lg w-full text-center p-12 rounded-[2.5rem] border-2 border-dashed transition-colors ${E?`border-accent bg-accent/5 dark:border-accent dark:bg-accent/10`:`border-zinc-200 bg-white dark:border-white/[0.06] dark:bg-zinc-800/40`}`,children:[(0,F.jsx)(`div`,{className:`w-16 h-16 mx-auto mb-6 bg-zinc-50 dark:bg-white/[0.06] rounded-3xl flex items-center justify-center`,children:(0,F.jsx)(Zd,{size:28,className:`text-zinc-300 dark:text-zinc-400`,weight:`duotone`})}),(0,F.jsx)(`h2`,{className:`text-xl font-semibold text-zinc-700 dark:text-zinc-300 mb-2`,children:`Drop, paste, or import telemetry files`}),(0,F.jsxs)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-400 mb-6 leading-relaxed`,children:[`Drag and drop `,(0,F.jsx)(`code`,{className:`metric-mono text-xs bg-zinc-100 dark:bg-white/[0.06] px-1.5 py-0.5 rounded`,children:`.jsonl`}),` files (one or many), or paste JSONL contents directly (`,(0,F.jsx)(`kbd`,{className:`metric-mono text-[11px] bg-zinc-100 dark:bg-white/[0.06] px-1.5 py-0.5 rounded border border-zinc-200/60 dark:border-white/[0.06]`,children:`⌘V`}),`). Supports telemetry exports from `,(0,F.jsx)(`code`,{className:`metric-mono text-xs bg-zinc-100 dark:bg-white/[0.06] px-1.5 py-0.5 rounded`,children:`/tps-export`}),` and raw session files from `,(0,F.jsx)(`code`,{className:`metric-mono text-xs bg-zinc-100 dark:bg-white/[0.06] px-1.5 py-0.5 rounded`,children:`~/.pi/agent/sessions`}),`.`]}),(0,F.jsxs)(`a`,{href:`https://github.com/monotykamary/pi-tps`,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-start gap-2.5 text-left px-4 py-3 rounded-xl border border-accent/15 dark:border-accent/20 bg-accent/[0.04] dark:bg-accent/10 hover:bg-accent/[0.07] dark:hover:bg-accent/[0.14] transition-colors mb-8`,children:[(0,F.jsx)(uf,{size:16,className:`text-accent shrink-0 mt-0.5`,weight:`bold`}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`p`,{className:`text-xs font-semibold text-accent leading-snug`,children:`Get the most out of your analytics`}),(0,F.jsxs)(`p`,{className:`text-[11px] text-zinc-500 dark:text-zinc-400 leading-relaxed mt-0.5`,children:[`Use `,(0,F.jsx)(`span`,{className:`font-medium text-zinc-700 dark:text-zinc-300`,children:`pi-tps`}),` to hook into pi and stream rich telemetry — TPS, TTFT, energy, cache hits, and more — straight to this inspector.`]})]})]}),(0,F.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-center justify-center gap-3`,children:[(0,F.jsxs)(`button`,{onClick:()=>O.current?.click(),className:`px-6 py-2.5 bg-white dark:bg-zinc-800/50 border border-zinc-200/60 dark:border-white/[0.08] text-zinc-700 dark:text-zinc-300 text-sm font-medium rounded-xl hover:bg-zinc-50 dark:hover:bg-white/[0.06] transition-colors active:scale-[0.98] active:translate-y-[1px] flex items-center gap-2`,children:[(0,F.jsx)(Hf,{size:16,weight:`bold`}),`Upload Files`]}),(0,F.jsx)(`button`,{onClick:re,className:`px-6 py-2.5 bg-accent text-white text-sm font-medium rounded-xl hover:bg-accent-dark transition-colors active:scale-[0.98] active:translate-y-[1px]`,children:`Load Sample Data`})]}),D&&(0,F.jsxs)(Pu.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0},className:`flex items-center gap-2 justify-center text-sm text-moss font-medium`,children:[(0,F.jsx)(Ld,{size:16,weight:`bold`}),`Pasted — loading telemetry…`]})]})},`empty`):(0,F.jsxs)(`div`,{className:`max-w-[1600px] mx-auto px-4 sm:px-6 py-8 space-y-8 rounded-[2rem] ${E?`border-2 border-dashed border-accent bg-accent/5 dark:border-accent dark:bg-accent/10`:``}`,children:[A&&(0,F.jsxs)(Pu.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{duration:.2},className:`grid grid-cols-2 md:grid-cols-5 lg:grid-cols-9 gap-2`,children:[(0,F.jsx)(jx,{icon:wf,label:`Requests`,value:Yf(A.totalCalls),tooltip:(0,F.jsx)(Kte,{total:A.totalCalls,models:M,avgTokensPerCall:A.avgTokensPerCall,stalledCalls:A.stalledCalls,cachedCalls:A.cachedCalls,fastCalls:A.fastCalls})}),(0,F.jsx)(jx,{icon:Mf,label:`Total Time`,value:Jf(A.wallClockMs),tooltip:(0,F.jsx)(qte,{wallClockMs:A.wallClockMs,totalTimeMs:A.totalTimeMs,generationMs:A.totalGenerationMs})}),(0,F.jsx)(Mx,{icon:rf,label:`Avg TPS`,activeTps:A.avgTps,wallTps:A.avgWallTps,lossPct:A.tpsLoss,mode:`avg`}),(0,F.jsx)(Mx,{icon:Dd,label:`Wtd TPS`,activeTps:A.weightedTps,wallTps:A.weightedWallTps,lossPct:A.weightedTpsLoss,accent:!0,mode:`weighted`}),(0,F.jsx)(jx,{icon:zd,label:`Avg TTFT`,value:Jf(Math.round(A.avgTtft)),tooltip:(0,F.jsx)(Jte,{avgTtft:A.avgTtft,p50:A.ttftP50,p75:A.ttftP75,p90:A.ttftP90,p99:A.ttftP99,min:A.minTtft,max:A.maxTtft})}),(0,F.jsx)(jx,{icon:$d,label:`Stalls (ITL)`,value:Yf(A.totalStallCount),accent:!0,tooltip:(0,F.jsx)(Yte,{count:A.totalStallCount,ms:A.totalStallMs,totalTimeMs:A.totalTimeMs})}),(0,F.jsx)(jx,{icon:Vd,label:`Cost`,value:Xf(A.totalCostUsd),tooltip:(0,F.jsx)(Xte,{totalCost:A.totalCostUsd,energyCost:A.energyCostUsd,costSource:A.costSource,models:M,totalTokens:A.totalTokens})}),(()=>{let e=A.totalEnergyJoules===null?null:ep(A.totalEnergyJoules);return(0,F.jsx)(jx,{icon:mf,label:`Energy`,value:e?e.value:`-`,unit:e?e.unit:void 0,tooltip:(0,F.jsx)(Zte,{joules:A.totalEnergyJoules,energyCost:A.energyCostUsd,models:M,totalCalls:A.totalCalls})})})(),(0,F.jsx)(jx,{icon:cf,label:`Tokens`,value:Yf(A.totalTokens),tooltip:(0,F.jsx)(Qte,{input:A.totalInput,output:A.totalOutput,cacheRead:A.totalCacheRead,cacheWrite:A.totalCacheWrite,total:A.totalTokens,totalCost:A.totalCostUsd})})]}),N&&N.sessionCount>1&&(0,F.jsxs)(Pu.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.2},className:`bg-white/80 dark:bg-zinc-800/40 border border-zinc-200/60 dark:border-white/[0.06] rounded-2xl overflow-hidden`,children:[(0,F.jsxs)(`div`,{className:`px-4 py-3 border-b border-zinc-200/40 dark:border-white/[0.06] flex items-center gap-2`,children:[(0,F.jsx)(Ef,{size:14,className:`text-accent`,weight:`bold`}),(0,F.jsx)(`h2`,{className:`text-sm font-semibold text-zinc-800 dark:text-zinc-300`,children:`Sessions Overview`}),(0,F.jsxs)(`span`,{className:`ml-auto text-[10px] metric-mono text-zinc-400 dark:text-zinc-500`,children:[N.sessionCount,` sessions · `,Yf(N.totalCalls),` requests`]}),(0,F.jsxs)(`button`,{onClick:he,className:`shrink-0 ml-2 px-2 py-1 rounded-lg text-[10px] font-medium text-zinc-400 dark:text-zinc-500 hover:text-accent hover:bg-accent/5 dark:hover:bg-accent/10 transition-colors flex items-center gap-1`,title:`Export per-session stats as CSV`,children:[(0,F.jsx)(Yd,{size:10,weight:`bold`}),`CSV`]})]}),(0,F.jsx)(`div`,{className:`overflow-x-auto`,style:{contain:`content`},children:(0,F.jsxs)(`table`,{className:`w-full text-[11px]`,children:[(0,F.jsx)(`thead`,{children:(0,F.jsxs)(`tr`,{className:`text-[9px] uppercase tracking-wider text-zinc-400 dark:text-zinc-500 border-b border-zinc-200/30 dark:border-white/[0.04]`,children:[(0,F.jsx)(`th`,{className:`text-left px-4 py-2 font-medium`,children:`Session`}),(0,F.jsx)(`th`,{className:`text-right px-3 py-2 font-medium`,children:`Requests`}),(0,F.jsx)(`th`,{className:`text-right px-3 py-2 font-medium`,children:`Avg TPS`}),(0,F.jsx)(`th`,{className:`text-right px-3 py-2 font-medium`,children:`Wtd TPS`}),(0,F.jsx)(`th`,{className:`text-right px-3 py-2 font-medium`,children:`Avg TTFT`}),(0,F.jsx)(`th`,{className:`text-right px-3 py-2 font-medium`,children:`Cost`}),(0,F.jsx)(`th`,{className:`text-right px-3 py-2 font-medium`,children:`Energy`}),(0,F.jsx)(`th`,{className:`text-right px-3 py-2 font-medium`,children:`Tokens`})]})}),(0,F.jsx)(`tbody`,{children:N.sessions.map((e,t)=>(0,F.jsxs)(`tr`,{className:`border-b border-zinc-200/20 dark:border-white/[0.03] hover:bg-zinc-50 dark:hover:bg-white/[0.02] cursor-pointer ${t%2==0?`bg-zinc-50/30 dark:bg-white/[0.01]`:``}`,onClick:()=>h(e.sessionId),children:[(0,F.jsx)(`td`,{className:`px-4 py-2 font-medium text-zinc-700 dark:text-zinc-300 max-w-[16rem] truncate`,children:e.fileName||e.sessionId.length>20?e.fileName||e.sessionId.slice(0,20)+`…`:e.sessionId}),(0,F.jsx)(`td`,{className:`px-3 py-2 text-right metric-mono text-zinc-600 dark:text-zinc-300`,children:Yf(e.totalCalls,0)}),(0,F.jsx)(`td`,{className:`px-3 py-2 text-right metric-mono text-zinc-600 dark:text-zinc-300`,children:Zf(e.avgTps)}),(0,F.jsx)(`td`,{className:`px-3 py-2 text-right metric-mono text-accent font-medium`,children:Zf(e.weightedTps)}),(0,F.jsx)(`td`,{className:`px-3 py-2 text-right metric-mono text-zinc-600 dark:text-zinc-300`,children:Jf(Math.round(e.avgTtft))}),(0,F.jsx)(`td`,{className:`px-3 py-2 text-right metric-mono text-zinc-600 dark:text-zinc-300`,children:Xf(e.totalCostUsd)}),(0,F.jsx)(`td`,{className:`px-3 py-2 text-right metric-mono text-zinc-600 dark:text-zinc-300`,children:e.totalEnergyJoules===null?`-`:Qf(e.totalEnergyJoules)}),(0,F.jsx)(`td`,{className:`px-3 py-2 text-right metric-mono text-zinc-600 dark:text-zinc-300`,children:Yf(e.totalTokens)})]},e.sessionId))}),(0,F.jsx)(`tfoot`,{children:(0,F.jsxs)(`tr`,{className:`border-t border-zinc-200/50 dark:border-white/[0.06] font-semibold text-zinc-800 dark:text-zinc-200 bg-zinc-100/40 dark:bg-white/[0.03]`,children:[(0,F.jsxs)(`td`,{className:`px-4 py-2.5`,children:[`Total (`,N.sessionCount,`)`]}),(0,F.jsx)(`td`,{className:`px-3 py-2.5 text-right metric-mono`,children:Yf(N.totalCalls,0)}),(0,F.jsx)(`td`,{className:`px-3 py-2.5 text-right metric-mono`,children:Zf(N.avgTps)}),(0,F.jsx)(`td`,{className:`px-3 py-2.5 text-right metric-mono text-accent`,children:Zf(N.weightedTps)}),(0,F.jsx)(`td`,{className:`px-3 py-2.5 text-right metric-mono`,children:Jf(Math.round(N.avgTtft))}),(0,F.jsx)(`td`,{className:`px-3 py-2.5 text-right metric-mono`,children:Xf(N.totalCostUsd)}),(0,F.jsx)(`td`,{className:`px-3 py-2.5 text-right metric-mono`,children:N.totalEnergyJoules===null?`-`:Qf(N.totalEnergyJoules)}),(0,F.jsx)(`td`,{className:`px-3 py-2.5 text-right metric-mono`,children:Yf(N.totalTokens)})]})})]})})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-12 gap-6`,children:[(0,F.jsxs)(`div`,{className:`lg:col-span-8 space-y-6`,children:[(0,F.jsx)(Hq,{buckets:se??[],onBucketClick:ve}),(0,F.jsx)(Gq,{data:pe??[],onPointClick:ge,thresholds:oe??qf}),N&&N.sessionCount>1&&(0,F.jsx)(vY,{multiSummary:N,onSessionClick:_e}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-6`,children:[(0,F.jsx)(hY,{bins:ue?.bins??[],fastCount:ue?.fastCount??0,slowCount:ue?.slowCount??0,percentiles:ue?.percentiles??[]}),(0,F.jsx)(BJ,{overall:ce?.overall??[],overTime:ce?.overTime??[],hitRate:ce?.hitRate??0})]}),(0,F.jsx)(Jq,{data:le??[]})]}),(0,F.jsxs)(`div`,{className:`lg:col-span-4 flex flex-col gap-6`,children:[M.length>1&&(0,F.jsx)(bY,{models:M,avgTps:A?.avgTps??0,weightedTps:A?.weightedTps??0,totalCalls:A?.totalCalls??0}),(0,F.jsx)(Xq,{stats:de??[]}),(0,F.jsx)(Qq,{anomalies:fe??[]}),(0,F.jsx)(kJ,{timeline:me??[],selectedId:i,onSelect:ge,thresholds:oe??qf})]})]}),(0,F.jsx)(pY,{dbVersion:v,activeSessionId:m,selectedModel:o})]})})]})}(0,x.createRoot)(document.getElementById(`root`)).render((0,F.jsx)(b.StrictMode,{children:(0,F.jsx)(sDe,{})}));
849
+ ORDER BY timestamp`}],V9=``,H9=/^_grp_count_(\d+)$/,U9={id:`ID`,usd:`USD`,ms:`MS`,cwd:`CWD`,url:`URL`,uri:`URI`,api:`API`,http:`HTTP`,https:`HTTPS`,ip:`IP`,db:`DB`,sql:`SQL`,jwt:`JWT`,csv:`CSV`,html:`HTML`,css:`CSS`,js:`JS`,ts:`TS`,json:`JSON`,xml:`XML`,os:`OS`,cpu:`CPU`,ram:`RAM`,gpu:`GPU`,ai:`AI`,llm:`LLM`,tps:`TPS`,ttft:`TTFT`,pct:`PCT`,avg:`AVG`};function W9(e){let t=e.match(H9);if(t)return`Count (L${t[1]})`;let n=e.replace(/_/g,` `);return n=n.replace(/([a-z0-9])([A-Z])/g,`$1 $2`),n.split(/\s+/).filter(Boolean).map(e=>{let t=e.toLowerCase();return U9[t]?U9[t]:e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}).join(` `)}function zEe(e){let t=e.toLowerCase();return t===`timestamp`||t===`time`||t===`createdat`||t===`updatedat`||t===`created_at`||t===`updated_at`||t===`session_start`||t===`session_end`}function BEe(e,t){let n=new Set;for(let r=0;r<e.length;r++){let i=e[r];for(let e=0;e<t.length;e++){let a=t[e][r];if(typeof a==`string`&&a.length>60){n.add(i);break}}}return n}var VEe=/[*_`>[\]#~|]/,HEe=/^[>|#*\-+] |^\d+\. |^```/m;function UEe(e){return VEe.test(e)?HEe.test(e)||/\|/.test(e)&&/\n/.test(e)?2:1:0}var WEe=/(\*\*[^*]+?\*\*|__[^_]+?__|~~[^~]+?~~|\*[^*]+?\*|_[^_]+?_|`[^`]+?`|\[.+?\]\(.+?\))/g,GEe=(0,b.memo)(function({text:e}){return(0,F.jsx)(`span`,{className:`text-zinc-600 dark:text-zinc-300`,children:e.split(WEe).filter(Boolean).map((e,t)=>{if(e.startsWith(`**`)||e.startsWith(`__`))return(0,F.jsx)(`strong`,{className:`font-semibold text-zinc-800 dark:text-zinc-200`,children:e.slice(2,-2)},t);if(e.startsWith(`~~`))return(0,F.jsx)(`del`,{children:e.slice(2,-2)},t);if(e.startsWith(`*`)||e.startsWith(`_`))return(0,F.jsx)(`em`,{className:`italic`,children:e.slice(1,-1)},t);if(e.startsWith("`"))return(0,F.jsx)(`code`,{className:`bg-zinc-100 dark:bg-zinc-900 rounded px-1 font-mono text-[11px]`,children:e.slice(1,-1)},t);if(e.startsWith(`[`)){let n=e.match(/\[(.+?)\]\((.+?)\)/);if(n)return(0,F.jsx)(`a`,{href:n[2],className:`text-accent underline`,target:`_blank`,rel:`noopener noreferrer`,children:n[1]},t)}return(0,F.jsx)(`span`,{children:e},t)})})}),G9=(0,b.memo)(function({text:e}){let t=UEe(e);return t===0?(0,F.jsx)(`span`,{className:`text-zinc-600 dark:text-zinc-300`,children:e}):t===1?(0,F.jsx)(GEe,{text:e}):(0,F.jsx)(__e,{remarkPlugins:[Aye],disallowedElements:[`h1`,`h2`,`h3`,`h4`,`h5`,`h6`,`hr`,`img`],unwrapDisallowed:!0,components:{p:({children:e})=>(0,F.jsx)(`span`,{children:e}),a:({href:e,children:t})=>(0,F.jsx)(`a`,{href:e,className:`text-accent underline`,target:`_blank`,rel:`noopener noreferrer`,children:t}),strong:({children:e})=>(0,F.jsx)(`strong`,{className:`font-semibold text-zinc-800 dark:text-zinc-200`,children:e}),em:({children:e})=>(0,F.jsx)(`em`,{className:`italic`,children:e}),code:({className:e,children:t})=>{if(!e||!e.startsWith(`language-`))return(0,F.jsx)(`code`,{className:`bg-zinc-100 dark:bg-zinc-900 rounded px-1 font-mono text-[11px]`,children:t});let n=e.replace(`language-`,``);return(0,F.jsxs)(`pre`,{className:`bg-zinc-100 dark:bg-zinc-900 rounded px-1.5 py-0.5 my-0.5 overflow-x-auto`,children:[n&&(0,F.jsx)(`div`,{className:`text-[9px] uppercase tracking-wider text-zinc-400 dark:text-zinc-500 mb-0.5`,children:n}),(0,F.jsx)(`code`,{className:`font-mono text-[11px]`,children:t})]})},blockquote:({children:e})=>(0,F.jsx)(`blockquote`,{className:`border-l-2 border-zinc-300 dark:border-zinc-600 pl-2 italic text-zinc-500 dark:text-zinc-400 my-0.5`,children:e}),ul:({children:e})=>(0,F.jsx)(`ul`,{className:`list-disc pl-4 my-0.5`,children:e}),ol:({children:e})=>(0,F.jsx)(`ol`,{className:`list-decimal pl-4 my-0.5`,children:e}),li:({children:e})=>(0,F.jsx)(`li`,{children:e}),table:({children:e})=>(0,F.jsx)(`table`,{className:`border-collapse text-[11px] my-1 w-full`,children:e}),thead:({children:e})=>(0,F.jsx)(`thead`,{className:`bg-zinc-100 dark:bg-zinc-900 border-b border-zinc-200/60 dark:border-white/[0.06]`,children:e}),tbody:({children:e})=>(0,F.jsx)(`tbody`,{children:e}),tr:({children:e})=>(0,F.jsx)(`tr`,{className:`border-b border-zinc-200/40 dark:border-white/[0.04]`,children:e}),th:({children:e})=>(0,F.jsx)(`th`,{className:`px-2 py-1 text-left font-medium text-zinc-600 dark:text-zinc-300`,children:e}),td:({children:e})=>(0,F.jsx)(`td`,{className:`px-2 py-1 text-zinc-600 dark:text-zinc-300`,children:e}),br:()=>(0,F.jsx)(`br`,{})},children:e})});function K9(e,t){return e==null?`NULL`:typeof e==`number`&&zEe(t)&&Number.isFinite(e)&&e>0xe8d4a51000?new Date(e).toISOString().replace(`T`,` `).slice(0,19):typeof e==`number`?e%1==0?e.toLocaleString():e.toFixed(4):String(e)}function KEe(e,t,n){let r=t.length<=500?1:Math.ceil(t.length/500),i=new Set([`timestamp`,`time`,`createdat`,`updatedat`,`created_at`,`updated_at`,`session_start`,`session_end`]);return e.map((e,a)=>{let o=e.toLowerCase(),s=e.replace(/_/g,` `).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).split(/\s+/).filter(Boolean),c=s.reduce((e,t)=>e+(U9[t.toLowerCase()]||t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).length,s.length-1)*7+24,l=i.has(o);for(let i=0;i<t.length;i+=r){let r=t[i][a],o;o=r==null?4:typeof r==`number`?l&&Number.isFinite(r)&&r>0xe8d4a51000?19:r%1==0?r.toLocaleString().length:r.toFixed(4).length:String(r).length;let s=n.has(e)?520:300;c=Math.max(c,Math.min(o*7+24,s))}return c})}function qEe(e,t){if(t.length===0)return null;let n=e.replace(/;+\s*$/,``).trim();return`SELECT _sub.*, ${t.map((e,t)=>`COUNT(*) OVER (PARTITION BY ${e}) AS _grp_count_${t+1}`).join(`, `)} FROM (${n}) AS _sub`}function JEe(e,t){let n=[],r=/COUNT\(\*\)\s+OVER\s+\(\s*PARTITION\s+BY\s+([^)]+)\)\s+AS\s+_grp_count_(\d+)/gi,i;for(;(i=r.exec(e))!==null;){let e=i[1].trim().split(`.`).pop(),t=parseInt(i[2],10)-1;for(;n.length<=t;)n.push(``);n[t]=e}return n.filter(e=>e&&t.includes(e))}function YEe(e,t){let n=e.replace(/--[^\n]*\n?/g,` `).replace(/\/\*[\s\S]*?\*\//g,` `),r=JEe(n,t);if(r.length>0)return r;let i=n.match(/GROUP\s+BY\s+([^)]+?)(?:\s+ORDER\s+BY|\s+LIMIT|\s+HAVING|\s+WINDOW|\s+QUALIFY|$)/i);if(!i)return[];let a=i[1].split(`,`).map(e=>e.trim()).filter(Boolean),o=n.match(/SELECT\s+(.*?)\s+FROM\s+/is),s=[];if(o){let e=o[1].split(`,`).map(e=>e.trim());for(let t of e){let e=t.match(/\s+AS\s+(\w+)$/i);if(e)s.push(e[1]);else{let e=t.split(/\s+/),n=e[e.length-1].replace(/[^a-zA-Z0-9_]/g,``);n&&s.push(n)}}}return a.map(e=>{let t=parseInt(e,10);return!isNaN(t)&&t>0&&t<=s.length?s[t-1]:e.split(`.`).pop()}).filter(e=>t.includes(e))}function XEe(e,t,n){if(n.length===0||e.length===0)return[];let r=n.map(e=>t.indexOf(e));if(r.some(e=>e===-1))return[];let i=n.map((e,n)=>t.indexOf(`_grp_count_${n+1}`)),a=new Map;for(let t of e){let e=r.map(e=>String(t[e]??``));for(let r=0;r<n.length;r++){let n=e.slice(0,r+1).join(V9),o=i[r],s=o===-1?0:Number(t[o]);a.has(n)||a.set(n,s)}}let o=0;function s(e,t){let r=[];for(let[i,c]of a){let a=i.split(V9);if(a.length!==t+1||t>0&&a.slice(0,t).join(V9)!==e)continue;let l=a[t],u=a.join(V9);if(t===n.length-1)r.push({id:o++,value:l||null,depth:t,groupCount:c,children:[],path:u});else{let e=s(u,t+1),n=e.reduce((e,t)=>e+t.groupCount,0);r.push({id:o++,value:l||null,depth:t,groupCount:n,children:e,path:u})}}return r.sort((e,t)=>t.groupCount-e.groupCount),r}return s(``,0)}function ZEe(e,t,n){let r=e.map(e=>t.indexOf(e)),i=new Map;for(let t=0;t<n.length;t++){let a=n[t],o=r.map(e=>String(a[e]??``));for(let n=0;n<e.length;n++){let e=o.slice(0,n+1).join(V9),r=i.get(e);r||(r=[],i.set(e,r)),r.push(t)}}return i}var q9={group:36,detail:30,flat:36};function J9(e,t,n,r,i){let a=[];for(let o of e){let e=o.children.length>0;if(a.push({type:`group`,nodeId:o.id,depth:i}),e&&t.has(o.id))a.push(...J9(o.children,t,n,r,i+1));else if(!e&&n.has(o.id)){let e=r.get(o.path),t=e?e.length:0;for(let e=0;e<t;e++)a.push({type:`detail`,nodeId:o.id,depth:i,rowIndex:e})}}return a}function QEe(e){return e.filter(e=>!H9.test(e))}function $Ee({cols:e}){return(0,F.jsx)(`div`,{className:`flex items-center gap-3 px-3 py-2 border-b border-zinc-200/40 dark:border-white/[0.04]`,children:Array.from({length:e}).map((e,t)=>(0,F.jsx)(`div`,{className:`h-3 rounded bg-zinc-200/60 dark:bg-zinc-700/40 animate-pulse`,style:{width:`${60+t*17%30}px`}},t))})}var Y9=[`events`,`tps_flat`,`energy_flat`,`messages_flat`],X9={events:`session_id.id.parent_id.timestamp.type.provider.model_id.tokens_input.tokens_output.tokens_cache_read.tokens_cache_write.tokens_total.ttft_ms.total_ms.generation_ms.stream_ms.stall_ms.stall_count.tps.cost_input.cost_output.cost_cache_read.cost_cache_write.cost_total.energy_joules.energy_cost_usd.rewind_v.from_id.summary.message_role.message_content.message_model`.split(`.`),tps_flat:[`session_id`,`id`,`parent_id`,`timestamp`,`provider`,`model_id`,`tokens_input`,`tokens_output`,`tokens_cache_read`,`tokens_cache_write`,`tokens_total`,`ttft_ms`,`total_ms`,`generation_ms`,`stream_ms`,`stall_ms`,`stall_count`,`tps`,`cost_input`,`cost_output`,`cost_cache_read`,`cost_cache_write`,`cost_total`],energy_flat:[`session_id`,`id`,`parent_id`,`timestamp`,`energy_joules`,`energy_cost_usd`],messages_flat:[`session_id`,`id`,`parent_id`,`timestamp`,`message_role`,`message_content`,`message_model`]},eDe=G5.define({keywords:`select from where group by order having limit offset as and or not in is null like between exists case when then else end insert into values create table view drop if alter set join on left right inner outer cross union all distinct asc desc over partition window function cast coalesce nullif true false with recursive using natural full fetch next rows range unbounded preceding following current row exclude`,types:`varchar bigint double int boolean float date timestamp`,builtin:`count sum avg min max round abs ceil floor row_number rank dense_rank lag lead first_value last_value list unnest struct_extract array_agg string_agg concat coalesce nullif cast try_cast date_trunc now extract interval generate_series read_csv read_parquet count_if`}),Z9=Z.theme({"&":{fontSize:`12px`,fontFamily:`'Geist Mono', 'JetBrains Mono', monospace`},".cm-content":{padding:`12px 16px`,caretColor:`#0891b2`},".cm-focused":{outline:`none`},".cm-gutters":{backgroundColor:`transparent`,border:`none`,color:`#a1a1aa`,paddingRight:`4px`},".cm-activeLineGutter":{backgroundColor:`rgba(8, 145, 178, 0.05)`,color:`#71717a`},".cm-activeLine":{backgroundColor:`rgba(8, 145, 178, 0.04)`},".cm-selectionBackground":{backgroundColor:`rgba(8, 145, 178, 0.15) !important`},".cm-cursor":{borderLeftColor:`#0891b2`,borderLeftWidth:`2px`},".cm-matchingBracket":{backgroundColor:`rgba(8, 145, 178, 0.2)`,outline:`1px solid rgba(8, 145, 178, 0.4)`},"&.cm-focused .cm-selectionBackground":{backgroundColor:`rgba(8, 145, 178, 0.2) !important`}}),Q9=Z.theme({"&":{fontSize:`12px`,fontFamily:`'Geist Mono', 'JetBrains Mono', monospace`,color:`#d4d4d8`,backgroundColor:`transparent`},".cm-content":{padding:`12px 16px`,caretColor:`#06b6d4`},".cm-focused":{outline:`none`},".cm-gutters":{backgroundColor:`transparent`,border:`none`,color:`#52525b`,paddingRight:`4px`},".cm-activeLineGutter":{backgroundColor:`rgba(6, 182, 212, 0.05)`,color:`#71717a`},".cm-activeLine":{backgroundColor:`rgba(6, 182, 212, 0.04)`},".cm-selectionBackground":{backgroundColor:`rgba(6, 182, 212, 0.15) !important`},".cm-cursor":{borderLeftColor:`#06b6d4`,borderLeftWidth:`2px`},".cm-matchingBracket":{backgroundColor:`rgba(6, 182, 212, 0.2)`,outline:`1px solid rgba(6, 182, 212, 0.4)`},"&.cm-focused .cm-selectionBackground":{backgroundColor:`rgba(6, 182, 212, 0.2) !important`}},{dark:!0}),tDe=s8.define([{tag:$.keyword,color:`#0e7490`,fontWeight:`600`},{tag:$.controlKeyword,color:`#0e7490`,fontWeight:`600`},{tag:$.definitionKeyword,color:`#0e7490`,fontWeight:`600`},{tag:$.operatorKeyword,color:`#0e7490`,fontWeight:`600`},{tag:$.moduleKeyword,color:`#0e7490`,fontWeight:`600`},{tag:$.string,color:`#b45309`},{tag:$.docString,color:`#b45309`},{tag:$.character,color:`#b45309`},{tag:$.number,color:`#9333ea`},{tag:$.integer,color:`#9333ea`},{tag:$.float,color:`#9333ea`},{tag:$.bool,color:`#0e7490`,fontStyle:`italic`},{tag:$.null,color:`#0e7490`,fontStyle:`italic`},{tag:$.atom,color:`#0e7490`,fontStyle:`italic`},{tag:$.typeName,color:`#15803d`},{tag:$.variableName,color:`#09090b`},{tag:$.propertyName,color:`#7c3aed`},{tag:$.function($.variableName),color:`#0e7490`},{tag:$.labelName,color:`#7c3aed`},{tag:$.operator,color:`#52525b`},{tag:$.arithmeticOperator,color:`#52525b`},{tag:$.compareOperator,color:`#52525b`},{tag:$.logicOperator,color:`#0e7490`},{tag:$.punctuation,color:`#a1a1aa`},{tag:$.bracket,color:`#a1a1aa`},{tag:$.separator,color:`#a1a1aa`},{tag:$.comment,color:`#a1a1aa`,fontStyle:`italic`},{tag:$.lineComment,color:`#a1a1aa`,fontStyle:`italic`},{tag:$.blockComment,color:`#a1a1aa`,fontStyle:`italic`},{tag:$.special($.string),color:`#0e7490`},{tag:$.escape,color:`#0e7490`},{tag:$.meta,color:`#71717a`},{tag:$.invalid,color:`#dc2626`}],{themeType:`light`}),nDe=s8.define([{tag:$.keyword,color:`#22d3ee`,fontWeight:`600`},{tag:$.controlKeyword,color:`#22d3ee`,fontWeight:`600`},{tag:$.definitionKeyword,color:`#22d3ee`,fontWeight:`600`},{tag:$.operatorKeyword,color:`#22d3ee`,fontWeight:`600`},{tag:$.moduleKeyword,color:`#22d3ee`,fontWeight:`600`},{tag:$.string,color:`#fbbf24`},{tag:$.docString,color:`#fbbf24`},{tag:$.character,color:`#fbbf24`},{tag:$.number,color:`#c084fc`},{tag:$.integer,color:`#c084fc`},{tag:$.float,color:`#c084fc`},{tag:$.bool,color:`#22d3ee`,fontStyle:`italic`},{tag:$.null,color:`#22d3ee`,fontStyle:`italic`},{tag:$.atom,color:`#22d3ee`,fontStyle:`italic`},{tag:$.typeName,color:`#4ade80`},{tag:$.variableName,color:`#d4d4d8`},{tag:$.propertyName,color:`#c084fc`},{tag:$.function($.variableName),color:`#22d3ee`},{tag:$.labelName,color:`#c084fc`},{tag:$.operator,color:`#a1a1aa`},{tag:$.arithmeticOperator,color:`#a1a1aa`},{tag:$.compareOperator,color:`#a1a1aa`},{tag:$.logicOperator,color:`#22d3ee`},{tag:$.punctuation,color:`#71717a`},{tag:$.bracket,color:`#71717a`},{tag:$.separator,color:`#71717a`},{tag:$.comment,color:`#52525b`,fontStyle:`italic`},{tag:$.lineComment,color:`#52525b`,fontStyle:`italic`},{tag:$.blockComment,color:`#52525b`,fontStyle:`italic`},{tag:$.special($.string),color:`#22d3ee`},{tag:$.escape,color:`#22d3ee`},{tag:$.meta,color:`#71717a`},{tag:$.invalid,color:`#f87171`}],{themeType:`dark`}),rDe=`SELECT.FROM.WHERE.GROUP.BY.ORDER.HAVING.LIMIT.OFFSET.AS.AND.OR.NOT.IN.IS.NULL.LIKE.BETWEEN.EXISTS.CASE.WHEN.THEN.ELSE.END.INSERT.INTO.VALUES.CREATE.TABLE.VIEW.DROP.IF.ALTER.SET.JOIN.ON.LEFT.RIGHT.INNER.OUTER.CROSS.UNION.ALL.DISTINCT.ASC.DESC.OVER.PARTITION.WINDOW.FUNCTION.CAST.COALESCE.NULLIF.TRUE.FALSE.WITH.RECURSIVE.USING.NATURAL.FULL.FETCH.NEXT.ROWS.RANGE.UNBOUNDED.PRECEDING.FOLLOWING.CURRENT.ROW.EXCLUDE`.split(`.`),iDe=`COUNT.SUM.AVG.MIN.MAX.ROUND.ABS.CEIL.FLOOR.ROW_NUMBER.RANK.DENSE_RANK.LAG.LEAD.FIRST_VALUE.LAST_VALUE.LIST.UNNEST.STRUCT_EXTRACT.ARRAY_AGG.STRING_AGG.CONCAT.COALESCE.NULLIF.CAST.TRY_CAST.DATE_TRUNC.NOW.EXTRACT.INTERVAL.GENERATE_SERIES.READ_CSV.READ_PARQUET.COUNT_IF`.split(`.`),aDe=[`VARCHAR`,`BIGINT`,`DOUBLE`,`INTEGER`,`BOOLEAN`,`FLOAT`,`DATE`,`TIMESTAMP`];function $9(e){let t=e.matchBefore(/[\w.]+/),n=t?t.from:e.pos;if(!t&&!e.explicit)return null;let r=[];for(let e of rDe)r.push({label:e,type:`keyword`,detail:`keyword`});for(let e of iDe)r.push({label:e,type:`function`,detail:`function`});for(let e of aDe)r.push({label:e,type:`type`,detail:`type`});for(let e of Y9)r.push({label:e,type:`class`,detail:`table`});for(let[e,t]of Object.entries(X9))for(let n of t)r.push({label:n,type:`property`,detail:e});return{from:n,options:r,filter:!0}}function oDe({dbVersion:e,activeSessionId:t}){let{theme:n}=_p(),[r,i]=(0,b.useState)(``),[a,o]=(0,b.useState)(``),[s,c]=(0,b.useState)(null),[l,u]=(0,b.useState)(!1),[d,f]=(0,b.useState)(!1),[p,m]=(0,b.useState)(null),[h,g]=(0,b.useState)([]),[_,v]=(0,b.useState)([]),[y,x]=(0,b.useState)(new Set),[S,C]=(0,b.useState)(new Set),w=_.length>0?_:h,[T,E]=(0,b.useState)(!1),[D,O]=(0,b.useState)(null),[k,ee]=(0,b.useState)(1),[te,ne]=(0,b.useState)(!1),[re,A]=(0,b.useState)(0),ie=(0,b.useRef)(null),j=(0,b.useRef)(null),M=(0,b.useRef)(null),ae=(0,b.useRef)(null),[oe,se]=(0,b.useState)(33),N=(0,b.useRef)(new a1),ce=(0,b.useRef)(new a1),le=(0,b.useRef)(()=>{}),ue=(0,b.useCallback)(async()=>{if(d)return;let{getDuckDB:e}=await REe(async()=>{let{getDuckDB:e}=await Promise.resolve().then(()=>dx);return{getDuckDB:e}},void 0);await e(),f(!0)},[]),de=(0,b.useRef)(0),fe=(0,b.useCallback)(async(e,t)=>{let n=e??r;if(!n.trim())return;let i=++de.current;u(!0),m(null);try{await ue();let e=await _x(),r=n.replace(/;+\s*$/,``);t&&(r=`SELECT * FROM (${r}) AS _q WHERE session_id = '${t.replace(/'/g,`''`)}'`);let a=`SELECT * FROM (${r}) AS _q LIMIT 50000`,o=await e.query(a),s=o.schema.fields.map(e=>e.name),l=[];for(let e of o.batches){let t=s.map(t=>e.getChild(t));for(let n=0;n<e.numRows;n++)l.push(t.map(e=>{let t=e?.get(n);return typeof t==`bigint`?Number(t):t??null}))}let u={columns:s,rows:l,rowCount:l.length};if(i!==de.current)return;(u.rowCount>0||s.length>0)&&(c(u),g(YEe(n,u.columns)),ne(!0))}catch(e){m(e instanceof Error?e.message:`Query failed`)}finally{u(!1)}},[r,ue]),pe=(0,b.useCallback)(()=>{h.length===0&&o(r),fe(r,t)},[r,fe,h,t]);(0,b.useEffect)(()=>{le.current=pe},[pe]),(0,b.useEffect)(()=>{if(e!==0){if(s&&r.trim())fe(r,t);else if(!s&&!r.trim()){let e=B9[0].sql;i(e),o(e),M.current&&M.current.dispatch({changes:{from:0,to:M.current.state.doc.length,insert:e}}),fe(e,t)}}},[e]),(0,b.useEffect)(()=>{s&&r.trim()&&fe(r,t)},[t]);let me=(0,b.useCallback)(async e=>{if(!a.trim())return;if(e.length===0){v([]),i(a),M.current&&M.current.dispatch({changes:{from:0,to:M.current.state.doc.length,insert:a}}),fe(a,t);return}let n=qEe(a,e);n&&(i(n),M.current&&M.current.dispatch({changes:{from:0,to:M.current.state.doc.length,insert:n}}),v(e),fe(n,t),x(new Set),C(new Set))},[a,fe,t]);(0,b.useEffect)(()=>{if(!ie.current)return;let e=n===`dark`,t=new Z({state:E1.create({doc:r,extensions:[lSe(),fSe(),Kxe(),rTe(),tCe(),XCe(),dEe(),qwe({dialect:eDe,tables:Y9.map(e=>({label:e,type:`table`,columns:X9[e]?.map(e=>({label:e,type:`column`}))??[]}))}),ce.current.of(_5({override:[$9],activateOnTyping:!0,tooltipClass:()=>`cm-tps-autocomplete`})),N.current.of(e?Q9:Z9),d8(tDe),d8(nDe),y3.of([{key:`Mod-Enter`,run:()=>(le.current(),!0)},...$Ce,...sEe,...MEe,...fTe]),Z.updateListener.of(e=>{e.docChanged&&(i(e.state.doc.toString()),ee(e.state.doc.lines))}),Z.lineWrapping]}),parent:ie.current});return M.current=t,()=>{t.destroy(),M.current=null}},[]),(0,b.useEffect)(()=>{if(!M.current)return;let e=n===`dark`;M.current.dispatch({effects:[ce.current.reconfigure(_5({override:[$9],activateOnTyping:!0,tooltipClass:()=>`cm-tps-autocomplete`})),N.current.reconfigure(e?Q9:Z9)]})},[n]),(0,b.useEffect)(()=>{let e=ae.current;if(!e)return;let t=()=>{let t=e.getBoundingClientRect().height;t>0&&se(t)};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[s]),(0,b.useEffect)(()=>{let e=j.current;if(!e)return;let t=()=>{let t=e.getBoundingClientRect().height;t>0&&A(t)};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[r,s,k,p,h,T]);let he=(0,b.useCallback)((e,t)=>{O(t),e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,t)},[]),ge=(0,b.useCallback)(()=>{O(null)},[]),_e=(0,b.useCallback)(e=>{e.preventDefault(),E(!1);let t=e.dataTransfer.getData(`text/plain`);!t||h.includes(t)||(me([...h,t]),O(null))},[h,me]),ve=(0,b.useCallback)(e=>{me(h.filter(t=>t!==e))},[h,me]),ye=(0,b.useCallback)(e=>{x(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),be=(0,b.useCallback)(e=>{C(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),xe=(0,b.useMemo)(()=>s&&h.length>0&&s.rows.length>0?XEe(s.rows,s.columns,h):null,[s,h]),Se=(0,b.useMemo)(()=>{if(!xe)return!1;function e(t){for(let n of t)if(n.children.length>0){if(!e(n.children))return!1}else if(n.groupCount>1)return!1;return!0}return e(xe)},[xe]),Ce=(0,b.useMemo)(()=>s?s.columns.filter(e=>!H9.test(e)):[],[s]),we=(0,b.useMemo)(()=>s&&h.length>0?ZEe(h,s.columns,s.rows):new Map,[s,h]),Te=(0,b.useMemo)(()=>{if(!xe)return new Map;let e=new Map;function t(n){for(let r of n)e.set(r.id,r),r.children.length>0&&t(r.children)}return t(xe),e},[xe]),Ee=(0,b.useMemo)(()=>xe&&xe.length>0&&h.length>0&&!Se?J9(xe,y,S,we,0):s?s.rows.map((e,t)=>({type:`flat`,rowIndex:t})):[],[xe,h,Se,y,S,we,s]),De=(0,b.useMemo)(()=>s?QEe(s.columns):[],[s]),Oe=(0,b.useMemo)(()=>De.map(e=>s?s.columns.indexOf(e):-1),[De,s]),ke=(0,b.useMemo)(()=>Ce.map(e=>s?s.columns.indexOf(e):-1),[Ce,s]),Ae=(0,b.useRef)(null),je=bJ({count:Ee.length,getScrollElement:()=>Ae.current,estimateSize:e=>{let t=Ee[e];return t?t.type===`group`?q9.group:q9[t.type]:36},measureElement:e=>e.getBoundingClientRect().height,overscan:20}),Me=je.getVirtualItems(),Ne=je.scrollOffset??0,Pe=null;if(xe&&xe.length>0&&h.length>0&&!Se&&Me.length>0){let e=-1;for(let t of Me){let n=Ee[t.index];if(n){if(n.type!==`group`){e=t.index;break}if(t.start+t.size<=Ne)Pe={nodeId:n.nodeId,depth:n.depth};else{Pe=null;break}}}if(e>=0&&!Pe)for(let t=e-1;t>=0;t--){let e=Ee[t];if(e&&e.type===`group`){Pe={nodeId:e.nodeId,depth:e.depth};break}}}let Fe=(0,b.useCallback)(()=>{if(!s)return;let e=De,t=[e.map(W9).join(`,`),...s.rows.map(t=>e.map(e=>{let n=s.columns.indexOf(e),r=n===-1?null:t[n],i=r==null?``:String(r);return/[",\r\n]/.test(i)?`"${i.replace(/"/g,`""`)}"`:i}).join(`,`))].join(`
850
+ `),n=new Blob([t],{type:`text/csv;charset=utf-8`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`query-result-${new Date().toISOString().slice(0,19).replace(/[T:]/g,`-`)}.csv`,i.click(),URL.revokeObjectURL(r)},[s,De]),Ie=(0,b.useCallback)(()=>{i(``),o(``),c(null),m(null),g([]),x(new Set),C(new Set),ee(1),ne(!1),M.current&&M.current.dispatch({changes:{from:0,to:M.current.state.doc.length,insert:``}})},[]),Le=(0,b.useCallback)(e=>{i(e),M.current&&M.current.dispatch({changes:{from:0,to:M.current.state.doc.length,insert:e}})},[]),Re=(0,b.useMemo)(()=>{if(!r.trim())return``;let e=r.replace(/\n+/g,` `).replace(/\s+/g,` `).trim();return e.length>80?e.slice(0,77)+`...`:e},[r]),ze=(0,b.useCallback)(()=>ne(!1),[]),Be=(0,b.useCallback)(()=>ne(!0),[]),{colWidths:Ve,longTextCols:He}=(0,b.useMemo)(()=>{if(!s)return{colWidths:[],longTextCols:new Set};let e=s.rows.length<=500?1:Math.ceil(s.rows.length/500),t=Ce.map(e=>s.columns.indexOf(e)),n=[];for(let r=0;r<s.rows.length;r+=e){let e=s.rows[r];n.push(t.map(t=>t===-1?null:e[t]))}let r=BEe(Ce,n),i=KEe(Ce,n,r);if(xe&&xe.length>0&&h.length>0&&!Se&&i.length>0){let e=0;function t(n,r){for(let i of n){let n=r*16,a=(i.value===null?`NULL`:String(i.value)).length*8+8;e=Math.max(e,n+48+a),i.children.length>0&&t(i.children,r+1)}}t(xe,0),i[0]=Math.max(i[0],e)}return{colWidths:i,longTextCols:r}},[s,Ce,xe,h,Se]);return(0,F.jsxs)(`div`,{className:`bg-white/80 dark:bg-zinc-800/40 border border-zinc-200/60 dark:border-white/[0.06] rounded-2xl overflow-hidden flex flex-col min-h-0 h-full`,children:[(0,F.jsxs)(`div`,{onClick:()=>te?ze():s?Be():void 0,className:`flex items-center gap-2 px-4 py-3 border-b border-zinc-200/60 dark:border-white/[0.06] shrink-0 transition-colors duration-150 ${s?`cursor-pointer hover:bg-zinc-50 dark:hover:bg-white/[0.04]`:``}`,children:[(0,F.jsx)(Ud,{size:16,className:`text-accent shrink-0`,weight:`bold`}),(0,F.jsx)(`h2`,{className:`text-sm font-semibold text-zinc-800 dark:text-zinc-300 shrink-0`,children:`SQL Playground`}),(0,F.jsx)(`span`,{className:`text-[10px] metric-mono text-zinc-400 dark:text-zinc-500 shrink-0`,children:`DuckDB WASM · in-browser`}),te&&Re&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{className:`text-zinc-300 dark:text-zinc-600 shrink-0`,children:`·`}),(0,F.jsx)(`code`,{className:`text-[11px] font-mono text-zinc-500 dark:text-zinc-400 truncate min-w-0`,children:Re})]}),(0,F.jsxs)(`div`,{className:`ml-auto flex items-center gap-1.5 shrink-0`,children:[te&&(0,F.jsx)(`button`,{onClick:ze,className:`p-1 rounded-md transition-colors hover:bg-zinc-100 dark:hover:bg-white/[0.06] text-zinc-400 hover:text-zinc-600 dark:hover:text-zinc-300`,title:`Expand editor`,children:(0,F.jsx)(jd,{size:14})}),!te&&s&&(0,F.jsx)(`button`,{onClick:Be,className:`p-1 rounded-md transition-colors hover:bg-zinc-100 dark:hover:bg-white/[0.06] text-zinc-400 hover:text-zinc-600 dark:hover:text-zinc-300`,title:`Collapse editor`,children:(0,F.jsx)(jd,{size:14,className:`rotate-180`})})]})]}),(0,F.jsx)(Pu.div,{initial:!1,animate:te?{height:0,opacity:0}:{height:re,opacity:1},transition:{duration:.25,ease:[.4,0,.2,1]},className:`overflow-hidden shrink-0`,children:(0,F.jsxs)(`div`,{ref:j,className:`px-4 pt-3 space-y-2`,children:[(0,F.jsxs)(`div`,{className:`relative rounded-2xl border border-zinc-200/60 dark:border-white/[0.06] bg-white/60 dark:bg-zinc-800/40 overflow-hidden transition-colors focus-within:border-accent/40 dark:focus-within:border-accent/40`,children:[(0,F.jsx)(`div`,{ref:ie,className:`min-h-[120px] max-h-[280px] overflow-auto`}),(0,F.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 border-t border-zinc-100 dark:border-white/[0.04]`,children:[(0,F.jsxs)(`span`,{className:`text-[10px] metric-mono text-zinc-400 dark:text-zinc-500`,children:[k,`L`]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[r.trim()&&!s&&(0,F.jsx)(`button`,{onClick:Ie,className:`p-1.5 rounded-lg transition-colors hover:bg-zinc-100 dark:hover:bg-white/[0.06] active:scale-[0.97] text-zinc-400 hover:text-zinc-600 dark:hover:text-zinc-300`,title:`Clear`,children:(0,F.jsx)(Kf,{size:12})}),(0,F.jsxs)(`button`,{onClick:()=>le.current(),disabled:l||!r.trim(),className:`inline-flex items-center justify-center gap-1 px-2.5 py-1 rounded-lg text-[10px] font-medium transition-all duration-200 active:scale-[0.97] disabled:opacity-30 disabled:cursor-not-allowed bg-accent text-white hover:bg-accent/90`,children:[l?(0,F.jsx)(`span`,{className:`inline-block w-3 h-3 rounded-full border-2 border-current border-t-transparent animate-spin`}):(0,F.jsx)(Sf,{size:12,weight:`fill`}),`Run`]}),(0,F.jsx)(`span`,{className:`text-[10px] metric-mono text-zinc-400 dark:text-zinc-500 ml-1`,children:`⌘↵`})]})]})]}),(0,F.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:B9.map(e=>(0,F.jsx)(`button`,{onClick:()=>{Le(e.sql),o(e.sql),g([]),x(new Set),C(new Set),m(null),fe(e.sql,t)},className:`px-3 py-1.5 text-[11px] font-medium rounded-lg border border-zinc-200/60 dark:border-white/[0.06] bg-white/60 dark:bg-zinc-800/40 text-zinc-500 dark:text-zinc-400 hover:border-accent/30 hover:text-accent dark:hover:border-accent/40 dark:hover:text-accent-light transition-all duration-200 active:scale-[0.97]`,children:e.label},e.label))}),(0,F.jsx)(`div`,{onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`,T||E(!0)},onDragLeave:e=>{let t=e.currentTarget.getBoundingClientRect();(e.clientX<t.left||e.clientX>t.right||e.clientY<t.top||e.clientY>t.bottom)&&E(!1)},onDrop:_e,className:`rounded-xl border-2 border-dashed h-[36px] overflow-hidden transition-all duration-200 ${T?`scale-[1.005]`:``} ${w.length>0||T?`border-accent/40 bg-accent/5 dark:bg-accent/10`:`border-zinc-200/60 dark:border-white/[0.06] bg-white/40 dark:bg-zinc-800/20`}`,children:(0,F.jsxs)(`div`,{className:`flex items-center gap-2 px-3 h-full`,children:[(0,F.jsx)(qd,{size:12,className:w.length>0?`text-accent/60`:`text-zinc-400 dark:text-zinc-500 opacity-40`}),w.length>0?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{className:`text-[10px] font-medium shrink-0 text-accent`,children:`Grouped by`}),(0,F.jsx)(Rc,{children:w.map(e=>(0,F.jsxs)(Pu.span,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},className:`inline-flex items-center gap-1 px-2 py-0.5 rounded text-[10px] border border-accent/30 bg-accent/10 text-accent font-mono`,children:[W9(e),(0,F.jsx)(`button`,{onClick:()=>ve(e),className:`rounded p-0.5 opacity-50 hover:opacity-100 transition-opacity`,children:(0,F.jsx)(Kf,{size:10})})]},e))})]}):(0,F.jsx)(`span`,{className:`text-[10px] text-zinc-400 dark:text-zinc-500`,children:s?`Drag column headers here to group and aggregate`:`Run a query, then drag column headers into this zone to group`})]})}),p&&(0,F.jsx)(Pu.div,{initial:{opacity:0,y:-4},animate:{opacity:1,y:0},className:`p-3 rounded-xl border border-red-200/40 dark:border-red-500/20 bg-red-50/50 dark:bg-red-500/5`,children:(0,F.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,F.jsx)(`div`,{className:`w-5 h-5 rounded-full flex items-center justify-center shrink-0 mt-0.5 bg-red-500/10`,children:(0,F.jsx)(Kf,{size:12,weight:`bold`,className:`text-red-500`})}),(0,F.jsxs)(`div`,{className:`min-w-0`,children:[(0,F.jsx)(`p`,{className:`text-xs font-medium mb-0.5 text-red-600 dark:text-red-400`,children:`Query Error`}),(0,F.jsx)(`pre`,{className:`text-[11px] whitespace-pre-wrap break-all font-mono text-zinc-600 dark:text-zinc-300`,children:p})]})]})})]})}),te&&s&&(0,F.jsx)(`div`,{onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`,T||E(!0)},onDragLeave:e=>{let t=e.currentTarget.getBoundingClientRect();(e.clientX<t.left||e.clientX>t.right||e.clientY<t.top||e.clientY>t.bottom)&&E(!1)},onDrop:_e,className:`rounded-xl border-2 border-dashed mx-4 mt-2 mb-2 h-[36px] overflow-hidden transition-all duration-200 ${T?`scale-[1.005]`:``} ${w.length>0||T?`border-accent/40 bg-accent/5 dark:bg-accent/10`:`border-zinc-200/60 dark:border-white/[0.06] bg-white/40 dark:bg-zinc-800/20`}`,children:(0,F.jsxs)(`div`,{className:`flex items-center gap-2 px-3 h-full`,children:[(0,F.jsx)(qd,{size:12,className:w.length>0?`text-accent/60`:`text-zinc-400 dark:text-zinc-500 opacity-40`}),w.length>0?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{className:`text-[10px] font-medium shrink-0 text-accent`,children:`Grouped by`}),w.map(e=>(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded text-[10px] border border-accent/30 bg-accent/10 text-accent font-mono`,children:[W9(e),(0,F.jsx)(`button`,{onClick:()=>ve(e),className:`rounded p-0.5 opacity-50 hover:opacity-100 transition-opacity`,children:(0,F.jsx)(Kf,{size:10})})]},e))]}):(0,F.jsx)(`span`,{className:`text-[10px] text-zinc-400 dark:text-zinc-500`,children:`Drag column headers here to group and aggregate`})]})}),l&&!s&&(0,F.jsxs)(`div`,{className:`m-4 rounded-2xl overflow-hidden border border-zinc-200/60 dark:border-white/[0.06] flex-1 min-h-0`,children:[(0,F.jsx)(`div`,{className:`px-3 py-2 border-b border-zinc-200/40 dark:border-white/[0.04] bg-white dark:bg-zinc-800`,children:(0,F.jsx)(`div`,{className:`h-3 w-32 rounded bg-zinc-200/60 dark:bg-zinc-700/40 animate-pulse`})}),Array.from({length:5}).map((e,t)=>(0,F.jsx)($Ee,{cols:4},t))]}),!s&&!l&&!p&&!te&&(0,F.jsx)(`div`,{className:`m-4 rounded-2xl border border-zinc-200/60 dark:border-white/[0.06] p-10 flex-1 min-h-0 flex flex-col items-center justify-center bg-white/40 dark:bg-zinc-800/20`,children:(0,F.jsxs)(`div`,{className:`flex flex-col items-center justify-center text-center`,children:[(0,F.jsx)(`div`,{className:`w-10 h-10 rounded-xl flex items-center justify-center mb-3 bg-zinc-100 dark:bg-white/[0.04]`,children:(0,F.jsx)(Af,{size:20,className:`text-zinc-400 dark:text-zinc-500`})}),(0,F.jsx)(`p`,{className:`text-sm font-medium mb-0.5 text-zinc-600 dark:text-zinc-300`,children:`No data yet`}),(0,F.jsx)(`p`,{className:`text-xs max-w-sm text-zinc-400 dark:text-zinc-500`,children:`Write a SQL query and hit run, or pick an example query to explore your telemetry data with DuckDB.`})]})}),s&&(0,F.jsxs)(Pu.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},className:`relative mx-4 mb-4 `+(te?`mt-0 `:`mt-2 `)+`rounded-2xl border border-zinc-200/60 dark:border-white/[0.06] flex-1 min-h-0 flex flex-col bg-white dark:bg-zinc-800 overflow-hidden`,children:[(0,F.jsx)(`div`,{ref:Ae,className:`overflow-auto flex-1 min-h-0 max-h-full custom-scrollbar`,style:{overscrollBehavior:`none`},children:(0,F.jsxs)(`table`,{className:`text-left`,style:{tableLayout:`fixed`,width:`100%`},children:[(0,F.jsx)(`colgroup`,{children:Ce.map((e,t)=>{let n=Ve[t];return(0,F.jsx)(`col`,{style:{width:n+`px`,minWidth:n+`px`}},e)})}),(0,F.jsx)(`thead`,{ref:ae,className:`sticky top-0 z-30 bg-white dark:bg-zinc-800`,children:(0,F.jsx)(`tr`,{className:`border-b border-zinc-200/60 dark:border-white/[0.06]`,children:Ce.map(e=>(0,F.jsx)(`th`,{draggable:!0,onDragStart:t=>he(t,e),onDragEnd:ge,className:`px-3 py-2 text-[10px] font-medium tracking-wider cursor-grab active:cursor-grabbing select-none transition-colors hover:text-accent whitespace-nowrap`+(D===e?` text-accent`:` text-zinc-400 dark:text-zinc-500`),children:(0,F.jsx)(`span`,{className:`truncate`,children:W9(e)})},e))})}),(0,F.jsx)(`tbody`,{children:(()=>{let e=je.getVirtualItems();if(e.length===0)return null;let t=e[0].start,n=e[e.length-1],r=je.getTotalSize()-(n.start+n.size);return(0,F.jsxs)(F.Fragment,{children:[t>0&&(0,F.jsx)(`tr`,{children:(0,F.jsx)(`td`,{colSpan:Ce.length,style:{height:t,padding:0,border:`none`}})}),e.map(e=>{let t=Ee[e.index];if(!t)return null;if(t.type===`group`){let n=Te.get(t.nodeId);if(!n)return null;let r=n.children.length>0,i=y.has(n.id)||S.has(n.id);return(0,F.jsxs)(`tr`,{"data-index":e.index,className:`group/row cursor-pointer transition-colors duration-150 bg-white dark:bg-zinc-800 hover:bg-zinc-50 dark:hover:bg-[#28282d] border-b border-zinc-200/40 dark:border-white/[0.04]`,onClick:()=>{r?ye(n.id):be(n.id)},children:[(0,F.jsx)(`td`,{className:`py-2 px-3 transition-colors duration-150 group-hover/row:bg-zinc-50 dark:group-hover/row:bg-[#28282d]`,children:(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,style:{paddingLeft:t.depth*16+`px`},children:[(0,F.jsx)(`div`,{className:`shrink-0 flex items-center justify-center w-4`,children:(0,F.jsx)(`div`,{className:`transition-transform duration-200`+(i?` rotate-90`:``),children:(0,F.jsx)(Nd,{size:12,className:`text-zinc-400 dark:text-zinc-500`})})}),(0,F.jsx)(`div`,{className:`text-xs font-medium truncate text-zinc-600 dark:text-zinc-300 min-w-0`,children:n.value===null?(0,F.jsx)(`span`,{className:`italic text-zinc-400 dark:text-zinc-500`,children:`NULL`}):String(n.value)})]})}),Ce.slice(1).map((e,t)=>(0,F.jsx)(`td`,{className:`py-2 border-b border-zinc-200/40 dark:border-white/[0.04] transition-colors duration-150 group-hover/row:bg-zinc-50 dark:group-hover/row:bg-[#28282d]`},t))]},e.key)}if(t.type===`detail`){let n=Te.get(t.nodeId);if(!n)return null;let r=we.get(n.path)?.[t.rowIndex];if(r===void 0)return null;let i=s.rows[r];return i?(0,F.jsx)(`tr`,{"data-index":e.index,ref:je.measureElement,className:`group/row border-b border-zinc-200/40 dark:border-white/[0.04] transition-colors duration-150 hover:bg-zinc-50 dark:hover:bg-[#28282d]`,children:Oe.map((e,n)=>{let r=e===-1?null:i[e],a=De[n],o=typeof r==`number`,s=n===0,c=He.has(a);return(0,F.jsx)(`td`,{className:`py-1.5 px-3 text-[11px] align-top`+(c?` whitespace-pre-wrap break-words leading-relaxed`:` whitespace-nowrap`)+(o?` metric-mono tabular-nums`:``)+(s?` transition-colors duration-150 group-hover/row:bg-zinc-50 dark:group-hover/row:bg-[#28282d]`:``),children:(0,F.jsxs)(`div`,{className:c?``:`flex items-center truncate`,children:[s&&(0,F.jsx)(`span`,{style:{display:`inline-block`,width:(t.depth+1)*16+28+`px`,flexShrink:0}}),r==null?(0,F.jsx)(`span`,{className:`italic text-zinc-400 dark:text-zinc-500`,children:`NULL`}):c&&typeof r==`string`?(0,F.jsx)(G9,{text:r}):(0,F.jsx)(`span`,{className:o?`text-zinc-800 dark:text-zinc-200`:`text-zinc-600 dark:text-zinc-300`,children:K9(r,a)})]})},n)})},e.key):null}if(t.type===`flat`){let n=s.rows[t.rowIndex];return n?(0,F.jsx)(`tr`,{"data-index":e.index,ref:je.measureElement,className:`group/row border-b border-zinc-200/40 dark:border-white/[0.04] transition-colors duration-150 hover:bg-zinc-50 dark:hover:bg-[#28282d]`,children:ke.map((e,t)=>{let r=e===-1?null:n[e],i=Ce[t],a=typeof r==`number`,o=He.has(i);return(0,F.jsx)(`td`,{className:`py-2 px-3 text-xs align-top`+(o?` whitespace-pre-wrap break-words leading-relaxed`:` whitespace-nowrap`)+(a?` metric-mono tabular-nums`:``)+(t===0?` transition-colors duration-150 group-hover/row:bg-zinc-50 dark:group-hover/row:bg-[#28282d]`:``),children:(0,F.jsx)(`div`,{className:o?``:`truncate max-w-[240px]`,children:r==null?(0,F.jsx)(`span`,{className:`italic text-[10px] text-zinc-400 dark:text-zinc-500`,children:`NULL`}):o&&typeof r==`string`?(0,F.jsx)(G9,{text:r}):(0,F.jsx)(`span`,{className:a?`text-zinc-800 dark:text-zinc-200`:`text-zinc-600 dark:text-zinc-300`,children:K9(r,i)})})},t)})},e.key):null}return null}),r>0&&(0,F.jsx)(`tr`,{children:(0,F.jsx)(`td`,{colSpan:Ce.length,style:{height:r,padding:0,border:`none`}})})]})})()})]})}),(0,F.jsx)(Rc,{children:Pe&&(()=>{let e=Te.get(Pe.nodeId);if(!e)return null;let t=e.children.length>0,n=y.has(e.id)||S.has(e.id),r=e.path.split(V9).map((e,t)=>({value:e||null,depth:t}));return(0,F.jsx)(Pu.div,{initial:{opacity:0,y:-8},animate:{opacity:1,y:0},exit:{opacity:0,y:-8},transition:{duration:.15,ease:[.4,0,.2,1]},className:`absolute left-0 right-0 z-20 cursor-pointer bg-white/95 dark:bg-zinc-800/95 backdrop-blur-sm border-t border-zinc-200/60 dark:border-white/[0.06] border-b border-zinc-200/60 dark:border-white/[0.06] shadow-sm shadow-zinc-200/40 dark:shadow-black/20`,style:{top:oe-1},onClick:()=>{t?ye(e.id):be(e.id)},children:(0,F.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2`,style:{paddingLeft:Pe.depth*16+13+`px`},children:[(0,F.jsx)(`div`,{className:`shrink-0 flex items-center justify-center w-4`,children:(0,F.jsx)(`div`,{className:`transition-transform duration-200`+(n?` rotate-90`:``),children:(0,F.jsx)(Nd,{size:12,className:`text-zinc-400 dark:text-zinc-500`})})}),r.length>1?(0,F.jsx)(`div`,{className:`flex items-center gap-1 min-w-0 text-xs font-medium truncate`,children:r.map((e,t)=>(0,F.jsxs)(`span`,{className:`contents`,children:[t>0&&(0,F.jsx)(Nd,{size:8,className:`text-zinc-300 dark:text-zinc-600 shrink-0`}),(0,F.jsx)(`span`,{className:t===r.length-1?`text-zinc-600 dark:text-zinc-300`:`text-zinc-400 dark:text-zinc-500`,children:e.value===null?(0,F.jsx)(`span`,{className:`italic text-zinc-400 dark:text-zinc-500`,children:`NULL`}):String(e.value)})]},t))}):(0,F.jsx)(`div`,{className:`text-xs font-medium truncate text-zinc-600 dark:text-zinc-300 min-w-0`,children:e.value===null?(0,F.jsx)(`span`,{className:`italic text-zinc-400 dark:text-zinc-500`,children:`NULL`}):String(e.value)})]})},Pe.nodeId)})()}),(0,F.jsx)(`div`,{className:`border-t border-zinc-200/60 dark:border-white/[0.06] px-4 py-2 bg-white dark:bg-zinc-800`,children:(0,F.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,F.jsxs)(`span`,{className:`text-[10px] tabular-nums flex items-center gap-1.5 metric-mono text-zinc-400 dark:text-zinc-500`,children:[l&&(0,F.jsx)(`span`,{className:`inline-block w-3 h-3 rounded-full border-2 border-current border-t-transparent animate-spin`}),s.rowCount.toLocaleString(),` rows`,xe&&xe.length>0&&h.length>0&&!Se?` · `+h.length+` level`+(h.length>1?`s`:``):``]}),(0,F.jsxs)(`button`,{onClick:Fe,className:`shrink-0 px-2 py-1 rounded-lg text-[10px] font-medium text-zinc-400 dark:text-zinc-500 hover:text-accent hover:bg-accent/5 dark:hover:bg-accent/10 transition-colors flex items-center gap-1`,title:`Download current result as CSV`,children:[(0,F.jsx)(Yd,{size:10,weight:`bold`}),`CSV`]})]})})]})]})}function sDe(){let{theme:e,setTheme:t}=_p(),[n,r]=(0,b.useState)(!1),[i,a]=(0,b.useState)(null),[o,s]=(0,b.useState)(null),[c,l]=(0,b.useState)(`dashboard`),u=(0,b.useRef)(null),[d,f]=(0,b.useState)(0),{sessions:p,activeSessionId:m,setActiveSessionId:h,dbLoading:g,hasLoaded:_,dbVersion:v,addSession:y,removeSession:x,clearSessions:S}=xx(r),C=(0,b.useCallback)((e,t)=>{y(e,t),s(null),a(null)},[y]),w=(0,b.useCallback)(()=>{S(),s(null),a(null)},[S]),T=Sx(C,r);Cx(C,r);let{dragOver:E,pasteFlash:D,fileInputRef:O,handleDrop:k,handleDragOver:ee,handleDragLeave:te,handleFileSelect:ne,loadSample:re}=T,{data:A}=wx(()=>GJ(m,o),[v,m,o],{skip:c===`sql`}),{data:ie}=wx(()=>KJ(m),[v,m],{skip:c===`sql`}),j=ie??[],M=(0,b.useMemo)(()=>ie?.map(e=>({modelId:e.modelId,provider:e.provider,callCount:e.callCount,totalTokens:e.totalTokens,energyCostUsd:e.energyCostUsd,energyJoules:e.energyJoules,blendedCostUsd:e.blendedCostUsd,costSource:e.costSource}))??[],[ie]),{data:ae}=wx(()=>$J(m,o),[v,m,o],{skip:c===`sql`}),oe=(0,b.useMemo)(()=>ae?{cacheThreshold:ae.cacheThreshold,lowContext:ae.lowContext,slowTtft:ae.slowTtft,fastTtft:ae.fastTtft,highNewInputRatio:ae.highNewInputRatio,anomalyInputThreshold:ae.anomalyInputThreshold,cacheDropMinTotal:ae.cacheDropMinTotal,cacheDropMinInput:ae.cacheDropMinInput,highInputRatio:ae.highInputRatio,highInputSeverityToken:ae.highInputSeverityToken,stallCountThreshold:ae.stallCountThreshold,stallMsSeverity:ae.stallMsSeverity}:void 0,[ae]),{data:se}=wx(()=>JJ(m,o),[v,m,o],{skip:c===`sql`}),{data:N}=wx(()=>{if(p.size<=1||m)return Promise.resolve(null);let e=new Map;for(let[t,n]of p.entries())e.set(t,n.fileName??null);return nY(e)},[v,p.size,m],{skip:c===`sql`}),{data:ce}=wx(()=>XJ(m,o),[v,m,o],{skip:c===`sql`}),{data:le}=wx(()=>YJ(m,o),[v,m,o],{skip:c===`sql`}),{data:ue}=wx(()=>ZJ(m,o),[v,m,o],{skip:c===`sql`}),{data:de}=wx(()=>ae?QJ(ae,m,o):Promise.resolve([]),[v,m,o,ae],{skip:c===`sql`||!ae}),{data:fe}=wx(()=>ae?eY(ae,m,o):Promise.resolve([]),[v,m,o,ae],{skip:c===`sql`||!ae}),{data:pe}=wx(()=>ae?qJ(ae,m,o):Promise.resolve([]),[v,m,o,ae],{skip:c===`sql`||!ae}),{data:me}=wx(()=>tY(m,o),[v,m,o],{skip:c===`sql`}),he=(0,b.useCallback)(()=>{if(!N)return;let e=np({...N,sessions:N.sessions.map(e=>({...e,models:[],timeRange:{start:e.timeRangeStart,end:e.timeRangeEnd}})),timeRange:{start:N.timeRangeStart,end:N.timeRangeEnd}}),t=new Blob([e],{type:`text/csv;charset=utf-8`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`pi-tps-sessions-${new Date().toISOString().slice(0,10)}.csv`,r.click(),setTimeout(()=>URL.revokeObjectURL(n),1e3)},[N]),ge=(0,b.useCallback)(e=>a(e),[]),_e=(0,b.useCallback)(e=>h(e),[h]),ve=(0,b.useCallback)(()=>{},[]);(0,b.useEffect)(()=>{let e=u.current;if(!e)return;let t=new ResizeObserver(([e])=>{f(Math.round(e.borderBoxSize?.[0]?.blockSize??e.contentRect.height))});return t.observe(e),()=>t.disconnect()},[]);let ye=(0,b.useCallback)(e=>up(p.get(e)?.events??[]).length,[p]);return(0,F.jsxs)(`div`,{className:`h-dvh flex flex-col overflow-hidden bg-[#fafafa] dark:bg-[#18181b]`,onDrop:k,onDragOver:ee,onDragLeave:te,children:[(0,F.jsx)(`input`,{ref:O,type:`file`,accept:`.jsonl,.json,text/plain`,multiple:!0,className:`hidden`,onChange:ne}),(0,F.jsx)(`header`,{ref:u,className:`sticky top-0 z-40 bg-[#fafafa] dark:bg-[#18181b] border-b border-zinc-200/60 dark:border-white/[0.08]`,children:(0,F.jsxs)(`div`,{className:`max-w-[1600px] mx-auto px-4 sm:px-6 py-3 sm:py-4 flex flex-wrap items-center justify-between gap-y-2`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0`,children:[(0,F.jsx)(`div`,{className:`p-2 bg-accent/10 dark:bg-accent/15 rounded-xl`,children:(0,F.jsx)(rf,{weight:`bold`,size:22,className:`text-accent`})}),(0,F.jsxs)(`div`,{className:`hidden sm:block`,children:[(0,F.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-zinc-900 dark:text-zinc-300 leading-none`,children:`pi-tps`}),(0,F.jsx)(`p`,{className:`text-[11px] text-zinc-400 dark:text-zinc-400 font-medium tracking-wide mt-0.5`,children:`TELEMETRY INSPECTOR`})]})]}),(0,F.jsxs)(`div`,{className:`flex flex-row items-center gap-1.5 min-w-0`,children:[p.size>0&&(0,F.jsxs)(`div`,{className:`flex items-center gap-1 bg-white/60 dark:bg-zinc-800/40 border border-zinc-200/60 dark:border-white/[0.06] rounded-lg p-0.5`,children:[(0,F.jsx)(`button`,{onClick:()=>l(`dashboard`),className:`px-2.5 py-1.5 rounded-md text-[11px] font-medium transition-all duration-200 ${c===`dashboard`?`bg-accent/10 text-accent dark:bg-accent/15`:`text-zinc-400 dark:text-zinc-500 hover:text-zinc-600 dark:hover:text-zinc-300`}`,children:`Dashboard`}),(0,F.jsxs)(`button`,{onClick:()=>l(`sql`),className:`flex items-center gap-1 px-2.5 py-1.5 rounded-md text-[11px] font-medium transition-all duration-200 ${c===`sql`?`bg-accent/10 text-accent dark:bg-accent/15`:`text-zinc-400 dark:text-zinc-500 hover:text-zinc-600 dark:hover:text-zinc-300`}`,children:[(0,F.jsx)(Ud,{size:11,weight:`bold`}),`SQL`]})]}),(0,F.jsx)(`div`,{className:`flex items-center gap-1 bg-white/60 dark:bg-zinc-800/40 border border-zinc-200/60 dark:border-white/[0.06] rounded-lg p-0.5`,children:(0,F.jsxs)(`button`,{onClick:()=>O.current?.click(),className:`flex items-center gap-1 px-2.5 py-1.5 rounded-md text-[11px] font-medium transition-all duration-200 text-zinc-400 dark:text-zinc-500 hover:text-zinc-600 dark:hover:text-zinc-300 hover:bg-zinc-100 dark:hover:bg-white/[0.06]`,title:`Upload telemetry files`,children:[(0,F.jsx)(Hf,{size:12,weight:`bold`}),`Upload`]})}),(0,F.jsx)(xY,{theme:e,setTheme:t}),j.length>0&&(0,F.jsx)(`div`,{className:`flex items-center bg-white/60 dark:bg-zinc-800/40 border border-zinc-200/60 dark:border-white/[0.06] rounded-lg p-0.5 min-w-0`,children:(0,F.jsxs)(`div`,{className:`relative min-w-0`,children:[(0,F.jsxs)(`select`,{value:o??``,onChange:e=>s(e.target.value||null),className:`appearance-none bg-transparent dark:bg-transparent border-0 rounded-md pl-2 pr-5 py-1.5 text-[11px] font-medium text-zinc-600 dark:text-zinc-300 focus:outline-none focus:ring-1 focus:ring-accent/30 max-w-[10rem] truncate`,children:[(0,F.jsx)(`option`,{value:``,children:`All models`}),j.map(e=>(0,F.jsxs)(`option`,{value:e.modelId,children:[`(`,e.provider,`) `,e.modelId.split(`/`)?.pop()]},e.modelId))]}),(0,F.jsx)(`svg`,{className:`absolute right-1.5 top-1/2 -translate-y-1/2 w-2.5 h-2.5 text-zinc-400 dark:text-zinc-500 pointer-events-none`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,viewBox:`0 0 24 24`,children:(0,F.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M19 9l-7 7-7-7`})})]})})]})]})}),p.size>0&&(0,F.jsx)(`div`,{style:{top:d?`${d}px`:0},className:`sticky z-30 bg-[#fafafa] dark:bg-[#18181b] border-b border-zinc-200/40 dark:border-white/[0.06]`,children:(0,F.jsxs)(`div`,{className:`max-w-[1600px] mx-auto px-4 sm:px-6 flex items-center gap-2`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 overflow-x-auto scrollbar-hide py-2 flex-1 min-w-0`,children:[(0,F.jsx)(tf,{size:14,className:`text-zinc-400 dark:text-zinc-500 shrink-0`,weight:`bold`}),(0,F.jsxs)(`button`,{onClick:()=>h(null),className:`shrink-0 px-2 py-1 rounded-lg text-[11px] font-medium ${m===null?`bg-accent/10 text-accent dark:bg-accent/15`:`text-zinc-500 dark:text-zinc-400 hover:text-zinc-700 dark:hover:text-zinc-300 hover:bg-zinc-100 dark:hover:bg-white/[0.06]`}`,children:[`All (`,p.size,`)`]}),Array.from(p.entries()).map(([e,t])=>{let n=ye(e),r=t.fileName?t.fileName.replace(/\.(jsonl|json)$/,``):e.length>16?e.slice(0,16)+`…`:e;return(0,F.jsxs)(`div`,{className:`shrink-0 flex items-center gap-1 px-2 py-1 rounded-lg text-[11px] font-medium cursor-pointer ${m===e?`bg-accent/10 text-accent dark:bg-accent/15`:`text-zinc-500 dark:text-zinc-400 hover:text-zinc-700 dark:hover:text-zinc-300 hover:bg-zinc-100 dark:hover:bg-white/[0.06]`}`,onClick:()=>h(m===e?null:e),children:[(0,F.jsx)(`span`,{className:`truncate max-w-[12rem]`,children:r}),(0,F.jsxs)(`span`,{className:`text-[9px] metric-mono text-zinc-400 dark:text-zinc-500`,children:[n,` req`]}),(0,F.jsx)(`button`,{onClick:t=>{t.stopPropagation(),x(e)},className:`ml-0.5 p-0.5 rounded hover:bg-zinc-200/60 dark:hover:bg-white/[0.08] text-zinc-400 hover:text-zinc-600 dark:hover:text-zinc-300 transition-colors`,title:`Remove session`,children:(0,F.jsx)(Kf,{size:10,weight:`bold`})})]},e)})]}),(0,F.jsx)(`div`,{className:`shrink-0 flex items-center gap-1.5 py-2 border-l border-zinc-200/40 dark:border-white/[0.06] pl-3 ml-1`,children:(0,F.jsx)(`button`,{onClick:w,className:`shrink-0 px-2 py-1 rounded-lg text-[10px] font-medium text-zinc-400 dark:text-zinc-500 hover:text-ember hover:bg-ember/5 dark:hover:bg-ember/10 transition-colors`,children:`Clear all`})})]})}),(0,F.jsx)(`div`,{className:`flex-1 min-h-0 flex flex-col px-4 sm:px-6 py-6 ${c===`sql`&&p.size>0?``:`hidden`}`,children:(0,F.jsx)(oDe,{dbVersion:v,activeSessionId:m})}),(0,F.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto ${c===`sql`&&p.size>0?`hidden`:``}`,children:(_||g||n)&&!A?(0,F.jsx)(`div`,{className:`flex items-center justify-center min-h-[60dvh]`,children:(0,F.jsxs)(`div`,{className:`flex flex-col items-center gap-4`,children:[(0,F.jsx)(`div`,{className:`w-10 h-10 border-2 border-zinc-200 dark:border-white/[0.06] border-t-accent rounded-full animate-spin`}),(0,F.jsx)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-400 font-medium`,children:`Loading telemetry…`})]})}):!_&&!A?(0,F.jsx)(Pu.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:`flex items-center justify-center min-h-[70dvh] px-4 sm:px-6`,children:(0,F.jsxs)(`div`,{className:`max-w-lg w-full text-center p-12 rounded-[2.5rem] border-2 border-dashed transition-colors ${E?`border-accent bg-accent/5 dark:border-accent dark:bg-accent/10`:`border-zinc-200 bg-white dark:border-white/[0.06] dark:bg-zinc-800/40`}`,children:[(0,F.jsx)(`div`,{className:`w-16 h-16 mx-auto mb-6 bg-zinc-50 dark:bg-white/[0.06] rounded-3xl flex items-center justify-center`,children:(0,F.jsx)(Zd,{size:28,className:`text-zinc-300 dark:text-zinc-400`,weight:`duotone`})}),(0,F.jsx)(`h2`,{className:`text-xl font-semibold text-zinc-700 dark:text-zinc-300 mb-2`,children:`Drop, paste, or import telemetry files`}),(0,F.jsxs)(`p`,{className:`text-sm text-zinc-400 dark:text-zinc-400 mb-6 leading-relaxed`,children:[`Drag and drop `,(0,F.jsx)(`code`,{className:`metric-mono text-xs bg-zinc-100 dark:bg-white/[0.06] px-1.5 py-0.5 rounded`,children:`.jsonl`}),` files (one or many), or paste JSONL contents directly (`,(0,F.jsx)(`kbd`,{className:`metric-mono text-[11px] bg-zinc-100 dark:bg-white/[0.06] px-1.5 py-0.5 rounded border border-zinc-200/60 dark:border-white/[0.06]`,children:`⌘V`}),`). Supports telemetry exports from `,(0,F.jsx)(`code`,{className:`metric-mono text-xs bg-zinc-100 dark:bg-white/[0.06] px-1.5 py-0.5 rounded`,children:`/tps-export`}),` and raw session files from `,(0,F.jsx)(`code`,{className:`metric-mono text-xs bg-zinc-100 dark:bg-white/[0.06] px-1.5 py-0.5 rounded`,children:`~/.pi/agent/sessions`}),`.`]}),(0,F.jsxs)(`a`,{href:`https://github.com/monotykamary/pi-tps`,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-start gap-2.5 text-left px-4 py-3 rounded-xl border border-accent/15 dark:border-accent/20 bg-accent/[0.04] dark:bg-accent/10 hover:bg-accent/[0.07] dark:hover:bg-accent/[0.14] transition-colors mb-8`,children:[(0,F.jsx)(uf,{size:16,className:`text-accent shrink-0 mt-0.5`,weight:`bold`}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`p`,{className:`text-xs font-semibold text-accent leading-snug`,children:`Get the most out of your analytics`}),(0,F.jsxs)(`p`,{className:`text-[11px] text-zinc-500 dark:text-zinc-400 leading-relaxed mt-0.5`,children:[`Use `,(0,F.jsx)(`span`,{className:`font-medium text-zinc-700 dark:text-zinc-300`,children:`pi-tps`}),` to hook into pi and stream rich telemetry — TPS, TTFT, energy, cache hits, and more — straight to this inspector.`]})]})]}),(0,F.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-center justify-center gap-3`,children:[(0,F.jsxs)(`button`,{onClick:()=>O.current?.click(),className:`px-6 py-2.5 bg-white dark:bg-zinc-800/50 border border-zinc-200/60 dark:border-white/[0.08] text-zinc-700 dark:text-zinc-300 text-sm font-medium rounded-xl hover:bg-zinc-50 dark:hover:bg-white/[0.06] transition-colors active:scale-[0.98] active:translate-y-[1px] flex items-center gap-2`,children:[(0,F.jsx)(Hf,{size:16,weight:`bold`}),`Upload Files`]}),(0,F.jsx)(`button`,{onClick:re,className:`px-6 py-2.5 bg-accent text-white text-sm font-medium rounded-xl hover:bg-accent-dark transition-colors active:scale-[0.98] active:translate-y-[1px]`,children:`Load Sample Data`})]}),D&&(0,F.jsxs)(Pu.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0},className:`flex items-center gap-2 justify-center text-sm text-moss font-medium`,children:[(0,F.jsx)(Ld,{size:16,weight:`bold`}),`Pasted — loading telemetry…`]})]})},`empty`):(0,F.jsxs)(`div`,{className:`max-w-[1600px] mx-auto px-4 sm:px-6 py-8 space-y-8 rounded-[2rem] ${E?`border-2 border-dashed border-accent bg-accent/5 dark:border-accent dark:bg-accent/10`:``}`,children:[A&&(0,F.jsxs)(Pu.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{duration:.2},className:`grid grid-cols-2 md:grid-cols-5 lg:grid-cols-9 gap-2`,children:[(0,F.jsx)(jx,{icon:wf,label:`Requests`,value:Yf(A.totalCalls),tooltip:(0,F.jsx)(Kte,{total:A.totalCalls,models:M,avgTokensPerCall:A.avgTokensPerCall,stalledCalls:A.stalledCalls,cachedCalls:A.cachedCalls,fastCalls:A.fastCalls})}),(0,F.jsx)(jx,{icon:Mf,label:`Total Time`,value:Jf(A.wallClockMs),tooltip:(0,F.jsx)(qte,{wallClockMs:A.wallClockMs,totalTimeMs:A.totalTimeMs,generationMs:A.totalGenerationMs})}),(0,F.jsx)(Mx,{icon:rf,label:`Avg TPS`,activeTps:A.avgTps,wallTps:A.avgWallTps,lossPct:A.tpsLoss,mode:`avg`}),(0,F.jsx)(Mx,{icon:Dd,label:`Wtd TPS`,activeTps:A.weightedTps,wallTps:A.weightedWallTps,lossPct:A.weightedTpsLoss,accent:!0,mode:`weighted`}),(0,F.jsx)(jx,{icon:zd,label:`Avg TTFT`,value:Jf(Math.round(A.avgTtft)),tooltip:(0,F.jsx)(Jte,{avgTtft:A.avgTtft,p50:A.ttftP50,p75:A.ttftP75,p90:A.ttftP90,p99:A.ttftP99,min:A.minTtft,max:A.maxTtft})}),(0,F.jsx)(jx,{icon:$d,label:`Stalls (ITL)`,value:Yf(A.totalStallCount),accent:!0,tooltip:(0,F.jsx)(Yte,{count:A.totalStallCount,ms:A.totalStallMs,totalTimeMs:A.totalTimeMs})}),(0,F.jsx)(jx,{icon:Vd,label:`Cost`,value:Xf(A.totalCostUsd),tooltip:(0,F.jsx)(Xte,{totalCost:A.totalCostUsd,energyCost:A.energyCostUsd,costSource:A.costSource,models:M,totalTokens:A.totalTokens})}),(()=>{let e=A.totalEnergyJoules===null?null:ep(A.totalEnergyJoules);return(0,F.jsx)(jx,{icon:mf,label:`Energy`,value:e?e.value:`-`,unit:e?e.unit:void 0,tooltip:(0,F.jsx)(Zte,{joules:A.totalEnergyJoules,energyCost:A.energyCostUsd,models:M,totalCalls:A.totalCalls})})})(),(0,F.jsx)(jx,{icon:cf,label:`Tokens`,value:Yf(A.totalTokens),tooltip:(0,F.jsx)(Qte,{input:A.totalInput,output:A.totalOutput,cacheRead:A.totalCacheRead,cacheWrite:A.totalCacheWrite,total:A.totalTokens,totalCost:A.totalCostUsd})})]}),N&&N.sessionCount>1&&(0,F.jsxs)(Pu.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.2},className:`bg-white/80 dark:bg-zinc-800/40 border border-zinc-200/60 dark:border-white/[0.06] rounded-2xl overflow-hidden`,children:[(0,F.jsxs)(`div`,{className:`px-4 py-3 border-b border-zinc-200/40 dark:border-white/[0.06] flex items-center gap-2`,children:[(0,F.jsx)(Ef,{size:14,className:`text-accent`,weight:`bold`}),(0,F.jsx)(`h2`,{className:`text-sm font-semibold text-zinc-800 dark:text-zinc-300`,children:`Sessions Overview`}),(0,F.jsxs)(`span`,{className:`ml-auto text-[10px] metric-mono text-zinc-400 dark:text-zinc-500`,children:[N.sessionCount,` sessions · `,Yf(N.totalCalls),` requests`]}),(0,F.jsxs)(`button`,{onClick:he,className:`shrink-0 ml-2 px-2 py-1 rounded-lg text-[10px] font-medium text-zinc-400 dark:text-zinc-500 hover:text-accent hover:bg-accent/5 dark:hover:bg-accent/10 transition-colors flex items-center gap-1`,title:`Export per-session stats as CSV`,children:[(0,F.jsx)(Yd,{size:10,weight:`bold`}),`CSV`]})]}),(0,F.jsx)(`div`,{className:`overflow-x-auto`,style:{contain:`content`},children:(0,F.jsxs)(`table`,{className:`w-full text-[11px]`,children:[(0,F.jsx)(`thead`,{children:(0,F.jsxs)(`tr`,{className:`text-[9px] uppercase tracking-wider text-zinc-400 dark:text-zinc-500 border-b border-zinc-200/30 dark:border-white/[0.04]`,children:[(0,F.jsx)(`th`,{className:`text-left px-4 py-2 font-medium`,children:`Session`}),(0,F.jsx)(`th`,{className:`text-right px-3 py-2 font-medium`,children:`Requests`}),(0,F.jsx)(`th`,{className:`text-right px-3 py-2 font-medium`,children:`Avg TPS`}),(0,F.jsx)(`th`,{className:`text-right px-3 py-2 font-medium`,children:`Wtd TPS`}),(0,F.jsx)(`th`,{className:`text-right px-3 py-2 font-medium`,children:`Avg TTFT`}),(0,F.jsx)(`th`,{className:`text-right px-3 py-2 font-medium`,children:`Cost`}),(0,F.jsx)(`th`,{className:`text-right px-3 py-2 font-medium`,children:`Energy`}),(0,F.jsx)(`th`,{className:`text-right px-3 py-2 font-medium`,children:`Tokens`})]})}),(0,F.jsx)(`tbody`,{children:N.sessions.map((e,t)=>(0,F.jsxs)(`tr`,{className:`border-b border-zinc-200/20 dark:border-white/[0.03] hover:bg-zinc-50 dark:hover:bg-white/[0.02] cursor-pointer ${t%2==0?`bg-zinc-50/30 dark:bg-white/[0.01]`:``}`,onClick:()=>h(e.sessionId),children:[(0,F.jsx)(`td`,{className:`px-4 py-2 font-medium text-zinc-700 dark:text-zinc-300 max-w-[16rem] truncate`,children:e.fileName||e.sessionId.length>20?e.fileName||e.sessionId.slice(0,20)+`…`:e.sessionId}),(0,F.jsx)(`td`,{className:`px-3 py-2 text-right metric-mono text-zinc-600 dark:text-zinc-300`,children:Yf(e.totalCalls,0)}),(0,F.jsx)(`td`,{className:`px-3 py-2 text-right metric-mono text-zinc-600 dark:text-zinc-300`,children:Zf(e.avgTps)}),(0,F.jsx)(`td`,{className:`px-3 py-2 text-right metric-mono text-accent font-medium`,children:Zf(e.weightedTps)}),(0,F.jsx)(`td`,{className:`px-3 py-2 text-right metric-mono text-zinc-600 dark:text-zinc-300`,children:Jf(Math.round(e.avgTtft))}),(0,F.jsx)(`td`,{className:`px-3 py-2 text-right metric-mono text-zinc-600 dark:text-zinc-300`,children:Xf(e.totalCostUsd)}),(0,F.jsx)(`td`,{className:`px-3 py-2 text-right metric-mono text-zinc-600 dark:text-zinc-300`,children:e.totalEnergyJoules===null?`-`:Qf(e.totalEnergyJoules)}),(0,F.jsx)(`td`,{className:`px-3 py-2 text-right metric-mono text-zinc-600 dark:text-zinc-300`,children:Yf(e.totalTokens)})]},e.sessionId))}),(0,F.jsx)(`tfoot`,{children:(0,F.jsxs)(`tr`,{className:`border-t border-zinc-200/50 dark:border-white/[0.06] font-semibold text-zinc-800 dark:text-zinc-200 bg-zinc-100/40 dark:bg-white/[0.03]`,children:[(0,F.jsxs)(`td`,{className:`px-4 py-2.5`,children:[`Total (`,N.sessionCount,`)`]}),(0,F.jsx)(`td`,{className:`px-3 py-2.5 text-right metric-mono`,children:Yf(N.totalCalls,0)}),(0,F.jsx)(`td`,{className:`px-3 py-2.5 text-right metric-mono`,children:Zf(N.avgTps)}),(0,F.jsx)(`td`,{className:`px-3 py-2.5 text-right metric-mono text-accent`,children:Zf(N.weightedTps)}),(0,F.jsx)(`td`,{className:`px-3 py-2.5 text-right metric-mono`,children:Jf(Math.round(N.avgTtft))}),(0,F.jsx)(`td`,{className:`px-3 py-2.5 text-right metric-mono`,children:Xf(N.totalCostUsd)}),(0,F.jsx)(`td`,{className:`px-3 py-2.5 text-right metric-mono`,children:N.totalEnergyJoules===null?`-`:Qf(N.totalEnergyJoules)}),(0,F.jsx)(`td`,{className:`px-3 py-2.5 text-right metric-mono`,children:Yf(N.totalTokens)})]})})]})})]}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-12 gap-6`,children:[(0,F.jsxs)(`div`,{className:`lg:col-span-8 space-y-6`,children:[(0,F.jsx)(Vq,{buckets:se??[],onBucketClick:ve}),(0,F.jsx)(Wq,{data:pe??[],onPointClick:ge,thresholds:oe??qf}),N&&N.sessionCount>1&&(0,F.jsx)(_Y,{multiSummary:N,onSessionClick:_e}),(0,F.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-6`,children:[(0,F.jsx)(mY,{bins:ue?.bins??[],fastCount:ue?.fastCount??0,slowCount:ue?.slowCount??0,percentiles:ue?.percentiles??[]}),(0,F.jsx)(zJ,{overall:ce?.overall??[],overTime:ce?.overTime??[],hitRate:ce?.hitRate??0})]}),(0,F.jsx)(qq,{data:le??[]})]}),(0,F.jsxs)(`div`,{className:`lg:col-span-4 flex flex-col gap-6`,children:[M.length>1&&(0,F.jsx)(yY,{models:M,avgTps:A?.avgTps??0,weightedTps:A?.weightedTps??0,totalCalls:A?.totalCalls??0}),(0,F.jsx)(Yq,{stats:de??[]}),(0,F.jsx)(Zq,{anomalies:fe??[]}),(0,F.jsx)(OJ,{timeline:me??[],selectedId:i,onSelect:ge,thresholds:oe??qf})]})]}),(0,F.jsx)(fY,{dbVersion:v,activeSessionId:m,selectedModel:o})]})})]})}(0,x.createRoot)(document.getElementById(`root`)).render((0,F.jsx)(b.StrictMode,{children:(0,F.jsx)(sDe,{})}));