@claudecam/dashboard 0.1.5 → 0.1.6
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/dist/assets/{howler-CzrxH3Wg.js → howler-R81SmKVH.js} +2 -2
- package/dist/assets/{howler-CzrxH3Wg.js.map → howler-R81SmKVH.js.map} +1 -1
- package/dist/assets/{index-CZU3kiy9.js → index-4RuPrhph.js} +4 -4
- package/dist/assets/{index-CZU3kiy9.js.map → index-4RuPrhph.js.map} +1 -1
- package/dist/index.html +1 -1
- package/package.json +1 -1
|
@@ -5551,7 +5551,7 @@ float sobelSample(sampler2D t, sampler2D d, vec2 uv, vec2 resolution, float outl
|
|
|
5551
5551
|
outgoingLight = spe_blend( diffuseColor, outgoingLight, ${a.result} * ${h}, ${s.result} );
|
|
5552
5552
|
}
|
|
5553
5553
|
`),o&&u.push(o.code,`outgoingLight = spe_blend(outgoingLight, ${o.result}, 1.0, SPE_BLENDING_NORMAL);`),l?u.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${l.result} );`):u.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),c&&u.push(`gl_FragColor.a *= ${c.result};`),u.push("#include <encodings_fragment>","#include <fog_fragment>","#include <dithering_fragment>"),t=u.join(`
|
|
5554
|
-
`)}return t}},wut=class{constructor(e=1e3*10){this.timeout=e,this.cache=new Map,this.head={data:null,time:0,src:null,next:null,prev:null},this.tail={data:null,time:1/0,src:null,next:null,prev:null},this.hasClean=!1,this.cleanupTimer=null,this.head.next=this.tail,this.tail.prev=this.head}log(...e){}remove(e){let t=this.cache.get(e);t&&(this.dispose(e,t.data),this.cache.delete(e),t.prev.next=t.next,t.next.prev=t.prev,t.next=null,t.prev=null,t.data=null)}scheduleCleanup(){this.hasClean||(this.log("scheduled cleanup"),this.hasClean=!0,this.cleanupTimer=setTimeout(()=>{this.hasClean=!1,this.cleanupTimer=null,this.log("cleaning");let e=Date.now(),t=this.head.next;for(;t.time<e-this.timeout;){this.dispose(t.src,t.data),this.cache.delete(t.src);let i=t;t=t.next,t.prev=this.head,this.head.next=t,i.next=null,i.prev=null,i.data=null}this.head.next!==this.tail?this.scheduleCleanup():this.log("no more cleanup")},this.timeout+1e3))}has(e){var t;return(t=this.cache.get(e))==null?void 0:t.data}load(e){let t=Date.now(),i=this.cache.get(e);return i===void 0?(i={data:this.create(e),src:e,time:t,next:null,prev:null},this.cache.set(e,i)):(i.time=t,i.prev.next=i.next,i.next.prev=i.prev),i.prev=this.tail.prev,i.next=this.tail,this.tail.prev.next=i,this.tail.prev=i,this.scheduleCleanup(),i.data}disposeAll(){this.cleanupTimer!==null&&(clearTimeout(this.cleanupTimer),this.cleanupTimer=null),this.hasClean=!1,this.cache.forEach((e,t)=>{this.dispose(t,e.data),e.next=null,e.prev=null,e.data=null}),this.cache.clear(),this.head.next=this.tail,this.tail.prev=this.head}destroy(){this.disposeAll(),this.head=null,this.tail=null}},_ut=class extends wut{create(e){return URL.createObjectURL(new Blob([e]))}dispose(e,t){URL.revokeObjectURL(t)}},$T;function Sut(e){return typeof e=="string"?e:($T||($T=new _ut),$T.load(e))}function Aut(){$T&&$T.disposeAll()}var Mut=class{constructor(e,t){this.data=e,this.cache=t,this.refCount=0}deref(){this.refCount,this.refCount-=1,this.refCount===0&&(this.cache.remove(this),this.dispose())}dispose(){this.refCount}},Eut=class{constructor(){this.cache=new Map}remove(e){this.cache.delete(e.data)}load(e){let t=this.cache.get(e);return t===void 0&&(t=this.create(e),this.cache.set(e,t)),t.refCount+=1,t}},Swe=class extends Mut{constructor(e,t){super(e,t.imageHolderCache),this.data=e,this.shared=t,this.loaded=!1,this.isVideo=!1,this.isBuffer=!1,this._cache={1e3:{},1001:{},1002:{}},this.isVideo=e.type==="video",this.isBuffer=e.isWebGLRenderTarget===!0,this.loadPromise=this.updateSrc(this.isBuffer?e:e.data)}async updateSrc(e){if(typeof document>"u")return;this.disposeTextures(),this.loaded=!1;let t=()=>{this.loaded=!0;for(let r of Object.values(this._cache))for(let n of Object.values(r))for(let a of Object.values(n))a&&(a.image=this.img,a.needsUpdate=!0);this.shared.requestRender()};if(this.isBuffer)this.img=e,this.loaded=!0;else if(this.isVideo){if(this.img=document.createElement("video"),this.img.preload="auto",this.img.playsInline=!0,this.img.currentTime=.01,typeof e!="string"){var i=new FileReader;i.readAsDataURL(new Blob([e],{type:"video/mp4"}));let r;await new Promise(n=>{i.onloadend=a=>{var s;r=(s=a.target)==null?void 0:s.result,n(null)}}),this.img.src=r}else this.img.src=e;this.img.onloadeddata=()=>{t()}}else this.img=new Image,this.img.src=Sut(e),this.img.onload=t,await new Promise(r=>{this.img.onload=()=>{t(),r(null)}})}getTexture(e,t=1008,i=1006){var n,a;let r=(a=(n=this._cache[e])==null?void 0:n[t])==null?void 0:a[i];if(r)return r;{let s;return this.isBuffer?s=this.img.texture:this.isVideo?s=new ZXe(this.img,void 0,e,e):s=new wa(this.img,void 0,e,e,i,t),this.loaded&&(s.needsUpdate=!0),this._cache[e]===void 0&&(this._cache[e]={}),this._cache[e][t]===void 0&&(this._cache[e][t]={}),this._cache[e][t][i]=s,s}}setNeedsUpdate(e){for(let t of Object.values(this._cache))for(let i of Object.values(t))for(let r of Object.values(i))r&&(r.needsUpdate=e)}disposeTextures(){for(let[e,t]of Object.entries(this._cache))for(let[i,r]of Object.entries(t))for(let[n,a]of Object.entries(r))a==null||a.dispose(),this._cache[e]!==void 0&&this._cache[e][i]!==void 0&&(this._cache[e][i][n]=void 0)}dispose(){super.dispose(),this.disposeTextures()}},zv=class extends Swe{};function Tut(e,t){var i=Out(t);return i.formatToParts?Put(i,e):Dut(i,e)}var Cut={year:0,month:1,day:2,hour:3,minute:4,second:5};function Put(e,t){try{for(var i=e.formatToParts(t),r=[],n=0;n<i.length;n++){var a=Cut[i[n].type];a>=0&&(r[a]=parseInt(i[n].value,10))}return r}catch(s){if(s instanceof RangeError)return[NaN];throw s}}function Dut(e,t){var i=e.format(t).replace(/\u200E/g,""),r=/(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/.exec(i);return[r[3],r[1],r[2],r[4],r[5],r[6]]}var w6={};function Out(e){if(!w6[e]){var t=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:"America/New_York",year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(new Date("2014-06-25T04:00:00.123Z")),i=t==="06/25/2014, 00:00:00"||t==="06/25/2014 00:00:00";w6[e]=i?new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:e,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}):new Intl.DateTimeFormat("en-US",{hourCycle:"h23",timeZone:e,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})}return w6[e]}function Awe(e,t,i,r,n,a,s){var o=new Date(0);return o.setUTCFullYear(e,t,i),o.setUTCHours(r,n,a,s),o}var hue=36e5,Rut=6e4,_6={timezoneZ:/^(Z)$/,timezoneHH:/^([+-]\d{2})$/,timezoneHHMM:/^([+-]\d{2}):?(\d{2})$/};function Mwe(e,t,i){var r,n;if(!e||(r=_6.timezoneZ.exec(e),r))return 0;var a;if(r=_6.timezoneHH.exec(e),r)return a=parseInt(r[1],10),due(a)?-(a*hue):NaN;if(r=_6.timezoneHHMM.exec(e),r){a=parseInt(r[1],10);var s=parseInt(r[2],10);return due(a,s)?(n=Math.abs(a)*hue+s*Rut,a>0?-n:n):NaN}if(Lut(e)){t=new Date(t||Date.now());var o=i?t:Iut(t),l=H9(o,e),c=i?l:Nut(t,l,e);return-c}return NaN}function Iut(e){return Awe(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds())}function H9(e,t){var i=Tut(e,t),r=Awe(i[0],i[1]-1,i[2],i[3]%24,i[4],i[5],0).getTime(),n=e.getTime(),a=n%1e3;return n-=a>=0?a:1e3+a,r-n}function Nut(e,t,i){var r=e.getTime(),n=r-t,a=H9(new Date(n),i);if(t===a)return t;n-=a-t;var s=H9(new Date(n),i);return a===s?a:Math.max(a,s)}function due(e,t){return-23<=e&&e<=23&&(t==null||0<=t&&t<=59)}var fue={};function Lut(e){if(fue[e])return!0;try{return new Intl.DateTimeFormat(void 0,{timeZone:e}),fue[e]=!0,!0}catch{return!1}}var kut=N0(jGe(),1),pue=N0(FGe(),1),zut=/(Z|[+-]\d{2}(?::?\d{2})?| UTC| [a-zA-Z]+\/[a-zA-Z_]+(?:\/[a-zA-Z_]+)?)$/,But=zut,S6=36e5,mue=6e4,Uut=2,Kl={dateTimePattern:/^([0-9W+-]+)(T| )(.*)/,datePattern:/^([0-9W+-]+)(.*)/,YY:/^(\d{2})$/,YYY:[/^([+-]\d{2})$/,/^([+-]\d{3})$/,/^([+-]\d{4})$/],YYYY:/^(\d{4})/,YYYYY:[/^([+-]\d{4})/,/^([+-]\d{5})/,/^([+-]\d{6})/],MM:/^-(\d{2})$/,DDD:/^-?(\d{3})$/,MMDD:/^-?(\d{2})-?(\d{2})$/,Www:/^-?W(\d{2})$/,WwwD:/^-?W(\d{2})-?(\d{1})$/,HH:/^(\d{2}([.,]\d*)?)$/,HHMM:/^(\d{2}):?(\d{2}([.,]\d*)?)$/,HHMMSS:/^(\d{2}):?(\d{2}):?(\d{2}([.,]\d*)?)$/,timeZone:But};function jut(e,t){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");if(e===null)return new Date(NaN);var i={},r=i.additionalDigits==null?Uut:(0,kut.default)(i.additionalDigits);if(r!==2&&r!==1&&r!==0)throw new RangeError("additionalDigits must be 0, 1 or 2");if(e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]")return new Date(e.getTime());if(typeof e=="number"||Object.prototype.toString.call(e)==="[object Number]")return new Date(e);if(!(typeof e=="string"||Object.prototype.toString.call(e)==="[object String]"))return new Date(NaN);var n=Fut(e),a=Vut(n.date,r),s=a.year,o=a.restDateString,l=Hut(o,s);if(isNaN(l))return new Date(NaN);if(l){var c=l.getTime(),u=0,h;if(n.time&&(u=Gut(n.time),isNaN(u)))return new Date(NaN);if(n.timeZone||i.timeZone){if(h=Mwe(n.timeZone||i.timeZone,new Date(c+u)),isNaN(h))return new Date(NaN)}else h=(0,pue.default)(new Date(c+u)),h=(0,pue.default)(new Date(c+u+h));return new Date(c+u+h)}else return new Date(NaN)}function Fut(e){var t={},i=Kl.dateTimePattern.exec(e),r;if(i?(t.date=i[1],r=i[3]):(i=Kl.datePattern.exec(e),i?(t.date=i[1],r=i[2]):(t.date=null,r=e)),r){var n=Kl.timeZone.exec(r);n?(t.time=r.replace(n[1],""),t.timeZone=n[1].trim()):t.time=r}return t}function Vut(e,t){var i=Kl.YYY[t],r=Kl.YYYYY[t],n;if(n=Kl.YYYY.exec(e)||r.exec(e),n){var a=n[1];return{year:parseInt(a,10),restDateString:e.slice(a.length)}}if(n=Kl.YY.exec(e)||i.exec(e),n){var s=n[1];return{year:parseInt(s,10)*100,restDateString:e.slice(s.length)}}return{year:null}}function Hut(e,t){if(t===null)return null;var i,r,n,a;if(e.length===0)return r=new Date(0),r.setUTCFullYear(t),r;if(i=Kl.MM.exec(e),i)return r=new Date(0),n=parseInt(i[1],10)-1,vue(t,n)?(r.setUTCFullYear(t,n),r):new Date(NaN);if(i=Kl.DDD.exec(e),i){r=new Date(0);var s=parseInt(i[1],10);return Xut(t,s)?(r.setUTCFullYear(t,0,s),r):new Date(NaN)}if(i=Kl.MMDD.exec(e),i){r=new Date(0),n=parseInt(i[1],10)-1;var o=parseInt(i[2],10);return vue(t,n,o)?(r.setUTCFullYear(t,n,o),r):new Date(NaN)}if(i=Kl.Www.exec(e),i)return a=parseInt(i[1],10)-1,yue(t,a)?gue(t,a):new Date(NaN);if(i=Kl.WwwD.exec(e),i){a=parseInt(i[1],10)-1;var l=parseInt(i[2],10)-1;return yue(t,a,l)?gue(t,a,l):new Date(NaN)}return null}function Gut(e){var t,i,r;if(t=Kl.HH.exec(e),t)return i=parseFloat(t[1].replace(",",".")),A6(i)?i%24*S6:NaN;if(t=Kl.HHMM.exec(e),t)return i=parseInt(t[1],10),r=parseFloat(t[2].replace(",",".")),A6(i,r)?i%24*S6+r*mue:NaN;if(t=Kl.HHMMSS.exec(e),t){i=parseInt(t[1],10),r=parseInt(t[2],10);var n=parseFloat(t[3].replace(",","."));return A6(i,r,n)?i%24*S6+r*mue+n*1e3:NaN}return null}function gue(e,t,i){t=t||0,i=i||0;var r=new Date(0);r.setUTCFullYear(e,0,4);var n=r.getUTCDay()||7,a=t*7+i+1-n;return r.setUTCDate(r.getUTCDate()+a),r}var Wut=[31,28,31,30,31,30,31,31,30,31,30,31],qut=[31,29,31,30,31,30,31,31,30,31,30,31];function Ewe(e){return e%400===0||e%4===0&&e%100!==0}function vue(e,t,i){if(t<0||t>11)return!1;if(i!=null){if(i<1)return!1;var r=Ewe(e);if(r&&i>qut[t]||!r&&i>Wut[t])return!1}return!0}function Xut(e,t){if(t<1)return!1;var i=Ewe(e);return!(i&&t>366||!i&&t>365)}function yue(e,t,i){return!(t<0||t>52||i!=null&&(i<0||i>6))}function A6(e,t,i){return!(e!=null&&(e<0||e>=25)||t!=null&&(t<0||t>=60)||i!=null&&(i<0||i>=60))}function Yut(e,t,i){var r=jut(e,i),n=Mwe(t,r,!0),a=new Date(r.getTime()-n),s=new Date(0);return s.setFullYear(a.getUTCFullYear(),a.getUTCMonth(),a.getUTCDate()),s.setHours(a.getUTCHours(),a.getUTCMinutes(),a.getUTCSeconds(),a.getUTCMilliseconds()),s}function tc(e,t){return t.color(e)}function xue(e=new Date,t){let i=t.format,r=e.getSeconds(),n=e;t&&t.timeZone!==null&&(n=Yut(new Date,t.timeZone));let a=n.getHours(),s=n.getMinutes(),o;t.format12h24h==="12ampm"&&(o=a>=12?"PM":"AM");let l=a;t.format12h24h!=="24"&&(l=a%12,l===0&&(l=12));let c,u;switch(i){case"HH:mm:ss":c=[l,s,r];break;case"HH:mm":c=[l,s];break;case"HH":c=[l],o=void 0;break;case"mm":c=[s],o=void 0;break;case"ss":c=[r],o=void 0;break;case"year":u=n.getFullYear();break;case"month":u=n.getMonth()+1;break;case"dayOfYear":u=Math.floor((n.getTime()-new Date(n.getFullYear(),0,0).getTime())/864e5);break;case"dayOfMonth":u=n.getDate();break;case"secondOfDay":u=a*60*60+s*60+r;break;default:console.error("Unknown time format",i),u=0;break}return c!==void 0?{textValue:c,suffix:o}:u}function $ut(e,t){switch(e.type){case"fresnel":return Zut(e,t);case"gradient":return Jut(e,t);case"depth":return eht(e,t);case"normal":return tht(e,t);case"noise":return iht(e,t);case"rainbow":return rht(e,t);case"toon":return nht(e,t);case"outline":return aht(e,t);case"transmission":return sht(e,t);case"pattern":return oht(e,t);case"color":default:return Qut(e,t)}}function Kut(e){return{type:e.type}}function Rd(e,t){let{alpha:i,mode:r,isMask:n}=e,a=typeof i=="string"?(Number(t.getVariable(i))??100)/100:i;return{...Kut(e),alpha:a,mode:r,isMask:n}}function Qut(e,t){return{...Rd(e,t),color:tc(e.color,t)}}function Zut(e,t){let{bias:i,scale:r,intensity:n,factor:a,color:s}=e;return{...Rd(e,t),color:tc(s,t),bias:i,scale:r,intensity:n,factor:a}}function Jut(e,t){let{gradientType:i,smooth:r,colors:n,steps:a,angle:s,offset:o,morph:l}=e;return{...Rd(e,t),gradientType:i,smooth:r,colors:n.map(c=>new Ii(c[0],c[1],c[2],c[3])),num:n.length,steps:a,offset:new Ce(...o.map(c=>typeof c=="number"?c:0)),morph:new Ce(...l.map(c=>typeof c=="number"?c:0)),angle:s}}function eht(e,t){let{gradientType:i,near:r,far:n,isVector:a,isWorldSpace:s,origin:o,direction:l,colors:c,steps:u,smooth:h}=e;return{...Rd(e,t),gradientType:i,near:r,far:n,isVector:a,isWorldSpace:s,origin:new Y(...o),direction:l?new Y(...l):new Y(1,0,0),colors:c.map(d=>d!==void 0?new Ii(d[0],d[1],d[2],d[3]):new Ii(0,0,0,0)),steps:u.slice(0,c.length),smooth:h}}function tht(e,t){let{cnormal:i}=e;return{...Rd(e,t),cnormal:new Y(i[0],i[1],i[2])}}function iht(e,t){return{...Rd(e,t),scale:e.scale,move:e.move,fA:new Ce(...e.fA.map(i=>typeof i=="number"?i:0)),fB:new Ce(...e.fB.map(i=>typeof i=="number"?i:0)),size:new Y(...e.size),distortion:new Ce(...e.distortion.map(i=>typeof i=="number"?i:0)),colorA:tc(e.colorA,t),colorB:tc(e.colorB,t),colorC:tc(e.colorC,t),colorD:tc(e.colorD,t),noiseType:e.noiseType,voronoiStyle:e.voronoiStyle,highCut:e.highCut,lowCut:e.lowCut,smoothness:e.smoothness,seed:e.seed,quality:e.quality}}function rht(e,t){return{...Rd(e,t),filmThickness:e.filmThickness,movement:e.movement,wavelengths:new Y(...e.wavelengths),noiseStrength:e.noiseStrength,noiseScale:e.noiseScale,offset:new Y(...e.offset)}}function nht(e,t){return{...Rd(e,t),positioning:e.positioning,colors:e.colors.map(i=>new Ii(i[0],i[1],i[2],i[3])),num:e.colors.length,steps:e.steps,source:new Y(...e.source),isWorldSpace:e.isWorldSpace,noiseStrength:e.noiseStrength,noiseScale:e.noiseScale,shadowColor:tc(e.shadowColor,t),offset:new Y(...e.offset)}}function aht(e,t){return{...Rd(e,t),outlineColor:tc(e.outlineColor,t),contourColor:tc(e.contourColor,t),outlineWidth:e.outlineWidth,contourWidth:e.contourWidth,outlineThreshold:e.outlineThreshold,contourThreshold:e.contourThreshold,outlineSmoothing:e.outlineSmoothing,contourFrequency:e.contourFrequency,contourDirection:new Y(...e.contourDirection),positionalLines:e.positionalLines,compensation:e.compensation}}function sht(e,t){return{...Rd(e,t),thickness:e.thickness,ior:e.ior,roughness:e.roughness}}function oht(e,t){return{...Rd(e,t),style:e.style,projection:e.projection,axis:e.axis,blending:e.blending,offset:new Ce(...e.offset.map(i=>typeof i=="number"?i:0)),colorA:tc(e.colorA,t),colorB:tc(e.colorB,t),frequency:new Ce(...e.frequency.map(i=>typeof i=="number"?i:0)),size:e.size,variation:e.variation,smoothness:e.smoothness,zigzag:e.zigzag,rotation:e.rotation,vertical:new Ce(...e.vertical.map(i=>typeof i=="number"?i:0)),horizontal:new Ce(...e.horizontal.map(i=>typeof i=="number"?i:0)),sides:e.sides}}var HL=class extends Ks{},lht={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"]},cht={depth:["colors"]};function uht(e,t,i){var a,s;if(t==="isMask")return!0;let r=lht[e.type],n=cht[e.type];if(n!==void 0){let o=e.color;if(n.includes(t)){let l=(s=(a=o[t])==null?void 0:a.value)==null?void 0:s.length;if(l!==void 0&&l!==i.length)return!0}}return r!==void 0?r.includes(t):!1}function M6(e,t){if(Array.isArray(t)){if(!Array.isArray(e)||e.length!==t.length)return!1;for(let[n,a]of t.entries()){let s=e[n];if(typeof a=="string"||typeof a=="number"&&typeof s=="string")return!0}return!1}let i=typeof e=="string",r=typeof t=="string";return i!==r||i&&r}function o$(e,t,i){let r=i.uniforms[`f${i.id}_texture`];if(!r)return!1;let n=!1,a=e;if("image"in a){let s=a.image,o=t.image(s),l=r;l.image instanceof zv||l.image.deref(),l.image=o}if("video"in a){let s=a.video,o=t.video(s),l=r;l.image instanceof zv||l.image.deref(),l.image=o}if("wrapping"in a){let s=r;s.wrap=a.wrapping}if("minFilter"in a){let s=r;s.minFilter=a.minFilter}if("magFilter"in a){let s=r;s.magFilter=a.magFilter}if("rotation"in a&&i.uniforms[`f${i.id}_rotation`])return i.uniforms[`f${i.id}_rotation`].value=(Pi(a.rotation??0,t)??0)*Wt.DEG2RAD,n;if("repeat"in a||"offset"in a||"rotation"in a){let s="mat",o=i.uniforms[`f${i.id}_${s}`];if(!o)return n;if("repeat"in a){let l=a.repeat;M6(i.data.texture.repeat,l)&&(n=!0),o.repeat=KT(l,t).map((c,u)=>typeof l[u]=="string"?1/c:c)}if("offset"in a){let l=a.offset;M6(i.data.texture.offset,l)&&(n=!0),o.offset=KT(l,t).map((c,u)=>typeof l[u]=="string"?-c:c)}if("rotation"in a){let l=i.data.texture.rotation,c=a.rotation??0;(l===void 0||M6(l,c))&&(n=!0),o.rotation=Pi(c,t)??0}o.updateMatrix()}return n}function hht(e,t,i,r){let n=!1;for(let[a,s]of Object.entries(e)){if(a==="bumpMap"||a==="roughnessMap"){n=!0;continue}if(!a||s===void 0)continue;if(Cwe(a,i,r,t)){a==="visible"&&i.type==="light"&&(n=!0);continue}i.visible=r.visible;let o=i.uniforms[`f${i.id}_${a}`];if(o&&!(o instanceof n$))switch(n=n||uht(i,a,s),o.constructor){case qa:if(typeof s=="string"){let l=t.getColor(s);l&&(o.value=l);break}else{let l=s;o.value instanceof HL?o.value=new Ks(l.r,l.g,l.b,l.a):o.setRGBA(l);break}case mm:if(typeof s=="string"){let l=t.getColor(s);l&&(o.value=l);break}else{let l=s;o.value instanceof HL?o.value=new Ks(l.r,l.g,l.b,l.a):o.value.setRGBA(l.r,l.g,l.b,l.a);break}case Wo:{let l=s;o.value.setX(l[0]),o.value.setY(l[1]);break}case hh:{let l=s;o.value.setX(l[0]),o.value.setY(l[1]),o.value.setZ(l[2]);break}case _m:{o$(s,t,i);break}case sx:{o.value=s.map(l=>new Ii(...l));break}default:{o.value=s;break}}}return n}var ob=(e,t,i)=>Math.max(0,Math.min(1,Number(t.getVariable(typeof e=="number"?e*100:e,i)??100)/100))??1,Pi=(e,t,i)=>typeof e=="number"?e:t.getVariable(e,i),lv=(e,t)=>(e||(e=new Y),e.x=Pi(e.x,t)??0,e.y=Pi(e.y,t)??0,e.z=Pi(e.z,t)??0,e),Zp=(e,t)=>(e||(e=new Ce),e.x=Pi(e.x,t)??0,e.y=Pi(e.y,t)??0,e),KT=(e,t)=>{let i=e.map(r=>Pi(r,t)??0);return[i[0],i[1]]},yD=class{constructor(e,t,i,r,n){this.id=e,this.uuid=t,this.data=i,this.uniforms={};for(let a in r)this.uniforms[`f${this.id}_${a}`]=r[a];for(let a in i)Cwe(a,this,i,n)}get type(){return this.data.type}static create(e,t,i,r){if(i.type==="light")return Cf.createLightLayer(e,t,i,r);if(i.type==="texture"||i.type==="video"){let n=i.type==="texture"?r.uiBuffer(i.texture.image)??r.image(i.texture.image):r.video(i.texture.video),a=new j9(n,i.texture.wrapping,i.texture.minFilter??1008,i.texture.magFilter??1006),s=new dut(n),o=new fut(KT(i.texture.repeat,r),KT(i.texture.offset,r),Pi(i.texture.rotation??0,r)),l=new Zt(i.crop?1:0),c=new Ln(i.projection??0),u=new Ln(["x","y","z"].indexOf(i.axis)??0),h=new Ln(i.side??0),d=new Wo(i.size?new Ce(...KT(i.size,r)):new Ce(100,100)),f=new Zt(i.blending??0),m=new Zt(ob(i.alpha,r)),y=new Ln(i.mode??0),g=new wl(i.isMask??!1),x=new a$(a,s,l,c,u,h,d,f,o,m,y,g),w=new Kn(x.calpha,"f");return new ja(e,t,i,{texture:a,textureSize:s,crop:l,projection:c,axis:u,side:h,size:d,blending:f,mat:o,alpha:m,mode:y,isMask:g},x,y,w,g,r)}else if(i.type==="matcap"){let n=r.image(i.texture.image),a=new j9(n,i.texture.wrapping,i.texture.minFilter??1008,i.texture.magFilter??1006),s=new Zt(ob(i.alpha,r)),o=new Ln(i.mode??0),l=new wl(i.isMask??!1),c=new Zt((Pi(i.texture.rotation??0,r)??0)*Wt.DEG2RAD),u=new cwe(a,s,o,l,c),h=new Kn(u.calpha,"f");return new ja(e,t,i,{texture:a,alpha:s,mode:o,isMask:l,rotation:c},u,o,h,l,r)}else if(i.type==="displace")if(i.displacementType==="noise"){let n=new hh(new Y(...i.offset.map(g=>Pi(g,r)??0))),a=new Zt(Pi(i.scale,r)??10),s=new Zt(Pi(i.intensity,r)??8),o=new Zt(Pi(i.movement,r)??1),l=new Ln(i.noiseType??0),c=new Ln(i.voronoiStyle??0),u=new Zt(Pi(i.smoothness,r)??.5),h=new Zt(Pi(i.seed,r)??0),d=new Zt(Pi(i.highCut,r)??1),f=new Zt(Pi(i.lowCut,r)??0),m=new Ln(Pi(i.quality,r)??1),y=new wwe(s,o,n,c,u,h,d,f,m,a,l);return new Twe(e,t,i,{offset:n,scale:a,intensity:s,movement:o,noiseType:l,voronoiStyle:c,smoothness:u,seed:h,highCut:d,lowCut:f,quality:m},y,r)}else throw new Error;else return pht(e,t,i,r)}updateByOp(e,t,i){let r=e,n=!1;if(r.path[0]===void 0){for(let a of Object.keys(r.props))try{let s=this.data[a],o=t[a];if(Array.isArray(s)&&Array.isArray(o)){for(let[l,c]of o.entries()){let u=s[l];if(typeof c=="string"||typeof c=="number"&&typeof u=="string"){n=!0;break}}if(n)break}else if(typeof o=="string"&&typeof s=="number"||typeof o=="number"&&typeof s=="string"||typeof o=="string"&&typeof s=="string"&&o!==s){n=!0;break}}catch(s){console.error(s)}if(r.type===0)return"type"in r.props||"category"in r.props||"visible"in r.props||"noiseType"in r.props?(i.scene.markNeedsUpdateRendererDirty(),!0):hht(r.props,i.shared,this,t)||n}else if(r.path[0]==="texture")return"texture"in t||"video"in t?o$(r.props,i.shared,this)||n:!0;return n}dispose(){if(dht(this)){let e=this.uniforms[`f${this.id}_texture`];if(!e)return!1;let t=e;t.image instanceof zv||t.image.deref()}}hasValueByKey(e){return this.uniforms[e]!==void 0}hasValue(e){return this.hasValueByKey(`f${this.id}_${e}`)}setValue(e,t){let i=`f${this.id}_${e}`;this.hasValueByKey(i)&&t!==void 0&&(this.uniforms[i].value=t)}getNode(e){let t=`f${this.id}_${e}`;if(this.hasValueByKey(t))return this.uniforms[t]}getValue(e){let t=`f${this.id}_${e}`;if(this.hasValueByKey(t))return this.uniforms[t].value}getName(e){let t=/f\d+_(.*)/.exec(e);if(t&&t.length>1)return t[1];console.log(`Layer.getName: error ${e}`)}getNames(){let e=[];for(let t in this.uniforms){let i=this.getName(t);i&&e.push(i)}return e}},ja=class extends yD{constructor(e,t,i,r,n,a,s,o,l){super(e,t,i,r,l),this.params=r,this.color=n,this.mode=a,this.alpha=s,this.isMask=o}},Twe=class extends yD{constructor(e,t,i,r,n,a){super(e,t,i,r,a),this.position=n}},Cf=class extends yD{constructor(e,t,i,r,n,a){super(e,t,i,n,a),this.node=r}static createLightLayer(e,t,i,r){let n,a=new Zt(ob(i.alpha,r)),s=new Ln(i.mode),o=new Zt(i.bumpMapIntensity),l=new Zt(ob(i.alphaOverride,r)),c;if(!i.visible)n=new s$,c={};else if(i.category==="lambert"){n=new vut;let u=new qa(r.color(i.emissive)??0),h=new wl(i.occlusion??!0);c={emissive:u,occlusion:h},n.emissive=u,n.occlusion=h}else if(i.category==="toon"){n=new but;let u=new Zt(i.shininess??30),h=new qa(r.color(i.specular)??1118481);c={shininess:u,specular:h},n.shininess=u,n.specular=h}else if(i.category==="physical"){n=new xut;let u=new Zt(i.roughness??.3),h=new Zt(i.metalness??0),d=new Zt(i.reflectivity??.5),f=new wl(i.occlusion??!0);c={roughness:u,metalness:h,reflectivity:d,occlusion:f},n.roughness=u,n.metalness=h,n.reflectivity=d,n.occlusion=f}else{n=new yut;let u=new Zt(i.shininess??30),h=new qa(i.specular!==void 0?r.color(i.specular)??1118481:1118481),d=new wl(i.occlusion??!0);c={shininess:u,specular:h,occlusion:d},n.shininess=u,n.specular=h,n.occlusion=d}return n.alpha=new Zt(1),n.shadingAlpha=a,n.shadingBlend=s,n.bumpMapIntensity=o,n.alphaOverride=l,c.alpha=n.shadingAlpha,c.mode=n.shadingBlend,c.bumpMapIntensity=n.bumpMapIntensity,c.alphaOverride=n.alphaOverride,new Cf(e,t,i,n,c,r)}get category(){return this.node.category}};function dht(e){let t=e instanceof yD?e.type:e;return t==="texture"||t==="video"||t==="displace_map"||t==="matcap"}function nh(e){return{alpha:new Zt(e.alpha??1),mode:new Ln(e.mode??0),isMask:new wl(e.isMask??!1)}}function fht(e,t,i,r,n){switch(e.type){case"color":{let a=new qa(r.color??Au),s=nh(r),o=new F9(a,s.alpha),l=new Kn(o.calpha,"f");return new ja(t,i,e,{color:a,...s},o,s.mode,l,s.isMask,n)}case"fresnel":{let a=new qa(r.color??16777215),s=new Zt(Pi(r.bias,n)??.1),o=new Zt(Pi(r.scale,n)??1),l=new Zt(Pi(r.intensity,n)??2),c=new Zt(Pi(r.factor,n)??1),u=nh(r),h=new put(a,s,o,l,c,u.alpha,u.mode,u.isMask),d=new Kn(h.calpha,"f");return new ja(t,i,e,{color:a,bias:s,scale:o,intensity:l,factor:c,...u},h,u.mode,d,u.isMask,n)}case"rainbow":{let a=new Zt(Pi(r.filmThickness,n)??30),s=new Zt(Pi(r.movement,n)??0),o=new hh(lv(r.wavelengths,n)),l=new Zt(Pi(r.noiseStrength,n)??0),c=new Zt(Pi(r.noiseScale,n)??1),u=new hh(lv(r.offset,n)),h=nh(r),d=new mwe(a,s,o,l,c,u,h.alpha,h.isMask),f=new Kn(d.calpha,"f");return new ja(t,i,e,{filmThickness:a,movement:s,wavelengths:o,noiseStrength:l,noiseScale:c,offset:u,...h},d,h.mode,f,h.isMask,n)}case"transmission":{let a=new Zt(Pi(r.thickness??10,n)),s=new Zt(Pi(r.ior??1.5,n)),o=new Zt(Pi(r.roughness??.5,n)),l=gi.transmissionSize,c=gi.transmissionRenderTarget,u=gi.transmissionRenderTargetDepth,h=window.innerWidth,d=window.innerHeight,f=h>=d?new Wo(d/h,1):new Wo(1,h/d),m=nh(r),y=new xwe(a,s,o,l,c,u,f,m.alpha),g=new Kn(y.calpha,"f");return new ja(t,i,e,{thickness:a,ior:s,roughness:o,aspectRatio:f,...m},y,m.mode,g,m.isMask,n)}case"toon":{let a=new Ln(r.positioning??0),s;r.colors?s=new sx(r.colors.length,r.colors):(s=new sx(10,new Ii(0,0,0,1)),s.value[1]=new Ii(1,1,1,1));let o;r.steps?o=new ax(r.steps.length,r.steps):(o=new ax(10,1),o.value[0]=0);let l=new hh(lv(r.source??new Y(0,0,0),n)),c=new wl(r.isWorldSpace??!0),u=new Zt(Pi(r.noiseStrength??0,n)),h=new Zt(Pi(r.noiseScale??1,n)),d=new mm(r.shadowColor),f=new hh(lv(r.offset??new Y(0,0,0),n)),m=nh(r),y=new vwe(a,s,o,l,c,u,h,d,f,m.alpha),g=new Kn(y.calpha,"f");return new ja(t,i,e,{positioning:a,colors:s,steps:o,source:l,isWorldSpace:c,noiseStrength:u,noiseScale:h,shadowColor:d,offset:f,...m},y,m.mode,g,m.isMask,n)}case"outline":{let a=new qa(r.outlineColor??16777215),s=new qa(r.contourColor??16777215),o=new Zt(Pi(r.outlineWidth??.1,n)),l=new Zt(Pi(r.contourWidth??.1,n)),c=new Zt(Pi(r.outlineThreshold??.1,n)),u=new Zt(Pi(r.contourThreshold??.1,n)),h=new Zt(Pi(r.outlineSmoothing??.1,n)),d=new Zt(Pi(r.contourFrequency??.1,n)),f=new hh(lv(r.contourDirection??new Y(0,1,0),n)),m=new wl(r.positionalLines??!1),y=new wl(r.compensation??!0),g=gi.normalRenderTarget,x=gi.normalRenderTargetDepth,w=gi.pixelRatioNode,S=gi.resolution,M=nh(r),E=new dwe(a,s,o,l,c,u,h,d,f,m,y,S,g,x,w,M.alpha),T=new Kn(E.calpha,"f");return new ja(t,i,e,{outlineColor:a,contourColor:s,outlineWidth:o,contourWidth:l,outlineThreshold:c,contourThreshold:u,outlineSmoothing:h,contourFrequency:d,contourDirection:f,positionalLines:m,compensation:y,...M},E,M.mode,T,M.isMask,n)}case"depth":{let a=new Ln(r.gradientType??0),s=new wl(r.smooth??!1),o=new Zt(Pi(r.near,n)??50),l=new Zt(Pi(r.far,n)??200),c=new Zt(r.isVector??1),u=new Zt(r.isWorldSpace??0),h=new hh(lv(r.origin,n)),d=new hh(lv(r.direction,n)),f;r.colors?f=new sx(r.colors.length,r.colors):(f=new sx(2,new Ii(0,0,0,1)),f.value[1]=new Ii(1,1,1,1));let m;r.steps?m=new ax(r.steps.length,r.steps):(m=new ax(2,1),m.value[0]=0);let y=nh(r),g=new awe(a,s,o,l,c,u,h,d,f,m,y.alpha,y.isMask),x=new Kn(g.calpha,"f");return new ja(t,i,e,{gradientType:a,smooth:s,near:o,far:l,isVector:c,isWorldSpace:u,origin:h,direction:d,colors:f,steps:m,...y},g,y.mode,x,y.isMask,n)}case"noise":{let a=new Zt(Pi(r.scale,n)??1),s=new hh(lv(r.size??new Y(100,100,100),n)),o=new Zt(Pi(r.move,n)??1),l=new Wo(Zp(r.fA??new Ce(1.7,9.2),n)),c=new Wo(Zp(r.fB??new Ce(8.3,2.8),n)),u=new Wo(Zp(r.distortion??new Ce(1,1),n)),h=new mm(r.colorA),d=new mm(r.colorB),f=new mm(r.colorC),m=new mm(r.colorD),y=new Ln(r.noiseType??0),g=new Ln(r.voronoiStyle??0),x=new Zt(Pi(r.highCut,n)??1),w=new Zt(Pi(r.lowCut,n)??0),S=new Zt(Pi(r.smoothness,n)??.5),M=new Zt(Pi(r.seed,n)??.5),E=new Ln(r.quality??1),T=nh(r),R=new uwe(a,s,o,l,c,u,h,d,f,m,T.alpha,y,T.isMask,g,x,w,S,M,E),P=new Kn(R.calpha,"f");return new ja(t,i,e,{scale:a,size:s,move:o,fA:l,fB:c,distortion:u,colorA:h,colorB:d,colorC:f,colorD:m,noiseType:y,...T,voronoiStyle:g,highCut:x,lowCut:w,smoothness:S,seed:M,quality:E},R,T.mode,P,T.isMask,n)}case"normal":{let a=new hh(r.cnormal??new Y(1,1,1)),s=nh(r),o=new nwe(a,s.alpha),l=new Kn(o.calpha,"f");return new ja(t,i,e,{cnormal:a,...s},o,s.mode,l,s.isMask,n)}case"gradient":{let a=new Ln(r.gradientType??0),s=new wl(r.smooth??!1),o;r.colors?o=new sx(r.colors.length,r.colors):(o=new sx(10,new Ii(0,0,0,1)),o.value[1]=new Ii(1,1,1,1));let l;r.steps?l=new ax(r.steps.length,r.steps):(l=new ax(10,1),l.value[0]=0);let c=new Wo(Zp(r.offset??new Ce(0,0),n)),u=new Wo(Zp(r.morph??new Ce(0,0),n)),h=new Zt(Pi(r.angle??0,n)),d=nh(r),f=new owe(a,s,o,l,c,u,h,d.alpha,d.isMask),m=new Kn(f.calpha,"f");return new ja(t,i,e,{gradientType:a,smooth:s,colors:o,steps:l,offset:c,morph:u,angle:h,...d},f,d.mode,m,d.isMask,n)}case"pattern":{let a=new Ln(r.style??0),s=new Ln(r.projection??0),o=new Ln(["x","y","z"].indexOf(r.axis)??0),l=new Zt(Pi(r.blending??0,n)),c=new Wo(Zp(r.offset,n)),u=new mm(r.colorA),h=new mm(r.colorB),d=new Wo(Zp(r.frequency??new Ce(10,10),n)),f=new Zt(Pi(r.size??.5,n)),m=new Zt(Pi(r.variation??0,n)),y=new Zt(Pi(r.smoothness??.5,n)),g=new Zt(Pi(r.zigzag??0,n)),x=new Zt(Pi(r.rotation??0,n)),w=new Wo(Zp(r.vertical??new Ce(0,1),n)),S=new Wo(Zp(r.horizontal??new Ce(0,1),n)),M=new Ln(r.sides??6),E=nh(r),T=new fwe(a,s,o,l,c,u,h,d,f,m,y,g,x,w,S,M,E.alpha,E.isMask),R=new Kn(T.calpha,"f");return new ja(t,i,e,{style:a,projection:s,axis:o,blending:l,offset:c,colorA:u,colorB:h,frequency:d,size:f,variation:m,smoothness:y,zigzag:g,rotation:x,vertical:w,horizontal:S,sides:M,...E},T,E.mode,R,E.isMask,n)}default:{let a=new qa(1,0,0,1),s=nh(r),o=new F9(a,s.alpha),l=new Kn(o.calpha,"f");return new ja(t,i,e,{color:a,...s},o,s.mode,l,s.isMask,n)}}}function pht(e,t,i,r){let n=$ut(i,r);return fht(i,e,t,n,r)}function Cwe(e,t,i,r){if(i.type==="displace"&&(e==="intensity"||e==="visible")){let n=t.uniforms[`f${t.id}_intensity`];return n?(n.value=(Pi(i.intensity,r)??1)*(i.visible?1:0),n):void 0}if(i.type!=="displace"&&(e==="alpha"||e==="visible")){let n=t.uniforms[`f${t.id}_alpha`];if(!n)return;if(n.value=ob(i.alpha,r)*(i.visible?1:0),i.type==="outline"&&e==="visible"){let a=t.uniforms[`f${t.id}_compensation`];a&&(a.value=i.compensation&&i.visible)}return n}}function Oc(e,t,i,r,n,a,s=[]){let o=i;for(let l of s)l in o&&(o=o[l]);for(let l of e)l in o&&n.getVariable(o[l],["material",a,"layer",r,...s,String(l)]);for(let l of t)l in o&&o[l].forEach((c,u)=>{n.getVariable(c,["material",a,"layer",r,...s,String(l),u===0?"x":u===1?"y":"z"])})}function y_(e,t){let i=0,r=e.layers.find(n=>n.data.type==="light");if(r){let n=r.data,a=Number(t.getVariable(n.alphaOverride));if((typeof n.alphaOverride=="string"?a/100:n.alphaOverride)<1)return!0}for(let n of e.layers){if(n.data.type!=="displace"&&n.data.isMask)return!0;if(n.data.type!=="displace"&&"alpha"in n.data&&n.data.type!=="light"&&n.data.type!=="fresnel"&&n.data.type!=="texture"&&n.data.type!=="matcap"&&n.data.type!=="rainbow"&&n.data.type!=="outline"&&n.data.type!=="pattern"){let a=n.data.visible?n.data.alpha:0;if(typeof a=="string"&&(a=Math.max(0,Math.min(1,Number(t.getVariable(a)??100)/100))),a===1&&n.data.type==="depth"||n.data.type==="gradient"){for(let s of n.data.colors)if(s[3]<1){a=s[3];break}}else if(a===1&&n.data.type==="noise"){let s=t.color(n.data.colorA).a,o=t.color(n.data.colorB).a,l=t.color(n.data.colorC).a,c=t.color(n.data.colorD).a,u=Math.min(s,Math.min(o,Math.min(l,c)));u<1&&(a=u)}i+=(1-i)*a}}return i<1}var rg=class extends Fr{constructor(){super(void 0),this.flatShading=!1,this.needsJitter=!0,this.shadersPatchedForShapeBlend=!1,this.nodeContextUuid=0,this.fog=!0,this.dithering=!0,this.vertexColors=!0,this.transparent=!0}customProgramCacheKey(){return""}},mht=class extends rg{constructor(e,t,i,r){super(),this.flatShading=e,this.side=t,this.wireframe=i,this.root=r}updateAfterBuild(){let e=this.root;this.lights=e.lights,this.vertexShader=e.vertexShader,this.fragmentShader=e.fragmentShader,Object.assign(this.defines,e.defines),Object.assign(this.uniforms,e.uniforms),this.extensions=e.extensions,this.transparent=e.transparent,this.cacheKey=e.customProgramCacheKey()+"flat"+this.flatShading+this.side}onBeforeCompile(e,t){this.root.onBeforeCompile(e)}get data(){return this.root.data}get category(){return this.root.category}get hasAO(){return this.root.hasAO}getFlavor(e,t,i,r){return this.root.getFlavor(e,t,i,r)}get layers(){return this.root.layers}get fragment(){return this.root.fragment}getLayersOfType(e){return this.root.getLayersOfType(e)}getLayerByUuid(e){return this.root.getLayerByUuid(e)}updateByOp(e,t,i){this.root.updateByOp(e,t,i)}nodeMaterialDispose(){this.root.nodeMaterialDispose()}},l$=class extends rg{constructor(e,t,i=!0){super(),this.data=e,this.allowVariableSaves=i,this.layerIdGen=0,this.flavors=[],this.masks={},this.type="NodeMaterial",this.updaters=[],this.needsJitter=t.shared.needsJitter,qs.startContext(this),this.reset0(e,t),qs.endContext(this)}get nodeMaterial(){return this}getFlavor(e,t,i,r){let n=i?6:(e?3:0)+t;if(n+=(((r==null?void 0:r.resolutionLevel)??0)-(r!=null&&r.useChildrenColors?4:0))*7,n===0)return this;this.flavors===void 0&&(this.flavors=[]),n-=1;let a=this.flavors[n];return a===void 0&&(a=new mht(e,t,i,this),a.needsJitter=this.needsJitter,this.flavors[n]=a,a.flatShading=e,a.side=t,a.updateAfterBuild(),r&&(a.defines.SHAPEBLEND=r.resolutionLevel,a.defines.SHAPEBLEND_C=r.useChildrenColors?1:0)),a}get fragment(){return this.lightLayer.node}get category(){return this.lightLayer.category}get hasAO(){var e;return((e=this.lightLayer.getNode("occlusion"))==null?void 0:e.value)??!1}reset(e,t,i=!1){qs.startContext(this),(this.data!==e||i)&&this.reset0(e,t),qs.endContext(this)}reset0(e,t){this.data=e;let i=e.layers??wo.defaultTwoLayerData("phong").layers;try{this.layers=i.map(r=>yD.create(this.layerIdGen++,r.id,r.data,t.shared))}catch{this.layers=[]}this.layers.reverse(),this.name=e.name??"Untitled Material",this.onUpdate(t.shared),this.transparent=y_(e,t.shared),this.saveVariableLocations(t)}onVariableUpdate(e,t,i){if(e[0]==="alphaOverride")this.transparent=y_(this.data,i.shared),this.lightLayer.setValue("alphaOverride",Math.max(0,Math.min(Number(t)/100,1)));else if(e[0]==="layer"){let r=e[1],n=e[2];if(r&&n){let a=this.layers.find(s=>s.uuid===r);if(a!=null&&a.hasValue(n))if(n==="alpha")this.transparent=y_(this.data,i.shared),a.setValue(n,Math.max(0,Math.min(Number(t)/100,1)));else{let s=a.getValue(n),o=e[3],l=e[4];if(s instanceof wa){let c=s[o],u;typeof c=="number"?u=Number(t):c.isVector2&&(u=c.toArray(),l==="x"?u[0]=Number(t):l==="y"&&(u[1]=Number(t))),o$({[o]:u},i.shared,a);return}(o==="x"||o==="y"||o==="z")&&s.isVector3||(o==="x"||o==="y")&&s.isVector2?s[o]=Number(t):a.setValue(n,t)}}}}saveVariableLocations(e){if(!this.allowVariableSaves)return;let t=this.data.layers.find(i=>i.data.type==="light");t&&e.shared.getVariable(t.data.alphaOverride,["material",this.uuid,"alphaOverride"]),this.data.layers.forEach(i=>{"alpha"in i.data&&typeof i.data.alpha=="string"&&e.shared.getVariable(i.data.alpha,["material",this.uuid,"layer",i.id,"alpha"]),i.data.type==="displace"?i.data.displacementType==="noise"?Oc(["intensity","scale","movement","smoothness","seed","highCut","lowCut"],["offset"],i.data,i.id,e.shared,this.uuid):Oc(["intensity"],[],i.data,i.id,e.shared,this.uuid):i.data.type==="depth"?Oc(["near","far"],["origin","direction"],i.data,i.id,e.shared,this.uuid):i.data.type==="fresnel"?Oc(["bias","scale","intensity","factor"],[],i.data,i.id,e.shared,this.uuid):i.data.type==="rainbow"?Oc(["filmThickness","movement","noiseStrength","noiseScale"],["offset","wavelengths"],i.data,i.id,e.shared,this.uuid):i.data.type==="noise"?Oc(["scale","move","seed","highCut","lowCut","smoothness"],["size","distortion","fA","fB"],i.data,i.id,e.shared,this.uuid):i.data.type==="pattern"?Oc(["blending","size","variation","smoothness","zigzag","rotation"],["offset","frequency","vertical","horizontal"],i.data,i.id,e.shared,this.uuid):i.data.type==="outline"?Oc(["outlineWidth","contourWidth","outlineThreshold","contourThreshold","outlineSmoothing","contourFrequency"],["contourDirection"],i.data,i.id,e.shared,this.uuid):i.data.type==="toon"?Oc(["noiseStrength","noiseScale"],["offset","source"],i.data,i.id,e.shared,this.uuid):i.data.type==="transmission"?Oc(["roughness","thickness","ior"],[],i.data,i.id,e.shared,this.uuid):i.data.type==="texture"||i.data.type==="video"?(Oc([],["size"],i.data,i.id,e.shared,this.uuid),Oc(["rotation"],["repeat","offset"],i.data,i.id,e.shared,this.uuid,["texture"])):i.data.type==="gradient"?Oc(["angle"],["offset","morph"],i.data,i.id,e.shared,this.uuid):i.data.type==="matcap"&&Oc(["rotation"],[],i.data,i.id,e.shared,this.uuid,["texture"])})}getLayersOfType(e){return this.layers.filter(t=>t.type===e)}getLayerByUuid(e){return this.layers.find(t=>t.uuid===e)}onUpdate(e){this.lightLayer=this.layers.find(t=>t instanceof Cf),this.lightLayer===void 0&&(this.lightLayer=new Cf(0,"",{...ss.defaultData("light","phong"),visible:!1},new s$,{},e)),this.dispose();for(let t of this.flavors)t&&t.dispose();this.applyTextureMaps(),this.applyMasks(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),this.build(),this.nodeContextUuid=0}applyTextureMaps(){let e=this.layers.find(n=>n instanceof Cf);if(!e)return;let t=e.data,i=t.bumpMap,r=t.roughnessMap;e.node.bumpMap=void 0,e.node.roughnessMap=void 0;for(let n=0;n<this.layers.length;++n){let a=this.layers[n];a instanceof ja&&a.color instanceof a$&&(a.uuid===i&&(e.node.bumpMap=a.color),a.uuid===r&&(e.node.roughnessMap=a.color))}}updateByOp(e,t,i){if(qs.startContext(this),t!==void 0?this.data=t:t=this.data,this.transparent=y_(t,i.shared),e.path[0]==="layers"){let r=i.shared,n=e.path[1];if(n===void 0)i.scene.markNeedsUpdateRendererDirty(),this.reset0(t,i);else{e.type===0&&e.props.occlusion!==void 0&&i.scene.markNeedsUpdateRendererDirty();let a=this.layers.find(s=>s.uuid===n);if(a){let s=t.layers.data(n),o;e.type===0&&("alpha"in e.props||"alphaOverride"in e.props)&&("alpha"in e.props?o={...e.props,alpha:ob(e.props.alpha,r,["material",this.uuid,"layer",n,"alpha"])}:o={...e.props,alphaOverride:ob(e.props.alphaOverride,r,["material",this.uuid,"alphaOverride"])}),a.updateByOp({...e,...o?{props:o}:{},path:e.path.slice(2)},s,i)&&this.reset0(t,i)}}}else this.reset0(t,i);qs.endContext(this)}applyMasks(){for(let e=0;e<this.layers.length;++e){let t=this.layers[e];t instanceof ja?t.color.mask=void 0:t instanceof Cf&&(t.node.mask=void 0)}for(let e=0;e<this.layers.length;++e){let t=this.layers[e];if(t instanceof ja&&t.isMask.value&&t.data.visible&&e>0){let i=e-1,r=this.layers[i];r instanceof Cf?r.node.mask=new Lc(t.color,t.alpha,Lc.MUL):r instanceof ja&&(r.isMask.value||(r.color.mask=new Lc(t.color,t.alpha,Lc.MUL)))}}}blendColors(){let e=this.layers.findIndex(i=>i instanceof ja),t=this.layers.findIndex(i=>i instanceof Cf);if(e!==-1&&e<t){let i=this.layers[e].color;for(let r=e+1;r<t;++r){let n=this.layers[r];if(n instanceof ja){if(n.isMask.value)continue;i=new uue(i,n.color,n.alpha,n.mode)}}this.fragment.color=i}else this.fragment.color=void 0}blendAfterColors(){let e=new Kn("outgoingLight","f"),t=this.layers.findIndex(i=>i instanceof Cf);if(this.layers.length>t+1){for(let i=t+1;i<this.layers.length;++i){let r=this.layers[i];if(r instanceof ja){if(r.isMask.value)continue;e=new uue(e,r.color,r.alpha,r.mode)}}this.fragment.afterColor=e}else this.fragment.afterColor=void 0}blendPositions(){let e=this.layers.filter(t=>t instanceof Twe);if(e.length>0){let t=e[0].position;for(let i=1;i<e.length;++i)e[i]&&(t=new Lc(t,e[i].position,Lc.ADD),t=new Lc(t,new Zt(.5).setReadonly(!0),Lc.MUL));this.fragment.position=t}else this.fragment.position=void 0}getDefines(){return this.defines}getUniforms(){return this.uniforms}getVertexShader(){return this.vertexShader}getFragmentShader(){return this.fragmentShader}onBeforeCompile(e){this.shapeBlendhack&&this.shapeBlendhack(this),e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.extensionDerivatives=this.extensions.derivatives===!0,e.extensionFragDepth=this.extensions.fragDepth===!0,e.extensionDrawBuffers=this.extensions.drawBuffers===!0,e.extensionShaderTextureLOD=this.extensions.shaderTextureLOD===!0}clampUniformsForPreview(e,t){let i=(r,n,a)=>Math.min(Math.max(r,n),a);for(let r of this.layers)if(r.type==="displace"){let n=i(r.uniforms[`f${r.id}_intensity`].value,e,t);r.uniforms[`f${r.id}_intensity`].value=n}}updateFrame(e){for(let t=0;t<this.updaters.length;++t)e.updateNode(this.updaters[t])}build(){let e=new ewe;e.needsJitter=this.needsJitter,this.lights=this.lightLayer.data.visible,e.build(this.fragment,this.fragment),this.vertexShader=e.getCode("vertex"),this.fragmentShader=e.getCode("fragment"),this.defines=e.defines,this.uniforms=e.uniforms,this.extensions=e.extensions,this.updaters=e.updaters;for(let t of this.flavors)t&&t.updateAfterBuild();return this.shadersPatchedForShapeBlend=!1,this}nodeMaterialDispose(){this.layers.forEach(e=>e.dispose()),super.dispose();for(let e of this.flavors)e&&e.dispose()}assetsLoaded(){for(let e of this.layers)if(e instanceof ja){let t=e.params.texture;if(t instanceof j9&&!t.image.loaded)return!1}return!0}};Object.defineProperties(rg.prototype,{properties:{get:function(){return this.fragment.properties}}});var G9=class extends l${constructor(e,t,i){super(e,t,!1),this.uuid=i,this.allowVariableSaves=!0,this.saveVariableLocations(t)}},bue=new Map;function ght(e){if(typeof e=="string")return e;let t=bue.get(e);return t||(t={url:URL.createObjectURL(new Blob([e]))},bue.set(e,t)),t.url}var Pwe,vht=new Promise(e=>{Pwe=e}),wue=!1,HO;function yht(){if(wue)return;if(HO)return HO;async function e(){await I0(()=>import("./howler-CzrxH3Wg.js").then(t=>t.h),[]),Pwe(window!==void 0?window:global),wue=!0}return HO=e(),HO}var Dwe;vht.then(e=>Dwe=e);function _ue(e,t){e.forEach(i=>{"dragDropActions"in i.data?(t.push(...i.data.dragDropActions.drag),t.push(...i.data.dragDropActions.drop)):"inActions"in i.data?(t.push(...i.data.inActions),t.push(...i.data.outActions)):"gameActions"in i.data?(t.push(...i.data.gameActions.idle),t.push(...i.data.gameActions.move),t.push(...i.data.gameActions.jump),t.push(...i.data.gameActions.run)):"breakpoints"in i.data?i.data.breakpoints.forEach(r=>{t.push(...r.data.actions)}):"actions"in i.data&&(t.push(...i.data.actions),i.data.actions.forEach(r=>{r.data.type==="Conditional"&&r.data.ifActions&&(t.push(...r.data.ifActions),t.push(...r.data.elseActions))}))})}function xht(e){let t=!1,i=[];return e.scene.objects.traverse((r,n)=>{if(n.type==="Page"&&n.uiScene!==void 0&&n.uiScene.objects.traverse((a,s)=>{if(s.events===void 0||Array.isArray(s.events)===!1)return!0;_ue(s.events,i),t=t||i.some(o=>o.data.type==="Audio")}),n.events===void 0||Array.isArray(n.events)===!1)return!0;_ue(n.events,i),t=t||i.some(a=>a.data.type==="Audio")}),t}var AT=class{constructor({src:e,volume:t,delay:i,loop:r}){this._volume=1,this.delay=0,this._loop=1,this.loopsRemaining=0,this._status="stopped",this.onEnd=()=>{this.loopsRemaining===1/0?this.replay():this.loopsRemaining>1?(this.replay(),this.loopsRemaining--):(this._status="stopped",this.loopsRemaining=this._loop)};let n;typeof e=="string"?n={src:e}:n={src:ght(e),format:"wav"},this.sound=new Dwe.Howl(n),this.sound.on("end",this.onEnd),this.src=e,t!==void 0&&(this.volume=t),i!==void 0&&(this.delay=i),r!==void 0&&(this.loop=r)}get status(){return this._status}get volume(){return this._volume}set volume(e){this._volume=e,this.sound.volume(e)}get loop(){return this._loop}set loop(e){this._loop=e,this.loopsRemaining=e}replay(){this.clearDelay(),this.delayTimerId=window.setTimeout(()=>{this.sound.play(),this.clearDelay()},this.delay)}fade(e,t=1e3){e?(this.sound.volume(this._volume),this.clearFade(),this.fadeTimerId=window.setTimeout(()=>{this.sound.fade(this._volume,0,t),this.clearFade()},e)):this.sound.fade(this._volume,0,t)}on(e,t,i){this.sound.on(e,t,i)}off(e,t,i){this.sound.off(e,t,i)}play(){this._status==="playing"||this.sound.playing()||(this._status==="paused"?(this.sound.seek()===0?this.replay():this.sound.play(),this._status="playing"):this._status==="stopped"&&(this.replay(),this._status="playing"))}pause(){this._status==="playing"&&(this.sound.pause(),this.clearFade(),this.clearDelay(),this._status="paused")}stop(){this.sound.stop(),this.loopsRemaining=this._loop,this.clearFade(),this.clearDelay(),this._status="stopped"}clearFade(){this.fadeTimerId&&(clearTimeout(this.fadeTimerId),delete this.fadeTimerId)}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}dispose(e=!1){this.off(),this.stop(),this.clearFade(),this.clearDelay()}},bht=class{constructor(){this.type="ShapePath",this.color=new _i,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new eL,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){var i;return(i=this.currentPath)==null||i.lineTo(e,t),this}quadraticCurveTo(e,t,i,r){var n;return(n=this.currentPath)==null||n.quadraticCurveTo(e,t,i,r),this}bezierCurveTo(e,t,i,r,n,a){var s;return(s=this.currentPath)==null||s.bezierCurveTo(e,t,i,r,n,a),this}splineThru(e){var t;return(t=this.currentPath)==null||t.splineThru(e),this}toShapes(){let e={ORIGIN:0,DESTINATION:1,BETWEEN:2,LEFT:3,RIGHT:4,BEHIND:5,BEYOND:6},t={loc:e.ORIGIN,t:0};function i(f,m,y,g){let x=f.x,w=m.x,S=y.x,M=g.x,E=f.y,T=m.y,R=y.y,P=g.y,I=(M-S)*(E-R)-(P-R)*(x-S),L=(w-x)*(E-R)-(T-E)*(x-S),z=(P-R)*(w-x)-(M-S)*(T-E),U=I/z,j=L/z;if(z===0&&I!==0||U<=0||U>=1||j<0||j>1)return null;if(I===0&&z===0){for(let F=0;F<2;F++)if(r(F===0?y:g,f,m),t.loc===e.ORIGIN){let G=F===0?y:g;return{x:G.x,y:G.y,t:t.t}}else if(t.loc===e.BETWEEN){let G=+(x+t.t*(w-x)).toPrecision(10),H=+(E+t.t*(T-E)).toPrecision(10);return{x:G,y:H,t:t.t}}return null}else{for(let H=0;H<2;H++)if(r(H===0?y:g,f,m),t.loc===e.ORIGIN){let W=H===0?y:g;return{x:W.x,y:W.y,t:t.t}}let F=+(x+U*(w-x)).toPrecision(10),G=+(E+U*(T-E)).toPrecision(10);return{x:F,y:G,t:U}}}function r(f,m,y){let g=y.x-m.x,x=y.y-m.y,w=f.x-m.x,S=f.y-m.y,M=g*S-w*x;if(f.x===m.x&&f.y===m.y){t.loc=e.ORIGIN,t.t=0;return}if(f.x===y.x&&f.y===y.y){t.loc=e.DESTINATION,t.t=1;return}if(M<-Number.EPSILON){t.loc=e.LEFT;return}if(M>Number.EPSILON){t.loc=e.RIGHT;return}if(g*w<0||x*S<0){t.loc=e.BEHIND;return}if(Math.sqrt(g*g+x*x)<Math.sqrt(w*w+S*S)){t.loc=e.BEYOND;return}let E;g!==0?E=w/g:E=S/x,t.loc=e.BETWEEN,t.t=E}function n(f,m){let y=[],g=[];for(let x=1;x<f.length;x++){let w=f[x-1],S=f[x];for(let M=1;M<m.length;M++){let E=m[M-1],T=m[M],R=i(w,S,E,T);R!==null&&y.find(P=>P.t<=R.t+Number.EPSILON&&P.t>=R.t-Number.EPSILON)===void 0&&(y.push(R),g.push(new Ce(R.x,R.y)))}}return g}function a(f,m,y){let g=new Ce;m.getCenter(g);let x=[];return y.forEach(w=>{w.boundingBox.containsPoint(g)&&n(f,w.points).forEach(S=>{x.push({identifier:w.identifier,isCW:w.isCW,point:S})})}),x.sort((w,S)=>w.point.x-S.point.x),x}function s(f,m,y,g,x){(x==null||x==="")&&(x="nonzero");let w=new Ce;f.boundingBox.getCenter(w);let S=[new Ce(y,w.y),new Ce(g,w.y)],M=a(S,f.boundingBox,m);M.sort((L,z)=>L.point.x-z.point.x);let E=[],T=[];M.forEach(L=>{L.identifier===f.identifier?E.push(L):T.push(L)});let R=E[0].point.x,P=[],I=0;for(;I<T.length&&T[I].point.x<R;)P.length>0&&P[P.length-1]===T[I].identifier?P.pop():P.push(T[I].identifier),I++;if(P.push(f.identifier),x==="evenodd"){let L=P.length%2===0,z=P[P.length-2];return{identifier:f.identifier,isHole:L,for:z}}else if(x==="nonzero"){let L=!0,z=null,U=null;for(let j=0;j<P.length;j++){let F=P[j];m[F]&&(L?(U=m[F].isCW,L=!1,z=F):U!==m[F].isCW&&(U=m[F].isCW,L=!0))}return{identifier:f.identifier,isHole:L,for:z}}else console.warn('fill-rule: "'+x+'" is currently not implemented.')}let o=0,l=999999999,c=-999999999,u=[];this.subPaths.forEach(f=>{let m=f.getPoints(),y=-999999999,g=999999999,x=-999999999,w=999999999;for(let S=0;S<m.length;S++){let M=m[S];M.y>y&&(y=M.y),M.y<g&&(g=M.y),M.x>x&&(x=M.x),M.x<w&&(w=M.x)}c<=x&&(c=x+1),l>=w&&(l=w-1),m.length&&u.push({curves:f.curves,points:m,isCW:fxe.isClockWise(m),identifier:o++,boundingBox:new tY(new Ce(w,g),new Ce(x,y))})});let h=u.map(f=>{var m;return s(f,u,l,c,(m=this.userData)==null?void 0:m.style.fillRule)}),d=[];return u.forEach(f=>{let m=h[f.identifier];if(m&&!m.isHole){let y=new tL;y.curves=f.curves,h.filter(g=>(g==null?void 0:g.isHole)&&g.for===f.identifier).forEach(g=>{if(g){let x=u[g.identifier],w=new eL;w.curves=x.curves,y.holes.push(w)}}),d.push(y)}}),d}},Owe=!1,Rwe,Sue=new Promise(e=>{Rwe=e}),Aue=!1,GO;function wht(){if(Owe=!0,Aue)return;if(GO)return GO;async function e(){let t=await I0(()=>import("./opentype-U-0Y99ve.js"),[]);Rwe(t),Aue=!0}return GO=e(),GO}var _ht=class{async load(e,t,i=()=>{}){let{load:r}=await Sue;r(e,(n,a)=>{n||!a?i(n??"Something went wrong"):t(a)})}async parse(e){let{parse:t,Bidi:i}=await Sue;try{let r=t(e),n=new i,a=s=>r.charToGlyphIndex(s.char);return n.registerModifier("glyphIndex",null,a),n.applyFeatures(r,r.defaultRenderOptions.features),{font:r,bidi:n}}catch(r){console.error(r)}}};async function Sht(e){return await(await fetch(e)).arrayBuffer()}var Aht=new _ht;async function Mue(e){let t,i,r=!1;if(e.url?(t=await Sht(e.url),i=e.url,r=e.url.startsWith("/")):e.data&&(t=e.data.buffer.slice(e.data.byteOffset,e.data.byteOffset+e.data.byteLength)),t)if(Owe){let n=await Aht.parse(t);if(n)return{font:n.font,url:i,intercepted:r,arr:t,bidi:n.bidi}}else return{font:void 0,url:i,intercepted:r,arr:t,bidi:null}}function Mht(e,t){return t.state.glyphIndex===e||t.state.fina===e||t.state.medi===e||t.state.init===e}var Eht=class{constructor(e){this._arrayBuffer=new ArrayBuffer(1),this._isLoaded=!1,this._intercepted=!1,this._isUserFont=e.isUserFont??!1,this._loadingPromise=Mue(e).then(t=>{t&&(this._arrayBuffer=t.arr,this._url=t.url,this.font=t.font,this._intercepted=t.intercepted,this._isLoaded=!0,this._bidi=t.bidi)})}update(e){this._isLoaded=!1,this._isUserFont=e.isUserFont??!1,this._loadingPromise=Mue(e).then(t=>{t&&(this._arrayBuffer=t.arr,this._url=t.url,this.font=t.font,this._intercepted=t.intercepted,this._isLoaded=!0,this._bidi=t.bidi)})}get url(){return this._url}get intercepted(){return this._intercepted}get isLoaded(){return this._isLoaded}get loadingPromise(){return this._loadingPromise}reverseLigaturesTable(e,t,i){if(!this._bidi)return[];let r=this._bidi;r.getTextGlyphs(t);let n=r.tokenizer.tokens,a=[],s=0,o=i.length===n.length;for(let l=0;l<i.length;l++){let c=i[l].index,u=String.fromCharCode(i[l].unicode),h=n[s];if(Mht(c,h)||o)a.push({char:u,index:c,replacements:[h.state.glyphIndex],replacementChars:[h.char]}),s++;else{let d=h.char,f="",m=[h.state.glyphIndex],y=[],g=!1;for(;!g;)s++,f=t.charAt(s),d+=f,m.push(e.charToGlyphIndex(f)),y=e.stringToGlyphs(d),y.length===1&&y[0].index===c&&(g=!0),s>t.length&&(g=!0);a.push({char:u,index:c,replacements:m,replacementChars:Array.from(d)}),s++}}return a}generateShapes(e,t,i){var x;if(!this._isLoaded)return;let r=this.font,n=t.fontSize/this.unitsPerEm,a=t.fontSize*t.lineHeight,s=e.map(w=>this.getTextWidth(w,t)),o=typeof t.width=="string"?Number(i.getVariable(t.width)):t.width,l=typeof t.height=="string"?Number(i.getVariable(t.height)):t.height,c=this.getCharWidth(`
|
|
5554
|
+
`)}return t}},wut=class{constructor(e=1e3*10){this.timeout=e,this.cache=new Map,this.head={data:null,time:0,src:null,next:null,prev:null},this.tail={data:null,time:1/0,src:null,next:null,prev:null},this.hasClean=!1,this.cleanupTimer=null,this.head.next=this.tail,this.tail.prev=this.head}log(...e){}remove(e){let t=this.cache.get(e);t&&(this.dispose(e,t.data),this.cache.delete(e),t.prev.next=t.next,t.next.prev=t.prev,t.next=null,t.prev=null,t.data=null)}scheduleCleanup(){this.hasClean||(this.log("scheduled cleanup"),this.hasClean=!0,this.cleanupTimer=setTimeout(()=>{this.hasClean=!1,this.cleanupTimer=null,this.log("cleaning");let e=Date.now(),t=this.head.next;for(;t.time<e-this.timeout;){this.dispose(t.src,t.data),this.cache.delete(t.src);let i=t;t=t.next,t.prev=this.head,this.head.next=t,i.next=null,i.prev=null,i.data=null}this.head.next!==this.tail?this.scheduleCleanup():this.log("no more cleanup")},this.timeout+1e3))}has(e){var t;return(t=this.cache.get(e))==null?void 0:t.data}load(e){let t=Date.now(),i=this.cache.get(e);return i===void 0?(i={data:this.create(e),src:e,time:t,next:null,prev:null},this.cache.set(e,i)):(i.time=t,i.prev.next=i.next,i.next.prev=i.prev),i.prev=this.tail.prev,i.next=this.tail,this.tail.prev.next=i,this.tail.prev=i,this.scheduleCleanup(),i.data}disposeAll(){this.cleanupTimer!==null&&(clearTimeout(this.cleanupTimer),this.cleanupTimer=null),this.hasClean=!1,this.cache.forEach((e,t)=>{this.dispose(t,e.data),e.next=null,e.prev=null,e.data=null}),this.cache.clear(),this.head.next=this.tail,this.tail.prev=this.head}destroy(){this.disposeAll(),this.head=null,this.tail=null}},_ut=class extends wut{create(e){return URL.createObjectURL(new Blob([e]))}dispose(e,t){URL.revokeObjectURL(t)}},$T;function Sut(e){return typeof e=="string"?e:($T||($T=new _ut),$T.load(e))}function Aut(){$T&&$T.disposeAll()}var Mut=class{constructor(e,t){this.data=e,this.cache=t,this.refCount=0}deref(){this.refCount,this.refCount-=1,this.refCount===0&&(this.cache.remove(this),this.dispose())}dispose(){this.refCount}},Eut=class{constructor(){this.cache=new Map}remove(e){this.cache.delete(e.data)}load(e){let t=this.cache.get(e);return t===void 0&&(t=this.create(e),this.cache.set(e,t)),t.refCount+=1,t}},Swe=class extends Mut{constructor(e,t){super(e,t.imageHolderCache),this.data=e,this.shared=t,this.loaded=!1,this.isVideo=!1,this.isBuffer=!1,this._cache={1e3:{},1001:{},1002:{}},this.isVideo=e.type==="video",this.isBuffer=e.isWebGLRenderTarget===!0,this.loadPromise=this.updateSrc(this.isBuffer?e:e.data)}async updateSrc(e){if(typeof document>"u")return;this.disposeTextures(),this.loaded=!1;let t=()=>{this.loaded=!0;for(let r of Object.values(this._cache))for(let n of Object.values(r))for(let a of Object.values(n))a&&(a.image=this.img,a.needsUpdate=!0);this.shared.requestRender()};if(this.isBuffer)this.img=e,this.loaded=!0;else if(this.isVideo){if(this.img=document.createElement("video"),this.img.preload="auto",this.img.playsInline=!0,this.img.currentTime=.01,typeof e!="string"){var i=new FileReader;i.readAsDataURL(new Blob([e],{type:"video/mp4"}));let r;await new Promise(n=>{i.onloadend=a=>{var s;r=(s=a.target)==null?void 0:s.result,n(null)}}),this.img.src=r}else this.img.src=e;this.img.onloadeddata=()=>{t()}}else this.img=new Image,this.img.src=Sut(e),this.img.onload=t,await new Promise(r=>{this.img.onload=()=>{t(),r(null)}})}getTexture(e,t=1008,i=1006){var n,a;let r=(a=(n=this._cache[e])==null?void 0:n[t])==null?void 0:a[i];if(r)return r;{let s;return this.isBuffer?s=this.img.texture:this.isVideo?s=new ZXe(this.img,void 0,e,e):s=new wa(this.img,void 0,e,e,i,t),this.loaded&&(s.needsUpdate=!0),this._cache[e]===void 0&&(this._cache[e]={}),this._cache[e][t]===void 0&&(this._cache[e][t]={}),this._cache[e][t][i]=s,s}}setNeedsUpdate(e){for(let t of Object.values(this._cache))for(let i of Object.values(t))for(let r of Object.values(i))r&&(r.needsUpdate=e)}disposeTextures(){for(let[e,t]of Object.entries(this._cache))for(let[i,r]of Object.entries(t))for(let[n,a]of Object.entries(r))a==null||a.dispose(),this._cache[e]!==void 0&&this._cache[e][i]!==void 0&&(this._cache[e][i][n]=void 0)}dispose(){super.dispose(),this.disposeTextures()}},zv=class extends Swe{};function Tut(e,t){var i=Out(t);return i.formatToParts?Put(i,e):Dut(i,e)}var Cut={year:0,month:1,day:2,hour:3,minute:4,second:5};function Put(e,t){try{for(var i=e.formatToParts(t),r=[],n=0;n<i.length;n++){var a=Cut[i[n].type];a>=0&&(r[a]=parseInt(i[n].value,10))}return r}catch(s){if(s instanceof RangeError)return[NaN];throw s}}function Dut(e,t){var i=e.format(t).replace(/\u200E/g,""),r=/(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/.exec(i);return[r[3],r[1],r[2],r[4],r[5],r[6]]}var w6={};function Out(e){if(!w6[e]){var t=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:"America/New_York",year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(new Date("2014-06-25T04:00:00.123Z")),i=t==="06/25/2014, 00:00:00"||t==="06/25/2014 00:00:00";w6[e]=i?new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:e,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}):new Intl.DateTimeFormat("en-US",{hourCycle:"h23",timeZone:e,year:"numeric",month:"numeric",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})}return w6[e]}function Awe(e,t,i,r,n,a,s){var o=new Date(0);return o.setUTCFullYear(e,t,i),o.setUTCHours(r,n,a,s),o}var hue=36e5,Rut=6e4,_6={timezoneZ:/^(Z)$/,timezoneHH:/^([+-]\d{2})$/,timezoneHHMM:/^([+-]\d{2}):?(\d{2})$/};function Mwe(e,t,i){var r,n;if(!e||(r=_6.timezoneZ.exec(e),r))return 0;var a;if(r=_6.timezoneHH.exec(e),r)return a=parseInt(r[1],10),due(a)?-(a*hue):NaN;if(r=_6.timezoneHHMM.exec(e),r){a=parseInt(r[1],10);var s=parseInt(r[2],10);return due(a,s)?(n=Math.abs(a)*hue+s*Rut,a>0?-n:n):NaN}if(Lut(e)){t=new Date(t||Date.now());var o=i?t:Iut(t),l=H9(o,e),c=i?l:Nut(t,l,e);return-c}return NaN}function Iut(e){return Awe(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds())}function H9(e,t){var i=Tut(e,t),r=Awe(i[0],i[1]-1,i[2],i[3]%24,i[4],i[5],0).getTime(),n=e.getTime(),a=n%1e3;return n-=a>=0?a:1e3+a,r-n}function Nut(e,t,i){var r=e.getTime(),n=r-t,a=H9(new Date(n),i);if(t===a)return t;n-=a-t;var s=H9(new Date(n),i);return a===s?a:Math.max(a,s)}function due(e,t){return-23<=e&&e<=23&&(t==null||0<=t&&t<=59)}var fue={};function Lut(e){if(fue[e])return!0;try{return new Intl.DateTimeFormat(void 0,{timeZone:e}),fue[e]=!0,!0}catch{return!1}}var kut=N0(jGe(),1),pue=N0(FGe(),1),zut=/(Z|[+-]\d{2}(?::?\d{2})?| UTC| [a-zA-Z]+\/[a-zA-Z_]+(?:\/[a-zA-Z_]+)?)$/,But=zut,S6=36e5,mue=6e4,Uut=2,Kl={dateTimePattern:/^([0-9W+-]+)(T| )(.*)/,datePattern:/^([0-9W+-]+)(.*)/,YY:/^(\d{2})$/,YYY:[/^([+-]\d{2})$/,/^([+-]\d{3})$/,/^([+-]\d{4})$/],YYYY:/^(\d{4})/,YYYYY:[/^([+-]\d{4})/,/^([+-]\d{5})/,/^([+-]\d{6})/],MM:/^-(\d{2})$/,DDD:/^-?(\d{3})$/,MMDD:/^-?(\d{2})-?(\d{2})$/,Www:/^-?W(\d{2})$/,WwwD:/^-?W(\d{2})-?(\d{1})$/,HH:/^(\d{2}([.,]\d*)?)$/,HHMM:/^(\d{2}):?(\d{2}([.,]\d*)?)$/,HHMMSS:/^(\d{2}):?(\d{2}):?(\d{2}([.,]\d*)?)$/,timeZone:But};function jut(e,t){if(arguments.length<1)throw new TypeError("1 argument required, but only "+arguments.length+" present");if(e===null)return new Date(NaN);var i={},r=i.additionalDigits==null?Uut:(0,kut.default)(i.additionalDigits);if(r!==2&&r!==1&&r!==0)throw new RangeError("additionalDigits must be 0, 1 or 2");if(e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]")return new Date(e.getTime());if(typeof e=="number"||Object.prototype.toString.call(e)==="[object Number]")return new Date(e);if(!(typeof e=="string"||Object.prototype.toString.call(e)==="[object String]"))return new Date(NaN);var n=Fut(e),a=Vut(n.date,r),s=a.year,o=a.restDateString,l=Hut(o,s);if(isNaN(l))return new Date(NaN);if(l){var c=l.getTime(),u=0,h;if(n.time&&(u=Gut(n.time),isNaN(u)))return new Date(NaN);if(n.timeZone||i.timeZone){if(h=Mwe(n.timeZone||i.timeZone,new Date(c+u)),isNaN(h))return new Date(NaN)}else h=(0,pue.default)(new Date(c+u)),h=(0,pue.default)(new Date(c+u+h));return new Date(c+u+h)}else return new Date(NaN)}function Fut(e){var t={},i=Kl.dateTimePattern.exec(e),r;if(i?(t.date=i[1],r=i[3]):(i=Kl.datePattern.exec(e),i?(t.date=i[1],r=i[2]):(t.date=null,r=e)),r){var n=Kl.timeZone.exec(r);n?(t.time=r.replace(n[1],""),t.timeZone=n[1].trim()):t.time=r}return t}function Vut(e,t){var i=Kl.YYY[t],r=Kl.YYYYY[t],n;if(n=Kl.YYYY.exec(e)||r.exec(e),n){var a=n[1];return{year:parseInt(a,10),restDateString:e.slice(a.length)}}if(n=Kl.YY.exec(e)||i.exec(e),n){var s=n[1];return{year:parseInt(s,10)*100,restDateString:e.slice(s.length)}}return{year:null}}function Hut(e,t){if(t===null)return null;var i,r,n,a;if(e.length===0)return r=new Date(0),r.setUTCFullYear(t),r;if(i=Kl.MM.exec(e),i)return r=new Date(0),n=parseInt(i[1],10)-1,vue(t,n)?(r.setUTCFullYear(t,n),r):new Date(NaN);if(i=Kl.DDD.exec(e),i){r=new Date(0);var s=parseInt(i[1],10);return Xut(t,s)?(r.setUTCFullYear(t,0,s),r):new Date(NaN)}if(i=Kl.MMDD.exec(e),i){r=new Date(0),n=parseInt(i[1],10)-1;var o=parseInt(i[2],10);return vue(t,n,o)?(r.setUTCFullYear(t,n,o),r):new Date(NaN)}if(i=Kl.Www.exec(e),i)return a=parseInt(i[1],10)-1,yue(t,a)?gue(t,a):new Date(NaN);if(i=Kl.WwwD.exec(e),i){a=parseInt(i[1],10)-1;var l=parseInt(i[2],10)-1;return yue(t,a,l)?gue(t,a,l):new Date(NaN)}return null}function Gut(e){var t,i,r;if(t=Kl.HH.exec(e),t)return i=parseFloat(t[1].replace(",",".")),A6(i)?i%24*S6:NaN;if(t=Kl.HHMM.exec(e),t)return i=parseInt(t[1],10),r=parseFloat(t[2].replace(",",".")),A6(i,r)?i%24*S6+r*mue:NaN;if(t=Kl.HHMMSS.exec(e),t){i=parseInt(t[1],10),r=parseInt(t[2],10);var n=parseFloat(t[3].replace(",","."));return A6(i,r,n)?i%24*S6+r*mue+n*1e3:NaN}return null}function gue(e,t,i){t=t||0,i=i||0;var r=new Date(0);r.setUTCFullYear(e,0,4);var n=r.getUTCDay()||7,a=t*7+i+1-n;return r.setUTCDate(r.getUTCDate()+a),r}var Wut=[31,28,31,30,31,30,31,31,30,31,30,31],qut=[31,29,31,30,31,30,31,31,30,31,30,31];function Ewe(e){return e%400===0||e%4===0&&e%100!==0}function vue(e,t,i){if(t<0||t>11)return!1;if(i!=null){if(i<1)return!1;var r=Ewe(e);if(r&&i>qut[t]||!r&&i>Wut[t])return!1}return!0}function Xut(e,t){if(t<1)return!1;var i=Ewe(e);return!(i&&t>366||!i&&t>365)}function yue(e,t,i){return!(t<0||t>52||i!=null&&(i<0||i>6))}function A6(e,t,i){return!(e!=null&&(e<0||e>=25)||t!=null&&(t<0||t>=60)||i!=null&&(i<0||i>=60))}function Yut(e,t,i){var r=jut(e,i),n=Mwe(t,r,!0),a=new Date(r.getTime()-n),s=new Date(0);return s.setFullYear(a.getUTCFullYear(),a.getUTCMonth(),a.getUTCDate()),s.setHours(a.getUTCHours(),a.getUTCMinutes(),a.getUTCSeconds(),a.getUTCMilliseconds()),s}function tc(e,t){return t.color(e)}function xue(e=new Date,t){let i=t.format,r=e.getSeconds(),n=e;t&&t.timeZone!==null&&(n=Yut(new Date,t.timeZone));let a=n.getHours(),s=n.getMinutes(),o;t.format12h24h==="12ampm"&&(o=a>=12?"PM":"AM");let l=a;t.format12h24h!=="24"&&(l=a%12,l===0&&(l=12));let c,u;switch(i){case"HH:mm:ss":c=[l,s,r];break;case"HH:mm":c=[l,s];break;case"HH":c=[l],o=void 0;break;case"mm":c=[s],o=void 0;break;case"ss":c=[r],o=void 0;break;case"year":u=n.getFullYear();break;case"month":u=n.getMonth()+1;break;case"dayOfYear":u=Math.floor((n.getTime()-new Date(n.getFullYear(),0,0).getTime())/864e5);break;case"dayOfMonth":u=n.getDate();break;case"secondOfDay":u=a*60*60+s*60+r;break;default:console.error("Unknown time format",i),u=0;break}return c!==void 0?{textValue:c,suffix:o}:u}function $ut(e,t){switch(e.type){case"fresnel":return Zut(e,t);case"gradient":return Jut(e,t);case"depth":return eht(e,t);case"normal":return tht(e,t);case"noise":return iht(e,t);case"rainbow":return rht(e,t);case"toon":return nht(e,t);case"outline":return aht(e,t);case"transmission":return sht(e,t);case"pattern":return oht(e,t);case"color":default:return Qut(e,t)}}function Kut(e){return{type:e.type}}function Rd(e,t){let{alpha:i,mode:r,isMask:n}=e,a=typeof i=="string"?(Number(t.getVariable(i))??100)/100:i;return{...Kut(e),alpha:a,mode:r,isMask:n}}function Qut(e,t){return{...Rd(e,t),color:tc(e.color,t)}}function Zut(e,t){let{bias:i,scale:r,intensity:n,factor:a,color:s}=e;return{...Rd(e,t),color:tc(s,t),bias:i,scale:r,intensity:n,factor:a}}function Jut(e,t){let{gradientType:i,smooth:r,colors:n,steps:a,angle:s,offset:o,morph:l}=e;return{...Rd(e,t),gradientType:i,smooth:r,colors:n.map(c=>new Ii(c[0],c[1],c[2],c[3])),num:n.length,steps:a,offset:new Ce(...o.map(c=>typeof c=="number"?c:0)),morph:new Ce(...l.map(c=>typeof c=="number"?c:0)),angle:s}}function eht(e,t){let{gradientType:i,near:r,far:n,isVector:a,isWorldSpace:s,origin:o,direction:l,colors:c,steps:u,smooth:h}=e;return{...Rd(e,t),gradientType:i,near:r,far:n,isVector:a,isWorldSpace:s,origin:new Y(...o),direction:l?new Y(...l):new Y(1,0,0),colors:c.map(d=>d!==void 0?new Ii(d[0],d[1],d[2],d[3]):new Ii(0,0,0,0)),steps:u.slice(0,c.length),smooth:h}}function tht(e,t){let{cnormal:i}=e;return{...Rd(e,t),cnormal:new Y(i[0],i[1],i[2])}}function iht(e,t){return{...Rd(e,t),scale:e.scale,move:e.move,fA:new Ce(...e.fA.map(i=>typeof i=="number"?i:0)),fB:new Ce(...e.fB.map(i=>typeof i=="number"?i:0)),size:new Y(...e.size),distortion:new Ce(...e.distortion.map(i=>typeof i=="number"?i:0)),colorA:tc(e.colorA,t),colorB:tc(e.colorB,t),colorC:tc(e.colorC,t),colorD:tc(e.colorD,t),noiseType:e.noiseType,voronoiStyle:e.voronoiStyle,highCut:e.highCut,lowCut:e.lowCut,smoothness:e.smoothness,seed:e.seed,quality:e.quality}}function rht(e,t){return{...Rd(e,t),filmThickness:e.filmThickness,movement:e.movement,wavelengths:new Y(...e.wavelengths),noiseStrength:e.noiseStrength,noiseScale:e.noiseScale,offset:new Y(...e.offset)}}function nht(e,t){return{...Rd(e,t),positioning:e.positioning,colors:e.colors.map(i=>new Ii(i[0],i[1],i[2],i[3])),num:e.colors.length,steps:e.steps,source:new Y(...e.source),isWorldSpace:e.isWorldSpace,noiseStrength:e.noiseStrength,noiseScale:e.noiseScale,shadowColor:tc(e.shadowColor,t),offset:new Y(...e.offset)}}function aht(e,t){return{...Rd(e,t),outlineColor:tc(e.outlineColor,t),contourColor:tc(e.contourColor,t),outlineWidth:e.outlineWidth,contourWidth:e.contourWidth,outlineThreshold:e.outlineThreshold,contourThreshold:e.contourThreshold,outlineSmoothing:e.outlineSmoothing,contourFrequency:e.contourFrequency,contourDirection:new Y(...e.contourDirection),positionalLines:e.positionalLines,compensation:e.compensation}}function sht(e,t){return{...Rd(e,t),thickness:e.thickness,ior:e.ior,roughness:e.roughness}}function oht(e,t){return{...Rd(e,t),style:e.style,projection:e.projection,axis:e.axis,blending:e.blending,offset:new Ce(...e.offset.map(i=>typeof i=="number"?i:0)),colorA:tc(e.colorA,t),colorB:tc(e.colorB,t),frequency:new Ce(...e.frequency.map(i=>typeof i=="number"?i:0)),size:e.size,variation:e.variation,smoothness:e.smoothness,zigzag:e.zigzag,rotation:e.rotation,vertical:new Ce(...e.vertical.map(i=>typeof i=="number"?i:0)),horizontal:new Ce(...e.horizontal.map(i=>typeof i=="number"?i:0)),sides:e.sides}}var HL=class extends Ks{},lht={noise:["noiseType"],texture:["projection","axis","side"],video:["projection","axis","side"],displace:["noiseType"],light:["roughnessMap","bumpMap"],depth:["smooth","isWorldSpace","gradientType","isVector"],pattern:["style","projection","axis"]},cht={depth:["colors"]};function uht(e,t,i){var a,s;if(t==="isMask")return!0;let r=lht[e.type],n=cht[e.type];if(n!==void 0){let o=e.color;if(n.includes(t)){let l=(s=(a=o[t])==null?void 0:a.value)==null?void 0:s.length;if(l!==void 0&&l!==i.length)return!0}}return r!==void 0?r.includes(t):!1}function M6(e,t){if(Array.isArray(t)){if(!Array.isArray(e)||e.length!==t.length)return!1;for(let[n,a]of t.entries()){let s=e[n];if(typeof a=="string"||typeof a=="number"&&typeof s=="string")return!0}return!1}let i=typeof e=="string",r=typeof t=="string";return i!==r||i&&r}function o$(e,t,i){let r=i.uniforms[`f${i.id}_texture`];if(!r)return!1;let n=!1,a=e;if("image"in a){let s=a.image,o=t.image(s),l=r;l.image instanceof zv||l.image.deref(),l.image=o}if("video"in a){let s=a.video,o=t.video(s),l=r;l.image instanceof zv||l.image.deref(),l.image=o}if("wrapping"in a){let s=r;s.wrap=a.wrapping}if("minFilter"in a){let s=r;s.minFilter=a.minFilter}if("magFilter"in a){let s=r;s.magFilter=a.magFilter}if("rotation"in a&&i.uniforms[`f${i.id}_rotation`])return i.uniforms[`f${i.id}_rotation`].value=(Pi(a.rotation??0,t)??0)*Wt.DEG2RAD,n;if("repeat"in a||"offset"in a||"rotation"in a){let s="mat",o=i.uniforms[`f${i.id}_${s}`];if(!o)return n;if("repeat"in a){let l=a.repeat;M6(i.data.texture.repeat,l)&&(n=!0),o.repeat=KT(l,t).map((c,u)=>typeof l[u]=="string"?1/c:c)}if("offset"in a){let l=a.offset;M6(i.data.texture.offset,l)&&(n=!0),o.offset=KT(l,t).map((c,u)=>typeof l[u]=="string"?-c:c)}if("rotation"in a){let l=i.data.texture.rotation,c=a.rotation??0;(l===void 0||M6(l,c))&&(n=!0),o.rotation=Pi(c,t)??0}o.updateMatrix()}return n}function hht(e,t,i,r){let n=!1;for(let[a,s]of Object.entries(e)){if(a==="bumpMap"||a==="roughnessMap"){n=!0;continue}if(!a||s===void 0)continue;if(Cwe(a,i,r,t)){a==="visible"&&i.type==="light"&&(n=!0);continue}i.visible=r.visible;let o=i.uniforms[`f${i.id}_${a}`];if(o&&!(o instanceof n$))switch(n=n||uht(i,a,s),o.constructor){case qa:if(typeof s=="string"){let l=t.getColor(s);l&&(o.value=l);break}else{let l=s;o.value instanceof HL?o.value=new Ks(l.r,l.g,l.b,l.a):o.setRGBA(l);break}case mm:if(typeof s=="string"){let l=t.getColor(s);l&&(o.value=l);break}else{let l=s;o.value instanceof HL?o.value=new Ks(l.r,l.g,l.b,l.a):o.value.setRGBA(l.r,l.g,l.b,l.a);break}case Wo:{let l=s;o.value.setX(l[0]),o.value.setY(l[1]);break}case hh:{let l=s;o.value.setX(l[0]),o.value.setY(l[1]),o.value.setZ(l[2]);break}case _m:{o$(s,t,i);break}case sx:{o.value=s.map(l=>new Ii(...l));break}default:{o.value=s;break}}}return n}var ob=(e,t,i)=>Math.max(0,Math.min(1,Number(t.getVariable(typeof e=="number"?e*100:e,i)??100)/100))??1,Pi=(e,t,i)=>typeof e=="number"?e:t.getVariable(e,i),lv=(e,t)=>(e||(e=new Y),e.x=Pi(e.x,t)??0,e.y=Pi(e.y,t)??0,e.z=Pi(e.z,t)??0,e),Zp=(e,t)=>(e||(e=new Ce),e.x=Pi(e.x,t)??0,e.y=Pi(e.y,t)??0,e),KT=(e,t)=>{let i=e.map(r=>Pi(r,t)??0);return[i[0],i[1]]},yD=class{constructor(e,t,i,r,n){this.id=e,this.uuid=t,this.data=i,this.uniforms={};for(let a in r)this.uniforms[`f${this.id}_${a}`]=r[a];for(let a in i)Cwe(a,this,i,n)}get type(){return this.data.type}static create(e,t,i,r){if(i.type==="light")return Cf.createLightLayer(e,t,i,r);if(i.type==="texture"||i.type==="video"){let n=i.type==="texture"?r.uiBuffer(i.texture.image)??r.image(i.texture.image):r.video(i.texture.video),a=new j9(n,i.texture.wrapping,i.texture.minFilter??1008,i.texture.magFilter??1006),s=new dut(n),o=new fut(KT(i.texture.repeat,r),KT(i.texture.offset,r),Pi(i.texture.rotation??0,r)),l=new Zt(i.crop?1:0),c=new Ln(i.projection??0),u=new Ln(["x","y","z"].indexOf(i.axis)??0),h=new Ln(i.side??0),d=new Wo(i.size?new Ce(...KT(i.size,r)):new Ce(100,100)),f=new Zt(i.blending??0),m=new Zt(ob(i.alpha,r)),y=new Ln(i.mode??0),g=new wl(i.isMask??!1),x=new a$(a,s,l,c,u,h,d,f,o,m,y,g),w=new Kn(x.calpha,"f");return new ja(e,t,i,{texture:a,textureSize:s,crop:l,projection:c,axis:u,side:h,size:d,blending:f,mat:o,alpha:m,mode:y,isMask:g},x,y,w,g,r)}else if(i.type==="matcap"){let n=r.image(i.texture.image),a=new j9(n,i.texture.wrapping,i.texture.minFilter??1008,i.texture.magFilter??1006),s=new Zt(ob(i.alpha,r)),o=new Ln(i.mode??0),l=new wl(i.isMask??!1),c=new Zt((Pi(i.texture.rotation??0,r)??0)*Wt.DEG2RAD),u=new cwe(a,s,o,l,c),h=new Kn(u.calpha,"f");return new ja(e,t,i,{texture:a,alpha:s,mode:o,isMask:l,rotation:c},u,o,h,l,r)}else if(i.type==="displace")if(i.displacementType==="noise"){let n=new hh(new Y(...i.offset.map(g=>Pi(g,r)??0))),a=new Zt(Pi(i.scale,r)??10),s=new Zt(Pi(i.intensity,r)??8),o=new Zt(Pi(i.movement,r)??1),l=new Ln(i.noiseType??0),c=new Ln(i.voronoiStyle??0),u=new Zt(Pi(i.smoothness,r)??.5),h=new Zt(Pi(i.seed,r)??0),d=new Zt(Pi(i.highCut,r)??1),f=new Zt(Pi(i.lowCut,r)??0),m=new Ln(Pi(i.quality,r)??1),y=new wwe(s,o,n,c,u,h,d,f,m,a,l);return new Twe(e,t,i,{offset:n,scale:a,intensity:s,movement:o,noiseType:l,voronoiStyle:c,smoothness:u,seed:h,highCut:d,lowCut:f,quality:m},y,r)}else throw new Error;else return pht(e,t,i,r)}updateByOp(e,t,i){let r=e,n=!1;if(r.path[0]===void 0){for(let a of Object.keys(r.props))try{let s=this.data[a],o=t[a];if(Array.isArray(s)&&Array.isArray(o)){for(let[l,c]of o.entries()){let u=s[l];if(typeof c=="string"||typeof c=="number"&&typeof u=="string"){n=!0;break}}if(n)break}else if(typeof o=="string"&&typeof s=="number"||typeof o=="number"&&typeof s=="string"||typeof o=="string"&&typeof s=="string"&&o!==s){n=!0;break}}catch(s){console.error(s)}if(r.type===0)return"type"in r.props||"category"in r.props||"visible"in r.props||"noiseType"in r.props?(i.scene.markNeedsUpdateRendererDirty(),!0):hht(r.props,i.shared,this,t)||n}else if(r.path[0]==="texture")return"texture"in t||"video"in t?o$(r.props,i.shared,this)||n:!0;return n}dispose(){if(dht(this)){let e=this.uniforms[`f${this.id}_texture`];if(!e)return!1;let t=e;t.image instanceof zv||t.image.deref()}}hasValueByKey(e){return this.uniforms[e]!==void 0}hasValue(e){return this.hasValueByKey(`f${this.id}_${e}`)}setValue(e,t){let i=`f${this.id}_${e}`;this.hasValueByKey(i)&&t!==void 0&&(this.uniforms[i].value=t)}getNode(e){let t=`f${this.id}_${e}`;if(this.hasValueByKey(t))return this.uniforms[t]}getValue(e){let t=`f${this.id}_${e}`;if(this.hasValueByKey(t))return this.uniforms[t].value}getName(e){let t=/f\d+_(.*)/.exec(e);if(t&&t.length>1)return t[1];console.log(`Layer.getName: error ${e}`)}getNames(){let e=[];for(let t in this.uniforms){let i=this.getName(t);i&&e.push(i)}return e}},ja=class extends yD{constructor(e,t,i,r,n,a,s,o,l){super(e,t,i,r,l),this.params=r,this.color=n,this.mode=a,this.alpha=s,this.isMask=o}},Twe=class extends yD{constructor(e,t,i,r,n,a){super(e,t,i,r,a),this.position=n}},Cf=class extends yD{constructor(e,t,i,r,n,a){super(e,t,i,n,a),this.node=r}static createLightLayer(e,t,i,r){let n,a=new Zt(ob(i.alpha,r)),s=new Ln(i.mode),o=new Zt(i.bumpMapIntensity),l=new Zt(ob(i.alphaOverride,r)),c;if(!i.visible)n=new s$,c={};else if(i.category==="lambert"){n=new vut;let u=new qa(r.color(i.emissive)??0),h=new wl(i.occlusion??!0);c={emissive:u,occlusion:h},n.emissive=u,n.occlusion=h}else if(i.category==="toon"){n=new but;let u=new Zt(i.shininess??30),h=new qa(r.color(i.specular)??1118481);c={shininess:u,specular:h},n.shininess=u,n.specular=h}else if(i.category==="physical"){n=new xut;let u=new Zt(i.roughness??.3),h=new Zt(i.metalness??0),d=new Zt(i.reflectivity??.5),f=new wl(i.occlusion??!0);c={roughness:u,metalness:h,reflectivity:d,occlusion:f},n.roughness=u,n.metalness=h,n.reflectivity=d,n.occlusion=f}else{n=new yut;let u=new Zt(i.shininess??30),h=new qa(i.specular!==void 0?r.color(i.specular)??1118481:1118481),d=new wl(i.occlusion??!0);c={shininess:u,specular:h,occlusion:d},n.shininess=u,n.specular=h,n.occlusion=d}return n.alpha=new Zt(1),n.shadingAlpha=a,n.shadingBlend=s,n.bumpMapIntensity=o,n.alphaOverride=l,c.alpha=n.shadingAlpha,c.mode=n.shadingBlend,c.bumpMapIntensity=n.bumpMapIntensity,c.alphaOverride=n.alphaOverride,new Cf(e,t,i,n,c,r)}get category(){return this.node.category}};function dht(e){let t=e instanceof yD?e.type:e;return t==="texture"||t==="video"||t==="displace_map"||t==="matcap"}function nh(e){return{alpha:new Zt(e.alpha??1),mode:new Ln(e.mode??0),isMask:new wl(e.isMask??!1)}}function fht(e,t,i,r,n){switch(e.type){case"color":{let a=new qa(r.color??Au),s=nh(r),o=new F9(a,s.alpha),l=new Kn(o.calpha,"f");return new ja(t,i,e,{color:a,...s},o,s.mode,l,s.isMask,n)}case"fresnel":{let a=new qa(r.color??16777215),s=new Zt(Pi(r.bias,n)??.1),o=new Zt(Pi(r.scale,n)??1),l=new Zt(Pi(r.intensity,n)??2),c=new Zt(Pi(r.factor,n)??1),u=nh(r),h=new put(a,s,o,l,c,u.alpha,u.mode,u.isMask),d=new Kn(h.calpha,"f");return new ja(t,i,e,{color:a,bias:s,scale:o,intensity:l,factor:c,...u},h,u.mode,d,u.isMask,n)}case"rainbow":{let a=new Zt(Pi(r.filmThickness,n)??30),s=new Zt(Pi(r.movement,n)??0),o=new hh(lv(r.wavelengths,n)),l=new Zt(Pi(r.noiseStrength,n)??0),c=new Zt(Pi(r.noiseScale,n)??1),u=new hh(lv(r.offset,n)),h=nh(r),d=new mwe(a,s,o,l,c,u,h.alpha,h.isMask),f=new Kn(d.calpha,"f");return new ja(t,i,e,{filmThickness:a,movement:s,wavelengths:o,noiseStrength:l,noiseScale:c,offset:u,...h},d,h.mode,f,h.isMask,n)}case"transmission":{let a=new Zt(Pi(r.thickness??10,n)),s=new Zt(Pi(r.ior??1.5,n)),o=new Zt(Pi(r.roughness??.5,n)),l=gi.transmissionSize,c=gi.transmissionRenderTarget,u=gi.transmissionRenderTargetDepth,h=window.innerWidth,d=window.innerHeight,f=h>=d?new Wo(d/h,1):new Wo(1,h/d),m=nh(r),y=new xwe(a,s,o,l,c,u,f,m.alpha),g=new Kn(y.calpha,"f");return new ja(t,i,e,{thickness:a,ior:s,roughness:o,aspectRatio:f,...m},y,m.mode,g,m.isMask,n)}case"toon":{let a=new Ln(r.positioning??0),s;r.colors?s=new sx(r.colors.length,r.colors):(s=new sx(10,new Ii(0,0,0,1)),s.value[1]=new Ii(1,1,1,1));let o;r.steps?o=new ax(r.steps.length,r.steps):(o=new ax(10,1),o.value[0]=0);let l=new hh(lv(r.source??new Y(0,0,0),n)),c=new wl(r.isWorldSpace??!0),u=new Zt(Pi(r.noiseStrength??0,n)),h=new Zt(Pi(r.noiseScale??1,n)),d=new mm(r.shadowColor),f=new hh(lv(r.offset??new Y(0,0,0),n)),m=nh(r),y=new vwe(a,s,o,l,c,u,h,d,f,m.alpha),g=new Kn(y.calpha,"f");return new ja(t,i,e,{positioning:a,colors:s,steps:o,source:l,isWorldSpace:c,noiseStrength:u,noiseScale:h,shadowColor:d,offset:f,...m},y,m.mode,g,m.isMask,n)}case"outline":{let a=new qa(r.outlineColor??16777215),s=new qa(r.contourColor??16777215),o=new Zt(Pi(r.outlineWidth??.1,n)),l=new Zt(Pi(r.contourWidth??.1,n)),c=new Zt(Pi(r.outlineThreshold??.1,n)),u=new Zt(Pi(r.contourThreshold??.1,n)),h=new Zt(Pi(r.outlineSmoothing??.1,n)),d=new Zt(Pi(r.contourFrequency??.1,n)),f=new hh(lv(r.contourDirection??new Y(0,1,0),n)),m=new wl(r.positionalLines??!1),y=new wl(r.compensation??!0),g=gi.normalRenderTarget,x=gi.normalRenderTargetDepth,w=gi.pixelRatioNode,S=gi.resolution,M=nh(r),E=new dwe(a,s,o,l,c,u,h,d,f,m,y,S,g,x,w,M.alpha),T=new Kn(E.calpha,"f");return new ja(t,i,e,{outlineColor:a,contourColor:s,outlineWidth:o,contourWidth:l,outlineThreshold:c,contourThreshold:u,outlineSmoothing:h,contourFrequency:d,contourDirection:f,positionalLines:m,compensation:y,...M},E,M.mode,T,M.isMask,n)}case"depth":{let a=new Ln(r.gradientType??0),s=new wl(r.smooth??!1),o=new Zt(Pi(r.near,n)??50),l=new Zt(Pi(r.far,n)??200),c=new Zt(r.isVector??1),u=new Zt(r.isWorldSpace??0),h=new hh(lv(r.origin,n)),d=new hh(lv(r.direction,n)),f;r.colors?f=new sx(r.colors.length,r.colors):(f=new sx(2,new Ii(0,0,0,1)),f.value[1]=new Ii(1,1,1,1));let m;r.steps?m=new ax(r.steps.length,r.steps):(m=new ax(2,1),m.value[0]=0);let y=nh(r),g=new awe(a,s,o,l,c,u,h,d,f,m,y.alpha,y.isMask),x=new Kn(g.calpha,"f");return new ja(t,i,e,{gradientType:a,smooth:s,near:o,far:l,isVector:c,isWorldSpace:u,origin:h,direction:d,colors:f,steps:m,...y},g,y.mode,x,y.isMask,n)}case"noise":{let a=new Zt(Pi(r.scale,n)??1),s=new hh(lv(r.size??new Y(100,100,100),n)),o=new Zt(Pi(r.move,n)??1),l=new Wo(Zp(r.fA??new Ce(1.7,9.2),n)),c=new Wo(Zp(r.fB??new Ce(8.3,2.8),n)),u=new Wo(Zp(r.distortion??new Ce(1,1),n)),h=new mm(r.colorA),d=new mm(r.colorB),f=new mm(r.colorC),m=new mm(r.colorD),y=new Ln(r.noiseType??0),g=new Ln(r.voronoiStyle??0),x=new Zt(Pi(r.highCut,n)??1),w=new Zt(Pi(r.lowCut,n)??0),S=new Zt(Pi(r.smoothness,n)??.5),M=new Zt(Pi(r.seed,n)??.5),E=new Ln(r.quality??1),T=nh(r),R=new uwe(a,s,o,l,c,u,h,d,f,m,T.alpha,y,T.isMask,g,x,w,S,M,E),P=new Kn(R.calpha,"f");return new ja(t,i,e,{scale:a,size:s,move:o,fA:l,fB:c,distortion:u,colorA:h,colorB:d,colorC:f,colorD:m,noiseType:y,...T,voronoiStyle:g,highCut:x,lowCut:w,smoothness:S,seed:M,quality:E},R,T.mode,P,T.isMask,n)}case"normal":{let a=new hh(r.cnormal??new Y(1,1,1)),s=nh(r),o=new nwe(a,s.alpha),l=new Kn(o.calpha,"f");return new ja(t,i,e,{cnormal:a,...s},o,s.mode,l,s.isMask,n)}case"gradient":{let a=new Ln(r.gradientType??0),s=new wl(r.smooth??!1),o;r.colors?o=new sx(r.colors.length,r.colors):(o=new sx(10,new Ii(0,0,0,1)),o.value[1]=new Ii(1,1,1,1));let l;r.steps?l=new ax(r.steps.length,r.steps):(l=new ax(10,1),l.value[0]=0);let c=new Wo(Zp(r.offset??new Ce(0,0),n)),u=new Wo(Zp(r.morph??new Ce(0,0),n)),h=new Zt(Pi(r.angle??0,n)),d=nh(r),f=new owe(a,s,o,l,c,u,h,d.alpha,d.isMask),m=new Kn(f.calpha,"f");return new ja(t,i,e,{gradientType:a,smooth:s,colors:o,steps:l,offset:c,morph:u,angle:h,...d},f,d.mode,m,d.isMask,n)}case"pattern":{let a=new Ln(r.style??0),s=new Ln(r.projection??0),o=new Ln(["x","y","z"].indexOf(r.axis)??0),l=new Zt(Pi(r.blending??0,n)),c=new Wo(Zp(r.offset,n)),u=new mm(r.colorA),h=new mm(r.colorB),d=new Wo(Zp(r.frequency??new Ce(10,10),n)),f=new Zt(Pi(r.size??.5,n)),m=new Zt(Pi(r.variation??0,n)),y=new Zt(Pi(r.smoothness??.5,n)),g=new Zt(Pi(r.zigzag??0,n)),x=new Zt(Pi(r.rotation??0,n)),w=new Wo(Zp(r.vertical??new Ce(0,1),n)),S=new Wo(Zp(r.horizontal??new Ce(0,1),n)),M=new Ln(r.sides??6),E=nh(r),T=new fwe(a,s,o,l,c,u,h,d,f,m,y,g,x,w,S,M,E.alpha,E.isMask),R=new Kn(T.calpha,"f");return new ja(t,i,e,{style:a,projection:s,axis:o,blending:l,offset:c,colorA:u,colorB:h,frequency:d,size:f,variation:m,smoothness:y,zigzag:g,rotation:x,vertical:w,horizontal:S,sides:M,...E},T,E.mode,R,E.isMask,n)}default:{let a=new qa(1,0,0,1),s=nh(r),o=new F9(a,s.alpha),l=new Kn(o.calpha,"f");return new ja(t,i,e,{color:a,...s},o,s.mode,l,s.isMask,n)}}}function pht(e,t,i,r){let n=$ut(i,r);return fht(i,e,t,n,r)}function Cwe(e,t,i,r){if(i.type==="displace"&&(e==="intensity"||e==="visible")){let n=t.uniforms[`f${t.id}_intensity`];return n?(n.value=(Pi(i.intensity,r)??1)*(i.visible?1:0),n):void 0}if(i.type!=="displace"&&(e==="alpha"||e==="visible")){let n=t.uniforms[`f${t.id}_alpha`];if(!n)return;if(n.value=ob(i.alpha,r)*(i.visible?1:0),i.type==="outline"&&e==="visible"){let a=t.uniforms[`f${t.id}_compensation`];a&&(a.value=i.compensation&&i.visible)}return n}}function Oc(e,t,i,r,n,a,s=[]){let o=i;for(let l of s)l in o&&(o=o[l]);for(let l of e)l in o&&n.getVariable(o[l],["material",a,"layer",r,...s,String(l)]);for(let l of t)l in o&&o[l].forEach((c,u)=>{n.getVariable(c,["material",a,"layer",r,...s,String(l),u===0?"x":u===1?"y":"z"])})}function y_(e,t){let i=0,r=e.layers.find(n=>n.data.type==="light");if(r){let n=r.data,a=Number(t.getVariable(n.alphaOverride));if((typeof n.alphaOverride=="string"?a/100:n.alphaOverride)<1)return!0}for(let n of e.layers){if(n.data.type!=="displace"&&n.data.isMask)return!0;if(n.data.type!=="displace"&&"alpha"in n.data&&n.data.type!=="light"&&n.data.type!=="fresnel"&&n.data.type!=="texture"&&n.data.type!=="matcap"&&n.data.type!=="rainbow"&&n.data.type!=="outline"&&n.data.type!=="pattern"){let a=n.data.visible?n.data.alpha:0;if(typeof a=="string"&&(a=Math.max(0,Math.min(1,Number(t.getVariable(a)??100)/100))),a===1&&n.data.type==="depth"||n.data.type==="gradient"){for(let s of n.data.colors)if(s[3]<1){a=s[3];break}}else if(a===1&&n.data.type==="noise"){let s=t.color(n.data.colorA).a,o=t.color(n.data.colorB).a,l=t.color(n.data.colorC).a,c=t.color(n.data.colorD).a,u=Math.min(s,Math.min(o,Math.min(l,c)));u<1&&(a=u)}i+=(1-i)*a}}return i<1}var rg=class extends Fr{constructor(){super(void 0),this.flatShading=!1,this.needsJitter=!0,this.shadersPatchedForShapeBlend=!1,this.nodeContextUuid=0,this.fog=!0,this.dithering=!0,this.vertexColors=!0,this.transparent=!0}customProgramCacheKey(){return""}},mht=class extends rg{constructor(e,t,i,r){super(),this.flatShading=e,this.side=t,this.wireframe=i,this.root=r}updateAfterBuild(){let e=this.root;this.lights=e.lights,this.vertexShader=e.vertexShader,this.fragmentShader=e.fragmentShader,Object.assign(this.defines,e.defines),Object.assign(this.uniforms,e.uniforms),this.extensions=e.extensions,this.transparent=e.transparent,this.cacheKey=e.customProgramCacheKey()+"flat"+this.flatShading+this.side}onBeforeCompile(e,t){this.root.onBeforeCompile(e)}get data(){return this.root.data}get category(){return this.root.category}get hasAO(){return this.root.hasAO}getFlavor(e,t,i,r){return this.root.getFlavor(e,t,i,r)}get layers(){return this.root.layers}get fragment(){return this.root.fragment}getLayersOfType(e){return this.root.getLayersOfType(e)}getLayerByUuid(e){return this.root.getLayerByUuid(e)}updateByOp(e,t,i){this.root.updateByOp(e,t,i)}nodeMaterialDispose(){this.root.nodeMaterialDispose()}},l$=class extends rg{constructor(e,t,i=!0){super(),this.data=e,this.allowVariableSaves=i,this.layerIdGen=0,this.flavors=[],this.masks={},this.type="NodeMaterial",this.updaters=[],this.needsJitter=t.shared.needsJitter,qs.startContext(this),this.reset0(e,t),qs.endContext(this)}get nodeMaterial(){return this}getFlavor(e,t,i,r){let n=i?6:(e?3:0)+t;if(n+=(((r==null?void 0:r.resolutionLevel)??0)-(r!=null&&r.useChildrenColors?4:0))*7,n===0)return this;this.flavors===void 0&&(this.flavors=[]),n-=1;let a=this.flavors[n];return a===void 0&&(a=new mht(e,t,i,this),a.needsJitter=this.needsJitter,this.flavors[n]=a,a.flatShading=e,a.side=t,a.updateAfterBuild(),r&&(a.defines.SHAPEBLEND=r.resolutionLevel,a.defines.SHAPEBLEND_C=r.useChildrenColors?1:0)),a}get fragment(){return this.lightLayer.node}get category(){return this.lightLayer.category}get hasAO(){var e;return((e=this.lightLayer.getNode("occlusion"))==null?void 0:e.value)??!1}reset(e,t,i=!1){qs.startContext(this),(this.data!==e||i)&&this.reset0(e,t),qs.endContext(this)}reset0(e,t){this.data=e;let i=e.layers??wo.defaultTwoLayerData("phong").layers;try{this.layers=i.map(r=>yD.create(this.layerIdGen++,r.id,r.data,t.shared))}catch{this.layers=[]}this.layers.reverse(),this.name=e.name??"Untitled Material",this.onUpdate(t.shared),this.transparent=y_(e,t.shared),this.saveVariableLocations(t)}onVariableUpdate(e,t,i){if(e[0]==="alphaOverride")this.transparent=y_(this.data,i.shared),this.lightLayer.setValue("alphaOverride",Math.max(0,Math.min(Number(t)/100,1)));else if(e[0]==="layer"){let r=e[1],n=e[2];if(r&&n){let a=this.layers.find(s=>s.uuid===r);if(a!=null&&a.hasValue(n))if(n==="alpha")this.transparent=y_(this.data,i.shared),a.setValue(n,Math.max(0,Math.min(Number(t)/100,1)));else{let s=a.getValue(n),o=e[3],l=e[4];if(s instanceof wa){let c=s[o],u;typeof c=="number"?u=Number(t):c.isVector2&&(u=c.toArray(),l==="x"?u[0]=Number(t):l==="y"&&(u[1]=Number(t))),o$({[o]:u},i.shared,a);return}(o==="x"||o==="y"||o==="z")&&s.isVector3||(o==="x"||o==="y")&&s.isVector2?s[o]=Number(t):a.setValue(n,t)}}}}saveVariableLocations(e){if(!this.allowVariableSaves)return;let t=this.data.layers.find(i=>i.data.type==="light");t&&e.shared.getVariable(t.data.alphaOverride,["material",this.uuid,"alphaOverride"]),this.data.layers.forEach(i=>{"alpha"in i.data&&typeof i.data.alpha=="string"&&e.shared.getVariable(i.data.alpha,["material",this.uuid,"layer",i.id,"alpha"]),i.data.type==="displace"?i.data.displacementType==="noise"?Oc(["intensity","scale","movement","smoothness","seed","highCut","lowCut"],["offset"],i.data,i.id,e.shared,this.uuid):Oc(["intensity"],[],i.data,i.id,e.shared,this.uuid):i.data.type==="depth"?Oc(["near","far"],["origin","direction"],i.data,i.id,e.shared,this.uuid):i.data.type==="fresnel"?Oc(["bias","scale","intensity","factor"],[],i.data,i.id,e.shared,this.uuid):i.data.type==="rainbow"?Oc(["filmThickness","movement","noiseStrength","noiseScale"],["offset","wavelengths"],i.data,i.id,e.shared,this.uuid):i.data.type==="noise"?Oc(["scale","move","seed","highCut","lowCut","smoothness"],["size","distortion","fA","fB"],i.data,i.id,e.shared,this.uuid):i.data.type==="pattern"?Oc(["blending","size","variation","smoothness","zigzag","rotation"],["offset","frequency","vertical","horizontal"],i.data,i.id,e.shared,this.uuid):i.data.type==="outline"?Oc(["outlineWidth","contourWidth","outlineThreshold","contourThreshold","outlineSmoothing","contourFrequency"],["contourDirection"],i.data,i.id,e.shared,this.uuid):i.data.type==="toon"?Oc(["noiseStrength","noiseScale"],["offset","source"],i.data,i.id,e.shared,this.uuid):i.data.type==="transmission"?Oc(["roughness","thickness","ior"],[],i.data,i.id,e.shared,this.uuid):i.data.type==="texture"||i.data.type==="video"?(Oc([],["size"],i.data,i.id,e.shared,this.uuid),Oc(["rotation"],["repeat","offset"],i.data,i.id,e.shared,this.uuid,["texture"])):i.data.type==="gradient"?Oc(["angle"],["offset","morph"],i.data,i.id,e.shared,this.uuid):i.data.type==="matcap"&&Oc(["rotation"],[],i.data,i.id,e.shared,this.uuid,["texture"])})}getLayersOfType(e){return this.layers.filter(t=>t.type===e)}getLayerByUuid(e){return this.layers.find(t=>t.uuid===e)}onUpdate(e){this.lightLayer=this.layers.find(t=>t instanceof Cf),this.lightLayer===void 0&&(this.lightLayer=new Cf(0,"",{...ss.defaultData("light","phong"),visible:!1},new s$,{},e)),this.dispose();for(let t of this.flavors)t&&t.dispose();this.applyTextureMaps(),this.applyMasks(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),this.build(),this.nodeContextUuid=0}applyTextureMaps(){let e=this.layers.find(n=>n instanceof Cf);if(!e)return;let t=e.data,i=t.bumpMap,r=t.roughnessMap;e.node.bumpMap=void 0,e.node.roughnessMap=void 0;for(let n=0;n<this.layers.length;++n){let a=this.layers[n];a instanceof ja&&a.color instanceof a$&&(a.uuid===i&&(e.node.bumpMap=a.color),a.uuid===r&&(e.node.roughnessMap=a.color))}}updateByOp(e,t,i){if(qs.startContext(this),t!==void 0?this.data=t:t=this.data,this.transparent=y_(t,i.shared),e.path[0]==="layers"){let r=i.shared,n=e.path[1];if(n===void 0)i.scene.markNeedsUpdateRendererDirty(),this.reset0(t,i);else{e.type===0&&e.props.occlusion!==void 0&&i.scene.markNeedsUpdateRendererDirty();let a=this.layers.find(s=>s.uuid===n);if(a){let s=t.layers.data(n),o;e.type===0&&("alpha"in e.props||"alphaOverride"in e.props)&&("alpha"in e.props?o={...e.props,alpha:ob(e.props.alpha,r,["material",this.uuid,"layer",n,"alpha"])}:o={...e.props,alphaOverride:ob(e.props.alphaOverride,r,["material",this.uuid,"alphaOverride"])}),a.updateByOp({...e,...o?{props:o}:{},path:e.path.slice(2)},s,i)&&this.reset0(t,i)}}}else this.reset0(t,i);qs.endContext(this)}applyMasks(){for(let e=0;e<this.layers.length;++e){let t=this.layers[e];t instanceof ja?t.color.mask=void 0:t instanceof Cf&&(t.node.mask=void 0)}for(let e=0;e<this.layers.length;++e){let t=this.layers[e];if(t instanceof ja&&t.isMask.value&&t.data.visible&&e>0){let i=e-1,r=this.layers[i];r instanceof Cf?r.node.mask=new Lc(t.color,t.alpha,Lc.MUL):r instanceof ja&&(r.isMask.value||(r.color.mask=new Lc(t.color,t.alpha,Lc.MUL)))}}}blendColors(){let e=this.layers.findIndex(i=>i instanceof ja),t=this.layers.findIndex(i=>i instanceof Cf);if(e!==-1&&e<t){let i=this.layers[e].color;for(let r=e+1;r<t;++r){let n=this.layers[r];if(n instanceof ja){if(n.isMask.value)continue;i=new uue(i,n.color,n.alpha,n.mode)}}this.fragment.color=i}else this.fragment.color=void 0}blendAfterColors(){let e=new Kn("outgoingLight","f"),t=this.layers.findIndex(i=>i instanceof Cf);if(this.layers.length>t+1){for(let i=t+1;i<this.layers.length;++i){let r=this.layers[i];if(r instanceof ja){if(r.isMask.value)continue;e=new uue(e,r.color,r.alpha,r.mode)}}this.fragment.afterColor=e}else this.fragment.afterColor=void 0}blendPositions(){let e=this.layers.filter(t=>t instanceof Twe);if(e.length>0){let t=e[0].position;for(let i=1;i<e.length;++i)e[i]&&(t=new Lc(t,e[i].position,Lc.ADD),t=new Lc(t,new Zt(.5).setReadonly(!0),Lc.MUL));this.fragment.position=t}else this.fragment.position=void 0}getDefines(){return this.defines}getUniforms(){return this.uniforms}getVertexShader(){return this.vertexShader}getFragmentShader(){return this.fragmentShader}onBeforeCompile(e){this.shapeBlendhack&&this.shapeBlendhack(this),e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.extensionDerivatives=this.extensions.derivatives===!0,e.extensionFragDepth=this.extensions.fragDepth===!0,e.extensionDrawBuffers=this.extensions.drawBuffers===!0,e.extensionShaderTextureLOD=this.extensions.shaderTextureLOD===!0}clampUniformsForPreview(e,t){let i=(r,n,a)=>Math.min(Math.max(r,n),a);for(let r of this.layers)if(r.type==="displace"){let n=i(r.uniforms[`f${r.id}_intensity`].value,e,t);r.uniforms[`f${r.id}_intensity`].value=n}}updateFrame(e){for(let t=0;t<this.updaters.length;++t)e.updateNode(this.updaters[t])}build(){let e=new ewe;e.needsJitter=this.needsJitter,this.lights=this.lightLayer.data.visible,e.build(this.fragment,this.fragment),this.vertexShader=e.getCode("vertex"),this.fragmentShader=e.getCode("fragment"),this.defines=e.defines,this.uniforms=e.uniforms,this.extensions=e.extensions,this.updaters=e.updaters;for(let t of this.flavors)t&&t.updateAfterBuild();return this.shadersPatchedForShapeBlend=!1,this}nodeMaterialDispose(){this.layers.forEach(e=>e.dispose()),super.dispose();for(let e of this.flavors)e&&e.dispose()}assetsLoaded(){for(let e of this.layers)if(e instanceof ja){let t=e.params.texture;if(t instanceof j9&&!t.image.loaded)return!1}return!0}};Object.defineProperties(rg.prototype,{properties:{get:function(){return this.fragment.properties}}});var G9=class extends l${constructor(e,t,i){super(e,t,!1),this.uuid=i,this.allowVariableSaves=!0,this.saveVariableLocations(t)}},bue=new Map;function ght(e){if(typeof e=="string")return e;let t=bue.get(e);return t||(t={url:URL.createObjectURL(new Blob([e]))},bue.set(e,t)),t.url}var Pwe,vht=new Promise(e=>{Pwe=e}),wue=!1,HO;function yht(){if(wue)return;if(HO)return HO;async function e(){await I0(()=>import("./howler-R81SmKVH.js").then(t=>t.h),[]),Pwe(window!==void 0?window:global),wue=!0}return HO=e(),HO}var Dwe;vht.then(e=>Dwe=e);function _ue(e,t){e.forEach(i=>{"dragDropActions"in i.data?(t.push(...i.data.dragDropActions.drag),t.push(...i.data.dragDropActions.drop)):"inActions"in i.data?(t.push(...i.data.inActions),t.push(...i.data.outActions)):"gameActions"in i.data?(t.push(...i.data.gameActions.idle),t.push(...i.data.gameActions.move),t.push(...i.data.gameActions.jump),t.push(...i.data.gameActions.run)):"breakpoints"in i.data?i.data.breakpoints.forEach(r=>{t.push(...r.data.actions)}):"actions"in i.data&&(t.push(...i.data.actions),i.data.actions.forEach(r=>{r.data.type==="Conditional"&&r.data.ifActions&&(t.push(...r.data.ifActions),t.push(...r.data.elseActions))}))})}function xht(e){let t=!1,i=[];return e.scene.objects.traverse((r,n)=>{if(n.type==="Page"&&n.uiScene!==void 0&&n.uiScene.objects.traverse((a,s)=>{if(s.events===void 0||Array.isArray(s.events)===!1)return!0;_ue(s.events,i),t=t||i.some(o=>o.data.type==="Audio")}),n.events===void 0||Array.isArray(n.events)===!1)return!0;_ue(n.events,i),t=t||i.some(a=>a.data.type==="Audio")}),t}var AT=class{constructor({src:e,volume:t,delay:i,loop:r}){this._volume=1,this.delay=0,this._loop=1,this.loopsRemaining=0,this._status="stopped",this.onEnd=()=>{this.loopsRemaining===1/0?this.replay():this.loopsRemaining>1?(this.replay(),this.loopsRemaining--):(this._status="stopped",this.loopsRemaining=this._loop)};let n;typeof e=="string"?n={src:e}:n={src:ght(e),format:"wav"},this.sound=new Dwe.Howl(n),this.sound.on("end",this.onEnd),this.src=e,t!==void 0&&(this.volume=t),i!==void 0&&(this.delay=i),r!==void 0&&(this.loop=r)}get status(){return this._status}get volume(){return this._volume}set volume(e){this._volume=e,this.sound.volume(e)}get loop(){return this._loop}set loop(e){this._loop=e,this.loopsRemaining=e}replay(){this.clearDelay(),this.delayTimerId=window.setTimeout(()=>{this.sound.play(),this.clearDelay()},this.delay)}fade(e,t=1e3){e?(this.sound.volume(this._volume),this.clearFade(),this.fadeTimerId=window.setTimeout(()=>{this.sound.fade(this._volume,0,t),this.clearFade()},e)):this.sound.fade(this._volume,0,t)}on(e,t,i){this.sound.on(e,t,i)}off(e,t,i){this.sound.off(e,t,i)}play(){this._status==="playing"||this.sound.playing()||(this._status==="paused"?(this.sound.seek()===0?this.replay():this.sound.play(),this._status="playing"):this._status==="stopped"&&(this.replay(),this._status="playing"))}pause(){this._status==="playing"&&(this.sound.pause(),this.clearFade(),this.clearDelay(),this._status="paused")}stop(){this.sound.stop(),this.loopsRemaining=this._loop,this.clearFade(),this.clearDelay(),this._status="stopped"}clearFade(){this.fadeTimerId&&(clearTimeout(this.fadeTimerId),delete this.fadeTimerId)}clearDelay(){this.delayTimerId&&(clearTimeout(this.delayTimerId),delete this.delayTimerId)}dispose(e=!1){this.off(),this.stop(),this.clearFade(),this.clearDelay()}},bht=class{constructor(){this.type="ShapePath",this.color=new _i,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new eL,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){var i;return(i=this.currentPath)==null||i.lineTo(e,t),this}quadraticCurveTo(e,t,i,r){var n;return(n=this.currentPath)==null||n.quadraticCurveTo(e,t,i,r),this}bezierCurveTo(e,t,i,r,n,a){var s;return(s=this.currentPath)==null||s.bezierCurveTo(e,t,i,r,n,a),this}splineThru(e){var t;return(t=this.currentPath)==null||t.splineThru(e),this}toShapes(){let e={ORIGIN:0,DESTINATION:1,BETWEEN:2,LEFT:3,RIGHT:4,BEHIND:5,BEYOND:6},t={loc:e.ORIGIN,t:0};function i(f,m,y,g){let x=f.x,w=m.x,S=y.x,M=g.x,E=f.y,T=m.y,R=y.y,P=g.y,I=(M-S)*(E-R)-(P-R)*(x-S),L=(w-x)*(E-R)-(T-E)*(x-S),z=(P-R)*(w-x)-(M-S)*(T-E),U=I/z,j=L/z;if(z===0&&I!==0||U<=0||U>=1||j<0||j>1)return null;if(I===0&&z===0){for(let F=0;F<2;F++)if(r(F===0?y:g,f,m),t.loc===e.ORIGIN){let G=F===0?y:g;return{x:G.x,y:G.y,t:t.t}}else if(t.loc===e.BETWEEN){let G=+(x+t.t*(w-x)).toPrecision(10),H=+(E+t.t*(T-E)).toPrecision(10);return{x:G,y:H,t:t.t}}return null}else{for(let H=0;H<2;H++)if(r(H===0?y:g,f,m),t.loc===e.ORIGIN){let W=H===0?y:g;return{x:W.x,y:W.y,t:t.t}}let F=+(x+U*(w-x)).toPrecision(10),G=+(E+U*(T-E)).toPrecision(10);return{x:F,y:G,t:U}}}function r(f,m,y){let g=y.x-m.x,x=y.y-m.y,w=f.x-m.x,S=f.y-m.y,M=g*S-w*x;if(f.x===m.x&&f.y===m.y){t.loc=e.ORIGIN,t.t=0;return}if(f.x===y.x&&f.y===y.y){t.loc=e.DESTINATION,t.t=1;return}if(M<-Number.EPSILON){t.loc=e.LEFT;return}if(M>Number.EPSILON){t.loc=e.RIGHT;return}if(g*w<0||x*S<0){t.loc=e.BEHIND;return}if(Math.sqrt(g*g+x*x)<Math.sqrt(w*w+S*S)){t.loc=e.BEYOND;return}let E;g!==0?E=w/g:E=S/x,t.loc=e.BETWEEN,t.t=E}function n(f,m){let y=[],g=[];for(let x=1;x<f.length;x++){let w=f[x-1],S=f[x];for(let M=1;M<m.length;M++){let E=m[M-1],T=m[M],R=i(w,S,E,T);R!==null&&y.find(P=>P.t<=R.t+Number.EPSILON&&P.t>=R.t-Number.EPSILON)===void 0&&(y.push(R),g.push(new Ce(R.x,R.y)))}}return g}function a(f,m,y){let g=new Ce;m.getCenter(g);let x=[];return y.forEach(w=>{w.boundingBox.containsPoint(g)&&n(f,w.points).forEach(S=>{x.push({identifier:w.identifier,isCW:w.isCW,point:S})})}),x.sort((w,S)=>w.point.x-S.point.x),x}function s(f,m,y,g,x){(x==null||x==="")&&(x="nonzero");let w=new Ce;f.boundingBox.getCenter(w);let S=[new Ce(y,w.y),new Ce(g,w.y)],M=a(S,f.boundingBox,m);M.sort((L,z)=>L.point.x-z.point.x);let E=[],T=[];M.forEach(L=>{L.identifier===f.identifier?E.push(L):T.push(L)});let R=E[0].point.x,P=[],I=0;for(;I<T.length&&T[I].point.x<R;)P.length>0&&P[P.length-1]===T[I].identifier?P.pop():P.push(T[I].identifier),I++;if(P.push(f.identifier),x==="evenodd"){let L=P.length%2===0,z=P[P.length-2];return{identifier:f.identifier,isHole:L,for:z}}else if(x==="nonzero"){let L=!0,z=null,U=null;for(let j=0;j<P.length;j++){let F=P[j];m[F]&&(L?(U=m[F].isCW,L=!1,z=F):U!==m[F].isCW&&(U=m[F].isCW,L=!0))}return{identifier:f.identifier,isHole:L,for:z}}else console.warn('fill-rule: "'+x+'" is currently not implemented.')}let o=0,l=999999999,c=-999999999,u=[];this.subPaths.forEach(f=>{let m=f.getPoints(),y=-999999999,g=999999999,x=-999999999,w=999999999;for(let S=0;S<m.length;S++){let M=m[S];M.y>y&&(y=M.y),M.y<g&&(g=M.y),M.x>x&&(x=M.x),M.x<w&&(w=M.x)}c<=x&&(c=x+1),l>=w&&(l=w-1),m.length&&u.push({curves:f.curves,points:m,isCW:fxe.isClockWise(m),identifier:o++,boundingBox:new tY(new Ce(w,g),new Ce(x,y))})});let h=u.map(f=>{var m;return s(f,u,l,c,(m=this.userData)==null?void 0:m.style.fillRule)}),d=[];return u.forEach(f=>{let m=h[f.identifier];if(m&&!m.isHole){let y=new tL;y.curves=f.curves,h.filter(g=>(g==null?void 0:g.isHole)&&g.for===f.identifier).forEach(g=>{if(g){let x=u[g.identifier],w=new eL;w.curves=x.curves,y.holes.push(w)}}),d.push(y)}}),d}},Owe=!1,Rwe,Sue=new Promise(e=>{Rwe=e}),Aue=!1,GO;function wht(){if(Owe=!0,Aue)return;if(GO)return GO;async function e(){let t=await I0(()=>import("./opentype-U-0Y99ve.js"),[]);Rwe(t),Aue=!0}return GO=e(),GO}var _ht=class{async load(e,t,i=()=>{}){let{load:r}=await Sue;r(e,(n,a)=>{n||!a?i(n??"Something went wrong"):t(a)})}async parse(e){let{parse:t,Bidi:i}=await Sue;try{let r=t(e),n=new i,a=s=>r.charToGlyphIndex(s.char);return n.registerModifier("glyphIndex",null,a),n.applyFeatures(r,r.defaultRenderOptions.features),{font:r,bidi:n}}catch(r){console.error(r)}}};async function Sht(e){return await(await fetch(e)).arrayBuffer()}var Aht=new _ht;async function Mue(e){let t,i,r=!1;if(e.url?(t=await Sht(e.url),i=e.url,r=e.url.startsWith("/")):e.data&&(t=e.data.buffer.slice(e.data.byteOffset,e.data.byteOffset+e.data.byteLength)),t)if(Owe){let n=await Aht.parse(t);if(n)return{font:n.font,url:i,intercepted:r,arr:t,bidi:n.bidi}}else return{font:void 0,url:i,intercepted:r,arr:t,bidi:null}}function Mht(e,t){return t.state.glyphIndex===e||t.state.fina===e||t.state.medi===e||t.state.init===e}var Eht=class{constructor(e){this._arrayBuffer=new ArrayBuffer(1),this._isLoaded=!1,this._intercepted=!1,this._isUserFont=e.isUserFont??!1,this._loadingPromise=Mue(e).then(t=>{t&&(this._arrayBuffer=t.arr,this._url=t.url,this.font=t.font,this._intercepted=t.intercepted,this._isLoaded=!0,this._bidi=t.bidi)})}update(e){this._isLoaded=!1,this._isUserFont=e.isUserFont??!1,this._loadingPromise=Mue(e).then(t=>{t&&(this._arrayBuffer=t.arr,this._url=t.url,this.font=t.font,this._intercepted=t.intercepted,this._isLoaded=!0,this._bidi=t.bidi)})}get url(){return this._url}get intercepted(){return this._intercepted}get isLoaded(){return this._isLoaded}get loadingPromise(){return this._loadingPromise}reverseLigaturesTable(e,t,i){if(!this._bidi)return[];let r=this._bidi;r.getTextGlyphs(t);let n=r.tokenizer.tokens,a=[],s=0,o=i.length===n.length;for(let l=0;l<i.length;l++){let c=i[l].index,u=String.fromCharCode(i[l].unicode),h=n[s];if(Mht(c,h)||o)a.push({char:u,index:c,replacements:[h.state.glyphIndex],replacementChars:[h.char]}),s++;else{let d=h.char,f="",m=[h.state.glyphIndex],y=[],g=!1;for(;!g;)s++,f=t.charAt(s),d+=f,m.push(e.charToGlyphIndex(f)),y=e.stringToGlyphs(d),y.length===1&&y[0].index===c&&(g=!0),s>t.length&&(g=!0);a.push({char:u,index:c,replacements:m,replacementChars:Array.from(d)}),s++}}return a}generateShapes(e,t,i){var x;if(!this._isLoaded)return;let r=this.font,n=t.fontSize/this.unitsPerEm,a=t.fontSize*t.lineHeight,s=e.map(w=>this.getTextWidth(w,t)),o=typeof t.width=="string"?Number(i.getVariable(t.width)):t.width,l=typeof t.height=="string"?Number(i.getVariable(t.height)):t.height,c=this.getCharWidth(`
|
|
5555
5555
|
`,t),u=t.horizontalAlign===1?c:0,h=this.getLineInitialOffsetX(s[0],o,t.horizontalAlign,e[0],c),d=this.getLineInitialOffsetY(a,e.length,l,n,t.verticalAlign),f=[],m=e.map(w=>[]),y=e.map(w=>[]);for(let w=0;w<e.length;w++){let S=e[w],M={features:{liga:!0},letterSpacing:t.letterSpacing},E=[];try{E=r.stringToGlyphs(S,M)}catch(L){console.warn(L)}h=this.getLineInitialOffsetX(s[w],o,t.horizontalAlign,S,c);let T=[];try{T=this.reverseLigaturesTable(r,S,E)}catch(L){console.warn(L)}let R=this.computeSpaceWidthForLine(e,w,t,i),P=0,I=E[0];I&&t.horizontalAlign===2&&I.leftSideBearing!==void 0&&(h-=I.leftSideBearing*n),(x=this.font)==null||x.forEachGlyph(S,h,d,t.fontSize,M,(L,z,U,j,F)=>{let G=L.index===0?`
|
|
5556
5556
|
`:L.unicode?String.fromCharCode(L.unicode):void 0,H=T[P],W=0;if(G===`
|
|
5557
5557
|
`)W=u;else if(G===" ")W=R;else{let Q=this.createPath(L,n,z,U,t);Q&&(W=Q.offsetX,f.push(Q.path))}if(H.replacements.length===1)y[w].push([z,U]),m[w].push(W);else{let Q=H.replacements.map(J=>(r.glyphs.get(J).advanceWidth??0)*n),ne=Q.reduce((J,ae)=>J+=ae,0),se=Q.map(J=>J/ne),$=z;for(let J=0;J<se.length;J++){let ae=W*se[J];y[w].push([$,U]),m[w].push(ae),$+=ae}}P++}),d-=a}let g=[];for(let w=0,S=f.length;w<S;w++)g.push(...f[w].toShapes());return{shapes:g,charWidths:m,lineWidths:s,charCoords:y}}get isUserFont(){return this._isUserFont}get arrayBuffer(){return this._arrayBuffer}get ascender(){var e;return((e=this.font)==null?void 0:e.ascender)??0}get descender(){var e;return((e=this.font)==null?void 0:e.descender)??0}get familyName(){var e;return((e=this.font)==null?void 0:e.names.fontFamily)??""}get subfamilyName(){var e;return((e=this.font)==null?void 0:e.names.fontSubfamily)??""}get unitsPerEm(){var e;return((e=this.font)==null?void 0:e.unitsPerEm)??1}getLineInitialOffsetX(e,t,i,r,n){return(i===3||i===2)&&r.indexOf(`
|
|
@@ -12432,7 +12432,7 @@ No matching component was found for:
|
|
|
12432
12432
|
#include <tonemapping_fragment>
|
|
12433
12433
|
#include <${_Tt>=154?"colorspace_fragment":"encodings_fragment"}>
|
|
12434
12434
|
}
|
|
12435
|
-
`})}get time(){return this.uniforms.time.value}set time(t){this.uniforms.time.value=t}get pixelRatio(){return this.uniforms.pixelRatio.value}set pixelRatio(t){this.uniforms.pixelRatio.value=t}}const uMe=e=>e&&e.constructor===Float32Array,ETt=e=>[e.r,e.g,e.b],hMe=e=>e instanceof Dt||e instanceof Me||e instanceof zn,dMe=e=>Array.isArray(e)?e:hMe(e)?e.toArray():[e,e,e];function sT(e,t,i){return ee.useMemo(()=>{if(t!==void 0){if(uMe(t))return t;if(t instanceof Jt){const r=Array.from({length:e*3},()=>ETt(t)).flat();return Float32Array.from(r)}else if(hMe(t)||Array.isArray(t)){const r=Array.from({length:e*3},()=>dMe(t)).flat();return Float32Array.from(r)}return Float32Array.from({length:e},()=>t)}return Float32Array.from({length:e},i)},[t])}const fMe=ee.forwardRef(({noise:e=1,count:t=100,speed:i=1,opacity:r=1,scale:n=1,size:a,color:s,children:o,...l},c)=>{ee.useMemo(()=>rMe({SparklesImplMaterial:MTt}),[]);const u=ee.useRef(null),h=mx(S=>S.viewport.dpr),d=dMe(n),f=ee.useMemo(()=>Float32Array.from(Array.from({length:t},()=>d.map(G$.randFloatSpread)).flat()),[t,...d]),m=sT(t,a,Math.random),y=sT(t,r),g=sT(t,i),x=sT(t*3,e),w=sT(s===void 0?t*3:t,uMe(s)?s:new Jt(s),()=>1);return Jc(S=>{u.current&&u.current.material&&(u.current.material.time=S.clock.elapsedTime)}),ee.useImperativeHandle(c,()=>u.current,[]),ee.createElement("points",SN({key:`particle-${t}-${JSON.stringify(n)}`},l,{ref:u}),ee.createElement("bufferGeometry",null,ee.createElement("bufferAttribute",{attach:"attributes-position",args:[f,3]}),ee.createElement("bufferAttribute",{attach:"attributes-size",args:[m,1]}),ee.createElement("bufferAttribute",{attach:"attributes-opacity",args:[y,1]}),ee.createElement("bufferAttribute",{attach:"attributes-speed",args:[g,1]}),ee.createElement("bufferAttribute",{attach:"attributes-color",args:[w,3]}),ee.createElement("bufferAttribute",{attach:"attributes-noise",args:[x,3]})),o||ee.createElement("sparklesImplMaterial",{transparent:!0,pixelRatio:h,depthWrite:!1}))});function TTt({pixelated:e}){const t=mx(s=>s.gl),i=mx(s=>s.internal.active),r=mx(s=>s.performance.current),n=mx(s=>s.viewport.initialDpr),a=mx(s=>s.setDpr);return ee.useEffect(()=>{const s=t.domElement;return()=>{i&&a(n),e&&s&&(s.style.imageRendering="auto")}},[]),ee.useEffect(()=>{a(r*n),e&&t.domElement&&(t.domElement.style.imageRendering=r===1?"auto":"pixelated")},[r]),null}function CTt({position:e}){const t=ee.useRef(null),i=ee.useRef(null);return Jc(({clock:r})=>{const n=r.getElapsedTime();if(i.current&&(i.current.rotation.y=Math.sin(n*1.2)*.12),t.current){const a=t.current.material;a.emissiveIntensity=.6+Math.sin(n*3)*.3}}),C.jsx("group",{position:e,children:C.jsx(V0,{speed:1.5,rotationIntensity:.1,floatIntensity:.5,children:C.jsxs("group",{ref:i,children:[C.jsxs("mesh",{children:[C.jsx("boxGeometry",{args:[30,20,2]}),C.jsx("meshStandardMaterial",{color:"#111122",metalness:.5,roughness:.3})]}),C.jsxs("mesh",{ref:t,position:[0,0,1.2],children:[C.jsx("boxGeometry",{args:[26,16,.5]}),C.jsx("meshStandardMaterial",{color:"#22d3ee",emissive:"#22d3ee",emissiveIntensity:.6,transparent:!0,opacity:.85})]})]})})})}function PTt({position:e}){const t=ee.useRef(null),i=ee.useRef(null);Jc(({clock:n})=>{const a=n.getElapsedTime();t.current&&(t.current.rotation.y=.3+Math.sin(a*1.5)*.05),i.current&&(i.current.rotation.y=-.3-Math.sin(a*1.5)*.05)});const r=C.jsx("meshStandardMaterial",{color:"#c4b5fd",emissive:"#8b5cf6",emissiveIntensity:.5});return C.jsx("group",{position:e,children:C.jsxs(V0,{speed:1.5,rotationIntensity:.1,floatIntensity:.5,children:[C.jsx("group",{ref:t,position:[-7,0,0],children:C.jsxs("mesh",{children:[C.jsx("boxGeometry",{args:[12,16,1]}),r]})}),C.jsx("group",{ref:i,position:[7,0,0],children:C.jsxs("mesh",{children:[C.jsx("boxGeometry",{args:[12,16,1]}),r]})}),C.jsxs("mesh",{children:[C.jsx("boxGeometry",{args:[2,16,2]}),C.jsx("meshStandardMaterial",{color:"#1e1b2e"})]})]})})}function DTt({position:e}){const t=ee.useRef(null);Jc(({clock:r})=>{const n=r.getElapsedTime();t.current&&(t.current.visible=Math.sin(n*4)>0,t.current.position.x=-8+n*6%16)});const i=C.jsx("meshStandardMaterial",{color:"#22c55e",emissive:"#22c55e",emissiveIntensity:.6});return C.jsx("group",{position:e,children:C.jsxs(V0,{speed:1.5,rotationIntensity:.1,floatIntensity:.5,children:[C.jsxs("mesh",{children:[C.jsx("boxGeometry",{args:[28,18,2]}),C.jsx("meshStandardMaterial",{color:"#0a0a14"})]}),C.jsxs("mesh",{position:[-11,4,1.2],children:[C.jsx("boxGeometry",{args:[2,2,.5]}),i]}),C.jsxs("mesh",{position:[-2,4,1.2],children:[C.jsx("boxGeometry",{args:[14,1.2,.3]}),i]}),C.jsxs("mesh",{position:[-4,0,1.2],children:[C.jsx("boxGeometry",{args:[10,1.2,.3]}),i]}),C.jsxs("mesh",{ref:t,position:[-8,-4,1.2],children:[C.jsx("boxGeometry",{args:[2,3,.5]}),i]})]})})}function OTt({position:e}){const t=ee.useRef(null);Jc(({clock:r})=>{const n=r.getElapsedTime();t.current&&(t.current.rotation.z=Math.sin(n*1.2)*.4)});const i=C.jsx("meshStandardMaterial",{color:"#3b82f6",emissive:"#3b82f6",emissiveIntensity:.5});return C.jsx("group",{position:e,children:C.jsx(V0,{speed:1.5,rotationIntensity:.1,floatIntensity:.5,children:C.jsxs("group",{ref:t,children:[C.jsxs("mesh",{children:[C.jsx("torusGeometry",{args:[9,2.5,16,32]}),i]}),C.jsxs("mesh",{position:[0,0,0],children:[C.jsx("circleGeometry",{args:[6.5,32]}),C.jsx("meshStandardMaterial",{color:"#3b82f6",emissive:"#3b82f6",emissiveIntensity:.2,transparent:!0,opacity:.3})]}),C.jsxs("mesh",{rotation:[0,0,-Math.PI/4],position:[8,-8,0],children:[C.jsx("cylinderGeometry",{args:[2,1.5,14,8]}),i]})]})})})}function RTt({position:e}){const t=ee.useRef(null),i=ee.useRef(null),r=ee.useRef(null);Jc(({clock:a})=>{const s=a.getElapsedTime();[t,i,r].forEach((l,c)=>{if(l.current){const u=s*3-c*.4,h=Math.max(0,Math.sin(u)),d=Math.pow(2,-5*h)*Math.sin(h*Math.PI*2)+h;l.current.position.y=d*5}})});const n=C.jsx("meshStandardMaterial",{color:"#a855f7",emissive:"#a855f7",emissiveIntensity:.6});return C.jsx("group",{position:e,children:C.jsxs(V0,{speed:1.5,rotationIntensity:.1,floatIntensity:.5,children:[C.jsxs("mesh",{position:[0,-2,-1],children:[C.jsx("boxGeometry",{args:[36,14,1]}),C.jsx("meshStandardMaterial",{color:"#1a0a2e",transparent:!0,opacity:.5})]}),C.jsxs("mesh",{ref:t,position:[-10,0,0],children:[C.jsx("sphereGeometry",{args:[3,16,16]}),n]}),C.jsxs("mesh",{ref:i,position:[0,0,0],children:[C.jsx("sphereGeometry",{args:[3,16,16]}),n]}),C.jsxs("mesh",{ref:r,position:[10,0,0],children:[C.jsx("sphereGeometry",{args:[3,16,16]}),n]})]})})}function ITt({position:e}){const t=ee.useRef(null);Jc(({clock:r})=>{t.current&&(t.current.rotation.z=r.getElapsedTime()*.8)});const i=C.jsx("meshStandardMaterial",{color:"#f97316",emissive:"#f97316",emissiveIntensity:.5});return C.jsx("group",{position:e,children:C.jsxs(V0,{speed:1.5,rotationIntensity:.1,floatIntensity:.5,children:[C.jsxs("mesh",{ref:t,children:[C.jsx("torusGeometry",{args:[10,3,6,8]}),i]}),C.jsxs("mesh",{children:[C.jsx("circleGeometry",{args:[5,32]}),i]})]})})}function NTt({position:e}){const t=ee.useRef(null);return Jc(({clock:i})=>{const r=i.getElapsedTime();if(t.current){t.current.rotation.y=r*.6,t.current.rotation.x=Math.sin(r*.8)*.3;const n=t.current.material;n.emissiveIntensity=.5+Math.sin(r*2)*.4}}),C.jsx("group",{position:e,children:C.jsxs(V0,{speed:1.5,rotationIntensity:.1,floatIntensity:.5,children:[C.jsxs("mesh",{ref:t,children:[C.jsx("octahedronGeometry",{args:[12,0]}),C.jsx("meshStandardMaterial",{color:"#fbbf24",emissive:"#fbbf24",emissiveIntensity:.5,metalness:.4,roughness:.2})]}),C.jsx(fMe,{count:30,size:3,speed:.5,color:"#fbbf24",scale:30})]})})}function LTt({position:e}){const t=ee.useRef(null);Jc(({clock:r})=>{const n=r.getElapsedTime();if(t.current){const a=1+Math.sin(n*3)*.1;t.current.scale.set(a,a,a)}});const i=C.jsx("meshStandardMaterial",{color:"#ef4444",emissive:"#ef4444",emissiveIntensity:.6});return C.jsx("group",{position:e,children:C.jsx(V0,{speed:1.5,rotationIntensity:.1,floatIntensity:.5,children:C.jsxs("group",{ref:t,children:[C.jsxs("mesh",{rotation:[0,0,Math.PI/4],children:[C.jsx("boxGeometry",{args:[4,24,3]}),i]}),C.jsxs("mesh",{rotation:[0,0,-Math.PI/4],children:[C.jsx("boxGeometry",{args:[4,24,3]}),i]})]})})})}function npe(e){const t=1-e;return 1-t*t*t}function ape(e){return e*e*e}const kTt=2,sI=.3,Hw=.7;function zTt({position:e,color:t,onComplete:i}){const r=ee.useRef(null),n=ee.useRef(null),a=ee.useRef(null),s=ee.useRef(null),[o,l]=ee.useState(!1),c=t??"#8b5cf6";return Jc(({clock:u})=>{if(o)return;const h=u.getElapsedTime();s.current===null&&(s.current=h);const d=h-s.current,f=Math.min(d/kTt,1);if(f>=1){l(!0),i==null||i();return}const m=r.current;if(!m)return;let y;if(f<sI){const S=f/sI;y=npe(S)}else if(f<Hw)y=1;else{const S=(f-Hw)/(1-Hw);y=1-ape(S)}m.scale.setScalar(Math.max(y,.001));const g=n.current;g&&(g.rotation.y+=.05,g.rotation.x=Math.sin(d*2)*.3);let x;if(f<sI)x=npe(f/sI)*.8;else if(f<Hw)x=.8;else{const S=(f-Hw)/(1-Hw);x=.8*(1-ape(S))}if(g){const S=g.material;S.opacity=x}const w=a.current;w&&(w.intensity=y*2)}),o?null:C.jsxs("group",{ref:r,position:e,children:[C.jsx(ATt,{ref:n,args:[15,25,32],children:C.jsx("meshStandardMaterial",{color:c,emissive:c,emissiveIntensity:1.5,transparent:!0,opacity:.8,side:2,depthWrite:!1})}),C.jsx(fMe,{count:40,size:3,speed:.5,color:c,scale:[50,50,10]}),C.jsx("pointLight",{ref:a,color:c,intensity:2,distance:100,decay:2})]})}const fm=[0,0,0];function BTt({pose:e}){switch(e){case"coding":return C.jsx(CTt,{position:fm});case"reading":return C.jsx(PTt,{position:fm});case"terminal":return C.jsx(DTt,{position:fm});case"searching":return C.jsx(OTt,{position:fm});case"talking":return C.jsx(RTt,{position:fm});case"managing":return C.jsx(ITt,{position:fm});case"celebrating":return C.jsx(NTt,{position:fm});case"idle":return null;default:return C.jsx(LTt,{position:fm})}}function UTt({agentId:e,pose:t,positionsRef:i,zoom:r}){const n=ee.useRef(null);return Jc(()=>{var c;const a=n.current,s=(c=i.current)==null?void 0:c.get(e);if(!a)return;if(!s){a.visible=!1;return}a.visible=!0,a.position.x+=(s.x-a.position.x)*.15,a.position.y+=(s.y-a.position.y)*.15,a.position.z=0;const l=r*1.8-a.scale.x;if(Math.abs(l)>.001){const u=a.scale.x+l*.2;a.scale.set(u,u,u)}}),C.jsx("group",{ref:n,visible:!1,children:C.jsx(BTt,{pose:t})})}function jTt({agentId:e,positionsRef:t,color:i,onComplete:r}){const n=ee.useRef(null);return Jc(()=>{var o;const a=n.current,s=(o=t.current)==null?void 0:o.get(e);!a||!s||(a.position.x=s.x,a.position.y=s.y,a.position.z=0,a.visible=!0)}),C.jsx("group",{ref:n,visible:!1,children:C.jsx(zTt,{position:fm,color:i,onComplete:r})})}function FTt({containerRef:e,agents:t,zoom:i,spawningAgentIds:r}){const{camera:n,size:a}=mx(),s=ee.useRef(new Map),o=ee.useRef(new Map),l=ee.useRef(0);ee.useEffect(()=>{const u=n;u.left=-a.width/2,u.right=a.width/2,u.top=a.height/2,u.bottom=-a.height/2,u.updateProjectionMatrix()},[n,a]),Jc(()=>{const u=e.current;if(!u||!u.isConnected)return;l.current++;const h=l.current;if(h%30===0||o.current.size===0){o.current.clear();const d=u.querySelectorAll("[data-agent-id]");for(const f of d){const m=f.dataset.agentId;m&&o.current.set(m,f)}}if(h%2===0){const d=u.getBoundingClientRect(),f=d.width/2,m=d.height/2;for(const y of t){if(y.pose==="idle")continue;let g=o.current.get(y.agentId);if(!g||!g.isConnected){const T=u.querySelector(`[data-agent-id="${y.agentId}"]`);if(T)g=T,o.current.set(y.agentId,T);else continue}const x=g.getBoundingClientRect(),w=x.left-d.left+x.width/2,S=x.top-d.top,M=w-f,E=m-S+30*i;s.current.set(y.agentId,{x:M,y:E})}}});const c=ee.useMemo(()=>t.filter(u=>u.pose!=="idle"),[t]);return C.jsxs(C.Fragment,{children:[C.jsx("ambientLight",{intensity:.6}),C.jsx("directionalLight",{position:[100,200,300],intensity:.8}),C.jsx(TTt,{pixelated:!0}),c.map(u=>C.jsx(UTt,{agentId:u.agentId,pose:u.pose,positionsRef:s,zoom:i},u.agentId)),c.filter(u=>r.has(u.agentId)).map(u=>C.jsx(jTt,{agentId:u.agentId,positionsRef:s},`spawn-${u.agentId}`))]})}function VTt({containerRef:e,agents:t,zoom:i,spawningAgentIds:r}){return ee.useMemo(()=>t.some(a=>a.pose!=="idle")||r.size>0,[t,r])?C.jsx(bTt,{orthographic:!0,camera:{position:[0,0,500],zoom:1},gl:{alpha:!0,antialias:!1,powerPreference:"high-performance"},style:{pointerEvents:"none",position:"absolute",inset:"0",zIndex:15},frameloop:"always",children:C.jsx(FTt,{containerRef:e,agents:t,zoom:i,spawningAgentIds:r})}):null}const HTt=new Set(["working","moving","talking","error"]),GTt=new Set(["idle","shutdown","completed"]),WTt=new Set(["coding","reading","terminal","talking","searching","managing"]);function qTt(e){return HTt.has(e.animationState)?!0:GTt.has(e.animationState)?!1:WTt.has(e.pose)}function XTt({positions:e,agentMeta:t}){return ee.useMemo(()=>{const i=[],r=[],n=[],a=[];for(const m of e.values())qTt(m)?n.push(m):a.push(m);const s=new Set(n.map(m=>m.agentId)),o=new Map,l=[];for(const m of n){const y=m.parentAgentId;if(!y||!s.has(y))l.push(m);else{const g=o.get(y)??[];g.push(m),o.set(y,g)}}const u=n.length<=1,h=l.length,f=-((h-1)*fH)/2;for(let m=0;m<h;m++){const y=l[m],g=t.get(y.agentId),x=h===1?0:f+m*fH;i.push({agentId:y.agentId,position:[x,0,0],modelType:"main",color:(g==null?void 0:g.color)??"#8b5cf6",name:(g==null?void 0:g.name)??y.agentId,type:(g==null?void 0:g.type)??"general-purpose",pose:y.pose,animationState:y.animationState,activityLabel:y.activityLabel,lastTool:y.lastTool,parentAgentId:y.parentAgentId});const w=o.get(y.agentId)??[],S=fH*.8,M=(w.length-1)*S,E=x-M/2;for(let T=0;T<w.length;T++){const R=w[T],P=t.get(R.agentId),I=w.length===1?x:E+T*S;i.push({agentId:R.agentId,position:[I,0,3],modelType:u?"main":"sub",color:(P==null?void 0:P.color)??"#8b5cf6",name:(P==null?void 0:P.name)??R.agentId,type:(P==null?void 0:P.type)??"general-purpose",pose:R.pose,animationState:R.animationState,activityLabel:R.activityLabel,lastTool:R.lastTool,parentAgentId:R.parentAgentId})}}for(const m of a){const y=t.get(m.agentId);r.push({agentId:m.agentId,position:[0,0,0],modelType:m.parentAgentId?"sub":"main",color:(y==null?void 0:y.color)??"#8b5cf6",name:(y==null?void 0:y.name)??m.agentId,type:(y==null?void 0:y.type)??"general-purpose",pose:m.pose,animationState:m.animationState,activityLabel:m.activityLabel,lastTool:m.lastTool,parentAgentId:m.parentAgentId})}return{active:i,inactive:r}},[e,t])}const spe={zoom:1,panX:0,panY:0};function YTt(e){const[t,i]=ee.useState(spe),[r,n]=ee.useState(!1),a=ee.useRef(t);a.current=t;const s=ee.useRef(!1),o=ee.useRef({x:0,y:0,panX:0,panY:0});ee.useEffect(()=>{const h=e.current;if(!h)return;function d(f){if(Math.abs(f.deltaX)>Math.abs(f.deltaY))return;f.preventDefault();const m=h.getBoundingClientRect(),y=f.clientX-m.left,g=f.clientY-m.top;i(x=>{const w=1-f.deltaY*.001,S=Math.round(Math.min(cyt,Math.max(lyt,x.zoom*w))*100)/100;if(S===x.zoom)return x;const M=S/x.zoom,E=y-M*(y-x.panX),T=g-M*(g-x.panY);return{zoom:S,panX:E,panY:T}})}return h.addEventListener("wheel",d,{passive:!1}),()=>h.removeEventListener("wheel",d)},[e]);const l=ee.useCallback(h=>{const d=h.target.closest("[data-agent-id]");if(h.button===0&&d||h.button!==0&&h.button!==1)return;s.current=!0,n(!0);const f=a.current;o.current={x:h.clientX,y:h.clientY,panX:f.panX,panY:f.panY},h.preventDefault()},[]);ee.useEffect(()=>{function h(f){if(!s.current)return;const m=f.clientX-o.current.x,y=f.clientY-o.current.y;i({zoom:a.current.zoom,panX:o.current.panX+m,panY:o.current.panY+y})}function d(){s.current&&(s.current=!1,n(!1))}return window.addEventListener("mousemove",h),window.addEventListener("mouseup",d),()=>{window.removeEventListener("mousemove",h),window.removeEventListener("mouseup",d)}},[]);const c=ee.useCallback(()=>{i(spe)},[]),u=`translate(${t.panX}px, ${t.panY}px) scale(${t.zoom})`;return{zoom:t.zoom,panX:t.panX,panY:t.panY,isPanning:r,transformStyle:u,handleMouseDown:l,reset:c}}const F7=160,pMe=2,ope=F7*pMe,$Tt={default:{accent:"#8b5cf6",text:"text-violet-400"},warning:{accent:"#f59e0b",text:"text-amber-400"},error:{accent:"#ef4444",text:"text-red-400"},success:{accent:"#22c55e",text:"text-emerald-400"},pulse:{accent:"#10b981",text:"text-emerald-400"}};function KTt({title:e,subtitle:t,variant:i="default",children:r}){const[n,a]=ee.useState(!0),s=ee.useRef(null),o=$Tt[i],l=ee.useCallback(c=>{var h,d;const u=c;try{const f=(h=u._renderer)==null?void 0:h.pipeline;f!=null&&f.logoOverlayPass&&(f.logoOverlayPass.enabled=!1),f==null||f.setWatermark(null)}catch{}try{(d=u.play)==null||d.call(u)}catch{}a(!1)},[]);return ee.useEffect(()=>{if(n)return;const c=s.current;if(!c)return;const u=c.querySelector("canvas");if(!u)return;let h=!1;function d(){h=!0}function f(){h=!1}function m(y){h||u.dispatchEvent(new PointerEvent("pointermove",{clientX:y.clientX,clientY:y.clientY,pointerId:1,pointerType:"mouse",bubbles:!1}))}return u.addEventListener("pointerenter",d),u.addEventListener("pointerleave",f),window.addEventListener("pointermove",m),()=>{u.removeEventListener("pointerenter",d),u.removeEventListener("pointerleave",f),window.removeEventListener("pointermove",m)}},[n]),C.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-5 px-6",children:[C.jsxs("div",{ref:s,className:"relative overflow-hidden shrink-0",style:{width:F7,height:F7},children:[n&&C.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-10",children:C.jsx("div",{className:"w-8 h-8 border-2 rounded-full animate-spin",style:{borderColor:`${o.accent}30`,borderTopColor:"transparent"}})}),C.jsx("div",{style:{width:ope,height:ope,transform:`scale(${1/pMe})`,transformOrigin:"top left"},children:C.jsx($_e,{scene:K_e.main,onLoad:l,style:{width:"100%",height:"100%",opacity:n?0:1,transition:"opacity 0.5s ease-in"}})}),!n&&C.jsx("div",{className:"absolute inset-[-6px] rounded-2xl pointer-events-none transition-all duration-700",style:{boxShadow:`0 0 20px ${o.accent}25, 0 0 40px ${o.accent}10`}})]}),C.jsxs("div",{className:"flex flex-col items-center gap-2 max-w-sm text-center",children:[C.jsx("h3",{className:`${o.text} text-sm font-mono font-semibold`,children:e}),t&&C.jsx("p",{className:"text-zinc-500 text-xs font-mono leading-relaxed",children:t}),r]})]})}function pG({n:e,children:t}){return C.jsxs("div",{className:"flex items-start gap-2.5",children:[C.jsx("span",{className:"shrink-0 w-5 h-5 rounded-full flex items-center justify-center text-[10px] font-mono font-bold bg-violet-500/15 text-violet-400",children:e}),C.jsx("span",{className:"text-zinc-400 text-xs font-mono pt-0.5 leading-relaxed",children:t})]})}function MK(){Dye();const e=ee.useRef(null),t=Ni(Z=>Z.session),i=Ni(Z=>Z.agents),r=Ni(Z=>Z.selectedAgentId),n=Ni(Z=>Z.selectAgent),{positions:a,speechBubbles:s,interactionLines:o,showLabels:l,showInteractions:c}=C_(),{zoom:u,transformStyle:h,isPanning:d,handleMouseDown:f,reset:m}=YTt(e),[y,g]=ee.useState(null),[x,w]=ee.useState(new Map),S=ee.useRef({agentId:null,mouseX:0,mouseY:0,agentX:0,agentY:0}),M=ee.useRef(u);M.current=u;const E=ee.useMemo(()=>{const Z=new Map;for(const ce of i)Z.set(ce.id,Ch(ce.id,ce.name||ce.id,ce.type??void 0));return Z},[i]),T=ee.useMemo(()=>{const Z=new Map;for(const ce of i){const me=jHe(ce.name||ce.id);Z.set(ce.id,me.primary)}return Z},[i]),R=ee.useMemo(()=>{const Z=new Map;for(const ce of i)Z.set(ce.id,ce.type);return Z},[i]),P=ee.useMemo(()=>{const Z=new Map;for(const ce of i)Z.set(ce.id,{name:E.get(ce.id)??ce.id,type:R.get(ce.id)??"general-purpose",color:T.get(ce.id)??"#8b5cf6",status:ce.status});return Z},[i,E,R,T]),{active:I,inactive:L}=XTt({positions:a,agentMeta:P}),z=ee.useMemo(()=>{const Z=new Map;for(const ce of s){const me=Z.get(ce.fromAgentId)??[];me.push(ce),Z.set(ce.fromAgentId,me)}return Z},[s]),U=ee.useCallback(Z=>{n(r===Z?null:Z)},[n,r]),j=I.length>0?I:[{agentId:"claude-main",position:[0,0,0],modelType:"main",color:"#8b5cf6",name:"Claude",type:"general-purpose",pose:"idle",animationState:"idle",activityLabel:null,lastTool:null,parentAgentId:null}],F=ee.useMemo(()=>j.map(Z=>Z.agentId).join(","),[j]),[G,H]=ee.useState({w:1200,h:600}),W=ee.useMemo(()=>{const{w:Z,h:ce}=G,me=j.length,he=me*H_+(me-1)*cde,we=(Z-he)/2,Ee=(ce-uyt)/2,Se=new Map;for(let Ne=0;Ne<me;Ne++)Se.set(j[Ne].agentId,{x:Math.max(0,we+Ne*(H_+cde)),y:Math.max(0,Ee)});return Se},[F,G,j]);ee.useEffect(()=>{const Z=e.current;if(!Z)return;const ce=new ResizeObserver(me=>{const{width:he,height:we}=me[0].contentRect;he>0&&we>0&&H({w:he,h:we})});return ce.observe(Z),()=>ce.disconnect()},[]),ee.useEffect(()=>{const Z=new Set(j.map(ce=>ce.agentId));w(ce=>{let me=!1;for(const we of ce.keys())Z.has(we)||(me=!0);if(!me)return ce;const he=new Map;for(const[we,Ee]of ce)Z.has(we)&&he.set(we,Ee);return he})},[F,j]);const Q=ee.useCallback(Z=>x.get(Z)??W.get(Z)??{x:0,y:0},[x,W]),ne=ee.useCallback((Z,ce)=>{if(ce.button!==0)return;ce.stopPropagation();const me=Q(Z);S.current={agentId:Z,mouseX:ce.clientX,mouseY:ce.clientY,agentX:me.x,agentY:me.y},g(Z)},[Q]);ee.useEffect(()=>{function Z(me){const he=S.current;if(!he.agentId)return;const we=M.current,Ee=(me.clientX-he.mouseX)/we,Se=(me.clientY-he.mouseY)/we;w(Ne=>{const Pe=new Map(Ne);return Pe.set(he.agentId,{x:he.agentX+Ee,y:he.agentY+Se}),Pe})}function ce(){S.current.agentId&&(S.current.agentId=null,g(null))}return window.addEventListener("mousemove",Z),window.addEventListener("mouseup",ce),()=>{window.removeEventListener("mousemove",Z),window.removeEventListener("mouseup",ce)}},[]);const se=ee.useMemo(()=>j.map(Z=>({agentId:Z.agentId,pose:Z.pose})),[j]),$=ee.useRef(new Set),[J,ae]=ee.useState(new Set);ee.useEffect(()=>{const Z=new Set(j.map(he=>he.agentId)),ce=$.current,me=new Set;for(const he of Z)ce.has(he)||me.add(he);if($.current=Z,me.size>0){ae(me);const he=setTimeout(()=>ae(new Set),1500);return()=>clearTimeout(he)}},[F,j]);const oe=ee.useCallback(Z=>{Z.target.closest("[data-agent-id]")||m()},[m]),xe=y||d?"grabbing":"default";return t?C.jsxs("div",{className:"flex flex-col h-full overflow-hidden relative",children:[C.jsx($ae,{}),C.jsxs("div",{ref:e,className:"flex-1 relative overflow-hidden",style:{background:"radial-gradient(ellipse at center, #0f0f1a 0%, #0a0a12 70%)",minHeight:0,cursor:xe},onMouseDown:f,onDoubleClick:oe,children:[C.jsx("div",{className:"absolute inset-0 pointer-events-none",style:{backgroundImage:["linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px)","linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px)"].join(","),backgroundSize:`${40*u}px ${40*u}px`}}),C.jsx("div",{className:"absolute inset-0",style:{transform:h,transformOrigin:"0 0",willChange:y||d?"transform":"auto"},children:j.map(Z=>{const ce=Q(Z.agentId),me=y===Z.agentId,he=z.get(Z.agentId)??[],we=he.length>0?he[he.length-1]:null;return C.jsxs("div",{"data-agent-id":Z.agentId,className:`absolute flex flex-col items-center${J.has(Z.agentId)?" cam-agent-spawning":""}`,style:{left:`${ce.x}px`,top:`${ce.y}px`,width:`${H_}px`,zIndex:me?50:10,cursor:me?"grabbing":"grab",transition:me?"none":"left 0.3s ease, top 0.3s ease",userSelect:"none"},onMouseDown:Ee=>ne(Z.agentId,Ee),children:[we&&C.jsx("div",{className:"mb-2 max-w-[280px]",children:C.jsx(Z_e,{bubble:we,color:Z.color},we.id)}),C.jsx(fyt,{modelType:Z.modelType,isSelected:r===Z.agentId,isDragging:y===Z.agentId,onClick:()=>U(Z.agentId),color:Z.color,pose:Z.pose,animationState:Z.animationState}),C.jsx(byt,{agentId:Z.agentId,name:Z.name,color:Z.color,activityLabel:Z.activityLabel,speechBubbles:he,showLabels:l,hideBubble:!0})]},Z.agentId)})}),C.jsx(VTt,{containerRef:e,agents:se,zoom:u,spawningAgentIds:J}),C.jsx(Syt,{containerRef:e,interactionLines:o,positions:a,agentColors:T,showInteractions:c}),u!==1&&C.jsxs("div",{className:"absolute bottom-3 right-3 z-30 text-xs font-mono text-zinc-500 bg-black/50 px-2 py-1 rounded select-none pointer-events-none",children:[Math.round(u*100),"%"]})]}),C.jsx(wyt,{agents:L,selectedAgentId:r,onSelectAgent:U})]}):C.jsxs("div",{className:"flex flex-col h-full overflow-hidden relative",children:[C.jsx($ae,{}),C.jsxs("div",{className:"flex-1 relative overflow-hidden flex items-center justify-center",style:{background:"radial-gradient(ellipse at center, #0f0f1a 0%, #0a0a12 70%)"},children:[C.jsx("div",{className:"absolute inset-0 pointer-events-none",style:{backgroundImage:["linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px)","linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px)"].join(","),backgroundSize:"40px 40px"}}),C.jsxs(KTt,{title:"Welcome to CAM!",subtitle:"Start a Claude Code session to see your agents here in real-time.",variant:"default",children:[C.jsxs("div",{className:"flex flex-col gap-2 mt-3 text-left",children:[C.jsx(pG,{n:1,children:"Open a terminal in this project"}),C.jsxs(pG,{n:2,children:["Run ",C.jsx("code",{className:"px-1.5 py-0.5 rounded bg-zinc-800 text-violet-300 text-[11px] font-mono",children:"claude"})," to start Claude Code"]}),C.jsx(pG,{n:3,children:"Agents will appear here as they work"})]}),C.jsx("p",{className:"text-zinc-600 text-[10px] font-mono mt-3",children:"Or select a previous session from the picker above"})]})]})]})}const QTt=[{id:"overview",label:"Overview"},{id:"dependencies",label:"Deps"},{id:"activity",label:"Activity"}];function EK(){const{selectedTaskId:e,tasks:t,selectTask:i,sprints:r,activeProject:n}=_n(),a=oz(),[s,o]=ee.useState("overview"),[l,c]=ee.useState([]),[u,h]=ee.useState(!1),d=t.find(S=>S.id===e);if(ee.useEffect(()=>{s==="activity"&&d&&n&&(h(!0),KEe(n.id,d.id).then(S=>c(S.activities??[])).catch(()=>c([])).finally(()=>h(!1)))},[s,d==null?void 0:d.id,n==null?void 0:n.id]),!d)return null;const f=r.find(S=>S.id===d.sprintId),m=G7(d.priority),y=FEe(d.status),g=d.dependsOn.map(S=>t.find(M=>M.id===S)).filter(S=>S!==void 0),x=d.blockedBy.map(S=>t.find(M=>M.id===S)).filter(S=>S!==void 0),w=t.filter(S=>S.dependsOn.includes(d.id)||S.blockedBy.includes(d.id));return C.jsxs("div",{className:"h-full flex flex-col",children:[C.jsxs("div",{className:"p-4 border-b border-cam-border/30 shrink-0",children:[C.jsxs("div",{className:"flex items-start justify-between mb-3",children:[C.jsx("h3",{className:"text-sm font-semibold text-cam-text leading-tight flex-1 pr-2",children:d.title}),C.jsx("button",{onClick:()=>i(null),className:"text-cam-text-muted hover:text-cam-text transition-colors p-1 shrink-0",children:C.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:C.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),C.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-3",children:[C.jsx("span",{className:`text-[9px] px-1.5 py-0.5 rounded border font-medium ${m}`,children:d.priority}),C.jsx("span",{className:`text-[9px] px-1.5 py-0.5 rounded font-medium ${y}`,children:d.status.replace(/_/g," ")}),d.complexity&&C.jsxs("span",{className:"text-[9px] px-1.5 py-0.5 rounded bg-cam-surface-3 text-cam-text-muted border border-cam-border/50",children:["C",d.complexity]})]}),C.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[f&&C.jsxs("div",{className:"bg-cam-surface-2 rounded-md px-2 py-1.5",children:[C.jsx("div",{className:"text-[9px] text-cam-text-muted",children:"Sprint"}),C.jsx("div",{className:"text-[10px] text-cam-text font-medium truncate",children:f.name})]}),d.prdSection&&C.jsxs("div",{className:"bg-cam-surface-2 rounded-md px-2 py-1.5",children:[C.jsx("div",{className:"text-[9px] text-cam-text-muted",children:"Section"}),C.jsx("div",{className:"text-[10px] text-cam-text font-medium truncate",children:d.prdSection})]}),d.assignedAgent&&(()=>{const S=a(d.assignedAgent);return C.jsxs("div",{className:"bg-cam-surface-2 rounded-md px-2 py-1.5",children:[C.jsx("div",{className:"text-[9px] text-cam-text-muted",children:"Agent"}),C.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[C.jsx("div",{className:"w-3 h-3 rounded-full flex items-center justify-center text-[7px] font-bold",style:{backgroundColor:`${f0(d.assignedAgent)}20`,color:f0(d.assignedAgent)},children:S.charAt(0).toUpperCase()}),C.jsx("span",{className:"text-[10px] text-cam-text font-medium",children:S})]})]})})()]})]}),C.jsx("div",{className:"flex border-b border-cam-border/30 shrink-0",children:QTt.map(S=>{const M=S.id==="dependencies"?g.length+x.length+w.length:S.id==="activity"?l.length:0;return C.jsxs("button",{onClick:()=>o(S.id),className:`flex-1 py-2 text-[10px] font-medium transition-colors border-b-2 ${s===S.id?"text-cam-accent border-cam-accent":"text-cam-text-muted border-transparent hover:text-cam-text-secondary"}`,children:[S.label,M>0&&` (${M})`]},S.id)})}),C.jsxs("div",{className:"flex-1 overflow-y-auto modern-scrollbar",children:[s==="overview"&&C.jsx(ZTt,{task:d}),s==="dependencies"&&C.jsx(JTt,{dependsOn:g,blockedBy:x,blocks:w,onSelectTask:i,resolveAgentName:a}),s==="activity"&&C.jsx(tCt,{activities:l,loading:u,resolveAgentName:a})]})]})}function ZTt({task:e}){return C.jsxs("div",{className:"p-3 space-y-4",children:[e.description&&C.jsxs("div",{children:[C.jsx("h4",{className:"text-[10px] uppercase tracking-wider text-cam-text-muted font-medium mb-1",children:"Description"}),C.jsx("p",{className:"text-[11px] text-cam-text-secondary leading-relaxed",children:e.description})]}),e.acceptanceCriteria&&e.acceptanceCriteria.length>0&&C.jsxs("div",{children:[C.jsx("h4",{className:"text-[10px] uppercase tracking-wider text-cam-text-muted font-medium mb-1",children:"Acceptance Criteria"}),C.jsx("ul",{className:"space-y-1",children:e.acceptanceCriteria.map((t,i)=>C.jsxs("li",{className:"flex items-start gap-1.5 text-[11px] text-cam-text-secondary",children:[C.jsx("span",{className:"text-cam-accent mt-0.5 shrink-0",children:e.status==="completed"?"✓":"○"}),C.jsx("span",{children:t})]},i))})]}),e.tags&&e.tags.length>0&&C.jsxs("div",{children:[C.jsx("h4",{className:"text-[10px] uppercase tracking-wider text-cam-text-muted font-medium mb-1",children:"Tags"}),C.jsx("div",{className:"flex flex-wrap gap-1",children:e.tags.map(t=>C.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded bg-cam-surface-3 text-cam-text-muted border border-cam-border/30",children:t},t))})]}),C.jsxs("div",{children:[C.jsx("h4",{className:"text-[10px] uppercase tracking-wider text-cam-text-muted font-medium mb-1",children:"Timeline"}),C.jsxs("div",{className:"space-y-1 text-[10px]",children:[C.jsxs("div",{className:"flex justify-between",children:[C.jsx("span",{className:"text-cam-text-muted",children:"Created"}),C.jsx("span",{className:"text-cam-text-secondary font-mono",children:qc(e.createdAt)})]}),e.startedAt&&C.jsxs("div",{className:"flex justify-between",children:[C.jsx("span",{className:"text-cam-text-muted",children:"Started"}),C.jsx("span",{className:"text-cam-text-secondary font-mono",children:qc(e.startedAt)})]}),e.completedAt&&C.jsxs("div",{className:"flex justify-between",children:[C.jsx("span",{className:"text-cam-text-muted",children:"Completed"}),C.jsx("span",{className:"text-cam-text-secondary font-mono",children:qc(e.completedAt)})]})]})]})]})}function JTt({dependsOn:e,blockedBy:t,blocks:i,onSelectTask:r,resolveAgentName:n}){return e.length===0&&t.length===0&&i.length===0?C.jsx("p",{className:"text-xs text-cam-text-muted p-4 text-center",children:"No dependencies"}):C.jsxs("div",{className:"p-3 space-y-4",children:[t.length>0&&C.jsx(mG,{title:"Blocked By",tasks:t,color:"text-red-400",onSelect:r,resolveAgentName:n}),e.length>0&&C.jsx(mG,{title:"Depends On",tasks:e,color:"text-yellow-400",onSelect:r,resolveAgentName:n}),i.length>0&&C.jsx(mG,{title:"Blocks",tasks:i,color:"text-blue-400",onSelect:r,resolveAgentName:n})]})}function mG({title:e,tasks:t,color:i,onSelect:r,resolveAgentName:n}){return C.jsxs("div",{children:[C.jsxs("h4",{className:`text-[10px] uppercase tracking-wider font-medium mb-1 ${i}`,children:[e," (",t.length,")"]}),C.jsx("div",{className:"space-y-1",children:t.map(a=>C.jsxs("button",{onClick:()=>r(a.id),className:"w-full text-left px-2 py-1.5 rounded hover:bg-cam-surface-2 transition-colors group",children:[C.jsxs("div",{className:"flex items-center gap-2",children:[C.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${eCt(a.status)}`}),C.jsx("span",{className:"text-[11px] text-cam-text-secondary group-hover:text-cam-text truncate",children:a.title})]}),C.jsxs("div",{className:"flex items-center gap-2 ml-3.5 mt-0.5",children:[C.jsx("span",{className:"text-[9px] text-cam-text-muted capitalize",children:a.status.replace(/_/g," ")}),a.assignedAgent&&C.jsxs("span",{className:"text-[9px] text-cam-text-muted",children:["@",n(a.assignedAgent)]})]})]},a.id))})]})}function eCt(e){return{backlog:"bg-gray-500",planned:"bg-blue-500",pending:"bg-yellow-500",in_progress:"bg-emerald-500",in_review:"bg-purple-500",completed:"bg-green-500",blocked:"bg-red-500",deferred:"bg-gray-500"}[e]||"bg-gray-500"}function tCt({activities:e,loading:t,resolveAgentName:i}){return t?C.jsx("div",{className:"flex items-center justify-center p-4",children:C.jsx("span",{className:"text-[10px] text-cam-text-muted animate-pulse",children:"Loading activities..."})}):e.length===0?C.jsx("p",{className:"text-xs text-cam-text-muted p-4 text-center",children:"No activity recorded"}):C.jsx("div",{className:"divide-y divide-cam-border/20",children:e.map(r=>C.jsxs("div",{className:"px-3 py-2",children:[C.jsxs("div",{className:"flex items-center justify-between",children:[C.jsx("span",{className:"text-[11px] font-medium text-cam-accent",children:iCt(r.activityType)}),C.jsx("span",{className:"text-[9px] text-cam-text-muted font-mono",children:gu(r.timestamp)})]}),C.jsx("div",{className:"flex items-center gap-2 mt-0.5",children:C.jsxs("span",{className:"text-[9px] text-cam-text-muted",children:["@",i(r.agentId)]})}),r.details&&C.jsx("p",{className:"text-[10px] text-cam-text-secondary mt-0.5",children:r.details})]},r.id))})}function iCt(e){return{task_created:"Task Created",task_started:"Task Started",task_completed:"Task Completed",task_blocked:"Task Blocked",task_unblocked:"Task Unblocked",agent_assigned:"Agent Assigned",file_modified:"File Modified",error_occurred:"Error Occurred",manual_update:"Manual Update"}[e]||e.replace(/_/g," ")}const tU=ee.createContext(null);tU.displayName="PanelGroupContext";const Ha={group:"data-panel-group",groupDirection:"data-panel-group-direction",groupId:"data-panel-group-id",panel:"data-panel",panelCollapsible:"data-panel-collapsible",panelId:"data-panel-id",panelSize:"data-panel-size",resizeHandle:"data-resize-handle",resizeHandleActive:"data-resize-handle-active",resizeHandleEnabled:"data-panel-resize-handle-enabled",resizeHandleId:"data-panel-resize-handle-id",resizeHandleState:"data-resize-handle-state"},TK=10,$x=ee.useLayoutEffect,lpe=PEe.useId,rCt=typeof lpe=="function"?lpe:()=>null;let nCt=0;function CK(e=null){const t=rCt(),i=ee.useRef(e||t||null);return i.current===null&&(i.current=""+nCt++),e??i.current}function mMe({children:e,className:t="",collapsedSize:i,collapsible:r,defaultSize:n,forwardedRef:a,id:s,maxSize:o,minSize:l,onCollapse:c,onExpand:u,onResize:h,order:d,style:f,tagName:m="div",...y}){const g=ee.useContext(tU);if(g===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:x,expandPanel:w,getPanelSize:S,getPanelStyle:M,groupId:E,isPanelCollapsed:T,reevaluatePanelConstraints:R,registerPanel:P,resizePanel:I,unregisterPanel:L}=g,z=CK(s),U=ee.useRef({callbacks:{onCollapse:c,onExpand:u,onResize:h},constraints:{collapsedSize:i,collapsible:r,defaultSize:n,maxSize:o,minSize:l},id:z,idIsFromProps:s!==void 0,order:d});ee.useRef({didLogMissingDefaultSizeWarning:!1}),$x(()=>{const{callbacks:F,constraints:G}=U.current,H={...G};U.current.id=z,U.current.idIsFromProps=s!==void 0,U.current.order=d,F.onCollapse=c,F.onExpand=u,F.onResize=h,G.collapsedSize=i,G.collapsible=r,G.defaultSize=n,G.maxSize=o,G.minSize=l,(H.collapsedSize!==G.collapsedSize||H.collapsible!==G.collapsible||H.maxSize!==G.maxSize||H.minSize!==G.minSize)&&R(U.current,H)}),$x(()=>{const F=U.current;return P(F),()=>{L(F)}},[d,z,P,L]),ee.useImperativeHandle(a,()=>({collapse:()=>{x(U.current)},expand:F=>{w(U.current,F)},getId(){return z},getSize(){return S(U.current)},isCollapsed(){return T(U.current)},isExpanded(){return!T(U.current)},resize:F=>{I(U.current,F)}}),[x,w,S,T,z,I]);const j=M(U.current,n);return ee.createElement(m,{...y,children:e,className:t,id:z,style:{...j,...f},[Ha.groupId]:E,[Ha.panel]:"",[Ha.panelCollapsible]:r||void 0,[Ha.panelId]:z,[Ha.panelSize]:parseFloat(""+j.flexGrow).toFixed(1)})}const gMe=ee.forwardRef((e,t)=>ee.createElement(mMe,{...e,forwardedRef:t}));mMe.displayName="Panel";gMe.displayName="forwardRef(Panel)";let V7=null,II=-1,jv=null;function aCt(e,t){if(t){const i=(t&wMe)!==0,r=(t&_Me)!==0,n=(t&SMe)!==0,a=(t&AMe)!==0;if(i)return n?"se-resize":a?"ne-resize":"e-resize";if(r)return n?"sw-resize":a?"nw-resize":"w-resize";if(n)return"s-resize";if(a)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function sCt(){jv!==null&&(document.head.removeChild(jv),V7=null,jv=null,II=-1)}function gG(e,t){var i,r;const n=aCt(e,t);if(V7!==n){if(V7=n,jv===null&&(jv=document.createElement("style"),document.head.appendChild(jv)),II>=0){var a;(a=jv.sheet)===null||a===void 0||a.removeRule(II)}II=(i=(r=jv.sheet)===null||r===void 0?void 0:r.insertRule(`*{cursor: ${n} !important;}`))!==null&&i!==void 0?i:-1}}function vMe(e){return e.type==="keydown"}function yMe(e){return e.type.startsWith("pointer")}function xMe(e){return e.type.startsWith("mouse")}function iU(e){if(yMe(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(xMe(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function oCt(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function lCt(e,t,i){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function cCt(e,t){if(e===t)throw new Error("Cannot compare node with itself");const i={a:hpe(e),b:hpe(t)};let r;for(;i.a.at(-1)===i.b.at(-1);)e=i.a.pop(),t=i.b.pop(),r=e;br(r,"Stacking order can only be calculated for elements with a common ancestor");const n={a:upe(cpe(i.a)),b:upe(cpe(i.b))};if(n.a===n.b){const a=r.childNodes,s={a:i.a.at(-1),b:i.b.at(-1)};let o=a.length;for(;o--;){const l=a[o];if(l===s.a)return 1;if(l===s.b)return-1}}return Math.sign(n.a-n.b)}const uCt=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function hCt(e){var t;const i=getComputedStyle((t=bMe(e))!==null&&t!==void 0?t:e).display;return i==="flex"||i==="inline-flex"}function dCt(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||hCt(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||uCt.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function cpe(e){let t=e.length;for(;t--;){const i=e[t];if(br(i,"Missing node"),dCt(i))return i}return null}function upe(e){return e&&Number(getComputedStyle(e).zIndex)||0}function hpe(e){const t=[];for(;e;)t.push(e),e=bMe(e);return t}function bMe(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const wMe=1,_Me=2,SMe=4,AMe=8,fCt=oCt()==="coarse";let Ed=[],q_=!1,gx=new Map,rU=new Map;const qP=new Set;function pCt(e,t,i,r,n){var a;const{ownerDocument:s}=t,o={direction:i,element:t,hitAreaMargins:r,setResizeHandlerState:n},l=(a=gx.get(s))!==null&&a!==void 0?a:0;return gx.set(s,l+1),qP.add(o),Qk(),function(){var u;rU.delete(e),qP.delete(o);const h=(u=gx.get(s))!==null&&u!==void 0?u:1;if(gx.set(s,h-1),Qk(),h===1&&gx.delete(s),Ed.includes(o)){const d=Ed.indexOf(o);d>=0&&Ed.splice(d,1),DK(),n("up",!0,null)}}}function mCt(e){const{target:t}=e,{x:i,y:r}=iU(e);q_=!0,PK({target:t,x:i,y:r}),Qk(),Ed.length>0&&(Zk("down",e),e.preventDefault(),MMe(t)||e.stopImmediatePropagation())}function vG(e){const{x:t,y:i}=iU(e);if(q_&&e.buttons===0&&(q_=!1,Zk("up",e)),!q_){const{target:r}=e;PK({target:r,x:t,y:i})}Zk("move",e),DK(),Ed.length>0&&e.preventDefault()}function yG(e){const{target:t}=e,{x:i,y:r}=iU(e);rU.clear(),q_=!1,Ed.length>0&&(e.preventDefault(),MMe(t)||e.stopImmediatePropagation()),Zk("up",e),PK({target:t,x:i,y:r}),DK(),Qk()}function MMe(e){let t=e;for(;t;){if(t.hasAttribute(Ha.resizeHandle))return!0;t=t.parentElement}return!1}function PK({target:e,x:t,y:i}){Ed.splice(0);let r=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(r=e),qP.forEach(n=>{const{element:a,hitAreaMargins:s}=n,o=a.getBoundingClientRect(),{bottom:l,left:c,right:u,top:h}=o,d=fCt?s.coarse:s.fine;if(t>=c-d&&t<=u+d&&i>=h-d&&i<=l+d){if(r!==null&&document.contains(r)&&a!==r&&!a.contains(r)&&!r.contains(a)&&cCt(r,a)>0){let m=r,y=!1;for(;m&&!m.contains(a);){if(lCt(m.getBoundingClientRect(),o)){y=!0;break}m=m.parentElement}if(y)return}Ed.push(n)}})}function xG(e,t){rU.set(e,t)}function DK(){let e=!1,t=!1;Ed.forEach(r=>{const{direction:n}=r;n==="horizontal"?e=!0:t=!0});let i=0;rU.forEach(r=>{i|=r}),e&&t?gG("intersection",i):e?gG("horizontal",i):t?gG("vertical",i):sCt()}let bG=new AbortController;function Qk(){bG.abort(),bG=new AbortController;const e={capture:!0,signal:bG.signal};qP.size&&(q_?(Ed.length>0&&gx.forEach((t,i)=>{const{body:r}=i;t>0&&(r.addEventListener("contextmenu",yG,e),r.addEventListener("pointerleave",vG,e),r.addEventListener("pointermove",vG,e))}),window.addEventListener("pointerup",yG,e),window.addEventListener("pointercancel",yG,e)):gx.forEach((t,i)=>{const{body:r}=i;t>0&&(r.addEventListener("pointerdown",mCt,e),r.addEventListener("pointermove",vG,e))}))}function Zk(e,t){qP.forEach(i=>{const{setResizeHandlerState:r}=i,n=Ed.includes(i);r(e,n,t)})}function gCt(){const[e,t]=ee.useState(0);return ee.useCallback(()=>t(i=>i+1),[])}function br(e,t){if(!e)throw console.error(t),Error(t)}function gb(e,t,i=TK){return e.toFixed(i)===t.toFixed(i)?0:e>t?1:-1}function Mm(e,t,i=TK){return gb(e,t,i)===0}function hu(e,t,i){return gb(e,t,i)===0}function vCt(e,t,i){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++){const n=e[r],a=t[r];if(!hu(n,a,i))return!1}return!0}function S_({panelConstraints:e,panelIndex:t,size:i}){const r=e[t];br(r!=null,`Panel constraints not found for index ${t}`);let{collapsedSize:n=0,collapsible:a,maxSize:s=100,minSize:o=0}=r;if(gb(i,o)<0)if(a){const l=(n+o)/2;gb(i,l)<0?i=n:i=o}else i=o;return i=Math.min(s,i),i=parseFloat(i.toFixed(TK)),i}function CT({delta:e,initialLayout:t,panelConstraints:i,pivotIndices:r,prevLayout:n,trigger:a}){if(hu(e,0))return t;const s=[...t],[o,l]=r;br(o!=null,"Invalid first pivot index"),br(l!=null,"Invalid second pivot index");let c=0;if(a==="keyboard"){{const h=e<0?l:o,d=i[h];br(d,`Panel constraints not found for index ${h}`);const{collapsedSize:f=0,collapsible:m,minSize:y=0}=d;if(m){const g=t[h];if(br(g!=null,`Previous layout not found for panel index ${h}`),hu(g,f)){const x=y-g;gb(x,Math.abs(e))>0&&(e=e<0?0-x:x)}}}{const h=e<0?o:l,d=i[h];br(d,`No panel constraints found for index ${h}`);const{collapsedSize:f=0,collapsible:m,minSize:y=0}=d;if(m){const g=t[h];if(br(g!=null,`Previous layout not found for panel index ${h}`),hu(g,y)){const x=g-f;gb(x,Math.abs(e))>0&&(e=e<0?0-x:x)}}}}{const h=e<0?1:-1;let d=e<0?l:o,f=0;for(;;){const y=t[d];br(y!=null,`Previous layout not found for panel index ${d}`);const x=S_({panelConstraints:i,panelIndex:d,size:100})-y;if(f+=x,d+=h,d<0||d>=i.length)break}const m=Math.min(Math.abs(e),Math.abs(f));e=e<0?0-m:m}{let d=e<0?o:l;for(;d>=0&&d<i.length;){const f=Math.abs(e)-Math.abs(c),m=t[d];br(m!=null,`Previous layout not found for panel index ${d}`);const y=m-f,g=S_({panelConstraints:i,panelIndex:d,size:y});if(!hu(m,g)&&(c+=m-g,s[d]=g,c.toPrecision(3).localeCompare(Math.abs(e).toPrecision(3),void 0,{numeric:!0})>=0))break;e<0?d--:d++}}if(vCt(n,s))return n;{const h=e<0?l:o,d=t[h];br(d!=null,`Previous layout not found for panel index ${h}`);const f=d+c,m=S_({panelConstraints:i,panelIndex:h,size:f});if(s[h]=m,!hu(m,f)){let y=f-m,x=e<0?l:o;for(;x>=0&&x<i.length;){const w=s[x];br(w!=null,`Previous layout not found for panel index ${x}`);const S=w+y,M=S_({panelConstraints:i,panelIndex:x,size:S});if(hu(w,M)||(y-=M-w,s[x]=M),hu(y,0))break;e>0?x--:x++}}}const u=s.reduce((h,d)=>d+h,0);return hu(u,100)?s:n}function yCt({layout:e,panelsArray:t,pivotIndices:i}){let r=0,n=100,a=0,s=0;const o=i[0];br(o!=null,"No pivot index found"),t.forEach((h,d)=>{const{constraints:f}=h,{maxSize:m=100,minSize:y=0}=f;d===o?(r=y,n=m):(a+=y,s+=m)});const l=Math.min(n,100-a),c=Math.max(r,100-s),u=e[o];return{valueMax:l,valueMin:c,valueNow:u}}function XP(e,t=document){return Array.from(t.querySelectorAll(`[${Ha.resizeHandleId}][data-panel-group-id="${e}"]`))}function EMe(e,t,i=document){const n=XP(e,i).findIndex(a=>a.getAttribute(Ha.resizeHandleId)===t);return n??null}function TMe(e,t,i){const r=EMe(e,t,i);return r!=null?[r,r+1]:[-1,-1]}function CMe(e,t=document){var i;if(t instanceof HTMLElement&&(t==null||(i=t.dataset)===null||i===void 0?void 0:i.panelGroupId)==e)return t;const r=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return r||null}function nU(e,t=document){const i=t.querySelector(`[${Ha.resizeHandleId}="${e}"]`);return i||null}function xCt(e,t,i,r=document){var n,a,s,o;const l=nU(t,r),c=XP(e,r),u=l?c.indexOf(l):-1,h=(n=(a=i[u])===null||a===void 0?void 0:a.id)!==null&&n!==void 0?n:null,d=(s=(o=i[u+1])===null||o===void 0?void 0:o.id)!==null&&s!==void 0?s:null;return[h,d]}function bCt({committedValuesRef:e,eagerValuesRef:t,groupId:i,layout:r,panelDataArray:n,panelGroupElement:a,setLayout:s}){ee.useRef({didWarnAboutMissingResizeHandle:!1}),$x(()=>{if(!a)return;const o=XP(i,a);for(let l=0;l<n.length-1;l++){const{valueMax:c,valueMin:u,valueNow:h}=yCt({layout:r,panelsArray:n,pivotIndices:[l,l+1]}),d=o[l];if(d!=null){const f=n[l];br(f,`No panel data found for index "${l}"`),d.setAttribute("aria-controls",f.id),d.setAttribute("aria-valuemax",""+Math.round(c)),d.setAttribute("aria-valuemin",""+Math.round(u)),d.setAttribute("aria-valuenow",h!=null?""+Math.round(h):"")}}return()=>{o.forEach((l,c)=>{l.removeAttribute("aria-controls"),l.removeAttribute("aria-valuemax"),l.removeAttribute("aria-valuemin"),l.removeAttribute("aria-valuenow")})}},[i,r,n,a]),ee.useEffect(()=>{if(!a)return;const o=t.current;br(o,"Eager values not found");const{panelDataArray:l}=o,c=CMe(i,a);br(c!=null,`No group found for id "${i}"`);const u=XP(i,a);br(u,`No resize handles found for group id "${i}"`);const h=u.map(d=>{const f=d.getAttribute(Ha.resizeHandleId);br(f,"Resize handle element has no handle id attribute");const[m,y]=xCt(i,f,l,a);if(m==null||y==null)return()=>{};const g=x=>{if(!x.defaultPrevented)switch(x.key){case"Enter":{x.preventDefault();const w=l.findIndex(S=>S.id===m);if(w>=0){const S=l[w];br(S,`No panel data found for index ${w}`);const M=r[w],{collapsedSize:E=0,collapsible:T,minSize:R=0}=S.constraints;if(M!=null&&T){const P=CT({delta:hu(M,E)?R-E:E-M,initialLayout:r,panelConstraints:l.map(I=>I.constraints),pivotIndices:TMe(i,f,a),prevLayout:r,trigger:"keyboard"});r!==P&&s(P)}}break}}};return d.addEventListener("keydown",g),()=>{d.removeEventListener("keydown",g)}});return()=>{h.forEach(d=>d())}},[a,e,t,i,r,n,s])}function dpe(e,t){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(e[i]!==t[i])return!1;return!0}function PMe(e,t){const i=e==="horizontal",{x:r,y:n}=iU(t);return i?r:n}function wCt(e,t,i,r,n){const a=i==="horizontal",s=nU(t,n);br(s,`No resize handle element found for id "${t}"`);const o=s.getAttribute(Ha.groupId);br(o,"Resize handle element has no group id attribute");let{initialCursorPosition:l}=r;const c=PMe(i,e),u=CMe(o,n);br(u,`No group element found for id "${o}"`);const h=u.getBoundingClientRect(),d=a?h.width:h.height;return(c-l)/d*100}function _Ct(e,t,i,r,n,a){if(vMe(e)){const s=i==="horizontal";let o=0;e.shiftKey?o=100:n!=null?o=n:o=10;let l=0;switch(e.key){case"ArrowDown":l=s?0:o;break;case"ArrowLeft":l=s?-o:0;break;case"ArrowRight":l=s?o:0;break;case"ArrowUp":l=s?0:-o;break;case"End":l=100;break;case"Home":l=-100;break}return l}else return r==null?0:wCt(e,t,i,r,a)}function SCt({panelDataArray:e}){const t=Array(e.length),i=e.map(a=>a.constraints);let r=0,n=100;for(let a=0;a<e.length;a++){const s=i[a];br(s,`Panel constraints not found for index ${a}`);const{defaultSize:o}=s;o!=null&&(r++,t[a]=o,n-=o)}for(let a=0;a<e.length;a++){const s=i[a];br(s,`Panel constraints not found for index ${a}`);const{defaultSize:o}=s;if(o!=null)continue;const l=e.length-r,c=n/l;r++,t[a]=c,n-=c}return t}function Gw(e,t,i){t.forEach((r,n)=>{const a=e[n];br(a,`Panel data not found for index ${n}`);const{callbacks:s,constraints:o,id:l}=a,{collapsedSize:c=0,collapsible:u}=o,h=i[l];if(h==null||r!==h){i[l]=r;const{onCollapse:d,onExpand:f,onResize:m}=s;m&&m(r,h),u&&(d||f)&&(f&&(h==null||Mm(h,c))&&!Mm(r,c)&&f(),d&&(h==null||!Mm(h,c))&&Mm(r,c)&&d())}})}function oI(e,t){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(e[i]!=t[i])return!1;return!0}function ACt({defaultSize:e,dragState:t,layout:i,panelData:r,panelIndex:n,precision:a=3}){const s=i[n];let o;return s==null?o=e!=null?e.toPrecision(a):"1":r.length===1?o="1":o=s.toPrecision(a),{flexBasis:0,flexGrow:o,flexShrink:1,overflow:"hidden",pointerEvents:t!==null?"none":void 0}}function MCt(e,t=10){let i=null;return(...n)=>{i!==null&&clearTimeout(i),i=setTimeout(()=>{e(...n)},t)}}function fpe(e){try{if(typeof localStorage<"u")e.getItem=t=>localStorage.getItem(t),e.setItem=(t,i)=>{localStorage.setItem(t,i)};else throw new Error("localStorage not supported in this environment")}catch(t){console.error(t),e.getItem=()=>null,e.setItem=()=>{}}}function DMe(e){return`react-resizable-panels:${e}`}function OMe(e){return e.map(t=>{const{constraints:i,id:r,idIsFromProps:n,order:a}=t;return n?r:a?`${a}:${JSON.stringify(i)}`:JSON.stringify(i)}).sort((t,i)=>t.localeCompare(i)).join(",")}function RMe(e,t){try{const i=DMe(e),r=t.getItem(i);if(r){const n=JSON.parse(r);if(typeof n=="object"&&n!=null)return n}}catch{}return null}function ECt(e,t,i){var r,n;const a=(r=RMe(e,i))!==null&&r!==void 0?r:{},s=OMe(t);return(n=a[s])!==null&&n!==void 0?n:null}function TCt(e,t,i,r,n){var a;const s=DMe(e),o=OMe(t),l=(a=RMe(e,n))!==null&&a!==void 0?a:{};l[o]={expandToSizes:Object.fromEntries(i.entries()),layout:r};try{n.setItem(s,JSON.stringify(l))}catch(c){console.error(c)}}function ppe({layout:e,panelConstraints:t}){const i=[...e],r=i.reduce((a,s)=>a+s,0);if(i.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${i.map(a=>`${a}%`).join(", ")}`);if(!hu(r,100)&&i.length>0)for(let a=0;a<t.length;a++){const s=i[a];br(s!=null,`No layout data found for index ${a}`);const o=100/r*s;i[a]=o}let n=0;for(let a=0;a<t.length;a++){const s=i[a];br(s!=null,`No layout data found for index ${a}`);const o=S_({panelConstraints:t,panelIndex:a,size:s});s!=o&&(n+=s-o,i[a]=o)}if(!hu(n,0))for(let a=0;a<t.length;a++){const s=i[a];br(s!=null,`No layout data found for index ${a}`);const o=s+n,l=S_({panelConstraints:t,panelIndex:a,size:o});if(s!==l&&(n-=l-s,i[a]=l,hu(n,0)))break}return i}const CCt=100,PT={getItem:e=>(fpe(PT),PT.getItem(e)),setItem:(e,t)=>{fpe(PT),PT.setItem(e,t)}},mpe={};function IMe({autoSaveId:e=null,children:t,className:i="",direction:r,forwardedRef:n,id:a=null,onLayout:s=null,keyboardResizeBy:o=null,storage:l=PT,style:c,tagName:u="div",...h}){const d=CK(a),f=ee.useRef(null),[m,y]=ee.useState(null),[g,x]=ee.useState([]),w=gCt(),S=ee.useRef({}),M=ee.useRef(new Map),E=ee.useRef(0),T=ee.useRef({autoSaveId:e,direction:r,dragState:m,id:d,keyboardResizeBy:o,onLayout:s,storage:l}),R=ee.useRef({layout:g,panelDataArray:[],panelDataArrayChanged:!1});ee.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),ee.useImperativeHandle(n,()=>({getId:()=>T.current.id,getLayout:()=>{const{layout:ae}=R.current;return ae},setLayout:ae=>{const{onLayout:oe}=T.current,{layout:xe,panelDataArray:Z}=R.current,ce=ppe({layout:ae,panelConstraints:Z.map(me=>me.constraints)});dpe(xe,ce)||(x(ce),R.current.layout=ce,oe&&oe(ce),Gw(Z,ce,S.current))}}),[]),$x(()=>{T.current.autoSaveId=e,T.current.direction=r,T.current.dragState=m,T.current.id=d,T.current.onLayout=s,T.current.storage=l}),bCt({committedValuesRef:T,eagerValuesRef:R,groupId:d,layout:g,panelDataArray:R.current.panelDataArray,setLayout:x,panelGroupElement:f.current}),ee.useEffect(()=>{const{panelDataArray:ae}=R.current;if(e){if(g.length===0||g.length!==ae.length)return;let oe=mpe[e];oe==null&&(oe=MCt(TCt,CCt),mpe[e]=oe);const xe=[...ae],Z=new Map(M.current);oe(e,xe,Z,g,l)}},[e,g,l]),ee.useEffect(()=>{});const P=ee.useCallback(ae=>{const{onLayout:oe}=T.current,{layout:xe,panelDataArray:Z}=R.current;if(ae.constraints.collapsible){const ce=Z.map(Ee=>Ee.constraints),{collapsedSize:me=0,panelSize:he,pivotIndices:we}=Zy(Z,ae,xe);if(br(he!=null,`Panel size not found for panel "${ae.id}"`),!Mm(he,me)){M.current.set(ae.id,he);const Se=n_(Z,ae)===Z.length-1?he-me:me-he,Ne=CT({delta:Se,initialLayout:xe,panelConstraints:ce,pivotIndices:we,prevLayout:xe,trigger:"imperative-api"});oI(xe,Ne)||(x(Ne),R.current.layout=Ne,oe&&oe(Ne),Gw(Z,Ne,S.current))}}},[]),I=ee.useCallback((ae,oe)=>{const{onLayout:xe}=T.current,{layout:Z,panelDataArray:ce}=R.current;if(ae.constraints.collapsible){const me=ce.map(Pe=>Pe.constraints),{collapsedSize:he=0,panelSize:we=0,minSize:Ee=0,pivotIndices:Se}=Zy(ce,ae,Z),Ne=oe??Ee;if(Mm(we,he)){const Pe=M.current.get(ae.id),Re=Pe!=null&&Pe>=Ne?Pe:Ne,He=n_(ce,ae)===ce.length-1?we-Re:Re-we,de=CT({delta:He,initialLayout:Z,panelConstraints:me,pivotIndices:Se,prevLayout:Z,trigger:"imperative-api"});oI(Z,de)||(x(de),R.current.layout=de,xe&&xe(de),Gw(ce,de,S.current))}}},[]),L=ee.useCallback(ae=>{const{layout:oe,panelDataArray:xe}=R.current,{panelSize:Z}=Zy(xe,ae,oe);return br(Z!=null,`Panel size not found for panel "${ae.id}"`),Z},[]),z=ee.useCallback((ae,oe)=>{const{panelDataArray:xe}=R.current,Z=n_(xe,ae);return ACt({defaultSize:oe,dragState:m,layout:g,panelData:xe,panelIndex:Z})},[m,g]),U=ee.useCallback(ae=>{const{layout:oe,panelDataArray:xe}=R.current,{collapsedSize:Z=0,collapsible:ce,panelSize:me}=Zy(xe,ae,oe);return br(me!=null,`Panel size not found for panel "${ae.id}"`),ce===!0&&Mm(me,Z)},[]),j=ee.useCallback(ae=>{const{layout:oe,panelDataArray:xe}=R.current,{collapsedSize:Z=0,collapsible:ce,panelSize:me}=Zy(xe,ae,oe);return br(me!=null,`Panel size not found for panel "${ae.id}"`),!ce||gb(me,Z)>0},[]),F=ee.useCallback(ae=>{const{panelDataArray:oe}=R.current;oe.push(ae),oe.sort((xe,Z)=>{const ce=xe.order,me=Z.order;return ce==null&&me==null?0:ce==null?-1:me==null?1:ce-me}),R.current.panelDataArrayChanged=!0,w()},[w]);$x(()=>{if(R.current.panelDataArrayChanged){R.current.panelDataArrayChanged=!1;const{autoSaveId:ae,onLayout:oe,storage:xe}=T.current,{layout:Z,panelDataArray:ce}=R.current;let me=null;if(ae){const we=ECt(ae,ce,xe);we&&(M.current=new Map(Object.entries(we.expandToSizes)),me=we.layout)}me==null&&(me=SCt({panelDataArray:ce}));const he=ppe({layout:me,panelConstraints:ce.map(we=>we.constraints)});dpe(Z,he)||(x(he),R.current.layout=he,oe&&oe(he),Gw(ce,he,S.current))}}),$x(()=>{const ae=R.current;return()=>{ae.layout=[]}},[]);const G=ee.useCallback(ae=>{let oe=!1;const xe=f.current;return xe&&window.getComputedStyle(xe,null).getPropertyValue("direction")==="rtl"&&(oe=!0),function(ce){ce.preventDefault();const me=f.current;if(!me)return()=>null;const{direction:he,dragState:we,id:Ee,keyboardResizeBy:Se,onLayout:Ne}=T.current,{layout:Pe,panelDataArray:Re}=R.current,{initialLayout:ze}=we??{},He=TMe(Ee,ae,me);let de=_Ct(ce,ae,he,we,Se,me);const et=he==="horizontal";et&&oe&&(de=-de);const ut=Re.map(q=>q.constraints),vt=CT({delta:de,initialLayout:ze??Pe,panelConstraints:ut,pivotIndices:He,prevLayout:Pe,trigger:vMe(ce)?"keyboard":"mouse-or-touch"}),fe=!oI(Pe,vt);(yMe(ce)||xMe(ce))&&E.current!=de&&(E.current=de,!fe&&de!==0?et?xG(ae,de<0?wMe:_Me):xG(ae,de<0?SMe:AMe):xG(ae,0)),fe&&(x(vt),R.current.layout=vt,Ne&&Ne(vt),Gw(Re,vt,S.current))}},[]),H=ee.useCallback((ae,oe)=>{const{onLayout:xe}=T.current,{layout:Z,panelDataArray:ce}=R.current,me=ce.map(Pe=>Pe.constraints),{panelSize:he,pivotIndices:we}=Zy(ce,ae,Z);br(he!=null,`Panel size not found for panel "${ae.id}"`);const Se=n_(ce,ae)===ce.length-1?he-oe:oe-he,Ne=CT({delta:Se,initialLayout:Z,panelConstraints:me,pivotIndices:we,prevLayout:Z,trigger:"imperative-api"});oI(Z,Ne)||(x(Ne),R.current.layout=Ne,xe&&xe(Ne),Gw(ce,Ne,S.current))},[]),W=ee.useCallback((ae,oe)=>{const{layout:xe,panelDataArray:Z}=R.current,{collapsedSize:ce=0,collapsible:me}=oe,{collapsedSize:he=0,collapsible:we,maxSize:Ee=100,minSize:Se=0}=ae.constraints,{panelSize:Ne}=Zy(Z,ae,xe);Ne!=null&&(me&&we&&Mm(Ne,ce)?Mm(ce,he)||H(ae,he):Ne<Se?H(ae,Se):Ne>Ee&&H(ae,Ee))},[H]),Q=ee.useCallback((ae,oe)=>{const{direction:xe}=T.current,{layout:Z}=R.current;if(!f.current)return;const ce=nU(ae,f.current);br(ce,`Drag handle element not found for id "${ae}"`);const me=PMe(xe,oe);y({dragHandleId:ae,dragHandleRect:ce.getBoundingClientRect(),initialCursorPosition:me,initialLayout:Z})},[]),ne=ee.useCallback(()=>{y(null)},[]),se=ee.useCallback(ae=>{const{panelDataArray:oe}=R.current,xe=n_(oe,ae);xe>=0&&(oe.splice(xe,1),delete S.current[ae.id],R.current.panelDataArrayChanged=!0,w())},[w]),$=ee.useMemo(()=>({collapsePanel:P,direction:r,dragState:m,expandPanel:I,getPanelSize:L,getPanelStyle:z,groupId:d,isPanelCollapsed:U,isPanelExpanded:j,reevaluatePanelConstraints:W,registerPanel:F,registerResizeHandle:G,resizePanel:H,startDragging:Q,stopDragging:ne,unregisterPanel:se,panelGroupElement:f.current}),[P,m,r,I,L,z,d,U,j,W,F,G,H,Q,ne,se]),J={display:"flex",flexDirection:r==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return ee.createElement(tU.Provider,{value:$},ee.createElement(u,{...h,children:t,className:i,id:a,ref:f,style:{...J,...c},[Ha.group]:"",[Ha.groupDirection]:r,[Ha.groupId]:d}))}const OK=ee.forwardRef((e,t)=>ee.createElement(IMe,{...e,forwardedRef:t}));IMe.displayName="PanelGroup";OK.displayName="forwardRef(PanelGroup)";function n_(e,t){return e.findIndex(i=>i===t||i.id===t.id)}function Zy(e,t,i){const r=n_(e,t),a=r===e.length-1?[r-1,r]:[r,r+1],s=i[r];return{...t.constraints,panelSize:s,pivotIndices:a}}function PCt({disabled:e,handleId:t,resizeHandler:i,panelGroupElement:r}){ee.useEffect(()=>{if(e||i==null||r==null)return;const n=nU(t,r);if(n==null)return;const a=s=>{if(!s.defaultPrevented)switch(s.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{s.preventDefault(),i(s);break}case"F6":{s.preventDefault();const o=n.getAttribute(Ha.groupId);br(o,`No group element found for id "${o}"`);const l=XP(o,r),c=EMe(o,t,r);br(c!==null,`No resize element found for id "${t}"`);const u=s.shiftKey?c>0?c-1:l.length-1:c+1<l.length?c+1:0;l[u].focus();break}}};return n.addEventListener("keydown",a),()=>{n.removeEventListener("keydown",a)}},[r,e,t,i])}function NMe({children:e=null,className:t="",disabled:i=!1,hitAreaMargins:r,id:n,onBlur:a,onClick:s,onDragging:o,onFocus:l,onPointerDown:c,onPointerUp:u,style:h={},tabIndex:d=0,tagName:f="div",...m}){var y,g;const x=ee.useRef(null),w=ee.useRef({onClick:s,onDragging:o,onPointerDown:c,onPointerUp:u});ee.useEffect(()=>{w.current.onClick=s,w.current.onDragging=o,w.current.onPointerDown=c,w.current.onPointerUp=u});const S=ee.useContext(tU);if(S===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:M,groupId:E,registerResizeHandle:T,startDragging:R,stopDragging:P,panelGroupElement:I}=S,L=CK(n),[z,U]=ee.useState("inactive"),[j,F]=ee.useState(!1),[G,H]=ee.useState(null),W=ee.useRef({state:z});$x(()=>{W.current.state=z}),ee.useEffect(()=>{if(i)H(null);else{const $=T(L);H(()=>$)}},[i,L,T]);const Q=(y=r==null?void 0:r.coarse)!==null&&y!==void 0?y:15,ne=(g=r==null?void 0:r.fine)!==null&&g!==void 0?g:5;ee.useEffect(()=>{if(i||G==null)return;const $=x.current;br($,"Element ref not attached");let J=!1;return pCt(L,$,M,{coarse:Q,fine:ne},(oe,xe,Z)=>{if(!xe){U("inactive");return}switch(oe){case"down":{U("drag"),J=!1,br(Z,'Expected event to be defined for "down" action'),R(L,Z);const{onDragging:ce,onPointerDown:me}=w.current;ce==null||ce(!0),me==null||me();break}case"move":{const{state:ce}=W.current;J=!0,ce!=="drag"&&U("hover"),br(Z,'Expected event to be defined for "move" action'),G(Z);break}case"up":{U("hover"),P();const{onClick:ce,onDragging:me,onPointerUp:he}=w.current;me==null||me(!1),he==null||he(),J||ce==null||ce();break}}})},[Q,M,i,ne,T,L,G,R,P]),PCt({disabled:i,handleId:L,resizeHandler:G,panelGroupElement:I});const se={touchAction:"none",userSelect:"none"};return ee.createElement(f,{...m,children:e,className:t,id:n,onBlur:()=>{F(!1),a==null||a()},onFocus:()=>{F(!0),l==null||l()},ref:x,role:"separator",style:{...se,...h},tabIndex:d,[Ha.groupDirection]:M,[Ha.groupId]:E,[Ha.resizeHandle]:"",[Ha.resizeHandleActive]:z==="drag"?"pointer":j?"keyboard":void 0,[Ha.resizeHandleEnabled]:!i,[Ha.resizeHandleId]:L,[Ha.resizeHandleState]:z})}NMe.displayName="PanelResizeHandle";function DCt(e,t){switch(e){case"pixel":return t?"group relative flex items-center justify-center cursor-col-resize":"group relative flex items-center justify-center cursor-row-resize";case"terminal":return t?"group relative flex items-center justify-center cursor-col-resize":"group relative flex items-center justify-center cursor-row-resize";case"modern":default:return t?"group relative flex items-center justify-center cursor-col-resize transition-all duration-200":"group relative flex items-center justify-center cursor-row-resize transition-all duration-200"}}function OCt(e,t){switch(e){case"pixel":return t?{width:"8px",background:"var(--pixel-surface, #222244)",borderLeft:"2px solid var(--pixel-border, #444477)",borderRight:"2px solid var(--pixel-border, #444477)"}:{height:"8px",background:"var(--pixel-surface, #222244)",borderTop:"2px solid var(--pixel-border, #444477)",borderBottom:"2px solid var(--pixel-border, #444477)"};case"terminal":return t?{width:"6px",background:"#0a0a0a",borderLeft:"1px solid #1a3a1a",borderRight:"1px solid #1a3a1a"}:{height:"6px",background:"#0a0a0a",borderTop:"1px solid #1a3a1a",borderBottom:"1px solid #1a3a1a"};case"modern":default:return t?{width:"4px",background:"rgba(100,100,100,0.15)",borderRadius:"2px"}:{height:"4px",background:"rgba(100,100,100,0.15)",borderRadius:"2px"}}}function RCt({theme:e,isHorizontal:t}){switch(e){case"pixel":{const i=t?{flexDirection:"column",gap:"3px"}:{flexDirection:"row",gap:"3px"};return C.jsx("div",{className:"flex",style:i,children:[0,1,2].map(r=>C.jsx("div",{style:{width:"2px",height:"2px",background:"var(--pixel-border-light, #5555aa)"},className:"group-hover:!bg-[var(--pixel-gold)]"},r))})}case"terminal":return t?C.jsxs("div",{className:"flex flex-col items-center gap-0 text-[8px] leading-none group-hover:text-[#00ff00]",style:{color:"#1a3a1a",fontFamily:"monospace"},children:[C.jsx("span",{children:"│"}),C.jsx("span",{children:"│"}),C.jsx("span",{children:"│"})]}):C.jsx("div",{className:"flex items-center gap-0 text-[8px] leading-none group-hover:text-[#00ff00]",style:{color:"#1a3a1a",fontFamily:"monospace"},children:C.jsx("span",{children:"═══"})});case"modern":default:{const i=t?{flexDirection:"column",gap:"2px"}:{flexDirection:"row",gap:"2px"};return C.jsx("div",{className:"flex opacity-0 group-hover:opacity-100 transition-opacity duration-200",style:i,children:[0,1,2].map(r=>C.jsx("div",{className:"rounded-full bg-white/20 group-hover:bg-blue-400/50",style:{width:"3px",height:"3px"}},r))})}}}function LMe({id:e,children:t}){return C.jsx(OK,{direction:"horizontal",autoSaveId:e,className:"flex-1 overflow-hidden",children:t})}function ICt({id:e,children:t}){return C.jsx(OK,{direction:"vertical",autoSaveId:e,className:"flex-1 flex flex-col overflow-hidden",children:t})}function Fv({defaultSize:e,minSize:t,maxSize:i,children:r,className:n,collapsible:a,collapsedSize:s,order:o}){return C.jsx(gMe,{defaultSize:e,minSize:t,maxSize:i,collapsible:a,collapsedSize:s,order:o,className:`overflow-hidden${n?` ${n}`:""}`,children:r})}function mC({direction:e="horizontal",disabled:t,className:i}){const r=Di(a=>a.theme);if(t)return null;const n=e==="horizontal";return C.jsx(NMe,{className:`${DCt(r,n)}${i?` ${i}`:""}`,style:OCt(r,n),children:C.jsx(RCt,{theme:r,isHorizontal:n})})}function RK({AgentDetail:e,ActivityFeed:t,FileWatcher:i,tabBarClass:r="flex border-b border-cam-border/50 bg-cam-surface/50",activeTabClass:n="text-cam-accent border-b-2 border-cam-accent",inactiveTabClass:a="text-cam-text-muted hover:text-cam-text",panelClass:s="flex-1 overflow-y-auto"}){const o=Ni(u=>u.selectedAgentId),[l,c]=ee.useState("activity");return o?C.jsx(e,{}):C.jsxs("div",{className:"h-full flex flex-col",children:[C.jsxs("div",{className:r,children:[C.jsx("button",{onClick:()=>c("activity"),className:`px-3 py-1.5 text-[10px] font-medium uppercase tracking-wider transition-colors ${l==="activity"?n:a}`,children:"Activity"}),C.jsx("button",{onClick:()=>c("files"),className:`px-3 py-1.5 text-[10px] font-medium uppercase tracking-wider transition-colors ${l==="files"?n:a}`,children:"Files"})]}),C.jsx("div",{className:s,children:l==="activity"?C.jsx(t,{}):C.jsx(i,{})})]})}const gpe="cam-in-process-dismissed";function NCt(){const e=Ni(r=>r.agents);return!Ni(r=>r.session)||e.length<2?!1:new Set(e.map(r=>r.sessionId)).size===1}function LCt(e){const[t,i]=ee.useState(()=>{if(!e)return!1;try{return localStorage.getItem(gpe)===e}catch{return!1}}),r=ee.useCallback(()=>{if(e)try{localStorage.setItem(gpe,e)}catch{}i(!0)},[e]);return[t,r]}function IK(){const e=NCt(),t=Ni(a=>a.session),[i,r]=LCt(t==null?void 0:t.id),{theme:n}=$P();if(!e||i)return null;switch(n){case"pixel":return C.jsx(zCt,{onDismiss:r});case"terminal":return C.jsx(BCt,{onDismiss:r});default:return C.jsx(kCt,{onDismiss:r})}}function kCt({onDismiss:e}){return C.jsxs("div",{className:"h-8 flex items-center justify-between px-4 bg-amber-500/10 border-b border-amber-500/30 shrink-0",children:[C.jsxs("div",{className:"flex items-center gap-2",children:[C.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 animate-pulse"}),C.jsx("span",{className:"text-xs text-amber-300",children:"In-process mode detected — per-agent tracking is limited. Use tmux + Teams for full E2E tracking."})]}),C.jsx("button",{onClick:e,className:"text-amber-400/60 hover:text-amber-300 text-xs px-1",title:"Dismiss",children:"×"})]})}function zCt({onDismiss:e}){return C.jsxs("div",{className:"h-8 flex items-center justify-between px-4 shrink-0",style:{background:"rgba(255, 170, 0, 0.1)",borderBottom:"2px solid var(--pixel-gold, #d4a017)"},children:[C.jsx("div",{className:"flex items-center gap-2",children:C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-gold, #d4a017)"},children:"! IN-PROCESS MODE - PER-AGENT TRACKING LIMITED. USE TMUX + TEAMS FOR FULL TRACKING."})}),C.jsx("button",{onClick:e,className:"pixel-text-xs px-1",style:{color:"var(--pixel-gold, #d4a017)",opacity:.6},title:"Dismiss",children:"X"})]})}function BCt({onDismiss:e}){return C.jsxs("div",{className:"h-8 flex items-center justify-between px-3 bg-[#1a1a00] border-b border-[#3a3a1a] shrink-0 font-mono text-[11px]",children:[C.jsx("div",{className:"flex items-center gap-2",children:C.jsx("span",{className:"text-[#ffaa00]",children:"[WARN] in-process mode: per-agent tracking limited. use tmux + teams for full e2e tracking."})}),C.jsx("button",{onClick:e,className:"text-[#ffaa00]/60 hover:text-[#ffaa00] px-1",title:"Dismiss",children:"[x]"})]})}function UCt(){const{connectionStatus:e,session:t}=Ni();if(t&&t.status!=="active"){const r=t.status==="error";return C.jsxs("div",{className:"flex items-center gap-1.5",children:[C.jsx("div",{className:`w-2 h-2 rounded-full ${r?"bg-cam-error":"bg-gray-400"}`}),C.jsx("span",{className:`text-xs ${r?"text-cam-error":"text-cam-text-muted"}`,children:r?"Session error":"Session ended"})]})}const i={connected:{dotClass:"bg-cam-success animate-pulse-dot",textClass:"text-cam-success",label:"Connected",sublabel:"capturing events"},reconnecting:{dotClass:"bg-amber-400 animate-pulse",textClass:"text-amber-400",label:"Reconnecting...",sublabel:""},disconnected:{dotClass:"bg-cam-error",textClass:"text-cam-error",label:"Disconnected",sublabel:"waiting for server"}}[e];return C.jsxs("div",{className:"flex items-center gap-1.5",children:[C.jsx("div",{className:`w-2 h-2 rounded-full ${i.dotClass}`}),C.jsx("span",{className:`text-xs ${i.textClass}`,children:i.label}),i.sublabel&&C.jsxs("span",{className:"text-xs text-cam-text-muted",children:["- ",i.sublabel]})]})}function jCt(){const{viewMode:e}=_n();return C.jsxs("div",{className:"h-full w-full flex flex-col modern-gradient-bg overflow-hidden",children:[C.jsxs("header",{className:"h-12 flex items-center justify-between px-4 border-b border-cam-border/50 modern-glass shrink-0 relative z-50",children:[C.jsxs("div",{className:"flex items-center gap-3",children:[C.jsx("h1",{className:"text-sm font-semibold text-cam-text tracking-tight",children:"Claude Agent Monitor"}),C.jsx(UCt,{})]}),C.jsxs("div",{className:"flex items-center gap-3",children:[C.jsx(RX,{}),C.jsx(RHe,{})]})]}),C.jsx(VEe,{}),C.jsx(IK,{}),C.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[e==="agents"&&C.jsx(FCt,{}),e==="tracker"&&C.jsx(VCt,{})]})]})}function FCt(){const e=Di(t=>t.lockPanels);return C.jsxs(LMe,{id:"modern-agents",children:[C.jsx(Fv,{defaultSize:20,minSize:10,maxSize:25,order:1,children:C.jsx("aside",{className:"h-full overflow-y-auto modern-scrollbar",children:C.jsx(nTe,{})})}),C.jsx(mC,{disabled:e}),C.jsx(Fv,{defaultSize:55,minSize:30,order:2,children:C.jsx("main",{className:"h-full overflow-hidden",children:C.jsx(MK,{})})}),C.jsx(mC,{disabled:e}),C.jsx(Fv,{defaultSize:25,minSize:15,maxSize:40,order:3,children:C.jsx("aside",{className:"h-full modern-scrollbar",children:C.jsx(RK,{AgentDetail:k3e,ActivityFeed:I3e,FileWatcher:B3e})})})]})}function VCt(){const{selectedTaskId:e}=_n(),t=Di(i=>i.lockPanels);return C.jsxs(ICt,{id:"modern-tracker",children:[C.jsx(Fv,{defaultSize:75,minSize:50,order:1,children:C.jsxs(LMe,{id:e?"modern-tracker-top-detail":"modern-tracker-top",children:[C.jsx(Fv,{defaultSize:e?55:70,minSize:30,order:1,children:C.jsx("main",{className:"h-full overflow-hidden",children:C.jsx(F3e,{})})}),e&&C.jsxs(C.Fragment,{children:[C.jsx(mC,{disabled:t}),C.jsx(Fv,{defaultSize:20,minSize:15,maxSize:35,order:2,children:C.jsx("aside",{className:"h-full overflow-y-auto modern-scrollbar",children:C.jsx(EK,{})})})]}),C.jsx(mC,{disabled:t}),C.jsx(Fv,{defaultSize:e?25:30,minSize:15,maxSize:40,order:3,children:C.jsxs("aside",{className:"h-full overflow-y-auto modern-scrollbar flex flex-col",children:[C.jsx(H3e,{}),C.jsx(AHe,{}),C.jsx(OHe,{})]})})]})}),C.jsx(mC,{direction:"vertical",disabled:t}),C.jsx(Fv,{defaultSize:25,minSize:10,maxSize:40,order:2,children:C.jsx("div",{className:"h-full overflow-y-auto modern-scrollbar",children:C.jsx(MHe,{})})})]})}function HCt(){const{session:e,agents:t,events:i}=Ni(),[r,n]=ee.useState("00m 00s");ee.useEffect(()=>{if(!(e!=null&&e.startedAt))return;const u=()=>n(H7(e.startedAt,e.endedAt));if(u(),!e.endedAt){const h=setInterval(u,1e3);return()=>clearInterval(h)}},[e==null?void 0:e.startedAt,e==null?void 0:e.endedAt]);const a=t.filter(u=>u.status==="active").length,s=t.reduce((u,h)=>u+h.errorCount,0),o=t.reduce((u,h)=>u+h.toolCallCount,0),l=i.filter(u=>u.category==="file_change").length,c=[{label:"TIME",value:r,isError:!1},{label:"AGENTS",value:`${a}/${t.length}`,isError:!1},{label:"CALLS",value:Lm(o),isError:!1},{label:"EVENTS",value:Lm((e==null?void 0:e.eventCount)??0),isError:!1},{label:"FILES",value:Lm(l),isError:!1},{label:"ERRORS",value:String(s),isError:s>0}];return C.jsx("div",{className:"shrink-0 border-b border-[#1a3a1a] px-2 py-1 font-mono text-[11px]",children:C.jsxs("div",{className:"flex items-center gap-0",children:[C.jsx("span",{className:"terminal-dim mr-2",children:"["}),c.map((u,h)=>C.jsxs("span",{className:"flex items-center",children:[h>0&&C.jsx("span",{className:"terminal-dim mx-1",children:"|"}),C.jsxs("span",{className:"terminal-muted",children:[u.label,":"]}),C.jsx("span",{className:`ml-1 font-bold ${u.isError?"terminal-error":"text-[#00ff00] terminal-glow"}`,children:u.value})]},u.label)),C.jsx("span",{className:"terminal-dim ml-2",children:"]"})]})})}const GCt={active:"[*]",idle:"[-]",error:"[!]",completed:"[+]",shutdown:"[x]"},WCt={active:"text-[#00ff00]",idle:"text-[#ffaa00]",error:"text-[#ff3333]",completed:"text-[#00ccff]",shutdown:"text-[#006600]"};function qCt(e){return e.status==="active"}function XCt(){const e=$7(),{selectedAgentId:t,selectAgent:i}=Ni(),[r,n]=ee.useState(!1),{activeAgents:a,inactiveAgents:s}=ee.useMemo(()=>{const o=[],l=[];for(const c of e)qCt(c)?o.push(c):l.push(c);return{activeAgents:o,inactiveAgents:l}},[e]);return e.length===0?C.jsxs("div",{className:"p-3 font-mono text-[11px]",children:[C.jsx("div",{className:"terminal-muted mb-2",children:"## AGENTS ##"}),C.jsxs("div",{className:"terminal-dim",children:[C.jsx("p",{children:"> Waiting for agents..."}),C.jsx("p",{className:"mt-1 terminal-cursor",children:"> "})]})]}):C.jsxs("div",{className:"p-2 font-mono text-[11px]",children:[C.jsx("div",{className:"terminal-muted mb-1 px-1",children:"## ACTIVE ("+a.length+") ##"}),C.jsx("div",{className:"border-t border-[#1a3a1a] mb-1"}),a.length>0?C.jsx("div",{className:"space-y-0.5",children:a.map(o=>C.jsx(vpe,{agent:o,isSelected:t===o.id,onSelect:()=>i(t===o.id?null:o.id)},o.id))}):C.jsx("div",{className:"px-1 py-1 terminal-dim",children:"> No active agents"}),s.length>0&&C.jsxs("div",{className:"mt-2",children:[C.jsxs("button",{onClick:()=>n(!r),className:"w-full text-left px-1 py-0.5 hover:bg-[#0a1a0a] transition-colors",children:[C.jsxs("span",{className:"terminal-dim",children:[r?"[-]":"[+]"," "]}),C.jsx("span",{className:"terminal-muted",children:"INACTIVE ("+s.length+")"})]}),r&&C.jsxs(C.Fragment,{children:[C.jsx("div",{className:"border-t border-[#1a3a1a] mb-1 mt-1"}),C.jsx("div",{className:"space-y-0.5",children:s.map(o=>C.jsx(vpe,{agent:o,isSelected:t===o.id,onSelect:()=>i(t===o.id?null:o.id),compact:!0},o.id))})]})]})]})}function vpe({agent:e,isSelected:t,onSelect:i,compact:r=!1}){const n=Ch(e.id,e.name,e.type??void 0),a=GCt[e.status]||"[ ]",s=WCt[e.status]||"terminal-dim";return r?C.jsx("button",{onClick:i,title:`${e.name} (${e.id})`,className:`
|
|
12435
|
+
`})}get time(){return this.uniforms.time.value}set time(t){this.uniforms.time.value=t}get pixelRatio(){return this.uniforms.pixelRatio.value}set pixelRatio(t){this.uniforms.pixelRatio.value=t}}const uMe=e=>e&&e.constructor===Float32Array,ETt=e=>[e.r,e.g,e.b],hMe=e=>e instanceof Dt||e instanceof Me||e instanceof zn,dMe=e=>Array.isArray(e)?e:hMe(e)?e.toArray():[e,e,e];function sT(e,t,i){return ee.useMemo(()=>{if(t!==void 0){if(uMe(t))return t;if(t instanceof Jt){const r=Array.from({length:e*3},()=>ETt(t)).flat();return Float32Array.from(r)}else if(hMe(t)||Array.isArray(t)){const r=Array.from({length:e*3},()=>dMe(t)).flat();return Float32Array.from(r)}return Float32Array.from({length:e},()=>t)}return Float32Array.from({length:e},i)},[t])}const fMe=ee.forwardRef(({noise:e=1,count:t=100,speed:i=1,opacity:r=1,scale:n=1,size:a,color:s,children:o,...l},c)=>{ee.useMemo(()=>rMe({SparklesImplMaterial:MTt}),[]);const u=ee.useRef(null),h=mx(S=>S.viewport.dpr),d=dMe(n),f=ee.useMemo(()=>Float32Array.from(Array.from({length:t},()=>d.map(G$.randFloatSpread)).flat()),[t,...d]),m=sT(t,a,Math.random),y=sT(t,r),g=sT(t,i),x=sT(t*3,e),w=sT(s===void 0?t*3:t,uMe(s)?s:new Jt(s),()=>1);return Jc(S=>{u.current&&u.current.material&&(u.current.material.time=S.clock.elapsedTime)}),ee.useImperativeHandle(c,()=>u.current,[]),ee.createElement("points",SN({key:`particle-${t}-${JSON.stringify(n)}`},l,{ref:u}),ee.createElement("bufferGeometry",null,ee.createElement("bufferAttribute",{attach:"attributes-position",args:[f,3]}),ee.createElement("bufferAttribute",{attach:"attributes-size",args:[m,1]}),ee.createElement("bufferAttribute",{attach:"attributes-opacity",args:[y,1]}),ee.createElement("bufferAttribute",{attach:"attributes-speed",args:[g,1]}),ee.createElement("bufferAttribute",{attach:"attributes-color",args:[w,3]}),ee.createElement("bufferAttribute",{attach:"attributes-noise",args:[x,3]})),o||ee.createElement("sparklesImplMaterial",{transparent:!0,pixelRatio:h,depthWrite:!1}))});function TTt({pixelated:e}){const t=mx(s=>s.gl),i=mx(s=>s.internal.active),r=mx(s=>s.performance.current),n=mx(s=>s.viewport.initialDpr),a=mx(s=>s.setDpr);return ee.useEffect(()=>{const s=t.domElement;return()=>{i&&a(n),e&&s&&(s.style.imageRendering="auto")}},[]),ee.useEffect(()=>{a(r*n),e&&t.domElement&&(t.domElement.style.imageRendering=r===1?"auto":"pixelated")},[r]),null}function CTt({position:e}){const t=ee.useRef(null),i=ee.useRef(null);return Jc(({clock:r})=>{const n=r.getElapsedTime();if(i.current&&(i.current.rotation.y=Math.sin(n*1.2)*.12),t.current){const a=t.current.material;a.emissiveIntensity=.6+Math.sin(n*3)*.3}}),C.jsx("group",{position:e,children:C.jsx(V0,{speed:1.5,rotationIntensity:.1,floatIntensity:.5,children:C.jsxs("group",{ref:i,children:[C.jsxs("mesh",{children:[C.jsx("boxGeometry",{args:[30,20,2]}),C.jsx("meshStandardMaterial",{color:"#111122",metalness:.5,roughness:.3})]}),C.jsxs("mesh",{ref:t,position:[0,0,1.2],children:[C.jsx("boxGeometry",{args:[26,16,.5]}),C.jsx("meshStandardMaterial",{color:"#22d3ee",emissive:"#22d3ee",emissiveIntensity:.6,transparent:!0,opacity:.85})]})]})})})}function PTt({position:e}){const t=ee.useRef(null),i=ee.useRef(null);Jc(({clock:n})=>{const a=n.getElapsedTime();t.current&&(t.current.rotation.y=.3+Math.sin(a*1.5)*.05),i.current&&(i.current.rotation.y=-.3-Math.sin(a*1.5)*.05)});const r=C.jsx("meshStandardMaterial",{color:"#c4b5fd",emissive:"#8b5cf6",emissiveIntensity:.5});return C.jsx("group",{position:e,children:C.jsxs(V0,{speed:1.5,rotationIntensity:.1,floatIntensity:.5,children:[C.jsx("group",{ref:t,position:[-7,0,0],children:C.jsxs("mesh",{children:[C.jsx("boxGeometry",{args:[12,16,1]}),r]})}),C.jsx("group",{ref:i,position:[7,0,0],children:C.jsxs("mesh",{children:[C.jsx("boxGeometry",{args:[12,16,1]}),r]})}),C.jsxs("mesh",{children:[C.jsx("boxGeometry",{args:[2,16,2]}),C.jsx("meshStandardMaterial",{color:"#1e1b2e"})]})]})})}function DTt({position:e}){const t=ee.useRef(null);Jc(({clock:r})=>{const n=r.getElapsedTime();t.current&&(t.current.visible=Math.sin(n*4)>0,t.current.position.x=-8+n*6%16)});const i=C.jsx("meshStandardMaterial",{color:"#22c55e",emissive:"#22c55e",emissiveIntensity:.6});return C.jsx("group",{position:e,children:C.jsxs(V0,{speed:1.5,rotationIntensity:.1,floatIntensity:.5,children:[C.jsxs("mesh",{children:[C.jsx("boxGeometry",{args:[28,18,2]}),C.jsx("meshStandardMaterial",{color:"#0a0a14"})]}),C.jsxs("mesh",{position:[-11,4,1.2],children:[C.jsx("boxGeometry",{args:[2,2,.5]}),i]}),C.jsxs("mesh",{position:[-2,4,1.2],children:[C.jsx("boxGeometry",{args:[14,1.2,.3]}),i]}),C.jsxs("mesh",{position:[-4,0,1.2],children:[C.jsx("boxGeometry",{args:[10,1.2,.3]}),i]}),C.jsxs("mesh",{ref:t,position:[-8,-4,1.2],children:[C.jsx("boxGeometry",{args:[2,3,.5]}),i]})]})})}function OTt({position:e}){const t=ee.useRef(null);Jc(({clock:r})=>{const n=r.getElapsedTime();t.current&&(t.current.rotation.z=Math.sin(n*1.2)*.4)});const i=C.jsx("meshStandardMaterial",{color:"#3b82f6",emissive:"#3b82f6",emissiveIntensity:.5});return C.jsx("group",{position:e,children:C.jsx(V0,{speed:1.5,rotationIntensity:.1,floatIntensity:.5,children:C.jsxs("group",{ref:t,children:[C.jsxs("mesh",{children:[C.jsx("torusGeometry",{args:[9,2.5,16,32]}),i]}),C.jsxs("mesh",{position:[0,0,0],children:[C.jsx("circleGeometry",{args:[6.5,32]}),C.jsx("meshStandardMaterial",{color:"#3b82f6",emissive:"#3b82f6",emissiveIntensity:.2,transparent:!0,opacity:.3})]}),C.jsxs("mesh",{rotation:[0,0,-Math.PI/4],position:[8,-8,0],children:[C.jsx("cylinderGeometry",{args:[2,1.5,14,8]}),i]})]})})})}function RTt({position:e}){const t=ee.useRef(null),i=ee.useRef(null),r=ee.useRef(null);Jc(({clock:a})=>{const s=a.getElapsedTime();[t,i,r].forEach((l,c)=>{if(l.current){const u=s*3-c*.4,h=Math.max(0,Math.sin(u)),d=Math.pow(2,-5*h)*Math.sin(h*Math.PI*2)+h;l.current.position.y=d*5}})});const n=C.jsx("meshStandardMaterial",{color:"#a855f7",emissive:"#a855f7",emissiveIntensity:.6});return C.jsx("group",{position:e,children:C.jsxs(V0,{speed:1.5,rotationIntensity:.1,floatIntensity:.5,children:[C.jsxs("mesh",{position:[0,-2,-1],children:[C.jsx("boxGeometry",{args:[36,14,1]}),C.jsx("meshStandardMaterial",{color:"#1a0a2e",transparent:!0,opacity:.5})]}),C.jsxs("mesh",{ref:t,position:[-10,0,0],children:[C.jsx("sphereGeometry",{args:[3,16,16]}),n]}),C.jsxs("mesh",{ref:i,position:[0,0,0],children:[C.jsx("sphereGeometry",{args:[3,16,16]}),n]}),C.jsxs("mesh",{ref:r,position:[10,0,0],children:[C.jsx("sphereGeometry",{args:[3,16,16]}),n]})]})})}function ITt({position:e}){const t=ee.useRef(null);Jc(({clock:r})=>{t.current&&(t.current.rotation.z=r.getElapsedTime()*.8)});const i=C.jsx("meshStandardMaterial",{color:"#f97316",emissive:"#f97316",emissiveIntensity:.5});return C.jsx("group",{position:e,children:C.jsxs(V0,{speed:1.5,rotationIntensity:.1,floatIntensity:.5,children:[C.jsxs("mesh",{ref:t,children:[C.jsx("torusGeometry",{args:[10,3,6,8]}),i]}),C.jsxs("mesh",{children:[C.jsx("circleGeometry",{args:[5,32]}),i]})]})})}function NTt({position:e}){const t=ee.useRef(null);return Jc(({clock:i})=>{const r=i.getElapsedTime();if(t.current){t.current.rotation.y=r*.6,t.current.rotation.x=Math.sin(r*.8)*.3;const n=t.current.material;n.emissiveIntensity=.5+Math.sin(r*2)*.4}}),C.jsx("group",{position:e,children:C.jsxs(V0,{speed:1.5,rotationIntensity:.1,floatIntensity:.5,children:[C.jsxs("mesh",{ref:t,children:[C.jsx("octahedronGeometry",{args:[12,0]}),C.jsx("meshStandardMaterial",{color:"#fbbf24",emissive:"#fbbf24",emissiveIntensity:.5,metalness:.4,roughness:.2})]}),C.jsx(fMe,{count:30,size:3,speed:.5,color:"#fbbf24",scale:30})]})})}function LTt({position:e}){const t=ee.useRef(null);Jc(({clock:r})=>{const n=r.getElapsedTime();if(t.current){const a=1+Math.sin(n*3)*.1;t.current.scale.set(a,a,a)}});const i=C.jsx("meshStandardMaterial",{color:"#ef4444",emissive:"#ef4444",emissiveIntensity:.6});return C.jsx("group",{position:e,children:C.jsx(V0,{speed:1.5,rotationIntensity:.1,floatIntensity:.5,children:C.jsxs("group",{ref:t,children:[C.jsxs("mesh",{rotation:[0,0,Math.PI/4],children:[C.jsx("boxGeometry",{args:[4,24,3]}),i]}),C.jsxs("mesh",{rotation:[0,0,-Math.PI/4],children:[C.jsx("boxGeometry",{args:[4,24,3]}),i]})]})})})}function npe(e){const t=1-e;return 1-t*t*t}function ape(e){return e*e*e}const kTt=2,sI=.3,Hw=.7;function zTt({position:e,color:t,onComplete:i}){const r=ee.useRef(null),n=ee.useRef(null),a=ee.useRef(null),s=ee.useRef(null),[o,l]=ee.useState(!1),c=t??"#8b5cf6";return Jc(({clock:u})=>{if(o)return;const h=u.getElapsedTime();s.current===null&&(s.current=h);const d=h-s.current,f=Math.min(d/kTt,1);if(f>=1){l(!0),i==null||i();return}const m=r.current;if(!m)return;let y;if(f<sI){const S=f/sI;y=npe(S)}else if(f<Hw)y=1;else{const S=(f-Hw)/(1-Hw);y=1-ape(S)}m.scale.setScalar(Math.max(y,.001));const g=n.current;g&&(g.rotation.y+=.05,g.rotation.x=Math.sin(d*2)*.3);let x;if(f<sI)x=npe(f/sI)*.8;else if(f<Hw)x=.8;else{const S=(f-Hw)/(1-Hw);x=.8*(1-ape(S))}if(g){const S=g.material;S.opacity=x}const w=a.current;w&&(w.intensity=y*2)}),o?null:C.jsxs("group",{ref:r,position:e,children:[C.jsx(ATt,{ref:n,args:[15,25,32],children:C.jsx("meshStandardMaterial",{color:c,emissive:c,emissiveIntensity:1.5,transparent:!0,opacity:.8,side:2,depthWrite:!1})}),C.jsx(fMe,{count:40,size:3,speed:.5,color:c,scale:[50,50,10]}),C.jsx("pointLight",{ref:a,color:c,intensity:2,distance:100,decay:2})]})}const fm=[0,0,0];function BTt({pose:e}){switch(e){case"coding":return C.jsx(CTt,{position:fm});case"reading":return C.jsx(PTt,{position:fm});case"terminal":return C.jsx(DTt,{position:fm});case"searching":return C.jsx(OTt,{position:fm});case"talking":return C.jsx(RTt,{position:fm});case"managing":return C.jsx(ITt,{position:fm});case"celebrating":return C.jsx(NTt,{position:fm});case"idle":return null;default:return C.jsx(LTt,{position:fm})}}function UTt({agentId:e,pose:t,positionsRef:i,zoom:r}){const n=ee.useRef(null);return Jc(()=>{var c;const a=n.current,s=(c=i.current)==null?void 0:c.get(e);if(!a)return;if(!s){a.visible=!1;return}a.visible=!0,a.position.x+=(s.x-a.position.x)*.15,a.position.y+=(s.y-a.position.y)*.15,a.position.z=0;const l=r*1.8-a.scale.x;if(Math.abs(l)>.001){const u=a.scale.x+l*.2;a.scale.set(u,u,u)}}),C.jsx("group",{ref:n,visible:!1,children:C.jsx(BTt,{pose:t})})}function jTt({agentId:e,positionsRef:t,color:i,onComplete:r}){const n=ee.useRef(null);return Jc(()=>{var o;const a=n.current,s=(o=t.current)==null?void 0:o.get(e);!a||!s||(a.position.x=s.x,a.position.y=s.y,a.position.z=0,a.visible=!0)}),C.jsx("group",{ref:n,visible:!1,children:C.jsx(zTt,{position:fm,color:i,onComplete:r})})}function FTt({containerRef:e,agents:t,zoom:i,spawningAgentIds:r}){const{camera:n,size:a}=mx(),s=ee.useRef(new Map),o=ee.useRef(new Map),l=ee.useRef(0);ee.useEffect(()=>{const u=n;u.left=-a.width/2,u.right=a.width/2,u.top=a.height/2,u.bottom=-a.height/2,u.updateProjectionMatrix()},[n,a]),Jc(()=>{const u=e.current;if(!u||!u.isConnected)return;l.current++;const h=l.current;if(h%30===0||o.current.size===0){o.current.clear();const d=u.querySelectorAll("[data-agent-id]");for(const f of d){const m=f.dataset.agentId;m&&o.current.set(m,f)}}if(h%2===0){const d=u.getBoundingClientRect(),f=d.width/2,m=d.height/2;for(const y of t){if(y.pose==="idle")continue;let g=o.current.get(y.agentId);if(!g||!g.isConnected){const T=u.querySelector(`[data-agent-id="${y.agentId}"]`);if(T)g=T,o.current.set(y.agentId,T);else continue}const x=g.getBoundingClientRect(),w=x.left-d.left+x.width/2,S=x.top-d.top,M=w-f,E=m-S+30*i;s.current.set(y.agentId,{x:M,y:E})}}});const c=ee.useMemo(()=>t.filter(u=>u.pose!=="idle"),[t]);return C.jsxs(C.Fragment,{children:[C.jsx("ambientLight",{intensity:.6}),C.jsx("directionalLight",{position:[100,200,300],intensity:.8}),C.jsx(TTt,{pixelated:!0}),c.map(u=>C.jsx(UTt,{agentId:u.agentId,pose:u.pose,positionsRef:s,zoom:i},u.agentId)),c.filter(u=>r.has(u.agentId)).map(u=>C.jsx(jTt,{agentId:u.agentId,positionsRef:s},`spawn-${u.agentId}`))]})}function VTt({containerRef:e,agents:t,zoom:i,spawningAgentIds:r}){return ee.useMemo(()=>t.some(a=>a.pose!=="idle")||r.size>0,[t,r])?C.jsx(bTt,{orthographic:!0,camera:{position:[0,0,500],zoom:1},gl:{alpha:!0,antialias:!1,powerPreference:"high-performance"},style:{pointerEvents:"none",position:"absolute",inset:"0",zIndex:15},frameloop:"always",children:C.jsx(FTt,{containerRef:e,agents:t,zoom:i,spawningAgentIds:r})}):null}const HTt=new Set(["working","moving","talking","error"]),GTt=new Set(["idle","shutdown","completed"]),WTt=new Set(["coding","reading","terminal","talking","searching","managing"]);function qTt(e){return HTt.has(e.animationState)?!0:GTt.has(e.animationState)?!1:WTt.has(e.pose)}function XTt({positions:e,agentMeta:t}){return ee.useMemo(()=>{const i=[],r=[],n=[],a=[];for(const m of e.values())qTt(m)?n.push(m):a.push(m);const s=new Set(n.map(m=>m.agentId)),o=new Map,l=[];for(const m of n){const y=m.parentAgentId;if(!y||!s.has(y))l.push(m);else{const g=o.get(y)??[];g.push(m),o.set(y,g)}}const u=n.length<=1,h=l.length,f=-((h-1)*fH)/2;for(let m=0;m<h;m++){const y=l[m],g=t.get(y.agentId),x=h===1?0:f+m*fH;i.push({agentId:y.agentId,position:[x,0,0],modelType:"main",color:(g==null?void 0:g.color)??"#8b5cf6",name:(g==null?void 0:g.name)??y.agentId,type:(g==null?void 0:g.type)??"general-purpose",pose:y.pose,animationState:y.animationState,activityLabel:y.activityLabel,lastTool:y.lastTool,parentAgentId:y.parentAgentId});const w=o.get(y.agentId)??[],S=fH*.8,M=(w.length-1)*S,E=x-M/2;for(let T=0;T<w.length;T++){const R=w[T],P=t.get(R.agentId),I=w.length===1?x:E+T*S;i.push({agentId:R.agentId,position:[I,0,3],modelType:u?"main":"sub",color:(P==null?void 0:P.color)??"#8b5cf6",name:(P==null?void 0:P.name)??R.agentId,type:(P==null?void 0:P.type)??"general-purpose",pose:R.pose,animationState:R.animationState,activityLabel:R.activityLabel,lastTool:R.lastTool,parentAgentId:R.parentAgentId})}}for(const m of a){const y=t.get(m.agentId);r.push({agentId:m.agentId,position:[0,0,0],modelType:m.parentAgentId?"sub":"main",color:(y==null?void 0:y.color)??"#8b5cf6",name:(y==null?void 0:y.name)??m.agentId,type:(y==null?void 0:y.type)??"general-purpose",pose:m.pose,animationState:m.animationState,activityLabel:m.activityLabel,lastTool:m.lastTool,parentAgentId:m.parentAgentId})}return{active:i,inactive:r}},[e,t])}const spe={zoom:1,panX:0,panY:0};function YTt(e){const[t,i]=ee.useState(spe),[r,n]=ee.useState(!1),a=ee.useRef(t);a.current=t;const s=ee.useRef(!1),o=ee.useRef({x:0,y:0,panX:0,panY:0});ee.useEffect(()=>{const h=e.current;if(!h)return;function d(f){if(Math.abs(f.deltaX)>Math.abs(f.deltaY))return;f.preventDefault(),f.stopPropagation();const m=h.getBoundingClientRect(),y=f.clientX-m.left,g=f.clientY-m.top;i(x=>{const w=1-f.deltaY*.001,S=Math.round(Math.min(cyt,Math.max(lyt,x.zoom*w))*100)/100;if(S===x.zoom)return x;const M=S/x.zoom,E=y-M*(y-x.panX),T=g-M*(g-x.panY);return{zoom:S,panX:E,panY:T}})}return h.addEventListener("wheel",d,{passive:!1,capture:!0}),()=>h.removeEventListener("wheel",d,{capture:!0})},[e]);const l=ee.useCallback(h=>{const d=h.target.closest("[data-agent-id]");if(h.button===0&&d||h.button!==0&&h.button!==1)return;s.current=!0,n(!0);const f=a.current;o.current={x:h.clientX,y:h.clientY,panX:f.panX,panY:f.panY},h.preventDefault()},[]);ee.useEffect(()=>{function h(f){if(!s.current)return;const m=f.clientX-o.current.x,y=f.clientY-o.current.y;i({zoom:a.current.zoom,panX:o.current.panX+m,panY:o.current.panY+y})}function d(){s.current&&(s.current=!1,n(!1))}return window.addEventListener("mousemove",h),window.addEventListener("mouseup",d),()=>{window.removeEventListener("mousemove",h),window.removeEventListener("mouseup",d)}},[]);const c=ee.useCallback(()=>{i(spe)},[]),u=`translate(${t.panX}px, ${t.panY}px) scale(${t.zoom})`;return{zoom:t.zoom,panX:t.panX,panY:t.panY,isPanning:r,transformStyle:u,handleMouseDown:l,reset:c}}const F7=160,pMe=2,ope=F7*pMe,$Tt={default:{accent:"#8b5cf6",text:"text-violet-400"},warning:{accent:"#f59e0b",text:"text-amber-400"},error:{accent:"#ef4444",text:"text-red-400"},success:{accent:"#22c55e",text:"text-emerald-400"},pulse:{accent:"#10b981",text:"text-emerald-400"}};function KTt({title:e,subtitle:t,variant:i="default",children:r}){const[n,a]=ee.useState(!0),s=ee.useRef(null),o=$Tt[i],l=ee.useCallback(c=>{var h,d;const u=c;try{const f=(h=u._renderer)==null?void 0:h.pipeline;f!=null&&f.logoOverlayPass&&(f.logoOverlayPass.enabled=!1),f==null||f.setWatermark(null)}catch{}try{(d=u.play)==null||d.call(u)}catch{}a(!1)},[]);return ee.useEffect(()=>{if(n)return;const c=s.current;if(!c)return;const u=c.querySelector("canvas");if(!u)return;let h=!1;function d(){h=!0}function f(){h=!1}function m(y){h||u.dispatchEvent(new PointerEvent("pointermove",{clientX:y.clientX,clientY:y.clientY,pointerId:1,pointerType:"mouse",bubbles:!1}))}return u.addEventListener("pointerenter",d),u.addEventListener("pointerleave",f),window.addEventListener("pointermove",m),()=>{u.removeEventListener("pointerenter",d),u.removeEventListener("pointerleave",f),window.removeEventListener("pointermove",m)}},[n]),C.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-5 px-6",children:[C.jsxs("div",{ref:s,className:"relative overflow-hidden shrink-0",style:{width:F7,height:F7},children:[n&&C.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-10",children:C.jsx("div",{className:"w-8 h-8 border-2 rounded-full animate-spin",style:{borderColor:`${o.accent}30`,borderTopColor:"transparent"}})}),C.jsx("div",{style:{width:ope,height:ope,transform:`scale(${1/pMe})`,transformOrigin:"top left"},children:C.jsx($_e,{scene:K_e.main,onLoad:l,style:{width:"100%",height:"100%",opacity:n?0:1,transition:"opacity 0.5s ease-in"}})}),!n&&C.jsx("div",{className:"absolute inset-[-6px] rounded-2xl pointer-events-none transition-all duration-700",style:{boxShadow:`0 0 20px ${o.accent}25, 0 0 40px ${o.accent}10`}})]}),C.jsxs("div",{className:"flex flex-col items-center gap-2 max-w-sm text-center",children:[C.jsx("h3",{className:`${o.text} text-sm font-mono font-semibold`,children:e}),t&&C.jsx("p",{className:"text-zinc-500 text-xs font-mono leading-relaxed",children:t}),r]})]})}function pG({n:e,children:t}){return C.jsxs("div",{className:"flex items-start gap-2.5",children:[C.jsx("span",{className:"shrink-0 w-5 h-5 rounded-full flex items-center justify-center text-[10px] font-mono font-bold bg-violet-500/15 text-violet-400",children:e}),C.jsx("span",{className:"text-zinc-400 text-xs font-mono pt-0.5 leading-relaxed",children:t})]})}function MK(){Dye();const e=ee.useRef(null),t=Ni(Z=>Z.session),i=Ni(Z=>Z.agents),r=Ni(Z=>Z.selectedAgentId),n=Ni(Z=>Z.selectAgent),{positions:a,speechBubbles:s,interactionLines:o,showLabels:l,showInteractions:c}=C_(),{zoom:u,transformStyle:h,isPanning:d,handleMouseDown:f,reset:m}=YTt(e),[y,g]=ee.useState(null),[x,w]=ee.useState(new Map),S=ee.useRef({agentId:null,mouseX:0,mouseY:0,agentX:0,agentY:0}),M=ee.useRef(u);M.current=u;const E=ee.useMemo(()=>{const Z=new Map;for(const ce of i)Z.set(ce.id,Ch(ce.id,ce.name||ce.id,ce.type??void 0));return Z},[i]),T=ee.useMemo(()=>{const Z=new Map;for(const ce of i){const me=jHe(ce.name||ce.id);Z.set(ce.id,me.primary)}return Z},[i]),R=ee.useMemo(()=>{const Z=new Map;for(const ce of i)Z.set(ce.id,ce.type);return Z},[i]),P=ee.useMemo(()=>{const Z=new Map;for(const ce of i)Z.set(ce.id,{name:E.get(ce.id)??ce.id,type:R.get(ce.id)??"general-purpose",color:T.get(ce.id)??"#8b5cf6",status:ce.status});return Z},[i,E,R,T]),{active:I,inactive:L}=XTt({positions:a,agentMeta:P}),z=ee.useMemo(()=>{const Z=new Map;for(const ce of s){const me=Z.get(ce.fromAgentId)??[];me.push(ce),Z.set(ce.fromAgentId,me)}return Z},[s]),U=ee.useCallback(Z=>{n(r===Z?null:Z)},[n,r]),j=I.length>0?I:[{agentId:"claude-main",position:[0,0,0],modelType:"main",color:"#8b5cf6",name:"Claude",type:"general-purpose",pose:"idle",animationState:"idle",activityLabel:null,lastTool:null,parentAgentId:null}],F=ee.useMemo(()=>j.map(Z=>Z.agentId).join(","),[j]),[G,H]=ee.useState({w:1200,h:600}),W=ee.useMemo(()=>{const{w:Z,h:ce}=G,me=j.length,he=me*H_+(me-1)*cde,we=(Z-he)/2,Ee=(ce-uyt)/2,Se=new Map;for(let Ne=0;Ne<me;Ne++)Se.set(j[Ne].agentId,{x:Math.max(0,we+Ne*(H_+cde)),y:Math.max(0,Ee)});return Se},[F,G,j]);ee.useEffect(()=>{const Z=e.current;if(!Z)return;const ce=new ResizeObserver(me=>{const{width:he,height:we}=me[0].contentRect;he>0&&we>0&&H({w:he,h:we})});return ce.observe(Z),()=>ce.disconnect()},[]),ee.useEffect(()=>{const Z=new Set(j.map(ce=>ce.agentId));w(ce=>{let me=!1;for(const we of ce.keys())Z.has(we)||(me=!0);if(!me)return ce;const he=new Map;for(const[we,Ee]of ce)Z.has(we)&&he.set(we,Ee);return he})},[F,j]);const Q=ee.useCallback(Z=>x.get(Z)??W.get(Z)??{x:0,y:0},[x,W]),ne=ee.useCallback((Z,ce)=>{if(ce.button!==0)return;ce.stopPropagation();const me=Q(Z);S.current={agentId:Z,mouseX:ce.clientX,mouseY:ce.clientY,agentX:me.x,agentY:me.y},g(Z)},[Q]);ee.useEffect(()=>{function Z(me){const he=S.current;if(!he.agentId)return;const we=M.current,Ee=(me.clientX-he.mouseX)/we,Se=(me.clientY-he.mouseY)/we;w(Ne=>{const Pe=new Map(Ne);return Pe.set(he.agentId,{x:he.agentX+Ee,y:he.agentY+Se}),Pe})}function ce(){S.current.agentId&&(S.current.agentId=null,g(null))}return window.addEventListener("mousemove",Z),window.addEventListener("mouseup",ce),()=>{window.removeEventListener("mousemove",Z),window.removeEventListener("mouseup",ce)}},[]);const se=ee.useMemo(()=>j.map(Z=>({agentId:Z.agentId,pose:Z.pose})),[j]),$=ee.useRef(new Set),[J,ae]=ee.useState(new Set);ee.useEffect(()=>{const Z=new Set(j.map(he=>he.agentId)),ce=$.current,me=new Set;for(const he of Z)ce.has(he)||me.add(he);if($.current=Z,me.size>0){ae(me);const he=setTimeout(()=>ae(new Set),1500);return()=>clearTimeout(he)}},[F,j]);const oe=ee.useCallback(Z=>{Z.target.closest("[data-agent-id]")||m()},[m]),xe=y||d?"grabbing":"default";return t?C.jsxs("div",{className:"flex flex-col h-full overflow-hidden relative",children:[C.jsx($ae,{}),C.jsxs("div",{ref:e,className:"flex-1 relative overflow-hidden",style:{background:"radial-gradient(ellipse at center, #0f0f1a 0%, #0a0a12 70%)",minHeight:0,cursor:xe},onMouseDown:f,onDoubleClick:oe,children:[C.jsx("div",{className:"absolute inset-0 pointer-events-none",style:{backgroundImage:["linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px)","linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px)"].join(","),backgroundSize:`${40*u}px ${40*u}px`}}),C.jsx("div",{className:"absolute inset-0",style:{transform:h,transformOrigin:"0 0",willChange:y||d?"transform":"auto"},children:j.map(Z=>{const ce=Q(Z.agentId),me=y===Z.agentId,he=z.get(Z.agentId)??[],we=he.length>0?he[he.length-1]:null;return C.jsxs("div",{"data-agent-id":Z.agentId,className:`absolute flex flex-col items-center${J.has(Z.agentId)?" cam-agent-spawning":""}`,style:{left:`${ce.x}px`,top:`${ce.y}px`,width:`${H_}px`,zIndex:me?50:10,cursor:me?"grabbing":"grab",transition:me?"none":"left 0.3s ease, top 0.3s ease",userSelect:"none"},onMouseDown:Ee=>ne(Z.agentId,Ee),children:[we&&C.jsx("div",{className:"mb-2 max-w-[280px]",children:C.jsx(Z_e,{bubble:we,color:Z.color},we.id)}),C.jsx(fyt,{modelType:Z.modelType,isSelected:r===Z.agentId,isDragging:y===Z.agentId,onClick:()=>U(Z.agentId),color:Z.color,pose:Z.pose,animationState:Z.animationState}),C.jsx(byt,{agentId:Z.agentId,name:Z.name,color:Z.color,activityLabel:Z.activityLabel,speechBubbles:he,showLabels:l,hideBubble:!0})]},Z.agentId)})}),C.jsx(VTt,{containerRef:e,agents:se,zoom:u,spawningAgentIds:J}),C.jsx(Syt,{containerRef:e,interactionLines:o,positions:a,agentColors:T,showInteractions:c}),u!==1&&C.jsxs("div",{className:"absolute bottom-3 right-3 z-30 text-xs font-mono text-zinc-500 bg-black/50 px-2 py-1 rounded select-none pointer-events-none",children:[Math.round(u*100),"%"]})]}),C.jsx(wyt,{agents:L,selectedAgentId:r,onSelectAgent:U})]}):C.jsxs("div",{className:"flex flex-col h-full overflow-hidden relative",children:[C.jsx($ae,{}),C.jsxs("div",{className:"flex-1 relative overflow-hidden flex items-center justify-center",style:{background:"radial-gradient(ellipse at center, #0f0f1a 0%, #0a0a12 70%)"},children:[C.jsx("div",{className:"absolute inset-0 pointer-events-none",style:{backgroundImage:["linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px)","linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px)"].join(","),backgroundSize:"40px 40px"}}),C.jsxs(KTt,{title:"Welcome to CAM!",subtitle:"Start a Claude Code session to see your agents here in real-time.",variant:"default",children:[C.jsxs("div",{className:"flex flex-col gap-2 mt-3 text-left",children:[C.jsx(pG,{n:1,children:"Open a terminal in this project"}),C.jsxs(pG,{n:2,children:["Run ",C.jsx("code",{className:"px-1.5 py-0.5 rounded bg-zinc-800 text-violet-300 text-[11px] font-mono",children:"claude"})," to start Claude Code"]}),C.jsx(pG,{n:3,children:"Agents will appear here as they work"})]}),C.jsx("p",{className:"text-zinc-600 text-[10px] font-mono mt-3",children:"Or select a previous session from the picker above"})]})]})]})}const QTt=[{id:"overview",label:"Overview"},{id:"dependencies",label:"Deps"},{id:"activity",label:"Activity"}];function EK(){const{selectedTaskId:e,tasks:t,selectTask:i,sprints:r,activeProject:n}=_n(),a=oz(),[s,o]=ee.useState("overview"),[l,c]=ee.useState([]),[u,h]=ee.useState(!1),d=t.find(S=>S.id===e);if(ee.useEffect(()=>{s==="activity"&&d&&n&&(h(!0),KEe(n.id,d.id).then(S=>c(S.activities??[])).catch(()=>c([])).finally(()=>h(!1)))},[s,d==null?void 0:d.id,n==null?void 0:n.id]),!d)return null;const f=r.find(S=>S.id===d.sprintId),m=G7(d.priority),y=FEe(d.status),g=d.dependsOn.map(S=>t.find(M=>M.id===S)).filter(S=>S!==void 0),x=d.blockedBy.map(S=>t.find(M=>M.id===S)).filter(S=>S!==void 0),w=t.filter(S=>S.dependsOn.includes(d.id)||S.blockedBy.includes(d.id));return C.jsxs("div",{className:"h-full flex flex-col",children:[C.jsxs("div",{className:"p-4 border-b border-cam-border/30 shrink-0",children:[C.jsxs("div",{className:"flex items-start justify-between mb-3",children:[C.jsx("h3",{className:"text-sm font-semibold text-cam-text leading-tight flex-1 pr-2",children:d.title}),C.jsx("button",{onClick:()=>i(null),className:"text-cam-text-muted hover:text-cam-text transition-colors p-1 shrink-0",children:C.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:C.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),C.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-3",children:[C.jsx("span",{className:`text-[9px] px-1.5 py-0.5 rounded border font-medium ${m}`,children:d.priority}),C.jsx("span",{className:`text-[9px] px-1.5 py-0.5 rounded font-medium ${y}`,children:d.status.replace(/_/g," ")}),d.complexity&&C.jsxs("span",{className:"text-[9px] px-1.5 py-0.5 rounded bg-cam-surface-3 text-cam-text-muted border border-cam-border/50",children:["C",d.complexity]})]}),C.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[f&&C.jsxs("div",{className:"bg-cam-surface-2 rounded-md px-2 py-1.5",children:[C.jsx("div",{className:"text-[9px] text-cam-text-muted",children:"Sprint"}),C.jsx("div",{className:"text-[10px] text-cam-text font-medium truncate",children:f.name})]}),d.prdSection&&C.jsxs("div",{className:"bg-cam-surface-2 rounded-md px-2 py-1.5",children:[C.jsx("div",{className:"text-[9px] text-cam-text-muted",children:"Section"}),C.jsx("div",{className:"text-[10px] text-cam-text font-medium truncate",children:d.prdSection})]}),d.assignedAgent&&(()=>{const S=a(d.assignedAgent);return C.jsxs("div",{className:"bg-cam-surface-2 rounded-md px-2 py-1.5",children:[C.jsx("div",{className:"text-[9px] text-cam-text-muted",children:"Agent"}),C.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[C.jsx("div",{className:"w-3 h-3 rounded-full flex items-center justify-center text-[7px] font-bold",style:{backgroundColor:`${f0(d.assignedAgent)}20`,color:f0(d.assignedAgent)},children:S.charAt(0).toUpperCase()}),C.jsx("span",{className:"text-[10px] text-cam-text font-medium",children:S})]})]})})()]})]}),C.jsx("div",{className:"flex border-b border-cam-border/30 shrink-0",children:QTt.map(S=>{const M=S.id==="dependencies"?g.length+x.length+w.length:S.id==="activity"?l.length:0;return C.jsxs("button",{onClick:()=>o(S.id),className:`flex-1 py-2 text-[10px] font-medium transition-colors border-b-2 ${s===S.id?"text-cam-accent border-cam-accent":"text-cam-text-muted border-transparent hover:text-cam-text-secondary"}`,children:[S.label,M>0&&` (${M})`]},S.id)})}),C.jsxs("div",{className:"flex-1 overflow-y-auto modern-scrollbar",children:[s==="overview"&&C.jsx(ZTt,{task:d}),s==="dependencies"&&C.jsx(JTt,{dependsOn:g,blockedBy:x,blocks:w,onSelectTask:i,resolveAgentName:a}),s==="activity"&&C.jsx(tCt,{activities:l,loading:u,resolveAgentName:a})]})]})}function ZTt({task:e}){return C.jsxs("div",{className:"p-3 space-y-4",children:[e.description&&C.jsxs("div",{children:[C.jsx("h4",{className:"text-[10px] uppercase tracking-wider text-cam-text-muted font-medium mb-1",children:"Description"}),C.jsx("p",{className:"text-[11px] text-cam-text-secondary leading-relaxed",children:e.description})]}),e.acceptanceCriteria&&e.acceptanceCriteria.length>0&&C.jsxs("div",{children:[C.jsx("h4",{className:"text-[10px] uppercase tracking-wider text-cam-text-muted font-medium mb-1",children:"Acceptance Criteria"}),C.jsx("ul",{className:"space-y-1",children:e.acceptanceCriteria.map((t,i)=>C.jsxs("li",{className:"flex items-start gap-1.5 text-[11px] text-cam-text-secondary",children:[C.jsx("span",{className:"text-cam-accent mt-0.5 shrink-0",children:e.status==="completed"?"✓":"○"}),C.jsx("span",{children:t})]},i))})]}),e.tags&&e.tags.length>0&&C.jsxs("div",{children:[C.jsx("h4",{className:"text-[10px] uppercase tracking-wider text-cam-text-muted font-medium mb-1",children:"Tags"}),C.jsx("div",{className:"flex flex-wrap gap-1",children:e.tags.map(t=>C.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded bg-cam-surface-3 text-cam-text-muted border border-cam-border/30",children:t},t))})]}),C.jsxs("div",{children:[C.jsx("h4",{className:"text-[10px] uppercase tracking-wider text-cam-text-muted font-medium mb-1",children:"Timeline"}),C.jsxs("div",{className:"space-y-1 text-[10px]",children:[C.jsxs("div",{className:"flex justify-between",children:[C.jsx("span",{className:"text-cam-text-muted",children:"Created"}),C.jsx("span",{className:"text-cam-text-secondary font-mono",children:qc(e.createdAt)})]}),e.startedAt&&C.jsxs("div",{className:"flex justify-between",children:[C.jsx("span",{className:"text-cam-text-muted",children:"Started"}),C.jsx("span",{className:"text-cam-text-secondary font-mono",children:qc(e.startedAt)})]}),e.completedAt&&C.jsxs("div",{className:"flex justify-between",children:[C.jsx("span",{className:"text-cam-text-muted",children:"Completed"}),C.jsx("span",{className:"text-cam-text-secondary font-mono",children:qc(e.completedAt)})]})]})]})]})}function JTt({dependsOn:e,blockedBy:t,blocks:i,onSelectTask:r,resolveAgentName:n}){return e.length===0&&t.length===0&&i.length===0?C.jsx("p",{className:"text-xs text-cam-text-muted p-4 text-center",children:"No dependencies"}):C.jsxs("div",{className:"p-3 space-y-4",children:[t.length>0&&C.jsx(mG,{title:"Blocked By",tasks:t,color:"text-red-400",onSelect:r,resolveAgentName:n}),e.length>0&&C.jsx(mG,{title:"Depends On",tasks:e,color:"text-yellow-400",onSelect:r,resolveAgentName:n}),i.length>0&&C.jsx(mG,{title:"Blocks",tasks:i,color:"text-blue-400",onSelect:r,resolveAgentName:n})]})}function mG({title:e,tasks:t,color:i,onSelect:r,resolveAgentName:n}){return C.jsxs("div",{children:[C.jsxs("h4",{className:`text-[10px] uppercase tracking-wider font-medium mb-1 ${i}`,children:[e," (",t.length,")"]}),C.jsx("div",{className:"space-y-1",children:t.map(a=>C.jsxs("button",{onClick:()=>r(a.id),className:"w-full text-left px-2 py-1.5 rounded hover:bg-cam-surface-2 transition-colors group",children:[C.jsxs("div",{className:"flex items-center gap-2",children:[C.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${eCt(a.status)}`}),C.jsx("span",{className:"text-[11px] text-cam-text-secondary group-hover:text-cam-text truncate",children:a.title})]}),C.jsxs("div",{className:"flex items-center gap-2 ml-3.5 mt-0.5",children:[C.jsx("span",{className:"text-[9px] text-cam-text-muted capitalize",children:a.status.replace(/_/g," ")}),a.assignedAgent&&C.jsxs("span",{className:"text-[9px] text-cam-text-muted",children:["@",n(a.assignedAgent)]})]})]},a.id))})]})}function eCt(e){return{backlog:"bg-gray-500",planned:"bg-blue-500",pending:"bg-yellow-500",in_progress:"bg-emerald-500",in_review:"bg-purple-500",completed:"bg-green-500",blocked:"bg-red-500",deferred:"bg-gray-500"}[e]||"bg-gray-500"}function tCt({activities:e,loading:t,resolveAgentName:i}){return t?C.jsx("div",{className:"flex items-center justify-center p-4",children:C.jsx("span",{className:"text-[10px] text-cam-text-muted animate-pulse",children:"Loading activities..."})}):e.length===0?C.jsx("p",{className:"text-xs text-cam-text-muted p-4 text-center",children:"No activity recorded"}):C.jsx("div",{className:"divide-y divide-cam-border/20",children:e.map(r=>C.jsxs("div",{className:"px-3 py-2",children:[C.jsxs("div",{className:"flex items-center justify-between",children:[C.jsx("span",{className:"text-[11px] font-medium text-cam-accent",children:iCt(r.activityType)}),C.jsx("span",{className:"text-[9px] text-cam-text-muted font-mono",children:gu(r.timestamp)})]}),C.jsx("div",{className:"flex items-center gap-2 mt-0.5",children:C.jsxs("span",{className:"text-[9px] text-cam-text-muted",children:["@",i(r.agentId)]})}),r.details&&C.jsx("p",{className:"text-[10px] text-cam-text-secondary mt-0.5",children:r.details})]},r.id))})}function iCt(e){return{task_created:"Task Created",task_started:"Task Started",task_completed:"Task Completed",task_blocked:"Task Blocked",task_unblocked:"Task Unblocked",agent_assigned:"Agent Assigned",file_modified:"File Modified",error_occurred:"Error Occurred",manual_update:"Manual Update"}[e]||e.replace(/_/g," ")}const tU=ee.createContext(null);tU.displayName="PanelGroupContext";const Ha={group:"data-panel-group",groupDirection:"data-panel-group-direction",groupId:"data-panel-group-id",panel:"data-panel",panelCollapsible:"data-panel-collapsible",panelId:"data-panel-id",panelSize:"data-panel-size",resizeHandle:"data-resize-handle",resizeHandleActive:"data-resize-handle-active",resizeHandleEnabled:"data-panel-resize-handle-enabled",resizeHandleId:"data-panel-resize-handle-id",resizeHandleState:"data-resize-handle-state"},TK=10,$x=ee.useLayoutEffect,lpe=PEe.useId,rCt=typeof lpe=="function"?lpe:()=>null;let nCt=0;function CK(e=null){const t=rCt(),i=ee.useRef(e||t||null);return i.current===null&&(i.current=""+nCt++),e??i.current}function mMe({children:e,className:t="",collapsedSize:i,collapsible:r,defaultSize:n,forwardedRef:a,id:s,maxSize:o,minSize:l,onCollapse:c,onExpand:u,onResize:h,order:d,style:f,tagName:m="div",...y}){const g=ee.useContext(tU);if(g===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:x,expandPanel:w,getPanelSize:S,getPanelStyle:M,groupId:E,isPanelCollapsed:T,reevaluatePanelConstraints:R,registerPanel:P,resizePanel:I,unregisterPanel:L}=g,z=CK(s),U=ee.useRef({callbacks:{onCollapse:c,onExpand:u,onResize:h},constraints:{collapsedSize:i,collapsible:r,defaultSize:n,maxSize:o,minSize:l},id:z,idIsFromProps:s!==void 0,order:d});ee.useRef({didLogMissingDefaultSizeWarning:!1}),$x(()=>{const{callbacks:F,constraints:G}=U.current,H={...G};U.current.id=z,U.current.idIsFromProps=s!==void 0,U.current.order=d,F.onCollapse=c,F.onExpand=u,F.onResize=h,G.collapsedSize=i,G.collapsible=r,G.defaultSize=n,G.maxSize=o,G.minSize=l,(H.collapsedSize!==G.collapsedSize||H.collapsible!==G.collapsible||H.maxSize!==G.maxSize||H.minSize!==G.minSize)&&R(U.current,H)}),$x(()=>{const F=U.current;return P(F),()=>{L(F)}},[d,z,P,L]),ee.useImperativeHandle(a,()=>({collapse:()=>{x(U.current)},expand:F=>{w(U.current,F)},getId(){return z},getSize(){return S(U.current)},isCollapsed(){return T(U.current)},isExpanded(){return!T(U.current)},resize:F=>{I(U.current,F)}}),[x,w,S,T,z,I]);const j=M(U.current,n);return ee.createElement(m,{...y,children:e,className:t,id:z,style:{...j,...f},[Ha.groupId]:E,[Ha.panel]:"",[Ha.panelCollapsible]:r||void 0,[Ha.panelId]:z,[Ha.panelSize]:parseFloat(""+j.flexGrow).toFixed(1)})}const gMe=ee.forwardRef((e,t)=>ee.createElement(mMe,{...e,forwardedRef:t}));mMe.displayName="Panel";gMe.displayName="forwardRef(Panel)";let V7=null,II=-1,jv=null;function aCt(e,t){if(t){const i=(t&wMe)!==0,r=(t&_Me)!==0,n=(t&SMe)!==0,a=(t&AMe)!==0;if(i)return n?"se-resize":a?"ne-resize":"e-resize";if(r)return n?"sw-resize":a?"nw-resize":"w-resize";if(n)return"s-resize";if(a)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function sCt(){jv!==null&&(document.head.removeChild(jv),V7=null,jv=null,II=-1)}function gG(e,t){var i,r;const n=aCt(e,t);if(V7!==n){if(V7=n,jv===null&&(jv=document.createElement("style"),document.head.appendChild(jv)),II>=0){var a;(a=jv.sheet)===null||a===void 0||a.removeRule(II)}II=(i=(r=jv.sheet)===null||r===void 0?void 0:r.insertRule(`*{cursor: ${n} !important;}`))!==null&&i!==void 0?i:-1}}function vMe(e){return e.type==="keydown"}function yMe(e){return e.type.startsWith("pointer")}function xMe(e){return e.type.startsWith("mouse")}function iU(e){if(yMe(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(xMe(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function oCt(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function lCt(e,t,i){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function cCt(e,t){if(e===t)throw new Error("Cannot compare node with itself");const i={a:hpe(e),b:hpe(t)};let r;for(;i.a.at(-1)===i.b.at(-1);)e=i.a.pop(),t=i.b.pop(),r=e;br(r,"Stacking order can only be calculated for elements with a common ancestor");const n={a:upe(cpe(i.a)),b:upe(cpe(i.b))};if(n.a===n.b){const a=r.childNodes,s={a:i.a.at(-1),b:i.b.at(-1)};let o=a.length;for(;o--;){const l=a[o];if(l===s.a)return 1;if(l===s.b)return-1}}return Math.sign(n.a-n.b)}const uCt=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function hCt(e){var t;const i=getComputedStyle((t=bMe(e))!==null&&t!==void 0?t:e).display;return i==="flex"||i==="inline-flex"}function dCt(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||hCt(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||uCt.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function cpe(e){let t=e.length;for(;t--;){const i=e[t];if(br(i,"Missing node"),dCt(i))return i}return null}function upe(e){return e&&Number(getComputedStyle(e).zIndex)||0}function hpe(e){const t=[];for(;e;)t.push(e),e=bMe(e);return t}function bMe(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const wMe=1,_Me=2,SMe=4,AMe=8,fCt=oCt()==="coarse";let Ed=[],q_=!1,gx=new Map,rU=new Map;const qP=new Set;function pCt(e,t,i,r,n){var a;const{ownerDocument:s}=t,o={direction:i,element:t,hitAreaMargins:r,setResizeHandlerState:n},l=(a=gx.get(s))!==null&&a!==void 0?a:0;return gx.set(s,l+1),qP.add(o),Qk(),function(){var u;rU.delete(e),qP.delete(o);const h=(u=gx.get(s))!==null&&u!==void 0?u:1;if(gx.set(s,h-1),Qk(),h===1&&gx.delete(s),Ed.includes(o)){const d=Ed.indexOf(o);d>=0&&Ed.splice(d,1),DK(),n("up",!0,null)}}}function mCt(e){const{target:t}=e,{x:i,y:r}=iU(e);q_=!0,PK({target:t,x:i,y:r}),Qk(),Ed.length>0&&(Zk("down",e),e.preventDefault(),MMe(t)||e.stopImmediatePropagation())}function vG(e){const{x:t,y:i}=iU(e);if(q_&&e.buttons===0&&(q_=!1,Zk("up",e)),!q_){const{target:r}=e;PK({target:r,x:t,y:i})}Zk("move",e),DK(),Ed.length>0&&e.preventDefault()}function yG(e){const{target:t}=e,{x:i,y:r}=iU(e);rU.clear(),q_=!1,Ed.length>0&&(e.preventDefault(),MMe(t)||e.stopImmediatePropagation()),Zk("up",e),PK({target:t,x:i,y:r}),DK(),Qk()}function MMe(e){let t=e;for(;t;){if(t.hasAttribute(Ha.resizeHandle))return!0;t=t.parentElement}return!1}function PK({target:e,x:t,y:i}){Ed.splice(0);let r=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(r=e),qP.forEach(n=>{const{element:a,hitAreaMargins:s}=n,o=a.getBoundingClientRect(),{bottom:l,left:c,right:u,top:h}=o,d=fCt?s.coarse:s.fine;if(t>=c-d&&t<=u+d&&i>=h-d&&i<=l+d){if(r!==null&&document.contains(r)&&a!==r&&!a.contains(r)&&!r.contains(a)&&cCt(r,a)>0){let m=r,y=!1;for(;m&&!m.contains(a);){if(lCt(m.getBoundingClientRect(),o)){y=!0;break}m=m.parentElement}if(y)return}Ed.push(n)}})}function xG(e,t){rU.set(e,t)}function DK(){let e=!1,t=!1;Ed.forEach(r=>{const{direction:n}=r;n==="horizontal"?e=!0:t=!0});let i=0;rU.forEach(r=>{i|=r}),e&&t?gG("intersection",i):e?gG("horizontal",i):t?gG("vertical",i):sCt()}let bG=new AbortController;function Qk(){bG.abort(),bG=new AbortController;const e={capture:!0,signal:bG.signal};qP.size&&(q_?(Ed.length>0&&gx.forEach((t,i)=>{const{body:r}=i;t>0&&(r.addEventListener("contextmenu",yG,e),r.addEventListener("pointerleave",vG,e),r.addEventListener("pointermove",vG,e))}),window.addEventListener("pointerup",yG,e),window.addEventListener("pointercancel",yG,e)):gx.forEach((t,i)=>{const{body:r}=i;t>0&&(r.addEventListener("pointerdown",mCt,e),r.addEventListener("pointermove",vG,e))}))}function Zk(e,t){qP.forEach(i=>{const{setResizeHandlerState:r}=i,n=Ed.includes(i);r(e,n,t)})}function gCt(){const[e,t]=ee.useState(0);return ee.useCallback(()=>t(i=>i+1),[])}function br(e,t){if(!e)throw console.error(t),Error(t)}function gb(e,t,i=TK){return e.toFixed(i)===t.toFixed(i)?0:e>t?1:-1}function Mm(e,t,i=TK){return gb(e,t,i)===0}function hu(e,t,i){return gb(e,t,i)===0}function vCt(e,t,i){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++){const n=e[r],a=t[r];if(!hu(n,a,i))return!1}return!0}function S_({panelConstraints:e,panelIndex:t,size:i}){const r=e[t];br(r!=null,`Panel constraints not found for index ${t}`);let{collapsedSize:n=0,collapsible:a,maxSize:s=100,minSize:o=0}=r;if(gb(i,o)<0)if(a){const l=(n+o)/2;gb(i,l)<0?i=n:i=o}else i=o;return i=Math.min(s,i),i=parseFloat(i.toFixed(TK)),i}function CT({delta:e,initialLayout:t,panelConstraints:i,pivotIndices:r,prevLayout:n,trigger:a}){if(hu(e,0))return t;const s=[...t],[o,l]=r;br(o!=null,"Invalid first pivot index"),br(l!=null,"Invalid second pivot index");let c=0;if(a==="keyboard"){{const h=e<0?l:o,d=i[h];br(d,`Panel constraints not found for index ${h}`);const{collapsedSize:f=0,collapsible:m,minSize:y=0}=d;if(m){const g=t[h];if(br(g!=null,`Previous layout not found for panel index ${h}`),hu(g,f)){const x=y-g;gb(x,Math.abs(e))>0&&(e=e<0?0-x:x)}}}{const h=e<0?o:l,d=i[h];br(d,`No panel constraints found for index ${h}`);const{collapsedSize:f=0,collapsible:m,minSize:y=0}=d;if(m){const g=t[h];if(br(g!=null,`Previous layout not found for panel index ${h}`),hu(g,y)){const x=g-f;gb(x,Math.abs(e))>0&&(e=e<0?0-x:x)}}}}{const h=e<0?1:-1;let d=e<0?l:o,f=0;for(;;){const y=t[d];br(y!=null,`Previous layout not found for panel index ${d}`);const x=S_({panelConstraints:i,panelIndex:d,size:100})-y;if(f+=x,d+=h,d<0||d>=i.length)break}const m=Math.min(Math.abs(e),Math.abs(f));e=e<0?0-m:m}{let d=e<0?o:l;for(;d>=0&&d<i.length;){const f=Math.abs(e)-Math.abs(c),m=t[d];br(m!=null,`Previous layout not found for panel index ${d}`);const y=m-f,g=S_({panelConstraints:i,panelIndex:d,size:y});if(!hu(m,g)&&(c+=m-g,s[d]=g,c.toPrecision(3).localeCompare(Math.abs(e).toPrecision(3),void 0,{numeric:!0})>=0))break;e<0?d--:d++}}if(vCt(n,s))return n;{const h=e<0?l:o,d=t[h];br(d!=null,`Previous layout not found for panel index ${h}`);const f=d+c,m=S_({panelConstraints:i,panelIndex:h,size:f});if(s[h]=m,!hu(m,f)){let y=f-m,x=e<0?l:o;for(;x>=0&&x<i.length;){const w=s[x];br(w!=null,`Previous layout not found for panel index ${x}`);const S=w+y,M=S_({panelConstraints:i,panelIndex:x,size:S});if(hu(w,M)||(y-=M-w,s[x]=M),hu(y,0))break;e>0?x--:x++}}}const u=s.reduce((h,d)=>d+h,0);return hu(u,100)?s:n}function yCt({layout:e,panelsArray:t,pivotIndices:i}){let r=0,n=100,a=0,s=0;const o=i[0];br(o!=null,"No pivot index found"),t.forEach((h,d)=>{const{constraints:f}=h,{maxSize:m=100,minSize:y=0}=f;d===o?(r=y,n=m):(a+=y,s+=m)});const l=Math.min(n,100-a),c=Math.max(r,100-s),u=e[o];return{valueMax:l,valueMin:c,valueNow:u}}function XP(e,t=document){return Array.from(t.querySelectorAll(`[${Ha.resizeHandleId}][data-panel-group-id="${e}"]`))}function EMe(e,t,i=document){const n=XP(e,i).findIndex(a=>a.getAttribute(Ha.resizeHandleId)===t);return n??null}function TMe(e,t,i){const r=EMe(e,t,i);return r!=null?[r,r+1]:[-1,-1]}function CMe(e,t=document){var i;if(t instanceof HTMLElement&&(t==null||(i=t.dataset)===null||i===void 0?void 0:i.panelGroupId)==e)return t;const r=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return r||null}function nU(e,t=document){const i=t.querySelector(`[${Ha.resizeHandleId}="${e}"]`);return i||null}function xCt(e,t,i,r=document){var n,a,s,o;const l=nU(t,r),c=XP(e,r),u=l?c.indexOf(l):-1,h=(n=(a=i[u])===null||a===void 0?void 0:a.id)!==null&&n!==void 0?n:null,d=(s=(o=i[u+1])===null||o===void 0?void 0:o.id)!==null&&s!==void 0?s:null;return[h,d]}function bCt({committedValuesRef:e,eagerValuesRef:t,groupId:i,layout:r,panelDataArray:n,panelGroupElement:a,setLayout:s}){ee.useRef({didWarnAboutMissingResizeHandle:!1}),$x(()=>{if(!a)return;const o=XP(i,a);for(let l=0;l<n.length-1;l++){const{valueMax:c,valueMin:u,valueNow:h}=yCt({layout:r,panelsArray:n,pivotIndices:[l,l+1]}),d=o[l];if(d!=null){const f=n[l];br(f,`No panel data found for index "${l}"`),d.setAttribute("aria-controls",f.id),d.setAttribute("aria-valuemax",""+Math.round(c)),d.setAttribute("aria-valuemin",""+Math.round(u)),d.setAttribute("aria-valuenow",h!=null?""+Math.round(h):"")}}return()=>{o.forEach((l,c)=>{l.removeAttribute("aria-controls"),l.removeAttribute("aria-valuemax"),l.removeAttribute("aria-valuemin"),l.removeAttribute("aria-valuenow")})}},[i,r,n,a]),ee.useEffect(()=>{if(!a)return;const o=t.current;br(o,"Eager values not found");const{panelDataArray:l}=o,c=CMe(i,a);br(c!=null,`No group found for id "${i}"`);const u=XP(i,a);br(u,`No resize handles found for group id "${i}"`);const h=u.map(d=>{const f=d.getAttribute(Ha.resizeHandleId);br(f,"Resize handle element has no handle id attribute");const[m,y]=xCt(i,f,l,a);if(m==null||y==null)return()=>{};const g=x=>{if(!x.defaultPrevented)switch(x.key){case"Enter":{x.preventDefault();const w=l.findIndex(S=>S.id===m);if(w>=0){const S=l[w];br(S,`No panel data found for index ${w}`);const M=r[w],{collapsedSize:E=0,collapsible:T,minSize:R=0}=S.constraints;if(M!=null&&T){const P=CT({delta:hu(M,E)?R-E:E-M,initialLayout:r,panelConstraints:l.map(I=>I.constraints),pivotIndices:TMe(i,f,a),prevLayout:r,trigger:"keyboard"});r!==P&&s(P)}}break}}};return d.addEventListener("keydown",g),()=>{d.removeEventListener("keydown",g)}});return()=>{h.forEach(d=>d())}},[a,e,t,i,r,n,s])}function dpe(e,t){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(e[i]!==t[i])return!1;return!0}function PMe(e,t){const i=e==="horizontal",{x:r,y:n}=iU(t);return i?r:n}function wCt(e,t,i,r,n){const a=i==="horizontal",s=nU(t,n);br(s,`No resize handle element found for id "${t}"`);const o=s.getAttribute(Ha.groupId);br(o,"Resize handle element has no group id attribute");let{initialCursorPosition:l}=r;const c=PMe(i,e),u=CMe(o,n);br(u,`No group element found for id "${o}"`);const h=u.getBoundingClientRect(),d=a?h.width:h.height;return(c-l)/d*100}function _Ct(e,t,i,r,n,a){if(vMe(e)){const s=i==="horizontal";let o=0;e.shiftKey?o=100:n!=null?o=n:o=10;let l=0;switch(e.key){case"ArrowDown":l=s?0:o;break;case"ArrowLeft":l=s?-o:0;break;case"ArrowRight":l=s?o:0;break;case"ArrowUp":l=s?0:-o;break;case"End":l=100;break;case"Home":l=-100;break}return l}else return r==null?0:wCt(e,t,i,r,a)}function SCt({panelDataArray:e}){const t=Array(e.length),i=e.map(a=>a.constraints);let r=0,n=100;for(let a=0;a<e.length;a++){const s=i[a];br(s,`Panel constraints not found for index ${a}`);const{defaultSize:o}=s;o!=null&&(r++,t[a]=o,n-=o)}for(let a=0;a<e.length;a++){const s=i[a];br(s,`Panel constraints not found for index ${a}`);const{defaultSize:o}=s;if(o!=null)continue;const l=e.length-r,c=n/l;r++,t[a]=c,n-=c}return t}function Gw(e,t,i){t.forEach((r,n)=>{const a=e[n];br(a,`Panel data not found for index ${n}`);const{callbacks:s,constraints:o,id:l}=a,{collapsedSize:c=0,collapsible:u}=o,h=i[l];if(h==null||r!==h){i[l]=r;const{onCollapse:d,onExpand:f,onResize:m}=s;m&&m(r,h),u&&(d||f)&&(f&&(h==null||Mm(h,c))&&!Mm(r,c)&&f(),d&&(h==null||!Mm(h,c))&&Mm(r,c)&&d())}})}function oI(e,t){if(e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(e[i]!=t[i])return!1;return!0}function ACt({defaultSize:e,dragState:t,layout:i,panelData:r,panelIndex:n,precision:a=3}){const s=i[n];let o;return s==null?o=e!=null?e.toPrecision(a):"1":r.length===1?o="1":o=s.toPrecision(a),{flexBasis:0,flexGrow:o,flexShrink:1,overflow:"hidden",pointerEvents:t!==null?"none":void 0}}function MCt(e,t=10){let i=null;return(...n)=>{i!==null&&clearTimeout(i),i=setTimeout(()=>{e(...n)},t)}}function fpe(e){try{if(typeof localStorage<"u")e.getItem=t=>localStorage.getItem(t),e.setItem=(t,i)=>{localStorage.setItem(t,i)};else throw new Error("localStorage not supported in this environment")}catch(t){console.error(t),e.getItem=()=>null,e.setItem=()=>{}}}function DMe(e){return`react-resizable-panels:${e}`}function OMe(e){return e.map(t=>{const{constraints:i,id:r,idIsFromProps:n,order:a}=t;return n?r:a?`${a}:${JSON.stringify(i)}`:JSON.stringify(i)}).sort((t,i)=>t.localeCompare(i)).join(",")}function RMe(e,t){try{const i=DMe(e),r=t.getItem(i);if(r){const n=JSON.parse(r);if(typeof n=="object"&&n!=null)return n}}catch{}return null}function ECt(e,t,i){var r,n;const a=(r=RMe(e,i))!==null&&r!==void 0?r:{},s=OMe(t);return(n=a[s])!==null&&n!==void 0?n:null}function TCt(e,t,i,r,n){var a;const s=DMe(e),o=OMe(t),l=(a=RMe(e,n))!==null&&a!==void 0?a:{};l[o]={expandToSizes:Object.fromEntries(i.entries()),layout:r};try{n.setItem(s,JSON.stringify(l))}catch(c){console.error(c)}}function ppe({layout:e,panelConstraints:t}){const i=[...e],r=i.reduce((a,s)=>a+s,0);if(i.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${i.map(a=>`${a}%`).join(", ")}`);if(!hu(r,100)&&i.length>0)for(let a=0;a<t.length;a++){const s=i[a];br(s!=null,`No layout data found for index ${a}`);const o=100/r*s;i[a]=o}let n=0;for(let a=0;a<t.length;a++){const s=i[a];br(s!=null,`No layout data found for index ${a}`);const o=S_({panelConstraints:t,panelIndex:a,size:s});s!=o&&(n+=s-o,i[a]=o)}if(!hu(n,0))for(let a=0;a<t.length;a++){const s=i[a];br(s!=null,`No layout data found for index ${a}`);const o=s+n,l=S_({panelConstraints:t,panelIndex:a,size:o});if(s!==l&&(n-=l-s,i[a]=l,hu(n,0)))break}return i}const CCt=100,PT={getItem:e=>(fpe(PT),PT.getItem(e)),setItem:(e,t)=>{fpe(PT),PT.setItem(e,t)}},mpe={};function IMe({autoSaveId:e=null,children:t,className:i="",direction:r,forwardedRef:n,id:a=null,onLayout:s=null,keyboardResizeBy:o=null,storage:l=PT,style:c,tagName:u="div",...h}){const d=CK(a),f=ee.useRef(null),[m,y]=ee.useState(null),[g,x]=ee.useState([]),w=gCt(),S=ee.useRef({}),M=ee.useRef(new Map),E=ee.useRef(0),T=ee.useRef({autoSaveId:e,direction:r,dragState:m,id:d,keyboardResizeBy:o,onLayout:s,storage:l}),R=ee.useRef({layout:g,panelDataArray:[],panelDataArrayChanged:!1});ee.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),ee.useImperativeHandle(n,()=>({getId:()=>T.current.id,getLayout:()=>{const{layout:ae}=R.current;return ae},setLayout:ae=>{const{onLayout:oe}=T.current,{layout:xe,panelDataArray:Z}=R.current,ce=ppe({layout:ae,panelConstraints:Z.map(me=>me.constraints)});dpe(xe,ce)||(x(ce),R.current.layout=ce,oe&&oe(ce),Gw(Z,ce,S.current))}}),[]),$x(()=>{T.current.autoSaveId=e,T.current.direction=r,T.current.dragState=m,T.current.id=d,T.current.onLayout=s,T.current.storage=l}),bCt({committedValuesRef:T,eagerValuesRef:R,groupId:d,layout:g,panelDataArray:R.current.panelDataArray,setLayout:x,panelGroupElement:f.current}),ee.useEffect(()=>{const{panelDataArray:ae}=R.current;if(e){if(g.length===0||g.length!==ae.length)return;let oe=mpe[e];oe==null&&(oe=MCt(TCt,CCt),mpe[e]=oe);const xe=[...ae],Z=new Map(M.current);oe(e,xe,Z,g,l)}},[e,g,l]),ee.useEffect(()=>{});const P=ee.useCallback(ae=>{const{onLayout:oe}=T.current,{layout:xe,panelDataArray:Z}=R.current;if(ae.constraints.collapsible){const ce=Z.map(Ee=>Ee.constraints),{collapsedSize:me=0,panelSize:he,pivotIndices:we}=Zy(Z,ae,xe);if(br(he!=null,`Panel size not found for panel "${ae.id}"`),!Mm(he,me)){M.current.set(ae.id,he);const Se=n_(Z,ae)===Z.length-1?he-me:me-he,Ne=CT({delta:Se,initialLayout:xe,panelConstraints:ce,pivotIndices:we,prevLayout:xe,trigger:"imperative-api"});oI(xe,Ne)||(x(Ne),R.current.layout=Ne,oe&&oe(Ne),Gw(Z,Ne,S.current))}}},[]),I=ee.useCallback((ae,oe)=>{const{onLayout:xe}=T.current,{layout:Z,panelDataArray:ce}=R.current;if(ae.constraints.collapsible){const me=ce.map(Pe=>Pe.constraints),{collapsedSize:he=0,panelSize:we=0,minSize:Ee=0,pivotIndices:Se}=Zy(ce,ae,Z),Ne=oe??Ee;if(Mm(we,he)){const Pe=M.current.get(ae.id),Re=Pe!=null&&Pe>=Ne?Pe:Ne,He=n_(ce,ae)===ce.length-1?we-Re:Re-we,de=CT({delta:He,initialLayout:Z,panelConstraints:me,pivotIndices:Se,prevLayout:Z,trigger:"imperative-api"});oI(Z,de)||(x(de),R.current.layout=de,xe&&xe(de),Gw(ce,de,S.current))}}},[]),L=ee.useCallback(ae=>{const{layout:oe,panelDataArray:xe}=R.current,{panelSize:Z}=Zy(xe,ae,oe);return br(Z!=null,`Panel size not found for panel "${ae.id}"`),Z},[]),z=ee.useCallback((ae,oe)=>{const{panelDataArray:xe}=R.current,Z=n_(xe,ae);return ACt({defaultSize:oe,dragState:m,layout:g,panelData:xe,panelIndex:Z})},[m,g]),U=ee.useCallback(ae=>{const{layout:oe,panelDataArray:xe}=R.current,{collapsedSize:Z=0,collapsible:ce,panelSize:me}=Zy(xe,ae,oe);return br(me!=null,`Panel size not found for panel "${ae.id}"`),ce===!0&&Mm(me,Z)},[]),j=ee.useCallback(ae=>{const{layout:oe,panelDataArray:xe}=R.current,{collapsedSize:Z=0,collapsible:ce,panelSize:me}=Zy(xe,ae,oe);return br(me!=null,`Panel size not found for panel "${ae.id}"`),!ce||gb(me,Z)>0},[]),F=ee.useCallback(ae=>{const{panelDataArray:oe}=R.current;oe.push(ae),oe.sort((xe,Z)=>{const ce=xe.order,me=Z.order;return ce==null&&me==null?0:ce==null?-1:me==null?1:ce-me}),R.current.panelDataArrayChanged=!0,w()},[w]);$x(()=>{if(R.current.panelDataArrayChanged){R.current.panelDataArrayChanged=!1;const{autoSaveId:ae,onLayout:oe,storage:xe}=T.current,{layout:Z,panelDataArray:ce}=R.current;let me=null;if(ae){const we=ECt(ae,ce,xe);we&&(M.current=new Map(Object.entries(we.expandToSizes)),me=we.layout)}me==null&&(me=SCt({panelDataArray:ce}));const he=ppe({layout:me,panelConstraints:ce.map(we=>we.constraints)});dpe(Z,he)||(x(he),R.current.layout=he,oe&&oe(he),Gw(ce,he,S.current))}}),$x(()=>{const ae=R.current;return()=>{ae.layout=[]}},[]);const G=ee.useCallback(ae=>{let oe=!1;const xe=f.current;return xe&&window.getComputedStyle(xe,null).getPropertyValue("direction")==="rtl"&&(oe=!0),function(ce){ce.preventDefault();const me=f.current;if(!me)return()=>null;const{direction:he,dragState:we,id:Ee,keyboardResizeBy:Se,onLayout:Ne}=T.current,{layout:Pe,panelDataArray:Re}=R.current,{initialLayout:ze}=we??{},He=TMe(Ee,ae,me);let de=_Ct(ce,ae,he,we,Se,me);const et=he==="horizontal";et&&oe&&(de=-de);const ut=Re.map(q=>q.constraints),vt=CT({delta:de,initialLayout:ze??Pe,panelConstraints:ut,pivotIndices:He,prevLayout:Pe,trigger:vMe(ce)?"keyboard":"mouse-or-touch"}),fe=!oI(Pe,vt);(yMe(ce)||xMe(ce))&&E.current!=de&&(E.current=de,!fe&&de!==0?et?xG(ae,de<0?wMe:_Me):xG(ae,de<0?SMe:AMe):xG(ae,0)),fe&&(x(vt),R.current.layout=vt,Ne&&Ne(vt),Gw(Re,vt,S.current))}},[]),H=ee.useCallback((ae,oe)=>{const{onLayout:xe}=T.current,{layout:Z,panelDataArray:ce}=R.current,me=ce.map(Pe=>Pe.constraints),{panelSize:he,pivotIndices:we}=Zy(ce,ae,Z);br(he!=null,`Panel size not found for panel "${ae.id}"`);const Se=n_(ce,ae)===ce.length-1?he-oe:oe-he,Ne=CT({delta:Se,initialLayout:Z,panelConstraints:me,pivotIndices:we,prevLayout:Z,trigger:"imperative-api"});oI(Z,Ne)||(x(Ne),R.current.layout=Ne,xe&&xe(Ne),Gw(ce,Ne,S.current))},[]),W=ee.useCallback((ae,oe)=>{const{layout:xe,panelDataArray:Z}=R.current,{collapsedSize:ce=0,collapsible:me}=oe,{collapsedSize:he=0,collapsible:we,maxSize:Ee=100,minSize:Se=0}=ae.constraints,{panelSize:Ne}=Zy(Z,ae,xe);Ne!=null&&(me&&we&&Mm(Ne,ce)?Mm(ce,he)||H(ae,he):Ne<Se?H(ae,Se):Ne>Ee&&H(ae,Ee))},[H]),Q=ee.useCallback((ae,oe)=>{const{direction:xe}=T.current,{layout:Z}=R.current;if(!f.current)return;const ce=nU(ae,f.current);br(ce,`Drag handle element not found for id "${ae}"`);const me=PMe(xe,oe);y({dragHandleId:ae,dragHandleRect:ce.getBoundingClientRect(),initialCursorPosition:me,initialLayout:Z})},[]),ne=ee.useCallback(()=>{y(null)},[]),se=ee.useCallback(ae=>{const{panelDataArray:oe}=R.current,xe=n_(oe,ae);xe>=0&&(oe.splice(xe,1),delete S.current[ae.id],R.current.panelDataArrayChanged=!0,w())},[w]),$=ee.useMemo(()=>({collapsePanel:P,direction:r,dragState:m,expandPanel:I,getPanelSize:L,getPanelStyle:z,groupId:d,isPanelCollapsed:U,isPanelExpanded:j,reevaluatePanelConstraints:W,registerPanel:F,registerResizeHandle:G,resizePanel:H,startDragging:Q,stopDragging:ne,unregisterPanel:se,panelGroupElement:f.current}),[P,m,r,I,L,z,d,U,j,W,F,G,H,Q,ne,se]),J={display:"flex",flexDirection:r==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return ee.createElement(tU.Provider,{value:$},ee.createElement(u,{...h,children:t,className:i,id:a,ref:f,style:{...J,...c},[Ha.group]:"",[Ha.groupDirection]:r,[Ha.groupId]:d}))}const OK=ee.forwardRef((e,t)=>ee.createElement(IMe,{...e,forwardedRef:t}));IMe.displayName="PanelGroup";OK.displayName="forwardRef(PanelGroup)";function n_(e,t){return e.findIndex(i=>i===t||i.id===t.id)}function Zy(e,t,i){const r=n_(e,t),a=r===e.length-1?[r-1,r]:[r,r+1],s=i[r];return{...t.constraints,panelSize:s,pivotIndices:a}}function PCt({disabled:e,handleId:t,resizeHandler:i,panelGroupElement:r}){ee.useEffect(()=>{if(e||i==null||r==null)return;const n=nU(t,r);if(n==null)return;const a=s=>{if(!s.defaultPrevented)switch(s.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{s.preventDefault(),i(s);break}case"F6":{s.preventDefault();const o=n.getAttribute(Ha.groupId);br(o,`No group element found for id "${o}"`);const l=XP(o,r),c=EMe(o,t,r);br(c!==null,`No resize element found for id "${t}"`);const u=s.shiftKey?c>0?c-1:l.length-1:c+1<l.length?c+1:0;l[u].focus();break}}};return n.addEventListener("keydown",a),()=>{n.removeEventListener("keydown",a)}},[r,e,t,i])}function NMe({children:e=null,className:t="",disabled:i=!1,hitAreaMargins:r,id:n,onBlur:a,onClick:s,onDragging:o,onFocus:l,onPointerDown:c,onPointerUp:u,style:h={},tabIndex:d=0,tagName:f="div",...m}){var y,g;const x=ee.useRef(null),w=ee.useRef({onClick:s,onDragging:o,onPointerDown:c,onPointerUp:u});ee.useEffect(()=>{w.current.onClick=s,w.current.onDragging=o,w.current.onPointerDown=c,w.current.onPointerUp=u});const S=ee.useContext(tU);if(S===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:M,groupId:E,registerResizeHandle:T,startDragging:R,stopDragging:P,panelGroupElement:I}=S,L=CK(n),[z,U]=ee.useState("inactive"),[j,F]=ee.useState(!1),[G,H]=ee.useState(null),W=ee.useRef({state:z});$x(()=>{W.current.state=z}),ee.useEffect(()=>{if(i)H(null);else{const $=T(L);H(()=>$)}},[i,L,T]);const Q=(y=r==null?void 0:r.coarse)!==null&&y!==void 0?y:15,ne=(g=r==null?void 0:r.fine)!==null&&g!==void 0?g:5;ee.useEffect(()=>{if(i||G==null)return;const $=x.current;br($,"Element ref not attached");let J=!1;return pCt(L,$,M,{coarse:Q,fine:ne},(oe,xe,Z)=>{if(!xe){U("inactive");return}switch(oe){case"down":{U("drag"),J=!1,br(Z,'Expected event to be defined for "down" action'),R(L,Z);const{onDragging:ce,onPointerDown:me}=w.current;ce==null||ce(!0),me==null||me();break}case"move":{const{state:ce}=W.current;J=!0,ce!=="drag"&&U("hover"),br(Z,'Expected event to be defined for "move" action'),G(Z);break}case"up":{U("hover"),P();const{onClick:ce,onDragging:me,onPointerUp:he}=w.current;me==null||me(!1),he==null||he(),J||ce==null||ce();break}}})},[Q,M,i,ne,T,L,G,R,P]),PCt({disabled:i,handleId:L,resizeHandler:G,panelGroupElement:I});const se={touchAction:"none",userSelect:"none"};return ee.createElement(f,{...m,children:e,className:t,id:n,onBlur:()=>{F(!1),a==null||a()},onFocus:()=>{F(!0),l==null||l()},ref:x,role:"separator",style:{...se,...h},tabIndex:d,[Ha.groupDirection]:M,[Ha.groupId]:E,[Ha.resizeHandle]:"",[Ha.resizeHandleActive]:z==="drag"?"pointer":j?"keyboard":void 0,[Ha.resizeHandleEnabled]:!i,[Ha.resizeHandleId]:L,[Ha.resizeHandleState]:z})}NMe.displayName="PanelResizeHandle";function DCt(e,t){switch(e){case"pixel":return t?"group relative flex items-center justify-center cursor-col-resize":"group relative flex items-center justify-center cursor-row-resize";case"terminal":return t?"group relative flex items-center justify-center cursor-col-resize":"group relative flex items-center justify-center cursor-row-resize";case"modern":default:return t?"group relative flex items-center justify-center cursor-col-resize transition-all duration-200":"group relative flex items-center justify-center cursor-row-resize transition-all duration-200"}}function OCt(e,t){switch(e){case"pixel":return t?{width:"8px",background:"var(--pixel-surface, #222244)",borderLeft:"2px solid var(--pixel-border, #444477)",borderRight:"2px solid var(--pixel-border, #444477)"}:{height:"8px",background:"var(--pixel-surface, #222244)",borderTop:"2px solid var(--pixel-border, #444477)",borderBottom:"2px solid var(--pixel-border, #444477)"};case"terminal":return t?{width:"6px",background:"#0a0a0a",borderLeft:"1px solid #1a3a1a",borderRight:"1px solid #1a3a1a"}:{height:"6px",background:"#0a0a0a",borderTop:"1px solid #1a3a1a",borderBottom:"1px solid #1a3a1a"};case"modern":default:return t?{width:"4px",background:"rgba(100,100,100,0.15)",borderRadius:"2px"}:{height:"4px",background:"rgba(100,100,100,0.15)",borderRadius:"2px"}}}function RCt({theme:e,isHorizontal:t}){switch(e){case"pixel":{const i=t?{flexDirection:"column",gap:"3px"}:{flexDirection:"row",gap:"3px"};return C.jsx("div",{className:"flex",style:i,children:[0,1,2].map(r=>C.jsx("div",{style:{width:"2px",height:"2px",background:"var(--pixel-border-light, #5555aa)"},className:"group-hover:!bg-[var(--pixel-gold)]"},r))})}case"terminal":return t?C.jsxs("div",{className:"flex flex-col items-center gap-0 text-[8px] leading-none group-hover:text-[#00ff00]",style:{color:"#1a3a1a",fontFamily:"monospace"},children:[C.jsx("span",{children:"│"}),C.jsx("span",{children:"│"}),C.jsx("span",{children:"│"})]}):C.jsx("div",{className:"flex items-center gap-0 text-[8px] leading-none group-hover:text-[#00ff00]",style:{color:"#1a3a1a",fontFamily:"monospace"},children:C.jsx("span",{children:"═══"})});case"modern":default:{const i=t?{flexDirection:"column",gap:"2px"}:{flexDirection:"row",gap:"2px"};return C.jsx("div",{className:"flex opacity-0 group-hover:opacity-100 transition-opacity duration-200",style:i,children:[0,1,2].map(r=>C.jsx("div",{className:"rounded-full bg-white/20 group-hover:bg-blue-400/50",style:{width:"3px",height:"3px"}},r))})}}}function LMe({id:e,children:t}){return C.jsx(OK,{direction:"horizontal",autoSaveId:e,className:"flex-1 overflow-hidden",children:t})}function ICt({id:e,children:t}){return C.jsx(OK,{direction:"vertical",autoSaveId:e,className:"flex-1 flex flex-col overflow-hidden",children:t})}function Fv({defaultSize:e,minSize:t,maxSize:i,children:r,className:n,collapsible:a,collapsedSize:s,order:o}){return C.jsx(gMe,{defaultSize:e,minSize:t,maxSize:i,collapsible:a,collapsedSize:s,order:o,className:`overflow-hidden${n?` ${n}`:""}`,children:r})}function mC({direction:e="horizontal",disabled:t,className:i}){const r=Di(a=>a.theme);if(t)return null;const n=e==="horizontal";return C.jsx(NMe,{className:`${DCt(r,n)}${i?` ${i}`:""}`,style:OCt(r,n),children:C.jsx(RCt,{theme:r,isHorizontal:n})})}function RK({AgentDetail:e,ActivityFeed:t,FileWatcher:i,tabBarClass:r="flex border-b border-cam-border/50 bg-cam-surface/50",activeTabClass:n="text-cam-accent border-b-2 border-cam-accent",inactiveTabClass:a="text-cam-text-muted hover:text-cam-text",panelClass:s="flex-1 overflow-y-auto"}){const o=Ni(u=>u.selectedAgentId),[l,c]=ee.useState("activity");return o?C.jsx(e,{}):C.jsxs("div",{className:"h-full flex flex-col",children:[C.jsxs("div",{className:r,children:[C.jsx("button",{onClick:()=>c("activity"),className:`px-3 py-1.5 text-[10px] font-medium uppercase tracking-wider transition-colors ${l==="activity"?n:a}`,children:"Activity"}),C.jsx("button",{onClick:()=>c("files"),className:`px-3 py-1.5 text-[10px] font-medium uppercase tracking-wider transition-colors ${l==="files"?n:a}`,children:"Files"})]}),C.jsx("div",{className:s,children:l==="activity"?C.jsx(t,{}):C.jsx(i,{})})]})}const gpe="cam-in-process-dismissed";function NCt(){const e=Ni(r=>r.agents);return!Ni(r=>r.session)||e.length<2?!1:new Set(e.map(r=>r.sessionId)).size===1}function LCt(e){const[t,i]=ee.useState(()=>{if(!e)return!1;try{return localStorage.getItem(gpe)===e}catch{return!1}}),r=ee.useCallback(()=>{if(e)try{localStorage.setItem(gpe,e)}catch{}i(!0)},[e]);return[t,r]}function IK(){const e=NCt(),t=Ni(a=>a.session),[i,r]=LCt(t==null?void 0:t.id),{theme:n}=$P();if(!e||i)return null;switch(n){case"pixel":return C.jsx(zCt,{onDismiss:r});case"terminal":return C.jsx(BCt,{onDismiss:r});default:return C.jsx(kCt,{onDismiss:r})}}function kCt({onDismiss:e}){return C.jsxs("div",{className:"h-8 flex items-center justify-between px-4 bg-amber-500/10 border-b border-amber-500/30 shrink-0",children:[C.jsxs("div",{className:"flex items-center gap-2",children:[C.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 animate-pulse"}),C.jsx("span",{className:"text-xs text-amber-300",children:"In-process mode detected — per-agent tracking is limited. Use tmux + Teams for full E2E tracking."})]}),C.jsx("button",{onClick:e,className:"text-amber-400/60 hover:text-amber-300 text-xs px-1",title:"Dismiss",children:"×"})]})}function zCt({onDismiss:e}){return C.jsxs("div",{className:"h-8 flex items-center justify-between px-4 shrink-0",style:{background:"rgba(255, 170, 0, 0.1)",borderBottom:"2px solid var(--pixel-gold, #d4a017)"},children:[C.jsx("div",{className:"flex items-center gap-2",children:C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-gold, #d4a017)"},children:"! IN-PROCESS MODE - PER-AGENT TRACKING LIMITED. USE TMUX + TEAMS FOR FULL TRACKING."})}),C.jsx("button",{onClick:e,className:"pixel-text-xs px-1",style:{color:"var(--pixel-gold, #d4a017)",opacity:.6},title:"Dismiss",children:"X"})]})}function BCt({onDismiss:e}){return C.jsxs("div",{className:"h-8 flex items-center justify-between px-3 bg-[#1a1a00] border-b border-[#3a3a1a] shrink-0 font-mono text-[11px]",children:[C.jsx("div",{className:"flex items-center gap-2",children:C.jsx("span",{className:"text-[#ffaa00]",children:"[WARN] in-process mode: per-agent tracking limited. use tmux + teams for full e2e tracking."})}),C.jsx("button",{onClick:e,className:"text-[#ffaa00]/60 hover:text-[#ffaa00] px-1",title:"Dismiss",children:"[x]"})]})}function UCt(){const{connectionStatus:e,session:t}=Ni();if(t&&t.status!=="active"){const r=t.status==="error";return C.jsxs("div",{className:"flex items-center gap-1.5",children:[C.jsx("div",{className:`w-2 h-2 rounded-full ${r?"bg-cam-error":"bg-gray-400"}`}),C.jsx("span",{className:`text-xs ${r?"text-cam-error":"text-cam-text-muted"}`,children:r?"Session error":"Session ended"})]})}const i={connected:{dotClass:"bg-cam-success animate-pulse-dot",textClass:"text-cam-success",label:"Connected",sublabel:"capturing events"},reconnecting:{dotClass:"bg-amber-400 animate-pulse",textClass:"text-amber-400",label:"Reconnecting...",sublabel:""},disconnected:{dotClass:"bg-cam-error",textClass:"text-cam-error",label:"Disconnected",sublabel:"waiting for server"}}[e];return C.jsxs("div",{className:"flex items-center gap-1.5",children:[C.jsx("div",{className:`w-2 h-2 rounded-full ${i.dotClass}`}),C.jsx("span",{className:`text-xs ${i.textClass}`,children:i.label}),i.sublabel&&C.jsxs("span",{className:"text-xs text-cam-text-muted",children:["- ",i.sublabel]})]})}function jCt(){const{viewMode:e}=_n();return C.jsxs("div",{className:"h-full w-full flex flex-col modern-gradient-bg overflow-hidden",children:[C.jsxs("header",{className:"h-12 flex items-center justify-between px-4 border-b border-cam-border/50 modern-glass shrink-0 relative z-50",children:[C.jsxs("div",{className:"flex items-center gap-3",children:[C.jsx("h1",{className:"text-sm font-semibold text-cam-text tracking-tight",children:"Claude Agent Monitor"}),C.jsx(UCt,{})]}),C.jsxs("div",{className:"flex items-center gap-3",children:[C.jsx(RX,{}),C.jsx(RHe,{})]})]}),C.jsx(VEe,{}),C.jsx(IK,{}),C.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[e==="agents"&&C.jsx(FCt,{}),e==="tracker"&&C.jsx(VCt,{})]})]})}function FCt(){const e=Di(t=>t.lockPanels);return C.jsxs(LMe,{id:"modern-agents",children:[C.jsx(Fv,{defaultSize:20,minSize:10,maxSize:25,order:1,children:C.jsx("aside",{className:"h-full overflow-y-auto modern-scrollbar",children:C.jsx(nTe,{})})}),C.jsx(mC,{disabled:e}),C.jsx(Fv,{defaultSize:55,minSize:30,order:2,children:C.jsx("main",{className:"h-full overflow-hidden",children:C.jsx(MK,{})})}),C.jsx(mC,{disabled:e}),C.jsx(Fv,{defaultSize:25,minSize:15,maxSize:40,order:3,children:C.jsx("aside",{className:"h-full modern-scrollbar",children:C.jsx(RK,{AgentDetail:k3e,ActivityFeed:I3e,FileWatcher:B3e})})})]})}function VCt(){const{selectedTaskId:e}=_n(),t=Di(i=>i.lockPanels);return C.jsxs(ICt,{id:"modern-tracker",children:[C.jsx(Fv,{defaultSize:75,minSize:50,order:1,children:C.jsxs(LMe,{id:e?"modern-tracker-top-detail":"modern-tracker-top",children:[C.jsx(Fv,{defaultSize:e?55:70,minSize:30,order:1,children:C.jsx("main",{className:"h-full overflow-hidden",children:C.jsx(F3e,{})})}),e&&C.jsxs(C.Fragment,{children:[C.jsx(mC,{disabled:t}),C.jsx(Fv,{defaultSize:20,minSize:15,maxSize:35,order:2,children:C.jsx("aside",{className:"h-full overflow-y-auto modern-scrollbar",children:C.jsx(EK,{})})})]}),C.jsx(mC,{disabled:t}),C.jsx(Fv,{defaultSize:e?25:30,minSize:15,maxSize:40,order:3,children:C.jsxs("aside",{className:"h-full overflow-y-auto modern-scrollbar flex flex-col",children:[C.jsx(H3e,{}),C.jsx(AHe,{}),C.jsx(OHe,{})]})})]})}),C.jsx(mC,{direction:"vertical",disabled:t}),C.jsx(Fv,{defaultSize:25,minSize:10,maxSize:40,order:2,children:C.jsx("div",{className:"h-full overflow-y-auto modern-scrollbar",children:C.jsx(MHe,{})})})]})}function HCt(){const{session:e,agents:t,events:i}=Ni(),[r,n]=ee.useState("00m 00s");ee.useEffect(()=>{if(!(e!=null&&e.startedAt))return;const u=()=>n(H7(e.startedAt,e.endedAt));if(u(),!e.endedAt){const h=setInterval(u,1e3);return()=>clearInterval(h)}},[e==null?void 0:e.startedAt,e==null?void 0:e.endedAt]);const a=t.filter(u=>u.status==="active").length,s=t.reduce((u,h)=>u+h.errorCount,0),o=t.reduce((u,h)=>u+h.toolCallCount,0),l=i.filter(u=>u.category==="file_change").length,c=[{label:"TIME",value:r,isError:!1},{label:"AGENTS",value:`${a}/${t.length}`,isError:!1},{label:"CALLS",value:Lm(o),isError:!1},{label:"EVENTS",value:Lm((e==null?void 0:e.eventCount)??0),isError:!1},{label:"FILES",value:Lm(l),isError:!1},{label:"ERRORS",value:String(s),isError:s>0}];return C.jsx("div",{className:"shrink-0 border-b border-[#1a3a1a] px-2 py-1 font-mono text-[11px]",children:C.jsxs("div",{className:"flex items-center gap-0",children:[C.jsx("span",{className:"terminal-dim mr-2",children:"["}),c.map((u,h)=>C.jsxs("span",{className:"flex items-center",children:[h>0&&C.jsx("span",{className:"terminal-dim mx-1",children:"|"}),C.jsxs("span",{className:"terminal-muted",children:[u.label,":"]}),C.jsx("span",{className:`ml-1 font-bold ${u.isError?"terminal-error":"text-[#00ff00] terminal-glow"}`,children:u.value})]},u.label)),C.jsx("span",{className:"terminal-dim ml-2",children:"]"})]})})}const GCt={active:"[*]",idle:"[-]",error:"[!]",completed:"[+]",shutdown:"[x]"},WCt={active:"text-[#00ff00]",idle:"text-[#ffaa00]",error:"text-[#ff3333]",completed:"text-[#00ccff]",shutdown:"text-[#006600]"};function qCt(e){return e.status==="active"}function XCt(){const e=$7(),{selectedAgentId:t,selectAgent:i}=Ni(),[r,n]=ee.useState(!1),{activeAgents:a,inactiveAgents:s}=ee.useMemo(()=>{const o=[],l=[];for(const c of e)qCt(c)?o.push(c):l.push(c);return{activeAgents:o,inactiveAgents:l}},[e]);return e.length===0?C.jsxs("div",{className:"p-3 font-mono text-[11px]",children:[C.jsx("div",{className:"terminal-muted mb-2",children:"## AGENTS ##"}),C.jsxs("div",{className:"terminal-dim",children:[C.jsx("p",{children:"> Waiting for agents..."}),C.jsx("p",{className:"mt-1 terminal-cursor",children:"> "})]})]}):C.jsxs("div",{className:"p-2 font-mono text-[11px]",children:[C.jsx("div",{className:"terminal-muted mb-1 px-1",children:"## ACTIVE ("+a.length+") ##"}),C.jsx("div",{className:"border-t border-[#1a3a1a] mb-1"}),a.length>0?C.jsx("div",{className:"space-y-0.5",children:a.map(o=>C.jsx(vpe,{agent:o,isSelected:t===o.id,onSelect:()=>i(t===o.id?null:o.id)},o.id))}):C.jsx("div",{className:"px-1 py-1 terminal-dim",children:"> No active agents"}),s.length>0&&C.jsxs("div",{className:"mt-2",children:[C.jsxs("button",{onClick:()=>n(!r),className:"w-full text-left px-1 py-0.5 hover:bg-[#0a1a0a] transition-colors",children:[C.jsxs("span",{className:"terminal-dim",children:[r?"[-]":"[+]"," "]}),C.jsx("span",{className:"terminal-muted",children:"INACTIVE ("+s.length+")"})]}),r&&C.jsxs(C.Fragment,{children:[C.jsx("div",{className:"border-t border-[#1a3a1a] mb-1 mt-1"}),C.jsx("div",{className:"space-y-0.5",children:s.map(o=>C.jsx(vpe,{agent:o,isSelected:t===o.id,onSelect:()=>i(t===o.id?null:o.id),compact:!0},o.id))})]})]})]})}function vpe({agent:e,isSelected:t,onSelect:i,compact:r=!1}){const n=Ch(e.id,e.name,e.type??void 0),a=GCt[e.status]||"[ ]",s=WCt[e.status]||"terminal-dim";return r?C.jsx("button",{onClick:i,title:`${e.name} (${e.id})`,className:`
|
|
12436
12436
|
w-full text-left px-1 py-0.5 font-mono text-[10px] transition-colors
|
|
12437
12437
|
${t?"bg-[#0a1f0a] border-l-2 border-[#00ff00]":"hover:bg-[#0d1a0d] border-l-2 border-transparent"}
|
|
12438
12438
|
`,children:C.jsxs("div",{className:"flex items-center gap-1",children:[C.jsx("span",{className:`${s} shrink-0`,children:a}),C.jsx("span",{className:"terminal-dim truncate",children:n}),C.jsxs("span",{className:"text-[#006600] shrink-0",children:["[",e.type,"]"]}),C.jsxs("span",{className:"terminal-dim shrink-0",children:["c:",e.toolCallCount]}),C.jsx("span",{className:"terminal-dim shrink-0",children:qc(e.lastActivityAt)})]})}):C.jsxs("button",{onClick:i,title:`${e.name} (${e.id})`,className:`
|
|
@@ -12441,5 +12441,5 @@ No matching component was found for:
|
|
|
12441
12441
|
`,children:[C.jsxs("div",{className:"flex items-center gap-1",children:[C.jsx("span",{className:`${s} shrink-0 ${e.status==="active"?"terminal-glow":""}`,children:a}),C.jsx("span",{className:`truncate ${t?"text-[#00ff00] terminal-glow":"text-[#00cc00]"}`,children:n}),C.jsxs("span",{className:"text-[#006600] shrink-0",children:["[",e.type,"]"]})]}),C.jsxs("div",{className:"flex items-center gap-2 ml-4 mt-0.5",children:[C.jsxs("span",{className:"terminal-dim",children:["calls:",e.toolCallCount]}),e.errorCount>0&&C.jsxs("span",{className:"terminal-error",children:["err:",e.errorCount]}),C.jsx("span",{className:"terminal-dim ml-auto",children:qc(e.lastActivityAt)})]})]})}const kMe=new Set(["TaskList","TaskGet"]);function YCt(e){const t=[];let i=0;for(;i<e.length;){const r=e[i];if(r.tool&&kMe.has(r.tool)){let n=1;for(;i+n<e.length&&e[i+n].tool===r.tool&&e[i+n].agentId===r.agentId;)n++;t.push({event:r,count:n,groupId:`grp-${r.id}`}),i+=n}else t.push({event:r,count:1,groupId:r.id}),i++}return t}const $Ct={Edit:"EDT",Write:"WRT",Read:"RD ",Bash:"SH ",Grep:"GRP",Glob:"GLB",TaskCreate:"T+ ",TaskUpdate:"T~ ",TaskList:"TL ",SendMessage:"MSG",WebFetch:"GET",WebSearch:"WEB"},KCt={tool_call:"TOOL",file_change:"FILE",command:"CMD ",message:"MSG ",lifecycle:"SYS ",error:"ERR ",compact:"CMP ",notification:"NTF "};function QCt(){const e=Dq(),t=Ni(m=>m.agents),{searchQuery:i,setSearchQuery:r}=az(),n=Di(m=>m.followMode),a=Di(m=>m.hidePolling),s=Di(m=>m.toggleFollowMode),o=Di(m=>m.toggleHidePolling),l=ee.useRef(null),[c,u]=ee.useState(null),h=ee.useMemo(()=>{const m=new Map;for(const y of t)m.set(y.id,Ch(y.id,y.name||y.id,y.type??void 0));return m},[t]);ee.useEffect(()=>{n&&l.current&&(l.current.scrollTop=0)},[e.length,n]);const d=ee.useMemo(()=>{let m=e;if(a&&(m=m.filter(y=>!y.tool||!kMe.has(y.tool))),i){const y=i.toLowerCase();m=m.filter(g=>{var x,w,S,M;return((x=g.tool)==null?void 0:x.toLowerCase().includes(y))||((w=g.filePath)==null?void 0:w.toLowerCase().includes(y))||((S=g.input)==null?void 0:S.toLowerCase().includes(y))||((M=g.output)==null?void 0:M.toLowerCase().includes(y))})}return m},[e,a,i]),f=ee.useMemo(()=>YCt(d),[d]);return C.jsxs("div",{className:"h-full flex flex-col font-mono text-[11px]",children:[C.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-[#1a3a1a] shrink-0",children:[C.jsx("span",{className:"terminal-muted",children:"## tail -f activity.log ("+d.length+" lines) ##"}),C.jsxs("div",{className:"flex items-center gap-2",children:[C.jsxs("div",{className:"flex items-center",children:[C.jsx("span",{className:"terminal-dim mr-1",children:"grep:"}),C.jsx("input",{type:"text",placeholder:"...",value:i,onChange:m=>r(m.target.value),className:"w-24 bg-[#0d0d0d] border border-[#1a3a1a] px-1.5 py-0.5 text-[11px] text-[#00ff00] font-mono placeholder:text-[#003300] focus:outline-none focus:border-[#00aa00]"})]}),C.jsx("button",{onClick:o,className:`px-2 py-0.5 font-mono text-[10px] border ${a?"bg-[#1f1f0a] text-[#ffaa00] border-[#aa7700]":"bg-[#0d0d0d] text-[#006600] border-[#1a3a1a]"}`,title:"Hide TaskList/TaskGet polling",children:a?"[P]oll:OFF":"[P]oll"}),C.jsx("button",{onClick:s,className:`px-2 py-0.5 font-mono text-[10px] border ${n?"bg-[#0a1f0a] text-[#00ff00] border-[#00aa00] terminal-glow":"bg-[#0d0d0d] text-[#006600] border-[#1a3a1a]"}`,children:n?"[F]ollow:ON":"[F]ollow:OFF"})]})]}),C.jsx("div",{ref:l,className:"flex-1 overflow-y-auto terminal-scrollbar",children:d.length===0?C.jsx("div",{className:"p-4 text-center",children:C.jsxs("div",{className:"terminal-dim",children:[C.jsx("p",{children:"> No activity logged"}),C.jsx("p",{children:"> Waiting for events..."}),C.jsx("p",{className:"mt-2 terminal-cursor",children:"> "})]})}):C.jsx("div",{children:f.map(({event:m,count:y,groupId:g})=>C.jsx(ZCt,{event:m,agentNameMap:h,isExpanded:c===m.id,groupCount:y,onToggle:()=>u(c===m.id?null:m.id)},g))})})]})}function ZCt({event:e,agentNameMap:t,isExpanded:i,groupCount:r,onToggle:n}){const[a,s]=ee.useState(!1),o=$Ct[e.tool||""]||"...",l=KCt[e.category]||"??? ",c=e.category==="error"||!!e.error,u=t.get(e.agentId)??e.agentId.slice(0,8),h=sz(e.tool||e.hookType);return C.jsxs("div",{className:`px-3 py-0.5 hover:bg-[#0a1a0a] cursor-pointer transition-colors border-l-2 ${c?"border-[#ff3333]":i?"border-[#00ff00]":"border-transparent"}`,onClick:n,children:[C.jsxs("div",{className:"flex items-center gap-0 whitespace-nowrap overflow-hidden",children:[C.jsx("span",{className:"terminal-dim shrink-0 w-[60px]",children:gu(e.timestamp)}),C.jsx("span",{className:`shrink-0 w-[36px] ml-1 ${c?"terminal-error":"terminal-muted"}`,children:l}),C.jsx("span",{className:"shrink-0 w-[28px] ml-1 text-[#00ccff]",title:h,children:o}),r&&r>1&&C.jsxs("span",{className:"shrink-0 ml-1 text-[#ffaa00]",children:["x",r]}),C.jsxs("span",{className:"terminal-dim shrink-0 ml-1",title:e.agentId,children:["[",u,"]"]}),e.filePath&&C.jsx("span",{className:"text-[#00aa00] ml-2 truncate",title:e.filePath,children:Ah(e.filePath)}),e.error&&C.jsx("span",{className:"terminal-error ml-2 truncate",title:e.error,children:e.error}),e.duration!==void 0&&C.jsxs("span",{className:"terminal-dim ml-auto shrink-0 pl-2",children:[e.duration,"ms"]})]}),i&&C.jsxs("div",{className:"ml-4 mt-1 mb-1 border-l border-[#1a3a1a] pl-2",onClick:d=>d.stopPropagation(),children:[e.input&&C.jsxs("div",{className:"mb-1",children:[C.jsx("span",{className:"terminal-muted",children:">>> INPUT:"}),a?C.jsx("pre",{className:"text-[10px] text-[#00aa00] whitespace-pre-wrap break-all mt-0.5 max-h-28 overflow-y-auto terminal-scrollbar bg-[#050505] p-1 border border-[#1a3a1a]",children:e.input}):C.jsx("pre",{className:"text-[10px] text-[#00aa00] whitespace-pre-wrap break-all mt-0.5 max-h-28 overflow-y-auto terminal-scrollbar bg-[#050505] p-1 border border-[#1a3a1a]",children:Oq(e.tool,e.input)})]}),e.output&&C.jsxs("div",{className:"mb-1",children:[C.jsx("span",{className:"terminal-muted",children:"<<< OUTPUT:"}),a?C.jsx("pre",{className:"text-[10px] text-[#00aa00] whitespace-pre-wrap break-all mt-0.5 max-h-28 overflow-y-auto terminal-scrollbar bg-[#050505] p-1 border border-[#1a3a1a]",children:e.output}):C.jsx("pre",{className:"text-[10px] text-[#00aa00] whitespace-pre-wrap break-all mt-0.5 max-h-28 overflow-y-auto terminal-scrollbar bg-[#050505] p-1 border border-[#1a3a1a]",children:Rq(e.output)})]}),C.jsxs("div",{className:"flex items-center gap-2",children:[e.duration!==void 0&&C.jsx("span",{className:"terminal-dim text-[10px]",children:"--- duration: "+e.duration+"ms ---"}),(e.input||e.output)&&C.jsx("button",{onClick:d=>{d.stopPropagation(),s(!a)},className:"text-[9px] px-1 py-0.5 border border-[#1a3a1a] hover:border-[#00aa00] text-[#006600] hover:text-[#00ff00] transition-colors",children:a?"[SUMMARY]":"[RAW]"})]})]})]})}const JCt=[{id:"activity",label:"Activity",key:"1"},{id:"files",label:"Files",key:"2"},{id:"errors",label:"Errors",key:"3"},{id:"messages",label:"Messages",key:"4"}],ePt={active:"[ACTIVE]",idle:"[IDLE] ",error:"[ERROR] ",completed:"[DONE] ",shutdown:"[DOWN] "};function tPt(){const{selectedAgentId:e,agents:t,events:i,selectAgent:r}=Ni(),[n,a]=ee.useState("activity"),s=t.find(d=>d.id===e);if(!s)return null;const o=i.filter(d=>d.agentId===s.id),l=o.filter(d=>d.category==="error"||d.error),c=o.filter(d=>d.filePath).reduce((d,f)=>(f.filePath&&!d.includes(f.filePath)&&d.push(f.filePath),d),[]),u=o.filter(d=>d.category==="message"),h=ePt[s.status]||"[???] ";return C.jsxs("div",{className:"h-full flex flex-col font-mono text-[11px]",children:[C.jsxs("div",{className:"p-2 border-b border-[#1a3a1a] shrink-0",children:[C.jsxs("div",{className:"flex items-center justify-between mb-1",children:[C.jsx("span",{className:"text-[#00ff00] terminal-glow font-bold",title:`${s.name} (${s.id})`,children:">> "+Ch(s.id,s.name,s.type??void 0)}),C.jsx("button",{onClick:()=>r(null),className:"text-[#006600] hover:text-[#ff3333] transition-colors",children:"[X]"})]}),C.jsxs("div",{className:"terminal-dim",children:[C.jsx("span",{className:s.status==="active"?"text-[#00ff00]":s.status==="error"?"terminal-error":"terminal-muted",children:h}),C.jsx("span",{className:"ml-2",children:s.type})]}),C.jsxs("div",{className:"mt-2 border border-[#1a3a1a] p-1.5",children:[C.jsx("div",{className:"text-[10px] terminal-dim mb-1",children:"┌── STATS ──────────────┐"}),C.jsxs("div",{className:"grid grid-cols-3 gap-x-2 text-[10px]",children:[C.jsxs("div",{children:[C.jsx("span",{className:"terminal-dim",children:"calls:"}),C.jsx("span",{className:"text-[#00ff00] ml-1",children:s.toolCallCount})]}),C.jsxs("div",{children:[C.jsx("span",{className:"terminal-dim",children:"errs:"}),C.jsx("span",{className:`ml-1 ${s.errorCount>0?"terminal-error":"text-[#00ff00]"}`,children:s.errorCount})]}),C.jsxs("div",{children:[C.jsx("span",{className:"terminal-dim",children:"last:"}),C.jsx("span",{className:"text-[#00aa00] ml-1",children:qc(s.lastActivityAt)})]})]}),C.jsx("div",{className:"text-[10px] terminal-dim mt-1",children:"└──────────────────────┘"})]})]}),C.jsx("div",{className:"flex border-b border-[#1a3a1a] shrink-0",children:JCt.map(d=>{const f=d.id==="activity"?o.length:d.id==="files"?c.length:d.id==="errors"?l.length:u.length;return C.jsxs("button",{onClick:()=>a(d.id),className:`flex-1 py-1.5 text-[10px] font-mono transition-colors border-b ${n===d.id?"text-[#00ff00] border-[#00ff00] bg-[#0a1f0a] terminal-glow":"text-[#006600] border-transparent hover:text-[#00aa00]"}`,children:["[",d.key,"]",d.label,"(",f,")"]},d.id)})}),C.jsxs("div",{className:"flex-1 overflow-y-auto terminal-scrollbar",children:[n==="activity"&&C.jsx("div",{children:o.length===0?C.jsx("p",{className:"terminal-dim p-3 text-center",children:"> No activity recorded"}):o.slice(0,100).map(d=>C.jsx("div",{className:"px-2 py-0.5 hover:bg-[#0a1a0a] transition-colors border-b border-[#0a1a0a]",children:C.jsxs("div",{className:"flex items-center gap-2",children:[C.jsx("span",{className:"terminal-dim shrink-0 text-[10px]",children:gu(d.timestamp)}),C.jsx("span",{className:`text-[10px] ${d.category==="error"?"terminal-error":"text-[#00ccff]"}`,children:d.tool||d.hookType}),d.filePath&&C.jsx("span",{className:"text-[#00aa00] text-[10px]",title:d.filePath,children:Ah(d.filePath)})]})},d.id))}),n==="files"&&C.jsx("div",{className:"p-2",children:c.length===0?C.jsx("p",{className:"terminal-dim text-center",children:"> No files touched"}):c.map((d,f)=>{const y=f===c.length-1?"└─":"├─";return C.jsxs("div",{className:"flex items-center gap-1 py-0.5 hover:bg-[#0a1a0a]",children:[C.jsx("span",{className:"terminal-dim",children:y}),C.jsx("span",{className:"text-[#00aa00] text-[10px] break-all",title:d,children:Ah(d)})]},d)})}),n==="errors"&&C.jsx("div",{children:l.length===0?C.jsx("p",{className:"terminal-dim p-3 text-center",children:"> No errors - all clear"}):l.map(d=>C.jsxs("div",{className:"px-2 py-1 border-b border-[#1a0a0a]",children:[C.jsxs("div",{className:"flex items-center gap-2",children:[C.jsx("span",{className:"terminal-dim text-[10px]",children:gu(d.timestamp)}),C.jsx("span",{className:"terminal-error text-[10px]",children:d.tool||d.hookType})]}),d.error&&C.jsx("p",{className:"terminal-error text-[10px] ml-2 mt-0.5 break-all",children:"! "+d.error})]},d.id))}),n==="messages"&&C.jsx("div",{children:u.length===0?C.jsx("p",{className:"terminal-dim p-3 text-center",children:"> No messages"}):u.map(d=>C.jsxs("div",{className:"px-2 py-1 border-b border-[#0a1a0a]",children:[C.jsxs("div",{className:"flex items-center gap-2",children:[C.jsx("span",{className:"terminal-dim text-[10px]",children:gu(d.timestamp)}),C.jsx("span",{className:"terminal-info text-[10px]",children:"SendMessage"})]}),d.input&&C.jsx("p",{className:"text-[#00aa00] text-[10px] ml-2 mt-0.5 break-words whitespace-pre-wrap",children:"> "+d.input})]},d.id))})]})]})}const iPt={created:{symbol:"+",color:"text-[#00ff00]"},modified:{symbol:"~",color:"text-[#ffaa00]"},read:{symbol:".",color:"text-[#00ccff]"}};function rPt(){const{session:e}=Ni(),[t,i]=ee.useState([]);ee.useEffect(()=>{if(!(e!=null&&e.id))return;let s=!1;async function o(){try{const{files:c}=await X7(e.id);s||i(c)}catch{}}o();const l=setInterval(o,5e3);return()=>{s=!0,clearInterval(l)}},[e==null?void 0:e.id]);const r=t.filter(s=>s.changeType==="created"),n=t.filter(s=>s.changeType==="modified"),a=t.filter(s=>s.changeType==="read");return C.jsxs("div",{className:"p-2 h-full flex flex-col font-mono text-[11px]",children:[C.jsxs("div",{className:"flex items-center justify-between mb-1 px-1",children:[C.jsx("span",{className:"terminal-muted",children:"## tree --files ##"}),C.jsxs("div",{className:"flex items-center gap-2 text-[10px]",children:[C.jsxs("span",{className:"text-[#00ff00]",children:["+",r.length]}),C.jsxs("span",{className:"text-[#ffaa00]",children:["~",n.length]}),C.jsxs("span",{className:"text-[#00ccff]",children:[".",a.length]})]})]}),C.jsx("div",{className:"border-t border-[#1a3a1a] mb-1"}),t.length===0?C.jsx("div",{className:"flex-1 flex items-center justify-center",children:C.jsxs("div",{className:"terminal-dim text-center",children:[C.jsx("p",{children:"> No files touched"}),C.jsx("p",{className:"terminal-cursor mt-1",children:"> "})]})}):C.jsx("div",{className:"flex-1 overflow-y-auto terminal-scrollbar space-y-0",children:t.map((s,o)=>{const l=o===t.length-1,c=iPt[s.changeType]||{symbol:"?",color:"terminal-dim"},u=l?"└──":"├──";return C.jsxs("div",{className:"flex items-center gap-0 px-1 py-0.5 hover:bg-[#0a1a0a] transition-colors",children:[C.jsx("span",{className:"terminal-dim shrink-0 w-[28px]",children:u}),C.jsx("span",{className:`shrink-0 w-[12px] font-bold ${c.color}`,children:c.symbol}),C.jsx("span",{className:"text-[#00aa00] flex-1 ml-1",title:s.filePath,children:Ah(s.filePath)}),s.touchCount>1&&C.jsxs("span",{className:"terminal-dim shrink-0 ml-1",children:["x",s.touchCount]}),C.jsx("span",{className:"terminal-dim shrink-0 ml-2 text-[10px]",children:qc(s.lastTouchedAt)})]},`${s.filePath}-${s.agentId}`)})})]})}const nPt={backlog:".",planned:"-",in_progress:"*",in_review:"?",completed:"+",blocked:"!"},aPt={backlog:"terminal-dim",planned:"text-[#00ccff]",in_progress:"text-[#00ff00]",in_review:"terminal-muted",completed:"text-[#00ff00]",blocked:"terminal-error"},sPt={critical:"!!!",high:"!! ",medium:"! ",low:". "};function oPt(){const e=T0(),t=r=>r==="pending"?"planned":r==="deferred"?"backlog":r==="in_review"||r==="blocked"?"in_progress":r,i=K_.reduce((r,n)=>(r[n.id]=e.filter(a=>t(a.status)===n.id),r),{});return e.length===0?C.jsx("div",{className:"h-full flex flex-col items-center justify-center font-mono text-[11px]",children:C.jsx("div",{className:"terminal-dim text-center",children:C.jsx("pre",{className:"text-[10px]",children:`┌────────────────────────┐
|
|
12442
12442
|
│ No PRD tasks loaded │
|
|
12443
12443
|
│ Import a PRD first │
|
|
12444
|
-
└────────────────────────┘`})})}):C.jsx("div",{className:"h-full flex gap-1 p-2 overflow-x-auto terminal-scrollbar font-mono text-[11px]",children:K_.map(r=>{const n=i[r.id]||[],a=aPt[r.id]||"terminal-dim",s=nPt[r.id]||" ";return C.jsxs("div",{className:"flex-shrink-0 w-52 flex flex-col border border-[#1a3a1a] bg-[#0a0a0a]",children:[C.jsx("div",{className:"px-2 py-1 border-b border-[#1a3a1a] shrink-0",children:C.jsxs("div",{className:"flex items-center justify-between",children:[C.jsxs("span",{className:`text-[10px] font-bold uppercase ${a}`,children:["[",s,"] ",r.label]}),C.jsxs("span",{className:"terminal-dim text-[10px]",children:["(",n.length,")"]})]})}),C.jsx("div",{className:"flex-1 overflow-y-auto terminal-scrollbar p-1 space-y-1",children:n.map(o=>C.jsx(lPt,{task:o},o.id))})]},r.id)})})}function lPt({task:e}){const{selectTask:t,selectedTaskId:i}=_n(),r=oz(),n=sPt[e.priority]||" ",a=W7(e.prdSection);return C.jsxs("div",{className:`terminal-card p-1.5 text-[10px] cursor-pointer ${i===e.id?"border border-[#00ccff]":""}`,onClick:()=>t(e.id),children:[C.jsxs("div",{className:"flex items-center gap-1 mb-0.5",children:[C.jsx("span",{className:`${e.priority==="critical"||e.priority==="high"?"terminal-error":"terminal-dim"}`,children:n}),e.complexity&&C.jsxs("span",{className:"terminal-dim",children:["C",e.complexity]}),a&&C.jsxs("span",{className:"text-[#00ff00]",children:["[",a,"]"]})]}),C.jsx("div",{className:"text-[#00cc00] leading-tight mb-1 line-clamp-2",children:e.title}),C.jsxs("div",{className:"flex items-center justify-between terminal-dim",children:[e.assignedAgent?C.jsxs("span",{children:["@",r(e.assignedAgent)]}):C.jsx("span",{className:"italic",children:"unassigned"}),e.tags&&e.tags.length>0&&C.jsxs("span",{children:["#",e.tags[0]]})]}),e.blockedBy.length>0&&C.jsx("div",{className:"terminal-error mt-0.5",children:"! blocked by "+e.blockedBy.length+" task"+(e.blockedBy.length>1?"s":"")})]})}function cPt(e,t=20){const i=Math.round(e/100*t),r=t-i;return"["+("█".repeat(i)+"░".repeat(r))+"] "+e+"%"}function uPt(){const{activeSprint:e}=lz(),t=T0(),i=ee.useMemo(()=>{if(!e)return{total:0,completed:0,inProgress:0,blocked:0,pending:0,percent:0};const r=t.filter(u=>u.sprintId===e.id),n=r.length||e.totalTasks||0,a=r.filter(u=>u.status==="completed").length,s=r.filter(u=>u.status==="in_progress").length,o=r.filter(u=>u.status==="blocked").length,l=n-a-s-o,c=n>0?Math.round(a/n*100):0;return{total:n,completed:a,inProgress:s,blocked:o,pending:l,percent:c}},[e,t]);return e?C.jsxs("div",{className:"p-3 border-b border-[#1a3a1a] font-mono text-[11px]",children:[C.jsxs("div",{className:"flex items-center justify-between mb-2",children:[C.jsx("span",{className:"terminal-muted",children:"## SPRINT ##"}),C.jsx("span",{className:"text-[#00ccff] text-[10px]",children:e.name})]}),C.jsx("div",{className:"text-[#00ff00] terminal-glow mb-2",children:cPt(i.percent,24)}),C.jsxs("div",{className:"space-y-0.5 text-[10px]",children:[C.jsxs("div",{className:"flex items-center gap-2",children:[C.jsx("span",{className:"text-[#00ff00] w-[12px]",children:"+"}),C.jsx("span",{className:"terminal-dim flex-1",children:"Completed"}),C.jsx("span",{className:"text-[#00ff00]",children:i.completed})]}),C.jsxs("div",{className:"flex items-center gap-2",children:[C.jsx("span",{className:"text-[#00ccff] w-[12px]",children:"*"}),C.jsx("span",{className:"terminal-dim flex-1",children:"In Progress"}),C.jsx("span",{className:"text-[#00ccff]",children:i.inProgress})]}),C.jsxs("div",{className:"flex items-center gap-2",children:[C.jsx("span",{className:"terminal-muted w-[12px]",children:"-"}),C.jsx("span",{className:"terminal-dim flex-1",children:"Pending"}),C.jsx("span",{className:"terminal-muted",children:i.pending})]}),C.jsxs("div",{className:"flex items-center gap-2",children:[C.jsx("span",{className:"terminal-error w-[12px]",children:"!"}),C.jsx("span",{className:"terminal-dim flex-1",children:"Blocked"}),C.jsx("span",{className:i.blocked>0?"terminal-error":"terminal-dim",children:i.blocked})]}),C.jsxs("div",{className:"border-t border-[#1a3a1a] mt-1 pt-1 flex items-center gap-2",children:[C.jsx("span",{className:"terminal-dim w-[12px]",children:"="}),C.jsx("span",{className:"terminal-dim flex-1",children:"Total"}),C.jsx("span",{className:"text-[#00ff00]",children:i.total})]})]})]}):C.jsx("div",{className:"p-3 font-mono text-[11px]",children:C.jsx("span",{className:"terminal-dim",children:"> No active sprint"})})}function hPt(){const{activeSprint:e,tasks:t}=_n(),[i,r]=ee.useState("burndown"),{chart:n,maxVal:a}=ee.useMemo(()=>{if(!e)return{chart:[],maxVal:0};const c=t.filter(w=>w.sprintId===e.id),u=c.length;if(u===0)return{chart:[],maxVal:0};const h=c.filter(w=>w.completedAt).sort((w,S)=>new Date(w.completedAt).getTime()-new Date(S.completedAt).getTime()),d=e.startedAt?new Date(e.startedAt).getTime():Date.now()-36e5,m=Date.now()-d,y=10,g=[];for(let w=0;w<=y;w++){const S=d+m/y*w,M=h.filter(P=>new Date(P.completedAt).getTime()<=S).length,E=new Date(S).getHours(),T=new Date(S).getMinutes(),R=`${String(E).padStart(2,"0")}:${String(T).padStart(2,"0")}`;i==="burndown"?g.push({label:R,actual:u-M,ideal:Math.max(0,Math.round(u-u/y*w))}):g.push({label:R,actual:M,ideal:Math.round(u/y*w)})}const x=Math.max(u,...g.map(w=>Math.max(w.actual,w.ideal)));return{chart:g,maxVal:x}},[e,t,i]);if(!e||n.length===0)return C.jsxs("div",{className:"p-3 border-b border-[#1a3a1a] font-mono text-[11px]",children:[C.jsx("div",{className:"flex items-center justify-between mb-2",children:C.jsx("span",{className:"terminal-muted",children:"## BURNDOWN ##"})}),C.jsx("div",{className:"terminal-dim text-center py-4",children:"> No data available"})]});const s=8,o=n.length,l=[];for(let c=s;c>=0;c--){const u=c/s*a;let h="";for(let d=0;d<o;d++){const f=n[d],m=f.actual>=u,y=f.ideal>=u;m&&y?h+="#":m?h+="*":y?h+=".":h+=" ",h+=" "}l.push(h)}return C.jsxs("div",{className:"p-3 border-b border-[#1a3a1a] font-mono text-[11px]",children:[C.jsxs("div",{className:"flex items-center justify-between mb-2",children:[C.jsx("span",{className:"terminal-muted",children:"## "+(i==="burndown"?"BURNDOWN":"BURNUP")+" ##"}),C.jsxs("div",{className:"flex items-center gap-1",children:[C.jsx("button",{onClick:()=>r("burndown"),className:`px-1.5 py-0.5 text-[9px] border ${i==="burndown"?"text-[#00ff00] border-[#00aa00] bg-[#0a1f0a]":"terminal-dim border-[#1a3a1a]"}`,children:"DN"}),C.jsx("button",{onClick:()=>r("burnup"),className:`px-1.5 py-0.5 text-[9px] border ${i==="burnup"?"text-[#00ff00] border-[#00aa00] bg-[#0a1f0a]":"terminal-dim border-[#1a3a1a]"}`,children:"UP"})]})]}),C.jsxs("div",{className:"bg-[#050505] border border-[#1a3a1a] p-2 text-[10px]",children:[C.jsxs("div",{className:"flex",children:[C.jsxs("div",{className:"flex flex-col justify-between text-right pr-1 terminal-dim text-[9px] shrink-0 w-[20px]",children:[C.jsx("span",{children:a}),C.jsx("span",{children:Math.round(a/2)}),C.jsx("span",{children:"0"})]}),C.jsx("div",{className:"flex-1",children:C.jsx("div",{className:"border-l border-b border-[#1a3a1a] pl-1 pb-1",children:l.map((c,u)=>C.jsx("div",{className:"leading-none",children:C.jsx("span",{className:"text-[#00ff00]",children:c.split("").map((h,d)=>h==="*"?C.jsx("span",{className:"text-[#00ff00] terminal-glow",children:h},d):h==="."?C.jsx("span",{className:"terminal-dim",children:h},d):h==="#"?C.jsx("span",{className:"text-[#00ccff]",children:h},d):C.jsx("span",{children:h},d))})},u))})})]}),C.jsxs("div",{className:"flex items-center gap-3 mt-1 text-[9px]",children:[C.jsx("span",{className:"text-[#00ff00]",children:"* actual"}),C.jsx("span",{className:"terminal-dim",children:". ideal"}),C.jsx("span",{className:"text-[#00ccff]",children:"# overlap"})]})]})]})}const ype={backlog:{char:".",color:"terminal-dim"},planned:{char:"-",color:"text-[#00ccff]"},pending:{char:"-",color:"text-[#00ccff]"},in_progress:{char:"*",color:"text-[#00ff00]"},in_review:{char:"?",color:"terminal-muted"},completed:{char:"+",color:"text-[#00ff00]"},blocked:{char:"!",color:"terminal-error"},deferred:{char:".",color:"terminal-dim"}};function xpe(e,t=12){const i=Math.round(e/100*t),r=t-i;return"█".repeat(i)+"░".repeat(r)}function dPt(){const{activeProject:e,tasks:t,sprints:i,selectTask:r}=_n(),[n,a]=ee.useState(null),[s,o]=ee.useState(null),l=ee.useMemo(()=>{if(!e||t.length===0||i.length===0)return[];const c=new Map;for(const d of i)c.set(d.id,d);const u=new Map;for(const d of t){const f=d.sprintId||"unknown";u.has(f)||u.set(f,new Map);const m=u.get(f),y=d.prdSection||"Uncategorized";m.has(y)||m.set(y,{name:y,total:0,completed:0,inProgress:0,blocked:0,percent:0,tasks:[],order:d.prdLineStart??999});const g=m.get(y);g.total++,g.tasks.push(d),d.status==="completed"&&g.completed++,d.status==="in_progress"&&g.inProgress++,d.status==="blocked"&&g.blocked++}const h=[];for(const[d,f]of u){const m=c.get(d);if(!m)continue;const y=Array.from(f.values());for(const w of y)w.percent=w.total>0?Math.round(w.completed/w.total*100):0;y.sort((w,S)=>w.order-S.order);const g=y.reduce((w,S)=>w+S.total,0),x=y.reduce((w,S)=>w+S.completed,0);h.push({sprint:m,sections:y,total:g,completed:x,percent:g>0?Math.round(x/g*100):0})}return h.sort((d,f)=>(d.sprint.order??0)-(f.sprint.order??0)),h},[e,t,i]);return l.length===0?C.jsx("div",{className:"h-full flex items-center justify-center font-mono text-[11px]",children:C.jsxs("div",{className:"terminal-dim text-center",children:[C.jsx("p",{children:"## PRD OVERVIEW ##"}),C.jsx("p",{className:"mt-1",children:"> Import a PRD to see section progress"})]})}):C.jsxs("div",{className:"p-2 font-mono text-[11px]",children:[C.jsxs("div",{className:"flex items-center justify-between mb-2",children:[C.jsx("span",{className:"terminal-muted",children:"## PRD SECTIONS ##"}),C.jsx("span",{className:"text-[#00ccff] text-[10px]",children:e==null?void 0:e.name})]}),C.jsx("div",{className:"border border-[#1a3a1a] bg-[#050505]",children:l.map(c=>{const u=n===c.sprint.id,h=c.percent===100?"text-[#00ff00]":"text-[#ffaa00]";return C.jsxs("div",{children:[C.jsxs("div",{className:"flex items-center gap-0 px-2 py-1.5 hover:bg-[#0a1a0a] transition-colors border-b border-[#1a3a1a] cursor-pointer",onClick:()=>a(u?null:c.sprint.id),children:[C.jsx("span",{className:"w-[24px] terminal-dim text-[10px]",children:u?"[-]":"[+]"}),C.jsx("span",{className:`flex-1 font-bold uppercase text-[11px] ${h}`,children:c.sprint.name}),C.jsxs("span",{className:`w-[110px] text-center text-[10px] ${h}`,children:[xpe(c.percent)," ",c.percent,"%"]}),C.jsxs("span",{className:"w-[50px] text-right text-[10px] text-[#00ff00]",children:[c.completed,"/",c.total]})]}),u&&C.jsxs("div",{className:"bg-[#030303]",children:[C.jsxs("div",{className:"flex items-center gap-0 px-2 py-0.5 border-b border-[#0a1a0a] terminal-dim text-[9px]",children:[C.jsx("span",{className:"w-[36px]"}),C.jsx("span",{className:"flex-1",children:"SECTION"}),C.jsx("span",{className:"w-[110px] text-center",children:"PROGRESS"}),C.jsx("span",{className:"w-[40px] text-right",children:"DONE"}),C.jsx("span",{className:"w-[30px] text-right",children:"ACT"}),C.jsx("span",{className:"w-[30px] text-right",children:"BLK"})]}),c.sections.map(d=>{const f=`${c.sprint.id}:${d.name}`,m=s===f,y=d.percent===100?"text-[#00ff00]":d.blocked>0?"terminal-error":d.inProgress>0?"text-[#00ccff]":"terminal-dim";return C.jsxs("div",{children:[C.jsxs("div",{className:"flex items-center gap-0 px-2 py-0.5 hover:bg-[#0a1a0a] transition-colors border-b border-[#0a1a0a] text-[10px] cursor-pointer",onClick:()=>o(m?null:f),children:[C.jsx("span",{className:"w-[12px]"}),C.jsx("span",{className:"w-[24px] terminal-dim",children:m?"[-]":"[+]"}),C.jsx("span",{className:"flex-1 truncate text-[#00cc00]",children:d.name}),C.jsxs("span",{className:`w-[110px] text-center ${y}`,children:[xpe(d.percent)," ",d.percent,"%"]}),C.jsxs("span",{className:"w-[40px] text-right text-[#00ff00]",children:[d.completed,"/",d.total]}),C.jsx("span",{className:`w-[30px] text-right ${d.inProgress>0?"text-[#00ccff]":"terminal-dim"}`,children:d.inProgress}),C.jsx("span",{className:`w-[30px] text-right ${d.blocked>0?"terminal-error":"terminal-dim"}`,children:d.blocked})]}),m&&C.jsx("div",{className:"bg-[#050505] border-b border-[#0a1a0a]",children:d.tasks.map(g=>{const x=ype[g.status]||ype.backlog;return C.jsxs("div",{onClick:()=>r(g.id),className:"cursor-pointer hover:bg-[#0a1a0a] px-6 py-0.5 text-[10px] flex items-center gap-1",children:[C.jsxs("span",{className:x.color,children:["[",x.char,"]"]}),C.jsx("span",{className:"text-[#00cc00] truncate flex-1",children:g.title}),g.assignedAgent&&C.jsxs("span",{className:"terminal-dim",children:["@",g.assignedAgent]})]},g.id)})})]},f)})]})]},c.sprint.id)})})]})}const zMe={backlog:".",planned:"-",pending:"~",in_progress:"*",in_review:"?",completed:"+",blocked:"!",deferred:"_"},BMe={backlog:"terminal-dim",planned:"text-[#00ccff]",pending:"terminal-muted",in_progress:"text-[#00ff00]",in_review:"terminal-muted",completed:"text-[#00ff00]",blocked:"terminal-error",deferred:"terminal-dim"};function fPt(){const{tasks:e}=_n(),{roots:t,edgeCount:i,nodeCount:r}=ee.useMemo(()=>{const n=new Map,a=new Map,s=new Map;for(const f of e){s.set(f.id,f);const m=new Set([...f.dependsOn,...f.blockedBy]);n.set(f.id,m)}const o=new Set;let l=0;for(const f of e){const m=n.get(f.id)??new Set;if(m.size>0){o.add(f.id);for(const y of m)o.add(y),l++,a.has(y)||a.set(y,new Set),a.get(y).add(f.id)}}if(o.size===0)return{roots:[],edgeCount:0,nodeCount:0};const c=new Set;for(const f of o){const m=n.get(f)??new Set;Array.from(m).some(g=>o.has(g))||c.add(f)}if(c.size===0){const f=Array.from(o).slice(0,3);for(const m of f)c.add(m)}const u=new Set;function h(f,m){if(u.has(f)||m>6)return null;u.add(f);const y=s.get(f);if(!y)return null;const g=a.get(f)??new Set,x=[];for(const w of g)if(o.has(w)){const S=h(w,m+1);S&&x.push(S)}return{task:y,children:x,depth:m}}const d=[];for(const f of c){const m=h(f,0);m&&d.push(m)}return{roots:d,edgeCount:l,nodeCount:o.size}},[e]);return t.length===0?C.jsxs("div",{className:"p-3 border-b border-[#1a3a1a] font-mono text-[11px]",children:[C.jsx("span",{className:"terminal-muted",children:"## DEPENDENCIES ##"}),C.jsx("div",{className:"terminal-dim text-center py-3",children:"> No task dependencies"})]}):C.jsxs("div",{className:"p-3 border-b border-[#1a3a1a] font-mono text-[11px]",children:[C.jsxs("div",{className:"flex items-center justify-between mb-2",children:[C.jsx("span",{className:"terminal-muted",children:"## DEPENDENCIES ##"}),C.jsxs("span",{className:"terminal-dim text-[10px]",children:[r," tasks ","·"," ",i," links"]})]}),C.jsx("div",{className:"bg-[#050505] border border-[#1a3a1a] p-2 overflow-auto terminal-scrollbar max-h-[280px]",children:t.map((n,a)=>C.jsx(UMe,{node:n,prefix:"",isLast:a===t.length-1},n.task.id))}),C.jsx("div",{className:"flex flex-wrap gap-x-3 gap-y-0.5 mt-1.5 text-[9px]",children:Object.entries(zMe).filter(([n])=>e.some(a=>a.status===n)).map(([n,a])=>C.jsxs("span",{className:BMe[n]||"terminal-dim",children:["[",a,"] ",n.replace(/_/g," ")]},n))})]})}function UMe({node:e,prefix:t,isLast:i}){const r=i?"└─":"├─",n=t+(i?" ":"│ "),a=zMe[e.task.status]||"?",s=BMe[e.task.status]||"terminal-dim",o=e.task.title.length>30?e.task.title.slice(0,27)+"...":e.task.title;return C.jsxs("div",{className:"text-[10px]",children:[C.jsxs("div",{className:"flex items-center gap-0 whitespace-nowrap",children:[C.jsxs("span",{className:"terminal-dim",children:[t,r]}),C.jsxs("span",{className:`font-bold ${s}`,children:["[",a,"]"]}),C.jsx("span",{className:"text-[#00cc00] ml-1",children:o}),e.task.assignedAgent&&C.jsxs("span",{className:"terminal-dim ml-1",children:["@",e.task.assignedAgent]})]}),e.children.map((l,c)=>C.jsx(UMe,{node:l,prefix:n,isLast:c===e.children.length-1},l.task.id))]})}function pPt(){const{viewMode:e,setViewMode:t,activeProject:i}=_n();return C.jsxs("div",{className:"flex items-center gap-2 font-mono text-[11px]",children:[C.jsx("button",{onClick:()=>t("agents"),className:`px-2 py-0.5 transition-colors ${e==="agents"?"text-[#00ff00] terminal-glow bg-[#0a1f0a]":"terminal-muted hover:text-[#00aa00]"}`,children:"[AGENTS]"}),C.jsx("button",{onClick:()=>t("tracker"),className:`px-2 py-0.5 transition-colors ${e==="tracker"?"text-[#00ff00] terminal-glow bg-[#0a1f0a]":"terminal-muted hover:text-[#00aa00]"}`,children:"[TRACKER]"}),i&&C.jsxs("span",{className:"terminal-muted",children:[i.completedTasks,"/",i.totalTasks]})]})}function mPt(){const{connectionStatus:e}=Ni(),t={connected:{className:"text-[#00ff00] terminal-glow",label:"[CONNECTED]",sublabel:"capturing events",sublabelClass:"text-[#00aa00]",showCursor:!0},reconnecting:{className:"text-[#ffaa00]",label:"[RECONNECTING...]",sublabel:"",sublabelClass:"",showCursor:!1},disconnected:{className:"terminal-error",label:"[DISCONNECTED]",sublabel:"waiting for server",sublabelClass:"terminal-error",showCursor:!1}}[e];return C.jsxs("div",{className:"flex items-center gap-1",children:[C.jsx("span",{className:t.className,children:t.label}),t.sublabel&&C.jsx("span",{className:t.sublabelClass,children:t.sublabel}),t.showCursor&&C.jsx("span",{className:"terminal-cursor-active"})]})}function gPt(){const{viewMode:e}=_n();return C.jsxs("div",{className:"h-full w-full flex flex-col terminal-bg terminal-boot overflow-hidden",children:[C.jsxs("header",{className:"h-10 flex items-center justify-between px-3 border-b border-[#1a3a1a] bg-[#0d0d0d] shrink-0 font-mono text-[11px] relative z-50",children:[C.jsxs("div",{className:"flex items-center gap-3",children:[C.jsx("span",{className:"text-[#00ff00] terminal-glow font-bold",children:"CAM://"}),C.jsx("span",{className:"text-[#00aa00]",children:"Claude Agent Monitor"}),C.jsx("span",{className:"terminal-dim",children:"|"}),C.jsx(mPt,{})]}),C.jsxs("div",{className:"flex items-center gap-3",children:[C.jsx(RX,{}),C.jsx(pPt,{})]})]}),C.jsx(HCt,{}),C.jsx(IK,{}),C.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[e==="agents"&&C.jsx(vPt,{}),e==="tracker"&&C.jsx(yPt,{})]})]})}function vPt(){return C.jsxs(C.Fragment,{children:[C.jsx("aside",{className:"w-48 border-r border-[#1a3a1a] overflow-y-auto terminal-scrollbar shrink-0",children:C.jsx(XCt,{})}),C.jsx("main",{className:"flex-1 overflow-hidden",children:C.jsx(MK,{})}),C.jsx("aside",{className:"w-72 border-l border-[#1a3a1a] terminal-scrollbar shrink-0",children:C.jsx(RK,{AgentDetail:tPt,ActivityFeed:QCt,FileWatcher:rPt,tabBarClass:"flex border-b border-[#1a3a1a] bg-[#0d0d0d]",activeTabClass:"text-[#00ff00] terminal-glow border-b-2 border-[#00ff00]",inactiveTabClass:"text-[#00aa00]/60 hover:text-[#00aa00]"})})]})}function yPt(){const{selectedTaskId:e}=_n();return C.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[C.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[C.jsx("main",{className:"flex-1 overflow-hidden",children:C.jsx(oPt,{})}),e&&C.jsx("aside",{className:"w-80 border-l border-[#1a3a1a] overflow-y-auto terminal-scrollbar shrink-0",children:C.jsx(EK,{})}),C.jsxs("aside",{className:"w-80 border-l border-[#1a3a1a] overflow-y-auto terminal-scrollbar shrink-0 flex flex-col",children:[C.jsx(uPt,{}),C.jsx(hPt,{}),C.jsx(fPt,{})]})]}),C.jsx("div",{className:"h-48 border-t border-[#1a3a1a] overflow-y-auto terminal-scrollbar shrink-0",children:C.jsx(dPt,{})})]})}const Ww={TIME:"⌛",PARTY:"⚔",SKILLS:"🎯",EVENTS:"📜",LOOT:"📦",POISON:"☠"};function xPt(){const{session:e,agents:t,events:i}=Ni(),[r,n]=ee.useState("00m 00s");ee.useEffect(()=>{if(!(e!=null&&e.startedAt))return;const u=()=>n(H7(e.startedAt,e.endedAt));if(u(),!e.endedAt){const h=setInterval(u,1e3);return()=>clearInterval(h)}},[e==null?void 0:e.startedAt,e==null?void 0:e.endedAt]);const a=t.filter(u=>u.status==="active").length,s=t.reduce((u,h)=>u+h.errorCount,0),o=t.reduce((u,h)=>u+h.toolCallCount,0),l=i.filter(u=>u.category==="file_change").length,c=[{label:"TIME",value:r,icon:Ww.TIME,color:"var(--pixel-text)"},{label:"PARTY",value:`${a}/${t.length}`,icon:Ww.PARTY,color:a>0?"var(--pixel-green)":"var(--pixel-text)"},{label:"SKILLS",value:Lm(o),icon:Ww.SKILLS,color:"var(--pixel-cyan)"},{label:"EVENTS",value:Lm((e==null?void 0:e.eventCount)??0),icon:Ww.EVENTS,color:"var(--pixel-text)"},{label:"LOOT",value:Lm(l),icon:Ww.LOOT,color:"var(--pixel-orange)"},{label:"POISON",value:String(s),icon:Ww.POISON,color:s>0?"var(--pixel-error)":"var(--pixel-text)"}];return C.jsx("div",{className:"h-11 flex items-center gap-0 px-4 shrink-0",style:{background:"var(--pixel-bg-dark)",borderBottom:"3px solid var(--pixel-border)"},children:c.map((u,h)=>C.jsxs("div",{className:"flex items-center gap-2",style:{borderLeft:h>0?"2px solid var(--pixel-border)":"none",paddingLeft:h>0?"12px":"0",marginLeft:h>0?"12px":"0"},children:[C.jsx("span",{className:"pixel-text-sm",children:u.icon}),C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-dim)"},children:u.label}),C.jsx("span",{className:"pixel-text-sm",style:{color:u.color,fontWeight:"bold"},children:u.value})]},u.label))})}const bPt={"team-lead":"PALADIN","code-writer":"MAGE","code-reviewer":"CLERIC",tester:"RANGER",researcher:"SCHOLAR",designer:"BARD"},wPt={"team-lead":"⚔","code-writer":"🧙","code-reviewer":"🛡",tester:"🎯",researcher:"📚",designer:"🎨"};function _Pt(e){const t=e.name.toLowerCase();for(const[i,r]of Object.entries(bPt))if(t.includes(i))return r;return e.type==="lead"?"PALADIN":"ADVENTURER"}function jMe(e){const t=e.name.toLowerCase();for(const[i,r]of Object.entries(wPt))if(t.includes(i))return r;return"⚔"}function FMe(e){switch(e){case"active":return{text:"FIGHTING",color:"var(--pixel-green)"};case"idle":return{text:"RESTING",color:"var(--pixel-orange)"};case"error":return{text:"POISONED",color:"var(--pixel-error)"};case"completed":return{text:"VICTORY",color:"var(--pixel-cyan)"};case"shutdown":return{text:"FALLEN",color:"var(--pixel-text-dim)"};default:return{text:e.toUpperCase(),color:"var(--pixel-text-muted)"}}}function SPt(e){return e.status==="active"}function APt(){const e=$7(),{selectedAgentId:t,selectAgent:i}=Ni(),[r,n]=ee.useState(!1),{activeAgents:a,inactiveAgents:s}=ee.useMemo(()=>{const o=[],l=[];for(const c of e)SPt(c)?o.push(c):l.push(c);return{activeAgents:o,inactiveAgents:l}},[e]);return e.length===0?C.jsxs("div",{className:"p-4 flex flex-col items-center justify-center h-full text-center",children:[C.jsx("div",{className:"pixel-text-xl mb-3",children:"\\u2694"}),C.jsx("p",{className:"pixel-text-sm",style:{color:"var(--pixel-text-muted)"},children:"WAITING FOR"}),C.jsx("p",{className:"pixel-text-sm mt-1 pixel-blink",style:{color:"var(--pixel-gold)"},children:"PARTY MEMBERS..."})]}):C.jsxs("div",{className:"p-2",children:[C.jsx("div",{className:"px-2 py-2 mb-2",children:C.jsxs("span",{className:"pixel-text-xs",style:{color:"var(--pixel-gold)"},children:["ACTIVE PARTY (",a.length,")"]})}),a.length>0?C.jsx("div",{className:"space-y-2",children:a.map(o=>C.jsx(EPt,{agent:o,isSelected:t===o.id,onSelect:()=>i(t===o.id?null:o.id)},o.id))}):C.jsx("div",{className:"px-2 py-3 text-center",children:C.jsx("p",{className:"pixel-text-xs",style:{color:"var(--pixel-text-muted)"},children:"NO ACTIVE HEROES"})}),s.length>0&&C.jsxs("div",{className:"mt-3",children:[C.jsx("button",{onClick:()=>n(!r),className:"w-full text-left px-2 py-1.5 pixel-card",style:{cursor:"pointer"},children:C.jsxs("div",{className:"flex items-center justify-between",children:[C.jsxs("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-dim)"},children:[r?"▼":"▶"," FALLEN/RESTING"]}),C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-gold)",background:"var(--pixel-bg-dark)",border:"1px solid var(--pixel-border)",padding:"0 4px"},children:s.length})]})}),r&&C.jsx("div",{className:"space-y-1 mt-1",children:s.map(o=>C.jsx(MPt,{agent:o,isSelected:t===o.id,onSelect:()=>i(t===o.id?null:o.id)},o.id))})]})]})}function MPt({agent:e,isSelected:t,onSelect:i}){const r=Ch(e.id,e.name,e.type??void 0),n=FMe(e.status),a=jMe(e);return C.jsx("button",{onClick:i,title:`${e.name} (${e.id})`,className:`w-full text-left px-2 py-1 ${t?"pixel-border-accent":"pixel-card"}`,style:{cursor:"pointer"},children:C.jsxs("div",{className:"flex items-center gap-2",children:[C.jsx("span",{className:"pixel-text-xs",children:a}),C.jsx("span",{className:"pixel-text-xs truncate",style:{color:"var(--pixel-text-dim)"},children:r}),C.jsx("span",{className:"pixel-text-xs shrink-0",style:{color:"var(--pixel-gold, #d4a017)"},children:e.type}),C.jsx("span",{className:"pixel-text-xs",style:{color:n.color},children:n.text}),C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-dim)"},children:qc(e.lastActivityAt)})]})})}function EPt({agent:e,isSelected:t,onSelect:i}){const r=f0(e.name),n=FMe(e.status),a=_Pt(e),s=jMe(e),o=100,l=e.errorCount>0?Math.max(10,o-e.errorCount*20):o,c=Math.min(100,e.toolCallCount%100),u=Ch(e.id,e.name,e.type??void 0);return C.jsxs("button",{onClick:i,title:`${e.name} (${e.id})`,className:`w-full text-left p-2 ${t?"pixel-border-accent":"pixel-card"}`,style:{cursor:"pointer"},children:[C.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[C.jsx("span",{className:"pixel-text-base",children:s}),C.jsxs("div",{className:"flex-1 min-w-0",children:[C.jsxs("div",{className:"flex items-center gap-1",children:[C.jsx("span",{className:"pixel-text-sm truncate",style:{color:r},children:u}),C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-gold, #d4a017)"},children:e.type})]}),C.jsxs("div",{className:"flex items-center gap-2",children:[C.jsxs("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-dim)"},children:["LV.",Math.min(99,Math.floor(e.toolCallCount/5)+1)]}),C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-dim)"},children:a})]})]})]}),C.jsxs("div",{className:"flex items-center gap-1 mb-1",children:[C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-hp)",width:"16px"},children:"HP"}),C.jsx("div",{className:"flex-1 pixel-bar-container pixel-bar-hp",children:C.jsx("div",{className:"pixel-bar-fill",style:{width:`${l}%`}})}),C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-muted)",width:"32px",textAlign:"right"},children:l})]}),C.jsxs("div",{className:"flex items-center gap-1 mb-1",children:[C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-mp)",width:"16px"},children:"MP"}),C.jsx("div",{className:"flex-1 pixel-bar-container pixel-bar-mp",children:C.jsx("div",{className:"pixel-bar-fill",style:{width:`${c}%`}})}),C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-muted)",width:"32px",textAlign:"right"},children:c})]}),C.jsxs("div",{className:"flex items-center justify-between",children:[C.jsx("span",{className:`pixel-text-xs ${e.status==="active"?"pixel-pulse":""}`,style:{color:n.color},children:n.text}),C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-dim)"},children:qc(e.lastActivityAt)})]}),e.errorCount>0&&C.jsxs("div",{className:"mt-1 pixel-text-xs pixel-shake",style:{color:"var(--pixel-error)"},children:["\\u2620 ",e.errorCount," CURSE",e.errorCount>1?"S":""]})]})}const VMe=new Set(["TaskList","TaskGet"]);function TPt(e){const t=[];let i=0;for(;i<e.length;){const r=e[i];if(r.tool&&VMe.has(r.tool)){let n=1;for(;i+n<e.length&&e[i+n].tool===r.tool&&e[i+n].agentId===r.agentId;)n++;t.push({event:r,count:n,groupId:`grp-${r.id}`}),i+=n}else t.push({event:r,count:1,groupId:r.id}),i++}return t}const CPt={Edit:"used ENCHANT!",Write:"cast CREATE!",Read:"used SCAN!",Bash:"cast INVOKE!",Grep:"used SEARCH!",Glob:"used DETECT!",TaskCreate:"used QUEST LOG!",TaskUpdate:"used QUEST UPDATE!",TaskList:"checked QUEST BOARD!",SendMessage:"cast TELEPATHY!",WebFetch:"used SCRY!",WebSearch:"cast DIVINATION!",NotebookEdit:"used TOME EDIT!"};function PPt(e){return e.error?{text:"IT MISSED!",color:"var(--pixel-error)"}:e.duration&&e.duration>5e3?{text:"IT WAS SLOW...",color:"var(--pixel-orange)"}:e.category==="error"?{text:"CRITICAL MISS!",color:"var(--pixel-error)"}:e.category==="file_change"?{text:"IT'S SUPER EFFECTIVE!",color:"var(--pixel-green)"}:{text:"HIT!",color:"var(--pixel-cyan)"}}function DPt(e){switch(e){case"tool_call":return"⚔";case"file_change":return"📦";case"command":return"💻";case"message":return"💬";case"lifecycle":return"🔄";case"error":return"☠";case"compact":return"📦";case"notification":return"🔔";default:return"●"}}function OPt(){const e=Dq(),t=Ni(m=>m.agents),{searchQuery:i,setSearchQuery:r}=az(),n=Di(m=>m.followMode),a=Di(m=>m.hidePolling),s=Di(m=>m.toggleFollowMode),o=Di(m=>m.toggleHidePolling),l=ee.useRef(null),[c,u]=ee.useState(null),h=ee.useMemo(()=>{const m=new Map;for(const y of t)m.set(y.id,Ch(y.id,y.name||y.id,y.type??void 0));return m},[t]);ee.useEffect(()=>{n&&l.current&&(l.current.scrollTop=0)},[e.length,n]);const d=ee.useMemo(()=>{let m=e;if(a&&(m=m.filter(y=>!y.tool||!VMe.has(y.tool))),i){const y=i.toLowerCase();m=m.filter(g=>{var x,w,S,M;return((x=g.tool)==null?void 0:x.toLowerCase().includes(y))||((w=g.filePath)==null?void 0:w.toLowerCase().includes(y))||((S=g.input)==null?void 0:S.toLowerCase().includes(y))||((M=g.output)==null?void 0:M.toLowerCase().includes(y))})}return m},[e,a,i]),f=ee.useMemo(()=>TPt(d),[d]);return C.jsxs("div",{className:"h-full flex flex-col",style:{background:"var(--pixel-bg)"},children:[C.jsxs("div",{className:"flex items-center justify-between px-4 py-2 shrink-0",style:{borderBottom:"3px solid var(--pixel-border)",background:"var(--pixel-surface)"},children:[C.jsxs("span",{className:"pixel-text-sm",style:{color:"var(--pixel-gold)"},children:["\\u2694 BATTLE LOG (",d.length,")"]}),C.jsxs("div",{className:"flex items-center gap-2",children:[C.jsx("input",{type:"text",placeholder:"SEARCH...",value:i,onChange:m=>r(m.target.value),className:"pixel-text-xs px-2 py-1",style:{width:"100px",background:"var(--pixel-bg-dark)",border:"2px solid var(--pixel-border)",color:"var(--pixel-text)",outline:"none",fontFamily:"'Press Start 2P', monospace"}}),C.jsx("button",{onClick:o,className:`pixel-text-xs px-2 py-1 ${a?"pixel-btn-active":"pixel-btn"}`,title:"Hide TaskList/TaskGet polling",children:a?"POLL:OFF":"POLL"}),C.jsx("button",{onClick:s,className:`pixel-text-xs px-2 py-1 ${n?"pixel-btn-active":"pixel-btn"}`,children:n?"AUTO":"MANUAL"})]})]}),C.jsx("div",{ref:l,className:"flex-1 overflow-y-auto pixel-scrollbar",children:d.length===0?C.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center p-8",children:[C.jsx("div",{className:"pixel-text-2xl mb-3",children:"\\u2694"}),C.jsx("p",{className:"pixel-text-sm",style:{color:"var(--pixel-text-muted)"},children:"NO ENCOUNTERS YET"}),C.jsx("p",{className:"pixel-text-xs mt-2 pixel-blink",style:{color:"var(--pixel-gold)"},children:"AWAITING BATTLE..."})]}):C.jsx("div",{children:f.map(({event:m,count:y,groupId:g},x)=>C.jsx("div",{className:"pixel-slide-in",style:{animationDelay:`${Math.min(x*.02,.2)}s`},children:C.jsx(RPt,{event:m,agentNameMap:h,isExpanded:c===m.id,groupCount:y,onToggle:()=>u(c===m.id?null:m.id)})},g))})})]})}function RPt({event:e,agentNameMap:t,isExpanded:i,groupCount:r,onToggle:n}){const[a,s]=ee.useState(!1),o=DPt(e.category),l=sz(e.tool||e.hookType),c=CPt[e.tool||""]||`used ${l.toUpperCase()}!`,u=PPt(e);return C.jsx("div",{className:"px-4 py-2 cursor-pointer",onClick:n,style:{borderBottom:"1px solid var(--pixel-border)",background:i?"var(--pixel-surface)":"transparent"},onMouseEnter:h=>{h.currentTarget.style.background="var(--pixel-surface)"},onMouseLeave:h=>{i||(h.currentTarget.style.background="transparent")},children:C.jsxs("div",{className:"flex items-start gap-3",children:[C.jsx("span",{className:"pixel-text-base mt-0.5 w-5 text-center shrink-0",children:o}),C.jsxs("div",{className:"flex-1 min-w-0",children:[C.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-cyan)"},title:e.agentId,children:t.get(e.agentId)??e.agentId.slice(0,8)}),C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text)"},title:e.tool||e.hookType,children:c}),r&&r>1&&C.jsxs("span",{className:"pixel-text-xs",style:{color:"var(--pixel-gold)",background:"var(--pixel-bg-dark)",border:"1px solid var(--pixel-border)",padding:"0 3px"},children:["x",r]})]}),C.jsx("span",{className:"pixel-text-xs",style:{color:u.color},children:u.text}),e.filePath&&C.jsx("div",{className:"mt-0.5",children:C.jsxs("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-dim)"},title:e.filePath,children:["TARGET: ",Ah(e.filePath)]})}),e.error&&C.jsxs("p",{className:"pixel-text-xs mt-0.5 pixel-shake",style:{color:"var(--pixel-error)"},children:["\\u2620 ",e.error]}),i&&C.jsxs("div",{className:"mt-2 space-y-2",onClick:h=>h.stopPropagation(),children:[e.input&&C.jsxs("div",{children:[C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-gold)"},children:"INPUT:"}),C.jsx("pre",{className:"mt-1 pixel-text-xs overflow-x-auto max-h-32 pixel-scrollbar whitespace-pre-wrap break-all p-2",style:{color:"var(--pixel-text-muted)",background:"var(--pixel-bg-dark)",border:"2px solid var(--pixel-border)",fontFamily:"'Press Start 2P', monospace"},children:a?e.input:Oq(e.tool,e.input)})]}),e.output&&C.jsxs("div",{children:[C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-gold)"},children:"OUTPUT:"}),C.jsx("pre",{className:"mt-1 pixel-text-xs overflow-x-auto max-h-32 pixel-scrollbar whitespace-pre-wrap break-all p-2",style:{color:"var(--pixel-text-muted)",background:"var(--pixel-bg-dark)",border:"2px solid var(--pixel-border)",fontFamily:"'Press Start 2P', monospace"},children:a?e.output:Rq(e.output)})]}),C.jsxs("div",{className:"flex items-center gap-2",children:[e.duration!==void 0&&C.jsxs("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-dim)"},children:["CAST TIME: ",e.duration,"ms"]}),(e.input||e.output)&&C.jsx("button",{onClick:h=>{h.stopPropagation(),s(!a)},className:"pixel-text-xs pixel-btn",style:{padding:"0 4px",fontSize:"7px"},children:a?"SUMMARY":"RAW"})]})]})]}),C.jsx("span",{className:"pixel-text-xs shrink-0",style:{color:"var(--pixel-text-dim)"},children:gu(e.timestamp)})]})})}const IPt=[{id:"activity",label:"LOG",icon:"📜"},{id:"files",label:"LOOT",icon:"📦"},{id:"errors",label:"CURSES",icon:"☠"},{id:"messages",label:"CHAT",icon:"💬"}];function NPt(){const{selectedAgentId:e,agents:t,events:i,selectAgent:r}=Ni(),[n,a]=ee.useState("activity"),s=t.find(E=>E.id===e);if(!s)return null;const o=i.filter(E=>E.agentId===s.id),l=o.filter(E=>E.category==="error"||E.error),c=o.filter(E=>E.filePath).reduce((E,T)=>(T.filePath&&!E.includes(T.filePath)&&E.push(T.filePath),E),[]),u=o.filter(E=>E.category==="message"),h=f0(s.name),d=Math.min(99,Math.floor(s.toolCallCount/5)+1),f=s.toolCallCount%50,m=50,y=s.errorCount>0?Math.max(10,100-s.errorCount*20):100,g=Math.min(100,s.toolCallCount%100),x=Math.min(99,Math.floor(s.toolCallCount/3)),w=Math.min(99,50-Math.min(50,s.errorCount*10)),S=Math.min(99,o.length>0?60:10),M=Math.min(99,s.errorCount===0?80:20);return C.jsxs("div",{className:"h-full flex flex-col",style:{background:"var(--pixel-bg)"},children:[C.jsxs("div",{className:"p-3 shrink-0",style:{borderBottom:"3px solid var(--pixel-border)",background:"var(--pixel-surface)"},children:[C.jsxs("div",{className:"flex items-center justify-between mb-2",children:[C.jsxs("div",{className:"flex items-center gap-2",children:[C.jsx("div",{className:"w-10 h-10 flex items-center justify-center pixel-border",style:{background:`${h}20`,color:h},children:C.jsx("span",{className:"pixel-text-lg font-bold",children:s.name.charAt(0).toUpperCase()})}),C.jsxs("div",{children:[C.jsx("h3",{className:"pixel-text-sm",style:{color:"var(--pixel-text)"},title:`${s.name} (${s.id})`,children:Ch(s.id,s.name,s.type??void 0)}),C.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[C.jsxs("span",{className:"pixel-text-xs",style:{color:"var(--pixel-gold)"},children:["LV.",d]}),C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-dim)"},children:s.type.toUpperCase()})]})]})]}),C.jsx("button",{onClick:()=>r(null),className:"pixel-btn px-2 py-1 pixel-text-xs",style:{color:"var(--pixel-text-muted)"},children:"X"})]}),C.jsxs("div",{className:"space-y-1 mb-2",children:[C.jsxs("div",{className:"flex items-center gap-1",children:[C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-hp)",width:"20px"},children:"HP"}),C.jsx("div",{className:"flex-1 pixel-bar-container pixel-bar-hp",children:C.jsx("div",{className:"pixel-bar-fill",style:{width:`${y}%`}})}),C.jsxs("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-muted)",width:"40px",textAlign:"right"},children:[y,"/100"]})]}),C.jsxs("div",{className:"flex items-center gap-1",children:[C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-mp)",width:"20px"},children:"MP"}),C.jsx("div",{className:"flex-1 pixel-bar-container pixel-bar-mp",children:C.jsx("div",{className:"pixel-bar-fill",style:{width:`${g}%`}})}),C.jsxs("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-muted)",width:"40px",textAlign:"right"},children:[g,"/100"]})]}),C.jsxs("div",{className:"flex items-center gap-1",children:[C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-xp)",width:"20px"},children:"XP"}),C.jsx("div",{className:"flex-1 pixel-bar-container pixel-bar-xp",children:C.jsx("div",{className:"pixel-bar-fill",style:{width:`${f/m*100}%`}})}),C.jsxs("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-muted)",width:"40px",textAlign:"right"},children:[f,"/",m]})]})]}),C.jsx("div",{className:"grid grid-cols-4 gap-1",children:[{label:"STR",value:x,color:"var(--pixel-hp)"},{label:"DEF",value:w,color:"var(--pixel-blue)"},{label:"SPD",value:S,color:"var(--pixel-green)"},{label:"LCK",value:M,color:"var(--pixel-gold)"}].map(E=>C.jsxs("div",{className:"text-center p-1",style:{background:"var(--pixel-bg-dark)",border:"2px solid var(--pixel-border)"},children:[C.jsx("div",{className:"pixel-text-sm font-bold",style:{color:E.color},children:E.value}),C.jsx("div",{className:"pixel-text-xs",style:{color:"var(--pixel-text-dim)"},children:E.label})]},E.label))})]}),C.jsx("div",{className:"flex shrink-0",style:{borderBottom:"3px solid var(--pixel-border)"},children:IPt.map(E=>{const T=E.id==="activity"?o.length:E.id==="files"?c.length:E.id==="errors"?l.length:u.length;return C.jsxs("button",{onClick:()=>a(E.id),className:"flex-1 py-2 pixel-text-xs text-center",style:{background:n===E.id?"var(--pixel-accent)":"var(--pixel-surface)",color:n===E.id?"#fff":"var(--pixel-text-muted)",borderRight:"2px solid var(--pixel-border)",cursor:"pointer"},children:[E.icon," ",E.label," (",T,")"]},E.id)})}),C.jsxs("div",{className:"flex-1 overflow-y-auto pixel-scrollbar",children:[n==="activity"&&C.jsx("div",{children:o.length===0?C.jsx("p",{className:"pixel-text-xs p-4 text-center",style:{color:"var(--pixel-text-muted)"},children:"NO ADVENTURE LOG YET"}):o.slice(0,100).map(E=>C.jsxs("div",{className:"px-3 py-2",style:{borderBottom:"1px solid var(--pixel-border)"},children:[C.jsxs("div",{className:"flex items-center justify-between",children:[C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-cyan)"},children:E.tool||E.hookType}),C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-dim)"},children:gu(E.timestamp)})]}),E.filePath&&C.jsx("span",{className:"pixel-text-xs block mt-0.5",style:{color:"var(--pixel-text-muted)"},title:E.filePath,children:Ah(E.filePath)})]},E.id))}),n==="files"&&C.jsx("div",{className:"p-2 space-y-1",children:c.length===0?C.jsx("p",{className:"pixel-text-xs p-4 text-center",style:{color:"var(--pixel-text-muted)"},children:"NO LOOT FOUND"}):c.map(E=>C.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5",style:{border:"1px solid var(--pixel-border)"},children:[C.jsx("span",{className:"pixel-text-xs",children:"\\📦"}),C.jsx("span",{className:"pixel-text-xs break-all",style:{color:"var(--pixel-text)"},title:E,children:Ah(E)})]},E))}),n==="errors"&&C.jsx("div",{children:l.length===0?C.jsx("p",{className:"pixel-text-xs p-4 text-center",style:{color:"var(--pixel-green)"},children:"NO CURSES! ALL CLEAR!"}):l.map(E=>C.jsxs("div",{className:"px-3 py-2",style:{borderBottom:"1px solid var(--pixel-border)"},children:[C.jsxs("div",{className:"flex items-center justify-between",children:[C.jsxs("span",{className:"pixel-text-xs",style:{color:"var(--pixel-error)"},children:["\\u2620 ",E.tool||E.hookType]}),C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-dim)"},children:gu(E.timestamp)})]}),E.error&&C.jsx("p",{className:"pixel-text-xs mt-0.5 break-all",style:{color:"var(--pixel-error)"},children:E.error})]},E.id))}),n==="messages"&&C.jsx("div",{children:u.length===0?C.jsx("p",{className:"pixel-text-xs p-4 text-center",style:{color:"var(--pixel-text-muted)"},children:"NO TELEPATHY LOGS"}):u.map(E=>C.jsxs("div",{className:"px-3 py-2",style:{borderBottom:"1px solid var(--pixel-border)"},children:[C.jsxs("div",{className:"flex items-center justify-between",children:[C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-purple)"},children:"\\💬 TELEPATHY"}),C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-dim)"},children:gu(E.timestamp)})]}),E.input&&C.jsx("p",{className:"pixel-text-xs mt-0.5 break-words whitespace-pre-wrap",style:{color:"var(--pixel-text-muted)"},children:E.input})]},E.id))})]})]})}const bpe={created:{icon:"✨",label:"NEW",rarity:"LEGENDARY",color:"var(--pixel-gold)"},modified:{icon:"🔮",label:"MOD",rarity:"RARE",color:"var(--pixel-purple)"},read:{icon:"📜",label:"READ",rarity:"COMMON",color:"var(--pixel-cyan)"}};function LPt(){const{session:e}=Ni(),[t,i]=ee.useState([]);ee.useEffect(()=>{if(!(e!=null&&e.id))return;let s=!1;async function o(){try{const{files:c}=await X7(e.id);s||i(c)}catch{}}o();const l=setInterval(o,5e3);return()=>{s=!0,clearInterval(l)}},[e==null?void 0:e.id]);const r=t.filter(s=>s.changeType==="created"),n=t.filter(s=>s.changeType==="modified"),a=t.filter(s=>s.changeType==="read");return C.jsxs("div",{className:"p-3 h-full flex flex-col",children:[C.jsxs("div",{className:"flex items-center justify-between mb-3 pb-2",style:{borderBottom:"2px solid var(--pixel-border)"},children:[C.jsx("span",{className:"pixel-text-sm",style:{color:"var(--pixel-gold)"},children:"\\📦 INVENTORY"}),C.jsxs("div",{className:"flex items-center gap-2",children:[C.jsxs("span",{className:"pixel-text-xs",style:{color:"var(--pixel-gold)"},children:[r.length,"\\u2728"]}),C.jsxs("span",{className:"pixel-text-xs",style:{color:"var(--pixel-purple)"},children:[n.length,"\\🔮"]}),C.jsxs("span",{className:"pixel-text-xs",style:{color:"var(--pixel-cyan)"},children:[a.length,"\\📜"]})]})]}),t.length===0?C.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-center",children:[C.jsx("div",{className:"pixel-text-xl mb-3",children:"\\📦"}),C.jsx("p",{className:"pixel-text-sm",style:{color:"var(--pixel-text-muted)"},children:"INVENTORY EMPTY"}),C.jsx("p",{className:"pixel-text-xs mt-2",style:{color:"var(--pixel-text-dim)"},children:"NO LOOT COLLECTED YET"})]}):C.jsx("div",{className:"flex-1 overflow-y-auto pixel-scrollbar space-y-1",children:t.map(s=>{const o=bpe[s.changeType]||bpe.read;return C.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 group",style:{border:"2px solid transparent",cursor:"default"},onMouseEnter:l=>{l.currentTarget.style.borderColor="var(--pixel-border)",l.currentTarget.style.background="var(--pixel-surface)"},onMouseLeave:l=>{l.currentTarget.style.borderColor="transparent",l.currentTarget.style.background="transparent"},children:[C.jsx("span",{className:"pixel-text-base shrink-0",children:o.icon}),C.jsxs("div",{className:"flex-1 min-w-0",children:[C.jsx("span",{className:"pixel-text-xs block",style:{color:"var(--pixel-text)"},title:s.filePath,children:Ah(s.filePath)}),C.jsxs("span",{className:"pixel-text-xs",style:{color:o.color},children:["[",o.rarity,"]"]})]}),C.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[s.touchCount>1&&C.jsxs("span",{className:"pixel-text-xs px-1",style:{color:"var(--pixel-gold)",border:"1px solid var(--pixel-border)",background:"var(--pixel-bg-dark)"},children:["x",s.touchCount]}),C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-dim)"},children:qc(s.lastTouchedAt)})]})]},`${s.filePath}-${s.agentId}`)})})]})}const kPt={backlog:{label:"RUMORS",icon:"💬",color:"var(--pixel-text-dim)"},planned:{label:"ACCEPTED",icon:"📜",color:"var(--pixel-blue)"},in_progress:{label:"ACTIVE",icon:"⚔",color:"var(--pixel-green)"},in_review:{label:"REPORTING",icon:"🔍",color:"var(--pixel-purple)"},completed:{label:"COMPLETE!",icon:"🏆",color:"var(--pixel-gold)"},blocked:{label:"SEALED",icon:"🔒",color:"var(--pixel-error)"}},wpe={critical:{label:"LEGENDARY",stars:"★★★★★",color:"var(--pixel-error)"},high:{label:"EPIC",stars:"★★★★",color:"var(--pixel-orange)"},medium:{label:"RARE",stars:"★★★",color:"var(--pixel-blue)"},low:{label:"COMMON",stars:"★★",color:"var(--pixel-text-dim)"}};function zPt(){const e=T0(),t=r=>r==="pending"?"planned":r==="deferred"?"backlog":r==="in_review"||r==="blocked"?"in_progress":r,i=K_.reduce((r,n)=>(r[n.id]=e.filter(a=>t(a.status)===n.id),r),{});return e.length===0?C.jsxs("div",{className:"h-full flex flex-col items-center justify-center p-8",children:[C.jsx("div",{className:"pixel-text-2xl mb-4",children:"\\📜"}),C.jsx("p",{className:"pixel-text-sm",style:{color:"var(--pixel-text-muted)"},children:"QUEST BOARD EMPTY"}),C.jsx("p",{className:"pixel-text-xs mt-2",style:{color:"var(--pixel-text-dim)"},children:"NO QUESTS AVAILABLE"}),C.jsx("p",{className:"pixel-text-xs mt-1 pixel-blink",style:{color:"var(--pixel-gold)"},children:"CHECK BACK LATER..."})]}):C.jsx("div",{className:"h-full flex gap-2 p-3 overflow-x-auto pixel-scrollbar",children:K_.map(r=>{const n=i[r.id]||[],a=kPt[r.id]||{label:r.label,icon:"■",color:"var(--pixel-text-muted)"};return C.jsxs("div",{className:"flex-shrink-0 w-56 flex flex-col pixel-card",children:[C.jsx("div",{className:"px-3 py-2 shrink-0",style:{borderBottom:"3px solid var(--pixel-border)"},children:C.jsxs("div",{className:"flex items-center justify-between",children:[C.jsxs("span",{className:"pixel-text-xs",style:{color:a.color},children:[a.icon," ",a.label]}),C.jsx("span",{className:"pixel-text-xs px-1.5 py-0.5",style:{color:"var(--pixel-text)",background:"var(--pixel-bg-dark)",border:"2px solid var(--pixel-border)"},children:n.length})]})}),C.jsx("div",{className:"flex-1 overflow-y-auto pixel-scrollbar p-2 space-y-2",children:n.map(s=>C.jsx(BPt,{task:s},s.id))})]},r.id)})})}function BPt({task:e}){const{selectTask:t,selectedTaskId:i}=_n(),r=oz(),n=wpe[e.priority]||wpe.low,a=e.assignedAgent?f0(e.assignedAgent):null,s=e.assignedAgent?r(e.assignedAgent):null,o=e.status==="completed",l=W7(e.prdSection);return C.jsxs("div",{className:`p-2 cursor-pointer ${o?"pixel-glow-gold":i===e.id?"pixel-glow-green":"pixel-border-light"}`,onClick:()=>t(e.id),style:{background:"var(--pixel-bg-dark)",opacity:o?.85:1},children:[C.jsxs("div",{className:"flex items-center justify-between mb-1",children:[C.jsxs("div",{className:"flex items-center gap-1",children:[C.jsxs("span",{className:"pixel-text-xs",style:{color:n.color},children:["[",n.label,"]"]}),l&&C.jsx("span",{className:"pixel-text-xs px-1",style:{color:"var(--pixel-gold)",background:"rgba(255, 215, 0, 0.1)",border:"1px solid var(--pixel-gold)"},children:l})]}),e.complexity&&C.jsxs("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-dim)"},children:["C",e.complexity]})]}),C.jsx("div",{className:"mb-1",children:C.jsx("span",{className:"pixel-text-xs",style:{color:n.color},children:n.stars})}),C.jsxs("h4",{className:"pixel-text-xs leading-relaxed mb-2",style:{color:o?"var(--pixel-text-dim)":"var(--pixel-text)",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:[o&&"✓ ",e.title]}),C.jsxs("div",{className:"flex items-center justify-between",children:[e.assignedAgent&&a?C.jsxs("div",{className:"flex items-center gap-1",children:[C.jsx("div",{className:"w-4 h-4 flex items-center justify-center pixel-text-xs",style:{background:`${a}30`,color:a,border:"1px solid var(--pixel-border)"},children:(s??"?").charAt(0).toUpperCase()}),C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-dim)"},children:s})]}):C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-dim)"},children:"UNASSIGNED"}),e.tags&&e.tags.length>0&&C.jsxs("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-dim)"},children:["#",e.tags[0]]})]}),e.blockedBy.length>0&&C.jsxs("div",{className:"mt-1 pixel-text-xs pixel-shake",style:{color:"var(--pixel-error)"},children:["\\🔒 SEALED BY ",e.blockedBy.length," QUEST",e.blockedBy.length>1?"S":""]})]})}function UPt(){const{activeSprint:e}=lz(),t=T0(),i=ee.useMemo(()=>{if(!e)return{total:0,completed:0,inProgress:0,blocked:0,pending:0,percent:0};const n=t.filter(h=>h.sprintId===e.id),a=n.length||e.totalTasks||0,s=n.filter(h=>h.status==="completed").length,o=n.filter(h=>h.status==="in_progress").length,l=n.filter(h=>h.status==="blocked").length,c=a-s-o-l,u=a>0?Math.round(s/a*100):0;return{total:a,completed:s,inProgress:o,blocked:l,pending:c,percent:u}},[e,t]);if(!e)return C.jsx("div",{className:"p-4 text-center",children:C.jsx("p",{className:"pixel-text-xs",style:{color:"var(--pixel-text-muted)"},children:"NO ACTIVE CHAPTER"})});const r=Math.floor(i.percent/10);return C.jsxs("div",{className:"p-4",style:{borderBottom:"3px solid var(--pixel-border)"},children:[C.jsxs("div",{className:"flex items-center justify-between mb-3",children:[C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-gold)"},children:"\\📖 CHAPTER PROGRESS"}),C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-muted)"},children:e.name})]}),C.jsxs("div",{className:"mb-3",children:[C.jsxs("div",{className:"flex items-center justify-between mb-1",children:[C.jsxs("span",{className:"pixel-text-xs",style:{color:"var(--pixel-xp)"},children:["XP LV.",r]}),C.jsxs("span",{className:"pixel-text-sm font-bold",style:{color:"var(--pixel-gold)"},children:[i.percent,"%"]})]}),C.jsx("div",{className:"pixel-bar-container pixel-bar-xp",style:{height:"16px"},children:C.jsx("div",{className:"pixel-bar-fill",style:{width:`${i.percent}%`,transition:"width 0.5s steps(8)"}})}),C.jsxs("div",{className:"flex items-center justify-between mt-1",children:[C.jsxs("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-dim)"},children:[i.completed,"/",i.total," QUESTS"]}),i.percent===100&&C.jsx("span",{className:"pixel-text-xs pixel-bounce",style:{color:"var(--pixel-gold)"},children:"CHAPTER COMPLETE!"})]})]}),C.jsx("div",{className:"space-y-1",children:[{label:"VICTORIES",value:i.completed,icon:"🏆",color:"var(--pixel-green)",barClass:"pixel-bar-green"},{label:"IN BATTLE",value:i.inProgress,icon:"⚔",color:"var(--pixel-cyan)",barClass:"pixel-bar-purple"},{label:"WAITING",value:i.pending,icon:"⌛",color:"var(--pixel-orange)",barClass:"pixel-bar-xp"},{label:"SEALED",value:i.blocked,icon:"🔒",color:"var(--pixel-error)",barClass:"pixel-bar-hp"}].map(n=>C.jsxs("div",{className:"flex items-center gap-2",children:[C.jsx("span",{className:"pixel-text-xs",style:{width:"14px"},children:n.icon}),C.jsx("span",{className:"pixel-text-xs flex-1",style:{color:n.color},children:n.label}),C.jsx("span",{className:"pixel-text-xs font-bold",style:{color:"var(--pixel-text)"},children:n.value})]},n.label))})]})}function jPt(){const e=T0(),{activeSprint:t}=_n(),i=t?e.filter(c=>c.sprintId===t.id):e,r=i.length,n=i.filter(c=>c.status==="completed").length,a=r-n,s=r>0?Math.round(n/r*100):0,o=20,l=8;return r===0?C.jsxs("div",{className:"pixel-panel p-3",children:[C.jsx("h3",{className:"pixel-title text-xs mb-2",children:"BURNDOWN"}),C.jsx("p",{className:"text-[10px] text-pixel-dim",children:"No quest data..."})]}):C.jsxs("div",{className:"pixel-panel p-3",children:[C.jsxs("h3",{className:"pixel-title text-xs mb-2",children:["BURNDOWN ",C.jsxs("span",{className:"text-pixel-dim",children:["LV.",s]})]}),C.jsxs("div",{className:"font-mono text-[9px] leading-tight text-pixel-green",children:[Array.from({length:l}).map((c,u)=>{const h=(l-u)/l*r,d=Math.round((l-u)/l*r),f=Array.from({length:o}).map((m,y)=>y/o*r<=n&&u>=l-Math.ceil(a/r*l)?"*":d>=h?".":" ").join("");return C.jsxs("div",{children:[String(Math.round(h)).padStart(3," "),"|",f,"|"]},u)}),C.jsx("div",{children:" +"+"-".repeat(o)+"+"})]}),C.jsxs("div",{className:"mt-2 flex gap-3 text-[9px]",children:[C.jsxs("span",{className:"text-pixel-green",children:["Done: ",n]}),C.jsxs("span",{className:"text-pixel-yellow",children:["Left: ",a]}),C.jsxs("span",{className:"text-pixel-dim",children:["Total: ",r]})]})]})}const _pe={backlog:{icon:"○",color:"var(--pixel-text-dim)"},planned:{icon:"○",color:"var(--pixel-blue)"},pending:{icon:"○",color:"var(--pixel-blue)"},in_progress:{icon:"⚔",color:"var(--pixel-green)"},in_review:{icon:"◆",color:"var(--pixel-purple)"},completed:{icon:"✓",color:"var(--pixel-gold)"},blocked:{icon:"✖",color:"var(--pixel-error)"},deferred:{icon:"○",color:"var(--pixel-text-dim)"}};function FPt(){const{activeProject:e,tasks:t,sprints:i,selectTask:r}=_n(),[n,a]=ee.useState(null),[s,o]=ee.useState(null),l=ee.useMemo(()=>{if(!e||t.length===0||i.length===0)return[];const c=new Map;for(const d of i)c.set(d.id,d);const u=new Map;for(const d of t){const f=d.sprintId||"unknown";u.has(f)||u.set(f,new Map);const m=u.get(f),y=d.prdSection||"Uncategorized";m.has(y)||m.set(y,{name:y,total:0,completed:0,inProgress:0,blocked:0,percent:0,tasks:[],order:d.prdLineStart??999});const g=m.get(y);g.total++,g.tasks.push(d),d.status==="completed"&&g.completed++,d.status==="in_progress"&&g.inProgress++,d.status==="blocked"&&g.blocked++}const h=[];for(const[d,f]of u){const m=c.get(d);if(!m)continue;const y=Array.from(f.values());for(const w of y)w.percent=w.total>0?Math.round(w.completed/w.total*100):0;y.sort((w,S)=>w.order-S.order);const g=y.reduce((w,S)=>w+S.total,0),x=y.reduce((w,S)=>w+S.completed,0);h.push({sprint:m,sections:y,total:g,completed:x,percent:g>0?Math.round(x/g*100):0})}return h.sort((d,f)=>(d.sprint.order??0)-(f.sprint.order??0)),h},[e,t,i]);return l.length===0?C.jsx("div",{className:"h-full flex items-center justify-center p-4",children:C.jsxs("div",{className:"text-center",children:[C.jsx("span",{className:"pixel-text-xl",children:"📖"}),C.jsx("p",{className:"pixel-text-xs mt-2",style:{color:"var(--pixel-text-muted)"},children:"QUEST JOURNAL"}),C.jsx("p",{className:"pixel-text-xs mt-1",style:{color:"var(--pixel-text-dim)"},children:"NO ENTRIES YET"})]})}):C.jsxs("div",{className:"p-3",children:[C.jsxs("div",{className:"flex items-center justify-between mb-2",children:[C.jsxs("span",{className:"pixel-text-xs",style:{color:"var(--pixel-gold)"},children:["📖"," QUEST JOURNAL"]}),C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-muted)"},children:e==null?void 0:e.name})]}),C.jsx("div",{className:"space-y-1",children:l.map(c=>{const u=n===c.sprint.id,h=c.percent===100;return C.jsxs("div",{children:[C.jsxs("div",{className:`p-2 cursor-pointer ${h?"pixel-border-gold":"pixel-card"}`,style:{background:"var(--pixel-bg-dark)"},onClick:()=>a(u?null:c.sprint.id),children:[C.jsxs("div",{className:"flex items-center justify-between mb-1",children:[C.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-dim)"},children:u?"▼":"▶"}),C.jsx("h4",{className:"pixel-text-xs truncate",style:{color:"var(--pixel-gold)",fontWeight:"bold"},children:c.sprint.name})]}),C.jsxs("span",{className:"pixel-text-xs font-bold ml-2 shrink-0",style:{color:h?"var(--pixel-gold)":"var(--pixel-text)"},children:[c.percent,"%"]})]}),C.jsx("div",{className:"pixel-bar-container pixel-bar-xp",style:{height:"8px"},children:C.jsx("div",{className:"pixel-bar-fill",style:{width:`${c.percent}%`,background:h?"var(--pixel-gold)":"var(--pixel-xp)"}})}),C.jsx("div",{className:"flex items-center gap-2 pixel-text-xs mt-1",style:{color:"var(--pixel-text-dim)"},children:C.jsxs("span",{children:[c.completed,"/",c.total]})})]}),u&&C.jsx("div",{className:"ml-2 space-y-0.5",style:{borderLeft:"2px solid var(--pixel-border)"},children:c.sections.map(d=>{const f=`${c.sprint.id}:${d.name}`,m=s===f,y=d.percent===100,g=d.blocked>0,x=d.inProgress>0;let w="var(--pixel-text-dim)";return y?w="var(--pixel-gold)":g?w="var(--pixel-error)":x&&(w="var(--pixel-green)"),C.jsxs("div",{children:[C.jsxs("div",{className:"p-2 cursor-pointer",style:{background:"var(--pixel-bg-dark)"},onClick:()=>o(m?null:f),children:[C.jsxs("div",{className:"flex items-center justify-between mb-1",children:[C.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-dim)"},children:m?"▼":"▶"}),C.jsx("h4",{className:"pixel-text-xs truncate",style:{color:"var(--pixel-text)"},children:d.name})]}),C.jsxs("span",{className:"pixel-text-xs font-bold ml-2 shrink-0",style:{color:w},children:[d.percent,"%"]})]}),C.jsx("div",{className:"pixel-bar-container pixel-bar-xp",style:{height:"6px"},children:C.jsx("div",{className:"pixel-bar-fill",style:{width:`${d.percent}%`,background:y?"var(--pixel-gold)":g?"var(--pixel-error)":"var(--pixel-xp)"}})}),C.jsxs("div",{className:"flex items-center gap-2 pixel-text-xs mt-1",style:{color:"var(--pixel-text-dim)"},children:[C.jsxs("span",{children:[d.completed,"/",d.total]}),d.inProgress>0&&C.jsxs("span",{style:{color:"var(--pixel-green)"},children:[d.inProgress,"⚔"]}),d.blocked>0&&C.jsxs("span",{style:{color:"var(--pixel-error)"},children:[d.blocked,"🔒"]})]})]}),m&&C.jsx("div",{className:"ml-2",style:{borderLeft:"2px solid var(--pixel-border)",background:"var(--pixel-bg-dark)"},children:d.tasks.map(S=>{const M=_pe[S.status]||_pe.backlog;return C.jsxs("div",{onClick:()=>r(S.id),className:"cursor-pointer px-3 py-1 flex items-center gap-2 pixel-text-xs",style:{borderBottom:"1px solid var(--pixel-border)"},children:[C.jsx("span",{style:{color:M.color},children:M.icon}),C.jsx("span",{className:"truncate flex-1",style:{color:"var(--pixel-text)"},children:S.title}),S.assignedAgent&&C.jsxs("span",{style:{color:"var(--pixel-text-dim)"},children:["@",S.assignedAgent]})]},S.id)})})]},f)})})]},c.sprint.id)})})]})}const qw=140,Xw=44,VPt=36,HPt=20,Spe=28,Ape=20,GPt={backlog:"#6b7280",planned:"#457b9d",pending:"#f4a261",in_progress:"#2dce89",in_review:"#7c5cff",completed:"#ffd700",blocked:"#e63946",deferred:"#6b7280"},WPt={backlog:"LOCKED",planned:"AVAILABLE",pending:"QUEUED",in_progress:"LEARNING",in_review:"TESTING",completed:"MASTERED",blocked:"SEALED",deferred:"HIDDEN"};function Mpe(e){return GPt[e]??"#6b7280"}function Epe(e){return WPt[e]??e.replace(/_/g," ").toUpperCase()}function qPt(e,t){const i=new Map;function r(a,s){if(i.has(a))return i.get(a);if(s.has(a))return 0;s.add(a);const c=(t.get(a)??[]).reduce((u,h)=>!t.has(h)&&!e.some(d=>d.id===h)?u:Math.max(u,r(h,s)),-1)+1;return i.set(a,c),c}const n=new Set;for(const a of e)r(a.id,n);return i}function XPt(){const{tasks:e}=_n(),t=ee.useRef(null),[i,r]=ee.useState(null),{nodes:n,edges:a,svgWidth:s,svgHeight:o,isEmpty:l}=ee.useMemo(()=>{const d=new Map;for(const R of e){const P=new Set([...R.dependsOn,...R.blockedBy]);d.set(R.id,Array.from(P))}const f=new Set;for(const R of e){const P=d.get(R.id)??[];if(P.length>0){f.add(R.id);for(const I of P)f.add(I)}}const m=e.filter(R=>f.has(R.id));if(m.length===0)return{nodes:[],edges:[],svgWidth:0,svgHeight:0,isEmpty:!0};const y=qPt(m,d),g=new Map;for(const R of m){const P=y.get(R.id)??0;g.has(P)||g.set(P,[]),g.get(P).push(R)}const x=Array.from(g.keys()).sort((R,P)=>R-P),w=[];for(const R of x){const P=g.get(R),I={blocked:0,in_progress:1,in_review:2,pending:3,planned:4,backlog:5,completed:6,deferred:7};P.sort((L,z)=>(I[L.status]??9)-(I[z.status]??9)||L.title.localeCompare(z.title)),P.forEach((L,z)=>{const U=Ape+R*(qw+VPt),j=Spe+z*(Xw+HPt);w.push({id:L.id,title:L.title,status:L.status,col:R,row:z,x:U,y:j})})}const S=[],M=new Set(w.map(R=>R.id));for(const R of m){const P=d.get(R.id)??[];for(const I of P)M.has(I)&&S.push({fromId:I,toId:R.id})}const E=Math.max(...w.map(R=>R.x))+qw+Ape,T=Math.max(...w.map(R=>R.y))+Xw+Spe;return{nodes:w,edges:S,svgWidth:E,svgHeight:T,isEmpty:!1}},[e]);ee.useEffect(()=>{var d;(d=t.current)==null||d.scrollTo({left:0,top:0})},[n]);const c=ee.useMemo(()=>{const d=new Map;for(const f of n)d.set(f.id,f);return d},[n]),u=ee.useCallback(d=>i!==null&&(d.fromId===i||d.toId===i),[i]);if(l)return C.jsxs("div",{className:"p-4",style:{borderBottom:"3px solid var(--pixel-border)"},children:[C.jsx("div",{className:"flex items-center justify-between mb-2",children:C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-gold)"},children:"\\🌲 SKILL TREE"})}),C.jsx("div",{className:"h-24 flex items-center justify-center",children:C.jsx("p",{className:"pixel-text-xs",style:{color:"var(--pixel-text-muted)"},children:"NO SKILL DEPENDENCIES"})})]});const h=Array.from(new Set(n.map(d=>d.status)));return C.jsxs("div",{className:"p-4",style:{borderBottom:"3px solid var(--pixel-border)"},children:[C.jsxs("div",{className:"flex items-center justify-between mb-2",children:[C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-gold)"},children:"\\🌲 SKILL TREE"}),C.jsxs("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-dim)"},children:[n.length," SKILLS \\u00B7 ",a.length," LINKS"]})]}),C.jsx("div",{className:"flex flex-wrap gap-x-3 gap-y-1 mb-2",children:h.map(d=>C.jsxs("div",{className:"flex items-center gap-1",children:[C.jsx("span",{className:"inline-block w-3 h-3",style:{backgroundColor:Mpe(d),border:"1px solid #000"}}),C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-dim)"},children:Epe(d)})]},d))}),C.jsx("div",{ref:t,className:"overflow-auto pixel-scrollbar pixel-card",style:{maxHeight:360,background:"var(--pixel-bg-dark)"},children:C.jsxs("svg",{width:s,height:o,viewBox:`0 0 ${s} ${o}`,className:"select-none",children:[C.jsxs("defs",{children:[C.jsx("marker",{id:"pixel-arrow",viewBox:"0 0 10 10",refX:"10",refY:"5",markerWidth:"8",markerHeight:"8",orient:"auto-start-reverse",children:C.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"#444477"})}),C.jsx("marker",{id:"pixel-arrow-hl",viewBox:"0 0 10 10",refX:"10",refY:"5",markerWidth:"8",markerHeight:"8",orient:"auto-start-reverse",children:C.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"#ffd700"})})]}),a.map(d=>{const f=c.get(d.fromId),m=c.get(d.toId);if(!f||!m)return null;const y=u(d),g=f.x+qw,x=f.y+Xw/2,w=m.x,S=m.y+Xw/2,M=(g+w)/2,E=`M ${g} ${x} L ${M} ${x} L ${M} ${S} L ${w} ${S}`;return C.jsx("path",{d:E,fill:"none",stroke:y?"#ffd700":"#444477",strokeWidth:y?3:2,markerEnd:y?"url(#pixel-arrow-hl)":"url(#pixel-arrow)",opacity:i===null||y?1:.25},`${d.fromId}-${d.toId}`)}),n.map(d=>{const f=Mpe(d.status),m=i===d.id,y=i!==null&&!m&&!a.some(x=>x.fromId===i&&x.toId===d.id||x.toId===i&&x.fromId===d.id),g=d.status==="completed";return C.jsxs("g",{onMouseEnter:()=>r(d.id),onMouseLeave:()=>r(null),style:{cursor:"default"},opacity:y?.3:1,children:[C.jsx("rect",{x:d.x,y:d.y,width:qw,height:Xw,fill:"#1a1a2e",stroke:m?"#ffd700":f,strokeWidth:3}),C.jsx("rect",{x:d.x+3,y:d.y+3,width:qw-6,height:2,fill:"rgba(255,255,255,0.08)"}),C.jsx("rect",{x:d.x+6,y:d.y+Xw/2-4,width:8,height:8,fill:f}),g&&C.jsx("text",{x:d.x+qw-16,y:d.y+14,fontSize:10,fill:"#ffd700",children:"⭐"}),C.jsx("text",{x:d.x+20,y:d.y+17,fill:"#e8e8ff",fontSize:7,fontFamily:"'Press Start 2P', monospace",children:d.title.length>14?d.title.slice(0,13)+"…":d.title}),C.jsx("text",{x:d.x+20,y:d.y+32,fill:"#6666aa",fontSize:6,fontFamily:"'Press Start 2P', monospace",children:Epe(d.status)})]},d.id)})]})})]})}function YPt(){const{viewMode:e,setViewMode:t,activeProject:i}=_n();return C.jsxs("div",{className:"flex items-center gap-2",children:[C.jsxs("div",{className:"flex items-center gap-1",children:[C.jsx("button",{onClick:()=>t("agents"),className:"pixel-text-xs px-2 py-1 transition-colors",style:{color:e==="agents"?"var(--pixel-gold)":"var(--pixel-text-muted)",border:e==="agents"?"2px solid var(--pixel-gold)":"2px solid var(--pixel-border)"},children:"[A] AGENTS"}),C.jsx("button",{onClick:()=>t("tracker"),className:"pixel-text-xs px-2 py-1 transition-colors",style:{color:e==="tracker"?"var(--pixel-gold)":"var(--pixel-text-muted)",border:e==="tracker"?"2px solid var(--pixel-gold)":"2px solid var(--pixel-border)"},children:"[T] TRACKER"})]}),i&&C.jsxs("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-muted)"},children:[i.completedTasks,"/",i.totalTasks]})]})}function $Pt(){const{connectionStatus:e}=Ni(),t={connected:{color:"var(--pixel-green)",glow:"0 0 6px var(--pixel-green)",pulse:!0,label:"ONLINE"},reconnecting:{color:"var(--pixel-gold)",glow:"0 0 6px var(--pixel-gold)",pulse:!0,label:"RECONECTANDO..."},disconnected:{color:"var(--pixel-error)",glow:"0 0 6px var(--pixel-error)",pulse:!1,label:"OFFLINE"}}[e];return C.jsxs("div",{className:"flex items-center gap-2 ml-2",children:[C.jsx("div",{className:`w-3 h-3 ${t.pulse?"pixel-pulse":""}`,style:{background:t.color,boxShadow:t.glow}}),C.jsx("span",{className:"pixel-text-xs",style:{color:t.color},children:t.label})]})}function KPt(){const{viewMode:e}=_n();return C.jsxs("div",{className:"pixel-theme h-full w-full flex flex-col overflow-hidden",style:{background:"var(--pixel-bg)"},children:[C.jsxs("header",{className:"h-14 flex items-center justify-between px-4 pixel-hud shrink-0 relative z-50",children:[C.jsxs("div",{className:"flex items-center gap-4",children:[C.jsx("h1",{className:"pixel-text-lg",style:{color:"var(--pixel-gold)"},children:"CAM"}),C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-muted)"},children:"CLAUDE AGENT MONITOR"}),C.jsx($Pt,{})]}),C.jsxs("div",{className:"flex items-center gap-3",children:[C.jsx(RX,{}),C.jsx(YPt,{})]})]}),C.jsx(xPt,{}),C.jsx(IK,{}),C.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[e==="agents"&&C.jsx(QPt,{}),e==="tracker"&&C.jsx(ZPt,{})]})]})}function QPt(){return C.jsxs(C.Fragment,{children:[C.jsx("aside",{className:"w-48 overflow-y-auto pixel-scrollbar shrink-0",style:{borderRight:"3px solid var(--pixel-border)"},children:C.jsx(APt,{})}),C.jsx("main",{className:"flex-1 overflow-hidden",children:C.jsx(MK,{})}),C.jsx("aside",{className:"w-72 pixel-scrollbar shrink-0",style:{borderLeft:"3px solid var(--pixel-border)"},children:C.jsx(RK,{AgentDetail:NPt,ActivityFeed:OPt,FileWatcher:LPt,tabBarClass:"flex border-b-[3px] border-[var(--pixel-border)] bg-[var(--pixel-surface)]",activeTabClass:"text-[var(--pixel-gold)]",inactiveTabClass:"text-[var(--pixel-text-muted)] hover:text-[var(--pixel-text)]",panelClass:"flex-1 overflow-y-auto pixel-scrollbar"})})]})}function ZPt(){const{selectedTaskId:e}=_n();return C.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[C.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[C.jsx("main",{className:"flex-1 overflow-hidden",children:C.jsx(zPt,{})}),e&&C.jsx("aside",{className:"w-80 overflow-y-auto pixel-scrollbar shrink-0",style:{borderLeft:"3px solid var(--pixel-border)"},children:C.jsx(EK,{})}),C.jsxs("aside",{className:"w-80 overflow-y-auto pixel-scrollbar shrink-0 flex flex-col",style:{borderLeft:"3px solid var(--pixel-border)"},children:[C.jsx(UPt,{}),C.jsx(jPt,{}),C.jsx(XPt,{})]})]}),C.jsx("div",{className:"h-48 overflow-y-auto pixel-scrollbar shrink-0",style:{borderTop:"3px solid var(--pixel-border)"},children:C.jsx(FPt,{})})]})}function JPt({agentCount:e,hasNewEvents:t}){return e===0?null:C.jsx(p0,{children:C.jsxs(rc.div,{className:"flex items-center gap-1",initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:{duration:.2},children:[C.jsxs("span",{className:"relative flex h-2 w-2",children:[C.jsx("span",{className:`absolute inline-flex h-full w-full rounded-full bg-cam-success opacity-75 ${t?"animate-ping":"animate-pulse"}`}),C.jsx("span",{className:"relative inline-flex h-2 w-2 rounded-full bg-cam-success"})]}),C.jsx(rc.span,{className:"flex items-center justify-center min-w-[16px] h-4 px-1 rounded-full bg-cam-accent/20 text-cam-accent text-[10px] font-bold leading-none",initial:{scale:1.3},animate:{scale:1},transition:{type:"spring",stiffness:400,damping:15},children:e},e)]})})}function eDt({open:e,title:t,message:i,confirmLabel:r="Delete",cancelLabel:n="Cancel",onConfirm:a,onCancel:s}){return ee.useEffect(()=>{if(!e)return;const o=l=>{l.key==="Escape"&&s()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[e,s]),C.jsx(p0,{children:e&&C.jsxs(rc.div,{className:"fixed inset-0 z-50 flex items-center justify-center",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},children:[C.jsx("div",{className:"absolute inset-0 bg-black/50",onClick:s}),C.jsxs(rc.div,{className:"relative bg-cam-surface border border-cam-border rounded-lg shadow-xl p-6 max-w-sm w-full mx-4",initial:{scale:.95,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.95,opacity:0},transition:{duration:.15},children:[C.jsx("h3",{className:"text-sm font-semibold text-cam-text mb-2",children:t}),C.jsx("p",{className:"text-xs text-cam-text-muted mb-6",children:i}),C.jsxs("div",{className:"flex justify-end gap-2",children:[C.jsx("button",{onClick:s,className:"px-3 py-1.5 text-xs rounded-md text-cam-text-muted hover:text-cam-text hover:bg-cam-surface-2 transition-colors",children:n}),C.jsx("button",{onClick:a,className:"px-3 py-1.5 text-xs rounded-md bg-red-600 text-white hover:bg-red-700 transition-colors",children:r})]})]})]})})}function tDt(e){let t=0;for(let r=0;r<e.length;r++)t=e.charCodeAt(r)+((t<<5)-t);return`hsl(${Math.abs(t%360)}, 65%, 55%)`}function iDt(e){return e.totalTasks===0?0:Math.round(e.completedTasks/e.totalTasks*100)}function rDt(e){switch(e){case"pixel":return{background:"var(--pixel-bg-dark, #0f0f1e)",borderRight:"3px solid var(--pixel-border, #444477)",fontFamily:"'Press Start 2P', monospace",imageRendering:"pixelated"};case"terminal":return{background:"#0a0a0a",borderRight:"1px solid #1a3a1a",fontFamily:"'JetBrains Mono', 'Fira Code', monospace"};default:return{}}}function nDt(e){switch(e){case"pixel":case"terminal":return"flex flex-col h-full shrink-0 select-none";case"modern":default:return"flex flex-col h-full bg-cam-surface border-r border-cam-border/50 shrink-0 select-none"}}function aDt(e){switch(e){case"pixel":return{borderBottom:"3px solid var(--pixel-border, #444477)",background:"var(--pixel-surface, #222244)"};case"terminal":return{borderBottom:"1px solid #1a3a1a"};default:return{}}}function sDt(e){switch(e){case"pixel":case"terminal":return"flex items-center justify-between h-12 px-3 shrink-0";case"modern":default:return"flex items-center justify-between h-12 px-3 border-b border-cam-border/50 shrink-0"}}function oDt(e){switch(e){case"pixel":return{fontSize:"7px",lineHeight:"12px",color:"var(--pixel-gold, #ffd700)"};case"terminal":return{fontSize:"11px",color:"#00ff00",textShadow:"0 0 4px rgba(0,255,0,0.4)"};default:return{}}}function lDt(e){switch(e){case"pixel":case"terminal":return"whitespace-nowrap overflow-hidden";case"modern":default:return"text-xs font-semibold text-cam-text tracking-tight whitespace-nowrap overflow-hidden"}}function cDt(e){switch(e){case"pixel":return"PROJECTS";case"terminal":return"[PROJECTS]";default:return"Projects"}}function uDt(e){switch(e){case"pixel":return"p-1.5 pixel-btn";case"terminal":return"p-1.5";case"modern":default:return"p-1.5 rounded-md text-cam-text-muted hover:text-cam-text hover:bg-cam-surface-2 transition-colors"}}function hDt(e){switch(e){case"pixel":return{color:"var(--pixel-text, #e8e8ff)"};case"terminal":return{color:"#00aa00"};default:return{}}}function dDt(e){switch(e){case"pixel":return"flex-1 overflow-y-auto overflow-x-hidden py-1 space-y-0.5 px-1 pixel-scrollbar";case"terminal":return"flex-1 overflow-y-auto overflow-x-hidden py-1 space-y-0 px-1 terminal-scrollbar";case"modern":default:return"flex-1 overflow-y-auto overflow-x-hidden py-2 space-y-0.5 px-2"}}function fDt(e){switch(e){case"pixel":case"terminal":return"shrink-0 p-2";case"modern":default:return"shrink-0 border-t border-cam-border/50 p-2"}}function pDt(e){switch(e){case"pixel":return{borderTop:"3px solid var(--pixel-border, #444477)"};case"terminal":return{borderTop:"1px solid #1a3a1a"};default:return{}}}function mDt(e,t){const i=t?"justify-center p-2":"px-3 py-2";switch(e){case"pixel":return`flex items-center gap-2 w-full pixel-btn ${i}`;case"terminal":return`flex items-center gap-2 w-full ${i}`;case"modern":default:return`flex items-center gap-2 w-full rounded-md text-cam-text-muted hover:text-cam-text hover:bg-cam-surface-2 transition-colors ${i}`}}function gDt(e){switch(e){case"pixel":return{color:"var(--pixel-text-muted, #8888bb)"};case"terminal":return{color:"#00aa00",fontSize:"11px"};default:return{}}}function vDt(e){switch(e){case"terminal":return"> config";default:return"Settings"}}function yDt(e){switch(e){case"pixel":return"whitespace-nowrap overflow-hidden";case"terminal":return"whitespace-nowrap overflow-hidden";case"modern":default:return"text-xs whitespace-nowrap overflow-hidden"}}function xDt(e){switch(e){case"pixel":return{fontSize:"6px",lineHeight:"10px"};case"terminal":return{fontSize:"11px"};default:return{}}}function bDt(e){switch(e){case"pixel":return"text-center px-2 py-4";case"terminal":return"text-center px-2 py-4";case"modern":default:return"text-[10px] text-cam-text-muted text-center px-2 py-4"}}function wDt(e){switch(e){case"pixel":return{fontSize:"6px",lineHeight:"12px",color:"var(--pixel-text-muted, #8888bb)"};case"terminal":return{fontSize:"10px",color:"#00aa00"};default:return{}}}function _Dt({collapsed:e,onToggleCollapse:t,onOpenSettings:i}){const{projects:r,activeProject:n,setActiveProject:a,removeProject:s}=_n(),o=Ni(S=>S.agents),l=Ni(S=>S.events),c=Di(S=>S.theme),[u,h]=ee.useState(null),d=ee.useCallback(async()=>{if(u){try{await YEe(u.id),s(u.id)}catch{}h(null)}},[u,s]),f=ee.useMemo(()=>[...r].sort((S,M)=>S.status==="active"&&M.status!=="active"?-1:S.status!=="active"&&M.status==="active"?1:new Date(M.updatedAt).getTime()-new Date(S.updatedAt).getTime()),[r]),m=Ni(S=>S.projectId);function y(S){a(S)}const g=ee.useMemo(()=>{if(l.length===0)return!1;const S=l[0];return S!=null&&S.timestamp?Date.now()-new Date(S.timestamp).getTime()<5e3:!1},[l]),x=c==="terminal"?C.jsx("span",{style:{fontSize:"11px",color:"#00aa00"},children:e?">":"<"}):c==="pixel"?C.jsx("span",{style:{fontSize:"8px",fontFamily:"'Press Start 2P', monospace"},children:e?"▶":"◀"}):C.jsx("svg",{className:`w-4 h-4 transition-transform duration-200 ${e?"rotate-180":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:C.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 19l-7-7 7-7"})}),w=c==="terminal"?C.jsx("span",{style:{fontSize:"11px",color:"#00aa00"},children:"[*]"}):c==="pixel"?C.jsx("span",{style:{fontSize:"8px",fontFamily:"'Press Start 2P', monospace",color:"var(--pixel-text-muted)"},children:"⚙"}):C.jsxs("svg",{className:"w-4 h-4 shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:[C.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.594 3.94c.09-.542.56-.94 1.11-.94h2.593c.55 0 1.02.398 1.11.94l.213 1.281c.063.374.313.686.645.87.074.04.147.083.22.127.325.196.72.257 1.075.124l1.217-.456a1.125 1.125 0 011.37.49l1.296 2.247a1.125 1.125 0 01-.26 1.431l-1.003.827c-.293.241-.438.613-.43.992a7.723 7.723 0 010 .255c-.008.378.137.75.43.991l1.004.827c.424.35.534.955.26 1.43l-1.298 2.247a1.125 1.125 0 01-1.369.491l-1.217-.456c-.355-.133-.75-.072-1.076.124a6.47 6.47 0 01-.22.128c-.331.183-.581.495-.644.869l-.213 1.281c-.09.543-.56.941-1.11.941h-2.594c-.55 0-1.019-.398-1.11-.94l-.213-1.281c-.062-.374-.312-.686-.644-.87a6.52 6.52 0 01-.22-.127c-.325-.196-.72-.257-1.076-.124l-1.217.456a1.125 1.125 0 01-1.369-.49l-1.297-2.247a1.125 1.125 0 01.26-1.431l1.004-.827c.292-.24.437-.613.43-.991a6.932 6.932 0 010-.255c.007-.38-.138-.751-.43-.992l-1.004-.827a1.125 1.125 0 01-.26-1.43l1.297-2.247a1.125 1.125 0 011.37-.491l1.216.456c.356.133.751.072 1.076-.124.072-.044.146-.086.22-.128.332-.183.582-.495.644-.869l.214-1.28z"}),C.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]});return C.jsxs(rc.aside,{className:nDt(c),style:rDt(c),animate:{width:e?56:224},transition:{duration:.2,ease:"easeInOut"},children:[C.jsxs("div",{className:sDt(c),style:aDt(c),children:[C.jsx(p0,{mode:"wait",children:!e&&C.jsx(rc.span,{className:lDt(c),style:oDt(c),initial:{opacity:0,width:0},animate:{opacity:1,width:"auto"},exit:{opacity:0,width:0},transition:{duration:.15},children:cDt(c)},"logo-text")}),C.jsx("button",{onClick:t,className:uDt(c),style:hDt(c),title:e?"Expand sidebar":"Collapse sidebar",children:x})]}),C.jsxs("nav",{className:dDt(c),children:[f.length===0&&!e&&C.jsx("p",{className:bDt(c),style:wDt(c),children:c==="terminal"?"> no projects. run: cam init":C.jsxs(C.Fragment,{children:["No registered projects. Use ",C.jsx("code",{className:"text-cam-accent",children:"cam init"})," to get started."]})}),f.map(S=>{const M=(n==null?void 0:n.id)===S.id,E=m===S.id,T=E?o.length:0,R=tDt(S.name),P=iDt(S);return C.jsx(SDt,{project:S,isActive:M,collapsed:e,color:R,completionPct:P,agentCount:T,hasNewEvents:E&&g,onSelect:y,onDelete:h,theme:c},S.id)})]}),C.jsx("div",{className:fDt(c),style:pDt(c),children:C.jsxs("button",{onClick:i,className:mDt(c,e),style:gDt(c),title:"Settings",children:[w,C.jsx(p0,{mode:"wait",children:!e&&C.jsx(rc.span,{className:yDt(c),style:xDt(c),initial:{opacity:0,width:0},animate:{opacity:1,width:"auto"},exit:{opacity:0,width:0},transition:{duration:.15},children:vDt(c)},"settings-label")})]})}),C.jsx(eDt,{open:u!==null,title:"Delete project",message:`Are you sure you want to delete "${(u==null?void 0:u.name)??""}"? All sprints and tasks will be permanently removed. This action cannot be undone.`,onConfirm:d,onCancel:()=>h(null)})]})}function SDt({project:e,isActive:t,collapsed:i,color:r,completionPct:n,agentCount:a,hasNewEvents:s,onSelect:o,onDelete:l,theme:c}){const u=e.name.charAt(0).toUpperCase(),h=e.status==="active";if(i){const d=c==="pixel"?`relative flex items-center justify-center w-full p-2 ${t?"pixel-border-accent":"pixel-btn"}`:c==="terminal"?`relative flex items-center justify-center w-full p-2 ${t?"bg-[#0a1f0a] border border-[#00ff00]":"hover:bg-[#0a1f0a] border border-transparent"}`:`relative flex items-center justify-center w-full rounded-md p-2 transition-colors ${t?"bg-cam-accent/10 ring-1 ring-cam-accent/40":"hover:bg-cam-surface-2"}`,f=c==="pixel"?{backgroundColor:r,imageRendering:"pixelated",borderRadius:0,border:"2px solid var(--pixel-border)"}:c==="terminal"?{backgroundColor:"transparent",color:"#00ff00",border:"1px solid #00aa00",borderRadius:0,fontFamily:"monospace",fontSize:"12px"}:{backgroundColor:r};return C.jsxs(rc.button,{onClick:()=>o(e),className:d,title:`${e.name} (${n}%)`,whileHover:{scale:c==="pixel"?1:1.05},whileTap:{scale:c==="pixel"?1:.95},children:[C.jsx("div",{className:`w-8 h-8 flex items-center justify-center text-xs font-bold text-white shrink-0 ${c==="modern"?"rounded-full":""}`,style:f,children:u}),a>0&&C.jsx("span",{className:"absolute top-1 right-1",children:C.jsx("span",{className:"relative flex h-2 w-2",children:c==="terminal"?C.jsx("span",{className:"relative inline-flex h-2 w-2",style:{background:"#00ff00",borderRadius:0}}):C.jsxs(C.Fragment,{children:[C.jsx("span",{className:"absolute inline-flex h-full w-full rounded-full bg-cam-success opacity-75 animate-ping"}),C.jsx("span",{className:"relative inline-flex h-2 w-2 rounded-full bg-cam-success"})]})})})]})}return c==="terminal"?C.jsxs("button",{onClick:()=>o(e),className:`relative w-full text-left px-2 py-1.5 transition-colors ${t?"bg-[#0a1f0a]":"hover:bg-[#0a1f0a]"}`,style:{fontFamily:"'JetBrains Mono', monospace",fontSize:"11px",borderLeft:t?"2px solid #00ff00":"2px solid transparent"},children:[C.jsxs("div",{className:"flex items-center gap-1.5",children:[C.jsx("span",{style:{color:t?"#00ff00":"#00aa00"},children:t?">":" "}),C.jsx("span",{style:{color:"#00aa00"},children:"[DIR]"}),C.jsx("span",{className:"truncate",style:{color:t?"#00ff00":"#00aa00",textShadow:t?"0 0 4px rgba(0,255,0,0.4)":"none"},children:e.name}),a>0&&C.jsxs("span",{style:{color:"#00ff00",fontSize:"10px"},children:["[",a,"]"]})]}),C.jsxs("div",{className:"flex items-center gap-1 mt-0.5 ml-4",children:[C.jsxs("span",{style:{color:"#006600",fontSize:"10px"},children:[e.completedTasks,"/",e.totalTasks]}),C.jsxs("span",{style:{color:"#006600",fontSize:"10px"},children:["[","█".repeat(Math.round(n/10)),"░".repeat(10-Math.round(n/10)),"] ",n,"%"]})]}),C.jsx("span",{onClick:d=>{d.stopPropagation(),l(e)},className:"absolute right-1 top-1/2 -translate-y-1/2 opacity-0 hover:opacity-100 transition-opacity",style:{color:"#aa0000",fontSize:"10px",cursor:"pointer"},title:"Delete project",children:"[DEL]"})]}):c==="pixel"?C.jsxs("button",{onClick:()=>o(e),className:`relative w-full text-left p-2 ${t?"pixel-border-accent":"pixel-btn"}`,style:{fontFamily:"'Press Start 2P', monospace"},children:[C.jsxs("div",{className:"flex items-start gap-2",children:[C.jsx("div",{className:"w-6 h-6 flex items-center justify-center shrink-0 mt-0.5",style:{backgroundColor:r,border:"2px solid var(--pixel-border)",imageRendering:"pixelated",fontSize:"7px",color:"#fff",fontWeight:"bold"},children:u}),C.jsxs("div",{className:"flex-1 min-w-0",children:[C.jsxs("div",{className:"flex items-center gap-1",children:[C.jsx("span",{style:{width:"4px",height:"4px",display:"inline-block",background:h?"var(--pixel-green)":"var(--pixel-text-muted)"}}),C.jsx("span",{className:"truncate",style:{fontSize:"6px",lineHeight:"10px",color:t?"var(--pixel-gold)":"var(--pixel-text)"},children:e.name.toUpperCase()})]}),C.jsxs("div",{className:"flex items-center justify-between mt-1",children:[C.jsxs("span",{style:{fontSize:"6px",color:"var(--pixel-text-muted)"},children:[e.completedTasks,"/",e.totalTasks]}),C.jsxs("span",{style:{fontSize:"6px",color:"var(--pixel-text-muted)"},children:[n,"%"]})]}),C.jsx("div",{className:"w-full mt-1 pixel-bar-container",style:{height:"6px"},children:C.jsx("div",{className:"pixel-bar-fill",style:{width:`${n}%`,background:t?"var(--pixel-gold)":"var(--pixel-green)",transition:"width 0.3s steps(8)"}})})]}),a>0&&C.jsx("div",{className:"shrink-0 mt-0.5",children:C.jsx("span",{className:"pixel-pulse",style:{display:"inline-block",width:"6px",height:"6px",background:"var(--pixel-green)",boxShadow:"0 0 4px var(--pixel-green)"}})})]}),C.jsx("span",{onClick:d=>{d.stopPropagation(),l(e)},className:"absolute right-1 top-1 opacity-0 hover:opacity-100 transition-opacity",style:{fontSize:"6px",color:"#ff4444",cursor:"pointer",fontFamily:"'Press Start 2P', monospace"},title:"Delete project",children:"X"})]}):C.jsxs(rc.div,{role:"button",tabIndex:0,onClick:()=>o(e),onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),o(e))},className:`relative w-full text-left rounded-lg p-2.5 transition-all duration-150 group cursor-pointer ${t?"bg-cam-accent/10 border-l-2 border-cam-accent":"border-l-2 border-transparent hover:bg-cam-surface-2"}`,whileTap:{scale:.98},children:[C.jsxs("div",{className:"flex items-start gap-2.5",children:[C.jsx("div",{className:"w-7 h-7 rounded-full flex items-center justify-center text-[10px] font-bold text-white shrink-0 mt-0.5",style:{backgroundColor:r},children:u}),C.jsxs("div",{className:"flex-1 min-w-0",children:[C.jsxs("div",{className:"flex items-center gap-1.5",children:[C.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${h?"bg-cam-success":"bg-cam-text-muted"}`}),C.jsx("span",{className:"text-xs font-medium text-cam-text truncate",children:e.name})]}),C.jsxs("div",{className:"flex items-center justify-between mt-1.5",children:[C.jsxs("span",{className:"text-[10px] text-cam-text-muted font-mono",children:[e.completedTasks,"/",e.totalTasks]}),C.jsx("span",{className:"text-[10px] text-cam-text-muted",children:Npe(e.completedTasks,e.totalTasks)})]}),C.jsx("div",{className:"w-full h-1 bg-cam-surface-3 rounded-full overflow-hidden mt-1",children:C.jsx(rc.div,{className:"h-full bg-cam-accent rounded-full",initial:!1,animate:{width:`${n}%`},transition:{duration:.4,ease:"easeOut"}})})]}),a>0&&C.jsx("div",{className:"shrink-0 mt-0.5",children:C.jsx(JPt,{agentCount:a,hasNewEvents:s})})]}),C.jsx("button",{onClick:d=>{d.stopPropagation(),l(e)},className:"absolute top-1.5 right-1.5 p-1 rounded-md text-cam-text-muted hover:text-red-500 hover:bg-red-500/10 opacity-0 group-hover:opacity-100 transition-all",title:"Delete project",children:C.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:C.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})})]})}const ADt=[{value:"modern",label:"Modern",description:"Clean and minimalist interface"},{value:"pixel",label:"Pixel",description:"Retro pixel art style"},{value:"terminal",label:"Terminal",description:"Hacker console style"}],Tpe=[{value:"#3b82f6",label:"Blue"},{value:"#ef4444",label:"Red"},{value:"#22c55e",label:"Green"},{value:"#f59e0b",label:"Amber"},{value:"#8b5cf6",label:"Purple"},{value:"#ec4899",label:"Pink"},{value:"#06b6d4",label:"Cyan"},{value:"#f97316",label:"Orange"}],Cpe=/^#[0-9a-fA-F]{6}$/;function MDt(){const e=Di(u=>u.theme),t=Di(u=>u.accentColor),i=Di(u=>u.setTheme),r=Di(u=>u.setAccentColor),[n,a]=ee.useState(Tpe.some(u=>u.value===t)?"":t),[s,o]=ee.useState(!1),l=u=>{if(a(u),o(!1),u==="")return;const h=u.startsWith("#")?u:`#${u}`;Cpe.test(h)?(r(h),o(!1)):h.length>=7&&o(!0)},c=u=>{r(u),a(""),o(!1)};return C.jsxs("div",{className:"space-y-6",children:[C.jsxs("section",{children:[C.jsx("h3",{className:"text-sm font-medium text-cam-text mb-3",children:"Theme"}),C.jsx("div",{className:"grid grid-cols-3 gap-2",children:ADt.map(u=>C.jsxs("button",{onClick:()=>i(u.value),className:`flex flex-col items-center gap-1.5 p-3 rounded-lg border transition-all ${e===u.value?"border-cam-accent bg-cam-accent/10 ring-1 ring-cam-accent/30":"border-cam-border hover:border-cam-border-hover bg-cam-surface-2"}`,children:[C.jsx("div",{className:`w-full h-8 rounded-md ${u.value==="modern"?"bg-gradient-to-br from-cam-surface-3 to-cam-bg":u.value==="pixel"?"bg-[#1a1a2e] border border-[#533483]":"bg-black border border-[#1a3a1a]"}`,children:C.jsx("div",{className:`w-3 h-1.5 mt-1.5 ml-1.5 rounded-sm ${u.value==="modern"?"bg-cam-accent":u.value==="pixel"?"bg-[#e94560]":"bg-[#00ff00]"}`})}),C.jsx("span",{className:`text-xs font-medium ${e===u.value?"text-cam-accent":"text-cam-text-secondary"}`,children:u.label}),C.jsx("span",{className:"text-[10px] text-cam-text-muted leading-tight text-center",children:u.description})]},u.value))})]}),C.jsxs("section",{children:[C.jsx("h3",{className:"text-sm font-medium text-cam-text mb-3",children:"Accent color"}),C.jsx("div",{className:"flex flex-wrap gap-2 mb-3",children:Tpe.map(u=>C.jsx("button",{onClick:()=>c(u.value),className:`w-8 h-8 rounded-full border-2 transition-all ${t===u.value?"border-white ring-2 ring-offset-2 ring-offset-cam-surface scale-110":"border-transparent hover:scale-105"}`,style:{backgroundColor:u.value},title:u.label,"aria-label":`Color ${u.label}`},u.value))}),C.jsxs("div",{className:"flex items-center gap-2",children:[C.jsx("label",{className:"text-xs text-cam-text-muted shrink-0",children:"Custom color:"}),C.jsx("div",{className:"relative flex-1",children:C.jsx("input",{type:"text",value:n,onChange:u=>l(u.target.value),placeholder:"#RRGGBB",maxLength:7,className:`w-full px-3 py-1.5 text-xs rounded-md border bg-cam-surface-2 text-cam-text placeholder:text-cam-text-muted focus:outline-none focus:ring-1 ${s?"border-cam-error focus:ring-cam-error":"border-cam-border focus:ring-cam-accent"}`})}),n&&!s&&Cpe.test(n)&&C.jsx("div",{className:"w-6 h-6 rounded-md border border-cam-border shrink-0",style:{backgroundColor:n}})]}),s&&C.jsx("p",{className:"text-[10px] text-cam-error mt-1",children:"Invalid format. Use #RRGGBB (e.g. #ff5500)"})]})]})}const EDt=[{value:6e4,label:"1 minute"},{value:18e4,label:"3 minutes"},{value:3e5,label:"5 minutes"},{value:6e5,label:"10 minutes"}];function Ppe({checked:e,onChange:t,label:i}){return C.jsxs("div",{className:"flex items-center justify-between",children:[C.jsx("span",{className:"text-xs text-cam-text-secondary",children:i}),C.jsx("button",{role:"switch","aria-checked":e,onClick:t,className:`relative w-9 h-5 rounded-full transition-colors shrink-0 ${e?"bg-cam-accent":"bg-cam-surface-3 border border-cam-border"}`,children:C.jsx("div",{className:`absolute top-0.5 w-4 h-4 rounded-full bg-white shadow-sm transition-transform ${e?"translate-x-[18px]":"translate-x-0.5"}`})})]})}function TDt(){const e=Di(l=>l.showLabels),t=Di(l=>l.showInteractions),i=Di(l=>l.displayMode),r=Di(l=>l.activityWindow),n=Di(l=>l.toggleLabels),a=Di(l=>l.toggleInteractions),s=Di(l=>l.setDisplayMode),o=Di(l=>l.setActivityWindow);return C.jsxs("div",{className:"space-y-6",children:[C.jsxs("section",{children:[C.jsx(Ppe,{checked:e,onChange:n,label:"Show activity labels"}),C.jsx("p",{className:"text-[10px] text-cam-text-muted mt-1.5 ml-0.5",children:"Displays the tool/action name above each agent on the map."})]}),C.jsxs("section",{children:[C.jsx(Ppe,{checked:t,onChange:a,label:"Show communication lines"}),C.jsx("p",{className:"text-[10px] text-cam-text-muted mt-1.5 ml-0.5",children:"Draws lines connecting agents that communicate with each other."})]}),C.jsxs("section",{children:[C.jsx("h3",{className:"text-sm font-medium text-cam-text mb-3",children:"Speech bubbles"}),C.jsx("div",{className:"grid grid-cols-2 gap-2",children:[{value:"technical",label:"Technical",description:"Shows function/tool being executed"},{value:"didactic",label:"Didactic",description:"Shows friendly explanation"}].map(l=>C.jsxs("button",{onClick:()=>s(l.value),className:`flex items-center gap-2.5 p-2.5 rounded-lg border transition-all ${i===l.value?"border-cam-accent bg-cam-accent/10 ring-1 ring-cam-accent/30":"border-cam-border hover:border-cam-border-hover bg-cam-surface-2"}`,children:[C.jsx("div",{className:`w-4 h-4 rounded-full border-2 flex items-center justify-center shrink-0 ${i===l.value?"border-cam-accent":"border-cam-text-muted"}`,children:i===l.value&&C.jsx("div",{className:"w-2 h-2 rounded-full bg-cam-accent"})}),C.jsxs("div",{className:"text-left",children:[C.jsx("span",{className:`text-xs font-medium block ${i===l.value?"text-cam-accent":"text-cam-text-secondary"}`,children:l.label}),C.jsx("span",{className:"text-[10px] text-cam-text-muted leading-tight",children:l.description})]})]},l.value))})]}),C.jsxs("section",{children:[C.jsx("h3",{className:"text-sm font-medium text-cam-text mb-3",children:"Activity window"}),C.jsx("p",{className:"text-[10px] text-cam-text-muted mb-2",children:"Maximum time to consider an agent as active."}),C.jsx("select",{value:r,onChange:l=>o(Number(l.target.value)),className:"w-full px-3 py-2 text-xs rounded-md border border-cam-border bg-cam-surface-2 text-cam-text focus:outline-none focus:ring-1 focus:ring-cam-accent appearance-none cursor-pointer",children:EDt.map(l=>C.jsx("option",{value:l.value,children:l.label},l.value))})]})]})}function wG({checked:e,onChange:t,label:i}){return C.jsxs("div",{className:"flex items-center justify-between",children:[C.jsx("span",{className:"text-xs text-cam-text-secondary",children:i}),C.jsx("button",{role:"switch","aria-checked":e,onClick:t,className:`relative w-9 h-5 rounded-full transition-colors shrink-0 ${e?"bg-cam-accent":"bg-cam-surface-3 border border-cam-border"}`,children:C.jsx("div",{className:`absolute top-0.5 w-4 h-4 rounded-full bg-white shadow-sm transition-transform ${e?"translate-x-[18px]":"translate-x-0.5"}`})})]})}function CDt(){const e=Di(f=>f.followMode),t=Di(f=>f.hidePolling),i=Di(f=>f.pollingTools),r=Di(f=>f.groupRepetitive),n=Di(f=>f.toggleFollowMode),a=Di(f=>f.toggleHidePolling),s=Di(f=>f.toggleGroupRepetitive),o=Di(f=>f.addPollingTool),l=Di(f=>f.removePollingTool),[c,u]=ee.useState(""),h=()=>{const f=c.trim();f!==""&&(o(f),u(""))},d=f=>{f.key==="Enter"&&(f.preventDefault(),h())};return C.jsxs("div",{className:"space-y-6",children:[C.jsxs("section",{children:[C.jsx(wG,{checked:e,onChange:n,label:"Auto-scroll to recent events"}),C.jsx("p",{className:"text-[10px] text-cam-text-muted mt-1.5 ml-0.5",children:"Automatically scrolls the feed to show new events."})]}),C.jsxs("section",{children:[C.jsx(wG,{checked:t,onChange:a,label:"Hide repetitive tools"}),C.jsx("p",{className:"text-[10px] text-cam-text-muted mt-1.5 ml-0.5",children:"Hides events from tools that do constant polling."})]}),C.jsxs("section",{children:[C.jsx("h3",{className:"text-sm font-medium text-cam-text mb-3",children:"Polling tools"}),C.jsx("p",{className:"text-[10px] text-cam-text-muted mb-2",children:'Tools that will be hidden when "Hide repetitive tools" is active.'}),C.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-3 min-h-[28px]",children:[i.map(f=>C.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 text-[11px] rounded-md bg-cam-surface-3 text-cam-text-secondary border border-cam-border",children:[f,C.jsx("button",{onClick:()=>l(f),className:"text-cam-text-muted hover:text-cam-error transition-colors ml-0.5","aria-label":`Remove ${f}`,children:C.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:[C.jsx("line",{x1:"2",y1:"2",x2:"8",y2:"8"}),C.jsx("line",{x1:"8",y1:"2",x2:"2",y2:"8"})]})})]},f)),i.length===0&&C.jsx("span",{className:"text-[10px] text-cam-text-muted italic",children:"No tools configured"})]}),C.jsxs("div",{className:"flex gap-2",children:[C.jsx("input",{type:"text",value:c,onChange:f=>u(f.target.value),onKeyDown:d,placeholder:"Tool name...",className:"flex-1 px-3 py-1.5 text-xs rounded-md border border-cam-border bg-cam-surface-2 text-cam-text placeholder:text-cam-text-muted focus:outline-none focus:ring-1 focus:ring-cam-accent"}),C.jsx("button",{onClick:h,disabled:c.trim()==="",className:"px-3 py-1.5 text-xs font-medium rounded-md bg-cam-accent text-white hover:bg-cam-accent-hover disabled:opacity-40 disabled:cursor-not-allowed transition-colors shrink-0",children:"Add"})]})]}),C.jsxs("section",{children:[C.jsx(wG,{checked:r,onChange:s,label:"Agrupar eventos repetitivos consecutivos"}),C.jsx("p",{className:"text-[10px] text-cam-text-muted mt-1.5 ml-0.5",children:"Eventos identicos consecutivos sao agrupados com contador."})]})]})}function PDt({checked:e,onChange:t,label:i}){return C.jsxs("div",{className:"flex items-center justify-between",children:[C.jsx("span",{className:"text-xs text-cam-text-secondary",children:i}),C.jsx("button",{role:"switch","aria-checked":e,onClick:t,className:`relative w-9 h-5 rounded-full transition-colors shrink-0 ${e?"bg-cam-accent":"bg-cam-surface-3 border border-cam-border"}`,children:C.jsx("div",{className:`absolute top-0.5 w-4 h-4 rounded-full bg-white shadow-sm transition-transform ${e?"translate-x-[18px]":"translate-x-0.5"}`})})]})}function _G({value:e,onChange:t,min:i,max:r,label:n,suffix:a}){const s=c=>{const u=parseInt(c.target.value,10);if(Number.isNaN(u))return;const h=Math.min(r,Math.max(i,u));t(h)},o=()=>{e<r&&t(e+1)},l=()=>{e>i&&t(e-1)};return C.jsxs("div",{children:[C.jsx("label",{className:"text-xs text-cam-text-secondary block mb-1.5",children:n}),C.jsxs("div",{className:"flex items-center gap-1",children:[C.jsx("button",{onClick:l,disabled:e<=i,className:"w-7 h-7 flex items-center justify-center rounded-md border border-cam-border bg-cam-surface-2 text-cam-text-secondary hover:text-cam-text hover:bg-cam-surface-3 disabled:opacity-30 disabled:cursor-not-allowed transition-colors text-sm font-mono","aria-label":"Decrease",children:"-"}),C.jsx("input",{type:"number",value:e,onChange:s,min:i,max:r,className:"w-20 px-2 py-1 text-xs text-center rounded-md border border-cam-border bg-cam-surface-2 text-cam-text focus:outline-none focus:ring-1 focus:ring-cam-accent [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none"}),C.jsx("button",{onClick:o,disabled:e>=r,className:"w-7 h-7 flex items-center justify-center rounded-md border border-cam-border bg-cam-surface-2 text-cam-text-secondary hover:text-cam-text hover:bg-cam-surface-3 disabled:opacity-30 disabled:cursor-not-allowed transition-colors text-sm font-mono","aria-label":"Increase",children:"+"}),a&&C.jsx("span",{className:"text-[10px] text-cam-text-muted ml-1",children:a})]}),C.jsxs("p",{className:"text-[10px] text-cam-text-muted mt-1",children:["Min: ",i," / Max: ",r]})]})}function DDt(){const e=Di(d=>d.maxEvents),t=Di(d=>d.speechBubbleTimeout),i=Di(d=>d.maxCommunicationLines),r=Di(d=>d.lockPanels),n=Di(d=>d.setMaxEvents),a=Di(d=>d.setSpeechBubbleTimeout),s=Di(d=>d.setMaxCommunicationLines),o=Di(d=>d.toggleLockPanels),l=Di(d=>d.resetToDefaults),[c,u]=ee.useState(!1),h=()=>{window.confirm("Are you sure you want to restore all settings to default values?")&&(l(),u(!0),setTimeout(()=>u(!1),2500))};return C.jsxs("div",{className:"space-y-6",children:[C.jsxs("section",{children:[C.jsx(_G,{value:e,onChange:n,min:100,max:1e4,label:"Maximum events in memory",suffix:"events"}),C.jsx("p",{className:"text-[10px] text-cam-text-muted mt-1",children:"Maximum number of events kept in the dashboard. Higher values use more memory."})]}),C.jsxs("section",{children:[C.jsx(_G,{value:t,onChange:a,min:1,max:30,label:"Speech bubble timeout",suffix:"seconds"}),C.jsx("p",{className:"text-[10px] text-cam-text-muted mt-1",children:"How long each speech bubble remains visible before disappearing."})]}),C.jsxs("section",{children:[C.jsx(_G,{value:i,onChange:s,min:1,max:20,label:"Maximum communication lines"}),C.jsx("p",{className:"text-[10px] text-cam-text-muted mt-1",children:"Maximum number of interaction lines visible simultaneously on the Agent Map."})]}),C.jsxs("section",{children:[C.jsx(PDt,{checked:r,onChange:o,label:"Lock panel resizing"}),C.jsx("p",{className:"text-[10px] text-cam-text-muted mt-1.5 ml-0.5",children:"Prevents accidental resizing of dashboard panels."})]}),C.jsxs("section",{className:"pt-2 border-t border-cam-border",children:[C.jsxs("div",{className:"flex items-center justify-between",children:[C.jsxs("div",{children:[C.jsx("h3",{className:"text-sm font-medium text-cam-text",children:"Restore Defaults"}),C.jsx("p",{className:"text-[10px] text-cam-text-muted mt-0.5",children:"Resets all settings to their original values."})]}),C.jsx("button",{onClick:h,className:"px-3 py-1.5 text-xs font-medium rounded-md border border-cam-error/50 text-cam-error hover:bg-cam-error/10 transition-colors shrink-0",children:"Restore Defaults"})]}),c&&C.jsx("div",{className:"mt-2 px-3 py-1.5 text-[11px] text-cam-success bg-cam-success/10 border border-cam-success/30 rounded-md",children:"Settings restored successfully!"})]})]})}const ODt=[{id:"appearance",label:"Appearance"},{id:"agent-map",label:"Agent Map"},{id:"activity-feed",label:"Activity Feed"},{id:"advanced",label:"Advanced"}],RDt={hidden:{opacity:0},visible:{opacity:1},exit:{opacity:0}},IDt={hidden:{opacity:0,scale:.95,y:20},visible:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:20}};function NDt(e){switch(e){case"pixel":return"relative w-full max-w-lg mx-4 max-h-[85vh] flex flex-col";case"terminal":return"relative w-full max-w-lg mx-4 max-h-[85vh] flex flex-col";case"modern":default:return"relative w-full max-w-lg mx-4 max-h-[85vh] flex flex-col rounded-2xl shadow-2xl"}}function LDt(e){switch(e){case"pixel":return{background:"var(--pixel-bg-dark, #0f0f1e)",border:"4px solid var(--pixel-border, #444477)",boxShadow:"inset -4px -4px 0 rgba(0,0,0,0.4), inset 4px 4px 0 rgba(255,255,255,0.08), 0 0 0 2px #000, 8px 8px 0 rgba(0,0,0,0.5)",fontFamily:"'Press Start 2P', monospace",imageRendering:"pixelated"};case"terminal":return{background:"#0a0a0a",border:"1px solid #00aa00",boxShadow:"0 0 20px rgba(0,255,0,0.05), inset 0 0 60px rgba(0,255,0,0.02)",fontFamily:"'JetBrains Mono', 'Fira Code', monospace"};case"modern":default:return{background:"rgba(15, 15, 15, 0.85)",backdropFilter:"blur(24px)",WebkitBackdropFilter:"blur(24px)",border:"1px solid rgba(255,255,255,0.08)"}}}function kDt(e){switch(e){case"pixel":return"flex items-center justify-between px-4 py-3 shrink-0";case"terminal":return"flex items-center justify-between px-4 py-3 shrink-0";case"modern":default:return"flex items-center justify-between px-5 py-4 border-b border-white/5 shrink-0"}}function zDt(e){switch(e){case"pixel":return{borderBottom:"3px solid var(--pixel-border, #444477)",background:"var(--pixel-surface, #222244)"};case"terminal":return{borderBottom:"1px solid #1a3a1a"};default:return{}}}function BDt(e){switch(e){case"pixel":return C.jsx("span",{style:{fontSize:"8px",lineHeight:"14px",color:"var(--pixel-gold, #ffd700)"},children:"SETTINGS"});case"terminal":return C.jsxs("span",{style:{color:"#00ff00",textShadow:"0 0 4px rgba(0,255,0,0.4)",fontSize:"12px"},children:["> settings",C.jsx("span",{style:{animation:"terminal-cursor-blink 0.6s step-end infinite",color:"#00ff00"},children:"█"})]});case"modern":default:return C.jsx("span",{className:"text-base font-semibold text-cam-text",children:"Settings"})}}function UDt(e){switch(e){case"pixel":return"flex items-center justify-center w-7 h-7 pixel-btn";case"terminal":return"flex items-center justify-center w-7 h-7";case"modern":default:return"flex items-center justify-center w-7 h-7 rounded-md text-cam-text-muted hover:text-cam-text hover:bg-white/5 transition-colors"}}function jDt(e){switch(e){case"pixel":return{color:"var(--pixel-text, #e8e8ff)"};case"terminal":return{color:"#00aa00"};default:return{}}}function FDt(e){switch(e){case"pixel":return"flex gap-0 px-3 pt-2 pb-0 shrink-0 flex-wrap";case"terminal":return"flex gap-0 px-4 pt-2 pb-0 shrink-0";case"modern":default:return"flex gap-1 px-5 pt-3 pb-0 shrink-0"}}function VDt(e){switch(e){case"pixel":return{borderBottom:"3px solid var(--pixel-border, #444477)"};case"terminal":return{borderBottom:"1px solid #1a3a1a"};default:return{}}}function HDt(e,t){switch(e){case"pixel":return t?"pixel-btn-active px-2 py-1.5":"pixel-btn px-2 py-1.5";case"terminal":return`px-3 py-1.5 ${t?"":"hover:bg-[#0a1f0a]"}`;case"modern":default:return`px-3 py-1.5 text-xs font-medium rounded-md transition-colors ${t?"bg-cam-accent text-white":"text-cam-text-muted hover:text-cam-text hover:bg-white/5"}`}}function GDt(e,t){switch(e){case"pixel":return{fontSize:"6px",lineHeight:"10px",fontFamily:"'Press Start 2P', monospace"};case"terminal":return{fontSize:"11px",fontFamily:"'JetBrains Mono', monospace",color:t?"#00ff00":"#00aa00",textShadow:t?"0 0 4px rgba(0,255,0,0.4)":"none",borderBottom:t?"2px solid #00ff00":"2px solid transparent",background:"transparent"};default:return{}}}function WDt(e,t,i){return e==="terminal"?i?`> ${t}`:` ${t}`:e==="pixel"?t.toUpperCase():t}function qDt(e){switch(e){case"pixel":return"flex-1 overflow-y-auto px-4 py-3 pixel-scrollbar";case"terminal":return"flex-1 overflow-y-auto px-4 py-3 terminal-scrollbar";case"modern":default:return"flex-1 overflow-y-auto px-5 py-4 modern-scrollbar"}}function XDt({isOpen:e,onClose:t}){const[i,r]=ee.useState("appearance"),n=Di(c=>c.theme),a=ee.useCallback(c=>{c.key==="Escape"&&t()},[t]);ee.useEffect(()=>{if(e)return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[e,a]);const s=ee.useCallback(()=>{t()},[t]),o=ee.useCallback(c=>{c.stopPropagation()},[]),l=()=>{switch(i){case"appearance":return C.jsx(MDt,{});case"agent-map":return C.jsx(TDt,{});case"activity-feed":return C.jsx(CDt,{});case"advanced":return C.jsx(DDt,{})}};return C.jsx(p0,{children:e&&C.jsxs(rc.div,{className:"fixed inset-0 z-50 flex items-center justify-center",variants:RDt,initial:"hidden",animate:"visible",exit:"exit",transition:{duration:.2},onClick:s,children:[C.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm"}),n==="terminal"&&C.jsx("div",{className:"absolute inset-0 pointer-events-none z-[51]",style:{background:"repeating-linear-gradient(0deg, rgba(0,0,0,0.15) 0px, rgba(0,0,0,0.15) 1px, transparent 1px, transparent 3px)"}}),C.jsxs(rc.div,{className:NDt(n),style:LDt(n),variants:IDt,initial:"hidden",animate:"visible",exit:"exit",transition:{duration:.25,ease:"easeOut"},onClick:o,children:[C.jsxs("header",{className:kDt(n),style:zDt(n),children:[C.jsx("h2",{children:BDt(n)}),C.jsx("button",{onClick:t,className:UDt(n),style:jDt(n),"aria-label":"Close",children:n==="terminal"?C.jsx("span",{style:{fontSize:"12px"},children:"[X]"}):n==="pixel"?C.jsx("span",{style:{fontSize:"8px",fontFamily:"'Press Start 2P', monospace"},children:"X"}):C.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[C.jsx("line",{x1:"1",y1:"1",x2:"13",y2:"13"}),C.jsx("line",{x1:"13",y1:"1",x2:"1",y2:"13"})]})})]}),C.jsx("nav",{className:FDt(n),style:VDt(n),children:ODt.map(c=>C.jsx("button",{onClick:()=>r(c.id),className:HDt(n,i===c.id),style:GDt(n,i===c.id),children:WDt(n,c.label,i===c.id)},c.id))}),C.jsx("main",{className:qDt(n),children:l()})]})]})})}function YDt(e){ee.useEffect(()=>{function t(i){for(const r of e){const n=r.ctrl?i.ctrlKey||i.metaKey:!0,a=r.alt?i.altKey:!0,s=r.shift?i.shiftKey:!0;if(i.key===r.key&&n&&a&&s){const o=i.target;if(o.tagName==="INPUT"||o.tagName==="TEXTAREA"||o.isContentEditable)return;i.preventDefault(),r.handler();return}}}return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e])}function $Dt(){const{theme:e}=$P(),t=Di(u=>u.toggleLockPanels),{settingsOpen:i,sidebarCollapsed:r,closeSettings:n,toggleSettings:a,toggleSidebar:s,openSettings:o}=jEe(),l=ee.useMemo(()=>[{key:",",ctrl:!0,handler:a,description:"Toggle settings modal"},{key:"l",ctrl:!0,handler:t,description:"Toggle panel lock"},{key:"b",ctrl:!0,handler:s,description:"Toggle sidebar"}],[t,a,s]);YDt(l);const c=(()=>{switch(e){case"terminal":return C.jsx(gPt,{});case"pixel":return C.jsx(KPt,{});case"modern":default:return C.jsx(jCt,{})}})();return C.jsxs("div",{className:"flex h-screen w-screen overflow-hidden",children:[C.jsx(_Dt,{collapsed:r,onToggleCollapse:s,onOpenSettings:o}),C.jsx("div",{className:"flex-1 overflow-hidden",children:c}),C.jsx(XDt,{isOpen:i,onClose:n})]})}let KDt=0;const NI=sg(e=>({toasts:[],addToast:t=>{const i=`toast-${++KDt}`,r={...t,id:i,createdAt:Date.now()};e(n=>({toasts:[...n.toasts,r].slice(-5)})),setTimeout(()=>{e(n=>({toasts:n.toasts.filter(a=>a.id!==i)}))},t.duration)},removeToast:t=>e(i=>({toasts:i.toasts.filter(r=>r.id!==t)})),clearAll:()=>e({toasts:[]})}));function Dpe({toast:e,onDismiss:t}){const i={info:"border-blue-500/50 bg-blue-500/10",success:"border-cam-success/50 bg-cam-success/10",warning:"border-amber-500/50 bg-amber-500/10",error:"border-cam-error/50 bg-cam-error/10"},r={info:"text-blue-400",success:"text-cam-success",warning:"text-amber-400",error:"text-cam-error"},n={info:"ℹ",success:"✓",warning:"⚠",error:"✗"};return C.jsxs("div",{className:`flex items-start gap-2 px-3 py-2 rounded-lg border backdrop-blur-sm ${i[e.type]} animate-slide-in-right`,style:{minWidth:"240px",maxWidth:"360px"},children:[C.jsx("span",{className:`text-sm mt-0.5 ${r[e.type]}`,children:n[e.type]}),C.jsxs("div",{className:"flex-1 min-w-0",children:[C.jsx("p",{className:"text-xs font-medium text-cam-text",children:e.title}),e.message&&C.jsx("p",{className:"text-xs text-cam-text-muted mt-0.5",children:e.message})]}),C.jsx("button",{onClick:t,className:"text-cam-text-muted hover:text-cam-text text-xs ml-1 shrink-0",children:"x"})]})}function QDt({toast:e,onDismiss:t}){const i={info:"var(--pixel-blue, #4488ff)",success:"var(--pixel-green)",warning:"var(--pixel-gold)",error:"var(--pixel-error)"},r={info:"◆",success:"★",warning:"!",error:"☠"};return C.jsx("div",{className:"pixel-border animate-slide-in-right",style:{background:"var(--pixel-panel)",borderColor:i[e.type],borderWidth:"2px",borderStyle:"solid",padding:"6px 10px",minWidth:"240px",maxWidth:"360px"},children:C.jsxs("div",{className:"flex items-start gap-2",children:[C.jsx("span",{className:"pixel-text-xs",style:{color:i[e.type]},children:r[e.type]}),C.jsxs("div",{className:"flex-1 min-w-0",children:[C.jsx("p",{className:"pixel-text-xs",style:{color:i[e.type]},children:e.title}),e.message&&C.jsx("p",{className:"pixel-text-xs",style:{color:"var(--pixel-text-muted)"},children:e.message})]}),C.jsx("button",{onClick:t,className:"pixel-text-xs",style:{color:"var(--pixel-text-muted)"},children:"x"})]})})}function ZDt({toast:e,onDismiss:t}){const r={info:{text:"[INFO]",color:"#00ff00"},success:{text:"[OK]",color:"#00ff00"},warning:{text:"[WARN]",color:"#ffaa00"},error:{text:"[ERR]",color:"#ff0000"}}[e.type];return C.jsxs("div",{className:"font-mono text-[11px] border border-[#1a3a1a] bg-[#0a0a0a] px-2 py-1 animate-slide-in-right",style:{minWidth:"240px",maxWidth:"360px"},children:[C.jsxs("div",{className:"flex items-start gap-1",children:[C.jsx("span",{style:{color:r.color},children:r.text}),C.jsx("span",{className:"text-[#00ff00] flex-1",children:e.title}),C.jsx("button",{onClick:t,className:"text-[#555] hover:text-[#00ff00]",children:"[x]"})]}),e.message&&C.jsx("div",{className:"text-[#00aa00] ml-7",children:e.message})]})}function JDt(){const{toasts:e,removeToast:t}=NI(),{theme:i}=$P();if(e.length===0)return null;const r={modern:Dpe,pixel:QDt,terminal:ZDt}[i]??Dpe;return C.jsx("div",{className:"fixed top-16 right-4 z-[100] flex flex-col gap-2",children:e.map(n=>C.jsx(r,{toast:n,onDismiss:()=>t(n.id)},n.id))})}function e3t(){return new URLSearchParams(window.location.search).has("session_id")}function t3t(){const{session:e,setSession:t,setProjectId:i}=Ni(),r=ee.useRef(!1),n=ee.useCallback(async()=>{if(!r.current){if(e3t()){r.current=!0;return}try{try{const{registrations:s}=await QEe();if(s.length>0){const o=s.find(u=>u.project_status==="active")||s[0];i(o.project_id);const{sessions:l}=await Y7(o.project_id),c=l.find(u=>u.status==="active");if(c){const{session:u}=await gC(c.id);t(u),r.current=!0;return}}r.current=!0;return}catch{}i(null);const{sessions:a}=await q7({status:"active",limit:1});if(a.length>0){const{session:s}=await gC(a[0].id);t(s),r.current=!0}}catch{}}},[t,i]);return ee.useEffect(()=>{n();const a=setInterval(n,15e3);return()=>clearInterval(a)},[n]),{session:e,refreshSession:n}}class i3t{constructor(t){iE(this,"source",null);iE(this,"options");iE(this,"reconnectTimer",null);iE(this,"shouldReconnect",!0);this.options=t}connect(){this.source&&this.disconnect();const t=new URL(this.options.url,window.location.origin);this.options.projectId?t.searchParams.set("project_id",this.options.projectId):this.options.sessionId&&t.searchParams.set("session_id",this.options.sessionId),this.source=new EventSource(t.toString()),this.source.onopen=()=>{var i,r;(r=(i=this.options).onConnect)==null||r.call(i)},this.source.onerror=i=>{var r,n,a,s;(n=(r=this.options).onError)==null||n.call(r,i),(s=(a=this.options).onDisconnect)==null||s.call(a),this.shouldReconnect&&this.scheduleReconnect()},this.addListener("agent_event",this.options.onEvent),this.addListener("agent_status",this.options.onAgentStatus),this.addListener("session_status",this.options.onSessionStatus),this.addListener("task_status_changed",this.options.onTaskStatusChanged),this.addListener("task_assigned",this.options.onTaskAssigned),this.addListener("sprint_progress",this.options.onSprintProgress),this.addListener("project_progress",this.options.onProjectProgress),this.addListener("task_blocked",this.options.onTaskBlocked),this.addListener("task_unblocked",this.options.onTaskUnblocked),this.addListener("correlation_match",this.options.onCorrelationMatch),this.addListener("agent_created",this.options.onAgentCreated),this.addListener("team_created",this.options.onTeamCreated),this.addListener("heartbeat",this.options.onHeartbeat)}addListener(t,i){!this.source||!i||this.source.addEventListener(t,r=>{try{const n=JSON.parse(r.data);i(n)}catch{}})}scheduleReconnect(){this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.reconnectTimer=setTimeout(()=>{this.connect()},this.options.reconnectDelay??3e3)}disconnect(){this.shouldReconnect=!1,this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.source&&(this.source.close(),this.source=null)}reconnect(){this.shouldReconnect=!0,this.connect()}}function r3t(e){const t=ee.useRef(null),i=Ni(d=>d.projectId),{addEvent:r,addAgent:n,updateAgent:a,setConnected:s,setConnectionStatus:o,setLastHeartbeat:l}=Ni(),{updateTask:c,updateActiveProject:u,updateActiveSprint:h}=_n();return ee.useEffect(()=>{if(!e){o("disconnected");return}const d=new i3t({url:"/api/stream",sessionId:e,projectId:i??void 0,onConnect:()=>{s(!0),o("connected")},onDisconnect:()=>{s(!1),o("reconnecting")},onEvent:f=>{r(f),f.agentId&&n({id:f.agentId,sessionId:f.sessionId,name:f.agentId,type:"agent",status:"active",firstSeenAt:f.timestamp,lastActivityAt:f.timestamp,toolCallCount:0,errorCount:0})},onAgentStatus:f=>{a(f.agent,{status:f.status}),(f.status==="shutdown"||f.status==="completed")&&NI.getState().addToast({type:"info",title:`Agent ${f.agent} finished`,duration:4e3})},onSessionStatus:f=>{const m=Ni.getState().session;f.status==="completed"||f.status==="error"?m&&(m.id===f.session||!f.session)&&(Ni.getState().setSession({...m,status:f.status,endedAt:new Date().toISOString()}),NI.getState().addToast({type:f.status==="completed"?"info":"error",title:f.status==="completed"?"Session ended":"Session ended with error",duration:5e3})):f.status==="active"&&m&&(m.id===f.session||!f.session)&&Ni.getState().setSession({...m,status:"active",endedAt:void 0})},onTaskStatusChanged:f=>{c(f.taskId,{status:f.newStatus})},onTaskAssigned:f=>{c(f.taskId,{assignedAgent:f.agent})},onSprintProgress:f=>{h({completedTasks:f.completedTasks,totalTasks:f.totalTasks})},onProjectProgress:f=>{u({completedTasks:f.completedTasks,totalTasks:f.totalTasks})},onTaskBlocked:f=>{c(f.taskId,{status:"blocked",blockedBy:f.blockedBy})},onTaskUnblocked:f=>{c(f.taskId,{status:"pending",blockedBy:[]})},onCorrelationMatch:()=>{},onAgentCreated:f=>{const m=f.name||f.agent;n({id:f.agent,sessionId:f.sessionId,name:m,type:f.type||"agent",status:f.status||"active",firstSeenAt:f.timestamp,lastActivityAt:f.timestamp,toolCallCount:0,errorCount:0}),NI.getState().addToast({type:"success",title:`Agent ${m} joined`,message:f.type?`Type: ${f.type}`:void 0,duration:4e3})},onTeamCreated:()=>{},onHeartbeat:f=>{l(f.timestamp)}});return d.connect(),t.current=d,()=>{d.disconnect(),t.current=null}},[e,i,r,n,a,s,o,l,c,u,h]),t.current}function n3t(){const{projects:e,activeProject:t,setProjects:i,setActiveProject:r}=_n(),n=ee.useRef(!1);return ee.useEffect(()=>{let a=!1;async function s(){try{const{projects:l}=await XEe();a||(i(l),!n.current&&l.length>0&&(_n.getState().activeProject||r(l[0]),n.current=!0))}catch{}}s();const o=setInterval(s,15e3);return()=>{a=!0,clearInterval(o)}},[i,r]),{projects:e,activeProject:t}}function a3t(){const{projects:e,activeProject:t,setActiveProject:i}=_n(),r=ee.useRef(!1);ee.useEffect(()=>{if(r.current||e.length===0)return;const a=new URLSearchParams(window.location.search).get("project_id");if(a){const s=e.find(o=>o.id===a);s&&i(s)}r.current=!0},[e,i]),ee.useEffect(()=>{if(t){const n=new URLSearchParams(window.location.search);n.get("project_id")!==t.id&&(n.set("project_id",t.id),window.history.replaceState({},"",`?${n.toString()}`))}},[t])}function s3t(){const{session:e,setSession:t}=Ni(),i=ee.useRef(!1);ee.useEffect(()=>{if(i.current)return;i.current=!0;const n=new URLSearchParams(window.location.search).get("session_id");n&&o3t(n)},[]),ee.useEffect(()=>{if(!e)return;const r=e.id.slice(0,8),n=new URLSearchParams(window.location.search);n.get("session_id")!==r&&(n.set("session_id",r),window.history.replaceState({},"",`?${n.toString()}`))},[e==null?void 0:e.id])}async function o3t(e){const{setSession:t}=Ni.getState();if(e.length>8)try{const{session:i}=await gC(e);if(i){t(i);return}}catch{}try{const{sessions:i}=await q7({limit:50}),r=i.find(n=>n.id.startsWith(e));if(r){const{session:n}=await gC(r.id);n&&t(n)}}catch{}}function l3t(){const e=Di(s=>s.theme),t=Di(s=>s.accentColor),i=Di(s=>s.activityWindow),r=Di(s=>s.showLabels),n=Di(s=>s.showInteractions),a=Di(s=>s.displayMode);ee.useEffect(()=>{const s=$P.getState();s.theme!==e&&s.setTheme(e),s.accentColor!==t&&s.setAccentColor(t)},[e,t]),ee.useEffect(()=>{const s=Ni.getState();s.activityWindow!==i&&s.setActivityWindow(i)},[i]),ee.useEffect(()=>{const s=C_.getState();s.showLabels!==r&&s.toggleLabels(),s.showInteractions!==n&&s.toggleInteractions(),s.displayMode!==a&&s.setDisplayMode(a)},[r,n,a])}function c3t(){const{session:e}=t3t();return r3t(e==null?void 0:e.id),n3t(),lz(),T0(),Dye(),a3t(),s3t(),l3t(),C.jsxs(C.Fragment,{children:[C.jsx($Dt,{}),C.jsx(JDt,{})]})}LEe.createRoot(document.getElementById("root")).render(C.jsx(ee.StrictMode,{children:C.jsx(c3t,{})}));export{Vv as c,En as g};
|
|
12445
|
-
//# sourceMappingURL=index-
|
|
12444
|
+
└────────────────────────┘`})})}):C.jsx("div",{className:"h-full flex gap-1 p-2 overflow-x-auto terminal-scrollbar font-mono text-[11px]",children:K_.map(r=>{const n=i[r.id]||[],a=aPt[r.id]||"terminal-dim",s=nPt[r.id]||" ";return C.jsxs("div",{className:"flex-shrink-0 w-52 flex flex-col border border-[#1a3a1a] bg-[#0a0a0a]",children:[C.jsx("div",{className:"px-2 py-1 border-b border-[#1a3a1a] shrink-0",children:C.jsxs("div",{className:"flex items-center justify-between",children:[C.jsxs("span",{className:`text-[10px] font-bold uppercase ${a}`,children:["[",s,"] ",r.label]}),C.jsxs("span",{className:"terminal-dim text-[10px]",children:["(",n.length,")"]})]})}),C.jsx("div",{className:"flex-1 overflow-y-auto terminal-scrollbar p-1 space-y-1",children:n.map(o=>C.jsx(lPt,{task:o},o.id))})]},r.id)})})}function lPt({task:e}){const{selectTask:t,selectedTaskId:i}=_n(),r=oz(),n=sPt[e.priority]||" ",a=W7(e.prdSection);return C.jsxs("div",{className:`terminal-card p-1.5 text-[10px] cursor-pointer ${i===e.id?"border border-[#00ccff]":""}`,onClick:()=>t(e.id),children:[C.jsxs("div",{className:"flex items-center gap-1 mb-0.5",children:[C.jsx("span",{className:`${e.priority==="critical"||e.priority==="high"?"terminal-error":"terminal-dim"}`,children:n}),e.complexity&&C.jsxs("span",{className:"terminal-dim",children:["C",e.complexity]}),a&&C.jsxs("span",{className:"text-[#00ff00]",children:["[",a,"]"]})]}),C.jsx("div",{className:"text-[#00cc00] leading-tight mb-1 line-clamp-2",children:e.title}),C.jsxs("div",{className:"flex items-center justify-between terminal-dim",children:[e.assignedAgent?C.jsxs("span",{children:["@",r(e.assignedAgent)]}):C.jsx("span",{className:"italic",children:"unassigned"}),e.tags&&e.tags.length>0&&C.jsxs("span",{children:["#",e.tags[0]]})]}),e.blockedBy.length>0&&C.jsx("div",{className:"terminal-error mt-0.5",children:"! blocked by "+e.blockedBy.length+" task"+(e.blockedBy.length>1?"s":"")})]})}function cPt(e,t=20){const i=Math.round(e/100*t),r=t-i;return"["+("█".repeat(i)+"░".repeat(r))+"] "+e+"%"}function uPt(){const{activeSprint:e}=lz(),t=T0(),i=ee.useMemo(()=>{if(!e)return{total:0,completed:0,inProgress:0,blocked:0,pending:0,percent:0};const r=t.filter(u=>u.sprintId===e.id),n=r.length||e.totalTasks||0,a=r.filter(u=>u.status==="completed").length,s=r.filter(u=>u.status==="in_progress").length,o=r.filter(u=>u.status==="blocked").length,l=n-a-s-o,c=n>0?Math.round(a/n*100):0;return{total:n,completed:a,inProgress:s,blocked:o,pending:l,percent:c}},[e,t]);return e?C.jsxs("div",{className:"p-3 border-b border-[#1a3a1a] font-mono text-[11px]",children:[C.jsxs("div",{className:"flex items-center justify-between mb-2",children:[C.jsx("span",{className:"terminal-muted",children:"## SPRINT ##"}),C.jsx("span",{className:"text-[#00ccff] text-[10px]",children:e.name})]}),C.jsx("div",{className:"text-[#00ff00] terminal-glow mb-2",children:cPt(i.percent,24)}),C.jsxs("div",{className:"space-y-0.5 text-[10px]",children:[C.jsxs("div",{className:"flex items-center gap-2",children:[C.jsx("span",{className:"text-[#00ff00] w-[12px]",children:"+"}),C.jsx("span",{className:"terminal-dim flex-1",children:"Completed"}),C.jsx("span",{className:"text-[#00ff00]",children:i.completed})]}),C.jsxs("div",{className:"flex items-center gap-2",children:[C.jsx("span",{className:"text-[#00ccff] w-[12px]",children:"*"}),C.jsx("span",{className:"terminal-dim flex-1",children:"In Progress"}),C.jsx("span",{className:"text-[#00ccff]",children:i.inProgress})]}),C.jsxs("div",{className:"flex items-center gap-2",children:[C.jsx("span",{className:"terminal-muted w-[12px]",children:"-"}),C.jsx("span",{className:"terminal-dim flex-1",children:"Pending"}),C.jsx("span",{className:"terminal-muted",children:i.pending})]}),C.jsxs("div",{className:"flex items-center gap-2",children:[C.jsx("span",{className:"terminal-error w-[12px]",children:"!"}),C.jsx("span",{className:"terminal-dim flex-1",children:"Blocked"}),C.jsx("span",{className:i.blocked>0?"terminal-error":"terminal-dim",children:i.blocked})]}),C.jsxs("div",{className:"border-t border-[#1a3a1a] mt-1 pt-1 flex items-center gap-2",children:[C.jsx("span",{className:"terminal-dim w-[12px]",children:"="}),C.jsx("span",{className:"terminal-dim flex-1",children:"Total"}),C.jsx("span",{className:"text-[#00ff00]",children:i.total})]})]})]}):C.jsx("div",{className:"p-3 font-mono text-[11px]",children:C.jsx("span",{className:"terminal-dim",children:"> No active sprint"})})}function hPt(){const{activeSprint:e,tasks:t}=_n(),[i,r]=ee.useState("burndown"),{chart:n,maxVal:a}=ee.useMemo(()=>{if(!e)return{chart:[],maxVal:0};const c=t.filter(w=>w.sprintId===e.id),u=c.length;if(u===0)return{chart:[],maxVal:0};const h=c.filter(w=>w.completedAt).sort((w,S)=>new Date(w.completedAt).getTime()-new Date(S.completedAt).getTime()),d=e.startedAt?new Date(e.startedAt).getTime():Date.now()-36e5,m=Date.now()-d,y=10,g=[];for(let w=0;w<=y;w++){const S=d+m/y*w,M=h.filter(P=>new Date(P.completedAt).getTime()<=S).length,E=new Date(S).getHours(),T=new Date(S).getMinutes(),R=`${String(E).padStart(2,"0")}:${String(T).padStart(2,"0")}`;i==="burndown"?g.push({label:R,actual:u-M,ideal:Math.max(0,Math.round(u-u/y*w))}):g.push({label:R,actual:M,ideal:Math.round(u/y*w)})}const x=Math.max(u,...g.map(w=>Math.max(w.actual,w.ideal)));return{chart:g,maxVal:x}},[e,t,i]);if(!e||n.length===0)return C.jsxs("div",{className:"p-3 border-b border-[#1a3a1a] font-mono text-[11px]",children:[C.jsx("div",{className:"flex items-center justify-between mb-2",children:C.jsx("span",{className:"terminal-muted",children:"## BURNDOWN ##"})}),C.jsx("div",{className:"terminal-dim text-center py-4",children:"> No data available"})]});const s=8,o=n.length,l=[];for(let c=s;c>=0;c--){const u=c/s*a;let h="";for(let d=0;d<o;d++){const f=n[d],m=f.actual>=u,y=f.ideal>=u;m&&y?h+="#":m?h+="*":y?h+=".":h+=" ",h+=" "}l.push(h)}return C.jsxs("div",{className:"p-3 border-b border-[#1a3a1a] font-mono text-[11px]",children:[C.jsxs("div",{className:"flex items-center justify-between mb-2",children:[C.jsx("span",{className:"terminal-muted",children:"## "+(i==="burndown"?"BURNDOWN":"BURNUP")+" ##"}),C.jsxs("div",{className:"flex items-center gap-1",children:[C.jsx("button",{onClick:()=>r("burndown"),className:`px-1.5 py-0.5 text-[9px] border ${i==="burndown"?"text-[#00ff00] border-[#00aa00] bg-[#0a1f0a]":"terminal-dim border-[#1a3a1a]"}`,children:"DN"}),C.jsx("button",{onClick:()=>r("burnup"),className:`px-1.5 py-0.5 text-[9px] border ${i==="burnup"?"text-[#00ff00] border-[#00aa00] bg-[#0a1f0a]":"terminal-dim border-[#1a3a1a]"}`,children:"UP"})]})]}),C.jsxs("div",{className:"bg-[#050505] border border-[#1a3a1a] p-2 text-[10px]",children:[C.jsxs("div",{className:"flex",children:[C.jsxs("div",{className:"flex flex-col justify-between text-right pr-1 terminal-dim text-[9px] shrink-0 w-[20px]",children:[C.jsx("span",{children:a}),C.jsx("span",{children:Math.round(a/2)}),C.jsx("span",{children:"0"})]}),C.jsx("div",{className:"flex-1",children:C.jsx("div",{className:"border-l border-b border-[#1a3a1a] pl-1 pb-1",children:l.map((c,u)=>C.jsx("div",{className:"leading-none",children:C.jsx("span",{className:"text-[#00ff00]",children:c.split("").map((h,d)=>h==="*"?C.jsx("span",{className:"text-[#00ff00] terminal-glow",children:h},d):h==="."?C.jsx("span",{className:"terminal-dim",children:h},d):h==="#"?C.jsx("span",{className:"text-[#00ccff]",children:h},d):C.jsx("span",{children:h},d))})},u))})})]}),C.jsxs("div",{className:"flex items-center gap-3 mt-1 text-[9px]",children:[C.jsx("span",{className:"text-[#00ff00]",children:"* actual"}),C.jsx("span",{className:"terminal-dim",children:". ideal"}),C.jsx("span",{className:"text-[#00ccff]",children:"# overlap"})]})]})]})}const ype={backlog:{char:".",color:"terminal-dim"},planned:{char:"-",color:"text-[#00ccff]"},pending:{char:"-",color:"text-[#00ccff]"},in_progress:{char:"*",color:"text-[#00ff00]"},in_review:{char:"?",color:"terminal-muted"},completed:{char:"+",color:"text-[#00ff00]"},blocked:{char:"!",color:"terminal-error"},deferred:{char:".",color:"terminal-dim"}};function xpe(e,t=12){const i=Math.round(e/100*t),r=t-i;return"█".repeat(i)+"░".repeat(r)}function dPt(){const{activeProject:e,tasks:t,sprints:i,selectTask:r}=_n(),[n,a]=ee.useState(null),[s,o]=ee.useState(null),l=ee.useMemo(()=>{if(!e||t.length===0||i.length===0)return[];const c=new Map;for(const d of i)c.set(d.id,d);const u=new Map;for(const d of t){const f=d.sprintId||"unknown";u.has(f)||u.set(f,new Map);const m=u.get(f),y=d.prdSection||"Uncategorized";m.has(y)||m.set(y,{name:y,total:0,completed:0,inProgress:0,blocked:0,percent:0,tasks:[],order:d.prdLineStart??999});const g=m.get(y);g.total++,g.tasks.push(d),d.status==="completed"&&g.completed++,d.status==="in_progress"&&g.inProgress++,d.status==="blocked"&&g.blocked++}const h=[];for(const[d,f]of u){const m=c.get(d);if(!m)continue;const y=Array.from(f.values());for(const w of y)w.percent=w.total>0?Math.round(w.completed/w.total*100):0;y.sort((w,S)=>w.order-S.order);const g=y.reduce((w,S)=>w+S.total,0),x=y.reduce((w,S)=>w+S.completed,0);h.push({sprint:m,sections:y,total:g,completed:x,percent:g>0?Math.round(x/g*100):0})}return h.sort((d,f)=>(d.sprint.order??0)-(f.sprint.order??0)),h},[e,t,i]);return l.length===0?C.jsx("div",{className:"h-full flex items-center justify-center font-mono text-[11px]",children:C.jsxs("div",{className:"terminal-dim text-center",children:[C.jsx("p",{children:"## PRD OVERVIEW ##"}),C.jsx("p",{className:"mt-1",children:"> Import a PRD to see section progress"})]})}):C.jsxs("div",{className:"p-2 font-mono text-[11px]",children:[C.jsxs("div",{className:"flex items-center justify-between mb-2",children:[C.jsx("span",{className:"terminal-muted",children:"## PRD SECTIONS ##"}),C.jsx("span",{className:"text-[#00ccff] text-[10px]",children:e==null?void 0:e.name})]}),C.jsx("div",{className:"border border-[#1a3a1a] bg-[#050505]",children:l.map(c=>{const u=n===c.sprint.id,h=c.percent===100?"text-[#00ff00]":"text-[#ffaa00]";return C.jsxs("div",{children:[C.jsxs("div",{className:"flex items-center gap-0 px-2 py-1.5 hover:bg-[#0a1a0a] transition-colors border-b border-[#1a3a1a] cursor-pointer",onClick:()=>a(u?null:c.sprint.id),children:[C.jsx("span",{className:"w-[24px] terminal-dim text-[10px]",children:u?"[-]":"[+]"}),C.jsx("span",{className:`flex-1 font-bold uppercase text-[11px] ${h}`,children:c.sprint.name}),C.jsxs("span",{className:`w-[110px] text-center text-[10px] ${h}`,children:[xpe(c.percent)," ",c.percent,"%"]}),C.jsxs("span",{className:"w-[50px] text-right text-[10px] text-[#00ff00]",children:[c.completed,"/",c.total]})]}),u&&C.jsxs("div",{className:"bg-[#030303]",children:[C.jsxs("div",{className:"flex items-center gap-0 px-2 py-0.5 border-b border-[#0a1a0a] terminal-dim text-[9px]",children:[C.jsx("span",{className:"w-[36px]"}),C.jsx("span",{className:"flex-1",children:"SECTION"}),C.jsx("span",{className:"w-[110px] text-center",children:"PROGRESS"}),C.jsx("span",{className:"w-[40px] text-right",children:"DONE"}),C.jsx("span",{className:"w-[30px] text-right",children:"ACT"}),C.jsx("span",{className:"w-[30px] text-right",children:"BLK"})]}),c.sections.map(d=>{const f=`${c.sprint.id}:${d.name}`,m=s===f,y=d.percent===100?"text-[#00ff00]":d.blocked>0?"terminal-error":d.inProgress>0?"text-[#00ccff]":"terminal-dim";return C.jsxs("div",{children:[C.jsxs("div",{className:"flex items-center gap-0 px-2 py-0.5 hover:bg-[#0a1a0a] transition-colors border-b border-[#0a1a0a] text-[10px] cursor-pointer",onClick:()=>o(m?null:f),children:[C.jsx("span",{className:"w-[12px]"}),C.jsx("span",{className:"w-[24px] terminal-dim",children:m?"[-]":"[+]"}),C.jsx("span",{className:"flex-1 truncate text-[#00cc00]",children:d.name}),C.jsxs("span",{className:`w-[110px] text-center ${y}`,children:[xpe(d.percent)," ",d.percent,"%"]}),C.jsxs("span",{className:"w-[40px] text-right text-[#00ff00]",children:[d.completed,"/",d.total]}),C.jsx("span",{className:`w-[30px] text-right ${d.inProgress>0?"text-[#00ccff]":"terminal-dim"}`,children:d.inProgress}),C.jsx("span",{className:`w-[30px] text-right ${d.blocked>0?"terminal-error":"terminal-dim"}`,children:d.blocked})]}),m&&C.jsx("div",{className:"bg-[#050505] border-b border-[#0a1a0a]",children:d.tasks.map(g=>{const x=ype[g.status]||ype.backlog;return C.jsxs("div",{onClick:()=>r(g.id),className:"cursor-pointer hover:bg-[#0a1a0a] px-6 py-0.5 text-[10px] flex items-center gap-1",children:[C.jsxs("span",{className:x.color,children:["[",x.char,"]"]}),C.jsx("span",{className:"text-[#00cc00] truncate flex-1",children:g.title}),g.assignedAgent&&C.jsxs("span",{className:"terminal-dim",children:["@",g.assignedAgent]})]},g.id)})})]},f)})]})]},c.sprint.id)})})]})}const zMe={backlog:".",planned:"-",pending:"~",in_progress:"*",in_review:"?",completed:"+",blocked:"!",deferred:"_"},BMe={backlog:"terminal-dim",planned:"text-[#00ccff]",pending:"terminal-muted",in_progress:"text-[#00ff00]",in_review:"terminal-muted",completed:"text-[#00ff00]",blocked:"terminal-error",deferred:"terminal-dim"};function fPt(){const{tasks:e}=_n(),{roots:t,edgeCount:i,nodeCount:r}=ee.useMemo(()=>{const n=new Map,a=new Map,s=new Map;for(const f of e){s.set(f.id,f);const m=new Set([...f.dependsOn,...f.blockedBy]);n.set(f.id,m)}const o=new Set;let l=0;for(const f of e){const m=n.get(f.id)??new Set;if(m.size>0){o.add(f.id);for(const y of m)o.add(y),l++,a.has(y)||a.set(y,new Set),a.get(y).add(f.id)}}if(o.size===0)return{roots:[],edgeCount:0,nodeCount:0};const c=new Set;for(const f of o){const m=n.get(f)??new Set;Array.from(m).some(g=>o.has(g))||c.add(f)}if(c.size===0){const f=Array.from(o).slice(0,3);for(const m of f)c.add(m)}const u=new Set;function h(f,m){if(u.has(f)||m>6)return null;u.add(f);const y=s.get(f);if(!y)return null;const g=a.get(f)??new Set,x=[];for(const w of g)if(o.has(w)){const S=h(w,m+1);S&&x.push(S)}return{task:y,children:x,depth:m}}const d=[];for(const f of c){const m=h(f,0);m&&d.push(m)}return{roots:d,edgeCount:l,nodeCount:o.size}},[e]);return t.length===0?C.jsxs("div",{className:"p-3 border-b border-[#1a3a1a] font-mono text-[11px]",children:[C.jsx("span",{className:"terminal-muted",children:"## DEPENDENCIES ##"}),C.jsx("div",{className:"terminal-dim text-center py-3",children:"> No task dependencies"})]}):C.jsxs("div",{className:"p-3 border-b border-[#1a3a1a] font-mono text-[11px]",children:[C.jsxs("div",{className:"flex items-center justify-between mb-2",children:[C.jsx("span",{className:"terminal-muted",children:"## DEPENDENCIES ##"}),C.jsxs("span",{className:"terminal-dim text-[10px]",children:[r," tasks ","·"," ",i," links"]})]}),C.jsx("div",{className:"bg-[#050505] border border-[#1a3a1a] p-2 overflow-auto terminal-scrollbar max-h-[280px]",children:t.map((n,a)=>C.jsx(UMe,{node:n,prefix:"",isLast:a===t.length-1},n.task.id))}),C.jsx("div",{className:"flex flex-wrap gap-x-3 gap-y-0.5 mt-1.5 text-[9px]",children:Object.entries(zMe).filter(([n])=>e.some(a=>a.status===n)).map(([n,a])=>C.jsxs("span",{className:BMe[n]||"terminal-dim",children:["[",a,"] ",n.replace(/_/g," ")]},n))})]})}function UMe({node:e,prefix:t,isLast:i}){const r=i?"└─":"├─",n=t+(i?" ":"│ "),a=zMe[e.task.status]||"?",s=BMe[e.task.status]||"terminal-dim",o=e.task.title.length>30?e.task.title.slice(0,27)+"...":e.task.title;return C.jsxs("div",{className:"text-[10px]",children:[C.jsxs("div",{className:"flex items-center gap-0 whitespace-nowrap",children:[C.jsxs("span",{className:"terminal-dim",children:[t,r]}),C.jsxs("span",{className:`font-bold ${s}`,children:["[",a,"]"]}),C.jsx("span",{className:"text-[#00cc00] ml-1",children:o}),e.task.assignedAgent&&C.jsxs("span",{className:"terminal-dim ml-1",children:["@",e.task.assignedAgent]})]}),e.children.map((l,c)=>C.jsx(UMe,{node:l,prefix:n,isLast:c===e.children.length-1},l.task.id))]})}function pPt(){const{viewMode:e,setViewMode:t,activeProject:i}=_n();return C.jsxs("div",{className:"flex items-center gap-2 font-mono text-[11px]",children:[C.jsx("button",{onClick:()=>t("agents"),className:`px-2 py-0.5 transition-colors ${e==="agents"?"text-[#00ff00] terminal-glow bg-[#0a1f0a]":"terminal-muted hover:text-[#00aa00]"}`,children:"[AGENTS]"}),C.jsx("button",{onClick:()=>t("tracker"),className:`px-2 py-0.5 transition-colors ${e==="tracker"?"text-[#00ff00] terminal-glow bg-[#0a1f0a]":"terminal-muted hover:text-[#00aa00]"}`,children:"[TRACKER]"}),i&&C.jsxs("span",{className:"terminal-muted",children:[i.completedTasks,"/",i.totalTasks]})]})}function mPt(){const{connectionStatus:e}=Ni(),t={connected:{className:"text-[#00ff00] terminal-glow",label:"[CONNECTED]",sublabel:"capturing events",sublabelClass:"text-[#00aa00]",showCursor:!0},reconnecting:{className:"text-[#ffaa00]",label:"[RECONNECTING...]",sublabel:"",sublabelClass:"",showCursor:!1},disconnected:{className:"terminal-error",label:"[DISCONNECTED]",sublabel:"waiting for server",sublabelClass:"terminal-error",showCursor:!1}}[e];return C.jsxs("div",{className:"flex items-center gap-1",children:[C.jsx("span",{className:t.className,children:t.label}),t.sublabel&&C.jsx("span",{className:t.sublabelClass,children:t.sublabel}),t.showCursor&&C.jsx("span",{className:"terminal-cursor-active"})]})}function gPt(){const{viewMode:e}=_n();return C.jsxs("div",{className:"h-full w-full flex flex-col terminal-bg terminal-boot overflow-hidden",children:[C.jsxs("header",{className:"h-10 flex items-center justify-between px-3 border-b border-[#1a3a1a] bg-[#0d0d0d] shrink-0 font-mono text-[11px] relative z-50",children:[C.jsxs("div",{className:"flex items-center gap-3",children:[C.jsx("span",{className:"text-[#00ff00] terminal-glow font-bold",children:"CAM://"}),C.jsx("span",{className:"text-[#00aa00]",children:"Claude Agent Monitor"}),C.jsx("span",{className:"terminal-dim",children:"|"}),C.jsx(mPt,{})]}),C.jsxs("div",{className:"flex items-center gap-3",children:[C.jsx(RX,{}),C.jsx(pPt,{})]})]}),C.jsx(HCt,{}),C.jsx(IK,{}),C.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[e==="agents"&&C.jsx(vPt,{}),e==="tracker"&&C.jsx(yPt,{})]})]})}function vPt(){return C.jsxs(C.Fragment,{children:[C.jsx("aside",{className:"w-48 border-r border-[#1a3a1a] overflow-y-auto terminal-scrollbar shrink-0",children:C.jsx(XCt,{})}),C.jsx("main",{className:"flex-1 overflow-hidden",children:C.jsx(MK,{})}),C.jsx("aside",{className:"w-72 border-l border-[#1a3a1a] terminal-scrollbar shrink-0",children:C.jsx(RK,{AgentDetail:tPt,ActivityFeed:QCt,FileWatcher:rPt,tabBarClass:"flex border-b border-[#1a3a1a] bg-[#0d0d0d]",activeTabClass:"text-[#00ff00] terminal-glow border-b-2 border-[#00ff00]",inactiveTabClass:"text-[#00aa00]/60 hover:text-[#00aa00]"})})]})}function yPt(){const{selectedTaskId:e}=_n();return C.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[C.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[C.jsx("main",{className:"flex-1 overflow-hidden",children:C.jsx(oPt,{})}),e&&C.jsx("aside",{className:"w-80 border-l border-[#1a3a1a] overflow-y-auto terminal-scrollbar shrink-0",children:C.jsx(EK,{})}),C.jsxs("aside",{className:"w-80 border-l border-[#1a3a1a] overflow-y-auto terminal-scrollbar shrink-0 flex flex-col",children:[C.jsx(uPt,{}),C.jsx(hPt,{}),C.jsx(fPt,{})]})]}),C.jsx("div",{className:"h-48 border-t border-[#1a3a1a] overflow-y-auto terminal-scrollbar shrink-0",children:C.jsx(dPt,{})})]})}const Ww={TIME:"⌛",PARTY:"⚔",SKILLS:"🎯",EVENTS:"📜",LOOT:"📦",POISON:"☠"};function xPt(){const{session:e,agents:t,events:i}=Ni(),[r,n]=ee.useState("00m 00s");ee.useEffect(()=>{if(!(e!=null&&e.startedAt))return;const u=()=>n(H7(e.startedAt,e.endedAt));if(u(),!e.endedAt){const h=setInterval(u,1e3);return()=>clearInterval(h)}},[e==null?void 0:e.startedAt,e==null?void 0:e.endedAt]);const a=t.filter(u=>u.status==="active").length,s=t.reduce((u,h)=>u+h.errorCount,0),o=t.reduce((u,h)=>u+h.toolCallCount,0),l=i.filter(u=>u.category==="file_change").length,c=[{label:"TIME",value:r,icon:Ww.TIME,color:"var(--pixel-text)"},{label:"PARTY",value:`${a}/${t.length}`,icon:Ww.PARTY,color:a>0?"var(--pixel-green)":"var(--pixel-text)"},{label:"SKILLS",value:Lm(o),icon:Ww.SKILLS,color:"var(--pixel-cyan)"},{label:"EVENTS",value:Lm((e==null?void 0:e.eventCount)??0),icon:Ww.EVENTS,color:"var(--pixel-text)"},{label:"LOOT",value:Lm(l),icon:Ww.LOOT,color:"var(--pixel-orange)"},{label:"POISON",value:String(s),icon:Ww.POISON,color:s>0?"var(--pixel-error)":"var(--pixel-text)"}];return C.jsx("div",{className:"h-11 flex items-center gap-0 px-4 shrink-0",style:{background:"var(--pixel-bg-dark)",borderBottom:"3px solid var(--pixel-border)"},children:c.map((u,h)=>C.jsxs("div",{className:"flex items-center gap-2",style:{borderLeft:h>0?"2px solid var(--pixel-border)":"none",paddingLeft:h>0?"12px":"0",marginLeft:h>0?"12px":"0"},children:[C.jsx("span",{className:"pixel-text-sm",children:u.icon}),C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-dim)"},children:u.label}),C.jsx("span",{className:"pixel-text-sm",style:{color:u.color,fontWeight:"bold"},children:u.value})]},u.label))})}const bPt={"team-lead":"PALADIN","code-writer":"MAGE","code-reviewer":"CLERIC",tester:"RANGER",researcher:"SCHOLAR",designer:"BARD"},wPt={"team-lead":"⚔","code-writer":"🧙","code-reviewer":"🛡",tester:"🎯",researcher:"📚",designer:"🎨"};function _Pt(e){const t=e.name.toLowerCase();for(const[i,r]of Object.entries(bPt))if(t.includes(i))return r;return e.type==="lead"?"PALADIN":"ADVENTURER"}function jMe(e){const t=e.name.toLowerCase();for(const[i,r]of Object.entries(wPt))if(t.includes(i))return r;return"⚔"}function FMe(e){switch(e){case"active":return{text:"FIGHTING",color:"var(--pixel-green)"};case"idle":return{text:"RESTING",color:"var(--pixel-orange)"};case"error":return{text:"POISONED",color:"var(--pixel-error)"};case"completed":return{text:"VICTORY",color:"var(--pixel-cyan)"};case"shutdown":return{text:"FALLEN",color:"var(--pixel-text-dim)"};default:return{text:e.toUpperCase(),color:"var(--pixel-text-muted)"}}}function SPt(e){return e.status==="active"}function APt(){const e=$7(),{selectedAgentId:t,selectAgent:i}=Ni(),[r,n]=ee.useState(!1),{activeAgents:a,inactiveAgents:s}=ee.useMemo(()=>{const o=[],l=[];for(const c of e)SPt(c)?o.push(c):l.push(c);return{activeAgents:o,inactiveAgents:l}},[e]);return e.length===0?C.jsxs("div",{className:"p-4 flex flex-col items-center justify-center h-full text-center",children:[C.jsx("div",{className:"pixel-text-xl mb-3",children:"\\u2694"}),C.jsx("p",{className:"pixel-text-sm",style:{color:"var(--pixel-text-muted)"},children:"WAITING FOR"}),C.jsx("p",{className:"pixel-text-sm mt-1 pixel-blink",style:{color:"var(--pixel-gold)"},children:"PARTY MEMBERS..."})]}):C.jsxs("div",{className:"p-2",children:[C.jsx("div",{className:"px-2 py-2 mb-2",children:C.jsxs("span",{className:"pixel-text-xs",style:{color:"var(--pixel-gold)"},children:["ACTIVE PARTY (",a.length,")"]})}),a.length>0?C.jsx("div",{className:"space-y-2",children:a.map(o=>C.jsx(EPt,{agent:o,isSelected:t===o.id,onSelect:()=>i(t===o.id?null:o.id)},o.id))}):C.jsx("div",{className:"px-2 py-3 text-center",children:C.jsx("p",{className:"pixel-text-xs",style:{color:"var(--pixel-text-muted)"},children:"NO ACTIVE HEROES"})}),s.length>0&&C.jsxs("div",{className:"mt-3",children:[C.jsx("button",{onClick:()=>n(!r),className:"w-full text-left px-2 py-1.5 pixel-card",style:{cursor:"pointer"},children:C.jsxs("div",{className:"flex items-center justify-between",children:[C.jsxs("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-dim)"},children:[r?"▼":"▶"," FALLEN/RESTING"]}),C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-gold)",background:"var(--pixel-bg-dark)",border:"1px solid var(--pixel-border)",padding:"0 4px"},children:s.length})]})}),r&&C.jsx("div",{className:"space-y-1 mt-1",children:s.map(o=>C.jsx(MPt,{agent:o,isSelected:t===o.id,onSelect:()=>i(t===o.id?null:o.id)},o.id))})]})]})}function MPt({agent:e,isSelected:t,onSelect:i}){const r=Ch(e.id,e.name,e.type??void 0),n=FMe(e.status),a=jMe(e);return C.jsx("button",{onClick:i,title:`${e.name} (${e.id})`,className:`w-full text-left px-2 py-1 ${t?"pixel-border-accent":"pixel-card"}`,style:{cursor:"pointer"},children:C.jsxs("div",{className:"flex items-center gap-2",children:[C.jsx("span",{className:"pixel-text-xs",children:a}),C.jsx("span",{className:"pixel-text-xs truncate",style:{color:"var(--pixel-text-dim)"},children:r}),C.jsx("span",{className:"pixel-text-xs shrink-0",style:{color:"var(--pixel-gold, #d4a017)"},children:e.type}),C.jsx("span",{className:"pixel-text-xs",style:{color:n.color},children:n.text}),C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-dim)"},children:qc(e.lastActivityAt)})]})})}function EPt({agent:e,isSelected:t,onSelect:i}){const r=f0(e.name),n=FMe(e.status),a=_Pt(e),s=jMe(e),o=100,l=e.errorCount>0?Math.max(10,o-e.errorCount*20):o,c=Math.min(100,e.toolCallCount%100),u=Ch(e.id,e.name,e.type??void 0);return C.jsxs("button",{onClick:i,title:`${e.name} (${e.id})`,className:`w-full text-left p-2 ${t?"pixel-border-accent":"pixel-card"}`,style:{cursor:"pointer"},children:[C.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[C.jsx("span",{className:"pixel-text-base",children:s}),C.jsxs("div",{className:"flex-1 min-w-0",children:[C.jsxs("div",{className:"flex items-center gap-1",children:[C.jsx("span",{className:"pixel-text-sm truncate",style:{color:r},children:u}),C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-gold, #d4a017)"},children:e.type})]}),C.jsxs("div",{className:"flex items-center gap-2",children:[C.jsxs("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-dim)"},children:["LV.",Math.min(99,Math.floor(e.toolCallCount/5)+1)]}),C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-dim)"},children:a})]})]})]}),C.jsxs("div",{className:"flex items-center gap-1 mb-1",children:[C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-hp)",width:"16px"},children:"HP"}),C.jsx("div",{className:"flex-1 pixel-bar-container pixel-bar-hp",children:C.jsx("div",{className:"pixel-bar-fill",style:{width:`${l}%`}})}),C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-muted)",width:"32px",textAlign:"right"},children:l})]}),C.jsxs("div",{className:"flex items-center gap-1 mb-1",children:[C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-mp)",width:"16px"},children:"MP"}),C.jsx("div",{className:"flex-1 pixel-bar-container pixel-bar-mp",children:C.jsx("div",{className:"pixel-bar-fill",style:{width:`${c}%`}})}),C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-muted)",width:"32px",textAlign:"right"},children:c})]}),C.jsxs("div",{className:"flex items-center justify-between",children:[C.jsx("span",{className:`pixel-text-xs ${e.status==="active"?"pixel-pulse":""}`,style:{color:n.color},children:n.text}),C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-dim)"},children:qc(e.lastActivityAt)})]}),e.errorCount>0&&C.jsxs("div",{className:"mt-1 pixel-text-xs pixel-shake",style:{color:"var(--pixel-error)"},children:["\\u2620 ",e.errorCount," CURSE",e.errorCount>1?"S":""]})]})}const VMe=new Set(["TaskList","TaskGet"]);function TPt(e){const t=[];let i=0;for(;i<e.length;){const r=e[i];if(r.tool&&VMe.has(r.tool)){let n=1;for(;i+n<e.length&&e[i+n].tool===r.tool&&e[i+n].agentId===r.agentId;)n++;t.push({event:r,count:n,groupId:`grp-${r.id}`}),i+=n}else t.push({event:r,count:1,groupId:r.id}),i++}return t}const CPt={Edit:"used ENCHANT!",Write:"cast CREATE!",Read:"used SCAN!",Bash:"cast INVOKE!",Grep:"used SEARCH!",Glob:"used DETECT!",TaskCreate:"used QUEST LOG!",TaskUpdate:"used QUEST UPDATE!",TaskList:"checked QUEST BOARD!",SendMessage:"cast TELEPATHY!",WebFetch:"used SCRY!",WebSearch:"cast DIVINATION!",NotebookEdit:"used TOME EDIT!"};function PPt(e){return e.error?{text:"IT MISSED!",color:"var(--pixel-error)"}:e.duration&&e.duration>5e3?{text:"IT WAS SLOW...",color:"var(--pixel-orange)"}:e.category==="error"?{text:"CRITICAL MISS!",color:"var(--pixel-error)"}:e.category==="file_change"?{text:"IT'S SUPER EFFECTIVE!",color:"var(--pixel-green)"}:{text:"HIT!",color:"var(--pixel-cyan)"}}function DPt(e){switch(e){case"tool_call":return"⚔";case"file_change":return"📦";case"command":return"💻";case"message":return"💬";case"lifecycle":return"🔄";case"error":return"☠";case"compact":return"📦";case"notification":return"🔔";default:return"●"}}function OPt(){const e=Dq(),t=Ni(m=>m.agents),{searchQuery:i,setSearchQuery:r}=az(),n=Di(m=>m.followMode),a=Di(m=>m.hidePolling),s=Di(m=>m.toggleFollowMode),o=Di(m=>m.toggleHidePolling),l=ee.useRef(null),[c,u]=ee.useState(null),h=ee.useMemo(()=>{const m=new Map;for(const y of t)m.set(y.id,Ch(y.id,y.name||y.id,y.type??void 0));return m},[t]);ee.useEffect(()=>{n&&l.current&&(l.current.scrollTop=0)},[e.length,n]);const d=ee.useMemo(()=>{let m=e;if(a&&(m=m.filter(y=>!y.tool||!VMe.has(y.tool))),i){const y=i.toLowerCase();m=m.filter(g=>{var x,w,S,M;return((x=g.tool)==null?void 0:x.toLowerCase().includes(y))||((w=g.filePath)==null?void 0:w.toLowerCase().includes(y))||((S=g.input)==null?void 0:S.toLowerCase().includes(y))||((M=g.output)==null?void 0:M.toLowerCase().includes(y))})}return m},[e,a,i]),f=ee.useMemo(()=>TPt(d),[d]);return C.jsxs("div",{className:"h-full flex flex-col",style:{background:"var(--pixel-bg)"},children:[C.jsxs("div",{className:"flex items-center justify-between px-4 py-2 shrink-0",style:{borderBottom:"3px solid var(--pixel-border)",background:"var(--pixel-surface)"},children:[C.jsxs("span",{className:"pixel-text-sm",style:{color:"var(--pixel-gold)"},children:["\\u2694 BATTLE LOG (",d.length,")"]}),C.jsxs("div",{className:"flex items-center gap-2",children:[C.jsx("input",{type:"text",placeholder:"SEARCH...",value:i,onChange:m=>r(m.target.value),className:"pixel-text-xs px-2 py-1",style:{width:"100px",background:"var(--pixel-bg-dark)",border:"2px solid var(--pixel-border)",color:"var(--pixel-text)",outline:"none",fontFamily:"'Press Start 2P', monospace"}}),C.jsx("button",{onClick:o,className:`pixel-text-xs px-2 py-1 ${a?"pixel-btn-active":"pixel-btn"}`,title:"Hide TaskList/TaskGet polling",children:a?"POLL:OFF":"POLL"}),C.jsx("button",{onClick:s,className:`pixel-text-xs px-2 py-1 ${n?"pixel-btn-active":"pixel-btn"}`,children:n?"AUTO":"MANUAL"})]})]}),C.jsx("div",{ref:l,className:"flex-1 overflow-y-auto pixel-scrollbar",children:d.length===0?C.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center p-8",children:[C.jsx("div",{className:"pixel-text-2xl mb-3",children:"\\u2694"}),C.jsx("p",{className:"pixel-text-sm",style:{color:"var(--pixel-text-muted)"},children:"NO ENCOUNTERS YET"}),C.jsx("p",{className:"pixel-text-xs mt-2 pixel-blink",style:{color:"var(--pixel-gold)"},children:"AWAITING BATTLE..."})]}):C.jsx("div",{children:f.map(({event:m,count:y,groupId:g},x)=>C.jsx("div",{className:"pixel-slide-in",style:{animationDelay:`${Math.min(x*.02,.2)}s`},children:C.jsx(RPt,{event:m,agentNameMap:h,isExpanded:c===m.id,groupCount:y,onToggle:()=>u(c===m.id?null:m.id)})},g))})})]})}function RPt({event:e,agentNameMap:t,isExpanded:i,groupCount:r,onToggle:n}){const[a,s]=ee.useState(!1),o=DPt(e.category),l=sz(e.tool||e.hookType),c=CPt[e.tool||""]||`used ${l.toUpperCase()}!`,u=PPt(e);return C.jsx("div",{className:"px-4 py-2 cursor-pointer",onClick:n,style:{borderBottom:"1px solid var(--pixel-border)",background:i?"var(--pixel-surface)":"transparent"},onMouseEnter:h=>{h.currentTarget.style.background="var(--pixel-surface)"},onMouseLeave:h=>{i||(h.currentTarget.style.background="transparent")},children:C.jsxs("div",{className:"flex items-start gap-3",children:[C.jsx("span",{className:"pixel-text-base mt-0.5 w-5 text-center shrink-0",children:o}),C.jsxs("div",{className:"flex-1 min-w-0",children:[C.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-cyan)"},title:e.agentId,children:t.get(e.agentId)??e.agentId.slice(0,8)}),C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text)"},title:e.tool||e.hookType,children:c}),r&&r>1&&C.jsxs("span",{className:"pixel-text-xs",style:{color:"var(--pixel-gold)",background:"var(--pixel-bg-dark)",border:"1px solid var(--pixel-border)",padding:"0 3px"},children:["x",r]})]}),C.jsx("span",{className:"pixel-text-xs",style:{color:u.color},children:u.text}),e.filePath&&C.jsx("div",{className:"mt-0.5",children:C.jsxs("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-dim)"},title:e.filePath,children:["TARGET: ",Ah(e.filePath)]})}),e.error&&C.jsxs("p",{className:"pixel-text-xs mt-0.5 pixel-shake",style:{color:"var(--pixel-error)"},children:["\\u2620 ",e.error]}),i&&C.jsxs("div",{className:"mt-2 space-y-2",onClick:h=>h.stopPropagation(),children:[e.input&&C.jsxs("div",{children:[C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-gold)"},children:"INPUT:"}),C.jsx("pre",{className:"mt-1 pixel-text-xs overflow-x-auto max-h-32 pixel-scrollbar whitespace-pre-wrap break-all p-2",style:{color:"var(--pixel-text-muted)",background:"var(--pixel-bg-dark)",border:"2px solid var(--pixel-border)",fontFamily:"'Press Start 2P', monospace"},children:a?e.input:Oq(e.tool,e.input)})]}),e.output&&C.jsxs("div",{children:[C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-gold)"},children:"OUTPUT:"}),C.jsx("pre",{className:"mt-1 pixel-text-xs overflow-x-auto max-h-32 pixel-scrollbar whitespace-pre-wrap break-all p-2",style:{color:"var(--pixel-text-muted)",background:"var(--pixel-bg-dark)",border:"2px solid var(--pixel-border)",fontFamily:"'Press Start 2P', monospace"},children:a?e.output:Rq(e.output)})]}),C.jsxs("div",{className:"flex items-center gap-2",children:[e.duration!==void 0&&C.jsxs("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-dim)"},children:["CAST TIME: ",e.duration,"ms"]}),(e.input||e.output)&&C.jsx("button",{onClick:h=>{h.stopPropagation(),s(!a)},className:"pixel-text-xs pixel-btn",style:{padding:"0 4px",fontSize:"7px"},children:a?"SUMMARY":"RAW"})]})]})]}),C.jsx("span",{className:"pixel-text-xs shrink-0",style:{color:"var(--pixel-text-dim)"},children:gu(e.timestamp)})]})})}const IPt=[{id:"activity",label:"LOG",icon:"📜"},{id:"files",label:"LOOT",icon:"📦"},{id:"errors",label:"CURSES",icon:"☠"},{id:"messages",label:"CHAT",icon:"💬"}];function NPt(){const{selectedAgentId:e,agents:t,events:i,selectAgent:r}=Ni(),[n,a]=ee.useState("activity"),s=t.find(E=>E.id===e);if(!s)return null;const o=i.filter(E=>E.agentId===s.id),l=o.filter(E=>E.category==="error"||E.error),c=o.filter(E=>E.filePath).reduce((E,T)=>(T.filePath&&!E.includes(T.filePath)&&E.push(T.filePath),E),[]),u=o.filter(E=>E.category==="message"),h=f0(s.name),d=Math.min(99,Math.floor(s.toolCallCount/5)+1),f=s.toolCallCount%50,m=50,y=s.errorCount>0?Math.max(10,100-s.errorCount*20):100,g=Math.min(100,s.toolCallCount%100),x=Math.min(99,Math.floor(s.toolCallCount/3)),w=Math.min(99,50-Math.min(50,s.errorCount*10)),S=Math.min(99,o.length>0?60:10),M=Math.min(99,s.errorCount===0?80:20);return C.jsxs("div",{className:"h-full flex flex-col",style:{background:"var(--pixel-bg)"},children:[C.jsxs("div",{className:"p-3 shrink-0",style:{borderBottom:"3px solid var(--pixel-border)",background:"var(--pixel-surface)"},children:[C.jsxs("div",{className:"flex items-center justify-between mb-2",children:[C.jsxs("div",{className:"flex items-center gap-2",children:[C.jsx("div",{className:"w-10 h-10 flex items-center justify-center pixel-border",style:{background:`${h}20`,color:h},children:C.jsx("span",{className:"pixel-text-lg font-bold",children:s.name.charAt(0).toUpperCase()})}),C.jsxs("div",{children:[C.jsx("h3",{className:"pixel-text-sm",style:{color:"var(--pixel-text)"},title:`${s.name} (${s.id})`,children:Ch(s.id,s.name,s.type??void 0)}),C.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[C.jsxs("span",{className:"pixel-text-xs",style:{color:"var(--pixel-gold)"},children:["LV.",d]}),C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-dim)"},children:s.type.toUpperCase()})]})]})]}),C.jsx("button",{onClick:()=>r(null),className:"pixel-btn px-2 py-1 pixel-text-xs",style:{color:"var(--pixel-text-muted)"},children:"X"})]}),C.jsxs("div",{className:"space-y-1 mb-2",children:[C.jsxs("div",{className:"flex items-center gap-1",children:[C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-hp)",width:"20px"},children:"HP"}),C.jsx("div",{className:"flex-1 pixel-bar-container pixel-bar-hp",children:C.jsx("div",{className:"pixel-bar-fill",style:{width:`${y}%`}})}),C.jsxs("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-muted)",width:"40px",textAlign:"right"},children:[y,"/100"]})]}),C.jsxs("div",{className:"flex items-center gap-1",children:[C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-mp)",width:"20px"},children:"MP"}),C.jsx("div",{className:"flex-1 pixel-bar-container pixel-bar-mp",children:C.jsx("div",{className:"pixel-bar-fill",style:{width:`${g}%`}})}),C.jsxs("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-muted)",width:"40px",textAlign:"right"},children:[g,"/100"]})]}),C.jsxs("div",{className:"flex items-center gap-1",children:[C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-xp)",width:"20px"},children:"XP"}),C.jsx("div",{className:"flex-1 pixel-bar-container pixel-bar-xp",children:C.jsx("div",{className:"pixel-bar-fill",style:{width:`${f/m*100}%`}})}),C.jsxs("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-muted)",width:"40px",textAlign:"right"},children:[f,"/",m]})]})]}),C.jsx("div",{className:"grid grid-cols-4 gap-1",children:[{label:"STR",value:x,color:"var(--pixel-hp)"},{label:"DEF",value:w,color:"var(--pixel-blue)"},{label:"SPD",value:S,color:"var(--pixel-green)"},{label:"LCK",value:M,color:"var(--pixel-gold)"}].map(E=>C.jsxs("div",{className:"text-center p-1",style:{background:"var(--pixel-bg-dark)",border:"2px solid var(--pixel-border)"},children:[C.jsx("div",{className:"pixel-text-sm font-bold",style:{color:E.color},children:E.value}),C.jsx("div",{className:"pixel-text-xs",style:{color:"var(--pixel-text-dim)"},children:E.label})]},E.label))})]}),C.jsx("div",{className:"flex shrink-0",style:{borderBottom:"3px solid var(--pixel-border)"},children:IPt.map(E=>{const T=E.id==="activity"?o.length:E.id==="files"?c.length:E.id==="errors"?l.length:u.length;return C.jsxs("button",{onClick:()=>a(E.id),className:"flex-1 py-2 pixel-text-xs text-center",style:{background:n===E.id?"var(--pixel-accent)":"var(--pixel-surface)",color:n===E.id?"#fff":"var(--pixel-text-muted)",borderRight:"2px solid var(--pixel-border)",cursor:"pointer"},children:[E.icon," ",E.label," (",T,")"]},E.id)})}),C.jsxs("div",{className:"flex-1 overflow-y-auto pixel-scrollbar",children:[n==="activity"&&C.jsx("div",{children:o.length===0?C.jsx("p",{className:"pixel-text-xs p-4 text-center",style:{color:"var(--pixel-text-muted)"},children:"NO ADVENTURE LOG YET"}):o.slice(0,100).map(E=>C.jsxs("div",{className:"px-3 py-2",style:{borderBottom:"1px solid var(--pixel-border)"},children:[C.jsxs("div",{className:"flex items-center justify-between",children:[C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-cyan)"},children:E.tool||E.hookType}),C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-dim)"},children:gu(E.timestamp)})]}),E.filePath&&C.jsx("span",{className:"pixel-text-xs block mt-0.5",style:{color:"var(--pixel-text-muted)"},title:E.filePath,children:Ah(E.filePath)})]},E.id))}),n==="files"&&C.jsx("div",{className:"p-2 space-y-1",children:c.length===0?C.jsx("p",{className:"pixel-text-xs p-4 text-center",style:{color:"var(--pixel-text-muted)"},children:"NO LOOT FOUND"}):c.map(E=>C.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5",style:{border:"1px solid var(--pixel-border)"},children:[C.jsx("span",{className:"pixel-text-xs",children:"\\📦"}),C.jsx("span",{className:"pixel-text-xs break-all",style:{color:"var(--pixel-text)"},title:E,children:Ah(E)})]},E))}),n==="errors"&&C.jsx("div",{children:l.length===0?C.jsx("p",{className:"pixel-text-xs p-4 text-center",style:{color:"var(--pixel-green)"},children:"NO CURSES! ALL CLEAR!"}):l.map(E=>C.jsxs("div",{className:"px-3 py-2",style:{borderBottom:"1px solid var(--pixel-border)"},children:[C.jsxs("div",{className:"flex items-center justify-between",children:[C.jsxs("span",{className:"pixel-text-xs",style:{color:"var(--pixel-error)"},children:["\\u2620 ",E.tool||E.hookType]}),C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-dim)"},children:gu(E.timestamp)})]}),E.error&&C.jsx("p",{className:"pixel-text-xs mt-0.5 break-all",style:{color:"var(--pixel-error)"},children:E.error})]},E.id))}),n==="messages"&&C.jsx("div",{children:u.length===0?C.jsx("p",{className:"pixel-text-xs p-4 text-center",style:{color:"var(--pixel-text-muted)"},children:"NO TELEPATHY LOGS"}):u.map(E=>C.jsxs("div",{className:"px-3 py-2",style:{borderBottom:"1px solid var(--pixel-border)"},children:[C.jsxs("div",{className:"flex items-center justify-between",children:[C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-purple)"},children:"\\💬 TELEPATHY"}),C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-dim)"},children:gu(E.timestamp)})]}),E.input&&C.jsx("p",{className:"pixel-text-xs mt-0.5 break-words whitespace-pre-wrap",style:{color:"var(--pixel-text-muted)"},children:E.input})]},E.id))})]})]})}const bpe={created:{icon:"✨",label:"NEW",rarity:"LEGENDARY",color:"var(--pixel-gold)"},modified:{icon:"🔮",label:"MOD",rarity:"RARE",color:"var(--pixel-purple)"},read:{icon:"📜",label:"READ",rarity:"COMMON",color:"var(--pixel-cyan)"}};function LPt(){const{session:e}=Ni(),[t,i]=ee.useState([]);ee.useEffect(()=>{if(!(e!=null&&e.id))return;let s=!1;async function o(){try{const{files:c}=await X7(e.id);s||i(c)}catch{}}o();const l=setInterval(o,5e3);return()=>{s=!0,clearInterval(l)}},[e==null?void 0:e.id]);const r=t.filter(s=>s.changeType==="created"),n=t.filter(s=>s.changeType==="modified"),a=t.filter(s=>s.changeType==="read");return C.jsxs("div",{className:"p-3 h-full flex flex-col",children:[C.jsxs("div",{className:"flex items-center justify-between mb-3 pb-2",style:{borderBottom:"2px solid var(--pixel-border)"},children:[C.jsx("span",{className:"pixel-text-sm",style:{color:"var(--pixel-gold)"},children:"\\📦 INVENTORY"}),C.jsxs("div",{className:"flex items-center gap-2",children:[C.jsxs("span",{className:"pixel-text-xs",style:{color:"var(--pixel-gold)"},children:[r.length,"\\u2728"]}),C.jsxs("span",{className:"pixel-text-xs",style:{color:"var(--pixel-purple)"},children:[n.length,"\\🔮"]}),C.jsxs("span",{className:"pixel-text-xs",style:{color:"var(--pixel-cyan)"},children:[a.length,"\\📜"]})]})]}),t.length===0?C.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-center",children:[C.jsx("div",{className:"pixel-text-xl mb-3",children:"\\📦"}),C.jsx("p",{className:"pixel-text-sm",style:{color:"var(--pixel-text-muted)"},children:"INVENTORY EMPTY"}),C.jsx("p",{className:"pixel-text-xs mt-2",style:{color:"var(--pixel-text-dim)"},children:"NO LOOT COLLECTED YET"})]}):C.jsx("div",{className:"flex-1 overflow-y-auto pixel-scrollbar space-y-1",children:t.map(s=>{const o=bpe[s.changeType]||bpe.read;return C.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 group",style:{border:"2px solid transparent",cursor:"default"},onMouseEnter:l=>{l.currentTarget.style.borderColor="var(--pixel-border)",l.currentTarget.style.background="var(--pixel-surface)"},onMouseLeave:l=>{l.currentTarget.style.borderColor="transparent",l.currentTarget.style.background="transparent"},children:[C.jsx("span",{className:"pixel-text-base shrink-0",children:o.icon}),C.jsxs("div",{className:"flex-1 min-w-0",children:[C.jsx("span",{className:"pixel-text-xs block",style:{color:"var(--pixel-text)"},title:s.filePath,children:Ah(s.filePath)}),C.jsxs("span",{className:"pixel-text-xs",style:{color:o.color},children:["[",o.rarity,"]"]})]}),C.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[s.touchCount>1&&C.jsxs("span",{className:"pixel-text-xs px-1",style:{color:"var(--pixel-gold)",border:"1px solid var(--pixel-border)",background:"var(--pixel-bg-dark)"},children:["x",s.touchCount]}),C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-dim)"},children:qc(s.lastTouchedAt)})]})]},`${s.filePath}-${s.agentId}`)})})]})}const kPt={backlog:{label:"RUMORS",icon:"💬",color:"var(--pixel-text-dim)"},planned:{label:"ACCEPTED",icon:"📜",color:"var(--pixel-blue)"},in_progress:{label:"ACTIVE",icon:"⚔",color:"var(--pixel-green)"},in_review:{label:"REPORTING",icon:"🔍",color:"var(--pixel-purple)"},completed:{label:"COMPLETE!",icon:"🏆",color:"var(--pixel-gold)"},blocked:{label:"SEALED",icon:"🔒",color:"var(--pixel-error)"}},wpe={critical:{label:"LEGENDARY",stars:"★★★★★",color:"var(--pixel-error)"},high:{label:"EPIC",stars:"★★★★",color:"var(--pixel-orange)"},medium:{label:"RARE",stars:"★★★",color:"var(--pixel-blue)"},low:{label:"COMMON",stars:"★★",color:"var(--pixel-text-dim)"}};function zPt(){const e=T0(),t=r=>r==="pending"?"planned":r==="deferred"?"backlog":r==="in_review"||r==="blocked"?"in_progress":r,i=K_.reduce((r,n)=>(r[n.id]=e.filter(a=>t(a.status)===n.id),r),{});return e.length===0?C.jsxs("div",{className:"h-full flex flex-col items-center justify-center p-8",children:[C.jsx("div",{className:"pixel-text-2xl mb-4",children:"\\📜"}),C.jsx("p",{className:"pixel-text-sm",style:{color:"var(--pixel-text-muted)"},children:"QUEST BOARD EMPTY"}),C.jsx("p",{className:"pixel-text-xs mt-2",style:{color:"var(--pixel-text-dim)"},children:"NO QUESTS AVAILABLE"}),C.jsx("p",{className:"pixel-text-xs mt-1 pixel-blink",style:{color:"var(--pixel-gold)"},children:"CHECK BACK LATER..."})]}):C.jsx("div",{className:"h-full flex gap-2 p-3 overflow-x-auto pixel-scrollbar",children:K_.map(r=>{const n=i[r.id]||[],a=kPt[r.id]||{label:r.label,icon:"■",color:"var(--pixel-text-muted)"};return C.jsxs("div",{className:"flex-shrink-0 w-56 flex flex-col pixel-card",children:[C.jsx("div",{className:"px-3 py-2 shrink-0",style:{borderBottom:"3px solid var(--pixel-border)"},children:C.jsxs("div",{className:"flex items-center justify-between",children:[C.jsxs("span",{className:"pixel-text-xs",style:{color:a.color},children:[a.icon," ",a.label]}),C.jsx("span",{className:"pixel-text-xs px-1.5 py-0.5",style:{color:"var(--pixel-text)",background:"var(--pixel-bg-dark)",border:"2px solid var(--pixel-border)"},children:n.length})]})}),C.jsx("div",{className:"flex-1 overflow-y-auto pixel-scrollbar p-2 space-y-2",children:n.map(s=>C.jsx(BPt,{task:s},s.id))})]},r.id)})})}function BPt({task:e}){const{selectTask:t,selectedTaskId:i}=_n(),r=oz(),n=wpe[e.priority]||wpe.low,a=e.assignedAgent?f0(e.assignedAgent):null,s=e.assignedAgent?r(e.assignedAgent):null,o=e.status==="completed",l=W7(e.prdSection);return C.jsxs("div",{className:`p-2 cursor-pointer ${o?"pixel-glow-gold":i===e.id?"pixel-glow-green":"pixel-border-light"}`,onClick:()=>t(e.id),style:{background:"var(--pixel-bg-dark)",opacity:o?.85:1},children:[C.jsxs("div",{className:"flex items-center justify-between mb-1",children:[C.jsxs("div",{className:"flex items-center gap-1",children:[C.jsxs("span",{className:"pixel-text-xs",style:{color:n.color},children:["[",n.label,"]"]}),l&&C.jsx("span",{className:"pixel-text-xs px-1",style:{color:"var(--pixel-gold)",background:"rgba(255, 215, 0, 0.1)",border:"1px solid var(--pixel-gold)"},children:l})]}),e.complexity&&C.jsxs("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-dim)"},children:["C",e.complexity]})]}),C.jsx("div",{className:"mb-1",children:C.jsx("span",{className:"pixel-text-xs",style:{color:n.color},children:n.stars})}),C.jsxs("h4",{className:"pixel-text-xs leading-relaxed mb-2",style:{color:o?"var(--pixel-text-dim)":"var(--pixel-text)",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:[o&&"✓ ",e.title]}),C.jsxs("div",{className:"flex items-center justify-between",children:[e.assignedAgent&&a?C.jsxs("div",{className:"flex items-center gap-1",children:[C.jsx("div",{className:"w-4 h-4 flex items-center justify-center pixel-text-xs",style:{background:`${a}30`,color:a,border:"1px solid var(--pixel-border)"},children:(s??"?").charAt(0).toUpperCase()}),C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-dim)"},children:s})]}):C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-dim)"},children:"UNASSIGNED"}),e.tags&&e.tags.length>0&&C.jsxs("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-dim)"},children:["#",e.tags[0]]})]}),e.blockedBy.length>0&&C.jsxs("div",{className:"mt-1 pixel-text-xs pixel-shake",style:{color:"var(--pixel-error)"},children:["\\🔒 SEALED BY ",e.blockedBy.length," QUEST",e.blockedBy.length>1?"S":""]})]})}function UPt(){const{activeSprint:e}=lz(),t=T0(),i=ee.useMemo(()=>{if(!e)return{total:0,completed:0,inProgress:0,blocked:0,pending:0,percent:0};const n=t.filter(h=>h.sprintId===e.id),a=n.length||e.totalTasks||0,s=n.filter(h=>h.status==="completed").length,o=n.filter(h=>h.status==="in_progress").length,l=n.filter(h=>h.status==="blocked").length,c=a-s-o-l,u=a>0?Math.round(s/a*100):0;return{total:a,completed:s,inProgress:o,blocked:l,pending:c,percent:u}},[e,t]);if(!e)return C.jsx("div",{className:"p-4 text-center",children:C.jsx("p",{className:"pixel-text-xs",style:{color:"var(--pixel-text-muted)"},children:"NO ACTIVE CHAPTER"})});const r=Math.floor(i.percent/10);return C.jsxs("div",{className:"p-4",style:{borderBottom:"3px solid var(--pixel-border)"},children:[C.jsxs("div",{className:"flex items-center justify-between mb-3",children:[C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-gold)"},children:"\\📖 CHAPTER PROGRESS"}),C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-muted)"},children:e.name})]}),C.jsxs("div",{className:"mb-3",children:[C.jsxs("div",{className:"flex items-center justify-between mb-1",children:[C.jsxs("span",{className:"pixel-text-xs",style:{color:"var(--pixel-xp)"},children:["XP LV.",r]}),C.jsxs("span",{className:"pixel-text-sm font-bold",style:{color:"var(--pixel-gold)"},children:[i.percent,"%"]})]}),C.jsx("div",{className:"pixel-bar-container pixel-bar-xp",style:{height:"16px"},children:C.jsx("div",{className:"pixel-bar-fill",style:{width:`${i.percent}%`,transition:"width 0.5s steps(8)"}})}),C.jsxs("div",{className:"flex items-center justify-between mt-1",children:[C.jsxs("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-dim)"},children:[i.completed,"/",i.total," QUESTS"]}),i.percent===100&&C.jsx("span",{className:"pixel-text-xs pixel-bounce",style:{color:"var(--pixel-gold)"},children:"CHAPTER COMPLETE!"})]})]}),C.jsx("div",{className:"space-y-1",children:[{label:"VICTORIES",value:i.completed,icon:"🏆",color:"var(--pixel-green)",barClass:"pixel-bar-green"},{label:"IN BATTLE",value:i.inProgress,icon:"⚔",color:"var(--pixel-cyan)",barClass:"pixel-bar-purple"},{label:"WAITING",value:i.pending,icon:"⌛",color:"var(--pixel-orange)",barClass:"pixel-bar-xp"},{label:"SEALED",value:i.blocked,icon:"🔒",color:"var(--pixel-error)",barClass:"pixel-bar-hp"}].map(n=>C.jsxs("div",{className:"flex items-center gap-2",children:[C.jsx("span",{className:"pixel-text-xs",style:{width:"14px"},children:n.icon}),C.jsx("span",{className:"pixel-text-xs flex-1",style:{color:n.color},children:n.label}),C.jsx("span",{className:"pixel-text-xs font-bold",style:{color:"var(--pixel-text)"},children:n.value})]},n.label))})]})}function jPt(){const e=T0(),{activeSprint:t}=_n(),i=t?e.filter(c=>c.sprintId===t.id):e,r=i.length,n=i.filter(c=>c.status==="completed").length,a=r-n,s=r>0?Math.round(n/r*100):0,o=20,l=8;return r===0?C.jsxs("div",{className:"pixel-panel p-3",children:[C.jsx("h3",{className:"pixel-title text-xs mb-2",children:"BURNDOWN"}),C.jsx("p",{className:"text-[10px] text-pixel-dim",children:"No quest data..."})]}):C.jsxs("div",{className:"pixel-panel p-3",children:[C.jsxs("h3",{className:"pixel-title text-xs mb-2",children:["BURNDOWN ",C.jsxs("span",{className:"text-pixel-dim",children:["LV.",s]})]}),C.jsxs("div",{className:"font-mono text-[9px] leading-tight text-pixel-green",children:[Array.from({length:l}).map((c,u)=>{const h=(l-u)/l*r,d=Math.round((l-u)/l*r),f=Array.from({length:o}).map((m,y)=>y/o*r<=n&&u>=l-Math.ceil(a/r*l)?"*":d>=h?".":" ").join("");return C.jsxs("div",{children:[String(Math.round(h)).padStart(3," "),"|",f,"|"]},u)}),C.jsx("div",{children:" +"+"-".repeat(o)+"+"})]}),C.jsxs("div",{className:"mt-2 flex gap-3 text-[9px]",children:[C.jsxs("span",{className:"text-pixel-green",children:["Done: ",n]}),C.jsxs("span",{className:"text-pixel-yellow",children:["Left: ",a]}),C.jsxs("span",{className:"text-pixel-dim",children:["Total: ",r]})]})]})}const _pe={backlog:{icon:"○",color:"var(--pixel-text-dim)"},planned:{icon:"○",color:"var(--pixel-blue)"},pending:{icon:"○",color:"var(--pixel-blue)"},in_progress:{icon:"⚔",color:"var(--pixel-green)"},in_review:{icon:"◆",color:"var(--pixel-purple)"},completed:{icon:"✓",color:"var(--pixel-gold)"},blocked:{icon:"✖",color:"var(--pixel-error)"},deferred:{icon:"○",color:"var(--pixel-text-dim)"}};function FPt(){const{activeProject:e,tasks:t,sprints:i,selectTask:r}=_n(),[n,a]=ee.useState(null),[s,o]=ee.useState(null),l=ee.useMemo(()=>{if(!e||t.length===0||i.length===0)return[];const c=new Map;for(const d of i)c.set(d.id,d);const u=new Map;for(const d of t){const f=d.sprintId||"unknown";u.has(f)||u.set(f,new Map);const m=u.get(f),y=d.prdSection||"Uncategorized";m.has(y)||m.set(y,{name:y,total:0,completed:0,inProgress:0,blocked:0,percent:0,tasks:[],order:d.prdLineStart??999});const g=m.get(y);g.total++,g.tasks.push(d),d.status==="completed"&&g.completed++,d.status==="in_progress"&&g.inProgress++,d.status==="blocked"&&g.blocked++}const h=[];for(const[d,f]of u){const m=c.get(d);if(!m)continue;const y=Array.from(f.values());for(const w of y)w.percent=w.total>0?Math.round(w.completed/w.total*100):0;y.sort((w,S)=>w.order-S.order);const g=y.reduce((w,S)=>w+S.total,0),x=y.reduce((w,S)=>w+S.completed,0);h.push({sprint:m,sections:y,total:g,completed:x,percent:g>0?Math.round(x/g*100):0})}return h.sort((d,f)=>(d.sprint.order??0)-(f.sprint.order??0)),h},[e,t,i]);return l.length===0?C.jsx("div",{className:"h-full flex items-center justify-center p-4",children:C.jsxs("div",{className:"text-center",children:[C.jsx("span",{className:"pixel-text-xl",children:"📖"}),C.jsx("p",{className:"pixel-text-xs mt-2",style:{color:"var(--pixel-text-muted)"},children:"QUEST JOURNAL"}),C.jsx("p",{className:"pixel-text-xs mt-1",style:{color:"var(--pixel-text-dim)"},children:"NO ENTRIES YET"})]})}):C.jsxs("div",{className:"p-3",children:[C.jsxs("div",{className:"flex items-center justify-between mb-2",children:[C.jsxs("span",{className:"pixel-text-xs",style:{color:"var(--pixel-gold)"},children:["📖"," QUEST JOURNAL"]}),C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-muted)"},children:e==null?void 0:e.name})]}),C.jsx("div",{className:"space-y-1",children:l.map(c=>{const u=n===c.sprint.id,h=c.percent===100;return C.jsxs("div",{children:[C.jsxs("div",{className:`p-2 cursor-pointer ${h?"pixel-border-gold":"pixel-card"}`,style:{background:"var(--pixel-bg-dark)"},onClick:()=>a(u?null:c.sprint.id),children:[C.jsxs("div",{className:"flex items-center justify-between mb-1",children:[C.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-dim)"},children:u?"▼":"▶"}),C.jsx("h4",{className:"pixel-text-xs truncate",style:{color:"var(--pixel-gold)",fontWeight:"bold"},children:c.sprint.name})]}),C.jsxs("span",{className:"pixel-text-xs font-bold ml-2 shrink-0",style:{color:h?"var(--pixel-gold)":"var(--pixel-text)"},children:[c.percent,"%"]})]}),C.jsx("div",{className:"pixel-bar-container pixel-bar-xp",style:{height:"8px"},children:C.jsx("div",{className:"pixel-bar-fill",style:{width:`${c.percent}%`,background:h?"var(--pixel-gold)":"var(--pixel-xp)"}})}),C.jsx("div",{className:"flex items-center gap-2 pixel-text-xs mt-1",style:{color:"var(--pixel-text-dim)"},children:C.jsxs("span",{children:[c.completed,"/",c.total]})})]}),u&&C.jsx("div",{className:"ml-2 space-y-0.5",style:{borderLeft:"2px solid var(--pixel-border)"},children:c.sections.map(d=>{const f=`${c.sprint.id}:${d.name}`,m=s===f,y=d.percent===100,g=d.blocked>0,x=d.inProgress>0;let w="var(--pixel-text-dim)";return y?w="var(--pixel-gold)":g?w="var(--pixel-error)":x&&(w="var(--pixel-green)"),C.jsxs("div",{children:[C.jsxs("div",{className:"p-2 cursor-pointer",style:{background:"var(--pixel-bg-dark)"},onClick:()=>o(m?null:f),children:[C.jsxs("div",{className:"flex items-center justify-between mb-1",children:[C.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-dim)"},children:m?"▼":"▶"}),C.jsx("h4",{className:"pixel-text-xs truncate",style:{color:"var(--pixel-text)"},children:d.name})]}),C.jsxs("span",{className:"pixel-text-xs font-bold ml-2 shrink-0",style:{color:w},children:[d.percent,"%"]})]}),C.jsx("div",{className:"pixel-bar-container pixel-bar-xp",style:{height:"6px"},children:C.jsx("div",{className:"pixel-bar-fill",style:{width:`${d.percent}%`,background:y?"var(--pixel-gold)":g?"var(--pixel-error)":"var(--pixel-xp)"}})}),C.jsxs("div",{className:"flex items-center gap-2 pixel-text-xs mt-1",style:{color:"var(--pixel-text-dim)"},children:[C.jsxs("span",{children:[d.completed,"/",d.total]}),d.inProgress>0&&C.jsxs("span",{style:{color:"var(--pixel-green)"},children:[d.inProgress,"⚔"]}),d.blocked>0&&C.jsxs("span",{style:{color:"var(--pixel-error)"},children:[d.blocked,"🔒"]})]})]}),m&&C.jsx("div",{className:"ml-2",style:{borderLeft:"2px solid var(--pixel-border)",background:"var(--pixel-bg-dark)"},children:d.tasks.map(S=>{const M=_pe[S.status]||_pe.backlog;return C.jsxs("div",{onClick:()=>r(S.id),className:"cursor-pointer px-3 py-1 flex items-center gap-2 pixel-text-xs",style:{borderBottom:"1px solid var(--pixel-border)"},children:[C.jsx("span",{style:{color:M.color},children:M.icon}),C.jsx("span",{className:"truncate flex-1",style:{color:"var(--pixel-text)"},children:S.title}),S.assignedAgent&&C.jsxs("span",{style:{color:"var(--pixel-text-dim)"},children:["@",S.assignedAgent]})]},S.id)})})]},f)})})]},c.sprint.id)})})]})}const qw=140,Xw=44,VPt=36,HPt=20,Spe=28,Ape=20,GPt={backlog:"#6b7280",planned:"#457b9d",pending:"#f4a261",in_progress:"#2dce89",in_review:"#7c5cff",completed:"#ffd700",blocked:"#e63946",deferred:"#6b7280"},WPt={backlog:"LOCKED",planned:"AVAILABLE",pending:"QUEUED",in_progress:"LEARNING",in_review:"TESTING",completed:"MASTERED",blocked:"SEALED",deferred:"HIDDEN"};function Mpe(e){return GPt[e]??"#6b7280"}function Epe(e){return WPt[e]??e.replace(/_/g," ").toUpperCase()}function qPt(e,t){const i=new Map;function r(a,s){if(i.has(a))return i.get(a);if(s.has(a))return 0;s.add(a);const c=(t.get(a)??[]).reduce((u,h)=>!t.has(h)&&!e.some(d=>d.id===h)?u:Math.max(u,r(h,s)),-1)+1;return i.set(a,c),c}const n=new Set;for(const a of e)r(a.id,n);return i}function XPt(){const{tasks:e}=_n(),t=ee.useRef(null),[i,r]=ee.useState(null),{nodes:n,edges:a,svgWidth:s,svgHeight:o,isEmpty:l}=ee.useMemo(()=>{const d=new Map;for(const R of e){const P=new Set([...R.dependsOn,...R.blockedBy]);d.set(R.id,Array.from(P))}const f=new Set;for(const R of e){const P=d.get(R.id)??[];if(P.length>0){f.add(R.id);for(const I of P)f.add(I)}}const m=e.filter(R=>f.has(R.id));if(m.length===0)return{nodes:[],edges:[],svgWidth:0,svgHeight:0,isEmpty:!0};const y=qPt(m,d),g=new Map;for(const R of m){const P=y.get(R.id)??0;g.has(P)||g.set(P,[]),g.get(P).push(R)}const x=Array.from(g.keys()).sort((R,P)=>R-P),w=[];for(const R of x){const P=g.get(R),I={blocked:0,in_progress:1,in_review:2,pending:3,planned:4,backlog:5,completed:6,deferred:7};P.sort((L,z)=>(I[L.status]??9)-(I[z.status]??9)||L.title.localeCompare(z.title)),P.forEach((L,z)=>{const U=Ape+R*(qw+VPt),j=Spe+z*(Xw+HPt);w.push({id:L.id,title:L.title,status:L.status,col:R,row:z,x:U,y:j})})}const S=[],M=new Set(w.map(R=>R.id));for(const R of m){const P=d.get(R.id)??[];for(const I of P)M.has(I)&&S.push({fromId:I,toId:R.id})}const E=Math.max(...w.map(R=>R.x))+qw+Ape,T=Math.max(...w.map(R=>R.y))+Xw+Spe;return{nodes:w,edges:S,svgWidth:E,svgHeight:T,isEmpty:!1}},[e]);ee.useEffect(()=>{var d;(d=t.current)==null||d.scrollTo({left:0,top:0})},[n]);const c=ee.useMemo(()=>{const d=new Map;for(const f of n)d.set(f.id,f);return d},[n]),u=ee.useCallback(d=>i!==null&&(d.fromId===i||d.toId===i),[i]);if(l)return C.jsxs("div",{className:"p-4",style:{borderBottom:"3px solid var(--pixel-border)"},children:[C.jsx("div",{className:"flex items-center justify-between mb-2",children:C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-gold)"},children:"\\🌲 SKILL TREE"})}),C.jsx("div",{className:"h-24 flex items-center justify-center",children:C.jsx("p",{className:"pixel-text-xs",style:{color:"var(--pixel-text-muted)"},children:"NO SKILL DEPENDENCIES"})})]});const h=Array.from(new Set(n.map(d=>d.status)));return C.jsxs("div",{className:"p-4",style:{borderBottom:"3px solid var(--pixel-border)"},children:[C.jsxs("div",{className:"flex items-center justify-between mb-2",children:[C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-gold)"},children:"\\🌲 SKILL TREE"}),C.jsxs("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-dim)"},children:[n.length," SKILLS \\u00B7 ",a.length," LINKS"]})]}),C.jsx("div",{className:"flex flex-wrap gap-x-3 gap-y-1 mb-2",children:h.map(d=>C.jsxs("div",{className:"flex items-center gap-1",children:[C.jsx("span",{className:"inline-block w-3 h-3",style:{backgroundColor:Mpe(d),border:"1px solid #000"}}),C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-dim)"},children:Epe(d)})]},d))}),C.jsx("div",{ref:t,className:"overflow-auto pixel-scrollbar pixel-card",style:{maxHeight:360,background:"var(--pixel-bg-dark)"},children:C.jsxs("svg",{width:s,height:o,viewBox:`0 0 ${s} ${o}`,className:"select-none",children:[C.jsxs("defs",{children:[C.jsx("marker",{id:"pixel-arrow",viewBox:"0 0 10 10",refX:"10",refY:"5",markerWidth:"8",markerHeight:"8",orient:"auto-start-reverse",children:C.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"#444477"})}),C.jsx("marker",{id:"pixel-arrow-hl",viewBox:"0 0 10 10",refX:"10",refY:"5",markerWidth:"8",markerHeight:"8",orient:"auto-start-reverse",children:C.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"#ffd700"})})]}),a.map(d=>{const f=c.get(d.fromId),m=c.get(d.toId);if(!f||!m)return null;const y=u(d),g=f.x+qw,x=f.y+Xw/2,w=m.x,S=m.y+Xw/2,M=(g+w)/2,E=`M ${g} ${x} L ${M} ${x} L ${M} ${S} L ${w} ${S}`;return C.jsx("path",{d:E,fill:"none",stroke:y?"#ffd700":"#444477",strokeWidth:y?3:2,markerEnd:y?"url(#pixel-arrow-hl)":"url(#pixel-arrow)",opacity:i===null||y?1:.25},`${d.fromId}-${d.toId}`)}),n.map(d=>{const f=Mpe(d.status),m=i===d.id,y=i!==null&&!m&&!a.some(x=>x.fromId===i&&x.toId===d.id||x.toId===i&&x.fromId===d.id),g=d.status==="completed";return C.jsxs("g",{onMouseEnter:()=>r(d.id),onMouseLeave:()=>r(null),style:{cursor:"default"},opacity:y?.3:1,children:[C.jsx("rect",{x:d.x,y:d.y,width:qw,height:Xw,fill:"#1a1a2e",stroke:m?"#ffd700":f,strokeWidth:3}),C.jsx("rect",{x:d.x+3,y:d.y+3,width:qw-6,height:2,fill:"rgba(255,255,255,0.08)"}),C.jsx("rect",{x:d.x+6,y:d.y+Xw/2-4,width:8,height:8,fill:f}),g&&C.jsx("text",{x:d.x+qw-16,y:d.y+14,fontSize:10,fill:"#ffd700",children:"⭐"}),C.jsx("text",{x:d.x+20,y:d.y+17,fill:"#e8e8ff",fontSize:7,fontFamily:"'Press Start 2P', monospace",children:d.title.length>14?d.title.slice(0,13)+"…":d.title}),C.jsx("text",{x:d.x+20,y:d.y+32,fill:"#6666aa",fontSize:6,fontFamily:"'Press Start 2P', monospace",children:Epe(d.status)})]},d.id)})]})})]})}function YPt(){const{viewMode:e,setViewMode:t,activeProject:i}=_n();return C.jsxs("div",{className:"flex items-center gap-2",children:[C.jsxs("div",{className:"flex items-center gap-1",children:[C.jsx("button",{onClick:()=>t("agents"),className:"pixel-text-xs px-2 py-1 transition-colors",style:{color:e==="agents"?"var(--pixel-gold)":"var(--pixel-text-muted)",border:e==="agents"?"2px solid var(--pixel-gold)":"2px solid var(--pixel-border)"},children:"[A] AGENTS"}),C.jsx("button",{onClick:()=>t("tracker"),className:"pixel-text-xs px-2 py-1 transition-colors",style:{color:e==="tracker"?"var(--pixel-gold)":"var(--pixel-text-muted)",border:e==="tracker"?"2px solid var(--pixel-gold)":"2px solid var(--pixel-border)"},children:"[T] TRACKER"})]}),i&&C.jsxs("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-muted)"},children:[i.completedTasks,"/",i.totalTasks]})]})}function $Pt(){const{connectionStatus:e}=Ni(),t={connected:{color:"var(--pixel-green)",glow:"0 0 6px var(--pixel-green)",pulse:!0,label:"ONLINE"},reconnecting:{color:"var(--pixel-gold)",glow:"0 0 6px var(--pixel-gold)",pulse:!0,label:"RECONECTANDO..."},disconnected:{color:"var(--pixel-error)",glow:"0 0 6px var(--pixel-error)",pulse:!1,label:"OFFLINE"}}[e];return C.jsxs("div",{className:"flex items-center gap-2 ml-2",children:[C.jsx("div",{className:`w-3 h-3 ${t.pulse?"pixel-pulse":""}`,style:{background:t.color,boxShadow:t.glow}}),C.jsx("span",{className:"pixel-text-xs",style:{color:t.color},children:t.label})]})}function KPt(){const{viewMode:e}=_n();return C.jsxs("div",{className:"pixel-theme h-full w-full flex flex-col overflow-hidden",style:{background:"var(--pixel-bg)"},children:[C.jsxs("header",{className:"h-14 flex items-center justify-between px-4 pixel-hud shrink-0 relative z-50",children:[C.jsxs("div",{className:"flex items-center gap-4",children:[C.jsx("h1",{className:"pixel-text-lg",style:{color:"var(--pixel-gold)"},children:"CAM"}),C.jsx("span",{className:"pixel-text-xs",style:{color:"var(--pixel-text-muted)"},children:"CLAUDE AGENT MONITOR"}),C.jsx($Pt,{})]}),C.jsxs("div",{className:"flex items-center gap-3",children:[C.jsx(RX,{}),C.jsx(YPt,{})]})]}),C.jsx(xPt,{}),C.jsx(IK,{}),C.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[e==="agents"&&C.jsx(QPt,{}),e==="tracker"&&C.jsx(ZPt,{})]})]})}function QPt(){return C.jsxs(C.Fragment,{children:[C.jsx("aside",{className:"w-48 overflow-y-auto pixel-scrollbar shrink-0",style:{borderRight:"3px solid var(--pixel-border)"},children:C.jsx(APt,{})}),C.jsx("main",{className:"flex-1 overflow-hidden",children:C.jsx(MK,{})}),C.jsx("aside",{className:"w-72 pixel-scrollbar shrink-0",style:{borderLeft:"3px solid var(--pixel-border)"},children:C.jsx(RK,{AgentDetail:NPt,ActivityFeed:OPt,FileWatcher:LPt,tabBarClass:"flex border-b-[3px] border-[var(--pixel-border)] bg-[var(--pixel-surface)]",activeTabClass:"text-[var(--pixel-gold)]",inactiveTabClass:"text-[var(--pixel-text-muted)] hover:text-[var(--pixel-text)]",panelClass:"flex-1 overflow-y-auto pixel-scrollbar"})})]})}function ZPt(){const{selectedTaskId:e}=_n();return C.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[C.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[C.jsx("main",{className:"flex-1 overflow-hidden",children:C.jsx(zPt,{})}),e&&C.jsx("aside",{className:"w-80 overflow-y-auto pixel-scrollbar shrink-0",style:{borderLeft:"3px solid var(--pixel-border)"},children:C.jsx(EK,{})}),C.jsxs("aside",{className:"w-80 overflow-y-auto pixel-scrollbar shrink-0 flex flex-col",style:{borderLeft:"3px solid var(--pixel-border)"},children:[C.jsx(UPt,{}),C.jsx(jPt,{}),C.jsx(XPt,{})]})]}),C.jsx("div",{className:"h-48 overflow-y-auto pixel-scrollbar shrink-0",style:{borderTop:"3px solid var(--pixel-border)"},children:C.jsx(FPt,{})})]})}function JPt({agentCount:e,hasNewEvents:t}){return e===0?null:C.jsx(p0,{children:C.jsxs(rc.div,{className:"flex items-center gap-1",initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:{duration:.2},children:[C.jsxs("span",{className:"relative flex h-2 w-2",children:[C.jsx("span",{className:`absolute inline-flex h-full w-full rounded-full bg-cam-success opacity-75 ${t?"animate-ping":"animate-pulse"}`}),C.jsx("span",{className:"relative inline-flex h-2 w-2 rounded-full bg-cam-success"})]}),C.jsx(rc.span,{className:"flex items-center justify-center min-w-[16px] h-4 px-1 rounded-full bg-cam-accent/20 text-cam-accent text-[10px] font-bold leading-none",initial:{scale:1.3},animate:{scale:1},transition:{type:"spring",stiffness:400,damping:15},children:e},e)]})})}function eDt({open:e,title:t,message:i,confirmLabel:r="Delete",cancelLabel:n="Cancel",onConfirm:a,onCancel:s}){return ee.useEffect(()=>{if(!e)return;const o=l=>{l.key==="Escape"&&s()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[e,s]),C.jsx(p0,{children:e&&C.jsxs(rc.div,{className:"fixed inset-0 z-50 flex items-center justify-center",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},children:[C.jsx("div",{className:"absolute inset-0 bg-black/50",onClick:s}),C.jsxs(rc.div,{className:"relative bg-cam-surface border border-cam-border rounded-lg shadow-xl p-6 max-w-sm w-full mx-4",initial:{scale:.95,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.95,opacity:0},transition:{duration:.15},children:[C.jsx("h3",{className:"text-sm font-semibold text-cam-text mb-2",children:t}),C.jsx("p",{className:"text-xs text-cam-text-muted mb-6",children:i}),C.jsxs("div",{className:"flex justify-end gap-2",children:[C.jsx("button",{onClick:s,className:"px-3 py-1.5 text-xs rounded-md text-cam-text-muted hover:text-cam-text hover:bg-cam-surface-2 transition-colors",children:n}),C.jsx("button",{onClick:a,className:"px-3 py-1.5 text-xs rounded-md bg-red-600 text-white hover:bg-red-700 transition-colors",children:r})]})]})]})})}function tDt(e){let t=0;for(let r=0;r<e.length;r++)t=e.charCodeAt(r)+((t<<5)-t);return`hsl(${Math.abs(t%360)}, 65%, 55%)`}function iDt(e){return e.totalTasks===0?0:Math.round(e.completedTasks/e.totalTasks*100)}function rDt(e){switch(e){case"pixel":return{background:"var(--pixel-bg-dark, #0f0f1e)",borderRight:"3px solid var(--pixel-border, #444477)",fontFamily:"'Press Start 2P', monospace",imageRendering:"pixelated"};case"terminal":return{background:"#0a0a0a",borderRight:"1px solid #1a3a1a",fontFamily:"'JetBrains Mono', 'Fira Code', monospace"};default:return{}}}function nDt(e){switch(e){case"pixel":case"terminal":return"flex flex-col h-full shrink-0 select-none";case"modern":default:return"flex flex-col h-full bg-cam-surface border-r border-cam-border/50 shrink-0 select-none"}}function aDt(e){switch(e){case"pixel":return{borderBottom:"3px solid var(--pixel-border, #444477)",background:"var(--pixel-surface, #222244)"};case"terminal":return{borderBottom:"1px solid #1a3a1a"};default:return{}}}function sDt(e){switch(e){case"pixel":case"terminal":return"flex items-center justify-between h-12 px-3 shrink-0";case"modern":default:return"flex items-center justify-between h-12 px-3 border-b border-cam-border/50 shrink-0"}}function oDt(e){switch(e){case"pixel":return{fontSize:"7px",lineHeight:"12px",color:"var(--pixel-gold, #ffd700)"};case"terminal":return{fontSize:"11px",color:"#00ff00",textShadow:"0 0 4px rgba(0,255,0,0.4)"};default:return{}}}function lDt(e){switch(e){case"pixel":case"terminal":return"whitespace-nowrap overflow-hidden";case"modern":default:return"text-xs font-semibold text-cam-text tracking-tight whitespace-nowrap overflow-hidden"}}function cDt(e){switch(e){case"pixel":return"PROJECTS";case"terminal":return"[PROJECTS]";default:return"Projects"}}function uDt(e){switch(e){case"pixel":return"p-1.5 pixel-btn";case"terminal":return"p-1.5";case"modern":default:return"p-1.5 rounded-md text-cam-text-muted hover:text-cam-text hover:bg-cam-surface-2 transition-colors"}}function hDt(e){switch(e){case"pixel":return{color:"var(--pixel-text, #e8e8ff)"};case"terminal":return{color:"#00aa00"};default:return{}}}function dDt(e){switch(e){case"pixel":return"flex-1 overflow-y-auto overflow-x-hidden py-1 space-y-0.5 px-1 pixel-scrollbar";case"terminal":return"flex-1 overflow-y-auto overflow-x-hidden py-1 space-y-0 px-1 terminal-scrollbar";case"modern":default:return"flex-1 overflow-y-auto overflow-x-hidden py-2 space-y-0.5 px-2"}}function fDt(e){switch(e){case"pixel":case"terminal":return"shrink-0 p-2";case"modern":default:return"shrink-0 border-t border-cam-border/50 p-2"}}function pDt(e){switch(e){case"pixel":return{borderTop:"3px solid var(--pixel-border, #444477)"};case"terminal":return{borderTop:"1px solid #1a3a1a"};default:return{}}}function mDt(e,t){const i=t?"justify-center p-2":"px-3 py-2";switch(e){case"pixel":return`flex items-center gap-2 w-full pixel-btn ${i}`;case"terminal":return`flex items-center gap-2 w-full ${i}`;case"modern":default:return`flex items-center gap-2 w-full rounded-md text-cam-text-muted hover:text-cam-text hover:bg-cam-surface-2 transition-colors ${i}`}}function gDt(e){switch(e){case"pixel":return{color:"var(--pixel-text-muted, #8888bb)"};case"terminal":return{color:"#00aa00",fontSize:"11px"};default:return{}}}function vDt(e){switch(e){case"terminal":return"> config";default:return"Settings"}}function yDt(e){switch(e){case"pixel":return"whitespace-nowrap overflow-hidden";case"terminal":return"whitespace-nowrap overflow-hidden";case"modern":default:return"text-xs whitespace-nowrap overflow-hidden"}}function xDt(e){switch(e){case"pixel":return{fontSize:"6px",lineHeight:"10px"};case"terminal":return{fontSize:"11px"};default:return{}}}function bDt(e){switch(e){case"pixel":return"text-center px-2 py-4";case"terminal":return"text-center px-2 py-4";case"modern":default:return"text-[10px] text-cam-text-muted text-center px-2 py-4"}}function wDt(e){switch(e){case"pixel":return{fontSize:"6px",lineHeight:"12px",color:"var(--pixel-text-muted, #8888bb)"};case"terminal":return{fontSize:"10px",color:"#00aa00"};default:return{}}}function _Dt({collapsed:e,onToggleCollapse:t,onOpenSettings:i}){const{projects:r,activeProject:n,setActiveProject:a,removeProject:s}=_n(),o=Ni(S=>S.agents),l=Ni(S=>S.events),c=Di(S=>S.theme),[u,h]=ee.useState(null),d=ee.useCallback(async()=>{if(u){try{await YEe(u.id),s(u.id)}catch{}h(null)}},[u,s]),f=ee.useMemo(()=>[...r].sort((S,M)=>S.status==="active"&&M.status!=="active"?-1:S.status!=="active"&&M.status==="active"?1:new Date(M.updatedAt).getTime()-new Date(S.updatedAt).getTime()),[r]),m=Ni(S=>S.projectId);function y(S){a(S)}const g=ee.useMemo(()=>{if(l.length===0)return!1;const S=l[0];return S!=null&&S.timestamp?Date.now()-new Date(S.timestamp).getTime()<5e3:!1},[l]),x=c==="terminal"?C.jsx("span",{style:{fontSize:"11px",color:"#00aa00"},children:e?">":"<"}):c==="pixel"?C.jsx("span",{style:{fontSize:"8px",fontFamily:"'Press Start 2P', monospace"},children:e?"▶":"◀"}):C.jsx("svg",{className:`w-4 h-4 transition-transform duration-200 ${e?"rotate-180":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:C.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 19l-7-7 7-7"})}),w=c==="terminal"?C.jsx("span",{style:{fontSize:"11px",color:"#00aa00"},children:"[*]"}):c==="pixel"?C.jsx("span",{style:{fontSize:"8px",fontFamily:"'Press Start 2P', monospace",color:"var(--pixel-text-muted)"},children:"⚙"}):C.jsxs("svg",{className:"w-4 h-4 shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:[C.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.594 3.94c.09-.542.56-.94 1.11-.94h2.593c.55 0 1.02.398 1.11.94l.213 1.281c.063.374.313.686.645.87.074.04.147.083.22.127.325.196.72.257 1.075.124l1.217-.456a1.125 1.125 0 011.37.49l1.296 2.247a1.125 1.125 0 01-.26 1.431l-1.003.827c-.293.241-.438.613-.43.992a7.723 7.723 0 010 .255c-.008.378.137.75.43.991l1.004.827c.424.35.534.955.26 1.43l-1.298 2.247a1.125 1.125 0 01-1.369.491l-1.217-.456c-.355-.133-.75-.072-1.076.124a6.47 6.47 0 01-.22.128c-.331.183-.581.495-.644.869l-.213 1.281c-.09.543-.56.941-1.11.941h-2.594c-.55 0-1.019-.398-1.11-.94l-.213-1.281c-.062-.374-.312-.686-.644-.87a6.52 6.52 0 01-.22-.127c-.325-.196-.72-.257-1.076-.124l-1.217.456a1.125 1.125 0 01-1.369-.49l-1.297-2.247a1.125 1.125 0 01.26-1.431l1.004-.827c.292-.24.437-.613.43-.991a6.932 6.932 0 010-.255c.007-.38-.138-.751-.43-.992l-1.004-.827a1.125 1.125 0 01-.26-1.43l1.297-2.247a1.125 1.125 0 011.37-.491l1.216.456c.356.133.751.072 1.076-.124.072-.044.146-.086.22-.128.332-.183.582-.495.644-.869l.214-1.28z"}),C.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]});return C.jsxs(rc.aside,{className:nDt(c),style:rDt(c),animate:{width:e?56:224},transition:{duration:.2,ease:"easeInOut"},children:[C.jsxs("div",{className:sDt(c),style:aDt(c),children:[C.jsx(p0,{mode:"wait",children:!e&&C.jsx(rc.span,{className:lDt(c),style:oDt(c),initial:{opacity:0,width:0},animate:{opacity:1,width:"auto"},exit:{opacity:0,width:0},transition:{duration:.15},children:cDt(c)},"logo-text")}),C.jsx("button",{onClick:t,className:uDt(c),style:hDt(c),title:e?"Expand sidebar":"Collapse sidebar",children:x})]}),C.jsxs("nav",{className:dDt(c),children:[f.length===0&&!e&&C.jsx("p",{className:bDt(c),style:wDt(c),children:c==="terminal"?"> no projects. run: cam init":C.jsxs(C.Fragment,{children:["No registered projects. Use ",C.jsx("code",{className:"text-cam-accent",children:"cam init"})," to get started."]})}),f.map(S=>{const M=(n==null?void 0:n.id)===S.id,E=m===S.id,T=E?o.length:0,R=tDt(S.name),P=iDt(S);return C.jsx(SDt,{project:S,isActive:M,collapsed:e,color:R,completionPct:P,agentCount:T,hasNewEvents:E&&g,onSelect:y,onDelete:h,theme:c},S.id)})]}),C.jsx("div",{className:fDt(c),style:pDt(c),children:C.jsxs("button",{onClick:i,className:mDt(c,e),style:gDt(c),title:"Settings",children:[w,C.jsx(p0,{mode:"wait",children:!e&&C.jsx(rc.span,{className:yDt(c),style:xDt(c),initial:{opacity:0,width:0},animate:{opacity:1,width:"auto"},exit:{opacity:0,width:0},transition:{duration:.15},children:vDt(c)},"settings-label")})]})}),C.jsx(eDt,{open:u!==null,title:"Delete project",message:`Are you sure you want to delete "${(u==null?void 0:u.name)??""}"? All sprints and tasks will be permanently removed. This action cannot be undone.`,onConfirm:d,onCancel:()=>h(null)})]})}function SDt({project:e,isActive:t,collapsed:i,color:r,completionPct:n,agentCount:a,hasNewEvents:s,onSelect:o,onDelete:l,theme:c}){const u=e.name.charAt(0).toUpperCase(),h=e.status==="active";if(i){const d=c==="pixel"?`relative flex items-center justify-center w-full p-2 ${t?"pixel-border-accent":"pixel-btn"}`:c==="terminal"?`relative flex items-center justify-center w-full p-2 ${t?"bg-[#0a1f0a] border border-[#00ff00]":"hover:bg-[#0a1f0a] border border-transparent"}`:`relative flex items-center justify-center w-full rounded-md p-2 transition-colors ${t?"bg-cam-accent/10 ring-1 ring-cam-accent/40":"hover:bg-cam-surface-2"}`,f=c==="pixel"?{backgroundColor:r,imageRendering:"pixelated",borderRadius:0,border:"2px solid var(--pixel-border)"}:c==="terminal"?{backgroundColor:"transparent",color:"#00ff00",border:"1px solid #00aa00",borderRadius:0,fontFamily:"monospace",fontSize:"12px"}:{backgroundColor:r};return C.jsxs(rc.button,{onClick:()=>o(e),className:d,title:`${e.name} (${n}%)`,whileHover:{scale:c==="pixel"?1:1.05},whileTap:{scale:c==="pixel"?1:.95},children:[C.jsx("div",{className:`w-8 h-8 flex items-center justify-center text-xs font-bold text-white shrink-0 ${c==="modern"?"rounded-full":""}`,style:f,children:u}),a>0&&C.jsx("span",{className:"absolute top-1 right-1",children:C.jsx("span",{className:"relative flex h-2 w-2",children:c==="terminal"?C.jsx("span",{className:"relative inline-flex h-2 w-2",style:{background:"#00ff00",borderRadius:0}}):C.jsxs(C.Fragment,{children:[C.jsx("span",{className:"absolute inline-flex h-full w-full rounded-full bg-cam-success opacity-75 animate-ping"}),C.jsx("span",{className:"relative inline-flex h-2 w-2 rounded-full bg-cam-success"})]})})})]})}return c==="terminal"?C.jsxs("button",{onClick:()=>o(e),className:`relative w-full text-left px-2 py-1.5 transition-colors ${t?"bg-[#0a1f0a]":"hover:bg-[#0a1f0a]"}`,style:{fontFamily:"'JetBrains Mono', monospace",fontSize:"11px",borderLeft:t?"2px solid #00ff00":"2px solid transparent"},children:[C.jsxs("div",{className:"flex items-center gap-1.5",children:[C.jsx("span",{style:{color:t?"#00ff00":"#00aa00"},children:t?">":" "}),C.jsx("span",{style:{color:"#00aa00"},children:"[DIR]"}),C.jsx("span",{className:"truncate",style:{color:t?"#00ff00":"#00aa00",textShadow:t?"0 0 4px rgba(0,255,0,0.4)":"none"},children:e.name}),a>0&&C.jsxs("span",{style:{color:"#00ff00",fontSize:"10px"},children:["[",a,"]"]})]}),C.jsxs("div",{className:"flex items-center gap-1 mt-0.5 ml-4",children:[C.jsxs("span",{style:{color:"#006600",fontSize:"10px"},children:[e.completedTasks,"/",e.totalTasks]}),C.jsxs("span",{style:{color:"#006600",fontSize:"10px"},children:["[","█".repeat(Math.round(n/10)),"░".repeat(10-Math.round(n/10)),"] ",n,"%"]})]}),C.jsx("span",{onClick:d=>{d.stopPropagation(),l(e)},className:"absolute right-1 top-1/2 -translate-y-1/2 opacity-0 hover:opacity-100 transition-opacity",style:{color:"#aa0000",fontSize:"10px",cursor:"pointer"},title:"Delete project",children:"[DEL]"})]}):c==="pixel"?C.jsxs("button",{onClick:()=>o(e),className:`relative w-full text-left p-2 ${t?"pixel-border-accent":"pixel-btn"}`,style:{fontFamily:"'Press Start 2P', monospace"},children:[C.jsxs("div",{className:"flex items-start gap-2",children:[C.jsx("div",{className:"w-6 h-6 flex items-center justify-center shrink-0 mt-0.5",style:{backgroundColor:r,border:"2px solid var(--pixel-border)",imageRendering:"pixelated",fontSize:"7px",color:"#fff",fontWeight:"bold"},children:u}),C.jsxs("div",{className:"flex-1 min-w-0",children:[C.jsxs("div",{className:"flex items-center gap-1",children:[C.jsx("span",{style:{width:"4px",height:"4px",display:"inline-block",background:h?"var(--pixel-green)":"var(--pixel-text-muted)"}}),C.jsx("span",{className:"truncate",style:{fontSize:"6px",lineHeight:"10px",color:t?"var(--pixel-gold)":"var(--pixel-text)"},children:e.name.toUpperCase()})]}),C.jsxs("div",{className:"flex items-center justify-between mt-1",children:[C.jsxs("span",{style:{fontSize:"6px",color:"var(--pixel-text-muted)"},children:[e.completedTasks,"/",e.totalTasks]}),C.jsxs("span",{style:{fontSize:"6px",color:"var(--pixel-text-muted)"},children:[n,"%"]})]}),C.jsx("div",{className:"w-full mt-1 pixel-bar-container",style:{height:"6px"},children:C.jsx("div",{className:"pixel-bar-fill",style:{width:`${n}%`,background:t?"var(--pixel-gold)":"var(--pixel-green)",transition:"width 0.3s steps(8)"}})})]}),a>0&&C.jsx("div",{className:"shrink-0 mt-0.5",children:C.jsx("span",{className:"pixel-pulse",style:{display:"inline-block",width:"6px",height:"6px",background:"var(--pixel-green)",boxShadow:"0 0 4px var(--pixel-green)"}})})]}),C.jsx("span",{onClick:d=>{d.stopPropagation(),l(e)},className:"absolute right-1 top-1 opacity-0 hover:opacity-100 transition-opacity",style:{fontSize:"6px",color:"#ff4444",cursor:"pointer",fontFamily:"'Press Start 2P', monospace"},title:"Delete project",children:"X"})]}):C.jsxs(rc.div,{role:"button",tabIndex:0,onClick:()=>o(e),onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),o(e))},className:`relative w-full text-left rounded-lg p-2.5 transition-all duration-150 group cursor-pointer ${t?"bg-cam-accent/10 border-l-2 border-cam-accent":"border-l-2 border-transparent hover:bg-cam-surface-2"}`,whileTap:{scale:.98},children:[C.jsxs("div",{className:"flex items-start gap-2.5",children:[C.jsx("div",{className:"w-7 h-7 rounded-full flex items-center justify-center text-[10px] font-bold text-white shrink-0 mt-0.5",style:{backgroundColor:r},children:u}),C.jsxs("div",{className:"flex-1 min-w-0",children:[C.jsxs("div",{className:"flex items-center gap-1.5",children:[C.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${h?"bg-cam-success":"bg-cam-text-muted"}`}),C.jsx("span",{className:"text-xs font-medium text-cam-text truncate",children:e.name})]}),C.jsxs("div",{className:"flex items-center justify-between mt-1.5",children:[C.jsxs("span",{className:"text-[10px] text-cam-text-muted font-mono",children:[e.completedTasks,"/",e.totalTasks]}),C.jsx("span",{className:"text-[10px] text-cam-text-muted",children:Npe(e.completedTasks,e.totalTasks)})]}),C.jsx("div",{className:"w-full h-1 bg-cam-surface-3 rounded-full overflow-hidden mt-1",children:C.jsx(rc.div,{className:"h-full bg-cam-accent rounded-full",initial:!1,animate:{width:`${n}%`},transition:{duration:.4,ease:"easeOut"}})})]}),a>0&&C.jsx("div",{className:"shrink-0 mt-0.5",children:C.jsx(JPt,{agentCount:a,hasNewEvents:s})})]}),C.jsx("button",{onClick:d=>{d.stopPropagation(),l(e)},className:"absolute top-1.5 right-1.5 p-1 rounded-md text-cam-text-muted hover:text-red-500 hover:bg-red-500/10 opacity-0 group-hover:opacity-100 transition-all",title:"Delete project",children:C.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:C.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})})]})}const ADt=[{value:"modern",label:"Modern",description:"Clean and minimalist interface"},{value:"pixel",label:"Pixel",description:"Retro pixel art style"},{value:"terminal",label:"Terminal",description:"Hacker console style"}],Tpe=[{value:"#3b82f6",label:"Blue"},{value:"#ef4444",label:"Red"},{value:"#22c55e",label:"Green"},{value:"#f59e0b",label:"Amber"},{value:"#8b5cf6",label:"Purple"},{value:"#ec4899",label:"Pink"},{value:"#06b6d4",label:"Cyan"},{value:"#f97316",label:"Orange"}],Cpe=/^#[0-9a-fA-F]{6}$/;function MDt(){const e=Di(u=>u.theme),t=Di(u=>u.accentColor),i=Di(u=>u.setTheme),r=Di(u=>u.setAccentColor),[n,a]=ee.useState(Tpe.some(u=>u.value===t)?"":t),[s,o]=ee.useState(!1),l=u=>{if(a(u),o(!1),u==="")return;const h=u.startsWith("#")?u:`#${u}`;Cpe.test(h)?(r(h),o(!1)):h.length>=7&&o(!0)},c=u=>{r(u),a(""),o(!1)};return C.jsxs("div",{className:"space-y-6",children:[C.jsxs("section",{children:[C.jsx("h3",{className:"text-sm font-medium text-cam-text mb-3",children:"Theme"}),C.jsx("div",{className:"grid grid-cols-3 gap-2",children:ADt.map(u=>C.jsxs("button",{onClick:()=>i(u.value),className:`flex flex-col items-center gap-1.5 p-3 rounded-lg border transition-all ${e===u.value?"border-cam-accent bg-cam-accent/10 ring-1 ring-cam-accent/30":"border-cam-border hover:border-cam-border-hover bg-cam-surface-2"}`,children:[C.jsx("div",{className:`w-full h-8 rounded-md ${u.value==="modern"?"bg-gradient-to-br from-cam-surface-3 to-cam-bg":u.value==="pixel"?"bg-[#1a1a2e] border border-[#533483]":"bg-black border border-[#1a3a1a]"}`,children:C.jsx("div",{className:`w-3 h-1.5 mt-1.5 ml-1.5 rounded-sm ${u.value==="modern"?"bg-cam-accent":u.value==="pixel"?"bg-[#e94560]":"bg-[#00ff00]"}`})}),C.jsx("span",{className:`text-xs font-medium ${e===u.value?"text-cam-accent":"text-cam-text-secondary"}`,children:u.label}),C.jsx("span",{className:"text-[10px] text-cam-text-muted leading-tight text-center",children:u.description})]},u.value))})]}),C.jsxs("section",{children:[C.jsx("h3",{className:"text-sm font-medium text-cam-text mb-3",children:"Accent color"}),C.jsx("div",{className:"flex flex-wrap gap-2 mb-3",children:Tpe.map(u=>C.jsx("button",{onClick:()=>c(u.value),className:`w-8 h-8 rounded-full border-2 transition-all ${t===u.value?"border-white ring-2 ring-offset-2 ring-offset-cam-surface scale-110":"border-transparent hover:scale-105"}`,style:{backgroundColor:u.value},title:u.label,"aria-label":`Color ${u.label}`},u.value))}),C.jsxs("div",{className:"flex items-center gap-2",children:[C.jsx("label",{className:"text-xs text-cam-text-muted shrink-0",children:"Custom color:"}),C.jsx("div",{className:"relative flex-1",children:C.jsx("input",{type:"text",value:n,onChange:u=>l(u.target.value),placeholder:"#RRGGBB",maxLength:7,className:`w-full px-3 py-1.5 text-xs rounded-md border bg-cam-surface-2 text-cam-text placeholder:text-cam-text-muted focus:outline-none focus:ring-1 ${s?"border-cam-error focus:ring-cam-error":"border-cam-border focus:ring-cam-accent"}`})}),n&&!s&&Cpe.test(n)&&C.jsx("div",{className:"w-6 h-6 rounded-md border border-cam-border shrink-0",style:{backgroundColor:n}})]}),s&&C.jsx("p",{className:"text-[10px] text-cam-error mt-1",children:"Invalid format. Use #RRGGBB (e.g. #ff5500)"})]})]})}const EDt=[{value:6e4,label:"1 minute"},{value:18e4,label:"3 minutes"},{value:3e5,label:"5 minutes"},{value:6e5,label:"10 minutes"}];function Ppe({checked:e,onChange:t,label:i}){return C.jsxs("div",{className:"flex items-center justify-between",children:[C.jsx("span",{className:"text-xs text-cam-text-secondary",children:i}),C.jsx("button",{role:"switch","aria-checked":e,onClick:t,className:`relative w-9 h-5 rounded-full transition-colors shrink-0 ${e?"bg-cam-accent":"bg-cam-surface-3 border border-cam-border"}`,children:C.jsx("div",{className:`absolute top-0.5 w-4 h-4 rounded-full bg-white shadow-sm transition-transform ${e?"translate-x-[18px]":"translate-x-0.5"}`})})]})}function TDt(){const e=Di(l=>l.showLabels),t=Di(l=>l.showInteractions),i=Di(l=>l.displayMode),r=Di(l=>l.activityWindow),n=Di(l=>l.toggleLabels),a=Di(l=>l.toggleInteractions),s=Di(l=>l.setDisplayMode),o=Di(l=>l.setActivityWindow);return C.jsxs("div",{className:"space-y-6",children:[C.jsxs("section",{children:[C.jsx(Ppe,{checked:e,onChange:n,label:"Show activity labels"}),C.jsx("p",{className:"text-[10px] text-cam-text-muted mt-1.5 ml-0.5",children:"Displays the tool/action name above each agent on the map."})]}),C.jsxs("section",{children:[C.jsx(Ppe,{checked:t,onChange:a,label:"Show communication lines"}),C.jsx("p",{className:"text-[10px] text-cam-text-muted mt-1.5 ml-0.5",children:"Draws lines connecting agents that communicate with each other."})]}),C.jsxs("section",{children:[C.jsx("h3",{className:"text-sm font-medium text-cam-text mb-3",children:"Speech bubbles"}),C.jsx("div",{className:"grid grid-cols-2 gap-2",children:[{value:"technical",label:"Technical",description:"Shows function/tool being executed"},{value:"didactic",label:"Didactic",description:"Shows friendly explanation"}].map(l=>C.jsxs("button",{onClick:()=>s(l.value),className:`flex items-center gap-2.5 p-2.5 rounded-lg border transition-all ${i===l.value?"border-cam-accent bg-cam-accent/10 ring-1 ring-cam-accent/30":"border-cam-border hover:border-cam-border-hover bg-cam-surface-2"}`,children:[C.jsx("div",{className:`w-4 h-4 rounded-full border-2 flex items-center justify-center shrink-0 ${i===l.value?"border-cam-accent":"border-cam-text-muted"}`,children:i===l.value&&C.jsx("div",{className:"w-2 h-2 rounded-full bg-cam-accent"})}),C.jsxs("div",{className:"text-left",children:[C.jsx("span",{className:`text-xs font-medium block ${i===l.value?"text-cam-accent":"text-cam-text-secondary"}`,children:l.label}),C.jsx("span",{className:"text-[10px] text-cam-text-muted leading-tight",children:l.description})]})]},l.value))})]}),C.jsxs("section",{children:[C.jsx("h3",{className:"text-sm font-medium text-cam-text mb-3",children:"Activity window"}),C.jsx("p",{className:"text-[10px] text-cam-text-muted mb-2",children:"Maximum time to consider an agent as active."}),C.jsx("select",{value:r,onChange:l=>o(Number(l.target.value)),className:"w-full px-3 py-2 text-xs rounded-md border border-cam-border bg-cam-surface-2 text-cam-text focus:outline-none focus:ring-1 focus:ring-cam-accent appearance-none cursor-pointer",children:EDt.map(l=>C.jsx("option",{value:l.value,children:l.label},l.value))})]})]})}function wG({checked:e,onChange:t,label:i}){return C.jsxs("div",{className:"flex items-center justify-between",children:[C.jsx("span",{className:"text-xs text-cam-text-secondary",children:i}),C.jsx("button",{role:"switch","aria-checked":e,onClick:t,className:`relative w-9 h-5 rounded-full transition-colors shrink-0 ${e?"bg-cam-accent":"bg-cam-surface-3 border border-cam-border"}`,children:C.jsx("div",{className:`absolute top-0.5 w-4 h-4 rounded-full bg-white shadow-sm transition-transform ${e?"translate-x-[18px]":"translate-x-0.5"}`})})]})}function CDt(){const e=Di(f=>f.followMode),t=Di(f=>f.hidePolling),i=Di(f=>f.pollingTools),r=Di(f=>f.groupRepetitive),n=Di(f=>f.toggleFollowMode),a=Di(f=>f.toggleHidePolling),s=Di(f=>f.toggleGroupRepetitive),o=Di(f=>f.addPollingTool),l=Di(f=>f.removePollingTool),[c,u]=ee.useState(""),h=()=>{const f=c.trim();f!==""&&(o(f),u(""))},d=f=>{f.key==="Enter"&&(f.preventDefault(),h())};return C.jsxs("div",{className:"space-y-6",children:[C.jsxs("section",{children:[C.jsx(wG,{checked:e,onChange:n,label:"Auto-scroll to recent events"}),C.jsx("p",{className:"text-[10px] text-cam-text-muted mt-1.5 ml-0.5",children:"Automatically scrolls the feed to show new events."})]}),C.jsxs("section",{children:[C.jsx(wG,{checked:t,onChange:a,label:"Hide repetitive tools"}),C.jsx("p",{className:"text-[10px] text-cam-text-muted mt-1.5 ml-0.5",children:"Hides events from tools that do constant polling."})]}),C.jsxs("section",{children:[C.jsx("h3",{className:"text-sm font-medium text-cam-text mb-3",children:"Polling tools"}),C.jsx("p",{className:"text-[10px] text-cam-text-muted mb-2",children:'Tools that will be hidden when "Hide repetitive tools" is active.'}),C.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-3 min-h-[28px]",children:[i.map(f=>C.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 text-[11px] rounded-md bg-cam-surface-3 text-cam-text-secondary border border-cam-border",children:[f,C.jsx("button",{onClick:()=>l(f),className:"text-cam-text-muted hover:text-cam-error transition-colors ml-0.5","aria-label":`Remove ${f}`,children:C.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:[C.jsx("line",{x1:"2",y1:"2",x2:"8",y2:"8"}),C.jsx("line",{x1:"8",y1:"2",x2:"2",y2:"8"})]})})]},f)),i.length===0&&C.jsx("span",{className:"text-[10px] text-cam-text-muted italic",children:"No tools configured"})]}),C.jsxs("div",{className:"flex gap-2",children:[C.jsx("input",{type:"text",value:c,onChange:f=>u(f.target.value),onKeyDown:d,placeholder:"Tool name...",className:"flex-1 px-3 py-1.5 text-xs rounded-md border border-cam-border bg-cam-surface-2 text-cam-text placeholder:text-cam-text-muted focus:outline-none focus:ring-1 focus:ring-cam-accent"}),C.jsx("button",{onClick:h,disabled:c.trim()==="",className:"px-3 py-1.5 text-xs font-medium rounded-md bg-cam-accent text-white hover:bg-cam-accent-hover disabled:opacity-40 disabled:cursor-not-allowed transition-colors shrink-0",children:"Add"})]})]}),C.jsxs("section",{children:[C.jsx(wG,{checked:r,onChange:s,label:"Agrupar eventos repetitivos consecutivos"}),C.jsx("p",{className:"text-[10px] text-cam-text-muted mt-1.5 ml-0.5",children:"Eventos identicos consecutivos sao agrupados com contador."})]})]})}function PDt({checked:e,onChange:t,label:i}){return C.jsxs("div",{className:"flex items-center justify-between",children:[C.jsx("span",{className:"text-xs text-cam-text-secondary",children:i}),C.jsx("button",{role:"switch","aria-checked":e,onClick:t,className:`relative w-9 h-5 rounded-full transition-colors shrink-0 ${e?"bg-cam-accent":"bg-cam-surface-3 border border-cam-border"}`,children:C.jsx("div",{className:`absolute top-0.5 w-4 h-4 rounded-full bg-white shadow-sm transition-transform ${e?"translate-x-[18px]":"translate-x-0.5"}`})})]})}function _G({value:e,onChange:t,min:i,max:r,label:n,suffix:a}){const s=c=>{const u=parseInt(c.target.value,10);if(Number.isNaN(u))return;const h=Math.min(r,Math.max(i,u));t(h)},o=()=>{e<r&&t(e+1)},l=()=>{e>i&&t(e-1)};return C.jsxs("div",{children:[C.jsx("label",{className:"text-xs text-cam-text-secondary block mb-1.5",children:n}),C.jsxs("div",{className:"flex items-center gap-1",children:[C.jsx("button",{onClick:l,disabled:e<=i,className:"w-7 h-7 flex items-center justify-center rounded-md border border-cam-border bg-cam-surface-2 text-cam-text-secondary hover:text-cam-text hover:bg-cam-surface-3 disabled:opacity-30 disabled:cursor-not-allowed transition-colors text-sm font-mono","aria-label":"Decrease",children:"-"}),C.jsx("input",{type:"number",value:e,onChange:s,min:i,max:r,className:"w-20 px-2 py-1 text-xs text-center rounded-md border border-cam-border bg-cam-surface-2 text-cam-text focus:outline-none focus:ring-1 focus:ring-cam-accent [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none"}),C.jsx("button",{onClick:o,disabled:e>=r,className:"w-7 h-7 flex items-center justify-center rounded-md border border-cam-border bg-cam-surface-2 text-cam-text-secondary hover:text-cam-text hover:bg-cam-surface-3 disabled:opacity-30 disabled:cursor-not-allowed transition-colors text-sm font-mono","aria-label":"Increase",children:"+"}),a&&C.jsx("span",{className:"text-[10px] text-cam-text-muted ml-1",children:a})]}),C.jsxs("p",{className:"text-[10px] text-cam-text-muted mt-1",children:["Min: ",i," / Max: ",r]})]})}function DDt(){const e=Di(d=>d.maxEvents),t=Di(d=>d.speechBubbleTimeout),i=Di(d=>d.maxCommunicationLines),r=Di(d=>d.lockPanels),n=Di(d=>d.setMaxEvents),a=Di(d=>d.setSpeechBubbleTimeout),s=Di(d=>d.setMaxCommunicationLines),o=Di(d=>d.toggleLockPanels),l=Di(d=>d.resetToDefaults),[c,u]=ee.useState(!1),h=()=>{window.confirm("Are you sure you want to restore all settings to default values?")&&(l(),u(!0),setTimeout(()=>u(!1),2500))};return C.jsxs("div",{className:"space-y-6",children:[C.jsxs("section",{children:[C.jsx(_G,{value:e,onChange:n,min:100,max:1e4,label:"Maximum events in memory",suffix:"events"}),C.jsx("p",{className:"text-[10px] text-cam-text-muted mt-1",children:"Maximum number of events kept in the dashboard. Higher values use more memory."})]}),C.jsxs("section",{children:[C.jsx(_G,{value:t,onChange:a,min:1,max:30,label:"Speech bubble timeout",suffix:"seconds"}),C.jsx("p",{className:"text-[10px] text-cam-text-muted mt-1",children:"How long each speech bubble remains visible before disappearing."})]}),C.jsxs("section",{children:[C.jsx(_G,{value:i,onChange:s,min:1,max:20,label:"Maximum communication lines"}),C.jsx("p",{className:"text-[10px] text-cam-text-muted mt-1",children:"Maximum number of interaction lines visible simultaneously on the Agent Map."})]}),C.jsxs("section",{children:[C.jsx(PDt,{checked:r,onChange:o,label:"Lock panel resizing"}),C.jsx("p",{className:"text-[10px] text-cam-text-muted mt-1.5 ml-0.5",children:"Prevents accidental resizing of dashboard panels."})]}),C.jsxs("section",{className:"pt-2 border-t border-cam-border",children:[C.jsxs("div",{className:"flex items-center justify-between",children:[C.jsxs("div",{children:[C.jsx("h3",{className:"text-sm font-medium text-cam-text",children:"Restore Defaults"}),C.jsx("p",{className:"text-[10px] text-cam-text-muted mt-0.5",children:"Resets all settings to their original values."})]}),C.jsx("button",{onClick:h,className:"px-3 py-1.5 text-xs font-medium rounded-md border border-cam-error/50 text-cam-error hover:bg-cam-error/10 transition-colors shrink-0",children:"Restore Defaults"})]}),c&&C.jsx("div",{className:"mt-2 px-3 py-1.5 text-[11px] text-cam-success bg-cam-success/10 border border-cam-success/30 rounded-md",children:"Settings restored successfully!"})]})]})}const ODt=[{id:"appearance",label:"Appearance"},{id:"agent-map",label:"Agent Map"},{id:"activity-feed",label:"Activity Feed"},{id:"advanced",label:"Advanced"}],RDt={hidden:{opacity:0},visible:{opacity:1},exit:{opacity:0}},IDt={hidden:{opacity:0,scale:.95,y:20},visible:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:20}};function NDt(e){switch(e){case"pixel":return"relative w-full max-w-lg mx-4 max-h-[85vh] flex flex-col";case"terminal":return"relative w-full max-w-lg mx-4 max-h-[85vh] flex flex-col";case"modern":default:return"relative w-full max-w-lg mx-4 max-h-[85vh] flex flex-col rounded-2xl shadow-2xl"}}function LDt(e){switch(e){case"pixel":return{background:"var(--pixel-bg-dark, #0f0f1e)",border:"4px solid var(--pixel-border, #444477)",boxShadow:"inset -4px -4px 0 rgba(0,0,0,0.4), inset 4px 4px 0 rgba(255,255,255,0.08), 0 0 0 2px #000, 8px 8px 0 rgba(0,0,0,0.5)",fontFamily:"'Press Start 2P', monospace",imageRendering:"pixelated"};case"terminal":return{background:"#0a0a0a",border:"1px solid #00aa00",boxShadow:"0 0 20px rgba(0,255,0,0.05), inset 0 0 60px rgba(0,255,0,0.02)",fontFamily:"'JetBrains Mono', 'Fira Code', monospace"};case"modern":default:return{background:"rgba(15, 15, 15, 0.85)",backdropFilter:"blur(24px)",WebkitBackdropFilter:"blur(24px)",border:"1px solid rgba(255,255,255,0.08)"}}}function kDt(e){switch(e){case"pixel":return"flex items-center justify-between px-4 py-3 shrink-0";case"terminal":return"flex items-center justify-between px-4 py-3 shrink-0";case"modern":default:return"flex items-center justify-between px-5 py-4 border-b border-white/5 shrink-0"}}function zDt(e){switch(e){case"pixel":return{borderBottom:"3px solid var(--pixel-border, #444477)",background:"var(--pixel-surface, #222244)"};case"terminal":return{borderBottom:"1px solid #1a3a1a"};default:return{}}}function BDt(e){switch(e){case"pixel":return C.jsx("span",{style:{fontSize:"8px",lineHeight:"14px",color:"var(--pixel-gold, #ffd700)"},children:"SETTINGS"});case"terminal":return C.jsxs("span",{style:{color:"#00ff00",textShadow:"0 0 4px rgba(0,255,0,0.4)",fontSize:"12px"},children:["> settings",C.jsx("span",{style:{animation:"terminal-cursor-blink 0.6s step-end infinite",color:"#00ff00"},children:"█"})]});case"modern":default:return C.jsx("span",{className:"text-base font-semibold text-cam-text",children:"Settings"})}}function UDt(e){switch(e){case"pixel":return"flex items-center justify-center w-7 h-7 pixel-btn";case"terminal":return"flex items-center justify-center w-7 h-7";case"modern":default:return"flex items-center justify-center w-7 h-7 rounded-md text-cam-text-muted hover:text-cam-text hover:bg-white/5 transition-colors"}}function jDt(e){switch(e){case"pixel":return{color:"var(--pixel-text, #e8e8ff)"};case"terminal":return{color:"#00aa00"};default:return{}}}function FDt(e){switch(e){case"pixel":return"flex gap-0 px-3 pt-2 pb-0 shrink-0 flex-wrap";case"terminal":return"flex gap-0 px-4 pt-2 pb-0 shrink-0";case"modern":default:return"flex gap-1 px-5 pt-3 pb-0 shrink-0"}}function VDt(e){switch(e){case"pixel":return{borderBottom:"3px solid var(--pixel-border, #444477)"};case"terminal":return{borderBottom:"1px solid #1a3a1a"};default:return{}}}function HDt(e,t){switch(e){case"pixel":return t?"pixel-btn-active px-2 py-1.5":"pixel-btn px-2 py-1.5";case"terminal":return`px-3 py-1.5 ${t?"":"hover:bg-[#0a1f0a]"}`;case"modern":default:return`px-3 py-1.5 text-xs font-medium rounded-md transition-colors ${t?"bg-cam-accent text-white":"text-cam-text-muted hover:text-cam-text hover:bg-white/5"}`}}function GDt(e,t){switch(e){case"pixel":return{fontSize:"6px",lineHeight:"10px",fontFamily:"'Press Start 2P', monospace"};case"terminal":return{fontSize:"11px",fontFamily:"'JetBrains Mono', monospace",color:t?"#00ff00":"#00aa00",textShadow:t?"0 0 4px rgba(0,255,0,0.4)":"none",borderBottom:t?"2px solid #00ff00":"2px solid transparent",background:"transparent"};default:return{}}}function WDt(e,t,i){return e==="terminal"?i?`> ${t}`:` ${t}`:e==="pixel"?t.toUpperCase():t}function qDt(e){switch(e){case"pixel":return"flex-1 overflow-y-auto px-4 py-3 pixel-scrollbar";case"terminal":return"flex-1 overflow-y-auto px-4 py-3 terminal-scrollbar";case"modern":default:return"flex-1 overflow-y-auto px-5 py-4 modern-scrollbar"}}function XDt({isOpen:e,onClose:t}){const[i,r]=ee.useState("appearance"),n=Di(c=>c.theme),a=ee.useCallback(c=>{c.key==="Escape"&&t()},[t]);ee.useEffect(()=>{if(e)return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[e,a]);const s=ee.useCallback(()=>{t()},[t]),o=ee.useCallback(c=>{c.stopPropagation()},[]),l=()=>{switch(i){case"appearance":return C.jsx(MDt,{});case"agent-map":return C.jsx(TDt,{});case"activity-feed":return C.jsx(CDt,{});case"advanced":return C.jsx(DDt,{})}};return C.jsx(p0,{children:e&&C.jsxs(rc.div,{className:"fixed inset-0 z-50 flex items-center justify-center",variants:RDt,initial:"hidden",animate:"visible",exit:"exit",transition:{duration:.2},onClick:s,children:[C.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm"}),n==="terminal"&&C.jsx("div",{className:"absolute inset-0 pointer-events-none z-[51]",style:{background:"repeating-linear-gradient(0deg, rgba(0,0,0,0.15) 0px, rgba(0,0,0,0.15) 1px, transparent 1px, transparent 3px)"}}),C.jsxs(rc.div,{className:NDt(n),style:LDt(n),variants:IDt,initial:"hidden",animate:"visible",exit:"exit",transition:{duration:.25,ease:"easeOut"},onClick:o,children:[C.jsxs("header",{className:kDt(n),style:zDt(n),children:[C.jsx("h2",{children:BDt(n)}),C.jsx("button",{onClick:t,className:UDt(n),style:jDt(n),"aria-label":"Close",children:n==="terminal"?C.jsx("span",{style:{fontSize:"12px"},children:"[X]"}):n==="pixel"?C.jsx("span",{style:{fontSize:"8px",fontFamily:"'Press Start 2P', monospace"},children:"X"}):C.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[C.jsx("line",{x1:"1",y1:"1",x2:"13",y2:"13"}),C.jsx("line",{x1:"13",y1:"1",x2:"1",y2:"13"})]})})]}),C.jsx("nav",{className:FDt(n),style:VDt(n),children:ODt.map(c=>C.jsx("button",{onClick:()=>r(c.id),className:HDt(n,i===c.id),style:GDt(n,i===c.id),children:WDt(n,c.label,i===c.id)},c.id))}),C.jsx("main",{className:qDt(n),children:l()})]})]})})}function YDt(e){ee.useEffect(()=>{function t(i){for(const r of e){const n=r.ctrl?i.ctrlKey||i.metaKey:!0,a=r.alt?i.altKey:!0,s=r.shift?i.shiftKey:!0;if(i.key===r.key&&n&&a&&s){const o=i.target;if(o.tagName==="INPUT"||o.tagName==="TEXTAREA"||o.isContentEditable)return;i.preventDefault(),r.handler();return}}}return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e])}function $Dt(){const{theme:e}=$P(),t=Di(u=>u.toggleLockPanels),{settingsOpen:i,sidebarCollapsed:r,closeSettings:n,toggleSettings:a,toggleSidebar:s,openSettings:o}=jEe(),l=ee.useMemo(()=>[{key:",",ctrl:!0,handler:a,description:"Toggle settings modal"},{key:"l",ctrl:!0,handler:t,description:"Toggle panel lock"},{key:"b",ctrl:!0,handler:s,description:"Toggle sidebar"}],[t,a,s]);YDt(l);const c=(()=>{switch(e){case"terminal":return C.jsx(gPt,{});case"pixel":return C.jsx(KPt,{});case"modern":default:return C.jsx(jCt,{})}})();return C.jsxs("div",{className:"flex h-screen w-screen overflow-hidden",children:[C.jsx(_Dt,{collapsed:r,onToggleCollapse:s,onOpenSettings:o}),C.jsx("div",{className:"flex-1 overflow-hidden",children:c}),C.jsx(XDt,{isOpen:i,onClose:n})]})}let KDt=0;const NI=sg(e=>({toasts:[],addToast:t=>{const i=`toast-${++KDt}`,r={...t,id:i,createdAt:Date.now()};e(n=>({toasts:[...n.toasts,r].slice(-5)})),setTimeout(()=>{e(n=>({toasts:n.toasts.filter(a=>a.id!==i)}))},t.duration)},removeToast:t=>e(i=>({toasts:i.toasts.filter(r=>r.id!==t)})),clearAll:()=>e({toasts:[]})}));function Dpe({toast:e,onDismiss:t}){const i={info:"border-blue-500/50 bg-blue-500/10",success:"border-cam-success/50 bg-cam-success/10",warning:"border-amber-500/50 bg-amber-500/10",error:"border-cam-error/50 bg-cam-error/10"},r={info:"text-blue-400",success:"text-cam-success",warning:"text-amber-400",error:"text-cam-error"},n={info:"ℹ",success:"✓",warning:"⚠",error:"✗"};return C.jsxs("div",{className:`flex items-start gap-2 px-3 py-2 rounded-lg border backdrop-blur-sm ${i[e.type]} animate-slide-in-right`,style:{minWidth:"240px",maxWidth:"360px"},children:[C.jsx("span",{className:`text-sm mt-0.5 ${r[e.type]}`,children:n[e.type]}),C.jsxs("div",{className:"flex-1 min-w-0",children:[C.jsx("p",{className:"text-xs font-medium text-cam-text",children:e.title}),e.message&&C.jsx("p",{className:"text-xs text-cam-text-muted mt-0.5",children:e.message})]}),C.jsx("button",{onClick:t,className:"text-cam-text-muted hover:text-cam-text text-xs ml-1 shrink-0",children:"x"})]})}function QDt({toast:e,onDismiss:t}){const i={info:"var(--pixel-blue, #4488ff)",success:"var(--pixel-green)",warning:"var(--pixel-gold)",error:"var(--pixel-error)"},r={info:"◆",success:"★",warning:"!",error:"☠"};return C.jsx("div",{className:"pixel-border animate-slide-in-right",style:{background:"var(--pixel-panel)",borderColor:i[e.type],borderWidth:"2px",borderStyle:"solid",padding:"6px 10px",minWidth:"240px",maxWidth:"360px"},children:C.jsxs("div",{className:"flex items-start gap-2",children:[C.jsx("span",{className:"pixel-text-xs",style:{color:i[e.type]},children:r[e.type]}),C.jsxs("div",{className:"flex-1 min-w-0",children:[C.jsx("p",{className:"pixel-text-xs",style:{color:i[e.type]},children:e.title}),e.message&&C.jsx("p",{className:"pixel-text-xs",style:{color:"var(--pixel-text-muted)"},children:e.message})]}),C.jsx("button",{onClick:t,className:"pixel-text-xs",style:{color:"var(--pixel-text-muted)"},children:"x"})]})})}function ZDt({toast:e,onDismiss:t}){const r={info:{text:"[INFO]",color:"#00ff00"},success:{text:"[OK]",color:"#00ff00"},warning:{text:"[WARN]",color:"#ffaa00"},error:{text:"[ERR]",color:"#ff0000"}}[e.type];return C.jsxs("div",{className:"font-mono text-[11px] border border-[#1a3a1a] bg-[#0a0a0a] px-2 py-1 animate-slide-in-right",style:{minWidth:"240px",maxWidth:"360px"},children:[C.jsxs("div",{className:"flex items-start gap-1",children:[C.jsx("span",{style:{color:r.color},children:r.text}),C.jsx("span",{className:"text-[#00ff00] flex-1",children:e.title}),C.jsx("button",{onClick:t,className:"text-[#555] hover:text-[#00ff00]",children:"[x]"})]}),e.message&&C.jsx("div",{className:"text-[#00aa00] ml-7",children:e.message})]})}function JDt(){const{toasts:e,removeToast:t}=NI(),{theme:i}=$P();if(e.length===0)return null;const r={modern:Dpe,pixel:QDt,terminal:ZDt}[i]??Dpe;return C.jsx("div",{className:"fixed top-16 right-4 z-[100] flex flex-col gap-2",children:e.map(n=>C.jsx(r,{toast:n,onDismiss:()=>t(n.id)},n.id))})}function e3t(){return new URLSearchParams(window.location.search).has("session_id")}function t3t(){const{session:e,setSession:t,setProjectId:i}=Ni(),r=ee.useRef(!1),n=ee.useCallback(async()=>{if(!r.current){if(e3t()){r.current=!0;return}try{try{const{registrations:s}=await QEe();if(s.length>0){const o=s.find(u=>u.project_status==="active")||s[0];i(o.project_id);const{sessions:l}=await Y7(o.project_id),c=l.find(u=>u.status==="active");if(c){const{session:u}=await gC(c.id);t(u),r.current=!0;return}}return}catch{}i(null);const{sessions:a}=await q7({status:"active",limit:1});if(a.length>0){const{session:s}=await gC(a[0].id);t(s),r.current=!0}}catch{}}},[t,i]);return ee.useEffect(()=>{n();const a=setInterval(n,15e3);return()=>clearInterval(a)},[n]),{session:e,refreshSession:n}}class i3t{constructor(t){iE(this,"source",null);iE(this,"options");iE(this,"reconnectTimer",null);iE(this,"shouldReconnect",!0);this.options=t}connect(){this.source&&this.disconnect();const t=new URL(this.options.url,window.location.origin);this.options.projectId?t.searchParams.set("project_id",this.options.projectId):this.options.sessionId&&t.searchParams.set("session_id",this.options.sessionId),this.source=new EventSource(t.toString()),this.source.onopen=()=>{var i,r;(r=(i=this.options).onConnect)==null||r.call(i)},this.source.onerror=i=>{var r,n,a,s;(n=(r=this.options).onError)==null||n.call(r,i),(s=(a=this.options).onDisconnect)==null||s.call(a),this.shouldReconnect&&this.scheduleReconnect()},this.addListener("agent_event",this.options.onEvent),this.addListener("agent_status",this.options.onAgentStatus),this.addListener("session_status",this.options.onSessionStatus),this.addListener("task_status_changed",this.options.onTaskStatusChanged),this.addListener("task_assigned",this.options.onTaskAssigned),this.addListener("sprint_progress",this.options.onSprintProgress),this.addListener("project_progress",this.options.onProjectProgress),this.addListener("task_blocked",this.options.onTaskBlocked),this.addListener("task_unblocked",this.options.onTaskUnblocked),this.addListener("correlation_match",this.options.onCorrelationMatch),this.addListener("agent_created",this.options.onAgentCreated),this.addListener("team_created",this.options.onTeamCreated),this.addListener("heartbeat",this.options.onHeartbeat)}addListener(t,i){!this.source||!i||this.source.addEventListener(t,r=>{try{const n=JSON.parse(r.data);i(n)}catch{}})}scheduleReconnect(){this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.reconnectTimer=setTimeout(()=>{this.connect()},this.options.reconnectDelay??3e3)}disconnect(){this.shouldReconnect=!1,this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.source&&(this.source.close(),this.source=null)}reconnect(){this.shouldReconnect=!0,this.connect()}}function r3t(e){const t=ee.useRef(null),i=Ni(d=>d.projectId),{addEvent:r,addAgent:n,updateAgent:a,setConnected:s,setConnectionStatus:o,setLastHeartbeat:l}=Ni(),{updateTask:c,updateActiveProject:u,updateActiveSprint:h}=_n();return ee.useEffect(()=>{if(!e){o("disconnected");return}const d=new i3t({url:"/api/stream",sessionId:e,projectId:i??void 0,onConnect:()=>{s(!0),o("connected")},onDisconnect:()=>{s(!1),o("reconnecting")},onEvent:f=>{r(f),f.agentId&&n({id:f.agentId,sessionId:f.sessionId,name:f.agentId,type:"agent",status:"active",firstSeenAt:f.timestamp,lastActivityAt:f.timestamp,toolCallCount:0,errorCount:0})},onAgentStatus:f=>{a(f.agent,{status:f.status}),(f.status==="shutdown"||f.status==="completed")&&NI.getState().addToast({type:"info",title:`Agent ${f.agent} finished`,duration:4e3})},onSessionStatus:f=>{const m=Ni.getState().session;f.status==="completed"||f.status==="error"?m&&(m.id===f.session||!f.session)&&(Ni.getState().setSession({...m,status:f.status,endedAt:new Date().toISOString()}),NI.getState().addToast({type:f.status==="completed"?"info":"error",title:f.status==="completed"?"Session ended":"Session ended with error",duration:5e3})):f.status==="active"&&m&&(m.id===f.session||!f.session)&&Ni.getState().setSession({...m,status:"active",endedAt:void 0})},onTaskStatusChanged:f=>{c(f.taskId,{status:f.newStatus})},onTaskAssigned:f=>{c(f.taskId,{assignedAgent:f.agent})},onSprintProgress:f=>{h({completedTasks:f.completedTasks,totalTasks:f.totalTasks})},onProjectProgress:f=>{u({completedTasks:f.completedTasks,totalTasks:f.totalTasks})},onTaskBlocked:f=>{c(f.taskId,{status:"blocked",blockedBy:f.blockedBy})},onTaskUnblocked:f=>{c(f.taskId,{status:"pending",blockedBy:[]})},onCorrelationMatch:()=>{},onAgentCreated:f=>{const m=f.name||f.agent;n({id:f.agent,sessionId:f.sessionId,name:m,type:f.type||"agent",status:f.status||"active",firstSeenAt:f.timestamp,lastActivityAt:f.timestamp,toolCallCount:0,errorCount:0}),NI.getState().addToast({type:"success",title:`Agent ${m} joined`,message:f.type?`Type: ${f.type}`:void 0,duration:4e3})},onTeamCreated:()=>{},onHeartbeat:f=>{l(f.timestamp)}});return d.connect(),t.current=d,()=>{d.disconnect(),t.current=null}},[e,i,r,n,a,s,o,l,c,u,h]),t.current}function n3t(){const{projects:e,activeProject:t,setProjects:i,setActiveProject:r}=_n(),n=ee.useRef(!1);return ee.useEffect(()=>{let a=!1;async function s(){try{const{projects:l}=await XEe();a||(i(l),!n.current&&l.length>0&&(_n.getState().activeProject||r(l[0]),n.current=!0))}catch{}}s();const o=setInterval(s,15e3);return()=>{a=!0,clearInterval(o)}},[i,r]),{projects:e,activeProject:t}}function a3t(){const{projects:e,activeProject:t,setActiveProject:i}=_n(),r=ee.useRef(!1);ee.useEffect(()=>{if(r.current||e.length===0)return;const a=new URLSearchParams(window.location.search).get("project_id");if(a){const s=e.find(o=>o.id===a);s&&i(s)}r.current=!0},[e,i]),ee.useEffect(()=>{if(t){const n=new URLSearchParams(window.location.search);n.get("project_id")!==t.id&&(n.set("project_id",t.id),window.history.replaceState({},"",`?${n.toString()}`))}},[t])}function s3t(){const{session:e,setSession:t}=Ni(),i=ee.useRef(!1);ee.useEffect(()=>{if(i.current)return;i.current=!0;const n=new URLSearchParams(window.location.search).get("session_id");n&&o3t(n)},[]),ee.useEffect(()=>{if(!e)return;const r=e.id.slice(0,8),n=new URLSearchParams(window.location.search);n.get("session_id")!==r&&(n.set("session_id",r),window.history.replaceState({},"",`?${n.toString()}`))},[e==null?void 0:e.id])}async function o3t(e){const{setSession:t}=Ni.getState();if(e.length>8)try{const{session:i}=await gC(e);if(i){t(i);return}}catch{}try{const{sessions:i}=await q7({limit:50}),r=i.find(n=>n.id.startsWith(e));if(r){const{session:n}=await gC(r.id);n&&t(n)}}catch{}}function l3t(){const e=Di(s=>s.theme),t=Di(s=>s.accentColor),i=Di(s=>s.activityWindow),r=Di(s=>s.showLabels),n=Di(s=>s.showInteractions),a=Di(s=>s.displayMode);ee.useEffect(()=>{const s=$P.getState();s.theme!==e&&s.setTheme(e),s.accentColor!==t&&s.setAccentColor(t)},[e,t]),ee.useEffect(()=>{const s=Ni.getState();s.activityWindow!==i&&s.setActivityWindow(i)},[i]),ee.useEffect(()=>{const s=C_.getState();s.showLabels!==r&&s.toggleLabels(),s.showInteractions!==n&&s.toggleInteractions(),s.displayMode!==a&&s.setDisplayMode(a)},[r,n,a])}function c3t(){const{session:e}=t3t();return r3t(e==null?void 0:e.id),n3t(),lz(),T0(),Dye(),a3t(),s3t(),l3t(),C.jsxs(C.Fragment,{children:[C.jsx($Dt,{}),C.jsx(JDt,{})]})}LEe.createRoot(document.getElementById("root")).render(C.jsx(ee.StrictMode,{children:C.jsx(c3t,{})}));export{Vv as c,En as g};
|
|
12445
|
+
//# sourceMappingURL=index-4RuPrhph.js.map
|