modscape 1.0.5 → 1.0.7
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.
- package/package.json +1 -1
- package/src/create.js +45 -0
- package/src/index.js +10 -1
- package/src/templates/default-model.yaml +61 -0
- package/visualizer/package.json +1 -1
- package/visualizer-dist/assets/{index-xtv3bmxO.js → index-CzpKPd1L.js} +2 -2
- package/visualizer-dist/assets/index-D-n9UqHA.css +1 -0
- package/visualizer-dist/index.html +2 -2
- package/visualizer-dist/assets/index-CoPelnvo.css +0 -1
|
@@ -37,7 +37,7 @@ Error generating stack: `+p.message+`
|
|
|
37
37
|
`+t.slice(r,s),r=s+1),o=c;return u+=`
|
|
38
38
|
`,t.length-r>e&&o>r?u+=t.slice(r,o)+`
|
|
39
39
|
`+t.slice(o+1):u+=t.slice(r),u.slice(1)}function nY(t){for(var e="",n=0,i,r=0;r<t.length;n>=65536?r+=2:r++)n=Ic(t,r),i=An[n],!i&&fu(n)?(e+=t[r],n>=65536&&(e+=t[r+1])):e+=i||YG(n);return e}function iY(t,e,n){var i="",r=t.tag,s,o,c;for(s=0,o=n.length;s<o;s+=1)c=n[s],t.replacer&&(c=t.replacer.call(n,String(s),c)),(Wr(t,e,c,!1,!1)||typeof c>"u"&&Wr(t,e,null,!1,!1))&&(i!==""&&(i+=","+(t.condenseFlow?"":" ")),i+=t.dump);t.tag=r,t.dump="["+i+"]"}function YE(t,e,n,i){var r="",s=t.tag,o,c,u;for(o=0,c=n.length;o<c;o+=1)u=n[o],t.replacer&&(u=t.replacer.call(n,String(o),u)),(Wr(t,e+1,u,!0,!0,!1,!0)||typeof u>"u"&&Wr(t,e+1,null,!0,!0,!1,!0))&&((!i||r!=="")&&(r+=Kw(t,e)),t.dump&&cu===t.dump.charCodeAt(0)?r+="-":r+="- ",r+=t.dump);t.tag=s,t.dump=r||"[]"}function rY(t,e,n){var i="",r=t.tag,s=Object.keys(n),o,c,u,h,d;for(o=0,c=s.length;o<c;o+=1)d="",i!==""&&(d+=", "),t.condenseFlow&&(d+='"'),u=s[o],h=n[u],t.replacer&&(h=t.replacer.call(n,u,h)),Wr(t,e,u,!1,!1)&&(t.dump.length>1024&&(d+="? "),d+=t.dump+(t.condenseFlow?'"':"")+":"+(t.condenseFlow?"":" "),Wr(t,e,h,!1,!1)&&(d+=t.dump,i+=d));t.tag=r,t.dump="{"+i+"}"}function sY(t,e,n,i){var r="",s=t.tag,o=Object.keys(n),c,u,h,d,m,g;if(t.sortKeys===!0)o.sort();else if(typeof t.sortKeys=="function")o.sort(t.sortKeys);else if(t.sortKeys)throw new Mn("sortKeys must be a boolean or a function");for(c=0,u=o.length;c<u;c+=1)g="",(!i||r!=="")&&(g+=Kw(t,e)),h=o[c],d=n[h],t.replacer&&(d=t.replacer.call(n,h,d)),Wr(t,e+1,h,!0,!0,!0)&&(m=t.tag!==null&&t.tag!=="?"||t.dump&&t.dump.length>1024,m&&(t.dump&&cu===t.dump.charCodeAt(0)?g+="?":g+="? "),g+=t.dump,m&&(g+=Kw(t,e)),Wr(t,e+1,d,!0,m)&&(t.dump&&cu===t.dump.charCodeAt(0)?g+=":":g+=": ",g+=t.dump,r+=g));t.tag=s,t.dump=r||"{}"}function QE(t,e,n){var i,r,s,o,c,u;for(r=n?t.explicitTypes:t.implicitTypes,s=0,o=r.length;s<o;s+=1)if(c=r[s],(c.instanceOf||c.predicate)&&(!c.instanceOf||typeof e=="object"&&e instanceof c.instanceOf)&&(!c.predicate||c.predicate(e))){if(n?c.multi&&c.representName?t.tag=c.representName(e):t.tag=c.tag:t.tag="?",c.represent){if(u=t.styleMap[c.tag]||c.defaultStyle,Dz.call(c.represent)==="[object Function]")i=c.represent(e,u);else if(Lz.call(c.represent,u))i=c.represent[u](e,u);else throw new Mn("!<"+c.tag+'> tag resolver accepts not "'+u+'" style');t.dump=i}return!0}return!1}function Wr(t,e,n,i,r,s,o){t.tag=null,t.dump=n,QE(t,n,!1)||QE(t,n,!0);var c=Dz.call(t.dump),u=i,h;i&&(i=t.flowLevel<0||t.flowLevel>e);var d=c==="[object Object]"||c==="[object Array]",m,g;if(d&&(m=t.duplicates.indexOf(n),g=m!==-1),(t.tag!==null&&t.tag!=="?"||g||t.indent!==2&&e>0)&&(r=!1),g&&t.usedDuplicates[m])t.dump="*ref_"+m;else{if(d&&g&&!t.usedDuplicates[m]&&(t.usedDuplicates[m]=!0),c==="[object Object]")i&&Object.keys(t.dump).length!==0?(sY(t,e,t.dump,r),g&&(t.dump="&ref_"+m+t.dump)):(rY(t,e,t.dump),g&&(t.dump="&ref_"+m+" "+t.dump));else if(c==="[object Array]")i&&t.dump.length!==0?(t.noArrayIndent&&!o&&e>0?YE(t,e-1,t.dump,r):YE(t,e,t.dump,r),g&&(t.dump="&ref_"+m+t.dump)):(iY(t,e,t.dump),g&&(t.dump="&ref_"+m+" "+t.dump));else if(c==="[object String]")t.tag!=="?"&&eY(t,t.dump,e,s,u);else{if(c==="[object Undefined]")return!1;if(t.skipInvalid)return!1;throw new Mn("unacceptable kind of an object to dump "+c)}t.tag!==null&&t.tag!=="?"&&(h=encodeURI(t.tag[0]==="!"?t.tag.slice(1):t.tag).replace(/!/g,"%21"),t.tag[0]==="!"?h="!"+h:h.slice(0,18)==="tag:yaml.org,2002:"?h="!!"+h.slice(18):h="!<"+h+">",t.dump=h+" "+t.dump)}return!0}function aY(t,e){var n=[],i=[],r,s;for(Jw(t,n,i),r=0,s=i.length;r<s;r+=1)e.duplicates.push(n[i[r]]);e.usedDuplicates=new Array(s)}function Jw(t,e,n){var i,r,s;if(t!==null&&typeof t=="object")if(r=e.indexOf(t),r!==-1)n.indexOf(r)===-1&&n.push(r);else if(e.push(t),Array.isArray(t))for(r=0,s=t.length;r<s;r+=1)Jw(t[r],e,n);else for(i=Object.keys(t),r=0,s=i.length;r<s;r+=1)Jw(t[i[r]],e,n)}function oY(t,e){e=e||{};var n=new XG(e);n.noRefs||aY(t,n);var i=t;return n.replacer&&(i=n.replacer.call({"":i},"",i)),Wr(n,0,i,!0,!0)?n.dump+`
|
|
40
|
-
`:""}var lY=oY,cY={dump:lY};function N2(t,e){return function(){throw new Error("Function yaml."+t+" is removed in js-yaml 4. Use yaml."+e+" instead, which is now safe by default.")}}var uY=vn,fY=rz,hY=lz,dY=dz,pY=pz,mY=E2,gY=Nz.load,yY=Nz.loadAll,vY=cY.dump,bY=Mn,xY={binary:bz,float:hz,map:oz,null:cz,pairs:wz,set:Sz,timestamp:yz,bool:uz,int:fz,merge:vz,omap:xz,seq:az,str:sz},wY=N2("safeLoad","load"),SY=N2("safeLoadAll","loadAll"),CY=N2("safeDump","dump"),eS={Type:uY,Schema:fY,FAILSAFE_SCHEMA:hY,JSON_SCHEMA:dY,CORE_SCHEMA:pY,DEFAULT_SCHEMA:mY,load:gY,loadAll:yY,dump:vY,YAMLException:bY,types:xY,safeLoad:wY,safeLoadAll:SY,safeDump:CY};function D2(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var N0,XE;function kY(){if(XE)return N0;XE=1;function t(){this.__data__=[],this.size=0}return N0=t,N0}var D0,WE;function wl(){if(WE)return D0;WE=1;function t(e,n){return e===n||e!==e&&n!==n}return D0=t,D0}var L0,KE;function yp(){if(KE)return L0;KE=1;var t=wl();function e(n,i){for(var r=n.length;r--;)if(t(n[r][0],i))return r;return-1}return L0=e,L0}var z0,ZE;function AY(){if(ZE)return z0;ZE=1;var t=yp(),e=Array.prototype,n=e.splice;function i(r){var s=this.__data__,o=t(s,r);if(o<0)return!1;var c=s.length-1;return o==c?s.pop():n.call(s,o,1),--this.size,!0}return z0=i,z0}var B0,JE;function _Y(){if(JE)return B0;JE=1;var t=yp();function e(n){var i=this.__data__,r=t(i,n);return r<0?void 0:i[r][1]}return B0=e,B0}var q0,eT;function OY(){if(eT)return q0;eT=1;var t=yp();function e(n){return t(this.__data__,n)>-1}return q0=e,q0}var j0,tT;function EY(){if(tT)return j0;tT=1;var t=yp();function e(n,i){var r=this.__data__,s=t(r,n);return s<0?(++this.size,r.push([n,i])):r[s][1]=i,this}return j0=e,j0}var I0,nT;function vp(){if(nT)return I0;nT=1;var t=kY(),e=AY(),n=_Y(),i=OY(),r=EY();function s(o){var c=-1,u=o==null?0:o.length;for(this.clear();++c<u;){var h=o[c];this.set(h[0],h[1])}}return s.prototype.clear=t,s.prototype.delete=e,s.prototype.get=n,s.prototype.has=i,s.prototype.set=r,I0=s,I0}var P0,iT;function TY(){if(iT)return P0;iT=1;var t=vp();function e(){this.__data__=new t,this.size=0}return P0=e,P0}var H0,rT;function MY(){if(rT)return H0;rT=1;function t(e){var n=this.__data__,i=n.delete(e);return this.size=n.size,i}return H0=t,H0}var U0,sT;function RY(){if(sT)return U0;sT=1;function t(e){return this.__data__.get(e)}return U0=t,U0}var V0,aT;function NY(){if(aT)return V0;aT=1;function t(e){return this.__data__.has(e)}return V0=t,V0}var F0,oT;function Fz(){if(oT)return F0;oT=1;var t=typeof vh=="object"&&vh&&vh.Object===Object&&vh;return F0=t,F0}var $0,lT;function Hi(){if(lT)return $0;lT=1;var t=Fz(),e=typeof self=="object"&&self&&self.Object===Object&&self,n=t||e||Function("return this")();return $0=n,$0}var G0,cT;function Sl(){if(cT)return G0;cT=1;var t=Hi(),e=t.Symbol;return G0=e,G0}var Y0,uT;function DY(){if(uT)return Y0;uT=1;var t=Sl(),e=Object.prototype,n=e.hasOwnProperty,i=e.toString,r=t?t.toStringTag:void 0;function s(o){var c=n.call(o,r),u=o[r];try{o[r]=void 0;var h=!0}catch{}var d=i.call(o);return h&&(c?o[r]=u:delete o[r]),d}return Y0=s,Y0}var Q0,fT;function LY(){if(fT)return Q0;fT=1;var t=Object.prototype,e=t.toString;function n(i){return e.call(i)}return Q0=n,Q0}var X0,hT;function Ya(){if(hT)return X0;hT=1;var t=Sl(),e=DY(),n=LY(),i="[object Null]",r="[object Undefined]",s=t?t.toStringTag:void 0;function o(c){return c==null?c===void 0?r:i:s&&s in Object(c)?e(c):n(c)}return X0=o,X0}var W0,dT;function Oi(){if(dT)return W0;dT=1;function t(e){var n=typeof e;return e!=null&&(n=="object"||n=="function")}return W0=t,W0}var K0,pT;function Lu(){if(pT)return K0;pT=1;var t=Ya(),e=Oi(),n="[object AsyncFunction]",i="[object Function]",r="[object GeneratorFunction]",s="[object Proxy]";function o(c){if(!e(c))return!1;var u=t(c);return u==i||u==r||u==n||u==s}return K0=o,K0}var Z0,mT;function zY(){if(mT)return Z0;mT=1;var t=Hi(),e=t["__core-js_shared__"];return Z0=e,Z0}var J0,gT;function BY(){if(gT)return J0;gT=1;var t=zY(),e=(function(){var i=/[^.]+$/.exec(t&&t.keys&&t.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""})();function n(i){return!!e&&e in i}return J0=n,J0}var ey,yT;function $z(){if(yT)return ey;yT=1;var t=Function.prototype,e=t.toString;function n(i){if(i!=null){try{return e.call(i)}catch{}try{return i+""}catch{}}return""}return ey=n,ey}var ty,vT;function qY(){if(vT)return ty;vT=1;var t=Lu(),e=BY(),n=Oi(),i=$z(),r=/[\\^$.*+?()[\]{}|]/g,s=/^\[object .+?Constructor\]$/,o=Function.prototype,c=Object.prototype,u=o.toString,h=c.hasOwnProperty,d=RegExp("^"+u.call(h).replace(r,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function m(g){if(!n(g)||e(g))return!1;var y=t(g)?d:s;return y.test(i(g))}return ty=m,ty}var ny,bT;function jY(){if(bT)return ny;bT=1;function t(e,n){return e?.[n]}return ny=t,ny}var iy,xT;function Qa(){if(xT)return iy;xT=1;var t=qY(),e=jY();function n(i,r){var s=e(i,r);return t(s)?s:void 0}return iy=n,iy}var ry,wT;function L2(){if(wT)return ry;wT=1;var t=Qa(),e=Hi(),n=t(e,"Map");return ry=n,ry}var sy,ST;function bp(){if(ST)return sy;ST=1;var t=Qa(),e=t(Object,"create");return sy=e,sy}var ay,CT;function IY(){if(CT)return ay;CT=1;var t=bp();function e(){this.__data__=t?t(null):{},this.size=0}return ay=e,ay}var oy,kT;function PY(){if(kT)return oy;kT=1;function t(e){var n=this.has(e)&&delete this.__data__[e];return this.size-=n?1:0,n}return oy=t,oy}var ly,AT;function HY(){if(AT)return ly;AT=1;var t=bp(),e="__lodash_hash_undefined__",n=Object.prototype,i=n.hasOwnProperty;function r(s){var o=this.__data__;if(t){var c=o[s];return c===e?void 0:c}return i.call(o,s)?o[s]:void 0}return ly=r,ly}var cy,_T;function UY(){if(_T)return cy;_T=1;var t=bp(),e=Object.prototype,n=e.hasOwnProperty;function i(r){var s=this.__data__;return t?s[r]!==void 0:n.call(s,r)}return cy=i,cy}var uy,OT;function VY(){if(OT)return uy;OT=1;var t=bp(),e="__lodash_hash_undefined__";function n(i,r){var s=this.__data__;return this.size+=this.has(i)?0:1,s[i]=t&&r===void 0?e:r,this}return uy=n,uy}var fy,ET;function FY(){if(ET)return fy;ET=1;var t=IY(),e=PY(),n=HY(),i=UY(),r=VY();function s(o){var c=-1,u=o==null?0:o.length;for(this.clear();++c<u;){var h=o[c];this.set(h[0],h[1])}}return s.prototype.clear=t,s.prototype.delete=e,s.prototype.get=n,s.prototype.has=i,s.prototype.set=r,fy=s,fy}var hy,TT;function $Y(){if(TT)return hy;TT=1;var t=FY(),e=vp(),n=L2();function i(){this.size=0,this.__data__={hash:new t,map:new(n||e),string:new t}}return hy=i,hy}var dy,MT;function GY(){if(MT)return dy;MT=1;function t(e){var n=typeof e;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?e!=="__proto__":e===null}return dy=t,dy}var py,RT;function xp(){if(RT)return py;RT=1;var t=GY();function e(n,i){var r=n.__data__;return t(i)?r[typeof i=="string"?"string":"hash"]:r.map}return py=e,py}var my,NT;function YY(){if(NT)return my;NT=1;var t=xp();function e(n){var i=t(this,n).delete(n);return this.size-=i?1:0,i}return my=e,my}var gy,DT;function QY(){if(DT)return gy;DT=1;var t=xp();function e(n){return t(this,n).get(n)}return gy=e,gy}var yy,LT;function XY(){if(LT)return yy;LT=1;var t=xp();function e(n){return t(this,n).has(n)}return yy=e,yy}var vy,zT;function WY(){if(zT)return vy;zT=1;var t=xp();function e(n,i){var r=t(this,n),s=r.size;return r.set(n,i),this.size+=r.size==s?0:1,this}return vy=e,vy}var by,BT;function z2(){if(BT)return by;BT=1;var t=$Y(),e=YY(),n=QY(),i=XY(),r=WY();function s(o){var c=-1,u=o==null?0:o.length;for(this.clear();++c<u;){var h=o[c];this.set(h[0],h[1])}}return s.prototype.clear=t,s.prototype.delete=e,s.prototype.get=n,s.prototype.has=i,s.prototype.set=r,by=s,by}var xy,qT;function KY(){if(qT)return xy;qT=1;var t=vp(),e=L2(),n=z2(),i=200;function r(s,o){var c=this.__data__;if(c instanceof t){var u=c.__data__;if(!e||u.length<i-1)return u.push([s,o]),this.size=++c.size,this;c=this.__data__=new n(u)}return c.set(s,o),this.size=c.size,this}return xy=r,xy}var wy,jT;function wp(){if(jT)return wy;jT=1;var t=vp(),e=TY(),n=MY(),i=RY(),r=NY(),s=KY();function o(c){var u=this.__data__=new t(c);this.size=u.size}return o.prototype.clear=e,o.prototype.delete=n,o.prototype.get=i,o.prototype.has=r,o.prototype.set=s,wy=o,wy}var Sy,IT;function B2(){if(IT)return Sy;IT=1;function t(e,n){for(var i=-1,r=e==null?0:e.length;++i<r&&n(e[i],i,e)!==!1;);return e}return Sy=t,Sy}var Cy,PT;function Gz(){if(PT)return Cy;PT=1;var t=Qa(),e=(function(){try{var n=t(Object,"defineProperty");return n({},"",{}),n}catch{}})();return Cy=e,Cy}var ky,HT;function Sp(){if(HT)return ky;HT=1;var t=Gz();function e(n,i,r){i=="__proto__"&&t?t(n,i,{configurable:!0,enumerable:!0,value:r,writable:!0}):n[i]=r}return ky=e,ky}var Ay,UT;function Cp(){if(UT)return Ay;UT=1;var t=Sp(),e=wl(),n=Object.prototype,i=n.hasOwnProperty;function r(s,o,c){var u=s[o];(!(i.call(s,o)&&e(u,c))||c===void 0&&!(o in s))&&t(s,o,c)}return Ay=r,Ay}var _y,VT;function zu(){if(VT)return _y;VT=1;var t=Cp(),e=Sp();function n(i,r,s,o){var c=!s;s||(s={});for(var u=-1,h=r.length;++u<h;){var d=r[u],m=o?o(s[d],i[d],d,s,i):void 0;m===void 0&&(m=i[d]),c?e(s,d,m):t(s,d,m)}return s}return _y=n,_y}var Oy,FT;function ZY(){if(FT)return Oy;FT=1;function t(e,n){for(var i=-1,r=Array(e);++i<e;)r[i]=n(i);return r}return Oy=t,Oy}var Ey,$T;function hr(){if($T)return Ey;$T=1;function t(e){return e!=null&&typeof e=="object"}return Ey=t,Ey}var Ty,GT;function JY(){if(GT)return Ty;GT=1;var t=Ya(),e=hr(),n="[object Arguments]";function i(r){return e(r)&&t(r)==n}return Ty=i,Ty}var My,YT;function Bu(){if(YT)return My;YT=1;var t=JY(),e=hr(),n=Object.prototype,i=n.hasOwnProperty,r=n.propertyIsEnumerable,s=t((function(){return arguments})())?t:function(o){return e(o)&&i.call(o,"callee")&&!r.call(o,"callee")};return My=s,My}var Ry,QT;function Wt(){if(QT)return Ry;QT=1;var t=Array.isArray;return Ry=t,Ry}var Pc={exports:{}},Ny,XT;function eQ(){if(XT)return Ny;XT=1;function t(){return!1}return Ny=t,Ny}Pc.exports;var WT;function Cl(){return WT||(WT=1,(function(t,e){var n=Hi(),i=eQ(),r=e&&!e.nodeType&&e,s=r&&!0&&t&&!t.nodeType&&t,o=s&&s.exports===r,c=o?n.Buffer:void 0,u=c?c.isBuffer:void 0,h=u||i;t.exports=h})(Pc,Pc.exports)),Pc.exports}var Dy,KT;function kp(){if(KT)return Dy;KT=1;var t=9007199254740991,e=/^(?:0|[1-9]\d*)$/;function n(i,r){var s=typeof i;return r=r??t,!!r&&(s=="number"||s!="symbol"&&e.test(i))&&i>-1&&i%1==0&&i<r}return Dy=n,Dy}var Ly,ZT;function q2(){if(ZT)return Ly;ZT=1;var t=9007199254740991;function e(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=t}return Ly=e,Ly}var zy,JT;function tQ(){if(JT)return zy;JT=1;var t=Ya(),e=q2(),n=hr(),i="[object Arguments]",r="[object Array]",s="[object Boolean]",o="[object Date]",c="[object Error]",u="[object Function]",h="[object Map]",d="[object Number]",m="[object Object]",g="[object RegExp]",y="[object Set]",x="[object String]",w="[object WeakMap]",S="[object ArrayBuffer]",C="[object DataView]",A="[object Float32Array]",O="[object Float64Array]",E="[object Int8Array]",T="[object Int16Array]",M="[object Int32Array]",R="[object Uint8Array]",z="[object Uint8ClampedArray]",q="[object Uint16Array]",U="[object Uint32Array]",P={};P[A]=P[O]=P[E]=P[T]=P[M]=P[R]=P[z]=P[q]=P[U]=!0,P[i]=P[r]=P[S]=P[s]=P[C]=P[o]=P[c]=P[u]=P[h]=P[d]=P[m]=P[g]=P[y]=P[x]=P[w]=!1;function $(K){return n(K)&&e(K.length)&&!!P[t(K)]}return zy=$,zy}var By,eM;function Ap(){if(eM)return By;eM=1;function t(e){return function(n){return e(n)}}return By=t,By}var Hc={exports:{}};Hc.exports;var tM;function j2(){return tM||(tM=1,(function(t,e){var n=Fz(),i=e&&!e.nodeType&&e,r=i&&!0&&t&&!t.nodeType&&t,s=r&&r.exports===i,o=s&&n.process,c=(function(){try{var u=r&&r.require&&r.require("util").types;return u||o&&o.binding&&o.binding("util")}catch{}})();t.exports=c})(Hc,Hc.exports)),Hc.exports}var qy,nM;function qu(){if(nM)return qy;nM=1;var t=tQ(),e=Ap(),n=j2(),i=n&&n.isTypedArray,r=i?e(i):t;return qy=r,qy}var jy,iM;function Yz(){if(iM)return jy;iM=1;var t=ZY(),e=Bu(),n=Wt(),i=Cl(),r=kp(),s=qu(),o=Object.prototype,c=o.hasOwnProperty;function u(h,d){var m=n(h),g=!m&&e(h),y=!m&&!g&&i(h),x=!m&&!g&&!y&&s(h),w=m||g||y||x,S=w?t(h.length,String):[],C=S.length;for(var A in h)(d||c.call(h,A))&&!(w&&(A=="length"||y&&(A=="offset"||A=="parent")||x&&(A=="buffer"||A=="byteLength"||A=="byteOffset")||r(A,C)))&&S.push(A);return S}return jy=u,jy}var Iy,rM;function _p(){if(rM)return Iy;rM=1;var t=Object.prototype;function e(n){var i=n&&n.constructor,r=typeof i=="function"&&i.prototype||t;return n===r}return Iy=e,Iy}var Py,sM;function Qz(){if(sM)return Py;sM=1;function t(e,n){return function(i){return e(n(i))}}return Py=t,Py}var Hy,aM;function nQ(){if(aM)return Hy;aM=1;var t=Qz(),e=t(Object.keys,Object);return Hy=e,Hy}var Uy,oM;function I2(){if(oM)return Uy;oM=1;var t=_p(),e=nQ(),n=Object.prototype,i=n.hasOwnProperty;function r(s){if(!t(s))return e(s);var o=[];for(var c in Object(s))i.call(s,c)&&c!="constructor"&&o.push(c);return o}return Uy=r,Uy}var Vy,lM;function ts(){if(lM)return Vy;lM=1;var t=Lu(),e=q2();function n(i){return i!=null&&e(i.length)&&!t(i)}return Vy=n,Vy}var Fy,cM;function Js(){if(cM)return Fy;cM=1;var t=Yz(),e=I2(),n=ts();function i(r){return n(r)?t(r):e(r)}return Fy=i,Fy}var $y,uM;function iQ(){if(uM)return $y;uM=1;var t=zu(),e=Js();function n(i,r){return i&&t(r,e(r),i)}return $y=n,$y}var Gy,fM;function rQ(){if(fM)return Gy;fM=1;function t(e){var n=[];if(e!=null)for(var i in Object(e))n.push(i);return n}return Gy=t,Gy}var Yy,hM;function sQ(){if(hM)return Yy;hM=1;var t=Oi(),e=_p(),n=rQ(),i=Object.prototype,r=i.hasOwnProperty;function s(o){if(!t(o))return n(o);var c=e(o),u=[];for(var h in o)h=="constructor"&&(c||!r.call(o,h))||u.push(h);return u}return Yy=s,Yy}var Qy,dM;function Xa(){if(dM)return Qy;dM=1;var t=Yz(),e=sQ(),n=ts();function i(r){return n(r)?t(r,!0):e(r)}return Qy=i,Qy}var Xy,pM;function aQ(){if(pM)return Xy;pM=1;var t=zu(),e=Xa();function n(i,r){return i&&t(r,e(r),i)}return Xy=n,Xy}var Uc={exports:{}};Uc.exports;var mM;function Xz(){return mM||(mM=1,(function(t,e){var n=Hi(),i=e&&!e.nodeType&&e,r=i&&!0&&t&&!t.nodeType&&t,s=r&&r.exports===i,o=s?n.Buffer:void 0,c=o?o.allocUnsafe:void 0;function u(h,d){if(d)return h.slice();var m=h.length,g=c?c(m):new h.constructor(m);return h.copy(g),g}t.exports=u})(Uc,Uc.exports)),Uc.exports}var Wy,gM;function Wz(){if(gM)return Wy;gM=1;function t(e,n){var i=-1,r=e.length;for(n||(n=Array(r));++i<r;)n[i]=e[i];return n}return Wy=t,Wy}var Ky,yM;function Kz(){if(yM)return Ky;yM=1;function t(e,n){for(var i=-1,r=e==null?0:e.length,s=0,o=[];++i<r;){var c=e[i];n(c,i,e)&&(o[s++]=c)}return o}return Ky=t,Ky}var Zy,vM;function Zz(){if(vM)return Zy;vM=1;function t(){return[]}return Zy=t,Zy}var Jy,bM;function P2(){if(bM)return Jy;bM=1;var t=Kz(),e=Zz(),n=Object.prototype,i=n.propertyIsEnumerable,r=Object.getOwnPropertySymbols,s=r?function(o){return o==null?[]:(o=Object(o),t(r(o),function(c){return i.call(o,c)}))}:e;return Jy=s,Jy}var ev,xM;function oQ(){if(xM)return ev;xM=1;var t=zu(),e=P2();function n(i,r){return t(i,e(i),r)}return ev=n,ev}var tv,wM;function H2(){if(wM)return tv;wM=1;function t(e,n){for(var i=-1,r=n.length,s=e.length;++i<r;)e[s+i]=n[i];return e}return tv=t,tv}var nv,SM;function Op(){if(SM)return nv;SM=1;var t=Qz(),e=t(Object.getPrototypeOf,Object);return nv=e,nv}var iv,CM;function Jz(){if(CM)return iv;CM=1;var t=H2(),e=Op(),n=P2(),i=Zz(),r=Object.getOwnPropertySymbols,s=r?function(o){for(var c=[];o;)t(c,n(o)),o=e(o);return c}:i;return iv=s,iv}var rv,kM;function lQ(){if(kM)return rv;kM=1;var t=zu(),e=Jz();function n(i,r){return t(i,e(i),r)}return rv=n,rv}var sv,AM;function e8(){if(AM)return sv;AM=1;var t=H2(),e=Wt();function n(i,r,s){var o=r(i);return e(i)?o:t(o,s(i))}return sv=n,sv}var av,_M;function t8(){if(_M)return av;_M=1;var t=e8(),e=P2(),n=Js();function i(r){return t(r,n,e)}return av=i,av}var ov,OM;function cQ(){if(OM)return ov;OM=1;var t=e8(),e=Jz(),n=Xa();function i(r){return t(r,n,e)}return ov=i,ov}var lv,EM;function uQ(){if(EM)return lv;EM=1;var t=Qa(),e=Hi(),n=t(e,"DataView");return lv=n,lv}var cv,TM;function fQ(){if(TM)return cv;TM=1;var t=Qa(),e=Hi(),n=t(e,"Promise");return cv=n,cv}var uv,MM;function n8(){if(MM)return uv;MM=1;var t=Qa(),e=Hi(),n=t(e,"Set");return uv=n,uv}var fv,RM;function hQ(){if(RM)return fv;RM=1;var t=Qa(),e=Hi(),n=t(e,"WeakMap");return fv=n,fv}var hv,NM;function kl(){if(NM)return hv;NM=1;var t=uQ(),e=L2(),n=fQ(),i=n8(),r=hQ(),s=Ya(),o=$z(),c="[object Map]",u="[object Object]",h="[object Promise]",d="[object Set]",m="[object WeakMap]",g="[object DataView]",y=o(t),x=o(e),w=o(n),S=o(i),C=o(r),A=s;return(t&&A(new t(new ArrayBuffer(1)))!=g||e&&A(new e)!=c||n&&A(n.resolve())!=h||i&&A(new i)!=d||r&&A(new r)!=m)&&(A=function(O){var E=s(O),T=E==u?O.constructor:void 0,M=T?o(T):"";if(M)switch(M){case y:return g;case x:return c;case w:return h;case S:return d;case C:return m}return E}),hv=A,hv}var dv,DM;function dQ(){if(DM)return dv;DM=1;var t=Object.prototype,e=t.hasOwnProperty;function n(i){var r=i.length,s=new i.constructor(r);return r&&typeof i[0]=="string"&&e.call(i,"index")&&(s.index=i.index,s.input=i.input),s}return dv=n,dv}var pv,LM;function i8(){if(LM)return pv;LM=1;var t=Hi(),e=t.Uint8Array;return pv=e,pv}var mv,zM;function U2(){if(zM)return mv;zM=1;var t=i8();function e(n){var i=new n.constructor(n.byteLength);return new t(i).set(new t(n)),i}return mv=e,mv}var gv,BM;function pQ(){if(BM)return gv;BM=1;var t=U2();function e(n,i){var r=i?t(n.buffer):n.buffer;return new n.constructor(r,n.byteOffset,n.byteLength)}return gv=e,gv}var yv,qM;function mQ(){if(qM)return yv;qM=1;var t=/\w*$/;function e(n){var i=new n.constructor(n.source,t.exec(n));return i.lastIndex=n.lastIndex,i}return yv=e,yv}var vv,jM;function gQ(){if(jM)return vv;jM=1;var t=Sl(),e=t?t.prototype:void 0,n=e?e.valueOf:void 0;function i(r){return n?Object(n.call(r)):{}}return vv=i,vv}var bv,IM;function r8(){if(IM)return bv;IM=1;var t=U2();function e(n,i){var r=i?t(n.buffer):n.buffer;return new n.constructor(r,n.byteOffset,n.length)}return bv=e,bv}var xv,PM;function yQ(){if(PM)return xv;PM=1;var t=U2(),e=pQ(),n=mQ(),i=gQ(),r=r8(),s="[object Boolean]",o="[object Date]",c="[object Map]",u="[object Number]",h="[object RegExp]",d="[object Set]",m="[object String]",g="[object Symbol]",y="[object ArrayBuffer]",x="[object DataView]",w="[object Float32Array]",S="[object Float64Array]",C="[object Int8Array]",A="[object Int16Array]",O="[object Int32Array]",E="[object Uint8Array]",T="[object Uint8ClampedArray]",M="[object Uint16Array]",R="[object Uint32Array]";function z(q,U,P){var $=q.constructor;switch(U){case y:return t(q);case s:case o:return new $(+q);case x:return e(q,P);case w:case S:case C:case A:case O:case E:case T:case M:case R:return r(q,P);case c:return new $;case u:case m:return new $(q);case h:return n(q);case d:return new $;case g:return i(q)}}return xv=z,xv}var wv,HM;function s8(){if(HM)return wv;HM=1;var t=Oi(),e=Object.create,n=(function(){function i(){}return function(r){if(!t(r))return{};if(e)return e(r);i.prototype=r;var s=new i;return i.prototype=void 0,s}})();return wv=n,wv}var Sv,UM;function a8(){if(UM)return Sv;UM=1;var t=s8(),e=Op(),n=_p();function i(r){return typeof r.constructor=="function"&&!n(r)?t(e(r)):{}}return Sv=i,Sv}var Cv,VM;function vQ(){if(VM)return Cv;VM=1;var t=kl(),e=hr(),n="[object Map]";function i(r){return e(r)&&t(r)==n}return Cv=i,Cv}var kv,FM;function bQ(){if(FM)return kv;FM=1;var t=vQ(),e=Ap(),n=j2(),i=n&&n.isMap,r=i?e(i):t;return kv=r,kv}var Av,$M;function xQ(){if($M)return Av;$M=1;var t=kl(),e=hr(),n="[object Set]";function i(r){return e(r)&&t(r)==n}return Av=i,Av}var _v,GM;function wQ(){if(GM)return _v;GM=1;var t=xQ(),e=Ap(),n=j2(),i=n&&n.isSet,r=i?e(i):t;return _v=r,_v}var Ov,YM;function o8(){if(YM)return Ov;YM=1;var t=wp(),e=B2(),n=Cp(),i=iQ(),r=aQ(),s=Xz(),o=Wz(),c=oQ(),u=lQ(),h=t8(),d=cQ(),m=kl(),g=dQ(),y=yQ(),x=a8(),w=Wt(),S=Cl(),C=bQ(),A=Oi(),O=wQ(),E=Js(),T=Xa(),M=1,R=2,z=4,q="[object Arguments]",U="[object Array]",P="[object Boolean]",$="[object Date]",K="[object Error]",L="[object Function]",Y="[object GeneratorFunction]",D="[object Map]",Q="[object Number]",ee="[object Object]",G="[object RegExp]",W="[object Set]",B="[object String]",F="[object Symbol]",ne="[object WeakMap]",I="[object ArrayBuffer]",X="[object DataView]",J="[object Float32Array]",oe="[object Float64Array]",ve="[object Int8Array]",H="[object Int16Array]",pe="[object Int32Array]",me="[object Uint8Array]",ye="[object Uint8ClampedArray]",_e="[object Uint16Array]",Ae="[object Uint32Array]",be={};be[q]=be[U]=be[I]=be[X]=be[P]=be[$]=be[J]=be[oe]=be[ve]=be[H]=be[pe]=be[D]=be[Q]=be[ee]=be[G]=be[W]=be[B]=be[F]=be[me]=be[ye]=be[_e]=be[Ae]=!0,be[K]=be[L]=be[ne]=!1;function He(we,ge,Be,vt,Xe,bt){var rt,et=ge&M,Et=ge&R,Pt=ge&z;if(Be&&(rt=Xe?Be(we,vt,Xe,bt):Be(we)),rt!==void 0)return rt;if(!A(we))return we;var Ht=w(we);if(Ht){if(rt=g(we),!et)return o(we,rt)}else{var ct=m(we),an=ct==L||ct==Y;if(S(we))return s(we,et);if(ct==ee||ct==q||an&&!Xe){if(rt=Et||an?{}:x(we),!et)return Et?u(we,r(rt,we)):c(we,i(rt,we))}else{if(!be[ct])return Xe?we:{};rt=y(we,ct,et)}}bt||(bt=new t);var Wn=bt.get(we);if(Wn)return Wn;bt.set(we,rt),O(we)?we.forEach(function(Ct){rt.add(He(Ct,ge,Be,Ct,we,bt))}):C(we)&&we.forEach(function(Ct,st){rt.set(st,He(Ct,ge,Be,st,we,bt))});var Tt=Pt?Et?d:h:Et?T:E,on=Ht?void 0:Tt(we);return e(on||we,function(Ct,st){on&&(st=Ct,Ct=we[st]),n(rt,st,He(Ct,ge,Be,st,we,bt))}),rt}return Ov=He,Ov}var Ev,QM;function SQ(){if(QM)return Ev;QM=1;var t=o8(),e=4;function n(i){return t(i,e)}return Ev=n,Ev}var Tv,XM;function V2(){if(XM)return Tv;XM=1;function t(e){return function(){return e}}return Tv=t,Tv}var Mv,WM;function CQ(){if(WM)return Mv;WM=1;function t(e){return function(n,i,r){for(var s=-1,o=Object(n),c=r(n),u=c.length;u--;){var h=c[e?u:++s];if(i(o[h],h,o)===!1)break}return n}}return Mv=t,Mv}var Rv,KM;function F2(){if(KM)return Rv;KM=1;var t=CQ(),e=t();return Rv=e,Rv}var Nv,ZM;function $2(){if(ZM)return Nv;ZM=1;var t=F2(),e=Js();function n(i,r){return i&&t(i,r,e)}return Nv=n,Nv}var Dv,JM;function kQ(){if(JM)return Dv;JM=1;var t=ts();function e(n,i){return function(r,s){if(r==null)return r;if(!t(r))return n(r,s);for(var o=r.length,c=i?o:-1,u=Object(r);(i?c--:++c<o)&&s(u[c],c,u)!==!1;);return r}}return Dv=e,Dv}var Lv,eR;function Ep(){if(eR)return Lv;eR=1;var t=$2(),e=kQ(),n=e(t);return Lv=n,Lv}var zv,tR;function Wa(){if(tR)return zv;tR=1;function t(e){return e}return zv=t,zv}var Bv,nR;function l8(){if(nR)return Bv;nR=1;var t=Wa();function e(n){return typeof n=="function"?n:t}return Bv=e,Bv}var qv,iR;function c8(){if(iR)return qv;iR=1;var t=B2(),e=Ep(),n=l8(),i=Wt();function r(s,o){var c=i(s)?t:e;return c(s,n(o))}return qv=r,qv}var jv,rR;function u8(){return rR||(rR=1,jv=c8()),jv}var Iv,sR;function AQ(){if(sR)return Iv;sR=1;var t=Ep();function e(n,i){var r=[];return t(n,function(s,o,c){i(s,o,c)&&r.push(s)}),r}return Iv=e,Iv}var Pv,aR;function _Q(){if(aR)return Pv;aR=1;var t="__lodash_hash_undefined__";function e(n){return this.__data__.set(n,t),this}return Pv=e,Pv}var Hv,oR;function OQ(){if(oR)return Hv;oR=1;function t(e){return this.__data__.has(e)}return Hv=t,Hv}var Uv,lR;function f8(){if(lR)return Uv;lR=1;var t=z2(),e=_Q(),n=OQ();function i(r){var s=-1,o=r==null?0:r.length;for(this.__data__=new t;++s<o;)this.add(r[s])}return i.prototype.add=i.prototype.push=e,i.prototype.has=n,Uv=i,Uv}var Vv,cR;function EQ(){if(cR)return Vv;cR=1;function t(e,n){for(var i=-1,r=e==null?0:e.length;++i<r;)if(n(e[i],i,e))return!0;return!1}return Vv=t,Vv}var Fv,uR;function h8(){if(uR)return Fv;uR=1;function t(e,n){return e.has(n)}return Fv=t,Fv}var $v,fR;function d8(){if(fR)return $v;fR=1;var t=f8(),e=EQ(),n=h8(),i=1,r=2;function s(o,c,u,h,d,m){var g=u&i,y=o.length,x=c.length;if(y!=x&&!(g&&x>y))return!1;var w=m.get(o),S=m.get(c);if(w&&S)return w==c&&S==o;var C=-1,A=!0,O=u&r?new t:void 0;for(m.set(o,c),m.set(c,o);++C<y;){var E=o[C],T=c[C];if(h)var M=g?h(T,E,C,c,o,m):h(E,T,C,o,c,m);if(M!==void 0){if(M)continue;A=!1;break}if(O){if(!e(c,function(R,z){if(!n(O,z)&&(E===R||d(E,R,u,h,m)))return O.push(z)})){A=!1;break}}else if(!(E===T||d(E,T,u,h,m))){A=!1;break}}return m.delete(o),m.delete(c),A}return $v=s,$v}var Gv,hR;function TQ(){if(hR)return Gv;hR=1;function t(e){var n=-1,i=Array(e.size);return e.forEach(function(r,s){i[++n]=[s,r]}),i}return Gv=t,Gv}var Yv,dR;function G2(){if(dR)return Yv;dR=1;function t(e){var n=-1,i=Array(e.size);return e.forEach(function(r){i[++n]=r}),i}return Yv=t,Yv}var Qv,pR;function MQ(){if(pR)return Qv;pR=1;var t=Sl(),e=i8(),n=wl(),i=d8(),r=TQ(),s=G2(),o=1,c=2,u="[object Boolean]",h="[object Date]",d="[object Error]",m="[object Map]",g="[object Number]",y="[object RegExp]",x="[object Set]",w="[object String]",S="[object Symbol]",C="[object ArrayBuffer]",A="[object DataView]",O=t?t.prototype:void 0,E=O?O.valueOf:void 0;function T(M,R,z,q,U,P,$){switch(z){case A:if(M.byteLength!=R.byteLength||M.byteOffset!=R.byteOffset)return!1;M=M.buffer,R=R.buffer;case C:return!(M.byteLength!=R.byteLength||!P(new e(M),new e(R)));case u:case h:case g:return n(+M,+R);case d:return M.name==R.name&&M.message==R.message;case y:case w:return M==R+"";case m:var K=r;case x:var L=q&o;if(K||(K=s),M.size!=R.size&&!L)return!1;var Y=$.get(M);if(Y)return Y==R;q|=c,$.set(M,R);var D=i(K(M),K(R),q,U,P,$);return $.delete(M),D;case S:if(E)return E.call(M)==E.call(R)}return!1}return Qv=T,Qv}var Xv,mR;function RQ(){if(mR)return Xv;mR=1;var t=t8(),e=1,n=Object.prototype,i=n.hasOwnProperty;function r(s,o,c,u,h,d){var m=c&e,g=t(s),y=g.length,x=t(o),w=x.length;if(y!=w&&!m)return!1;for(var S=y;S--;){var C=g[S];if(!(m?C in o:i.call(o,C)))return!1}var A=d.get(s),O=d.get(o);if(A&&O)return A==o&&O==s;var E=!0;d.set(s,o),d.set(o,s);for(var T=m;++S<y;){C=g[S];var M=s[C],R=o[C];if(u)var z=m?u(R,M,C,o,s,d):u(M,R,C,s,o,d);if(!(z===void 0?M===R||h(M,R,c,u,d):z)){E=!1;break}T||(T=C=="constructor")}if(E&&!T){var q=s.constructor,U=o.constructor;q!=U&&"constructor"in s&&"constructor"in o&&!(typeof q=="function"&&q instanceof q&&typeof U=="function"&&U instanceof U)&&(E=!1)}return d.delete(s),d.delete(o),E}return Xv=r,Xv}var Wv,gR;function NQ(){if(gR)return Wv;gR=1;var t=wp(),e=d8(),n=MQ(),i=RQ(),r=kl(),s=Wt(),o=Cl(),c=qu(),u=1,h="[object Arguments]",d="[object Array]",m="[object Object]",g=Object.prototype,y=g.hasOwnProperty;function x(w,S,C,A,O,E){var T=s(w),M=s(S),R=T?d:r(w),z=M?d:r(S);R=R==h?m:R,z=z==h?m:z;var q=R==m,U=z==m,P=R==z;if(P&&o(w)){if(!o(S))return!1;T=!0,q=!1}if(P&&!q)return E||(E=new t),T||c(w)?e(w,S,C,A,O,E):n(w,S,R,C,A,O,E);if(!(C&u)){var $=q&&y.call(w,"__wrapped__"),K=U&&y.call(S,"__wrapped__");if($||K){var L=$?w.value():w,Y=K?S.value():S;return E||(E=new t),O(L,Y,C,A,E)}}return P?(E||(E=new t),i(w,S,C,A,O,E)):!1}return Wv=x,Wv}var Kv,yR;function p8(){if(yR)return Kv;yR=1;var t=NQ(),e=hr();function n(i,r,s,o,c){return i===r?!0:i==null||r==null||!e(i)&&!e(r)?i!==i&&r!==r:t(i,r,s,o,n,c)}return Kv=n,Kv}var Zv,vR;function DQ(){if(vR)return Zv;vR=1;var t=wp(),e=p8(),n=1,i=2;function r(s,o,c,u){var h=c.length,d=h,m=!u;if(s==null)return!d;for(s=Object(s);h--;){var g=c[h];if(m&&g[2]?g[1]!==s[g[0]]:!(g[0]in s))return!1}for(;++h<d;){g=c[h];var y=g[0],x=s[y],w=g[1];if(m&&g[2]){if(x===void 0&&!(y in s))return!1}else{var S=new t;if(u)var C=u(x,w,y,s,o,S);if(!(C===void 0?e(w,x,n|i,u,S):C))return!1}}return!0}return Zv=r,Zv}var Jv,bR;function m8(){if(bR)return Jv;bR=1;var t=Oi();function e(n){return n===n&&!t(n)}return Jv=e,Jv}var eb,xR;function LQ(){if(xR)return eb;xR=1;var t=m8(),e=Js();function n(i){for(var r=e(i),s=r.length;s--;){var o=r[s],c=i[o];r[s]=[o,c,t(c)]}return r}return eb=n,eb}var tb,wR;function g8(){if(wR)return tb;wR=1;function t(e,n){return function(i){return i==null?!1:i[e]===n&&(n!==void 0||e in Object(i))}}return tb=t,tb}var nb,SR;function zQ(){if(SR)return nb;SR=1;var t=DQ(),e=LQ(),n=g8();function i(r){var s=e(r);return s.length==1&&s[0][2]?n(s[0][0],s[0][1]):function(o){return o===r||t(o,r,s)}}return nb=i,nb}var ib,CR;function Al(){if(CR)return ib;CR=1;var t=Ya(),e=hr(),n="[object Symbol]";function i(r){return typeof r=="symbol"||e(r)&&t(r)==n}return ib=i,ib}var rb,kR;function Y2(){if(kR)return rb;kR=1;var t=Wt(),e=Al(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,i=/^\w*$/;function r(s,o){if(t(s))return!1;var c=typeof s;return c=="number"||c=="symbol"||c=="boolean"||s==null||e(s)?!0:i.test(s)||!n.test(s)||o!=null&&s in Object(o)}return rb=r,rb}var sb,AR;function BQ(){if(AR)return sb;AR=1;var t=z2(),e="Expected a function";function n(i,r){if(typeof i!="function"||r!=null&&typeof r!="function")throw new TypeError(e);var s=function(){var o=arguments,c=r?r.apply(this,o):o[0],u=s.cache;if(u.has(c))return u.get(c);var h=i.apply(this,o);return s.cache=u.set(c,h)||u,h};return s.cache=new(n.Cache||t),s}return n.Cache=t,sb=n,sb}var ab,_R;function qQ(){if(_R)return ab;_R=1;var t=BQ(),e=500;function n(i){var r=t(i,function(o){return s.size===e&&s.clear(),o}),s=r.cache;return r}return ab=n,ab}var ob,OR;function jQ(){if(OR)return ob;OR=1;var t=qQ(),e=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,n=/\\(\\)?/g,i=t(function(r){var s=[];return r.charCodeAt(0)===46&&s.push(""),r.replace(e,function(o,c,u,h){s.push(u?h.replace(n,"$1"):c||o)}),s});return ob=i,ob}var lb,ER;function Tp(){if(ER)return lb;ER=1;function t(e,n){for(var i=-1,r=e==null?0:e.length,s=Array(r);++i<r;)s[i]=n(e[i],i,e);return s}return lb=t,lb}var cb,TR;function IQ(){if(TR)return cb;TR=1;var t=Sl(),e=Tp(),n=Wt(),i=Al(),r=t?t.prototype:void 0,s=r?r.toString:void 0;function o(c){if(typeof c=="string")return c;if(n(c))return e(c,o)+"";if(i(c))return s?s.call(c):"";var u=c+"";return u=="0"&&1/c==-1/0?"-0":u}return cb=o,cb}var ub,MR;function y8(){if(MR)return ub;MR=1;var t=IQ();function e(n){return n==null?"":t(n)}return ub=e,ub}var fb,RR;function Mp(){if(RR)return fb;RR=1;var t=Wt(),e=Y2(),n=jQ(),i=y8();function r(s,o){return t(s)?s:e(s,o)?[s]:n(i(s))}return fb=r,fb}var hb,NR;function ju(){if(NR)return hb;NR=1;var t=Al();function e(n){if(typeof n=="string"||t(n))return n;var i=n+"";return i=="0"&&1/n==-1/0?"-0":i}return hb=e,hb}var db,DR;function Rp(){if(DR)return db;DR=1;var t=Mp(),e=ju();function n(i,r){r=t(r,i);for(var s=0,o=r.length;i!=null&&s<o;)i=i[e(r[s++])];return s&&s==o?i:void 0}return db=n,db}var pb,LR;function PQ(){if(LR)return pb;LR=1;var t=Rp();function e(n,i,r){var s=n==null?void 0:t(n,i);return s===void 0?r:s}return pb=e,pb}var mb,zR;function HQ(){if(zR)return mb;zR=1;function t(e,n){return e!=null&&n in Object(e)}return mb=t,mb}var gb,BR;function v8(){if(BR)return gb;BR=1;var t=Mp(),e=Bu(),n=Wt(),i=kp(),r=q2(),s=ju();function o(c,u,h){u=t(u,c);for(var d=-1,m=u.length,g=!1;++d<m;){var y=s(u[d]);if(!(g=c!=null&&h(c,y)))break;c=c[y]}return g||++d!=m?g:(m=c==null?0:c.length,!!m&&r(m)&&i(y,m)&&(n(c)||e(c)))}return gb=o,gb}var yb,qR;function b8(){if(qR)return yb;qR=1;var t=HQ(),e=v8();function n(i,r){return i!=null&&e(i,r,t)}return yb=n,yb}var vb,jR;function UQ(){if(jR)return vb;jR=1;var t=p8(),e=PQ(),n=b8(),i=Y2(),r=m8(),s=g8(),o=ju(),c=1,u=2;function h(d,m){return i(d)&&r(m)?s(o(d),m):function(g){var y=e(g,d);return y===void 0&&y===m?n(g,d):t(m,y,c|u)}}return vb=h,vb}var bb,IR;function x8(){if(IR)return bb;IR=1;function t(e){return function(n){return n?.[e]}}return bb=t,bb}var xb,PR;function VQ(){if(PR)return xb;PR=1;var t=Rp();function e(n){return function(i){return t(i,n)}}return xb=e,xb}var wb,HR;function FQ(){if(HR)return wb;HR=1;var t=x8(),e=VQ(),n=Y2(),i=ju();function r(s){return n(s)?t(i(s)):e(s)}return wb=r,wb}var Sb,UR;function ns(){if(UR)return Sb;UR=1;var t=zQ(),e=UQ(),n=Wa(),i=Wt(),r=FQ();function s(o){return typeof o=="function"?o:o==null?n:typeof o=="object"?i(o)?e(o[0],o[1]):t(o):r(o)}return Sb=s,Sb}var Cb,VR;function w8(){if(VR)return Cb;VR=1;var t=Kz(),e=AQ(),n=ns(),i=Wt();function r(s,o){var c=i(s)?t:e;return c(s,n(o,3))}return Cb=r,Cb}var kb,FR;function $Q(){if(FR)return kb;FR=1;var t=Object.prototype,e=t.hasOwnProperty;function n(i,r){return i!=null&&e.call(i,r)}return kb=n,kb}var Ab,$R;function S8(){if($R)return Ab;$R=1;var t=$Q(),e=v8();function n(i,r){return i!=null&&e(i,r,t)}return Ab=n,Ab}var _b,GR;function GQ(){if(GR)return _b;GR=1;var t=I2(),e=kl(),n=Bu(),i=Wt(),r=ts(),s=Cl(),o=_p(),c=qu(),u="[object Map]",h="[object Set]",d=Object.prototype,m=d.hasOwnProperty;function g(y){if(y==null)return!0;if(r(y)&&(i(y)||typeof y=="string"||typeof y.splice=="function"||s(y)||c(y)||n(y)))return!y.length;var x=e(y);if(x==u||x==h)return!y.size;if(o(y))return!t(y).length;for(var w in y)if(m.call(y,w))return!1;return!0}return _b=g,_b}var Ob,YR;function C8(){if(YR)return Ob;YR=1;function t(e){return e===void 0}return Ob=t,Ob}var Eb,QR;function k8(){if(QR)return Eb;QR=1;var t=Ep(),e=ts();function n(i,r){var s=-1,o=e(i)?Array(i.length):[];return t(i,function(c,u,h){o[++s]=r(c,u,h)}),o}return Eb=n,Eb}var Tb,XR;function A8(){if(XR)return Tb;XR=1;var t=Tp(),e=ns(),n=k8(),i=Wt();function r(s,o){var c=i(s)?t:n;return c(s,e(o,3))}return Tb=r,Tb}var Mb,WR;function YQ(){if(WR)return Mb;WR=1;function t(e,n,i,r){var s=-1,o=e==null?0:e.length;for(r&&o&&(i=e[++s]);++s<o;)i=n(i,e[s],s,e);return i}return Mb=t,Mb}var Rb,KR;function QQ(){if(KR)return Rb;KR=1;function t(e,n,i,r,s){return s(e,function(o,c,u){i=r?(r=!1,o):n(i,o,c,u)}),i}return Rb=t,Rb}var Nb,ZR;function _8(){if(ZR)return Nb;ZR=1;var t=YQ(),e=Ep(),n=ns(),i=QQ(),r=Wt();function s(o,c,u){var h=r(o)?t:i,d=arguments.length<3;return h(o,n(c,4),u,d,e)}return Nb=s,Nb}var Db,JR;function XQ(){if(JR)return Db;JR=1;var t=Ya(),e=Wt(),n=hr(),i="[object String]";function r(s){return typeof s=="string"||!e(s)&&n(s)&&t(s)==i}return Db=r,Db}var Lb,eN;function WQ(){if(eN)return Lb;eN=1;var t=x8(),e=t("length");return Lb=e,Lb}var zb,tN;function KQ(){if(tN)return zb;tN=1;var t="\\ud800-\\udfff",e="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",i="\\u20d0-\\u20ff",r=e+n+i,s="\\ufe0e\\ufe0f",o="\\u200d",c=RegExp("["+o+t+r+s+"]");function u(h){return c.test(h)}return zb=u,zb}var Bb,nN;function ZQ(){if(nN)return Bb;nN=1;var t="\\ud800-\\udfff",e="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",i="\\u20d0-\\u20ff",r=e+n+i,s="\\ufe0e\\ufe0f",o="["+t+"]",c="["+r+"]",u="\\ud83c[\\udffb-\\udfff]",h="(?:"+c+"|"+u+")",d="[^"+t+"]",m="(?:\\ud83c[\\udde6-\\uddff]){2}",g="[\\ud800-\\udbff][\\udc00-\\udfff]",y="\\u200d",x=h+"?",w="["+s+"]?",S="(?:"+y+"(?:"+[d,m,g].join("|")+")"+w+x+")*",C=w+x+S,A="(?:"+[d+c+"?",c,m,g,o].join("|")+")",O=RegExp(u+"(?="+u+")|"+A+C,"g");function E(T){for(var M=O.lastIndex=0;O.test(T);)++M;return M}return Bb=E,Bb}var qb,iN;function JQ(){if(iN)return qb;iN=1;var t=WQ(),e=KQ(),n=ZQ();function i(r){return e(r)?n(r):t(r)}return qb=i,qb}var jb,rN;function eX(){if(rN)return jb;rN=1;var t=I2(),e=kl(),n=ts(),i=XQ(),r=JQ(),s="[object Map]",o="[object Set]";function c(u){if(u==null)return 0;if(n(u))return i(u)?r(u):u.length;var h=e(u);return h==s||h==o?u.size:t(u).length}return jb=c,jb}var Ib,sN;function tX(){if(sN)return Ib;sN=1;var t=B2(),e=s8(),n=$2(),i=ns(),r=Op(),s=Wt(),o=Cl(),c=Lu(),u=Oi(),h=qu();function d(m,g,y){var x=s(m),w=x||o(m)||h(m);if(g=i(g,4),y==null){var S=m&&m.constructor;w?y=x?new S:[]:u(m)?y=c(S)?e(r(m)):{}:y={}}return(w?t:n)(m,function(C,A,O){return g(y,C,A,O)}),y}return Ib=d,Ib}var Pb,aN;function nX(){if(aN)return Pb;aN=1;var t=Sl(),e=Bu(),n=Wt(),i=t?t.isConcatSpreadable:void 0;function r(s){return n(s)||e(s)||!!(i&&s&&s[i])}return Pb=r,Pb}var Hb,oN;function Q2(){if(oN)return Hb;oN=1;var t=H2(),e=nX();function n(i,r,s,o,c){var u=-1,h=i.length;for(s||(s=e),c||(c=[]);++u<h;){var d=i[u];r>0&&s(d)?r>1?n(d,r-1,s,o,c):t(c,d):o||(c[c.length]=d)}return c}return Hb=n,Hb}var Ub,lN;function iX(){if(lN)return Ub;lN=1;function t(e,n,i){switch(i.length){case 0:return e.call(n);case 1:return e.call(n,i[0]);case 2:return e.call(n,i[0],i[1]);case 3:return e.call(n,i[0],i[1],i[2])}return e.apply(n,i)}return Ub=t,Ub}var Vb,cN;function O8(){if(cN)return Vb;cN=1;var t=iX(),e=Math.max;function n(i,r,s){return r=e(r===void 0?i.length-1:r,0),function(){for(var o=arguments,c=-1,u=e(o.length-r,0),h=Array(u);++c<u;)h[c]=o[r+c];c=-1;for(var d=Array(r+1);++c<r;)d[c]=o[c];return d[r]=s(h),t(i,this,d)}}return Vb=n,Vb}var Fb,uN;function rX(){if(uN)return Fb;uN=1;var t=V2(),e=Gz(),n=Wa(),i=e?function(r,s){return e(r,"toString",{configurable:!0,enumerable:!1,value:t(s),writable:!0})}:n;return Fb=i,Fb}var $b,fN;function sX(){if(fN)return $b;fN=1;var t=800,e=16,n=Date.now;function i(r){var s=0,o=0;return function(){var c=n(),u=e-(c-o);if(o=c,u>0){if(++s>=t)return arguments[0]}else s=0;return r.apply(void 0,arguments)}}return $b=i,$b}var Gb,hN;function E8(){if(hN)return Gb;hN=1;var t=rX(),e=sX(),n=e(t);return Gb=n,Gb}var Yb,dN;function Np(){if(dN)return Yb;dN=1;var t=Wa(),e=O8(),n=E8();function i(r,s){return n(e(r,s,t),r+"")}return Yb=i,Yb}var Qb,pN;function T8(){if(pN)return Qb;pN=1;function t(e,n,i,r){for(var s=e.length,o=i+(r?1:-1);r?o--:++o<s;)if(n(e[o],o,e))return o;return-1}return Qb=t,Qb}var Xb,mN;function aX(){if(mN)return Xb;mN=1;function t(e){return e!==e}return Xb=t,Xb}var Wb,gN;function oX(){if(gN)return Wb;gN=1;function t(e,n,i){for(var r=i-1,s=e.length;++r<s;)if(e[r]===n)return r;return-1}return Wb=t,Wb}var Kb,yN;function lX(){if(yN)return Kb;yN=1;var t=T8(),e=aX(),n=oX();function i(r,s,o){return s===s?n(r,s,o):t(r,e,o)}return Kb=i,Kb}var Zb,vN;function cX(){if(vN)return Zb;vN=1;var t=lX();function e(n,i){var r=n==null?0:n.length;return!!r&&t(n,i,0)>-1}return Zb=e,Zb}var Jb,bN;function uX(){if(bN)return Jb;bN=1;function t(e,n,i){for(var r=-1,s=e==null?0:e.length;++r<s;)if(i(n,e[r]))return!0;return!1}return Jb=t,Jb}var ex,xN;function fX(){if(xN)return ex;xN=1;function t(){}return ex=t,ex}var tx,wN;function hX(){if(wN)return tx;wN=1;var t=n8(),e=fX(),n=G2(),i=1/0,r=t&&1/n(new t([,-0]))[1]==i?function(s){return new t(s)}:e;return tx=r,tx}var nx,SN;function dX(){if(SN)return nx;SN=1;var t=f8(),e=cX(),n=uX(),i=h8(),r=hX(),s=G2(),o=200;function c(u,h,d){var m=-1,g=e,y=u.length,x=!0,w=[],S=w;if(d)x=!1,g=n;else if(y>=o){var C=h?null:r(u);if(C)return s(C);x=!1,g=i,S=new t}else S=h?[]:w;e:for(;++m<y;){var A=u[m],O=h?h(A):A;if(A=d||A!==0?A:0,x&&O===O){for(var E=S.length;E--;)if(S[E]===O)continue e;h&&S.push(O),w.push(A)}else g(S,O,d)||(S!==w&&S.push(O),w.push(A))}return w}return nx=c,nx}var ix,CN;function M8(){if(CN)return ix;CN=1;var t=ts(),e=hr();function n(i){return e(i)&&t(i)}return ix=n,ix}var rx,kN;function pX(){if(kN)return rx;kN=1;var t=Q2(),e=Np(),n=dX(),i=M8(),r=e(function(s){return n(t(s,1,i,!0))});return rx=r,rx}var sx,AN;function mX(){if(AN)return sx;AN=1;var t=Tp();function e(n,i){return t(i,function(r){return n[r]})}return sx=e,sx}var ax,_N;function R8(){if(_N)return ax;_N=1;var t=mX(),e=Js();function n(i){return i==null?[]:t(i,e(i))}return ax=n,ax}var ox,ON;function Ei(){if(ON)return ox;ON=1;var t;if(typeof D2=="function")try{t={clone:SQ(),constant:V2(),each:u8(),filter:w8(),has:S8(),isArray:Wt(),isEmpty:GQ(),isFunction:Lu(),isUndefined:C8(),keys:Js(),map:A8(),reduce:_8(),size:eX(),transform:tX(),union:pX(),values:R8()}}catch{}return t||(t=window._),ox=t,ox}var lx,EN;function X2(){if(EN)return lx;EN=1;var t=Ei();lx=r;var e="\0",n="\0",i="";function r(d){this._isDirected=t.has(d,"directed")?d.directed:!0,this._isMultigraph=t.has(d,"multigraph")?d.multigraph:!1,this._isCompound=t.has(d,"compound")?d.compound:!1,this._label=void 0,this._defaultNodeLabelFn=t.constant(void 0),this._defaultEdgeLabelFn=t.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[n]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}r.prototype._nodeCount=0,r.prototype._edgeCount=0,r.prototype.isDirected=function(){return this._isDirected},r.prototype.isMultigraph=function(){return this._isMultigraph},r.prototype.isCompound=function(){return this._isCompound},r.prototype.setGraph=function(d){return this._label=d,this},r.prototype.graph=function(){return this._label},r.prototype.setDefaultNodeLabel=function(d){return t.isFunction(d)||(d=t.constant(d)),this._defaultNodeLabelFn=d,this},r.prototype.nodeCount=function(){return this._nodeCount},r.prototype.nodes=function(){return t.keys(this._nodes)},r.prototype.sources=function(){var d=this;return t.filter(this.nodes(),function(m){return t.isEmpty(d._in[m])})},r.prototype.sinks=function(){var d=this;return t.filter(this.nodes(),function(m){return t.isEmpty(d._out[m])})},r.prototype.setNodes=function(d,m){var g=arguments,y=this;return t.each(d,function(x){g.length>1?y.setNode(x,m):y.setNode(x)}),this},r.prototype.setNode=function(d,m){return t.has(this._nodes,d)?(arguments.length>1&&(this._nodes[d]=m),this):(this._nodes[d]=arguments.length>1?m:this._defaultNodeLabelFn(d),this._isCompound&&(this._parent[d]=n,this._children[d]={},this._children[n][d]=!0),this._in[d]={},this._preds[d]={},this._out[d]={},this._sucs[d]={},++this._nodeCount,this)},r.prototype.node=function(d){return this._nodes[d]},r.prototype.hasNode=function(d){return t.has(this._nodes,d)},r.prototype.removeNode=function(d){var m=this;if(t.has(this._nodes,d)){var g=function(y){m.removeEdge(m._edgeObjs[y])};delete this._nodes[d],this._isCompound&&(this._removeFromParentsChildList(d),delete this._parent[d],t.each(this.children(d),function(y){m.setParent(y)}),delete this._children[d]),t.each(t.keys(this._in[d]),g),delete this._in[d],delete this._preds[d],t.each(t.keys(this._out[d]),g),delete this._out[d],delete this._sucs[d],--this._nodeCount}return this},r.prototype.setParent=function(d,m){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(t.isUndefined(m))m=n;else{m+="";for(var g=m;!t.isUndefined(g);g=this.parent(g))if(g===d)throw new Error("Setting "+m+" as parent of "+d+" would create a cycle");this.setNode(m)}return this.setNode(d),this._removeFromParentsChildList(d),this._parent[d]=m,this._children[m][d]=!0,this},r.prototype._removeFromParentsChildList=function(d){delete this._children[this._parent[d]][d]},r.prototype.parent=function(d){if(this._isCompound){var m=this._parent[d];if(m!==n)return m}},r.prototype.children=function(d){if(t.isUndefined(d)&&(d=n),this._isCompound){var m=this._children[d];if(m)return t.keys(m)}else{if(d===n)return this.nodes();if(this.hasNode(d))return[]}},r.prototype.predecessors=function(d){var m=this._preds[d];if(m)return t.keys(m)},r.prototype.successors=function(d){var m=this._sucs[d];if(m)return t.keys(m)},r.prototype.neighbors=function(d){var m=this.predecessors(d);if(m)return t.union(m,this.successors(d))},r.prototype.isLeaf=function(d){var m;return this.isDirected()?m=this.successors(d):m=this.neighbors(d),m.length===0},r.prototype.filterNodes=function(d){var m=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});m.setGraph(this.graph());var g=this;t.each(this._nodes,function(w,S){d(S)&&m.setNode(S,w)}),t.each(this._edgeObjs,function(w){m.hasNode(w.v)&&m.hasNode(w.w)&&m.setEdge(w,g.edge(w))});var y={};function x(w){var S=g.parent(w);return S===void 0||m.hasNode(S)?(y[w]=S,S):S in y?y[S]:x(S)}return this._isCompound&&t.each(m.nodes(),function(w){m.setParent(w,x(w))}),m},r.prototype.setDefaultEdgeLabel=function(d){return t.isFunction(d)||(d=t.constant(d)),this._defaultEdgeLabelFn=d,this},r.prototype.edgeCount=function(){return this._edgeCount},r.prototype.edges=function(){return t.values(this._edgeObjs)},r.prototype.setPath=function(d,m){var g=this,y=arguments;return t.reduce(d,function(x,w){return y.length>1?g.setEdge(x,w,m):g.setEdge(x,w),w}),this},r.prototype.setEdge=function(){var d,m,g,y,x=!1,w=arguments[0];typeof w=="object"&&w!==null&&"v"in w?(d=w.v,m=w.w,g=w.name,arguments.length===2&&(y=arguments[1],x=!0)):(d=w,m=arguments[1],g=arguments[3],arguments.length>2&&(y=arguments[2],x=!0)),d=""+d,m=""+m,t.isUndefined(g)||(g=""+g);var S=c(this._isDirected,d,m,g);if(t.has(this._edgeLabels,S))return x&&(this._edgeLabels[S]=y),this;if(!t.isUndefined(g)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(d),this.setNode(m),this._edgeLabels[S]=x?y:this._defaultEdgeLabelFn(d,m,g);var C=u(this._isDirected,d,m,g);return d=C.v,m=C.w,Object.freeze(C),this._edgeObjs[S]=C,s(this._preds[m],d),s(this._sucs[d],m),this._in[m][S]=C,this._out[d][S]=C,this._edgeCount++,this},r.prototype.edge=function(d,m,g){var y=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,d,m,g);return this._edgeLabels[y]},r.prototype.hasEdge=function(d,m,g){var y=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,d,m,g);return t.has(this._edgeLabels,y)},r.prototype.removeEdge=function(d,m,g){var y=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,d,m,g),x=this._edgeObjs[y];return x&&(d=x.v,m=x.w,delete this._edgeLabels[y],delete this._edgeObjs[y],o(this._preds[m],d),o(this._sucs[d],m),delete this._in[m][y],delete this._out[d][y],this._edgeCount--),this},r.prototype.inEdges=function(d,m){var g=this._in[d];if(g){var y=t.values(g);return m?t.filter(y,function(x){return x.v===m}):y}},r.prototype.outEdges=function(d,m){var g=this._out[d];if(g){var y=t.values(g);return m?t.filter(y,function(x){return x.w===m}):y}},r.prototype.nodeEdges=function(d,m){var g=this.inEdges(d,m);if(g)return g.concat(this.outEdges(d,m))};function s(d,m){d[m]?d[m]++:d[m]=1}function o(d,m){--d[m]||delete d[m]}function c(d,m,g,y){var x=""+m,w=""+g;if(!d&&x>w){var S=x;x=w,w=S}return x+i+w+i+(t.isUndefined(y)?e:y)}function u(d,m,g,y){var x=""+m,w=""+g;if(!d&&x>w){var S=x;x=w,w=S}var C={v:x,w};return y&&(C.name=y),C}function h(d,m){return c(d,m.v,m.w,m.name)}return lx}var cx,TN;function gX(){return TN||(TN=1,cx="2.1.8"),cx}var ux,MN;function yX(){return MN||(MN=1,ux={Graph:X2(),version:gX()}),ux}var fx,RN;function vX(){if(RN)return fx;RN=1;var t=Ei(),e=X2();fx={write:n,read:s};function n(o){var c={options:{directed:o.isDirected(),multigraph:o.isMultigraph(),compound:o.isCompound()},nodes:i(o),edges:r(o)};return t.isUndefined(o.graph())||(c.value=t.clone(o.graph())),c}function i(o){return t.map(o.nodes(),function(c){var u=o.node(c),h=o.parent(c),d={v:c};return t.isUndefined(u)||(d.value=u),t.isUndefined(h)||(d.parent=h),d})}function r(o){return t.map(o.edges(),function(c){var u=o.edge(c),h={v:c.v,w:c.w};return t.isUndefined(c.name)||(h.name=c.name),t.isUndefined(u)||(h.value=u),h})}function s(o){var c=new e(o.options).setGraph(o.value);return t.each(o.nodes,function(u){c.setNode(u.v,u.value),u.parent&&c.setParent(u.v,u.parent)}),t.each(o.edges,function(u){c.setEdge({v:u.v,w:u.w,name:u.name},u.value)}),c}return fx}var hx,NN;function bX(){if(NN)return hx;NN=1;var t=Ei();hx=e;function e(n){var i={},r=[],s;function o(c){t.has(i,c)||(i[c]=!0,s.push(c),t.each(n.successors(c),o),t.each(n.predecessors(c),o))}return t.each(n.nodes(),function(c){s=[],o(c),s.length&&r.push(s)}),r}return hx}var dx,DN;function N8(){if(DN)return dx;DN=1;var t=Ei();dx=e;function e(){this._arr=[],this._keyIndices={}}return e.prototype.size=function(){return this._arr.length},e.prototype.keys=function(){return this._arr.map(function(n){return n.key})},e.prototype.has=function(n){return t.has(this._keyIndices,n)},e.prototype.priority=function(n){var i=this._keyIndices[n];if(i!==void 0)return this._arr[i].priority},e.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},e.prototype.add=function(n,i){var r=this._keyIndices;if(n=String(n),!t.has(r,n)){var s=this._arr,o=s.length;return r[n]=o,s.push({key:n,priority:i}),this._decrease(o),!0}return!1},e.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var n=this._arr.pop();return delete this._keyIndices[n.key],this._heapify(0),n.key},e.prototype.decrease=function(n,i){var r=this._keyIndices[n];if(i>this._arr[r].priority)throw new Error("New priority is greater than current priority. Key: "+n+" Old: "+this._arr[r].priority+" New: "+i);this._arr[r].priority=i,this._decrease(r)},e.prototype._heapify=function(n){var i=this._arr,r=2*n,s=r+1,o=n;r<i.length&&(o=i[r].priority<i[o].priority?r:o,s<i.length&&(o=i[s].priority<i[o].priority?s:o),o!==n&&(this._swap(n,o),this._heapify(o)))},e.prototype._decrease=function(n){for(var i=this._arr,r=i[n].priority,s;n!==0&&(s=n>>1,!(i[s].priority<r));)this._swap(n,s),n=s},e.prototype._swap=function(n,i){var r=this._arr,s=this._keyIndices,o=r[n],c=r[i];r[n]=c,r[i]=o,s[c.key]=n,s[o.key]=i},dx}var px,LN;function D8(){if(LN)return px;LN=1;var t=Ei(),e=N8();px=i;var n=t.constant(1);function i(s,o,c,u){return r(s,String(o),c||n,u||function(h){return s.outEdges(h)})}function r(s,o,c,u){var h={},d=new e,m,g,y=function(x){var w=x.v!==m?x.v:x.w,S=h[w],C=c(x),A=g.distance+C;if(C<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+x+" Weight: "+C);A<S.distance&&(S.distance=A,S.predecessor=m,d.decrease(w,A))};for(s.nodes().forEach(function(x){var w=x===o?0:Number.POSITIVE_INFINITY;h[x]={distance:w},d.add(x,w)});d.size()>0&&(m=d.removeMin(),g=h[m],g.distance!==Number.POSITIVE_INFINITY);)u(m).forEach(y);return h}return px}var mx,zN;function xX(){if(zN)return mx;zN=1;var t=D8(),e=Ei();mx=n;function n(i,r,s){return e.transform(i.nodes(),function(o,c){o[c]=t(i,c,r,s)},{})}return mx}var gx,BN;function L8(){if(BN)return gx;BN=1;var t=Ei();gx=e;function e(n){var i=0,r=[],s={},o=[];function c(u){var h=s[u]={onStack:!0,lowlink:i,index:i++};if(r.push(u),n.successors(u).forEach(function(g){t.has(s,g)?s[g].onStack&&(h.lowlink=Math.min(h.lowlink,s[g].index)):(c(g),h.lowlink=Math.min(h.lowlink,s[g].lowlink))}),h.lowlink===h.index){var d=[],m;do m=r.pop(),s[m].onStack=!1,d.push(m);while(u!==m);o.push(d)}}return n.nodes().forEach(function(u){t.has(s,u)||c(u)}),o}return gx}var yx,qN;function wX(){if(qN)return yx;qN=1;var t=Ei(),e=L8();yx=n;function n(i){return t.filter(e(i),function(r){return r.length>1||r.length===1&&i.hasEdge(r[0],r[0])})}return yx}var vx,jN;function SX(){if(jN)return vx;jN=1;var t=Ei();vx=n;var e=t.constant(1);function n(r,s,o){return i(r,s||e,o||function(c){return r.outEdges(c)})}function i(r,s,o){var c={},u=r.nodes();return u.forEach(function(h){c[h]={},c[h][h]={distance:0},u.forEach(function(d){h!==d&&(c[h][d]={distance:Number.POSITIVE_INFINITY})}),o(h).forEach(function(d){var m=d.v===h?d.w:d.v,g=s(d);c[h][m]={distance:g,predecessor:h}})}),u.forEach(function(h){var d=c[h];u.forEach(function(m){var g=c[m];u.forEach(function(y){var x=g[h],w=d[y],S=g[y],C=x.distance+w.distance;C<S.distance&&(S.distance=C,S.predecessor=w.predecessor)})})}),c}return vx}var bx,IN;function z8(){if(IN)return bx;IN=1;var t=Ei();bx=e,e.CycleException=n;function e(i){var r={},s={},o=[];function c(u){if(t.has(s,u))throw new n;t.has(r,u)||(s[u]=!0,r[u]=!0,t.each(i.predecessors(u),c),delete s[u],o.push(u))}if(t.each(i.sinks(),c),t.size(r)!==i.nodeCount())throw new n;return o}function n(){}return n.prototype=new Error,bx}var xx,PN;function CX(){if(PN)return xx;PN=1;var t=z8();xx=e;function e(n){try{t(n)}catch(i){if(i instanceof t.CycleException)return!1;throw i}return!0}return xx}var wx,HN;function B8(){if(HN)return wx;HN=1;var t=Ei();wx=e;function e(i,r,s){t.isArray(r)||(r=[r]);var o=(i.isDirected()?i.successors:i.neighbors).bind(i),c=[],u={};return t.each(r,function(h){if(!i.hasNode(h))throw new Error("Graph does not have node: "+h);n(i,h,s==="post",u,o,c)}),c}function n(i,r,s,o,c,u){t.has(o,r)||(o[r]=!0,s||u.push(r),t.each(c(r),function(h){n(i,h,s,o,c,u)}),s&&u.push(r))}return wx}var Sx,UN;function kX(){if(UN)return Sx;UN=1;var t=B8();Sx=e;function e(n,i){return t(n,i,"post")}return Sx}var Cx,VN;function AX(){if(VN)return Cx;VN=1;var t=B8();Cx=e;function e(n,i){return t(n,i,"pre")}return Cx}var kx,FN;function _X(){if(FN)return kx;FN=1;var t=Ei(),e=X2(),n=N8();kx=i;function i(r,s){var o=new e,c={},u=new n,h;function d(g){var y=g.v===h?g.w:g.v,x=u.priority(y);if(x!==void 0){var w=s(g);w<x&&(c[y]=h,u.decrease(y,w))}}if(r.nodeCount()===0)return o;t.each(r.nodes(),function(g){u.add(g,Number.POSITIVE_INFINITY),o.setNode(g)}),u.decrease(r.nodes()[0],0);for(var m=!1;u.size()>0;){if(h=u.removeMin(),t.has(c,h))o.setEdge(h,c[h]);else{if(m)throw new Error("Input graph is not connected: "+r);m=!0}r.nodeEdges(h).forEach(d)}return o}return kx}var Ax,$N;function OX(){return $N||($N=1,Ax={components:bX(),dijkstra:D8(),dijkstraAll:xX(),findCycles:wX(),floydWarshall:SX(),isAcyclic:CX(),postorder:kX(),preorder:AX(),prim:_X(),tarjan:L8(),topsort:z8()}),Ax}var _x,GN;function EX(){if(GN)return _x;GN=1;var t=yX();return _x={Graph:t.Graph,json:vX(),alg:OX(),version:t.version},_x}var Ox,YN;function ji(){if(YN)return Ox;YN=1;var t;if(typeof D2=="function")try{t=EX()}catch{}return t||(t=window.graphlib),Ox=t,Ox}var Ex,QN;function TX(){if(QN)return Ex;QN=1;var t=o8(),e=1,n=4;function i(r){return t(r,e|n)}return Ex=i,Ex}var Tx,XN;function Dp(){if(XN)return Tx;XN=1;var t=wl(),e=ts(),n=kp(),i=Oi();function r(s,o,c){if(!i(c))return!1;var u=typeof o;return(u=="number"?e(c)&&n(o,c.length):u=="string"&&o in c)?t(c[o],s):!1}return Tx=r,Tx}var Mx,WN;function MX(){if(WN)return Mx;WN=1;var t=Np(),e=wl(),n=Dp(),i=Xa(),r=Object.prototype,s=r.hasOwnProperty,o=t(function(c,u){c=Object(c);var h=-1,d=u.length,m=d>2?u[2]:void 0;for(m&&n(u[0],u[1],m)&&(d=1);++h<d;)for(var g=u[h],y=i(g),x=-1,w=y.length;++x<w;){var S=y[x],C=c[S];(C===void 0||e(C,r[S])&&!s.call(c,S))&&(c[S]=g[S])}return c});return Mx=o,Mx}var Rx,KN;function RX(){if(KN)return Rx;KN=1;var t=ns(),e=ts(),n=Js();function i(r){return function(s,o,c){var u=Object(s);if(!e(s)){var h=t(o,3);s=n(s),o=function(m){return h(u[m],m,u)}}var d=r(s,o,c);return d>-1?u[h?s[d]:d]:void 0}}return Rx=i,Rx}var Nx,ZN;function NX(){if(ZN)return Nx;ZN=1;var t=/\s/;function e(n){for(var i=n.length;i--&&t.test(n.charAt(i)););return i}return Nx=e,Nx}var Dx,JN;function DX(){if(JN)return Dx;JN=1;var t=NX(),e=/^\s+/;function n(i){return i&&i.slice(0,t(i)+1).replace(e,"")}return Dx=n,Dx}var Lx,eD;function LX(){if(eD)return Lx;eD=1;var t=DX(),e=Oi(),n=Al(),i=NaN,r=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,o=/^0o[0-7]+$/i,c=parseInt;function u(h){if(typeof h=="number")return h;if(n(h))return i;if(e(h)){var d=typeof h.valueOf=="function"?h.valueOf():h;h=e(d)?d+"":d}if(typeof h!="string")return h===0?h:+h;h=t(h);var m=s.test(h);return m||o.test(h)?c(h.slice(2),m?2:8):r.test(h)?i:+h}return Lx=u,Lx}var zx,tD;function q8(){if(tD)return zx;tD=1;var t=LX(),e=1/0,n=17976931348623157e292;function i(r){if(!r)return r===0?r:0;if(r=t(r),r===e||r===-e){var s=r<0?-1:1;return s*n}return r===r?r:0}return zx=i,zx}var Bx,nD;function zX(){if(nD)return Bx;nD=1;var t=q8();function e(n){var i=t(n),r=i%1;return i===i?r?i-r:i:0}return Bx=e,Bx}var qx,iD;function BX(){if(iD)return qx;iD=1;var t=T8(),e=ns(),n=zX(),i=Math.max;function r(s,o,c){var u=s==null?0:s.length;if(!u)return-1;var h=c==null?0:n(c);return h<0&&(h=i(u+h,0)),t(s,e(o,3),h)}return qx=r,qx}var jx,rD;function qX(){if(rD)return jx;rD=1;var t=RX(),e=BX(),n=t(e);return jx=n,jx}var Ix,sD;function j8(){if(sD)return Ix;sD=1;var t=Q2();function e(n){var i=n==null?0:n.length;return i?t(n,1):[]}return Ix=e,Ix}var Px,aD;function jX(){if(aD)return Px;aD=1;var t=F2(),e=l8(),n=Xa();function i(r,s){return r==null?r:t(r,e(s),n)}return Px=i,Px}var Hx,oD;function IX(){if(oD)return Hx;oD=1;function t(e){var n=e==null?0:e.length;return n?e[n-1]:void 0}return Hx=t,Hx}var Ux,lD;function PX(){if(lD)return Ux;lD=1;var t=Sp(),e=$2(),n=ns();function i(r,s){var o={};return s=n(s,3),e(r,function(c,u,h){t(o,u,s(c,u,h))}),o}return Ux=i,Ux}var Vx,cD;function W2(){if(cD)return Vx;cD=1;var t=Al();function e(n,i,r){for(var s=-1,o=n.length;++s<o;){var c=n[s],u=i(c);if(u!=null&&(h===void 0?u===u&&!t(u):r(u,h)))var h=u,d=c}return d}return Vx=e,Vx}var Fx,uD;function HX(){if(uD)return Fx;uD=1;function t(e,n){return e>n}return Fx=t,Fx}var $x,fD;function UX(){if(fD)return $x;fD=1;var t=W2(),e=HX(),n=Wa();function i(r){return r&&r.length?t(r,n,e):void 0}return $x=i,$x}var Gx,hD;function I8(){if(hD)return Gx;hD=1;var t=Sp(),e=wl();function n(i,r,s){(s!==void 0&&!e(i[r],s)||s===void 0&&!(r in i))&&t(i,r,s)}return Gx=n,Gx}var Yx,dD;function VX(){if(dD)return Yx;dD=1;var t=Ya(),e=Op(),n=hr(),i="[object Object]",r=Function.prototype,s=Object.prototype,o=r.toString,c=s.hasOwnProperty,u=o.call(Object);function h(d){if(!n(d)||t(d)!=i)return!1;var m=e(d);if(m===null)return!0;var g=c.call(m,"constructor")&&m.constructor;return typeof g=="function"&&g instanceof g&&o.call(g)==u}return Yx=h,Yx}var Qx,pD;function P8(){if(pD)return Qx;pD=1;function t(e,n){if(!(n==="constructor"&&typeof e[n]=="function")&&n!="__proto__")return e[n]}return Qx=t,Qx}var Xx,mD;function FX(){if(mD)return Xx;mD=1;var t=zu(),e=Xa();function n(i){return t(i,e(i))}return Xx=n,Xx}var Wx,gD;function $X(){if(gD)return Wx;gD=1;var t=I8(),e=Xz(),n=r8(),i=Wz(),r=a8(),s=Bu(),o=Wt(),c=M8(),u=Cl(),h=Lu(),d=Oi(),m=VX(),g=qu(),y=P8(),x=FX();function w(S,C,A,O,E,T,M){var R=y(S,A),z=y(C,A),q=M.get(z);if(q){t(S,A,q);return}var U=T?T(R,z,A+"",S,C,M):void 0,P=U===void 0;if(P){var $=o(z),K=!$&&u(z),L=!$&&!K&&g(z);U=z,$||K||L?o(R)?U=R:c(R)?U=i(R):K?(P=!1,U=e(z,!0)):L?(P=!1,U=n(z,!0)):U=[]:m(z)||s(z)?(U=R,s(R)?U=x(R):(!d(R)||h(R))&&(U=r(z))):P=!1}P&&(M.set(z,U),E(U,z,O,T,M),M.delete(z)),t(S,A,U)}return Wx=w,Wx}var Kx,yD;function GX(){if(yD)return Kx;yD=1;var t=wp(),e=I8(),n=F2(),i=$X(),r=Oi(),s=Xa(),o=P8();function c(u,h,d,m,g){u!==h&&n(h,function(y,x){if(g||(g=new t),r(y))i(u,h,x,d,c,m,g);else{var w=m?m(o(u,x),y,x+"",u,h,g):void 0;w===void 0&&(w=y),e(u,x,w)}},s)}return Kx=c,Kx}var Zx,vD;function YX(){if(vD)return Zx;vD=1;var t=Np(),e=Dp();function n(i){return t(function(r,s){var o=-1,c=s.length,u=c>1?s[c-1]:void 0,h=c>2?s[2]:void 0;for(u=i.length>3&&typeof u=="function"?(c--,u):void 0,h&&e(s[0],s[1],h)&&(u=c<3?void 0:u,c=1),r=Object(r);++o<c;){var d=s[o];d&&i(r,d,o,u)}return r})}return Zx=n,Zx}var Jx,bD;function QX(){if(bD)return Jx;bD=1;var t=GX(),e=YX(),n=e(function(i,r,s){t(i,r,s)});return Jx=n,Jx}var e1,xD;function H8(){if(xD)return e1;xD=1;function t(e,n){return e<n}return e1=t,e1}var t1,wD;function XX(){if(wD)return t1;wD=1;var t=W2(),e=H8(),n=Wa();function i(r){return r&&r.length?t(r,n,e):void 0}return t1=i,t1}var n1,SD;function WX(){if(SD)return n1;SD=1;var t=W2(),e=ns(),n=H8();function i(r,s){return r&&r.length?t(r,e(s,2),n):void 0}return n1=i,n1}var i1,CD;function KX(){if(CD)return i1;CD=1;var t=Hi(),e=function(){return t.Date.now()};return i1=e,i1}var r1,kD;function ZX(){if(kD)return r1;kD=1;var t=Cp(),e=Mp(),n=kp(),i=Oi(),r=ju();function s(o,c,u,h){if(!i(o))return o;c=e(c,o);for(var d=-1,m=c.length,g=m-1,y=o;y!=null&&++d<m;){var x=r(c[d]),w=u;if(x==="__proto__"||x==="constructor"||x==="prototype")return o;if(d!=g){var S=y[x];w=h?h(S,x,y):void 0,w===void 0&&(w=i(S)?S:n(c[d+1])?[]:{})}t(y,x,w),y=y[x]}return o}return r1=s,r1}var s1,AD;function JX(){if(AD)return s1;AD=1;var t=Rp(),e=ZX(),n=Mp();function i(r,s,o){for(var c=-1,u=s.length,h={};++c<u;){var d=s[c],m=t(r,d);o(m,d)&&e(h,n(d,r),m)}return h}return s1=i,s1}var a1,_D;function eW(){if(_D)return a1;_D=1;var t=JX(),e=b8();function n(i,r){return t(i,r,function(s,o){return e(i,o)})}return a1=n,a1}var o1,OD;function tW(){if(OD)return o1;OD=1;var t=j8(),e=O8(),n=E8();function i(r){return n(e(r,void 0,t),r+"")}return o1=i,o1}var l1,ED;function nW(){if(ED)return l1;ED=1;var t=eW(),e=tW(),n=e(function(i,r){return i==null?{}:t(i,r)});return l1=n,l1}var c1,TD;function iW(){if(TD)return c1;TD=1;var t=Math.ceil,e=Math.max;function n(i,r,s,o){for(var c=-1,u=e(t((r-i)/(s||1)),0),h=Array(u);u--;)h[o?u:++c]=i,i+=s;return h}return c1=n,c1}var u1,MD;function rW(){if(MD)return u1;MD=1;var t=iW(),e=Dp(),n=q8();function i(r){return function(s,o,c){return c&&typeof c!="number"&&e(s,o,c)&&(o=c=void 0),s=n(s),o===void 0?(o=s,s=0):o=n(o),c=c===void 0?s<o?1:-1:n(c),t(s,o,c,r)}}return u1=i,u1}var f1,RD;function sW(){if(RD)return f1;RD=1;var t=rW(),e=t();return f1=e,f1}var h1,ND;function aW(){if(ND)return h1;ND=1;function t(e,n){var i=e.length;for(e.sort(n);i--;)e[i]=e[i].value;return e}return h1=t,h1}var d1,DD;function oW(){if(DD)return d1;DD=1;var t=Al();function e(n,i){if(n!==i){var r=n!==void 0,s=n===null,o=n===n,c=t(n),u=i!==void 0,h=i===null,d=i===i,m=t(i);if(!h&&!m&&!c&&n>i||c&&u&&d&&!h&&!m||s&&u&&d||!r&&d||!o)return 1;if(!s&&!c&&!m&&n<i||m&&r&&o&&!s&&!c||h&&r&&o||!u&&o||!d)return-1}return 0}return d1=e,d1}var p1,LD;function lW(){if(LD)return p1;LD=1;var t=oW();function e(n,i,r){for(var s=-1,o=n.criteria,c=i.criteria,u=o.length,h=r.length;++s<u;){var d=t(o[s],c[s]);if(d){if(s>=h)return d;var m=r[s];return d*(m=="desc"?-1:1)}}return n.index-i.index}return p1=e,p1}var m1,zD;function cW(){if(zD)return m1;zD=1;var t=Tp(),e=Rp(),n=ns(),i=k8(),r=aW(),s=Ap(),o=lW(),c=Wa(),u=Wt();function h(d,m,g){m.length?m=t(m,function(w){return u(w)?function(S){return e(S,w.length===1?w[0]:w)}:w}):m=[c];var y=-1;m=t(m,s(n));var x=i(d,function(w,S,C){var A=t(m,function(O){return O(w)});return{criteria:A,index:++y,value:w}});return r(x,function(w,S){return o(w,S,g)})}return m1=h,m1}var g1,BD;function uW(){if(BD)return g1;BD=1;var t=Q2(),e=cW(),n=Np(),i=Dp(),r=n(function(s,o){if(s==null)return[];var c=o.length;return c>1&&i(s,o[0],o[1])?o=[]:c>2&&i(o[0],o[1],o[2])&&(o=[o[0]]),e(s,t(o,1),[])});return g1=r,g1}var y1,qD;function fW(){if(qD)return y1;qD=1;var t=y8(),e=0;function n(i){var r=++e;return t(i)+r}return y1=n,y1}var v1,jD;function hW(){if(jD)return v1;jD=1;function t(e,n,i){for(var r=-1,s=e.length,o=n.length,c={};++r<s;){var u=r<o?n[r]:void 0;i(c,e[r],u)}return c}return v1=t,v1}var b1,ID;function dW(){if(ID)return b1;ID=1;var t=Cp(),e=hW();function n(i,r){return e(i||[],r||[],t)}return b1=n,b1}var x1,PD;function Ot(){if(PD)return x1;PD=1;var t;if(typeof D2=="function")try{t={cloneDeep:TX(),constant:V2(),defaults:MX(),each:u8(),filter:w8(),find:qX(),flatten:j8(),forEach:c8(),forIn:jX(),has:S8(),isUndefined:C8(),last:IX(),map:A8(),mapValues:PX(),max:UX(),merge:QX(),min:XX(),minBy:WX(),now:KX(),pick:nW(),range:sW(),reduce:_8(),sortBy:uW(),uniqueId:fW(),values:R8(),zipObject:dW()}}catch{}return t||(t=window._),x1=t,x1}var w1,HD;function pW(){if(HD)return w1;HD=1,w1=t;function t(){var i={};i._next=i._prev=i,this._sentinel=i}t.prototype.dequeue=function(){var i=this._sentinel,r=i._prev;if(r!==i)return e(r),r},t.prototype.enqueue=function(i){var r=this._sentinel;i._prev&&i._next&&e(i),i._next=r._next,r._next._prev=i,r._next=i,i._prev=r},t.prototype.toString=function(){for(var i=[],r=this._sentinel,s=r._prev;s!==r;)i.push(JSON.stringify(s,n)),s=s._prev;return"["+i.join(", ")+"]"};function e(i){i._prev._next=i._next,i._next._prev=i._prev,delete i._next,delete i._prev}function n(i,r){if(i!=="_next"&&i!=="_prev")return r}return w1}var S1,UD;function mW(){if(UD)return S1;UD=1;var t=Ot(),e=ji().Graph,n=pW();S1=r;var i=t.constant(1);function r(h,d){if(h.nodeCount()<=1)return[];var m=c(h,d||i),g=s(m.graph,m.buckets,m.zeroIdx);return t.flatten(t.map(g,function(y){return h.outEdges(y.v,y.w)}),!0)}function s(h,d,m){for(var g=[],y=d[d.length-1],x=d[0],w;h.nodeCount();){for(;w=x.dequeue();)o(h,d,m,w);for(;w=y.dequeue();)o(h,d,m,w);if(h.nodeCount()){for(var S=d.length-2;S>0;--S)if(w=d[S].dequeue(),w){g=g.concat(o(h,d,m,w,!0));break}}}return g}function o(h,d,m,g,y){var x=y?[]:void 0;return t.forEach(h.inEdges(g.v),function(w){var S=h.edge(w),C=h.node(w.v);y&&x.push({v:w.v,w:w.w}),C.out-=S,u(d,m,C)}),t.forEach(h.outEdges(g.v),function(w){var S=h.edge(w),C=w.w,A=h.node(C);A.in-=S,u(d,m,A)}),h.removeNode(g.v),x}function c(h,d){var m=new e,g=0,y=0;t.forEach(h.nodes(),function(S){m.setNode(S,{v:S,in:0,out:0})}),t.forEach(h.edges(),function(S){var C=m.edge(S.v,S.w)||0,A=d(S),O=C+A;m.setEdge(S.v,S.w,O),y=Math.max(y,m.node(S.v).out+=A),g=Math.max(g,m.node(S.w).in+=A)});var x=t.range(y+g+3).map(function(){return new n}),w=g+1;return t.forEach(m.nodes(),function(S){u(x,w,m.node(S))}),{graph:m,buckets:x,zeroIdx:w}}function u(h,d,m){m.out?m.in?h[m.out-m.in+d].enqueue(m):h[h.length-1].enqueue(m):h[0].enqueue(m)}return S1}var C1,VD;function gW(){if(VD)return C1;VD=1;var t=Ot(),e=mW();C1={run:n,undo:r};function n(s){var o=s.graph().acyclicer==="greedy"?e(s,c(s)):i(s);t.forEach(o,function(u){var h=s.edge(u);s.removeEdge(u),h.forwardName=u.name,h.reversed=!0,s.setEdge(u.w,u.v,h,t.uniqueId("rev"))});function c(u){return function(h){return u.edge(h).weight}}}function i(s){var o=[],c={},u={};function h(d){t.has(u,d)||(u[d]=!0,c[d]=!0,t.forEach(s.outEdges(d),function(m){t.has(c,m.w)?o.push(m):h(m.w)}),delete c[d])}return t.forEach(s.nodes(),h),o}function r(s){t.forEach(s.edges(),function(o){var c=s.edge(o);if(c.reversed){s.removeEdge(o);var u=c.forwardName;delete c.reversed,delete c.forwardName,s.setEdge(o.w,o.v,c,u)}})}return C1}var k1,FD;function Gn(){if(FD)return k1;FD=1;var t=Ot(),e=ji().Graph;k1={addDummyNode:n,simplify:i,asNonCompoundGraph:r,successorWeights:s,predecessorWeights:o,intersectRect:c,buildLayerMatrix:u,normalizeRanks:h,removeEmptyRanks:d,addBorderNode:m,maxRank:g,partition:y,time:x,notime:w};function n(S,C,A,O){var E;do E=t.uniqueId(O);while(S.hasNode(E));return A.dummy=C,S.setNode(E,A),E}function i(S){var C=new e().setGraph(S.graph());return t.forEach(S.nodes(),function(A){C.setNode(A,S.node(A))}),t.forEach(S.edges(),function(A){var O=C.edge(A.v,A.w)||{weight:0,minlen:1},E=S.edge(A);C.setEdge(A.v,A.w,{weight:O.weight+E.weight,minlen:Math.max(O.minlen,E.minlen)})}),C}function r(S){var C=new e({multigraph:S.isMultigraph()}).setGraph(S.graph());return t.forEach(S.nodes(),function(A){S.children(A).length||C.setNode(A,S.node(A))}),t.forEach(S.edges(),function(A){C.setEdge(A,S.edge(A))}),C}function s(S){var C=t.map(S.nodes(),function(A){var O={};return t.forEach(S.outEdges(A),function(E){O[E.w]=(O[E.w]||0)+S.edge(E).weight}),O});return t.zipObject(S.nodes(),C)}function o(S){var C=t.map(S.nodes(),function(A){var O={};return t.forEach(S.inEdges(A),function(E){O[E.v]=(O[E.v]||0)+S.edge(E).weight}),O});return t.zipObject(S.nodes(),C)}function c(S,C){var A=S.x,O=S.y,E=C.x-A,T=C.y-O,M=S.width/2,R=S.height/2;if(!E&&!T)throw new Error("Not possible to find intersection inside of the rectangle");var z,q;return Math.abs(T)*M>Math.abs(E)*R?(T<0&&(R=-R),z=R*E/T,q=R):(E<0&&(M=-M),z=M,q=M*T/E),{x:A+z,y:O+q}}function u(S){var C=t.map(t.range(g(S)+1),function(){return[]});return t.forEach(S.nodes(),function(A){var O=S.node(A),E=O.rank;t.isUndefined(E)||(C[E][O.order]=A)}),C}function h(S){var C=t.min(t.map(S.nodes(),function(A){return S.node(A).rank}));t.forEach(S.nodes(),function(A){var O=S.node(A);t.has(O,"rank")&&(O.rank-=C)})}function d(S){var C=t.min(t.map(S.nodes(),function(T){return S.node(T).rank})),A=[];t.forEach(S.nodes(),function(T){var M=S.node(T).rank-C;A[M]||(A[M]=[]),A[M].push(T)});var O=0,E=S.graph().nodeRankFactor;t.forEach(A,function(T,M){t.isUndefined(T)&&M%E!==0?--O:O&&t.forEach(T,function(R){S.node(R).rank+=O})})}function m(S,C,A,O){var E={width:0,height:0};return arguments.length>=4&&(E.rank=A,E.order=O),n(S,"border",E,C)}function g(S){return t.max(t.map(S.nodes(),function(C){var A=S.node(C).rank;if(!t.isUndefined(A))return A}))}function y(S,C){var A={lhs:[],rhs:[]};return t.forEach(S,function(O){C(O)?A.lhs.push(O):A.rhs.push(O)}),A}function x(S,C){var A=t.now();try{return C()}finally{console.log(S+" time: "+(t.now()-A)+"ms")}}function w(S,C){return C()}return k1}var A1,$D;function yW(){if($D)return A1;$D=1;var t=Ot(),e=Gn();A1={run:n,undo:r};function n(s){s.graph().dummyChains=[],t.forEach(s.edges(),function(o){i(s,o)})}function i(s,o){var c=o.v,u=s.node(c).rank,h=o.w,d=s.node(h).rank,m=o.name,g=s.edge(o),y=g.labelRank;if(d!==u+1){s.removeEdge(o);var x,w,S;for(S=0,++u;u<d;++S,++u)g.points=[],w={width:0,height:0,edgeLabel:g,edgeObj:o,rank:u},x=e.addDummyNode(s,"edge",w,"_d"),u===y&&(w.width=g.width,w.height=g.height,w.dummy="edge-label",w.labelpos=g.labelpos),s.setEdge(c,x,{weight:g.weight},m),S===0&&s.graph().dummyChains.push(x),c=x;s.setEdge(c,h,{weight:g.weight},m)}}function r(s){t.forEach(s.graph().dummyChains,function(o){var c=s.node(o),u=c.edgeLabel,h;for(s.setEdge(c.edgeObj,u);c.dummy;)h=s.successors(o)[0],s.removeNode(o),u.points.push({x:c.x,y:c.y}),c.dummy==="edge-label"&&(u.x=c.x,u.y=c.y,u.width=c.width,u.height=c.height),o=h,c=s.node(o)})}return A1}var _1,GD;function Td(){if(GD)return _1;GD=1;var t=Ot();_1={longestPath:e,slack:n};function e(i){var r={};function s(o){var c=i.node(o);if(t.has(r,o))return c.rank;r[o]=!0;var u=t.min(t.map(i.outEdges(o),function(h){return s(h.w)-i.edge(h).minlen}));return(u===Number.POSITIVE_INFINITY||u===void 0||u===null)&&(u=0),c.rank=u}t.forEach(i.sources(),s)}function n(i,r){return i.node(r.w).rank-i.node(r.v).rank-i.edge(r).minlen}return _1}var O1,YD;function U8(){if(YD)return O1;YD=1;var t=Ot(),e=ji().Graph,n=Td().slack;O1=i;function i(c){var u=new e({directed:!1}),h=c.nodes()[0],d=c.nodeCount();u.setNode(h,{});for(var m,g;r(u,c)<d;)m=s(u,c),g=u.hasNode(m.v)?n(c,m):-n(c,m),o(u,c,g);return u}function r(c,u){function h(d){t.forEach(u.nodeEdges(d),function(m){var g=m.v,y=d===g?m.w:g;!c.hasNode(y)&&!n(u,m)&&(c.setNode(y,{}),c.setEdge(d,y,{}),h(y))})}return t.forEach(c.nodes(),h),c.nodeCount()}function s(c,u){return t.minBy(u.edges(),function(h){if(c.hasNode(h.v)!==c.hasNode(h.w))return n(u,h)})}function o(c,u,h){t.forEach(c.nodes(),function(d){u.node(d).rank+=h})}return O1}var E1,QD;function vW(){if(QD)return E1;QD=1;var t=Ot(),e=U8(),n=Td().slack,i=Td().longestPath,r=ji().alg.preorder,s=ji().alg.postorder,o=Gn().simplify;E1=c,c.initLowLimValues=m,c.initCutValues=u,c.calcCutValue=d,c.leaveEdge=y,c.enterEdge=x,c.exchangeEdges=w;function c(O){O=o(O),i(O);var E=e(O);m(E),u(E,O);for(var T,M;T=y(E);)M=x(E,O,T),w(E,O,T,M)}function u(O,E){var T=s(O,O.nodes());T=T.slice(0,T.length-1),t.forEach(T,function(M){h(O,E,M)})}function h(O,E,T){var M=O.node(T),R=M.parent;O.edge(T,R).cutvalue=d(O,E,T)}function d(O,E,T){var M=O.node(T),R=M.parent,z=!0,q=E.edge(T,R),U=0;return q||(z=!1,q=E.edge(R,T)),U=q.weight,t.forEach(E.nodeEdges(T),function(P){var $=P.v===T,K=$?P.w:P.v;if(K!==R){var L=$===z,Y=E.edge(P).weight;if(U+=L?Y:-Y,C(O,T,K)){var D=O.edge(T,K).cutvalue;U+=L?-D:D}}}),U}function m(O,E){arguments.length<2&&(E=O.nodes()[0]),g(O,{},1,E)}function g(O,E,T,M,R){var z=T,q=O.node(M);return E[M]=!0,t.forEach(O.neighbors(M),function(U){t.has(E,U)||(T=g(O,E,T,U,M))}),q.low=z,q.lim=T++,R?q.parent=R:delete q.parent,T}function y(O){return t.find(O.edges(),function(E){return O.edge(E).cutvalue<0})}function x(O,E,T){var M=T.v,R=T.w;E.hasEdge(M,R)||(M=T.w,R=T.v);var z=O.node(M),q=O.node(R),U=z,P=!1;z.lim>q.lim&&(U=q,P=!0);var $=t.filter(E.edges(),function(K){return P===A(O,O.node(K.v),U)&&P!==A(O,O.node(K.w),U)});return t.minBy($,function(K){return n(E,K)})}function w(O,E,T,M){var R=T.v,z=T.w;O.removeEdge(R,z),O.setEdge(M.v,M.w,{}),m(O),u(O,E),S(O,E)}function S(O,E){var T=t.find(O.nodes(),function(R){return!E.node(R).parent}),M=r(O,T);M=M.slice(1),t.forEach(M,function(R){var z=O.node(R).parent,q=E.edge(R,z),U=!1;q||(q=E.edge(z,R),U=!0),E.node(R).rank=E.node(z).rank+(U?q.minlen:-q.minlen)})}function C(O,E,T){return O.hasEdge(E,T)}function A(O,E,T){return T.low<=E.lim&&E.lim<=T.lim}return E1}var T1,XD;function bW(){if(XD)return T1;XD=1;var t=Td(),e=t.longestPath,n=U8(),i=vW();T1=r;function r(u){switch(u.graph().ranker){case"network-simplex":c(u);break;case"tight-tree":o(u);break;case"longest-path":s(u);break;default:c(u)}}var s=e;function o(u){e(u),n(u)}function c(u){i(u)}return T1}var M1,WD;function xW(){if(WD)return M1;WD=1;var t=Ot();M1=e;function e(r){var s=i(r);t.forEach(r.graph().dummyChains,function(o){for(var c=r.node(o),u=c.edgeObj,h=n(r,s,u.v,u.w),d=h.path,m=h.lca,g=0,y=d[g],x=!0;o!==u.w;){if(c=r.node(o),x){for(;(y=d[g])!==m&&r.node(y).maxRank<c.rank;)g++;y===m&&(x=!1)}if(!x){for(;g<d.length-1&&r.node(y=d[g+1]).minRank<=c.rank;)g++;y=d[g]}r.setParent(o,y),o=r.successors(o)[0]}})}function n(r,s,o,c){var u=[],h=[],d=Math.min(s[o].low,s[c].low),m=Math.max(s[o].lim,s[c].lim),g,y;g=o;do g=r.parent(g),u.push(g);while(g&&(s[g].low>d||m>s[g].lim));for(y=g,g=c;(g=r.parent(g))!==y;)h.push(g);return{path:u.concat(h.reverse()),lca:y}}function i(r){var s={},o=0;function c(u){var h=o;t.forEach(r.children(u),c),s[u]={low:h,lim:o++}}return t.forEach(r.children(),c),s}return M1}var R1,KD;function wW(){if(KD)return R1;KD=1;var t=Ot(),e=Gn();R1={run:n,cleanup:o};function n(c){var u=e.addDummyNode(c,"root",{},"_root"),h=r(c),d=t.max(t.values(h))-1,m=2*d+1;c.graph().nestingRoot=u,t.forEach(c.edges(),function(y){c.edge(y).minlen*=m});var g=s(c)+1;t.forEach(c.children(),function(y){i(c,u,m,g,d,h,y)}),c.graph().nodeRankFactor=m}function i(c,u,h,d,m,g,y){var x=c.children(y);if(!x.length){y!==u&&c.setEdge(u,y,{weight:0,minlen:h});return}var w=e.addBorderNode(c,"_bt"),S=e.addBorderNode(c,"_bb"),C=c.node(y);c.setParent(w,y),C.borderTop=w,c.setParent(S,y),C.borderBottom=S,t.forEach(x,function(A){i(c,u,h,d,m,g,A);var O=c.node(A),E=O.borderTop?O.borderTop:A,T=O.borderBottom?O.borderBottom:A,M=O.borderTop?d:2*d,R=E!==T?1:m-g[y]+1;c.setEdge(w,E,{weight:M,minlen:R,nestingEdge:!0}),c.setEdge(T,S,{weight:M,minlen:R,nestingEdge:!0})}),c.parent(y)||c.setEdge(u,w,{weight:0,minlen:m+g[y]})}function r(c){var u={};function h(d,m){var g=c.children(d);g&&g.length&&t.forEach(g,function(y){h(y,m+1)}),u[d]=m}return t.forEach(c.children(),function(d){h(d,1)}),u}function s(c){return t.reduce(c.edges(),function(u,h){return u+c.edge(h).weight},0)}function o(c){var u=c.graph();c.removeNode(u.nestingRoot),delete u.nestingRoot,t.forEach(c.edges(),function(h){var d=c.edge(h);d.nestingEdge&&c.removeEdge(h)})}return R1}var N1,ZD;function SW(){if(ZD)return N1;ZD=1;var t=Ot(),e=Gn();N1=n;function n(r){function s(o){var c=r.children(o),u=r.node(o);if(c.length&&t.forEach(c,s),t.has(u,"minRank")){u.borderLeft=[],u.borderRight=[];for(var h=u.minRank,d=u.maxRank+1;h<d;++h)i(r,"borderLeft","_bl",o,u,h),i(r,"borderRight","_br",o,u,h)}}t.forEach(r.children(),s)}function i(r,s,o,c,u,h){var d={width:0,height:0,rank:h,borderType:s},m=u[s][h-1],g=e.addDummyNode(r,"border",d,o);u[s][h]=g,r.setParent(g,c),m&&r.setEdge(m,g,{weight:1})}return N1}var D1,JD;function CW(){if(JD)return D1;JD=1;var t=Ot();D1={adjust:e,undo:n};function e(h){var d=h.graph().rankdir.toLowerCase();(d==="lr"||d==="rl")&&i(h)}function n(h){var d=h.graph().rankdir.toLowerCase();(d==="bt"||d==="rl")&&s(h),(d==="lr"||d==="rl")&&(c(h),i(h))}function i(h){t.forEach(h.nodes(),function(d){r(h.node(d))}),t.forEach(h.edges(),function(d){r(h.edge(d))})}function r(h){var d=h.width;h.width=h.height,h.height=d}function s(h){t.forEach(h.nodes(),function(d){o(h.node(d))}),t.forEach(h.edges(),function(d){var m=h.edge(d);t.forEach(m.points,o),t.has(m,"y")&&o(m)})}function o(h){h.y=-h.y}function c(h){t.forEach(h.nodes(),function(d){u(h.node(d))}),t.forEach(h.edges(),function(d){var m=h.edge(d);t.forEach(m.points,u),t.has(m,"x")&&u(m)})}function u(h){var d=h.x;h.x=h.y,h.y=d}return D1}var L1,e3;function kW(){if(e3)return L1;e3=1;var t=Ot();L1=e;function e(n){var i={},r=t.filter(n.nodes(),function(h){return!n.children(h).length}),s=t.max(t.map(r,function(h){return n.node(h).rank})),o=t.map(t.range(s+1),function(){return[]});function c(h){if(!t.has(i,h)){i[h]=!0;var d=n.node(h);o[d.rank].push(h),t.forEach(n.successors(h),c)}}var u=t.sortBy(r,function(h){return n.node(h).rank});return t.forEach(u,c),o}return L1}var z1,t3;function AW(){if(t3)return z1;t3=1;var t=Ot();z1=e;function e(i,r){for(var s=0,o=1;o<r.length;++o)s+=n(i,r[o-1],r[o]);return s}function n(i,r,s){for(var o=t.zipObject(s,t.map(s,function(g,y){return y})),c=t.flatten(t.map(r,function(g){return t.sortBy(t.map(i.outEdges(g),function(y){return{pos:o[y.w],weight:i.edge(y).weight}}),"pos")}),!0),u=1;u<s.length;)u<<=1;var h=2*u-1;u-=1;var d=t.map(new Array(h),function(){return 0}),m=0;return t.forEach(c.forEach(function(g){var y=g.pos+u;d[y]+=g.weight;for(var x=0;y>0;)y%2&&(x+=d[y+1]),y=y-1>>1,d[y]+=g.weight;m+=g.weight*x})),m}return z1}var B1,n3;function _W(){if(n3)return B1;n3=1;var t=Ot();B1=e;function e(n,i){return t.map(i,function(r){var s=n.inEdges(r);if(s.length){var o=t.reduce(s,function(c,u){var h=n.edge(u),d=n.node(u.v);return{sum:c.sum+h.weight*d.order,weight:c.weight+h.weight}},{sum:0,weight:0});return{v:r,barycenter:o.sum/o.weight,weight:o.weight}}else return{v:r}})}return B1}var q1,i3;function OW(){if(i3)return q1;i3=1;var t=Ot();q1=e;function e(r,s){var o={};t.forEach(r,function(u,h){var d=o[u.v]={indegree:0,in:[],out:[],vs:[u.v],i:h};t.isUndefined(u.barycenter)||(d.barycenter=u.barycenter,d.weight=u.weight)}),t.forEach(s.edges(),function(u){var h=o[u.v],d=o[u.w];!t.isUndefined(h)&&!t.isUndefined(d)&&(d.indegree++,h.out.push(o[u.w]))});var c=t.filter(o,function(u){return!u.indegree});return n(c)}function n(r){var s=[];function o(h){return function(d){d.merged||(t.isUndefined(d.barycenter)||t.isUndefined(h.barycenter)||d.barycenter>=h.barycenter)&&i(h,d)}}function c(h){return function(d){d.in.push(h),--d.indegree===0&&r.push(d)}}for(;r.length;){var u=r.pop();s.push(u),t.forEach(u.in.reverse(),o(u)),t.forEach(u.out,c(u))}return t.map(t.filter(s,function(h){return!h.merged}),function(h){return t.pick(h,["vs","i","barycenter","weight"])})}function i(r,s){var o=0,c=0;r.weight&&(o+=r.barycenter*r.weight,c+=r.weight),s.weight&&(o+=s.barycenter*s.weight,c+=s.weight),r.vs=s.vs.concat(r.vs),r.barycenter=o/c,r.weight=c,r.i=Math.min(s.i,r.i),s.merged=!0}return q1}var j1,r3;function EW(){if(r3)return j1;r3=1;var t=Ot(),e=Gn();j1=n;function n(s,o){var c=e.partition(s,function(w){return t.has(w,"barycenter")}),u=c.lhs,h=t.sortBy(c.rhs,function(w){return-w.i}),d=[],m=0,g=0,y=0;u.sort(r(!!o)),y=i(d,h,y),t.forEach(u,function(w){y+=w.vs.length,d.push(w.vs),m+=w.barycenter*w.weight,g+=w.weight,y=i(d,h,y)});var x={vs:t.flatten(d,!0)};return g&&(x.barycenter=m/g,x.weight=g),x}function i(s,o,c){for(var u;o.length&&(u=t.last(o)).i<=c;)o.pop(),s.push(u.vs),c++;return c}function r(s){return function(o,c){return o.barycenter<c.barycenter?-1:o.barycenter>c.barycenter?1:s?c.i-o.i:o.i-c.i}}return j1}var I1,s3;function TW(){if(s3)return I1;s3=1;var t=Ot(),e=_W(),n=OW(),i=EW();I1=r;function r(c,u,h,d){var m=c.children(u),g=c.node(u),y=g?g.borderLeft:void 0,x=g?g.borderRight:void 0,w={};y&&(m=t.filter(m,function(T){return T!==y&&T!==x}));var S=e(c,m);t.forEach(S,function(T){if(c.children(T.v).length){var M=r(c,T.v,h,d);w[T.v]=M,t.has(M,"barycenter")&&o(T,M)}});var C=n(S,h);s(C,w);var A=i(C,d);if(y&&(A.vs=t.flatten([y,A.vs,x],!0),c.predecessors(y).length)){var O=c.node(c.predecessors(y)[0]),E=c.node(c.predecessors(x)[0]);t.has(A,"barycenter")||(A.barycenter=0,A.weight=0),A.barycenter=(A.barycenter*A.weight+O.order+E.order)/(A.weight+2),A.weight+=2}return A}function s(c,u){t.forEach(c,function(h){h.vs=t.flatten(h.vs.map(function(d){return u[d]?u[d].vs:d}),!0)})}function o(c,u){t.isUndefined(c.barycenter)?(c.barycenter=u.barycenter,c.weight=u.weight):(c.barycenter=(c.barycenter*c.weight+u.barycenter*u.weight)/(c.weight+u.weight),c.weight+=u.weight)}return I1}var P1,a3;function MW(){if(a3)return P1;a3=1;var t=Ot(),e=ji().Graph;P1=n;function n(r,s,o){var c=i(r),u=new e({compound:!0}).setGraph({root:c}).setDefaultNodeLabel(function(h){return r.node(h)});return t.forEach(r.nodes(),function(h){var d=r.node(h),m=r.parent(h);(d.rank===s||d.minRank<=s&&s<=d.maxRank)&&(u.setNode(h),u.setParent(h,m||c),t.forEach(r[o](h),function(g){var y=g.v===h?g.w:g.v,x=u.edge(y,h),w=t.isUndefined(x)?0:x.weight;u.setEdge(y,h,{weight:r.edge(g).weight+w})}),t.has(d,"minRank")&&u.setNode(h,{borderLeft:d.borderLeft[s],borderRight:d.borderRight[s]}))}),u}function i(r){for(var s;r.hasNode(s=t.uniqueId("_root")););return s}return P1}var H1,o3;function RW(){if(o3)return H1;o3=1;var t=Ot();H1=e;function e(n,i,r){var s={},o;t.forEach(r,function(c){for(var u=n.parent(c),h,d;u;){if(h=n.parent(u),h?(d=s[h],s[h]=u):(d=o,o=u),d&&d!==u){i.setEdge(d,u);return}u=h}})}return H1}var U1,l3;function NW(){if(l3)return U1;l3=1;var t=Ot(),e=kW(),n=AW(),i=TW(),r=MW(),s=RW(),o=ji().Graph,c=Gn();U1=u;function u(g){var y=c.maxRank(g),x=h(g,t.range(1,y+1),"inEdges"),w=h(g,t.range(y-1,-1,-1),"outEdges"),S=e(g);m(g,S);for(var C=Number.POSITIVE_INFINITY,A,O=0,E=0;E<4;++O,++E){d(O%2?x:w,O%4>=2),S=c.buildLayerMatrix(g);var T=n(g,S);T<C&&(E=0,A=t.cloneDeep(S),C=T)}m(g,A)}function h(g,y,x){return t.map(y,function(w){return r(g,w,x)})}function d(g,y){var x=new o;t.forEach(g,function(w){var S=w.graph().root,C=i(w,S,x,y);t.forEach(C.vs,function(A,O){w.node(A).order=O}),s(w,x,C.vs)})}function m(g,y){t.forEach(y,function(x){t.forEach(x,function(w,S){g.node(w).order=S})})}return U1}var V1,c3;function DW(){if(c3)return V1;c3=1;var t=Ot(),e=ji().Graph,n=Gn();V1={positionX:x,findType1Conflicts:i,findType2Conflicts:r,addConflict:o,hasConflict:c,verticalAlignment:u,horizontalCompaction:h,alignCoordinates:g,findSmallestWidthAlignment:m,balance:y};function i(C,A){var O={};function E(T,M){var R=0,z=0,q=T.length,U=t.last(M);return t.forEach(M,function(P,$){var K=s(C,P),L=K?C.node(K).order:q;(K||P===U)&&(t.forEach(M.slice(z,$+1),function(Y){t.forEach(C.predecessors(Y),function(D){var Q=C.node(D),ee=Q.order;(ee<R||L<ee)&&!(Q.dummy&&C.node(Y).dummy)&&o(O,D,Y)})}),z=$+1,R=L)}),M}return t.reduce(A,E),O}function r(C,A){var O={};function E(M,R,z,q,U){var P;t.forEach(t.range(R,z),function($){P=M[$],C.node(P).dummy&&t.forEach(C.predecessors(P),function(K){var L=C.node(K);L.dummy&&(L.order<q||L.order>U)&&o(O,K,P)})})}function T(M,R){var z=-1,q,U=0;return t.forEach(R,function(P,$){if(C.node(P).dummy==="border"){var K=C.predecessors(P);K.length&&(q=C.node(K[0]).order,E(R,U,$,z,q),U=$,z=q)}E(R,U,R.length,q,M.length)}),R}return t.reduce(A,T),O}function s(C,A){if(C.node(A).dummy)return t.find(C.predecessors(A),function(O){return C.node(O).dummy})}function o(C,A,O){if(A>O){var E=A;A=O,O=E}var T=C[A];T||(C[A]=T={}),T[O]=!0}function c(C,A,O){if(A>O){var E=A;A=O,O=E}return t.has(C[A],O)}function u(C,A,O,E){var T={},M={},R={};return t.forEach(A,function(z){t.forEach(z,function(q,U){T[q]=q,M[q]=q,R[q]=U})}),t.forEach(A,function(z){var q=-1;t.forEach(z,function(U){var P=E(U);if(P.length){P=t.sortBy(P,function(D){return R[D]});for(var $=(P.length-1)/2,K=Math.floor($),L=Math.ceil($);K<=L;++K){var Y=P[K];M[U]===U&&q<R[Y]&&!c(O,U,Y)&&(M[Y]=U,M[U]=T[U]=T[Y],q=R[Y])}}})}),{root:T,align:M}}function h(C,A,O,E,T){var M={},R=d(C,A,O,T),z=T?"borderLeft":"borderRight";function q($,K){for(var L=R.nodes(),Y=L.pop(),D={};Y;)D[Y]?$(Y):(D[Y]=!0,L.push(Y),L=L.concat(K(Y))),Y=L.pop()}function U($){M[$]=R.inEdges($).reduce(function(K,L){return Math.max(K,M[L.v]+R.edge(L))},0)}function P($){var K=R.outEdges($).reduce(function(Y,D){return Math.min(Y,M[D.w]-R.edge(D))},Number.POSITIVE_INFINITY),L=C.node($);K!==Number.POSITIVE_INFINITY&&L.borderType!==z&&(M[$]=Math.max(M[$],K))}return q(U,R.predecessors.bind(R)),q(P,R.successors.bind(R)),t.forEach(E,function($){M[$]=M[O[$]]}),M}function d(C,A,O,E){var T=new e,M=C.graph(),R=w(M.nodesep,M.edgesep,E);return t.forEach(A,function(z){var q;t.forEach(z,function(U){var P=O[U];if(T.setNode(P),q){var $=O[q],K=T.edge($,P);T.setEdge($,P,Math.max(R(C,U,q),K||0))}q=U})}),T}function m(C,A){return t.minBy(t.values(A),function(O){var E=Number.NEGATIVE_INFINITY,T=Number.POSITIVE_INFINITY;return t.forIn(O,function(M,R){var z=S(C,R)/2;E=Math.max(M+z,E),T=Math.min(M-z,T)}),E-T})}function g(C,A){var O=t.values(A),E=t.min(O),T=t.max(O);t.forEach(["u","d"],function(M){t.forEach(["l","r"],function(R){var z=M+R,q=C[z],U;if(q!==A){var P=t.values(q);U=R==="l"?E-t.min(P):T-t.max(P),U&&(C[z]=t.mapValues(q,function($){return $+U}))}})})}function y(C,A){return t.mapValues(C.ul,function(O,E){if(A)return C[A.toLowerCase()][E];var T=t.sortBy(t.map(C,E));return(T[1]+T[2])/2})}function x(C){var A=n.buildLayerMatrix(C),O=t.merge(i(C,A),r(C,A)),E={},T;t.forEach(["u","d"],function(R){T=R==="u"?A:t.values(A).reverse(),t.forEach(["l","r"],function(z){z==="r"&&(T=t.map(T,function($){return t.values($).reverse()}));var q=(R==="u"?C.predecessors:C.successors).bind(C),U=u(C,T,O,q),P=h(C,T,U.root,U.align,z==="r");z==="r"&&(P=t.mapValues(P,function($){return-$})),E[R+z]=P})});var M=m(C,E);return g(E,M),y(E,C.graph().align)}function w(C,A,O){return function(E,T,M){var R=E.node(T),z=E.node(M),q=0,U;if(q+=R.width/2,t.has(R,"labelpos"))switch(R.labelpos.toLowerCase()){case"l":U=-R.width/2;break;case"r":U=R.width/2;break}if(U&&(q+=O?U:-U),U=0,q+=(R.dummy?A:C)/2,q+=(z.dummy?A:C)/2,q+=z.width/2,t.has(z,"labelpos"))switch(z.labelpos.toLowerCase()){case"l":U=z.width/2;break;case"r":U=-z.width/2;break}return U&&(q+=O?U:-U),U=0,q}}function S(C,A){return C.node(A).width}return V1}var F1,u3;function LW(){if(u3)return F1;u3=1;var t=Ot(),e=Gn(),n=DW().positionX;F1=i;function i(s){s=e.asNonCompoundGraph(s),r(s),t.forEach(n(s),function(o,c){s.node(c).x=o})}function r(s){var o=e.buildLayerMatrix(s),c=s.graph().ranksep,u=0;t.forEach(o,function(h){var d=t.max(t.map(h,function(m){return s.node(m).height}));t.forEach(h,function(m){s.node(m).y=u+d/2}),u+=d+c})}return F1}var $1,f3;function zW(){if(f3)return $1;f3=1;var t=Ot(),e=gW(),n=yW(),i=bW(),r=Gn().normalizeRanks,s=xW(),o=Gn().removeEmptyRanks,c=wW(),u=SW(),h=CW(),d=NW(),m=LW(),g=Gn(),y=ji().Graph;$1=x;function x(I,X){var J=X&&X.debugTiming?g.time:g.notime;J("layout",function(){var oe=J(" buildLayoutGraph",function(){return q(I)});J(" runLayout",function(){w(oe,J)}),J(" updateInputGraph",function(){S(I,oe)})})}function w(I,X){X(" makeSpaceForEdgeLabels",function(){U(I)}),X(" removeSelfEdges",function(){G(I)}),X(" acyclic",function(){e.run(I)}),X(" nestingGraph.run",function(){c.run(I)}),X(" rank",function(){i(g.asNonCompoundGraph(I))}),X(" injectEdgeLabelProxies",function(){P(I)}),X(" removeEmptyRanks",function(){o(I)}),X(" nestingGraph.cleanup",function(){c.cleanup(I)}),X(" normalizeRanks",function(){r(I)}),X(" assignRankMinMax",function(){$(I)}),X(" removeEdgeLabelProxies",function(){K(I)}),X(" normalize.run",function(){n.run(I)}),X(" parentDummyChains",function(){s(I)}),X(" addBorderSegments",function(){u(I)}),X(" order",function(){d(I)}),X(" insertSelfEdges",function(){W(I)}),X(" adjustCoordinateSystem",function(){h.adjust(I)}),X(" position",function(){m(I)}),X(" positionSelfEdges",function(){B(I)}),X(" removeBorderNodes",function(){ee(I)}),X(" normalize.undo",function(){n.undo(I)}),X(" fixupEdgeLabelCoords",function(){D(I)}),X(" undoCoordinateSystem",function(){h.undo(I)}),X(" translateGraph",function(){L(I)}),X(" assignNodeIntersects",function(){Y(I)}),X(" reversePoints",function(){Q(I)}),X(" acyclic.undo",function(){e.undo(I)})}function S(I,X){t.forEach(I.nodes(),function(J){var oe=I.node(J),ve=X.node(J);oe&&(oe.x=ve.x,oe.y=ve.y,X.children(J).length&&(oe.width=ve.width,oe.height=ve.height))}),t.forEach(I.edges(),function(J){var oe=I.edge(J),ve=X.edge(J);oe.points=ve.points,t.has(ve,"x")&&(oe.x=ve.x,oe.y=ve.y)}),I.graph().width=X.graph().width,I.graph().height=X.graph().height}var C=["nodesep","edgesep","ranksep","marginx","marginy"],A={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},O=["acyclicer","ranker","rankdir","align"],E=["width","height"],T={width:0,height:0},M=["minlen","weight","width","height","labeloffset"],R={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},z=["labelpos"];function q(I){var X=new y({multigraph:!0,compound:!0}),J=ne(I.graph());return X.setGraph(t.merge({},A,F(J,C),t.pick(J,O))),t.forEach(I.nodes(),function(oe){var ve=ne(I.node(oe));X.setNode(oe,t.defaults(F(ve,E),T)),X.setParent(oe,I.parent(oe))}),t.forEach(I.edges(),function(oe){var ve=ne(I.edge(oe));X.setEdge(oe,t.merge({},R,F(ve,M),t.pick(ve,z)))}),X}function U(I){var X=I.graph();X.ranksep/=2,t.forEach(I.edges(),function(J){var oe=I.edge(J);oe.minlen*=2,oe.labelpos.toLowerCase()!=="c"&&(X.rankdir==="TB"||X.rankdir==="BT"?oe.width+=oe.labeloffset:oe.height+=oe.labeloffset)})}function P(I){t.forEach(I.edges(),function(X){var J=I.edge(X);if(J.width&&J.height){var oe=I.node(X.v),ve=I.node(X.w),H={rank:(ve.rank-oe.rank)/2+oe.rank,e:X};g.addDummyNode(I,"edge-proxy",H,"_ep")}})}function $(I){var X=0;t.forEach(I.nodes(),function(J){var oe=I.node(J);oe.borderTop&&(oe.minRank=I.node(oe.borderTop).rank,oe.maxRank=I.node(oe.borderBottom).rank,X=t.max(X,oe.maxRank))}),I.graph().maxRank=X}function K(I){t.forEach(I.nodes(),function(X){var J=I.node(X);J.dummy==="edge-proxy"&&(I.edge(J.e).labelRank=J.rank,I.removeNode(X))})}function L(I){var X=Number.POSITIVE_INFINITY,J=0,oe=Number.POSITIVE_INFINITY,ve=0,H=I.graph(),pe=H.marginx||0,me=H.marginy||0;function ye(_e){var Ae=_e.x,be=_e.y,He=_e.width,we=_e.height;X=Math.min(X,Ae-He/2),J=Math.max(J,Ae+He/2),oe=Math.min(oe,be-we/2),ve=Math.max(ve,be+we/2)}t.forEach(I.nodes(),function(_e){ye(I.node(_e))}),t.forEach(I.edges(),function(_e){var Ae=I.edge(_e);t.has(Ae,"x")&&ye(Ae)}),X-=pe,oe-=me,t.forEach(I.nodes(),function(_e){var Ae=I.node(_e);Ae.x-=X,Ae.y-=oe}),t.forEach(I.edges(),function(_e){var Ae=I.edge(_e);t.forEach(Ae.points,function(be){be.x-=X,be.y-=oe}),t.has(Ae,"x")&&(Ae.x-=X),t.has(Ae,"y")&&(Ae.y-=oe)}),H.width=J-X+pe,H.height=ve-oe+me}function Y(I){t.forEach(I.edges(),function(X){var J=I.edge(X),oe=I.node(X.v),ve=I.node(X.w),H,pe;J.points?(H=J.points[0],pe=J.points[J.points.length-1]):(J.points=[],H=ve,pe=oe),J.points.unshift(g.intersectRect(oe,H)),J.points.push(g.intersectRect(ve,pe))})}function D(I){t.forEach(I.edges(),function(X){var J=I.edge(X);if(t.has(J,"x"))switch((J.labelpos==="l"||J.labelpos==="r")&&(J.width-=J.labeloffset),J.labelpos){case"l":J.x-=J.width/2+J.labeloffset;break;case"r":J.x+=J.width/2+J.labeloffset;break}})}function Q(I){t.forEach(I.edges(),function(X){var J=I.edge(X);J.reversed&&J.points.reverse()})}function ee(I){t.forEach(I.nodes(),function(X){if(I.children(X).length){var J=I.node(X),oe=I.node(J.borderTop),ve=I.node(J.borderBottom),H=I.node(t.last(J.borderLeft)),pe=I.node(t.last(J.borderRight));J.width=Math.abs(pe.x-H.x),J.height=Math.abs(ve.y-oe.y),J.x=H.x+J.width/2,J.y=oe.y+J.height/2}}),t.forEach(I.nodes(),function(X){I.node(X).dummy==="border"&&I.removeNode(X)})}function G(I){t.forEach(I.edges(),function(X){if(X.v===X.w){var J=I.node(X.v);J.selfEdges||(J.selfEdges=[]),J.selfEdges.push({e:X,label:I.edge(X)}),I.removeEdge(X)}})}function W(I){var X=g.buildLayerMatrix(I);t.forEach(X,function(J){var oe=0;t.forEach(J,function(ve,H){var pe=I.node(ve);pe.order=H+oe,t.forEach(pe.selfEdges,function(me){g.addDummyNode(I,"selfedge",{width:me.label.width,height:me.label.height,rank:pe.rank,order:H+ ++oe,e:me.e,label:me.label},"_se")}),delete pe.selfEdges})})}function B(I){t.forEach(I.nodes(),function(X){var J=I.node(X);if(J.dummy==="selfedge"){var oe=I.node(J.e.v),ve=oe.x+oe.width/2,H=oe.y,pe=J.x-ve,me=oe.height/2;I.setEdge(J.e,J.label),I.removeNode(X),J.label.points=[{x:ve+2*pe/3,y:H-me},{x:ve+5*pe/6,y:H-me},{x:ve+pe,y:H},{x:ve+5*pe/6,y:H+me},{x:ve+2*pe/3,y:H+me}],J.label.x=J.x,J.label.y=J.y}})}function F(I,X){return t.mapValues(t.pick(I,X),Number)}function ne(I){var X={};return t.forEach(I,function(J,oe){X[oe.toLowerCase()]=J}),X}return $1}var G1,h3;function BW(){if(h3)return G1;h3=1;var t=Ot(),e=Gn(),n=ji().Graph;G1={debugOrdering:i};function i(r){var s=e.buildLayerMatrix(r),o=new n({compound:!0,multigraph:!0}).setGraph({});return t.forEach(r.nodes(),function(c){o.setNode(c,{label:c}),o.setParent(c,"layer"+r.node(c).rank)}),t.forEach(r.edges(),function(c){o.setEdge(c.v,c.w,{},c.name)}),t.forEach(s,function(c,u){var h="layer"+u;o.setNode(h,{rank:"same"}),t.reduce(c,function(d,m){return o.setEdge(d,m,{style:"invis"}),m})}),o}return G1}var Y1,d3;function qW(){return d3||(d3=1,Y1="0.8.5"),Y1}var Q1,p3;function jW(){return p3||(p3=1,Q1={graphlib:ji(),layout:zW(),debug:BW(),util:{time:Gn().time,notime:Gn().notime},version:qW()}),Q1}var IW=jW();const Eh=o2(IW);function xi(t){if(!t||typeof t!="object")throw new Error("Invalid YAML: Root must be an object");const e={tables:Array.isArray(t.tables)?t.tables:[],relationships:Array.isArray(t.relationships)?t.relationships:[],domains:Array.isArray(t.domains)?t.domains:[],layout:t.layout||{}};return e.tables=e.tables.map(n=>{let i=n.sampleData;if(i&&typeof i=="object"&&!Array.isArray(i)){const s=Array.isArray(i.columns)?i.columns:[],o=Array.isArray(i.rows)?i.rows:[];if(s.length>0&&o.length>0){const c=Array.isArray(n.columns)?n.columns:[];i=o.map(u=>c.map(h=>{const d=s.indexOf(h.id);return d!==-1?u[d]:null}))}else o.length>0?i=o:i=[]}const r=n.appearance?{...n.appearance}:void 0;return r&&r.sub_type&&/^type[0-7]$/.test(r.sub_type)&&!r.scd&&(r.scd=r.sub_type,r.sub_type=void 0),{...n,id:n.id||"unknown",name:n.name!==void 0?n.name:n.id||"Unnamed Table",logical_name:n.logical_name,physical_name:n.physical_name,appearance:r,lineage:n.lineage?{...n.lineage}:void 0,columns:Array.isArray(n.columns)?n.columns.map(s=>({...s,logical:s.logical?{...s.logical}:void 0,physical:s.physical?{...s.physical}:void 0})):[],sampleData:Array.isArray(i)?i:[]}}),e}function PW(t){try{const e=eS.load(t);return xi(e)}catch(e){throw new Error(`YAML Parsing Error: ${e.message}`)}}let X1=null;const ci=r$((t,e)=>({schema:null,selectedTableId:null,selectedEdgeId:null,hoveredColumnId:null,error:null,isCliMode:typeof window<"u"&&window.MODSCAPE_CLI_MODE===!0,isAutoSaveEnabled:!0,savingStatus:"idle",lastUpdateSource:"visual",yamlInput:"",setYamlInput:n=>t({yamlInput:n,lastUpdateSource:"user"}),syncToYamlInput:()=>{const{schema:n}=e();if(n){const i=eS.dump(n,{indent:2,lineWidth:-1,noRefs:!0});t({yamlInput:i,lastUpdateSource:"visual"})}},availableFiles:[],currentModelSlug:null,isSidebarOpen:!0,activeTab:"editor",focusNodeId:null,showER:!0,showLineage:!0,connectionStartHandle:null,theme:typeof window<"u"&&localStorage.getItem("modscape-theme")||(window.matchMedia?.("(prefers-color-scheme: light)").matches?"light":"dark"),setSchema:n=>{try{const i=xi(n);t({schema:i,error:null}),e().syncToYamlInput()}catch(i){t({error:i.message})}},setShowER:n=>t({showER:n}),setShowLineage:n=>t({showLineage:n}),setIsAutoSaveEnabled:n=>t({isAutoSaveEnabled:n}),setLastUpdateSource:n=>t({lastUpdateSource:n}),setSelectedTableId:n=>t({selectedTableId:n}),setSelectedEdgeId:n=>t({selectedEdgeId:n}),setHoveredColumnId:n=>t({hoveredColumnId:n}),setIsCliMode:n=>t({isCliMode:n}),setIsSidebarOpen:n=>t({isSidebarOpen:n}),setActiveTab:n=>t({activeTab:n}),setFocusNodeId:n=>t({focusNodeId:n}),setConnectionStartHandle:n=>t({connectionStartHandle:n}),toggleTheme:()=>{const{theme:n}=e(),i=n==="dark"?"light":"dark";t({theme:i}),localStorage.setItem("modscape-theme",i)},calculateAutoLayout:()=>{const{schema:n}=e();if(!n)return;const i={...n.layout||{}},r=320,s=220,o=80,c=120,u={};n.domains?.forEach(g=>{const y=g.tables;if(y.length===0){u[g.id]={width:400,height:200,tableOffsets:{}};return}const x=new Eh.graphlib.Graph;x.setGraph({rankdir:"TB",nodesep:o,ranksep:o}),x.setDefaultEdgeLabel(()=>({})),y.forEach(M=>{const R=n.layout?.[M];x.setNode(M,{width:R?.width||r,height:R?.height||s})}),(n.relationships||[]).forEach(M=>{y.includes(M.from.table)&&y.includes(M.to.table)&&x.setEdge(M.from.table,M.to.table)}),n.tables.forEach(M=>{y.includes(M.id)&&M.lineage?.upstream&&M.lineage.upstream.forEach(R=>{y.includes(R)&&x.setEdge(R,M.id)})}),Eh.layout(x);let w=1/0,S=1/0,C=-1/0,A=-1/0;const O={};x.nodes().forEach(M=>{const R=x.node(M);O[M]={x:R.x,y:R.y},w=Math.min(w,R.x-R.width/2),S=Math.min(S,R.y-R.height/2),C=Math.max(C,R.x+R.width/2),A=Math.max(A,R.y+R.height/2)});const E=C-w+c,T=A-S+c;y.forEach(M=>{O[M].x=Math.round(O[M].x-w-x.node(M).width/2+c/2),O[M].y=Math.round(O[M].y-S-x.node(M).height/2+c/2)}),u[g.id]={width:E,height:T,tableOffsets:O}});const h=[...n.domains?.map(g=>g.id)||[],...n.tables.filter(g=>!n.domains?.some(y=>y.tables.includes(g.id))).map(g=>g.id)],d=new Eh.graphlib.Graph;d.setGraph({rankdir:"LR",nodesep:200,ranksep:300}),d.setDefaultEdgeLabel(()=>({})),h.forEach(g=>{const y=n.domains?.some(S=>S.id===g),x=y?u[g].width:n.layout?.[g]?.width||r,w=y?u[g].height:n.layout?.[g]?.height||s;d.setNode(g,{width:x,height:w})});const m=g=>n.domains?.find(y=>y.tables.includes(g))?.id||g;n.relationships?.forEach(g=>{const y=m(g.from.table),x=m(g.to.table);y!==x&&d.setEdge(y,x)}),n.tables.forEach(g=>{if(g.lineage?.upstream){const y=m(g.id);g.lineage.upstream.forEach(x=>{const w=m(x);w!==y&&d.setEdge(w,y)})}}),Eh.layout(d),d.nodes().forEach(g=>{const y=d.node(g),x=Math.round(y.x-y.width/2),w=Math.round(y.y-y.height/2),S=n.domains?.find(C=>C.id===g);S?(i[g]={x,y:w,width:u[g].width,height:u[g].height},S.tables.forEach(C=>{i[C]={x:u[g].tableOffsets[C].x,y:u[g].tableOffsets[C].y}})):i[g]={x,y:w}}),t({schema:{...n,layout:i},lastUpdateSource:"visual"}),e().syncToYamlInput(),e().saveSchema(!0)},fetchAvailableFiles:async()=>{const n=window.__MODSCAPE_DATA__;if(n&&n.models){const i=n.models.map(r=>({slug:r.slug,name:r.name,path:""}));t({availableFiles:i});return}try{const r=await(await fetch("/api/files")).json();t({availableFiles:r})}catch(i){console.error("Failed to fetch files:",i)}},setCurrentModel:async n=>{const i=window.__MODSCAPE_DATA__;if(i&&i.models){const r=i.models.find(s=>s.slug===n);if(r){t({currentModelSlug:n,schema:xi(r.schema),selectedTableId:null,error:null}),e().syncToYamlInput();const s=new URLSearchParams(window.location.search);s.set("model",n);const o=window.location.pathname+"?"+s.toString();window.history.pushState(null,"",o)}return}try{const r=`/api/model?model=${n}`,o=await(await fetch(r)).json();t({currentModelSlug:n,schema:xi(o),selectedTableId:null,error:null}),e().syncToYamlInput();const c=new URLSearchParams(window.location.search);c.set("model",n);const u=window.location.pathname+"?"+c.toString();window.history.pushState(null,"",u)}catch(r){console.error("Failed to fetch model:",r)}},parseAndSetSchema:n=>{if(!(!n||n.trim()===""))try{const i=PW(n);t({schema:i,error:null}),e().saveSchema()}catch(i){t({error:i.message})}},updateNodePosition:(n,i,r,s)=>{const o=e().schema;if(!o)return;let c=o.domains||[];s!==void 0&&(c=c.map(d=>({...d,tables:d.tables.filter(m=>m!==n)})),s&&(c=c.map(d=>d.id===s?{...d,tables:Array.from(new Set([...d.tables,n]))}:d)));const u=o.layout?.[n]||{x:0,y:0},h={...o.layout||{},[n]:{...u,x:Math.round(i),y:Math.round(r)}};t({schema:{...o,domains:c,layout:h}}),e().syncToYamlInput(),e().saveSchema()},updateNodesPosition:n=>{const i=e().schema;if(!i||n.length===0)return;const r={...i.layout||{}};n.forEach(s=>{const o=r[s.id]||{x:0,y:0};r[s.id]={...o,x:Math.round(s.x),y:Math.round(s.y)}}),t({schema:{...i,layout:r},lastUpdateSource:"visual"}),e().syncToYamlInput(),e().saveSchema()},updateNodeDimensions:(n,i,r)=>{const s=e().schema;if(!s)return;const o=s.layout?.[n]||{x:0,y:0},c={...s.layout||{},[n]:{...o,width:Math.round(i),height:Math.round(r)}};t({schema:{...s,layout:c}}),e().syncToYamlInput(),e().saveSchema()},saveSchema:async(n=!1)=>{const{schema:i,currentModelSlug:r,isAutoSaveEnabled:s,isCliMode:o}=e();!i||!o||!s&&!n||(t({savingStatus:"saving"}),X1&&clearTimeout(X1),X1=setTimeout(async()=>{try{const c=r?`/api/save?model=${r}`:"/api/save",u=eS.dump(i,{indent:2,lineWidth:-1,noRefs:!0});await fetch(c,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({yaml:u})}),t({savingStatus:"saved"}),setTimeout(()=>t({savingStatus:"idle"}),2e3)}catch(c){console.error("Failed to save schema:",c),t({savingStatus:"error"})}},500))},addTable:(n,i)=>{const r=e().schema||{tables:[],relationships:[],domains:[],layout:{}},s=`new_table_${Date.now()}`,o={id:s,name:"NEW_TABLE",appearance:{type:"table"},columns:[{id:"id",logical:{name:"ID",type:"Integer",isPrimaryKey:!0}}]},c={...r,tables:[...r.tables||[],o],layout:{...r.layout||{},[s]:{x:Math.round(n),y:Math.round(i)}}};t({schema:xi(c),error:null,selectedTableId:s,selectedEdgeId:null}),e().syncToYamlInput(),e().saveSchema()},addDomain:(n,i)=>{const r=e().schema||{tables:[],relationships:[],domains:[],layout:{}},s=`new_domain_${Date.now()}`,o={id:s,name:"NEW_DOMAIN",description:"Domain purpose",tables:[],color:"rgba(59, 130, 246, 0.05)"},c={...r,domains:[...r.domains||[],o],layout:{...r.layout||{},[s]:{x:Math.round(n),y:Math.round(i),width:600,height:400}}};t({schema:xi(c),error:null,selectedTableId:s,selectedEdgeId:null}),e().syncToYamlInput(),e().saveSchema()},addRelationship:(n,i,r,s)=>{const o=e().schema;if(!o)return;if(r?.includes("lineage")||s?.includes("lineage")){e().addLineage(n,i);return}let u=n,h=i,d=r,m=s;const g=r?.includes("target"),y=s?.includes("source");(g||y)&&(u=i,h=n,d=s,m=r);const x=(E,T)=>{if(!T)return;const M=T.replace(`${E}-`,"");if(!(M.startsWith("er-")||M.startsWith("lin-")))return M.split("-")[0]||void 0},w=x(u,d),S=x(h,m);if((o.relationships||[]).some(E=>E.from.table===u&&E.from.column===w&&E.to.table===h&&E.to.column===S))return;const A={from:{table:u,column:w},to:{table:h,column:S},type:"one-to-many"},O={...o,relationships:[...o.relationships||[],A]};t({schema:xi(O)}),e().syncToYamlInput(),e().saveSchema()},addLineage:(n,i)=>{const{schema:r}=e();if(!r)return;const s=r.tables.map(c=>{if(c.id===i){const u=c.lineage?.upstream||[];if(!u.includes(n))return{...c,lineage:{...c.lineage,upstream:[...u,n]}}}return c}),o={...r,tables:s};t({schema:xi(o)}),e().syncToYamlInput(),e().saveSchema()},updateRelationship:(n,i)=>{const{schema:r}=e();if(!r||!r.relationships)return;const s=r.relationships.map((o,c)=>c===n?{...o,...i}:o);t({schema:{...r,relationships:s}}),e().syncToYamlInput(),e().saveSchema()},removeEdge:(n,i)=>{const{schema:r}=e();if(!r)return;const s=(r.relationships||[]).filter(u=>!(u.from.table===n&&u.to.table===i||u.from.table===i&&u.to.table===n)),o=r.tables.map(u=>u.id===i&&u.lineage?.upstream?{...u,lineage:{...u.lineage,upstream:u.lineage.upstream.filter(h=>h!==n)}}:u),c={...r,relationships:s,tables:o};t({schema:xi(c),selectedEdgeId:null}),e().syncToYamlInput(),e().saveSchema()},removeNode:n=>{const{schema:i}=e();if(!i)return;const r=i.tables.filter(h=>h.id!==n),s=(i.domains||[]).filter(h=>h.id!==n).map(h=>({...h,tables:h.tables.filter(d=>d!==n)})),o=(i.relationships||[]).filter(h=>h.from.table!==n&&h.to.table!==n),c={...i.layout||{}};delete c[n];const u={...i,tables:r,domains:s,relationships:o,layout:c};t({schema:xi(u),selectedTableId:null}),e().syncToYamlInput(),e().saveSchema()},updateTable:(n,i)=>{const{schema:r}=e();if(!r)return;const s=r.tables.map(c=>c.id===n?{...c,...i}:c),o={...r,tables:s};t({schema:xi(o)}),e().syncToYamlInput(),e().saveSchema()},updateDomain:(n,i)=>{const{schema:r}=e();if(!r||!r.domains)return;const s=r.domains.map(c=>c.id===n?{...c,...i}:c),o={...r,domains:s};t({schema:xi(o)}),e().syncToYamlInput(),e().saveSchema()},toggleDomainLock:n=>{const{schema:i}=e();if(!i||!i.domains)return;const r=i.domains.map(s=>s.id===n?{...s,isLocked:!s.isLocked}:s);t({schema:{...i,domains:r}}),e().syncToYamlInput(),e().saveSchema()},assignTableToDomain:(n,i)=>{const{schema:r}=e();if(!r)return;const s=(r.domains||[]).map(c=>{const u=c.tables.filter(h=>h!==n);return c.id===i?{...c,tables:Array.from(new Set([...u,n]))}:{...c,tables:u}}),o={...r.layout||{},[n]:{x:20,y:20}};t({schema:{...r,domains:s,layout:o}}),e().syncToYamlInput(),e().saveSchema()},toggleTableSelection:n=>{const{selectedTableId:i}=e();t(i===n?{selectedTableId:null}:{selectedTableId:n,selectedEdgeId:null})},toggleEdgeSelection:n=>{const{selectedEdgeId:i}=e();t(i===n?{selectedEdgeId:null}:{selectedEdgeId:n,selectedTableId:null})},getSelectedTable:()=>{const{schema:n,selectedTableId:i}=e();return!n||!i?null:n.tables.find(r=>r.id===i)||null},getSelectedDomain:()=>{const{schema:n,selectedTableId:i}=e();return!n||!i||!n.domains?null:n.domains.find(r=>r.id===i)||null},getSelectedRelationship:()=>{const{schema:n,selectedEdgeId:i}=e();if(!n||!i)return null;if(i.startsWith("lin-")){const o=i.split("-"),c=o[1],u=o[2];return{relationship:{from:{table:c},to:{table:u},type:"lineage"},index:-1}}if(!i.startsWith("e-"))return null;const r=parseInt(i.split("-")[1]),s=n.relationships[r];return s?{relationship:s,index:r}:null}})),HW={fact:{color:"#f87171",icon:"📊",label:"FACT"},dimension:{color:"#60a5fa",icon:"🏷️",label:"DIM"},hub:{color:"#fbbf24",icon:"🌐",label:"HUB"},link:{color:"#34d399",icon:"🔗",label:"LINK"},satellite:{color:"#a78bfa",icon:"🛰️",label:"SAT"},mart:{color:"#f5700b",icon:"📈",label:"MART"},table:{color:"#64748b",icon:"📋",label:"TABLE"}},UW=({id:t,data:e,selected:n})=>{const{table:i}=e,[r,s]=j.useState(!0),o=NF();j.useEffect(()=>{o(t);const q=setTimeout(()=>s(!1),1e3);return()=>clearTimeout(q)},[t,i.name,i.logical_name,i.physical_name,o]);const{updateNodeDimensions:c,hoveredColumnId:u,showER:h,showLineage:d,connectionStartHandle:m,theme:g}=ci(),y=n,x=i.columns&&i.columns.length>0,w=h&&d,S=i.appearance?.type?HW[i.appearance.type]:null,C=i.appearance?.color||S?.color||"#334155",A=i.appearance?.icon||S?.icon||"";let O=S?.label||"";const E=i.appearance?.sub_type,T=i.appearance?.scd;if(i.appearance?.type==="fact"&&E?O=`FACT (${{transaction:"Trans.",periodic:"Periodic",accumulating:"Accum.",factless:"Factless"}[E]||E})`:i.appearance?.type&&E?O=`${i.appearance.type.toUpperCase()} (${E})`:i.appearance?.type&&(O=i.appearance.type.toUpperCase()),T){const q=`SCD ${T.replace("type","T")}`;O=O?`${O} / ${q}`:q}const M=(q,U)=>{c(t,U.width,U.height)},R=(q,U)=>{if(!m)return"";const P=m.nodeId===t,$=m.handleType,K=!m.handleId?.includes("lin-");return P||U!==K?"handle-dim":$==="source"&&q==="target"||$==="target"&&q==="source"?"handle-pulse":"handle-dim"},z=(q,U)=>w&&U?{background:"#ef4444",cursor:"not-allowed",border:"1px solid #7f1d1d"}:{background:q,cursor:"crosshair"};return k.jsxs("div",{className:r?"animate-creation":"",style:{width:"100%",height:"100%",minWidth:"220px",position:"relative",cursor:"default"},children:[k.jsx(tz,{color:"#3b82f6",isVisible:y,minWidth:220,minHeight:40,onResizeEnd:M,handleStyle:{width:12,height:12,borderRadius:"50%",backgroundColor:"#3b82f6",border:"2px solid #ffffff",zIndex:100}}),O&&k.jsx("div",{style:{position:"absolute",top:"-12px",left:"12px",height:"14px",padding:"0 6px",backgroundColor:C,color:"#ffffff",fontSize:"8px",fontWeight:900,borderRadius:"4px 4px 0 0",display:"flex",alignItems:"center",justifyContent:"center",textTransform:"uppercase",letterSpacing:"0.05em",boxShadow:"0 -2px 4px rgba(0,0,0,0.1)",zIndex:1},children:O}),k.jsx(tr,{type:"target",position:Te.Top,id:`${t}-er-target-top`,className:R("target",!0),style:{...z(g==="dark"?"#94a3b8":"#64748b",h),width:"8px",height:"8px",zIndex:10,opacity:h?1:0,pointerEvents:h?"all":"none"}}),k.jsx(tr,{type:"target",position:Te.Left,id:`${t}-lin-target-left`,className:R("target",!1),style:{...z("#3b82f6",d),top:"50%",left:"-4px",width:"10px",height:"10px",zIndex:20,opacity:d?1:0,pointerEvents:d?"all":"none"}}),k.jsx(tr,{type:"source",position:Te.Right,id:`${t}-lin-source-right`,className:R("source",!1),style:{...z("#3b82f6",d),top:"50%",right:"-4px",width:"10px",height:"10px",zIndex:20,opacity:d?1:0,pointerEvents:d?"all":"none"}}),k.jsxs("div",{style:{width:"100%",height:"100%",backgroundColor:"var(--node-bg)",borderLeft:`2px solid ${y?"#3b82f6":"var(--border-main)"}`,borderRight:`2px solid ${y?"#3b82f6":"var(--border-main)"}`,borderBottom:`2px solid ${y?"#3b82f6":"var(--border-main)"}`,borderTop:`4px solid ${C}`,borderRadius:"8px",overflow:"hidden",color:"var(--text-primary)",boxShadow:y?"0 0 0 4px rgba(59, 130, 246, 0.2)":g==="dark"?"0 4px 6px -1px rgba(0, 0, 0, 0.3)":"0 4px 12px -2px rgba(0, 0, 0, 0.1)",fontFamily:"sans-serif",display:"flex",flexDirection:"column",transition:"background-color 0.3s, border-color 0.3s, color 0.3s"},children:[k.jsxs("div",{className:"table-drag-handle",style:{padding:"12px",backgroundColor:g==="dark"?"rgba(15, 23, 42, 0.8)":"rgba(241, 245, 249, 0.9)",borderBottom:x?"1px solid var(--border-main)":"none",flexShrink:0,cursor:"grab",display:"flex",flexDirection:"column",gap:"2px"},children:[k.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[A&&k.jsx("span",{style:{fontSize:"18px"},children:A}),k.jsx("div",{style:{fontSize:"16px",fontWeight:800,color:"var(--text-primary)",lineHeight:"1.2",wordBreak:"break-all"},children:i.name})]}),i.logical_name&&i.logical_name!==i.name&&k.jsx("div",{style:{fontSize:"11px",fontWeight:500,color:"var(--text-secondary)",paddingLeft:A?"26px":"0",opacity:.8},children:i.logical_name}),k.jsx("div",{title:i.physical_name||i.id,style:{fontSize:"9px",color:g==="dark"?"#94a3b8":"#64748b",fontFamily:"monospace",letterSpacing:"0.02em",paddingLeft:A?"26px":"0",marginTop:"2px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"100%"},children:i.physical_name||i.id})]}),x&&k.jsx("div",{className:"nodrag",style:{padding:"0",overflowY:"auto",flex:1,cursor:"default"},children:k.jsx("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"11px"},children:k.jsx("tbody",{children:i.columns.map((q,U)=>k.jsxs("tr",{className:"column-row",style:{borderBottom:"1px solid var(--border-main)",backgroundColor:u===q.id?g==="dark"?"rgba(30, 58, 138, 0.6)":"rgba(191, 219, 254, 0.4)":"transparent",position:"relative"},children:[k.jsxs("td",{style:{padding:"6px 12px",fontWeight:500,color:"var(--text-primary)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"350px",position:"relative"},children:[k.jsx(tr,{type:"target",position:Te.Left,id:`${t}-${q.id}-er-target-left`,className:`column-handle ${R("target",!0)}`,style:{...z("#3b82f6",h),left:"-4px",opacity:0,pointerEvents:h?"all":"none"}}),k.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[k.jsxs("span",{style:{color:"var(--text-secondary)",marginRight:"6px",fontSize:"9px",fontFamily:"monospace",width:"14px",textAlign:"right",opacity:.6},children:[U+1,"."]}),q.logical?.isPrimaryKey&&k.jsx("span",{style:{color:"#eab308",marginRight:"4px"},children:"🔑"}),q.logical?.isForeignKey&&k.jsx("span",{style:{marginRight:"4px"},children:"🔩"}),q.logical?.isPartitionKey&&k.jsx("span",{style:{marginRight:"4px"},children:"📂"}),q.logical?.isMetadata&&k.jsx("span",{style:{marginRight:"4px"},title:"Metadata/Audit Column",children:"🕒"}),q.logical?.additivity==="fully"&&k.jsx("span",{style:{color:"#4ade80",marginRight:"4px"},title:"Fully Additive",children:"Σ"}),q.logical?.additivity==="semi"&&k.jsx("span",{style:{color:"#fbbf24",marginRight:"4px"},title:"Semi-Additive",children:"Σ~"}),q.logical?.additivity==="non"&&k.jsx("span",{style:{color:"#f87171",marginRight:"4px"},title:"Non-Additive",children:"⊘"}),k.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis"},children:q.logical?.name||q.id})]})]}),k.jsxs("td",{style:{padding:"6px 12px",textAlign:"right",fontStyle:"italic",color:"var(--text-secondary)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"150px",position:"relative",opacity:.8},children:[q.logical?.type||"Unknown",k.jsx(tr,{type:"source",position:Te.Right,id:`${t}-${q.id}-er-source-right`,className:`column-handle ${R("source",!0)}`,style:{...z("#3b82f6",h),right:"-4px",opacity:0,pointerEvents:h?"all":"none"}})]})]},q.id))})})})]}),k.jsx(tr,{type:"source",position:Te.Bottom,id:`${t}-er-source-bottom`,className:R("source",!0),style:{...z(g==="dark"?"#94a3b8":"#64748b",h),width:"8px",height:"8px",zIndex:10,opacity:h?1:0,pointerEvents:h?"all":"none"}})]})},VW=j.memo(UW);const V8=(...t)=>t.filter((e,n,i)=>!!e&&e.trim()!==""&&i.indexOf(e)===n).join(" ").trim();const FW=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const $W=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,i)=>i?i.toUpperCase():n.toLowerCase());const m3=t=>{const e=$W(t);return e.charAt(0).toUpperCase()+e.slice(1)};var GW={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const YW=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0;return!1};const QW=j.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:i,className:r="",children:s,iconNode:o,...c},u)=>j.createElement("svg",{ref:u,...GW,width:e,height:e,stroke:t,strokeWidth:i?Number(n)*24/Number(e):n,className:V8("lucide",r),...!s&&!YW(c)&&{"aria-hidden":"true"},...c},[...o.map(([h,d])=>j.createElement(h,d)),...Array.isArray(s)?s:[s]]));const Qe=(t,e)=>{const n=j.forwardRef(({className:i,...r},s)=>j.createElement(QW,{ref:s,iconNode:e,className:V8(`lucide-${FW(m3(t))}`,`lucide-${t}`,i),...r}));return n.displayName=m3(t),n};const XW=[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]],W1=Qe("arrow-up-right",XW);const WW=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],tS=Qe("chevron-down",WW);const KW=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],ZW=Qe("chevron-left",KW);const JW=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],nS=Qe("chevron-right",JW);const eK=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],K1=Qe("circle-alert",eK);const tK=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],nK=Qe("circle-check",tK);const iK=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],F8=Qe("circle-question-mark",iK);const rK=[["path",{d:"M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3",key:"11bfej"}]],sK=Qe("command",rK);const aK=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],Go=Qe("database",aK);const oK=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],lK=Qe("eye",oK);const cK=[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M5 9v6",key:"158jrl"}],["circle",{cx:"5",cy:"18",r:"3",key:"104gr9"}],["path",{d:"M12 3v18",key:"108xh3"}],["circle",{cx:"19",cy:"6",r:"3",key:"108a5v"}],["path",{d:"M16 15.7A9 9 0 0 0 19 9",key:"1e3vqb"}]],g3=Qe("git-graph",cK);const uK=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]],fK=Qe("grid-3x3",uK);const hK=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],dK=Qe("grip-vertical",hK);const pK=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],mK=Qe("info",pK);const gK=[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"9",height:"7",x:"3",y:"14",rx:"1",key:"jqznyg"}],["rect",{width:"5",height:"7",x:"16",y:"14",rx:"1",key:"q5h2i8"}]],y3=Qe("layout-template",gK);const yK=[["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"M3 10a2 2 0 0 0 2 2h3",key:"1npucw"}],["path",{d:"M3 5v12a2 2 0 0 0 2 2h3",key:"x1gjn2"}]],vK=Qe("list-tree",yK);const bK=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],xK=Qe("loader-circle",bK);const wK=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]],SK=Qe("lock-open",wK);const CK=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],iS=Qe("lock",CK);const kK=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],AK=Qe("moon",kK);const _K=[["path",{d:"M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z",key:"edeuup"}]],OK=Qe("mouse-pointer-2",_K);const EK=[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m19 9 3 3-3 3",key:"1mg7y2"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m5 9-3 3 3 3",key:"j64kie"}],["path",{d:"m9 5 3-3 3 3",key:"l8vdw6"}]],TK=Qe("move",EK);const MK=[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]],RK=Qe("network",MK);const NK=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M9 21V9",key:"1oto5p"}]],v3=Qe("panels-top-left",NK);const DK=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],LK=Qe("pen-line",DK);const zK=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],BK=Qe("play",zK);const qK=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],rS=Qe("plus",qK);const jK=[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]],$8=Qe("redo-2",jK);const IK=[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}]],PK=Qe("refresh-ccw",IK);const HK=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],UK=Qe("save",HK);const VK=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],FK=Qe("search",VK);const $K=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],GK=Qe("sun",$K);const YK=[["path",{d:"M12 3v18",key:"108xh3"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}]],b3=Qe("table",YK);const QK=[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]],G8=Qe("tag",QK);const XK=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],Md=Qe("trash-2",XK);const WK=[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]],Y8=Qe("undo-2",WK);const KK=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Yo=Qe("x",KK),ZK=({id:t,data:e,selected:n})=>{const[i,r]=j.useState(!0);j.useEffect(()=>{const S=setTimeout(()=>r(!1),1e3);return()=>clearTimeout(S)},[]);const{updateNodeDimensions:s,theme:o,toggleDomainLock:c}=ci(),u=n,h=e.isLocked,d=e.color||"#3b82f6",m=o==="dark"?"rgba(15, 23, 42, 0.98)":"rgba(255, 255, 255, 0.98)",g=d,x=d.startsWith("rgba")||d.startsWith("hsla")||d.startsWith("#")&&d.length>7?1:.5,w=(S,C)=>{s(t,C.width,C.height)};return k.jsxs("div",{className:i?"animate-creation":"",style:{width:"100%",height:"100%",border:h?`2px solid ${o==="dark"?"#334155":"#cbd5e1"}`:`2px dashed ${u?"#3b82f6":o==="dark"?"#334155":"#cbd5e1"}`,borderRadius:"12px",padding:"10px",position:"relative",color:"var(--text-secondary)",cursor:"default",transition:"border-color 0.3s, opacity 0.3s",opacity:h?.8:1},children:[!h&&k.jsx(tz,{color:"#3b82f6",isVisible:u,minWidth:200,minHeight:150,onResizeEnd:w,handleStyle:{width:14,height:14,borderRadius:"50%",backgroundColor:"#3b82f6",border:"2px solid #ffffff",zIndex:100}}),k.jsx("div",{style:{position:"absolute",inset:0,backgroundColor:d,opacity:x,borderRadius:"10px",zIndex:-1,cursor:"default"}}),k.jsxs("div",{className:h?"domain-locked-handle":"domain-drag-handle",style:{position:"absolute",top:"-30px",left:"0",fontSize:"13px",fontWeight:"bold",color:o==="dark"?"#f1f5f9":"#0f172a",whiteSpace:"nowrap",pointerEvents:"all",cursor:h?"default":"grab",padding:"4px 12px 4px 10px",backgroundColor:m,borderRadius:"6px 6px 0 0",border:`1px solid ${u?"#3b82f6":o==="dark"?"#334155":"#cbd5e1"}`,borderLeft:`4px solid ${g}`,borderBottom:"none",transition:"all 0.2s ease",display:"flex",alignItems:"center",gap:"8px",boxShadow:o==="dark"?"0 -4px 12px rgba(0,0,0,0.4)":"0 -2px 8px rgba(0,0,0,0.08)",zIndex:10},children:[!h&&k.jsx(dK,{size:14,className:o==="dark"?"text-slate-400":"text-slate-500"}),k.jsx("span",{className:"truncate max-w-[200px]",children:e.label}),k.jsx("div",{className:`w-px h-3 mx-1 ${o==="dark"?"bg-slate-700":"bg-slate-200"}`}),k.jsx("button",{onClick:S=>{S.stopPropagation(),c(t)},className:`p-0.5 rounded transition-colors ${h?"text-amber-500 hover:text-amber-400":"text-slate-400 hover:text-blue-500"}`,title:h?"Unlock Domain":"Lock Domain",children:h?k.jsx(iS,{size:12}):k.jsx(SK,{size:12})})]})]})},JK=j.memo(ZK),eZ={fact:{color:"#f87171",icon:"📊",label:"FACT"},dimension:{color:"#60a5fa",icon:"🏷️",label:"DIM"},hub:{color:"#fbbf24",icon:"🌐",label:"HUB"},link:{color:"#34d399",icon:"🔗",label:"LINK"},satellite:{color:"#a78bfa",icon:"🛰️",label:"SAT"},mart:{color:"#f5700b",icon:"📈",label:"MART"},table:{color:"#64748b",icon:"📋",label:"TABLE"}},tZ=()=>{const{schema:t,selectedTableId:e,selectedEdgeId:n,getSelectedTable:i,getSelectedDomain:r,getSelectedRelationship:s,setSelectedTableId:o,setSelectedEdgeId:c,updateTable:u,updateDomain:h,updateRelationship:d,assignTableToDomain:m,theme:g}=ci(),y=i(),x=r(),w=s(),[S,C]=j.useState("conceptual"),[A,O]=j.useState(""),[E,T]=j.useState(400),[M,R]=j.useState(!1);if(j.useEffect(()=>{if(!M)return;const H=me=>{const ye=window.innerHeight-me.clientY;T(Math.max(150,Math.min(ye,window.innerHeight*.9)))},pe=()=>{R(!1),document.body.style.cursor="default"};return window.addEventListener("mousemove",H),window.addEventListener("mouseup",pe),()=>{window.removeEventListener("mousemove",H),window.removeEventListener("mouseup",pe)}},[M]),!e&&!n||!y&&!x&&!w)return null;const z=H=>{H.preventDefault(),R(!0),document.body.style.cursor="ns-resize"},q=H=>{H.stopPropagation()},U={height:`${E}px`,maxHeight:"90vh",minHeight:"150px",backgroundColor:"var(--node-bg)",borderTop:`2px solid ${g==="dark"?"#3b82f6":"#60a5fa"}`,display:"flex",flexDirection:"column",color:"var(--text-primary)",boxShadow:g==="dark"?"0 -10px 25px -5px rgba(0, 0, 0, 0.4)":"0 -4px 12px rgba(0, 0, 0, 0.05)",fontFamily:"sans-serif",position:"relative",transition:"background-color 0.3s, color 0.3s"},P=H=>{u(y.id,H)};if(w){const{relationship:H,index:pe}=w;return k.jsxs("div",{className:"shadow-2xl z-50 flex flex-col",onClick:q,onMouseDown:q,onPointerDown:q,style:U,children:[k.jsx("div",{onMouseDown:z,style:{position:"absolute",top:"-4px",left:0,right:0,height:"8px",cursor:"ns-resize",zIndex:60}}),k.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 20px",borderBottom:"1px solid var(--border-main)",backgroundColor:"var(--header-bg)"},children:[k.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",flex:1},children:[k.jsx(Go,{size:18,style:{color:"#3b82f6"}}),k.jsxs("div",{style:{flex:1},children:[k.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[k.jsx("span",{style:{fontSize:"14px",fontWeight:"bold"},children:"Relationship"}),k.jsx("span",{style:{fontSize:"9px",fontWeight:800,padding:"1px 5px",borderRadius:"3px",backgroundColor:"rgba(59, 130, 246, 0.1)",color:"#60a5fa",border:"1px solid rgba(59, 130, 246, 0.2)",textTransform:"uppercase"},children:"EDGE"})]}),k.jsxs("p",{style:{fontSize:"11px",color:"var(--text-secondary)",textTransform:"uppercase",margin:0},children:[H.from.table,H.from.column?`.${H.from.column}`:""," → ",H.to.table,H.to.column?`.${H.to.column}`:""]})]})]}),k.jsx("button",{onClick:()=>c(null),className:`p-1.5 rounded-full transition-colors ${g==="dark"?"hover:bg-slate-800 text-slate-500":"hover:bg-slate-200 text-slate-400"}`,children:k.jsx(Yo,{size:18})})]}),k.jsx("div",{style:{flex:1,overflowY:"auto",padding:"20px"},children:k.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"24px"},children:[k.jsxs("div",{className:"grid grid-cols-2 gap-8",children:[k.jsxs("section",{children:[k.jsx("h3",{className:"text-[11px] font-bold uppercase tracking-wider text-slate-500 mb-2",children:"Relationship Type"}),k.jsxs("select",{value:H.type||"one-to-many",onChange:me=>d(pe,{type:me.target.value}),className:`w-full border rounded text-sm p-2.5 outline-none transition-colors ${g==="dark"?"bg-slate-800 border-slate-700 text-slate-200 focus:ring-blue-500":"bg-white border-slate-200 text-slate-900 focus:ring-blue-400 focus:border-blue-400 shadow-sm"}`,children:[k.jsx("option",{value:"one-to-one",children:"One-to-One"}),k.jsx("option",{value:"one-to-many",children:"One-to-Many"}),k.jsx("option",{value:"many-to-one",children:"Many-to-One"}),k.jsx("option",{value:"many-to-many",children:"Many-to-Many"})]})]}),k.jsxs("section",{children:[k.jsx("h3",{className:"text-[11px] font-bold uppercase tracking-wider text-slate-500 mb-2",children:"Cardinality (Metadata)"}),k.jsxs("div",{className:"text-slate-500 text-sm",children:["Mapping established from ",k.jsx("strong",{children:H.from.table})," to ",k.jsx("strong",{children:H.to.table}),"."]})]})]}),k.jsxs("section",{children:[k.jsx("h3",{className:"text-[11px] font-bold uppercase tracking-wider text-slate-500 mb-2",children:"Source/Target Details"}),k.jsxs("div",{className:`flex gap-4 items-center p-3 rounded border ${g==="dark"?"bg-slate-800/50 border-slate-800":"bg-slate-50 border-slate-100"}`,children:[k.jsxs("div",{className:"flex-1",children:[k.jsx("div",{className:"text-[10px] text-slate-500 uppercase",children:"From Table"}),k.jsx("div",{className:`text-sm font-bold ${g==="dark"?"text-blue-400":"text-blue-600"}`,children:H.from.table}),k.jsxs("div",{className:"text-[10px] text-slate-500",children:["Column: ",H.from.column||"(Table level)"]})]}),k.jsx("div",{className:"text-slate-400 dark:text-slate-600",children:"→"}),k.jsxs("div",{className:"flex-1",children:[k.jsx("div",{className:"text-[10px] text-slate-500 uppercase",children:"To Table"}),k.jsx("div",{className:`text-sm font-bold ${g==="dark"?"text-blue-400":"text-blue-600"}`,children:H.to.table}),k.jsxs("div",{className:"text-[10px] text-slate-500",children:["Column: ",H.to.column||"(Table level)"]})]})]})]})]})})]})}if(x)return k.jsxs("div",{className:"shadow-2xl z-50 flex flex-col",onClick:q,onMouseDown:q,onPointerDown:q,style:{...U,borderTopColor:x.color||"#3b82f6"},children:[k.jsx("div",{onMouseDown:z,style:{position:"absolute",top:"-4px",left:0,right:0,height:"8px",cursor:"ns-resize",zIndex:60}}),k.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 20px",borderBottom:"1px solid var(--border-main)",backgroundColor:"var(--header-bg)"},children:[k.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",flex:1},children:[k.jsx(Go,{size:18,style:{color:x.color||"#3b82f6"}}),k.jsxs("div",{style:{flex:1},children:[k.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[k.jsx("input",{value:x.name??"",onChange:H=>h(x.id,{name:H.target.value}),onBlur:H=>{H.target.value||h(x.id,{name:"UNNAMED_DOMAIN"})},style:{fontSize:"16px",fontWeight:"bold",color:"var(--text-primary)",backgroundColor:"transparent",border:"none",borderBottom:"1px solid transparent",padding:"2px 0",outline:"none",width:"fit-content",minWidth:"200px"},onFocus:H=>H.target.style.borderBottom="1px solid #3b82f6"}),k.jsx("span",{style:{fontSize:"9px",fontWeight:800,padding:"1px 5px",borderRadius:"3px",backgroundColor:"rgba(59, 130, 246, 0.1)",color:"#60a5fa",border:"1px solid rgba(59, 130, 246, 0.2)",textTransform:"uppercase"},children:"DOMAIN"})]}),k.jsx("p",{style:{fontSize:"11px",color:"var(--text-secondary)",textTransform:"uppercase",margin:0},children:x.id})]})]}),k.jsx("button",{onClick:()=>o(null),className:`p-1.5 rounded-full transition-colors ${g==="dark"?"hover:bg-slate-800 text-slate-500":"hover:bg-slate-200 text-slate-400"}`,children:k.jsx(Yo,{size:18})})]}),k.jsx("div",{style:{flex:1,overflowY:"auto",padding:"20px"},children:k.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"20px"},children:[k.jsxs("section",{children:[k.jsx("h3",{className:"text-[11px] font-bold uppercase tracking-wider text-slate-500 mb-2",children:"Domain Description"}),k.jsx("textarea",{value:x.description||"",onChange:H=>h(x.id,{description:H.target.value}),placeholder:"What is the purpose of this domain?",style:{width:"100%",minHeight:"80px",backgroundColor:g==="dark"?"#0f172a":"#ffffff",border:"1px solid var(--border-main)",borderRadius:"6px",padding:"12px",color:"var(--text-primary)",fontSize:"13px",lineHeight:"1.6",resize:"none",outline:"none",transition:"background-color 0.3s"}})]}),k.jsxs("section",{children:[k.jsx("h3",{className:"text-[11px] font-bold uppercase tracking-wider text-slate-500 mb-2",children:"Domain Theme Color"}),k.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[k.jsx("input",{type:"color",value:x.color?.startsWith("rgba")?"#3b82f6":x.color||"#3b82f6",onChange:H=>h(x.id,{color:H.target.value}),style:{width:"40px",height:"40px",padding:0,border:"none",borderRadius:"4px",cursor:"pointer",backgroundColor:"transparent"}}),k.jsx("input",{value:x.color||"",onChange:H=>h(x.id,{color:H.target.value}),placeholder:"e.g. #3b82f6 or rgba(...)",className:`border rounded font-mono text-sm p-2 outline-none flex-1 transition-colors ${g==="dark"?"bg-slate-800 border-slate-700 text-slate-300 focus:ring-blue-500":"bg-white border-slate-200 text-slate-900 focus:ring-blue-400 focus:border-blue-400 shadow-sm"}`})]})]})]})})]});const $=[{id:"conceptual",label:"Conceptual",icon:k.jsx(G8,{size:14})},{id:"logical",label:"Logical",icon:k.jsx(Go,{size:14})},{id:"physical",label:"Physical",icon:k.jsx(Go,{size:14})},{id:"sample",label:"Sample Data",icon:k.jsx(b3,{size:14})}],K=y.appearance?.type?eZ[y.appearance.type]:null,L=y.appearance?.color||K?.color||"#334155",Y=y.appearance?.icon||K?.icon||"";let D=K?.label||"";const Q=y.appearance?.sub_type,ee=y.appearance?.scd;if(y.appearance?.type==="fact"&&Q?D=`FACT (${{transaction:"Trans.",periodic:"Periodic",accumulating:"Accum.",factless:"Factless"}[Q]||Q})`:y.appearance?.type&&Q?D=`${y.appearance.type.toUpperCase()} (${Q})`:y.appearance?.type&&(D=y.appearance.type.toUpperCase()),ee){const H=`SCD ${ee.replace("type","T")}`;D=D?`${D} / ${H}`:H}const G=H=>{H.stopPropagation();const pe={id:`col_${Date.now()}`,logical:{name:"New Column",type:"String",description:""},physical:{name:"",type:"VARCHAR(255)",constraints:[]}};P({columns:[...y.columns||[],pe]})},W=(H,pe)=>{H.stopPropagation();const me=y.columns?.filter(ye=>ye.id!==pe)||[];P({columns:me})},B=(H,pe)=>{const me=y.columns?.map(ye=>ye.id===H?{...ye,logical:{name:ye.logical?.name||ye.id,type:ye.logical?.type||"String",...ye.logical,...pe}}:ye)||[];P({columns:me})},F=(H,pe)=>{const me=y.columns?.map(ye=>ye.id===H?{...ye,physical:{...ye.physical,...pe}}:ye)||[];P({columns:me})},ne=H=>{if(H.key==="Enter"&&A.trim()){const pe=y.conceptual?.tags||[];pe.includes(A.trim())||P({conceptual:{...y.conceptual,tags:[...pe,A.trim()]}}),O("")}},I=(H,pe)=>{H.stopPropagation();const me=y.conceptual?.tags||[];P({conceptual:{...y.conceptual,tags:me.filter(ye=>ye!==pe)}})},X=H=>{P({sampleData:H})},J=H=>{H.stopPropagation();const pe=y.sampleData||[],me=y.columns?.length||0,ye=new Array(me).fill("");X([...pe,ye])},oe=(H,pe)=>{H.stopPropagation();const ye=(y.sampleData||[]).filter((_e,Ae)=>Ae!==pe);X(ye)},ve=(H,pe,me)=>{const ye=[...y.sampleData||[]];if(!ye[H])return;const _e=[...ye[H]];_e[pe]=me,ye[H]=_e,X(ye)};return k.jsxs("div",{className:"shadow-2xl z-50 flex flex-col",onClick:q,onMouseDown:q,onPointerDown:q,style:{...U,borderTopColor:L},children:[k.jsx("div",{onMouseDown:z,style:{position:"absolute",top:"-4px",left:0,right:0,height:"8px",cursor:"ns-resize",zIndex:60}}),k.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 20px",borderBottom:"1px solid var(--border-main)",backgroundColor:"var(--header-bg)"},children:[k.jsxs("div",{style:{flex:1},children:[k.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"4px"},children:[Y&&k.jsx("span",{style:{fontSize:"16px"},children:Y}),k.jsx("span",{style:{fontSize:"11px",color:"var(--text-secondary)",textTransform:"uppercase",fontFamily:"monospace",letterSpacing:"0.05em"},children:y.id}),D&&k.jsx("span",{style:{fontSize:"9px",fontWeight:800,padding:"1px 5px",borderRadius:"3px",backgroundColor:`${L}30`,color:L,border:`1px solid ${L}50`,textTransform:"uppercase"},children:D})]}),k.jsx("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:k.jsx("input",{value:y.name??"",onChange:H=>P({name:H.target.value}),onBlur:H=>{H.target.value||P({name:"UNNAMED_TABLE"})},title:"Conceptual Table Name",style:{fontSize:"18px",fontWeight:"bold",color:"var(--text-primary)",backgroundColor:"transparent",border:"none",borderBottom:"1px solid transparent",padding:"2px 0",outline:"none",width:"100%",maxWidth:"500px"},onFocus:H=>H.target.style.borderBottom="1px solid #3b82f6"})})]}),k.jsxs("div",{style:{display:"flex",gap:"8px",marginRight:"16px"},children:[k.jsxs("select",{value:y.appearance?.type||"fact",onChange:H=>P({appearance:{...y.appearance,type:H.target.value}}),className:`border rounded text-[10px] px-2 py-1 outline-none transition-colors ${g==="dark"?"bg-slate-800 border-slate-700 text-slate-300 focus:ring-blue-500":"bg-white border-slate-200 text-slate-900 focus:ring-blue-400 focus:border-blue-400"}`,title:"Table Type",children:[k.jsx("option",{value:"fact",children:"Fact"}),k.jsx("option",{value:"dimension",children:"Dimension"}),k.jsx("option",{value:"mart",children:"Mart"}),k.jsx("option",{value:"table",children:"Table"}),k.jsx("option",{value:"hub",children:"Hub"}),k.jsx("option",{value:"link",children:"Link"}),k.jsx("option",{value:"satellite",children:"Satellite"})]}),k.jsxs("select",{value:y.appearance?.sub_type||"",onChange:H=>P({appearance:{...y.appearance,sub_type:H.target.value||void 0}}),className:`border rounded text-[10px] px-2 py-1 outline-none transition-colors ${g==="dark"?"bg-slate-800 border-slate-700 text-slate-300 focus:ring-blue-500":"bg-white border-slate-200 text-slate-900 focus:ring-blue-400 focus:border-blue-400"}`,title:"Table Sub-type",children:[k.jsx("option",{value:"",children:"- Sub-type -"}),k.jsx("option",{value:"transaction",children:"Transaction"}),k.jsx("option",{value:"periodic",children:"Periodic Snapshot"}),k.jsx("option",{value:"accumulating",children:"Accumulating Snapshot"}),k.jsx("option",{value:"factless",children:"Factless"}),k.jsx("option",{value:"conformed",children:"Conformed"}),k.jsx("option",{value:"junk",children:"Junk"}),k.jsx("option",{value:"degenerate",children:"Degenerate"})]}),k.jsxs("select",{value:y.appearance?.scd||"",onChange:H=>P({appearance:{...y.appearance,scd:H.target.value||void 0}}),className:`border rounded text-[10px] px-2 py-1 outline-none transition-colors ${g==="dark"?"bg-slate-800 border-slate-700 text-slate-300 focus:ring-blue-500":"bg-white border-slate-200 text-slate-900 focus:ring-blue-400 focus:border-blue-400"}`,title:"SCD Type",children:[k.jsx("option",{value:"",children:"- SCD Type -"}),k.jsx("option",{value:"type0",children:"SCD Type 0"}),k.jsx("option",{value:"type1",children:"SCD Type 1"}),k.jsx("option",{value:"type2",children:"SCD Type 2"}),k.jsx("option",{value:"type3",children:"SCD Type 3"}),k.jsx("option",{value:"type4",children:"SCD Type 4"}),k.jsx("option",{value:"type5",children:"SCD Type 5"}),k.jsx("option",{value:"type6",children:"SCD Type 6"}),k.jsx("option",{value:"type7",children:"SCD Type 7"})]})]}),k.jsx("button",{onClick:H=>{H.stopPropagation(),o(null)},className:`p-1.5 rounded-full transition-colors ${g==="dark"?"hover:bg-slate-800 text-slate-500":"hover:bg-slate-200 text-slate-400"}`,children:k.jsx(Yo,{size:18})})]}),k.jsx("div",{style:{display:"flex",gap:"24px",padding:"0 20px",borderBottom:"1px solid var(--border-main)",backgroundColor:"var(--header-bg)"},children:$.map(H=>k.jsxs("button",{onClick:pe=>{pe.stopPropagation(),C(H.id)},style:{padding:"12px 0",backgroundColor:"transparent",border:"none",borderBottom:S===H.id?"2px solid #3b82f6":"2px solid transparent",color:S===H.id?g==="dark"?"#60a5fa":"#2563eb":"var(--text-secondary)",fontSize:"13px",fontWeight:500,cursor:"pointer",display:"flex",alignItems:"center",gap:"6px",transition:"all 0.2s"},children:[H.icon," ",H.label]},H.id))}),k.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"15px 20px"},children:[S==="conceptual"&&k.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"20px"},children:[k.jsxs("section",{children:[k.jsx("h3",{className:"text-[11px] font-bold uppercase tracking-wider text-slate-500 mb-2",children:"Description"}),k.jsx("textarea",{value:y.conceptual?.description||"",onChange:H=>P({conceptual:{...y.conceptual,description:H.target.value}}),placeholder:"Enter business description...",style:{width:"100%",minHeight:"100px",backgroundColor:g==="dark"?"#0f172a":"#ffffff",border:"1px solid var(--border-main)",borderRadius:"6px",padding:"12px",color:"var(--text-primary)",fontSize:"13px",lineHeight:"1.6",resize:"none",outline:"none",transition:"background-color 0.3s"}})]}),k.jsxs("section",{children:[k.jsx("h3",{className:"text-[11px] font-bold uppercase tracking-wider text-slate-500 mb-2",children:"Domain Assignment"}),k.jsxs("select",{value:t?.domains?.find(H=>H.tables.includes(y.id))?.id||"",onChange:H=>m(y.id,H.target.value||null),className:`w-full border rounded text-sm p-2 outline-none transition-colors ${g==="dark"?"bg-slate-800 border-slate-700 text-slate-200 focus:ring-blue-500":"bg-white border-slate-200 text-slate-900 focus:ring-blue-400 focus:border-blue-400 shadow-sm"}`,children:[k.jsx("option",{value:"",children:"- No Domain -"}),t?.domains?.map(H=>k.jsxs("option",{value:H.id,children:[H.name," (",H.id,")"]},H.id))]})]}),k.jsxs("section",{children:[k.jsx("h3",{className:"text-[11px] font-bold uppercase tracking-wider text-slate-500 mb-2",children:"Tags"}),k.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",alignItems:"center"},children:[y.conceptual?.tags?.map(H=>k.jsxs("span",{className:`flex items-center gap-2 px-3 py-1 border rounded-full text-xs font-medium transition-colors ${g==="dark"?"bg-blue-500/10 text-blue-400 border-blue-500/20":"bg-blue-50 text-blue-600 border-blue-100"}`,children:[H,k.jsx("button",{onClick:pe=>I(pe,H),className:"hover:text-red-500 transition-colors",children:k.jsx(Yo,{size:12})})]},H)),k.jsx("div",{style:{position:"relative"},children:k.jsx("input",{type:"text",value:A,onChange:H=>O(H.target.value),onKeyDown:ne,placeholder:"+ New Tag",style:{backgroundColor:"transparent",border:"1px dashed var(--border-main)",borderRadius:"16px",padding:"4px 12px",fontSize:"11px",color:"var(--text-primary)",outline:"none",width:"100px"}})})]})]})]}),S==="logical"&&k.jsxs("div",{children:[k.jsxs("div",{className:"flex flex-col gap-4 mb-6",children:[k.jsxs("section",{children:[k.jsx("h3",{className:"text-[11px] font-bold uppercase tracking-wider text-slate-500 mb-2",children:"Logical Table Name"}),k.jsx("input",{value:y.logical_name||"",onChange:H=>P({logical_name:H.target.value}),placeholder:y.name,className:`w-full border rounded text-sm p-2 outline-none transition-colors ${g==="dark"?"bg-slate-800 border-slate-700 text-slate-200 focus:ring-blue-500":"bg-white border-slate-200 text-slate-900 focus:ring-blue-400 focus:border-blue-400 shadow-sm"}`})]}),k.jsxs("div",{className:"flex justify-between items-center",children:[k.jsx("h3",{className:"text-[11px] font-bold uppercase tracking-wider text-slate-500",children:"Logical Schema (Columns)"}),k.jsxs("button",{onClick:G,className:"flex items-center gap-2 px-3 py-1.5 bg-blue-600 hover:bg-blue-700 text-white rounded text-xs transition-colors shadow-md shadow-blue-500/20 font-medium",children:[k.jsx(rS,{size:14})," Add Column"]})]})]}),k.jsx("div",{style:{border:"1px solid var(--border-main)",borderRadius:"8px",overflow:"hidden"},children:k.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"12px"},children:[k.jsx("thead",{style:{backgroundColor:"var(--header-bg)",borderBottom:"1px solid var(--border-main)",textAlign:"left"},children:k.jsxs("tr",{children:[k.jsx("th",{style:{padding:"10px 16px",color:"var(--text-secondary)",width:"35%"},children:"Logical Name"}),k.jsx("th",{style:{padding:"10px 16px",color:"var(--text-secondary)",width:"15%"},children:"Role"}),k.jsx("th",{style:{padding:"10px 16px",color:"var(--text-secondary)",width:"15%"},children:"Type"}),k.jsx("th",{style:{padding:"10px 16px",color:"var(--text-secondary)",width:"30%"},children:"Description"}),k.jsx("th",{style:{padding:"10px 16px",width:"50px"}})]})}),k.jsx("tbody",{children:(y.columns||[]).map(H=>k.jsxs("tr",{style:{borderBottom:"1px solid var(--border-main)",backgroundColor:"var(--node-bg)"},children:[k.jsx("td",{style:{padding:"6px 16px"},children:k.jsxs("div",{className:"flex items-center gap-2",children:[k.jsx("button",{onClick:()=>B(H.id,{isPrimaryKey:!H.logical?.isPrimaryKey}),title:"Primary Key",className:`transition-opacity ${H.logical?.isPrimaryKey?"opacity-100":"opacity-20 hover:opacity-50"}`,children:"🔑"}),k.jsx("input",{value:H.logical?.name??"",onChange:pe=>B(H.id,{name:pe.target.value}),onBlur:pe=>{pe.target.value||B(H.id,{name:H.id})},className:`bg-transparent border-none w-full outline-none p-1 rounded font-medium transition-colors ${g==="dark"?"text-white focus:bg-slate-800":"text-slate-900 focus:bg-slate-50"}`})]})}),k.jsx("td",{style:{padding:"6px 16px"},children:k.jsxs("div",{className:"flex items-center gap-2",children:[k.jsx("button",{onClick:()=>B(H.id,{isMetadata:!H.logical?.isMetadata}),title:"Metadata/Audit",className:`transition-opacity text-sm ${H.logical?.isMetadata?"opacity-100":"opacity-20 hover:opacity-50"}`,children:"🕒"}),k.jsxs("select",{value:H.logical?.additivity||"",onChange:pe=>B(H.id,{additivity:pe.target.value||void 0}),title:"Additivity (for Measures)",style:{fontSize:"10px"},className:`border rounded outline-none transition-colors ${g==="dark"?"bg-slate-800 border-slate-700 text-slate-400":"bg-white border-slate-200 text-slate-600"}`,children:[k.jsx("option",{value:"",children:"-"}),k.jsx("option",{value:"fully",children:"Σ (Full)"}),k.jsx("option",{value:"semi",children:"Σ~ (Semi)"}),k.jsx("option",{value:"non",children:"⊘ (Non)"})]})]})}),k.jsx("td",{style:{padding:"6px 16px"},children:k.jsx("input",{value:H.logical?.type??"",onChange:pe=>B(H.id,{type:pe.target.value}),onBlur:pe=>{pe.target.value||B(H.id,{type:"String"})},placeholder:"Type...",className:`bg-transparent border-none font-mono text-[11px] w-full outline-none p-1 rounded transition-colors ${g==="dark"?"text-slate-400 focus:bg-slate-800":"text-slate-500 focus:bg-slate-50"}`})}),k.jsx("td",{style:{padding:"6px 16px"},children:k.jsx("input",{value:H.logical?.description||"",onChange:pe=>B(H.id,{description:pe.target.value}),placeholder:"Description...",className:`bg-transparent border-none text-[11px] w-full outline-none p-1 rounded transition-colors ${g==="dark"?"text-slate-500 focus:bg-slate-800":"text-slate-400 focus:bg-slate-50"}`})}),k.jsx("td",{style:{padding:"6px 16px",textAlign:"right"},children:k.jsx("button",{onClick:pe=>W(pe,H.id),className:"text-red-500/50 hover:text-red-500 p-1 transition-colors",children:k.jsx(Md,{size:14})})})]},H.id))})]})})]}),S==="physical"&&k.jsxs("div",{children:[k.jsxs("div",{className:"flex flex-col gap-4 mb-6",children:[k.jsxs("section",{children:[k.jsx("h3",{className:"text-[11px] font-bold uppercase tracking-wider text-slate-500 mb-2",children:"Physical Table Name"}),k.jsx("input",{value:y.physical_name||"",onChange:H=>P({physical_name:H.target.value}),placeholder:y.id,className:`w-full border rounded font-mono text-sm p-2 outline-none transition-colors ${g==="dark"?"bg-slate-800 border-slate-700 text-slate-300 focus:ring-blue-500":"bg-white border-slate-200 text-slate-900 focus:ring-blue-400 focus:border-blue-400 shadow-sm"}`})]}),k.jsx("div",{className:"flex justify-between items-center",children:k.jsx("h3",{className:"text-[11px] font-bold uppercase tracking-wider text-slate-500",children:"Physical Mappings"})})]}),k.jsx("div",{style:{border:"1px solid var(--border-main)",borderRadius:"8px",overflow:"hidden"},children:k.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"12px"},children:[k.jsx("thead",{style:{backgroundColor:"var(--header-bg)",borderBottom:"1px solid var(--border-main)",textAlign:"left"},children:k.jsxs("tr",{children:[k.jsx("th",{style:{padding:"10px 16px",color:"var(--text-secondary)",width:"25%"},children:"Logical Column"}),k.jsx("th",{style:{padding:"10px 16px",color:"var(--text-secondary)",width:"30%"},children:"DB Column Name"}),k.jsx("th",{style:{padding:"10px 16px",color:"var(--text-secondary)",width:"20%"},children:"DB Type"}),k.jsx("th",{style:{padding:"10px 16px",color:"var(--text-secondary)",width:"25%"},children:"Constraints"})]})}),k.jsx("tbody",{children:(y.columns||[]).map(H=>k.jsxs("tr",{style:{borderBottom:"1px solid var(--border-main)",backgroundColor:"var(--node-bg)"},children:[k.jsx("td",{style:{padding:"6px 16px",color:"var(--text-secondary)",borderRight:"1px solid var(--border-main)"},children:k.jsx("div",{className:"text-[11px] font-medium truncate",title:H.logical?.name||H.id,children:H.logical?.name||H.id})}),k.jsx("td",{style:{padding:"6px 16px"},children:k.jsx("input",{value:H.physical?.name??"",onChange:pe=>F(H.id,{name:pe.target.value}),placeholder:H.logical?.name.toLowerCase().replace(/ /g,"_"),className:`bg-transparent border-none font-mono text-[11px] w-full outline-none p-1 rounded transition-colors ${g==="dark"?"text-blue-400 focus:bg-slate-800":"text-blue-600 focus:bg-slate-50"}`})}),k.jsx("td",{style:{padding:"6px 16px"},children:k.jsx("input",{value:H.physical?.type??"",onChange:pe=>F(H.id,{type:pe.target.value}),placeholder:H.logical?.type.toUpperCase(),className:`bg-transparent border-none font-mono text-[11px] w-full outline-none p-1 rounded transition-colors ${g==="dark"?"text-slate-400 focus:bg-slate-800":"text-slate-500 focus:bg-slate-50"}`})}),k.jsx("td",{style:{padding:"6px 16px"},children:k.jsx("input",{value:H.physical?.constraints?.join(", ")||"",onChange:pe=>F(H.id,{constraints:pe.target.value.split(",").map(me=>me.trim()).filter(Boolean)}),placeholder:"e.g. NOT NULL",className:`bg-transparent border-none text-[11px] w-full outline-none p-1 rounded transition-colors ${g==="dark"?"text-slate-500 focus:bg-slate-800":"text-slate-400 focus:bg-slate-50"}`})})]},H.id))})]})})]}),S==="sample"&&k.jsxs("div",{className:"flex flex-col h-full",children:[k.jsxs("div",{className:"flex justify-between items-center mb-4",children:[k.jsx("h3",{className:"text-[11px] font-bold uppercase tracking-wider text-slate-500",children:"Sample Data Editor"}),k.jsx("div",{className:"flex gap-2",children:k.jsxs("button",{onClick:J,disabled:!y.columns||y.columns.length===0,className:`flex items-center gap-2 px-3 py-1.5 text-white rounded text-xs transition-colors font-medium shadow-md ${!y.columns||y.columns.length===0?"bg-slate-300 dark:bg-slate-700 cursor-not-allowed opacity-50":"bg-emerald-600 hover:bg-emerald-700 shadow-emerald-500/20"}`,children:[k.jsx(rS,{size:14})," Add Row"]})})]}),!y.columns||y.columns.length===0?k.jsxs("div",{className:`flex-1 flex flex-col items-center justify-center p-8 rounded-lg border border-dashed transition-colors ${g==="dark"?"bg-slate-900/50 border-slate-800":"bg-slate-50 border-slate-200"}`,children:[k.jsx(b3,{size:32,className:`${g==="dark"?"text-slate-700":"text-slate-300"} mb-4`}),k.jsx("p",{className:"text-sm text-slate-500 mb-1",children:"No columns defined yet."}),k.jsx("p",{className:"text-xs text-slate-400 italic",children:'Add columns in the "Logical" tab first to enable sample data.'})]}):k.jsx("div",{className:`flex-1 overflow-auto border rounded-lg shadow-inner transition-colors ${g==="dark"?"border-slate-800 bg-slate-950/20":"border-slate-200 bg-white"}`,children:k.jsxs("table",{className:"w-full border-collapse text-xs",children:[k.jsx("thead",{className:`sticky top-0 z-10 border-b transition-colors ${g==="dark"?"bg-slate-950 border-slate-800":"bg-slate-100 border-slate-200"}`,children:k.jsxs("tr",{children:[(y.columns||[]).map(H=>k.jsx("th",{className:`p-3 text-left border-r min-w-[140px] transition-colors ${g==="dark"?"border-slate-800":"border-slate-200"}`,children:k.jsxs("div",{className:"flex flex-col gap-0.5",children:[k.jsx("span",{className:`font-bold ${g==="dark"?"text-slate-200":"text-slate-700"}`,children:H?.logical?.name||H.id}),k.jsx("span",{className:`text-[10px] font-mono italic ${g==="dark"?"text-blue-400":"text-blue-600"}`,children:H?.physical?.name||H?.logical?.name?.toLowerCase().replace(/ /g,"_")||H.id})]})},H.id)),k.jsx("th",{className:`w-10 transition-colors ${g==="dark"?"bg-slate-950":"bg-slate-100"}`})]})}),k.jsxs("tbody",{children:[(y.sampleData||[]).map((H,pe)=>k.jsxs("tr",{className:`border-b transition-colors ${g==="dark"?"border-slate-800 hover:bg-slate-800/30":"border-slate-100 hover:bg-slate-50"}`,children:[(y.columns||[]).map((me,ye)=>k.jsx("td",{className:`p-0 border-r transition-colors ${g==="dark"?"border-slate-800":"border-slate-200"}`,children:k.jsx("input",{value:String(H[ye]??""),onChange:_e=>ve(pe,ye,_e.target.value),className:`w-full bg-transparent border-none p-3 outline-none font-mono transition-colors ${g==="dark"?"focus:bg-slate-800 text-slate-300":"focus:bg-blue-50 text-slate-700"}`})},me.id)),k.jsx("td",{className:"p-2 text-center",children:k.jsx("button",{onClick:me=>oe(me,pe),className:"text-slate-400 hover:text-red-500 transition-colors",children:k.jsx(Md,{size:12})})})]},pe)),(!y.sampleData||y.sampleData.length===0)&&k.jsx("tr",{children:k.jsx("td",{colSpan:(y.columns?.length||0)+1,className:`p-8 text-center text-slate-400 italic transition-colors ${g==="dark"?"bg-slate-900/20":"bg-slate-50"}`,children:'No rows defined. Click "Add Row" to start.'})})]})]})})]})]})]})};function Gr(t,e,{checkForDefaultPrevented:n=!0}={}){return function(r){if(t?.(r),n===!1||!r.defaultPrevented)return e?.(r)}}function K2(t,e=[]){let n=[];function i(s,o){const c=j.createContext(o),u=n.length;n=[...n,o];const h=m=>{const{scope:g,children:y,...x}=m,w=g?.[t]?.[u]||c,S=j.useMemo(()=>x,Object.values(x));return k.jsx(w.Provider,{value:S,children:y})};h.displayName=s+"Provider";function d(m,g){const y=g?.[t]?.[u]||c,x=j.useContext(y);if(x)return x;if(o!==void 0)return o;throw new Error(`\`${m}\` must be used within \`${s}\``)}return[h,d]}const r=()=>{const s=n.map(o=>j.createContext(o));return function(c){const u=c?.[t]||s;return j.useMemo(()=>({[`__scope${t}`]:{...c,[t]:u}}),[c,u])}};return r.scopeName=t,[i,nZ(r,...e)]}function nZ(...t){const e=t[0];if(t.length===1)return e;const n=()=>{const i=t.map(r=>({useScope:r(),scopeName:r.scopeName}));return function(s){const o=i.reduce((c,{useScope:u,scopeName:h})=>{const m=u(s)[`__scope${h}`];return{...c,...m}},{});return j.useMemo(()=>({[`__scope${e.scopeName}`]:o}),[o])}};return n.scopeName=e.scopeName,n}function x3(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function Z2(...t){return e=>{let n=!1;const i=t.map(r=>{const s=x3(r,e);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let r=0;r<i.length;r++){const s=i[r];typeof s=="function"?s():x3(t[r],null)}}}}function Rd(...t){return j.useCallback(Z2(...t),t)}function w3(t){const e=iZ(t),n=j.forwardRef((i,r)=>{const{children:s,...o}=i,c=j.Children.toArray(s),u=c.find(sZ);if(u){const h=u.props.children,d=c.map(m=>m===u?j.Children.count(h)>1?j.Children.only(null):j.isValidElement(h)?h.props.children:null:m);return k.jsx(e,{...o,ref:r,children:j.isValidElement(h)?j.cloneElement(h,void 0,d):null})}return k.jsx(e,{...o,ref:r,children:s})});return n.displayName=`${t}.Slot`,n}function iZ(t){const e=j.forwardRef((n,i)=>{const{children:r,...s}=n;if(j.isValidElement(r)){const o=oZ(r),c=aZ(s,r.props);return r.type!==j.Fragment&&(c.ref=i?Z2(i,o):o),j.cloneElement(r,c)}return j.Children.count(r)>1?j.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var rZ=Symbol("radix.slottable");function sZ(t){return j.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===rZ}function aZ(t,e){const n={...e};for(const i in e){const r=t[i],s=e[i];/^on[A-Z]/.test(i)?r&&s?n[i]=(...c)=>{const u=s(...c);return r(...c),u}:r&&(n[i]=r):i==="style"?n[i]={...r,...s}:i==="className"&&(n[i]=[r,s].filter(Boolean).join(" "))}return{...t,...n}}function oZ(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}function lZ(t){const e=t+"CollectionProvider",[n,i]=K2(e),[r,s]=n(e,{collectionRef:{current:null},itemMap:new Map}),o=w=>{const{scope:S,children:C}=w,A=ce.useRef(null),O=ce.useRef(new Map).current;return k.jsx(r,{scope:S,itemMap:O,collectionRef:A,children:C})};o.displayName=e;const c=t+"CollectionSlot",u=w3(c),h=ce.forwardRef((w,S)=>{const{scope:C,children:A}=w,O=s(c,C),E=Rd(S,O.collectionRef);return k.jsx(u,{ref:E,children:A})});h.displayName=c;const d=t+"CollectionItemSlot",m="data-radix-collection-item",g=w3(d),y=ce.forwardRef((w,S)=>{const{scope:C,children:A,...O}=w,E=ce.useRef(null),T=Rd(S,E),M=s(d,C);return ce.useEffect(()=>(M.itemMap.set(E,{ref:E,...O}),()=>{M.itemMap.delete(E)})),k.jsx(g,{[m]:"",ref:T,children:A})});y.displayName=d;function x(w){const S=s(t+"CollectionConsumer",w);return ce.useCallback(()=>{const A=S.collectionRef.current;if(!A)return[];const O=Array.from(A.querySelectorAll(`[${m}]`));return Array.from(S.itemMap.values()).sort((M,R)=>O.indexOf(M.ref.current)-O.indexOf(R.ref.current))},[S.collectionRef,S.itemMap])}return[{Provider:o,Slot:h,ItemSlot:y},x,i]}var Nd=globalThis?.document?j.useLayoutEffect:()=>{},cZ=T4[" useId ".trim().toString()]||(()=>{}),uZ=0;function Q8(t){const[e,n]=j.useState(cZ());return Nd(()=>{n(i=>i??String(uZ++))},[t]),e?`radix-${e}`:""}function fZ(t){const e=hZ(t),n=j.forwardRef((i,r)=>{const{children:s,...o}=i,c=j.Children.toArray(s),u=c.find(pZ);if(u){const h=u.props.children,d=c.map(m=>m===u?j.Children.count(h)>1?j.Children.only(null):j.isValidElement(h)?h.props.children:null:m);return k.jsx(e,{...o,ref:r,children:j.isValidElement(h)?j.cloneElement(h,void 0,d):null})}return k.jsx(e,{...o,ref:r,children:s})});return n.displayName=`${t}.Slot`,n}function hZ(t){const e=j.forwardRef((n,i)=>{const{children:r,...s}=n;if(j.isValidElement(r)){const o=gZ(r),c=mZ(s,r.props);return r.type!==j.Fragment&&(c.ref=i?Z2(i,o):o),j.cloneElement(r,c)}return j.Children.count(r)>1?j.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var dZ=Symbol("radix.slottable");function pZ(t){return j.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===dZ}function mZ(t,e){const n={...e};for(const i in e){const r=t[i],s=e[i];/^on[A-Z]/.test(i)?r&&s?n[i]=(...c)=>{const u=s(...c);return r(...c),u}:r&&(n[i]=r):i==="style"?n[i]={...r,...s}:i==="className"&&(n[i]=[r,s].filter(Boolean).join(" "))}return{...t,...n}}function gZ(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var yZ=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],_l=yZ.reduce((t,e)=>{const n=fZ(`Primitive.${e}`),i=j.forwardRef((r,s)=>{const{asChild:o,...c}=r,u=o?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),k.jsx(u,{...c,ref:s})});return i.displayName=`Primitive.${e}`,{...t,[e]:i}},{});function vZ(t){const e=j.useRef(t);return j.useEffect(()=>{e.current=t}),j.useMemo(()=>(...n)=>e.current?.(...n),[])}var bZ=T4[" useInsertionEffect ".trim().toString()]||Nd;function X8({prop:t,defaultProp:e,onChange:n=()=>{},caller:i}){const[r,s,o]=xZ({defaultProp:e,onChange:n}),c=t!==void 0,u=c?t:r;{const d=j.useRef(t!==void 0);j.useEffect(()=>{const m=d.current;m!==c&&console.warn(`${i} is changing from ${m?"controlled":"uncontrolled"} to ${c?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=c},[c,i])}const h=j.useCallback(d=>{if(c){const m=wZ(d)?d(t):d;m!==t&&o.current?.(m)}else s(d)},[c,t,s,o]);return[u,h]}function xZ({defaultProp:t,onChange:e}){const[n,i]=j.useState(t),r=j.useRef(n),s=j.useRef(e);return bZ(()=>{s.current=e},[e]),j.useEffect(()=>{r.current!==n&&(s.current?.(n),r.current=n)},[n,r]),[n,i,s]}function wZ(t){return typeof t=="function"}var SZ=j.createContext(void 0);function W8(t){const e=j.useContext(SZ);return t||e||"ltr"}var Z1="rovingFocusGroup.onEntryFocus",CZ={bubbles:!1,cancelable:!0},Iu="RovingFocusGroup",[sS,K8,kZ]=lZ(Iu),[AZ,Z8]=K2(Iu,[kZ]),[_Z,OZ]=AZ(Iu),J8=j.forwardRef((t,e)=>k.jsx(sS.Provider,{scope:t.__scopeRovingFocusGroup,children:k.jsx(sS.Slot,{scope:t.__scopeRovingFocusGroup,children:k.jsx(EZ,{...t,ref:e})})}));J8.displayName=Iu;var EZ=j.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,orientation:i,loop:r=!1,dir:s,currentTabStopId:o,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:u,onEntryFocus:h,preventScrollOnEntryFocus:d=!1,...m}=t,g=j.useRef(null),y=Rd(e,g),x=W8(s),[w,S]=X8({prop:o,defaultProp:c??null,onChange:u,caller:Iu}),[C,A]=j.useState(!1),O=vZ(h),E=K8(n),T=j.useRef(!1),[M,R]=j.useState(0);return j.useEffect(()=>{const z=g.current;if(z)return z.addEventListener(Z1,O),()=>z.removeEventListener(Z1,O)},[O]),k.jsx(_Z,{scope:n,orientation:i,dir:x,loop:r,currentTabStopId:w,onItemFocus:j.useCallback(z=>S(z),[S]),onItemShiftTab:j.useCallback(()=>A(!0),[]),onFocusableItemAdd:j.useCallback(()=>R(z=>z+1),[]),onFocusableItemRemove:j.useCallback(()=>R(z=>z-1),[]),children:k.jsx(_l.div,{tabIndex:C||M===0?-1:0,"data-orientation":i,...m,ref:y,style:{outline:"none",...t.style},onMouseDown:Gr(t.onMouseDown,()=>{T.current=!0}),onFocus:Gr(t.onFocus,z=>{const q=!T.current;if(z.target===z.currentTarget&&q&&!C){const U=new CustomEvent(Z1,CZ);if(z.currentTarget.dispatchEvent(U),!U.defaultPrevented){const P=E().filter(D=>D.focusable),$=P.find(D=>D.active),K=P.find(D=>D.id===w),Y=[$,K,...P].filter(Boolean).map(D=>D.ref.current);nB(Y,d)}}T.current=!1}),onBlur:Gr(t.onBlur,()=>A(!1))})})}),eB="RovingFocusGroupItem",tB=j.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,focusable:i=!0,active:r=!1,tabStopId:s,children:o,...c}=t,u=Q8(),h=s||u,d=OZ(eB,n),m=d.currentTabStopId===h,g=K8(n),{onFocusableItemAdd:y,onFocusableItemRemove:x,currentTabStopId:w}=d;return j.useEffect(()=>{if(i)return y(),()=>x()},[i,y,x]),k.jsx(sS.ItemSlot,{scope:n,id:h,focusable:i,active:r,children:k.jsx(_l.span,{tabIndex:m?0:-1,"data-orientation":d.orientation,...c,ref:e,onMouseDown:Gr(t.onMouseDown,S=>{i?d.onItemFocus(h):S.preventDefault()}),onFocus:Gr(t.onFocus,()=>d.onItemFocus(h)),onKeyDown:Gr(t.onKeyDown,S=>{if(S.key==="Tab"&&S.shiftKey){d.onItemShiftTab();return}if(S.target!==S.currentTarget)return;const C=RZ(S,d.orientation,d.dir);if(C!==void 0){if(S.metaKey||S.ctrlKey||S.altKey||S.shiftKey)return;S.preventDefault();let O=g().filter(E=>E.focusable).map(E=>E.ref.current);if(C==="last")O.reverse();else if(C==="prev"||C==="next"){C==="prev"&&O.reverse();const E=O.indexOf(S.currentTarget);O=d.loop?NZ(O,E+1):O.slice(E+1)}setTimeout(()=>nB(O))}}),children:typeof o=="function"?o({isCurrentTabStop:m,hasTabStop:w!=null}):o})})});tB.displayName=eB;var TZ={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function MZ(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function RZ(t,e,n){const i=MZ(t.key,n);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(i))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(i)))return TZ[i]}function nB(t,e=!1){const n=document.activeElement;for(const i of t)if(i===n||(i.focus({preventScroll:e}),document.activeElement!==n))return}function NZ(t,e){return t.map((n,i)=>t[(e+i)%t.length])}var DZ=J8,LZ=tB;function zZ(t,e){return j.useReducer((n,i)=>e[n][i]??n,t)}var iB=t=>{const{present:e,children:n}=t,i=BZ(e),r=typeof n=="function"?n({present:i.isPresent}):j.Children.only(n),s=Rd(i.ref,qZ(r));return typeof n=="function"||i.isPresent?j.cloneElement(r,{ref:s}):null};iB.displayName="Presence";function BZ(t){const[e,n]=j.useState(),i=j.useRef(null),r=j.useRef(t),s=j.useRef("none"),o=t?"mounted":"unmounted",[c,u]=zZ(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return j.useEffect(()=>{const h=Th(i.current);s.current=c==="mounted"?h:"none"},[c]),Nd(()=>{const h=i.current,d=r.current;if(d!==t){const g=s.current,y=Th(h);t?u("MOUNT"):y==="none"||h?.display==="none"?u("UNMOUNT"):u(d&&g!==y?"ANIMATION_OUT":"UNMOUNT"),r.current=t}},[t,u]),Nd(()=>{if(e){let h;const d=e.ownerDocument.defaultView??window,m=y=>{const w=Th(i.current).includes(CSS.escape(y.animationName));if(y.target===e&&w&&(u("ANIMATION_END"),!r.current)){const S=e.style.animationFillMode;e.style.animationFillMode="forwards",h=d.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=S)})}},g=y=>{y.target===e&&(s.current=Th(i.current))};return e.addEventListener("animationstart",g),e.addEventListener("animationcancel",m),e.addEventListener("animationend",m),()=>{d.clearTimeout(h),e.removeEventListener("animationstart",g),e.removeEventListener("animationcancel",m),e.removeEventListener("animationend",m)}}else u("ANIMATION_END")},[e,u]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:j.useCallback(h=>{i.current=h?getComputedStyle(h):null,n(h)},[])}}function Th(t){return t?.animationName||"none"}function qZ(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var Lp="Tabs",[jZ]=K2(Lp,[Z8]),rB=Z8(),[IZ,J2]=jZ(Lp),sB=j.forwardRef((t,e)=>{const{__scopeTabs:n,value:i,onValueChange:r,defaultValue:s,orientation:o="horizontal",dir:c,activationMode:u="automatic",...h}=t,d=W8(c),[m,g]=X8({prop:i,onChange:r,defaultProp:s??"",caller:Lp});return k.jsx(IZ,{scope:n,baseId:Q8(),value:m,onValueChange:g,orientation:o,dir:d,activationMode:u,children:k.jsx(_l.div,{dir:d,"data-orientation":o,...h,ref:e})})});sB.displayName=Lp;var aB="TabsList",oB=j.forwardRef((t,e)=>{const{__scopeTabs:n,loop:i=!0,...r}=t,s=J2(aB,n),o=rB(n);return k.jsx(DZ,{asChild:!0,...o,orientation:s.orientation,dir:s.dir,loop:i,children:k.jsx(_l.div,{role:"tablist","aria-orientation":s.orientation,...r,ref:e})})});oB.displayName=aB;var lB="TabsTrigger",cB=j.forwardRef((t,e)=>{const{__scopeTabs:n,value:i,disabled:r=!1,...s}=t,o=J2(lB,n),c=rB(n),u=hB(o.baseId,i),h=dB(o.baseId,i),d=i===o.value;return k.jsx(LZ,{asChild:!0,...c,focusable:!r,active:d,children:k.jsx(_l.button,{type:"button",role:"tab","aria-selected":d,"aria-controls":h,"data-state":d?"active":"inactive","data-disabled":r?"":void 0,disabled:r,id:u,...s,ref:e,onMouseDown:Gr(t.onMouseDown,m=>{!r&&m.button===0&&m.ctrlKey===!1?o.onValueChange(i):m.preventDefault()}),onKeyDown:Gr(t.onKeyDown,m=>{[" ","Enter"].includes(m.key)&&o.onValueChange(i)}),onFocus:Gr(t.onFocus,()=>{const m=o.activationMode!=="manual";!d&&!r&&m&&o.onValueChange(i)})})})});cB.displayName=lB;var uB="TabsContent",fB=j.forwardRef((t,e)=>{const{__scopeTabs:n,value:i,forceMount:r,children:s,...o}=t,c=J2(uB,n),u=hB(c.baseId,i),h=dB(c.baseId,i),d=i===c.value,m=j.useRef(d);return j.useEffect(()=>{const g=requestAnimationFrame(()=>m.current=!1);return()=>cancelAnimationFrame(g)},[]),k.jsx(iB,{present:r||d,children:({present:g})=>k.jsx(_l.div,{"data-state":d?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":u,hidden:!g,id:h,tabIndex:0,...o,ref:e,style:{...t.style,animationDuration:m.current?"0s":void 0},children:g&&s})})});fB.displayName=uB;function hB(t,e){return`${t}-trigger-${e}`}function dB(t,e){return`${t}-content-${e}`}var PZ=sB,pB=oB,mB=cB,gB=fB;function yB(t){var e,n,i="";if(typeof t=="string"||typeof t=="number")i+=t;else if(typeof t=="object")if(Array.isArray(t)){var r=t.length;for(e=0;e<r;e++)t[e]&&(n=yB(t[e]))&&(i&&(i+=" "),i+=n)}else for(n in t)t[n]&&(i&&(i+=" "),i+=n);return i}function HZ(){for(var t,e,n=0,i="",r=arguments.length;n<r;n++)(t=arguments[n])&&(e=yB(t))&&(i&&(i+=" "),i+=e);return i}const UZ=(t,e)=>{const n=new Array(t.length+e.length);for(let i=0;i<t.length;i++)n[i]=t[i];for(let i=0;i<e.length;i++)n[t.length+i]=e[i];return n},VZ=(t,e)=>({classGroupId:t,validator:e}),vB=(t=new Map,e=null,n)=>({nextPart:t,validators:e,classGroupId:n}),Dd="-",S3=[],FZ="arbitrary..",$Z=t=>{const e=YZ(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:i}=t;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return GZ(o);const c=o.split(Dd),u=c[0]===""&&c.length>1?1:0;return bB(c,u,e)},getConflictingClassGroupIds:(o,c)=>{if(c){const u=i[o],h=n[o];return u?h?UZ(h,u):u:h||S3}return n[o]||S3}}},bB=(t,e,n)=>{if(t.length-e===0)return n.classGroupId;const r=t[e],s=n.nextPart.get(r);if(s){const h=bB(t,e+1,s);if(h)return h}const o=n.validators;if(o===null)return;const c=e===0?t.join(Dd):t.slice(e).join(Dd),u=o.length;for(let h=0;h<u;h++){const d=o[h];if(d.validator(c))return d.classGroupId}},GZ=t=>t.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const e=t.slice(1,-1),n=e.indexOf(":"),i=e.slice(0,n);return i?FZ+i:void 0})(),YZ=t=>{const{theme:e,classGroups:n}=t;return QZ(n,e)},QZ=(t,e)=>{const n=vB();for(const i in t){const r=t[i];eC(r,n,i,e)}return n},eC=(t,e,n,i)=>{const r=t.length;for(let s=0;s<r;s++){const o=t[s];XZ(o,e,n,i)}},XZ=(t,e,n,i)=>{if(typeof t=="string"){WZ(t,e,n);return}if(typeof t=="function"){KZ(t,e,n,i);return}ZZ(t,e,n,i)},WZ=(t,e,n)=>{const i=t===""?e:xB(e,t);i.classGroupId=n},KZ=(t,e,n,i)=>{if(JZ(t)){eC(t(i),e,n,i);return}e.validators===null&&(e.validators=[]),e.validators.push(VZ(n,t))},ZZ=(t,e,n,i)=>{const r=Object.entries(t),s=r.length;for(let o=0;o<s;o++){const[c,u]=r[o];eC(u,xB(e,c),n,i)}},xB=(t,e)=>{let n=t;const i=e.split(Dd),r=i.length;for(let s=0;s<r;s++){const o=i[s];let c=n.nextPart.get(o);c||(c=vB(),n.nextPart.set(o,c)),n=c}return n},JZ=t=>"isThemeGetter"in t&&t.isThemeGetter===!0,eJ=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,n=Object.create(null),i=Object.create(null);const r=(s,o)=>{n[s]=o,e++,e>t&&(e=0,i=n,n=Object.create(null))};return{get(s){let o=n[s];if(o!==void 0)return o;if((o=i[s])!==void 0)return r(s,o),o},set(s,o){s in n?n[s]=o:r(s,o)}}},aS="!",C3=":",tJ=[],k3=(t,e,n,i,r)=>({modifiers:t,hasImportantModifier:e,baseClassName:n,maybePostfixModifierPosition:i,isExternal:r}),nJ=t=>{const{prefix:e,experimentalParseClassName:n}=t;let i=r=>{const s=[];let o=0,c=0,u=0,h;const d=r.length;for(let w=0;w<d;w++){const S=r[w];if(o===0&&c===0){if(S===C3){s.push(r.slice(u,w)),u=w+1;continue}if(S==="/"){h=w;continue}}S==="["?o++:S==="]"?o--:S==="("?c++:S===")"&&c--}const m=s.length===0?r:r.slice(u);let g=m,y=!1;m.endsWith(aS)?(g=m.slice(0,-1),y=!0):m.startsWith(aS)&&(g=m.slice(1),y=!0);const x=h&&h>u?h-u:void 0;return k3(s,y,g,x)};if(e){const r=e+C3,s=i;i=o=>o.startsWith(r)?s(o.slice(r.length)):k3(tJ,!1,o,void 0,!0)}if(n){const r=i;i=s=>n({className:s,parseClassName:r})}return i},iJ=t=>{const e=new Map;return t.orderSensitiveModifiers.forEach((n,i)=>{e.set(n,1e6+i)}),n=>{const i=[];let r=[];for(let s=0;s<n.length;s++){const o=n[s],c=o[0]==="[",u=e.has(o);c||u?(r.length>0&&(r.sort(),i.push(...r),r=[]),i.push(o)):r.push(o)}return r.length>0&&(r.sort(),i.push(...r)),i}},rJ=t=>({cache:eJ(t.cacheSize),parseClassName:nJ(t),sortModifiers:iJ(t),...$Z(t)}),sJ=/\s+/,aJ=(t,e)=>{const{parseClassName:n,getClassGroupId:i,getConflictingClassGroupIds:r,sortModifiers:s}=e,o=[],c=t.trim().split(sJ);let u="";for(let h=c.length-1;h>=0;h-=1){const d=c[h],{isExternal:m,modifiers:g,hasImportantModifier:y,baseClassName:x,maybePostfixModifierPosition:w}=n(d);if(m){u=d+(u.length>0?" "+u:u);continue}let S=!!w,C=i(S?x.substring(0,w):x);if(!C){if(!S){u=d+(u.length>0?" "+u:u);continue}if(C=i(x),!C){u=d+(u.length>0?" "+u:u);continue}S=!1}const A=g.length===0?"":g.length===1?g[0]:s(g).join(":"),O=y?A+aS:A,E=O+C;if(o.indexOf(E)>-1)continue;o.push(E);const T=r(C,S);for(let M=0;M<T.length;++M){const R=T[M];o.push(O+R)}u=d+(u.length>0?" "+u:u)}return u},oJ=(...t)=>{let e=0,n,i,r="";for(;e<t.length;)(n=t[e++])&&(i=wB(n))&&(r&&(r+=" "),r+=i);return r},wB=t=>{if(typeof t=="string")return t;let e,n="";for(let i=0;i<t.length;i++)t[i]&&(e=wB(t[i]))&&(n&&(n+=" "),n+=e);return n},lJ=(t,...e)=>{let n,i,r,s;const o=u=>{const h=e.reduce((d,m)=>m(d),t());return n=rJ(h),i=n.cache.get,r=n.cache.set,s=c,c(u)},c=u=>{const h=i(u);if(h)return h;const d=aJ(u,n);return r(u,d),d};return s=o,(...u)=>s(oJ(...u))},cJ=[],Jt=t=>{const e=n=>n[t]||cJ;return e.isThemeGetter=!0,e},SB=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,CB=/^\((?:(\w[\w-]*):)?(.+)\)$/i,uJ=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,fJ=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,hJ=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,dJ=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,pJ=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,mJ=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Ms=t=>uJ.test(t),Ue=t=>!!t&&!Number.isNaN(Number(t)),Rs=t=>!!t&&Number.isInteger(Number(t)),J1=t=>t.endsWith("%")&&Ue(t.slice(0,-1)),Hr=t=>fJ.test(t),kB=()=>!0,gJ=t=>hJ.test(t)&&!dJ.test(t),tC=()=>!1,yJ=t=>pJ.test(t),vJ=t=>mJ.test(t),bJ=t=>!Ee(t)&&!Me(t),xJ=t=>ea(t,OB,tC),Ee=t=>SB.test(t),Ca=t=>ea(t,EB,gJ),A3=t=>ea(t,EJ,Ue),wJ=t=>ea(t,MB,kB),SJ=t=>ea(t,TB,tC),_3=t=>ea(t,AB,tC),CJ=t=>ea(t,_B,vJ),Mh=t=>ea(t,RB,yJ),Me=t=>CB.test(t),Mc=t=>Ka(t,EB),kJ=t=>Ka(t,TB),O3=t=>Ka(t,AB),AJ=t=>Ka(t,OB),_J=t=>Ka(t,_B),Rh=t=>Ka(t,RB,!0),OJ=t=>Ka(t,MB,!0),ea=(t,e,n)=>{const i=SB.exec(t);return i?i[1]?e(i[1]):n(i[2]):!1},Ka=(t,e,n=!1)=>{const i=CB.exec(t);return i?i[1]?e(i[1]):n:!1},AB=t=>t==="position"||t==="percentage",_B=t=>t==="image"||t==="url",OB=t=>t==="length"||t==="size"||t==="bg-size",EB=t=>t==="length",EJ=t=>t==="number",TB=t=>t==="family-name",MB=t=>t==="number"||t==="weight",RB=t=>t==="shadow",TJ=()=>{const t=Jt("color"),e=Jt("font"),n=Jt("text"),i=Jt("font-weight"),r=Jt("tracking"),s=Jt("leading"),o=Jt("breakpoint"),c=Jt("container"),u=Jt("spacing"),h=Jt("radius"),d=Jt("shadow"),m=Jt("inset-shadow"),g=Jt("text-shadow"),y=Jt("drop-shadow"),x=Jt("blur"),w=Jt("perspective"),S=Jt("aspect"),C=Jt("ease"),A=Jt("animate"),O=()=>["auto","avoid","all","avoid-page","page","left","right","column"],E=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],T=()=>[...E(),Me,Ee],M=()=>["auto","hidden","clip","visible","scroll"],R=()=>["auto","contain","none"],z=()=>[Me,Ee,u],q=()=>[Ms,"full","auto",...z()],U=()=>[Rs,"none","subgrid",Me,Ee],P=()=>["auto",{span:["full",Rs,Me,Ee]},Rs,Me,Ee],$=()=>[Rs,"auto",Me,Ee],K=()=>["auto","min","max","fr",Me,Ee],L=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],Y=()=>["start","end","center","stretch","center-safe","end-safe"],D=()=>["auto",...z()],Q=()=>[Ms,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...z()],ee=()=>[Ms,"screen","full","dvw","lvw","svw","min","max","fit",...z()],G=()=>[Ms,"screen","full","lh","dvh","lvh","svh","min","max","fit",...z()],W=()=>[t,Me,Ee],B=()=>[...E(),O3,_3,{position:[Me,Ee]}],F=()=>["no-repeat",{repeat:["","x","y","space","round"]}],ne=()=>["auto","cover","contain",AJ,xJ,{size:[Me,Ee]}],I=()=>[J1,Mc,Ca],X=()=>["","none","full",h,Me,Ee],J=()=>["",Ue,Mc,Ca],oe=()=>["solid","dashed","dotted","double"],ve=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],H=()=>[Ue,J1,O3,_3],pe=()=>["","none",x,Me,Ee],me=()=>["none",Ue,Me,Ee],ye=()=>["none",Ue,Me,Ee],_e=()=>[Ue,Me,Ee],Ae=()=>[Ms,"full",...z()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Hr],breakpoint:[Hr],color:[kB],container:[Hr],"drop-shadow":[Hr],ease:["in","out","in-out"],font:[bJ],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Hr],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Hr],shadow:[Hr],spacing:["px",Ue],text:[Hr],"text-shadow":[Hr],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Ms,Ee,Me,S]}],container:["container"],columns:[{columns:[Ue,Ee,Me,c]}],"break-after":[{"break-after":O()}],"break-before":[{"break-before":O()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:T()}],overflow:[{overflow:M()}],"overflow-x":[{"overflow-x":M()}],"overflow-y":[{"overflow-y":M()}],overscroll:[{overscroll:R()}],"overscroll-x":[{"overscroll-x":R()}],"overscroll-y":[{"overscroll-y":R()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:q()}],"inset-x":[{"inset-x":q()}],"inset-y":[{"inset-y":q()}],start:[{"inset-s":q(),start:q()}],end:[{"inset-e":q(),end:q()}],"inset-bs":[{"inset-bs":q()}],"inset-be":[{"inset-be":q()}],top:[{top:q()}],right:[{right:q()}],bottom:[{bottom:q()}],left:[{left:q()}],visibility:["visible","invisible","collapse"],z:[{z:[Rs,"auto",Me,Ee]}],basis:[{basis:[Ms,"full","auto",c,...z()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Ue,Ms,"auto","initial","none",Ee]}],grow:[{grow:["",Ue,Me,Ee]}],shrink:[{shrink:["",Ue,Me,Ee]}],order:[{order:[Rs,"first","last","none",Me,Ee]}],"grid-cols":[{"grid-cols":U()}],"col-start-end":[{col:P()}],"col-start":[{"col-start":$()}],"col-end":[{"col-end":$()}],"grid-rows":[{"grid-rows":U()}],"row-start-end":[{row:P()}],"row-start":[{"row-start":$()}],"row-end":[{"row-end":$()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":K()}],"auto-rows":[{"auto-rows":K()}],gap:[{gap:z()}],"gap-x":[{"gap-x":z()}],"gap-y":[{"gap-y":z()}],"justify-content":[{justify:[...L(),"normal"]}],"justify-items":[{"justify-items":[...Y(),"normal"]}],"justify-self":[{"justify-self":["auto",...Y()]}],"align-content":[{content:["normal",...L()]}],"align-items":[{items:[...Y(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...Y(),{baseline:["","last"]}]}],"place-content":[{"place-content":L()}],"place-items":[{"place-items":[...Y(),"baseline"]}],"place-self":[{"place-self":["auto",...Y()]}],p:[{p:z()}],px:[{px:z()}],py:[{py:z()}],ps:[{ps:z()}],pe:[{pe:z()}],pbs:[{pbs:z()}],pbe:[{pbe:z()}],pt:[{pt:z()}],pr:[{pr:z()}],pb:[{pb:z()}],pl:[{pl:z()}],m:[{m:D()}],mx:[{mx:D()}],my:[{my:D()}],ms:[{ms:D()}],me:[{me:D()}],mbs:[{mbs:D()}],mbe:[{mbe:D()}],mt:[{mt:D()}],mr:[{mr:D()}],mb:[{mb:D()}],ml:[{ml:D()}],"space-x":[{"space-x":z()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":z()}],"space-y-reverse":["space-y-reverse"],size:[{size:Q()}],"inline-size":[{inline:["auto",...ee()]}],"min-inline-size":[{"min-inline":["auto",...ee()]}],"max-inline-size":[{"max-inline":["none",...ee()]}],"block-size":[{block:["auto",...G()]}],"min-block-size":[{"min-block":["auto",...G()]}],"max-block-size":[{"max-block":["none",...G()]}],w:[{w:[c,"screen",...Q()]}],"min-w":[{"min-w":[c,"screen","none",...Q()]}],"max-w":[{"max-w":[c,"screen","none","prose",{screen:[o]},...Q()]}],h:[{h:["screen","lh",...Q()]}],"min-h":[{"min-h":["screen","lh","none",...Q()]}],"max-h":[{"max-h":["screen","lh",...Q()]}],"font-size":[{text:["base",n,Mc,Ca]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[i,OJ,wJ]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",J1,Ee]}],"font-family":[{font:[kJ,SJ,e]}],"font-features":[{"font-features":[Ee]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[r,Me,Ee]}],"line-clamp":[{"line-clamp":[Ue,"none",Me,A3]}],leading:[{leading:[s,...z()]}],"list-image":[{"list-image":["none",Me,Ee]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Me,Ee]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:W()}],"text-color":[{text:W()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...oe(),"wavy"]}],"text-decoration-thickness":[{decoration:[Ue,"from-font","auto",Me,Ca]}],"text-decoration-color":[{decoration:W()}],"underline-offset":[{"underline-offset":[Ue,"auto",Me,Ee]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:z()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Me,Ee]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Me,Ee]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:B()}],"bg-repeat":[{bg:F()}],"bg-size":[{bg:ne()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Rs,Me,Ee],radial:["",Me,Ee],conic:[Rs,Me,Ee]},_J,CJ]}],"bg-color":[{bg:W()}],"gradient-from-pos":[{from:I()}],"gradient-via-pos":[{via:I()}],"gradient-to-pos":[{to:I()}],"gradient-from":[{from:W()}],"gradient-via":[{via:W()}],"gradient-to":[{to:W()}],rounded:[{rounded:X()}],"rounded-s":[{"rounded-s":X()}],"rounded-e":[{"rounded-e":X()}],"rounded-t":[{"rounded-t":X()}],"rounded-r":[{"rounded-r":X()}],"rounded-b":[{"rounded-b":X()}],"rounded-l":[{"rounded-l":X()}],"rounded-ss":[{"rounded-ss":X()}],"rounded-se":[{"rounded-se":X()}],"rounded-ee":[{"rounded-ee":X()}],"rounded-es":[{"rounded-es":X()}],"rounded-tl":[{"rounded-tl":X()}],"rounded-tr":[{"rounded-tr":X()}],"rounded-br":[{"rounded-br":X()}],"rounded-bl":[{"rounded-bl":X()}],"border-w":[{border:J()}],"border-w-x":[{"border-x":J()}],"border-w-y":[{"border-y":J()}],"border-w-s":[{"border-s":J()}],"border-w-e":[{"border-e":J()}],"border-w-bs":[{"border-bs":J()}],"border-w-be":[{"border-be":J()}],"border-w-t":[{"border-t":J()}],"border-w-r":[{"border-r":J()}],"border-w-b":[{"border-b":J()}],"border-w-l":[{"border-l":J()}],"divide-x":[{"divide-x":J()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":J()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...oe(),"hidden","none"]}],"divide-style":[{divide:[...oe(),"hidden","none"]}],"border-color":[{border:W()}],"border-color-x":[{"border-x":W()}],"border-color-y":[{"border-y":W()}],"border-color-s":[{"border-s":W()}],"border-color-e":[{"border-e":W()}],"border-color-bs":[{"border-bs":W()}],"border-color-be":[{"border-be":W()}],"border-color-t":[{"border-t":W()}],"border-color-r":[{"border-r":W()}],"border-color-b":[{"border-b":W()}],"border-color-l":[{"border-l":W()}],"divide-color":[{divide:W()}],"outline-style":[{outline:[...oe(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Ue,Me,Ee]}],"outline-w":[{outline:["",Ue,Mc,Ca]}],"outline-color":[{outline:W()}],shadow:[{shadow:["","none",d,Rh,Mh]}],"shadow-color":[{shadow:W()}],"inset-shadow":[{"inset-shadow":["none",m,Rh,Mh]}],"inset-shadow-color":[{"inset-shadow":W()}],"ring-w":[{ring:J()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:W()}],"ring-offset-w":[{"ring-offset":[Ue,Ca]}],"ring-offset-color":[{"ring-offset":W()}],"inset-ring-w":[{"inset-ring":J()}],"inset-ring-color":[{"inset-ring":W()}],"text-shadow":[{"text-shadow":["none",g,Rh,Mh]}],"text-shadow-color":[{"text-shadow":W()}],opacity:[{opacity:[Ue,Me,Ee]}],"mix-blend":[{"mix-blend":[...ve(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":ve()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Ue]}],"mask-image-linear-from-pos":[{"mask-linear-from":H()}],"mask-image-linear-to-pos":[{"mask-linear-to":H()}],"mask-image-linear-from-color":[{"mask-linear-from":W()}],"mask-image-linear-to-color":[{"mask-linear-to":W()}],"mask-image-t-from-pos":[{"mask-t-from":H()}],"mask-image-t-to-pos":[{"mask-t-to":H()}],"mask-image-t-from-color":[{"mask-t-from":W()}],"mask-image-t-to-color":[{"mask-t-to":W()}],"mask-image-r-from-pos":[{"mask-r-from":H()}],"mask-image-r-to-pos":[{"mask-r-to":H()}],"mask-image-r-from-color":[{"mask-r-from":W()}],"mask-image-r-to-color":[{"mask-r-to":W()}],"mask-image-b-from-pos":[{"mask-b-from":H()}],"mask-image-b-to-pos":[{"mask-b-to":H()}],"mask-image-b-from-color":[{"mask-b-from":W()}],"mask-image-b-to-color":[{"mask-b-to":W()}],"mask-image-l-from-pos":[{"mask-l-from":H()}],"mask-image-l-to-pos":[{"mask-l-to":H()}],"mask-image-l-from-color":[{"mask-l-from":W()}],"mask-image-l-to-color":[{"mask-l-to":W()}],"mask-image-x-from-pos":[{"mask-x-from":H()}],"mask-image-x-to-pos":[{"mask-x-to":H()}],"mask-image-x-from-color":[{"mask-x-from":W()}],"mask-image-x-to-color":[{"mask-x-to":W()}],"mask-image-y-from-pos":[{"mask-y-from":H()}],"mask-image-y-to-pos":[{"mask-y-to":H()}],"mask-image-y-from-color":[{"mask-y-from":W()}],"mask-image-y-to-color":[{"mask-y-to":W()}],"mask-image-radial":[{"mask-radial":[Me,Ee]}],"mask-image-radial-from-pos":[{"mask-radial-from":H()}],"mask-image-radial-to-pos":[{"mask-radial-to":H()}],"mask-image-radial-from-color":[{"mask-radial-from":W()}],"mask-image-radial-to-color":[{"mask-radial-to":W()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":E()}],"mask-image-conic-pos":[{"mask-conic":[Ue]}],"mask-image-conic-from-pos":[{"mask-conic-from":H()}],"mask-image-conic-to-pos":[{"mask-conic-to":H()}],"mask-image-conic-from-color":[{"mask-conic-from":W()}],"mask-image-conic-to-color":[{"mask-conic-to":W()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:B()}],"mask-repeat":[{mask:F()}],"mask-size":[{mask:ne()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Me,Ee]}],filter:[{filter:["","none",Me,Ee]}],blur:[{blur:pe()}],brightness:[{brightness:[Ue,Me,Ee]}],contrast:[{contrast:[Ue,Me,Ee]}],"drop-shadow":[{"drop-shadow":["","none",y,Rh,Mh]}],"drop-shadow-color":[{"drop-shadow":W()}],grayscale:[{grayscale:["",Ue,Me,Ee]}],"hue-rotate":[{"hue-rotate":[Ue,Me,Ee]}],invert:[{invert:["",Ue,Me,Ee]}],saturate:[{saturate:[Ue,Me,Ee]}],sepia:[{sepia:["",Ue,Me,Ee]}],"backdrop-filter":[{"backdrop-filter":["","none",Me,Ee]}],"backdrop-blur":[{"backdrop-blur":pe()}],"backdrop-brightness":[{"backdrop-brightness":[Ue,Me,Ee]}],"backdrop-contrast":[{"backdrop-contrast":[Ue,Me,Ee]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Ue,Me,Ee]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Ue,Me,Ee]}],"backdrop-invert":[{"backdrop-invert":["",Ue,Me,Ee]}],"backdrop-opacity":[{"backdrop-opacity":[Ue,Me,Ee]}],"backdrop-saturate":[{"backdrop-saturate":[Ue,Me,Ee]}],"backdrop-sepia":[{"backdrop-sepia":["",Ue,Me,Ee]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":z()}],"border-spacing-x":[{"border-spacing-x":z()}],"border-spacing-y":[{"border-spacing-y":z()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Me,Ee]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Ue,"initial",Me,Ee]}],ease:[{ease:["linear","initial",C,Me,Ee]}],delay:[{delay:[Ue,Me,Ee]}],animate:[{animate:["none",A,Me,Ee]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[w,Me,Ee]}],"perspective-origin":[{"perspective-origin":T()}],rotate:[{rotate:me()}],"rotate-x":[{"rotate-x":me()}],"rotate-y":[{"rotate-y":me()}],"rotate-z":[{"rotate-z":me()}],scale:[{scale:ye()}],"scale-x":[{"scale-x":ye()}],"scale-y":[{"scale-y":ye()}],"scale-z":[{"scale-z":ye()}],"scale-3d":["scale-3d"],skew:[{skew:_e()}],"skew-x":[{"skew-x":_e()}],"skew-y":[{"skew-y":_e()}],transform:[{transform:[Me,Ee,"","none","gpu","cpu"]}],"transform-origin":[{origin:T()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Ae()}],"translate-x":[{"translate-x":Ae()}],"translate-y":[{"translate-y":Ae()}],"translate-z":[{"translate-z":Ae()}],"translate-none":["translate-none"],accent:[{accent:W()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:W()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Me,Ee]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":z()}],"scroll-mx":[{"scroll-mx":z()}],"scroll-my":[{"scroll-my":z()}],"scroll-ms":[{"scroll-ms":z()}],"scroll-me":[{"scroll-me":z()}],"scroll-mbs":[{"scroll-mbs":z()}],"scroll-mbe":[{"scroll-mbe":z()}],"scroll-mt":[{"scroll-mt":z()}],"scroll-mr":[{"scroll-mr":z()}],"scroll-mb":[{"scroll-mb":z()}],"scroll-ml":[{"scroll-ml":z()}],"scroll-p":[{"scroll-p":z()}],"scroll-px":[{"scroll-px":z()}],"scroll-py":[{"scroll-py":z()}],"scroll-ps":[{"scroll-ps":z()}],"scroll-pe":[{"scroll-pe":z()}],"scroll-pbs":[{"scroll-pbs":z()}],"scroll-pbe":[{"scroll-pbe":z()}],"scroll-pt":[{"scroll-pt":z()}],"scroll-pr":[{"scroll-pr":z()}],"scroll-pb":[{"scroll-pb":z()}],"scroll-pl":[{"scroll-pl":z()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Me,Ee]}],fill:[{fill:["none",...W()]}],"stroke-w":[{stroke:[Ue,Mc,Ca,A3]}],stroke:[{stroke:["none",...W()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},MJ=lJ(TJ);function nC(...t){return MJ(HZ(t))}const RJ=PZ,NB=j.forwardRef(({className:t,...e},n)=>k.jsx(pB,{ref:n,className:nC("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",t),...e}));NB.displayName=pB.displayName;const oS=j.forwardRef(({className:t,...e},n)=>k.jsx(mB,{ref:n,className:nC("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",t),...e}));oS.displayName=mB.displayName;const lS=j.forwardRef(({className:t,...e},n)=>k.jsx(gB,{ref:n,className:nC("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...e}));lS.displayName=gB.displayName;function cS(){return cS=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)({}).hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},cS.apply(null,arguments)}function NJ(t,e){if(t==null)return{};var n={};for(var i in t)if({}.hasOwnProperty.call(t,i)){if(e.indexOf(i)!==-1)continue;n[i]=t[i]}return n}let uS=[],DB=[];(()=>{let t="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 e=0,n=0;e<t.length;e++)(e%2?DB:uS).push(n=n+t[e])})();function DJ(t){if(t<768)return!1;for(let e=0,n=uS.length;;){let i=e+n>>1;if(t<uS[i])n=i;else if(t>=DB[i])e=i+1;else return!0;if(e==n)return!1}}function E3(t){return t>=127462&&t<=127487}const T3=8205;function LJ(t,e,n=!0,i=!0){return(n?LB:zJ)(t,e,i)}function LB(t,e,n){if(e==t.length)return e;e&&zB(t.charCodeAt(e))&&BB(t.charCodeAt(e-1))&&e--;let i=ew(t,e);for(e+=M3(i);e<t.length;){let r=ew(t,e);if(i==T3||r==T3||n&&DJ(r))e+=M3(r),i=r;else if(E3(r)){let s=0,o=e-2;for(;o>=0&&E3(ew(t,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function zJ(t,e,n){for(;e>0;){let i=LB(t,e-2,n);if(i<e)return i;e--}return 0}function ew(t,e){let n=t.charCodeAt(e);if(!BB(n)||e+1==t.length)return n;let i=t.charCodeAt(e+1);return zB(i)?(n-55296<<10)+(i-56320)+65536:n}function zB(t){return t>=56320&&t<57344}function BB(t){return t>=55296&&t<56320}function M3(t){return t<65536?1:2}class tt{lineAt(e){if(e<0||e>this.length)throw new 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 new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,n,i){[e,n]=pl(this,e,n);let r=[];return this.decompose(0,e,r,2),i.length&&i.decompose(0,i.length,r,3),this.decompose(n,this.length,r,1),nr.from(r,this.length-(n-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=pl(this,e,n);let i=[];return this.decompose(e,n,i,0),nr.from(i,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),r=new Gc(this),s=new Gc(e);for(let o=n,c=n;;){if(r.next(o),s.next(o),o=0,r.lineBreak!=s.lineBreak||r.done!=s.done||r.value!=s.value)return!1;if(c+=r.value.length,r.done||c>=i)return!0}}iter(e=1){return new Gc(this,e)}iterRange(e,n=this.length){return new qB(this,e,n)}iterLines(e,n){let i;if(e==null)i=this.iter();else{n==null&&(n=this.lines+1);let r=this.line(e).from;i=this.iterRange(r,Math.max(r,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new jB(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?tt.empty:e.length<=32?new jt(e):nr.from(jt.split(e,[]))}}class jt extends tt{constructor(e,n=BJ(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,i,r){for(let s=0;;s++){let o=this.text[s],c=r+o.length;if((n?i:c)>=e)return new qJ(r,c,i,o);r=c+1,i++}}decompose(e,n,i,r){let s=e<=0&&n>=this.length?this:new jt(R3(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(r&1){let o=i.pop(),c=ad(s.text,o.text.slice(),0,s.length);if(c.length<=32)i.push(new jt(c,o.length+s.length));else{let u=c.length>>1;i.push(new jt(c.slice(0,u)),new jt(c.slice(u)))}}else i.push(s)}replace(e,n,i){if(!(i instanceof jt))return super.replace(e,n,i);[e,n]=pl(this,e,n);let r=ad(this.text,ad(i.text,R3(this.text,0,e)),n),s=this.length+i.length-(n-e);return r.length<=32?new jt(r,s):nr.from(jt.split(r,[]),s)}sliceString(e,n=this.length,i=`
|
|
40
|
+
`:""}var lY=oY,cY={dump:lY};function N2(t,e){return function(){throw new Error("Function yaml."+t+" is removed in js-yaml 4. Use yaml."+e+" instead, which is now safe by default.")}}var uY=vn,fY=rz,hY=lz,dY=dz,pY=pz,mY=E2,gY=Nz.load,yY=Nz.loadAll,vY=cY.dump,bY=Mn,xY={binary:bz,float:hz,map:oz,null:cz,pairs:wz,set:Sz,timestamp:yz,bool:uz,int:fz,merge:vz,omap:xz,seq:az,str:sz},wY=N2("safeLoad","load"),SY=N2("safeLoadAll","loadAll"),CY=N2("safeDump","dump"),eS={Type:uY,Schema:fY,FAILSAFE_SCHEMA:hY,JSON_SCHEMA:dY,CORE_SCHEMA:pY,DEFAULT_SCHEMA:mY,load:gY,loadAll:yY,dump:vY,YAMLException:bY,types:xY,safeLoad:wY,safeLoadAll:SY,safeDump:CY};function D2(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var N0,XE;function kY(){if(XE)return N0;XE=1;function t(){this.__data__=[],this.size=0}return N0=t,N0}var D0,WE;function wl(){if(WE)return D0;WE=1;function t(e,n){return e===n||e!==e&&n!==n}return D0=t,D0}var L0,KE;function yp(){if(KE)return L0;KE=1;var t=wl();function e(n,i){for(var r=n.length;r--;)if(t(n[r][0],i))return r;return-1}return L0=e,L0}var z0,ZE;function AY(){if(ZE)return z0;ZE=1;var t=yp(),e=Array.prototype,n=e.splice;function i(r){var s=this.__data__,o=t(s,r);if(o<0)return!1;var c=s.length-1;return o==c?s.pop():n.call(s,o,1),--this.size,!0}return z0=i,z0}var B0,JE;function _Y(){if(JE)return B0;JE=1;var t=yp();function e(n){var i=this.__data__,r=t(i,n);return r<0?void 0:i[r][1]}return B0=e,B0}var q0,eT;function OY(){if(eT)return q0;eT=1;var t=yp();function e(n){return t(this.__data__,n)>-1}return q0=e,q0}var j0,tT;function EY(){if(tT)return j0;tT=1;var t=yp();function e(n,i){var r=this.__data__,s=t(r,n);return s<0?(++this.size,r.push([n,i])):r[s][1]=i,this}return j0=e,j0}var I0,nT;function vp(){if(nT)return I0;nT=1;var t=kY(),e=AY(),n=_Y(),i=OY(),r=EY();function s(o){var c=-1,u=o==null?0:o.length;for(this.clear();++c<u;){var h=o[c];this.set(h[0],h[1])}}return s.prototype.clear=t,s.prototype.delete=e,s.prototype.get=n,s.prototype.has=i,s.prototype.set=r,I0=s,I0}var P0,iT;function TY(){if(iT)return P0;iT=1;var t=vp();function e(){this.__data__=new t,this.size=0}return P0=e,P0}var H0,rT;function MY(){if(rT)return H0;rT=1;function t(e){var n=this.__data__,i=n.delete(e);return this.size=n.size,i}return H0=t,H0}var U0,sT;function RY(){if(sT)return U0;sT=1;function t(e){return this.__data__.get(e)}return U0=t,U0}var V0,aT;function NY(){if(aT)return V0;aT=1;function t(e){return this.__data__.has(e)}return V0=t,V0}var F0,oT;function Fz(){if(oT)return F0;oT=1;var t=typeof vh=="object"&&vh&&vh.Object===Object&&vh;return F0=t,F0}var $0,lT;function Hi(){if(lT)return $0;lT=1;var t=Fz(),e=typeof self=="object"&&self&&self.Object===Object&&self,n=t||e||Function("return this")();return $0=n,$0}var G0,cT;function Sl(){if(cT)return G0;cT=1;var t=Hi(),e=t.Symbol;return G0=e,G0}var Y0,uT;function DY(){if(uT)return Y0;uT=1;var t=Sl(),e=Object.prototype,n=e.hasOwnProperty,i=e.toString,r=t?t.toStringTag:void 0;function s(o){var c=n.call(o,r),u=o[r];try{o[r]=void 0;var h=!0}catch{}var d=i.call(o);return h&&(c?o[r]=u:delete o[r]),d}return Y0=s,Y0}var Q0,fT;function LY(){if(fT)return Q0;fT=1;var t=Object.prototype,e=t.toString;function n(i){return e.call(i)}return Q0=n,Q0}var X0,hT;function Ya(){if(hT)return X0;hT=1;var t=Sl(),e=DY(),n=LY(),i="[object Null]",r="[object Undefined]",s=t?t.toStringTag:void 0;function o(c){return c==null?c===void 0?r:i:s&&s in Object(c)?e(c):n(c)}return X0=o,X0}var W0,dT;function Oi(){if(dT)return W0;dT=1;function t(e){var n=typeof e;return e!=null&&(n=="object"||n=="function")}return W0=t,W0}var K0,pT;function Lu(){if(pT)return K0;pT=1;var t=Ya(),e=Oi(),n="[object AsyncFunction]",i="[object Function]",r="[object GeneratorFunction]",s="[object Proxy]";function o(c){if(!e(c))return!1;var u=t(c);return u==i||u==r||u==n||u==s}return K0=o,K0}var Z0,mT;function zY(){if(mT)return Z0;mT=1;var t=Hi(),e=t["__core-js_shared__"];return Z0=e,Z0}var J0,gT;function BY(){if(gT)return J0;gT=1;var t=zY(),e=(function(){var i=/[^.]+$/.exec(t&&t.keys&&t.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""})();function n(i){return!!e&&e in i}return J0=n,J0}var ey,yT;function $z(){if(yT)return ey;yT=1;var t=Function.prototype,e=t.toString;function n(i){if(i!=null){try{return e.call(i)}catch{}try{return i+""}catch{}}return""}return ey=n,ey}var ty,vT;function qY(){if(vT)return ty;vT=1;var t=Lu(),e=BY(),n=Oi(),i=$z(),r=/[\\^$.*+?()[\]{}|]/g,s=/^\[object .+?Constructor\]$/,o=Function.prototype,c=Object.prototype,u=o.toString,h=c.hasOwnProperty,d=RegExp("^"+u.call(h).replace(r,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function m(g){if(!n(g)||e(g))return!1;var y=t(g)?d:s;return y.test(i(g))}return ty=m,ty}var ny,bT;function jY(){if(bT)return ny;bT=1;function t(e,n){return e?.[n]}return ny=t,ny}var iy,xT;function Qa(){if(xT)return iy;xT=1;var t=qY(),e=jY();function n(i,r){var s=e(i,r);return t(s)?s:void 0}return iy=n,iy}var ry,wT;function L2(){if(wT)return ry;wT=1;var t=Qa(),e=Hi(),n=t(e,"Map");return ry=n,ry}var sy,ST;function bp(){if(ST)return sy;ST=1;var t=Qa(),e=t(Object,"create");return sy=e,sy}var ay,CT;function IY(){if(CT)return ay;CT=1;var t=bp();function e(){this.__data__=t?t(null):{},this.size=0}return ay=e,ay}var oy,kT;function PY(){if(kT)return oy;kT=1;function t(e){var n=this.has(e)&&delete this.__data__[e];return this.size-=n?1:0,n}return oy=t,oy}var ly,AT;function HY(){if(AT)return ly;AT=1;var t=bp(),e="__lodash_hash_undefined__",n=Object.prototype,i=n.hasOwnProperty;function r(s){var o=this.__data__;if(t){var c=o[s];return c===e?void 0:c}return i.call(o,s)?o[s]:void 0}return ly=r,ly}var cy,_T;function UY(){if(_T)return cy;_T=1;var t=bp(),e=Object.prototype,n=e.hasOwnProperty;function i(r){var s=this.__data__;return t?s[r]!==void 0:n.call(s,r)}return cy=i,cy}var uy,OT;function VY(){if(OT)return uy;OT=1;var t=bp(),e="__lodash_hash_undefined__";function n(i,r){var s=this.__data__;return this.size+=this.has(i)?0:1,s[i]=t&&r===void 0?e:r,this}return uy=n,uy}var fy,ET;function FY(){if(ET)return fy;ET=1;var t=IY(),e=PY(),n=HY(),i=UY(),r=VY();function s(o){var c=-1,u=o==null?0:o.length;for(this.clear();++c<u;){var h=o[c];this.set(h[0],h[1])}}return s.prototype.clear=t,s.prototype.delete=e,s.prototype.get=n,s.prototype.has=i,s.prototype.set=r,fy=s,fy}var hy,TT;function $Y(){if(TT)return hy;TT=1;var t=FY(),e=vp(),n=L2();function i(){this.size=0,this.__data__={hash:new t,map:new(n||e),string:new t}}return hy=i,hy}var dy,MT;function GY(){if(MT)return dy;MT=1;function t(e){var n=typeof e;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?e!=="__proto__":e===null}return dy=t,dy}var py,RT;function xp(){if(RT)return py;RT=1;var t=GY();function e(n,i){var r=n.__data__;return t(i)?r[typeof i=="string"?"string":"hash"]:r.map}return py=e,py}var my,NT;function YY(){if(NT)return my;NT=1;var t=xp();function e(n){var i=t(this,n).delete(n);return this.size-=i?1:0,i}return my=e,my}var gy,DT;function QY(){if(DT)return gy;DT=1;var t=xp();function e(n){return t(this,n).get(n)}return gy=e,gy}var yy,LT;function XY(){if(LT)return yy;LT=1;var t=xp();function e(n){return t(this,n).has(n)}return yy=e,yy}var vy,zT;function WY(){if(zT)return vy;zT=1;var t=xp();function e(n,i){var r=t(this,n),s=r.size;return r.set(n,i),this.size+=r.size==s?0:1,this}return vy=e,vy}var by,BT;function z2(){if(BT)return by;BT=1;var t=$Y(),e=YY(),n=QY(),i=XY(),r=WY();function s(o){var c=-1,u=o==null?0:o.length;for(this.clear();++c<u;){var h=o[c];this.set(h[0],h[1])}}return s.prototype.clear=t,s.prototype.delete=e,s.prototype.get=n,s.prototype.has=i,s.prototype.set=r,by=s,by}var xy,qT;function KY(){if(qT)return xy;qT=1;var t=vp(),e=L2(),n=z2(),i=200;function r(s,o){var c=this.__data__;if(c instanceof t){var u=c.__data__;if(!e||u.length<i-1)return u.push([s,o]),this.size=++c.size,this;c=this.__data__=new n(u)}return c.set(s,o),this.size=c.size,this}return xy=r,xy}var wy,jT;function wp(){if(jT)return wy;jT=1;var t=vp(),e=TY(),n=MY(),i=RY(),r=NY(),s=KY();function o(c){var u=this.__data__=new t(c);this.size=u.size}return o.prototype.clear=e,o.prototype.delete=n,o.prototype.get=i,o.prototype.has=r,o.prototype.set=s,wy=o,wy}var Sy,IT;function B2(){if(IT)return Sy;IT=1;function t(e,n){for(var i=-1,r=e==null?0:e.length;++i<r&&n(e[i],i,e)!==!1;);return e}return Sy=t,Sy}var Cy,PT;function Gz(){if(PT)return Cy;PT=1;var t=Qa(),e=(function(){try{var n=t(Object,"defineProperty");return n({},"",{}),n}catch{}})();return Cy=e,Cy}var ky,HT;function Sp(){if(HT)return ky;HT=1;var t=Gz();function e(n,i,r){i=="__proto__"&&t?t(n,i,{configurable:!0,enumerable:!0,value:r,writable:!0}):n[i]=r}return ky=e,ky}var Ay,UT;function Cp(){if(UT)return Ay;UT=1;var t=Sp(),e=wl(),n=Object.prototype,i=n.hasOwnProperty;function r(s,o,c){var u=s[o];(!(i.call(s,o)&&e(u,c))||c===void 0&&!(o in s))&&t(s,o,c)}return Ay=r,Ay}var _y,VT;function zu(){if(VT)return _y;VT=1;var t=Cp(),e=Sp();function n(i,r,s,o){var c=!s;s||(s={});for(var u=-1,h=r.length;++u<h;){var d=r[u],m=o?o(s[d],i[d],d,s,i):void 0;m===void 0&&(m=i[d]),c?e(s,d,m):t(s,d,m)}return s}return _y=n,_y}var Oy,FT;function ZY(){if(FT)return Oy;FT=1;function t(e,n){for(var i=-1,r=Array(e);++i<e;)r[i]=n(i);return r}return Oy=t,Oy}var Ey,$T;function hr(){if($T)return Ey;$T=1;function t(e){return e!=null&&typeof e=="object"}return Ey=t,Ey}var Ty,GT;function JY(){if(GT)return Ty;GT=1;var t=Ya(),e=hr(),n="[object Arguments]";function i(r){return e(r)&&t(r)==n}return Ty=i,Ty}var My,YT;function Bu(){if(YT)return My;YT=1;var t=JY(),e=hr(),n=Object.prototype,i=n.hasOwnProperty,r=n.propertyIsEnumerable,s=t((function(){return arguments})())?t:function(o){return e(o)&&i.call(o,"callee")&&!r.call(o,"callee")};return My=s,My}var Ry,QT;function Wt(){if(QT)return Ry;QT=1;var t=Array.isArray;return Ry=t,Ry}var Pc={exports:{}},Ny,XT;function eQ(){if(XT)return Ny;XT=1;function t(){return!1}return Ny=t,Ny}Pc.exports;var WT;function Cl(){return WT||(WT=1,(function(t,e){var n=Hi(),i=eQ(),r=e&&!e.nodeType&&e,s=r&&!0&&t&&!t.nodeType&&t,o=s&&s.exports===r,c=o?n.Buffer:void 0,u=c?c.isBuffer:void 0,h=u||i;t.exports=h})(Pc,Pc.exports)),Pc.exports}var Dy,KT;function kp(){if(KT)return Dy;KT=1;var t=9007199254740991,e=/^(?:0|[1-9]\d*)$/;function n(i,r){var s=typeof i;return r=r??t,!!r&&(s=="number"||s!="symbol"&&e.test(i))&&i>-1&&i%1==0&&i<r}return Dy=n,Dy}var Ly,ZT;function q2(){if(ZT)return Ly;ZT=1;var t=9007199254740991;function e(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=t}return Ly=e,Ly}var zy,JT;function tQ(){if(JT)return zy;JT=1;var t=Ya(),e=q2(),n=hr(),i="[object Arguments]",r="[object Array]",s="[object Boolean]",o="[object Date]",c="[object Error]",u="[object Function]",h="[object Map]",d="[object Number]",m="[object Object]",g="[object RegExp]",y="[object Set]",x="[object String]",w="[object WeakMap]",S="[object ArrayBuffer]",C="[object DataView]",A="[object Float32Array]",O="[object Float64Array]",E="[object Int8Array]",T="[object Int16Array]",M="[object Int32Array]",R="[object Uint8Array]",z="[object Uint8ClampedArray]",q="[object Uint16Array]",U="[object Uint32Array]",P={};P[A]=P[O]=P[E]=P[T]=P[M]=P[R]=P[z]=P[q]=P[U]=!0,P[i]=P[r]=P[S]=P[s]=P[C]=P[o]=P[c]=P[u]=P[h]=P[d]=P[m]=P[g]=P[y]=P[x]=P[w]=!1;function $(K){return n(K)&&e(K.length)&&!!P[t(K)]}return zy=$,zy}var By,eM;function Ap(){if(eM)return By;eM=1;function t(e){return function(n){return e(n)}}return By=t,By}var Hc={exports:{}};Hc.exports;var tM;function j2(){return tM||(tM=1,(function(t,e){var n=Fz(),i=e&&!e.nodeType&&e,r=i&&!0&&t&&!t.nodeType&&t,s=r&&r.exports===i,o=s&&n.process,c=(function(){try{var u=r&&r.require&&r.require("util").types;return u||o&&o.binding&&o.binding("util")}catch{}})();t.exports=c})(Hc,Hc.exports)),Hc.exports}var qy,nM;function qu(){if(nM)return qy;nM=1;var t=tQ(),e=Ap(),n=j2(),i=n&&n.isTypedArray,r=i?e(i):t;return qy=r,qy}var jy,iM;function Yz(){if(iM)return jy;iM=1;var t=ZY(),e=Bu(),n=Wt(),i=Cl(),r=kp(),s=qu(),o=Object.prototype,c=o.hasOwnProperty;function u(h,d){var m=n(h),g=!m&&e(h),y=!m&&!g&&i(h),x=!m&&!g&&!y&&s(h),w=m||g||y||x,S=w?t(h.length,String):[],C=S.length;for(var A in h)(d||c.call(h,A))&&!(w&&(A=="length"||y&&(A=="offset"||A=="parent")||x&&(A=="buffer"||A=="byteLength"||A=="byteOffset")||r(A,C)))&&S.push(A);return S}return jy=u,jy}var Iy,rM;function _p(){if(rM)return Iy;rM=1;var t=Object.prototype;function e(n){var i=n&&n.constructor,r=typeof i=="function"&&i.prototype||t;return n===r}return Iy=e,Iy}var Py,sM;function Qz(){if(sM)return Py;sM=1;function t(e,n){return function(i){return e(n(i))}}return Py=t,Py}var Hy,aM;function nQ(){if(aM)return Hy;aM=1;var t=Qz(),e=t(Object.keys,Object);return Hy=e,Hy}var Uy,oM;function I2(){if(oM)return Uy;oM=1;var t=_p(),e=nQ(),n=Object.prototype,i=n.hasOwnProperty;function r(s){if(!t(s))return e(s);var o=[];for(var c in Object(s))i.call(s,c)&&c!="constructor"&&o.push(c);return o}return Uy=r,Uy}var Vy,lM;function ts(){if(lM)return Vy;lM=1;var t=Lu(),e=q2();function n(i){return i!=null&&e(i.length)&&!t(i)}return Vy=n,Vy}var Fy,cM;function Js(){if(cM)return Fy;cM=1;var t=Yz(),e=I2(),n=ts();function i(r){return n(r)?t(r):e(r)}return Fy=i,Fy}var $y,uM;function iQ(){if(uM)return $y;uM=1;var t=zu(),e=Js();function n(i,r){return i&&t(r,e(r),i)}return $y=n,$y}var Gy,fM;function rQ(){if(fM)return Gy;fM=1;function t(e){var n=[];if(e!=null)for(var i in Object(e))n.push(i);return n}return Gy=t,Gy}var Yy,hM;function sQ(){if(hM)return Yy;hM=1;var t=Oi(),e=_p(),n=rQ(),i=Object.prototype,r=i.hasOwnProperty;function s(o){if(!t(o))return n(o);var c=e(o),u=[];for(var h in o)h=="constructor"&&(c||!r.call(o,h))||u.push(h);return u}return Yy=s,Yy}var Qy,dM;function Xa(){if(dM)return Qy;dM=1;var t=Yz(),e=sQ(),n=ts();function i(r){return n(r)?t(r,!0):e(r)}return Qy=i,Qy}var Xy,pM;function aQ(){if(pM)return Xy;pM=1;var t=zu(),e=Xa();function n(i,r){return i&&t(r,e(r),i)}return Xy=n,Xy}var Uc={exports:{}};Uc.exports;var mM;function Xz(){return mM||(mM=1,(function(t,e){var n=Hi(),i=e&&!e.nodeType&&e,r=i&&!0&&t&&!t.nodeType&&t,s=r&&r.exports===i,o=s?n.Buffer:void 0,c=o?o.allocUnsafe:void 0;function u(h,d){if(d)return h.slice();var m=h.length,g=c?c(m):new h.constructor(m);return h.copy(g),g}t.exports=u})(Uc,Uc.exports)),Uc.exports}var Wy,gM;function Wz(){if(gM)return Wy;gM=1;function t(e,n){var i=-1,r=e.length;for(n||(n=Array(r));++i<r;)n[i]=e[i];return n}return Wy=t,Wy}var Ky,yM;function Kz(){if(yM)return Ky;yM=1;function t(e,n){for(var i=-1,r=e==null?0:e.length,s=0,o=[];++i<r;){var c=e[i];n(c,i,e)&&(o[s++]=c)}return o}return Ky=t,Ky}var Zy,vM;function Zz(){if(vM)return Zy;vM=1;function t(){return[]}return Zy=t,Zy}var Jy,bM;function P2(){if(bM)return Jy;bM=1;var t=Kz(),e=Zz(),n=Object.prototype,i=n.propertyIsEnumerable,r=Object.getOwnPropertySymbols,s=r?function(o){return o==null?[]:(o=Object(o),t(r(o),function(c){return i.call(o,c)}))}:e;return Jy=s,Jy}var ev,xM;function oQ(){if(xM)return ev;xM=1;var t=zu(),e=P2();function n(i,r){return t(i,e(i),r)}return ev=n,ev}var tv,wM;function H2(){if(wM)return tv;wM=1;function t(e,n){for(var i=-1,r=n.length,s=e.length;++i<r;)e[s+i]=n[i];return e}return tv=t,tv}var nv,SM;function Op(){if(SM)return nv;SM=1;var t=Qz(),e=t(Object.getPrototypeOf,Object);return nv=e,nv}var iv,CM;function Jz(){if(CM)return iv;CM=1;var t=H2(),e=Op(),n=P2(),i=Zz(),r=Object.getOwnPropertySymbols,s=r?function(o){for(var c=[];o;)t(c,n(o)),o=e(o);return c}:i;return iv=s,iv}var rv,kM;function lQ(){if(kM)return rv;kM=1;var t=zu(),e=Jz();function n(i,r){return t(i,e(i),r)}return rv=n,rv}var sv,AM;function e8(){if(AM)return sv;AM=1;var t=H2(),e=Wt();function n(i,r,s){var o=r(i);return e(i)?o:t(o,s(i))}return sv=n,sv}var av,_M;function t8(){if(_M)return av;_M=1;var t=e8(),e=P2(),n=Js();function i(r){return t(r,n,e)}return av=i,av}var ov,OM;function cQ(){if(OM)return ov;OM=1;var t=e8(),e=Jz(),n=Xa();function i(r){return t(r,n,e)}return ov=i,ov}var lv,EM;function uQ(){if(EM)return lv;EM=1;var t=Qa(),e=Hi(),n=t(e,"DataView");return lv=n,lv}var cv,TM;function fQ(){if(TM)return cv;TM=1;var t=Qa(),e=Hi(),n=t(e,"Promise");return cv=n,cv}var uv,MM;function n8(){if(MM)return uv;MM=1;var t=Qa(),e=Hi(),n=t(e,"Set");return uv=n,uv}var fv,RM;function hQ(){if(RM)return fv;RM=1;var t=Qa(),e=Hi(),n=t(e,"WeakMap");return fv=n,fv}var hv,NM;function kl(){if(NM)return hv;NM=1;var t=uQ(),e=L2(),n=fQ(),i=n8(),r=hQ(),s=Ya(),o=$z(),c="[object Map]",u="[object Object]",h="[object Promise]",d="[object Set]",m="[object WeakMap]",g="[object DataView]",y=o(t),x=o(e),w=o(n),S=o(i),C=o(r),A=s;return(t&&A(new t(new ArrayBuffer(1)))!=g||e&&A(new e)!=c||n&&A(n.resolve())!=h||i&&A(new i)!=d||r&&A(new r)!=m)&&(A=function(O){var E=s(O),T=E==u?O.constructor:void 0,M=T?o(T):"";if(M)switch(M){case y:return g;case x:return c;case w:return h;case S:return d;case C:return m}return E}),hv=A,hv}var dv,DM;function dQ(){if(DM)return dv;DM=1;var t=Object.prototype,e=t.hasOwnProperty;function n(i){var r=i.length,s=new i.constructor(r);return r&&typeof i[0]=="string"&&e.call(i,"index")&&(s.index=i.index,s.input=i.input),s}return dv=n,dv}var pv,LM;function i8(){if(LM)return pv;LM=1;var t=Hi(),e=t.Uint8Array;return pv=e,pv}var mv,zM;function U2(){if(zM)return mv;zM=1;var t=i8();function e(n){var i=new n.constructor(n.byteLength);return new t(i).set(new t(n)),i}return mv=e,mv}var gv,BM;function pQ(){if(BM)return gv;BM=1;var t=U2();function e(n,i){var r=i?t(n.buffer):n.buffer;return new n.constructor(r,n.byteOffset,n.byteLength)}return gv=e,gv}var yv,qM;function mQ(){if(qM)return yv;qM=1;var t=/\w*$/;function e(n){var i=new n.constructor(n.source,t.exec(n));return i.lastIndex=n.lastIndex,i}return yv=e,yv}var vv,jM;function gQ(){if(jM)return vv;jM=1;var t=Sl(),e=t?t.prototype:void 0,n=e?e.valueOf:void 0;function i(r){return n?Object(n.call(r)):{}}return vv=i,vv}var bv,IM;function r8(){if(IM)return bv;IM=1;var t=U2();function e(n,i){var r=i?t(n.buffer):n.buffer;return new n.constructor(r,n.byteOffset,n.length)}return bv=e,bv}var xv,PM;function yQ(){if(PM)return xv;PM=1;var t=U2(),e=pQ(),n=mQ(),i=gQ(),r=r8(),s="[object Boolean]",o="[object Date]",c="[object Map]",u="[object Number]",h="[object RegExp]",d="[object Set]",m="[object String]",g="[object Symbol]",y="[object ArrayBuffer]",x="[object DataView]",w="[object Float32Array]",S="[object Float64Array]",C="[object Int8Array]",A="[object Int16Array]",O="[object Int32Array]",E="[object Uint8Array]",T="[object Uint8ClampedArray]",M="[object Uint16Array]",R="[object Uint32Array]";function z(q,U,P){var $=q.constructor;switch(U){case y:return t(q);case s:case o:return new $(+q);case x:return e(q,P);case w:case S:case C:case A:case O:case E:case T:case M:case R:return r(q,P);case c:return new $;case u:case m:return new $(q);case h:return n(q);case d:return new $;case g:return i(q)}}return xv=z,xv}var wv,HM;function s8(){if(HM)return wv;HM=1;var t=Oi(),e=Object.create,n=(function(){function i(){}return function(r){if(!t(r))return{};if(e)return e(r);i.prototype=r;var s=new i;return i.prototype=void 0,s}})();return wv=n,wv}var Sv,UM;function a8(){if(UM)return Sv;UM=1;var t=s8(),e=Op(),n=_p();function i(r){return typeof r.constructor=="function"&&!n(r)?t(e(r)):{}}return Sv=i,Sv}var Cv,VM;function vQ(){if(VM)return Cv;VM=1;var t=kl(),e=hr(),n="[object Map]";function i(r){return e(r)&&t(r)==n}return Cv=i,Cv}var kv,FM;function bQ(){if(FM)return kv;FM=1;var t=vQ(),e=Ap(),n=j2(),i=n&&n.isMap,r=i?e(i):t;return kv=r,kv}var Av,$M;function xQ(){if($M)return Av;$M=1;var t=kl(),e=hr(),n="[object Set]";function i(r){return e(r)&&t(r)==n}return Av=i,Av}var _v,GM;function wQ(){if(GM)return _v;GM=1;var t=xQ(),e=Ap(),n=j2(),i=n&&n.isSet,r=i?e(i):t;return _v=r,_v}var Ov,YM;function o8(){if(YM)return Ov;YM=1;var t=wp(),e=B2(),n=Cp(),i=iQ(),r=aQ(),s=Xz(),o=Wz(),c=oQ(),u=lQ(),h=t8(),d=cQ(),m=kl(),g=dQ(),y=yQ(),x=a8(),w=Wt(),S=Cl(),C=bQ(),A=Oi(),O=wQ(),E=Js(),T=Xa(),M=1,R=2,z=4,q="[object Arguments]",U="[object Array]",P="[object Boolean]",$="[object Date]",K="[object Error]",L="[object Function]",Y="[object GeneratorFunction]",D="[object Map]",Q="[object Number]",ee="[object Object]",G="[object RegExp]",W="[object Set]",B="[object String]",F="[object Symbol]",ne="[object WeakMap]",I="[object ArrayBuffer]",X="[object DataView]",J="[object Float32Array]",oe="[object Float64Array]",ve="[object Int8Array]",H="[object Int16Array]",pe="[object Int32Array]",me="[object Uint8Array]",ye="[object Uint8ClampedArray]",_e="[object Uint16Array]",Ae="[object Uint32Array]",be={};be[q]=be[U]=be[I]=be[X]=be[P]=be[$]=be[J]=be[oe]=be[ve]=be[H]=be[pe]=be[D]=be[Q]=be[ee]=be[G]=be[W]=be[B]=be[F]=be[me]=be[ye]=be[_e]=be[Ae]=!0,be[K]=be[L]=be[ne]=!1;function He(we,ge,Be,vt,Xe,bt){var rt,et=ge&M,Et=ge&R,Pt=ge&z;if(Be&&(rt=Xe?Be(we,vt,Xe,bt):Be(we)),rt!==void 0)return rt;if(!A(we))return we;var Ht=w(we);if(Ht){if(rt=g(we),!et)return o(we,rt)}else{var ct=m(we),an=ct==L||ct==Y;if(S(we))return s(we,et);if(ct==ee||ct==q||an&&!Xe){if(rt=Et||an?{}:x(we),!et)return Et?u(we,r(rt,we)):c(we,i(rt,we))}else{if(!be[ct])return Xe?we:{};rt=y(we,ct,et)}}bt||(bt=new t);var Wn=bt.get(we);if(Wn)return Wn;bt.set(we,rt),O(we)?we.forEach(function(Ct){rt.add(He(Ct,ge,Be,Ct,we,bt))}):C(we)&&we.forEach(function(Ct,st){rt.set(st,He(Ct,ge,Be,st,we,bt))});var Tt=Pt?Et?d:h:Et?T:E,on=Ht?void 0:Tt(we);return e(on||we,function(Ct,st){on&&(st=Ct,Ct=we[st]),n(rt,st,He(Ct,ge,Be,st,we,bt))}),rt}return Ov=He,Ov}var Ev,QM;function SQ(){if(QM)return Ev;QM=1;var t=o8(),e=4;function n(i){return t(i,e)}return Ev=n,Ev}var Tv,XM;function V2(){if(XM)return Tv;XM=1;function t(e){return function(){return e}}return Tv=t,Tv}var Mv,WM;function CQ(){if(WM)return Mv;WM=1;function t(e){return function(n,i,r){for(var s=-1,o=Object(n),c=r(n),u=c.length;u--;){var h=c[e?u:++s];if(i(o[h],h,o)===!1)break}return n}}return Mv=t,Mv}var Rv,KM;function F2(){if(KM)return Rv;KM=1;var t=CQ(),e=t();return Rv=e,Rv}var Nv,ZM;function $2(){if(ZM)return Nv;ZM=1;var t=F2(),e=Js();function n(i,r){return i&&t(i,r,e)}return Nv=n,Nv}var Dv,JM;function kQ(){if(JM)return Dv;JM=1;var t=ts();function e(n,i){return function(r,s){if(r==null)return r;if(!t(r))return n(r,s);for(var o=r.length,c=i?o:-1,u=Object(r);(i?c--:++c<o)&&s(u[c],c,u)!==!1;);return r}}return Dv=e,Dv}var Lv,eR;function Ep(){if(eR)return Lv;eR=1;var t=$2(),e=kQ(),n=e(t);return Lv=n,Lv}var zv,tR;function Wa(){if(tR)return zv;tR=1;function t(e){return e}return zv=t,zv}var Bv,nR;function l8(){if(nR)return Bv;nR=1;var t=Wa();function e(n){return typeof n=="function"?n:t}return Bv=e,Bv}var qv,iR;function c8(){if(iR)return qv;iR=1;var t=B2(),e=Ep(),n=l8(),i=Wt();function r(s,o){var c=i(s)?t:e;return c(s,n(o))}return qv=r,qv}var jv,rR;function u8(){return rR||(rR=1,jv=c8()),jv}var Iv,sR;function AQ(){if(sR)return Iv;sR=1;var t=Ep();function e(n,i){var r=[];return t(n,function(s,o,c){i(s,o,c)&&r.push(s)}),r}return Iv=e,Iv}var Pv,aR;function _Q(){if(aR)return Pv;aR=1;var t="__lodash_hash_undefined__";function e(n){return this.__data__.set(n,t),this}return Pv=e,Pv}var Hv,oR;function OQ(){if(oR)return Hv;oR=1;function t(e){return this.__data__.has(e)}return Hv=t,Hv}var Uv,lR;function f8(){if(lR)return Uv;lR=1;var t=z2(),e=_Q(),n=OQ();function i(r){var s=-1,o=r==null?0:r.length;for(this.__data__=new t;++s<o;)this.add(r[s])}return i.prototype.add=i.prototype.push=e,i.prototype.has=n,Uv=i,Uv}var Vv,cR;function EQ(){if(cR)return Vv;cR=1;function t(e,n){for(var i=-1,r=e==null?0:e.length;++i<r;)if(n(e[i],i,e))return!0;return!1}return Vv=t,Vv}var Fv,uR;function h8(){if(uR)return Fv;uR=1;function t(e,n){return e.has(n)}return Fv=t,Fv}var $v,fR;function d8(){if(fR)return $v;fR=1;var t=f8(),e=EQ(),n=h8(),i=1,r=2;function s(o,c,u,h,d,m){var g=u&i,y=o.length,x=c.length;if(y!=x&&!(g&&x>y))return!1;var w=m.get(o),S=m.get(c);if(w&&S)return w==c&&S==o;var C=-1,A=!0,O=u&r?new t:void 0;for(m.set(o,c),m.set(c,o);++C<y;){var E=o[C],T=c[C];if(h)var M=g?h(T,E,C,c,o,m):h(E,T,C,o,c,m);if(M!==void 0){if(M)continue;A=!1;break}if(O){if(!e(c,function(R,z){if(!n(O,z)&&(E===R||d(E,R,u,h,m)))return O.push(z)})){A=!1;break}}else if(!(E===T||d(E,T,u,h,m))){A=!1;break}}return m.delete(o),m.delete(c),A}return $v=s,$v}var Gv,hR;function TQ(){if(hR)return Gv;hR=1;function t(e){var n=-1,i=Array(e.size);return e.forEach(function(r,s){i[++n]=[s,r]}),i}return Gv=t,Gv}var Yv,dR;function G2(){if(dR)return Yv;dR=1;function t(e){var n=-1,i=Array(e.size);return e.forEach(function(r){i[++n]=r}),i}return Yv=t,Yv}var Qv,pR;function MQ(){if(pR)return Qv;pR=1;var t=Sl(),e=i8(),n=wl(),i=d8(),r=TQ(),s=G2(),o=1,c=2,u="[object Boolean]",h="[object Date]",d="[object Error]",m="[object Map]",g="[object Number]",y="[object RegExp]",x="[object Set]",w="[object String]",S="[object Symbol]",C="[object ArrayBuffer]",A="[object DataView]",O=t?t.prototype:void 0,E=O?O.valueOf:void 0;function T(M,R,z,q,U,P,$){switch(z){case A:if(M.byteLength!=R.byteLength||M.byteOffset!=R.byteOffset)return!1;M=M.buffer,R=R.buffer;case C:return!(M.byteLength!=R.byteLength||!P(new e(M),new e(R)));case u:case h:case g:return n(+M,+R);case d:return M.name==R.name&&M.message==R.message;case y:case w:return M==R+"";case m:var K=r;case x:var L=q&o;if(K||(K=s),M.size!=R.size&&!L)return!1;var Y=$.get(M);if(Y)return Y==R;q|=c,$.set(M,R);var D=i(K(M),K(R),q,U,P,$);return $.delete(M),D;case S:if(E)return E.call(M)==E.call(R)}return!1}return Qv=T,Qv}var Xv,mR;function RQ(){if(mR)return Xv;mR=1;var t=t8(),e=1,n=Object.prototype,i=n.hasOwnProperty;function r(s,o,c,u,h,d){var m=c&e,g=t(s),y=g.length,x=t(o),w=x.length;if(y!=w&&!m)return!1;for(var S=y;S--;){var C=g[S];if(!(m?C in o:i.call(o,C)))return!1}var A=d.get(s),O=d.get(o);if(A&&O)return A==o&&O==s;var E=!0;d.set(s,o),d.set(o,s);for(var T=m;++S<y;){C=g[S];var M=s[C],R=o[C];if(u)var z=m?u(R,M,C,o,s,d):u(M,R,C,s,o,d);if(!(z===void 0?M===R||h(M,R,c,u,d):z)){E=!1;break}T||(T=C=="constructor")}if(E&&!T){var q=s.constructor,U=o.constructor;q!=U&&"constructor"in s&&"constructor"in o&&!(typeof q=="function"&&q instanceof q&&typeof U=="function"&&U instanceof U)&&(E=!1)}return d.delete(s),d.delete(o),E}return Xv=r,Xv}var Wv,gR;function NQ(){if(gR)return Wv;gR=1;var t=wp(),e=d8(),n=MQ(),i=RQ(),r=kl(),s=Wt(),o=Cl(),c=qu(),u=1,h="[object Arguments]",d="[object Array]",m="[object Object]",g=Object.prototype,y=g.hasOwnProperty;function x(w,S,C,A,O,E){var T=s(w),M=s(S),R=T?d:r(w),z=M?d:r(S);R=R==h?m:R,z=z==h?m:z;var q=R==m,U=z==m,P=R==z;if(P&&o(w)){if(!o(S))return!1;T=!0,q=!1}if(P&&!q)return E||(E=new t),T||c(w)?e(w,S,C,A,O,E):n(w,S,R,C,A,O,E);if(!(C&u)){var $=q&&y.call(w,"__wrapped__"),K=U&&y.call(S,"__wrapped__");if($||K){var L=$?w.value():w,Y=K?S.value():S;return E||(E=new t),O(L,Y,C,A,E)}}return P?(E||(E=new t),i(w,S,C,A,O,E)):!1}return Wv=x,Wv}var Kv,yR;function p8(){if(yR)return Kv;yR=1;var t=NQ(),e=hr();function n(i,r,s,o,c){return i===r?!0:i==null||r==null||!e(i)&&!e(r)?i!==i&&r!==r:t(i,r,s,o,n,c)}return Kv=n,Kv}var Zv,vR;function DQ(){if(vR)return Zv;vR=1;var t=wp(),e=p8(),n=1,i=2;function r(s,o,c,u){var h=c.length,d=h,m=!u;if(s==null)return!d;for(s=Object(s);h--;){var g=c[h];if(m&&g[2]?g[1]!==s[g[0]]:!(g[0]in s))return!1}for(;++h<d;){g=c[h];var y=g[0],x=s[y],w=g[1];if(m&&g[2]){if(x===void 0&&!(y in s))return!1}else{var S=new t;if(u)var C=u(x,w,y,s,o,S);if(!(C===void 0?e(w,x,n|i,u,S):C))return!1}}return!0}return Zv=r,Zv}var Jv,bR;function m8(){if(bR)return Jv;bR=1;var t=Oi();function e(n){return n===n&&!t(n)}return Jv=e,Jv}var eb,xR;function LQ(){if(xR)return eb;xR=1;var t=m8(),e=Js();function n(i){for(var r=e(i),s=r.length;s--;){var o=r[s],c=i[o];r[s]=[o,c,t(c)]}return r}return eb=n,eb}var tb,wR;function g8(){if(wR)return tb;wR=1;function t(e,n){return function(i){return i==null?!1:i[e]===n&&(n!==void 0||e in Object(i))}}return tb=t,tb}var nb,SR;function zQ(){if(SR)return nb;SR=1;var t=DQ(),e=LQ(),n=g8();function i(r){var s=e(r);return s.length==1&&s[0][2]?n(s[0][0],s[0][1]):function(o){return o===r||t(o,r,s)}}return nb=i,nb}var ib,CR;function Al(){if(CR)return ib;CR=1;var t=Ya(),e=hr(),n="[object Symbol]";function i(r){return typeof r=="symbol"||e(r)&&t(r)==n}return ib=i,ib}var rb,kR;function Y2(){if(kR)return rb;kR=1;var t=Wt(),e=Al(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,i=/^\w*$/;function r(s,o){if(t(s))return!1;var c=typeof s;return c=="number"||c=="symbol"||c=="boolean"||s==null||e(s)?!0:i.test(s)||!n.test(s)||o!=null&&s in Object(o)}return rb=r,rb}var sb,AR;function BQ(){if(AR)return sb;AR=1;var t=z2(),e="Expected a function";function n(i,r){if(typeof i!="function"||r!=null&&typeof r!="function")throw new TypeError(e);var s=function(){var o=arguments,c=r?r.apply(this,o):o[0],u=s.cache;if(u.has(c))return u.get(c);var h=i.apply(this,o);return s.cache=u.set(c,h)||u,h};return s.cache=new(n.Cache||t),s}return n.Cache=t,sb=n,sb}var ab,_R;function qQ(){if(_R)return ab;_R=1;var t=BQ(),e=500;function n(i){var r=t(i,function(o){return s.size===e&&s.clear(),o}),s=r.cache;return r}return ab=n,ab}var ob,OR;function jQ(){if(OR)return ob;OR=1;var t=qQ(),e=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,n=/\\(\\)?/g,i=t(function(r){var s=[];return r.charCodeAt(0)===46&&s.push(""),r.replace(e,function(o,c,u,h){s.push(u?h.replace(n,"$1"):c||o)}),s});return ob=i,ob}var lb,ER;function Tp(){if(ER)return lb;ER=1;function t(e,n){for(var i=-1,r=e==null?0:e.length,s=Array(r);++i<r;)s[i]=n(e[i],i,e);return s}return lb=t,lb}var cb,TR;function IQ(){if(TR)return cb;TR=1;var t=Sl(),e=Tp(),n=Wt(),i=Al(),r=t?t.prototype:void 0,s=r?r.toString:void 0;function o(c){if(typeof c=="string")return c;if(n(c))return e(c,o)+"";if(i(c))return s?s.call(c):"";var u=c+"";return u=="0"&&1/c==-1/0?"-0":u}return cb=o,cb}var ub,MR;function y8(){if(MR)return ub;MR=1;var t=IQ();function e(n){return n==null?"":t(n)}return ub=e,ub}var fb,RR;function Mp(){if(RR)return fb;RR=1;var t=Wt(),e=Y2(),n=jQ(),i=y8();function r(s,o){return t(s)?s:e(s,o)?[s]:n(i(s))}return fb=r,fb}var hb,NR;function ju(){if(NR)return hb;NR=1;var t=Al();function e(n){if(typeof n=="string"||t(n))return n;var i=n+"";return i=="0"&&1/n==-1/0?"-0":i}return hb=e,hb}var db,DR;function Rp(){if(DR)return db;DR=1;var t=Mp(),e=ju();function n(i,r){r=t(r,i);for(var s=0,o=r.length;i!=null&&s<o;)i=i[e(r[s++])];return s&&s==o?i:void 0}return db=n,db}var pb,LR;function PQ(){if(LR)return pb;LR=1;var t=Rp();function e(n,i,r){var s=n==null?void 0:t(n,i);return s===void 0?r:s}return pb=e,pb}var mb,zR;function HQ(){if(zR)return mb;zR=1;function t(e,n){return e!=null&&n in Object(e)}return mb=t,mb}var gb,BR;function v8(){if(BR)return gb;BR=1;var t=Mp(),e=Bu(),n=Wt(),i=kp(),r=q2(),s=ju();function o(c,u,h){u=t(u,c);for(var d=-1,m=u.length,g=!1;++d<m;){var y=s(u[d]);if(!(g=c!=null&&h(c,y)))break;c=c[y]}return g||++d!=m?g:(m=c==null?0:c.length,!!m&&r(m)&&i(y,m)&&(n(c)||e(c)))}return gb=o,gb}var yb,qR;function b8(){if(qR)return yb;qR=1;var t=HQ(),e=v8();function n(i,r){return i!=null&&e(i,r,t)}return yb=n,yb}var vb,jR;function UQ(){if(jR)return vb;jR=1;var t=p8(),e=PQ(),n=b8(),i=Y2(),r=m8(),s=g8(),o=ju(),c=1,u=2;function h(d,m){return i(d)&&r(m)?s(o(d),m):function(g){var y=e(g,d);return y===void 0&&y===m?n(g,d):t(m,y,c|u)}}return vb=h,vb}var bb,IR;function x8(){if(IR)return bb;IR=1;function t(e){return function(n){return n?.[e]}}return bb=t,bb}var xb,PR;function VQ(){if(PR)return xb;PR=1;var t=Rp();function e(n){return function(i){return t(i,n)}}return xb=e,xb}var wb,HR;function FQ(){if(HR)return wb;HR=1;var t=x8(),e=VQ(),n=Y2(),i=ju();function r(s){return n(s)?t(i(s)):e(s)}return wb=r,wb}var Sb,UR;function ns(){if(UR)return Sb;UR=1;var t=zQ(),e=UQ(),n=Wa(),i=Wt(),r=FQ();function s(o){return typeof o=="function"?o:o==null?n:typeof o=="object"?i(o)?e(o[0],o[1]):t(o):r(o)}return Sb=s,Sb}var Cb,VR;function w8(){if(VR)return Cb;VR=1;var t=Kz(),e=AQ(),n=ns(),i=Wt();function r(s,o){var c=i(s)?t:e;return c(s,n(o,3))}return Cb=r,Cb}var kb,FR;function $Q(){if(FR)return kb;FR=1;var t=Object.prototype,e=t.hasOwnProperty;function n(i,r){return i!=null&&e.call(i,r)}return kb=n,kb}var Ab,$R;function S8(){if($R)return Ab;$R=1;var t=$Q(),e=v8();function n(i,r){return i!=null&&e(i,r,t)}return Ab=n,Ab}var _b,GR;function GQ(){if(GR)return _b;GR=1;var t=I2(),e=kl(),n=Bu(),i=Wt(),r=ts(),s=Cl(),o=_p(),c=qu(),u="[object Map]",h="[object Set]",d=Object.prototype,m=d.hasOwnProperty;function g(y){if(y==null)return!0;if(r(y)&&(i(y)||typeof y=="string"||typeof y.splice=="function"||s(y)||c(y)||n(y)))return!y.length;var x=e(y);if(x==u||x==h)return!y.size;if(o(y))return!t(y).length;for(var w in y)if(m.call(y,w))return!1;return!0}return _b=g,_b}var Ob,YR;function C8(){if(YR)return Ob;YR=1;function t(e){return e===void 0}return Ob=t,Ob}var Eb,QR;function k8(){if(QR)return Eb;QR=1;var t=Ep(),e=ts();function n(i,r){var s=-1,o=e(i)?Array(i.length):[];return t(i,function(c,u,h){o[++s]=r(c,u,h)}),o}return Eb=n,Eb}var Tb,XR;function A8(){if(XR)return Tb;XR=1;var t=Tp(),e=ns(),n=k8(),i=Wt();function r(s,o){var c=i(s)?t:n;return c(s,e(o,3))}return Tb=r,Tb}var Mb,WR;function YQ(){if(WR)return Mb;WR=1;function t(e,n,i,r){var s=-1,o=e==null?0:e.length;for(r&&o&&(i=e[++s]);++s<o;)i=n(i,e[s],s,e);return i}return Mb=t,Mb}var Rb,KR;function QQ(){if(KR)return Rb;KR=1;function t(e,n,i,r,s){return s(e,function(o,c,u){i=r?(r=!1,o):n(i,o,c,u)}),i}return Rb=t,Rb}var Nb,ZR;function _8(){if(ZR)return Nb;ZR=1;var t=YQ(),e=Ep(),n=ns(),i=QQ(),r=Wt();function s(o,c,u){var h=r(o)?t:i,d=arguments.length<3;return h(o,n(c,4),u,d,e)}return Nb=s,Nb}var Db,JR;function XQ(){if(JR)return Db;JR=1;var t=Ya(),e=Wt(),n=hr(),i="[object String]";function r(s){return typeof s=="string"||!e(s)&&n(s)&&t(s)==i}return Db=r,Db}var Lb,eN;function WQ(){if(eN)return Lb;eN=1;var t=x8(),e=t("length");return Lb=e,Lb}var zb,tN;function KQ(){if(tN)return zb;tN=1;var t="\\ud800-\\udfff",e="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",i="\\u20d0-\\u20ff",r=e+n+i,s="\\ufe0e\\ufe0f",o="\\u200d",c=RegExp("["+o+t+r+s+"]");function u(h){return c.test(h)}return zb=u,zb}var Bb,nN;function ZQ(){if(nN)return Bb;nN=1;var t="\\ud800-\\udfff",e="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",i="\\u20d0-\\u20ff",r=e+n+i,s="\\ufe0e\\ufe0f",o="["+t+"]",c="["+r+"]",u="\\ud83c[\\udffb-\\udfff]",h="(?:"+c+"|"+u+")",d="[^"+t+"]",m="(?:\\ud83c[\\udde6-\\uddff]){2}",g="[\\ud800-\\udbff][\\udc00-\\udfff]",y="\\u200d",x=h+"?",w="["+s+"]?",S="(?:"+y+"(?:"+[d,m,g].join("|")+")"+w+x+")*",C=w+x+S,A="(?:"+[d+c+"?",c,m,g,o].join("|")+")",O=RegExp(u+"(?="+u+")|"+A+C,"g");function E(T){for(var M=O.lastIndex=0;O.test(T);)++M;return M}return Bb=E,Bb}var qb,iN;function JQ(){if(iN)return qb;iN=1;var t=WQ(),e=KQ(),n=ZQ();function i(r){return e(r)?n(r):t(r)}return qb=i,qb}var jb,rN;function eX(){if(rN)return jb;rN=1;var t=I2(),e=kl(),n=ts(),i=XQ(),r=JQ(),s="[object Map]",o="[object Set]";function c(u){if(u==null)return 0;if(n(u))return i(u)?r(u):u.length;var h=e(u);return h==s||h==o?u.size:t(u).length}return jb=c,jb}var Ib,sN;function tX(){if(sN)return Ib;sN=1;var t=B2(),e=s8(),n=$2(),i=ns(),r=Op(),s=Wt(),o=Cl(),c=Lu(),u=Oi(),h=qu();function d(m,g,y){var x=s(m),w=x||o(m)||h(m);if(g=i(g,4),y==null){var S=m&&m.constructor;w?y=x?new S:[]:u(m)?y=c(S)?e(r(m)):{}:y={}}return(w?t:n)(m,function(C,A,O){return g(y,C,A,O)}),y}return Ib=d,Ib}var Pb,aN;function nX(){if(aN)return Pb;aN=1;var t=Sl(),e=Bu(),n=Wt(),i=t?t.isConcatSpreadable:void 0;function r(s){return n(s)||e(s)||!!(i&&s&&s[i])}return Pb=r,Pb}var Hb,oN;function Q2(){if(oN)return Hb;oN=1;var t=H2(),e=nX();function n(i,r,s,o,c){var u=-1,h=i.length;for(s||(s=e),c||(c=[]);++u<h;){var d=i[u];r>0&&s(d)?r>1?n(d,r-1,s,o,c):t(c,d):o||(c[c.length]=d)}return c}return Hb=n,Hb}var Ub,lN;function iX(){if(lN)return Ub;lN=1;function t(e,n,i){switch(i.length){case 0:return e.call(n);case 1:return e.call(n,i[0]);case 2:return e.call(n,i[0],i[1]);case 3:return e.call(n,i[0],i[1],i[2])}return e.apply(n,i)}return Ub=t,Ub}var Vb,cN;function O8(){if(cN)return Vb;cN=1;var t=iX(),e=Math.max;function n(i,r,s){return r=e(r===void 0?i.length-1:r,0),function(){for(var o=arguments,c=-1,u=e(o.length-r,0),h=Array(u);++c<u;)h[c]=o[r+c];c=-1;for(var d=Array(r+1);++c<r;)d[c]=o[c];return d[r]=s(h),t(i,this,d)}}return Vb=n,Vb}var Fb,uN;function rX(){if(uN)return Fb;uN=1;var t=V2(),e=Gz(),n=Wa(),i=e?function(r,s){return e(r,"toString",{configurable:!0,enumerable:!1,value:t(s),writable:!0})}:n;return Fb=i,Fb}var $b,fN;function sX(){if(fN)return $b;fN=1;var t=800,e=16,n=Date.now;function i(r){var s=0,o=0;return function(){var c=n(),u=e-(c-o);if(o=c,u>0){if(++s>=t)return arguments[0]}else s=0;return r.apply(void 0,arguments)}}return $b=i,$b}var Gb,hN;function E8(){if(hN)return Gb;hN=1;var t=rX(),e=sX(),n=e(t);return Gb=n,Gb}var Yb,dN;function Np(){if(dN)return Yb;dN=1;var t=Wa(),e=O8(),n=E8();function i(r,s){return n(e(r,s,t),r+"")}return Yb=i,Yb}var Qb,pN;function T8(){if(pN)return Qb;pN=1;function t(e,n,i,r){for(var s=e.length,o=i+(r?1:-1);r?o--:++o<s;)if(n(e[o],o,e))return o;return-1}return Qb=t,Qb}var Xb,mN;function aX(){if(mN)return Xb;mN=1;function t(e){return e!==e}return Xb=t,Xb}var Wb,gN;function oX(){if(gN)return Wb;gN=1;function t(e,n,i){for(var r=i-1,s=e.length;++r<s;)if(e[r]===n)return r;return-1}return Wb=t,Wb}var Kb,yN;function lX(){if(yN)return Kb;yN=1;var t=T8(),e=aX(),n=oX();function i(r,s,o){return s===s?n(r,s,o):t(r,e,o)}return Kb=i,Kb}var Zb,vN;function cX(){if(vN)return Zb;vN=1;var t=lX();function e(n,i){var r=n==null?0:n.length;return!!r&&t(n,i,0)>-1}return Zb=e,Zb}var Jb,bN;function uX(){if(bN)return Jb;bN=1;function t(e,n,i){for(var r=-1,s=e==null?0:e.length;++r<s;)if(i(n,e[r]))return!0;return!1}return Jb=t,Jb}var ex,xN;function fX(){if(xN)return ex;xN=1;function t(){}return ex=t,ex}var tx,wN;function hX(){if(wN)return tx;wN=1;var t=n8(),e=fX(),n=G2(),i=1/0,r=t&&1/n(new t([,-0]))[1]==i?function(s){return new t(s)}:e;return tx=r,tx}var nx,SN;function dX(){if(SN)return nx;SN=1;var t=f8(),e=cX(),n=uX(),i=h8(),r=hX(),s=G2(),o=200;function c(u,h,d){var m=-1,g=e,y=u.length,x=!0,w=[],S=w;if(d)x=!1,g=n;else if(y>=o){var C=h?null:r(u);if(C)return s(C);x=!1,g=i,S=new t}else S=h?[]:w;e:for(;++m<y;){var A=u[m],O=h?h(A):A;if(A=d||A!==0?A:0,x&&O===O){for(var E=S.length;E--;)if(S[E]===O)continue e;h&&S.push(O),w.push(A)}else g(S,O,d)||(S!==w&&S.push(O),w.push(A))}return w}return nx=c,nx}var ix,CN;function M8(){if(CN)return ix;CN=1;var t=ts(),e=hr();function n(i){return e(i)&&t(i)}return ix=n,ix}var rx,kN;function pX(){if(kN)return rx;kN=1;var t=Q2(),e=Np(),n=dX(),i=M8(),r=e(function(s){return n(t(s,1,i,!0))});return rx=r,rx}var sx,AN;function mX(){if(AN)return sx;AN=1;var t=Tp();function e(n,i){return t(i,function(r){return n[r]})}return sx=e,sx}var ax,_N;function R8(){if(_N)return ax;_N=1;var t=mX(),e=Js();function n(i){return i==null?[]:t(i,e(i))}return ax=n,ax}var ox,ON;function Ei(){if(ON)return ox;ON=1;var t;if(typeof D2=="function")try{t={clone:SQ(),constant:V2(),each:u8(),filter:w8(),has:S8(),isArray:Wt(),isEmpty:GQ(),isFunction:Lu(),isUndefined:C8(),keys:Js(),map:A8(),reduce:_8(),size:eX(),transform:tX(),union:pX(),values:R8()}}catch{}return t||(t=window._),ox=t,ox}var lx,EN;function X2(){if(EN)return lx;EN=1;var t=Ei();lx=r;var e="\0",n="\0",i="";function r(d){this._isDirected=t.has(d,"directed")?d.directed:!0,this._isMultigraph=t.has(d,"multigraph")?d.multigraph:!1,this._isCompound=t.has(d,"compound")?d.compound:!1,this._label=void 0,this._defaultNodeLabelFn=t.constant(void 0),this._defaultEdgeLabelFn=t.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[n]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}r.prototype._nodeCount=0,r.prototype._edgeCount=0,r.prototype.isDirected=function(){return this._isDirected},r.prototype.isMultigraph=function(){return this._isMultigraph},r.prototype.isCompound=function(){return this._isCompound},r.prototype.setGraph=function(d){return this._label=d,this},r.prototype.graph=function(){return this._label},r.prototype.setDefaultNodeLabel=function(d){return t.isFunction(d)||(d=t.constant(d)),this._defaultNodeLabelFn=d,this},r.prototype.nodeCount=function(){return this._nodeCount},r.prototype.nodes=function(){return t.keys(this._nodes)},r.prototype.sources=function(){var d=this;return t.filter(this.nodes(),function(m){return t.isEmpty(d._in[m])})},r.prototype.sinks=function(){var d=this;return t.filter(this.nodes(),function(m){return t.isEmpty(d._out[m])})},r.prototype.setNodes=function(d,m){var g=arguments,y=this;return t.each(d,function(x){g.length>1?y.setNode(x,m):y.setNode(x)}),this},r.prototype.setNode=function(d,m){return t.has(this._nodes,d)?(arguments.length>1&&(this._nodes[d]=m),this):(this._nodes[d]=arguments.length>1?m:this._defaultNodeLabelFn(d),this._isCompound&&(this._parent[d]=n,this._children[d]={},this._children[n][d]=!0),this._in[d]={},this._preds[d]={},this._out[d]={},this._sucs[d]={},++this._nodeCount,this)},r.prototype.node=function(d){return this._nodes[d]},r.prototype.hasNode=function(d){return t.has(this._nodes,d)},r.prototype.removeNode=function(d){var m=this;if(t.has(this._nodes,d)){var g=function(y){m.removeEdge(m._edgeObjs[y])};delete this._nodes[d],this._isCompound&&(this._removeFromParentsChildList(d),delete this._parent[d],t.each(this.children(d),function(y){m.setParent(y)}),delete this._children[d]),t.each(t.keys(this._in[d]),g),delete this._in[d],delete this._preds[d],t.each(t.keys(this._out[d]),g),delete this._out[d],delete this._sucs[d],--this._nodeCount}return this},r.prototype.setParent=function(d,m){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(t.isUndefined(m))m=n;else{m+="";for(var g=m;!t.isUndefined(g);g=this.parent(g))if(g===d)throw new Error("Setting "+m+" as parent of "+d+" would create a cycle");this.setNode(m)}return this.setNode(d),this._removeFromParentsChildList(d),this._parent[d]=m,this._children[m][d]=!0,this},r.prototype._removeFromParentsChildList=function(d){delete this._children[this._parent[d]][d]},r.prototype.parent=function(d){if(this._isCompound){var m=this._parent[d];if(m!==n)return m}},r.prototype.children=function(d){if(t.isUndefined(d)&&(d=n),this._isCompound){var m=this._children[d];if(m)return t.keys(m)}else{if(d===n)return this.nodes();if(this.hasNode(d))return[]}},r.prototype.predecessors=function(d){var m=this._preds[d];if(m)return t.keys(m)},r.prototype.successors=function(d){var m=this._sucs[d];if(m)return t.keys(m)},r.prototype.neighbors=function(d){var m=this.predecessors(d);if(m)return t.union(m,this.successors(d))},r.prototype.isLeaf=function(d){var m;return this.isDirected()?m=this.successors(d):m=this.neighbors(d),m.length===0},r.prototype.filterNodes=function(d){var m=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});m.setGraph(this.graph());var g=this;t.each(this._nodes,function(w,S){d(S)&&m.setNode(S,w)}),t.each(this._edgeObjs,function(w){m.hasNode(w.v)&&m.hasNode(w.w)&&m.setEdge(w,g.edge(w))});var y={};function x(w){var S=g.parent(w);return S===void 0||m.hasNode(S)?(y[w]=S,S):S in y?y[S]:x(S)}return this._isCompound&&t.each(m.nodes(),function(w){m.setParent(w,x(w))}),m},r.prototype.setDefaultEdgeLabel=function(d){return t.isFunction(d)||(d=t.constant(d)),this._defaultEdgeLabelFn=d,this},r.prototype.edgeCount=function(){return this._edgeCount},r.prototype.edges=function(){return t.values(this._edgeObjs)},r.prototype.setPath=function(d,m){var g=this,y=arguments;return t.reduce(d,function(x,w){return y.length>1?g.setEdge(x,w,m):g.setEdge(x,w),w}),this},r.prototype.setEdge=function(){var d,m,g,y,x=!1,w=arguments[0];typeof w=="object"&&w!==null&&"v"in w?(d=w.v,m=w.w,g=w.name,arguments.length===2&&(y=arguments[1],x=!0)):(d=w,m=arguments[1],g=arguments[3],arguments.length>2&&(y=arguments[2],x=!0)),d=""+d,m=""+m,t.isUndefined(g)||(g=""+g);var S=c(this._isDirected,d,m,g);if(t.has(this._edgeLabels,S))return x&&(this._edgeLabels[S]=y),this;if(!t.isUndefined(g)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(d),this.setNode(m),this._edgeLabels[S]=x?y:this._defaultEdgeLabelFn(d,m,g);var C=u(this._isDirected,d,m,g);return d=C.v,m=C.w,Object.freeze(C),this._edgeObjs[S]=C,s(this._preds[m],d),s(this._sucs[d],m),this._in[m][S]=C,this._out[d][S]=C,this._edgeCount++,this},r.prototype.edge=function(d,m,g){var y=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,d,m,g);return this._edgeLabels[y]},r.prototype.hasEdge=function(d,m,g){var y=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,d,m,g);return t.has(this._edgeLabels,y)},r.prototype.removeEdge=function(d,m,g){var y=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,d,m,g),x=this._edgeObjs[y];return x&&(d=x.v,m=x.w,delete this._edgeLabels[y],delete this._edgeObjs[y],o(this._preds[m],d),o(this._sucs[d],m),delete this._in[m][y],delete this._out[d][y],this._edgeCount--),this},r.prototype.inEdges=function(d,m){var g=this._in[d];if(g){var y=t.values(g);return m?t.filter(y,function(x){return x.v===m}):y}},r.prototype.outEdges=function(d,m){var g=this._out[d];if(g){var y=t.values(g);return m?t.filter(y,function(x){return x.w===m}):y}},r.prototype.nodeEdges=function(d,m){var g=this.inEdges(d,m);if(g)return g.concat(this.outEdges(d,m))};function s(d,m){d[m]?d[m]++:d[m]=1}function o(d,m){--d[m]||delete d[m]}function c(d,m,g,y){var x=""+m,w=""+g;if(!d&&x>w){var S=x;x=w,w=S}return x+i+w+i+(t.isUndefined(y)?e:y)}function u(d,m,g,y){var x=""+m,w=""+g;if(!d&&x>w){var S=x;x=w,w=S}var C={v:x,w};return y&&(C.name=y),C}function h(d,m){return c(d,m.v,m.w,m.name)}return lx}var cx,TN;function gX(){return TN||(TN=1,cx="2.1.8"),cx}var ux,MN;function yX(){return MN||(MN=1,ux={Graph:X2(),version:gX()}),ux}var fx,RN;function vX(){if(RN)return fx;RN=1;var t=Ei(),e=X2();fx={write:n,read:s};function n(o){var c={options:{directed:o.isDirected(),multigraph:o.isMultigraph(),compound:o.isCompound()},nodes:i(o),edges:r(o)};return t.isUndefined(o.graph())||(c.value=t.clone(o.graph())),c}function i(o){return t.map(o.nodes(),function(c){var u=o.node(c),h=o.parent(c),d={v:c};return t.isUndefined(u)||(d.value=u),t.isUndefined(h)||(d.parent=h),d})}function r(o){return t.map(o.edges(),function(c){var u=o.edge(c),h={v:c.v,w:c.w};return t.isUndefined(c.name)||(h.name=c.name),t.isUndefined(u)||(h.value=u),h})}function s(o){var c=new e(o.options).setGraph(o.value);return t.each(o.nodes,function(u){c.setNode(u.v,u.value),u.parent&&c.setParent(u.v,u.parent)}),t.each(o.edges,function(u){c.setEdge({v:u.v,w:u.w,name:u.name},u.value)}),c}return fx}var hx,NN;function bX(){if(NN)return hx;NN=1;var t=Ei();hx=e;function e(n){var i={},r=[],s;function o(c){t.has(i,c)||(i[c]=!0,s.push(c),t.each(n.successors(c),o),t.each(n.predecessors(c),o))}return t.each(n.nodes(),function(c){s=[],o(c),s.length&&r.push(s)}),r}return hx}var dx,DN;function N8(){if(DN)return dx;DN=1;var t=Ei();dx=e;function e(){this._arr=[],this._keyIndices={}}return e.prototype.size=function(){return this._arr.length},e.prototype.keys=function(){return this._arr.map(function(n){return n.key})},e.prototype.has=function(n){return t.has(this._keyIndices,n)},e.prototype.priority=function(n){var i=this._keyIndices[n];if(i!==void 0)return this._arr[i].priority},e.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},e.prototype.add=function(n,i){var r=this._keyIndices;if(n=String(n),!t.has(r,n)){var s=this._arr,o=s.length;return r[n]=o,s.push({key:n,priority:i}),this._decrease(o),!0}return!1},e.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var n=this._arr.pop();return delete this._keyIndices[n.key],this._heapify(0),n.key},e.prototype.decrease=function(n,i){var r=this._keyIndices[n];if(i>this._arr[r].priority)throw new Error("New priority is greater than current priority. Key: "+n+" Old: "+this._arr[r].priority+" New: "+i);this._arr[r].priority=i,this._decrease(r)},e.prototype._heapify=function(n){var i=this._arr,r=2*n,s=r+1,o=n;r<i.length&&(o=i[r].priority<i[o].priority?r:o,s<i.length&&(o=i[s].priority<i[o].priority?s:o),o!==n&&(this._swap(n,o),this._heapify(o)))},e.prototype._decrease=function(n){for(var i=this._arr,r=i[n].priority,s;n!==0&&(s=n>>1,!(i[s].priority<r));)this._swap(n,s),n=s},e.prototype._swap=function(n,i){var r=this._arr,s=this._keyIndices,o=r[n],c=r[i];r[n]=c,r[i]=o,s[c.key]=n,s[o.key]=i},dx}var px,LN;function D8(){if(LN)return px;LN=1;var t=Ei(),e=N8();px=i;var n=t.constant(1);function i(s,o,c,u){return r(s,String(o),c||n,u||function(h){return s.outEdges(h)})}function r(s,o,c,u){var h={},d=new e,m,g,y=function(x){var w=x.v!==m?x.v:x.w,S=h[w],C=c(x),A=g.distance+C;if(C<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+x+" Weight: "+C);A<S.distance&&(S.distance=A,S.predecessor=m,d.decrease(w,A))};for(s.nodes().forEach(function(x){var w=x===o?0:Number.POSITIVE_INFINITY;h[x]={distance:w},d.add(x,w)});d.size()>0&&(m=d.removeMin(),g=h[m],g.distance!==Number.POSITIVE_INFINITY);)u(m).forEach(y);return h}return px}var mx,zN;function xX(){if(zN)return mx;zN=1;var t=D8(),e=Ei();mx=n;function n(i,r,s){return e.transform(i.nodes(),function(o,c){o[c]=t(i,c,r,s)},{})}return mx}var gx,BN;function L8(){if(BN)return gx;BN=1;var t=Ei();gx=e;function e(n){var i=0,r=[],s={},o=[];function c(u){var h=s[u]={onStack:!0,lowlink:i,index:i++};if(r.push(u),n.successors(u).forEach(function(g){t.has(s,g)?s[g].onStack&&(h.lowlink=Math.min(h.lowlink,s[g].index)):(c(g),h.lowlink=Math.min(h.lowlink,s[g].lowlink))}),h.lowlink===h.index){var d=[],m;do m=r.pop(),s[m].onStack=!1,d.push(m);while(u!==m);o.push(d)}}return n.nodes().forEach(function(u){t.has(s,u)||c(u)}),o}return gx}var yx,qN;function wX(){if(qN)return yx;qN=1;var t=Ei(),e=L8();yx=n;function n(i){return t.filter(e(i),function(r){return r.length>1||r.length===1&&i.hasEdge(r[0],r[0])})}return yx}var vx,jN;function SX(){if(jN)return vx;jN=1;var t=Ei();vx=n;var e=t.constant(1);function n(r,s,o){return i(r,s||e,o||function(c){return r.outEdges(c)})}function i(r,s,o){var c={},u=r.nodes();return u.forEach(function(h){c[h]={},c[h][h]={distance:0},u.forEach(function(d){h!==d&&(c[h][d]={distance:Number.POSITIVE_INFINITY})}),o(h).forEach(function(d){var m=d.v===h?d.w:d.v,g=s(d);c[h][m]={distance:g,predecessor:h}})}),u.forEach(function(h){var d=c[h];u.forEach(function(m){var g=c[m];u.forEach(function(y){var x=g[h],w=d[y],S=g[y],C=x.distance+w.distance;C<S.distance&&(S.distance=C,S.predecessor=w.predecessor)})})}),c}return vx}var bx,IN;function z8(){if(IN)return bx;IN=1;var t=Ei();bx=e,e.CycleException=n;function e(i){var r={},s={},o=[];function c(u){if(t.has(s,u))throw new n;t.has(r,u)||(s[u]=!0,r[u]=!0,t.each(i.predecessors(u),c),delete s[u],o.push(u))}if(t.each(i.sinks(),c),t.size(r)!==i.nodeCount())throw new n;return o}function n(){}return n.prototype=new Error,bx}var xx,PN;function CX(){if(PN)return xx;PN=1;var t=z8();xx=e;function e(n){try{t(n)}catch(i){if(i instanceof t.CycleException)return!1;throw i}return!0}return xx}var wx,HN;function B8(){if(HN)return wx;HN=1;var t=Ei();wx=e;function e(i,r,s){t.isArray(r)||(r=[r]);var o=(i.isDirected()?i.successors:i.neighbors).bind(i),c=[],u={};return t.each(r,function(h){if(!i.hasNode(h))throw new Error("Graph does not have node: "+h);n(i,h,s==="post",u,o,c)}),c}function n(i,r,s,o,c,u){t.has(o,r)||(o[r]=!0,s||u.push(r),t.each(c(r),function(h){n(i,h,s,o,c,u)}),s&&u.push(r))}return wx}var Sx,UN;function kX(){if(UN)return Sx;UN=1;var t=B8();Sx=e;function e(n,i){return t(n,i,"post")}return Sx}var Cx,VN;function AX(){if(VN)return Cx;VN=1;var t=B8();Cx=e;function e(n,i){return t(n,i,"pre")}return Cx}var kx,FN;function _X(){if(FN)return kx;FN=1;var t=Ei(),e=X2(),n=N8();kx=i;function i(r,s){var o=new e,c={},u=new n,h;function d(g){var y=g.v===h?g.w:g.v,x=u.priority(y);if(x!==void 0){var w=s(g);w<x&&(c[y]=h,u.decrease(y,w))}}if(r.nodeCount()===0)return o;t.each(r.nodes(),function(g){u.add(g,Number.POSITIVE_INFINITY),o.setNode(g)}),u.decrease(r.nodes()[0],0);for(var m=!1;u.size()>0;){if(h=u.removeMin(),t.has(c,h))o.setEdge(h,c[h]);else{if(m)throw new Error("Input graph is not connected: "+r);m=!0}r.nodeEdges(h).forEach(d)}return o}return kx}var Ax,$N;function OX(){return $N||($N=1,Ax={components:bX(),dijkstra:D8(),dijkstraAll:xX(),findCycles:wX(),floydWarshall:SX(),isAcyclic:CX(),postorder:kX(),preorder:AX(),prim:_X(),tarjan:L8(),topsort:z8()}),Ax}var _x,GN;function EX(){if(GN)return _x;GN=1;var t=yX();return _x={Graph:t.Graph,json:vX(),alg:OX(),version:t.version},_x}var Ox,YN;function ji(){if(YN)return Ox;YN=1;var t;if(typeof D2=="function")try{t=EX()}catch{}return t||(t=window.graphlib),Ox=t,Ox}var Ex,QN;function TX(){if(QN)return Ex;QN=1;var t=o8(),e=1,n=4;function i(r){return t(r,e|n)}return Ex=i,Ex}var Tx,XN;function Dp(){if(XN)return Tx;XN=1;var t=wl(),e=ts(),n=kp(),i=Oi();function r(s,o,c){if(!i(c))return!1;var u=typeof o;return(u=="number"?e(c)&&n(o,c.length):u=="string"&&o in c)?t(c[o],s):!1}return Tx=r,Tx}var Mx,WN;function MX(){if(WN)return Mx;WN=1;var t=Np(),e=wl(),n=Dp(),i=Xa(),r=Object.prototype,s=r.hasOwnProperty,o=t(function(c,u){c=Object(c);var h=-1,d=u.length,m=d>2?u[2]:void 0;for(m&&n(u[0],u[1],m)&&(d=1);++h<d;)for(var g=u[h],y=i(g),x=-1,w=y.length;++x<w;){var S=y[x],C=c[S];(C===void 0||e(C,r[S])&&!s.call(c,S))&&(c[S]=g[S])}return c});return Mx=o,Mx}var Rx,KN;function RX(){if(KN)return Rx;KN=1;var t=ns(),e=ts(),n=Js();function i(r){return function(s,o,c){var u=Object(s);if(!e(s)){var h=t(o,3);s=n(s),o=function(m){return h(u[m],m,u)}}var d=r(s,o,c);return d>-1?u[h?s[d]:d]:void 0}}return Rx=i,Rx}var Nx,ZN;function NX(){if(ZN)return Nx;ZN=1;var t=/\s/;function e(n){for(var i=n.length;i--&&t.test(n.charAt(i)););return i}return Nx=e,Nx}var Dx,JN;function DX(){if(JN)return Dx;JN=1;var t=NX(),e=/^\s+/;function n(i){return i&&i.slice(0,t(i)+1).replace(e,"")}return Dx=n,Dx}var Lx,eD;function LX(){if(eD)return Lx;eD=1;var t=DX(),e=Oi(),n=Al(),i=NaN,r=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,o=/^0o[0-7]+$/i,c=parseInt;function u(h){if(typeof h=="number")return h;if(n(h))return i;if(e(h)){var d=typeof h.valueOf=="function"?h.valueOf():h;h=e(d)?d+"":d}if(typeof h!="string")return h===0?h:+h;h=t(h);var m=s.test(h);return m||o.test(h)?c(h.slice(2),m?2:8):r.test(h)?i:+h}return Lx=u,Lx}var zx,tD;function q8(){if(tD)return zx;tD=1;var t=LX(),e=1/0,n=17976931348623157e292;function i(r){if(!r)return r===0?r:0;if(r=t(r),r===e||r===-e){var s=r<0?-1:1;return s*n}return r===r?r:0}return zx=i,zx}var Bx,nD;function zX(){if(nD)return Bx;nD=1;var t=q8();function e(n){var i=t(n),r=i%1;return i===i?r?i-r:i:0}return Bx=e,Bx}var qx,iD;function BX(){if(iD)return qx;iD=1;var t=T8(),e=ns(),n=zX(),i=Math.max;function r(s,o,c){var u=s==null?0:s.length;if(!u)return-1;var h=c==null?0:n(c);return h<0&&(h=i(u+h,0)),t(s,e(o,3),h)}return qx=r,qx}var jx,rD;function qX(){if(rD)return jx;rD=1;var t=RX(),e=BX(),n=t(e);return jx=n,jx}var Ix,sD;function j8(){if(sD)return Ix;sD=1;var t=Q2();function e(n){var i=n==null?0:n.length;return i?t(n,1):[]}return Ix=e,Ix}var Px,aD;function jX(){if(aD)return Px;aD=1;var t=F2(),e=l8(),n=Xa();function i(r,s){return r==null?r:t(r,e(s),n)}return Px=i,Px}var Hx,oD;function IX(){if(oD)return Hx;oD=1;function t(e){var n=e==null?0:e.length;return n?e[n-1]:void 0}return Hx=t,Hx}var Ux,lD;function PX(){if(lD)return Ux;lD=1;var t=Sp(),e=$2(),n=ns();function i(r,s){var o={};return s=n(s,3),e(r,function(c,u,h){t(o,u,s(c,u,h))}),o}return Ux=i,Ux}var Vx,cD;function W2(){if(cD)return Vx;cD=1;var t=Al();function e(n,i,r){for(var s=-1,o=n.length;++s<o;){var c=n[s],u=i(c);if(u!=null&&(h===void 0?u===u&&!t(u):r(u,h)))var h=u,d=c}return d}return Vx=e,Vx}var Fx,uD;function HX(){if(uD)return Fx;uD=1;function t(e,n){return e>n}return Fx=t,Fx}var $x,fD;function UX(){if(fD)return $x;fD=1;var t=W2(),e=HX(),n=Wa();function i(r){return r&&r.length?t(r,n,e):void 0}return $x=i,$x}var Gx,hD;function I8(){if(hD)return Gx;hD=1;var t=Sp(),e=wl();function n(i,r,s){(s!==void 0&&!e(i[r],s)||s===void 0&&!(r in i))&&t(i,r,s)}return Gx=n,Gx}var Yx,dD;function VX(){if(dD)return Yx;dD=1;var t=Ya(),e=Op(),n=hr(),i="[object Object]",r=Function.prototype,s=Object.prototype,o=r.toString,c=s.hasOwnProperty,u=o.call(Object);function h(d){if(!n(d)||t(d)!=i)return!1;var m=e(d);if(m===null)return!0;var g=c.call(m,"constructor")&&m.constructor;return typeof g=="function"&&g instanceof g&&o.call(g)==u}return Yx=h,Yx}var Qx,pD;function P8(){if(pD)return Qx;pD=1;function t(e,n){if(!(n==="constructor"&&typeof e[n]=="function")&&n!="__proto__")return e[n]}return Qx=t,Qx}var Xx,mD;function FX(){if(mD)return Xx;mD=1;var t=zu(),e=Xa();function n(i){return t(i,e(i))}return Xx=n,Xx}var Wx,gD;function $X(){if(gD)return Wx;gD=1;var t=I8(),e=Xz(),n=r8(),i=Wz(),r=a8(),s=Bu(),o=Wt(),c=M8(),u=Cl(),h=Lu(),d=Oi(),m=VX(),g=qu(),y=P8(),x=FX();function w(S,C,A,O,E,T,M){var R=y(S,A),z=y(C,A),q=M.get(z);if(q){t(S,A,q);return}var U=T?T(R,z,A+"",S,C,M):void 0,P=U===void 0;if(P){var $=o(z),K=!$&&u(z),L=!$&&!K&&g(z);U=z,$||K||L?o(R)?U=R:c(R)?U=i(R):K?(P=!1,U=e(z,!0)):L?(P=!1,U=n(z,!0)):U=[]:m(z)||s(z)?(U=R,s(R)?U=x(R):(!d(R)||h(R))&&(U=r(z))):P=!1}P&&(M.set(z,U),E(U,z,O,T,M),M.delete(z)),t(S,A,U)}return Wx=w,Wx}var Kx,yD;function GX(){if(yD)return Kx;yD=1;var t=wp(),e=I8(),n=F2(),i=$X(),r=Oi(),s=Xa(),o=P8();function c(u,h,d,m,g){u!==h&&n(h,function(y,x){if(g||(g=new t),r(y))i(u,h,x,d,c,m,g);else{var w=m?m(o(u,x),y,x+"",u,h,g):void 0;w===void 0&&(w=y),e(u,x,w)}},s)}return Kx=c,Kx}var Zx,vD;function YX(){if(vD)return Zx;vD=1;var t=Np(),e=Dp();function n(i){return t(function(r,s){var o=-1,c=s.length,u=c>1?s[c-1]:void 0,h=c>2?s[2]:void 0;for(u=i.length>3&&typeof u=="function"?(c--,u):void 0,h&&e(s[0],s[1],h)&&(u=c<3?void 0:u,c=1),r=Object(r);++o<c;){var d=s[o];d&&i(r,d,o,u)}return r})}return Zx=n,Zx}var Jx,bD;function QX(){if(bD)return Jx;bD=1;var t=GX(),e=YX(),n=e(function(i,r,s){t(i,r,s)});return Jx=n,Jx}var e1,xD;function H8(){if(xD)return e1;xD=1;function t(e,n){return e<n}return e1=t,e1}var t1,wD;function XX(){if(wD)return t1;wD=1;var t=W2(),e=H8(),n=Wa();function i(r){return r&&r.length?t(r,n,e):void 0}return t1=i,t1}var n1,SD;function WX(){if(SD)return n1;SD=1;var t=W2(),e=ns(),n=H8();function i(r,s){return r&&r.length?t(r,e(s,2),n):void 0}return n1=i,n1}var i1,CD;function KX(){if(CD)return i1;CD=1;var t=Hi(),e=function(){return t.Date.now()};return i1=e,i1}var r1,kD;function ZX(){if(kD)return r1;kD=1;var t=Cp(),e=Mp(),n=kp(),i=Oi(),r=ju();function s(o,c,u,h){if(!i(o))return o;c=e(c,o);for(var d=-1,m=c.length,g=m-1,y=o;y!=null&&++d<m;){var x=r(c[d]),w=u;if(x==="__proto__"||x==="constructor"||x==="prototype")return o;if(d!=g){var S=y[x];w=h?h(S,x,y):void 0,w===void 0&&(w=i(S)?S:n(c[d+1])?[]:{})}t(y,x,w),y=y[x]}return o}return r1=s,r1}var s1,AD;function JX(){if(AD)return s1;AD=1;var t=Rp(),e=ZX(),n=Mp();function i(r,s,o){for(var c=-1,u=s.length,h={};++c<u;){var d=s[c],m=t(r,d);o(m,d)&&e(h,n(d,r),m)}return h}return s1=i,s1}var a1,_D;function eW(){if(_D)return a1;_D=1;var t=JX(),e=b8();function n(i,r){return t(i,r,function(s,o){return e(i,o)})}return a1=n,a1}var o1,OD;function tW(){if(OD)return o1;OD=1;var t=j8(),e=O8(),n=E8();function i(r){return n(e(r,void 0,t),r+"")}return o1=i,o1}var l1,ED;function nW(){if(ED)return l1;ED=1;var t=eW(),e=tW(),n=e(function(i,r){return i==null?{}:t(i,r)});return l1=n,l1}var c1,TD;function iW(){if(TD)return c1;TD=1;var t=Math.ceil,e=Math.max;function n(i,r,s,o){for(var c=-1,u=e(t((r-i)/(s||1)),0),h=Array(u);u--;)h[o?u:++c]=i,i+=s;return h}return c1=n,c1}var u1,MD;function rW(){if(MD)return u1;MD=1;var t=iW(),e=Dp(),n=q8();function i(r){return function(s,o,c){return c&&typeof c!="number"&&e(s,o,c)&&(o=c=void 0),s=n(s),o===void 0?(o=s,s=0):o=n(o),c=c===void 0?s<o?1:-1:n(c),t(s,o,c,r)}}return u1=i,u1}var f1,RD;function sW(){if(RD)return f1;RD=1;var t=rW(),e=t();return f1=e,f1}var h1,ND;function aW(){if(ND)return h1;ND=1;function t(e,n){var i=e.length;for(e.sort(n);i--;)e[i]=e[i].value;return e}return h1=t,h1}var d1,DD;function oW(){if(DD)return d1;DD=1;var t=Al();function e(n,i){if(n!==i){var r=n!==void 0,s=n===null,o=n===n,c=t(n),u=i!==void 0,h=i===null,d=i===i,m=t(i);if(!h&&!m&&!c&&n>i||c&&u&&d&&!h&&!m||s&&u&&d||!r&&d||!o)return 1;if(!s&&!c&&!m&&n<i||m&&r&&o&&!s&&!c||h&&r&&o||!u&&o||!d)return-1}return 0}return d1=e,d1}var p1,LD;function lW(){if(LD)return p1;LD=1;var t=oW();function e(n,i,r){for(var s=-1,o=n.criteria,c=i.criteria,u=o.length,h=r.length;++s<u;){var d=t(o[s],c[s]);if(d){if(s>=h)return d;var m=r[s];return d*(m=="desc"?-1:1)}}return n.index-i.index}return p1=e,p1}var m1,zD;function cW(){if(zD)return m1;zD=1;var t=Tp(),e=Rp(),n=ns(),i=k8(),r=aW(),s=Ap(),o=lW(),c=Wa(),u=Wt();function h(d,m,g){m.length?m=t(m,function(w){return u(w)?function(S){return e(S,w.length===1?w[0]:w)}:w}):m=[c];var y=-1;m=t(m,s(n));var x=i(d,function(w,S,C){var A=t(m,function(O){return O(w)});return{criteria:A,index:++y,value:w}});return r(x,function(w,S){return o(w,S,g)})}return m1=h,m1}var g1,BD;function uW(){if(BD)return g1;BD=1;var t=Q2(),e=cW(),n=Np(),i=Dp(),r=n(function(s,o){if(s==null)return[];var c=o.length;return c>1&&i(s,o[0],o[1])?o=[]:c>2&&i(o[0],o[1],o[2])&&(o=[o[0]]),e(s,t(o,1),[])});return g1=r,g1}var y1,qD;function fW(){if(qD)return y1;qD=1;var t=y8(),e=0;function n(i){var r=++e;return t(i)+r}return y1=n,y1}var v1,jD;function hW(){if(jD)return v1;jD=1;function t(e,n,i){for(var r=-1,s=e.length,o=n.length,c={};++r<s;){var u=r<o?n[r]:void 0;i(c,e[r],u)}return c}return v1=t,v1}var b1,ID;function dW(){if(ID)return b1;ID=1;var t=Cp(),e=hW();function n(i,r){return e(i||[],r||[],t)}return b1=n,b1}var x1,PD;function Ot(){if(PD)return x1;PD=1;var t;if(typeof D2=="function")try{t={cloneDeep:TX(),constant:V2(),defaults:MX(),each:u8(),filter:w8(),find:qX(),flatten:j8(),forEach:c8(),forIn:jX(),has:S8(),isUndefined:C8(),last:IX(),map:A8(),mapValues:PX(),max:UX(),merge:QX(),min:XX(),minBy:WX(),now:KX(),pick:nW(),range:sW(),reduce:_8(),sortBy:uW(),uniqueId:fW(),values:R8(),zipObject:dW()}}catch{}return t||(t=window._),x1=t,x1}var w1,HD;function pW(){if(HD)return w1;HD=1,w1=t;function t(){var i={};i._next=i._prev=i,this._sentinel=i}t.prototype.dequeue=function(){var i=this._sentinel,r=i._prev;if(r!==i)return e(r),r},t.prototype.enqueue=function(i){var r=this._sentinel;i._prev&&i._next&&e(i),i._next=r._next,r._next._prev=i,r._next=i,i._prev=r},t.prototype.toString=function(){for(var i=[],r=this._sentinel,s=r._prev;s!==r;)i.push(JSON.stringify(s,n)),s=s._prev;return"["+i.join(", ")+"]"};function e(i){i._prev._next=i._next,i._next._prev=i._prev,delete i._next,delete i._prev}function n(i,r){if(i!=="_next"&&i!=="_prev")return r}return w1}var S1,UD;function mW(){if(UD)return S1;UD=1;var t=Ot(),e=ji().Graph,n=pW();S1=r;var i=t.constant(1);function r(h,d){if(h.nodeCount()<=1)return[];var m=c(h,d||i),g=s(m.graph,m.buckets,m.zeroIdx);return t.flatten(t.map(g,function(y){return h.outEdges(y.v,y.w)}),!0)}function s(h,d,m){for(var g=[],y=d[d.length-1],x=d[0],w;h.nodeCount();){for(;w=x.dequeue();)o(h,d,m,w);for(;w=y.dequeue();)o(h,d,m,w);if(h.nodeCount()){for(var S=d.length-2;S>0;--S)if(w=d[S].dequeue(),w){g=g.concat(o(h,d,m,w,!0));break}}}return g}function o(h,d,m,g,y){var x=y?[]:void 0;return t.forEach(h.inEdges(g.v),function(w){var S=h.edge(w),C=h.node(w.v);y&&x.push({v:w.v,w:w.w}),C.out-=S,u(d,m,C)}),t.forEach(h.outEdges(g.v),function(w){var S=h.edge(w),C=w.w,A=h.node(C);A.in-=S,u(d,m,A)}),h.removeNode(g.v),x}function c(h,d){var m=new e,g=0,y=0;t.forEach(h.nodes(),function(S){m.setNode(S,{v:S,in:0,out:0})}),t.forEach(h.edges(),function(S){var C=m.edge(S.v,S.w)||0,A=d(S),O=C+A;m.setEdge(S.v,S.w,O),y=Math.max(y,m.node(S.v).out+=A),g=Math.max(g,m.node(S.w).in+=A)});var x=t.range(y+g+3).map(function(){return new n}),w=g+1;return t.forEach(m.nodes(),function(S){u(x,w,m.node(S))}),{graph:m,buckets:x,zeroIdx:w}}function u(h,d,m){m.out?m.in?h[m.out-m.in+d].enqueue(m):h[h.length-1].enqueue(m):h[0].enqueue(m)}return S1}var C1,VD;function gW(){if(VD)return C1;VD=1;var t=Ot(),e=mW();C1={run:n,undo:r};function n(s){var o=s.graph().acyclicer==="greedy"?e(s,c(s)):i(s);t.forEach(o,function(u){var h=s.edge(u);s.removeEdge(u),h.forwardName=u.name,h.reversed=!0,s.setEdge(u.w,u.v,h,t.uniqueId("rev"))});function c(u){return function(h){return u.edge(h).weight}}}function i(s){var o=[],c={},u={};function h(d){t.has(u,d)||(u[d]=!0,c[d]=!0,t.forEach(s.outEdges(d),function(m){t.has(c,m.w)?o.push(m):h(m.w)}),delete c[d])}return t.forEach(s.nodes(),h),o}function r(s){t.forEach(s.edges(),function(o){var c=s.edge(o);if(c.reversed){s.removeEdge(o);var u=c.forwardName;delete c.reversed,delete c.forwardName,s.setEdge(o.w,o.v,c,u)}})}return C1}var k1,FD;function Gn(){if(FD)return k1;FD=1;var t=Ot(),e=ji().Graph;k1={addDummyNode:n,simplify:i,asNonCompoundGraph:r,successorWeights:s,predecessorWeights:o,intersectRect:c,buildLayerMatrix:u,normalizeRanks:h,removeEmptyRanks:d,addBorderNode:m,maxRank:g,partition:y,time:x,notime:w};function n(S,C,A,O){var E;do E=t.uniqueId(O);while(S.hasNode(E));return A.dummy=C,S.setNode(E,A),E}function i(S){var C=new e().setGraph(S.graph());return t.forEach(S.nodes(),function(A){C.setNode(A,S.node(A))}),t.forEach(S.edges(),function(A){var O=C.edge(A.v,A.w)||{weight:0,minlen:1},E=S.edge(A);C.setEdge(A.v,A.w,{weight:O.weight+E.weight,minlen:Math.max(O.minlen,E.minlen)})}),C}function r(S){var C=new e({multigraph:S.isMultigraph()}).setGraph(S.graph());return t.forEach(S.nodes(),function(A){S.children(A).length||C.setNode(A,S.node(A))}),t.forEach(S.edges(),function(A){C.setEdge(A,S.edge(A))}),C}function s(S){var C=t.map(S.nodes(),function(A){var O={};return t.forEach(S.outEdges(A),function(E){O[E.w]=(O[E.w]||0)+S.edge(E).weight}),O});return t.zipObject(S.nodes(),C)}function o(S){var C=t.map(S.nodes(),function(A){var O={};return t.forEach(S.inEdges(A),function(E){O[E.v]=(O[E.v]||0)+S.edge(E).weight}),O});return t.zipObject(S.nodes(),C)}function c(S,C){var A=S.x,O=S.y,E=C.x-A,T=C.y-O,M=S.width/2,R=S.height/2;if(!E&&!T)throw new Error("Not possible to find intersection inside of the rectangle");var z,q;return Math.abs(T)*M>Math.abs(E)*R?(T<0&&(R=-R),z=R*E/T,q=R):(E<0&&(M=-M),z=M,q=M*T/E),{x:A+z,y:O+q}}function u(S){var C=t.map(t.range(g(S)+1),function(){return[]});return t.forEach(S.nodes(),function(A){var O=S.node(A),E=O.rank;t.isUndefined(E)||(C[E][O.order]=A)}),C}function h(S){var C=t.min(t.map(S.nodes(),function(A){return S.node(A).rank}));t.forEach(S.nodes(),function(A){var O=S.node(A);t.has(O,"rank")&&(O.rank-=C)})}function d(S){var C=t.min(t.map(S.nodes(),function(T){return S.node(T).rank})),A=[];t.forEach(S.nodes(),function(T){var M=S.node(T).rank-C;A[M]||(A[M]=[]),A[M].push(T)});var O=0,E=S.graph().nodeRankFactor;t.forEach(A,function(T,M){t.isUndefined(T)&&M%E!==0?--O:O&&t.forEach(T,function(R){S.node(R).rank+=O})})}function m(S,C,A,O){var E={width:0,height:0};return arguments.length>=4&&(E.rank=A,E.order=O),n(S,"border",E,C)}function g(S){return t.max(t.map(S.nodes(),function(C){var A=S.node(C).rank;if(!t.isUndefined(A))return A}))}function y(S,C){var A={lhs:[],rhs:[]};return t.forEach(S,function(O){C(O)?A.lhs.push(O):A.rhs.push(O)}),A}function x(S,C){var A=t.now();try{return C()}finally{console.log(S+" time: "+(t.now()-A)+"ms")}}function w(S,C){return C()}return k1}var A1,$D;function yW(){if($D)return A1;$D=1;var t=Ot(),e=Gn();A1={run:n,undo:r};function n(s){s.graph().dummyChains=[],t.forEach(s.edges(),function(o){i(s,o)})}function i(s,o){var c=o.v,u=s.node(c).rank,h=o.w,d=s.node(h).rank,m=o.name,g=s.edge(o),y=g.labelRank;if(d!==u+1){s.removeEdge(o);var x,w,S;for(S=0,++u;u<d;++S,++u)g.points=[],w={width:0,height:0,edgeLabel:g,edgeObj:o,rank:u},x=e.addDummyNode(s,"edge",w,"_d"),u===y&&(w.width=g.width,w.height=g.height,w.dummy="edge-label",w.labelpos=g.labelpos),s.setEdge(c,x,{weight:g.weight},m),S===0&&s.graph().dummyChains.push(x),c=x;s.setEdge(c,h,{weight:g.weight},m)}}function r(s){t.forEach(s.graph().dummyChains,function(o){var c=s.node(o),u=c.edgeLabel,h;for(s.setEdge(c.edgeObj,u);c.dummy;)h=s.successors(o)[0],s.removeNode(o),u.points.push({x:c.x,y:c.y}),c.dummy==="edge-label"&&(u.x=c.x,u.y=c.y,u.width=c.width,u.height=c.height),o=h,c=s.node(o)})}return A1}var _1,GD;function Td(){if(GD)return _1;GD=1;var t=Ot();_1={longestPath:e,slack:n};function e(i){var r={};function s(o){var c=i.node(o);if(t.has(r,o))return c.rank;r[o]=!0;var u=t.min(t.map(i.outEdges(o),function(h){return s(h.w)-i.edge(h).minlen}));return(u===Number.POSITIVE_INFINITY||u===void 0||u===null)&&(u=0),c.rank=u}t.forEach(i.sources(),s)}function n(i,r){return i.node(r.w).rank-i.node(r.v).rank-i.edge(r).minlen}return _1}var O1,YD;function U8(){if(YD)return O1;YD=1;var t=Ot(),e=ji().Graph,n=Td().slack;O1=i;function i(c){var u=new e({directed:!1}),h=c.nodes()[0],d=c.nodeCount();u.setNode(h,{});for(var m,g;r(u,c)<d;)m=s(u,c),g=u.hasNode(m.v)?n(c,m):-n(c,m),o(u,c,g);return u}function r(c,u){function h(d){t.forEach(u.nodeEdges(d),function(m){var g=m.v,y=d===g?m.w:g;!c.hasNode(y)&&!n(u,m)&&(c.setNode(y,{}),c.setEdge(d,y,{}),h(y))})}return t.forEach(c.nodes(),h),c.nodeCount()}function s(c,u){return t.minBy(u.edges(),function(h){if(c.hasNode(h.v)!==c.hasNode(h.w))return n(u,h)})}function o(c,u,h){t.forEach(c.nodes(),function(d){u.node(d).rank+=h})}return O1}var E1,QD;function vW(){if(QD)return E1;QD=1;var t=Ot(),e=U8(),n=Td().slack,i=Td().longestPath,r=ji().alg.preorder,s=ji().alg.postorder,o=Gn().simplify;E1=c,c.initLowLimValues=m,c.initCutValues=u,c.calcCutValue=d,c.leaveEdge=y,c.enterEdge=x,c.exchangeEdges=w;function c(O){O=o(O),i(O);var E=e(O);m(E),u(E,O);for(var T,M;T=y(E);)M=x(E,O,T),w(E,O,T,M)}function u(O,E){var T=s(O,O.nodes());T=T.slice(0,T.length-1),t.forEach(T,function(M){h(O,E,M)})}function h(O,E,T){var M=O.node(T),R=M.parent;O.edge(T,R).cutvalue=d(O,E,T)}function d(O,E,T){var M=O.node(T),R=M.parent,z=!0,q=E.edge(T,R),U=0;return q||(z=!1,q=E.edge(R,T)),U=q.weight,t.forEach(E.nodeEdges(T),function(P){var $=P.v===T,K=$?P.w:P.v;if(K!==R){var L=$===z,Y=E.edge(P).weight;if(U+=L?Y:-Y,C(O,T,K)){var D=O.edge(T,K).cutvalue;U+=L?-D:D}}}),U}function m(O,E){arguments.length<2&&(E=O.nodes()[0]),g(O,{},1,E)}function g(O,E,T,M,R){var z=T,q=O.node(M);return E[M]=!0,t.forEach(O.neighbors(M),function(U){t.has(E,U)||(T=g(O,E,T,U,M))}),q.low=z,q.lim=T++,R?q.parent=R:delete q.parent,T}function y(O){return t.find(O.edges(),function(E){return O.edge(E).cutvalue<0})}function x(O,E,T){var M=T.v,R=T.w;E.hasEdge(M,R)||(M=T.w,R=T.v);var z=O.node(M),q=O.node(R),U=z,P=!1;z.lim>q.lim&&(U=q,P=!0);var $=t.filter(E.edges(),function(K){return P===A(O,O.node(K.v),U)&&P!==A(O,O.node(K.w),U)});return t.minBy($,function(K){return n(E,K)})}function w(O,E,T,M){var R=T.v,z=T.w;O.removeEdge(R,z),O.setEdge(M.v,M.w,{}),m(O),u(O,E),S(O,E)}function S(O,E){var T=t.find(O.nodes(),function(R){return!E.node(R).parent}),M=r(O,T);M=M.slice(1),t.forEach(M,function(R){var z=O.node(R).parent,q=E.edge(R,z),U=!1;q||(q=E.edge(z,R),U=!0),E.node(R).rank=E.node(z).rank+(U?q.minlen:-q.minlen)})}function C(O,E,T){return O.hasEdge(E,T)}function A(O,E,T){return T.low<=E.lim&&E.lim<=T.lim}return E1}var T1,XD;function bW(){if(XD)return T1;XD=1;var t=Td(),e=t.longestPath,n=U8(),i=vW();T1=r;function r(u){switch(u.graph().ranker){case"network-simplex":c(u);break;case"tight-tree":o(u);break;case"longest-path":s(u);break;default:c(u)}}var s=e;function o(u){e(u),n(u)}function c(u){i(u)}return T1}var M1,WD;function xW(){if(WD)return M1;WD=1;var t=Ot();M1=e;function e(r){var s=i(r);t.forEach(r.graph().dummyChains,function(o){for(var c=r.node(o),u=c.edgeObj,h=n(r,s,u.v,u.w),d=h.path,m=h.lca,g=0,y=d[g],x=!0;o!==u.w;){if(c=r.node(o),x){for(;(y=d[g])!==m&&r.node(y).maxRank<c.rank;)g++;y===m&&(x=!1)}if(!x){for(;g<d.length-1&&r.node(y=d[g+1]).minRank<=c.rank;)g++;y=d[g]}r.setParent(o,y),o=r.successors(o)[0]}})}function n(r,s,o,c){var u=[],h=[],d=Math.min(s[o].low,s[c].low),m=Math.max(s[o].lim,s[c].lim),g,y;g=o;do g=r.parent(g),u.push(g);while(g&&(s[g].low>d||m>s[g].lim));for(y=g,g=c;(g=r.parent(g))!==y;)h.push(g);return{path:u.concat(h.reverse()),lca:y}}function i(r){var s={},o=0;function c(u){var h=o;t.forEach(r.children(u),c),s[u]={low:h,lim:o++}}return t.forEach(r.children(),c),s}return M1}var R1,KD;function wW(){if(KD)return R1;KD=1;var t=Ot(),e=Gn();R1={run:n,cleanup:o};function n(c){var u=e.addDummyNode(c,"root",{},"_root"),h=r(c),d=t.max(t.values(h))-1,m=2*d+1;c.graph().nestingRoot=u,t.forEach(c.edges(),function(y){c.edge(y).minlen*=m});var g=s(c)+1;t.forEach(c.children(),function(y){i(c,u,m,g,d,h,y)}),c.graph().nodeRankFactor=m}function i(c,u,h,d,m,g,y){var x=c.children(y);if(!x.length){y!==u&&c.setEdge(u,y,{weight:0,minlen:h});return}var w=e.addBorderNode(c,"_bt"),S=e.addBorderNode(c,"_bb"),C=c.node(y);c.setParent(w,y),C.borderTop=w,c.setParent(S,y),C.borderBottom=S,t.forEach(x,function(A){i(c,u,h,d,m,g,A);var O=c.node(A),E=O.borderTop?O.borderTop:A,T=O.borderBottom?O.borderBottom:A,M=O.borderTop?d:2*d,R=E!==T?1:m-g[y]+1;c.setEdge(w,E,{weight:M,minlen:R,nestingEdge:!0}),c.setEdge(T,S,{weight:M,minlen:R,nestingEdge:!0})}),c.parent(y)||c.setEdge(u,w,{weight:0,minlen:m+g[y]})}function r(c){var u={};function h(d,m){var g=c.children(d);g&&g.length&&t.forEach(g,function(y){h(y,m+1)}),u[d]=m}return t.forEach(c.children(),function(d){h(d,1)}),u}function s(c){return t.reduce(c.edges(),function(u,h){return u+c.edge(h).weight},0)}function o(c){var u=c.graph();c.removeNode(u.nestingRoot),delete u.nestingRoot,t.forEach(c.edges(),function(h){var d=c.edge(h);d.nestingEdge&&c.removeEdge(h)})}return R1}var N1,ZD;function SW(){if(ZD)return N1;ZD=1;var t=Ot(),e=Gn();N1=n;function n(r){function s(o){var c=r.children(o),u=r.node(o);if(c.length&&t.forEach(c,s),t.has(u,"minRank")){u.borderLeft=[],u.borderRight=[];for(var h=u.minRank,d=u.maxRank+1;h<d;++h)i(r,"borderLeft","_bl",o,u,h),i(r,"borderRight","_br",o,u,h)}}t.forEach(r.children(),s)}function i(r,s,o,c,u,h){var d={width:0,height:0,rank:h,borderType:s},m=u[s][h-1],g=e.addDummyNode(r,"border",d,o);u[s][h]=g,r.setParent(g,c),m&&r.setEdge(m,g,{weight:1})}return N1}var D1,JD;function CW(){if(JD)return D1;JD=1;var t=Ot();D1={adjust:e,undo:n};function e(h){var d=h.graph().rankdir.toLowerCase();(d==="lr"||d==="rl")&&i(h)}function n(h){var d=h.graph().rankdir.toLowerCase();(d==="bt"||d==="rl")&&s(h),(d==="lr"||d==="rl")&&(c(h),i(h))}function i(h){t.forEach(h.nodes(),function(d){r(h.node(d))}),t.forEach(h.edges(),function(d){r(h.edge(d))})}function r(h){var d=h.width;h.width=h.height,h.height=d}function s(h){t.forEach(h.nodes(),function(d){o(h.node(d))}),t.forEach(h.edges(),function(d){var m=h.edge(d);t.forEach(m.points,o),t.has(m,"y")&&o(m)})}function o(h){h.y=-h.y}function c(h){t.forEach(h.nodes(),function(d){u(h.node(d))}),t.forEach(h.edges(),function(d){var m=h.edge(d);t.forEach(m.points,u),t.has(m,"x")&&u(m)})}function u(h){var d=h.x;h.x=h.y,h.y=d}return D1}var L1,e3;function kW(){if(e3)return L1;e3=1;var t=Ot();L1=e;function e(n){var i={},r=t.filter(n.nodes(),function(h){return!n.children(h).length}),s=t.max(t.map(r,function(h){return n.node(h).rank})),o=t.map(t.range(s+1),function(){return[]});function c(h){if(!t.has(i,h)){i[h]=!0;var d=n.node(h);o[d.rank].push(h),t.forEach(n.successors(h),c)}}var u=t.sortBy(r,function(h){return n.node(h).rank});return t.forEach(u,c),o}return L1}var z1,t3;function AW(){if(t3)return z1;t3=1;var t=Ot();z1=e;function e(i,r){for(var s=0,o=1;o<r.length;++o)s+=n(i,r[o-1],r[o]);return s}function n(i,r,s){for(var o=t.zipObject(s,t.map(s,function(g,y){return y})),c=t.flatten(t.map(r,function(g){return t.sortBy(t.map(i.outEdges(g),function(y){return{pos:o[y.w],weight:i.edge(y).weight}}),"pos")}),!0),u=1;u<s.length;)u<<=1;var h=2*u-1;u-=1;var d=t.map(new Array(h),function(){return 0}),m=0;return t.forEach(c.forEach(function(g){var y=g.pos+u;d[y]+=g.weight;for(var x=0;y>0;)y%2&&(x+=d[y+1]),y=y-1>>1,d[y]+=g.weight;m+=g.weight*x})),m}return z1}var B1,n3;function _W(){if(n3)return B1;n3=1;var t=Ot();B1=e;function e(n,i){return t.map(i,function(r){var s=n.inEdges(r);if(s.length){var o=t.reduce(s,function(c,u){var h=n.edge(u),d=n.node(u.v);return{sum:c.sum+h.weight*d.order,weight:c.weight+h.weight}},{sum:0,weight:0});return{v:r,barycenter:o.sum/o.weight,weight:o.weight}}else return{v:r}})}return B1}var q1,i3;function OW(){if(i3)return q1;i3=1;var t=Ot();q1=e;function e(r,s){var o={};t.forEach(r,function(u,h){var d=o[u.v]={indegree:0,in:[],out:[],vs:[u.v],i:h};t.isUndefined(u.barycenter)||(d.barycenter=u.barycenter,d.weight=u.weight)}),t.forEach(s.edges(),function(u){var h=o[u.v],d=o[u.w];!t.isUndefined(h)&&!t.isUndefined(d)&&(d.indegree++,h.out.push(o[u.w]))});var c=t.filter(o,function(u){return!u.indegree});return n(c)}function n(r){var s=[];function o(h){return function(d){d.merged||(t.isUndefined(d.barycenter)||t.isUndefined(h.barycenter)||d.barycenter>=h.barycenter)&&i(h,d)}}function c(h){return function(d){d.in.push(h),--d.indegree===0&&r.push(d)}}for(;r.length;){var u=r.pop();s.push(u),t.forEach(u.in.reverse(),o(u)),t.forEach(u.out,c(u))}return t.map(t.filter(s,function(h){return!h.merged}),function(h){return t.pick(h,["vs","i","barycenter","weight"])})}function i(r,s){var o=0,c=0;r.weight&&(o+=r.barycenter*r.weight,c+=r.weight),s.weight&&(o+=s.barycenter*s.weight,c+=s.weight),r.vs=s.vs.concat(r.vs),r.barycenter=o/c,r.weight=c,r.i=Math.min(s.i,r.i),s.merged=!0}return q1}var j1,r3;function EW(){if(r3)return j1;r3=1;var t=Ot(),e=Gn();j1=n;function n(s,o){var c=e.partition(s,function(w){return t.has(w,"barycenter")}),u=c.lhs,h=t.sortBy(c.rhs,function(w){return-w.i}),d=[],m=0,g=0,y=0;u.sort(r(!!o)),y=i(d,h,y),t.forEach(u,function(w){y+=w.vs.length,d.push(w.vs),m+=w.barycenter*w.weight,g+=w.weight,y=i(d,h,y)});var x={vs:t.flatten(d,!0)};return g&&(x.barycenter=m/g,x.weight=g),x}function i(s,o,c){for(var u;o.length&&(u=t.last(o)).i<=c;)o.pop(),s.push(u.vs),c++;return c}function r(s){return function(o,c){return o.barycenter<c.barycenter?-1:o.barycenter>c.barycenter?1:s?c.i-o.i:o.i-c.i}}return j1}var I1,s3;function TW(){if(s3)return I1;s3=1;var t=Ot(),e=_W(),n=OW(),i=EW();I1=r;function r(c,u,h,d){var m=c.children(u),g=c.node(u),y=g?g.borderLeft:void 0,x=g?g.borderRight:void 0,w={};y&&(m=t.filter(m,function(T){return T!==y&&T!==x}));var S=e(c,m);t.forEach(S,function(T){if(c.children(T.v).length){var M=r(c,T.v,h,d);w[T.v]=M,t.has(M,"barycenter")&&o(T,M)}});var C=n(S,h);s(C,w);var A=i(C,d);if(y&&(A.vs=t.flatten([y,A.vs,x],!0),c.predecessors(y).length)){var O=c.node(c.predecessors(y)[0]),E=c.node(c.predecessors(x)[0]);t.has(A,"barycenter")||(A.barycenter=0,A.weight=0),A.barycenter=(A.barycenter*A.weight+O.order+E.order)/(A.weight+2),A.weight+=2}return A}function s(c,u){t.forEach(c,function(h){h.vs=t.flatten(h.vs.map(function(d){return u[d]?u[d].vs:d}),!0)})}function o(c,u){t.isUndefined(c.barycenter)?(c.barycenter=u.barycenter,c.weight=u.weight):(c.barycenter=(c.barycenter*c.weight+u.barycenter*u.weight)/(c.weight+u.weight),c.weight+=u.weight)}return I1}var P1,a3;function MW(){if(a3)return P1;a3=1;var t=Ot(),e=ji().Graph;P1=n;function n(r,s,o){var c=i(r),u=new e({compound:!0}).setGraph({root:c}).setDefaultNodeLabel(function(h){return r.node(h)});return t.forEach(r.nodes(),function(h){var d=r.node(h),m=r.parent(h);(d.rank===s||d.minRank<=s&&s<=d.maxRank)&&(u.setNode(h),u.setParent(h,m||c),t.forEach(r[o](h),function(g){var y=g.v===h?g.w:g.v,x=u.edge(y,h),w=t.isUndefined(x)?0:x.weight;u.setEdge(y,h,{weight:r.edge(g).weight+w})}),t.has(d,"minRank")&&u.setNode(h,{borderLeft:d.borderLeft[s],borderRight:d.borderRight[s]}))}),u}function i(r){for(var s;r.hasNode(s=t.uniqueId("_root")););return s}return P1}var H1,o3;function RW(){if(o3)return H1;o3=1;var t=Ot();H1=e;function e(n,i,r){var s={},o;t.forEach(r,function(c){for(var u=n.parent(c),h,d;u;){if(h=n.parent(u),h?(d=s[h],s[h]=u):(d=o,o=u),d&&d!==u){i.setEdge(d,u);return}u=h}})}return H1}var U1,l3;function NW(){if(l3)return U1;l3=1;var t=Ot(),e=kW(),n=AW(),i=TW(),r=MW(),s=RW(),o=ji().Graph,c=Gn();U1=u;function u(g){var y=c.maxRank(g),x=h(g,t.range(1,y+1),"inEdges"),w=h(g,t.range(y-1,-1,-1),"outEdges"),S=e(g);m(g,S);for(var C=Number.POSITIVE_INFINITY,A,O=0,E=0;E<4;++O,++E){d(O%2?x:w,O%4>=2),S=c.buildLayerMatrix(g);var T=n(g,S);T<C&&(E=0,A=t.cloneDeep(S),C=T)}m(g,A)}function h(g,y,x){return t.map(y,function(w){return r(g,w,x)})}function d(g,y){var x=new o;t.forEach(g,function(w){var S=w.graph().root,C=i(w,S,x,y);t.forEach(C.vs,function(A,O){w.node(A).order=O}),s(w,x,C.vs)})}function m(g,y){t.forEach(y,function(x){t.forEach(x,function(w,S){g.node(w).order=S})})}return U1}var V1,c3;function DW(){if(c3)return V1;c3=1;var t=Ot(),e=ji().Graph,n=Gn();V1={positionX:x,findType1Conflicts:i,findType2Conflicts:r,addConflict:o,hasConflict:c,verticalAlignment:u,horizontalCompaction:h,alignCoordinates:g,findSmallestWidthAlignment:m,balance:y};function i(C,A){var O={};function E(T,M){var R=0,z=0,q=T.length,U=t.last(M);return t.forEach(M,function(P,$){var K=s(C,P),L=K?C.node(K).order:q;(K||P===U)&&(t.forEach(M.slice(z,$+1),function(Y){t.forEach(C.predecessors(Y),function(D){var Q=C.node(D),ee=Q.order;(ee<R||L<ee)&&!(Q.dummy&&C.node(Y).dummy)&&o(O,D,Y)})}),z=$+1,R=L)}),M}return t.reduce(A,E),O}function r(C,A){var O={};function E(M,R,z,q,U){var P;t.forEach(t.range(R,z),function($){P=M[$],C.node(P).dummy&&t.forEach(C.predecessors(P),function(K){var L=C.node(K);L.dummy&&(L.order<q||L.order>U)&&o(O,K,P)})})}function T(M,R){var z=-1,q,U=0;return t.forEach(R,function(P,$){if(C.node(P).dummy==="border"){var K=C.predecessors(P);K.length&&(q=C.node(K[0]).order,E(R,U,$,z,q),U=$,z=q)}E(R,U,R.length,q,M.length)}),R}return t.reduce(A,T),O}function s(C,A){if(C.node(A).dummy)return t.find(C.predecessors(A),function(O){return C.node(O).dummy})}function o(C,A,O){if(A>O){var E=A;A=O,O=E}var T=C[A];T||(C[A]=T={}),T[O]=!0}function c(C,A,O){if(A>O){var E=A;A=O,O=E}return t.has(C[A],O)}function u(C,A,O,E){var T={},M={},R={};return t.forEach(A,function(z){t.forEach(z,function(q,U){T[q]=q,M[q]=q,R[q]=U})}),t.forEach(A,function(z){var q=-1;t.forEach(z,function(U){var P=E(U);if(P.length){P=t.sortBy(P,function(D){return R[D]});for(var $=(P.length-1)/2,K=Math.floor($),L=Math.ceil($);K<=L;++K){var Y=P[K];M[U]===U&&q<R[Y]&&!c(O,U,Y)&&(M[Y]=U,M[U]=T[U]=T[Y],q=R[Y])}}})}),{root:T,align:M}}function h(C,A,O,E,T){var M={},R=d(C,A,O,T),z=T?"borderLeft":"borderRight";function q($,K){for(var L=R.nodes(),Y=L.pop(),D={};Y;)D[Y]?$(Y):(D[Y]=!0,L.push(Y),L=L.concat(K(Y))),Y=L.pop()}function U($){M[$]=R.inEdges($).reduce(function(K,L){return Math.max(K,M[L.v]+R.edge(L))},0)}function P($){var K=R.outEdges($).reduce(function(Y,D){return Math.min(Y,M[D.w]-R.edge(D))},Number.POSITIVE_INFINITY),L=C.node($);K!==Number.POSITIVE_INFINITY&&L.borderType!==z&&(M[$]=Math.max(M[$],K))}return q(U,R.predecessors.bind(R)),q(P,R.successors.bind(R)),t.forEach(E,function($){M[$]=M[O[$]]}),M}function d(C,A,O,E){var T=new e,M=C.graph(),R=w(M.nodesep,M.edgesep,E);return t.forEach(A,function(z){var q;t.forEach(z,function(U){var P=O[U];if(T.setNode(P),q){var $=O[q],K=T.edge($,P);T.setEdge($,P,Math.max(R(C,U,q),K||0))}q=U})}),T}function m(C,A){return t.minBy(t.values(A),function(O){var E=Number.NEGATIVE_INFINITY,T=Number.POSITIVE_INFINITY;return t.forIn(O,function(M,R){var z=S(C,R)/2;E=Math.max(M+z,E),T=Math.min(M-z,T)}),E-T})}function g(C,A){var O=t.values(A),E=t.min(O),T=t.max(O);t.forEach(["u","d"],function(M){t.forEach(["l","r"],function(R){var z=M+R,q=C[z],U;if(q!==A){var P=t.values(q);U=R==="l"?E-t.min(P):T-t.max(P),U&&(C[z]=t.mapValues(q,function($){return $+U}))}})})}function y(C,A){return t.mapValues(C.ul,function(O,E){if(A)return C[A.toLowerCase()][E];var T=t.sortBy(t.map(C,E));return(T[1]+T[2])/2})}function x(C){var A=n.buildLayerMatrix(C),O=t.merge(i(C,A),r(C,A)),E={},T;t.forEach(["u","d"],function(R){T=R==="u"?A:t.values(A).reverse(),t.forEach(["l","r"],function(z){z==="r"&&(T=t.map(T,function($){return t.values($).reverse()}));var q=(R==="u"?C.predecessors:C.successors).bind(C),U=u(C,T,O,q),P=h(C,T,U.root,U.align,z==="r");z==="r"&&(P=t.mapValues(P,function($){return-$})),E[R+z]=P})});var M=m(C,E);return g(E,M),y(E,C.graph().align)}function w(C,A,O){return function(E,T,M){var R=E.node(T),z=E.node(M),q=0,U;if(q+=R.width/2,t.has(R,"labelpos"))switch(R.labelpos.toLowerCase()){case"l":U=-R.width/2;break;case"r":U=R.width/2;break}if(U&&(q+=O?U:-U),U=0,q+=(R.dummy?A:C)/2,q+=(z.dummy?A:C)/2,q+=z.width/2,t.has(z,"labelpos"))switch(z.labelpos.toLowerCase()){case"l":U=z.width/2;break;case"r":U=-z.width/2;break}return U&&(q+=O?U:-U),U=0,q}}function S(C,A){return C.node(A).width}return V1}var F1,u3;function LW(){if(u3)return F1;u3=1;var t=Ot(),e=Gn(),n=DW().positionX;F1=i;function i(s){s=e.asNonCompoundGraph(s),r(s),t.forEach(n(s),function(o,c){s.node(c).x=o})}function r(s){var o=e.buildLayerMatrix(s),c=s.graph().ranksep,u=0;t.forEach(o,function(h){var d=t.max(t.map(h,function(m){return s.node(m).height}));t.forEach(h,function(m){s.node(m).y=u+d/2}),u+=d+c})}return F1}var $1,f3;function zW(){if(f3)return $1;f3=1;var t=Ot(),e=gW(),n=yW(),i=bW(),r=Gn().normalizeRanks,s=xW(),o=Gn().removeEmptyRanks,c=wW(),u=SW(),h=CW(),d=NW(),m=LW(),g=Gn(),y=ji().Graph;$1=x;function x(I,X){var J=X&&X.debugTiming?g.time:g.notime;J("layout",function(){var oe=J(" buildLayoutGraph",function(){return q(I)});J(" runLayout",function(){w(oe,J)}),J(" updateInputGraph",function(){S(I,oe)})})}function w(I,X){X(" makeSpaceForEdgeLabels",function(){U(I)}),X(" removeSelfEdges",function(){G(I)}),X(" acyclic",function(){e.run(I)}),X(" nestingGraph.run",function(){c.run(I)}),X(" rank",function(){i(g.asNonCompoundGraph(I))}),X(" injectEdgeLabelProxies",function(){P(I)}),X(" removeEmptyRanks",function(){o(I)}),X(" nestingGraph.cleanup",function(){c.cleanup(I)}),X(" normalizeRanks",function(){r(I)}),X(" assignRankMinMax",function(){$(I)}),X(" removeEdgeLabelProxies",function(){K(I)}),X(" normalize.run",function(){n.run(I)}),X(" parentDummyChains",function(){s(I)}),X(" addBorderSegments",function(){u(I)}),X(" order",function(){d(I)}),X(" insertSelfEdges",function(){W(I)}),X(" adjustCoordinateSystem",function(){h.adjust(I)}),X(" position",function(){m(I)}),X(" positionSelfEdges",function(){B(I)}),X(" removeBorderNodes",function(){ee(I)}),X(" normalize.undo",function(){n.undo(I)}),X(" fixupEdgeLabelCoords",function(){D(I)}),X(" undoCoordinateSystem",function(){h.undo(I)}),X(" translateGraph",function(){L(I)}),X(" assignNodeIntersects",function(){Y(I)}),X(" reversePoints",function(){Q(I)}),X(" acyclic.undo",function(){e.undo(I)})}function S(I,X){t.forEach(I.nodes(),function(J){var oe=I.node(J),ve=X.node(J);oe&&(oe.x=ve.x,oe.y=ve.y,X.children(J).length&&(oe.width=ve.width,oe.height=ve.height))}),t.forEach(I.edges(),function(J){var oe=I.edge(J),ve=X.edge(J);oe.points=ve.points,t.has(ve,"x")&&(oe.x=ve.x,oe.y=ve.y)}),I.graph().width=X.graph().width,I.graph().height=X.graph().height}var C=["nodesep","edgesep","ranksep","marginx","marginy"],A={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},O=["acyclicer","ranker","rankdir","align"],E=["width","height"],T={width:0,height:0},M=["minlen","weight","width","height","labeloffset"],R={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},z=["labelpos"];function q(I){var X=new y({multigraph:!0,compound:!0}),J=ne(I.graph());return X.setGraph(t.merge({},A,F(J,C),t.pick(J,O))),t.forEach(I.nodes(),function(oe){var ve=ne(I.node(oe));X.setNode(oe,t.defaults(F(ve,E),T)),X.setParent(oe,I.parent(oe))}),t.forEach(I.edges(),function(oe){var ve=ne(I.edge(oe));X.setEdge(oe,t.merge({},R,F(ve,M),t.pick(ve,z)))}),X}function U(I){var X=I.graph();X.ranksep/=2,t.forEach(I.edges(),function(J){var oe=I.edge(J);oe.minlen*=2,oe.labelpos.toLowerCase()!=="c"&&(X.rankdir==="TB"||X.rankdir==="BT"?oe.width+=oe.labeloffset:oe.height+=oe.labeloffset)})}function P(I){t.forEach(I.edges(),function(X){var J=I.edge(X);if(J.width&&J.height){var oe=I.node(X.v),ve=I.node(X.w),H={rank:(ve.rank-oe.rank)/2+oe.rank,e:X};g.addDummyNode(I,"edge-proxy",H,"_ep")}})}function $(I){var X=0;t.forEach(I.nodes(),function(J){var oe=I.node(J);oe.borderTop&&(oe.minRank=I.node(oe.borderTop).rank,oe.maxRank=I.node(oe.borderBottom).rank,X=t.max(X,oe.maxRank))}),I.graph().maxRank=X}function K(I){t.forEach(I.nodes(),function(X){var J=I.node(X);J.dummy==="edge-proxy"&&(I.edge(J.e).labelRank=J.rank,I.removeNode(X))})}function L(I){var X=Number.POSITIVE_INFINITY,J=0,oe=Number.POSITIVE_INFINITY,ve=0,H=I.graph(),pe=H.marginx||0,me=H.marginy||0;function ye(_e){var Ae=_e.x,be=_e.y,He=_e.width,we=_e.height;X=Math.min(X,Ae-He/2),J=Math.max(J,Ae+He/2),oe=Math.min(oe,be-we/2),ve=Math.max(ve,be+we/2)}t.forEach(I.nodes(),function(_e){ye(I.node(_e))}),t.forEach(I.edges(),function(_e){var Ae=I.edge(_e);t.has(Ae,"x")&&ye(Ae)}),X-=pe,oe-=me,t.forEach(I.nodes(),function(_e){var Ae=I.node(_e);Ae.x-=X,Ae.y-=oe}),t.forEach(I.edges(),function(_e){var Ae=I.edge(_e);t.forEach(Ae.points,function(be){be.x-=X,be.y-=oe}),t.has(Ae,"x")&&(Ae.x-=X),t.has(Ae,"y")&&(Ae.y-=oe)}),H.width=J-X+pe,H.height=ve-oe+me}function Y(I){t.forEach(I.edges(),function(X){var J=I.edge(X),oe=I.node(X.v),ve=I.node(X.w),H,pe;J.points?(H=J.points[0],pe=J.points[J.points.length-1]):(J.points=[],H=ve,pe=oe),J.points.unshift(g.intersectRect(oe,H)),J.points.push(g.intersectRect(ve,pe))})}function D(I){t.forEach(I.edges(),function(X){var J=I.edge(X);if(t.has(J,"x"))switch((J.labelpos==="l"||J.labelpos==="r")&&(J.width-=J.labeloffset),J.labelpos){case"l":J.x-=J.width/2+J.labeloffset;break;case"r":J.x+=J.width/2+J.labeloffset;break}})}function Q(I){t.forEach(I.edges(),function(X){var J=I.edge(X);J.reversed&&J.points.reverse()})}function ee(I){t.forEach(I.nodes(),function(X){if(I.children(X).length){var J=I.node(X),oe=I.node(J.borderTop),ve=I.node(J.borderBottom),H=I.node(t.last(J.borderLeft)),pe=I.node(t.last(J.borderRight));J.width=Math.abs(pe.x-H.x),J.height=Math.abs(ve.y-oe.y),J.x=H.x+J.width/2,J.y=oe.y+J.height/2}}),t.forEach(I.nodes(),function(X){I.node(X).dummy==="border"&&I.removeNode(X)})}function G(I){t.forEach(I.edges(),function(X){if(X.v===X.w){var J=I.node(X.v);J.selfEdges||(J.selfEdges=[]),J.selfEdges.push({e:X,label:I.edge(X)}),I.removeEdge(X)}})}function W(I){var X=g.buildLayerMatrix(I);t.forEach(X,function(J){var oe=0;t.forEach(J,function(ve,H){var pe=I.node(ve);pe.order=H+oe,t.forEach(pe.selfEdges,function(me){g.addDummyNode(I,"selfedge",{width:me.label.width,height:me.label.height,rank:pe.rank,order:H+ ++oe,e:me.e,label:me.label},"_se")}),delete pe.selfEdges})})}function B(I){t.forEach(I.nodes(),function(X){var J=I.node(X);if(J.dummy==="selfedge"){var oe=I.node(J.e.v),ve=oe.x+oe.width/2,H=oe.y,pe=J.x-ve,me=oe.height/2;I.setEdge(J.e,J.label),I.removeNode(X),J.label.points=[{x:ve+2*pe/3,y:H-me},{x:ve+5*pe/6,y:H-me},{x:ve+pe,y:H},{x:ve+5*pe/6,y:H+me},{x:ve+2*pe/3,y:H+me}],J.label.x=J.x,J.label.y=J.y}})}function F(I,X){return t.mapValues(t.pick(I,X),Number)}function ne(I){var X={};return t.forEach(I,function(J,oe){X[oe.toLowerCase()]=J}),X}return $1}var G1,h3;function BW(){if(h3)return G1;h3=1;var t=Ot(),e=Gn(),n=ji().Graph;G1={debugOrdering:i};function i(r){var s=e.buildLayerMatrix(r),o=new n({compound:!0,multigraph:!0}).setGraph({});return t.forEach(r.nodes(),function(c){o.setNode(c,{label:c}),o.setParent(c,"layer"+r.node(c).rank)}),t.forEach(r.edges(),function(c){o.setEdge(c.v,c.w,{},c.name)}),t.forEach(s,function(c,u){var h="layer"+u;o.setNode(h,{rank:"same"}),t.reduce(c,function(d,m){return o.setEdge(d,m,{style:"invis"}),m})}),o}return G1}var Y1,d3;function qW(){return d3||(d3=1,Y1="0.8.5"),Y1}var Q1,p3;function jW(){return p3||(p3=1,Q1={graphlib:ji(),layout:zW(),debug:BW(),util:{time:Gn().time,notime:Gn().notime},version:qW()}),Q1}var IW=jW();const Eh=o2(IW);function xi(t){if(!t||typeof t!="object")throw new Error("Invalid YAML: Root must be an object");const e={tables:Array.isArray(t.tables)?t.tables:[],relationships:Array.isArray(t.relationships)?t.relationships:[],domains:Array.isArray(t.domains)?t.domains:[],layout:t.layout||{}};return e.tables=e.tables.map(n=>{let i=n.sampleData;if(i&&typeof i=="object"&&!Array.isArray(i)){const s=Array.isArray(i.columns)?i.columns:[],o=Array.isArray(i.rows)?i.rows:[];if(s.length>0&&o.length>0){const c=Array.isArray(n.columns)?n.columns:[];i=o.map(u=>c.map(h=>{const d=s.indexOf(h.id);return d!==-1?u[d]:null}))}else o.length>0?i=o:i=[]}const r=n.appearance?{...n.appearance}:void 0;return r&&r.sub_type&&/^type[0-7]$/.test(r.sub_type)&&!r.scd&&(r.scd=r.sub_type,r.sub_type=void 0),{...n,id:n.id||"unknown",name:n.name!==void 0?n.name:n.id||"Unnamed Table",logical_name:n.logical_name,physical_name:n.physical_name,appearance:r,lineage:n.lineage?{...n.lineage}:void 0,columns:Array.isArray(n.columns)?n.columns.map(s=>({...s,logical:s.logical?{...s.logical}:void 0,physical:s.physical?{...s.physical}:void 0})):[],sampleData:Array.isArray(i)?i:[]}}),e}function PW(t){try{const e=eS.load(t);return xi(e)}catch(e){throw new Error(`YAML Parsing Error: ${e.message}`)}}let X1=null;const ci=r$((t,e)=>({schema:null,selectedTableId:null,selectedEdgeId:null,hoveredColumnId:null,error:null,isCliMode:typeof window<"u"&&window.MODSCAPE_CLI_MODE===!0,isAutoSaveEnabled:!0,savingStatus:"idle",lastUpdateSource:"visual",yamlInput:"",setYamlInput:n=>t({yamlInput:n,lastUpdateSource:"user"}),syncToYamlInput:()=>{const{schema:n}=e();if(n){const i=eS.dump(n,{indent:2,lineWidth:-1,noRefs:!0});t({yamlInput:i,lastUpdateSource:"visual"})}},availableFiles:[],currentModelSlug:null,isSidebarOpen:!0,activeTab:"editor",focusNodeId:null,showER:!0,showLineage:!0,connectionStartHandle:null,theme:typeof window<"u"&&localStorage.getItem("modscape-theme")||(window.matchMedia?.("(prefers-color-scheme: light)").matches?"light":"dark"),setSchema:n=>{try{const i=xi(n);t({schema:i,error:null}),e().syncToYamlInput()}catch(i){t({error:i.message})}},setShowER:n=>t({showER:n}),setShowLineage:n=>t({showLineage:n}),setIsAutoSaveEnabled:n=>t({isAutoSaveEnabled:n}),setLastUpdateSource:n=>t({lastUpdateSource:n}),setSelectedTableId:n=>t({selectedTableId:n}),setSelectedEdgeId:n=>t({selectedEdgeId:n}),setHoveredColumnId:n=>t({hoveredColumnId:n}),setIsCliMode:n=>t({isCliMode:n}),setIsSidebarOpen:n=>t({isSidebarOpen:n}),setActiveTab:n=>t({activeTab:n}),setFocusNodeId:n=>t({focusNodeId:n}),setConnectionStartHandle:n=>t({connectionStartHandle:n}),toggleTheme:()=>{const{theme:n}=e(),i=n==="dark"?"light":"dark";t({theme:i}),localStorage.setItem("modscape-theme",i)},calculateAutoLayout:()=>{const{schema:n}=e();if(!n)return;const i={...n.layout||{}},r=320,s=220,o=80,c=120,u={};n.domains?.forEach(g=>{const y=g.tables;if(y.length===0){u[g.id]={width:400,height:200,tableOffsets:{}};return}const x=new Eh.graphlib.Graph;x.setGraph({rankdir:"TB",nodesep:o,ranksep:o}),x.setDefaultEdgeLabel(()=>({})),y.forEach(M=>{const R=n.layout?.[M];x.setNode(M,{width:R?.width||r,height:R?.height||s})}),(n.relationships||[]).forEach(M=>{y.includes(M.from.table)&&y.includes(M.to.table)&&x.setEdge(M.from.table,M.to.table)}),n.tables.forEach(M=>{y.includes(M.id)&&M.lineage?.upstream&&M.lineage.upstream.forEach(R=>{y.includes(R)&&x.setEdge(R,M.id)})}),Eh.layout(x);let w=1/0,S=1/0,C=-1/0,A=-1/0;const O={};x.nodes().forEach(M=>{const R=x.node(M);O[M]={x:R.x,y:R.y},w=Math.min(w,R.x-R.width/2),S=Math.min(S,R.y-R.height/2),C=Math.max(C,R.x+R.width/2),A=Math.max(A,R.y+R.height/2)});const E=C-w+c,T=A-S+c;y.forEach(M=>{O[M].x=Math.round(O[M].x-w-x.node(M).width/2+c/2),O[M].y=Math.round(O[M].y-S-x.node(M).height/2+c/2)}),u[g.id]={width:E,height:T,tableOffsets:O}});const h=[...n.domains?.map(g=>g.id)||[],...n.tables.filter(g=>!n.domains?.some(y=>y.tables.includes(g.id))).map(g=>g.id)],d=new Eh.graphlib.Graph;d.setGraph({rankdir:"LR",nodesep:200,ranksep:300}),d.setDefaultEdgeLabel(()=>({})),h.forEach(g=>{const y=n.domains?.some(S=>S.id===g),x=y?u[g].width:n.layout?.[g]?.width||r,w=y?u[g].height:n.layout?.[g]?.height||s;d.setNode(g,{width:x,height:w})});const m=g=>n.domains?.find(y=>y.tables.includes(g))?.id||g;n.relationships?.forEach(g=>{const y=m(g.from.table),x=m(g.to.table);y!==x&&d.setEdge(y,x)}),n.tables.forEach(g=>{if(g.lineage?.upstream){const y=m(g.id);g.lineage.upstream.forEach(x=>{const w=m(x);w!==y&&d.setEdge(w,y)})}}),Eh.layout(d),d.nodes().forEach(g=>{const y=d.node(g),x=Math.round(y.x-y.width/2),w=Math.round(y.y-y.height/2),S=n.domains?.find(C=>C.id===g);S?(i[g]={x,y:w,width:u[g].width,height:u[g].height},S.tables.forEach(C=>{i[C]={x:u[g].tableOffsets[C].x,y:u[g].tableOffsets[C].y}})):i[g]={x,y:w}}),t({schema:{...n,layout:i},lastUpdateSource:"visual"}),e().syncToYamlInput(),e().saveSchema(!0)},fetchAvailableFiles:async()=>{const n=window.__MODSCAPE_DATA__;if(n&&n.models){const i=n.models.map(r=>({slug:r.slug,name:r.name,path:""}));t({availableFiles:i});return}try{const r=await(await fetch("/api/files")).json();t({availableFiles:r})}catch(i){console.error("Failed to fetch files:",i)}},setCurrentModel:async n=>{const i=window.__MODSCAPE_DATA__;if(i&&i.models){const r=i.models.find(s=>s.slug===n);if(r){t({currentModelSlug:n,schema:xi(r.schema),selectedTableId:null,error:null}),e().syncToYamlInput();const s=new URLSearchParams(window.location.search);s.set("model",n);const o=window.location.pathname+"?"+s.toString();window.history.pushState(null,"",o)}return}try{const r=`/api/model?model=${n}`,o=await(await fetch(r)).json();t({currentModelSlug:n,schema:xi(o),selectedTableId:null,error:null}),e().syncToYamlInput();const c=new URLSearchParams(window.location.search);c.set("model",n);const u=window.location.pathname+"?"+c.toString();window.history.pushState(null,"",u)}catch(r){console.error("Failed to fetch model:",r)}},parseAndSetSchema:n=>{if(!(!n||n.trim()===""))try{const i=PW(n);t({schema:i,error:null}),e().saveSchema()}catch(i){t({error:i.message})}},updateNodePosition:(n,i,r,s)=>{const o=e().schema;if(!o)return;let c=o.domains||[];s!==void 0&&(c=c.map(d=>({...d,tables:d.tables.filter(m=>m!==n)})),s&&(c=c.map(d=>d.id===s?{...d,tables:Array.from(new Set([...d.tables,n]))}:d)));const u=o.layout?.[n]||{x:0,y:0},h={...o.layout||{},[n]:{...u,x:Math.round(i),y:Math.round(r)}};t({schema:{...o,domains:c,layout:h}}),e().syncToYamlInput(),e().saveSchema()},updateNodesPosition:n=>{const i=e().schema;if(!i||n.length===0)return;const r={...i.layout||{}};n.forEach(s=>{const o=r[s.id]||{x:0,y:0};r[s.id]={...o,x:Math.round(s.x),y:Math.round(s.y)}}),t({schema:{...i,layout:r},lastUpdateSource:"visual"}),e().syncToYamlInput(),e().saveSchema()},updateNodeDimensions:(n,i,r)=>{const s=e().schema;if(!s)return;const o=s.layout?.[n]||{x:0,y:0},c={...s.layout||{},[n]:{...o,width:Math.round(i),height:Math.round(r)}};t({schema:{...s,layout:c}}),e().syncToYamlInput(),e().saveSchema()},saveSchema:async(n=!1)=>{const{schema:i,currentModelSlug:r,isAutoSaveEnabled:s,isCliMode:o}=e();!i||!o||!s&&!n||(t({savingStatus:"saving"}),X1&&clearTimeout(X1),X1=setTimeout(async()=>{try{const c=r?`/api/save?model=${r}`:"/api/save",u=eS.dump(i,{indent:2,lineWidth:-1,noRefs:!0});await fetch(c,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({yaml:u})}),t({savingStatus:"saved"}),setTimeout(()=>t({savingStatus:"idle"}),2e3)}catch(c){console.error("Failed to save schema:",c),t({savingStatus:"error"})}},500))},addTable:(n,i)=>{const r=e().schema||{tables:[],relationships:[],domains:[],layout:{}},s=`new_table_${Date.now()}`,o={id:s,name:"NEW_TABLE",appearance:{type:"table"},columns:[{id:"id",logical:{name:"ID",type:"Integer",isPrimaryKey:!0}}]},c={...r,tables:[...r.tables||[],o],layout:{...r.layout||{},[s]:{x:Math.round(n),y:Math.round(i)}}};t({schema:xi(c),error:null,selectedTableId:s,selectedEdgeId:null}),e().syncToYamlInput(),e().saveSchema()},addDomain:(n,i)=>{const r=e().schema||{tables:[],relationships:[],domains:[],layout:{}},s=`new_domain_${Date.now()}`,o={id:s,name:"NEW_DOMAIN",description:"Domain purpose",tables:[],color:"rgba(59, 130, 246, 0.05)"},c={...r,domains:[...r.domains||[],o],layout:{...r.layout||{},[s]:{x:Math.round(n),y:Math.round(i),width:600,height:400}}};t({schema:xi(c),error:null,selectedTableId:s,selectedEdgeId:null}),e().syncToYamlInput(),e().saveSchema()},addRelationship:(n,i,r,s)=>{const o=e().schema;if(!o)return;if(r?.includes("lineage")||s?.includes("lineage")){e().addLineage(n,i);return}let u=n,h=i,d=r,m=s;const g=r?.includes("target"),y=s?.includes("source");(g||y)&&(u=i,h=n,d=s,m=r);const x=(E,T)=>{if(!T)return;const M=T.replace(`${E}-`,"");if(!(M.startsWith("er-")||M.startsWith("lin-")))return M.split("-")[0]||void 0},w=x(u,d),S=x(h,m);if((o.relationships||[]).some(E=>E.from.table===u&&E.from.column===w&&E.to.table===h&&E.to.column===S))return;const A={from:{table:u,column:w},to:{table:h,column:S},type:"one-to-many"},O={...o,relationships:[...o.relationships||[],A]};t({schema:xi(O)}),e().syncToYamlInput(),e().saveSchema()},addLineage:(n,i)=>{const{schema:r}=e();if(!r)return;const s=r.tables.map(c=>{if(c.id===i){const u=c.lineage?.upstream||[];if(!u.includes(n))return{...c,lineage:{...c.lineage,upstream:[...u,n]}}}return c}),o={...r,tables:s};t({schema:xi(o)}),e().syncToYamlInput(),e().saveSchema()},updateRelationship:(n,i)=>{const{schema:r}=e();if(!r||!r.relationships)return;const s=r.relationships.map((o,c)=>c===n?{...o,...i}:o);t({schema:{...r,relationships:s}}),e().syncToYamlInput(),e().saveSchema()},removeEdge:(n,i)=>{const{schema:r}=e();if(!r)return;const s=(r.relationships||[]).filter(u=>!(u.from.table===n&&u.to.table===i||u.from.table===i&&u.to.table===n)),o=r.tables.map(u=>u.id===i&&u.lineage?.upstream?{...u,lineage:{...u.lineage,upstream:u.lineage.upstream.filter(h=>h!==n)}}:u),c={...r,relationships:s,tables:o};t({schema:xi(c),selectedEdgeId:null}),e().syncToYamlInput(),e().saveSchema()},removeNode:n=>{const{schema:i}=e();if(!i)return;const r=i.tables.filter(h=>h.id!==n),s=(i.domains||[]).filter(h=>h.id!==n).map(h=>({...h,tables:h.tables.filter(d=>d!==n)})),o=(i.relationships||[]).filter(h=>h.from.table!==n&&h.to.table!==n),c={...i.layout||{}};delete c[n];const u={...i,tables:r,domains:s,relationships:o,layout:c};t({schema:xi(u),selectedTableId:null}),e().syncToYamlInput(),e().saveSchema()},updateTable:(n,i)=>{const{schema:r}=e();if(!r)return;const s=r.tables.map(c=>c.id===n?{...c,...i}:c),o={...r,tables:s};t({schema:xi(o)}),e().syncToYamlInput(),e().saveSchema()},updateDomain:(n,i)=>{const{schema:r}=e();if(!r||!r.domains)return;const s=r.domains.map(c=>c.id===n?{...c,...i}:c),o={...r,domains:s};t({schema:xi(o)}),e().syncToYamlInput(),e().saveSchema()},toggleDomainLock:n=>{const{schema:i}=e();if(!i||!i.domains)return;const r=i.domains.map(s=>s.id===n?{...s,isLocked:!s.isLocked}:s);t({schema:{...i,domains:r}}),e().syncToYamlInput(),e().saveSchema()},assignTableToDomain:(n,i)=>{const{schema:r}=e();if(!r)return;const s=(r.domains||[]).map(c=>{const u=c.tables.filter(h=>h!==n);return c.id===i?{...c,tables:Array.from(new Set([...u,n]))}:{...c,tables:u}}),o={...r.layout||{},[n]:{x:20,y:20}};t({schema:{...r,domains:s,layout:o}}),e().syncToYamlInput(),e().saveSchema()},toggleTableSelection:n=>{const{selectedTableId:i}=e();t(i===n?{selectedTableId:null}:{selectedTableId:n,selectedEdgeId:null})},toggleEdgeSelection:n=>{const{selectedEdgeId:i}=e();t(i===n?{selectedEdgeId:null}:{selectedEdgeId:n,selectedTableId:null})},getSelectedTable:()=>{const{schema:n,selectedTableId:i}=e();return!n||!i?null:n.tables.find(r=>r.id===i)||null},getSelectedDomain:()=>{const{schema:n,selectedTableId:i}=e();return!n||!i||!n.domains?null:n.domains.find(r=>r.id===i)||null},getSelectedRelationship:()=>{const{schema:n,selectedEdgeId:i}=e();if(!n||!i)return null;if(i.startsWith("lin-")){const o=i.split("-"),c=o[1],u=o[2];return{relationship:{from:{table:c},to:{table:u},type:"lineage"},index:-1}}if(!i.startsWith("e-"))return null;const r=parseInt(i.split("-")[1]),s=n.relationships[r];return s?{relationship:s,index:r}:null}})),HW={fact:{color:"#f87171",icon:"📊",label:"FACT"},dimension:{color:"#60a5fa",icon:"🏷️",label:"DIM"},hub:{color:"#fbbf24",icon:"🌐",label:"HUB"},link:{color:"#34d399",icon:"🔗",label:"LINK"},satellite:{color:"#a78bfa",icon:"🛰️",label:"SAT"},mart:{color:"#f5700b",icon:"📈",label:"MART"},table:{color:"#64748b",icon:"📋",label:"TABLE"}},UW=({id:t,data:e,selected:n})=>{const{table:i}=e,[r,s]=j.useState(!0),o=NF();j.useEffect(()=>{o(t);const q=setTimeout(()=>s(!1),1e3);return()=>clearTimeout(q)},[t,i.name,i.logical_name,i.physical_name,i.columns,o]);const{updateNodeDimensions:c,hoveredColumnId:u,showER:h,showLineage:d,connectionStartHandle:m,theme:g}=ci(),y=n,x=i.columns&&i.columns.length>0,w=h&&d,S=i.appearance?.type?HW[i.appearance.type]:null,C=i.appearance?.color||S?.color||"#334155",A=i.appearance?.icon||S?.icon||"";let O=S?.label||"";const E=i.appearance?.sub_type,T=i.appearance?.scd;if(i.appearance?.type==="fact"&&E?O=`FACT (${{transaction:"Trans.",periodic:"Periodic",accumulating:"Accum.",factless:"Factless"}[E]||E})`:i.appearance?.type&&E?O=`${i.appearance.type.toUpperCase()} (${E})`:i.appearance?.type&&(O=i.appearance.type.toUpperCase()),T){const q=`SCD ${T.replace("type","T")}`;O=O?`${O} / ${q}`:q}const M=(q,U)=>{c(t,U.width,U.height)},R=(q,U)=>{if(!m)return"";const P=m.nodeId===t,$=m.handleType,K=!m.handleId?.includes("lin-");return P||U!==K?"handle-dim":$==="source"&&q==="target"||$==="target"&&q==="source"?"handle-pulse":"handle-dim"},z=(q,U)=>w&&U?{background:"#ef4444",cursor:"not-allowed",border:"1px solid #7f1d1d"}:{background:q,cursor:"crosshair"};return k.jsxs("div",{className:r?"animate-creation":"",style:{width:"100%",height:"100%",minWidth:"220px",position:"relative",cursor:"default"},children:[k.jsx(tz,{color:"#3b82f6",isVisible:y,minWidth:220,minHeight:40,onResizeEnd:M,handleStyle:{width:12,height:12,borderRadius:"50%",backgroundColor:"#3b82f6",border:"2px solid #ffffff",zIndex:100}}),O&&k.jsx("div",{style:{position:"absolute",top:"-12px",left:"12px",height:"14px",padding:"0 6px",backgroundColor:C,color:"#ffffff",fontSize:"8px",fontWeight:900,borderRadius:"4px 4px 0 0",display:"flex",alignItems:"center",justifyContent:"center",textTransform:"uppercase",letterSpacing:"0.05em",boxShadow:"0 -2px 4px rgba(0,0,0,0.1)",zIndex:1},children:O}),k.jsx(tr,{type:"target",position:Te.Top,id:`${t}-er-target-top`,className:R("target",!0),style:{...z(g==="dark"?"#94a3b8":"#64748b",h),width:"8px",height:"8px",zIndex:10,opacity:h?1:0,pointerEvents:h?"all":"none"}}),k.jsx(tr,{type:"target",position:Te.Left,id:`${t}-lin-target-left`,className:R("target",!1),style:{...z("#3b82f6",d),top:"50%",left:"-4px",width:"10px",height:"10px",zIndex:20,opacity:d?1:0,pointerEvents:d?"all":"none"}}),k.jsx(tr,{type:"source",position:Te.Right,id:`${t}-lin-source-right`,className:R("source",!1),style:{...z("#3b82f6",d),top:"50%",right:"-4px",width:"10px",height:"10px",zIndex:20,opacity:d?1:0,pointerEvents:d?"all":"none"}}),k.jsxs("div",{style:{width:"100%",height:"100%",backgroundColor:"var(--node-bg)",borderLeft:`2px solid ${y?"#3b82f6":"var(--border-main)"}`,borderRight:`2px solid ${y?"#3b82f6":"var(--border-main)"}`,borderBottom:`2px solid ${y?"#3b82f6":"var(--border-main)"}`,borderTop:`4px solid ${C}`,borderRadius:"8px",overflow:"hidden",color:"var(--text-primary)",boxShadow:y?"0 0 0 4px rgba(59, 130, 246, 0.2)":g==="dark"?"0 4px 6px -1px rgba(0, 0, 0, 0.3)":"0 4px 12px -2px rgba(0, 0, 0, 0.1)",fontFamily:"sans-serif",display:"flex",flexDirection:"column",transition:"background-color 0.3s, border-color 0.3s, color 0.3s"},children:[k.jsxs("div",{className:"table-drag-handle",style:{padding:"12px",backgroundColor:g==="dark"?"rgba(15, 23, 42, 0.8)":"rgba(241, 245, 249, 0.9)",borderBottom:x?"1px solid var(--border-main)":"none",flexShrink:0,cursor:"grab",display:"flex",flexDirection:"column",gap:"2px"},children:[k.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[A&&k.jsx("span",{style:{fontSize:"18px"},children:A}),k.jsx("div",{style:{fontSize:"16px",fontWeight:800,color:"var(--text-primary)",lineHeight:"1.2",wordBreak:"break-all"},children:i.name})]}),i.logical_name&&i.logical_name!==i.name&&k.jsx("div",{style:{fontSize:"11px",fontWeight:500,color:"var(--text-secondary)",paddingLeft:A?"26px":"0",opacity:.8},children:i.logical_name}),k.jsx("div",{title:i.physical_name||i.id,style:{fontSize:"9px",color:g==="dark"?"#94a3b8":"#64748b",fontFamily:"monospace",letterSpacing:"0.02em",paddingLeft:A?"26px":"0",marginTop:"2px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"100%"},children:i.physical_name||i.id})]}),x&&k.jsx("div",{className:"nodrag",style:{padding:"0",overflowY:"auto",flex:1,cursor:"default"},children:k.jsx("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"11px"},children:k.jsx("tbody",{children:i.columns.map((q,U)=>{const P=q.logical?.name||q.id,$=q.physical?.name||q.id,K=P!==$;return k.jsxs("tr",{className:"column-row",style:{borderBottom:"1px solid var(--border-main)",backgroundColor:u===q.id?g==="dark"?"rgba(30, 58, 138, 0.6)":"rgba(191, 219, 254, 0.4)":"transparent",position:"relative"},children:[k.jsxs("td",{style:{padding:"6px 12px",fontWeight:500,color:"var(--text-primary)",position:"relative"},children:[k.jsx(tr,{type:"target",position:Te.Left,id:`${t}-${q.id}-er-target-left`,className:`column-handle ${R("target",!0)}`,style:{...z("#3b82f6",h),left:"-4px",opacity:0,pointerEvents:h?"all":"none"}}),k.jsxs("div",{style:{display:"flex",alignItems:"flex-start"},children:[k.jsxs("span",{style:{color:"var(--text-secondary)",marginRight:"6px",fontSize:"9px",fontFamily:"monospace",width:"14px",textAlign:"right",opacity:.6,marginTop:"2px"},children:[U+1,"."]}),k.jsxs("div",{className:"flex flex-col flex-1 min-w-0",children:[k.jsxs("div",{className:"flex items-center gap-1.5 overflow-hidden",children:[q.logical?.isPrimaryKey&&k.jsx("span",{style:{color:"#eab308"},children:"🔑"}),q.logical?.isForeignKey&&k.jsx("span",{style:{opacity:.8},children:"🔩"}),q.logical?.isPartitionKey&&k.jsx("span",{style:{opacity:.8},children:"📂"}),q.logical?.isMetadata&&k.jsx("span",{style:{opacity:.8},title:"Metadata/Audit Column",children:"🕒"}),q.logical?.additivity==="fully"&&k.jsx("span",{style:{color:"#4ade80"},title:"Fully Additive",children:"Σ"}),q.logical?.additivity==="semi"&&k.jsx("span",{style:{color:"#fbbf24"},title:"Semi-Additive",children:"Σ~"}),q.logical?.additivity==="non"&&k.jsx("span",{style:{color:"#f87171"},title:"Non-Additive",children:"⊘"}),k.jsx("span",{className:"truncate",title:P,children:P})]}),K&&k.jsx("div",{style:{fontSize:"8px",fontFamily:"monospace",opacity:.6,marginTop:"1px",paddingLeft:"2px"},className:"truncate",title:$,children:$})]})]})]}),k.jsxs("td",{style:{padding:"6px 12px",textAlign:"right",fontStyle:"italic",color:"var(--text-secondary)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"120px",position:"relative",verticalAlign:"top",opacity:.8},children:[q.logical?.type||"Unknown",k.jsx(tr,{type:"source",position:Te.Right,id:`${t}-${q.id}-er-source-right`,className:`column-handle ${R("source",!0)}`,style:{...z("#3b82f6",h),right:"-4px",opacity:0,pointerEvents:h?"all":"none"}})]})]},q.id)})})})})]}),k.jsx(tr,{type:"source",position:Te.Bottom,id:`${t}-er-source-bottom`,className:R("source",!0),style:{...z(g==="dark"?"#94a3b8":"#64748b",h),width:"8px",height:"8px",zIndex:10,opacity:h?1:0,pointerEvents:h?"all":"none"}})]})},VW=j.memo(UW);const V8=(...t)=>t.filter((e,n,i)=>!!e&&e.trim()!==""&&i.indexOf(e)===n).join(" ").trim();const FW=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const $W=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,i)=>i?i.toUpperCase():n.toLowerCase());const m3=t=>{const e=$W(t);return e.charAt(0).toUpperCase()+e.slice(1)};var GW={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const YW=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0;return!1};const QW=j.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:i,className:r="",children:s,iconNode:o,...c},u)=>j.createElement("svg",{ref:u,...GW,width:e,height:e,stroke:t,strokeWidth:i?Number(n)*24/Number(e):n,className:V8("lucide",r),...!s&&!YW(c)&&{"aria-hidden":"true"},...c},[...o.map(([h,d])=>j.createElement(h,d)),...Array.isArray(s)?s:[s]]));const Qe=(t,e)=>{const n=j.forwardRef(({className:i,...r},s)=>j.createElement(QW,{ref:s,iconNode:e,className:V8(`lucide-${FW(m3(t))}`,`lucide-${t}`,i),...r}));return n.displayName=m3(t),n};const XW=[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]],W1=Qe("arrow-up-right",XW);const WW=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],tS=Qe("chevron-down",WW);const KW=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],ZW=Qe("chevron-left",KW);const JW=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],nS=Qe("chevron-right",JW);const eK=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],K1=Qe("circle-alert",eK);const tK=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],nK=Qe("circle-check",tK);const iK=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],F8=Qe("circle-question-mark",iK);const rK=[["path",{d:"M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3",key:"11bfej"}]],sK=Qe("command",rK);const aK=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],Go=Qe("database",aK);const oK=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],lK=Qe("eye",oK);const cK=[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M5 9v6",key:"158jrl"}],["circle",{cx:"5",cy:"18",r:"3",key:"104gr9"}],["path",{d:"M12 3v18",key:"108xh3"}],["circle",{cx:"19",cy:"6",r:"3",key:"108a5v"}],["path",{d:"M16 15.7A9 9 0 0 0 19 9",key:"1e3vqb"}]],g3=Qe("git-graph",cK);const uK=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]],fK=Qe("grid-3x3",uK);const hK=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],dK=Qe("grip-vertical",hK);const pK=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],mK=Qe("info",pK);const gK=[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"9",height:"7",x:"3",y:"14",rx:"1",key:"jqznyg"}],["rect",{width:"5",height:"7",x:"16",y:"14",rx:"1",key:"q5h2i8"}]],y3=Qe("layout-template",gK);const yK=[["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"M3 10a2 2 0 0 0 2 2h3",key:"1npucw"}],["path",{d:"M3 5v12a2 2 0 0 0 2 2h3",key:"x1gjn2"}]],vK=Qe("list-tree",yK);const bK=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],xK=Qe("loader-circle",bK);const wK=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]],SK=Qe("lock-open",wK);const CK=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],iS=Qe("lock",CK);const kK=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],AK=Qe("moon",kK);const _K=[["path",{d:"M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z",key:"edeuup"}]],OK=Qe("mouse-pointer-2",_K);const EK=[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m19 9 3 3-3 3",key:"1mg7y2"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m5 9-3 3 3 3",key:"j64kie"}],["path",{d:"m9 5 3-3 3 3",key:"l8vdw6"}]],TK=Qe("move",EK);const MK=[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]],RK=Qe("network",MK);const NK=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M9 21V9",key:"1oto5p"}]],v3=Qe("panels-top-left",NK);const DK=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],LK=Qe("pen-line",DK);const zK=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],BK=Qe("play",zK);const qK=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],rS=Qe("plus",qK);const jK=[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]],$8=Qe("redo-2",jK);const IK=[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}]],PK=Qe("refresh-ccw",IK);const HK=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],UK=Qe("save",HK);const VK=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],FK=Qe("search",VK);const $K=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],GK=Qe("sun",$K);const YK=[["path",{d:"M12 3v18",key:"108xh3"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}]],b3=Qe("table",YK);const QK=[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]],G8=Qe("tag",QK);const XK=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],Md=Qe("trash-2",XK);const WK=[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]],Y8=Qe("undo-2",WK);const KK=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Yo=Qe("x",KK),ZK=({id:t,data:e,selected:n})=>{const[i,r]=j.useState(!0);j.useEffect(()=>{const S=setTimeout(()=>r(!1),1e3);return()=>clearTimeout(S)},[]);const{updateNodeDimensions:s,theme:o,toggleDomainLock:c}=ci(),u=n,h=e.isLocked,d=e.color||"#3b82f6",m=o==="dark"?"rgba(15, 23, 42, 0.98)":"rgba(255, 255, 255, 0.98)",g=d,x=d.startsWith("rgba")||d.startsWith("hsla")||d.startsWith("#")&&d.length>7?1:.5,w=(S,C)=>{s(t,C.width,C.height)};return k.jsxs("div",{className:i?"animate-creation":"",style:{width:"100%",height:"100%",border:h?`2px solid ${o==="dark"?"#334155":"#cbd5e1"}`:`2px dashed ${u?"#3b82f6":o==="dark"?"#334155":"#cbd5e1"}`,borderRadius:"12px",padding:"10px",position:"relative",color:"var(--text-secondary)",cursor:"default",transition:"border-color 0.3s, opacity 0.3s",opacity:h?.8:1},children:[!h&&k.jsx(tz,{color:"#3b82f6",isVisible:u,minWidth:200,minHeight:150,onResizeEnd:w,handleStyle:{width:14,height:14,borderRadius:"50%",backgroundColor:"#3b82f6",border:"2px solid #ffffff",zIndex:100}}),k.jsx("div",{style:{position:"absolute",inset:0,backgroundColor:d,opacity:x,borderRadius:"10px",zIndex:-1,cursor:"default"}}),k.jsxs("div",{className:h?"domain-locked-handle":"domain-drag-handle",style:{position:"absolute",top:"-30px",left:"0",fontSize:"13px",fontWeight:"bold",color:o==="dark"?"#f1f5f9":"#0f172a",whiteSpace:"nowrap",pointerEvents:"all",cursor:h?"default":"grab",padding:"4px 12px 4px 10px",backgroundColor:m,borderRadius:"6px 6px 0 0",border:`1px solid ${u?"#3b82f6":o==="dark"?"#334155":"#cbd5e1"}`,borderLeft:`4px solid ${g}`,borderBottom:"none",transition:"all 0.2s ease",display:"flex",alignItems:"center",gap:"8px",boxShadow:o==="dark"?"0 -4px 12px rgba(0,0,0,0.4)":"0 -2px 8px rgba(0,0,0,0.08)",zIndex:10},children:[!h&&k.jsx(dK,{size:14,className:o==="dark"?"text-slate-400":"text-slate-500"}),k.jsx("span",{className:"truncate max-w-[200px]",children:e.label}),k.jsx("div",{className:`w-px h-3 mx-1 ${o==="dark"?"bg-slate-700":"bg-slate-200"}`}),k.jsx("button",{onClick:S=>{S.stopPropagation(),c(t)},className:`p-0.5 rounded transition-colors ${h?"text-amber-500 hover:text-amber-400":"text-slate-400 hover:text-blue-500"}`,title:h?"Unlock Domain":"Lock Domain",children:h?k.jsx(iS,{size:12}):k.jsx(SK,{size:12})})]})]})},JK=j.memo(ZK),eZ={fact:{color:"#f87171",icon:"📊",label:"FACT"},dimension:{color:"#60a5fa",icon:"🏷️",label:"DIM"},hub:{color:"#fbbf24",icon:"🌐",label:"HUB"},link:{color:"#34d399",icon:"🔗",label:"LINK"},satellite:{color:"#a78bfa",icon:"🛰️",label:"SAT"},mart:{color:"#f5700b",icon:"📈",label:"MART"},table:{color:"#64748b",icon:"📋",label:"TABLE"}},tZ=()=>{const{schema:t,selectedTableId:e,selectedEdgeId:n,getSelectedTable:i,getSelectedDomain:r,getSelectedRelationship:s,setSelectedTableId:o,setSelectedEdgeId:c,updateTable:u,updateDomain:h,updateRelationship:d,assignTableToDomain:m,theme:g}=ci(),y=i(),x=r(),w=s(),[S,C]=j.useState("conceptual"),[A,O]=j.useState(""),[E,T]=j.useState(400),[M,R]=j.useState(!1);if(j.useEffect(()=>{if(!M)return;const H=me=>{const ye=window.innerHeight-me.clientY;T(Math.max(150,Math.min(ye,window.innerHeight*.9)))},pe=()=>{R(!1),document.body.style.cursor="default"};return window.addEventListener("mousemove",H),window.addEventListener("mouseup",pe),()=>{window.removeEventListener("mousemove",H),window.removeEventListener("mouseup",pe)}},[M]),!e&&!n||!y&&!x&&!w)return null;const z=H=>{H.preventDefault(),R(!0),document.body.style.cursor="ns-resize"},q=H=>{H.stopPropagation()},U={height:`${E}px`,maxHeight:"90vh",minHeight:"150px",backgroundColor:"var(--node-bg)",borderTop:`2px solid ${g==="dark"?"#3b82f6":"#60a5fa"}`,display:"flex",flexDirection:"column",color:"var(--text-primary)",boxShadow:g==="dark"?"0 -10px 25px -5px rgba(0, 0, 0, 0.4)":"0 -4px 12px rgba(0, 0, 0, 0.05)",fontFamily:"sans-serif",position:"relative",transition:"background-color 0.3s, color 0.3s"},P=H=>{u(y.id,H)};if(w){const{relationship:H,index:pe}=w;return k.jsxs("div",{className:"shadow-2xl z-50 flex flex-col",onClick:q,onMouseDown:q,onPointerDown:q,style:U,children:[k.jsx("div",{onMouseDown:z,style:{position:"absolute",top:"-4px",left:0,right:0,height:"8px",cursor:"ns-resize",zIndex:60}}),k.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 20px",borderBottom:"1px solid var(--border-main)",backgroundColor:"var(--header-bg)"},children:[k.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",flex:1},children:[k.jsx(Go,{size:18,style:{color:"#3b82f6"}}),k.jsxs("div",{style:{flex:1},children:[k.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[k.jsx("span",{style:{fontSize:"14px",fontWeight:"bold"},children:"Relationship"}),k.jsx("span",{style:{fontSize:"9px",fontWeight:800,padding:"1px 5px",borderRadius:"3px",backgroundColor:"rgba(59, 130, 246, 0.1)",color:"#60a5fa",border:"1px solid rgba(59, 130, 246, 0.2)",textTransform:"uppercase"},children:"EDGE"})]}),k.jsxs("p",{style:{fontSize:"11px",color:"var(--text-secondary)",textTransform:"uppercase",margin:0},children:[H.from.table,H.from.column?`.${H.from.column}`:""," → ",H.to.table,H.to.column?`.${H.to.column}`:""]})]})]}),k.jsx("button",{onClick:()=>c(null),className:`p-1.5 rounded-full transition-colors ${g==="dark"?"hover:bg-slate-800 text-slate-500":"hover:bg-slate-200 text-slate-400"}`,children:k.jsx(Yo,{size:18})})]}),k.jsx("div",{style:{flex:1,overflowY:"auto",padding:"20px"},children:k.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"24px"},children:[k.jsxs("div",{className:"grid grid-cols-2 gap-8",children:[k.jsxs("section",{children:[k.jsx("h3",{className:"text-[11px] font-bold uppercase tracking-wider text-slate-500 mb-2",children:"Relationship Type"}),k.jsxs("select",{value:H.type||"one-to-many",onChange:me=>d(pe,{type:me.target.value}),className:`w-full border rounded text-sm p-2.5 outline-none transition-colors ${g==="dark"?"bg-slate-800 border-slate-700 text-slate-200 focus:ring-blue-500":"bg-white border-slate-200 text-slate-900 focus:ring-blue-400 focus:border-blue-400 shadow-sm"}`,children:[k.jsx("option",{value:"one-to-one",children:"One-to-One"}),k.jsx("option",{value:"one-to-many",children:"One-to-Many"}),k.jsx("option",{value:"many-to-one",children:"Many-to-One"}),k.jsx("option",{value:"many-to-many",children:"Many-to-Many"})]})]}),k.jsxs("section",{children:[k.jsx("h3",{className:"text-[11px] font-bold uppercase tracking-wider text-slate-500 mb-2",children:"Cardinality (Metadata)"}),k.jsxs("div",{className:"text-slate-500 text-sm",children:["Mapping established from ",k.jsx("strong",{children:H.from.table})," to ",k.jsx("strong",{children:H.to.table}),"."]})]})]}),k.jsxs("section",{children:[k.jsx("h3",{className:"text-[11px] font-bold uppercase tracking-wider text-slate-500 mb-2",children:"Source/Target Details"}),k.jsxs("div",{className:`flex gap-4 items-center p-3 rounded border ${g==="dark"?"bg-slate-800/50 border-slate-800":"bg-slate-50 border-slate-100"}`,children:[k.jsxs("div",{className:"flex-1",children:[k.jsx("div",{className:"text-[10px] text-slate-500 uppercase",children:"From Table"}),k.jsx("div",{className:`text-sm font-bold ${g==="dark"?"text-blue-400":"text-blue-600"}`,children:H.from.table}),k.jsxs("div",{className:"text-[10px] text-slate-500",children:["Column: ",H.from.column||"(Table level)"]})]}),k.jsx("div",{className:"text-slate-400 dark:text-slate-600",children:"→"}),k.jsxs("div",{className:"flex-1",children:[k.jsx("div",{className:"text-[10px] text-slate-500 uppercase",children:"To Table"}),k.jsx("div",{className:`text-sm font-bold ${g==="dark"?"text-blue-400":"text-blue-600"}`,children:H.to.table}),k.jsxs("div",{className:"text-[10px] text-slate-500",children:["Column: ",H.to.column||"(Table level)"]})]})]})]})]})})]})}if(x)return k.jsxs("div",{className:"shadow-2xl z-50 flex flex-col",onClick:q,onMouseDown:q,onPointerDown:q,style:{...U,borderTopColor:x.color||"#3b82f6"},children:[k.jsx("div",{onMouseDown:z,style:{position:"absolute",top:"-4px",left:0,right:0,height:"8px",cursor:"ns-resize",zIndex:60}}),k.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 20px",borderBottom:"1px solid var(--border-main)",backgroundColor:"var(--header-bg)"},children:[k.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",flex:1},children:[k.jsx(Go,{size:18,style:{color:x.color||"#3b82f6"}}),k.jsxs("div",{style:{flex:1},children:[k.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[k.jsx("input",{value:x.name??"",onChange:H=>h(x.id,{name:H.target.value}),onBlur:H=>{H.target.value||h(x.id,{name:"UNNAMED_DOMAIN"})},style:{fontSize:"16px",fontWeight:"bold",color:"var(--text-primary)",backgroundColor:"transparent",border:"none",borderBottom:"1px solid transparent",padding:"2px 0",outline:"none",width:"fit-content",minWidth:"200px"},onFocus:H=>H.target.style.borderBottom="1px solid #3b82f6"}),k.jsx("span",{style:{fontSize:"9px",fontWeight:800,padding:"1px 5px",borderRadius:"3px",backgroundColor:"rgba(59, 130, 246, 0.1)",color:"#60a5fa",border:"1px solid rgba(59, 130, 246, 0.2)",textTransform:"uppercase"},children:"DOMAIN"})]}),k.jsx("p",{style:{fontSize:"11px",color:"var(--text-secondary)",textTransform:"uppercase",margin:0},children:x.id})]})]}),k.jsx("button",{onClick:()=>o(null),className:`p-1.5 rounded-full transition-colors ${g==="dark"?"hover:bg-slate-800 text-slate-500":"hover:bg-slate-200 text-slate-400"}`,children:k.jsx(Yo,{size:18})})]}),k.jsx("div",{style:{flex:1,overflowY:"auto",padding:"20px"},children:k.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"20px"},children:[k.jsxs("section",{children:[k.jsx("h3",{className:"text-[11px] font-bold uppercase tracking-wider text-slate-500 mb-2",children:"Domain Description"}),k.jsx("textarea",{value:x.description||"",onChange:H=>h(x.id,{description:H.target.value}),placeholder:"What is the purpose of this domain?",style:{width:"100%",minHeight:"80px",backgroundColor:g==="dark"?"#0f172a":"#ffffff",border:"1px solid var(--border-main)",borderRadius:"6px",padding:"12px",color:"var(--text-primary)",fontSize:"13px",lineHeight:"1.6",resize:"none",outline:"none",transition:"background-color 0.3s"}})]}),k.jsxs("section",{children:[k.jsx("h3",{className:"text-[11px] font-bold uppercase tracking-wider text-slate-500 mb-2",children:"Domain Theme Color"}),k.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[k.jsx("input",{type:"color",value:x.color?.startsWith("rgba")?"#3b82f6":x.color||"#3b82f6",onChange:H=>h(x.id,{color:H.target.value}),style:{width:"40px",height:"40px",padding:0,border:"none",borderRadius:"4px",cursor:"pointer",backgroundColor:"transparent"}}),k.jsx("input",{value:x.color||"",onChange:H=>h(x.id,{color:H.target.value}),placeholder:"e.g. #3b82f6 or rgba(...)",className:`border rounded font-mono text-sm p-2 outline-none flex-1 transition-colors ${g==="dark"?"bg-slate-800 border-slate-700 text-slate-300 focus:ring-blue-500":"bg-white border-slate-200 text-slate-900 focus:ring-blue-400 focus:border-blue-400 shadow-sm"}`})]})]})]})})]});const $=[{id:"conceptual",label:"Conceptual",icon:k.jsx(G8,{size:14})},{id:"logical",label:"Logical",icon:k.jsx(Go,{size:14})},{id:"physical",label:"Physical",icon:k.jsx(Go,{size:14})},{id:"sample",label:"Sample Data",icon:k.jsx(b3,{size:14})}],K=y.appearance?.type?eZ[y.appearance.type]:null,L=y.appearance?.color||K?.color||"#334155",Y=y.appearance?.icon||K?.icon||"";let D=K?.label||"";const Q=y.appearance?.sub_type,ee=y.appearance?.scd;if(y.appearance?.type==="fact"&&Q?D=`FACT (${{transaction:"Trans.",periodic:"Periodic",accumulating:"Accum.",factless:"Factless"}[Q]||Q})`:y.appearance?.type&&Q?D=`${y.appearance.type.toUpperCase()} (${Q})`:y.appearance?.type&&(D=y.appearance.type.toUpperCase()),ee){const H=`SCD ${ee.replace("type","T")}`;D=D?`${D} / ${H}`:H}const G=H=>{H.stopPropagation();const pe={id:`col_${Date.now()}`,logical:{name:"New Column",type:"String",description:""},physical:{name:"",type:"VARCHAR(255)",constraints:[]}};P({columns:[...y.columns||[],pe]})},W=(H,pe)=>{H.stopPropagation();const me=y.columns?.filter(ye=>ye.id!==pe)||[];P({columns:me})},B=(H,pe)=>{const me=y.columns?.map(ye=>ye.id===H?{...ye,logical:{name:ye.logical?.name||ye.id,type:ye.logical?.type||"String",...ye.logical,...pe}}:ye)||[];P({columns:me})},F=(H,pe)=>{const me=y.columns?.map(ye=>ye.id===H?{...ye,physical:{...ye.physical,...pe}}:ye)||[];P({columns:me})},ne=H=>{if(H.key==="Enter"&&A.trim()){const pe=y.conceptual?.tags||[];pe.includes(A.trim())||P({conceptual:{...y.conceptual,tags:[...pe,A.trim()]}}),O("")}},I=(H,pe)=>{H.stopPropagation();const me=y.conceptual?.tags||[];P({conceptual:{...y.conceptual,tags:me.filter(ye=>ye!==pe)}})},X=H=>{P({sampleData:H})},J=H=>{H.stopPropagation();const pe=y.sampleData||[],me=y.columns?.length||0,ye=new Array(me).fill("");X([...pe,ye])},oe=(H,pe)=>{H.stopPropagation();const ye=(y.sampleData||[]).filter((_e,Ae)=>Ae!==pe);X(ye)},ve=(H,pe,me)=>{const ye=[...y.sampleData||[]];if(!ye[H])return;const _e=[...ye[H]];_e[pe]=me,ye[H]=_e,X(ye)};return k.jsxs("div",{className:"shadow-2xl z-50 flex flex-col",onClick:q,onMouseDown:q,onPointerDown:q,style:{...U,borderTopColor:L},children:[k.jsx("div",{onMouseDown:z,style:{position:"absolute",top:"-4px",left:0,right:0,height:"8px",cursor:"ns-resize",zIndex:60}}),k.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 20px",borderBottom:"1px solid var(--border-main)",backgroundColor:"var(--header-bg)"},children:[k.jsxs("div",{style:{flex:1},children:[k.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"4px"},children:[Y&&k.jsx("span",{style:{fontSize:"16px"},children:Y}),k.jsx("span",{style:{fontSize:"11px",color:"var(--text-secondary)",textTransform:"uppercase",fontFamily:"monospace",letterSpacing:"0.05em"},children:y.id}),D&&k.jsx("span",{style:{fontSize:"9px",fontWeight:800,padding:"1px 5px",borderRadius:"3px",backgroundColor:`${L}30`,color:L,border:`1px solid ${L}50`,textTransform:"uppercase"},children:D})]}),k.jsx("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:k.jsx("input",{value:y.name??"",onChange:H=>P({name:H.target.value}),onBlur:H=>{H.target.value||P({name:"UNNAMED_TABLE"})},title:"Conceptual Table Name",style:{fontSize:"18px",fontWeight:"bold",color:"var(--text-primary)",backgroundColor:"transparent",border:"none",borderBottom:"1px solid transparent",padding:"2px 0",outline:"none",width:"100%",maxWidth:"500px"},onFocus:H=>H.target.style.borderBottom="1px solid #3b82f6"})})]}),k.jsxs("div",{style:{display:"flex",gap:"8px",marginRight:"16px"},children:[k.jsxs("select",{value:y.appearance?.type||"fact",onChange:H=>P({appearance:{...y.appearance,type:H.target.value}}),className:`border rounded text-[10px] px-2 py-1 outline-none transition-colors ${g==="dark"?"bg-slate-800 border-slate-700 text-slate-300 focus:ring-blue-500":"bg-white border-slate-200 text-slate-900 focus:ring-blue-400 focus:border-blue-400"}`,title:"Table Type",children:[k.jsx("option",{value:"fact",children:"Fact"}),k.jsx("option",{value:"dimension",children:"Dimension"}),k.jsx("option",{value:"mart",children:"Mart"}),k.jsx("option",{value:"table",children:"Table"}),k.jsx("option",{value:"hub",children:"Hub"}),k.jsx("option",{value:"link",children:"Link"}),k.jsx("option",{value:"satellite",children:"Satellite"})]}),k.jsxs("select",{value:y.appearance?.sub_type||"",onChange:H=>P({appearance:{...y.appearance,sub_type:H.target.value||void 0}}),className:`border rounded text-[10px] px-2 py-1 outline-none transition-colors ${g==="dark"?"bg-slate-800 border-slate-700 text-slate-300 focus:ring-blue-500":"bg-white border-slate-200 text-slate-900 focus:ring-blue-400 focus:border-blue-400"}`,title:"Table Sub-type",children:[k.jsx("option",{value:"",children:"- Sub-type -"}),k.jsx("option",{value:"transaction",children:"Transaction"}),k.jsx("option",{value:"periodic",children:"Periodic Snapshot"}),k.jsx("option",{value:"accumulating",children:"Accumulating Snapshot"}),k.jsx("option",{value:"factless",children:"Factless"}),k.jsx("option",{value:"conformed",children:"Conformed"}),k.jsx("option",{value:"junk",children:"Junk"}),k.jsx("option",{value:"degenerate",children:"Degenerate"})]}),k.jsxs("select",{value:y.appearance?.scd||"",onChange:H=>P({appearance:{...y.appearance,scd:H.target.value||void 0}}),className:`border rounded text-[10px] px-2 py-1 outline-none transition-colors ${g==="dark"?"bg-slate-800 border-slate-700 text-slate-300 focus:ring-blue-500":"bg-white border-slate-200 text-slate-900 focus:ring-blue-400 focus:border-blue-400"}`,title:"SCD Type",children:[k.jsx("option",{value:"",children:"- SCD Type -"}),k.jsx("option",{value:"type0",children:"SCD Type 0"}),k.jsx("option",{value:"type1",children:"SCD Type 1"}),k.jsx("option",{value:"type2",children:"SCD Type 2"}),k.jsx("option",{value:"type3",children:"SCD Type 3"}),k.jsx("option",{value:"type4",children:"SCD Type 4"}),k.jsx("option",{value:"type5",children:"SCD Type 5"}),k.jsx("option",{value:"type6",children:"SCD Type 6"}),k.jsx("option",{value:"type7",children:"SCD Type 7"})]})]}),k.jsx("button",{onClick:H=>{H.stopPropagation(),o(null)},className:`p-1.5 rounded-full transition-colors ${g==="dark"?"hover:bg-slate-800 text-slate-500":"hover:bg-slate-200 text-slate-400"}`,children:k.jsx(Yo,{size:18})})]}),k.jsx("div",{style:{display:"flex",gap:"24px",padding:"0 20px",borderBottom:"1px solid var(--border-main)",backgroundColor:"var(--header-bg)"},children:$.map(H=>k.jsxs("button",{onClick:pe=>{pe.stopPropagation(),C(H.id)},style:{padding:"12px 0",backgroundColor:"transparent",border:"none",borderBottom:S===H.id?"2px solid #3b82f6":"2px solid transparent",color:S===H.id?g==="dark"?"#60a5fa":"#2563eb":"var(--text-secondary)",fontSize:"13px",fontWeight:500,cursor:"pointer",display:"flex",alignItems:"center",gap:"6px",transition:"all 0.2s"},children:[H.icon," ",H.label]},H.id))}),k.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"15px 20px"},children:[S==="conceptual"&&k.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"20px"},children:[k.jsxs("section",{children:[k.jsx("h3",{className:"text-[11px] font-bold uppercase tracking-wider text-slate-500 mb-2",children:"Description"}),k.jsx("textarea",{value:y.conceptual?.description||"",onChange:H=>P({conceptual:{...y.conceptual,description:H.target.value}}),placeholder:"Enter business description...",style:{width:"100%",minHeight:"100px",backgroundColor:g==="dark"?"#0f172a":"#ffffff",border:"1px solid var(--border-main)",borderRadius:"6px",padding:"12px",color:"var(--text-primary)",fontSize:"13px",lineHeight:"1.6",resize:"none",outline:"none",transition:"background-color 0.3s"}})]}),k.jsxs("section",{children:[k.jsx("h3",{className:"text-[11px] font-bold uppercase tracking-wider text-slate-500 mb-2",children:"Domain Assignment"}),k.jsxs("select",{value:t?.domains?.find(H=>H.tables.includes(y.id))?.id||"",onChange:H=>m(y.id,H.target.value||null),className:`w-full border rounded text-sm p-2 outline-none transition-colors ${g==="dark"?"bg-slate-800 border-slate-700 text-slate-200 focus:ring-blue-500":"bg-white border-slate-200 text-slate-900 focus:ring-blue-400 focus:border-blue-400 shadow-sm"}`,children:[k.jsx("option",{value:"",children:"- No Domain -"}),t?.domains?.map(H=>k.jsxs("option",{value:H.id,children:[H.name," (",H.id,")"]},H.id))]})]}),k.jsxs("section",{children:[k.jsx("h3",{className:"text-[11px] font-bold uppercase tracking-wider text-slate-500 mb-2",children:"Tags"}),k.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",alignItems:"center"},children:[y.conceptual?.tags?.map(H=>k.jsxs("span",{className:`flex items-center gap-2 px-3 py-1 border rounded-full text-xs font-medium transition-colors ${g==="dark"?"bg-blue-500/10 text-blue-400 border-blue-500/20":"bg-blue-50 text-blue-600 border-blue-100"}`,children:[H,k.jsx("button",{onClick:pe=>I(pe,H),className:"hover:text-red-500 transition-colors",children:k.jsx(Yo,{size:12})})]},H)),k.jsx("div",{style:{position:"relative"},children:k.jsx("input",{type:"text",value:A,onChange:H=>O(H.target.value),onKeyDown:ne,placeholder:"+ New Tag",style:{backgroundColor:"transparent",border:"1px dashed var(--border-main)",borderRadius:"16px",padding:"4px 12px",fontSize:"11px",color:"var(--text-primary)",outline:"none",width:"100px"}})})]})]})]}),S==="logical"&&k.jsxs("div",{children:[k.jsxs("div",{className:"flex flex-col gap-4 mb-6",children:[k.jsxs("section",{children:[k.jsx("h3",{className:"text-[11px] font-bold uppercase tracking-wider text-slate-500 mb-2",children:"Logical Table Name"}),k.jsx("input",{value:y.logical_name||"",onChange:H=>P({logical_name:H.target.value}),placeholder:y.name,className:`w-full border rounded text-sm p-2 outline-none transition-colors ${g==="dark"?"bg-slate-800 border-slate-700 text-slate-200 focus:ring-blue-500":"bg-white border-slate-200 text-slate-900 focus:ring-blue-400 focus:border-blue-400 shadow-sm"}`})]}),k.jsxs("div",{className:"flex justify-between items-center",children:[k.jsx("h3",{className:"text-[11px] font-bold uppercase tracking-wider text-slate-500",children:"Logical Schema (Columns)"}),k.jsxs("button",{onClick:G,className:"flex items-center gap-2 px-3 py-1.5 bg-blue-600 hover:bg-blue-700 text-white rounded text-xs transition-colors shadow-md shadow-blue-500/20 font-medium",children:[k.jsx(rS,{size:14})," Add Column"]})]})]}),k.jsx("div",{style:{border:"1px solid var(--border-main)",borderRadius:"8px",overflow:"hidden"},children:k.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"12px"},children:[k.jsx("thead",{style:{backgroundColor:"var(--header-bg)",borderBottom:"1px solid var(--border-main)",textAlign:"left"},children:k.jsxs("tr",{children:[k.jsx("th",{style:{padding:"10px 16px",color:"var(--text-secondary)",width:"35%"},children:"Logical Name"}),k.jsx("th",{style:{padding:"10px 16px",color:"var(--text-secondary)",width:"15%"},children:"Role"}),k.jsx("th",{style:{padding:"10px 16px",color:"var(--text-secondary)",width:"15%"},children:"Type"}),k.jsx("th",{style:{padding:"10px 16px",color:"var(--text-secondary)",width:"30%"},children:"Description"}),k.jsx("th",{style:{padding:"10px 16px",width:"50px"}})]})}),k.jsx("tbody",{children:(y.columns||[]).map(H=>k.jsxs("tr",{style:{borderBottom:"1px solid var(--border-main)",backgroundColor:"var(--node-bg)"},children:[k.jsx("td",{style:{padding:"6px 16px"},children:k.jsxs("div",{className:"flex items-center gap-2",children:[k.jsx("button",{onClick:()=>B(H.id,{isPrimaryKey:!H.logical?.isPrimaryKey}),title:"Primary Key",className:`transition-opacity ${H.logical?.isPrimaryKey?"opacity-100":"opacity-20 hover:opacity-50"}`,children:"🔑"}),k.jsx("input",{value:H.logical?.name??"",onChange:pe=>B(H.id,{name:pe.target.value}),onBlur:pe=>{pe.target.value||B(H.id,{name:H.id})},className:`bg-transparent border-none w-full outline-none p-1 rounded font-medium transition-colors ${g==="dark"?"text-white focus:bg-slate-800":"text-slate-900 focus:bg-slate-50"}`})]})}),k.jsx("td",{style:{padding:"6px 16px"},children:k.jsxs("div",{className:"flex items-center gap-2",children:[k.jsx("button",{onClick:()=>B(H.id,{isMetadata:!H.logical?.isMetadata}),title:"Metadata/Audit",className:`transition-opacity text-sm ${H.logical?.isMetadata?"opacity-100":"opacity-20 hover:opacity-50"}`,children:"🕒"}),k.jsxs("select",{value:H.logical?.additivity||"",onChange:pe=>B(H.id,{additivity:pe.target.value||void 0}),title:"Additivity (for Measures)",style:{fontSize:"10px"},className:`border rounded outline-none transition-colors ${g==="dark"?"bg-slate-800 border-slate-700 text-slate-400":"bg-white border-slate-200 text-slate-600"}`,children:[k.jsx("option",{value:"",children:"-"}),k.jsx("option",{value:"fully",children:"Σ (Full)"}),k.jsx("option",{value:"semi",children:"Σ~ (Semi)"}),k.jsx("option",{value:"non",children:"⊘ (Non)"})]})]})}),k.jsx("td",{style:{padding:"6px 16px"},children:k.jsx("input",{value:H.logical?.type??"",onChange:pe=>B(H.id,{type:pe.target.value}),onBlur:pe=>{pe.target.value||B(H.id,{type:"String"})},placeholder:"Type...",className:`bg-transparent border-none font-mono text-[11px] w-full outline-none p-1 rounded transition-colors ${g==="dark"?"text-slate-400 focus:bg-slate-800":"text-slate-500 focus:bg-slate-50"}`})}),k.jsx("td",{style:{padding:"6px 16px"},children:k.jsx("input",{value:H.logical?.description||"",onChange:pe=>B(H.id,{description:pe.target.value}),placeholder:"Description...",className:`bg-transparent border-none text-[11px] w-full outline-none p-1 rounded transition-colors ${g==="dark"?"text-slate-500 focus:bg-slate-800":"text-slate-400 focus:bg-slate-50"}`})}),k.jsx("td",{style:{padding:"6px 16px",textAlign:"right"},children:k.jsx("button",{onClick:pe=>W(pe,H.id),className:"text-red-500/50 hover:text-red-500 p-1 transition-colors",children:k.jsx(Md,{size:14})})})]},H.id))})]})})]}),S==="physical"&&k.jsxs("div",{children:[k.jsxs("div",{className:"flex flex-col gap-4 mb-6",children:[k.jsxs("section",{children:[k.jsx("h3",{className:"text-[11px] font-bold uppercase tracking-wider text-slate-500 mb-2",children:"Physical Table Name"}),k.jsx("input",{value:y.physical_name||"",onChange:H=>P({physical_name:H.target.value}),placeholder:y.id,className:`w-full border rounded font-mono text-sm p-2 outline-none transition-colors ${g==="dark"?"bg-slate-800 border-slate-700 text-slate-300 focus:ring-blue-500":"bg-white border-slate-200 text-slate-900 focus:ring-blue-400 focus:border-blue-400 shadow-sm"}`})]}),k.jsx("div",{className:"flex justify-between items-center",children:k.jsx("h3",{className:"text-[11px] font-bold uppercase tracking-wider text-slate-500",children:"Physical Mappings"})})]}),k.jsx("div",{style:{border:"1px solid var(--border-main)",borderRadius:"8px",overflow:"hidden"},children:k.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"12px"},children:[k.jsx("thead",{style:{backgroundColor:"var(--header-bg)",borderBottom:"1px solid var(--border-main)",textAlign:"left"},children:k.jsxs("tr",{children:[k.jsx("th",{style:{padding:"10px 16px",color:"var(--text-secondary)",width:"25%"},children:"Logical Column"}),k.jsx("th",{style:{padding:"10px 16px",color:"var(--text-secondary)",width:"30%"},children:"DB Column Name"}),k.jsx("th",{style:{padding:"10px 16px",color:"var(--text-secondary)",width:"20%"},children:"DB Type"}),k.jsx("th",{style:{padding:"10px 16px",color:"var(--text-secondary)",width:"25%"},children:"Constraints"})]})}),k.jsx("tbody",{children:(y.columns||[]).map(H=>k.jsxs("tr",{style:{borderBottom:"1px solid var(--border-main)",backgroundColor:"var(--node-bg)"},children:[k.jsx("td",{style:{padding:"6px 16px",color:"var(--text-secondary)",borderRight:"1px solid var(--border-main)"},children:k.jsx("div",{className:"text-[11px] font-medium truncate",title:H.logical?.name||H.id,children:H.logical?.name||H.id})}),k.jsx("td",{style:{padding:"6px 16px"},children:k.jsx("input",{value:H.physical?.name??"",onChange:pe=>F(H.id,{name:pe.target.value}),placeholder:H.logical?.name.toLowerCase().replace(/ /g,"_"),className:`bg-transparent border-none font-mono text-[11px] w-full outline-none p-1 rounded transition-colors ${g==="dark"?"text-blue-400 focus:bg-slate-800":"text-blue-600 focus:bg-slate-50"}`})}),k.jsx("td",{style:{padding:"6px 16px"},children:k.jsx("input",{value:H.physical?.type??"",onChange:pe=>F(H.id,{type:pe.target.value}),placeholder:H.logical?.type.toUpperCase(),className:`bg-transparent border-none font-mono text-[11px] w-full outline-none p-1 rounded transition-colors ${g==="dark"?"text-slate-400 focus:bg-slate-800":"text-slate-500 focus:bg-slate-50"}`})}),k.jsx("td",{style:{padding:"6px 16px"},children:k.jsx("input",{value:H.physical?.constraints?.join(", ")||"",onChange:pe=>F(H.id,{constraints:pe.target.value.split(",").map(me=>me.trim()).filter(Boolean)}),placeholder:"e.g. NOT NULL",className:`bg-transparent border-none text-[11px] w-full outline-none p-1 rounded transition-colors ${g==="dark"?"text-slate-500 focus:bg-slate-800":"text-slate-400 focus:bg-slate-50"}`})})]},H.id))})]})})]}),S==="sample"&&k.jsxs("div",{className:"flex flex-col h-full",children:[k.jsxs("div",{className:"flex justify-between items-center mb-4",children:[k.jsx("h3",{className:"text-[11px] font-bold uppercase tracking-wider text-slate-500",children:"Sample Data Editor"}),k.jsx("div",{className:"flex gap-2",children:k.jsxs("button",{onClick:J,disabled:!y.columns||y.columns.length===0,className:`flex items-center gap-2 px-3 py-1.5 text-white rounded text-xs transition-colors font-medium shadow-md ${!y.columns||y.columns.length===0?"bg-slate-300 dark:bg-slate-700 cursor-not-allowed opacity-50":"bg-emerald-600 hover:bg-emerald-700 shadow-emerald-500/20"}`,children:[k.jsx(rS,{size:14})," Add Row"]})})]}),!y.columns||y.columns.length===0?k.jsxs("div",{className:`flex-1 flex flex-col items-center justify-center p-8 rounded-lg border border-dashed transition-colors ${g==="dark"?"bg-slate-900/50 border-slate-800":"bg-slate-50 border-slate-200"}`,children:[k.jsx(b3,{size:32,className:`${g==="dark"?"text-slate-700":"text-slate-300"} mb-4`}),k.jsx("p",{className:"text-sm text-slate-500 mb-1",children:"No columns defined yet."}),k.jsx("p",{className:"text-xs text-slate-400 italic",children:'Add columns in the "Logical" tab first to enable sample data.'})]}):k.jsx("div",{className:`flex-1 overflow-auto border rounded-lg shadow-inner transition-colors ${g==="dark"?"border-slate-800 bg-slate-950/20":"border-slate-200 bg-white"}`,children:k.jsxs("table",{className:"w-full border-collapse text-xs",children:[k.jsx("thead",{className:`sticky top-0 z-10 border-b transition-colors ${g==="dark"?"bg-slate-950 border-slate-800":"bg-slate-100 border-slate-200"}`,children:k.jsxs("tr",{children:[(y.columns||[]).map(H=>k.jsx("th",{className:`p-3 text-left border-r min-w-[140px] transition-colors ${g==="dark"?"border-slate-800":"border-slate-200"}`,children:k.jsxs("div",{className:"flex flex-col gap-0.5",children:[k.jsx("span",{className:`font-bold ${g==="dark"?"text-slate-200":"text-slate-700"}`,children:H?.logical?.name||H.id}),k.jsx("span",{className:`text-[10px] font-mono italic ${g==="dark"?"text-blue-400":"text-blue-600"}`,children:H?.physical?.name||H?.logical?.name?.toLowerCase().replace(/ /g,"_")||H.id})]})},H.id)),k.jsx("th",{className:`w-10 transition-colors ${g==="dark"?"bg-slate-950":"bg-slate-100"}`})]})}),k.jsxs("tbody",{children:[(y.sampleData||[]).map((H,pe)=>k.jsxs("tr",{className:`border-b transition-colors ${g==="dark"?"border-slate-800 hover:bg-slate-800/30":"border-slate-100 hover:bg-slate-50"}`,children:[(y.columns||[]).map((me,ye)=>k.jsx("td",{className:`p-0 border-r transition-colors ${g==="dark"?"border-slate-800":"border-slate-200"}`,children:k.jsx("input",{value:String(H[ye]??""),onChange:_e=>ve(pe,ye,_e.target.value),className:`w-full bg-transparent border-none p-3 outline-none font-mono transition-colors ${g==="dark"?"focus:bg-slate-800 text-slate-300":"focus:bg-blue-50 text-slate-700"}`})},me.id)),k.jsx("td",{className:"p-2 text-center",children:k.jsx("button",{onClick:me=>oe(me,pe),className:"text-slate-400 hover:text-red-500 transition-colors",children:k.jsx(Md,{size:12})})})]},pe)),(!y.sampleData||y.sampleData.length===0)&&k.jsx("tr",{children:k.jsx("td",{colSpan:(y.columns?.length||0)+1,className:`p-8 text-center text-slate-400 italic transition-colors ${g==="dark"?"bg-slate-900/20":"bg-slate-50"}`,children:'No rows defined. Click "Add Row" to start.'})})]})]})})]})]})]})};function Gr(t,e,{checkForDefaultPrevented:n=!0}={}){return function(r){if(t?.(r),n===!1||!r.defaultPrevented)return e?.(r)}}function K2(t,e=[]){let n=[];function i(s,o){const c=j.createContext(o),u=n.length;n=[...n,o];const h=m=>{const{scope:g,children:y,...x}=m,w=g?.[t]?.[u]||c,S=j.useMemo(()=>x,Object.values(x));return k.jsx(w.Provider,{value:S,children:y})};h.displayName=s+"Provider";function d(m,g){const y=g?.[t]?.[u]||c,x=j.useContext(y);if(x)return x;if(o!==void 0)return o;throw new Error(`\`${m}\` must be used within \`${s}\``)}return[h,d]}const r=()=>{const s=n.map(o=>j.createContext(o));return function(c){const u=c?.[t]||s;return j.useMemo(()=>({[`__scope${t}`]:{...c,[t]:u}}),[c,u])}};return r.scopeName=t,[i,nZ(r,...e)]}function nZ(...t){const e=t[0];if(t.length===1)return e;const n=()=>{const i=t.map(r=>({useScope:r(),scopeName:r.scopeName}));return function(s){const o=i.reduce((c,{useScope:u,scopeName:h})=>{const m=u(s)[`__scope${h}`];return{...c,...m}},{});return j.useMemo(()=>({[`__scope${e.scopeName}`]:o}),[o])}};return n.scopeName=e.scopeName,n}function x3(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function Z2(...t){return e=>{let n=!1;const i=t.map(r=>{const s=x3(r,e);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let r=0;r<i.length;r++){const s=i[r];typeof s=="function"?s():x3(t[r],null)}}}}function Rd(...t){return j.useCallback(Z2(...t),t)}function w3(t){const e=iZ(t),n=j.forwardRef((i,r)=>{const{children:s,...o}=i,c=j.Children.toArray(s),u=c.find(sZ);if(u){const h=u.props.children,d=c.map(m=>m===u?j.Children.count(h)>1?j.Children.only(null):j.isValidElement(h)?h.props.children:null:m);return k.jsx(e,{...o,ref:r,children:j.isValidElement(h)?j.cloneElement(h,void 0,d):null})}return k.jsx(e,{...o,ref:r,children:s})});return n.displayName=`${t}.Slot`,n}function iZ(t){const e=j.forwardRef((n,i)=>{const{children:r,...s}=n;if(j.isValidElement(r)){const o=oZ(r),c=aZ(s,r.props);return r.type!==j.Fragment&&(c.ref=i?Z2(i,o):o),j.cloneElement(r,c)}return j.Children.count(r)>1?j.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var rZ=Symbol("radix.slottable");function sZ(t){return j.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===rZ}function aZ(t,e){const n={...e};for(const i in e){const r=t[i],s=e[i];/^on[A-Z]/.test(i)?r&&s?n[i]=(...c)=>{const u=s(...c);return r(...c),u}:r&&(n[i]=r):i==="style"?n[i]={...r,...s}:i==="className"&&(n[i]=[r,s].filter(Boolean).join(" "))}return{...t,...n}}function oZ(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}function lZ(t){const e=t+"CollectionProvider",[n,i]=K2(e),[r,s]=n(e,{collectionRef:{current:null},itemMap:new Map}),o=w=>{const{scope:S,children:C}=w,A=ce.useRef(null),O=ce.useRef(new Map).current;return k.jsx(r,{scope:S,itemMap:O,collectionRef:A,children:C})};o.displayName=e;const c=t+"CollectionSlot",u=w3(c),h=ce.forwardRef((w,S)=>{const{scope:C,children:A}=w,O=s(c,C),E=Rd(S,O.collectionRef);return k.jsx(u,{ref:E,children:A})});h.displayName=c;const d=t+"CollectionItemSlot",m="data-radix-collection-item",g=w3(d),y=ce.forwardRef((w,S)=>{const{scope:C,children:A,...O}=w,E=ce.useRef(null),T=Rd(S,E),M=s(d,C);return ce.useEffect(()=>(M.itemMap.set(E,{ref:E,...O}),()=>{M.itemMap.delete(E)})),k.jsx(g,{[m]:"",ref:T,children:A})});y.displayName=d;function x(w){const S=s(t+"CollectionConsumer",w);return ce.useCallback(()=>{const A=S.collectionRef.current;if(!A)return[];const O=Array.from(A.querySelectorAll(`[${m}]`));return Array.from(S.itemMap.values()).sort((M,R)=>O.indexOf(M.ref.current)-O.indexOf(R.ref.current))},[S.collectionRef,S.itemMap])}return[{Provider:o,Slot:h,ItemSlot:y},x,i]}var Nd=globalThis?.document?j.useLayoutEffect:()=>{},cZ=T4[" useId ".trim().toString()]||(()=>{}),uZ=0;function Q8(t){const[e,n]=j.useState(cZ());return Nd(()=>{n(i=>i??String(uZ++))},[t]),e?`radix-${e}`:""}function fZ(t){const e=hZ(t),n=j.forwardRef((i,r)=>{const{children:s,...o}=i,c=j.Children.toArray(s),u=c.find(pZ);if(u){const h=u.props.children,d=c.map(m=>m===u?j.Children.count(h)>1?j.Children.only(null):j.isValidElement(h)?h.props.children:null:m);return k.jsx(e,{...o,ref:r,children:j.isValidElement(h)?j.cloneElement(h,void 0,d):null})}return k.jsx(e,{...o,ref:r,children:s})});return n.displayName=`${t}.Slot`,n}function hZ(t){const e=j.forwardRef((n,i)=>{const{children:r,...s}=n;if(j.isValidElement(r)){const o=gZ(r),c=mZ(s,r.props);return r.type!==j.Fragment&&(c.ref=i?Z2(i,o):o),j.cloneElement(r,c)}return j.Children.count(r)>1?j.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var dZ=Symbol("radix.slottable");function pZ(t){return j.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===dZ}function mZ(t,e){const n={...e};for(const i in e){const r=t[i],s=e[i];/^on[A-Z]/.test(i)?r&&s?n[i]=(...c)=>{const u=s(...c);return r(...c),u}:r&&(n[i]=r):i==="style"?n[i]={...r,...s}:i==="className"&&(n[i]=[r,s].filter(Boolean).join(" "))}return{...t,...n}}function gZ(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var yZ=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],_l=yZ.reduce((t,e)=>{const n=fZ(`Primitive.${e}`),i=j.forwardRef((r,s)=>{const{asChild:o,...c}=r,u=o?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),k.jsx(u,{...c,ref:s})});return i.displayName=`Primitive.${e}`,{...t,[e]:i}},{});function vZ(t){const e=j.useRef(t);return j.useEffect(()=>{e.current=t}),j.useMemo(()=>(...n)=>e.current?.(...n),[])}var bZ=T4[" useInsertionEffect ".trim().toString()]||Nd;function X8({prop:t,defaultProp:e,onChange:n=()=>{},caller:i}){const[r,s,o]=xZ({defaultProp:e,onChange:n}),c=t!==void 0,u=c?t:r;{const d=j.useRef(t!==void 0);j.useEffect(()=>{const m=d.current;m!==c&&console.warn(`${i} is changing from ${m?"controlled":"uncontrolled"} to ${c?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=c},[c,i])}const h=j.useCallback(d=>{if(c){const m=wZ(d)?d(t):d;m!==t&&o.current?.(m)}else s(d)},[c,t,s,o]);return[u,h]}function xZ({defaultProp:t,onChange:e}){const[n,i]=j.useState(t),r=j.useRef(n),s=j.useRef(e);return bZ(()=>{s.current=e},[e]),j.useEffect(()=>{r.current!==n&&(s.current?.(n),r.current=n)},[n,r]),[n,i,s]}function wZ(t){return typeof t=="function"}var SZ=j.createContext(void 0);function W8(t){const e=j.useContext(SZ);return t||e||"ltr"}var Z1="rovingFocusGroup.onEntryFocus",CZ={bubbles:!1,cancelable:!0},Iu="RovingFocusGroup",[sS,K8,kZ]=lZ(Iu),[AZ,Z8]=K2(Iu,[kZ]),[_Z,OZ]=AZ(Iu),J8=j.forwardRef((t,e)=>k.jsx(sS.Provider,{scope:t.__scopeRovingFocusGroup,children:k.jsx(sS.Slot,{scope:t.__scopeRovingFocusGroup,children:k.jsx(EZ,{...t,ref:e})})}));J8.displayName=Iu;var EZ=j.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,orientation:i,loop:r=!1,dir:s,currentTabStopId:o,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:u,onEntryFocus:h,preventScrollOnEntryFocus:d=!1,...m}=t,g=j.useRef(null),y=Rd(e,g),x=W8(s),[w,S]=X8({prop:o,defaultProp:c??null,onChange:u,caller:Iu}),[C,A]=j.useState(!1),O=vZ(h),E=K8(n),T=j.useRef(!1),[M,R]=j.useState(0);return j.useEffect(()=>{const z=g.current;if(z)return z.addEventListener(Z1,O),()=>z.removeEventListener(Z1,O)},[O]),k.jsx(_Z,{scope:n,orientation:i,dir:x,loop:r,currentTabStopId:w,onItemFocus:j.useCallback(z=>S(z),[S]),onItemShiftTab:j.useCallback(()=>A(!0),[]),onFocusableItemAdd:j.useCallback(()=>R(z=>z+1),[]),onFocusableItemRemove:j.useCallback(()=>R(z=>z-1),[]),children:k.jsx(_l.div,{tabIndex:C||M===0?-1:0,"data-orientation":i,...m,ref:y,style:{outline:"none",...t.style},onMouseDown:Gr(t.onMouseDown,()=>{T.current=!0}),onFocus:Gr(t.onFocus,z=>{const q=!T.current;if(z.target===z.currentTarget&&q&&!C){const U=new CustomEvent(Z1,CZ);if(z.currentTarget.dispatchEvent(U),!U.defaultPrevented){const P=E().filter(D=>D.focusable),$=P.find(D=>D.active),K=P.find(D=>D.id===w),Y=[$,K,...P].filter(Boolean).map(D=>D.ref.current);nB(Y,d)}}T.current=!1}),onBlur:Gr(t.onBlur,()=>A(!1))})})}),eB="RovingFocusGroupItem",tB=j.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,focusable:i=!0,active:r=!1,tabStopId:s,children:o,...c}=t,u=Q8(),h=s||u,d=OZ(eB,n),m=d.currentTabStopId===h,g=K8(n),{onFocusableItemAdd:y,onFocusableItemRemove:x,currentTabStopId:w}=d;return j.useEffect(()=>{if(i)return y(),()=>x()},[i,y,x]),k.jsx(sS.ItemSlot,{scope:n,id:h,focusable:i,active:r,children:k.jsx(_l.span,{tabIndex:m?0:-1,"data-orientation":d.orientation,...c,ref:e,onMouseDown:Gr(t.onMouseDown,S=>{i?d.onItemFocus(h):S.preventDefault()}),onFocus:Gr(t.onFocus,()=>d.onItemFocus(h)),onKeyDown:Gr(t.onKeyDown,S=>{if(S.key==="Tab"&&S.shiftKey){d.onItemShiftTab();return}if(S.target!==S.currentTarget)return;const C=RZ(S,d.orientation,d.dir);if(C!==void 0){if(S.metaKey||S.ctrlKey||S.altKey||S.shiftKey)return;S.preventDefault();let O=g().filter(E=>E.focusable).map(E=>E.ref.current);if(C==="last")O.reverse();else if(C==="prev"||C==="next"){C==="prev"&&O.reverse();const E=O.indexOf(S.currentTarget);O=d.loop?NZ(O,E+1):O.slice(E+1)}setTimeout(()=>nB(O))}}),children:typeof o=="function"?o({isCurrentTabStop:m,hasTabStop:w!=null}):o})})});tB.displayName=eB;var TZ={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function MZ(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function RZ(t,e,n){const i=MZ(t.key,n);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(i))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(i)))return TZ[i]}function nB(t,e=!1){const n=document.activeElement;for(const i of t)if(i===n||(i.focus({preventScroll:e}),document.activeElement!==n))return}function NZ(t,e){return t.map((n,i)=>t[(e+i)%t.length])}var DZ=J8,LZ=tB;function zZ(t,e){return j.useReducer((n,i)=>e[n][i]??n,t)}var iB=t=>{const{present:e,children:n}=t,i=BZ(e),r=typeof n=="function"?n({present:i.isPresent}):j.Children.only(n),s=Rd(i.ref,qZ(r));return typeof n=="function"||i.isPresent?j.cloneElement(r,{ref:s}):null};iB.displayName="Presence";function BZ(t){const[e,n]=j.useState(),i=j.useRef(null),r=j.useRef(t),s=j.useRef("none"),o=t?"mounted":"unmounted",[c,u]=zZ(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return j.useEffect(()=>{const h=Th(i.current);s.current=c==="mounted"?h:"none"},[c]),Nd(()=>{const h=i.current,d=r.current;if(d!==t){const g=s.current,y=Th(h);t?u("MOUNT"):y==="none"||h?.display==="none"?u("UNMOUNT"):u(d&&g!==y?"ANIMATION_OUT":"UNMOUNT"),r.current=t}},[t,u]),Nd(()=>{if(e){let h;const d=e.ownerDocument.defaultView??window,m=y=>{const w=Th(i.current).includes(CSS.escape(y.animationName));if(y.target===e&&w&&(u("ANIMATION_END"),!r.current)){const S=e.style.animationFillMode;e.style.animationFillMode="forwards",h=d.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=S)})}},g=y=>{y.target===e&&(s.current=Th(i.current))};return e.addEventListener("animationstart",g),e.addEventListener("animationcancel",m),e.addEventListener("animationend",m),()=>{d.clearTimeout(h),e.removeEventListener("animationstart",g),e.removeEventListener("animationcancel",m),e.removeEventListener("animationend",m)}}else u("ANIMATION_END")},[e,u]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:j.useCallback(h=>{i.current=h?getComputedStyle(h):null,n(h)},[])}}function Th(t){return t?.animationName||"none"}function qZ(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var Lp="Tabs",[jZ]=K2(Lp,[Z8]),rB=Z8(),[IZ,J2]=jZ(Lp),sB=j.forwardRef((t,e)=>{const{__scopeTabs:n,value:i,onValueChange:r,defaultValue:s,orientation:o="horizontal",dir:c,activationMode:u="automatic",...h}=t,d=W8(c),[m,g]=X8({prop:i,onChange:r,defaultProp:s??"",caller:Lp});return k.jsx(IZ,{scope:n,baseId:Q8(),value:m,onValueChange:g,orientation:o,dir:d,activationMode:u,children:k.jsx(_l.div,{dir:d,"data-orientation":o,...h,ref:e})})});sB.displayName=Lp;var aB="TabsList",oB=j.forwardRef((t,e)=>{const{__scopeTabs:n,loop:i=!0,...r}=t,s=J2(aB,n),o=rB(n);return k.jsx(DZ,{asChild:!0,...o,orientation:s.orientation,dir:s.dir,loop:i,children:k.jsx(_l.div,{role:"tablist","aria-orientation":s.orientation,...r,ref:e})})});oB.displayName=aB;var lB="TabsTrigger",cB=j.forwardRef((t,e)=>{const{__scopeTabs:n,value:i,disabled:r=!1,...s}=t,o=J2(lB,n),c=rB(n),u=hB(o.baseId,i),h=dB(o.baseId,i),d=i===o.value;return k.jsx(LZ,{asChild:!0,...c,focusable:!r,active:d,children:k.jsx(_l.button,{type:"button",role:"tab","aria-selected":d,"aria-controls":h,"data-state":d?"active":"inactive","data-disabled":r?"":void 0,disabled:r,id:u,...s,ref:e,onMouseDown:Gr(t.onMouseDown,m=>{!r&&m.button===0&&m.ctrlKey===!1?o.onValueChange(i):m.preventDefault()}),onKeyDown:Gr(t.onKeyDown,m=>{[" ","Enter"].includes(m.key)&&o.onValueChange(i)}),onFocus:Gr(t.onFocus,()=>{const m=o.activationMode!=="manual";!d&&!r&&m&&o.onValueChange(i)})})})});cB.displayName=lB;var uB="TabsContent",fB=j.forwardRef((t,e)=>{const{__scopeTabs:n,value:i,forceMount:r,children:s,...o}=t,c=J2(uB,n),u=hB(c.baseId,i),h=dB(c.baseId,i),d=i===c.value,m=j.useRef(d);return j.useEffect(()=>{const g=requestAnimationFrame(()=>m.current=!1);return()=>cancelAnimationFrame(g)},[]),k.jsx(iB,{present:r||d,children:({present:g})=>k.jsx(_l.div,{"data-state":d?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":u,hidden:!g,id:h,tabIndex:0,...o,ref:e,style:{...t.style,animationDuration:m.current?"0s":void 0},children:g&&s})})});fB.displayName=uB;function hB(t,e){return`${t}-trigger-${e}`}function dB(t,e){return`${t}-content-${e}`}var PZ=sB,pB=oB,mB=cB,gB=fB;function yB(t){var e,n,i="";if(typeof t=="string"||typeof t=="number")i+=t;else if(typeof t=="object")if(Array.isArray(t)){var r=t.length;for(e=0;e<r;e++)t[e]&&(n=yB(t[e]))&&(i&&(i+=" "),i+=n)}else for(n in t)t[n]&&(i&&(i+=" "),i+=n);return i}function HZ(){for(var t,e,n=0,i="",r=arguments.length;n<r;n++)(t=arguments[n])&&(e=yB(t))&&(i&&(i+=" "),i+=e);return i}const UZ=(t,e)=>{const n=new Array(t.length+e.length);for(let i=0;i<t.length;i++)n[i]=t[i];for(let i=0;i<e.length;i++)n[t.length+i]=e[i];return n},VZ=(t,e)=>({classGroupId:t,validator:e}),vB=(t=new Map,e=null,n)=>({nextPart:t,validators:e,classGroupId:n}),Dd="-",S3=[],FZ="arbitrary..",$Z=t=>{const e=YZ(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:i}=t;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return GZ(o);const c=o.split(Dd),u=c[0]===""&&c.length>1?1:0;return bB(c,u,e)},getConflictingClassGroupIds:(o,c)=>{if(c){const u=i[o],h=n[o];return u?h?UZ(h,u):u:h||S3}return n[o]||S3}}},bB=(t,e,n)=>{if(t.length-e===0)return n.classGroupId;const r=t[e],s=n.nextPart.get(r);if(s){const h=bB(t,e+1,s);if(h)return h}const o=n.validators;if(o===null)return;const c=e===0?t.join(Dd):t.slice(e).join(Dd),u=o.length;for(let h=0;h<u;h++){const d=o[h];if(d.validator(c))return d.classGroupId}},GZ=t=>t.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const e=t.slice(1,-1),n=e.indexOf(":"),i=e.slice(0,n);return i?FZ+i:void 0})(),YZ=t=>{const{theme:e,classGroups:n}=t;return QZ(n,e)},QZ=(t,e)=>{const n=vB();for(const i in t){const r=t[i];eC(r,n,i,e)}return n},eC=(t,e,n,i)=>{const r=t.length;for(let s=0;s<r;s++){const o=t[s];XZ(o,e,n,i)}},XZ=(t,e,n,i)=>{if(typeof t=="string"){WZ(t,e,n);return}if(typeof t=="function"){KZ(t,e,n,i);return}ZZ(t,e,n,i)},WZ=(t,e,n)=>{const i=t===""?e:xB(e,t);i.classGroupId=n},KZ=(t,e,n,i)=>{if(JZ(t)){eC(t(i),e,n,i);return}e.validators===null&&(e.validators=[]),e.validators.push(VZ(n,t))},ZZ=(t,e,n,i)=>{const r=Object.entries(t),s=r.length;for(let o=0;o<s;o++){const[c,u]=r[o];eC(u,xB(e,c),n,i)}},xB=(t,e)=>{let n=t;const i=e.split(Dd),r=i.length;for(let s=0;s<r;s++){const o=i[s];let c=n.nextPart.get(o);c||(c=vB(),n.nextPart.set(o,c)),n=c}return n},JZ=t=>"isThemeGetter"in t&&t.isThemeGetter===!0,eJ=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,n=Object.create(null),i=Object.create(null);const r=(s,o)=>{n[s]=o,e++,e>t&&(e=0,i=n,n=Object.create(null))};return{get(s){let o=n[s];if(o!==void 0)return o;if((o=i[s])!==void 0)return r(s,o),o},set(s,o){s in n?n[s]=o:r(s,o)}}},aS="!",C3=":",tJ=[],k3=(t,e,n,i,r)=>({modifiers:t,hasImportantModifier:e,baseClassName:n,maybePostfixModifierPosition:i,isExternal:r}),nJ=t=>{const{prefix:e,experimentalParseClassName:n}=t;let i=r=>{const s=[];let o=0,c=0,u=0,h;const d=r.length;for(let w=0;w<d;w++){const S=r[w];if(o===0&&c===0){if(S===C3){s.push(r.slice(u,w)),u=w+1;continue}if(S==="/"){h=w;continue}}S==="["?o++:S==="]"?o--:S==="("?c++:S===")"&&c--}const m=s.length===0?r:r.slice(u);let g=m,y=!1;m.endsWith(aS)?(g=m.slice(0,-1),y=!0):m.startsWith(aS)&&(g=m.slice(1),y=!0);const x=h&&h>u?h-u:void 0;return k3(s,y,g,x)};if(e){const r=e+C3,s=i;i=o=>o.startsWith(r)?s(o.slice(r.length)):k3(tJ,!1,o,void 0,!0)}if(n){const r=i;i=s=>n({className:s,parseClassName:r})}return i},iJ=t=>{const e=new Map;return t.orderSensitiveModifiers.forEach((n,i)=>{e.set(n,1e6+i)}),n=>{const i=[];let r=[];for(let s=0;s<n.length;s++){const o=n[s],c=o[0]==="[",u=e.has(o);c||u?(r.length>0&&(r.sort(),i.push(...r),r=[]),i.push(o)):r.push(o)}return r.length>0&&(r.sort(),i.push(...r)),i}},rJ=t=>({cache:eJ(t.cacheSize),parseClassName:nJ(t),sortModifiers:iJ(t),...$Z(t)}),sJ=/\s+/,aJ=(t,e)=>{const{parseClassName:n,getClassGroupId:i,getConflictingClassGroupIds:r,sortModifiers:s}=e,o=[],c=t.trim().split(sJ);let u="";for(let h=c.length-1;h>=0;h-=1){const d=c[h],{isExternal:m,modifiers:g,hasImportantModifier:y,baseClassName:x,maybePostfixModifierPosition:w}=n(d);if(m){u=d+(u.length>0?" "+u:u);continue}let S=!!w,C=i(S?x.substring(0,w):x);if(!C){if(!S){u=d+(u.length>0?" "+u:u);continue}if(C=i(x),!C){u=d+(u.length>0?" "+u:u);continue}S=!1}const A=g.length===0?"":g.length===1?g[0]:s(g).join(":"),O=y?A+aS:A,E=O+C;if(o.indexOf(E)>-1)continue;o.push(E);const T=r(C,S);for(let M=0;M<T.length;++M){const R=T[M];o.push(O+R)}u=d+(u.length>0?" "+u:u)}return u},oJ=(...t)=>{let e=0,n,i,r="";for(;e<t.length;)(n=t[e++])&&(i=wB(n))&&(r&&(r+=" "),r+=i);return r},wB=t=>{if(typeof t=="string")return t;let e,n="";for(let i=0;i<t.length;i++)t[i]&&(e=wB(t[i]))&&(n&&(n+=" "),n+=e);return n},lJ=(t,...e)=>{let n,i,r,s;const o=u=>{const h=e.reduce((d,m)=>m(d),t());return n=rJ(h),i=n.cache.get,r=n.cache.set,s=c,c(u)},c=u=>{const h=i(u);if(h)return h;const d=aJ(u,n);return r(u,d),d};return s=o,(...u)=>s(oJ(...u))},cJ=[],Jt=t=>{const e=n=>n[t]||cJ;return e.isThemeGetter=!0,e},SB=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,CB=/^\((?:(\w[\w-]*):)?(.+)\)$/i,uJ=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,fJ=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,hJ=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,dJ=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,pJ=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,mJ=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Ms=t=>uJ.test(t),Ue=t=>!!t&&!Number.isNaN(Number(t)),Rs=t=>!!t&&Number.isInteger(Number(t)),J1=t=>t.endsWith("%")&&Ue(t.slice(0,-1)),Hr=t=>fJ.test(t),kB=()=>!0,gJ=t=>hJ.test(t)&&!dJ.test(t),tC=()=>!1,yJ=t=>pJ.test(t),vJ=t=>mJ.test(t),bJ=t=>!Ee(t)&&!Me(t),xJ=t=>ea(t,OB,tC),Ee=t=>SB.test(t),Ca=t=>ea(t,EB,gJ),A3=t=>ea(t,EJ,Ue),wJ=t=>ea(t,MB,kB),SJ=t=>ea(t,TB,tC),_3=t=>ea(t,AB,tC),CJ=t=>ea(t,_B,vJ),Mh=t=>ea(t,RB,yJ),Me=t=>CB.test(t),Mc=t=>Ka(t,EB),kJ=t=>Ka(t,TB),O3=t=>Ka(t,AB),AJ=t=>Ka(t,OB),_J=t=>Ka(t,_B),Rh=t=>Ka(t,RB,!0),OJ=t=>Ka(t,MB,!0),ea=(t,e,n)=>{const i=SB.exec(t);return i?i[1]?e(i[1]):n(i[2]):!1},Ka=(t,e,n=!1)=>{const i=CB.exec(t);return i?i[1]?e(i[1]):n:!1},AB=t=>t==="position"||t==="percentage",_B=t=>t==="image"||t==="url",OB=t=>t==="length"||t==="size"||t==="bg-size",EB=t=>t==="length",EJ=t=>t==="number",TB=t=>t==="family-name",MB=t=>t==="number"||t==="weight",RB=t=>t==="shadow",TJ=()=>{const t=Jt("color"),e=Jt("font"),n=Jt("text"),i=Jt("font-weight"),r=Jt("tracking"),s=Jt("leading"),o=Jt("breakpoint"),c=Jt("container"),u=Jt("spacing"),h=Jt("radius"),d=Jt("shadow"),m=Jt("inset-shadow"),g=Jt("text-shadow"),y=Jt("drop-shadow"),x=Jt("blur"),w=Jt("perspective"),S=Jt("aspect"),C=Jt("ease"),A=Jt("animate"),O=()=>["auto","avoid","all","avoid-page","page","left","right","column"],E=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],T=()=>[...E(),Me,Ee],M=()=>["auto","hidden","clip","visible","scroll"],R=()=>["auto","contain","none"],z=()=>[Me,Ee,u],q=()=>[Ms,"full","auto",...z()],U=()=>[Rs,"none","subgrid",Me,Ee],P=()=>["auto",{span:["full",Rs,Me,Ee]},Rs,Me,Ee],$=()=>[Rs,"auto",Me,Ee],K=()=>["auto","min","max","fr",Me,Ee],L=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],Y=()=>["start","end","center","stretch","center-safe","end-safe"],D=()=>["auto",...z()],Q=()=>[Ms,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...z()],ee=()=>[Ms,"screen","full","dvw","lvw","svw","min","max","fit",...z()],G=()=>[Ms,"screen","full","lh","dvh","lvh","svh","min","max","fit",...z()],W=()=>[t,Me,Ee],B=()=>[...E(),O3,_3,{position:[Me,Ee]}],F=()=>["no-repeat",{repeat:["","x","y","space","round"]}],ne=()=>["auto","cover","contain",AJ,xJ,{size:[Me,Ee]}],I=()=>[J1,Mc,Ca],X=()=>["","none","full",h,Me,Ee],J=()=>["",Ue,Mc,Ca],oe=()=>["solid","dashed","dotted","double"],ve=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],H=()=>[Ue,J1,O3,_3],pe=()=>["","none",x,Me,Ee],me=()=>["none",Ue,Me,Ee],ye=()=>["none",Ue,Me,Ee],_e=()=>[Ue,Me,Ee],Ae=()=>[Ms,"full",...z()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Hr],breakpoint:[Hr],color:[kB],container:[Hr],"drop-shadow":[Hr],ease:["in","out","in-out"],font:[bJ],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Hr],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Hr],shadow:[Hr],spacing:["px",Ue],text:[Hr],"text-shadow":[Hr],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Ms,Ee,Me,S]}],container:["container"],columns:[{columns:[Ue,Ee,Me,c]}],"break-after":[{"break-after":O()}],"break-before":[{"break-before":O()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:T()}],overflow:[{overflow:M()}],"overflow-x":[{"overflow-x":M()}],"overflow-y":[{"overflow-y":M()}],overscroll:[{overscroll:R()}],"overscroll-x":[{"overscroll-x":R()}],"overscroll-y":[{"overscroll-y":R()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:q()}],"inset-x":[{"inset-x":q()}],"inset-y":[{"inset-y":q()}],start:[{"inset-s":q(),start:q()}],end:[{"inset-e":q(),end:q()}],"inset-bs":[{"inset-bs":q()}],"inset-be":[{"inset-be":q()}],top:[{top:q()}],right:[{right:q()}],bottom:[{bottom:q()}],left:[{left:q()}],visibility:["visible","invisible","collapse"],z:[{z:[Rs,"auto",Me,Ee]}],basis:[{basis:[Ms,"full","auto",c,...z()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Ue,Ms,"auto","initial","none",Ee]}],grow:[{grow:["",Ue,Me,Ee]}],shrink:[{shrink:["",Ue,Me,Ee]}],order:[{order:[Rs,"first","last","none",Me,Ee]}],"grid-cols":[{"grid-cols":U()}],"col-start-end":[{col:P()}],"col-start":[{"col-start":$()}],"col-end":[{"col-end":$()}],"grid-rows":[{"grid-rows":U()}],"row-start-end":[{row:P()}],"row-start":[{"row-start":$()}],"row-end":[{"row-end":$()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":K()}],"auto-rows":[{"auto-rows":K()}],gap:[{gap:z()}],"gap-x":[{"gap-x":z()}],"gap-y":[{"gap-y":z()}],"justify-content":[{justify:[...L(),"normal"]}],"justify-items":[{"justify-items":[...Y(),"normal"]}],"justify-self":[{"justify-self":["auto",...Y()]}],"align-content":[{content:["normal",...L()]}],"align-items":[{items:[...Y(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...Y(),{baseline:["","last"]}]}],"place-content":[{"place-content":L()}],"place-items":[{"place-items":[...Y(),"baseline"]}],"place-self":[{"place-self":["auto",...Y()]}],p:[{p:z()}],px:[{px:z()}],py:[{py:z()}],ps:[{ps:z()}],pe:[{pe:z()}],pbs:[{pbs:z()}],pbe:[{pbe:z()}],pt:[{pt:z()}],pr:[{pr:z()}],pb:[{pb:z()}],pl:[{pl:z()}],m:[{m:D()}],mx:[{mx:D()}],my:[{my:D()}],ms:[{ms:D()}],me:[{me:D()}],mbs:[{mbs:D()}],mbe:[{mbe:D()}],mt:[{mt:D()}],mr:[{mr:D()}],mb:[{mb:D()}],ml:[{ml:D()}],"space-x":[{"space-x":z()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":z()}],"space-y-reverse":["space-y-reverse"],size:[{size:Q()}],"inline-size":[{inline:["auto",...ee()]}],"min-inline-size":[{"min-inline":["auto",...ee()]}],"max-inline-size":[{"max-inline":["none",...ee()]}],"block-size":[{block:["auto",...G()]}],"min-block-size":[{"min-block":["auto",...G()]}],"max-block-size":[{"max-block":["none",...G()]}],w:[{w:[c,"screen",...Q()]}],"min-w":[{"min-w":[c,"screen","none",...Q()]}],"max-w":[{"max-w":[c,"screen","none","prose",{screen:[o]},...Q()]}],h:[{h:["screen","lh",...Q()]}],"min-h":[{"min-h":["screen","lh","none",...Q()]}],"max-h":[{"max-h":["screen","lh",...Q()]}],"font-size":[{text:["base",n,Mc,Ca]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[i,OJ,wJ]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",J1,Ee]}],"font-family":[{font:[kJ,SJ,e]}],"font-features":[{"font-features":[Ee]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[r,Me,Ee]}],"line-clamp":[{"line-clamp":[Ue,"none",Me,A3]}],leading:[{leading:[s,...z()]}],"list-image":[{"list-image":["none",Me,Ee]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Me,Ee]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:W()}],"text-color":[{text:W()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...oe(),"wavy"]}],"text-decoration-thickness":[{decoration:[Ue,"from-font","auto",Me,Ca]}],"text-decoration-color":[{decoration:W()}],"underline-offset":[{"underline-offset":[Ue,"auto",Me,Ee]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:z()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Me,Ee]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Me,Ee]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:B()}],"bg-repeat":[{bg:F()}],"bg-size":[{bg:ne()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Rs,Me,Ee],radial:["",Me,Ee],conic:[Rs,Me,Ee]},_J,CJ]}],"bg-color":[{bg:W()}],"gradient-from-pos":[{from:I()}],"gradient-via-pos":[{via:I()}],"gradient-to-pos":[{to:I()}],"gradient-from":[{from:W()}],"gradient-via":[{via:W()}],"gradient-to":[{to:W()}],rounded:[{rounded:X()}],"rounded-s":[{"rounded-s":X()}],"rounded-e":[{"rounded-e":X()}],"rounded-t":[{"rounded-t":X()}],"rounded-r":[{"rounded-r":X()}],"rounded-b":[{"rounded-b":X()}],"rounded-l":[{"rounded-l":X()}],"rounded-ss":[{"rounded-ss":X()}],"rounded-se":[{"rounded-se":X()}],"rounded-ee":[{"rounded-ee":X()}],"rounded-es":[{"rounded-es":X()}],"rounded-tl":[{"rounded-tl":X()}],"rounded-tr":[{"rounded-tr":X()}],"rounded-br":[{"rounded-br":X()}],"rounded-bl":[{"rounded-bl":X()}],"border-w":[{border:J()}],"border-w-x":[{"border-x":J()}],"border-w-y":[{"border-y":J()}],"border-w-s":[{"border-s":J()}],"border-w-e":[{"border-e":J()}],"border-w-bs":[{"border-bs":J()}],"border-w-be":[{"border-be":J()}],"border-w-t":[{"border-t":J()}],"border-w-r":[{"border-r":J()}],"border-w-b":[{"border-b":J()}],"border-w-l":[{"border-l":J()}],"divide-x":[{"divide-x":J()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":J()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...oe(),"hidden","none"]}],"divide-style":[{divide:[...oe(),"hidden","none"]}],"border-color":[{border:W()}],"border-color-x":[{"border-x":W()}],"border-color-y":[{"border-y":W()}],"border-color-s":[{"border-s":W()}],"border-color-e":[{"border-e":W()}],"border-color-bs":[{"border-bs":W()}],"border-color-be":[{"border-be":W()}],"border-color-t":[{"border-t":W()}],"border-color-r":[{"border-r":W()}],"border-color-b":[{"border-b":W()}],"border-color-l":[{"border-l":W()}],"divide-color":[{divide:W()}],"outline-style":[{outline:[...oe(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Ue,Me,Ee]}],"outline-w":[{outline:["",Ue,Mc,Ca]}],"outline-color":[{outline:W()}],shadow:[{shadow:["","none",d,Rh,Mh]}],"shadow-color":[{shadow:W()}],"inset-shadow":[{"inset-shadow":["none",m,Rh,Mh]}],"inset-shadow-color":[{"inset-shadow":W()}],"ring-w":[{ring:J()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:W()}],"ring-offset-w":[{"ring-offset":[Ue,Ca]}],"ring-offset-color":[{"ring-offset":W()}],"inset-ring-w":[{"inset-ring":J()}],"inset-ring-color":[{"inset-ring":W()}],"text-shadow":[{"text-shadow":["none",g,Rh,Mh]}],"text-shadow-color":[{"text-shadow":W()}],opacity:[{opacity:[Ue,Me,Ee]}],"mix-blend":[{"mix-blend":[...ve(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":ve()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Ue]}],"mask-image-linear-from-pos":[{"mask-linear-from":H()}],"mask-image-linear-to-pos":[{"mask-linear-to":H()}],"mask-image-linear-from-color":[{"mask-linear-from":W()}],"mask-image-linear-to-color":[{"mask-linear-to":W()}],"mask-image-t-from-pos":[{"mask-t-from":H()}],"mask-image-t-to-pos":[{"mask-t-to":H()}],"mask-image-t-from-color":[{"mask-t-from":W()}],"mask-image-t-to-color":[{"mask-t-to":W()}],"mask-image-r-from-pos":[{"mask-r-from":H()}],"mask-image-r-to-pos":[{"mask-r-to":H()}],"mask-image-r-from-color":[{"mask-r-from":W()}],"mask-image-r-to-color":[{"mask-r-to":W()}],"mask-image-b-from-pos":[{"mask-b-from":H()}],"mask-image-b-to-pos":[{"mask-b-to":H()}],"mask-image-b-from-color":[{"mask-b-from":W()}],"mask-image-b-to-color":[{"mask-b-to":W()}],"mask-image-l-from-pos":[{"mask-l-from":H()}],"mask-image-l-to-pos":[{"mask-l-to":H()}],"mask-image-l-from-color":[{"mask-l-from":W()}],"mask-image-l-to-color":[{"mask-l-to":W()}],"mask-image-x-from-pos":[{"mask-x-from":H()}],"mask-image-x-to-pos":[{"mask-x-to":H()}],"mask-image-x-from-color":[{"mask-x-from":W()}],"mask-image-x-to-color":[{"mask-x-to":W()}],"mask-image-y-from-pos":[{"mask-y-from":H()}],"mask-image-y-to-pos":[{"mask-y-to":H()}],"mask-image-y-from-color":[{"mask-y-from":W()}],"mask-image-y-to-color":[{"mask-y-to":W()}],"mask-image-radial":[{"mask-radial":[Me,Ee]}],"mask-image-radial-from-pos":[{"mask-radial-from":H()}],"mask-image-radial-to-pos":[{"mask-radial-to":H()}],"mask-image-radial-from-color":[{"mask-radial-from":W()}],"mask-image-radial-to-color":[{"mask-radial-to":W()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":E()}],"mask-image-conic-pos":[{"mask-conic":[Ue]}],"mask-image-conic-from-pos":[{"mask-conic-from":H()}],"mask-image-conic-to-pos":[{"mask-conic-to":H()}],"mask-image-conic-from-color":[{"mask-conic-from":W()}],"mask-image-conic-to-color":[{"mask-conic-to":W()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:B()}],"mask-repeat":[{mask:F()}],"mask-size":[{mask:ne()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Me,Ee]}],filter:[{filter:["","none",Me,Ee]}],blur:[{blur:pe()}],brightness:[{brightness:[Ue,Me,Ee]}],contrast:[{contrast:[Ue,Me,Ee]}],"drop-shadow":[{"drop-shadow":["","none",y,Rh,Mh]}],"drop-shadow-color":[{"drop-shadow":W()}],grayscale:[{grayscale:["",Ue,Me,Ee]}],"hue-rotate":[{"hue-rotate":[Ue,Me,Ee]}],invert:[{invert:["",Ue,Me,Ee]}],saturate:[{saturate:[Ue,Me,Ee]}],sepia:[{sepia:["",Ue,Me,Ee]}],"backdrop-filter":[{"backdrop-filter":["","none",Me,Ee]}],"backdrop-blur":[{"backdrop-blur":pe()}],"backdrop-brightness":[{"backdrop-brightness":[Ue,Me,Ee]}],"backdrop-contrast":[{"backdrop-contrast":[Ue,Me,Ee]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Ue,Me,Ee]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Ue,Me,Ee]}],"backdrop-invert":[{"backdrop-invert":["",Ue,Me,Ee]}],"backdrop-opacity":[{"backdrop-opacity":[Ue,Me,Ee]}],"backdrop-saturate":[{"backdrop-saturate":[Ue,Me,Ee]}],"backdrop-sepia":[{"backdrop-sepia":["",Ue,Me,Ee]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":z()}],"border-spacing-x":[{"border-spacing-x":z()}],"border-spacing-y":[{"border-spacing-y":z()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Me,Ee]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Ue,"initial",Me,Ee]}],ease:[{ease:["linear","initial",C,Me,Ee]}],delay:[{delay:[Ue,Me,Ee]}],animate:[{animate:["none",A,Me,Ee]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[w,Me,Ee]}],"perspective-origin":[{"perspective-origin":T()}],rotate:[{rotate:me()}],"rotate-x":[{"rotate-x":me()}],"rotate-y":[{"rotate-y":me()}],"rotate-z":[{"rotate-z":me()}],scale:[{scale:ye()}],"scale-x":[{"scale-x":ye()}],"scale-y":[{"scale-y":ye()}],"scale-z":[{"scale-z":ye()}],"scale-3d":["scale-3d"],skew:[{skew:_e()}],"skew-x":[{"skew-x":_e()}],"skew-y":[{"skew-y":_e()}],transform:[{transform:[Me,Ee,"","none","gpu","cpu"]}],"transform-origin":[{origin:T()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Ae()}],"translate-x":[{"translate-x":Ae()}],"translate-y":[{"translate-y":Ae()}],"translate-z":[{"translate-z":Ae()}],"translate-none":["translate-none"],accent:[{accent:W()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:W()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Me,Ee]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":z()}],"scroll-mx":[{"scroll-mx":z()}],"scroll-my":[{"scroll-my":z()}],"scroll-ms":[{"scroll-ms":z()}],"scroll-me":[{"scroll-me":z()}],"scroll-mbs":[{"scroll-mbs":z()}],"scroll-mbe":[{"scroll-mbe":z()}],"scroll-mt":[{"scroll-mt":z()}],"scroll-mr":[{"scroll-mr":z()}],"scroll-mb":[{"scroll-mb":z()}],"scroll-ml":[{"scroll-ml":z()}],"scroll-p":[{"scroll-p":z()}],"scroll-px":[{"scroll-px":z()}],"scroll-py":[{"scroll-py":z()}],"scroll-ps":[{"scroll-ps":z()}],"scroll-pe":[{"scroll-pe":z()}],"scroll-pbs":[{"scroll-pbs":z()}],"scroll-pbe":[{"scroll-pbe":z()}],"scroll-pt":[{"scroll-pt":z()}],"scroll-pr":[{"scroll-pr":z()}],"scroll-pb":[{"scroll-pb":z()}],"scroll-pl":[{"scroll-pl":z()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Me,Ee]}],fill:[{fill:["none",...W()]}],"stroke-w":[{stroke:[Ue,Mc,Ca,A3]}],stroke:[{stroke:["none",...W()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},MJ=lJ(TJ);function nC(...t){return MJ(HZ(t))}const RJ=PZ,NB=j.forwardRef(({className:t,...e},n)=>k.jsx(pB,{ref:n,className:nC("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",t),...e}));NB.displayName=pB.displayName;const oS=j.forwardRef(({className:t,...e},n)=>k.jsx(mB,{ref:n,className:nC("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",t),...e}));oS.displayName=mB.displayName;const lS=j.forwardRef(({className:t,...e},n)=>k.jsx(gB,{ref:n,className:nC("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...e}));lS.displayName=gB.displayName;function cS(){return cS=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)({}).hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},cS.apply(null,arguments)}function NJ(t,e){if(t==null)return{};var n={};for(var i in t)if({}.hasOwnProperty.call(t,i)){if(e.indexOf(i)!==-1)continue;n[i]=t[i]}return n}let uS=[],DB=[];(()=>{let t="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 e=0,n=0;e<t.length;e++)(e%2?DB:uS).push(n=n+t[e])})();function DJ(t){if(t<768)return!1;for(let e=0,n=uS.length;;){let i=e+n>>1;if(t<uS[i])n=i;else if(t>=DB[i])e=i+1;else return!0;if(e==n)return!1}}function E3(t){return t>=127462&&t<=127487}const T3=8205;function LJ(t,e,n=!0,i=!0){return(n?LB:zJ)(t,e,i)}function LB(t,e,n){if(e==t.length)return e;e&&zB(t.charCodeAt(e))&&BB(t.charCodeAt(e-1))&&e--;let i=ew(t,e);for(e+=M3(i);e<t.length;){let r=ew(t,e);if(i==T3||r==T3||n&&DJ(r))e+=M3(r),i=r;else if(E3(r)){let s=0,o=e-2;for(;o>=0&&E3(ew(t,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function zJ(t,e,n){for(;e>0;){let i=LB(t,e-2,n);if(i<e)return i;e--}return 0}function ew(t,e){let n=t.charCodeAt(e);if(!BB(n)||e+1==t.length)return n;let i=t.charCodeAt(e+1);return zB(i)?(n-55296<<10)+(i-56320)+65536:n}function zB(t){return t>=56320&&t<57344}function BB(t){return t>=55296&&t<56320}function M3(t){return t<65536?1:2}class tt{lineAt(e){if(e<0||e>this.length)throw new 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 new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,n,i){[e,n]=pl(this,e,n);let r=[];return this.decompose(0,e,r,2),i.length&&i.decompose(0,i.length,r,3),this.decompose(n,this.length,r,1),nr.from(r,this.length-(n-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=pl(this,e,n);let i=[];return this.decompose(e,n,i,0),nr.from(i,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),r=new Gc(this),s=new Gc(e);for(let o=n,c=n;;){if(r.next(o),s.next(o),o=0,r.lineBreak!=s.lineBreak||r.done!=s.done||r.value!=s.value)return!1;if(c+=r.value.length,r.done||c>=i)return!0}}iter(e=1){return new Gc(this,e)}iterRange(e,n=this.length){return new qB(this,e,n)}iterLines(e,n){let i;if(e==null)i=this.iter();else{n==null&&(n=this.lines+1);let r=this.line(e).from;i=this.iterRange(r,Math.max(r,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new jB(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?tt.empty:e.length<=32?new jt(e):nr.from(jt.split(e,[]))}}class jt extends tt{constructor(e,n=BJ(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,i,r){for(let s=0;;s++){let o=this.text[s],c=r+o.length;if((n?i:c)>=e)return new qJ(r,c,i,o);r=c+1,i++}}decompose(e,n,i,r){let s=e<=0&&n>=this.length?this:new jt(R3(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(r&1){let o=i.pop(),c=ad(s.text,o.text.slice(),0,s.length);if(c.length<=32)i.push(new jt(c,o.length+s.length));else{let u=c.length>>1;i.push(new jt(c.slice(0,u)),new jt(c.slice(u)))}}else i.push(s)}replace(e,n,i){if(!(i instanceof jt))return super.replace(e,n,i);[e,n]=pl(this,e,n);let r=ad(this.text,ad(i.text,R3(this.text,0,e)),n),s=this.length+i.length-(n-e);return r.length<=32?new jt(r,s):nr.from(jt.split(r,[]),s)}sliceString(e,n=this.length,i=`
|
|
41
41
|
`){[e,n]=pl(this,e,n);let r="";for(let s=0,o=0;s<=n&&o<this.text.length;o++){let c=this.text[o],u=s+c.length;s>e&&o&&(r+=i),e<u&&n>s&&(r+=c.slice(Math.max(0,e-s),n-s)),s=u+1}return r}flatten(e){for(let n of this.text)e.push(n)}scanIdentical(){return 0}static split(e,n){let i=[],r=-1;for(let s of e)i.push(s),r+=s.length+1,i.length==32&&(n.push(new jt(i,r)),i=[],r=-1);return r>-1&&n.push(new jt(i,r)),n}}class nr extends tt{constructor(e,n){super(),this.children=e,this.length=n,this.lines=0;for(let i of e)this.lines+=i.lines}lineInner(e,n,i,r){for(let s=0;;s++){let o=this.children[s],c=r+o.length,u=i+o.lines-1;if((n?u:c)>=e)return o.lineInner(e,n,i,r);r=c+1,i=u+1}}decompose(e,n,i,r){for(let s=0,o=0;o<=n&&s<this.children.length;s++){let c=this.children[s],u=o+c.length;if(e<=u&&n>=o){let h=r&((o<=e?1:0)|(u>=n?2:0));o>=e&&u<=n&&!h?i.push(c):c.decompose(e-o,n-o,i,h)}o=u+1}}replace(e,n,i){if([e,n]=pl(this,e,n),i.lines<this.lines)for(let r=0,s=0;r<this.children.length;r++){let o=this.children[r],c=s+o.length;if(e>=s&&n<=c){let u=o.replace(e-s,n-s,i),h=this.lines-o.lines+u.lines;if(u.lines<h>>4&&u.lines>h>>6){let d=this.children.slice();return d[r]=u,new nr(d,this.length-(n-e)+i.length)}return super.replace(s,c,u)}s=c+1}return super.replace(e,n,i)}sliceString(e,n=this.length,i=`
|
|
42
42
|
`){[e,n]=pl(this,e,n);let r="";for(let s=0,o=0;s<this.children.length&&o<=n;s++){let c=this.children[s],u=o+c.length;o>e&&s&&(r+=i),e<u&&n>o&&(r+=c.sliceString(e-o,n-o,i)),o=u+1}return r}flatten(e){for(let n of this.children)n.flatten(e)}scanIdentical(e,n){if(!(e instanceof nr))return 0;let i=0,[r,s,o,c]=n>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;r+=n,s+=n){if(r==o||s==c)return i;let u=this.children[r],h=e.children[s];if(u!=h)return i+u.scanIdentical(h,n);i+=u.length+1}}static from(e,n=e.reduce((i,r)=>i+r.length+1,-1)){let i=0;for(let y of e)i+=y.lines;if(i<32){let y=[];for(let x of e)x.flatten(y);return new jt(y,n)}let r=Math.max(32,i>>5),s=r<<1,o=r>>1,c=[],u=0,h=-1,d=[];function m(y){let x;if(y.lines>s&&y instanceof nr)for(let w of y.children)m(w);else y.lines>o&&(u>o||!u)?(g(),c.push(y)):y instanceof jt&&u&&(x=d[d.length-1])instanceof jt&&y.lines+x.lines<=32?(u+=y.lines,h+=y.length+1,d[d.length-1]=new jt(x.text.concat(y.text),x.length+1+y.length)):(u+y.lines>r&&g(),u+=y.lines,h+=y.length+1,d.push(y))}function g(){u!=0&&(c.push(d.length==1?d[0]:nr.from(d,h)),h=-1,u=d.length=0)}for(let y of e)m(y);return g(),c.length==1?c[0]:new nr(c,n)}}tt.empty=new jt([""],0);function BJ(t){let e=-1;for(let n of t)e+=n.length+1;return e}function ad(t,e,n=0,i=1e9){for(let r=0,s=0,o=!0;s<t.length&&r<=i;s++){let c=t[s],u=r+c.length;u>=n&&(u>i&&(c=c.slice(0,i-r)),r<n&&(c=c.slice(n-r)),o?(e[e.length-1]+=c,o=!1):e.push(c)),r=u+1}return e}function R3(t,e,n){return ad(t,[""],e,n)}class Gc{constructor(e,n=1){this.dir=n,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[n>0?1:(e instanceof jt?e.text.length:e.children.length)<<1]}nextInner(e,n){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,r=this.nodes[i],s=this.offsets[i],o=s>>1,c=r instanceof jt?r.text.length:r.children.length;if(o==(n>0?c:0)){if(i==0)return this.done=!0,this.value="",this;n>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(n>0?0:1)){if(this.offsets[i]+=n,e==0)return this.lineBreak=!0,this.value=`
|
|
43
43
|
`,this;e--}else if(r instanceof jt){let u=r.text[o+(n<0?-1:0)];if(this.offsets[i]+=n,u.length>Math.max(0,e))return this.value=e==0?u:n>0?u.slice(e):u.slice(0,u.length-e),this;e-=u.length}else{let u=r.children[o+(n<0?-1:0)];e>u.length?(e-=u.length,this.offsets[i]+=n):(n<0&&this.offsets[i]--,this.nodes.push(u),this.offsets.push(n>0?1:(u instanceof jt?u.text.length:u.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class qB{constructor(e,n,i){this.value="",this.done=!1,this.cursor=new Gc(e,n>i?-1:1),this.pos=n>i?e.length:0,this.from=Math.min(n,i),this.to=Math.max(n,i)}nextInner(e,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let i=n<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*n,this.value=r.length<=i?r:n<0?r.slice(r.length-i):r.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class jB{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:n,lineBreak:i,value:r}=this.inner.next(e);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(tt.prototype[Symbol.iterator]=function(){return this.iter()},Gc.prototype[Symbol.iterator]=qB.prototype[Symbol.iterator]=jB.prototype[Symbol.iterator]=function(){return this});class qJ{constructor(e,n,i,r){this.from=e,this.to=n,this.number=i,this.text=r}get length(){return this.to-this.from}}function pl(t,e,n){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,n))]}function sn(t,e,n=!0,i=!0){return LJ(t,e,n,i)}function jJ(t){return t>=56320&&t<57344}function IJ(t){return t>=55296&&t<56320}function In(t,e){let n=t.charCodeAt(e);if(!IJ(n)||e+1==t.length)return n;let i=t.charCodeAt(e+1);return jJ(i)?(n-55296<<10)+(i-56320)+65536:n}function iC(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10)+55296,(t&1023)+56320))}function ir(t){return t<65536?1:2}const fS=/\r\n?|\n/;var Rn=(function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t})(Rn||(Rn={}));class ur{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;n<this.sections.length;n+=2)e+=this.sections[n];return e}get newLength(){let e=0;for(let n=0;n<this.sections.length;n+=2){let i=this.sections[n+1];e+=i<0?this.sections[n]:i}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let n=0,i=0,r=0;n<this.sections.length;){let s=this.sections[n++],o=this.sections[n++];o<0?(e(i,r,s),r+=s):r+=o,i+=s}}iterChangedRanges(e,n=!1){hS(this,e,n)}get invertedDesc(){let e=[];for(let n=0;n<this.sections.length;){let i=this.sections[n++],r=this.sections[n++];r<0?e.push(i,r):e.push(r,i)}return new ur(e)}composeDesc(e){return this.empty?e:e.empty?this:IB(this,e)}mapDesc(e,n=!1){return e.empty?this:dS(this,e,n)}mapPos(e,n=-1,i=Rn.Simple){let r=0,s=0;for(let o=0;o<this.sections.length;){let c=this.sections[o++],u=this.sections[o++],h=r+c;if(u<0){if(h>e)return s+(e-r);s+=c}else{if(i!=Rn.Simple&&h>=e&&(i==Rn.TrackDel&&r<e&&h>e||i==Rn.TrackBefore&&r<e||i==Rn.TrackAfter&&h>e))return null;if(h>e||h==e&&n<0&&!c)return e==r||n<0?s:s+u;s+=u}r=h}if(e>r)throw new RangeError(`Position ${e} is out of range for changeset of length ${r}`);return s}touchesRange(e,n=e){for(let i=0,r=0;i<this.sections.length&&r<=n;){let s=this.sections[i++],o=this.sections[i++],c=r+s;if(o>=0&&r<=n&&c>=e)return r<e&&c>n?"cover":!0;r=c}return!1}toString(){let e="";for(let n=0;n<this.sections.length;){let i=this.sections[n++],r=this.sections[n++];e+=(e?" ":"")+i+(r>=0?":"+r:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new ur(e)}static create(e){return new ur(e)}}class en extends ur{constructor(e,n){super(e),this.inserted=n}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return hS(this,(n,i,r,s,o)=>e=e.replace(r,r+(i-n),o),!1),e}mapDesc(e,n=!1){return dS(this,e,n,!0)}invert(e){let n=this.sections.slice(),i=[];for(let r=0,s=0;r<n.length;r+=2){let o=n[r],c=n[r+1];if(c>=0){n[r]=c,n[r+1]=o;let u=r>>1;for(;i.length<u;)i.push(tt.empty);i.push(o?e.slice(s,s+o):tt.empty)}s+=o}return new en(n,i)}compose(e){return this.empty?e:e.empty?this:IB(this,e,!0)}map(e,n=!1){return e.empty?this:dS(this,e,n,!0)}iterChanges(e,n=!1){hS(this,e,n)}get desc(){return ur.create(this.sections)}filter(e){let n=[],i=[],r=[],s=new hu(this);e:for(let o=0,c=0;;){let u=o==e.length?1e9:e[o++];for(;c<u||c==u&&s.len==0;){if(s.done)break e;let d=Math.min(s.len,u-c);Sn(r,d,-1);let m=s.ins==-1?-1:s.off==0?s.ins:0;Sn(n,d,m),m>0&&js(i,n,s.text),s.forward(d),c+=d}let h=e[o++];for(;c<h;){if(s.done)break e;let d=Math.min(s.len,h-c);Sn(n,d,-1),Sn(r,d,s.ins==-1?-1:s.off==0?s.ins:0),s.forward(d),c+=d}}return{changes:new en(n,i),filtered:ur.create(r)}}toJSON(){let e=[];for(let n=0;n<this.sections.length;n+=2){let i=this.sections[n],r=this.sections[n+1];r<0?e.push(i):r==0?e.push([i]):e.push([i].concat(this.inserted[n>>1].toJSON()))}return e}static of(e,n,i){let r=[],s=[],o=0,c=null;function u(d=!1){if(!d&&!r.length)return;o<n&&Sn(r,n-o,-1);let m=new en(r,s);c=c?c.compose(m.map(c)):m,r=[],s=[],o=0}function h(d){if(Array.isArray(d))for(let m of d)h(m);else if(d instanceof en){if(d.length!=n)throw new RangeError(`Mismatched change set length (got ${d.length}, expected ${n})`);u(),c=c?c.compose(d.map(c)):d}else{let{from:m,to:g=m,insert:y}=d;if(m>g||m<0||g>n)throw new RangeError(`Invalid change range ${m} to ${g} (in doc of length ${n})`);let x=y?typeof y=="string"?tt.of(y.split(i||fS)):y:tt.empty,w=x.length;if(m==g&&w==0)return;m<o&&u(),m>o&&Sn(r,m-o,-1),Sn(r,g-m,w),js(s,r,x),o=g}}return h(e),u(!c),c}static empty(e){return new en(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],i=[];for(let r=0;r<e.length;r++){let s=e[r];if(typeof s=="number")n.push(s,-1);else{if(!Array.isArray(s)||typeof s[0]!="number"||s.some((o,c)=>c&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)n.push(s[0],0);else{for(;i.length<r;)i.push(tt.empty);i[r]=tt.of(s.slice(1)),n.push(s[0],i[r].length)}}}return new en(n,i)}static createSet(e,n){return new en(e,n)}}function Sn(t,e,n,i=!1){if(e==0&&n<=0)return;let r=t.length-2;r>=0&&n<=0&&n==t[r+1]?t[r]+=e:r>=0&&e==0&&t[r]==0?t[r+1]+=n:i?(t[r]+=e,t[r+1]+=n):t.push(e,n)}function js(t,e,n){if(n.length==0)return;let i=e.length-2>>1;if(i<t.length)t[t.length-1]=t[t.length-1].append(n);else{for(;t.length<i;)t.push(tt.empty);t.push(n)}}function hS(t,e,n){let i=t.inserted;for(let r=0,s=0,o=0;o<t.sections.length;){let c=t.sections[o++],u=t.sections[o++];if(u<0)r+=c,s+=c;else{let h=r,d=s,m=tt.empty;for(;h+=c,d+=u,u&&i&&(m=m.append(i[o-2>>1])),!(n||o==t.sections.length||t.sections[o+1]<0);)c=t.sections[o++],u=t.sections[o++];e(r,h,s,d,m),r=h,s=d}}}function dS(t,e,n,i=!1){let r=[],s=i?[]:null,o=new hu(t),c=new hu(e);for(let u=-1;;){if(o.done&&c.len||c.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&c.ins==-1){let h=Math.min(o.len,c.len);Sn(r,h,-1),o.forward(h),c.forward(h)}else if(c.ins>=0&&(o.ins<0||u==o.i||o.off==0&&(c.len<o.len||c.len==o.len&&!n))){let h=c.len;for(Sn(r,c.ins,-1);h;){let d=Math.min(o.len,h);o.ins>=0&&u<o.i&&o.len<=d&&(Sn(r,0,o.ins),s&&js(s,r,o.text),u=o.i),o.forward(d),h-=d}c.next()}else if(o.ins>=0){let h=0,d=o.len;for(;d;)if(c.ins==-1){let m=Math.min(d,c.len);h+=m,d-=m,c.forward(m)}else if(c.ins==0&&c.len<d)d-=c.len,c.next();else break;Sn(r,h,u<o.i?o.ins:0),s&&u<o.i&&js(s,r,o.text),u=o.i,o.forward(o.len-d)}else{if(o.done&&c.done)return s?en.createSet(r,s):ur.create(r);throw new Error("Mismatched change set lengths")}}}function IB(t,e,n=!1){let i=[],r=n?[]:null,s=new hu(t),o=new hu(e);for(let c=!1;;){if(s.done&&o.done)return r?en.createSet(i,r):ur.create(i);if(s.ins==0)Sn(i,s.len,0,c),s.next();else if(o.len==0&&!o.done)Sn(i,0,o.ins,c),r&&js(r,i,o.text),o.next();else{if(s.done||o.done)throw new Error("Mismatched change set lengths");{let u=Math.min(s.len2,o.len),h=i.length;if(s.ins==-1){let d=o.ins==-1?-1:o.off?0:o.ins;Sn(i,u,d,c),r&&d&&js(r,i,o.text)}else o.ins==-1?(Sn(i,s.off?0:s.len,u,c),r&&js(r,i,s.textBit(u))):(Sn(i,s.off?0:s.len,o.off?0:o.ins,c),r&&!o.off&&js(r,i,o.text));c=(s.ins>u||o.ins>=0&&o.len>u)&&(c||i.length>h),s.forward2(u),o.forward(u)}}}}class hu{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,n=this.i-2>>1;return n>=e.length?tt.empty:e[n]}textBit(e){let{inserted:n}=this.set,i=this.i-2>>1;return i>=n.length&&!e?tt.empty:n[i].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)}}class Na{constructor(e,n,i){this.from=e,this.to=n,this.flags=i}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(e,n=-1){let i,r;return this.empty?i=r=e.mapPos(this.from,n):(i=e.mapPos(this.from,1),r=e.mapPos(this.to,-1)),i==this.from&&r==this.to?this:new Na(i,r,this.flags)}extend(e,n=e){if(e<=this.anchor&&n>=this.anchor)return de.range(e,n);let i=Math.abs(e-this.anchor)>Math.abs(n-this.anchor)?e:n;return de.range(this.anchor,i)}eq(e,n=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!n||!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 new RangeError("Invalid JSON representation for SelectionRange");return de.range(e.anchor,e.head)}static create(e,n,i){return new Na(e,n,i)}}class de{constructor(e,n){this.ranges=e,this.mainIndex=n}map(e,n=-1){return e.empty?this:de.create(this.ranges.map(i=>i.map(e,n)),this.mainIndex)}eq(e,n=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(e.ranges[i],n))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new de([this.main],0)}addRange(e,n=!0){return de.create([e].concat(this.ranges),n?0:this.mainIndex+1)}replaceRange(e,n=this.mainIndex){let i=this.ranges.slice();return i[n]=e,de.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new de(e.ranges.map(n=>Na.fromJSON(n)),e.main)}static single(e,n=e){return new de([de.range(e,n)],0)}static create(e,n=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,r=0;r<e.length;r++){let s=e[r];if(s.empty?s.from<=i:s.from<i)return de.normalized(e.slice(),n);i=s.to}return new de(e,n)}static cursor(e,n=0,i,r){return Na.create(e,e,(n==0?0:n<0?8:16)|(i==null?7:Math.min(6,i))|(r??16777215)<<6)}static range(e,n,i,r){let s=(i??16777215)<<6|(r==null?7:Math.min(6,r));return n<e?Na.create(n,e,48|s):Na.create(e,n,(n>e?8:0)|s)}static normalized(e,n=0){let i=e[n];e.sort((r,s)=>r.from-s.from),n=e.indexOf(i);for(let r=1;r<e.length;r++){let s=e[r],o=e[r-1];if(s.empty?s.from<=o.to:s.from<o.to){let c=o.from,u=Math.max(s.to,o.to);r<=n&&n--,e.splice(--r,2,s.anchor>s.head?de.range(u,c):de.range(c,u))}}return new de(e,n)}}function PB(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let rC=0;class ke{constructor(e,n,i,r,s){this.combine=e,this.compareInput=n,this.compare=i,this.isStatic=r,this.id=rC++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new ke(e.combine||(n=>n),e.compareInput||((n,i)=>n===i),e.compare||(e.combine?(n,i)=>n===i:sC),!!e.static,e.enables)}of(e){return new od([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new od(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new od(e,this,2,n)}from(e,n){return n||(n=i=>i),this.compute([e],i=>n(i.field(e)))}}function sC(t,e){return t==e||t.length==e.length&&t.every((n,i)=>n===e[i])}class od{constructor(e,n,i,r){this.dependencies=e,this.facet=n,this.type=i,this.value=r,this.id=rC++}dynamicSlot(e){var n;let i=this.value,r=this.facet.compareInput,s=this.id,o=e[s]>>1,c=this.type==2,u=!1,h=!1,d=[];for(let m of this.dependencies)m=="doc"?u=!0:m=="selection"?h=!0:(((n=e[m.id])!==null&&n!==void 0?n:1)&1)==0&&d.push(e[m.id]);return{create(m){return m.values[o]=i(m),1},update(m,g){if(u&&g.docChanged||h&&(g.docChanged||g.selection)||pS(m,d)){let y=i(m);if(c?!N3(y,m.values[o],r):!r(y,m.values[o]))return m.values[o]=y,1}return 0},reconfigure:(m,g)=>{let y,x=g.config.address[s];if(x!=null){let w=zd(g,x);if(this.dependencies.every(S=>S instanceof ke?g.facet(S)===m.facet(S):S instanceof _n?g.field(S,!1)==m.field(S,!1):!0)||(c?N3(y=i(m),w,r):r(y=i(m),w)))return m.values[o]=w,0}else y=i(m);return m.values[o]=y,1}}}}function N3(t,e,n){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++)if(!n(t[i],e[i]))return!1;return!0}function pS(t,e){let n=!1;for(let i of e)Yc(t,i)&1&&(n=!0);return n}function PJ(t,e,n){let i=n.map(u=>t[u.id]),r=n.map(u=>u.type),s=i.filter(u=>!(u&1)),o=t[e.id]>>1;function c(u){let h=[];for(let d=0;d<i.length;d++){let m=zd(u,i[d]);if(r[d]==2)for(let g of m)h.push(g);else h.push(m)}return e.combine(h)}return{create(u){for(let h of i)Yc(u,h);return u.values[o]=c(u),1},update(u,h){if(!pS(u,s))return 0;let d=c(u);return e.compare(d,u.values[o])?0:(u.values[o]=d,1)},reconfigure(u,h){let d=pS(u,i),m=h.config.facets[e.id],g=h.facet(e);if(m&&!d&&sC(n,m))return u.values[o]=g,0;let y=c(u);return e.compare(y,g)?(u.values[o]=g,0):(u.values[o]=y,1)}}}const Nh=ke.define({static:!0});class _n{constructor(e,n,i,r,s){this.id=e,this.createF=n,this.updateF=i,this.compareF=r,this.spec=s,this.provides=void 0}static define(e){let n=new _n(rC++,e.create,e.update,e.compare||((i,r)=>i===r),e);return e.provide&&(n.provides=e.provide(n)),n}create(e){let n=e.facet(Nh).find(i=>i.field==this);return(n?.create||this.createF)(e)}slot(e){let n=e[this.id]>>1;return{create:i=>(i.values[n]=this.create(i),1),update:(i,r)=>{let s=i.values[n],o=this.updateF(s,r);return this.compareF(s,o)?0:(i.values[n]=o,1)},reconfigure:(i,r)=>{let s=i.facet(Nh),o=r.facet(Nh),c;return(c=s.find(u=>u.field==this))&&c!=o.find(u=>u.field==this)?(i.values[n]=c.create(i),1):r.config.address[this.id]!=null?(i.values[n]=r.field(this),0):(i.values[n]=this.create(i),1)}}}init(e){return[this,Nh.of({field:this,create:e})]}get extension(){return this}}const Oa={lowest:4,low:3,default:2,high:1,highest:0};function Rc(t){return e=>new HB(e,t)}const Za={highest:Rc(Oa.highest),high:Rc(Oa.high),default:Rc(Oa.default),low:Rc(Oa.low),lowest:Rc(Oa.lowest)};class HB{constructor(e,n){this.inner=e,this.prec=n}}class zp{of(e){return new mS(this,e)}reconfigure(e){return zp.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class mS{constructor(e,n){this.compartment=e,this.inner=n}}class Ld{constructor(e,n,i,r,s,o){for(this.base=e,this.compartments=n,this.dynamicSlots=i,this.address=r,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(e){let n=this.address[e.id];return n==null?e.default:this.staticValues[n>>1]}static resolve(e,n,i){let r=[],s=Object.create(null),o=new Map;for(let g of HJ(e,n,o))g instanceof _n?r.push(g):(s[g.facet.id]||(s[g.facet.id]=[])).push(g);let c=Object.create(null),u=[],h=[];for(let g of r)c[g.id]=h.length<<1,h.push(y=>g.slot(y));let d=i?.config.facets;for(let g in s){let y=s[g],x=y[0].facet,w=d&&d[g]||[];if(y.every(S=>S.type==0))if(c[x.id]=u.length<<1|1,sC(w,y))u.push(i.facet(x));else{let S=x.combine(y.map(C=>C.value));u.push(i&&x.compare(S,i.facet(x))?i.facet(x):S)}else{for(let S of y)S.type==0?(c[S.id]=u.length<<1|1,u.push(S.value)):(c[S.id]=h.length<<1,h.push(C=>S.dynamicSlot(C)));c[x.id]=h.length<<1,h.push(S=>PJ(S,x,y))}}let m=h.map(g=>g(c));return new Ld(e,o,m,c,u,s)}}function HJ(t,e,n){let i=[[],[],[],[],[]],r=new Map;function s(o,c){let u=r.get(o);if(u!=null){if(u<=c)return;let h=i[u].indexOf(o);h>-1&&i[u].splice(h,1),o instanceof mS&&n.delete(o.compartment)}if(r.set(o,c),Array.isArray(o))for(let h of o)s(h,c);else if(o instanceof mS){if(n.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(o.compartment)||o.inner;n.set(o.compartment,h),s(h,c)}else if(o instanceof HB)s(o.inner,o.prec);else if(o instanceof _n)i[c].push(o),o.provides&&s(o.provides,c);else if(o instanceof od)i[c].push(o),o.facet.extensions&&s(o.facet.extensions,Oa.default);else{let h=o.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(h,c)}}return s(t,Oa.default),i.reduce((o,c)=>o.concat(c))}function Yc(t,e){if(e&1)return 2;let n=e>>1,i=t.status[n];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;t.status[n]=4;let r=t.computeSlot(t,t.config.dynamicSlots[n]);return t.status[n]=2|r}function zd(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const UB=ke.define(),gS=ke.define({combine:t=>t.some(e=>e),static:!0}),VB=ke.define({combine:t=>t.length?t[0]:void 0,static:!0}),FB=ke.define(),$B=ke.define(),GB=ke.define(),YB=ke.define({combine:t=>t.length?t[0]:!1});class dr{constructor(e,n){this.type=e,this.value=n}static define(){return new UJ}}class UJ{of(e){return new dr(this,e)}}class VJ{constructor(e){this.map=e}of(e){return new je(this,e)}}class je{constructor(e,n){this.type=e,this.value=n}map(e){let n=this.type.map(this.value,e);return n===void 0?void 0:n==this.value?this:new je(this.type,n)}is(e){return this.type==e}static define(e={}){return new VJ(e.map||(n=>n))}static mapEffects(e,n){if(!e.length)return e;let i=[];for(let r of e){let s=r.map(n);s&&i.push(s)}return i}}je.reconfigure=je.define();je.appendConfig=je.define();class Qt{constructor(e,n,i,r,s,o){this.startState=e,this.changes=n,this.selection=i,this.effects=r,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,i&&PB(i,n.newLength),s.some(c=>c.type==Qt.time)||(this.annotations=s.concat(Qt.time.of(Date.now())))}static create(e,n,i,r,s,o){return new Qt(e,n,i,r,s,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let n of this.annotations)if(n.type==e)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let n=this.annotation(Qt.userEvent);return!!(n&&(n==e||n.length>e.length&&n.slice(0,e.length)==e&&n[e.length]=="."))}}Qt.time=dr.define();Qt.userEvent=dr.define();Qt.addToHistory=dr.define();Qt.remote=dr.define();function FJ(t,e){let n=[];for(let i=0,r=0;;){let s,o;if(i<t.length&&(r==e.length||e[r]>=t[i]))s=t[i++],o=t[i++];else if(r<e.length)s=e[r++],o=e[r++];else return n;!n.length||n[n.length-1]<s?n.push(s,o):n[n.length-1]<o&&(n[n.length-1]=o)}}function QB(t,e,n){var i;let r,s,o;return n?(r=e.changes,s=en.empty(e.changes.length),o=t.changes.compose(e.changes)):(r=e.changes.map(t.changes),s=t.changes.mapDesc(e.changes,!0),o=t.changes.compose(r)),{changes:o,selection:e.selection?e.selection.map(s):(i=t.selection)===null||i===void 0?void 0:i.map(r),effects:je.mapEffects(t.effects,r).concat(je.mapEffects(e.effects,s)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function yS(t,e,n){let i=e.selection,r=il(e.annotations);return e.userEvent&&(r=r.concat(Qt.userEvent.of(e.userEvent))),{changes:e.changes instanceof en?e.changes:en.of(e.changes||[],n,t.facet(VB)),selection:i&&(i instanceof de?i:de.single(i.anchor,i.head)),effects:il(e.effects),annotations:r,scrollIntoView:!!e.scrollIntoView}}function XB(t,e,n){let i=yS(t,e.length?e[0]:{},t.doc.length);e.length&&e[0].filter===!1&&(n=!1);for(let s=1;s<e.length;s++){e[s].filter===!1&&(n=!1);let o=!!e[s].sequential;i=QB(i,yS(t,e[s],o?i.changes.newLength:t.doc.length),o)}let r=Qt.create(t,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return GJ(n?$J(r):r)}function $J(t){let e=t.startState,n=!0;for(let r of e.facet(FB)){let s=r(t);if(s===!1){n=!1;break}Array.isArray(s)&&(n=n===!0?s:FJ(n,s))}if(n!==!0){let r,s;if(n===!1)s=t.changes.invertedDesc,r=en.empty(e.doc.length);else{let o=t.changes.filter(n);r=o.changes,s=o.filtered.mapDesc(o.changes).invertedDesc}t=Qt.create(e,r,t.selection&&t.selection.map(s),je.mapEffects(t.effects,s),t.annotations,t.scrollIntoView)}let i=e.facet($B);for(let r=i.length-1;r>=0;r--){let s=i[r](t);s instanceof Qt?t=s:Array.isArray(s)&&s.length==1&&s[0]instanceof Qt?t=s[0]:t=XB(e,il(s),!1)}return t}function GJ(t){let e=t.startState,n=e.facet(GB),i=t;for(let r=n.length-1;r>=0;r--){let s=n[r](t);s&&Object.keys(s).length&&(i=QB(i,yS(e,s,t.changes.newLength),!0))}return i==t?t:Qt.create(e,t.changes,t.selection,i.effects,i.annotations,i.scrollIntoView)}const YJ=[];function il(t){return t==null?YJ:Array.isArray(t)?t:[t]}var At=(function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t})(At||(At={}));const QJ=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let vS;try{vS=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function XJ(t){if(vS)return vS.test(t);for(let e=0;e<t.length;e++){let n=t[e];if(/\w/.test(n)||n>""&&(n.toUpperCase()!=n.toLowerCase()||QJ.test(n)))return!0}return!1}function WJ(t){return e=>{if(!/\S/.test(e))return At.Space;if(XJ(e))return At.Word;for(let n=0;n<t.length;n++)if(e.indexOf(t[n])>-1)return At.Word;return At.Other}}class Je{constructor(e,n,i,r,s,o){this.config=e,this.doc=n,this.selection=i,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let c=0;c<this.config.dynamicSlots.length;c++)Yc(this,c<<1);this.computeSlot=null}field(e,n=!0){let i=this.config.address[e.id];if(i==null){if(n)throw new RangeError("Field is not present in this state");return}return Yc(this,i),zd(this,i)}update(...e){return XB(this,e,!0)}applyTransaction(e){let n=this.config,{base:i,compartments:r}=n;for(let c of e.effects)c.is(zp.reconfigure)?(n&&(r=new Map,n.compartments.forEach((u,h)=>r.set(h,u)),n=null),r.set(c.value.compartment,c.value.extension)):c.is(je.reconfigure)?(n=null,i=c.value):c.is(je.appendConfig)&&(n=null,i=il(i).concat(c.value));let s;n?s=e.startState.values.slice():(n=Ld.resolve(i,r,this),s=new Je(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(u,h)=>h.reconfigure(u,this),null).values);let o=e.startState.facet(gS)?e.newSelection:e.newSelection.asSingle();new Je(n,e.newDoc,o,s,(c,u)=>u.update(c,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:e},range:de.cursor(n.from+e.length)}))}changeByRange(e){let n=this.selection,i=e(n.ranges[0]),r=this.changes(i.changes),s=[i.range],o=il(i.effects);for(let c=1;c<n.ranges.length;c++){let u=e(n.ranges[c]),h=this.changes(u.changes),d=h.map(r);for(let g=0;g<c;g++)s[g]=s[g].map(d);let m=r.mapDesc(h,!0);s.push(u.range.map(m)),r=r.compose(d),o=je.mapEffects(o,d).concat(je.mapEffects(il(u.effects),m))}return{changes:r,selection:de.create(s,n.mainIndex),effects:o}}changes(e=[]){return e instanceof en?e:en.of(e,this.doc.length,this.facet(Je.lineSeparator))}toText(e){return tt.of(e.split(this.facet(Je.lineSeparator)||fS))}sliceDoc(e=0,n=this.doc.length){return this.doc.sliceString(e,n,this.lineBreak)}facet(e){let n=this.config.address[e.id];return n==null?e.default:(Yc(this,n),zd(this,n))}toJSON(e){let n={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let i in e){let r=e[i];r instanceof _n&&this.config.address[r.id]!=null&&(n[i]=r.spec.toJSON(this.field(e[i]),this))}return n}static fromJSON(e,n={},i){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let r=[];if(i){for(let s in i)if(Object.prototype.hasOwnProperty.call(e,s)){let o=i[s],c=e[s];r.push(o.init(u=>o.spec.fromJSON(c,u)))}}return Je.create({doc:e.doc,selection:de.fromJSON(e.selection),extensions:n.extensions?r.concat([n.extensions]):r})}static create(e={}){let n=Ld.resolve(e.extensions||[],new Map),i=e.doc instanceof tt?e.doc:tt.of((e.doc||"").split(n.staticFacet(Je.lineSeparator)||fS)),r=e.selection?e.selection instanceof de?e.selection:de.single(e.selection.anchor,e.selection.head):de.single(0);return PB(r,i.length),n.staticFacet(gS)||(r=r.asSingle()),new Je(n,i,r,n.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(Je.tabSize)}get lineBreak(){return this.facet(Je.lineSeparator)||`
|
|
@@ -48,7 +48,7 @@ Error generating stack: `+p.message+`
|
|
|
48
48
|
`&&t.lineWrapping&&(i&&(i=de.single(i.main.anchor-1,i.main.head-1)),n={from:s.from,to:s.to,insert:tt.of([" "])}),n)return gC(t,n,i,o);if(i&&!Hd(i,s)){let c=!1,u="select";return t.inputState.lastSelectionTime>Date.now()-50&&(t.inputState.lastSelectionOrigin=="select"&&(c=!0),u=t.inputState.lastSelectionOrigin,u=="select.pointer"&&(i=E6(r.facet(Uu).map(h=>h(t)),i))),t.dispatch({selection:i,scrollIntoView:c,userEvent:u}),!0}else return!1}function gC(t,e,n,i=-1){if(Ce.ios&&t.inputState.flushIOSKey(e))return!0;let r=t.state.selection.main;if(Ce.android&&(e.to==r.to&&(e.from==r.from||e.from==r.from-1&&t.state.sliceDoc(e.from,r.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&sl(t.contentDOM,"Enter",13)||(e.from==r.from-1&&e.to==r.to&&e.insert.length==0||i==8&&e.insert.length<e.to-e.from&&e.to>r.head)&&sl(t.contentDOM,"Backspace",8)||e.from==r.from&&e.to==r.to+1&&e.insert.length==0&&sl(t.contentDOM,"Delete",46)))return!0;let s=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let o,c=()=>o||(o=Zee(t,e,n));return t.state.facet(g6).some(u=>u(t,e.from,e.to,s,c))||t.dispatch(c()),!0}function Zee(t,e,n){let i,r=t.state,s=r.selection.main,o=-1;if(e.from==e.to&&e.from<s.from||e.from>s.to){let u=e.from<s.from?-1:1,h=u<0?s.from:s.to,d=Kc(r.facet(Uu).map(m=>m(t)),h,u);e.from==d&&(o=d)}if(o>-1)i={changes:e,selection:de.cursor(e.from+e.insert.length,-1)};else if(e.from>=s.from&&e.to<=s.to&&e.to-e.from>=(s.to-s.from)/3&&(!n||n.main.empty&&n.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let u=s.from<e.from?r.sliceDoc(s.from,e.from):"",h=s.to>e.to?r.sliceDoc(e.to,s.to):"";i=r.replaceSelection(t.state.toText(u+e.insert.sliceString(0,void 0,t.state.lineBreak)+h))}else{let u=r.changes(e),h=n&&n.main.to<=u.newLength?n.main:void 0;if(r.selection.ranges.length>1&&(t.inputState.composing>=0||t.inputState.compositionPendingChange)&&e.to<=s.to+10&&e.to>=s.to-10){let d=t.state.sliceDoc(e.from,e.to),m,g=n&&O6(t,n.main.head);if(g){let x=e.insert.length-(e.to-e.from);m={from:g.from,to:g.to-x}}else m=t.state.doc.lineAt(s.head);let y=s.to-e.to;i=r.changeByRange(x=>{if(x.from==s.from&&x.to==s.to)return{changes:u,range:h||x.map(u)};let w=x.to-y,S=w-d.length;if(t.state.sliceDoc(S,w)!=d||w>=m.from&&S<=m.to)return{range:x};let C=r.changes({from:S,to:w,insert:e.insert}),A=x.to-s.to;return{changes:C,range:h?de.range(Math.max(0,h.anchor+A),Math.max(0,h.head+A)):x.map(C)}})}else i={changes:u,selection:h&&r.selection.replaceRange(h)}}let c="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,c+=".compose",t.inputState.compositionFirstChange&&(c+=".start",t.inputState.compositionFirstChange=!1)),r.update(i,{userEvent:c,scrollIntoView:!0})}function R6(t,e,n,i){let r=Math.min(t.length,e.length),s=0;for(;s<r&&t.charCodeAt(s)==e.charCodeAt(s);)s++;if(s==r&&t.length==e.length)return null;let o=t.length,c=e.length;for(;o>0&&c>0&&t.charCodeAt(o-1)==e.charCodeAt(c-1);)o--,c--;if(i=="end"){let u=Math.max(0,s-Math.min(o,c));n-=o+u-s}if(o<s&&t.length<e.length){let u=n<=s&&n>=o?s-n:0;s-=u,c=s+(c-o),o=s}else if(c<s){let u=n<=s&&n>=c?s-n:0;s-=u,o=s+(o-c),c=s}return{from:s,toA:o,toB:c}}function Jee(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:n,anchorOffset:i,focusNode:r,focusOffset:s}=t.observer.selectionRange;return n&&(e.push(new X3(n,i)),(r!=n||s!=i)&&e.push(new X3(r,s))),e}function ete(t,e){if(t.length==0)return null;let n=t[0].pos,i=t.length==2?t[1].pos:n;return n>-1&&i>-1?de.single(n+e,i+e):null}function Hd(t,e){return e.head==t.main.head&&e.anchor==t.main.anchor}class tte{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=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,Ce.safari&&e.contentDOM.addEventListener("input",()=>null),Ce.gecko&>e(e.contentDOM.ownerDocument)}handleEvent(e){!cte(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,n){let i=this.handlers[e];if(i){for(let r of i.observers)r(this.view,n);for(let r of i.handlers){if(n.defaultPrevented)break;if(r(this.view,n)){n.preventDefault();break}}}}ensureHandlers(e){let n=nte(e),i=this.handlers,r=this.view.contentDOM;for(let s in n)if(s!="scroll"){let o=!n[s].handlers.length,c=i[s];c&&o!=!c.handlers.length&&(r.removeEventListener(s,this.handleEvent),c=null),c||r.addEventListener(s,this.handleEvent,{passive:o})}for(let s in i)s!="scroll"&&!n[s]&&r.removeEventListener(s,this.handleEvent);this.handlers=n}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&&D6.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Ce.android&&Ce.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let n;return Ce.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&((n=N6.find(i=>i.keyCode==e.keyCode))&&!e.ctrlKey||ite.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey)?(this.pendingIOSKey=n||e,setTimeout(()=>this.flushIOSKey(),250),!0):(e.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(e){let n=this.pendingIOSKey;return!n||n.key=="Enter"&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString())?!1:(this.pendingIOSKey=void 0,sl(this.view.contentDOM,n.key,n.keyCode,n instanceof KeyboardEvent?n:void 0))}ignoreDuringComposition(e){return!/^key/.test(e.type)||e.synthetic?!1:this.composing>0?!0:Ce.safari&&!Ce.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 W3(t,e){return(n,i)=>{try{return e.call(t,i,n)}catch(r){Fn(n.state,r)}}}function nte(t){let e=Object.create(null);function n(i){return e[i]||(e[i]={observers:[],handlers:[]})}for(let i of t){let r=i.spec,s=r&&r.plugin.domEventHandlers,o=r&&r.plugin.domEventObservers;if(s)for(let c in s){let u=s[c];u&&n(c).handlers.push(W3(i.value,u))}if(o)for(let c in o){let u=o[c];u&&n(c).observers.push(W3(i.value,u))}}for(let i in Ii)n(i).handlers.push(Ii[i]);for(let i in Qn)n(i).observers.push(Qn[i]);return e}const N6=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],ite="dthko",D6=[16,17,18,20,91,92,224,225],Bh=6;function qh(t){return Math.max(0,t)*.7+8}function rte(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}class ste{constructor(e,n,i,r){this.view=e,this.startEvent=n,this.style=i,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=n,this.scrollParents=n6(e.contentDOM),this.atoms=e.state.facet(Uu).map(o=>o(e));let s=e.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=n.shiftKey,this.multiple=e.state.facet(Je.allowMultipleSelections)&&ate(e,n),this.dragging=lte(e,n)&&B6(n)==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&&rte(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let n=0,i=0,r=0,s=0,o=this.view.win.innerWidth,c=this.view.win.innerHeight;this.scrollParents.x&&({left:r,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:c}=this.scrollParents.y.getBoundingClientRect());let u=mC(this.view);e.clientX-u.left<=r+Bh?n=-qh(r-e.clientX):e.clientX+u.right>=o-Bh&&(n=qh(e.clientX-o)),e.clientY-u.top<=s+Bh?i=-qh(s-e.clientY):e.clientY+u.bottom>=c-Bh&&(i=qh(e.clientY-c)),this.setScrollSpeed(n,i)}up(e){this.dragging==null&&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,n){this.scrollSpeed={x:e,y:n},e||n?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:n}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),n&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=n,n=0),(e||n)&&this.view.win.scrollBy(e,n),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:n}=this,i=E6(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!i.eq(n.state.selection,this.dragging===!1))&&this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(n=>n.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function ate(t,e){let n=t.state.facet(h6);return n.length?n[0](e):Ce.mac?e.metaKey:e.ctrlKey}function ote(t,e){let n=t.state.facet(d6);return n.length?n[0](e):Ce.mac?!e.altKey:!e.ctrlKey}function lte(t,e){let{main:n}=t.state.selection;if(n.empty)return!1;let i=gu(t.root);if(!i||i.rangeCount==0)return!0;let r=i.getRangeAt(0).getClientRects();for(let s=0;s<r.length;s++){let o=r[s];if(o.left<=e.clientX&&o.right>=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function cte(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target,i;n!=t.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(i=Lt.get(n))&&i.isWidget()&&!i.isHidden&&i.widget.ignoreEvent(e))return!1;return!0}const Ii=Object.create(null),Qn=Object.create(null),L6=Ce.ie&&Ce.ie_version<15||Ce.ios&&Ce.webkit_version<604;function ute(t){let e=t.dom.parentNode;if(!e)return;let n=e.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{t.focus(),n.remove(),z6(t,n.value)},50)}function Pp(t,e,n){for(let i of t.facet(e))n=i(n,t);return n}function z6(t,e){e=Pp(t.state,fC,e);let{state:n}=t,i,r=1,s=n.toText(e),o=s.lines==n.selection.ranges.length;if(qS!=null&&n.selection.ranges.every(u=>u.empty)&&qS==s.toString()){let u=-1;i=n.changeByRange(h=>{let d=n.doc.lineAt(h.from);if(d.from==u)return{range:h};u=d.from;let m=n.toText((o?s.line(r++).text:e)+n.lineBreak);return{changes:{from:d.from,insert:m},range:de.cursor(h.from+m.length)}})}else o?i=n.changeByRange(u=>{let h=s.line(r++);return{changes:{from:u.from,to:u.to,insert:h.text},range:de.cursor(u.from+h.length)}}):i=n.replaceSelection(s);t.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}Qn.scroll=t=>{t.inputState.lastScrollTop=t.scrollDOM.scrollTop,t.inputState.lastScrollLeft=t.scrollDOM.scrollLeft};Qn.wheel=Qn.mousewheel=t=>{t.inputState.lastWheelEvent=Date.now()};Ii.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),e.keyCode==27&&t.inputState.tabFocusMode!=0&&(t.inputState.tabFocusMode=Date.now()+2e3),!1);Qn.touchstart=(t,e)=>{t.inputState.lastTouchTime=Date.now(),t.inputState.setSelectionOrigin("select.pointer")};Qn.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")};Ii.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let i of t.state.facet(p6))if(n=i(t,e),n)break;if(!n&&e.button==0&&(n=hte(t,e)),n){let i=!t.hasFocus;t.inputState.startMouseSelection(new ste(t,e,n,i)),i&&t.observer.ignore(()=>{i6(t.contentDOM);let s=t.root.activeElement;s&&!s.contains(t.contentDOM)&&s.blur()});let r=t.inputState.mouseSelection;if(r)return r.start(e),r.dragging===!1}else t.inputState.setSelectionOrigin("select.pointer");return!1};function K3(t,e,n,i){if(i==1)return de.cursor(e,n);if(i==2)return Uee(t.state,e,n);{let r=t.docView.lineAt(e,n),s=t.state.doc.lineAt(r?r.posAtEnd:e),o=r?r.posAtStart:s.from,c=r?r.posAtEnd:s.to;return c<t.state.doc.length&&c==s.to&&c++,de.range(o,c)}}const fte=Ce.ie&&Ce.ie_version<=11;let Z3=null,J3=0,e5=0;function B6(t){if(!fte)return t.detail;let e=Z3,n=e5;return Z3=t,e5=Date.now(),J3=!e||n>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(J3+1)%3:1}function hte(t,e){let n=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),i=B6(e),r=t.state.selection;return{update(s){s.docChanged&&(n.pos=s.changes.mapPos(n.pos),r=r.map(s.changes))},get(s,o,c){let u=t.posAndSideAtCoords({x:s.clientX,y:s.clientY},!1),h,d=K3(t,u.pos,u.assoc,i);if(n.pos!=u.pos&&!o){let m=K3(t,n.pos,n.assoc,i),g=Math.min(m.from,d.from),y=Math.max(m.to,d.to);d=g<d.from?de.range(g,y):de.range(y,g)}return o?r.replaceRange(r.main.extend(d.from,d.to)):c&&i==1&&r.ranges.length>1&&(h=dte(r,u.pos))?h:c?r.addRange(d):de.create([d])}}}function dte(t,e){for(let n=0;n<t.ranges.length;n++){let{from:i,to:r}=t.ranges[n];if(i<=e&&r>=e)return de.create(t.ranges.slice(0,n).concat(t.ranges.slice(n+1)),t.mainIndex==n?0:t.mainIndex-(t.mainIndex>n?1:0))}return null}Ii.dragstart=(t,e)=>{let{selection:{main:n}}=t.state;if(e.target.draggable){let r=t.docView.tile.nearest(e.target);if(r&&r.isWidget()){let s=r.posAtStart,o=s+r.length;(s>=n.to||o<=n.from)&&(n=de.range(s,o))}}let{inputState:i}=t;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=n,e.dataTransfer&&(e.dataTransfer.setData("Text",Pp(t.state,hC,t.state.sliceDoc(n.from,n.to))),e.dataTransfer.effectAllowed="copyMove"),!1};Ii.dragend=t=>(t.inputState.draggedContent=null,!1);function t5(t,e,n,i){if(n=Pp(t.state,fC,n),!n)return;let r=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=t.inputState,o=i&&s&&ote(t,e)?{from:s.from,to:s.to}:null,c={from:r,insert:n},u=t.state.changes(o?[o,c]:c);t.focus(),t.dispatch({changes:u,selection:{anchor:u.mapPos(r,-1),head:u.mapPos(r,1)},userEvent:o?"move.drop":"input.drop"}),t.inputState.draggedContent=null}Ii.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let n=e.dataTransfer.files;if(n&&n.length){let i=Array(n.length),r=0,s=()=>{++r==n.length&&t5(t,e,i.filter(o=>o!=null).join(t.state.lineBreak),!1)};for(let o=0;o<n.length;o++){let c=new FileReader;c.onerror=s,c.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(c.result)||(i[o]=c.result),s()},c.readAsText(n[o])}return!0}else{let i=e.dataTransfer.getData("Text");if(i)return t5(t,e,i,!0),!0}return!1};Ii.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let n=L6?null:e.clipboardData;return n?(z6(t,n.getData("text/plain")||n.getData("text/uri-list")),!0):(ute(t),!1)};function pte(t,e){let n=t.dom.parentNode;if(!n)return;let i=n.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=e,i.focus(),i.selectionEnd=e.length,i.selectionStart=0,setTimeout(()=>{i.remove(),t.focus()},50)}function mte(t){let e=[],n=[],i=!1;for(let r of t.selection.ranges)r.empty||(e.push(t.sliceDoc(r.from,r.to)),n.push(r));if(!e.length){let r=-1;for(let{from:s}of t.selection.ranges){let o=t.doc.lineAt(s);o.number>r&&(e.push(o.text),n.push({from:o.from,to:Math.min(t.doc.length,o.to+1)})),r=o.number}i=!0}return{text:Pp(t,hC,e.join(t.lineBreak)),ranges:n,linewise:i}}let qS=null;Ii.copy=Ii.cut=(t,e)=>{if(!Qc(t.contentDOM,t.observer.selectionRange))return!1;let{text:n,ranges:i,linewise:r}=mte(t.state);if(!n&&!r)return!1;qS=r?n:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let s=L6?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",n),!0):(pte(t,n),!1)};const q6=dr.define();function j6(t,e){let n=[];for(let i of t.facet(y6)){let r=i(t,e);r&&n.push(r)}return n.length?t.update({effects:n,annotations:q6.of(!0)}):null}function I6(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let n=j6(t.state,e);n?t.dispatch(n):t.update([])}},10)}Qn.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),I6(t)};Qn.blur=t=>{t.observer.clearSelectionRange(),I6(t)};Qn.compositionstart=Qn.compositionupdate=t=>{t.observer.editContext||(t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))};Qn.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,Ce.chrome&&Ce.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))};Qn.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()};Ii.beforeinput=(t,e)=>{var n,i;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(t.inputState.insertingText=e.data,t.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&t.observer.editContext){let s=(n=e.dataTransfer)===null||n===void 0?void 0:n.getData("text/plain"),o=e.getTargetRanges();if(s&&o.length){let c=o[0],u=t.posAtDOM(c.startContainer,c.startOffset),h=t.posAtDOM(c.endContainer,c.endOffset);return gC(t,{from:u,to:h,insert:t.state.toText(s)},null),!0}}let r;if(Ce.chrome&&Ce.android&&(r=N6.find(s=>s.inputType==e.inputType))&&(t.observer.delayAndroidKey(r.key,r.keyCode),r.key=="Backspace"||r.key=="Delete")){let s=((i=window.visualViewport)===null||i===void 0?void 0:i.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>s+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return Ce.ios&&e.inputType=="deleteContentForward"&&t.observer.flushSoon(),Ce.safari&&e.inputType=="insertText"&&t.inputState.composing>=0&&setTimeout(()=>Qn.compositionend(t,e),20),!1};const n5=new Set;function gte(t){n5.has(t)||(n5.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}const i5=["pre-wrap","normal","pre-line","break-spaces"];let yl=!1;function r5(){yl=!1}class yte{constructor(e){this.lineWrapping=e,this.doc=tt.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,n){let i=this.doc.lineAt(n).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((n-e-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}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 i5.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let n=!1;for(let i=0;i<e.length;i++){let r=e[i];r<0?i++:this.heightSamples[Math.floor(r*10)]||(n=!0,this.heightSamples[Math.floor(r*10)]=!0)}return n}refresh(e,n,i,r,s,o){let c=i5.indexOf(e)>-1,u=Math.abs(n-this.lineHeight)>.3||this.lineWrapping!=c||Math.abs(i-this.charWidth)>.1;if(this.lineWrapping=c,this.lineHeight=n,this.charWidth=i,this.textHeight=r,this.lineLength=s,u){this.heightSamples={};for(let h=0;h<o.length;h++){let d=o[h];d<0?h++:this.heightSamples[Math.floor(d*10)]=!0}}return u}}class vte{constructor(e,n){this.from=e,this.heights=n,this.index=0}get more(){return this.index<this.heights.length}}class Li{constructor(e,n,i,r,s){this.from=e,this.length=n,this.top=i,this.height=r,this._content=s}get type(){return typeof this._content=="number"?bn.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 Ua?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(e){let n=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new Li(this.from,this.length+e.length,this.top,this.height+e.height,n)}}var xt=(function(t){return t[t.ByPos=0]="ByPos",t[t.ByHeight=1]="ByHeight",t[t.ByPosNoHeight=2]="ByPosNoHeight",t})(xt||(xt={}));const ld=.001;class Nn{constructor(e,n,i=2){this.length=e,this.height=n,this.flags=i}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)>ld&&(yl=!0),this.height=e)}replace(e,n,i){return Nn.of(i)}decomposeLeft(e,n){n.push(this)}decomposeRight(e,n){n.push(this)}applyChanges(e,n,i,r){let s=this,o=i.doc;for(let c=r.length-1;c>=0;c--){let{fromA:u,toA:h,fromB:d,toB:m}=r[c],g=s.lineAt(u,xt.ByPosNoHeight,i.setDoc(n),0,0),y=g.to>=h?g:s.lineAt(h,xt.ByPosNoHeight,i,0,0);for(m+=y.to-h,h=y.to;c>0&&g.from<=r[c-1].toA;)u=r[c-1].fromA,d=r[c-1].fromB,c--,u<g.from&&(g=s.lineAt(u,xt.ByPosNoHeight,i,0,0));d+=g.from-u,u=g.from;let x=yC.build(i.setDoc(o),e,d,m);s=Ud(s,s.replace(u,h,x))}return s.updateHeight(i,0)}static empty(){return new ai(0,0,0)}static of(e){if(e.length==1)return e[0];let n=0,i=e.length,r=0,s=0;for(;;)if(n==i)if(r>s*2){let c=e[n-1];c.break?e.splice(--n,1,c.left,null,c.right):e.splice(--n,1,c.left,c.right),i+=1+c.break,r-=c.size}else if(s>r*2){let c=e[i];c.break?e.splice(i,1,c.left,null,c.right):e.splice(i,1,c.left,c.right),i+=2+c.break,s-=c.size}else break;else if(r<s){let c=e[n++];c&&(r+=c.size)}else{let c=e[--i];c&&(s+=c.size)}let o=0;return e[n-1]==null?(o=1,n--):e[n]==null&&(o=1,i++),new xte(Nn.of(e.slice(0,n)),o,Nn.of(e.slice(i)))}}function Ud(t,e){return t==e?t:(t.constructor!=e.constructor&&(yl=!0),e)}Nn.prototype.size=1;const bte=Le.replace({});class P6 extends Nn{constructor(e,n,i){super(e,n),this.deco=i,this.spaceAbove=0}mainBlock(e,n){return new Li(n,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(e,n,i,r){return this.spaceAbove&&e<i+this.spaceAbove?new Li(r,0,i,this.spaceAbove,bte):this.mainBlock(i,r)}lineAt(e,n,i,r,s){let o=this.mainBlock(r,s);return this.spaceAbove?this.blockAt(0,i,r,s).join(o):o}forEachLine(e,n,i,r,s,o){e<=s+this.length&&n>=s&&o(this.lineAt(0,xt.ByPos,i,r,s))}setMeasuredHeight(e){let n=e.heights[e.index++];n<0?(this.spaceAbove=-n,n=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(n)}updateHeight(e,n=0,i=!1,r){return r&&r.from<=n&&r.more&&this.setMeasuredHeight(r),this.outdated=!1,this}toString(){return`block(${this.length})`}}class ai extends P6{constructor(e,n,i){super(e,n,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=i}mainBlock(e,n){return new Li(n,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,n,i){let r=i[0];return i.length==1&&(r instanceof ai||r instanceof gn&&r.flags&4)&&Math.abs(this.length-r.length)<10?(r instanceof gn?r=new ai(r.length,this.height,this.spaceAbove):r.height=this.height,this.outdated||(r.outdated=!1),r):Nn.of(i)}updateHeight(e,n=0,i=!1,r){return r&&r.from<=n&&r.more?this.setMeasuredHeight(r):(i||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:""})`}}class gn extends Nn{constructor(e){super(e,0)}heightMetrics(e,n){let i=e.doc.lineAt(n).number,r=e.doc.lineAt(n+this.length).number,s=r-i+1,o,c=0;if(e.lineWrapping){let u=Math.min(this.height,e.lineHeight*s);o=u/s,this.length>s+1&&(c=(this.height-u)/(this.length-s-1))}else o=this.height/s;return{firstLine:i,lastLine:r,perLine:o,perChar:c}}blockAt(e,n,i,r){let{firstLine:s,lastLine:o,perLine:c,perChar:u}=this.heightMetrics(n,r);if(n.lineWrapping){let h=r+(e<n.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-i)/this.height))*this.length)),d=n.doc.lineAt(h),m=c+d.length*u,g=Math.max(i,e-m/2);return new Li(d.from,d.length,g,m,0)}else{let h=Math.max(0,Math.min(o-s,Math.floor((e-i)/c))),{from:d,length:m}=n.doc.line(s+h);return new Li(d,m,i+c*h,c,0)}}lineAt(e,n,i,r,s){if(n==xt.ByHeight)return this.blockAt(e,i,r,s);if(n==xt.ByPosNoHeight){let{from:y,to:x}=i.doc.lineAt(e);return new Li(y,x-y,0,0,0)}let{firstLine:o,perLine:c,perChar:u}=this.heightMetrics(i,s),h=i.doc.lineAt(e),d=c+h.length*u,m=h.number-o,g=r+c*m+u*(h.from-s-m);return new Li(h.from,h.length,Math.max(r,Math.min(g,r+this.height-d)),d,0)}forEachLine(e,n,i,r,s,o){e=Math.max(e,s),n=Math.min(n,s+this.length);let{firstLine:c,perLine:u,perChar:h}=this.heightMetrics(i,s);for(let d=e,m=r;d<=n;){let g=i.doc.lineAt(d);if(d==e){let x=g.number-c;m+=u*x+h*(e-s-x)}let y=u+h*g.length;o(new Li(g.from,g.length,m,y,0)),m+=y,d=g.to+1}}replace(e,n,i){let r=this.length-n;if(r>0){let s=i[i.length-1];s instanceof gn?i[i.length-1]=new gn(s.length+r):i.push(null,new gn(r-1))}if(e>0){let s=i[0];s instanceof gn?i[0]=new gn(e+s.length):i.unshift(new gn(e-1),null)}return Nn.of(i)}decomposeLeft(e,n){n.push(new gn(e-1),null)}decomposeRight(e,n){n.push(null,new gn(this.length-e-1))}updateHeight(e,n=0,i=!1,r){let s=n+this.length;if(r&&r.from<=n+this.length&&r.more){let o=[],c=Math.max(n,r.from),u=-1;for(r.from>n&&o.push(new gn(r.from-n-1).updateHeight(e,n));c<=s&&r.more;){let d=e.doc.lineAt(c).length;o.length&&o.push(null);let m=r.heights[r.index++],g=0;m<0&&(g=-m,m=r.heights[r.index++]),u==-1?u=m:Math.abs(m-u)>=ld&&(u=-2);let y=new ai(d,m,g);y.outdated=!1,o.push(y),c+=d+1}c<=s&&o.push(null,new gn(s-c).updateHeight(e,c));let h=Nn.of(o);return(u<0||Math.abs(h.height-this.height)>=ld||Math.abs(u-this.heightMetrics(e,n).perLine)>=ld)&&(yl=!0),Ud(this,h)}else(i||this.outdated)&&(this.setHeight(e.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class xte extends Nn{constructor(e,n,i){super(e.length+n+i.length,e.height+i.height,n|(e.outdated||i.outdated?2:0)),this.left=e,this.right=i,this.size=e.size+i.size}get break(){return this.flags&1}blockAt(e,n,i,r){let s=i+this.left.height;return e<s?this.left.blockAt(e,n,i,r):this.right.blockAt(e,n,s,r+this.left.length+this.break)}lineAt(e,n,i,r,s){let o=r+this.left.height,c=s+this.left.length+this.break,u=n==xt.ByHeight?e<o:e<c,h=u?this.left.lineAt(e,n,i,r,s):this.right.lineAt(e,n,i,o,c);if(this.break||(u?h.to<c:h.from>c))return h;let d=n==xt.ByPosNoHeight?xt.ByPosNoHeight:xt.ByPos;return u?h.join(this.right.lineAt(c,d,i,o,c)):this.left.lineAt(c,d,i,r,s).join(h)}forEachLine(e,n,i,r,s,o){let c=r+this.left.height,u=s+this.left.length+this.break;if(this.break)e<u&&this.left.forEachLine(e,n,i,r,s,o),n>=u&&this.right.forEachLine(e,n,i,c,u,o);else{let h=this.lineAt(u,xt.ByPos,i,r,s);e<h.from&&this.left.forEachLine(e,h.from-1,i,r,s,o),h.to>=e&&h.from<=n&&o(h),n>h.to&&this.right.forEachLine(h.to+1,n,i,c,u,o)}}replace(e,n,i){let r=this.left.length+this.break;if(n<r)return this.balanced(this.left.replace(e,n,i),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-r,n-r,i));let s=[];e>0&&this.decomposeLeft(e,s);let o=s.length;for(let c of i)s.push(c);if(e>0&&s5(s,o-1),n<this.length){let c=s.length;this.decomposeRight(n,s),s5(s,c)}return Nn.of(s)}decomposeLeft(e,n){let i=this.left.length;if(e<=i)return this.left.decomposeLeft(e,n);n.push(this.left),this.break&&(i++,e>=i&&n.push(null)),e>i&&this.right.decomposeLeft(e-i,n)}decomposeRight(e,n){let i=this.left.length,r=i+this.break;if(e>=r)return this.right.decomposeRight(e-r,n);e<i&&this.left.decomposeRight(e,n),this.break&&e<r&&n.push(null),n.push(this.right)}balanced(e,n){return e.size>2*n.size||n.size>2*e.size?Nn.of(this.break?[e,null,n]:[e,n]):(this.left=Ud(this.left,e),this.right=Ud(this.right,n),this.setHeight(e.height+n.height),this.outdated=e.outdated||n.outdated,this.size=e.size+n.size,this.length=e.length+this.break+n.length,this)}updateHeight(e,n=0,i=!1,r){let{left:s,right:o}=this,c=n+s.length+this.break,u=null;return r&&r.from<=n+s.length&&r.more?u=s=s.updateHeight(e,n,i,r):s.updateHeight(e,n,i),r&&r.from<=c+o.length&&r.more?u=o=o.updateHeight(e,c,i,r):o.updateHeight(e,c,i),u?this.balanced(s,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function s5(t,e){let n,i;t[e]==null&&(n=t[e-1])instanceof gn&&(i=t[e+1])instanceof gn&&t.splice(e-1,3,new gn(n.length+1+i.length))}const wte=5;class yC{constructor(e,n){this.pos=e,this.oracle=n,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,n){if(this.lineStart>-1){let i=Math.min(n,this.lineEnd),r=this.nodes[this.nodes.length-1];r instanceof ai?r.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new ai(i-this.pos,-1,0)),this.writtenTo=i,n>i&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=n}point(e,n,i){if(e<n||i.heightRelevant){let r=i.widget?i.widget.estimatedHeight:0,s=i.widget?i.widget.lineBreaks:0;r<0&&(r=this.oracle.lineHeight);let o=n-e;i.block?this.addBlock(new P6(o,r,i)):(o||s||r>=wte)&&this.addLineDeco(r,s,o)}else n>e&&this.span(e,n);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:n}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=n,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 ai(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,n){let i=new gn(n-e);return this.oracle.doc.lineAt(e).to==n&&(i.flags|=4),i}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof ai)return e;let n=new ai(0,-1,0);return this.nodes.push(n),n}addBlock(e){this.enterLine();let n=e.deco;n&&n.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,n&&n.endSide>0&&(this.covering=e)}addLineDeco(e,n,i){let r=this.ensureLine();r.length+=i,r.collapsed+=i,r.widgetHeight=Math.max(r.widgetHeight,e),r.breaks+=n,this.writtenTo=this.pos=this.pos+i}finish(e){let n=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(n instanceof ai)&&!this.isCovered?this.nodes.push(new ai(0,-1,0)):(this.writtenTo<this.pos||n==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let i=e;for(let r of this.nodes)r instanceof ai&&r.updateHeight(this.oracle,i),i+=r?r.length:1;return this.nodes}static build(e,n,i,r){let s=new yC(i,e);return Ye.spans(n,i,r,s,0),s.finish(i)}}function Ste(t,e,n){let i=new Cte;return Ye.compare(t,e,n,i,0),i.changes}class Cte{constructor(){this.changes=[]}compareRange(){}comparePoint(e,n,i,r){(e<n||i&&i.heightRelevant||r&&r.heightRelevant)&&rl(e,n,this.changes,5)}}function kte(t,e){let n=t.getBoundingClientRect(),i=t.ownerDocument,r=i.defaultView||window,s=Math.max(0,n.left),o=Math.min(r.innerWidth,n.right),c=Math.max(0,n.top),u=Math.min(r.innerHeight,n.bottom);for(let h=t.parentNode;h&&h!=i.body;)if(h.nodeType==1){let d=h,m=window.getComputedStyle(d);if((d.scrollHeight>d.clientHeight||d.scrollWidth>d.clientWidth)&&m.overflow!="visible"){let g=d.getBoundingClientRect();s=Math.max(s,g.left),o=Math.min(o,g.right),c=Math.max(c,g.top),u=Math.min(h==t.parentNode?r.innerHeight:u,g.bottom)}h=m.position=="absolute"||m.position=="fixed"?d.offsetParent:d.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:s-n.left,right:Math.max(s,o)-n.left,top:c-(n.top+e),bottom:Math.max(c,u)-(n.top+e)}}function Ate(t){let e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView||window;return e.left<n.innerWidth&&e.right>0&&e.top<n.innerHeight&&e.bottom>0}function _te(t,e){let n=t.getBoundingClientRect();return{left:0,right:n.right-n.left,top:e,bottom:n.bottom-(n.top+e)}}class cw{constructor(e,n,i,r){this.from=e,this.to=n,this.size=i,this.displaySize=r}static same(e,n){if(e.length!=n.length)return!1;for(let i=0;i<e.length;i++){let r=e[i],s=n[i];if(r.from!=s.from||r.to!=s.to||r.size!=s.size)return!1}return!0}draw(e,n){return Le.replace({widget:new Ote(this.displaySize*(n?e.scaleY:e.scaleX),n)}).range(this.from,this.to)}}class Ote extends mr{constructor(e,n){super(),this.size=e,this.vertical=n}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}}class a5{constructor(e,n){this.view=e,this.state=n,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=o5,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=yt.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let i=n.facet(dC).some(r=>typeof r!="function"&&r.class=="cm-lineWrapping");this.heightOracle=new yte(i),this.stateDeco=l5(n),this.heightMap=Nn.empty().applyChanges(this.stateDeco,tt.empty,this.heightOracle.setDoc(n.doc),[new Ci(0,0,0,n.doc.length)]);for(let r=0;r<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());r++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Le.set(this.lineGaps.map(r=>r.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:n}=this.state.selection;for(let i=0;i<=1;i++){let r=i?n.head:n.anchor;if(!e.some(({from:s,to:o})=>r>=s&&r<=o)){let{from:s,to:o}=this.lineBlockAt(r);e.push(new jh(s,o))}}return this.viewports=e.sort((i,r)=>i.from-r.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?o5:new vC(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(Fc(e,this.scaler))})}update(e,n=null){this.state=e.state;let i=this.stateDeco;this.stateDeco=l5(this.state);let r=e.changedRanges,s=Ci.extendWithRanges(r,Ste(i,this.stateDeco,e?e.changes:en.empty(this.state.doc.length))),o=this.heightMap.height,c=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);r5(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),s),(this.heightMap.height!=o||yl)&&(e.flags|=2),c?(this.scrollAnchorPos=e.changes.mapPos(c.from,-1),this.scrollAnchorHeight=c.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let u=s.length?this.mapViewport(this.viewport,e.changes):this.viewport;(n&&(n.range.head<u.from||n.range.head>u.to)||!this.viewportIsAppropriate(u))&&(u=this.getViewport(0,n));let h=u.from!=this.viewport.from||u.to!=this.viewport.to;this.viewport=u,e.flags|=this.updateForViewport(),(h||!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),n&&(this.scrollTarget=n),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(b6)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,n=e.contentDOM,i=window.getComputedStyle(n),r=this.heightOracle,s=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?yt.RTL:yt.LTR;let o=this.heightOracle.mustRefreshForWrapping(s)||this.mustMeasureContent==="refresh",c=n.getBoundingClientRect(),u=o||this.mustMeasureContent||this.contentDOMHeight!=c.height;this.contentDOMHeight=c.height,this.mustMeasureContent=!1;let h=0,d=0;if(c.width&&c.height){let{scaleX:T,scaleY:M}=t6(n,c);(T>.005&&Math.abs(this.scaleX-T)>.005||M>.005&&Math.abs(this.scaleY-M)>.005)&&(this.scaleX=T,this.scaleY=M,h|=16,o=u=!0)}let m=(parseInt(i.paddingTop)||0)*this.scaleY,g=(parseInt(i.paddingBottom)||0)*this.scaleY;(this.paddingTop!=m||this.paddingBottom!=g)&&(this.paddingTop=m,this.paddingBottom=g,h|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(u=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=16);let y=n6(this.view.contentDOM,!1).y;y!=this.scrollParent&&(this.scrollParent=y,this.scrollAnchorHeight=-1,this.scrollOffset=0);let x=this.getScrollOffset();this.scrollOffset!=x&&(this.scrollAnchorHeight=-1,this.scrollOffset=x),this.scrolledToBottom=r6(this.scrollParent||e.win);let w=(this.printing?_te:kte)(n,this.paddingTop),S=w.top-this.pixelViewport.top,C=w.bottom-this.pixelViewport.bottom;this.pixelViewport=w;let A=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(A!=this.inView&&(this.inView=A,A&&(u=!0)),!this.inView&&!this.scrollTarget&&!Ate(e.dom))return 0;let O=c.width;if((this.contentDOMWidth!=O||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=c.width,this.editorHeight=e.scrollDOM.clientHeight,h|=16),u){let T=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(T)&&(o=!0),o||r.lineWrapping&&Math.abs(O-this.contentDOMWidth)>r.charWidth){let{lineHeight:M,charWidth:R,textHeight:z}=e.docView.measureTextSize();o=M>0&&r.refresh(s,M,R,z,Math.max(5,O/R),T),o&&(e.docView.minWidth=0,h|=16)}S>0&&C>0?d=Math.max(S,C):S<0&&C<0&&(d=Math.min(S,C)),r5();for(let M of this.viewports){let R=M.from==this.viewport.from?T:e.docView.measureVisibleLineHeights(M);this.heightMap=(o?Nn.empty().applyChanges(this.stateDeco,tt.empty,this.heightOracle,[new Ci(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,o,new vte(M.from,R))}yl&&(h|=2)}let E=!this.viewportIsAppropriate(this.viewport,d)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return E&&(h&2&&(h|=this.updateScaler()),this.viewport=this.getViewport(d,this.scrollTarget),h|=this.updateForViewport()),(h&2||E)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,n){let i=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),r=this.heightMap,s=this.heightOracle,{visibleTop:o,visibleBottom:c}=this,u=new jh(r.lineAt(o-i*1e3,xt.ByHeight,s,0,0).from,r.lineAt(c+(1-i)*1e3,xt.ByHeight,s,0,0).to);if(n){let{head:h}=n.range;if(h<u.from||h>u.to){let d=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),m=r.lineAt(h,xt.ByPos,s,0,0),g;n.y=="center"?g=(m.top+m.bottom)/2-d/2:n.y=="start"||n.y=="nearest"&&h<u.from?g=m.top:g=m.bottom-d,u=new jh(r.lineAt(g-1e3/2,xt.ByHeight,s,0,0).from,r.lineAt(g+d+1e3/2,xt.ByHeight,s,0,0).to)}}return u}mapViewport(e,n){let i=n.mapPos(e.from,-1),r=n.mapPos(e.to,1);return new jh(this.heightMap.lineAt(i,xt.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(r,xt.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:n},i=0){if(!this.inView)return!0;let{top:r}=this.heightMap.lineAt(e,xt.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(n,xt.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:c}=this;return(e==0||r<=o-Math.max(10,Math.min(-i,250)))&&(n==this.state.doc.length||s>=c+Math.max(10,Math.min(i,250)))&&r>o-2*1e3&&s<c+2*1e3}mapLineGaps(e,n){if(!e.length||n.empty)return e;let i=[];for(let r of e)n.touchesRange(r.from,r.to)||i.push(new cw(n.mapPos(r.from),n.mapPos(r.to),r.size,r.displaySize));return i}ensureLineGaps(e,n){let i=this.heightOracle.lineWrapping,r=i?1e4:2e3,s=r>>1,o=r<<1;if(this.defaultTextDirection!=yt.LTR&&!i)return[];let c=[],u=(d,m,g,y)=>{if(m-d<s)return;let x=this.state.selection.main,w=[x.from];x.empty||w.push(x.to);for(let C of w)if(C>d&&C<m){u(d,C-10,g,y),u(C+10,m,g,y);return}let S=Tte(e,C=>C.from>=g.from&&C.to<=g.to&&Math.abs(C.from-d)<s&&Math.abs(C.to-m)<s&&!w.some(A=>C.from<A&&C.to>A));if(!S){if(m<g.to&&n&&i&&n.visibleRanges.some(O=>O.from<=m&&O.to>=m)){let O=n.moveToLineBoundary(de.cursor(m),!1,!0).head;O>d&&(m=O)}let C=this.gapSize(g,d,m,y),A=i||C<2e6?C:2e6;S=new cw(d,m,C,A)}c.push(S)},h=d=>{if(d.length<o||d.type!=bn.Text)return;let m=Ete(d.from,d.to,this.stateDeco);if(m.total<o)return;let g=this.scrollTarget?this.scrollTarget.range.head:null,y,x;if(i){let w=r/this.heightOracle.lineLength*this.heightOracle.lineHeight,S,C;if(g!=null){let A=Ph(m,g),O=((this.visibleBottom-this.visibleTop)/2+w)/d.height;S=A-O,C=A+O}else S=(this.visibleTop-d.top-w)/d.height,C=(this.visibleBottom-d.top+w)/d.height;y=Ih(m,S),x=Ih(m,C)}else{let w=m.total*this.heightOracle.charWidth,S=r*this.heightOracle.charWidth,C=0;if(w>2e6)for(let M of e)M.from>=d.from&&M.from<d.to&&M.size!=M.displaySize&&M.from*this.heightOracle.charWidth+C<this.pixelViewport.left&&(C=M.size-M.displaySize);let A=this.pixelViewport.left+C,O=this.pixelViewport.right+C,E,T;if(g!=null){let M=Ph(m,g),R=((O-A)/2+S)/w;E=M-R,T=M+R}else E=(A-S)/w,T=(O+S)/w;y=Ih(m,E),x=Ih(m,T)}y>d.from&&u(d.from,y,d,m),x<d.to&&u(x,d.to,d,m)};for(let d of this.viewportLines)Array.isArray(d.type)?d.type.forEach(h):h(d);return c}gapSize(e,n,i,r){let s=Ph(r,i)-Ph(r,n);return this.heightOracle.lineWrapping?e.height*s:r.total*this.heightOracle.charWidth*s}updateLineGaps(e){cw.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=Le.set(e.map(n=>n.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let n=this.stateDeco;this.lineGaps.length&&(n=n.concat(this.lineGapDeco));let i=[];Ye.spans(n,this.viewport.from,this.viewport.to,{span(s,o){i.push({from:s,to:o})},point(){}},20);let r=0;if(i.length!=this.visibleRanges.length)r=12;else for(let s=0;s<i.length&&!(r&8);s++){let o=this.visibleRanges[s],c=i[s];(o.from!=c.from||o.to!=c.to)&&(r|=4,e&&e.mapPos(o.from,-1)==c.from&&e.mapPos(o.to,1)==c.to||(r|=8))}return this.visibleRanges=i,r}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(n=>n.from<=e&&n.to>=e)||Fc(this.heightMap.lineAt(e,xt.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(n=>n.top<=e&&n.bottom>=e)||Fc(this.heightMap.lineAt(this.scaler.fromDOM(e),xt.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 n=this.lineBlockAtHeight(e+8);return n.from>=this.viewport.from||this.viewportLines[0].top-e>200?n:this.viewportLines[0]}elementAtHeight(e){return Fc(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}}class jh{constructor(e,n){this.from=e,this.to=n}}function Ete(t,e,n){let i=[],r=t,s=0;return Ye.spans(n,t,e,{span(){},point(o,c){o>r&&(i.push({from:r,to:o}),s+=o-r),r=c}},20),r<e&&(i.push({from:r,to:e}),s+=e-r),{total:s,ranges:i}}function Ih({total:t,ranges:e},n){if(n<=0)return e[0].from;if(n>=1)return e[e.length-1].to;let i=Math.floor(t*n);for(let r=0;;r++){let{from:s,to:o}=e[r],c=o-s;if(i<=c)return s+i;i-=c}}function Ph(t,e){let n=0;for(let{from:i,to:r}of t.ranges){if(e<=r){n+=e-i;break}n+=r-i}return n/t.total}function Tte(t,e){for(let n of t)if(e(n))return n}const o5={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};function l5(t){let e=t.facet(qp).filter(i=>typeof i!="function"),n=t.facet(pC).filter(i=>typeof i!="function");return n.length&&e.push(Ye.join(n)),e}class vC{constructor(e,n,i){let r=0,s=0,o=0;this.viewports=i.map(({from:c,to:u})=>{let h=n.lineAt(c,xt.ByPos,e,0,0).top,d=n.lineAt(u,xt.ByPos,e,0,0).bottom;return r+=d-h,{from:c,to:u,top:h,bottom:d,domTop:0,domBottom:0}}),this.scale=(7e6-r)/(n.height-r);for(let c of this.viewports)c.domTop=o+(c.top-s)*this.scale,o=c.domBottom=c.domTop+(c.bottom-c.top),s=c.bottom}toDOM(e){for(let n=0,i=0,r=0;;n++){let s=n<this.viewports.length?this.viewports[n]:null;if(!s||e<s.top)return r+(e-i)*this.scale;if(e<=s.bottom)return s.domTop+(e-s.top);i=s.bottom,r=s.domBottom}}fromDOM(e){for(let n=0,i=0,r=0;;n++){let s=n<this.viewports.length?this.viewports[n]:null;if(!s||e<s.domTop)return i+(e-r)/this.scale;if(e<=s.domBottom)return s.top+(e-s.domTop);i=s.bottom,r=s.domBottom}}eq(e){return e instanceof vC?this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every((n,i)=>n.from==e.viewports[i].from&&n.to==e.viewports[i].to):!1}}function Fc(t,e){if(e.scale==1)return t;let n=e.toDOM(t.top),i=e.toDOM(t.bottom);return new Li(t.from,t.length,n,i-n,Array.isArray(t._content)?t._content.map(r=>Fc(r,e)):t._content)}const Hh=ke.define({combine:t=>t.join(" ")}),jS=ke.define({combine:t=>t.indexOf(!0)>-1}),IS=Ys.newName(),H6=Ys.newName(),U6=Ys.newName(),V6={"&light":"."+H6,"&dark":"."+U6};function PS(t,e,n){return new Ys(e,{finish(i){return/&/.test(i)?i.replace(/&\w*/,r=>{if(r=="&")return t;if(!n||!n[r])throw new RangeError(`Unsupported selector: ${r}`);return n[r]}):t+" "+i}})}const Mte=PS("."+IS,{"&":{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-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"}},V6),Rte={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},uw=Ce.ie&&Ce.ie_version<=11;class Nte{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new lee,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(n=>{for(let i of n)this.queue.push(i);(Ce.ie&&Ce.ie_version<=11||Ce.ios&&e.composing)&&n.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Ce.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Ce.chrome&&Ce.chrome_version<126)&&(this.editContext=new Lte(e),e.state.facet(Fr)&&(e.contentDOM.editContext=this.editContext.editContext)),uw&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.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(()=>{var n;((n=this.view.docView)===null||n===void 0?void 0:n.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(n=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),n.length>0&&n[n.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(n=>{n.length>0&&n[n.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((n,i)=>n!=e[i]))){this.gapIntersection.disconnect();for(let n of e)this.gapIntersection.observe(n);this.gaps=e}}onSelectionChange(e){let n=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,r=this.selectionRange;if(i.state.facet(Fr)?i.root.activeElement!=this.dom:!Qc(this.dom,r))return;let s=r.anchorNode&&i.docView.tile.nearest(r.anchorNode);if(s&&s.isWidget()&&s.widget.ignoreEvent(e)){n||(this.selectionChanged=!1);return}(Ce.ie&&Ce.ie_version<=11||Ce.android&&Ce.chrome)&&!i.state.selection.main.empty&&r.focusNode&&Wc(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,n=gu(e.root);if(!n)return!1;let i=Ce.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&Dte(this.view,n)||n;if(!i||this.selectionRange.eq(i))return!1;let r=Qc(this.dom,i);return r&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&uee(this.dom,i)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(i),r&&(this.selectionChanged=!0),!0)}setSelectionRange(e,n){this.selectionRange.set(e.node,e.offset,n.node,n.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,n=null;for(let i=this.dom;i;)if(i.nodeType==1)!n&&e<this.scrollTargets.length&&this.scrollTargets[e]==i?e++:n||(n=this.scrollTargets.slice(0,e)),n&&n.push(i),i=i.assignedSlot||i.parentNode;else if(i.nodeType==11)i=i.host;else break;if(e<this.scrollTargets.length&&!n&&(n=this.scrollTargets.slice(0,e)),n){for(let i of this.scrollTargets)i.removeEventListener("scroll",this.onScroll);for(let i of this.scrollTargets=n)i.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,Rte),uw&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),uw&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,n){var i;if(!this.delayedAndroidKey){let r=()=>{let s=this.delayedAndroidKey;s&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=s.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&s.force&&sl(this.dom,s.key,s.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(r)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:n,force:this.lastChange<Date.now()-50||!!(!((i=this.delayedAndroidKey)===null||i===void 0)&&i.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 n=-1,i=-1,r=!1;for(let s of e){let o=this.readMutation(s);o&&(o.typeOver&&(r=!0),n==-1?{from:n,to:i}=o:(n=Math.min(o.from,n),i=Math.max(o.to,i)))}return{from:n,to:i,typeOver:r}}readChange(){let{from:e,to:n,typeOver:i}=this.processRecords(),r=this.selectionChanged&&Qc(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 s=new Kee(this.view,e,n,i);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let i=this.view.state,r=M6(this.view,n);return this.view.state==i&&(n.domChanged||n.newSel&&!Hd(this.view.state.selection,n.newSel.main))&&this.view.update([]),r}readMutation(e){let n=this.view.docView.tile.nearest(e.target);if(!n||n.isWidget())return null;if(n.markDirty(e.type=="attributes"),e.type=="childList"){let i=c5(n,e.previousSibling||e.target.previousSibling,-1),r=c5(n,e.nextSibling||e.target.nextSibling,1);return{from:i?n.posAfter(i):n.posAtStart,to:r?n.posBefore(r):n.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}: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(Fr)!=e.state.facet(Fr)&&(e.view.contentDOM.editContext=e.state.facet(Fr)?this.editContext.editContext:null))}destroy(){var e,n,i;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(n=this.gapIntersection)===null||n===void 0||n.disconnect(),(i=this.resizeScroll)===null||i===void 0||i.disconnect();for(let r of this.scrollTargets)r.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 c5(t,e,n){for(;e;){let i=Lt.get(e);if(i&&i.parent==t)return i;let r=e.parentNode;e=r!=t.dom?r:n>0?e.nextSibling:e.previousSibling}return null}function u5(t,e){let n=e.startContainer,i=e.startOffset,r=e.endContainer,s=e.endOffset,o=t.docView.domAtPos(t.state.selection.main.anchor,1);return Wc(o.node,o.offset,r,s)&&([n,i,r,s]=[r,s,n,i]),{anchorNode:n,anchorOffset:i,focusNode:r,focusOffset:s}}function Dte(t,e){if(e.getComposedRanges){let r=e.getComposedRanges(t.root)[0];if(r)return u5(t,r)}let n=null;function i(r){r.preventDefault(),r.stopImmediatePropagation(),n=r.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",i,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",i,!0),n?u5(t,n):null}class Lte{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let n=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=i=>{let r=e.state.selection.main,{anchor:s,head:o}=r,c=this.toEditorPos(i.updateRangeStart),u=this.toEditorPos(i.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:i.updateRangeStart,editorBase:c,drifted:!1});let h=u-c>i.text.length;c==this.from&&s<this.from?c=s:u==this.to&&s>this.to&&(u=s);let d=R6(e.state.sliceDoc(c,u),i.text,(h?r.from:r.to)-c,h?"end":null);if(!d){let g=de.single(this.toEditorPos(i.selectionStart),this.toEditorPos(i.selectionEnd));Hd(g,r)||e.dispatch({selection:g,userEvent:"select"});return}let m={from:d.from+c,to:d.toA+c,insert:tt.of(i.text.slice(d.from,d.toB).split(`
|
|
49
49
|
`))};if((Ce.mac||Ce.android)&&m.from==o-1&&/^\. ?$/.test(i.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(m={from:c,to:u,insert:tt.of([i.text.replace("."," ")])}),this.pendingContextChange=m,!e.state.readOnly){let g=this.to-this.from+(m.to-m.from+m.insert.length);gC(e,m,de.single(this.toEditorPos(i.selectionStart,g),this.toEditorPos(i.selectionEnd,g)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),m.from<m.to&&!m.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(n.text.slice(Math.max(0,i.updateRangeStart-1),Math.min(n.text.length,i.updateRangeStart+1)))&&this.handlers.compositionend(i)},this.handlers.characterboundsupdate=i=>{let r=[],s=null;for(let o=this.toEditorPos(i.rangeStart),c=this.toEditorPos(i.rangeEnd);o<c;o++){let u=e.coordsForChar(o);s=u&&new DOMRect(u.left,u.top,u.right-u.left,u.bottom-u.top)||s||new DOMRect,r.push(s)}n.updateCharacterBounds(i.rangeStart,r)},this.handlers.textformatupdate=i=>{let r=[];for(let s of i.getTextFormats()){let o=s.underlineStyle,c=s.underlineThickness;if(!/none/i.test(o)&&!/none/i.test(c)){let u=this.toEditorPos(s.rangeStart),h=this.toEditorPos(s.rangeEnd);if(u<h){let d=`text-decoration: underline ${/^[a-z]/.test(o)?o+" ":o=="Dashed"?"dashed ":o=="Squiggle"?"wavy ":""}${/thin/i.test(c)?1:2}px`;r.push(Le.mark({attributes:{style:d}}).range(u,h))}}}e.dispatch({effects:w6.of(Le.set(r))})},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:i}=this.composing;this.composing=null,i&&this.reset(e.state)}};for(let i in this.handlers)n.addEventListener(i,this.handlers[i]);this.measureReq={read:i=>{this.editContext.updateControlBounds(i.contentDOM.getBoundingClientRect());let r=gu(i.root);r&&r.rangeCount&&this.editContext.updateSelectionBounds(r.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let n=0,i=!1,r=this.pendingContextChange;return e.changes.iterChanges((s,o,c,u,h)=>{if(i)return;let d=h.length-(o-s);if(r&&o>=r.to)if(r.from==s&&r.to==o&&r.insert.eq(h)){r=this.pendingContextChange=null,n+=d,this.to+=d;return}else r=null,this.revertPending(e.state);if(s+=n,o+=n,o<=this.from)this.from+=d,this.to+=d;else if(s<this.to){if(s<this.from||o>this.to||this.to-this.from+h.length>3e4){i=!0;return}this.editContext.updateText(this.toContextPos(s),this.toContextPos(o),h.toString()),this.to+=d}n+=d}),r&&!i&&this.revertPending(e.state),!i}update(e){let n=this.pendingContextChange,i=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(i.from,i.to)&&e.transactions.some(r=>!r.isUserEvent("input.type")&&r.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||n)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:n}=e.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(e.doc.length,n+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 n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.from+n.insert.length),e.doc.sliceString(n.from,n.to))}setSelection(e){let{main:n}=e.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),r=this.toContextPos(n.head);(this.editContext.selectionStart!=i||this.editContext.selectionEnd!=r)&&this.editContext.updateSelection(i,r)}rangeIsValid(e){let{head:n}=e.selection.main;return!(this.from>0&&n-this.from<500||this.to<e.doc.length&&this.to-n<500||this.to-this.from>1e4*3)}toEditorPos(e,n=this.to-this.from){e=Math.min(e,n);let i=this.composing;return i&&i.drifted?i.editorBase+(e-i.contextBase):e+this.from}toContextPos(e){let n=this.composing;return n&&n.drifted?n.contextBase+(e-n.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class Se{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={}){var n;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:i}=e;this.dispatchTransactions=e.dispatchTransactions||i&&(r=>r.forEach(s=>i(s,this)))||(r=>this.update(r)),this.dispatch=this.dispatch.bind(this),this._root=e.root||cee(e.parent)||document,this.viewState=new a5(this,e.state||Je.create(e)),e.scrollTo&&e.scrollTo.is(zh)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Qo).map(r=>new rw(r));for(let r of this.plugins)r.update(this);this.observer=new Nte(this),this.inputState=new tte(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Y3(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let n=e.length==1&&e[0]instanceof Qt?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(n,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,i=!1,r,s=this.state;for(let g of e){if(g.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=g.state}if(this.destroyed){this.viewState.state=s;return}let o=this.hasFocus,c=0,u=null;e.some(g=>g.annotation(q6))?(this.inputState.notifiedFocused=o,c=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,u=j6(s,o),u||(c=1));let h=this.observer.delayedAndroidKey,d=null;if(h?(this.observer.clearDelayedAndroidKey(),d=this.observer.readChange(),(d&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(d=null)):this.observer.clear(),s.facet(Je.phrases)!=this.state.facet(Je.phrases))return this.setState(s);r=jd.create(this,s,e),r.flags|=c;let m=this.viewState.scrollTarget;try{this.updateState=2;for(let g of e){if(m&&(m=m.map(g.changes)),g.scrollIntoView){let{main:y}=g.state.selection;m=new al(y.empty?y:de.cursor(y.head,y.head>y.anchor?-1:1))}for(let y of g.effects)y.is(zh)&&(m=y.value.clip(this.state))}this.viewState.update(r,m),this.bidiCache=Vd.update(this.bidiCache,r.changes),r.empty||(this.updatePlugins(r),this.inputState.update(r)),n=this.docView.update(r),this.state.facet(Vc)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(g=>g.isUserEvent("select.pointer")))}finally{this.updateState=0}if(r.startState.facet(Hh)!=r.state.facet(Hh)&&(this.viewState.mustMeasureContent=!0),(n||i||m||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!r.empty)for(let g of this.state.facet(DS))try{g(r)}catch(y){Fn(this.state,y,"update listener")}(u||d)&&Promise.resolve().then(()=>{u&&this.state==u.startState&&this.dispatch(u),d&&!M6(this,d)&&h.force&&sl(this.contentDOM,h.key,h.keyCode)})}setState(e){if(this.updateState!=0)throw new 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 n=this.hasFocus;try{for(let i of this.plugins)i.destroy(this);this.viewState=new a5(this,e),this.plugins=e.facet(Qo).map(i=>new rw(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new Y3(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(e){let n=e.startState.facet(Qo),i=e.state.facet(Qo);if(n!=i){let r=[];for(let s of i){let o=n.indexOf(s);if(o<0)r.push(new rw(s));else{let c=this.plugins[o];c.mustUpdate=e,r.push(c)}}for(let s of this.plugins)s.mustUpdate!=e&&s.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let r of this.plugins)r.mustUpdate=e;for(let r=0;r<this.plugins.length;r++)this.plugins[r].update(this);n!=i&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let n=e.value;if(n&&n.docViewUpdate)try{n.docViewUpdate(this)}catch(i){Fn(this.state,i,"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 n=null,i=this.viewState.scrollParent,r=this.viewState.getScrollOffset(),{scrollAnchorPos:s,scrollAnchorHeight:o}=this.viewState;Math.abs(r-this.viewState.scrollOffset)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let c=0;;c++){if(o<0)if(r6(i||this.win))s=-1,o=this.viewState.heightMap.height;else{let y=this.viewState.scrollAnchorAt(r);s=y.from,o=y.top}this.updateState=1;let u=this.viewState.measure();if(!u&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(c>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let h=[];u&4||([this.measureRequests,h]=[h,this.measureRequests]);let d=h.map(y=>{try{return y.read(this)}catch(x){return Fn(this.state,x),f5}}),m=jd.create(this,this.state,[]),g=!1;m.flags|=u,n?n.flags|=u:n=m,this.updateState=2,m.empty||(this.updatePlugins(m),this.inputState.update(m),this.updateAttrs(),g=this.docView.update(m),g&&this.docViewUpdate());for(let y=0;y<h.length;y++)if(d[y]!=f5)try{let x=h[y];x.write&&x.write(d[y],this)}catch(x){Fn(this.state,x)}if(g&&this.docView.updateSelection(!0),!m.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}else{let x=((s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)-o)/this.scaleY;if((x>1||x<-1)&&(i==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){r=r+x,i?i.scrollTop+=x:this.win.scrollBy(0,x),o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let c of this.state.facet(DS))c(n)}get themeClasses(){return IS+" "+(this.state.facet(jS)?U6:H6)+" "+this.state.facet(Hh)}updateAttrs(){let e=h5(this,S6,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Fr)?"true":"false",class:"cm-content",style:`${Ce.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),h5(this,dC,n);let i=this.observer.ignore(()=>{let r=H3(this.contentDOM,this.contentAttrs,n),s=H3(this.dom,this.editorAttrs,e);return r||s});return this.editorAttrs=e,this.contentAttrs=n,i}showAnnouncements(e){let n=!0;for(let i of e)for(let r of i.effects)if(r.is(Se.announce)){n&&(this.announceDOM.textContent=""),n=!1;let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=r.value}}mountStyles(){this.styleModules=this.state.facet(Vc);let e=this.state.facet(Se.cspNonce);Ys.mount(this.root,this.styleModules.concat(Mte).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new 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 n=0;n<this.measureRequests.length;n++)if(this.measureRequests[n].key===e.key){this.measureRequests[n]=e;return}}this.measureRequests.push(e)}}plugin(e){let n=this.pluginMap.get(e);return(n===void 0||n&&n.plugin!=e)&&this.pluginMap.set(e,n=this.plugins.find(i=>i.plugin==e)||null),n&&n.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,n,i){return lw(this,e,Q3(this,e,n,i))}moveByGroup(e,n){return lw(this,e,Q3(this,e,n,i=>$ee(this,e.head,i)))}visualLineSide(e,n){let i=this.bidiSpans(e),r=this.textDirectionAt(e.from),s=i[n?i.length-1:0];return de.cursor(s.side(n,r)+e.from,s.forward(!n,r)?1:-1)}moveToLineBoundary(e,n,i=!0){return Fee(this,e,n,i)}moveVertically(e,n,i){return lw(this,e,Gee(this,e,n,i))}domAtPos(e,n=1){return this.docView.domAtPos(e,n)}posAtDOM(e,n=0){return this.docView.posFromDOM(e,n)}posAtCoords(e,n=!0){this.readMeasured();let i=BS(this,e,n);return i&&i.pos}posAndSideAtCoords(e,n=!0){return this.readMeasured(),BS(this,e,n)}coordsAtPos(e,n=1){this.readMeasured();let i=this.docView.coordsAt(e,n);if(!i||i.left==i.right)return i;let r=this.state.doc.lineAt(e),s=this.bidiSpans(r),o=s[sr.find(s,e-r.from,-1,n)];return yu(i,o.dir==yt.LTR==n>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(v6)||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>zte)return u6(e.length);let n=this.textDirectionAt(e.from),i;for(let s of this.bidiCache)if(s.from==e.from&&s.dir==n&&(s.fresh||c6(s.isolates,i=F3(this,e))))return s.order;i||(i=F3(this,e));let r=yee(e.text,n,i);return this.bidiCache.push(new Vd(e.from,e.to,n,i,!0,r)),r}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Ce.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{i6(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,n={}){return zh.of(new al(typeof e=="number"?de.cursor(e):e,n.y,n.x,n.yMargin,n.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:n}=this.scrollDOM,i=this.viewState.scrollAnchorAt(e);return zh.of(new al(de.cursor(i.from),"start","start",i.top-e,n,!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 zt.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return zt.define(()=>({}),{eventObservers:e})}static theme(e,n){let i=Ys.newName(),r=[Hh.of(i),Vc.of(PS(`.${i}`,e))];return n&&n.dark&&r.push(jS.of(!0)),r}static baseTheme(e){return Za.lowest(Vc.of(PS("."+IS,e,V6)))}static findFromDOM(e){var n;let i=e.querySelector(".cm-content"),r=i&&Lt.get(i)||Lt.get(e);return((n=r?.root)===null||n===void 0?void 0:n.view)||null}}Se.styleModule=Vc;Se.inputHandler=g6;Se.clipboardInputFilter=fC;Se.clipboardOutputFilter=hC;Se.scrollHandler=x6;Se.focusChangeEffect=y6;Se.perLineTextDirection=v6;Se.exceptionSink=m6;Se.updateListener=DS;Se.editable=Fr;Se.mouseSelectionStyle=p6;Se.dragMovesSelection=d6;Se.clickAddsSelectionRange=h6;Se.decorations=qp;Se.blockWrappers=C6;Se.outerDecorations=pC;Se.atomicRanges=Uu;Se.bidiIsolatedRanges=k6;Se.scrollMargins=A6;Se.darkTheme=jS;Se.cspNonce=ke.define({combine:t=>t.length?t[0]:""});Se.contentAttributes=dC;Se.editorAttributes=S6;Se.lineWrapping=Se.contentAttributes.of({class:"cm-lineWrapping"});Se.announce=je.define();const zte=4096,f5={};class Vd{constructor(e,n,i,r,s,o){this.from=e,this.to=n,this.dir=i,this.isolates=r,this.fresh=s,this.order=o}static update(e,n){if(n.empty&&!e.some(s=>s.fresh))return e;let i=[],r=e.length?e[e.length-1].dir:yt.LTR;for(let s=Math.max(0,e.length-10);s<e.length;s++){let o=e[s];o.dir==r&&!n.touchesRange(o.from,o.to)&&i.push(new Vd(n.mapPos(o.from,1),n.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return i}}function h5(t,e,n){for(let i=t.state.facet(e),r=i.length-1;r>=0;r--){let s=i[r],o=typeof s=="function"?s(t):s;o&&lC(o,n)}return n}const Bte=Ce.mac?"mac":Ce.windows?"win":Ce.linux?"linux":"key";function qte(t,e){const n=t.split(/-(?!$)/);let i=n[n.length-1];i=="Space"&&(i=" ");let r,s,o,c;for(let u=0;u<n.length-1;++u){const h=n[u];if(/^(cmd|meta|m)$/i.test(h))c=!0;else if(/^a(lt)?$/i.test(h))r=!0;else if(/^(c|ctrl|control)$/i.test(h))s=!0;else if(/^s(hift)?$/i.test(h))o=!0;else if(/^mod$/i.test(h))e=="mac"?c=!0:s=!0;else throw new Error("Unrecognized modifier name: "+h)}return r&&(i="Alt-"+i),s&&(i="Ctrl-"+i),c&&(i="Meta-"+i),o&&(i="Shift-"+i),i}function Uh(t,e,n){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n!==!1&&e.shiftKey&&(t="Shift-"+t),t}const jte=Za.default(Se.domEventHandlers({keydown(t,e){return $6(F6(e.state),t,e,"editor")}})),Hp=ke.define({enables:jte}),d5=new WeakMap;function F6(t){let e=t.facet(Hp),n=d5.get(e);return n||d5.set(e,n=Hte(e.reduce((i,r)=>i.concat(r),[]))),n}function Ite(t,e,n){return $6(F6(t.state),e,t,n)}let qs=null;const Pte=4e3;function Hte(t,e=Bte){let n=Object.create(null),i=Object.create(null),r=(o,c)=>{let u=i[o];if(u==null)i[o]=c;else if(u!=c)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},s=(o,c,u,h,d)=>{var m,g;let y=n[o]||(n[o]=Object.create(null)),x=c.split(/ (?!$)/).map(C=>qte(C,e));for(let C=1;C<x.length;C++){let A=x.slice(0,C).join(" ");r(A,!0),y[A]||(y[A]={preventDefault:!0,stopPropagation:!1,run:[O=>{let E=qs={view:O,prefix:A,scope:o};return setTimeout(()=>{qs==E&&(qs=null)},Pte),!0}]})}let w=x.join(" ");r(w,!1);let S=y[w]||(y[w]={preventDefault:!1,stopPropagation:!1,run:((g=(m=y._any)===null||m===void 0?void 0:m.run)===null||g===void 0?void 0:g.slice())||[]});u&&S.run.push(u),h&&(S.preventDefault=!0),d&&(S.stopPropagation=!0)};for(let o of t){let c=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let h of c){let d=n[h]||(n[h]=Object.create(null));d._any||(d._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:m}=o;for(let g in d)d[g].run.push(y=>m(y,HS))}let u=o[e]||o.key;if(u)for(let h of c)s(h,u,o.run,o.preventDefault,o.stopPropagation),o.shift&&s(h,"Shift-"+u,o.shift,o.preventDefault,o.stopPropagation)}return n}let HS=null;function $6(t,e,n,i){HS=e;let r=tee(e),s=In(r,0),o=ir(s)==r.length&&r!=" ",c="",u=!1,h=!1,d=!1;qs&&qs.view==n&&qs.scope==i&&(c=qs.prefix+" ",D6.indexOf(e.keyCode)<0&&(h=!0,qs=null));let m=new Set,g=S=>{if(S){for(let C of S.run)if(!m.has(C)&&(m.add(C),C(n)))return S.stopPropagation&&(d=!0),!0;S.preventDefault&&(S.stopPropagation&&(d=!0),h=!0)}return!1},y=t[i],x,w;return y&&(g(y[c+Uh(r,e,!o)])?u=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Ce.windows&&e.ctrlKey&&e.altKey)&&!(Ce.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(x=Qs[e.keyCode])&&x!=r?(g(y[c+Uh(x,e,!0)])||e.shiftKey&&(w=pu[e.keyCode])!=r&&w!=x&&g(y[c+Uh(w,e,!1)]))&&(u=!0):o&&e.shiftKey&&g(y[c+Uh(r,e,!0)])&&(u=!0),!u&&g(y._any)&&(u=!0)),h&&(u=!0),u&&d&&e.stopPropagation(),HS=null,u}class Vu{constructor(e,n,i,r,s){this.className=e,this.left=n,this.top=i,this.width=r,this.height=s}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,n){return n.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,n,i){if(i.empty){let r=e.coordsAtPos(i.head,i.assoc||1);if(!r)return[];let s=G6(e);return[new Vu(n,r.left-s.left,r.top-s.top,null,r.bottom-r.top)]}else return Ute(e,n,i)}}function G6(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==yt.LTR?e.left:e.right-t.scrollDOM.clientWidth*t.scaleX)-t.scrollDOM.scrollLeft*t.scaleX,top:e.top-t.scrollDOM.scrollTop*t.scaleY}}function p5(t,e,n,i){let r=t.coordsAtPos(e,n*2);if(!r)return i;let s=t.dom.getBoundingClientRect(),o=(r.top+r.bottom)/2,c=t.posAtCoords({x:s.left+1,y:o}),u=t.posAtCoords({x:s.right-1,y:o});return c==null||u==null?i:{from:Math.max(i.from,Math.min(c,u)),to:Math.min(i.to,Math.max(c,u))}}function Ute(t,e,n){if(n.to<=t.viewport.from||n.from>=t.viewport.to)return[];let i=Math.max(n.from,t.viewport.from),r=Math.min(n.to,t.viewport.to),s=t.textDirection==yt.LTR,o=t.contentDOM,c=o.getBoundingClientRect(),u=G6(t),h=o.querySelector(".cm-line"),d=h&&window.getComputedStyle(h),m=c.left+(d?parseInt(d.paddingLeft)+Math.min(0,parseInt(d.textIndent)):0),g=c.right-(d?parseInt(d.paddingRight):0),y=zS(t,i,1),x=zS(t,r,-1),w=y.type==bn.Text?y:null,S=x.type==bn.Text?x:null;if(w&&(t.lineWrapping||y.widgetLineBreaks)&&(w=p5(t,i,1,w)),S&&(t.lineWrapping||x.widgetLineBreaks)&&(S=p5(t,r,-1,S)),w&&S&&w.from==S.from&&w.to==S.to)return A(O(n.from,n.to,w));{let T=w?O(n.from,null,w):E(y,!1),M=S?O(null,n.to,S):E(x,!0),R=[];return(w||y).to<(S||x).from-(w&&S?1:0)||y.widgetLineBreaks>1&&T.bottom+t.defaultLineHeight/2<M.top?R.push(C(m,T.bottom,g,M.top)):T.bottom<M.top&&t.elementAtHeight((T.bottom+M.top)/2).type==bn.Text&&(T.bottom=M.top=(T.bottom+M.top)/2),A(T).concat(R).concat(A(M))}function C(T,M,R,z){return new Vu(e,T-u.left,M-u.top,Math.max(0,R-T),z-M)}function A({top:T,bottom:M,horizontal:R}){let z=[];for(let q=0;q<R.length;q+=2)z.push(C(R[q],T,R[q+1],M));return z}function O(T,M,R){let z=1e9,q=-1e9,U=[];function P(L,Y,D,Q,ee){let G=t.coordsAtPos(L,L==R.to?-2:2),W=t.coordsAtPos(D,D==R.from?2:-2);!G||!W||(z=Math.min(G.top,W.top,z),q=Math.max(G.bottom,W.bottom,q),ee==yt.LTR?U.push(s&&Y?m:G.left,s&&Q?g:W.right):U.push(!s&&Q?m:W.left,!s&&Y?g:G.right))}let $=T??R.from,K=M??R.to;for(let L of t.visibleRanges)if(L.to>$&&L.from<K)for(let Y=Math.max(L.from,$),D=Math.min(L.to,K);;){let Q=t.state.doc.lineAt(Y);for(let ee of t.bidiSpans(Q)){let G=ee.from+Q.from,W=ee.to+Q.from;if(G>=D)break;W>Y&&P(Math.max(G,Y),T==null&&G<=$,Math.min(W,D),M==null&&W>=K,ee.dir)}if(Y=Q.to+1,Y>=D)break}return U.length==0&&P($,T==null,K,M==null,t.textDirection),{top:z,bottom:q,horizontal:U}}function E(T,M){let R=c.top+(M?T.top:T.bottom);return{top:R,bottom:R,horizontal:[]}}}function Vte(t,e){return t.constructor==e.constructor&&t.eq(e)}class Fte{constructor(e,n){this.view=e,this.layer=n,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),n.above&&this.dom.classList.add("cm-layer-above"),n.class&&this.dom.classList.add(n.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),n.mount&&n.mount(this.dom,e)}update(e){e.startState.facet(cd)!=e.state.facet(cd)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let n=0,i=e.facet(cd);for(;n<i.length&&i[n]!=this.layer;)n++;this.dom.style.zIndex=String((this.layer.above?150:-1)-n)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:n}=this.view;(e!=this.scaleX||n!=this.scaleY)&&(this.scaleX=e,this.scaleY=n,this.dom.style.transform=`scale(${1/e}, ${1/n})`)}draw(e){if(e.length!=this.drawn.length||e.some((n,i)=>!Vte(n,this.drawn[i]))){let n=this.dom.firstChild,i=0;for(let r of e)r.update&&n&&r.constructor&&this.drawn[i].constructor&&r.update(n,this.drawn[i])?(n=n.nextSibling,i++):this.dom.insertBefore(r.draw(),n);for(;n;){let r=n.nextSibling;n.remove(),n=r}this.drawn=e,Ce.safari&&Ce.safari_version>=26&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const cd=ke.define();function Y6(t){return[zt.define(e=>new Fte(e,t)),cd.of(t)]}const bu=ke.define({combine(t){return pr(t,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,n)=>Math.min(e,n),drawRangeCursor:(e,n)=>e||n})}});function $te(t={}){return[bu.of(t),Gte,Yte,Qte,b6.of(!0)]}function Q6(t){return t.startState.facet(bu)!=t.state.facet(bu)}const Gte=Y6({above:!0,markers(t){let{state:e}=t,n=e.facet(bu),i=[];for(let r of e.selection.ranges){let s=r==e.selection.main;if(r.empty||n.drawRangeCursor){let o=s?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",c=r.empty?r:de.cursor(r.head,r.head>r.anchor?-1:1);for(let u of Vu.forRange(t,o,c))i.push(u)}}return i},update(t,e){t.transactions.some(i=>i.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let n=Q6(t);return n&&m5(t.state,e),t.docChanged||t.selectionSet||n},mount(t,e){m5(e.state,t)},class:"cm-cursorLayer"});function m5(t,e){e.style.animationDuration=t.facet(bu).cursorBlinkRate+"ms"}const Yte=Y6({above:!1,markers(t){return t.state.selection.ranges.map(e=>e.empty?[]:Vu.forRange(t,"cm-selectionBackground",e)).reduce((e,n)=>e.concat(n))},update(t,e){return t.docChanged||t.selectionSet||t.viewportChanged||Q6(t)},class:"cm-selectionLayer"}),Qte=Za.highest(Se.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),X6=je.define({map(t,e){return t==null?null:e.mapPos(t)}}),$c=_n.define({create(){return null},update(t,e){return t!=null&&(t=e.changes.mapPos(t)),e.effects.reduce((n,i)=>i.is(X6)?i.value:n,t)}}),Xte=zt.fromClass(class{constructor(t){this.view=t,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(t){var e;let n=t.state.field($c);n==null?this.cursor!=null&&((e=this.cursor)===null||e===void 0||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(t.startState.field($c)!=n||t.docChanged||t.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:t}=this,e=t.state.field($c),n=e!=null&&t.coordsAtPos(e);if(!n)return null;let i=t.scrollDOM.getBoundingClientRect();return{left:n.left-i.left+t.scrollDOM.scrollLeft*t.scaleX,top:n.top-i.top+t.scrollDOM.scrollTop*t.scaleY,height:n.bottom-n.top}}drawCursor(t){if(this.cursor){let{scaleX:e,scaleY:n}=this.view;t?(this.cursor.style.left=t.left/e+"px",this.cursor.style.top=t.top/n+"px",this.cursor.style.height=t.height/n+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(t){this.view.state.field($c)!=t&&this.view.dispatch({effects:X6.of(t)})}},{eventObservers:{dragover(t){this.setDropPos(this.view.posAtCoords({x:t.clientX,y:t.clientY}))},dragleave(t){(t.target==this.view.contentDOM||!this.view.contentDOM.contains(t.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function Wte(){return[$c,Xte]}function g5(t,e,n,i,r){e.lastIndex=0;for(let s=t.iterRange(n,i),o=n,c;!s.next().done;o+=s.value.length)if(!s.lineBreak)for(;c=e.exec(s.value);)r(o+c.index,c)}function Kte(t,e){let n=t.visibleRanges;if(n.length==1&&n[0].from==t.viewport.from&&n[0].to==t.viewport.to)return n;let i=[];for(let{from:r,to:s}of n)r=Math.max(t.state.doc.lineAt(r).from,r-e),s=Math.min(t.state.doc.lineAt(s).to,s+e),i.length&&i[i.length-1].to>=r?i[i.length-1].to=s:i.push({from:r,to:s});return i}class Zte{constructor(e){const{regexp:n,decoration:i,decorate:r,boundary:s,maxLength:o=1e3}=e;if(!n.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=n,r)this.addMatch=(c,u,h,d)=>r(d,h,h+c[0].length,c,u);else if(typeof i=="function")this.addMatch=(c,u,h,d)=>{let m=i(c,u,h);m&&d(h,h+c[0].length,m)};else if(i)this.addMatch=(c,u,h,d)=>d(h,h+c[0].length,i);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=s,this.maxLength=o}createDeco(e){let n=new Kr,i=n.add.bind(n);for(let{from:r,to:s}of Kte(e,this.maxLength))g5(e.state.doc,this.regexp,r,s,(o,c)=>this.addMatch(c,e,o,i));return n.finish()}updateDeco(e,n){let i=1e9,r=-1;return e.docChanged&&e.changes.iterChanges((s,o,c,u)=>{u>=e.view.viewport.from&&c<=e.view.viewport.to&&(i=Math.min(c,i),r=Math.max(u,r))}),e.viewportMoved||r-i>1e3?this.createDeco(e.view):r>-1?this.updateRange(e.view,n.map(e.changes),i,r):n}updateRange(e,n,i,r){for(let s of e.visibleRanges){let o=Math.max(s.from,i),c=Math.min(s.to,r);if(c>=o){let u=e.state.doc.lineAt(o),h=u.to<c?e.state.doc.lineAt(c):u,d=Math.max(s.from,u.from),m=Math.min(s.to,h.to);if(this.boundary){for(;o>u.from;o--)if(this.boundary.test(u.text[o-1-u.from])){d=o;break}for(;c<h.to;c++)if(this.boundary.test(h.text[c-h.from])){m=c;break}}let g=[],y,x=(w,S,C)=>g.push(C.range(w,S));if(u==h)for(this.regexp.lastIndex=d-u.from;(y=this.regexp.exec(u.text))&&y.index<m-u.from;)this.addMatch(y,e,y.index+u.from,x);else g5(e.state.doc,this.regexp,d,m,(w,S)=>this.addMatch(S,e,w,x));n=n.update({filterFrom:d,filterTo:m,filter:(w,S)=>w<d||S>m,add:g})}}return n}}const US=/x/.unicode!=null?"gu":"g",Jte=new RegExp(`[\0-\b
|
|
50
50
|
--\u2028\u2029\uFEFF-]`,US),ene={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let fw=null;function tne(){var t;if(fw==null&&typeof document<"u"&&document.body){let e=document.body.style;fw=((t=e.tabSize)!==null&&t!==void 0?t:e.MozTabSize)!=null}return fw||!1}const ud=ke.define({combine(t){let e=pr(t,{render:null,specialChars:Jte,addSpecialChars:null});return(e.replaceTabs=!tne())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,US)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,US)),e}});function nne(t={}){return[ud.of(t),ine()]}let y5=null;function ine(){return y5||(y5=zt.fromClass(class{constructor(t){this.view=t,this.decorations=Le.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(t.state.facet(ud)),this.decorations=this.decorator.createDeco(t)}makeDecorator(t){return new Zte({regexp:t.specialChars,decoration:(e,n,i)=>{let{doc:r}=n.state,s=In(e[0],0);if(s==9){let o=r.lineAt(i),c=n.state.tabSize,u=Ol(o.text,c,i-o.from);return Le.replace({widget:new one((c-u%c)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[s]||(this.decorationCache[s]=Le.replace({widget:new ane(t,s)}))},boundary:t.replaceTabs?void 0:/[^]/})}update(t){let e=t.state.facet(ud);t.startState.facet(ud)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(t.view)):this.decorations=this.decorator.updateDeco(t,this.decorations)}},{decorations:t=>t.decorations}))}const rne="•";function sne(t){return t>=32?rne:t==10?"":String.fromCharCode(9216+t)}class ane extends mr{constructor(e,n){super(),this.options=e,this.code=n}eq(e){return e.code==this.code}toDOM(e){let n=sne(this.code),i=e.state.phrase("Control character")+" "+(ene[this.code]||"0x"+this.code.toString(16)),r=this.options.render&&this.options.render(this.code,i,n);if(r)return r;let s=document.createElement("span");return s.textContent=n,s.title=i,s.setAttribute("aria-label",i),s.className="cm-specialChar",s}ignoreEvent(){return!1}}class one extends mr{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent=" ",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}}function lne(){return une}const cne=Le.line({class:"cm-activeLine"}),une=zt.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,n=[];for(let i of t.state.selection.ranges){let r=t.lineBlockAt(i.head);r.from>e&&(n.push(cne.range(r.from)),e=r.from)}return Le.set(n)}},{decorations:t=>t.decorations});class fne extends mr{constructor(e){super(),this.content=e}toDOM(e){let n=document.createElement("span");return n.className="cm-placeholder",n.style.pointerEvents="none",n.appendChild(typeof this.content=="string"?document.createTextNode(this.content):typeof this.content=="function"?this.content(e):this.content.cloneNode(!0)),n.setAttribute("aria-hidden","true"),n}coordsAt(e){let n=e.firstChild?Xc(e.firstChild):[];if(!n.length)return null;let i=window.getComputedStyle(e.parentNode),r=yu(n[0],i.direction!="rtl"),s=parseInt(i.lineHeight);return r.bottom-r.top>s*1.5?{left:r.left,right:r.right,top:r.top,bottom:r.top+s}:r}ignoreEvent(){return!1}}function hne(t){let e=zt.fromClass(class{constructor(n){this.view=n,this.placeholder=t?Le.set([Le.widget({widget:new fne(t),side:1}).range(0)]):Le.none}get decorations(){return this.view.state.doc.length?Le.none:this.placeholder}},{decorations:n=>n.decorations});return typeof t=="string"?[e,Se.contentAttributes.of({"aria-placeholder":t})]:e}const VS=2e3;function dne(t,e,n){let i=Math.min(e.line,n.line),r=Math.max(e.line,n.line),s=[];if(e.off>VS||n.off>VS||e.col<0||n.col<0){let o=Math.min(e.off,n.off),c=Math.max(e.off,n.off);for(let u=i;u<=r;u++){let h=t.doc.line(u);h.length<=c&&s.push(de.range(h.from+o,h.to+c))}}else{let o=Math.min(e.col,n.col),c=Math.max(e.col,n.col);for(let u=i;u<=r;u++){let h=t.doc.line(u),d=SS(h.text,o,t.tabSize,!0);if(d<0)s.push(de.cursor(h.to));else{let m=SS(h.text,c,t.tabSize);s.push(de.range(h.from+d,h.from+m))}}}return s}function pne(t,e){let n=t.coordsAtPos(t.viewport.from);return n?Math.round(Math.abs((n.left-e)/t.defaultCharacterWidth)):-1}function v5(t,e){let n=t.posAtCoords({x:e.clientX,y:e.clientY},!1),i=t.state.doc.lineAt(n),r=n-i.from,s=r>VS?-1:r==i.length?pne(t,e.clientX):Ol(i.text,t.state.tabSize,n-i.from);return{line:i.number,col:s,off:r}}function mne(t,e){let n=v5(t,e),i=t.state.selection;return n?{update(r){if(r.docChanged){let s=r.changes.mapPos(r.startState.doc.line(n.line).from),o=r.state.doc.lineAt(s);n={line:o.number,col:n.col,off:Math.min(n.off,o.length)},i=i.map(r.changes)}},get(r,s,o){let c=v5(t,r);if(!c)return i;let u=dne(t.state,n,c);return u.length?o?de.create(u.concat(i.ranges)):de.create(u):i}}:null}function gne(t){let e=(n=>n.altKey&&n.button==0);return Se.mouseSelectionStyle.of((n,i)=>e(i)?mne(n,i):null)}const yne={Alt:[18,t=>!!t.altKey],Control:[17,t=>!!t.ctrlKey],Shift:[16,t=>!!t.shiftKey],Meta:[91,t=>!!t.metaKey]},vne={style:"cursor: crosshair"};function bne(t={}){let[e,n]=yne[t.key||"Alt"],i=zt.fromClass(class{constructor(r){this.view=r,this.isDown=!1}set(r){this.isDown!=r&&(this.isDown=r,this.view.update([]))}},{eventObservers:{keydown(r){this.set(r.keyCode==e||n(r))},keyup(r){(r.keyCode==e||!n(r))&&this.set(!1)},mousemove(r){this.set(n(r))}}});return[i,Se.contentAttributes.of(r=>{var s;return!((s=r.plugin(i))===null||s===void 0)&&s.isDown?vne:null})]}const Vh="-10000px";class W6{constructor(e,n,i,r){this.facet=n,this.createTooltipView=i,this.removeTooltipView=r,this.input=e.state.facet(n),this.tooltips=this.input.filter(o=>o);let s=null;this.tooltipViews=this.tooltips.map(o=>s=i(o,s))}update(e,n){var i;let r=e.state.facet(this.facet),s=r.filter(u=>u);if(r===this.input){for(let u of this.tooltipViews)u.update&&u.update(e);return!1}let o=[],c=n?[]:null;for(let u=0;u<s.length;u++){let h=s[u],d=-1;if(h){for(let m=0;m<this.tooltips.length;m++){let g=this.tooltips[m];g&&g.create==h.create&&(d=m)}if(d<0)o[u]=this.createTooltipView(h,u?o[u-1]:null),c&&(c[u]=!!h.above);else{let m=o[u]=this.tooltipViews[d];c&&(c[u]=n[d]),m.update&&m.update(e)}}}for(let u of this.tooltipViews)o.indexOf(u)<0&&(this.removeTooltipView(u),(i=u.destroy)===null||i===void 0||i.call(u));return n&&(c.forEach((u,h)=>n[h]=u),n.length=c.length),this.input=r,this.tooltips=s,this.tooltipViews=o,!0}}function xne(t){let e=t.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}const hw=ke.define({combine:t=>{var e,n,i;return{position:Ce.ios?"absolute":((e=t.find(r=>r.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((n=t.find(r=>r.parent))===null||n===void 0?void 0:n.parent)||null,tooltipSpace:((i=t.find(r=>r.tooltipSpace))===null||i===void 0?void 0:i.tooltipSpace)||xne}}}),b5=new WeakMap,bC=zt.fromClass(class{constructor(t){this.view=t,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=t.state.facet(hw);this.position=e.position,this.parent=e.parent,this.classes=t.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 W6(t,xC,(n,i)=>this.createTooltip(n,i),n=>{this.resizeObserver&&this.resizeObserver.unobserve(n.dom),n.dom.remove()}),this.above=this.manager.tooltips.map(n=>!!n.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(n=>{Date.now()>this.lastTransaction-50&&n.length>0&&n[n.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),t.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 t of this.manager.tooltipViews)this.intersectionObserver.observe(t.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(t){t.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(t,this.above);e&&this.observeIntersection();let n=e||t.geometryChanged,i=t.state.facet(hw);if(i.position!=this.position&&!this.madeAbsolute){this.position=i.position;for(let r of this.manager.tooltipViews)r.dom.style.position=this.position;n=!0}if(i.parent!=this.parent){this.parent&&this.container.remove(),this.parent=i.parent,this.createContainer();for(let r of this.manager.tooltipViews)this.container.appendChild(r.dom);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(t,e){let n=t.create(this.view),i=e?e.dom:null;if(n.dom.classList.add("cm-tooltip"),t.arrow&&!n.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let r=document.createElement("div");r.className="cm-tooltip-arrow",n.dom.appendChild(r)}return n.dom.style.position=this.position,n.dom.style.top=Vh,n.dom.style.left="0px",this.container.insertBefore(n.dom,i),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var t,e,n;this.view.win.removeEventListener("resize",this.measureSoon);for(let i of this.manager.tooltipViews)i.dom.remove(),(t=i.destroy)===null||t===void 0||t.call(i);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(n=this.intersectionObserver)===null||n===void 0||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let t=1,e=1,n=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:s}=this.manager.tooltipViews[0];if(Ce.safari){let o=s.getBoundingClientRect();n=Math.abs(o.top+1e4)>1||Math.abs(o.left)>1}else n=!!s.offsetParent&&s.offsetParent!=this.container.ownerDocument.body}if(n||this.position=="absolute")if(this.parent){let s=this.parent.getBoundingClientRect();s.width&&s.height&&(t=s.width/this.parent.offsetWidth,e=s.height/this.parent.offsetHeight)}else({scaleX:t,scaleY:e}=this.view.viewState);let i=this.view.scrollDOM.getBoundingClientRect(),r=mC(this.view);return{visible:{left:i.left+r.left,top:i.top+r.top,right:i.right-r.right,bottom:i.bottom-r.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((s,o)=>{let c=this.manager.tooltipViews[o];return c.getCoords?c.getCoords(s.pos):this.view.coordsAtPos(s.pos)}),size:this.manager.tooltipViews.map(({dom:s})=>s.getBoundingClientRect()),space:this.view.state.facet(hw).tooltipSpace(this.view),scaleX:t,scaleY:e,makeAbsolute:n}}writeMeasure(t){var e;if(t.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let c of this.manager.tooltipViews)c.dom.style.position="absolute"}let{visible:n,space:i,scaleX:r,scaleY:s}=t,o=[];for(let c=0;c<this.manager.tooltips.length;c++){let u=this.manager.tooltips[c],h=this.manager.tooltipViews[c],{dom:d}=h,m=t.pos[c],g=t.size[c];if(!m||u.clip!==!1&&(m.bottom<=Math.max(n.top,i.top)||m.top>=Math.min(n.bottom,i.bottom)||m.right<Math.max(n.left,i.left)-.1||m.left>Math.min(n.right,i.right)+.1)){d.style.top=Vh;continue}let y=u.arrow?h.dom.querySelector(".cm-tooltip-arrow"):null,x=y?7:0,w=g.right-g.left,S=(e=b5.get(h))!==null&&e!==void 0?e:g.bottom-g.top,C=h.offset||Sne,A=this.view.textDirection==yt.LTR,O=g.width>i.right-i.left?A?i.left:i.right-g.width:A?Math.max(i.left,Math.min(m.left-(y?14:0)+C.x,i.right-w)):Math.min(Math.max(i.left,m.left-w+(y?14:0)-C.x),i.right-w),E=this.above[c];!u.strictSide&&(E?m.top-S-x-C.y<i.top:m.bottom+S+x+C.y>i.bottom)&&E==i.bottom-m.bottom>m.top-i.top&&(E=this.above[c]=!E);let T=(E?m.top-i.top:i.bottom-m.bottom)-x;if(T<S&&h.resize!==!1){if(T<this.view.defaultLineHeight){d.style.top=Vh;continue}b5.set(h,S),d.style.height=(S=T)/s+"px"}else d.style.height&&(d.style.height="");let M=E?m.top-S-x-C.y:m.bottom+x+C.y,R=O+w;if(h.overlap!==!0)for(let z of o)z.left<R&&z.right>O&&z.top<M+S&&z.bottom>M&&(M=E?z.top-S-2-x:z.bottom+x+2);if(this.position=="absolute"?(d.style.top=(M-t.parent.top)/s+"px",x5(d,(O-t.parent.left)/r)):(d.style.top=M/s+"px",x5(d,O/r)),y){let z=m.left+(A?C.x:-C.x)-(O+14-7);y.style.left=z/r+"px"}h.overlap!==!0&&o.push({left:O,top:M,right:R,bottom:M+S}),d.classList.toggle("cm-tooltip-above",E),d.classList.toggle("cm-tooltip-below",!E),h.positioned&&h.positioned(t.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 t of this.manager.tooltipViews)t.dom.style.top=Vh}},{eventObservers:{scroll(){this.maybeMeasure()}}});function x5(t,e){let n=parseInt(t.style.left,10);(isNaN(n)||Math.abs(e-n)>1)&&(t.style.left=e+"px")}const wne=Se.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"}}}),Sne={x:0,y:0},xC=ke.define({enables:[bC,wne]}),Fd=ke.define({combine:t=>t.reduce((e,n)=>e.concat(n),[])});class Up{static create(e){return new Up(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new W6(e,Fd,(n,i)=>this.createHostedView(n,i),n=>n.dom.remove())}createHostedView(e,n){let i=e.create(this.view);return i.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(i.dom,n?n.dom.nextSibling:this.dom.firstChild),this.mounted&&i.mount&&i.mount(this.view),i}mount(e){for(let n of this.manager.tooltipViews)n.mount&&n.mount(e);this.mounted=!0}positioned(e){for(let n of this.manager.tooltipViews)n.positioned&&n.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let n of this.manager.tooltipViews)(e=n.destroy)===null||e===void 0||e.call(n)}passProp(e){let n;for(let i of this.manager.tooltipViews){let r=i[e];if(r!==void 0){if(n===void 0)n=r;else if(n!==r)return}}return n}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const Cne=xC.compute([Fd],t=>{let e=t.facet(Fd);return e.length===0?null:{pos:Math.min(...e.map(n=>n.pos)),end:Math.max(...e.map(n=>{var i;return(i=n.end)!==null&&i!==void 0?i:n.pos})),create:Up.create,above:e[0].above,arrow:e.some(n=>n.arrow)}});class kne{constructor(e,n,i,r,s){this.view=e,this.source=n,this.field=i,this.setHover=r,this.hoverTime=s,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;e<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-e):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:e,lastMove:n}=this,i=e.docView.tile.nearest(n.target);if(!i)return;let r,s=1;if(i.isWidget())r=i.posAtStart;else{if(r=e.posAtCoords(n),r==null)return;let c=e.coordsAtPos(r);if(!c||n.y<c.top||n.y>c.bottom||n.x<c.left-e.defaultCharacterWidth||n.x>c.right+e.defaultCharacterWidth)return;let u=e.bidiSpans(e.state.doc.lineAt(r)).find(d=>d.from<=r&&d.to>=r),h=u&&u.dir==yt.RTL?-1:1;s=n.x<c.left?-h:h}let o=this.source(e,r,s);if(o?.then){let c=this.pending={pos:r};o.then(u=>{this.pending==c&&(this.pending=null,u&&!(Array.isArray(u)&&!u.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(u)?u:[u])}))},u=>Fn(e.state,u,"hover tooltip"))}else o&&!(Array.isArray(o)&&!o.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(o)?o:[o])})}get tooltip(){let e=this.view.plugin(bC),n=e?e.manager.tooltips.findIndex(i=>i.create==Up.create):-1;return n>-1?e.manager.tooltipViews[n]:null}mousemove(e){var n,i;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:r,tooltip:s}=this;if(r.length&&s&&!Ane(s.dom,e)||this.pending){let{pos:o}=r[0]||this.pending,c=(i=(n=r[0])===null||n===void 0?void 0:n.end)!==null&&i!==void 0?i:o;(o==c?this.view.posAtCoords(this.lastMove)!=o:!_ne(this.view,o,c,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:n}=this;if(n.length){let{tooltip:i}=this;i&&i.dom.contains(e.relatedTarget)?this.watchTooltipLeave(i.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let n=i=>{e.removeEventListener("mouseleave",n),this.active.length&&!this.view.dom.contains(i.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",n)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const Fh=4;function Ane(t,e){let{left:n,right:i,top:r,bottom:s}=t.getBoundingClientRect(),o;if(o=t.querySelector(".cm-tooltip-arrow")){let c=o.getBoundingClientRect();r=Math.min(c.top,r),s=Math.max(c.bottom,s)}return e.clientX>=n-Fh&&e.clientX<=i+Fh&&e.clientY>=r-Fh&&e.clientY<=s+Fh}function _ne(t,e,n,i,r,s){let o=t.scrollDOM.getBoundingClientRect(),c=t.documentTop+t.documentPadding.top+t.contentHeight;if(o.left>i||o.right<i||o.top>r||Math.min(o.bottom,c)<r)return!1;let u=t.posAtCoords({x:i,y:r},!1);return u>=e&&u<=n}function One(t,e={}){let n=je.define(),i=_n.define({create(){return[]},update(r,s){if(r.length&&(e.hideOnChange&&(s.docChanged||s.selection)?r=[]:e.hideOn&&(r=r.filter(o=>!e.hideOn(s,o))),s.docChanged)){let o=[];for(let c of r){let u=s.changes.mapPos(c.pos,-1,Rn.TrackDel);if(u!=null){let h=Object.assign(Object.create(null),c);h.pos=u,h.end!=null&&(h.end=s.changes.mapPos(h.end)),o.push(h)}}r=o}for(let o of s.effects)o.is(n)&&(r=o.value),o.is(Ene)&&(r=[]);return r},provide:r=>Fd.from(r)});return{active:i,extension:[i,zt.define(r=>new kne(r,t,i,n,e.hoverTime||300)),Cne]}}function K6(t,e){let n=t.plugin(bC);if(!n)return null;let i=n.manager.tooltips.indexOf(e);return i<0?null:n.manager.tooltipViews[i]}const Ene=je.define(),w5=ke.define({combine(t){let e,n;for(let i of t)e=e||i.topContainer,n=n||i.bottomContainer;return{topContainer:e,bottomContainer:n}}});function wC(t,e){let n=t.plugin(Z6),i=n?n.specs.indexOf(e):-1;return i>-1?n.panels[i]:null}const Z6=zt.fromClass(class{constructor(t){this.input=t.state.facet(xu),this.specs=this.input.filter(n=>n),this.panels=this.specs.map(n=>n(t));let e=t.state.facet(w5);this.top=new $h(t,!0,e.topContainer),this.bottom=new $h(t,!1,e.bottomContainer),this.top.sync(this.panels.filter(n=>n.top)),this.bottom.sync(this.panels.filter(n=>!n.top));for(let n of this.panels)n.dom.classList.add("cm-panel"),n.mount&&n.mount()}update(t){let e=t.state.facet(w5);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new $h(t.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new $h(t.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=t.state.facet(xu);if(n!=this.input){let i=n.filter(u=>u),r=[],s=[],o=[],c=[];for(let u of i){let h=this.specs.indexOf(u),d;h<0?(d=u(t.view),c.push(d)):(d=this.panels[h],d.update&&d.update(t)),r.push(d),(d.top?s:o).push(d)}this.specs=i,this.panels=r,this.top.sync(s),this.bottom.sync(o);for(let u of c)u.dom.classList.add("cm-panel"),u.mount&&u.mount()}else for(let i of this.panels)i.update&&i.update(t)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:t=>Se.scrollMargins.of(e=>{let n=e.plugin(t);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})});class $h{constructor(e,n,i){this.view=e,this.top=n,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let n of this.panels)n.destroy&&e.indexOf(n)<0&&n.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=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 n=this.container||this.view.dom;n.insertBefore(this.dom,this.top?n.firstChild:null)}let e=this.dom.firstChild;for(let n of this.panels)if(n.dom.parentNode==this.dom){for(;e!=n.dom;)e=S5(e);e=e.nextSibling}else this.dom.insertBefore(n.dom,e);for(;e;)e=S5(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 S5(t){let e=t.nextSibling;return t.remove(),e}const xu=ke.define({enables:Z6});function Tne(t,e){let n,i=new Promise(o=>n=o),r=o=>Mne(o,e,n);t.state.field(dw,!1)?t.dispatch({effects:J6.of(r)}):t.dispatch({effects:je.appendConfig.of(dw.init(()=>[r]))});let s=eq.of(r);return{close:s,result:i.then(o=>((t.win.queueMicrotask||(u=>t.win.setTimeout(u,10)))(()=>{t.state.field(dw).indexOf(r)>-1&&t.dispatch({effects:s})}),o))}}const dw=_n.define({create(){return[]},update(t,e){for(let n of e.effects)n.is(J6)?t=[n.value].concat(t):n.is(eq)&&(t=t.filter(i=>i!=n.value));return t},provide:t=>xu.computeN([t],e=>e.field(t))}),J6=je.define(),eq=je.define();function Mne(t,e,n){let i=e.content?e.content(t,()=>o(null)):null;if(!i){if(i=dt("form"),e.input){let c=dt("input",e.input);/^(text|password|number|email|tel|url)$/.test(c.type)&&c.classList.add("cm-textfield"),c.name||(c.name="input"),i.appendChild(dt("label",(e.label||"")+": ",c))}else i.appendChild(document.createTextNode(e.label||""));i.appendChild(document.createTextNode(" ")),i.appendChild(dt("button",{class:"cm-button",type:"submit"},e.submitLabel||"OK"))}let r=i.nodeName=="FORM"?[i]:i.querySelectorAll("form");for(let c=0;c<r.length;c++){let u=r[c];u.addEventListener("keydown",h=>{h.keyCode==27?(h.preventDefault(),o(null)):h.keyCode==13&&(h.preventDefault(),o(u))}),u.addEventListener("submit",h=>{h.preventDefault(),o(u)})}let s=dt("div",i,dt("button",{onclick:()=>o(null),"aria-label":t.state.phrase("close"),class:"cm-dialog-close",type:"button"},["×"]));e.class&&(s.className=e.class),s.classList.add("cm-dialog");function o(c){s.contains(s.ownerDocument.activeElement)&&t.focus(),n(c)}return{dom:s,top:e.top,mount:()=>{if(e.focus){let c;typeof e.focus=="string"?c=i.querySelector(e.focus):c=i.querySelector("input")||i.querySelector("button"),c&&"select"in c?c.select():c&&"focus"in c&&c.focus()}}}}class Jr extends Gs{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}Jr.prototype.elementClass="";Jr.prototype.toDOM=void 0;Jr.prototype.mapMode=Rn.TrackBefore;Jr.prototype.startSide=Jr.prototype.endSide=-1;Jr.prototype.point=!0;const fd=ke.define(),Rne=ke.define(),Nne={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>Ye.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},Zc=ke.define();function Dne(t){return[tq(),Zc.of({...Nne,...t})]}const C5=ke.define({combine:t=>t.some(e=>e)});function tq(t){return[Lne]}const Lne=zt.fromClass(class{constructor(t){this.view=t,this.domAfter=null,this.prevViewport=t.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=t.state.facet(Zc).map(e=>new A5(t,e)),this.fixed=!t.state.facet(C5);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),t.scrollDOM.insertBefore(this.dom,t.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(t){if(this.updateGutters(t)){let e=this.prevViewport,n=t.view.viewport,i=Math.min(e.to,n.to)-Math.max(e.from,n.from);this.syncGutters(i<(n.to-n.from)*.8)}if(t.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(C5)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=Ye.iter(this.view.state.facet(fd),this.view.viewport.from),i=[],r=this.gutters.map(s=>new zne(s,this.view.viewport,-this.view.documentPadding.top));for(let s of this.view.viewportLineBlocks)if(i.length&&(i=[]),Array.isArray(s.type)){let o=!0;for(let c of s.type)if(c.type==bn.Text&&o){FS(n,i,c.from);for(let u of r)u.line(this.view,c,i);o=!1}else if(c.widget)for(let u of r)u.widget(this.view,c)}else if(s.type==bn.Text){FS(n,i,s.from);for(let o of r)o.line(this.view,s,i)}else if(s.widget)for(let o of r)o.widget(this.view,s);for(let s of r)s.finish();t&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(t){let e=t.startState.facet(Zc),n=t.state.facet(Zc),i=t.docChanged||t.heightChanged||t.viewportChanged||!Ye.eq(t.startState.facet(fd),t.state.facet(fd),t.view.viewport.from,t.view.viewport.to);if(e==n)for(let r of this.gutters)r.update(t)&&(i=!0);else{i=!0;let r=[];for(let s of n){let o=e.indexOf(s);o<0?r.push(new A5(this.view,s)):(this.gutters[o].update(t),r.push(this.gutters[o]))}for(let s of this.gutters)s.dom.remove(),r.indexOf(s)<0&&s.destroy();for(let s of r)s.config.side=="after"?this.getDOMAfter().appendChild(s.dom):this.dom.appendChild(s.dom);this.gutters=r}return i}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:t=>Se.scrollMargins.of(e=>{let n=e.plugin(t);if(!n||n.gutters.length==0||!n.fixed)return null;let i=n.dom.offsetWidth*e.scaleX,r=n.domAfter?n.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==yt.LTR?{left:i,right:r}:{right:i,left:r}})});function k5(t){return Array.isArray(t)?t:[t]}function FS(t,e,n){for(;t.value&&t.from<=n;)t.from==n&&e.push(t.value),t.next()}class zne{constructor(e,n,i){this.gutter=e,this.height=i,this.i=0,this.cursor=Ye.iter(e.markers,n.from)}addElement(e,n,i){let{gutter:r}=this,s=(n.top-this.height)/e.scaleY,o=n.height/e.scaleY;if(this.i==r.elements.length){let c=new nq(e,o,s,i);r.elements.push(c),r.dom.appendChild(c.dom)}else r.elements[this.i].update(e,o,s,i);this.height=n.bottom,this.i++}line(e,n,i){let r=[];FS(this.cursor,r,n.from),i.length&&(r=r.concat(i));let s=this.gutter.config.lineMarker(e,n,r);s&&r.unshift(s);let o=this.gutter;r.length==0&&!o.config.renderEmptyElements||this.addElement(e,n,r)}widget(e,n){let i=this.gutter.config.widgetMarker(e,n.widget,n),r=i?[i]:null;for(let s of e.state.facet(Rne)){let o=s(e,n.widget,n);o&&(r||(r=[])).push(o)}r&&this.addElement(e,n,r)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let n=e.elements.pop();e.dom.removeChild(n.dom),n.destroy()}}}class A5{constructor(e,n){this.view=e,this.config=n,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in n.domEventHandlers)this.dom.addEventListener(i,r=>{let s=r.target,o;if(s!=this.dom&&this.dom.contains(s)){for(;s.parentNode!=this.dom;)s=s.parentNode;let u=s.getBoundingClientRect();o=(u.top+u.bottom)/2}else o=r.clientY;let c=e.lineBlockAtHeight(o-e.documentTop);n.domEventHandlers[i](e,c,r)&&r.preventDefault()});this.markers=k5(n.markers(e)),n.initialSpacer&&(this.spacer=new nq(e,0,0,[n.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let n=this.markers;if(this.markers=k5(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let r=this.config.updateSpacer(this.spacer.markers[0],e);r!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[r])}let i=e.view.viewport;return!Ye.eq(this.markers,n,i.from,i.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class nq{constructor(e,n,i,r){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,n,i,r)}update(e,n,i,r){this.height!=n&&(this.height=n,this.dom.style.height=n+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),Bne(this.markers,r)||this.setMarkers(e,r)}setMarkers(e,n){let i="cm-gutterElement",r=this.dom.firstChild;for(let s=0,o=0;;){let c=o,u=s<n.length?n[s++]:null,h=!1;if(u){let d=u.elementClass;d&&(i+=" "+d);for(let m=o;m<this.markers.length;m++)if(this.markers[m].compare(u)){c=m,h=!0;break}}else c=this.markers.length;for(;o<c;){let d=this.markers[o++];if(d.toDOM){d.destroy(r);let m=r.nextSibling;r.remove(),r=m}}if(!u)break;u.toDOM&&(h?r=r.nextSibling:this.dom.insertBefore(u.toDOM(e),r)),h&&o++}this.dom.className=i,this.markers=n}destroy(){this.setMarkers(null,[])}}function Bne(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].compare(e[n]))return!1;return!0}const qne=ke.define(),jne=ke.define(),Xo=ke.define({combine(t){return pr(t,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,n){let i=Object.assign({},e);for(let r in n){let s=i[r],o=n[r];i[r]=s?(c,u,h)=>s(c,u,h)||o(c,u,h):o}return i}})}});class pw extends Jr{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function mw(t,e){return t.state.facet(Xo).formatNumber(e,t.state)}const Ine=Zc.compute([Xo],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(qne)},lineMarker(e,n,i){return i.some(r=>r.toDOM)?null:new pw(mw(e,e.state.doc.lineAt(n.from).number))},widgetMarker:(e,n,i)=>{for(let r of e.state.facet(jne)){let s=r(e,n,i);if(s)return s}return null},lineMarkerChange:e=>e.startState.facet(Xo)!=e.state.facet(Xo),initialSpacer(e){return new pw(mw(e,_5(e.state.doc.lines)))},updateSpacer(e,n){let i=mw(n.view,_5(n.view.state.doc.lines));return i==e.number?e:new pw(i)},domEventHandlers:t.facet(Xo).domEventHandlers,side:"before"}));function Pne(t={}){return[Xo.of(t),tq(),Ine]}function _5(t){let e=9;for(;e<t;)e=e*10+9;return e}const Hne=new class extends Jr{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},Une=fd.compute(["selection"],t=>{let e=[],n=-1;for(let i of t.selection.ranges){let r=t.doc.lineAt(i.head).from;r>n&&(n=r,e.push(Hne.range(r)))}return Ye.of(e)});function Vne(){return Une}const iq=1024;let Fne=0;class gw{constructor(e,n){this.from=e,this.to=n}}class Fe{constructor(e={}){this.id=Fne++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=Xn.match(e)),n=>{let i=e(n);return i===void 0?null:[this,i]}}}Fe.closedBy=new Fe({deserialize:t=>t.split(" ")});Fe.openedBy=new Fe({deserialize:t=>t.split(" ")});Fe.group=new Fe({deserialize:t=>t.split(" ")});Fe.isolate=new Fe({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}});Fe.contextHash=new Fe({perNode:!0});Fe.lookAhead=new Fe({perNode:!0});Fe.mounted=new Fe({perNode:!0});class Jc{constructor(e,n,i,r=!1){this.tree=e,this.overlay=n,this.parser=i,this.bracketed=r}static get(e){return e&&e.props&&e.props[Fe.mounted.id]}}const $ne=Object.create(null);class Xn{constructor(e,n,i,r=0){this.name=e,this.props=n,this.id=i,this.flags=r}static define(e){let n=e.props&&e.props.length?Object.create(null):$ne,i=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),r=new Xn(e.name||"",n,e.id,i);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(r)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[s[0].id]=s[1]}}return r}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 n=this.prop(Fe.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let i in e)for(let r of i.split(" "))n[r]=e[i];return i=>{for(let r=i.prop(Fe.group),s=-1;s<(r?r.length:0);s++){let o=n[s<0?i.name:r[s]];if(o)return o}}}}Xn.none=new Xn("",Object.create(null),0,8);class SC{constructor(e){this.types=e;for(let n=0;n<e.length;n++)if(e[n].id!=n)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let n=[];for(let i of this.types){let r=null;for(let s of e){let o=s(i);if(o){r||(r=Object.assign({},i.props));let c=o[1],u=o[0];u.combine&&u.id in r&&(c=u.combine(r[u.id],c)),r[u.id]=c}}n.push(r?new Xn(i.name,r,i.id,i.flags):i)}return new SC(n)}}const Gh=new WeakMap,O5=new WeakMap;var Nt;(function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays",t[t.EnterBracketed=16]="EnterBracketed"})(Nt||(Nt={}));class It{constructor(e,n,i,r,s){if(this.type=e,this.children=n,this.positions=i,this.length=r,this.props=null,s&&s.length){this.props=Object.create(null);for(let[o,c]of s)this.props[typeof o=="number"?o:o.id]=c}}toString(){let e=Jc.get(this);if(e&&!e.overlay)return e.tree.toString();let n="";for(let i of this.children){let r=i.toString();r&&(n&&(n+=","),n+=r)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(n.length?"("+n+")":""):n}cursor(e=0){return new GS(this.topNode,e)}cursorAt(e,n=0,i=0){let r=Gh.get(this)||this.topNode,s=new GS(r);return s.moveTo(e,n),Gh.set(this,s._tree),s}get topNode(){return new _i(this,0,0,null)}resolve(e,n=0){let i=wu(Gh.get(this)||this.topNode,e,n,!1);return Gh.set(this,i),i}resolveInner(e,n=0){let i=wu(O5.get(this)||this.topNode,e,n,!0);return O5.set(this,i),i}resolveStack(e,n=0){return Qne(this,e,n)}iterate(e){let{enter:n,leave:i,from:r=0,to:s=this.length}=e,o=e.mode||0,c=(o&Nt.IncludeAnonymous)>0;for(let u=this.cursor(o|Nt.IncludeAnonymous);;){let h=!1;if(u.from<=s&&u.to>=r&&(!c&&u.type.isAnonymous||n(u)!==!1)){if(u.firstChild())continue;h=!0}for(;h&&i&&(c||!u.type.isAnonymous)&&i(u),!u.nextSibling();){if(!u.parent())return;h=!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 n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:AC(Xn.none,this.children,this.positions,0,this.children.length,0,this.length,(n,i,r)=>new It(this.type,n,i,r,this.propValues),e.makeTree||((n,i,r)=>new It(Xn.none,n,i,r)))}static build(e){return Xne(e)}}It.empty=new It(Xn.none,[],[],0);class CC{constructor(e,n){this.buffer=e,this.index=n}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 CC(this.buffer,this.index)}}class Ws{constructor(e,n,i){this.buffer=e,this.length=n,this.set=i}get type(){return Xn.none}toString(){let e=[];for(let n=0;n<this.buffer.length;)e.push(this.childString(n)),n=this.buffer[n+3];return e.join(",")}childString(e){let n=this.buffer[e],i=this.buffer[e+3],r=this.set.types[n],s=r.name;if(/\W/.test(s)&&!r.isError&&(s=JSON.stringify(s)),e+=4,i==e)return s;let o=[];for(;e<i;)o.push(this.childString(e)),e=this.buffer[e+3];return s+"("+o.join(",")+")"}findChild(e,n,i,r,s){let{buffer:o}=this,c=-1;for(let u=e;u!=n&&!(rq(s,r,o[u+1],o[u+2])&&(c=u,i>0));u=o[u+3]);return c}slice(e,n,i){let r=this.buffer,s=new Uint16Array(n-e),o=0;for(let c=e,u=0;c<n;){s[u++]=r[c++],s[u++]=r[c++]-i;let h=s[u++]=r[c++]-i;s[u++]=r[c++]-e,o=Math.max(o,h)}return new Ws(s,o,this.set)}}function rq(t,e,n,i){switch(t){case-2:return n<e;case-1:return i>=e&&n<e;case 0:return n<e&&i>e;case 1:return n<=e&&i>e;case 2:return i>e;case 4:return!0}}function wu(t,e,n,i){for(var r;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to<e);){let o=!i&&t instanceof _i&&t.index<0?null:t.parent;if(!o)return t;t=o}let s=i?0:Nt.IgnoreOverlays;if(i)for(let o=t,c=o.parent;c;o=c,c=o.parent)o instanceof _i&&o.index<0&&((r=c.enter(e,n,s))===null||r===void 0?void 0:r.from)!=o.from&&(t=c);for(;;){let o=t.enter(e,n,s);if(!o)return t;t=o}}class sq{cursor(e=0){return new GS(this,e)}getChild(e,n=null,i=null){let r=E5(this,e,n,i);return r.length?r[0]:null}getChildren(e,n=null,i=null){return E5(this,e,n,i)}resolve(e,n=0){return wu(this,e,n,!1)}resolveInner(e,n=0){return wu(this,e,n,!0)}matchContext(e){return $S(this.parent,e)}enterUnfinishedNodesBefore(e){let n=this.childBefore(e),i=this;for(;n;){let r=n.lastChild;if(!r||r.to!=n.to)break;r.type.isError&&r.from==r.to?(i=n,n=r.prevSibling):n=r}return i}get node(){return this}get next(){return this.parent}}class _i extends sq{constructor(e,n,i,r){super(),this._tree=e,this.from=n,this.index=i,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(e,n,i,r,s=0){for(let o=this;;){for(let{children:c,positions:u}=o._tree,h=n>0?c.length:-1;e!=h;e+=n){let d=c[e],m=u[e]+o.from,g;if(!(!(s&Nt.EnterBracketed&&d instanceof It&&(g=Jc.get(d))&&!g.overlay&&g.bracketed&&i>=m&&i<=m+d.length)&&!rq(r,i,m,m+d.length))){if(d instanceof Ws){if(s&Nt.ExcludeBuffers)continue;let y=d.findChild(0,d.buffer.length,n,i-m,r);if(y>-1)return new Is(new Gne(o,d,e,m),null,y)}else if(s&Nt.IncludeAnonymous||!d.type.isAnonymous||kC(d)){let y;if(!(s&Nt.IgnoreMounts)&&(y=Jc.get(d))&&!y.overlay)return new _i(y.tree,m,e,o);let x=new _i(d,m,e,o);return s&Nt.IncludeAnonymous||!x.type.isAnonymous?x:x.nextChild(n<0?d.children.length-1:0,n,i,r,s)}}}if(s&Nt.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+n:e=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(e,n,i=0){let r;if(!(i&Nt.IgnoreOverlays)&&(r=Jc.get(this._tree))&&r.overlay){let s=e-this.from,o=i&Nt.EnterBracketed&&r.bracketed;for(let{from:c,to:u}of r.overlay)if((n>0||o?c<=s:c<s)&&(n<0||o?u>=s:u>s))return new _i(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,n,i)}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 E5(t,e,n,i){let r=t.cursor(),s=[];if(!r.firstChild())return s;if(n!=null){for(let o=!1;!o;)if(o=r.type.is(n),!r.nextSibling())return s}for(;;){if(i!=null&&r.type.is(i))return s;if(r.type.is(e)&&s.push(r.node),!r.nextSibling())return i==null?s:[]}}function $S(t,e,n=e.length-1){for(let i=t;n>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(e[n]&&e[n]!=i.name)return!1;n--}}return!0}class Gne{constructor(e,n,i,r){this.parent=e,this.buffer=n,this.index=i,this.start=r}}class Is extends sq{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,n,i){super(),this.context=e,this._parent=n,this.index=i,this.type=e.buffer.set.types[e.buffer.buffer[i]]}child(e,n,i){let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],e,n-this.context.start,i);return s<0?null:new Is(this.context,this,s)}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(e,n,i=0){if(i&Nt.ExcludeBuffers)return null;let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return s<0?null:new Is(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Is(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new Is(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{buffer:i}=this.context,r=this.index+4,s=i.buffer[this.index+3];if(s>r){let o=i.buffer[this.index+1];e.push(i.slice(r,s,o)),n.push(0)}return new It(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function aq(t){if(!t.length)return null;let e=0,n=t[0];for(let s=1;s<t.length;s++){let o=t[s];(o.from>n.from||o.to<n.to)&&(n=o,e=s)}let i=n instanceof _i&&n.index<0?null:n.parent,r=t.slice();return i?r[e]=i:r.splice(e,1),new Yne(r,n)}class Yne{constructor(e,n){this.heads=e,this.node=n}get next(){return aq(this.heads)}}function Qne(t,e,n){let i=t.resolveInner(e,n),r=null;for(let s=i instanceof _i?i:i.context.parent;s;s=s.parent)if(s.index<0){let o=s.parent;(r||(r=[i])).push(o.resolve(e,n)),s=o}else{let o=Jc.get(s.tree);if(o&&o.overlay&&o.overlay[0].from<=e&&o.overlay[o.overlay.length-1].to>=e){let c=new _i(o.tree,o.overlay[0].from+s.from,-1,s);(r||(r=[i])).push(wu(c,e,n,!1))}}return r?aq(r):i}class GS{get name(){return this.type.name}constructor(e,n=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=n&~Nt.EnterBracketed,e instanceof _i)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let i=e._parent;i;i=i._parent)this.stack.unshift(i.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,n){this.index=e;let{start:i,buffer:r}=this.buffer;return this.type=n||r.set.types[r.buffer[e]],this.from=i+r.buffer[e+1],this.to=i+r.buffer[e+2],!0}yield(e){return e?e instanceof _i?(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,n,i){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,i,this.mode));let{buffer:r}=this.buffer,s=r.findChild(this.index+4,r.buffer[this.index+3],e,n-this.buffer.start,i);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}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,n,i=this.mode){return this.buffer?i&Nt.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Nt.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Nt.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:n}=this.buffer,i=this.stack.length-1;if(e<0){let r=i<0?0:this.stack[i]+4;if(this.index!=r)return this.yieldBuf(n.findChild(r,this.index,-1,0,4))}else{let r=n.buffer[this.index+3];if(r<(i<0?n.buffer.length:n.buffer[this.stack[i]+3]))return this.yieldBuf(r)}return i<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 n,i,{buffer:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let s=0;s<this.index;s++)if(r.buffer.buffer[s+3]<this.index)return!1;({index:n,parent:i}=r)}else({index:n,_parent:i}=this._tree);for(;i;{index:n,_parent:i}=i)if(n>-1)for(let s=n+e,o=e<0?-1:i._tree.children.length;s!=o;s+=e){let c=i._tree.children[s];if(this.mode&Nt.IncludeAnonymous||c instanceof Ws||!c.type.isAnonymous||kC(c))return!1}return!0}move(e,n){if(n&&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,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,n););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,n=null,i=0;if(e&&e.context==this.buffer)e:for(let r=this.index,s=this.stack.length;s>=0;){for(let o=e;o;o=o._parent)if(o.index==r){if(r==this.index)return o;n=o,i=s+1;break e}r=this.stack[--s]}for(let r=i;r<this.stack.length;r++)n=new Is(this.buffer,n,this.stack[r]);return this.bufferNode=new Is(this.buffer,n,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,n){for(let i=0;;){let r=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){i++;continue}this.type.isAnonymous||(r=!0)}for(;;){if(r&&n&&n(this),r=this.type.isAnonymous,!i)return;if(this.nextSibling())break;this.parent(),i--,r=!0}}}matchContext(e){if(!this.buffer)return $S(this.node.parent,e);let{buffer:n}=this.buffer,{types:i}=n.set;for(let r=e.length-1,s=this.stack.length-1;r>=0;s--){if(s<0)return $S(this._tree,e,r);let o=i[n.buffer[this.stack[s]]];if(!o.isAnonymous){if(e[r]&&e[r]!=o.name)return!1;r--}}return!0}}function kC(t){return t.children.some(e=>e instanceof Ws||!e.type.isAnonymous||kC(e))}function Xne(t){var e;let{buffer:n,nodeSet:i,maxBufferLength:r=iq,reused:s=[],minRepeatType:o=i.types.length}=t,c=Array.isArray(n)?new CC(n,n.length):n,u=i.types,h=0,d=0;function m(T,M,R,z,q,U){let{id:P,start:$,end:K,size:L}=c,Y=d,D=h;if(L<0)if(c.next(),L==-1){let B=s[P];R.push(B),z.push($-T);return}else if(L==-3){h=P;return}else if(L==-4){d=P;return}else throw new RangeError(`Unrecognized record size: ${L}`);let Q=u[P],ee,G,W=$-T;if(K-$<=r&&(G=S(c.pos-M,q))){let B=new Uint16Array(G.size-G.skip),F=c.pos-G.size,ne=B.length;for(;c.pos>F;)ne=C(G.start,B,ne);ee=new Ws(B,K-G.start,i),W=G.start-T}else{let B=c.pos-L;c.next();let F=[],ne=[],I=P>=o?P:-1,X=0,J=K;for(;c.pos>B;)I>=0&&c.id==I&&c.size>=0?(c.end<=J-r&&(x(F,ne,$,X,c.end,J,I,Y,D),X=F.length,J=c.end),c.next()):U>2500?g($,B,F,ne):m($,B,F,ne,I,U+1);if(I>=0&&X>0&&X<F.length&&x(F,ne,$,X,$,J,I,Y,D),F.reverse(),ne.reverse(),I>-1&&X>0){let oe=y(Q,D);ee=AC(Q,F,ne,0,F.length,0,K-$,oe,oe)}else ee=w(Q,F,ne,K-$,Y-K,D)}R.push(ee),z.push(W)}function g(T,M,R,z){let q=[],U=0,P=-1;for(;c.pos>M;){let{id:$,start:K,end:L,size:Y}=c;if(Y>4)c.next();else{if(P>-1&&K<P)break;P<0&&(P=L-r),q.push($,K,L),U++,c.next()}}if(U){let $=new Uint16Array(U*4),K=q[q.length-2];for(let L=q.length-3,Y=0;L>=0;L-=3)$[Y++]=q[L],$[Y++]=q[L+1]-K,$[Y++]=q[L+2]-K,$[Y++]=Y;R.push(new Ws($,q[2]-K,i)),z.push(K-T)}}function y(T,M){return(R,z,q)=>{let U=0,P=R.length-1,$,K;if(P>=0&&($=R[P])instanceof It){if(!P&&$.type==T&&$.length==q)return $;(K=$.prop(Fe.lookAhead))&&(U=z[P]+$.length+K)}return w(T,R,z,q,U,M)}}function x(T,M,R,z,q,U,P,$,K){let L=[],Y=[];for(;T.length>z;)L.push(T.pop()),Y.push(M.pop()+R-q);T.push(w(i.types[P],L,Y,U-q,$-U,K)),M.push(q-R)}function w(T,M,R,z,q,U,P){if(U){let $=[Fe.contextHash,U];P=P?[$].concat(P):[$]}if(q>25){let $=[Fe.lookAhead,q];P=P?[$].concat(P):[$]}return new It(T,M,R,z,P)}function S(T,M){let R=c.fork(),z=0,q=0,U=0,P=R.end-r,$={size:0,start:0,skip:0};e:for(let K=R.pos-T;R.pos>K;){let L=R.size;if(R.id==M&&L>=0){$.size=z,$.start=q,$.skip=U,U+=4,z+=4,R.next();continue}let Y=R.pos-L;if(L<0||Y<K||R.start<P)break;let D=R.id>=o?4:0,Q=R.start;for(R.next();R.pos>Y;){if(R.size<0)if(R.size==-3||R.size==-4)D+=4;else break e;else R.id>=o&&(D+=4);R.next()}q=Q,z+=L,U+=D}return(M<0||z==T)&&($.size=z,$.start=q,$.skip=U),$.size>4?$:void 0}function C(T,M,R){let{id:z,start:q,end:U,size:P}=c;if(c.next(),P>=0&&z<o){let $=R;if(P>4){let K=c.pos-(P-4);for(;c.pos>K;)R=C(T,M,R)}M[--R]=$,M[--R]=U-T,M[--R]=q-T,M[--R]=z}else P==-3?h=z:P==-4&&(d=z);return R}let A=[],O=[];for(;c.pos>0;)m(t.start||0,t.bufferStart||0,A,O,-1,0);let E=(e=t.length)!==null&&e!==void 0?e:A.length?O[0]+A[0].length:0;return new It(u[t.topID],A.reverse(),O.reverse(),E)}const T5=new WeakMap;function hd(t,e){if(!t.isAnonymous||e instanceof Ws||e.type!=t)return 1;let n=T5.get(e);if(n==null){n=1;for(let i of e.children){if(i.type!=t||!(i instanceof It)){n=1;break}n+=hd(t,i)}T5.set(e,n)}return n}function AC(t,e,n,i,r,s,o,c,u){let h=0;for(let x=i;x<r;x++)h+=hd(t,e[x]);let d=Math.ceil(h*1.5/8),m=[],g=[];function y(x,w,S,C,A){for(let O=S;O<C;){let E=O,T=w[O],M=hd(t,x[O]);for(O++;O<C;O++){let R=hd(t,x[O]);if(M+R>=d)break;M+=R}if(O==E+1){if(M>d){let R=x[E];y(R.children,R.positions,0,R.children.length,w[E]+A);continue}m.push(x[E])}else{let R=w[O-1]+x[O-1].length-T;m.push(AC(t,x,w,E,O,T,R,null,u))}g.push(T+A-s)}}return y(e,n,i,r,0),(c||u)(m,g,o)}class ja{constructor(e,n,i,r,s=!1,o=!1){this.from=e,this.to=n,this.tree=i,this.offset=r,this.open=(s?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,n=[],i=!1){let r=[new ja(0,e.length,e,0,!1,i)];for(let s of n)s.to>e.length&&r.push(s);return r}static applyChanges(e,n,i=128){if(!n.length)return e;let r=[],s=1,o=e.length?e[0]:null;for(let c=0,u=0,h=0;;c++){let d=c<n.length?n[c]:null,m=d?d.fromA:1e9;if(m-u>=i)for(;o&&o.from<m;){let g=o;if(u>=g.from||m<=g.to||h){let y=Math.max(g.from,u)-h,x=Math.min(g.to,m)-h;g=y>=x?null:new ja(y,x,g.tree,g.offset+h,c>0,!!d)}if(g&&r.push(g),o.to>m)break;o=s<e.length?e[s++]:null}if(!d)break;u=d.toA,h=d.toA-d.toB}return r}}class oq{startParse(e,n,i){return typeof e=="string"&&(e=new Wne(e)),i=i?i.length?i.map(r=>new gw(r.from,r.to)):[new gw(0,0)]:[new gw(0,e.length)],this.createParse(e,n||[],i)}parse(e,n,i){let r=this.startParse(e,n,i);for(;;){let s=r.advance();if(s)return s}}}class Wne{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}new Fe({perNode:!0});let Kne=0,Ur=class YS{constructor(e,n,i,r){this.name=e,this.set=n,this.base=i,this.modified=r,this.id=Kne++}toString(){let{name:e}=this;for(let n of this.modified)n.name&&(e=`${n.name}(${e})`);return e}static define(e,n){let i=typeof e=="string"?e:"?";if(e instanceof YS&&(n=e),n?.base)throw new Error("Can not derive from a modified tag");let r=new YS(i,[],null,[]);if(r.set.push(r),n)for(let s of n.set)r.set.push(s);return r}static defineModifier(e){let n=new $d(e);return i=>i.modified.indexOf(n)>-1?i:$d.get(i.base||i,i.modified.concat(n).sort((r,s)=>r.id-s.id))}},Zne=0;class $d{constructor(e){this.name=e,this.instances=[],this.id=Zne++}static get(e,n){if(!n.length)return e;let i=n[0].instances.find(c=>c.base==e&&Jne(n,c.modified));if(i)return i;let r=[],s=new Ur(e.name,r,e,n);for(let c of n)c.instances.push(s);let o=eie(n);for(let c of e.set)if(!c.modified.length)for(let u of o)r.push($d.get(c,u));return s}}function Jne(t,e){return t.length==e.length&&t.every((n,i)=>n==e[i])}function eie(t){let e=[[]];for(let n=0;n<t.length;n++)for(let i=0,r=e.length;i<r;i++)e.push(e[i].concat(t[n]));return e.sort((n,i)=>i.length-n.length)}function lq(t){let e=Object.create(null);for(let n in t){let i=t[n];Array.isArray(i)||(i=[i]);for(let r of n.split(" "))if(r){let s=[],o=2,c=r;for(let m=0;;){if(c=="..."&&m>0&&m+3==r.length){o=1;break}let g=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(c);if(!g)throw new RangeError("Invalid path: "+r);if(s.push(g[0]=="*"?"":g[0][0]=='"'?JSON.parse(g[0]):g[0]),m+=g[0].length,m==r.length)break;let y=r[m++];if(m==r.length&&y=="!"){o=0;break}if(y!="/")throw new RangeError("Invalid path: "+r);c=r.slice(m)}let u=s.length-1,h=s[u];if(!h)throw new RangeError("Invalid path: "+r);let d=new Su(i,o,u>0?s.slice(0,u):null);e[h]=d.sort(e[h])}}return cq.add(e)}const cq=new Fe({combine(t,e){let n,i,r;for(;t||e;){if(!t||e&&t.depth>=e.depth?(r=e,e=e.next):(r=t,t=t.next),n&&n.mode==r.mode&&!r.context&&!n.context)continue;let s=new Su(r.tags,r.mode,r.context);n?n.next=s:i=s,n=s}return i}});class Su{constructor(e,n,i,r){this.tags=e,this.mode=n,this.context=i,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}}Su.empty=new Su([],2,null);function uq(t,e){let n=Object.create(null);for(let s of t)if(!Array.isArray(s.tag))n[s.tag.id]=s.class;else for(let o of s.tag)n[o.id]=s.class;let{scope:i,all:r=null}=e||{};return{style:s=>{let o=r;for(let c of s)for(let u of c.set){let h=n[u.id];if(h){o=o?o+" "+h:h;break}}return o},scope:i}}function tie(t,e){let n=null;for(let i of t){let r=i.style(e);r&&(n=n?n+" "+r:r)}return n}function nie(t,e,n,i=0,r=t.length){let s=new iie(i,Array.isArray(e)?e:[e],n);s.highlightRange(t.cursor(),i,r,"",s.highlighters),s.flush(r)}class iie{constructor(e,n,i){this.at=e,this.highlighters=n,this.span=i,this.class=""}startSpan(e,n){n!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=n)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,n,i,r,s){let{type:o,from:c,to:u}=e;if(c>=i||u<=n)return;o.isTop&&(s=this.highlighters.filter(y=>!y.scope||y.scope(o)));let h=r,d=rie(e)||Su.empty,m=tie(s,d.tags);if(m&&(h&&(h+=" "),h+=m,d.mode==1&&(r+=(r?" ":"")+m)),this.startSpan(Math.max(n,c),h),d.opaque)return;let g=e.tree&&e.tree.prop(Fe.mounted);if(g&&g.overlay){let y=e.node.enter(g.overlay[0].from+c,1),x=this.highlighters.filter(S=>!S.scope||S.scope(g.tree.type)),w=e.firstChild();for(let S=0,C=c;;S++){let A=S<g.overlay.length?g.overlay[S]:null,O=A?A.from+c:u,E=Math.max(n,C),T=Math.min(i,O);if(E<T&&w)for(;e.from<T&&(this.highlightRange(e,E,T,r,s),this.startSpan(Math.min(T,e.to),h),!(e.to>=O||!e.nextSibling())););if(!A||O>i)break;C=A.to+c,C>n&&(this.highlightRange(y.cursor(),Math.max(n,A.from+c),Math.min(i,C),"",x),this.startSpan(Math.min(i,C),h))}w&&e.parent()}else if(e.firstChild()){g&&(r="");do if(!(e.to<=n)){if(e.from>=i)break;this.highlightRange(e,n,i,r,s),this.startSpan(Math.min(i,e.to),h)}while(e.nextSibling());e.parent()}}}function rie(t){let e=t.type.prop(cq);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}const xe=Ur.define,Yh=xe(),Ls=xe(),M5=xe(Ls),R5=xe(Ls),zs=xe(),Qh=xe(zs),yw=xe(zs),Ji=xe(),ka=xe(Ji),Ki=xe(),Zi=xe(),QS=xe(),Dc=xe(QS),Xh=xe(),le={comment:Yh,lineComment:xe(Yh),blockComment:xe(Yh),docComment:xe(Yh),name:Ls,variableName:xe(Ls),typeName:M5,tagName:xe(M5),propertyName:R5,attributeName:xe(R5),className:xe(Ls),labelName:xe(Ls),namespace:xe(Ls),macroName:xe(Ls),literal:zs,string:Qh,docString:xe(Qh),character:xe(Qh),attributeValue:xe(Qh),number:yw,integer:xe(yw),float:xe(yw),bool:xe(zs),regexp:xe(zs),escape:xe(zs),color:xe(zs),url:xe(zs),keyword:Ki,self:xe(Ki),null:xe(Ki),atom:xe(Ki),unit:xe(Ki),modifier:xe(Ki),operatorKeyword:xe(Ki),controlKeyword:xe(Ki),definitionKeyword:xe(Ki),moduleKeyword:xe(Ki),operator:Zi,derefOperator:xe(Zi),arithmeticOperator:xe(Zi),logicOperator:xe(Zi),bitwiseOperator:xe(Zi),compareOperator:xe(Zi),updateOperator:xe(Zi),definitionOperator:xe(Zi),typeOperator:xe(Zi),controlOperator:xe(Zi),punctuation:QS,separator:xe(QS),bracket:Dc,angleBracket:xe(Dc),squareBracket:xe(Dc),paren:xe(Dc),brace:xe(Dc),content:Ji,heading:ka,heading1:xe(ka),heading2:xe(ka),heading3:xe(ka),heading4:xe(ka),heading5:xe(ka),heading6:xe(ka),contentSeparator:xe(Ji),list:xe(Ji),quote:xe(Ji),emphasis:xe(Ji),strong:xe(Ji),link:xe(Ji),monospace:xe(Ji),strikethrough:xe(Ji),inserted:xe(),deleted:xe(),changed:xe(),invalid:xe(),meta:Xh,documentMeta:xe(Xh),annotation:xe(Xh),processingInstruction:xe(Xh),definition:Ur.defineModifier("definition"),constant:Ur.defineModifier("constant"),function:Ur.defineModifier("function"),standard:Ur.defineModifier("standard"),local:Ur.defineModifier("local"),special:Ur.defineModifier("special")};for(let t in le){let e=le[t];e instanceof Ur&&(e.name=t)}uq([{tag:le.link,class:"tok-link"},{tag:le.heading,class:"tok-heading"},{tag:le.emphasis,class:"tok-emphasis"},{tag:le.strong,class:"tok-strong"},{tag:le.keyword,class:"tok-keyword"},{tag:le.atom,class:"tok-atom"},{tag:le.bool,class:"tok-bool"},{tag:le.url,class:"tok-url"},{tag:le.labelName,class:"tok-labelName"},{tag:le.inserted,class:"tok-inserted"},{tag:le.deleted,class:"tok-deleted"},{tag:le.literal,class:"tok-literal"},{tag:le.string,class:"tok-string"},{tag:le.number,class:"tok-number"},{tag:[le.regexp,le.escape,le.special(le.string)],class:"tok-string2"},{tag:le.variableName,class:"tok-variableName"},{tag:le.local(le.variableName),class:"tok-variableName tok-local"},{tag:le.definition(le.variableName),class:"tok-variableName tok-definition"},{tag:le.special(le.variableName),class:"tok-variableName2"},{tag:le.definition(le.propertyName),class:"tok-propertyName tok-definition"},{tag:le.typeName,class:"tok-typeName"},{tag:le.namespace,class:"tok-namespace"},{tag:le.className,class:"tok-className"},{tag:le.macroName,class:"tok-macroName"},{tag:le.propertyName,class:"tok-propertyName"},{tag:le.operator,class:"tok-operator"},{tag:le.comment,class:"tok-comment"},{tag:le.meta,class:"tok-meta"},{tag:le.invalid,class:"tok-invalid"},{tag:le.punctuation,class:"tok-punctuation"}]);var vw;const Wo=new Fe;function sie(t){return ke.define({combine:t?e=>e.concat(t):void 0})}const aie=new Fe;class Bi{constructor(e,n,i=[],r=""){this.data=e,this.name=r,Je.prototype.hasOwnProperty("tree")||Object.defineProperty(Je.prototype,"tree",{get(){return Cn(this)}}),this.parser=n,this.extension=[Ks.of(this),Je.languageData.of((s,o,c)=>{let u=N5(s,o,c),h=u.type.prop(Wo);if(!h)return[];let d=s.facet(h),m=u.type.prop(aie);if(m){let g=u.resolve(o-u.from,c);for(let y of m)if(y.test(g,s)){let x=s.facet(y.facet);return y.type=="replace"?x:x.concat(d)}}return d})].concat(i)}isActiveAt(e,n,i=-1){return N5(e,n,i).type.prop(Wo)==this.data}findRegions(e){let n=e.facet(Ks);if(n?.data==this.data)return[{from:0,to:e.doc.length}];if(!n||!n.allowsNesting)return[];let i=[],r=(s,o)=>{if(s.prop(Wo)==this.data){i.push({from:o,to:o+s.length});return}let c=s.prop(Fe.mounted);if(c){if(c.tree.prop(Wo)==this.data){if(c.overlay)for(let u of c.overlay)i.push({from:u.from+o,to:u.to+o});else i.push({from:o,to:o+s.length});return}else if(c.overlay){let u=i.length;if(r(c.tree,c.overlay[0].from+o),i.length>u)return}}for(let u=0;u<s.children.length;u++){let h=s.children[u];h instanceof It&&r(h,s.positions[u]+o)}};return r(Cn(e),0),i}get allowsNesting(){return!0}}Bi.setState=je.define();function N5(t,e,n){let i=t.facet(Ks),r=Cn(t).topNode;if(!i||i.allowsNesting)for(let s=r;s;s=s.enter(e,n,Nt.ExcludeBuffers|Nt.EnterBracketed))s.type.isTop&&(r=s);return r}class Gd extends Bi{constructor(e,n,i){super(e,n,[],i),this.parser=n}static define(e){let n=sie(e.languageData);return new Gd(n,e.parser.configure({props:[Wo.add(i=>i.isTop?n:void 0)]}),e.name)}configure(e,n){return new Gd(this.data,this.parser.configure(e),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function Cn(t){let e=t.field(Bi.state,!1);return e?e.tree:It.empty}class oie{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,n){let i=this.cursorPos-this.string.length;return e<i||n>=this.cursorPos?this.doc.sliceString(e,n):this.string.slice(e-i,n-i)}}let Lc=null;class Yd{constructor(e,n,i=[],r,s,o,c,u){this.parser=e,this.state=n,this.fragments=i,this.tree=r,this.treeLen=s,this.viewport=o,this.skipped=c,this.scheduleOn=u,this.parse=null,this.tempSkipped=[]}static create(e,n,i){return new Yd(e,n,[],It.empty,0,i,[],null)}startParse(){return this.parser.startParse(new oie(this.state.doc),this.fragments)}work(e,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=It.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof e=="number"){let r=Date.now()+e;e=()=>Date.now()>r}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n<this.state.doc.length&&this.parse.stopAt(n);;){let r=this.parse.advance();if(r)if(this.fragments=this.withoutTempSkipped(ja.addTree(r,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(i=this.parse.stoppedAt)!==null&&i!==void 0?i:this.state.doc.length,this.tree=r,this.parse=null,this.treeLen<(n??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,n;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=e,this.tree=n,this.fragments=this.withoutTempSkipped(ja.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let n=Lc;Lc=this;try{return e()}finally{Lc=n}}withoutTempSkipped(e){for(let n;n=this.tempSkipped.pop();)e=D5(e,n.from,n.to);return e}changes(e,n){let{fragments:i,tree:r,treeLen:s,viewport:o,skipped:c}=this;if(this.takeTree(),!e.empty){let u=[];if(e.iterChangedRanges((h,d,m,g)=>u.push({fromA:h,toA:d,fromB:m,toB:g})),i=ja.applyChanges(i,u),r=It.empty,s=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){c=[];for(let h of this.skipped){let d=e.mapPos(h.from,1),m=e.mapPos(h.to,-1);d<m&&c.push({from:d,to:m})}}}return new Yd(this.parser,n,i,r,s,o,c,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let n=this.skipped.length;for(let i=0;i<this.skipped.length;i++){let{from:r,to:s}=this.skipped[i];r<e.to&&s>e.from&&(this.fragments=D5(this.fragments,r,s),this.skipped.splice(i--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,n){this.skipped.push({from:e,to:n})}static getSkippingParser(e){return new class extends oq{createParse(n,i,r){let s=r[0].from,o=r[r.length-1].to;return{parsedPos:s,advance(){let u=Lc;if(u){for(let h of r)u.tempSkipped.push(h);e&&(u.scheduleOn=u.scheduleOn?Promise.all([u.scheduleOn,e]):e)}return this.parsedPos=o,new It(Xn.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let n=this.fragments;return this.treeLen>=e&&n.length&&n[0].from==0&&n[0].to>=e}static get(){return Lc}}function D5(t,e,n){return ja.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class vl{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(e.changes,e.state),i=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,i)||n.takeTree(),new vl(n)}static init(e){let n=Math.min(3e3,e.doc.length),i=Yd.create(e.facet(Ks).parser,e,{from:0,to:n});return i.work(20,n)||i.takeTree(),new vl(i)}}Bi.state=_n.define({create:vl.init,update(t,e){for(let n of e.effects)if(n.is(Bi.setState))return n.value;return e.startState.facet(Ks)!=e.state.facet(Ks)?vl.init(e.state):t.apply(e)}});let fq=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(fq=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const bw=typeof navigator<"u"&&(!((vw=navigator.scheduling)===null||vw===void 0)&&vw.isInputPending)?()=>navigator.scheduling.isInputPending():null,lie=zt.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 n=this.view.state.field(Bi.state).context;(n.updateViewport(e.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:e}=this.view,n=e.field(Bi.state);(n.tree!=n.context.tree||!n.context.isDone(e.doc.length))&&(this.working=fq(this.work))}work(e){this.working=null;let n=Date.now();if(this.chunkEnd<n&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=n+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:i,viewport:{to:r}}=this.view,s=i.field(Bi.state);if(s.tree==s.context.tree&&s.context.isDone(r+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!bw?Math.max(25,e.timeRemaining()-5):1e9),c=s.context.treeLen<r&&i.doc.length>r+1e3,u=s.context.work(()=>bw&&bw()||Date.now()>o,r+(c?0:1e5));this.chunkBudget-=Date.now()-n,(u||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:Bi.setState.of(new vl(s.context))})),this.chunkBudget>0&&!(u&&!c)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(n=>Fn(this.view.state,n)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Ks=ke.define({combine(t){return t.length?t[0]:null},enables:t=>[Bi.state,lie,Se.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]});class cie{constructor(e,n=[]){this.language=e,this.support=n,this.extension=[e,n]}}const uie=ke.define(),Vp=ke.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(n=>n!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function Qd(t){let e=t.facet(Vp);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function Cu(t,e){let n="",i=t.tabSize,r=t.facet(Vp)[0];if(r==" "){for(;e>=i;)n+=" ",e-=i;r=" "}for(let s=0;s<e;s++)n+=r;return n}function _C(t,e){t instanceof Je&&(t=new Fp(t));for(let i of t.state.facet(uie)){let r=i(t,e);if(r!==void 0)return r}let n=Cn(t.state);return n.length>=e?fie(t,n,e):null}class Fp{constructor(e,n={}){this.state=e,this.options=n,this.unit=Qd(e)}lineAt(e,n=1){let i=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:s}=this.options;return r!=null&&r>=i.from&&r<=i.to?s&&r==e?{text:"",from:e}:(n<0?r<e:r<=e)?{text:i.text.slice(r-i.from),from:r}:{text:i.text.slice(0,r-i.from),from:i.from}:i}textAfterPos(e,n=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:i,from:r}=this.lineAt(e,n);return i.slice(e-r,Math.min(i.length,e+100-r))}column(e,n=1){let{text:i,from:r}=this.lineAt(e,n),s=this.countColumn(i,e-r),o=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return o>-1&&(s+=o-this.countColumn(i,i.search(/\S|$/))),s}countColumn(e,n=e.length){return Ol(e,this.state.tabSize,n)}lineIndent(e,n=1){let{text:i,from:r}=this.lineAt(e,n),s=this.options.overrideIndentation;if(s){let o=s(r);if(o>-1)return o}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const hq=new Fe;function fie(t,e,n){let i=e.resolveStack(n),r=e.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(r!=i.node){let s=[];for(let o=r;o&&!(o.from<i.node.from||o.to>i.node.to||o.from==i.node.from&&o.type==i.node.type);o=o.parent)s.push(o);for(let o=s.length-1;o>=0;o--)i={node:s[o],next:i}}return dq(i,t,n)}function dq(t,e,n){for(let i=t;i;i=i.next){let r=die(i.node);if(r)return r(OC.create(e,n,i))}return 0}function hie(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function die(t){let e=t.type.prop(hq);if(e)return e;let n=t.firstChild,i;if(n&&(i=n.type.prop(Fe.closedBy))){let r=t.lastChild,s=r&&i.indexOf(r.name)>-1;return o=>pq(o,!0,1,void 0,s&&!hie(o)?r.from:void 0)}return t.parent==null?pie:null}function pie(){return 0}class OC extends Fp{constructor(e,n,i){super(e.state,e.options),this.base=e,this.pos=n,this.context=i}get node(){return this.context.node}static create(e,n,i){return new OC(e,n,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let n=this.state.doc.lineAt(e.from);for(;;){let i=e.resolve(n.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(mie(i,e))break;n=this.state.doc.lineAt(i.from)}return this.lineIndent(n.from)}continue(){return dq(this.context.next,this.base,this.pos)}}function mie(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}function gie(t){let e=t.node,n=e.childAfter(e.from),i=e.lastChild;if(!n)return null;let r=t.options.simulateBreak,s=t.state.doc.lineAt(n.from),o=r==null||r<=s.from?s.to:Math.min(s.to,r);for(let c=n.to;;){let u=e.childAfter(c);if(!u||u==i)return null;if(!u.type.isSkipped){if(u.from>=o)return null;let h=/^ */.exec(s.text.slice(n.to-s.from))[0].length;return{from:n.from,to:n.to+h}}c=u.to}}function L5({closing:t,align:e=!0,units:n=1}){return i=>pq(i,e,n,t)}function pq(t,e,n,i,r){let s=t.textAfter,o=s.match(/^\s*/)[0].length,c=i&&s.slice(o,o+i.length)==i||r==t.pos+o,u=e?gie(t):null;return u?c?t.column(u.from):t.column(u.to):t.baseIndent+(c?0:t.unit*n)}const yie=200;function vie(){return Je.transactionFilter.of(t=>{if(!t.docChanged||!t.isUserEvent("input.type")&&!t.isUserEvent("input.complete"))return t;let e=t.startState.languageDataAt("indentOnInput",t.startState.selection.main.head);if(!e.length)return t;let n=t.newDoc,{head:i}=t.newSelection.main,r=n.lineAt(i);if(i>r.from+yie)return t;let s=n.sliceString(r.from,i);if(!e.some(h=>h.test(s)))return t;let{state:o}=t,c=-1,u=[];for(let{head:h}of o.selection.ranges){let d=o.doc.lineAt(h);if(d.from==c)continue;c=d.from;let m=_C(o,d.from);if(m==null)continue;let g=/^\s*/.exec(d.text)[0],y=Cu(o,m);g!=y&&u.push({from:d.from,to:d.from+g.length,insert:y})}return u.length?[t,{changes:u,sequential:!0}]:t})}const bie=ke.define(),mq=new Fe;function xie(t){let e=t.firstChild,n=t.lastChild;return e&&e.to<n.from?{from:e.to,to:n.type.isError?t.to:n.from}:null}function wie(t,e,n){let i=Cn(t);if(i.length<n)return null;let r=i.resolveStack(n,1),s=null;for(let o=r;o;o=o.next){let c=o.node;if(c.to<=n||c.from>n)continue;if(s&&c.from<e)break;let u=c.type.prop(mq);if(u&&(c.to<i.length-50||i.length==t.doc.length||!Sie(c))){let h=u(c,t);h&&h.from<=n&&h.from>=e&&h.to>n&&(s=h)}}return s}function Sie(t){let e=t.lastChild;return e&&e.to==t.to&&e.type.isError}function Xd(t,e,n){for(let i of t.facet(bie)){let r=i(t,e,n);if(r)return r}return wie(t,e,n)}function gq(t,e){let n=e.mapPos(t.from,1),i=e.mapPos(t.to,-1);return n>=i?void 0:{from:n,to:i}}const $p=je.define({map:gq}),Fu=je.define({map:gq});function yq(t){let e=[];for(let{head:n}of t.state.selection.ranges)e.some(i=>i.from<=n&&i.to>=n)||e.push(t.lineBlockAt(n));return e}const $a=_n.define({create(){return Le.none},update(t,e){e.isUserEvent("delete")&&e.changes.iterChangedRanges((n,i)=>t=z5(t,n,i)),t=t.map(e.changes);for(let n of e.effects)if(n.is($p)&&!Cie(t,n.value.from,n.value.to)){let{preparePlaceholder:i}=e.state.facet(xq),r=i?Le.replace({widget:new Mie(i(e.state,n.value))}):B5;t=t.update({add:[r.range(n.value.from,n.value.to)]})}else n.is(Fu)&&(t=t.update({filter:(i,r)=>n.value.from!=i||n.value.to!=r,filterFrom:n.value.from,filterTo:n.value.to}));return e.selection&&(t=z5(t,e.selection.main.head)),t},provide:t=>Se.decorations.from(t),toJSON(t,e){let n=[];return t.between(0,e.doc.length,(i,r)=>{n.push(i,r)}),n},fromJSON(t){if(!Array.isArray(t)||t.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let n=0;n<t.length;){let i=t[n++],r=t[n++];if(typeof i!="number"||typeof r!="number")throw new RangeError("Invalid JSON for fold state");e.push(B5.range(i,r))}return Le.set(e,!0)}});function z5(t,e,n=e){let i=!1;return t.between(e,n,(r,s)=>{r<n&&s>e&&(i=!0)}),i?t.update({filterFrom:e,filterTo:n,filter:(r,s)=>r>=n||s<=e}):t}function Wd(t,e,n){var i;let r=null;return(i=t.field($a,!1))===null||i===void 0||i.between(e,n,(s,o)=>{(!r||r.from>s)&&(r={from:s,to:o})}),r}function Cie(t,e,n){let i=!1;return t.between(e,e,(r,s)=>{r==e&&s==n&&(i=!0)}),i}function vq(t,e){return t.field($a,!1)?e:e.concat(je.appendConfig.of(wq()))}const kie=t=>{for(let e of yq(t)){let n=Xd(t.state,e.from,e.to);if(n)return t.dispatch({effects:vq(t.state,[$p.of(n),bq(t,n)])}),!0}return!1},Aie=t=>{if(!t.state.field($a,!1))return!1;let e=[];for(let n of yq(t)){let i=Wd(t.state,n.from,n.to);i&&e.push(Fu.of(i),bq(t,i,!1))}return e.length&&t.dispatch({effects:e}),e.length>0};function bq(t,e,n=!0){let i=t.state.doc.lineAt(e.from).number,r=t.state.doc.lineAt(e.to).number;return Se.announce.of(`${t.state.phrase(n?"Folded lines":"Unfolded lines")} ${i} ${t.state.phrase("to")} ${r}.`)}const _ie=t=>{let{state:e}=t,n=[];for(let i=0;i<e.doc.length;){let r=t.lineBlockAt(i),s=Xd(e,r.from,r.to);s&&n.push($p.of(s)),i=(s?t.lineBlockAt(s.to):r).to+1}return n.length&&t.dispatch({effects:vq(t.state,n)}),!!n.length},Oie=t=>{let e=t.state.field($a,!1);if(!e||!e.size)return!1;let n=[];return e.between(0,t.state.doc.length,(i,r)=>{n.push(Fu.of({from:i,to:r}))}),t.dispatch({effects:n}),!0},Eie=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:kie},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:Aie},{key:"Ctrl-Alt-[",run:_ie},{key:"Ctrl-Alt-]",run:Oie}],Tie={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},xq=ke.define({combine(t){return pr(t,Tie)}});function wq(t){return[$a,Die]}function Sq(t,e){let{state:n}=t,i=n.facet(xq),r=o=>{let c=t.lineBlockAt(t.posAtDOM(o.target)),u=Wd(t.state,c.from,c.to);u&&t.dispatch({effects:Fu.of(u)}),o.preventDefault()};if(i.placeholderDOM)return i.placeholderDOM(t,r,e);let s=document.createElement("span");return s.textContent=i.placeholderText,s.setAttribute("aria-label",n.phrase("folded code")),s.title=n.phrase("unfold"),s.className="cm-foldPlaceholder",s.onclick=r,s}const B5=Le.replace({widget:new class extends mr{toDOM(t){return Sq(t,null)}}});class Mie extends mr{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return Sq(e,this.value)}}const Rie={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class xw extends Jr{constructor(e,n){super(),this.config=e,this.open=n}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let n=document.createElement("span");return n.textContent=this.open?this.config.openText:this.config.closedText,n.title=e.state.phrase(this.open?"Fold line":"Unfold line"),n}}function Nie(t={}){let e={...Rie,...t},n=new xw(e,!0),i=new xw(e,!1),r=zt.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(Ks)!=o.state.facet(Ks)||o.startState.field($a,!1)!=o.state.field($a,!1)||Cn(o.startState)!=Cn(o.state)||e.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let c=new Kr;for(let u of o.viewportLineBlocks){let h=Wd(o.state,u.from,u.to)?i:Xd(o.state,u.from,u.to)?n:null;h&&c.add(u.from,u.from,h)}return c.finish()}}),{domEventHandlers:s}=e;return[r,Dne({class:"cm-foldGutter",markers(o){var c;return((c=o.plugin(r))===null||c===void 0?void 0:c.markers)||Ye.empty},initialSpacer(){return new xw(e,!1)},domEventHandlers:{...s,click:(o,c,u)=>{if(s.click&&s.click(o,c,u))return!0;let h=Wd(o.state,c.from,c.to);if(h)return o.dispatch({effects:Fu.of(h)}),!0;let d=Xd(o.state,c.from,c.to);return d?(o.dispatch({effects:$p.of(d)}),!0):!1}}}),wq()]}const Die=Se.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class $u{constructor(e,n){this.specs=e;let i;function r(c){let u=Ys.newName();return(i||(i=Object.create(null)))["."+u]=c,u}const s=typeof n.all=="string"?n.all:n.all?r(n.all):void 0,o=n.scope;this.scope=o instanceof Bi?c=>c.prop(Wo)==o.data:o?c=>c==o:void 0,this.style=uq(e.map(c=>({tag:c.tag,class:c.class||r(Object.assign({},c,{tag:null}))})),{all:s}).style,this.module=i?new Ys(i):null,this.themeType=n.themeType}static define(e,n){return new $u(e,n||{})}}const XS=ke.define(),Cq=ke.define({combine(t){return t.length?[t[0]]:null}});function ww(t){let e=t.facet(XS);return e.length?e:t.facet(Cq)}function kq(t,e){let n=[zie],i;return t instanceof $u&&(t.module&&n.push(Se.styleModule.of(t.module)),i=t.themeType),e?.fallback?n.push(Cq.of(t)):i?n.push(XS.computeN([Se.darkTheme],r=>r.facet(Se.darkTheme)==(i=="dark")?[t]:[])):n.push(XS.of(t)),n}class Lie{constructor(e){this.markCache=Object.create(null),this.tree=Cn(e.state),this.decorations=this.buildDeco(e,ww(e.state)),this.decoratedTo=e.viewport.to}update(e){let n=Cn(e.state),i=ww(e.state),r=i!=ww(e.startState),{viewport:s}=e.view,o=e.changes.mapPos(this.decoratedTo,1);n.length<s.to&&!r&&n.type==this.tree.type&&o>=s.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(n!=this.tree||e.viewportChanged||r)&&(this.tree=n,this.decorations=this.buildDeco(e.view,i),this.decoratedTo=s.to)}buildDeco(e,n){if(!n||!this.tree.length)return Le.none;let i=new Kr;for(let{from:r,to:s}of e.visibleRanges)nie(this.tree,n,(o,c,u)=>{i.add(o,c,this.markCache[u]||(this.markCache[u]=Le.mark({class:u})))},r,s);return i.finish()}}const zie=Za.high(zt.fromClass(Lie,{decorations:t=>t.decorations})),Bie=$u.define([{tag:le.meta,color:"#404740"},{tag:le.link,textDecoration:"underline"},{tag:le.heading,textDecoration:"underline",fontWeight:"bold"},{tag:le.emphasis,fontStyle:"italic"},{tag:le.strong,fontWeight:"bold"},{tag:le.strikethrough,textDecoration:"line-through"},{tag:le.keyword,color:"#708"},{tag:[le.atom,le.bool,le.url,le.contentSeparator,le.labelName],color:"#219"},{tag:[le.literal,le.inserted],color:"#164"},{tag:[le.string,le.deleted],color:"#a11"},{tag:[le.regexp,le.escape,le.special(le.string)],color:"#e40"},{tag:le.definition(le.variableName),color:"#00f"},{tag:le.local(le.variableName),color:"#30a"},{tag:[le.typeName,le.namespace],color:"#085"},{tag:le.className,color:"#167"},{tag:[le.special(le.variableName),le.macroName],color:"#256"},{tag:le.definition(le.propertyName),color:"#00c"},{tag:le.comment,color:"#940"},{tag:le.invalid,color:"#f00"}]),qie=Se.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Aq=1e4,_q="()[]{}",Oq=ke.define({combine(t){return pr(t,{afterCursor:!0,brackets:_q,maxScanDistance:Aq,renderMatch:Pie})}}),jie=Le.mark({class:"cm-matchingBracket"}),Iie=Le.mark({class:"cm-nonmatchingBracket"});function Pie(t){let e=[],n=t.matched?jie:Iie;return e.push(n.range(t.start.from,t.start.to)),t.end&&e.push(n.range(t.end.from,t.end.to)),e}function q5(t){let e=[],n=t.facet(Oq);for(let i of t.selection.ranges){if(!i.empty)continue;let r=ar(t,i.head,-1,n)||i.head>0&&ar(t,i.head-1,1,n)||n.afterCursor&&(ar(t,i.head,1,n)||i.head<t.doc.length&&ar(t,i.head+1,-1,n));r&&(e=e.concat(n.renderMatch(r,t)))}return Le.set(e,!0)}const Hie=zt.fromClass(class{constructor(t){this.paused=!1,this.decorations=q5(t.state)}update(t){(t.docChanged||t.selectionSet||this.paused)&&(t.view.composing?(this.decorations=this.decorations.map(t.changes),this.paused=!0):(this.decorations=q5(t.state),this.paused=!1))}},{decorations:t=>t.decorations}),Uie=[Hie,qie];function Vie(t={}){return[Oq.of(t),Uie]}const Fie=new Fe;function WS(t,e,n){let i=t.prop(e<0?Fe.openedBy:Fe.closedBy);if(i)return i;if(t.name.length==1){let r=n.indexOf(t.name);if(r>-1&&r%2==(e<0?1:0))return[n[r+e]]}return null}function KS(t){let e=t.type.prop(Fie);return e?e(t.node):t}function ar(t,e,n,i={}){let r=i.maxScanDistance||Aq,s=i.brackets||_q,o=Cn(t),c=o.resolveInner(e,n);for(let u=c;u;u=u.parent){let h=WS(u.type,n,s);if(h&&u.from<u.to){let d=KS(u);if(d&&(n>0?e>=d.from&&e<d.to:e>d.from&&e<=d.to))return $ie(t,e,n,u,d,h,s)}}return Gie(t,e,n,o,c.type,r,s)}function $ie(t,e,n,i,r,s,o){let c=i.parent,u={from:r.from,to:r.to},h=0,d=c?.cursor();if(d&&(n<0?d.childBefore(i.from):d.childAfter(i.to)))do if(n<0?d.to<=i.from:d.from>=i.to){if(h==0&&s.indexOf(d.type.name)>-1&&d.from<d.to){let m=KS(d);return{start:u,end:m?{from:m.from,to:m.to}:void 0,matched:!0}}else if(WS(d.type,n,o))h++;else if(WS(d.type,-n,o)){if(h==0){let m=KS(d);return{start:u,end:m&&m.from<m.to?{from:m.from,to:m.to}:void 0,matched:!1}}h--}}while(n<0?d.prevSibling():d.nextSibling());return{start:u,matched:!1}}function Gie(t,e,n,i,r,s,o){let c=n<0?t.sliceDoc(e-1,e):t.sliceDoc(e,e+1),u=o.indexOf(c);if(u<0||u%2==0!=n>0)return null;let h={from:n<0?e-1:e,to:n>0?e+1:e},d=t.doc.iterRange(e,n>0?t.doc.length:0),m=0;for(let g=0;!d.next().done&&g<=s;){let y=d.value;n<0&&(g+=y.length);let x=e+g*n;for(let w=n>0?0:y.length-1,S=n>0?y.length:-1;w!=S;w+=n){let C=o.indexOf(y[w]);if(!(C<0||i.resolveInner(x+w,1).type!=r))if(C%2==0==n>0)m++;else{if(m==1)return{start:h,end:{from:x+w,to:x+w+1},matched:C>>1==u>>1};m--}}n>0&&(g+=y.length)}return d.done?{start:h,matched:!1}:null}const Yie=Object.create(null),j5=[Xn.none],I5=[],P5=Object.create(null),Qie=Object.create(null);for(let[t,e]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"]])Qie[t]=Xie(Yie,e);function Sw(t,e){I5.indexOf(t)>-1||(I5.push(t),console.warn(e))}function Xie(t,e){let n=[];for(let c of e.split(" ")){let u=[];for(let h of c.split(".")){let d=t[h]||le[h];d?typeof d=="function"?u.length?u=u.map(d):Sw(h,`Modifier ${h} used at start of tag`):u.length?Sw(h,`Tag ${h} used as modifier`):u=Array.isArray(d)?d:[d]:Sw(h,`Unknown highlighting tag ${h}`)}for(let h of u)n.push(h)}if(!n.length)return 0;let i=e.replace(/ /g,"_"),r=i+" "+n.map(c=>c.id),s=P5[r];if(s)return s.id;let o=P5[r]=Xn.define({id:j5.length,name:i,props:[lq({[i]:n})]});return j5.push(o),o.id}yt.RTL,yt.LTR;const Wie=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),i=TC(t.state,n.from);return i.line?Kie(t):i.block?Jie(t):!1};function EC(t,e){return({state:n,dispatch:i})=>{if(n.readOnly)return!1;let r=t(e,n);return r?(i(n.update(r)),!0):!1}}const Kie=EC(nre,0),Zie=EC(Eq,0),Jie=EC((t,e)=>Eq(t,e,tre(e)),0);function TC(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}const zc=50;function ere(t,{open:e,close:n},i,r){let s=t.sliceDoc(i-zc,i),o=t.sliceDoc(r,r+zc),c=/\s*$/.exec(s)[0].length,u=/^\s*/.exec(o)[0].length,h=s.length-c;if(s.slice(h-e.length,h)==e&&o.slice(u,u+n.length)==n)return{open:{pos:i-c,margin:c&&1},close:{pos:r+u,margin:u&&1}};let d,m;r-i<=2*zc?d=m=t.sliceDoc(i,r):(d=t.sliceDoc(i,i+zc),m=t.sliceDoc(r-zc,r));let g=/^\s*/.exec(d)[0].length,y=/\s*$/.exec(m)[0].length,x=m.length-y-n.length;return d.slice(g,g+e.length)==e&&m.slice(x,x+n.length)==n?{open:{pos:i+g+e.length,margin:/\s/.test(d.charAt(g+e.length))?1:0},close:{pos:r-y-n.length,margin:/\s/.test(m.charAt(x-1))?1:0}}:null}function tre(t){let e=[];for(let n of t.selection.ranges){let i=t.doc.lineAt(n.from),r=n.to<=i.to?i:t.doc.lineAt(n.to);r.from>i.from&&r.from==n.to&&(r=n.to==i.to+1?i:t.doc.lineAt(n.to-1));let s=e.length-1;s>=0&&e[s].to>i.from?e[s].to=r.to:e.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:r.to})}return e}function Eq(t,e,n=e.selection.ranges){let i=n.map(s=>TC(e,s.from).block);if(!i.every(s=>s))return null;let r=n.map((s,o)=>ere(e,i[o],s.from,s.to));if(t!=2&&!r.every(s=>s))return{changes:e.changes(n.map((s,o)=>r[o]?[]:[{from:s.from,insert:i[o].open+" "},{from:s.to,insert:" "+i[o].close}]))};if(t!=1&&r.some(s=>s)){let s=[];for(let o=0,c;o<r.length;o++)if(c=r[o]){let u=i[o],{open:h,close:d}=c;s.push({from:h.pos-u.open.length,to:h.pos+h.margin},{from:d.pos-d.margin,to:d.pos+u.close.length})}return{changes:s}}return null}function nre(t,e,n=e.selection.ranges){let i=[],r=-1;e:for(let{from:s,to:o}of n){let c=i.length,u=1e9,h;for(let d=s;d<=o;){let m=e.doc.lineAt(d);if(h==null&&(h=TC(e,m.from).line,!h))continue e;if(m.from>r&&(s==o||o>m.from)){r=m.from;let g=/^\s*/.exec(m.text)[0].length,y=g==m.length,x=m.text.slice(g,g+h.length)==h?g:-1;g<m.text.length&&g<u&&(u=g),i.push({line:m,comment:x,token:h,indent:g,empty:y,single:!1})}d=m.to+1}if(u<1e9)for(let d=c;d<i.length;d++)i[d].indent<i[d].line.text.length&&(i[d].indent=u);i.length==c+1&&(i[c].single=!0)}if(t!=2&&i.some(s=>s.comment<0&&(!s.empty||s.single))){let s=[];for(let{line:c,token:u,indent:h,empty:d,single:m}of i)(m||!d)&&s.push({from:c.from+h,insert:u+" "});let o=e.changes(s);return{changes:o,selection:e.selection.map(o,1)}}else if(t!=1&&i.some(s=>s.comment>=0)){let s=[];for(let{line:o,comment:c,token:u}of i)if(c>=0){let h=o.from+c,d=h+u.length;o.text[d-o.from]==" "&&d++,s.push({from:h,to:d})}return{changes:s}}return null}const ZS=dr.define(),ire=dr.define(),rre=ke.define(),Tq=ke.define({combine(t){return pr(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,n)=>(i,r)=>e(i,r)||n(i,r)})}}),Mq=_n.define({create(){return or.empty},update(t,e){let n=e.state.facet(Tq),i=e.annotation(ZS);if(i){let u=$n.fromTransaction(e,i.selection),h=i.side,d=h==0?t.undone:t.done;return u?d=Zd(d,d.length,n.minDepth,u):d=Nq(d,e.startState.selection),new or(h==0?i.rest:d,h==0?d:i.rest)}let r=e.annotation(ire);if((r=="full"||r=="before")&&(t=t.isolate()),e.annotation(Qt.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let s=$n.fromTransaction(e),o=e.annotation(Qt.time),c=e.annotation(Qt.userEvent);return s?t=t.addChanges(s,o,c,n,e):e.selection&&(t=t.addSelection(e.startState.selection,o,c,n.newGroupDelay)),(r=="full"||r=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new or(t.done.map($n.fromJSON),t.undone.map($n.fromJSON))}});function sre(t={}){return[Mq,Tq.of(t),Se.domEventHandlers({beforeinput(e,n){let i=e.inputType=="historyUndo"?MC:e.inputType=="historyRedo"?Kd:null;return i?(e.preventDefault(),i(n)):!1}})]}function Gp(t,e){return function({state:n,dispatch:i}){if(!e&&n.readOnly)return!1;let r=n.field(Mq,!1);if(!r)return!1;let s=r.pop(t,n,e);return s?(i(s),!0):!1}}const MC=Gp(0,!1),Kd=Gp(1,!1),are=Gp(0,!0),ore=Gp(1,!0);class $n{constructor(e,n,i,r,s){this.changes=e,this.effects=n,this.mapped=i,this.startSelection=r,this.selectionsAfter=s}setSelAfter(e){return new $n(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,n,i;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(i=this.startSelection)===null||i===void 0?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(r=>r.toJSON())}}static fromJSON(e){return new $n(e.changes&&en.fromJSON(e.changes),[],e.mapped&&ur.fromJSON(e.mapped),e.startSelection&&de.fromJSON(e.startSelection),e.selectionsAfter.map(de.fromJSON))}static fromTransaction(e,n){let i=ki;for(let r of e.startState.facet(rre)){let s=r(e);s.length&&(i=i.concat(s))}return!i.length&&e.changes.empty?null:new $n(e.changes.invert(e.startState.doc),i,void 0,n||e.startState.selection,ki)}static selection(e){return new $n(void 0,ki,void 0,void 0,e)}}function Zd(t,e,n,i){let r=e+1>n+20?e-n-1:0,s=t.slice(r,e);return s.push(i),s}function lre(t,e){let n=[],i=!1;return t.iterChangedRanges((r,s)=>n.push(r,s)),e.iterChangedRanges((r,s,o,c)=>{for(let u=0;u<n.length;){let h=n[u++],d=n[u++];c>=h&&o<=d&&(i=!0)}}),i}function cre(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,i)=>n.empty!=e.ranges[i].empty).length===0}function Rq(t,e){return t.length?e.length?t.concat(e):t:e}const ki=[],ure=200;function Nq(t,e){if(t.length){let n=t[t.length-1],i=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-ure));return i.length&&i[i.length-1].eq(e)?t:(i.push(e),Zd(t,t.length-1,1e9,n.setSelAfter(i)))}else return[$n.selection([e])]}function fre(t){let e=t[t.length-1],n=t.slice();return n[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function Cw(t,e){if(!t.length)return t;let n=t.length,i=ki;for(;n;){let r=hre(t[n-1],e,i);if(r.changes&&!r.changes.empty||r.effects.length){let s=t.slice(0,n);return s[n-1]=r,s}else e=r.mapped,n--,i=r.selectionsAfter}return i.length?[$n.selection(i)]:ki}function hre(t,e,n){let i=Rq(t.selectionsAfter.length?t.selectionsAfter.map(c=>c.map(e)):ki,n);if(!t.changes)return $n.selection(i);let r=t.changes.map(e),s=e.mapDesc(t.changes,!0),o=t.mapped?t.mapped.composeDesc(s):s;return new $n(r,je.mapEffects(t.effects,e),o,t.startSelection.map(s),i)}const dre=/^(input\.type|delete)($|\.)/;class or{constructor(e,n,i=0,r=void 0){this.done=e,this.undone=n,this.prevTime=i,this.prevUserEvent=r}isolate(){return this.prevTime?new or(this.done,this.undone):this}addChanges(e,n,i,r,s){let o=this.done,c=o[o.length-1];return c&&c.changes&&!c.changes.empty&&e.changes&&(!i||dre.test(i))&&(!c.selectionsAfter.length&&n-this.prevTime<r.newGroupDelay&&r.joinToEvent(s,lre(c.changes,e.changes))||i=="input.type.compose")?o=Zd(o,o.length-1,r.minDepth,new $n(e.changes.compose(c.changes),Rq(je.mapEffects(e.effects,c.changes),c.effects),c.mapped,c.startSelection,ki)):o=Zd(o,o.length,r.minDepth,e),new or(o,ki,n,i)}addSelection(e,n,i,r){let s=this.done.length?this.done[this.done.length-1].selectionsAfter:ki;return s.length>0&&n-this.prevTime<r&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&cre(s[s.length-1],e)?this:new or(Nq(this.done,e),this.undone,n,i)}addMapping(e){return new or(Cw(this.done,e),Cw(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,n,i){let r=e==0?this.done:this.undone;if(r.length==0)return null;let s=r[r.length-1],o=s.selectionsAfter[0]||(s.startSelection?s.startSelection.map(s.changes.invertedDesc,1):n.selection);if(i&&s.selectionsAfter.length)return n.update({selection:s.selectionsAfter[s.selectionsAfter.length-1],annotations:ZS.of({side:e,rest:fre(r),selection:o}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(s.changes){let c=r.length==1?ki:r.slice(0,r.length-1);return s.mapped&&(c=Cw(c,s.mapped)),n.update({changes:s.changes,selection:s.startSelection,effects:s.effects,annotations:ZS.of({side:e,rest:c,selection:o}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}}or.empty=new or(ki,ki);const pre=[{key:"Mod-z",run:MC,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Kd,preventDefault:!0},{linux:"Ctrl-Shift-z",run:Kd,preventDefault:!0},{key:"Mod-u",run:are,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:ore,preventDefault:!0}];function El(t,e){return de.create(t.ranges.map(e),t.mainIndex)}function Ui(t,e){return t.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function Vi({state:t,dispatch:e},n){let i=El(t.selection,n);return i.eq(t.selection,!0)?!1:(e(Ui(t,i)),!0)}function Yp(t,e){return de.cursor(e?t.to:t.from)}function Dq(t,e){return Vi(t,n=>n.empty?t.moveByChar(n,e):Yp(n,e))}function On(t){return t.textDirectionAt(t.state.selection.main.head)==yt.LTR}const Lq=t=>Dq(t,!On(t)),zq=t=>Dq(t,On(t));function Bq(t,e){return Vi(t,n=>n.empty?t.moveByGroup(n,e):Yp(n,e))}const mre=t=>Bq(t,!On(t)),gre=t=>Bq(t,On(t));function yre(t,e,n){if(e.type.prop(n))return!0;let i=e.to-e.from;return i&&(i>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function Qp(t,e,n){let i=Cn(t).resolveInner(e.head),r=n?Fe.closedBy:Fe.openedBy;for(let u=e.head;;){let h=n?i.childAfter(u):i.childBefore(u);if(!h)break;yre(t,h,r)?i=h:u=n?h.to:h.from}let s=i.type.prop(r),o,c;return s&&(o=n?ar(t,i.from,1):ar(t,i.to,-1))&&o.matched?c=n?o.end.to:o.end.from:c=n?i.to:i.from,de.cursor(c,n?-1:1)}const vre=t=>Vi(t,e=>Qp(t.state,e,!On(t))),bre=t=>Vi(t,e=>Qp(t.state,e,On(t)));function qq(t,e){return Vi(t,n=>{if(!n.empty)return Yp(n,e);let i=t.moveVertically(n,e);return i.head!=n.head?i:t.moveToLineBoundary(n,e)})}const jq=t=>qq(t,!1),Iq=t=>qq(t,!0);function Pq(t){let e=t.scrollDOM.clientHeight<t.scrollDOM.scrollHeight-2,n=0,i=0,r;if(e){for(let s of t.state.facet(Se.scrollMargins)){let o=s(t);o?.top&&(n=Math.max(o?.top,n)),o?.bottom&&(i=Math.max(o?.bottom,i))}r=t.scrollDOM.clientHeight-n-i}else r=(t.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:i,selfScroll:e,height:Math.max(t.defaultLineHeight,r-5)}}function Hq(t,e){let n=Pq(t),{state:i}=t,r=El(i.selection,o=>o.empty?t.moveVertically(o,e,n.height):Yp(o,e));if(r.eq(i.selection))return!1;let s;if(n.selfScroll){let o=t.coordsAtPos(i.selection.main.head),c=t.scrollDOM.getBoundingClientRect(),u=c.top+n.marginTop,h=c.bottom-n.marginBottom;o&&o.top>u&&o.bottom<h&&(s=Se.scrollIntoView(r.main.head,{y:"start",yMargin:o.top-u}))}return t.dispatch(Ui(i,r),{effects:s}),!0}const H5=t=>Hq(t,!1),JS=t=>Hq(t,!0);function ta(t,e,n){let i=t.lineBlockAt(e.head),r=t.moveToLineBoundary(e,n);if(r.head==e.head&&r.head!=(n?i.to:i.from)&&(r=t.moveToLineBoundary(e,n,!1)),!n&&r.head==i.from&&i.length){let s=/^\s*/.exec(t.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;s&&e.head!=i.from+s&&(r=de.cursor(i.from+s))}return r}const xre=t=>Vi(t,e=>ta(t,e,!0)),wre=t=>Vi(t,e=>ta(t,e,!1)),Sre=t=>Vi(t,e=>ta(t,e,!On(t))),Cre=t=>Vi(t,e=>ta(t,e,On(t))),kre=t=>Vi(t,e=>de.cursor(t.lineBlockAt(e.head).from,1)),Are=t=>Vi(t,e=>de.cursor(t.lineBlockAt(e.head).to,-1));function _re(t,e,n){let i=!1,r=El(t.selection,s=>{let o=ar(t,s.head,-1)||ar(t,s.head,1)||s.head>0&&ar(t,s.head-1,1)||s.head<t.doc.length&&ar(t,s.head+1,-1);if(!o||!o.end)return s;i=!0;let c=o.start.from==s.head?o.end.to:o.end.from;return de.cursor(c)});return i?(e(Ui(t,r)),!0):!1}const Ore=({state:t,dispatch:e})=>_re(t,e);function Ti(t,e){let n=El(t.state.selection,i=>{let r=e(i);return de.range(i.anchor,r.head,r.goalColumn,r.bidiLevel||void 0)});return n.eq(t.state.selection)?!1:(t.dispatch(Ui(t.state,n)),!0)}function Uq(t,e){return Ti(t,n=>t.moveByChar(n,e))}const Vq=t=>Uq(t,!On(t)),Fq=t=>Uq(t,On(t));function $q(t,e){return Ti(t,n=>t.moveByGroup(n,e))}const Ere=t=>$q(t,!On(t)),Tre=t=>$q(t,On(t)),Mre=t=>Ti(t,e=>Qp(t.state,e,!On(t))),Rre=t=>Ti(t,e=>Qp(t.state,e,On(t)));function Gq(t,e){return Ti(t,n=>t.moveVertically(n,e))}const Yq=t=>Gq(t,!1),Qq=t=>Gq(t,!0);function Xq(t,e){return Ti(t,n=>t.moveVertically(n,e,Pq(t).height))}const U5=t=>Xq(t,!1),V5=t=>Xq(t,!0),Nre=t=>Ti(t,e=>ta(t,e,!0)),Dre=t=>Ti(t,e=>ta(t,e,!1)),Lre=t=>Ti(t,e=>ta(t,e,!On(t))),zre=t=>Ti(t,e=>ta(t,e,On(t))),Bre=t=>Ti(t,e=>de.cursor(t.lineBlockAt(e.head).from)),qre=t=>Ti(t,e=>de.cursor(t.lineBlockAt(e.head).to)),F5=({state:t,dispatch:e})=>(e(Ui(t,{anchor:0})),!0),$5=({state:t,dispatch:e})=>(e(Ui(t,{anchor:t.doc.length})),!0),G5=({state:t,dispatch:e})=>(e(Ui(t,{anchor:t.selection.main.anchor,head:0})),!0),Y5=({state:t,dispatch:e})=>(e(Ui(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),jre=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),Ire=({state:t,dispatch:e})=>{let n=Xp(t).map(({from:i,to:r})=>de.range(i,Math.min(r+1,t.doc.length)));return e(t.update({selection:de.create(n),userEvent:"select"})),!0},Pre=({state:t,dispatch:e})=>{let n=El(t.selection,i=>{let r=Cn(t),s=r.resolveStack(i.from,1);if(i.empty){let o=r.resolveStack(i.from,-1);o.node.from>=s.node.from&&o.node.to<=s.node.to&&(s=o)}for(let o=s;o;o=o.next){let{node:c}=o;if((c.from<i.from&&c.to>=i.to||c.to>i.to&&c.from<=i.from)&&o.next)return de.range(c.to,c.from)}return i});return n.eq(t.selection)?!1:(e(Ui(t,n)),!0)};function Wq(t,e){let{state:n}=t,i=n.selection,r=n.selection.ranges.slice();for(let s of n.selection.ranges){let o=n.doc.lineAt(s.head);if(e?o.to<t.state.doc.length:o.from>0)for(let c=s;;){let u=t.moveVertically(c,e);if(u.head<o.from||u.head>o.to){r.some(h=>h.head==u.head)||r.push(u);break}else{if(u.head==c.head)break;c=u}}}return r.length==i.ranges.length?!1:(t.dispatch(Ui(n,de.create(r,r.length-1))),!0)}const Hre=t=>Wq(t,!1),Ure=t=>Wq(t,!0),Vre=({state:t,dispatch:e})=>{let n=t.selection,i=null;return n.ranges.length>1?i=de.create([n.main]):n.main.empty||(i=de.create([de.cursor(n.main.head)])),i?(e(Ui(t,i)),!0):!1};function Gu(t,e){if(t.state.readOnly)return!1;let n="delete.selection",{state:i}=t,r=i.changeByRange(s=>{let{from:o,to:c}=s;if(o==c){let u=e(s);u<o?(n="delete.backward",u=Wh(t,u,!1)):u>o&&(n="delete.forward",u=Wh(t,u,!0)),o=Math.min(o,u),c=Math.max(c,u)}else o=Wh(t,o,!1),c=Wh(t,c,!0);return o==c?{range:s}:{changes:{from:o,to:c},range:de.cursor(o,o<s.head?-1:1)}});return r.changes.empty?!1:(t.dispatch(i.update(r,{scrollIntoView:!0,userEvent:n,effects:n=="delete.selection"?Se.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function Wh(t,e,n){if(t instanceof Se)for(let i of t.state.facet(Se.atomicRanges).map(r=>r(t)))i.between(e,e,(r,s)=>{r<e&&s>e&&(e=n?s:r)});return e}const Kq=(t,e,n)=>Gu(t,i=>{let r=i.from,{state:s}=t,o=s.doc.lineAt(r),c,u;if(n&&!e&&r>o.from&&r<o.from+200&&!/[^ \t]/.test(c=o.text.slice(0,r-o.from))){if(c[c.length-1]==" ")return r-1;let h=Ol(c,s.tabSize),d=h%Qd(s)||Qd(s);for(let m=0;m<d&&c[c.length-1-m]==" ";m++)r--;u=r}else u=sn(o.text,r-o.from,e,e)+o.from,u==r&&o.number!=(e?s.doc.lines:1)?u+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(o.text.slice(u-o.from,r-o.from))&&(u=sn(o.text,u-o.from,!1,!1)+o.from);return u}),e2=t=>Kq(t,!1,!0),Zq=t=>Kq(t,!0,!1),Jq=(t,e)=>Gu(t,n=>{let i=n.head,{state:r}=t,s=r.doc.lineAt(i),o=r.charCategorizer(i);for(let c=null;;){if(i==(e?s.to:s.from)){i==n.head&&s.number!=(e?r.doc.lines:1)&&(i+=e?1:-1);break}let u=sn(s.text,i-s.from,e)+s.from,h=s.text.slice(Math.min(i,u)-s.from,Math.max(i,u)-s.from),d=o(h);if(c!=null&&d!=c)break;(h!=" "||i!=n.head)&&(c=d),i=u}return i}),ej=t=>Jq(t,!1),Fre=t=>Jq(t,!0),$re=t=>Gu(t,e=>{let n=t.lineBlockAt(e.head).to;return e.head<n?n:Math.min(t.state.doc.length,e.head+1)}),Gre=t=>Gu(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),Yre=t=>Gu(t,e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head<n?n:Math.min(t.state.doc.length,e.head+1)}),Qre=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:tt.of(["",""])},range:de.cursor(i.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},Xre=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(i=>{if(!i.empty||i.from==0||i.from==t.doc.length)return{range:i};let r=i.from,s=t.doc.lineAt(r),o=r==s.from?r-1:sn(s.text,r-s.from,!1)+s.from,c=r==s.to?r+1:sn(s.text,r-s.from,!0)+s.from;return{changes:{from:o,to:c,insert:t.doc.slice(r,c).append(t.doc.slice(o,r))},range:de.cursor(c)}});return n.changes.empty?!1:(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Xp(t){let e=[],n=-1;for(let i of t.selection.ranges){let r=t.doc.lineAt(i.from),s=t.doc.lineAt(i.to);if(!i.empty&&i.to==s.from&&(s=t.doc.lineAt(i.to-1)),n>=r.number){let o=e[e.length-1];o.to=s.to,o.ranges.push(i)}else e.push({from:r.from,to:s.to,ranges:[i]});n=s.number+1}return e}function tj(t,e,n){if(t.readOnly)return!1;let i=[],r=[];for(let s of Xp(t)){if(n?s.to==t.doc.length:s.from==0)continue;let o=t.doc.lineAt(n?s.to+1:s.from-1),c=o.length+1;if(n){i.push({from:s.to,to:o.to},{from:s.from,insert:o.text+t.lineBreak});for(let u of s.ranges)r.push(de.range(Math.min(t.doc.length,u.anchor+c),Math.min(t.doc.length,u.head+c)))}else{i.push({from:o.from,to:s.from},{from:s.to,insert:t.lineBreak+o.text});for(let u of s.ranges)r.push(de.range(u.anchor-c,u.head-c))}}return i.length?(e(t.update({changes:i,scrollIntoView:!0,selection:de.create(r,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const Wre=({state:t,dispatch:e})=>tj(t,e,!1),Kre=({state:t,dispatch:e})=>tj(t,e,!0);function nj(t,e,n){if(t.readOnly)return!1;let i=[];for(let s of Xp(t))n?i.push({from:s.from,insert:t.doc.slice(s.from,s.to)+t.lineBreak}):i.push({from:s.to,insert:t.lineBreak+t.doc.slice(s.from,s.to)});let r=t.changes(i);return e(t.update({changes:r,selection:t.selection.map(r,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const Zre=({state:t,dispatch:e})=>nj(t,e,!1),Jre=({state:t,dispatch:e})=>nj(t,e,!0),ese=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(Xp(e).map(({from:r,to:s})=>(r>0?r--:s<e.doc.length&&s++,{from:r,to:s}))),i=El(e.selection,r=>{let s;if(t.lineWrapping){let o=t.lineBlockAt(r.head),c=t.coordsAtPos(r.head,r.assoc||1);c&&(s=o.bottom+t.documentTop-c.bottom+t.defaultLineHeight/2)}return t.moveVertically(r,!0,s)}).map(n);return t.dispatch({changes:n,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function tse(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=Cn(t).resolveInner(e),i=n.childBefore(e),r=n.childAfter(e),s;return i&&r&&i.to<=e&&r.from>=e&&(s=i.type.prop(Fe.closedBy))&&s.indexOf(r.name)>-1&&t.doc.lineAt(i.to).from==t.doc.lineAt(r.from).from&&!/\S/.test(t.sliceDoc(i.to,r.from))?{from:i.to,to:r.from}:null}const Q5=ij(!1),nse=ij(!0);function ij(t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let i=e.changeByRange(r=>{let{from:s,to:o}=r,c=e.doc.lineAt(s),u=!t&&s==o&&tse(e,s);t&&(s=o=(o<=c.to?c:e.doc.lineAt(o)).to);let h=new Fp(e,{simulateBreak:s,simulateDoubleBreak:!!u}),d=_C(h,s);for(d==null&&(d=Ol(/^\s*/.exec(e.doc.lineAt(s).text)[0],e.tabSize));o<c.to&&/\s/.test(c.text[o-c.from]);)o++;u?{from:s,to:o}=u:s>c.from&&s<c.from+100&&!/\S/.test(c.text.slice(0,s))&&(s=c.from);let m=["",Cu(e,d)];return u&&m.push(Cu(e,h.lineIndent(c.from,-1))),{changes:{from:s,to:o,insert:tt.of(m)},range:de.cursor(s+1+m[1].length)}});return n(e.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function RC(t,e){let n=-1;return t.changeByRange(i=>{let r=[];for(let o=i.from;o<=i.to;){let c=t.doc.lineAt(o);c.number>n&&(i.empty||i.to>c.from)&&(e(c,r,i),n=c.number),o=c.to+1}let s=t.changes(r);return{changes:r,range:de.range(s.mapPos(i.anchor,1),s.mapPos(i.head,1))}})}const ise=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),i=new Fp(t,{overrideIndentation:s=>{let o=n[s];return o??-1}}),r=RC(t,(s,o,c)=>{let u=_C(i,s.from);if(u==null)return;/\S/.test(s.text)||(u=0);let h=/^\s*/.exec(s.text)[0],d=Cu(t,u);(h!=d||c.from<s.from+h.length)&&(n[s.from]=u,o.push({from:s.from,to:s.from+h.length,insert:d}))});return r.changes.empty||e(t.update(r,{userEvent:"indent"})),!0},rj=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(RC(t,(n,i)=>{i.push({from:n.from,insert:t.facet(Vp)})}),{userEvent:"input.indent"})),!0),sj=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(RC(t,(n,i)=>{let r=/^\s*/.exec(n.text)[0];if(!r)return;let s=Ol(r,t.tabSize),o=0,c=Cu(t,Math.max(0,s-Qd(t)));for(;o<r.length&&o<c.length&&r.charCodeAt(o)==c.charCodeAt(o);)o++;i.push({from:n.from+o,to:n.from+r.length,insert:c.slice(o)})}),{userEvent:"delete.dedent"})),!0),rse=t=>(t.setTabFocusMode(),!0),sse=[{key:"Ctrl-b",run:Lq,shift:Vq,preventDefault:!0},{key:"Ctrl-f",run:zq,shift:Fq},{key:"Ctrl-p",run:jq,shift:Yq},{key:"Ctrl-n",run:Iq,shift:Qq},{key:"Ctrl-a",run:kre,shift:Bre},{key:"Ctrl-e",run:Are,shift:qre},{key:"Ctrl-d",run:Zq},{key:"Ctrl-h",run:e2},{key:"Ctrl-k",run:$re},{key:"Ctrl-Alt-h",run:ej},{key:"Ctrl-o",run:Qre},{key:"Ctrl-t",run:Xre},{key:"Ctrl-v",run:JS}],ase=[{key:"ArrowLeft",run:Lq,shift:Vq,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:mre,shift:Ere,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:Sre,shift:Lre,preventDefault:!0},{key:"ArrowRight",run:zq,shift:Fq,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:gre,shift:Tre,preventDefault:!0},{mac:"Cmd-ArrowRight",run:Cre,shift:zre,preventDefault:!0},{key:"ArrowUp",run:jq,shift:Yq,preventDefault:!0},{mac:"Cmd-ArrowUp",run:F5,shift:G5},{mac:"Ctrl-ArrowUp",run:H5,shift:U5},{key:"ArrowDown",run:Iq,shift:Qq,preventDefault:!0},{mac:"Cmd-ArrowDown",run:$5,shift:Y5},{mac:"Ctrl-ArrowDown",run:JS,shift:V5},{key:"PageUp",run:H5,shift:U5},{key:"PageDown",run:JS,shift:V5},{key:"Home",run:wre,shift:Dre,preventDefault:!0},{key:"Mod-Home",run:F5,shift:G5},{key:"End",run:xre,shift:Nre,preventDefault:!0},{key:"Mod-End",run:$5,shift:Y5},{key:"Enter",run:Q5,shift:Q5},{key:"Mod-a",run:jre},{key:"Backspace",run:e2,shift:e2,preventDefault:!0},{key:"Delete",run:Zq,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:ej,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:Fre,preventDefault:!0},{mac:"Mod-Backspace",run:Gre,preventDefault:!0},{mac:"Mod-Delete",run:Yre,preventDefault:!0}].concat(sse.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),ose=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:vre,shift:Mre},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:bre,shift:Rre},{key:"Alt-ArrowUp",run:Wre},{key:"Shift-Alt-ArrowUp",run:Zre},{key:"Alt-ArrowDown",run:Kre},{key:"Shift-Alt-ArrowDown",run:Jre},{key:"Mod-Alt-ArrowUp",run:Hre},{key:"Mod-Alt-ArrowDown",run:Ure},{key:"Escape",run:Vre},{key:"Mod-Enter",run:nse},{key:"Alt-l",mac:"Ctrl-l",run:Ire},{key:"Mod-i",run:Pre,preventDefault:!0},{key:"Mod-[",run:sj},{key:"Mod-]",run:rj},{key:"Mod-Alt-\\",run:ise},{key:"Shift-Mod-k",run:ese},{key:"Shift-Mod-\\",run:Ore},{key:"Mod-/",run:Wie},{key:"Alt-A",run:Zie},{key:"Ctrl-m",mac:"Shift-Alt-m",run:rse}].concat(ase),lse={key:"Tab",run:rj,shift:sj},X5=typeof String.prototype.normalize=="function"?t=>t.normalize("NFKD"):t=>t;class bl{constructor(e,n,i=0,r=e.length,s,o){this.test=o,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(i,r),this.bufferStart=i,this.normalize=s?c=>s(X5(c)):X5,this.query=this.normalize(n)}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 In(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 n=iC(e),i=this.bufferStart+this.bufferPos;this.bufferPos+=ir(e);let r=this.normalize(n);if(r.length)for(let s=0,o=i;;s++){let c=r.charCodeAt(s),u=this.match(c,o,this.bufferPos+this.bufferStart);if(s==r.length-1){if(u)return this.value=u,this;break}o==i&&s<n.length&&n.charCodeAt(s)==c&&o++}}}match(e,n,i){let r=null;for(let s=0;s<this.matches.length;s+=2){let o=this.matches[s],c=!1;this.query.charCodeAt(o)==e&&(o==this.query.length-1?r={from:this.matches[s+1],to:i}:(this.matches[s]++,c=!0)),c||(this.matches.splice(s,2),s-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?r={from:n,to:i}:this.matches.push(1,n)),r&&this.test&&!this.test(r.from,r.to,this.buffer,this.bufferStart)&&(r=null),r}}typeof Symbol<"u"&&(bl.prototype[Symbol.iterator]=function(){return this});const aj={from:-1,to:-1,match:/.*/.exec("")},NC="gm"+(/x/.unicode==null?"":"u");class oj{constructor(e,n,i,r=0,s=e.length){if(this.text=e,this.to=s,this.curLine="",this.done=!1,this.value=aj,/\\[sWDnr]|\n|\r|\[\^/.test(n))return new lj(e,n,i,r,s);this.re=new RegExp(n,NC+(i?.ignoreCase?"i":"")),this.test=i?.test,this.iter=e.iter();let o=e.lineAt(r);this.curLineStart=o.from,this.matchPos=Jd(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 n=this.matchPos<=this.to&&this.re.exec(this.curLine);if(n){let i=this.curLineStart+n.index,r=i+n[0].length;if(this.matchPos=Jd(this.text,r+(i==r?1:0)),i==this.curLineStart+this.curLine.length&&this.nextLine(),(i<r||i>this.value.to)&&(!this.test||this.test(i,r,n)))return this.value={from:i,to:r,match:n},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}}}const kw=new WeakMap;class ol{constructor(e,n){this.from=e,this.text=n}get to(){return this.from+this.text.length}static get(e,n,i){let r=kw.get(e);if(!r||r.from>=i||r.to<=n){let c=new ol(n,e.sliceString(n,i));return kw.set(e,c),c}if(r.from==n&&r.to==i)return r;let{text:s,from:o}=r;return o>n&&(s=e.sliceString(n,o)+s,o=n),r.to<i&&(s+=e.sliceString(r.to,i)),kw.set(e,new ol(o,s)),new ol(n,s.slice(n-o,i-o))}}class lj{constructor(e,n,i,r,s){this.text=e,this.to=s,this.done=!1,this.value=aj,this.matchPos=Jd(e,r),this.re=new RegExp(n,NC+(i?.ignoreCase?"i":"")),this.test=i?.test,this.flat=ol.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,n=this.re.exec(this.flat.text);if(n&&!n[0]&&n.index==e&&(this.re.lastIndex=e+1,n=this.re.exec(this.flat.text)),n){let i=this.flat.from+n.index,r=i+n[0].length;if((this.flat.to>=this.to||n.index+n[0].length<=this.flat.text.length-10)&&(!this.test||this.test(i,r,n)))return this.value={from:i,to:r,match:n},this.matchPos=Jd(this.text,r+(i==r?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=ol.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(oj.prototype[Symbol.iterator]=lj.prototype[Symbol.iterator]=function(){return this});function cse(t){try{return new RegExp(t,NC),!0}catch{return!1}}function Jd(t,e){if(e>=t.length)return e;let n=t.lineAt(e),i;for(;e<n.to&&(i=n.text.charCodeAt(e-n.from))>=56320&&i<57344;)e++;return e}const use=t=>{let{state:e}=t,n=String(e.doc.lineAt(t.state.selection.main.head).number),{close:i,result:r}=Tne(t,{label:e.phrase("Go to line"),input:{type:"text",name:"line",value:n},focus:!0,submitLabel:e.phrase("go")});return r.then(s=>{let o=s&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(s.elements.line.value);if(!o){t.dispatch({effects:i});return}let c=e.doc.lineAt(e.selection.main.head),[,u,h,d,m]=o,g=d?+d.slice(1):0,y=h?+h:c.number;if(h&&m){let S=y/100;u&&(S=S*(u=="-"?-1:1)+c.number/e.doc.lines),y=Math.round(e.doc.lines*S)}else h&&u&&(y=y*(u=="-"?-1:1)+c.number);let x=e.doc.line(Math.max(1,Math.min(e.doc.lines,y))),w=de.cursor(x.from+Math.max(0,Math.min(g,x.length)));t.dispatch({effects:[i,Se.scrollIntoView(w.from,{y:"center"})],selection:w})}),!0},fse={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},hse=ke.define({combine(t){return pr(t,fse,{highlightWordAroundCursor:(e,n)=>e||n,minSelectionLength:Math.min,maxMatches:Math.min})}});function dse(t){return[vse,yse]}const pse=Le.mark({class:"cm-selectionMatch"}),mse=Le.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function W5(t,e,n,i){return(n==0||t(e.sliceDoc(n-1,n))!=At.Word)&&(i==e.doc.length||t(e.sliceDoc(i,i+1))!=At.Word)}function gse(t,e,n,i){return t(e.sliceDoc(n,n+1))==At.Word&&t(e.sliceDoc(i-1,i))==At.Word}const yse=zt.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.selectionSet||t.docChanged||t.viewportChanged)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=t.state.facet(hse),{state:n}=t,i=n.selection;if(i.ranges.length>1)return Le.none;let r=i.main,s,o=null;if(r.empty){if(!e.highlightWordAroundCursor)return Le.none;let u=n.wordAt(r.head);if(!u)return Le.none;o=n.charCategorizer(r.head),s=n.sliceDoc(u.from,u.to)}else{let u=r.to-r.from;if(u<e.minSelectionLength||u>200)return Le.none;if(e.wholeWords){if(s=n.sliceDoc(r.from,r.to),o=n.charCategorizer(r.head),!(W5(o,n,r.from,r.to)&&gse(o,n,r.from,r.to)))return Le.none}else if(s=n.sliceDoc(r.from,r.to),!s)return Le.none}let c=[];for(let u of t.visibleRanges){let h=new bl(n.doc,s,u.from,u.to);for(;!h.next().done;){let{from:d,to:m}=h.value;if((!o||W5(o,n,d,m))&&(r.empty&&d<=r.from&&m>=r.to?c.push(mse.range(d,m)):(d>=r.to||m<=r.from)&&c.push(pse.range(d,m)),c.length>e.maxMatches))return Le.none}}return Le.set(c)}},{decorations:t=>t.decorations}),vse=Se.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),bse=({state:t,dispatch:e})=>{let{selection:n}=t,i=de.create(n.ranges.map(r=>t.wordAt(r.head)||de.cursor(r.head)),n.mainIndex);return i.eq(n)?!1:(e(t.update({selection:i})),!0)};function xse(t,e){let{main:n,ranges:i}=t.selection,r=t.wordAt(n.head),s=r&&r.from==n.from&&r.to==n.to;for(let o=!1,c=new bl(t.doc,e,i[i.length-1].to);;)if(c.next(),c.done){if(o)return null;c=new bl(t.doc,e,0,Math.max(0,i[i.length-1].from-1)),o=!0}else{if(o&&i.some(u=>u.from==c.value.from))continue;if(s){let u=t.wordAt(c.value.from);if(!u||u.from!=c.value.from||u.to!=c.value.to)continue}return c.value}}const wse=({state:t,dispatch:e})=>{let{ranges:n}=t.selection;if(n.some(s=>s.from===s.to))return bse({state:t,dispatch:e});let i=t.sliceDoc(n[0].from,n[0].to);if(t.selection.ranges.some(s=>t.sliceDoc(s.from,s.to)!=i))return!1;let r=xse(t,i);return r?(e(t.update({selection:t.selection.addRange(de.range(r.from,r.to),!1),effects:Se.scrollIntoView(r.to)})),!0):!1},Tl=ke.define({combine(t){return pr(t,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new zse(e),scrollToMatch:e=>Se.scrollIntoView(e)})}});class cj{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||cse(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,(n,i)=>i=="n"?`
|
|
51
|
-
`:i=="r"?"\r":i=="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 Ose(this):new kse(this)}getCursor(e,n=0,i){let r=e.doc?e:Je.create({doc:e});return i==null&&(i=r.doc.length),this.regexp?Ho(this,r,n,i):Po(this,r,n,i)}}class uj{constructor(e){this.spec=e}}function Sse(t,e,n){return(i,r,s,o)=>{if(n&&!n(i,r,s,o))return!1;let c=i>=o&&r<=o+s.length?s.slice(i-o,r-o):e.doc.sliceString(i,r);return t(c,e,i,r)}}function Po(t,e,n,i){let r;return t.wholeWord&&(r=Cse(e.doc,e.charCategorizer(e.selection.main.head))),t.test&&(r=Sse(t.test,e,r)),new bl(e.doc,t.unquoted,n,i,t.caseSensitive?void 0:s=>s.toLowerCase(),r)}function Cse(t,e){return(n,i,r,s)=>((s>n||s+r.length<i)&&(s=Math.max(0,n-2),r=t.sliceString(s,Math.min(t.length,i+2))),(e(ep(r,n-s))!=At.Word||e(tp(r,n-s))!=At.Word)&&(e(tp(r,i-s))!=At.Word||e(ep(r,i-s))!=At.Word))}class kse extends uj{constructor(e){super(e)}nextMatch(e,n,i){let r=Po(this.spec,e,i,e.doc.length).nextOverlapping();if(r.done){let s=Math.min(e.doc.length,n+this.spec.unquoted.length);r=Po(this.spec,e,0,s).nextOverlapping()}return r.done||r.value.from==n&&r.value.to==i?null:r.value}prevMatchInRange(e,n,i){for(let r=i;;){let s=Math.max(n,r-1e4-this.spec.unquoted.length),o=Po(this.spec,e,s,r),c=null;for(;!o.nextOverlapping().done;)c=o.value;if(c)return c;if(s==n)return null;r-=1e4}}prevMatch(e,n,i){let r=this.prevMatchInRange(e,0,n);return r||(r=this.prevMatchInRange(e,Math.max(0,i-this.spec.unquoted.length),e.doc.length)),r&&(r.from!=n||r.to!=i)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,n){let i=Po(this.spec,e,0,e.doc.length),r=[];for(;!i.next().done;){if(r.length>=n)return null;r.push(i.value)}return r}highlight(e,n,i,r){let s=Po(this.spec,e,Math.max(0,n-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,e.doc.length));for(;!s.next().done;)r(s.value.from,s.value.to)}}function Ase(t,e,n){return(i,r,s)=>(!n||n(i,r,s))&&t(s[0],e,i,r)}function Ho(t,e,n,i){let r;return t.wholeWord&&(r=_se(e.charCategorizer(e.selection.main.head))),t.test&&(r=Ase(t.test,e,r)),new oj(e.doc,t.search,{ignoreCase:!t.caseSensitive,test:r},n,i)}function ep(t,e){return t.slice(sn(t,e,!1),e)}function tp(t,e){return t.slice(e,sn(t,e))}function _se(t){return(e,n,i)=>!i[0].length||(t(ep(i.input,i.index))!=At.Word||t(tp(i.input,i.index))!=At.Word)&&(t(tp(i.input,i.index+i[0].length))!=At.Word||t(ep(i.input,i.index+i[0].length))!=At.Word)}class Ose extends uj{nextMatch(e,n,i){let r=Ho(this.spec,e,i,e.doc.length).next();return r.done&&(r=Ho(this.spec,e,0,n).next()),r.done?null:r.value}prevMatchInRange(e,n,i){for(let r=1;;r++){let s=Math.max(n,i-r*1e4),o=Ho(this.spec,e,s,i),c=null;for(;!o.next().done;)c=o.value;if(c&&(s==n||c.from>s+10))return c;if(s==n)return null}}prevMatch(e,n,i){return this.prevMatchInRange(e,0,n)||this.prevMatchInRange(e,i,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(n,i)=>{if(i=="&")return e.match[0];if(i=="$")return"$";for(let r=i.length;r>0;r--){let s=+i.slice(0,r);if(s>0&&s<e.match.length)return e.match[s]+i.slice(r)}return n})}matchAll(e,n){let i=Ho(this.spec,e,0,e.doc.length),r=[];for(;!i.next().done;){if(r.length>=n)return null;r.push(i.value)}return r}highlight(e,n,i,r){let s=Ho(this.spec,e,Math.max(0,n-250),Math.min(i+250,e.doc.length));for(;!s.next().done;)r(s.value.from,s.value.to)}}const ku=je.define(),DC=je.define(),Vs=_n.define({create(t){return new Aw(t2(t).create(),null)},update(t,e){for(let n of e.effects)n.is(ku)?t=new Aw(n.value.create(),t.panel):n.is(DC)&&(t=new Aw(t.query,n.value?LC:null));return t},provide:t=>xu.from(t,e=>e.panel)});class Aw{constructor(e,n){this.query=e,this.panel=n}}const Ese=Le.mark({class:"cm-searchMatch"}),Tse=Le.mark({class:"cm-searchMatch cm-searchMatch-selected"}),Mse=zt.fromClass(class{constructor(t){this.view=t,this.decorations=this.highlight(t.state.field(Vs))}update(t){let e=t.state.field(Vs);(e!=t.startState.field(Vs)||t.docChanged||t.selectionSet||t.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:t,panel:e}){if(!e||!t.spec.valid)return Le.none;let{view:n}=this,i=new Kr;for(let r=0,s=n.visibleRanges,o=s.length;r<o;r++){let{from:c,to:u}=s[r];for(;r<o-1&&u>s[r+1].from-500;)u=s[++r].to;t.highlight(n.state,c,u,(h,d)=>{let m=n.state.selection.ranges.some(g=>g.from==h&&g.to==d);i.add(h,d,m?Tse:Ese)})}return i.finish()}},{decorations:t=>t.decorations});function Yu(t){return e=>{let n=e.state.field(Vs,!1);return n&&n.query.spec.valid?t(e,n):dj(e)}}const np=Yu((t,{query:e})=>{let{to:n}=t.state.selection.main,i=e.nextMatch(t.state,n,n);if(!i)return!1;let r=de.single(i.from,i.to),s=t.state.facet(Tl);return t.dispatch({selection:r,effects:[zC(t,i),s.scrollToMatch(r.main,t)],userEvent:"select.search"}),hj(t),!0}),ip=Yu((t,{query:e})=>{let{state:n}=t,{from:i}=n.selection.main,r=e.prevMatch(n,i,i);if(!r)return!1;let s=de.single(r.from,r.to),o=t.state.facet(Tl);return t.dispatch({selection:s,effects:[zC(t,r),o.scrollToMatch(s.main,t)],userEvent:"select.search"}),hj(t),!0}),Rse=Yu((t,{query:e})=>{let n=e.matchAll(t.state,1e3);return!n||!n.length?!1:(t.dispatch({selection:de.create(n.map(i=>de.range(i.from,i.to))),userEvent:"select.search.matches"}),!0)}),Nse=({state:t,dispatch:e})=>{let n=t.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:i,to:r}=n.main,s=[],o=0;for(let c=new bl(t.doc,t.sliceDoc(i,r));!c.next().done;){if(s.length>1e3)return!1;c.value.from==i&&(o=s.length),s.push(de.range(c.value.from,c.value.to))}return e(t.update({selection:de.create(s,o),userEvent:"select.search.matches"})),!0},K5=Yu((t,{query:e})=>{let{state:n}=t,{from:i,to:r}=n.selection.main;if(n.readOnly)return!1;let s=e.nextMatch(n,i,i);if(!s)return!1;let o=s,c=[],u,h,d=[];o.from==i&&o.to==r&&(h=n.toText(e.getReplacement(o)),c.push({from:o.from,to:o.to,insert:h}),o=e.nextMatch(n,o.from,o.to),d.push(Se.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(i).number)+".")));let m=t.state.changes(c);return o&&(u=de.single(o.from,o.to).map(m),d.push(zC(t,o)),d.push(n.facet(Tl).scrollToMatch(u.main,t))),t.dispatch({changes:m,selection:u,effects:d,userEvent:"input.replace"}),!0}),Dse=Yu((t,{query:e})=>{if(t.state.readOnly)return!1;let n=e.matchAll(t.state,1e9).map(r=>{let{from:s,to:o}=r;return{from:s,to:o,insert:e.getReplacement(r)}});if(!n.length)return!1;let i=t.state.phrase("replaced $ matches",n.length)+".";return t.dispatch({changes:n,effects:Se.announce.of(i),userEvent:"input.replace.all"}),!0});function LC(t){return t.state.facet(Tl).createPanel(t)}function t2(t,e){var n,i,r,s,o;let c=t.selection.main,u=c.empty||c.to>c.from+100?"":t.sliceDoc(c.from,c.to);if(e&&!u)return e;let h=t.facet(Tl);return new cj({search:((n=e?.literal)!==null&&n!==void 0?n:h.literal)?u:u.replace(/\n/g,"\\n"),caseSensitive:(i=e?.caseSensitive)!==null&&i!==void 0?i:h.caseSensitive,literal:(r=e?.literal)!==null&&r!==void 0?r:h.literal,regexp:(s=e?.regexp)!==null&&s!==void 0?s:h.regexp,wholeWord:(o=e?.wholeWord)!==null&&o!==void 0?o:h.wholeWord})}function fj(t){let e=wC(t,LC);return e&&e.dom.querySelector("[main-field]")}function hj(t){let e=fj(t);e&&e==t.root.activeElement&&e.select()}const dj=t=>{let e=t.state.field(Vs,!1);if(e&&e.panel){let n=fj(t);if(n&&n!=t.root.activeElement){let i=t2(t.state,e.query.spec);i.valid&&t.dispatch({effects:ku.of(i)}),n.focus(),n.select()}}else t.dispatch({effects:[DC.of(!0),e?ku.of(t2(t.state,e.query.spec)):je.appendConfig.of(qse)]});return!0},pj=t=>{let e=t.state.field(Vs,!1);if(!e||!e.panel)return!1;let n=wC(t,LC);return n&&n.dom.contains(t.root.activeElement)&&t.focus(),t.dispatch({effects:DC.of(!1)}),!0},Lse=[{key:"Mod-f",run:dj,scope:"editor search-panel"},{key:"F3",run:np,shift:ip,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:np,shift:ip,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:pj,scope:"editor search-panel"},{key:"Mod-Shift-l",run:Nse},{key:"Mod-Alt-g",run:use},{key:"Mod-d",run:wse,preventDefault:!0}];class zse{constructor(e){this.view=e;let n=this.query=e.state.field(Vs).query.spec;this.commit=this.commit.bind(this),this.searchField=dt("input",{value:n.search,placeholder:ri(e,"Find"),"aria-label":ri(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=dt("input",{value:n.replace,placeholder:ri(e,"Replace"),"aria-label":ri(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=dt("input",{type:"checkbox",name:"case",form:"",checked:n.caseSensitive,onchange:this.commit}),this.reField=dt("input",{type:"checkbox",name:"re",form:"",checked:n.regexp,onchange:this.commit}),this.wordField=dt("input",{type:"checkbox",name:"word",form:"",checked:n.wholeWord,onchange:this.commit});function i(r,s,o){return dt("button",{class:"cm-button",name:r,onclick:s,type:"button"},o)}this.dom=dt("div",{onkeydown:r=>this.keydown(r),class:"cm-search"},[this.searchField,i("next",()=>np(e),[ri(e,"next")]),i("prev",()=>ip(e),[ri(e,"previous")]),i("select",()=>Rse(e),[ri(e,"all")]),dt("label",null,[this.caseField,ri(e,"match case")]),dt("label",null,[this.reField,ri(e,"regexp")]),dt("label",null,[this.wordField,ri(e,"by word")]),...e.state.readOnly?[]:[dt("br"),this.replaceField,i("replace",()=>K5(e),[ri(e,"replace")]),i("replaceAll",()=>Dse(e),[ri(e,"replace all")])],dt("button",{name:"close",onclick:()=>pj(e),"aria-label":ri(e,"close"),type:"button"},["×"])])}commit(){let e=new cj({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:ku.of(e)}))}keydown(e){Ite(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?ip:np)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),K5(this.view))}update(e){for(let n of e.transactions)for(let i of n.effects)i.is(ku)&&!i.value.eq(this.query)&&this.setQuery(i.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(Tl).top}}function ri(t,e){return t.state.phrase(e)}const Kh=30,Zh=/[\s\.,:;?!]/;function zC(t,{from:e,to:n}){let i=t.state.doc.lineAt(e),r=t.state.doc.lineAt(n).to,s=Math.max(i.from,e-Kh),o=Math.min(r,n+Kh),c=t.state.sliceDoc(s,o);if(s!=i.from){for(let u=0;u<Kh;u++)if(!Zh.test(c[u+1])&&Zh.test(c[u])){c=c.slice(u);break}}if(o!=r){for(let u=c.length-1;u>c.length-Kh;u--)if(!Zh.test(c[u-1])&&Zh.test(c[u])){c=c.slice(0,u);break}}return Se.announce.of(`${t.state.phrase("current match")}. ${c} ${t.state.phrase("on line")} ${i.number}.`)}const Bse=Se.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"}}),qse=[Vs,Za.low(Mse),Bse];class mj{constructor(e,n,i,r){this.state=e,this.pos=n,this.explicit=i,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let n=Cn(this.state).resolveInner(this.pos,-1);for(;n&&e.indexOf(n.name)<0;)n=n.parent;return n?{from:n.from,to:this.pos,text:this.state.sliceDoc(n.from,this.pos),type:n.type}:null}matchBefore(e){let n=this.state.doc.lineAt(this.pos),i=Math.max(n.from,this.pos-250),r=n.text.slice(i-n.from,this.pos-n.from),s=r.search(gj(e,!1));return s<0?null:{from:i+s,to:this.pos,text:r.slice(s)}}get aborted(){return this.abortListeners==null}addEventListener(e,n,i){e=="abort"&&this.abortListeners&&(this.abortListeners.push(n),i&&i.onDocChange&&(this.abortOnDocChange=!0))}}function Z5(t){let e=Object.keys(t).join(""),n=/\w/.test(e);return n&&(e=e.replace(/\w/g,"")),`[${n?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function jse(t){let e=Object.create(null),n=Object.create(null);for(let{label:r}of t){e[r[0]]=!0;for(let s=1;s<r.length;s++)n[r[s]]=!0}let i=Z5(e)+Z5(n)+"*$";return[new RegExp("^"+i),new RegExp(i)]}function Ise(t){let e=t.map(r=>typeof r=="string"?{label:r}:r),[n,i]=e.every(r=>/^\w+$/.test(r.label))?[/\w*$/,/\w+$/]:jse(e);return r=>{let s=r.matchBefore(i);return s||r.explicit?{from:s?s.from:r.pos,options:e,validFor:n}:null}}class J5{constructor(e,n,i,r){this.completion=e,this.source=n,this.match=i,this.score=r}}function Ia(t){return t.selection.main.from}function gj(t,e){var n;let{source:i}=t,r=e&&i[0]!="^",s=i[i.length-1]!="$";return!r&&!s?t:new RegExp(`${r?"^":""}(?:${i})${s?"$":""}`,(n=t.flags)!==null&&n!==void 0?n:t.ignoreCase?"i":"")}const yj=dr.define();function Pse(t,e,n,i){let{main:r}=t.selection,s=n-r.from,o=i-r.from;return{...t.changeByRange(c=>{if(c!=r&&n!=i&&t.sliceDoc(c.from+s,c.from+o)!=t.sliceDoc(n,i))return{range:c};let u=t.toText(e);return{changes:{from:c.from+s,to:i==r.from?c.to:c.from+o,insert:u},range:de.cursor(c.from+s+u.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const e4=new WeakMap;function Hse(t){if(!Array.isArray(t))return t;let e=e4.get(t);return e||e4.set(t,e=Ise(t)),e}const rp=je.define(),Au=je.define();class Use{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let n=0;n<e.length;){let i=In(e,n),r=ir(i);this.chars.push(i);let s=e.slice(n,n+r),o=s.toUpperCase();this.folded.push(In(o==s?s.toLowerCase():o,0)),n+=r}this.astral=e.length!=this.chars.length}ret(e,n){return this.score=e,this.matched=n,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:n,folded:i,any:r,precise:s,byWord:o}=this;if(n.length==1){let A=In(e,0),O=ir(A),E=O==e.length?0:-100;if(A!=n[0])if(A==i[0])E+=-200;else return null;return this.ret(E,[0,O])}let c=e.indexOf(this.pattern);if(c==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let u=n.length,h=0;if(c<0){for(let A=0,O=Math.min(e.length,200);A<O&&h<u;){let E=In(e,A);(E==n[h]||E==i[h])&&(r[h++]=A),A+=ir(E)}if(h<u)return null}let d=0,m=0,g=!1,y=0,x=-1,w=-1,S=/[a-z]/.test(e),C=!0;for(let A=0,O=Math.min(e.length,200),E=0;A<O&&m<u;){let T=In(e,A);c<0&&(d<u&&T==n[d]&&(s[d++]=A),y<u&&(T==n[y]||T==i[y]?(y==0&&(x=A),w=A+1,y++):y=0));let M,R=T<255?T>=48&&T<=57||T>=97&&T<=122?2:T>=65&&T<=90?1:0:(M=iC(T))!=M.toLowerCase()?1:M!=M.toUpperCase()?2:0;(!A||R==1&&S||E==0&&R!=0)&&(n[m]==T||i[m]==T&&(g=!0)?o[m++]=A:o.length&&(C=!1)),E=R,A+=ir(T)}return m==u&&o[0]==0&&C?this.result(-100+(g?-200:0),o,e):y==u&&x==0?this.ret(-200-e.length+(w==e.length?0:-100),[0,w]):c>-1?this.ret(-700-e.length,[c,c+this.pattern.length]):y==u?this.ret(-900-e.length,[x,w]):m==u?this.result(-100+(g?-200:0)+-700+(C?0:-1100),o,e):n.length==2?null:this.result((r[0]?-700:0)+-200+-1100,r,e)}result(e,n,i){let r=[],s=0;for(let o of n){let c=o+(this.astral?ir(In(i,o)):1);s&&r[s-1]==o?r[s-1]=c:(r[s++]=o,r[s++]=c)}return this.ret(e-i.length,r)}}class Vse{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 n=e.slice(0,this.pattern.length),i=n==this.pattern?0:n.toLowerCase()==this.folded?-200:null;return i==null?null:(this.matched=[0,n.length],this.score=i+(e.length==this.pattern.length?0:-100),this)}}const rn=ke.define({combine(t){return pr(t,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:Fse,filterStrict:!1,compareCompletions:(e,n)=>(e.sortText||e.label).localeCompare(n.sortText||n.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,n)=>e&&n,closeOnBlur:(e,n)=>e&&n,icons:(e,n)=>e&&n,tooltipClass:(e,n)=>i=>t4(e(i),n(i)),optionClass:(e,n)=>i=>t4(e(i),n(i)),addToOptions:(e,n)=>e.concat(n),filterStrict:(e,n)=>e||n})}});function t4(t,e){return t?e?t+" "+e:t:e}function Fse(t,e,n,i,r,s){let o=t.textDirection==yt.RTL,c=o,u=!1,h="top",d,m,g=e.left-r.left,y=r.right-e.right,x=i.right-i.left,w=i.bottom-i.top;if(c&&g<Math.min(x,y)?c=!1:!c&&y<Math.min(x,g)&&(c=!0),x<=(c?g:y))d=Math.max(r.top,Math.min(n.top,r.bottom-w))-e.top,m=Math.min(400,c?g:y);else{u=!0,m=Math.min(400,(o?e.right:r.right-e.left)-30);let A=r.bottom-e.bottom;A>=w||A>e.top?d=n.bottom-e.top:(h="bottom",d=e.bottom-n.top)}let S=(e.bottom-e.top)/s.offsetHeight,C=(e.right-e.left)/s.offsetWidth;return{style:`${h}: ${d/S}px; max-width: ${m/C}px`,class:"cm-completionInfo-"+(u?o?"left-narrow":"right-narrow":c?"left":"right")}}const BC=je.define();function $se(t){let e=t.addToOptions.slice();return t.icons&&e.push({render(n){let i=document.createElement("div");return i.classList.add("cm-completionIcon"),n.type&&i.classList.add(...n.type.split(/\s+/g).map(r=>"cm-completionIcon-"+r)),i.setAttribute("aria-hidden","true"),i},position:20}),e.push({render(n,i,r,s){let o=document.createElement("span");o.className="cm-completionLabel";let c=n.displayLabel||n.label,u=0;for(let h=0;h<s.length;){let d=s[h++],m=s[h++];d>u&&o.appendChild(document.createTextNode(c.slice(u,d)));let g=o.appendChild(document.createElement("span"));g.appendChild(document.createTextNode(c.slice(d,m))),g.className="cm-completionMatchedText",u=m}return u<c.length&&o.appendChild(document.createTextNode(c.slice(u))),o},position:50},{render(n){if(!n.detail)return null;let i=document.createElement("span");return i.className="cm-completionDetail",i.textContent=n.detail,i},position:80}),e.sort((n,i)=>n.position-i.position).map(n=>n.render)}function _w(t,e,n){if(t<=n)return{from:0,to:t};if(e<0&&(e=0),e<=t>>1){let r=Math.floor(e/n);return{from:r*n,to:(r+1)*n}}let i=Math.floor((t-e)/n);return{from:t-(i+1)*n,to:t-i*n}}class Gse{constructor(e,n,i){this.view=e,this.stateField=n,this.applyCompletion=i,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:u=>this.placeInfo(u),key:this},this.space=null,this.currentClass="";let r=e.state.field(n),{options:s,selected:o}=r.open,c=e.state.facet(rn);this.optionContent=$se(c),this.optionClass=c.optionClass,this.tooltipClass=c.tooltipClass,this.range=_w(s.length,o,c.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",u=>{let{options:h}=e.state.field(n).open;for(let d=u.target,m;d&&d!=this.dom;d=d.parentNode)if(d.nodeName=="LI"&&(m=/-(\d+)$/.exec(d.id))&&+m[1]<h.length){this.applyCompletion(e,h[+m[1]]),u.preventDefault();return}if(u.target==this.list){let d=this.list.classList.contains("cm-completionListIncompleteTop")&&u.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains("cm-completionListIncompleteBottom")&&u.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;d!=null&&(e.dispatch({effects:BC.of(d)}),u.preventDefault())}}),this.dom.addEventListener("focusout",u=>{let h=e.state.field(this.stateField,!1);h&&h.tooltip&&e.state.facet(rn).closeOnBlur&&u.relatedTarget!=e.contentDOM&&e.dispatch({effects:Au.of(null)})}),this.showOptions(s,r.id)}mount(){this.updateSel()}showOptions(e,n){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,n,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var n;let i=e.state.field(this.stateField),r=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),i!=r){let{options:s,selected:o,disabled:c}=i.open;(!r.open||r.open.options!=s)&&(this.range=_w(s.length,o,e.state.facet(rn).maxRenderedOptions),this.showOptions(s,i.id)),this.updateSel(),c!=((n=r.open)===null||n===void 0?void 0:n.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!c)}}updateTooltipClass(e){let n=this.tooltipClass(e);if(n!=this.currentClass){for(let i of this.currentClass.split(" "))i&&this.dom.classList.remove(i);for(let i of n.split(" "))i&&this.dom.classList.add(i);this.currentClass=n}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),n=e.open;(n.selected>-1&&n.selected<this.range.from||n.selected>=this.range.to)&&(this.range=_w(n.options.length,n.selected,this.view.state.facet(rn).maxRenderedOptions),this.showOptions(n.options,e.id));let i=this.updateSelectedOption(n.selected);if(i){this.destroyInfo();let{completion:r}=n.options[n.selected],{info:s}=r;if(!s)return;let o=typeof s=="string"?document.createTextNode(s):s(r);if(!o)return;"then"in o?o.then(c=>{c&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(c,r)}).catch(c=>Fn(this.view.state,c,"completion info")):(this.addInfoPane(o,r),i.setAttribute("aria-describedby",this.info.id))}}addInfoPane(e,n){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",i.id="cm-completionInfo-"+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)i.appendChild(e),this.infoDestroy=null;else{let{dom:r,destroy:s}=e;i.appendChild(r),this.infoDestroy=s||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let n=null;for(let i=this.list.firstChild,r=this.range.from;i;i=i.nextSibling,r++)i.nodeName!="LI"||!i.id?r--:r==e?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),n=i):i.hasAttribute("aria-selected")&&(i.removeAttribute("aria-selected"),i.removeAttribute("aria-describedby"));return n&&Qse(this.list,n),n}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let n=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),r=e.getBoundingClientRect(),s=this.space;if(!s){let o=this.dom.ownerDocument.documentElement;s={left:0,top:0,right:o.clientWidth,bottom:o.clientHeight}}return r.top>Math.min(s.bottom,n.bottom)-10||r.bottom<Math.max(s.top,n.top)+10?null:this.view.state.facet(rn).positionInfo(this.view,n,r,i,s,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,n,i){const r=document.createElement("ul");r.id=n,r.setAttribute("role","listbox"),r.setAttribute("aria-expanded","true"),r.setAttribute("aria-label",this.view.state.phrase("Completions")),r.addEventListener("mousedown",o=>{o.target==r&&o.preventDefault()});let s=null;for(let o=i.from;o<i.to;o++){let{completion:c,match:u}=e[o],{section:h}=c;if(h){let g=typeof h=="string"?h:h.name;if(g!=s&&(o>i.from||i.from==0))if(s=g,typeof h!="string"&&h.header)r.appendChild(h.header(h));else{let y=r.appendChild(document.createElement("completion-section"));y.textContent=g}}const d=r.appendChild(document.createElement("li"));d.id=n+"-"+o,d.setAttribute("role","option");let m=this.optionClass(c);m&&(d.className=m);for(let g of this.optionContent){let y=g(c,this.view.state,this.view,u);y&&d.appendChild(y)}}return i.from&&r.classList.add("cm-completionListIncompleteTop"),i.to<e.length&&r.classList.add("cm-completionListIncompleteBottom"),r}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function Yse(t,e){return n=>new Gse(n,t,e)}function Qse(t,e){let n=t.getBoundingClientRect(),i=e.getBoundingClientRect(),r=n.height/t.offsetHeight;i.top<n.top?t.scrollTop-=(n.top-i.top)/r:i.bottom>n.bottom&&(t.scrollTop+=(i.bottom-n.bottom)/r)}function n4(t){return(t.boost||0)*100+(t.apply?10:0)+(t.info?5:0)+(t.type?1:0)}function Xse(t,e){let n=[],i=null,r=null,s=d=>{n.push(d);let{section:m}=d.completion;if(m){i||(i=[]);let g=typeof m=="string"?m:m.name;i.some(y=>y.name==g)||i.push(typeof m=="string"?{name:g}:m)}},o=e.facet(rn);for(let d of t)if(d.hasResult()){let m=d.result.getMatch;if(d.result.filter===!1)for(let g of d.result.options)s(new J5(g,d.source,m?m(g):[],1e9-n.length));else{let g=e.sliceDoc(d.from,d.to),y,x=o.filterStrict?new Vse(g):new Use(g);for(let w of d.result.options)if(y=x.match(w.label)){let S=w.displayLabel?m?m(w,y.matched):[]:y.matched,C=y.score+(w.boost||0);if(s(new J5(w,d.source,S,C)),typeof w.section=="object"&&w.section.rank==="dynamic"){let{name:A}=w.section;r||(r=Object.create(null)),r[A]=Math.max(C,r[A]||-1e9)}}}}if(i){let d=Object.create(null),m=0,g=(y,x)=>(y.rank==="dynamic"&&x.rank==="dynamic"?r[x.name]-r[y.name]:0)||(typeof y.rank=="number"?y.rank:1e9)-(typeof x.rank=="number"?x.rank:1e9)||(y.name<x.name?-1:1);for(let y of i.sort(g))m-=1e5,d[y.name]=m;for(let y of n){let{section:x}=y.completion;x&&(y.score+=d[typeof x=="string"?x:x.name])}}let c=[],u=null,h=o.compareCompletions;for(let d of n.sort((m,g)=>g.score-m.score||h(m.completion,g.completion))){let m=d.completion;!u||u.label!=m.label||u.detail!=m.detail||u.type!=null&&m.type!=null&&u.type!=m.type||u.apply!=m.apply||u.boost!=m.boost?c.push(d):n4(d.completion)>n4(u)&&(c[c.length-1]=d),u=d.completion}return c}class Ko{constructor(e,n,i,r,s,o){this.options=e,this.attrs=n,this.tooltip=i,this.timestamp=r,this.selected=s,this.disabled=o}setSelected(e,n){return e==this.selected||e>=this.options.length?this:new Ko(this.options,i4(n,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,n,i,r,s,o){if(r&&!o&&e.some(h=>h.isPending))return r.setDisabled();let c=Xse(e,n);if(!c.length)return r&&e.some(h=>h.isPending)?r.setDisabled():null;let u=n.facet(rn).selectOnOpen?0:-1;if(r&&r.selected!=u&&r.selected!=-1){let h=r.options[r.selected].completion;for(let d=0;d<c.length;d++)if(c[d].completion==h){u=d;break}}return new Ko(c,i4(i,u),{pos:e.reduce((h,d)=>d.hasResult()?Math.min(h,d.from):h,1e8),create:tae,above:s.aboveCursor},r?r.timestamp:Date.now(),u,!1)}map(e){return new Ko(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new Ko(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class sp{constructor(e,n,i){this.active=e,this.id=n,this.open=i}static start(){return new sp(Jse,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:n}=e,i=n.facet(rn),s=(i.override||n.languageDataAt("autocomplete",Ia(n)).map(Hse)).map(u=>(this.active.find(d=>d.source==u)||new Ai(u,this.active.some(d=>d.state!=0)?1:0)).update(e,i));s.length==this.active.length&&s.every((u,h)=>u==this.active[h])&&(s=this.active);let o=this.open,c=e.effects.some(u=>u.is(qC));o&&e.docChanged&&(o=o.map(e.changes)),e.selection||s.some(u=>u.hasResult()&&e.changes.touchesRange(u.from,u.to))||!Wse(s,this.active)||c?o=Ko.build(s,n,this.id,o,i,c):o&&o.disabled&&!s.some(u=>u.isPending)&&(o=null),!o&&s.every(u=>!u.isPending)&&s.some(u=>u.hasResult())&&(s=s.map(u=>u.hasResult()?new Ai(u.source,0):u));for(let u of e.effects)u.is(BC)&&(o=o&&o.setSelected(u.value,this.id));return s==this.active&&o==this.open?this:new sp(s,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?Kse:Zse}}function Wse(t,e){if(t==e)return!0;for(let n=0,i=0;;){for(;n<t.length&&!t[n].hasResult();)n++;for(;i<e.length&&!e[i].hasResult();)i++;let r=n==t.length,s=i==e.length;if(r||s)return r==s;if(t[n++].result!=e[i++].result)return!1}}const Kse={"aria-autocomplete":"list"},Zse={};function i4(t,e){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":t};return e>-1&&(n["aria-activedescendant"]=t+"-"+e),n}const Jse=[];function vj(t,e){if(t.isUserEvent("input.complete")){let i=t.annotation(yj);if(i&&e.activateOnCompletion(i))return 12}let n=t.isUserEvent("input.type");return n&&e.activateOnTyping?5:n?1:t.isUserEvent("delete.backward")?2:t.selection?8:t.docChanged?16:0}class Ai{constructor(e,n,i=!1){this.source=e,this.state=n,this.explicit=i}hasResult(){return!1}get isPending(){return this.state==1}update(e,n){let i=vj(e,n),r=this;(i&8||i&16&&this.touches(e))&&(r=new Ai(r.source,0)),i&4&&r.state==0&&(r=new Ai(this.source,1)),r=r.updateFor(e,i);for(let s of e.effects)if(s.is(rp))r=new Ai(r.source,1,s.value);else if(s.is(Au))r=new Ai(r.source,0);else if(s.is(qC))for(let o of s.value)o.source==r.source&&(r=o);return r}updateFor(e,n){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(Ia(e.state))}}class ll extends Ai{constructor(e,n,i,r,s,o){super(e,3,n),this.limit=i,this.result=r,this.from=s,this.to=o}hasResult(){return!0}updateFor(e,n){var i;if(!(n&3))return this.map(e.changes);let r=this.result;r.map&&!e.changes.empty&&(r=r.map(r,e.changes));let s=e.changes.mapPos(this.from),o=e.changes.mapPos(this.to,1),c=Ia(e.state);if(c>o||!r||n&2&&(Ia(e.startState)==this.from||c<this.limit))return new Ai(this.source,n&4?1:0);let u=e.changes.mapPos(this.limit);return eae(r.validFor,e.state,s,o)?new ll(this.source,this.explicit,u,r,s,o):r.update&&(r=r.update(r,s,o,new mj(e.state,c,!1)))?new ll(this.source,this.explicit,u,r,r.from,(i=r.to)!==null&&i!==void 0?i:Ia(e.state)):new Ai(this.source,1,this.explicit)}map(e){return e.empty?this:(this.result.map?this.result.map(this.result,e):this.result)?new ll(this.source,this.explicit,e.mapPos(this.limit),this.result,e.mapPos(this.from),e.mapPos(this.to,1)):new Ai(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}}function eae(t,e,n,i){if(!t)return!1;let r=e.sliceDoc(n,i);return typeof t=="function"?t(r,n,i,e):gj(t,!0).test(r)}const qC=je.define({map(t,e){return t.map(n=>n.map(e))}}),Pn=_n.define({create(){return sp.start()},update(t,e){return t.update(e)},provide:t=>[xC.from(t,e=>e.tooltip),Se.contentAttributes.from(t,e=>e.attrs)]});function jC(t,e){const n=e.completion.apply||e.completion.label;let i=t.state.field(Pn).active.find(r=>r.source==e.source);return i instanceof ll?(typeof n=="string"?t.dispatch({...Pse(t.state,n,i.from,i.to),annotations:yj.of(e.completion)}):n(t,e.completion,i.from,i.to),!0):!1}const tae=Yse(Pn,jC);function Jh(t,e="option"){return n=>{let i=n.state.field(Pn,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp<n.state.facet(rn).interactionDelay)return!1;let r=1,s;e=="page"&&(s=K6(n,i.open.tooltip))&&(r=Math.max(2,Math.floor(s.dom.offsetHeight/s.dom.querySelector("li").offsetHeight)-1));let{length:o}=i.open.options,c=i.open.selected>-1?i.open.selected+r*(t?1:-1):t?0:o-1;return c<0?c=e=="page"?0:o-1:c>=o&&(c=e=="page"?o-1:0),n.dispatch({effects:BC.of(c)}),!0}}const nae=t=>{let e=t.state.field(Pn,!1);return t.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<t.state.facet(rn).interactionDelay?!1:jC(t,e.open.options[e.open.selected])},Ow=t=>t.state.field(Pn,!1)?(t.dispatch({effects:rp.of(!0)}),!0):!1,iae=t=>{let e=t.state.field(Pn,!1);return!e||!e.active.some(n=>n.state!=0)?!1:(t.dispatch({effects:Au.of(null)}),!0)};class rae{constructor(e,n){this.active=e,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const sae=50,aae=1e3,oae=zt.fromClass(class{constructor(t){this.view=t,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of t.state.field(Pn).active)e.isPending&&this.startQuery(e)}update(t){let e=t.state.field(Pn),n=t.state.facet(rn);if(!t.selectionSet&&!t.docChanged&&t.startState.field(Pn)==e)return;let i=t.transactions.some(s=>{let o=vj(s,n);return o&8||(s.selection||s.docChanged)&&!(o&3)});for(let s=0;s<this.running.length;s++){let o=this.running[s];if(i||o.context.abortOnDocChange&&t.docChanged||o.updates.length+t.transactions.length>sae&&Date.now()-o.time>aae){for(let c of o.context.abortListeners)try{c()}catch(u){Fn(this.view.state,u)}o.context.abortListeners=null,this.running.splice(s--,1)}else o.updates.push(...t.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),t.transactions.some(s=>s.effects.some(o=>o.is(rp)))&&(this.pendingStart=!0);let r=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(s=>s.isPending&&!this.running.some(o=>o.active.source==s.source))?setTimeout(()=>this.startUpdate(),r):-1,this.composing!=0)for(let s of t.transactions)s.isUserEvent("input.type")?this.composing=2:this.composing==2&&s.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:t}=this.view,e=t.field(Pn);for(let n of e.active)n.isPending&&!this.running.some(i=>i.active.source==n.source)&&this.startQuery(n);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(rn).updateSyncTime))}startQuery(t){let{state:e}=this.view,n=Ia(e),i=new mj(e,n,t.explicit,this.view),r=new rae(t,i);this.running.push(r),Promise.resolve(t.source(i)).then(s=>{r.context.aborted||(r.done=s||null,this.scheduleAccept())},s=>{this.view.dispatch({effects:Au.of(null)}),Fn(this.view.state,s)})}scheduleAccept(){this.running.every(t=>t.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(rn).updateSyncTime))}accept(){var t;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],n=this.view.state.facet(rn),i=this.view.state.field(Pn);for(let r=0;r<this.running.length;r++){let s=this.running[r];if(s.done===void 0)continue;if(this.running.splice(r--,1),s.done){let c=Ia(s.updates.length?s.updates[0].startState:this.view.state),u=Math.min(c,s.done.from+(s.active.explicit?0:1)),h=new ll(s.active.source,s.active.explicit,u,s.done,s.done.from,(t=s.done.to)!==null&&t!==void 0?t:c);for(let d of s.updates)h=h.update(d,n);if(h.hasResult()){e.push(h);continue}}let o=i.active.find(c=>c.source==s.active.source);if(o&&o.isPending)if(s.done==null){let c=new Ai(s.active.source,0);for(let u of s.updates)c=c.update(u,n);c.isPending||e.push(c)}else this.startQuery(o)}(e.length||i.open&&i.open.disabled)&&this.view.dispatch({effects:qC.of(e)})}},{eventHandlers:{blur(t){let e=this.view.state.field(Pn,!1);if(e&&e.tooltip&&this.view.state.facet(rn).closeOnBlur){let n=e.open&&K6(this.view,e.open.tooltip);(!n||!n.dom.contains(t.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:Au.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:rp.of(!1)}),20),this.composing=0}}}),lae=typeof navigator=="object"&&/Win/.test(navigator.platform),cae=Za.highest(Se.domEventHandlers({keydown(t,e){let n=e.state.field(Pn,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||t.key.length>1||t.ctrlKey&&!(lae&&t.altKey)||t.metaKey)return!1;let i=n.open.options[n.open.selected],r=n.active.find(o=>o.source==i.source),s=i.completion.commitCharacters||r.result.commitCharacters;return s&&s.indexOf(t.key)>-1&&jC(e,i),!1}})),uae=Se.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"},".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"}}}),_u={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},La=je.define({map(t,e){let n=e.mapPos(t,-1,Rn.TrackAfter);return n??void 0}}),IC=new class extends Gs{};IC.startSide=1;IC.endSide=-1;const bj=_n.define({create(){return Ye.empty},update(t,e){if(t=t.map(e.changes),e.selection){let n=e.state.doc.lineAt(e.selection.main.head);t=t.update({filter:i=>i>=n.from&&i<=n.to})}for(let n of e.effects)n.is(La)&&(t=t.update({add:[IC.range(n.value,n.value+1)]}));return t}});function fae(){return[dae,bj]}const Ew="()[]{}<>«»»«[]{}";function xj(t){for(let e=0;e<Ew.length;e+=2)if(Ew.charCodeAt(e)==t)return Ew.charAt(e+1);return iC(t<128?t:t+1)}function wj(t,e){return t.languageDataAt("closeBrackets",e)[0]||_u}const hae=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),dae=Se.inputHandler.of((t,e,n,i)=>{if((hae?t.composing:t.compositionStarted)||t.state.readOnly)return!1;let r=t.state.selection.main;if(i.length>2||i.length==2&&ir(In(i,0))==1||e!=r.from||n!=r.to)return!1;let s=gae(t.state,i);return s?(t.dispatch(s),!0):!1}),pae=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=wj(t,t.selection.main.head).brackets||_u.brackets,r=null,s=t.changeByRange(o=>{if(o.empty){let c=yae(t.doc,o.head);for(let u of i)if(u==c&&Wp(t.doc,o.head)==xj(In(u,0)))return{changes:{from:o.head-u.length,to:o.head+u.length},range:de.cursor(o.head-u.length)}}return{range:r=o}});return r||e(t.update(s,{scrollIntoView:!0,userEvent:"delete.backward"})),!r},mae=[{key:"Backspace",run:pae}];function gae(t,e){let n=wj(t,t.selection.main.head),i=n.brackets||_u.brackets;for(let r of i){let s=xj(In(r,0));if(e==r)return s==r?xae(t,r,i.indexOf(r+r+r)>-1,n):vae(t,r,s,n.before||_u.before);if(e==s&&Sj(t,t.selection.main.from))return bae(t,r,s)}return null}function Sj(t,e){let n=!1;return t.field(bj).between(0,t.doc.length,i=>{i==e&&(n=!0)}),n}function Wp(t,e){let n=t.sliceString(e,e+2);return n.slice(0,ir(In(n,0)))}function yae(t,e){let n=t.sliceString(e-2,e);return ir(In(n,0))==n.length?n:n.slice(1)}function vae(t,e,n,i){let r=null,s=t.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:n,from:o.to}],effects:La.of(o.to+e.length),range:de.range(o.anchor+e.length,o.head+e.length)};let c=Wp(t.doc,o.head);return!c||/\s/.test(c)||i.indexOf(c)>-1?{changes:{insert:e+n,from:o.head},effects:La.of(o.head+e.length),range:de.cursor(o.head+e.length)}:{range:r=o}});return r?null:t.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function bae(t,e,n){let i=null,r=t.changeByRange(s=>s.empty&&Wp(t.doc,s.head)==n?{changes:{from:s.head,to:s.head+n.length,insert:n},range:de.cursor(s.head+n.length)}:i={range:s});return i?null:t.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function xae(t,e,n,i){let r=i.stringPrefixes||_u.stringPrefixes,s=null,o=t.changeByRange(c=>{if(!c.empty)return{changes:[{insert:e,from:c.from},{insert:e,from:c.to}],effects:La.of(c.to+e.length),range:de.range(c.anchor+e.length,c.head+e.length)};let u=c.head,h=Wp(t.doc,u),d;if(h==e){if(r4(t,u))return{changes:{insert:e+e,from:u},effects:La.of(u+e.length),range:de.cursor(u+e.length)};if(Sj(t,u)){let g=n&&t.sliceDoc(u,u+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:u,to:u+g.length,insert:g},range:de.cursor(u+g.length)}}}else{if(n&&t.sliceDoc(u-2*e.length,u)==e+e&&(d=s4(t,u-2*e.length,r))>-1&&r4(t,d))return{changes:{insert:e+e+e+e,from:u},effects:La.of(u+e.length),range:de.cursor(u+e.length)};if(t.charCategorizer(u)(h)!=At.Word&&s4(t,u,r)>-1&&!wae(t,u,e,r))return{changes:{insert:e+e,from:u},effects:La.of(u+e.length),range:de.cursor(u+e.length)}}return{range:s=c}});return s?null:t.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function r4(t,e){let n=Cn(t).resolveInner(e+1);return n.parent&&n.from==e}function wae(t,e,n,i){let r=Cn(t).resolveInner(e,-1),s=i.reduce((o,c)=>Math.max(o,c.length),0);for(let o=0;o<5;o++){let c=t.sliceDoc(r.from,Math.min(r.to,r.from+n.length+s)),u=c.indexOf(n);if(!u||u>-1&&i.indexOf(c.slice(0,u))>-1){let d=r.firstChild;for(;d&&d.from==r.from&&d.to-d.from>n.length+u;){if(t.sliceDoc(d.to-n.length,d.to)==n)return!1;d=d.firstChild}return!0}let h=r.to==e&&r.parent;if(!h)break;r=h}return!1}function s4(t,e,n){let i=t.charCategorizer(e);if(i(t.sliceDoc(e-1,e))!=At.Word)return e;for(let r of n){let s=e-r.length;if(t.sliceDoc(s,e)==r&&i(t.sliceDoc(s-1,s))!=At.Word)return s}return-1}function Sae(t={}){return[cae,Pn,rn.of(t),oae,Cae,uae]}const Cj=[{key:"Ctrl-Space",run:Ow},{mac:"Alt-`",run:Ow},{mac:"Alt-i",run:Ow},{key:"Escape",run:iae},{key:"ArrowDown",run:Jh(!0)},{key:"ArrowUp",run:Jh(!1)},{key:"PageDown",run:Jh(!0,"page")},{key:"PageUp",run:Jh(!1,"page")},{key:"Enter",run:nae}],Cae=Za.highest(Hp.computeN([rn],t=>t.facet(rn).defaultKeymap?[Cj]:[]));class a4{constructor(e,n,i){this.from=e,this.to=n,this.diagnostic=i}}class Ea{constructor(e,n,i){this.diagnostics=e,this.panel=n,this.selected=i}static init(e,n,i){let r=i.facet(Ou).markerFilter;r&&(e=r(e,i));let s=e.slice().sort((y,x)=>y.from-x.from||y.to-x.to),o=new Kr,c=[],u=0,h=i.doc.iter(),d=0,m=i.doc.length;for(let y=0;;){let x=y==s.length?null:s[y];if(!x&&!c.length)break;let w,S;if(c.length)w=u,S=c.reduce((O,E)=>Math.min(O,E.to),x&&x.from>w?x.from:1e8);else{if(w=x.from,w>m)break;S=x.to,c.push(x),y++}for(;y<s.length;){let O=s[y];if(O.from==w&&(O.to>O.from||O.to==w))c.push(O),y++,S=Math.min(O.to,S);else{S=Math.min(O.from,S);break}}S=Math.min(S,m);let C=!1;if(c.some(O=>O.from==w&&(O.to==S||S==m))&&(C=w==S,!C&&S-w<10)){let O=w-(d+h.value.length);O>0&&(h.next(O),d=w);for(let E=w;;){if(E>=S){C=!0;break}if(!h.lineBreak&&d+h.value.length>E)break;E=d+h.value.length,d+=h.value.length,h.next()}}let A=Bae(c);if(C)o.add(w,w,Le.widget({widget:new Nae(A),diagnostics:c.slice()}));else{let O=c.reduce((E,T)=>T.markClass?E+" "+T.markClass:E,"");o.add(w,S,Le.mark({class:"cm-lintRange cm-lintRange-"+A+O,diagnostics:c.slice(),inclusiveEnd:c.some(E=>E.to>S)}))}if(u=S,u==m)break;for(let O=0;O<c.length;O++)c[O].to<=u&&c.splice(O--,1)}let g=o.finish();return new Ea(g,n,Zs(g))}}function Zs(t,e=null,n=0){let i=null;return t.between(n,1e9,(r,s,{spec:o})=>{if(!(e&&o.diagnostics.indexOf(e)<0))if(!i)i=new a4(r,s,e||o.diagnostics[0]);else{if(o.diagnostics.indexOf(i.diagnostic)<0)return!1;i=new a4(i.from,s,i.diagnostic)}}),i}function kae(t,e){let n=e.pos,i=e.end||n,r=t.state.facet(Ou).hideOn(t,n,i);if(r!=null)return r;let s=t.startState.doc.lineAt(e.pos);return!!(t.effects.some(o=>o.is(kj))||t.changes.touchesRange(s.from,Math.max(s.to,i)))}function Aae(t,e){return t.field(oi,!1)?e:e.concat(je.appendConfig.of(qae))}const kj=je.define(),PC=je.define(),Aj=je.define(),oi=_n.define({create(){return new Ea(Le.none,null,null)},update(t,e){if(e.docChanged&&t.diagnostics.size){let n=t.diagnostics.map(e.changes),i=null,r=t.panel;if(t.selected){let s=e.changes.mapPos(t.selected.from,1);i=Zs(n,t.selected.diagnostic,s)||Zs(n,null,s)}!n.size&&r&&e.state.facet(Ou).autoPanel&&(r=null),t=new Ea(n,r,i)}for(let n of e.effects)if(n.is(kj)){let i=e.state.facet(Ou).autoPanel?n.value.length?Eu.open:null:t.panel;t=Ea.init(n.value,i,e.state)}else n.is(PC)?t=new Ea(t.diagnostics,n.value?Eu.open:null,t.selected):n.is(Aj)&&(t=new Ea(t.diagnostics,t.panel,n.value));return t},provide:t=>[xu.from(t,e=>e.panel),Se.decorations.from(t,e=>e.diagnostics)]}),_ae=Le.mark({class:"cm-lintRange cm-lintRange-active"});function Oae(t,e,n){let{diagnostics:i}=t.state.field(oi),r,s=-1,o=-1;i.between(e-(n<0?1:0),e+(n>0?1:0),(u,h,{spec:d})=>{if(e>=u&&e<=h&&(u==h||(e>u||n>0)&&(e<h||n<0)))return r=d.diagnostics,s=u,o=h,!1});let c=t.state.facet(Ou).tooltipFilter;return r&&c&&(r=c(r,t.state)),r?{pos:s,end:o,above:t.state.doc.lineAt(s).to<o,create(){return{dom:Eae(t,r)}}}:null}function Eae(t,e){return dt("ul",{class:"cm-tooltip-lint"},e.map(n=>Oj(t,n,!1)))}const Tae=t=>{let e=t.state.field(oi,!1);(!e||!e.panel)&&t.dispatch({effects:Aae(t.state,[PC.of(!0)])});let n=wC(t,Eu.open);return n&&n.dom.querySelector(".cm-panel-lint ul").focus(),!0},o4=t=>{let e=t.state.field(oi,!1);return!e||!e.panel?!1:(t.dispatch({effects:PC.of(!1)}),!0)},Mae=t=>{let e=t.state.field(oi,!1);if(!e)return!1;let n=t.state.selection.main,i=Zs(e.diagnostics,null,n.to+1);return!i&&(i=Zs(e.diagnostics,null,0),!i||i.from==n.from&&i.to==n.to)?!1:(t.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0}),!0)},Rae=[{key:"Mod-Shift-m",run:Tae,preventDefault:!0},{key:"F8",run:Mae}],Ou=ke.define({combine(t){return{sources:t.map(e=>e.source).filter(e=>e!=null),...pr(t.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:l4,tooltipFilter:l4,needsRefresh:(e,n)=>e?n?i=>e(i)||n(i):e:n,hideOn:(e,n)=>e?n?(i,r,s)=>e(i,r,s)||n(i,r,s):e:n,autoPanel:(e,n)=>e||n})}}});function l4(t,e){return t?e?(n,i)=>e(t(n,i),i):t:e}function _j(t){let e=[];if(t)e:for(let{name:n}of t){for(let i=0;i<n.length;i++){let r=n[i];if(/[a-zA-Z]/.test(r)&&!e.some(s=>s.toLowerCase()==r.toLowerCase())){e.push(r);continue e}}e.push("")}return e}function Oj(t,e,n){var i;let r=n?_j(e.actions):[];return dt("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},dt("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(t):e.message),(i=e.actions)===null||i===void 0?void 0:i.map((s,o)=>{let c=!1,u=y=>{if(y.preventDefault(),c)return;c=!0;let x=Zs(t.state.field(oi).diagnostics,e);x&&s.apply(t,x.from,x.to)},{name:h}=s,d=r[o]?h.indexOf(r[o]):-1,m=d<0?h:[h.slice(0,d),dt("u",h.slice(d,d+1)),h.slice(d+1)],g=s.markClass?" "+s.markClass:"";return dt("button",{type:"button",class:"cm-diagnosticAction"+g,onclick:u,onmousedown:u,"aria-label":` Action: ${h}${d<0?"":` (access key "${r[o]})"`}.`},m)}),e.source&&dt("div",{class:"cm-diagnosticSource"},e.source))}class Nae extends mr{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return dt("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class c4{constructor(e,n){this.diagnostic=n,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=Oj(e,n,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class Eu{constructor(e){this.view=e,this.items=[];let n=r=>{if(!(r.ctrlKey||r.altKey||r.metaKey)){if(r.keyCode==27)o4(this.view),this.view.focus();else if(r.keyCode==38||r.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(r.keyCode==40||r.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(r.keyCode==36)this.moveSelection(0);else if(r.keyCode==35)this.moveSelection(this.items.length-1);else if(r.keyCode==13)this.view.focus();else if(r.keyCode>=65&&r.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:s}=this.items[this.selectedIndex],o=_j(s.actions);for(let c=0;c<o.length;c++)if(o[c].toUpperCase().charCodeAt(0)==r.keyCode){let u=Zs(this.view.state.field(oi).diagnostics,s);u&&s.actions[c].apply(e,u.from,u.to)}}else return;r.preventDefault()}},i=r=>{for(let s=0;s<this.items.length;s++)this.items[s].dom.contains(r.target)&&this.moveSelection(s)};this.list=dt("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:n,onclick:i}),this.dom=dt("div",{class:"cm-panel-lint"},this.list,dt("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>o4(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(oi).selected;if(!e)return-1;for(let n=0;n<this.items.length;n++)if(this.items[n].diagnostic==e.diagnostic)return n;return-1}update(){let{diagnostics:e,selected:n}=this.view.state.field(oi),i=0,r=!1,s=null,o=new Set;for(e.between(0,this.view.state.doc.length,(c,u,{spec:h})=>{for(let d of h.diagnostics){if(o.has(d))continue;o.add(d);let m=-1,g;for(let y=i;y<this.items.length;y++)if(this.items[y].diagnostic==d){m=y;break}m<0?(g=new c4(this.view,d),this.items.splice(i,0,g),r=!0):(g=this.items[m],m>i&&(this.items.splice(i,m-i),r=!0)),n&&g.diagnostic==n.diagnostic?g.dom.hasAttribute("aria-selected")||(g.dom.setAttribute("aria-selected","true"),s=g):g.dom.hasAttribute("aria-selected")&&g.dom.removeAttribute("aria-selected"),i++}});i<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();this.items.length==0&&(this.items.push(new c4(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),r=!0),s?(this.list.setAttribute("aria-activedescendant",s.id),this.view.requestMeasure({key:this,read:()=>({sel:s.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:c,panel:u})=>{let h=u.height/this.list.offsetHeight;c.top<u.top?this.list.scrollTop-=(u.top-c.top)/h:c.bottom>u.bottom&&(this.list.scrollTop+=(c.bottom-u.bottom)/h)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),r&&this.sync()}sync(){let e=this.list.firstChild;function n(){let i=e;e=i.nextSibling,i.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;e!=i.dom;)n();e=i.dom.nextSibling}else this.list.insertBefore(i.dom,e);for(;e;)n()}moveSelection(e){if(this.selectedIndex<0)return;let n=this.view.state.field(oi),i=Zs(n.diagnostics,this.items[e].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:Aj.of(i)})}static open(e){return new Eu(e)}}function Dae(t,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(t)}</svg>')`}function ed(t){return Dae(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${t}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const Lae=Se.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:ed("#d11")},".cm-lintRange-warning":{backgroundImage:ed("orange")},".cm-lintRange-info":{backgroundImage:ed("#999")},".cm-lintRange-hint":{backgroundImage:ed("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:"#86714a80"},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:"#2e343e"}}});function zae(t){return t=="error"?4:t=="warning"?3:t=="info"?2:1}function Bae(t){let e="hint",n=1;for(let i of t){let r=zae(i.severity);r>n&&(n=r,e=i.severity)}return e}const qae=[oi,Se.decorations.compute([oi],t=>{let{selected:e,panel:n}=t.field(oi);return!e||!n||e.from==e.to?Le.none:Le.set([_ae.range(e.from,e.to)])}),One(Oae,{hideOn:kae}),Lae];var u4=function(e){e===void 0&&(e={});var{crosshairCursor:n=!1}=e,i=[];e.closeBracketsKeymap!==!1&&(i=i.concat(mae)),e.defaultKeymap!==!1&&(i=i.concat(ose)),e.searchKeymap!==!1&&(i=i.concat(Lse)),e.historyKeymap!==!1&&(i=i.concat(pre)),e.foldKeymap!==!1&&(i=i.concat(Eie)),e.completionKeymap!==!1&&(i=i.concat(Cj)),e.lintKeymap!==!1&&(i=i.concat(Rae));var r=[];return e.lineNumbers!==!1&&r.push(Pne()),e.highlightActiveLineGutter!==!1&&r.push(Vne()),e.highlightSpecialChars!==!1&&r.push(nne()),e.history!==!1&&r.push(sre()),e.foldGutter!==!1&&r.push(Nie()),e.drawSelection!==!1&&r.push($te()),e.dropCursor!==!1&&r.push(Wte()),e.allowMultipleSelections!==!1&&r.push(Je.allowMultipleSelections.of(!0)),e.indentOnInput!==!1&&r.push(vie()),e.syntaxHighlighting!==!1&&r.push(kq(Bie,{fallback:!0})),e.bracketMatching!==!1&&r.push(Vie()),e.closeBrackets!==!1&&r.push(fae()),e.autocompletion!==!1&&r.push(Sae()),e.rectangularSelection!==!1&&r.push(gne()),n!==!1&&r.push(bne()),e.highlightActiveLine!==!1&&r.push(lne()),e.highlightSelectionMatches!==!1&&r.push(dse()),e.tabSize&&typeof e.tabSize=="number"&&r.push(Vp.of(" ".repeat(e.tabSize))),r.concat([Hp.of(i.flat())]).filter(Boolean)};const jae="#e5c07b",f4="#e06c75",Iae="#56b6c2",Pae="#ffffff",dd="#abb2bf",n2="#7d8799",Hae="#61afef",Uae="#98c379",h4="#d19a66",Vae="#c678dd",Fae="#21252b",d4="#2c313a",p4="#282c34",Tw="#353a42",$ae="#3E4451",m4="#528bff",Gae=Se.theme({"&":{color:dd,backgroundColor:p4},".cm-content":{caretColor:m4},".cm-cursor, .cm-dropCursor":{borderLeftColor:m4},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:$ae},".cm-panels":{backgroundColor:Fae,color:dd},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:p4,color:n2,border:"none"},".cm-activeLineGutter":{backgroundColor:d4},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:Tw},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:Tw,borderBottomColor:Tw},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:d4,color:dd}}},{dark:!0}),Yae=$u.define([{tag:le.keyword,color:Vae},{tag:[le.name,le.deleted,le.character,le.propertyName,le.macroName],color:f4},{tag:[le.function(le.variableName),le.labelName],color:Hae},{tag:[le.color,le.constant(le.name),le.standard(le.name)],color:h4},{tag:[le.definition(le.name),le.separator],color:dd},{tag:[le.typeName,le.className,le.number,le.changed,le.annotation,le.modifier,le.self,le.namespace],color:jae},{tag:[le.operator,le.operatorKeyword,le.url,le.escape,le.regexp,le.link,le.special(le.string)],color:Iae},{tag:[le.meta,le.comment],color:n2},{tag:le.strong,fontWeight:"bold"},{tag:le.emphasis,fontStyle:"italic"},{tag:le.strikethrough,textDecoration:"line-through"},{tag:le.link,color:n2,textDecoration:"underline"},{tag:le.heading,fontWeight:"bold",color:f4},{tag:[le.atom,le.bool,le.special(le.variableName)],color:h4},{tag:[le.processingInstruction,le.string,le.inserted],color:Uae},{tag:le.invalid,color:Pae}]),Ej=[Gae,kq(Yae)];var Qae=Se.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),Xae=function(e){e===void 0&&(e={});var{indentWithTab:n=!0,editable:i=!0,readOnly:r=!1,theme:s="light",placeholder:o="",basicSetup:c=!0}=e,u=[];switch(n&&u.unshift(Hp.of([lse])),c&&(typeof c=="boolean"?u.unshift(u4()):u.unshift(u4(c))),o&&u.unshift(hne(o)),s){case"light":u.push(Qae);break;case"dark":u.push(Ej);break;case"none":break;default:u.push(s);break}return i===!1&&u.push(Se.editable.of(!1)),r&&u.push(Je.readOnly.of(!0)),[...u]},Wae=t=>({line:t.state.doc.lineAt(t.state.selection.main.from),lineCount:t.state.doc.lines,lineBreak:t.state.lineBreak,length:t.state.doc.length,readOnly:t.state.readOnly,tabSize:t.state.tabSize,selection:t.state.selection,selectionAsSingle:t.state.selection.asSingle().main,ranges:t.state.selection.ranges,selectionCode:t.state.sliceDoc(t.state.selection.main.from,t.state.selection.main.to),selections:t.state.selection.ranges.map(e=>t.state.sliceDoc(e.from,e.to)),selectedText:t.state.selection.ranges.some(e=>!e.empty)});class Kae{constructor(e,n){this.timeLeftMS=void 0,this.timeoutMS=void 0,this.isCancelled=!1,this.isTimeExhausted=!1,this.callbacks=[],this.timeLeftMS=n,this.timeoutMS=n,this.callbacks.push(e)}tick(){if(!this.isCancelled&&!this.isTimeExhausted&&(this.timeLeftMS--,this.timeLeftMS<=0)){this.isTimeExhausted=!0;var e=this.callbacks.slice();this.callbacks.length=0,e.forEach(n=>{try{n()}catch(i){console.error("TimeoutLatch callback error:",i)}})}}cancel(){this.isCancelled=!0,this.callbacks.length=0}reset(){this.timeLeftMS=this.timeoutMS,this.isCancelled=!1,this.isTimeExhausted=!1}get isDone(){return this.isCancelled||this.isTimeExhausted}}class g4{constructor(){this.interval=null,this.latches=new Set}add(e){this.latches.add(e),this.start()}remove(e){this.latches.delete(e),this.latches.size===0&&this.stop()}start(){this.interval===null&&(this.interval=setInterval(()=>{this.latches.forEach(e=>{e.tick(),e.isDone&&this.remove(e)})},1))}stop(){this.interval!==null&&(clearInterval(this.interval),this.interval=null)}}var Mw=null,Zae=()=>typeof window>"u"?new g4:(Mw||(Mw=new g4),Mw),y4=dr.define(),Jae=200,eoe=[];function toe(t){var{value:e,selection:n,onChange:i,onStatistics:r,onCreateEditor:s,onUpdate:o,extensions:c=eoe,autoFocus:u,theme:h="light",height:d=null,minHeight:m=null,maxHeight:g=null,width:y=null,minWidth:x=null,maxWidth:w=null,placeholder:S="",editable:C=!0,readOnly:A=!1,indentWithTab:O=!0,basicSetup:E=!0,root:T,initialState:M}=t,[R,z]=j.useState(),[q,U]=j.useState(),[P,$]=j.useState(),K=j.useState(()=>({current:null}))[0],L=j.useState(()=>({current:null}))[0],Y=Se.theme({"&":{height:d,minHeight:m,maxHeight:g,width:y,minWidth:x,maxWidth:w},"& .cm-scroller":{height:"100% !important"}}),D=Se.updateListener.of(G=>{if(G.docChanged&&typeof i=="function"&&!G.transactions.some(F=>F.annotation(y4))){K.current?K.current.reset():(K.current=new Kae(()=>{if(L.current){var F=L.current;L.current=null,F()}K.current=null},Jae),Zae().add(K.current));var W=G.state.doc,B=W.toString();i(B,G)}r&&r(Wae(G))}),Q=Xae({theme:h,editable:C,readOnly:A,placeholder:S,indentWithTab:O,basicSetup:E}),ee=[D,Y,...Q];return o&&typeof o=="function"&&ee.push(Se.updateListener.of(o)),ee=ee.concat(c),j.useLayoutEffect(()=>{if(R&&!P){var G={doc:e,selection:n,extensions:ee},W=M?Je.fromJSON(M.json,G,M.fields):Je.create(G);if($(W),!q){var B=new Se({state:W,parent:R,root:T});U(B),s&&s(B,W)}}return()=>{q&&($(void 0),U(void 0))}},[R,P]),j.useEffect(()=>{t.container&&z(t.container)},[t.container]),j.useEffect(()=>()=>{q&&(q.destroy(),U(void 0)),K.current&&(K.current.cancel(),K.current=null)},[q]),j.useEffect(()=>{u&&q&&q.focus()},[u,q]),j.useEffect(()=>{q&&q.dispatch({effects:je.reconfigure.of(ee)})},[h,c,d,m,g,y,x,w,S,C,A,O,E,i,o]),j.useEffect(()=>{if(e!==void 0){var G=q?q.state.doc.toString():"";if(q&&e!==G){var W=K.current&&!K.current.isDone,B=()=>{q&&e!==q.state.doc.toString()&&q.dispatch({changes:{from:0,to:q.state.doc.toString().length,insert:e||""},annotations:[y4.of(!0)]})};W?L.current=B:B()}}},[e,q]),{state:P,setState:$,view:q,setView:U,container:R,setContainer:z}}var noe=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],Tj=j.forwardRef((t,e)=>{var{className:n,value:i="",selection:r,extensions:s=[],onChange:o,onStatistics:c,onCreateEditor:u,onUpdate:h,autoFocus:d,theme:m="light",height:g,minHeight:y,maxHeight:x,width:w,minWidth:S,maxWidth:C,basicSetup:A,placeholder:O,indentWithTab:E,editable:T,readOnly:M,root:R,initialState:z}=t,q=NJ(t,noe),U=j.useRef(null),{state:P,view:$,container:K,setContainer:L}=toe({root:R,value:i,autoFocus:d,theme:m,height:g,minHeight:y,maxHeight:x,width:w,minWidth:S,maxWidth:C,basicSetup:A,placeholder:O,indentWithTab:E,editable:T,readOnly:M,selection:r,onChange:o,onStatistics:c,onCreateEditor:u,onUpdate:h,extensions:s,initialState:z});j.useImperativeHandle(e,()=>({editor:U.current,state:P,view:$}),[U,K,P,$]);var Y=j.useCallback(Q=>{U.current=Q,L(Q)},[L]);if(typeof i!="string")throw new Error("value must be typeof string but got "+typeof i);var D=typeof m=="string"?"cm-theme-"+m:"cm-theme";return k.jsx("div",cS({ref:Y,className:""+D+(n?" "+n:"")},q))});Tj.displayName="CodeMirror";var v4={};class ap{constructor(e,n,i,r,s,o,c,u,h,d=0,m){this.p=e,this.stack=n,this.state=i,this.reducePos=r,this.pos=s,this.score=o,this.buffer=c,this.bufferBase=u,this.curContext=h,this.lookAhead=d,this.parent=m}toString(){return`[${this.stack.filter((e,n)=>n%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,n,i=0){let r=e.parser.context;return new ap(e,[],n,i,i,0,[],0,r?new b4(r,r.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,n){this.stack.push(this.state,n,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var n;let i=e>>19,r=e&65535,{parser:s}=this.p,o=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),c=s.dynamicPrecedence(r);if(c&&(this.score+=c),i==0){this.pushState(s.getGoto(this.state,r,!0),this.reducePos),r<s.minRepeatTerm&&this.storeNode(r,this.reducePos,this.reducePos,o?8:4,!0),this.reduceContext(r,this.reducePos);return}let u=this.stack.length-(i-1)*3-(e&262144?6:0),h=u?this.stack[u-2]:this.p.ranges[0].from,d=this.reducePos-h;d>=2e3&&!(!((n=this.p.parser.nodeSet.types[r])===null||n===void 0)&&n.isAnonymous)&&(h==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=d):this.p.lastBigReductionSize<d&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=h,this.p.lastBigReductionSize=d));let m=u?this.stack[u-1]:0,g=this.bufferBase+this.buffer.length-m;if(r<s.minRepeatTerm||e&131072){let y=s.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(r,h,y,g+4,!0)}if(e&262144)this.state=this.stack[u];else{let y=this.stack[u-3];this.state=s.getGoto(y,r,!0)}for(;this.stack.length>u;)this.stack.pop();this.reduceContext(r,h)}storeNode(e,n,i,r=4,s=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let o=this,c=this.buffer.length;if(c==0&&o.parent&&(c=o.bufferBase-o.parent.bufferBase,o=o.parent),c>0&&o.buffer[c-4]==0&&o.buffer[c-1]>-1){if(n==i)return;if(o.buffer[c-2]>=n){o.buffer[c-2]=i;return}}}if(!s||this.pos==i)this.buffer.push(e,n,i,r);else{let o=this.buffer.length;if(o>0&&(this.buffer[o-4]!=0||this.buffer[o-1]<0)){let c=!1;for(let u=o;u>0&&this.buffer[u-2]>i;u-=4)if(this.buffer[u-1]>=0){c=!0;break}if(c)for(;o>0&&this.buffer[o-2]>i;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,r>4&&(r-=4)}this.buffer[o]=e,this.buffer[o+1]=n,this.buffer[o+2]=i,this.buffer[o+3]=r}}shift(e,n,i,r){if(e&131072)this.pushState(e&65535,this.pos);else if((e&262144)==0){let s=e,{parser:o}=this.p;this.pos=r;let c=o.stateFlag(s,1);!c&&(r>i||n<=o.maxNode)&&(this.reducePos=r),this.pushState(s,c?i:Math.min(i,this.reducePos)),this.shiftContext(n,i),n<=o.maxNode&&this.buffer.push(n,i,r,4)}else this.pos=r,this.shiftContext(n,i),n<=this.p.parser.maxNode&&this.buffer.push(n,i,r,4)}apply(e,n,i,r){e&65536?this.reduce(e):this.shift(e,n,i,r)}useNode(e,n){let i=this.p.reused.length-1;(i<0||this.p.reused[i]!=e)&&(this.p.reused.push(e),i++);let r=this.pos;this.reducePos=this.pos=r+e.length,this.pushState(n,r),this.buffer.push(i,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 e=this,n=e.buffer.length;for(;n>0&&e.buffer[n-2]>e.reducePos;)n-=4;let i=e.buffer.slice(n),r=e.bufferBase+n;for(;e&&r==e.bufferBase;)e=e.parent;return new ap(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,r,this.curContext,this.lookAhead,e)}recoverByDelete(e,n){let i=e<=this.p.parser.maxNode;i&&this.storeNode(e,this.pos,n,4),this.storeNode(0,this.pos,n,i?8:4),this.pos=this.reducePos=n,this.score-=190}canShift(e){for(let n=new ioe(this);;){let i=this.p.parser.stateSlot(n.state,4)||this.p.parser.hasAction(n.state,e);if(i==0)return!1;if((i&65536)==0)return!0;n.reduce(i)}}recoverByInsert(e){if(this.stack.length>=300)return[];let n=this.p.parser.nextStates(this.state);if(n.length>8||this.stack.length>=120){let r=[];for(let s=0,o;s<n.length;s+=2)(o=n[s+1])!=this.state&&this.p.parser.hasAction(o,e)&&r.push(n[s],o);if(this.stack.length<120)for(let s=0;r.length<8&&s<n.length;s+=2){let o=n[s+1];r.some((c,u)=>u&1&&c==o)||r.push(n[s],o)}n=r}let i=[];for(let r=0;r<n.length&&i.length<4;r+=2){let s=n[r+1];if(s==this.state)continue;let o=this.split();o.pushState(s,this.pos),o.storeNode(0,o.pos,o.pos,4,!0),o.shiftContext(n[r],this.pos),o.reducePos=this.pos,o.score-=200,i.push(o)}return i}forceReduce(){let{parser:e}=this.p,n=e.stateSlot(this.state,5);if((n&65536)==0)return!1;if(!e.validAction(this.state,n)){let i=n>>19,r=n&65535,s=this.stack.length-i*3;if(s<0||e.getGoto(this.stack[s],r,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;n=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(n),!0}findForcedReduction(){let{parser:e}=this.p,n=[],i=(r,s)=>{if(!n.includes(r))return n.push(r),e.allActions(r,o=>{if(!(o&393216))if(o&65536){let c=(o>>19)-s;if(c>1){let u=o&65535,h=this.stack.length-c*3;if(h>=0&&e.getGoto(this.stack[h],u,!1)>=0)return c<<19|65536|u}}else{let c=i(o,s+1);if(c!=null)return c}})};return i(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 n=0;n<this.stack.length;n+=3)if(this.stack[n]!=e.stack[n])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,n){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(n)))}reduceContext(e,n){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(n)))}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 n=new b4(this.curContext.tracker,e);n.hash!=this.curContext.hash&&this.emitContext(),this.curContext=n}}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()}}class b4{constructor(e,n){this.tracker=e,this.context=n,this.hash=e.strict?e.hash(n):0}}class ioe{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let n=e&65535,i=e>>19;i==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(i-1)*3;let r=this.start.p.parser.getGoto(this.stack[this.base-3],n,!0);this.state=r}}class op{constructor(e,n,i){this.stack=e,this.pos=n,this.index=i,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,n=e.bufferBase+e.buffer.length){return new op(e,n,n-e.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 op(this.stack,this.pos,this.index)}}function td(t,e=Uint16Array){if(typeof t!="string")return t;let n=null;for(let i=0,r=0;i<t.length;){let s=0;for(;;){let o=t.charCodeAt(i++),c=!1;if(o==126){s=65535;break}o>=92&&o--,o>=34&&o--;let u=o-32;if(u>=46&&(u-=46,c=!0),s+=u,c)break;s*=46}n?n[r++]=s:n=new e(s)}return n}class pd{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const x4=new pd;class roe{constructor(e,n){this.input=e,this.ranges=n,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=x4,this.rangeIndex=0,this.pos=this.chunkPos=n[0].from,this.range=n[0],this.end=n[n.length-1].to,this.readNext()}resolveOffset(e,n){let i=this.range,r=this.rangeIndex,s=this.pos+e;for(;s<i.from;){if(!r)return null;let o=this.ranges[--r];s-=i.from-o.to,i=o}for(;n<0?s>i.to:s>=i.to;){if(r==this.ranges.length-1)return null;let o=this.ranges[++r];s+=o.from-i.to,i=o}return s}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let n of this.ranges)if(n.to>e)return Math.max(e,n.from);return this.end}peek(e){let n=this.chunkOff+e,i,r;if(n>=0&&n<this.chunk.length)i=this.pos+e,r=this.chunk.charCodeAt(n);else{let s=this.resolveOffset(e,1);if(s==null)return-1;if(i=s,i>=this.chunk2Pos&&i<this.chunk2Pos+this.chunk2.length)r=this.chunk2.charCodeAt(i-this.chunk2Pos);else{let o=this.rangeIndex,c=this.range;for(;c.to<=i;)c=this.ranges[++o];this.chunk2=this.input.chunk(this.chunk2Pos=i),i+this.chunk2.length>c.to&&(this.chunk2=this.chunk2.slice(0,c.to-i)),r=this.chunk2.charCodeAt(0)}}return i>=this.token.lookAhead&&(this.token.lookAhead=i+1),r}acceptToken(e,n=0){let i=n?this.resolveOffset(n,-1):this.pos;if(i==null||i<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=i}acceptTokenTo(e,n){this.token.value=e,this.token.end=n}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:n}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=n,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),n=this.pos+e.length;this.chunk=n>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,n){if(n?(this.token=n,n.start=e,n.lookAhead=e+1,n.value=n.extended=-1):this.token=x4,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,n){if(e>=this.chunkPos&&n<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,n-this.chunkPos);if(e>=this.chunk2Pos&&n<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,n-this.chunk2Pos);if(e>=this.range.from&&n<=this.range.to)return this.input.read(e,n);let i="";for(let r of this.ranges){if(r.from>=n)break;r.to>e&&(i+=this.input.read(Math.max(r.from,e),Math.min(r.to,n)))}return i}}class cl{constructor(e,n){this.data=e,this.id=n}token(e,n){let{parser:i}=n.p;soe(this.data,e,n,this.id,i.data,i.tokenPrecTable)}}cl.prototype.contextual=cl.prototype.fallback=cl.prototype.extend=!1;cl.prototype.fallback=cl.prototype.extend=!1;class Kp{constructor(e,n={}){this.token=e,this.contextual=!!n.contextual,this.fallback=!!n.fallback,this.extend=!!n.extend}}function soe(t,e,n,i,r,s){let o=0,c=1<<i,{dialect:u}=n.p.parser;e:for(;(c&t[o])!=0;){let h=t[o+1];for(let y=o+3;y<h;y+=2)if((t[y+1]&c)>0){let x=t[y];if(u.allows(x)&&(e.token.value==-1||e.token.value==x||aoe(x,e.token.value,r,s))){e.acceptToken(x);break}}let d=e.next,m=0,g=t[o+2];if(e.next<0&&g>m&&t[h+g*3-3]==65535){o=t[h+g*3-1];continue e}for(;m<g;){let y=m+g>>1,x=h+y+(y<<1),w=t[x],S=t[x+1]||65536;if(d<w)g=y;else if(d>=S)m=y+1;else{o=t[x+2],e.advance();continue e}}break}}function w4(t,e,n){for(let i=e,r;(r=t[i])!=65535;i++)if(r==n)return i-e;return-1}function aoe(t,e,n,i){let r=w4(n,i,e);return r<0||w4(n,i,t)<r}const si=typeof process<"u"&&v4&&/\bparse\b/.test(v4.LOG);let Rw=null;function S4(t,e,n){let i=t.cursor(Nt.IncludeAnonymous);for(i.moveTo(e);;)if(!(n<0?i.childBefore(e):i.childAfter(e)))for(;;){if((n<0?i.to<e:i.from>e)&&!i.type.isError)return n<0?Math.max(0,Math.min(i.to-1,e-25)):Math.min(t.length,Math.max(i.from+1,e+25));if(n<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return n<0?0:t.length}}class ooe{constructor(e,n){this.fragments=e,this.nodeSet=n,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?S4(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?S4(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 n=this.trees.length-1;if(n<0)return this.nextFragment(),null;let i=this.trees[n],r=this.index[n];if(r==i.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let s=i.children[r],o=this.start[n]+i.positions[r];if(o>e)return this.nextStart=o,null;if(s instanceof It){if(o==e){if(o<this.safeFrom)return null;let c=o+s.length;if(c<=this.safeTo){let u=s.prop(Fe.lookAhead);if(!u||c+u<this.fragment.to)return s}}this.index[n]++,o+s.length>=Math.max(this.safeFrom,e)&&(this.trees.push(s),this.start.push(o),this.index.push(0))}else this.index[n]++,this.nextStart=o+s.length}}}class loe{constructor(e,n){this.stream=n,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(i=>new pd)}getActions(e){let n=0,i=null,{parser:r}=e.p,{tokenizers:s}=r,o=r.stateSlot(e.state,3),c=e.curContext?e.curContext.hash:0,u=0;for(let h=0;h<s.length;h++){if((1<<h&o)==0)continue;let d=s[h],m=this.tokens[h];if(!(i&&!d.fallback)&&((d.contextual||m.start!=e.pos||m.mask!=o||m.context!=c)&&(this.updateCachedToken(m,d,e),m.mask=o,m.context=c),m.lookAhead>m.end+25&&(u=Math.max(m.lookAhead,u)),m.value!=0)){let g=n;if(m.extended>-1&&(n=this.addActions(e,m.extended,m.end,n)),n=this.addActions(e,m.value,m.end,n),!d.extend&&(i=m,n>g))break}}for(;this.actions.length>n;)this.actions.pop();return u&&e.setLookAhead(u),!i&&e.pos==this.stream.end&&(i=new pd,i.value=e.p.parser.eofTerm,i.start=i.end=e.pos,n=this.addActions(e,i.value,i.end,n)),this.mainToken=i,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let n=new pd,{pos:i,p:r}=e;return n.start=i,n.end=Math.min(i+1,r.stream.end),n.value=i==r.stream.end?r.parser.eofTerm:0,n}updateCachedToken(e,n,i){let r=this.stream.clipPos(i.pos);if(n.token(this.stream.reset(r,e),i),e.value>-1){let{parser:s}=i.p;for(let o=0;o<s.specialized.length;o++)if(s.specialized[o]==e.value){let c=s.specializers[o](this.stream.read(e.start,e.end),i);if(c>=0&&i.p.parser.dialect.allows(c>>1)){(c&1)==0?e.value=c>>1:e.extended=c>>1;break}}}else e.value=0,e.end=this.stream.clipPos(r+1)}putAction(e,n,i,r){for(let s=0;s<r;s+=3)if(this.actions[s]==e)return r;return this.actions[r++]=e,this.actions[r++]=n,this.actions[r++]=i,r}addActions(e,n,i,r){let{state:s}=e,{parser:o}=e.p,{data:c}=o;for(let u=0;u<2;u++)for(let h=o.stateSlot(s,u?2:1);;h+=3){if(c[h]==65535)if(c[h+1]==1)h=Vr(c,h+2);else{r==0&&c[h+1]==2&&(r=this.putAction(Vr(c,h+2),n,i,r));break}c[h]==n&&(r=this.putAction(Vr(c,h+1),n,i,r))}return r}}class coe{constructor(e,n,i,r){this.parser=e,this.input=n,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 roe(n,r),this.tokens=new loe(e,this.stream),this.topTerm=e.top[1];let{from:s}=r[0];this.stacks=[ap.start(this,e.top[0],s)],this.fragments=i.length&&this.stream.end-s>e.bufferLength*4?new ooe(i,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,n=this.minStackPos,i=this.stacks=[],r,s;if(this.bigReductionCount>300&&e.length==1){let[o]=e;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;o<e.length;o++){let c=e[o];for(;;){if(this.tokens.mainToken=null,c.pos>n)i.push(c);else{if(this.advanceStack(c,i,e))continue;{r||(r=[],s=[]),r.push(c);let u=this.tokens.getMainToken(c);s.push(u.value,u.end)}}break}}if(!i.length){let o=r&&hoe(r);if(o)return si&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw si&&r&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+n);this.recovering||(this.recovering=5)}if(this.recovering&&r){let o=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,s,i);if(o)return si&&console.log("Force-finish "+this.stackID(o)),this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(i.length>o)for(i.sort((c,u)=>u.score-c.score);i.length>o;)i.pop();i.some(c=>c.reducePos>n)&&this.recovering--}else if(i.length>1){e:for(let o=0;o<i.length-1;o++){let c=i[o];for(let u=o+1;u<i.length;u++){let h=i[u];if(c.sameState(h)||c.buffer.length>500&&h.buffer.length>500)if((c.score-h.score||c.buffer.length-h.buffer.length)>0)i.splice(u--,1);else{i.splice(o--,1);continue e}}}i.length>12&&(i.sort((o,c)=>c.score-o.score),i.splice(12,i.length-12))}this.minStackPos=i[0].pos;for(let o=1;o<i.length;o++)i[o].pos<this.minStackPos&&(this.minStackPos=i[o].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,n,i){let r=e.pos,{parser:s}=this,o=si?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&r>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let h=e.curContext&&e.curContext.tracker.strict,d=h?e.curContext.hash:0;for(let m=this.fragments.nodeAt(r);m;){let g=this.parser.nodeSet.types[m.type.id]==m.type?s.getGoto(e.state,m.type.id):-1;if(g>-1&&m.length&&(!h||(m.prop(Fe.contextHash)||0)==d))return e.useNode(m,g),si&&console.log(o+this.stackID(e)+` (via reuse of ${s.getName(m.type.id)})`),!0;if(!(m instanceof It)||m.children.length==0||m.positions[0]>0)break;let y=m.children[0];if(y instanceof It&&m.positions[0]==0)m=y;else break}}let c=s.stateSlot(e.state,4);if(c>0)return e.reduce(c),si&&console.log(o+this.stackID(e)+` (via always-reduce ${s.getName(c&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let u=this.tokens.getActions(e);for(let h=0;h<u.length;){let d=u[h++],m=u[h++],g=u[h++],y=h==u.length||!i,x=y?e:e.split(),w=this.tokens.mainToken;if(x.apply(d,m,w?w.start:x.pos,g),si&&console.log(o+this.stackID(x)+` (via ${(d&65536)==0?"shift":`reduce of ${s.getName(d&65535)}`} for ${s.getName(m)} @ ${r}${x==e?"":", split"})`),y)return!0;x.pos>r?n.push(x):i.push(x)}return!1}advanceFully(e,n){let i=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>i)return C4(e,n),!0}}runRecovery(e,n,i){let r=null,s=!1;for(let o=0;o<e.length;o++){let c=e[o],u=n[o<<1],h=n[(o<<1)+1],d=si?this.stackID(c)+" -> ":"";if(c.deadEnd&&(s||(s=!0,c.restart(),si&&console.log(d+this.stackID(c)+" (restarted)"),this.advanceFully(c,i))))continue;let m=c.split(),g=d;for(let y=0;y<10&&m.forceReduce()&&(si&&console.log(g+this.stackID(m)+" (via force-reduce)"),!this.advanceFully(m,i));y++)si&&(g=this.stackID(m)+" -> ");for(let y of c.recoverByInsert(u))si&&console.log(d+this.stackID(y)+" (via recover-insert)"),this.advanceFully(y,i);this.stream.end>c.pos?(h==c.pos&&(h++,u=0),c.recoverByDelete(u,h),si&&console.log(d+this.stackID(c)+` (via recover-delete ${this.parser.getName(u)})`),C4(c,i)):(!r||r.score<m.score)&&(r=m)}return r}stackToTree(e){return e.close(),It.build({buffer:op.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 n=(Rw||(Rw=new WeakMap)).get(e);return n||Rw.set(e,n=String.fromCodePoint(this.nextStackID++)),n+e}}function C4(t,e){for(let n=0;n<e.length;n++){let i=e[n];if(i.pos==t.pos&&i.sameState(t)){e[n].score<t.score&&(e[n]=t);return}}e.push(t)}class uoe{constructor(e,n,i){this.source=e,this.flags=n,this.disabled=i}allows(e){return!this.disabled||this.disabled[e]==0}}const Nw=t=>t;class foe{constructor(e){this.start=e.start,this.shift=e.shift||Nw,this.reduce=e.reduce||Nw,this.reuse=e.reuse||Nw,this.hash=e.hash||(()=>0),this.strict=e.strict!==!1}}class lp extends oq{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let n=e.nodeNames.split(" ");this.minRepeatTerm=n.length;for(let c=0;c<e.repeatNodeCount;c++)n.push("");let i=Object.keys(e.topRules).map(c=>e.topRules[c][1]),r=[];for(let c=0;c<n.length;c++)r.push([]);function s(c,u,h){r[c].push([u,u.deserialize(String(h))])}if(e.nodeProps)for(let c of e.nodeProps){let u=c[0];typeof u=="string"&&(u=Fe[u]);for(let h=1;h<c.length;){let d=c[h++];if(d>=0)s(d,u,c[h++]);else{let m=c[h+-d];for(let g=-d;g>0;g--)s(c[h++],u,m);h++}}}this.nodeSet=new SC(n.map((c,u)=>Xn.define({name:u>=this.minRepeatTerm?void 0:c,id:u,props:r[u],top:i.indexOf(u)>-1,error:u==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(u)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=iq;let o=td(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let c=0;c<this.specializerSpecs.length;c++)this.specialized[c]=this.specializerSpecs[c].term;this.specializers=this.specializerSpecs.map(k4),this.states=td(e.states,Uint32Array),this.data=td(e.stateData),this.goto=td(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(c=>typeof c=="number"?new cl(o,c):c),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,n,i){let r=new coe(this,e,n,i);for(let s of this.wrappers)r=s(r,e,n,i);return r}getGoto(e,n,i=!1){let r=this.goto;if(n>=r[0])return-1;for(let s=r[n+1];;){let o=r[s++],c=o&1,u=r[s++];if(c&&i)return u;for(let h=s+(o>>1);s<h;s++)if(r[s]==e)return u;if(c)return-1}}hasAction(e,n){let i=this.data;for(let r=0;r<2;r++)for(let s=this.stateSlot(e,r?2:1),o;;s+=3){if((o=i[s])==65535)if(i[s+1]==1)o=i[s=Vr(i,s+2)];else{if(i[s+1]==2)return Vr(i,s+2);break}if(o==n||o==0)return Vr(i,s+1)}return 0}stateSlot(e,n){return this.states[e*6+n]}stateFlag(e,n){return(this.stateSlot(e,0)&n)>0}validAction(e,n){return!!this.allActions(e,i=>i==n?!0:null)}allActions(e,n){let i=this.stateSlot(e,4),r=i?n(i):void 0;for(let s=this.stateSlot(e,1);r==null;s+=3){if(this.data[s]==65535)if(this.data[s+1]==1)s=Vr(this.data,s+2);else break;r=n(Vr(this.data,s+1))}return r}nextStates(e){let n=[];for(let i=this.stateSlot(e,1);;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=Vr(this.data,i+2);else break;if((this.data[i+2]&1)==0){let r=this.data[i+1];n.some((s,o)=>o&1&&s==r)||n.push(this.data[i],r)}}return n}configure(e){let n=Object.assign(Object.create(lp.prototype),this);if(e.props&&(n.nodeSet=this.nodeSet.extend(...e.props)),e.top){let i=this.topRules[e.top];if(!i)throw new RangeError(`Invalid top rule name ${e.top}`);n.top=i}return e.tokenizers&&(n.tokenizers=this.tokenizers.map(i=>{let r=e.tokenizers.find(s=>s.from==i);return r?r.to:i})),e.specializers&&(n.specializers=this.specializers.slice(),n.specializerSpecs=this.specializerSpecs.map((i,r)=>{let s=e.specializers.find(c=>c.from==i.external);if(!s)return i;let o=Object.assign(Object.assign({},i),{external:s.to});return n.specializers[r]=k4(o),o})),e.contextTracker&&(n.context=e.contextTracker),e.dialect&&(n.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(n.strict=e.strict),e.wrap&&(n.wrappers=n.wrappers.concat(e.wrap)),e.bufferLength!=null&&(n.bufferLength=e.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 n=this.dynamicPrecedences;return n==null?0:n[e]||0}parseDialect(e){let n=Object.keys(this.dialects),i=n.map(()=>!1);if(e)for(let s of e.split(" ")){let o=n.indexOf(s);o>=0&&(i[o]=!0)}let r=null;for(let s=0;s<n.length;s++)if(!i[s])for(let o=this.dialects[n[s]],c;(c=this.data[o++])!=65535;)(r||(r=new Uint8Array(this.maxTerm+1)))[c]=1;return new uoe(e,i,r)}static deserialize(e){return new lp(e)}}function Vr(t,e){return t[e]|t[e+1]<<16}function hoe(t){let e=null;for(let n of t){let i=n.p.stoppedAt;(n.pos==n.p.stream.end||i!=null&&n.pos>i)&&n.p.parser.stateFlag(n.state,2)&&(!e||e.score<n.score)&&(e=n)}return e}function k4(t){if(t.external){let e=t.extend?1:0;return(n,i)=>t.external(n,i)<<1|e}return t.get}const Uo=63,A4=64,doe=1,poe=2,Mj=3,moe=4,Rj=5,goe=6,yoe=7,Nj=65,voe=66,boe=8,xoe=9,woe=10,Soe=11,Coe=12,Dj=13,koe=19,Aoe=20,_oe=29,Ooe=33,Eoe=34,Toe=47,Moe=0,HC=1,i2=2,Tu=3,r2=4;class Ta{constructor(e,n,i){this.parent=e,this.depth=n,this.type=i,this.hash=(e?e.hash+e.hash<<8:0)+n+(n<<4)+i}}Ta.top=new Ta(null,-1,Moe);function eu(t,e){for(let n=0,i=e-t.pos-1;;i--,n++){let r=t.peek(i);if(es(r)||r==-1)return n}}function s2(t){return t==32||t==9}function es(t){return t==10||t==13}function Lj(t){return s2(t)||es(t)}function za(t){return t<0||Lj(t)}const Roe=new foe({start:Ta.top,reduce(t,e){return t.type==Tu&&(e==Aoe||e==Eoe)?t.parent:t},shift(t,e,n,i){if(e==Mj)return new Ta(t,eu(i,i.pos),HC);if(e==Nj||e==Rj)return new Ta(t,eu(i,i.pos),i2);if(e==Uo)return t.parent;if(e==koe||e==Ooe)return new Ta(t,0,Tu);if(e==Dj&&t.type==r2)return t.parent;if(e==Toe){let r=/[1-9]/.exec(i.read(i.pos,n.pos));if(r)return new Ta(t,t.depth+ +r[0],r2)}return t},hash(t){return t.hash}});function xl(t,e,n=0){return t.peek(n)==e&&t.peek(n+1)==e&&t.peek(n+2)==e&&za(t.peek(n+3))}const Noe=new Kp((t,e)=>{if(t.next==-1&&e.canShift(A4))return t.acceptToken(A4);let n=t.peek(-1);if((es(n)||n<0)&&e.context.type!=Tu){if(xl(t,45))if(e.canShift(Uo))t.acceptToken(Uo);else return t.acceptToken(doe,3);if(xl(t,46))if(e.canShift(Uo))t.acceptToken(Uo);else return t.acceptToken(poe,3);let i=0;for(;t.next==32;)i++,t.advance();(i<e.context.depth||i==e.context.depth&&e.context.type==HC&&(t.next!=45||!za(t.peek(1))))&&t.next!=-1&&!es(t.next)&&t.next!=35&&t.acceptToken(Uo,-i)}},{contextual:!0}),Doe=new Kp((t,e)=>{if(e.context.type==Tu){t.next==63&&(t.advance(),za(t.next)&&t.acceptToken(yoe));return}if(t.next==45)t.advance(),za(t.next)&&t.acceptToken(e.context.type==HC&&e.context.depth==eu(t,t.pos-1)?moe:Mj);else if(t.next==63)t.advance(),za(t.next)&&t.acceptToken(e.context.type==i2&&e.context.depth==eu(t,t.pos-1)?goe:Rj);else{let n=t.pos;for(;;)if(s2(t.next)){if(t.pos==n)return;t.advance()}else if(t.next==33)zj(t);else if(t.next==38)a2(t);else if(t.next==42){a2(t);break}else if(t.next==39||t.next==34){if(UC(t,!0))break;return}else if(t.next==91||t.next==123){if(!zoe(t))return;break}else{Bj(t,!0,!1,0);break}for(;s2(t.next);)t.advance();if(t.next==58){if(t.pos==n&&e.canShift(_oe))return;let i=t.peek(1);za(i)&&t.acceptTokenTo(e.context.type==i2&&e.context.depth==eu(t,n)?voe:Nj,n)}}},{contextual:!0});function Loe(t){return t>32&&t<127&&t!=34&&t!=37&&t!=44&&t!=60&&t!=62&&t!=92&&t!=94&&t!=96&&t!=123&&t!=124&&t!=125}function _4(t){return t>=48&&t<=57||t>=97&&t<=102||t>=65&&t<=70}function O4(t,e){return t.next==37?(t.advance(),_4(t.next)&&t.advance(),_4(t.next)&&t.advance(),!0):Loe(t.next)||e&&t.next==44?(t.advance(),!0):!1}function zj(t){if(t.advance(),t.next==60){for(t.advance();;)if(!O4(t,!0)){t.next==62&&t.advance();break}}else for(;O4(t,!1););}function a2(t){for(t.advance();!za(t.next)&&cp(t.next)!="f";)t.advance()}function UC(t,e){let n=t.next,i=!1,r=t.pos;for(t.advance();;){let s=t.next;if(s<0)break;if(t.advance(),s==n)if(s==39)if(t.next==39)t.advance();else break;else break;else if(s==92&&n==34)t.next>=0&&t.advance();else if(es(s)){if(e)return!1;i=!0}else if(e&&t.pos>=r+1024)return!1}return!i}function zoe(t){for(let e=[],n=t.pos+1024;;)if(t.next==91||t.next==123)e.push(t.next),t.advance();else if(t.next==39||t.next==34){if(!UC(t,!0))return!1}else if(t.next==93||t.next==125){if(e[e.length-1]!=t.next-2)return!1;if(e.pop(),t.advance(),!e.length)return!0}else{if(t.next<0||t.pos>n||es(t.next))return!1;t.advance()}}const Boe="iiisiiissisfissssssssssssisssiiissssssssssssssssssssssssssfsfssissssssssssssssssssssssssssfif";function cp(t){return t<33?"u":t>125?"s":Boe[t-33]}function Dw(t,e){let n=cp(t);return n!="u"&&!(e&&n=="f")}function Bj(t,e,n,i){if(cp(t.next)=="s"||(t.next==63||t.next==58||t.next==45)&&Dw(t.peek(1),n))t.advance();else return!1;let r=t.pos;for(;;){let s=t.next,o=0,c=i+1;for(;Lj(s);){if(es(s)){if(e)return!1;c=0}else c++;s=t.peek(++o)}if(!(s>=0&&(s==58?Dw(t.peek(o+1),n):s==35?t.peek(o-1)!=32:Dw(s,n)))||!n&&c<=i||c==0&&!n&&(xl(t,45,o)||xl(t,46,o)))break;if(e&&cp(s)=="f")return!1;for(let h=o;h>=0;h--)t.advance();if(e&&t.pos>r+1024)return!1}return!0}const qoe=new Kp((t,e)=>{if(t.next==33)zj(t),t.acceptToken(Coe);else if(t.next==38||t.next==42){let n=t.next==38?woe:Soe;a2(t),t.acceptToken(n)}else t.next==39||t.next==34?(UC(t,!1),t.acceptToken(xoe)):Bj(t,!1,e.context.type==Tu,e.context.depth)&&t.acceptToken(boe)}),joe=new Kp((t,e)=>{let n=e.context.type==r2?e.context.depth:-1,i=t.pos;e:for(;;){let r=0,s=t.next;for(;s==32;)s=t.peek(++r);if(!r&&(xl(t,45,r)||xl(t,46,r))||!es(s)&&(n<0&&(n=Math.max(e.context.depth+1,r)),r<n))break;for(;;){if(t.next<0)break e;let o=es(t.next);if(t.advance(),o)continue e;i=t.pos}}t.acceptTokenTo(Dj,i)}),Ioe=lq({DirectiveName:le.keyword,DirectiveContent:le.attributeValue,"DirectiveEnd DocEnd":le.meta,QuotedLiteral:le.string,BlockLiteralHeader:le.special(le.string),BlockLiteralContent:le.content,Literal:le.content,"Key/Literal Key/QuotedLiteral":le.definition(le.propertyName),"Anchor Alias":le.labelName,Tag:le.typeName,Comment:le.lineComment,": , -":le.separator,"?":le.punctuation,"[ ]":le.squareBracket,"{ }":le.brace}),Poe=lp.deserialize({version:14,states:"5lQ!ZQgOOO#PQfO'#CpO#uQfO'#DOOOQR'#Dv'#DvO$qQgO'#DRO%gQdO'#DUO%nQgO'#DUO&ROaO'#D[OOQR'#Du'#DuO&{QgO'#D^O'rQgO'#D`OOQR'#Dt'#DtO(iOqO'#DbOOQP'#Dj'#DjO(zQaO'#CmO)YQgO'#CmOOQP'#Cm'#CmQ)jQaOOQ)uQgOOQ]QgOOO*PQdO'#CrO*nQdO'#CtOOQO'#Dw'#DwO+]Q`O'#CxO+hQdO'#CwO+rQ`O'#CwOOQO'#Cv'#CvO+wQdO'#CvOOQO'#Cq'#CqO,UQ`O,59[O,^QfO,59[OOQR,59[,59[OOQO'#Cx'#CxO,eQ`O'#DPO,pQdO'#DPOOQO'#Dx'#DxO,zQdO'#DxO-XQ`O,59jO-aQfO,59jOOQR,59j,59jOOQR'#DS'#DSO-hQcO,59mO-sQgO'#DVO.TQ`O'#DVO.YQcO,59pOOQR'#DX'#DXO#|QfO'#DWO.hQcO'#DWOOQR,59v,59vO.yOWO,59vO/OOaO,59vO/WOaO,59vO/cQgO'#D_OOQR,59x,59xO0VQgO'#DaOOQR,59z,59zOOQP,59|,59|O0yOaO,59|O1ROaO,59|O1aOqO,59|OOQP-E7h-E7hO1oQgO,59XOOQP,59X,59XO2PQaO'#DeO2_QgO'#DeO2oQgO'#DkOOQP'#Dk'#DkQ)jQaOOO3PQdO'#CsOOQO,59^,59^O3kQdO'#CuOOQO,59`,59`OOQO,59c,59cO4VQdO,59cO4aQdO'#CzO4kQ`O'#CzOOQO,59b,59bOOQU,5:Q,5:QOOQR1G.v1G.vO4pQ`O1G.vOOQU-E7d-E7dO4xQdO,59kOOQO,59k,59kO5SQdO'#DQO5^Q`O'#DQOOQO,5:d,5:dOOQU,5:R,5:ROOQR1G/U1G/UO5cQ`O1G/UOOQU-E7e-E7eO5kQgO'#DhO5xQcO1G/XOOQR1G/X1G/XOOQR,59q,59qO6TQgO,59qO6eQdO'#DiO6lQgO'#DiO7PQcO1G/[OOQR1G/[1G/[OOQR,59r,59rO#|QfO,59rOOQR1G/b1G/bO7_OWO1G/bO7dOaO1G/bOOQR,59y,59yOOQR,59{,59{OOQP1G/h1G/hO7lOaO1G/hO7tOaO1G/hO8POaO1G/hOOQP1G.s1G.sO8_QgO,5:POOQP,5:P,5:POOQP,5:V,5:VOOQP-E7i-E7iOOQO,59_,59_OOQO,59a,59aOOQO1G.}1G.}OOQO,59f,59fO8oQdO,59fOOQR7+$b7+$bP,XQ`O'#DfOOQO1G/V1G/VOOQO,59l,59lO8yQdO,59lOOQR7+$p7+$pP9TQ`O'#DgOOQR'#DT'#DTOOQR,5:S,5:SOOQR-E7f-E7fOOQR7+$s7+$sOOQR1G/]1G/]O9YQgO'#DYO9jQ`O'#DYOOQR,5:T,5:TO#|QfO'#DZO9oQcO'#DZOOQR-E7g-E7gOOQR7+$v7+$vOOQR1G/^1G/^OOQR7+$|7+$|O:QOWO7+$|OOQP7+%S7+%SO:VOaO7+%SO:_OaO7+%SOOQP1G/k1G/kOOQO1G/Q1G/QOOQO1G/W1G/WOOQR,59t,59tO:jQgO,59tOOQR,59u,59uO#|QfO,59uOOQR<<Hh<<HhOOQP<<Hn<<HnO:zOaO<<HnOOQR1G/`1G/`OOQR1G/a1G/aOOQPAN>YAN>Y",stateData:";S~O!fOS!gOS^OS~OP_OQbORSOTUOWROXROYYOZZO[XOcPOqQO!PVO!V[O!cTO~O`cO~P]OVkOWROXROYeOZfO[dOcPOmhOqQO~OboO~P!bOVtOWROXROYeOZfO[dOcPOmrOqQO~OpwO~P#WORSOTUOWROXROYYOZZO[XOcPOqQO!PVO!cTO~OSvP!avP!bvP~P#|OWROXROYeOZfO[dOcPOqQO~OmzO~P%OOm!OOUzP!azP!bzP!dzP~P#|O^!SO!b!QO!f!TO!g!RO~ORSOTUOWROXROcPOqQO!PVO!cTO~OY!UOP!QXQ!QX!V!QX!`!QXS!QX!a!QX!b!QXU!QXm!QX!d!QX~P&aO[!WOP!SXQ!SX!V!SX!`!SXS!SX!a!SX!b!SXU!SXm!SX!d!SX~P&aO^!ZO!W![O!b!YO!f!]O!g!YO~OP!_O!V[OQaX!`aX~OPaXQaX!VaX!`aX~P#|OP!bOQ!cO!V[O~OP_O!V[O~P#|OWROXROY!fOcPOqQObfXmfXofXpfX~OWROXRO[!hOcPOqQObhXmhXohXphX~ObeXmlXoeX~ObkXokX~P%OOm!kO~Om!lObnPonP~P%OOb!pOo!oO~Ob!pO~P!bOm!sOosXpsX~OosXpsX~P%OOm!uOotPptP~P%OOo!xOp!yO~Op!yO~P#WOS!|O!a#OO!b#OO~OUyX!ayX!byX!dyX~P#|Om#QO~OU#SO!a#UO!b#UO!d#RO~Om#WOUzX!azX!bzX!dzX~O]#XO~O!b#XO!g#YO~O^#ZO!b#XO!g#YO~OP!RXQ!RX!V!RX!`!RXS!RX!a!RX!b!RXU!RXm!RX!d!RX~P&aOP!TXQ!TX!V!TX!`!TXS!TX!a!TX!b!TXU!TXm!TX!d!TX~P&aO!b#^O!g#^O~O^#_O!b#^O!f#`O!g#^O~O^#_O!W#aO!b#^O!g#^O~OPaaQaa!Vaa!`aa~P#|OP#cO!V[OQ!XX!`!XX~OP!XXQ!XX!V!XX!`!XX~P#|OP_O!V[OQ!_X!`!_X~P#|OWROXROcPOqQObgXmgXogXpgX~OWROXROcPOqQObiXmiXoiXpiX~Obkaoka~P%OObnXonX~P%OOm#kO~Ob#lOo!oO~Oosapsa~P%OOotXptX~P%OOm#pO~Oo!xOp#qO~OSwP!awP!bwP~P#|OS!|O!a#vO!b#vO~OUya!aya!bya!dya~P#|Om#xO~P%OOm#{OU}P!a}P!b}P!d}P~P#|OU#SO!a$OO!b$OO!d#RO~O]$QO~O!b$QO!g$RO~O!b$SO!g$SO~O^$TO!b$SO!g$SO~O^$TO!b$SO!f$UO!g$SO~OP!XaQ!Xa!V!Xa!`!Xa~P#|Obnaona~P%OOotapta~P%OOo!xO~OU|X!a|X!b|X!d|X~P#|Om$ZO~Om$]OU}X!a}X!b}X!d}X~O]$^O~O!b$_O!g$_O~O^$`O!b$_O!g$_O~OU|a!a|a!b|a!d|a~P#|O!b$cO!g$cO~O",goto:",]!mPPPPPPPPPPPPPPPPP!nPP!v#v#|$`#|$c$f$j$nP%VPPP!v%Y%^%a%{&O%a&R&U&X&_&b%aP&e&{&e'O'RPP']'a'g'm's'y(XPPPPPPPP(_)e*X+c,VUaObcR#e!c!{ROPQSTUXY_bcdehknrtvz!O!U!W!_!b!c!f!h!k!l!s!u!|#Q#R#S#W#c#k#p#x#{$Z$]QmPR!qnqfPQThknrtv!k!l!s!u#R#k#pR!gdR!ieTlPnTjPnSiPnSqQvQ{TQ!mkQ!trQ!vtR#y#RR!nkTsQvR!wt!RWOSUXY_bcz!O!U!W!_!b!c!|#Q#S#W#c#x#{$Z$]RySR#t!|R|TR|UQ!PUR#|#SR#z#RR#z#SyZOSU_bcz!O!_!b!c!|#Q#S#W#c#x#{$Z$]R!VXR!XYa]O^abc!a!c!eT!da!eQnPR!rnQvQR!{vQ!}yR#u!}Q#T|R#}#TW^Obc!cS!^^!aT!aa!eQ!eaR#f!eW`Obc!cQxSS}U#SQ!`_Q#PzQ#V!OQ#b!_Q#d!bQ#s!|Q#w#QQ$P#WQ$V#cQ$Y#xQ$[#{Q$a$ZR$b$]xZOSU_bcz!O!_!b!c!|#Q#S#W#c#x#{$Z$]Q!VXQ!XYQ#[!UR#]!W!QWOSUXY_bcz!O!U!W!_!b!c!|#Q#S#W#c#x#{$Z$]pfPQThknrtv!k!l!s!u#R#k#pQ!gdQ!ieQ#g!fR#h!hSgPn^pQTkrtv#RQ!jhQ#i!kQ#j!lQ#n!sQ#o!uQ$W#kR$X#pQuQR!zv",nodeNames:"⚠ DirectiveEnd DocEnd - - ? ? ? Literal QuotedLiteral Anchor Alias Tag BlockLiteralContent Comment Stream BOM Document ] [ FlowSequence Item Tagged Anchored Anchored Tagged FlowMapping Pair Key : Pair , } { FlowMapping Pair Pair BlockSequence Item Item BlockMapping Pair Pair Key Pair Pair BlockLiteral BlockLiteralHeader Tagged Anchored Anchored Tagged Directive DirectiveName DirectiveContent Document",maxTerm:74,context:Roe,nodeProps:[["isolate",-3,8,9,14,""],["openedBy",18,"[",32,"{"],["closedBy",19,"]",33,"}"]],propSources:[Ioe],skippedNodes:[0],repeatNodeCount:6,tokenData:"-Y~RnOX#PXY$QYZ$]Z]#P]^$]^p#Ppq$Qqs#Pst$btu#Puv$yv|#P|}&e}![#P![!]'O!]!`#P!`!a'i!a!}#P!}#O*g#O#P#P#P#Q+Q#Q#o#P#o#p+k#p#q'i#q#r,U#r;'S#P;'S;=`#z<%l?HT#P?HT?HU,o?HUO#PQ#UU!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PQ#kTOY#PZs#Pt;'S#P;'S;=`#z<%lO#PQ#}P;=`<%l#P~$VQ!f~XY$Qpq$Q~$bO!g~~$gS^~OY$bZ;'S$b;'S;=`$s<%lO$b~$vP;=`<%l$bR%OX!WQOX%kXY#PZ]%k]^#P^p%kpq#hq;'S%k;'S;=`&_<%lO%kR%rX!WQ!VPOX%kXY#PZ]%k]^#P^p%kpq#hq;'S%k;'S;=`&_<%lO%kR&bP;=`<%l%kR&lUoP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR'VUmP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR'p[!PP!WQOY#PZp#Ppq#hq{#P{|(f|}#P}!O(f!O!R#P!R![)p![;'S#P;'S;=`#z<%lO#PR(mW!PP!WQOY#PZp#Ppq#hq!R#P!R![)V![;'S#P;'S;=`#z<%lO#PR)^U!PP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR)wY!PP!WQOY#PZp#Ppq#hq{#P{|)V|}#P}!O)V!O;'S#P;'S;=`#z<%lO#PR*nUcP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR+XUbP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR+rUqP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR,]UpP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR,vU`P!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#P",tokenizers:[Noe,Doe,qoe,joe,0,1],topRules:{Stream:[0,15]},tokenPrec:0}),Hoe=Gd.define({name:"yaml",parser:Poe.configure({props:[hq.add({Stream:t=>{for(let e=t.node.resolve(t.pos,-1);e&&e.to>=t.pos;e=e.parent){if(e.name=="BlockLiteralContent"&&e.from<e.to)return t.baseIndentFor(e);if(e.name=="BlockLiteral")return t.baseIndentFor(e)+t.unit;if(e.name=="BlockSequence"||e.name=="BlockMapping")return t.column(e.from,1);if(e.name=="QuotedLiteral")return null;if(e.name=="Literal"){let n=t.column(e.from,1);if(n==t.lineIndent(e.from,1))return n;if(e.to>t.pos)return null}}return null},FlowMapping:L5({closing:"}"}),FlowSequence:L5({closing:"]"})}),mq.add({"FlowMapping FlowSequence":xie,"Item Pair BlockLiteral":(t,e)=>({from:e.doc.lineAt(t.from).to,to:t.to})})]}),languageData:{commentTokens:{line:"#"},indentOnInput:/^\s*[\]\}]$/}});function Uoe(){return new cie(Hoe)}const Voe=()=>{const{error:t,isCliMode:e,yamlInput:n,setYamlInput:i,parseAndSetSchema:r,isAutoSaveEnabled:s,setIsAutoSaveEnabled:o,savingStatus:c,saveSchema:u,lastUpdateSource:h,theme:d}=ci(),[m,g]=j.useState(n),y=j.useRef(null),x=j.useRef(null),w=j.useRef(!0);j.useEffect(()=>{if(!x.current?.view)return;const E=x.current.view,T=E.state.doc.toString();if(w.current&&n){E.dispatch({changes:{from:0,to:T.length,insert:n},annotations:Qt.addToHistory.of(!1)}),g(n),w.current=!1;return}h==="visual"&&T!==n&&(E.dispatch({changes:{from:0,to:T.length,insert:n},userEvent:"visual-edit"}),g(n))},[n,h]);const S=j.useCallback(E=>{g(E),!(!E||E.trim()==="")&&(y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{i(E),r(E)},300))},[i,r]),C=async()=>{r(m),e&&await u(!0)},A=()=>{x.current?.view&&MC(x.current.view)},O=()=>{x.current?.view&&Kd(x.current.view)};return k.jsxs("div",{className:"flex-1 flex flex-col gap-3 overflow-hidden p-4 pt-2 h-full",children:[k.jsxs("div",{className:"flex items-center justify-between px-1",children:[e?k.jsxs("div",{className:"flex items-center gap-4",children:[k.jsxs("label",{className:"flex items-center gap-2 cursor-pointer group",children:[k.jsx("div",{className:`relative w-7 h-4 rounded-full transition-colors ${s?"bg-blue-600":"bg-slate-300 dark:bg-slate-700"}`,onClick:()=>o(!s),children:k.jsx("div",{className:`absolute top-0.5 left-0.5 w-3 h-3 bg-white rounded-full transition-transform ${s?"translate-x-3":"translate-x-0"}`})}),k.jsx("span",{className:`text-[10px] font-bold uppercase tracking-widest ${d==="dark"?"text-slate-500 group-hover:text-slate-400":"text-slate-400 group-hover:text-slate-600"}`,children:"Auto-save"})]}),k.jsxs("div",{className:"flex items-center gap-1.5 min-w-[60px]",children:[c==="saving"&&k.jsxs("div",{className:"flex items-center gap-1 text-slate-400 animate-pulse",children:[k.jsx(xK,{size:10,className:"animate-spin"}),k.jsx("span",{className:"text-[9px] font-bold uppercase",children:"Saving"})]}),c==="saved"&&k.jsxs("div",{className:"flex items-center gap-1 text-emerald-500",children:[k.jsx(nK,{size:10}),k.jsx("span",{className:"text-[9px] font-bold uppercase tracking-wider",children:"Saved"})]}),c==="error"&&k.jsxs("div",{className:"flex items-center gap-1 text-red-500",children:[k.jsx(K1,{size:10}),k.jsx("span",{className:"text-[9px] font-bold uppercase",children:"Error"})]})]})]}):k.jsxs("div",{className:"flex items-center gap-2 px-2 py-1 bg-blue-500/10 border border-blue-500/30 rounded-md",children:[k.jsx(K1,{size:12,className:"text-blue-400"}),k.jsx("span",{className:"text-[10px] text-blue-300 font-medium uppercase tracking-tight",children:"Sandbox Mode"})]}),k.jsxs("div",{className:"flex items-center gap-3",children:[k.jsxs("div",{className:`flex rounded-lg p-0.5 border ${d==="dark"?"bg-slate-800/50 border-slate-700/50":"bg-slate-100 border-slate-200"}`,children:[k.jsx("button",{onClick:A,className:`p-1.5 rounded-md transition-all active:scale-95 ${d==="dark"?"text-slate-400 hover:bg-slate-700 hover:text-slate-100":"text-slate-500 hover:bg-white hover:text-blue-600 hover:shadow-sm"}`,title:"Undo (Ctrl+Z)",children:k.jsx(Y8,{size:14})}),k.jsx("div",{className:`w-px h-4 self-center mx-0.5 ${d==="dark"?"bg-slate-700/50":"bg-slate-200"}`}),k.jsx("button",{onClick:O,className:`p-1.5 rounded-md transition-all active:scale-95 ${d==="dark"?"text-slate-400 hover:bg-slate-700 hover:text-slate-100":"text-slate-500 hover:bg-white hover:text-blue-600 hover:shadow-sm"}`,title:"Redo (Ctrl+Y)",children:k.jsx($8,{size:14})})]}),k.jsxs("div",{className:"flex items-center gap-1 text-slate-400 dark:text-slate-600 cursor-help",title:"Pro Tip: Use Ctrl+Z to undo visual changes!",children:[k.jsx(mK,{size:12}),k.jsx("span",{className:"text-[9px] font-bold uppercase tracking-tighter",children:"Undo Active"})]})]})]}),k.jsxs("div",{className:`relative flex-1 flex flex-col min-h-0 border rounded-md overflow-hidden transition-colors ${d==="dark"?"border-slate-700 bg-[#282c34]":"border-slate-200 bg-white"}`,children:[k.jsx(Tj,{ref:x,value:m,height:"100%",theme:d==="dark"?Ej:"light",extensions:[Uoe()],onChange:S,basicSetup:{lineNumbers:!0,foldGutter:!0,highlightActiveLine:!0},className:"flex-1 text-sm overflow-auto"}),t&&m===n&&k.jsxs("div",{className:"absolute bottom-4 left-4 right-4 p-3 bg-red-900/90 border border-red-500/50 rounded-md text-red-100 text-xs flex gap-2 items-start z-10 shadow-2xl backdrop-blur-sm animate-in fade-in slide-in-from-bottom-2",children:[k.jsx(K1,{size:14,className:"shrink-0 mt-0.5 text-red-400"}),k.jsx("span",{children:t})]})]}),k.jsxs("div",{className:"flex justify-between items-center pt-1 shrink-0",children:[k.jsx("div",{className:"text-[10px] text-slate-500 italic",children:e?s?"Changes save automatically":"Click save to update file":"Changes reset on reload"}),k.jsxs("button",{onClick:C,disabled:c==="saving",className:`flex items-center gap-2 px-4 py-2 rounded-md font-medium text-sm transition-all shadow-lg shrink-0 ${e?s?"bg-slate-300 dark:bg-slate-700 text-slate-500 dark:text-slate-400 cursor-not-allowed opacity-50":"bg-blue-600 hover:bg-blue-700 text-white":"bg-emerald-600 hover:bg-emerald-700 text-white"}`,children:[e?k.jsx(UK,{size:16}):k.jsx(BK,{size:16}),e?"Save & Update":"Apply Changes"]})]})]})},Foe=()=>{const{schema:t,setSelectedTableId:e,setFocusNodeId:n,theme:i}=ci(),[r,s]=j.useState(""),[o,c]=j.useState(new Set),u=m=>{const g=new Set(o);g.has(m)?g.delete(m):g.add(m),c(g)},h=m=>{e(m),n(m)},d=j.useMemo(()=>{if(!t)return{domains:[],unassigned:[]};const m={},g=new Set;t.domains?.forEach(w=>{m[w.id]=[]}),t.tables.forEach(w=>{const S=t.domains?.find(A=>A.tables.includes(w.id));(w.name.toLowerCase().includes(r.toLowerCase())||w.id.toLowerCase().includes(r.toLowerCase()))&&S&&(m[S.id].push(w),g.add(w.id))});const y=(t.domains||[]).filter(w=>{const S=m[w.id].length>0,C=w.name.toLowerCase().includes(r.toLowerCase())||w.id.toLowerCase().includes(r.toLowerCase());return S||C&&r!==""}).map(w=>({...w,tables:m[w.id]})),x=t.tables.filter(w=>(w.name.toLowerCase().includes(r.toLowerCase())||w.id.toLowerCase().includes(r.toLowerCase()))&&!g.has(w.id)&&!t.domains?.some(C=>C.tables.includes(w.id)));return{domains:y,unassigned:x}},[t,r]);return t?k.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden p-4 pt-2",children:[k.jsxs("div",{className:"relative mb-4 shrink-0",children:[k.jsx(FK,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500"}),k.jsx("input",{type:"text",value:r,onChange:m=>s(m.target.value),placeholder:"Search entities...",className:`w-full pl-9 pr-4 py-2 rounded-md text-sm transition-all shadow-sm focus:outline-none focus:ring-1 focus:ring-blue-500/50 ${i==="dark"?"bg-slate-800 border-slate-700 text-slate-100":"bg-white border-slate-200 text-slate-900 shadow-slate-200/50"}`})]}),k.jsxs("div",{className:"flex-1 space-y-4 overflow-auto pr-1",children:[d.domains.map(m=>{const g=o.has(m.id);return k.jsxs("section",{className:"flex flex-col",children:[k.jsxs("div",{className:`flex items-center justify-between group px-1 py-1.5 cursor-pointer rounded transition-colors ${i==="dark"?"hover:bg-slate-800/30":"hover:bg-slate-100"}`,onClick:()=>u(m.id),children:[k.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[g?k.jsx(nS,{size:12,className:"text-slate-500"}):k.jsx(tS,{size:12,className:"text-slate-500"}),k.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:m.color||"#3b82f6"}}),k.jsx("h3",{className:`text-[10px] font-bold uppercase tracking-wider truncate ${i==="dark"?"text-slate-300":"text-slate-600"}`,children:m.name}),k.jsx("span",{className:`text-[9px] font-medium px-1.5 py-0.5 rounded-full ${i==="dark"?"text-slate-600 bg-slate-800/50":"text-slate-400 bg-slate-100"}`,children:m.tables.length})]}),k.jsx("button",{onClick:y=>{y.stopPropagation(),h(m.id)},className:"opacity-0 group-hover:opacity-100 p-1 hover:text-blue-500 text-slate-500 transition-all",title:"Focus on Domain",children:k.jsx(W1,{size:12})})]}),!g&&k.jsxs("div",{className:`ml-4 mt-1 space-y-0.5 border-l pl-2 ${i==="dark"?"border-slate-800":"border-slate-100"}`,children:[m.tables.map(y=>k.jsxs("button",{onClick:()=>h(y.id),className:`w-full flex items-center justify-between group p-1.5 text-xs rounded border border-transparent transition-all text-left ${i==="dark"?"hover:bg-slate-800/50 text-slate-400 hover:text-slate-200":"hover:bg-blue-50 text-slate-500 hover:text-blue-600"}`,children:[k.jsx("span",{className:"truncate",children:y.name}),k.jsx(W1,{size:10,className:"opacity-0 group-hover:opacity-100"})]},y.id)),m.tables.length===0&&k.jsx("div",{className:"p-2 text-[10px] text-slate-500 italic",children:"No tables in this domain"})]})]},m.id)}),d.unassigned.length>0&&k.jsxs("section",{className:"flex flex-col",children:[k.jsx("div",{className:`flex items-center justify-between group px-1 py-1.5 cursor-pointer rounded transition-colors ${i==="dark"?"hover:bg-slate-800/30":"hover:bg-slate-100"}`,onClick:()=>u("unassigned"),children:k.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[o.has("unassigned")?k.jsx(nS,{size:12,className:"text-slate-500"}):k.jsx(tS,{size:12,className:"text-slate-500"}),k.jsx(F8,{size:12,className:"text-slate-500 shrink-0"}),k.jsx("h3",{className:`text-[10px] font-bold uppercase tracking-wider truncate ${i==="dark"?"text-slate-500":"text-slate-400"}`,children:"Unassigned"}),k.jsx("span",{className:`text-[9px] font-medium px-1.5 py-0.5 rounded-full ${i==="dark"?"text-slate-600 bg-slate-800/50":"text-slate-400 bg-slate-100"}`,children:d.unassigned.length})]})}),!o.has("unassigned")&&k.jsx("div",{className:`ml-4 mt-1 space-y-0.5 border-l pl-2 ${i==="dark"?"border-slate-800":"border-slate-100"}`,children:d.unassigned.map(m=>k.jsxs("button",{onClick:()=>h(m.id),className:`w-full flex items-center justify-between group p-1.5 text-xs rounded border border-transparent transition-all text-left ${i==="dark"?"hover:bg-slate-800/50 text-slate-400 hover:text-slate-200":"hover:bg-blue-50 text-slate-500 hover:text-blue-600"}`,children:[k.jsx("span",{className:"truncate",children:m.name}),k.jsx(W1,{size:10,className:"opacity-0 group-hover:opacity-100"})]},m.id))})]}),d.domains.length===0&&d.unassigned.length===0&&k.jsx("div",{className:"text-center py-10",children:k.jsxs("p",{className:"text-sm text-slate-500 italic",children:['No entities found for "',r,'"']})})]})]}):null},$oe=()=>{const{isSidebarOpen:t,setIsSidebarOpen:e,theme:n}=ci();return k.jsx("button",{onClick:()=>e(!t),className:`absolute -right-3.5 top-1/2 -translate-y-1/2 z-[60] flex h-7 w-7 items-center justify-center rounded-full border transition-all shadow-xl ${n==="dark"?"border-slate-700 bg-slate-900 text-slate-400 hover:text-white hover:bg-slate-800":"border-slate-200 bg-white text-slate-500 hover:text-blue-600 hover:bg-slate-50 shadow-slate-200/50"}`,"aria-label":t?"Collapse sidebar":"Expand sidebar",children:t?k.jsx(ZW,{size:16}):k.jsx(nS,{size:16})})},Goe=()=>{const{availableFiles:t,currentModelSlug:e,setCurrentModel:n,isSidebarOpen:i,fetchAvailableFiles:r,theme:s}=ci(),[o,c]=j.useState(!1);if(!i||t.length<=0)return null;const u=async()=>{c(!0),await r(),setTimeout(()=>c(!1),500)},h=e||t[0]?.slug;return k.jsxs("div",{className:"px-4 mb-4",children:[k.jsxs("div",{className:"flex items-center justify-between mb-1.5 px-1",children:[k.jsx("div",{className:"text-[10px] font-bold uppercase tracking-wider text-slate-500",children:"Current Model"}),k.jsx("button",{onClick:u,className:`transition-all p-0.5 rounded ${o?"animate-spin text-blue-400":"text-slate-500 hover:text-blue-400"} ${s==="dark"?"hover:bg-slate-800":"hover:bg-slate-100"}`,title:"Refresh model list",children:k.jsx(PK,{size:12})})]}),k.jsxs("div",{className:"relative group",children:[k.jsx("select",{value:h,onChange:d=>n(d.target.value),className:`w-full pl-9 pr-8 py-2 rounded-md text-sm appearance-none focus:outline-none focus:ring-1 focus:ring-blue-500/50 transition-all shadow-sm cursor-pointer ${s==="dark"?"bg-slate-800 border-slate-700 text-slate-100 hover:bg-slate-750":"bg-white border-slate-200 text-slate-900 hover:bg-slate-50 shadow-slate-200/50"}`,children:t.map(d=>k.jsx("option",{value:d.slug,className:s==="light"?"bg-white text-slate-900":"bg-slate-800 text-slate-100",children:d.name},d.slug))}),k.jsx(Go,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-blue-500 pointer-events-none"}),k.jsx(tS,{size:14,className:`absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none transition-colors ${s==="dark"?"text-slate-500 group-hover:text-slate-300":"text-slate-400 group-hover:text-slate-600"}`})]})]})},Yoe=""+new URL("../favicon.svg",import.meta.url).href,Qoe=()=>{const{isSidebarOpen:t,activeTab:e,setActiveTab:n,isCliMode:i,theme:r,toggleTheme:s}=ci();return k.jsxs("div",{className:`relative h-full flex flex-col border-r transition-all duration-300 ease-in-out shadow-2xl z-50 ${t?"w-[400px]":"w-[50px]"} ${r==="dark"?"bg-slate-900 border-slate-800":"bg-white border-slate-200"}`,children:[k.jsx($oe,{}),k.jsxs("div",{className:`p-4 border-b flex items-center justify-between ${!t&&"hidden"} ${r==="dark"?"border-slate-800":"border-slate-100"}`,children:[k.jsxs("div",{className:"flex items-center gap-2",children:[k.jsx("img",{src:Yoe,alt:"Modscape Logo",className:"w-5 h-5 rounded-md"}),k.jsx("h1",{className:`text-base font-bold tracking-tight ${r==="dark"?"text-white":"text-slate-900"}`,children:"Modscape"})]}),i&&k.jsx("span",{className:"px-1.5 py-0.5 bg-emerald-500/10 border border-emerald-500/30 text-emerald-500 text-[10px] font-bold rounded uppercase",children:"Live"})]}),k.jsx("div",{className:"mt-4",children:t&&k.jsx(Goe,{})}),k.jsxs(RJ,{value:e,onValueChange:o=>n(o),className:`flex-1 flex flex-col overflow-hidden ${!t&&"items-center py-4"}`,children:[k.jsx("div",{className:`px-4 pt-4 ${!t&&"px-0"}`,children:k.jsxs(NB,{className:`w-full p-1 border ${r==="dark"?"bg-slate-800/50 border-slate-700/50":"bg-slate-100 border-slate-200"} ${!t&&"flex-col h-auto w-10 gap-2 p-0 bg-transparent border-none"}`,children:[k.jsxs(oS,{value:"editor",className:`flex-1 gap-2 ${!t&&"w-9 h-9 p-0 rounded-md shadow-sm transition-all"} ${r==="dark"?"text-slate-400 data-[state=active]:bg-blue-600 data-[state=active]:text-white":"text-slate-500 data-[state=active]:bg-white data-[state=active]:text-blue-600 data-[state=active]:shadow-sm"}`,title:"Editor",children:[k.jsx(LK,{size:14}),t&&k.jsx("span",{children:"Editor"})]}),k.jsxs(oS,{value:"entities",className:`flex-1 gap-2 ${!t&&"w-9 h-9 p-0 rounded-md shadow-sm transition-all"} ${r==="dark"?"text-slate-400 data-[state=active]:bg-blue-600 data-[state=active]:text-white":"text-slate-500 data-[state=active]:bg-white data-[state=active]:text-blue-600 data-[state=active]:shadow-sm"}`,title:"Entities",children:[k.jsx(vK,{size:14}),t&&k.jsx("span",{children:"Entities"})]})]})}),t&&k.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[k.jsx(lS,{value:"editor",className:"flex-1 flex flex-col min-h-0 mt-0 data-[state=inactive]:hidden",children:k.jsx(Voe,{})}),k.jsx(lS,{value:"entities",className:"flex-1 flex flex-col min-h-0 mt-0 data-[state=inactive]:hidden",children:k.jsx(Foe,{})})]})]}),t&&k.jsxs("div",{className:`p-3 border-t flex items-center justify-between ${r==="dark"?"border-slate-800 bg-slate-950/20":"border-slate-100 bg-slate-50/50"}`,children:[k.jsx("p",{className:"text-[10px] text-slate-500 font-medium px-1",children:"Modscape v1.0.5"}),k.jsx("button",{onClick:s,className:`p-1.5 rounded-lg transition-all ${r==="dark"?"text-slate-400 hover:bg-slate-800 hover:text-yellow-400":"text-slate-500 hover:bg-slate-200 hover:text-blue-600"}`,title:`Switch to ${r==="dark"?"Light":"Dark"} Mode`,children:r==="dark"?k.jsx(GK,{size:14}):k.jsx(AK,{size:14})})]})]})},Xoe=()=>{const{addTable:t,addDomain:e,getSelectedTable:n,getSelectedDomain:i,getSelectedRelationship:r,removeNode:s,removeEdge:o,showER:c,showLineage:u,setShowER:h,setShowLineage:d,setSelectedTableId:m,setSelectedEdgeId:g,calculateAutoLayout:y,theme:x}=ci(),{screenToFlowPosition:w}=Du(),[S,C]=j.useState(!1),A=c&&u,O=()=>{if(A)return;const P=w({x:window.innerWidth/2,y:window.innerHeight/2});e(P.x-300,P.y-200)},E=()=>{if(A)return;const P=w({x:window.innerWidth/2,y:window.innerHeight/2});t(P.x-160,P.y-125)},T=n(),M=i(),R=r(),z=T||M||R,q=()=>{T?s(T.id):M?s(M.id):R&&o(R.relationship.from.table,R.relationship.to.table)},U=()=>{m(null),g(null)};return k.jsxs(k.Fragment,{children:[k.jsxs("div",{className:"absolute top-4 left-4 z-10 flex flex-col gap-2",children:[k.jsxs("div",{className:`flex flex-col border rounded-2xl shadow-2xl overflow-hidden w-14 transition-colors ${x==="dark"?"bg-slate-900/85 backdrop-blur-md border-slate-700":"bg-white/90 backdrop-blur-md border-slate-200"}`,children:[k.jsxs("div",{className:"flex flex-col items-center py-3 gap-2",children:[k.jsxs("div",{className:"flex flex-col items-center text-[8px] font-bold text-slate-500 uppercase tracking-tighter opacity-80",children:[k.jsx(lK,{size:12}),k.jsx("span",{children:"View"})]}),k.jsxs("div",{className:"flex flex-col gap-1 px-1.5 w-full",children:[k.jsx("button",{onClick:()=>h(!c),className:`flex items-center justify-center w-full aspect-square rounded-xl transition-all ${c?"bg-emerald-500/20 text-emerald-500 border border-emerald-500/30":x==="dark"?"text-slate-500 hover:text-slate-300 hover:bg-slate-800":"text-slate-400 hover:text-slate-600 hover:bg-slate-100"}`,title:c?"Hide ER Relationships":"Show ER Relationships (Disables editing if Lineage is also ON)",children:k.jsx(RK,{size:20})}),k.jsx("button",{onClick:()=>d(!u),className:`flex items-center justify-center w-full aspect-square rounded-xl transition-all ${u?"bg-blue-500/20 text-blue-500 border border-blue-500/30":x==="dark"?"text-slate-500 hover:text-slate-300 hover:bg-slate-800":"text-slate-400 hover:text-slate-600 hover:bg-slate-100"}`,title:u?"Hide Data Lineage":"Show Data Lineage (Disables editing if ER is also ON)",children:k.jsx(g3,{size:20})})]})]}),k.jsx("div",{className:`mx-2 border-t ${x==="dark"?"border-slate-800":"border-slate-100"}`}),k.jsxs("div",{className:"flex flex-col items-center py-3 gap-2",children:[k.jsxs("div",{className:"flex flex-col items-center text-[8px] font-bold text-slate-500 uppercase tracking-tighter opacity-80",children:[k.jsx(rS,{size:12}),k.jsx("span",{children:"Add"})]}),k.jsxs("div",{className:"flex flex-col gap-1 px-1.5 w-full",children:[k.jsxs("button",{onClick:O,className:`flex items-center justify-center w-full aspect-square rounded-xl transition-all group relative ${A?"opacity-40 cursor-not-allowed text-slate-500":x==="dark"?"text-slate-500 hover:text-blue-400 hover:bg-slate-800":"text-slate-400 hover:text-blue-600 hover:bg-slate-50"}`,title:A?"Addition locked while ER & Lineage are both active":"Add new Domain",children:[k.jsx(v3,{size:20}),A&&k.jsx(iS,{size:10,className:"absolute bottom-1 right-1 text-slate-500"})]}),k.jsxs("button",{onClick:E,className:`flex items-center justify-center w-full aspect-square rounded-xl transition-all group relative ${A?"opacity-40 cursor-not-allowed text-slate-500":x==="dark"?"text-slate-500 hover:text-emerald-400 hover:bg-slate-800":"text-slate-400 hover:text-emerald-600 hover:bg-slate-100"}`,title:A?"Addition locked while ER & Lineage are both active":"Add new Table",children:[k.jsx(fK,{size:20}),A&&k.jsx(iS,{size:10,className:"absolute bottom-1 right-1 text-slate-500"})]})]})]}),k.jsx("div",{className:`mx-2 border-t ${x==="dark"?"border-slate-800":"border-slate-100"}`}),k.jsxs("div",{className:"flex flex-col items-center py-3 gap-2",children:[k.jsxs("div",{className:"flex flex-col items-center text-[8px] font-bold text-slate-500 uppercase tracking-tighter opacity-80",children:[k.jsx(y3,{size:12}),k.jsx("span",{children:"Format"})]}),k.jsx("div",{className:"flex flex-col gap-1 px-1.5 w-full",children:k.jsx("button",{onClick:()=>y(),className:`flex items-center justify-center w-full aspect-square rounded-xl transition-all group ${x==="dark"?"text-slate-500 hover:text-blue-400 hover:bg-slate-800":"text-slate-400 hover:text-blue-600 hover:bg-slate-100"}`,title:"Auto-format Layout (Relation-driven flow)",children:k.jsx(y3,{size:20})})})]}),k.jsx("div",{className:`mx-2 border-t ${x==="dark"?"border-slate-800":"border-slate-100"}`}),k.jsx("div",{className:"flex flex-col items-center py-3",children:k.jsx("button",{onClick:()=>C(!S),className:`flex items-center justify-center w-10 h-10 rounded-xl transition-all ${S?x==="dark"?"bg-blue-600 text-white":"bg-blue-600 text-white shadow-md shadow-blue-500/20":x==="dark"?"text-slate-500 hover:bg-slate-800 hover:text-slate-300":"text-slate-400 hover:bg-slate-100 hover:text-slate-600"}`,title:"Keyboard Shortcuts & Help",children:k.jsx(F8,{size:20})})})]}),S&&k.jsxs("div",{className:`flex flex-col border rounded-2xl shadow-2xl p-5 w-64 animate-in zoom-in-95 fade-in duration-200 origin-top-left ${x==="dark"?"bg-slate-900/95 backdrop-blur-xl border-slate-700":"bg-white/95 backdrop-blur-xl border-slate-200"}`,children:[k.jsxs("div",{className:`flex items-center gap-2 mb-4 border-b pb-3 ${x==="dark"?"border-slate-800":"border-slate-100"}`,children:[k.jsx(sK,{size:16,className:"text-blue-500"}),k.jsx("h4",{className:`text-xs font-bold uppercase tracking-widest ${x==="dark"?"text-slate-200":"text-slate-800"}`,children:"Shortcuts"})]}),k.jsxs("div",{className:"space-y-4",children:[k.jsxs("div",{className:"flex items-center justify-between group",children:[k.jsxs("div",{className:"flex items-center gap-2 text-slate-500",children:[k.jsx(Y8,{size:14}),k.jsx("span",{className:"text-xs font-medium",children:"Undo"})]}),k.jsx("kbd",{className:`px-1.5 py-0.5 border rounded text-[10px] font-mono ${x==="dark"?"bg-slate-800 border-slate-700 text-slate-300":"bg-slate-50 border-slate-200 text-slate-600"}`,children:"Ctrl Z"})]}),k.jsxs("div",{className:"flex items-center justify-between group",children:[k.jsxs("div",{className:"flex items-center gap-2 text-slate-500",children:[k.jsx($8,{size:14}),k.jsx("span",{className:"text-xs font-medium",children:"Redo"})]}),k.jsx("kbd",{className:`px-1.5 py-0.5 border rounded text-[10px] font-mono ${x==="dark"?"bg-slate-800 border-slate-700 text-slate-300":"bg-slate-50 border-slate-200 text-slate-600"}`,children:"Ctrl Y"})]}),k.jsxs("div",{className:"flex items-center justify-between group",children:[k.jsxs("div",{className:"flex items-center gap-2 text-slate-500",children:[k.jsx(Md,{size:14}),k.jsx("span",{className:"text-xs font-medium text-red-500/80",children:"Delete"})]}),k.jsx("kbd",{className:`px-1.5 py-0.5 border rounded text-[10px] font-mono ${x==="dark"?"bg-slate-800 border-slate-700 text-slate-300 text-red-400/80":"bg-slate-50 border-slate-200 text-red-600/80"}`,children:"Del"})]}),k.jsxs("div",{className:"flex items-center justify-between group",children:[k.jsxs("div",{className:"flex items-center gap-2 text-slate-500",children:[k.jsx(Yo,{size:14}),k.jsx("span",{className:"text-xs font-medium",children:"Clear Focus"})]}),k.jsx("kbd",{className:`px-1.5 py-0.5 border rounded text-[10px] font-mono ${x==="dark"?"bg-slate-800 border-slate-700 text-slate-300":"bg-slate-50 border-slate-200 text-slate-600"}`,children:"Esc"})]}),k.jsxs("div",{className:"flex items-center justify-between group",children:[k.jsxs("div",{className:"flex items-center gap-2 text-slate-500",children:[k.jsx(TK,{size:14}),k.jsx("span",{className:"text-xs font-medium",children:"Pan Canvas"})]}),k.jsx("span",{className:`px-1.5 py-0.5 border rounded text-[10px] font-mono ${x==="dark"?"bg-slate-800 border-slate-700 text-slate-300":"bg-slate-50 border-slate-200 text-slate-600"}`,children:"Arrow Keys"})]}),k.jsxs("div",{className:"flex items-center justify-between group",children:[k.jsxs("div",{className:"flex items-center gap-2 text-slate-500",children:[k.jsx(OK,{size:14}),k.jsx("span",{className:"text-xs font-medium",children:"Multi-select"})]}),k.jsx("span",{className:`px-1.5 py-0.5 border rounded text-[10px] font-mono ${x==="dark"?"bg-slate-800 border-slate-700 text-slate-300":"bg-slate-50 border-slate-200 text-slate-600"}`,children:"Shift + Drag"})]})]}),k.jsx("div",{className:`mt-5 pt-3 border-t text-[10px] text-slate-400 italic leading-relaxed ${x==="dark"?"border-slate-800":"border-slate-100"}`,children:"* Edits are saved to local YAML files in real-time if Auto-save is enabled."})]})]}),z&&k.jsxs("div",{className:`absolute top-4 right-4 z-10 flex items-center gap-3 border rounded-xl shadow-2xl p-1.5 px-4 animate-in fade-in slide-in-from-top-4 duration-300 ${x==="dark"?"bg-slate-900/90 backdrop-blur-md border-blue-500/30":"bg-white/90 backdrop-blur-md border-blue-200 shadow-blue-500/5"}`,children:[k.jsxs("div",{className:`flex items-center gap-2 border-r pr-4 mr-1 ${x==="dark"?"border-slate-700":"border-slate-100"}`,children:[T&&k.jsx(Go,{size:16,className:"text-emerald-500"}),M&&k.jsx(v3,{size:16,className:"text-blue-500"}),R&&(R.relationship.type==="lineage"?k.jsx(g3,{size:16,className:"text-blue-400"}):k.jsx(G8,{size:16,className:"text-amber-500"})),k.jsxs("div",{className:"flex flex-col leading-tight",children:[k.jsxs("span",{className:"text-[10px] font-bold uppercase tracking-widest text-slate-500",children:["Selected ",T?"Table":M?"Domain":R?.relationship.type==="lineage"?"Lineage":"Relation"]}),k.jsx("span",{className:`text-xs font-semibold truncate max-w-[180px] ${x==="dark"?"text-slate-200":"text-slate-800"}`,children:T?T.name:M?M.name:R?`${R.relationship.from.table} → ${R.relationship.to.table}`:""})]})]}),k.jsxs("div",{className:"flex items-center gap-1",children:[k.jsx("button",{onClick:q,className:"flex items-center justify-center w-8 h-8 hover:bg-red-500/20 text-slate-400 hover:text-red-500 rounded-lg transition-all group",title:"Delete Selected (Del)",children:k.jsx(Md,{size:16})}),k.jsx("button",{onClick:U,className:`flex items-center justify-center w-8 h-8 rounded-lg transition-all ${x==="dark"?"hover:bg-slate-800 text-slate-500 hover:text-slate-300":"hover:bg-slate-100 text-slate-400 hover:text-slate-600"}`,title:"Clear Selection",children:k.jsx(Yo,{size:16})})]})]})]})},Woe=t=>{if(!t)return["",""];const n=t.toLowerCase().split("-to-");return n.length!==2?["",""]:n.map(i=>i.includes("one")?"1":i.includes("many")?"M":"")},E4=(t,e,n,i=45)=>{switch(n){case Te.Top:return{x:t,y:e-i};case Te.Bottom:return{x:t,y:e+i};case Te.Left:return{x:t-i,y:e};case Te.Right:return{x:t+i,y:e};default:return{x:t,y:e}}};function Koe({sourceX:t,sourceY:e,targetX:n,targetY:i,sourcePosition:r,targetPosition:s,style:o={},markerEnd:c,markerStart:u,label:h,data:d}){const[m]=Sd({sourceX:t,sourceY:e,sourcePosition:r,targetX:n,targetY:i,targetPosition:s}),{theme:g}=ci(),y=d?.isDirectlySelected,x=d?.isConnectedToSelectedTable,w=y||x,S=d?.label||h||"",[C,A]=Woe(S),O=E4(t,e,r),E=E4(n,i,s),T=({x:M,y:R,symbol:z})=>{if(!z)return null;const q=z==="1",U=`
|
|
51
|
+
`:i=="r"?"\r":i=="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 Ose(this):new kse(this)}getCursor(e,n=0,i){let r=e.doc?e:Je.create({doc:e});return i==null&&(i=r.doc.length),this.regexp?Ho(this,r,n,i):Po(this,r,n,i)}}class uj{constructor(e){this.spec=e}}function Sse(t,e,n){return(i,r,s,o)=>{if(n&&!n(i,r,s,o))return!1;let c=i>=o&&r<=o+s.length?s.slice(i-o,r-o):e.doc.sliceString(i,r);return t(c,e,i,r)}}function Po(t,e,n,i){let r;return t.wholeWord&&(r=Cse(e.doc,e.charCategorizer(e.selection.main.head))),t.test&&(r=Sse(t.test,e,r)),new bl(e.doc,t.unquoted,n,i,t.caseSensitive?void 0:s=>s.toLowerCase(),r)}function Cse(t,e){return(n,i,r,s)=>((s>n||s+r.length<i)&&(s=Math.max(0,n-2),r=t.sliceString(s,Math.min(t.length,i+2))),(e(ep(r,n-s))!=At.Word||e(tp(r,n-s))!=At.Word)&&(e(tp(r,i-s))!=At.Word||e(ep(r,i-s))!=At.Word))}class kse extends uj{constructor(e){super(e)}nextMatch(e,n,i){let r=Po(this.spec,e,i,e.doc.length).nextOverlapping();if(r.done){let s=Math.min(e.doc.length,n+this.spec.unquoted.length);r=Po(this.spec,e,0,s).nextOverlapping()}return r.done||r.value.from==n&&r.value.to==i?null:r.value}prevMatchInRange(e,n,i){for(let r=i;;){let s=Math.max(n,r-1e4-this.spec.unquoted.length),o=Po(this.spec,e,s,r),c=null;for(;!o.nextOverlapping().done;)c=o.value;if(c)return c;if(s==n)return null;r-=1e4}}prevMatch(e,n,i){let r=this.prevMatchInRange(e,0,n);return r||(r=this.prevMatchInRange(e,Math.max(0,i-this.spec.unquoted.length),e.doc.length)),r&&(r.from!=n||r.to!=i)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,n){let i=Po(this.spec,e,0,e.doc.length),r=[];for(;!i.next().done;){if(r.length>=n)return null;r.push(i.value)}return r}highlight(e,n,i,r){let s=Po(this.spec,e,Math.max(0,n-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,e.doc.length));for(;!s.next().done;)r(s.value.from,s.value.to)}}function Ase(t,e,n){return(i,r,s)=>(!n||n(i,r,s))&&t(s[0],e,i,r)}function Ho(t,e,n,i){let r;return t.wholeWord&&(r=_se(e.charCategorizer(e.selection.main.head))),t.test&&(r=Ase(t.test,e,r)),new oj(e.doc,t.search,{ignoreCase:!t.caseSensitive,test:r},n,i)}function ep(t,e){return t.slice(sn(t,e,!1),e)}function tp(t,e){return t.slice(e,sn(t,e))}function _se(t){return(e,n,i)=>!i[0].length||(t(ep(i.input,i.index))!=At.Word||t(tp(i.input,i.index))!=At.Word)&&(t(tp(i.input,i.index+i[0].length))!=At.Word||t(ep(i.input,i.index+i[0].length))!=At.Word)}class Ose extends uj{nextMatch(e,n,i){let r=Ho(this.spec,e,i,e.doc.length).next();return r.done&&(r=Ho(this.spec,e,0,n).next()),r.done?null:r.value}prevMatchInRange(e,n,i){for(let r=1;;r++){let s=Math.max(n,i-r*1e4),o=Ho(this.spec,e,s,i),c=null;for(;!o.next().done;)c=o.value;if(c&&(s==n||c.from>s+10))return c;if(s==n)return null}}prevMatch(e,n,i){return this.prevMatchInRange(e,0,n)||this.prevMatchInRange(e,i,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(n,i)=>{if(i=="&")return e.match[0];if(i=="$")return"$";for(let r=i.length;r>0;r--){let s=+i.slice(0,r);if(s>0&&s<e.match.length)return e.match[s]+i.slice(r)}return n})}matchAll(e,n){let i=Ho(this.spec,e,0,e.doc.length),r=[];for(;!i.next().done;){if(r.length>=n)return null;r.push(i.value)}return r}highlight(e,n,i,r){let s=Ho(this.spec,e,Math.max(0,n-250),Math.min(i+250,e.doc.length));for(;!s.next().done;)r(s.value.from,s.value.to)}}const ku=je.define(),DC=je.define(),Vs=_n.define({create(t){return new Aw(t2(t).create(),null)},update(t,e){for(let n of e.effects)n.is(ku)?t=new Aw(n.value.create(),t.panel):n.is(DC)&&(t=new Aw(t.query,n.value?LC:null));return t},provide:t=>xu.from(t,e=>e.panel)});class Aw{constructor(e,n){this.query=e,this.panel=n}}const Ese=Le.mark({class:"cm-searchMatch"}),Tse=Le.mark({class:"cm-searchMatch cm-searchMatch-selected"}),Mse=zt.fromClass(class{constructor(t){this.view=t,this.decorations=this.highlight(t.state.field(Vs))}update(t){let e=t.state.field(Vs);(e!=t.startState.field(Vs)||t.docChanged||t.selectionSet||t.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:t,panel:e}){if(!e||!t.spec.valid)return Le.none;let{view:n}=this,i=new Kr;for(let r=0,s=n.visibleRanges,o=s.length;r<o;r++){let{from:c,to:u}=s[r];for(;r<o-1&&u>s[r+1].from-500;)u=s[++r].to;t.highlight(n.state,c,u,(h,d)=>{let m=n.state.selection.ranges.some(g=>g.from==h&&g.to==d);i.add(h,d,m?Tse:Ese)})}return i.finish()}},{decorations:t=>t.decorations});function Yu(t){return e=>{let n=e.state.field(Vs,!1);return n&&n.query.spec.valid?t(e,n):dj(e)}}const np=Yu((t,{query:e})=>{let{to:n}=t.state.selection.main,i=e.nextMatch(t.state,n,n);if(!i)return!1;let r=de.single(i.from,i.to),s=t.state.facet(Tl);return t.dispatch({selection:r,effects:[zC(t,i),s.scrollToMatch(r.main,t)],userEvent:"select.search"}),hj(t),!0}),ip=Yu((t,{query:e})=>{let{state:n}=t,{from:i}=n.selection.main,r=e.prevMatch(n,i,i);if(!r)return!1;let s=de.single(r.from,r.to),o=t.state.facet(Tl);return t.dispatch({selection:s,effects:[zC(t,r),o.scrollToMatch(s.main,t)],userEvent:"select.search"}),hj(t),!0}),Rse=Yu((t,{query:e})=>{let n=e.matchAll(t.state,1e3);return!n||!n.length?!1:(t.dispatch({selection:de.create(n.map(i=>de.range(i.from,i.to))),userEvent:"select.search.matches"}),!0)}),Nse=({state:t,dispatch:e})=>{let n=t.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:i,to:r}=n.main,s=[],o=0;for(let c=new bl(t.doc,t.sliceDoc(i,r));!c.next().done;){if(s.length>1e3)return!1;c.value.from==i&&(o=s.length),s.push(de.range(c.value.from,c.value.to))}return e(t.update({selection:de.create(s,o),userEvent:"select.search.matches"})),!0},K5=Yu((t,{query:e})=>{let{state:n}=t,{from:i,to:r}=n.selection.main;if(n.readOnly)return!1;let s=e.nextMatch(n,i,i);if(!s)return!1;let o=s,c=[],u,h,d=[];o.from==i&&o.to==r&&(h=n.toText(e.getReplacement(o)),c.push({from:o.from,to:o.to,insert:h}),o=e.nextMatch(n,o.from,o.to),d.push(Se.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(i).number)+".")));let m=t.state.changes(c);return o&&(u=de.single(o.from,o.to).map(m),d.push(zC(t,o)),d.push(n.facet(Tl).scrollToMatch(u.main,t))),t.dispatch({changes:m,selection:u,effects:d,userEvent:"input.replace"}),!0}),Dse=Yu((t,{query:e})=>{if(t.state.readOnly)return!1;let n=e.matchAll(t.state,1e9).map(r=>{let{from:s,to:o}=r;return{from:s,to:o,insert:e.getReplacement(r)}});if(!n.length)return!1;let i=t.state.phrase("replaced $ matches",n.length)+".";return t.dispatch({changes:n,effects:Se.announce.of(i),userEvent:"input.replace.all"}),!0});function LC(t){return t.state.facet(Tl).createPanel(t)}function t2(t,e){var n,i,r,s,o;let c=t.selection.main,u=c.empty||c.to>c.from+100?"":t.sliceDoc(c.from,c.to);if(e&&!u)return e;let h=t.facet(Tl);return new cj({search:((n=e?.literal)!==null&&n!==void 0?n:h.literal)?u:u.replace(/\n/g,"\\n"),caseSensitive:(i=e?.caseSensitive)!==null&&i!==void 0?i:h.caseSensitive,literal:(r=e?.literal)!==null&&r!==void 0?r:h.literal,regexp:(s=e?.regexp)!==null&&s!==void 0?s:h.regexp,wholeWord:(o=e?.wholeWord)!==null&&o!==void 0?o:h.wholeWord})}function fj(t){let e=wC(t,LC);return e&&e.dom.querySelector("[main-field]")}function hj(t){let e=fj(t);e&&e==t.root.activeElement&&e.select()}const dj=t=>{let e=t.state.field(Vs,!1);if(e&&e.panel){let n=fj(t);if(n&&n!=t.root.activeElement){let i=t2(t.state,e.query.spec);i.valid&&t.dispatch({effects:ku.of(i)}),n.focus(),n.select()}}else t.dispatch({effects:[DC.of(!0),e?ku.of(t2(t.state,e.query.spec)):je.appendConfig.of(qse)]});return!0},pj=t=>{let e=t.state.field(Vs,!1);if(!e||!e.panel)return!1;let n=wC(t,LC);return n&&n.dom.contains(t.root.activeElement)&&t.focus(),t.dispatch({effects:DC.of(!1)}),!0},Lse=[{key:"Mod-f",run:dj,scope:"editor search-panel"},{key:"F3",run:np,shift:ip,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:np,shift:ip,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:pj,scope:"editor search-panel"},{key:"Mod-Shift-l",run:Nse},{key:"Mod-Alt-g",run:use},{key:"Mod-d",run:wse,preventDefault:!0}];class zse{constructor(e){this.view=e;let n=this.query=e.state.field(Vs).query.spec;this.commit=this.commit.bind(this),this.searchField=dt("input",{value:n.search,placeholder:ri(e,"Find"),"aria-label":ri(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=dt("input",{value:n.replace,placeholder:ri(e,"Replace"),"aria-label":ri(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=dt("input",{type:"checkbox",name:"case",form:"",checked:n.caseSensitive,onchange:this.commit}),this.reField=dt("input",{type:"checkbox",name:"re",form:"",checked:n.regexp,onchange:this.commit}),this.wordField=dt("input",{type:"checkbox",name:"word",form:"",checked:n.wholeWord,onchange:this.commit});function i(r,s,o){return dt("button",{class:"cm-button",name:r,onclick:s,type:"button"},o)}this.dom=dt("div",{onkeydown:r=>this.keydown(r),class:"cm-search"},[this.searchField,i("next",()=>np(e),[ri(e,"next")]),i("prev",()=>ip(e),[ri(e,"previous")]),i("select",()=>Rse(e),[ri(e,"all")]),dt("label",null,[this.caseField,ri(e,"match case")]),dt("label",null,[this.reField,ri(e,"regexp")]),dt("label",null,[this.wordField,ri(e,"by word")]),...e.state.readOnly?[]:[dt("br"),this.replaceField,i("replace",()=>K5(e),[ri(e,"replace")]),i("replaceAll",()=>Dse(e),[ri(e,"replace all")])],dt("button",{name:"close",onclick:()=>pj(e),"aria-label":ri(e,"close"),type:"button"},["×"])])}commit(){let e=new cj({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:ku.of(e)}))}keydown(e){Ite(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?ip:np)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),K5(this.view))}update(e){for(let n of e.transactions)for(let i of n.effects)i.is(ku)&&!i.value.eq(this.query)&&this.setQuery(i.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(Tl).top}}function ri(t,e){return t.state.phrase(e)}const Kh=30,Zh=/[\s\.,:;?!]/;function zC(t,{from:e,to:n}){let i=t.state.doc.lineAt(e),r=t.state.doc.lineAt(n).to,s=Math.max(i.from,e-Kh),o=Math.min(r,n+Kh),c=t.state.sliceDoc(s,o);if(s!=i.from){for(let u=0;u<Kh;u++)if(!Zh.test(c[u+1])&&Zh.test(c[u])){c=c.slice(u);break}}if(o!=r){for(let u=c.length-1;u>c.length-Kh;u--)if(!Zh.test(c[u-1])&&Zh.test(c[u])){c=c.slice(0,u);break}}return Se.announce.of(`${t.state.phrase("current match")}. ${c} ${t.state.phrase("on line")} ${i.number}.`)}const Bse=Se.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"}}),qse=[Vs,Za.low(Mse),Bse];class mj{constructor(e,n,i,r){this.state=e,this.pos=n,this.explicit=i,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let n=Cn(this.state).resolveInner(this.pos,-1);for(;n&&e.indexOf(n.name)<0;)n=n.parent;return n?{from:n.from,to:this.pos,text:this.state.sliceDoc(n.from,this.pos),type:n.type}:null}matchBefore(e){let n=this.state.doc.lineAt(this.pos),i=Math.max(n.from,this.pos-250),r=n.text.slice(i-n.from,this.pos-n.from),s=r.search(gj(e,!1));return s<0?null:{from:i+s,to:this.pos,text:r.slice(s)}}get aborted(){return this.abortListeners==null}addEventListener(e,n,i){e=="abort"&&this.abortListeners&&(this.abortListeners.push(n),i&&i.onDocChange&&(this.abortOnDocChange=!0))}}function Z5(t){let e=Object.keys(t).join(""),n=/\w/.test(e);return n&&(e=e.replace(/\w/g,"")),`[${n?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function jse(t){let e=Object.create(null),n=Object.create(null);for(let{label:r}of t){e[r[0]]=!0;for(let s=1;s<r.length;s++)n[r[s]]=!0}let i=Z5(e)+Z5(n)+"*$";return[new RegExp("^"+i),new RegExp(i)]}function Ise(t){let e=t.map(r=>typeof r=="string"?{label:r}:r),[n,i]=e.every(r=>/^\w+$/.test(r.label))?[/\w*$/,/\w+$/]:jse(e);return r=>{let s=r.matchBefore(i);return s||r.explicit?{from:s?s.from:r.pos,options:e,validFor:n}:null}}class J5{constructor(e,n,i,r){this.completion=e,this.source=n,this.match=i,this.score=r}}function Ia(t){return t.selection.main.from}function gj(t,e){var n;let{source:i}=t,r=e&&i[0]!="^",s=i[i.length-1]!="$";return!r&&!s?t:new RegExp(`${r?"^":""}(?:${i})${s?"$":""}`,(n=t.flags)!==null&&n!==void 0?n:t.ignoreCase?"i":"")}const yj=dr.define();function Pse(t,e,n,i){let{main:r}=t.selection,s=n-r.from,o=i-r.from;return{...t.changeByRange(c=>{if(c!=r&&n!=i&&t.sliceDoc(c.from+s,c.from+o)!=t.sliceDoc(n,i))return{range:c};let u=t.toText(e);return{changes:{from:c.from+s,to:i==r.from?c.to:c.from+o,insert:u},range:de.cursor(c.from+s+u.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const e4=new WeakMap;function Hse(t){if(!Array.isArray(t))return t;let e=e4.get(t);return e||e4.set(t,e=Ise(t)),e}const rp=je.define(),Au=je.define();class Use{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let n=0;n<e.length;){let i=In(e,n),r=ir(i);this.chars.push(i);let s=e.slice(n,n+r),o=s.toUpperCase();this.folded.push(In(o==s?s.toLowerCase():o,0)),n+=r}this.astral=e.length!=this.chars.length}ret(e,n){return this.score=e,this.matched=n,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:n,folded:i,any:r,precise:s,byWord:o}=this;if(n.length==1){let A=In(e,0),O=ir(A),E=O==e.length?0:-100;if(A!=n[0])if(A==i[0])E+=-200;else return null;return this.ret(E,[0,O])}let c=e.indexOf(this.pattern);if(c==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let u=n.length,h=0;if(c<0){for(let A=0,O=Math.min(e.length,200);A<O&&h<u;){let E=In(e,A);(E==n[h]||E==i[h])&&(r[h++]=A),A+=ir(E)}if(h<u)return null}let d=0,m=0,g=!1,y=0,x=-1,w=-1,S=/[a-z]/.test(e),C=!0;for(let A=0,O=Math.min(e.length,200),E=0;A<O&&m<u;){let T=In(e,A);c<0&&(d<u&&T==n[d]&&(s[d++]=A),y<u&&(T==n[y]||T==i[y]?(y==0&&(x=A),w=A+1,y++):y=0));let M,R=T<255?T>=48&&T<=57||T>=97&&T<=122?2:T>=65&&T<=90?1:0:(M=iC(T))!=M.toLowerCase()?1:M!=M.toUpperCase()?2:0;(!A||R==1&&S||E==0&&R!=0)&&(n[m]==T||i[m]==T&&(g=!0)?o[m++]=A:o.length&&(C=!1)),E=R,A+=ir(T)}return m==u&&o[0]==0&&C?this.result(-100+(g?-200:0),o,e):y==u&&x==0?this.ret(-200-e.length+(w==e.length?0:-100),[0,w]):c>-1?this.ret(-700-e.length,[c,c+this.pattern.length]):y==u?this.ret(-900-e.length,[x,w]):m==u?this.result(-100+(g?-200:0)+-700+(C?0:-1100),o,e):n.length==2?null:this.result((r[0]?-700:0)+-200+-1100,r,e)}result(e,n,i){let r=[],s=0;for(let o of n){let c=o+(this.astral?ir(In(i,o)):1);s&&r[s-1]==o?r[s-1]=c:(r[s++]=o,r[s++]=c)}return this.ret(e-i.length,r)}}class Vse{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 n=e.slice(0,this.pattern.length),i=n==this.pattern?0:n.toLowerCase()==this.folded?-200:null;return i==null?null:(this.matched=[0,n.length],this.score=i+(e.length==this.pattern.length?0:-100),this)}}const rn=ke.define({combine(t){return pr(t,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:Fse,filterStrict:!1,compareCompletions:(e,n)=>(e.sortText||e.label).localeCompare(n.sortText||n.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,n)=>e&&n,closeOnBlur:(e,n)=>e&&n,icons:(e,n)=>e&&n,tooltipClass:(e,n)=>i=>t4(e(i),n(i)),optionClass:(e,n)=>i=>t4(e(i),n(i)),addToOptions:(e,n)=>e.concat(n),filterStrict:(e,n)=>e||n})}});function t4(t,e){return t?e?t+" "+e:t:e}function Fse(t,e,n,i,r,s){let o=t.textDirection==yt.RTL,c=o,u=!1,h="top",d,m,g=e.left-r.left,y=r.right-e.right,x=i.right-i.left,w=i.bottom-i.top;if(c&&g<Math.min(x,y)?c=!1:!c&&y<Math.min(x,g)&&(c=!0),x<=(c?g:y))d=Math.max(r.top,Math.min(n.top,r.bottom-w))-e.top,m=Math.min(400,c?g:y);else{u=!0,m=Math.min(400,(o?e.right:r.right-e.left)-30);let A=r.bottom-e.bottom;A>=w||A>e.top?d=n.bottom-e.top:(h="bottom",d=e.bottom-n.top)}let S=(e.bottom-e.top)/s.offsetHeight,C=(e.right-e.left)/s.offsetWidth;return{style:`${h}: ${d/S}px; max-width: ${m/C}px`,class:"cm-completionInfo-"+(u?o?"left-narrow":"right-narrow":c?"left":"right")}}const BC=je.define();function $se(t){let e=t.addToOptions.slice();return t.icons&&e.push({render(n){let i=document.createElement("div");return i.classList.add("cm-completionIcon"),n.type&&i.classList.add(...n.type.split(/\s+/g).map(r=>"cm-completionIcon-"+r)),i.setAttribute("aria-hidden","true"),i},position:20}),e.push({render(n,i,r,s){let o=document.createElement("span");o.className="cm-completionLabel";let c=n.displayLabel||n.label,u=0;for(let h=0;h<s.length;){let d=s[h++],m=s[h++];d>u&&o.appendChild(document.createTextNode(c.slice(u,d)));let g=o.appendChild(document.createElement("span"));g.appendChild(document.createTextNode(c.slice(d,m))),g.className="cm-completionMatchedText",u=m}return u<c.length&&o.appendChild(document.createTextNode(c.slice(u))),o},position:50},{render(n){if(!n.detail)return null;let i=document.createElement("span");return i.className="cm-completionDetail",i.textContent=n.detail,i},position:80}),e.sort((n,i)=>n.position-i.position).map(n=>n.render)}function _w(t,e,n){if(t<=n)return{from:0,to:t};if(e<0&&(e=0),e<=t>>1){let r=Math.floor(e/n);return{from:r*n,to:(r+1)*n}}let i=Math.floor((t-e)/n);return{from:t-(i+1)*n,to:t-i*n}}class Gse{constructor(e,n,i){this.view=e,this.stateField=n,this.applyCompletion=i,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:u=>this.placeInfo(u),key:this},this.space=null,this.currentClass="";let r=e.state.field(n),{options:s,selected:o}=r.open,c=e.state.facet(rn);this.optionContent=$se(c),this.optionClass=c.optionClass,this.tooltipClass=c.tooltipClass,this.range=_w(s.length,o,c.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",u=>{let{options:h}=e.state.field(n).open;for(let d=u.target,m;d&&d!=this.dom;d=d.parentNode)if(d.nodeName=="LI"&&(m=/-(\d+)$/.exec(d.id))&&+m[1]<h.length){this.applyCompletion(e,h[+m[1]]),u.preventDefault();return}if(u.target==this.list){let d=this.list.classList.contains("cm-completionListIncompleteTop")&&u.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains("cm-completionListIncompleteBottom")&&u.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;d!=null&&(e.dispatch({effects:BC.of(d)}),u.preventDefault())}}),this.dom.addEventListener("focusout",u=>{let h=e.state.field(this.stateField,!1);h&&h.tooltip&&e.state.facet(rn).closeOnBlur&&u.relatedTarget!=e.contentDOM&&e.dispatch({effects:Au.of(null)})}),this.showOptions(s,r.id)}mount(){this.updateSel()}showOptions(e,n){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,n,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var n;let i=e.state.field(this.stateField),r=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),i!=r){let{options:s,selected:o,disabled:c}=i.open;(!r.open||r.open.options!=s)&&(this.range=_w(s.length,o,e.state.facet(rn).maxRenderedOptions),this.showOptions(s,i.id)),this.updateSel(),c!=((n=r.open)===null||n===void 0?void 0:n.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!c)}}updateTooltipClass(e){let n=this.tooltipClass(e);if(n!=this.currentClass){for(let i of this.currentClass.split(" "))i&&this.dom.classList.remove(i);for(let i of n.split(" "))i&&this.dom.classList.add(i);this.currentClass=n}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),n=e.open;(n.selected>-1&&n.selected<this.range.from||n.selected>=this.range.to)&&(this.range=_w(n.options.length,n.selected,this.view.state.facet(rn).maxRenderedOptions),this.showOptions(n.options,e.id));let i=this.updateSelectedOption(n.selected);if(i){this.destroyInfo();let{completion:r}=n.options[n.selected],{info:s}=r;if(!s)return;let o=typeof s=="string"?document.createTextNode(s):s(r);if(!o)return;"then"in o?o.then(c=>{c&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(c,r)}).catch(c=>Fn(this.view.state,c,"completion info")):(this.addInfoPane(o,r),i.setAttribute("aria-describedby",this.info.id))}}addInfoPane(e,n){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",i.id="cm-completionInfo-"+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)i.appendChild(e),this.infoDestroy=null;else{let{dom:r,destroy:s}=e;i.appendChild(r),this.infoDestroy=s||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let n=null;for(let i=this.list.firstChild,r=this.range.from;i;i=i.nextSibling,r++)i.nodeName!="LI"||!i.id?r--:r==e?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),n=i):i.hasAttribute("aria-selected")&&(i.removeAttribute("aria-selected"),i.removeAttribute("aria-describedby"));return n&&Qse(this.list,n),n}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let n=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),r=e.getBoundingClientRect(),s=this.space;if(!s){let o=this.dom.ownerDocument.documentElement;s={left:0,top:0,right:o.clientWidth,bottom:o.clientHeight}}return r.top>Math.min(s.bottom,n.bottom)-10||r.bottom<Math.max(s.top,n.top)+10?null:this.view.state.facet(rn).positionInfo(this.view,n,r,i,s,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,n,i){const r=document.createElement("ul");r.id=n,r.setAttribute("role","listbox"),r.setAttribute("aria-expanded","true"),r.setAttribute("aria-label",this.view.state.phrase("Completions")),r.addEventListener("mousedown",o=>{o.target==r&&o.preventDefault()});let s=null;for(let o=i.from;o<i.to;o++){let{completion:c,match:u}=e[o],{section:h}=c;if(h){let g=typeof h=="string"?h:h.name;if(g!=s&&(o>i.from||i.from==0))if(s=g,typeof h!="string"&&h.header)r.appendChild(h.header(h));else{let y=r.appendChild(document.createElement("completion-section"));y.textContent=g}}const d=r.appendChild(document.createElement("li"));d.id=n+"-"+o,d.setAttribute("role","option");let m=this.optionClass(c);m&&(d.className=m);for(let g of this.optionContent){let y=g(c,this.view.state,this.view,u);y&&d.appendChild(y)}}return i.from&&r.classList.add("cm-completionListIncompleteTop"),i.to<e.length&&r.classList.add("cm-completionListIncompleteBottom"),r}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function Yse(t,e){return n=>new Gse(n,t,e)}function Qse(t,e){let n=t.getBoundingClientRect(),i=e.getBoundingClientRect(),r=n.height/t.offsetHeight;i.top<n.top?t.scrollTop-=(n.top-i.top)/r:i.bottom>n.bottom&&(t.scrollTop+=(i.bottom-n.bottom)/r)}function n4(t){return(t.boost||0)*100+(t.apply?10:0)+(t.info?5:0)+(t.type?1:0)}function Xse(t,e){let n=[],i=null,r=null,s=d=>{n.push(d);let{section:m}=d.completion;if(m){i||(i=[]);let g=typeof m=="string"?m:m.name;i.some(y=>y.name==g)||i.push(typeof m=="string"?{name:g}:m)}},o=e.facet(rn);for(let d of t)if(d.hasResult()){let m=d.result.getMatch;if(d.result.filter===!1)for(let g of d.result.options)s(new J5(g,d.source,m?m(g):[],1e9-n.length));else{let g=e.sliceDoc(d.from,d.to),y,x=o.filterStrict?new Vse(g):new Use(g);for(let w of d.result.options)if(y=x.match(w.label)){let S=w.displayLabel?m?m(w,y.matched):[]:y.matched,C=y.score+(w.boost||0);if(s(new J5(w,d.source,S,C)),typeof w.section=="object"&&w.section.rank==="dynamic"){let{name:A}=w.section;r||(r=Object.create(null)),r[A]=Math.max(C,r[A]||-1e9)}}}}if(i){let d=Object.create(null),m=0,g=(y,x)=>(y.rank==="dynamic"&&x.rank==="dynamic"?r[x.name]-r[y.name]:0)||(typeof y.rank=="number"?y.rank:1e9)-(typeof x.rank=="number"?x.rank:1e9)||(y.name<x.name?-1:1);for(let y of i.sort(g))m-=1e5,d[y.name]=m;for(let y of n){let{section:x}=y.completion;x&&(y.score+=d[typeof x=="string"?x:x.name])}}let c=[],u=null,h=o.compareCompletions;for(let d of n.sort((m,g)=>g.score-m.score||h(m.completion,g.completion))){let m=d.completion;!u||u.label!=m.label||u.detail!=m.detail||u.type!=null&&m.type!=null&&u.type!=m.type||u.apply!=m.apply||u.boost!=m.boost?c.push(d):n4(d.completion)>n4(u)&&(c[c.length-1]=d),u=d.completion}return c}class Ko{constructor(e,n,i,r,s,o){this.options=e,this.attrs=n,this.tooltip=i,this.timestamp=r,this.selected=s,this.disabled=o}setSelected(e,n){return e==this.selected||e>=this.options.length?this:new Ko(this.options,i4(n,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,n,i,r,s,o){if(r&&!o&&e.some(h=>h.isPending))return r.setDisabled();let c=Xse(e,n);if(!c.length)return r&&e.some(h=>h.isPending)?r.setDisabled():null;let u=n.facet(rn).selectOnOpen?0:-1;if(r&&r.selected!=u&&r.selected!=-1){let h=r.options[r.selected].completion;for(let d=0;d<c.length;d++)if(c[d].completion==h){u=d;break}}return new Ko(c,i4(i,u),{pos:e.reduce((h,d)=>d.hasResult()?Math.min(h,d.from):h,1e8),create:tae,above:s.aboveCursor},r?r.timestamp:Date.now(),u,!1)}map(e){return new Ko(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new Ko(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class sp{constructor(e,n,i){this.active=e,this.id=n,this.open=i}static start(){return new sp(Jse,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:n}=e,i=n.facet(rn),s=(i.override||n.languageDataAt("autocomplete",Ia(n)).map(Hse)).map(u=>(this.active.find(d=>d.source==u)||new Ai(u,this.active.some(d=>d.state!=0)?1:0)).update(e,i));s.length==this.active.length&&s.every((u,h)=>u==this.active[h])&&(s=this.active);let o=this.open,c=e.effects.some(u=>u.is(qC));o&&e.docChanged&&(o=o.map(e.changes)),e.selection||s.some(u=>u.hasResult()&&e.changes.touchesRange(u.from,u.to))||!Wse(s,this.active)||c?o=Ko.build(s,n,this.id,o,i,c):o&&o.disabled&&!s.some(u=>u.isPending)&&(o=null),!o&&s.every(u=>!u.isPending)&&s.some(u=>u.hasResult())&&(s=s.map(u=>u.hasResult()?new Ai(u.source,0):u));for(let u of e.effects)u.is(BC)&&(o=o&&o.setSelected(u.value,this.id));return s==this.active&&o==this.open?this:new sp(s,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?Kse:Zse}}function Wse(t,e){if(t==e)return!0;for(let n=0,i=0;;){for(;n<t.length&&!t[n].hasResult();)n++;for(;i<e.length&&!e[i].hasResult();)i++;let r=n==t.length,s=i==e.length;if(r||s)return r==s;if(t[n++].result!=e[i++].result)return!1}}const Kse={"aria-autocomplete":"list"},Zse={};function i4(t,e){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":t};return e>-1&&(n["aria-activedescendant"]=t+"-"+e),n}const Jse=[];function vj(t,e){if(t.isUserEvent("input.complete")){let i=t.annotation(yj);if(i&&e.activateOnCompletion(i))return 12}let n=t.isUserEvent("input.type");return n&&e.activateOnTyping?5:n?1:t.isUserEvent("delete.backward")?2:t.selection?8:t.docChanged?16:0}class Ai{constructor(e,n,i=!1){this.source=e,this.state=n,this.explicit=i}hasResult(){return!1}get isPending(){return this.state==1}update(e,n){let i=vj(e,n),r=this;(i&8||i&16&&this.touches(e))&&(r=new Ai(r.source,0)),i&4&&r.state==0&&(r=new Ai(this.source,1)),r=r.updateFor(e,i);for(let s of e.effects)if(s.is(rp))r=new Ai(r.source,1,s.value);else if(s.is(Au))r=new Ai(r.source,0);else if(s.is(qC))for(let o of s.value)o.source==r.source&&(r=o);return r}updateFor(e,n){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(Ia(e.state))}}class ll extends Ai{constructor(e,n,i,r,s,o){super(e,3,n),this.limit=i,this.result=r,this.from=s,this.to=o}hasResult(){return!0}updateFor(e,n){var i;if(!(n&3))return this.map(e.changes);let r=this.result;r.map&&!e.changes.empty&&(r=r.map(r,e.changes));let s=e.changes.mapPos(this.from),o=e.changes.mapPos(this.to,1),c=Ia(e.state);if(c>o||!r||n&2&&(Ia(e.startState)==this.from||c<this.limit))return new Ai(this.source,n&4?1:0);let u=e.changes.mapPos(this.limit);return eae(r.validFor,e.state,s,o)?new ll(this.source,this.explicit,u,r,s,o):r.update&&(r=r.update(r,s,o,new mj(e.state,c,!1)))?new ll(this.source,this.explicit,u,r,r.from,(i=r.to)!==null&&i!==void 0?i:Ia(e.state)):new Ai(this.source,1,this.explicit)}map(e){return e.empty?this:(this.result.map?this.result.map(this.result,e):this.result)?new ll(this.source,this.explicit,e.mapPos(this.limit),this.result,e.mapPos(this.from),e.mapPos(this.to,1)):new Ai(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}}function eae(t,e,n,i){if(!t)return!1;let r=e.sliceDoc(n,i);return typeof t=="function"?t(r,n,i,e):gj(t,!0).test(r)}const qC=je.define({map(t,e){return t.map(n=>n.map(e))}}),Pn=_n.define({create(){return sp.start()},update(t,e){return t.update(e)},provide:t=>[xC.from(t,e=>e.tooltip),Se.contentAttributes.from(t,e=>e.attrs)]});function jC(t,e){const n=e.completion.apply||e.completion.label;let i=t.state.field(Pn).active.find(r=>r.source==e.source);return i instanceof ll?(typeof n=="string"?t.dispatch({...Pse(t.state,n,i.from,i.to),annotations:yj.of(e.completion)}):n(t,e.completion,i.from,i.to),!0):!1}const tae=Yse(Pn,jC);function Jh(t,e="option"){return n=>{let i=n.state.field(Pn,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp<n.state.facet(rn).interactionDelay)return!1;let r=1,s;e=="page"&&(s=K6(n,i.open.tooltip))&&(r=Math.max(2,Math.floor(s.dom.offsetHeight/s.dom.querySelector("li").offsetHeight)-1));let{length:o}=i.open.options,c=i.open.selected>-1?i.open.selected+r*(t?1:-1):t?0:o-1;return c<0?c=e=="page"?0:o-1:c>=o&&(c=e=="page"?o-1:0),n.dispatch({effects:BC.of(c)}),!0}}const nae=t=>{let e=t.state.field(Pn,!1);return t.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<t.state.facet(rn).interactionDelay?!1:jC(t,e.open.options[e.open.selected])},Ow=t=>t.state.field(Pn,!1)?(t.dispatch({effects:rp.of(!0)}),!0):!1,iae=t=>{let e=t.state.field(Pn,!1);return!e||!e.active.some(n=>n.state!=0)?!1:(t.dispatch({effects:Au.of(null)}),!0)};class rae{constructor(e,n){this.active=e,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const sae=50,aae=1e3,oae=zt.fromClass(class{constructor(t){this.view=t,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of t.state.field(Pn).active)e.isPending&&this.startQuery(e)}update(t){let e=t.state.field(Pn),n=t.state.facet(rn);if(!t.selectionSet&&!t.docChanged&&t.startState.field(Pn)==e)return;let i=t.transactions.some(s=>{let o=vj(s,n);return o&8||(s.selection||s.docChanged)&&!(o&3)});for(let s=0;s<this.running.length;s++){let o=this.running[s];if(i||o.context.abortOnDocChange&&t.docChanged||o.updates.length+t.transactions.length>sae&&Date.now()-o.time>aae){for(let c of o.context.abortListeners)try{c()}catch(u){Fn(this.view.state,u)}o.context.abortListeners=null,this.running.splice(s--,1)}else o.updates.push(...t.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),t.transactions.some(s=>s.effects.some(o=>o.is(rp)))&&(this.pendingStart=!0);let r=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(s=>s.isPending&&!this.running.some(o=>o.active.source==s.source))?setTimeout(()=>this.startUpdate(),r):-1,this.composing!=0)for(let s of t.transactions)s.isUserEvent("input.type")?this.composing=2:this.composing==2&&s.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:t}=this.view,e=t.field(Pn);for(let n of e.active)n.isPending&&!this.running.some(i=>i.active.source==n.source)&&this.startQuery(n);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(rn).updateSyncTime))}startQuery(t){let{state:e}=this.view,n=Ia(e),i=new mj(e,n,t.explicit,this.view),r=new rae(t,i);this.running.push(r),Promise.resolve(t.source(i)).then(s=>{r.context.aborted||(r.done=s||null,this.scheduleAccept())},s=>{this.view.dispatch({effects:Au.of(null)}),Fn(this.view.state,s)})}scheduleAccept(){this.running.every(t=>t.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(rn).updateSyncTime))}accept(){var t;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],n=this.view.state.facet(rn),i=this.view.state.field(Pn);for(let r=0;r<this.running.length;r++){let s=this.running[r];if(s.done===void 0)continue;if(this.running.splice(r--,1),s.done){let c=Ia(s.updates.length?s.updates[0].startState:this.view.state),u=Math.min(c,s.done.from+(s.active.explicit?0:1)),h=new ll(s.active.source,s.active.explicit,u,s.done,s.done.from,(t=s.done.to)!==null&&t!==void 0?t:c);for(let d of s.updates)h=h.update(d,n);if(h.hasResult()){e.push(h);continue}}let o=i.active.find(c=>c.source==s.active.source);if(o&&o.isPending)if(s.done==null){let c=new Ai(s.active.source,0);for(let u of s.updates)c=c.update(u,n);c.isPending||e.push(c)}else this.startQuery(o)}(e.length||i.open&&i.open.disabled)&&this.view.dispatch({effects:qC.of(e)})}},{eventHandlers:{blur(t){let e=this.view.state.field(Pn,!1);if(e&&e.tooltip&&this.view.state.facet(rn).closeOnBlur){let n=e.open&&K6(this.view,e.open.tooltip);(!n||!n.dom.contains(t.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:Au.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:rp.of(!1)}),20),this.composing=0}}}),lae=typeof navigator=="object"&&/Win/.test(navigator.platform),cae=Za.highest(Se.domEventHandlers({keydown(t,e){let n=e.state.field(Pn,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||t.key.length>1||t.ctrlKey&&!(lae&&t.altKey)||t.metaKey)return!1;let i=n.open.options[n.open.selected],r=n.active.find(o=>o.source==i.source),s=i.completion.commitCharacters||r.result.commitCharacters;return s&&s.indexOf(t.key)>-1&&jC(e,i),!1}})),uae=Se.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"},".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"}}}),_u={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},La=je.define({map(t,e){let n=e.mapPos(t,-1,Rn.TrackAfter);return n??void 0}}),IC=new class extends Gs{};IC.startSide=1;IC.endSide=-1;const bj=_n.define({create(){return Ye.empty},update(t,e){if(t=t.map(e.changes),e.selection){let n=e.state.doc.lineAt(e.selection.main.head);t=t.update({filter:i=>i>=n.from&&i<=n.to})}for(let n of e.effects)n.is(La)&&(t=t.update({add:[IC.range(n.value,n.value+1)]}));return t}});function fae(){return[dae,bj]}const Ew="()[]{}<>«»»«[]{}";function xj(t){for(let e=0;e<Ew.length;e+=2)if(Ew.charCodeAt(e)==t)return Ew.charAt(e+1);return iC(t<128?t:t+1)}function wj(t,e){return t.languageDataAt("closeBrackets",e)[0]||_u}const hae=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),dae=Se.inputHandler.of((t,e,n,i)=>{if((hae?t.composing:t.compositionStarted)||t.state.readOnly)return!1;let r=t.state.selection.main;if(i.length>2||i.length==2&&ir(In(i,0))==1||e!=r.from||n!=r.to)return!1;let s=gae(t.state,i);return s?(t.dispatch(s),!0):!1}),pae=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=wj(t,t.selection.main.head).brackets||_u.brackets,r=null,s=t.changeByRange(o=>{if(o.empty){let c=yae(t.doc,o.head);for(let u of i)if(u==c&&Wp(t.doc,o.head)==xj(In(u,0)))return{changes:{from:o.head-u.length,to:o.head+u.length},range:de.cursor(o.head-u.length)}}return{range:r=o}});return r||e(t.update(s,{scrollIntoView:!0,userEvent:"delete.backward"})),!r},mae=[{key:"Backspace",run:pae}];function gae(t,e){let n=wj(t,t.selection.main.head),i=n.brackets||_u.brackets;for(let r of i){let s=xj(In(r,0));if(e==r)return s==r?xae(t,r,i.indexOf(r+r+r)>-1,n):vae(t,r,s,n.before||_u.before);if(e==s&&Sj(t,t.selection.main.from))return bae(t,r,s)}return null}function Sj(t,e){let n=!1;return t.field(bj).between(0,t.doc.length,i=>{i==e&&(n=!0)}),n}function Wp(t,e){let n=t.sliceString(e,e+2);return n.slice(0,ir(In(n,0)))}function yae(t,e){let n=t.sliceString(e-2,e);return ir(In(n,0))==n.length?n:n.slice(1)}function vae(t,e,n,i){let r=null,s=t.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:n,from:o.to}],effects:La.of(o.to+e.length),range:de.range(o.anchor+e.length,o.head+e.length)};let c=Wp(t.doc,o.head);return!c||/\s/.test(c)||i.indexOf(c)>-1?{changes:{insert:e+n,from:o.head},effects:La.of(o.head+e.length),range:de.cursor(o.head+e.length)}:{range:r=o}});return r?null:t.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function bae(t,e,n){let i=null,r=t.changeByRange(s=>s.empty&&Wp(t.doc,s.head)==n?{changes:{from:s.head,to:s.head+n.length,insert:n},range:de.cursor(s.head+n.length)}:i={range:s});return i?null:t.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function xae(t,e,n,i){let r=i.stringPrefixes||_u.stringPrefixes,s=null,o=t.changeByRange(c=>{if(!c.empty)return{changes:[{insert:e,from:c.from},{insert:e,from:c.to}],effects:La.of(c.to+e.length),range:de.range(c.anchor+e.length,c.head+e.length)};let u=c.head,h=Wp(t.doc,u),d;if(h==e){if(r4(t,u))return{changes:{insert:e+e,from:u},effects:La.of(u+e.length),range:de.cursor(u+e.length)};if(Sj(t,u)){let g=n&&t.sliceDoc(u,u+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:u,to:u+g.length,insert:g},range:de.cursor(u+g.length)}}}else{if(n&&t.sliceDoc(u-2*e.length,u)==e+e&&(d=s4(t,u-2*e.length,r))>-1&&r4(t,d))return{changes:{insert:e+e+e+e,from:u},effects:La.of(u+e.length),range:de.cursor(u+e.length)};if(t.charCategorizer(u)(h)!=At.Word&&s4(t,u,r)>-1&&!wae(t,u,e,r))return{changes:{insert:e+e,from:u},effects:La.of(u+e.length),range:de.cursor(u+e.length)}}return{range:s=c}});return s?null:t.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function r4(t,e){let n=Cn(t).resolveInner(e+1);return n.parent&&n.from==e}function wae(t,e,n,i){let r=Cn(t).resolveInner(e,-1),s=i.reduce((o,c)=>Math.max(o,c.length),0);for(let o=0;o<5;o++){let c=t.sliceDoc(r.from,Math.min(r.to,r.from+n.length+s)),u=c.indexOf(n);if(!u||u>-1&&i.indexOf(c.slice(0,u))>-1){let d=r.firstChild;for(;d&&d.from==r.from&&d.to-d.from>n.length+u;){if(t.sliceDoc(d.to-n.length,d.to)==n)return!1;d=d.firstChild}return!0}let h=r.to==e&&r.parent;if(!h)break;r=h}return!1}function s4(t,e,n){let i=t.charCategorizer(e);if(i(t.sliceDoc(e-1,e))!=At.Word)return e;for(let r of n){let s=e-r.length;if(t.sliceDoc(s,e)==r&&i(t.sliceDoc(s-1,s))!=At.Word)return s}return-1}function Sae(t={}){return[cae,Pn,rn.of(t),oae,Cae,uae]}const Cj=[{key:"Ctrl-Space",run:Ow},{mac:"Alt-`",run:Ow},{mac:"Alt-i",run:Ow},{key:"Escape",run:iae},{key:"ArrowDown",run:Jh(!0)},{key:"ArrowUp",run:Jh(!1)},{key:"PageDown",run:Jh(!0,"page")},{key:"PageUp",run:Jh(!1,"page")},{key:"Enter",run:nae}],Cae=Za.highest(Hp.computeN([rn],t=>t.facet(rn).defaultKeymap?[Cj]:[]));class a4{constructor(e,n,i){this.from=e,this.to=n,this.diagnostic=i}}class Ea{constructor(e,n,i){this.diagnostics=e,this.panel=n,this.selected=i}static init(e,n,i){let r=i.facet(Ou).markerFilter;r&&(e=r(e,i));let s=e.slice().sort((y,x)=>y.from-x.from||y.to-x.to),o=new Kr,c=[],u=0,h=i.doc.iter(),d=0,m=i.doc.length;for(let y=0;;){let x=y==s.length?null:s[y];if(!x&&!c.length)break;let w,S;if(c.length)w=u,S=c.reduce((O,E)=>Math.min(O,E.to),x&&x.from>w?x.from:1e8);else{if(w=x.from,w>m)break;S=x.to,c.push(x),y++}for(;y<s.length;){let O=s[y];if(O.from==w&&(O.to>O.from||O.to==w))c.push(O),y++,S=Math.min(O.to,S);else{S=Math.min(O.from,S);break}}S=Math.min(S,m);let C=!1;if(c.some(O=>O.from==w&&(O.to==S||S==m))&&(C=w==S,!C&&S-w<10)){let O=w-(d+h.value.length);O>0&&(h.next(O),d=w);for(let E=w;;){if(E>=S){C=!0;break}if(!h.lineBreak&&d+h.value.length>E)break;E=d+h.value.length,d+=h.value.length,h.next()}}let A=Bae(c);if(C)o.add(w,w,Le.widget({widget:new Nae(A),diagnostics:c.slice()}));else{let O=c.reduce((E,T)=>T.markClass?E+" "+T.markClass:E,"");o.add(w,S,Le.mark({class:"cm-lintRange cm-lintRange-"+A+O,diagnostics:c.slice(),inclusiveEnd:c.some(E=>E.to>S)}))}if(u=S,u==m)break;for(let O=0;O<c.length;O++)c[O].to<=u&&c.splice(O--,1)}let g=o.finish();return new Ea(g,n,Zs(g))}}function Zs(t,e=null,n=0){let i=null;return t.between(n,1e9,(r,s,{spec:o})=>{if(!(e&&o.diagnostics.indexOf(e)<0))if(!i)i=new a4(r,s,e||o.diagnostics[0]);else{if(o.diagnostics.indexOf(i.diagnostic)<0)return!1;i=new a4(i.from,s,i.diagnostic)}}),i}function kae(t,e){let n=e.pos,i=e.end||n,r=t.state.facet(Ou).hideOn(t,n,i);if(r!=null)return r;let s=t.startState.doc.lineAt(e.pos);return!!(t.effects.some(o=>o.is(kj))||t.changes.touchesRange(s.from,Math.max(s.to,i)))}function Aae(t,e){return t.field(oi,!1)?e:e.concat(je.appendConfig.of(qae))}const kj=je.define(),PC=je.define(),Aj=je.define(),oi=_n.define({create(){return new Ea(Le.none,null,null)},update(t,e){if(e.docChanged&&t.diagnostics.size){let n=t.diagnostics.map(e.changes),i=null,r=t.panel;if(t.selected){let s=e.changes.mapPos(t.selected.from,1);i=Zs(n,t.selected.diagnostic,s)||Zs(n,null,s)}!n.size&&r&&e.state.facet(Ou).autoPanel&&(r=null),t=new Ea(n,r,i)}for(let n of e.effects)if(n.is(kj)){let i=e.state.facet(Ou).autoPanel?n.value.length?Eu.open:null:t.panel;t=Ea.init(n.value,i,e.state)}else n.is(PC)?t=new Ea(t.diagnostics,n.value?Eu.open:null,t.selected):n.is(Aj)&&(t=new Ea(t.diagnostics,t.panel,n.value));return t},provide:t=>[xu.from(t,e=>e.panel),Se.decorations.from(t,e=>e.diagnostics)]}),_ae=Le.mark({class:"cm-lintRange cm-lintRange-active"});function Oae(t,e,n){let{diagnostics:i}=t.state.field(oi),r,s=-1,o=-1;i.between(e-(n<0?1:0),e+(n>0?1:0),(u,h,{spec:d})=>{if(e>=u&&e<=h&&(u==h||(e>u||n>0)&&(e<h||n<0)))return r=d.diagnostics,s=u,o=h,!1});let c=t.state.facet(Ou).tooltipFilter;return r&&c&&(r=c(r,t.state)),r?{pos:s,end:o,above:t.state.doc.lineAt(s).to<o,create(){return{dom:Eae(t,r)}}}:null}function Eae(t,e){return dt("ul",{class:"cm-tooltip-lint"},e.map(n=>Oj(t,n,!1)))}const Tae=t=>{let e=t.state.field(oi,!1);(!e||!e.panel)&&t.dispatch({effects:Aae(t.state,[PC.of(!0)])});let n=wC(t,Eu.open);return n&&n.dom.querySelector(".cm-panel-lint ul").focus(),!0},o4=t=>{let e=t.state.field(oi,!1);return!e||!e.panel?!1:(t.dispatch({effects:PC.of(!1)}),!0)},Mae=t=>{let e=t.state.field(oi,!1);if(!e)return!1;let n=t.state.selection.main,i=Zs(e.diagnostics,null,n.to+1);return!i&&(i=Zs(e.diagnostics,null,0),!i||i.from==n.from&&i.to==n.to)?!1:(t.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0}),!0)},Rae=[{key:"Mod-Shift-m",run:Tae,preventDefault:!0},{key:"F8",run:Mae}],Ou=ke.define({combine(t){return{sources:t.map(e=>e.source).filter(e=>e!=null),...pr(t.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:l4,tooltipFilter:l4,needsRefresh:(e,n)=>e?n?i=>e(i)||n(i):e:n,hideOn:(e,n)=>e?n?(i,r,s)=>e(i,r,s)||n(i,r,s):e:n,autoPanel:(e,n)=>e||n})}}});function l4(t,e){return t?e?(n,i)=>e(t(n,i),i):t:e}function _j(t){let e=[];if(t)e:for(let{name:n}of t){for(let i=0;i<n.length;i++){let r=n[i];if(/[a-zA-Z]/.test(r)&&!e.some(s=>s.toLowerCase()==r.toLowerCase())){e.push(r);continue e}}e.push("")}return e}function Oj(t,e,n){var i;let r=n?_j(e.actions):[];return dt("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},dt("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(t):e.message),(i=e.actions)===null||i===void 0?void 0:i.map((s,o)=>{let c=!1,u=y=>{if(y.preventDefault(),c)return;c=!0;let x=Zs(t.state.field(oi).diagnostics,e);x&&s.apply(t,x.from,x.to)},{name:h}=s,d=r[o]?h.indexOf(r[o]):-1,m=d<0?h:[h.slice(0,d),dt("u",h.slice(d,d+1)),h.slice(d+1)],g=s.markClass?" "+s.markClass:"";return dt("button",{type:"button",class:"cm-diagnosticAction"+g,onclick:u,onmousedown:u,"aria-label":` Action: ${h}${d<0?"":` (access key "${r[o]})"`}.`},m)}),e.source&&dt("div",{class:"cm-diagnosticSource"},e.source))}class Nae extends mr{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return dt("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class c4{constructor(e,n){this.diagnostic=n,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=Oj(e,n,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class Eu{constructor(e){this.view=e,this.items=[];let n=r=>{if(!(r.ctrlKey||r.altKey||r.metaKey)){if(r.keyCode==27)o4(this.view),this.view.focus();else if(r.keyCode==38||r.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(r.keyCode==40||r.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(r.keyCode==36)this.moveSelection(0);else if(r.keyCode==35)this.moveSelection(this.items.length-1);else if(r.keyCode==13)this.view.focus();else if(r.keyCode>=65&&r.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:s}=this.items[this.selectedIndex],o=_j(s.actions);for(let c=0;c<o.length;c++)if(o[c].toUpperCase().charCodeAt(0)==r.keyCode){let u=Zs(this.view.state.field(oi).diagnostics,s);u&&s.actions[c].apply(e,u.from,u.to)}}else return;r.preventDefault()}},i=r=>{for(let s=0;s<this.items.length;s++)this.items[s].dom.contains(r.target)&&this.moveSelection(s)};this.list=dt("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:n,onclick:i}),this.dom=dt("div",{class:"cm-panel-lint"},this.list,dt("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>o4(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(oi).selected;if(!e)return-1;for(let n=0;n<this.items.length;n++)if(this.items[n].diagnostic==e.diagnostic)return n;return-1}update(){let{diagnostics:e,selected:n}=this.view.state.field(oi),i=0,r=!1,s=null,o=new Set;for(e.between(0,this.view.state.doc.length,(c,u,{spec:h})=>{for(let d of h.diagnostics){if(o.has(d))continue;o.add(d);let m=-1,g;for(let y=i;y<this.items.length;y++)if(this.items[y].diagnostic==d){m=y;break}m<0?(g=new c4(this.view,d),this.items.splice(i,0,g),r=!0):(g=this.items[m],m>i&&(this.items.splice(i,m-i),r=!0)),n&&g.diagnostic==n.diagnostic?g.dom.hasAttribute("aria-selected")||(g.dom.setAttribute("aria-selected","true"),s=g):g.dom.hasAttribute("aria-selected")&&g.dom.removeAttribute("aria-selected"),i++}});i<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();this.items.length==0&&(this.items.push(new c4(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),r=!0),s?(this.list.setAttribute("aria-activedescendant",s.id),this.view.requestMeasure({key:this,read:()=>({sel:s.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:c,panel:u})=>{let h=u.height/this.list.offsetHeight;c.top<u.top?this.list.scrollTop-=(u.top-c.top)/h:c.bottom>u.bottom&&(this.list.scrollTop+=(c.bottom-u.bottom)/h)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),r&&this.sync()}sync(){let e=this.list.firstChild;function n(){let i=e;e=i.nextSibling,i.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;e!=i.dom;)n();e=i.dom.nextSibling}else this.list.insertBefore(i.dom,e);for(;e;)n()}moveSelection(e){if(this.selectedIndex<0)return;let n=this.view.state.field(oi),i=Zs(n.diagnostics,this.items[e].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:Aj.of(i)})}static open(e){return new Eu(e)}}function Dae(t,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(t)}</svg>')`}function ed(t){return Dae(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${t}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const Lae=Se.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:ed("#d11")},".cm-lintRange-warning":{backgroundImage:ed("orange")},".cm-lintRange-info":{backgroundImage:ed("#999")},".cm-lintRange-hint":{backgroundImage:ed("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:"#86714a80"},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:"#2e343e"}}});function zae(t){return t=="error"?4:t=="warning"?3:t=="info"?2:1}function Bae(t){let e="hint",n=1;for(let i of t){let r=zae(i.severity);r>n&&(n=r,e=i.severity)}return e}const qae=[oi,Se.decorations.compute([oi],t=>{let{selected:e,panel:n}=t.field(oi);return!e||!n||e.from==e.to?Le.none:Le.set([_ae.range(e.from,e.to)])}),One(Oae,{hideOn:kae}),Lae];var u4=function(e){e===void 0&&(e={});var{crosshairCursor:n=!1}=e,i=[];e.closeBracketsKeymap!==!1&&(i=i.concat(mae)),e.defaultKeymap!==!1&&(i=i.concat(ose)),e.searchKeymap!==!1&&(i=i.concat(Lse)),e.historyKeymap!==!1&&(i=i.concat(pre)),e.foldKeymap!==!1&&(i=i.concat(Eie)),e.completionKeymap!==!1&&(i=i.concat(Cj)),e.lintKeymap!==!1&&(i=i.concat(Rae));var r=[];return e.lineNumbers!==!1&&r.push(Pne()),e.highlightActiveLineGutter!==!1&&r.push(Vne()),e.highlightSpecialChars!==!1&&r.push(nne()),e.history!==!1&&r.push(sre()),e.foldGutter!==!1&&r.push(Nie()),e.drawSelection!==!1&&r.push($te()),e.dropCursor!==!1&&r.push(Wte()),e.allowMultipleSelections!==!1&&r.push(Je.allowMultipleSelections.of(!0)),e.indentOnInput!==!1&&r.push(vie()),e.syntaxHighlighting!==!1&&r.push(kq(Bie,{fallback:!0})),e.bracketMatching!==!1&&r.push(Vie()),e.closeBrackets!==!1&&r.push(fae()),e.autocompletion!==!1&&r.push(Sae()),e.rectangularSelection!==!1&&r.push(gne()),n!==!1&&r.push(bne()),e.highlightActiveLine!==!1&&r.push(lne()),e.highlightSelectionMatches!==!1&&r.push(dse()),e.tabSize&&typeof e.tabSize=="number"&&r.push(Vp.of(" ".repeat(e.tabSize))),r.concat([Hp.of(i.flat())]).filter(Boolean)};const jae="#e5c07b",f4="#e06c75",Iae="#56b6c2",Pae="#ffffff",dd="#abb2bf",n2="#7d8799",Hae="#61afef",Uae="#98c379",h4="#d19a66",Vae="#c678dd",Fae="#21252b",d4="#2c313a",p4="#282c34",Tw="#353a42",$ae="#3E4451",m4="#528bff",Gae=Se.theme({"&":{color:dd,backgroundColor:p4},".cm-content":{caretColor:m4},".cm-cursor, .cm-dropCursor":{borderLeftColor:m4},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:$ae},".cm-panels":{backgroundColor:Fae,color:dd},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:p4,color:n2,border:"none"},".cm-activeLineGutter":{backgroundColor:d4},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:Tw},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:Tw,borderBottomColor:Tw},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:d4,color:dd}}},{dark:!0}),Yae=$u.define([{tag:le.keyword,color:Vae},{tag:[le.name,le.deleted,le.character,le.propertyName,le.macroName],color:f4},{tag:[le.function(le.variableName),le.labelName],color:Hae},{tag:[le.color,le.constant(le.name),le.standard(le.name)],color:h4},{tag:[le.definition(le.name),le.separator],color:dd},{tag:[le.typeName,le.className,le.number,le.changed,le.annotation,le.modifier,le.self,le.namespace],color:jae},{tag:[le.operator,le.operatorKeyword,le.url,le.escape,le.regexp,le.link,le.special(le.string)],color:Iae},{tag:[le.meta,le.comment],color:n2},{tag:le.strong,fontWeight:"bold"},{tag:le.emphasis,fontStyle:"italic"},{tag:le.strikethrough,textDecoration:"line-through"},{tag:le.link,color:n2,textDecoration:"underline"},{tag:le.heading,fontWeight:"bold",color:f4},{tag:[le.atom,le.bool,le.special(le.variableName)],color:h4},{tag:[le.processingInstruction,le.string,le.inserted],color:Uae},{tag:le.invalid,color:Pae}]),Ej=[Gae,kq(Yae)];var Qae=Se.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),Xae=function(e){e===void 0&&(e={});var{indentWithTab:n=!0,editable:i=!0,readOnly:r=!1,theme:s="light",placeholder:o="",basicSetup:c=!0}=e,u=[];switch(n&&u.unshift(Hp.of([lse])),c&&(typeof c=="boolean"?u.unshift(u4()):u.unshift(u4(c))),o&&u.unshift(hne(o)),s){case"light":u.push(Qae);break;case"dark":u.push(Ej);break;case"none":break;default:u.push(s);break}return i===!1&&u.push(Se.editable.of(!1)),r&&u.push(Je.readOnly.of(!0)),[...u]},Wae=t=>({line:t.state.doc.lineAt(t.state.selection.main.from),lineCount:t.state.doc.lines,lineBreak:t.state.lineBreak,length:t.state.doc.length,readOnly:t.state.readOnly,tabSize:t.state.tabSize,selection:t.state.selection,selectionAsSingle:t.state.selection.asSingle().main,ranges:t.state.selection.ranges,selectionCode:t.state.sliceDoc(t.state.selection.main.from,t.state.selection.main.to),selections:t.state.selection.ranges.map(e=>t.state.sliceDoc(e.from,e.to)),selectedText:t.state.selection.ranges.some(e=>!e.empty)});class Kae{constructor(e,n){this.timeLeftMS=void 0,this.timeoutMS=void 0,this.isCancelled=!1,this.isTimeExhausted=!1,this.callbacks=[],this.timeLeftMS=n,this.timeoutMS=n,this.callbacks.push(e)}tick(){if(!this.isCancelled&&!this.isTimeExhausted&&(this.timeLeftMS--,this.timeLeftMS<=0)){this.isTimeExhausted=!0;var e=this.callbacks.slice();this.callbacks.length=0,e.forEach(n=>{try{n()}catch(i){console.error("TimeoutLatch callback error:",i)}})}}cancel(){this.isCancelled=!0,this.callbacks.length=0}reset(){this.timeLeftMS=this.timeoutMS,this.isCancelled=!1,this.isTimeExhausted=!1}get isDone(){return this.isCancelled||this.isTimeExhausted}}class g4{constructor(){this.interval=null,this.latches=new Set}add(e){this.latches.add(e),this.start()}remove(e){this.latches.delete(e),this.latches.size===0&&this.stop()}start(){this.interval===null&&(this.interval=setInterval(()=>{this.latches.forEach(e=>{e.tick(),e.isDone&&this.remove(e)})},1))}stop(){this.interval!==null&&(clearInterval(this.interval),this.interval=null)}}var Mw=null,Zae=()=>typeof window>"u"?new g4:(Mw||(Mw=new g4),Mw),y4=dr.define(),Jae=200,eoe=[];function toe(t){var{value:e,selection:n,onChange:i,onStatistics:r,onCreateEditor:s,onUpdate:o,extensions:c=eoe,autoFocus:u,theme:h="light",height:d=null,minHeight:m=null,maxHeight:g=null,width:y=null,minWidth:x=null,maxWidth:w=null,placeholder:S="",editable:C=!0,readOnly:A=!1,indentWithTab:O=!0,basicSetup:E=!0,root:T,initialState:M}=t,[R,z]=j.useState(),[q,U]=j.useState(),[P,$]=j.useState(),K=j.useState(()=>({current:null}))[0],L=j.useState(()=>({current:null}))[0],Y=Se.theme({"&":{height:d,minHeight:m,maxHeight:g,width:y,minWidth:x,maxWidth:w},"& .cm-scroller":{height:"100% !important"}}),D=Se.updateListener.of(G=>{if(G.docChanged&&typeof i=="function"&&!G.transactions.some(F=>F.annotation(y4))){K.current?K.current.reset():(K.current=new Kae(()=>{if(L.current){var F=L.current;L.current=null,F()}K.current=null},Jae),Zae().add(K.current));var W=G.state.doc,B=W.toString();i(B,G)}r&&r(Wae(G))}),Q=Xae({theme:h,editable:C,readOnly:A,placeholder:S,indentWithTab:O,basicSetup:E}),ee=[D,Y,...Q];return o&&typeof o=="function"&&ee.push(Se.updateListener.of(o)),ee=ee.concat(c),j.useLayoutEffect(()=>{if(R&&!P){var G={doc:e,selection:n,extensions:ee},W=M?Je.fromJSON(M.json,G,M.fields):Je.create(G);if($(W),!q){var B=new Se({state:W,parent:R,root:T});U(B),s&&s(B,W)}}return()=>{q&&($(void 0),U(void 0))}},[R,P]),j.useEffect(()=>{t.container&&z(t.container)},[t.container]),j.useEffect(()=>()=>{q&&(q.destroy(),U(void 0)),K.current&&(K.current.cancel(),K.current=null)},[q]),j.useEffect(()=>{u&&q&&q.focus()},[u,q]),j.useEffect(()=>{q&&q.dispatch({effects:je.reconfigure.of(ee)})},[h,c,d,m,g,y,x,w,S,C,A,O,E,i,o]),j.useEffect(()=>{if(e!==void 0){var G=q?q.state.doc.toString():"";if(q&&e!==G){var W=K.current&&!K.current.isDone,B=()=>{q&&e!==q.state.doc.toString()&&q.dispatch({changes:{from:0,to:q.state.doc.toString().length,insert:e||""},annotations:[y4.of(!0)]})};W?L.current=B:B()}}},[e,q]),{state:P,setState:$,view:q,setView:U,container:R,setContainer:z}}var noe=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],Tj=j.forwardRef((t,e)=>{var{className:n,value:i="",selection:r,extensions:s=[],onChange:o,onStatistics:c,onCreateEditor:u,onUpdate:h,autoFocus:d,theme:m="light",height:g,minHeight:y,maxHeight:x,width:w,minWidth:S,maxWidth:C,basicSetup:A,placeholder:O,indentWithTab:E,editable:T,readOnly:M,root:R,initialState:z}=t,q=NJ(t,noe),U=j.useRef(null),{state:P,view:$,container:K,setContainer:L}=toe({root:R,value:i,autoFocus:d,theme:m,height:g,minHeight:y,maxHeight:x,width:w,minWidth:S,maxWidth:C,basicSetup:A,placeholder:O,indentWithTab:E,editable:T,readOnly:M,selection:r,onChange:o,onStatistics:c,onCreateEditor:u,onUpdate:h,extensions:s,initialState:z});j.useImperativeHandle(e,()=>({editor:U.current,state:P,view:$}),[U,K,P,$]);var Y=j.useCallback(Q=>{U.current=Q,L(Q)},[L]);if(typeof i!="string")throw new Error("value must be typeof string but got "+typeof i);var D=typeof m=="string"?"cm-theme-"+m:"cm-theme";return k.jsx("div",cS({ref:Y,className:""+D+(n?" "+n:"")},q))});Tj.displayName="CodeMirror";var v4={};class ap{constructor(e,n,i,r,s,o,c,u,h,d=0,m){this.p=e,this.stack=n,this.state=i,this.reducePos=r,this.pos=s,this.score=o,this.buffer=c,this.bufferBase=u,this.curContext=h,this.lookAhead=d,this.parent=m}toString(){return`[${this.stack.filter((e,n)=>n%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,n,i=0){let r=e.parser.context;return new ap(e,[],n,i,i,0,[],0,r?new b4(r,r.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,n){this.stack.push(this.state,n,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var n;let i=e>>19,r=e&65535,{parser:s}=this.p,o=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),c=s.dynamicPrecedence(r);if(c&&(this.score+=c),i==0){this.pushState(s.getGoto(this.state,r,!0),this.reducePos),r<s.minRepeatTerm&&this.storeNode(r,this.reducePos,this.reducePos,o?8:4,!0),this.reduceContext(r,this.reducePos);return}let u=this.stack.length-(i-1)*3-(e&262144?6:0),h=u?this.stack[u-2]:this.p.ranges[0].from,d=this.reducePos-h;d>=2e3&&!(!((n=this.p.parser.nodeSet.types[r])===null||n===void 0)&&n.isAnonymous)&&(h==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=d):this.p.lastBigReductionSize<d&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=h,this.p.lastBigReductionSize=d));let m=u?this.stack[u-1]:0,g=this.bufferBase+this.buffer.length-m;if(r<s.minRepeatTerm||e&131072){let y=s.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(r,h,y,g+4,!0)}if(e&262144)this.state=this.stack[u];else{let y=this.stack[u-3];this.state=s.getGoto(y,r,!0)}for(;this.stack.length>u;)this.stack.pop();this.reduceContext(r,h)}storeNode(e,n,i,r=4,s=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let o=this,c=this.buffer.length;if(c==0&&o.parent&&(c=o.bufferBase-o.parent.bufferBase,o=o.parent),c>0&&o.buffer[c-4]==0&&o.buffer[c-1]>-1){if(n==i)return;if(o.buffer[c-2]>=n){o.buffer[c-2]=i;return}}}if(!s||this.pos==i)this.buffer.push(e,n,i,r);else{let o=this.buffer.length;if(o>0&&(this.buffer[o-4]!=0||this.buffer[o-1]<0)){let c=!1;for(let u=o;u>0&&this.buffer[u-2]>i;u-=4)if(this.buffer[u-1]>=0){c=!0;break}if(c)for(;o>0&&this.buffer[o-2]>i;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,r>4&&(r-=4)}this.buffer[o]=e,this.buffer[o+1]=n,this.buffer[o+2]=i,this.buffer[o+3]=r}}shift(e,n,i,r){if(e&131072)this.pushState(e&65535,this.pos);else if((e&262144)==0){let s=e,{parser:o}=this.p;this.pos=r;let c=o.stateFlag(s,1);!c&&(r>i||n<=o.maxNode)&&(this.reducePos=r),this.pushState(s,c?i:Math.min(i,this.reducePos)),this.shiftContext(n,i),n<=o.maxNode&&this.buffer.push(n,i,r,4)}else this.pos=r,this.shiftContext(n,i),n<=this.p.parser.maxNode&&this.buffer.push(n,i,r,4)}apply(e,n,i,r){e&65536?this.reduce(e):this.shift(e,n,i,r)}useNode(e,n){let i=this.p.reused.length-1;(i<0||this.p.reused[i]!=e)&&(this.p.reused.push(e),i++);let r=this.pos;this.reducePos=this.pos=r+e.length,this.pushState(n,r),this.buffer.push(i,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 e=this,n=e.buffer.length;for(;n>0&&e.buffer[n-2]>e.reducePos;)n-=4;let i=e.buffer.slice(n),r=e.bufferBase+n;for(;e&&r==e.bufferBase;)e=e.parent;return new ap(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,r,this.curContext,this.lookAhead,e)}recoverByDelete(e,n){let i=e<=this.p.parser.maxNode;i&&this.storeNode(e,this.pos,n,4),this.storeNode(0,this.pos,n,i?8:4),this.pos=this.reducePos=n,this.score-=190}canShift(e){for(let n=new ioe(this);;){let i=this.p.parser.stateSlot(n.state,4)||this.p.parser.hasAction(n.state,e);if(i==0)return!1;if((i&65536)==0)return!0;n.reduce(i)}}recoverByInsert(e){if(this.stack.length>=300)return[];let n=this.p.parser.nextStates(this.state);if(n.length>8||this.stack.length>=120){let r=[];for(let s=0,o;s<n.length;s+=2)(o=n[s+1])!=this.state&&this.p.parser.hasAction(o,e)&&r.push(n[s],o);if(this.stack.length<120)for(let s=0;r.length<8&&s<n.length;s+=2){let o=n[s+1];r.some((c,u)=>u&1&&c==o)||r.push(n[s],o)}n=r}let i=[];for(let r=0;r<n.length&&i.length<4;r+=2){let s=n[r+1];if(s==this.state)continue;let o=this.split();o.pushState(s,this.pos),o.storeNode(0,o.pos,o.pos,4,!0),o.shiftContext(n[r],this.pos),o.reducePos=this.pos,o.score-=200,i.push(o)}return i}forceReduce(){let{parser:e}=this.p,n=e.stateSlot(this.state,5);if((n&65536)==0)return!1;if(!e.validAction(this.state,n)){let i=n>>19,r=n&65535,s=this.stack.length-i*3;if(s<0||e.getGoto(this.stack[s],r,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;n=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(n),!0}findForcedReduction(){let{parser:e}=this.p,n=[],i=(r,s)=>{if(!n.includes(r))return n.push(r),e.allActions(r,o=>{if(!(o&393216))if(o&65536){let c=(o>>19)-s;if(c>1){let u=o&65535,h=this.stack.length-c*3;if(h>=0&&e.getGoto(this.stack[h],u,!1)>=0)return c<<19|65536|u}}else{let c=i(o,s+1);if(c!=null)return c}})};return i(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 n=0;n<this.stack.length;n+=3)if(this.stack[n]!=e.stack[n])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,n){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(n)))}reduceContext(e,n){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(n)))}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 n=new b4(this.curContext.tracker,e);n.hash!=this.curContext.hash&&this.emitContext(),this.curContext=n}}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()}}class b4{constructor(e,n){this.tracker=e,this.context=n,this.hash=e.strict?e.hash(n):0}}class ioe{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let n=e&65535,i=e>>19;i==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(i-1)*3;let r=this.start.p.parser.getGoto(this.stack[this.base-3],n,!0);this.state=r}}class op{constructor(e,n,i){this.stack=e,this.pos=n,this.index=i,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,n=e.bufferBase+e.buffer.length){return new op(e,n,n-e.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 op(this.stack,this.pos,this.index)}}function td(t,e=Uint16Array){if(typeof t!="string")return t;let n=null;for(let i=0,r=0;i<t.length;){let s=0;for(;;){let o=t.charCodeAt(i++),c=!1;if(o==126){s=65535;break}o>=92&&o--,o>=34&&o--;let u=o-32;if(u>=46&&(u-=46,c=!0),s+=u,c)break;s*=46}n?n[r++]=s:n=new e(s)}return n}class pd{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const x4=new pd;class roe{constructor(e,n){this.input=e,this.ranges=n,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=x4,this.rangeIndex=0,this.pos=this.chunkPos=n[0].from,this.range=n[0],this.end=n[n.length-1].to,this.readNext()}resolveOffset(e,n){let i=this.range,r=this.rangeIndex,s=this.pos+e;for(;s<i.from;){if(!r)return null;let o=this.ranges[--r];s-=i.from-o.to,i=o}for(;n<0?s>i.to:s>=i.to;){if(r==this.ranges.length-1)return null;let o=this.ranges[++r];s+=o.from-i.to,i=o}return s}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let n of this.ranges)if(n.to>e)return Math.max(e,n.from);return this.end}peek(e){let n=this.chunkOff+e,i,r;if(n>=0&&n<this.chunk.length)i=this.pos+e,r=this.chunk.charCodeAt(n);else{let s=this.resolveOffset(e,1);if(s==null)return-1;if(i=s,i>=this.chunk2Pos&&i<this.chunk2Pos+this.chunk2.length)r=this.chunk2.charCodeAt(i-this.chunk2Pos);else{let o=this.rangeIndex,c=this.range;for(;c.to<=i;)c=this.ranges[++o];this.chunk2=this.input.chunk(this.chunk2Pos=i),i+this.chunk2.length>c.to&&(this.chunk2=this.chunk2.slice(0,c.to-i)),r=this.chunk2.charCodeAt(0)}}return i>=this.token.lookAhead&&(this.token.lookAhead=i+1),r}acceptToken(e,n=0){let i=n?this.resolveOffset(n,-1):this.pos;if(i==null||i<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=i}acceptTokenTo(e,n){this.token.value=e,this.token.end=n}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:n}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=n,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),n=this.pos+e.length;this.chunk=n>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,n){if(n?(this.token=n,n.start=e,n.lookAhead=e+1,n.value=n.extended=-1):this.token=x4,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,n){if(e>=this.chunkPos&&n<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,n-this.chunkPos);if(e>=this.chunk2Pos&&n<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,n-this.chunk2Pos);if(e>=this.range.from&&n<=this.range.to)return this.input.read(e,n);let i="";for(let r of this.ranges){if(r.from>=n)break;r.to>e&&(i+=this.input.read(Math.max(r.from,e),Math.min(r.to,n)))}return i}}class cl{constructor(e,n){this.data=e,this.id=n}token(e,n){let{parser:i}=n.p;soe(this.data,e,n,this.id,i.data,i.tokenPrecTable)}}cl.prototype.contextual=cl.prototype.fallback=cl.prototype.extend=!1;cl.prototype.fallback=cl.prototype.extend=!1;class Kp{constructor(e,n={}){this.token=e,this.contextual=!!n.contextual,this.fallback=!!n.fallback,this.extend=!!n.extend}}function soe(t,e,n,i,r,s){let o=0,c=1<<i,{dialect:u}=n.p.parser;e:for(;(c&t[o])!=0;){let h=t[o+1];for(let y=o+3;y<h;y+=2)if((t[y+1]&c)>0){let x=t[y];if(u.allows(x)&&(e.token.value==-1||e.token.value==x||aoe(x,e.token.value,r,s))){e.acceptToken(x);break}}let d=e.next,m=0,g=t[o+2];if(e.next<0&&g>m&&t[h+g*3-3]==65535){o=t[h+g*3-1];continue e}for(;m<g;){let y=m+g>>1,x=h+y+(y<<1),w=t[x],S=t[x+1]||65536;if(d<w)g=y;else if(d>=S)m=y+1;else{o=t[x+2],e.advance();continue e}}break}}function w4(t,e,n){for(let i=e,r;(r=t[i])!=65535;i++)if(r==n)return i-e;return-1}function aoe(t,e,n,i){let r=w4(n,i,e);return r<0||w4(n,i,t)<r}const si=typeof process<"u"&&v4&&/\bparse\b/.test(v4.LOG);let Rw=null;function S4(t,e,n){let i=t.cursor(Nt.IncludeAnonymous);for(i.moveTo(e);;)if(!(n<0?i.childBefore(e):i.childAfter(e)))for(;;){if((n<0?i.to<e:i.from>e)&&!i.type.isError)return n<0?Math.max(0,Math.min(i.to-1,e-25)):Math.min(t.length,Math.max(i.from+1,e+25));if(n<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return n<0?0:t.length}}class ooe{constructor(e,n){this.fragments=e,this.nodeSet=n,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?S4(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?S4(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 n=this.trees.length-1;if(n<0)return this.nextFragment(),null;let i=this.trees[n],r=this.index[n];if(r==i.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let s=i.children[r],o=this.start[n]+i.positions[r];if(o>e)return this.nextStart=o,null;if(s instanceof It){if(o==e){if(o<this.safeFrom)return null;let c=o+s.length;if(c<=this.safeTo){let u=s.prop(Fe.lookAhead);if(!u||c+u<this.fragment.to)return s}}this.index[n]++,o+s.length>=Math.max(this.safeFrom,e)&&(this.trees.push(s),this.start.push(o),this.index.push(0))}else this.index[n]++,this.nextStart=o+s.length}}}class loe{constructor(e,n){this.stream=n,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(i=>new pd)}getActions(e){let n=0,i=null,{parser:r}=e.p,{tokenizers:s}=r,o=r.stateSlot(e.state,3),c=e.curContext?e.curContext.hash:0,u=0;for(let h=0;h<s.length;h++){if((1<<h&o)==0)continue;let d=s[h],m=this.tokens[h];if(!(i&&!d.fallback)&&((d.contextual||m.start!=e.pos||m.mask!=o||m.context!=c)&&(this.updateCachedToken(m,d,e),m.mask=o,m.context=c),m.lookAhead>m.end+25&&(u=Math.max(m.lookAhead,u)),m.value!=0)){let g=n;if(m.extended>-1&&(n=this.addActions(e,m.extended,m.end,n)),n=this.addActions(e,m.value,m.end,n),!d.extend&&(i=m,n>g))break}}for(;this.actions.length>n;)this.actions.pop();return u&&e.setLookAhead(u),!i&&e.pos==this.stream.end&&(i=new pd,i.value=e.p.parser.eofTerm,i.start=i.end=e.pos,n=this.addActions(e,i.value,i.end,n)),this.mainToken=i,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let n=new pd,{pos:i,p:r}=e;return n.start=i,n.end=Math.min(i+1,r.stream.end),n.value=i==r.stream.end?r.parser.eofTerm:0,n}updateCachedToken(e,n,i){let r=this.stream.clipPos(i.pos);if(n.token(this.stream.reset(r,e),i),e.value>-1){let{parser:s}=i.p;for(let o=0;o<s.specialized.length;o++)if(s.specialized[o]==e.value){let c=s.specializers[o](this.stream.read(e.start,e.end),i);if(c>=0&&i.p.parser.dialect.allows(c>>1)){(c&1)==0?e.value=c>>1:e.extended=c>>1;break}}}else e.value=0,e.end=this.stream.clipPos(r+1)}putAction(e,n,i,r){for(let s=0;s<r;s+=3)if(this.actions[s]==e)return r;return this.actions[r++]=e,this.actions[r++]=n,this.actions[r++]=i,r}addActions(e,n,i,r){let{state:s}=e,{parser:o}=e.p,{data:c}=o;for(let u=0;u<2;u++)for(let h=o.stateSlot(s,u?2:1);;h+=3){if(c[h]==65535)if(c[h+1]==1)h=Vr(c,h+2);else{r==0&&c[h+1]==2&&(r=this.putAction(Vr(c,h+2),n,i,r));break}c[h]==n&&(r=this.putAction(Vr(c,h+1),n,i,r))}return r}}class coe{constructor(e,n,i,r){this.parser=e,this.input=n,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 roe(n,r),this.tokens=new loe(e,this.stream),this.topTerm=e.top[1];let{from:s}=r[0];this.stacks=[ap.start(this,e.top[0],s)],this.fragments=i.length&&this.stream.end-s>e.bufferLength*4?new ooe(i,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,n=this.minStackPos,i=this.stacks=[],r,s;if(this.bigReductionCount>300&&e.length==1){let[o]=e;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;o<e.length;o++){let c=e[o];for(;;){if(this.tokens.mainToken=null,c.pos>n)i.push(c);else{if(this.advanceStack(c,i,e))continue;{r||(r=[],s=[]),r.push(c);let u=this.tokens.getMainToken(c);s.push(u.value,u.end)}}break}}if(!i.length){let o=r&&hoe(r);if(o)return si&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw si&&r&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+n);this.recovering||(this.recovering=5)}if(this.recovering&&r){let o=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,s,i);if(o)return si&&console.log("Force-finish "+this.stackID(o)),this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(i.length>o)for(i.sort((c,u)=>u.score-c.score);i.length>o;)i.pop();i.some(c=>c.reducePos>n)&&this.recovering--}else if(i.length>1){e:for(let o=0;o<i.length-1;o++){let c=i[o];for(let u=o+1;u<i.length;u++){let h=i[u];if(c.sameState(h)||c.buffer.length>500&&h.buffer.length>500)if((c.score-h.score||c.buffer.length-h.buffer.length)>0)i.splice(u--,1);else{i.splice(o--,1);continue e}}}i.length>12&&(i.sort((o,c)=>c.score-o.score),i.splice(12,i.length-12))}this.minStackPos=i[0].pos;for(let o=1;o<i.length;o++)i[o].pos<this.minStackPos&&(this.minStackPos=i[o].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,n,i){let r=e.pos,{parser:s}=this,o=si?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&r>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let h=e.curContext&&e.curContext.tracker.strict,d=h?e.curContext.hash:0;for(let m=this.fragments.nodeAt(r);m;){let g=this.parser.nodeSet.types[m.type.id]==m.type?s.getGoto(e.state,m.type.id):-1;if(g>-1&&m.length&&(!h||(m.prop(Fe.contextHash)||0)==d))return e.useNode(m,g),si&&console.log(o+this.stackID(e)+` (via reuse of ${s.getName(m.type.id)})`),!0;if(!(m instanceof It)||m.children.length==0||m.positions[0]>0)break;let y=m.children[0];if(y instanceof It&&m.positions[0]==0)m=y;else break}}let c=s.stateSlot(e.state,4);if(c>0)return e.reduce(c),si&&console.log(o+this.stackID(e)+` (via always-reduce ${s.getName(c&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let u=this.tokens.getActions(e);for(let h=0;h<u.length;){let d=u[h++],m=u[h++],g=u[h++],y=h==u.length||!i,x=y?e:e.split(),w=this.tokens.mainToken;if(x.apply(d,m,w?w.start:x.pos,g),si&&console.log(o+this.stackID(x)+` (via ${(d&65536)==0?"shift":`reduce of ${s.getName(d&65535)}`} for ${s.getName(m)} @ ${r}${x==e?"":", split"})`),y)return!0;x.pos>r?n.push(x):i.push(x)}return!1}advanceFully(e,n){let i=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>i)return C4(e,n),!0}}runRecovery(e,n,i){let r=null,s=!1;for(let o=0;o<e.length;o++){let c=e[o],u=n[o<<1],h=n[(o<<1)+1],d=si?this.stackID(c)+" -> ":"";if(c.deadEnd&&(s||(s=!0,c.restart(),si&&console.log(d+this.stackID(c)+" (restarted)"),this.advanceFully(c,i))))continue;let m=c.split(),g=d;for(let y=0;y<10&&m.forceReduce()&&(si&&console.log(g+this.stackID(m)+" (via force-reduce)"),!this.advanceFully(m,i));y++)si&&(g=this.stackID(m)+" -> ");for(let y of c.recoverByInsert(u))si&&console.log(d+this.stackID(y)+" (via recover-insert)"),this.advanceFully(y,i);this.stream.end>c.pos?(h==c.pos&&(h++,u=0),c.recoverByDelete(u,h),si&&console.log(d+this.stackID(c)+` (via recover-delete ${this.parser.getName(u)})`),C4(c,i)):(!r||r.score<m.score)&&(r=m)}return r}stackToTree(e){return e.close(),It.build({buffer:op.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 n=(Rw||(Rw=new WeakMap)).get(e);return n||Rw.set(e,n=String.fromCodePoint(this.nextStackID++)),n+e}}function C4(t,e){for(let n=0;n<e.length;n++){let i=e[n];if(i.pos==t.pos&&i.sameState(t)){e[n].score<t.score&&(e[n]=t);return}}e.push(t)}class uoe{constructor(e,n,i){this.source=e,this.flags=n,this.disabled=i}allows(e){return!this.disabled||this.disabled[e]==0}}const Nw=t=>t;class foe{constructor(e){this.start=e.start,this.shift=e.shift||Nw,this.reduce=e.reduce||Nw,this.reuse=e.reuse||Nw,this.hash=e.hash||(()=>0),this.strict=e.strict!==!1}}class lp extends oq{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let n=e.nodeNames.split(" ");this.minRepeatTerm=n.length;for(let c=0;c<e.repeatNodeCount;c++)n.push("");let i=Object.keys(e.topRules).map(c=>e.topRules[c][1]),r=[];for(let c=0;c<n.length;c++)r.push([]);function s(c,u,h){r[c].push([u,u.deserialize(String(h))])}if(e.nodeProps)for(let c of e.nodeProps){let u=c[0];typeof u=="string"&&(u=Fe[u]);for(let h=1;h<c.length;){let d=c[h++];if(d>=0)s(d,u,c[h++]);else{let m=c[h+-d];for(let g=-d;g>0;g--)s(c[h++],u,m);h++}}}this.nodeSet=new SC(n.map((c,u)=>Xn.define({name:u>=this.minRepeatTerm?void 0:c,id:u,props:r[u],top:i.indexOf(u)>-1,error:u==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(u)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=iq;let o=td(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let c=0;c<this.specializerSpecs.length;c++)this.specialized[c]=this.specializerSpecs[c].term;this.specializers=this.specializerSpecs.map(k4),this.states=td(e.states,Uint32Array),this.data=td(e.stateData),this.goto=td(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(c=>typeof c=="number"?new cl(o,c):c),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,n,i){let r=new coe(this,e,n,i);for(let s of this.wrappers)r=s(r,e,n,i);return r}getGoto(e,n,i=!1){let r=this.goto;if(n>=r[0])return-1;for(let s=r[n+1];;){let o=r[s++],c=o&1,u=r[s++];if(c&&i)return u;for(let h=s+(o>>1);s<h;s++)if(r[s]==e)return u;if(c)return-1}}hasAction(e,n){let i=this.data;for(let r=0;r<2;r++)for(let s=this.stateSlot(e,r?2:1),o;;s+=3){if((o=i[s])==65535)if(i[s+1]==1)o=i[s=Vr(i,s+2)];else{if(i[s+1]==2)return Vr(i,s+2);break}if(o==n||o==0)return Vr(i,s+1)}return 0}stateSlot(e,n){return this.states[e*6+n]}stateFlag(e,n){return(this.stateSlot(e,0)&n)>0}validAction(e,n){return!!this.allActions(e,i=>i==n?!0:null)}allActions(e,n){let i=this.stateSlot(e,4),r=i?n(i):void 0;for(let s=this.stateSlot(e,1);r==null;s+=3){if(this.data[s]==65535)if(this.data[s+1]==1)s=Vr(this.data,s+2);else break;r=n(Vr(this.data,s+1))}return r}nextStates(e){let n=[];for(let i=this.stateSlot(e,1);;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=Vr(this.data,i+2);else break;if((this.data[i+2]&1)==0){let r=this.data[i+1];n.some((s,o)=>o&1&&s==r)||n.push(this.data[i],r)}}return n}configure(e){let n=Object.assign(Object.create(lp.prototype),this);if(e.props&&(n.nodeSet=this.nodeSet.extend(...e.props)),e.top){let i=this.topRules[e.top];if(!i)throw new RangeError(`Invalid top rule name ${e.top}`);n.top=i}return e.tokenizers&&(n.tokenizers=this.tokenizers.map(i=>{let r=e.tokenizers.find(s=>s.from==i);return r?r.to:i})),e.specializers&&(n.specializers=this.specializers.slice(),n.specializerSpecs=this.specializerSpecs.map((i,r)=>{let s=e.specializers.find(c=>c.from==i.external);if(!s)return i;let o=Object.assign(Object.assign({},i),{external:s.to});return n.specializers[r]=k4(o),o})),e.contextTracker&&(n.context=e.contextTracker),e.dialect&&(n.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(n.strict=e.strict),e.wrap&&(n.wrappers=n.wrappers.concat(e.wrap)),e.bufferLength!=null&&(n.bufferLength=e.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 n=this.dynamicPrecedences;return n==null?0:n[e]||0}parseDialect(e){let n=Object.keys(this.dialects),i=n.map(()=>!1);if(e)for(let s of e.split(" ")){let o=n.indexOf(s);o>=0&&(i[o]=!0)}let r=null;for(let s=0;s<n.length;s++)if(!i[s])for(let o=this.dialects[n[s]],c;(c=this.data[o++])!=65535;)(r||(r=new Uint8Array(this.maxTerm+1)))[c]=1;return new uoe(e,i,r)}static deserialize(e){return new lp(e)}}function Vr(t,e){return t[e]|t[e+1]<<16}function hoe(t){let e=null;for(let n of t){let i=n.p.stoppedAt;(n.pos==n.p.stream.end||i!=null&&n.pos>i)&&n.p.parser.stateFlag(n.state,2)&&(!e||e.score<n.score)&&(e=n)}return e}function k4(t){if(t.external){let e=t.extend?1:0;return(n,i)=>t.external(n,i)<<1|e}return t.get}const Uo=63,A4=64,doe=1,poe=2,Mj=3,moe=4,Rj=5,goe=6,yoe=7,Nj=65,voe=66,boe=8,xoe=9,woe=10,Soe=11,Coe=12,Dj=13,koe=19,Aoe=20,_oe=29,Ooe=33,Eoe=34,Toe=47,Moe=0,HC=1,i2=2,Tu=3,r2=4;class Ta{constructor(e,n,i){this.parent=e,this.depth=n,this.type=i,this.hash=(e?e.hash+e.hash<<8:0)+n+(n<<4)+i}}Ta.top=new Ta(null,-1,Moe);function eu(t,e){for(let n=0,i=e-t.pos-1;;i--,n++){let r=t.peek(i);if(es(r)||r==-1)return n}}function s2(t){return t==32||t==9}function es(t){return t==10||t==13}function Lj(t){return s2(t)||es(t)}function za(t){return t<0||Lj(t)}const Roe=new foe({start:Ta.top,reduce(t,e){return t.type==Tu&&(e==Aoe||e==Eoe)?t.parent:t},shift(t,e,n,i){if(e==Mj)return new Ta(t,eu(i,i.pos),HC);if(e==Nj||e==Rj)return new Ta(t,eu(i,i.pos),i2);if(e==Uo)return t.parent;if(e==koe||e==Ooe)return new Ta(t,0,Tu);if(e==Dj&&t.type==r2)return t.parent;if(e==Toe){let r=/[1-9]/.exec(i.read(i.pos,n.pos));if(r)return new Ta(t,t.depth+ +r[0],r2)}return t},hash(t){return t.hash}});function xl(t,e,n=0){return t.peek(n)==e&&t.peek(n+1)==e&&t.peek(n+2)==e&&za(t.peek(n+3))}const Noe=new Kp((t,e)=>{if(t.next==-1&&e.canShift(A4))return t.acceptToken(A4);let n=t.peek(-1);if((es(n)||n<0)&&e.context.type!=Tu){if(xl(t,45))if(e.canShift(Uo))t.acceptToken(Uo);else return t.acceptToken(doe,3);if(xl(t,46))if(e.canShift(Uo))t.acceptToken(Uo);else return t.acceptToken(poe,3);let i=0;for(;t.next==32;)i++,t.advance();(i<e.context.depth||i==e.context.depth&&e.context.type==HC&&(t.next!=45||!za(t.peek(1))))&&t.next!=-1&&!es(t.next)&&t.next!=35&&t.acceptToken(Uo,-i)}},{contextual:!0}),Doe=new Kp((t,e)=>{if(e.context.type==Tu){t.next==63&&(t.advance(),za(t.next)&&t.acceptToken(yoe));return}if(t.next==45)t.advance(),za(t.next)&&t.acceptToken(e.context.type==HC&&e.context.depth==eu(t,t.pos-1)?moe:Mj);else if(t.next==63)t.advance(),za(t.next)&&t.acceptToken(e.context.type==i2&&e.context.depth==eu(t,t.pos-1)?goe:Rj);else{let n=t.pos;for(;;)if(s2(t.next)){if(t.pos==n)return;t.advance()}else if(t.next==33)zj(t);else if(t.next==38)a2(t);else if(t.next==42){a2(t);break}else if(t.next==39||t.next==34){if(UC(t,!0))break;return}else if(t.next==91||t.next==123){if(!zoe(t))return;break}else{Bj(t,!0,!1,0);break}for(;s2(t.next);)t.advance();if(t.next==58){if(t.pos==n&&e.canShift(_oe))return;let i=t.peek(1);za(i)&&t.acceptTokenTo(e.context.type==i2&&e.context.depth==eu(t,n)?voe:Nj,n)}}},{contextual:!0});function Loe(t){return t>32&&t<127&&t!=34&&t!=37&&t!=44&&t!=60&&t!=62&&t!=92&&t!=94&&t!=96&&t!=123&&t!=124&&t!=125}function _4(t){return t>=48&&t<=57||t>=97&&t<=102||t>=65&&t<=70}function O4(t,e){return t.next==37?(t.advance(),_4(t.next)&&t.advance(),_4(t.next)&&t.advance(),!0):Loe(t.next)||e&&t.next==44?(t.advance(),!0):!1}function zj(t){if(t.advance(),t.next==60){for(t.advance();;)if(!O4(t,!0)){t.next==62&&t.advance();break}}else for(;O4(t,!1););}function a2(t){for(t.advance();!za(t.next)&&cp(t.next)!="f";)t.advance()}function UC(t,e){let n=t.next,i=!1,r=t.pos;for(t.advance();;){let s=t.next;if(s<0)break;if(t.advance(),s==n)if(s==39)if(t.next==39)t.advance();else break;else break;else if(s==92&&n==34)t.next>=0&&t.advance();else if(es(s)){if(e)return!1;i=!0}else if(e&&t.pos>=r+1024)return!1}return!i}function zoe(t){for(let e=[],n=t.pos+1024;;)if(t.next==91||t.next==123)e.push(t.next),t.advance();else if(t.next==39||t.next==34){if(!UC(t,!0))return!1}else if(t.next==93||t.next==125){if(e[e.length-1]!=t.next-2)return!1;if(e.pop(),t.advance(),!e.length)return!0}else{if(t.next<0||t.pos>n||es(t.next))return!1;t.advance()}}const Boe="iiisiiissisfissssssssssssisssiiissssssssssssssssssssssssssfsfssissssssssssssssssssssssssssfif";function cp(t){return t<33?"u":t>125?"s":Boe[t-33]}function Dw(t,e){let n=cp(t);return n!="u"&&!(e&&n=="f")}function Bj(t,e,n,i){if(cp(t.next)=="s"||(t.next==63||t.next==58||t.next==45)&&Dw(t.peek(1),n))t.advance();else return!1;let r=t.pos;for(;;){let s=t.next,o=0,c=i+1;for(;Lj(s);){if(es(s)){if(e)return!1;c=0}else c++;s=t.peek(++o)}if(!(s>=0&&(s==58?Dw(t.peek(o+1),n):s==35?t.peek(o-1)!=32:Dw(s,n)))||!n&&c<=i||c==0&&!n&&(xl(t,45,o)||xl(t,46,o)))break;if(e&&cp(s)=="f")return!1;for(let h=o;h>=0;h--)t.advance();if(e&&t.pos>r+1024)return!1}return!0}const qoe=new Kp((t,e)=>{if(t.next==33)zj(t),t.acceptToken(Coe);else if(t.next==38||t.next==42){let n=t.next==38?woe:Soe;a2(t),t.acceptToken(n)}else t.next==39||t.next==34?(UC(t,!1),t.acceptToken(xoe)):Bj(t,!1,e.context.type==Tu,e.context.depth)&&t.acceptToken(boe)}),joe=new Kp((t,e)=>{let n=e.context.type==r2?e.context.depth:-1,i=t.pos;e:for(;;){let r=0,s=t.next;for(;s==32;)s=t.peek(++r);if(!r&&(xl(t,45,r)||xl(t,46,r))||!es(s)&&(n<0&&(n=Math.max(e.context.depth+1,r)),r<n))break;for(;;){if(t.next<0)break e;let o=es(t.next);if(t.advance(),o)continue e;i=t.pos}}t.acceptTokenTo(Dj,i)}),Ioe=lq({DirectiveName:le.keyword,DirectiveContent:le.attributeValue,"DirectiveEnd DocEnd":le.meta,QuotedLiteral:le.string,BlockLiteralHeader:le.special(le.string),BlockLiteralContent:le.content,Literal:le.content,"Key/Literal Key/QuotedLiteral":le.definition(le.propertyName),"Anchor Alias":le.labelName,Tag:le.typeName,Comment:le.lineComment,": , -":le.separator,"?":le.punctuation,"[ ]":le.squareBracket,"{ }":le.brace}),Poe=lp.deserialize({version:14,states:"5lQ!ZQgOOO#PQfO'#CpO#uQfO'#DOOOQR'#Dv'#DvO$qQgO'#DRO%gQdO'#DUO%nQgO'#DUO&ROaO'#D[OOQR'#Du'#DuO&{QgO'#D^O'rQgO'#D`OOQR'#Dt'#DtO(iOqO'#DbOOQP'#Dj'#DjO(zQaO'#CmO)YQgO'#CmOOQP'#Cm'#CmQ)jQaOOQ)uQgOOQ]QgOOO*PQdO'#CrO*nQdO'#CtOOQO'#Dw'#DwO+]Q`O'#CxO+hQdO'#CwO+rQ`O'#CwOOQO'#Cv'#CvO+wQdO'#CvOOQO'#Cq'#CqO,UQ`O,59[O,^QfO,59[OOQR,59[,59[OOQO'#Cx'#CxO,eQ`O'#DPO,pQdO'#DPOOQO'#Dx'#DxO,zQdO'#DxO-XQ`O,59jO-aQfO,59jOOQR,59j,59jOOQR'#DS'#DSO-hQcO,59mO-sQgO'#DVO.TQ`O'#DVO.YQcO,59pOOQR'#DX'#DXO#|QfO'#DWO.hQcO'#DWOOQR,59v,59vO.yOWO,59vO/OOaO,59vO/WOaO,59vO/cQgO'#D_OOQR,59x,59xO0VQgO'#DaOOQR,59z,59zOOQP,59|,59|O0yOaO,59|O1ROaO,59|O1aOqO,59|OOQP-E7h-E7hO1oQgO,59XOOQP,59X,59XO2PQaO'#DeO2_QgO'#DeO2oQgO'#DkOOQP'#Dk'#DkQ)jQaOOO3PQdO'#CsOOQO,59^,59^O3kQdO'#CuOOQO,59`,59`OOQO,59c,59cO4VQdO,59cO4aQdO'#CzO4kQ`O'#CzOOQO,59b,59bOOQU,5:Q,5:QOOQR1G.v1G.vO4pQ`O1G.vOOQU-E7d-E7dO4xQdO,59kOOQO,59k,59kO5SQdO'#DQO5^Q`O'#DQOOQO,5:d,5:dOOQU,5:R,5:ROOQR1G/U1G/UO5cQ`O1G/UOOQU-E7e-E7eO5kQgO'#DhO5xQcO1G/XOOQR1G/X1G/XOOQR,59q,59qO6TQgO,59qO6eQdO'#DiO6lQgO'#DiO7PQcO1G/[OOQR1G/[1G/[OOQR,59r,59rO#|QfO,59rOOQR1G/b1G/bO7_OWO1G/bO7dOaO1G/bOOQR,59y,59yOOQR,59{,59{OOQP1G/h1G/hO7lOaO1G/hO7tOaO1G/hO8POaO1G/hOOQP1G.s1G.sO8_QgO,5:POOQP,5:P,5:POOQP,5:V,5:VOOQP-E7i-E7iOOQO,59_,59_OOQO,59a,59aOOQO1G.}1G.}OOQO,59f,59fO8oQdO,59fOOQR7+$b7+$bP,XQ`O'#DfOOQO1G/V1G/VOOQO,59l,59lO8yQdO,59lOOQR7+$p7+$pP9TQ`O'#DgOOQR'#DT'#DTOOQR,5:S,5:SOOQR-E7f-E7fOOQR7+$s7+$sOOQR1G/]1G/]O9YQgO'#DYO9jQ`O'#DYOOQR,5:T,5:TO#|QfO'#DZO9oQcO'#DZOOQR-E7g-E7gOOQR7+$v7+$vOOQR1G/^1G/^OOQR7+$|7+$|O:QOWO7+$|OOQP7+%S7+%SO:VOaO7+%SO:_OaO7+%SOOQP1G/k1G/kOOQO1G/Q1G/QOOQO1G/W1G/WOOQR,59t,59tO:jQgO,59tOOQR,59u,59uO#|QfO,59uOOQR<<Hh<<HhOOQP<<Hn<<HnO:zOaO<<HnOOQR1G/`1G/`OOQR1G/a1G/aOOQPAN>YAN>Y",stateData:";S~O!fOS!gOS^OS~OP_OQbORSOTUOWROXROYYOZZO[XOcPOqQO!PVO!V[O!cTO~O`cO~P]OVkOWROXROYeOZfO[dOcPOmhOqQO~OboO~P!bOVtOWROXROYeOZfO[dOcPOmrOqQO~OpwO~P#WORSOTUOWROXROYYOZZO[XOcPOqQO!PVO!cTO~OSvP!avP!bvP~P#|OWROXROYeOZfO[dOcPOqQO~OmzO~P%OOm!OOUzP!azP!bzP!dzP~P#|O^!SO!b!QO!f!TO!g!RO~ORSOTUOWROXROcPOqQO!PVO!cTO~OY!UOP!QXQ!QX!V!QX!`!QXS!QX!a!QX!b!QXU!QXm!QX!d!QX~P&aO[!WOP!SXQ!SX!V!SX!`!SXS!SX!a!SX!b!SXU!SXm!SX!d!SX~P&aO^!ZO!W![O!b!YO!f!]O!g!YO~OP!_O!V[OQaX!`aX~OPaXQaX!VaX!`aX~P#|OP!bOQ!cO!V[O~OP_O!V[O~P#|OWROXROY!fOcPOqQObfXmfXofXpfX~OWROXRO[!hOcPOqQObhXmhXohXphX~ObeXmlXoeX~ObkXokX~P%OOm!kO~Om!lObnPonP~P%OOb!pOo!oO~Ob!pO~P!bOm!sOosXpsX~OosXpsX~P%OOm!uOotPptP~P%OOo!xOp!yO~Op!yO~P#WOS!|O!a#OO!b#OO~OUyX!ayX!byX!dyX~P#|Om#QO~OU#SO!a#UO!b#UO!d#RO~Om#WOUzX!azX!bzX!dzX~O]#XO~O!b#XO!g#YO~O^#ZO!b#XO!g#YO~OP!RXQ!RX!V!RX!`!RXS!RX!a!RX!b!RXU!RXm!RX!d!RX~P&aOP!TXQ!TX!V!TX!`!TXS!TX!a!TX!b!TXU!TXm!TX!d!TX~P&aO!b#^O!g#^O~O^#_O!b#^O!f#`O!g#^O~O^#_O!W#aO!b#^O!g#^O~OPaaQaa!Vaa!`aa~P#|OP#cO!V[OQ!XX!`!XX~OP!XXQ!XX!V!XX!`!XX~P#|OP_O!V[OQ!_X!`!_X~P#|OWROXROcPOqQObgXmgXogXpgX~OWROXROcPOqQObiXmiXoiXpiX~Obkaoka~P%OObnXonX~P%OOm#kO~Ob#lOo!oO~Oosapsa~P%OOotXptX~P%OOm#pO~Oo!xOp#qO~OSwP!awP!bwP~P#|OS!|O!a#vO!b#vO~OUya!aya!bya!dya~P#|Om#xO~P%OOm#{OU}P!a}P!b}P!d}P~P#|OU#SO!a$OO!b$OO!d#RO~O]$QO~O!b$QO!g$RO~O!b$SO!g$SO~O^$TO!b$SO!g$SO~O^$TO!b$SO!f$UO!g$SO~OP!XaQ!Xa!V!Xa!`!Xa~P#|Obnaona~P%OOotapta~P%OOo!xO~OU|X!a|X!b|X!d|X~P#|Om$ZO~Om$]OU}X!a}X!b}X!d}X~O]$^O~O!b$_O!g$_O~O^$`O!b$_O!g$_O~OU|a!a|a!b|a!d|a~P#|O!b$cO!g$cO~O",goto:",]!mPPPPPPPPPPPPPPPPP!nPP!v#v#|$`#|$c$f$j$nP%VPPP!v%Y%^%a%{&O%a&R&U&X&_&b%aP&e&{&e'O'RPP']'a'g'm's'y(XPPPPPPPP(_)e*X+c,VUaObcR#e!c!{ROPQSTUXY_bcdehknrtvz!O!U!W!_!b!c!f!h!k!l!s!u!|#Q#R#S#W#c#k#p#x#{$Z$]QmPR!qnqfPQThknrtv!k!l!s!u#R#k#pR!gdR!ieTlPnTjPnSiPnSqQvQ{TQ!mkQ!trQ!vtR#y#RR!nkTsQvR!wt!RWOSUXY_bcz!O!U!W!_!b!c!|#Q#S#W#c#x#{$Z$]RySR#t!|R|TR|UQ!PUR#|#SR#z#RR#z#SyZOSU_bcz!O!_!b!c!|#Q#S#W#c#x#{$Z$]R!VXR!XYa]O^abc!a!c!eT!da!eQnPR!rnQvQR!{vQ!}yR#u!}Q#T|R#}#TW^Obc!cS!^^!aT!aa!eQ!eaR#f!eW`Obc!cQxSS}U#SQ!`_Q#PzQ#V!OQ#b!_Q#d!bQ#s!|Q#w#QQ$P#WQ$V#cQ$Y#xQ$[#{Q$a$ZR$b$]xZOSU_bcz!O!_!b!c!|#Q#S#W#c#x#{$Z$]Q!VXQ!XYQ#[!UR#]!W!QWOSUXY_bcz!O!U!W!_!b!c!|#Q#S#W#c#x#{$Z$]pfPQThknrtv!k!l!s!u#R#k#pQ!gdQ!ieQ#g!fR#h!hSgPn^pQTkrtv#RQ!jhQ#i!kQ#j!lQ#n!sQ#o!uQ$W#kR$X#pQuQR!zv",nodeNames:"⚠ DirectiveEnd DocEnd - - ? ? ? Literal QuotedLiteral Anchor Alias Tag BlockLiteralContent Comment Stream BOM Document ] [ FlowSequence Item Tagged Anchored Anchored Tagged FlowMapping Pair Key : Pair , } { FlowMapping Pair Pair BlockSequence Item Item BlockMapping Pair Pair Key Pair Pair BlockLiteral BlockLiteralHeader Tagged Anchored Anchored Tagged Directive DirectiveName DirectiveContent Document",maxTerm:74,context:Roe,nodeProps:[["isolate",-3,8,9,14,""],["openedBy",18,"[",32,"{"],["closedBy",19,"]",33,"}"]],propSources:[Ioe],skippedNodes:[0],repeatNodeCount:6,tokenData:"-Y~RnOX#PXY$QYZ$]Z]#P]^$]^p#Ppq$Qqs#Pst$btu#Puv$yv|#P|}&e}![#P![!]'O!]!`#P!`!a'i!a!}#P!}#O*g#O#P#P#P#Q+Q#Q#o#P#o#p+k#p#q'i#q#r,U#r;'S#P;'S;=`#z<%l?HT#P?HT?HU,o?HUO#PQ#UU!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PQ#kTOY#PZs#Pt;'S#P;'S;=`#z<%lO#PQ#}P;=`<%l#P~$VQ!f~XY$Qpq$Q~$bO!g~~$gS^~OY$bZ;'S$b;'S;=`$s<%lO$b~$vP;=`<%l$bR%OX!WQOX%kXY#PZ]%k]^#P^p%kpq#hq;'S%k;'S;=`&_<%lO%kR%rX!WQ!VPOX%kXY#PZ]%k]^#P^p%kpq#hq;'S%k;'S;=`&_<%lO%kR&bP;=`<%l%kR&lUoP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR'VUmP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR'p[!PP!WQOY#PZp#Ppq#hq{#P{|(f|}#P}!O(f!O!R#P!R![)p![;'S#P;'S;=`#z<%lO#PR(mW!PP!WQOY#PZp#Ppq#hq!R#P!R![)V![;'S#P;'S;=`#z<%lO#PR)^U!PP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR)wY!PP!WQOY#PZp#Ppq#hq{#P{|)V|}#P}!O)V!O;'S#P;'S;=`#z<%lO#PR*nUcP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR+XUbP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR+rUqP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR,]UpP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR,vU`P!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#P",tokenizers:[Noe,Doe,qoe,joe,0,1],topRules:{Stream:[0,15]},tokenPrec:0}),Hoe=Gd.define({name:"yaml",parser:Poe.configure({props:[hq.add({Stream:t=>{for(let e=t.node.resolve(t.pos,-1);e&&e.to>=t.pos;e=e.parent){if(e.name=="BlockLiteralContent"&&e.from<e.to)return t.baseIndentFor(e);if(e.name=="BlockLiteral")return t.baseIndentFor(e)+t.unit;if(e.name=="BlockSequence"||e.name=="BlockMapping")return t.column(e.from,1);if(e.name=="QuotedLiteral")return null;if(e.name=="Literal"){let n=t.column(e.from,1);if(n==t.lineIndent(e.from,1))return n;if(e.to>t.pos)return null}}return null},FlowMapping:L5({closing:"}"}),FlowSequence:L5({closing:"]"})}),mq.add({"FlowMapping FlowSequence":xie,"Item Pair BlockLiteral":(t,e)=>({from:e.doc.lineAt(t.from).to,to:t.to})})]}),languageData:{commentTokens:{line:"#"},indentOnInput:/^\s*[\]\}]$/}});function Uoe(){return new cie(Hoe)}const Voe=()=>{const{error:t,isCliMode:e,yamlInput:n,setYamlInput:i,parseAndSetSchema:r,isAutoSaveEnabled:s,setIsAutoSaveEnabled:o,savingStatus:c,saveSchema:u,lastUpdateSource:h,theme:d}=ci(),[m,g]=j.useState(n),y=j.useRef(null),x=j.useRef(null),w=j.useRef(!0);j.useEffect(()=>{if(!x.current?.view)return;const E=x.current.view,T=E.state.doc.toString();if(w.current&&n){E.dispatch({changes:{from:0,to:T.length,insert:n},annotations:Qt.addToHistory.of(!1)}),g(n),w.current=!1;return}h==="visual"&&T!==n&&(E.dispatch({changes:{from:0,to:T.length,insert:n},userEvent:"visual-edit"}),g(n))},[n,h]);const S=j.useCallback(E=>{g(E),!(!E||E.trim()==="")&&(y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{i(E),r(E)},300))},[i,r]),C=async()=>{r(m),e&&await u(!0)},A=()=>{x.current?.view&&MC(x.current.view)},O=()=>{x.current?.view&&Kd(x.current.view)};return k.jsxs("div",{className:"flex-1 flex flex-col gap-3 overflow-hidden p-4 pt-2 h-full",children:[k.jsxs("div",{className:"flex items-center justify-between px-1",children:[e?k.jsxs("div",{className:"flex items-center gap-4",children:[k.jsxs("label",{className:"flex items-center gap-2 cursor-pointer group",children:[k.jsx("div",{className:`relative w-7 h-4 rounded-full transition-colors ${s?"bg-blue-600":"bg-slate-300 dark:bg-slate-700"}`,onClick:()=>o(!s),children:k.jsx("div",{className:`absolute top-0.5 left-0.5 w-3 h-3 bg-white rounded-full transition-transform ${s?"translate-x-3":"translate-x-0"}`})}),k.jsx("span",{className:`text-[10px] font-bold uppercase tracking-widest ${d==="dark"?"text-slate-500 group-hover:text-slate-400":"text-slate-400 group-hover:text-slate-600"}`,children:"Auto-save"})]}),k.jsxs("div",{className:"flex items-center gap-1.5 min-w-[60px]",children:[c==="saving"&&k.jsxs("div",{className:"flex items-center gap-1 text-slate-400 animate-pulse",children:[k.jsx(xK,{size:10,className:"animate-spin"}),k.jsx("span",{className:"text-[9px] font-bold uppercase",children:"Saving"})]}),c==="saved"&&k.jsxs("div",{className:"flex items-center gap-1 text-emerald-500",children:[k.jsx(nK,{size:10}),k.jsx("span",{className:"text-[9px] font-bold uppercase tracking-wider",children:"Saved"})]}),c==="error"&&k.jsxs("div",{className:"flex items-center gap-1 text-red-500",children:[k.jsx(K1,{size:10}),k.jsx("span",{className:"text-[9px] font-bold uppercase",children:"Error"})]})]})]}):k.jsxs("div",{className:"flex items-center gap-2 px-2 py-1 bg-blue-500/10 border border-blue-500/30 rounded-md",children:[k.jsx(K1,{size:12,className:"text-blue-400"}),k.jsx("span",{className:"text-[10px] text-blue-300 font-medium uppercase tracking-tight",children:"Sandbox Mode"})]}),k.jsxs("div",{className:"flex items-center gap-3",children:[k.jsxs("div",{className:`flex rounded-lg p-0.5 border ${d==="dark"?"bg-slate-800/50 border-slate-700/50":"bg-slate-100 border-slate-200"}`,children:[k.jsx("button",{onClick:A,className:`p-1.5 rounded-md transition-all active:scale-95 ${d==="dark"?"text-slate-400 hover:bg-slate-700 hover:text-slate-100":"text-slate-500 hover:bg-white hover:text-blue-600 hover:shadow-sm"}`,title:"Undo (Ctrl+Z)",children:k.jsx(Y8,{size:14})}),k.jsx("div",{className:`w-px h-4 self-center mx-0.5 ${d==="dark"?"bg-slate-700/50":"bg-slate-200"}`}),k.jsx("button",{onClick:O,className:`p-1.5 rounded-md transition-all active:scale-95 ${d==="dark"?"text-slate-400 hover:bg-slate-700 hover:text-slate-100":"text-slate-500 hover:bg-white hover:text-blue-600 hover:shadow-sm"}`,title:"Redo (Ctrl+Y)",children:k.jsx($8,{size:14})})]}),k.jsxs("div",{className:"flex items-center gap-1 text-slate-400 dark:text-slate-600 cursor-help",title:"Pro Tip: Use Ctrl+Z to undo visual changes!",children:[k.jsx(mK,{size:12}),k.jsx("span",{className:"text-[9px] font-bold uppercase tracking-tighter",children:"Undo Active"})]})]})]}),k.jsxs("div",{className:`relative flex-1 flex flex-col min-h-0 border rounded-md overflow-hidden transition-colors ${d==="dark"?"border-slate-700 bg-[#282c34]":"border-slate-200 bg-white"}`,children:[k.jsx(Tj,{ref:x,value:m,height:"100%",theme:d==="dark"?Ej:"light",extensions:[Uoe()],onChange:S,basicSetup:{lineNumbers:!0,foldGutter:!0,highlightActiveLine:!0},className:"flex-1 text-sm overflow-auto"}),t&&m===n&&k.jsxs("div",{className:"absolute bottom-4 left-4 right-4 p-3 bg-red-900/90 border border-red-500/50 rounded-md text-red-100 text-xs flex gap-2 items-start z-10 shadow-2xl backdrop-blur-sm animate-in fade-in slide-in-from-bottom-2",children:[k.jsx(K1,{size:14,className:"shrink-0 mt-0.5 text-red-400"}),k.jsx("span",{children:t})]})]}),k.jsxs("div",{className:"flex justify-between items-center pt-1 shrink-0",children:[k.jsx("div",{className:"text-[10px] text-slate-500 italic",children:e?s?"Changes save automatically":"Click save to update file":"Changes reset on reload"}),k.jsxs("button",{onClick:C,disabled:c==="saving",className:`flex items-center gap-2 px-4 py-2 rounded-md font-medium text-sm transition-all shadow-lg shrink-0 ${e?s?"bg-slate-300 dark:bg-slate-700 text-slate-500 dark:text-slate-400 cursor-not-allowed opacity-50":"bg-blue-600 hover:bg-blue-700 text-white":"bg-emerald-600 hover:bg-emerald-700 text-white"}`,children:[e?k.jsx(UK,{size:16}):k.jsx(BK,{size:16}),e?"Save & Update":"Apply Changes"]})]})]})},Foe=()=>{const{schema:t,setSelectedTableId:e,setFocusNodeId:n,theme:i}=ci(),[r,s]=j.useState(""),[o,c]=j.useState(new Set),u=m=>{const g=new Set(o);g.has(m)?g.delete(m):g.add(m),c(g)},h=m=>{e(m),n(m)},d=j.useMemo(()=>{if(!t)return{domains:[],unassigned:[]};const m={},g=new Set;t.domains?.forEach(w=>{m[w.id]=[]}),t.tables.forEach(w=>{const S=t.domains?.find(A=>A.tables.includes(w.id));(w.name.toLowerCase().includes(r.toLowerCase())||w.id.toLowerCase().includes(r.toLowerCase()))&&S&&(m[S.id].push(w),g.add(w.id))});const y=(t.domains||[]).filter(w=>{const S=m[w.id].length>0,C=w.name.toLowerCase().includes(r.toLowerCase())||w.id.toLowerCase().includes(r.toLowerCase());return S||C&&r!==""}).map(w=>({...w,tables:m[w.id]})),x=t.tables.filter(w=>(w.name.toLowerCase().includes(r.toLowerCase())||w.id.toLowerCase().includes(r.toLowerCase()))&&!g.has(w.id)&&!t.domains?.some(C=>C.tables.includes(w.id)));return{domains:y,unassigned:x}},[t,r]);return t?k.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden p-4 pt-2",children:[k.jsxs("div",{className:"relative mb-4 shrink-0",children:[k.jsx(FK,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-slate-500"}),k.jsx("input",{type:"text",value:r,onChange:m=>s(m.target.value),placeholder:"Search entities...",className:`w-full pl-9 pr-4 py-2 rounded-md text-sm transition-all shadow-sm focus:outline-none focus:ring-1 focus:ring-blue-500/50 ${i==="dark"?"bg-slate-800 border-slate-700 text-slate-100":"bg-white border-slate-200 text-slate-900 shadow-slate-200/50"}`})]}),k.jsxs("div",{className:"flex-1 space-y-4 overflow-auto pr-1",children:[d.domains.map(m=>{const g=o.has(m.id);return k.jsxs("section",{className:"flex flex-col",children:[k.jsxs("div",{className:`flex items-center justify-between group px-1 py-1.5 cursor-pointer rounded transition-colors ${i==="dark"?"hover:bg-slate-800/30":"hover:bg-slate-100"}`,onClick:()=>u(m.id),children:[k.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[g?k.jsx(nS,{size:12,className:"text-slate-500"}):k.jsx(tS,{size:12,className:"text-slate-500"}),k.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:m.color||"#3b82f6"}}),k.jsx("h3",{className:`text-[10px] font-bold uppercase tracking-wider truncate ${i==="dark"?"text-slate-300":"text-slate-600"}`,children:m.name}),k.jsx("span",{className:`text-[9px] font-medium px-1.5 py-0.5 rounded-full ${i==="dark"?"text-slate-600 bg-slate-800/50":"text-slate-400 bg-slate-100"}`,children:m.tables.length})]}),k.jsx("button",{onClick:y=>{y.stopPropagation(),h(m.id)},className:"opacity-0 group-hover:opacity-100 p-1 hover:text-blue-500 text-slate-500 transition-all",title:"Focus on Domain",children:k.jsx(W1,{size:12})})]}),!g&&k.jsxs("div",{className:`ml-4 mt-1 space-y-0.5 border-l pl-2 ${i==="dark"?"border-slate-800":"border-slate-100"}`,children:[m.tables.map(y=>k.jsxs("button",{onClick:()=>h(y.id),className:`w-full flex items-center justify-between group p-1.5 text-xs rounded border border-transparent transition-all text-left ${i==="dark"?"hover:bg-slate-800/50 text-slate-400 hover:text-slate-200":"hover:bg-blue-50 text-slate-500 hover:text-blue-600"}`,children:[k.jsx("span",{className:"truncate",children:y.name}),k.jsx(W1,{size:10,className:"opacity-0 group-hover:opacity-100"})]},y.id)),m.tables.length===0&&k.jsx("div",{className:"p-2 text-[10px] text-slate-500 italic",children:"No tables in this domain"})]})]},m.id)}),d.unassigned.length>0&&k.jsxs("section",{className:"flex flex-col",children:[k.jsx("div",{className:`flex items-center justify-between group px-1 py-1.5 cursor-pointer rounded transition-colors ${i==="dark"?"hover:bg-slate-800/30":"hover:bg-slate-100"}`,onClick:()=>u("unassigned"),children:k.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[o.has("unassigned")?k.jsx(nS,{size:12,className:"text-slate-500"}):k.jsx(tS,{size:12,className:"text-slate-500"}),k.jsx(F8,{size:12,className:"text-slate-500 shrink-0"}),k.jsx("h3",{className:`text-[10px] font-bold uppercase tracking-wider truncate ${i==="dark"?"text-slate-500":"text-slate-400"}`,children:"Unassigned"}),k.jsx("span",{className:`text-[9px] font-medium px-1.5 py-0.5 rounded-full ${i==="dark"?"text-slate-600 bg-slate-800/50":"text-slate-400 bg-slate-100"}`,children:d.unassigned.length})]})}),!o.has("unassigned")&&k.jsx("div",{className:`ml-4 mt-1 space-y-0.5 border-l pl-2 ${i==="dark"?"border-slate-800":"border-slate-100"}`,children:d.unassigned.map(m=>k.jsxs("button",{onClick:()=>h(m.id),className:`w-full flex items-center justify-between group p-1.5 text-xs rounded border border-transparent transition-all text-left ${i==="dark"?"hover:bg-slate-800/50 text-slate-400 hover:text-slate-200":"hover:bg-blue-50 text-slate-500 hover:text-blue-600"}`,children:[k.jsx("span",{className:"truncate",children:m.name}),k.jsx(W1,{size:10,className:"opacity-0 group-hover:opacity-100"})]},m.id))})]}),d.domains.length===0&&d.unassigned.length===0&&k.jsx("div",{className:"text-center py-10",children:k.jsxs("p",{className:"text-sm text-slate-500 italic",children:['No entities found for "',r,'"']})})]})]}):null},$oe=()=>{const{isSidebarOpen:t,setIsSidebarOpen:e,theme:n}=ci();return k.jsx("button",{onClick:()=>e(!t),className:`absolute -right-3.5 top-1/2 -translate-y-1/2 z-[60] flex h-7 w-7 items-center justify-center rounded-full border transition-all shadow-xl ${n==="dark"?"border-slate-700 bg-slate-900 text-slate-400 hover:text-white hover:bg-slate-800":"border-slate-200 bg-white text-slate-500 hover:text-blue-600 hover:bg-slate-50 shadow-slate-200/50"}`,"aria-label":t?"Collapse sidebar":"Expand sidebar",children:t?k.jsx(ZW,{size:16}):k.jsx(nS,{size:16})})},Goe=()=>{const{availableFiles:t,currentModelSlug:e,setCurrentModel:n,isSidebarOpen:i,fetchAvailableFiles:r,theme:s}=ci(),[o,c]=j.useState(!1);if(!i||t.length<=0)return null;const u=async()=>{c(!0),await r(),setTimeout(()=>c(!1),500)},h=e||t[0]?.slug;return k.jsxs("div",{className:"px-4 mb-4",children:[k.jsxs("div",{className:"flex items-center justify-between mb-1.5 px-1",children:[k.jsx("div",{className:"text-[10px] font-bold uppercase tracking-wider text-slate-500",children:"Current Model"}),k.jsx("button",{onClick:u,className:`transition-all p-0.5 rounded ${o?"animate-spin text-blue-400":"text-slate-500 hover:text-blue-400"} ${s==="dark"?"hover:bg-slate-800":"hover:bg-slate-100"}`,title:"Refresh model list",children:k.jsx(PK,{size:12})})]}),k.jsxs("div",{className:"relative group",children:[k.jsx("select",{value:h,onChange:d=>n(d.target.value),className:`w-full pl-9 pr-8 py-2 rounded-md text-sm appearance-none focus:outline-none focus:ring-1 focus:ring-blue-500/50 transition-all shadow-sm cursor-pointer ${s==="dark"?"bg-slate-800 border-slate-700 text-slate-100 hover:bg-slate-750":"bg-white border-slate-200 text-slate-900 hover:bg-slate-50 shadow-slate-200/50"}`,children:t.map(d=>k.jsx("option",{value:d.slug,className:s==="light"?"bg-white text-slate-900":"bg-slate-800 text-slate-100",children:d.name},d.slug))}),k.jsx(Go,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-blue-500 pointer-events-none"}),k.jsx(tS,{size:14,className:`absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none transition-colors ${s==="dark"?"text-slate-500 group-hover:text-slate-300":"text-slate-400 group-hover:text-slate-600"}`})]})]})},Yoe=""+new URL("../favicon.svg",import.meta.url).href,Qoe=()=>{const{isSidebarOpen:t,activeTab:e,setActiveTab:n,isCliMode:i,theme:r,toggleTheme:s}=ci();return k.jsxs("div",{className:`relative h-full flex flex-col border-r transition-all duration-300 ease-in-out shadow-2xl z-50 ${t?"w-[400px]":"w-[50px]"} ${r==="dark"?"bg-slate-900 border-slate-800":"bg-white border-slate-200"}`,children:[k.jsx($oe,{}),k.jsxs("div",{className:`p-4 border-b flex items-center justify-between ${!t&&"hidden"} ${r==="dark"?"border-slate-800":"border-slate-100"}`,children:[k.jsxs("div",{className:"flex items-center gap-2",children:[k.jsx("img",{src:Yoe,alt:"Modscape Logo",className:"w-5 h-5 rounded-md"}),k.jsx("h1",{className:`text-base font-bold tracking-tight ${r==="dark"?"text-white":"text-slate-900"}`,children:"Modscape"})]}),i&&k.jsx("span",{className:"px-1.5 py-0.5 bg-emerald-500/10 border border-emerald-500/30 text-emerald-500 text-[10px] font-bold rounded uppercase",children:"Live"})]}),k.jsx("div",{className:"mt-4",children:t&&k.jsx(Goe,{})}),k.jsxs(RJ,{value:e,onValueChange:o=>n(o),className:`flex-1 flex flex-col overflow-hidden ${!t&&"items-center py-4"}`,children:[k.jsx("div",{className:`px-4 pt-4 ${!t&&"px-0"}`,children:k.jsxs(NB,{className:`w-full p-1 border ${r==="dark"?"bg-slate-800/50 border-slate-700/50":"bg-slate-100 border-slate-200"} ${!t&&"flex-col h-auto w-10 gap-2 p-0 bg-transparent border-none"}`,children:[k.jsxs(oS,{value:"editor",className:`flex-1 gap-2 ${!t&&"w-9 h-9 p-0 rounded-md shadow-sm transition-all"} ${r==="dark"?"text-slate-400 data-[state=active]:bg-blue-600 data-[state=active]:text-white":"text-slate-500 data-[state=active]:bg-white data-[state=active]:text-blue-600 data-[state=active]:shadow-sm"}`,title:"Editor",children:[k.jsx(LK,{size:14}),t&&k.jsx("span",{children:"Editor"})]}),k.jsxs(oS,{value:"entities",className:`flex-1 gap-2 ${!t&&"w-9 h-9 p-0 rounded-md shadow-sm transition-all"} ${r==="dark"?"text-slate-400 data-[state=active]:bg-blue-600 data-[state=active]:text-white":"text-slate-500 data-[state=active]:bg-white data-[state=active]:text-blue-600 data-[state=active]:shadow-sm"}`,title:"Entities",children:[k.jsx(vK,{size:14}),t&&k.jsx("span",{children:"Entities"})]})]})}),t&&k.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[k.jsx(lS,{value:"editor",className:"flex-1 flex flex-col min-h-0 mt-0 data-[state=inactive]:hidden",children:k.jsx(Voe,{})}),k.jsx(lS,{value:"entities",className:"flex-1 flex flex-col min-h-0 mt-0 data-[state=inactive]:hidden",children:k.jsx(Foe,{})})]})]}),t&&k.jsxs("div",{className:`p-3 border-t flex items-center justify-between ${r==="dark"?"border-slate-800 bg-slate-950/20":"border-slate-100 bg-slate-50/50"}`,children:[k.jsx("p",{className:"text-[10px] text-slate-500 font-medium px-1",children:"Modscape v1.0.7"}),k.jsx("button",{onClick:s,className:`p-1.5 rounded-lg transition-all ${r==="dark"?"text-slate-400 hover:bg-slate-800 hover:text-yellow-400":"text-slate-500 hover:bg-slate-200 hover:text-blue-600"}`,title:`Switch to ${r==="dark"?"Light":"Dark"} Mode`,children:r==="dark"?k.jsx(GK,{size:14}):k.jsx(AK,{size:14})})]})]})},Xoe=()=>{const{addTable:t,addDomain:e,getSelectedTable:n,getSelectedDomain:i,getSelectedRelationship:r,removeNode:s,removeEdge:o,showER:c,showLineage:u,setShowER:h,setShowLineage:d,setSelectedTableId:m,setSelectedEdgeId:g,calculateAutoLayout:y,theme:x}=ci(),{screenToFlowPosition:w}=Du(),[S,C]=j.useState(!1),A=c&&u,O=()=>{if(A)return;const P=w({x:window.innerWidth/2,y:window.innerHeight/2});e(P.x-300,P.y-200)},E=()=>{if(A)return;const P=w({x:window.innerWidth/2,y:window.innerHeight/2});t(P.x-160,P.y-125)},T=n(),M=i(),R=r(),z=T||M||R,q=()=>{T?s(T.id):M?s(M.id):R&&o(R.relationship.from.table,R.relationship.to.table)},U=()=>{m(null),g(null)};return k.jsxs(k.Fragment,{children:[k.jsxs("div",{className:"absolute top-4 left-4 z-10 flex flex-col gap-2",children:[k.jsxs("div",{className:`flex flex-col border rounded-2xl shadow-2xl overflow-hidden w-14 transition-colors ${x==="dark"?"bg-slate-900/85 backdrop-blur-md border-slate-700":"bg-white/90 backdrop-blur-md border-slate-200"}`,children:[k.jsxs("div",{className:"flex flex-col items-center py-3 gap-2",children:[k.jsxs("div",{className:"flex flex-col items-center text-[8px] font-bold text-slate-500 uppercase tracking-tighter opacity-80",children:[k.jsx(lK,{size:12}),k.jsx("span",{children:"View"})]}),k.jsxs("div",{className:"flex flex-col gap-1 px-1.5 w-full",children:[k.jsx("button",{onClick:()=>h(!c),className:`flex items-center justify-center w-full aspect-square rounded-xl transition-all ${c?"bg-emerald-500/20 text-emerald-500 border border-emerald-500/30":x==="dark"?"text-slate-500 hover:text-slate-300 hover:bg-slate-800":"text-slate-400 hover:text-slate-600 hover:bg-slate-100"}`,title:c?"Hide ER Relationships":"Show ER Relationships (Disables editing if Lineage is also ON)",children:k.jsx(RK,{size:20})}),k.jsx("button",{onClick:()=>d(!u),className:`flex items-center justify-center w-full aspect-square rounded-xl transition-all ${u?"bg-blue-500/20 text-blue-500 border border-blue-500/30":x==="dark"?"text-slate-500 hover:text-slate-300 hover:bg-slate-800":"text-slate-400 hover:text-slate-600 hover:bg-slate-100"}`,title:u?"Hide Data Lineage":"Show Data Lineage (Disables editing if ER is also ON)",children:k.jsx(g3,{size:20})})]})]}),k.jsx("div",{className:`mx-2 border-t ${x==="dark"?"border-slate-800":"border-slate-100"}`}),k.jsxs("div",{className:"flex flex-col items-center py-3 gap-2",children:[k.jsxs("div",{className:"flex flex-col items-center text-[8px] font-bold text-slate-500 uppercase tracking-tighter opacity-80",children:[k.jsx(rS,{size:12}),k.jsx("span",{children:"Add"})]}),k.jsxs("div",{className:"flex flex-col gap-1 px-1.5 w-full",children:[k.jsxs("button",{onClick:O,className:`flex items-center justify-center w-full aspect-square rounded-xl transition-all group relative ${A?"opacity-40 cursor-not-allowed text-slate-500":x==="dark"?"text-slate-500 hover:text-blue-400 hover:bg-slate-800":"text-slate-400 hover:text-blue-600 hover:bg-slate-50"}`,title:A?"Addition locked while ER & Lineage are both active":"Add new Domain",children:[k.jsx(v3,{size:20}),A&&k.jsx(iS,{size:10,className:"absolute bottom-1 right-1 text-slate-500"})]}),k.jsxs("button",{onClick:E,className:`flex items-center justify-center w-full aspect-square rounded-xl transition-all group relative ${A?"opacity-40 cursor-not-allowed text-slate-500":x==="dark"?"text-slate-500 hover:text-emerald-400 hover:bg-slate-800":"text-slate-400 hover:text-emerald-600 hover:bg-slate-100"}`,title:A?"Addition locked while ER & Lineage are both active":"Add new Table",children:[k.jsx(fK,{size:20}),A&&k.jsx(iS,{size:10,className:"absolute bottom-1 right-1 text-slate-500"})]})]})]}),k.jsx("div",{className:`mx-2 border-t ${x==="dark"?"border-slate-800":"border-slate-100"}`}),k.jsxs("div",{className:"flex flex-col items-center py-3 gap-2",children:[k.jsxs("div",{className:"flex flex-col items-center text-[8px] font-bold text-slate-500 uppercase tracking-tighter opacity-80",children:[k.jsx(y3,{size:12}),k.jsx("span",{children:"Format"})]}),k.jsx("div",{className:"flex flex-col gap-1 px-1.5 w-full",children:k.jsx("button",{onClick:()=>y(),className:`flex items-center justify-center w-full aspect-square rounded-xl transition-all group ${x==="dark"?"text-slate-500 hover:text-blue-400 hover:bg-slate-800":"text-slate-400 hover:text-blue-600 hover:bg-slate-100"}`,title:"Auto-format Layout (Relation-driven flow)",children:k.jsx(y3,{size:20})})})]}),k.jsx("div",{className:`mx-2 border-t ${x==="dark"?"border-slate-800":"border-slate-100"}`}),k.jsx("div",{className:"flex flex-col items-center py-3",children:k.jsx("button",{onClick:()=>C(!S),className:`flex items-center justify-center w-10 h-10 rounded-xl transition-all ${S?x==="dark"?"bg-blue-600 text-white":"bg-blue-600 text-white shadow-md shadow-blue-500/20":x==="dark"?"text-slate-500 hover:bg-slate-800 hover:text-slate-300":"text-slate-400 hover:bg-slate-100 hover:text-slate-600"}`,title:"Keyboard Shortcuts & Help",children:k.jsx(F8,{size:20})})})]}),S&&k.jsxs("div",{className:`flex flex-col border rounded-2xl shadow-2xl p-5 w-64 animate-in zoom-in-95 fade-in duration-200 origin-top-left ${x==="dark"?"bg-slate-900/95 backdrop-blur-xl border-slate-700":"bg-white/95 backdrop-blur-xl border-slate-200"}`,children:[k.jsxs("div",{className:`flex items-center gap-2 mb-4 border-b pb-3 ${x==="dark"?"border-slate-800":"border-slate-100"}`,children:[k.jsx(sK,{size:16,className:"text-blue-500"}),k.jsx("h4",{className:`text-xs font-bold uppercase tracking-widest ${x==="dark"?"text-slate-200":"text-slate-800"}`,children:"Shortcuts"})]}),k.jsxs("div",{className:"space-y-4",children:[k.jsxs("div",{className:"flex items-center justify-between group",children:[k.jsxs("div",{className:"flex items-center gap-2 text-slate-500",children:[k.jsx(Y8,{size:14}),k.jsx("span",{className:"text-xs font-medium",children:"Undo"})]}),k.jsx("kbd",{className:`px-1.5 py-0.5 border rounded text-[10px] font-mono ${x==="dark"?"bg-slate-800 border-slate-700 text-slate-300":"bg-slate-50 border-slate-200 text-slate-600"}`,children:"Ctrl Z"})]}),k.jsxs("div",{className:"flex items-center justify-between group",children:[k.jsxs("div",{className:"flex items-center gap-2 text-slate-500",children:[k.jsx($8,{size:14}),k.jsx("span",{className:"text-xs font-medium",children:"Redo"})]}),k.jsx("kbd",{className:`px-1.5 py-0.5 border rounded text-[10px] font-mono ${x==="dark"?"bg-slate-800 border-slate-700 text-slate-300":"bg-slate-50 border-slate-200 text-slate-600"}`,children:"Ctrl Y"})]}),k.jsxs("div",{className:"flex items-center justify-between group",children:[k.jsxs("div",{className:"flex items-center gap-2 text-slate-500",children:[k.jsx(Md,{size:14}),k.jsx("span",{className:"text-xs font-medium text-red-500/80",children:"Delete"})]}),k.jsx("kbd",{className:`px-1.5 py-0.5 border rounded text-[10px] font-mono ${x==="dark"?"bg-slate-800 border-slate-700 text-slate-300 text-red-400/80":"bg-slate-50 border-slate-200 text-red-600/80"}`,children:"Del"})]}),k.jsxs("div",{className:"flex items-center justify-between group",children:[k.jsxs("div",{className:"flex items-center gap-2 text-slate-500",children:[k.jsx(Yo,{size:14}),k.jsx("span",{className:"text-xs font-medium",children:"Clear Focus"})]}),k.jsx("kbd",{className:`px-1.5 py-0.5 border rounded text-[10px] font-mono ${x==="dark"?"bg-slate-800 border-slate-700 text-slate-300":"bg-slate-50 border-slate-200 text-slate-600"}`,children:"Esc"})]}),k.jsxs("div",{className:"flex items-center justify-between group",children:[k.jsxs("div",{className:"flex items-center gap-2 text-slate-500",children:[k.jsx(TK,{size:14}),k.jsx("span",{className:"text-xs font-medium",children:"Pan Canvas"})]}),k.jsx("span",{className:`px-1.5 py-0.5 border rounded text-[10px] font-mono ${x==="dark"?"bg-slate-800 border-slate-700 text-slate-300":"bg-slate-50 border-slate-200 text-slate-600"}`,children:"Arrow Keys"})]}),k.jsxs("div",{className:"flex items-center justify-between group",children:[k.jsxs("div",{className:"flex items-center gap-2 text-slate-500",children:[k.jsx(OK,{size:14}),k.jsx("span",{className:"text-xs font-medium",children:"Multi-select"})]}),k.jsx("span",{className:`px-1.5 py-0.5 border rounded text-[10px] font-mono ${x==="dark"?"bg-slate-800 border-slate-700 text-slate-300":"bg-slate-50 border-slate-200 text-slate-600"}`,children:"Shift + Drag"})]})]}),k.jsx("div",{className:`mt-5 pt-3 border-t text-[10px] text-slate-400 italic leading-relaxed ${x==="dark"?"border-slate-800":"border-slate-100"}`,children:"* Edits are saved to local YAML files in real-time if Auto-save is enabled."})]})]}),z&&k.jsxs("div",{className:`absolute top-4 right-4 z-10 flex items-center gap-3 border rounded-xl shadow-2xl p-1.5 px-4 animate-in fade-in slide-in-from-top-4 duration-300 ${x==="dark"?"bg-slate-900/90 backdrop-blur-md border-blue-500/30":"bg-white/90 backdrop-blur-md border-blue-200 shadow-blue-500/5"}`,children:[k.jsxs("div",{className:`flex items-center gap-2 border-r pr-4 mr-1 ${x==="dark"?"border-slate-700":"border-slate-100"}`,children:[T&&k.jsx(Go,{size:16,className:"text-emerald-500"}),M&&k.jsx(v3,{size:16,className:"text-blue-500"}),R&&(R.relationship.type==="lineage"?k.jsx(g3,{size:16,className:"text-blue-400"}):k.jsx(G8,{size:16,className:"text-amber-500"})),k.jsxs("div",{className:"flex flex-col leading-tight",children:[k.jsxs("span",{className:"text-[10px] font-bold uppercase tracking-widest text-slate-500",children:["Selected ",T?"Table":M?"Domain":R?.relationship.type==="lineage"?"Lineage":"Relation"]}),k.jsx("span",{className:`text-xs font-semibold truncate max-w-[180px] ${x==="dark"?"text-slate-200":"text-slate-800"}`,children:T?T.name:M?M.name:R?`${R.relationship.from.table} → ${R.relationship.to.table}`:""})]})]}),k.jsxs("div",{className:"flex items-center gap-1",children:[k.jsx("button",{onClick:q,className:"flex items-center justify-center w-8 h-8 hover:bg-red-500/20 text-slate-400 hover:text-red-500 rounded-lg transition-all group",title:"Delete Selected (Del)",children:k.jsx(Md,{size:16})}),k.jsx("button",{onClick:U,className:`flex items-center justify-center w-8 h-8 rounded-lg transition-all ${x==="dark"?"hover:bg-slate-800 text-slate-500 hover:text-slate-300":"hover:bg-slate-100 text-slate-400 hover:text-slate-600"}`,title:"Clear Selection",children:k.jsx(Yo,{size:16})})]})]})]})},Woe=t=>{if(!t)return["",""];const n=t.toLowerCase().split("-to-");return n.length!==2?["",""]:n.map(i=>i.includes("one")?"1":i.includes("many")?"M":"")},E4=(t,e,n,i=45)=>{switch(n){case Te.Top:return{x:t,y:e-i};case Te.Bottom:return{x:t,y:e+i};case Te.Left:return{x:t-i,y:e};case Te.Right:return{x:t+i,y:e};default:return{x:t,y:e}}};function Koe({sourceX:t,sourceY:e,targetX:n,targetY:i,sourcePosition:r,targetPosition:s,style:o={},markerEnd:c,markerStart:u,label:h,data:d}){const[m]=Sd({sourceX:t,sourceY:e,sourcePosition:r,targetX:n,targetY:i,targetPosition:s}),{theme:g}=ci(),y=d?.isDirectlySelected,x=d?.isConnectedToSelectedTable,w=y||x,S=d?.label||h||"",[C,A]=Woe(S),O=E4(t,e,r),E=E4(n,i,s),T=({x:M,y:R,symbol:z})=>{if(!z)return null;const q=z==="1",U=`
|
|
52
52
|
absolute flex items-center justify-center
|
|
53
53
|
w-5 h-5 text-[9px] font-black border shadow-sm
|
|
54
54
|
backdrop-blur-sm transition-all duration-300
|