@foothill/agent-move 1.0.11 → 1.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/packages/client/dist/assets/{BufferResource-Dl7AyA-b.js → BufferResource-Dhljy8H8.js} +1 -1
- package/packages/client/dist/assets/{CanvasRenderer-CoGUh0dQ.js → CanvasRenderer-Bpr11iOT.js} +1 -1
- package/packages/client/dist/assets/{Filter-DNvhyFhm.js → Filter-DL2yN3-o.js} +1 -1
- package/packages/client/dist/assets/{RenderTargetSystem-C8Ap8tmK.js → RenderTargetSystem-BTwylEdr.js} +1 -1
- package/packages/client/dist/assets/{WebGLRenderer-DGZDe07g.js → WebGLRenderer-wH1P7d1x.js} +1 -1
- package/packages/client/dist/assets/{WebGPURenderer-D3zU-ngm.js → WebGPURenderer-C7n8jUXC.js} +1 -1
- package/packages/client/dist/assets/{browserAll-Dw8CUBpx.js → browserAll-CgAMpWnT.js} +1 -1
- package/packages/client/dist/assets/index-DG7HqEmM.js +1338 -0
- package/packages/client/dist/assets/{index-edh-N9Dm.css → index-Nz5TZeB1.css} +1 -1
- package/packages/client/dist/assets/{webworkerAll-XKfx082n.js → webworkerAll-wrP2P1GC.js} +1 -1
- package/packages/client/dist/index.html +7 -2
- package/packages/server/dist/index.d.ts.map +1 -1
- package/packages/server/dist/index.js +954 -31
- package/packages/server/dist/index.js.map +1 -1
- package/packages/server/dist/routes/sessions-api.d.ts +5 -0
- package/packages/server/dist/routes/sessions-api.d.ts.map +1 -0
- package/packages/server/dist/routes/sessions-api.js +88 -0
- package/packages/server/dist/routes/sessions-api.js.map +1 -0
- package/packages/server/dist/state/activity-processor.d.ts.map +1 -1
- package/packages/server/dist/state/activity-processor.js +0 -2
- package/packages/server/dist/state/activity-processor.js.map +1 -1
- package/packages/server/dist/state/agent-state-manager.d.ts.map +1 -1
- package/packages/server/dist/state/agent-state-manager.js +3 -5
- package/packages/server/dist/state/agent-state-manager.js.map +1 -1
- package/packages/server/dist/state/identity-manager.d.ts.map +1 -1
- package/packages/server/dist/state/identity-manager.js +0 -3
- package/packages/server/dist/state/identity-manager.js.map +1 -1
- package/packages/server/dist/storage/session-recorder.d.ts +38 -0
- package/packages/server/dist/storage/session-recorder.d.ts.map +1 -0
- package/packages/server/dist/storage/session-recorder.js +941 -0
- package/packages/server/dist/storage/session-recorder.js.map +1 -0
- package/packages/server/dist/storage/session-store.d.ts +60 -0
- package/packages/server/dist/storage/session-store.d.ts.map +1 -0
- package/packages/server/dist/storage/session-store.js +330 -0
- package/packages/server/dist/storage/session-store.js.map +1 -0
- package/packages/server/dist/watcher/opencode/opencode-watcher.d.ts +15 -0
- package/packages/server/dist/watcher/opencode/opencode-watcher.d.ts.map +1 -1
- package/packages/server/dist/watcher/opencode/opencode-watcher.js +61 -4
- package/packages/server/dist/watcher/opencode/opencode-watcher.js.map +1 -1
- package/packages/server/dist/ws/broadcaster.d.ts.map +1 -1
- package/packages/server/dist/ws/broadcaster.js +3 -18
- package/packages/server/dist/ws/broadcaster.js.map +1 -1
- package/packages/shared/dist/constants/tools.d.ts +4 -0
- package/packages/shared/dist/constants/tools.d.ts.map +1 -1
- package/packages/shared/dist/constants/tools.js +4 -0
- package/packages/shared/dist/constants/tools.js.map +1 -1
- package/packages/shared/dist/index.d.ts +2 -1
- package/packages/shared/dist/index.d.ts.map +1 -1
- package/packages/shared/dist/index.js +1 -1
- package/packages/shared/dist/index.js.map +1 -1
- package/packages/shared/dist/types/session-record.d.ts +87 -0
- package/packages/shared/dist/types/session-record.d.ts.map +1 -0
- package/packages/shared/dist/types/session-record.js +2 -0
- package/packages/shared/dist/types/session-record.js.map +1 -0
- package/packages/shared/dist/types/websocket.d.ts +3 -0
- package/packages/shared/dist/types/websocket.d.ts.map +1 -1
- package/packages/client/dist/assets/index-F7EORPP_.js +0 -850
|
@@ -1,850 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/browserAll-Dw8CUBpx.js","assets/webworkerAll-XKfx082n.js","assets/Filter-DNvhyFhm.js","assets/WebGPURenderer-D3zU-ngm.js","assets/BufferResource-Dl7AyA-b.js","assets/RenderTargetSystem-C8Ap8tmK.js","assets/WebGLRenderer-DGZDe07g.js","assets/CanvasRenderer-CoGUh0dQ.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
var Yu=Object.defineProperty;var ju=(i,t,e)=>t in i?Yu(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var b=(i,t,e)=>ju(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 Xu="modulepreload",Zu=function(i){return"/"+i},Gl={},io=function(t,e,s){let n=Promise.resolve();if(e&&e.length>0){let r=function(d){return Promise.all(d.map(h=>Promise.resolve(h).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),c=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));n=r(e.map(d=>{if(d=Zu(d),d in Gl)return;Gl[d]=!0;const h=d.endsWith(".css"),p=h?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${p}`))return;const g=document.createElement("link");if(g.rel=h?"stylesheet":Xu,h||(g.as="script"),g.crossOrigin="",g.href=d,c&&g.setAttribute("nonce",c),document.head.appendChild(g),h)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 bt=(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))(bt||{});const za=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},_o=(i,t)=>za(i).priority??t,jt={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...i){return i.map(za).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(za).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)=>_o(r.value,e)-_o(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)=>_o(o,e)-_o(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))}},Ku={extension:{type:bt.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await io(()=>import("./browserAll-Dw8CUBpx.js"),__vite__mapDeps([0,1,2]))}},Qu={extension:{type:bt.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await io(()=>import("./webworkerAll-XKfx082n.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 sd(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Pr={exports:{}},Wl;function Ju(){return Wl||(Wl=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(c,d,h){this.fn=c,this.context=d,this.once=h||!1}function o(c,d,h,p,g){if(typeof h!="function")throw new TypeError("The listener must be a function");var m=new n(h,p||c,g),y=e?e+d:d;return c._events[y]?c._events[y].fn?c._events[y]=[c._events[y],m]:c._events[y].push(m):(c._events[y]=m,c._eventsCount++),c}function r(c,d){--c._eventsCount===0?c._events=new s:delete c._events[d]}function l(){this._events=new s,this._eventsCount=0}l.prototype.eventNames=function(){var d=[],h,p;if(this._eventsCount===0)return d;for(p in h=this._events)t.call(h,p)&&d.push(e?p.slice(1):p);return Object.getOwnPropertySymbols?d.concat(Object.getOwnPropertySymbols(h)):d},l.prototype.listeners=function(d){var h=e?e+d:d,p=this._events[h];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 h=e?e+d:d,p=this._events[h];return p?p.fn?1:p.length:0},l.prototype.emit=function(d,h,p,g,m,y){var _=e?e+d:d;if(!this._events[_])return!1;var w=this._events[_],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,h),!0;case 3:return w.fn.call(w.context,h,p),!0;case 4:return w.fn.call(w.context,h,p,g),!0;case 5:return w.fn.call(w.context,h,p,g,m),!0;case 6:return w.fn.call(w.context,h,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,h);break;case 3:w[B].fn.call(w[B].context,h,p);break;case 4:w[B].fn.call(w[B].context,h,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,h,p){return o(this,d,h,p,!1)},l.prototype.once=function(d,h,p){return o(this,d,h,p,!0)},l.prototype.removeListener=function(d,h,p,g){var m=e?e+d:d;if(!this._events[m])return this;if(!h)return r(this,m),this;var y=this._events[m];if(y.fn)y.fn===h&&(!g||y.once)&&(!p||y.context===p)&&r(this,m);else{for(var _=0,w=[],k=y.length;_<k;_++)(y[_].fn!==h||g&&!y[_].once||p&&y[_].context!==p)&&w.push(y[_]);w.length?this._events[m]=w.length===1?w[0]:w:r(this,m)}return this},l.prototype.removeAllListeners=function(d){var h;return d?(h=e?e+d:d,this._events[h]&&r(this,h)):(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})(Pr)),Pr.exports}var tf=Ju();const cs=sd(tf),ef=Math.PI*2,sf=180/Math.PI,nf=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 Ir.x=0,Ir.y=0,Ir}}const Ir=new pe;class xt{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,c=this.ty,d=1/(s*r+o*-n),h=t.x,p=t.y;return e.x=r*d*h+-o*d*p+(c*o-l*r)*d,e.y=s*d*p+-n*d*h+(-c*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,c=t.ty,d=e.a,h=e.b,p=e.c,g=e.d;return this.a=s*d+n*p,this.b=s*h+n*g,this.c=o*d+r*p,this.d=o*h+r*g,this.tx=l*d+c*p+e.tx,this.ty=l*h+c*g+e.ty,this}setTransform(t,e,s,n,o,r,l,c,d){return this.a=Math.cos(l+d)*o,this.b=Math.sin(l+d)*o,this.c=-Math.sin(l-c)*r,this.d=Math.cos(l-c)*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),c=Math.atan2(s,e),d=Math.abs(l+c);return d<1e-5||Math.abs(ef-d)<1e-5?(t.rotation=c,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=l,t.skew.y=c),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 xt;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 rf.identity()}static get shared(){return of.identity()}}const of=new xt,rf=new xt,Hi=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],Ui=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],Vi=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],qi=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],Fa=[],id=[],xo=Math.sign;function af(){for(let i=0;i<16;i++){const t=[];Fa.push(t);for(let e=0;e<16;e++){const s=xo(Hi[i]*Hi[e]+Vi[i]*Ui[e]),n=xo(Ui[i]*Hi[e]+qi[i]*Ui[e]),o=xo(Hi[i]*Vi[e]+Vi[i]*qi[e]),r=xo(Ui[i]*Vi[e]+qi[i]*qi[e]);for(let l=0;l<16;l++)if(Hi[l]===s&&Ui[l]===n&&Vi[l]===o&&qi[l]===r){t.push(l);break}}}for(let i=0;i<16;i++){const t=new xt;t.set(Hi[i],Ui[i],Vi[i],qi[i],0,0),id.push(t)}}af();const Rt={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=>Hi[i],uY:i=>Ui[i],vX:i=>Vi[i],vY:i=>qi[i],inv:i=>i&8?i&15:-i&7,add:(i,t)=>Fa[i][t],sub:(i,t)=>Fa[i][Rt.inv(t)],rotate180:i=>i^4,isVertical:i=>(i&3)===2,byDirection:(i,t)=>Math.abs(i)*2<=Math.abs(t)?t>=0?Rt.S:Rt.N:Math.abs(t)*2<=Math.abs(i)?i>0?Rt.E:Rt.W:t>0?i>0?Rt.SE:Rt.SW:i>0?Rt.NE:Rt.NW,matrixAppendRotationInv:(i,t,e=0,s=0,n=0,o=0)=>{const r=id[Rt.inv(t)],l=r.a,c=r.b,d=r.c,h=r.d,p=e-Math.min(0,l*n,d*o,l*n+d*o),g=s-Math.min(0,c*n,h*o,c*n+h*o),m=i.a,y=i.b,_=i.c,w=i.d;i.a=l*m+c*_,i.b=l*y+c*w,i.c=d*m+h*_,i.d=d*y+h*w,i.tx=p*m+g*_+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:c,y:d,width:h,height:p}=t;return e===Rt.E?(s.set(n+c,o+d,r,l),s):e===Rt.S?s.set(h-o-l+c,n+d,l,r):e===Rt.W?s.set(h-n-r+c,p-o-l+d,r,l):e===Rt.N?s.set(o+c,p-n-r+d,l,r):s.set(n+c,o+d,r,l)}},wo=[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,c=this.y,d=s*(1-n),h=s-d,p=l-d,g=l+o+d,m=c-d,y=c+r+d,_=l+h,w=l+o-h,k=c+h,E=c+r-h;return t>=p&&t<=g&&e>=m&&e<=y&&!(t>_&&t<w&&e>k&&e<E)}intersects(t,e){if(!e){const et=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=et)return!1;const j=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>j}const s=this.left,n=this.right,o=this.top,r=this.bottom;if(n<=s||r<=o)return!1;const l=wo[0].set(t.left,t.top),c=wo[1].set(t.left,t.bottom),d=wo[2].set(t.right,t.top),h=wo[3].set(t.right,t.bottom);if(d.x<=l.x||c.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(c,c),e.apply(d,d),e.apply(h,h),Math.max(l.x,c.x,d.x,h.x)<=s||Math.min(l.x,c.x,d.x,h.x)>=n||Math.max(l.y,c.y,d.y,h.y)<=o||Math.min(l.y,c.y,d.y,h.y)>=r))return!1;const g=p*(c.y-l.y),m=p*(l.x-c.x),y=g*s+m*o,_=g*n+m*o,w=g*s+m*r,k=g*n+m*r;if(Math.max(y,_,w,k)<=g*l.x+m*l.y||Math.min(y,_,w,k)>=g*h.x+m*h.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*h.x+B*h.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 Lr={default:-1};function Vt(i="default"){return Lr[i]===void 0&&(Lr[i]=-1),++Lr[i]}const Ol=new Set,Ut="8.0.0",lf="8.3.4",yn={quiet:!1,noColor:!1},At=((i,t,e=3)=>{if(yn.quiet||Ol.has(t))return;let s=new Error().stack;const n=`${t}
|
|
3
|
-
Deprecated since v${i}`,o=typeof console.groupCollapsed=="function"&&!yn.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))),Ol.add(t)});Object.defineProperties(At,{quiet:{get:()=>yn.quiet,set:i=>{yn.quiet=i},enumerable:!0,configurable:!1},noColor:{get:()=>yn.noColor,set:i=>{yn.noColor=i},enumerable:!0,configurable:!1}});const nd=()=>{};function kn(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 Hl(i){return!(i&i-1)&&!!i}function od(i){const t={};for(const e in i)i[e]!==void 0&&(t[e]=i[e]);return t}const Ul=Object.create(null);function cf(i){const t=Ul[i];return t===void 0&&(Ul[i]=Vt("resource")),t}const rd=class ad extends cs{constructor(t={}){super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,t={...ad.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){At(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=cf(t),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};rd.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let Tn=rd;const ld=class cd extends cs{constructor(t={}){super(),this.options=t,this._gpuData=Object.create(null),this._gcLastUsed=-1,this.uid=Vt("textureSource"),this._resourceType="textureSource",this._resourceId=Vt("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={...cd.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 Tn(od(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=Vt("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=Vt("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=Hl(this.pixelWidth)&&Hl(this.pixelHeight)}static test(t){throw new Error("Unimplemented")}};ld.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 He=ld;class wl extends He{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}}wl.extension=bt.TextureSource;const Vl=new xt;class hf{constructor(t,e){this.mapCoord=new xt,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&&(Vl.set(s.width/n.width,0,0,s.height/n.height,-n.x/n.width,-n.y/n.height),this.mapCoord.append(Vl));const o=t.source,r=this.uClampFrame,l=this.clampMargin/o._resolution,c=this.clampOffset/o._resolution;return r[0]=(t.frame.x+l+c)/o.width,r[1]=(t.frame.y+l+c)/o.height,r[2]=(t.frame.x+t.frame.width-l+c)/o.width,r[3]=(t.frame.y+t.frame.height-l+c)/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 Lt extends cs{constructor({source:t,label:e,frame:s,orig:n,trim:o,defaultAnchor:r,defaultBorders:l,rotate:c,dynamic:d}={}){if(super(),this.uid=Vt("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 He,this.noFrame=!s,s)this.frame.copyFrom(s);else{const{width:h,height:p}=this._source;this.frame.width=h,this.frame.height=p}this.orig=n||this.frame,this.trim=o,this.rotate=c??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 hf(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,c=e.height/n;let d=this.rotate;if(d){const h=l/2,p=c/2,g=o+h,m=r+p;d=Rt.add(d,Rt.NW),t.x0=g+h*Rt.uX(d),t.y0=m+p*Rt.uY(d),d=Rt.add(d,2),t.x1=g+h*Rt.uX(d),t.y1=m+p*Rt.uY(d),d=Rt.add(d,2),t.x2=g+h*Rt.uX(d),t.y2=m+p*Rt.uY(d),d=Rt.add(d,2),t.x3=g+h*Rt.uX(d),t.y3=m+p*Rt.uY(d)}else t.x0=o,t.y0=r,t.x1=o+l,t.y1=r,t.x2=o+l,t.y2=r+c,t.x3=o,t.y3=r+c}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 At(Ut,"Texture.baseTexture is now Texture.source"),this._source}}Lt.EMPTY=new Lt({label:"EMPTY",source:new He({label:"EMPTY"})});Lt.EMPTY.destroy=nd;Lt.WHITE=new Lt({source:new wl({resource:new Uint8Array([255,255,255,255]),width:1,height:1,alphaMode:"premultiply-alpha-on-upload",label:"WHITE"}),label:"WHITE"});Lt.WHITE.destroy=nd;function hd(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 ql=new xt;class Oe{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=ql,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=ql,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,c=o.c,d=o.d,h=o.tx,p=o.ty;let g=this.minX,m=this.minY,y=this.maxX,_=this.maxY,w=r*t+c*e+h,k=l*t+d*e+p;w<g&&(g=w),k<m&&(m=k),w>y&&(y=w),k>_&&(_=k),w=r*s+c*e+h,k=l*s+d*e+p,w<g&&(g=w),k<m&&(m=k),w>y&&(y=w),k>_&&(_=k),w=r*t+c*n+h,k=l*t+d*n+p,w<g&&(g=w),k<m&&(m=k),w>y&&(y=w),k>_&&(_=k),w=r*s+c*n+h,k=l*s+d*n+p,w<g&&(g=w),k<m&&(m=k),w>y&&(y=w),k>_&&(_=k),this.minX=g,this.minY=m,this.maxX=y,this.maxY=_}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,d,tx:h,ty:p}=t;let g=r*e+c*s+h,m=l*e+d*s+p;this.minX=g,this.minY=m,this.maxX=g,this.maxY=m,g=r*n+c*s+h,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+c*o+h,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+c*o+h,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 Oe(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,c=this.maxY;n||(n=this.matrix);const d=n.a,h=n.b,p=n.c,g=n.d,m=n.tx,y=n.ty;for(let _=e;_<s;_+=2){const w=t[_],k=t[_+1],E=d*w+p*k+m,B=h*w+g*k+y;o=E<o?E:o,r=B<r?B:r,l=E>l?E:l,c=B>c?B:c}this.minX=o,this.minY=r,this.maxX=l,this.maxY=c}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 df={grad:.9,turn:360,rad:360/(2*Math.PI)},hs=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},Ne=function(i,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),i>e?e:i>t?i:t},dd=function(i){return(i=isFinite(i)?i%360:0)>0?i:i+360},Yl=function(i){return{r:Ne(i.r,0,255),g:Ne(i.g,0,255),b:Ne(i.b,0,255),a:Ne(i.a)}},Br=function(i){return{r:Qt(i.r),g:Qt(i.g),b:Qt(i.b),a:Qt(i.a,3)}},uf=/^#([0-9a-f]{3,8})$/i,So=function(i){var t=i.toString(16);return t.length<2?"0"+t:t},ud=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}},fd=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),c=s*(1-(1-t+o)*e),d=o%6;return{r:255*[s,l,r,r,c,s][d],g:255*[c,s,s,l,r,r][d],b:255*[r,r,c,s,s,l][d],a:n}},jl=function(i){return{h:dd(i.h),s:Ne(i.s,0,100),l:Ne(i.l,0,100),a:Ne(i.a)}},Xl=function(i){return{h:Qt(i.h),s:Qt(i.s),l:Qt(i.l),a:Qt(i.a,3)}},Zl=function(i){return fd((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},no=function(i){return{h:(t=ud(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},ff=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,pf=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,mf=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,gf=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Na={string:[[function(i){var t=uf.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=mf.exec(i)||gf.exec(i);return t?t[2]!==t[4]||t[4]!==t[6]?null:Yl({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=ff.exec(i)||pf.exec(i);if(!t)return null;var e,s,n=jl({h:(e=t[1],s=t[2],s===void 0&&(s="deg"),Number(e)*(df[s]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return Zl(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 hs(t)&&hs(e)&&hs(s)?Yl({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(!hs(t)||!hs(e)||!hs(s))return null;var r=jl({h:Number(t),s:Number(e),l:Number(s),a:Number(o)});return Zl(r)},"hsl"],[function(i){var t=i.h,e=i.s,s=i.v,n=i.a,o=n===void 0?1:n;if(!hs(t)||!hs(e)||!hs(s))return null;var r=(function(l){return{h:dd(l.h),s:Ne(l.s,0,100),v:Ne(l.v,0,100),a:Ne(l.a)}})({h:Number(t),s:Number(e),v:Number(s),a:Number(o)});return fd(r)},"hsv"]]},Kl=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]},yf=function(i){return typeof i=="string"?Kl(i.trim(),Na.string):typeof i=="object"&&i!==null?Kl(i,Na.object):[null,void 0]},Rr=function(i,t){var e=no(i);return{h:e.h,s:Ne(e.s+100*t,0,100),l:e.l,a:e.a}},$r=function(i){return(299*i.r+587*i.g+114*i.b)/1e3/255},Ql=function(i,t){var e=no(i);return{h:e.h,s:e.s,l:Ne(e.l+100*t,0,100),a:e.a}},Ga=(function(){function i(t){this.parsed=yf(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($r(this.rgba),2)},i.prototype.isDark=function(){return $r(this.rgba)<.5},i.prototype.isLight=function(){return $r(this.rgba)>=.5},i.prototype.toHex=function(){return t=Br(this.rgba),e=t.r,s=t.g,n=t.b,r=(o=t.a)<1?So(Qt(255*o)):"","#"+So(e)+So(s)+So(n)+r;var t,e,s,n,o,r},i.prototype.toRgb=function(){return Br(this.rgba)},i.prototype.toRgbString=function(){return t=Br(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 Xl(no(this.rgba))},i.prototype.toHslString=function(){return t=Xl(no(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=ud(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 ss({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),ss(Rr(this.rgba,t))},i.prototype.desaturate=function(t){return t===void 0&&(t=.1),ss(Rr(this.rgba,-t))},i.prototype.grayscale=function(){return ss(Rr(this.rgba,-1))},i.prototype.lighten=function(t){return t===void 0&&(t=.1),ss(Ql(this.rgba,t))},i.prototype.darken=function(t){return t===void 0&&(t=.1),ss(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"?ss({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=no(this.rgba);return typeof t=="number"?ss({h:t,s:e.s,l:e.l,a:e.a}):Qt(e.h)},i.prototype.isEqual=function(t){return this.toHex()===ss(t).toHex()},i})(),ss=function(i){return i instanceof Ga?i:new Ga(i)},Jl=[],bf=function(i){i.forEach(function(t){Jl.indexOf(t)<0&&(t(Ga,Na),Jl.push(t))})};function vf(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,c,d=s[this.toHex()];if(d)return d;if(r!=null&&r.closest){var h=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 _=(l=h,c=o[y],Math.pow(l.r-c.r,2)+Math.pow(l.g-c.g,2)+Math.pow(l.b-c.b,2));_<p&&(p=_,g=y)}return g}},t.string.push([function(r){var l=r.toLowerCase(),c=l==="transparent"?"#0000":e[l];return c?new i(c).toRgb():null},"name"])}bf([vf]);const Cn=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=ss(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}};Cn.shared=new Cn;Cn._temp=new Cn;Cn.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let Kt=Cn;const _f={cullArea:null,cullable:!1,cullableChildren:!0};let Dr=0;const tc=500;function we(...i){Dr!==tc&&(Dr++,Dr===tc?console.warn("PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS."):console.warn("PixiJS Warning: ",...i))}const yo={_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 xf{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 wf{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 xf(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 Te=new wf;yo.register(Te);const Sf={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){At("v8.6.0","cacheAsBitmap is deprecated, use cacheAsTexture instead."),this.cacheAsTexture(i)}};function kf(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 Tf={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 c=this.children[l];c&&(n.push(c),c.parent=null)}kf(this.children,i,e);const r=this.renderGroup||this.parentRenderGroup;r&&r.removeChildren(n);for(let l=0;l<n.length;++l){const c=n[l];(o=c.parentRenderLayer)==null||o.detach(c),this.emit("childRemoved",c,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||At(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)}},Cf={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 ec{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 Af{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 Te.get(s.maskClass,t)}return t}returnMaskEffect(t){Te.return(t)}}const Wa=new Af;jt.handleByList(bt.MaskEffect,Wa._effectClasses);const Mf={_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),Wa.returnMaskEffect(t),this._maskEffect=null),i!=null&&(this._maskEffect=Wa.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 ec);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 ec),this._filterEffect.filterArea=i},get filterArea(){var i;return(i=this._filterEffect)==null?void 0:i.filterArea}},Ef={label:null,get name(){return At(Ut,"Container.name property has been removed, use Container.label instead"),this.label},set name(i){At(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}},xe=Te.getPool(xt),vs=Te.getPool(Oe),Pf=new xt,If={getFastGlobalBounds(i,t){t||(t=new Oe),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=vs.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(Pf).invert()),t.addBounds(s),vs.return(s)}else this.renderGroup&&(t.addBounds(s,this.relativeGroupTransform),vs.return(s))}};function pd(i,t,e){e.clear();let s,n;return i.parent?t?s=i.parent.worldTransform:(n=xe.get().identity(),s=Sl(i,n)):s=xt.IDENTITY,md(i,e,s,t),n&&xe.return(n),e.isValid||e.set(0,0,0,0),e}function md(i,t,e,s){var l,c;if(!i.visible||!i.measurable)return;let n;s?n=i.worldTransform:(i.updateLocalTransform(),n=xe.get(),n.appendFrom(i.localTransform,e));const o=t,r=!!i.effects.length;if(r&&(t=vs.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 h=0;h<i.children.length;h++)md(i.children[h],t,n,s)}if(r){for(let d=0;d<i.effects.length;d++)(c=(l=i.effects[d]).addBounds)==null||c.call(l,t);o.addBounds(t,xt.IDENTITY),vs.return(t)}s||xe.return(n)}function Sl(i,t){const e=i.parent;return e&&(Sl(e,t),e.updateLocalTransform(),t.append(e.localTransform)),t}function gd(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,c=e*o/255|0,d=s*r/255|0,h=n*l/255|0;return(c<<16)+(d<<8)+h}const sc=16777215;function ic(i,t){return i===sc?t:t===sc?i:gd(i,t)}function Jo(i){return((i&255)<<16)+(i&65280)+(i>>16&255)}const Lf={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 xt,t){if(t)return i.copyFrom(this.worldTransform);this.updateLocalTransform();const e=Sl(this,xe.get().identity());return i.appendFrom(this.localTransform,e),xe.return(e),i},getGlobalTint(i){if(i)return this.renderGroup?Jo(this.renderGroup.worldColor):this.parentRenderGroup?Jo(ic(this.localColor,this.parentRenderGroup.worldColor)):this.tint;let t=this.localColor,e=this.parent;for(;e;)t=ic(t,e.localColor),e=e.parent;return Jo(t)}};function yd(i,t,e){return t.clear(),e||(e=xt.IDENTITY),bd(i,t,e,i,!0),t.isValid||t.set(0,0,0,0),t}function bd(i,t,e,s,n){var c,d;let o;if(n)o=xe.get(),o=e.copyTo(o);else{if(!i.visible||!i.measurable)return;i.updateLocalTransform();const h=i.localTransform;o=xe.get(),o.appendFrom(h,e)}const r=t,l=!!i.effects.length;if(l&&(t=vs.get().clear()),i.boundsArea)t.addRect(i.boundsArea,o);else{i.renderPipeId&&(t.matrix=o,t.addBounds(i.bounds));const h=i.children;for(let p=0;p<h.length;p++)bd(h[p],t,o,s,!1)}if(l){for(let h=0;h<i.effects.length;h++)(d=(c=i.effects[h]).addLocalBounds)==null||d.call(c,t,s);r.addBounds(t,xt.IDENTITY),vs.return(t)}xe.return(o)}function vd(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&&vd(n,t)}return t.didChange}const Bf=new xt,Rf={_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 Oe});const i=this._localBoundsCacheData;return i.index=1,i.didChange=!1,i.data[0]!==this._didViewChangeTick&&(i.didChange=!0,i.data[0]=this._didViewChangeTick),vd(this,i),i.didChange&&yd(this,i.localBounds,Bf),i.localBounds},getBounds(i,t){return pd(this,i,t||new Oe)}},$f={_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}},Df={_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(zf))}};function zf(i,t){return i._zIndex-t._zIndex}const Ff={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(xe.get(),e);return t=s.apply(i,t),xe.return(s),t},toLocal(i,t,e,s){t&&(i=t.toGlobal(i,e,s));const n=this.getGlobalTransform(xe.get(),s);return e=n.applyInverse(i,e),xe.return(n),e}};class kl{constructor(){this.uid=Vt("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 Nf=0;class Gf{constructor(t){this._poolKeyHash=Object.create(null),this._texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this.textureStyle=new Tn(this.textureOptions)}createTexture(t,e,s,n){const o=new He({...this.textureOptions,width:t,height:e,resolution:1,antialias:s,autoGarbageCollect:!1,autoGenerateMipmaps:n});return new Lt({source:o,label:`texturePool_${Nf++}`})}getOptimalTexture(t,e,s=1,n,o=!1){let r=Math.ceil(t*s-1e-6),l=Math.ceil(e*s-1e-6);r=kn(r),l=kn(l);const c=n?1:0,d=o?1:0,h=(r<<17)+(l<<2)+(d<<1)+c;this._texturePool[h]||(this._texturePool[h]=[]);let p=this._texturePool[h].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]=h,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 wr=new Gf;yo.register(wr);class Wf{constructor(){this.renderPipeId="renderGroup",this.root=null,this.canBundle=!1,this.renderGroupParent=null,this.renderGroupChildren=[],this.worldTransform=new xt,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 kl,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&&(wr.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 xt),this._inverseWorldTransform.copyFrom(this.worldTransform).invert())}get textureOffsetInverseTransform(){return(this._matrixDirty&2)===0?this._textureOffsetInverseTransform:(this._matrixDirty&=-3,this._textureOffsetInverseTransform||(this._textureOffsetInverseTransform=new xt),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 xt),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 Of(i,t,e={}){for(const s in t)!e[s]&&t[s]!==void 0&&(i[s]=t[s])}const zr=new ee(null),ko=new ee(null),Fr=new ee(null,1,1),To=new ee(null),nc=1,Hf=2,Nr=4;class zt extends cs{constructor(t={}){var e,s;super(),this.uid=Vt("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 xt,this.relativeGroupTransform=new xt,this.groupTransform=this.relativeGroupTransform,this.destroyed=!1,this._position=new ee(this,0,0),this._scale=Fr,this._pivot=ko,this._origin=To,this._skew=zr,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=[],Of(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){At("8.8.0","Container.mixin is deprecated, please use extensions.mixin instead."),jt.mixin(zt,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||At(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=Te.get(Wf,this),this.groupTransform=xt.IDENTITY,t==null||t.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const t=this.parentRenderGroup;t==null||t.removeChild(this),Te.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 xt),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*sf}set angle(t){this.rotation=t*nf}get pivot(){return this._pivot===ko&&(this._pivot=new ee(this,0,0)),this._pivot}set pivot(t){this._pivot===ko&&(this._pivot=new ee(this,0,0),this._origin!==To&&we("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===zr&&(this._skew=new ee(this,0,0)),this._skew}set skew(t){this._skew===zr&&(this._skew=new ee(this,0,0)),this._skew.copyFrom(t)}get scale(){return this._scale===Fr&&(this._scale=new ee(this,1,1)),this._scale}set scale(t){this._scale===Fr&&(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===To&&(this._origin=new ee(this,0,0)),this._origin}set origin(t){this._origin===To&&(this._origin=new ee(this,0,0),this._pivot!==ko&&we("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,c=s._y,d=n._x,h=n._y,p=-o._x,g=-o._y;e.a=this._cx*l,e.b=this._sx*l,e.c=this._cy*c,e.d=this._sy*c,e.tx=r._x-(d*e.a+h*e.c)+(p*e.a+g*e.c)-p,e.ty=r._y-(d*e.b+h*e.d)+(p*e.b+g*e.d)-g}set alpha(t){t!==this.localAlpha&&(this.localAlpha=t,this._updateFlags|=nc,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|=nc,this._onUpdate())}get tint(){return Jo(this.localColor)}set blendMode(t){this.localBlendMode!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Hf,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|=Nr,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|=Nr,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|=Nr,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(zt,Tf,If,Ff,$f,Rf,Mf,Ef,Df,_f,Sf,Lf,Cf);class Tl extends zt{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 Oe(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,c=l.length;for(let d=0;d<c;d++)l[d].collectRenderables(t,e,s);n.blendMode.popBlendMode(t)}}class Qi extends Tl{constructor(t=Lt.EMPTY){t instanceof Lt&&(t={texture:t});const{texture:e=Lt.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 Lt?new Qi(t):new Qi(Lt.from(t,e))}set texture(t){t||(t=Lt.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 hd(this._visualBounds,this._anchor,this._texture),this._visualBounds}get sourceBounds(){return At("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 Uf=new Oe;function _d(i,t,e){const s=Uf;i.measurable=!0,pd(i,e,s),t.addBoundsMask(s),i.measurable=!1}function xd(i,t,e){const s=vs.get();i.measurable=!0;const n=xe.get().identity(),o=wd(i,e,n);yd(i,s,o),i.measurable=!1,t.addBoundsMask(s),xe.return(n),vs.return(s)}function wd(i,t,e){return i?(i!==t&&(wd(i.parent,t,e),i.updateLocalTransform(),e.append(i.localTransform)),e):(we("Mask bounds, renderable is not inside the root container"),e)}class Sd{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 Qi),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||_d(this.mask,t,e)}addLocalBounds(t,e){xd(this.mask,t,e)}containsPoint(t,e){const s=this.mask;return e(s,t)}destroy(){this.reset()}static test(t){return t instanceof Qi}}Sd.extension=bt.MaskEffect;class kd{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"}}kd.extension=bt.MaskEffect;class Td{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){_d(this.mask,t,e)}addLocalBounds(t,e){xd(this.mask,t,e)}containsPoint(t,e){const s=this.mask;return e(s,t)}destroy(){this.reset()}static test(t){return t instanceof zt}}Td.extension=bt.MaskEffect;const Vf={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 oc=Vf;const Ie={get(){return oc},set(i){oc=i}};class Cd extends He{constructor(t){t.resource||(t.resource=Ie.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"))}}Cd.extension=bt.TextureSource;class hr extends He{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}}hr.extension=bt.TextureSource;var dr=(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))(dr||{});class Gr{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 Ad=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 Gr(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=dr.NORMAL){return this._addListener(new Gr(t,e,s))}addOnce(t,e,s=dr.NORMAL){return this._addListener(new Gr(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}};Ad.targetFPMS=.06;let bn=Ad,Wr;async function qf(){return Wr??(Wr=(async()=>{var r;const t=Ie.get().createCanvas(1,1).getContext("webgl");if(!t)return"premultiply-alpha-on-upload";const e=await new Promise(l=>{const c=document.createElement("video");c.onloadeddata=()=>l(c),c.onerror=()=>l(null),c.autoplay=!1,c.crossOrigin="anonymous",c.preload="auto",c.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",c.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"})()),Wr}const Sr=class Md extends He{constructor(t){super(t),this.isReady=!1,this.uploadMethodId="video",t={...Md.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=bn.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 qf(),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&&(bn.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||(bn.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(bn.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement}};Sr.extension=bt.TextureSource;Sr.defaultOptions={...He.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1};Sr.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let Yf=Sr;const pn=(i,t,e=!1)=>(Array.isArray(i)||(i=[i]),t?i.map(s=>typeof s=="string"||e?t(s):s):i);class jf{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||we(`[Assets] Asset id ${t} was not found in the Cache`),e}set(t,e){const s=pn(t);let n;for(let c=0;c<this.parsers.length;c++){const d=this.parsers[c];if(d.test(e)){n=d.getCacheableAssets(s,e);break}}const o=new Map(Object.entries(n||{}));n||s.forEach(c=>{o.set(c,e)});const r=[...o.keys()],l={cacheKeys:r,keys:s};s.forEach(c=>{this._cacheMap.set(c,l)}),r.forEach(c=>{const d=n?n[c]:e;this._cache.has(c)&&this._cache.get(c)!==d&&we("[Cache] already has key:",c),this._cache.set(c,o.get(c))})}remove(t){if(!this._cacheMap.has(t)){we(`[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 mn=new jf,Oa=[];jt.handleByList(bt.TextureSource,Oa);function Ed(i={}){const t=i&&i.resource,e=t?i.resource:i,s=t?i:{resource:i};for(let n=0;n<Oa.length;n++){const o=Oa[n];if(o.test(e))return new o(s)}throw new Error(`Could not find a source type for resource: ${s.resource}`)}function Xf(i={},t=!1){const e=i&&i.resource,s=e?i.resource:i,n=e?i:{resource:i};if(!t&&mn.has(s))return mn.get(s);const o=new Lt({source:Ed(n)});return o.on("destroy",()=>{mn.has(s)&&mn.remove(s)}),t||mn.set(s,o),o}function Zf(i,t=!1){return typeof i=="string"?mn.get(i):i instanceof He?new Lt({source:i}):Xf(i,t)}Lt.from=Zf;He.from=Ed;jt.add(Sd,kd,Td,Yf,hr,Cd,wl);var Pd=(i=>(i[i.Low=0]="Low",i[i.Normal=1]="Normal",i[i.High=2]="High",i))(Pd||{});function Ve(i){if(typeof i!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(i)}`)}function Pn(i){return i.split("?")[0].split("#")[0]}function Kf(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Qf(i,t,e){return i.replace(new RegExp(Kf(t),"g"),e)}function Jf(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 c=e.lastIndexOf("/");if(c!==e.length-1){c===-1?(e="",s=0):(e=e.slice(0,c),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 lo={toPosix(i){return Qf(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){Ve(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(Ve(i),this.isDataUrl(i)||this.isBlobUrl(i))return i;const s=Pn(this.toPosix(t??Ie.get().getBaseUrl())),n=Pn(this.toPosix(e??this.rootname(s)));return i=this.toPosix(i),i.startsWith("/")?lo.join(n,i.slice(1)):this.isAbsolute(i)?i:this.join(s,i)},normalize(i){if(Ve(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=Jf(i),i.length>0&&s&&(i+="/"),e?`/${i}`:t+i},isAbsolute(i){return Ve(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(Ve(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(Ve(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){Ve(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){Ve(i),t&&Ve(t),i=Pn(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 c=i.charCodeAt(o);if(c===47){if(!n){e=o+1;break}}else l===-1&&(n=!1,l=o+1),r>=0&&(c===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){Ve(i),i=Pn(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){Ve(i);const t={root:"",dir:"",base:"",ext:"",name:""};if(i.length===0)return t;i=Pn(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,c=!0,d=i.length-1,h=0;for(;d>=n;--d){if(e=i.charCodeAt(d),e===47){if(!c){r=d+1;break}continue}l===-1&&(c=!1,l=d+1),e===46?o===-1?o=d:h!==1&&(h=1):o!==-1&&(h=-1)}return o===-1||l===-1||h===0||h===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 Id(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?Id(i.replace(s[e],l),t,e+1,s,n):n.push(i.replace(s[e],l))}}function tp(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)}),Id(i,n,0,e,s)}else s.push(i);return s}const rc=i=>!Array.isArray(i);class Ld{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 pn(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&&we("[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 c;if(typeof l=="string"){const d=this._createBundleAssetId(t,l);s.push(d),c=[l,d]}else{const d=l.map(h=>this._createBundleAssetId(t,h));s.push(...d),c=[...l,...d]}this.add({...o,alias:c,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)&&we(`[Resolver] already has key: ${o} overwriting`)},pn(e).forEach(o=>{const{src:r}=o;let{data:l,format:c,loadParser:d,parser:h}=o;const p=pn(r).map(_=>typeof _=="string"?tp(_):Array.isArray(_)?_:[_]),g=this.getAlias(o);Array.isArray(g)?g.forEach(s):s(g);const m=[],y=_=>{const w=this._parsers.find(k=>k.test(_));return{src:_,...w==null?void 0:w.parse(_)}};p.forEach(_=>{_.forEach(w=>{let k={};if(typeof w!="object"?k=y(w):(l=w.data??l,c=w.format??c,(w.loadParser||w.parser)&&(d=w.loadParser??d,h=w.parser??h),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:c,loadParser:d,parser:h,progressSize:o.progressSize}),m.push(k)})}),g.forEach(_=>{this._assetMap[_]=m})})}resolveBundle(t){const e=rc(t);t=pn(t);const s={};return t.forEach(n=>{const o=this._bundles[n];if(o){const r=this.resolve(o),l={};for(const c in r){const d=r[c];l[this._extractAssetIdFromBundle(n,c)]=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=rc(t);t=pn(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(c=>{const d=o.filter(h=>h[l]?h[l]===c:!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:c}=e;return(this._basePath||this._rootPath)&&(t.src=lo.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??ep(t.src),c!==void 0&&(t.progressSize=c),t}}Ld.RETINA_PREFIX=/@([0-9\.]+)x/;function ep(i){return i.split(".").pop().split("?").shift().split("#").shift()}const ac=(i,t)=>{const e=t.split("?")[1];return e&&(i+=`?${e}`),i},Bd=class to{constructor(t,e){this.linkedSheets=[];let s=t;(t==null?void 0:t.source)instanceof He&&(s={texture:t,data:e});const{texture:n,data:o,cachePrefix:r=""}=s;this.cachePrefix=r,this._texture=n instanceof Lt?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<=to.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:to.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 c=null,d=null;const h=r.trimmed!==!1&&r.sourceSize?r.sourceSize:r.frame,p=new Yt(0,0,Math.floor(h.w)/this.resolution,Math.floor(h.h)/this.resolution);r.rotated?c=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):c=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 Lt({source:this.textureSource,frame:c,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*to.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*to.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=[]}};Bd.BATCH_SIZE=1e3;let lc=Bd;const sp=["jpg","png","jpeg","avif","webp","basis","etc2","bc7","bc6h","bc5","bc4","bc3","bc2","bc1","eac","astc"];function Rd(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=lo.dirname(i[0]);t.linkedSheets.forEach((o,r)=>{const l=Rd([`${n}/${t.data.meta.related_multi_packs[r]}`],o,!0);Object.assign(s,l)})}return s}const ip={extension:bt.Asset,cache:{test:i=>i instanceof lc,getCacheableAssets:(i,t)=>Rd(i,t,!1)},resolver:{extension:{type:bt.ResolveParser,name:"resolveSpritesheet"},test:i=>{const e=i.split("?")[0].split("."),s=e.pop(),n=e.pop();return s==="json"&&sp.includes(n)},parse:i=>{var e;const t=i.split(".");return{resolution:parseFloat(((e=Ld.RETINA_PREFIX.exec(i))==null?void 0:e[1])??"1"),format:t[t.length-2],src:i}}},loader:{name:"spritesheetLoader",id:"spritesheet",extension:{type:bt.LoadParser,priority:Pd.Normal,name:"spritesheetLoader"},async testParse(i,t){return lo.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=lo.dirname(t.src);l&&l.lastIndexOf("/")!==l.length-1&&(l+="/");let c;if(s instanceof Lt)c=s;else{const m=ac(l+(n??i.meta.image),t.src);c=(await e.load([{src:m,data:o}]))[m]}const d=new lc({texture:c.source,data:i,cachePrefix:r});await d.parse();const h=(p=i==null?void 0:i.meta)==null?void 0:p.related_multi_packs;if(Array.isArray(h)){const m=[];for(const _ of h){if(typeof _!="string")continue;let w=l+_;(g=t.data)!=null&&g.ignoreMultiPack||(w=ac(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(_=>{_.linkedSheets=[d].concat(d.linkedSheets.filter(w=>w!==_))})}return d},async unload(i,t,e){await e.unload(i.textureSource._sourceOrigin),i.destroy(!1)}}};jt.add(ip);const Or=Object.create(null),cc=Object.create(null);function Cl(i,t){let e=cc[i];return e===void 0&&(Or[t]===void 0&&(Or[t]=1),cc[i]=e=Or[t]++),e}let sn;function $d(){return(!sn||sn!=null&&sn.isContextLost())&&(sn=Ie.get().createCanvas().getContext("webgl",{})),sn}let Co;function np(){if(!Co){Co="mediump";const i=$d();i&&i.getShaderPrecisionFormat&&(Co=i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision?"highp":"mediump")}return Co}function op(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 rp(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 ap(i,t){return t?`#version 300 es
|
|
22
|
-
${i}`:i}const lp={},cp={};function hp(i,{name:t="pixi-program"},e=!0){t=t.replace(/\s+/g,"-"),t+=e?"-fragment":"-vertex";const s=e?lp:cp;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 dp(i,t){return t?i.replace("#version 300 es",""):i}const Hr={stripVersion:dp,ensurePrecision:rp,addProgramDefines:op,setProgramName:hp,insertVersion:ap},In=Object.create(null),Dd=class Ha{constructor(t){t={...Ha.defaultOptions,...t};const e=t.fragment.indexOf("#version 300 es")!==-1,s={stripVersion:e,ensurePrecision:{requestedFragmentPrecision:t.preferredFragmentPrecision,requestedVertexPrecision:t.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:np()},setProgramName:{name:t.name},addProgramDefines:e,insertVersion:e};let n=t.fragment,o=t.vertex;Object.keys(Hr).forEach(r=>{const l=s[r];n=Hr[r](n,l,!0),o=Hr[r](o,l,!1)}),this.fragment=n,this.vertex=o,this.transformFeedbackVaryings=t.transformFeedbackVaryings,this._key=Cl(`${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,In[this._cacheKey]=null}static from(t){const e=`${t.vertex}:${t.fragment}`;return In[e]||(In[e]=new Ha(t),In[e]._cacheKey=e),In[e]}};Dd.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let zd=Dd;const hc={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 up(i){return hc[i]??hc.float32}const fp={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"},dc=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|\)|$)/g;function uc(i,t){let e;for(;(e=dc.exec(i))!==null;){const s=fp[e[3]]??"float32";t[e[2]]={location:parseInt(e[1],10),format:s,stride:up(s).stride,offset:0,instance:!1,start:0}}dc.lastIndex=0}function pp(i){return i.replace(/\/\/.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,"")}function mp({source:i,entryPoint:t}){const e={},s=pp(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(uc(r,e),Object.keys(e).length===0){const l=r.match(/\(\s*\w+\s*:\s*(\w+)/);if(l){const c=l[1],d=new RegExp(`struct\\s+${c}\\s*\\{([^}]+)\\}`,"s"),h=s.match(d);h&&uc(h[1],e)}}return e}function Ur(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,c=/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 h=((g=i.match(r))==null?void 0:g.map(m=>{const y=m.match(c)[1],_=m.match(l).reduce((w,k)=>{const[E,B]=k.split(":");return w[E.trim()]=B.trim(),w},{});return _?{name:y,members:_}:null}).filter(({name:m})=>d.some(y=>y.type===m||y.type.includes(`<${m}>`))))??[];return{groups:d,structs:h}}var Yi=(i=>(i[i.VERTEX=1]="VERTEX",i[i.FRAGMENT=2]="FRAGMENT",i[i.COMPUTE=4]="COMPUTE",i))(Yi||{});function gp({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:Yi.VERTEX|Yi.FRAGMENT,buffer:{type:"uniform"}}):s.type==="sampler"?t[s.group].push({binding:s.binding,visibility:Yi.FRAGMENT,sampler:{type:"filtering"}}):s.type==="texture_2d"||s.type.startsWith("texture_2d<")?t[s.group].push({binding:s.binding,visibility:Yi.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:Yi.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:Yi.FRAGMENT,texture:{sampleType:"float",viewDimension:"cube",multisampled:!1}})}for(let e=0;e<t.length;e++)t[e]||(t[e]=[]);return t}function yp({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 bp(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 Ln=Object.create(null);class kr{constructor(t){var l,c;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=Ur(e.source);this.structsAndGroups=d}else{const d=Ur(s.source),h=Ur(e.source);this.structsAndGroups=bp(d,h)}this.layout=n??yp(this.structsAndGroups),this.gpuLayout=o??gp(this.structsAndGroups),this.autoAssignGlobalUniforms=((l=this.layout[0])==null?void 0:l.globalUniforms)!==void 0,this.autoAssignLocalUniforms=((c=this.layout[1])==null?void 0:c.localUniforms)!==void 0,this._generateProgramKey()}_generateProgramKey(){const{vertex:t,fragment:e}=this,s=t.source+e.source+t.entryPoint+e.entryPoint;this._layoutKey=Cl(s,"program")}get attributeData(){return this._attributeData??(this._attributeData=mp(this.vertex)),this._attributeData}destroy(){this.gpuLayout=null,this.layout=null,this.structsAndGroups=null,this.fragment=null,this.vertex=null,Ln[this._cacheKey]=null}static from(t){const e=`${t.vertex.source}:${t.fragment.source}:${t.fragment.entryPoint}:${t.vertex.entryPoint}`;return Ln[e]||(Ln[e]=new kr(t),Ln[e]._cacheKey=e),Ln[e]}}const Fd=["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>"],vp=Fd.reduce((i,t)=>(i[t]=!0,i),{});function _p(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 Nd=class Gd{constructor(t,e){this._touched=0,this.uid=Vt("uniform"),this._resourceType="uniformGroup",this._resourceId=Vt("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1,e={...Gd.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,!vp[o.type]){const r=o.type.match(/^array<(\w+(?:<\w+>)?),\s*(\d+)>$/);if(r){const[,l,c]=r;throw new Error(`Uniform type ${o.type} is not supported. Use type: '${l}', size: ${c} instead.`)}throw new Error(`Uniform type ${o.type} is not supported. Supported uniform types are: ${Fd.join(", ")}`)}o.value??(o.value=_p(o.type,o.size)),s[n]=o.value}this.uniforms=s,this._dirtyId=1,this.ubo=e.ubo,this.isStatic=e.isStatic,this._signature=Cl(Object.keys(s).map(n=>`${n}-${t[n].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};Nd.defaultOptions={ubo:!1,isStatic:!1};let Wd=Nd;class tr{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 Ua=(i=>(i[i.WEBGL=1]="WEBGL",i[i.WEBGPU=2]="WEBGPU",i[i.CANVAS=4]="CANVAS",i[i.BOTH=3]="BOTH",i))(Ua||{});class Al extends cs{constructor(t){super(),this.uid=Vt("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|=Ua.WEBGPU),s&&(r|=Ua.WEBGL)),this.compatibleRenderers=r;const c={};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 h in l[d]){const p=l[d][h];c[p]={group:d,binding:h,name:p}}else if(e&&n&&!l){const d=e.structsAndGroups.groups;l={},d.forEach(h=>{l[h.group]=l[h.group]||{},l[h.group][h.binding]=h.name,c[h.name]=h})}else if(o){n={},l={},e&&e.structsAndGroups.groups.forEach(p=>{l[p.group]=l[p.group]||{},l[p.group][p.binding]=p.name,c[p.name]=p});let d=0;for(const h in o)c[h]||(n[99]||(n[99]=new tr,this._ownedBindGroups.push(n[99])),c[h]={group:99,binding:d,name:h},l[99]=l[99]||{},l[99][d]=h,d++);for(const h in o){const p=h;let g=o[h];!g.source&&!g._resourceType&&(g=new Wd(g));const m=c[p];m&&(n[m.group]||(n[m.group]=new tr,this._ownedBindGroups.push(n[m.group])),n[m.group].setResource(g,m.binding))}}this.groups=n,this._uniformBindMap=l,this.resources=this._buildResourceAccessor(n,c)}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 tr,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=kr.from(e)),s&&(r=zd.from(s)),new Al({gpuProgram:o,glProgram:r,...n})}}const xp={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},Vr=0,qr=1,Yr=2,jr=3,Xr=4,Zr=5,Va=class Od{constructor(){this.data=0,this.blendMode="normal",this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<Vr)}set blend(t){!!(this.data&1<<Vr)!==t&&(this.data^=1<<Vr)}get offsets(){return!!(this.data&1<<qr)}set offsets(t){!!(this.data&1<<qr)!==t&&(this.data^=1<<qr)}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<<Yr)}set culling(t){!!(this.data&1<<Yr)!==t&&(this.data^=1<<Yr)}get depthTest(){return!!(this.data&1<<jr)}set depthTest(t){!!(this.data&1<<jr)!==t&&(this.data^=1<<jr)}get depthMask(){return!!(this.data&1<<Zr)}set depthMask(t){!!(this.data&1<<Zr)!==t&&(this.data^=1<<Zr)}get clockwiseFrontFace(){return!!(this.data&1<<Xr)}set clockwiseFrontFace(t){!!(this.data&1<<Xr)!==t&&(this.data^=1<<Xr)}get blendMode(){return this._blendMode}set blendMode(t){this.blend=t!=="none",this._blendMode=t,this._blendModeId=xp[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 Od;return t.depthTest=!1,t.blend=!0,t}};Va.default2d=Va.for2d();let Hd=Va;const qa=[];jt.handleByNamedList(bt.Environment,qa);async function wp(i){if(!i)for(let t=0;t<qa.length;t++){const e=qa[t];if(e.value.test()){await e.value.load();return}}}let Bn;function Sp(){if(typeof Bn=="boolean")return Bn;try{Bn=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch{Bn=!1}return Bn}function fc(i,t,e=2){const s=t&&t.length,n=s?t[0]*e:i.length;let o=Ud(i,0,n,e,!0);const r=[];if(!o||o.next===o.prev)return r;let l,c,d;if(s&&(o=Mp(i,t,o,e)),i.length>80*e){l=i[0],c=i[1];let h=l,p=c;for(let g=e;g<n;g+=e){const m=i[g],y=i[g+1];m<l&&(l=m),y<c&&(c=y),m>h&&(h=m),y>p&&(p=y)}d=Math.max(h-l,p-c),d=d!==0?32767/d:0}return co(o,r,e,l,c,d,0),r}function Ud(i,t,e,s,n){let o;if(n===Np(i,t,e,s)>0)for(let r=t;r<e;r+=s)o=pc(r/s|0,i[r],i[r+1],o);else for(let r=e-s;r>=t;r-=s)o=pc(r/s|0,i[r],i[r+1],o);return o&&An(o,o.next)&&(uo(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&&(An(e,e.next)||Ot(e.prev,e,e.next)===0)){if(uo(e),e=t=e.prev,e===e.next)break;s=!0}else e=e.next;while(s||e!==t);return t}function co(i,t,e,s,n,o,r){if(!i)return;!r&&o&&Bp(i,s,n,o);let l=i;for(;i.prev!==i.next;){const c=i.prev,d=i.next;if(o?Tp(i,s,n,o):kp(i)){t.push(c.i,i.i,d.i),uo(i),i=d.next,l=d.next;continue}if(i=d,i===l){r?r===1?(i=Cp(Ji(i),t),co(i,t,e,s,n,o,2)):r===2&&Ap(i,t,e,s,n,o):co(Ji(i),t,e,s,n,o,1);break}}}function kp(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,c=e.y,d=s.y,h=Math.min(n,o,r),p=Math.min(l,c,d),g=Math.max(n,o,r),m=Math.max(l,c,d);let y=s.next;for(;y!==t;){if(y.x>=h&&y.x<=g&&y.y>=p&&y.y<=m&&eo(n,l,o,c,r,d,y.x,y.y)&&Ot(y.prev,y,y.next)>=0)return!1;y=y.next}return!0}function Tp(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,c=o.x,d=r.x,h=n.y,p=o.y,g=r.y,m=Math.min(l,c,d),y=Math.min(h,p,g),_=Math.max(l,c,d),w=Math.max(h,p,g),k=Ya(m,y,t,e,s),E=Ya(_,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<=_&&B.y>=y&&B.y<=w&&B!==n&&B!==r&&eo(l,h,c,p,d,g,B.x,B.y)&&Ot(B.prev,B,B.next)>=0||(B=B.prevZ,L.x>=m&&L.x<=_&&L.y>=y&&L.y<=w&&L!==n&&L!==r&&eo(l,h,c,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<=_&&B.y>=y&&B.y<=w&&B!==n&&B!==r&&eo(l,h,c,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<=_&&L.y>=y&&L.y<=w&&L!==n&&L!==r&&eo(l,h,c,p,d,g,L.x,L.y)&&Ot(L.prev,L,L.next)>=0)return!1;L=L.nextZ}return!0}function Cp(i,t){let e=i;do{const s=e.prev,n=e.next.next;!An(s,n)&&qd(s,e,e.next,n)&&ho(s,n)&&ho(n,s)&&(t.push(s.i,e.i,n.i),uo(e),uo(e.next),e=i=n),e=e.next}while(e!==i);return Ji(e)}function Ap(i,t,e,s,n,o){let r=i;do{let l=r.next.next;for(;l!==r.prev;){if(r.i!==l.i&&Dp(r,l)){let c=Yd(r,l);r=Ji(r,r.next),c=Ji(c,c.next),co(r,t,e,s,n,o,0),co(c,t,e,s,n,o,0);return}l=l.next}r=r.next}while(r!==i)}function Mp(i,t,e,s){const n=[];for(let o=0,r=t.length;o<r;o++){const l=t[o]*s,c=o<r-1?t[o+1]*s:i.length,d=Ud(i,l,c,s,!1);d===d.next&&(d.steiner=!0),n.push($p(d))}n.sort(Ep);for(let o=0;o<n.length;o++)e=Pp(n[o],e);return e}function Ep(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 Pp(i,t){const e=Ip(i,t);if(!e)return t;const s=Yd(e,i);return Ji(s,s.next),Ji(e,e.next)}function Ip(i,t){let e=t;const s=i.x,n=i.y;let o=-1/0,r;if(An(i,e))return e;do{if(An(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,c=r.x,d=r.y;let h=1/0;e=r;do{if(s>=e.x&&e.x>=c&&s!==e.x&&Vd(n<d?s:o,n,c,d,n<d?o:s,n,e.x,e.y)){const p=Math.abs(n-e.y)/(s-e.x);ho(e,i)&&(p<h||p===h&&(e.x>r.x||e.x===r.x&&Lp(r,e)))&&(r=e,h=p)}e=e.next}while(e!==l);return r}function Lp(i,t){return Ot(i.prev,i,t.prev)<0&&Ot(t.next,i,i.next)<0}function Bp(i,t,e,s){let n=i;do n.z===0&&(n.z=Ya(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,Rp(n)}function Rp(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 c=e;for(;l>0||c>0&&r;)l!==0&&(c===0||!r||s.z<=r.z)?(n=s,s=s.nextZ,l--):(n=r,r=r.nextZ,c--),o?o.nextZ=n:i=n,n.prevZ=o,o=n;s=r}o.nextZ=null,e*=2}while(t>1);return i}function Ya(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 $p(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 Vd(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 eo(i,t,e,s,n,o,r,l){return!(i===r&&t===l)&&Vd(i,t,e,s,n,o,r,l)}function Dp(i,t){return i.next.i!==t.i&&i.prev.i!==t.i&&!zp(i,t)&&(ho(i,t)&&ho(t,i)&&Fp(i,t)&&(Ot(i.prev,i,t.prev)||Ot(i,t.prev,t))||An(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 An(i,t){return i.x===t.x&&i.y===t.y}function qd(i,t,e,s){const n=Mo(Ot(i,t,e)),o=Mo(Ot(i,t,s)),r=Mo(Ot(e,s,i)),l=Mo(Ot(e,s,t));return!!(n!==o&&r!==l||n===0&&Ao(i,e,t)||o===0&&Ao(i,s,t)||r===0&&Ao(e,i,s)||l===0&&Ao(e,t,s))}function Ao(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 Mo(i){return i>0?1:i<0?-1:0}function zp(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&&qd(e,e.next,i,t))return!0;e=e.next}while(e!==i);return!1}function ho(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 Fp(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 Yd(i,t){const e=ja(i.i,i.x,i.y),s=ja(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 pc(i,t,e,s){const n=ja(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 uo(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 ja(i,t,e){return{i,x:t,y:e,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function Np(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 Gp=fc.default||fc;var jd=(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))(jd||{});class Wp{constructor(t){this.items=[],this._name=t}emit(t,e,s,n,o,r,l,c){const{name:d,items:h}=this;for(let p=0,g=h.length;p<g;p++)h[p][d](t,e,s,n,o,r,l,c);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 Op=["init","destroy","contextChange","resolutionChange","resetState","renderEnd","renderStart","render","update","postrender","prerender"],Xd=class Zd extends cs{constructor(t){super(),this.tick=0,this.uid=Vt("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=[...Op,...this.config.runners??[]];this._addRunners(...e),this._unsafeEvalCheck()}async init(t={}){const e=t.skipExtensionImports===!0?!0:t.manageImports===!1;await wp(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={...Zd.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 zt&&(s={container:s},e&&(At(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=jd.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 Wp(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)&&yo.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(!Sp())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()}};Xd.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let Kd=Xd,Eo;function Hp(i){return Eo!==void 0||(Eo=(()=>{var e;const t={stencil:!0,failIfMajorPerformanceCaveat:i??Kd.defaultOptions.failIfMajorPerformanceCaveat};try{if(!Ie.get().getWebGLRenderingContext())return!1;let n=Ie.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}})()),Eo}let Po;async function Up(i={}){return Po!==void 0||(Po=await(async()=>{const t=Ie.get().getNavigator().gpu;if(!t)return!1;try{return await(await t.requestAdapter(i)).requestDevice(),!0}catch{return!1}})()),Po}const mc=["webgl","webgpu","canvas"];async function Vp(i){let t=[];i.preference?(t.push(i.preference),mc.forEach(o=>{o!==i.preference&&t.push(o)})):t=mc.slice();let e,s={};for(let o=0;o<t.length;o++){const r=t[o];if(r==="webgpu"&&await Up()){const{WebGPURenderer:l}=await io(async()=>{const{WebGPURenderer:c}=await import("./WebGPURenderer-D3zU-ngm.js");return{WebGPURenderer:c}},__vite__mapDeps([3,4,5,2]));e=l,s={...i,...i.webgpu};break}else if(r==="webgl"&&Hp(i.failIfMajorPerformanceCaveat??Kd.defaultOptions.failIfMajorPerformanceCaveat)){const{WebGLRenderer:l}=await io(async()=>{const{WebGLRenderer:c}=await import("./WebGLRenderer-DGZDe07g.js");return{WebGLRenderer:c}},__vite__mapDeps([6,4,5,2]));e=l,s={...i,...i.webgl};break}else if(r==="canvas"){const{CanvasRenderer:l}=await io(async()=>{const{CanvasRenderer:c}=await import("./CanvasRenderer-CoGUh0dQ.js");return{CanvasRenderer:c}},__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 Jd{static init(){var t;(t=globalThis.__PIXI_APP_INIT__)==null||t.call(globalThis,this,Qd)}static destroy(){}}Jd.extension=bt.Application;class qp{constructor(t){this._renderer=t}init(){var t;(t=globalThis.__PIXI_RENDERER_INIT__)==null||t.call(globalThis,this._renderer,Qd)}destroy(){this._renderer=null}}qp.extension={type:[bt.WebGLSystem,bt.WebGPUSystem],name:"initHook",priority:-10};class tu{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}}tu.extension=bt.Application;class eu{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,dr.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?bn.shared:new bn,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}eu.extension=bt.Application;jt.add(tu);jt.add(eu);const su=class Xa{constructor(...t){this.stage=new zt,t[0]!==void 0&&At(Ut,"Application constructor options are deprecated, please use Application.init() instead.")}async init(t){t={...t},this.stage||(this.stage=new zt),this.renderer=await Vp(t),Xa._plugins.forEach(e=>{e.init.call(this,t)})}render(){this.renderer.render({container:this.stage})}get canvas(){return this.renderer.canvas}get view(){return At(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=Xa._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}};su._plugins=[];let iu=su;jt.handleByList(bt.Application,iu._plugins);jt.add(Jd);var Kr,gc;function Yp(){if(gc)return Kr;gc=1,Kr=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,c,d){var h=c.toLowerCase();for(d=n(d),h=="m"&&d.length>2&&(r.push([c].concat(d.splice(0,2))),h="l",c=c=="m"?"l":"L");;){if(d.length==i[h])return d.unshift(c),r.push(d);if(d.length<i[h])throw new Error("malformed path data");r.push([c].concat(d.splice(0,i[h])))}}),r}var s=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/ig;function n(o){var r=o.match(s);return r?r.map(Number):[]}return Kr}var jp=Yp();const Xp=sd(jp);function Zp(i,t){const e=Xp(i),s=[];let n=null,o=0,r=0;for(let l=0;l<e.length;l++){const c=e[l],d=c[0],h=c;switch(d){case"M":o=h[1],r=h[2],t.moveTo(o,r);break;case"m":o+=h[1],r+=h[2],t.moveTo(o,r);break;case"H":o=h[1],t.lineTo(o,r);break;case"h":o+=h[1],t.lineTo(o,r);break;case"V":r=h[1],t.lineTo(o,r);break;case"v":r+=h[1],t.lineTo(o,r);break;case"L":o=h[1],r=h[2],t.lineTo(o,r);break;case"l":o+=h[1],r+=h[2],t.lineTo(o,r);break;case"C":o=h[5],r=h[6],t.bezierCurveTo(h[1],h[2],h[3],h[4],o,r);break;case"c":t.bezierCurveTo(o+h[1],r+h[2],o+h[3],r+h[4],o+h[5],r+h[6]),o+=h[5],r+=h[6];break;case"S":o=h[3],r=h[4],t.bezierCurveToShort(h[1],h[2],o,r);break;case"s":t.bezierCurveToShort(o+h[1],r+h[2],o+h[3],r+h[4]),o+=h[3],r+=h[4];break;case"Q":o=h[3],r=h[4],t.quadraticCurveTo(h[1],h[2],o,r);break;case"q":t.quadraticCurveTo(o+h[1],r+h[2],o+h[3],r+h[4]),o+=h[3],r+=h[4];break;case"T":o=h[1],r=h[2],t.quadraticCurveToShort(o,r);break;case"t":o+=h[1],r+=h[2],t.quadraticCurveToShort(o,r);break;case"A":o=h[6],r=h[7],t.arcToSvg(h[1],h[2],h[3],h[4],h[5],o,r);break;case"a":o+=h[6],r+=h[7],t.arcToSvg(h[1],h[2],h[3],h[4],h[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:we(`Unknown SVG path command: ${d}`)}d!=="Z"&&d!=="z"&&n===null&&(n={startX:o,startY:r},s.push(n))}return t}class Ml{constructor(t=0,e=0,s=0){this.type="circle",this.x=t,this.y=e,this.radius=s}clone(){return new Ml(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,c=(1-n)*s,d=Math.sqrt(o*o+r*r);return d<=l+c&&d>l-(s-c)}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 El{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 El(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),c=s-l,d=o-c,h=r-c,p=o+l,g=r+l,m=t-this.x,y=e-this.y,_=m*m/(d*d)+y*y/(h*h),w=m*m/(p*p)+y*y/(g*g);return _>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 Kp(i,t,e,s,n,o){const r=i-e,l=t-s,c=n-e,d=o-s,h=r*c+l*d,p=c*c+d*d;let g=-1;p!==0&&(g=h/p);let m,y;g<0?(m=e,y=s):g>1?(m=n,y=o):(m=e+g*c,y=s+g*d);const _=i-m,w=t-y;return _*_+w*w}let Qp,Jp;class oo{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],c=e[(n+3)%s];t+=(l-o)*(c+r)}return t<0}containsPolygon(t){const e=this.getBounds(Qp),s=t.getBounds(Jp);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 oo(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],c=this.points[o*2+1],d=this.points[r*2],h=this.points[r*2+1];c>e!=h>e&&t<(d-l)*((e-c)/(h-c))+l&&(s=!s)}return s}strokeContains(t,e,s,n=.5){const o=s*s,r=o*(1-n),l=o-r,{points:c}=this,d=c.length-(this.closePath?0:2);for(let h=0;h<d;h+=2){const p=c[h],g=c[h+1],m=c[(h+2)%c.length],y=c[(h+3)%c.length],_=Kp(t,e,p,g,m,y),w=Math.sign((m-p)*(e-g)-(y-g)*(t-p));if(_<=(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,c=e.length;l<c;l+=2){const d=e[l],h=e[l+1];s=d<s?d:s,n=d>n?d:n,o=h<o?h:o,r=h>r?h: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 At("8.11.0","Polygon.lastX is deprecated, please use Polygon.lastX instead."),this.points[this.points.length-2]}get y(){return At("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 Io=(i,t,e,s,n,o,r)=>{const l=i-e,c=t-s,d=Math.sqrt(l*l+c*c);return d>=n-o&&d<=n+r};class Pl{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 Pl(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:c,radius:d}=this,h=s*(1-n),p=s-h,g=o+d,m=r+d,y=l-d*2,_=c-d*2,w=o+l,k=r+c;return(t>=o-h&&t<=o+p||t>=w-p&&t<=w+h)&&e>=m&&e<=m+_||(e>=r-h&&e<=r+p||e>=k-p&&e<=k+h)&&t>=g&&t<=g+y?!0:t<g&&e<m&&Io(t,e,g,m,d,p,h)||t>w-d&&e<m&&Io(t,e,w-d,m,d,p,h)||t>w-d&&e>k-d&&Io(t,e,w-d,k-d,d,p,h)||t<g&&e>k-d&&Io(t,e,g,k-d,d,p,h)}toString(){return`[pixi.js/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`}}const nu={};function tm(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 nu[s]||em(i,t,s,e)}function em(i,t,e,s){const n={};let o=0;for(let l=0;l<s;l++){const c=l<t?i[l]:Lt.EMPTY.source;n[o++]=c.source,n[o++]=c.style}const r=new tr(n);return nu[e]=r,r}class yc{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 bc(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 sm={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var im=(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))(im||{});function vc(i,t){return t.alphaMode==="no-premultiply-alpha"&&sm[i]||i}const nm=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
|
|
24
|
-
`);function om(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 rm(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=nm.replace(/%forloop%/gi,om(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 nn=null;function am(){var t;if(nn)return nn;const i=$d();return nn=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),nn=rm(nn,i),(t=i.getExtension("WEBGL_lose_context"))==null||t.loseContext(),nn}class lm{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 cm{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.textures=new lm,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 ro=[];let ur=0;yo.register({clear:()=>{if(ro.length>0)for(const i of ro)i&&i.destroy();ro.length=0,ur=0}});function _c(){return ur>0?ro[--ur]:new cm}function xc(i){i.elements=null,ro[ur++]=i}let Rn=0;const ou=class ru{constructor(t){this.uid=Vt("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],t={...ru.defaultOptions,...t},t.maxTextures||(At("v8.8.0","maxTextures is a required option for Batcher now, please pass it in the options"),t.maxTextures=am());const{maxTextures:e,attributesInitialSize:s,indicesInitialSize:n}=t;this.attributeBuffer=new yc(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++)xc(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=_c(),n=s.textures;n.clear();const o=e[this.elementStart];let r=vc(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 c=this.attributeBuffer.float32View,d=this.attributeBuffer.uint32View,h=this.indexBuffer;let p=this._batchIndexSize,g=this._batchIndexStart,m="startBatch",y=[];const _=this.maxTextures;for(let w=this.elementStart;w<this.elementSize;++w){const k=e[w];e[w]=null;const B=k.texture._source,L=vc(k.blendMode,B),H=r!==L||l!==k.topology;if(B._batchTick===Rn&&!H){k._textureId=B._textureBindLocation,p+=k.indexSize,k.packAsQuad?(this.packQuadAttributes(k,c,d,k._attributeStart,k._textureId),this.packQuadIndex(h,k._indexStart,k._attributeStart/this.vertexSize)):(this.packAttributes(k,c,d,k._attributeStart,k._textureId),this.packIndex(k,h,k._indexStart,k._attributeStart/this.vertexSize)),k._batch=s,y.push(k);continue}B._batchTick=Rn,(n.count>=_||H)&&(this._finishBatch(s,g,p-g,n,r,l,t,m,y),m="renderBatch",g=p,r=L,l=k.topology,s=_c(),n=s.textures,n.clear(),y=[],++Rn),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,c,d,k._attributeStart,k._textureId),this.packQuadIndex(h,k._indexStart,k._attributeStart/this.vertexSize)):(this.packAttributes(k,c,d,k._attributeStart,k._textureId),this.packIndex(k,h,k._indexStart,k._attributeStart/this.vertexSize))}n.count>0&&(this._finishBatch(s,g,p-g,n,r,l,t,m,y),g=p,++Rn),this.elementStart=this.elementSize,this._batchIndexStart=g,this._batchIndexSize=p}_finishBatch(t,e,s,n,o,r,l,c,d){t.gpuBindGroup=null,t.bindGroup=null,t.action=c,t.batcher=this,t.textures=n,t.blendMode=o,t.topology=r,t.start=e,t.size=s,t.elements=d,++Rn,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 yc(e);bc(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 bc(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,c=t.attributeOffset;for(let d=0;d<r;d++)e[s++]=n+o[d+l]-c}destroy(t={}){var e;if(this.batches!==null){for(let s=0;s<this.batchIndex;s++)xc(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}}};ou.defaultOptions={maxTextures:null,attributesInitialSize:4,indicesInitialSize:6};let hm=ou;var Se=(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))(Se||{});class fo extends cs{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=Vt("buffer"),this._resourceType="buffer",this._resourceId=Vt("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&Se.STATIC)}set static(t){t?this.descriptor.usage|=Se.STATIC:this.descriptor.usage&=~Se.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=Vt("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 au(i,t){if(!(i instanceof fo)){let e=t?Se.INDEX:Se.VERTEX;i instanceof Array&&(t?(i=new Uint32Array(i),e=Se.INDEX|Se.COPY_DST):(i=new Float32Array(i),e=Se.VERTEX|Se.COPY_DST)),i=new fo({data:i,label:t?"index-mesh-buffer":"vertex-mesh-buffer",usage:e})}return i}function dm(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,c=-1/0;const d=n.BYTES_PER_ELEMENT,h=(s.offset||0)/d,p=(s.stride||8)/d;for(let g=h;g<n.length;g+=p){const m=n[g],y=n[g+1];m>l&&(l=m),y>c&&(c=y),m<o&&(o=m),y<r&&(r=y)}return e.minX=o,e.minY=r,e.maxX=l,e.maxY=c,e}function um(i){return(i instanceof fo||Array.isArray(i)||i.BYTES_PER_ELEMENT)&&(i={buffer:i}),i.buffer=au(i.buffer,!1),i}class fm extends cs{constructor(t={}){super(),this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this.uid=Vt("geometry"),this._layoutKey=0,this.instanceCount=1,this._bounds=new Oe,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=um(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=au(t,!0),this.buffers.push(this.indexBuffer)}get bounds(){return this._boundsDirty?(this._boundsDirty=!1,dm(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 pm=new Float32Array(1),mm=new Uint32Array(1);class gm extends fm{constructor(){const e=new fo({data:pm,label:"attribute-batch-buffer",usage:Se.VERTEX|Se.COPY_DST,shrinkToFit:!1}),s=new fo({data:mm,label:"index-batch-buffer",usage:Se.INDEX|Se.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 wc(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 we(`${s} placement hook does not exist in shader`)}}const ym=/\{\{(.*?)\}\}/g;function Sc(i){var s;const t={};return(((s=i.match(ym))==null?void 0:s.map(n=>n.replace(/[{()}]/g,"")))??[]).forEach(n=>{t[n]=[]}),t}function kc(i,t){let e;const s=/@in\s+([^;]+);/g;for(;(e=s.exec(i))!==null;)t.push(e[1])}function Tc(i,t,e=!1){const s=[];kc(t,s),i.forEach(l=>{l.header&&kc(l.header,s)});const n=s;e&&n.sort();const o=n.map((l,c)=>` @location(${c}) ${l},`).join(`
|
|
26
|
-
`);let r=t.replace(/@in\s+[^;]+;\s*/g,"");return r=r.replace("{{in}}",`
|
|
27
|
-
${o}
|
|
28
|
-
`),r}function Cc(i,t){let e;const s=/@out\s+([^;]+);/g;for(;(e=s.exec(i))!==null;)t.push(e[1])}function bm(i){const e=/\b(\w+)\s*:/g.exec(i);return e?e[1]:""}function vm(i){const t=/@.*?\s+/g;return i.replace(t,"")}function _m(i,t){const e=[];Cc(t,e),i.forEach(c=>{c.header&&Cc(c.header,e)});let s=0;const n=e.sort().map(c=>c.indexOf("builtin")>-1?c:`@location(${s++}) ${c}`).join(`,
|
|
29
|
-
`),o=e.sort().map(c=>` var ${vm(c)};`).join(`
|
|
30
|
-
`),r=`return VSOutput(
|
|
31
|
-
${e.sort().map(c=>` ${bm(c)}`).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 Ac(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 Li=Object.create(null),Qr=new Map;let xm=0;function wm({template:i,bits:t}){const e=lu(i,t);if(Li[e])return Li[e];const{vertex:s,fragment:n}=km(i,t);return Li[e]=cu(s,n,t),Li[e]}function Sm({template:i,bits:t}){const e=lu(i,t);return Li[e]||(Li[e]=cu(i.vertex,i.fragment,t)),Li[e]}function km(i,t){const e=t.map(r=>r.vertex).filter(r=>!!r),s=t.map(r=>r.fragment).filter(r=>!!r);let n=Tc(e,i.vertex,!0);n=_m(e,n);const o=Tc(s,i.fragment,!0);return{vertex:n,fragment:o}}function lu(i,t){return t.map(e=>(Qr.has(e)||Qr.set(e,xm++),Qr.get(e))).sort((e,s)=>e-s).join("-")+i.vertex+i.fragment}function cu(i,t,e){const s=Sc(i),n=Sc(t);return e.forEach(o=>{wc(o.vertex,s,o.name),wc(o.fragment,n,o.name)}),{vertex:Ac(i,s),fragment:Ac(t,n)}}const Tm=`
|
|
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
|
-
`,Cm=`
|
|
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
|
-
`,Am=`
|
|
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
|
-
`,Mm=`
|
|
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
|
-
`,Em={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
|
-
`}},Pm={name:"global-uniforms-bit",vertex:{header:`
|
|
176
|
-
uniform mat3 uProjectionMatrix;
|
|
177
|
-
uniform mat3 uWorldTransformMatrix;
|
|
178
|
-
uniform vec4 uWorldColorAlpha;
|
|
179
|
-
uniform vec2 uResolution;
|
|
180
|
-
`}};function Im({bits:i,name:t}){const e=wm({template:{fragment:Cm,vertex:Tm},bits:[Em,...i]});return kr.from({name:t,vertex:{source:e.vertex,entryPoint:"main"},fragment:{source:e.fragment,entryPoint:"main"}})}function Lm({bits:i,name:t}){return new zd({name:t,...Sm({template:{vertex:Am,fragment:Mm},bits:[Pm,...i]})})}const Bm={name:"color-bit",vertex:{header:`
|
|
181
|
-
@in aColor: vec4<f32>;
|
|
182
|
-
`,main:`
|
|
183
|
-
vColor *= vec4<f32>(aColor.rgb * aColor.a, aColor.a);
|
|
184
|
-
`}},Rm={name:"color-bit",vertex:{header:`
|
|
185
|
-
in vec4 aColor;
|
|
186
|
-
`,main:`
|
|
187
|
-
vColor *= vec4(aColor.rgb * aColor.a, aColor.a);
|
|
188
|
-
`}},Jr={};function $m(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 Dm(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 zm(i){return Jr[i]||(Jr[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
|
-
${$m(i)}
|
|
204
|
-
`,main:`
|
|
205
|
-
var uvDx = dpdx(vUV);
|
|
206
|
-
var uvDy = dpdy(vUV);
|
|
207
|
-
|
|
208
|
-
${Dm(i)}
|
|
209
|
-
`}}),Jr[i]}const ta={};function Fm(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 Nm(i){return ta[i]||(ta[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
|
-
${Fm(i)}
|
|
229
|
-
`}}),ta[i]}const Gm={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
|
-
`}},Wm={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
|
-
`}},Mc={};function Om(i){let t=Mc[i];if(t)return t;const e=new Int32Array(i);for(let s=0;s<i;s++)e[s]=s;return t=Mc[i]=new Wd({uTextures:{value:e,type:"i32",size:i}},{isStatic:!0}),t}class Ec extends Al{constructor(t){const e=Lm({name:"batch",bits:[Rm,Nm(t),Wm]}),s=Im({name:"batch",bits:[Bm,zm(t),Gm]});super({glProgram:e,gpuProgram:s,resources:{batchSamplers:Om(t)}}),this.maxTextures=t}}let $n=null;const hu=class du extends hm{constructor(t){super(t),this.geometry=new gm,this.name=du.extension.name,this.vertexSize=6,$n??($n=new Ec(t.maxTextures)),this.shader=$n}packAttributes(t,e,s,n,o){const r=o<<16|t.roundPixels&65535,l=t.transform,c=l.a,d=l.b,h=l.c,p=l.d,g=l.tx,m=l.ty,{positions:y,uvs:_}=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++]=c*H+h*$+g,e[n++]=p*$+d*H+m,e[n++]=_[L],e[n++]=_[L+1],s[n++]=w,s[n++]=r}}packQuadAttributes(t,e,s,n,o){const r=t.texture,l=t.transform,c=l.a,d=l.b,h=l.c,p=l.d,g=l.tx,m=l.ty,y=t.bounds,_=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]=c*w+h*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]=c*_+h*E+g,e[n+7]=p*E+d*_+m,e[n+8]=B.x1,e[n+9]=B.y1,s[n+10]=L,s[n+11]=H,e[n+12]=c*_+h*k+g,e[n+13]=p*k+d*_+m,e[n+14]=B.x2,e[n+15]=B.y2,s[n+16]=L,s[n+17]=H,e[n+18]=c*w+h*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&&($n=new Ec(t),this.shader=$n)}destroy(){this.shader=null,super.destroy()}};hu.extension={type:[bt.Batcher],name:"default"};let Hm=hu;class bo{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 Um(i,t,e,s,n,o,r,l=null){let c=0;e*=t,n*=o;const d=l.a,h=l.b,p=l.c,g=l.d,m=l.tx,y=l.ty;for(;c<r;){const _=i[e],w=i[e+1];s[n]=d*_+p*w+m,s[n+1]=h*_+g*w+y,n+=o,e+=t,c++}}function Vm(i,t,e,s){let n=0;for(t*=e;n<s;)i[t]=0,i[t+1]=0,t+=e,n++}function uu(i,t,e,s,n){const o=t.a,r=t.b,l=t.c,c=t.d,d=t.tx,h=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+c*y+h,p+=s}}const qm=new xt;class Il{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?gd(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)||qm}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 po={extension:{type:bt.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 c=Math.ceil(2.3*Math.sqrt(r+l)),d=c*8+(n?4:0)+(o?4:0);if(d===0)return!1;if(c===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 h=0,p=c*4+(n?2:0)+2,g=p,m=d,y=n+r,_=o,w=e+y,k=e-y,E=s+_;if(t[h++]=w,t[h++]=E,t[--p]=E,t[--p]=k,o){const L=s-_;t[g++]=k,t[g++]=L,t[--m]=L,t[--m]=w}for(let L=1;L<c;L++){const H=Math.PI/2*(L/c),$=n+Math.cos(H)*r,G=o+Math.sin(H)*l,et=e+$,Z=e-$,j=s+G,Q=s-G;t[h++]=et,t[h++]=j,t[--p]=j,t[--p]=Z,t[g++]=Z,t[g++]=Q,t[--m]=Q,t[--m]=et}y=n,_=o+l,w=e+y,k=e-y,E=s+_;const B=s-_;return t[h++]=w,t[h++]=E,t[--m]=B,t[--m]=w,n&&(t[h++]=k,t[h++]=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 h=0;h<i.length;h+=2)r+=i[h],l+=i[h+1];r/=i.length/2,l/=i.length/2;let c=s;t[c*e]=r,t[c*e+1]=l;const d=c++;for(let h=0;h<i.length;h+=2)t[c*e]=i[h],t[c*e+1]=i[h+1],h>0&&(n[o++]=c,n[o++]=d,n[o++]=c-1),c++;n[o++]=d+1,n[o++]=d,n[o++]=c-1}},Ym={...po,extension:{...po.extension,name:"ellipse"}},jm={...po,extension:{...po.extension,name:"roundedRectangle"}},fu=1e-4,Pc=1e-4;function Xm(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 Ic(i,t,e,s,n,o,r,l){const c=i-e*n,d=t-s*n,h=i+e*o,p=t+s*o;let g,m;r?(g=s,m=-e):(g=-s,m=e);const y=c+g,_=d+m,w=h+g,k=p+m;return l.push(y,_),l.push(w,k),2}function zi(i,t,e,s,n,o,r,l){const c=e-i,d=s-t;let h=Math.atan2(c,d),p=Math.atan2(n-i,o-t);l&&h<p?h+=Math.PI*2:!l&&h>p&&(p+=Math.PI*2);let g=h;const m=p-h,y=Math.abs(m),_=Math.sqrt(c*c+d*d),w=(15*y*Math.sqrt(_)/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)*_,t+Math.cos(B)*_);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)*_,t+Math.cos(B)*_),r.push(i,t);r.push(n,o),r.push(i,t)}return w*2}function Zm(i,t,e,s,n,o){const r=fu;if(i.length===0)return;const l=t;let c=l.alignment;if(t.alignment!==.5){let it=Xm(i);c=(c-.5)*it+.5}const d=new pe(i[0],i[1]),h=new pe(i[i.length-2],i[i.length-1]),p=s,g=Math.abs(d.x-h.x)<r&&Math.abs(d.y-h.y)<r;if(p){i=i.slice(),g&&(i.pop(),i.pop(),h.set(i[i.length-2],i[i.length-1]));const it=(d.x+h.x)*.5,yt=(h.y+d.y)*.5;i.unshift(it,yt),i.push(it,yt)}const m=n,y=i.length/2;let _=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],et=0,Z=0,j=-(H-G),Q=L-$,rt=0,lt=0,ct=Math.sqrt(j*j+Q*Q);j/=ct,Q/=ct,j*=k,Q*=k;const Gt=c,J=(1-Gt)*2,nt=Gt*2;p||(l.cap==="round"?_+=zi(L-j*(J-nt)*.5,H-Q*(J-nt)*.5,L-j*J,H-Q*J,L+j*nt,H+Q*nt,m,!0)+2:l.cap==="square"&&(_+=Ic(L,H,j,Q,J,nt,!0,m))),m.push(L-j*J,H-Q*J),m.push(L+j*nt,H+Q*nt);for(let it=1;it<y-1;++it){L=i[(it-1)*2],H=i[(it-1)*2+1],$=i[it*2],G=i[it*2+1],et=i[(it+1)*2],Z=i[(it+1)*2+1],j=-(H-G),Q=L-$,ct=Math.sqrt(j*j+Q*Q),j/=ct,Q/=ct,j*=k,Q*=k,rt=-(G-Z),lt=$-et,ct=Math.sqrt(rt*rt+lt*lt),rt/=ct,lt/=ct,rt*=k,lt*=k;const yt=$-L,Bt=H-G,wt=$-et,ft=Z-G,Ft=yt*wt+Bt*ft,qt=Bt*wt-ft*yt,ye=qt<0;if(Math.abs(qt)<.001*Math.abs(Ft)){m.push($-j*J,G-Q*J),m.push($+j*nt,G+Q*nt),Ft>=0&&(l.join==="round"?_+=zi($,G,$-j*J,G-Q*J,$-rt*J,G-lt*J,m,!1)+4:_+=2,m.push($-rt*nt,G-lt*nt),m.push($+rt*J,G+lt*J));continue}const Zt=(-j+L)*(-Q+G)-(-j+$)*(-Q+H),be=(-rt+et)*(-lt+G)-(-rt+$)*(-lt+Z),Le=(yt*be-wt*Zt)/qt,Ts=(ft*Zt-Bt*be)/qt,Be=(Le-$)*(Le-$)+(Ts-G)*(Ts-G),Ze=$+(Le-$)*J,Ke=G+(Ts-G)*J,Qe=$-(Le-$)*nt,Ue=G-(Ts-G)*nt,en=Math.min(yt*yt+Bt*Bt,wt*wt+ft*ft),Cs=ye?J:nt,Re=en+Cs*Cs*E;Be<=Re?l.join==="bevel"||Be/E>B?(ye?(m.push(Ze,Ke),m.push($+j*nt,G+Q*nt),m.push(Ze,Ke),m.push($+rt*nt,G+lt*nt)):(m.push($-j*J,G-Q*J),m.push(Qe,Ue),m.push($-rt*J,G-lt*J),m.push(Qe,Ue)),_+=2):l.join==="round"?ye?(m.push(Ze,Ke),m.push($+j*nt,G+Q*nt),_+=zi($,G,$+j*nt,G+Q*nt,$+rt*nt,G+lt*nt,m,!0)+4,m.push(Ze,Ke),m.push($+rt*nt,G+lt*nt)):(m.push($-j*J,G-Q*J),m.push(Qe,Ue),_+=zi($,G,$-j*J,G-Q*J,$-rt*J,G-lt*J,m,!1)+4,m.push($-rt*J,G-lt*J),m.push(Qe,Ue)):(m.push(Ze,Ke),m.push(Qe,Ue)):(m.push($-j*J,G-Q*J),m.push($+j*nt,G+Q*nt),l.join==="round"?ye?_+=zi($,G,$+j*nt,G+Q*nt,$+rt*nt,G+lt*nt,m,!0)+2:_+=zi($,G,$-j*J,G-Q*J,$-rt*J,G-lt*J,m,!1)+2:l.join==="miter"&&Be/E<=B&&(ye?(m.push(Qe,Ue),m.push(Qe,Ue)):(m.push(Ze,Ke),m.push(Ze,Ke)),_+=2),m.push($-rt*J,G-lt*J),m.push($+rt*nt,G+lt*nt),_+=2)}L=i[(y-2)*2],H=i[(y-2)*2+1],$=i[(y-1)*2],G=i[(y-1)*2+1],j=-(H-G),Q=L-$,ct=Math.sqrt(j*j+Q*Q),j/=ct,Q/=ct,j*=k,Q*=k,m.push($-j*J,G-Q*J),m.push($+j*nt,G+Q*nt),p||(l.cap==="round"?_+=zi($-j*(J-nt)*.5,G-Q*(J-nt)*.5,$-j*J,G-Q*J,$+j*nt,G+Q*nt,m,!1)+2:l.cap==="square"&&(_+=Ic($,G,j,Q,J,nt,!1,m)));const Dt=Pc*Pc;for(let it=w;it<_+w-2;++it)L=m[it*2],H=m[it*2+1],$=m[(it+1)*2],G=m[(it+1)*2+1],et=m[(it+2)*2],Z=m[(it+2)*2+1],!(Math.abs(L*(G-Z)+$*(Z-H)+et*(H-G))<Dt)&&o.push(it,it+1,it+2)}function Km(i,t,e,s){const n=fu;if(i.length===0)return;const o=i[0],r=i[1],l=i[i.length-2],c=i[i.length-1],d=t||Math.abs(o-l)<n&&Math.abs(r-c)<n,h=e,p=i.length/2,g=h.length/2;for(let m=0;m<p;m++)h.push(i[m*2]),h.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 pu(i,t,e,s,n,o,r){const l=Gp(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 c=n*s;for(let d=0;d<i.length;d+=2)e[c]=i[d],e[c+1]=i[d+1],c+=s}const Qm=[],Jm={extension:{type:bt.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){pu(i,Qm,t,e,s,n,o)}},tg={extension:{type:bt.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}},eg={extension:{type:bt.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}},Lc=[{offset:0,color:"white"},{offset:1,color:"black"}],Ll=class Za{constructor(...t){this.uid=Vt("fillGradient"),this._tick=0,this.type="linear",this.colorStops=[];let e=sg(t);e={...e.type==="radial"?Za.defaultRadialOptions:Za.defaultLinearOptions,...od(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 c=this.colorStops.length?this.colorStops:Lc,d=this._textureSize,{canvas:h,context:p}=Rc(d,1),g=l?p.createLinearGradient(this._textureSize,0,0,0):p.createLinearGradient(0,0,this._textureSize,0);Bc(g,c),p.fillStyle=g,p.fillRect(0,0,d,1),this.texture=new Lt({source:new hr({resource:h,addressMode:this._wrapMode})});const m=Math.sqrt(o*o+r*r),y=Math.atan2(r,o),_=new xt;_.scale(m/d,1),_.rotate(y),_.translate(t,e),this.textureSpace==="local"&&_.scale(d,d),this.transform=_}buildGradient(){this.texture||this._tick++,this.type==="linear"?this.buildLinearGradient():this.buildRadialGradient()}buildRadialGradient(){if(this.texture)return;const t=this.colorStops.length?this.colorStops:Lc,e=this._textureSize,{canvas:s,context:n}=Rc(e,e),{x:o,y:r}=this.center,{x:l,y:c}=this.outerCenter,d=this.innerRadius,h=this.outerRadius,p=l-h,g=c-h,m=e/(h*2),y=(o-p)*m,_=(r-g)*m,w=n.createRadialGradient(y,_,d*m,(l-p)*m,(c-g)*m,h*m);Bc(w,t),n.fillStyle=t[t.length-1].color,n.fillRect(0,0,e,e),n.fillStyle=w,n.translate(y,_),n.rotate(this.rotation),n.scale(1,this.scale),n.translate(-y,-_),n.fillRect(0,0,e,e),this.texture=new Lt({source:new hr({resource:s,addressMode:this._wrapMode})});const k=new xt;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}`}};Ll.defaultLinearOptions={start:{x:0,y:0},end:{x:0,y:1},colorStops:[],textureSpace:"local",type:"linear",textureSize:256,wrapMode:"clamp-to-edge"};Ll.defaultRadialOptions={center:{x:.5,y:.5},innerRadius:0,outerRadius:.5,colorStops:[],scale:1,textureSpace:"local",type:"radial",textureSize:256,wrapMode:"clamp-to-edge"};let ws=Ll;function Bc(i,t){for(let e=0;e<t.length;e++){const s=t[e];i.addColorStop(s.offset,s.color)}}function Rc(i,t){const e=Ie.get().createCanvas(i,t),s=e.getContext("2d");return{canvas:e,context:s}}function sg(i){let t=i[0]??{};return(typeof t=="number"||i[1])&&(At("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]??ws.defaultLinearOptions.textureSize}),t}const ig=new xt,ng=new Yt;function og(i,t,e,s){const n=t.matrix?i.copyFrom(t.matrix).invert():i.identity();if(t.textureSpace==="local"){const r=e.getBounds(ng);t.width&&r.pad(t.width);const{x:l,y:c}=r,d=1/r.width,h=1/r.height,p=-l*d,g=-c*h,m=n.a,y=n.b,_=n.c,w=n.d;n.a*=d,n.b*=d,n.c*=h,n.d*=h,n.tx=p*m+g*_+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 ws)&&o.addressMode==="clamp-to-edge"&&(o.addressMode="repeat",o.update()),s&&n.append(ig.copyFrom(s).invert()),n}const Tr={};jt.handleByMap(bt.ShapeBuilder,Tr);jt.add(tg,Jm,eg,po,Ym,jm);const rg=new Yt,ag=new xt;function lg(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")cg(o.data,s,e);else if(o.action==="fill"||o.action==="stroke"){const r=o.action==="stroke",l=o.data.path.shapePath,c=o.data.style,d=o.data.hole;r&&d&&$c(d.shapePath,c,!0,s,e),d&&(l.shapePrimitives[l.shapePrimitives.length-1].holes=d.shapePath.shapePrimitives),$c(l,c,r,s,e)}}}function cg(i,t,e){const s=[],n=Tr.rectangle,o=rg;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:c,indices:d}=e,h=d.length,p=l.length/2;r&&uu(s,r),n.triangulate(s,l,2,p,d,h);const g=i.image,m=g.uvs;c.push(m.x0,m.y0,m.x1,m.y1,m.x3,m.y3,m.x2,m.y2);const y=Te.get(Il);y.indexOffset=h,y.indexSize=d.length-h,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 $c(i,t,e,s,n){const{vertices:o,uvs:r,indices:l}=n;i.shapePrimitives.forEach(({shape:c,transform:d,holes:h})=>{const p=[],g=Tr[c.type];if(!g.build(c,p))return;const m=l.length,y=o.length/2;let _="triangle-list";if(d&&uu(p,d),e){const B=c.closePath??!0,L=t;L.pixelLine?(Km(p,B,o,l),_="line-list"):Zm(p,L,!1,B,o,l)}else if(h){const B=[],L=p.slice();hg(h).forEach($=>{B.push(L.length/2),L.push(...$)}),pu(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!==Lt.WHITE){const B=og(ag,t,c,d);Um(o,2,y,r,w,2,o.length/2-y,B)}else Vm(r,w,2,o.length/2-y);const E=Te.get(Il);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=_,s.push(E)})}function hg(i){const t=[];for(let e=0;e<i.length;e++){const s=i[e].shape,n=[];Tr[s.type].build(s,n)&&t.push(n)}return t}class dg{constructor(){this.batches=[],this.geometryData={vertices:[],uvs:[],indices:[]}}reset(){this.batches&&this.batches.forEach(t=>{Te.return(t)}),this.graphicsData&&Te.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 ug{constructor(){this.instructions=new kl}init(t){const e=t.maxTextures;this.batcher?this.batcher._updateMaxTextures(e):this.batcher=new Hm({maxTextures:e}),this.instructions.reset()}get geometry(){return At(lf,"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 Bl=class Ka{constructor(t){this._renderer=t,this._managedContexts=new bo({renderer:t,type:"resource",name:"graphicsContext"})}init(t){Ka.defaultOptions.bezierSmoothness=(t==null?void 0:t.bezierSmoothness)??Ka.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(),lg(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=Te.get(ug,{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 c=e.batcher;c.ensureAttributeBuffer(r),c.ensureIndexBuffer(l),c.begin();for(let p=0;p<n.length;p++){const g=n[p];c.add(g)}c.finish(e.instructions);const d=c.geometry;d.indexBuffer.setDataWithSize(c.indexBuffer,c.indexSize,!0),d.buffers[0].setDataWithSize(c.attributeBuffer.float32View,c.attributeSize,!0);const h=c.batches;for(let p=0;p<h.length;p++){const g=h[p];g.bindGroup=tm(g.textures.textures,g.textures.count,this._renderer.limits.maxBatchableTextures)}return e}_initContext(t){const e=new dg;return e.context=t,t._gpuData[this._renderer.uid]=e,this._managedContexts.add(t),e}destroy(){this._managedContexts.destroy(),this._renderer=null}};Bl.extension={type:[bt.WebGLSystem,bt.WebGPUSystem],name:"graphicsContext"};Bl.defaultOptions={bezierSmoothness:.5};let Rl=Bl;const fg=8,Lo=11920929e-14,pg=1;function mu(i,t,e,s,n,o,r,l,c,d){const p=Math.min(.99,Math.max(0,d??Rl.defaultOptions.bezierSmoothness));let g=(pg-p)/1;return g*=g,mg(t,e,s,n,o,r,l,c,i,g),i}function mg(i,t,e,s,n,o,r,l,c,d){Qa(i,t,e,s,n,o,r,l,c,d,0),c.push(r,l)}function Qa(i,t,e,s,n,o,r,l,c,d,h){if(h>fg)return;const p=(i+e)/2,g=(t+s)/2,m=(e+n)/2,y=(s+o)/2,_=(n+r)/2,w=(o+l)/2,k=(p+m)/2,E=(g+y)/2,B=(m+_)/2,L=(y+w)/2,H=(k+B)/2,$=(E+L)/2;if(h>0){let G=r-i,et=l-t;const Z=Math.abs((e-r)*et-(s-l)*G),j=Math.abs((n-r)*et-(o-l)*G);if(Z>Lo&&j>Lo){if((Z+j)*(Z+j)<=d*(G*G+et*et)){c.push(H,$);return}}else if(Z>Lo){if(Z*Z<=d*(G*G+et*et)){c.push(H,$);return}}else if(j>Lo){if(j*j<=d*(G*G+et*et)){c.push(H,$);return}}else if(G=H-(i+r)/2,et=$-(t+l)/2,G*G+et*et<=d){c.push(H,$);return}}Qa(i,t,p,g,k,E,H,$,c,d,h+1),Qa(H,$,B,L,_,w,r,l,c,d,h+1)}const gg=8,yg=11920929e-14,bg=1;function vg(i,t,e,s,n,o,r,l){const d=Math.min(.99,Math.max(0,l??Rl.defaultOptions.bezierSmoothness));let h=(bg-d)/1;return h*=h,_g(t,e,s,n,o,r,i,h),i}function _g(i,t,e,s,n,o,r,l){Ja(r,i,t,e,s,n,o,l,0),r.push(n,o)}function Ja(i,t,e,s,n,o,r,l,c){if(c>gg)return;const d=(t+s)/2,h=(e+n)/2,p=(s+o)/2,g=(n+r)/2,m=(d+p)/2,y=(h+g)/2;let _=o-t,w=r-e;const k=Math.abs((s-o)*w-(n-r)*_);if(k>yg){if(k*k<=l*(_*_+w*w)){i.push(m,y);return}}else if(_=m-(t+o)/2,w=y-(e+r)/2,_*_+w*w<=l){i.push(m,y);return}Ja(i,t,e,d,h,m,y,l,c+1),Ja(i,m,y,p,g,o,r,l,c+1)}function gu(i,t,e,s,n,o,r,l){let c=Math.abs(n-o);(!r&&n>o||r&&o>n)&&(c=2*Math.PI-c),l||(l=Math.max(6,Math.floor(6*Math.pow(s,1/3)*(c/Math.PI)))),l=Math.max(l,3);let d=c/l,h=n;d*=r?-1:1;for(let p=0;p<l+1;p++){const g=Math.cos(h),m=Math.sin(h),y=t+g*s,_=e+m*s;i.push(y,_),h+=d}}function xg(i,t,e,s,n,o){const r=i[i.length-2],c=i[i.length-1]-e,d=r-t,h=n-e,p=s-t,g=Math.abs(c*p-d*h);if(g<1e-8||o===0){(i[i.length-2]!==t||i[i.length-1]!==e)&&i.push(t,e);return}const m=c*c+d*d,y=h*h+p*p,_=c*h+d*p,w=o*Math.sqrt(m)/g,k=o*Math.sqrt(y)/g,E=w*_/m,B=k*_/y,L=w*p+k*d,H=w*h+k*c,$=d*(k+E),G=c*(k+E),et=p*(w+B),Z=h*(w+B),j=Math.atan2(G-H,$-L),Q=Math.atan2(Z-H,et-L);gu(i,L+t,H+e,o,j,Q,d*h>p*c)}const ao=Math.PI*2,ea={centerX:0,centerY:0,ang1:0,ang2:0},sa=({x:i,y:t},e,s,n,o,r,l,c)=>{i*=e,t*=s;const d=n*i-o*t,h=o*i+n*t;return c.x=d+r,c.y=h+l,c};function wg(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 Dc=(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)},Sg=(i,t,e,s,n,o,r,l,c,d,h,p,g)=>{const m=Math.pow(n,2),y=Math.pow(o,2),_=Math.pow(h,2),w=Math.pow(p,2);let k=m*y-m*w-y*_;k<0&&(k=0),k/=m*w+y*_,k=Math.sqrt(k)*(r===l?-1:1);const E=k*n/o*p,B=k*-o/n*h,L=d*E-c*B+(i+e)/2,H=c*E+d*B+(t+s)/2,$=(h-E)/n,G=(p-B)/o,et=(-h-E)/n,Z=(-p-B)/o,j=Dc(1,0,$,G);let Q=Dc($,G,et,Z);l===0&&Q>0&&(Q-=ao),l===1&&Q<0&&(Q+=ao),g.centerX=L,g.centerY=H,g.ang1=j,g.ang2=Q};function kg(i,t,e,s,n,o,r,l=0,c=0,d=0){if(o===0||r===0)return;const h=Math.sin(l*ao/360),p=Math.cos(l*ao/360),g=p*(t-s)/2+h*(e-n)/2,m=-h*(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)),Sg(t,e,s,n,o,r,c,d,h,p,g,m,ea);let{ang1:_,ang2:w}=ea;const{centerX:k,centerY:E}=ea;let B=Math.abs(w)/(ao/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 et=0;et<L;et++){const Z=wg(_,w),{x:j,y:Q}=sa(Z[0],o,r,p,h,k,E,G),{x:rt,y:lt}=sa(Z[1],o,r,p,h,k,E,G),{x:ct,y:Gt}=sa(Z[2],o,r,p,h,k,E,G);mu(i,H,$,j,Q,rt,lt,ct,Gt),H=ct,$=Gt,_+=w}}function Tg(i,t,e){const s=(r,l)=>{const c=l.x-r.x,d=l.y-r.y,h=Math.sqrt(c*c+d*d),p=c/h,g=d/h;return{len:h,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],c=l.radius??e;if(c<=0){n(r,l),o=l;continue}const d=t[(r+1)%t.length],h=s(l,o),p=s(l,d);if(h.len<1e-4||p.len<1e-4){n(r,l),o=l;continue}let g=Math.asin(h.nx*p.ny-h.ny*p.nx),m=1,y=!1;h.nx*p.nx-h.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 _=g/2;let w,k=Math.abs(Math.cos(_)*c/Math.sin(_));k>Math.min(h.len/2,p.len/2)?(k=Math.min(h.len/2,p.len/2),w=Math.abs(k*Math.sin(_)/Math.cos(_))):w=c;const E=l.x+p.nx*k+-p.ny*w*m,B=l.y+p.ny*k+p.nx*w*m,L=Math.atan2(h.ny,h.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 Cg(i,t,e,s){const n=(l,c)=>Math.sqrt((l.x-c.x)**2+(l.y-c.y)**2),o=(l,c,d)=>({x:l.x+(c.x-l.x)*d,y:l.y+(c.y-l.y)*d}),r=t.length;for(let l=0;l<r;l++){const c=t[(l+1)%r],d=c.radius??e;if(d<=0){l===0?i.moveTo(c.x,c.y):i.lineTo(c.x,c.y);continue}const h=t[l],p=t[(l+2)%r],g=n(h,c);let m;if(g<1e-4)m=c;else{const w=Math.min(g/2,d);m=o(c,h,w/g)}const y=n(p,c);let _;if(y<1e-4)_=c;else{const w=Math.min(y/2,d);_=o(c,p,w/y)}l===0?i.moveTo(m.x,m.y):i.lineTo(m.x,m.y),i.quadraticCurveTo(c.x,c.y,_.x,_.y,s)}}const Ag=new Yt;class Mg{constructor(t){this.shapePrimitives=[],this._currentPoly=null,this._bounds=new Oe,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 gu(l,t,e,s,n,o,r),this}arcTo(t,e,s,n,o){this._ensurePoly();const r=this._currentPoly.points;return xg(r,t,e,s,n,o),this}arcToSvg(t,e,s,n,o,r,l){const c=this._currentPoly.points;return kg(c,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 c=this._currentPoly;return mu(this._currentPoly.points,c.lastX,c.lastY,t,e,s,n,o,r,l),this}quadraticCurveTo(t,e,s,n,o){this._ensurePoly();const r=this._currentPoly;return vg(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 c=l.shape,d=o==null?void 0:o.shape;d&&d.containsPolygon(c)?(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 Ml(t,e,s),n),this}poly(t,e,s){const n=new oo(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,c=Math.PI*2/n,d=[];for(let h=0;h<n;h++){const p=l-h*c;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 c=s*Math.sin(Math.PI/n)-.001;o=Math.min(o,c);const d=-1*Math.PI/2+r,h=Math.PI*2/n,p=(n-2)*Math.PI/n/2;for(let g=0;g<n;g++){const m=g*h+d,y=t+s*Math.cos(m),_=e+s*Math.sin(m),w=m+Math.PI+p,k=m-Math.PI-p,E=y+o*Math.cos(w),B=_+o*Math.sin(w),L=y+o*Math.cos(k),H=_+o*Math.sin(k);g===0?this.moveTo(E,B):this.lineTo(E,B),this.quadraticCurveTo(y,_,L,H,l)}return this.closePath()}roundShape(t,e,s=!1,n){return t.length<3?this:(s?Cg(this,t,e,n):Tg(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)),c=t+s,d=e+n,h=l<0?-l:0,p=Math.abs(l);return this.moveTo(t,e+p).arcTo(t+h,e+h,t+p,e,p).lineTo(c-p,e).arcTo(c-h,e+h,c,e+p,p).lineTo(c,d-p).arcTo(c-h,d-h,t+s-p,d,p).lineTo(t+p,d).arcTo(t+h,d-h,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),c=t+s,d=e+n,h=[t+l,e,c-l,e,c,e+l,c,d-l,c-l,d,t+l,d,t,d-l,t,e+l];for(let p=h.length-1;p>=2;p-=2)h[p]===h[p-2]&&h[p-1]===h[p-3]&&h.splice(p-1,2);return this.poly(h,!0,r)}ellipse(t,e,s,n,o){return this.drawShape(new El(t,e,s,n),o),this}roundRect(t,e,s,n,o,r){return this.drawShape(new Pl(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 oo,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 oo,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(Ag);n.transform?t.addRect(o,n.transform):t.addRect(o)}return t}}class _s{constructor(t,e=!1){this.instructions=[],this.uid=Vt("graphicsPath"),this._dirty=!0,this.checkForHoles=e,typeof t=="string"?Zp(t,this):this.instructions=(t==null?void 0:t.slice())??[]}get shapePath(){return this._shapePath||(this._shapePath=new Mg(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 c=0,d=0;if(!r||r.action!=="bezierCurveTo")c=l.x,d=l.y;else{c=r.data[2],d=r.data[3];const h=l.x,p=l.y;c=h+(h-c),d=p+(p-d)}return this.instructions.push({action:"bezierCurveTo",data:[c,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 c=o.x,d=o.y;r=c+(c-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 c=-1*Math.PI/2+r,d=s*2,h=Math.PI*2/d,p=[];for(let g=0;g<d;g++){const m=g%2?o:n,y=g*h+c;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 _s;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 c=0,d=0,h=0,p=0,g=0,m=0,y=0,_=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":c=E[0],d=E[1],E[0]=e*c+n*d+r,E[1]=s*c+o*d+l;break;case"bezierCurveTo":h=E[0],p=E[1],g=E[2],m=E[3],c=E[4],d=E[5],E[0]=e*h+n*p+r,E[1]=s*h+o*p+l,E[2]=e*g+n*m+r,E[3]=s*g+o*m+l,E[4]=e*c+n*d+r,E[5]=s*c+o*d+l;break;case"quadraticCurveTo":h=E[0],p=E[1],c=E[2],d=E[3],E[0]=e*h+n*p+r,E[1]=s*h+o*p+l,E[2]=e*c+n*d+r,E[3]=s*c+o*d+l;break;case"arcToSvg":c=E[5],d=E[6],y=E[0],_=E[1],E[0]=e*y+n*_,E[1]=s*y+o*_,E[5]=e*c+n*d+r,E[6]=s*c+o*d+l;break;case"circle":E[4]=Dn(E[3],t);break;case"rect":E[4]=Dn(E[4],t);break;case"ellipse":E[8]=Dn(E[8],t);break;case"roundRect":E[5]=Dn(E[5],t);break;case"addPath":E[0].transform(t);break;case"poly":E[2]=Dn(E[2],t);break;default:we("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 Dn(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 Eg(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]=Pg(r);break;case"radialgradient":t.defs[r.id]=Ig();break}}}}function Pg(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 ws(t,e,s,n,o==="objectBoundingBox"?"local":"global");for(let l=0;l<i.children.length;l++){const c=i.children[l],d=Ht(c,"offset",0),h=Kt.shared.setValue(c.getAttribute("stop-color")).toNumber();r.addColorStop(d,h)}return r}function Ig(i){return we("[SVG Parser] Radial gradients are not yet supported"),new ws(0,0,1,0)}function zc(i){const t=i.match(/url\s*\(\s*['"]?\s*#([^'"\s)]+)\s*['"]?\s*\)/i);return t?t[1]:""}const Fc={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 yu(i,t){const e=i.getAttribute("style"),s={},n={},o={strokeStyle:s,fillStyle:n,useFill:!1,useStroke:!1};for(const r in Fc){const l=i.getAttribute(r);l&&Nc(t,o,r,l.trim())}if(e){const r=e.split(";");for(let l=0;l<r.length;l++){const c=r[l].trim(),[d,h]=c.split(":");Fc[d]&&Nc(t,o,d,h.trim())}}return{strokeStyle:o.useStroke?s:null,fillStyle:o.useFill?n:null,useFill:o.useFill,useStroke:o.useStroke}}function Nc(i,t,e,s){switch(e){case"stroke":if(s!=="none"){if(s.startsWith("url(")){const n=zc(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=zc(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 Lg(i){if(i.length<=2)return!0;const t=i.map(l=>l.area).sort((l,c)=>c-l),[e,s]=t,n=t[t.length-1],o=e/s,r=s/n;return!(o>3&&r<2)}function Bg(i){return i.split(/(?=[Mm])/).filter(s=>s.trim().length>0)}function Rg(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 h=0;h<e.length;h+=2)h+1<e.length&&(s.push(e[h]),n.push(e[h+1]));if(s.length===0||n.length===0)return 0;const o=Math.min(...s),r=Math.max(...s),l=Math.min(...n),c=Math.max(...n);return(r-o)*(c-l)}function Gc(i,t){const e=new _s(i,!1);for(const s of e.instructions)t.instructions.push(s)}function $g(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 _s};Eg(i,e);const s=i.children,{fillStyle:n,strokeStyle:o}=yu(i,e);for(let r=0;r<s.length;r++){const l=s[r];l.nodeName.toLowerCase()!=="defs"&&bu(l,e,n,o)}return t}function bu(i,t,e,s){const n=i.children,{fillStyle:o,strokeStyle:r}=yu(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 c,d,h,p,g,m,y,_,w,k,E,B,L,H,$,G,et;switch(i.nodeName.toLowerCase()){case"path":{H=i.getAttribute("d");const Z=i.getAttribute("fill-rule"),j=Bg(H),Q=Z==="evenodd",rt=j.length>1;if(Q&&rt){const ct=j.map(J=>({path:J,area:Rg(J)}));if(ct.sort((J,nt)=>nt.area-J.area),j.length>3||!Lg(ct))for(let J=0;J<ct.length;J++){const nt=ct[J],Dt=J===0;t.context.beginPath();const it=new _s(void 0,!0);Gc(nt.path,it),t.context.path(it),Dt?(e&&t.context.fill(e),s&&t.context.stroke(s)):t.context.cut()}else for(let J=0;J<ct.length;J++){const nt=ct[J],Dt=J%2===1;t.context.beginPath();const it=new _s(void 0,!0);Gc(nt.path,it),t.context.path(it),Dt?t.context.cut():(e&&t.context.fill(e),s&&t.context.stroke(s))}}else{const ct=Z?Z==="evenodd":!0;$=new _s(H,ct),t.context.path($),e&&t.context.fill(e),s&&t.context.stroke(s)}break}case"circle":y=Ht(i,"cx",0),_=Ht(i,"cy",0),w=Ht(i,"r",0),t.context.ellipse(y,_,w,w),e&&t.context.fill(e),s&&t.context.stroke(s);break;case"rect":c=Ht(i,"x",0),d=Ht(i,"y",0),G=Ht(i,"width",0),et=Ht(i,"height",0),k=Ht(i,"rx",0),E=Ht(i,"ry",0),k||E?t.context.roundRect(c,d,G,et,k||E):t.context.rect(c,d,G,et),e&&t.context.fill(e),s&&t.context.stroke(s);break;case"ellipse":y=Ht(i,"cx",0),_=Ht(i,"cy",0),k=Ht(i,"rx",0),E=Ht(i,"ry",0),t.context.beginPath(),t.context.ellipse(y,_,k,E),e&&t.context.fill(e),s&&t.context.stroke(s);break;case"line":h=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(h,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:{we(`[SVG parser] <${i.nodeName}> elements unsupported`);break}}l&&(e=null);for(let Z=0;Z<n.length;Z++)bu(n[Z],t,e,s)}const Wc={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 Cr{constructor(t,e){this.uid=Vt("fillPattern"),this._tick=0,this.transform=new xt,this.texture=t,this.transform.scale(1/t.frame.width,1/t.frame.height),e&&(t.source.style.addressModeU=Wc[e].addressModeU,t.source.style.addressModeV=Wc[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 Dg(i){return Kt.isColorLike(i)}function Oc(i){return i instanceof Cr}function Hc(i){return i instanceof ws}function zg(i){return i instanceof Lt}function Fg(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=Lt.WHITE,{...e,...i}}function Ng(i,t,e){return i.texture=t,{...e,...i}}function Uc(i,t,e){return i.fill=t,i.color=16777215,i.texture=t.texture,i.matrix=t.transform,{...e,...i}}function Vc(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 Gg(i,t){const e={...t,...i},s=Kt.shared.setValue(e.color);return e.alpha*=s.alpha,e.color=s.toNumber(),e}function Zi(i,t){if(i==null)return null;const e={},s=i;return Dg(i)?Fg(e,i,t):zg(i)?Ng(e,i,t):Oc(i)?Uc(e,i,t):Hc(i)?Vc(e,i,t):s.fill&&Oc(s.fill)?Uc(s,s.fill,t):s.fill&&Hc(s.fill)?Vc(s,s.fill,t):Gg(s,t)}function fr(i,t){const{width:e,alignment:s,miterLimit:n,cap:o,join:r,pixelLine:l,...c}=t,d=Zi(i,c);return d?{width:e,alignment:s,miterLimit:n,cap:o,join:r,pixelLine:l,...d}:null}function Wg(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 c=o.closePath;for(let d=0;d<l;d+=2){if(!c&&(d===0||d===l-2))continue;const h=(d-2+l)%l,p=(d+2)%l,g=r[h],m=r[h+1],y=r[d],_=r[d+1],w=r[p],k=r[p+1],E=g-y,B=m-_,L=w-y,H=k-_,$=E*E+B*B,G=L*L+H*H;if($<1e-12||G<1e-12)continue;let j=(E*L+B*H)/Math.sqrt($*G);j<-1?j=-1:j>1&&(j=1);const Q=Math.sqrt((1-j)*.5);if(Q<1e-6)continue;const rt=Math.min(1/Q,t);rt>e&&(e=rt)}}return e}const Og=new pe,qc=new xt,$l=class is extends cs{constructor(){super(...arguments),this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this.uid=Vt("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this.destroyed=!1,this._activePath=new _s,this._transform=new xt,this._fillStyle={...is.defaultFillStyle},this._strokeStyle={...is.defaultStrokeStyle},this._stateStack=[],this._tick=0,this._bounds=new Oe,this._boundsDirty=!0}clone(){const t=new is;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=Zi(t,is.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(t){this._strokeStyle=fr(t,is.defaultStrokeStyle)}setFillStyle(t){return this._fillStyle=Zi(t,is.defaultFillStyle),this}setStrokeStyle(t){return this._strokeStyle=Zi(t,is.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 _s,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"&&(At(Ut,"GraphicsContext.fill(color, alpha) is deprecated, use GraphicsContext.fill({ color, alpha }) instead"),t={color:t,alpha:e}),this._fillStyle=Zi(t,is.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=fr(t,is.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 c=this._transform;return this._activePath.arcToSvg(t,e,s,n,o,c.a*r+c.c*l+c.tx,c.b*r+c.d*l+c.ty),this}bezierCurveTo(t,e,s,n,o,r,l){this._tick++;const c=this._transform;return this._activePath.bezierCurveTo(c.a*t+c.c*e+c.tx,c.b*t+c.d*e+c.ty,c.a*s+c.c*n+c.tx,c.b*s+c.d*n+c.ty,c.a*o+c.c*r+c.tx,c.b*o+c.d*r+c.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++,$g(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 xt?(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 xt?(this._transform.append(t),this):(qc.set(t,e,s,n,o,r),this._transform.append(qc),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*=Wg(o.path,o.style.miterLimit));const c=o.path.bounds;t.addFrame(c.minX-l,c.minY-l,c.maxX+l,c.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,c=l.path;if(!r.action||!c)continue;const d=l.style,h=c.shapePath.shapePrimitives;for(let p=0;p<h.length;p++){const g=h[p].shape;if(!d||!g)continue;const m=h[p].transform,y=m?m.applyInverse(t,Og):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 _=l.hole;if(_){const w=(n=_.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}};$l.defaultFillStyle={color:16777215,alpha:1,texture:Lt.WHITE,matrix:null,fill:null,textureSpace:"local"};$l.defaultStrokeStyle={width:1,color:16777215,alpha:1,alignment:.5,miterLimit:10,cap:"butt",join:"miter",texture:Lt.WHITE,matrix:null,fill:null,textureSpace:"local",pixelLine:!1};let je=$l;class Hg{constructor(){this.isBatchable=!1}reset(){this.isBatchable=!1,this.context=null,this.graphicsData&&(this.graphicsData.destroy(),this.graphicsData=null)}destroy(){this.reset()}}class Ug{constructor(){this.instructions=new kl}init(){this.instructions.reset()}destroy(){this.instructions.destroy(),this.instructions=null}}const Dl=class tl{constructor(t){this._renderer=t,this._managedContexts=new bo({renderer:t,type:"resource",name:"graphicsContext"})}init(t){tl.defaultOptions.bezierSmoothness=(t==null?void 0:t.bezierSmoothness)??tl.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 Ug,s=this.getGpuContext(t);return s.graphicsData=e,e.init(),e}_initContext(t){const e=new Hg;return e.context=t,t._gpuData[this._renderer.uid]=e,this._managedContexts.add(t),e}destroy(){this._managedContexts.destroy(),this._renderer=null}};Dl.extension={type:[bt.CanvasSystem],name:"graphicsContext"};Dl.defaultOptions={bezierSmoothness:.5};let Vg=Dl;class vu{constructor(t,e){this.state=Hd.for2d(),this.renderer=t,this._adaptor=e,this.renderer.runners.contextChange.add(this),this._managedGraphics=new bo({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}}vu.extension={type:[bt.CanvasPipes],name:"graphics"};function qg(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 Yg{constructor(){this.batches=[],this.batched=!1}destroy(){this.batches.forEach(t=>{Te.return(t)}),this.batches.length=0}}class _u{constructor(t,e){this.state=Hd.for2d(),this.renderer=t,this._adaptor=e,this.renderer.runners.contextChange.add(this),this._managedGraphics=new bo({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,qg(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 Yg;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 c=Te.get(Il);return l.copyTo(c),c.renderable=t,c.roundPixels=r,c})}destroy(){this._managedGraphics.destroy(),this.renderer=null,this._adaptor.destroy(),this._adaptor=null,this.state=null}}_u.extension={type:[bt.WebGLPipes,bt.WebGPUPipes],name:"graphics"};jt.add(vu);jt.add(_u);jt.add(Vg);jt.add(Rl);class Wt extends Tl{constructor(t){t instanceof je&&(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 je,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){At(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){At(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(){At(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!==je.defaultStrokeStyle.width||t.color!==je.defaultStrokeStyle.color||t.alpha!==je.defaultStrokeStyle.alpha)&&this.context.stroke(),this}drawCircle(...t){return At(Ut,"Graphics#drawCircle has been renamed to Graphics#circle"),this._callContextMethod("circle",t)}drawEllipse(...t){return At(Ut,"Graphics#drawEllipse has been renamed to Graphics#ellipse"),this._callContextMethod("ellipse",t)}drawPolygon(...t){return At(Ut,"Graphics#drawPolygon has been renamed to Graphics#poly"),this._callContextMethod("poly",t)}drawRect(...t){return At(Ut,"Graphics#drawRect has been renamed to Graphics#rect"),this._callContextMethod("rect",t)}drawRoundedRect(...t){return At(Ut,"Graphics#drawRoundedRect has been renamed to Graphics#roundRect"),this._callContextMethod("roundRect",t)}drawStar(...t){return At(Ut,"Graphics#drawStar has been renamed to Graphics#star"),this._callContextMethod("star",t)}}class jg extends Tl{constructor(t,e){const{text:s,resolution:n,style:o,anchor:r,width:l,height:c,roundPixels:d,...h}=t;super({...h}),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),c!==void 0&&(this.height=c)}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 Xg(i,t){let e=i[0]??{};return(typeof e=="string"||i[1])&&(At(Ut,`use new ${t}({ text: "hi!", style }) instead`),e={text:e,style:i[1]}),e}class Zg{constructor(t){this._canvasPool=Object.create(null),this.canvasOptions=t||{},this.enableFullScreen=!1}_createCanvasAndContext(t,e){const s=Ie.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=kn(t),e=kn(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 el=new Zg;yo.register(el);let Fi=null,bs=null;function Kg(i,t){Fi||(Fi=Ie.get().createCanvas(256,128),bs=Fi.getContext("2d",{willReadFrequently:!0}),bs.globalCompositeOperation="copy",bs.globalAlpha=1),(Fi.width<i||Fi.height<t)&&(Fi.width=kn(i),Fi.height=kn(t))}function Yc(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 jc(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 Qg(...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(Kg(n,o),!bs)throw new TypeError("Failed to get canvas 2D context");bs.drawImage(e,0,0,n,o,0,0,n*s,o*s);const c=bs.getImageData(0,0,n,o).data;let d=0,h=0,p=n-1,g=o-1;for(;h<o&&Yc(c,n,h);)++h;if(h===o)return Yt.EMPTY;for(;Yc(c,n,g);)--g;for(;jc(c,n,d,h,g);)++d;for(;jc(c,n,p,h,g);)--p;return++p,++g,bs.globalCompositeOperation="source-over",bs.strokeRect(d,h,p-d,g-h),bs.globalCompositeOperation="copy",r??(r=new Yt),r.set(d/s,h/s,(p-d)/s,(g-h)/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 Jg{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 t0(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 Jg(i,t,e)}function xu(i){return!!i.tagStyles&&Object.keys(i.tagStyles).length>0}function wu(i){return i.includes("<")}function e0(i,t){return i.clone().assign(t)}function s0(i,t){const e=[],s=t.tagStyles;if(!xu(t)||!wu(i))return e.push({text:i,style:t}),e;const n=[t],o=[];let r="",l=0;for(;l<i.length;){const c=i[l];if(c==="<"){const d=i.indexOf(">",l);if(d===-1){r+=c,l++;continue}const h=i.slice(l+1,d);if(h.startsWith("/")){const p=h.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=h.trim();if(s[p]){r.length>0&&(e.push({text:r,style:n[n.length-1]}),r="");const g=n[n.length-1],m=e0(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+=c,l++}return r.length>0&&e.push({text:r,style:n[n.length-1]}),e}const i0=[10,13],n0=new Set(i0),o0=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288],r0=new Set(o0),a0=[9,32];new Set(a0);const l0=[45,8208,8211,8212,173],c0=new Set(l0),h0=/(\r\n|\r|\n)/,d0=/(?:\r\n|\r|\n)/;function pr(i){return typeof i!="string"?!1:n0.has(i.charCodeAt(0))}function Ge(i,t){return typeof i!="string"?!1:r0.has(i.charCodeAt(0))}function u0(i){return typeof i!="string"?!1:c0.has(i.charCodeAt(0))}function Su(i){return i==="normal"||i==="pre-line"}function ku(i){return i==="normal"}function ys(i){if(typeof i!="string")return"";let t=i.length-1;for(;t>=0&&Ge(i[t]);)t--;return t<i.length-1?i.slice(0,t+1):i}function Tu(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(Ge(n)||pr(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),u0(n)&&o&&!Ge(o)&&!pr(o)&&(t.push(e.join("")),e.length=0)}return e.length>0&&t.push(e.join("")),t}function Cu(i,t,e,s){const n=e(i),o=[];for(let r=0;r<n.length;r++){let l=n[r],c=l,d=1;for(;n[r+d];){const h=n[r+d];if(!s(c,h,i,r,t))l+=h,c=h,d++;else break}r+=d-1,o.push(l)}return o}const f0=/\r\n|\r|\n/g;function p0(i,t,e,s,n,o,r,l){var Gt,J;const c=s0(i,t);if(ku(t.whiteSpace))for(let nt=0;nt<c.length;nt++){const Dt=c[nt];c[nt]={text:Dt.text.replace(f0," "),style:Dt.style}}const h=[];let p=[];for(const nt of c){const Dt=nt.text.split(h0);for(let it=0;it<Dt.length;it++){const yt=Dt[it];yt===`\r
|
|
248
|
-
`||yt==="\r"||yt===`
|
|
249
|
-
`?(h.push(p),p=[]):yt.length>0&&p.push({text:yt,style:nt.style})}}(p.length>0||h.length===0)&&h.push(p);const g=e?m0(h,t,s,n,r,l):h,m=[],y=[],_=[],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=((Gt=t._stroke)==null?void 0:Gt.width)||0;for(const nt of g){let Dt=0,it=L.ascent,yt=L.descent,Bt="";for(const ft of nt){const Ft=ft.style._fontString,qt=o(Ft);Ft!==H&&(s.font=Ft,H=Ft);const ye=n(ft.text,ft.style.letterSpacing,s);Dt+=ye,it=Math.max(it,qt.ascent),yt=Math.max(yt,qt.descent),Bt+=ft.text;const Zt=((J=ft.style._stroke)==null?void 0:J.width)||0;Zt>G&&(G=Zt),!$&&ft.style.dropShadow&&($=!0)}nt.length===0&&(it=L.ascent,yt=L.descent),m.push(Dt),y.push(it),_.push(yt),k.push(Bt);const wt=t.lineHeight||it+yt;w.push(wt+t.leading),E=Math.max(E,Dt)}const et=G,Q=(e&&t.align!=="left"?Math.max(E,t.wordWrapWidth):E)+et+(t.dropShadow?t.dropShadow.distance:0);let rt=0;for(let nt=0;nt<w.length;nt++)rt+=w[nt];rt=Math.max(rt,w[0]+et);const lt=rt+(t.dropShadow?t.dropShadow.distance:0),ct=t.lineHeight||L.fontSize;return{width:Q,height:lt,lines:k,lineWidths:m,lineHeight:ct+t.leading,maxLineWidth:E,fontProperties:L,runsByLine:g,lineAscents:y,lineDescents:_,lineHeights:w,hasDropShadow:$}}function m0(i,t,e,s,n,o){var w;const{letterSpacing:r,whiteSpace:l,wordWrapWidth:c,breakWords:d}=t,h=Su(l),p=c+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},_=[];for(const k of i){const E=g0(k),B=_.length,L=rt=>{let lt=0,ct=rt;do{const{token:Gt,style:J}=E[ct];lt+=y(Gt,J),ct++}while(ct<E.length&&E[ct].continuesFromPrevious);return lt},H=rt=>{const lt=[];let ct=rt;do lt.push({token:E[ct].token,style:E[ct].style}),ct++;while(ct<E.length&&E[ct].continuesFromPrevious);return lt};let $=[],G=0,et=!h,Z=null;const j=()=>{Z&&Z.text.length>0&&$.push(Z),Z=null},Q=()=>{if(j(),$.length>0){const rt=$[$.length-1];rt.text=ys(rt.text),rt.text.length===0&&$.pop()}_.push($),$=[],G=0,et=!1};for(let rt=0;rt<E.length;rt++){const{token:lt,style:ct,continuesFromPrevious:Gt}=E[rt],J=y(lt,ct);if(h){const it=Ge(lt),yt=(Z==null?void 0:Z.text[Z.text.length-1])??((w=$[$.length-1])==null?void 0:w.text.slice(-1))??"",Bt=yt?Ge(yt):!1;if(it&&Bt)continue}const nt=!Gt,Dt=nt?L(rt):J;if(Dt>p&&nt)if(G>0&&Q(),d){const it=H(rt);for(let yt=0;yt<it.length;yt++){const Bt=it[yt].token,wt=it[yt].style,ft=Cu(Bt,d,o,n);for(const Ft of ft){const qt=y(Ft,wt);qt+G>p&&Q(),!Z||Z.style!==wt?(j(),Z={text:Ft,style:wt}):Z.text+=Ft,G+=qt}}rt+=it.length-1}else{const it=H(rt);j(),_.push(it.map(yt=>({text:yt.token,style:yt.style}))),et=!1,rt+=it.length-1}else if(Dt+G>p&&nt){if(Ge(lt)){et=!1;continue}Q(),Z={text:lt,style:ct},G=J}else if(Gt&&!d)!Z||Z.style!==ct?(j(),Z={text:lt,style:ct}):Z.text+=lt,G+=J;else{const it=Ge(lt);if(G===0&&it&&!et)continue;!Z||Z.style!==ct?(j(),Z={text:lt,style:ct}):Z.text+=lt,G+=J}}if(j(),$.length>0){const rt=$[$.length-1];rt.text=ys(rt.text),rt.text.length===0&&$.pop()}($.length>0||_.length===B)&&_.push($)}return _}function g0(i){const t=[];let e=!1;for(const s of i){const n=Tu(s.text);let o=!0;for(const r of n){const l=Ge(r)||pr(r),c=o&&e&&!l;t.push({token:r,style:s.style,continuesFromPrevious:c}),e=!l,o=!1}}return t}const y0={willReadFrequently:!0};function Xc(i,t,e,s,n){let o=e[i];return typeof o!="number"&&(o=n(i,t,s)+t,e[i]=o),o}function b0(i,t,e,s,n,o,r){const l=e.getContext("2d",y0);l.font=t._fontString;let c=0,d="";const h=[],p=Object.create(null),{letterSpacing:g,whiteSpace:m}=t,y=Su(m),_=ku(m);let w=!y;const k=t.wordWrapWidth+g,E=Tu(i);for(let L=0;L<E.length;L++){let H=E[L];if(pr(H)){if(!_){h.push(ys(d)),w=!y,d="",c=0;continue}H=" "}if(y){const G=Ge(H),et=Ge(d[d.length-1]);if(G&&et)continue}const $=Xc(H,g,p,l,s);if($>k)if(d!==""&&(h.push(ys(d)),d="",c=0),n(H,t.breakWords)){const G=Cu(H,t.breakWords,r,o);for(const et of G){const Z=Xc(et,g,p,l,s);Z+c>k&&(h.push(ys(d)),w=!1,d="",c=0),d+=et,c+=Z}}else d.length>0&&(h.push(ys(d)),d="",c=0),h.push(ys(H)),w=!1,d="",c=0;else $+c>k&&(w=!1,h.push(ys(d)),d="",c=0),(d.length>0||!Ge(H)||w)&&(d+=H,c+=$)}const B=ys(d);return B.length>0&&h.push(B),h.join(`
|
|
250
|
-
`)}const Zc={willReadFrequently:!0},ks=class dt{static get experimentalLetterSpacingSupported(){let t=dt._experimentalLetterSpacingSupported;if(t===void 0){const e=Ie.get().getCanvasRenderingContext2D().prototype;t=dt._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,s,n,o,r,l,c,d,h){this.text=t,this.style=e,this.width=s,this.height=n,this.lines=o,this.lineWidths=r,this.lineHeight=l,this.maxLineWidth=c,this.fontProperties=d,h&&(this.runsByLine=h.runsByLine,this.lineAscents=h.lineAscents,this.lineDescents=h.lineDescents,this.lineHeights=h.lineHeights,this.hasDropShadow=h.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(xu(e)&&wu(t)){const $=p0(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,c=dt.measureFont(l);c.fontSize===0&&(c.fontSize=e.fontSize,c.ascent=e.fontSize,c.descent=0);const d=dt._context;d.font=l;const p=(n?dt._wordWrap(t,e,s):t).split(d0),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,_=e.lineHeight||c.fontSize,w=dt._getAlignWidth(m,e,n),k=dt._adjustWidthForStyle(w,e),E=Math.max(_,c.fontSize+y)+(p.length-1)*(_+e.leading),B=dt._adjustHeightForStyle(E,e),L=new dt(t,e,k,B,p,g,_+e.leading,m,c);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 h=(dt.graphemeSegmenter(t).length-1)*e;r+=h,d+=h}return Math.max(r,d)}static _wordWrap(t,e,s=dt._canvas){return b0(t,e,s,dt._measureText,dt.canBreakWords,dt.canBreakChars,dt.wordWrapSplit)}static isBreakingSpace(t,e){return Ge(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",Zc);if(s!=null&&s.measureText)return dt.__canvas=e,e;t=Ie.get().createCanvas()}catch{t=Ie.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",Zc)),dt.__context}};ks.METRICS_STRING="|ÉqÅ";ks.BASELINE_SYMBOL="M";ks.BASELINE_MULTIPLIER=1.4;ks.HEIGHT_MULTIPLIER=2;ks.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]})();ks.experimentalLetterSpacing=!1;ks._fonts={};ks._measurementCache=t0(1e3);let xi=ks;const v0=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function sl(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)&&!v0.includes(n)&&(n=`"${n}"`),e[s]=n}return`${i.fontStyle} ${i.fontVariant} ${i.fontWeight} ${t} ${e.join(",")}`}const Kc=1e5;function Bo(i,t,e,s=0,n=0,o=0){if(i.texture===Lt.WHITE&&!i.fill)return Kt.shared.setValue(i.color).setAlpha(i.alpha??1).toHexa();if(i.fill){if(i.fill instanceof Cr){const r=i.fill,l=t.createPattern(r.texture.source.resource,"repeat"),c=r.transform.copyTo(xt.shared);return c.scale(r.texture.source.pixelWidth,r.texture.source.pixelHeight),l.setTransform(c),l}else if(i.fill instanceof ws){const r=i.fill,l=r.type==="linear",c=r.textureSpace==="local";let d=1,h=1;c&&e&&(d=e.width+s,h=e.height+s);let p,g=!1;if(l){const{start:m,end:y}=r;p=t.createLinearGradient(m.x*d+n,m.y*h+o,y.x*d+n,y.y*h+o),g=Math.abs(y.x-m.x)<Math.abs((y.y-m.y)*.1)}else{const{center:m,innerRadius:y,outerCenter:_,outerRadius:w}=r;p=t.createRadialGradient(m.x*d+n,m.y*h+o,y*d,_.x*d+n,_.y*h+o,w*d)}if(g&&c&&e){const m=e.lineHeight/h;for(let y=0;y<e.lines.length;y++){const _=(y*e.lineHeight+s/2)/h;r.colorStops.forEach(w=>{let k=_+w.offset*m;k=Math.max(0,Math.min(1,k)),p.addColorStop(Math.floor(k*Kc)/Kc,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(xt.shared);return l.scale(i.texture.source.pixelWidth,i.texture.source.pixelHeight),r.setTransform(l),r}return we("FillStyle not recognised",i),"red"}const Qc=new Yt;function on(i){let t=0;for(let e=0;e<i.length;e++)i.charCodeAt(e)===32&&t++;return t}class _0{getCanvasAndContext(t){const{text:e,style:s,resolution:n=1}=t,o=s._getFinalPadding(),r=xi.measureText(e||" ",s),l=Math.ceil(Math.ceil(Math.max(1,r.width)+o*2)*n),c=Math.ceil(Math.ceil(Math.max(1,r.height)+o*2)*n),d=el.getOptimalCanvasAndContext(l,c);this._renderTextToCanvas(s,o,n,d,r);const h=s.trim?Qg({canvas:d.canvas,width:l,height:c,resolution:1,output:Qc}):Qc.set(0,0,l,c);return{canvasAndContext:d,frame:h}}returnCanvasAndContext(t){el.returnCanvasAndContext(t)}_renderTextToCanvas(t,e,s,n,o){var $,G,et;if(o.runsByLine&&o.runsByLine.length>0){this._renderTaggedTextToCanvas(o,t,e,s,n);return}const{canvas:r,context:l}=n,c=sl(t),d=o.lines,h=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=c;let _,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=(h-m.fontSize)/2;h-m.fontSize<0&&(H=0);for(let Z=0;Z<k;++Z){const j=t.dropShadow&&Z===0,Q=j?Math.ceil(Math.max(1,y)+e*2):0,rt=Q*s;if(j)this._setupDropShadow(l,t,s,rt);else{const lt=t._gradientBounds,ct=t._gradientOffset;if(lt){const Gt={width:lt.width,height:lt.height,lineHeight:lt.height,lines:o.lines};this._setFillAndStrokeStyles(l,t,Gt,e,L,(ct==null?void 0:ct.x)??0,(ct==null?void 0:ct.y)??0)}else ct?this._setFillAndStrokeStyles(l,t,o,e,L,ct.x,ct.y):this._setFillAndStrokeStyles(l,t,o,e,L);l.shadowColor="rgba(0,0,0,0)"}for(let lt=0;lt<d.length;lt++){_=L,w=L+lt*h+m.ascent+H,_+=this._getAlignmentOffset(p[lt],E,t.align);let ct=0;if(t.align==="justify"&&t.wordWrap&<<d.length-1){const Gt=on(d[lt]);Gt>0&&(ct=(E-p[lt])/Gt)}(et=t._stroke)!=null&&et.width&&this._drawLetterSpacing(d[lt],t,n,_+e,w+e-Q,!0,ct),t._fill!==void 0&&this._drawLetterSpacing(d[lt],t,n,_+e,w+e-Q,!1,ct)}}}_renderTaggedTextToCanvas(t,e,s,n,o){var L,H,$;const{canvas:r,context:l}=o,{runsByLine:c,lineWidths:d,maxLineWidth:h,lineAscents:p,lineHeights:g,hasDropShadow:m}=t,y=r.height;l.resetTransform(),l.scale(n,n),l.textBaseline=e.textBaseline;const _=m?2:1,w=e.wordWrap?e.wordWrapWidth:h;let k=((L=e._stroke)==null?void 0:L.width)??0;for(const G of c)for(const et of G){const Z=((H=et.style._stroke)==null?void 0:H.width)??0;Z>k&&(k=Z)}const E=k/2,B=[];for(let G=0;G<c.length;G++){const et=c[G],Z=[];for(const j of et){const Q=sl(j.style);l.font=Q,Z.push({width:xi._measureText(j.text,j.style.letterSpacing,l),font:Q})}B.push(Z)}for(let G=0;G<_;++G){const et=m&&G===0,Z=et?Math.ceil(Math.max(1,y)+s*2):0,j=Z*n;et||(l.shadowColor="rgba(0,0,0,0)");let Q=E;for(let rt=0;rt<c.length;rt++){const lt=c[rt],ct=d[rt],Gt=p[rt],J=g[rt],nt=B[rt];let Dt=E;Dt+=this._getAlignmentOffset(ct,w,e.align);let it=0;if(e.align==="justify"&&e.wordWrap&&rt<c.length-1){let wt=0;for(const ft of lt)wt+=on(ft.text);wt>0&&(it=(w-ct)/wt)}const yt=Q+Gt;let Bt=Dt+s;for(let wt=0;wt<lt.length;wt++){const ft=lt[wt],{width:Ft,font:qt}=nt[wt];if(l.font=qt,l.textBaseline=ft.style.textBaseline,($=ft.style._stroke)!=null&&$.width){const Zt=ft.style._stroke;if(l.lineWidth=Zt.width,l.miterLimit=Zt.miterLimit,l.lineJoin=Zt.join,l.lineCap=Zt.cap,et)if(ft.style.dropShadow)this._setupDropShadow(l,ft.style,n,j);else{const be=on(ft.text);Bt+=Ft+be*it;continue}else{const be=xi.measureFont(qt),Le=ft.style.lineHeight||be.fontSize,Ts={width:Ft,height:Le,lineHeight:Le,lines:[ft.text]};l.strokeStyle=Bo(Zt,l,Ts,s*2,Bt-s,Q)}this._drawLetterSpacing(ft.text,ft.style,o,Bt,yt+s-Z,!0,it)}const ye=on(ft.text);Bt+=Ft+ye*it}Bt=Dt+s;for(let wt=0;wt<lt.length;wt++){const ft=lt[wt],{width:Ft,font:qt}=nt[wt];if(l.font=qt,l.textBaseline=ft.style.textBaseline,ft.style._fill!==void 0){if(et)if(ft.style.dropShadow)this._setupDropShadow(l,ft.style,n,j);else{const Zt=on(ft.text);Bt+=Ft+Zt*it;continue}else{const Zt=xi.measureFont(qt),be=ft.style.lineHeight||Zt.fontSize,Le={width:Ft,height:be,lineHeight:be,lines:[ft.text]};l.fillStyle=Bo(ft.style._fill,l,Le,s*2,Bt-s,Q)}this._drawLetterSpacing(ft.text,ft.style,o,Bt,yt+s-Z,!1,it)}const ye=on(ft.text);Bt+=Ft+ye*it}Q+=J}}}_setFillAndStrokeStyles(t,e,s,n,o,r=0,l=0){var c;if(t.fillStyle=e._fill?Bo(e._fill,t,s,n*2,r,l):null,(c=e._stroke)!=null&&c.width){const d=o+n*2;t.strokeStyle=Bo(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 c=o.blur*s,d=o.distance*s;t.shadowBlur=c,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:c}=s,d=e.letterSpacing;let h=!1;if(xi.experimentalLetterSpacingSupported&&(xi.experimentalLetterSpacing?(c.letterSpacing=`${d}px`,c.textLetterSpacing=`${d}px`,h=!0):(c.letterSpacing="0px",c.textLetterSpacing="0px")),(d===0||h)&&l===0){r?c.strokeText(t,n,o):c.fillText(t,n,o);return}if(l!==0&&(d===0||h)){const _=t.split(" ");let w=n;const k=c.measureText(" ").width;for(let E=0;E<_.length;E++)r?c.strokeText(_[E],w,o):c.fillText(_[E],w,o),w+=c.measureText(_[E]).width+k+l;return}let p=n;const g=xi.graphemeSegmenter(t);let m=c.measureText(t).width,y=0;for(let _=0;_<g.length;++_){const w=g[_];r?c.strokeText(w,p,o):c.fillText(w,p,o);let k="";for(let E=_+1;E<g.length;++E)k+=g[E];y=c.measureText(k).width,p+=m-y+d,w===" "&&(p+=l),m=y}}}const vn=new _0,zl=class ji extends cs{constructor(t={}){super(),this.uid=Vt("textStyle"),this._tick=0,this._cachedFontString=null,x0(t),t instanceof ji&&(t=t._toObject());const n={...ji.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({...ji.defaultDropShadow,...t}):this._dropShadow=t?this._createProxy({...ji.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({...je.defaultFillStyle,...t},()=>{this._fill=Zi({...this._originalFill},je.defaultFillStyle)})),this._fill=Zi(t===0?"black":t,je.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(t){t!==this._originalStroke&&(this._originalStroke=t,this._isFillStyle(t)&&(this._originalStroke=this._createProxy({...je.defaultStrokeStyle,...t},()=>{this._stroke=fr({...this._originalStroke},je.defaultStrokeStyle)})),this._stroke=fr(t,je.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=ji.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=sl(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 ji(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 ws||t instanceof Cr)}};zl.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5};zl.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 Xe=zl;function x0(i){const t=i;if(typeof t.dropShadow=="boolean"&&t.dropShadow){const e=Xe.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){At(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 ws||e instanceof Cr)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(At(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&&we("The number of fill colors must match the number of fill gradient stops.");const e=new ws({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 w0(i,t){const{texture:e,bounds:s}=i,n=t._style._getFinalPadding();hd(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 S0{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 k0 extends S0{}class Au{constructor(t){this._renderer=t,t.runners.resolutionChange.add(this),this._managedTexts=new bo({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,w0(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 k0;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}}Au.extension={type:[bt.WebGLPipes,bt.WebGPUPipes,bt.CanvasPipes],name:"text"};const T0=new Oe;function C0(i,t,e,s,n=!1){const o=T0;o.minX=0,o.minY=0,o.maxX=i.width/s|0,o.maxY=i.height/s|0;const r=wr.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 Mu{constructor(t,e){this._activeTextures={},this._renderer=t,this._retainCanvasContext=e}getTexture(t,e,s,n){typeof t=="string"&&(At("8.0.0","CanvasTextSystem.getTexture: Use object TextOptions instead of separate arguments"),t={text:t,style:s,resolution:e}),t.style instanceof Xe||(t.style=new Xe(t.style)),t.textureStyle instanceof Tn||(t.textureStyle=new Tn(t.textureStyle)),typeof t.text!="string"&&(t.text=t.text.toString());const{text:o,style:r,textureStyle:l,autoGenerateMipmaps:c}=t,d=t.resolution??this._renderer.resolution,{frame:h,canvasAndContext:p}=vn.getCanvasAndContext({text:o,style:r,resolution:d}),g=C0(p.canvas,h.width,h.height,d,c);if(l&&(g.source.style=l),r.trim&&(h.pad(r.padding),g.frame.copyFrom(h),g.frame.scale(1/d),g.updateUvs()),r.filters){const m=this._applyFilters(g,r.filters);return this.returnTexture(g),vn.returnCanvasAndContext(p),m}return this._renderer.texture.initSource(g._source),this._retainCanvasContext||vn.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&&vn.returnCanvasAndContext({canvas:s,context:n})}e.resource=null,e.uploadMethodId="unknown",e.alphaMode="no-premultiply-alpha",wr.returnTexture(t,!0)}renderTextToCanvas(){At("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 Eu extends Mu{constructor(t){super(t,!0)}}Eu.extension={type:[bt.CanvasSystem],name:"canvasText"};class Pu extends Mu{constructor(t){super(t,!1)}}Pu.extension={type:[bt.WebGLSystem,bt.WebGPUSystem],name:"canvasText"};jt.add(Eu);jt.add(Pu);jt.add(Au);class Ki extends jg{constructor(...t){const e=Xg(t,"Text");super(e,Xe),this.renderPipeId="text",e.textureStyle&&(this.textureStyle=e.textureStyle instanceof Tn?e.textureStyle:new Tn(e.textureStyle)),this.autoGenerateMipmaps=e.autoGenerateMipmaps??He.defaultOptions.autoGenerateMipmaps}updateBounds(){const t=this._bounds,e=this._anchor;let s=0,n=0;if(this._style.trim){const{frame:o,canvasAndContext:r}=vn.getCanvasAndContext({text:this.text,style:this._style,resolution:1});vn.returnCanvasAndContext(r),s=o.width,n=o.height}else{const o=xi.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(Ku,Qu);const A0={Read:"📖",Write:"✏️",Edit:"🔧",Patch:"🔧",Bash:"💻",Glob:"🔍",Grep:"🔎",WebSearch:"🌐",WebFetch:"🌐",Agent:"🤖",TeamCreate:"👥",SendMessage:"💬",TaskCreate:"📋",TaskUpdate:"✅",TodoRead:"📋",TodoWrite:"✅",AskUserQuestion:"❓",EnterPlanMode:"📝",ExitPlanMode:"📝"},Jc=12,Ro=[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}],Xt=new Map(se.map(i=>[i.id,i]));let il=1100,nl=980;function M0(i,t){il=i,nl=t}const ut=[{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}],E0={background:14995640},ve={"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}},th={input:3,output:15},ia={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 Iu(i){if(!i)return th;const t=i.toLowerCase();if(ve[t])return ve[t];for(const[e,s]of Object.entries(ve))if(t.startsWith(e)||t.includes(e))return s;return t.includes("opus")?ve["claude-opus-4-6"]:t.includes("haiku")?ve["claude-haiku-4-5-20251001"]:t.includes("sonnet")?ve["claude-sonnet-4-6"]:t.includes("o3-mini")||t.includes("o4-mini")?ve["o3-mini"]:t.includes("o1-mini")?ve["o1-mini"]:t.includes("gemini-2.5")?ve["gemini-2.5-pro"]:t.includes("gemini-2")?ve["gemini-2.0-flash"]:t.includes("gemini")?ve["gemini-1.5-pro"]:t.includes("gpt-4o")?ve["gpt-4o"]:t.includes("deepseek")?ve["deepseek-chat"]:t.includes("grok")?ve["grok-3"]:t.includes("mistral")?ve["mistral-large"]:th}function Fl(i){if(!i)return 2e5;const t=i.toLowerCase();if(ia[t])return ia[t];let e=null;for(const[s,n]of Object.entries(ia))(t.startsWith(s)||t.includes(s))&&(!e||s.length>e[0].length)&&(e=[s,n]);return e?e[1]:2e5}function Lu(i){let t=0;for(let e=0;e<i.length;e++)t=(t<<5)-t+i.charCodeAt(e)|0;return Math.abs(t)%ut.length}function Ar(i){const t=Iu(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 eh=["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 mo(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)%eh.length;return eh[e]}async function P0(i){const t=new iu,e=document.getElementById("canvas-container")??i;return await t.init({background:E0.background,resizeTo:e,antialias:!1,resolution:window.devicePixelRatio||1,autoDensity:!0}),i.appendChild(t.canvas),t}const sh=1e3,I0=1e4;class L0{constructor(t){b(this,"ws",null);b(this,"store");b(this,"reconnectMs",sh);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=sh,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,I0))}disconnect(){this.disposed=!0,this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.ws&&(this.ws.close(),this.ws=null)}}const vr=class vr{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-vr.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(vr,"MAX_TIMELINE",5e3);let ol=vr;const B0=658452;function ih(i,t,e){const s=new Wt;return e?(e(s,i,t),s):(s.rect(0,0,i,t).fill(B0),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},nh=[[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 mr(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){mr(i,t+3,e+n,s,4,0,.12)}function gr(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 R0(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 oh(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 wi(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),c=nh[r%nh.length];let d=t+S+1,h=r*3;for(;d<t+n-S-1;){const p=S-1,g=u(2)+(h*7+r*3)%4;M(i,d,l-g,p,g,c[h%c.length]),d+=p+1,h++}}M(i,t,e+o-S,n,S,T.shelfFrame)}function gn(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 _n(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 rl(i,t,e,s){mr(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 al(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 $0(i,t,e,s){mr(i,t+2,e+2,u(4),u(4),0,.09),M(i,t,e,u(4),u(4),s),mr(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 rh(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 go(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 ls(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 Ss(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 Bu(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 Ru(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 Di(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 tn(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 na(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 D0(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 z0(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 F0(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 N0(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 G0(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 W0(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 c=t+u(2)+l*(o+S);M(i,c,e+u(2),o,u(2),r[l]),M(i,c,e+u(2),o,S,15658734);const d=[T.stickyYellow,T.stickyBlue,T.stickyPink,T.stickyGreen,T.stickyOrange,T.stickyPurple],h=l===0?3:l===1?2:1;for(let p=0;p<h;p++)M(i,c+2,e+u(5)+p*(u(3)+2),o-4,u(2),d[(l+p*2)%d.length]),M(i,c+2,e+u(5)+p*(u(3)+2),o-4,1,15658734),M(i,c+S,e+u(5)+p*(u(3)+2)+S+1,o-S*2,1,T.metalDark)}}function O0(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 H0(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 U0(i,t,e,s,n){wi(i,t+u(2),e+u(4),!0),wi(i,t+u(22),e+u(4),!0),wi(i,t+u(42),e+u(4),!0),wi(i,t+u(62),e+u(4),!1),wi(i,t+u(2),e+u(23),!1),wi(i,t+u(2),e+u(42),!1),go(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)),tn(i,t+u(22),e+u(34)),Di(i,t+u(30),e+u(34)),go(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)),tn(i,t+u(46),e+u(35)),ls(i,t+u(2),e+n-u(12)),ls(i,t+s-u(9),e+u(22)),Ss(i,t+s-u(6),e+n-u(8)),_n(i,t+s-u(8),e+n-u(15)),_n(i,t+s-u(15),e+n-u(15))}function V0(i,t,e,s,n){gn(i,t+u(2),e+u(4)),gn(i,t+u(13),e+u(4)),gn(i,t+u(24),e+u(4)),gn(i,t+s-u(10),e+u(25)),gn(i,t+s-u(10),e+u(45)),oh(i,t+u(2),e+u(25)),Nt(i,t+u(6),e+u(37)),oh(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 q0(i,t,e,s,n){O0(i,t+u(2),e+u(4)),gn(i,t+s-u(10),e+u(4)),gr(i,t+u(2),e+u(25)),Nt(i,t+u(6),e+u(37)),gr(i,t+u(26),e+u(25)),Nt(i,t+u(30),e+u(37)),go(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);ls(i,t+u(2),e+n-u(13)),Ss(i,t+s-u(5),e+n-u(9))}function Y0(i,t,e,s,n){_n(i,t+u(2),e+u(4)),_n(i,t+u(10),e+u(4)),_n(i,t+u(18),e+u(4)),_n(i,t+u(26),e+u(4)),wi(i,t+u(2),e+u(19),!0),gr(i,t+u(26),e+u(23)),Nt(i,t+u(30),e+u(35)),na(i,t+u(2),e+u(39),T.paleWood),na(i,t+u(8),e+u(41),T.medWood),na(i,t+u(2),e+u(45),T.wood),tn(i,t+u(38),e+u(6)),tn(i,t+u(28),e+u(25)),Ss(i,t+s-u(5),e+n-u(9)),ls(i,t+s-u(9),e+u(19))}function j0(i,t,e,s,n){rl(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)),al(i,t+u(4),e+u(4),u(26),u(14)),al(i,t+u(34),e+u(4),u(22),u(14)),Bu(i,t+s-u(16),e+u(4),u(12),u(8)),tn(i,t+s/2-u(5),e+n/2-u(4)),Di(i,t+s/2+u(3),e+n/2-u(2)),ls(i,t+u(2),e+n-u(14)),ls(i,t+s-u(9),e+n-u(14))}function X0(i,t,e,s,n){Bu(i,t+u(10),e+u(4),u(16),u(9)),wi(i,t+u(2),e+u(4),!1),rh(i,t+u(3),e+u(19),u(18)),go(i,t+u(5),e+u(31),u(14),u(6)),Di(i,t+u(9),e+u(32)),Di(i,t+u(14),e+u(32)),tn(i,t+u(7),e+u(33)),rh(i,t+u(26),e+u(23),u(12)),go(i,t+u(28),e+u(37),u(8),u(5)),Di(i,t+u(30),e+u(38)),ls(i,t+u(2),e+n-u(13)),Ss(i,t+s-u(5),e+u(4)),Ru(i,t+s-u(9),e+u(5))}function Z0(i,t,e,s,n){H0(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),Ss(i,t+u(2),e+u(7)),Ss(i,t+s-u(5),e+u(7)),ls(i,t+u(2),e+n-u(14)),ls(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 K0(i,t,e,s,n){G0(i,t+u(2),e+u(4),u(30)),F0(i,t+u(4),e+u(-1)),Di(i,t+u(10),e+u(1)),z0(i,t+u(34),e+u(4)),D0(i,t+s-u(11),e+u(4)),N0(i,t+u(45),e+u(4)),rl(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)),Di(i,t+u(17),e+u(32)),rl(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)),Di(i,t+u(47),e+u(32)),Ru(i,t+u(58),e+u(5)),Ss(i,t+u(2),e+n-u(9)),Ss(i,t+s-u(5),e+n-u(9))}function Q0(i,t,e,s,n){W0(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++)$0(i,t+u(38)+r%3*u(5),e+u(4)+Math.floor(r/3)*u(5),o[r]);R0(i,t+u(4),e+u(31)),Nt(i,t+u(7),e+u(42)),gr(i,t+u(30),e+u(31)),Nt(i,t+u(34),e+u(42)),tn(i,t+u(46),e+u(33)),al(i,t+u(52),e+u(4),u(14),u(12)),ls(i,t+s-u(9),e+n-u(14)),Ss(i,t+u(2),e+n-u(9))}const Ye={search:U0,terminal:V0,web:q0,files:Y0,thinking:j0,messaging:X0,spawn:Z0,idle:K0,tasks:Q0},ah={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}},Je=14,$e=10,ne=6,ts=6,J0=1710638,ty=.55;function Tt(i,t,e,s,n,o){i.rect(t,e,s,n).fill(o)}function ey(i,t,e,s,n,o,r,l){Tt(i,t,e,s,n,o);const c=20;let d=0;for(let h=0;h<n;h+=c){const p=Math.min(c,n-h);d%2===1&&Tt(i,t,e+h,s,p,r),Tt(i,t,e+h,s,1,l);const g=d%2*32;for(let m=g;m<s;m+=64)Tt(i,t+m,e+h+1,1,p-2,l);d++}}function sy(i,t,e,s,n,o,r,l){Tt(i,t,e,s,n,o);const c=24;for(let d=0;d<n;d+=c)for(let h=0;h<s;h+=c)(h/c+d/c)%2===0&&Tt(i,t+h,e+d,Math.min(c,s-h),Math.min(c,n-d),r),Tt(i,t+h,e+d,Math.min(c,s-h),1,l),Tt(i,t+h,e+d,1,Math.min(c,n-d),l)}function iy(i,t,e,s,n,o,r,l){Tt(i,t,e,s,n,o);for(let c=0;c<n;c+=12)for(let d=c/12%2*12;d<s;d+=24)Tt(i,t+d,e+c,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 ny(i,t,e,s,n,o,r,l){Tt(i,t,e,s,n,o);const c=16;for(let d=0;d<n;d+=c)for(let h=0;h<s;h+=c)(h/c+d/c)%2===0&&Tt(i,t+h,e+d,Math.min(c,s-h),Math.min(c,n-d),r),Tt(i,t+h,e+d,Math.min(c,s-h),1,l),Tt(i,t+h,e+d,1,Math.min(c,n-d),l)}const oy={wood:ey,tile:sy,carpet:iy,dark:ny};class ry{constructor(){b(this,"zones",new Map);b(this,"container",new zt);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 zt;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=ah[e.id],n=s&&(s.floorType==="dark"||s.floorType==="carpet"),o=new Xe({fontSize:11,fontFamily:"'Inter', 'SF Pro Display', 'Segoe UI', system-ui, sans-serif",fill:16777215,fontWeight:"700",letterSpacing:.5}),r=new Ki({text:`${e.icon} ${e.label}`,style:o});r.position.set($e+8,1);const l=r.width+16,c=r.height+6,d=new Wt;d.roundRect($e+2,-1,l,c,4).fill({color:0,alpha:n?.5:.55}),t.addChild(d),t.addChild(r)}addGlassLabel(t,e){const s=new Xe({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 Ki({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:J0,alpha:ty}),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])??Ye[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=ah[e.id];if(!o)return;Tt(t,0,0,s,n,o.wallMain);const r=$e,l=Je,c=s-$e-ts,d=n-Je-ne,h=oy[o.floorType];h(t,r,l,c,d,o.floorA,o.floorB,o.floorGrid),Tt(t,0,0,s,Je,o.wallDark),Tt(t,$e,Je-2,s-$e-ts,2,o.wallLight),Tt(t,0,0,$e,n,o.wallMain),Tt(t,$e-2,Je,2,n-Je-ne,o.wallLight),Tt(t,0,n-ne,s,ne,o.wallLight),Tt(t,$e,n-ne,s-$e-ts,1,o.wallBaseboard),Tt(t,s-ts,0,ts,n,o.wallLight),Tt(t,s-ts,Je,1,n-Je-ne,o.wallBaseboard),Tt(t,0,0,$e,Je,o.wallDark),Tt(t,s-ts,0,ts,Je,o.wallMain),Tt(t,0,n-ne,$e,ne,o.wallMain),Tt(t,s-ts,n-ne,ts,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])??Ye[e.id];m&&m(t,r,l,c,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 oa=.5,ra=3,ay=.001;class ly{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(oa,Math.min(ra,this.zoom-t.deltaY*ay));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(oa,Math.min(ra,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,c=Math.min(r,l,1);this.setZoom(c),this.world.position.set((s-t*c)/2,(n-e*c)/2)}smoothFollow(t,e,s=.05){const n=this.app.screen.width,o=this.app.screen.height,r=n/2,l=o/2,c=r-t*this.zoom,d=l-e*this.zoom;this.world.position.x+=(c-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(oa,Math.min(ra,this.zoom*t));this.zoom=s;const n=this.app.screen.width,o=this.app.screen.height,r=n/2,l=o/2,c=s/e;this.world.position.x=r-(r-this.world.position.x)*c,this.world.position.y=l-(l-this.world.position.y)*c,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 lh=120,aa=100,rn=48,As=4;class cy{constructor(){b(this,"lastW",0);b(this,"lastH",0)}computeLayout(t,e){const s=Math.max(t,lh*3+As*4+rn*2),n=Math.max(e,aa*3+As*4+rn*2);if(s===this.lastW&&n===this.lastH)return{worldWidth:s,worldHeight:n};this.lastW=s,this.lastH=n;const o=Ro.reduce((g,m)=>g+m,0),r=s-rn*2-As*(Jc-1),l=n-rn*2-As*(Ro.length-1),c=r/Jc,d=Ro.map(g=>Math.max(aa,g/o*l)),h=[];let p=rn;for(let g=0;g<Ro.length;g++)h.push(p),p+=d[g]+As;for(const g of se)g.x=rn+g.colStart*(c+As),g.y=h[g.rowStart],g.width=Math.max(lh,g.colSpan*c+(g.colSpan-1)*As),g.height=Math.max(aa,d[g.rowStart]*g.rowSpan+(g.rowSpan-1)*As);return M0(s,n),{worldWidth:s,worldHeight:n}}invalidate(){this.lastW=0,this.lastH=0}}const hy=1710666,la=.45,dy=.15,$o=6,ch=8,ca=18,ha=22,uy=1e3;class fy{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:hy,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>=ha||e<$o?s=la:e>=ca&&e<ha?s=la*((e-ca)/(ha-ca)):e>=$o&&e<ch?s=la*(1-(e-$o)/(ch-$o)):s=0,this.targetAlpha=Math.max(s,dy)}update(t){if(!this._enabled)return;this.updateTimer+=t,this.updateTimer>=uy&&(this.updateTimer=0,this.computeTargetAlpha());const e=1-Math.exp(-3*t/1e3);this.overlay.alpha+=(this.targetAlpha-this.overlay.alpha)*e}}const py=[["search","terminal"],["terminal","web"],["files","thinking"],["thinking","messaging"],["spawn","idle"],["idle","tasks"],["search","files"],["terminal","thinking"],["web","messaging"],["files","spawn"],["thinking","idle"],["messaging","tasks"]],my=.04,gy=.12,hh=3,yy=1200;class by{constructor(){b(this,"container",new zt);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/yy,color:s,alpha:.8})}getZoneCenter(t){const e=Xt.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 c=1-l;return{x:c*c*t+2*c*l*s+l*l*o,y:c*c*e+2*c*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 py){const n=this.getZoneCenter(e),o=this.getZoneCenter(s),r=`${e}->${s}`,l=`${s}->${e}`,d=this.activeFlows.has(r)||this.activeFlows.has(l)?gy:my,h=Xt.get(e),p=(h==null?void 0:h.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),c=e.alpha*(1-e.t*.5);this.particleGfx.circle(l.x,l.y,hh).fill({color:e.color,alpha:c}),this.particleGfx.circle(l.x,l.y,hh*2).fill({color:e.color,alpha:c*.3})}}}class vy{constructor(t){b(this,"root",new zt);b(this,"gridLayer",new zt);b(this,"zoneLayer");b(this,"agentLayer",new zt);b(this,"effectLayer",new zt);b(this,"uiLayer",new zt);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 cy;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=ih(n,o),this.gridLayer.addChild(this.gridGraphics),this.zoneRenderer=new ry,this.zoneLayer=this.zoneRenderer.container,this.flowLines=new by,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 fy(n,o),this.root.addChild(this.dayNight.overlay),t.stage.addChild(this.root),this.camera=new ly(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 zt?t:t.container;this.agentLayer.addChild(e)}removeAgent(t){const e=t instanceof zt?t:t.container;this.agentLayer.removeChild(e)}addEffect(t){this.effectLayer.addChild(t)}removeEffect(t){this.effectLayer.removeChild(t)}getZoneCenter(t){const e=Xt.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 Xt.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=ih(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",x="body",f="outline",I="highlight",It="eye",v="skin",_y={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,v,v,v,v,v,v,I,f,a,a,a],[a,a,a,f,v,It,It,v,v,It,It,v,f,a,a,a],[a,a,a,f,v,v,v,v,v,v,v,v,f,a,a,a],[a,a,a,a,f,f,v,v,v,v,f,f,a,a,a,a],[a,a,a,a,a,f,x,x,x,x,f,a,a,a,a,a],[a,a,a,a,f,x,x,x,x,x,x,f,a,a,a,a],[a,a,a,v,f,x,x,x,x,x,x,f,v,a,a,a],[a,a,a,v,f,x,x,x,x,x,x,f,v,a,a,a],[a,a,a,a,f,x,x,x,x,x,x,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,v,v,v,v,v,v,I,f,a,a,a],[a,a,a,f,v,f,f,v,v,f,f,v,f,a,a,a],[a,a,a,f,v,v,v,v,v,v,v,v,f,a,a,a],[a,a,a,a,f,f,v,v,v,v,f,f,a,a,a,a],[a,a,a,a,a,f,x,x,x,x,f,a,a,a,a,a],[a,a,a,a,f,x,x,x,x,x,x,f,a,a,a,a],[a,a,a,v,f,x,x,x,x,x,x,f,v,a,a,a],[a,a,a,v,f,x,x,x,x,x,x,f,v,a,a,a],[a,a,a,a,f,x,x,x,x,x,x,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,v,v,v,v,v,v,I,f,a,a,a],[a,a,a,f,v,It,It,v,v,It,It,v,f,a,a,a],[a,a,a,f,v,v,v,v,v,v,v,v,f,a,a,a],[a,a,a,a,f,f,v,v,v,v,f,f,a,a,a,a],[a,a,a,a,a,f,x,x,x,x,f,a,a,a,a,a],[a,a,a,a,f,x,x,x,x,x,x,f,a,a,a,a],[a,a,a,v,f,x,x,x,x,x,x,f,v,a,a,a],[a,a,a,v,f,x,x,x,x,x,x,f,v,a,a,a],[a,a,a,a,f,x,x,x,x,x,x,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,v,v,v,v,v,v,I,f,a,a,a],[a,a,a,f,v,It,It,v,v,It,It,v,f,a,a,a],[a,a,a,f,v,v,v,v,v,v,v,v,f,a,a,a],[a,a,a,a,f,f,v,v,v,v,f,f,a,a,a,a],[a,a,a,a,a,f,x,x,x,x,f,a,a,a,a,a],[a,a,a,a,f,x,x,x,x,x,x,f,a,a,a,a],[a,a,a,v,f,x,x,x,x,x,x,f,v,a,a,a],[a,a,a,v,f,x,x,x,x,x,x,f,v,a,a,a],[a,a,a,a,f,x,x,x,x,x,x,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,v,v,v,v,v,v,I,f,a,a,a],[a,a,a,f,v,It,It,v,v,It,It,v,f,a,a,a],[a,a,a,f,v,v,f,f,f,f,v,v,f,a,a,a],[a,a,a,a,f,f,v,v,v,v,f,f,a,a,a,a],[a,a,a,a,a,f,x,x,x,x,f,a,a,a,a,a],[a,a,a,a,f,x,x,x,x,x,x,f,a,a,a,a],[a,a,v,v,f,x,x,x,x,x,x,f,v,v,a,a],[a,a,a,v,f,x,x,x,x,x,x,f,v,a,a,a],[a,a,a,a,f,x,x,x,x,x,x,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,v,v,v,v,v,v,I,f,a,a],[a,a,a,a,f,v,f,f,v,v,f,f,v,f,a,a],[a,a,a,a,f,v,v,v,v,v,v,v,v,f,a,a],[a,a,a,a,a,f,f,v,v,v,v,f,f,a,a,a],[a,a,a,a,a,f,x,x,x,x,f,a,a,a,a,a],[a,a,a,a,f,x,x,x,x,x,x,f,a,a,a,a],[a,a,a,v,f,x,x,x,x,x,x,f,v,a,a,a],[a,a,a,v,f,x,x,x,x,x,x,f,v,a,a,a],[a,a,a,a,f,x,x,x,x,x,x,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,v,v,v,v,v,v,I,f,a,a],[a,a,a,a,f,v,f,f,v,v,f,f,v,f,a,a],[a,a,a,a,f,v,v,v,f,f,v,v,v,f,a,a],[a,a,a,a,a,f,f,v,v,v,v,f,f,a,a,a],[a,a,a,a,a,f,x,x,x,x,f,a,a,a,a,a],[a,a,a,a,f,x,x,x,x,x,x,f,a,a,a,a],[a,a,a,v,f,x,x,x,x,x,x,f,v,a,a,a],[a,a,a,v,f,x,x,x,x,x,x,f,v,a,a,a],[a,a,a,a,f,x,x,x,x,x,x,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,v,v,v,v,v,v,I,f,a,a,a],[a,a,a,f,v,v,It,v,v,It,v,v,f,a,a,a],[a,a,a,f,v,v,v,f,f,v,v,v,f,a,a,a],[a,a,a,a,f,f,v,v,v,v,f,f,a,a,a,a],[a,a,a,a,a,f,x,x,x,x,f,a,a,a,a,a],[a,a,a,a,f,x,x,x,x,x,x,f,a,a,a,a],[a,a,v,v,f,x,x,x,x,x,x,f,v,v,a,a],[a,a,a,v,f,x,x,x,x,x,x,f,v,a,a,a],[a,a,a,a,f,x,x,x,x,x,x,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},xy={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,v,v,v,v,I,I,f,a],[a,f,v,It,v,v,v,v,It,v,f,a],[a,f,v,v,v,v,v,v,v,v,f,a],[a,a,f,f,v,v,v,v,f,f,a,a],[a,a,f,x,x,x,x,x,x,f,a,a],[a,v,f,x,x,x,x,x,x,f,v,a],[a,a,f,x,x,x,x,x,x,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,v,v,v,v,I,I,f,a],[a,f,v,f,v,v,v,v,f,v,f,a],[a,f,v,v,v,v,v,v,v,v,f,a],[a,a,f,f,v,v,v,v,f,f,a,a],[a,a,f,x,x,x,x,x,x,f,a,a],[a,v,f,x,x,x,x,x,x,f,v,a],[a,a,f,x,x,x,x,x,x,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,v,v,v,v,I,I,f,a],[a,f,v,It,v,v,v,v,It,v,f,a],[a,f,v,v,v,v,v,v,v,v,f,a],[a,a,f,f,v,v,v,v,f,f,a,a],[a,a,f,x,x,x,x,x,x,f,a,a],[a,v,f,x,x,x,x,x,x,f,v,a],[a,a,f,x,x,x,x,x,x,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,v,v,v,v,I,I,f,a],[a,f,v,It,v,v,v,v,It,v,f,a],[a,f,v,v,v,v,v,v,v,v,f,a],[a,a,f,f,v,v,v,v,f,f,a,a],[a,a,f,x,x,x,x,x,x,f,a,a],[a,v,f,x,x,x,x,x,x,f,v,a],[a,a,f,x,x,x,x,x,x,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,v,v,v,v,I,I,f,a],[a,f,v,It,v,v,v,v,It,v,f,a],[a,f,v,f,f,f,f,f,f,v,f,a],[a,a,f,f,v,v,v,v,f,f,a,a],[a,a,f,x,x,x,x,x,x,f,a,a],[v,v,f,x,x,x,x,x,x,f,v,v],[a,a,f,x,x,x,x,x,x,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,v,v,v,v,I,I,f],[a,a,f,v,f,v,v,v,v,f,v,f],[a,a,f,v,v,v,v,v,v,v,v,f],[a,a,a,f,f,v,v,v,v,f,f,a],[a,a,f,x,x,x,x,x,x,f,a,a],[a,v,f,x,x,x,x,x,x,f,v,a],[a,a,f,x,x,x,x,x,x,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,v,v,v,v,I,I,f],[a,a,f,v,f,v,v,v,v,f,v,f],[a,a,f,v,v,v,f,f,v,v,v,f],[a,a,a,f,f,v,v,v,v,f,f,a],[a,a,f,x,x,x,x,x,x,f,a,a],[a,v,f,x,x,x,x,x,x,f,v,a],[a,a,f,x,x,x,x,x,x,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,v,v,v,v,I,I,f,a],[a,f,v,v,It,v,v,It,v,v,f,a],[a,f,v,v,f,v,v,f,v,v,f,a],[a,a,f,f,v,v,v,v,f,f,a,a],[a,a,f,x,x,x,x,x,x,f,a,a],[v,v,f,x,x,x,x,x,x,f,v,v],[a,a,f,x,x,x,x,x,x,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",at="body",F="outline",me="highlight",Bi="eye",Si=[C,C,C,C,C,C,C,F,F,C,C,C,C,C,C,C],ki=[C,C,C,F,F,F,F,F,F,F,F,F,F,C,C,C],Ti=[C,C,C,F,at,at,at,at,at,at,at,at,F,C,C,C],so=[C,C,C,F,at,Bi,Bi,at,at,Bi,Bi,at,F,C,C,C],ll=[C,C,C,F,at,F,F,at,at,F,F,at,F,C,C,C],xn=[C,C,C,F,at,at,F,F,F,F,at,at,F,C,C,C],Ci=[C,C,C,F,F,F,F,F,F,F,F,F,F,C,C,C],Ai=[C,C,C,C,C,F,me,me,me,me,F,C,C,C,C,C],ue=[C,C,C,C,F,at,at,at,at,at,at,F,C,C,C,C],Mi=[C,C,F,F,F,at,at,at,at,at,at,F,F,F,C,C],Ei=[C,C,C,F,F,at,at,at,at,at,at,F,F,C,C,C],fe=[C,C,C,C,F,F,me,me,me,me,F,F,C,C,C,C],os=[C,C,C,C,F,F,F,C,C,F,F,F,C,C,C,C],wn=[C,C,C,F,F,F,F,C,C,F,F,F,F,C,C,C],dh=[C,C,C,C,F,F,F,C,C,C,F,F,C,C,C,C],wy=[C,C,C,F,F,F,C,C,C,C,F,F,F,C,C,C],uh=[C,C,C,C,C,F,F,C,C,F,F,F,C,C,C,C],Sy=[C,C,C,F,F,F,C,C,C,F,F,F,C,C,C,C],ky=[C,C,C,F,at,F,me,me,me,me,F,at,F,C,C,C],Ty=[C,C,C,F,at,at,at,F,F,at,at,at,F,C,C,C],Cy=[Si,ki,Ti,so,xn,Ci,Ai,ue,Mi,Ei,fe,ue,fe,os,os,wn],Ay=[Si,ki,Ti,ll,xn,Ci,Ai,ue,Mi,Ei,fe,ue,fe,os,os,wn],My={idle:[Cy,Ay],walk:[[Si,ki,Ti,so,xn,Ci,Ai,ue,Mi,Ei,fe,ue,fe,dh,dh,wy],[Si,ki,Ti,so,xn,Ci,Ai,ue,Mi,Ei,fe,ue,fe,uh,uh,Sy]],working:[Si,ki,Ti,so,ky,Ci,Ai,ue,Mi,Ei,fe,ue,fe,os,os,wn],sleeping:[[[C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C],...[Si,ki,Ti,ll,xn,Ci,Ai,ue,Mi,Ei,fe,ue,fe,os,wn].map(i=>[C,...i.slice(0,-1)])],[[C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C],...[Si,ki,Ti,ll,xn,Ci,Ai,ue,Mi,Ei,fe,ue,fe,os,wn].map(i=>[C,...i.slice(0,-1)])]],done:[Si,ki,Ti,so,Ty,Ci,Ai,ue,Mi,Ei,fe,ue,fe,os,os,wn],size:16},Ms=[C,C,C,C,C,F,F,C,C,C,C,C],Es=[C,C,F,F,F,F,F,F,F,F,C,C],Ps=[C,C,F,at,at,at,at,at,at,F,C,C],zn=[C,C,F,Bi,Bi,at,at,Bi,Bi,F,C,C],da=[C,C,F,F,F,at,at,F,F,F,C,C],an=[C,C,F,at,F,F,F,F,at,F,C,C],Is=[C,C,F,F,F,F,F,F,F,F,C,C],oe=[C,C,C,F,at,at,at,at,F,C,C,C],Ls=[C,F,F,F,at,at,at,at,F,F,F,C],De=[C,C,C,F,F,C,C,F,F,C,C,C],Bs=[C,C,F,F,F,C,C,F,F,F,C,C],fh=[C,C,F,F,C,C,C,C,F,F,C,C],ph=[C,C,C,F,F,C,C,F,F,C,C,C],Ey=[C,C,F,at,me,me,me,me,at,F,C,C],Py=[C,C,F,at,at,F,F,at,at,F,C,C],Iy={idle:[[Ms,Es,Ps,zn,an,Is,oe,Ls,oe,De,De,Bs],[Ms,Es,Ps,da,an,Is,oe,Ls,oe,De,De,Bs]],walk:[[Ms,Es,Ps,zn,an,Is,oe,Ls,oe,fh,fh,Bs],[Ms,Es,Ps,zn,an,Is,oe,Ls,oe,ph,ph,Bs]],working:[Ms,Es,Ps,zn,Ey,Is,oe,Ls,oe,De,De,Bs],sleeping:[[Ms,Es,Ps,da,an,Is,oe,Ls,oe,De,De,Bs],[Ms,Es,Ps,da,an,Is,oe,Ls,oe,De,De,Bs]],done:[Ms,Es,Ps,zn,Py,Is,oe,Ls,oe,De,De,Bs],size:12},P="transparent",ge="body",q="outline",Y="skin",Rs=[P,P,P,P,P,q,q,q,q,q,q,P,P,P,P,P],$s=[P,P,P,P,q,Y,Y,Y,Y,Y,Y,q,P,P,P,P],Ds=[P,P,P,q,Y,Y,Y,Y,Y,Y,Y,Y,q,P,P,P],Fn=[P,P,P,q,Y,q,q,Y,Y,q,q,Y,q,P,P,P],ua=[P,P,P,q,Y,q,P,Y,Y,P,q,Y,q,P,P,P],ln=[P,P,P,q,Y,Y,Y,q,q,Y,Y,Y,q,P,P,P],zs=[P,P,P,P,q,Y,q,q,q,q,Y,q,P,P,P,P],cl=[P,P,P,P,P,P,q,Y,Y,q,P,P,P,P,P,P],Sn=[P,P,P,P,q,Y,ge,Y,Y,ge,Y,q,P,P,P,P],hl=[P,P,P,P,q,ge,Y,ge,ge,Y,ge,q,P,P,P,P],dl=[P,P,Y,Y,q,Y,ge,Y,Y,ge,Y,q,Y,Y,P,P],ul=[P,P,P,P,P,q,Y,Y,Y,Y,q,P,P,P,P,P],fl=[P,P,P,P,P,q,Y,q,q,Y,q,P,P,P,P,P],pl=[P,P,P,P,P,q,Y,P,P,Y,q,P,P,P,P,P],Ly=[P,P,P,P,q,q,Y,P,P,Y,q,q,P,P,P,P],fa=[P,P,P,P,q,Y,P,P,P,P,Y,q,P,P,P,P],mh=[P,P,P,q,q,Y,P,P,P,Y,q,q,P,P,P,P],By=[P,P,P,P,q,Y,q,Y,Y,q,Y,q,P,P,P,P],Ry=[P,P,P,q,Y,Y,q,q,q,q,Y,Y,q,P,P,P],cn=[cl,Sn,dl,hl,Sn,ul,fl,pl,pl,Ly],$y={idle:[[Rs,$s,Ds,Fn,ln,zs,...cn],[Rs,$s,Ds,ua,ln,zs,...cn]],walk:[[Rs,$s,Ds,Fn,ln,zs,cl,Sn,dl,hl,Sn,ul,fl,fa,fa,mh],[Rs,$s,Ds,Fn,ln,zs,cl,Sn,dl,hl,Sn,ul,fl,pl,fa,mh]],working:[Rs,$s,Ds,Fn,By,zs,...cn],sleeping:[[[P,...Rs.slice(0,-1)],[P,...$s.slice(0,-1)],[P,...Ds.slice(0,-1)],[P,...ua.slice(0,-1)],[P,...ln.slice(0,-1)],[P,...zs.slice(0,-1)],...cn],[[P,...Rs.slice(0,-1)],[P,...$s.slice(0,-1)],[P,...Ds.slice(0,-1)],[P,...ua.slice(0,-1)],[P,...ln.slice(0,-1)],[P,...zs.slice(0,-1)],...cn]],done:[Rs,$s,Ds,Fn,Ry,zs,...cn],size:16},Fs=[P,P,P,q,q,q,q,q,q,P,P,P],Ns=[P,P,q,Y,Y,Y,Y,Y,Y,q,P,P],Nn=[P,q,Y,q,q,Y,Y,q,q,Y,q,P],pa=[P,q,Y,q,P,Y,Y,P,q,Y,q,P],Ni=[P,q,Y,Y,q,q,q,q,Y,Y,q,P],Gs=[P,P,q,Y,q,q,q,q,Y,q,P,P],Ws=[P,P,q,Y,ge,Y,Y,ge,Y,q,P,P],Os=[P,P,q,ge,Y,ge,ge,Y,ge,q,P,P],Hs=[P,Y,q,Y,ge,Y,Y,ge,Y,q,Y,P],Us=[P,P,P,q,Y,Y,Y,Y,q,P,P,P],Ce=[P,P,P,q,Y,P,P,Y,q,P,P,P],Vs=[P,P,q,q,Y,P,P,Y,q,q,P,P],ma=[P,P,q,Y,P,P,P,P,Y,q,P,P],Dy=[P,q,Y,Y,q,q,q,q,Y,Y,q,P],zy={idle:[[Fs,Ns,Nn,Ni,Gs,Ws,Hs,Os,Us,Ce,Ce,Vs],[Fs,Ns,pa,Ni,Gs,Ws,Hs,Os,Us,Ce,Ce,Vs]],walk:[[Fs,Ns,Nn,Ni,Gs,Ws,Hs,Os,Us,ma,ma,Vs],[Fs,Ns,Nn,Ni,Gs,Ws,Hs,Os,Us,Ce,ma,Vs]],working:[Fs,Ns,Nn,Ni,Gs,Ws,Hs,Os,Us,Ce,Ce,Vs],sleeping:[[Fs,Ns,pa,Ni,Gs,Ws,Hs,Os,Us,Ce,Ce,Vs],[Fs,Ns,pa,Ni,Gs,Ws,Hs,Os,Us,Ce,Ce,Vs]],done:[Fs,Ns,Nn,Dy,Gs,Ws,Hs,Os,Us,Ce,Ce,Vs],size:12},A="transparent",ot="body",W="outline",Ri="highlight",ke="eye",$u=[A,A,A,A,A,A,W,W,W,W,A,A,A,A,A,A],Du=[A,A,A,A,W,W,ot,ot,ot,ot,W,W,A,A,A,A],zu=[A,A,A,W,ot,ot,ot,ot,ot,ot,ot,ot,W,A,A,A],ga=[A,A,A,W,ot,ke,ke,W,W,ke,ke,ot,W,A,A,A],ya=[A,A,A,W,ot,W,W,W,W,W,W,ot,W,A,A,A],qs=[A,A,A,W,W,W,W,W,W,W,W,W,W,A,A,A],Ys=[A,A,A,A,W,W,W,W,W,W,W,W,A,A,A,A],er=[A,A,A,A,A,W,ot,ot,ot,ot,W,A,A,A,A,A],Pi=[A,A,A,A,W,ot,ot,ot,ot,ot,ot,W,A,A,A,A],sr=[A,A,A,W,W,ot,ot,ot,ot,ot,ot,W,W,A,A,A],ir=[A,A,W,W,W,ot,ot,ot,ot,ot,ot,W,W,W,A,A],nr=[A,A,A,A,W,W,Ri,Ri,Ri,Ri,W,W,A,A,A,A],yr=[A,A,A,A,A,W,W,A,A,W,W,A,A,A,A,A],ml=[A,A,A,A,W,W,W,A,A,W,W,W,A,A,A,A],gh=[A,A,A,A,W,W,A,A,A,A,W,W,A,A,A,A],Fy=[A,A,A,W,W,W,A,A,A,A,W,W,W,A,A,A],Ny=[A,A,A,A,A,W,W,A,W,W,A,A,A,A,A,A],Gy=[A,A,A,A,W,W,A,A,A,W,W,A,A,A,A,A],Wy=[A,A,A,W,ot,ke,W,W,W,W,ke,ot,W,A,A,A],Oy=[A,A,A,W,ot,W,ke,W,W,ke,W,ot,W,A,A,A],hn=[$u,Du,zu],yh=[[A,...$u.slice(0,-1)],[A,...Du.slice(0,-1)],[A,...zu.slice(0,-1)]],Gn=[er,Pi,ir,sr,Pi,nr,yr,yr,ml],Hy={idle:[[...hn,ga,qs,Ys,...Gn],[...hn,ya,qs,Ys,...Gn]],walk:[[...hn,ga,qs,Ys,er,Pi,ir,sr,Pi,nr,gh,gh,Fy],[...hn,ga,qs,Ys,er,Pi,ir,sr,Pi,nr,Ny,Gy,ml]],working:[...hn,Wy,qs,Ys,er,Pi,ir,sr,Pi,nr,yr,yr,ml],sleeping:[[[A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A],...yh,[A,...ya.slice(0,-1)],[A,...qs.slice(0,-1)],[A,...Ys.slice(0,-1)],...Gn],[[A,A,A,A,A,A,A,A,A,A,A,A,A,A,A,A],...yh,[A,...ya.slice(0,-1)],[A,...qs.slice(0,-1)],[A,...Ys.slice(0,-1)],...Gn]],done:[...hn,Oy,qs,Ys,...Gn],size:16},js=[A,A,A,W,W,W,W,W,W,A,A,A],Xs=[A,A,W,ot,ot,ot,ot,ot,ot,W,A,A],Zs=[A,W,ot,ot,ot,ot,ot,ot,ot,ot,W,A],Do=[A,W,ot,ke,ke,W,W,ke,ke,ot,W,A],ba=[A,W,ot,W,W,W,W,W,W,ot,W,A],Ks=[A,W,W,W,W,W,W,W,W,W,W,A],re=[A,A,W,ot,ot,ot,ot,ot,ot,W,A,A],Qs=[A,W,W,ot,ot,ot,ot,ot,ot,W,W,A],Js=[A,A,W,W,Ri,Ri,Ri,Ri,W,W,A,A],Ae=[A,A,A,W,W,A,A,W,W,A,A,A],ti=[A,A,W,W,W,A,A,W,W,W,A,A],va=[A,A,W,W,A,A,A,A,W,W,A,A],Uy=[A,W,ot,W,ke,W,W,ke,W,ot,W,A],Vy={idle:[[js,Xs,Zs,Do,Ks,re,Qs,re,Js,Ae,Ae,ti],[js,Xs,Zs,ba,Ks,re,Qs,re,Js,Ae,Ae,ti]],walk:[[js,Xs,Zs,Do,Ks,re,Qs,re,Js,va,va,ti],[js,Xs,Zs,Do,Ks,re,Qs,re,Js,Ae,va,ti]],working:[js,Xs,Zs,Do,Ks,re,Qs,re,Js,Ae,Ae,ti],sleeping:[[js,Xs,Zs,ba,Ks,re,Qs,re,Js,Ae,Ae,ti],[js,Xs,Zs,ba,Ks,re,Qs,re,Js,Ae,Ae,ti]],done:[js,Xs,Zs,Uy,Ks,re,Qs,re,Js,Ae,Ae,ti],size:12},D="transparent",tt="body",X="outline",$i="highlight",rs="eye",ht="skin",qy=[D,D,D,D,D,D,D,X,X,D,D,D,D,D,D,D],Yy=[D,D,D,D,D,D,X,$i,$i,X,D,D,D,D,D,D],jy=[D,D,D,D,D,X,$i,$i,$i,$i,X,D,D,D,D,D],Xy=[D,D,D,X,X,X,X,X,X,X,X,X,X,D,D,D],_a=[D,D,D,X,ht,rs,rs,ht,ht,rs,rs,ht,X,D,D,D],zo=[D,D,D,X,ht,X,X,ht,ht,X,X,ht,X,D,D,D],Gi=[D,D,D,D,X,ht,ht,ht,ht,ht,ht,X,D,D,D,D],or=[D,D,D,D,D,X,tt,tt,tt,tt,X,D,D,D,D,D],Ii=[D,D,D,D,X,tt,tt,tt,tt,tt,tt,X,D,D,D,D],gl=[D,D,D,ht,X,tt,tt,tt,tt,tt,tt,X,ht,D,D,D],rr=[D,D,D,X,tt,tt,tt,tt,tt,tt,tt,tt,X,D,D,D],ar=[D,D,X,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,X,D,D],lr=[D,X,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,X,D],cr=[D,X,X,X,X,X,X,X,X,X,X,X,X,X,X,D],Zy=[D,D,ht,ht,X,tt,tt,tt,tt,tt,tt,X,ht,ht,D,D],Ky=[D,D,D,X,ht,ht,rs,ht,ht,rs,ht,ht,X,D,D,D],Qy=[D,D,D,D,X,ht,ht,X,X,ht,ht,X,D,D,D,D],Xi=[qy,Yy,jy,Xy],bh=Xi.map(i=>[D,...i.slice(0,-1)]),Wn=[or,Ii,gl,Ii,rr,ar,lr,cr],Jy={idle:[[...Xi,_a,Gi,...Wn],[...Xi,zo,Gi,...Wn]],walk:[[...Xi,_a,Gi,or,Ii,gl,Ii,rr,ar,lr,cr],[...Xi,zo,Gi,or,Ii,gl,Ii,rr,ar,lr,cr]],working:[...Xi,_a,Gi,or,Ii,Zy,Ii,rr,ar,lr,cr],sleeping:[[...bh,[D,...zo.slice(0,-1)],[D,...Gi.slice(0,-1)],...Wn],[...bh,[D,...zo.slice(0,-1)],[D,...Gi.slice(0,-1)],...Wn]],done:[...Xi,Ky,Qy,...Wn],size:16},ei=[D,D,D,D,D,X,X,D,D,D,D,D],si=[D,D,D,D,X,$i,$i,X,D,D,D,D],ii=[D,D,X,X,X,X,X,X,X,X,D,D],xa=[D,D,X,ht,rs,ht,ht,rs,ht,X,D,D],Fo=[D,D,X,ht,X,ht,ht,X,ht,X,D,D],Wi=[D,D,X,ht,ht,ht,ht,ht,ht,X,D,D],ae=[D,D,X,tt,tt,tt,tt,tt,tt,X,D,D],ni=[D,ht,X,tt,tt,tt,tt,tt,tt,X,ht,D],oi=[D,X,tt,tt,tt,tt,tt,tt,tt,tt,X,D],le=[X,tt,tt,tt,tt,tt,tt,tt,tt,tt,tt,X],ri=[X,X,X,X,X,X,X,X,X,X,X,X],t1=[D,D,X,ht,ht,rs,rs,ht,ht,X,D,D],e1=[D,D,X,ht,X,ht,ht,X,ht,X,D,D],s1={idle:[[ei,si,ii,xa,Wi,ae,ni,ae,oi,le,le,ri],[ei,si,ii,Fo,Wi,ae,ni,ae,oi,le,le,ri]],walk:[[ei,si,ii,xa,Wi,ae,ni,ae,oi,le,le,ri],[ei,si,ii,Fo,Wi,ae,ni,ae,oi,le,le,ri]],working:[ei,si,ii,xa,Wi,ae,ni,ae,oi,le,le,ri],sleeping:[[ei,si,ii,Fo,Wi,ae,ni,ae,oi,le,le,ri],[ei,si,ii,Fo,Wi,ae,ni,ae,oi,le,le,ri]],done:[ei,si,ii,t1,e1,ae,ni,ae,oi,le,le,ri],size:12},O="transparent",N="body",V="outline",Fu="highlight",We="eye",mt=[O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O],ai=[O,O,O,O,O,O,V,V,V,V,O,O,O,O,O,O],li=[O,O,O,O,O,V,N,N,N,N,V,O,O,O,O,O],ci=[O,O,O,O,V,N,N,Fu,N,N,N,V,O,O,O,O],hi=[O,O,O,V,N,N,N,N,N,N,N,N,V,O,O,O],No=[O,O,O,V,N,We,We,N,N,We,We,N,V,O,O,O],wa=[O,O,O,V,N,V,V,N,N,V,V,N,V,O,O,O],Oi=[O,O,V,N,N,N,N,N,N,N,N,N,N,V,O,O],di=[O,O,V,N,N,N,N,N,N,N,N,N,N,V,O,O],Go=[O,V,N,N,N,N,N,N,N,N,N,N,N,N,V,O],qe=[O,V,N,N,N,N,N,N,N,N,N,N,N,N,V,O],On=[O,O,V,V,V,V,V,V,V,V,V,V,V,V,O,O],Sa=[V,N,N,N,N,N,N,N,N,N,N,N,N,N,N,V],ka=[V,N,N,N,N,N,N,N,N,N,N,N,N,N,N,V],Ta=[O,V,V,V,V,V,V,V,V,V,V,V,V,V,V,O],i1=[O,O,V,N,N,N,V,V,V,V,N,N,N,V,O,O],n1=[O,O,O,V,N,V,We,N,N,We,V,N,V,O,O,O],o1=[O,V,N,N,N,N,N,N,N,N,N,N,N,N,V,O],r1={idle:[[mt,mt,mt,mt,ai,li,ci,hi,No,Oi,di,Go,qe,qe,On,mt],[mt,mt,mt,mt,ai,li,ci,hi,wa,Oi,di,Go,qe,qe,On,mt]],walk:[[mt,mt,mt,ai,li,ci,hi,No,Oi,di,Go,qe,qe,qe,On,mt],[mt,mt,mt,mt,mt,ai,li,ci,hi,No,Oi,di,Sa,ka,Ta,mt]],working:[mt,mt,mt,mt,ai,li,ci,hi,No,i1,di,o1,qe,qe,On,mt],sleeping:[[mt,mt,mt,mt,mt,ai,li,ci,hi,wa,Oi,di,Sa,ka,Ta,mt],[mt,mt,mt,mt,mt,ai,li,ci,hi,wa,Oi,di,Sa,ka,Ta,mt]],done:[mt,mt,mt,mt,ai,li,ci,hi,n1,Oi,di,Go,qe,qe,On,mt],size:16},St=[O,O,O,O,O,O,O,O,O,O,O,O],ui=[O,O,O,O,V,V,V,V,O,O,O,O],fi=[O,O,O,V,N,N,Fu,N,V,O,O,O],pi=[O,O,V,N,N,N,N,N,N,V,O,O],Wo=[O,O,V,We,We,N,N,We,We,V,O,O],Ca=[O,O,V,V,V,N,N,V,V,V,O,O],mi=[O,V,N,N,N,N,N,N,N,N,V,O],es=[O,V,N,N,N,N,N,N,N,N,V,O],Hn=[O,O,V,V,V,V,V,V,V,V,O,O],Aa=[V,N,N,N,N,N,N,N,N,N,N,V],Ma=[O,V,V,V,V,V,V,V,V,V,V,O],a1=[O,V,N,N,V,V,V,V,N,N,V,O],l1=[O,O,V,V,We,N,N,We,V,V,O,O],c1={idle:[[St,St,St,ui,fi,pi,Wo,mi,es,es,Hn,St],[St,St,St,ui,fi,pi,Ca,mi,es,es,Hn,St]],walk:[[St,St,ui,fi,pi,Wo,mi,es,es,es,Hn,St],[St,St,St,St,ui,fi,pi,Wo,mi,Aa,Ma,St]],working:[St,St,St,ui,fi,pi,Wo,a1,mi,es,Hn,St],sleeping:[[St,St,St,St,ui,fi,pi,Ca,mi,Aa,Ma,St],[St,St,St,St,ui,fi,pi,Ca,mi,Aa,Ma,St]],done:[St,St,St,ui,fi,pi,l1,mi,es,es,Hn,St],size:12},yl=[_y,My,$y,Hy,Jy,r1],vh=[xy,Iy,zy,Vy,s1,c1];function h1(i){let t=0;for(let e=0;e<i.length;e++)t=(t<<5)-t+i.charCodeAt(e)|0;return Math.abs(t)%yl.length}function d1(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 Oo=3,_h=new Map;function ce(i,t,e,s){const n=_h.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 h=0;h<l;h++){const p=d1(e,t[d][h]);p!==null&&o.rect(h*Oo,d*Oo,Oo,Oo).fill(p)}const c=i.generateTexture({target:o});return o.destroy(),_h.set(s,c),c}function he(i,t){return`${i}_p${t}`}function dn(i){const t=new zt,e=new Wt;t.addChild(e);const s=new Ki({text:i.label,style:new Xe({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 Ho(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 xh(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 wh=3500,u1=3e3,Sh=500,Ea=8,f1=5,p1=6,kh=160,Uo=5,m1={tool:{bg:1712960,border:3821696,text:15266047},text:{bg:1712960,border:4212832,text:13421772},"input-needed":{bg:3809296,border:16750592,text:16764032}};class g1{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 zt,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 Xe({fontSize:10,fontFamily:"'Segoe UI', 'Helvetica Neue', Arial, sans-serif",fill:15266047,wordWrap:!0,wordWrapWidth:kh-Ea*2,lineHeight:14});this.textObj=new Ki({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=wh,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>=u1&&(this.rotateTimer=0,this.currentIndex=(this.currentIndex+1)%this.queue.length,this.showCurrentMessage(),this.speechTimer=wh)),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<=Sh&&this.currentType!=="input-needed"&&(this.container.alpha=Math.max(0,this.speechTimer/Sh)),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=m1[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 c=Math.min(this.textObj.width,kh-Ea*2),d=this.textObj.height,h=c+Ea*2,p=d+f1*2;this.bg.clear(),this.bg.roundRect(-h/2,-(p+Uo),h,p,p1).fill({color:e.bg,alpha:.92}).stroke({color:e.border,width:1,alpha:.6}),this.pointer.clear(),this.pointer.moveTo(-Uo,0).lineTo(0,Uo).lineTo(Uo,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 y1=2,b1=4,v1=.7,_1=100,x1=3,w1=1.5,S1=2,k1=2.5,T1=.8,C1=1,A1=1.5,Th=600,Ch=3e3,Ah=30,Mh=18,ns=class ns{constructor(t,e,s){b(this,"container",new zt);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=h1(t.projectPath??t.sessionId);const o=this.variantIndex,r=n?vh[o]:yl[o],l=n?`sub_v${o}`:`main_v${o}`,c=t.colorIndex;this.spriteHeight=r.size*3,this.textures={idle:[ce(s,r.idle[0],e,he(`${l}_idle0`,c)),ce(s,r.idle[1],e,he(`${l}_idle1`,c))],walk:[ce(s,r.walk[0],e,he(`${l}_walk0`,c)),ce(s,r.walk[1],e,he(`${l}_walk1`,c))],working:ce(s,r.working,e,he(`${l}_working`,c)),sleeping:[ce(s,r.sleeping[0],e,he(`${l}_sleeping0`,c)),ce(s,r.sleeping[1],e,he(`${l}_sleeping1`,c))],done:ce(s,r.done,e,he(`${l}_done`,c))},this.sprite=new Qi(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||mo(t.sessionId),h=d.length>14?d.slice(0,12)+"..":d,p=new Xe({fontSize:11,fontFamily:"'Segoe UI', 'Helvetica Neue', Arial, sans-serif",fill:16777215,align:"center",fontWeight:"700"});this.nameLabel=new Ki({text:h,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 g1(this.spriteHeight),this.container.addChild(this.speechBubble.container),this.zzzContainer=new zt,this.zzzContainer.visible=!1,this.zzzLetters=[];const g=[8,10,13],m=["z","z","Z"];for(let _=0;_<3;_++){const w=new Ki({text:m[_],style:new Xe({fontSize:g[_],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 zt,this.waitQContainer.visible=!1,this.waitQLetters=[];const y=[9,11,14];for(let _=0;_<3;_++){const w=new Ki({text:"?",style:new Xe({fontSize:y[_],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:(_,w)=>{const k=this.spriteHeight/2+10,E=-this.spriteHeight/2-10,B=this.spriteHeight/2+25;return _>=-k&&_<=k&&w>=E&&w<=B}},this.spawnAnimTimer=ns.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()}setNameVisible(t){this.nameLabel.visible=t,this.nameBg.visible=t}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?vh[n]:yl[n],r=this.isSubagent?`sub_v${n}`:`main_v${n}`,l=e;this.textures={idle:[ce(s,o.idle[0],t,he(`${r}_idle0`,l)),ce(s,o.idle[1],t,he(`${r}_idle1`,l))],walk:[ce(s,o.walk[0],t,he(`${r}_walk0`,l)),ce(s,o.walk[1],t,he(`${r}_walk1`,l))],working:ce(s,o.working,t,he(`${r}_working`,l)),sleeping:[ce(s,o.sleeping[0],t,he(`${r}_sleeping0`,l)),ce(s,o.sleeping[1],t,he(`${r}_sleeping1`,l))],done:ce(s,o.done,t,he(`${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 c=Math.max(2,n*this._contextPct);this.contextBar.roundRect(o,r+n-c,s,c,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=dn({label:"✓",fontSize:10}),this.doneBadge.container.position.set(0,-this.spriteHeight/2-14),this.container.addChild(this.doneBadge.container)),Ho(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=dn({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}`,Ho(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=dn({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&&xh(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=dn({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&&Ho(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=dn({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&&xh(this.compactBadge.bg,58,13,3,8141549,10980346,t*.9,t*.7)}flashOutcome(t){this.outcomeFlash={outcome:t,timer:ns.OUTCOME_FLASH_DURATION}}bumpActivity(){this.activityLevel=Math.min(1,this.activityLevel+.35)}setAnomaly(t){this._hasAnomaly=!0,this.anomalyPulseTimer=0,this.anomalyBadge||(this.anomalyBadge=dn({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=Th,new Promise(t=>{this.fadeResolve=t}))}update(t){var n,o,r,l,c;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/ns.SPAWN_ANIM_DURATION,h=1-Math.pow(2,-8*d)*Math.cos(d*Math.PI*3);this.container.scale.set(Math.max(.3,Math.min(1,h)))}if(this.fadingOut){this.fadeTimer-=t,this.container.alpha=Math.max(0,this.fadeTimer/Th),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>=ns.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"?b1:this.animState==="sleeping"?v1:y1);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 h=d/this.zzzLetters.length,p=(this.zzzTimer/Ch+h)%1,g=this.zzzLetters[d];g.position.set(p*Mh,-p*Ah),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 h=d/this.waitQLetters.length,p=(this.waitQTimer/Ch+h)%1,g=this.waitQLetters[d];g.position.set(p*Mh,-p*Ah),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 h=this.sparkles[d];h.phase+=t;const p=2e3+d*700,g=h.phase%p/p;g<.15?(h.gfx.visible=!0,h.gfx.alpha=g/.15):g<.3?(h.gfx.visible=!0,h.gfx.alpha=1-(g-.15)/.15):h.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,h=.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:h})}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:h*.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,h=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:h})}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:h*.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 h=1+.04*Math.sin(this.compactPulseTimer*2);this.compactBadge.container.scale.set(h,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/ns.OUTCOME_FLASH_DURATION,h=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:h}),this.activityRing.circle(0,0,p+4).stroke({color:g,width:1.5,alpha:h*.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),Ho(this.anomalyBadge.bg,8,15680580,16498468,1.5,.9,.7)}if(this._isWaiting&&((c=this.waitBadge)!=null&&c.container.visible)){this.waitPulseTimer+=t*.005;const d=.5+.5*Math.sin(this.waitPulseTimer);this.drawWaitBadge(d);const h=1+.15*Math.sin(this.waitPulseTimer*.7);this.waitBadge.container.scale.set(h)}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<x1){this.container.x=this.targetX,this.container.y=this.targetY,this.baseY=this.container.y,this.isMoving=!1;return}const r=Math.min(_1*e,o);this.container.x+=s/o*r,this.container.y+=n/o*r}updateBob(t){const e=this.animState==="sleeping"?k1:this.animState==="done"?C1:w1,s=this.animState==="sleeping"?T1:this.animState==="done"?A1:S1;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(ns,"IDLE_TO_SLEEP_MS",3e4),b(ns,"OUTCOME_FLASH_DURATION",700),b(ns,"SPAWN_ANIM_DURATION",400);let bl=ns;const Eh=6,Ph=4,M1=.04,E1=3,P1=.15,I1=1,Ih=.5,Lh=6,Bh=400,Rh=4886745,L1=4521796;class B1{constructor(){b(this,"graphics",new Wt);b(this,"time",0);b(this,"pulseTimers",new Map)}pulseConnection(t,e){this.pulseTimers.set(`${t}->${e}`,Bh)}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 c=`${r.parentId}->${o}`,d=this.pulseTimers.get(c)??0,p=d>0?d/Bh:0;this.drawGlowingDashedLine(l.x,l.y,r.x,r.y,Rh,p),this.drawArrow(l.x,l.y,r.x,r.y,Rh,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,L1,0)}drawGlowingDashedLine(t,e,s,n,o,r){const l=this.time*M1,c=P1+r*.35,d=Ih+r*.4,h=E1+r*2;this.drawDashedLine(t,e,s,n,o,c,h,l),this.drawDashedLine(t,e,s,n,o,d,I1,l)}drawDashedLine(t,e,s,n,o,r,l,c){const d=s-t,h=n-e,p=Math.sqrt(d*d+h*h);if(p<1)return;const g=d/p,m=h/p,y=Eh+Ph;let w=-((c%y+y)%y),k=!0;for(;w<p;){const B=w+(k?Eh:Ph);if(k){const L=Math.max(w,0),H=Math.min(B,p);if(H>L){const $=t+g*L,G=e+m*L,et=t+g*H,Z=e+m*H;this.graphics.moveTo($,G).lineTo(et,Z).stroke({color:o,width:l,alpha:r})}}w=B,k=!k}}drawArrow(t,e,s,n,o,r){const l=s-t,c=n-e,d=Math.sqrt(l*l+c*c);if(d<Lh*3)return;const h=l/d,p=c/d,g=(t+s)/2,m=(e+n)/2,y=-p,_=h,w=Lh/2,k=Ih+r*.4,E=g+h*w,B=m+p*w,L=g-h*w+y*w,H=m-p*w+_*w,$=g-h*w-y*w,G=m-p*w-_*w;this.graphics.moveTo(E,B).lineTo(L,H).lineTo($,G).closePath().fill({color:o,alpha:k})}destroy(){this.graphics.destroy()}}const R1=8,Pa=3,$h=800,Dh=30;class $1{constructor(t){b(this,"container",new zt);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<R1;o++){const r=new Qi(n);r.anchor.set(.5),r.position.set(t,e),r.alpha=1;const l=Math.random()*Math.PI*2,c=Dh*(.5+Math.random()*.5);this.container.addChild(r),this.particles.push({sprite:r,vx:Math.cos(l)*c,vy:-Math.abs(Math.sin(l)*c)-Dh*.5,life:$h,maxLife:$h})}}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(Pa,Pa,Pa).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 D1=800,zh=3,Fh=3,z1=40;class F1{constructor(){b(this,"container",new zt);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:D1})}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<=zh;r++){const l=Math.max(0,n-r*.06),c=this.getArcPosition(s,l),d=(1-r/(zh+1))*(1-n*.3),h=Fh*(1-r*.2);s.gfx.circle(c.x,c.y,h).fill({color:s.color,alpha:d})}const o=this.getArcPosition(s,n);s.gfx.circle(o.x,o.y,Fh*2.5).fill({color:s.color,alpha:.15})}}getArcPosition(t,e){const s=(t.fromX+t.toX)/2,n=(t.fromY+t.toY)/2-z1,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 N1{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 G1(i){const t=[];if(i.currentTool==="AskUserQuestion")return t.push({text:"Waiting for input...",type:"input-needed",icon:"⏳"}),t;if(i.currentTool){const e=A0[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 Vo(i,t,e,s){const n=Xt.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,c=n.width-40,d=n.height-70,h=n.x+20,p=n.y+50;if(l===1)return{x:h+c/2,y:p+d/2};const g=Math.ceil(Math.sqrt(l)),m=Math.ceil(l/g),y=r%g,_=Math.floor(r/g),w=c/g,k=d/m;return{x:h+w*y+w/2,y:p+k*_+k/2}}class W1{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,"_showNames",!0);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 B1,this.world.uiLayer.addChild(this.lines.graphics),this.particles=new $1(t.renderer),this.world.addEffect(this.particles.container),this.messageFlow=new F1,this.world.addEffect(this.messageFlow.container),this.zoneGlow=new N1,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}setShowNames(t){if(t!==this._showNames){this._showNames=t;for(const e of this.agents.values())e.sprite.setNameVisible(t)}}getDisplayName(t){return this._customizationLookup?this._customizationLookup(t).displayName:t.agentName||mo(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 c,d;if(this.agents.has(t.id))return;const e=ut[t.colorIndex%ut.length],s=new bl(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 h=this.world.getZoneCenter("spawn");s.container.position.set(h.x,h.y)}s.onClick(()=>{var h;return(h=this._onAgentClick)==null?void 0:h.call(this,t.id)}),s.onHover(()=>{var h;return(h=this._onAgentHover)==null?void 0:h.call(this,t.id,s.container.x,s.container.y)},()=>{var h;return(h=this._onAgentHover)==null?void 0:h.call(this,null,0,0)});const o=this.getDisplayName(t),r=this.getDisplayColorIndex(t);if(s.setCustomName(o),r!==t.colorIndex){const h=ut[r%ut.length];s.rebuildTextures(h,r,this.app.renderer)}s.setContextHealth(t.contextTokens/this.getContextWindowSize(t.model),t.contextCacheTokens/this.getContextWindowSize(t.model)),this._showNames||s.setNameVisible(!1),this.agents.set(t.id,{sprite:s,state:t,notifiedWaiting:!1,lastSeenOutcome:null}),this.world.addAgent(s.container);const l=Vo(t.currentZone,t.id,this.agents,this.world);s.moveTo(l.x,l.y),this.updateChildBadges(),(c=this.sound)==null||c.play("spawn"),(d=this.notifications)==null||d.notifySpawn(o)}getContextWindowSize(t){return Fl(t)}onUpdate(t){var r,l,c,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=Vo(t.currentZone,t.id,this.agents,this.world);e.sprite.moveTo(n.x,n.y);const o=G1(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 h=ut[this.getDisplayColorIndex(t)%ut.length];if(this.particles.emit(e.sprite.container.x,e.sprite.container.y,h.body),(c=this.sound)==null||c.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,h.body)}e.sprite.bumpActivity()}if(s!==t.currentZone){(d=this.sound)==null||d.play("zone-change");const h=ut[this.getDisplayColorIndex(t)%ut.length];this.world.flowLines.triggerFlow(s,t.currentZone,h.body)}}onIdle(t){var n,o;const e=this.agents.get(t.id);if(!e)return;e.state=t;const s=Vo("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=Vo(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 Xt.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||mo(o.sessionId);n.sprite.setCustomName(r);const l=s??o.colorIndex,c=ut[l%ut.length];n.sprite.rebuildTextures(c,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 $t(i){return i.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function te(i){return $t(i).replace(/"/g,""")}function as(i){return"#"+i.toString(16).padStart(6,"0")}function _e(i){return i>=1e6?`${(i/1e6).toFixed(1)}M`:i>=1e3?`${(i/1e3).toFixed(1)}K`:`${i}`}function Nu(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 Mn(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 Gu(i,t){return i.length>t?i.slice(0,t-1)+"…":i}const O1={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 Wu(i){const t=O1[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 H1{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(h=>h.isDone).length,n=[...new Set(e.map(h=>h.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(h=>{const p=h.value==="done"&&s>0?` <span class="filter-badge">${s}</span>`:"";return`<button class="filter-pill${this.currentFilter===h.value?" active":""}" data-filter="${h.value}">${h.label}${p}</button>`}).join("")+`
|
|
262
|
-
<select class="filter-zone-select" title="Filter by zone">
|
|
263
|
-
<option value="">Zone...</option>
|
|
264
|
-
${se.map(h=>`<option value="${h.id}" ${this.currentFilter===h.id?"selected":""}>${h.icon} ${h.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(h=>`<option value="project:${te(h)}" ${r===h?"selected":""}>${$t(h)}</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(h=>{h.addEventListener("click",()=>{this.currentFilter=h.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 h=this.filterEl.querySelector(".filter-project-select");h&&(h.value=""),this.renderFilters(),this.renderAgents()});const c=this.filterEl.querySelector(".filter-project-select");c&&c.addEventListener("change",()=>{c.value?this.currentFilter=c.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,_)=>y.isDone!==_.isDone?y.isDone?1:-1:y.isIdle!==_.isIdle?y.isIdle?1:-1:y.spawnedAt-_.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)),c=new Map;for(const y of n)if(y.parentId&&l.has(y.parentId)){let _=c.get(y.parentId);_||(_=[],c.set(y.parentId,_)),_.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 h=new Map,p=[];for(const y of o)if(y.teamName){const _=`${y.rootSessionId}:${y.teamName}`;let w=h.get(_);w||(w=[],h.set(_,w)),w.push(y)}else p.push(y);let g="";for(const[y,_]of h){const w=y.indexOf(":"),k=w>=0?y.slice(w+1):y,E=(m=_[0])==null?void 0:m.rootSessionId;_.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?"▸":"▾"}</span>
|
|
297
|
-
<span class="group-icon">👥</span>
|
|
298
|
-
<span class="group-name">${$t(k)}</span>
|
|
299
|
-
<span class="group-count">${B}</span>
|
|
300
|
-
</div>`,!H){g+='<div class="group-children">';for(const $ of _)g+=this.renderAgentWithSubs($,c,d);g+="</div>"}g+="</div>"}for(const y of p)g+=this.renderAgentWithSubs(y,c,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 _=y.dataset.groupId;_&&this.toggleGroup(_)}),y.addEventListener("keydown",_=>{if(_.key==="Enter"||_.key===" "){_.preventDefault();const w=y.dataset.groupId;w&&this.toggleGroup(w)}})}),this.agentListEl.querySelectorAll(".sub-collapse-bar").forEach(y=>{y.addEventListener("click",()=>{const _=y.dataset.groupId;_&&this.toggleGroup(_)})}),this.agentListEl.querySelectorAll(".agent-card[data-agent-id]").forEach(y=>{y.addEventListener("click",()=>{const _=y.dataset.agentId;_&&this.onAgentClick&&this.onAgentClick(_)})}),this.agentListEl.querySelectorAll(".sparkline-canvas").forEach(y=>{const _=y.dataset.agentId;_&&this.drawSparkline(y,_)}),this.agentListEl.querySelectorAll(".agent-sparkline").forEach(y=>{const _=y.dataset.agentId;_&&this.drawToolVelocitySparkline(y,_)})}renderAgentWithSubs(t,e,s,n=!1){const o=e.get(t.id),r=s.get(t.id)??0,l=o&&o.length>0;let c="";if(l){const d=`sub:${t.id}`,h=this.collapsedGroups.has(d);c+=this.renderCard(t,n,0);const p=h?"▸":"▾",g=`${r} subagent${r>1?"s":""}`;if(c+=`<div class="sub-collapse-bar${h?" 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>`,!h){c+='<div class="subagent-group">';for(const m of o)c+=this.renderAgentWithSubs(m,e,s,!0);c+="</div>"}}else c+=this.renderCard(t,n,r);return c}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=ut[o%ut.length],l=as(r.body),c=Xt.get(t.currentZone),d=c?c.label:t.currentZone,h=t.currentTool??"none",p=Nu(t.totalInputTokens,t.totalOutputTokens),g=(n==null?void 0:n.displayName)||t.agentName||mo(t.sessionId),m=e?" agent-card-child":"",y=t.isDone?" agent-card-done":"",_=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?Lu(t.projectPath):o,E=as(ut[k%ut.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
|
-
">${$t(t.projectName)}</span>`:"",L=Wu(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">↳</span>':""}${$t(g)}${L}${this.roleBadge(t.role)}${B}${_}${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)}">${$t(Gu(t.taskDescription,48))}</div>`:""}
|
|
325
|
-
<div class="zone">${(c==null?void 0:c.icon)??""} ${d} · ${h}</div>
|
|
326
|
-
<div class="card-tokens">${t.contextTokens>0?(()=>{const et=Fl(t.model),Z=Math.round(t.contextTokens/et*100),j=Z>=90?"#ef4444":Z>=75?"#f97316":Z>=50?"#eab308":"#22c55e",Q=t.contextTokens-t.contextCacheTokens,rt=lt=>lt>=1e3?`${Math.round(lt/1e3)}k`:`${lt}`;return`<span class="detail-ctx-bar" title="Context window: ${Z}% full ${Q.toLocaleString()} new + ${t.contextCacheTokens.toLocaleString()} cached = ${t.contextTokens.toLocaleString()} / ${et.toLocaleString()}"><span class="detail-ctx-breakdown">${rt(Q)} new · ${rt(t.contextCacheTokens)} cached</span><span class="detail-ctx-track"><span class="detail-ctx-fill" style="width:${Z}%;background:${j}"></span></span><span class="detail-ctx-label" style="color:${j}">${Z}%</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 c=s-l,d=Math.floor(c/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),c=10,d=Math.floor(n/c)-1,h=1,p=t.dataset.colorIndex,g=p?parseInt(p,10):0,m=ut[g%ut.length],y=as(m.body);for(let _=0;_<c;_++){const w=r[_]??0,k=Math.max(w>0?2:0,Math.round(w/l*(o-2))),E=_*(d+h),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 h=1;h<n.samples.length;h++)l.push(Math.max(0,n.samples[h]-n.samples[h-1]));const c=Math.max(...l,1),d=o/Math.max(l.length-1,1);s.beginPath(),s.moveTo(0,r);for(let h=0;h<l.length;h++){const p=h*d,g=r-l[h]/c*(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 h=0;h<l.length;h++){const p=h*d,g=r-l[h]/c*(r-2)-1;h===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 U1{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=ut[s%ut.length],o=as(n.body),r=e||this.getDisplayName(t),l=t.isDone?"done":t.isIdle?"idle":"active",c=t.isDone?"Agent finished":t.isIdle?"Agent is idle":"Agent is actively working",h={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: ${h.label}" style="background:${h.color}33;color:${h.color};">${h.label}</span>`;let g="";if(t.projectName){const _=t.projectPath?Lu(t.projectPath):s,w=as(ut[_%ut.length].body);g=`<span class="detail-project-badge" title="Project: ${te(t.projectName)}" style="background:${w}33;color:${w};">${$t(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="${c}"></span>
|
|
348
|
-
${$t(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)}">${$t(Gu(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=Xt.get(t.currentZone),s=(e==null?void 0:e.icon)??"",n=(e==null?void 0:e.label)??t.currentZone,o=t.currentTool??"none",r=Nu(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">·</span> <span class="detail-card-tool" title="Current tool: ${te(o)}">${$t(o)}</span>`);const c=this.panelEl.querySelector("#detail-token-line");if(c){const h=Fl(t.model),p=t.contextTokens>0?Math.round(t.contextTokens/h*100):0,g=p>=90?"#ef4444":p>=75?"#f97316":p>=50?"#eab308":"#22c55e",m=t.contextTokens-t.contextCacheTokens,y=w=>w>=1e3?`${Math.round(w/1e3)}k`:`${w}`,_=`Context window: ${p}% full
|
|
361
|
-
${m.toLocaleString()} new + ${t.contextCacheTokens.toLocaleString()} cached = ${t.contextTokens.toLocaleString()} / ${h.toLocaleString()}`;c.innerHTML=p>0?`<span class="detail-ctx-bar" title="${_}">
|
|
362
|
-
<span class="detail-ctx-breakdown">${y(m)} new · ${y(t.contextCacheTokens)} cached</span>
|
|
363
|
-
<span class="detail-ctx-track"><span class="detail-ctx-fill" style="width:${p}%;background:${g}"></span></span>
|
|
364
|
-
<span class="detail-ctx-label" style="color:${g}">${p}%</span>
|
|
365
|
-
</span>`:`<span title="Total token usage">${r}</span>`}const d=this.panelEl.querySelector(".detail-health-dot");if(d){const h=t.isDone||t.isIdle?"#888":"#22c55e";d.style.background=h,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",Mn(Date.now()-t.spawnedAt),"How long this agent has been running")),s.push(this.infoRow("CLI",Wu(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",$t(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),c=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">${$t(c)}</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(c=>{const d=this.getDisplayName(c);return`<a href="#" class="detail-link" data-agent-id="${te(c.id)}" title="Navigate to subagent">${$t(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",c=>{c.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",c=>{c.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 h=1;h<this.tokenSamples.length;h++)l.push(Math.max(0,this.tokenSamples[h]-this.tokenSamples[h-1]));const c=Math.max(...l,1),d=o/Math.max(l.length-1,1);n.beginPath(),n.moveTo(0,r);for(let h=0;h<l.length;h++)n.lineTo(h*d,r-l[h]/c*(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 h=0;h<l.length;h++){const p=h*d,g=r-l[h]/c*(r-2)-1;h===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(),c=3e4,d=10,h=new Array(d).fill(0);for(const w of this.toolTimestamps){const k=Math.floor((l-w)/c);k>=0&&k<d&&h[d-1-k]++}const p=Math.max(...h,1),g=Math.floor(o/d)-1,m=this.getDisplayColorIndex(t),y=ut[m%ut.length],_=as(y.body);for(let w=0;w<d;w++){const k=h[w]??0,E=Math.max(k>0?2:0,Math.round(k/p*(r-2)));n.fillStyle=_,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">🔧</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">💬</span> ${te(n)}</div>`}case"zone-change":{const n=Xt.get(t.prevZone),o=Xt.get(t.zone);return`<div class="feed-entry feed-zone">${s} <span class="feed-icon">🚶</span> ${(n==null?void 0:n.icon)??""} ${(n==null?void 0:n.label)??t.prevZone} → ${(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">⚡</span> Agent spawned</div>`;case"idle":return`<div class="feed-entry feed-idle">${s} <span class="feed-icon">☕</span> Went idle</div>`;case"shutdown":return`<div class="feed-entry feed-shutdown">${s} <span class="feed-icon">🛑</span> Agent shut down</div>`;case"tokens":return`<div class="feed-entry feed-tokens">${s} <span class="feed-icon">🎬</span> +${_e(t.inputTokens??0)} in / +${_e(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 V1(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 Nh(i){switch(i.type){case"agent:spawn":return"#a855f7";case"agent:shutdown":return"#f87171";case"agent:idle":return"#6b7280";case"agent:update":return"#"+ut[i.agent.colorIndex%ut.length].body.toString(16).padStart(6,"0")}}function Ou(i){return i<300*1e3?60*1e3:i<900*1e3?120*1e3:300*1e3}function q1(i,t,e,s,n,o){e.fillStyle="rgba(255,255,255,0.15)",e.font="9px monospace",e.textAlign="center";const r=Ou(o),l=Math.ceil(s/r)*r;for(let c=l;c<=n;c+=r){const d=(c-s)/o*i;e.fillRect(d,0,1,3);const h=new Date(c);e.fillText(h.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),d,t-1)}}function Gh(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 c=r*i;e.strokeStyle="#e94560",e.lineWidth=2,e.beginPath(),e.moveTo(c,0),e.lineTo(c,t),e.stroke();const d=s+r*n;l.textContent=new Date(d).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}}class Y1{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="#"+ut[e.colorIndex%ut.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 j1{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">▶</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">🔧</span> Tools
|
|
391
|
-
</button>
|
|
392
|
-
<button class="tl-filter-pill active" data-category="zone" title="Zone changes">
|
|
393
|
-
<span class="tl-filter-icon">🏢</span> Zones
|
|
394
|
-
</button>
|
|
395
|
-
<button class="tl-filter-pill active" data-category="idle" title="Idle events">
|
|
396
|
-
<span class="tl-filter-icon">☕</span> Idle
|
|
397
|
-
</button>
|
|
398
|
-
<button class="tl-filter-pill active" data-category="lifecycle" title="Spawn / Shutdown">
|
|
399
|
-
<span class="tl-filter-icon">⭐</span> Life
|
|
400
|
-
</button>
|
|
401
|
-
</div>
|
|
402
|
-
<div class="timeline-agent-filters"></div>
|
|
403
|
-
<button class="timeline-expand-btn" title="Expand swim lanes">▲</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 Y1(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?"▮▮":"▶",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="▼",this.expandBtn.title="Collapse swim lanes"):(this.el.classList.remove("expanded"),this.expandBtn.classList.remove("active"),this.expandBtn.innerHTML="▲",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 c of n){const d=(c.timestamp-o)/l*t,h=Nh(c);s.fillStyle=h,c.type==="agent:spawn"||c.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)}q1(t,e,s,o,r,l),Gh(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:c}=this.getTimeRange(),d=c-l||1,h=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),Gh(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)),_=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 $="#"+ut[L.colorIndex%ut.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,h,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,_);for(const L of r){const H=V1(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*h,et=$*y,Z=Nh(L);s.fillStyle=Z;const j=et+y/2;L.type==="agent:spawn"||L.type==="agent:shutdown"?s.fillRect(G-1,et+1,3,y-2):L.type==="agent:idle"?(s.globalAlpha=.5,s.beginPath(),s.moveTo(G,j-3),s.lineTo(G+3,j),s.lineTo(G,j+3),s.lineTo(G-3,j),s.closePath(),s.fill(),s.globalAlpha=1):(s.globalAlpha=.7,s.beginPath(),s.arc(G,j,2.5,0,Math.PI*2),s.fill(),s.globalAlpha=1)}const k=_;s.fillStyle="rgba(255,255,255,0.15)",s.font="9px monospace",s.textAlign="center";const E=Ou(d),B=Math.ceil(l/E)*E;for(let L=B;L<=c;L+=E){const H=p+(L-l)/d*h;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*h;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="▶",this.stopPlayback(),this.reconstructState(),this.render()}goLive(){this.isLive=!0,this.isPlaying=!1,this.playBtn.innerHTML="▶",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)}}function xs(i,t,e,s,n,o,r,l){s.forEach((c,d)=>{const h=i.createOscillator(),p=i.createGain();h.type=n,h.frequency.value=c;const g=t+d*o;p.gain.setValueAtTime(0,g),p.gain.linearRampToValueAtTime(e,g+r),p.gain.exponentialRampToValueAtTime(.001,g+l),h.connect(p).connect(i.destination),h.start(g),h.stop(g+l+.05)})}function Pe(i,t,e,s,n,o,r,l){const c=i.createOscillator(),d=i.createGain();c.type=o,c.frequency.setValueAtTime(s,t),c.frequency.exponentialRampToValueAtTime(n,t+r),d.gain.setValueAtTime(e,t),d.gain.exponentialRampToValueAtTime(.001,t+l),c.connect(d).connect(i.destination),c.start(t),c.stop(t+l+.05)}const X1=[{id:"chime",label:"Chime",play:(i,t,e)=>xs(i,t,e*.25,[523.25,659.25,783.99],"sine",.1,.03,.3)},{id:"fanfare",label:"Fanfare",play:(i,t,e)=>xs(i,t,e*.2,[392,523.25,659.25],"square",.12,.02,.35)},{id:"pixel-pop",label:"Pixel Pop",play:(i,t,e)=>Pe(i,t,e*.2,200,1200,"square",.15,.25)},{id:"synth-rise",label:"Synth Rise",play:(i,t,e)=>Pe(i,t,e*.18,220,880,"sawtooth",.3,.4)},{id:"harp",label:"Harp",play:(i,t,e)=>xs(i,t,e*.2,[261.63,329.63,392,523.25],"triangle",.06,.01,.5)}],Z1=[{id:"blip",label:"Blip",play:(i,t,e)=>Pe(i,t,e*.12,440,660,"sine",.08,.15)},{id:"swoosh",label:"Swoosh",play:(i,t,e)=>Pe(i,t,e*.1,1200,200,"sawtooth",.12,.18)},{id:"pop",label:"Pop",play:(i,t,e)=>Pe(i,t,e*.15,600,300,"sine",.04,.08)},{id:"warp",label:"Warp",play(i,t,e){const s=e*.07;["sine","triangle"].forEach((n,o)=>{const r=i.createOscillator(),l=i.createGain();r.type=n,r.frequency.setValueAtTime(300+o*20,t),r.frequency.exponentialRampToValueAtTime(800+o*40,t+.1),r.frequency.exponentialRampToValueAtTime(400,t+.18),l.gain.setValueAtTime(s,t),l.gain.exponentialRampToValueAtTime(.001,t+.22),r.connect(l).connect(i.destination),r.start(t),r.stop(t+.27)})}}],K1=[{id:"tap",label:"Tap",play:(i,t,e)=>Pe(i,t,e*.06,880,600,"sine",.06,.08)},{id:"click",label:"Click",play:(i,t,e)=>Pe(i,t,e*.08,1200,400,"square",.02,.04)},{id:"hammer",label:"Hammer",play:(i,t,e)=>Pe(i,t,e*.07,200,80,"triangle",.05,.1)},{id:"beep",label:"Beep",play:(i,t,e)=>Pe(i,t,e*.06,1e3,980,"sine",.04,.06)},{id:"typewriter",label:"Typewriter",play(i,t,e){const s=e*.05;[0,.03].forEach(n=>{Pe(i,t+n,s,800+Math.random()*400,200,"square",.015,.025)})}}],Q1=[{id:"descend",label:"Descend",play:(i,t,e)=>Pe(i,t,e*.1,440,330,"sine",.2,.3)},{id:"wind-down",label:"Wind Down",play(i,t,e){const s=e*.08,n=i.createOscillator(),o=i.createOscillator(),r=i.createGain(),l=i.createGain();n.type="triangle",n.frequency.setValueAtTime(500,t),n.frequency.exponentialRampToValueAtTime(150,t+.4),o.type="sine",o.frequency.value=8,r.gain.value=30,o.connect(r).connect(n.frequency),l.gain.setValueAtTime(s,t),l.gain.exponentialRampToValueAtTime(.001,t+.45),n.connect(l).connect(i.destination),o.start(t),n.start(t),n.stop(t+.5),o.stop(t+.5)}},{id:"sigh",label:"Sigh",play:(i,t,e)=>Pe(i,t,e*.08,600,200,"sawtooth",.3,.4)},{id:"music-box",label:"Music Box",play:(i,t,e)=>xs(i,t,e*.12,[659.25,440],"sine",.2,.01,.4)}],J1=[{id:"farewell",label:"Farewell",play:(i,t,e)=>xs(i,t,e*.2,[659.25,523.25,392],"triangle",.12,.02,.3)},{id:"power-down",label:"Power Down",play:(i,t,e)=>Pe(i,t,e*.15,800,60,"square",.5,.55)},{id:"portal",label:"Portal",play(i,t,e){const s=e*.12;[0,5].forEach(n=>{const o=i.createOscillator(),r=i.createGain();o.type="sine",o.frequency.setValueAtTime(900+n,t),o.frequency.exponentialRampToValueAtTime(200,t+.35),o.detune.value=n*10,r.gain.setValueAtTime(s*.6,t),r.gain.exponentialRampToValueAtTime(.001,t+.4),o.connect(r).connect(i.destination),o.start(t),o.stop(t+.45)})}},{id:"wave",label:"Wave",play:(i,t,e)=>xs(i,t,e*.15,[392,523.25,440,330],"sine",.08,.02,.2)}],tb=[{id:"doorbell",label:"Doorbell",play:(i,t,e)=>xs(i,t,e*.3,[880,660],"sine",.15,.02,.25)},{id:"alarm",label:"Alarm",play(i,t,e){const s=e*.2;for(let n=0;n<4;n++){const o=i.createOscillator(),r=i.createGain();o.type="square",o.frequency.value=n%2===0?1e3:800;const l=t+n*.08;r.gain.setValueAtTime(s,l),r.gain.setValueAtTime(.001,l+.06),o.connect(r).connect(i.destination),o.start(l),o.stop(l+.07)}}},{id:"ping",label:"Ping",play:(i,t,e)=>xs(i,t,e*.25,[1047],"sine",0,.01,.6)},{id:"siren",label:"Siren",play(i,t,e){const s=e*.15,n=i.createOscillator(),o=i.createGain();n.type="sine",n.frequency.setValueAtTime(600,t),n.frequency.linearRampToValueAtTime(1e3,t+.15),n.frequency.linearRampToValueAtTime(600,t+.3),n.frequency.linearRampToValueAtTime(1e3,t+.45),o.gain.setValueAtTime(s,t),o.gain.setValueAtTime(s,t+.4),o.gain.exponentialRampToValueAtTime(.001,t+.5),n.connect(o).connect(i.destination),n.start(t),n.stop(t+.55)}},{id:"chime-alert",label:"Chime Alert",play:(i,t,e)=>xs(i,t,e*.25,[1047,1319],"sine",.12,.01,.4)}],vl={spawn:X1,"zone-change":Z1,"tool-use":K1,idle:Q1,shutdown:J1,"input-needed":tb},br={spawn:"chime","zone-change":"blip","tool-use":"tap",idle:"descend",shutdown:"farewell","input-needed":"doorbell"},_r=class _r{constructor(){b(this,"ctx",null);b(this,"_volume",.3);b(this,"_muted",!1);b(this,"initialized",!1);b(this,"lastToolUseTime",0);b(this,"_enabledEvents",{spawn:!0,"zone-change":!0,"tool-use":!0,idle:!0,shutdown:!0,"input-needed":!0});b(this,"_voices",{...br})}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}setEnabledEvents(t){this._enabledEvents={...t}}setVoices(t){this._voices={...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}getVoice(t){const e=this._voices[t],s=vl[t];return s.find(n=>n.id===e)??s[0]}play(t){if(this._muted||this._volume===0||!this._enabledEvents[t])return;if(t==="tool-use"){const n=performance.now();if(n-this.lastToolUseTime<_r.TOOL_USE_COOLDOWN)return;this.lastToolUseTime=n}const e=this.ensureContext();if(!e)return;const s=this.getVoice(t);s==null||s.play(e,e.currentTime,this.gain())}preview(t,e){const s=this.ensureContext();if(!s)return;const n=vl[t],o=n.find(l=>l.id===e)??n[0],r=this._volume>0?this._volume:.3;o==null||o.play(s,s.currentTime,r)}};b(_r,"TOOL_USE_COOLDOWN",300);let _l=_r;class eb{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 Un=300,sb=2,ib=3,nb=8;class ob{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<Un;l++){const c=(this.currentBucketIndex-l+Un)%Un,d=Math.exp(-c/60);o+=n.buckets[l]*d}const r=Math.min(1,o/(nb*15));n.heat+=(r-n.heat)*Math.min(1,sb*e),n.pulsePhase+=ib*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(Un).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)%Un;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,c=n.width*s,d=n.height*s;o.overlay.style.left=`${r}px`,o.overlay.style.top=`${l}px`,o.overlay.style.width=`${c}px`,o.overlay.style.height=`${d}px`,o.overlay.width=Math.ceil(c),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,c=t.heat*.18*l,d=Math.floor(Vn(30,255,t.heat)),h=Math.floor(Vn(60,t.heat<.5?Vn(80,160,t.heat*2):Vn(160,50,(t.heat-.5)*2),t.heat)),p=Math.floor(Vn(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},${h},${p},${c})`),y.addColorStop(.6,`rgba(${d},${h},${p},${c*.5})`),y.addColorStop(1,`rgba(${d},${h},${p},0)`),s.fillStyle=y,s.fillRect(0,0,o,r),t.heat>.3){const _=(t.heat-.3)*.4*l;s.strokeStyle=`rgba(${d},${h},${p},${_})`,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 rb(i,t,e){return Math.min(Math.max(i,t),e)}function Vn(i,t,e){return i+(t-i)*rb(e,0,1)}class ab{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>↑↓</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")}),this.actions.push({id:"feature:settings",label:"Open Settings",description:"Sound, notifications, cost alerts, display (S)",icon:"⚙",category:"feature",action:()=>this.onCommand("toggle-settings")})}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=Xt.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">${$t(t.label)}</div>
|
|
440
|
-
<div class="cmd-item-desc">${$t(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 lb=6e4,Ia=2e3,cb=180;class hb{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(),Ia),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}setCostThreshold(t){this.costThreshold=t,this.thresholdAlerted=!1}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+Ia/1e3)}this.tokenSamples.push({timestamp:Date.now(),totalTokens:e}),this.tokenSamples.length>cb&&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 Ar({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()-lb,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(),c=this.getVelocityTrend(),d=c==="up"?"↑":c==="down"?"↓":"→",h=c==="up"?"#f87171":c==="down"?"#4ade80":"#888",p=s+o+r,g=p>0?o/p*100:0,m=t.reduce((k,E)=>{const B=Iu(E.model);return k+E.cacheReadTokens/1e6*B.input*.9},0),y=[...t].sort((k,E)=>this.calculateCost(E)-this.calculateCost(k)),_=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">${_e(p)} in / ${_e(n)} out</div>
|
|
449
|
-
</div>
|
|
450
|
-
<div class="analytics-card velocity">
|
|
451
|
-
<div class="card-label">Token Velocity</div>
|
|
452
|
-
<div class="card-value">${_e(Math.round(l))}<span class="card-unit">/min</span></div>
|
|
453
|
-
<div class="card-sub" style="color:${h}">${d} ${c}</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">${_e(o)} read / ${_e(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*Ia/6e4)}min)</div>
|
|
470
|
-
<div class="sparkline-container">${_}</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=ut[t.colorIndex%ut.length],r=as(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">${$t(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=Xt.get(s),r=s==="idle",l=t>0?n/t*100:0,c=r?"#6b7280":o?as(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">${Mn(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:${c}"></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 h=1;h<s.length;h++)n.push(Math.max(0,s[h].totalTokens-s[h-1].totalTokens));if(n.length===0)return"";const o=Math.max(...n,1),r=t/Math.max(n.length-1,1),c=n.map((h,p)=>{const g=p*r,m=e-h/o*(e-4)-2;return`${g.toFixed(1)},${m.toFixed(1)}`}).map((h,p)=>p===0?`M${h}`:`L${h}`).join(" "),d=`${c} 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="${c}" 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 c=n>0?l/n*100:0,d=r.startsWith("mcp__")?"#60a5fa":"#a78bfa";let h=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];h=`${g} / ${m}`}}return`<div class="tool-bar">
|
|
533
|
-
<div class="tool-bar-label">
|
|
534
|
-
<span class="tool-bar-name" title="${$t(r)}">${$t(h)}</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,c)}%;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((h,p)=>h+p,0),n=s>0?e/s:0,o=t.reduce((h,p)=>h+p.inputTokens+p.outputTokens+p.cacheReadTokens+p.cacheCreationTokens,0),r=s>0?o/s:0,l=Date.now(),c=t.map(h=>{const p=Math.max((l-h.spawnedAt)/6e4,.5),g=this.calculateCost(h);return{name:h.name,rate:g/p,cost:g}}).filter(h=>h.cost>.001).sort((h,p)=>p.rate-h.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">${_e(Math.round(r))}</div>
|
|
550
|
-
<div class="card-sub">${_e(o)} total</div>
|
|
551
|
-
</div>
|
|
552
|
-
</div>
|
|
553
|
-
${c.length>0?'<div class="cost-rate-header">Cost rate ($/min)</div>'+c.slice(0,5).map(h=>`<div class="cost-rate-row">
|
|
554
|
-
<span class="cost-rate-name">${$t(h.name)}</span>
|
|
555
|
-
<span class="cost-rate-value">$${h.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=ut[s.colorIndex%ut.length];return`<div class="session-row">
|
|
558
|
-
<span class="agent-dot" style="background:${as(o.body)}"></span>
|
|
559
|
-
<span class="session-name">${$t(s.name)}</span>
|
|
560
|
-
<span class="session-duration">${Mn(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 db="agent-move-layout",Wh=200;new Map(se.map(i=>[i.id,{x:i.x,y:i.y,width:i.width,height:i.height}]));function ub(){try{const i=localStorage.getItem(db);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=Xt.get(e);n&&(n.x=s.x,n.y=s.y,n.width=Math.max(Wh,s.width),n.height=Math.max(Wh,s.height))}}catch{}}const fb=6e4,pb=2e3;class mb{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(),pb)}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()-fb,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(h=>!h.isIdle&&!h.isDone).length,s=t.filter(h=>h.isIdle||h.isDone).length;let n=0;for(const h of t)n+=Ar(h);const o=this.getVelocity(),r=(h,p)=>{const g=document.querySelector(`#${h} .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",_e(Math.round(o)));const l=document.querySelector("#tb-active .tb-stat-dot");l&&l.classList.toggle("pulse",e>0);const c=this.store.getPendingPermissions().length,d=this.store.isHooksActive();this.hooksDot.classList.toggle("hooks-pending",c>0),this.hooksDot.classList.toggle("hooks-active",d&&c===0),c>0?this.hooksDot.title=`Hooks: ${c} permission${c>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 gb{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 yb=4500,bb=5,xr=class xr{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=ut[t.colorIndex%ut.length];return as(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>${$t(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>${$t(e)}</strong> finished`,"done")}}onShutdown(t){const e=this.store.getAgent(t),s=e?this.getName(e):t.slice(0,10);this.show(`<strong>${$t(s)}</strong> shut down`,"shutdown")}onTaskCompleted(t){this.show(`✓ Task completed: <strong>${$t(t)}</strong>`,"done")}onAnomaly(t){const e=xr.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>${$t(o)}</strong>: ${$t(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),yb);for(this.toasts.push({el:s,timer:n});this.toasts.length>bb;){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(xr,"ANOMALY_ICONS",{"retry-loop":"🔁","token-spike":"📈","stuck-agent":"⏳"});let xl=xr;const vb=[{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"},{keys:"S",description:"Open settings panel"}]}];class _b{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">×</button>
|
|
568
|
-
</div>
|
|
569
|
-
<div class="sh-body">
|
|
570
|
-
${vb.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 xb{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">×</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(_=>_.spawnedAt)):e,n=e-s;let o=0,r=0,l=0,c=0;const d=[];for(const _ of t){const w=Ar(_);o+=w,r+=_.totalInputTokens,l+=_.totalOutputTokens,c+=_.cacheReadTokens;const k=Xt.get(_.currentZone);d.push({name:((m=(g=this._customizationLookup)==null?void 0:g.call(this,_))==null?void 0:m.displayName)||_.agentName||_.projectName||_.sessionId.slice(0,10),cost:w,tokens:_.totalInputTokens+_.totalOutputTokens,duration:e-_.spawnedAt,role:_.role,zone:(k==null?void 0:k.label)??_.currentZone,status:_.isDone?"Done":_.isIdle?"Idle":"Active"})}d.sort((_,w)=>w.cost-_.cost);const h=[];if(h.push("# AgentMove Session Summary"),h.push(`> Generated ${new Date().toISOString()}`),h.push(""),h.push("## Overview"),h.push("| Metric | Value |"),h.push("|--------|-------|"),h.push(`| Duration | ${Mn(n)} |`),h.push(`| Total Agents | ${t.length} |`),h.push(`| Active | ${t.filter(_=>!_.isIdle&&!_.isDone).length} |`),h.push(`| Idle | ${t.filter(_=>_.isIdle&&!_.isDone).length} |`),h.push(`| Done | ${t.filter(_=>_.isDone).length} |`),h.push(`| Total Cost | $${o.toFixed(4)} |`),h.push(`| Input Tokens | ${_e(r)} |`),h.push(`| Output Tokens | ${_e(l)} |`),h.push(`| Cache Reads | ${_e(c)} |`),h.push(""),d.length>0){h.push("## Agents"),h.push("| Agent | Role | Status | Zone | Cost | Tokens | Duration |"),h.push("|-------|------|--------|------|------|--------|----------|");for(const _ of d)h.push(`| ${_.name} | ${_.role} | ${_.status} | ${_.zone} | $${_.cost.toFixed(4)} | ${_e(_.tokens)} | ${Mn(_.duration)} |`);h.push("")}const p=new Map;for(const _ of t){const w=((y=Xt.get(_.currentZone))==null?void 0:y.label)??_.currentZone;p.set(w,(p.get(w)??0)+1)}if(p.size>0){h.push("## Zone Distribution"),h.push("| Zone | Agents |"),h.push("|------|--------|");for(const[_,w]of Array.from(p.entries()).sort((k,E)=>E[1]-k[1]))h.push(`| ${_} | ${w} |`);h.push("")}return h.push("---"),h.push("*Generated by AgentMove*"),h.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 Oh="agent-move:onboarding-dismissed";class wb{constructor(){b(this,"el",null);this.isDismissed()||this.show()}isDismissed(){try{return localStorage.getItem(Oh)==="1"}catch{return!1}}dismiss(){try{localStorage.setItem(Oh,"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">×</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">💻</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">⌨</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">🔍</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">📊</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 Hu="agent-move:";function Mr(i,t){try{const e=localStorage.getItem(Hu+i);return e===null?t:JSON.parse(e)}catch{return t}}function En(i,t){try{localStorage.setItem(Hu+i,JSON.stringify(t))}catch{}}const Sb=200,Hh=5,kb=20,Uh=4e3,Tb=2;class Cb{constructor(){b(this,"container",new zt);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<Sb)return;this.timers.set(t,0);let l=this.trails.get(t);l||(l=[],this.trails.set(t,l));const c=l[l.length-1];if(c){const d=e-c.x,h=s-c.y;if(d*d+h*h<Hh*Hh)return}l.push({x:e,y:s,age:0}),l.length>kb&&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>=Uh)n.splice(r,1);else{const l=.4*(1-n[r].age/Uh);this.graphics.circle(n[r].x,n[r].y,Tb).fill({color:o,alpha:l}),r++}n.length===0&&this.trails.delete(s)}}}}const qn=200,Yn=150;class Ab{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=qn/Math.max(1,il),this.scaleY=Yn/Math.max(1,nl),this.canvas=document.createElement("canvas");const s=window.devicePixelRatio||1;this.canvas.width=qn*s,this.canvas.height=Yn*s,this.canvas.id="minimap",this.canvas.style.cssText=`
|
|
642
|
-
position: fixed; bottom: 12px; right: 12px;
|
|
643
|
-
width: ${qn}px; height: ${Yn}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,c=r/this.scaleX,d=l/this.scaleY;e(c,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=qn/Math.max(1,il),this.scaleY=Yn/Math.max(1,nl);const s=this.ctx;s.clearRect(0,0,qn,Yn),s.imageSmoothingEnabled=!1;for(const c of se){const d=c.x*this.scaleX,h=c.y*this.scaleY,p=c.width*this.scaleX,g=c.height*this.scaleY;s.fillStyle="#"+c.color.toString(16).padStart(6,"0")+"30",s.strokeStyle="#"+c.color.toString(16).padStart(6,"0")+"60",s.lineWidth=.5,s.fillRect(d,h,p,g),s.strokeRect(d,h,p,g),s.save(),s.fillStyle="#"+c.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(c.label,d+p/2,h+g/2,p-4),s.restore()}for(const c of t){const d=ut[c.colorIndex%ut.length];s.fillStyle="#"+d.body.toString(16).padStart(6,"0"),s.beginPath(),s.arc(c.x*this.scaleX,c.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 Mb=["🥇","🥈","🥉"];class Eb{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 Ar(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,c=r>6e4?l/(r/6e4):l;return{...n,cost:o,duration:r,velocity:c}});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="#"+ut[l%ut.length].body.toString(16).padStart(6,"0"),h=(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?Mb[o]:`${o+1}`}</td>
|
|
663
|
-
<td class="lb-name"><span class="lb-dot" style="background:${d}"></span>${$t(h)}</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">${_e(p)}</span>
|
|
668
|
-
</div>
|
|
669
|
-
</td>
|
|
670
|
-
<td>$${n.cost.toFixed(2)}</td>
|
|
671
|
-
<td>${Mn(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 La="agent-customizations";class Pb{constructor(){b(this,"el");b(this,"customizations");b(this,"currentAgent",null);b(this,"onChange",null);this.customizations=Mr(La,{}),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">×</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");ut.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||mo(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,En(La,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],En(La,this.customizations),(t=this.onChange)==null||t.call(this,this.currentAgent.id,{}),this.close())}dispose(){this.el.remove()}}const ds=(i,t,e,s,n)=>{i.roundRect(t,e,s,n,4).fill({color:3355460,alpha:.15})},Ib=14995640,Lb=14469296,Bb=14207152,qo=13154464,Yo=12114072,Rb=11061384,Fe=4,K=i=>i*Fe;function vt(i,t,e,s,n,o){i.rect(t,e,s,n).fill(o)}function $b(i,t,e){const s=K(7),n=s/2;vt(i,t-2,e+n-K(2),Fe+1,K(2),9067056),vt(i,t-2,e+n-K(2),2,K(2),8014368),vt(i,t-n+K(2),e-n,s-K(4),K(1),2779690),vt(i,t-n+K(2),e+n-K(1),s-K(4),K(1),2779690),vt(i,t-n,e-n+K(2),K(1),s-K(4),2779690),vt(i,t+n-K(1),e-n+K(2),K(1),s-K(4),2779690),vt(i,t-n+K(1),e-n+K(1),s-K(2),s-K(2),3836474),vt(i,t-n+K(2),e-n+K(2),s-K(4),s-K(4),4893258),vt(i,t-K(2),e-n+K(1),K(3),K(2),6736998),vt(i,t-K(1),e-n,K(2),K(1),8973960)}function Db(i,t,e){vt(i,t-1,e+K(1),3,K(2),9067056),vt(i,t-K(2),e-K(1),K(4),K(2),2783786),vt(i,t-K(1),e-K(2),K(2),K(4),2783786),vt(i,t-K(2)+Fe,e-K(2)+Fe,K(2),K(2),3836474),vt(i,t-K(1),e-K(1),K(2),K(2),4893258),vt(i,t-Fe,e-K(2),Fe,Fe,6736998)}function zb(i,t,e){vt(i,t-1,e+K(2),3,K(2),6965792),vt(i,t-K(1),e-K(3),K(2),K(5),1731098),vt(i,t-K(2),e-K(2),K(4),K(3),2783786),vt(i,t-K(1),e-K(2),K(2),K(3),3836474),vt(i,t-Fe,e-K(2),Fe,K(2),4889162),vt(i,t-1,e-K(3),3,Fe,5941850)}const Vh=[$b,Db,zb];function jo(i,t,e,s){Vh[s%Vh.length](i,t,e)}function Fb(i,t,e){vt(i,t-K(2),e-K(1),K(4),K(2),3836474),vt(i,t-K(1),e-K(2),K(2),K(4),3836474),vt(i,t-K(1),e-K(1),K(2),K(2),5941850),vt(i,t,e-K(2),Fe,Fe,6736964)}function Nb(i,t,e){vt(i,0,0,t,e,Ib);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&&vt(i,y,m,s,s,Lb);const n=K(8);vt(i,0,0,t,n,Yo),vt(i,0,e-n,t,n,Yo),vt(i,0,0,n,e,Yo),vt(i,t-n,0,n,e,Yo);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&&vt(i,y,m,o,o,Rb);let r=0,l=0,c=0,d=0;if(se.length>0){r=Math.min(...se.map(y=>y.x)),l=Math.min(...se.map(y=>y.y)),c=Math.max(...se.map(y=>y.x+y.width)),d=Math.max(...se.map(y=>y.y+y.height));const m=12;vt(i,r-m,l-m,c-r+m*2,d-l+m*2,Bb),vt(i,r-m,l-m,c-r+m*2,2,qo),vt(i,r-m,d+m-2,c-r+m*2,2,qo),vt(i,r-m,l-m,2,d-l+m*2,qo),vt(i,c+m-2,l-m,2,d-l+m*2,qo),vt(i,r,l,c-r,d-l,15260872)}const h=K(4),p=K(24);let g=0;for(let m=h;m<t-h;m+=p)jo(i,m,h,g++);for(let m=h+K(12);m<t-h;m+=p)jo(i,m,e-h,g++);for(let m=h+p;m<e-h;m+=p)jo(i,h,m,g++);for(let m=h+K(12);m<e-h;m+=p)jo(i,t-h,m,g++);if(se.length>0)for(let m=r+K(10);m<c-K(8);m+=K(18))Fb(i,m,d+16)}const Uu={id:"office",name:"Office",icon:"🏢",colors:{background:14995640,gridLine:14206124,gridLineSub:13416608},decorators:{search:Ye.search??ds,terminal:Ye.terminal??ds,web:Ye.web??ds,files:Ye.files??ds,thinking:Ye.thinking??ds,messaging:Ye.messaging??ds,spawn:Ye.spawn??ds,idle:Ye.idle??ds,tasks:Ye.tasks??ds},gridRenderer:Nb,pixelRooms:!0},Gb=4,z=i=>i*Gb,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 _t(i,t,e,s,n,o){i.rect(t,e,s,n).fill(o)}function us(i,t,e,s,n){_t(i,t,e,s,n,gt.floor);for(let o=0;o<n;o+=z(4))_t(i,t,e+o,s,1,gt.floorLine);for(let o=0;o<s;o+=z(8))_t(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))_t(i,t+r,e+o,z(1),z(1),gt.floorAlt)}function un(i,t,e,s){_t(i,t,e,s,z(10),gt.panel),_t(i,t,e,s,z(1),gt.panelLight),_t(i,t+z(2),e+z(2),s-z(4),z(4),gt.screen),_t(i,t+z(3),e+z(3),s-z(6),z(1),gt.screenGlow);for(let n=0;n<3;n++)_t(i,t+z(2)+n*z(3),e+z(7),z(2),z(2),gt.ledBlue)}function Ba(i,t,e){_t(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);_t(i,t-n/2,e-z(2)-s*z(2),n,z(1),gt.holo)}_t(i,t-z(1),e-z(4),z(2),z(2),gt.holoBright)}const Wb={search:(i,t,e,s,n)=>{us(i,t,e,s,n),un(i,t+z(4),e+z(7),z(20)),un(i,t+z(28),e+z(7),z(20)),Ba(i,t+s/2,e+n/2)},terminal:(i,t,e,s,n)=>{us(i,t,e,s,n);for(let o=0;o<3;o++){_t(i,t+z(2)+o*z(10),e+z(7),z(7),z(14),gt.hull);for(let r=0;r<4;r++)_t(i,t+z(3)+o*z(10),e+z(8)+r*z(3),z(5),z(2),gt.panelDark),_t(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)=>{us(i,t,e,s,n),_t(i,t+z(4),e+z(7),z(20),z(14),gt.panelDark),_t(i,t+z(5),e+z(8),z(18),z(12),gt.screen),_t(i,t+z(8),e+z(11),z(12),z(6),gt.holo),Ba(i,t+z(40),e+z(30))},files:(i,t,e,s,n)=>{us(i,t,e,s,n);for(let o=0;o<4;o++)_t(i,t+z(2)+o*z(7),e+z(7),z(5),z(10),gt.metalDark),_t(i,t+z(3)+o*z(7),e+z(8),z(3),z(3),gt.metal),_t(i,t+z(3)+o*z(7),e+z(12),z(3),z(3),gt.metal);un(i,t+z(24),e+z(25),z(14))},thinking:(i,t,e,s,n)=>{us(i,t,e,s,n),Ba(i,t+s/2,e+n/2),_t(i,t+s/2-z(9),e+n/2+z(2),z(18),z(1),gt.metalDark),un(i,t+z(4),e+z(7),z(24)),un(i,t+z(32),e+z(7),z(20))},messaging:(i,t,e,s,n)=>{us(i,t,e,s,n),_t(i,t+z(4),e+z(21),z(16),z(8),gt.hull),_t(i,t+z(5),e+z(22),z(14),z(6),gt.hullLight),un(i,t+z(4),e+z(7),z(14))},spawn:(i,t,e,s,n)=>{us(i,t,e,s,n);const o=t+s/2,r=e+n/2;_t(i,o-z(6),r-z(6),z(12),z(12),gt.panelDark),_t(i,o-z(4),r-z(4),z(8),z(8),gt.holo),_t(i,o-z(2),r-z(2),z(4),z(4),gt.holoBright),_t(i,o-z(8),r-z(1),z(16),z(2),gt.airlockEdge),_t(i,o-z(1),r-z(8),z(2),z(16),gt.airlockEdge)},idle:(i,t,e,s,n)=>{us(i,t,e,s,n),_t(i,t+z(2),e+z(7),z(28),z(5),gt.hull),_t(i,t+z(3),e+z(8),z(26),z(3),gt.hullLight),_t(i,t+z(4),e+z(9),z(2),z(1),gt.screenGlow),_t(i,t+z(32),e+z(7),z(6),z(14),gt.metalDark);for(let o=0;o<3;o++)_t(i,t+z(33),e+z(8)+o*z(4),z(4),z(3),gt.screen)},tasks:(i,t,e,s,n)=>{us(i,t,e,s,n),_t(i,t+z(2),e+z(7),z(30),z(18),gt.panel),_t(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),c=t+z(4)+r*(l+z(1));_t(i,c,e+z(9),l,z(2),o[r]);for(let d=0;d<3-r;d++)_t(i,c+2,e+z(12)+d*z(3),l-4,z(2),gt.holo)}}},Ob={id:"space",name:"Space Station",icon:"🚀",colors:{background:657944,gridLine:1381672,gridLineSub:1052704},decorators:Wb},Hb=4,R=i=>i*Hb,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 fs(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 Xo(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 gi(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 Ub={search:(i,t,e,s,n)=>{fs(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)),gi(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)=>{fs(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)),Xo(i,t+R(4),e+R(28),R(8),R(12))},web:(i,t,e,s,n)=>{fs(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)),gi(i,t+R(4),e+R(27),R(14),R(5))},files:(i,t,e,s,n)=>{fs(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);gi(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)=>{fs(i,t,e,s,n),Pt(i,t+R(8),e+n/2-R(8),R(10),R(4),Et.rugEdge),gi(i,t+s/2-R(9),e+n/2-R(4),R(18),R(8)),Xo(i,t+R(4),e+R(7),R(10),R(14)),Xo(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)=>{fs(i,t,e,s,n),Xo(i,t+R(8),e+R(7),R(14),R(10)),gi(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)=>{fs(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)=>{fs(i,t,e,s,n),gi(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),gi(i,t+R(14),e+R(30),R(10),R(10)),gi(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)=>{fs(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))}},Vb={id:"castle",name:"Medieval Castle",icon:"🏰",colors:{background:1710096,gridLine:2762784,gridLineSub:2104856},decorators:Ub},qb=4,U=i=>i*qb,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 ps(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 yi(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 jn(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 ms(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 Yb={search:(i,t,e,s,n)=>{ps(i,t,e,s,n),yi(i,t+U(4),e+U(7),U(20),U(12),pt.neonPink),yi(i,t+U(28),e+U(7),U(20),U(12),pt.neonBlue),jn(i,t+U(4),e+U(26),U(44),pt.neonPurple),ms(i,t,e,s,n)},terminal:(i,t,e,s,n)=>{ps(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)}ms(i,t,e,s,n)},web:(i,t,e,s,n)=>{ps(i,t,e,s,n),yi(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),jn(i,t+U(30),e+U(20),U(10),pt.neonPink),ms(i,t,e,s,n)},files:(i,t,e,s,n)=>{ps(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);yi(i,t+U(24),e+U(25),U(14),U(8),pt.neonGreen),ms(i,t,e,s,n)},thinking:(i,t,e,s,n)=>{ps(i,t,e,s,n),yi(i,t+U(4),e+U(7),U(24),U(12),pt.neonPurple),yi(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),jn(i,t+U(4),e+n-U(4),U(40),pt.neonPink),ms(i,t,e,s,n)},messaging:(i,t,e,s,n)=>{ps(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),yi(i,t+U(4),e+U(7),U(14),U(8),pt.neonYellow),jn(i,t+U(22),e+U(18),U(8),pt.neonGreen),ms(i,t,e,s,n)},spawn:(i,t,e,s,n)=>{ps(i,t,e,s,n);const o=t+s/2,r=e+n/2;for(let l=0;l<3;l++){const c=U(3)+l*U(3);kt(i,o-c,r-c,c*2,1,pt.neonPurple),kt(i,o-c,r+c,c*2,1,pt.neonPurple),kt(i,o-c,r-c,1,c*2,pt.neonBlue),kt(i,o+c,r-c,1,c*2,pt.neonBlue)}kt(i,o-U(1),r-U(1),U(2),U(2),pt.neonGreen),ms(i,t,e,s,n)},idle:(i,t,e,s,n)=>{ps(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),jn(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),ms(i,t,e,s,n)},tasks:(i,t,e,s,n)=>{ps(i,t,e,s,n),yi(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),c=t+U(4)+r*(l+U(1));kt(i,c,e+U(9),l,U(2),o[r]);for(let d=0;d<3-r;d++)kt(i,c+2,e+U(12)+d*U(3),l-4,U(2),pt.panel)}ms(i,t,e,s,n)}},jb={id:"cyberpunk",name:"Cyberpunk",icon:"🌃",colors:{background:657424,gridLine:1708072,gridLineSub:1051162},decorators:Yb},qh="theme",Xn=[Uu,Ob,Vb,jb];class Xb{constructor(){b(this,"_current");b(this,"_onChange",null);const t=Mr(qh,"office");this._current=Xn.find(e=>e.id===t)??Uu}get current(){return this._current}setTheme(t){var s;const e=Xn.find(n=>n.id===t);!e||e.id===this._current.id||(this._current=e,En(qh,e.id),(s=this._onChange)==null||s.call(this,e))}onChange(t){this._onChange=t}cycleNext(){const t=Xn.indexOf(this._current),e=Xn[(t+1)%Xn.length];this.setTheme(e.id)}}const Yh="zone-annotations";let Ra=0;class Zb{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(Yh);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>=Ra&&(Ra=n+1)}}}catch{}}save(){localStorage.setItem(Yh,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">×</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=Xt.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=Xt.get(e.zoneId);if(!l)return;const c=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",h,{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)},h=()=>{t.removeEventListener("pointermove",d),this.save()};t.addEventListener("pointerdown",c)}addAnnotationAtWorld(t,e){for(const s of se){const n=Xt.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=Xt.get(t);if(!n)return;const o=n.x+e*n.width,r=n.y+s*n.height,l=o*this.scale+this.rootX,c=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,${c}px);z-index:20;`,d.placeholder="Type a note...",d.rows=2,this.container.appendChild(d),d.focus();const h=()=>{const p=d.value.trim();if(d.remove(),p){const g=`ann-${Ra++}`,m={id:g,text:p,relX:e,relY:s,zoneId:t};this.annotations.set(g,m),this.createNoteEl(m),this.save()}};d.addEventListener("blur",h,{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,"&").replace(/</g,"<").replace(/>/g,">")}}class Kb{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]),c=((w=l[0])==null?void 0:w[1])??1,d=l.reduce((k,[,E])=>k+E,0),h=this.selectedTool?t.filter(k=>k.from===this.selectedTool||k.to===this.selectedTool):t,p=Math.max(...h.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/c*100,L=k===this.selectedTool,H=(s==null?void 0:s[k])??0,$=(n==null?void 0:n[k])??0,G=H+$,et=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 j=G>0?$/G*B:0;m+=`<div class="tc-tool-bar tc-fail-bar" style="width:${j}%"></div>`}m+="</div>",m+=`<span class="tc-tool-count">${E}</span>`,g&&G>0&&et>0?m+=`<span class="tc-outcome tc-outcome-fail" title="${$} failed">${Math.round(et*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=[...h].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 _=this.container.querySelector(".tc-clear-filter");_&&_.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,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}}const Zo={pending:"#a78bfa",in_progress:"#38bdf8",completed:"#4ade80",deleted:"#f87171"},Ko={pending:"○",in_progress:"◔",completed:"✓",deleted:"✕"},bi=210,Zn=56,Qb=50,Kn=12,Qo=16;class Jb{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(h=>h.status!=="deleted");if(t.length===0){this.container.innerHTML='<div class="tg-empty">No tasks created yet</div>';return}const e=h=>h._rootKey??h.id,s=new Map(t.map(h=>[e(h),h])),n=new Set;for(const h of t){const p=h.blockedBy.some(m=>s.has(m)),g=h.blocks.some(m=>s.has(m));if(p||g){n.add(e(h));for(const m of h.blockedBy)s.has(m)&&n.add(m);for(const m of h.blocks)s.has(m)&&n.add(m)}}const o=t.filter(h=>!n.has(e(h))),r=t.filter(h=>n.has(e(h))),l={in_progress:0,pending:1,completed:2,deleted:3};o.sort((h,p)=>{const g=(l[h.status]??9)-(l[p.status]??9);return g!==0?g:parseInt(h.id)-parseInt(p.id)});const c={pending:0,in_progress:0,completed:0};for(const h of t)h.status in c&&c[h.status]++;let d="";if(d+='<div class="tg-summary">',c.in_progress>0&&(d+=`<span class="tg-badge tg-badge-active">${c.in_progress} active</span>`),c.pending>0&&(d+=`<span class="tg-badge tg-badge-pending">${c.pending} pending</span>`),c.completed>0&&(d+=`<span class="tg-badge tg-badge-done">${c.completed} done</span>`),d+=`<span class="tg-total">${t.length} total</span>`,d+="</div>",o.length>0){d+='<div class="tg-standalone">';for(const h of o){const p=Zo[h.status]??Zo.pending,g=Ko[h.status]??Ko.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">${vi(h.subject)}</span>`,d+=this.renderRowTags(h),d+=`<span class="tg-row-id">#${vi(h.id)}</span>`,d+="</div>"}d+="</div>"}if(r.length>0){const h=this.findClusters(r,s,e);for(const p of h)d+=this.renderCluster(p,s,e)}this.container.innerHTML=d}renderCluster(t,e,s){const n=new Map(t.map(h=>[s(h),h])),o=this.layoutCluster(t,n,s),r=new Map(o.map(h=>[s(h.task),h])),l=Math.max(...o.map(h=>h.x+bi))+Qo,c=Math.max(...o.map(h=>h.y+Zn))+Qo;let d='<div class="tg-cluster">';d+=`<svg class="tg-svg" width="${l}" height="${c}" viewBox="0 0 ${l} ${c}">`,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 h of o)for(const p of h.task.blockedBy){const g=r.get(p);if(!g)continue;const m=g.x+bi/2,y=g.y+Zn,_=h.x+bi/2,w=h.y,k=Math.max((w-y)*.4,12);d+=`<path class="tg-edge" d="M${m},${y} C${m},${y+k} ${_},${w-k} ${_},${w}" marker-end="url(#tg-arr)"/>`}for(const h of o){const p=h.task,g=Zo[p.status]??Zo.pending,m=Ko[p.status]??Ko.pending;d+='<g class="tg-node">',d+=`<rect x="${h.x}" y="${h.y}" width="${bi}" height="${Zn}" rx="5" class="tg-node-bg"/>`,d+=`<rect x="${h.x}" y="${h.y}" width="3" height="${Zn}" rx="1" fill="${g}"/>`,d+=`<text x="${h.x+12}" y="${h.y+18}" class="tg-node-icon" fill="${g}">${m}</text>`,d+=`<text x="${h.x+bi-7}" y="${h.y+16}" class="tg-node-id" text-anchor="end">#${vi(p.id)}</text>`,d+=`<text x="${h.x+25}" y="${h.y+18}" class="tg-node-subj">${vi(Xh(p.subject,24))}</text>`;const y=this.nodeInfoText(p);y&&(d+=`<text x="${h.x+12}" y="${h.y+38}" class="tg-node-info">${vi(Xh(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 c=s(l);if(o.has(c))continue;const d=[],h=[c];for(o.add(c);h.length>0;){const p=h.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),h.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 _=0;for(const k of y.blockedBy)e.has(k)&&(_=Math.max(_,o(k,m)));const w=_+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 c={in_progress:0,pending:1,completed:2,deleted:3};for(const g of l)g.sort((m,y)=>{const _=(c[m.status]??9)-(c[y.status]??9);return _!==0?_:parseInt(m.id)-parseInt(y.id)});for(let g=1;g<l.length;g++){const m=new Map;l[g-1].forEach((y,_)=>m.set(s(y),_)),l[g].sort((y,_)=>jh(y,m)-jh(_,m))}const h=Math.max(...l.map(g=>g.length))*(bi+Kn)-Kn,p=[];for(let g=0;g<l.length;g++){const m=l[g],y=m.length*(bi+Kn)-Kn,_=Qo+(h-y)/2,w=Qo+g*(Zn+Qb);for(let k=0;k<m.length;k++)p.push({task:m[k],x:_+k*(bi+Kn),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">${vi(t.projectName)}</span>`),t.agentName&&t.agentName!==t.projectName&&(e+=`<span class="tg-row-tag">${vi(t.agentName)}</span>`),t.owner&&t.owner!==t.agentName&&(e+=`<span class="tg-row-tag">${vi(t.owner)}</span>`),e}}function jh(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 vi(i){return i.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Xh(i,t){return i.length>t?i.slice(0,t-1)+"…":i}class tv{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)"),c=r==null?void 0:r.querySelector(".perm-feedback");l!=null&&l.value?this.store.approvePermission(o,{answer:l.value}):c!=null&&c.value?this.store.approvePermission(o,{userFeedback:c.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),c=(l==null?void 0:l.permissionSuggestions)??[];this.store.approvePermissionAlways(o,c)}})})}esc(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}dispose(){this.store.off("permission:request",this.onPermRequestBound),this.store.off("permission:resolved",this.onPermResolvedBound),this.container.remove()}}const ev=50;let sv=0;class iv{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${++sv}`,...t,timestamp:Date.now()};this.notifications.unshift(e),this.notifications.length>ev&&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,"&").replace(/</g,"<").replace(/>/g,">")}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 Zh=200,nv=["all","spawn","tool","idle","shutdown","permission","anomaly","task"],ov=200;class rv{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 nv){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>Zh&&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>Zh;)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()},ov)}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,"&").replace(/</g,"<").replace(/>/g,">")}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 Kh={files:"#34d399",terminal:"#fb923c",search:"#60a5fa",web:"#f59e0b",thinking:"#a78bfa",messaging:"#38bdf8",tasks:"#f472b6",idle:"#6b7280",spawn:"#6b7280"},Qh=500,gs=28,Qn=2,ze=32,de=120,av=300*1e3,lv=1e4,cv=30*6e4;class hv{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",av);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(lv,Math.min(cv,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>Qh&&this.spans.splice(0,this.spans.length-Qh)}updateCanvasSize(){const t=this.container.clientWidth,e=Math.max(this.agentLanes.length,1),s=ze+e*(gs+Qn)+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=ze+s*(gs+Qn)+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,ze),t.strokeStyle="#374151",t.lineWidth=1,t.beginPath(),t.moveTo(0,ze),t.lineTo(e,ze),t.stroke();const l=this.pickGridInterval(),c=Math.ceil(o/l)*l;t.font="10px monospace",t.textAlign="center",t.textBaseline="middle";for(let d=c;d<=this.viewEndTime;d+=l){const h=de+(d-o)/this.viewWindowMs*r;t.strokeStyle="#1f2937",t.beginPath(),t.moveTo(h,ze),t.lineTo(h,n),t.stroke(),t.fillStyle="#9ca3af",t.fillText(this.formatTime(d),h,ze/2)}t.textAlign="right",t.textBaseline="middle",t.font="11px sans-serif";for(let d=0;d<this.agentLanes.length;d++){const h=this.agentLanes[d],p=this.agentNames.get(h)??h.slice(0,8),g=ze+d*(gs+Qn);t.fillStyle=d%2===0?"#111827":"#0f172a",t.fillRect(0,g,e,gs);const m=this.store.getAgent(h),y=m?ut[m.colorIndex%ut.length]:null;t.fillStyle=y?`#${y.body.toString(16).padStart(6,"0")}`:"#9ca3af";const _=p.length>14?p.slice(0,12)+"..":p;t.fillText(_,de-8,g+gs/2)}t.strokeStyle="#374151",t.beginPath(),t.moveTo(de,0),t.lineTo(de,n),t.stroke();for(const d of this.spans){const h=d.endTime??Date.now();if(h<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(h,this.viewEndTime),y=de+(g-o)/this.viewWindowMs*r,_=de+(m-o)/this.viewWindowMs*r,w=Math.max(_-y,2),k=ze+p*(gs+Qn)+3,E=gs-6,B=Kh[d.zone]??Kh.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,ze),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<ze)return null;const r=this.viewEndTime-this.viewWindowMs,l=this.container.clientWidth-de;for(let c=this.spans.length-1;c>=0;c--){const d=this.spans[c],h=d.endTime??Date.now();if(h<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(h,this.viewEndTime),y=de+(g-r)/this.viewWindowMs*l,_=de+(m-r)/this.viewWindowMs*l,w=Math.max(_-y,2),k=ze+p*(gs+Qn)+3,E=gs-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 _i=20,dv=25,uv=120,fv=4e3,pv=.005,Jh=.9,$a=3,td=.01,ed={running:"#4caf50",idle:"#9e9e9e",compacting:"#9c27b0"},mv={main:"MAIN",subagent:"SUB","team-lead":"LEAD"};function gv(i){return"#"+i.toString(16).padStart(6,"0")}function yv(i,t){return i.length>t?i.slice(0,t-1)+"…":i}class bv{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=dv;for(const l of this.nodes.values()){const c=l.x-s,d=l.y-n,h=Math.sqrt(c*c+d*d);h<r&&(r=h,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 c=l+1;c<t.length;c++){const d=t[l],h=t[c],p=h.x-d.x,g=h.y-d.y,m=Math.sqrt(p*p+g*g)||1,y=fv/(m*m),_=p/m*y,w=g/m*y;d.vx-=_,d.vy-=w,h.vx+=_,h.vy+=w}const r=new Set;for(const l of this.edges){const c=this.nodes.get(l.source),d=this.nodes.get(l.target);if(!c||!d)continue;r.add(l.source),r.add(l.target);const h=d.x-c.x,p=d.y-c.y,g=Math.sqrt(h*h+p*p)||1,m=g-uv,y=pv*m,_=h/g*y,w=p/g*y;c.vx+=_,c.vy+=w,d.vx-=_,d.vy-=w}for(const l of t)l.vx+=(n-l.x)*td,l.vy+=(o-l.y)*td;for(const l of t){l.vx*=Jh,l.vy*=Jh;const c=Math.sqrt(l.vx*l.vx+l.vy*l.vy);c>$a&&(l.vx=l.vx/c*$a,l.vy=l.vy/c*$a),l.x+=l.vx,l.y+=l.vy,l.x=Math.max(_i,Math.min(e-_i,l.x)),l.y=Math.max(_i+15,Math.min(s-_i-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 c=0;c<3;c++){const d=(l+c*.33)%1,h=o.x+(r.x-o.x)*d,p=o.y+(r.y-o.y)*d;s.beginPath(),s.arc(h,p,3,0,Math.PI*2),s.fillStyle="#ffcc80",s.fill()}}}for(const n of this.nodes.values()){const o=ut[n.colorIndex%ut.length],r=gv(o.body),l=ed[n.phase]??ed.idle;s.beginPath(),s.arc(n.x,n.y,_i+3,0,Math.PI*2),s.strokeStyle=l,s.lineWidth=3,s.stroke(),s.beginPath(),s.arc(n.x,n.y,_i,0,Math.PI*2),s.fillStyle=r,s.fill();const c=mv[n.role];c&&(s.font="9px monospace",s.textAlign="center",s.fillStyle="#aaa",s.fillText(c,n.x,n.y-_i-8)),s.font="11px sans-serif",s.textAlign="center",s.fillStyle="#ddd",s.fillText(yv(n.label,12),n.x,n.y+_i+14)}}}class vv{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(c=>c.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()}}const _v=["spawn","zone-change","tool-use","idle","shutdown","input-needed"],xv={spawn:"Agent Spawn","zone-change":"Zone Change","tool-use":"Tool Use",idle:"Agent Idle",shutdown:"Agent Shutdown","input-needed":"Input Needed"},fn={masterVolume:.3,muted:!1,soundEvents:{spawn:!0,"zone-change":!0,"tool-use":!0,idle:!0,shutdown:!0,"input-needed":!0},soundVoices:{...br},browserNotifications:!0,costThreshold:5,showTrails:!1,showHeatmap:!0,showAgentNames:!0},Da="settings";class wv{constructor(t){b(this,"contentEl");b(this,"containerEl");b(this,"isVisible",!1);b(this,"settings");b(this,"onChange",null);b(this,"soundManager",null);this.containerEl=t,this.settings=this.loadSettings(),this.contentEl=document.createElement("div"),this.contentEl.id="settings-content",this.contentEl.style.display="none",this.containerEl.appendChild(this.contentEl)}setSoundManager(t){this.soundManager=t}loadSettings(){const t=Mr(Da,{});return{...fn,...t,soundEvents:{...fn.soundEvents,...t.soundEvents??{}},soundVoices:{...fn.soundVoices,...t.soundVoices??{}}}}save(){var t;En(Da,this.settings),(t=this.onChange)==null||t.call(this,this.settings)}getSettings(){return this.settings}updateSetting(t,e){this.settings[t]!==e&&(this.settings[t]=e,En(Da,this.settings),this.isVisible&&this.render())}setChangeHandler(t){this.onChange=t}show(){this.isVisible=!0,this.contentEl.style.display="",this.render()}hide(){this.isVisible=!1,this.contentEl.style.display="none"}render(){const t=this.settings;this.contentEl.innerHTML=`
|
|
723
|
-
<div class="settings-panel">
|
|
724
|
-
<!-- Sound -->
|
|
725
|
-
<div class="settings-section">
|
|
726
|
-
<h3 class="settings-section-title">
|
|
727
|
-
<svg viewBox="0 0 24 24" width="14" height="14" fill="currentColor"><path d="M3 9v6h4l5 5V4L7 9H3zm13.5 3c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z"/></svg>
|
|
728
|
-
Sound
|
|
729
|
-
</h3>
|
|
730
|
-
<div class="settings-row">
|
|
731
|
-
<label class="settings-label">Master Volume</label>
|
|
732
|
-
<div class="settings-control">
|
|
733
|
-
<input type="range" id="s-volume" min="0" max="100" value="${Math.round(t.masterVolume*100)}" class="settings-slider" />
|
|
734
|
-
<span class="settings-value" id="s-volume-val">${Math.round(t.masterVolume*100)}%</span>
|
|
735
|
-
</div>
|
|
736
|
-
</div>
|
|
737
|
-
<div class="settings-row">
|
|
738
|
-
<label class="settings-label">Mute All</label>
|
|
739
|
-
<div class="settings-control">
|
|
740
|
-
<label class="settings-toggle">
|
|
741
|
-
<input type="checkbox" id="s-mute" ${t.muted?"checked":""} />
|
|
742
|
-
<span class="settings-toggle-track"></span>
|
|
743
|
-
</label>
|
|
744
|
-
</div>
|
|
745
|
-
</div>
|
|
746
|
-
<div class="settings-sub-title">Sound Events</div>
|
|
747
|
-
${_v.map(e=>{const s=vl[e],n=t.soundVoices[e]||br[e];return`
|
|
748
|
-
<div class="settings-sound-row">
|
|
749
|
-
<label class="settings-toggle settings-sound-toggle">
|
|
750
|
-
<input type="checkbox" data-sound="${e}" ${t.soundEvents[e]?"checked":""} />
|
|
751
|
-
<span class="settings-toggle-track"></span>
|
|
752
|
-
</label>
|
|
753
|
-
<span class="settings-sound-label">${xv[e]}</span>
|
|
754
|
-
<select class="settings-voice-select" data-voice-event="${e}">
|
|
755
|
-
${s.map(o=>`<option value="${o.id}" ${o.id===n?"selected":""}>${o.label}</option>`).join("")}
|
|
756
|
-
</select>
|
|
757
|
-
<button class="settings-preview-btn" data-preview="${e}" title="Preview sound">
|
|
758
|
-
<svg viewBox="0 0 24 24" width="12" height="12" fill="currentColor"><path d="M8 5v14l11-7z"/></svg>
|
|
759
|
-
</button>
|
|
760
|
-
</div>
|
|
761
|
-
`}).join("")}
|
|
762
|
-
</div>
|
|
763
|
-
|
|
764
|
-
<!-- Notifications -->
|
|
765
|
-
<div class="settings-section">
|
|
766
|
-
<h3 class="settings-section-title">
|
|
767
|
-
<svg viewBox="0 0 24 24" width="14" height="14" fill="currentColor"><path d="M12 22c1.1 0 2-.9 2-2h-4c0 1.1.89 2 2 2zm6-6v-5c0-3.07-1.64-5.64-4.5-6.32V4c0-.83-.67-1.5-1.5-1.5s-1.5.67-1.5 1.5v.68C7.63 5.36 6 7.92 6 11v5l-2 2v1h16v-1l-2-2z"/></svg>
|
|
768
|
-
Notifications
|
|
769
|
-
</h3>
|
|
770
|
-
<div class="settings-row">
|
|
771
|
-
<div class="settings-label-group">
|
|
772
|
-
<label class="settings-label">Browser Notifications</label>
|
|
773
|
-
<span class="settings-hint">Show alerts when tab is in background</span>
|
|
774
|
-
</div>
|
|
775
|
-
<div class="settings-control">
|
|
776
|
-
<label class="settings-toggle">
|
|
777
|
-
<input type="checkbox" id="s-notif" ${t.browserNotifications?"checked":""} />
|
|
778
|
-
<span class="settings-toggle-track"></span>
|
|
779
|
-
</label>
|
|
780
|
-
</div>
|
|
781
|
-
</div>
|
|
782
|
-
</div>
|
|
783
|
-
|
|
784
|
-
<!-- Cost Alerts -->
|
|
785
|
-
<div class="settings-section">
|
|
786
|
-
<h3 class="settings-section-title">
|
|
787
|
-
<svg viewBox="0 0 24 24" width="14" height="14" fill="currentColor"><path d="M11.8 10.9c-2.27-.59-3-1.2-3-2.15 0-1.09 1.01-1.85 2.7-1.85 1.78 0 2.44.85 2.5 2.1h2.21c-.07-1.72-1.12-3.3-3.21-3.81V3h-3v2.16c-1.94.42-3.5 1.68-3.5 3.61 0 2.31 1.91 3.46 4.7 4.13 2.5.6 3 1.48 3 2.41 0 .69-.49 1.79-2.7 1.79-2.06 0-2.87-.92-2.98-2.1h-2.2c.12 2.19 1.76 3.42 3.68 3.83V21h3v-2.15c1.95-.37 3.5-1.5 3.5-3.55 0-2.84-2.43-3.81-4.7-4.4z"/></svg>
|
|
788
|
-
Cost Alerts
|
|
789
|
-
</h3>
|
|
790
|
-
<div class="settings-row">
|
|
791
|
-
<div class="settings-label-group">
|
|
792
|
-
<label class="settings-label">Spend Threshold</label>
|
|
793
|
-
<span class="settings-hint">Alert when total cost exceeds this amount</span>
|
|
794
|
-
</div>
|
|
795
|
-
<div class="settings-control">
|
|
796
|
-
<span class="settings-input-prefix">$</span>
|
|
797
|
-
<input type="number" id="s-threshold" value="${t.costThreshold}" min="0.1" step="0.5" class="settings-number" />
|
|
798
|
-
</div>
|
|
799
|
-
</div>
|
|
800
|
-
</div>
|
|
801
|
-
|
|
802
|
-
<!-- Display -->
|
|
803
|
-
<div class="settings-section">
|
|
804
|
-
<h3 class="settings-section-title">
|
|
805
|
-
<svg viewBox="0 0 24 24" width="14" height="14" fill="currentColor"><path d="M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5zM12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5zm0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z"/></svg>
|
|
806
|
-
Display
|
|
807
|
-
</h3>
|
|
808
|
-
<div class="settings-row">
|
|
809
|
-
<div class="settings-label-group">
|
|
810
|
-
<label class="settings-label">Agent Trails</label>
|
|
811
|
-
<span class="settings-hint">Show movement trails behind agents</span>
|
|
812
|
-
</div>
|
|
813
|
-
<div class="settings-control">
|
|
814
|
-
<label class="settings-toggle">
|
|
815
|
-
<input type="checkbox" id="s-trails" ${t.showTrails?"checked":""} />
|
|
816
|
-
<span class="settings-toggle-track"></span>
|
|
817
|
-
</label>
|
|
818
|
-
</div>
|
|
819
|
-
</div>
|
|
820
|
-
<div class="settings-row">
|
|
821
|
-
<div class="settings-label-group">
|
|
822
|
-
<label class="settings-label">Zone Heatmap</label>
|
|
823
|
-
<span class="settings-hint">Overlay showing zone activity intensity</span>
|
|
824
|
-
</div>
|
|
825
|
-
<div class="settings-control">
|
|
826
|
-
<label class="settings-toggle">
|
|
827
|
-
<input type="checkbox" id="s-heatmap" ${t.showHeatmap?"checked":""} />
|
|
828
|
-
<span class="settings-toggle-track"></span>
|
|
829
|
-
</label>
|
|
830
|
-
</div>
|
|
831
|
-
</div>
|
|
832
|
-
<div class="settings-row">
|
|
833
|
-
<div class="settings-label-group">
|
|
834
|
-
<label class="settings-label">Agent Names</label>
|
|
835
|
-
<span class="settings-hint">Show name labels above agent sprites</span>
|
|
836
|
-
</div>
|
|
837
|
-
<div class="settings-control">
|
|
838
|
-
<label class="settings-toggle">
|
|
839
|
-
<input type="checkbox" id="s-names" ${t.showAgentNames?"checked":""} />
|
|
840
|
-
<span class="settings-toggle-track"></span>
|
|
841
|
-
</label>
|
|
842
|
-
</div>
|
|
843
|
-
</div>
|
|
844
|
-
</div>
|
|
845
|
-
|
|
846
|
-
<div class="settings-footer">
|
|
847
|
-
<button id="s-reset" class="settings-reset-btn">Reset to Defaults</button>
|
|
848
|
-
</div>
|
|
849
|
-
</div>
|
|
850
|
-
`,this.bindEvents()}bindEvents(){const t=this.contentEl.querySelector("#s-volume"),e=this.contentEl.querySelector("#s-volume-val");t==null||t.addEventListener("input",()=>{const h=Number(t.value);e.textContent=`${h}%`,this.settings.masterVolume=h/100,this.save()});const s=this.contentEl.querySelector("#s-mute");s==null||s.addEventListener("change",()=>{this.settings.muted=s.checked,this.save()}),this.contentEl.querySelectorAll("[data-sound]").forEach(h=>{h.addEventListener("change",()=>{const p=h.dataset.sound;this.settings.soundEvents[p]=h.checked,this.save()})}),this.contentEl.querySelectorAll("[data-voice-event]").forEach(h=>{h.addEventListener("change",()=>{var g;const p=h.dataset.voiceEvent;this.settings.soundVoices[p]=h.value,this.save(),(g=this.soundManager)==null||g.preview(p,h.value)})}),this.contentEl.querySelectorAll("[data-preview]").forEach(h=>{h.addEventListener("click",()=>{var m;const p=h.dataset.preview,g=this.settings.soundVoices[p]||br[p];(m=this.soundManager)==null||m.preview(p,g),h.classList.add("settings-preview-active"),setTimeout(()=>h.classList.remove("settings-preview-active"),300)})});const n=this.contentEl.querySelector("#s-notif");n==null||n.addEventListener("change",()=>{this.settings.browserNotifications=n.checked,this.save()});const o=this.contentEl.querySelector("#s-threshold");o==null||o.addEventListener("change",()=>{this.settings.costThreshold=parseFloat(o.value)||5,this.save()});const r=this.contentEl.querySelector("#s-trails");r==null||r.addEventListener("change",()=>{this.settings.showTrails=r.checked,this.save()});const l=this.contentEl.querySelector("#s-heatmap");l==null||l.addEventListener("change",()=>{this.settings.showHeatmap=l.checked,this.save()});const c=this.contentEl.querySelector("#s-names");c==null||c.addEventListener("change",()=>{this.settings.showAgentNames=c.checked,this.save()});const d=this.contentEl.querySelector("#s-reset");d==null||d.addEventListener("click",()=>{this.settings={...fn,soundEvents:{...fn.soundEvents},soundVoices:{...fn.soundVoices}},this.save(),this.render()})}}async function Sv(){const i=document.getElementById("app"),t=await P0(i),e=new ol;ub();const s=new vy(t),n=new W1(t,s,e),o=new _l,r=new eb;n.setSoundManager(o),n.setNotificationManager(r);const l=new mb(e),c=new gb,d=new H1(e),h=new U1(e);d.setAgentClickHandler(st=>{h.open(st),Ft(st)}),n.setClickHandler(st=>{h.open(st),Ft(st)});const p=new vv(e);p.setFocusHandler(st=>Ft(st)),p.setDetailHandler(st=>{h.open(st),Ft(st)}),n.setHoverHandler((st,Ct,Mt)=>{if(st){const Jt=s.root,vo=Ct*Jt.scale.x+Jt.x,qu=Mt*Jt.scale.y+Jt.y,Nl=t.canvas.getBoundingClientRect();p.show(st,vo+Nl.left,qu+Nl.top)}else p.hide()});const g=new j1(e);g.setReplayCallback(st=>{n.rebuildFromState(st)});const m=new ob(e);let y=!0;const _=document.getElementById("right-panel-content"),w=document.getElementById("overlay"),k=document.getElementById("right-panel-title"),E=new hb(e,_),B=new Eb(e,_),L=new Kb(e,_),H=new Jb(e,_),$=new Zb,G=new rv(e,_),et=new hv(e,_),Z=new bv(e,_),j=new wv(_);j.setSoundManager(o);const Q=new tv(e),rt=new iv(e),lt=new xl(e),ct=new _b,Gt=new xb(e);new wb;const J=new Cb;s.addEffect(J.container);const nt=new Ab(s.camera,(st,Ct)=>{s.camera.panTo(st,Ct)}),Dt=new Pb,it=st=>Dt.getCustomDisplay(st);n.setCustomizationLookup(it),h.setCustomizationLookup(it),d.setCustomizationLookup(it),B.setCustomizationLookup(it),E.setCustomizationLookup(it),et.setCustomizationLookup(it),Z.setCustomizationLookup(it),G.setCustomizationLookup(it),lt.setCustomizationLookup(it),rt.setCustomizationLookup(it),g.setCustomizationLookup(it),Gt.setCustomizationLookup(it),Dt.setChangeHandler((st,Ct)=>{n.applyCustomization(st,Ct.displayName,Ct.colorIndex),h.currentAgentId===st&&h.refreshHeader(Ct.displayName),d.scheduleRender()}),h.setCustomizeHandler(st=>{Dt.open(st)}),t.canvas.addEventListener("contextmenu",st=>{st.preventDefault()}),t.canvas.addEventListener("dblclick",st=>{const Ct=t.canvas.getBoundingClientRect(),Mt=st.clientX-Ct.left,Jt=st.clientY-Ct.top;$.addAnnotationFromScreen(Mt,Jt)});const yt=new Xb;s.applyTheme(yt.current);const Bt=document.getElementById("theme-select");Bt.value=yt.current.id,Bt.addEventListener("change",()=>yt.setTheme(Bt.value)),yt.onChange(st=>{s.applyTheme(st),Bt.value=st.id});let wt=!1;function ft(){if(wt&&n.focusedAgentId){const st=n.getFocusedAgentName()||"Agent";l.showFocus(st)}else l.hideFocus()}function Ft(st){n.setFocusAgent(st),wt=!0,ft()}function qt(){wt=!1,n.setFocusAgent(null),ft()}let ye=null;function Zt(){return ye||(ye=document.getElementById("zone-heatmap")),ye}document.getElementById("focus-stop").addEventListener("click",qt);let be=Mr("activeTab","monitor");const Le={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:()=>et.show(),hide:()=>et.hide(),title:"Waterfall"},graph:{show:()=>Z.show(),hide:()=>Z.hide(),title:"Agent Graph"},settings:{show:()=>j.show(),hide:()=>j.hide(),title:"Settings"}};function Ts(st){var Ct;if(En("activeTab",st),(Ct=Le[be])==null||Ct.hide(),be=st,st==="monitor")w.style.display="",_.style.display="none",k.textContent="Agents";else{h.isOpen()&&h.close(),w.style.display="none",_.style.display="";const Mt=Le[st];k.textContent=(Mt==null?void 0:Mt.title)??st,Mt==null||Mt.show()}}c.setTabChangeHandler(st=>{Ts(st)}),be!=="monitor"&&c.setActiveTab(be),document.getElementById("right-panel");function Be(st){c.setActiveTab(be===st?"monitor":st)}function Ze(st,Ct){switch(st){case"focus-zone":{const Mt=Ct?Xt.get(Ct):null;Mt&&s.camera.panTo(Mt.x+Mt.width/2,Mt.y+Mt.height/2);break}case"focus-agent":Ct&&(h.open(Ct),Ft(Ct));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,Cs();break;case"toggle-heatmap":y=!y;{const Mt=Zt();Mt&&(Mt.style.display=y?"block":"none")}break;case"toggle-shortcuts":ct.toggle();break;case"toggle-focus":wt?qt():(n.cycleNextAgent(),wt=!!n.focusedAgentId,ft());break;case"cycle-focus":wt?n.cycleNextAgent()||qt():(n.cycleNextAgent(),wt=!!n.focusedAgentId),ft();break;case"exit-focus":wt&&qt();break;case"session-export":Gt.toggle();break;case"toggle-trails":J.toggle();break;case"toggle-daynight":s.dayNight.toggle();break;case"toggle-minimap":nt.toggle();break;case"cycle-theme":yt.cycleNext();break;case"toggle-annotations":$.toggle();break;case"toggle-sidebar":c.toggle();break;case"toggle-analytics":Be("analytics");break;case"toggle-leaderboard":Be("leaderboard");break;case"toggle-toolchain":Be("toolchain");break;case"toggle-taskgraph":Be("taskgraph");break;case"toggle-activity":Be("activity");break;case"toggle-waterfall":Be("waterfall");break;case"toggle-graph":Be("graph");break;case"toggle-settings":Be("settings");break}}const Ke=new ab(e,Ze);Ke.setCustomizationLookup(it),e.on("agent:shutdown",st=>{J.removeAgent(st)});const Qe=new L0(e);Qe.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 Ue=document.getElementById("mute-btn"),en=document.getElementById("volume-slider");function Cs(){Ue.textContent=o.muted||o.volume===0?"🔇":"🔈",Ue.classList.toggle("muted",o.muted||o.volume===0)}Ue.addEventListener("click",()=>{o.init(),o.muted=!o.muted,Cs(),j.updateSetting("muted",o.muted)}),en.addEventListener("input",()=>{o.init(),o.volume=Number(en.value)/100,o.muted&&o.volume>0&&(o.muted=!1),Cs(),j.updateSetting("masterVolume",o.volume),o.muted||j.updateSetting("muted",!1)});const Re=j.getSettings();if(o.volume=Re.masterVolume,o.muted=Re.muted,en.value=String(Math.round(Re.masterVolume*100)),Cs(),o.setEnabledEvents(Re.soundEvents),o.setVoices(Re.soundVoices),r.enabled=Re.browserNotifications,E.setCostThreshold(Re.costThreshold),Re.showTrails&&J.toggle(),y=Re.showHeatmap,!y){const st=Zt();st&&(st.style.display="none")}n.setShowNames(Re.showAgentNames),j.setChangeHandler(st=>{o.volume=st.masterVolume,o.muted=st.muted,o.setEnabledEvents(st.soundEvents),o.setVoices(st.soundVoices),en.value=String(Math.round(st.masterVolume*100)),Cs(),r.enabled=st.browserNotifications,E.setCostThreshold(st.costThreshold),st.showTrails!==J.enabled&&J.toggle(),y=st.showHeatmap;{const Ct=Zt();Ct&&(Ct.style.display=y?"block":"none")}n.setShowNames(st.showAgentNames)});const Er=document.getElementById("notif-btn");Er.appendChild(rt.getBadgeElement()),Er.addEventListener("click",()=>{rt.toggle()}),document.getElementById("shortcuts-btn").addEventListener("click",()=>{ct.toggle()}),document.getElementById("cmd-hint").addEventListener("click",()=>{Ke.toggle()}),document.addEventListener("click",()=>{o.init(),r.requestPermission()},{once:!0});const Vu={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",s:"toggle-settings"};document.addEventListener("keydown",st=>{var Jt;const Ct=(Jt=st.target)==null?void 0:Jt.tagName;if(Ct==="INPUT"||Ct==="TEXTAREA"||Ct==="SELECT"||st.ctrlKey||st.metaKey||st.altKey)return;const Mt=Vu[st.key];Mt&&Ze(Mt)}),window.addEventListener("beforeunload",()=>{Qe.disconnect(),n.dispose(),d.dispose(),h.dispose(),g.dispose(),E.dispose(),B.dispose(),l.dispose(),lt.dispose(),rt.dispose(),Q.dispose(),et.destroy(),G.destroy(),nt.dispose(),e.dispose()}),t.ticker.add(()=>{const st=t.ticker.deltaMS;n.update(st),s.update(st);const Ct=s.root;if(y&&m.updateTransform(Ct.x,Ct.y,Ct.scale.x),$.updateTransform(Ct.x,Ct.y,Ct.scale.x),wt){const Mt=n.getFocusedAgentPosition();Mt&&s.camera.smoothFollow(Mt.x,Mt.y)}if(J.enabled){const Mt=new Map;for(const Jt of n.getAgentPositions()){const vo=ut[Jt.colorIndex%ut.length];Mt.set(Jt.id,vo.body),J.recordPosition(Jt.id,Jt.x,Jt.y,st,vo.body)}J.update(st,Mt)}if(nt.visible){const Mt=s.camera.getViewport(),Jt=n.getAgentPositions();nt.render(Jt,Mt)}}),console.log("AgentMove started")}Sv().catch(console.error);export{wr as $,Kd as A,fo as B,Kt as C,Ie as D,cs as E,ws as F,kr as G,Cl as H,jd as I,He as J,Wd as K,el as L,xt as M,Im as N,Bm as O,pe as P,Gm as Q,Ua as R,Al as S,Lt as T,dr as U,zm as V,hf as W,Hm as X,Te as Y,pd as Z,Oe as _,Hd as a,ec as a0,Qi as a1,S0 as a2,Wf as a3,ic as a4,Nr as a5,nc as a6,Hf as a7,Tn as a8,Yt as a9,yd as aa,qg as ab,Qd as ac,At as ad,yo as ae,Ut as af,qp as ag,Wp as ah,fm as ai,rm as aj,Lm as ak,Rm as al,Wm as am,Nm as an,Om as ao,zd as b,im as c,Se as d,Vt as e,Rt as f,up as g,Jo as h,bt as i,Wt as j,og as k,Zm as l,gd as m,Cr as n,Cd as o,jt as p,bn as q,kf as r,Tr as s,zt as t,Sp as u,tm as v,we as w,bo as x,bc as y,tr as z};
|