@foothill/agent-move 1.0.10 → 1.0.11

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.
@@ -1,722 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/browserAll-QyCAT8_K.js","assets/webworkerAll-hM-gNP7L.js","assets/Filter-CBX7EB7j.js","assets/WebGPURenderer-Dwywvwqe.js","assets/BufferResource-Dfd5uHKt.js","assets/RenderTargetSystem-ko-v73NG.js","assets/WebGLRenderer-vhPQEPUG.js","assets/CanvasRenderer-7Cv6xZVP.js"])))=>i.map(i=>d[i]);
2
- var Fu=Object.defineProperty;var Nu=(i,t,e)=>t in i?Fu(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var b=(i,t,e)=>Nu(i,typeof t!="symbol"?t+"":t,e);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))s(n);new MutationObserver(n=>{for(const o of n)if(o.type==="childList")for(const r of o.addedNodes)r.tagName==="LINK"&&r.rel==="modulepreload"&&s(r)}).observe(document,{childList:!0,subtree:!0});function e(n){const o={};return n.integrity&&(o.integrity=n.integrity),n.referrerPolicy&&(o.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?o.credentials="include":n.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function s(n){if(n.ep)return;n.ep=!0;const o=e(n);fetch(n.href,o)}})();const Gu="modulepreload",Wu=function(i){return"/"+i},Bl={},Qn=function(t,e,s){let n=Promise.resolve();if(e&&e.length>0){let r=function(d){return Promise.all(d.map(c=>Promise.resolve(c).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),h=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));n=r(e.map(d=>{if(d=Wu(d),d in Bl)return;Bl[d]=!0;const c=d.endsWith(".css"),p=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${p}`))return;const g=document.createElement("link");if(g.rel=c?"stylesheet":Gu,c||(g.as="script"),g.crossOrigin="",g.href=d,h&&g.setAttribute("nonce",h),document.head.appendChild(g),c)return new Promise((m,y)=>{g.addEventListener("load",m),g.addEventListener("error",()=>y(new Error(`Unable to preload CSS for ${d}`)))})}))}function o(r){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=r,window.dispatchEvent(l),!l.defaultPrevented)throw r}return n.then(r=>{for(const l of r||[])l.status==="rejected"&&o(l.reason);return t().catch(o)})};var yt=(i=>(i.Application="application",i.WebGLPipes="webgl-pipes",i.WebGLPipesAdaptor="webgl-pipes-adaptor",i.WebGLSystem="webgl-system",i.WebGPUPipes="webgpu-pipes",i.WebGPUPipesAdaptor="webgpu-pipes-adaptor",i.WebGPUSystem="webgpu-system",i.CanvasSystem="canvas-system",i.CanvasPipesAdaptor="canvas-pipes-adaptor",i.CanvasPipes="canvas-pipes",i.Asset="asset",i.LoadParser="load-parser",i.ResolveParser="resolve-parser",i.CacheParser="cache-parser",i.DetectionParser="detection-parser",i.MaskEffect="mask-effect",i.BlendMode="blend-mode",i.TextureSource="texture-source",i.Environment="environment",i.ShapeBuilder="shape-builder",i.Batcher="batcher",i))(yt||{});const Ea=i=>{if(typeof i=="function"||typeof i=="object"&&i.extension){if(!i.extension)throw new Error("Extension class must have an extension object");i={...typeof i.extension!="object"?{type:i.extension}:i.extension,ref:i}}if(typeof i=="object")i={...i};else throw new Error("Invalid extension type");return typeof i.type=="string"&&(i.type=[i.type]),i},mo=(i,t)=>Ea(i).priority??t,jt={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...i){return i.map(Ea).forEach(t=>{t.type.forEach(e=>{var s,n;return(n=(s=this._removeHandlers)[e])==null?void 0:n.call(s,t)})}),this},add(...i){return i.map(Ea).forEach(t=>{t.type.forEach(e=>{var o,r;const s=this._addHandlers,n=this._queue;s[e]?(r=s[e])==null||r.call(s,t):(n[e]=n[e]||[],(o=n[e])==null||o.push(t))})}),this},handle(i,t,e){var r;const s=this._addHandlers,n=this._removeHandlers;if(s[i]||n[i])throw new Error(`Extension type ${i} already has a handler`);s[i]=t,n[i]=e;const o=this._queue;return o[i]&&((r=o[i])==null||r.forEach(l=>t(l)),delete o[i]),this},handleByMap(i,t){return this.handle(i,e=>{e.name&&(t[e.name]=e.ref)},e=>{e.name&&delete t[e.name]})},handleByNamedList(i,t,e=-1){return this.handle(i,s=>{t.findIndex(o=>o.name===s.name)>=0||(t.push({name:s.name,value:s.ref}),t.sort((o,r)=>mo(r.value,e)-mo(o.value,e)))},s=>{const n=t.findIndex(o=>o.name===s.name);n!==-1&&t.splice(n,1)})},handleByList(i,t,e=-1){return this.handle(i,s=>{t.includes(s.ref)||(t.push(s.ref),t.sort((n,o)=>mo(o,e)-mo(n,e)))},s=>{const n=t.indexOf(s.ref);n!==-1&&t.splice(n,1)})},mixin(i,...t){for(const e of t)Object.defineProperties(i.prototype,Object.getOwnPropertyDescriptors(e))}},Ou={extension:{type:yt.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await Qn(()=>import("./browserAll-QyCAT8_K.js"),__vite__mapDeps([0,1,2]))}},Hu={extension:{type:yt.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await Qn(()=>import("./webworkerAll-hM-gNP7L.js"),__vite__mapDeps([1,2]))}};class ee{constructor(t,e,s){this._x=e||0,this._y=s||0,this._observer=t}clone(t){return new ee(t??this._observer,this._x,this._y)}set(t=0,e=t){return(this._x!==t||this._y!==e)&&(this._x=t,this._y=e,this._observer._onUpdate(this)),this}copyFrom(t){return(this._x!==t.x||this._y!==t.y)&&(this._x=t.x,this._y=t.y,this._observer._onUpdate(this)),this}copyTo(t){return t.set(this._x,this._y),t}equals(t){return t.x===this._x&&t.y===this._y}toString(){return`[pixi.js/math:ObservablePoint x=${this._x} y=${this._y} scope=${this._observer}]`}get x(){return this._x}set x(t){this._x!==t&&(this._x=t,this._observer._onUpdate(this))}get y(){return this._y}set y(t){this._y!==t&&(this._y=t,this._observer._onUpdate(this))}}function Xc(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Sr={exports:{}},Rl;function Uu(){return Rl||(Rl=1,(function(i){var t=Object.prototype.hasOwnProperty,e="~";function s(){}Object.create&&(s.prototype=Object.create(null),new s().__proto__||(e=!1));function n(h,d,c){this.fn=h,this.context=d,this.once=c||!1}function o(h,d,c,p,g){if(typeof c!="function")throw new TypeError("The listener must be a function");var m=new n(c,p||h,g),y=e?e+d:d;return h._events[y]?h._events[y].fn?h._events[y]=[h._events[y],m]:h._events[y].push(m):(h._events[y]=m,h._eventsCount++),h}function r(h,d){--h._eventsCount===0?h._events=new s:delete h._events[d]}function l(){this._events=new s,this._eventsCount=0}l.prototype.eventNames=function(){var d=[],c,p;if(this._eventsCount===0)return d;for(p in c=this._events)t.call(c,p)&&d.push(e?p.slice(1):p);return Object.getOwnPropertySymbols?d.concat(Object.getOwnPropertySymbols(c)):d},l.prototype.listeners=function(d){var c=e?e+d:d,p=this._events[c];if(!p)return[];if(p.fn)return[p.fn];for(var g=0,m=p.length,y=new Array(m);g<m;g++)y[g]=p[g].fn;return y},l.prototype.listenerCount=function(d){var c=e?e+d:d,p=this._events[c];return p?p.fn?1:p.length:0},l.prototype.emit=function(d,c,p,g,m,y){var x=e?e+d:d;if(!this._events[x])return!1;var w=this._events[x],k=arguments.length,E,B;if(w.fn){switch(w.once&&this.removeListener(d,w.fn,void 0,!0),k){case 1:return w.fn.call(w.context),!0;case 2:return w.fn.call(w.context,c),!0;case 3:return w.fn.call(w.context,c,p),!0;case 4:return w.fn.call(w.context,c,p,g),!0;case 5:return w.fn.call(w.context,c,p,g,m),!0;case 6:return w.fn.call(w.context,c,p,g,m,y),!0}for(B=1,E=new Array(k-1);B<k;B++)E[B-1]=arguments[B];w.fn.apply(w.context,E)}else{var L=w.length,H;for(B=0;B<L;B++)switch(w[B].once&&this.removeListener(d,w[B].fn,void 0,!0),k){case 1:w[B].fn.call(w[B].context);break;case 2:w[B].fn.call(w[B].context,c);break;case 3:w[B].fn.call(w[B].context,c,p);break;case 4:w[B].fn.call(w[B].context,c,p,g);break;default:if(!E)for(H=1,E=new Array(k-1);H<k;H++)E[H-1]=arguments[H];w[B].fn.apply(w[B].context,E)}}return!0},l.prototype.on=function(d,c,p){return o(this,d,c,p,!1)},l.prototype.once=function(d,c,p){return o(this,d,c,p,!0)},l.prototype.removeListener=function(d,c,p,g){var m=e?e+d:d;if(!this._events[m])return this;if(!c)return r(this,m),this;var y=this._events[m];if(y.fn)y.fn===c&&(!g||y.once)&&(!p||y.context===p)&&r(this,m);else{for(var x=0,w=[],k=y.length;x<k;x++)(y[x].fn!==c||g&&!y[x].once||p&&y[x].context!==p)&&w.push(y[x]);w.length?this._events[m]=w.length===1?w[0]:w:r(this,m)}return this},l.prototype.removeAllListeners=function(d){var c;return d?(c=e?e+d:d,this._events[c]&&r(this,c)):(this._events=new s,this._eventsCount=0),this},l.prototype.off=l.prototype.removeListener,l.prototype.addListener=l.prototype.on,l.prefixed=e,l.EventEmitter=l,i.exports=l})(Sr)),Sr.exports}var qu=Uu();const as=Xc(qu),Vu=Math.PI*2,Yu=180/Math.PI,ju=Math.PI/180;class pe{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new pe(this.x,this.y)}copyFrom(t){return this.set(t.x,t.y),this}copyTo(t){return t.set(this.x,this.y),t}equals(t){return t.x===this.x&&t.y===this.y}set(t=0,e=t){return this.x=t,this.y=e,this}toString(){return`[pixi.js/math:Point x=${this.x} y=${this.y}]`}static get shared(){return kr.x=0,kr.y=0,kr}}const kr=new pe;class wt{constructor(t=1,e=0,s=0,n=1,o=0,r=0){this.array=null,this.a=t,this.b=e,this.c=s,this.d=n,this.tx=o,this.ty=r}fromArray(t){this.a=t[0],this.b=t[1],this.c=t[3],this.d=t[4],this.tx=t[2],this.ty=t[5]}set(t,e,s,n,o,r){return this.a=t,this.b=e,this.c=s,this.d=n,this.tx=o,this.ty=r,this}toArray(t,e){this.array||(this.array=new Float32Array(9));const s=e||this.array;return t?(s[0]=this.a,s[1]=this.b,s[2]=0,s[3]=this.c,s[4]=this.d,s[5]=0,s[6]=this.tx,s[7]=this.ty,s[8]=1):(s[0]=this.a,s[1]=this.c,s[2]=this.tx,s[3]=this.b,s[4]=this.d,s[5]=this.ty,s[6]=0,s[7]=0,s[8]=1),s}apply(t,e){e=e||new pe;const s=t.x,n=t.y;return e.x=this.a*s+this.c*n+this.tx,e.y=this.b*s+this.d*n+this.ty,e}applyInverse(t,e){e=e||new pe;const s=this.a,n=this.b,o=this.c,r=this.d,l=this.tx,h=this.ty,d=1/(s*r+o*-n),c=t.x,p=t.y;return e.x=r*d*c+-o*d*p+(h*o-l*r)*d,e.y=s*d*p+-n*d*c+(-h*s+l*n)*d,e}translate(t,e){return this.tx+=t,this.ty+=e,this}scale(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this}rotate(t){const e=Math.cos(t),s=Math.sin(t),n=this.a,o=this.c,r=this.tx;return this.a=n*e-this.b*s,this.b=n*s+this.b*e,this.c=o*e-this.d*s,this.d=o*s+this.d*e,this.tx=r*e-this.ty*s,this.ty=r*s+this.ty*e,this}append(t){const e=this.a,s=this.b,n=this.c,o=this.d;return this.a=t.a*e+t.b*n,this.b=t.a*s+t.b*o,this.c=t.c*e+t.d*n,this.d=t.c*s+t.d*o,this.tx=t.tx*e+t.ty*n+this.tx,this.ty=t.tx*s+t.ty*o+this.ty,this}appendFrom(t,e){const s=t.a,n=t.b,o=t.c,r=t.d,l=t.tx,h=t.ty,d=e.a,c=e.b,p=e.c,g=e.d;return this.a=s*d+n*p,this.b=s*c+n*g,this.c=o*d+r*p,this.d=o*c+r*g,this.tx=l*d+h*p+e.tx,this.ty=l*c+h*g+e.ty,this}setTransform(t,e,s,n,o,r,l,h,d){return this.a=Math.cos(l+d)*o,this.b=Math.sin(l+d)*o,this.c=-Math.sin(l-h)*r,this.d=Math.cos(l-h)*r,this.tx=t-(s*this.a+n*this.c),this.ty=e-(s*this.b+n*this.d),this}prepend(t){const e=this.tx;if(t.a!==1||t.b!==0||t.c!==0||t.d!==1){const s=this.a,n=this.c;this.a=s*t.a+this.b*t.c,this.b=s*t.b+this.b*t.d,this.c=n*t.a+this.d*t.c,this.d=n*t.b+this.d*t.d}return this.tx=e*t.a+this.ty*t.c+t.tx,this.ty=e*t.b+this.ty*t.d+t.ty,this}decompose(t){const e=this.a,s=this.b,n=this.c,o=this.d,r=t.pivot,l=-Math.atan2(-n,o),h=Math.atan2(s,e),d=Math.abs(l+h);return d<1e-5||Math.abs(Vu-d)<1e-5?(t.rotation=h,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=l,t.skew.y=h),t.scale.x=Math.sqrt(e*e+s*s),t.scale.y=Math.sqrt(n*n+o*o),t.position.x=this.tx+(r.x*e+r.y*n),t.position.y=this.ty+(r.x*s+r.y*o),t}invert(){const t=this.a,e=this.b,s=this.c,n=this.d,o=this.tx,r=t*n-e*s;return this.a=n/r,this.b=-e/r,this.c=-s/r,this.d=t/r,this.tx=(s*this.ty-n*o)/r,this.ty=-(t*this.ty-e*o)/r,this}isIdentity(){return this.a===1&&this.b===0&&this.c===0&&this.d===1&&this.tx===0&&this.ty===0}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){const t=new wt;return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyTo(t){return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyFrom(t){return this.a=t.a,this.b=t.b,this.c=t.c,this.d=t.d,this.tx=t.tx,this.ty=t.ty,this}equals(t){return t.a===this.a&&t.b===this.b&&t.c===this.c&&t.d===this.d&&t.tx===this.tx&&t.ty===this.ty}toString(){return`[pixi.js:Matrix a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`}static get IDENTITY(){return Zu.identity()}static get shared(){return Xu.identity()}}const Xu=new wt,Zu=new wt,Fi=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],Ni=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],Gi=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],Wi=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],Pa=[],Zc=[],go=Math.sign;function Ku(){for(let i=0;i<16;i++){const t=[];Pa.push(t);for(let e=0;e<16;e++){const s=go(Fi[i]*Fi[e]+Gi[i]*Ni[e]),n=go(Ni[i]*Fi[e]+Wi[i]*Ni[e]),o=go(Fi[i]*Gi[e]+Gi[i]*Wi[e]),r=go(Ni[i]*Gi[e]+Wi[i]*Wi[e]);for(let l=0;l<16;l++)if(Fi[l]===s&&Ni[l]===n&&Gi[l]===o&&Wi[l]===r){t.push(l);break}}}for(let i=0;i<16;i++){const t=new wt;t.set(Fi[i],Ni[i],Gi[i],Wi[i],0,0),Zc.push(t)}}Ku();const Dt={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:i=>Fi[i],uY:i=>Ni[i],vX:i=>Gi[i],vY:i=>Wi[i],inv:i=>i&8?i&15:-i&7,add:(i,t)=>Pa[i][t],sub:(i,t)=>Pa[i][Dt.inv(t)],rotate180:i=>i^4,isVertical:i=>(i&3)===2,byDirection:(i,t)=>Math.abs(i)*2<=Math.abs(t)?t>=0?Dt.S:Dt.N:Math.abs(t)*2<=Math.abs(i)?i>0?Dt.E:Dt.W:t>0?i>0?Dt.SE:Dt.SW:i>0?Dt.NE:Dt.NW,matrixAppendRotationInv:(i,t,e=0,s=0,n=0,o=0)=>{const r=Zc[Dt.inv(t)],l=r.a,h=r.b,d=r.c,c=r.d,p=e-Math.min(0,l*n,d*o,l*n+d*o),g=s-Math.min(0,h*n,c*o,h*n+c*o),m=i.a,y=i.b,x=i.c,w=i.d;i.a=l*m+h*x,i.b=l*y+h*w,i.c=d*m+c*x,i.d=d*y+c*w,i.tx=p*m+g*x+i.tx,i.ty=p*y+g*w+i.ty},transformRectCoords:(i,t,e,s)=>{const{x:n,y:o,width:r,height:l}=i,{x:h,y:d,width:c,height:p}=t;return e===Dt.E?(s.set(n+h,o+d,r,l),s):e===Dt.S?s.set(c-o-l+h,n+d,l,r):e===Dt.W?s.set(c-n-r+h,p-o-l+d,r,l):e===Dt.N?s.set(o+h,p-n-r+d,l,r):s.set(n+h,o+d,r,l)}},yo=[new pe,new pe,new pe,new pe];class Yt{constructor(t=0,e=0,s=0,n=0){this.type="rectangle",this.x=Number(t),this.y=Number(e),this.width=Number(s),this.height=Number(n)}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}isEmpty(){return this.left===this.right||this.top===this.bottom}static get EMPTY(){return new Yt(0,0,0,0)}clone(){return new Yt(this.x,this.y,this.width,this.height)}copyFromBounds(t){return this.x=t.minX,this.y=t.minY,this.width=t.maxX-t.minX,this.height=t.maxY-t.minY,this}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,e){return this.width<=0||this.height<=0?!1:t>=this.x&&t<this.x+this.width&&e>=this.y&&e<this.y+this.height}strokeContains(t,e,s,n=.5){const{width:o,height:r}=this;if(o<=0||r<=0)return!1;const l=this.x,h=this.y,d=s*(1-n),c=s-d,p=l-d,g=l+o+d,m=h-d,y=h+r+d,x=l+c,w=l+o-c,k=h+c,E=h+r-c;return t>=p&&t<=g&&e>=m&&e<=y&&!(t>x&&t<w&&e>k&&e<E)}intersects(t,e){if(!e){const tt=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=tt)return!1;const X=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>X}const s=this.left,n=this.right,o=this.top,r=this.bottom;if(n<=s||r<=o)return!1;const l=yo[0].set(t.left,t.top),h=yo[1].set(t.left,t.bottom),d=yo[2].set(t.right,t.top),c=yo[3].set(t.right,t.bottom);if(d.x<=l.x||h.y<=l.y)return!1;const p=Math.sign(e.a*e.d-e.b*e.c);if(p===0||(e.apply(l,l),e.apply(h,h),e.apply(d,d),e.apply(c,c),Math.max(l.x,h.x,d.x,c.x)<=s||Math.min(l.x,h.x,d.x,c.x)>=n||Math.max(l.y,h.y,d.y,c.y)<=o||Math.min(l.y,h.y,d.y,c.y)>=r))return!1;const g=p*(h.y-l.y),m=p*(l.x-h.x),y=g*s+m*o,x=g*n+m*o,w=g*s+m*r,k=g*n+m*r;if(Math.max(y,x,w,k)<=g*l.x+m*l.y||Math.min(y,x,w,k)>=g*c.x+m*c.y)return!1;const E=p*(l.y-d.y),B=p*(d.x-l.x),L=E*s+B*o,H=E*n+B*o,$=E*s+B*r,G=E*n+B*r;return!(Math.max(L,H,$,G)<=E*l.x+B*l.y||Math.min(L,H,$,G)>=E*c.x+B*c.y)}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=t*2,this.height+=e*2,this}fit(t){const e=Math.max(this.x,t.x),s=Math.min(this.x+this.width,t.x+t.width),n=Math.max(this.y,t.y),o=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(s-e,0),this.y=n,this.height=Math.max(o-n,0),this}ceil(t=1,e=.001){const s=Math.ceil((this.x+this.width-e)*t)/t,n=Math.ceil((this.y+this.height-e)*t)/t;return this.x=Math.floor((this.x+e)*t)/t,this.y=Math.floor((this.y+e)*t)/t,this.width=s-this.x,this.height=n-this.y,this}scale(t,e=t){return this.x*=t,this.y*=e,this.width*=t,this.height*=e,this}enlarge(t){const e=Math.min(this.x,t.x),s=Math.max(this.x+this.width,t.x+t.width),n=Math.min(this.y,t.y),o=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=s-e,this.y=n,this.height=o-n,this}getBounds(t){return t||(t=new Yt),t.copyFrom(this),t}containsRect(t){if(this.width<=0||this.height<=0)return!1;const e=t.x,s=t.y,n=t.x+t.width,o=t.y+t.height;return e>=this.x&&e<this.x+this.width&&s>=this.y&&s<this.y+this.height&&n>=this.x&&n<this.x+this.width&&o>=this.y&&o<this.y+this.height}set(t,e,s,n){return this.x=t,this.y=e,this.width=s,this.height=n,this}toString(){return`[pixi.js/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`}}const Tr={default:-1};function qt(i="default"){return Tr[i]===void 0&&(Tr[i]=-1),++Tr[i]}const $l=new Set,Ut="8.0.0",Qu="8.3.4",dn={quiet:!1,noColor:!1},Ct=((i,t,e=3)=>{if(dn.quiet||$l.has(t))return;let s=new Error().stack;const n=`${t}
3
- Deprecated since v${i}`,o=typeof console.groupCollapsed=="function"&&!dn.noColor;typeof s>"u"?console.warn("PixiJS Deprecation Warning: ",n):(s=s.split(`
4
- `).splice(e).join(`
5
- `),o?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",n),console.warn(s),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",n),console.warn(s))),$l.add(t)});Object.defineProperties(Ct,{quiet:{get:()=>dn.quiet,set:i=>{dn.quiet=i},enumerable:!0,configurable:!1},noColor:{get:()=>dn.noColor,set:i=>{dn.noColor=i},enumerable:!0,configurable:!1}});const Kc=()=>{};function bn(i){return i+=i===0?1:0,--i,i|=i>>>1,i|=i>>>2,i|=i>>>4,i|=i>>>8,i|=i>>>16,i+1}function Dl(i){return!(i&i-1)&&!!i}function Qc(i){const t={};for(const e in i)i[e]!==void 0&&(t[e]=i[e]);return t}const zl=Object.create(null);function Ju(i){const t=zl[i];return t===void 0&&(zl[i]=qt("resource")),t}const Jc=class td extends as{constructor(t={}){super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,t={...td.defaultOptions,...t},this.addressMode=t.addressMode,this.addressModeU=t.addressModeU??this.addressModeU,this.addressModeV=t.addressModeV??this.addressModeV,this.addressModeW=t.addressModeW??this.addressModeW,this.scaleMode=t.scaleMode,this.magFilter=t.magFilter??this.magFilter,this.minFilter=t.minFilter??this.minFilter,this.mipmapFilter=t.mipmapFilter??this.mipmapFilter,this.lodMinClamp=t.lodMinClamp,this.lodMaxClamp=t.lodMaxClamp,this.compare=t.compare,this.maxAnisotropy=t.maxAnisotropy??1}set addressMode(t){this.addressModeU=t,this.addressModeV=t,this.addressModeW=t}get addressMode(){return this.addressModeU}set wrapMode(t){Ct(Ut,"TextureStyle.wrapMode is now TextureStyle.addressMode"),this.addressMode=t}get wrapMode(){return this.addressMode}set scaleMode(t){this.magFilter=t,this.minFilter=t,this.mipmapFilter=t}get scaleMode(){return this.magFilter}set maxAnisotropy(t){this._maxAnisotropy=Math.min(t,16),this._maxAnisotropy>1&&(this.scaleMode="linear")}get maxAnisotropy(){return this._maxAnisotropy}get _resourceId(){return this._sharedResourceId||this._generateResourceId()}update(){this._sharedResourceId=null,this.emit("change",this)}_generateResourceId(){const t=`${this.addressModeU}-${this.addressModeV}-${this.addressModeW}-${this.magFilter}-${this.minFilter}-${this.mipmapFilter}-${this.lodMinClamp}-${this.lodMaxClamp}-${this.compare}-${this._maxAnisotropy}`;return this._sharedResourceId=Ju(t),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};Jc.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let _n=Jc;const ed=class sd extends as{constructor(t={}){super(),this.options=t,this._gpuData=Object.create(null),this._gcLastUsed=-1,this.uid=qt("textureSource"),this._resourceType="textureSource",this._resourceId=qt("resource"),this.uploadMethodId="unknown",this._resolution=1,this.pixelWidth=1,this.pixelHeight=1,this.width=1,this.height=1,this.sampleCount=1,this.mipLevelCount=1,this.autoGenerateMipmaps=!1,this.format="rgba8unorm",this.dimension="2d",this.viewDimension="2d",this.arrayLayerCount=1,this.antialias=!1,this._touched=0,this._batchTick=-1,this._textureBindLocation=-1,t={...sd.defaultOptions,...t},this.label=t.label??"",this.resource=t.resource,this.autoGarbageCollect=t.autoGarbageCollect,this._resolution=t.resolution,t.width?this.pixelWidth=t.width*this._resolution:this.pixelWidth=this.resource?this.resourceWidth??1:1,t.height?this.pixelHeight=t.height*this._resolution:this.pixelHeight=this.resource?this.resourceHeight??1:1,this.width=this.pixelWidth/this._resolution,this.height=this.pixelHeight/this._resolution,this.format=t.format,this.dimension=t.dimensions,this.viewDimension=t.viewDimension??t.dimensions,this.arrayLayerCount=t.arrayLayerCount,this.mipLevelCount=t.mipLevelCount,this.autoGenerateMipmaps=t.autoGenerateMipmaps,this.sampleCount=t.sampleCount,this.antialias=t.antialias,this.alphaMode=t.alphaMode,this.style=new _n(Qc(t)),this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(t){var e,s;this.style!==t&&((e=this._style)==null||e.off("change",this._onStyleChange,this),this._style=t,(s=this._style)==null||s.on("change",this._onStyleChange,this),this._onStyleChange())}set maxAnisotropy(t){this._style.maxAnisotropy=t}get maxAnisotropy(){return this._style.maxAnisotropy}get addressMode(){return this._style.addressMode}set addressMode(t){this._style.addressMode=t}get repeatMode(){return this._style.addressMode}set repeatMode(t){this._style.addressMode=t}get magFilter(){return this._style.magFilter}set magFilter(t){this._style.magFilter=t}get minFilter(){return this._style.minFilter}set minFilter(t){this._style.minFilter=t}get mipmapFilter(){return this._style.mipmapFilter}set mipmapFilter(t){this._style.mipmapFilter=t}get lodMinClamp(){return this._style.lodMinClamp}set lodMinClamp(t){this._style.lodMinClamp=t}get lodMaxClamp(){return this._style.lodMaxClamp}set lodMaxClamp(t){this._style.lodMaxClamp=t}_onStyleChange(){this.emit("styleChange",this)}update(){if(this.resource){const t=this._resolution;if(this.resize(this.resourceWidth/t,this.resourceHeight/t))return}this.emit("update",this)}destroy(){this.destroyed=!0,this.unload(),this.emit("destroy",this),this._style&&(this._style.destroy(),this._style=null),this.uploadMethodId=null,this.resource=null,this.removeAllListeners()}unload(){var t,e;this._resourceId=qt("resource"),this.emit("change",this),this.emit("unload",this);for(const s in this._gpuData)(e=(t=this._gpuData[s])==null?void 0:t.destroy)==null||e.call(t);this._gpuData=Object.create(null)}get resourceWidth(){const{resource:t}=this;return t.naturalWidth||t.videoWidth||t.displayWidth||t.width}get resourceHeight(){const{resource:t}=this;return t.naturalHeight||t.videoHeight||t.displayHeight||t.height}get resolution(){return this._resolution}set resolution(t){this._resolution!==t&&(this._resolution=t,this.width=this.pixelWidth/t,this.height=this.pixelHeight/t)}resize(t,e,s){s||(s=this._resolution),t||(t=this.width),e||(e=this.height);const n=Math.round(t*s),o=Math.round(e*s);return this.width=n/s,this.height=o/s,this._resolution=s,this.pixelWidth===n&&this.pixelHeight===o?!1:(this._refreshPOT(),this.pixelWidth=n,this.pixelHeight=o,this.emit("resize",this),this._resourceId=qt("resource"),this.emit("change",this),!0)}updateMipmaps(){this.autoGenerateMipmaps&&this.mipLevelCount>1&&this.emit("updateMipmaps",this)}set wrapMode(t){this._style.wrapMode=t}get wrapMode(){return this._style.wrapMode}set scaleMode(t){this._style.scaleMode=t}get scaleMode(){return this._style.scaleMode}_refreshPOT(){this.isPowerOfTwo=Dl(this.pixelWidth)&&Dl(this.pixelHeight)}static test(t){throw new Error("Unimplemented")}};ed.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",dimensions:"2d",viewDimension:"2d",arrayLayerCount:1,mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};let Ge=ed;class fl extends Ge{constructor(t){const e=t.resource||new Float32Array(t.width*t.height*4);let s=t.format;s||(e instanceof Float32Array?s="rgba32float":e instanceof Int32Array||e instanceof Uint32Array?s="rgba32uint":e instanceof Int16Array||e instanceof Uint16Array?s="rgba16uint":(e instanceof Int8Array,s="bgra8unorm")),super({...t,resource:e,format:s}),this.uploadMethodId="buffer"}static test(t){return t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array}}fl.extension=yt.TextureSource;const Fl=new wt;class tf{constructor(t,e){this.mapCoord=new wt,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,typeof e>"u"?this.clampMargin=t.width<10?0:.5:this.clampMargin=e,this.isSimple=!1,this.texture=t}get texture(){return this._texture}set texture(t){var e;this.texture!==t&&((e=this._texture)==null||e.removeListener("update",this.update,this),this._texture=t,this._texture.addListener("update",this.update,this),this.update())}multiplyUvs(t,e){e===void 0&&(e=t);const s=this.mapCoord;for(let n=0;n<t.length;n+=2){const o=t[n],r=t[n+1];e[n]=o*s.a+r*s.c+s.tx,e[n+1]=o*s.b+r*s.d+s.ty}return e}update(){const t=this._texture;this._updateID++;const e=t.uvs;this.mapCoord.set(e.x1-e.x0,e.y1-e.y0,e.x3-e.x0,e.y3-e.y0,e.x0,e.y0);const s=t.orig,n=t.trim;n&&(Fl.set(s.width/n.width,0,0,s.height/n.height,-n.x/n.width,-n.y/n.height),this.mapCoord.append(Fl));const o=t.source,r=this.uClampFrame,l=this.clampMargin/o._resolution,h=this.clampOffset/o._resolution;return r[0]=(t.frame.x+l+h)/o.width,r[1]=(t.frame.y+l+h)/o.height,r[2]=(t.frame.x+t.frame.width-l+h)/o.width,r[3]=(t.frame.y+t.frame.height-l+h)/o.height,this.uClampOffset[0]=this.clampOffset/o.pixelWidth,this.uClampOffset[1]=this.clampOffset/o.pixelHeight,this.isSimple=t.frame.width===o.width&&t.frame.height===o.height&&t.rotate===0,!0}}class $t extends as{constructor({source:t,label:e,frame:s,orig:n,trim:o,defaultAnchor:r,defaultBorders:l,rotate:h,dynamic:d}={}){if(super(),this.uid=qt("texture"),this.uvs={x0:0,y0:0,x1:0,y1:0,x2:0,y2:0,x3:0,y3:0},this.frame=new Yt,this.noFrame=!1,this.dynamic=!1,this.isTexture=!0,this.label=e,this.source=(t==null?void 0:t.source)??new Ge,this.noFrame=!s,s)this.frame.copyFrom(s);else{const{width:c,height:p}=this._source;this.frame.width=c,this.frame.height=p}this.orig=n||this.frame,this.trim=o,this.rotate=h??0,this.defaultAnchor=r,this.defaultBorders=l,this.destroyed=!1,this.dynamic=d||!1,this.updateUvs()}set source(t){this._source&&this._source.off("resize",this.update,this),this._source=t,t.on("resize",this.update,this),this.emit("update",this)}get source(){return this._source}get textureMatrix(){return this._textureMatrix||(this._textureMatrix=new tf(this)),this._textureMatrix}get width(){return this.orig.width}get height(){return this.orig.height}updateUvs(){const{uvs:t,frame:e}=this,{width:s,height:n}=this._source,o=e.x/s,r=e.y/n,l=e.width/s,h=e.height/n;let d=this.rotate;if(d){const c=l/2,p=h/2,g=o+c,m=r+p;d=Dt.add(d,Dt.NW),t.x0=g+c*Dt.uX(d),t.y0=m+p*Dt.uY(d),d=Dt.add(d,2),t.x1=g+c*Dt.uX(d),t.y1=m+p*Dt.uY(d),d=Dt.add(d,2),t.x2=g+c*Dt.uX(d),t.y2=m+p*Dt.uY(d),d=Dt.add(d,2),t.x3=g+c*Dt.uX(d),t.y3=m+p*Dt.uY(d)}else t.x0=o,t.y0=r,t.x1=o+l,t.y1=r,t.x2=o+l,t.y2=r+h,t.x3=o,t.y3=r+h}destroy(t=!1){this._source&&(this._source.off("resize",this.update,this),t&&(this._source.destroy(),this._source=null)),this._textureMatrix=null,this.destroyed=!0,this.emit("destroy",this),this.removeAllListeners()}update(){this.noFrame&&(this.frame.width=this._source.width,this.frame.height=this._source.height),this.updateUvs(),this.emit("update",this)}get baseTexture(){return Ct(Ut,"Texture.baseTexture is now Texture.source"),this._source}}$t.EMPTY=new $t({label:"EMPTY",source:new Ge({label:"EMPTY"})});$t.EMPTY.destroy=Kc;$t.WHITE=new $t({source:new fl({resource:new Uint8Array([255,255,255,255]),width:1,height:1,alphaMode:"premultiply-alpha-on-upload",label:"WHITE"}),label:"WHITE"});$t.WHITE.destroy=Kc;function id(i,t,e){const{width:s,height:n}=e.orig,o=e.trim;if(o){const r=o.width,l=o.height;i.minX=o.x-t._x*s,i.maxX=i.minX+r,i.minY=o.y-t._y*n,i.maxY=i.minY+l}else i.minX=-t._x*s,i.maxX=i.minX+s,i.minY=-t._y*n,i.maxY=i.minY+n}const Nl=new wt;class Ne{constructor(t=1/0,e=1/0,s=-1/0,n=-1/0){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=Nl,this.minX=t,this.minY=e,this.maxX=s,this.maxY=n}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new Yt);const t=this._rectangle;return this.minX>this.maxX||this.minY>this.maxY?(t.x=0,t.y=0,t.width=0,t.height=0):t.copyFromBounds(this),t}clear(){return this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=Nl,this}set(t,e,s,n){this.minX=t,this.minY=e,this.maxX=s,this.maxY=n}addFrame(t,e,s,n,o){o||(o=this.matrix);const r=o.a,l=o.b,h=o.c,d=o.d,c=o.tx,p=o.ty;let g=this.minX,m=this.minY,y=this.maxX,x=this.maxY,w=r*t+h*e+c,k=l*t+d*e+p;w<g&&(g=w),k<m&&(m=k),w>y&&(y=w),k>x&&(x=k),w=r*s+h*e+c,k=l*s+d*e+p,w<g&&(g=w),k<m&&(m=k),w>y&&(y=w),k>x&&(x=k),w=r*t+h*n+c,k=l*t+d*n+p,w<g&&(g=w),k<m&&(m=k),w>y&&(y=w),k>x&&(x=k),w=r*s+h*n+c,k=l*s+d*n+p,w<g&&(g=w),k<m&&(m=k),w>y&&(y=w),k>x&&(x=k),this.minX=g,this.minY=m,this.maxX=y,this.maxY=x}addRect(t,e){this.addFrame(t.x,t.y,t.x+t.width,t.y+t.height,e)}addBounds(t,e){this.addFrame(t.minX,t.minY,t.maxX,t.maxY,e)}addBoundsMask(t){this.minX=this.minX>t.minX?this.minX:t.minX,this.minY=this.minY>t.minY?this.minY:t.minY,this.maxX=this.maxX<t.maxX?this.maxX:t.maxX,this.maxY=this.maxY<t.maxY?this.maxY:t.maxY}applyMatrix(t){const e=this.minX,s=this.minY,n=this.maxX,o=this.maxY,{a:r,b:l,c:h,d,tx:c,ty:p}=t;let g=r*e+h*s+c,m=l*e+d*s+p;this.minX=g,this.minY=m,this.maxX=g,this.maxY=m,g=r*n+h*s+c,m=l*n+d*s+p,this.minX=g<this.minX?g:this.minX,this.minY=m<this.minY?m:this.minY,this.maxX=g>this.maxX?g:this.maxX,this.maxY=m>this.maxY?m:this.maxY,g=r*e+h*o+c,m=l*e+d*o+p,this.minX=g<this.minX?g:this.minX,this.minY=m<this.minY?m:this.minY,this.maxX=g>this.maxX?g:this.maxX,this.maxY=m>this.maxY?m:this.maxY,g=r*n+h*o+c,m=l*n+d*o+p,this.minX=g<this.minX?g:this.minX,this.minY=m<this.minY?m:this.minY,this.maxX=g>this.maxX?g:this.maxX,this.maxY=m>this.maxY?m:this.maxY}fit(t){return this.minX<t.left&&(this.minX=t.left),this.maxX>t.right&&(this.maxX=t.right),this.minY<t.top&&(this.minY=t.top),this.maxY>t.bottom&&(this.maxY=t.bottom),this}fitBounds(t,e,s,n){return this.minX<t&&(this.minX=t),this.maxX>e&&(this.maxX=e),this.minY<s&&(this.minY=s),this.maxY>n&&(this.maxY=n),this}pad(t,e=t){return this.minX-=t,this.maxX+=t,this.minY-=e,this.maxY+=e,this}ceil(){return this.minX=Math.floor(this.minX),this.minY=Math.floor(this.minY),this.maxX=Math.ceil(this.maxX),this.maxY=Math.ceil(this.maxY),this}clone(){return new Ne(this.minX,this.minY,this.maxX,this.maxY)}scale(t,e=t){return this.minX*=t,this.minY*=e,this.maxX*=t,this.maxY*=e,this}get x(){return this.minX}set x(t){const e=this.maxX-this.minX;this.minX=t,this.maxX=t+e}get y(){return this.minY}set y(t){const e=this.maxY-this.minY;this.minY=t,this.maxY=t+e}get width(){return this.maxX-this.minX}set width(t){this.maxX=this.minX+t}get height(){return this.maxY-this.minY}set height(t){this.maxY=this.minY+t}get left(){return this.minX}get right(){return this.maxX}get top(){return this.minY}get bottom(){return this.maxY}get isPositive(){return this.maxX-this.minX>0&&this.maxY-this.minY>0}get isValid(){return this.minX+this.minY!==1/0}addVertexData(t,e,s,n){let o=this.minX,r=this.minY,l=this.maxX,h=this.maxY;n||(n=this.matrix);const d=n.a,c=n.b,p=n.c,g=n.d,m=n.tx,y=n.ty;for(let x=e;x<s;x+=2){const w=t[x],k=t[x+1],E=d*w+p*k+m,B=c*w+g*k+y;o=E<o?E:o,r=B<r?B:r,l=E>l?E:l,h=B>h?B:h}this.minX=o,this.minY=r,this.maxX=l,this.maxY=h}containsPoint(t,e){return this.minX<=t&&this.minY<=e&&this.maxX>=t&&this.maxY>=e}toString(){return`[pixi.js:Bounds minX=${this.minX} minY=${this.minY} maxX=${this.maxX} maxY=${this.maxY} width=${this.width} height=${this.height}]`}copyFrom(t){return this.minX=t.minX,this.minY=t.minY,this.maxX=t.maxX,this.maxY=t.maxY,this}}var ef={grad:.9,turn:360,rad:360/(2*Math.PI)},ls=function(i){return typeof i=="string"?i.length>0:typeof i=="number"},Qt=function(i,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*i)/e+0},De=function(i,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),i>e?e:i>t?i:t},nd=function(i){return(i=isFinite(i)?i%360:0)>0?i:i+360},Gl=function(i){return{r:De(i.r,0,255),g:De(i.g,0,255),b:De(i.b,0,255),a:De(i.a)}},Cr=function(i){return{r:Qt(i.r),g:Qt(i.g),b:Qt(i.b),a:Qt(i.a,3)}},sf=/^#([0-9a-f]{3,8})$/i,bo=function(i){var t=i.toString(16);return t.length<2?"0"+t:t},od=function(i){var t=i.r,e=i.g,s=i.b,n=i.a,o=Math.max(t,e,s),r=o-Math.min(t,e,s),l=r?o===t?(e-s)/r:o===e?2+(s-t)/r:4+(t-e)/r:0;return{h:60*(l<0?l+6:l),s:o?r/o*100:0,v:o/255*100,a:n}},rd=function(i){var t=i.h,e=i.s,s=i.v,n=i.a;t=t/360*6,e/=100,s/=100;var o=Math.floor(t),r=s*(1-e),l=s*(1-(t-o)*e),h=s*(1-(1-t+o)*e),d=o%6;return{r:255*[s,l,r,r,h,s][d],g:255*[h,s,s,l,r,r][d],b:255*[r,r,h,s,s,l][d],a:n}},Wl=function(i){return{h:nd(i.h),s:De(i.s,0,100),l:De(i.l,0,100),a:De(i.a)}},Ol=function(i){return{h:Qt(i.h),s:Qt(i.s),l:Qt(i.l),a:Qt(i.a,3)}},Hl=function(i){return rd((e=(t=i).s,{h:t.h,s:(e*=((s=t.l)<50?s:100-s)/100)>0?2*e/(s+e)*100:0,v:s+e,a:t.a}));var t,e,s},Jn=function(i){return{h:(t=od(i)).h,s:(n=(200-(e=t.s))*(s=t.v)/100)>0&&n<200?e*s/100/(n<=100?n:200-n)*100:0,l:n/2,a:t.a};var t,e,s,n},nf=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,of=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,rf=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,af=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ia={string:[[function(i){var t=sf.exec(i);return t?(i=t[1]).length<=4?{r:parseInt(i[0]+i[0],16),g:parseInt(i[1]+i[1],16),b:parseInt(i[2]+i[2],16),a:i.length===4?Qt(parseInt(i[3]+i[3],16)/255,2):1}:i.length===6||i.length===8?{r:parseInt(i.substr(0,2),16),g:parseInt(i.substr(2,2),16),b:parseInt(i.substr(4,2),16),a:i.length===8?Qt(parseInt(i.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(i){var t=rf.exec(i)||af.exec(i);return t?t[2]!==t[4]||t[4]!==t[6]?null:Gl({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(i){var t=nf.exec(i)||of.exec(i);if(!t)return null;var e,s,n=Wl({h:(e=t[1],s=t[2],s===void 0&&(s="deg"),Number(e)*(ef[s]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return Hl(n)},"hsl"]],object:[[function(i){var t=i.r,e=i.g,s=i.b,n=i.a,o=n===void 0?1:n;return ls(t)&&ls(e)&&ls(s)?Gl({r:Number(t),g:Number(e),b:Number(s),a:Number(o)}):null},"rgb"],[function(i){var t=i.h,e=i.s,s=i.l,n=i.a,o=n===void 0?1:n;if(!ls(t)||!ls(e)||!ls(s))return null;var r=Wl({h:Number(t),s:Number(e),l:Number(s),a:Number(o)});return Hl(r)},"hsl"],[function(i){var t=i.h,e=i.s,s=i.v,n=i.a,o=n===void 0?1:n;if(!ls(t)||!ls(e)||!ls(s))return null;var r=(function(l){return{h:nd(l.h),s:De(l.s,0,100),v:De(l.v,0,100),a:De(l.a)}})({h:Number(t),s:Number(e),v:Number(s),a:Number(o)});return rd(r)},"hsv"]]},Ul=function(i,t){for(var e=0;e<t.length;e++){var s=t[e][0](i);if(s)return[s,t[e][1]]}return[null,void 0]},lf=function(i){return typeof i=="string"?Ul(i.trim(),Ia.string):typeof i=="object"&&i!==null?Ul(i,Ia.object):[null,void 0]},Ar=function(i,t){var e=Jn(i);return{h:e.h,s:De(e.s+100*t,0,100),l:e.l,a:e.a}},Mr=function(i){return(299*i.r+587*i.g+114*i.b)/1e3/255},ql=function(i,t){var e=Jn(i);return{h:e.h,s:e.s,l:De(e.l+100*t,0,100),a:e.a}},La=(function(){function i(t){this.parsed=lf(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return i.prototype.isValid=function(){return this.parsed!==null},i.prototype.brightness=function(){return Qt(Mr(this.rgba),2)},i.prototype.isDark=function(){return Mr(this.rgba)<.5},i.prototype.isLight=function(){return Mr(this.rgba)>=.5},i.prototype.toHex=function(){return t=Cr(this.rgba),e=t.r,s=t.g,n=t.b,r=(o=t.a)<1?bo(Qt(255*o)):"","#"+bo(e)+bo(s)+bo(n)+r;var t,e,s,n,o,r},i.prototype.toRgb=function(){return Cr(this.rgba)},i.prototype.toRgbString=function(){return t=Cr(this.rgba),e=t.r,s=t.g,n=t.b,(o=t.a)<1?"rgba("+e+", "+s+", "+n+", "+o+")":"rgb("+e+", "+s+", "+n+")";var t,e,s,n,o},i.prototype.toHsl=function(){return Ol(Jn(this.rgba))},i.prototype.toHslString=function(){return t=Ol(Jn(this.rgba)),e=t.h,s=t.s,n=t.l,(o=t.a)<1?"hsla("+e+", "+s+"%, "+n+"%, "+o+")":"hsl("+e+", "+s+"%, "+n+"%)";var t,e,s,n,o},i.prototype.toHsv=function(){return t=od(this.rgba),{h:Qt(t.h),s:Qt(t.s),v:Qt(t.v),a:Qt(t.a,3)};var t},i.prototype.invert=function(){return ts({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},i.prototype.saturate=function(t){return t===void 0&&(t=.1),ts(Ar(this.rgba,t))},i.prototype.desaturate=function(t){return t===void 0&&(t=.1),ts(Ar(this.rgba,-t))},i.prototype.grayscale=function(){return ts(Ar(this.rgba,-1))},i.prototype.lighten=function(t){return t===void 0&&(t=.1),ts(ql(this.rgba,t))},i.prototype.darken=function(t){return t===void 0&&(t=.1),ts(ql(this.rgba,-t))},i.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},i.prototype.alpha=function(t){return typeof t=="number"?ts({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):Qt(this.rgba.a,3);var e},i.prototype.hue=function(t){var e=Jn(this.rgba);return typeof t=="number"?ts({h:t,s:e.s,l:e.l,a:e.a}):Qt(e.h)},i.prototype.isEqual=function(t){return this.toHex()===ts(t).toHex()},i})(),ts=function(i){return i instanceof La?i:new La(i)},Vl=[],hf=function(i){i.forEach(function(t){Vl.indexOf(t)<0&&(t(La,Ia),Vl.push(t))})};function cf(i,t){var e={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},s={};for(var n in e)s[e[n]]=n;var o={};i.prototype.toName=function(r){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var l,h,d=s[this.toHex()];if(d)return d;if(r!=null&&r.closest){var c=this.toRgb(),p=1/0,g="black";if(!o.length)for(var m in e)o[m]=new i(e[m]).toRgb();for(var y in e){var x=(l=c,h=o[y],Math.pow(l.r-h.r,2)+Math.pow(l.g-h.g,2)+Math.pow(l.b-h.b,2));x<p&&(p=x,g=y)}return g}},t.string.push([function(r){var l=r.toLowerCase(),h=l==="transparent"?"#0000":e[l];return h?new i(h).toRgb():null},"name"])}hf([cf]);const xn=class jn{constructor(t=16777215){this._value=null,this._components=new Float32Array(4),this._components.fill(1),this._int=16777215,this.value=t}get red(){return this._components[0]}get green(){return this._components[1]}get blue(){return this._components[2]}get alpha(){return this._components[3]}setValue(t){return this.value=t,this}set value(t){if(t instanceof jn)this._value=this._cloneSource(t._value),this._int=t._int,this._components.set(t._components);else{if(t===null)throw new Error("Cannot set Color#value to null");(this._value===null||!this._isSourceEqual(this._value,t))&&(this._value=this._cloneSource(t),this._normalize(this._value))}}get value(){return this._value}_cloneSource(t){return typeof t=="string"||typeof t=="number"||t instanceof Number||t===null?t:Array.isArray(t)||ArrayBuffer.isView(t)?t.slice(0):typeof t=="object"&&t!==null?{...t}:t}_isSourceEqual(t,e){const s=typeof t;if(s!==typeof e)return!1;if(s==="number"||s==="string"||t instanceof Number)return t===e;if(Array.isArray(t)&&Array.isArray(e)||ArrayBuffer.isView(t)&&ArrayBuffer.isView(e))return t.length!==e.length?!1:t.every((o,r)=>o===e[r]);if(t!==null&&e!==null){const o=Object.keys(t),r=Object.keys(e);return o.length!==r.length?!1:o.every(l=>t[l]===e[l])}return t===e}toRgba(){const[t,e,s,n]=this._components;return{r:t,g:e,b:s,a:n}}toRgb(){const[t,e,s]=this._components;return{r:t,g:e,b:s}}toRgbaString(){const[t,e,s]=this.toUint8RgbArray();return`rgba(${t},${e},${s},${this.alpha})`}toUint8RgbArray(t){const[e,s,n]=this._components;return this._arrayRgb||(this._arrayRgb=[]),t||(t=this._arrayRgb),t[0]=Math.round(e*255),t[1]=Math.round(s*255),t[2]=Math.round(n*255),t}toArray(t){this._arrayRgba||(this._arrayRgba=[]),t||(t=this._arrayRgba);const[e,s,n,o]=this._components;return t[0]=e,t[1]=s,t[2]=n,t[3]=o,t}toRgbArray(t){this._arrayRgb||(this._arrayRgb=[]),t||(t=this._arrayRgb);const[e,s,n]=this._components;return t[0]=e,t[1]=s,t[2]=n,t}toNumber(){return this._int}toBgrNumber(){const[t,e,s]=this.toUint8RgbArray();return(s<<16)+(e<<8)+t}toLittleEndianNumber(){const t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){const[e,s,n,o]=jn._temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=s,this._components[2]*=n,this._components[3]*=o,this._refreshInt(),this._value=null,this}premultiply(t,e=!0){return e&&(this._components[0]*=t,this._components[1]*=t,this._components[2]*=t),this._components[3]=t,this._refreshInt(),this._value=null,this}toPremultiplied(t,e=!0){if(t===1)return(255<<24)+this._int;if(t===0)return e?0:this._int;let s=this._int>>16&255,n=this._int>>8&255,o=this._int&255;return e&&(s=s*t+.5|0,n=n*t+.5|0,o=o*t+.5|0),(t*255<<24)+(s<<16)+(n<<8)+o}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const e=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-e.length)+e}setAlpha(t){return this._components[3]=this._clamp(t),this._value=null,this}_normalize(t){let e,s,n,o;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const r=t;e=(r>>16&255)/255,s=(r>>8&255)/255,n=(r&255)/255,o=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[e,s,n,o=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[e,s,n,o=255]=t,e/=255,s/=255,n/=255,o/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const l=jn.HEX_PATTERN.exec(t);l&&(t=`#${l[2]}`)}const r=ts(t);r.isValid()&&({r:e,g:s,b:n,a:o}=r.rgba,e/=255,s/=255,n/=255)}if(e!==void 0)this._components[0]=e,this._components[1]=s,this._components[2]=n,this._components[3]=o,this._refreshInt();else throw new Error(`Unable to convert color ${t}`)}_refreshInt(){this._clamp(this._components);const[t,e,s]=this._components;this._int=(t*255<<16)+(e*255<<8)+(s*255|0)}_clamp(t,e=0,s=1){return typeof t=="number"?Math.min(Math.max(t,e),s):(t.forEach((n,o)=>{t[o]=Math.min(Math.max(n,e),s)}),t)}static isColorLike(t){return typeof t=="number"||typeof t=="string"||t instanceof Number||t instanceof jn||Array.isArray(t)||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Float32Array||t.r!==void 0&&t.g!==void 0&&t.b!==void 0||t.r!==void 0&&t.g!==void 0&&t.b!==void 0&&t.a!==void 0||t.h!==void 0&&t.s!==void 0&&t.l!==void 0||t.h!==void 0&&t.s!==void 0&&t.l!==void 0&&t.a!==void 0||t.h!==void 0&&t.s!==void 0&&t.v!==void 0||t.h!==void 0&&t.s!==void 0&&t.v!==void 0&&t.a!==void 0}};xn.shared=new xn;xn._temp=new xn;xn.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let Kt=xn;const df={cullArea:null,cullable:!1,cullableChildren:!0};let Er=0;const Yl=500;function xe(...i){Er!==Yl&&(Er++,Er===Yl?console.warn("PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS."):console.warn("PixiJS Warning: ",...i))}const uo={_registeredResources:new Set,register(i){this._registeredResources.add(i)},unregister(i){this._registeredResources.delete(i)},release(){this._registeredResources.forEach(i=>i.clear())},get registeredCount(){return this._registeredResources.size},isRegistered(i){return this._registeredResources.has(i)},reset(){this._registeredResources.clear()}};class uf{constructor(t,e){this._pool=[],this._count=0,this._index=0,this._classType=t,e&&this.prepopulate(e)}prepopulate(t){for(let e=0;e<t;e++)this._pool[this._index++]=new this._classType;this._count+=t}get(t){var s;let e;return this._index>0?e=this._pool[--this._index]:(e=new this._classType,this._count++),(s=e.init)==null||s.call(e,t),e}return(t){var e;(e=t.reset)==null||e.call(t),this._pool[this._index++]=t}get totalSize(){return this._count}get totalFree(){return this._index}get totalUsed(){return this._count-this._index}clear(){if(this._pool.length>0&&this._pool[0].destroy)for(let t=0;t<this._index;t++)this._pool[t].destroy();this._pool.length=0,this._count=0,this._index=0}}class ff{constructor(){this._poolsByClass=new Map}prepopulate(t,e){this.getPool(t).prepopulate(e)}get(t,e){return this.getPool(t).get(e)}return(t){this.getPool(t.constructor).return(t)}getPool(t){return this._poolsByClass.has(t)||this._poolsByClass.set(t,new uf(t)),this._poolsByClass.get(t)}stats(){const t={};return this._poolsByClass.forEach(e=>{const s=t[e._classType.name]?e._classType.name+e._classType.ID:e._classType.name;t[s]={free:e.totalFree,used:e.totalUsed,size:e.totalSize}}),t}clear(){this._poolsByClass.forEach(t=>t.clear()),this._poolsByClass.clear()}}const ke=new ff;uo.register(ke);const pf={get isCachedAsTexture(){var i;return!!((i=this.renderGroup)!=null&&i.isCachedAsTexture)},cacheAsTexture(i){typeof i=="boolean"&&i===!1?this.disableRenderGroup():(this.enableRenderGroup(),this.renderGroup.enableCacheAsTexture(i===!0?{}:i))},updateCacheTexture(){var i;(i=this.renderGroup)==null||i.updateCacheTexture()},get cacheAsBitmap(){return this.isCachedAsTexture},set cacheAsBitmap(i){Ct("v8.6.0","cacheAsBitmap is deprecated, use cacheAsTexture instead."),this.cacheAsTexture(i)}};function mf(i,t,e){const s=i.length;let n;if(t>=s||e===0)return;e=t+e>s?s-t:e;const o=s-e;for(n=t;n<o;++n)i[n]=i[n+e];i.length=o}const gf={allowChildren:!0,removeChildren(i=0,t){var o;const e=t??this.children.length,s=e-i,n=[];if(s>0&&s<=e){for(let l=e-1;l>=i;l--){const h=this.children[l];h&&(n.push(h),h.parent=null)}mf(this.children,i,e);const r=this.renderGroup||this.parentRenderGroup;r&&r.removeChildren(n);for(let l=0;l<n.length;++l){const h=n[l];(o=h.parentRenderLayer)==null||o.detach(h),this.emit("childRemoved",h,this,l),n[l].emit("removed",this)}return n.length>0&&this._didViewChangeTick++,n}else if(s===0&&this.children.length===0)return n;throw new RangeError("removeChildren: numeric values are outside the acceptable range.")},removeChildAt(i){const t=this.getChildAt(i);return this.removeChild(t)},getChildAt(i){if(i<0||i>=this.children.length)throw new Error(`getChildAt: Index (${i}) does not exist.`);return this.children[i]},setChildIndex(i,t){if(t<0||t>=this.children.length)throw new Error(`The index ${t} supplied is out of bounds ${this.children.length}`);this.getChildIndex(i),this.addChildAt(i,t)},getChildIndex(i){const t=this.children.indexOf(i);if(t===-1)throw new Error("The supplied Container must be a child of the caller");return t},addChildAt(i,t){this.allowChildren||Ct(Ut,"addChildAt: Only Containers will be allowed to add children in v8.0.0");const{children:e}=this;if(t<0||t>e.length)throw new Error(`${i}addChildAt: The index ${t} supplied is out of bounds ${e.length}`);const s=i.parent===this;if(i.parent){const o=i.parent.children.indexOf(i);if(s){if(o===t)return i;i.parent.children.splice(o,1)}else i.removeFromParent()}t===e.length?e.push(i):e.splice(t,0,i),i.parent=this,i.didChange=!0,i._updateFlags=15;const n=this.renderGroup||this.parentRenderGroup;return n&&n.addChild(i),this.sortableChildren&&(this.sortDirty=!0),s||(this.emit("childAdded",i,this,t),i.emit("added",this)),i},swapChildren(i,t){if(i===t)return;const e=this.getChildIndex(i),s=this.getChildIndex(t);this.children[e]=t,this.children[s]=i;const n=this.renderGroup||this.parentRenderGroup;n&&(n.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){var i;(i=this.parent)==null||i.removeChild(this)},reparentChild(...i){return i.length===1?this.reparentChildAt(i[0],this.children.length):(i.forEach(t=>this.reparentChildAt(t,this.children.length)),i[0])},reparentChildAt(i,t){if(i.parent===this)return this.setChildIndex(i,t),i;const e=i.worldTransform.clone();i.removeFromParent(),this.addChildAt(i,t);const s=this.worldTransform.clone();return s.invert(),e.prepend(s),i.setFromMatrix(e),i},replaceChild(i,t){i.updateLocalTransform(),this.addChildAt(t,this.getChildIndex(i)),t.setFromMatrix(i.localTransform),t.updateLocalTransform(),this.removeChild(i)}},yf={collectRenderables(i,t,e){this.parentRenderLayer&&this.parentRenderLayer!==e||this.globalDisplayStatus<7||!this.includeInBuild||(this.sortableChildren&&this.sortChildren(),this.isSimple?this.collectRenderablesSimple(i,t,e):this.renderGroup?t.renderPipes.renderGroup.addRenderGroup(this.renderGroup,i):this.collectRenderablesWithEffects(i,t,e))},collectRenderablesSimple(i,t,e){const s=this.children,n=s.length;for(let o=0;o<n;o++)s[o].collectRenderables(i,t,e)},collectRenderablesWithEffects(i,t,e){const{renderPipes:s}=t;for(let n=0;n<this.effects.length;n++){const o=this.effects[n];s[o.pipe].push(o,this,i)}this.collectRenderablesSimple(i,t,e);for(let n=this.effects.length-1;n>=0;n--){const o=this.effects[n];s[o.pipe].pop(o,this,i)}}};class jl{constructor(){this.pipe="filter",this.priority=1}destroy(){for(let t=0;t<this.filters.length;t++)this.filters[t].destroy();this.filters=null,this.filterArea=null}}class bf{constructor(){this._effectClasses=[],this._tests=[],this._initialized=!1}init(){this._initialized||(this._initialized=!0,this._effectClasses.forEach(t=>{this.add({test:t.test,maskClass:t})}))}add(t){this._tests.push(t)}getMaskEffect(t){this._initialized||this.init();for(let e=0;e<this._tests.length;e++){const s=this._tests[e];if(s.test(t))return ke.get(s.maskClass,t)}return t}returnMaskEffect(t){ke.return(t)}}const Ba=new bf;jt.handleByList(yt.MaskEffect,Ba._effectClasses);const _f={_maskEffect:null,_maskOptions:{inverse:!1},_filterEffect:null,effects:[],_markStructureAsChanged(){const i=this.renderGroup||this.parentRenderGroup;i&&(i.structureDidChange=!0)},addEffect(i){this.effects.indexOf(i)===-1&&(this.effects.push(i),this.effects.sort((e,s)=>e.priority-s.priority),this._markStructureAsChanged(),this._updateIsSimple())},removeEffect(i){const t=this.effects.indexOf(i);t!==-1&&(this.effects.splice(t,1),this._markStructureAsChanged(),this._updateIsSimple())},set mask(i){const t=this._maskEffect;(t==null?void 0:t.mask)!==i&&(t&&(this.removeEffect(t),Ba.returnMaskEffect(t),this._maskEffect=null),i!=null&&(this._maskEffect=Ba.getMaskEffect(i),this.addEffect(this._maskEffect)))},get mask(){var i;return(i=this._maskEffect)==null?void 0:i.mask},setMask(i){this._maskOptions={...this._maskOptions,...i},i.mask&&(this.mask=i.mask),this._markStructureAsChanged()},set filters(i){var o;!Array.isArray(i)&&i&&(i=[i]);const t=this._filterEffect||(this._filterEffect=new jl);i=i;const e=(i==null?void 0:i.length)>0,s=((o=t.filters)==null?void 0:o.length)>0,n=e!==s;i=Array.isArray(i)?i.slice(0):i,t.filters=Object.freeze(i),n&&(e?this.addEffect(t):(this.removeEffect(t),t.filters=i??null))},get filters(){var i;return(i=this._filterEffect)==null?void 0:i.filters},set filterArea(i){this._filterEffect||(this._filterEffect=new jl),this._filterEffect.filterArea=i},get filterArea(){var i;return(i=this._filterEffect)==null?void 0:i.filterArea}},xf={label:null,get name(){return Ct(Ut,"Container.name property has been removed, use Container.label instead"),this.label},set name(i){Ct(Ut,"Container.name property has been removed, use Container.label instead"),this.label=i},getChildByName(i,t=!1){return this.getChildByLabel(i,t)},getChildByLabel(i,t=!1){const e=this.children;for(let s=0;s<e.length;s++){const n=e[s];if(n.label===i||i instanceof RegExp&&i.test(n.label))return n}if(t)for(let s=0;s<e.length;s++){const o=e[s].getChildByLabel(i,!0);if(o)return o}return null},getChildrenByLabel(i,t=!1,e=[]){const s=this.children;for(let n=0;n<s.length;n++){const o=s[n];(o.label===i||i instanceof RegExp&&i.test(o.label))&&e.push(o)}if(t)for(let n=0;n<s.length;n++)s[n].getChildrenByLabel(i,!0,e);return e}},_e=ke.getPool(wt),ys=ke.getPool(Ne),vf=new wt,wf={getFastGlobalBounds(i,t){t||(t=new Ne),t.clear(),this._getGlobalBoundsRecursive(!!i,t,this.parentRenderLayer),t.isValid||t.set(0,0,0,0);const e=this.renderGroup||this.parentRenderGroup;return t.applyMatrix(e.worldTransform),t},_getGlobalBoundsRecursive(i,t,e){let s=t;if(i&&this.parentRenderLayer&&this.parentRenderLayer!==e||this.localDisplayStatus!==7||!this.measurable)return;const n=!!this.effects.length;if((this.renderGroup||n)&&(s=ys.get().clear()),this.boundsArea)t.addRect(this.boundsArea,this.worldTransform);else{if(this.renderPipeId){const r=this.bounds;s.addFrame(r.minX,r.minY,r.maxX,r.maxY,this.groupTransform)}const o=this.children;for(let r=0;r<o.length;r++)o[r]._getGlobalBoundsRecursive(i,s,e)}if(n){let o=!1;const r=this.renderGroup||this.parentRenderGroup;for(let l=0;l<this.effects.length;l++)this.effects[l].addBounds&&(o||(o=!0,s.applyMatrix(r.worldTransform)),this.effects[l].addBounds(s,!0));o&&s.applyMatrix(r.worldTransform.copyTo(vf).invert()),t.addBounds(s),ys.return(s)}else this.renderGroup&&(t.addBounds(s,this.relativeGroupTransform),ys.return(s))}};function ad(i,t,e){e.clear();let s,n;return i.parent?t?s=i.parent.worldTransform:(n=_e.get().identity(),s=pl(i,n)):s=wt.IDENTITY,ld(i,e,s,t),n&&_e.return(n),e.isValid||e.set(0,0,0,0),e}function ld(i,t,e,s){var l,h;if(!i.visible||!i.measurable)return;let n;s?n=i.worldTransform:(i.updateLocalTransform(),n=_e.get(),n.appendFrom(i.localTransform,e));const o=t,r=!!i.effects.length;if(r&&(t=ys.get().clear()),i.boundsArea)t.addRect(i.boundsArea,n);else{const d=i.bounds;d&&!d.isEmpty()&&(t.matrix=n,t.addBounds(d));for(let c=0;c<i.children.length;c++)ld(i.children[c],t,n,s)}if(r){for(let d=0;d<i.effects.length;d++)(h=(l=i.effects[d]).addBounds)==null||h.call(l,t);o.addBounds(t,wt.IDENTITY),ys.return(t)}s||_e.return(n)}function pl(i,t){const e=i.parent;return e&&(pl(e,t),e.updateLocalTransform(),t.append(e.localTransform)),t}function hd(i,t){if(i===16777215||!t)return t;if(t===16777215||!i)return i;const e=i>>16&255,s=i>>8&255,n=i&255,o=t>>16&255,r=t>>8&255,l=t&255,h=e*o/255|0,d=s*r/255|0,c=n*l/255|0;return(h<<16)+(d<<8)+c}const Xl=16777215;function Zl(i,t){return i===Xl?t:t===Xl?i:hd(i,t)}function jo(i){return((i&255)<<16)+(i&65280)+(i>>16&255)}const Sf={getGlobalAlpha(i){if(i)return this.renderGroup?this.renderGroup.worldAlpha:this.parentRenderGroup?this.parentRenderGroup.worldAlpha*this.alpha:this.alpha;let t=this.alpha,e=this.parent;for(;e;)t*=e.alpha,e=e.parent;return t},getGlobalTransform(i=new wt,t){if(t)return i.copyFrom(this.worldTransform);this.updateLocalTransform();const e=pl(this,_e.get().identity());return i.appendFrom(this.localTransform,e),_e.return(e),i},getGlobalTint(i){if(i)return this.renderGroup?jo(this.renderGroup.worldColor):this.parentRenderGroup?jo(Zl(this.localColor,this.parentRenderGroup.worldColor)):this.tint;let t=this.localColor,e=this.parent;for(;e;)t=Zl(t,e.localColor),e=e.parent;return jo(t)}};function cd(i,t,e){return t.clear(),e||(e=wt.IDENTITY),dd(i,t,e,i,!0),t.isValid||t.set(0,0,0,0),t}function dd(i,t,e,s,n){var h,d;let o;if(n)o=_e.get(),o=e.copyTo(o);else{if(!i.visible||!i.measurable)return;i.updateLocalTransform();const c=i.localTransform;o=_e.get(),o.appendFrom(c,e)}const r=t,l=!!i.effects.length;if(l&&(t=ys.get().clear()),i.boundsArea)t.addRect(i.boundsArea,o);else{i.renderPipeId&&(t.matrix=o,t.addBounds(i.bounds));const c=i.children;for(let p=0;p<c.length;p++)dd(c[p],t,o,s,!1)}if(l){for(let c=0;c<i.effects.length;c++)(d=(h=i.effects[c]).addLocalBounds)==null||d.call(h,t,s);r.addBounds(t,wt.IDENTITY),ys.return(t)}_e.return(o)}function ud(i,t){const e=i.children;for(let s=0;s<e.length;s++){const n=e[s],o=n.uid,r=(n._didViewChangeTick&65535)<<16|n._didContainerChangeTick&65535,l=t.index;(t.data[l]!==o||t.data[l+1]!==r)&&(t.data[t.index]=o,t.data[t.index+1]=r,t.didChange=!0),t.index=l+2,n.children.length&&ud(n,t)}return t.didChange}const kf=new wt,Tf={_localBoundsCacheId:-1,_localBoundsCacheData:null,_setWidth(i,t){const e=Math.sign(this.scale.x)||1;t!==0?this.scale.x=i/t*e:this.scale.x=e},_setHeight(i,t){const e=Math.sign(this.scale.y)||1;t!==0?this.scale.y=i/t*e:this.scale.y=e},getLocalBounds(){this._localBoundsCacheData||(this._localBoundsCacheData={data:[],index:1,didChange:!1,localBounds:new Ne});const i=this._localBoundsCacheData;return i.index=1,i.didChange=!1,i.data[0]!==this._didViewChangeTick&&(i.didChange=!0,i.data[0]=this._didViewChangeTick),ud(this,i),i.didChange&&cd(this,i.localBounds,kf),i.localBounds},getBounds(i,t){return ad(this,i,t||new Ne)}},Cf={_onRender:null,set onRender(i){const t=this.renderGroup||this.parentRenderGroup;if(!i){this._onRender&&(t==null||t.removeOnRender(this)),this._onRender=null;return}this._onRender||t==null||t.addOnRender(this),this._onRender=i},get onRender(){return this._onRender}},Af={_zIndex:0,sortDirty:!1,sortableChildren:!1,get zIndex(){return this._zIndex},set zIndex(i){this._zIndex!==i&&(this._zIndex=i,this.depthOfChildModified())},depthOfChildModified(){this.parent&&(this.parent.sortableChildren=!0,this.parent.sortDirty=!0),this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0)},sortChildren(){this.sortDirty&&(this.sortDirty=!1,this.children.sort(Mf))}};function Mf(i,t){return i._zIndex-t._zIndex}const Ef={getGlobalPosition(i=new pe,t=!1){return this.parent?this.parent.toGlobal(this._position,i,t):(i.x=this._position.x,i.y=this._position.y),i},toGlobal(i,t,e=!1){const s=this.getGlobalTransform(_e.get(),e);return t=s.apply(i,t),_e.return(s),t},toLocal(i,t,e,s){t&&(i=t.toGlobal(i,e,s));const n=this.getGlobalTransform(_e.get(),s);return e=n.applyInverse(i,e),_e.return(n),e}};class ml{constructor(){this.uid=qt("instructionSet"),this.instructions=[],this.instructionSize=0,this.renderables=[],this.gcTick=0}reset(){this.instructionSize=0}destroy(){this.instructions.length=0,this.renderables.length=0,this.renderPipes=null,this.gcTick=0}add(t){this.instructions[this.instructionSize++]=t}log(){this.instructions.length=this.instructionSize,console.table(this.instructions,["type","action"])}}let Pf=0;class If{constructor(t){this._poolKeyHash=Object.create(null),this._texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this.textureStyle=new _n(this.textureOptions)}createTexture(t,e,s,n){const o=new Ge({...this.textureOptions,width:t,height:e,resolution:1,antialias:s,autoGarbageCollect:!1,autoGenerateMipmaps:n});return new $t({source:o,label:`texturePool_${Pf++}`})}getOptimalTexture(t,e,s=1,n,o=!1){let r=Math.ceil(t*s-1e-6),l=Math.ceil(e*s-1e-6);r=bn(r),l=bn(l);const h=n?1:0,d=o?1:0,c=(r<<17)+(l<<2)+(d<<1)+h;this._texturePool[c]||(this._texturePool[c]=[]);let p=this._texturePool[c].pop();return p||(p=this.createTexture(r,l,n,o)),p.source._resolution=s,p.source.width=r/s,p.source.height=l/s,p.source.pixelWidth=r,p.source.pixelHeight=l,p.frame.x=0,p.frame.y=0,p.frame.width=t,p.frame.height=e,p.updateUvs(),this._poolKeyHash[p.uid]=c,p}getSameSizeTexture(t,e=!1){const s=t.source;return this.getOptimalTexture(t.width,t.height,s._resolution,e)}returnTexture(t,e=!1){const s=this._poolKeyHash[t.uid];e&&(t.source.style=this.textureStyle),this._texturePool[s].push(t)}clear(t){if(t=t!==!1,t)for(const e in this._texturePool){const s=this._texturePool[e];if(s)for(let n=0;n<s.length;n++)s[n].destroy(!0)}this._texturePool={}}}const yr=new If;uo.register(yr);class Lf{constructor(){this.renderPipeId="renderGroup",this.root=null,this.canBundle=!1,this.renderGroupParent=null,this.renderGroupChildren=[],this.worldTransform=new wt,this.worldColorAlpha=4294967295,this.worldColor=16777215,this.worldAlpha=1,this.childrenToUpdate=Object.create(null),this.updateTick=0,this.gcTick=0,this.childrenRenderablesToUpdate={list:[],index:0},this.structureDidChange=!0,this.instructionSet=new ml,this._onRenderContainers=[],this.textureNeedsUpdate=!0,this.isCachedAsTexture=!1,this._matrixDirty=7}init(t){this.root=t,t._onRender&&this.addOnRender(t),t.didChange=!0;const e=t.children;for(let s=0;s<e.length;s++){const n=e[s];n._updateFlags=15,this.addChild(n)}}enableCacheAsTexture(t={}){this.textureOptions=t,this.isCachedAsTexture=!0,this.textureNeedsUpdate=!0}disableCacheAsTexture(){this.isCachedAsTexture=!1,this.texture&&(yr.returnTexture(this.texture,!0),this.texture=null)}updateCacheTexture(){this.textureNeedsUpdate=!0;const t=this._parentCacheAsTextureRenderGroup;t&&!t.textureNeedsUpdate&&t.updateCacheTexture()}reset(){this.renderGroupChildren.length=0;for(const t in this.childrenToUpdate){const e=this.childrenToUpdate[t];e.list.fill(null),e.index=0}this.childrenRenderablesToUpdate.index=0,this.childrenRenderablesToUpdate.list.fill(null),this.root=null,this.updateTick=0,this.structureDidChange=!0,this._onRenderContainers.length=0,this.renderGroupParent=null,this.disableCacheAsTexture()}get localTransform(){return this.root.localTransform}addRenderGroupChild(t){t.renderGroupParent&&t.renderGroupParent._removeRenderGroupChild(t),t.renderGroupParent=this,this.renderGroupChildren.push(t)}_removeRenderGroupChild(t){const e=this.renderGroupChildren.indexOf(t);e>-1&&this.renderGroupChildren.splice(e,1),t.renderGroupParent=null}addChild(t){if(this.structureDidChange=!0,t.parentRenderGroup=this,t.updateTick=-1,t.parent===this.root?t.relativeRenderGroupDepth=1:t.relativeRenderGroupDepth=t.parent.relativeRenderGroupDepth+1,t.didChange=!0,this.onChildUpdate(t),t.renderGroup){this.addRenderGroupChild(t.renderGroup);return}t._onRender&&this.addOnRender(t);const e=t.children;for(let s=0;s<e.length;s++)this.addChild(e[s])}removeChild(t){if(this.structureDidChange=!0,t._onRender&&(t.renderGroup||this.removeOnRender(t)),t.parentRenderGroup=null,t.renderGroup){this._removeRenderGroupChild(t.renderGroup);return}const e=t.children;for(let s=0;s<e.length;s++)this.removeChild(e[s])}removeChildren(t){for(let e=0;e<t.length;e++)this.removeChild(t[e])}onChildUpdate(t){let e=this.childrenToUpdate[t.relativeRenderGroupDepth];e||(e=this.childrenToUpdate[t.relativeRenderGroupDepth]={index:0,list:[]}),e.list[e.index++]=t}updateRenderable(t){t.globalDisplayStatus<7||(this.instructionSet.renderPipes[t.renderPipeId].updateRenderable(t),t.didViewUpdate=!1)}onChildViewUpdate(t){this.childrenRenderablesToUpdate.list[this.childrenRenderablesToUpdate.index++]=t}get isRenderable(){return this.root.localDisplayStatus===7&&this.worldAlpha>0}addOnRender(t){this._onRenderContainers.push(t)}removeOnRender(t){this._onRenderContainers.splice(this._onRenderContainers.indexOf(t),1)}runOnRender(t){for(let e=0;e<this._onRenderContainers.length;e++)this._onRenderContainers[e]._onRender(t)}destroy(){this.disableCacheAsTexture(),this.renderGroupParent=null,this.root=null,this.childrenRenderablesToUpdate=null,this.childrenToUpdate=null,this.renderGroupChildren=null,this._onRenderContainers=null,this.instructionSet=null}getChildren(t=[]){const e=this.root.children;for(let s=0;s<e.length;s++)this._getChildren(e[s],t);return t}_getChildren(t,e=[]){if(e.push(t),t.renderGroup)return e;const s=t.children;for(let n=0;n<s.length;n++)this._getChildren(s[n],e);return e}invalidateMatrices(){this._matrixDirty=7}get inverseWorldTransform(){return(this._matrixDirty&1)===0?this._inverseWorldTransform:(this._matrixDirty&=-2,this._inverseWorldTransform||(this._inverseWorldTransform=new wt),this._inverseWorldTransform.copyFrom(this.worldTransform).invert())}get textureOffsetInverseTransform(){return(this._matrixDirty&2)===0?this._textureOffsetInverseTransform:(this._matrixDirty&=-3,this._textureOffsetInverseTransform||(this._textureOffsetInverseTransform=new wt),this._textureOffsetInverseTransform.copyFrom(this.inverseWorldTransform).translate(-this._textureBounds.x,-this._textureBounds.y))}get inverseParentTextureTransform(){if((this._matrixDirty&4)===0)return this._inverseParentTextureTransform;this._matrixDirty&=-5;const t=this._parentCacheAsTextureRenderGroup;return t?(this._inverseParentTextureTransform||(this._inverseParentTextureTransform=new wt),this._inverseParentTextureTransform.copyFrom(this.worldTransform).prepend(t.inverseWorldTransform).translate(-t._textureBounds.x,-t._textureBounds.y)):this.worldTransform}get cacheToLocalTransform(){return this.isCachedAsTexture?this.textureOffsetInverseTransform:this._parentCacheAsTextureRenderGroup?this._parentCacheAsTextureRenderGroup.textureOffsetInverseTransform:null}}function Bf(i,t,e={}){for(const s in t)!e[s]&&t[s]!==void 0&&(i[s]=t[s])}const Pr=new ee(null),_o=new ee(null),Ir=new ee(null,1,1),xo=new ee(null),Kl=1,Rf=2,Lr=4;class Ft extends as{constructor(t={}){var e,s;super(),this.uid=qt("renderable"),this._updateFlags=15,this.renderGroup=null,this.parentRenderGroup=null,this.parentRenderGroupIndex=0,this.didChange=!1,this.didViewUpdate=!1,this.relativeRenderGroupDepth=0,this.children=[],this.parent=null,this.includeInBuild=!0,this.measurable=!0,this.isSimple=!0,this.parentRenderLayer=null,this.updateTick=-1,this.localTransform=new wt,this.relativeGroupTransform=new wt,this.groupTransform=this.relativeGroupTransform,this.destroyed=!1,this._position=new ee(this,0,0),this._scale=Ir,this._pivot=_o,this._origin=xo,this._skew=Pr,this._cx=1,this._sx=0,this._cy=0,this._sy=1,this._rotation=0,this.localColor=16777215,this.localAlpha=1,this.groupAlpha=1,this.groupColor=16777215,this.groupColorAlpha=4294967295,this.localBlendMode="inherit",this.groupBlendMode="normal",this.localDisplayStatus=7,this.globalDisplayStatus=7,this._didContainerChangeTick=0,this._didViewChangeTick=0,this._didLocalTransformChangeId=-1,this.effects=[],Bf(this,t,{children:!0,parent:!0,effects:!0}),(e=t.children)==null||e.forEach(n=>this.addChild(n)),(s=t.parent)==null||s.addChild(this)}static mixin(t){Ct("8.8.0","Container.mixin is deprecated, please use extensions.mixin instead."),jt.mixin(Ft,t)}set _didChangeId(t){this._didViewChangeTick=t>>12&4095,this._didContainerChangeTick=t&4095}get _didChangeId(){return this._didContainerChangeTick&4095|(this._didViewChangeTick&4095)<<12}addChild(...t){if(this.allowChildren||Ct(Ut,"addChild: Only Containers will be allowed to add children in v8.0.0"),t.length>1){for(let n=0;n<t.length;n++)this.addChild(t[n]);return t[0]}const e=t[0],s=this.renderGroup||this.parentRenderGroup;return e.parent===this?(this.children.splice(this.children.indexOf(e),1),this.children.push(e),s&&(s.structureDidChange=!0),e):(e.parent&&e.parent.removeChild(e),this.children.push(e),this.sortableChildren&&(this.sortDirty=!0),e.parent=this,e.didChange=!0,e._updateFlags=15,s&&s.addChild(e),this.emit("childAdded",e,this,this.children.length-1),e.emit("added",this),this._didViewChangeTick++,e._zIndex!==0&&e.depthOfChildModified(),e)}removeChild(...t){if(t.length>1){for(let n=0;n<t.length;n++)this.removeChild(t[n]);return t[0]}const e=t[0],s=this.children.indexOf(e);return s>-1&&(this._didViewChangeTick++,this.children.splice(s,1),this.renderGroup?this.renderGroup.removeChild(e):this.parentRenderGroup&&this.parentRenderGroup.removeChild(e),e.parentRenderLayer&&e.parentRenderLayer.detach(e),e.parent=null,this.emit("childRemoved",e,this,s),e.emit("removed",this)),e}_onUpdate(t){t&&t===this._skew&&this._updateSkew(),this._didContainerChangeTick++,!this.didChange&&(this.didChange=!0,this.parentRenderGroup&&this.parentRenderGroup.onChildUpdate(this))}set isRenderGroup(t){!!this.renderGroup!==t&&(t?this.enableRenderGroup():this.disableRenderGroup())}get isRenderGroup(){return!!this.renderGroup}enableRenderGroup(){if(this.renderGroup)return;const t=this.parentRenderGroup;t==null||t.removeChild(this),this.renderGroup=ke.get(Lf,this),this.groupTransform=wt.IDENTITY,t==null||t.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const t=this.parentRenderGroup;t==null||t.removeChild(this),ke.return(this.renderGroup),this.renderGroup=null,this.groupTransform=this.relativeGroupTransform,t==null||t.addChild(this),this._updateIsSimple()}_updateIsSimple(){this.isSimple=!this.renderGroup&&this.effects.length===0}get worldTransform(){return this._worldTransform||(this._worldTransform=new wt),this.renderGroup?this._worldTransform.copyFrom(this.renderGroup.worldTransform):this.parentRenderGroup&&this._worldTransform.appendFrom(this.relativeGroupTransform,this.parentRenderGroup.worldTransform),this._worldTransform}get x(){return this._position.x}set x(t){this._position.x=t}get y(){return this._position.y}set y(t){this._position.y=t}get position(){return this._position}set position(t){this._position.copyFrom(t)}get rotation(){return this._rotation}set rotation(t){this._rotation!==t&&(this._rotation=t,this._onUpdate(this._skew))}get angle(){return this.rotation*Yu}set angle(t){this.rotation=t*ju}get pivot(){return this._pivot===_o&&(this._pivot=new ee(this,0,0)),this._pivot}set pivot(t){this._pivot===_o&&(this._pivot=new ee(this,0,0),this._origin!==xo&&xe("Setting both a pivot and origin on a Container is not recommended. This can lead to unexpected behavior if not handled carefully.")),typeof t=="number"?this._pivot.set(t):this._pivot.copyFrom(t)}get skew(){return this._skew===Pr&&(this._skew=new ee(this,0,0)),this._skew}set skew(t){this._skew===Pr&&(this._skew=new ee(this,0,0)),this._skew.copyFrom(t)}get scale(){return this._scale===Ir&&(this._scale=new ee(this,1,1)),this._scale}set scale(t){this._scale===Ir&&(this._scale=new ee(this,0,0)),typeof t=="string"&&(t=parseFloat(t)),typeof t=="number"?this._scale.set(t):this._scale.copyFrom(t)}get origin(){return this._origin===xo&&(this._origin=new ee(this,0,0)),this._origin}set origin(t){this._origin===xo&&(this._origin=new ee(this,0,0),this._pivot!==_o&&xe("Setting both a pivot and origin on a Container is not recommended. This can lead to unexpected behavior if not handled carefully.")),typeof t=="number"?this._origin.set(t):this._origin.copyFrom(t)}get width(){return Math.abs(this.scale.x*this.getLocalBounds().width)}set width(t){const e=this.getLocalBounds().width;this._setWidth(t,e)}get height(){return Math.abs(this.scale.y*this.getLocalBounds().height)}set height(t){const e=this.getLocalBounds().height;this._setHeight(t,e)}getSize(t){t||(t={});const e=this.getLocalBounds();return t.width=Math.abs(this.scale.x*e.width),t.height=Math.abs(this.scale.y*e.height),t}setSize(t,e){const s=this.getLocalBounds();typeof t=="object"?(e=t.height??t.width,t=t.width):e??(e=t),t!==void 0&&this._setWidth(t,s.width),e!==void 0&&this._setHeight(e,s.height)}_updateSkew(){const t=this._rotation,e=this._skew;this._cx=Math.cos(t+e._y),this._sx=Math.sin(t+e._y),this._cy=-Math.sin(t-e._x),this._sy=Math.cos(t-e._x)}updateTransform(t){return this.position.set(typeof t.x=="number"?t.x:this.position.x,typeof t.y=="number"?t.y:this.position.y),this.scale.set(typeof t.scaleX=="number"?t.scaleX||1:this.scale.x,typeof t.scaleY=="number"?t.scaleY||1:this.scale.y),this.rotation=typeof t.rotation=="number"?t.rotation:this.rotation,this.skew.set(typeof t.skewX=="number"?t.skewX:this.skew.x,typeof t.skewY=="number"?t.skewY:this.skew.y),this.pivot.set(typeof t.pivotX=="number"?t.pivotX:this.pivot.x,typeof t.pivotY=="number"?t.pivotY:this.pivot.y),this.origin.set(typeof t.originX=="number"?t.originX:this.origin.x,typeof t.originY=="number"?t.originY:this.origin.y),this}setFromMatrix(t){t.decompose(this)}updateLocalTransform(){const t=this._didContainerChangeTick;if(this._didLocalTransformChangeId===t)return;this._didLocalTransformChangeId=t;const e=this.localTransform,s=this._scale,n=this._pivot,o=this._origin,r=this._position,l=s._x,h=s._y,d=n._x,c=n._y,p=-o._x,g=-o._y;e.a=this._cx*l,e.b=this._sx*l,e.c=this._cy*h,e.d=this._sy*h,e.tx=r._x-(d*e.a+c*e.c)+(p*e.a+g*e.c)-p,e.ty=r._y-(d*e.b+c*e.d)+(p*e.b+g*e.d)-g}set alpha(t){t!==this.localAlpha&&(this.localAlpha=t,this._updateFlags|=Kl,this._onUpdate())}get alpha(){return this.localAlpha}set tint(t){const s=Kt.shared.setValue(t??16777215).toBgrNumber();s!==this.localColor&&(this.localColor=s,this._updateFlags|=Kl,this._onUpdate())}get tint(){return jo(this.localColor)}set blendMode(t){this.localBlendMode!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Rf,this.localBlendMode=t,this._onUpdate())}get blendMode(){return this.localBlendMode}get visible(){return!!(this.localDisplayStatus&2)}set visible(t){const e=t?2:0;(this.localDisplayStatus&2)!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Lr,this.localDisplayStatus^=2,this._onUpdate(),this.emit("visibleChanged",t))}get culled(){return!(this.localDisplayStatus&4)}set culled(t){const e=t?0:4;(this.localDisplayStatus&4)!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Lr,this.localDisplayStatus^=4,this._onUpdate())}get renderable(){return!!(this.localDisplayStatus&1)}set renderable(t){const e=t?1:0;(this.localDisplayStatus&1)!==e&&(this._updateFlags|=Lr,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get isRenderable(){return this.localDisplayStatus===7&&this.groupAlpha>0}destroy(t=!1){var n;if(this.destroyed)return;this.destroyed=!0;let e;if(this.children.length&&(e=this.removeChildren(0,this.children.length)),this.removeFromParent(),this.parent=null,this._maskEffect=null,this._filterEffect=null,this.effects=null,this._position=null,this._scale=null,this._pivot=null,this._origin=null,this._skew=null,this.emit("destroyed",this),this.removeAllListeners(),(typeof t=="boolean"?t:t==null?void 0:t.children)&&e)for(let o=0;o<e.length;++o)e[o].destroy(t);(n=this.renderGroup)==null||n.destroy(),this.renderGroup=null}}jt.mixin(Ft,gf,wf,Ef,Cf,Tf,_f,xf,Af,df,pf,Sf,yf);class gl extends Ft{constructor(t){super(t),this.canBundle=!0,this.allowChildren=!1,this._roundPixels=0,this._lastUsed=-1,this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this._bounds=new Ne(0,1,0,0),this._boundsDirty=!0,this.autoGarbageCollect=t.autoGarbageCollect??!0}get bounds(){return this._boundsDirty?(this.updateBounds(),this._boundsDirty=!1,this._bounds):this._bounds}get roundPixels(){return!!this._roundPixels}set roundPixels(t){this._roundPixels=t?1:0}containsPoint(t){const e=this.bounds,{x:s,y:n}=t;return s>=e.minX&&s<=e.maxX&&n>=e.minY&&n<=e.maxY}onViewUpdate(){if(this._didViewChangeTick++,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}unload(){var t;this.emit("unload",this);for(const e in this._gpuData)(t=this._gpuData[e])==null||t.destroy();this._gpuData=Object.create(null),this.onViewUpdate()}destroy(t){this.unload(),super.destroy(t),this._bounds=null}collectRenderablesSimple(t,e,s){const{renderPipes:n}=e;n.blendMode.pushBlendMode(this,this.groupBlendMode,t);const r=n[this.renderPipeId];r!=null&&r.addRenderable&&r.addRenderable(this,t),this.didViewUpdate=!1;const l=this.children,h=l.length;for(let d=0;d<h;d++)l[d].collectRenderables(t,e,s);n.blendMode.popBlendMode(t)}}class Yi extends gl{constructor(t=$t.EMPTY){t instanceof $t&&(t={texture:t});const{texture:e=$t.EMPTY,anchor:s,roundPixels:n,width:o,height:r,...l}=t;super({label:"Sprite",...l}),this.renderPipeId="sprite",this.batched=!0,this._visualBounds={minX:0,maxX:1,minY:0,maxY:0},this._anchor=new ee({_onUpdate:()=>{this.onViewUpdate()}}),s?this.anchor=s:e.defaultAnchor&&(this.anchor=e.defaultAnchor),this.texture=e,this.allowChildren=!1,this.roundPixels=n??!1,o!==void 0&&(this.width=o),r!==void 0&&(this.height=r)}static from(t,e=!1){return t instanceof $t?new Yi(t):new Yi($t.from(t,e))}set texture(t){t||(t=$t.EMPTY);const e=this._texture;e!==t&&(e&&e.dynamic&&e.off("update",this.onViewUpdate,this),t.dynamic&&t.on("update",this.onViewUpdate,this),this._texture=t,this._width&&this._setWidth(this._width,this._texture.orig.width),this._height&&this._setHeight(this._height,this._texture.orig.height),this.onViewUpdate())}get texture(){return this._texture}get visualBounds(){return id(this._visualBounds,this._anchor,this._texture),this._visualBounds}get sourceBounds(){return Ct("8.6.1","Sprite.sourceBounds is deprecated, use visualBounds instead."),this.visualBounds}updateBounds(){const t=this._anchor,e=this._texture,s=this._bounds,{width:n,height:o}=e.orig;s.minX=-t._x*n,s.maxX=s.minX+n,s.minY=-t._y*o,s.maxY=s.minY+o}destroy(t=!1){if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const s=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(s)}this._texture=null,this._visualBounds=null,this._bounds=null,this._anchor=null}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(t){this._setWidth(t,this._texture.orig.width),this._width=t}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(t){this._setHeight(t,this._texture.orig.height),this._height=t}getSize(t){return t||(t={}),t.width=Math.abs(this.scale.x)*this._texture.orig.width,t.height=Math.abs(this.scale.y)*this._texture.orig.height,t}setSize(t,e){typeof t=="object"?(e=t.height??t.width,t=t.width):e??(e=t),t!==void 0&&this._setWidth(t,this._texture.orig.width),e!==void 0&&this._setHeight(e,this._texture.orig.height)}}const $f=new Ne;function fd(i,t,e){const s=$f;i.measurable=!0,ad(i,e,s),t.addBoundsMask(s),i.measurable=!1}function pd(i,t,e){const s=ys.get();i.measurable=!0;const n=_e.get().identity(),o=md(i,e,n);cd(i,s,o),i.measurable=!1,t.addBoundsMask(s),_e.return(n),ys.return(s)}function md(i,t,e){return i?(i!==t&&(md(i.parent,t,e),i.updateLocalTransform(),e.append(i.localTransform)),e):(xe("Mask bounds, renderable is not inside the root container"),e)}class gd{constructor(t){this.priority=0,this.inverse=!1,this.pipe="alphaMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t,this.renderMaskToTexture=!(t instanceof Yi),this.mask.renderable=this.renderMaskToTexture,this.mask.includeInBuild=!this.renderMaskToTexture,this.mask.measurable=!1}reset(){this.mask!==null&&(this.mask.measurable=!0,this.mask=null)}addBounds(t,e){this.inverse||fd(this.mask,t,e)}addLocalBounds(t,e){pd(this.mask,t,e)}containsPoint(t,e){const s=this.mask;return e(s,t)}destroy(){this.reset()}static test(t){return t instanceof Yi}}gd.extension=yt.MaskEffect;class yd{constructor(t){this.priority=0,this.pipe="colorMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t}destroy(){}static test(t){return typeof t=="number"}}yd.extension=yt.MaskEffect;class bd{constructor(t){this.priority=0,this.pipe="stencilMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t,this.mask.includeInBuild=!1,this.mask.measurable=!1}reset(){this.mask!==null&&(this.mask.measurable=!0,this.mask.includeInBuild=!0,this.mask=null)}addBounds(t,e){fd(this.mask,t,e)}addLocalBounds(t,e){pd(this.mask,t,e)}containsPoint(t,e){const s=this.mask;return e(s,t)}destroy(){this.reset()}static test(t){return t instanceof Ft}}bd.extension=yt.MaskEffect;const Df={createCanvas:(i,t)=>{const e=document.createElement("canvas");return e.width=i,e.height=t,e},createImage:()=>new Image,getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(i,t)=>fetch(i,t),parseXML:i=>new DOMParser().parseFromString(i,"text/xml")};let Ql=Df;const Pe={get(){return Ql},set(i){Ql=i}};class _d extends Ge{constructor(t){t.resource||(t.resource=Pe.get().createCanvas()),t.width||(t.width=t.resource.width,t.autoDensity||(t.width/=t.resolution)),t.height||(t.height=t.resource.height,t.autoDensity||(t.height/=t.resolution)),super(t),this.uploadMethodId="image",this.autoDensity=t.autoDensity,this.resizeCanvas(),this.transparent=!!t.transparent}resizeCanvas(){this.autoDensity&&"style"in this.resource&&(this.resource.style.width=`${this.width}px`,this.resource.style.height=`${this.height}px`),(this.resource.width!==this.pixelWidth||this.resource.height!==this.pixelHeight)&&(this.resource.width=this.pixelWidth,this.resource.height=this.pixelHeight)}resize(t=this.width,e=this.height,s=this._resolution){const n=super.resize(t,e,s);return n&&this.resizeCanvas(),n}static test(t){return globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement||globalThis.OffscreenCanvas&&t instanceof OffscreenCanvas}get context2D(){return this._context2D||(this._context2D=this.resource.getContext("2d"))}}_d.extension=yt.TextureSource;class or extends Ge{constructor(t){super(t),this.uploadMethodId="image",this.autoGarbageCollect=!0}static test(t){return globalThis.HTMLImageElement&&t instanceof HTMLImageElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap||globalThis.VideoFrame&&t instanceof VideoFrame}}or.extension=yt.TextureSource;var rr=(i=>(i[i.INTERACTION=50]="INTERACTION",i[i.HIGH=25]="HIGH",i[i.NORMAL=0]="NORMAL",i[i.LOW=-25]="LOW",i[i.UTILITY=-50]="UTILITY",i))(rr||{});class Br{constructor(t,e=null,s=0,n=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=t,this._context=e,this.priority=s,this._once=n}match(t,e=null){return this._fn===t&&this._context===e}emit(t){this._fn&&(this._context?this._fn.call(this._context,t):this._fn(t));const e=this.next;return this._once&&this.destroy(!0),this._destroyed&&(this.next=null),e}connect(t){this.previous=t,t.next&&(t.next.previous=this),this.next=t.next,t.next=this}destroy(t=!1){this._destroyed=!0,this._fn=null,this._context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);const e=this.next;return this.next=t?null:e,this.previous=null,e}}const xd=class Ee{constructor(){this.autoStart=!1,this.deltaTime=1,this.lastTime=-1,this.speed=1,this.started=!1,this._requestId=null,this._maxElapsedMS=100,this._minElapsedMS=0,this._protected=!1,this._lastFrame=-1,this._head=new Br(null,null,1/0),this.deltaMS=1/Ee.targetFPMS,this.elapsedMS=1/Ee.targetFPMS,this._tick=t=>{this._requestId=null,this.started&&(this.update(t),this.started&&this._requestId===null&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(t,e,s=rr.NORMAL){return this._addListener(new Br(t,e,s))}addOnce(t,e,s=rr.NORMAL){return this._addListener(new Br(t,e,s,!0))}_addListener(t){let e=this._head.next,s=this._head;if(!e)t.connect(s);else{for(;e;){if(t.priority>e.priority){t.connect(s);break}s=e,e=e.next}t.previous||t.connect(s)}return this._startIfPossible(),this}remove(t,e){let s=this._head.next;for(;s;)s.match(t,e)?s=s.destroy():s=s.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let t=0,e=this._head;for(;e=e.next;)t++;return t}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let t=this._head.next;for(;t;)t=t.destroy(!0);this._head.destroy(),this._head=null}}update(t=performance.now()){let e;if(t>this.lastTime){if(e=this.elapsedMS=t-this.lastTime,e>this._maxElapsedMS&&(e=this._maxElapsedMS),e*=this.speed,this._minElapsedMS){const o=t-this._lastFrame|0;if(o<this._minElapsedMS)return;this._lastFrame=t-o%this._minElapsedMS}this.deltaMS=e,this.deltaTime=this.deltaMS*Ee.targetFPMS;const s=this._head;let n=s.next;for(;n;)n=n.emit(this);s.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=t}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(t){const e=Math.min(Math.max(0,t)/1e3,Ee.targetFPMS);this._maxElapsedMS=1/e,this._minElapsedMS&&t>this.maxFPS&&(this.maxFPS=t)}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(t){t===0?this._minElapsedMS=0:(t<this.minFPS&&(this.minFPS=t),this._minElapsedMS=1/(t/1e3))}static get shared(){if(!Ee._shared){const t=Ee._shared=new Ee;t.autoStart=!0,t._protected=!0}return Ee._shared}static get system(){if(!Ee._system){const t=Ee._system=new Ee;t.autoStart=!0,t._protected=!0}return Ee._system}};xd.targetFPMS=.06;let un=xd,Rr;async function zf(){return Rr??(Rr=(async()=>{var r;const t=Pe.get().createCanvas(1,1).getContext("webgl");if(!t)return"premultiply-alpha-on-upload";const e=await new Promise(l=>{const h=document.createElement("video");h.onloadeddata=()=>l(h),h.onerror=()=>l(null),h.autoplay=!1,h.crossOrigin="anonymous",h.preload="auto",h.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",h.load()});if(!e)return"premultiply-alpha-on-upload";const s=t.createTexture();t.bindTexture(t.TEXTURE_2D,s);const n=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,n),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,s,0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,t.NONE),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e);const o=new Uint8Array(4);return t.readPixels(0,0,1,1,t.RGBA,t.UNSIGNED_BYTE,o),t.deleteFramebuffer(n),t.deleteTexture(s),(r=t.getExtension("WEBGL_lose_context"))==null||r.loseContext(),o[0]<=o[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),Rr}const br=class vd extends Ge{constructor(t){super(t),this.isReady=!1,this.uploadMethodId="video",t={...vd.defaultOptions,...t},this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=t.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=t.autoPlay!==!1,this.alphaMode=t.alphaMode??"premultiply-alpha-on-upload",this._videoFrameRequestCallback=this._videoFrameRequestCallback.bind(this),this._videoFrameRequestCallbackHandle=null,this._load=null,this._resolve=null,this._reject=null,this._onCanPlay=this._onCanPlay.bind(this),this._onCanPlayThrough=this._onCanPlayThrough.bind(this),this._onError=this._onError.bind(this),this._onPlayStart=this._onPlayStart.bind(this),this._onPlayStop=this._onPlayStop.bind(this),this._onSeeked=this._onSeeked.bind(this),t.autoLoad!==!1&&this.load()}updateFrame(){if(!this.destroyed){if(this._updateFPS){const t=un.shared.elapsedMS*this.resource.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-t)}(!this._updateFPS||this._msToNextUpdate<=0)&&(this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0),this.isValid&&this.update()}}_videoFrameRequestCallback(){this.updateFrame(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback)}get isValid(){return!!this.resource.videoWidth&&!!this.resource.videoHeight}async load(){if(this._load)return this._load;const t=this.resource,e=this.options;return(t.readyState===t.HAVE_ENOUGH_DATA||t.readyState===t.HAVE_FUTURE_DATA)&&t.width&&t.height&&(t.complete=!0),t.addEventListener("play",this._onPlayStart),t.addEventListener("pause",this._onPlayStop),t.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._mediaReady():(e.preload||t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlayThrough),t.addEventListener("error",this._onError,!0)),this.alphaMode=await zf(),this._load=new Promise((s,n)=>{this.isValid?s(this):(this._resolve=s,this._reject=n,e.preloadTimeoutMs!==void 0&&(this._preloadTimeout=setTimeout(()=>{this._onError(new ErrorEvent(`Preload exceeded timeout of ${e.preloadTimeoutMs}ms`))})),t.load())}),this._load}_onError(t){this.resource.removeEventListener("error",this._onError,!0),this.emit("error",t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null)}_isSourcePlaying(){const t=this.resource;return!t.paused&&!t.ended}_isSourceReady(){return this.resource.readyState>2}_onPlayStart(){this.isValid||this._mediaReady(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0)}_onCanPlay(){this.resource.removeEventListener("canplay",this._onCanPlay),this._mediaReady()}_onCanPlayThrough(){this.resource.removeEventListener("canplaythrough",this._onCanPlay),this._preloadTimeout&&(clearTimeout(this._preloadTimeout),this._preloadTimeout=void 0),this._mediaReady()}_mediaReady(){const t=this.resource;this.isValid&&(this.isReady=!0,this.resize(t.videoWidth,t.videoHeight)),this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0,this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&this.resource.play()}destroy(){this._configureAutoUpdate();const t=this.resource;t&&(t.removeEventListener("play",this._onPlayStart),t.removeEventListener("pause",this._onPlayStop),t.removeEventListener("seeked",this._onSeeked),t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlayThrough),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load()),super.destroy()}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(t){t!==this._updateFPS&&(this._updateFPS=t,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.resource.requestVideoFrameCallback?(this._isConnectedToTicker&&(un.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),this._videoFrameRequestCallbackHandle===null&&(this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||(un.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(un.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement}};br.extension=yt.TextureSource;br.defaultOptions={...Ge.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1};br.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let Ff=br;const ln=(i,t,e=!1)=>(Array.isArray(i)||(i=[i]),t?i.map(s=>typeof s=="string"||e?t(s):s):i);class Nf{constructor(){this._parsers=[],this._cache=new Map,this._cacheMap=new Map}reset(){this._cacheMap.clear(),this._cache.clear()}has(t){return this._cache.has(t)}get(t){const e=this._cache.get(t);return e||xe(`[Assets] Asset id ${t} was not found in the Cache`),e}set(t,e){const s=ln(t);let n;for(let h=0;h<this.parsers.length;h++){const d=this.parsers[h];if(d.test(e)){n=d.getCacheableAssets(s,e);break}}const o=new Map(Object.entries(n||{}));n||s.forEach(h=>{o.set(h,e)});const r=[...o.keys()],l={cacheKeys:r,keys:s};s.forEach(h=>{this._cacheMap.set(h,l)}),r.forEach(h=>{const d=n?n[h]:e;this._cache.has(h)&&this._cache.get(h)!==d&&xe("[Cache] already has key:",h),this._cache.set(h,o.get(h))})}remove(t){if(!this._cacheMap.has(t)){xe(`[Assets] Asset id ${t} was not found in the Cache`);return}const e=this._cacheMap.get(t);e.cacheKeys.forEach(n=>{this._cache.delete(n)}),e.keys.forEach(n=>{this._cacheMap.delete(n)})}get parsers(){return this._parsers}}const hn=new Nf,Ra=[];jt.handleByList(yt.TextureSource,Ra);function wd(i={}){const t=i&&i.resource,e=t?i.resource:i,s=t?i:{resource:i};for(let n=0;n<Ra.length;n++){const o=Ra[n];if(o.test(e))return new o(s)}throw new Error(`Could not find a source type for resource: ${s.resource}`)}function Gf(i={},t=!1){const e=i&&i.resource,s=e?i.resource:i,n=e?i:{resource:i};if(!t&&hn.has(s))return hn.get(s);const o=new $t({source:wd(n)});return o.on("destroy",()=>{hn.has(s)&&hn.remove(s)}),t||hn.set(s,o),o}function Wf(i,t=!1){return typeof i=="string"?hn.get(i):i instanceof Ge?new $t({source:i}):Gf(i,t)}$t.from=Wf;Ge.from=wd;jt.add(gd,yd,bd,Ff,or,_d,fl);var Sd=(i=>(i[i.Low=0]="Low",i[i.Normal=1]="Normal",i[i.High=2]="High",i))(Sd||{});function He(i){if(typeof i!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(i)}`)}function Tn(i){return i.split("?")[0].split("#")[0]}function Of(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Hf(i,t,e){return i.replace(new RegExp(Of(t),"g"),e)}function Uf(i,t){let e="",s=0,n=-1,o=0,r=-1;for(let l=0;l<=i.length;++l){if(l<i.length)r=i.charCodeAt(l);else{if(r===47)break;r=47}if(r===47){if(!(n===l-1||o===1))if(n!==l-1&&o===2){if(e.length<2||s!==2||e.charCodeAt(e.length-1)!==46||e.charCodeAt(e.length-2)!==46){if(e.length>2){const h=e.lastIndexOf("/");if(h!==e.length-1){h===-1?(e="",s=0):(e=e.slice(0,h),s=e.length-1-e.lastIndexOf("/")),n=l,o=0;continue}}else if(e.length===2||e.length===1){e="",s=0,n=l,o=0;continue}}}else e.length>0?e+=`/${i.slice(n+1,l)}`:e=i.slice(n+1,l),s=l-n-1;n=l,o=0}else r===46&&o!==-1?++o:o=-1}return e}const io={toPosix(i){return Hf(i,"\\","/")},isUrl(i){return/^https?:/.test(this.toPosix(i))},isDataUrl(i){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(i)},isBlobUrl(i){return i.startsWith("blob:")},hasProtocol(i){return/^[^/:]+:/.test(this.toPosix(i))},getProtocol(i){He(i),i=this.toPosix(i);const t=/^file:\/\/\//.exec(i);if(t)return t[0];const e=/^[^/:]+:\/{0,2}/.exec(i);return e?e[0]:""},toAbsolute(i,t,e){if(He(i),this.isDataUrl(i)||this.isBlobUrl(i))return i;const s=Tn(this.toPosix(t??Pe.get().getBaseUrl())),n=Tn(this.toPosix(e??this.rootname(s)));return i=this.toPosix(i),i.startsWith("/")?io.join(n,i.slice(1)):this.isAbsolute(i)?i:this.join(s,i)},normalize(i){if(He(i),i.length===0)return".";if(this.isDataUrl(i)||this.isBlobUrl(i))return i;i=this.toPosix(i);let t="";const e=i.startsWith("/");this.hasProtocol(i)&&(t=this.rootname(i),i=i.slice(t.length));const s=i.endsWith("/");return i=Uf(i),i.length>0&&s&&(i+="/"),e?`/${i}`:t+i},isAbsolute(i){return He(i),i=this.toPosix(i),this.hasProtocol(i)?!0:i.startsWith("/")},join(...i){if(i.length===0)return".";let t;for(let e=0;e<i.length;++e){const s=i[e];if(He(s),s.length>0)if(t===void 0)t=s;else{const n=i[e-1]??"";this.joinExtensions.includes(this.extname(n).toLowerCase())?t+=`/../${s}`:t+=`/${s}`}}return t===void 0?".":this.normalize(t)},dirname(i){if(He(i),i.length===0)return".";i=this.toPosix(i);let t=i.charCodeAt(0);const e=t===47;let s=-1,n=!0;const o=this.getProtocol(i),r=i;i=i.slice(o.length);for(let l=i.length-1;l>=1;--l)if(t=i.charCodeAt(l),t===47){if(!n){s=l;break}}else n=!1;return s===-1?e?"/":this.isUrl(r)?o+i:o:e&&s===1?"//":o+i.slice(0,s)},rootname(i){He(i),i=this.toPosix(i);let t="";if(i.startsWith("/")?t="/":t=this.getProtocol(i),this.isUrl(i)){const e=i.indexOf("/",t.length);e!==-1?t=i.slice(0,e):t=i,t.endsWith("/")||(t+="/")}return t},basename(i,t){He(i),t&&He(t),i=Tn(this.toPosix(i));let e=0,s=-1,n=!0,o;if(t!==void 0&&t.length>0&&t.length<=i.length){if(t.length===i.length&&t===i)return"";let r=t.length-1,l=-1;for(o=i.length-1;o>=0;--o){const h=i.charCodeAt(o);if(h===47){if(!n){e=o+1;break}}else l===-1&&(n=!1,l=o+1),r>=0&&(h===t.charCodeAt(r)?--r===-1&&(s=o):(r=-1,s=l))}return e===s?s=l:s===-1&&(s=i.length),i.slice(e,s)}for(o=i.length-1;o>=0;--o)if(i.charCodeAt(o)===47){if(!n){e=o+1;break}}else s===-1&&(n=!1,s=o+1);return s===-1?"":i.slice(e,s)},extname(i){He(i),i=Tn(this.toPosix(i));let t=-1,e=0,s=-1,n=!0,o=0;for(let r=i.length-1;r>=0;--r){const l=i.charCodeAt(r);if(l===47){if(!n){e=r+1;break}continue}s===-1&&(n=!1,s=r+1),l===46?t===-1?t=r:o!==1&&(o=1):t!==-1&&(o=-1)}return t===-1||s===-1||o===0||o===1&&t===s-1&&t===e+1?"":i.slice(t,s)},parse(i){He(i);const t={root:"",dir:"",base:"",ext:"",name:""};if(i.length===0)return t;i=Tn(this.toPosix(i));let e=i.charCodeAt(0);const s=this.isAbsolute(i);let n;t.root=this.rootname(i),s||this.hasProtocol(i)?n=1:n=0;let o=-1,r=0,l=-1,h=!0,d=i.length-1,c=0;for(;d>=n;--d){if(e=i.charCodeAt(d),e===47){if(!h){r=d+1;break}continue}l===-1&&(h=!1,l=d+1),e===46?o===-1?o=d:c!==1&&(c=1):o!==-1&&(c=-1)}return o===-1||l===-1||c===0||c===1&&o===l-1&&o===r+1?l!==-1&&(r===0&&s?t.base=t.name=i.slice(1,l):t.base=t.name=i.slice(r,l)):(r===0&&s?(t.name=i.slice(1,o),t.base=i.slice(1,l)):(t.name=i.slice(r,o),t.base=i.slice(r,l)),t.ext=i.slice(o,l)),t.dir=this.dirname(i),t},sep:"/",delimiter:":",joinExtensions:[".html"]};function kd(i,t,e,s,n){const o=t[e];for(let r=0;r<o.length;r++){const l=o[r];e<t.length-1?kd(i.replace(s[e],l),t,e+1,s,n):n.push(i.replace(s[e],l))}}function qf(i){const t=/\{(.*?)\}/g,e=i.match(t),s=[];if(e){const n=[];e.forEach(o=>{const r=o.substring(1,o.length-1).split(",");n.push(r)}),kd(i,n,0,e,s)}else s.push(i);return s}const Jl=i=>!Array.isArray(i);class Td{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(t,e)=>`${t}${this._bundleIdConnector}${e}`,extractAssetIdFromBundle:(t,e)=>e.replace(`${t}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(t){if(this._bundleIdConnector=t.connector??this._bundleIdConnector,this._createBundleAssetId=t.createBundleAssetId??this._createBundleAssetId,this._extractAssetIdFromBundle=t.extractAssetIdFromBundle??this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...t){t.forEach(e=>{this._preferredOrder.push(e),e.priority||(e.priority=Object.keys(e.params))}),this._resolverHash={}}set basePath(t){this._basePath=t}get basePath(){return this._basePath}set rootPath(t){this._rootPath=t}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(t){if(typeof t=="string")this._defaultSearchParams=t;else{const e=t;this._defaultSearchParams=Object.keys(e).map(s=>`${encodeURIComponent(s)}=${encodeURIComponent(e[s])}`).join("&")}}getAlias(t){const{alias:e,src:s}=t;return ln(e||s,o=>typeof o=="string"?o:Array.isArray(o)?o.map(r=>(r==null?void 0:r.src)??r):o!=null&&o.src?o.src:o,!0)}removeAlias(t,e){this._assetMap[t]&&(e&&e!==this._resolverHash[t]||(delete this._resolverHash[t],delete this._assetMap[t]))}addManifest(t){this._manifest&&xe("[Resolver] Manifest already exists, this will be overwritten"),this._manifest=t,t.bundles.forEach(e=>{this.addBundle(e.name,e.assets)})}addBundle(t,e){const s=[];let n=e;Array.isArray(e)||(n=Object.entries(e).map(([o,r])=>typeof r=="string"||Array.isArray(r)?{alias:o,src:r}:{alias:o,...r})),n.forEach(o=>{const r=o.src,l=o.alias;let h;if(typeof l=="string"){const d=this._createBundleAssetId(t,l);s.push(d),h=[l,d]}else{const d=l.map(c=>this._createBundleAssetId(t,c));s.push(...d),h=[...l,...d]}this.add({...o,alias:h,src:r})}),this._bundles[t]=s}add(t){const e=[];Array.isArray(t)?e.push(...t):e.push(t);let s;s=o=>{this.hasKey(o)&&xe(`[Resolver] already has key: ${o} overwriting`)},ln(e).forEach(o=>{const{src:r}=o;let{data:l,format:h,loadParser:d,parser:c}=o;const p=ln(r).map(x=>typeof x=="string"?qf(x):Array.isArray(x)?x:[x]),g=this.getAlias(o);Array.isArray(g)?g.forEach(s):s(g);const m=[],y=x=>{const w=this._parsers.find(k=>k.test(x));return{src:x,...w==null?void 0:w.parse(x)}};p.forEach(x=>{x.forEach(w=>{let k={};if(typeof w!="object"?k=y(w):(l=w.data??l,h=w.format??h,(w.loadParser||w.parser)&&(d=w.loadParser??d,c=w.parser??c),k={...y(w.src),...w}),!g)throw new Error(`[Resolver] alias is undefined for this asset: ${k.src}`);k=this._buildResolvedAsset(k,{aliases:g,data:l,format:h,loadParser:d,parser:c,progressSize:o.progressSize}),m.push(k)})}),g.forEach(x=>{this._assetMap[x]=m})})}resolveBundle(t){const e=Jl(t);t=ln(t);const s={};return t.forEach(n=>{const o=this._bundles[n];if(o){const r=this.resolve(o),l={};for(const h in r){const d=r[h];l[this._extractAssetIdFromBundle(n,h)]=d}s[n]=l}}),e?s[t[0]]:s}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const s={};for(const n in e)s[n]=e[n].src;return s}return e.src}resolve(t){const e=Jl(t);t=ln(t);const s={};return t.forEach(n=>{if(!this._resolverHash[n])if(this._assetMap[n]){let o=this._assetMap[n];const r=this._getPreferredOrder(o);r==null||r.priority.forEach(l=>{r.params[l].forEach(h=>{const d=o.filter(c=>c[l]?c[l]===h:!1);d.length&&(o=d)})}),this._resolverHash[n]=o[0]}else this._resolverHash[n]=this._buildResolvedAsset({alias:[n],src:n},{});s[n]=this._resolverHash[n]}),e?s[t[0]]:s}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let e=0;e<t.length;e++){const s=t[e],n=this._preferredOrder.find(o=>o.params.format.includes(s.format));if(n)return n}return this._preferredOrder[0]}_appendDefaultSearchParams(t){if(!this._defaultSearchParams)return t;const e=/\?/.test(t)?"&":"?";return`${t}${e}${this._defaultSearchParams}`}_buildResolvedAsset(t,e){const{aliases:s,data:n,loadParser:o,parser:r,format:l,progressSize:h}=e;return(this._basePath||this._rootPath)&&(t.src=io.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=s??t.alias??[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data={...n||{},...t.data},t.loadParser=o??t.loadParser,t.parser=r??t.parser,t.format=l??t.format??Vf(t.src),h!==void 0&&(t.progressSize=h),t}}Td.RETINA_PREFIX=/@([0-9\.]+)x/;function Vf(i){return i.split(".").pop().split("?").shift().split("#").shift()}const th=(i,t)=>{const e=t.split("?")[1];return e&&(i+=`?${e}`),i},Cd=class Xn{constructor(t,e){this.linkedSheets=[];let s=t;(t==null?void 0:t.source)instanceof Ge&&(s={texture:t,data:e});const{texture:n,data:o,cachePrefix:r=""}=s;this.cachePrefix=r,this._texture=n instanceof $t?n:null,this.textureSource=n.source,this.textures={},this.animations={},this.data=o;const l=parseFloat(o.meta.scale);l?(this.resolution=l,n.source.resolution=this.resolution):this.resolution=n.source._resolution,this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}parse(){return new Promise(t=>{this._callback=t,this._batchIndex=0,this._frameKeys.length<=Xn.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}parseSync(){return this._processFrames(0,!0),this._processAnimations(),this.textures}_processFrames(t,e=!1){let s=t;const n=e?1/0:Xn.BATCH_SIZE;for(;s-t<n&&s<this._frameKeys.length;){const o=this._frameKeys[s],r=this._frames[o],l=r.frame;if(l){let h=null,d=null;const c=r.trimmed!==!1&&r.sourceSize?r.sourceSize:r.frame,p=new Yt(0,0,Math.floor(c.w)/this.resolution,Math.floor(c.h)/this.resolution);r.rotated?h=new Yt(Math.floor(l.x)/this.resolution,Math.floor(l.y)/this.resolution,Math.floor(l.h)/this.resolution,Math.floor(l.w)/this.resolution):h=new Yt(Math.floor(l.x)/this.resolution,Math.floor(l.y)/this.resolution,Math.floor(l.w)/this.resolution,Math.floor(l.h)/this.resolution),r.trimmed!==!1&&r.spriteSourceSize&&(d=new Yt(Math.floor(r.spriteSourceSize.x)/this.resolution,Math.floor(r.spriteSourceSize.y)/this.resolution,Math.floor(l.w)/this.resolution,Math.floor(l.h)/this.resolution)),this.textures[o]=new $t({source:this.textureSource,frame:h,orig:p,trim:d,rotate:r.rotated?2:0,defaultAnchor:r.anchor,defaultBorders:r.borders,label:o.toString()})}s++}}_processAnimations(){const t=this.data.animations||{};for(const e in t){this.animations[e]=[];for(let s=0;s<t[e].length;s++){const n=t[e][s];this.animations[e].push(this.textures[n])}}}_parseComplete(){const t=this._callback;this._callback=null,this._batchIndex=0,t.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*Xn.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*Xn.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(t=!1){var e;for(const s in this.textures)this.textures[s].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,t&&((e=this._texture)==null||e.destroy(),this.textureSource.destroy()),this._texture=null,this.textureSource=null,this.linkedSheets=[]}};Cd.BATCH_SIZE=1e3;let eh=Cd;const Yf=["jpg","png","jpeg","avif","webp","basis","etc2","bc7","bc6h","bc5","bc4","bc3","bc2","bc1","eac","astc"];function Ad(i,t,e){const s={};if(i.forEach(n=>{s[n]=t}),Object.keys(t.textures).forEach(n=>{s[`${t.cachePrefix}${n}`]=t.textures[n]}),!e){const n=io.dirname(i[0]);t.linkedSheets.forEach((o,r)=>{const l=Ad([`${n}/${t.data.meta.related_multi_packs[r]}`],o,!0);Object.assign(s,l)})}return s}const jf={extension:yt.Asset,cache:{test:i=>i instanceof eh,getCacheableAssets:(i,t)=>Ad(i,t,!1)},resolver:{extension:{type:yt.ResolveParser,name:"resolveSpritesheet"},test:i=>{const e=i.split("?")[0].split("."),s=e.pop(),n=e.pop();return s==="json"&&Yf.includes(n)},parse:i=>{var e;const t=i.split(".");return{resolution:parseFloat(((e=Td.RETINA_PREFIX.exec(i))==null?void 0:e[1])??"1"),format:t[t.length-2],src:i}}},loader:{name:"spritesheetLoader",id:"spritesheet",extension:{type:yt.LoadParser,priority:Sd.Normal,name:"spritesheetLoader"},async testParse(i,t){return io.extname(t.src).toLowerCase()===".json"&&!!i.frames},async parse(i,t,e){var p,g;const{texture:s,imageFilename:n,textureOptions:o,cachePrefix:r}=(t==null?void 0:t.data)??{};let l=io.dirname(t.src);l&&l.lastIndexOf("/")!==l.length-1&&(l+="/");let h;if(s instanceof $t)h=s;else{const m=th(l+(n??i.meta.image),t.src);h=(await e.load([{src:m,data:o}]))[m]}const d=new eh({texture:h.source,data:i,cachePrefix:r});await d.parse();const c=(p=i==null?void 0:i.meta)==null?void 0:p.related_multi_packs;if(Array.isArray(c)){const m=[];for(const x of c){if(typeof x!="string")continue;let w=l+x;(g=t.data)!=null&&g.ignoreMultiPack||(w=th(w,t.src),m.push(e.load({src:w,data:{textureOptions:o,ignoreMultiPack:!0}})))}const y=await Promise.all(m);d.linkedSheets=y,y.forEach(x=>{x.linkedSheets=[d].concat(d.linkedSheets.filter(w=>w!==x))})}return d},async unload(i,t,e){await e.unload(i.textureSource._sourceOrigin),i.destroy(!1)}}};jt.add(jf);const $r=Object.create(null),sh=Object.create(null);function yl(i,t){let e=sh[i];return e===void 0&&($r[t]===void 0&&($r[t]=1),sh[i]=e=$r[t]++),e}let Ki;function Md(){return(!Ki||Ki!=null&&Ki.isContextLost())&&(Ki=Pe.get().createCanvas().getContext("webgl",{})),Ki}let vo;function Xf(){if(!vo){vo="mediump";const i=Md();i&&i.getShaderPrecisionFormat&&(vo=i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision?"highp":"mediump")}return vo}function Zf(i,t,e){return t?i:e?(i=i.replace("out vec4 finalColor;",""),`
6
-
7
- #ifdef GL_ES // This checks if it is WebGL1
8
- #define in varying
9
- #define finalColor gl_FragColor
10
- #define texture texture2D
11
- #endif
12
- ${i}
13
- `):`
14
-
15
- #ifdef GL_ES // This checks if it is WebGL1
16
- #define in attribute
17
- #define out varying
18
- #endif
19
- ${i}
20
- `}function Kf(i,t,e){const s=e?t.maxSupportedFragmentPrecision:t.maxSupportedVertexPrecision;if(i.substring(0,9)!=="precision"){let n=e?t.requestedFragmentPrecision:t.requestedVertexPrecision;return n==="highp"&&s!=="highp"&&(n="mediump"),`precision ${n} float;
21
- ${i}`}else if(s!=="highp"&&i.substring(0,15)==="precision highp")return i.replace("precision highp","precision mediump");return i}function Qf(i,t){return t?`#version 300 es
22
- ${i}`:i}const Jf={},tp={};function ep(i,{name:t="pixi-program"},e=!0){t=t.replace(/\s+/g,"-"),t+=e?"-fragment":"-vertex";const s=e?Jf:tp;return s[t]?(s[t]++,t+=`-${s[t]}`):s[t]=1,i.indexOf("#define SHADER_NAME")!==-1?i:`${`#define SHADER_NAME ${t}`}
23
- ${i}`}function sp(i,t){return t?i.replace("#version 300 es",""):i}const Dr={stripVersion:sp,ensurePrecision:Kf,addProgramDefines:Zf,setProgramName:ep,insertVersion:Qf},Cn=Object.create(null),Ed=class $a{constructor(t){t={...$a.defaultOptions,...t};const e=t.fragment.indexOf("#version 300 es")!==-1,s={stripVersion:e,ensurePrecision:{requestedFragmentPrecision:t.preferredFragmentPrecision,requestedVertexPrecision:t.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:Xf()},setProgramName:{name:t.name},addProgramDefines:e,insertVersion:e};let n=t.fragment,o=t.vertex;Object.keys(Dr).forEach(r=>{const l=s[r];n=Dr[r](n,l,!0),o=Dr[r](o,l,!1)}),this.fragment=n,this.vertex=o,this.transformFeedbackVaryings=t.transformFeedbackVaryings,this._key=yl(`${this.vertex}:${this.fragment}`,"gl-program")}destroy(){this.fragment=null,this.vertex=null,this._attributeData=null,this._uniformData=null,this._uniformBlockData=null,this.transformFeedbackVaryings=null,Cn[this._cacheKey]=null}static from(t){const e=`${t.vertex}:${t.fragment}`;return Cn[e]||(Cn[e]=new $a(t),Cn[e]._cacheKey=e),Cn[e]}};Ed.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let Pd=Ed;const ih={uint8x2:{size:2,stride:2,normalised:!1},uint8x4:{size:4,stride:4,normalised:!1},sint8x2:{size:2,stride:2,normalised:!1},sint8x4:{size:4,stride:4,normalised:!1},unorm8x2:{size:2,stride:2,normalised:!0},unorm8x4:{size:4,stride:4,normalised:!0},snorm8x2:{size:2,stride:2,normalised:!0},snorm8x4:{size:4,stride:4,normalised:!0},uint16x2:{size:2,stride:4,normalised:!1},uint16x4:{size:4,stride:8,normalised:!1},sint16x2:{size:2,stride:4,normalised:!1},sint16x4:{size:4,stride:8,normalised:!1},unorm16x2:{size:2,stride:4,normalised:!0},unorm16x4:{size:4,stride:8,normalised:!0},snorm16x2:{size:2,stride:4,normalised:!0},snorm16x4:{size:4,stride:8,normalised:!0},float16x2:{size:2,stride:4,normalised:!1},float16x4:{size:4,stride:8,normalised:!1},float32:{size:1,stride:4,normalised:!1},float32x2:{size:2,stride:8,normalised:!1},float32x3:{size:3,stride:12,normalised:!1},float32x4:{size:4,stride:16,normalised:!1},uint32:{size:1,stride:4,normalised:!1},uint32x2:{size:2,stride:8,normalised:!1},uint32x3:{size:3,stride:12,normalised:!1},uint32x4:{size:4,stride:16,normalised:!1},sint32:{size:1,stride:4,normalised:!1},sint32x2:{size:2,stride:8,normalised:!1},sint32x3:{size:3,stride:12,normalised:!1},sint32x4:{size:4,stride:16,normalised:!1}};function ip(i){return ih[i]??ih.float32}const np={f32:"float32","vec2<f32>":"float32x2","vec3<f32>":"float32x3","vec4<f32>":"float32x4",vec2f:"float32x2",vec3f:"float32x3",vec4f:"float32x4",i32:"sint32","vec2<i32>":"sint32x2","vec3<i32>":"sint32x3","vec4<i32>":"sint32x4",vec2i:"sint32x2",vec3i:"sint32x3",vec4i:"sint32x4",u32:"uint32","vec2<u32>":"uint32x2","vec3<u32>":"uint32x3","vec4<u32>":"uint32x4",vec2u:"uint32x2",vec3u:"uint32x3",vec4u:"uint32x4",bool:"uint32","vec2<bool>":"uint32x2","vec3<bool>":"uint32x3","vec4<bool>":"uint32x4"},nh=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|\)|$)/g;function oh(i,t){let e;for(;(e=nh.exec(i))!==null;){const s=np[e[3]]??"float32";t[e[2]]={location:parseInt(e[1],10),format:s,stride:ip(s).stride,offset:0,instance:!1,start:0}}nh.lastIndex=0}function op(i){return i.replace(/\/\/.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,"")}function rp({source:i,entryPoint:t}){const e={},s=op(i),n=s.indexOf(`fn ${t}(`);if(n===-1)return e;const o=s.indexOf("->",n);if(o===-1)return e;const r=s.substring(n,o);if(oh(r,e),Object.keys(e).length===0){const l=r.match(/\(\s*\w+\s*:\s*(\w+)/);if(l){const h=l[1],d=new RegExp(`struct\\s+${h}\\s*\\{([^}]+)\\}`,"s"),c=s.match(d);c&&oh(c[1],e)}}return e}function zr(i){var p,g;const t=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,e=/@group\((\d+)\)/,s=/@binding\((\d+)\)/,n=/var(<[^>]+>)? (\w+)/,o=/:\s*([\w<>]+)/,r=/struct\s+(\w+)\s*{([^}]+)}/g,l=/(\w+)\s*:\s*([\w\<\>]+)/g,h=/struct\s+(\w+)/,d=(p=i.match(t))==null?void 0:p.map(m=>({group:parseInt(m.match(e)[1],10),binding:parseInt(m.match(s)[1],10),name:m.match(n)[2],isUniform:m.match(n)[1]==="<uniform>",type:m.match(o)[1]}));if(!d)return{groups:[],structs:[]};const c=((g=i.match(r))==null?void 0:g.map(m=>{const y=m.match(h)[1],x=m.match(l).reduce((w,k)=>{const[E,B]=k.split(":");return w[E.trim()]=B.trim(),w},{});return x?{name:y,members:x}:null}).filter(({name:m})=>d.some(y=>y.type===m||y.type.includes(`<${m}>`))))??[];return{groups:d,structs:c}}var Oi=(i=>(i[i.VERTEX=1]="VERTEX",i[i.FRAGMENT=2]="FRAGMENT",i[i.COMPUTE=4]="COMPUTE",i))(Oi||{});function ap({groups:i}){const t=[];for(let e=0;e<i.length;e++){const s=i[e];t[s.group]||(t[s.group]=[]),s.isUniform?t[s.group].push({binding:s.binding,visibility:Oi.VERTEX|Oi.FRAGMENT,buffer:{type:"uniform"}}):s.type==="sampler"?t[s.group].push({binding:s.binding,visibility:Oi.FRAGMENT,sampler:{type:"filtering"}}):s.type==="texture_2d"||s.type.startsWith("texture_2d<")?t[s.group].push({binding:s.binding,visibility:Oi.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d",multisampled:!1}}):s.type==="texture_2d_array"||s.type.startsWith("texture_2d_array<")?t[s.group].push({binding:s.binding,visibility:Oi.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d-array",multisampled:!1}}):(s.type==="texture_cube"||s.type.startsWith("texture_cube<"))&&t[s.group].push({binding:s.binding,visibility:Oi.FRAGMENT,texture:{sampleType:"float",viewDimension:"cube",multisampled:!1}})}for(let e=0;e<t.length;e++)t[e]||(t[e]=[]);return t}function lp({groups:i}){const t=[];for(let e=0;e<i.length;e++){const s=i[e];t[s.group]||(t[s.group]={}),t[s.group][s.name]=s.binding}return t}function hp(i,t){const e=new Set,s=new Set,n=[...i.structs,...t.structs].filter(r=>e.has(r.name)?!1:(e.add(r.name),!0)),o=[...i.groups,...t.groups].filter(r=>{const l=`${r.name}-${r.binding}`;return s.has(l)?!1:(s.add(l),!0)});return{structs:n,groups:o}}const An=Object.create(null);class _r{constructor(t){var l,h;this._layoutKey=0,this._attributeLocationsKey=0;const{fragment:e,vertex:s,layout:n,gpuLayout:o,name:r}=t;if(this.name=r,this.fragment=e,this.vertex=s,e.source===s.source){const d=zr(e.source);this.structsAndGroups=d}else{const d=zr(s.source),c=zr(e.source);this.structsAndGroups=hp(d,c)}this.layout=n??lp(this.structsAndGroups),this.gpuLayout=o??ap(this.structsAndGroups),this.autoAssignGlobalUniforms=((l=this.layout[0])==null?void 0:l.globalUniforms)!==void 0,this.autoAssignLocalUniforms=((h=this.layout[1])==null?void 0:h.localUniforms)!==void 0,this._generateProgramKey()}_generateProgramKey(){const{vertex:t,fragment:e}=this,s=t.source+e.source+t.entryPoint+e.entryPoint;this._layoutKey=yl(s,"program")}get attributeData(){return this._attributeData??(this._attributeData=rp(this.vertex)),this._attributeData}destroy(){this.gpuLayout=null,this.layout=null,this.structsAndGroups=null,this.fragment=null,this.vertex=null,An[this._cacheKey]=null}static from(t){const e=`${t.vertex.source}:${t.fragment.source}:${t.fragment.entryPoint}:${t.vertex.entryPoint}`;return An[e]||(An[e]=new _r(t),An[e]._cacheKey=e),An[e]}}const Id=["f32","i32","vec2<f32>","vec3<f32>","vec4<f32>","mat2x2<f32>","mat3x3<f32>","mat4x4<f32>","mat3x2<f32>","mat4x2<f32>","mat2x3<f32>","mat4x3<f32>","mat2x4<f32>","mat3x4<f32>","vec2<i32>","vec3<i32>","vec4<i32>"],cp=Id.reduce((i,t)=>(i[t]=!0,i),{});function dp(i,t){switch(i){case"f32":return 0;case"vec2<f32>":return new Float32Array(2*t);case"vec3<f32>":return new Float32Array(3*t);case"vec4<f32>":return new Float32Array(4*t);case"mat2x2<f32>":return new Float32Array([1,0,0,1]);case"mat3x3<f32>":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4x4<f32>":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}const Ld=class Bd{constructor(t,e){this._touched=0,this.uid=qt("uniform"),this._resourceType="uniformGroup",this._resourceId=qt("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1,e={...Bd.defaultOptions,...e},this.uniformStructures=t;const s={};for(const n in t){const o=t[n];if(o.name=n,o.size=o.size??1,!cp[o.type]){const r=o.type.match(/^array<(\w+(?:<\w+>)?),\s*(\d+)>$/);if(r){const[,l,h]=r;throw new Error(`Uniform type ${o.type} is not supported. Use type: '${l}', size: ${h} instead.`)}throw new Error(`Uniform type ${o.type} is not supported. Supported uniform types are: ${Id.join(", ")}`)}o.value??(o.value=dp(o.type,o.size)),s[n]=o.value}this.uniforms=s,this._dirtyId=1,this.ubo=e.ubo,this.isStatic=e.isStatic,this._signature=yl(Object.keys(s).map(n=>`${n}-${t[n].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};Ld.defaultOptions={ubo:!1,isStatic:!1};let Rd=Ld;class Xo{constructor(t){this.resources=Object.create(null),this._dirty=!0;let e=0;for(const s in t){const n=t[s];this.setResource(n,e++)}this._updateKey()}_updateKey(){if(!this._dirty)return;this._dirty=!1;const t=[];let e=0;for(const s in this.resources)t[e++]=this.resources[s]._resourceId;this._key=t.join("|")}setResource(t,e){var n,o;const s=this.resources[e];t!==s&&((n=s==null?void 0:s.off)==null||n.call(s,"change",this.onResourceChange,this),(o=t.on)==null||o.call(t,"change",this.onResourceChange,this),this.resources[e]=t,this._dirty=!0)}getResource(t){return this.resources[t]}_touch(t,e){const s=this.resources;for(const n in s)s[n]._gcLastUsed=t,s[n]._touched=e}destroy(){var e;const t=this.resources;for(const s in t){const n=t[s];(e=n==null?void 0:n.off)==null||e.call(n,"change",this.onResourceChange,this)}this.resources=null}onResourceChange(t){this._dirty=!0,t.destroyed?this.destroy():this._updateKey()}}var Da=(i=>(i[i.WEBGL=1]="WEBGL",i[i.WEBGPU=2]="WEBGPU",i[i.CANVAS=4]="CANVAS",i[i.BOTH=3]="BOTH",i))(Da||{});class bl extends as{constructor(t){super(),this.uid=qt("shader"),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[],this._destroyed=!1;let{gpuProgram:e,glProgram:s,groups:n,resources:o,compatibleRenderers:r,groupMap:l}=t;this.gpuProgram=e,this.glProgram=s,r===void 0&&(r=0,e&&(r|=Da.WEBGPU),s&&(r|=Da.WEBGL)),this.compatibleRenderers=r;const h={};if(!o&&!n&&(o={}),o&&n)throw new Error("[Shader] Cannot have both resources and groups");if(!e&&n&&!l)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(!e&&n&&l)for(const d in l)for(const c in l[d]){const p=l[d][c];h[p]={group:d,binding:c,name:p}}else if(e&&n&&!l){const d=e.structsAndGroups.groups;l={},d.forEach(c=>{l[c.group]=l[c.group]||{},l[c.group][c.binding]=c.name,h[c.name]=c})}else if(o){n={},l={},e&&e.structsAndGroups.groups.forEach(p=>{l[p.group]=l[p.group]||{},l[p.group][p.binding]=p.name,h[p.name]=p});let d=0;for(const c in o)h[c]||(n[99]||(n[99]=new Xo,this._ownedBindGroups.push(n[99])),h[c]={group:99,binding:d,name:c},l[99]=l[99]||{},l[99][d]=c,d++);for(const c in o){const p=c;let g=o[c];!g.source&&!g._resourceType&&(g=new Rd(g));const m=h[p];m&&(n[m.group]||(n[m.group]=new Xo,this._ownedBindGroups.push(n[m.group])),n[m.group].setResource(g,m.binding))}}this.groups=n,this._uniformBindMap=l,this.resources=this._buildResourceAccessor(n,h)}addResource(t,e,s){var n,o;(n=this._uniformBindMap)[e]||(n[e]={}),(o=this._uniformBindMap[e])[s]||(o[s]=t),this.groups[e]||(this.groups[e]=new Xo,this._ownedBindGroups.push(this.groups[e]))}_buildResourceAccessor(t,e){const s={};for(const n in e){const o=e[n];Object.defineProperty(s,o.name,{get(){return t[o.group].getResource(o.binding)},set(r){t[o.group].setResource(r,o.binding)}})}return s}destroy(t=!1){var e,s;this._destroyed||(this._destroyed=!0,this.emit("destroy",this),t&&((e=this.gpuProgram)==null||e.destroy(),(s=this.glProgram)==null||s.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(n=>{n.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null)}static from(t){const{gpu:e,gl:s,...n}=t;let o,r;return e&&(o=_r.from(e)),s&&(r=Pd.from(s)),new bl({gpuProgram:o,glProgram:r,...n})}}const up={normal:0,add:1,multiply:2,screen:3,overlay:4,erase:5,"normal-npm":6,"add-npm":7,"screen-npm":8,min:9,max:10},Fr=0,Nr=1,Gr=2,Wr=3,Or=4,Hr=5,za=class $d{constructor(){this.data=0,this.blendMode="normal",this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<Fr)}set blend(t){!!(this.data&1<<Fr)!==t&&(this.data^=1<<Fr)}get offsets(){return!!(this.data&1<<Nr)}set offsets(t){!!(this.data&1<<Nr)!==t&&(this.data^=1<<Nr)}set cullMode(t){if(t==="none"){this.culling=!1;return}this.culling=!0,this.clockwiseFrontFace=t==="front"}get cullMode(){return this.culling?this.clockwiseFrontFace?"front":"back":"none"}get culling(){return!!(this.data&1<<Gr)}set culling(t){!!(this.data&1<<Gr)!==t&&(this.data^=1<<Gr)}get depthTest(){return!!(this.data&1<<Wr)}set depthTest(t){!!(this.data&1<<Wr)!==t&&(this.data^=1<<Wr)}get depthMask(){return!!(this.data&1<<Hr)}set depthMask(t){!!(this.data&1<<Hr)!==t&&(this.data^=1<<Hr)}get clockwiseFrontFace(){return!!(this.data&1<<Or)}set clockwiseFrontFace(t){!!(this.data&1<<Or)!==t&&(this.data^=1<<Or)}get blendMode(){return this._blendMode}set blendMode(t){this.blend=t!=="none",this._blendMode=t,this._blendModeId=up[t]||0}get polygonOffset(){return this._polygonOffset}set polygonOffset(t){this.offsets=!!t,this._polygonOffset=t}toString(){return`[pixi.js/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`}static for2d(){const t=new $d;return t.depthTest=!1,t.blend=!0,t}};za.default2d=za.for2d();let Dd=za;const Fa=[];jt.handleByNamedList(yt.Environment,Fa);async function fp(i){if(!i)for(let t=0;t<Fa.length;t++){const e=Fa[t];if(e.value.test()){await e.value.load();return}}}let Mn;function pp(){if(typeof Mn=="boolean")return Mn;try{Mn=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch{Mn=!1}return Mn}function rh(i,t,e=2){const s=t&&t.length,n=s?t[0]*e:i.length;let o=zd(i,0,n,e,!0);const r=[];if(!o||o.next===o.prev)return r;let l,h,d;if(s&&(o=_p(i,t,o,e)),i.length>80*e){l=i[0],h=i[1];let c=l,p=h;for(let g=e;g<n;g+=e){const m=i[g],y=i[g+1];m<l&&(l=m),y<h&&(h=y),m>c&&(c=m),y>p&&(p=y)}d=Math.max(c-l,p-h),d=d!==0?32767/d:0}return no(o,r,e,l,h,d,0),r}function zd(i,t,e,s,n){let o;if(n===Pp(i,t,e,s)>0)for(let r=t;r<e;r+=s)o=ah(r/s|0,i[r],i[r+1],o);else for(let r=e-s;r>=t;r-=s)o=ah(r/s|0,i[r],i[r+1],o);return o&&vn(o,o.next)&&(ro(o),o=o.next),o}function ji(i,t){if(!i)return i;t||(t=i);let e=i,s;do if(s=!1,!e.steiner&&(vn(e,e.next)||Ot(e.prev,e,e.next)===0)){if(ro(e),e=t=e.prev,e===e.next)break;s=!0}else e=e.next;while(s||e!==t);return t}function no(i,t,e,s,n,o,r){if(!i)return;!r&&o&&kp(i,s,n,o);let l=i;for(;i.prev!==i.next;){const h=i.prev,d=i.next;if(o?gp(i,s,n,o):mp(i)){t.push(h.i,i.i,d.i),ro(i),i=d.next,l=d.next;continue}if(i=d,i===l){r?r===1?(i=yp(ji(i),t),no(i,t,e,s,n,o,2)):r===2&&bp(i,t,e,s,n,o):no(ji(i),t,e,s,n,o,1);break}}}function mp(i){const t=i.prev,e=i,s=i.next;if(Ot(t,e,s)>=0)return!1;const n=t.x,o=e.x,r=s.x,l=t.y,h=e.y,d=s.y,c=Math.min(n,o,r),p=Math.min(l,h,d),g=Math.max(n,o,r),m=Math.max(l,h,d);let y=s.next;for(;y!==t;){if(y.x>=c&&y.x<=g&&y.y>=p&&y.y<=m&&Zn(n,l,o,h,r,d,y.x,y.y)&&Ot(y.prev,y,y.next)>=0)return!1;y=y.next}return!0}function gp(i,t,e,s){const n=i.prev,o=i,r=i.next;if(Ot(n,o,r)>=0)return!1;const l=n.x,h=o.x,d=r.x,c=n.y,p=o.y,g=r.y,m=Math.min(l,h,d),y=Math.min(c,p,g),x=Math.max(l,h,d),w=Math.max(c,p,g),k=Na(m,y,t,e,s),E=Na(x,w,t,e,s);let B=i.prevZ,L=i.nextZ;for(;B&&B.z>=k&&L&&L.z<=E;){if(B.x>=m&&B.x<=x&&B.y>=y&&B.y<=w&&B!==n&&B!==r&&Zn(l,c,h,p,d,g,B.x,B.y)&&Ot(B.prev,B,B.next)>=0||(B=B.prevZ,L.x>=m&&L.x<=x&&L.y>=y&&L.y<=w&&L!==n&&L!==r&&Zn(l,c,h,p,d,g,L.x,L.y)&&Ot(L.prev,L,L.next)>=0))return!1;L=L.nextZ}for(;B&&B.z>=k;){if(B.x>=m&&B.x<=x&&B.y>=y&&B.y<=w&&B!==n&&B!==r&&Zn(l,c,h,p,d,g,B.x,B.y)&&Ot(B.prev,B,B.next)>=0)return!1;B=B.prevZ}for(;L&&L.z<=E;){if(L.x>=m&&L.x<=x&&L.y>=y&&L.y<=w&&L!==n&&L!==r&&Zn(l,c,h,p,d,g,L.x,L.y)&&Ot(L.prev,L,L.next)>=0)return!1;L=L.nextZ}return!0}function yp(i,t){let e=i;do{const s=e.prev,n=e.next.next;!vn(s,n)&&Nd(s,e,e.next,n)&&oo(s,n)&&oo(n,s)&&(t.push(s.i,e.i,n.i),ro(e),ro(e.next),e=i=n),e=e.next}while(e!==i);return ji(e)}function bp(i,t,e,s,n,o){let r=i;do{let l=r.next.next;for(;l!==r.prev;){if(r.i!==l.i&&Ap(r,l)){let h=Gd(r,l);r=ji(r,r.next),h=ji(h,h.next),no(r,t,e,s,n,o,0),no(h,t,e,s,n,o,0);return}l=l.next}r=r.next}while(r!==i)}function _p(i,t,e,s){const n=[];for(let o=0,r=t.length;o<r;o++){const l=t[o]*s,h=o<r-1?t[o+1]*s:i.length,d=zd(i,l,h,s,!1);d===d.next&&(d.steiner=!0),n.push(Cp(d))}n.sort(xp);for(let o=0;o<n.length;o++)e=vp(n[o],e);return e}function xp(i,t){let e=i.x-t.x;if(e===0&&(e=i.y-t.y,e===0)){const s=(i.next.y-i.y)/(i.next.x-i.x),n=(t.next.y-t.y)/(t.next.x-t.x);e=s-n}return e}function vp(i,t){const e=wp(i,t);if(!e)return t;const s=Gd(e,i);return ji(s,s.next),ji(e,e.next)}function wp(i,t){let e=t;const s=i.x,n=i.y;let o=-1/0,r;if(vn(i,e))return e;do{if(vn(i,e.next))return e.next;if(n<=e.y&&n>=e.next.y&&e.next.y!==e.y){const p=e.x+(n-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(p<=s&&p>o&&(o=p,r=e.x<e.next.x?e:e.next,p===s))return r}e=e.next}while(e!==t);if(!r)return null;const l=r,h=r.x,d=r.y;let c=1/0;e=r;do{if(s>=e.x&&e.x>=h&&s!==e.x&&Fd(n<d?s:o,n,h,d,n<d?o:s,n,e.x,e.y)){const p=Math.abs(n-e.y)/(s-e.x);oo(e,i)&&(p<c||p===c&&(e.x>r.x||e.x===r.x&&Sp(r,e)))&&(r=e,c=p)}e=e.next}while(e!==l);return r}function Sp(i,t){return Ot(i.prev,i,t.prev)<0&&Ot(t.next,i,i.next)<0}function kp(i,t,e,s){let n=i;do n.z===0&&(n.z=Na(n.x,n.y,t,e,s)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next;while(n!==i);n.prevZ.nextZ=null,n.prevZ=null,Tp(n)}function Tp(i){let t,e=1;do{let s=i,n;i=null;let o=null;for(t=0;s;){t++;let r=s,l=0;for(let d=0;d<e&&(l++,r=r.nextZ,!!r);d++);let h=e;for(;l>0||h>0&&r;)l!==0&&(h===0||!r||s.z<=r.z)?(n=s,s=s.nextZ,l--):(n=r,r=r.nextZ,h--),o?o.nextZ=n:i=n,n.prevZ=o,o=n;s=r}o.nextZ=null,e*=2}while(t>1);return i}function Na(i,t,e,s,n){return i=(i-e)*n|0,t=(t-s)*n|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,i|t<<1}function Cp(i){let t=i,e=i;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==i);return e}function Fd(i,t,e,s,n,o,r,l){return(n-r)*(t-l)>=(i-r)*(o-l)&&(i-r)*(s-l)>=(e-r)*(t-l)&&(e-r)*(o-l)>=(n-r)*(s-l)}function Zn(i,t,e,s,n,o,r,l){return!(i===r&&t===l)&&Fd(i,t,e,s,n,o,r,l)}function Ap(i,t){return i.next.i!==t.i&&i.prev.i!==t.i&&!Mp(i,t)&&(oo(i,t)&&oo(t,i)&&Ep(i,t)&&(Ot(i.prev,i,t.prev)||Ot(i,t.prev,t))||vn(i,t)&&Ot(i.prev,i,i.next)>0&&Ot(t.prev,t,t.next)>0)}function Ot(i,t,e){return(t.y-i.y)*(e.x-t.x)-(t.x-i.x)*(e.y-t.y)}function vn(i,t){return i.x===t.x&&i.y===t.y}function Nd(i,t,e,s){const n=So(Ot(i,t,e)),o=So(Ot(i,t,s)),r=So(Ot(e,s,i)),l=So(Ot(e,s,t));return!!(n!==o&&r!==l||n===0&&wo(i,e,t)||o===0&&wo(i,s,t)||r===0&&wo(e,i,s)||l===0&&wo(e,t,s))}function wo(i,t,e){return t.x<=Math.max(i.x,e.x)&&t.x>=Math.min(i.x,e.x)&&t.y<=Math.max(i.y,e.y)&&t.y>=Math.min(i.y,e.y)}function So(i){return i>0?1:i<0?-1:0}function Mp(i,t){let e=i;do{if(e.i!==i.i&&e.next.i!==i.i&&e.i!==t.i&&e.next.i!==t.i&&Nd(e,e.next,i,t))return!0;e=e.next}while(e!==i);return!1}function oo(i,t){return Ot(i.prev,i,i.next)<0?Ot(i,t,i.next)>=0&&Ot(i,i.prev,t)>=0:Ot(i,t,i.prev)<0||Ot(i,i.next,t)<0}function Ep(i,t){let e=i,s=!1;const n=(i.x+t.x)/2,o=(i.y+t.y)/2;do e.y>o!=e.next.y>o&&e.next.y!==e.y&&n<(e.next.x-e.x)*(o-e.y)/(e.next.y-e.y)+e.x&&(s=!s),e=e.next;while(e!==i);return s}function Gd(i,t){const e=Ga(i.i,i.x,i.y),s=Ga(t.i,t.x,t.y),n=i.next,o=t.prev;return i.next=t,t.prev=i,e.next=n,n.prev=e,s.next=e,e.prev=s,o.next=s,s.prev=o,s}function ah(i,t,e,s){const n=Ga(i,t,e);return s?(n.next=s.next,n.prev=s,s.next.prev=n,s.next=n):(n.prev=n,n.next=n),n}function ro(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function Ga(i,t,e){return{i,x:t,y:e,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function Pp(i,t,e,s){let n=0;for(let o=t,r=e-s;o<e;o+=s)n+=(i[r]-i[o])*(i[o+1]+i[r+1]),r=o;return n}const Ip=rh.default||rh;var Wd=(i=>(i[i.NONE=0]="NONE",i[i.COLOR=16384]="COLOR",i[i.STENCIL=1024]="STENCIL",i[i.DEPTH=256]="DEPTH",i[i.COLOR_DEPTH=16640]="COLOR_DEPTH",i[i.COLOR_STENCIL=17408]="COLOR_STENCIL",i[i.DEPTH_STENCIL=1280]="DEPTH_STENCIL",i[i.ALL=17664]="ALL",i))(Wd||{});class Lp{constructor(t){this.items=[],this._name=t}emit(t,e,s,n,o,r,l,h){const{name:d,items:c}=this;for(let p=0,g=c.length;p<g;p++)c[p][d](t,e,s,n,o,r,l,h);return this}add(t){return t[this._name]&&(this.remove(t),this.items.push(t)),this}remove(t){const e=this.items.indexOf(t);return e!==-1&&this.items.splice(e,1),this}contains(t){return this.items.indexOf(t)!==-1}removeAll(){return this.items.length=0,this}destroy(){this.removeAll(),this.items=null,this._name=null}get empty(){return this.items.length===0}get name(){return this._name}}const Bp=["init","destroy","contextChange","resolutionChange","resetState","renderEnd","renderStart","render","update","postrender","prerender"],Od=class Hd extends as{constructor(t){super(),this.tick=0,this.uid=qt("renderer"),this.runners=Object.create(null),this.renderPipes=Object.create(null),this._initOptions={},this._systemsHash=Object.create(null),this.type=t.type,this.name=t.name,this.config=t;const e=[...Bp,...this.config.runners??[]];this._addRunners(...e),this._unsafeEvalCheck()}async init(t={}){const e=t.skipExtensionImports===!0?!0:t.manageImports===!1;await fp(e),this._addSystems(this.config.systems),this._addPipes(this.config.renderPipes,this.config.renderPipeAdaptors);for(const s in this._systemsHash)t={...this._systemsHash[s].constructor.defaultOptions,...t};t={...Hd.defaultOptions,...t},this._roundPixels=t.roundPixels?1:0;for(let s=0;s<this.runners.init.items.length;s++)await this.runners.init.items[s].init(t);this._initOptions=t}render(t,e){this.tick++;let s=t;if(s instanceof Ft&&(s={container:s},e&&(Ct(Ut,"passing a second argument is deprecated, please use render options instead"),s.target=e.renderTexture)),s.target||(s.target=this.view.renderTarget),s.target===this.view.renderTarget&&(this._lastObjectRendered=s.container,s.clearColor??(s.clearColor=this.background.colorRgba),s.clear??(s.clear=this.background.clearBeforeRender)),s.clearColor){const n=Array.isArray(s.clearColor)&&s.clearColor.length===4;s.clearColor=n?s.clearColor:Kt.shared.setValue(s.clearColor).toArray()}s.transform||(s.container.updateLocalTransform(),s.transform=s.container.localTransform),s.container.visible&&(s.container.enableRenderGroup(),this.runners.prerender.emit(s),this.runners.renderStart.emit(s),this.runners.render.emit(s),this.runners.renderEnd.emit(s),this.runners.postrender.emit(s))}resize(t,e,s){const n=this.view.resolution;this.view.resize(t,e,s),this.emit("resize",this.view.screen.width,this.view.screen.height,this.view.resolution),s!==void 0&&s!==n&&this.runners.resolutionChange.emit(s)}clear(t={}){const e=this;t.target||(t.target=e.renderTarget.renderTarget),t.clearColor||(t.clearColor=this.background.colorRgba),t.clear??(t.clear=Wd.ALL);const{clear:s,clearColor:n,target:o,mipLevel:r,layer:l}=t;Kt.shared.setValue(n??this.background.colorRgba),e.renderTarget.clear(o,s,Kt.shared.toArray(),r??0,l??0)}get resolution(){return this.view.resolution}set resolution(t){this.view.resolution=t,this.runners.resolutionChange.emit(t)}get width(){return this.view.texture.frame.width}get height(){return this.view.texture.frame.height}get canvas(){return this.view.canvas}get lastObjectRendered(){return this._lastObjectRendered}get renderingToScreen(){return this.renderTarget.renderingToScreen}get screen(){return this.view.screen}_addRunners(...t){t.forEach(e=>{this.runners[e]=new Lp(e)})}_addSystems(t){let e;for(e in t){const s=t[e];this._addSystem(s.value,s.name)}}_addSystem(t,e){const s=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=s,this._systemsHash[e]=s;for(const n in this.runners)this.runners[n].add(s);return this}_addPipes(t,e){const s=e.reduce((n,o)=>(n[o.name]=o.value,n),{});t.forEach(n=>{const o=n.value,r=n.name,l=s[r];this.renderPipes[r]=new o(this,l?new l:null),this.runners.destroy.add(this.renderPipes[r])})}destroy(t=!1){this.runners.destroy.items.reverse(),this.runners.destroy.emit(t),(t===!0||typeof t=="object"&&t.releaseGlobalResources)&&uo.release(),Object.values(this.runners).forEach(e=>{e.destroy()}),this._systemsHash=null,this.renderPipes=null,this.removeAllListeners()}generateTexture(t){return this.textureGenerator.generateTexture(t)}get roundPixels(){return!!this._roundPixels}_unsafeEvalCheck(){if(!pp())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}resetState(){this.runners.resetState.emit()}};Od.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let Ud=Od,ko;function Rp(i){return ko!==void 0||(ko=(()=>{var e;const t={stencil:!0,failIfMajorPerformanceCaveat:i??Ud.defaultOptions.failIfMajorPerformanceCaveat};try{if(!Pe.get().getWebGLRenderingContext())return!1;let n=Pe.get().createCanvas().getContext("webgl",t);const o=!!((e=n==null?void 0:n.getContextAttributes())!=null&&e.stencil);if(n){const r=n.getExtension("WEBGL_lose_context");r&&r.loseContext()}return n=null,o}catch{return!1}})()),ko}let To;async function $p(i={}){return To!==void 0||(To=await(async()=>{const t=Pe.get().getNavigator().gpu;if(!t)return!1;try{return await(await t.requestAdapter(i)).requestDevice(),!0}catch{return!1}})()),To}const lh=["webgl","webgpu","canvas"];async function Dp(i){let t=[];i.preference?(t.push(i.preference),lh.forEach(o=>{o!==i.preference&&t.push(o)})):t=lh.slice();let e,s={};for(let o=0;o<t.length;o++){const r=t[o];if(r==="webgpu"&&await $p()){const{WebGPURenderer:l}=await Qn(async()=>{const{WebGPURenderer:h}=await import("./WebGPURenderer-Dwywvwqe.js");return{WebGPURenderer:h}},__vite__mapDeps([3,4,5,2]));e=l,s={...i,...i.webgpu};break}else if(r==="webgl"&&Rp(i.failIfMajorPerformanceCaveat??Ud.defaultOptions.failIfMajorPerformanceCaveat)){const{WebGLRenderer:l}=await Qn(async()=>{const{WebGLRenderer:h}=await import("./WebGLRenderer-vhPQEPUG.js");return{WebGLRenderer:h}},__vite__mapDeps([6,4,5,2]));e=l,s={...i,...i.webgl};break}else if(r==="canvas"){const{CanvasRenderer:l}=await Qn(async()=>{const{CanvasRenderer:h}=await import("./CanvasRenderer-7Cv6xZVP.js");return{CanvasRenderer:h}},__vite__mapDeps([7,5,2]));e=l,s={...i,...i.canvasOptions};break}}if(delete s.webgpu,delete s.webgl,delete s.canvasOptions,!e)throw new Error("No available renderer for the current environment");const n=new e;return await n.init(s),n}const qd="8.17.0";class Vd{static init(){var t;(t=globalThis.__PIXI_APP_INIT__)==null||t.call(globalThis,this,qd)}static destroy(){}}Vd.extension=yt.Application;class zp{constructor(t){this._renderer=t}init(){var t;(t=globalThis.__PIXI_RENDERER_INIT__)==null||t.call(globalThis,this._renderer,qd)}destroy(){this._renderer=null}}zp.extension={type:[yt.WebGLSystem,yt.WebGPUSystem],name:"initHook",priority:-10};class Yd{static init(t){Object.defineProperty(this,"resizeTo",{configurable:!0,set(e){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=e,e&&(globalThis.addEventListener("resize",this.queueResize),this.resize())},get(){return this._resizeTo}}),this.queueResize=()=>{this._resizeTo&&(this._cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize()))},this._cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;this._cancelResize();let e,s;if(this._resizeTo===globalThis.window)e=globalThis.innerWidth,s=globalThis.innerHeight;else{const{clientWidth:n,clientHeight:o}=this._resizeTo;e=n,s=o}this.renderer.resize(e,s),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=t.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this._cancelResize(),this._cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}}Yd.extension=yt.Application;class jd{static init(t){t=Object.assign({autoStart:!0,sharedTicker:!1},t),Object.defineProperty(this,"ticker",{configurable:!0,set(e){this._ticker&&this._ticker.remove(this.render,this),this._ticker=e,e&&e.add(this.render,this,rr.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?un.shared:new un,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}jd.extension=yt.Application;jt.add(Yd);jt.add(jd);const Xd=class Wa{constructor(...t){this.stage=new Ft,t[0]!==void 0&&Ct(Ut,"Application constructor options are deprecated, please use Application.init() instead.")}async init(t){t={...t},this.stage||(this.stage=new Ft),this.renderer=await Dp(t),Wa._plugins.forEach(e=>{e.init.call(this,t)})}render(){this.renderer.render({container:this.stage})}get canvas(){return this.renderer.canvas}get view(){return Ct(Ut,"Application.view is deprecated, please use Application.canvas instead."),this.renderer.canvas}get screen(){return this.renderer.screen}destroy(t=!1,e=!1){const s=Wa._plugins.slice(0);s.reverse(),s.forEach(n=>{n.destroy.call(this)}),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null}};Xd._plugins=[];let Zd=Xd;jt.handleByList(yt.Application,Zd._plugins);jt.add(Vd);var Ur,hh;function Fp(){if(hh)return Ur;hh=1,Ur=e;var i={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},t=/([astvzqmhlc])([^astvzqmhlc]*)/ig;function e(o){var r=[];return o.replace(t,function(l,h,d){var c=h.toLowerCase();for(d=n(d),c=="m"&&d.length>2&&(r.push([h].concat(d.splice(0,2))),c="l",h=h=="m"?"l":"L");;){if(d.length==i[c])return d.unshift(h),r.push(d);if(d.length<i[c])throw new Error("malformed path data");r.push([h].concat(d.splice(0,i[c])))}}),r}var s=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/ig;function n(o){var r=o.match(s);return r?r.map(Number):[]}return Ur}var Np=Fp();const Gp=Xc(Np);function Wp(i,t){const e=Gp(i),s=[];let n=null,o=0,r=0;for(let l=0;l<e.length;l++){const h=e[l],d=h[0],c=h;switch(d){case"M":o=c[1],r=c[2],t.moveTo(o,r);break;case"m":o+=c[1],r+=c[2],t.moveTo(o,r);break;case"H":o=c[1],t.lineTo(o,r);break;case"h":o+=c[1],t.lineTo(o,r);break;case"V":r=c[1],t.lineTo(o,r);break;case"v":r+=c[1],t.lineTo(o,r);break;case"L":o=c[1],r=c[2],t.lineTo(o,r);break;case"l":o+=c[1],r+=c[2],t.lineTo(o,r);break;case"C":o=c[5],r=c[6],t.bezierCurveTo(c[1],c[2],c[3],c[4],o,r);break;case"c":t.bezierCurveTo(o+c[1],r+c[2],o+c[3],r+c[4],o+c[5],r+c[6]),o+=c[5],r+=c[6];break;case"S":o=c[3],r=c[4],t.bezierCurveToShort(c[1],c[2],o,r);break;case"s":t.bezierCurveToShort(o+c[1],r+c[2],o+c[3],r+c[4]),o+=c[3],r+=c[4];break;case"Q":o=c[3],r=c[4],t.quadraticCurveTo(c[1],c[2],o,r);break;case"q":t.quadraticCurveTo(o+c[1],r+c[2],o+c[3],r+c[4]),o+=c[3],r+=c[4];break;case"T":o=c[1],r=c[2],t.quadraticCurveToShort(o,r);break;case"t":o+=c[1],r+=c[2],t.quadraticCurveToShort(o,r);break;case"A":o=c[6],r=c[7],t.arcToSvg(c[1],c[2],c[3],c[4],c[5],o,r);break;case"a":o+=c[6],r+=c[7],t.arcToSvg(c[1],c[2],c[3],c[4],c[5],o,r);break;case"Z":case"z":t.closePath(),s.length>0&&(n=s.pop(),n?(o=n.startX,r=n.startY):(o=0,r=0)),n=null;break;default:xe(`Unknown SVG path command: ${d}`)}d!=="Z"&&d!=="z"&&n===null&&(n={startX:o,startY:r},s.push(n))}return t}class _l{constructor(t=0,e=0,s=0){this.type="circle",this.x=t,this.y=e,this.radius=s}clone(){return new _l(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const s=this.radius*this.radius;let n=this.x-t,o=this.y-e;return n*=n,o*=o,n+o<=s}strokeContains(t,e,s,n=.5){if(this.radius===0)return!1;const o=this.x-t,r=this.y-e,l=this.radius,h=(1-n)*s,d=Math.sqrt(o*o+r*r);return d<=l+h&&d>l-(s-h)}getBounds(t){return t||(t=new Yt),t.x=this.x-this.radius,t.y=this.y-this.radius,t.width=this.radius*2,t.height=this.radius*2,t}copyFrom(t){return this.x=t.x,this.y=t.y,this.radius=t.radius,this}copyTo(t){return t.copyFrom(this),t}toString(){return`[pixi.js/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`}}class xl{constructor(t=0,e=0,s=0,n=0){this.type="ellipse",this.x=t,this.y=e,this.halfWidth=s,this.halfHeight=n}clone(){return new xl(this.x,this.y,this.halfWidth,this.halfHeight)}contains(t,e){if(this.halfWidth<=0||this.halfHeight<=0)return!1;let s=(t-this.x)/this.halfWidth,n=(e-this.y)/this.halfHeight;return s*=s,n*=n,s+n<=1}strokeContains(t,e,s,n=.5){const{halfWidth:o,halfHeight:r}=this;if(o<=0||r<=0)return!1;const l=s*(1-n),h=s-l,d=o-h,c=r-h,p=o+l,g=r+l,m=t-this.x,y=e-this.y,x=m*m/(d*d)+y*y/(c*c),w=m*m/(p*p)+y*y/(g*g);return x>1&&w<=1}getBounds(t){return t||(t=new Yt),t.x=this.x-this.halfWidth,t.y=this.y-this.halfHeight,t.width=this.halfWidth*2,t.height=this.halfHeight*2,t}copyFrom(t){return this.x=t.x,this.y=t.y,this.halfWidth=t.halfWidth,this.halfHeight=t.halfHeight,this}copyTo(t){return t.copyFrom(this),t}toString(){return`[pixi.js/math:Ellipse x=${this.x} y=${this.y} halfWidth=${this.halfWidth} halfHeight=${this.halfHeight}]`}}function Op(i,t,e,s,n,o){const r=i-e,l=t-s,h=n-e,d=o-s,c=r*h+l*d,p=h*h+d*d;let g=-1;p!==0&&(g=c/p);let m,y;g<0?(m=e,y=s):g>1?(m=n,y=o):(m=e+g*h,y=s+g*d);const x=i-m,w=t-y;return x*x+w*w}let Hp,Up;class to{constructor(...t){this.type="polygon";let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const s=[];for(let n=0,o=e.length;n<o;n++)s.push(e[n].x,e[n].y);e=s}this.points=e,this.closePath=!0}isClockwise(){let t=0;const e=this.points,s=e.length;for(let n=0;n<s;n+=2){const o=e[n],r=e[n+1],l=e[(n+2)%s],h=e[(n+3)%s];t+=(l-o)*(h+r)}return t<0}containsPolygon(t){const e=this.getBounds(Hp),s=t.getBounds(Up);if(!e.containsRect(s))return!1;const n=t.points;for(let o=0;o<n.length;o+=2){const r=n[o],l=n[o+1];if(!this.contains(r,l))return!1}return!0}clone(){const t=this.points.slice(),e=new to(t);return e.closePath=this.closePath,e}contains(t,e){let s=!1;const n=this.points.length/2;for(let o=0,r=n-1;o<n;r=o++){const l=this.points[o*2],h=this.points[o*2+1],d=this.points[r*2],c=this.points[r*2+1];h>e!=c>e&&t<(d-l)*((e-h)/(c-h))+l&&(s=!s)}return s}strokeContains(t,e,s,n=.5){const o=s*s,r=o*(1-n),l=o-r,{points:h}=this,d=h.length-(this.closePath?0:2);for(let c=0;c<d;c+=2){const p=h[c],g=h[c+1],m=h[(c+2)%h.length],y=h[(c+3)%h.length],x=Op(t,e,p,g,m,y),w=Math.sign((m-p)*(e-g)-(y-g)*(t-p));if(x<=(w<0?l:r))return!0}return!1}getBounds(t){t||(t=new Yt);const e=this.points;let s=1/0,n=-1/0,o=1/0,r=-1/0;for(let l=0,h=e.length;l<h;l+=2){const d=e[l],c=e[l+1];s=d<s?d:s,n=d>n?d:n,o=c<o?c:o,r=c>r?c:r}return t.x=s,t.width=n-s,t.y=o,t.height=r-o,t}copyFrom(t){return this.points=t.points.slice(),this.closePath=t.closePath,this}copyTo(t){return t.copyFrom(this),t}toString(){return`[pixi.js/math:PolygoncloseStroke=${this.closePath}points=${this.points.reduce((t,e)=>`${t}, ${e}`,"")}]`}get lastX(){return this.points[this.points.length-2]}get lastY(){return this.points[this.points.length-1]}get x(){return Ct("8.11.0","Polygon.lastX is deprecated, please use Polygon.lastX instead."),this.points[this.points.length-2]}get y(){return Ct("8.11.0","Polygon.y is deprecated, please use Polygon.lastY instead."),this.points[this.points.length-1]}get startX(){return this.points[0]}get startY(){return this.points[1]}}const Co=(i,t,e,s,n,o,r)=>{const l=i-e,h=t-s,d=Math.sqrt(l*l+h*h);return d>=n-o&&d<=n+r};class vl{constructor(t=0,e=0,s=0,n=0,o=20){this.type="roundedRectangle",this.x=t,this.y=e,this.width=s,this.height=n,this.radius=o}getBounds(t){return t||(t=new Yt),t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}clone(){return new vl(this.x,this.y,this.width,this.height,this.radius)}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.copyFrom(this),t}contains(t,e){if(this.width<=0||this.height<=0)return!1;if(t>=this.x&&t<=this.x+this.width&&e>=this.y&&e<=this.y+this.height){const s=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(e>=this.y+s&&e<=this.y+this.height-s||t>=this.x+s&&t<=this.x+this.width-s)return!0;let n=t-(this.x+s),o=e-(this.y+s);const r=s*s;if(n*n+o*o<=r||(n=t-(this.x+this.width-s),n*n+o*o<=r)||(o=e-(this.y+this.height-s),n*n+o*o<=r)||(n=t-(this.x+s),n*n+o*o<=r))return!0}return!1}strokeContains(t,e,s,n=.5){const{x:o,y:r,width:l,height:h,radius:d}=this,c=s*(1-n),p=s-c,g=o+d,m=r+d,y=l-d*2,x=h-d*2,w=o+l,k=r+h;return(t>=o-c&&t<=o+p||t>=w-p&&t<=w+c)&&e>=m&&e<=m+x||(e>=r-c&&e<=r+p||e>=k-p&&e<=k+c)&&t>=g&&t<=g+y?!0:t<g&&e<m&&Co(t,e,g,m,d,p,c)||t>w-d&&e<m&&Co(t,e,w-d,m,d,p,c)||t>w-d&&e>k-d&&Co(t,e,w-d,k-d,d,p,c)||t<g&&e>k-d&&Co(t,e,g,k-d,d,p,c)}toString(){return`[pixi.js/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`}}const Kd={};function qp(i,t,e){let s=2166136261;for(let n=0;n<t;n++)s^=i[n].uid,s=Math.imul(s,16777619),s>>>=0;return Kd[s]||Vp(i,t,s,e)}function Vp(i,t,e,s){const n={};let o=0;for(let l=0;l<s;l++){const h=l<t?i[l]:$t.EMPTY.source;n[o++]=h.source,n[o++]=h.style}const r=new Xo(n);return Kd[e]=r,r}class ch{constructor(t){typeof t=="number"?this.rawBinaryData=new ArrayBuffer(t):t instanceof Uint8Array?this.rawBinaryData=t.buffer:this.rawBinaryData=t,this.uint32View=new Uint32Array(this.rawBinaryData),this.float32View=new Float32Array(this.rawBinaryData),this.size=this.rawBinaryData.byteLength}get int8View(){return this._int8View||(this._int8View=new Int8Array(this.rawBinaryData)),this._int8View}get uint8View(){return this._uint8View||(this._uint8View=new Uint8Array(this.rawBinaryData)),this._uint8View}get int16View(){return this._int16View||(this._int16View=new Int16Array(this.rawBinaryData)),this._int16View}get int32View(){return this._int32View||(this._int32View=new Int32Array(this.rawBinaryData)),this._int32View}get float64View(){return this._float64Array||(this._float64Array=new Float64Array(this.rawBinaryData)),this._float64Array}get bigUint64View(){return this._bigUint64Array||(this._bigUint64Array=new BigUint64Array(this.rawBinaryData)),this._bigUint64Array}view(t){return this[`${t}View`]}destroy(){this.rawBinaryData=null,this.uint32View=null,this.float32View=null,this.uint16View=null,this._int8View=null,this._uint8View=null,this._int16View=null,this._int32View=null,this._float64Array=null,this._bigUint64Array=null}static sizeOf(t){switch(t){case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;default:throw new Error(`${t} isn't a valid view type`)}}}function dh(i,t,e,s){if(e??(e=0),s??(s=Math.min(i.byteLength-e,t.byteLength)),!(e&7)&&!(s&7)){const n=s/8;new Float64Array(t,0,n).set(new Float64Array(i,e,n))}else if(!(e&3)&&!(s&3)){const n=s/4;new Float32Array(t,0,n).set(new Float32Array(i,e,n))}else new Uint8Array(t).set(new Uint8Array(i,e,s))}const Yp={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var jp=(i=>(i[i.DISABLED=0]="DISABLED",i[i.RENDERING_MASK_ADD=1]="RENDERING_MASK_ADD",i[i.MASK_ACTIVE=2]="MASK_ACTIVE",i[i.INVERSE_MASK_ACTIVE=3]="INVERSE_MASK_ACTIVE",i[i.RENDERING_MASK_REMOVE=4]="RENDERING_MASK_REMOVE",i[i.NONE=5]="NONE",i))(jp||{});function uh(i,t){return t.alphaMode==="no-premultiply-alpha"&&Yp[i]||i}const Xp=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
24
- `);function Zp(i){let t="";for(let e=0;e<i;++e)e>0&&(t+=`
25
- else `),e<i-1&&(t+=`if(test == ${e}.0){}`);return t}function Kp(i,t){if(i===0)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");const e=t.createShader(t.FRAGMENT_SHADER);try{for(;;){const s=Xp.replace(/%forloop%/gi,Zp(i));if(t.shaderSource(e,s),t.compileShader(e),!t.getShaderParameter(e,t.COMPILE_STATUS))i=i/2|0;else break}}finally{t.deleteShader(e)}return i}let Qi=null;function Qp(){var t;if(Qi)return Qi;const i=Md();return Qi=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),Qi=Kp(Qi,i),(t=i.getExtension("WEBGL_lose_context"))==null||t.loseContext(),Qi}class Jp{constructor(){this.ids=Object.create(null),this.textures=[],this.count=0}clear(){for(let t=0;t<this.count;t++){const e=this.textures[t];this.textures[t]=null,this.ids[e.uid]=null}this.count=0}}class tm{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.textures=new Jp,this.blendMode="normal",this.topology="triangle-strip",this.canBundle=!0}destroy(){this.textures=null,this.gpuBindGroup=null,this.bindGroup=null,this.batcher=null,this.elements=null}}const eo=[];let ar=0;uo.register({clear:()=>{if(eo.length>0)for(const i of eo)i&&i.destroy();eo.length=0,ar=0}});function fh(){return ar>0?eo[--ar]:new tm}function ph(i){i.elements=null,eo[ar++]=i}let En=0;const Qd=class Jd{constructor(t){this.uid=qt("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],t={...Jd.defaultOptions,...t},t.maxTextures||(Ct("v8.8.0","maxTextures is a required option for Batcher now, please pass it in the options"),t.maxTextures=Qp());const{maxTextures:e,attributesInitialSize:s,indicesInitialSize:n}=t;this.attributeBuffer=new ch(s*4),this.indexBuffer=new Uint16Array(n),this.maxTextures=e}begin(){this.elementSize=0,this.elementStart=0,this.indexSize=0,this.attributeSize=0;for(let t=0;t<this.batchIndex;t++)ph(this.batches[t]);this.batchIndex=0,this._batchIndexStart=0,this._batchIndexSize=0,this.dirty=!0}add(t){this._elements[this.elementSize++]=t,t._indexStart=this.indexSize,t._attributeStart=this.attributeSize,t._batcher=this,this.indexSize+=t.indexSize,this.attributeSize+=t.attributeSize*this.vertexSize}checkAndUpdateTexture(t,e){const s=t._batch.textures.ids[e._source.uid];return!s&&s!==0?!1:(t._textureId=s,t.texture=e,!0)}updateElement(t){this.dirty=!0;const e=this.attributeBuffer;t.packAsQuad?this.packQuadAttributes(t,e.float32View,e.uint32View,t._attributeStart,t._textureId):this.packAttributes(t,e.float32View,e.uint32View,t._attributeStart,t._textureId)}break(t){const e=this._elements;if(!e[this.elementStart])return;let s=fh(),n=s.textures;n.clear();const o=e[this.elementStart];let r=uh(o.blendMode,o.texture._source),l=o.topology;this.attributeSize*4>this.attributeBuffer.size&&this._resizeAttributeBuffer(this.attributeSize*4),this.indexSize>this.indexBuffer.length&&this._resizeIndexBuffer(this.indexSize);const h=this.attributeBuffer.float32View,d=this.attributeBuffer.uint32View,c=this.indexBuffer;let p=this._batchIndexSize,g=this._batchIndexStart,m="startBatch",y=[];const x=this.maxTextures;for(let w=this.elementStart;w<this.elementSize;++w){const k=e[w];e[w]=null;const B=k.texture._source,L=uh(k.blendMode,B),H=r!==L||l!==k.topology;if(B._batchTick===En&&!H){k._textureId=B._textureBindLocation,p+=k.indexSize,k.packAsQuad?(this.packQuadAttributes(k,h,d,k._attributeStart,k._textureId),this.packQuadIndex(c,k._indexStart,k._attributeStart/this.vertexSize)):(this.packAttributes(k,h,d,k._attributeStart,k._textureId),this.packIndex(k,c,k._indexStart,k._attributeStart/this.vertexSize)),k._batch=s,y.push(k);continue}B._batchTick=En,(n.count>=x||H)&&(this._finishBatch(s,g,p-g,n,r,l,t,m,y),m="renderBatch",g=p,r=L,l=k.topology,s=fh(),n=s.textures,n.clear(),y=[],++En),k._textureId=B._textureBindLocation=n.count,n.ids[B.uid]=n.count,n.textures[n.count++]=B,k._batch=s,y.push(k),p+=k.indexSize,k.packAsQuad?(this.packQuadAttributes(k,h,d,k._attributeStart,k._textureId),this.packQuadIndex(c,k._indexStart,k._attributeStart/this.vertexSize)):(this.packAttributes(k,h,d,k._attributeStart,k._textureId),this.packIndex(k,c,k._indexStart,k._attributeStart/this.vertexSize))}n.count>0&&(this._finishBatch(s,g,p-g,n,r,l,t,m,y),g=p,++En),this.elementStart=this.elementSize,this._batchIndexStart=g,this._batchIndexSize=p}_finishBatch(t,e,s,n,o,r,l,h,d){t.gpuBindGroup=null,t.bindGroup=null,t.action=h,t.batcher=this,t.textures=n,t.blendMode=o,t.topology=r,t.start=e,t.size=s,t.elements=d,++En,this.batches[this.batchIndex++]=t,l.add(t)}finish(t){this.break(t)}ensureAttributeBuffer(t){t*4<=this.attributeBuffer.size||this._resizeAttributeBuffer(t*4)}ensureIndexBuffer(t){t<=this.indexBuffer.length||this._resizeIndexBuffer(t)}_resizeAttributeBuffer(t){const e=Math.max(t,this.attributeBuffer.size*2),s=new ch(e);dh(this.attributeBuffer.rawBinaryData,s.rawBinaryData),this.attributeBuffer=s}_resizeIndexBuffer(t){const e=this.indexBuffer;let s=Math.max(t,e.length*1.5);s+=s%2;const n=s>65535?new Uint32Array(s):new Uint16Array(s);if(n.BYTES_PER_ELEMENT!==e.BYTES_PER_ELEMENT)for(let o=0;o<e.length;o++)n[o]=e[o];else dh(e.buffer,n.buffer);this.indexBuffer=n}packQuadIndex(t,e,s){t[e]=s+0,t[e+1]=s+1,t[e+2]=s+2,t[e+3]=s+0,t[e+4]=s+2,t[e+5]=s+3}packIndex(t,e,s,n){const o=t.indices,r=t.indexSize,l=t.indexOffset,h=t.attributeOffset;for(let d=0;d<r;d++)e[s++]=n+o[d+l]-h}destroy(t={}){var e;if(this.batches!==null){for(let s=0;s<this.batchIndex;s++)ph(this.batches[s]);this.batches=null,this.geometry.destroy(!0),this.geometry=null,t.shader&&((e=this.shader)==null||e.destroy(),this.shader=null);for(let s=0;s<this._elements.length;s++)this._elements[s]&&(this._elements[s]._batch=null);this._elements=null,this.indexBuffer=null,this.attributeBuffer.destroy(),this.attributeBuffer=null}}};Qd.defaultOptions={maxTextures:null,attributesInitialSize:4,indicesInitialSize:6};let em=Qd;var we=(i=>(i[i.MAP_READ=1]="MAP_READ",i[i.MAP_WRITE=2]="MAP_WRITE",i[i.COPY_SRC=4]="COPY_SRC",i[i.COPY_DST=8]="COPY_DST",i[i.INDEX=16]="INDEX",i[i.VERTEX=32]="VERTEX",i[i.UNIFORM=64]="UNIFORM",i[i.STORAGE=128]="STORAGE",i[i.INDIRECT=256]="INDIRECT",i[i.QUERY_RESOLVE=512]="QUERY_RESOLVE",i[i.STATIC=1024]="STATIC",i))(we||{});class ao extends as{constructor(t){let{data:e,size:s}=t;const{usage:n,label:o,shrinkToFit:r}=t;super(),this._gpuData=Object.create(null),this._gcLastUsed=-1,this.autoGarbageCollect=!0,this.uid=qt("buffer"),this._resourceType="buffer",this._resourceId=qt("resource"),this._touched=0,this._updateID=1,this._dataInt32=null,this.shrinkToFit=!0,this.destroyed=!1,e instanceof Array&&(e=new Float32Array(e)),this._data=e,s??(s=e==null?void 0:e.byteLength);const l=!!e;this.descriptor={size:s,usage:n,mappedAtCreation:l,label:o},this.shrinkToFit=r??!0}get data(){return this._data}set data(t){this.setDataWithSize(t,t.length,!0)}get dataInt32(){return this._dataInt32||(this._dataInt32=new Int32Array(this.data.buffer)),this._dataInt32}get static(){return!!(this.descriptor.usage&we.STATIC)}set static(t){t?this.descriptor.usage|=we.STATIC:this.descriptor.usage&=~we.STATIC}setDataWithSize(t,e,s){if(this._updateID++,this._updateSize=e*t.BYTES_PER_ELEMENT,this._data===t){s&&this.emit("update",this);return}const n=this._data;if(this._data=t,this._dataInt32=null,!n||n.length!==t.length){!this.shrinkToFit&&n&&t.byteLength<n.byteLength?s&&this.emit("update",this):(this.descriptor.size=t.byteLength,this._resourceId=qt("resource"),this.emit("change",this));return}s&&this.emit("update",this)}update(t){this._updateSize=t??this._updateSize,this._updateID++,this.emit("update",this)}unload(){var t;this.emit("unload",this);for(const e in this._gpuData)(t=this._gpuData[e])==null||t.destroy();this._gpuData=Object.create(null)}destroy(){this.destroyed=!0,this.unload(),this.emit("destroy",this),this.emit("change",this),this._data=null,this.descriptor=null,this.removeAllListeners()}}function tu(i,t){if(!(i instanceof ao)){let e=t?we.INDEX:we.VERTEX;i instanceof Array&&(t?(i=new Uint32Array(i),e=we.INDEX|we.COPY_DST):(i=new Float32Array(i),e=we.VERTEX|we.COPY_DST)),i=new ao({data:i,label:t?"index-mesh-buffer":"vertex-mesh-buffer",usage:e})}return i}function sm(i,t,e){const s=i.getAttribute(t);if(!s)return e.minX=0,e.minY=0,e.maxX=0,e.maxY=0,e;const n=s.buffer.data;let o=1/0,r=1/0,l=-1/0,h=-1/0;const d=n.BYTES_PER_ELEMENT,c=(s.offset||0)/d,p=(s.stride||8)/d;for(let g=c;g<n.length;g+=p){const m=n[g],y=n[g+1];m>l&&(l=m),y>h&&(h=y),m<o&&(o=m),y<r&&(r=y)}return e.minX=o,e.minY=r,e.maxX=l,e.maxY=h,e}function im(i){return(i instanceof ao||Array.isArray(i)||i.BYTES_PER_ELEMENT)&&(i={buffer:i}),i.buffer=tu(i.buffer,!1),i}class nm extends as{constructor(t={}){super(),this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this.uid=qt("geometry"),this._layoutKey=0,this.instanceCount=1,this._bounds=new Ne,this._boundsDirty=!0;const{attributes:e,indexBuffer:s,topology:n}=t;if(this.buffers=[],this.attributes={},e)for(const o in e)this.addAttribute(o,e[o]);this.instanceCount=t.instanceCount??1,s&&this.addIndex(s),this.topology=n||"triangle-list"}onBufferUpdate(){this._boundsDirty=!0,this.emit("update",this)}getAttribute(t){return this.attributes[t]}getIndex(){return this.indexBuffer}getBuffer(t){return this.getAttribute(t).buffer}getSize(){for(const t in this.attributes){const e=this.attributes[t];return e.buffer.data.length/(e.stride/4||e.size)}return 0}addAttribute(t,e){const s=im(e);this.buffers.indexOf(s.buffer)===-1&&(this.buffers.push(s.buffer),s.buffer.on("update",this.onBufferUpdate,this),s.buffer.on("change",this.onBufferUpdate,this)),this.attributes[t]=s}addIndex(t){this.indexBuffer=tu(t,!0),this.buffers.push(this.indexBuffer)}get bounds(){return this._boundsDirty?(this._boundsDirty=!1,sm(this,"aPosition",this._bounds)):this._bounds}unload(){var t;this.emit("unload",this);for(const e in this._gpuData)(t=this._gpuData[e])==null||t.destroy();this._gpuData=Object.create(null)}destroy(t=!1){var e;this.emit("destroy",this),this.removeAllListeners(),t&&this.buffers.forEach(s=>s.destroy()),this.unload(),(e=this.indexBuffer)==null||e.destroy(),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null}}const om=new Float32Array(1),rm=new Uint32Array(1);class am extends nm{constructor(){const e=new ao({data:om,label:"attribute-batch-buffer",usage:we.VERTEX|we.COPY_DST,shrinkToFit:!1}),s=new ao({data:rm,label:"index-batch-buffer",usage:we.INDEX|we.COPY_DST,shrinkToFit:!1}),n=24;super({attributes:{aPosition:{buffer:e,format:"float32x2",stride:n,offset:0},aUV:{buffer:e,format:"float32x2",stride:n,offset:8},aColor:{buffer:e,format:"unorm8x4",stride:n,offset:16},aTextureIdAndRound:{buffer:e,format:"uint16x2",stride:n,offset:20}},indexBuffer:s})}}function mh(i,t,e){if(i)for(const s in i){const n=s.toLocaleLowerCase(),o=t[n];if(o){let r=i[s];s==="header"&&(r=r.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),e&&o.push(`//----${e}----//`),o.push(r)}else xe(`${s} placement hook does not exist in shader`)}}const lm=/\{\{(.*?)\}\}/g;function gh(i){var s;const t={};return(((s=i.match(lm))==null?void 0:s.map(n=>n.replace(/[{()}]/g,"")))??[]).forEach(n=>{t[n]=[]}),t}function yh(i,t){let e;const s=/@in\s+([^;]+);/g;for(;(e=s.exec(i))!==null;)t.push(e[1])}function bh(i,t,e=!1){const s=[];yh(t,s),i.forEach(l=>{l.header&&yh(l.header,s)});const n=s;e&&n.sort();const o=n.map((l,h)=>` @location(${h}) ${l},`).join(`
26
- `);let r=t.replace(/@in\s+[^;]+;\s*/g,"");return r=r.replace("{{in}}",`
27
- ${o}
28
- `),r}function _h(i,t){let e;const s=/@out\s+([^;]+);/g;for(;(e=s.exec(i))!==null;)t.push(e[1])}function hm(i){const e=/\b(\w+)\s*:/g.exec(i);return e?e[1]:""}function cm(i){const t=/@.*?\s+/g;return i.replace(t,"")}function dm(i,t){const e=[];_h(t,e),i.forEach(h=>{h.header&&_h(h.header,e)});let s=0;const n=e.sort().map(h=>h.indexOf("builtin")>-1?h:`@location(${s++}) ${h}`).join(`,
29
- `),o=e.sort().map(h=>` var ${cm(h)};`).join(`
30
- `),r=`return VSOutput(
31
- ${e.sort().map(h=>` ${hm(h)}`).join(`,
32
- `)});`;let l=t.replace(/@out\s+[^;]+;\s*/g,"");return l=l.replace("{{struct}}",`
33
- ${n}
34
- `),l=l.replace("{{start}}",`
35
- ${o}
36
- `),l=l.replace("{{return}}",`
37
- ${r}
38
- `),l}function xh(i,t){let e=i;for(const s in t){const n=t[s];n.join(`
39
- `).length?e=e.replace(`{{${s}}}`,`//-----${s} START-----//
40
- ${n.join(`
41
- `)}
42
- //----${s} FINISH----//`):e=e.replace(`{{${s}}}`,"")}return e}const Ai=Object.create(null),qr=new Map;let um=0;function fm({template:i,bits:t}){const e=eu(i,t);if(Ai[e])return Ai[e];const{vertex:s,fragment:n}=mm(i,t);return Ai[e]=su(s,n,t),Ai[e]}function pm({template:i,bits:t}){const e=eu(i,t);return Ai[e]||(Ai[e]=su(i.vertex,i.fragment,t)),Ai[e]}function mm(i,t){const e=t.map(r=>r.vertex).filter(r=>!!r),s=t.map(r=>r.fragment).filter(r=>!!r);let n=bh(e,i.vertex,!0);n=dm(e,n);const o=bh(s,i.fragment,!0);return{vertex:n,fragment:o}}function eu(i,t){return t.map(e=>(qr.has(e)||qr.set(e,um++),qr.get(e))).sort((e,s)=>e-s).join("-")+i.vertex+i.fragment}function su(i,t,e){const s=gh(i),n=gh(t);return e.forEach(o=>{mh(o.vertex,s,o.name),mh(o.fragment,n,o.name)}),{vertex:xh(i,s),fragment:xh(t,n)}}const gm=`
43
- @in aPosition: vec2<f32>;
44
- @in aUV: vec2<f32>;
45
-
46
- @out @builtin(position) vPosition: vec4<f32>;
47
- @out vUV : vec2<f32>;
48
- @out vColor : vec4<f32>;
49
-
50
- {{header}}
51
-
52
- struct VSOutput {
53
- {{struct}}
54
- };
55
-
56
- @vertex
57
- fn main( {{in}} ) -> VSOutput {
58
-
59
- var worldTransformMatrix = globalUniforms.uWorldTransformMatrix;
60
- var modelMatrix = mat3x3<f32>(
61
- 1.0, 0.0, 0.0,
62
- 0.0, 1.0, 0.0,
63
- 0.0, 0.0, 1.0
64
- );
65
- var position = aPosition;
66
- var uv = aUV;
67
-
68
- {{start}}
69
-
70
- vColor = vec4<f32>(1., 1., 1., 1.);
71
-
72
- {{main}}
73
-
74
- vUV = uv;
75
-
76
- var modelViewProjectionMatrix = globalUniforms.uProjectionMatrix * worldTransformMatrix * modelMatrix;
77
-
78
- vPosition = vec4<f32>((modelViewProjectionMatrix * vec3<f32>(position, 1.0)).xy, 0.0, 1.0);
79
-
80
- vColor *= globalUniforms.uWorldColorAlpha;
81
-
82
- {{end}}
83
-
84
- {{return}}
85
- };
86
- `,ym=`
87
- @in vUV : vec2<f32>;
88
- @in vColor : vec4<f32>;
89
-
90
- {{header}}
91
-
92
- @fragment
93
- fn main(
94
- {{in}}
95
- ) -> @location(0) vec4<f32> {
96
-
97
- {{start}}
98
-
99
- var outColor:vec4<f32>;
100
-
101
- {{main}}
102
-
103
- var finalColor:vec4<f32> = outColor * vColor;
104
-
105
- {{end}}
106
-
107
- return finalColor;
108
- };
109
- `,bm=`
110
- in vec2 aPosition;
111
- in vec2 aUV;
112
-
113
- out vec4 vColor;
114
- out vec2 vUV;
115
-
116
- {{header}}
117
-
118
- void main(void){
119
-
120
- mat3 worldTransformMatrix = uWorldTransformMatrix;
121
- mat3 modelMatrix = mat3(
122
- 1.0, 0.0, 0.0,
123
- 0.0, 1.0, 0.0,
124
- 0.0, 0.0, 1.0
125
- );
126
- vec2 position = aPosition;
127
- vec2 uv = aUV;
128
-
129
- {{start}}
130
-
131
- vColor = vec4(1.);
132
-
133
- {{main}}
134
-
135
- vUV = uv;
136
-
137
- mat3 modelViewProjectionMatrix = uProjectionMatrix * worldTransformMatrix * modelMatrix;
138
-
139
- gl_Position = vec4((modelViewProjectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
140
-
141
- vColor *= uWorldColorAlpha;
142
-
143
- {{end}}
144
- }
145
- `,_m=`
146
-
147
- in vec4 vColor;
148
- in vec2 vUV;
149
-
150
- out vec4 finalColor;
151
-
152
- {{header}}
153
-
154
- void main(void) {
155
-
156
- {{start}}
157
-
158
- vec4 outColor;
159
-
160
- {{main}}
161
-
162
- finalColor = outColor * vColor;
163
-
164
- {{end}}
165
- }
166
- `,xm={name:"global-uniforms-bit",vertex:{header:`
167
- struct GlobalUniforms {
168
- uProjectionMatrix:mat3x3<f32>,
169
- uWorldTransformMatrix:mat3x3<f32>,
170
- uWorldColorAlpha: vec4<f32>,
171
- uResolution: vec2<f32>,
172
- }
173
-
174
- @group(0) @binding(0) var<uniform> globalUniforms : GlobalUniforms;
175
- `}},vm={name:"global-uniforms-bit",vertex:{header:`
176
- uniform mat3 uProjectionMatrix;
177
- uniform mat3 uWorldTransformMatrix;
178
- uniform vec4 uWorldColorAlpha;
179
- uniform vec2 uResolution;
180
- `}};function wm({bits:i,name:t}){const e=fm({template:{fragment:ym,vertex:gm},bits:[xm,...i]});return _r.from({name:t,vertex:{source:e.vertex,entryPoint:"main"},fragment:{source:e.fragment,entryPoint:"main"}})}function Sm({bits:i,name:t}){return new Pd({name:t,...pm({template:{vertex:bm,fragment:_m},bits:[vm,...i]})})}const km={name:"color-bit",vertex:{header:`
181
- @in aColor: vec4<f32>;
182
- `,main:`
183
- vColor *= vec4<f32>(aColor.rgb * aColor.a, aColor.a);
184
- `}},Tm={name:"color-bit",vertex:{header:`
185
- in vec4 aColor;
186
- `,main:`
187
- vColor *= vec4(aColor.rgb * aColor.a, aColor.a);
188
- `}},Vr={};function Cm(i){const t=[];if(i===1)t.push("@group(1) @binding(0) var textureSource1: texture_2d<f32>;"),t.push("@group(1) @binding(1) var textureSampler1: sampler;");else{let e=0;for(let s=0;s<i;s++)t.push(`@group(1) @binding(${e++}) var textureSource${s+1}: texture_2d<f32>;`),t.push(`@group(1) @binding(${e++}) var textureSampler${s+1}: sampler;`)}return t.join(`
189
- `)}function Am(i){const t=[];if(i===1)t.push("outColor = textureSampleGrad(textureSource1, textureSampler1, vUV, uvDx, uvDy);");else{t.push("switch vTextureId {");for(let e=0;e<i;e++)e===i-1?t.push(" default:{"):t.push(` case ${e}:{`),t.push(` outColor = textureSampleGrad(textureSource${e+1}, textureSampler${e+1}, vUV, uvDx, uvDy);`),t.push(" break;}");t.push("}")}return t.join(`
190
- `)}function Mm(i){return Vr[i]||(Vr[i]={name:"texture-batch-bit",vertex:{header:`
191
- @in aTextureIdAndRound: vec2<u32>;
192
- @out @interpolate(flat) vTextureId : u32;
193
- `,main:`
194
- vTextureId = aTextureIdAndRound.y;
195
- `,end:`
196
- if(aTextureIdAndRound.x == 1)
197
- {
198
- vPosition = vec4<f32>(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
199
- }
200
- `},fragment:{header:`
201
- @in @interpolate(flat) vTextureId: u32;
202
-
203
- ${Cm(i)}
204
- `,main:`
205
- var uvDx = dpdx(vUV);
206
- var uvDy = dpdy(vUV);
207
-
208
- ${Am(i)}
209
- `}}),Vr[i]}const Yr={};function Em(i){const t=[];for(let e=0;e<i;e++)e>0&&t.push("else"),e<i-1&&t.push(`if(vTextureId < ${e}.5)`),t.push("{"),t.push(` outColor = texture(uTextures[${e}], vUV);`),t.push("}");return t.join(`
210
- `)}function Pm(i){return Yr[i]||(Yr[i]={name:"texture-batch-bit",vertex:{header:`
211
- in vec2 aTextureIdAndRound;
212
- out float vTextureId;
213
-
214
- `,main:`
215
- vTextureId = aTextureIdAndRound.y;
216
- `,end:`
217
- if(aTextureIdAndRound.x == 1.)
218
- {
219
- gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
220
- }
221
- `},fragment:{header:`
222
- in float vTextureId;
223
-
224
- uniform sampler2D uTextures[${i}];
225
-
226
- `,main:`
227
-
228
- ${Em(i)}
229
- `}}),Yr[i]}const Im={name:"round-pixels-bit",vertex:{header:`
230
- fn roundPixels(position: vec2<f32>, targetSize: vec2<f32>) -> vec2<f32>
231
- {
232
- return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
233
- }
234
- `}},Lm={name:"round-pixels-bit",vertex:{header:`
235
- vec2 roundPixels(vec2 position, vec2 targetSize)
236
- {
237
- return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
238
- }
239
- `}},vh={};function Bm(i){let t=vh[i];if(t)return t;const e=new Int32Array(i);for(let s=0;s<i;s++)e[s]=s;return t=vh[i]=new Rd({uTextures:{value:e,type:"i32",size:i}},{isStatic:!0}),t}class wh extends bl{constructor(t){const e=Sm({name:"batch",bits:[Tm,Pm(t),Lm]}),s=wm({name:"batch",bits:[km,Mm(t),Im]});super({glProgram:e,gpuProgram:s,resources:{batchSamplers:Bm(t)}}),this.maxTextures=t}}let Pn=null;const iu=class nu extends em{constructor(t){super(t),this.geometry=new am,this.name=nu.extension.name,this.vertexSize=6,Pn??(Pn=new wh(t.maxTextures)),this.shader=Pn}packAttributes(t,e,s,n,o){const r=o<<16|t.roundPixels&65535,l=t.transform,h=l.a,d=l.b,c=l.c,p=l.d,g=l.tx,m=l.ty,{positions:y,uvs:x}=t,w=t.color,k=t.attributeOffset,E=k+t.attributeSize;for(let B=k;B<E;B++){const L=B*2,H=y[L],$=y[L+1];e[n++]=h*H+c*$+g,e[n++]=p*$+d*H+m,e[n++]=x[L],e[n++]=x[L+1],s[n++]=w,s[n++]=r}}packQuadAttributes(t,e,s,n,o){const r=t.texture,l=t.transform,h=l.a,d=l.b,c=l.c,p=l.d,g=l.tx,m=l.ty,y=t.bounds,x=y.maxX,w=y.minX,k=y.maxY,E=y.minY,B=r.uvs,L=t.color,H=o<<16|t.roundPixels&65535;e[n+0]=h*w+c*E+g,e[n+1]=p*E+d*w+m,e[n+2]=B.x0,e[n+3]=B.y0,s[n+4]=L,s[n+5]=H,e[n+6]=h*x+c*E+g,e[n+7]=p*E+d*x+m,e[n+8]=B.x1,e[n+9]=B.y1,s[n+10]=L,s[n+11]=H,e[n+12]=h*x+c*k+g,e[n+13]=p*k+d*x+m,e[n+14]=B.x2,e[n+15]=B.y2,s[n+16]=L,s[n+17]=H,e[n+18]=h*w+c*k+g,e[n+19]=p*k+d*w+m,e[n+20]=B.x3,e[n+21]=B.y3,s[n+22]=L,s[n+23]=H}_updateMaxTextures(t){this.shader.maxTextures!==t&&(Pn=new wh(t),this.shader=Pn)}destroy(){this.shader=null,super.destroy()}};iu.extension={type:[yt.Batcher],name:"default"};let Rm=iu;class fo{constructor(t){this.items=Object.create(null);const{renderer:e,type:s,onUnload:n,priority:o,name:r}=t;this._renderer=e,e.gc.addResourceHash(this,"items",s,o??0),this._onUnload=n,this.name=r}add(t){return this.items[t.uid]?!1:(this.items[t.uid]=t,t.once("unload",this.remove,this),t._gcLastUsed=this._renderer.gc.now,!0)}remove(t,...e){var n;if(!this.items[t.uid])return;const s=t._gpuData[this._renderer.uid];s&&((n=this._onUnload)==null||n.call(this,t,...e),s.destroy(),t._gpuData[this._renderer.uid]=null,this.items[t.uid]=null)}removeAll(...t){Object.values(this.items).forEach(e=>e&&this.remove(e,...t))}destroy(...t){this.removeAll(...t),this.items=Object.create(null),this._renderer=null,this._onUnload=null}}function $m(i,t,e,s,n,o,r,l=null){let h=0;e*=t,n*=o;const d=l.a,c=l.b,p=l.c,g=l.d,m=l.tx,y=l.ty;for(;h<r;){const x=i[e],w=i[e+1];s[n]=d*x+p*w+m,s[n+1]=c*x+g*w+y,n+=o,e+=t,h++}}function Dm(i,t,e,s){let n=0;for(t*=e;n<s;)i[t]=0,i[t+1]=0,t+=e,n++}function ou(i,t,e,s,n){const o=t.a,r=t.b,l=t.c,h=t.d,d=t.tx,c=t.ty;e||(e=0),s||(s=2),n||(n=i.length/s-e);let p=e*s;for(let g=0;g<n;g++){const m=i[p],y=i[p+1];i[p]=o*m+l*y+d,i[p+1]=r*m+h*y+c,p+=s}}const zm=new wt;class wl{constructor(){this.packAsQuad=!1,this.batcherName="default",this.topology="triangle-list",this.applyTransform=!0,this.roundPixels=0,this._batcher=null,this._batch=null}get uvs(){return this.geometryData.uvs}get positions(){return this.geometryData.vertices}get indices(){return this.geometryData.indices}get blendMode(){return this.renderable&&this.applyTransform?this.renderable.groupBlendMode:"normal"}get color(){const t=this.baseColor,e=t>>16|t&65280|(t&255)<<16,s=this.renderable;return s?hd(e,s.groupColor)+(this.alpha*s.groupAlpha*255<<24):e+(this.alpha*255<<24)}get transform(){var t;return((t=this.renderable)==null?void 0:t.groupTransform)||zm}copyTo(t){t.indexOffset=this.indexOffset,t.indexSize=this.indexSize,t.attributeOffset=this.attributeOffset,t.attributeSize=this.attributeSize,t.baseColor=this.baseColor,t.alpha=this.alpha,t.texture=this.texture,t.geometryData=this.geometryData,t.topology=this.topology}reset(){this.applyTransform=!0,this.renderable=null,this.topology="triangle-list"}destroy(){this.renderable=null,this.texture=null,this.geometryData=null,this._batcher=null,this._batch=null}}const lo={extension:{type:yt.ShapeBuilder,name:"circle"},build(i,t){let e,s,n,o,r,l;if(i.type==="circle"){const L=i;if(r=l=L.radius,r<=0)return!1;e=L.x,s=L.y,n=o=0}else if(i.type==="ellipse"){const L=i;if(r=L.halfWidth,l=L.halfHeight,r<=0||l<=0)return!1;e=L.x,s=L.y,n=o=0}else{const L=i,H=L.width/2,$=L.height/2;e=L.x+H,s=L.y+$,r=l=Math.max(0,Math.min(L.radius,Math.min(H,$))),n=H-r,o=$-l}if(n<0||o<0)return!1;const h=Math.ceil(2.3*Math.sqrt(r+l)),d=h*8+(n?4:0)+(o?4:0);if(d===0)return!1;if(h===0)return t[0]=t[6]=e+n,t[1]=t[3]=s+o,t[2]=t[4]=e-n,t[5]=t[7]=s-o,!0;let c=0,p=h*4+(n?2:0)+2,g=p,m=d,y=n+r,x=o,w=e+y,k=e-y,E=s+x;if(t[c++]=w,t[c++]=E,t[--p]=E,t[--p]=k,o){const L=s-x;t[g++]=k,t[g++]=L,t[--m]=L,t[--m]=w}for(let L=1;L<h;L++){const H=Math.PI/2*(L/h),$=n+Math.cos(H)*r,G=o+Math.sin(H)*l,tt=e+$,Z=e-$,X=s+G,Q=s-G;t[c++]=tt,t[c++]=X,t[--p]=X,t[--p]=Z,t[g++]=Z,t[g++]=Q,t[--m]=Q,t[--m]=tt}y=n,x=o+l,w=e+y,k=e-y,E=s+x;const B=s-x;return t[c++]=w,t[c++]=E,t[--m]=B,t[--m]=w,n&&(t[c++]=k,t[c++]=E,t[--m]=B,t[--m]=k),!0},triangulate(i,t,e,s,n,o){if(i.length===0)return;let r=0,l=0;for(let c=0;c<i.length;c+=2)r+=i[c],l+=i[c+1];r/=i.length/2,l/=i.length/2;let h=s;t[h*e]=r,t[h*e+1]=l;const d=h++;for(let c=0;c<i.length;c+=2)t[h*e]=i[c],t[h*e+1]=i[c+1],c>0&&(n[o++]=h,n[o++]=d,n[o++]=h-1),h++;n[o++]=d+1,n[o++]=d,n[o++]=h-1}},Fm={...lo,extension:{...lo.extension,name:"ellipse"}},Nm={...lo,extension:{...lo.extension,name:"roundedRectangle"}},ru=1e-4,Sh=1e-4;function Gm(i){const t=i.length;if(t<6)return 1;let e=0;for(let s=0,n=i[t-2],o=i[t-1];s<t;s+=2){const r=i[s],l=i[s+1];e+=(r-n)*(l+o),n=r,o=l}return e<0?-1:1}function kh(i,t,e,s,n,o,r,l){const h=i-e*n,d=t-s*n,c=i+e*o,p=t+s*o;let g,m;r?(g=s,m=-e):(g=-s,m=e);const y=h+g,x=d+m,w=c+g,k=p+m;return l.push(y,x),l.push(w,k),2}function Li(i,t,e,s,n,o,r,l){const h=e-i,d=s-t;let c=Math.atan2(h,d),p=Math.atan2(n-i,o-t);l&&c<p?c+=Math.PI*2:!l&&c>p&&(p+=Math.PI*2);let g=c;const m=p-c,y=Math.abs(m),x=Math.sqrt(h*h+d*d),w=(15*y*Math.sqrt(x)/Math.PI>>0)+1,k=m/w;if(g+=k,l){r.push(i,t),r.push(e,s);for(let E=1,B=g;E<w;E++,B+=k)r.push(i,t),r.push(i+Math.sin(B)*x,t+Math.cos(B)*x);r.push(i,t),r.push(n,o)}else{r.push(e,s),r.push(i,t);for(let E=1,B=g;E<w;E++,B+=k)r.push(i+Math.sin(B)*x,t+Math.cos(B)*x),r.push(i,t);r.push(n,o),r.push(i,t)}return w*2}function Wm(i,t,e,s,n,o){const r=ru;if(i.length===0)return;const l=t;let h=l.alignment;if(t.alignment!==.5){let rt=Gm(i);h=(h-.5)*rt+.5}const d=new pe(i[0],i[1]),c=new pe(i[i.length-2],i[i.length-1]),p=s,g=Math.abs(d.x-c.x)<r&&Math.abs(d.y-c.y)<r;if(p){i=i.slice(),g&&(i.pop(),i.pop(),c.set(i[i.length-2],i[i.length-1]));const rt=(d.x+c.x)*.5,bt=(c.y+d.y)*.5;i.unshift(rt,bt),i.push(rt,bt)}const m=n,y=i.length/2;let x=i.length;const w=m.length/2,k=l.width/2,E=k*k,B=l.miterLimit*l.miterLimit;let L=i[0],H=i[1],$=i[2],G=i[3],tt=0,Z=0,X=-(H-G),Q=L-$,ot=0,at=0,lt=Math.sqrt(X*X+Q*Q);X/=lt,Q/=lt,X*=k,Q*=k;const Bt=h,et=(1-Bt)*2,it=Bt*2;p||(l.cap==="round"?x+=Li(L-X*(et-it)*.5,H-Q*(et-it)*.5,L-X*et,H-Q*et,L+X*it,H+Q*it,m,!0)+2:l.cap==="square"&&(x+=kh(L,H,X,Q,et,it,!0,m))),m.push(L-X*et,H-Q*et),m.push(L+X*it,H+Q*it);for(let rt=1;rt<y-1;++rt){L=i[(rt-1)*2],H=i[(rt-1)*2+1],$=i[rt*2],G=i[rt*2+1],tt=i[(rt+1)*2],Z=i[(rt+1)*2+1],X=-(H-G),Q=L-$,lt=Math.sqrt(X*X+Q*Q),X/=lt,Q/=lt,X*=k,Q*=k,ot=-(G-Z),at=$-tt,lt=Math.sqrt(ot*ot+at*at),ot/=lt,at/=lt,ot*=k,at*=k;const bt=$-L,At=H-G,It=$-tt,ut=Z-G,Gt=bt*It+At*ut,Xt=At*It-ut*bt,Te=Xt<0;if(Math.abs(Xt)<.001*Math.abs(Gt)){m.push($-X*et,G-Q*et),m.push($+X*it,G+Q*it),Gt>=0&&(l.join==="round"?x+=Li($,G,$-X*et,G-Q*et,$-ot*et,G-at*et,m,!1)+4:x+=2,m.push($-ot*it,G-at*it),m.push($+ot*et,G+at*et));continue}const Vt=(-X+L)*(-Q+G)-(-X+$)*(-Q+H),Ie=(-ot+tt)*(-at+G)-(-ot+$)*(-at+Z),We=(bt*Ie-It*Vt)/Xt,ve=(ut*Vt-At*Ie)/Xt,Zi=(We-$)*(We-$)+(ve-G)*(ve-G),je=$+(We-$)*et,Xe=G+(ve-G)*et,Oe=$-(We-$)*it,Ze=G-(ve-G)*it,Sn=Math.min(bt*bt+At*At,It*It+ut*ut),kn=Te?et:it,wr=Sn+kn*kn*E;Zi<=wr?l.join==="bevel"||Zi/E>B?(Te?(m.push(je,Xe),m.push($+X*it,G+Q*it),m.push(je,Xe),m.push($+ot*it,G+at*it)):(m.push($-X*et,G-Q*et),m.push(Oe,Ze),m.push($-ot*et,G-at*et),m.push(Oe,Ze)),x+=2):l.join==="round"?Te?(m.push(je,Xe),m.push($+X*it,G+Q*it),x+=Li($,G,$+X*it,G+Q*it,$+ot*it,G+at*it,m,!0)+4,m.push(je,Xe),m.push($+ot*it,G+at*it)):(m.push($-X*et,G-Q*et),m.push(Oe,Ze),x+=Li($,G,$-X*et,G-Q*et,$-ot*et,G-at*et,m,!1)+4,m.push($-ot*et,G-at*et),m.push(Oe,Ze)):(m.push(je,Xe),m.push(Oe,Ze)):(m.push($-X*et,G-Q*et),m.push($+X*it,G+Q*it),l.join==="round"?Te?x+=Li($,G,$+X*it,G+Q*it,$+ot*it,G+at*it,m,!0)+2:x+=Li($,G,$-X*et,G-Q*et,$-ot*et,G-at*et,m,!1)+2:l.join==="miter"&&Zi/E<=B&&(Te?(m.push(Oe,Ze),m.push(Oe,Ze)):(m.push(je,Xe),m.push(je,Xe)),x+=2),m.push($-ot*et,G-at*et),m.push($+ot*it,G+at*it),x+=2)}L=i[(y-2)*2],H=i[(y-2)*2+1],$=i[(y-1)*2],G=i[(y-1)*2+1],X=-(H-G),Q=L-$,lt=Math.sqrt(X*X+Q*Q),X/=lt,Q/=lt,X*=k,Q*=k,m.push($-X*et,G-Q*et),m.push($+X*it,G+Q*it),p||(l.cap==="round"?x+=Li($-X*(et-it)*.5,G-Q*(et-it)*.5,$-X*et,G-Q*et,$+X*it,G+Q*it,m,!1)+2:l.cap==="square"&&(x+=kh($,G,X,Q,et,it,!1,m)));const vt=Sh*Sh;for(let rt=w;rt<x+w-2;++rt)L=m[rt*2],H=m[rt*2+1],$=m[(rt+1)*2],G=m[(rt+1)*2+1],tt=m[(rt+2)*2],Z=m[(rt+2)*2+1],!(Math.abs(L*(G-Z)+$*(Z-H)+tt*(H-G))<vt)&&o.push(rt,rt+1,rt+2)}function Om(i,t,e,s){const n=ru;if(i.length===0)return;const o=i[0],r=i[1],l=i[i.length-2],h=i[i.length-1],d=t||Math.abs(o-l)<n&&Math.abs(r-h)<n,c=e,p=i.length/2,g=c.length/2;for(let m=0;m<p;m++)c.push(i[m*2]),c.push(i[m*2+1]);for(let m=0;m<p-1;m++)s.push(g+m,g+m+1);d&&s.push(g+p-1,g)}function au(i,t,e,s,n,o,r){const l=Ip(i,t,2);if(!l)return;for(let d=0;d<l.length;d+=3)o[r++]=l[d]+n,o[r++]=l[d+1]+n,o[r++]=l[d+2]+n;let h=n*s;for(let d=0;d<i.length;d+=2)e[h]=i[d],e[h+1]=i[d+1],h+=s}const Hm=[],Um={extension:{type:yt.ShapeBuilder,name:"polygon"},build(i,t){for(let e=0;e<i.points.length;e++)t[e]=i.points[e];return!0},triangulate(i,t,e,s,n,o){au(i,Hm,t,e,s,n,o)}},qm={extension:{type:yt.ShapeBuilder,name:"rectangle"},build(i,t){const e=i,s=e.x,n=e.y,o=e.width,r=e.height;return o>0&&r>0?(t[0]=s,t[1]=n,t[2]=s+o,t[3]=n,t[4]=s+o,t[5]=n+r,t[6]=s,t[7]=n+r,!0):!1},triangulate(i,t,e,s,n,o){let r=0;s*=e,t[s+r]=i[0],t[s+r+1]=i[1],r+=e,t[s+r]=i[2],t[s+r+1]=i[3],r+=e,t[s+r]=i[6],t[s+r+1]=i[7],r+=e,t[s+r]=i[4],t[s+r+1]=i[5],r+=e;const l=s/e;n[o++]=l,n[o++]=l+1,n[o++]=l+2,n[o++]=l+1,n[o++]=l+3,n[o++]=l+2}},Vm={extension:{type:yt.ShapeBuilder,name:"triangle"},build(i,t){return t[0]=i.x,t[1]=i.y,t[2]=i.x2,t[3]=i.y2,t[4]=i.x3,t[5]=i.y3,!0},triangulate(i,t,e,s,n,o){let r=0;s*=e,t[s+r]=i[0],t[s+r+1]=i[1],r+=e,t[s+r]=i[2],t[s+r+1]=i[3],r+=e,t[s+r]=i[4],t[s+r+1]=i[5];const l=s/e;n[o++]=l,n[o++]=l+1,n[o++]=l+2}},Th=[{offset:0,color:"white"},{offset:1,color:"black"}],Sl=class Oa{constructor(...t){this.uid=qt("fillGradient"),this._tick=0,this.type="linear",this.colorStops=[];let e=Ym(t);e={...e.type==="radial"?Oa.defaultRadialOptions:Oa.defaultLinearOptions,...Qc(e)},this._textureSize=e.textureSize,this._wrapMode=e.wrapMode,e.type==="radial"?(this.center=e.center,this.outerCenter=e.outerCenter??this.center,this.innerRadius=e.innerRadius,this.outerRadius=e.outerRadius,this.scale=e.scale,this.rotation=e.rotation):(this.start=e.start,this.end=e.end),this.textureSpace=e.textureSpace,this.type=e.type,e.colorStops.forEach(n=>{this.addColorStop(n.offset,n.color)})}addColorStop(t,e){return this.colorStops.push({offset:t,color:Kt.shared.setValue(e).toHexa()}),this}buildLinearGradient(){if(this.texture)return;let{x:t,y:e}=this.start,{x:s,y:n}=this.end,o=s-t,r=n-e;const l=o<0||r<0;if(this._wrapMode==="clamp-to-edge"){if(o<0){const w=t;t=s,s=w,o*=-1}if(r<0){const w=e;e=n,n=w,r*=-1}}const h=this.colorStops.length?this.colorStops:Th,d=this._textureSize,{canvas:c,context:p}=Ah(d,1),g=l?p.createLinearGradient(this._textureSize,0,0,0):p.createLinearGradient(0,0,this._textureSize,0);Ch(g,h),p.fillStyle=g,p.fillRect(0,0,d,1),this.texture=new $t({source:new or({resource:c,addressMode:this._wrapMode})});const m=Math.sqrt(o*o+r*r),y=Math.atan2(r,o),x=new wt;x.scale(m/d,1),x.rotate(y),x.translate(t,e),this.textureSpace==="local"&&x.scale(d,d),this.transform=x}buildGradient(){this.texture||this._tick++,this.type==="linear"?this.buildLinearGradient():this.buildRadialGradient()}buildRadialGradient(){if(this.texture)return;const t=this.colorStops.length?this.colorStops:Th,e=this._textureSize,{canvas:s,context:n}=Ah(e,e),{x:o,y:r}=this.center,{x:l,y:h}=this.outerCenter,d=this.innerRadius,c=this.outerRadius,p=l-c,g=h-c,m=e/(c*2),y=(o-p)*m,x=(r-g)*m,w=n.createRadialGradient(y,x,d*m,(l-p)*m,(h-g)*m,c*m);Ch(w,t),n.fillStyle=t[t.length-1].color,n.fillRect(0,0,e,e),n.fillStyle=w,n.translate(y,x),n.rotate(this.rotation),n.scale(1,this.scale),n.translate(-y,-x),n.fillRect(0,0,e,e),this.texture=new $t({source:new or({resource:s,addressMode:this._wrapMode})});const k=new wt;k.scale(1/m,1/m),k.translate(p,g),this.textureSpace==="local"&&k.scale(e,e),this.transform=k}destroy(){var t;(t=this.texture)==null||t.destroy(!0),this.texture=null,this.transform=null,this.colorStops=[],this.start=null,this.end=null,this.center=null,this.outerCenter=null}get styleKey(){return`fill-gradient-${this.uid}-${this._tick}`}};Sl.defaultLinearOptions={start:{x:0,y:0},end:{x:0,y:1},colorStops:[],textureSpace:"local",type:"linear",textureSize:256,wrapMode:"clamp-to-edge"};Sl.defaultRadialOptions={center:{x:.5,y:.5},innerRadius:0,outerRadius:.5,colorStops:[],scale:1,textureSpace:"local",type:"radial",textureSize:256,wrapMode:"clamp-to-edge"};let _s=Sl;function Ch(i,t){for(let e=0;e<t.length;e++){const s=t[e];i.addColorStop(s.offset,s.color)}}function Ah(i,t){const e=Pe.get().createCanvas(i,t),s=e.getContext("2d");return{canvas:e,context:s}}function Ym(i){let t=i[0]??{};return(typeof t=="number"||i[1])&&(Ct("8.5.2","use options object instead"),t={type:"linear",start:{x:i[0],y:i[1]},end:{x:i[2],y:i[3]},textureSpace:i[4],textureSize:i[5]??_s.defaultLinearOptions.textureSize}),t}const jm=new wt,Xm=new Yt;function Zm(i,t,e,s){const n=t.matrix?i.copyFrom(t.matrix).invert():i.identity();if(t.textureSpace==="local"){const r=e.getBounds(Xm);t.width&&r.pad(t.width);const{x:l,y:h}=r,d=1/r.width,c=1/r.height,p=-l*d,g=-h*c,m=n.a,y=n.b,x=n.c,w=n.d;n.a*=d,n.b*=d,n.c*=c,n.d*=c,n.tx=p*m+g*x+n.tx,n.ty=p*y+g*w+n.ty}else n.translate(t.texture.frame.x,t.texture.frame.y),n.scale(1/t.texture.source.width,1/t.texture.source.height);const o=t.texture.source.style;return!(t.fill instanceof _s)&&o.addressMode==="clamp-to-edge"&&(o.addressMode="repeat",o.update()),s&&n.append(jm.copyFrom(s).invert()),n}const xr={};jt.handleByMap(yt.ShapeBuilder,xr);jt.add(qm,Um,Vm,lo,Fm,Nm);const Km=new Yt,Qm=new wt;function Jm(i,t){const{geometryData:e,batches:s}=t;s.length=0,e.indices.length=0,e.vertices.length=0,e.uvs.length=0;for(let n=0;n<i.instructions.length;n++){const o=i.instructions[n];if(o.action==="texture")tg(o.data,s,e);else if(o.action==="fill"||o.action==="stroke"){const r=o.action==="stroke",l=o.data.path.shapePath,h=o.data.style,d=o.data.hole;r&&d&&Mh(d.shapePath,h,!0,s,e),d&&(l.shapePrimitives[l.shapePrimitives.length-1].holes=d.shapePath.shapePrimitives),Mh(l,h,r,s,e)}}}function tg(i,t,e){const s=[],n=xr.rectangle,o=Km;o.x=i.dx,o.y=i.dy,o.width=i.dw,o.height=i.dh;const r=i.transform;if(!n.build(o,s))return;const{vertices:l,uvs:h,indices:d}=e,c=d.length,p=l.length/2;r&&ou(s,r),n.triangulate(s,l,2,p,d,c);const g=i.image,m=g.uvs;h.push(m.x0,m.y0,m.x1,m.y1,m.x3,m.y3,m.x2,m.y2);const y=ke.get(wl);y.indexOffset=c,y.indexSize=d.length-c,y.attributeOffset=p,y.attributeSize=l.length/2-p,y.baseColor=i.style,y.alpha=i.alpha,y.texture=g,y.geometryData=e,t.push(y)}function Mh(i,t,e,s,n){const{vertices:o,uvs:r,indices:l}=n;i.shapePrimitives.forEach(({shape:h,transform:d,holes:c})=>{const p=[],g=xr[h.type];if(!g.build(h,p))return;const m=l.length,y=o.length/2;let x="triangle-list";if(d&&ou(p,d),e){const B=h.closePath??!0,L=t;L.pixelLine?(Om(p,B,o,l),x="line-list"):Wm(p,L,!1,B,o,l)}else if(c){const B=[],L=p.slice();eg(c).forEach($=>{B.push(L.length/2),L.push(...$)}),au(L,B,o,2,y,l,m)}else g.triangulate(p,o,2,y,l,m);const w=r.length/2,k=t.texture;if(k!==$t.WHITE){const B=Zm(Qm,t,h,d);$m(o,2,y,r,w,2,o.length/2-y,B)}else Dm(r,w,2,o.length/2-y);const E=ke.get(wl);E.indexOffset=m,E.indexSize=l.length-m,E.attributeOffset=y,E.attributeSize=o.length/2-y,E.baseColor=t.color,E.alpha=t.alpha,E.texture=k,E.geometryData=n,E.topology=x,s.push(E)})}function eg(i){const t=[];for(let e=0;e<i.length;e++){const s=i[e].shape,n=[];xr[s.type].build(s,n)&&t.push(n)}return t}class sg{constructor(){this.batches=[],this.geometryData={vertices:[],uvs:[],indices:[]}}reset(){this.batches&&this.batches.forEach(t=>{ke.return(t)}),this.graphicsData&&ke.return(this.graphicsData),this.isBatchable=!1,this.context=null,this.batches.length=0,this.geometryData.indices.length=0,this.geometryData.vertices.length=0,this.geometryData.uvs.length=0,this.graphicsData=null}destroy(){this.reset(),this.batches=null,this.geometryData=null}}class ig{constructor(){this.instructions=new ml}init(t){const e=t.maxTextures;this.batcher?this.batcher._updateMaxTextures(e):this.batcher=new Rm({maxTextures:e}),this.instructions.reset()}get geometry(){return Ct(Qu,"GraphicsContextRenderData#geometry is deprecated, please use batcher.geometry instead."),this.batcher.geometry}destroy(){this.batcher.destroy(),this.instructions.destroy(),this.batcher=null,this.instructions=null}}const kl=class Ha{constructor(t){this._renderer=t,this._managedContexts=new fo({renderer:t,type:"resource",name:"graphicsContext"})}init(t){Ha.defaultOptions.bezierSmoothness=(t==null?void 0:t.bezierSmoothness)??Ha.defaultOptions.bezierSmoothness}getContextRenderData(t){return t._gpuData[this._renderer.uid].graphicsData||this._initContextRenderData(t)}updateGpuContext(t){const e=!!t._gpuData[this._renderer.uid],s=t._gpuData[this._renderer.uid]||this._initContext(t);if(t.dirty||!e){e&&s.reset(),Jm(t,s);const n=t.batchMode;t.customShader||n==="no-batch"?s.isBatchable=!1:n==="auto"?s.isBatchable=s.geometryData.vertices.length<400:s.isBatchable=!0,t.dirty=!1}return s}getGpuContext(t){return t._gpuData[this._renderer.uid]||this._initContext(t)}_initContextRenderData(t){const e=ke.get(ig,{maxTextures:this._renderer.limits.maxBatchableTextures}),s=t._gpuData[this._renderer.uid],{batches:n,geometryData:o}=s;s.graphicsData=e;const r=o.vertices.length,l=o.indices.length;for(let p=0;p<n.length;p++)n[p].applyTransform=!1;const h=e.batcher;h.ensureAttributeBuffer(r),h.ensureIndexBuffer(l),h.begin();for(let p=0;p<n.length;p++){const g=n[p];h.add(g)}h.finish(e.instructions);const d=h.geometry;d.indexBuffer.setDataWithSize(h.indexBuffer,h.indexSize,!0),d.buffers[0].setDataWithSize(h.attributeBuffer.float32View,h.attributeSize,!0);const c=h.batches;for(let p=0;p<c.length;p++){const g=c[p];g.bindGroup=qp(g.textures.textures,g.textures.count,this._renderer.limits.maxBatchableTextures)}return e}_initContext(t){const e=new sg;return e.context=t,t._gpuData[this._renderer.uid]=e,this._managedContexts.add(t),e}destroy(){this._managedContexts.destroy(),this._renderer=null}};kl.extension={type:[yt.WebGLSystem,yt.WebGPUSystem],name:"graphicsContext"};kl.defaultOptions={bezierSmoothness:.5};let Tl=kl;const ng=8,Ao=11920929e-14,og=1;function lu(i,t,e,s,n,o,r,l,h,d){const p=Math.min(.99,Math.max(0,d??Tl.defaultOptions.bezierSmoothness));let g=(og-p)/1;return g*=g,rg(t,e,s,n,o,r,l,h,i,g),i}function rg(i,t,e,s,n,o,r,l,h,d){Ua(i,t,e,s,n,o,r,l,h,d,0),h.push(r,l)}function Ua(i,t,e,s,n,o,r,l,h,d,c){if(c>ng)return;const p=(i+e)/2,g=(t+s)/2,m=(e+n)/2,y=(s+o)/2,x=(n+r)/2,w=(o+l)/2,k=(p+m)/2,E=(g+y)/2,B=(m+x)/2,L=(y+w)/2,H=(k+B)/2,$=(E+L)/2;if(c>0){let G=r-i,tt=l-t;const Z=Math.abs((e-r)*tt-(s-l)*G),X=Math.abs((n-r)*tt-(o-l)*G);if(Z>Ao&&X>Ao){if((Z+X)*(Z+X)<=d*(G*G+tt*tt)){h.push(H,$);return}}else if(Z>Ao){if(Z*Z<=d*(G*G+tt*tt)){h.push(H,$);return}}else if(X>Ao){if(X*X<=d*(G*G+tt*tt)){h.push(H,$);return}}else if(G=H-(i+r)/2,tt=$-(t+l)/2,G*G+tt*tt<=d){h.push(H,$);return}}Ua(i,t,p,g,k,E,H,$,h,d,c+1),Ua(H,$,B,L,x,w,r,l,h,d,c+1)}const ag=8,lg=11920929e-14,hg=1;function cg(i,t,e,s,n,o,r,l){const d=Math.min(.99,Math.max(0,l??Tl.defaultOptions.bezierSmoothness));let c=(hg-d)/1;return c*=c,dg(t,e,s,n,o,r,i,c),i}function dg(i,t,e,s,n,o,r,l){qa(r,i,t,e,s,n,o,l,0),r.push(n,o)}function qa(i,t,e,s,n,o,r,l,h){if(h>ag)return;const d=(t+s)/2,c=(e+n)/2,p=(s+o)/2,g=(n+r)/2,m=(d+p)/2,y=(c+g)/2;let x=o-t,w=r-e;const k=Math.abs((s-o)*w-(n-r)*x);if(k>lg){if(k*k<=l*(x*x+w*w)){i.push(m,y);return}}else if(x=m-(t+o)/2,w=y-(e+r)/2,x*x+w*w<=l){i.push(m,y);return}qa(i,t,e,d,c,m,y,l,h+1),qa(i,m,y,p,g,o,r,l,h+1)}function hu(i,t,e,s,n,o,r,l){let h=Math.abs(n-o);(!r&&n>o||r&&o>n)&&(h=2*Math.PI-h),l||(l=Math.max(6,Math.floor(6*Math.pow(s,1/3)*(h/Math.PI)))),l=Math.max(l,3);let d=h/l,c=n;d*=r?-1:1;for(let p=0;p<l+1;p++){const g=Math.cos(c),m=Math.sin(c),y=t+g*s,x=e+m*s;i.push(y,x),c+=d}}function ug(i,t,e,s,n,o){const r=i[i.length-2],h=i[i.length-1]-e,d=r-t,c=n-e,p=s-t,g=Math.abs(h*p-d*c);if(g<1e-8||o===0){(i[i.length-2]!==t||i[i.length-1]!==e)&&i.push(t,e);return}const m=h*h+d*d,y=c*c+p*p,x=h*c+d*p,w=o*Math.sqrt(m)/g,k=o*Math.sqrt(y)/g,E=w*x/m,B=k*x/y,L=w*p+k*d,H=w*c+k*h,$=d*(k+E),G=h*(k+E),tt=p*(w+B),Z=c*(w+B),X=Math.atan2(G-H,$-L),Q=Math.atan2(Z-H,tt-L);hu(i,L+t,H+e,o,X,Q,d*c>p*h)}const so=Math.PI*2,jr={centerX:0,centerY:0,ang1:0,ang2:0},Xr=({x:i,y:t},e,s,n,o,r,l,h)=>{i*=e,t*=s;const d=n*i-o*t,c=o*i+n*t;return h.x=d+r,h.y=c+l,h};function fg(i,t){const e=t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),s=t===1.5707963267948966?.551915024494:e,n=Math.cos(i),o=Math.sin(i),r=Math.cos(i+t),l=Math.sin(i+t);return[{x:n-o*s,y:o+n*s},{x:r+l*s,y:l-r*s},{x:r,y:l}]}const Eh=(i,t,e,s)=>{const n=i*s-t*e<0?-1:1;let o=i*e+t*s;return o>1&&(o=1),o<-1&&(o=-1),n*Math.acos(o)},pg=(i,t,e,s,n,o,r,l,h,d,c,p,g)=>{const m=Math.pow(n,2),y=Math.pow(o,2),x=Math.pow(c,2),w=Math.pow(p,2);let k=m*y-m*w-y*x;k<0&&(k=0),k/=m*w+y*x,k=Math.sqrt(k)*(r===l?-1:1);const E=k*n/o*p,B=k*-o/n*c,L=d*E-h*B+(i+e)/2,H=h*E+d*B+(t+s)/2,$=(c-E)/n,G=(p-B)/o,tt=(-c-E)/n,Z=(-p-B)/o,X=Eh(1,0,$,G);let Q=Eh($,G,tt,Z);l===0&&Q>0&&(Q-=so),l===1&&Q<0&&(Q+=so),g.centerX=L,g.centerY=H,g.ang1=X,g.ang2=Q};function mg(i,t,e,s,n,o,r,l=0,h=0,d=0){if(o===0||r===0)return;const c=Math.sin(l*so/360),p=Math.cos(l*so/360),g=p*(t-s)/2+c*(e-n)/2,m=-c*(t-s)/2+p*(e-n)/2;if(g===0&&m===0)return;o=Math.abs(o),r=Math.abs(r);const y=Math.pow(g,2)/Math.pow(o,2)+Math.pow(m,2)/Math.pow(r,2);y>1&&(o*=Math.sqrt(y),r*=Math.sqrt(y)),pg(t,e,s,n,o,r,h,d,c,p,g,m,jr);let{ang1:x,ang2:w}=jr;const{centerX:k,centerY:E}=jr;let B=Math.abs(w)/(so/4);Math.abs(1-B)<1e-7&&(B=1);const L=Math.max(Math.ceil(B),1);w/=L;let H=i[i.length-2],$=i[i.length-1];const G={x:0,y:0};for(let tt=0;tt<L;tt++){const Z=fg(x,w),{x:X,y:Q}=Xr(Z[0],o,r,p,c,k,E,G),{x:ot,y:at}=Xr(Z[1],o,r,p,c,k,E,G),{x:lt,y:Bt}=Xr(Z[2],o,r,p,c,k,E,G);lu(i,H,$,X,Q,ot,at,lt,Bt),H=lt,$=Bt,x+=w}}function gg(i,t,e){const s=(r,l)=>{const h=l.x-r.x,d=l.y-r.y,c=Math.sqrt(h*h+d*d),p=h/c,g=d/c;return{len:c,nx:p,ny:g}},n=(r,l)=>{r===0?i.moveTo(l.x,l.y):i.lineTo(l.x,l.y)};let o=t[t.length-1];for(let r=0;r<t.length;r++){const l=t[r%t.length],h=l.radius??e;if(h<=0){n(r,l),o=l;continue}const d=t[(r+1)%t.length],c=s(l,o),p=s(l,d);if(c.len<1e-4||p.len<1e-4){n(r,l),o=l;continue}let g=Math.asin(c.nx*p.ny-c.ny*p.nx),m=1,y=!1;c.nx*p.nx-c.ny*-p.ny<0?g<0?g=Math.PI+g:(g=Math.PI-g,m=-1,y=!0):g>0&&(m=-1,y=!0);const x=g/2;let w,k=Math.abs(Math.cos(x)*h/Math.sin(x));k>Math.min(c.len/2,p.len/2)?(k=Math.min(c.len/2,p.len/2),w=Math.abs(k*Math.sin(x)/Math.cos(x))):w=h;const E=l.x+p.nx*k+-p.ny*w*m,B=l.y+p.ny*k+p.nx*w*m,L=Math.atan2(c.ny,c.nx)+Math.PI/2*m,H=Math.atan2(p.ny,p.nx)-Math.PI/2*m;r===0&&i.moveTo(E+Math.cos(L)*w,B+Math.sin(L)*w),i.arc(E,B,w,L,H,y),o=l}}function yg(i,t,e,s){const n=(l,h)=>Math.sqrt((l.x-h.x)**2+(l.y-h.y)**2),o=(l,h,d)=>({x:l.x+(h.x-l.x)*d,y:l.y+(h.y-l.y)*d}),r=t.length;for(let l=0;l<r;l++){const h=t[(l+1)%r],d=h.radius??e;if(d<=0){l===0?i.moveTo(h.x,h.y):i.lineTo(h.x,h.y);continue}const c=t[l],p=t[(l+2)%r],g=n(c,h);let m;if(g<1e-4)m=h;else{const w=Math.min(g/2,d);m=o(h,c,w/g)}const y=n(p,h);let x;if(y<1e-4)x=h;else{const w=Math.min(y/2,d);x=o(h,p,w/y)}l===0?i.moveTo(m.x,m.y):i.lineTo(m.x,m.y),i.quadraticCurveTo(h.x,h.y,x.x,x.y,s)}}const bg=new Yt;class _g{constructor(t){this.shapePrimitives=[],this._currentPoly=null,this._bounds=new Ne,this._graphicsPath2D=t,this.signed=t.checkForHoles}moveTo(t,e){return this.startPoly(t,e),this}lineTo(t,e){this._ensurePoly();const s=this._currentPoly.points,n=s[s.length-2],o=s[s.length-1];return(n!==t||o!==e)&&s.push(t,e),this}arc(t,e,s,n,o,r){this._ensurePoly(!1);const l=this._currentPoly.points;return hu(l,t,e,s,n,o,r),this}arcTo(t,e,s,n,o){this._ensurePoly();const r=this._currentPoly.points;return ug(r,t,e,s,n,o),this}arcToSvg(t,e,s,n,o,r,l){const h=this._currentPoly.points;return mg(h,this._currentPoly.lastX,this._currentPoly.lastY,r,l,t,e,s,n,o),this}bezierCurveTo(t,e,s,n,o,r,l){this._ensurePoly();const h=this._currentPoly;return lu(this._currentPoly.points,h.lastX,h.lastY,t,e,s,n,o,r,l),this}quadraticCurveTo(t,e,s,n,o){this._ensurePoly();const r=this._currentPoly;return cg(this._currentPoly.points,r.lastX,r.lastY,t,e,s,n,o),this}closePath(){return this.endPoly(!0),this}addPath(t,e){this.endPoly(),e&&!e.isIdentity()&&(t=t.clone(!0),t.transform(e));const s=this.shapePrimitives,n=s.length;for(let o=0;o<t.instructions.length;o++){const r=t.instructions[o];this[r.action](...r.data)}if(t.checkForHoles&&s.length-n>1){let o=null;for(let r=n;r<s.length;r++){const l=s[r];if(l.shape.type==="polygon"){const h=l.shape,d=o==null?void 0:o.shape;d&&d.containsPolygon(h)?(o.holes||(o.holes=[]),o.holes.push(l),s.copyWithin(r,r+1),s.length--,r--):o=l}}}return this}finish(t=!1){this.endPoly(t)}rect(t,e,s,n,o){return this.drawShape(new Yt(t,e,s,n),o),this}circle(t,e,s,n){return this.drawShape(new _l(t,e,s),n),this}poly(t,e,s){const n=new to(t);return n.closePath=e,this.drawShape(n,s),this}regularPoly(t,e,s,n,o=0,r){n=Math.max(n|0,3);const l=-1*Math.PI/2+o,h=Math.PI*2/n,d=[];for(let c=0;c<n;c++){const p=l-c*h;d.push(t+s*Math.cos(p),e+s*Math.sin(p))}return this.poly(d,!0,r),this}roundPoly(t,e,s,n,o,r=0,l){if(n=Math.max(n|0,3),o<=0)return this.regularPoly(t,e,s,n,r);const h=s*Math.sin(Math.PI/n)-.001;o=Math.min(o,h);const d=-1*Math.PI/2+r,c=Math.PI*2/n,p=(n-2)*Math.PI/n/2;for(let g=0;g<n;g++){const m=g*c+d,y=t+s*Math.cos(m),x=e+s*Math.sin(m),w=m+Math.PI+p,k=m-Math.PI-p,E=y+o*Math.cos(w),B=x+o*Math.sin(w),L=y+o*Math.cos(k),H=x+o*Math.sin(k);g===0?this.moveTo(E,B):this.lineTo(E,B),this.quadraticCurveTo(y,x,L,H,l)}return this.closePath()}roundShape(t,e,s=!1,n){return t.length<3?this:(s?yg(this,t,e,n):gg(this,t,e),this.closePath())}filletRect(t,e,s,n,o){if(o===0)return this.rect(t,e,s,n);const r=Math.min(s,n)/2,l=Math.min(r,Math.max(-r,o)),h=t+s,d=e+n,c=l<0?-l:0,p=Math.abs(l);return this.moveTo(t,e+p).arcTo(t+c,e+c,t+p,e,p).lineTo(h-p,e).arcTo(h-c,e+c,h,e+p,p).lineTo(h,d-p).arcTo(h-c,d-c,t+s-p,d,p).lineTo(t+p,d).arcTo(t+c,d-c,t,d-p,p).closePath()}chamferRect(t,e,s,n,o,r){if(o<=0)return this.rect(t,e,s,n);const l=Math.min(o,Math.min(s,n)/2),h=t+s,d=e+n,c=[t+l,e,h-l,e,h,e+l,h,d-l,h-l,d,t+l,d,t,d-l,t,e+l];for(let p=c.length-1;p>=2;p-=2)c[p]===c[p-2]&&c[p-1]===c[p-3]&&c.splice(p-1,2);return this.poly(c,!0,r)}ellipse(t,e,s,n,o){return this.drawShape(new xl(t,e,s,n),o),this}roundRect(t,e,s,n,o,r){return this.drawShape(new vl(t,e,s,n,o),r),this}drawShape(t,e){return this.endPoly(),this.shapePrimitives.push({shape:t,transform:e}),this}startPoly(t,e){let s=this._currentPoly;return s&&this.endPoly(),s=new to,s.points.push(t,e),this._currentPoly=s,this}endPoly(t=!1){const e=this._currentPoly;return e&&e.points.length>2&&(e.closePath=t,this.shapePrimitives.push({shape:e})),this._currentPoly=null,this}_ensurePoly(t=!0){if(!this._currentPoly&&(this._currentPoly=new to,t)){const e=this.shapePrimitives[this.shapePrimitives.length-1];if(e){let s=e.shape.x,n=e.shape.y;if(e.transform&&!e.transform.isIdentity()){const o=e.transform,r=s;s=o.a*s+o.c*n+o.tx,n=o.b*r+o.d*n+o.ty}this._currentPoly.points.push(s,n)}else this._currentPoly.points.push(0,0)}}buildPath(){const t=this._graphicsPath2D;this.shapePrimitives.length=0,this._currentPoly=null;for(let e=0;e<t.instructions.length;e++){const s=t.instructions[e];this[s.action](...s.data)}this.finish()}get bounds(){const t=this._bounds;t.clear();const e=this.shapePrimitives;for(let s=0;s<e.length;s++){const n=e[s],o=n.shape.getBounds(bg);n.transform?t.addRect(o,n.transform):t.addRect(o)}return t}}class bs{constructor(t,e=!1){this.instructions=[],this.uid=qt("graphicsPath"),this._dirty=!0,this.checkForHoles=e,typeof t=="string"?Wp(t,this):this.instructions=(t==null?void 0:t.slice())??[]}get shapePath(){return this._shapePath||(this._shapePath=new _g(this)),this._dirty&&(this._dirty=!1,this._shapePath.buildPath()),this._shapePath}addPath(t,e){return t=t.clone(),this.instructions.push({action:"addPath",data:[t,e]}),this._dirty=!0,this}arc(...t){return this.instructions.push({action:"arc",data:t}),this._dirty=!0,this}arcTo(...t){return this.instructions.push({action:"arcTo",data:t}),this._dirty=!0,this}arcToSvg(...t){return this.instructions.push({action:"arcToSvg",data:t}),this._dirty=!0,this}bezierCurveTo(...t){return this.instructions.push({action:"bezierCurveTo",data:t}),this._dirty=!0,this}bezierCurveToShort(t,e,s,n,o){const r=this.instructions[this.instructions.length-1],l=this.getLastPoint(pe.shared);let h=0,d=0;if(!r||r.action!=="bezierCurveTo")h=l.x,d=l.y;else{h=r.data[2],d=r.data[3];const c=l.x,p=l.y;h=c+(c-h),d=p+(p-d)}return this.instructions.push({action:"bezierCurveTo",data:[h,d,t,e,s,n,o]}),this._dirty=!0,this}closePath(){return this.instructions.push({action:"closePath",data:[]}),this._dirty=!0,this}ellipse(...t){return this.instructions.push({action:"ellipse",data:t}),this._dirty=!0,this}lineTo(...t){return this.instructions.push({action:"lineTo",data:t}),this._dirty=!0,this}moveTo(...t){return this.instructions.push({action:"moveTo",data:t}),this}quadraticCurveTo(...t){return this.instructions.push({action:"quadraticCurveTo",data:t}),this._dirty=!0,this}quadraticCurveToShort(t,e,s){const n=this.instructions[this.instructions.length-1],o=this.getLastPoint(pe.shared);let r=0,l=0;if(!n||n.action!=="quadraticCurveTo")r=o.x,l=o.y;else{r=n.data[0],l=n.data[1];const h=o.x,d=o.y;r=h+(h-r),l=d+(d-l)}return this.instructions.push({action:"quadraticCurveTo",data:[r,l,t,e,s]}),this._dirty=!0,this}rect(t,e,s,n,o){return this.instructions.push({action:"rect",data:[t,e,s,n,o]}),this._dirty=!0,this}circle(t,e,s,n){return this.instructions.push({action:"circle",data:[t,e,s,n]}),this._dirty=!0,this}roundRect(...t){return this.instructions.push({action:"roundRect",data:t}),this._dirty=!0,this}poly(...t){return this.instructions.push({action:"poly",data:t}),this._dirty=!0,this}regularPoly(...t){return this.instructions.push({action:"regularPoly",data:t}),this._dirty=!0,this}roundPoly(...t){return this.instructions.push({action:"roundPoly",data:t}),this._dirty=!0,this}roundShape(...t){return this.instructions.push({action:"roundShape",data:t}),this._dirty=!0,this}filletRect(...t){return this.instructions.push({action:"filletRect",data:t}),this._dirty=!0,this}chamferRect(...t){return this.instructions.push({action:"chamferRect",data:t}),this._dirty=!0,this}star(t,e,s,n,o,r,l){o||(o=n/2);const h=-1*Math.PI/2+r,d=s*2,c=Math.PI*2/d,p=[];for(let g=0;g<d;g++){const m=g%2?o:n,y=g*c+h;p.push(t+m*Math.cos(y),e+m*Math.sin(y))}return this.poly(p,!0,l),this}clone(t=!1){const e=new bs;if(e.checkForHoles=this.checkForHoles,!t)e.instructions=this.instructions.slice();else for(let s=0;s<this.instructions.length;s++){const n=this.instructions[s];e.instructions.push({action:n.action,data:n.data.slice()})}return e}clear(){return this.instructions.length=0,this._dirty=!0,this}transform(t){if(t.isIdentity())return this;const e=t.a,s=t.b,n=t.c,o=t.d,r=t.tx,l=t.ty;let h=0,d=0,c=0,p=0,g=0,m=0,y=0,x=0;for(let w=0;w<this.instructions.length;w++){const k=this.instructions[w],E=k.data;switch(k.action){case"moveTo":case"lineTo":h=E[0],d=E[1],E[0]=e*h+n*d+r,E[1]=s*h+o*d+l;break;case"bezierCurveTo":c=E[0],p=E[1],g=E[2],m=E[3],h=E[4],d=E[5],E[0]=e*c+n*p+r,E[1]=s*c+o*p+l,E[2]=e*g+n*m+r,E[3]=s*g+o*m+l,E[4]=e*h+n*d+r,E[5]=s*h+o*d+l;break;case"quadraticCurveTo":c=E[0],p=E[1],h=E[2],d=E[3],E[0]=e*c+n*p+r,E[1]=s*c+o*p+l,E[2]=e*h+n*d+r,E[3]=s*h+o*d+l;break;case"arcToSvg":h=E[5],d=E[6],y=E[0],x=E[1],E[0]=e*y+n*x,E[1]=s*y+o*x,E[5]=e*h+n*d+r,E[6]=s*h+o*d+l;break;case"circle":E[4]=In(E[3],t);break;case"rect":E[4]=In(E[4],t);break;case"ellipse":E[8]=In(E[8],t);break;case"roundRect":E[5]=In(E[5],t);break;case"addPath":E[0].transform(t);break;case"poly":E[2]=In(E[2],t);break;default:xe("unknown transform action",k.action);break}}return this._dirty=!0,this}get bounds(){return this.shapePath.bounds}getLastPoint(t){let e=this.instructions.length-1,s=this.instructions[e];if(!s)return t.x=0,t.y=0,t;for(;s.action==="closePath";){if(e--,e<0)return t.x=0,t.y=0,t;s=this.instructions[e]}switch(s.action){case"moveTo":case"lineTo":t.x=s.data[0],t.y=s.data[1];break;case"quadraticCurveTo":t.x=s.data[2],t.y=s.data[3];break;case"bezierCurveTo":t.x=s.data[4],t.y=s.data[5];break;case"arc":case"arcToSvg":t.x=s.data[5],t.y=s.data[6];break;case"addPath":s.data[0].getLastPoint(t);break}return t}}function In(i,t){return i?i.prepend(t):t.clone()}function Ht(i,t,e){const s=i.getAttribute(t);return s?Number(s):e}function xg(i,t){const e=i.querySelectorAll("defs");for(let s=0;s<e.length;s++){const n=e[s];for(let o=0;o<n.children.length;o++){const r=n.children[o];switch(r.nodeName.toLowerCase()){case"lineargradient":t.defs[r.id]=vg(r);break;case"radialgradient":t.defs[r.id]=wg();break}}}}function vg(i){const t=Ht(i,"x1",0),e=Ht(i,"y1",0),s=Ht(i,"x2",1),n=Ht(i,"y2",0),o=i.getAttribute("gradientUnits")||"objectBoundingBox",r=new _s(t,e,s,n,o==="objectBoundingBox"?"local":"global");for(let l=0;l<i.children.length;l++){const h=i.children[l],d=Ht(h,"offset",0),c=Kt.shared.setValue(h.getAttribute("stop-color")).toNumber();r.addColorStop(d,c)}return r}function wg(i){return xe("[SVG Parser] Radial gradients are not yet supported"),new _s(0,0,1,0)}function Ph(i){const t=i.match(/url\s*\(\s*['"]?\s*#([^'"\s)]+)\s*['"]?\s*\)/i);return t?t[1]:""}const Ih={fill:{type:"paint",default:0},"fill-opacity":{type:"number",default:1},stroke:{type:"paint",default:0},"stroke-width":{type:"number",default:1},"stroke-opacity":{type:"number",default:1},"stroke-linecap":{type:"string",default:"butt"},"stroke-linejoin":{type:"string",default:"miter"},"stroke-miterlimit":{type:"number",default:10},"stroke-dasharray":{type:"string",default:"none"},"stroke-dashoffset":{type:"number",default:0},opacity:{type:"number",default:1}};function cu(i,t){const e=i.getAttribute("style"),s={},n={},o={strokeStyle:s,fillStyle:n,useFill:!1,useStroke:!1};for(const r in Ih){const l=i.getAttribute(r);l&&Lh(t,o,r,l.trim())}if(e){const r=e.split(";");for(let l=0;l<r.length;l++){const h=r[l].trim(),[d,c]=h.split(":");Ih[d]&&Lh(t,o,d,c.trim())}}return{strokeStyle:o.useStroke?s:null,fillStyle:o.useFill?n:null,useFill:o.useFill,useStroke:o.useStroke}}function Lh(i,t,e,s){switch(e){case"stroke":if(s!=="none"){if(s.startsWith("url(")){const n=Ph(s);t.strokeStyle.fill=i.defs[n]}else t.strokeStyle.color=Kt.shared.setValue(s).toNumber();t.useStroke=!0}break;case"stroke-width":t.strokeStyle.width=Number(s);break;case"fill":if(s!=="none"){if(s.startsWith("url(")){const n=Ph(s);t.fillStyle.fill=i.defs[n]}else t.fillStyle.color=Kt.shared.setValue(s).toNumber();t.useFill=!0}break;case"fill-opacity":t.fillStyle.alpha=Number(s);break;case"stroke-opacity":t.strokeStyle.alpha=Number(s);break;case"opacity":t.fillStyle.alpha=Number(s),t.strokeStyle.alpha=Number(s);break}}function Sg(i){if(i.length<=2)return!0;const t=i.map(l=>l.area).sort((l,h)=>h-l),[e,s]=t,n=t[t.length-1],o=e/s,r=s/n;return!(o>3&&r<2)}function kg(i){return i.split(/(?=[Mm])/).filter(s=>s.trim().length>0)}function Tg(i){const t=i.match(/[-+]?[0-9]*\.?[0-9]+/g);if(!t||t.length<4)return 0;const e=t.map(Number),s=[],n=[];for(let c=0;c<e.length;c+=2)c+1<e.length&&(s.push(e[c]),n.push(e[c+1]));if(s.length===0||n.length===0)return 0;const o=Math.min(...s),r=Math.max(...s),l=Math.min(...n),h=Math.max(...n);return(r-o)*(h-l)}function Bh(i,t){const e=new bs(i,!1);for(const s of e.instructions)t.instructions.push(s)}function Cg(i,t){if(typeof i=="string"){const r=document.createElement("div");r.innerHTML=i.trim(),i=r.querySelector("svg")}const e={context:t,defs:{},path:new bs};xg(i,e);const s=i.children,{fillStyle:n,strokeStyle:o}=cu(i,e);for(let r=0;r<s.length;r++){const l=s[r];l.nodeName.toLowerCase()!=="defs"&&du(l,e,n,o)}return t}function du(i,t,e,s){const n=i.children,{fillStyle:o,strokeStyle:r}=cu(i,t);o&&e?e={...e,...o}:o&&(e=o),r&&s?s={...s,...r}:r&&(s=r);const l=!e&&!s;l&&(e={color:0});let h,d,c,p,g,m,y,x,w,k,E,B,L,H,$,G,tt;switch(i.nodeName.toLowerCase()){case"path":{H=i.getAttribute("d");const Z=i.getAttribute("fill-rule"),X=kg(H),Q=Z==="evenodd",ot=X.length>1;if(Q&&ot){const lt=X.map(et=>({path:et,area:Tg(et)}));if(lt.sort((et,it)=>it.area-et.area),X.length>3||!Sg(lt))for(let et=0;et<lt.length;et++){const it=lt[et],vt=et===0;t.context.beginPath();const rt=new bs(void 0,!0);Bh(it.path,rt),t.context.path(rt),vt?(e&&t.context.fill(e),s&&t.context.stroke(s)):t.context.cut()}else for(let et=0;et<lt.length;et++){const it=lt[et],vt=et%2===1;t.context.beginPath();const rt=new bs(void 0,!0);Bh(it.path,rt),t.context.path(rt),vt?t.context.cut():(e&&t.context.fill(e),s&&t.context.stroke(s))}}else{const lt=Z?Z==="evenodd":!0;$=new bs(H,lt),t.context.path($),e&&t.context.fill(e),s&&t.context.stroke(s)}break}case"circle":y=Ht(i,"cx",0),x=Ht(i,"cy",0),w=Ht(i,"r",0),t.context.ellipse(y,x,w,w),e&&t.context.fill(e),s&&t.context.stroke(s);break;case"rect":h=Ht(i,"x",0),d=Ht(i,"y",0),G=Ht(i,"width",0),tt=Ht(i,"height",0),k=Ht(i,"rx",0),E=Ht(i,"ry",0),k||E?t.context.roundRect(h,d,G,tt,k||E):t.context.rect(h,d,G,tt),e&&t.context.fill(e),s&&t.context.stroke(s);break;case"ellipse":y=Ht(i,"cx",0),x=Ht(i,"cy",0),k=Ht(i,"rx",0),E=Ht(i,"ry",0),t.context.beginPath(),t.context.ellipse(y,x,k,E),e&&t.context.fill(e),s&&t.context.stroke(s);break;case"line":c=Ht(i,"x1",0),p=Ht(i,"y1",0),g=Ht(i,"x2",0),m=Ht(i,"y2",0),t.context.beginPath(),t.context.moveTo(c,p),t.context.lineTo(g,m),s&&t.context.stroke(s);break;case"polygon":L=i.getAttribute("points"),B=L.match(/-?\d+/g).map(Z=>parseInt(Z,10)),t.context.poly(B,!0),e&&t.context.fill(e),s&&t.context.stroke(s);break;case"polyline":L=i.getAttribute("points"),B=L.match(/-?\d+/g).map(Z=>parseInt(Z,10)),t.context.poly(B,!1),s&&t.context.stroke(s);break;case"g":case"svg":break;default:{xe(`[SVG parser] <${i.nodeName}> elements unsupported`);break}}l&&(e=null);for(let Z=0;Z<n.length;Z++)du(n[Z],t,e,s)}const Rh={repeat:{addressModeU:"repeat",addressModeV:"repeat"},"repeat-x":{addressModeU:"repeat",addressModeV:"clamp-to-edge"},"repeat-y":{addressModeU:"clamp-to-edge",addressModeV:"repeat"},"no-repeat":{addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}};class vr{constructor(t,e){this.uid=qt("fillPattern"),this._tick=0,this.transform=new wt,this.texture=t,this.transform.scale(1/t.frame.width,1/t.frame.height),e&&(t.source.style.addressModeU=Rh[e].addressModeU,t.source.style.addressModeV=Rh[e].addressModeV)}setTransform(t){const e=this.texture;this.transform.copyFrom(t),this.transform.invert(),this.transform.scale(1/e.frame.width,1/e.frame.height),this._tick++}get texture(){return this._texture}set texture(t){this._texture!==t&&(this._texture=t,this._tick++)}get styleKey(){return`fill-pattern-${this.uid}-${this._tick}`}destroy(){this.texture.destroy(!0),this.texture=null}}function Ag(i){return Kt.isColorLike(i)}function $h(i){return i instanceof vr}function Dh(i){return i instanceof _s}function Mg(i){return i instanceof $t}function Eg(i,t,e){const s=Kt.shared.setValue(t??0);return i.color=s.toNumber(),i.alpha=s.alpha===1?e.alpha:s.alpha,i.texture=$t.WHITE,{...e,...i}}function Pg(i,t,e){return i.texture=t,{...e,...i}}function zh(i,t,e){return i.fill=t,i.color=16777215,i.texture=t.texture,i.matrix=t.transform,{...e,...i}}function Fh(i,t,e){return t.buildGradient(),i.fill=t,i.color=16777215,i.texture=t.texture,i.matrix=t.transform,i.textureSpace=t.textureSpace,{...e,...i}}function Ig(i,t){const e={...t,...i},s=Kt.shared.setValue(e.color);return e.alpha*=s.alpha,e.color=s.toNumber(),e}function qi(i,t){if(i==null)return null;const e={},s=i;return Ag(i)?Eg(e,i,t):Mg(i)?Pg(e,i,t):$h(i)?zh(e,i,t):Dh(i)?Fh(e,i,t):s.fill&&$h(s.fill)?zh(s,s.fill,t):s.fill&&Dh(s.fill)?Fh(s,s.fill,t):Ig(s,t)}function lr(i,t){const{width:e,alignment:s,miterLimit:n,cap:o,join:r,pixelLine:l,...h}=t,d=qi(i,h);return d?{width:e,alignment:s,miterLimit:n,cap:o,join:r,pixelLine:l,...d}:null}function Lg(i,t){let e=1;const s=i.shapePath.shapePrimitives;for(let n=0;n<s.length;n++){const o=s[n].shape;if(o.type!=="polygon")continue;const r=o.points,l=r.length;if(l<6)continue;const h=o.closePath;for(let d=0;d<l;d+=2){if(!h&&(d===0||d===l-2))continue;const c=(d-2+l)%l,p=(d+2)%l,g=r[c],m=r[c+1],y=r[d],x=r[d+1],w=r[p],k=r[p+1],E=g-y,B=m-x,L=w-y,H=k-x,$=E*E+B*B,G=L*L+H*H;if($<1e-12||G<1e-12)continue;let X=(E*L+B*H)/Math.sqrt($*G);X<-1?X=-1:X>1&&(X=1);const Q=Math.sqrt((1-X)*.5);if(Q<1e-6)continue;const ot=Math.min(1/Q,t);ot>e&&(e=ot)}}return e}const Bg=new pe,Nh=new wt,Cl=class es extends as{constructor(){super(...arguments),this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this.uid=qt("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this.destroyed=!1,this._activePath=new bs,this._transform=new wt,this._fillStyle={...es.defaultFillStyle},this._strokeStyle={...es.defaultStrokeStyle},this._stateStack=[],this._tick=0,this._bounds=new Ne,this._boundsDirty=!0}clone(){const t=new es;return t.batchMode=this.batchMode,t.instructions=this.instructions.slice(),t._activePath=this._activePath.clone(),t._transform=this._transform.clone(),t._fillStyle={...this._fillStyle},t._strokeStyle={...this._strokeStyle},t._stateStack=this._stateStack.slice(),t._bounds=this._bounds.clone(),t._boundsDirty=!0,t}get fillStyle(){return this._fillStyle}set fillStyle(t){this._fillStyle=qi(t,es.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(t){this._strokeStyle=lr(t,es.defaultStrokeStyle)}setFillStyle(t){return this._fillStyle=qi(t,es.defaultFillStyle),this}setStrokeStyle(t){return this._strokeStyle=qi(t,es.defaultStrokeStyle),this}texture(t,e,s,n,o,r){return this.instructions.push({action:"texture",data:{image:t,dx:s||0,dy:n||0,dw:o||t.frame.width,dh:r||t.frame.height,transform:this._transform.clone(),alpha:this._fillStyle.alpha,style:e||e===0?Kt.shared.setValue(e).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new bs,this}fill(t,e){let s;const n=this.instructions[this.instructions.length-1];return this._tick===0&&(n==null?void 0:n.action)==="stroke"?s=n.data.path:s=this._activePath.clone(),s?(t!=null&&(e!==void 0&&typeof t=="number"&&(Ct(Ut,"GraphicsContext.fill(color, alpha) is deprecated, use GraphicsContext.fill({ color, alpha }) instead"),t={color:t,alpha:e}),this._fillStyle=qi(t,es.defaultFillStyle)),this.instructions.push({action:"fill",data:{style:this.fillStyle,path:s}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}_initNextPathLocation(){const{x:t,y:e}=this._activePath.getLastPoint(pe.shared);this._activePath.clear(),this._activePath.moveTo(t,e)}stroke(t){let e;const s=this.instructions[this.instructions.length-1];return this._tick===0&&(s==null?void 0:s.action)==="fill"?e=s.data.path:e=this._activePath.clone(),e?(t!=null&&(this._strokeStyle=lr(t,es.defaultStrokeStyle)),this.instructions.push({action:"stroke",data:{style:this.strokeStyle,path:e}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}cut(){for(let t=0;t<2;t++){const e=this.instructions[this.instructions.length-1-t],s=this._activePath.clone();if(e&&(e.action==="stroke"||e.action==="fill"))if(e.data.hole)e.data.hole.addPath(s);else{e.data.hole=s;break}}return this._initNextPathLocation(),this}arc(t,e,s,n,o,r){this._tick++;const l=this._transform;return this._activePath.arc(l.a*t+l.c*e+l.tx,l.b*t+l.d*e+l.ty,s,n,o,r),this}arcTo(t,e,s,n,o){this._tick++;const r=this._transform;return this._activePath.arcTo(r.a*t+r.c*e+r.tx,r.b*t+r.d*e+r.ty,r.a*s+r.c*n+r.tx,r.b*s+r.d*n+r.ty,o),this}arcToSvg(t,e,s,n,o,r,l){this._tick++;const h=this._transform;return this._activePath.arcToSvg(t,e,s,n,o,h.a*r+h.c*l+h.tx,h.b*r+h.d*l+h.ty),this}bezierCurveTo(t,e,s,n,o,r,l){this._tick++;const h=this._transform;return this._activePath.bezierCurveTo(h.a*t+h.c*e+h.tx,h.b*t+h.d*e+h.ty,h.a*s+h.c*n+h.tx,h.b*s+h.d*n+h.ty,h.a*o+h.c*r+h.tx,h.b*o+h.d*r+h.ty,l),this}closePath(){var t;return this._tick++,(t=this._activePath)==null||t.closePath(),this}ellipse(t,e,s,n){return this._tick++,this._activePath.ellipse(t,e,s,n,this._transform.clone()),this}circle(t,e,s){return this._tick++,this._activePath.circle(t,e,s,this._transform.clone()),this}path(t){return this._tick++,this._activePath.addPath(t,this._transform.clone()),this}lineTo(t,e){this._tick++;const s=this._transform;return this._activePath.lineTo(s.a*t+s.c*e+s.tx,s.b*t+s.d*e+s.ty),this}moveTo(t,e){this._tick++;const s=this._transform,n=this._activePath.instructions,o=s.a*t+s.c*e+s.tx,r=s.b*t+s.d*e+s.ty;return n.length===1&&n[0].action==="moveTo"?(n[0].data[0]=o,n[0].data[1]=r,this):(this._activePath.moveTo(o,r),this)}quadraticCurveTo(t,e,s,n,o){this._tick++;const r=this._transform;return this._activePath.quadraticCurveTo(r.a*t+r.c*e+r.tx,r.b*t+r.d*e+r.ty,r.a*s+r.c*n+r.tx,r.b*s+r.d*n+r.ty,o),this}rect(t,e,s,n){return this._tick++,this._activePath.rect(t,e,s,n,this._transform.clone()),this}roundRect(t,e,s,n,o){return this._tick++,this._activePath.roundRect(t,e,s,n,o,this._transform.clone()),this}poly(t,e){return this._tick++,this._activePath.poly(t,e,this._transform.clone()),this}regularPoly(t,e,s,n,o=0,r){return this._tick++,this._activePath.regularPoly(t,e,s,n,o,r),this}roundPoly(t,e,s,n,o,r){return this._tick++,this._activePath.roundPoly(t,e,s,n,o,r),this}roundShape(t,e,s,n){return this._tick++,this._activePath.roundShape(t,e,s,n),this}filletRect(t,e,s,n,o){return this._tick++,this._activePath.filletRect(t,e,s,n,o),this}chamferRect(t,e,s,n,o,r){return this._tick++,this._activePath.chamferRect(t,e,s,n,o,r),this}star(t,e,s,n,o=0,r=0){return this._tick++,this._activePath.star(t,e,s,n,o,r,this._transform.clone()),this}svg(t){return this._tick++,Cg(t,this),this}restore(){const t=this._stateStack.pop();return t&&(this._transform=t.transform,this._fillStyle=t.fillStyle,this._strokeStyle=t.strokeStyle),this}save(){return this._stateStack.push({transform:this._transform.clone(),fillStyle:{...this._fillStyle},strokeStyle:{...this._strokeStyle}}),this}getTransform(){return this._transform}resetTransform(){return this._transform.identity(),this}rotate(t){return this._transform.rotate(t),this}scale(t,e=t){return this._transform.scale(t,e),this}setTransform(t,e,s,n,o,r){return t instanceof wt?(this._transform.set(t.a,t.b,t.c,t.d,t.tx,t.ty),this):(this._transform.set(t,e,s,n,o,r),this)}transform(t,e,s,n,o,r){return t instanceof wt?(this._transform.append(t),this):(Nh.set(t,e,s,n,o,r),this._transform.append(Nh),this)}translate(t,e=t){return this._transform.translate(t,e),this}clear(){return this._activePath.clear(),this.instructions.length=0,this.resetTransform(),this.onUpdate(),this}onUpdate(){this._boundsDirty=!0,this.dirty=!0,this.emit("update",this,16)}get bounds(){if(!this._boundsDirty)return this._bounds;this._boundsDirty=!1;const t=this._bounds;t.clear();for(let e=0;e<this.instructions.length;e++){const s=this.instructions[e],n=s.action;if(n==="fill"){const o=s.data;t.addBounds(o.path.bounds)}else if(n==="texture"){const o=s.data;t.addFrame(o.dx,o.dy,o.dx+o.dw,o.dy+o.dh,o.transform)}if(n==="stroke"){const o=s.data,r=o.style.alignment;let l=o.style.width*(1-r);o.style.join==="miter"&&(l*=Lg(o.path,o.style.miterLimit));const h=o.path.bounds;t.addFrame(h.minX-l,h.minY-l,h.maxX+l,h.maxY+l)}}return t.isValid||t.set(0,0,0,0),t}containsPoint(t){var n;if(!this.bounds.containsPoint(t.x,t.y))return!1;const e=this.instructions;let s=!1;for(let o=0;o<e.length;o++){const r=e[o],l=r.data,h=l.path;if(!r.action||!h)continue;const d=l.style,c=h.shapePath.shapePrimitives;for(let p=0;p<c.length;p++){const g=c[p].shape;if(!d||!g)continue;const m=c[p].transform,y=m?m.applyInverse(t,Bg):t;if(r.action==="fill")s=g.contains(y.x,y.y);else{const w=d;s=g.strokeContains(y.x,y.y,w.width,w.alignment)}const x=l.hole;if(x){const w=(n=x.shapePath)==null?void 0:n.shapePrimitives;if(w)for(let k=0;k<w.length;k++)w[k].shape.contains(y.x,y.y)&&(s=!1)}if(s)return!0}}return s}unload(){var t;this.emit("unload",this);for(const e in this._gpuData)(t=this._gpuData[e])==null||t.destroy();this._gpuData=Object.create(null)}destroy(t=!1){if(this.destroyed)return;if(this.destroyed=!0,this._stateStack.length=0,this._transform=null,this.unload(),this.emit("destroy",this),this.removeAllListeners(),typeof t=="boolean"?t:t==null?void 0:t.texture){const s=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._fillStyle.texture&&(this._fillStyle.fill&&"uid"in this._fillStyle.fill?this._fillStyle.fill.destroy():this._fillStyle.texture.destroy(s)),this._strokeStyle.texture&&(this._strokeStyle.fill&&"uid"in this._strokeStyle.fill?this._strokeStyle.fill.destroy():this._strokeStyle.texture.destroy(s))}this._fillStyle=null,this._strokeStyle=null,this.instructions=null,this._activePath=null,this._bounds=null,this._stateStack=null,this.customShader=null,this._transform=null}};Cl.defaultFillStyle={color:16777215,alpha:1,texture:$t.WHITE,matrix:null,fill:null,textureSpace:"local"};Cl.defaultStrokeStyle={width:1,color:16777215,alpha:1,alignment:.5,miterLimit:10,cap:"butt",join:"miter",texture:$t.WHITE,matrix:null,fill:null,textureSpace:"local",pixelLine:!1};let Ve=Cl;class Rg{constructor(){this.isBatchable=!1}reset(){this.isBatchable=!1,this.context=null,this.graphicsData&&(this.graphicsData.destroy(),this.graphicsData=null)}destroy(){this.reset()}}class $g{constructor(){this.instructions=new ml}init(){this.instructions.reset()}destroy(){this.instructions.destroy(),this.instructions=null}}const Al=class Va{constructor(t){this._renderer=t,this._managedContexts=new fo({renderer:t,type:"resource",name:"graphicsContext"})}init(t){Va.defaultOptions.bezierSmoothness=(t==null?void 0:t.bezierSmoothness)??Va.defaultOptions.bezierSmoothness}getContextRenderData(t){return this.getGpuContext(t).graphicsData||this._initContextRenderData(t)}updateGpuContext(t){const e=t._gpuData,s=!!e[this._renderer.uid],n=e[this._renderer.uid]||this._initContext(t);return(t.dirty||!s)&&(s&&n.reset(),n.isBatchable=!1,t.dirty=!1),n}getGpuContext(t){return t._gpuData[this._renderer.uid]||this._initContext(t)}_initContextRenderData(t){const e=new $g,s=this.getGpuContext(t);return s.graphicsData=e,e.init(),e}_initContext(t){const e=new Rg;return e.context=t,t._gpuData[this._renderer.uid]=e,this._managedContexts.add(t),e}destroy(){this._managedContexts.destroy(),this._renderer=null}};Al.extension={type:[yt.CanvasSystem],name:"graphicsContext"};Al.defaultOptions={bezierSmoothness:.5};let Dg=Al;class uu{constructor(t,e){this.state=Dd.for2d(),this.renderer=t,this._adaptor=e,this.renderer.runners.contextChange.add(this),this._managedGraphics=new fo({renderer:t,type:"renderable",priority:-1,name:"graphics"})}contextChange(){this._adaptor.contextChange(this.renderer)}validateRenderable(t){return!1}addRenderable(t,e){this._managedGraphics.add(t),this.renderer.renderPipes.batch.break(e),e.add(t)}updateRenderable(t){}execute(t){t.isRenderable&&this._adaptor.execute(this,t)}destroy(){this._managedGraphics.destroy(),this.renderer=null,this._adaptor.destroy(),this._adaptor=null}}uu.extension={type:[yt.CanvasPipes],name:"graphics"};function zg(i,t,e){const s=(i>>24&255)/255;t[e++]=(i&255)/255*s,t[e++]=(i>>8&255)/255*s,t[e++]=(i>>16&255)/255*s,t[e++]=s}class Fg{constructor(){this.batches=[],this.batched=!1}destroy(){this.batches.forEach(t=>{ke.return(t)}),this.batches.length=0}}class fu{constructor(t,e){this.state=Dd.for2d(),this.renderer=t,this._adaptor=e,this.renderer.runners.contextChange.add(this),this._managedGraphics=new fo({renderer:t,type:"renderable",priority:-1,name:"graphics"})}contextChange(){this._adaptor.contextChange(this.renderer)}validateRenderable(t){const e=t.context,s=!!t._gpuData,o=this.renderer.graphicsContext.updateGpuContext(e);return!!(o.isBatchable||s!==o.isBatchable)}addRenderable(t,e){const n=this.renderer.graphicsContext.updateGpuContext(t.context);t.didViewUpdate&&this._rebuild(t),n.isBatchable?this._addToBatcher(t,e):(this.renderer.renderPipes.batch.break(e),e.add(t))}updateRenderable(t){const s=this._getGpuDataForRenderable(t).batches;for(let n=0;n<s.length;n++){const o=s[n];o._batcher.updateElement(o)}}execute(t){if(!t.isRenderable)return;const e=this.renderer,s=t.context;if(!e.graphicsContext.getGpuContext(s).batches.length)return;const o=s.customShader||this._adaptor.shader;this.state.blendMode=t.groupBlendMode;const r=o.resources.localUniforms.uniforms;r.uTransformMatrix=t.groupTransform,r.uRound=e._roundPixels|t._roundPixels,zg(t.groupColorAlpha,r.uColor,0),this._adaptor.execute(this,t)}_rebuild(t){const e=this._getGpuDataForRenderable(t),n=this.renderer.graphicsContext.updateGpuContext(t.context);e.destroy(),n.isBatchable&&this._updateBatchesForRenderable(t,e)}_addToBatcher(t,e){const s=this.renderer.renderPipes.batch,n=this._getGpuDataForRenderable(t).batches;for(let o=0;o<n.length;o++){const r=n[o];s.addToBatch(r,e)}}_getGpuDataForRenderable(t){return t._gpuData[this.renderer.uid]||this._initGpuDataForRenderable(t)}_initGpuDataForRenderable(t){const e=new Fg;return t._gpuData[this.renderer.uid]=e,this._managedGraphics.add(t),e}_updateBatchesForRenderable(t,e){const s=t.context,o=this.renderer.graphicsContext.getGpuContext(s),r=this.renderer._roundPixels|t._roundPixels;e.batches=o.batches.map(l=>{const h=ke.get(wl);return l.copyTo(h),h.renderable=t,h.roundPixels=r,h})}destroy(){this._managedGraphics.destroy(),this.renderer=null,this._adaptor.destroy(),this._adaptor=null,this.state=null}}fu.extension={type:[yt.WebGLPipes,yt.WebGPUPipes],name:"graphics"};jt.add(uu);jt.add(fu);jt.add(Dg);jt.add(Tl);class Wt extends gl{constructor(t){t instanceof Ve&&(t={context:t});const{context:e,roundPixels:s,...n}=t||{};super({label:"Graphics",...n}),this.renderPipeId="graphics",e?this.context=e:(this.context=this._ownedContext=new Ve,this.context.autoGarbageCollect=this.autoGarbageCollect),this.didViewUpdate=!0,this.allowChildren=!1,this.roundPixels=s??!1}set context(t){t!==this._context&&(this._context&&(this._context.off("update",this.onViewUpdate,this),this._context.off("unload",this.unload,this)),this._context=t,this._context.on("update",this.onViewUpdate,this),this._context.on("unload",this.unload,this),this.onViewUpdate())}get context(){return this._context}get bounds(){return this._context.bounds}updateBounds(){}containsPoint(t){return this._context.containsPoint(t)}destroy(t){this._ownedContext&&!t?this._ownedContext.destroy(t):(t===!0||(t==null?void 0:t.context)===!0)&&this._context.destroy(t),this._ownedContext=null,this._context=null,super.destroy(t)}_onTouch(t){this._gcLastUsed=t,this._context._gcLastUsed=t}_callContextMethod(t,e){return this.context[t](...e),this}setFillStyle(...t){return this._callContextMethod("setFillStyle",t)}setStrokeStyle(...t){return this._callContextMethod("setStrokeStyle",t)}fill(...t){return this._callContextMethod("fill",t)}stroke(...t){return this._callContextMethod("stroke",t)}texture(...t){return this._callContextMethod("texture",t)}beginPath(){return this._callContextMethod("beginPath",[])}cut(){return this._callContextMethod("cut",[])}arc(...t){return this._callContextMethod("arc",t)}arcTo(...t){return this._callContextMethod("arcTo",t)}arcToSvg(...t){return this._callContextMethod("arcToSvg",t)}bezierCurveTo(...t){return this._callContextMethod("bezierCurveTo",t)}closePath(){return this._callContextMethod("closePath",[])}ellipse(...t){return this._callContextMethod("ellipse",t)}circle(...t){return this._callContextMethod("circle",t)}path(...t){return this._callContextMethod("path",t)}lineTo(...t){return this._callContextMethod("lineTo",t)}moveTo(...t){return this._callContextMethod("moveTo",t)}quadraticCurveTo(...t){return this._callContextMethod("quadraticCurveTo",t)}rect(...t){return this._callContextMethod("rect",t)}roundRect(...t){return this._callContextMethod("roundRect",t)}poly(...t){return this._callContextMethod("poly",t)}regularPoly(...t){return this._callContextMethod("regularPoly",t)}roundPoly(...t){return this._callContextMethod("roundPoly",t)}roundShape(...t){return this._callContextMethod("roundShape",t)}filletRect(...t){return this._callContextMethod("filletRect",t)}chamferRect(...t){return this._callContextMethod("chamferRect",t)}star(...t){return this._callContextMethod("star",t)}svg(...t){return this._callContextMethod("svg",t)}restore(...t){return this._callContextMethod("restore",t)}save(){return this._callContextMethod("save",[])}getTransform(){return this.context.getTransform()}resetTransform(){return this._callContextMethod("resetTransform",[])}rotateTransform(...t){return this._callContextMethod("rotate",t)}scaleTransform(...t){return this._callContextMethod("scale",t)}setTransform(...t){return this._callContextMethod("setTransform",t)}transform(...t){return this._callContextMethod("transform",t)}translateTransform(...t){return this._callContextMethod("translate",t)}clear(){return this._callContextMethod("clear",[])}get fillStyle(){return this._context.fillStyle}set fillStyle(t){this._context.fillStyle=t}get strokeStyle(){return this._context.strokeStyle}set strokeStyle(t){this._context.strokeStyle=t}clone(t=!1){return t?new Wt(this._context.clone()):(this._ownedContext=null,new Wt(this._context))}lineStyle(t,e,s){Ct(Ut,"Graphics#lineStyle is no longer needed. Use Graphics#setStrokeStyle to set the stroke style.");const n={};return t&&(n.width=t),e&&(n.color=e),s&&(n.alpha=s),this.context.strokeStyle=n,this}beginFill(t,e){Ct(Ut,"Graphics#beginFill is no longer needed. Use Graphics#fill to fill the shape with the desired style.");const s={};return t!==void 0&&(s.color=t),e!==void 0&&(s.alpha=e),this.context.fillStyle=s,this}endFill(){Ct(Ut,"Graphics#endFill is no longer needed. Use Graphics#fill to fill the shape with the desired style."),this.context.fill();const t=this.context.strokeStyle;return(t.width!==Ve.defaultStrokeStyle.width||t.color!==Ve.defaultStrokeStyle.color||t.alpha!==Ve.defaultStrokeStyle.alpha)&&this.context.stroke(),this}drawCircle(...t){return Ct(Ut,"Graphics#drawCircle has been renamed to Graphics#circle"),this._callContextMethod("circle",t)}drawEllipse(...t){return Ct(Ut,"Graphics#drawEllipse has been renamed to Graphics#ellipse"),this._callContextMethod("ellipse",t)}drawPolygon(...t){return Ct(Ut,"Graphics#drawPolygon has been renamed to Graphics#poly"),this._callContextMethod("poly",t)}drawRect(...t){return Ct(Ut,"Graphics#drawRect has been renamed to Graphics#rect"),this._callContextMethod("rect",t)}drawRoundedRect(...t){return Ct(Ut,"Graphics#drawRoundedRect has been renamed to Graphics#roundRect"),this._callContextMethod("roundRect",t)}drawStar(...t){return Ct(Ut,"Graphics#drawStar has been renamed to Graphics#star"),this._callContextMethod("star",t)}}class Ng extends gl{constructor(t,e){const{text:s,resolution:n,style:o,anchor:r,width:l,height:h,roundPixels:d,...c}=t;super({...c}),this.batched=!0,this._resolution=null,this._autoResolution=!0,this._didTextUpdate=!0,this._styleClass=e,this.text=s??"",this.style=o,this.resolution=n??null,this.allowChildren=!1,this._anchor=new ee({_onUpdate:()=>{this.onViewUpdate()}}),r&&(this.anchor=r),this.roundPixels=d??!1,l!==void 0&&(this.width=l),h!==void 0&&(this.height=h)}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}set text(t){t=t.toString(),this._text!==t&&(this._text=t,this.onViewUpdate())}get text(){return this._text}set resolution(t){this._autoResolution=t===null,this._resolution=t,this.onViewUpdate()}get resolution(){return this._resolution}get style(){return this._style}set style(t){var e;t||(t={}),(e=this._style)==null||e.off("update",this.onViewUpdate,this),t instanceof this._styleClass?this._style=t:this._style=new this._styleClass(t),this._style.on("update",this.onViewUpdate,this),this.onViewUpdate()}get width(){return Math.abs(this.scale.x)*this.bounds.width}set width(t){this._setWidth(t,this.bounds.width)}get height(){return Math.abs(this.scale.y)*this.bounds.height}set height(t){this._setHeight(t,this.bounds.height)}getSize(t){return t||(t={}),t.width=Math.abs(this.scale.x)*this.bounds.width,t.height=Math.abs(this.scale.y)*this.bounds.height,t}setSize(t,e){typeof t=="object"?(e=t.height??t.width,t=t.width):e??(e=t),t!==void 0&&this._setWidth(t,this.bounds.width),e!==void 0&&this._setHeight(e,this.bounds.height)}containsPoint(t){const e=this.bounds.width,s=this.bounds.height,n=-e*this.anchor.x;let o=0;return t.x>=n&&t.x<=n+e&&(o=-s*this.anchor.y,t.y>=o&&t.y<=o+s)}onViewUpdate(){this.didViewUpdate||(this._didTextUpdate=!0),super.onViewUpdate()}destroy(t=!1){super.destroy(t),this.owner=null,this._bounds=null,this._anchor=null,(typeof t=="boolean"?t:t!=null&&t.style)&&this._style.destroy(t),this._style=null,this._text=null}get styleKey(){return`${this._text}:${this._style.styleKey}:${this._resolution}`}}function Gg(i,t){let e=i[0]??{};return(typeof e=="string"||i[1])&&(Ct(Ut,`use new ${t}({ text: "hi!", style }) instead`),e={text:e,style:i[1]}),e}class Wg{constructor(t){this._canvasPool=Object.create(null),this.canvasOptions=t||{},this.enableFullScreen=!1}_createCanvasAndContext(t,e){const s=Pe.get().createCanvas();s.width=t,s.height=e;const n=s.getContext("2d");return{canvas:s,context:n}}getOptimalCanvasAndContext(t,e,s=1){t=Math.ceil(t*s-1e-6),e=Math.ceil(e*s-1e-6),t=bn(t),e=bn(e);const n=(t<<17)+(e<<1);this._canvasPool[n]||(this._canvasPool[n]=[]);let o=this._canvasPool[n].pop();return o||(o=this._createCanvasAndContext(t,e)),o}returnCanvasAndContext(t){const e=t.canvas,{width:s,height:n}=e,o=(s<<17)+(n<<1);t.context.resetTransform(),t.context.clearRect(0,0,s,n),this._canvasPool[o].push(t)}clear(){this._canvasPool={}}}const Ya=new Wg;uo.register(Ya);let Bi=null,gs=null;function Og(i,t){Bi||(Bi=Pe.get().createCanvas(256,128),gs=Bi.getContext("2d",{willReadFrequently:!0}),gs.globalCompositeOperation="copy",gs.globalAlpha=1),(Bi.width<i||Bi.height<t)&&(Bi.width=bn(i),Bi.height=bn(t))}function Gh(i,t,e){for(let s=0,n=4*e*t;s<t;++s,n+=4)if(i[n+3]!==0)return!1;return!0}function Wh(i,t,e,s,n){const o=4*t;for(let r=s,l=s*o+4*e;r<=n;++r,l+=o)if(i[l+3]!==0)return!1;return!0}function Hg(...i){let t=i[0];t.canvas||(t={canvas:i[0],resolution:i[1]});const{canvas:e}=t,s=Math.min(t.resolution??1,1),n=t.width??e.width,o=t.height??e.height;let r=t.output;if(Og(n,o),!gs)throw new TypeError("Failed to get canvas 2D context");gs.drawImage(e,0,0,n,o,0,0,n*s,o*s);const h=gs.getImageData(0,0,n,o).data;let d=0,c=0,p=n-1,g=o-1;for(;c<o&&Gh(h,n,c);)++c;if(c===o)return Yt.EMPTY;for(;Gh(h,n,g);)--g;for(;Wh(h,n,d,c,g);)++d;for(;Wh(h,n,p,c,g);)--p;return++p,++g,gs.globalCompositeOperation="source-over",gs.strokeRect(d,c,p-d,g-c),gs.globalCompositeOperation="copy",r??(r=new Yt),r.set(d/s,c/s,(p-d)/s,(g-c)/s),r}/**
240
- * tiny-lru
241
- *
242
- * @copyright 2026 Jason Mulligan <jason.mulligan@avoidwork.com>
243
- * @license BSD-3-Clause
244
- * @version 11.4.7
245
- */class Ug{constructor(t=0,e=0,s=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=t,this.resetTtl=s,this.size=0,this.ttl=e}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(t){if(this.has(t)){const e=this.items[t];delete this.items[t],this.size--,e.prev!==null&&(e.prev.next=e.next),e.next!==null&&(e.next.prev=e.prev),this.first===e&&(this.first=e.next),this.last===e&&(this.last=e.prev)}return this}entries(t=this.keys()){const e=new Array(t.length);for(let s=0;s<t.length;s++){const n=t[s];e[s]=[n,this.get(n)]}return e}evict(t=!1){if(t||this.size>0){const e=this.first;delete this.items[e.key],--this.size===0?(this.first=null,this.last=null):(this.first=e.next,this.first.prev=null)}return this}expiresAt(t){let e;return this.has(t)&&(e=this.items[t].expiry),e}get(t){const e=this.items[t];if(e!==void 0){if(this.ttl>0&&e.expiry<=Date.now()){this.delete(t);return}return this.moveToEnd(e),e.value}}has(t){return t in this.items}moveToEnd(t){this.last!==t&&(t.prev!==null&&(t.prev.next=t.next),t.next!==null&&(t.next.prev=t.prev),this.first===t&&(this.first=t.next),t.prev=this.last,t.next=null,this.last!==null&&(this.last.next=t),this.last=t,this.first===null&&(this.first=t))}keys(){const t=new Array(this.size);let e=this.first,s=0;for(;e!==null;)t[s++]=e.key,e=e.next;return t}setWithEvicted(t,e,s=this.resetTtl){let n=null;if(this.has(t))this.set(t,e,!0,s);else{this.max>0&&this.size===this.max&&(n={...this.first},this.evict(!0));let o=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e};++this.size===1?this.first=o:this.last.next=o,this.last=o}return n}set(t,e,s=!1,n=this.resetTtl){let o=this.items[t];return s||o!==void 0?(o.value=e,s===!1&&n&&(o.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.moveToEnd(o)):(this.max>0&&this.size===this.max&&this.evict(!0),o=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e},++this.size===1?this.first=o:this.last.next=o,this.last=o),this}values(t=this.keys()){const e=new Array(t.length);for(let s=0;s<t.length;s++)e[s]=this.get(t[s]);return e}}function qg(i=1e3,t=0,e=!1){if(isNaN(i)||i<0)throw new TypeError("Invalid max value");if(isNaN(t)||t<0)throw new TypeError("Invalid ttl value");if(typeof e!="boolean")throw new TypeError("Invalid resetTtl value");return new Ug(i,t,e)}function pu(i){return!!i.tagStyles&&Object.keys(i.tagStyles).length>0}function mu(i){return i.includes("<")}function Vg(i,t){return i.clone().assign(t)}function Yg(i,t){const e=[],s=t.tagStyles;if(!pu(t)||!mu(i))return e.push({text:i,style:t}),e;const n=[t],o=[];let r="",l=0;for(;l<i.length;){const h=i[l];if(h==="<"){const d=i.indexOf(">",l);if(d===-1){r+=h,l++;continue}const c=i.slice(l+1,d);if(c.startsWith("/")){const p=c.slice(1).trim();if(o.length>0&&o[o.length-1]===p){r.length>0&&(e.push({text:r,style:n[n.length-1]}),r=""),n.pop(),o.pop(),l=d+1;continue}else{r+=i.slice(l,d+1),l=d+1;continue}}else{const p=c.trim();if(s[p]){r.length>0&&(e.push({text:r,style:n[n.length-1]}),r="");const g=n[n.length-1],m=Vg(g,s[p]);n.push(m),o.push(p),l=d+1;continue}else{r+=i.slice(l,d+1),l=d+1;continue}}}else r+=h,l++}return r.length>0&&e.push({text:r,style:n[n.length-1]}),e}const jg=[10,13],Xg=new Set(jg),Zg=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288],Kg=new Set(Zg),Qg=[9,32];new Set(Qg);const Jg=[45,8208,8211,8212,173],t0=new Set(Jg),e0=/(\r\n|\r|\n)/,s0=/(?:\r\n|\r|\n)/;function hr(i){return typeof i!="string"?!1:Xg.has(i.charCodeAt(0))}function ze(i,t){return typeof i!="string"?!1:Kg.has(i.charCodeAt(0))}function i0(i){return typeof i!="string"?!1:t0.has(i.charCodeAt(0))}function gu(i){return i==="normal"||i==="pre-line"}function yu(i){return i==="normal"}function ms(i){if(typeof i!="string")return"";let t=i.length-1;for(;t>=0&&ze(i[t]);)t--;return t<i.length-1?i.slice(0,t+1):i}function bu(i){const t=[],e=[];if(typeof i!="string")return t;for(let s=0;s<i.length;s++){const n=i[s],o=i[s+1];if(ze(n)||hr(n)){e.length>0&&(t.push(e.join("")),e.length=0),n==="\r"&&o===`
246
- `?(t.push(`\r
247
- `),s++):t.push(n);continue}e.push(n),i0(n)&&o&&!ze(o)&&!hr(o)&&(t.push(e.join("")),e.length=0)}return e.length>0&&t.push(e.join("")),t}function _u(i,t,e,s){const n=e(i),o=[];for(let r=0;r<n.length;r++){let l=n[r],h=l,d=1;for(;n[r+d];){const c=n[r+d];if(!s(h,c,i,r,t))l+=c,h=c,d++;else break}r+=d-1,o.push(l)}return o}const n0=/\r\n|\r|\n/g;function o0(i,t,e,s,n,o,r,l){var Bt,et;const h=Yg(i,t);if(yu(t.whiteSpace))for(let it=0;it<h.length;it++){const vt=h[it];h[it]={text:vt.text.replace(n0," "),style:vt.style}}const c=[];let p=[];for(const it of h){const vt=it.text.split(e0);for(let rt=0;rt<vt.length;rt++){const bt=vt[rt];bt===`\r
248
- `||bt==="\r"||bt===`
249
- `?(c.push(p),p=[]):bt.length>0&&p.push({text:bt,style:it.style})}}(p.length>0||c.length===0)&&c.push(p);const g=e?r0(c,t,s,n,r,l):c,m=[],y=[],x=[],w=[],k=[];let E=0;const B=t._fontString,L=o(B);L.fontSize===0&&(L.fontSize=t.fontSize,L.ascent=t.fontSize);let H="",$=!!t.dropShadow,G=((Bt=t._stroke)==null?void 0:Bt.width)||0;for(const it of g){let vt=0,rt=L.ascent,bt=L.descent,At="";for(const ut of it){const Gt=ut.style._fontString,Xt=o(Gt);Gt!==H&&(s.font=Gt,H=Gt);const Te=n(ut.text,ut.style.letterSpacing,s);vt+=Te,rt=Math.max(rt,Xt.ascent),bt=Math.max(bt,Xt.descent),At+=ut.text;const Vt=((et=ut.style._stroke)==null?void 0:et.width)||0;Vt>G&&(G=Vt),!$&&ut.style.dropShadow&&($=!0)}it.length===0&&(rt=L.ascent,bt=L.descent),m.push(vt),y.push(rt),x.push(bt),k.push(At);const It=t.lineHeight||rt+bt;w.push(It+t.leading),E=Math.max(E,vt)}const tt=G,Q=(e&&t.align!=="left"?Math.max(E,t.wordWrapWidth):E)+tt+(t.dropShadow?t.dropShadow.distance:0);let ot=0;for(let it=0;it<w.length;it++)ot+=w[it];ot=Math.max(ot,w[0]+tt);const at=ot+(t.dropShadow?t.dropShadow.distance:0),lt=t.lineHeight||L.fontSize;return{width:Q,height:at,lines:k,lineWidths:m,lineHeight:lt+t.leading,maxLineWidth:E,fontProperties:L,runsByLine:g,lineAscents:y,lineDescents:x,lineHeights:w,hasDropShadow:$}}function r0(i,t,e,s,n,o){var w;const{letterSpacing:r,whiteSpace:l,wordWrapWidth:h,breakWords:d}=t,c=gu(l),p=h+r,g={};let m="";const y=(k,E)=>{const B=`${k}|${E.styleKey}`;let L=g[B];if(L===void 0){const H=E._fontString;H!==m&&(e.font=H,m=H),L=s(k,E.letterSpacing,e)+E.letterSpacing,g[B]=L}return L},x=[];for(const k of i){const E=a0(k),B=x.length,L=ot=>{let at=0,lt=ot;do{const{token:Bt,style:et}=E[lt];at+=y(Bt,et),lt++}while(lt<E.length&&E[lt].continuesFromPrevious);return at},H=ot=>{const at=[];let lt=ot;do at.push({token:E[lt].token,style:E[lt].style}),lt++;while(lt<E.length&&E[lt].continuesFromPrevious);return at};let $=[],G=0,tt=!c,Z=null;const X=()=>{Z&&Z.text.length>0&&$.push(Z),Z=null},Q=()=>{if(X(),$.length>0){const ot=$[$.length-1];ot.text=ms(ot.text),ot.text.length===0&&$.pop()}x.push($),$=[],G=0,tt=!1};for(let ot=0;ot<E.length;ot++){const{token:at,style:lt,continuesFromPrevious:Bt}=E[ot],et=y(at,lt);if(c){const rt=ze(at),bt=(Z==null?void 0:Z.text[Z.text.length-1])??((w=$[$.length-1])==null?void 0:w.text.slice(-1))??"",At=bt?ze(bt):!1;if(rt&&At)continue}const it=!Bt,vt=it?L(ot):et;if(vt>p&&it)if(G>0&&Q(),d){const rt=H(ot);for(let bt=0;bt<rt.length;bt++){const At=rt[bt].token,It=rt[bt].style,ut=_u(At,d,o,n);for(const Gt of ut){const Xt=y(Gt,It);Xt+G>p&&Q(),!Z||Z.style!==It?(X(),Z={text:Gt,style:It}):Z.text+=Gt,G+=Xt}}ot+=rt.length-1}else{const rt=H(ot);X(),x.push(rt.map(bt=>({text:bt.token,style:bt.style}))),tt=!1,ot+=rt.length-1}else if(vt+G>p&&it){if(ze(at)){tt=!1;continue}Q(),Z={text:at,style:lt},G=et}else if(Bt&&!d)!Z||Z.style!==lt?(X(),Z={text:at,style:lt}):Z.text+=at,G+=et;else{const rt=ze(at);if(G===0&&rt&&!tt)continue;!Z||Z.style!==lt?(X(),Z={text:at,style:lt}):Z.text+=at,G+=et}}if(X(),$.length>0){const ot=$[$.length-1];ot.text=ms(ot.text),ot.text.length===0&&$.pop()}($.length>0||x.length===B)&&x.push($)}return x}function a0(i){const t=[];let e=!1;for(const s of i){const n=bu(s.text);let o=!0;for(const r of n){const l=ze(r)||hr(r),h=o&&e&&!l;t.push({token:r,style:s.style,continuesFromPrevious:h}),e=!l,o=!1}}return t}const l0={willReadFrequently:!0};function Oh(i,t,e,s,n){let o=e[i];return typeof o!="number"&&(o=n(i,t,s)+t,e[i]=o),o}function h0(i,t,e,s,n,o,r){const l=e.getContext("2d",l0);l.font=t._fontString;let h=0,d="";const c=[],p=Object.create(null),{letterSpacing:g,whiteSpace:m}=t,y=gu(m),x=yu(m);let w=!y;const k=t.wordWrapWidth+g,E=bu(i);for(let L=0;L<E.length;L++){let H=E[L];if(hr(H)){if(!x){c.push(ms(d)),w=!y,d="",h=0;continue}H=" "}if(y){const G=ze(H),tt=ze(d[d.length-1]);if(G&&tt)continue}const $=Oh(H,g,p,l,s);if($>k)if(d!==""&&(c.push(ms(d)),d="",h=0),n(H,t.breakWords)){const G=_u(H,t.breakWords,r,o);for(const tt of G){const Z=Oh(tt,g,p,l,s);Z+h>k&&(c.push(ms(d)),w=!1,d="",h=0),d+=tt,h+=Z}}else d.length>0&&(c.push(ms(d)),d="",h=0),c.push(ms(H)),w=!1,d="",h=0;else $+h>k&&(w=!1,c.push(ms(d)),d="",h=0),(d.length>0||!ze(H)||w)&&(d+=H,h+=$)}const B=ms(d);return B.length>0&&c.push(B),c.join(`
250
- `)}const Hh={willReadFrequently:!0},vs=class dt{static get experimentalLetterSpacingSupported(){let t=dt._experimentalLetterSpacingSupported;if(t===void 0){const e=Pe.get().getCanvasRenderingContext2D().prototype;t=dt._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,s,n,o,r,l,h,d,c){this.text=t,this.style=e,this.width=s,this.height=n,this.lines=o,this.lineWidths=r,this.lineHeight=l,this.maxLineWidth=h,this.fontProperties=d,c&&(this.runsByLine=c.runsByLine,this.lineAscents=c.lineAscents,this.lineDescents=c.lineDescents,this.lineHeights=c.lineHeights,this.hasDropShadow=c.hasDropShadow)}static measureText(t=" ",e,s=dt._canvas,n=e.wordWrap){var H;const o=`${t}-${e.styleKey}-wordWrap-${n}`;if(dt._measurementCache.has(o))return dt._measurementCache.get(o);if(pu(e)&&mu(t)){const $=o0(t,e,n,dt._context,dt._measureText,dt.measureFont,dt.canBreakChars,dt.wordWrapSplit),G=new dt(t,e,$.width,$.height,$.lines,$.lineWidths,$.lineHeight,$.maxLineWidth,$.fontProperties,{runsByLine:$.runsByLine,lineAscents:$.lineAscents,lineDescents:$.lineDescents,lineHeights:$.lineHeights,hasDropShadow:$.hasDropShadow});return dt._measurementCache.set(o,G),G}const l=e._fontString,h=dt.measureFont(l);h.fontSize===0&&(h.fontSize=e.fontSize,h.ascent=e.fontSize,h.descent=0);const d=dt._context;d.font=l;const p=(n?dt._wordWrap(t,e,s):t).split(s0),g=new Array(p.length);let m=0;for(let $=0;$<p.length;$++){const G=dt._measureText(p[$],e.letterSpacing,d);g[$]=G,m=Math.max(m,G)}const y=((H=e._stroke)==null?void 0:H.width)??0,x=e.lineHeight||h.fontSize,w=dt._getAlignWidth(m,e,n),k=dt._adjustWidthForStyle(w,e),E=Math.max(x,h.fontSize+y)+(p.length-1)*(x+e.leading),B=dt._adjustHeightForStyle(E,e),L=new dt(t,e,k,B,p,g,x+e.leading,m,h);return dt._measurementCache.set(o,L),L}static _adjustWidthForStyle(t,e){var o;const s=((o=e._stroke)==null?void 0:o.width)||0;let n=t+s;return e.dropShadow&&(n+=e.dropShadow.distance),n}static _adjustHeightForStyle(t,e){let s=t;return e.dropShadow&&(s+=e.dropShadow.distance),s}static _getAlignWidth(t,e,s){return s&&e.align!=="left"?Math.max(t,e.wordWrapWidth):t}static _measureText(t,e,s){let n=!1;dt.experimentalLetterSpacingSupported&&(dt.experimentalLetterSpacing?(s.letterSpacing=`${e}px`,s.textLetterSpacing=`${e}px`,n=!0):(s.letterSpacing="0px",s.textLetterSpacing="0px"));const o=s.measureText(t);let r=o.width;const l=-(o.actualBoundingBoxLeft??0);let d=(o.actualBoundingBoxRight??0)-l;if(r>0)if(n)r-=e,d-=e;else{const c=(dt.graphemeSegmenter(t).length-1)*e;r+=c,d+=c}return Math.max(r,d)}static _wordWrap(t,e,s=dt._canvas){return h0(t,e,s,dt._measureText,dt.canBreakWords,dt.canBreakChars,dt.wordWrapSplit)}static isBreakingSpace(t,e){return ze(t)}static canBreakWords(t,e){return e}static canBreakChars(t,e,s,n,o){return!0}static wordWrapSplit(t){return dt.graphemeSegmenter(t)}static measureFont(t){if(dt._fonts[t])return dt._fonts[t];const e=dt._context;e.font=t;const s=e.measureText(dt.METRICS_STRING+dt.BASELINE_SYMBOL),n=s.actualBoundingBoxAscent??0,o=s.actualBoundingBoxDescent??0,r={ascent:n,descent:o,fontSize:n+o};return dt._fonts[t]=r,r}static clearMetrics(t=""){t?delete dt._fonts[t]:dt._fonts={}}static get _canvas(){if(!dt.__canvas){let t;try{const e=new OffscreenCanvas(0,0),s=e.getContext("2d",Hh);if(s!=null&&s.measureText)return dt.__canvas=e,e;t=Pe.get().createCanvas()}catch{t=Pe.get().createCanvas()}t.width=t.height=10,dt.__canvas=t}return dt.__canvas}static get _context(){return dt.__context||(dt.__context=dt._canvas.getContext("2d",Hh)),dt.__context}};vs.METRICS_STRING="|ÉqÅ";vs.BASELINE_SYMBOL="M";vs.BASELINE_MULTIPLIER=1.4;vs.HEIGHT_MULTIPLIER=2;vs.graphemeSegmenter=(()=>{if(typeof(Intl==null?void 0:Intl.Segmenter)=="function"){const i=new Intl.Segmenter;return t=>{const e=i.segment(t),s=[];let n=0;for(const o of e)s[n++]=o.segment;return s}}return i=>[...i]})();vs.experimentalLetterSpacing=!1;vs._fonts={};vs._measurementCache=qg(1e3);let gi=vs;const c0=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function ja(i){const t=typeof i.fontSize=="number"?`${i.fontSize}px`:i.fontSize;let e=i.fontFamily;Array.isArray(i.fontFamily)||(e=i.fontFamily.split(","));for(let s=e.length-1;s>=0;s--){let n=e[s].trim();!/([\"\'])[^\'\"]+\1/.test(n)&&!c0.includes(n)&&(n=`"${n}"`),e[s]=n}return`${i.fontStyle} ${i.fontVariant} ${i.fontWeight} ${t} ${e.join(",")}`}const Uh=1e5;function Mo(i,t,e,s=0,n=0,o=0){if(i.texture===$t.WHITE&&!i.fill)return Kt.shared.setValue(i.color).setAlpha(i.alpha??1).toHexa();if(i.fill){if(i.fill instanceof vr){const r=i.fill,l=t.createPattern(r.texture.source.resource,"repeat"),h=r.transform.copyTo(wt.shared);return h.scale(r.texture.source.pixelWidth,r.texture.source.pixelHeight),l.setTransform(h),l}else if(i.fill instanceof _s){const r=i.fill,l=r.type==="linear",h=r.textureSpace==="local";let d=1,c=1;h&&e&&(d=e.width+s,c=e.height+s);let p,g=!1;if(l){const{start:m,end:y}=r;p=t.createLinearGradient(m.x*d+n,m.y*c+o,y.x*d+n,y.y*c+o),g=Math.abs(y.x-m.x)<Math.abs((y.y-m.y)*.1)}else{const{center:m,innerRadius:y,outerCenter:x,outerRadius:w}=r;p=t.createRadialGradient(m.x*d+n,m.y*c+o,y*d,x.x*d+n,x.y*c+o,w*d)}if(g&&h&&e){const m=e.lineHeight/c;for(let y=0;y<e.lines.length;y++){const x=(y*e.lineHeight+s/2)/c;r.colorStops.forEach(w=>{let k=x+w.offset*m;k=Math.max(0,Math.min(1,k)),p.addColorStop(Math.floor(k*Uh)/Uh,Kt.shared.setValue(w.color).toHex())})}}else r.colorStops.forEach(m=>{p.addColorStop(m.offset,Kt.shared.setValue(m.color).toHex())});return p}}else{const r=t.createPattern(i.texture.source.resource,"repeat"),l=i.matrix.copyTo(wt.shared);return l.scale(i.texture.source.pixelWidth,i.texture.source.pixelHeight),r.setTransform(l),r}return xe("FillStyle not recognised",i),"red"}const qh=new Yt;function Ji(i){let t=0;for(let e=0;e<i.length;e++)i.charCodeAt(e)===32&&t++;return t}class d0{getCanvasAndContext(t){const{text:e,style:s,resolution:n=1}=t,o=s._getFinalPadding(),r=gi.measureText(e||" ",s),l=Math.ceil(Math.ceil(Math.max(1,r.width)+o*2)*n),h=Math.ceil(Math.ceil(Math.max(1,r.height)+o*2)*n),d=Ya.getOptimalCanvasAndContext(l,h);this._renderTextToCanvas(s,o,n,d,r);const c=s.trim?Hg({canvas:d.canvas,width:l,height:h,resolution:1,output:qh}):qh.set(0,0,l,h);return{canvasAndContext:d,frame:c}}returnCanvasAndContext(t){Ya.returnCanvasAndContext(t)}_renderTextToCanvas(t,e,s,n,o){var $,G,tt;if(o.runsByLine&&o.runsByLine.length>0){this._renderTaggedTextToCanvas(o,t,e,s,n);return}const{canvas:r,context:l}=n,h=ja(t),d=o.lines,c=o.lineHeight,p=o.lineWidths,g=o.maxLineWidth,m=o.fontProperties,y=r.height;if(l.resetTransform(),l.scale(s,s),l.textBaseline=t.textBaseline,($=t._stroke)!=null&&$.width){const Z=t._stroke;l.lineWidth=Z.width,l.miterLimit=Z.miterLimit,l.lineJoin=Z.join,l.lineCap=Z.cap}l.font=h;let x,w;const k=t.dropShadow?2:1,E=t.wordWrap?t.wordWrapWidth:g,L=(((G=t._stroke)==null?void 0:G.width)??0)/2;let H=(c-m.fontSize)/2;c-m.fontSize<0&&(H=0);for(let Z=0;Z<k;++Z){const X=t.dropShadow&&Z===0,Q=X?Math.ceil(Math.max(1,y)+e*2):0,ot=Q*s;if(X)this._setupDropShadow(l,t,s,ot);else{const at=t._gradientBounds,lt=t._gradientOffset;if(at){const Bt={width:at.width,height:at.height,lineHeight:at.height,lines:o.lines};this._setFillAndStrokeStyles(l,t,Bt,e,L,(lt==null?void 0:lt.x)??0,(lt==null?void 0:lt.y)??0)}else lt?this._setFillAndStrokeStyles(l,t,o,e,L,lt.x,lt.y):this._setFillAndStrokeStyles(l,t,o,e,L);l.shadowColor="rgba(0,0,0,0)"}for(let at=0;at<d.length;at++){x=L,w=L+at*c+m.ascent+H,x+=this._getAlignmentOffset(p[at],E,t.align);let lt=0;if(t.align==="justify"&&t.wordWrap&&at<d.length-1){const Bt=Ji(d[at]);Bt>0&&(lt=(E-p[at])/Bt)}(tt=t._stroke)!=null&&tt.width&&this._drawLetterSpacing(d[at],t,n,x+e,w+e-Q,!0,lt),t._fill!==void 0&&this._drawLetterSpacing(d[at],t,n,x+e,w+e-Q,!1,lt)}}}_renderTaggedTextToCanvas(t,e,s,n,o){var L,H,$;const{canvas:r,context:l}=o,{runsByLine:h,lineWidths:d,maxLineWidth:c,lineAscents:p,lineHeights:g,hasDropShadow:m}=t,y=r.height;l.resetTransform(),l.scale(n,n),l.textBaseline=e.textBaseline;const x=m?2:1,w=e.wordWrap?e.wordWrapWidth:c;let k=((L=e._stroke)==null?void 0:L.width)??0;for(const G of h)for(const tt of G){const Z=((H=tt.style._stroke)==null?void 0:H.width)??0;Z>k&&(k=Z)}const E=k/2,B=[];for(let G=0;G<h.length;G++){const tt=h[G],Z=[];for(const X of tt){const Q=ja(X.style);l.font=Q,Z.push({width:gi._measureText(X.text,X.style.letterSpacing,l),font:Q})}B.push(Z)}for(let G=0;G<x;++G){const tt=m&&G===0,Z=tt?Math.ceil(Math.max(1,y)+s*2):0,X=Z*n;tt||(l.shadowColor="rgba(0,0,0,0)");let Q=E;for(let ot=0;ot<h.length;ot++){const at=h[ot],lt=d[ot],Bt=p[ot],et=g[ot],it=B[ot];let vt=E;vt+=this._getAlignmentOffset(lt,w,e.align);let rt=0;if(e.align==="justify"&&e.wordWrap&&ot<h.length-1){let It=0;for(const ut of at)It+=Ji(ut.text);It>0&&(rt=(w-lt)/It)}const bt=Q+Bt;let At=vt+s;for(let It=0;It<at.length;It++){const ut=at[It],{width:Gt,font:Xt}=it[It];if(l.font=Xt,l.textBaseline=ut.style.textBaseline,($=ut.style._stroke)!=null&&$.width){const Vt=ut.style._stroke;if(l.lineWidth=Vt.width,l.miterLimit=Vt.miterLimit,l.lineJoin=Vt.join,l.lineCap=Vt.cap,tt)if(ut.style.dropShadow)this._setupDropShadow(l,ut.style,n,X);else{const Ie=Ji(ut.text);At+=Gt+Ie*rt;continue}else{const Ie=gi.measureFont(Xt),We=ut.style.lineHeight||Ie.fontSize,ve={width:Gt,height:We,lineHeight:We,lines:[ut.text]};l.strokeStyle=Mo(Vt,l,ve,s*2,At-s,Q)}this._drawLetterSpacing(ut.text,ut.style,o,At,bt+s-Z,!0,rt)}const Te=Ji(ut.text);At+=Gt+Te*rt}At=vt+s;for(let It=0;It<at.length;It++){const ut=at[It],{width:Gt,font:Xt}=it[It];if(l.font=Xt,l.textBaseline=ut.style.textBaseline,ut.style._fill!==void 0){if(tt)if(ut.style.dropShadow)this._setupDropShadow(l,ut.style,n,X);else{const Vt=Ji(ut.text);At+=Gt+Vt*rt;continue}else{const Vt=gi.measureFont(Xt),Ie=ut.style.lineHeight||Vt.fontSize,We={width:Gt,height:Ie,lineHeight:Ie,lines:[ut.text]};l.fillStyle=Mo(ut.style._fill,l,We,s*2,At-s,Q)}this._drawLetterSpacing(ut.text,ut.style,o,At,bt+s-Z,!1,rt)}const Te=Ji(ut.text);At+=Gt+Te*rt}Q+=et}}}_setFillAndStrokeStyles(t,e,s,n,o,r=0,l=0){var h;if(t.fillStyle=e._fill?Mo(e._fill,t,s,n*2,r,l):null,(h=e._stroke)!=null&&h.width){const d=o+n*2;t.strokeStyle=Mo(e._stroke,t,s,d,r,l)}}_setupDropShadow(t,e,s,n){t.fillStyle="black",t.strokeStyle="black";const o=e.dropShadow,r=o.color,l=o.alpha;t.shadowColor=Kt.shared.setValue(r).setAlpha(l).toRgbaString();const h=o.blur*s,d=o.distance*s;t.shadowBlur=h,t.shadowOffsetX=Math.cos(o.angle)*d,t.shadowOffsetY=Math.sin(o.angle)*d+n}_getAlignmentOffset(t,e,s){return s==="right"?e-t:s==="center"?(e-t)/2:0}_drawLetterSpacing(t,e,s,n,o,r=!1,l=0){const{context:h}=s,d=e.letterSpacing;let c=!1;if(gi.experimentalLetterSpacingSupported&&(gi.experimentalLetterSpacing?(h.letterSpacing=`${d}px`,h.textLetterSpacing=`${d}px`,c=!0):(h.letterSpacing="0px",h.textLetterSpacing="0px")),(d===0||c)&&l===0){r?h.strokeText(t,n,o):h.fillText(t,n,o);return}if(l!==0&&(d===0||c)){const x=t.split(" ");let w=n;const k=h.measureText(" ").width;for(let E=0;E<x.length;E++)r?h.strokeText(x[E],w,o):h.fillText(x[E],w,o),w+=h.measureText(x[E]).width+k+l;return}let p=n;const g=gi.graphemeSegmenter(t);let m=h.measureText(t).width,y=0;for(let x=0;x<g.length;++x){const w=g[x];r?h.strokeText(w,p,o):h.fillText(w,p,o);let k="";for(let E=x+1;E<g.length;++E)k+=g[E];y=h.measureText(k).width,p+=m-y+d,w===" "&&(p+=l),m=y}}}const fn=new d0,Ml=class Hi extends as{constructor(t={}){super(),this.uid=qt("textStyle"),this._tick=0,this._cachedFontString=null,u0(t),t instanceof Hi&&(t=t._toObject());const n={...Hi.defaultTextStyle,...t};for(const o in n){const r=o;this[r]=n[o]}this._tagStyles=t.tagStyles??void 0,this.update(),this._tick=0}get align(){return this._align}set align(t){this._align!==t&&(this._align=t,this.update())}get breakWords(){return this._breakWords}set breakWords(t){this._breakWords!==t&&(this._breakWords=t,this.update())}get dropShadow(){return this._dropShadow}set dropShadow(t){this._dropShadow!==t&&(t!==null&&typeof t=="object"?this._dropShadow=this._createProxy({...Hi.defaultDropShadow,...t}):this._dropShadow=t?this._createProxy({...Hi.defaultDropShadow}):null,this.update())}get fontFamily(){return this._fontFamily}set fontFamily(t){this._fontFamily!==t&&(this._fontFamily=t,this.update())}get fontSize(){return this._fontSize}set fontSize(t){this._fontSize!==t&&(typeof t=="string"?this._fontSize=parseInt(t,10):this._fontSize=t,this.update())}get fontStyle(){return this._fontStyle}set fontStyle(t){this._fontStyle!==t&&(this._fontStyle=t.toLowerCase(),this.update())}get fontVariant(){return this._fontVariant}set fontVariant(t){this._fontVariant!==t&&(this._fontVariant=t,this.update())}get fontWeight(){return this._fontWeight}set fontWeight(t){this._fontWeight!==t&&(this._fontWeight=t,this.update())}get leading(){return this._leading}set leading(t){this._leading!==t&&(this._leading=t,this.update())}get letterSpacing(){return this._letterSpacing}set letterSpacing(t){this._letterSpacing!==t&&(this._letterSpacing=t,this.update())}get lineHeight(){return this._lineHeight}set lineHeight(t){this._lineHeight!==t&&(this._lineHeight=t,this.update())}get padding(){return this._padding}set padding(t){this._padding!==t&&(this._padding=t,this.update())}get filters(){return this._filters}set filters(t){this._filters!==t&&(this._filters=Object.freeze(t),this.update())}get trim(){return this._trim}set trim(t){this._trim!==t&&(this._trim=t,this.update())}get textBaseline(){return this._textBaseline}set textBaseline(t){this._textBaseline!==t&&(this._textBaseline=t,this.update())}get whiteSpace(){return this._whiteSpace}set whiteSpace(t){this._whiteSpace!==t&&(this._whiteSpace=t,this.update())}get wordWrap(){return this._wordWrap}set wordWrap(t){this._wordWrap!==t&&(this._wordWrap=t,this.update())}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(t){this._wordWrapWidth!==t&&(this._wordWrapWidth=t,this.update())}get fill(){return this._originalFill}set fill(t){t!==this._originalFill&&(this._originalFill=t,this._isFillStyle(t)&&(this._originalFill=this._createProxy({...Ve.defaultFillStyle,...t},()=>{this._fill=qi({...this._originalFill},Ve.defaultFillStyle)})),this._fill=qi(t===0?"black":t,Ve.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(t){t!==this._originalStroke&&(this._originalStroke=t,this._isFillStyle(t)&&(this._originalStroke=this._createProxy({...Ve.defaultStrokeStyle,...t},()=>{this._stroke=lr({...this._originalStroke},Ve.defaultStrokeStyle)})),this._stroke=lr(t,Ve.defaultStrokeStyle),this.update())}get tagStyles(){return this._tagStyles}set tagStyles(t){this._tagStyles!==t&&(this._tagStyles=t??void 0,this.update())}update(){this._tick++,this._cachedFontString=null,this.emit("update",this)}reset(){const t=Hi.defaultTextStyle;for(const e in t)this[e]=t[e]}assign(t){for(const e in t){const s=e;this[s]=t[e]}return this}get styleKey(){return`${this.uid}-${this._tick}`}get _fontString(){return this._cachedFontString===null&&(this._cachedFontString=ja(this)),this._cachedFontString}_toObject(){return{align:this.align,breakWords:this.breakWords,dropShadow:this._dropShadow?{...this._dropShadow}:null,fill:this._fill?{...this._fill}:void 0,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,leading:this.leading,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke?{...this._stroke}:void 0,textBaseline:this.textBaseline,trim:this.trim,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth,filters:this._filters?[...this._filters]:void 0,tagStyles:this._tagStyles?{...this._tagStyles}:void 0}}clone(){return new Hi(this._toObject())}_getFinalPadding(){let t=0;if(this._filters)for(let e=0;e<this._filters.length;e++)t+=this._filters[e].padding;return Math.max(this._padding,t)}destroy(t=!1){var s,n,o,r;if(this.removeAllListeners(),typeof t=="boolean"?t:t==null?void 0:t.texture){const l=typeof t=="boolean"?t:t==null?void 0:t.textureSource;(s=this._fill)!=null&&s.texture&&this._fill.texture.destroy(l),(n=this._originalFill)!=null&&n.texture&&this._originalFill.texture.destroy(l),(o=this._stroke)!=null&&o.texture&&this._stroke.texture.destroy(l),(r=this._originalStroke)!=null&&r.texture&&this._originalStroke.texture.destroy(l)}this._fill=null,this._stroke=null,this.dropShadow=null,this._originalStroke=null,this._originalFill=null}_createProxy(t,e){return new Proxy(t,{set:(s,n,o)=>(s[n]===o||(s[n]=o,e==null||e(n,o),this.update()),!0)})}_isFillStyle(t){return(t??null)!==null&&!(Kt.isColorLike(t)||t instanceof _s||t instanceof vr)}};Ml.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5};Ml.defaultTextStyle={align:"left",breakWords:!1,dropShadow:null,fill:"black",fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",leading:0,letterSpacing:0,lineHeight:0,padding:0,stroke:null,textBaseline:"alphabetic",trim:!1,whiteSpace:"pre",wordWrap:!1,wordWrapWidth:100};let Ye=Ml;function u0(i){const t=i;if(typeof t.dropShadow=="boolean"&&t.dropShadow){const e=Ye.defaultDropShadow;i.dropShadow={alpha:t.dropShadowAlpha??e.alpha,angle:t.dropShadowAngle??e.angle,blur:t.dropShadowBlur??e.blur,color:t.dropShadowColor??e.color,distance:t.dropShadowDistance??e.distance}}if(t.strokeThickness!==void 0){Ct(Ut,"strokeThickness is now a part of stroke");const e=t.stroke;let s={};if(Kt.isColorLike(e))s.color=e;else if(e instanceof _s||e instanceof vr)s.fill=e;else if(Object.hasOwnProperty.call(e,"color")||Object.hasOwnProperty.call(e,"fill"))s=e;else throw new Error("Invalid stroke value.");i.stroke={...s,width:t.strokeThickness}}if(Array.isArray(t.fillGradientStops)){if(Ct(Ut,"gradient fill is now a fill pattern: `new FillGradient(...)`"),!Array.isArray(t.fill)||t.fill.length===0)throw new Error("Invalid fill value. Expected an array of colors for gradient fill.");t.fill.length!==t.fillGradientStops.length&&xe("The number of fill colors must match the number of fill gradient stops.");const e=new _s({start:{x:0,y:0},end:{x:0,y:1},textureSpace:"local"}),s=t.fillGradientStops.slice(),n=t.fill.map(o=>Kt.shared.setValue(o).toNumber());s.forEach((o,r)=>{e.addColorStop(o,n[r])}),i.fill={fill:e}}}function f0(i,t){const{texture:e,bounds:s}=i,n=t._style._getFinalPadding();id(s,t._anchor,e);const o=t._anchor._x*n*2,r=t._anchor._y*n*2;s.minX-=n-o,s.minY-=n-r,s.maxX-=n-o,s.maxY-=n-r}class p0{constructor(){this.batcherName="default",this.topology="triangle-list",this.attributeSize=4,this.indexSize=6,this.packAsQuad=!0,this.roundPixels=0,this._attributeStart=0,this._batcher=null,this._batch=null}get blendMode(){return this.renderable.groupBlendMode}get color(){return this.renderable.groupColorAlpha}reset(){this.renderable=null,this.texture=null,this._batcher=null,this._batch=null,this.bounds=null}destroy(){this.reset()}}class m0 extends p0{}class xu{constructor(t){this._renderer=t,t.runners.resolutionChange.add(this),this._managedTexts=new fo({renderer:t,type:"renderable",onUnload:this.onTextUnload.bind(this),name:"canvasText"})}resolutionChange(){for(const t in this._managedTexts.items){const e=this._managedTexts.items[t];e!=null&&e._autoResolution&&e.onViewUpdate()}}validateRenderable(t){const e=this._getGpuText(t),s=t.styleKey;return e.currentKey!==s?!0:t._didTextUpdate}addRenderable(t,e){const s=this._getGpuText(t);if(t._didTextUpdate){const n=t._autoResolution?this._renderer.resolution:t.resolution;(s.currentKey!==t.styleKey||t._resolution!==n)&&this._updateGpuText(t),t._didTextUpdate=!1,f0(s,t)}this._renderer.renderPipes.batch.addToBatch(s,e)}updateRenderable(t){const e=this._getGpuText(t);e._batcher.updateElement(e)}_updateGpuText(t){const e=this._getGpuText(t);e.texture&&this._renderer.canvasText.decreaseReferenceCount(e.currentKey),t._resolution=t._autoResolution?this._renderer.resolution:t.resolution,e.texture=this._renderer.canvasText.getManagedTexture(t),e.currentKey=t.styleKey}_getGpuText(t){return t._gpuData[this._renderer.uid]||this.initGpuText(t)}initGpuText(t){const e=new m0;return e.currentKey="--",e.renderable=t,e.transform=t.groupTransform,e.bounds={minX:0,maxX:1,minY:0,maxY:0},e.roundPixels=this._renderer._roundPixels|t._roundPixels,t._gpuData[this._renderer.uid]=e,this._managedTexts.add(t),e}onTextUnload(t){const e=t._gpuData[this._renderer.uid];if(!e)return;const{canvasText:s}=this._renderer;s.getReferenceCount(e.currentKey)>0?s.decreaseReferenceCount(e.currentKey):e.texture&&s.returnTexture(e.texture)}destroy(){this._managedTexts.destroy(),this._renderer=null}}xu.extension={type:[yt.WebGLPipes,yt.WebGPUPipes,yt.CanvasPipes],name:"text"};const g0=new Ne;function y0(i,t,e,s,n=!1){const o=g0;o.minX=0,o.minY=0,o.maxX=i.width/s|0,o.maxY=i.height/s|0;const r=yr.getOptimalTexture(o.width,o.height,s,!1,n);return r.source.uploadMethodId="image",r.source.resource=i,r.source.alphaMode="premultiply-alpha-on-upload",r.frame.width=t/s,r.frame.height=e/s,r.source.emit("update",r.source),r.updateUvs(),r}class vu{constructor(t,e){this._activeTextures={},this._renderer=t,this._retainCanvasContext=e}getTexture(t,e,s,n){typeof t=="string"&&(Ct("8.0.0","CanvasTextSystem.getTexture: Use object TextOptions instead of separate arguments"),t={text:t,style:s,resolution:e}),t.style instanceof Ye||(t.style=new Ye(t.style)),t.textureStyle instanceof _n||(t.textureStyle=new _n(t.textureStyle)),typeof t.text!="string"&&(t.text=t.text.toString());const{text:o,style:r,textureStyle:l,autoGenerateMipmaps:h}=t,d=t.resolution??this._renderer.resolution,{frame:c,canvasAndContext:p}=fn.getCanvasAndContext({text:o,style:r,resolution:d}),g=y0(p.canvas,c.width,c.height,d,h);if(l&&(g.source.style=l),r.trim&&(c.pad(r.padding),g.frame.copyFrom(c),g.frame.scale(1/d),g.updateUvs()),r.filters){const m=this._applyFilters(g,r.filters);return this.returnTexture(g),fn.returnCanvasAndContext(p),m}return this._renderer.texture.initSource(g._source),this._retainCanvasContext||fn.returnCanvasAndContext(p),g}returnTexture(t){const e=t.source,s=e.resource;if(this._retainCanvasContext&&(s!=null&&s.getContext)){const n=s.getContext("2d");n&&fn.returnCanvasAndContext({canvas:s,context:n})}e.resource=null,e.uploadMethodId="unknown",e.alphaMode="no-premultiply-alpha",yr.returnTexture(t,!0)}renderTextToCanvas(){Ct("8.10.0","CanvasTextSystem.renderTextToCanvas: no longer supported, use CanvasTextSystem.getTexture instead")}getManagedTexture(t){t._resolution=t._autoResolution?this._renderer.resolution:t.resolution;const e=t.styleKey;if(this._activeTextures[e])return this._increaseReferenceCount(e),this._activeTextures[e].texture;const s=this.getTexture({text:t.text,style:t.style,resolution:t._resolution,textureStyle:t.textureStyle,autoGenerateMipmaps:t.autoGenerateMipmaps});return this._activeTextures[e]={texture:s,usageCount:1},s}decreaseReferenceCount(t){const e=this._activeTextures[t];e&&(e.usageCount--,e.usageCount===0&&(this.returnTexture(e.texture),this._activeTextures[t]=null))}getReferenceCount(t){var e;return((e=this._activeTextures[t])==null?void 0:e.usageCount)??0}_increaseReferenceCount(t){this._activeTextures[t].usageCount++}_applyFilters(t,e){const s=this._renderer.renderTarget.renderTarget,n=this._renderer.filter.generateFilteredTexture({texture:t,filters:e});return this._renderer.renderTarget.bind(s,!1),n}destroy(){this._renderer=null;for(const t in this._activeTextures)this._activeTextures[t]&&this.returnTexture(this._activeTextures[t].texture);this._activeTextures=null}}class wu extends vu{constructor(t){super(t,!0)}}wu.extension={type:[yt.CanvasSystem],name:"canvasText"};class Su extends vu{constructor(t){super(t,!1)}}Su.extension={type:[yt.WebGLSystem,yt.WebGPUSystem],name:"canvasText"};jt.add(wu);jt.add(Su);jt.add(xu);class Vi extends Ng{constructor(...t){const e=Gg(t,"Text");super(e,Ye),this.renderPipeId="text",e.textureStyle&&(this.textureStyle=e.textureStyle instanceof _n?e.textureStyle:new _n(e.textureStyle)),this.autoGenerateMipmaps=e.autoGenerateMipmaps??Ge.defaultOptions.autoGenerateMipmaps}updateBounds(){const t=this._bounds,e=this._anchor;let s=0,n=0;if(this._style.trim){const{frame:o,canvasAndContext:r}=fn.getCanvasAndContext({text:this.text,style:this._style,resolution:1});fn.returnCanvasAndContext(r),s=o.width,n=o.height}else{const o=gi.measureText(this._text,this._style);s=o.width,n=o.height}t.minX=-e._x*s,t.maxX=t.minX+s,t.minY=-e._y*n,t.maxY=t.minY+n}}jt.add(Ou,Hu);const b0={Read:"📖",Write:"✏️",Edit:"🔧",Patch:"🔧",Bash:"💻",Glob:"🔍",Grep:"🔎",WebSearch:"🌐",WebFetch:"🌐",Agent:"🤖",TeamCreate:"👥",SendMessage:"💬",TaskCreate:"📋",TaskUpdate:"✅",TodoRead:"📋",TodoWrite:"✅",AskUserQuestion:"❓",EnterPlanMode:"📝",ExitPlanMode:"📝"},Vh=12,Eo=[5,4,3],se=[{id:"search",label:"Search",description:"Grep, WebSearch — Research & lookup",icon:"📚",color:15381256,colStart:0,colSpan:5,rowStart:0,rowSpan:1,x:0,y:0,width:0,height:0},{id:"terminal",label:"Terminal",description:"Bash commands — Server room",icon:"💻",color:2278750,colStart:5,colSpan:3,rowStart:0,rowSpan:1,x:0,y:0,width:0,height:0},{id:"web",label:"Web",description:"WebFetch, Browser — Network hub",icon:"🌐",color:9133302,colStart:8,colSpan:4,rowStart:0,rowSpan:1,x:0,y:0,width:0,height:0},{id:"files",label:"Files",description:"Read, Write, Edit, Glob — File storage",icon:"📁",color:3900150,colStart:0,colSpan:4,rowStart:1,rowSpan:1,x:0,y:0,width:0,height:0},{id:"thinking",label:"Thinking",description:"Planning, Questions — Conference area",icon:"💭",color:16347926,colStart:4,colSpan:5,rowStart:1,rowSpan:1,x:0,y:0,width:0,height:0},{id:"messaging",label:"Messaging",description:"SendMessage, Teams — Chat & relax",icon:"💬",color:15485081,colStart:9,colSpan:3,rowStart:1,rowSpan:1,x:0,y:0,width:0,height:0},{id:"spawn",label:"Spawn",description:"Agent spawn/despawn — Entry portal",icon:"🌀",color:11032055,colStart:0,colSpan:3,rowStart:2,rowSpan:1,x:0,y:0,width:0,height:0},{id:"idle",label:"Idle",description:"Idle agents rest here — Kitchen & lounge",icon:"☕",color:7041664,colStart:3,colSpan:5,rowStart:2,rowSpan:1,x:0,y:0,width:0,height:0},{id:"tasks",label:"Tasks",description:"TaskCreate, TaskUpdate — Kanban & planning",icon:"📋",color:1357990,colStart:8,colSpan:4,rowStart:2,rowSpan:1,x:0,y:0,width:0,height:0}],Zt=new Map(se.map(i=>[i.id,i]));let Xa=1100,Za=980;function _0(i,t){Xa=i,Za=t}const ft=[{name:"blue",body:4886745,outline:2906762,highlight:8042741,eye:16777215,skin:16767916},{name:"green",body:5025616,outline:3046706,highlight:8505220,eye:16777215,skin:16767916},{name:"red",body:15037299,outline:12986408,highlight:16764370,eye:16777215,skin:16767916},{name:"purple",body:11225020,outline:6953882,highlight:13538264,eye:16777215,skin:16767916},{name:"orange",body:16750592,outline:15094016,highlight:16764032,eye:16777215,skin:16767916},{name:"cyan",body:2541274,outline:33679,highlight:8445674,eye:16777215,skin:16767916},{name:"pink",body:15753874,outline:12720219,highlight:16301008,eye:16777215,skin:16767916},{name:"teal",body:2533018,outline:26972,highlight:8440772,eye:16777215,skin:16767916},{name:"amber",body:16761095,outline:16748288,highlight:16769154,eye:3355443,skin:16767916},{name:"indigo",body:6056896,outline:2635155,highlight:10463450,eye:16777215,skin:16767916},{name:"lime",body:10275941,outline:5606191,highlight:12968357,eye:3355443,skin:16767916},{name:"brown",body:9268835,outline:5125166,highlight:12364452,eye:16777215,skin:16767916}],x0={background:14995640},ye={"claude-opus-4-6":{input:15,output:75},"claude-opus-4-5-20250620":{input:15,output:75},"claude-sonnet-4-6":{input:3,output:15},"claude-sonnet-4-5-20250514":{input:3,output:15},"claude-sonnet-4-0-20250514":{input:3,output:15},"claude-haiku-4-5-20251001":{input:1,output:5},"claude-3-7-sonnet-20250219":{input:3,output:15},"claude-3-5-sonnet-20241022":{input:3,output:15},"claude-3-5-haiku-20241022":{input:1,output:5},"claude-3-opus-20240229":{input:15,output:75},"gpt-4o":{input:2.5,output:10},"gpt-4o-mini":{input:.15,output:.6},"gpt-4-turbo":{input:10,output:30},"gpt-4":{input:30,output:60},o1:{input:15,output:60},"o1-mini":{input:1.1,output:4.4},o3:{input:10,output:40},"o3-mini":{input:1.1,output:4.4},"o4-mini":{input:1.1,output:4.4},"gemini-2.5-pro":{input:1.25,output:10},"gemini-2.5-flash":{input:.15,output:.6},"gemini-2.0-flash":{input:.1,output:.4},"gemini-2.0-flash-lite":{input:.075,output:.3},"gemini-1.5-pro":{input:1.25,output:5},"gemini-1.5-flash":{input:.075,output:.3},"deepseek-chat":{input:.27,output:1.1},"deepseek-reasoner":{input:.55,output:2.19},"grok-3":{input:3,output:15},"grok-3-mini":{input:.3,output:.5},"grok-2":{input:2,output:10},"mistral-large":{input:2,output:6},"mistral-small":{input:.1,output:.3},codestral:{input:.1,output:.3}},Yh={input:3,output:15},Zr={claude:2e5,"gpt-4o":128e3,"gpt-4o-mini":128e3,"gpt-4-turbo":128e3,"gpt-4":8192,o1:2e5,"o1-mini":128e3,o3:2e5,"o3-mini":2e5,"o4-mini":2e5,"gemini-2":1e6,"gemini-1.5":1e6,"deepseek-chat":64e3,"deepseek-reasoner":128e3,"grok-3":131072,"grok-2":131072,"mistral-large":128e3,"mistral-small":32e3,codestral:256e3};function El(i){if(!i)return Yh;const t=i.toLowerCase();if(ye[t])return ye[t];for(const[e,s]of Object.entries(ye))if(t.startsWith(e)||t.includes(e))return s;return t.includes("opus")?ye["claude-opus-4-6"]:t.includes("haiku")?ye["claude-haiku-4-5-20251001"]:t.includes("sonnet")?ye["claude-sonnet-4-6"]:t.includes("o3-mini")||t.includes("o4-mini")?ye["o3-mini"]:t.includes("o1-mini")?ye["o1-mini"]:t.includes("gemini-2.5")?ye["gemini-2.5-pro"]:t.includes("gemini-2")?ye["gemini-2.0-flash"]:t.includes("gemini")?ye["gemini-1.5-pro"]:t.includes("gpt-4o")?ye["gpt-4o"]:t.includes("deepseek")?ye["deepseek-chat"]:t.includes("grok")?ye["grok-3"]:t.includes("mistral")?ye["mistral-large"]:Yh}function v0(i){if(!i)return 2e5;const t=i.toLowerCase();if(Zr[t])return Zr[t];let e=null;for(const[s,n]of Object.entries(Zr))(t.startsWith(s)||t.includes(s))&&(!e||s.length>e[0].length)&&(e=[s,n]);return e?e[1]:2e5}function ku(i){let t=0;for(let e=0;e<i.length;e++)t=(t<<5)-t+i.charCodeAt(e)|0;return Math.abs(t)%ft.length}function Pl(i){const t=El(i.model);return i.totalInputTokens/1e6*t.input+i.totalOutputTokens/1e6*t.output+i.cacheReadTokens/1e6*t.input*.1+i.cacheCreationTokens/1e6*t.input*1.25}const jh=["Pixel","Turbo","Nimbus","Sparky","Biscuit","Wombat","Noodle","Zigzag","Pickle","Mango","Rocket","Waffle","Pebble","Comet","Doodle","Gizmo","Quasar","Tango","Breeze","Fidget","Blitz","Marble","Sprout","Fizz","Cosmo","Rusty","Tofu","Orbit","Jinx","Clover","Bolt","Mochi","Atlas","Ember","Pippin","Rumble","Sage","Twix","Flint","Bumble","Nova","Chip","Pecan","Drift","Pluto","Rune","Taffy","Zing","Vapor","Acorn","Sonic","Puffin","Quill","Dash","Hazel","Crisp","Fable","Maple","Glitch","Sable"];function ho(i){let t=0;for(let s=0;s<i.length;s++)t=(t<<5)-t+i.charCodeAt(s)|0;const e=Math.abs(t)%jh.length;return jh[e]}async function w0(i){const t=new Zd,e=document.getElementById("canvas-container")??i;return await t.init({background:x0.background,resizeTo:e,antialias:!1,resolution:window.devicePixelRatio||1,autoDensity:!0}),i.appendChild(t.canvas),t}const Xh=1e3,S0=1e4;class k0{constructor(t){b(this,"ws",null);b(this,"store");b(this,"reconnectMs",Xh);b(this,"reconnectTimer",null);b(this,"disposed",!1);this.store=t,this.store.setWsClient(this)}send(t){this.ws&&this.ws.readyState===WebSocket.OPEN&&this.ws.send(JSON.stringify(t))}connect(){if(this.disposed)return;const e=`${location.protocol==="https:"?"wss:":"ws:"}//${location.host}/ws`;this.ws=new WebSocket(e),this.ws.onopen=()=>{this.reconnectMs=Xh,this.store.setConnectionStatus("connected")},this.ws.onmessage=s=>{let n;try{n=JSON.parse(s.data)}catch{return}this.store.handleMessage(n)},this.ws.onclose=()=>{this.store.setConnectionStatus("disconnected"),this.scheduleReconnect()},this.ws.onerror=()=>{}}scheduleReconnect(){this.disposed||this.reconnectTimer||(this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.connect()},this.reconnectMs),this.reconnectMs=Math.min(this.reconnectMs*2,S0))}disconnect(){this.disposed=!0,this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.ws&&(this.ws.close(),this.ws=null)}}const pr=class pr{constructor(){b(this,"agents",new Map);b(this,"listeners",new Map);b(this,"_connectionStatus","disconnected");b(this,"wsClient",null);b(this,"_timeline",[]);b(this,"_pendingPermissions",new Map);b(this,"_lastHookActivityAt",null)}get connectionStatus(){return this._connectionStatus}setWsClient(t){this.wsClient=t}getAgents(){return this.agents}getAgent(t){return this.agents.get(t)}requestHistory(t){var e;(e=this.wsClient)==null||e.send({type:"request:history",agentId:t})}requestToolChain(){var t;(t=this.wsClient)==null||t.send({type:"request:toolchain"})}requestTaskGraph(){var t;(t=this.wsClient)==null||t.send({type:"request:taskgraph"})}getPendingPermissions(){return Array.from(this._pendingPermissions.values())}isHooksActive(){return this._lastHookActivityAt!==null&&Date.now()-this._lastHookActivityAt<6e4}markHookActivity(){this._lastHookActivityAt=Date.now()}approvePermission(t,e){var s;(s=this.wsClient)==null||s.send({type:"permission:approve",permissionId:t,updatedInput:e})}denyPermission(t){var e;(e=this.wsClient)==null||e.send({type:"permission:deny",permissionId:t})}approvePermissionAlways(t,e){var s;(s=this.wsClient)==null||s.send({type:"permission:approve-always",permissionId:t,rules:e})}getTimeline(){return this._timeline}pushTimelineEvent(t,e,s){this._timeline.push({type:t,agent:{...e},timestamp:s});const n=Date.now()-1800*1e3;let o=0;for(;o<this._timeline.length&&this._timeline[o].timestamp<n;)o++;const r=this._timeline.length-pr.MAX_TIMELINE;r>0&&(o=Math.max(o,r)),o>0&&this._timeline.splice(0,o)}on(t,e){let s=this.listeners.get(t);s||(s=new Set,this.listeners.set(t,s)),s.add(e)}off(t,e){const s=this.listeners.get(t);s&&s.delete(e)}emit(t,e){const s=this.listeners.get(t);if(s)for(const n of s)n(e)}dispose(){this.listeners.clear(),this.agents.clear(),this._timeline=[],this._pendingPermissions.clear()}setConnectionStatus(t){this._connectionStatus=t,this.emit("connection:status",t)}handleMessage(t){switch(t.type){case"full_state":{this.agents.clear();for(const e of t.agents)this.agents.set(e.id,e);this.emit("state:reset",this.agents);break}case"agent:spawn":{this.agents.set(t.agent.id,t.agent),this.pushTimelineEvent("agent:spawn",t.agent,t.timestamp),this.emit("agent:spawn",t.agent);break}case"agent:update":{this.agents.set(t.agent.id,t.agent),this.pushTimelineEvent("agent:update",t.agent,t.timestamp),this.emit("agent:update",t.agent);break}case"agent:idle":{this.agents.set(t.agent.id,t.agent),this.pushTimelineEvent("agent:idle",t.agent,t.timestamp),this.emit("agent:idle",t.agent);break}case"agent:shutdown":{const e=this.agents.get(t.agentId);e&&this.pushTimelineEvent("agent:shutdown",e,t.timestamp),this.emit("agent:shutdown",t.agentId),this.agents.delete(t.agentId);break}case"agent:history":{this.emit("agent:history",{agentId:t.agentId,entries:t.entries});break}case"timeline:snapshot":{this._timeline=t.events,this.emit("timeline:snapshot",t.events);break}case"anomaly:alert":{this.emit("anomaly:alert",t.anomaly);break}case"toolchain:snapshot":{this.emit("toolchain:snapshot",t.data);break}case"taskgraph:snapshot":{this.emit("taskgraph:snapshot",t.data);break}case"permission:request":{this._pendingPermissions.set(t.permission.permissionId,t.permission),this.markHookActivity(),this.emit("permission:request",t.permission);break}case"permission:resolved":{this._pendingPermissions.delete(t.permissionId),this.emit("permission:resolved",{permissionId:t.permissionId,decision:t.decision});break}case"hooks:status":{this.markHookActivity(),this.emit("hooks:status",void 0);break}case"task:completed":{const e=t;this.emit("task:completed",{taskId:e.taskId,taskSubject:e.taskSubject,agentId:e.agentId});break}}}};b(pr,"MAX_TIMELINE",5e3);let Ka=pr;const T0=658452;function Zh(i,t,e){const s=new Wt;return e?(e(s,i,t),s):(s.rect(0,0,i,t).fill(T0),s)}const T={deskTop:15262944,deskEdge:13683912,deskHighlight:16052976,darkWood:8015920,medWood:10119224,wood:12093512,lightWood:13674584,paleWood:15255672,screenFrame:2236980,screenBlue:4491502,screenGlow:8965375,screenDark:3359829,screenGreen:2280550,screenGreenGlow:4517512,led:4521830,ledRed:16729156,ledBlue:4500223,ledYellow:16763938,bookRed:14496563,bookDarkRed:11149858,bookGreen:4500036,bookDarkGreen:3377203,bookBlue:3364300,bookNavy:2241416,bookYellow:14531362,bookPurple:10044620,bookOrange:15628066,bookCyan:2271931,bookBrown:8939076,bookPink:14505352,bookWhite:15263976,bookTan:13150839,chairSeat:3816008,chairBack:2763320,chairArm:4868696,chairWheel:2236976,chairHighlight:5921384,sofaBody:14190664,sofaDark:12087352,sofaLight:15771752,sofaHighlight:16304264,sofaArm:12613696,metalBright:13684960,metalLight:11579588,metalMid:8947864,metalDark:5592424,metalFrame:4473946,metalShine:15263984,shelfFrame:7899296,shelfBack:8951984,shelfEdge:6846624,shelfHighlight:10004672,leafDark:2783786,leaf:4108350,leafLight:5950554,leafBright:7794294,potBase:11561024,potDark:9063978,potRim:13404240,potHighlight:14721120,soil:5915184,white:16053492,offWhite:14736856,paper:15788244,cream:16577764,black:1315872,red:15610675,green:3394628,blue:3377390,yellow:15649843,vendingBody:3824250,vendingGlass:8960972,vendingLight:11197934,fridgeBody:13161690,fridgeLight:14740208,fridgeDark:8951972,fridgeHandle:10529464,portalDeep:5575082,portalMid:7812044,portalLight:11163135,portalGlow:14522879,whiteboardFrame:13421789,whiteboardSurface:16316668,stickyYellow:16772676,stickyPink:16746666,stickyGreen:8973960,stickyBlue:8961023,stickyOrange:16755268,stickyPurple:13404415},Kh=[[T.bookRed,T.bookGreen,T.bookBlue,T.bookYellow,T.bookPurple,T.bookOrange,T.bookBrown,T.bookCyan,T.bookPink,T.bookWhite,T.bookTan,T.bookNavy],[T.bookBlue,T.bookOrange,T.bookDarkGreen,T.bookPink,T.bookBrown,T.bookYellow,T.bookRed,T.bookWhite,T.bookNavy,T.bookCyan,T.bookTan,T.bookPurple],[T.bookPurple,T.bookTan,T.bookCyan,T.bookDarkRed,T.bookGreen,T.bookNavy,T.bookOrange,T.bookBrown,T.bookBlue,T.bookPink,T.bookYellow,T.bookWhite]],S=4,u=i=>i*S;function M(i,t,e,s,n,o){i.rect(t,e,s,n).fill(o)}function cr(i,t,e,s,n,o,r){i.rect(t,e,s,n).fill({color:o,alpha:r})}function ie(i,t,e,s,n){cr(i,t+3,e+n,s,4,0,.12)}function dr(i,t,e){const s=u(16),n=u(8);ie(i,t,e,s,n),M(i,t,e+u(2),s,n-u(2),T.deskTop),M(i,t+S,e+u(2),s-S*2,S,T.deskHighlight),M(i,t,e+n-S,s,S,T.deskEdge),M(i,t+u(3),e,u(8),u(6),T.screenFrame),M(i,t+u(4),e+S,u(6),u(4),T.screenBlue),M(i,t+u(4),e+S,u(3),u(2),T.screenGlow),M(i,t+u(6),e+u(5),u(2),S,T.metalDark),M(i,t+u(5),e+u(6),u(4),S,T.metalDark),M(i,t+u(3),e+u(6),u(7),u(2),T.offWhite),M(i,t+u(3)+1,e+u(6)+1,u(7)-2,S-2,T.white),M(i,t+u(11),e+u(6),u(2),u(2),T.metalMid),M(i,t+u(11),e+u(6),u(2),S,T.metalLight)}function C0(i,t,e){const s=u(14),n=u(7);ie(i,t,e,s,n),M(i,t,e,s,n,T.deskTop),M(i,t+S,e,s-S*2,S,T.deskHighlight),M(i,t,e+n-S,s,S,T.deskEdge),M(i,t+u(3),e+S,u(7),u(4),T.metalDark),M(i,t+u(4),e+u(1)+2,u(5),u(3)-2,T.screenBlue),M(i,t+u(4),e+u(1)+2,u(3),u(1),T.screenGlow),M(i,t+u(3),e+u(5),u(7),u(2),T.metalFrame),M(i,t+u(4),e+u(5)+2,u(5),S,T.metalMid),M(i,t+u(11),e+u(4),u(2),u(2),T.metalMid)}function Qh(i,t,e){const s=u(16),n=u(8);ie(i,t,e,s,n),M(i,t,e+u(2),s,n-u(2),T.metalFrame),M(i,t+S,e+u(3),s-S*2,n-u(4),T.metalDark),M(i,t,e+n-S,s,S,T.metalMid),M(i,t+u(2),e,u(10),u(7),T.screenFrame),M(i,t+u(3),e+S,u(8),u(5),T.screenGreen);for(let o=0;o<u(5);o+=S)M(i,t+u(3),e+S+o,u(8),1,T.screenGreenGlow);M(i,t+u(3),e+u(1),u(4),1,T.screenGreenGlow),M(i,t+u(3),e+u(2),u(6),1,T.screenGreenGlow),M(i,t+u(3),e+u(3),u(3),1,T.screenGreenGlow),M(i,t+u(6),e+u(6),u(2),S,T.metalDark)}function Nt(i,t,e){M(i,t+S,e+u(5),u(3),S,T.chairWheel),M(i,t,e+u(1),u(5),u(4),T.chairSeat),M(i,t+S,e+u(1),u(3),u(4),T.chairHighlight),M(i,t+S,e,u(3),u(2),T.chairBack),M(i,t+u(2),e,S,S,T.chairHighlight),M(i,t,e+u(2),S,u(2),T.chairArm),M(i,t+u(4),e+u(2),S,u(2),T.chairArm)}function yi(i,t,e,s){const n=u(s?18:11),o=u(16);ie(i,t,e,n,o),M(i,t,e,n,o,T.shelfFrame),M(i,t,e,S,o,T.shelfEdge),M(i,t+n-S,e,S,o,T.shelfEdge),M(i,t+S,e+S,n-S*2,o-S*2,T.shelfBack),M(i,t,e,n,S,T.shelfHighlight);for(let r=1;r<=4;r++){const l=e+r*u(3);M(i,t,l,n,S+1,T.shelfFrame),M(i,t+S,l,n-S*2,1,T.shelfHighlight)}for(let r=0;r<4;r++){const l=e+(r+1)*u(3),h=Kh[r%Kh.length];let d=t+S+1,c=r*3;for(;d<t+n-S-1;){const p=S-1,g=u(2)+(c*7+r*3)%4;M(i,d,l-g,p,g,h[c%h.length]),d+=p+1,c++}}M(i,t,e+o-S,n,S,T.shelfFrame)}function cn(i,t,e){const s=u(8),n=u(16);ie(i,t,e,s,n),M(i,t,e,s,n,T.metalFrame),M(i,t,e,S,n,T.metalDark),M(i,t+s-S,e,S,n,T.metalDark),M(i,t,e,s,S,T.metalMid);for(let o=0;o<5;o++){const r=e+u(1)+o*u(3);M(i,t+S,r,s-S*2,u(2),T.metalDark),M(i,t+S,r,s-S*2,S,T.metalMid),M(i,t+u(1),r+S,S,S,o===2?T.ledRed:o===4?T.ledBlue:T.led),M(i,t+u(2),r+S,s-u(4),1,T.metalDark)}M(i,t,e+n-S,s,S,T.metalMid)}function pn(i,t,e){const s=u(6),n=u(12);ie(i,t,e,s,n),M(i,t,e,s,n,T.metalDark),M(i,t,e,S,n,T.metalMid),M(i,t,e,s,S,T.metalLight);for(let o=0;o<2;o++){const r=e+S+o*u(5);M(i,t+S,r,s-S*2,u(4),T.metalMid),M(i,t+S,r,s-S*2,S,T.metalLight),M(i,t+u(1),r,s-u(3),S,T.paper),M(i,t+u(2),r+u(2),u(2),S,T.metalFrame),M(i,t+u(2),r+u(2),u(2),1,T.metalBright)}M(i,t,e+n-S,s,S,T.metalMid)}function Qa(i,t,e,s){cr(i,t-s/2+4,e-s/2+4,s,s,0,.12);const n=s/2;M(i,t-n+u(2),e-n,s-u(4),S,T.medWood),M(i,t-n+u(2),e+n-S,s-u(4),S,T.medWood),M(i,t-n,e-n+u(2),S,s-u(4),T.medWood),M(i,t+n-S,e-n+u(2),S,s-u(4),T.medWood),M(i,t-n+S,e-n+S,s-S*2,S,T.medWood),M(i,t-n+S,e+n-S*2,s-S*2,S,T.medWood),M(i,t-n+S,e-n+S,S,s-S*2,T.medWood),M(i,t+n-S*2,e-n+S,S,s-S*2,T.medWood),M(i,t-n+u(2),e-n+S,s-u(4),s-S*2,T.lightWood),M(i,t-n+S,e-n+u(2),s-S*2,s-u(4),T.lightWood),M(i,t-u(3),e-u(2),u(6),S,T.paleWood)}function Ja(i,t,e,s,n){ie(i,t,e,s,n),M(i,t,e,s,n,T.whiteboardFrame),M(i,t+S,e+S,s-S*2,n-S*2,T.whiteboardSurface),M(i,t+u(2),e+u(2),s*.45,S,T.blue),M(i,t+u(2),e+u(4),s*.65,S,T.red),M(i,t+u(2),e+u(6),s*.35,S,T.black),s>u(14)&&M(i,t+s/2,e+u(2),s*.3,S,T.green),M(i,t+u(2),e+n,s-u(4),S,T.metalDark),M(i,t+u(3),e+n,S,S,T.red),M(i,t+u(5),e+n,S,S,T.blue),M(i,t+u(7),e+n,S,S,T.green)}function A0(i,t,e,s){cr(i,t+2,e+2,u(4),u(4),0,.09),M(i,t,e,u(4),u(4),s),cr(i,t,e,u(4),S,16777215,.2),M(i,t+S,e+u(1)+2,u(2),1,T.metalDark),M(i,t+S,e+u(2)+1,u(2)+2,1,T.metalDark)}function Jh(i,t,e,s){ie(i,t,e,s,u(9)),M(i,t,e,s,u(3),T.sofaDark),M(i,t+S,e,s-S*2,S,T.sofaLight),M(i,t,e,S*2,u(9),T.sofaArm),M(i,t+s-S*2,e,S*2,u(9),T.sofaArm);const n=Math.floor((s-u(3)-S*4)/2);M(i,t+S*2,e+u(3),s-S*4,u(6),T.sofaBody),M(i,t+S*2+n,e+u(3),S,u(6),T.sofaDark),M(i,t+S*2,e+u(3),n,S,T.sofaHighlight),M(i,t+S*2+n+S,e+u(3),n-1,S,T.sofaHighlight),M(i,t,e+u(8),s,S,T.sofaDark)}function co(i,t,e,s,n){ie(i,t,e,s,n),M(i,t+S,e+n-S,s,S,T.medWood),M(i,t,e,s,n-S,T.lightWood),M(i,t+S,e,s-S*2,S,T.paleWood),M(i,t,e,S,n-S,T.paleWood)}function rs(i,t,e){ie(i,t+S,e+u(6),u(5),u(3)),M(i,t+S,e+u(6),u(5),u(3),T.potBase),M(i,t+S,e+u(6),u(5),S,T.potRim),M(i,t+u(2),e+u(6),u(3),S,T.potHighlight),M(i,t+S,e+u(8),u(5),S,T.potDark),M(i,t+u(2),e+u(5),u(3),S,T.soil),M(i,t+u(3),e+u(2),S,u(4),T.leaf),M(i,t+u(1),e+u(3),S,u(2),T.leaf),M(i,t+u(5),e+u(3),S,u(2),T.leaf),M(i,t+u(2),e,u(3),u(3),T.leaf),M(i,t+u(3),e+S,u(2),u(3),T.leafLight),M(i,t,e+u(2),u(2),u(2),T.leafDark),M(i,t+u(5),e+u(2),u(2),u(2),T.leafLight),M(i,t+u(1),e+u(1),S,u(2),T.leafDark),M(i,t+u(5),e+u(1),S,u(2),T.leafBright),M(i,t+u(3),e,S,S,T.leafBright)}function xs(i,t,e){M(i,t,e+u(3),u(3),u(2),T.potBase),M(i,t,e+u(3),u(3),S,T.potRim),M(i,t+S,e+u(3),S,S,T.potHighlight),M(i,t,e+u(4),u(3),S,T.potDark),M(i,t+S,e,S,u(3),T.leaf),M(i,t,e+S,S,u(2),T.leafDark),M(i,t+u(2),e+S,S,u(2),T.leafLight),M(i,t+S,e,S,S,T.leafBright)}function Tu(i,t,e,s,n){ie(i,t,e,s,n),M(i,t,e,s,n,T.darkWood),M(i,t+S,e+S,s-S*2,n-S*2,8956620),M(i,t+s-u(4),e+u(1),u(3),u(3),T.yellow),M(i,t+S,e+n-u(5),u(4),u(3),4482696),M(i,t+u(3),e+n-u(6),u(3),u(1),5601177),M(i,t+u(3),e+n-u(6),S,S,T.white),M(i,t+S,e+n-u(2),s-S*2,S,T.leaf)}function Cu(i,t,e){M(i,t+S,e,u(4),S,T.offWhite),M(i,t,e+S,u(6),u(4),T.white),M(i,t+S,e+u(5),u(4),S,T.offWhite),M(i,t+S,e+S,u(4),u(4),T.cream),M(i,t+u(3),e+S,S,S,T.black),M(i,t+u(5)-S,e+u(3),S,S,T.black),M(i,t+u(3),e+u(5)-S,S,S,T.black),M(i,t+S+1,e+u(3),S,S,T.black),M(i,t+u(3),e+u(2),S,u(2),T.black),M(i,t+u(3),e+u(3),S,S,T.red)}function Ii(i,t,e){M(i,t,e,u(2),u(3),T.white),M(i,t,e+u(2),u(2),S,T.offWhite),M(i,t+u(2),e+S,S,S,T.offWhite),M(i,t,e,u(2),S,11171652)}function Xi(i,t,e){M(i,t+3,e+3,u(4),u(5),T.offWhite),M(i,t,e,u(4),u(5),T.paper),M(i,t+S,e+u(1),u(2),1,T.metalDark),M(i,t+S,e+u(2),u(3)-1,1,T.metalDark),M(i,t+S,e+u(3),u(2)+1,1,T.metalDark)}function Kr(i,t,e,s){ie(i,t,e,u(4),u(4)),M(i,t,e,u(4),u(4),s),M(i,t,e,u(4),S,T.paleWood),M(i,t,e+u(3),u(4),S,T.darkWood),M(i,t+S,e+S,u(2),u(2),T.offWhite)}function M0(i,t,e){const s=u(9),n=u(18);ie(i,t,e,s,n),M(i,t,e,s,n,T.vendingBody),M(i,t,e,S,n,T.metalMid),M(i,t,e,s,S,T.metalDark),M(i,t+S,e+u(2),s-S*2,u(10),T.vendingGlass),M(i,t+S,e+u(2),s-S*2,S,T.vendingLight);const o=[T.bookRed,T.bookOrange,T.bookGreen,T.bookBlue,T.bookYellow,T.bookPink];for(let r=0;r<4;r++){for(let l=0;l<3;l++)M(i,t+u(2)+l*u(2),e+u(3)+r*u(2),u(1)+1,u(1)+1,o[(r*2+l)%o.length]);M(i,t+S,e+u(4)+r*u(2),s-S*2,1,T.metalDark)}M(i,t+S,e+u(13),s-S*2,u(3),T.metalFrame),M(i,t+s-u(2),e+u(14),S,S,T.ledRed),M(i,t+s-u(2),e+u(15),S,S,T.green),M(i,t,e+n-S,s,S,T.metalDark)}function E0(i,t,e){const s=u(7),n=u(16);ie(i,t,e,s,n),M(i,t,e,s,n,T.fridgeBody),M(i,t,e,s,S,T.metalShine),M(i,t,e,S,n,T.fridgeLight),M(i,t+S,e+S,s-S*2,n-S*2,T.fridgeLight),M(i,t+S,e+u(5),s-S*2,S,T.fridgeDark),M(i,t+s-S*2,e+u(2),S,u(2),T.fridgeHandle),M(i,t+s-S*2,e+u(7),S,u(2),T.fridgeHandle),M(i,t,e+n-S,s,S,T.fridgeDark)}function P0(i,t,e){M(i,t,e,u(5),u(7),T.metalDark),M(i,t,e,S,u(7),T.metalMid),M(i,t,e,u(5),S,T.metalBright),M(i,t+u(1),e+S,u(3),u(3),T.screenBlue),M(i,t+u(1),e+S,u(3),S,T.screenGlow),M(i,t+S,e+u(4),u(3),u(2),T.metalMid),M(i,t+u(1),e+u(4),S,S,T.red),M(i,t+u(2),e+u(4),S,S,T.led),M(i,t,e+u(6),u(5),S,T.metalFrame),M(i,t+u(1),e+u(5)+2,u(2),u(2),T.white)}function I0(i,t,e){M(i,t,e+u(3),u(4),u(6),T.fridgeLight),M(i,t,e+u(3),S,u(6),T.fridgeBody),M(i,t,e+u(3),u(4),S,T.metalShine),M(i,t+S,e,u(2),u(4),T.screenBlue),M(i,t+S,e,u(2),S,T.screenGlow),M(i,t+S,e+u(5),S,S,T.blue),M(i,t+u(2),e+u(5),S,S,T.red),M(i,t,e+u(8),u(4),S,T.fridgeDark)}function L0(i,t,e,s){ie(i,t,e,s,u(9)),M(i,t,e+u(5),s,u(5),T.deskTop),M(i,t,e+u(5),S,u(5),T.deskHighlight);const n=u(5);for(let o=0;o<s-S;o+=n+2)M(i,t+o+2,e+u(6),n-1,u(3),T.deskEdge),M(i,t+o+u(2),e+u(7),S,S,T.metalMid);M(i,t,e,s,u(5),T.deskTop),M(i,t+S,e+S,s-S*2,u(3),T.deskHighlight),M(i,t,e,s,S,T.white),M(i,t,e+u(5)-S,s,S,T.deskEdge)}function B0(i,t,e,s,n){ie(i,t,e,s,n),M(i,t,e,s,n,T.whiteboardFrame),M(i,t+S,e+S,s-S*2,n-S*2,T.whiteboardSurface);const o=Math.floor((s-u(5))/3),r=[T.bookRed,T.bookYellow,T.bookGreen];for(let l=0;l<3;l++){const h=t+u(2)+l*(o+S);M(i,h,e+u(2),o,u(2),r[l]),M(i,h,e+u(2),o,S,15658734);const d=[T.stickyYellow,T.stickyBlue,T.stickyPink,T.stickyGreen,T.stickyOrange,T.stickyPurple],c=l===0?3:l===1?2:1;for(let p=0;p<c;p++)M(i,h+2,e+u(5)+p*(u(3)+2),o-4,u(2),d[(l+p*2)%d.length]),M(i,h+2,e+u(5)+p*(u(3)+2),o-4,1,15658734),M(i,h+S,e+u(5)+p*(u(3)+2)+S+1,o-S*2,1,T.metalDark)}}function R0(i,t,e){const s=u(22),n=u(15);ie(i,t,e,s,n),M(i,t,e,s,n,T.screenFrame),M(i,t,e,s,S,T.metalMid),M(i,t+S,e+S,s-S*2,n-S*2,T.screenDark),M(i,t+u(2),e+u(2),s-u(4),n-u(4),T.screenBlue);const o=t+s/2,r=e+n/2;M(i,o-u(3),r-u(3),u(6),u(6),1140411),M(i,o-u(2),r-u(1),u(3),u(2),T.leafDark),M(i,o+u(1),r,u(2),u(1),T.leaf),M(i,t+u(2),e+u(2),s-u(4),1,4491468),M(i,t+u(2),e+n-u(3),s-u(4),1,4491468),M(i,t+u(4),e+u(4),S,S,T.led),M(i,t+s-u(6),e+u(4),S,S,T.ledRed),M(i,t+s/2-u(1),e+n,u(2),S,T.metalDark),M(i,t+s/2-u(2),e+n+S,u(4),S,T.metalDark)}function $0(i,t,e){M(i,t-u(7),e-u(1),u(14),u(2),T.portalDeep),M(i,t-u(1),e-u(7),u(2),u(14),T.portalDeep),M(i,t-u(5),e-u(6),u(10),S,T.portalMid),M(i,t-u(6),e-u(5),S,u(10),T.portalMid),M(i,t-u(5),e+u(5),u(10),S,T.portalMid),M(i,t+u(5),e-u(5),S,u(10),T.portalMid),M(i,t-u(4),e-u(5),u(8),S,T.portalLight),M(i,t-u(5),e-u(4),S,u(8),T.portalLight),M(i,t-u(4),e+u(4),u(8),S,T.portalLight),M(i,t+u(4),e-u(4),S,u(8),T.portalLight),M(i,t-u(3),e-u(3),u(6),u(6),T.portalDeep),M(i,t-u(2),e-u(2),u(4),u(4),T.portalMid),M(i,t-u(1),e-u(1),u(2),u(2),T.portalGlow),M(i,t-u(4),e,S,S,T.portalGlow),M(i,t+u(3),e-u(1),S,S,T.portalGlow),M(i,t,e+u(3),S,S,T.portalGlow)}function D0(i,t,e,s,n){yi(i,t+u(2),e+u(4),!0),yi(i,t+u(22),e+u(4),!0),yi(i,t+u(42),e+u(4),!0),yi(i,t+u(62),e+u(4),!1),yi(i,t+u(2),e+u(23),!1),yi(i,t+u(2),e+u(42),!1),co(i,t+u(20),e+u(33),u(14),u(7)),Nt(i,t+u(24),e+u(42)),Nt(i,t+u(24),e+u(27)),Xi(i,t+u(22),e+u(34)),Ii(i,t+u(30),e+u(34)),co(i,t+u(44),e+u(33),u(14),u(7)),Nt(i,t+u(48),e+u(42)),Nt(i,t+u(48),e+u(27)),Xi(i,t+u(46),e+u(35)),rs(i,t+u(2),e+n-u(12)),rs(i,t+s-u(9),e+u(22)),xs(i,t+s-u(6),e+n-u(8)),pn(i,t+s-u(8),e+n-u(15)),pn(i,t+s-u(15),e+n-u(15))}function z0(i,t,e,s,n){cn(i,t+u(2),e+u(4)),cn(i,t+u(13),e+u(4)),cn(i,t+u(24),e+u(4)),cn(i,t+s-u(10),e+u(25)),cn(i,t+s-u(10),e+u(45)),Qh(i,t+u(2),e+u(25)),Nt(i,t+u(6),e+u(37)),Qh(i,t+u(2),e+u(47)),Nt(i,t+u(6),e+u(59)),M(i,t+u(11),e+u(22),S,n-u(24),T.metalFrame),M(i,t+u(22),e+u(22),S,n-u(24),T.metalFrame),M(i,t+u(36),e+u(6),u(7),u(12),T.metalFrame),M(i,t+u(37),e+u(7),S,S,T.led),M(i,t+u(39),e+u(7),S,S,T.led),M(i,t+u(37),e+u(9),S,S,T.ledRed),M(i,t+u(39),e+u(9),S,S,T.led),M(i,t+u(37),e+u(11),S,S,T.ledBlue),M(i,t+u(39),e+u(11),S,S,T.ledYellow)}function F0(i,t,e,s,n){R0(i,t+u(2),e+u(4)),cn(i,t+s-u(10),e+u(4)),dr(i,t+u(2),e+u(25)),Nt(i,t+u(6),e+u(37)),dr(i,t+u(26),e+u(25)),Nt(i,t+u(30),e+u(37)),co(i,t+u(12),e+u(49),u(16),u(6)),M(i,t+u(14),e+u(50),u(10),u(3),T.metalDark),M(i,t+u(14),e+u(50),u(10),S,T.metalMid);for(let o=0;o<6;o++)M(i,t+u(15)+o*u(1)+2,e+u(51)+2,S-1,S-1,o<5?T.led:T.ledRed);rs(i,t+u(2),e+n-u(13)),xs(i,t+s-u(5),e+n-u(9))}function N0(i,t,e,s,n){pn(i,t+u(2),e+u(4)),pn(i,t+u(10),e+u(4)),pn(i,t+u(18),e+u(4)),pn(i,t+u(26),e+u(4)),yi(i,t+u(2),e+u(19),!0),dr(i,t+u(26),e+u(23)),Nt(i,t+u(30),e+u(35)),Kr(i,t+u(2),e+u(39),T.paleWood),Kr(i,t+u(8),e+u(41),T.medWood),Kr(i,t+u(2),e+u(45),T.wood),Xi(i,t+u(38),e+u(6)),Xi(i,t+u(28),e+u(25)),xs(i,t+s-u(5),e+n-u(9)),rs(i,t+s-u(9),e+u(19))}function G0(i,t,e,s,n){Qa(i,t+s/2,e+n/2-u(2),u(20)),Nt(i,t+s/2-u(14),e+n/2-u(13)),Nt(i,t+s/2+u(9),e+n/2-u(13)),Nt(i,t+s/2-u(18),e+n/2-u(3)),Nt(i,t+s/2+u(14),e+n/2-u(3)),Nt(i,t+s/2-u(14),e+n/2+u(8)),Nt(i,t+s/2+u(9),e+n/2+u(8)),Ja(i,t+u(4),e+u(4),u(26),u(14)),Ja(i,t+u(34),e+u(4),u(22),u(14)),Tu(i,t+s-u(16),e+u(4),u(12),u(8)),Xi(i,t+s/2-u(5),e+n/2-u(4)),Ii(i,t+s/2+u(3),e+n/2-u(2)),rs(i,t+u(2),e+n-u(14)),rs(i,t+s-u(9),e+n-u(14))}function W0(i,t,e,s,n){Tu(i,t+u(10),e+u(4),u(16),u(9)),yi(i,t+u(2),e+u(4),!1),Jh(i,t+u(3),e+u(19),u(18)),co(i,t+u(5),e+u(31),u(14),u(6)),Ii(i,t+u(9),e+u(32)),Ii(i,t+u(14),e+u(32)),Xi(i,t+u(7),e+u(33)),Jh(i,t+u(26),e+u(23),u(12)),co(i,t+u(28),e+u(37),u(8),u(5)),Ii(i,t+u(30),e+u(38)),rs(i,t+u(2),e+n-u(13)),xs(i,t+s-u(5),e+u(4)),Cu(i,t+s-u(9),e+u(5))}function O0(i,t,e,s,n){$0(i,t+s/2,e+n/2-u(4));const o=t+(s-u(16))/2,r=e+n-u(14);M(i,o,r,u(16),u(5),T.sofaBody),M(i,o+S,r+S,u(14),u(3),T.sofaHighlight),M(i,o,r,u(16),S,T.sofaDark),M(i,o,r+u(4),u(16),S,T.sofaDark),xs(i,t+u(2),e+u(7)),xs(i,t+s-u(5),e+u(7)),rs(i,t+u(2),e+n-u(14)),rs(i,t+s-u(9),e+n-u(14));for(let l=0;l<4;l++)M(i,t+u(4)+l*u(7),e+u(5),S,S,T.portalGlow)}function H0(i,t,e,s,n){L0(i,t+u(2),e+u(4),u(30)),P0(i,t+u(4),e+u(-1)),Ii(i,t+u(10),e+u(1)),E0(i,t+u(34),e+u(4)),M0(i,t+s-u(11),e+u(4)),I0(i,t+u(45),e+u(4)),Qa(i,t+u(18),e+u(33),u(11)),Nt(i,t+u(10),e+u(29)),Nt(i,t+u(22),e+u(29)),Nt(i,t+u(10),e+u(38)),Nt(i,t+u(22),e+u(38)),Ii(i,t+u(17),e+u(32)),Qa(i,t+u(48),e+u(33),u(11)),Nt(i,t+u(40),e+u(29)),Nt(i,t+u(52),e+u(29)),Nt(i,t+u(40),e+u(38)),Nt(i,t+u(52),e+u(38)),Ii(i,t+u(47),e+u(32)),Cu(i,t+u(58),e+u(5)),xs(i,t+u(2),e+n-u(9)),xs(i,t+s-u(5),e+n-u(9))}function U0(i,t,e,s,n){B0(i,t+u(2),e+u(4),u(32),u(20));const o=[T.stickyYellow,T.stickyPink,T.stickyGreen,T.stickyBlue,T.stickyOrange,T.stickyPurple];for(let r=0;r<6;r++)A0(i,t+u(38)+r%3*u(5),e+u(4)+Math.floor(r/3)*u(5),o[r]);C0(i,t+u(4),e+u(31)),Nt(i,t+u(7),e+u(42)),dr(i,t+u(30),e+u(31)),Nt(i,t+u(34),e+u(42)),Xi(i,t+u(46),e+u(33)),Ja(i,t+u(52),e+u(4),u(14),u(12)),rs(i,t+s-u(9),e+n-u(14)),xs(i,t+u(2),e+n-u(9))}const qe={search:D0,terminal:z0,web:F0,files:N0,thinking:G0,messaging:W0,spawn:O0,idle:H0,tasks:U0},tc={search:{wallMain:15787220,wallDark:14471360,wallLight:16314596,wallBaseboard:13155496,floorType:"wood",floorA:13942944,floorB:13416600,floorGrid:12101760},terminal:{wallMain:4737120,wallDark:3684424,wallLight:5789808,wallBaseboard:3158080,floorType:"dark",floorA:2763324,floorB:3289674,floorGrid:2236980},web:{wallMain:8943784,wallDark:7364760,wallLight:9996472,wallBaseboard:6312064,floorType:"carpet",floorA:8684736,floorB:7895220,floorGrid:6842532},files:{wallMain:14734532,wallDark:13155500,wallLight:15523016,wallBaseboard:12101784,floorType:"wood",floorA:13679768,floorB:12890248,floorGrid:11575416},thinking:{wallMain:8943784,wallDark:7364760,wallLight:9996472,wallBaseboard:6312064,floorType:"carpet",floorA:9737416,floorB:8947900,floorGrid:7895212},messaging:{wallMain:15788252,wallDark:14209220,wallLight:16314600,wallBaseboard:13156528,floorType:"tile",floorA:15789284,floorB:14999768,floorGrid:13683908},spawn:{wallMain:4737120,wallDark:3684424,wallLight:5789808,wallBaseboard:3158080,floorType:"dark",floorA:3158090,floorB:3816020,floorGrid:2631740},idle:{wallMain:15260872,wallDark:13681840,wallLight:15787220,wallBaseboard:12629152,floorType:"tile",floorA:15788248,floorB:14998728,floorGrid:13945012},tasks:{wallMain:12631232,wallDark:11052200,wallLight:13683920,wallBaseboard:9999512,floorType:"carpet",floorA:12631232,floorB:11841716,floorGrid:10789028}},Ke=14,Le=10,ne=6,Qe=6,q0=1710638,V0=.55;function Tt(i,t,e,s,n,o){i.rect(t,e,s,n).fill(o)}function Y0(i,t,e,s,n,o,r,l){Tt(i,t,e,s,n,o);const h=20;let d=0;for(let c=0;c<n;c+=h){const p=Math.min(h,n-c);d%2===1&&Tt(i,t,e+c,s,p,r),Tt(i,t,e+c,s,1,l);const g=d%2*32;for(let m=g;m<s;m+=64)Tt(i,t+m,e+c+1,1,p-2,l);d++}}function j0(i,t,e,s,n,o,r,l){Tt(i,t,e,s,n,o);const h=24;for(let d=0;d<n;d+=h)for(let c=0;c<s;c+=h)(c/h+d/h)%2===0&&Tt(i,t+c,e+d,Math.min(h,s-c),Math.min(h,n-d),r),Tt(i,t+c,e+d,Math.min(h,s-c),1,l),Tt(i,t+c,e+d,1,Math.min(h,n-d),l)}function X0(i,t,e,s,n,o,r,l){Tt(i,t,e,s,n,o);for(let h=0;h<n;h+=12)for(let d=h/12%2*12;d<s;d+=24)Tt(i,t+d,e+h,4,4,r);Tt(i,t,e,s,4,l),Tt(i,t,e+n-4,s,4,l),Tt(i,t,e,4,n,l),Tt(i,t+s-4,e,4,n,l)}function Z0(i,t,e,s,n,o,r,l){Tt(i,t,e,s,n,o);const h=16;for(let d=0;d<n;d+=h)for(let c=0;c<s;c+=h)(c/h+d/h)%2===0&&Tt(i,t+c,e+d,Math.min(h,s-c),Math.min(h,n-d),r),Tt(i,t+c,e+d,Math.min(h,s-c),1,l),Tt(i,t+c,e+d,1,Math.min(h,n-d),l)}const K0={wood:Y0,tile:j0,carpet:X0,dark:Z0};class Q0{constructor(){b(this,"zones",new Map);b(this,"container",new Ft);b(this,"themeDecorators",null);b(this,"usePixelRooms",!1);for(const t of se){const e=this.createZone(t);this.zones.set(t.id,e),this.container.addChild(e.container)}}setThemeDecorators(t,e=!1){this.themeDecorators=t,this.usePixelRooms=e,this.rebuild()}createZone(t){const e=new Ft;e.position.set(t.x,t.y);const s=new Wt;e.addChild(s);const n=new Wt;this.drawRoom(n,t),e.addChild(n);const o=new Wt;return e.addChild(o),this.usePixelRooms?this.addRetroLabel(e,t):this.addGlassLabel(e,t),{container:e,staticBg:n,glowBorder:o,outerGlow:s,config:t,agentCount:0,currentGlow:0}}addRetroLabel(t,e){const s=tc[e.id],n=s&&(s.floorType==="dark"||s.floorType==="carpet"),o=new Ye({fontSize:11,fontFamily:"'Inter', 'SF Pro Display', 'Segoe UI', system-ui, sans-serif",fill:16777215,fontWeight:"700",letterSpacing:.5}),r=new Vi({text:`${e.icon} ${e.label}`,style:o});r.position.set(Le+8,1);const l=r.width+16,h=r.height+6,d=new Wt;d.roundRect(Le+2,-1,l,h,4).fill({color:0,alpha:n?.5:.55}),t.addChild(d),t.addChild(r)}addGlassLabel(t,e){const s=new Ye({fontSize:13,fontFamily:"'Inter', 'SF Pro Display', 'Segoe UI', system-ui, sans-serif",fill:16777215,fontWeight:"600",letterSpacing:.5,dropShadow:{alpha:.6,blur:4,color:0,distance:0}}),n=new Vi({text:`${e.icon} ${e.label}`,style:s});n.position.set(14,10);const o=n.width+20,r=n.height+8,l=new Wt;l.roundRect(6,5,o,r,8).fill({color:0,alpha:.3}),t.addChild(l),t.addChild(n)}drawRoom(t,e){var o;if(this.usePixelRooms){this.drawPixelRoom(t,e);return}t.roundRect(0,0,e.width,e.height,8).fill({color:q0,alpha:V0}),t.roundRect(0,0,e.width,e.height,8).stroke({color:e.color,width:1,alpha:.15});const s=14,n=((o=this.themeDecorators)==null?void 0:o[e.id])??qe[e.id];n&&n(t,s,s+16,e.width-s*2,e.height-s*2-16)}drawPixelRoom(t,e){var y;const s=e.width,n=e.height,o=tc[e.id];if(!o)return;Tt(t,0,0,s,n,o.wallMain);const r=Le,l=Ke,h=s-Le-Qe,d=n-Ke-ne,c=K0[o.floorType];c(t,r,l,h,d,o.floorA,o.floorB,o.floorGrid),Tt(t,0,0,s,Ke,o.wallDark),Tt(t,Le,Ke-2,s-Le-Qe,2,o.wallLight),Tt(t,0,0,Le,n,o.wallMain),Tt(t,Le-2,Ke,2,n-Ke-ne,o.wallLight),Tt(t,0,n-ne,s,ne,o.wallLight),Tt(t,Le,n-ne,s-Le-Qe,1,o.wallBaseboard),Tt(t,s-Qe,0,Qe,n,o.wallLight),Tt(t,s-Qe,Ke,1,n-Ke-ne,o.wallBaseboard),Tt(t,0,0,Le,Ke,o.wallDark),Tt(t,s-Qe,0,Qe,Ke,o.wallMain),Tt(t,0,n-ne,Le,ne,o.wallMain),Tt(t,s-Qe,n-ne,Qe,ne,o.wallLight);const p=Math.min(Math.floor(s*.2),60),g=Math.floor((s-p)/2);Tt(t,g,n-ne,p,ne,o.floorA),Tt(t,g,n-ne,2,ne,o.wallBaseboard),Tt(t,g+p-2,n-ne,2,ne,o.wallBaseboard);const m=((y=this.themeDecorators)==null?void 0:y[e.id])??qe[e.id];m&&m(t,r,l,h,d)}setAgentCount(t,e){const s=this.zones.get(t);s&&(s.agentCount=e)}update(t){for(const e of this.zones.values()){const s=e.agentCount>0?1:0;e.currentGlow+=(s-e.currentGlow)*Math.min(1,3*t/1e3);const n=e.currentGlow;if(e.glowBorder.clear(),n>.01){const o=1+2*n;e.glowBorder.rect(-o,-o,e.config.width+o*2,e.config.height+o*2).stroke({color:e.config.color,width:o,alpha:.7*n})}if(e.outerGlow.clear(),n>.01){const o=8*n;e.outerGlow.rect(-o,-o,e.config.width+o*2,e.config.height+o*2).stroke({color:e.config.color,width:o,alpha:.15*n})}}}rebuild(){const t=new Map;for(const[e,s]of this.zones)t.set(e,s.agentCount);this.container.removeChildren(),this.zones.clear();for(const e of se){const s=this.createZone(e);this.zones.set(e.id,s),this.container.addChild(s.container),s.agentCount=t.get(e.id)??0}}getZoneConfig(t){var e;return(e=this.zones.get(t))==null?void 0:e.config}}const Qr=.5,Jr=3,J0=.001;class ty{constructor(t,e){b(this,"zoom",1);b(this,"dragging",!1);b(this,"lastMouse",{x:0,y:0});b(this,"onWheel",t=>{t.preventDefault();const e=this.zoom;this.zoom=Math.max(Qr,Math.min(Jr,this.zoom-t.deltaY*J0));const s=this.app.canvas.getBoundingClientRect(),n=t.clientX-s.left,o=t.clientY-s.top,r=this.zoom/e;this.world.position.x=n-(n-this.world.position.x)*r,this.world.position.y=o-(o-this.world.position.y)*r,this.world.scale.set(this.zoom)});b(this,"onPointerDown",t=>{t.button!==0&&t.button!==1||(this.dragging=!0,this.lastMouse.x=t.clientX,this.lastMouse.y=t.clientY)});b(this,"onPointerMove",t=>{if(!this.dragging)return;const e=t.clientX-this.lastMouse.x,s=t.clientY-this.lastMouse.y;this.world.position.x+=e,this.world.position.y+=s,this.lastMouse.x=t.clientX,this.lastMouse.y=t.clientY});b(this,"onPointerUp",()=>{this.dragging=!1});this.app=t,this.world=e;const s=t.canvas;s.addEventListener("wheel",this.onWheel,{passive:!1}),s.addEventListener("pointerdown",this.onPointerDown),s.addEventListener("pointermove",this.onPointerMove),s.addEventListener("pointerup",this.onPointerUp),s.addEventListener("pointerleave",this.onPointerUp)}setZoom(t){this.zoom=Math.max(Qr,Math.min(Jr,t)),this.world.scale.set(this.zoom)}getZoom(){return this.zoom}zoomIn(){this.zoomBy(1.2)}zoomOut(){this.zoomBy(1/1.2)}resetView(t,e){const s=this.app.screen.width,n=this.app.screen.height,o=16,r=(s-o*2)/t,l=(n-o*2)/e,h=Math.min(r,l,1);this.setZoom(h),this.world.position.set((s-t*h)/2,(n-e*h)/2)}smoothFollow(t,e,s=.05){const n=this.app.screen.width,o=this.app.screen.height,r=n/2,l=o/2,h=r-t*this.zoom,d=l-e*this.zoom;this.world.position.x+=(h-this.world.position.x)*s,this.world.position.y+=(d-this.world.position.y)*s}getViewport(){const t=this.app.screen.width,e=this.app.screen.height;return{x:-this.world.position.x/this.zoom,y:-this.world.position.y/this.zoom,width:t/this.zoom,height:e/this.zoom,zoom:this.zoom}}panTo(t,e){const s=this.app.screen.width,n=this.app.screen.height,o=s/2,r=n/2;this.world.position.x=o-t*this.zoom,this.world.position.y=r-e*this.zoom}zoomBy(t){const e=this.zoom,s=Math.max(Qr,Math.min(Jr,this.zoom*t));this.zoom=s;const n=this.app.screen.width,o=this.app.screen.height,r=n/2,l=o/2,h=s/e;this.world.position.x=r-(r-this.world.position.x)*h,this.world.position.y=l-(l-this.world.position.y)*h,this.world.scale.set(this.zoom)}destroy(){const t=this.app.canvas;t.removeEventListener("wheel",this.onWheel),t.removeEventListener("pointerdown",this.onPointerDown),t.removeEventListener("pointermove",this.onPointerMove),t.removeEventListener("pointerup",this.onPointerUp),t.removeEventListener("pointerleave",this.onPointerUp)}}const ec=120,ta=100,tn=48,ws=4;class ey{constructor(){b(this,"lastW",0);b(this,"lastH",0)}computeLayout(t,e){const s=Math.max(t,ec*3+ws*4+tn*2),n=Math.max(e,ta*3+ws*4+tn*2);if(s===this.lastW&&n===this.lastH)return{worldWidth:s,worldHeight:n};this.lastW=s,this.lastH=n;const o=Eo.reduce((g,m)=>g+m,0),r=s-tn*2-ws*(Vh-1),l=n-tn*2-ws*(Eo.length-1),h=r/Vh,d=Eo.map(g=>Math.max(ta,g/o*l)),c=[];let p=tn;for(let g=0;g<Eo.length;g++)c.push(p),p+=d[g]+ws;for(const g of se)g.x=tn+g.colStart*(h+ws),g.y=c[g.rowStart],g.width=Math.max(ec,g.colSpan*h+(g.colSpan-1)*ws),g.height=Math.max(ta,d[g.rowStart]*g.rowSpan+(g.rowSpan-1)*ws);return _0(s,n),{worldWidth:s,worldHeight:n}}invalidate(){this.lastW=0,this.lastH=0}}const sy=1710666,ea=.45,iy=.15,Po=6,sc=8,sa=18,ia=22,ny=1e3;class oy{constructor(t,e){b(this,"overlay",new Wt);b(this,"_enabled",!1);b(this,"targetAlpha",0);b(this,"updateTimer",0);this.overlay.rect(0,0,t,e).fill({color:sy,alpha:1}),this.overlay.alpha=0,this.overlay.eventMode="none",this.overlay.visible=!1}get enabled(){return this._enabled}toggle(){this._enabled=!this._enabled,this.overlay.visible=this._enabled,this._enabled&&(this.computeTargetAlpha(),this.overlay.alpha=this.targetAlpha)}computeTargetAlpha(){const t=new Date,e=t.getHours()+t.getMinutes()/60;let s;e>=ia||e<Po?s=ea:e>=sa&&e<ia?s=ea*((e-sa)/(ia-sa)):e>=Po&&e<sc?s=ea*(1-(e-Po)/(sc-Po)):s=0,this.targetAlpha=Math.max(s,iy)}update(t){if(!this._enabled)return;this.updateTimer+=t,this.updateTimer>=ny&&(this.updateTimer=0,this.computeTargetAlpha());const e=1-Math.exp(-3*t/1e3);this.overlay.alpha+=(this.targetAlpha-this.overlay.alpha)*e}}const ry=[["search","terminal"],["terminal","web"],["files","thinking"],["thinking","messaging"],["spawn","idle"],["idle","tasks"],["search","files"],["terminal","thinking"],["web","messaging"],["files","spawn"],["thinking","idle"],["messaging","tasks"]],ay=.04,ly=.12,ic=3,hy=1200;class cy{constructor(){b(this,"container",new Ft);b(this,"linesGfx",new Wt);b(this,"particleGfx",new Wt);b(this,"particles",[]);b(this,"activeFlows",new Map);this.container.addChild(this.linesGfx),this.container.addChild(this.particleGfx)}triggerFlow(t,e,s){const n=`${t}->${e}`;this.activeFlows.set(n,2e3);for(let o=0;o<3;o++)this.particles.push({fromZone:t,toZone:e,t:-o*.15,speed:1/hy,color:s,alpha:.8})}getZoneCenter(t){const e=Zt.get(t);return e?{x:e.x+e.width/2,y:e.y+e.height/2}:{x:0,y:0}}bezierPoint(t,e,s,n,o,r,l){const h=1-l;return{x:h*h*t+2*h*l*s+l*l*o,y:h*h*e+2*h*l*n+l*l*r}}update(t){for(const[e,s]of this.activeFlows){const n=s-t;n<=0?this.activeFlows.delete(e):this.activeFlows.set(e,n)}for(let e=this.particles.length-1;e>=0;e--){const s=this.particles[e];s.t+=s.speed*t,s.t>1&&this.particles.splice(e,1)}this.linesGfx.clear();for(const[e,s]of ry){const n=this.getZoneCenter(e),o=this.getZoneCenter(s),r=`${e}->${s}`,l=`${s}->${e}`,d=this.activeFlows.has(r)||this.activeFlows.has(l)?ly:ay,c=Zt.get(e),p=(c==null?void 0:c.color)??8947848,g=(n.x+o.x)/2,m=(n.y+o.y)/2-20;this.linesGfx.moveTo(n.x,n.y),this.linesGfx.quadraticCurveTo(g,m,o.x,o.y),this.linesGfx.stroke({color:p,width:1,alpha:d})}this.particleGfx.clear();for(const e of this.particles){if(e.t<0)continue;const s=this.getZoneCenter(e.fromZone),n=this.getZoneCenter(e.toZone),o=(s.x+n.x)/2,r=(s.y+n.y)/2-20,l=this.bezierPoint(s.x,s.y,o,r,n.x,n.y,e.t),h=e.alpha*(1-e.t*.5);this.particleGfx.circle(l.x,l.y,ic).fill({color:e.color,alpha:h}),this.particleGfx.circle(l.x,l.y,ic*2).fill({color:e.color,alpha:h*.3})}}}class dy{constructor(t){b(this,"root",new Ft);b(this,"gridLayer",new Ft);b(this,"zoneLayer");b(this,"agentLayer",new Ft);b(this,"effectLayer",new Ft);b(this,"uiLayer",new Ft);b(this,"zoneRenderer");b(this,"camera");b(this,"dayNight");b(this,"flowLines");b(this,"layoutEngine");b(this,"app");b(this,"_worldWidth",1100);b(this,"_worldHeight",980);b(this,"gridGraphics");b(this,"gridRendererFn");b(this,"resizeHandler");b(this,"resizeRaf",0);b(this,"resizeObserver",null);this.app=t,this.layoutEngine=new ey;const e=t.screen.width,s=t.screen.height,{worldWidth:n,worldHeight:o}=this.layoutEngine.computeLayout(e,s);this._worldWidth=n,this._worldHeight=o,this.gridGraphics=Zh(n,o),this.gridLayer.addChild(this.gridGraphics),this.zoneRenderer=new Q0,this.zoneLayer=this.zoneRenderer.container,this.flowLines=new cy,this.root.addChild(this.gridLayer),this.root.addChild(this.zoneLayer),this.root.addChild(this.flowLines.container),this.root.addChild(this.agentLayer),this.root.addChild(this.effectLayer),this.root.addChild(this.uiLayer),this.dayNight=new oy(n,o),this.root.addChild(this.dayNight.overlay),t.stage.addChild(this.root),this.camera=new ty(t,this.root),this.camera.resetView(n,o),this.resizeHandler=()=>{cancelAnimationFrame(this.resizeRaf),this.resizeRaf=requestAnimationFrame(()=>this.onResize())},window.addEventListener("resize",this.resizeHandler);const r=document.getElementById("canvas-container");if(r){let l=0;this.resizeObserver=new ResizeObserver(()=>{clearTimeout(l),l=window.setTimeout(()=>{t.resize(),this.onResize()},250)}),this.resizeObserver.observe(r)}}onResize(){const t=this.app.screen.width,e=this.app.screen.height,{worldWidth:s,worldHeight:n}=this.layoutEngine.computeLayout(t,e);(s!==this._worldWidth||n!==this._worldHeight)&&(this._worldWidth=s,this._worldHeight=n,this.rebuildGrid(),this.zoneRenderer.rebuild(),this.dayNight.overlay.clear(),this.dayNight.overlay.rect(0,0,s,n).fill({color:1710666,alpha:1})),this.camera.resetView(this._worldWidth,this._worldHeight)}resetCamera(){this.camera.resetView(this._worldWidth,this._worldHeight)}addAgent(t){const e=t instanceof Ft?t:t.container;this.agentLayer.addChild(e)}removeAgent(t){const e=t instanceof Ft?t:t.container;this.agentLayer.removeChild(e)}addEffect(t){this.effectLayer.addChild(t)}removeEffect(t){this.effectLayer.removeChild(t)}getZoneCenter(t){const e=Zt.get(t);return e?{x:e.x+e.width/2,y:e.y+e.height/2}:{x:this._worldWidth/2,y:this._worldHeight/2}}getZoneConfig(t){return Zt.get(t)}setZoneAgentCount(t,e){this.zoneRenderer.setAgentCount(t,e)}rebuildZones(){this.zoneRenderer.rebuild()}applyTheme(t){this.zoneRenderer.setThemeDecorators(t.decorators,t.pixelRooms??!1),this.app.renderer.background.color=t.colors.background,this.gridRendererFn=t.gridRenderer,this.rebuildGrid()}rebuildGrid(){this.gridLayer.removeChildren(),this.gridGraphics.destroy(),this.gridGraphics=Zh(this._worldWidth,this._worldHeight,this.gridRendererFn),this.gridLayer.addChild(this.gridGraphics)}update(t){this.zoneRenderer.update(t),this.dayNight.update(t),this.flowLines.update(t)}get worldWidth(){return this._worldWidth}get worldHeight(){return this._worldHeight}destroy(){var t;window.removeEventListener("resize",this.resizeHandler),(t=this.resizeObserver)==null||t.disconnect()}}const a="transparent",v="body",f="outline",I="highlight",Rt="eye",_="skin",uy={idle:[[[a,a,a,a,a,f,f,f,f,f,f,a,a,a,a,a],[a,a,a,a,f,I,I,I,I,I,I,f,a,a,a,a],[a,a,a,f,I,I,I,I,I,I,I,I,f,a,a,a],[a,a,a,f,I,_,_,_,_,_,_,I,f,a,a,a],[a,a,a,f,_,Rt,Rt,_,_,Rt,Rt,_,f,a,a,a],[a,a,a,f,_,_,_,_,_,_,_,_,f,a,a,a],[a,a,a,a,f,f,_,_,_,_,f,f,a,a,a,a],[a,a,a,a,a,f,v,v,v,v,f,a,a,a,a,a],[a,a,a,a,f,v,v,v,v,v,v,f,a,a,a,a],[a,a,a,_,f,v,v,v,v,v,v,f,_,a,a,a],[a,a,a,_,f,v,v,v,v,v,v,f,_,a,a,a],[a,a,a,a,f,v,v,v,v,v,v,f,a,a,a,a],[a,a,a,a,a,f,f,f,f,f,f,a,a,a,a,a],[a,a,a,a,a,f,f,a,a,f,f,a,a,a,a,a],[a,a,a,a,a,f,f,a,a,f,f,a,a,a,a,a],[a,a,a,a,f,f,f,a,a,f,f,f,a,a,a,a]],[[a,a,a,a,a,f,f,f,f,f,f,a,a,a,a,a],[a,a,a,a,f,I,I,I,I,I,I,f,a,a,a,a],[a,a,a,f,I,I,I,I,I,I,I,I,f,a,a,a],[a,a,a,f,I,_,_,_,_,_,_,I,f,a,a,a],[a,a,a,f,_,f,f,_,_,f,f,_,f,a,a,a],[a,a,a,f,_,_,_,_,_,_,_,_,f,a,a,a],[a,a,a,a,f,f,_,_,_,_,f,f,a,a,a,a],[a,a,a,a,a,f,v,v,v,v,f,a,a,a,a,a],[a,a,a,a,f,v,v,v,v,v,v,f,a,a,a,a],[a,a,a,_,f,v,v,v,v,v,v,f,_,a,a,a],[a,a,a,_,f,v,v,v,v,v,v,f,_,a,a,a],[a,a,a,a,f,v,v,v,v,v,v,f,a,a,a,a],[a,a,a,a,a,f,f,f,f,f,f,a,a,a,a,a],[a,a,a,a,a,f,f,a,a,f,f,a,a,a,a,a],[a,a,a,a,a,f,f,a,a,f,f,a,a,a,a,a],[a,a,a,a,f,f,f,a,a,f,f,f,a,a,a,a]]],walk:[[[a,a,a,a,a,f,f,f,f,f,f,a,a,a,a,a],[a,a,a,a,f,I,I,I,I,I,I,f,a,a,a,a],[a,a,a,f,I,I,I,I,I,I,I,I,f,a,a,a],[a,a,a,f,I,_,_,_,_,_,_,I,f,a,a,a],[a,a,a,f,_,Rt,Rt,_,_,Rt,Rt,_,f,a,a,a],[a,a,a,f,_,_,_,_,_,_,_,_,f,a,a,a],[a,a,a,a,f,f,_,_,_,_,f,f,a,a,a,a],[a,a,a,a,a,f,v,v,v,v,f,a,a,a,a,a],[a,a,a,a,f,v,v,v,v,v,v,f,a,a,a,a],[a,a,a,_,f,v,v,v,v,v,v,f,_,a,a,a],[a,a,a,_,f,v,v,v,v,v,v,f,_,a,a,a],[a,a,a,a,f,v,v,v,v,v,v,f,a,a,a,a],[a,a,a,a,a,f,f,f,f,f,f,a,a,a,a,a],[a,a,a,a,f,f,a,a,a,f,f,a,a,a,a,a],[a,a,a,a,f,f,a,a,a,a,f,f,a,a,a,a],[a,a,a,f,f,f,a,a,a,a,f,f,f,a,a,a]],[[a,a,a,a,a,f,f,f,f,f,f,a,a,a,a,a],[a,a,a,a,f,I,I,I,I,I,I,f,a,a,a,a],[a,a,a,f,I,I,I,I,I,I,I,I,f,a,a,a],[a,a,a,f,I,_,_,_,_,_,_,I,f,a,a,a],[a,a,a,f,_,Rt,Rt,_,_,Rt,Rt,_,f,a,a,a],[a,a,a,f,_,_,_,_,_,_,_,_,f,a,a,a],[a,a,a,a,f,f,_,_,_,_,f,f,a,a,a,a],[a,a,a,a,a,f,v,v,v,v,f,a,a,a,a,a],[a,a,a,a,f,v,v,v,v,v,v,f,a,a,a,a],[a,a,a,_,f,v,v,v,v,v,v,f,_,a,a,a],[a,a,a,_,f,v,v,v,v,v,v,f,_,a,a,a],[a,a,a,a,f,v,v,v,v,v,v,f,a,a,a,a],[a,a,a,a,a,f,f,f,f,f,f,a,a,a,a,a],[a,a,a,a,a,f,f,a,a,a,f,f,a,a,a,a],[a,a,a,a,f,f,a,a,a,a,f,f,a,a,a,a],[a,a,a,f,f,f,a,a,a,f,f,f,a,a,a,a]]],working:[[a,a,a,a,a,f,f,f,f,f,f,a,a,a,a,a],[a,a,a,a,f,I,I,I,I,I,I,f,a,a,a,a],[a,a,a,f,I,I,I,I,I,I,I,I,f,a,a,a],[a,a,a,f,I,_,_,_,_,_,_,I,f,a,a,a],[a,a,a,f,_,Rt,Rt,_,_,Rt,Rt,_,f,a,a,a],[a,a,a,f,_,_,f,f,f,f,_,_,f,a,a,a],[a,a,a,a,f,f,_,_,_,_,f,f,a,a,a,a],[a,a,a,a,a,f,v,v,v,v,f,a,a,a,a,a],[a,a,a,a,f,v,v,v,v,v,v,f,a,a,a,a],[a,a,_,_,f,v,v,v,v,v,v,f,_,_,a,a],[a,a,a,_,f,v,v,v,v,v,v,f,_,a,a,a],[a,a,a,a,f,v,v,v,v,v,v,f,a,a,a,a],[a,a,a,a,a,f,f,f,f,f,f,a,a,a,a,a],[a,a,a,a,a,f,f,a,a,f,f,a,a,a,a,a],[a,a,a,a,a,f,f,a,a,f,f,a,a,a,a,a],[a,a,a,a,f,f,f,a,a,f,f,f,a,a,a,a]],sleeping:[[[a,a,a,a,a,a,f,f,f,f,f,f,a,a,a,a],[a,a,a,a,a,f,I,I,I,I,I,I,f,a,a,a],[a,a,a,a,f,I,I,I,I,I,I,I,I,f,a,a],[a,a,a,a,f,I,_,_,_,_,_,_,I,f,a,a],[a,a,a,a,f,_,f,f,_,_,f,f,_,f,a,a],[a,a,a,a,f,_,_,_,_,_,_,_,_,f,a,a],[a,a,a,a,a,f,f,_,_,_,_,f,f,a,a,a],[a,a,a,a,a,f,v,v,v,v,f,a,a,a,a,a],[a,a,a,a,f,v,v,v,v,v,v,f,a,a,a,a],[a,a,a,_,f,v,v,v,v,v,v,f,_,a,a,a],[a,a,a,_,f,v,v,v,v,v,v,f,_,a,a,a],[a,a,a,a,f,v,v,v,v,v,v,f,a,a,a,a],[a,a,a,a,a,f,f,f,f,f,f,a,a,a,a,a],[a,a,a,a,a,f,f,a,a,f,f,a,a,a,a,a],[a,a,a,a,a,f,f,a,a,f,f,a,a,a,a,a],[a,a,a,a,f,f,f,a,a,f,f,f,a,a,a,a]],[[a,a,a,a,a,a,f,f,f,f,f,f,a,a,a,a],[a,a,a,a,a,f,I,I,I,I,I,I,f,a,a,a],[a,a,a,a,f,I,I,I,I,I,I,I,I,f,a,a],[a,a,a,a,f,I,_,_,_,_,_,_,I,f,a,a],[a,a,a,a,f,_,f,f,_,_,f,f,_,f,a,a],[a,a,a,a,f,_,_,_,f,f,_,_,_,f,a,a],[a,a,a,a,a,f,f,_,_,_,_,f,f,a,a,a],[a,a,a,a,a,f,v,v,v,v,f,a,a,a,a,a],[a,a,a,a,f,v,v,v,v,v,v,f,a,a,a,a],[a,a,a,_,f,v,v,v,v,v,v,f,_,a,a,a],[a,a,a,_,f,v,v,v,v,v,v,f,_,a,a,a],[a,a,a,a,f,v,v,v,v,v,v,f,a,a,a,a],[a,a,a,a,a,f,f,f,f,f,f,a,a,a,a,a],[a,a,a,a,a,f,f,a,a,f,f,a,a,a,a,a],[a,a,a,a,a,f,f,a,a,f,f,a,a,a,a,a],[a,a,a,a,f,f,f,a,a,f,f,f,a,a,a,a]]],done:[[a,a,a,a,a,f,f,f,f,f,f,a,a,a,a,a],[a,a,a,a,f,I,I,I,I,I,I,f,a,a,a,a],[a,a,a,f,I,I,I,I,I,I,I,I,f,a,a,a],[a,a,a,f,I,_,_,_,_,_,_,I,f,a,a,a],[a,a,a,f,_,_,Rt,_,_,Rt,_,_,f,a,a,a],[a,a,a,f,_,_,_,f,f,_,_,_,f,a,a,a],[a,a,a,a,f,f,_,_,_,_,f,f,a,a,a,a],[a,a,a,a,a,f,v,v,v,v,f,a,a,a,a,a],[a,a,a,a,f,v,v,v,v,v,v,f,a,a,a,a],[a,a,_,_,f,v,v,v,v,v,v,f,_,_,a,a],[a,a,a,_,f,v,v,v,v,v,v,f,_,a,a,a],[a,a,a,a,f,v,v,v,v,v,v,f,a,a,a,a],[a,a,a,a,a,f,f,f,f,f,f,a,a,a,a,a],[a,a,a,a,a,f,f,a,a,f,f,a,a,a,a,a],[a,a,a,a,a,f,f,a,a,f,f,a,a,a,a,a],[a,a,a,a,f,f,f,a,a,f,f,f,a,a,a,a]],size:16},fy={idle:[[[a,a,a,f,f,f,f,f,f,a,a,a],[a,a,f,I,I,I,I,I,I,f,a,a],[a,f,I,I,_,_,_,_,I,I,f,a],[a,f,_,Rt,_,_,_,_,Rt,_,f,a],[a,f,_,_,_,_,_,_,_,_,f,a],[a,a,f,f,_,_,_,_,f,f,a,a],[a,a,f,v,v,v,v,v,v,f,a,a],[a,_,f,v,v,v,v,v,v,f,_,a],[a,a,f,v,v,v,v,v,v,f,a,a],[a,a,a,f,f,a,a,f,f,a,a,a],[a,a,a,f,f,a,a,f,f,a,a,a],[a,a,f,f,f,a,a,f,f,f,a,a]],[[a,a,a,f,f,f,f,f,f,a,a,a],[a,a,f,I,I,I,I,I,I,f,a,a],[a,f,I,I,_,_,_,_,I,I,f,a],[a,f,_,f,_,_,_,_,f,_,f,a],[a,f,_,_,_,_,_,_,_,_,f,a],[a,a,f,f,_,_,_,_,f,f,a,a],[a,a,f,v,v,v,v,v,v,f,a,a],[a,_,f,v,v,v,v,v,v,f,_,a],[a,a,f,v,v,v,v,v,v,f,a,a],[a,a,a,f,f,a,a,f,f,a,a,a],[a,a,a,f,f,a,a,f,f,a,a,a],[a,a,f,f,f,a,a,f,f,f,a,a]]],walk:[[[a,a,a,f,f,f,f,f,f,a,a,a],[a,a,f,I,I,I,I,I,I,f,a,a],[a,f,I,I,_,_,_,_,I,I,f,a],[a,f,_,Rt,_,_,_,_,Rt,_,f,a],[a,f,_,_,_,_,_,_,_,_,f,a],[a,a,f,f,_,_,_,_,f,f,a,a],[a,a,f,v,v,v,v,v,v,f,a,a],[a,_,f,v,v,v,v,v,v,f,_,a],[a,a,f,v,v,v,v,v,v,f,a,a],[a,a,f,f,a,a,a,f,f,a,a,a],[a,a,f,f,a,a,a,a,f,f,a,a],[a,f,f,f,a,a,a,a,f,f,f,a]],[[a,a,a,f,f,f,f,f,f,a,a,a],[a,a,f,I,I,I,I,I,I,f,a,a],[a,f,I,I,_,_,_,_,I,I,f,a],[a,f,_,Rt,_,_,_,_,Rt,_,f,a],[a,f,_,_,_,_,_,_,_,_,f,a],[a,a,f,f,_,_,_,_,f,f,a,a],[a,a,f,v,v,v,v,v,v,f,a,a],[a,_,f,v,v,v,v,v,v,f,_,a],[a,a,f,v,v,v,v,v,v,f,a,a],[a,a,a,f,f,a,a,a,f,f,a,a],[a,a,f,f,a,a,a,a,f,f,a,a],[a,f,f,f,a,a,a,a,f,f,f,a]]],working:[[a,a,a,f,f,f,f,f,f,a,a,a],[a,a,f,I,I,I,I,I,I,f,a,a],[a,f,I,I,_,_,_,_,I,I,f,a],[a,f,_,Rt,_,_,_,_,Rt,_,f,a],[a,f,_,f,f,f,f,f,f,_,f,a],[a,a,f,f,_,_,_,_,f,f,a,a],[a,a,f,v,v,v,v,v,v,f,a,a],[_,_,f,v,v,v,v,v,v,f,_,_],[a,a,f,v,v,v,v,v,v,f,a,a],[a,a,a,f,f,a,a,f,f,a,a,a],[a,a,a,f,f,a,a,f,f,a,a,a],[a,a,f,f,f,a,a,f,f,f,a,a]],sleeping:[[[a,a,a,a,f,f,f,f,f,f,a,a],[a,a,a,f,I,I,I,I,I,I,f,a],[a,a,f,I,I,_,_,_,_,I,I,f],[a,a,f,_,f,_,_,_,_,f,_,f],[a,a,f,_,_,_,_,_,_,_,_,f],[a,a,a,f,f,_,_,_,_,f,f,a],[a,a,f,v,v,v,v,v,v,f,a,a],[a,_,f,v,v,v,v,v,v,f,_,a],[a,a,f,v,v,v,v,v,v,f,a,a],[a,a,a,f,f,a,a,f,f,a,a,a],[a,a,a,f,f,a,a,f,f,a,a,a],[a,a,f,f,f,a,a,f,f,f,a,a]],[[a,a,a,a,f,f,f,f,f,f,a,a],[a,a,a,f,I,I,I,I,I,I,f,a],[a,a,f,I,I,_,_,_,_,I,I,f],[a,a,f,_,f,_,_,_,_,f,_,f],[a,a,f,_,_,_,f,f,_,_,_,f],[a,a,a,f,f,_,_,_,_,f,f,a],[a,a,f,v,v,v,v,v,v,f,a,a],[a,_,f,v,v,v,v,v,v,f,_,a],[a,a,f,v,v,v,v,v,v,f,a,a],[a,a,a,f,f,a,a,f,f,a,a,a],[a,a,a,f,f,a,a,f,f,a,a,a],[a,a,f,f,f,a,a,f,f,f,a,a]]],done:[[a,a,a,f,f,f,f,f,f,a,a,a],[a,a,f,I,I,I,I,I,I,f,a,a],[a,f,I,I,_,_,_,_,I,I,f,a],[a,f,_,_,Rt,_,_,Rt,_,_,f,a],[a,f,_,_,f,_,_,f,_,_,f,a],[a,a,f,f,_,_,_,_,f,f,a,a],[a,a,f,v,v,v,v,v,v,f,a,a],[_,_,f,v,v,v,v,v,v,f,_,_],[a,a,f,v,v,v,v,v,v,f,a,a],[a,a,a,f,f,a,a,f,f,a,a,a],[a,a,a,f,f,a,a,f,f,a,a,a],[a,a,f,f,f,a,a,f,f,f,a,a]],size:12},C="transparent",nt="body",F="outline",me="highlight",Mi="eye",bi=[C,C,C,C,C,C,C,F,F,C,C,C,C,C,C,C],_i=[C,C,C,F,F,F,F,F,F,F,F,F,F,C,C,C],xi=[C,C,C,F,nt,nt,nt,nt,nt,nt,nt,nt,F,C,C,C],Kn=[C,C,C,F,nt,Mi,Mi,nt,nt,Mi,Mi,nt,F,C,C,C],tl=[C,C,C,F,nt,F,F,nt,nt,F,F,nt,F,C,C,C],mn=[C,C,C,F,nt,nt,F,F,F,F,nt,nt,F,C,C,C],vi=[C,C,C,F,F,F,F,F,F,F,F,F,F,C,C,C],wi=[C,C,C,C,C,F,me,me,me,me,F,C,C,C,C,C],ue=[C,C,C,C,F,nt,nt,nt,nt,nt,nt,F,C,C,C,C],Si=[C,C,F,F,F,nt,nt,nt,nt,nt,nt,F,F,F,C,C],ki=[C,C,C,F,F,nt,nt,nt,nt,nt,nt,F,F,C,C,C],fe=[C,C,C,C,F,F,me,me,me,me,F,F,C,C,C,C],is=[C,C,C,C,F,F,F,C,C,F,F,F,C,C,C,C],gn=[C,C,C,F,F,F,F,C,C,F,F,F,F,C,C,C],nc=[C,C,C,C,F,F,F,C,C,C,F,F,C,C,C,C],py=[C,C,C,F,F,F,C,C,C,C,F,F,F,C,C,C],oc=[C,C,C,C,C,F,F,C,C,F,F,F,C,C,C,C],my=[C,C,C,F,F,F,C,C,C,F,F,F,C,C,C,C],gy=[C,C,C,F,nt,F,me,me,me,me,F,nt,F,C,C,C],yy=[C,C,C,F,nt,nt,nt,F,F,nt,nt,nt,F,C,C,C],by=[bi,_i,xi,Kn,mn,vi,wi,ue,Si,ki,fe,ue,fe,is,is,gn],_y=[bi,_i,xi,tl,mn,vi,wi,ue,Si,ki,fe,ue,fe,is,is,gn],xy={idle:[by,_y],walk:[[bi,_i,xi,Kn,mn,vi,wi,ue,Si,ki,fe,ue,fe,nc,nc,py],[bi,_i,xi,Kn,mn,vi,wi,ue,Si,ki,fe,ue,fe,oc,oc,my]],working:[bi,_i,xi,Kn,gy,vi,wi,ue,Si,ki,fe,ue,fe,is,is,gn],sleeping:[[[C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C],...[bi,_i,xi,tl,mn,vi,wi,ue,Si,ki,fe,ue,fe,is,gn].map(i=>[C,...i.slice(0,-1)])],[[C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C],...[bi,_i,xi,tl,mn,vi,wi,ue,Si,ki,fe,ue,fe,is,gn].map(i=>[C,...i.slice(0,-1)])]],done:[bi,_i,xi,Kn,yy,vi,wi,ue,Si,ki,fe,ue,fe,is,is,gn],size:16},Ss=[C,C,C,C,C,F,F,C,C,C,C,C],ks=[C,C,F,F,F,F,F,F,F,F,C,C],Ts=[C,C,F,nt,nt,nt,nt,nt,nt,F,C,C],Ln=[C,C,F,Mi,Mi,nt,nt,Mi,Mi,F,C,C],na=[C,C,F,F,F,nt,nt,F,F,F,C,C],en=[C,C,F,nt,F,F,F,F,nt,F,C,C],Cs=[C,C,F,F,F,F,F,F,F,F,C,C],oe=[C,C,C,F,nt,nt,nt,nt,F,C,C,C],As=[C,F,F,F,nt,nt,nt,nt,F,F,F,C],Be=[C,C,C,F,F,C,C,F,F,C,C,C],Ms=[C,C,F,F,F,C,C,F,F,F,C,C],rc=[C,C,F,F,C,C,C,C,F,F,C,C],ac=[C,C,C,F,F,C,C,F,F,C,C,C],vy=[C,C,F,nt,me,me,me,me,nt,F,C,C],wy=[C,C,F,nt,nt,F,F,nt,nt,F,C,C],Sy={idle:[[Ss,ks,Ts,Ln,en,Cs,oe,As,oe,Be,Be,Ms],[Ss,ks,Ts,na,en,Cs,oe,As,oe,Be,Be,Ms]],walk:[[Ss,ks,Ts,Ln,en,Cs,oe,As,oe,rc,rc,Ms],[Ss,ks,Ts,Ln,en,Cs,oe,As,oe,ac,ac,Ms]],working:[Ss,ks,Ts,Ln,vy,Cs,oe,As,oe,Be,Be,Ms],sleeping:[[Ss,ks,Ts,na,en,Cs,oe,As,oe,Be,Be,Ms],[Ss,ks,Ts,na,en,Cs,oe,As,oe,Be,Be,Ms]],done:[Ss,ks,Ts,Ln,wy,Cs,oe,As,oe,Be,Be,Ms],size:12},P="transparent",ge="body",V="outline",Y="skin",Es=[P,P,P,P,P,V,V,V,V,V,V,P,P,P,P,P],Ps=[P,P,P,P,V,Y,Y,Y,Y,Y,Y,V,P,P,P,P],Is=[P,P,P,V,Y,Y,Y,Y,Y,Y,Y,Y,V,P,P,P],Bn=[P,P,P,V,Y,V,V,Y,Y,V,V,Y,V,P,P,P],oa=[P,P,P,V,Y,V,P,Y,Y,P,V,Y,V,P,P,P],sn=[P,P,P,V,Y,Y,Y,V,V,Y,Y,Y,V,P,P,P],Ls=[P,P,P,P,V,Y,V,V,V,V,Y,V,P,P,P,P],el=[P,P,P,P,P,P,V,Y,Y,V,P,P,P,P,P,P],yn=[P,P,P,P,V,Y,ge,Y,Y,ge,Y,V,P,P,P,P],sl=[P,P,P,P,V,ge,Y,ge,ge,Y,ge,V,P,P,P,P],il=[P,P,Y,Y,V,Y,ge,Y,Y,ge,Y,V,Y,Y,P,P],nl=[P,P,P,P,P,V,Y,Y,Y,Y,V,P,P,P,P,P],ol=[P,P,P,P,P,V,Y,V,V,Y,V,P,P,P,P,P],rl=[P,P,P,P,P,V,Y,P,P,Y,V,P,P,P,P,P],ky=[P,P,P,P,V,V,Y,P,P,Y,V,V,P,P,P,P],ra=[P,P,P,P,V,Y,P,P,P,P,Y,V,P,P,P,P],lc=[P,P,P,V,V,Y,P,P,P,Y,V,V,P,P,P,P],Ty=[P,P,P,P,V,Y,V,Y,Y,V,Y,V,P,P,P,P],Cy=[P,P,P,V,Y,Y,V,V,V,V,Y,Y,V,P,P,P],nn=[el,yn,il,sl,yn,nl,ol,rl,rl,ky],Ay={idle:[[Es,Ps,Is,Bn,sn,Ls,...nn],[Es,Ps,Is,oa,sn,Ls,...nn]],walk:[[Es,Ps,Is,Bn,sn,Ls,el,yn,il,sl,yn,nl,ol,ra,ra,lc],[Es,Ps,Is,Bn,sn,Ls,el,yn,il,sl,yn,nl,ol,rl,ra,lc]],working:[Es,Ps,Is,Bn,Ty,Ls,...nn],sleeping:[[[P,...Es.slice(0,-1)],[P,...Ps.slice(0,-1)],[P,...Is.slice(0,-1)],[P,...oa.slice(0,-1)],[P,...sn.slice(0,-1)],[P,...Ls.slice(0,-1)],...nn],[[P,...Es.slice(0,-1)],[P,...Ps.slice(0,-1)],[P,...Is.slice(0,-1)],[P,...oa.slice(0,-1)],[P,...sn.slice(0,-1)],[P,...Ls.slice(0,-1)],...nn]],done:[Es,Ps,Is,Bn,Cy,Ls,...nn],size:16},Bs=[P,P,P,V,V,V,V,V,V,P,P,P],Rs=[P,P,V,Y,Y,Y,Y,Y,Y,V,P,P],Rn=[P,V,Y,V,V,Y,Y,V,V,Y,V,P],aa=[P,V,Y,V,P,Y,Y,P,V,Y,V,P],Ri=[P,V,Y,Y,V,V,V,V,Y,Y,V,P],$s=[P,P,V,Y,V,V,V,V,Y,V,P,P],Ds=[P,P,V,Y,ge,Y,Y,ge,Y,V,P,P],zs=[P,P,V,ge,Y,ge,ge,Y,ge,V,P,P],Fs=[P,Y,V,Y,ge,Y,Y,ge,Y,V,Y,P],Ns=[P,P,P,V,Y,Y,Y,Y,V,P,P,P],Ce=[P,P,P,V,Y,P,P,Y,V,P,P,P],Gs=[P,P,V,V,Y,P,P,Y,V,V,P,P],la=[P,P,V,Y,P,P,P,P,Y,V,P,P],My=[P,V,Y,Y,V,V,V,V,Y,Y,V,P],Ey={idle:[[Bs,Rs,Rn,Ri,$s,Ds,Fs,zs,Ns,Ce,Ce,Gs],[Bs,Rs,aa,Ri,$s,Ds,Fs,zs,Ns,Ce,Ce,Gs]],walk:[[Bs,Rs,Rn,Ri,$s,Ds,Fs,zs,Ns,la,la,Gs],[Bs,Rs,Rn,Ri,$s,Ds,Fs,zs,Ns,Ce,la,Gs]],working:[Bs,Rs,Rn,Ri,$s,Ds,Fs,zs,Ns,Ce,Ce,Gs],sleeping:[[Bs,Rs,aa,Ri,$s,Ds,Fs,zs,Ns,Ce,Ce,Gs],[Bs,Rs,aa,Ri,$s,Ds,Fs,zs,Ns,Ce,Ce,Gs]],done:[Bs,Rs,Rn,My,$s,Ds,Fs,zs,Ns,Ce,Ce,Gs],size:12},A="transparent",st="body",W="outline",Ei="highlight",Se="eye",Au=[A,A,A,A,A,A,W,W,W,W,A,A,A,A,A,A],Mu=[A,A,A,A,W,W,st,st,st,st,W,W,A,A,A,A],Eu=[A,A,A,W,st,st,st,st,st,st,st,st,W,A,A,A],ha=[A,A,A,W,st,Se,Se,W,W,Se,Se,st,W,A,A,A],ca=[A,A,A,W,st,W,W,W,W,W,W,st,W,A,A,A],Ws=[A,A,A,W,W,W,W,W,W,W,W,W,W,A,A,A],Os=[A,A,A,A,W,W,W,W,W,W,W,W,A,A,A,A],Zo=[A,A,A,A,A,W,st,st,st,st,W,A,A,A,A,A],Ti=[A,A,A,A,W,st,st,st,st,st,st,W,A,A,A,A],Ko=[A,A,A,W,W,st,st,st,st,st,st,W,W,A,A,A],Qo=[A,A,W,W,W,st,st,st,st,st,st,W,W,W,A,A],Jo=[A,A,A,A,W,W,Ei,Ei,Ei,Ei,W,W,A,A,A,A],ur=[A,A,A,A,A,W,W,A,A,W,W,A,A,A,A,A],al=[A,A,A,A,W,W,W,A,A,W,W,W,A,A,A,A],hc=[A,A,A,A,W,W,A,A,A,A,W,W,A,A,A,A],Py=[A,A,A,W,W,W,A,A,A,A,W,W,W,A,A,A],Iy=[A,A,A,A,A,W,W,A,W,W,A,A,A,A,A,A],Ly=[A,A,A,A,W,W,A,A,A,W,W,A,A,A,A,A],By=[A,A,A,W,st,Se,W,W,W,W,Se,st,W,A,A,A],Ry=[A,A,A,W,st,W,Se,W,W,Se,W,st,W,A,A,A],on=[Au,Mu,Eu],cc=[[A,...Au.slice(0,-1)],[A,...Mu.slice(0,-1)],[A,...Eu.slice(0,-1)]],$n=[Zo,Ti,Qo,Ko,Ti,Jo,ur,ur,al],$y={idle:[[...on,ha,Ws,Os,...$n],[...on,ca,Ws,Os,...$n]],walk:[[...on,ha,Ws,Os,Zo,Ti,Qo,Ko,Ti,Jo,hc,hc,Py],[...on,ha,Ws,Os,Zo,Ti,Qo,Ko,Ti,Jo,Iy,Ly,al]],working:[...on,By,Ws,Os,Zo,Ti,Qo,Ko,Ti,Jo,ur,ur,al],sleeping:[[[A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A],...cc,[A,...ca.slice(0,-1)],[A,...Ws.slice(0,-1)],[A,...Os.slice(0,-1)],...$n],[[A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A],...cc,[A,...ca.slice(0,-1)],[A,...Ws.slice(0,-1)],[A,...Os.slice(0,-1)],...$n]],done:[...on,Ry,Ws,Os,...$n],size:16},Hs=[A,A,A,W,W,W,W,W,W,A,A,A],Us=[A,A,W,st,st,st,st,st,st,W,A,A],qs=[A,W,st,st,st,st,st,st,st,st,W,A],Io=[A,W,st,Se,Se,W,W,Se,Se,st,W,A],da=[A,W,st,W,W,W,W,W,W,st,W,A],Vs=[A,W,W,W,W,W,W,W,W,W,W,A],re=[A,A,W,st,st,st,st,st,st,W,A,A],Ys=[A,W,W,st,st,st,st,st,st,W,W,A],js=[A,A,W,W,Ei,Ei,Ei,Ei,W,W,A,A],Ae=[A,A,A,W,W,A,A,W,W,A,A,A],Xs=[A,A,W,W,W,A,A,W,W,W,A,A],ua=[A,A,W,W,A,A,A,A,W,W,A,A],Dy=[A,W,st,W,Se,W,W,Se,W,st,W,A],zy={idle:[[Hs,Us,qs,Io,Vs,re,Ys,re,js,Ae,Ae,Xs],[Hs,Us,qs,da,Vs,re,Ys,re,js,Ae,Ae,Xs]],walk:[[Hs,Us,qs,Io,Vs,re,Ys,re,js,ua,ua,Xs],[Hs,Us,qs,Io,Vs,re,Ys,re,js,Ae,ua,Xs]],working:[Hs,Us,qs,Io,Vs,re,Ys,re,js,Ae,Ae,Xs],sleeping:[[Hs,Us,qs,da,Vs,re,Ys,re,js,Ae,Ae,Xs],[Hs,Us,qs,da,Vs,re,Ys,re,js,Ae,Ae,Xs]],done:[Hs,Us,qs,Dy,Vs,re,Ys,re,js,Ae,Ae,Xs],size:12},D="transparent",J="body",j="outline",Pi="highlight",ns="eye",ct="skin",Fy=[D,D,D,D,D,D,D,j,j,D,D,D,D,D,D,D],Ny=[D,D,D,D,D,D,j,Pi,Pi,j,D,D,D,D,D,D],Gy=[D,D,D,D,D,j,Pi,Pi,Pi,Pi,j,D,D,D,D,D],Wy=[D,D,D,j,j,j,j,j,j,j,j,j,j,D,D,D],fa=[D,D,D,j,ct,ns,ns,ct,ct,ns,ns,ct,j,D,D,D],Lo=[D,D,D,j,ct,j,j,ct,ct,j,j,ct,j,D,D,D],$i=[D,D,D,D,j,ct,ct,ct,ct,ct,ct,j,D,D,D,D],tr=[D,D,D,D,D,j,J,J,J,J,j,D,D,D,D,D],Ci=[D,D,D,D,j,J,J,J,J,J,J,j,D,D,D,D],ll=[D,D,D,ct,j,J,J,J,J,J,J,j,ct,D,D,D],er=[D,D,D,j,J,J,J,J,J,J,J,J,j,D,D,D],sr=[D,D,j,J,J,J,J,J,J,J,J,J,J,j,D,D],ir=[D,j,J,J,J,J,J,J,J,J,J,J,J,J,j,D],nr=[D,j,j,j,j,j,j,j,j,j,j,j,j,j,j,D],Oy=[D,D,ct,ct,j,J,J,J,J,J,J,j,ct,ct,D,D],Hy=[D,D,D,j,ct,ct,ns,ct,ct,ns,ct,ct,j,D,D,D],Uy=[D,D,D,D,j,ct,ct,j,j,ct,ct,j,D,D,D,D],Ui=[Fy,Ny,Gy,Wy],dc=Ui.map(i=>[D,...i.slice(0,-1)]),Dn=[tr,Ci,ll,Ci,er,sr,ir,nr],qy={idle:[[...Ui,fa,$i,...Dn],[...Ui,Lo,$i,...Dn]],walk:[[...Ui,fa,$i,tr,Ci,ll,Ci,er,sr,ir,nr],[...Ui,Lo,$i,tr,Ci,ll,Ci,er,sr,ir,nr]],working:[...Ui,fa,$i,tr,Ci,Oy,Ci,er,sr,ir,nr],sleeping:[[...dc,[D,...Lo.slice(0,-1)],[D,...$i.slice(0,-1)],...Dn],[...dc,[D,...Lo.slice(0,-1)],[D,...$i.slice(0,-1)],...Dn]],done:[...Ui,Hy,Uy,...Dn],size:16},Zs=[D,D,D,D,D,j,j,D,D,D,D,D],Ks=[D,D,D,D,j,Pi,Pi,j,D,D,D,D],Qs=[D,D,j,j,j,j,j,j,j,j,D,D],pa=[D,D,j,ct,ns,ct,ct,ns,ct,j,D,D],Bo=[D,D,j,ct,j,ct,ct,j,ct,j,D,D],Di=[D,D,j,ct,ct,ct,ct,ct,ct,j,D,D],ae=[D,D,j,J,J,J,J,J,J,j,D,D],Js=[D,ct,j,J,J,J,J,J,J,j,ct,D],ti=[D,j,J,J,J,J,J,J,J,J,j,D],le=[j,J,J,J,J,J,J,J,J,J,J,j],ei=[j,j,j,j,j,j,j,j,j,j,j,j],Vy=[D,D,j,ct,ct,ns,ns,ct,ct,j,D,D],Yy=[D,D,j,ct,j,ct,ct,j,ct,j,D,D],jy={idle:[[Zs,Ks,Qs,pa,Di,ae,Js,ae,ti,le,le,ei],[Zs,Ks,Qs,Bo,Di,ae,Js,ae,ti,le,le,ei]],walk:[[Zs,Ks,Qs,pa,Di,ae,Js,ae,ti,le,le,ei],[Zs,Ks,Qs,Bo,Di,ae,Js,ae,ti,le,le,ei]],working:[Zs,Ks,Qs,pa,Di,ae,Js,ae,ti,le,le,ei],sleeping:[[Zs,Ks,Qs,Bo,Di,ae,Js,ae,ti,le,le,ei],[Zs,Ks,Qs,Bo,Di,ae,Js,ae,ti,le,le,ei]],done:[Zs,Ks,Qs,Vy,Yy,ae,Js,ae,ti,le,le,ei],size:12},O="transparent",N="body",q="outline",Pu="highlight",Fe="eye",mt=[O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O],si=[O,O,O,O,O,O,q,q,q,q,O,O,O,O,O,O],ii=[O,O,O,O,O,q,N,N,N,N,q,O,O,O,O,O],ni=[O,O,O,O,q,N,N,Pu,N,N,N,q,O,O,O,O],oi=[O,O,O,q,N,N,N,N,N,N,N,N,q,O,O,O],Ro=[O,O,O,q,N,Fe,Fe,N,N,Fe,Fe,N,q,O,O,O],ma=[O,O,O,q,N,q,q,N,N,q,q,N,q,O,O,O],zi=[O,O,q,N,N,N,N,N,N,N,N,N,N,q,O,O],ri=[O,O,q,N,N,N,N,N,N,N,N,N,N,q,O,O],$o=[O,q,N,N,N,N,N,N,N,N,N,N,N,N,q,O],Ue=[O,q,N,N,N,N,N,N,N,N,N,N,N,N,q,O],zn=[O,O,q,q,q,q,q,q,q,q,q,q,q,q,O,O],ga=[q,N,N,N,N,N,N,N,N,N,N,N,N,N,N,q],ya=[q,N,N,N,N,N,N,N,N,N,N,N,N,N,N,q],ba=[O,q,q,q,q,q,q,q,q,q,q,q,q,q,q,O],Xy=[O,O,q,N,N,N,q,q,q,q,N,N,N,q,O,O],Zy=[O,O,O,q,N,q,Fe,N,N,Fe,q,N,q,O,O,O],Ky=[O,q,N,N,N,N,N,N,N,N,N,N,N,N,q,O],Qy={idle:[[mt,mt,mt,mt,si,ii,ni,oi,Ro,zi,ri,$o,Ue,Ue,zn,mt],[mt,mt,mt,mt,si,ii,ni,oi,ma,zi,ri,$o,Ue,Ue,zn,mt]],walk:[[mt,mt,mt,si,ii,ni,oi,Ro,zi,ri,$o,Ue,Ue,Ue,zn,mt],[mt,mt,mt,mt,mt,si,ii,ni,oi,Ro,zi,ri,ga,ya,ba,mt]],working:[mt,mt,mt,mt,si,ii,ni,oi,Ro,Xy,ri,Ky,Ue,Ue,zn,mt],sleeping:[[mt,mt,mt,mt,mt,si,ii,ni,oi,ma,zi,ri,ga,ya,ba,mt],[mt,mt,mt,mt,mt,si,ii,ni,oi,ma,zi,ri,ga,ya,ba,mt]],done:[mt,mt,mt,mt,si,ii,ni,oi,Zy,zi,ri,$o,Ue,Ue,zn,mt],size:16},St=[O,O,O,O,O,O,O,O,O,O,O,O],ai=[O,O,O,O,q,q,q,q,O,O,O,O],li=[O,O,O,q,N,N,Pu,N,q,O,O,O],hi=[O,O,q,N,N,N,N,N,N,q,O,O],Do=[O,O,q,Fe,Fe,N,N,Fe,Fe,q,O,O],_a=[O,O,q,q,q,N,N,q,q,q,O,O],ci=[O,q,N,N,N,N,N,N,N,N,q,O],Je=[O,q,N,N,N,N,N,N,N,N,q,O],Fn=[O,O,q,q,q,q,q,q,q,q,O,O],xa=[q,N,N,N,N,N,N,N,N,N,N,q],va=[O,q,q,q,q,q,q,q,q,q,q,O],Jy=[O,q,N,N,q,q,q,q,N,N,q,O],t1=[O,O,q,q,Fe,N,N,Fe,q,q,O,O],e1={idle:[[St,St,St,ai,li,hi,Do,ci,Je,Je,Fn,St],[St,St,St,ai,li,hi,_a,ci,Je,Je,Fn,St]],walk:[[St,St,ai,li,hi,Do,ci,Je,Je,Je,Fn,St],[St,St,St,St,ai,li,hi,Do,ci,xa,va,St]],working:[St,St,St,ai,li,hi,Do,Jy,ci,Je,Fn,St],sleeping:[[St,St,St,St,ai,li,hi,_a,ci,xa,va,St],[St,St,St,St,ai,li,hi,_a,ci,xa,va,St]],done:[St,St,St,ai,li,hi,t1,ci,Je,Je,Fn,St],size:12},hl=[uy,xy,Ay,$y,qy,Qy],uc=[fy,Sy,Ey,zy,jy,e1];function s1(i){let t=0;for(let e=0;e<i.length;e++)t=(t<<5)-t+i.charCodeAt(e)|0;return Math.abs(t)%hl.length}function i1(i,t){switch(t){case"body":return i.body;case"outline":return i.outline;case"highlight":return i.highlight;case"eye":return i.eye;case"skin":return i.skin;case"transparent":return null}}const zo=3,fc=new Map;function he(i,t,e,s){const n=fc.get(s);if(n)return n;const o=new Wt,r=t.length,l=t[0].length;for(let d=0;d<r;d++)for(let c=0;c<l;c++){const p=i1(e,t[d][c]);p!==null&&o.rect(c*zo,d*zo,zo,zo).fill(p)}const h=i.generateTexture({target:o});return o.destroy(),fc.set(s,h),h}function ce(i,t){return`${i}_p${t}`}function rn(i){const t=new Ft,e=new Wt;t.addChild(e);const s=new Vi({text:i.label,style:new Ye({fontSize:i.fontSize,fontFamily:"'Segoe UI', sans-serif",fill:16777215,fontWeight:"700",...i.letterSpacing!==void 0?{letterSpacing:i.letterSpacing}:{}})});return s.anchor.set(.5,.5),t.addChild(s),{container:t,bg:e,text:s}}function Fo(i,t,e,s,n,o=.9,r=.7){i.clear(),i.circle(0,0,t).fill({color:e,alpha:o}).stroke({color:s,width:n,alpha:r})}function pc(i,t,e,s,n,o,r=.9,l=.7){i.clear(),i.roundRect(-t/2,-e/2,t,e,s).fill({color:n,alpha:r}).stroke({color:o,width:1,alpha:l})}const mc=3500,n1=3e3,gc=500,wa=8,o1=5,r1=6,yc=160,No=5,a1={tool:{bg:1712960,border:3821696,text:15266047},text:{bg:1712960,border:4212832,text:13421772},"input-needed":{bg:3809296,border:16750592,text:16764032}};class l1{constructor(t){b(this,"container");b(this,"bg");b(this,"pointer");b(this,"textObj");b(this,"speechTimer",0);b(this,"queue",[]);b(this,"currentIndex",0);b(this,"rotateTimer",0);b(this,"currentType","tool");b(this,"needsInputPulse",0);this.container=new Ft,this.container.visible=!1,this.bg=new Wt,this.container.addChild(this.bg),this.pointer=new Wt,this.container.addChild(this.pointer);const e=new Ye({fontSize:10,fontFamily:"'Segoe UI', 'Helvetica Neue', Arial, sans-serif",fill:15266047,wordWrap:!0,wordWrapWidth:yc-wa*2,lineHeight:14});this.textObj=new Vi({text:"",style:e}),this.textObj.anchor.set(.5,1),this.container.addChild(this.textObj),this.container.position.set(0,-t/2-8)}set(t){const e=Array.isArray(t)?t:[t];if(e.length===0||e.length===1&&!e[0].text){this.clear();return}if(this.queue=e.filter(s=>s.text),this.queue.length===0){this.clear();return}this.currentIndex=0,this.rotateTimer=0,this.speechTimer=mc,this.showCurrentMessage()}clear(){this.container.visible=!1,this.speechTimer=0,this.queue=[],this.currentIndex=0,this.needsInputPulse=0}update(t){if(!(this.speechTimer<=0)){if(this.speechTimer-=t,this.queue.length>1&&(this.rotateTimer+=t,this.rotateTimer>=n1&&(this.rotateTimer=0,this.currentIndex=(this.currentIndex+1)%this.queue.length,this.showCurrentMessage(),this.speechTimer=mc)),this.currentType==="input-needed"){this.needsInputPulse+=t*.004;const e=.7+.3*Math.sin(this.needsInputPulse);this.bg.alpha=e,this.speechTimer=Math.max(this.speechTimer,1e3)}else this.bg.alpha=1;this.speechTimer<=gc&&this.currentType!=="input-needed"&&(this.container.alpha=Math.max(0,this.speechTimer/gc)),this.speechTimer<=0&&this.currentType!=="input-needed"&&(this.container.visible=!1,this.speechTimer=0,this.queue=[])}}isActive(){return this.speechTimer>0}showCurrentMessage(){const t=this.queue[this.currentIndex];if(!t)return;this.currentType=t.type;const e=a1[t.type],s=t.icon??"",n=s?`${s} `:"",o=80,r=n+t.text,l=r.length>o?r.slice(0,o-1)+"…":r;this.textObj.text=l,this.textObj.style.fill=e.text;const h=Math.min(this.textObj.width,yc-wa*2),d=this.textObj.height,c=h+wa*2,p=d+o1*2;this.bg.clear(),this.bg.roundRect(-c/2,-(p+No),c,p,r1).fill({color:e.bg,alpha:.92}).stroke({color:e.border,width:1,alpha:.6}),this.pointer.clear(),this.pointer.moveTo(-No,0).lineTo(0,No).lineTo(No,0).closePath().fill({color:e.bg,alpha:.92}),this.pointer.position.set(0,-6),this.textObj.position.set(0,-10),this.container.visible=!0,this.container.alpha=1}}const h1=2,c1=4,d1=.7,u1=100,f1=3,p1=1.5,m1=2,g1=2.5,y1=.8,b1=1,_1=1.5,bc=600,_c=3e3,xc=30,vc=18,ss=class ss{constructor(t,e,s){b(this,"container",new Ft);b(this,"sprite");b(this,"nameBg");b(this,"nameLabel");b(this,"speechBubble");b(this,"needsInputPulse",0);b(this,"childBadge",null);b(this,"planBadge",null);b(this,"planPulseTimer",0);b(this,"_isPlanning",!1);b(this,"waitBadge",null);b(this,"waitPulseTimer",0);b(this,"_isWaiting",!1);b(this,"waitQContainer");b(this,"waitQLetters");b(this,"waitQTimer",0);b(this,"animState","idle");b(this,"isIdleState",!1);b(this,"isDoneState",!1);b(this,"idleTimer",0);b(this,"zzzContainer");b(this,"zzzLetters");b(this,"zzzTimer",0);b(this,"doneBadge",null);b(this,"sparkles",[]);b(this,"compactBadge",null);b(this,"compactPulseTimer",0);b(this,"_isCompacting",!1);b(this,"outcomeFlash",null);b(this,"anomalyBadge",null);b(this,"anomalyPulseTimer",0);b(this,"_hasAnomaly",!1);b(this,"anomalyAutoClearTimer",null);b(this,"contextBar");b(this,"_contextPct",0);b(this,"activityRing");b(this,"activityLevel",0);b(this,"activityPhase",0);b(this,"isSubagent");b(this,"variantIndex");b(this,"spriteHeight");b(this,"textures");b(this,"frameTimer",0);b(this,"frameIndex",0);b(this,"targetX");b(this,"targetY");b(this,"isMoving",!1);b(this,"bobTimer");b(this,"baseY");b(this,"fadingOut",!1);b(this,"fadeTimer",0);b(this,"fadeResolve",null);b(this,"spawnAnimTimer",0);this.isSubagent=t.role==="subagent";const n=this.isSubagent;this.variantIndex=s1(t.projectPath??t.sessionId);const o=this.variantIndex,r=n?uc[o]:hl[o],l=n?`sub_v${o}`:`main_v${o}`,h=t.colorIndex;this.spriteHeight=r.size*3,this.textures={idle:[he(s,r.idle[0],e,ce(`${l}_idle0`,h)),he(s,r.idle[1],e,ce(`${l}_idle1`,h))],walk:[he(s,r.walk[0],e,ce(`${l}_walk0`,h)),he(s,r.walk[1],e,ce(`${l}_walk1`,h))],working:he(s,r.working,e,ce(`${l}_working`,h)),sleeping:[he(s,r.sleeping[0],e,ce(`${l}_sleeping0`,h)),he(s,r.sleeping[1],e,ce(`${l}_sleeping1`,h))],done:he(s,r.done,e,ce(`${l}_done`,h))},this.sprite=new Yi(this.textures.idle[0]),this.sprite.anchor.set(.5,.5),this.container.addChild(this.sprite),this.nameBg=new Wt,this.container.addChild(this.nameBg);const d=t.agentName||ho(t.sessionId),c=d.length>14?d.slice(0,12)+"..":d,p=new Ye({fontSize:11,fontFamily:"'Segoe UI', 'Helvetica Neue', Arial, sans-serif",fill:16777215,align:"center",fontWeight:"700"});this.nameLabel=new Vi({text:c,style:p}),this.nameLabel.anchor.set(.5,0),this.nameLabel.position.set(0,this.spriteHeight/2+8),this.container.addChild(this.nameLabel),this.updateNameBg(),this.contextBar=new Wt,this.container.addChild(this.contextBar),this.setContextHealth(0),this.speechBubble=new l1(this.spriteHeight),this.container.addChild(this.speechBubble.container),this.zzzContainer=new Ft,this.zzzContainer.visible=!1,this.zzzLetters=[];const g=[8,10,13],m=["z","z","Z"];for(let x=0;x<3;x++){const w=new Vi({text:m[x],style:new Ye({fontSize:g[x],fontFamily:"'Segoe UI', sans-serif",fill:8952268,fontWeight:"700",dropShadow:{alpha:.5,blur:2,color:0,distance:1}})});w.anchor.set(.5,.5),this.zzzLetters.push(w),this.zzzContainer.addChild(w)}this.zzzContainer.position.set(this.spriteHeight/3,-this.spriteHeight/2),this.container.addChild(this.zzzContainer),this.waitQContainer=new Ft,this.waitQContainer.visible=!1,this.waitQLetters=[];const y=[9,11,14];for(let x=0;x<3;x++){const w=new Vi({text:"?",style:new Ye({fontSize:y[x],fontFamily:"'Segoe UI', sans-serif",fill:16750592,fontWeight:"700",dropShadow:{alpha:.5,blur:2,color:0,distance:1}})});w.anchor.set(.5,.5),this.waitQLetters.push(w),this.waitQContainer.addChild(w)}this.waitQContainer.position.set(this.spriteHeight/3,-this.spriteHeight/2),this.container.addChild(this.waitQContainer),this.activityRing=new Wt,this.activityRing.visible=!1,this.container.addChildAt(this.activityRing,0),this.container.eventMode="static",this.container.cursor="pointer",this.container.hitArea={contains:(x,w)=>{const k=this.spriteHeight/2+10,E=-this.spriteHeight/2-10,B=this.spriteHeight/2+25;return x>=-k&&x<=k&&w>=E&&w<=B}},this.spawnAnimTimer=ss.SPAWN_ANIM_DURATION,this.container.scale.set(.3),this.targetX=0,this.targetY=0,this.baseY=0,this.bobTimer=Math.random()*Math.PI*2}moveTo(t,e){this.targetX=t,this.targetY=e,this.isMoving=!0}setSpeech(t){this.speechBubble.set(t)}clearSpeech(){this.speechBubble.clear()}setCustomName(t){const e=t.length>14?t.slice(0,12)+"..":t;this.nameLabel.text=e,this.updateNameBg()}updateNameBg(){this.nameBg.clear();const t=6,e=3,s=this.nameLabel.width,n=this.nameLabel.height,o=s+t*2,r=n+e*2,l=this.spriteHeight/2+8-e;this.nameBg.roundRect(-o/2,l,o,r,4).fill({color:0,alpha:.55})}rebuildTextures(t,e,s){const n=this.variantIndex,o=this.isSubagent?uc[n]:hl[n],r=this.isSubagent?`sub_v${n}`:`main_v${n}`,l=e;this.textures={idle:[he(s,o.idle[0],t,ce(`${r}_idle0`,l)),he(s,o.idle[1],t,ce(`${r}_idle1`,l))],walk:[he(s,o.walk[0],t,ce(`${r}_walk0`,l)),he(s,o.walk[1],t,ce(`${r}_walk1`,l))],working:he(s,o.working,t,ce(`${r}_working`,l)),sleeping:[he(s,o.sleeping[0],t,ce(`${r}_sleeping0`,l)),he(s,o.sleeping[1],t,ce(`${r}_sleeping1`,l))],done:he(s,o.done,t,ce(`${r}_done`,l))},this.sprite.texture=this.textures.idle[0]}setContextHealth(t,e=0){this._contextPct=Math.max(0,Math.min(1,t));const s=4,n=this.spriteHeight,o=this.spriteHeight/2+4,r=-n/2;if(this.contextBar.clear(),this.contextBar.visible=!0,this.contextBar.roundRect(o,r,s,n,2).fill({color:0,alpha:.4}),this._contextPct>0){let l;this._contextPct<.5?l=2278750:this._contextPct<.75?l=15381256:this._contextPct<.9?l=16347926:l=15680580;const h=Math.max(2,n*this._contextPct);this.contextBar.roundRect(o,r+n-h,s,h,2).fill({color:l,alpha:.9})}}setIdle(t){t&&!this.isIdleState&&(this.idleTimer=0),this.isIdleState=t}setDone(t){if(this.isDoneState=t,t){if(this.doneBadge||(this.doneBadge=rn({label:"✓",fontSize:10}),this.doneBadge.container.position.set(0,-this.spriteHeight/2-14),this.container.addChild(this.doneBadge.container)),Fo(this.doneBadge.bg,8,5025616,8505220,1.5,.9,.7),this.doneBadge.container.visible=!0,this.sparkles.length===0){const e=[{x:-14,y:-18},{x:16,y:-12},{x:-10,y:8},{x:18,y:4}];for(let s=0;s<4;s++){const n=new Wt;n.rect(-.75,-3,1.5,6).fill({color:16766287}),n.rect(-3,-.75,6,1.5).fill({color:16766287}),n.position.set(e[s].x,e[s].y),n.visible=!1,this.container.addChild(n),this.sparkles.push({gfx:n,phase:Math.random()*4e3})}}for(const e of this.sparkles)e.gfx.visible=!1}else{this.doneBadge&&(this.doneBadge.container.visible=!1);for(const e of this.sparkles)e.gfx.visible=!1}}setChildCount(t){if(t<=0){this.childBadge&&(this.childBadge.container.visible=!1);return}this.childBadge||(this.childBadge=rn({label:"",fontSize:9}),this.childBadge.container.position.set(this.spriteHeight/2-4,-this.spriteHeight/2+4),this.container.addChild(this.childBadge.container)),this.childBadge.text.text=`${t}`,Fo(this.childBadge.bg,8,11225020,16777215,1,1,.5),this.childBadge.container.visible=!0}setPlanning(t){if(this._isPlanning=t,!t){this.planBadge&&(this.planBadge.container.visible=!1);return}this.planBadge||(this.planBadge=rn({label:"PLAN",fontSize:8,letterSpacing:.5}),this.planBadge.container.position.set(-this.spriteHeight/2+2,-this.spriteHeight/2+2),this.container.addChild(this.planBadge.container)),this.drawPlanBadge(1),this.planBadge.container.visible=!0}drawPlanBadge(t){this.planBadge&&pc(this.planBadge.bg,30,13,3,16347926,16498468,t*.9,t*.7)}setWaiting(t){if(this._isWaiting=t,!t){this.waitBadge&&(this.waitBadge.container.visible=!1),this.waitQContainer.visible=!1;return}this.waitBadge||(this.waitBadge=rn({label:"?",fontSize:11}),this.waitBadge.container.position.set(0,-this.spriteHeight/2-14),this.container.addChild(this.waitBadge.container)),this.drawWaitBadge(1),this.waitBadge.container.visible=!0}drawWaitBadge(t){this.waitBadge&&Fo(this.waitBadge.bg,9,16750592,16764032,1.5,t*.9,t*.7)}setCompacting(t){if(this._isCompacting=t,!t){this.compactBadge&&(this.compactBadge.container.visible=!1);return}this.compactBadge||(this.compactBadge=rn({label:"↺ COMPACT",fontSize:8,letterSpacing:.3}),this.compactBadge.container.position.set(0,this.spriteHeight/2+28),this.container.addChild(this.compactBadge.container)),this.drawCompactBadge(1),this.compactBadge.container.visible=!0}drawCompactBadge(t){this.compactBadge&&pc(this.compactBadge.bg,58,13,3,8141549,10980346,t*.9,t*.7)}flashOutcome(t){this.outcomeFlash={outcome:t,timer:ss.OUTCOME_FLASH_DURATION}}bumpActivity(){this.activityLevel=Math.min(1,this.activityLevel+.35)}setAnomaly(t){this._hasAnomaly=!0,this.anomalyPulseTimer=0,this.anomalyBadge||(this.anomalyBadge=rn({label:"!",fontSize:10}),this.anomalyBadge.container.position.set(this.spriteHeight/2+2,-this.spriteHeight/2-2),this.container.addChild(this.anomalyBadge.container)),this.anomalyBadge.container.visible=!0,this.anomalyAutoClearTimer&&clearTimeout(this.anomalyAutoClearTimer),this.anomalyAutoClearTimer=setTimeout(()=>this.clearAnomaly(),3e4)}clearAnomaly(){this._hasAnomaly=!1,this.anomalyBadge&&(this.anomalyBadge.container.visible=!1),this.anomalyAutoClearTimer&&(clearTimeout(this.anomalyAutoClearTimer),this.anomalyAutoClearTimer=null)}fadeOut(){return this.fadingOut?new Promise(t=>{const e=this.fadeResolve;this.fadeResolve=()=>{e==null||e(),t()}}):(this.fadingOut=!0,this.fadeTimer=bc,new Promise(t=>{this.fadeResolve=t}))}update(t){var n,o,r,l,h;if(this.spawnAnimTimer>0)if(this.spawnAnimTimer-=t,this.spawnAnimTimer<=0)this.spawnAnimTimer=0,this.container.scale.set(1);else{const d=1-this.spawnAnimTimer/ss.SPAWN_ANIM_DURATION,c=1-Math.pow(2,-8*d)*Math.cos(d*Math.PI*3);this.container.scale.set(Math.max(.3,Math.min(1,c)))}if(this.fadingOut){this.fadeTimer-=t,this.container.alpha=Math.max(0,this.fadeTimer/bc),this.fadeTimer<=0&&(this.fadingOut=!1,(n=this.fadeResolve)==null||n.call(this),this.fadeResolve=null);return}this.isMoving?this.updateMovement(t):this.updateBob(t),this.isIdleState&&!this.isDoneState&&(this.idleTimer+=t),this.isMoving?this.animState="walk":this.isDoneState?this.animState="done":this.isIdleState&&this.idleTimer>=ss.IDLE_TO_SLEEP_MS?this.animState="sleeping":this.speechBubble.isActive()?this.animState="working":this.animState="idle",this.frameTimer+=t;const s=1e3/(this.animState==="walk"?c1:this.animState==="sleeping"?d1:h1);if(this.animState==="working")this.sprite.texture=this.textures.working;else if(this.animState==="done")this.sprite.texture=this.textures.done;else{this.frameTimer>=s&&(this.frameTimer-=s,this.frameIndex=(this.frameIndex+1)%2);const d=this.animState==="walk"?this.textures.walk:this.animState==="sleeping"?this.textures.sleeping:this.textures.idle;this.sprite.texture=d[this.frameIndex]}if(this.animState==="sleeping"){this.zzzContainer.visible=!0,this.zzzTimer+=t;for(let d=0;d<this.zzzLetters.length;d++){const c=d/this.zzzLetters.length,p=(this.zzzTimer/_c+c)%1,g=this.zzzLetters[d];g.position.set(p*vc,-p*xc),g.alpha=Math.max(0,1-p*1.3),g.scale.set(.5+p*.6)}}else this.zzzContainer.visible=!1;if(this._isWaiting){this.waitQContainer.visible=!0,this.waitQTimer+=t;for(let d=0;d<this.waitQLetters.length;d++){const c=d/this.waitQLetters.length,p=(this.waitQTimer/_c+c)%1,g=this.waitQLetters[d];g.position.set(p*vc,-p*xc),g.alpha=Math.max(0,1-p*1.3),g.scale.set(.5+p*.6)}}else this.waitQContainer.visible=!1;if(this.isDoneState&&this.sparkles.length>0)for(let d=0;d<this.sparkles.length;d++){const c=this.sparkles[d];c.phase+=t;const p=2e3+d*700,g=c.phase%p/p;g<.15?(c.gfx.visible=!0,c.gfx.alpha=g/.15):g<.3?(c.gfx.visible=!0,c.gfx.alpha=1-(g-.15)/.15):c.gfx.visible=!1}if(!this.outcomeFlash)if(this._isWaiting){this.activityRing.visible=!0,this.activityPhase+=t*.004,this.activityRing.clear();const d=this.spriteHeight/2+6,c=.4+.3*Math.sin(this.activityPhase*2),p=Math.PI*1.2;for(let g=0;g<2;g++){const m=this.activityPhase+g*Math.PI;this.activityRing.arc(0,0,d,m,m+p).stroke({color:16750592,width:2.5,alpha:c})}for(let g=0;g<2;g++){const m=this.activityPhase+g*Math.PI;this.activityRing.arc(0,0,d+2,m,m+p*.8).stroke({color:16750592,width:3,alpha:c*.3})}}else if(this.activityLevel=Math.max(0,this.activityLevel-t*4e-4),this.activityLevel>.02&&!this.isDoneState){this.activityRing.visible=!0,this.activityPhase+=t*.003,this.activityRing.clear();const d=this.spriteHeight/2+6,c=this.activityLevel*.6,p=Math.PI*.4+this.activityLevel*Math.PI*.8;for(let g=0;g<2;g++){const m=this.activityPhase+g*Math.PI;this.activityRing.arc(0,0,d,m,m+p).stroke({color:4906624,width:2,alpha:c})}if(this.activityLevel>.3)for(let g=0;g<2;g++){const m=this.activityPhase+g*Math.PI;this.activityRing.arc(0,0,d+2,m,m+p*.8).stroke({color:4906624,width:3,alpha:c*.25})}}else this.activityRing.visible=!1;if(this._isPlanning&&((o=this.planBadge)!=null&&o.container.visible)){this.planPulseTimer+=t*.003;const d=.7+.3*Math.sin(this.planPulseTimer);this.drawPlanBadge(d)}if(this._isCompacting&&((r=this.compactBadge)!=null&&r.container.visible)){this.compactPulseTimer+=t*.003;const d=.65+.35*Math.sin(this.compactPulseTimer*1.5);this.drawCompactBadge(d);const c=1+.04*Math.sin(this.compactPulseTimer*2);this.compactBadge.container.scale.set(c,1)}if(this.outcomeFlash)if(this.outcomeFlash.timer-=t,this.outcomeFlash.timer<=0)this.outcomeFlash=null,this.activityRing.visible=!1;else{const d=this.outcomeFlash.timer/ss.OUTCOME_FLASH_DURATION,c=d*.85,p=this.spriteHeight/2+6+(1-d)*8,g=this.outcomeFlash.outcome==="success"?4906624:16281969;this.activityRing.visible=!0,this.activityRing.clear(),this.activityRing.circle(0,0,p).stroke({color:g,width:3,alpha:c}),this.activityRing.circle(0,0,p+4).stroke({color:g,width:1.5,alpha:c*.4})}if(this._hasAnomaly&&((l=this.anomalyBadge)!=null&&l.container.visible)&&this.anomalyBadge.bg){this.anomalyPulseTimer+=t*.005;const d=.85+.15*Math.sin(this.anomalyPulseTimer);this.anomalyBadge.container.scale.set(d),Fo(this.anomalyBadge.bg,8,15680580,16498468,1.5,.9,.7)}if(this._isWaiting&&((h=this.waitBadge)!=null&&h.container.visible)){this.waitPulseTimer+=t*.005;const d=.5+.5*Math.sin(this.waitPulseTimer);this.drawWaitBadge(d);const c=1+.15*Math.sin(this.waitPulseTimer*.7);this.waitBadge.container.scale.set(c)}this.speechBubble.update(t)}updateMovement(t){const e=t/1e3,s=this.targetX-this.container.x,n=this.targetY-this.container.y,o=Math.sqrt(s*s+n*n);if(o<f1){this.container.x=this.targetX,this.container.y=this.targetY,this.baseY=this.container.y,this.isMoving=!1;return}const r=Math.min(u1*e,o);this.container.x+=s/o*r,this.container.y+=n/o*r}updateBob(t){const e=this.animState==="sleeping"?g1:this.animState==="done"?b1:p1,s=this.animState==="sleeping"?y1:this.animState==="done"?_1:m1;this.bobTimer=(this.bobTimer+t/1e3*s*Math.PI*2)%(Math.PI*2),this.container.y=this.baseY+Math.sin(this.bobTimer)*e}onClick(t){this.container.on("pointertap",t)}onHover(t,e){this.container.on("pointerover",t),this.container.on("pointerout",e)}getPosition(){return{x:this.container.x,y:this.container.y}}destroy(){this.anomalyAutoClearTimer&&(clearTimeout(this.anomalyAutoClearTimer),this.anomalyAutoClearTimer=null),this.container.destroy({children:!0})}};b(ss,"IDLE_TO_SLEEP_MS",3e4),b(ss,"OUTCOME_FLASH_DURATION",700),b(ss,"SPAWN_ANIM_DURATION",400);let cl=ss;const wc=6,Sc=4,x1=.04,v1=3,w1=.15,S1=1,kc=.5,Tc=6,Cc=400,Ac=4886745,k1=4521796;class T1{constructor(){b(this,"graphics",new Wt);b(this,"time",0);b(this,"pulseTimers",new Map)}pulseConnection(t,e){this.pulseTimers.set(`${t}->${e}`,Cc)}update(t,e){this.time=(this.time+e)%1e6,this.graphics.clear();for(const[o,r]of this.pulseTimers){const l=r-e;l<=0?this.pulseTimers.delete(o):this.pulseTimers.set(o,l)}const s=Array.from(t.entries());for(const[o,r]of s)if(r.parentId){const l=t.get(r.parentId);if(l){const h=`${r.parentId}->${o}`,d=this.pulseTimers.get(h)??0,p=d>0?d/Cc:0;this.drawGlowingDashedLine(l.x,l.y,r.x,r.y,Ac,p),this.drawArrow(l.x,l.y,r.x,r.y,Ac,p)}}const n=new Map;for(const[,o]of s)if(o.teamName){const r=`${o.rootSessionId}:${o.teamName}`;let l=n.get(r);l||(l=[],n.set(r,l)),l.push(o)}for(const o of n.values())if(!(o.length<2))for(let r=0;r<o.length-1;r++)this.drawGlowingDashedLine(o[r].x,o[r].y,o[r+1].x,o[r+1].y,k1,0)}drawGlowingDashedLine(t,e,s,n,o,r){const l=this.time*x1,h=w1+r*.35,d=kc+r*.4,c=v1+r*2;this.drawDashedLine(t,e,s,n,o,h,c,l),this.drawDashedLine(t,e,s,n,o,d,S1,l)}drawDashedLine(t,e,s,n,o,r,l,h){const d=s-t,c=n-e,p=Math.sqrt(d*d+c*c);if(p<1)return;const g=d/p,m=c/p,y=wc+Sc;let w=-((h%y+y)%y),k=!0;for(;w<p;){const B=w+(k?wc:Sc);if(k){const L=Math.max(w,0),H=Math.min(B,p);if(H>L){const $=t+g*L,G=e+m*L,tt=t+g*H,Z=e+m*H;this.graphics.moveTo($,G).lineTo(tt,Z).stroke({color:o,width:l,alpha:r})}}w=B,k=!k}}drawArrow(t,e,s,n,o,r){const l=s-t,h=n-e,d=Math.sqrt(l*l+h*h);if(d<Tc*3)return;const c=l/d,p=h/d,g=(t+s)/2,m=(e+n)/2,y=-p,x=c,w=Tc/2,k=kc+r*.4,E=g+c*w,B=m+p*w,L=g-c*w+y*w,H=m-p*w+x*w,$=g-c*w-y*w,G=m-p*w-x*w;this.graphics.moveTo(E,B).lineTo(L,H).lineTo($,G).closePath().fill({color:o,alpha:k})}destroy(){this.graphics.destroy()}}const C1=8,Sa=3,Mc=800,Ec=30;class A1{constructor(t){b(this,"container",new Ft);b(this,"particles",[]);b(this,"particleTextures",new Map);this.renderer=t}emit(t,e,s){const n=this.getTexture(s);for(let o=0;o<C1;o++){const r=new Yi(n);r.anchor.set(.5),r.position.set(t,e),r.alpha=1;const l=Math.random()*Math.PI*2,h=Ec*(.5+Math.random()*.5);this.container.addChild(r),this.particles.push({sprite:r,vx:Math.cos(l)*h,vy:-Math.abs(Math.sin(l)*h)-Ec*.5,life:Mc,maxLife:Mc})}}update(t){const e=t/1e3;for(let s=this.particles.length-1;s>=0;s--){const n=this.particles[s];if(n.life-=t,n.life<=0){this.container.removeChild(n.sprite),n.sprite.destroy(),this.particles.splice(s,1);continue}n.sprite.x+=n.vx*e,n.sprite.y+=n.vy*e,n.sprite.alpha=Math.max(0,n.life/n.maxLife);const o=.3+.7*(n.life/n.maxLife);n.sprite.scale.set(o)}}getTexture(t){let e=this.particleTextures.get(t);if(e)return e;const s=new Wt;return s.circle(Sa,Sa,Sa).fill(t),e=this.renderer.generateTexture({target:s}),s.destroy(),this.particleTextures.set(t,e),e}destroy(){for(const t of this.particles)t.sprite.destroy();this.particles=[];for(const t of this.particleTextures.values())t.destroy(!0);this.particleTextures.clear(),this.container.destroy({children:!0})}}const M1=800,Pc=3,Ic=3,E1=40;class P1{constructor(){b(this,"container",new Ft);b(this,"particles",[])}send(t,e,s,n,o){const r=new Wt;this.container.addChild(r),this.particles.push({gfx:r,fromX:t,fromY:e,toX:s,toY:n,color:o,elapsed:0,duration:M1})}update(t){for(let e=this.particles.length-1;e>=0;e--){const s=this.particles[e];if(s.elapsed+=t,s.elapsed>=s.duration){this.container.removeChild(s.gfx),s.gfx.destroy(),this.particles.splice(e,1);continue}const n=s.elapsed/s.duration;s.gfx.clear();for(let r=0;r<=Pc;r++){const l=Math.max(0,n-r*.06),h=this.getArcPosition(s,l),d=(1-r/(Pc+1))*(1-n*.3),c=Ic*(1-r*.2);s.gfx.circle(h.x,h.y,c).fill({color:s.color,alpha:d})}const o=this.getArcPosition(s,n);s.gfx.circle(o.x,o.y,Ic*2.5).fill({color:s.color,alpha:.15})}}getArcPosition(t,e){const s=(t.fromX+t.toX)/2,n=(t.fromY+t.toY)/2-E1,o=1-e,r=o*o*t.fromX+2*o*e*s+e*e*t.toX,l=o*o*t.fromY+2*o*e*n+e*e*t.toY;return{x:r,y:l}}destroy(){for(const t of this.particles)t.gfx.destroy();this.particles=[],this.container.destroy({children:!0})}}class I1{constructor(){b(this,"zoneCounts",new Map)}updateFromAgents(t){this.zoneCounts.clear();for(const e of t)this.zoneCounts.set(e,(this.zoneCounts.get(e)??0)+1);return this.zoneCounts}getCount(t){return this.zoneCounts.get(t)??0}getCounts(){return this.zoneCounts}}function L1(i){const t=[];if(i.currentTool==="AskUserQuestion")return t.push({text:"Waiting for input...",type:"input-needed",icon:"⏳"}),t;if(i.currentTool){const e=b0[i.currentTool]||"⚙️";let s=i.currentTool;if(i.currentActivity){const n=i.currentActivity;if(n.length<=50)s=`${i.currentTool}: ${n}`;else{const o=n.replace(/\\/g,"/").split("/"),r=o.length>2?`.../${o.slice(-2).join("/")}`:n.slice(0,45);s=`${i.currentTool}: ${r}`}}t.push({text:s,type:"tool",icon:e})}return i.isPlanning&&i.currentTool!=="EnterPlanMode"&&i.currentTool!=="ExitPlanMode"&&t.push({text:"Planning...",type:"tool",icon:"📝"}),i.speechText&&t.push({text:i.speechText,type:"text",icon:"💭"}),t}function Go(i,t,e,s){const n=Zt.get(i);if(!n)return s.getZoneCenter(i);const o=[];for(const[E,B]of e)(B.state.currentZone===i||B.state.isIdle&&i==="idle")&&o.push(E);o.includes(t)||o.push(t),o.sort();const r=o.indexOf(t),l=o.length,h=n.width-40,d=n.height-70,c=n.x+20,p=n.y+50;if(l===1)return{x:c+h/2,y:p+d/2};const g=Math.ceil(Math.sqrt(l)),m=Math.ceil(l/g),y=r%g,x=Math.floor(r/g),w=h/g,k=d/m;return{x:c+w*y+w/2,y:p+k*x+k/2}}class B1{constructor(t,e,s){b(this,"agents",new Map);b(this,"lines");b(this,"particles");b(this,"messageFlow");b(this,"zoneGlow");b(this,"sound",null);b(this,"notifications",null);b(this,"_focusedAgentId",null);b(this,"_onAgentClick",null);b(this,"_onAgentHover",null);b(this,"_customizationLookup",null);b(this,"onSpawnBound");b(this,"onUpdateBound");b(this,"onIdleBound");b(this,"onShutdownBound");b(this,"onResetBound");b(this,"onAnomalyBound");this.app=t,this.world=e,this.store=s,this.lines=new T1,this.world.uiLayer.addChild(this.lines.graphics),this.particles=new A1(t.renderer),this.world.addEffect(this.particles.container),this.messageFlow=new P1,this.world.addEffect(this.messageFlow.container),this.zoneGlow=new I1,this.onSpawnBound=n=>this.onSpawn(n),this.onUpdateBound=n=>this.onUpdate(n),this.onIdleBound=n=>this.onIdle(n),this.onShutdownBound=n=>this.onShutdown(n),this.onResetBound=n=>this.onReset(n),this.store.on("agent:spawn",this.onSpawnBound),this.store.on("agent:update",this.onUpdateBound),this.store.on("agent:idle",this.onIdleBound),this.store.on("agent:shutdown",this.onShutdownBound),this.store.on("state:reset",this.onResetBound),this.onAnomalyBound=n=>{const o=this.agents.get(n.agentId);o&&o.sprite.setAnomaly(n.kind)},this.store.on("anomaly:alert",this.onAnomalyBound)}setSoundManager(t){this.sound=t}setNotificationManager(t){this.notifications=t}setClickHandler(t){this._onAgentClick=t}setHoverHandler(t){this._onAgentHover=t}setCustomizationLookup(t){this._customizationLookup=t}getDisplayName(t){return this._customizationLookup?this._customizationLookup(t).displayName:t.agentName||ho(t.sessionId)}getDisplayColorIndex(t){return this._customizationLookup?this._customizationLookup(t).colorIndex:t.colorIndex}updateChildBadges(){const t=new Map;for(const[,e]of this.agents)e.state.parentId&&t.set(e.state.parentId,(t.get(e.state.parentId)??0)+1);for(const[e,s]of this.agents)s.sprite.setChildCount(t.get(e)??0)}onSpawn(t){var h,d;if(this.agents.has(t.id))return;const e=ft[t.colorIndex%ft.length],s=new cl(t,e,this.app.renderer),n=t.parentId?this.agents.get(t.parentId):null;if(n)s.container.position.set(n.sprite.container.x,n.sprite.container.y);else{const c=this.world.getZoneCenter("spawn");s.container.position.set(c.x,c.y)}s.onClick(()=>{var c;return(c=this._onAgentClick)==null?void 0:c.call(this,t.id)}),s.onHover(()=>{var c;return(c=this._onAgentHover)==null?void 0:c.call(this,t.id,s.container.x,s.container.y)},()=>{var c;return(c=this._onAgentHover)==null?void 0:c.call(this,null,0,0)});const o=this.getDisplayName(t),r=this.getDisplayColorIndex(t);if(s.setCustomName(o),r!==t.colorIndex){const c=ft[r%ft.length];s.rebuildTextures(c,r,this.app.renderer)}s.setContextHealth(t.contextTokens/this.getContextWindowSize(t.model),t.contextCacheTokens/this.getContextWindowSize(t.model)),this.agents.set(t.id,{sprite:s,state:t,notifiedWaiting:!1,lastSeenOutcome:null}),this.world.addAgent(s.container);const l=Go(t.currentZone,t.id,this.agents,this.world);s.moveTo(l.x,l.y),this.updateChildBadges(),(h=this.sound)==null||h.play("spawn"),(d=this.notifications)==null||d.notifySpawn(o)}getContextWindowSize(t){return v0(t)}onUpdate(t){var r,l,h,d;const e=this.agents.get(t.id);if(!e){this.onSpawn(t);return}const s=e.state.currentZone;e.state=t,e.sprite.setCustomName(this.getDisplayName(t));const n=Go(t.currentZone,t.id,this.agents,this.world);e.sprite.moveTo(n.x,n.y);const o=L1(t);if(o.length>0?e.sprite.setSpeech(o):e.sprite.clearSpeech(),e.sprite.setIdle(!1),e.sprite.setPlanning(t.isPlanning),e.sprite.setCompacting(t.phase==="compacting"),e.sprite.setContextHealth(t.contextTokens/this.getContextWindowSize(t.model),t.contextCacheTokens/this.getContextWindowSize(t.model)),t.lastToolOutcome&&t.lastToolOutcome!==e.lastSeenOutcome&&e.sprite.flashOutcome(t.lastToolOutcome),e.lastSeenOutcome=t.lastToolOutcome,e.sprite.setWaiting(t.isWaitingForUser),t.isWaitingForUser&&!e.notifiedWaiting?(e.notifiedWaiting=!0,(r=this.sound)==null||r.play("input-needed"),(l=this.notifications)==null||l.notifyInputNeeded(this.getDisplayName(t)),this.updateDocTitle()):t.isWaitingForUser||(e.notifiedWaiting=!1,this.updateDocTitle()),t.isDone){e.sprite.setDone(!0),e.sprite.setIdle(!0),e.sprite.clearSpeech(),e.sprite.container.alpha=.65;return}if(e.sprite.setDone(!1),e.sprite.container.alpha=1,t.currentTool){const c=ft[this.getDisplayColorIndex(t)%ft.length];if(this.particles.emit(e.sprite.container.x,e.sprite.container.y,c.body),(h=this.sound)==null||h.play("tool-use"),t.currentTool==="SendMessage"){let p;if(t.messageTarget){for(const[,g]of this.agents)if((g.state.agentName===t.messageTarget||g.state.id===t.messageTarget)&&g.state.rootSessionId===t.rootSessionId){p=g;break}}if(!p&&t.parentId&&(p=this.agents.get(t.parentId)),!p){for(const[,g]of this.agents)if(g.state.parentId===t.id){p=g;break}}p&&this.messageFlow.send(e.sprite.container.x,e.sprite.container.y,p.sprite.container.x,p.sprite.container.y,c.body)}e.sprite.bumpActivity()}if(s!==t.currentZone){(d=this.sound)==null||d.play("zone-change");const c=ft[this.getDisplayColorIndex(t)%ft.length];this.world.flowLines.triggerFlow(s,t.currentZone,c.body)}}onIdle(t){var n,o;const e=this.agents.get(t.id);if(!e)return;e.state=t;const s=Go("idle",t.id,this.agents,this.world);e.sprite.moveTo(s.x,s.y),e.sprite.setIdle(!0),e.sprite.setWaiting(!1),e.sprite.setCompacting(!1),e.sprite.clearSpeech(),e.notifiedWaiting=!1,this.updateDocTitle(),(n=this.sound)==null||n.play("idle"),(o=this.notifications)==null||o.notifyIdle(this.getDisplayName(t))}onShutdown(t){var n,o;const e=this.agents.get(t);if(!e)return;(n=this.sound)==null||n.play("shutdown"),(o=this.notifications)==null||o.notifyShutdown(this.getDisplayName(e.state));const s=this.world.getZoneCenter("spawn");e.sprite.moveTo(s.x,s.y),e.sprite.fadeOut().then(()=>{this.world.removeAgent(e.sprite.container),e.sprite.destroy(),this.agents.delete(t),this.updateChildBadges(),this.updateDocTitle()})}onReset(t){this.rebuildFromState(t)}rebuildFromState(t){for(const[,s]of this.agents)this.world.removeAgent(s.sprite.container),s.sprite.destroy();this.agents.clear();const e=this.sound;this.sound=null;for(const s of t.values()){this.onSpawn(s);const n=this.agents.get(s.id);if(n){const o=Go(s.currentZone,s.id,this.agents,this.world);n.sprite.container.position.set(o.x,o.y),n.sprite.spawnAnimTimer=0,n.sprite.container.scale.set(1),n.sprite.setIdle(s.isIdle),n.sprite.setWaiting(s.isWaitingForUser),s.isDone&&(n.sprite.setDone(!0),n.sprite.container.alpha=.65)}}this.sound=e}update(t){for(const o of this.agents.values())o.sprite.update(t);this.particles.update(t),this.messageFlow.update(t);const e=new Map;for(const[o,r]of this.agents)e.set(o,{x:r.sprite.container.x,y:r.sprite.container.y,parentId:r.state.parentId,teamName:r.state.teamName,rootSessionId:r.state.rootSessionId,colorIndex:this.getDisplayColorIndex(r.state)});this.lines.update(e,t);const s=Array.from(this.agents.values()).map(o=>o.state.currentZone),n=this.zoneGlow.updateFromAgents(s);for(const[o,r]of n)this.world.setZoneAgentCount(o,r);for(const o of Zt.keys())n.has(o)||this.world.setZoneAgentCount(o,0)}updateDocTitle(){let t=0;for(const s of this.agents.values())s.state.isWaitingForUser&&t++;const e="Agent Move";if(t>0){const s=t===1?"⚠️ Input needed":`⚠️ ${t} agents waiting`;document.title=`${s} — ${e}`}else document.title!==e&&(document.title=e)}setFocusAgent(t){this._focusedAgentId=t}get focusedAgentId(){return this._focusedAgentId}getFocusedAgentName(){if(!this._focusedAgentId)return null;const t=this.agents.get(this._focusedAgentId);return t?this.getDisplayName(t.state):null}getActiveAgentIds(){const t=[];for(const[e,s]of this.agents)!s.state.isIdle&&!s.state.isDone&&t.push(e);if(t.length===0)for(const[e]of this.agents)t.push(e);return t.sort()}cycleNextAgent(){const t=this.getActiveAgentIds();if(t.length===0)return null;if(!this._focusedAgentId||!t.includes(this._focusedAgentId))this._focusedAgentId=t[0];else{const e=t.indexOf(this._focusedAgentId);this._focusedAgentId=t[(e+1)%t.length]}return this._focusedAgentId}dispose(){this.store.off("agent:spawn",this.onSpawnBound),this.store.off("agent:update",this.onUpdateBound),this.store.off("agent:idle",this.onIdleBound),this.store.off("agent:shutdown",this.onShutdownBound),this.store.off("state:reset",this.onResetBound),this.store.off("anomaly:alert",this.onAnomalyBound);for(const[,t]of this.agents)t.sprite.destroy();this.agents.clear(),this.lines.destroy(),this.particles.destroy()}getAgentPositions(){const t=[];for(const[e,s]of this.agents)t.push({id:e,x:s.sprite.container.x,y:s.sprite.container.y,colorIndex:this.getDisplayColorIndex(s.state)});return t}getAgentState(t){var e;return(e=this.agents.get(t))==null?void 0:e.state}applyCustomization(t,e,s){const n=this.agents.get(t);if(!n)return;const o=n.state,r=e||o.agentName||ho(o.sessionId);n.sprite.setCustomName(r);const l=s??o.colorIndex,h=ft[l%ft.length];n.sprite.rebuildTextures(h,l,this.app.renderer)}getFocusedAgentPosition(){if(!this._focusedAgentId)return null;const t=this.agents.get(this._focusedAgentId);return t?{x:t.sprite.container.x,y:t.sprite.container.y}:(this._focusedAgentId=null,null)}}function zt(i){return i.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function te(i){return zt(i).replace(/"/g,"&quot;")}function os(i){return"#"+i.toString(16).padStart(6,"0")}function be(i){return i>=1e6?`${(i/1e6).toFixed(1)}M`:i>=1e3?`${(i/1e3).toFixed(1)}K`:`${i}`}function Iu(i,t){const e=i+t;return e>=1e6?`${(e/1e6).toFixed(1)}M tokens`:e>=1e3?`${(e/1e3).toFixed(1)}K tokens`:`${e} tokens`}function wn(i){const t=Math.floor(i/1e3),e=Math.floor(t/3600),s=Math.floor(t%3600/60),n=t%60;return e>0?`${e}h ${s}m`:s>0?`${s}m ${n}s`:`${n}s`}function Lu(i,t){return i.length>t?i.slice(0,t-1)+"…":i}const R1={claude:{label:"CC",color:"#a78bfa",title:"Claude Code"},opencode:{label:"OC",color:"#22d3ee",title:"OpenCode"},pi:{label:"PI",color:"#f59e0b",title:"pi coding agent"},codex:{label:"CX",color:"#10b981",title:"Codex CLI"}};function Bu(i){const t=R1[i];return`<span class="cli-badge" title="${t.title}" style="
251
- background: ${t.color}22;
252
- color: ${t.color};
253
- border: 1px solid ${t.color}44;
254
- padding: 0 3px;
255
- border-radius: 3px;
256
- font-size: 8px;
257
- font-weight: 700;
258
- letter-spacing: 0.5px;
259
- margin-left: 4px;
260
- vertical-align: middle;
261
- ">${t.label}</span>`}class $1{constructor(t){b(this,"store");b(this,"agentListEl");b(this,"filterEl");b(this,"refreshTimer");b(this,"onAgentClick",null);b(this,"_customizationLookup",null);b(this,"currentFilter","all");b(this,"collapsedGroups",new Set);b(this,"renderPending",!1);b(this,"scheduleRender");b(this,"tokenHistory",new Map);b(this,"sparklineSampleTimer");b(this,"_metrics",new Map);b(this,"onAgentUpdate",t=>{let e=this._metrics.get(t.id);if(e||(e={toolTimestamps:[],failCount:0},this._metrics.set(t.id,e)),t.currentTool){const n=Date.now(),o=e.toolTimestamps.length>0?e.toolTimestamps[e.toolTimestamps.length-1]:0;n-o>1e3&&e.toolTimestamps.push(n)}t.lastToolOutcome==="failure"&&e.failCount++;const s=Date.now()-300*1e3;e.toolTimestamps=e.toolTimestamps.filter(n=>n>=s),this.scheduleRender()});this.store=t,this.agentListEl=document.getElementById("agent-list"),this.filterEl=document.createElement("div"),this.filterEl.id="filter-pills",this.agentListEl.parentElement.insertBefore(this.filterEl,this.agentListEl),this.renderFilters(),this.scheduleRender=()=>{this.renderPending||(this.renderPending=!0,requestAnimationFrame(()=>{this.renderPending=!1,this.renderAgents()}))},this.store.on("agent:spawn",this.scheduleRender),this.store.on("agent:update",this.onAgentUpdate),this.store.on("agent:idle",this.scheduleRender),this.store.on("agent:shutdown",this.scheduleRender),this.store.on("state:reset",this.scheduleRender),this.refreshTimer=setInterval(this.scheduleRender,500),this.sparklineSampleTimer=setInterval(()=>this.sampleSparklines(),2e3)}setAgentClickHandler(t){this.onAgentClick=t}setCustomizationLookup(t){this._customizationLookup=t}sampleSparklines(){const t=this.store.getAgents();for(const[e,s]of t){let n=this.tokenHistory.get(e);n||(n={samples:[]},this.tokenHistory.set(e,n)),n.samples.push(s.totalInputTokens+s.totalOutputTokens),n.samples.length>30&&n.samples.shift()}for(const e of this.tokenHistory.keys())t.has(e)||this.tokenHistory.delete(e);for(const e of this._metrics.keys())t.has(e)||this._metrics.delete(e)}toggleGroup(t){this.collapsedGroups.has(t)?this.collapsedGroups.delete(t):this.collapsedGroups.add(t),this.renderAgents()}renderFilters(){const t=[{label:"All",value:"all"},{label:"Active",value:"active"},{label:"Idle",value:"idle"},{label:"Done",value:"done"}],e=Array.from(this.store.getAgents().values()),s=e.filter(c=>c.isDone).length,n=[...new Set(e.map(c=>c.projectName).filter(Boolean))],o=n.length>1,r=typeof this.currentFilter=="string"&&this.currentFilter.startsWith("project:")?this.currentFilter.slice(8):"";this.filterEl.innerHTML=t.map(c=>{const p=c.value==="done"&&s>0?` <span class="filter-badge">${s}</span>`:"";return`<button class="filter-pill${this.currentFilter===c.value?" active":""}" data-filter="${c.value}">${c.label}${p}</button>`}).join("")+`
262
- <select class="filter-zone-select" title="Filter by zone">
263
- <option value="">Zone...</option>
264
- ${se.map(c=>`<option value="${c.id}" ${this.currentFilter===c.id?"selected":""}>${c.icon} ${c.label}</option>`).join("")}
265
- </select>
266
- ${o?`<select class="filter-zone-select filter-project-select" title="Filter by project">
267
- <option value="">Project...</option>
268
- ${n.sort().map(c=>`<option value="project:${te(c)}" ${r===c?"selected":""}>${zt(c)}</option>`).join("")}
269
- </select>`:""}
270
- ${s>0?`<button class="clean-done-btn" title="Remove ${s} done agent${s>1?"s":""}">Clean up (${s})</button>`:""}
271
- `,this.filterEl.querySelectorAll(".filter-pill").forEach(c=>{c.addEventListener("click",()=>{this.currentFilter=c.dataset.filter,this.filterEl.querySelector(".filter-zone-select").value="";const p=this.filterEl.querySelector(".filter-project-select");p&&(p.value=""),this.renderFilters(),this.renderAgents()})});const l=this.filterEl.querySelector(".filter-zone-select:not(.filter-project-select)");l.addEventListener("change",()=>{l.value?this.currentFilter=l.value:this.currentFilter="all";const c=this.filterEl.querySelector(".filter-project-select");c&&(c.value=""),this.renderFilters(),this.renderAgents()});const h=this.filterEl.querySelector(".filter-project-select");h&&h.addEventListener("change",()=>{h.value?this.currentFilter=h.value:this.currentFilter="all",l.value="",this.renderFilters(),this.renderAgents()});const d=this.filterEl.querySelector(".clean-done-btn");d&&d.addEventListener("click",()=>this.cleanDoneAgents())}shortenId(t){return t.length>8?t.slice(0,8):t}roleBadge(t){const s={main:{label:"MAIN",color:"#4a90d9"},subagent:{label:"SUB",color:"#ab47bc"},"team-lead":{label:"LEAD",color:"#ff9800"},"team-member":{label:"MEMBER",color:"#26c6da"}}[t]??{label:t.toUpperCase(),color:"#888"};return`<span style="
272
- background: ${s.color}33;
273
- color: ${s.color};
274
- padding: 1px 6px;
275
- border-radius: 3px;
276
- font-size: 10px;
277
- font-weight: bold;
278
- margin-left: 6px;
279
- ">${s.label}</span>`}filterAgents(t){const e=this.currentFilter;if(typeof e=="string"&&e.startsWith("project:")){const s=e.slice(8);return t.filter(n=>n.projectName===s)}switch(e){case"all":return t;case"active":return t.filter(s=>!s.isIdle&&!s.isDone);case"idle":return t.filter(s=>s.isIdle&&!s.isDone);case"done":return t.filter(s=>s.isDone);default:return t.filter(s=>s.currentZone===e)}}renderAgents(){var m;let t=Array.from(this.store.getAgents().values());const e=t.length;if(t=this.filterAgents(t),t.length===0){if(e===0)this.agentListEl.innerHTML=`
280
- <div class="empty-state">
281
- <div class="empty-icon">
282
- <svg viewBox="0 0 48 48" width="48" height="48" fill="none" stroke="currentColor" stroke-width="1.5">
283
- <rect x="14" y="6" width="20" height="16" rx="3" />
284
- <circle cx="20" cy="14" r="2" fill="currentColor"/>
285
- <circle cx="28" cy="14" r="2" fill="currentColor"/>
286
- <rect x="16" y="24" width="16" height="14" rx="2" />
287
- <rect x="10" y="26" width="6" height="4" rx="1" />
288
- <rect x="32" y="26" width="6" height="4" rx="1" />
289
- <rect x="18" y="38" width="4" height="6" rx="1" />
290
- <rect x="26" y="38" width="4" height="6" rx="1" />
291
- </svg>
292
- </div>
293
- <div class="empty-title">Waiting for agents</div>
294
- <div class="empty-desc">Start a Claude Code session and agents will appear here automatically</div>
295
- </div>`;else{const y=`No ${this.currentFilter} agents (${e} total)`;this.agentListEl.innerHTML=`<div class="empty-state"><div class="empty-desc">${y}</div></div>`}return}t.sort((y,x)=>y.isDone!==x.isDone?y.isDone?1:-1:y.isIdle!==x.isIdle?y.isIdle?1:-1:y.spawnedAt-x.spawnedAt);const s=this.store.getAgents(),n=t.filter(y=>y.role==="subagent"),o=t.filter(y=>y.role!=="subagent"),r=[],l=new Set(o.map(y=>y.id)),h=new Map;for(const y of n)if(y.parentId&&l.has(y.parentId)){let x=h.get(y.parentId);x||(x=[],h.set(y.parentId,x)),x.push(y)}else r.push(y);const d=new Map;for(const y of s.values())y.parentId&&y.role==="subagent"&&d.set(y.parentId,(d.get(y.parentId)??0)+1);const c=new Map,p=[];for(const y of o)if(y.teamName){const x=`${y.rootSessionId}:${y.teamName}`;let w=c.get(x);w||(w=[],c.set(x,w)),w.push(y)}else p.push(y);let g="";for(const[y,x]of c){const w=y.indexOf(":"),k=w>=0?y.slice(w+1):y,E=(m=x[0])==null?void 0:m.rootSessionId;x.sort(($,G)=>$.role==="team-lead"&&G.role!=="team-lead"?-1:$.role!=="team-lead"&&G.role==="team-lead"?1:0);let B=0;for(const $ of s.values())$.teamName===k&&$.rootSessionId===E&&B++;const L=`team:${y}`,H=this.collapsedGroups.has(L);if(g+=`<div class="agent-group${H?" collapsed":""}">`,g+=`<div class="group-header" role="button" tabindex="0" data-group-id="${te(L)}">
296
- <span class="group-chevron">${H?"&#9656;":"&#9662;"}</span>
297
- <span class="group-icon">&#128101;</span>
298
- <span class="group-name">${zt(k)}</span>
299
- <span class="group-count">${B}</span>
300
- </div>`,!H){g+='<div class="group-children">';for(const $ of x)g+=this.renderAgentWithSubs($,h,d);g+="</div>"}g+="</div>"}for(const y of p)g+=this.renderAgentWithSubs(y,h,d);for(const y of r)g+=this.renderCard(y,!0);this.agentListEl.innerHTML=g,this.agentListEl.querySelectorAll(".group-header").forEach(y=>{y.addEventListener("click",()=>{const x=y.dataset.groupId;x&&this.toggleGroup(x)}),y.addEventListener("keydown",x=>{if(x.key==="Enter"||x.key===" "){x.preventDefault();const w=y.dataset.groupId;w&&this.toggleGroup(w)}})}),this.agentListEl.querySelectorAll(".sub-collapse-bar").forEach(y=>{y.addEventListener("click",()=>{const x=y.dataset.groupId;x&&this.toggleGroup(x)})}),this.agentListEl.querySelectorAll(".agent-card[data-agent-id]").forEach(y=>{y.addEventListener("click",()=>{const x=y.dataset.agentId;x&&this.onAgentClick&&this.onAgentClick(x)})}),this.agentListEl.querySelectorAll(".sparkline-canvas").forEach(y=>{const x=y.dataset.agentId;x&&this.drawSparkline(y,x)}),this.agentListEl.querySelectorAll(".agent-sparkline").forEach(y=>{const x=y.dataset.agentId;x&&this.drawToolVelocitySparkline(y,x)})}renderAgentWithSubs(t,e,s,n=!1){const o=e.get(t.id),r=s.get(t.id)??0,l=o&&o.length>0;let h="";if(l){const d=`sub:${t.id}`,c=this.collapsedGroups.has(d);h+=this.renderCard(t,n,0);const p=c?"&#9656;":"&#9662;",g=`${r} subagent${r>1?"s":""}`;if(h+=`<div class="sub-collapse-bar${c?" is-collapsed":""}" data-group-id="${te(d)}">
301
- <span class="sub-collapse-chevron">${p}</span>
302
- <span class="sub-collapse-label">${g}</span>
303
- </div>`,!c){h+='<div class="subagent-group">';for(const m of o)h+=this.renderAgentWithSubs(m,e,s,!0);h+="</div>"}}else h+=this.renderCard(t,n,r);return h}getHealthColor(t){if(t.isDone||t.isIdle)return"#888";const e=this._metrics.get(t.id);if(e&&e.failCount>0){const s=e.toolTimestamps.length;return s>0&&e.failCount/s>.3?"#ef4444":"#eab308"}return"#22c55e"}renderCard(t,e=!1,s=0){var G;const n=(G=this._customizationLookup)==null?void 0:G.call(this,t),o=(n==null?void 0:n.colorIndex)??t.colorIndex,r=ft[o%ft.length],l=os(r.body),h=Zt.get(t.currentZone),d=h?h.label:t.currentZone,c=t.currentTool??"none",p=Iu(t.totalInputTokens,t.totalOutputTokens),g=(n==null?void 0:n.displayName)||t.agentName||ho(t.sessionId),m=e?" agent-card-child":"",y=t.isDone?" agent-card-done":"",x=t.isDone?'<span class="status-badge done">DONE</span>':"",w=s>0?`<span class="sub-count" title="${s} subagent${s>1?"s":""}">${s} sub${s>1?"s":""}</span>`:"",k=t.projectPath?ku(t.projectPath):o,E=os(ft[k%ft.length].body),B=t.projectName?`<span style="
304
- background: ${E}33;
305
- color: ${E};
306
- padding: 1px 5px;
307
- border-radius: 3px;
308
- font-size: 9px;
309
- margin-left: 4px;
310
- ">${zt(t.projectName)}</span>`:"",L=Bu(t.agentType),H=t.isDone?"done":t.isIdle?"idle":"active",$=this.getHealthColor(t);return`<div class="agent-card${m}${y}" data-agent-id="${t.id}" style="border-left: 3px solid ${l};">
311
- <div class="card-top-row">
312
- <div class="name">
313
- <span class="agent-status-dot ${H}"></span>
314
- ${e?'<span class="child-connector">&#8627;</span>':""}${zt(g)}${L}${this.roleBadge(t.role)}${B}${x}${w}
315
- </div>
316
- <div class="card-actions">
317
- <div class="agent-metrics">
318
- <canvas class="agent-sparkline" data-agent-id="${t.id}" data-color-index="${o}" width="60" height="16"></canvas>
319
- <span class="agent-health-dot" style="background: ${$};"></span>
320
- </div>
321
- <canvas class="sparkline-canvas" data-agent-id="${t.id}" width="60" height="20"></canvas>
322
- </div>
323
- </div>
324
- ${t.taskDescription?`<div class="task-desc" title="${te(t.taskDescription)}">${zt(Lu(t.taskDescription,48))}</div>`:""}
325
- <div class="zone">${(h==null?void 0:h.icon)??""} ${d} · ${c}</div>
326
- <div class="card-tokens">${t.contextTokens>0?(()=>{const tt=Math.round(t.contextTokens/2e5*100),Z=tt>=90?"#ef4444":tt>=75?"#f97316":tt>=50?"#eab308":"#22c55e",X=t.contextTokens-t.contextCacheTokens,Q=ot=>ot>=1e3?`${Math.round(ot/1e3)}k`:`${ot}`;return`<span class="detail-ctx-bar" title="Context window: ${tt}% full&#10;${X.toLocaleString()} new + ${t.contextCacheTokens.toLocaleString()} cached = ${t.contextTokens.toLocaleString()} / 200,000"><span class="detail-ctx-breakdown">${Q(X)} new · ${Q(t.contextCacheTokens)} cached</span><span class="detail-ctx-track"><span class="detail-ctx-fill" style="width:${tt}%;background:${Z}"></span></span><span class="detail-ctx-label" style="color:${Z}">${tt}%</span></span>`})():`<span>${p}</span>`}</div>
327
- </div>`}getToolVelocityBars(t){const e=this._metrics.get(t);if(!e||e.toolTimestamps.length===0)return[];const s=Date.now(),n=3e4,o=10,r=new Array(o).fill(0);for(const l of e.toolTimestamps){const h=s-l,d=Math.floor(h/n);d>=0&&d<o&&r[o-1-d]++}return r}drawToolVelocitySparkline(t,e){const s=t.getContext("2d");if(!s)return;const n=t.width,o=t.height;s.clearRect(0,0,n,o);const r=this.getToolVelocityBars(e);if(r.length===0)return;const l=Math.max(...r,1),h=10,d=Math.floor(n/h)-1,c=1,p=t.dataset.colorIndex,g=p?parseInt(p,10):0,m=ft[g%ft.length],y=os(m.body);for(let x=0;x<h;x++){const w=r[x]??0,k=Math.max(w>0?2:0,Math.round(w/l*(o-2))),E=x*(d+c),B=o-k;s.fillStyle=y,s.globalAlpha=w>0?.8:.15,s.fillRect(E,B,d,k)}s.globalAlpha=1}drawSparkline(t,e){const s=t.getContext("2d");if(!s)return;const n=this.tokenHistory.get(e);if(!n||n.samples.length<2)return;const o=t.width,r=t.height;s.clearRect(0,0,o,r);const l=[];for(let c=1;c<n.samples.length;c++)l.push(Math.max(0,n.samples[c]-n.samples[c-1]));const h=Math.max(...l,1),d=o/Math.max(l.length-1,1);s.beginPath(),s.moveTo(0,r);for(let c=0;c<l.length;c++){const p=c*d,g=r-l[c]/h*(r-2)-1;s.lineTo(p,g)}s.lineTo((l.length-1)*d,r),s.closePath(),s.fillStyle="rgba(74, 222, 128, 0.15)",s.fill(),s.beginPath();for(let c=0;c<l.length;c++){const p=c*d,g=r-l[c]/h*(r-2)-1;c===0?s.moveTo(p,g):s.lineTo(p,g)}s.strokeStyle="#4ade80",s.lineWidth=1.5,s.stroke()}async cleanDoneAgents(){try{(await fetch("/api/agents/clean-done",{method:"POST"})).ok&&(this.renderFilters(),this.renderAgents())}catch(t){console.error("Failed to clean done agents:",t)}}dispose(){clearInterval(this.refreshTimer),clearInterval(this.sparklineSampleTimer),this.store.off("agent:spawn",this.scheduleRender),this.store.off("agent:update",this.onAgentUpdate),this.store.off("agent:idle",this.scheduleRender),this.store.off("agent:shutdown",this.scheduleRender),this.store.off("state:reset",this.scheduleRender)}}class D1{constructor(t){b(this,"panelEl");b(this,"store");b(this,"selectedAgentId",null);b(this,"entries",[]);b(this,"historyListener",null);b(this,"onUpdateBound");b(this,"onIdleBound");b(this,"onShutdownBound");b(this,"_onCustomize",null);b(this,"_customizationLookup",null);b(this,"tokenSamples",[]);b(this,"toolTimestamps",[]);b(this,"sparklineTimer",null);this.store=t,this.panelEl=document.createElement("div"),this.panelEl.id="agent-detail-panel",this.panelEl.innerHTML=`
328
- <div class="detail-header">
329
- <div class="detail-header-buttons">
330
- <button id="detail-back" title="Back to agent list">
331
- <svg viewBox="0 0 24 24" width="14" height="14" fill="currentColor"><path d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z"/></svg>
332
- Back
333
- </button>
334
- <span class="detail-btn-spacer"></span>
335
- <button id="detail-customize" title="Customize agent name and color">Edit</button>
336
- <button id="detail-kill" title="Shut down this agent permanently">Kill</button>
337
- </div>
338
- <div id="detail-card"></div>
339
- </div>
340
- <div id="detail-info"></div>
341
- <div class="detail-section-title">Activity Feed</div>
342
- <div id="detail-feed"></div>
343
- `;const e=document.getElementById("right-panel");e?e.appendChild(this.panelEl):document.body.appendChild(this.panelEl),this.panelEl.querySelector("#detail-back").addEventListener("click",()=>this.close()),this.panelEl.querySelector("#detail-kill").addEventListener("click",()=>this.showKillConfirm()),this.panelEl.querySelector("#detail-customize").addEventListener("click",()=>{if(this.selectedAgentId&&this._onCustomize){const s=this.store.getAgent(this.selectedAgentId);s&&this._onCustomize(s)}}),this.historyListener=s=>{s.agentId===this.selectedAgentId&&(this.entries=s.entries,this.renderFeed())},this.store.on("agent:history",this.historyListener),this.onUpdateBound=s=>{if(s.id===this.selectedAgentId){if(this.renderCardStats(s),this.renderInfo(s),s.currentTool){const n=Date.now(),o=this.toolTimestamps.length>0?this.toolTimestamps[this.toolTimestamps.length-1]:0;n-o>1e3&&this.toolTimestamps.push(n);const r=n-300*1e3;this.toolTimestamps=this.toolTimestamps.filter(l=>l>=r)}this.drawSparklines(s)}},this.onIdleBound=s=>{s.id===this.selectedAgentId&&this.renderCardStats(s)},this.onShutdownBound=s=>{s===this.selectedAgentId&&this.close()},this.store.on("agent:update",this.onUpdateBound),this.store.on("agent:idle",this.onIdleBound),this.store.on("agent:shutdown",this.onShutdownBound)}setCustomizeHandler(t){this._onCustomize=t}setCustomizationLookup(t){this._customizationLookup=t}getDisplayName(t){return this._customizationLookup?this._customizationLookup(t).displayName:t.agentName||t.projectName||t.id.slice(0,8)}getDisplayColorIndex(t){return this._customizationLookup?this._customizationLookup(t).colorIndex:t.colorIndex}open(t){this.selectedAgentId=t,this.entries=[],this.tokenSamples=[],this.toolTimestamps=[],this.panelEl.classList.add("open");const e=this.store.getAgent(t);e&&(this.renderHeader(e),this.renderInfo(e),this.tokenSamples.push(e.totalInputTokens+e.totalOutputTokens)),this.sparklineTimer&&clearInterval(this.sparklineTimer),this.sparklineTimer=setInterval(()=>this.sampleSparkline(),2e3),this.store.requestHistory(t)}close(){this.selectedAgentId=null,this.panelEl.classList.remove("open"),this.sparklineTimer&&(clearInterval(this.sparklineTimer),this.sparklineTimer=null)}isOpen(){return this.selectedAgentId!==null}get currentAgentId(){return this.selectedAgentId}refreshHeader(t){if(!this.selectedAgentId)return;const e=this.store.getAgent(this.selectedAgentId);e&&this.renderHeader(e,t)}renderHeader(t,e){const s=this.getDisplayColorIndex(t),n=ft[s%ft.length],o=os(n.body),r=e||this.getDisplayName(t),l=t.isDone?"done":t.isIdle?"idle":"active",h=t.isDone?"Agent finished":t.isIdle?"Agent is idle":"Agent is actively working",c={main:{label:"MAIN",color:"#4a90d9"},subagent:{label:"SUB",color:"#ab47bc"},"team-lead":{label:"LEAD",color:"#ff9800"},"team-member":{label:"MEMBER",color:"#26c6da"}}[t.role]??{label:t.role.toUpperCase(),color:"#888"},p=`<span class="detail-role-badge" title="Agent role: ${c.label}" style="background:${c.color}33;color:${c.color};">${c.label}</span>`;let g="";if(t.projectName){const x=t.projectPath?ku(t.projectPath):s,w=os(ft[x%ft.length].body);g=`<span class="detail-project-badge" title="Project: ${te(t.projectName)}" style="background:${w}33;color:${w};">${zt(t.projectName)}</span>`}const m=t.isDone?'<span class="detail-done-badge" title="Agent has finished">DONE</span>':"",y=this.panelEl.querySelector("#detail-card");y.innerHTML=`
344
- <div class="detail-card-inner" style="border-left: 3px solid ${o};">
345
- <div class="detail-card-top">
346
- <div class="detail-card-name">
347
- <span class="agent-status-dot ${l}" title="${h}"></span>
348
- ${zt(r)}${p}${g}${m}
349
- </div>
350
- <div class="detail-card-actions">
351
- <canvas class="detail-velocity-canvas" width="60" height="16" title="Tool call frequency (last 5 min)"></canvas>
352
- <span class="detail-health-dot" title="Agent health indicator"></span>
353
- <canvas class="detail-sparkline-canvas" width="60" height="20" title="Token usage rate over time"></canvas>
354
- </div>
355
- </div>
356
- ${t.taskDescription?`<div class="detail-card-task" title="${te(t.taskDescription)}">${zt(Lu(t.taskDescription,80))}</div>`:""}
357
- <div class="detail-card-zone" id="detail-zone-line"></div>
358
- <div class="detail-card-tokens" id="detail-token-line"></div>
359
- </div>
360
- `,this.renderCardStats(t)}renderCardStats(t){const e=Zt.get(t.currentZone),s=(e==null?void 0:e.icon)??"",n=(e==null?void 0:e.label)??t.currentZone,o=t.currentTool??"none",r=Iu(t.totalInputTokens,t.totalOutputTokens),l=this.panelEl.querySelector("#detail-zone-line");l&&(l.innerHTML=`<span title="Current activity zone">${s} ${n}</span> <span class="detail-card-sep" title="Current tool">&middot;</span> <span class="detail-card-tool" title="Current tool: ${te(o)}">${zt(o)}</span>`);const h=this.panelEl.querySelector("#detail-token-line");if(h){const c=t.contextTokens>0?Math.round(t.contextTokens/2e5*100):0,p=c>=90?"#ef4444":c>=75?"#f97316":c>=50?"#eab308":"#22c55e",g=t.contextTokens-t.contextCacheTokens,m=x=>x>=1e3?`${Math.round(x/1e3)}k`:`${x}`,y=`Context window: ${c}% full
361
- ${g.toLocaleString()} new + ${t.contextCacheTokens.toLocaleString()} cached = ${t.contextTokens.toLocaleString()} / 200,000`;h.innerHTML=c>0?`<span class="detail-ctx-bar" title="${y}">
362
- <span class="detail-ctx-breakdown">${m(g)} new · ${m(t.contextCacheTokens)} cached</span>
363
- <span class="detail-ctx-track"><span class="detail-ctx-fill" style="width:${c}%;background:${p}"></span></span>
364
- <span class="detail-ctx-label" style="color:${p}">${c}%</span>
365
- </span>`:`<span title="Total token usage">${r}</span>`}const d=this.panelEl.querySelector(".detail-health-dot");if(d){const c=t.isDone||t.isIdle?"#888":"#22c55e";d.style.background=c,d.title=t.isDone?"Agent finished":t.isIdle?"Agent idle":"Agent healthy"}}renderInfo(t){const e=this.panelEl.querySelector("#detail-info"),s=[];s.push(this.infoRow("Uptime",wn(Date.now()-t.spawnedAt),"How long this agent has been running")),s.push(this.infoRow("CLI",Bu(t.agentType),"Agent CLI source")),t.model&&s.push(this.infoRow("Model",`<code>${te(t.model)}</code>`,"AI model powering this agent")),s.push(this.infoRow("Session",`<code class="detail-session-id" title="Click to copy full session ID">${t.sessionId.slice(0,16)}…</code>
366
- <button class="detail-copy-btn" data-copy="${te(t.sessionId)}" title="Copy session ID to clipboard">
367
- <svg viewBox="0 0 24 24" width="12" height="12" fill="currentColor"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg>
368
- </button>`,"Unique session identifier")),t.teamName&&s.push(this.infoRow("Team",zt(t.teamName),"Team this agent belongs to")),t.gitBranch&&s.push(this.infoRow("Branch",`<code>${te(t.gitBranch)}</code>`,"Git branch this agent is working on"));const n=t.recentDiffs?new Set(t.recentDiffs.map(l=>l.filePath)).size:0,o=t.recentFiles?t.recentFiles.length:0;if(o>0||n>0){const l=[];o>0&&l.push(`${o} touched`),n>0&&l.push(`${n} edited`),s.push(this.infoRow("Files",l.join(", "),"Files this agent has read or modified"))}if(t.parentId){const l=this.store.getAgent(t.parentId),h=l?this.getDisplayName(l):t.parentId.slice(0,10);s.push(this.infoRow("Parent",`<a href="#" class="detail-link" data-agent-id="${te(t.parentId)}" title="Navigate to parent agent">${zt(h)}</a>`,"The agent that spawned this one"))}const r=Array.from(this.store.getAgents().values()).filter(l=>l.parentId===t.id);if(r.length>0){const l=r.map(h=>{const d=this.getDisplayName(h);return`<a href="#" class="detail-link" data-agent-id="${te(h.id)}" title="Navigate to subagent">${zt(d)}</a>`});s.push(this.infoRow("Subagents",l.join(", "),"Child agents spawned by this agent"))}e.innerHTML=s.join(""),e.querySelectorAll(".detail-copy-btn").forEach(l=>{l.addEventListener("click",h=>{h.stopPropagation();const d=l.dataset.copy;d&&(navigator.clipboard.writeText(d).catch(()=>{}),l.classList.add("copied"),setTimeout(()=>l.classList.remove("copied"),1200))})}),e.querySelectorAll(".detail-session-id").forEach(l=>{l.addEventListener("click",()=>{navigator.clipboard.writeText(t.sessionId).catch(()=>{})})}),e.querySelectorAll(".detail-link").forEach(l=>{l.addEventListener("click",h=>{h.preventDefault();const d=l.dataset.agentId;d&&this.open(d)})})}infoRow(t,e,s){return`<div class="detail-info-row" title="${te(s)}">
369
- <span class="detail-info-label">${t}</span>
370
- <span class="detail-info-value">${e}</span>
371
- </div>`}sampleSparkline(){if(!this.selectedAgentId)return;const t=this.store.getAgent(this.selectedAgentId);t&&(this.tokenSamples.push(t.totalInputTokens+t.totalOutputTokens),this.tokenSamples.length>30&&this.tokenSamples.shift(),this.drawSparklines(t))}drawSparklines(t){const e=this.panelEl.querySelector(".detail-sparkline-canvas");if(e&&this.tokenSamples.length>=2){const n=e.getContext("2d");if(n){const o=e.width,r=e.height;n.clearRect(0,0,o,r);const l=[];for(let c=1;c<this.tokenSamples.length;c++)l.push(Math.max(0,this.tokenSamples[c]-this.tokenSamples[c-1]));const h=Math.max(...l,1),d=o/Math.max(l.length-1,1);n.beginPath(),n.moveTo(0,r);for(let c=0;c<l.length;c++)n.lineTo(c*d,r-l[c]/h*(r-2)-1);n.lineTo((l.length-1)*d,r),n.closePath(),n.fillStyle="rgba(74, 222, 128, 0.15)",n.fill(),n.beginPath();for(let c=0;c<l.length;c++){const p=c*d,g=r-l[c]/h*(r-2)-1;c===0?n.moveTo(p,g):n.lineTo(p,g)}n.strokeStyle="#4ade80",n.lineWidth=1.5,n.stroke()}}const s=this.panelEl.querySelector(".detail-velocity-canvas");if(s){const n=s.getContext("2d");if(!n)return;const o=s.width,r=s.height;n.clearRect(0,0,o,r);const l=Date.now(),h=3e4,d=10,c=new Array(d).fill(0);for(const w of this.toolTimestamps){const k=Math.floor((l-w)/h);k>=0&&k<d&&c[d-1-k]++}const p=Math.max(...c,1),g=Math.floor(o/d)-1,m=this.getDisplayColorIndex(t),y=ft[m%ft.length],x=os(y.body);for(let w=0;w<d;w++){const k=c[w]??0,E=Math.max(k>0?2:0,Math.round(k/p*(r-2)));n.fillStyle=x,n.globalAlpha=k>0?.8:.15,n.fillRect(w*(g+1),r-E,g,E)}n.globalAlpha=1}}renderFeed(){const t=this.panelEl.querySelector("#detail-feed");if(this.entries.length===0){t.innerHTML='<div class="feed-empty">No activity recorded yet</div>';return}const e=[...this.entries].reverse();t.innerHTML=e.map(s=>this.renderEntry(s)).join(""),t.scrollTop=0}relativePath(t){if(!this.selectedAgentId)return t;const e=this.store.getAgent(this.selectedAgentId);if(!(e!=null&&e.projectPath))return t;const s=e.projectPath.replace(/\\/g,"/").replace(/\/$/,"")+"/",n=t.replace(/\\/g,"/");return n.startsWith(s)?n.slice(s.length):n}shortenArgs(t){if(!this.selectedAgentId)return t;const e=this.store.getAgent(this.selectedAgentId);if(!(e!=null&&e.projectPath))return t;const s=e.projectPath.replace(/\\/g,"/").replace(/\/$/,"")+"/";return t.replace(/\\/g,"/").split(s).join("")}renderEntry(t){const s=`<span class="feed-time">${this.formatTime(t.timestamp)}</span>`;switch(t.kind){case"tool":{const n=t.toolArgs?` <span class="feed-args">${te(this.shortenArgs(t.toolArgs))}</span>`:"";return`<div class="feed-entry feed-tool">${s} <span class="feed-icon">&#128295;</span> <span class="feed-tool-name">${te(t.tool??"unknown")}</span>${n}</div>`}case"text":{const n=t.text?this.shortenArgs(t.text):"";return`<div class="feed-entry feed-text">${s} <span class="feed-icon">&#128172;</span> ${te(n)}</div>`}case"zone-change":{const n=Zt.get(t.prevZone),o=Zt.get(t.zone);return`<div class="feed-entry feed-zone">${s} <span class="feed-icon">&#128694;</span> ${(n==null?void 0:n.icon)??""} ${(n==null?void 0:n.label)??t.prevZone} &rarr; ${(o==null?void 0:o.icon)??""} ${(o==null?void 0:o.label)??t.zone}</div>`}case"spawn":return`<div class="feed-entry feed-spawn">${s} <span class="feed-icon">&#9889;</span> Agent spawned</div>`;case"idle":return`<div class="feed-entry feed-idle">${s} <span class="feed-icon">&#9749;</span> Went idle</div>`;case"shutdown":return`<div class="feed-entry feed-shutdown">${s} <span class="feed-icon">&#128721;</span> Agent shut down</div>`;case"tokens":return`<div class="feed-entry feed-tokens">${s} <span class="feed-icon">&#127916;</span> +${be(t.inputTokens??0)} in / +${be(t.outputTokens??0)} out</div>`;default:return""}}showKillConfirm(){var n;if(!this.selectedAgentId)return;const t=this.store.getAgent(this.selectedAgentId),e=t?this.getDisplayName(t):"this agent";(n=this.panelEl.querySelector(".kill-confirm-overlay"))==null||n.remove();const s=document.createElement("div");s.className="kill-confirm-overlay",s.innerHTML=`
372
- <div class="kill-confirm-box">
373
- <div class="kill-confirm-title">Kill Agent</div>
374
- <div class="kill-confirm-msg">Are you sure you want to shut down <strong>${te(e)}</strong>? This cannot be undone.</div>
375
- <div class="kill-confirm-actions">
376
- <button class="kill-confirm-cancel">Cancel</button>
377
- <button class="kill-confirm-yes">Kill Agent</button>
378
- </div>
379
- </div>
380
- `,this.panelEl.appendChild(s),s.querySelector(".kill-confirm-cancel").addEventListener("click",()=>s.remove()),s.querySelector(".kill-confirm-yes").addEventListener("click",async()=>{s.remove(),await this.killAgent()}),s.addEventListener("click",o=>{o.target===s&&s.remove()})}async killAgent(){if(this.selectedAgentId)try{(await fetch(`/api/agents/${this.selectedAgentId}/shutdown`,{method:"POST"})).ok&&this.close()}catch(t){console.error("Failed to kill agent:",t)}}formatTime(t){return new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}dispose(){this.sparklineTimer&&clearInterval(this.sparklineTimer),this.historyListener&&this.store.off("agent:history",this.historyListener),this.store.off("agent:update",this.onUpdateBound),this.store.off("agent:idle",this.onIdleBound),this.store.off("agent:shutdown",this.onShutdownBound),this.panelEl.remove()}}function z1(i){switch(i.type){case"agent:spawn":case"agent:shutdown":return"lifecycle";case"agent:idle":return"idle";case"agent:update":return i.agent.currentTool?"tool":"zone"}}function Lc(i){switch(i.type){case"agent:spawn":return"#a855f7";case"agent:shutdown":return"#f87171";case"agent:idle":return"#6b7280";case"agent:update":return"#"+ft[i.agent.colorIndex%ft.length].body.toString(16).padStart(6,"0")}}function Ru(i){return i<300*1e3?60*1e3:i<900*1e3?120*1e3:300*1e3}function F1(i,t,e,s,n,o){e.fillStyle="rgba(255,255,255,0.15)",e.font="9px monospace",e.textAlign="center";const r=Ru(o),l=Math.ceil(s/r)*r;for(let h=l;h<=n;h+=r){const d=(h-s)/o*i;e.fillRect(d,0,1,3);const c=new Date(h);e.fillText(c.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),d,t-1)}}function Bc(i,t,e,s,n,o,r,l){if(o)e.strokeStyle="#4ade80",e.lineWidth=2,e.beginPath(),e.moveTo(i-1,0),e.lineTo(i-1,t),e.stroke(),l.textContent="LIVE";else{const h=r*i;e.strokeStyle="#e94560",e.lineWidth=2,e.beginPath(),e.moveTo(h,0),e.lineTo(h,t),e.stroke();const d=s+r*n;l.textContent=new Date(d).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}}class N1{constructor(t,e,s){b(this,"activeFilters",new Set(["tool","zone","idle","lifecycle"]));b(this,"visibleAgents",new Set);b(this,"agentFilterContainer");b(this,"customizationLookup",null);b(this,"onChanged");b(this,"getTimeline");this.agentFilterContainer=t,this.getTimeline=e,this.onChanged=s}setCustomizationLookup(t){this.customizationLookup=t}isEventVisible(t,e){return this.activeFilters.has(e)}isAgentVisible(t){return this.visibleAgents.size===0||this.visibleAgents.has(t)}toggleCategory(t,e){this.activeFilters.has(t)?(this.activeFilters.delete(t),e.classList.remove("active")):(this.activeFilters.add(t),e.classList.add("active")),this.onChanged()}getUniqueAgents(){var s;const t=this.getTimeline(),e=new Map;for(const n of t)if(!e.has(n.agent.id)){const o=(s=this.customizationLookup)==null?void 0:s.call(this,n.agent);e.set(n.agent.id,{id:n.agent.id,name:(o==null?void 0:o.displayName)||n.agent.agentName||n.agent.projectName||n.agent.id.slice(0,8),colorIndex:(o==null?void 0:o.colorIndex)??n.agent.colorIndex})}return Array.from(e.values())}getSwimLaneAgents(){const t=this.getUniqueAgents();return this.visibleAgents.size===0?t:t.filter(e=>this.visibleAgents.has(e.id))}updateAgentFilters(){const t=this.getUniqueAgents();if(this.agentFilterContainer.innerHTML="",t.length!==0)for(const e of t){const n="#"+ft[e.colorIndex%ft.length].body.toString(16).padStart(6,"0"),o=document.createElement("button");o.className="tl-agent-pill",(this.visibleAgents.size===0||this.visibleAgents.has(e.id))&&o.classList.add("active"),o.innerHTML=`<span class="tl-agent-dot" style="background:${n}"></span>${e.name}`,o.title=`Toggle ${e.name}`,o.addEventListener("click",()=>{this.toggleAgentFilter(e.id)}),this.agentFilterContainer.appendChild(o)}}toggleAgentFilter(t){const e=this.getUniqueAgents();if(this.visibleAgents.size===0){if(e.length<=1)return;this.visibleAgents.clear(),this.visibleAgents.add(t)}else this.visibleAgents.has(t)?(this.visibleAgents.delete(t),this.visibleAgents.size):(this.visibleAgents.add(t),this.visibleAgents.size>=e.length&&this.visibleAgents.clear());this.updateAgentFilters(),this.onChanged()}}class G1{constructor(t){b(this,"el");b(this,"store");b(this,"canvas");b(this,"ctx");b(this,"playBtn");b(this,"liveBtn");b(this,"timeLabel");b(this,"expandBtn");b(this,"liveRenderTimer",null);b(this,"isLive",!0);b(this,"isPlaying",!1);b(this,"playbackPosition",0);b(this,"playbackSpeed",1);b(this,"lastFrameTime",0);b(this,"animId",null);b(this,"expanded",!1);b(this,"filter");b(this,"filterContainer");b(this,"swimLabelsEl");b(this,"trackWrapper");b(this,"_customizationLookup",null);b(this,"resizeHandler",()=>this.resizeCanvas());b(this,"onTimelineBound");b(this,"onSpawnBound");b(this,"onShutdownBound");b(this,"replayAgents",new Map);b(this,"onReplayState",null);this.store=t,this.el=document.createElement("div"),this.el.id="timeline-bar",this.el.innerHTML=`
381
- <div class="timeline-top-bar">
382
- <div class="timeline-controls">
383
- <button id="timeline-play" title="Play/Pause">&#9654;</button>
384
- <button id="timeline-live" class="active" title="Jump to Live">LIVE</button>
385
- <span id="timeline-time">--:--</span>
386
- <span id="timeline-speed" title="Click to change speed">1x</span>
387
- </div>
388
- <div class="timeline-filters">
389
- <button class="tl-filter-pill active" data-category="tool" title="Tool calls">
390
- <span class="tl-filter-icon">&#128295;</span> Tools
391
- </button>
392
- <button class="tl-filter-pill active" data-category="zone" title="Zone changes">
393
- <span class="tl-filter-icon">&#127970;</span> Zones
394
- </button>
395
- <button class="tl-filter-pill active" data-category="idle" title="Idle events">
396
- <span class="tl-filter-icon">&#9749;</span> Idle
397
- </button>
398
- <button class="tl-filter-pill active" data-category="lifecycle" title="Spawn / Shutdown">
399
- <span class="tl-filter-icon">&#11088;</span> Life
400
- </button>
401
- </div>
402
- <div class="timeline-agent-filters"></div>
403
- <button class="timeline-expand-btn" title="Expand swim lanes">&#9650;</button>
404
- </div>
405
- <div class="timeline-track" style="position:relative;">
406
- <div class="timeline-swim-labels"></div>
407
- <canvas id="timeline-canvas"></canvas>
408
- </div>
409
- `,(document.getElementById("canvas-container")??document.getElementById("app")).appendChild(this.el),this.canvas=this.el.querySelector("#timeline-canvas"),this.ctx=this.canvas.getContext("2d"),this.playBtn=this.el.querySelector("#timeline-play"),this.liveBtn=this.el.querySelector("#timeline-live"),this.timeLabel=this.el.querySelector("#timeline-time"),this.expandBtn=this.el.querySelector(".timeline-expand-btn"),this.filterContainer=this.el.querySelector(".timeline-filters");const e=this.el.querySelector(".timeline-agent-filters");this.swimLabelsEl=this.el.querySelector(".timeline-swim-labels"),this.trackWrapper=this.el.querySelector(".timeline-track");const s=this.el.querySelector("#timeline-speed");this.filter=new N1(e,()=>this.store.getTimeline(),()=>this.render()),this.resizeCanvas(),window.addEventListener("resize",this.resizeHandler),this.canvas.addEventListener("mousedown",n=>this.onTrackClick(n)),this.canvas.addEventListener("mousemove",n=>{n.buttons===1&&this.onTrackClick(n)}),this.playBtn.addEventListener("click",()=>{this.isLive&&(this.isLive=!1,this.liveBtn.classList.remove("active"),this.playbackPosition=1),this.isPlaying=!this.isPlaying,this.playBtn.innerHTML=this.isPlaying?"&#9646;&#9646;":"&#9654;",this.isPlaying?(this.lastFrameTime=performance.now(),this.startPlayback()):this.stopPlayback()}),this.liveBtn.addEventListener("click",()=>this.goLive()),s.addEventListener("click",()=>{const n=[.5,1,2,4,8],o=n.indexOf(this.playbackSpeed);this.playbackSpeed=n[(o+1)%n.length],s.textContent=`${this.playbackSpeed}x`}),this.expandBtn.addEventListener("click",()=>this.toggleExpanded()),this.filterContainer.querySelectorAll(".tl-filter-pill").forEach(n=>{n.addEventListener("click",()=>{const o=n.dataset.category;this.filter.toggleCategory(o,n)})}),this.onTimelineBound=()=>{this.filter.updateAgentFilters(),this.render()},this.store.on("timeline:snapshot",this.onTimelineBound),this.onSpawnBound=()=>this.filter.updateAgentFilters(),this.onShutdownBound=()=>this.filter.updateAgentFilters(),this.store.on("agent:spawn",this.onSpawnBound),this.store.on("agent:shutdown",this.onShutdownBound),this.liveRenderTimer=setInterval(()=>{this.isLive&&this.render()},1e3)}setCustomizationLookup(t){this._customizationLookup=t,this.filter.setCustomizationLookup(t)}setReplayCallback(t){this.onReplayState=t}dispose(){this.liveRenderTimer&&clearInterval(this.liveRenderTimer),this.animId&&cancelAnimationFrame(this.animId),window.removeEventListener("resize",this.resizeHandler),this.store.off("timeline:snapshot",this.onTimelineBound),this.store.off("agent:spawn",this.onSpawnBound),this.store.off("agent:shutdown",this.onShutdownBound),this.el.remove()}toggleExpanded(){this.expanded=!this.expanded,this.expanded?(this.el.classList.add("expanded"),this.expandBtn.classList.add("active"),this.expandBtn.innerHTML="&#9660;",this.expandBtn.title="Collapse swim lanes"):(this.el.classList.remove("expanded"),this.expandBtn.classList.remove("active"),this.expandBtn.innerHTML="&#9650;",this.expandBtn.title="Expand swim lanes"),this.filter.updateAgentFilters(),requestAnimationFrame(()=>{this.resizeCanvas()})}resizeCanvas(){const e=this.canvas.parentElement.getBoundingClientRect();this.canvas.width=e.width*window.devicePixelRatio,this.canvas.height=e.height*window.devicePixelRatio,this.canvas.style.width=`${e.width}px`,this.canvas.style.height=`${e.height}px`,this.ctx.setTransform(1,0,0,1,0,0),this.ctx.scale(window.devicePixelRatio,window.devicePixelRatio),this.render()}getTimeRange(){const t=this.store.getTimeline();if(t.length===0){const e=Date.now();return{start:e-6e4,end:e}}return{start:t[0].timestamp,end:Math.max(t[t.length-1].timestamp,Date.now())}}render(){const t=this.canvas.width/window.devicePixelRatio,e=this.canvas.height/window.devicePixelRatio,s=this.ctx;s.clearRect(0,0,t,e),this.expanded?this.renderExpanded(t,e,s):this.renderCompact(t,e,s)}renderCompact(t,e,s){this.swimLabelsEl.style.display="none",this.canvas.style.paddingLeft="0";const n=this.store.getTimeline(),{start:o,end:r}=this.getTimeRange(),l=r-o||1;s.fillStyle="rgba(255,255,255,0.04)",s.fillRect(0,4,t,e-8);for(const h of n){const d=(h.timestamp-o)/l*t,c=Lc(h);s.fillStyle=c,h.type==="agent:spawn"||h.type==="agent:shutdown"?s.fillRect(d-1,2,3,e-4):(s.globalAlpha=.6,s.fillRect(d,e/2-2,2,4),s.globalAlpha=1)}F1(t,e,s,o,r,l),Bc(t,e,s,o,l,this.isLive,this.playbackPosition,this.timeLabel)}renderExpanded(t,e,s){const o=this.filter.getSwimLaneAgents(),r=this.store.getTimeline(),{start:l,end:h}=this.getTimeRange(),d=h-l||1,c=t-60,p=60;if(o.length===0){this.swimLabelsEl.style.display="none",this.canvas.style.paddingLeft="0",s.fillStyle="rgba(255,255,255,0.04)",s.fillRect(0,4,t,e-8),s.fillStyle="#555",s.font="11px Inter, sans-serif",s.textAlign="center",s.fillText("No agent activity yet",t/2,e/2+4),Bc(t,e,s,l,d,this.isLive,this.playbackPosition,this.timeLabel);return}const m=e-14,y=Math.max(14,Math.min(28,m/o.length)),x=y*o.length,w=new Map;o.forEach((L,H)=>w.set(L.id,H)),this.swimLabelsEl.style.display="flex",this.swimLabelsEl.innerHTML="";for(const L of o){const $="#"+ft[L.colorIndex%ft.length].body.toString(16).padStart(6,"0"),G=document.createElement("div");G.className="swim-label",G.style.height=`${y}px`,G.style.color=$,G.textContent=L.name,this.swimLabelsEl.appendChild(G)}for(let L=0;L<o.length;L++){const H=L*y;s.fillStyle=L%2===0?"rgba(255,255,255,0.02)":"rgba(255,255,255,0.04)",s.fillRect(p,H,c,y),L>0&&(s.strokeStyle="rgba(255,255,255,0.04)",s.lineWidth=1,s.beginPath(),s.moveTo(p,H),s.lineTo(t,H),s.stroke())}s.fillStyle="rgba(14, 16, 32, 0.8)",s.fillRect(0,0,60,x);for(const L of r){const H=z1(L);if(!this.filter.isEventVisible(L,H))continue;const $=w.get(L.agent.id);if($===void 0)continue;const G=p+(L.timestamp-l)/d*c,tt=$*y,Z=Lc(L);s.fillStyle=Z;const X=tt+y/2;L.type==="agent:spawn"||L.type==="agent:shutdown"?s.fillRect(G-1,tt+1,3,y-2):L.type==="agent:idle"?(s.globalAlpha=.5,s.beginPath(),s.moveTo(G,X-3),s.lineTo(G+3,X),s.lineTo(G,X+3),s.lineTo(G-3,X),s.closePath(),s.fill(),s.globalAlpha=1):(s.globalAlpha=.7,s.beginPath(),s.arc(G,X,2.5,0,Math.PI*2),s.fill(),s.globalAlpha=1)}const k=x;s.fillStyle="rgba(255,255,255,0.15)",s.font="9px monospace",s.textAlign="center";const E=Ru(d),B=Math.ceil(l/E)*E;for(let L=B;L<=h;L+=E){const H=p+(L-l)/d*c;s.fillRect(H,k,1,3);const $=new Date(L);s.fillText($.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),H,k+12)}if(this.isLive)s.strokeStyle="#4ade80",s.lineWidth=2,s.beginPath(),s.moveTo(t-1,0),s.lineTo(t-1,e),s.stroke(),this.timeLabel.textContent="LIVE";else{const L=p+this.playbackPosition*c;s.strokeStyle="#e94560",s.lineWidth=2,s.beginPath(),s.moveTo(L,0),s.lineTo(L,e),s.stroke();const H=l+this.playbackPosition*d;this.timeLabel.textContent=new Date(H).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}}onTrackClick(t){const e=this.canvas.getBoundingClientRect();let s=t.clientX-e.left;if(this.expanded){const o=e.width-60;if(s=s-60,s<0)return;const r=Math.max(0,Math.min(1,s/o));this.isLive=!1,this.liveBtn.classList.remove("active"),this.playbackPosition=r}else{const n=Math.max(0,Math.min(1,s/e.width));this.isLive=!1,this.liveBtn.classList.remove("active"),this.playbackPosition=n}this.isPlaying=!1,this.playBtn.innerHTML="&#9654;",this.stopPlayback(),this.reconstructState(),this.render()}goLive(){this.isLive=!0,this.isPlaying=!1,this.playBtn.innerHTML="&#9654;",this.liveBtn.classList.add("active"),this.stopPlayback(),this.onReplayState&&this.onReplayState(this.store.getAgents()),this.render()}startPlayback(){if(this.animId)return;this.lastFrameTime=performance.now();const t=()=>{const e=performance.now(),s=e-this.lastFrameTime;this.lastFrameTime=e;const{start:n,end:o}=this.getTimeRange(),r=o-n||1,l=s*this.playbackSpeed/r;if(this.playbackPosition=Math.min(1,this.playbackPosition+l),this.playbackPosition>=1){this.goLive();return}this.reconstructState(),this.render(),this.animId=requestAnimationFrame(t)};this.animId=requestAnimationFrame(t)}stopPlayback(){this.animId&&(cancelAnimationFrame(this.animId),this.animId=null)}reconstructState(){const t=this.store.getTimeline(),{start:e,end:s}=this.getTimeRange(),n=s-e||1,o=e+this.playbackPosition*n;this.replayAgents.clear();for(const r of t){if(r.timestamp>o)break;switch(r.type){case"agent:spawn":case"agent:update":case"agent:idle":this.replayAgents.set(r.agent.id,{...r.agent});break;case"agent:shutdown":this.replayAgents.delete(r.agent.id);break}}this.onReplayState&&this.onReplayState(this.replayAgents)}}const mr=class mr{constructor(){b(this,"ctx",null);b(this,"_volume",.3);b(this,"_muted",!1);b(this,"initialized",!1);b(this,"lastToolUseTime",0)}get volume(){return this._volume}set volume(t){this._volume=Math.max(0,Math.min(1,t))}get muted(){return this._muted}set muted(t){this._muted=t}init(){this.initialized||(this.ctx=new AudioContext,this.initialized=!0)}ensureContext(){if(!this.ctx)try{this.ctx=new AudioContext,this.initialized=!0}catch{return null}return this.ctx.state==="suspended"&&this.ctx.resume(),this.ctx}gain(){return this._muted?0:this._volume}play(t){if(this._muted||this._volume===0)return;const e=this.ensureContext();if(e)switch(t){case"spawn":this.playSpawn(e);break;case"zone-change":this.playZoneChange(e);break;case"tool-use":{const s=performance.now();if(s-this.lastToolUseTime<mr.TOOL_USE_COOLDOWN)return;this.lastToolUseTime=s,this.playToolUse(e);break}case"idle":this.playIdle(e);break;case"shutdown":this.playShutdown(e);break;case"input-needed":this.playInputNeeded(e);break}}playSpawn(t){const e=t.currentTime,s=this.gain()*.25;[523.25,659.25,783.99].forEach((o,r)=>{const l=t.createOscillator(),h=t.createGain();l.type="sine",l.frequency.value=o,h.gain.setValueAtTime(0,e+r*.1),h.gain.linearRampToValueAtTime(s,e+r*.1+.03),h.gain.exponentialRampToValueAtTime(.001,e+r*.1+.3),l.connect(h).connect(t.destination),l.start(e+r*.1),l.stop(e+r*.1+.35)})}playZoneChange(t){const e=t.currentTime,s=this.gain()*.12,n=t.createOscillator(),o=t.createGain();n.type="sine",n.frequency.setValueAtTime(440,e),n.frequency.exponentialRampToValueAtTime(660,e+.08),o.gain.setValueAtTime(s,e),o.gain.exponentialRampToValueAtTime(.001,e+.15),n.connect(o).connect(t.destination),n.start(e),n.stop(e+.2)}playToolUse(t){const e=t.currentTime,s=this.gain()*.06,n=t.createOscillator(),o=t.createGain();n.type="sine",n.frequency.setValueAtTime(880,e),n.frequency.exponentialRampToValueAtTime(600,e+.06),o.gain.setValueAtTime(s,e),o.gain.exponentialRampToValueAtTime(.001,e+.08),n.connect(o).connect(t.destination),n.start(e),n.stop(e+.1)}playIdle(t){const e=t.currentTime,s=this.gain()*.1,n=t.createOscillator(),o=t.createGain();n.type="sine",n.frequency.setValueAtTime(440,e),n.frequency.exponentialRampToValueAtTime(330,e+.2),o.gain.setValueAtTime(s,e),o.gain.exponentialRampToValueAtTime(.001,e+.3),n.connect(o).connect(t.destination),n.start(e),n.stop(e+.35)}playShutdown(t){const e=t.currentTime,s=this.gain()*.2;[659.25,523.25,392].forEach((o,r)=>{const l=t.createOscillator(),h=t.createGain();l.type="triangle",l.frequency.value=o,h.gain.setValueAtTime(0,e+r*.12),h.gain.linearRampToValueAtTime(s,e+r*.12+.02),h.gain.exponentialRampToValueAtTime(.001,e+r*.12+.3),l.connect(h).connect(t.destination),l.start(e+r*.12),l.stop(e+r*.12+.35)})}playInputNeeded(t){const e=t.currentTime,s=this.gain()*.3;[{freq:880,start:0,type:"sine"},{freq:660,start:.15,type:"sine"}].forEach(({freq:o,start:r,type:l})=>{const h=t.createOscillator(),d=t.createGain();h.type=l,h.frequency.value=o,d.gain.setValueAtTime(0,e+r),d.gain.linearRampToValueAtTime(s,e+r+.02),d.gain.exponentialRampToValueAtTime(.001,e+r+.25),h.connect(d).connect(t.destination),h.start(e+r),h.stop(e+r+.3)})}};b(mr,"TOOL_USE_COOLDOWN",300);let dl=mr;class W1{constructor(){b(this,"_enabled",!0);b(this,"permissionGranted",!1)}get enabled(){return this._enabled}set enabled(t){this._enabled=t}async requestPermission(){if(!("Notification"in window))return;if(Notification.permission==="granted"){this.permissionGranted=!0;return}if(Notification.permission==="denied")return;const t=await Notification.requestPermission();this.permissionGranted=t==="granted"}notifySpawn(t){this.show("Agent Spawned",`${t} has entered the office`)}notifyShutdown(t){this.show("Agent Finished",`${t} has left the office`)}notifyIdle(t){this.show("Agent Idle",`${t} is now idle`)}notifyInputNeeded(t){this.show("⚠️ Input Needed",`${t} is waiting for your input!`)}show(t,e){if(this._enabled&&this.permissionGranted&&document.visibilityState!=="visible")try{new Notification(t,{body:e,icon:"/favicon.ico",silent:!0,tag:"agent-move"})}catch{}}}const Nn=300,O1=2,H1=3,U1=8;class q1{constructor(t){b(this,"zones",new Map);b(this,"container");b(this,"currentBucketIndex",0);b(this,"bucketTimer");b(this,"animFrame",null);b(this,"lastFrameTime",0);b(this,"animate",()=>{const t=performance.now(),e=(t-this.lastFrameTime)/1e3;this.lastFrameTime=t;for(const[s,n]of this.zones){let o=0;for(let l=0;l<Nn;l++){const h=(this.currentBucketIndex-l+Nn)%Nn,d=Math.exp(-h/60);o+=n.buckets[l]*d}const r=Math.min(1,o/(U1*15));n.heat+=(r-n.heat)*Math.min(1,O1*e),n.pulsePhase+=H1*e*(.5+n.heat*.5),this.renderZoneHeat(n,s)}this.animFrame=requestAnimationFrame(this.animate)});this.store=t,this.container=document.createElement("div"),this.container.id="zone-heatmap",this.container.style.cssText=`
410
- position: absolute;
411
- top: 0;
412
- left: 0;
413
- width: 100%;
414
- height: 100%;
415
- pointer-events: none;
416
- z-index: 5;
417
- `,document.getElementById("app").appendChild(this.container);for(const e of se){const s=document.createElement("canvas");s.style.cssText=`
418
- position: absolute;
419
- pointer-events: none;
420
- border-radius: 4px;
421
- `,this.container.appendChild(s);const n=s.getContext("2d");this.zones.set(e.id,{buckets:new Array(Nn).fill(0),heat:0,pulsePhase:Math.random()*Math.PI*2,overlay:s,ctx:n})}this.store.on("agent:update",e=>{const s=this.zones.get(e.currentZone);s&&s.buckets[this.currentBucketIndex]++}),this.bucketTimer=setInterval(()=>{this.currentBucketIndex=(this.currentBucketIndex+1)%Nn;for(const e of this.zones.values())e.buckets[this.currentBucketIndex]=0},1e3),this.lastFrameTime=performance.now(),this.animate()}updateTransform(t,e,s){for(const n of se){const o=this.zones.get(n.id);if(!o)continue;const r=n.x*s+t,l=n.y*s+e,h=n.width*s,d=n.height*s;o.overlay.style.left=`${r}px`,o.overlay.style.top=`${l}px`,o.overlay.style.width=`${h}px`,o.overlay.style.height=`${d}px`,o.overlay.width=Math.ceil(h),o.overlay.height=Math.ceil(d)}}renderZoneHeat(t,e){const{ctx:s,overlay:n}=t,o=n.width,r=n.height;if(o===0||r===0||(s.clearRect(0,0,o,r),t.heat<.01))return;const l=Math.sin(t.pulsePhase)*.15+.85,h=t.heat*.18*l,d=Math.floor(Gn(30,255,t.heat)),c=Math.floor(Gn(60,t.heat<.5?Gn(80,160,t.heat*2):Gn(160,50,(t.heat-.5)*2),t.heat)),p=Math.floor(Gn(180,20,t.heat)),g=o/2,m=r/2,y=s.createRadialGradient(g,m,0,g,m,Math.max(o,r)*.7);if(y.addColorStop(0,`rgba(${d},${c},${p},${h})`),y.addColorStop(.6,`rgba(${d},${c},${p},${h*.5})`),y.addColorStop(1,`rgba(${d},${c},${p},0)`),s.fillStyle=y,s.fillRect(0,0,o,r),t.heat>.3){const x=(t.heat-.3)*.4*l;s.strokeStyle=`rgba(${d},${c},${p},${x})`,s.lineWidth=2+t.heat*3,s.strokeRect(1,1,o-2,r-2)}}dispose(){clearInterval(this.bucketTimer),this.animFrame&&cancelAnimationFrame(this.animFrame),this.container.remove()}}function V1(i,t,e){return Math.min(Math.max(i,t),e)}function Gn(i,t,e){return i+(t-i)*V1(e,0,1)}class Y1{constructor(t,e){b(this,"el");b(this,"inputEl");b(this,"listEl");b(this,"isOpen",!1);b(this,"actions",[]);b(this,"filteredActions",[]);b(this,"selectedIndex",0);b(this,"onCommand");b(this,"_customizationLookup",null);b(this,"globalKeydownHandler",t=>{(t.metaKey||t.ctrlKey)&&t.key==="k"&&(t.preventDefault(),this.toggle())});this.store=t,this.onCommand=e,this.el=document.createElement("div"),this.el.id="command-palette",this.el.innerHTML=`
422
- <div class="cmd-backdrop"></div>
423
- <div class="cmd-modal">
424
- <div class="cmd-input-wrap">
425
- <span class="cmd-icon"><svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor" opacity="0.5"><path d="M15.5 14h-.79l-.28-.27A6.47 6.47 0 0016 9.5 6.5 6.5 0 109.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/></svg></span>
426
- <input type="text" class="cmd-input" placeholder="Search commands, agents, zones…" autocomplete="off" />
427
- <kbd class="cmd-kbd">ESC</kbd>
428
- </div>
429
- <div class="cmd-list"></div>
430
- <div class="cmd-footer">
431
- <span><kbd>&uarr;&darr;</kbd> Navigate</span>
432
- <span><kbd>Enter</kbd> Select</span>
433
- <span><kbd>Esc</kbd> Close</span>
434
- </div>
435
- </div>
436
- `,document.body.appendChild(this.el),this.inputEl=this.el.querySelector(".cmd-input"),this.listEl=this.el.querySelector(".cmd-list"),this.el.querySelector(".cmd-backdrop").addEventListener("click",()=>this.close()),this.inputEl.addEventListener("input",()=>this.onFilter()),this.inputEl.addEventListener("keydown",s=>this.onKeyDown(s)),document.addEventListener("keydown",this.globalKeydownHandler),this.buildActions()}setCustomizationLookup(t){this._customizationLookup=t}buildActions(){this.actions=[];for(const t of se)this.actions.push({id:`zone:${t.id}`,label:`Go to ${t.label}`,description:t.description,icon:t.icon,category:"zone",action:()=>this.onCommand("focus-zone",t.id)});this.actions.push({id:"view:reset",label:"Reset Camera",description:"Fit all zones in view",icon:"🔲",category:"view",action:()=>this.onCommand("reset-camera")}),this.actions.push({id:"view:zoom-in",label:"Zoom In",description:"Zoom into the scene",icon:"🔍",category:"view",action:()=>this.onCommand("zoom-in")}),this.actions.push({id:"view:zoom-out",label:"Zoom Out",description:"Zoom out of the scene",icon:"🔎",category:"view",action:()=>this.onCommand("zoom-out")}),this.actions.push({id:"audio:mute",label:"Toggle Sound",description:"Mute or unmute sound effects",icon:"🔊",category:"audio",action:()=>this.onCommand("toggle-mute")}),this.actions.push({id:"feature:heatmap",label:"Toggle Heatmap",description:"Show/hide zone activity heatmap",icon:"🌡",category:"feature",action:()=>this.onCommand("toggle-heatmap")}),this.actions.push({id:"feature:analytics",label:"Open Analytics",description:"Show cost tracker & analytics dashboard",icon:"📊",category:"feature",action:()=>this.onCommand("toggle-analytics")}),this.actions.push({id:"feature:timeline-live",label:"Jump to Live",description:"Return timeline to live mode",icon:"🟢",category:"feature",action:()=>this.onCommand("timeline-live")}),this.actions.push({id:"feature:shortcuts",label:"Keyboard Shortcuts",description:"Show all keyboard shortcuts (?)",icon:"⌨",category:"feature",action:()=>this.onCommand("toggle-shortcuts")}),this.actions.push({id:"feature:focus",label:"Toggle Focus Mode",description:"Camera follows selected agent (F)",icon:"🎯",category:"feature",action:()=>this.onCommand("toggle-focus")}),this.actions.push({id:"feature:export",label:"Export Session Summary",description:"Generate session report (E)",icon:"📋",category:"feature",action:()=>this.onCommand("session-export")}),this.actions.push({id:"feature:trails",label:"Toggle Agent Trails",description:"Show movement trail dots (T)",icon:"✨",category:"feature",action:()=>this.onCommand("toggle-trails")}),this.actions.push({id:"feature:daynight",label:"Toggle Day/Night Cycle",description:"Real-time lighting overlay (N)",icon:"🌙",category:"feature",action:()=>this.onCommand("toggle-daynight")}),this.actions.push({id:"feature:minimap",label:"Toggle Mini-map",description:"Overview navigation map (`)",icon:"🗺",category:"feature",action:()=>this.onCommand("toggle-minimap")}),this.actions.push({id:"feature:leaderboard",label:"Toggle Leaderboard",description:"Agent performance rankings (L)",icon:"🏆",category:"feature",action:()=>this.onCommand("toggle-leaderboard")}),this.actions.push({id:"feature:theme",label:"Cycle Theme",description:"Switch between Office, Space, Castle, Cyberpunk",icon:"🎨",category:"feature",action:()=>this.onCommand("cycle-theme")}),this.actions.push({id:"feature:toolchain",label:"Toggle Tool Chains",description:"Tool usage stats and transition graph (C)",icon:"🔗",category:"feature",action:()=>this.onCommand("toggle-toolchain")}),this.actions.push({id:"feature:taskgraph",label:"Toggle Task Graph",description:"Visualize task dependencies (G)",icon:"📋",category:"feature",action:()=>this.onCommand("toggle-taskgraph")}),this.actions.push({id:"feature:activity",label:"Toggle Activity Feed",description:"Scrollable event timeline (V)",icon:"📜",category:"feature",action:()=>this.onCommand("toggle-activity")}),this.actions.push({id:"feature:waterfall",label:"Toggle Waterfall View",description:"Tool call trace timeline (W)",icon:"📊",category:"feature",action:()=>this.onCommand("toggle-waterfall")}),this.actions.push({id:"feature:graph",label:"Toggle Agent Graph",description:"Agent relationship visualization (R)",icon:"🔗",category:"feature",action:()=>this.onCommand("toggle-graph")})}getAgentActions(){return Array.from(this.store.getAgents().values()).map(e=>{var o,r;const s=(o=this._customizationLookup)==null?void 0:o.call(this,e),n=(s==null?void 0:s.displayName)||e.agentName||e.projectName||e.sessionId.slice(0,10);return{id:`agent:${e.id}`,label:`Focus: ${n}`,description:`${e.isIdle?"Idle":"Active"} in ${((r=Zt.get(e.currentZone))==null?void 0:r.label)??e.currentZone}`,icon:e.isIdle?"💤":"🤖",category:"agent",action:()=>this.onCommand("focus-agent",e.id)}})}toggle(){this.isOpen?this.close():this.open()}open(){this.isOpen=!0,this.el.classList.add("open"),this.inputEl.value="",this.selectedIndex=0,this.onFilter(),requestAnimationFrame(()=>this.inputEl.focus())}close(){this.isOpen=!1,this.el.classList.remove("open")}dispose(){document.removeEventListener("keydown",this.globalKeydownHandler),this.el.remove()}onFilter(){const t=this.inputEl.value.toLowerCase().trim(),e=[...this.actions,...this.getAgentActions()];t?this.filteredActions=e.filter(s=>s.label.toLowerCase().includes(t)||s.description.toLowerCase().includes(t)||s.category.includes(t)):this.filteredActions=e,this.selectedIndex=0,this.renderList()}renderList(){if(this.filteredActions.length===0){this.listEl.innerHTML='<div class="cmd-empty">No matching commands</div>';return}this.listEl.innerHTML=this.filteredActions.map((t,e)=>{const s=e===this.selectedIndex?"selected":"",n=`cmd-cat-${t.category}`;return`<div class="cmd-item ${s} ${n}" data-index="${e}">
437
- <span class="cmd-item-icon">${t.icon}</span>
438
- <div class="cmd-item-text">
439
- <div class="cmd-item-label">${zt(t.label)}</div>
440
- <div class="cmd-item-desc">${zt(t.description)}</div>
441
- </div>
442
- <span class="cmd-item-cat">${t.category}</span>
443
- </div>`}).join(""),this.listEl.querySelectorAll(".cmd-item").forEach(t=>{t.addEventListener("click",()=>{const e=parseInt(t.dataset.index,10);this.executeAction(e)}),t.addEventListener("mouseenter",()=>{this.selectedIndex=parseInt(t.dataset.index,10),this.updateSelection()})})}updateSelection(){this.listEl.querySelectorAll(".cmd-item").forEach((e,s)=>{e.classList.toggle("selected",s===this.selectedIndex)});const t=this.listEl.querySelector(".cmd-item.selected");t==null||t.scrollIntoView({block:"nearest"})}onKeyDown(t){switch(t.key){case"ArrowDown":t.preventDefault(),this.selectedIndex=Math.min(this.selectedIndex+1,this.filteredActions.length-1),this.updateSelection();break;case"ArrowUp":t.preventDefault(),this.selectedIndex=Math.max(this.selectedIndex-1,0),this.updateSelection();break;case"Enter":t.preventDefault(),this.executeAction(this.selectedIndex);break;case"Escape":t.preventDefault(),this.close();break}}executeAction(t){const e=this.filteredActions[t];e&&(this.close(),e.action())}}const j1=6e4,ka=2e3,X1=180;class Z1{constructor(t,e){b(this,"containerEl");b(this,"contentEl");b(this,"store");b(this,"isVisible",!1);b(this,"refreshTimer");b(this,"sampleTimer");b(this,"tokenSamples",[]);b(this,"costThreshold",5);b(this,"thresholdAlerted",!1);b(this,"thresholdFocused",!1);b(this,"alertEl",null);b(this,"toolChainData",null);b(this,"zoneTime",new Map);b(this,"_customizationLookup",null);b(this,"onAgentUpdateBound");b(this,"onToolChainBound");this.store=t,this.containerEl=e,this.contentEl=document.createElement("div"),this.contentEl.id="analytics-content",this.contentEl.style.display="none",this.containerEl.appendChild(this.contentEl),this.alertEl=document.createElement("div"),this.alertEl.id="cost-alert",this.alertEl.style.display="none",document.body.appendChild(this.alertEl),this.refreshTimer=setInterval(()=>{this.isVisible&&this.render()},1e3),this.sampleTimer=setInterval(()=>this.takeSample(),ka),this.onAgentUpdateBound=s=>{this.checkThreshold()},this.onToolChainBound=s=>{this.toolChainData=s},this.store.on("agent:update",this.onAgentUpdateBound),this.store.on("toolchain:snapshot",this.onToolChainBound)}setCustomizationLookup(t){this._customizationLookup=t}show(){this.isVisible=!0,this.contentEl.style.display="",this.render()}hide(){this.isVisible=!1,this.contentEl.style.display="none"}toggle(){this.isVisible?this.hide():this.show()}takeSample(){const t=Array.from(this.store.getAgents().values());let e=0;for(const s of t){e+=s.totalInputTokens+s.totalOutputTokens+s.cacheReadTokens+s.cacheCreationTokens;const n=s.isIdle?"idle":s.currentZone,o=this.zoneTime.get(n)??0;this.zoneTime.set(n,o+ka/1e3)}this.tokenSamples.push({timestamp:Date.now(),totalTokens:e}),this.tokenSamples.length>X1&&this.tokenSamples.shift()}getSnapshots(){return Array.from(this.store.getAgents().values()).map(t=>{var s;const e=(s=this._customizationLookup)==null?void 0:s.call(this,t);return{id:t.id,name:(e==null?void 0:e.displayName)||t.agentName||t.projectName||t.sessionId.slice(0,10),model:t.model,inputTokens:t.totalInputTokens,outputTokens:t.totalOutputTokens,cacheReadTokens:t.cacheReadTokens,cacheCreationTokens:t.cacheCreationTokens,colorIndex:(e==null?void 0:e.colorIndex)??t.colorIndex,zone:t.currentZone,isIdle:t.isIdle,spawnedAt:t.spawnedAt}})}calculateCost(t){return Pl({totalInputTokens:t.inputTokens,totalOutputTokens:t.outputTokens,cacheReadTokens:t.cacheReadTokens,cacheCreationTokens:t.cacheCreationTokens,model:t.model})}getTokenVelocity(){if(this.tokenSamples.length<2)return 0;const e=Date.now()-j1,s=this.tokenSamples.filter(l=>l.timestamp>=e);if(s.length<2)return 0;const n=s[0],o=s[s.length-1],r=(o.timestamp-n.timestamp)/6e4;return r<.01?0:(o.totalTokens-n.totalTokens)/r}getVelocityTrend(){if(this.tokenSamples.length<10)return"stable";const t=Math.floor(this.tokenSamples.length/2),e=this.tokenSamples.slice(0,t),s=this.tokenSamples.slice(t),n=this.avgDelta(e),o=this.avgDelta(s);return o>n*1.2?"up":o<n*.8?"down":"stable"}avgDelta(t){if(t.length<2)return 0;let e=0;for(let s=1;s<t.length;s++)e+=t[s].totalTokens-t[s-1].totalTokens;return e/(t.length-1)}checkThreshold(){const e=this.getSnapshots().reduce((s,n)=>s+this.calculateCost(n),0);e>=this.costThreshold&&!this.thresholdAlerted&&(this.thresholdAlerted=!0,this.showAlert(e))}showAlert(t){this.alertEl&&(this.alertEl.textContent=`Warning: Cost threshold exceeded: $${t.toFixed(2)}`,this.alertEl.style.display="block",this.alertEl.classList.add("flash"),setTimeout(()=>{this.alertEl&&(this.alertEl.classList.remove("flash"),setTimeout(()=>{this.alertEl&&(this.alertEl.style.display="none")},5e3))},3e3))}render(){const t=this.getSnapshots(),e=t.reduce((k,E)=>k+this.calculateCost(E),0),s=t.reduce((k,E)=>k+E.inputTokens,0),n=t.reduce((k,E)=>k+E.outputTokens,0),o=t.reduce((k,E)=>k+E.cacheReadTokens,0),r=t.reduce((k,E)=>k+E.cacheCreationTokens,0),l=this.getTokenVelocity(),h=this.getVelocityTrend(),d=h==="up"?"↑":h==="down"?"↓":"→",c=h==="up"?"#f87171":h==="down"?"#4ade80":"#888",p=s+o+r,g=p>0?o/p*100:0,m=t.reduce((k,E)=>{const B=El(E.model);return k+E.cacheReadTokens/1e6*B.input*.9},0),y=[...t].sort((k,E)=>this.calculateCost(E)-this.calculateCost(k)),x=this.renderVelocitySparkline();this.contentEl.innerHTML=`
444
- <div class="analytics-cards">
445
- <div class="analytics-card total-cost">
446
- <div class="card-label">Total Cost</div>
447
- <div class="card-value">$${e.toFixed(2)}</div>
448
- <div class="card-sub">${be(p)} in / ${be(n)} out</div>
449
- </div>
450
- <div class="analytics-card velocity">
451
- <div class="card-label">Token Velocity</div>
452
- <div class="card-value">${be(Math.round(l))}<span class="card-unit">/min</span></div>
453
- <div class="card-sub" style="color:${c}">${d} ${h}</div>
454
- </div>
455
- <div class="analytics-card agents-count">
456
- <div class="card-label">Active Agents</div>
457
- <div class="card-value">${t.filter(k=>!k.isIdle).length}<span class="card-unit">/${t.length}</span></div>
458
- <div class="card-sub">${t.filter(k=>k.isIdle).length} idle</div>
459
- </div>
460
- <div class="analytics-card cache-card">
461
- <div class="card-label">Cache Efficiency</div>
462
- <div class="card-value">${Math.min(g,100).toFixed(1)}<span class="card-unit">%</span></div>
463
- <div class="card-sub">${be(o)} read / ${be(r)} created</div>
464
- <div class="cache-savings">~$${m.toFixed(2)} saved</div>
465
- </div>
466
- </div>
467
-
468
- <div class="analytics-section">
469
- <div class="section-title">Token Rate (last ${Math.round(this.tokenSamples.length*ka/6e4)}min)</div>
470
- <div class="sparkline-container">${x}</div>
471
- </div>
472
-
473
- <div class="analytics-section">
474
- <div class="section-title">Cost by Agent</div>
475
- ${y.length>0?y.map(k=>this.renderAgentBar(k,e)).join(""):'<div class="analytics-empty">No agents active</div>'}
476
- </div>
477
-
478
- <div class="analytics-section">
479
- <div class="section-title">Time Spent by Zone</div>
480
- ${this.renderZoneTimeBars()}
481
- </div>
482
-
483
- <div class="analytics-section">
484
- <div class="section-title">Tool Usage Distribution</div>
485
- ${this.renderToolUsageBars()}
486
- </div>
487
-
488
- <div class="analytics-section">
489
- <div class="section-title">Cost Efficiency</div>
490
- ${this.renderCostEfficiency(t,e)}
491
- </div>
492
-
493
- <div class="analytics-section">
494
- <div class="section-title">Session Duration</div>
495
- ${this.renderSessionDurations(t)}
496
- </div>
497
-
498
- <div class="analytics-section threshold-section">
499
- <div class="section-title">Alert Threshold</div>
500
- <div class="threshold-row">
501
- <span>$</span>
502
- <input type="number" id="cost-threshold" name="cost-threshold" autocomplete="off" value="${this.costThreshold}" min="0.1" step="0.5" />
503
- <span class="threshold-status">${this.thresholdAlerted?"Exceeded":"Under"}</span>
504
- </div>
505
- </div>
506
- `;const w=this.contentEl.querySelector("#cost-threshold");w&&(w.addEventListener("change",()=>{this.costThreshold=parseFloat(w.value)||5,this.thresholdAlerted=!1}),this.thresholdFocused&&w.focus(),w.addEventListener("focus",()=>{this.thresholdFocused=!0}),w.addEventListener("blur",()=>{this.thresholdFocused=!1}))}renderAgentBar(t,e){const s=this.calculateCost(t),n=e>0?s/e*100:0,o=ft[t.colorIndex%ft.length],r=os(o.body);return`<div class="agent-bar">
507
- <div class="agent-bar-label">
508
- <span class="agent-dot" style="background:${r}"></span>
509
- <span class="agent-bar-name">${zt(t.name)}</span>
510
- <span class="agent-bar-cost">$${s.toFixed(2)}</span>
511
- </div>
512
- <div class="agent-bar-track">
513
- <div class="agent-bar-fill" style="width:${Math.max(2,n)}%;background:${r}"></div>
514
- </div>
515
- </div>`}renderZoneTimeBars(){if(this.zoneTime.size===0)return'<div class="analytics-empty">Collecting data...</div>';const t=Array.from(this.zoneTime.values()).reduce((s,n)=>s+n,0);return Array.from(this.zoneTime.entries()).sort((s,n)=>n[1]-s[1]).map(([s,n])=>{const o=Zt.get(s),r=s==="idle",l=t>0?n/t*100:0,h=r?"#6b7280":o?os(o.color):"#666",d=r?"Idle":(o==null?void 0:o.label)??s;return`<div class="zone-bar">
516
- <div class="zone-bar-label">
517
- <span>${r?"💤":(o==null?void 0:o.icon)??""} ${d}</span>
518
- <span class="zone-bar-cost">${wn(n*1e3)} (${l.toFixed(0)}%)</span>
519
- </div>
520
- <div class="zone-bar-track">
521
- <div class="zone-bar-fill" style="width:${Math.max(2,l)}%;background:${h}"></div>
522
- </div>
523
- </div>`}).join("")}renderVelocitySparkline(){if(this.tokenSamples.length<2)return'<div class="analytics-empty">Collecting data...</div>';const t=260,e=50,s=this.tokenSamples,n=[];for(let c=1;c<s.length;c++)n.push(Math.max(0,s[c].totalTokens-s[c-1].totalTokens));if(n.length===0)return"";const o=Math.max(...n,1),r=t/Math.max(n.length-1,1),h=n.map((c,p)=>{const g=p*r,m=e-c/o*(e-4)-2;return`${g.toFixed(1)},${m.toFixed(1)}`}).map((c,p)=>p===0?`M${c}`:`L${c}`).join(" "),d=`${h} L${((n.length-1)*r).toFixed(1)},${e} L0,${e} Z`;return`<svg width="${t}" height="${e}" viewBox="0 0 ${t} ${e}" class="velocity-spark">
524
- <defs>
525
- <linearGradient id="sparkGrad" x1="0" y1="0" x2="0" y2="1">
526
- <stop offset="0%" stop-color="#4ade80" stop-opacity="0.3"/>
527
- <stop offset="100%" stop-color="#4ade80" stop-opacity="0"/>
528
- </linearGradient>
529
- </defs>
530
- <path d="${d}" fill="url(#sparkGrad)"/>
531
- <path d="${h}" fill="none" stroke="#4ade80" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
532
- </svg>`}renderToolUsageBars(){var o;const t=((o=this.toolChainData)==null?void 0:o.toolCounts)??{},e=Object.entries(t);if(e.length===0)return'<div class="analytics-empty">No tool usage data yet</div>';const s=e.sort((r,l)=>l[1]-r[1]).slice(0,10),n=s[0][1];return s.map(([r,l])=>{const h=n>0?l/n*100:0,d=r.startsWith("mcp__")?"#60a5fa":"#a78bfa";let c=r;if(r.startsWith("mcp__")){const p=r.slice(5).split("__");if(p.length>=2){const g=p.slice(0,-1).join("/"),m=p[p.length-1];c=`${g} / ${m}`}}return`<div class="tool-bar">
533
- <div class="tool-bar-label">
534
- <span class="tool-bar-name" title="${zt(r)}">${zt(c)}</span>
535
- <span class="tool-bar-count">${l}</span>
536
- </div>
537
- <div class="tool-bar-track">
538
- <div class="tool-bar-fill" style="width:${Math.max(2,h)}%;background:${d}"></div>
539
- </div>
540
- </div>`}).join("")}renderCostEfficiency(t,e){var d;const s=Object.values(((d=this.toolChainData)==null?void 0:d.toolCounts)??{}).reduce((c,p)=>c+p,0),n=s>0?e/s:0,o=t.reduce((c,p)=>c+p.inputTokens+p.outputTokens+p.cacheReadTokens+p.cacheCreationTokens,0),r=s>0?o/s:0,l=Date.now(),h=t.map(c=>{const p=Math.max((l-c.spawnedAt)/6e4,.5),g=this.calculateCost(c);return{name:c.name,rate:g/p,cost:g}}).filter(c=>c.cost>.001).sort((c,p)=>p.rate-c.rate);return`
541
- <div class="analytics-cards" style="margin-bottom:8px">
542
- <div class="analytics-card">
543
- <div class="card-label">Cost / Tool Use</div>
544
- <div class="card-value">$${n.toFixed(4)}</div>
545
- <div class="card-sub">${s} total uses</div>
546
- </div>
547
- <div class="analytics-card">
548
- <div class="card-label">Tokens / Tool Use</div>
549
- <div class="card-value">${be(Math.round(r))}</div>
550
- <div class="card-sub">${be(o)} total</div>
551
- </div>
552
- </div>
553
- ${h.length>0?'<div class="cost-rate-header">Cost rate ($/min)</div>'+h.slice(0,5).map(c=>`<div class="cost-rate-row">
554
- <span class="cost-rate-name">${zt(c.name)}</span>
555
- <span class="cost-rate-value">$${c.rate.toFixed(4)}/min</span>
556
- </div>`).join(""):""}
557
- `}renderSessionDurations(t){if(t.length===0)return'<div class="analytics-empty">No active sessions</div>';const e=Date.now();return t.map(s=>{const n=e-s.spawnedAt,o=ft[s.colorIndex%ft.length];return`<div class="session-row">
558
- <span class="agent-dot" style="background:${os(o.body)}"></span>
559
- <span class="session-name">${zt(s.name)}</span>
560
- <span class="session-duration">${wn(n)}</span>
561
- <span class="session-status ${s.isIdle?"idle":"active"}">${s.isIdle?"idle":"active"}</span>
562
- </div>`}).join("")}dispose(){var t;clearInterval(this.refreshTimer),clearInterval(this.sampleTimer),this.store.off("agent:update",this.onAgentUpdateBound),this.store.off("toolchain:snapshot",this.onToolChainBound),this.contentEl.remove(),(t=this.alertEl)==null||t.remove()}}const K1="agent-move-layout",Rc=200;new Map(se.map(i=>[i.id,{x:i.x,y:i.y,width:i.width,height:i.height}]));function Q1(){try{const i=localStorage.getItem(K1);if(!i)return;const t=JSON.parse(i);if(t.version!==1||!t.zones)return;for(const[e,s]of Object.entries(t.zones)){const n=Zt.get(e);n&&(n.x=s.x,n.y=s.y,n.width=Math.max(Rc,s.width),n.height=Math.max(Rc,s.height))}}catch{}}const J1=6e4,tb=2e3;class eb{constructor(t){b(this,"store");b(this,"refreshTimer");b(this,"sampleTimer");b(this,"samples",[]);b(this,"connectionDot");b(this,"hooksDot");b(this,"focusBar");b(this,"hookEventCount",0);b(this,"onHooksStatusBound");b(this,"onPermRequestBound");b(this,"onPermResolvedBound");b(this,"onConnectionStatusBound");this.store=t,this.connectionDot=document.getElementById("connection-dot"),this.hooksDot=document.getElementById("hooks-dot"),this.focusBar=document.getElementById("focus-sub-bar"),this.onHooksStatusBound=()=>{this.hookEventCount++},this.onPermRequestBound=()=>{this.hookEventCount++},this.onPermResolvedBound=()=>{this.hookEventCount++},t.on("hooks:status",this.onHooksStatusBound),t.on("permission:request",this.onPermRequestBound),t.on("permission:resolved",this.onPermResolvedBound),this.onConnectionStatusBound=e=>{const s=e==="connected";this.connectionDot.classList.toggle("connected",s),this.connectionDot.classList.toggle("disconnected",!s),this.connectionDot.title=s?"Connected":"Disconnected",document.getElementById("disconnected-bar").classList.toggle("visible",!s)},this.store.on("connection:status",this.onConnectionStatusBound),this.refreshTimer=setInterval(()=>this.updateStats(),1e3),this.sampleTimer=setInterval(()=>this.takeSample(),tb)}showFocus(t){this.focusBar.querySelector(".fi-name").textContent=t,this.focusBar.classList.add("visible")}hideFocus(){this.focusBar.classList.remove("visible")}takeSample(){const t=Array.from(this.store.getAgents().values());let e=0;for(const s of t)e+=s.totalInputTokens+s.totalOutputTokens;this.samples.push({timestamp:Date.now(),total:e}),this.samples.length>90&&this.samples.shift()}getVelocity(){if(this.samples.length<2)return 0;const e=Date.now()-J1,s=this.samples.filter(l=>l.timestamp>=e);if(s.length<2)return 0;const n=s[0],o=s[s.length-1],r=(o.timestamp-n.timestamp)/6e4;return r<.01?0:(o.total-n.total)/r}updateStats(){const t=Array.from(this.store.getAgents().values()),e=t.filter(c=>!c.isIdle&&!c.isDone).length,s=t.filter(c=>c.isIdle||c.isDone).length;let n=0;for(const c of t)n+=Pl(c);const o=this.getVelocity(),r=(c,p)=>{const g=document.querySelector(`#${c} .tb-stat-val`);g&&(g.textContent=p)};r("tb-active",String(e)),r("tb-idle",String(s)),r("tb-cost",n<.01?n.toFixed(4):n.toFixed(2)),r("tb-velocity",be(Math.round(o)));const l=document.querySelector("#tb-active .tb-stat-dot");l&&l.classList.toggle("pulse",e>0);const h=this.store.getPendingPermissions().length,d=this.store.isHooksActive();this.hooksDot.classList.toggle("hooks-pending",h>0),this.hooksDot.classList.toggle("hooks-active",d&&h===0),h>0?this.hooksDot.title=`Hooks: ${h} permission${h>1?"s":""} pending | ${this.hookEventCount} events received`:d?this.hooksDot.title=`Hooks: active | ${this.hookEventCount} events received`:this.hooksDot.title="Hooks: not detected (run `agent-move hooks install`)"}dispose(){clearInterval(this.refreshTimer),clearInterval(this.sampleTimer),this.store.off("hooks:status",this.onHooksStatusBound),this.store.off("permission:request",this.onPermRequestBound),this.store.off("permission:resolved",this.onPermResolvedBound),this.store.off("connection:status",this.onConnectionStatusBound)}}class sb{constructor(){b(this,"activeTab","monitor");b(this,"collapsed",!1);b(this,"onTabChange",null);b(this,"el");b(this,"toggleBtn");this.el=document.getElementById("sidebar"),this.toggleBtn=document.getElementById("sb-toggle"),localStorage.getItem("sidebar-collapsed")==="true"&&(this.collapsed=!0,this.el.classList.add("collapsed"),document.documentElement.style.setProperty("--sidebar-nav-width","52px")),this.toggleBtn.addEventListener("click",()=>this.toggle()),this.el.querySelectorAll(".sb-item").forEach(e=>{e.addEventListener("click",()=>{const s=e.dataset.tab;this.setActiveTab(s)})})}setTabChangeHandler(t){this.onTabChange=t}getActiveTab(){return this.activeTab}setActiveTab(t){var e,s;if(t===this.activeTab&&t!=="monitor"){this.activeTab="monitor",this.updateUI(),(e=this.onTabChange)==null||e.call(this,"monitor");return}this.activeTab=t,this.updateUI(),(s=this.onTabChange)==null||s.call(this,t)}toggle(){this.collapsed=!this.collapsed,this.el.classList.toggle("collapsed",this.collapsed),document.documentElement.style.setProperty("--sidebar-nav-width",this.collapsed?"52px":"200px"),localStorage.setItem("sidebar-collapsed",String(this.collapsed))}updateUI(){this.el.querySelectorAll(".sb-item").forEach(t=>{const e=t.dataset.tab;t.classList.toggle("active",e===this.activeTab)})}}const ib=4500,nb=5,gr=class gr{constructor(t){b(this,"containerEl");b(this,"store");b(this,"_customizationLookup",null);b(this,"toasts",[]);b(this,"onSpawnBound");b(this,"onIdleBound");b(this,"onShutdownBound");b(this,"onAnomalyBound");b(this,"onTaskBound");this.store=t,this.containerEl=document.createElement("div"),this.containerEl.id="toast-container",this.containerEl.setAttribute("aria-live","polite"),document.body.appendChild(this.containerEl),this.onSpawnBound=e=>this.onSpawn(e),this.onIdleBound=e=>this.onIdle(e),this.onShutdownBound=e=>this.onShutdown(e),this.onAnomalyBound=e=>this.onAnomaly(e),this.onTaskBound=({taskSubject:e})=>this.onTaskCompleted(e),this.store.on("agent:spawn",this.onSpawnBound),this.store.on("agent:idle",this.onIdleBound),this.store.on("agent:shutdown",this.onShutdownBound),this.store.on("anomaly:alert",this.onAnomalyBound),this.store.on("task:completed",this.onTaskBound)}setCustomizationLookup(t){this._customizationLookup=t}getName(t){var s;const e=(s=this._customizationLookup)==null?void 0:s.call(this,t);return(e==null?void 0:e.displayName)||t.agentName||t.projectName||t.sessionId.slice(0,10)}getColor(t){const e=ft[t.colorIndex%ft.length];return os(e.body)}onSpawn(t){const e=this.getName(t),s=this.getColor(t),n=t.role==="main"?"":` (${t.role})`;this.show(`<span class="toast-dot" style="background:${s}"></span> <strong>${zt(e)}</strong>${n} spawned`,"spawn")}onIdle(t){if(t.isDone){const e=this.getName(t),s=this.getColor(t);this.show(`<span class="toast-dot" style="background:${s}"></span> <strong>${zt(e)}</strong> finished`,"done")}}onShutdown(t){const e=this.store.getAgent(t),s=e?this.getName(e):t.slice(0,10);this.show(`<strong>${zt(s)}</strong> shut down`,"shutdown")}onTaskCompleted(t){this.show(`✓ Task completed: <strong>${zt(t)}</strong>`,"done")}onAnomaly(t){const e=gr.ANOMALY_ICONS[t.kind]??"⚠️",s=t.severity==="critical"?"critical":"warning",n=this.store.getAgent(t.agentId),o=n?this.getName(n):t.agentName;this.show(`${e} <strong>${zt(o)}</strong>: ${zt(t.message)}`,s)}show(t,e="info"){const s=document.createElement("div");s.className=`toast toast-${e}`,s.innerHTML=t,this.containerEl.appendChild(s),requestAnimationFrame(()=>{s.classList.add("toast-enter")});const n=setTimeout(()=>this.dismiss(s),ib);for(this.toasts.push({el:s,timer:n});this.toasts.length>nb;){const o=this.toasts.shift();o&&(clearTimeout(o.timer),this.removeEl(o.el))}}dismiss(t){t.classList.add("toast-exit"),t.addEventListener("animationend",()=>t.remove(),{once:!0}),setTimeout(()=>t.remove(),400);const e=this.toasts.findIndex(s=>s.el===t);e>=0&&this.toasts.splice(e,1)}removeEl(t){t.classList.add("toast-exit"),t.addEventListener("animationend",()=>t.remove(),{once:!0}),setTimeout(()=>t.remove(),400)}dispose(){this.store.off("agent:spawn",this.onSpawnBound),this.store.off("agent:idle",this.onIdleBound),this.store.off("agent:shutdown",this.onShutdownBound),this.store.off("anomaly:alert",this.onAnomalyBound),this.store.off("task:completed",this.onTaskBound);for(const t of this.toasts)clearTimeout(t.timer),t.el.remove();this.toasts=[],this.containerEl.remove()}};b(gr,"ANOMALY_ICONS",{"retry-loop":"🔁","token-spike":"📈","stuck-agent":"⏳"});let ul=gr;const ob=[{title:"General",shortcuts:[{keys:"?",description:"Toggle this help overlay"},{keys:"Ctrl + K",description:"Open command palette"},{keys:"Esc",description:"Close any open panel"}]},{title:"Navigation",shortcuts:[{keys:"Scroll",description:"Zoom in / out"},{keys:"Click + Drag",description:"Pan the canvas"},{keys:"+ / -",description:"Zoom in / out"},{keys:"0",description:"Reset camera to fit view"}]},{title:"Panels",shortcuts:[{keys:"A",description:"Toggle analytics panel"},{keys:"H",description:"Toggle activity heatmap"},{keys:"E",description:"Export session summary"},{keys:"M",description:"Toggle sound mute"}]},{title:"Camera & Focus",shortcuts:[{keys:"F",description:"Focus / cycle to next agent"},{keys:"Esc",description:"Exit focus mode"}]},{title:"Timeline",shortcuts:[{keys:"Space",description:"Play / pause timeline replay"}]},{title:"New Features",shortcuts:[{keys:"T",description:"Toggle agent trails"},{keys:"N",description:"Toggle day/night cycle"},{keys:"`",description:"Toggle mini-map"},{keys:"L",description:"Toggle leaderboard"},{keys:"P",description:"Cycle theme"},{keys:"C",description:"Toggle tool chains panel"},{keys:"G",description:"Toggle task graph panel"},{keys:"V",description:"Toggle activity feed"},{keys:"W",description:"Toggle waterfall trace view"},{keys:"R",description:"Toggle agent relationship graph"}]}];class rb{constructor(){b(this,"el");b(this,"isOpen",!1);b(this,"globalKeydownHandler",t=>{var s;const e=(s=t.target)==null?void 0:s.tagName;e==="INPUT"||e==="TEXTAREA"||e==="SELECT"||(t.key==="?"&&(t.preventDefault(),this.toggle()),t.key==="Escape"&&this.isOpen&&(t.preventDefault(),this.close()))});this.el=document.createElement("div"),this.el.id="shortcuts-help",this.el.innerHTML=`
563
- <div class="sh-backdrop"></div>
564
- <div class="sh-modal">
565
- <div class="sh-header">
566
- <span class="sh-title">Keyboard Shortcuts</span>
567
- <button class="sh-close">&times;</button>
568
- </div>
569
- <div class="sh-body">
570
- ${ob.map(t=>`
571
- <div class="sh-group">
572
- <div class="sh-group-title">${t.title}</div>
573
- ${t.shortcuts.map(e=>`
574
- <div class="sh-row">
575
- <span class="sh-keys">${this.renderKeys(e.keys)}</span>
576
- <span class="sh-desc">${e.description}</span>
577
- </div>
578
- `).join("")}
579
- </div>
580
- `).join("")}
581
- </div>
582
- <div class="sh-footer">Press <kbd>?</kbd> to close</div>
583
- </div>
584
- `,document.body.appendChild(this.el),this.el.querySelector(".sh-backdrop").addEventListener("click",()=>this.close()),this.el.querySelector(".sh-close").addEventListener("click",()=>this.close()),document.addEventListener("keydown",this.globalKeydownHandler)}renderKeys(t){return t.split(/\s*\+\s*|\s*\/\s*/).map(e=>{const s=e.trim();return s?`<kbd>${s}</kbd>`:""}).filter(Boolean).join(t.includes("+")?" + ":" / ")}toggle(){this.isOpen?this.close():this.open()}open(){this.isOpen=!0,this.el.classList.add("open")}close(){this.isOpen=!1,this.el.classList.remove("open")}dispose(){document.removeEventListener("keydown",this.globalKeydownHandler),this.el.remove()}}class ab{constructor(t){b(this,"el");b(this,"store");b(this,"isOpen",!1);b(this,"_customizationLookup",null);this.store=t,this.el=document.createElement("div"),this.el.id="session-export",this.el.innerHTML=`
585
- <div class="se-backdrop"></div>
586
- <div class="se-modal">
587
- <div class="se-header">
588
- <span class="se-title">Session Summary</span>
589
- <button class="se-close">&times;</button>
590
- </div>
591
- <div class="se-body">
592
- <pre class="se-content"></pre>
593
- </div>
594
- <div class="se-footer">
595
- <button class="se-copy-btn">Copy to Clipboard</button>
596
- <button class="se-download-btn">Download .md</button>
597
- </div>
598
- </div>
599
- `,document.body.appendChild(this.el),this.el.querySelector(".se-backdrop").addEventListener("click",()=>this.close()),this.el.querySelector(".se-close").addEventListener("click",()=>this.close()),this.el.querySelector(".se-copy-btn").addEventListener("click",()=>this.copyToClipboard()),this.el.querySelector(".se-download-btn").addEventListener("click",()=>this.download())}setCustomizationLookup(t){this._customizationLookup=t}toggle(){this.isOpen?this.close():this.open()}open(){this.isOpen=!0,this.el.classList.add("open"),this.render()}close(){this.isOpen=!1,this.el.classList.remove("open")}generateReport(){var g,m,y;const t=Array.from(this.store.getAgents().values()),e=Date.now(),s=t.length>0?Math.min(...t.map(x=>x.spawnedAt)):e,n=e-s;let o=0,r=0,l=0,h=0;const d=[];for(const x of t){const w=El(x.model),k=x.totalInputTokens/1e6*w.input+x.totalOutputTokens/1e6*w.output;o+=k,r+=x.totalInputTokens,l+=x.totalOutputTokens,h+=x.cacheReadTokens;const E=Zt.get(x.currentZone);d.push({name:((m=(g=this._customizationLookup)==null?void 0:g.call(this,x))==null?void 0:m.displayName)||x.agentName||x.projectName||x.sessionId.slice(0,10),cost:k,tokens:x.totalInputTokens+x.totalOutputTokens,duration:e-x.spawnedAt,role:x.role,zone:(E==null?void 0:E.label)??x.currentZone,status:x.isDone?"Done":x.isIdle?"Idle":"Active"})}d.sort((x,w)=>w.cost-x.cost);const c=[];if(c.push("# AgentMove Session Summary"),c.push(`> Generated ${new Date().toISOString()}`),c.push(""),c.push("## Overview"),c.push("| Metric | Value |"),c.push("|--------|-------|"),c.push(`| Duration | ${wn(n)} |`),c.push(`| Total Agents | ${t.length} |`),c.push(`| Active | ${t.filter(x=>!x.isIdle&&!x.isDone).length} |`),c.push(`| Idle | ${t.filter(x=>x.isIdle&&!x.isDone).length} |`),c.push(`| Done | ${t.filter(x=>x.isDone).length} |`),c.push(`| Total Cost | $${o.toFixed(4)} |`),c.push(`| Input Tokens | ${be(r)} |`),c.push(`| Output Tokens | ${be(l)} |`),c.push(`| Cache Reads | ${be(h)} |`),c.push(""),d.length>0){c.push("## Agents"),c.push("| Agent | Role | Status | Zone | Cost | Tokens | Duration |"),c.push("|-------|------|--------|------|------|--------|----------|");for(const x of d)c.push(`| ${x.name} | ${x.role} | ${x.status} | ${x.zone} | $${x.cost.toFixed(4)} | ${be(x.tokens)} | ${wn(x.duration)} |`);c.push("")}const p=new Map;for(const x of t){const w=((y=Zt.get(x.currentZone))==null?void 0:y.label)??x.currentZone;p.set(w,(p.get(w)??0)+1)}if(p.size>0){c.push("## Zone Distribution"),c.push("| Zone | Agents |"),c.push("|------|--------|");for(const[x,w]of Array.from(p.entries()).sort((k,E)=>E[1]-k[1]))c.push(`| ${x} | ${w} |`);c.push("")}return c.push("---"),c.push("*Generated by AgentMove*"),c.join(`
600
- `)}render(){const t=this.el.querySelector(".se-content");t.textContent=this.generateReport()}async copyToClipboard(){const t=this.generateReport();try{await navigator.clipboard.writeText(t);const e=this.el.querySelector(".se-copy-btn");e.textContent="Copied!",setTimeout(()=>{e.textContent="Copy to Clipboard"},2e3)}catch{const e=document.createElement("textarea");e.value=t,document.body.appendChild(e),e.select(),document.execCommand("copy"),e.remove()}}download(){const t=this.generateReport(),e=new Blob([t],{type:"text/markdown"}),s=URL.createObjectURL(e),n=document.createElement("a");n.href=s,n.download=`agent-move-session-${new Date().toISOString().slice(0,19).replace(/:/g,"-")}.md`,n.click(),URL.revokeObjectURL(s)}dispose(){this.el.remove()}}const $c="agent-move:onboarding-dismissed";class lb{constructor(){b(this,"el",null);this.isDismissed()||this.show()}isDismissed(){try{return localStorage.getItem($c)==="1"}catch{return!1}}dismiss(){try{localStorage.setItem($c,"1")}catch{}this.el&&(this.el.classList.add("ob-exit"),setTimeout(()=>{var t;return(t=this.el)==null?void 0:t.remove()},400))}show(){this.el=document.createElement("div"),this.el.id="onboarding",this.el.innerHTML=`
601
- <div class="ob-card">
602
- <div class="ob-header">
603
- <span class="ob-logo">AgentMove</span>
604
- <button class="ob-close">&times;</button>
605
- </div>
606
- <div class="ob-body">
607
- <p class="ob-desc">Real-time visualization of your Claude Code sessions.</p>
608
- <div class="ob-features">
609
- <div class="ob-feature">
610
- <span class="ob-icon">&#128187;</span>
611
- <div>
612
- <strong>Start a Claude Code session</strong>
613
- <span>Agents appear automatically as they work</span>
614
- </div>
615
- </div>
616
- <div class="ob-feature">
617
- <span class="ob-icon">&#9000;</span>
618
- <div>
619
- <strong>Press <kbd>?</kbd> for shortcuts</strong>
620
- <span>Quick keys for all features</span>
621
- </div>
622
- </div>
623
- <div class="ob-feature">
624
- <span class="ob-icon">&#128269;</span>
625
- <div>
626
- <strong>Press <kbd>Ctrl+K</kbd></strong>
627
- <span>Command palette to search anything</span>
628
- </div>
629
- </div>
630
- <div class="ob-feature">
631
- <span class="ob-icon">&#128202;</span>
632
- <div>
633
- <strong>Press <kbd>A</kbd> for analytics</strong>
634
- <span>Live cost tracking and token stats</span>
635
- </div>
636
- </div>
637
- </div>
638
- </div>
639
- <button class="ob-dismiss">Got it, let's go!</button>
640
- </div>
641
- `,document.body.appendChild(this.el),requestAnimationFrame(()=>{var t;return(t=this.el)==null?void 0:t.classList.add("ob-enter")}),this.el.querySelector(".ob-close").addEventListener("click",()=>this.dismiss()),this.el.querySelector(".ob-dismiss").addEventListener("click",()=>this.dismiss()),this.el.addEventListener("click",t=>{t.target===this.el&&this.dismiss()})}dispose(){var t;(t=this.el)==null||t.remove()}}const $u="agent-move:";function Il(i,t){try{const e=localStorage.getItem($u+i);return e===null?t:JSON.parse(e)}catch{return t}}function fr(i,t){try{localStorage.setItem($u+i,JSON.stringify(t))}catch{}}const hb=200,Dc=5,cb=20,zc=4e3,db=2;class ub{constructor(){b(this,"container",new Ft);b(this,"graphics",new Wt);b(this,"trails",new Map);b(this,"timers",new Map);b(this,"_enabled",!1);this.container.addChild(this.graphics),this.container.visible=!1}get enabled(){return this._enabled}toggle(){this._enabled=!this._enabled,this.container.visible=this._enabled,this._enabled||(this.trails.clear(),this.timers.clear(),this.graphics.clear())}recordPosition(t,e,s,n,o){if(!this._enabled)return;const r=(this.timers.get(t)??0)+n;if(this.timers.set(t,r),r<hb)return;this.timers.set(t,0);let l=this.trails.get(t);l||(l=[],this.trails.set(t,l));const h=l[l.length-1];if(h){const d=e-h.x,c=s-h.y;if(d*d+c*c<Dc*Dc)return}l.push({x:e,y:s,age:0}),l.length>cb&&l.shift()}removeAgent(t){this.trails.delete(t),this.timers.delete(t)}update(t,e){if(this._enabled){this.graphics.clear();for(const[s,n]of this.trails){const o=e.get(s)??4906624;let r=0;for(;r<n.length;)if(n[r].age+=t,n[r].age>=zc)n.splice(r,1);else{const l=.4*(1-n[r].age/zc);this.graphics.circle(n[r].x,n[r].y,db).fill({color:o,alpha:l}),r++}n.length===0&&this.trails.delete(s)}}}}const Wn=200,On=150;class fb{constructor(t,e){b(this,"canvas");b(this,"ctx");b(this,"_visible",!1);b(this,"camera");b(this,"scaleX");b(this,"scaleY");this.camera=t,this.scaleX=Wn/Math.max(1,Xa),this.scaleY=On/Math.max(1,Za),this.canvas=document.createElement("canvas");const s=window.devicePixelRatio||1;this.canvas.width=Wn*s,this.canvas.height=On*s,this.canvas.id="minimap",this.canvas.style.cssText=`
642
- position: fixed; bottom: 12px; right: 12px;
643
- width: ${Wn}px; height: ${On}px;
644
- border: 1px solid rgba(255,255,255,0.15);
645
- border-radius: 6px; background: rgba(10,12,20,0.85);
646
- cursor: crosshair; z-index: 80; display: none;
647
- box-shadow: 0 2px 12px rgba(0,0,0,0.5);
648
- `,document.body.appendChild(this.canvas),this.ctx=this.canvas.getContext("2d"),this.ctx.scale(s,s),this.canvas.addEventListener("click",n=>{const o=this.canvas.getBoundingClientRect(),r=n.clientX-o.left,l=n.clientY-o.top,h=r/this.scaleX,d=l/this.scaleY;e(h,d)})}get visible(){return this._visible}toggle(){this._visible=!this._visible,this.canvas.style.display=this._visible?"block":"none"}render(t,e){if(!this._visible)return;this.scaleX=Wn/Math.max(1,Xa),this.scaleY=On/Math.max(1,Za);const s=this.ctx;s.clearRect(0,0,Wn,On),s.imageSmoothingEnabled=!1;for(const h of se){const d=h.x*this.scaleX,c=h.y*this.scaleY,p=h.width*this.scaleX,g=h.height*this.scaleY;s.fillStyle="#"+h.color.toString(16).padStart(6,"0")+"30",s.strokeStyle="#"+h.color.toString(16).padStart(6,"0")+"60",s.lineWidth=.5,s.fillRect(d,c,p,g),s.strokeRect(d,c,p,g),s.save(),s.fillStyle="#"+h.color.toString(16).padStart(6,"0")+"aa",s.font='600 8px "Inter", "SF Pro Text", system-ui, sans-serif',s.textAlign="center",s.textBaseline="middle",s.fillText(h.label,d+p/2,c+g/2,p-4),s.restore()}for(const h of t){const d=ft[h.colorIndex%ft.length];s.fillStyle="#"+d.body.toString(16).padStart(6,"0"),s.beginPath(),s.arc(h.x*this.scaleX,h.y*this.scaleY,3,0,Math.PI*2),s.fill()}const n=e.x*this.scaleX,o=e.y*this.scaleY,r=e.width*this.scaleX,l=e.height*this.scaleY;s.strokeStyle="rgba(255, 255, 255, 0.6)",s.lineWidth=1,s.strokeRect(n,o,r,l)}dispose(){this.canvas.remove()}}const pb=["🥇","🥈","🥉"];class mb{constructor(t,e){b(this,"contentEl");b(this,"containerEl");b(this,"isVisible",!1);b(this,"refreshInterval",null);b(this,"sortColumn","tokens");b(this,"sortDir","desc");b(this,"_customizationLookup",null);this.store=t,this.containerEl=e,this.contentEl=document.createElement("div"),this.contentEl.id="leaderboard-content",this.contentEl.style.display="none",this.containerEl.appendChild(this.contentEl)}setCustomizationLookup(t){this._customizationLookup=t}show(){this.isVisible=!0,this.contentEl.style.display="",this.render(),this.refreshInterval=setInterval(()=>this.render(),1e3)}hide(){this.isVisible=!1,this.contentEl.style.display="none",this.refreshInterval&&(clearInterval(this.refreshInterval),this.refreshInterval=null)}toggle(){this.isVisible?this.hide():this.show()}computeCost(t){return Pl(t)}render(){const t=Array.from(this.store.getAgents().values());if(t.length===0){this.contentEl.innerHTML='<div class="lb-empty">No agents active</div>';return}const e=t.map(n=>{const o=this.computeCost(n),r=Date.now()-n.spawnedAt,l=n.totalInputTokens+n.totalOutputTokens+n.cacheReadTokens+n.cacheCreationTokens,h=r>6e4?l/(r/6e4):l;return{...n,cost:o,duration:r,velocity:h}});e.sort((n,o)=>{let r,l;switch(this.sortColumn){case"tokens":r=n.totalInputTokens+n.totalOutputTokens+n.cacheReadTokens+n.cacheCreationTokens,l=o.totalInputTokens+o.totalOutputTokens+o.cacheReadTokens+o.cacheCreationTokens;break;case"cost":r=n.cost,l=o.cost;break;case"duration":r=n.duration,l=o.duration;break;case"tools":r=n.toolUseCount,l=o.toolUseCount;break;case"velocity":r=n.velocity,l=o.velocity;break}return this.sortDir==="desc"?l-r:r-l});const s=Math.max(...e.map(n=>n.totalInputTokens+n.totalOutputTokens+n.cacheReadTokens+n.cacheCreationTokens),1);this.contentEl.innerHTML=`
649
- <table class="lb-table">
650
- <thead>
651
- <tr>
652
- <th>#</th>
653
- <th>Agent</th>
654
- <th class="lb-sortable" data-col="tokens">Tokens</th>
655
- <th class="lb-sortable" data-col="cost">Cost</th>
656
- <th class="lb-sortable" data-col="duration">Duration</th>
657
- <th class="lb-sortable" data-col="tools">Tools</th>
658
- </tr>
659
- </thead>
660
- <tbody>
661
- ${e.map((n,o)=>{var y;const r=(y=this._customizationLookup)==null?void 0:y.call(this,n),l=(r==null?void 0:r.colorIndex)??n.colorIndex,d="#"+ft[l%ft.length].body.toString(16).padStart(6,"0"),c=(r==null?void 0:r.displayName)||n.agentName||n.projectName||n.sessionId.slice(0,10),p=n.totalInputTokens+n.totalOutputTokens+n.cacheReadTokens+n.cacheCreationTokens,g=p/s*100;return`<tr>
662
- <td class="lb-rank">${o<3?pb[o]:`${o+1}`}</td>
663
- <td class="lb-name"><span class="lb-dot" style="background:${d}"></span>${zt(c)}</td>
664
- <td>
665
- <div class="lb-bar-wrap">
666
- <div class="lb-bar" style="width:${g}%;background:${d}"></div>
667
- <span class="lb-bar-label">${be(p)}</span>
668
- </div>
669
- </td>
670
- <td>$${n.cost.toFixed(2)}</td>
671
- <td>${wn(n.duration)}</td>
672
- <td>${n.toolUseCount}</td>
673
- </tr>`}).join("")}
674
- </tbody>
675
- </table>
676
- `,this.contentEl.querySelectorAll(".lb-sortable").forEach(n=>{n.addEventListener("click",()=>{const o=n.dataset.col;this.sortColumn===o?this.sortDir=this.sortDir==="desc"?"asc":"desc":(this.sortColumn=o,this.sortDir="desc"),this.render()})})}dispose(){this.refreshInterval&&clearInterval(this.refreshInterval),this.contentEl.remove()}}const Ta="agent-customizations";class gb{constructor(){b(this,"el");b(this,"customizations");b(this,"currentAgent",null);b(this,"onChange",null);this.customizations=Il(Ta,{}),this.el=document.createElement("div"),this.el.id="agent-customizer",this.el.innerHTML=`
677
- <div class="ac-backdrop"></div>
678
- <div class="ac-popover">
679
- <div class="ac-header">Customize Agent<button class="ac-close">&times;</button></div>
680
- <div class="ac-field">
681
- <label>Display Name</label>
682
- <input type="text" class="ac-name-input" maxlength="14" placeholder="Custom name..." />
683
- </div>
684
- <div class="ac-field">
685
- <label>Color</label>
686
- <div class="ac-palette"></div>
687
- </div>
688
- <div class="ac-actions">
689
- <button class="ac-reset">Reset</button>
690
- <button class="ac-save">Save</button>
691
- </div>
692
- </div>
693
- `,document.body.appendChild(this.el);const t=this.el.querySelector(".ac-palette");ft.forEach((e,s)=>{const n=document.createElement("div");n.className="ac-swatch",n.style.background="#"+e.body.toString(16).padStart(6,"0"),n.dataset.index=String(s),n.addEventListener("click",()=>{t.querySelectorAll(".ac-swatch").forEach(o=>o.classList.remove("selected")),n.classList.add("selected")}),t.appendChild(n)}),this.el.querySelector(".ac-backdrop").addEventListener("click",()=>this.close()),this.el.querySelector(".ac-close").addEventListener("click",()=>this.close()),this.el.querySelector(".ac-save").addEventListener("click",()=>this.save()),this.el.querySelector(".ac-reset").addEventListener("click",()=>this.reset())}setChangeHandler(t){this.onChange=t}getDefaultName(t){return t.agentName||ho(t.sessionId)}getDisplayName(t){const e=this.customizations[t.id];return(e==null?void 0:e.displayName)||this.getDefaultName(t)}getDisplayColorIndex(t){const e=this.customizations[t.id];return(e==null?void 0:e.colorIndex)??t.colorIndex}getCustomDisplay(t){return{displayName:this.getDisplayName(t),colorIndex:this.getDisplayColorIndex(t)}}open(t){this.currentAgent=t;const e=this.customizations[t.id],s=this.getDefaultName(t);this.el.querySelector(".ac-name-input").value=(e==null?void 0:e.displayName)??s;const n=(e==null?void 0:e.colorIndex)??-1;this.el.querySelectorAll(".ac-swatch").forEach(o=>{o.classList.toggle("selected",o.dataset.index===String(n))}),this.el.classList.add("open")}close(){this.el.classList.remove("open"),this.currentAgent=null}save(){var o;if(!this.currentAgent)return;const t=this.el.querySelector(".ac-name-input").value.trim(),e=this.el.querySelector(".ac-swatch.selected"),s=e?parseInt(e.dataset.index,10):void 0,n={};t&&(n.displayName=t),s!==void 0&&(n.colorIndex=s),this.customizations[this.currentAgent.id]=n,fr(Ta,this.customizations),(o=this.onChange)==null||o.call(this,this.currentAgent.id,n),this.close()}reset(){var t;this.currentAgent&&(delete this.customizations[this.currentAgent.id],fr(Ta,this.customizations),(t=this.onChange)==null||t.call(this,this.currentAgent.id,{}),this.close())}dispose(){this.el.remove()}}const hs=(i,t,e,s,n)=>{i.roundRect(t,e,s,n,4).fill({color:3355460,alpha:.15})},yb=14995640,bb=14469296,_b=14207152,Wo=13154464,Oo=12114072,xb=11061384,$e=4,K=i=>i*$e;function _t(i,t,e,s,n,o){i.rect(t,e,s,n).fill(o)}function vb(i,t,e){const s=K(7),n=s/2;_t(i,t-2,e+n-K(2),$e+1,K(2),9067056),_t(i,t-2,e+n-K(2),2,K(2),8014368),_t(i,t-n+K(2),e-n,s-K(4),K(1),2779690),_t(i,t-n+K(2),e+n-K(1),s-K(4),K(1),2779690),_t(i,t-n,e-n+K(2),K(1),s-K(4),2779690),_t(i,t+n-K(1),e-n+K(2),K(1),s-K(4),2779690),_t(i,t-n+K(1),e-n+K(1),s-K(2),s-K(2),3836474),_t(i,t-n+K(2),e-n+K(2),s-K(4),s-K(4),4893258),_t(i,t-K(2),e-n+K(1),K(3),K(2),6736998),_t(i,t-K(1),e-n,K(2),K(1),8973960)}function wb(i,t,e){_t(i,t-1,e+K(1),3,K(2),9067056),_t(i,t-K(2),e-K(1),K(4),K(2),2783786),_t(i,t-K(1),e-K(2),K(2),K(4),2783786),_t(i,t-K(2)+$e,e-K(2)+$e,K(2),K(2),3836474),_t(i,t-K(1),e-K(1),K(2),K(2),4893258),_t(i,t-$e,e-K(2),$e,$e,6736998)}function Sb(i,t,e){_t(i,t-1,e+K(2),3,K(2),6965792),_t(i,t-K(1),e-K(3),K(2),K(5),1731098),_t(i,t-K(2),e-K(2),K(4),K(3),2783786),_t(i,t-K(1),e-K(2),K(2),K(3),3836474),_t(i,t-$e,e-K(2),$e,K(2),4889162),_t(i,t-1,e-K(3),3,$e,5941850)}const Fc=[vb,wb,Sb];function Ho(i,t,e,s){Fc[s%Fc.length](i,t,e)}function kb(i,t,e){_t(i,t-K(2),e-K(1),K(4),K(2),3836474),_t(i,t-K(1),e-K(2),K(2),K(4),3836474),_t(i,t-K(1),e-K(1),K(2),K(2),5941850),_t(i,t,e-K(2),$e,$e,6736964)}function Tb(i,t,e){_t(i,0,0,t,e,yb);const s=K(12);for(let m=0;m<e;m+=s)for(let y=0;y<t;y+=s)(y/s+m/s)%5===0&&_t(i,y,m,s,s,bb);const n=K(8);_t(i,0,0,t,n,Oo),_t(i,0,e-n,t,n,Oo),_t(i,0,0,n,e,Oo),_t(i,t-n,0,n,e,Oo);const o=K(2);for(let m=0;m<e;m+=K(4))for(let y=0;y<t;y+=K(4))(y<n||y>t-n-o||m<n||m>e-n-o)&&(y*7+m*13)%97<20&&_t(i,y,m,o,o,xb);let r=0,l=0,h=0,d=0;if(se.length>0){r=Math.min(...se.map(y=>y.x)),l=Math.min(...se.map(y=>y.y)),h=Math.max(...se.map(y=>y.x+y.width)),d=Math.max(...se.map(y=>y.y+y.height));const m=12;_t(i,r-m,l-m,h-r+m*2,d-l+m*2,_b),_t(i,r-m,l-m,h-r+m*2,2,Wo),_t(i,r-m,d+m-2,h-r+m*2,2,Wo),_t(i,r-m,l-m,2,d-l+m*2,Wo),_t(i,h+m-2,l-m,2,d-l+m*2,Wo),_t(i,r,l,h-r,d-l,15260872)}const c=K(4),p=K(24);let g=0;for(let m=c;m<t-c;m+=p)Ho(i,m,c,g++);for(let m=c+K(12);m<t-c;m+=p)Ho(i,m,e-c,g++);for(let m=c+p;m<e-c;m+=p)Ho(i,c,m,g++);for(let m=c+K(12);m<e-c;m+=p)Ho(i,t-c,m,g++);if(se.length>0)for(let m=r+K(10);m<h-K(8);m+=K(18))kb(i,m,d+16)}const Du={id:"office",name:"Office",icon:"🏢",colors:{background:14995640,gridLine:14206124,gridLineSub:13416608},decorators:{search:qe.search??hs,terminal:qe.terminal??hs,web:qe.web??hs,files:qe.files??hs,thinking:qe.thinking??hs,messaging:qe.messaging??hs,spawn:qe.spawn??hs,idle:qe.idle??hs,tasks:qe.tasks??hs},gridRenderer:Tb,pixelRooms:!0},Cb=4,z=i=>i*Cb,gt={hull:2763322,hullLight:3816010,panel:3355472,panelLight:4473960,panelDark:2236992,floor:1973808,floorAlt:2368568,floorLine:1447466,led:4521864,ledBlue:4491519,ledRed:16729156,ledOff:2236979,screen:13124,screenGlow:43724,holo:6702335,holoBright:11176191,metal:7829384,metalDark:5592422,airlockEdge:6710920};function xt(i,t,e,s,n,o){i.rect(t,e,s,n).fill(o)}function cs(i,t,e,s,n){xt(i,t,e,s,n,gt.floor);for(let o=0;o<n;o+=z(4))xt(i,t,e+o,s,1,gt.floorLine);for(let o=0;o<s;o+=z(8))xt(i,t+o,e,1,n,gt.floorLine);for(let o=z(2);o<n;o+=z(8))for(let r=z(2);r<s;r+=z(8))xt(i,t+r,e+o,z(1),z(1),gt.floorAlt)}function an(i,t,e,s){xt(i,t,e,s,z(10),gt.panel),xt(i,t,e,s,z(1),gt.panelLight),xt(i,t+z(2),e+z(2),s-z(4),z(4),gt.screen),xt(i,t+z(3),e+z(3),s-z(6),z(1),gt.screenGlow);for(let n=0;n<3;n++)xt(i,t+z(2)+n*z(3),e+z(7),z(2),z(2),gt.ledBlue)}function Ca(i,t,e){xt(i,t-z(3),e,z(6),z(1),gt.metalDark);for(let s=0;s<5;s++){const n=z(8)-s*z(1);xt(i,t-n/2,e-z(2)-s*z(2),n,z(1),gt.holo)}xt(i,t-z(1),e-z(4),z(2),z(2),gt.holoBright)}const Ab={search:(i,t,e,s,n)=>{cs(i,t,e,s,n),an(i,t+z(4),e+z(7),z(20)),an(i,t+z(28),e+z(7),z(20)),Ca(i,t+s/2,e+n/2)},terminal:(i,t,e,s,n)=>{cs(i,t,e,s,n);for(let o=0;o<3;o++){xt(i,t+z(2)+o*z(10),e+z(7),z(7),z(14),gt.hull);for(let r=0;r<4;r++)xt(i,t+z(3)+o*z(10),e+z(8)+r*z(3),z(5),z(2),gt.panelDark),xt(i,t+z(4)+o*z(10),e+z(9)+r*z(3),z(1),z(1),r<3?gt.led:gt.ledOff)}},web:(i,t,e,s,n)=>{cs(i,t,e,s,n),xt(i,t+z(4),e+z(7),z(20),z(14),gt.panelDark),xt(i,t+z(5),e+z(8),z(18),z(12),gt.screen),xt(i,t+z(8),e+z(11),z(12),z(6),gt.holo),Ca(i,t+z(40),e+z(30))},files:(i,t,e,s,n)=>{cs(i,t,e,s,n);for(let o=0;o<4;o++)xt(i,t+z(2)+o*z(7),e+z(7),z(5),z(10),gt.metalDark),xt(i,t+z(3)+o*z(7),e+z(8),z(3),z(3),gt.metal),xt(i,t+z(3)+o*z(7),e+z(12),z(3),z(3),gt.metal);an(i,t+z(24),e+z(25),z(14))},thinking:(i,t,e,s,n)=>{cs(i,t,e,s,n),Ca(i,t+s/2,e+n/2),xt(i,t+s/2-z(9),e+n/2+z(2),z(18),z(1),gt.metalDark),an(i,t+z(4),e+z(7),z(24)),an(i,t+z(32),e+z(7),z(20))},messaging:(i,t,e,s,n)=>{cs(i,t,e,s,n),xt(i,t+z(4),e+z(21),z(16),z(8),gt.hull),xt(i,t+z(5),e+z(22),z(14),z(6),gt.hullLight),an(i,t+z(4),e+z(7),z(14))},spawn:(i,t,e,s,n)=>{cs(i,t,e,s,n);const o=t+s/2,r=e+n/2;xt(i,o-z(6),r-z(6),z(12),z(12),gt.panelDark),xt(i,o-z(4),r-z(4),z(8),z(8),gt.holo),xt(i,o-z(2),r-z(2),z(4),z(4),gt.holoBright),xt(i,o-z(8),r-z(1),z(16),z(2),gt.airlockEdge),xt(i,o-z(1),r-z(8),z(2),z(16),gt.airlockEdge)},idle:(i,t,e,s,n)=>{cs(i,t,e,s,n),xt(i,t+z(2),e+z(7),z(28),z(5),gt.hull),xt(i,t+z(3),e+z(8),z(26),z(3),gt.hullLight),xt(i,t+z(4),e+z(9),z(2),z(1),gt.screenGlow),xt(i,t+z(32),e+z(7),z(6),z(14),gt.metalDark);for(let o=0;o<3;o++)xt(i,t+z(33),e+z(8)+o*z(4),z(4),z(3),gt.screen)},tasks:(i,t,e,s,n)=>{cs(i,t,e,s,n),xt(i,t+z(2),e+z(7),z(30),z(18),gt.panel),xt(i,t+z(3),e+z(8),z(28),z(16),gt.screen);const o=[gt.ledRed,gt.led,gt.ledBlue];for(let r=0;r<3;r++){const l=z(8),h=t+z(4)+r*(l+z(1));xt(i,h,e+z(9),l,z(2),o[r]);for(let d=0;d<3-r;d++)xt(i,h+2,e+z(12)+d*z(3),l-4,z(2),gt.holo)}}},Mb={id:"space",name:"Space Station",icon:"🚀",colors:{background:657944,gridLine:1381672,gridLineSub:1052704},decorators:Ab},Eb=4,R=i=>i*Eb,Et={stone:6974058,stoneDark:4868682,stoneLight:9079434,mortar:3815994,wood:8015920,woodDark:5913120,woodLight:10119744,torch:16746496,torchGlow:16755251,torchHandle:4861984,banner:8921651,bannerEdge:6689058,scroll:15259824,rugEdge:6693427};function Pt(i,t,e,s,n,o){i.rect(t,e,s,n).fill(o)}function ds(i,t,e,s,n){Pt(i,t,e,s,n,Et.stone);for(let o=0;o<n;o+=R(5)){Pt(i,t,e+o,s,1,Et.mortar);const r=o/R(5)%2*R(6);for(let l=r;l<s;l+=R(12))Pt(i,t+l,e+o,1,R(5),Et.mortar)}for(let o=R(2);o<n;o+=R(10))for(let r=R(3);r<s;r+=R(12))Pt(i,t+r,e+o,R(1),R(1),Et.stoneLight)}function Me(i,t,e){Pt(i,t,e+R(3),R(1),R(4),Et.torchHandle),Pt(i,t-1,e+R(1),R(1)+2,R(2),Et.torch),Pt(i,t,e,R(1),R(1),Et.torchGlow)}function Uo(i,t,e,s,n){Pt(i,t,e,s,R(1),Et.woodDark),Pt(i,t+1,e+R(1),s-2,n,Et.banner),Pt(i,t+1,e+R(1),s-2,R(1),Et.bannerEdge),Pt(i,t+s/2-R(1),e+n/2,R(2),R(2),Et.torchGlow)}function di(i,t,e,s,n){Pt(i,t,e,s,n,Et.woodDark),Pt(i,t+1,e+1,s-2,n-2,Et.wood),Pt(i,t+2,e+2,s-4,1,Et.woodLight)}const Pb={search:(i,t,e,s,n)=>{ds(i,t,e,s,n);for(let o=0;o<4;o++)Pt(i,t+R(2)+o*R(16),e+R(7),R(10),R(14),Et.woodDark),Pt(i,t+R(3)+o*R(16),e+R(8),R(8),R(12),Et.wood);Me(i,t+R(14),e+R(8)),Me(i,t+R(30),e+R(8)),di(i,t+R(18),e+R(35),R(12),R(6)),Pt(i,t+R(20),e+R(36),R(6),R(3),Et.scroll)},terminal:(i,t,e,s,n)=>{ds(i,t,e,s,n);for(let o=0;o<3;o++)Pt(i,t+R(2)+o*R(10),e+R(7),R(7),R(14),Et.stoneDark),Pt(i,t+R(3)+o*R(10),e+R(9),R(5),R(1),Et.torch);Me(i,t+R(34),e+R(9)),Uo(i,t+R(4),e+R(28),R(8),R(12))},web:(i,t,e,s,n)=>{ds(i,t,e,s,n),Pt(i,t+R(4),e+R(7),R(20),R(14),Et.stoneDark),Pt(i,t+R(5),e+R(8),R(18),R(12),Et.stoneLight),Pt(i,t+R(8),e+R(11),R(12),R(6),Et.torchGlow),Me(i,t+R(28),e+R(10)),di(i,t+R(4),e+R(27),R(14),R(5))},files:(i,t,e,s,n)=>{ds(i,t,e,s,n);for(let o=0;o<4;o++)Pt(i,t+R(2)+o*R(7),e+R(7),R(5),R(10),Et.woodDark);di(i,t+R(24),e+R(25),R(14),R(6)),Pt(i,t+R(26),e+R(26),R(6),R(3),Et.scroll),Me(i,t+R(40),e+R(9))},thinking:(i,t,e,s,n)=>{ds(i,t,e,s,n),Pt(i,t+R(8),e+n/2-R(8),R(10),R(4),Et.rugEdge),di(i,t+s/2-R(9),e+n/2-R(4),R(18),R(8)),Uo(i,t+R(4),e+R(7),R(10),R(14)),Uo(i,t+R(34),e+R(7),R(10),R(14)),Me(i,t+R(18),e+R(8)),Me(i,t+R(28),e+R(8))},messaging:(i,t,e,s,n)=>{ds(i,t,e,s,n),Uo(i,t+R(8),e+R(7),R(14),R(10)),di(i,t+R(6),e+R(33),R(12),R(5)),Me(i,t+R(4),e+R(10)),Me(i,t+R(26),e+R(10))},spawn:(i,t,e,s,n)=>{ds(i,t,e,s,n);const o=t+s/2,r=e+n/2;Pt(i,o-R(4),r-R(4),R(8),R(8),Et.mortar),Pt(i,o-R(3),r-R(3),R(6),R(6),Et.torchGlow),Pt(i,o-R(1),r-R(1),R(2),R(2),Et.torch),Me(i,t+R(2),e+R(12)),Me(i,t+s-R(4),e+R(12))},idle:(i,t,e,s,n)=>{ds(i,t,e,s,n),di(i,t+R(2),e+R(7),R(28),R(5)),Pt(i,t+R(4),e+R(8),R(4),R(3),Et.woodLight),di(i,t+R(14),e+R(30),R(10),R(10)),di(i,t+R(40),e+R(30),R(10),R(10)),Me(i,t+R(50),e+R(8))},tasks:(i,t,e,s,n)=>{ds(i,t,e,s,n),Pt(i,t+R(2),e+R(7),R(30),R(18),Et.woodDark),Pt(i,t+R(3),e+R(8),R(28),R(16),Et.wood);for(let o=0;o<3;o++)for(let r=0;r<3-o;r++)Pt(i,t+R(4)+o*R(9)+2,e+R(12)+r*R(3),R(7),R(2),Et.scroll);Me(i,t+R(36),e+R(9))}},Ib={id:"castle",name:"Medieval Castle",icon:"🏰",colors:{background:1710096,gridLine:2762784,gridLineSub:2104856},decorators:Pb},Lb=4,U=i=>i*Lb,pt={floor:921114,floorAlt:1184288,floorLine:1710638,neonPink:16720537,neonBlue:52479,neonGreen:65416,neonPurple:11158783,neonYellow:16768256,darkPanel:1710632,panel:2236984,panelEdge:3355472,screen:6690,rain:3359846};function kt(i,t,e,s,n,o){i.rect(t,e,s,n).fill(o)}function us(i,t,e,s,n){kt(i,t,e,s,n,pt.floor);for(let o=0;o<n;o+=U(6))kt(i,t,e+o,s,1,pt.floorLine),o/U(6)%2===0&&kt(i,t,e+o+U(3),s,U(3),pt.floorAlt);kt(i,t,e,s,1,pt.neonPink),kt(i,t,e+n-1,s,1,pt.neonBlue)}function ui(i,t,e,s,n,o){kt(i,t,e,s,n,pt.darkPanel),kt(i,t+1,e+1,s-2,n-2,pt.screen),kt(i,t+2,e+2,s-4,U(1),o),kt(i,t,e,s,1,o),kt(i,t,e+n-1,s,1,o)}function Hn(i,t,e,s,n){kt(i,t,e,s,U(1),n),kt(i,t+U(1),e-1,s-U(2),1,n)}function fs(i,t,e,s,n){for(let o=0;o<12;o++){const r=t+(o*37+11)%(s-U(1)),l=e+(o*53+7)%(n-U(4));kt(i,r,l,1,U(2),pt.rain)}}const Bb={search:(i,t,e,s,n)=>{us(i,t,e,s,n),ui(i,t+U(4),e+U(7),U(20),U(12),pt.neonPink),ui(i,t+U(28),e+U(7),U(20),U(12),pt.neonBlue),Hn(i,t+U(4),e+U(26),U(44),pt.neonPurple),fs(i,t,e,s,n)},terminal:(i,t,e,s,n)=>{us(i,t,e,s,n);for(let o=0;o<3;o++){kt(i,t+U(2)+o*U(10),e+U(7),U(7),U(14),pt.darkPanel),kt(i,t+U(3)+o*U(10),e+U(9),U(5),U(1),pt.neonGreen);for(let r=0;r<3;r++)kt(i,t+U(4)+o*U(10),e+U(11)+r*U(2),U(1),U(1),pt.neonGreen)}fs(i,t,e,s,n)},web:(i,t,e,s,n)=>{us(i,t,e,s,n),ui(i,t+U(4),e+U(7),U(24),U(16),pt.neonBlue),kt(i,t+U(8),e+U(12),U(16),U(8),pt.neonPurple),Hn(i,t+U(30),e+U(20),U(10),pt.neonPink),fs(i,t,e,s,n)},files:(i,t,e,s,n)=>{us(i,t,e,s,n);for(let o=0;o<4;o++)kt(i,t+U(2)+o*U(7),e+U(7),U(5),U(10),pt.darkPanel),kt(i,t+U(2)+o*U(7),e+U(7),U(5),1,pt.neonBlue);ui(i,t+U(24),e+U(25),U(14),U(8),pt.neonGreen),fs(i,t,e,s,n)},thinking:(i,t,e,s,n)=>{us(i,t,e,s,n),ui(i,t+U(4),e+U(7),U(24),U(12),pt.neonPurple),ui(i,t+U(32),e+U(7),U(20),U(12),pt.neonBlue),kt(i,t+s/2-U(8),e+n/2+U(2),U(16),U(1),pt.panelEdge),Hn(i,t+U(4),e+n-U(4),U(40),pt.neonPink),fs(i,t,e,s,n)},messaging:(i,t,e,s,n)=>{us(i,t,e,s,n),kt(i,t+U(4),e+U(21),U(16),U(8),pt.darkPanel),kt(i,t+U(5),e+U(22),U(14),U(1),pt.neonPink),ui(i,t+U(4),e+U(7),U(14),U(8),pt.neonYellow),Hn(i,t+U(22),e+U(18),U(8),pt.neonGreen),fs(i,t,e,s,n)},spawn:(i,t,e,s,n)=>{us(i,t,e,s,n);const o=t+s/2,r=e+n/2;for(let l=0;l<3;l++){const h=U(3)+l*U(3);kt(i,o-h,r-h,h*2,1,pt.neonPurple),kt(i,o-h,r+h,h*2,1,pt.neonPurple),kt(i,o-h,r-h,1,h*2,pt.neonBlue),kt(i,o+h,r-h,1,h*2,pt.neonBlue)}kt(i,o-U(1),r-U(1),U(2),U(2),pt.neonGreen),fs(i,t,e,s,n)},idle:(i,t,e,s,n)=>{us(i,t,e,s,n),kt(i,t+U(2),e+U(7),U(28),U(5),pt.darkPanel),kt(i,t+U(2),e+U(7),U(28),1,pt.neonPink),Hn(i,t+U(34),e+U(12),U(12),pt.neonBlue),kt(i,t+U(34),e+U(7),U(8),U(14),pt.darkPanel),kt(i,t+U(35),e+U(8),U(6),U(4),pt.screen),kt(i,t+U(36),e+U(9),U(4),U(1),pt.neonGreen),fs(i,t,e,s,n)},tasks:(i,t,e,s,n)=>{us(i,t,e,s,n),ui(i,t+U(2),e+U(7),U(30),U(18),pt.neonGreen);const o=[pt.neonPink,pt.neonYellow,pt.neonBlue];for(let r=0;r<3;r++){const l=U(8),h=t+U(4)+r*(l+U(1));kt(i,h,e+U(9),l,U(2),o[r]);for(let d=0;d<3-r;d++)kt(i,h+2,e+U(12)+d*U(3),l-4,U(2),pt.panel)}fs(i,t,e,s,n)}},Rb={id:"cyberpunk",name:"Cyberpunk",icon:"🌃",colors:{background:657424,gridLine:1708072,gridLineSub:1051162},decorators:Bb},Nc="theme",Un=[Du,Mb,Ib,Rb];class $b{constructor(){b(this,"_current");b(this,"_onChange",null);const t=Il(Nc,"office");this._current=Un.find(e=>e.id===t)??Du}get current(){return this._current}setTheme(t){var s;const e=Un.find(n=>n.id===t);!e||e.id===this._current.id||(this._current=e,fr(Nc,e.id),(s=this._onChange)==null||s.call(this,e))}onChange(t){this._onChange=t}cycleNext(){const t=Un.indexOf(this._current),e=Un[(t+1)%Un.length];this.setTheme(e.id)}}const Gc="zone-annotations";let Aa=0;class Db{constructor(){b(this,"container");b(this,"annotations",new Map);b(this,"noteEls",new Map);b(this,"visible",!0);b(this,"rootX",0);b(this,"rootY",0);b(this,"scale",1);this.container=document.createElement("div"),this.container.id="zone-annotations",this.container.style.cssText="position:absolute;top:0;left:0;pointer-events:none;z-index:15;";const t=document.getElementById("canvas-container");t&&t.appendChild(this.container),this.load(),this.renderAll()}load(){try{const t=localStorage.getItem(Gc);if(t){const e=JSON.parse(t);for(const s of e){this.annotations.set(s.id,s);const n=parseInt(s.id.replace("ann-",""),10);!isNaN(n)&&n>=Aa&&(Aa=n+1)}}}catch{}}save(){localStorage.setItem(Gc,JSON.stringify(Array.from(this.annotations.values())))}renderAll(){for(const t of this.annotations.values())this.createNoteEl(t)}createNoteEl(t){const e=document.createElement("div");e.className="zone-annotation",e.style.pointerEvents="auto",e.innerHTML=`<span class="za-text">${this.escapeHtml(t.text)}</span><button class="za-delete" title="Delete">&times;</button>`,e.querySelector(".za-delete").addEventListener("click",s=>{s.stopPropagation(),this.removeAnnotation(t.id)}),this.makeDraggable(e,t),this.container.appendChild(e),this.noteEls.set(t.id,e),this.positionNote(t,e)}positionNote(t,e){const s=Zt.get(t.zoneId);if(!s)return;const n=s.x+t.relX*s.width,o=s.y+t.relY*s.height,r=n*this.scale+this.rootX,l=o*this.scale+this.rootY;e.style.transform=`translate(${r}px, ${l}px) scale(${Math.min(1,this.scale)})`}makeDraggable(t,e){let s=0,n=0,o=0,r=0;const l=Zt.get(e.zoneId);if(!l)return;const h=p=>{p.target.classList.contains("za-delete")||(p.stopPropagation(),s=p.clientX,n=p.clientY,o=e.relX,r=e.relY,t.setPointerCapture(p.pointerId),t.addEventListener("pointermove",d),t.addEventListener("pointerup",c,{once:!0}))},d=p=>{const g=(p.clientX-s)/this.scale,m=(p.clientY-n)/this.scale;e.relX=Math.max(.05,Math.min(.95,o+g/l.width)),e.relY=Math.max(.05,Math.min(.95,r+m/l.height)),this.positionNote(e,t)},c=()=>{t.removeEventListener("pointermove",d),this.save()};t.addEventListener("pointerdown",h)}addAnnotationAtWorld(t,e){for(const s of se){const n=Zt.get(s.id);if(t>=n.x&&t<=n.x+n.width&&e>=n.y&&e<=n.y+n.height){this.promptAndAdd(s.id,(t-n.x)/n.width,(e-n.y)/n.height);return}}}addAnnotationFromScreen(t,e){const s=(t-this.rootX)/this.scale,n=(e-this.rootY)/this.scale;this.addAnnotationAtWorld(s,n)}promptAndAdd(t,e,s){const n=Zt.get(t);if(!n)return;const o=n.x+e*n.width,r=n.y+s*n.height,l=o*this.scale+this.rootX,h=r*this.scale+this.rootY,d=document.createElement("textarea");d.className="zone-annotation za-input",d.style.cssText=`position:absolute;pointer-events:auto;transform:translate(${l}px,${h}px);z-index:20;`,d.placeholder="Type a note...",d.rows=2,this.container.appendChild(d),d.focus();const c=()=>{const p=d.value.trim();if(d.remove(),p){const g=`ann-${Aa++}`,m={id:g,text:p,relX:e,relY:s,zoneId:t};this.annotations.set(g,m),this.createNoteEl(m),this.save()}};d.addEventListener("blur",c,{once:!0}),d.addEventListener("keydown",p=>{p.key==="Enter"&&!p.shiftKey&&(p.preventDefault(),d.blur()),p.key==="Escape"&&(d.value="",d.blur())})}removeAnnotation(t){this.annotations.delete(t);const e=this.noteEls.get(t);e&&(e.remove(),this.noteEls.delete(t)),this.save()}updateTransform(t,e,s){if(this.rootX=t,this.rootY=e,this.scale=s,!!this.visible)for(const n of this.annotations.values()){const o=this.noteEls.get(n.id);o&&this.positionNote(n,o)}}toggle(){this.visible=!this.visible,this.container.style.display=this.visible?"":"none"}get isVisible(){return this.visible}escapeHtml(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}}class zb{constructor(t,e){b(this,"container");b(this,"data",null);b(this,"visible",!1);b(this,"selectedTool",null);b(this,"onSnapshot");this.store=t,this.container=document.createElement("div"),this.container.id="toolchain-content",this.container.style.display="none",e.appendChild(this.container),this.onSnapshot=s=>{this.data=s,this.visible&&this.render()},this.store.on("toolchain:snapshot",this.onSnapshot)}destroy(){this.store.off("toolchain:snapshot",this.onSnapshot),this.container.remove()}show(){this.visible=!0,this.container.style.display="",this.store.requestToolChain(),this.render()}hide(){this.visible=!1,this.container.style.display="none"}render(){var w;if(!this.data||this.data.transitions.length===0){this.container.innerHTML='<div class="tc-empty">No tool transitions recorded yet</div>';return}const{transitions:t,toolCounts:e,toolSuccesses:s,toolFailures:n,toolAvgDuration:o}=this.data,r=Math.max(...t.map(k=>k.count)),l=Object.entries(e).sort((k,E)=>E[1]-k[1]),h=((w=l[0])==null?void 0:w[1])??1,d=l.reduce((k,[,E])=>k+E,0),c=this.selectedTool?t.filter(k=>k.from===this.selectedTool||k.to===this.selectedTool):t,p=Math.max(...c.map(k=>k.count),1),g=Object.keys(s??{}).length>0||Object.keys(n??{}).length>0;let m="";m+=`<div class="tc-section"><div class="tc-section-title">Tool Usage <span class="tc-hint">(${d} total calls)</span></div>`,g&&(m+='<div class="tc-col-header"><span class="tc-col-name">Tool</span><span class="tc-col-mid"></span><span class="tc-col-count">Calls</span><span class="tc-col-status">Status</span><span class="tc-col-avg">Avg</span></div>'),m+='<div class="tc-tools">';for(const[k,E]of l){const B=E/h*100,L=k===this.selectedTool,H=(s==null?void 0:s[k])??0,$=(n==null?void 0:n[k])??0,G=H+$,tt=G>0?$/G:0,Z=o==null?void 0:o[k];if(m+=`<div class="tc-tool-row ${L?"tc-selected":""}" data-tool="${this.esc(k)}">`,m+=`<span class="tc-tool-name">${this.esc(this.shortName(k))}</span>`,m+='<div class="tc-tool-bar-wrap">',m+=`<div class="tc-tool-bar" style="width:${B}%"></div>`,$>0){const X=G>0?$/G*B:0;m+=`<div class="tc-tool-bar tc-fail-bar" style="width:${X}%"></div>`}m+="</div>",m+=`<span class="tc-tool-count">${E}</span>`,g&&G>0&&tt>0?m+=`<span class="tc-outcome tc-outcome-fail" title="${$} failed">${Math.round(tt*100)}%</span>`:g&&G>0?m+=`<span class="tc-outcome tc-outcome-ok" title="${H} succeeded">✓</span>`:g&&(m+='<span class="tc-outcome"></span>'),g&&(m+=`<span class="tc-duration" title="avg per call">${Z!==void 0?this.fmtMs(Z):"—"}</span>`),m+="</div>"}m+="</div></div>",m+='<div class="tc-section"><div class="tc-section-title">',m+=this.selectedTool?`Transitions for <strong>${this.esc(this.shortName(this.selectedTool))}</strong> <button class="tc-clear-filter">Clear</button>`:'Top Transitions <span class="tc-hint">(click a tool above to filter)</span>',m+="</div>",m+='<div class="tc-transitions">';const y=[...c].sort((k,E)=>E.count-k.count).slice(0,20);for(const k of y){const E=k.count/p*100,B=k.count/r,L=Math.round(100+B*155),H=Math.round(130+B*40),$=Math.round(180-B*100);m+='<div class="tc-transition-row">',m+=`<span class="tc-t-from">${this.esc(this.shortName(k.from))}</span>`,m+='<span class="tc-t-arrow">→</span>',m+=`<span class="tc-t-to">${this.esc(this.shortName(k.to))}</span>`,m+=`<div class="tc-t-bar-wrap"><div class="tc-t-bar" style="width:${E}%;background:rgb(${L},${H},${$})"></div></div>`,m+=`<span class="tc-t-count">${k.count}×</span>`,m+="</div>"}y.length===0&&(m+='<div class="tc-empty" style="padding:12px">No transitions for this tool</div>'),m+="</div></div>",this.container.innerHTML=m,this.container.querySelectorAll(".tc-tool-row").forEach(k=>{k.addEventListener("click",()=>{const E=k.dataset.tool;this.selectedTool=this.selectedTool===E?null:E,this.render()})});const x=this.container.querySelector(".tc-clear-filter");x&&x.addEventListener("click",k=>{k.stopPropagation(),this.selectedTool=null,this.render()})}fmtMs(t){return t<1e3?`${t}ms`:t<6e4?`${(t/1e3).toFixed(1)}s`:`${Math.round(t/6e4)}m`}shortName(t){if(t.startsWith("mcp__")){const e=t.split("__");return e[e.length-1].slice(0,18)}return t.length>18?t.slice(0,16)+"..":t}esc(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}}const qo={pending:"#a78bfa",in_progress:"#38bdf8",completed:"#4ade80",deleted:"#f87171"},Vo={pending:"○",in_progress:"◔",completed:"✓",deleted:"✕"},fi=210,qn=56,Fb=50,Vn=12,Yo=16;class Nb{constructor(t,e){b(this,"container");b(this,"data",null);b(this,"visible",!1);b(this,"onSnapshot");this.store=t,this.container=document.createElement("div"),this.container.id="taskgraph-content",this.container.style.display="none",e.appendChild(this.container),this.onSnapshot=s=>{this.data=s,this.visible&&this.render()},this.store.on("taskgraph:snapshot",this.onSnapshot)}destroy(){this.store.off("taskgraph:snapshot",this.onSnapshot),this.container.remove()}show(){this.visible=!0,this.container.style.display="",this.store.requestTaskGraph(),this.render()}hide(){this.visible=!1,this.container.style.display="none"}render(){if(!this.data||this.data.tasks.length===0){this.container.innerHTML='<div class="tg-empty">No tasks created yet</div>';return}const t=this.data.tasks.filter(c=>c.status!=="deleted");if(t.length===0){this.container.innerHTML='<div class="tg-empty">No tasks created yet</div>';return}const e=c=>c._rootKey??c.id,s=new Map(t.map(c=>[e(c),c])),n=new Set;for(const c of t){const p=c.blockedBy.some(m=>s.has(m)),g=c.blocks.some(m=>s.has(m));if(p||g){n.add(e(c));for(const m of c.blockedBy)s.has(m)&&n.add(m);for(const m of c.blocks)s.has(m)&&n.add(m)}}const o=t.filter(c=>!n.has(e(c))),r=t.filter(c=>n.has(e(c))),l={in_progress:0,pending:1,completed:2,deleted:3};o.sort((c,p)=>{const g=(l[c.status]??9)-(l[p.status]??9);return g!==0?g:parseInt(c.id)-parseInt(p.id)});const h={pending:0,in_progress:0,completed:0};for(const c of t)c.status in h&&h[c.status]++;let d="";if(d+='<div class="tg-summary">',h.in_progress>0&&(d+=`<span class="tg-badge tg-badge-active">${h.in_progress} active</span>`),h.pending>0&&(d+=`<span class="tg-badge tg-badge-pending">${h.pending} pending</span>`),h.completed>0&&(d+=`<span class="tg-badge tg-badge-done">${h.completed} done</span>`),d+=`<span class="tg-total">${t.length} total</span>`,d+="</div>",o.length>0){d+='<div class="tg-standalone">';for(const c of o){const p=qo[c.status]??qo.pending,g=Vo[c.status]??Vo.pending;d+=`<div class="tg-row" style="--sc:${p}">`,d+=`<span class="tg-row-icon" style="color:${p}">${g}</span>`,d+=`<span class="tg-row-subj">${pi(c.subject)}</span>`,d+=this.renderRowTags(c),d+=`<span class="tg-row-id">#${pi(c.id)}</span>`,d+="</div>"}d+="</div>"}if(r.length>0){const c=this.findClusters(r,s,e);for(const p of c)d+=this.renderCluster(p,s,e)}this.container.innerHTML=d}renderCluster(t,e,s){const n=new Map(t.map(c=>[s(c),c])),o=this.layoutCluster(t,n,s),r=new Map(o.map(c=>[s(c.task),c])),l=Math.max(...o.map(c=>c.x+fi))+Yo,h=Math.max(...o.map(c=>c.y+qn))+Yo;let d='<div class="tg-cluster">';d+=`<svg class="tg-svg" width="${l}" height="${h}" viewBox="0 0 ${l} ${h}">`,d+='<defs><marker id="tg-arr" viewBox="0 0 10 8" refX="10" refY="4" markerWidth="7" markerHeight="5" orient="auto-start-reverse"><path d="M0,0 L10,4 L0,8 Z" fill="#666"/></marker></defs>';for(const c of o)for(const p of c.task.blockedBy){const g=r.get(p);if(!g)continue;const m=g.x+fi/2,y=g.y+qn,x=c.x+fi/2,w=c.y,k=Math.max((w-y)*.4,12);d+=`<path class="tg-edge" d="M${m},${y} C${m},${y+k} ${x},${w-k} ${x},${w}" marker-end="url(#tg-arr)"/>`}for(const c of o){const p=c.task,g=qo[p.status]??qo.pending,m=Vo[p.status]??Vo.pending;d+='<g class="tg-node">',d+=`<rect x="${c.x}" y="${c.y}" width="${fi}" height="${qn}" rx="5" class="tg-node-bg"/>`,d+=`<rect x="${c.x}" y="${c.y}" width="3" height="${qn}" rx="1" fill="${g}"/>`,d+=`<text x="${c.x+12}" y="${c.y+18}" class="tg-node-icon" fill="${g}">${m}</text>`,d+=`<text x="${c.x+fi-7}" y="${c.y+16}" class="tg-node-id" text-anchor="end">#${pi(p.id)}</text>`,d+=`<text x="${c.x+25}" y="${c.y+18}" class="tg-node-subj">${pi(Oc(p.subject,24))}</text>`;const y=this.nodeInfoText(p);y&&(d+=`<text x="${c.x+12}" y="${c.y+38}" class="tg-node-info">${pi(Oc(y,28))}</text>`),d+="</g>"}return d+="</svg></div>",d}findClusters(t,e,s){const n=new Set(t.map(l=>s(l))),o=new Set,r=[];for(const l of t){const h=s(l);if(o.has(h))continue;const d=[],c=[h];for(o.add(h);c.length>0;){const p=c.shift(),g=e.get(p);if(g){d.push(g);for(const m of[...g.blockedBy,...g.blocks])n.has(m)&&!o.has(m)&&(o.add(m),c.push(m))}}r.push(d)}return r}layoutCluster(t,e,s){const n=new Map,o=(g,m)=>{if(n.has(g))return n.get(g);if(m.has(g))return 0;m.add(g);const y=e.get(g);if(!y||y.blockedBy.filter(k=>e.has(k)).length===0)return n.set(g,0),0;let x=0;for(const k of y.blockedBy)e.has(k)&&(x=Math.max(x,o(k,m)));const w=x+1;return n.set(g,w),w};for(const g of t)o(s(g),new Set);const r=Math.max(0,...n.values()),l=Array.from({length:r+1},()=>[]);for(const g of t)l[n.get(s(g))??0].push(g);const h={in_progress:0,pending:1,completed:2,deleted:3};for(const g of l)g.sort((m,y)=>{const x=(h[m.status]??9)-(h[y.status]??9);return x!==0?x:parseInt(m.id)-parseInt(y.id)});for(let g=1;g<l.length;g++){const m=new Map;l[g-1].forEach((y,x)=>m.set(s(y),x)),l[g].sort((y,x)=>Wc(y,m)-Wc(x,m))}const c=Math.max(...l.map(g=>g.length))*(fi+Vn)-Vn,p=[];for(let g=0;g<l.length;g++){const m=l[g],y=m.length*(fi+Vn)-Vn,x=Yo+(c-y)/2,w=Yo+g*(qn+Fb);for(let k=0;k<m.length;k++)p.push({task:m[k],x:x+k*(fi+Vn),y:w})}return p}nodeInfoText(t){const e=[];return t.projectName&&e.push(t.projectName),t.agentName&&t.agentName!==t.projectName&&e.push(t.agentName),t.owner&&t.owner!==t.agentName&&e.push(t.owner),e.join(" · ")}renderRowTags(t){let e="";return t.projectName&&(e+=`<span class="tg-row-tag">${pi(t.projectName)}</span>`),t.agentName&&t.agentName!==t.projectName&&(e+=`<span class="tg-row-tag">${pi(t.agentName)}</span>`),t.owner&&t.owner!==t.agentName&&(e+=`<span class="tg-row-tag">${pi(t.owner)}</span>`),e}}function Wc(i,t,e){const s=[];for(const n of i.blockedBy){const o=t.get(n);o!==void 0&&s.push(o)}return s.length===0?999:s.reduce((n,o)=>n+o,0)/s.length}function pi(i){return i.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Oc(i,t){return i.length>t?i.slice(0,t-1)+"…":i}class Gb{constructor(t){b(this,"container");b(this,"store");b(this,"permissions",[]);b(this,"onPermRequestBound");b(this,"onPermResolvedBound");this.store=t,this.container=document.createElement("div"),this.container.id="permission-panel",this.container.setAttribute("role","alertdialog"),this.container.setAttribute("aria-label","Permission requests"),document.body.appendChild(this.container),this.onPermRequestBound=e=>{this.permissions.push(e),this.render()},this.onPermResolvedBound=({permissionId:e})=>{this.permissions=this.permissions.filter(s=>s.permissionId!==e),this.render()},t.on("permission:request",this.onPermRequestBound),t.on("permission:resolved",this.onPermResolvedBound)}render(){var e;if(this.permissions.length===0){this.container.classList.remove("visible"),this.container.innerHTML="";return}this.container.classList.add("visible");let t=`<div class="perm-header">
694
- <span class="perm-badge">${this.permissions.length}</span>
695
- Permission Request${this.permissions.length>1?"s":""}
696
- </div>`;for(const s of this.permissions){const n=s.toolName==="AskUserQuestion",o=s.toolName==="ExitPlanMode",r=Math.round((Date.now()-s.timestamp)/1e3),l=r<60?`${r}s ago`:`${Math.round(r/60)}m ago`;t+=`<div class="perm-card" data-id="${this.esc(s.permissionId)}">`,t+='<div class="perm-tool">',t+=`<span class="perm-tool-name">${this.esc(s.toolName)}</span>`,t+=`<span class="perm-time">${l}</span>`,t+="</div>",n?t+=this.renderAskQuestion(s):o?t+=this.renderPlanReview(s):t+=this.renderToolInput(s),o&&(t+='<textarea class="perm-answer perm-feedback" placeholder="Optional feedback..." rows="2"></textarea>'),t+='<div class="perm-actions">',!n&&!o&&((e=s.permissionSuggestions)!=null&&e.length)&&(t+=`<button class="perm-btn perm-always" data-action="always" data-id="${this.esc(s.permissionId)}">Always Allow</button>`),t+=`<button class="perm-btn perm-approve" data-action="approve" data-id="${this.esc(s.permissionId)}">Approve</button>`,t+=`<button class="perm-btn perm-deny" data-action="deny" data-id="${this.esc(s.permissionId)}">Deny</button>`,t+="</div>",t+="</div>"}this.container.innerHTML=t,this.wireActions()}renderToolInput(t){const e=t.toolInput;if(!e)return"";const s=e,n=s.command??s.file_path??s.pattern??s.query??s.url??s.prompt;if(n){const l=n.length>200?n.slice(0,197)+"...":n;return`<div class="perm-preview"><code>${this.esc(l)}</code></div>`}const o=JSON.stringify(e,null,2),r=o.length>300?o.slice(0,297)+"...":o;return`<div class="perm-preview"><code>${this.esc(r)}</code></div>`}renderAskQuestion(t){const e=t.toolInput;if(!e)return"";const s=e.questions;if(!(s!=null&&s.length))return"";let n='<div class="perm-question">';for(const o of s)n+=`<p class="perm-q-text">${this.esc(o)}</p>`;return n+='<textarea class="perm-answer" placeholder="Type your answer..." rows="2"></textarea>',n+="</div>",n}renderPlanReview(t){const e=t.toolInput;if(!e)return'<div class="perm-preview">Plan review requested</div>';const s=e.plan??e.content??"";if(s){const n=s.length>500?s.slice(0,497)+"...":s;return`<div class="perm-preview perm-plan"><pre>${this.esc(n)}</pre></div>`}return'<div class="perm-preview">Plan review requested</div>'}wireActions(){this.container.querySelectorAll(".perm-btn").forEach(t=>{t.addEventListener("click",e=>{const s=e.currentTarget,n=s.dataset.action,o=s.dataset.id,r=s.closest(".perm-card");if(n==="approve"){const l=r==null?void 0:r.querySelector(".perm-answer:not(.perm-feedback)"),h=r==null?void 0:r.querySelector(".perm-feedback");l!=null&&l.value?this.store.approvePermission(o,{answer:l.value}):h!=null&&h.value?this.store.approvePermission(o,{userFeedback:h.value}):this.store.approvePermission(o)}else if(n==="deny")this.store.denyPermission(o);else if(n==="always"){const l=this.permissions.find(d=>d.permissionId===o),h=(l==null?void 0:l.permissionSuggestions)??[];this.store.approvePermissionAlways(o,h)}})})}esc(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}dispose(){this.store.off("permission:request",this.onPermRequestBound),this.store.off("permission:resolved",this.onPermResolvedBound),this.container.remove()}}const Wb=50;let Ob=0;class Hb{constructor(t){b(this,"container");b(this,"store");b(this,"_customizationLookup",null);b(this,"notifications",[]);b(this,"visible",!1);b(this,"badgeEl");b(this,"onPermRequestBound");b(this,"onAnomalyBound");b(this,"onTaskBound");b(this,"onSpawnBound");b(this,"onShutdownBound");this.store=t,this.badgeEl=document.createElement("span"),this.badgeEl.id="notif-badge",this.badgeEl.className="notif-badge",this.badgeEl.style.display="none",this.container=document.createElement("div"),this.container.id="notification-panel",this.container.style.display="none",document.body.appendChild(this.container),this.onPermRequestBound=e=>this.addPermission(e),this.onAnomalyBound=e=>this.addAnomaly(e),this.onTaskBound=({taskSubject:e})=>this.addTask(e),this.onSpawnBound=e=>this.push({kind:"lifecycle",priority:"low",agentId:e.id,message:" spawned"}),this.onShutdownBound=e=>{var o,r;const s=t.getAgent(e),n=s?((r=(o=this._customizationLookup)==null?void 0:o.call(this,s))==null?void 0:r.displayName)||s.agentName||s.projectName||s.sessionId.slice(0,10):e.slice(0,10);this.push({kind:"lifecycle",priority:"low",message:`${n} shut down`})},t.on("permission:request",this.onPermRequestBound),t.on("anomaly:alert",this.onAnomalyBound),t.on("task:completed",this.onTaskBound),t.on("agent:spawn",this.onSpawnBound),t.on("agent:shutdown",this.onShutdownBound)}setCustomizationLookup(t){this._customizationLookup=t}getBadgeElement(){return this.badgeEl}toggle(){this.visible=!this.visible,this.container.style.display=this.visible?"":"none",this.visible&&this.render()}addPermission(t){this.push({kind:"permission",priority:"urgent",message:`Permission: ${t.toolName}`,detail:this.summarizeInput(t.toolInput)})}addAnomaly(t){this.push({kind:"anomaly",priority:t.severity==="critical"?"urgent":"high",agentId:t.agentId,message:`: ${t.message}`})}addTask(t){this.push({kind:"task",priority:"normal",message:`Task completed: ${t}`})}resolveName(t){var s,n;const e=this.store.getAgent(t);return e?((n=(s=this._customizationLookup)==null?void 0:s.call(this,e))==null?void 0:n.displayName)||e.agentName||e.projectName||e.sessionId.slice(0,10):t.slice(0,10)}push(t){const e={id:`n${++Ob}`,...t,timestamp:Date.now()};this.notifications.unshift(e),this.notifications.length>Wb&&this.notifications.pop(),this.updateBadge(),this.visible&&this.render()}updateBadge(){const t=this.notifications.filter(e=>e.priority==="urgent"||e.priority==="high").length;t>0?(this.badgeEl.textContent=String(t),this.badgeEl.style.display=""):this.badgeEl.style.display="none"}render(){if(this.notifications.length===0){this.container.innerHTML='<div class="notif-empty">No notifications</div>';return}let t='<div class="notif-header">Notifications <button class="notif-clear">Clear</button></div>';t+='<div class="notif-list">';for(const s of this.notifications){const n=this.formatAge(s.timestamp),o=s.agentId?this.resolveName(s.agentId)+s.message:s.message;t+=`<div class="notif-item notif-${this.esc(s.priority)} notif-${this.esc(s.kind)}">`,t+=`<span class="notif-icon">${this.icon(s.kind)}</span>`,t+=`<span class="notif-msg">${this.esc(o)}</span>`,s.detail&&(t+=`<span class="notif-detail">${this.esc(s.detail)}</span>`),t+=`<span class="notif-age">${n}</span>`,t+="</div>"}t+="</div>",this.container.innerHTML=t;const e=this.container.querySelector(".notif-clear");e==null||e.addEventListener("click",()=>{this.notifications=[],this.updateBadge(),this.render()},{once:!0})}icon(t){switch(t){case"permission":return"🔒";case"failure":return"❌";case"anomaly":return"⚠️";case"task":return"✅";case"lifecycle":return"🟢"}}formatAge(t){const e=Math.round((Date.now()-t)/1e3);return e<60?`${e}s`:e<3600?`${Math.round(e/60)}m`:`${Math.round(e/3600)}h`}summarizeInput(t){if(!t)return;const e=t,s=e.command??e.file_path??e.pattern??e.query;if(s)return s.length>80?s.slice(0,77)+"...":s}esc(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}dispose(){this.store.off("permission:request",this.onPermRequestBound),this.store.off("anomaly:alert",this.onAnomalyBound),this.store.off("task:completed",this.onTaskBound),this.store.off("agent:spawn",this.onSpawnBound),this.store.off("agent:shutdown",this.onShutdownBound),this.container.remove(),this.badgeEl.remove()}}const Hc=200,Ub=["all","spawn","tool","idle","shutdown","permission","anomaly","task"],qb=200;class Vb{constructor(t,e){b(this,"container");b(this,"toolbarEl");b(this,"searchInput");b(this,"filtersEl");b(this,"agentSelect");b(this,"clearBtn");b(this,"listEl");b(this,"store");b(this,"entries",[]);b(this,"visible",!1);b(this,"autoScroll",!0);b(this,"_customizationLookup",null);b(this,"searchQuery","");b(this,"activeKind","all");b(this,"activeAgent","");b(this,"debounceTimer",null);b(this,"boundListeners",[]);this.store=t,this.container=document.createElement("div"),this.container.id="activity-feed",this.container.style.display="none",e.appendChild(this.container),this.toolbarEl=document.createElement("div"),this.toolbarEl.className="feed-toolbar",this.container.appendChild(this.toolbarEl),this.searchInput=document.createElement("input"),this.searchInput.type="text",this.searchInput.className="feed-search",this.searchInput.placeholder="Search feed…",this.searchInput.addEventListener("input",()=>this.onSearchInput()),this.toolbarEl.appendChild(this.searchInput),this.filtersEl=document.createElement("div"),this.filtersEl.className="feed-filters";for(const n of Ub){const o=document.createElement("button");o.className=`feed-chip${n==="all"?" active":""}`,o.textContent=n.charAt(0).toUpperCase()+n.slice(1),o.dataset.kind=n,o.addEventListener("click",()=>this.onChipClick(n)),this.filtersEl.appendChild(o)}this.toolbarEl.appendChild(this.filtersEl),this.agentSelect=document.createElement("select"),this.agentSelect.className="feed-agent-select",this.agentSelect.innerHTML='<option value="">All Agents</option>',this.agentSelect.addEventListener("change",()=>{this.activeAgent=this.agentSelect.value,this.applyFilters()}),this.toolbarEl.appendChild(this.agentSelect),this.clearBtn=document.createElement("button"),this.clearBtn.className="feed-chip",this.clearBtn.textContent="Clear",this.clearBtn.addEventListener("click",()=>this.clearFilters()),this.toolbarEl.appendChild(this.clearBtn),this.listEl=document.createElement("div"),this.listEl.className="feed-list",this.container.appendChild(this.listEl),this.listEl.addEventListener("scroll",()=>{const{scrollTop:n,scrollHeight:o,clientHeight:r}=this.listEl;this.autoScroll=o-n-r<40});const s=(n,o)=>{t.on(n,o),this.boundListeners.push({event:n,fn:o})};s("state:reset",n=>{for(const[,o]of n)this.add("spawn",this.agentHtml(o,"connected"),this.name(o));this.refreshAgentDropdown()}),s("agent:spawn",n=>this.add("spawn",this.agentHtml(n,"spawned"),this.name(n))),s("agent:update",n=>{n.currentTool&&this.add("tool",`<span class="feed-name">${this.esc(this.name(n))}</span> using <strong>${this.esc(n.currentTool)}</strong>${n.currentActivity?` — <span class="feed-dim">${this.esc(n.currentActivity.slice(0,60))}</span>`:""}`,this.name(n))}),s("agent:idle",n=>this.add("idle",this.agentHtml(n,"idle"),this.name(n))),s("agent:shutdown",n=>{const o=this.store.getAgent(n),r=o?this.name(o):n.slice(0,10);this.add("shutdown",`<span class="feed-name">${this.esc(r)}</span> shut down`,r)}),s("permission:request",n=>this.add("permission",`🔒 Permission request: <strong>${this.esc(n.toolName)}</strong>`,"")),s("permission:resolved",({permissionId:n,decision:o})=>this.add("permission",`🔓 Permission ${o}: <span class="feed-dim">${this.esc(n.slice(0,8))}</span>`,"")),s("anomaly:alert",n=>this.add("anomaly",`⚠️ ${this.esc(n.agentName)}: ${this.esc(n.message)}`,n.agentName)),s("task:completed",({taskSubject:n})=>this.add("task",`✅ Task completed: ${this.esc(n)}`,"")),s("hooks:status",()=>this.add("hooks","Hook event received",""))}setCustomizationLookup(t){this._customizationLookup=t}show(){this.visible=!0,this.container.style.display="flex",this.container.style.flexDirection="column",this.refreshAgentDropdown(),this.applyFilters()}hide(){this.visible=!1,this.container.style.display="none"}add(t,e,s){const n=e.replace(/<[^>]*>/g,"");if(this.entries.push({timestamp:Date.now(),html:e,kind:t,agentName:s,rawText:n}),this.entries.length>Hc&&this.entries.shift(),this.visible){const o=this.entries[this.entries.length-1];this.matchesFilters(o)&&this.appendEntry(o)}}matchesFilters(t){return!(this.activeKind!=="all"&&t.kind!==this.activeKind||this.activeAgent&&t.agentName!==this.activeAgent||this.searchQuery&&!t.rawText.toLowerCase().includes(this.searchQuery))}appendEntry(t){const e=document.createElement("div");e.className=`feed-entry feed-${t.kind}`;let s=t.html;for(this.searchQuery&&(s=this.highlightHtml(s,this.searchQuery)),e.innerHTML=`<span class="feed-time">${this.formatTime(t.timestamp)}</span> ${s}`,this.listEl.appendChild(e);this.listEl.children.length>Hc;)this.listEl.removeChild(this.listEl.firstChild);this.autoScroll&&(this.listEl.scrollTop=this.listEl.scrollHeight)}highlightHtml(t,e){const s=t.split(/(<[^>]*>)/),n=e.toLowerCase();for(let o=0;o<s.length;o++)o%2===0&&s[o]&&(s[o]=this.highlightText(s[o],n));return s.join("")}highlightText(t,e){const s=t.toLowerCase();let n="",o=0,r=s.indexOf(e,o);for(;r!==-1;)n+=t.slice(o,r),n+=`<mark>${t.slice(r,r+e.length)}</mark>`,o=r+e.length,r=s.indexOf(e,o);return n+=t.slice(o),n}applyFilters(){this.listEl.innerHTML="";for(const t of this.entries)if(this.matchesFilters(t)){const e=document.createElement("div");e.className=`feed-entry feed-${t.kind}`;let s=t.html;this.searchQuery&&(s=this.highlightHtml(s,this.searchQuery)),e.innerHTML=`<span class="feed-time">${this.formatTime(t.timestamp)}</span> ${s}`,this.listEl.appendChild(e)}this.autoScroll&&(this.listEl.scrollTop=this.listEl.scrollHeight)}onSearchInput(){this.debounceTimer&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(()=>{this.searchQuery=this.searchInput.value.trim().toLowerCase(),this.applyFilters()},qb)}onChipClick(t){this.activeKind=t,this.filtersEl.querySelectorAll(".feed-chip").forEach(s=>{const n=s;n.classList.toggle("active",n.dataset.kind===t)}),this.applyFilters()}clearFilters(){this.searchQuery="",this.searchInput.value="",this.activeKind="all",this.activeAgent="",this.agentSelect.value="",this.filtersEl.querySelectorAll(".feed-chip").forEach(e=>{const s=e;s.classList.toggle("active",s.dataset.kind==="all")}),this.applyFilters()}refreshAgentDropdown(){const t=this.store.getAgents(),e=this.agentSelect.value;this.agentSelect.innerHTML='<option value="">All Agents</option>';const s=new Set;for(const[,n]of t){const o=n.agentName||n.projectName||n.sessionId.slice(0,10);if(!s.has(o)){s.add(o);const r=document.createElement("option");r.value=o,r.textContent=o,this.agentSelect.appendChild(r)}}for(const n of this.entries)if(n.agentName&&!s.has(n.agentName)){s.add(n.agentName);const o=document.createElement("option");o.value=n.agentName,o.textContent=n.agentName,this.agentSelect.appendChild(o)}e&&(this.agentSelect.value=e,this.agentSelect.value||(this.activeAgent=""))}agentHtml(t,e){return`<span class="feed-name">${this.esc(this.name(t))}</span> ${e}`}name(t){return this._customizationLookup?this._customizationLookup(t).displayName:t.agentName||t.projectName||t.sessionId.slice(0,10)}formatTime(t){const e=new Date(t);return`${String(e.getHours()).padStart(2,"0")}:${String(e.getMinutes()).padStart(2,"0")}:${String(e.getSeconds()).padStart(2,"0")}`}esc(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}destroy(){this.debounceTimer&&clearTimeout(this.debounceTimer);for(const{event:t,fn:e}of this.boundListeners)this.store.off(t,e);this.boundListeners=[],this.container.remove()}}const Uc={files:"#34d399",terminal:"#fb923c",search:"#60a5fa",web:"#f59e0b",thinking:"#a78bfa",messaging:"#38bdf8",tasks:"#f472b6",idle:"#6b7280",spawn:"#6b7280"},qc=500,ps=28,Yn=2,Re=32,de=120,Yb=300*1e3,jb=1e4,Xb=30*6e4;class Zb{constructor(t,e){b(this,"container");b(this,"canvas");b(this,"ctx");b(this,"tooltip");b(this,"visible",!1);b(this,"spans",[]);b(this,"agentLanes",[]);b(this,"agentNames",new Map);b(this,"agentCurrentTool",new Map);b(this,"_customizationLookup",null);b(this,"viewEndTime",Date.now());b(this,"viewWindowMs",Yb);b(this,"autoScroll",!0);b(this,"animFrame",null);b(this,"resizeObserver",null);b(this,"onSpawn");b(this,"onUpdate");b(this,"onIdle");b(this,"onShutdown");b(this,"onReset");b(this,"handleMouseMove",t=>{const e=this.hitTest(t.clientX,t.clientY);if(e){const s=(e.endTime??Date.now())-e.startTime;let n=`${this.shortToolName(e.toolName)}
697
- `;n+=`Duration: ${this.fmtDuration(s)}
698
- `,n+=`Zone: ${e.zone}`,e.outcome&&(n+=`
699
- Outcome: ${e.outcome}`),this.tooltip.textContent=n,this.tooltip.style.display="";const o=this.container.getBoundingClientRect(),r=t.clientX-o.left+12,l=t.clientY-o.top-10;this.tooltip.style.left=`${Math.min(r,this.container.clientWidth-200)}px`,this.tooltip.style.top=`${l}px`,this.canvas.style.cursor="pointer"}else this.tooltip.style.display="none",this.canvas.style.cursor="crosshair"});b(this,"handleMouseLeave",()=>{this.tooltip.style.display="none",this.canvas.style.cursor="crosshair"});b(this,"handleClick",t=>{const e=this.hitTest(t.clientX,t.clientY);if(e){const s=(e.endTime??Date.now())-e.startTime;let n=`Tool: ${e.toolName}
700
- `;n+=`Agent: ${e.agentName}
701
- `,n+=`Zone: ${e.zone}
702
- `,n+=`Duration: ${this.fmtDuration(s)}
703
- `,n+=`Start: ${new Date(e.startTime).toLocaleTimeString()}
704
- `,e.endTime?n+=`End: ${new Date(e.endTime).toLocaleTimeString()}
705
- `:n+=`Status: In progress
706
- `,e.outcome&&(n+=`Outcome: ${e.outcome}
707
- `),e.toolInput&&(n+=`
708
- Input:
709
- ${e.toolInput}`),this.tooltip.textContent=n,this.tooltip.style.display="";const o=this.container.getBoundingClientRect(),r=t.clientX-o.left+12,l=t.clientY-o.top-10;this.tooltip.style.left=`${Math.min(r,this.container.clientWidth-200)}px`,this.tooltip.style.top=`${Math.max(l,4)}px`}});b(this,"handleWheel",t=>{t.preventDefault();const e=this.canvas.getBoundingClientRect(),s=t.clientX-e.left;if(t.ctrlKey||t.metaKey||Math.abs(t.deltaY)>Math.abs(t.deltaX)){const n=t.deltaY>0?1.15:.87,o=Math.max(jb,Math.min(Xb,this.viewWindowMs*n)),r=this.container.clientWidth-de,l=Math.max(0,(s-de)/r),d=this.viewEndTime-this.viewWindowMs+l*this.viewWindowMs;this.viewWindowMs=o,this.viewEndTime=d+(1-l)*o,this.autoScroll=!1}else{const n=t.deltaX/(this.container.clientWidth-de)*this.viewWindowMs;this.viewEndTime+=n,this.autoScroll=!1}Math.abs(this.viewEndTime-Date.now())<2e3&&(this.autoScroll=!0)});this.store=t,this.container=document.createElement("div"),this.container.id="waterfall-content",this.container.style.cssText="display:none;position:relative;width:100%;height:100%;overflow:hidden;",e.appendChild(this.container),this.canvas=document.createElement("canvas"),this.canvas.style.cssText="width:100%;display:block;cursor:crosshair;",this.container.appendChild(this.canvas),this.ctx=this.canvas.getContext("2d"),this.tooltip=document.createElement("div"),this.tooltip.style.cssText="display:none;position:absolute;pointer-events:none;background:#1e1e2e;border:1px solid #444;border-radius:4px;padding:6px 10px;color:#e0e0e0;font-size:11px;line-height:1.4;z-index:100;max-width:320px;white-space:pre-wrap;word-break:break-all;",this.container.appendChild(this.tooltip),this.onSpawn=s=>this.handleSpawn(s),this.onUpdate=s=>this.handleUpdate(s),this.onIdle=s=>this.handleIdle(s),this.onShutdown=s=>this.handleShutdown(s),this.onReset=s=>this.handleReset(s),this.store.on("agent:spawn",this.onSpawn),this.store.on("agent:update",this.onUpdate),this.store.on("agent:idle",this.onIdle),this.store.on("agent:shutdown",this.onShutdown),this.store.on("state:reset",this.onReset),this.canvas.addEventListener("mousemove",this.handleMouseMove),this.canvas.addEventListener("mouseleave",this.handleMouseLeave),this.canvas.addEventListener("click",this.handleClick),this.canvas.addEventListener("wheel",this.handleWheel,{passive:!1}),this.resizeObserver=new ResizeObserver(()=>this.updateCanvasSize()),this.resizeObserver.observe(this.container);for(const[,s]of this.store.getAgents())this.ensureLane(s)}setCustomizationLookup(t){this._customizationLookup=t;for(const[e]of this.agentNames){const s=this.store.getAgent(e);s&&this.agentNames.set(e,this.resolveDisplayName(s))}}resolveDisplayName(t){return this._customizationLookup?this._customizationLookup(t).displayName:t.agentName??t.projectName??t.id.slice(0,8)}show(){this.visible=!0,this.container.style.display="",this.autoScroll=!0,this.updateCanvasSize(),this.startRenderLoop()}hide(){this.visible=!1,this.container.style.display="none",this.stopRenderLoop(),this.tooltip.style.display="none"}destroy(){var t;this.store.off("agent:spawn",this.onSpawn),this.store.off("agent:update",this.onUpdate),this.store.off("agent:idle",this.onIdle),this.store.off("agent:shutdown",this.onShutdown),this.store.off("state:reset",this.onReset),this.canvas.removeEventListener("mousemove",this.handleMouseMove),this.canvas.removeEventListener("mouseleave",this.handleMouseLeave),this.canvas.removeEventListener("click",this.handleClick),this.canvas.removeEventListener("wheel",this.handleWheel),(t=this.resizeObserver)==null||t.disconnect(),this.stopRenderLoop(),this.container.remove()}ensureLane(t){this.agentLanes.includes(t.id)||this.agentLanes.push(t.id),this.agentNames.set(t.id,this.resolveDisplayName(t))}handleSpawn(t){this.ensureLane(t),this.agentCurrentTool.set(t.id,null),this.updateCanvasSize()}handleUpdate(t){this.ensureLane(t);const e=this.agentCurrentTool.get(t.id)??null,s=t.currentTool;if(s!==e){const n=Date.now();this.closeOpenSpan(t.id,n,t.lastToolOutcome),s&&this.openSpan(t,s,n),this.agentCurrentTool.set(t.id,s)}}handleIdle(t){const e=Date.now();this.closeOpenSpan(t.id,e,t.lastToolOutcome),this.agentCurrentTool.set(t.id,null)}handleShutdown(t){const e=Date.now();this.closeOpenSpan(t,e,null),this.agentCurrentTool.delete(t)}handleReset(t){this.spans=[],this.agentLanes=[],this.agentNames.clear(),this.agentCurrentTool.clear();for(const[,e]of t)this.ensureLane(e);this.updateCanvasSize()}openSpan(t,e,s){const n={agentId:t.id,agentName:this.agentNames.get(t.id)??this.resolveDisplayName(t),toolName:e,zone:t.currentZone,startTime:s,endTime:null,outcome:null,toolInput:t.currentActivity?t.currentActivity.slice(0,200):null};this.spans.push(n),this.trimSpans()}closeOpenSpan(t,e,s){for(let n=this.spans.length-1;n>=0;n--){const o=this.spans[n];if(o.agentId===t&&o.endTime===null){o.endTime=e,o.outcome=s;break}}}trimSpans(){this.spans.length>qc&&this.spans.splice(0,this.spans.length-qc)}updateCanvasSize(){const t=this.container.clientWidth,e=Math.max(this.agentLanes.length,1),s=Re+e*(ps+Yn)+8,n=window.devicePixelRatio||1;this.canvas.width=t*n,this.canvas.height=s*n,this.canvas.style.height=`${s}px`,this.ctx.setTransform(n,0,0,n,0,0)}startRenderLoop(){if(this.animFrame!==null)return;const t=()=>{this.visible&&(this.draw(),this.animFrame=requestAnimationFrame(t))};this.animFrame=requestAnimationFrame(t)}stopRenderLoop(){this.animFrame!==null&&(cancelAnimationFrame(this.animFrame),this.animFrame=null)}draw(){const t=this.ctx,e=this.container.clientWidth,s=Math.max(this.agentLanes.length,1),n=Re+s*(ps+Yn)+8;Math.abs(parseFloat(this.canvas.style.height)-n)>1&&this.updateCanvasSize(),this.autoScroll&&(this.viewEndTime=Date.now());const o=this.viewEndTime-this.viewWindowMs,r=e-de;t.fillStyle="#111827",t.fillRect(0,0,e,n),t.fillStyle="#1f2937",t.fillRect(0,0,e,Re),t.strokeStyle="#374151",t.lineWidth=1,t.beginPath(),t.moveTo(0,Re),t.lineTo(e,Re),t.stroke();const l=this.pickGridInterval(),h=Math.ceil(o/l)*l;t.font="10px monospace",t.textAlign="center",t.textBaseline="middle";for(let d=h;d<=this.viewEndTime;d+=l){const c=de+(d-o)/this.viewWindowMs*r;t.strokeStyle="#1f2937",t.beginPath(),t.moveTo(c,Re),t.lineTo(c,n),t.stroke(),t.fillStyle="#9ca3af",t.fillText(this.formatTime(d),c,Re/2)}t.textAlign="right",t.textBaseline="middle",t.font="11px sans-serif";for(let d=0;d<this.agentLanes.length;d++){const c=this.agentLanes[d],p=this.agentNames.get(c)??c.slice(0,8),g=Re+d*(ps+Yn);t.fillStyle=d%2===0?"#111827":"#0f172a",t.fillRect(0,g,e,ps);const m=this.store.getAgent(c),y=m?ft[m.colorIndex%ft.length]:null;t.fillStyle=y?`#${y.body.toString(16).padStart(6,"0")}`:"#9ca3af";const x=p.length>14?p.slice(0,12)+"..":p;t.fillText(x,de-8,g+ps/2)}t.strokeStyle="#374151",t.beginPath(),t.moveTo(de,0),t.lineTo(de,n),t.stroke();for(const d of this.spans){const c=d.endTime??Date.now();if(c<o||d.startTime>this.viewEndTime)continue;const p=this.agentLanes.indexOf(d.agentId);if(p<0)continue;const g=Math.max(d.startTime,o),m=Math.min(c,this.viewEndTime),y=de+(g-o)/this.viewWindowMs*r,x=de+(m-o)/this.viewWindowMs*r,w=Math.max(x-y,2),k=Re+p*(ps+Yn)+3,E=ps-6,B=Uc[d.zone]??Uc.thinking;if(t.fillStyle=B,t.globalAlpha=d.endTime===null?.7:.85,t.beginPath(),this.roundRect(t,y,k,w,E,3),t.fill(),t.globalAlpha=1,d.outcome&&(t.strokeStyle=d.outcome==="success"?"#22c55e":"#ef4444",t.lineWidth=1.5,t.beginPath(),this.roundRect(t,y,k,w,E,3),t.stroke()),d.endTime===null){const L=.4+.6*Math.abs(Math.sin(Date.now()/600));t.strokeStyle=`rgba(255,255,255,${L*.5})`,t.lineWidth=1,t.beginPath(),this.roundRect(t,y,k,w,E,3),t.stroke()}if(w>40){t.fillStyle="#ffffff",t.font="9px monospace",t.textAlign="left",t.textBaseline="middle";const L=this.shortToolName(d.toolName),H=Math.floor((w-6)/5.5),$=L.length>H?L.slice(0,H-1)+"..":L;t.fillText($,y+4,k+E/2)}}if(this.autoScroll){const d=de+r;t.strokeStyle="#ef4444",t.lineWidth=1,t.setLineDash([3,3]),t.beginPath(),t.moveTo(d,Re),t.lineTo(d,n),t.stroke(),t.setLineDash([])}this.spans.length===0&&(t.fillStyle="#6b7280",t.font="13px sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText("No tool spans recorded yet",e/2,n/2))}roundRect(t,e,s,n,o,r){r=Math.min(r,n/2,o/2),t.moveTo(e+r,s),t.lineTo(e+n-r,s),t.arcTo(e+n,s,e+n,s+r,r),t.lineTo(e+n,s+o-r),t.arcTo(e+n,s+o,e+n-r,s+o,r),t.lineTo(e+r,s+o),t.arcTo(e,s+o,e,s+o-r,r),t.lineTo(e,s+r),t.arcTo(e,s,e+r,s,r),t.closePath()}pickGridInterval(){const t=[1e3,2e3,5e3,1e4,15e3,3e4,6e4,12e4,3e5,6e5],e=this.container.clientWidth-de,s=60;for(const n of t)if(n/this.viewWindowMs*e>=s)return n;return 6e5}formatTime(t){const e=new Date(t),s=e.getHours().toString().padStart(2,"0"),n=e.getMinutes().toString().padStart(2,"0"),o=e.getSeconds().toString().padStart(2,"0");return`${s}:${n}:${o}`}shortToolName(t){if(t.startsWith("mcp__")){const e=t.split("__");return e[e.length-1]}return t}hitTest(t,e){const s=this.canvas.getBoundingClientRect(),n=t-s.left,o=e-s.top;if(n<de||o<Re)return null;const r=this.viewEndTime-this.viewWindowMs,l=this.container.clientWidth-de;for(let h=this.spans.length-1;h>=0;h--){const d=this.spans[h],c=d.endTime??Date.now();if(c<r||d.startTime>this.viewEndTime)continue;const p=this.agentLanes.indexOf(d.agentId);if(p<0)continue;const g=Math.max(d.startTime,r),m=Math.min(c,this.viewEndTime),y=de+(g-r)/this.viewWindowMs*l,x=de+(m-r)/this.viewWindowMs*l,w=Math.max(x-y,2),k=Re+p*(ps+Yn)+3,E=ps-6;if(n>=y&&n<=y+w&&o>=k&&o<=k+E)return d}return null}fmtDuration(t){if(t<1e3)return`${t}ms`;if(t<6e4)return`${(t/1e3).toFixed(1)}s`;const e=Math.floor(t/6e4),s=Math.floor(t%6e4/1e3);return`${e}m ${s}s`}}const mi=20,Kb=25,Qb=120,Jb=4e3,t_=.005,Vc=.9,Ma=3,Yc=.01,jc={running:"#4caf50",idle:"#9e9e9e",compacting:"#9c27b0"},e_={main:"MAIN",subagent:"SUB","team-lead":"LEAD"};function s_(i){return"#"+i.toString(16).padStart(6,"0")}function i_(i,t){return i.length>t?i.slice(0,t-1)+"…":i}class n_{constructor(t,e){b(this,"container");b(this,"canvas");b(this,"ctx");b(this,"nodes",new Map);b(this,"edges",[]);b(this,"animFrame",null);b(this,"visible",!1);b(this,"messageAnimT",0);b(this,"store");b(this,"_customizationLookup",null);b(this,"listeners",[]);b(this,"onClick",t=>{const e=this.canvas.getBoundingClientRect(),s=t.clientX-e.left,n=t.clientY-e.top;let o=null,r=Kb;for(const l of this.nodes.values()){const h=l.x-s,d=l.y-n,c=Math.sqrt(h*h+d*d);c<r&&(r=c,o=l)}o&&this.canvas.dispatchEvent(new CustomEvent("node-click",{detail:{agentId:o.id},bubbles:!0}))});this.store=t,this.container=document.createElement("div"),this.container.id="relationship-content",this.container.style.display="none",this.container.style.width="100%",this.container.style.height="100%",this.container.style.position="relative",this.canvas=document.createElement("canvas"),this.canvas.style.width="100%",this.canvas.style.height="100%",this.canvas.style.display="block",this.container.appendChild(this.canvas),e.appendChild(this.container);const s=this.canvas.getContext("2d");if(!s)throw new Error("Canvas 2D not supported");this.ctx=s,this.canvas.addEventListener("click",this.onClick),new ResizeObserver(()=>this.resizeCanvas()).observe(this.container);const o=(r,l)=>{t.on(r,l),this.listeners.push({event:r,fn:l})};o("state:reset",()=>this.rebuildFromStore()),o("agent:spawn",()=>this.rebuildFromStore()),o("agent:update",()=>this.rebuildFromStore()),o("agent:idle",()=>this.rebuildFromStore()),o("agent:shutdown",()=>this.rebuildFromStore())}setCustomizationLookup(t){this._customizationLookup=t;for(const[e,s]of this.nodes){const n=this.store.getAgent(e);n&&(s.label=this.resolveDisplayName(n),s.colorIndex=this.resolveColorIndex(n))}}resolveDisplayName(t){return this._customizationLookup?this._customizationLookup(t).displayName:t.agentName??t.projectName??t.id.slice(0,8)}resolveColorIndex(t){return this._customizationLookup?this._customizationLookup(t).colorIndex:t.colorIndex}show(){this.visible=!0,this.container.style.display="block",this.resizeCanvas(),this.rebuildFromStore(),this.startLoop()}hide(){this.visible=!1,this.container.style.display="none",this.stopLoop()}destroy(){this.stopLoop(),this.canvas.removeEventListener("click",this.onClick);for(const{event:t,fn:e}of this.listeners)this.store.off(t,e);this.listeners.length=0,this.container.remove()}resizeCanvas(){const t=this.container.getBoundingClientRect(),e=window.devicePixelRatio||1;this.canvas.width=t.width*e,this.canvas.height=t.height*e,this.ctx.setTransform(e,0,0,e,0,0)}rebuildFromStore(){const t=this.store.getAgents(),e=new Set;for(const[s,n]of t){e.add(s);let o=this.nodes.get(s);if(o)o.phase=n.phase,o.role=n.role,o.parentId=n.parentId,o.teamName=n.teamName,o.messageTarget=n.messageTarget,o.label=this.resolveDisplayName(n),o.colorIndex=this.resolveColorIndex(n),o.agentName=n.agentName;else{const r=this.canvas.width/(window.devicePixelRatio||1)/2,l=this.canvas.height/(window.devicePixelRatio||1)/2;o={id:s,label:this.resolveDisplayName(n),x:r+(Math.random()-.5)*100,y:l+(Math.random()-.5)*100,vx:0,vy:0,colorIndex:this.resolveColorIndex(n),phase:n.phase,role:n.role,parentId:n.parentId,teamName:n.teamName,messageTarget:n.messageTarget,agentName:n.agentName},this.nodes.set(s,o)}}for(const s of this.nodes.keys())e.has(s)||this.nodes.delete(s);this.rebuildEdges()}rebuildEdges(){this.edges=[];const t=Array.from(this.nodes.values());for(const s of t)s.parentId&&this.nodes.has(s.parentId)&&this.edges.push({source:s.parentId,target:s.id,kind:"parent-child"});const e=new Map;for(const s of t)if(s.teamName){let n=e.get(s.teamName);n||(n=[],e.set(s.teamName,n)),n.push(s.id)}for(const s of e.values())for(let n=0;n<s.length;n++)for(let o=n+1;o<s.length;o++)this.edges.some(l=>l.kind==="parent-child"&&(l.source===s[n]&&l.target===s[o]||l.source===s[o]&&l.target===s[n]))||this.edges.push({source:s[n],target:s[o],kind:"teammate"});for(const s of t)if(s.messageTarget){const n=t.find(o=>o.agentName===s.messageTarget);n&&this.edges.push({source:s.id,target:n.id,kind:"message"})}}startLoop(){if(this.animFrame!==null)return;const t=()=>{this.visible&&(this.simulate(),this.draw(),this.messageAnimT=(this.messageAnimT+.02)%1,this.animFrame=requestAnimationFrame(t))};this.animFrame=requestAnimationFrame(t)}stopLoop(){this.animFrame!==null&&(cancelAnimationFrame(this.animFrame),this.animFrame=null)}simulate(){const t=Array.from(this.nodes.values());if(t.length===0)return;const e=this.canvas.width/(window.devicePixelRatio||1),s=this.canvas.height/(window.devicePixelRatio||1),n=e/2,o=s/2;for(let l=0;l<t.length;l++)for(let h=l+1;h<t.length;h++){const d=t[l],c=t[h],p=c.x-d.x,g=c.y-d.y,m=Math.sqrt(p*p+g*g)||1,y=Jb/(m*m),x=p/m*y,w=g/m*y;d.vx-=x,d.vy-=w,c.vx+=x,c.vy+=w}const r=new Set;for(const l of this.edges){const h=this.nodes.get(l.source),d=this.nodes.get(l.target);if(!h||!d)continue;r.add(l.source),r.add(l.target);const c=d.x-h.x,p=d.y-h.y,g=Math.sqrt(c*c+p*p)||1,m=g-Qb,y=t_*m,x=c/g*y,w=p/g*y;h.vx+=x,h.vy+=w,d.vx-=x,d.vy-=w}for(const l of t)l.vx+=(n-l.x)*Yc,l.vy+=(o-l.y)*Yc;for(const l of t){l.vx*=Vc,l.vy*=Vc;const h=Math.sqrt(l.vx*l.vx+l.vy*l.vy);h>Ma&&(l.vx=l.vx/h*Ma,l.vy=l.vy/h*Ma),l.x+=l.vx,l.y+=l.vy,l.x=Math.max(mi,Math.min(e-mi,l.x)),l.y=Math.max(mi+15,Math.min(s-mi-15,l.y))}}draw(){const t=this.canvas.width/(window.devicePixelRatio||1),e=this.canvas.height/(window.devicePixelRatio||1),s=this.ctx;s.clearRect(0,0,t,e);for(const n of this.edges){const o=this.nodes.get(n.source),r=this.nodes.get(n.target);if(!(!o||!r)&&(s.beginPath(),s.moveTo(o.x,o.y),s.lineTo(r.x,r.y),n.kind==="teammate"?(s.setLineDash([6,4]),s.strokeStyle="#666",s.lineWidth=1.5):n.kind==="message"?(s.setLineDash([]),s.strokeStyle="#ff9800",s.lineWidth=2):(s.setLineDash([]),s.strokeStyle="#888",s.lineWidth=1.5),s.stroke(),s.setLineDash([]),n.kind==="message")){const l=this.messageAnimT;for(let h=0;h<3;h++){const d=(l+h*.33)%1,c=o.x+(r.x-o.x)*d,p=o.y+(r.y-o.y)*d;s.beginPath(),s.arc(c,p,3,0,Math.PI*2),s.fillStyle="#ffcc80",s.fill()}}}for(const n of this.nodes.values()){const o=ft[n.colorIndex%ft.length],r=s_(o.body),l=jc[n.phase]??jc.idle;s.beginPath(),s.arc(n.x,n.y,mi+3,0,Math.PI*2),s.strokeStyle=l,s.lineWidth=3,s.stroke(),s.beginPath(),s.arc(n.x,n.y,mi,0,Math.PI*2),s.fillStyle=r,s.fill();const h=e_[n.role];h&&(s.font="9px monospace",s.textAlign="center",s.fillStyle="#aaa",s.fillText(h,n.x,n.y-mi-8)),s.font="11px sans-serif",s.textAlign="center",s.fillStyle="#ddd",s.fillText(i_(n.label,12),n.x,n.y+mi+14)}}}class o_{constructor(t){b(this,"el");b(this,"currentAgentId",null);b(this,"hideTimer",null);b(this,"store");b(this,"onFocus",null);b(this,"onDetail",null);this.store=t,this.el=document.createElement("div"),this.el.id="agent-hover-bar",this.el.innerHTML=`
710
- <button class="ahb-btn ahb-focus" title="Focus camera">
711
- <svg viewBox="0 0 24 24" width="12" height="12" fill="currentColor"><circle cx="12" cy="12" r="3"/><path d="M12 2a10 10 0 100 20 10 10 0 000-20zm0 18a8 8 0 110-16 8 8 0 010 16z"/></svg>
712
- </button>
713
- <button class="ahb-btn ahb-detail" title="View details">
714
- <svg viewBox="0 0 24 24" width="12" height="12" fill="currentColor"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"/></svg>
715
- </button>
716
- <button class="ahb-btn ahb-approve" title="Approve pending" style="display:none">
717
- <svg viewBox="0 0 24 24" width="12" height="12" fill="currentColor"><path d="M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4z"/></svg>
718
- </button>
719
- <button class="ahb-btn ahb-copy" title="Copy session ID">
720
- <svg viewBox="0 0 24 24" width="12" height="12" fill="currentColor"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg>
721
- </button>
722
- `,document.body.appendChild(this.el),this.el.addEventListener("mouseenter",()=>{this.hideTimer&&(clearTimeout(this.hideTimer),this.hideTimer=null)}),this.el.addEventListener("mouseleave",()=>{this.scheduleHide()}),this.el.querySelector(".ahb-focus").addEventListener("click",e=>{e.stopPropagation(),this.currentAgentId&&this.onFocus&&this.onFocus(this.currentAgentId)}),this.el.querySelector(".ahb-detail").addEventListener("click",e=>{e.stopPropagation(),this.currentAgentId&&this.onDetail&&this.onDetail(this.currentAgentId)}),this.el.querySelector(".ahb-approve").addEventListener("click",e=>{if(e.stopPropagation(),!this.currentAgentId)return;const s=this.store.getAgent(this.currentAgentId);if(!s)return;const n=this.store.getPendingPermissions();for(const o of n)o.sessionId===s.sessionId&&this.store.approvePermission(o.permissionId)}),this.el.querySelector(".ahb-copy").addEventListener("click",e=>{if(e.stopPropagation(),!this.currentAgentId)return;const s=this.store.getAgent(this.currentAgentId);s&&navigator.clipboard.writeText(s.sessionId).catch(()=>{})})}setFocusHandler(t){this.onFocus=t}setDetailHandler(t){this.onDetail=t}show(t,e,s){this.hideTimer&&(clearTimeout(this.hideTimer),this.hideTimer=null),this.currentAgentId=t;const n=this.store.getAgent(t),o=this.el.querySelector(".ahb-approve");if(n){const l=this.store.getPendingPermissions().some(h=>h.sessionId===n.sessionId);o.style.display=l?"":"none"}this.el.style.left=`${e}px`,this.el.style.top=`${s-60}px`,this.el.classList.add("visible")}hide(){this.scheduleHide()}scheduleHide(){this.hideTimer||(this.hideTimer=setTimeout(()=>{this.el.classList.remove("visible"),this.currentAgentId=null,this.hideTimer=null},300))}dispose(){this.hideTimer&&clearTimeout(this.hideTimer),this.el.remove()}}async function r_(){const i=document.getElementById("app"),t=await w0(i),e=new Ka;Q1();const s=new dy(t),n=new B1(t,s,e),o=new dl,r=new W1;n.setSoundManager(o),n.setNotificationManager(r);const l=new eb(e),h=new sb,d=new $1(e),c=new D1(e);d.setAgentClickHandler(ht=>{c.open(ht),ut(ht)}),n.setClickHandler(ht=>{c.open(ht),ut(ht)});const p=new o_(e);p.setFocusHandler(ht=>ut(ht)),p.setDetailHandler(ht=>{c.open(ht),ut(ht)}),n.setHoverHandler((ht,Lt,Mt)=>{if(ht){const Jt=s.root,po=Lt*Jt.scale.x+Jt.x,zu=Mt*Jt.scale.y+Jt.y,Ll=t.canvas.getBoundingClientRect();p.show(ht,po+Ll.left,zu+Ll.top)}else p.hide()});const g=new G1(e);g.setReplayCallback(ht=>{n.rebuildFromState(ht)});const m=new q1(e);let y=!0;const x=document.getElementById("right-panel-content"),w=document.getElementById("overlay"),k=document.getElementById("right-panel-title"),E=new Z1(e,x),B=new mb(e,x),L=new zb(e,x),H=new Nb(e,x),$=new Db,G=new Vb(e,x),tt=new Zb(e,x),Z=new n_(e,x),X=new Gb(e),Q=new Hb(e),ot=new ul(e),at=new rb,lt=new ab(e);new lb;const Bt=new ub;s.addEffect(Bt.container);const et=new fb(s.camera,(ht,Lt)=>{s.camera.panTo(ht,Lt)}),it=new gb,vt=ht=>it.getCustomDisplay(ht);n.setCustomizationLookup(vt),c.setCustomizationLookup(vt),d.setCustomizationLookup(vt),B.setCustomizationLookup(vt),E.setCustomizationLookup(vt),tt.setCustomizationLookup(vt),Z.setCustomizationLookup(vt),G.setCustomizationLookup(vt),ot.setCustomizationLookup(vt),Q.setCustomizationLookup(vt),g.setCustomizationLookup(vt),lt.setCustomizationLookup(vt),it.setChangeHandler((ht,Lt)=>{n.applyCustomization(ht,Lt.displayName,Lt.colorIndex),c.currentAgentId===ht&&c.refreshHeader(Lt.displayName),d.scheduleRender()}),c.setCustomizeHandler(ht=>{it.open(ht)}),t.canvas.addEventListener("contextmenu",ht=>{ht.preventDefault()}),t.canvas.addEventListener("dblclick",ht=>{const Lt=t.canvas.getBoundingClientRect(),Mt=ht.clientX-Lt.left,Jt=ht.clientY-Lt.top;$.addAnnotationFromScreen(Mt,Jt)});const rt=new $b;s.applyTheme(rt.current);const bt=document.getElementById("theme-select");bt.value=rt.current.id,bt.addEventListener("change",()=>rt.setTheme(bt.value)),rt.onChange(ht=>{s.applyTheme(ht),bt.value=ht.id});let At=!1;function It(){if(At&&n.focusedAgentId){const ht=n.getFocusedAgentName()||"Agent";l.showFocus(ht)}else l.hideFocus()}function ut(ht){n.setFocusAgent(ht),At=!0,It()}function Gt(){At=!1,n.setFocusAgent(null),It()}let Xt=null;function Te(){return Xt||(Xt=document.getElementById("zone-heatmap")),Xt}document.getElementById("focus-stop").addEventListener("click",Gt);let Vt=Il("activeTab","monitor");const Ie={analytics:{show:()=>E.show(),hide:()=>E.hide(),title:"Analytics"},leaderboard:{show:()=>B.show(),hide:()=>B.hide(),title:"Leaderboard"},toolchain:{show:()=>L.show(),hide:()=>L.hide(),title:"Tool Chains"},taskgraph:{show:()=>H.show(),hide:()=>H.hide(),title:"Task Graph"},activity:{show:()=>G.show(),hide:()=>G.hide(),title:"Activity Feed"},waterfall:{show:()=>tt.show(),hide:()=>tt.hide(),title:"Waterfall"},graph:{show:()=>Z.show(),hide:()=>Z.hide(),title:"Agent Graph"}};function We(ht){var Lt;if(fr("activeTab",ht),(Lt=Ie[Vt])==null||Lt.hide(),Vt=ht,ht==="monitor")w.style.display="",x.style.display="none",k.textContent="Agents";else{c.isOpen()&&c.close(),w.style.display="none",x.style.display="";const Mt=Ie[ht];k.textContent=(Mt==null?void 0:Mt.title)??ht,Mt==null||Mt.show()}}h.setTabChangeHandler(ht=>{We(ht)}),Vt!=="monitor"&&h.setActiveTab(Vt),document.getElementById("right-panel");function ve(ht){h.setActiveTab(Vt===ht?"monitor":ht)}function Zi(ht,Lt){switch(ht){case"focus-zone":{const Mt=Lt?Zt.get(Lt):null;Mt&&s.camera.panTo(Mt.x+Mt.width/2,Mt.y+Mt.height/2);break}case"focus-agent":Lt&&(c.open(Lt),ut(Lt));break;case"reset-camera":s.resetCamera();break;case"zoom-in":s.camera.zoomIn();break;case"zoom-out":s.camera.zoomOut();break;case"toggle-mute":o.init(),o.muted=!o.muted,Sn();break;case"toggle-heatmap":y=!y;{const Mt=Te();Mt&&(Mt.style.display=y?"block":"none")}break;case"toggle-shortcuts":at.toggle();break;case"toggle-focus":At?Gt():(n.cycleNextAgent(),At=!!n.focusedAgentId,It());break;case"cycle-focus":At?n.cycleNextAgent()||Gt():(n.cycleNextAgent(),At=!!n.focusedAgentId),It();break;case"exit-focus":At&&Gt();break;case"session-export":lt.toggle();break;case"toggle-trails":Bt.toggle();break;case"toggle-daynight":s.dayNight.toggle();break;case"toggle-minimap":et.toggle();break;case"cycle-theme":rt.cycleNext();break;case"toggle-annotations":$.toggle();break;case"toggle-sidebar":h.toggle();break;case"toggle-analytics":ve("analytics");break;case"toggle-leaderboard":ve("leaderboard");break;case"toggle-toolchain":ve("toolchain");break;case"toggle-taskgraph":ve("taskgraph");break;case"toggle-activity":ve("activity");break;case"toggle-waterfall":ve("waterfall");break;case"toggle-graph":ve("graph");break}}const je=new Y1(e,Zi);je.setCustomizationLookup(vt),e.on("agent:shutdown",ht=>{Bt.removeAgent(ht)});const Xe=new k0(e);Xe.connect(),document.getElementById("zoom-in").addEventListener("click",()=>s.camera.zoomIn()),document.getElementById("zoom-out").addEventListener("click",()=>s.camera.zoomOut()),document.getElementById("zoom-reset").addEventListener("click",()=>s.resetCamera());const Oe=document.getElementById("mute-btn"),Ze=document.getElementById("volume-slider");function Sn(){Oe.textContent=o.muted||o.volume===0?"🔇":"🔈",Oe.classList.toggle("muted",o.muted||o.volume===0)}Oe.addEventListener("click",()=>{o.init(),o.muted=!o.muted,Sn()}),Ze.addEventListener("input",()=>{o.init(),o.volume=Number(Ze.value)/100,o.muted&&o.volume>0&&(o.muted=!1),Sn()});const kn=document.getElementById("notif-btn");kn.appendChild(Q.getBadgeElement()),kn.addEventListener("click",()=>{Q.toggle()}),document.getElementById("shortcuts-btn").addEventListener("click",()=>{at.toggle()}),document.getElementById("cmd-hint").addEventListener("click",()=>{je.toggle()}),document.addEventListener("click",()=>{o.init(),r.requestPermission()},{once:!0});const wr={a:"toggle-analytics",h:"toggle-heatmap",m:"toggle-mute",f:"cycle-focus",e:"session-export",Escape:"exit-focus",t:"toggle-trails",n:"toggle-daynight","`":"toggle-minimap",l:"toggle-leaderboard",p:"cycle-theme",o:"toggle-annotations",c:"toggle-toolchain",g:"toggle-taskgraph",v:"toggle-activity",w:"toggle-waterfall",r:"toggle-graph","[":"toggle-sidebar"};document.addEventListener("keydown",ht=>{var Jt;const Lt=(Jt=ht.target)==null?void 0:Jt.tagName;if(Lt==="INPUT"||Lt==="TEXTAREA"||Lt==="SELECT"||ht.ctrlKey||ht.metaKey||ht.altKey)return;const Mt=wr[ht.key];Mt&&Zi(Mt)}),window.addEventListener("beforeunload",()=>{Xe.disconnect(),n.dispose(),d.dispose(),c.dispose(),g.dispose(),E.dispose(),B.dispose(),l.dispose(),ot.dispose(),Q.dispose(),X.dispose(),tt.destroy(),G.destroy(),et.dispose(),e.dispose()}),t.ticker.add(()=>{const ht=t.ticker.deltaMS;n.update(ht),s.update(ht);const Lt=s.root;if(y&&m.updateTransform(Lt.x,Lt.y,Lt.scale.x),$.updateTransform(Lt.x,Lt.y,Lt.scale.x),At){const Mt=n.getFocusedAgentPosition();Mt&&s.camera.smoothFollow(Mt.x,Mt.y)}if(Bt.enabled){const Mt=new Map;for(const Jt of n.getAgentPositions()){const po=ft[Jt.colorIndex%ft.length];Mt.set(Jt.id,po.body),Bt.recordPosition(Jt.id,Jt.x,Jt.y,ht,po.body)}Bt.update(ht,Mt)}if(et.visible){const Mt=s.camera.getViewport(),Jt=n.getAgentPositions();et.render(Jt,Mt)}}),console.log("AgentMove started")}r_().catch(console.error);export{yr as $,Ud as A,ao as B,Kt as C,Pe as D,as as E,_s as F,_r as G,yl as H,Wd as I,Ge as J,Rd as K,Ya as L,wt as M,wm as N,km as O,pe as P,Im as Q,Da as R,bl as S,$t as T,rr as U,Mm as V,tf as W,Rm as X,ke as Y,ad as Z,Ne as _,Dd as a,jl as a0,Yi as a1,p0 as a2,Lf as a3,Zl as a4,Lr as a5,Kl as a6,Rf as a7,_n as a8,Yt as a9,cd as aa,zg as ab,qd as ac,Ct as ad,uo as ae,Ut as af,zp as ag,Lp as ah,nm as ai,Kp as aj,Sm as ak,Tm as al,Lm as am,Pm as an,Bm as ao,Pd as b,jp as c,we as d,qt as e,Dt as f,ip as g,jo as h,yt as i,Wt as j,Zm as k,Wm as l,hd as m,vr as n,_d as o,jt as p,un as q,mf as r,xr as s,Ft as t,pp as u,qp as v,xe as w,fo as x,dh as y,Xo as z};