agent-theatre 1.2.1 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/browserAll-DHOoTekQ.js","assets/webworkerAll-CwKw12By.js"])))=>i.map(i=>d[i]);
2
- (function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))s(r);new MutationObserver(r=>{for(const n of r)if(n.type==="childList")for(const o of n.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&s(o)}).observe(document,{childList:!0,subtree:!0});function t(r){const n={};return r.integrity&&(n.integrity=r.integrity),r.referrerPolicy&&(n.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?n.credentials="include":r.crossOrigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function s(r){if(r.ep)return;r.ep=!0;const n=t(r);fetch(r.href,n)}})();const Fg="modulepreload",Og=function(i){return"/"+i},yh={},St=function(e,t,s){let r=Promise.resolve();if(t&&t.length>0){let o=function(h){return Promise.all(h.map(c=>Promise.resolve(c).then(u=>({status:"fulfilled",value:u}),u=>({status:"rejected",reason:u}))))};document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),l=a?.nonce||a?.getAttribute("nonce");r=o(t.map(h=>{if(h=Og(h),h in yh)return;yh[h]=!0;const c=h.endsWith(".css"),u=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${u}`))return;const d=document.createElement("link");if(d.rel=c?"stylesheet":Fg,c||(d.as="script"),d.crossOrigin="",d.href=h,l&&d.setAttribute("nonce",l),document.head.appendChild(d),c)return new Promise((f,p)=>{d.addEventListener("load",f),d.addEventListener("error",()=>p(new Error(`Unable to preload CSS for ${h}`)))})}))}function n(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return r.then(o=>{for(const a of o||[])a.status==="rejected"&&n(a.reason);return e().catch(n)})};var S=(i=>(i.Application="application",i.WebGLPipes="webgl-pipes",i.WebGLPipesAdaptor="webgl-pipes-adaptor",i.WebGLSystem="webgl-system",i.WebGLLoader="webgl-loader",i.WebGPUPipes="webgpu-pipes",i.WebGPUPipesAdaptor="webgpu-pipes-adaptor",i.WebGPUSystem="webgpu-system",i.WebGPULoader="webgpu-loader",i.CanvasSystem="canvas-system",i.CanvasPipesAdaptor="canvas-pipes-adaptor",i.CanvasPipes="canvas-pipes",i.CanvasLoader="canvas-loader",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.TextureUploaderWebGL="texture-uploader-webgl",i.TextureUploaderWebGPU="texture-uploader-webgpu",i.Environment="environment",i.ShapeBuilder="shape-builder",i.Batcher="batcher",i))(S||{});const Ln=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},Ks=(i,e)=>Ln(i).priority??e,q={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...i){return i.map(Ln).forEach(e=>{e.type.forEach(t=>this._removeHandlers[t]?.(e))}),this},add(...i){return i.map(Ln).forEach(e=>{e.type.forEach(t=>{const s=this._addHandlers,r=this._queue;s[t]?s[t]?.(e):(r[t]=r[t]||[],r[t]?.push(e))})}),this},handle(i,e,t){const s=this._addHandlers,r=this._removeHandlers;if(s[i]||r[i])throw new Error(`Extension type ${i} already has a handler`);s[i]=e,r[i]=t;const n=this._queue;return n[i]&&(n[i]?.forEach(o=>e(o)),delete n[i]),this},handleByMap(i,e){return this.handle(i,t=>{t.name&&(e[t.name]=t.ref)},t=>{t.name&&delete e[t.name]})},handleByNamedList(i,e,t=-1){return this.handle(i,s=>{e.findIndex(n=>n.name===s.name)>=0||(e.push({name:s.name,value:s.ref}),e.sort((n,o)=>Ks(o.value,t)-Ks(n.value,t)))},s=>{const r=e.findIndex(n=>n.name===s.name);r!==-1&&e.splice(r,1)})},handleByList(i,e,t=-1){return this.handle(i,s=>{e.includes(s.ref)||(e.push(s.ref),e.sort((r,n)=>Ks(n,t)-Ks(r,t)))},s=>{const r=e.indexOf(s.ref);r!==-1&&e.splice(r,1)})},mixin(i,...e){for(const t of e)Object.defineProperties(i.prototype,Object.getOwnPropertyDescriptors(t))}},gu={extension:{type:S.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await St(()=>import("./browserAll-DHOoTekQ.js"),__vite__mapDeps([0,1]))}},_u={extension:{type:S.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await St(()=>import("./webworkerAll-CwKw12By.js"),[])}};class Ce{constructor(e,t,s){this._x=t||0,this._y=s||0,this._observer=e}clone(e){return new Ce(e??this._observer,this._x,this._y)}set(e=0,t=e){return(this._x!==e||this._y!==t)&&(this._x=e,this._y=t,this._observer._onUpdate(this)),this}copyFrom(e){return(this._x!==e.x||this._y!==e.y)&&(this._x=e.x,this._y=e.y,this._observer._onUpdate(this)),this}copyTo(e){return e.set(this._x,this._y),e}equals(e){return e.x===this._x&&e.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(e){this._x!==e&&(this._x=e,this._observer._onUpdate(this))}get y(){return this._y}set y(e){this._y!==e&&(this._y=e,this._observer._onUpdate(this))}}function Lg(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Qr={exports:{}},xh;function Ug(){return xh||(xh=1,(function(i){var e=Object.prototype.hasOwnProperty,t="~";function s(){}Object.create&&(s.prototype=Object.create(null),new s().__proto__||(t=!1));function r(l,h,c){this.fn=l,this.context=h,this.once=c||!1}function n(l,h,c,u,d){if(typeof c!="function")throw new TypeError("The listener must be a function");var f=new r(c,u||l,d),p=t?t+h:h;return l._events[p]?l._events[p].fn?l._events[p]=[l._events[p],f]:l._events[p].push(f):(l._events[p]=f,l._eventsCount++),l}function o(l,h){--l._eventsCount===0?l._events=new s:delete l._events[h]}function a(){this._events=new s,this._eventsCount=0}a.prototype.eventNames=function(){var h=[],c,u;if(this._eventsCount===0)return h;for(u in c=this._events)e.call(c,u)&&h.push(t?u.slice(1):u);return Object.getOwnPropertySymbols?h.concat(Object.getOwnPropertySymbols(c)):h},a.prototype.listeners=function(h){var c=t?t+h:h,u=this._events[c];if(!u)return[];if(u.fn)return[u.fn];for(var d=0,f=u.length,p=new Array(f);d<f;d++)p[d]=u[d].fn;return p},a.prototype.listenerCount=function(h){var c=t?t+h:h,u=this._events[c];return u?u.fn?1:u.length:0},a.prototype.emit=function(h,c,u,d,f,p){var g=t?t+h:h;if(!this._events[g])return!1;var m=this._events[g],_=arguments.length,y,x;if(m.fn){switch(m.once&&this.removeListener(h,m.fn,void 0,!0),_){case 1:return m.fn.call(m.context),!0;case 2:return m.fn.call(m.context,c),!0;case 3:return m.fn.call(m.context,c,u),!0;case 4:return m.fn.call(m.context,c,u,d),!0;case 5:return m.fn.call(m.context,c,u,d,f),!0;case 6:return m.fn.call(m.context,c,u,d,f,p),!0}for(x=1,y=new Array(_-1);x<_;x++)y[x-1]=arguments[x];m.fn.apply(m.context,y)}else{var b=m.length,v;for(x=0;x<b;x++)switch(m[x].once&&this.removeListener(h,m[x].fn,void 0,!0),_){case 1:m[x].fn.call(m[x].context);break;case 2:m[x].fn.call(m[x].context,c);break;case 3:m[x].fn.call(m[x].context,c,u);break;case 4:m[x].fn.call(m[x].context,c,u,d);break;default:if(!y)for(v=1,y=new Array(_-1);v<_;v++)y[v-1]=arguments[v];m[x].fn.apply(m[x].context,y)}}return!0},a.prototype.on=function(h,c,u){return n(this,h,c,u,!1)},a.prototype.once=function(h,c,u){return n(this,h,c,u,!0)},a.prototype.removeListener=function(h,c,u,d){var f=t?t+h:h;if(!this._events[f])return this;if(!c)return o(this,f),this;var p=this._events[f];if(p.fn)p.fn===c&&(!d||p.once)&&(!u||p.context===u)&&o(this,f);else{for(var g=0,m=[],_=p.length;g<_;g++)(p[g].fn!==c||d&&!p[g].once||u&&p[g].context!==u)&&m.push(p[g]);m.length?this._events[f]=m.length===1?m[0]:m:o(this,f)}return this},a.prototype.removeAllListeners=function(h){var c;return h?(c=t?t+h:h,this._events[c]&&o(this,c)):(this._events=new s,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=t,a.EventEmitter=a,i.exports=a})(Qr)),Qr.exports}var Ng=Ug();const Re=Lg(Ng),yu=Math.PI*2,xu=180/Math.PI,bu=Math.PI/180;class he{constructor(e=0,t=0){this.x=0,this.y=0,this.x=e,this.y=t}clone(){return new he(this.x,this.y)}copyFrom(e){return this.set(e.x,e.y),this}copyTo(e){return e.set(this.x,this.y),e}equals(e){return e.x===this.x&&e.y===this.y}set(e=0,t=e){return this.x=e,this.y=t,this}toString(){return`[pixi.js/math:Point x=${this.x} y=${this.y}]`}static get shared(){return Jr.x=0,Jr.y=0,Jr}}const Jr=new he;class U{constructor(e=1,t=0,s=0,r=1,n=0,o=0){this.array=null,this.a=e,this.b=t,this.c=s,this.d=r,this.tx=n,this.ty=o}fromArray(e){this.a=e[0],this.b=e[1],this.c=e[3],this.d=e[4],this.tx=e[2],this.ty=e[5]}set(e,t,s,r,n,o){return this.a=e,this.b=t,this.c=s,this.d=r,this.tx=n,this.ty=o,this}toArray(e,t){this.array||(this.array=new Float32Array(9));const s=t||this.array;return e?(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(e,t){t=t||new he;const s=e.x,r=e.y;return t.x=this.a*s+this.c*r+this.tx,t.y=this.b*s+this.d*r+this.ty,t}applyInverse(e,t){t=t||new he;const s=this.a,r=this.b,n=this.c,o=this.d,a=this.tx,l=this.ty,h=1/(s*o+n*-r),c=e.x,u=e.y;return t.x=o*h*c+-n*h*u+(l*n-a*o)*h,t.y=s*h*u+-r*h*c+(-l*s+a*r)*h,t}translate(e,t){return this.tx+=e,this.ty+=t,this}scale(e,t){return this.a*=e,this.d*=t,this.c*=e,this.b*=t,this.tx*=e,this.ty*=t,this}rotate(e){const t=Math.cos(e),s=Math.sin(e),r=this.a,n=this.c,o=this.tx;return this.a=r*t-this.b*s,this.b=r*s+this.b*t,this.c=n*t-this.d*s,this.d=n*s+this.d*t,this.tx=o*t-this.ty*s,this.ty=o*s+this.ty*t,this}append(e){const t=this.a,s=this.b,r=this.c,n=this.d;return this.a=e.a*t+e.b*r,this.b=e.a*s+e.b*n,this.c=e.c*t+e.d*r,this.d=e.c*s+e.d*n,this.tx=e.tx*t+e.ty*r+this.tx,this.ty=e.tx*s+e.ty*n+this.ty,this}appendFrom(e,t){const s=e.a,r=e.b,n=e.c,o=e.d,a=e.tx,l=e.ty,h=t.a,c=t.b,u=t.c,d=t.d;return this.a=s*h+r*u,this.b=s*c+r*d,this.c=n*h+o*u,this.d=n*c+o*d,this.tx=a*h+l*u+t.tx,this.ty=a*c+l*d+t.ty,this}setTransform(e,t,s,r,n,o,a,l,h){return this.a=Math.cos(a+h)*n,this.b=Math.sin(a+h)*n,this.c=-Math.sin(a-l)*o,this.d=Math.cos(a-l)*o,this.tx=e-(s*this.a+r*this.c),this.ty=t-(s*this.b+r*this.d),this}prepend(e){const t=this.tx;if(e.a!==1||e.b!==0||e.c!==0||e.d!==1){const s=this.a,r=this.c;this.a=s*e.a+this.b*e.c,this.b=s*e.b+this.b*e.d,this.c=r*e.a+this.d*e.c,this.d=r*e.b+this.d*e.d}return this.tx=t*e.a+this.ty*e.c+e.tx,this.ty=t*e.b+this.ty*e.d+e.ty,this}decompose(e){const t=this.a,s=this.b,r=this.c,n=this.d,o=e.pivot,a=-Math.atan2(-r,n),l=Math.atan2(s,t),h=Math.abs(a+l);let c=Math.sqrt(t*t+s*s);return h<1e-5||Math.abs(yu-h)<1e-5?(e.rotation=l,e.skew.x=e.skew.y=0):Math.abs(Math.PI-h)<1e-5?(e.rotation=l-Math.PI,e.skew.x=e.skew.y=0,c=-c):(e.rotation=0,e.skew.x=a,e.skew.y=l),e.scale.x=c,e.scale.y=Math.sqrt(r*r+n*n),e.position.x=this.tx+(o.x*t+o.y*r),e.position.y=this.ty+(o.x*s+o.y*n),e}invert(){const e=this.a,t=this.b,s=this.c,r=this.d,n=this.tx,o=e*r-t*s;return this.a=r/o,this.b=-t/o,this.c=-s/o,this.d=e/o,this.tx=(s*this.ty-r*n)/o,this.ty=-(e*this.ty-t*n)/o,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 e=new U;return e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.tx=this.tx,e.ty=this.ty,e}copyTo(e){return e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.tx=this.tx,e.ty=this.ty,e}copyFrom(e){return this.a=e.a,this.b=e.b,this.c=e.c,this.d=e.d,this.tx=e.tx,this.ty=e.ty,this}equals(e){return e.a===this.a&&e.b===this.b&&e.c===this.c&&e.d===this.d&&e.tx===this.tx&&e.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 zg.identity()}static get shared(){return Hg.identity()}}const Hg=new U,zg=new U,Ht=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],zt=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],Wt=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],$t=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],Un=[],vu=[],Ci=Math.sign;function Wg(){for(let i=0;i<16;i++){const e=[];Un.push(e);for(let t=0;t<16;t++){const s=Ci(Ht[i]*Ht[t]+Wt[i]*zt[t]),r=Ci(zt[i]*Ht[t]+$t[i]*zt[t]),n=Ci(Ht[i]*Wt[t]+Wt[i]*$t[t]),o=Ci(zt[i]*Wt[t]+$t[i]*$t[t]);for(let a=0;a<16;a++)if(Ht[a]===s&&zt[a]===r&&Wt[a]===n&&$t[a]===o){e.push(a);break}}}for(let i=0;i<16;i++){const e=new U;e.set(Ht[i],zt[i],Wt[i],$t[i],0,0),vu.push(e)}}Wg();const Z={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=>Ht[i],uY:i=>zt[i],vX:i=>Wt[i],vY:i=>$t[i],inv:i=>i&8?i&15:-i&7,add:(i,e)=>Un[i][e],sub:(i,e)=>Un[i][Z.inv(e)],rotate180:i=>i^4,isVertical:i=>(i&3)===2,byDirection:(i,e)=>Math.abs(i)*2<=Math.abs(e)?e>=0?Z.S:Z.N:Math.abs(e)*2<=Math.abs(i)?i>0?Z.E:Z.W:e>0?i>0?Z.SE:Z.SW:i>0?Z.NE:Z.NW,matrixAppendRotationInv:(i,e,t=0,s=0,r=0,n=0)=>{const o=vu[Z.inv(e)],a=o.a,l=o.b,h=o.c,c=o.d,u=t-Math.min(0,a*r,h*n,a*r+h*n),d=s-Math.min(0,l*r,c*n,l*r+c*n),f=i.a,p=i.b,g=i.c,m=i.d;i.a=a*f+l*g,i.b=a*p+l*m,i.c=h*f+c*g,i.d=h*p+c*m,i.tx=u*f+d*g+i.tx,i.ty=u*p+d*m+i.ty},transformRectCoords:(i,e,t,s)=>{const{x:r,y:n,width:o,height:a}=i,{x:l,y:h,width:c,height:u}=e;return t===Z.E?(s.set(r+l,n+h,o,a),s):t===Z.S?s.set(c-n-a+l,r+h,a,o):t===Z.W?s.set(c-r-o+l,u-n-a+h,o,a):t===Z.N?s.set(n+l,u-r-o+h,a,o):s.set(r+l,n+h,o,a)}},Mi=[new he,new he,new he,new he];class te{constructor(e=0,t=0,s=0,r=0){this.type="rectangle",this.x=Number(e),this.y=Number(t),this.width=Number(s),this.height=Number(r)}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 te(0,0,0,0)}clone(){return new te(this.x,this.y,this.width,this.height)}copyFromBounds(e){return this.x=e.minX,this.y=e.minY,this.width=e.maxX-e.minX,this.height=e.maxY-e.minY,this}copyFrom(e){return this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this}copyTo(e){return e.copyFrom(this),e}contains(e,t){return this.width<=0||this.height<=0?!1:e>=this.x&&e<this.x+this.width&&t>=this.y&&t<this.y+this.height}strokeContains(e,t,s,r=.5){const{width:n,height:o}=this;if(n<=0||o<=0)return!1;const a=this.x,l=this.y,h=s*(1-r),c=s-h,u=a-h,d=a+n+h,f=l-h,p=l+o+h,g=a+c,m=a+n-c,_=l+c,y=l+o-c;return e>=u&&e<=d&&t>=f&&t<=p&&!(e>g&&e<m&&t>_&&t<y)}intersects(e,t){if(!t){const k=this.x<e.x?e.x:this.x;if((this.right>e.right?e.right:this.right)<=k)return!1;const A=this.y<e.y?e.y:this.y;return(this.bottom>e.bottom?e.bottom:this.bottom)>A}const s=this.left,r=this.right,n=this.top,o=this.bottom;if(r<=s||o<=n)return!1;const a=Mi[0].set(e.left,e.top),l=Mi[1].set(e.left,e.bottom),h=Mi[2].set(e.right,e.top),c=Mi[3].set(e.right,e.bottom);if(h.x<=a.x||l.y<=a.y)return!1;const u=Math.sign(t.a*t.d-t.b*t.c);if(u===0||(t.apply(a,a),t.apply(l,l),t.apply(h,h),t.apply(c,c),Math.max(a.x,l.x,h.x,c.x)<=s||Math.min(a.x,l.x,h.x,c.x)>=r||Math.max(a.y,l.y,h.y,c.y)<=n||Math.min(a.y,l.y,h.y,c.y)>=o))return!1;const d=u*(l.y-a.y),f=u*(a.x-l.x),p=d*s+f*n,g=d*r+f*n,m=d*s+f*o,_=d*r+f*o;if(Math.max(p,g,m,_)<=d*a.x+f*a.y||Math.min(p,g,m,_)>=d*c.x+f*c.y)return!1;const y=u*(a.y-h.y),x=u*(h.x-a.x),b=y*s+x*n,v=y*r+x*n,w=y*s+x*o,T=y*r+x*o;return!(Math.max(b,v,w,T)<=y*a.x+x*a.y||Math.min(b,v,w,T)>=y*c.x+x*c.y)}pad(e=0,t=e){return this.x-=e,this.y-=t,this.width+=e*2,this.height+=t*2,this}fit(e){const t=Math.max(this.x,e.x),s=Math.min(this.x+this.width,e.x+e.width),r=Math.max(this.y,e.y),n=Math.min(this.y+this.height,e.y+e.height);return this.x=t,this.width=Math.max(s-t,0),this.y=r,this.height=Math.max(n-r,0),this}ceil(e=1,t=.001){const s=Math.ceil((this.x+this.width-t)*e)/e,r=Math.ceil((this.y+this.height-t)*e)/e;return this.x=Math.floor((this.x+t)*e)/e,this.y=Math.floor((this.y+t)*e)/e,this.width=s-this.x,this.height=r-this.y,this}scale(e,t=e){return this.x*=e,this.y*=t,this.width*=e,this.height*=t,this}enlarge(e){const t=Math.min(this.x,e.x),s=Math.max(this.x+this.width,e.x+e.width),r=Math.min(this.y,e.y),n=Math.max(this.y+this.height,e.y+e.height);return this.x=t,this.width=s-t,this.y=r,this.height=n-r,this}getBounds(e){return e||(e=new te),e.copyFrom(this),e}containsRect(e){if(this.width<=0||this.height<=0)return!1;const t=e.x,s=e.y,r=e.x+e.width,n=e.y+e.height;return t>=this.x&&t<this.x+this.width&&s>=this.y&&s<this.y+this.height&&r>=this.x&&r<=this.x+this.width&&n>=this.y&&n<=this.y+this.height}set(e,t,s,r){return this.x=e,this.y=t,this.width=s,this.height=r,this}toString(){return`[pixi.js/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`}}const en={default:-1};function oe(i="default"){return en[i]===void 0&&(en[i]=-1),++en[i]}const bh=new Set,ue="8.0.0",wu="8.3.4",ht="8.21.0",Tu="8.22.0",vs={quiet:!1,noColor:!1},H=((i,e,t=3)=>{if(vs.quiet||bh.has(e))return;let s=new Error().stack;const r=`${e}
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/browserAll-DpEOVFXE.js","assets/webworkerAll-BIhfsOqG.js"])))=>i.map(i=>d[i]);
2
+ (function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))s(r);new MutationObserver(r=>{for(const n of r)if(n.type==="childList")for(const o of n.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&s(o)}).observe(document,{childList:!0,subtree:!0});function t(r){const n={};return r.integrity&&(n.integrity=r.integrity),r.referrerPolicy&&(n.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?n.credentials="include":r.crossOrigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function s(r){if(r.ep)return;r.ep=!0;const n=t(r);fetch(r.href,n)}})();const Fg="modulepreload",Og=function(i){return"/"+i},yh={},St=function(e,t,s){let r=Promise.resolve();if(t&&t.length>0){let o=function(h){return Promise.all(h.map(c=>Promise.resolve(c).then(u=>({status:"fulfilled",value:u}),u=>({status:"rejected",reason:u}))))};document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),l=a?.nonce||a?.getAttribute("nonce");r=o(t.map(h=>{if(h=Og(h),h in yh)return;yh[h]=!0;const c=h.endsWith(".css"),u=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${u}`))return;const d=document.createElement("link");if(d.rel=c?"stylesheet":Fg,c||(d.as="script"),d.crossOrigin="",d.href=h,l&&d.setAttribute("nonce",l),document.head.appendChild(d),c)return new Promise((f,p)=>{d.addEventListener("load",f),d.addEventListener("error",()=>p(new Error(`Unable to preload CSS for ${h}`)))})}))}function n(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return r.then(o=>{for(const a of o||[])a.status==="rejected"&&n(a.reason);return e().catch(n)})};var S=(i=>(i.Application="application",i.WebGLPipes="webgl-pipes",i.WebGLPipesAdaptor="webgl-pipes-adaptor",i.WebGLSystem="webgl-system",i.WebGLLoader="webgl-loader",i.WebGPUPipes="webgpu-pipes",i.WebGPUPipesAdaptor="webgpu-pipes-adaptor",i.WebGPUSystem="webgpu-system",i.WebGPULoader="webgpu-loader",i.CanvasSystem="canvas-system",i.CanvasPipesAdaptor="canvas-pipes-adaptor",i.CanvasPipes="canvas-pipes",i.CanvasLoader="canvas-loader",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.TextureUploaderWebGL="texture-uploader-webgl",i.TextureUploaderWebGPU="texture-uploader-webgpu",i.Environment="environment",i.ShapeBuilder="shape-builder",i.Batcher="batcher",i))(S||{});const Ln=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},Ks=(i,e)=>Ln(i).priority??e,q={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...i){return i.map(Ln).forEach(e=>{e.type.forEach(t=>this._removeHandlers[t]?.(e))}),this},add(...i){return i.map(Ln).forEach(e=>{e.type.forEach(t=>{const s=this._addHandlers,r=this._queue;s[t]?s[t]?.(e):(r[t]=r[t]||[],r[t]?.push(e))})}),this},handle(i,e,t){const s=this._addHandlers,r=this._removeHandlers;if(s[i]||r[i])throw new Error(`Extension type ${i} already has a handler`);s[i]=e,r[i]=t;const n=this._queue;return n[i]&&(n[i]?.forEach(o=>e(o)),delete n[i]),this},handleByMap(i,e){return this.handle(i,t=>{t.name&&(e[t.name]=t.ref)},t=>{t.name&&delete e[t.name]})},handleByNamedList(i,e,t=-1){return this.handle(i,s=>{e.findIndex(n=>n.name===s.name)>=0||(e.push({name:s.name,value:s.ref}),e.sort((n,o)=>Ks(o.value,t)-Ks(n.value,t)))},s=>{const r=e.findIndex(n=>n.name===s.name);r!==-1&&e.splice(r,1)})},handleByList(i,e,t=-1){return this.handle(i,s=>{e.includes(s.ref)||(e.push(s.ref),e.sort((r,n)=>Ks(n,t)-Ks(r,t)))},s=>{const r=e.indexOf(s.ref);r!==-1&&e.splice(r,1)})},mixin(i,...e){for(const t of e)Object.defineProperties(i.prototype,Object.getOwnPropertyDescriptors(t))}},gu={extension:{type:S.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await St(()=>import("./browserAll-DpEOVFXE.js"),__vite__mapDeps([0,1]))}},_u={extension:{type:S.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await St(()=>import("./webworkerAll-BIhfsOqG.js"),[])}};class Ce{constructor(e,t,s){this._x=t||0,this._y=s||0,this._observer=e}clone(e){return new Ce(e??this._observer,this._x,this._y)}set(e=0,t=e){return(this._x!==e||this._y!==t)&&(this._x=e,this._y=t,this._observer._onUpdate(this)),this}copyFrom(e){return(this._x!==e.x||this._y!==e.y)&&(this._x=e.x,this._y=e.y,this._observer._onUpdate(this)),this}copyTo(e){return e.set(this._x,this._y),e}equals(e){return e.x===this._x&&e.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(e){this._x!==e&&(this._x=e,this._observer._onUpdate(this))}get y(){return this._y}set y(e){this._y!==e&&(this._y=e,this._observer._onUpdate(this))}}function Lg(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Qr={exports:{}},xh;function Ug(){return xh||(xh=1,(function(i){var e=Object.prototype.hasOwnProperty,t="~";function s(){}Object.create&&(s.prototype=Object.create(null),new s().__proto__||(t=!1));function r(l,h,c){this.fn=l,this.context=h,this.once=c||!1}function n(l,h,c,u,d){if(typeof c!="function")throw new TypeError("The listener must be a function");var f=new r(c,u||l,d),p=t?t+h:h;return l._events[p]?l._events[p].fn?l._events[p]=[l._events[p],f]:l._events[p].push(f):(l._events[p]=f,l._eventsCount++),l}function o(l,h){--l._eventsCount===0?l._events=new s:delete l._events[h]}function a(){this._events=new s,this._eventsCount=0}a.prototype.eventNames=function(){var h=[],c,u;if(this._eventsCount===0)return h;for(u in c=this._events)e.call(c,u)&&h.push(t?u.slice(1):u);return Object.getOwnPropertySymbols?h.concat(Object.getOwnPropertySymbols(c)):h},a.prototype.listeners=function(h){var c=t?t+h:h,u=this._events[c];if(!u)return[];if(u.fn)return[u.fn];for(var d=0,f=u.length,p=new Array(f);d<f;d++)p[d]=u[d].fn;return p},a.prototype.listenerCount=function(h){var c=t?t+h:h,u=this._events[c];return u?u.fn?1:u.length:0},a.prototype.emit=function(h,c,u,d,f,p){var g=t?t+h:h;if(!this._events[g])return!1;var m=this._events[g],_=arguments.length,y,x;if(m.fn){switch(m.once&&this.removeListener(h,m.fn,void 0,!0),_){case 1:return m.fn.call(m.context),!0;case 2:return m.fn.call(m.context,c),!0;case 3:return m.fn.call(m.context,c,u),!0;case 4:return m.fn.call(m.context,c,u,d),!0;case 5:return m.fn.call(m.context,c,u,d,f),!0;case 6:return m.fn.call(m.context,c,u,d,f,p),!0}for(x=1,y=new Array(_-1);x<_;x++)y[x-1]=arguments[x];m.fn.apply(m.context,y)}else{var b=m.length,v;for(x=0;x<b;x++)switch(m[x].once&&this.removeListener(h,m[x].fn,void 0,!0),_){case 1:m[x].fn.call(m[x].context);break;case 2:m[x].fn.call(m[x].context,c);break;case 3:m[x].fn.call(m[x].context,c,u);break;case 4:m[x].fn.call(m[x].context,c,u,d);break;default:if(!y)for(v=1,y=new Array(_-1);v<_;v++)y[v-1]=arguments[v];m[x].fn.apply(m[x].context,y)}}return!0},a.prototype.on=function(h,c,u){return n(this,h,c,u,!1)},a.prototype.once=function(h,c,u){return n(this,h,c,u,!0)},a.prototype.removeListener=function(h,c,u,d){var f=t?t+h:h;if(!this._events[f])return this;if(!c)return o(this,f),this;var p=this._events[f];if(p.fn)p.fn===c&&(!d||p.once)&&(!u||p.context===u)&&o(this,f);else{for(var g=0,m=[],_=p.length;g<_;g++)(p[g].fn!==c||d&&!p[g].once||u&&p[g].context!==u)&&m.push(p[g]);m.length?this._events[f]=m.length===1?m[0]:m:o(this,f)}return this},a.prototype.removeAllListeners=function(h){var c;return h?(c=t?t+h:h,this._events[c]&&o(this,c)):(this._events=new s,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=t,a.EventEmitter=a,i.exports=a})(Qr)),Qr.exports}var Ng=Ug();const Re=Lg(Ng),yu=Math.PI*2,xu=180/Math.PI,bu=Math.PI/180;class he{constructor(e=0,t=0){this.x=0,this.y=0,this.x=e,this.y=t}clone(){return new he(this.x,this.y)}copyFrom(e){return this.set(e.x,e.y),this}copyTo(e){return e.set(this.x,this.y),e}equals(e){return e.x===this.x&&e.y===this.y}set(e=0,t=e){return this.x=e,this.y=t,this}toString(){return`[pixi.js/math:Point x=${this.x} y=${this.y}]`}static get shared(){return Jr.x=0,Jr.y=0,Jr}}const Jr=new he;class U{constructor(e=1,t=0,s=0,r=1,n=0,o=0){this.array=null,this.a=e,this.b=t,this.c=s,this.d=r,this.tx=n,this.ty=o}fromArray(e){this.a=e[0],this.b=e[1],this.c=e[3],this.d=e[4],this.tx=e[2],this.ty=e[5]}set(e,t,s,r,n,o){return this.a=e,this.b=t,this.c=s,this.d=r,this.tx=n,this.ty=o,this}toArray(e,t){this.array||(this.array=new Float32Array(9));const s=t||this.array;return e?(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(e,t){t=t||new he;const s=e.x,r=e.y;return t.x=this.a*s+this.c*r+this.tx,t.y=this.b*s+this.d*r+this.ty,t}applyInverse(e,t){t=t||new he;const s=this.a,r=this.b,n=this.c,o=this.d,a=this.tx,l=this.ty,h=1/(s*o+n*-r),c=e.x,u=e.y;return t.x=o*h*c+-n*h*u+(l*n-a*o)*h,t.y=s*h*u+-r*h*c+(-l*s+a*r)*h,t}translate(e,t){return this.tx+=e,this.ty+=t,this}scale(e,t){return this.a*=e,this.d*=t,this.c*=e,this.b*=t,this.tx*=e,this.ty*=t,this}rotate(e){const t=Math.cos(e),s=Math.sin(e),r=this.a,n=this.c,o=this.tx;return this.a=r*t-this.b*s,this.b=r*s+this.b*t,this.c=n*t-this.d*s,this.d=n*s+this.d*t,this.tx=o*t-this.ty*s,this.ty=o*s+this.ty*t,this}append(e){const t=this.a,s=this.b,r=this.c,n=this.d;return this.a=e.a*t+e.b*r,this.b=e.a*s+e.b*n,this.c=e.c*t+e.d*r,this.d=e.c*s+e.d*n,this.tx=e.tx*t+e.ty*r+this.tx,this.ty=e.tx*s+e.ty*n+this.ty,this}appendFrom(e,t){const s=e.a,r=e.b,n=e.c,o=e.d,a=e.tx,l=e.ty,h=t.a,c=t.b,u=t.c,d=t.d;return this.a=s*h+r*u,this.b=s*c+r*d,this.c=n*h+o*u,this.d=n*c+o*d,this.tx=a*h+l*u+t.tx,this.ty=a*c+l*d+t.ty,this}setTransform(e,t,s,r,n,o,a,l,h){return this.a=Math.cos(a+h)*n,this.b=Math.sin(a+h)*n,this.c=-Math.sin(a-l)*o,this.d=Math.cos(a-l)*o,this.tx=e-(s*this.a+r*this.c),this.ty=t-(s*this.b+r*this.d),this}prepend(e){const t=this.tx;if(e.a!==1||e.b!==0||e.c!==0||e.d!==1){const s=this.a,r=this.c;this.a=s*e.a+this.b*e.c,this.b=s*e.b+this.b*e.d,this.c=r*e.a+this.d*e.c,this.d=r*e.b+this.d*e.d}return this.tx=t*e.a+this.ty*e.c+e.tx,this.ty=t*e.b+this.ty*e.d+e.ty,this}decompose(e){const t=this.a,s=this.b,r=this.c,n=this.d,o=e.pivot,a=-Math.atan2(-r,n),l=Math.atan2(s,t),h=Math.abs(a+l);let c=Math.sqrt(t*t+s*s);return h<1e-5||Math.abs(yu-h)<1e-5?(e.rotation=l,e.skew.x=e.skew.y=0):Math.abs(Math.PI-h)<1e-5?(e.rotation=l-Math.PI,e.skew.x=e.skew.y=0,c=-c):(e.rotation=0,e.skew.x=a,e.skew.y=l),e.scale.x=c,e.scale.y=Math.sqrt(r*r+n*n),e.position.x=this.tx+(o.x*t+o.y*r),e.position.y=this.ty+(o.x*s+o.y*n),e}invert(){const e=this.a,t=this.b,s=this.c,r=this.d,n=this.tx,o=e*r-t*s;return this.a=r/o,this.b=-t/o,this.c=-s/o,this.d=e/o,this.tx=(s*this.ty-r*n)/o,this.ty=-(e*this.ty-t*n)/o,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 e=new U;return e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.tx=this.tx,e.ty=this.ty,e}copyTo(e){return e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.tx=this.tx,e.ty=this.ty,e}copyFrom(e){return this.a=e.a,this.b=e.b,this.c=e.c,this.d=e.d,this.tx=e.tx,this.ty=e.ty,this}equals(e){return e.a===this.a&&e.b===this.b&&e.c===this.c&&e.d===this.d&&e.tx===this.tx&&e.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 zg.identity()}static get shared(){return Hg.identity()}}const Hg=new U,zg=new U,Ht=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],zt=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],Wt=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],$t=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],Un=[],vu=[],Ci=Math.sign;function Wg(){for(let i=0;i<16;i++){const e=[];Un.push(e);for(let t=0;t<16;t++){const s=Ci(Ht[i]*Ht[t]+Wt[i]*zt[t]),r=Ci(zt[i]*Ht[t]+$t[i]*zt[t]),n=Ci(Ht[i]*Wt[t]+Wt[i]*$t[t]),o=Ci(zt[i]*Wt[t]+$t[i]*$t[t]);for(let a=0;a<16;a++)if(Ht[a]===s&&zt[a]===r&&Wt[a]===n&&$t[a]===o){e.push(a);break}}}for(let i=0;i<16;i++){const e=new U;e.set(Ht[i],zt[i],Wt[i],$t[i],0,0),vu.push(e)}}Wg();const Z={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=>Ht[i],uY:i=>zt[i],vX:i=>Wt[i],vY:i=>$t[i],inv:i=>i&8?i&15:-i&7,add:(i,e)=>Un[i][e],sub:(i,e)=>Un[i][Z.inv(e)],rotate180:i=>i^4,isVertical:i=>(i&3)===2,byDirection:(i,e)=>Math.abs(i)*2<=Math.abs(e)?e>=0?Z.S:Z.N:Math.abs(e)*2<=Math.abs(i)?i>0?Z.E:Z.W:e>0?i>0?Z.SE:Z.SW:i>0?Z.NE:Z.NW,matrixAppendRotationInv:(i,e,t=0,s=0,r=0,n=0)=>{const o=vu[Z.inv(e)],a=o.a,l=o.b,h=o.c,c=o.d,u=t-Math.min(0,a*r,h*n,a*r+h*n),d=s-Math.min(0,l*r,c*n,l*r+c*n),f=i.a,p=i.b,g=i.c,m=i.d;i.a=a*f+l*g,i.b=a*p+l*m,i.c=h*f+c*g,i.d=h*p+c*m,i.tx=u*f+d*g+i.tx,i.ty=u*p+d*m+i.ty},transformRectCoords:(i,e,t,s)=>{const{x:r,y:n,width:o,height:a}=i,{x:l,y:h,width:c,height:u}=e;return t===Z.E?(s.set(r+l,n+h,o,a),s):t===Z.S?s.set(c-n-a+l,r+h,a,o):t===Z.W?s.set(c-r-o+l,u-n-a+h,o,a):t===Z.N?s.set(n+l,u-r-o+h,a,o):s.set(r+l,n+h,o,a)}},Mi=[new he,new he,new he,new he];class te{constructor(e=0,t=0,s=0,r=0){this.type="rectangle",this.x=Number(e),this.y=Number(t),this.width=Number(s),this.height=Number(r)}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 te(0,0,0,0)}clone(){return new te(this.x,this.y,this.width,this.height)}copyFromBounds(e){return this.x=e.minX,this.y=e.minY,this.width=e.maxX-e.minX,this.height=e.maxY-e.minY,this}copyFrom(e){return this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this}copyTo(e){return e.copyFrom(this),e}contains(e,t){return this.width<=0||this.height<=0?!1:e>=this.x&&e<this.x+this.width&&t>=this.y&&t<this.y+this.height}strokeContains(e,t,s,r=.5){const{width:n,height:o}=this;if(n<=0||o<=0)return!1;const a=this.x,l=this.y,h=s*(1-r),c=s-h,u=a-h,d=a+n+h,f=l-h,p=l+o+h,g=a+c,m=a+n-c,_=l+c,y=l+o-c;return e>=u&&e<=d&&t>=f&&t<=p&&!(e>g&&e<m&&t>_&&t<y)}intersects(e,t){if(!t){const k=this.x<e.x?e.x:this.x;if((this.right>e.right?e.right:this.right)<=k)return!1;const A=this.y<e.y?e.y:this.y;return(this.bottom>e.bottom?e.bottom:this.bottom)>A}const s=this.left,r=this.right,n=this.top,o=this.bottom;if(r<=s||o<=n)return!1;const a=Mi[0].set(e.left,e.top),l=Mi[1].set(e.left,e.bottom),h=Mi[2].set(e.right,e.top),c=Mi[3].set(e.right,e.bottom);if(h.x<=a.x||l.y<=a.y)return!1;const u=Math.sign(t.a*t.d-t.b*t.c);if(u===0||(t.apply(a,a),t.apply(l,l),t.apply(h,h),t.apply(c,c),Math.max(a.x,l.x,h.x,c.x)<=s||Math.min(a.x,l.x,h.x,c.x)>=r||Math.max(a.y,l.y,h.y,c.y)<=n||Math.min(a.y,l.y,h.y,c.y)>=o))return!1;const d=u*(l.y-a.y),f=u*(a.x-l.x),p=d*s+f*n,g=d*r+f*n,m=d*s+f*o,_=d*r+f*o;if(Math.max(p,g,m,_)<=d*a.x+f*a.y||Math.min(p,g,m,_)>=d*c.x+f*c.y)return!1;const y=u*(a.y-h.y),x=u*(h.x-a.x),b=y*s+x*n,v=y*r+x*n,w=y*s+x*o,T=y*r+x*o;return!(Math.max(b,v,w,T)<=y*a.x+x*a.y||Math.min(b,v,w,T)>=y*c.x+x*c.y)}pad(e=0,t=e){return this.x-=e,this.y-=t,this.width+=e*2,this.height+=t*2,this}fit(e){const t=Math.max(this.x,e.x),s=Math.min(this.x+this.width,e.x+e.width),r=Math.max(this.y,e.y),n=Math.min(this.y+this.height,e.y+e.height);return this.x=t,this.width=Math.max(s-t,0),this.y=r,this.height=Math.max(n-r,0),this}ceil(e=1,t=.001){const s=Math.ceil((this.x+this.width-t)*e)/e,r=Math.ceil((this.y+this.height-t)*e)/e;return this.x=Math.floor((this.x+t)*e)/e,this.y=Math.floor((this.y+t)*e)/e,this.width=s-this.x,this.height=r-this.y,this}scale(e,t=e){return this.x*=e,this.y*=t,this.width*=e,this.height*=t,this}enlarge(e){const t=Math.min(this.x,e.x),s=Math.max(this.x+this.width,e.x+e.width),r=Math.min(this.y,e.y),n=Math.max(this.y+this.height,e.y+e.height);return this.x=t,this.width=s-t,this.y=r,this.height=n-r,this}getBounds(e){return e||(e=new te),e.copyFrom(this),e}containsRect(e){if(this.width<=0||this.height<=0)return!1;const t=e.x,s=e.y,r=e.x+e.width,n=e.y+e.height;return t>=this.x&&t<this.x+this.width&&s>=this.y&&s<this.y+this.height&&r>=this.x&&r<=this.x+this.width&&n>=this.y&&n<=this.y+this.height}set(e,t,s,r){return this.x=e,this.y=t,this.width=s,this.height=r,this}toString(){return`[pixi.js/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`}}const en={default:-1};function oe(i="default"){return en[i]===void 0&&(en[i]=-1),++en[i]}const bh=new Set,ue="8.0.0",wu="8.3.4",ht="8.21.0",Tu="8.22.0",vs={quiet:!1,noColor:!1},H=((i,e,t=3)=>{if(vs.quiet||bh.has(e))return;let s=new Error().stack;const r=`${e}
3
3
  Deprecated since v${i}`,n=typeof console.groupCollapsed=="function"&&!vs.noColor;typeof s>"u"?console.warn("PixiJS Deprecation Warning: ",r):(s=s.split(`
4
4
  `).splice(t).join(`
5
5
  `),n?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",r),console.warn(s),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",r),console.warn(s))),bh.add(e)});Object.defineProperties(H,{quiet:{get:()=>vs.quiet,set:i=>{vs.quiet=i},enumerable:!0,configurable:!1},noColor:{get:()=>vs.noColor,set:i=>{vs.noColor=i},enumerable:!0,configurable:!1}});const Oo=()=>{};function ir(i){return i.endsWith("int")}function es(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 ts(i){return!(i&i-1)&&!!i}function Lo(i){const e={};for(const t in i)i[t]!==void 0&&(e[t]=i[t]);return e}const vh=Object.create(null);function $g(i){const e=vh[i];return e===void 0&&(vh[i]=oe("resource")),e}const Su=class Cu extends Re{constructor(e={}){super(),this._resourceType="textureSampler",this._maxAnisotropy=1,this.destroyed=!1,e={...Cu.defaultOptions,...e},this.addressMode=e.addressMode,this.addressModeU=e.addressModeU??this.addressModeU,this.addressModeV=e.addressModeV??this.addressModeV,this.addressModeW=e.addressModeW??this.addressModeW,this.scaleMode=e.scaleMode,this.magFilter=e.magFilter??this.magFilter,this.minFilter=e.minFilter??this.minFilter,this.mipmapFilter=e.mipmapFilter??this.mipmapFilter,this.lodMinClamp=e.lodMinClamp,this.lodMaxClamp=e.lodMaxClamp,this.compare=e.compare,this.maxAnisotropy=e.maxAnisotropy??1}set addressMode(e){this.addressModeU=e,this.addressModeV=e,this.addressModeW=e}get addressMode(){return this.addressModeU}set wrapMode(e){H(ue,"TextureStyle.wrapMode is now TextureStyle.addressMode"),this.addressMode=e}get wrapMode(){return this.addressMode}set scaleMode(e){this.magFilter=e,this.minFilter=e,this.mipmapFilter=e}get scaleMode(){return this.magFilter}set maxAnisotropy(e){this._maxAnisotropy=Math.min(e,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 e=`${this.addressModeU}-${this.addressModeV}-${this.addressModeW}-${this.magFilter}-${this.minFilter}-${this.mipmapFilter}-${this.lodMinClamp}-${this.lodMaxClamp}-${this.compare}-${this._maxAnisotropy}`;return this._sharedResourceId=$g(e),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};Su.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let Dt=Su;const Mu=class ku extends Re{constructor(e={}){super(),this.options=e,this._gpuData=Object.create(null),this._gcLastUsed=-1,this.uid=oe("textureSource"),this._resourceType="textureSource",this._resourceId=oe("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.depth=1,this._ownsStyle=!1,this.antialias=!1,this.transient=!1,this.storage=!1,this._batchTick=-1,this._textureBindLocation=-1;const t=e;e={...ku.defaultOptions,...e};const s=Vg(e),r=s==="3d"||s==="1d"?s:"2d";jg(t,s,r),this.label=e.label??"",this.resource=e.resource,this.autoGarbageCollect=e.autoGarbageCollect,this._resolution=e.resolution,e.width?this.pixelWidth=e.width*this._resolution:this.pixelWidth=this.resource?this.resourceWidth??1:1,e.height?this.pixelHeight=e.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=e.format,this.dimension=r,this.viewDimension=s,this.arrayLayerCount=e.arrayLayerCount,this.depth=r==="3d"?e.depth??1:1,this.mipLevelCount=e.mipLevelCount,this.autoGenerateMipmaps=e.autoGenerateMipmaps,this.sampleCount=e.sampleCount,this.antialias=r==="3d"?!1:e.antialias,this.transient=e.transient??!1,this.storage=e.storage??!1,this.alphaMode=e.alphaMode,this.style=new Dt(Lo(e)),this._ownsStyle=!0,this.destroyed=!1,this._refreshPOT()}get depthOrArrayLayers(){return this.dimension==="3d"?this.depth:this.arrayLayerCount||1}get source(){return this}get style(){return this._style}set style(e){this.style!==e&&(this._ownsStyle=!1,this._style?.off("change",this._onStyleChange,this),this._style=e,this._style?.on("change",this._onStyleChange,this),this._onStyleChange())}set maxAnisotropy(e){this._style.maxAnisotropy=e}get maxAnisotropy(){return this._style.maxAnisotropy}get addressMode(){return this._style.addressMode}set addressMode(e){this._style.addressMode=e}get repeatMode(){return this._style.addressMode}set repeatMode(e){this._style.addressMode=e}get magFilter(){return this._style.magFilter}set magFilter(e){this._style.magFilter=e}get minFilter(){return this._style.minFilter}set minFilter(e){this._style.minFilter=e}get mipmapFilter(){return this._style.mipmapFilter}set mipmapFilter(e){this._style.mipmapFilter=e}get lodMinClamp(){return this._style.lodMinClamp}set lodMinClamp(e){this._style.lodMinClamp=e}get lodMaxClamp(){return this._style.lodMaxClamp}set lodMaxClamp(e){this._style.lodMaxClamp=e}_onStyleChange(){this.emit("styleChange",this)}update(){if(this.resource){const e=this._resolution;if(this.resize(this.resourceWidth/e,this.resourceHeight/e))return}this.emit("update",this)}destroy(){this.destroyed=!0,this.unload(),this.emit("destroy",this),this._style&&(this._ownsStyle&&this._style.destroy(),this._style=null),this.uploadMethodId=null,this.resource=null,this.removeAllListeners()}unload(){this._resourceId=oe("resource"),this.emit("change",this),this.emit("unload",this);for(const e in this._gpuData)this._gpuData[e]?.destroy?.();this._gpuData=Object.create(null)}get resourceWidth(){const{resource:e}=this;return e.naturalWidth||e.videoWidth||e.displayWidth||e.width}get resourceHeight(){const{resource:e}=this;return e.naturalHeight||e.videoHeight||e.displayHeight||e.height}get resolution(){return this._resolution}set resolution(e){this._resolution!==e&&(this._resolution=e,this.width=this.pixelWidth/e,this.height=this.pixelHeight/e)}resize(e,t,s){s||(s=this._resolution),e||(e=this.width),t||(t=this.height);const r=Math.round(e*s),n=Math.round(t*s);return this.width=r/s,this.height=n/s,this._resolution=s,this.pixelWidth===r&&this.pixelHeight===n?!1:(this._refreshPOT(),this.pixelWidth=r,this.pixelHeight=n,this.emit("resize",this),this._resourceId=oe("resource"),this.emit("change",this),!0)}updateMipmaps(){this.autoGenerateMipmaps&&this.mipLevelCount>1&&this.emit("updateMipmaps",this)}set wrapMode(e){this._style.wrapMode=e}get wrapMode(){return this._style.wrapMode}set scaleMode(e){this._style.scaleMode=e}get scaleMode(){return this._style.scaleMode}_refreshPOT(){this.isPowerOfTwo=ts(this.pixelWidth)&&ts(this.pixelHeight)}static test(e){throw new Error("Unimplemented")}};Mu.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",arrayLayerCount:1,mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};let de=Mu;function Vg(i){return i.viewDimension?i.viewDimension:i.depth?"3d":i.arrayLayerCount>1?"2d-array":"2d"}function jg(i,e,t){if(i.depth!==void 0&&typeof i.depth!="number")throw new Error(`[TextureSource] depth is a 3D texture's depth in texels, but got ${i.depth}. For a depth buffer, use the depth option of a RenderTarget or the renderer.`);if(i.depth&&i.arrayLayerCount>1)throw new Error("[TextureSource] depth and arrayLayerCount can't be combined: use depth for a 3D texture or arrayLayerCount for a 2D array.");if(i.depth&&e!=="3d")throw new Error(`[TextureSource] depth makes a 3D texture, but viewDimension is '${e}'. Use arrayLayerCount for layered textures.`);if(e==="3d"&&i.arrayLayerCount>1)throw new Error("[TextureSource] a 3D texture takes depth, not arrayLayerCount.");if(i.dimensions&&i.dimensions!==t)throw new Error(`[TextureSource] dimensions '${i.dimensions}' doesn't match viewDimension '${e}'. Leave dimensions out; it is derived from the view.`);if(i.dimensions&&H(Tu,"TextureSource dimensions is derived from viewDimension and depth; leave it out."),t==="3d"&&i.antialias)throw new Error("[TextureSource] a 3D texture can't be antialiased: WebGPU has no multisampled 3D textures.")}class gr extends de{constructor(e){const t=e.depth??e.arrayLayerCount??1,s=e.resource||new Float32Array(e.width*e.height*t*4);let r=e.format;r||(s instanceof Float32Array?r="rgba32float":s instanceof Int32Array||s instanceof Uint32Array?r="rgba32uint":s instanceof Int16Array||s instanceof Uint16Array?r="rgba16uint":(s instanceof Int8Array,r="bgra8unorm"));const n=ir(r)||t>1;super({...n&&{alphaMode:"no-premultiply-alpha"},...e,resource:s,format:r}),this.uploadMethodId="buffer",this._updateStart=0,this._updateEnd=1/0}update(e=0,t=1/0){if((e>0||t<1/0)&&this.depthOrArrayLayers>1)throw new Error("[BufferImageSource] a 3D texture or 2D array uploads whole: call update() with no range.");this._updateStart=e,this._updateEnd=t,super.update(),this._updateStart=0,this._updateEnd=1/0}static test(e){return e instanceof Int8Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array}}gr.extension=S.TextureSource;const wh=new U;class Uo{constructor(e,t){this.mapCoord=new U,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._updateID=0,this.clampOffset=0,typeof t>"u"?this.clampMargin=e.width<10?0:.5:this.clampMargin=t,this.isSimple=!1,this.texture=e}get texture(){return this._texture}set texture(e){this._texture!==e&&(this._texture?.removeListener("update",this.update,this),this._texture=e,this._texture.addListener("update",this.update,this)),this.update()}destroy(){this._texture?.removeListener("update",this.update,this),this._texture=null}multiplyUvs(e,t){t===void 0&&(t=e);const s=this.mapCoord;for(let r=0;r<e.length;r+=2){const n=e[r],o=e[r+1];t[r]=n*s.a+o*s.c+s.tx,t[r+1]=n*s.b+o*s.d+s.ty}return t}update(){const e=this._texture;this._updateID++;const t=e.uvs;this.mapCoord.set(t.x1-t.x0,t.y1-t.y0,t.x3-t.x0,t.y3-t.y0,t.x0,t.y0);const s=e.orig,r=e.trim;r&&(wh.set(s.width/r.width,0,0,s.height/r.height,-r.x/r.width,-r.y/r.height),this.mapCoord.append(wh));const n=e.source,o=this.uClampFrame,a=this.clampMargin/n._resolution,l=this.clampOffset/n._resolution;return o[0]=(e.frame.x+a+l)/n.width,o[1]=(e.frame.y+a+l)/n.height,o[2]=(e.frame.x+e.frame.width-a+l)/n.width,o[3]=(e.frame.y+e.frame.height-a+l)/n.height,this.uClampOffset[0]=this.clampOffset/n.pixelWidth,this.uClampOffset[1]=this.clampOffset/n.pixelHeight,this.isSimple=e.frame.width===n.width&&e.frame.height===n.height&&e.rotate===0,!0}}class W extends Re{constructor({source:e,label:t,frame:s,orig:r,trim:n,defaultAnchor:o,defaultBorders:a,rotate:l,dynamic:h}={}){if(super(),this.uid=oe("texture"),this.uvs={x0:0,y0:0,x1:0,y1:0,x2:0,y2:0,x3:0,y3:0},this.frame=new te,this.noFrame=!1,this.dynamic=!1,this.isTexture=!0,this.label=t,this.source=e?.source??new de,this.noFrame=!s,s)this.frame.copyFrom(s);else{const{width:c,height:u}=this._source;this.frame.width=c,this.frame.height=u}this.orig=r||this.frame,this.trim=n,this.rotate=l??0,this.defaultAnchor=o,this.defaultBorders=a,this.destroyed=!1,this.dynamic=h||!1,this.updateUvs()}set source(e){this._source&&this._source.off("resize",this.update,this),this._source=e,e.on("resize",this.update,this),this.emit("update",this)}get source(){return this._source}get textureMatrix(){return this._textureMatrix||(this._textureMatrix=new Uo(this)),this._textureMatrix}get width(){return this.orig.width}get height(){return this.orig.height}updateUvs(){const{uvs:e,frame:t}=this,{width:s,height:r}=this._source,n=t.x/s,o=t.y/r,a=t.width/s,l=t.height/r;let h=this.rotate;if(h){const c=a/2,u=l/2,d=n+c,f=o+u;h=Z.add(h,Z.NW),e.x0=d+c*Z.uX(h),e.y0=f+u*Z.uY(h),h=Z.add(h,2),e.x1=d+c*Z.uX(h),e.y1=f+u*Z.uY(h),h=Z.add(h,2),e.x2=d+c*Z.uX(h),e.y2=f+u*Z.uY(h),h=Z.add(h,2),e.x3=d+c*Z.uX(h),e.y3=f+u*Z.uY(h)}else e.x0=n,e.y0=o,e.x1=n+a,e.y1=o,e.x2=n+a,e.y2=o+l,e.x3=n,e.y3=o+l}destroy(e=!1){this._source&&(this._source.off("resize",this.update,this),e&&(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 H(ue,"Texture.baseTexture is now Texture.source"),this._source}}W.EMPTY=new W({label:"EMPTY",source:new de({label:"EMPTY"})});W.EMPTY.destroy=Oo;W.WHITE=new W({source:new gr({resource:new Uint8Array([255,255,255,255]),width:1,height:1,alphaMode:"premultiply-alpha-on-upload",label:"WHITE"}),label:"WHITE"});W.WHITE.destroy=Oo;function No(i,e,t){const{width:s,height:r}=t.orig,n=t.trim;if(n){const o=n.width,a=n.height;i.minX=n.x-e._x*s,i.maxX=i.minX+o,i.minY=n.y-e._y*r,i.maxY=i.minY+a}else i.minX=-e._x*s,i.maxX=i.minX+s,i.minY=-e._y*r,i.maxY=i.minY+r}const Th=new U;class Ee{constructor(e=1/0,t=1/0,s=-1/0,r=-1/0){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=Th,this.minX=e,this.minY=t,this.maxX=s,this.maxY=r}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new te);const e=this._rectangle;return this.minX>this.maxX||this.minY>this.maxY?(e.x=0,e.y=0,e.width=0,e.height=0):e.copyFromBounds(this),e}clear(){return this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=Th,this}set(e,t,s,r){this.minX=e,this.minY=t,this.maxX=s,this.maxY=r}addFrame(e,t,s,r,n){n||(n=this.matrix);const o=n.a,a=n.b,l=n.c,h=n.d,c=n.tx,u=n.ty;let d=this.minX,f=this.minY,p=this.maxX,g=this.maxY,m=o*e+l*t+c,_=a*e+h*t+u;m<d&&(d=m),_<f&&(f=_),m>p&&(p=m),_>g&&(g=_),m=o*s+l*t+c,_=a*s+h*t+u,m<d&&(d=m),_<f&&(f=_),m>p&&(p=m),_>g&&(g=_),m=o*e+l*r+c,_=a*e+h*r+u,m<d&&(d=m),_<f&&(f=_),m>p&&(p=m),_>g&&(g=_),m=o*s+l*r+c,_=a*s+h*r+u,m<d&&(d=m),_<f&&(f=_),m>p&&(p=m),_>g&&(g=_),this.minX=d,this.minY=f,this.maxX=p,this.maxY=g}addRect(e,t){this.addFrame(e.x,e.y,e.x+e.width,e.y+e.height,t)}addBounds(e,t){this.addFrame(e.minX,e.minY,e.maxX,e.maxY,t)}addBoundsMask(e){this.minX=this.minX>e.minX?this.minX:e.minX,this.minY=this.minY>e.minY?this.minY:e.minY,this.maxX=this.maxX<e.maxX?this.maxX:e.maxX,this.maxY=this.maxY<e.maxY?this.maxY:e.maxY}applyMatrix(e){const t=this.minX,s=this.minY,r=this.maxX,n=this.maxY,{a:o,b:a,c:l,d:h,tx:c,ty:u}=e;let d=o*t+l*s+c,f=a*t+h*s+u;this.minX=d,this.minY=f,this.maxX=d,this.maxY=f,d=o*r+l*s+c,f=a*r+h*s+u,this.minX=d<this.minX?d:this.minX,this.minY=f<this.minY?f:this.minY,this.maxX=d>this.maxX?d:this.maxX,this.maxY=f>this.maxY?f:this.maxY,d=o*t+l*n+c,f=a*t+h*n+u,this.minX=d<this.minX?d:this.minX,this.minY=f<this.minY?f:this.minY,this.maxX=d>this.maxX?d:this.maxX,this.maxY=f>this.maxY?f:this.maxY,d=o*r+l*n+c,f=a*r+h*n+u,this.minX=d<this.minX?d:this.minX,this.minY=f<this.minY?f:this.minY,this.maxX=d>this.maxX?d:this.maxX,this.maxY=f>this.maxY?f:this.maxY}fit(e){return this.minX<e.left&&(this.minX=e.left),this.maxX>e.right&&(this.maxX=e.right),this.minY<e.top&&(this.minY=e.top),this.maxY>e.bottom&&(this.maxY=e.bottom),this}fitBounds(e,t,s,r){return this.minX<e&&(this.minX=e),this.maxX>t&&(this.maxX=t),this.minY<s&&(this.minY=s),this.maxY>r&&(this.maxY=r),this}pad(e,t=e){return this.minX-=e,this.maxX+=e,this.minY-=t,this.maxY+=t,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 Ee(this.minX,this.minY,this.maxX,this.maxY)}scale(e,t=e){return this.minX*=e,this.minY*=t,this.maxX*=e,this.maxY*=t,this}get x(){return this.minX}set x(e){const t=this.maxX-this.minX;this.minX=e,this.maxX=e+t}get y(){return this.minY}set y(e){const t=this.maxY-this.minY;this.minY=e,this.maxY=e+t}get width(){return this.maxX-this.minX}set width(e){this.maxX=this.minX+e}get height(){return this.maxY-this.minY}set height(e){this.maxY=this.minY+e}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(e,t,s,r){let n=this.minX,o=this.minY,a=this.maxX,l=this.maxY;r||(r=this.matrix);const h=r.a,c=r.b,u=r.c,d=r.d,f=r.tx,p=r.ty;for(let g=t;g<s;g+=2){const m=e[g],_=e[g+1],y=h*m+u*_+f,x=c*m+d*_+p;n=y<n?y:n,o=x<o?x:o,a=y>a?y:a,l=x>l?x:l}this.minX=n,this.minY=o,this.maxX=a,this.maxY=l}containsPoint(e,t){return this.minX<=e&&this.minY<=t&&this.maxX>=e&&this.maxY>=t}toString(){return`[pixi.js:Bounds minX=${this.minX} minY=${this.minY} maxX=${this.maxX} maxY=${this.maxY} width=${this.width} height=${this.height}]`}copyFrom(e){return this.minX=e.minX,this.minY=e.minY,this.maxX=e.maxX,this.maxY=e.maxY,this}}var Xg={grad:.9,turn:360,rad:360/(2*Math.PI)},_t=function(i){return typeof i=="string"?i.length>0:typeof i=="number"},Me=function(i,e,t){return e===void 0&&(e=0),t===void 0&&(t=Math.pow(10,e)),Math.round(t*i)/t+0},Ye=function(i,e,t){return e===void 0&&(e=0),t===void 0&&(t=1),i>t?t:i>e?i:e},Eu=function(i){return(i=isFinite(i)?i%360:0)>0?i:i+360},Sh=function(i){return{r:Ye(i.r,0,255),g:Ye(i.g,0,255),b:Ye(i.b,0,255),a:Ye(i.a)}},tn=function(i){return{r:Me(i.r),g:Me(i.g),b:Me(i.b),a:Me(i.a,3)}},qg=/^#([0-9a-f]{3,8})$/i,ki=function(i){var e=i.toString(16);return e.length<2?"0"+e:e},Pu=function(i){var e=i.r,t=i.g,s=i.b,r=i.a,n=Math.max(e,t,s),o=n-Math.min(e,t,s),a=o?n===e?(t-s)/o:n===t?2+(s-e)/o:4+(e-t)/o:0;return{h:60*(a<0?a+6:a),s:n?o/n*100:0,v:n/255*100,a:r}},Au=function(i){var e=i.h,t=i.s,s=i.v,r=i.a;e=e/360*6,t/=100,s/=100;var n=Math.floor(e),o=s*(1-t),a=s*(1-(e-n)*t),l=s*(1-(1-e+n)*t),h=n%6;return{r:255*[s,a,o,o,l,s][h],g:255*[l,s,s,a,o,o][h],b:255*[o,o,l,s,s,a][h],a:r}},Ch=function(i){return{h:Eu(i.h),s:Ye(i.s,0,100),l:Ye(i.l,0,100),a:Ye(i.a)}},Mh=function(i){return{h:Me(i.h),s:Me(i.s),l:Me(i.l),a:Me(i.a,3)}},kh=function(i){return Au((t=(e=i).s,{h:e.h,s:(t*=((s=e.l)<50?s:100-s)/100)>0?2*t/(s+t)*100:0,v:s+t,a:e.a}));var e,t,s},ei=function(i){return{h:(e=Pu(i)).h,s:(r=(200-(t=e.s))*(s=e.v)/100)>0&&r<200?t*s/100/(r<=100?r:200-r)*100:0,l:r/2,a:e.a};var e,t,s,r},Yg=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Kg=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Zg=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Qg=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Nn={string:[[function(i){var e=qg.exec(i);return e?(i=e[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?Me(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?Me(parseInt(i.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(i){var e=Zg.exec(i)||Qg.exec(i);return e?e[2]!==e[4]||e[4]!==e[6]?null:Sh({r:Number(e[1])/(e[2]?100/255:1),g:Number(e[3])/(e[4]?100/255:1),b:Number(e[5])/(e[6]?100/255:1),a:e[7]===void 0?1:Number(e[7])/(e[8]?100:1)}):null},"rgb"],[function(i){var e=Yg.exec(i)||Kg.exec(i);if(!e)return null;var t,s,r=Ch({h:(t=e[1],s=e[2],s===void 0&&(s="deg"),Number(t)*(Xg[s]||1)),s:Number(e[3]),l:Number(e[4]),a:e[5]===void 0?1:Number(e[5])/(e[6]?100:1)});return kh(r)},"hsl"]],object:[[function(i){var e=i.r,t=i.g,s=i.b,r=i.a,n=r===void 0?1:r;return _t(e)&&_t(t)&&_t(s)?Sh({r:Number(e),g:Number(t),b:Number(s),a:Number(n)}):null},"rgb"],[function(i){var e=i.h,t=i.s,s=i.l,r=i.a,n=r===void 0?1:r;if(!_t(e)||!_t(t)||!_t(s))return null;var o=Ch({h:Number(e),s:Number(t),l:Number(s),a:Number(n)});return kh(o)},"hsl"],[function(i){var e=i.h,t=i.s,s=i.v,r=i.a,n=r===void 0?1:r;if(!_t(e)||!_t(t)||!_t(s))return null;var o=(function(a){return{h:Eu(a.h),s:Ye(a.s,0,100),v:Ye(a.v,0,100),a:Ye(a.a)}})({h:Number(e),s:Number(t),v:Number(s),a:Number(n)});return Au(o)},"hsv"]]},Eh=function(i,e){for(var t=0;t<e.length;t++){var s=e[t][0](i);if(s)return[s,e[t][1]]}return[null,void 0]},Jg=function(i){return typeof i=="string"?Eh(i.trim(),Nn.string):typeof i=="object"&&i!==null?Eh(i,Nn.object):[null,void 0]},sn=function(i,e){var t=ei(i);return{h:t.h,s:Ye(t.s+100*e,0,100),l:t.l,a:t.a}},rn=function(i){return(299*i.r+587*i.g+114*i.b)/1e3/255},Ph=function(i,e){var t=ei(i);return{h:t.h,s:t.s,l:Ye(t.l+100*e,0,100),a:t.a}},Hn=(function(){function i(e){this.parsed=Jg(e)[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 Me(rn(this.rgba),2)},i.prototype.isDark=function(){return rn(this.rgba)<.5},i.prototype.isLight=function(){return rn(this.rgba)>=.5},i.prototype.toHex=function(){return e=tn(this.rgba),t=e.r,s=e.g,r=e.b,o=(n=e.a)<1?ki(Me(255*n)):"","#"+ki(t)+ki(s)+ki(r)+o;var e,t,s,r,n,o},i.prototype.toRgb=function(){return tn(this.rgba)},i.prototype.toRgbString=function(){return e=tn(this.rgba),t=e.r,s=e.g,r=e.b,(n=e.a)<1?"rgba("+t+", "+s+", "+r+", "+n+")":"rgb("+t+", "+s+", "+r+")";var e,t,s,r,n},i.prototype.toHsl=function(){return Mh(ei(this.rgba))},i.prototype.toHslString=function(){return e=Mh(ei(this.rgba)),t=e.h,s=e.s,r=e.l,(n=e.a)<1?"hsla("+t+", "+s+"%, "+r+"%, "+n+")":"hsl("+t+", "+s+"%, "+r+"%)";var e,t,s,r,n},i.prototype.toHsv=function(){return e=Pu(this.rgba),{h:Me(e.h),s:Me(e.s),v:Me(e.v),a:Me(e.a,3)};var e},i.prototype.invert=function(){return ot({r:255-(e=this.rgba).r,g:255-e.g,b:255-e.b,a:e.a});var e},i.prototype.saturate=function(e){return e===void 0&&(e=.1),ot(sn(this.rgba,e))},i.prototype.desaturate=function(e){return e===void 0&&(e=.1),ot(sn(this.rgba,-e))},i.prototype.grayscale=function(){return ot(sn(this.rgba,-1))},i.prototype.lighten=function(e){return e===void 0&&(e=.1),ot(Ph(this.rgba,e))},i.prototype.darken=function(e){return e===void 0&&(e=.1),ot(Ph(this.rgba,-e))},i.prototype.rotate=function(e){return e===void 0&&(e=15),this.hue(this.hue()+e)},i.prototype.alpha=function(e){return typeof e=="number"?ot({r:(t=this.rgba).r,g:t.g,b:t.b,a:e}):Me(this.rgba.a,3);var t},i.prototype.hue=function(e){var t=ei(this.rgba);return typeof e=="number"?ot({h:e,s:t.s,l:t.l,a:t.a}):Me(t.h)},i.prototype.isEqual=function(e){return this.toHex()===ot(e).toHex()},i})(),ot=function(i){return i instanceof Hn?i:new Hn(i)},Ah=[],e_=function(i){i.forEach(function(e){Ah.indexOf(e)<0&&(e(Hn,Nn),Ah.push(e))})};function t_(i,e){var t={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 r in t)s[t[r]]=r;var n={};i.prototype.toName=function(o){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var a,l,h=s[this.toHex()];if(h)return h;if(o?.closest){var c=this.toRgb(),u=1/0,d="black";if(!n.length)for(var f in t)n[f]=new i(t[f]).toRgb();for(var p in t){var g=(a=c,l=n[p],Math.pow(a.r-l.r,2)+Math.pow(a.g-l.g,2)+Math.pow(a.b-l.b,2));g<u&&(u=g,d=p)}return d}},e.string.push([function(o){var a=o.toLowerCase(),l=a==="transparent"?"#0000":t[a];return l?new i(l).toRgb():null},"name"])}e_([t_]);const Cs=class Zs{constructor(e=16777215){this._value=null,this._components=new Float32Array(4),this._components.fill(1),this._int=16777215,this.value=e}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(e){return this.value=e,this}set value(e){if(e instanceof Zs)this._value=this._cloneSource(e._value),this._int=e._int,this._components.set(e._components);else{if(e===null)throw new Error("Cannot set Color#value to null");(this._value===null||!this._isSourceEqual(this._value,e))&&(this._value=this._cloneSource(e),this._normalize(this._value))}}get value(){return this._value}_cloneSource(e){return typeof e=="string"||typeof e=="number"||e instanceof Number||e===null?e:Array.isArray(e)||ArrayBuffer.isView(e)?e.slice(0):typeof e=="object"&&e!==null?{...e}:e}_isSourceEqual(e,t){const s=typeof e;if(s!==typeof t)return!1;if(s==="number"||s==="string"||e instanceof Number)return e===t;if(Array.isArray(e)&&Array.isArray(t)||ArrayBuffer.isView(e)&&ArrayBuffer.isView(t))return e.length!==t.length?!1:e.every((n,o)=>n===t[o]);if(e!==null&&t!==null){const n=Object.keys(e),o=Object.keys(t);return n.length!==o.length?!1:n.every(a=>e[a]===t[a])}return e===t}toRgba(){const[e,t,s,r]=this._components;return{r:e,g:t,b:s,a:r}}toRgb(){const[e,t,s]=this._components;return{r:e,g:t,b:s}}toRgbaString(){const[e,t,s]=this.toUint8RgbArray();return`rgba(${e},${t},${s},${this.alpha})`}toUint8RgbArray(e){const[t,s,r]=this._components;return this._arrayRgb||(this._arrayRgb=[]),e||(e=this._arrayRgb),e[0]=Math.round(t*255),e[1]=Math.round(s*255),e[2]=Math.round(r*255),e}toArray(e){this._arrayRgba||(this._arrayRgba=[]),e||(e=this._arrayRgba);const[t,s,r,n]=this._components;return e[0]=t,e[1]=s,e[2]=r,e[3]=n,e}toRgbArray(e){this._arrayRgb||(this._arrayRgb=[]),e||(e=this._arrayRgb);const[t,s,r]=this._components;return e[0]=t,e[1]=s,e[2]=r,e}toNumber(){return this._int}toBgrNumber(){const[e,t,s]=this.toUint8RgbArray();return(s<<16)+(t<<8)+e}toLittleEndianNumber(){const e=this._int;return(e>>16)+(e&65280)+((e&255)<<16)}multiply(e){const[t,s,r,n]=Zs._temp.setValue(e)._components;return this._components[0]*=t,this._components[1]*=s,this._components[2]*=r,this._components[3]*=n,this._refreshInt(),this._value=null,this}premultiply(e,t=!0){return t&&(this._components[0]*=e,this._components[1]*=e,this._components[2]*=e),this._components[3]=e,this._refreshInt(),this._value=null,this}toPremultiplied(e,t=!0){if(e===1)return(255<<24)+this._int;if(e===0)return t?0:this._int;let s=this._int>>16&255,r=this._int>>8&255,n=this._int&255;return t&&(s=s*e+.5|0,r=r*e+.5|0,n=n*e+.5|0),(e*255<<24)+(s<<16)+(r<<8)+n}toHex(){const e=this._int.toString(16);return`#${"000000".substring(0,6-e.length)+e}`}toHexa(){const t=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-t.length)+t}setAlpha(e){return this._components[3]=this._clamp(e),this._value=null,this}_normalize(e){let t,s,r,n;if((typeof e=="number"||e instanceof Number)&&e>=0&&e<=16777215){const o=e;t=(o>>16&255)/255,s=(o>>8&255)/255,r=(o&255)/255,n=1}else if((Array.isArray(e)||e instanceof Float32Array)&&e.length>=3&&e.length<=4)e=this._clamp(e),[t,s,r,n=1]=e;else if((e instanceof Uint8Array||e instanceof Uint8ClampedArray)&&e.length>=3&&e.length<=4)e=this._clamp(e,0,255),[t,s,r,n=255]=e,t/=255,s/=255,r/=255,n/=255;else if(typeof e=="string"||typeof e=="object"){if(typeof e=="string"){const a=Zs.HEX_PATTERN.exec(e);a&&(e=`#${a[2]}`)}const o=ot(e);o.isValid()&&({r:t,g:s,b:r,a:n}=o.rgba,t/=255,s/=255,r/=255)}if(t!==void 0)this._components[0]=t,this._components[1]=s,this._components[2]=r,this._components[3]=n,this._refreshInt();else throw new Error(`Unable to convert color ${e}`)}_refreshInt(){this._clamp(this._components);const[e,t,s]=this._components;this._int=(e*255<<16)+(t*255<<8)+(s*255|0)}_clamp(e,t=0,s=1){return typeof e=="number"?Math.min(Math.max(e,t),s):(e.forEach((r,n)=>{e[n]=Math.min(Math.max(r,t),s)}),e)}static isColorLike(e){return typeof e=="number"||typeof e=="string"||e instanceof Number||e instanceof Zs||Array.isArray(e)||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Float32Array||e.r!==void 0&&e.g!==void 0&&e.b!==void 0||e.r!==void 0&&e.g!==void 0&&e.b!==void 0&&e.a!==void 0||e.h!==void 0&&e.s!==void 0&&e.l!==void 0||e.h!==void 0&&e.s!==void 0&&e.l!==void 0&&e.a!==void 0||e.h!==void 0&&e.s!==void 0&&e.v!==void 0||e.h!==void 0&&e.s!==void 0&&e.v!==void 0&&e.a!==void 0}};Cs.shared=new Cs;Cs._temp=new Cs;Cs.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let ae=Cs;const Ru={cullArea:null,cullable:!1,cullableChildren:!0};let nn=0;const Rh=500;function z(...i){nn!==Rh&&(nn++,nn===Rh?console.warn("PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS."):console.warn("PixiJS Warning: ",...i))}const as={_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 Bu{constructor(e,t){this._pool=[],this._count=0,this._index=0,this._classType=e,t&&this.prepopulate(t)}prepopulate(e){for(let t=0;t<e;t++)this._pool[this._index++]=new this._classType;this._count+=e}get(e){let t;return this._index>0?t=this._pool[--this._index]:(t=new this._classType,this._count++),t.init?.(e),t}return(e){e.reset?.(),this._pool[this._index++]=e}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 e=0;e<this._index;e++)this._pool[e].destroy();this._pool.length=0,this._count=0,this._index=0}}class Iu{constructor(){this._poolsByClass=new Map}prepopulate(e,t){this.getPool(e).prepopulate(t)}get(e,t){return this.getPool(e).get(t)}return(e){this.getPool(e.constructor).return(e)}getPool(e){return this._poolsByClass.has(e)||this._poolsByClass.set(e,new Bu(e)),this._poolsByClass.get(e)}stats(){const e={};return this._poolsByClass.forEach(t=>{const s=e[t._classType.name]?t._classType.name+t._classType.ID:t._classType.name;e[s]={free:t.totalFree,used:t.totalUsed,size:t.totalSize}}),e}clear(){this._poolsByClass.forEach(e=>e.clear()),this._poolsByClass.clear()}}const Se=new Iu;as.register(Se);const Gu={get isCachedAsTexture(){return!!this.renderGroup?.isCachedAsTexture},cacheAsTexture(i){typeof i=="boolean"&&i===!1?this.disableRenderGroup():(this.enableRenderGroup(),this.renderGroup.enableCacheAsTexture(i===!0?{}:i))},updateCacheTexture(){this.renderGroup?.updateCacheTexture()},get cacheAsBitmap(){return this.isCachedAsTexture},set cacheAsBitmap(i){H("v8.6.0","cacheAsBitmap is deprecated, use cacheAsTexture instead."),this.cacheAsTexture(i)}};function Ho(i,e,t){const s=i.length;let r;if(e>=s||t===0)return;t=e+t>s?s-e:t;const n=s-t;for(r=e;r<n;++r)i[r]=i[r+t];i.length=n}const Du={allowChildren:!0,removeChildren(i=0,e){const t=e??this.children.length,s=t-i,r=[];if(s>0&&s<=t){for(let o=t-1;o>=i;o--){const a=this.children[o];a&&(r.push(a),a.parent=null)}Ho(this.children,i,t);const n=this.renderGroup||this.parentRenderGroup;n&&n.removeChildren(r);for(let o=0;o<r.length;++o){const a=r[o];a.parentRenderLayer?.detach(a),this.emit("childRemoved",a,this,o),r[o].emit("removed",this)}return r.length>0&&this._didViewChangeTick++,r}else if(s===0&&this.children.length===0)return r;throw new RangeError("removeChildren: numeric values are outside the acceptable range.")},removeChildAt(i){const e=this.getChildAt(i);return this.removeChild(e)},getChildAt(i){if(i<0||i>=this.children.length)throw new Error(`getChildAt: Index (${i}) does not exist.`);return this.children[i]},setChildIndex(i,e){if(e<0||e>=this.children.length)throw new Error(`The index ${e} supplied is out of bounds ${this.children.length}`);this.getChildIndex(i),this.addChildAt(i,e)},getChildIndex(i){const e=this.children.indexOf(i);if(e===-1)throw new Error("The supplied Container must be a child of the caller");return e},addChildAt(i,e){this.allowChildren||H(ue,"addChildAt: Only Containers will be allowed to add children in v8.0.0");const{children:t}=this;if(e<0||e>t.length)throw new Error(`${i}addChildAt: The index ${e} supplied is out of bounds ${t.length}`);const s=i.parent===this;if(i.parent){const n=i.parent.children.indexOf(i);if(s){if(n===e)return i;i.parent.children.splice(n,1)}else i.removeFromParent()}e===t.length?t.push(i):t.splice(e,0,i);const r=this.renderGroup||this.parentRenderGroup;return this.sortableChildren&&(this.sortDirty=!0),s?(r&&(r.structureDidChange=!0),i):(i.parent=this,i.didChange=!0,i._updateFlags=15,r&&r.addChild(i),this.emit("childAdded",i,this,e),i.emit("added",this),i)},swapChildren(i,e){if(i===e)return;const t=this.getChildIndex(i),s=this.getChildIndex(e);this.children[t]=e,this.children[s]=i;const r=this.renderGroup||this.parentRenderGroup;r&&(r.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){this.parent?.removeChild(this)},reparentChild(...i){return i.length===1?this.reparentChildAt(i[0],this.children.length):(i.forEach(e=>this.reparentChildAt(e,this.children.length)),i[0])},reparentChildAt(i,e){if(i.parent===this)return this.setChildIndex(i,e),i;const t=i.worldTransform.clone();i.removeFromParent(),this.addChildAt(i,e);const s=this.worldTransform.clone();return s.invert(),t.prepend(s),i.setFromMatrix(t),i},replaceChild(i,e){i.updateLocalTransform(),this.addChildAt(e,this.getChildIndex(i)),e.setFromMatrix(i.localTransform),e.updateLocalTransform(),this.removeChild(i)}},Fu={collectRenderables(i,e,t){this.parentRenderLayer&&this.parentRenderLayer!==t||this.globalDisplayStatus<7||!this.includeInBuild||(this.sortableChildren&&this.sortChildren(),this.isSimple?this.collectRenderablesSimple(i,e,t):this.renderGroup?e.renderPipes.renderGroup.addRenderGroup(this.renderGroup,i):this.collectRenderablesWithEffects(i,e,t))},collectRenderablesSimple(i,e,t){const s=this.children,r=s.length;for(let n=0;n<r;n++)s[n].collectRenderables(i,e,t)},collectRenderablesWithEffects(i,e,t){const{renderPipes:s}=e;for(let r=0;r<this.effects.length;r++){const n=this.effects[r];s[n.pipe].push(n,this,i)}this.collectRenderablesSimple(i,e,t);for(let r=this.effects.length-1;r>=0;r--){const n=this.effects[r];s[n.pipe].pop(n,this,i)}}};class hi{constructor(){this.pipe="filter",this.priority=1}destroy(){for(let e=0;e<this.filters.length;e++)this.filters[e].destroy();this.filters=null,this.filterArea=null}}class Ou{constructor(){this._effectClasses=[],this._tests=[],this._initialized=!1}init(){this._initialized||(this._initialized=!0,this._effectClasses.forEach(e=>{this.add({test:e.test,maskClass:e})}))}add(e){this._tests.push(e)}getMaskEffect(e){this._initialized||this.init();for(let t=0;t<this._tests.length;t++){const s=this._tests[t];if(s.test(e))return Se.get(s.maskClass,e)}return e}returnMaskEffect(e){Se.return(e)}}const rr=new Ou;q.handleByList(S.MaskEffect,rr._effectClasses);const Lu={_maskEffect:null,_maskOptions:{inverse:!1,channel:"red"},_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((t,s)=>t.priority-s.priority),this._markStructureAsChanged(),this._updateIsSimple())},removeEffect(i){const e=this.effects.indexOf(i);e!==-1&&(this.effects.splice(e,1),this._markStructureAsChanged(),this._updateIsSimple())},set mask(i){const e=this._maskEffect;e?.mask!==i&&(e&&(this.removeEffect(e),rr.returnMaskEffect(e),this._maskEffect=null),i!=null&&(this._maskEffect=rr.getMaskEffect(i),this.addEffect(this._maskEffect)))},get mask(){return this._maskEffect?.mask},setMask(i){this._maskOptions={...this._maskOptions,...i},i.mask&&(this.mask=i.mask),this._markStructureAsChanged()},set filters(i){!Array.isArray(i)&&i&&(i=[i]);const e=this._filterEffect||(this._filterEffect=new hi);i=i;const t=i?.length>0,s=e.filters?.length>0,r=t!==s;i=Array.isArray(i)?i.slice(0):i,e.filters=Object.freeze(i),r&&(t?this.addEffect(e):(this.removeEffect(e),e.filters=i??null))},get filters(){return this._filterEffect?.filters},set filterArea(i){this._filterEffect||(this._filterEffect=new hi),this._filterEffect.filterArea=i},get filterArea(){return this._filterEffect?.filterArea}},Uu={label:null,get name(){return H(ue,"Container.name property has been removed, use Container.label instead"),this.label},set name(i){H(ue,"Container.name property has been removed, use Container.label instead"),this.label=i},getChildByName(i,e=!1){return this.getChildByLabel(i,e)},getChildByLabel(i,e=!1){const t=this.children;for(let s=0;s<t.length;s++){const r=t[s];if(r.label===i||i instanceof RegExp&&i.test(r.label))return r}if(e)for(let s=0;s<t.length;s++){const n=t[s].getChildByLabel(i,!0);if(n)return n}return null},getChildrenByLabel(i,e=!1,t=[]){const s=this.children;for(let r=0;r<s.length;r++){const n=s[r];(n.label===i||i instanceof RegExp&&i.test(n.label))&&t.push(n)}if(e)for(let r=0;r<s.length;r++)s[r].getChildrenByLabel(i,!0,t);return t}},Ae=Se.getPool(U),ut=Se.getPool(Ee),s_=new U,Nu={getFastGlobalBounds(i,e){e||(e=new Ee),e.clear(),this._getGlobalBoundsRecursive(!!i,e,this.parentRenderLayer),e.isValid||e.set(0,0,0,0);const t=this.renderGroup||this.parentRenderGroup;return e.applyMatrix(t.worldTransform),e},_getGlobalBoundsRecursive(i,e,t){let s=e;if(i&&this.parentRenderLayer&&this.parentRenderLayer!==t||this.localDisplayStatus!==7||!this.measurable)return;const r=!!this.effects.length;if((this.renderGroup||r)&&(s=ut.get().clear()),this.boundsArea)e.addRect(this.boundsArea,this.worldTransform);else{if(this.renderPipeId){const o=this.bounds;s.addFrame(o.minX,o.minY,o.maxX,o.maxY,this.groupTransform)}const n=this.children;for(let o=0;o<n.length;o++)n[o]._getGlobalBoundsRecursive(i,s,t)}if(r){let n=!1;const o=this.renderGroup||this.parentRenderGroup;for(let a=0;a<this.effects.length;a++)this.effects[a].addBounds&&(n||(n=!0,s.applyMatrix(o.worldTransform)),this.effects[a].addBounds(s,!0));n&&s.applyMatrix(o.worldTransform.copyTo(s_).invert()),e.addBounds(s),ut.return(s)}else this.renderGroup&&(e.addBounds(s,this.relativeGroupTransform),ut.return(s))}};function _r(i,e,t){t.clear();let s,r;return i.parent?e?s=i.parent.worldTransform:(r=Ae.get().identity(),s=yr(i,r)):s=U.IDENTITY,Hu(i,t,s,e),r&&Ae.return(r),t.isValid||t.set(0,0,0,0),t}function Hu(i,e,t,s){if(!i.visible||!i.measurable)return;let r;s?r=i.worldTransform:(i.updateLocalTransform(),r=Ae.get(),r.appendFrom(i.localTransform,t));const n=e,o=!!i.effects.length;if(o&&(e=ut.get().clear()),i.boundsArea)e.addRect(i.boundsArea,r);else{const a=i.bounds;a&&!a.isEmpty()&&(e.matrix=r,e.addBounds(a));for(let l=0;l<i.children.length;l++)Hu(i.children[l],e,r,s)}if(o){for(let a=0;a<i.effects.length;a++)i.effects[a].addBounds?.(e);n.addBounds(e,U.IDENTITY),ut.return(e)}s||Ae.return(r)}function yr(i,e){const t=i.parent;return t&&(yr(t,e),t.updateLocalTransform(),e.append(t.localTransform)),e}function Kt(i,e){if(i===16777215||!e)return e;if(e===16777215||!i)return i;const t=i>>16&255,s=i>>8&255,r=i&255,n=e>>16&255,o=e>>8&255,a=e&255,l=t*n/255|0,h=s*o/255|0,c=r*a/255|0;return(l<<16)+(h<<8)+c}const Bh=16777215;function ci(i,e){return i===Bh?e:e===Bh?i:Kt(i,e)}function Zt(i){return((i&255)<<16)+(i&65280)+(i>>16&255)}const zu={getGlobalAlpha(i){if(i)return this.renderGroup?this.renderGroup.worldAlpha:this.parentRenderGroup?this.parentRenderGroup.worldAlpha*this.alpha:this.alpha;let e=this.alpha,t=this.parent;for(;t;)e*=t.alpha,t=t.parent;return e},getGlobalTransform(i=new U,e){if(e)return i.copyFrom(this.worldTransform);this.updateLocalTransform();const t=yr(this,Ae.get().identity());return i.appendFrom(this.localTransform,t),Ae.return(t),i},getGlobalTint(i){if(i)return this.renderGroup?Zt(this.renderGroup.worldColor):this.parentRenderGroup?Zt(ci(this.localColor,this.parentRenderGroup.worldColor)):this.tint;let e=this.localColor,t=this.parent;for(;t;)e=ci(e,t.localColor),t=t.parent;return Zt(e)}};function xr(i,e,t){return e.clear(),t||(t=U.IDENTITY),Wu(i,e,t,i,!0),e.isValid||e.set(0,0,0,0),e}function Wu(i,e,t,s,r){let n;if(r)n=Ae.get(),n=t.copyTo(n);else{if(!i.visible||!i.measurable)return;i.updateLocalTransform();const l=i.localTransform;n=Ae.get(),n.appendFrom(l,t)}const o=e,a=!!i.effects.length;if(a&&(e=ut.get().clear()),i.boundsArea)e.addRect(i.boundsArea,n);else{i.renderPipeId&&(e.matrix=n,e.addBounds(i.bounds));const l=i.children;for(let h=0;h<l.length;h++)Wu(l[h],e,n,s,!1)}if(a){for(let l=0;l<i.effects.length;l++)i.effects[l].addLocalBounds?.(e,s);o.addBounds(e,U.IDENTITY),ut.return(e)}Ae.return(n)}function zo(i,e){const t=i.children;for(let s=0;s<t.length;s++){const r=t[s],n=r.uid,o=(r._didViewChangeTick&65535)<<16|r._didContainerChangeTick&65535,a=e.index;(e.data[a]!==n||e.data[a+1]!==o)&&(e.data[e.index]=n,e.data[e.index+1]=o,e.didChange=!0),e.index=a+2,r.children.length&&zo(r,e)}return e.didChange}const i_=new U,$u={_localBoundsCacheId:-1,_localBoundsCacheData:null,_setWidth(i,e){const t=Math.sign(this.scale.x)||1;e!==0?this.scale.x=i/e*t:this.scale.x=t},_setHeight(i,e){const t=Math.sign(this.scale.y)||1;e!==0?this.scale.y=i/e*t:this.scale.y=t},getLocalBounds(){this._localBoundsCacheData||(this._localBoundsCacheData={data:[],index:1,didChange:!1,localBounds:new Ee});const i=this._localBoundsCacheData;return i.index=1,i.didChange=!1,i.data[0]!==this._didViewChangeTick&&(i.didChange=!0,i.data[0]=this._didViewChangeTick),zo(this,i),i.didChange&&xr(this,i.localBounds,i_),i.localBounds},getBounds(i,e){return _r(this,i,e||new Ee)}},Vu={_onRender:null,set onRender(i){const e=this.renderGroup||this.parentRenderGroup;if(!i){this._onRender&&e?.removeOnRender(this),this._onRender=null;return}this._onRender||e?.addOnRender(this),this._onRender=i},get onRender(){return this._onRender}},ju={_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(r_))}};function r_(i,e){return i._zIndex-e._zIndex}const Xu={getGlobalPosition(i=new he,e=!1){return this.parent?this.parent.toGlobal(this._position,i,e):(i.x=this._position.x,i.y=this._position.y),i},toGlobal(i,e,t=!1){const s=this.getGlobalTransform(Ae.get(),t);return e=s.apply(i,e),Ae.return(s),e},toLocal(i,e,t,s){e&&(i=e.toGlobal(i,t,s));const r=this.getGlobalTransform(Ae.get(),s);return t=r.applyInverse(i,t),Ae.return(r),t}};class br{constructor(){this.uid=oe("instructionSet"),this.instructions=[],this.instructionSize=0,this.renderables=[],this.gcTick=0}reset(){this.instructionSize=0}destroy(){if(this.renderPipes)for(const e in this.renderPipes)this.renderPipes[e].destroyInstructionSet?.(this);this.instructions.length=0,this.renderables.length=0,this.renderPipes=null,this.gcTick=0}add(e){this.instructions[this.instructionSize++]=e}log(){this.instructions.length=this.instructionSize,console.table(this.instructions,["type","action"])}}class Wo{constructor(){this._screenSizes=new Map,this._widths=[],this._heights=[]}get size(){return this._screenSizes.size}set(e,t,s){const r=this._screenSizes.get(e);return r&&r.pixelWidth===t&&r.pixelHeight===s?!1:(this._screenSizes.set(e,{pixelWidth:t,pixelHeight:s}),this._update(),!0)}remove(e){return this._screenSizes.delete(e)?(this._update(),!0):!1}getFittingWidth(e){return this._getFittingAxis(e,this._widths)}getFittingHeight(e){return this._getFittingAxis(e,this._heights)}hasWidth(e){return this._widths.includes(e)}hasHeight(e){return this._heights.includes(e)}_getFittingAxis(e,t){for(let s=0;s<t.length;s++){const r=t[s];if(r>=e)return r}}_update(){this._widths=[...this._screenSizes.values()].map(e=>e.pixelWidth).filter((e,t,s)=>s.indexOf(e)===t).sort((e,t)=>e-t),this._heights=[...this._screenSizes.values()].map(e=>e.pixelHeight).filter((e,t,s)=>s.indexOf(e)===t).sort((e,t)=>e-t)}}let n_=0;const on=32767,o_=4294967296,a_=8589934592,Ih=Object.create(null);let l_=0;function h_(i){const e=Ih[i];return e!==void 0?e:Ih[i]=l_++}function c_(i,e,t,s,r,n){return(i<<17)+(e<<2)+((s?1:0)<<1)+(t?1:0)+(n==="nearest"?1:0)*o_+h_(r)*a_}class qu{constructor(e){this._buckets=new Map,this._poolKey=Object.create(null),this._poolStyle=Object.create(null),this._screens=new Wo,this._enableFullScreen=!1,this.textureOptions=e||{}}get textureStyle(){return H(ht,"TexturePool.textureStyle is no longer used, pooled textures carry their own style. Pass scaleMode in the request instead."),this._textureStyle||(this._textureStyle=new Dt(this.textureOptions)),this._textureStyle}set textureStyle(e){H(ht,"TexturePool.textureStyle is no longer used, pooled textures carry their own style. Pass scaleMode in the request instead."),this._textureStyle=e}get enableFullScreen(){return H(ht,"TexturePool.enableFullScreen is no longer used, the pool sizes textures to the screens registered with setScreenSize."),this._enableFullScreen}set enableFullScreen(e){H(ht,"TexturePool.enableFullScreen is no longer used, the pool sizes textures to the screens registered with setScreenSize."),this._enableFullScreen=e}createTexture(...e){let t=e[0];typeof t=="number"&&(H(ht,"TexturePool.createTexture params are now an options object. See params: { width, height, antialias, autoGenerateMipmaps }"),t={width:t,height:e[1],antialias:e[2]??!1,autoGenerateMipmaps:e[3]??!1});const s=t.format??this.textureOptions.format??de.defaultOptions.format,r=t.scaleMode??this.textureOptions.scaleMode??Dt.defaultOptions.scaleMode,n=new de({...this.textureOptions,width:t.width,height:t.height,resolution:1,antialias:t.antialias??!1,autoGarbageCollect:!1,autoGenerateMipmaps:t.autoGenerateMipmaps??!1,format:s,scaleMode:r});return new W({source:n,label:`texturePool_${n_++}`})}getOptimalTexture(...e){let t=e[0];typeof t=="number"&&(H(ht,"TexturePool.getOptimalTexture params are now an options object. See params: { width, height, resolution, antialias, autoGenerateMipmaps }"),t={width:t,height:e[1],resolution:e[2]??1,antialias:e[3]??!1,autoGenerateMipmaps:e[4]??!1});const s=t.width,r=t.height,n=t.resolution??1,o=t.antialias??!1,a=t.autoGenerateMipmaps??!1,l=t.format??this.textureOptions.format??de.defaultOptions.format,h=t.scaleMode??this.textureOptions.scaleMode??Dt.defaultOptions.scaleMode,{width:c,height:u}=this.getOptimalSize(s,r,n);(c>on||u>on)&&z(`TexturePool: ${c}x${u} is larger than the ${on}px pool key limit, textures of this size may be pooled together`);const d=c_(c,u,o,a,l,h);let f=this._buckets.get(d);f||(f=[],this._buckets.set(d,f));let p=f.pop();return p||(p=this.createTexture({width:c,height:u,antialias:o,autoGenerateMipmaps:a,format:l,scaleMode:h}),this._poolStyle[p.uid]=p.source.style),p.source._resolution=n,p.source.width=c/n,p.source.height=u/n,p.source.pixelWidth=c,p.source.pixelHeight=u,p.frame.x=0,p.frame.y=0,p.frame.width=s,p.frame.height=r,p.updateUvs(),this._poolKey[p.uid]=d,p}getOptimalSize(e,t,s=1){const r=Math.ceil(e*s-1e-6),n=Math.ceil(t*s-1e-6),o=es(r),a=this._screens.getFittingWidth(r),l=es(n),h=this._screens.getFittingHeight(n);return{width:a!==void 0?Math.min(a,o):o,height:h!==void 0?Math.min(h,l):l}}getSameSizeTexture(e,t=!1){const s=e.source;return this.getOptimalTexture({width:e.width,height:e.height,resolution:s._resolution,antialias:t})}returnTexture(e,t=!1){const s=e.uid,r=this._poolKey[s];if(r===void 0){z("TexturePool: returnTexture was passed a texture that did not come from this pool, ignoring it");return}const n=this._poolStyle[s];t&&e.source.style!==n&&(e.source.style=n);const o=this._buckets.get(r);if(!o){delete this._poolKey[s],delete this._poolStyle[s],e.destroy(!0);return}o.push(e)}setScreenSize(e,t,s){this._screens.set(e,t,s)&&this._pruneScreenTextures()}removeScreen(e){this._screens.remove(e)&&this._pruneScreenTextures()}_pruneScreenTextures(){for(const[e,t]of this._buckets){const s=e>>>0,r=s>>>17,n=s>>>2&32767;(ts(r)||this._screens.hasWidth(r))&&(ts(n)||this._screens.hasHeight(n))||(this._dropTextures(t,!0),this._buckets.delete(e))}}_dropTextures(e,t){for(let s=0;s<e.length;s++){const r=e[s];delete this._poolKey[r.uid],delete this._poolStyle[r.uid],t&&r.destroy(!0)}}clear(e){for(const t of this._buckets.values())this._dropTextures(t,e!==!1);this._buckets.clear()}}const Te=new qu;as.register(Te);class nr{constructor(){this.renderPipeId="renderGroup",this.root=null,this.canBundle=!1,this.renderGroupParent=null,this.renderGroupChildren=[],this.worldTransform=new U,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 br,this._onRenderContainers=[],this.textureNeedsUpdate=!0,this.isCachedAsTexture=!1,this._matrixDirty=7}init(e){this.root=e,e._onRender&&this.addOnRender(e),e.didChange=!0;const t=e.children;for(let s=0;s<t.length;s++){const r=t[s];r._updateFlags=15,this.addChild(r)}}enableCacheAsTexture(e={}){this.textureOptions=e,this.isCachedAsTexture=!0,this.textureNeedsUpdate=!0}disableCacheAsTexture(){this.isCachedAsTexture=!1,this.texture&&(Te.returnTexture(this.texture),this.texture=null)}updateCacheTexture(){this.textureNeedsUpdate=!0;const e=this._parentCacheAsTextureRenderGroup;e&&!e.textureNeedsUpdate&&e.updateCacheTexture()}reset(){this.renderGroupChildren.length=0;for(const e in this.childrenToUpdate){const t=this.childrenToUpdate[e];t.list.fill(null),t.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(e){e.renderGroupParent&&e.renderGroupParent._removeRenderGroupChild(e),e.renderGroupParent=this,this.renderGroupChildren.push(e)}_removeRenderGroupChild(e){const t=this.renderGroupChildren.indexOf(e);t>-1&&this.renderGroupChildren.splice(t,1),e.renderGroupParent=null}addChild(e){if(this.structureDidChange=!0,e.parentRenderGroup=this,e.updateTick=-1,e.parent===this.root?e.relativeRenderGroupDepth=1:e.relativeRenderGroupDepth=e.parent.relativeRenderGroupDepth+1,e.didChange=!0,this.onChildUpdate(e),e.renderGroup){this.addRenderGroupChild(e.renderGroup);return}e._onRender&&this.addOnRender(e);const t=e.children;for(let s=0;s<t.length;s++)this.addChild(t[s])}removeChild(e){if(this.structureDidChange=!0,e._onRender&&(e.renderGroup||this.removeOnRender(e)),e.parentRenderGroup=null,e.renderGroup){this._removeRenderGroupChild(e.renderGroup);return}const t=e.children;for(let s=0;s<t.length;s++)this.removeChild(t[s])}removeChildren(e){for(let t=0;t<e.length;t++)this.removeChild(e[t])}onChildUpdate(e){let t=this.childrenToUpdate[e.relativeRenderGroupDepth];t||(t=this.childrenToUpdate[e.relativeRenderGroupDepth]={index:0,list:[]}),t.list[t.index++]=e}updateRenderable(e){e.globalDisplayStatus<7||(this.instructionSet.renderPipes[e.renderPipeId].updateRenderable(e),e.didViewUpdate=!1)}onChildViewUpdate(e){this.childrenRenderablesToUpdate.list[this.childrenRenderablesToUpdate.index++]=e}get isRenderable(){return this.root.localDisplayStatus===7&&this.worldAlpha>0}addOnRender(e){this._onRenderContainers.indexOf(e)===-1&&this._onRenderContainers.push(e)}removeOnRender(e){const t=this._onRenderContainers.indexOf(e);t!==-1&&this._onRenderContainers.splice(t,1)}runOnRender(e){for(let t=0;t<this._onRenderContainers.length;t++)this._onRenderContainers[t]._onRender(e)}destroy(){this.disableCacheAsTexture(),this.renderGroupParent=null,this.root=null,this.childrenRenderablesToUpdate=null,this.childrenToUpdate=null,this.renderGroupChildren=null,this._onRenderContainers=null,this.instructionSet?.destroy(),this.instructionSet=null}getChildren(e=[]){const t=this.root.children;for(let s=0;s<t.length;s++)this._getChildren(t[s],e);return e}_getChildren(e,t=[]){if(t.push(e),e.renderGroup)return t;const s=e.children;for(let r=0;r<s.length;r++)this._getChildren(s[r],t);return t}invalidateMatrices(){this._matrixDirty=7}get inverseWorldTransform(){return(this._matrixDirty&1)===0?this._inverseWorldTransform:(this._matrixDirty&=-2,this._inverseWorldTransform||(this._inverseWorldTransform=new U),this._inverseWorldTransform.copyFrom(this.worldTransform).invert())}get textureOffsetInverseTransform(){return(this._matrixDirty&2)===0?this._textureOffsetInverseTransform:(this._matrixDirty&=-3,this._textureOffsetInverseTransform||(this._textureOffsetInverseTransform=new U),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 e=this._parentCacheAsTextureRenderGroup;return e?(this._inverseParentTextureTransform||(this._inverseParentTextureTransform=new U),this._inverseParentTextureTransform.copyFrom(this.worldTransform).prepend(e.inverseWorldTransform).translate(-e._textureBounds.x,-e._textureBounds.y)):this.worldTransform}get cacheToLocalTransform(){return this.isCachedAsTexture?this.textureOffsetInverseTransform:this._parentCacheAsTextureRenderGroup?this._parentCacheAsTextureRenderGroup.textureOffsetInverseTransform:null}}function Yu(i,e,t={}){for(const s in e)!t[s]&&e[s]!==void 0&&(i[s]=e[s])}const an=new Ce(null),Ei=new Ce(null),ln=new Ce(null,1,1),Pi=new Ce(null),ui=1,vr=2,ws=4;class _e extends Re{constructor(e={}){super(),this.uid=oe("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 U,this.relativeGroupTransform=new U,this.groupTransform=this.relativeGroupTransform,this.destroyed=!1,this._position=new Ce(this,0,0),this._scale=ln,this._pivot=Ei,this._origin=Pi,this._skew=an,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=[],Yu(this,e,{children:!0,parent:!0,effects:!0}),e.children?.forEach(t=>this.addChild(t)),e.parent?.addChild(this)}static mixin(e){H("8.8.0","Container.mixin is deprecated, please use extensions.mixin instead."),q.mixin(_e,e)}set _didChangeId(e){this._didViewChangeTick=e>>12&4095,this._didContainerChangeTick=e&4095}get _didChangeId(){return this._didContainerChangeTick&4095|(this._didViewChangeTick&4095)<<12}addChild(...e){if(this.allowChildren||H(ue,"addChild: Only Containers will be allowed to add children in v8.0.0"),e.length>1){for(let r=0;r<e.length;r++)this.addChild(e[r]);return e[0]}const t=e[0],s=this.renderGroup||this.parentRenderGroup;return t.parent===this?(this.children.splice(this.children.indexOf(t),1),this.children.push(t),s&&(s.structureDidChange=!0),t):(t.parent&&t.parent.removeChild(t),this.children.push(t),this.sortableChildren&&(this.sortDirty=!0),t.parent=this,t.didChange=!0,t._updateFlags=15,s&&s.addChild(t),this.emit("childAdded",t,this,this.children.length-1),t.emit("added",this),this._didViewChangeTick++,t._zIndex!==0&&t.depthOfChildModified(),t)}removeChild(...e){if(e.length>1){for(let r=0;r<e.length;r++)this.removeChild(e[r]);return e[0]}const t=e[0],s=this.children.indexOf(t);return s>-1&&(this._didViewChangeTick++,this.children.splice(s,1),this.renderGroup?this.renderGroup.removeChild(t):this.parentRenderGroup&&this.parentRenderGroup.removeChild(t),t.parentRenderLayer&&t.parentRenderLayer.detach(t),t.parent=null,this.emit("childRemoved",t,this,s),t.emit("removed",this)),t}_onUpdate(e){e&&e===this._skew&&this._updateSkew(),this._didContainerChangeTick++,!this.didChange&&(this.didChange=!0,this.parentRenderGroup&&this.parentRenderGroup.onChildUpdate(this))}set isRenderGroup(e){!!this.renderGroup!==e&&(e?this.enableRenderGroup():this.disableRenderGroup())}get isRenderGroup(){return!!this.renderGroup}enableRenderGroup(){if(this.renderGroup)return;const e=this.parentRenderGroup;e?.removeChild(this),this.renderGroup=Se.get(nr,this),this.groupTransform=U.IDENTITY,e?.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const e=this.parentRenderGroup;e?.removeChild(this),Se.return(this.renderGroup),this.renderGroup=null,this.groupTransform=this.relativeGroupTransform,e?.addChild(this),this._updateIsSimple()}_updateIsSimple(){this.isSimple=!this.renderGroup&&this.effects.length===0}get worldTransform(){return this._worldTransform||(this._worldTransform=new U),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(e){this._position.x=e}get y(){return this._position.y}set y(e){this._position.y=e}get position(){return this._position}set position(e){this._position.copyFrom(e)}get rotation(){return this._rotation}set rotation(e){this._rotation!==e&&(this._rotation=e,this._onUpdate(this._skew))}get angle(){return this.rotation*xu}set angle(e){this.rotation=e*bu}get pivot(){return this._pivot===Ei&&(this._pivot=new Ce(this,0,0)),this._pivot}set pivot(e){this._pivot===Ei&&(this._pivot=new Ce(this,0,0),this._origin!==Pi&&z("Setting both a pivot and origin on a Container is not recommended. This can lead to unexpected behavior if not handled carefully.")),typeof e=="number"?this._pivot.set(e):this._pivot.copyFrom(e)}get skew(){return this._skew===an&&(this._skew=new Ce(this,0,0)),this._skew}set skew(e){this._skew===an&&(this._skew=new Ce(this,0,0)),this._skew.copyFrom(e)}get scale(){return this._scale===ln&&(this._scale=new Ce(this,1,1)),this._scale}set scale(e){this._scale===ln&&(this._scale=new Ce(this,0,0)),typeof e=="string"&&(e=parseFloat(e)),typeof e=="number"?this._scale.set(e):this._scale.copyFrom(e)}get origin(){return this._origin===Pi&&(this._origin=new Ce(this,0,0)),this._origin}set origin(e){this._origin===Pi&&(this._origin=new Ce(this,0,0),this._pivot!==Ei&&z("Setting both a pivot and origin on a Container is not recommended. This can lead to unexpected behavior if not handled carefully.")),typeof e=="number"?this._origin.set(e):this._origin.copyFrom(e)}get width(){return Math.abs(this.scale.x*this.getLocalBounds().width)}set width(e){const t=this.getLocalBounds().width;this._setWidth(e,t)}get height(){return Math.abs(this.scale.y*this.getLocalBounds().height)}set height(e){const t=this.getLocalBounds().height;this._setHeight(e,t)}getSize(e){e||(e={});const t=this.getLocalBounds();return e.width=Math.abs(this.scale.x*t.width),e.height=Math.abs(this.scale.y*t.height),e}setSize(e,t){const s=this.getLocalBounds();typeof e=="object"?(t=e.height??e.width,e=e.width):t??(t=e),e!==void 0&&this._setWidth(e,s.width),t!==void 0&&this._setHeight(t,s.height)}_updateSkew(){const e=this._rotation,t=this._skew;this._cx=Math.cos(e+t._y),this._sx=Math.sin(e+t._y),this._cy=-Math.sin(e-t._x),this._sy=Math.cos(e-t._x)}updateTransform(e){return this.position.set(typeof e.x=="number"?e.x:this.position.x,typeof e.y=="number"?e.y:this.position.y),this.scale.set(typeof e.scaleX=="number"?e.scaleX:this.scale.x,typeof e.scaleY=="number"?e.scaleY:this.scale.y),this.rotation=typeof e.rotation=="number"?e.rotation:this.rotation,this.skew.set(typeof e.skewX=="number"?e.skewX:this.skew.x,typeof e.skewY=="number"?e.skewY:this.skew.y),this.pivot.set(typeof e.pivotX=="number"?e.pivotX:this.pivot.x,typeof e.pivotY=="number"?e.pivotY:this.pivot.y),this.origin.set(typeof e.originX=="number"?e.originX:this.origin.x,typeof e.originY=="number"?e.originY:this.origin.y),this}setFromMatrix(e){e.decompose(this)}updateLocalTransform(){const e=this._didContainerChangeTick;if(this._didLocalTransformChangeId===e)return;this._didLocalTransformChangeId=e;const t=this.localTransform,s=this._scale,r=this._pivot,n=this._origin,o=this._position,a=s._x,l=s._y,h=r._x,c=r._y,u=-n._x,d=-n._y;t.a=this._cx*a,t.b=this._sx*a,t.c=this._cy*l,t.d=this._sy*l,t.tx=o._x-(h*t.a+c*t.c)+(u*t.a+d*t.c)-u,t.ty=o._y-(h*t.b+c*t.d)+(u*t.b+d*t.d)-d}set alpha(e){e!==this.localAlpha&&(this.localAlpha=e,this._updateFlags|=ui,this._onUpdate())}get alpha(){return this.localAlpha}set tint(e){const s=ae.shared.setValue(e??16777215).toBgrNumber();s!==this.localColor&&(this.localColor=s,this._updateFlags|=ui,this._onUpdate())}get tint(){return Zt(this.localColor)}set blendMode(e){this.localBlendMode!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=vr,this.localBlendMode=e,this._onUpdate())}get blendMode(){return this.localBlendMode}get visible(){return!!(this.localDisplayStatus&2)}set visible(e){const t=e?2:0;(this.localDisplayStatus&2)!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=ws,this.localDisplayStatus^=2,this._onUpdate(),this.emit("visibleChanged",e))}get culled(){return!(this.localDisplayStatus&4)}set culled(e){const t=e?0:4;(this.localDisplayStatus&4)!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=ws,this.localDisplayStatus^=4,this._onUpdate())}get renderable(){return!!(this.localDisplayStatus&1)}set renderable(e){const t=e?1:0;(this.localDisplayStatus&1)!==t&&(this._updateFlags|=ws,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get isRenderable(){return this.localDisplayStatus===7&&this.groupAlpha>0}destroy(e=!1){if(this.destroyed)return;this.destroyed=!0;let t;if(this.children.length&&(t=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 e=="boolean"?e:e?.children)&&t)for(let r=0;r<t.length;++r)t[r].destroy(e);this.renderGroup?.destroy(),this.renderGroup=null}}q.mixin(_e,Du,Nu,Xu,Vu,$u,Lu,Uu,ju,Ru,Gu,zu,Fu);class wr extends _e{constructor(e){super(e),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 Ee(0,1,0,0),this._boundsDirty=!0,this.autoGarbageCollect=e.autoGarbageCollect??!0}get bounds(){return this._boundsDirty?(this.updateBounds(),this._boundsDirty=!1,this._bounds):this._bounds}get roundPixels(){return!!this._roundPixels}set roundPixels(e){this._roundPixels=e?1:0}containsPoint(e){const t=this.bounds,{x:s,y:r}=e;return s>=t.minX&&s<=t.maxX&&r>=t.minY&&r<=t.maxY}onViewUpdate(){if(this._didViewChangeTick++,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const e=this.renderGroup||this.parentRenderGroup;e&&e.onChildViewUpdate(this)}unload(){this.emit("unload",this);for(const e in this._gpuData)this._gpuData[e]?.destroy();this._gpuData=Object.create(null),this.onViewUpdate()}destroy(e){this.unload(),super.destroy(e),this._bounds=null}collectRenderablesSimple(e,t,s){const{renderPipes:r}=t;r.blendMode.pushBlendMode(this,this.groupBlendMode,e);const o=r[this.renderPipeId];o?.addRenderable&&o.addRenderable(this,e),this.didViewUpdate=!1;const a=this.children,l=a.length;for(let h=0;h<l;h++)a[h].collectRenderables(e,t,s);r.blendMode.popBlendMode(e)}}class ss extends wr{constructor(e=W.EMPTY){e instanceof W&&(e={texture:e});const{texture:t=W.EMPTY,anchor:s,roundPixels:r,width:n,height:o,...a}=e;super({label:"Sprite",...a}),this.renderPipeId="sprite",this.batched=!0,this._visualBounds={minX:0,maxX:1,minY:0,maxY:0},this._anchor=new Ce({_onUpdate:()=>{this.onViewUpdate()}}),s?this.anchor=s:t.defaultAnchor&&(this.anchor=t.defaultAnchor),this.texture=t,this.allowChildren=!1,this.roundPixels=r??!1,n!==void 0&&(this.width=n),o!==void 0&&(this.height=o)}static from(e,t=!1){return e instanceof W?new ss(e):new ss(W.from(e,t))}set texture(e){e||(e=W.EMPTY);const t=this._texture;t!==e&&(t&&t.dynamic&&t.off("update",this.onViewUpdate,this),e.dynamic&&e.on("update",this.onViewUpdate,this),this._texture=e,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 No(this._visualBounds,this._anchor,this._texture),this._visualBounds}get sourceBounds(){return H("8.6.1","Sprite.sourceBounds is deprecated, use visualBounds instead."),this.visualBounds}updateBounds(){const e=this._anchor,t=this._texture,s=this._bounds,{width:r,height:n}=t.orig;s.minX=-e._x*r,s.maxX=s.minX+r,s.minY=-e._y*n,s.maxY=s.minY+n}destroy(e=!1){if(super.destroy(e),typeof e=="boolean"?e:e?.texture){const s=typeof e=="boolean"?e:e?.textureSource;this._texture.destroy(s)}this._texture=null,this._visualBounds=null,this._bounds=null,this._anchor=null}get anchor(){return this._anchor}set anchor(e){typeof e=="number"?this._anchor.set(e):this._anchor.copyFrom(e)}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(e){this._setWidth(e,this._texture.orig.width),this._width=e}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(e){this._setHeight(e,this._texture.orig.height),this._height=e}getSize(e){return e||(e={}),e.width=Math.abs(this.scale.x)*this._texture.orig.width,e.height=Math.abs(this.scale.y)*this._texture.orig.height,e}setSize(e,t){typeof e=="object"?(t=e.height??e.width,e=e.width):t??(t=e),e!==void 0&&this._setWidth(e,this._texture.orig.width),t!==void 0&&this._setHeight(t,this._texture.orig.height)}}const u_=new Ee;function $o(i,e,t){const s=u_;i.measurable=!0,_r(i,t,s),e.addBoundsMask(s),i.measurable=!1}function Vo(i,e,t){const s=ut.get();i.measurable=!0;const r=Ae.get().identity(),n=Ku(i,t,r);xr(i,s,n),i.measurable=!1,e.addBoundsMask(s),Ae.return(r),ut.return(s)}function Ku(i,e,t){return i?(i!==e&&(Ku(i.parent,e,t),i.updateLocalTransform(),t.append(i.localTransform)),t):(z("Mask bounds, renderable is not inside the root container"),t)}class jo{constructor(e){this.priority=0,this.inverse=!1,this.channel="red",this.pipe="alphaMask",e?.mask&&this.init(e.mask)}init(e){this.mask=e,this.renderMaskToTexture=!(e instanceof ss),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(e,t){this.inverse||$o(this.mask,e,t)}addLocalBounds(e,t){Vo(this.mask,e,t)}containsPoint(e,t){const s=this.mask;return t(s,e)}destroy(){this.reset()}static test(e){return e instanceof ss}}jo.extension=S.MaskEffect;class Xo{constructor(e){this.priority=0,this.pipe="colorMask",e?.mask&&this.init(e.mask)}init(e){this.mask=e}destroy(){}static test(e){return typeof e=="number"}}Xo.extension=S.MaskEffect;class qo{constructor(e){this.priority=0,this.pipe="stencilMask",e?.mask&&this.init(e.mask)}init(e){this.mask=e,this.mask.includeInBuild=!1,this.mask.measurable=!1}reset(){this.mask!==null&&(this.mask.measurable=!0,this.mask.includeInBuild=!0,this.mask=null)}addBounds(e,t){$o(this.mask,e,t)}addLocalBounds(e,t){Vo(this.mask,e,t)}containsPoint(e,t){const s=this.mask;return t(s,e)}destroy(){this.reset()}static test(e){return e instanceof _e}}qo.extension=S.MaskEffect;const Zu={createCanvas:(i,e)=>{const t=document.createElement("canvas");return t.width=i,t.height=e,t},createImage:()=>new Image,getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(i,e)=>fetch(i,e),parseXML:i=>new DOMParser().parseFromString(i,"text/xml")};let Gh=Zu;const ee={get(){return Gh},set(i){Gh=i}};class Ve extends de{constructor(e){e.resource||(e.resource=ee.get().createCanvas()),e.width||(e.width=e.resource.width,e.autoDensity||(e.width/=e.resolution)),e.height||(e.height=e.resource.height,e.autoDensity||(e.height/=e.resolution)),super(e),this.uploadMethodId="image",this.autoDensity=e.autoDensity,this.resizeCanvas(),this.transparent=!!e.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(e=this.width,t=this.height,s=this._resolution){const r=super.resize(e,t,s);return r&&this.resizeCanvas(),r}static test(e){return globalThis.HTMLCanvasElement&&e instanceof HTMLCanvasElement||globalThis.OffscreenCanvas&&e instanceof OffscreenCanvas}get context2D(){return this._context2D||(this._context2D=this.resource.getContext("2d"))}}Ve.extension=S.TextureSource;class di extends de{constructor(e){super(e),this.uploadMethodId="image",this.autoGarbageCollect=!0}static test(e){return globalThis.HTMLImageElement&&e instanceof HTMLImageElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap||globalThis.VideoFrame&&e instanceof VideoFrame}}di.extension=S.TextureSource;var is=(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))(is||{});class qi{constructor(e,t=null,s=0,r=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=e,this._context=t,this.priority=s,this._once=r}match(e,t=null){return this._fn===e&&this._context===t}emit(e){this._fn&&(this._context?this._fn.call(this._context,e):this._fn(e));const t=this.next;return this._once&&this.destroy(!0),this._destroyed&&(this.next=null),t}connect(e){this.previous=e,e.next&&(e.next.previous=this),this.next=e.next,e.next=this}destroy(e=!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 t=this.next;return this.next=e?null:t,this.previous=null,t}}const Qu=class Ne{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 qi(null,null,1/0),this.deltaMS=1/Ne.targetFPMS,this.elapsedMS=1/Ne.targetFPMS,this._tick=e=>{this._requestId=null,this.started&&(this.update(e),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(e,t,s=is.NORMAL){return this._addListener(new qi(e,t,s))}addOnce(e,t,s=is.NORMAL){return this._addListener(new qi(e,t,s,!0))}_addListener(e){let t=this._head.next,s=this._head;if(!t)e.connect(s);else{for(;t;){if(e.priority>t.priority){e.connect(s);break}s=t,t=t.next}e.previous||e.connect(s)}return this._startIfPossible(),this}remove(e,t){let s=this._head.next;for(;s;)s.match(e,t)?s=s.destroy():s=s.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let e=0,t=this._head;for(;t=t.next;)e++;return e}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let e=this._head.next;for(;e;)e=e.destroy(!0);this._head.destroy(),this._head=null}}update(e=performance.now()){let t;if(e>this.lastTime){if(t=this.elapsedMS=e-this.lastTime,t>this._maxElapsedMS&&(t=this._maxElapsedMS),t*=this.speed,this._minElapsedMS){const n=e-this._lastFrame|0;if(n<this._minElapsedMS)return;this._lastFrame=e-n%this._minElapsedMS}this.deltaMS=t,this.deltaTime=this.deltaMS*Ne.targetFPMS;const s=this._head;let r=s.next;for(;r;)r=r.emit(this);s.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=e}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(e){const t=Math.min(Math.max(0,e)/1e3,Ne.targetFPMS);this._maxElapsedMS=1/t,this._minElapsedMS&&e>this.maxFPS&&(this.maxFPS=e)}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(e){e===0?this._minElapsedMS=0:(e<this.minFPS&&(this.minFPS=e),this._minElapsedMS=1/(e/1e3))}static get shared(){if(!Ne._shared){const e=Ne._shared=new Ne;e.autoStart=!0,e._protected=!0}return Ne._shared}static get system(){if(!Ne._system){const e=Ne._system=new Ne;e.autoStart=!0,e._protected=!0}return Ne._system}};Qu.targetFPMS=.06;let We=Qu,hn;async function Ju(){return hn??(hn=(async()=>{const e=ee.get().createCanvas(1,1).getContext("webgl");if(!e)return"premultiply-alpha-on-upload";const t=await new Promise(o=>{const a=document.createElement("video");a.onloadeddata=()=>o(a),a.onerror=()=>o(null),a.autoplay=!1,a.crossOrigin="anonymous",a.preload="auto",a.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",a.load()});if(!t)return"premultiply-alpha-on-upload";const s=e.createTexture();e.bindTexture(e.TEXTURE_2D,s);const r=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,r),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,s,0),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.NONE),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t);const n=new Uint8Array(4);return e.readPixels(0,0,1,1,e.RGBA,e.UNSIGNED_BYTE,n),e.deleteFramebuffer(r),e.deleteTexture(s),e.getExtension("WEBGL_lose_context")?.loseContext(),n[0]<=n[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),hn}const Tr=class ed extends de{constructor(e){super(e),this.isReady=!1,this.uploadMethodId="video",e={...ed.defaultOptions,...e},this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=e.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=e.autoPlay!==!1,this.alphaMode=e.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),this._onLoadedMetadata=this._onLoadedMetadata.bind(this),e.autoLoad!==!1&&this.load()}updateFrame(){if(!this.destroyed){if(this._updateFPS){const e=We.shared.elapsedMS*this.resource.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-e)}(!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 e=this.resource,t=this.options;return(e.readyState===e.HAVE_ENOUGH_DATA||e.readyState===e.HAVE_FUTURE_DATA)&&e.width&&e.height&&(e.complete=!0),e.addEventListener("play",this._onPlayStart),e.addEventListener("pause",this._onPlayStop),e.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._mediaReady():(t.preload||e.addEventListener("canplay",this._onCanPlay),e.addEventListener("canplaythrough",this._onCanPlayThrough),e.addEventListener("error",this._onError,!0)),this.isValid||e.addEventListener("loadedmetadata",this._onLoadedMetadata),this.alphaMode=await Ju(),this._load=new Promise((s,r)=>{this.isValid?s(this):(this._resolve=s,this._reject=r,t.preloadTimeoutMs!==void 0&&(this._preloadTimeout=setTimeout(()=>{this._onError(new ErrorEvent(`Preload exceeded timeout of ${t.preloadTimeoutMs}ms`))})),e.load())}),this._load}_onError(e){this.resource.removeEventListener("error",this._onError,!0),this.emit("error",e),this._reject&&(this._reject(e),this._reject=null,this._resolve=null)}_isSourcePlaying(){const e=this.resource;return!e.paused&&!e.ended}_isSourceReady(){return this.resource.readyState>2}_onPlayStart(){this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0)}_onLoadedMetadata(){this.isValid&&this._mediaReady()}_onCanPlay(){this.resource.removeEventListener("canplay",this._onCanPlay),this._mediaReady()}_onCanPlayThrough(){this.resource.removeEventListener("canplaythrough",this._onCanPlayThrough),this._preloadTimeout&&(clearTimeout(this._preloadTimeout),this._preloadTimeout=void 0),this._mediaReady()}_mediaReady(){const e=this.resource;this.isValid&&(this.isReady=!0,this.resize(e.videoWidth,e.videoHeight)),this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0,this._resolve&&this.isValid&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&this.resource.play()}destroy(){this._configureAutoUpdate();const e=this.resource;e&&(e.removeEventListener("play",this._onPlayStart),e.removeEventListener("pause",this._onPlayStop),e.removeEventListener("seeked",this._onSeeked),e.removeEventListener("canplay",this._onCanPlay),e.removeEventListener("canplaythrough",this._onCanPlayThrough),e.removeEventListener("loadedmetadata",this._onLoadedMetadata),e.removeEventListener("error",this._onError,!0),e.pause(),e.src="",e.load()),super.destroy()}get autoUpdate(){return this._autoUpdate}set autoUpdate(e){e!==this._autoUpdate&&(this._autoUpdate=e,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(e){e!==this._updateFPS&&(this._updateFPS=e,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.resource.requestVideoFrameCallback?(this._isConnectedToTicker&&(We.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||(We.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(We.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(e){return globalThis.HTMLVideoElement&&e instanceof HTMLVideoElement}};Tr.extension=S.TextureSource;Tr.defaultOptions={...de.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1};Tr.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let td=Tr;const Xt=(i,e,t=!1)=>(Array.isArray(i)||(i=[i]),e?i.map(s=>typeof s=="string"||t?e(s):s):i);class d_{constructor(){this._parsers=[],this._cache=new Map,this._cacheMap=new Map}reset(){this._cacheMap.clear(),this._cache.clear()}has(e){return this._cache.has(e)}get(e){const t=this._cache.get(e);return t||z(`[Assets] Asset id ${e} was not found in the Cache`),t}set(e,t){const s=Xt(e);let r;for(let l=0;l<this.parsers.length;l++){const h=this.parsers[l];if(h.test(t)){r=h.getCacheableAssets(s,t);break}}const n=new Map(Object.entries(r||{}));r||s.forEach(l=>{n.set(l,t)});const o=[...n.keys()],a={cacheKeys:o,keys:s};s.forEach(l=>{this._cacheMap.set(l,a)}),o.forEach(l=>{const h=r?r[l]:t;this._cache.has(l)&&this._cache.get(l)!==h&&z("[Cache] already has key:",l),this._cache.set(l,n.get(l))})}remove(e){if(!this._cacheMap.has(e)){z(`[Assets] Asset id ${e} was not found in the Cache`);return}const t=this._cacheMap.get(e);t.cacheKeys.forEach(r=>{this._cache.delete(r)}),t.keys.forEach(r=>{this._cacheMap.delete(r)})}get parsers(){return this._parsers}}const qt=new d_,zn=[];q.handleByList(S.TextureSource,zn);function sd(i={}){const e=i&&i.resource,t=e?i.resource:i,s=e?i:{resource:i};for(let r=0;r<zn.length;r++){const n=zn[r];if(n.test(t))return new n(s)}throw new Error(`Could not find a source type for resource: ${s.resource}`)}function id(i={},e=!1){const t=i&&i.resource,s=t?i.resource:i,r=t?i:{resource:i};if(!e&&qt.has(s))return qt.get(s);const n=new W({source:sd(r)});return n.on("destroy",()=>{qt.has(s)&&qt.remove(s)}),e||qt.set(s,n),n}function rd(i,e=!1){return typeof i=="string"?qt.get(i):i instanceof de?new W({source:i}):id(i,e)}W.from=rd;de.from=sd;q.add(jo,Xo,qo,td,di,Ve,gr);var Yo=(i=>(i[i.Low=0]="Low",i[i.Normal=1]="Normal",i[i.High=2]="High",i))(Yo||{});function et(i){if(typeof i!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(i)}`)}function Ns(i){return i.split("?")[0].split("#")[0]}function f_(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function p_(i,e,t){return i.replace(new RegExp(f_(e),"g"),t)}function m_(i,e){let t="",s=0,r=-1,n=0,o=-1;for(let a=0;a<=i.length;++a){if(a<i.length)o=i.charCodeAt(a);else{if(o===47)break;o=47}if(o===47){if(!(r===a-1||n===1))if(r!==a-1&&n===2){if(t.length<2||s!==2||t.charCodeAt(t.length-1)!==46||t.charCodeAt(t.length-2)!==46){if(t.length>2){const l=t.lastIndexOf("/");if(l!==t.length-1){l===-1?(t="",s=0):(t=t.slice(0,l),s=t.length-1-t.lastIndexOf("/")),r=a,n=0;continue}}else if(t.length===2||t.length===1){t="",s=0,r=a,n=0;continue}}}else t.length>0?t+=`/${i.slice(r+1,a)}`:t=i.slice(r+1,a),s=a-r-1;r=a,n=0}else o===46&&n!==-1?++n:n=-1}return t}const Ms={toPosix(i){return p_(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){et(i),i=this.toPosix(i);const e=/^file:\/\/\//.exec(i);if(e)return e[0];const t=/^[^/:]+:\/{0,2}/.exec(i);return t?t[0]:""},toAbsolute(i,e,t){if(et(i),this.isDataUrl(i)||this.isBlobUrl(i))return i;const s=Ns(this.toPosix(e??ee.get().getBaseUrl())),r=Ns(this.toPosix(t??this.rootname(s)));return i=this.toPosix(i),i.startsWith("/")?Ms.join(r,i.slice(1)):this.isAbsolute(i)?i:this.join(s,i)},normalize(i){if(et(i),i.length===0)return".";if(this.isDataUrl(i)||this.isBlobUrl(i))return i;i=this.toPosix(i);let e="";const t=i.startsWith("/");this.hasProtocol(i)&&(e=this.rootname(i),i=i.slice(e.length));const s=i.endsWith("/");return i=m_(i),i.length>0&&s&&(i+="/"),t?`/${i}`:e+i},isAbsolute(i){return et(i),i=this.toPosix(i),this.hasProtocol(i)?!0:i.startsWith("/")},join(...i){if(i.length===0)return".";let e;for(let t=0;t<i.length;++t){const s=i[t];if(et(s),s.length>0)if(e===void 0)e=s;else{const r=i[t-1]??"";this.joinExtensions.includes(this.extname(r).toLowerCase())?e+=`/../${s}`:e+=`/${s}`}}return e===void 0?".":this.normalize(e)},dirname(i){if(et(i),i.length===0)return".";i=this.toPosix(i);let e=i.charCodeAt(0);const t=e===47;let s=-1,r=!0;const n=this.getProtocol(i),o=i;i=i.slice(n.length);for(let a=i.length-1;a>=1;--a)if(e=i.charCodeAt(a),e===47){if(!r){s=a;break}}else r=!1;return s===-1?t?"/":this.isUrl(o)?n+i:n:t&&s===1?"//":n+i.slice(0,s)},rootname(i){et(i),i=this.toPosix(i);let e="";if(i.startsWith("/")?e="/":e=this.getProtocol(i),this.isUrl(i)){const t=i.indexOf("/",e.length);t!==-1?e=i.slice(0,t):e=i,e.endsWith("/")||(e+="/")}return e},basename(i,e){et(i),e&&et(e),i=Ns(this.toPosix(i));let t=0,s=-1,r=!0,n;if(e!==void 0&&e.length>0&&e.length<=i.length){if(e.length===i.length&&e===i)return"";let o=e.length-1,a=-1;for(n=i.length-1;n>=0;--n){const l=i.charCodeAt(n);if(l===47){if(!r){t=n+1;break}}else a===-1&&(r=!1,a=n+1),o>=0&&(l===e.charCodeAt(o)?--o===-1&&(s=n):(o=-1,s=a))}return t===s?s=a:s===-1&&(s=i.length),i.slice(t,s)}for(n=i.length-1;n>=0;--n)if(i.charCodeAt(n)===47){if(!r){t=n+1;break}}else s===-1&&(r=!1,s=n+1);return s===-1?"":i.slice(t,s)},extname(i){et(i),i=Ns(this.toPosix(i));let e=-1,t=0,s=-1,r=!0,n=0;for(let o=i.length-1;o>=0;--o){const a=i.charCodeAt(o);if(a===47){if(!r){t=o+1;break}continue}s===-1&&(r=!1,s=o+1),a===46?e===-1?e=o:n!==1&&(n=1):e!==-1&&(n=-1)}return e===-1||s===-1||n===0||n===1&&e===s-1&&e===t+1?"":i.slice(e,s)},parse(i){et(i);const e={root:"",dir:"",base:"",ext:"",name:""};if(i.length===0)return e;i=Ns(this.toPosix(i));let t=i.charCodeAt(0);const s=this.isAbsolute(i);let r;e.root=this.rootname(i),s||this.hasProtocol(i)?r=1:r=0;let n=-1,o=0,a=-1,l=!0,h=i.length-1,c=0;for(;h>=r;--h){if(t=i.charCodeAt(h),t===47){if(!l){o=h+1;break}continue}a===-1&&(l=!1,a=h+1),t===46?n===-1?n=h:c!==1&&(c=1):n!==-1&&(c=-1)}return n===-1||a===-1||c===0||c===1&&n===a-1&&n===o+1?a!==-1&&(o===0&&s?e.base=e.name=i.slice(1,a):e.base=e.name=i.slice(o,a)):(o===0&&s?(e.name=i.slice(1,n),e.base=i.slice(1,a)):(e.name=i.slice(o,n),e.base=i.slice(o,a)),e.ext=i.slice(n,a)),e.dir=this.dirname(i),e},sep:"/",delimiter:":",joinExtensions:[".html"]};function nd(i,e,t,s,r){const n=e[t];for(let o=0;o<n.length;o++){const a=n[o];t<e.length-1?nd(i.replace(s[t],a),e,t+1,s,r):r.push(i.replace(s[t],a))}}function od(i){const e=/\{(.*?)\}/g,t=i.match(e),s=[];if(t){const r=[];t.forEach(n=>{const o=n.substring(1,n.length-1).split(",");r.push(o)}),nd(i,r,0,t,s)}else s.push(i);return s}const Wn=i=>!Array.isArray(i);class Ko{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(e,t)=>`${e}${this._bundleIdConnector}${t}`,extractAssetIdFromBundle:(e,t)=>t.replace(`${e}${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(e){if(this._bundleIdConnector=e.connector??this._bundleIdConnector,this._createBundleAssetId=e.createBundleAssetId??this._createBundleAssetId,this._extractAssetIdFromBundle=e.extractAssetIdFromBundle??this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...e){e.forEach(t=>{this._preferredOrder.push(t),t.priority||(t.priority=Object.keys(t.params))}),this._resolverHash={}}set basePath(e){this._basePath=e}get basePath(){return this._basePath}set rootPath(e){this._rootPath=e}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(e){if(typeof e=="string")this._defaultSearchParams=e;else{const t=e;this._defaultSearchParams=Object.keys(t).map(s=>`${encodeURIComponent(s)}=${encodeURIComponent(t[s])}`).join("&")}}getAlias(e){const{alias:t,src:s}=e;return Xt(t||s,n=>typeof n=="string"?n:Array.isArray(n)?n.map(o=>o?.src??o):n?.src?n.src:n,!0)}removeAlias(e,t){this._assetMap[e]&&(t&&t!==this._resolverHash[e]||(delete this._resolverHash[e],delete this._assetMap[e]))}addManifest(e){this._manifest&&z("[Resolver] Manifest already exists, this will be overwritten"),this._manifest=e,e.bundles.forEach(t=>{this.addBundle(t.name,t.assets)})}addBundle(e,t){const s=[];let r=t;Array.isArray(t)||(r=Object.entries(t).map(([n,o])=>typeof o=="string"||Array.isArray(o)?{alias:n,src:o}:{alias:n,...o})),r.forEach(n=>{const o=n.src,a=n.alias;let l;if(typeof a=="string"){const h=this._createBundleAssetId(e,a);s.push(h),l=[a,h]}else{const h=a.map(c=>this._createBundleAssetId(e,c));s.push(...h),l=[...a,...h]}this.add({...n,alias:l,src:o})}),this._bundles[e]=s}add(e){const t=[];Array.isArray(e)?t.push(...e):t.push(e);let s;s=n=>{this.hasKey(n)&&z(`[Resolver] already has key: ${n} overwriting`)},Xt(t).forEach(n=>{const{src:o}=n;let{data:a,format:l,loadParser:h,parser:c}=n;const u=Xt(o).map(g=>typeof g=="string"?od(g):Array.isArray(g)?g:[g]),d=this.getAlias(n);Array.isArray(d)?d.forEach(s):s(d);const f=[],p=g=>{const m=this._parsers.find(_=>_.test(g));return{src:g,...m?.parse(g)}};u.forEach(g=>{g.forEach(m=>{let _={};if(typeof m!="object"?_=p(m):(a=m.data??a,l=m.format??l,(m.loadParser||m.parser)&&(h=m.loadParser??h,c=m.parser??c),_={...p(m.src),...m}),!d)throw new Error(`[Resolver] alias is undefined for this asset: ${_.src}`);_=this._buildResolvedAsset(_,{aliases:d,data:a,format:l,loadParser:h,parser:c,progressSize:n.progressSize}),f.push(_)})}),d.forEach(g=>{this._assetMap[g]=f})})}resolveBundle(e){const t=Wn(e);e=Xt(e);const s={};return e.forEach(r=>{const n=this._bundles[r];if(n){const o=this.resolve(n),a={};for(const l in o){const h=o[l];a[this._extractAssetIdFromBundle(r,l)]=h}s[r]=a}}),t?s[e[0]]:s}resolveUrl(e){const t=this.resolve(e);if(typeof e!="string"){const s={};for(const r in t)s[r]=t[r].src;return s}return t.src}resolve(e){const t=Wn(e);e=Xt(e);const s={};return e.forEach(r=>{if(!this._resolverHash[r])if(this._assetMap[r]){let n=this._assetMap[r];const o=this._getPreferredOrder(n);o?.priority.forEach(a=>{o.params[a].forEach(l=>{const h=n.filter(c=>c[a]?c[a]===l:!1);h.length&&(n=h)})}),this._resolverHash[r]=n[0]}else this._resolverHash[r]=this._buildResolvedAsset({alias:[r],src:r},{});s[r]=this._resolverHash[r]}),t?s[e[0]]:s}hasKey(e){return!!this._assetMap[e]}hasBundle(e){return!!this._bundles[e]}_getPreferredOrder(e){for(let t=0;t<e.length;t++){const s=e[t],r=this._preferredOrder.find(n=>n.params.format.includes(s.format));if(r)return r}return this._preferredOrder[0]}_appendDefaultSearchParams(e){if(!this._defaultSearchParams)return e;const t=/\?/.test(e)?"&":"?";return`${e}${t}${this._defaultSearchParams}`}_buildResolvedAsset(e,t){const{aliases:s,data:r,loadParser:n,parser:o,format:a,progressSize:l}=t;return(this._basePath||this._rootPath)&&(e.src=Ms.toAbsolute(e.src,this._basePath,this._rootPath)),e.alias=s??e.alias??[e.src],e.src=this._appendDefaultSearchParams(e.src),e.data={...r||{},...e.data},e.loadParser=n??e.loadParser,e.parser=o??e.parser,e.format=a??e.format??ad(e.src),l!==void 0&&(e.progressSize=l),e}}Ko.RETINA_PREFIX=/@([0-9\.]+)x/;function ad(i){return i.split(".").pop().split("?").shift().split("#").shift()}const $n=(i,e)=>{const t=e.split("?")[1];return t&&(i+=`?${t}`),i},ld=class Qs{constructor(e,t){this.linkedSheets=[];let s=e;e?.source instanceof de&&(s={texture:e,data:t});const{texture:r,data:n,cachePrefix:o=""}=s;this.cachePrefix=o,this._texture=r instanceof W?r:null,this.textureSource=r.source,this.textures={},this.animations={},this.data=n;const a=parseFloat(n.meta.scale);a?(this.resolution=a,r.source.resolution=this.resolution):this.resolution=r.source._resolution,this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}parse(){return new Promise(e=>{this._callback=e,this._batchIndex=0,this._frameKeys.length<=Qs.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}parseSync(){return this._processFrames(0,!0),this._processAnimations(),this.textures}_processFrames(e,t=!1){let s=e;const r=t?1/0:Qs.BATCH_SIZE;for(;s-e<r&&s<this._frameKeys.length;){const n=this._frameKeys[s],o=this._frames[n],a=o.frame;if(a){let l=null,h=null;const c=o.trimmed!==!1&&o.sourceSize?o.sourceSize:o.frame,u=new te(0,0,Math.floor(c.w)/this.resolution,Math.floor(c.h)/this.resolution);o.rotated?l=new te(Math.floor(a.x)/this.resolution,Math.floor(a.y)/this.resolution,Math.floor(a.h)/this.resolution,Math.floor(a.w)/this.resolution):l=new te(Math.floor(a.x)/this.resolution,Math.floor(a.y)/this.resolution,Math.floor(a.w)/this.resolution,Math.floor(a.h)/this.resolution),o.trimmed!==!1&&o.spriteSourceSize&&(h=new te(Math.floor(o.spriteSourceSize.x)/this.resolution,Math.floor(o.spriteSourceSize.y)/this.resolution,Math.floor(a.w)/this.resolution,Math.floor(a.h)/this.resolution)),this.textures[n]=new W({source:this.textureSource,frame:l,orig:u,trim:h,rotate:o.rotated?2:0,defaultAnchor:o.anchor,defaultBorders:o.borders,label:n.toString()})}s++}}_processAnimations(){const e=this.data.animations||{};for(const t in e){this.animations[t]=[];for(let s=0;s<e[t].length;s++){const r=e[t][s];this.animations[t].push(this.textures[r])}}}_parseComplete(){const e=this._callback;this._callback=null,this._batchIndex=0,e.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*Qs.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*Qs.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(e=!1){for(const t in this.textures)this.textures[t].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,e&&(this._texture?.destroy(),this.textureSource.destroy()),this._texture=null,this.textureSource=null,this.linkedSheets=[]}};ld.BATCH_SIZE=1e3;let Vn=ld;const g_=["jpg","png","jpeg","avif","webp","basis","etc2","bc7","bc6h","bc5","bc4","bc3","bc2","bc1","eac","astc"];function hd(i,e,t){const s={};if(i.forEach(r=>{s[r]=e}),Object.keys(e.textures).forEach(r=>{s[`${e.cachePrefix}${r}`]=e.textures[r]}),!t){const r=Ms.dirname(i[0]);e.linkedSheets.forEach((n,o)=>{const a=hd([`${r}/${e.data.meta.related_multi_packs[o]}`],n,!0);Object.assign(s,a)})}return s}const cd={extension:S.Asset,cache:{test:i=>i instanceof Vn,getCacheableAssets:(i,e)=>hd(i,e,!1)},resolver:{extension:{type:S.ResolveParser,name:"resolveSpritesheet"},test:i=>{const t=i.split("?")[0].split("."),s=t.pop(),r=t.pop();return s==="json"&&g_.includes(r)},parse:i=>{const e=i.split(".");return{resolution:parseFloat(Ko.RETINA_PREFIX.exec(i)?.[1]??"1"),format:e[e.length-2],src:i}}},loader:{name:"spritesheetLoader",id:"spritesheet",extension:{type:S.LoadParser,priority:Yo.Normal,name:"spritesheetLoader"},async testParse(i,e){return Ms.extname(e.src).toLowerCase()===".json"&&!!i.frames},async parse(i,e,t){const{texture:s,imageFilename:r,textureOptions:n,cachePrefix:o}=e?.data??{};let a=Ms.dirname(e.src);a&&a.lastIndexOf("/")!==a.length-1&&(a+="/");let l;if(s instanceof W)l=s;else{const u=$n(a+(r??i.meta.image),e.src);l=(await t.load([{src:u,data:n}]))[u]}const h=new Vn({texture:l.source,data:i,cachePrefix:o});await h.parse();const c=i?.meta?.related_multi_packs;if(Array.isArray(c)){const u=[];for(const f of c){if(typeof f!="string")continue;let p=a+f;e.data?.ignoreMultiPack||(p=$n(p,e.src),u.push(t.load({src:p,data:{textureOptions:n,ignoreMultiPack:!0}})))}const d=await Promise.all(u);h.linkedSheets=d,d.forEach(f=>{f.linkedSheets=[h].concat(h.linkedSheets.filter(p=>p!==f))})}return h},async unload(i,e,t){await t.unload(i.textureSource._sourceOrigin),i.destroy(!1)}}};q.add(cd);class Zo{constructor(e){this._lastTransform="",this._observer=null,this._tickerAttached=!1,this.updateTranslation=()=>{if(!this._canvas)return;const t=this._canvas.getBoundingClientRect(),s=this._canvas.width,r=this._canvas.height,n=t.width/s*this._renderer.resolution,o=t.height/r*this._renderer.resolution,a=t.left,l=t.top,h=`translate(${a}px, ${l}px) scale(${n}, ${o})`;h!==this._lastTransform&&(this._domElement.style.transform=h,this._lastTransform=h)},this._domElement=e.domElement,this._renderer=e.renderer,!(globalThis.OffscreenCanvas&&this._renderer.canvas instanceof OffscreenCanvas)&&(this._canvas=this._renderer.canvas,this._attachObserver())}get canvas(){return this._canvas}ensureAttached(){!this._domElement.parentNode&&this._canvas.parentNode&&(this._canvas.parentNode.appendChild(this._domElement),this.updateTranslation())}_attachObserver(){"ResizeObserver"in globalThis?(this._observer&&(this._observer.disconnect(),this._observer=null),this._observer=new ResizeObserver(e=>{for(const t of e){if(t.target!==this._canvas)continue;const s=this.canvas.width,r=this.canvas.height,n=t.contentRect.width/s*this._renderer.resolution,o=t.contentRect.height/r*this._renderer.resolution;(this._lastScaleX!==n||this._lastScaleY!==o)&&(this.updateTranslation(),this._lastScaleX=n,this._lastScaleY=o)}}),this._observer.observe(this._canvas)):this._tickerAttached||We.shared.add(this.updateTranslation,this,is.HIGH)}destroy(){this._observer?(this._observer.disconnect(),this._observer=null):this._tickerAttached&&We.shared.remove(this.updateTranslation),this._domElement=null,this._renderer=null,this._canvas=null,this._tickerAttached=!1,this._lastTransform="",this._lastScaleX=null,this._lastScaleY=null}}class Gs{constructor(e){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=Gs.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new he,this.page=new he,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=e}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}get data(){return this}composedPath(){return this.manager&&(!this.path||this.path[this.path.length-1]!==this.target)&&(this.path=this.target?this.manager.propagationPath(this.target):[]),this.path}initEvent(e,t,s){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(e,t,s,r,n){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}var cn=/iPhone/i,Dh=/iPod/i,Fh=/iPad/i,Oh=/\biOS-universal(?:.+)Mac\b/i,un=/\bAndroid(?:.+)Mobile\b/i,Lh=/Android/i,cs=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,Ai=/Silk/i,yt=/Windows Phone/i,Uh=/\bWindows(?:.+)ARM\b/i,Nh=/BlackBerry/i,Hh=/BB10/i,zh=/Opera Mini/i,Wh=/\b(CriOS|Chrome)(?:.+)Mobile/i,$h=/Mobile(?:.+)Firefox\b/i,Vh=function(i){return typeof i<"u"&&i.platform==="MacIntel"&&typeof i.maxTouchPoints=="number"&&i.maxTouchPoints>1&&typeof MSStream>"u"};function __(i){return function(e){return e.test(i)}}function jh(i){var e={userAgent:"",platform:"",maxTouchPoints:0};!i&&typeof navigator<"u"?e={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof i=="string"?e.userAgent=i:i&&i.userAgent&&(e={userAgent:i.userAgent,platform:i.platform,maxTouchPoints:i.maxTouchPoints||0});var t=e.userAgent,s=t.split("[FBAN");typeof s[1]<"u"&&(t=s[0]),s=t.split("Twitter"),typeof s[1]<"u"&&(t=s[0]);var r=__(t),n={apple:{phone:r(cn)&&!r(yt),ipod:r(Dh),tablet:!r(cn)&&(r(Fh)||Vh(e))&&!r(yt),universal:r(Oh),device:(r(cn)||r(Dh)||r(Fh)||r(Oh)||Vh(e))&&!r(yt)},amazon:{phone:r(cs),tablet:!r(cs)&&r(Ai),device:r(cs)||r(Ai)},android:{phone:!r(yt)&&r(cs)||!r(yt)&&r(un),tablet:!r(yt)&&!r(cs)&&!r(un)&&(r(Ai)||r(Lh)),device:!r(yt)&&(r(cs)||r(Ai)||r(un)||r(Lh))||r(/\bokhttp\b/i)},windows:{phone:r(yt),tablet:r(Uh),device:r(yt)||r(Uh)},other:{blackberry:r(Nh),blackberry10:r(Hh),opera:r(zh),firefox:r($h),chrome:r(Wh),device:r(Nh)||r(Hh)||r(zh)||r($h)||r(Wh)},any:!1,phone:!1,tablet:!1};return n.any=n.apple.device||n.android.device||n.windows.device||n.other.device,n.phone=n.apple.phone||n.android.phone||n.windows.phone,n.tablet=n.apple.tablet||n.android.tablet||n.windows.tablet,n}const y_=jh.default??jh,ud=y_(globalThis.navigator),x_=9,Xh=100,b_=0,v_=0,qh=2,Yh=1,w_=-1e3,T_=-1e3,S_=2,Qo=class dd{constructor(e,t=ud){this._mobileInfo=t,this.debug=!1,this._activateOnTab=!0,this._deactivateOnMouseMove=!0,this._isActive=!1,this._isMobileAccessibility=!1,this._div=null,this._pools={},this._renderId=0,this._children=[],this._androidUpdateCount=0,this._androidUpdateFrequency=500,this._isRunningTests=!1,this._boundOnKeyDown=this._onKeyDown.bind(this),this._boundOnMouseMove=this._onMouseMove.bind(this),this._hookDiv=null,(t.tablet||t.phone)&&this._createTouchHook(),this._renderer=e}get isActive(){return this._isActive}get isMobileAccessibility(){return this._isMobileAccessibility}get hookDiv(){return this._hookDiv}get div(){return this._div}_createTouchHook(){const e=document.createElement("button");e.style.width=`${Yh}px`,e.style.height=`${Yh}px`,e.style.position="absolute",e.style.top=`${w_}px`,e.style.left=`${T_}px`,e.style.zIndex=S_.toString(),e.style.backgroundColor="#FF0000",e.title="select to enable accessibility for this content",e.addEventListener("focus",()=>{this._isMobileAccessibility=!0,this._activate(),this._destroyTouchHook()}),document.body.appendChild(e),this._hookDiv=e}_destroyTouchHook(){this._hookDiv&&(document.body.removeChild(this._hookDiv),this._hookDiv=null)}_activate(){if(this._isActive)return;this._isActive=!0,this._div||(this._div=document.createElement("div"),this._div.style.position="absolute",this._div.style.top=`${b_}px`,this._div.style.left=`${v_}px`,this._div.style.pointerEvents="none",this._div.style.zIndex=qh.toString(),this._canvasObserver=new Zo({domElement:this._div,renderer:this._renderer})),this._deactivateOnMouseMove&&globalThis.document.addEventListener("mousemove",this._boundOnMouseMove,!0);const e=this._renderer.view.canvas;if(e.parentNode)this._canvasObserver.ensureAttached(),this._initAccessibilitySetup();else{const t=new MutationObserver(()=>{e.parentNode&&(t.disconnect(),this._canvasObserver.ensureAttached(),this._initAccessibilitySetup())});t.observe(document.body,{childList:!0,subtree:!0})}}_initAccessibilitySetup(){this._renderer.runners.postrender.add(this),this._renderer.lastObjectRendered&&this._updateAccessibleObjects(this._renderer.lastObjectRendered)}_deactivate(){if(!(!this._isActive||this._isMobileAccessibility)){this._isActive=!1,globalThis.document.removeEventListener("mousemove",this._boundOnMouseMove,!0),this._renderer.runners.postrender.remove(this);for(const e of this._children)e._accessibleDiv?.parentNode&&(e._accessibleDiv.parentNode.removeChild(e._accessibleDiv),e._accessibleDiv=null),e._accessibleActive=!1;for(const e in this._pools)this._pools[e].forEach(s=>{s.parentNode&&s.parentNode.removeChild(s)}),delete this._pools[e];this._div?.parentNode&&this._div.parentNode.removeChild(this._div),this._pools={},this._children=[]}}_updateAccessibleObjects(e){if(!e.visible||!e.accessibleChildren)return;e.accessible&&(e._accessibleActive||this._addChild(e),e._renderId=this._renderId);const t=e.children;if(t)for(let s=0;s<t.length;s++)this._updateAccessibleObjects(t[s])}init(e){const s={accessibilityOptions:{...dd.defaultOptions,...e?.accessibilityOptions||{}}};this.debug=s.accessibilityOptions.debug,this._activateOnTab=s.accessibilityOptions.activateOnTab,this._deactivateOnMouseMove=s.accessibilityOptions.deactivateOnMouseMove,this._activateOnTab&&globalThis.addEventListener("keydown",this._boundOnKeyDown,!1),s.accessibilityOptions.enabledByDefault&&this._activate(),this._renderer.runners.postrender.remove(this)}postrender(){const e=performance.now();if(this._mobileInfo.android.device&&e<this._androidUpdateCount||(this._androidUpdateCount=e+this._androidUpdateFrequency,(!this._renderer.renderingToScreen||!this._renderer.view.canvas)&&!this._isRunningTests))return;const t=new Set;if(this._renderer.lastObjectRendered){this._updateAccessibleObjects(this._renderer.lastObjectRendered);for(const s of this._children)s._renderId===this._renderId&&t.add(this._children.indexOf(s))}for(let s=this._children.length-1;s>=0;s--){const r=this._children[s];t.has(s)||(r._accessibleDiv&&r._accessibleDiv.parentNode&&(r._accessibleDiv.parentNode.removeChild(r._accessibleDiv),this._getPool(r.accessibleType).push(r._accessibleDiv),r._accessibleDiv=null),r._accessibleActive=!1,Ho(this._children,s,1))}this._renderer.renderingToScreen&&this._canvasObserver.ensureAttached();for(let s=0;s<this._children.length;s++){const r=this._children[s];if(!r._accessibleActive||!r._accessibleDiv)continue;const n=r._accessibleDiv,o=r.hitArea||r.getBounds().rectangle;if(r.hitArea){const a=r.worldTransform;n.style.left=`${a.tx+o.x*a.a}px`,n.style.top=`${a.ty+o.y*a.d}px`,n.style.width=`${o.width*a.a}px`,n.style.height=`${o.height*a.d}px`}else this._capHitArea(o),n.style.left=`${o.x}px`,n.style.top=`${o.y}px`,n.style.width=`${o.width}px`,n.style.height=`${o.height}px`}this._renderId++}_updateDebugHTML(e){e.innerHTML=`type: ${e.type}</br> title : ${e.title}</br> tabIndex: ${e.tabIndex}`}_capHitArea(e){e.x<0&&(e.width+=e.x,e.x=0),e.y<0&&(e.height+=e.y,e.y=0);const{width:t,height:s}=this._renderer;e.x+e.width>t&&(e.width=t-e.x),e.y+e.height>s&&(e.height=s-e.y)}_addChild(e){let s=this._getPool(e.accessibleType).pop();s?(s.innerHTML="",s.removeAttribute("title"),s.removeAttribute("aria-label"),s.tabIndex=0):(e.accessibleType==="button"?(s=document.createElement("button"),this.debug||(s.style.color="transparent")):(s=document.createElement(e.accessibleType),s.style.cssText=`
@@ -954,5 +954,5 @@ fn mainFragment(
954
954
  `):Array.isArray(i)?i.map(s=>we(ze(s).text)??"").join(`
955
955
  `):""}function Fx(i){let e=0;for(const t of i.matchAll(/<<-?\s*(['"]?)(\w+)\1[^\n]*\n([\s\S]*?)\n\2(?=\n|$)/g))e+=er(t[3]);return e===0&&/(?:^|[\s)])\d?>{1,2}\s*[^\s|&;<>]+/.test(i)&&!/>\s*\/dev\/null/.test(i)&&(e=1),e}var Ox=new Set(["Grep","Glob","LS","ToolSearch"]),Lx=new Set(["WebSearch","WebFetch"]),Ux=new Set(["TodoWrite","TodoRead","Skill","EnterPlanMode","ExitPlanMode","EnterWorktree","ExitWorktree","NotebookRead","ListAgents","SendMessage","TaskStop","Monitor","ScheduleWakeup","ReportFindings"]);function Zc(i,e){const t=ze(i.input),s=i.response,r=!i.isError&&ze(s).interrupted!==!0,n=a=>Tx(a,e),o=i.durationMs!==void 0?{durationMs:i.durationMs}:{};switch(i.name){case"Read":{const a=we(t.file_path)??we(t.path);if(!a)return{bodies:[],warning:{code:"missing_field",detail:"Read without file_path"}};const l=we(ze(ze(s).file).content);return{bodies:[{kind:"read_file",path:n(a),...l!==void 0?{bytes:l.length}:{}}]}}case"Edit":case"MultiEdit":case"NotebookEdit":{const a=we(t.file_path)??we(t.notebook_path);if(!a)return{bodies:[],warning:{code:"missing_field",detail:`${i.name} without file_path`}};const l=Gx(s)??{added:er(we(t.new_string)??we(t.new_source)),removed:er(we(t.old_string)),hunks:1};return{bodies:[{kind:"edit_file",path:n(a),...l}]}}case"Write":{const a=we(t.file_path);if(!a)return{bodies:[],warning:{code:"missing_field",detail:"Write without file_path"}};const l=ze(s),h=l.type==="create"||l.type===void 0&&l.originalFile===null;return{bodies:[{kind:"write_file",path:n(a),added:er(we(t.content)),created:h}]}}case"Bash":{const a=we(t.command)??"",l=Bx(a),h=[...new Set([...l.writes,...l.reads].map(n))],c=[{kind:"run_command",argv0:l.argv0,intent:l.intent,touched:h,ok:r,...o}],u=Fx(a);l.writes.forEach((d,f)=>c.push({kind:"write_file",path:n(d),added:f===0?u:0,created:!1}));for(const d of l.reads)c.push({kind:"read_file",path:n(d)});if(l.intent==="test"){const d=Ix(Dx(s));d?c.push({kind:"test_result",ok:d.failed===0&&r,passed:d.passed,failed:d.failed,...d.skipped!==void 0?{skipped:d.skipped}:{},framework:d.framework,...o}):c.push({kind:"test_result",ok:r,passed:0,failed:0,framework:"unknown",...o})}return{bodies:c}}case"Agent":case"Task":{const a=ze(s),l=we(a.agentId)??we(a.agent_id)??"",h=we(t.description)??we(t.subagent_type),c={kind:"subagent_start",childId:l,...h?{label:h}:{}};return a.status==="async_launched"||a.isAsync===!0?{bodies:[c],pendingSubagent:{childId:l}}:{bodies:[c,{kind:"subagent_stop",childId:l,ok:r}]}}case"AskUserQuestion":return{bodies:[{kind:"waiting_for_user",reason:"question"}]}}if(Ox.has(i.name)){const a=ze(s).numFiles??ze(s).numLines??ze(s).count;return{bodies:[{kind:"search",scope:"repo",...typeof a=="number"?{hits:a}:{}}]}}return Lx.has(i.name)?{bodies:[{kind:"search",scope:"web"}]}:Ux.has(i.name)?{bodies:[]}:{bodies:[{kind:"run_command",argv0:i.name.slice(0,40),intent:"other",touched:[],ok:r,...o}],warning:{code:"unknown_tool",detail:i.name.slice(0,80)}}}var Nx=[/\ball (?:\d+ )?tests? (?:are )?pass(?:ing|ed)?\b/i,/\btests? (?:are |is )?(?:now )?(?:passing|green)\b/i,/\b(?:is|are|it's|that's|everything(?:'s| is)) (?:now )?(?:fixed|working|done|complete|resolved)\b/i,/\bshould (?:now )?work\b/i,/\bworks now\b/i,/\b(?:done|complete|completed|fixed|resolved|shipped|implemented)[.!]/i,/✅/],Hx=[/\bnot (?:yet )?(?:done|fixed|working|tested|verified|complete)\b/i,/\bstill (?:fail|broken|not)/i,/\b(?:could ?n[’']?t|cannot|can ?not|unable to|wasn[’']?t able)\b/i,/\bfail(?:ed|ing|s)\b/i,/\bTODO\b/,/\bhaven[’']?t (?:run|tested|verified|checked)/i,/\buntested\b/i,/\bI did not (?:run|test|verify)/i],Qc=600;function Jc(i){if(!i)return!1;const e=i.length>Qc?i.slice(-Qc):i;return Hx.some(t=>t.test(e))?!1:Nx.some(t=>t.test(e))}var zx=new Set(["user","assistant","system"]),$i=i=>i&&typeof i=="object"?i:{},be=i=>typeof i=="string"?i:void 0;function Wx(i,e={}){const t=[],s=[],r=i.split(/\r?\n/);for(let o=0;o<r.length;o++){const a=r[o];if(a.trim())try{t.push(JSON.parse(a))}catch{s.push({code:"bad_json",detail:`line ${o+1}`,line:o+1})}}const n=$x(t,e);return{events:n.events,warnings:[...s,...n.warnings]}}function $x(i,e={}){const t=[],s=[],r=new Set,n=new Map,o=new Map;let a="",l="",h,c=Number.NaN,u=Number.NaN,d="",f=0,p=!1;const g=()=>({cwd:l,...e.home?{home:e.home}:{}}),m=(x,b,v,w={})=>{t.push({id:b,seq:f++,ts:x,sessionId:a,source:"transcript",...w,...v})},_=x=>{const b=be(x.timestamp),v=b?Date.parse(b):Number.NaN;return Number.isFinite(v)?v:Number.isFinite(u)?u:0},y=x=>be(x.agentId)??(x.isSidechain===!0?e.sidechainAgentId??"sidechain":void 0);for(const x of i){const b=$i(x),v=be(b.type)??"";if(!zx.has(v)){v&&r.add(v);continue}!a&&be(b.sessionId)&&(a=be(b.sessionId)),!l&&be(b.cwd)&&(l=be(b.cwd)),!h&&be(b.gitBranch)&&(h=be(b.gitBranch));const w=_(b);Number.isFinite(c)||(c=w,m(w,`${a||"session"}:start`,{kind:"session_start",repoId:Sx(l)||"repo",...h?{branch:h}:{}})),u=w;const T=y(b),k=$i(b.message),E=k.content;if(v==="system"){if(b.subtype==="api_error"){const M=typeof b.retryAttempt=="number"?b.retryAttempt:0,B=typeof b.maxRetries=="number"?b.maxRetries:0;m(w,be(b.uuid)??`sys:${f}`,{kind:"error",where:"api",retrying:M<B},T?{agentId:T}:{})}continue}if(v==="assistant"){const M=Array.isArray(E)?E:[];for(const B of M){const G=$i(B);if(G.type==="tool_use"&&be(G.id)&&be(G.name))n.set(be(G.id),{name:be(G.name),input:G.input,ts:w,...T?{agentId:T}:{}});else if(G.type==="text"&&!T){const O=be(G.text);O&&(d=O)}}typeof E=="string"&&!T&&(d=E),k.stop_reason==="end_turn"&&!T&&m(w,`${be(b.uuid)??f}:turn`,{kind:"turn_end",claimedSuccess:Jc(d)});continue}b.toolDenialKind!==void 0&&m(w,`${be(b.uuid)??f}:deny`,{kind:"waiting_for_user",reason:"permission"});const A=Array.isArray(E)?E:[];for(const M of A){const B=$i(M);if(B.type!=="tool_result")continue;const G=be(B.tool_use_id);if(!G)continue;const O=n.get(G);if(!O){s.push({code:"unpaired_result",detail:G});continue}n.delete(G);const I=b.toolUseResult??B.content,P=Zc({name:O.name,input:O.input,response:I,isError:B.is_error===!0,durationMs:Math.max(0,w-O.ts)},g());P.warning&&s.push(P.warning);const C=O.agentId??T,D=C?o.get(C):void 0,R={...C?{agentId:C}:{},...D?{parentId:D}:{}};P.bodies.forEach((L,N)=>m(O.ts,N===0?G:`${G}:${N}`,L,R)),P.pendingSubagent&&o.set(P.pendingSubagent.childId,G)}A.length===0&&typeof E=="string"&&/\[Request interrupted by user/i.test(E)&&m(w,`${be(b.uuid)??f}:interrupt`,{kind:"waiting_for_user",reason:"idle"})}for(const[x,b]of n){s.push({code:"unpaired_result",detail:`tool_use ${x} (${b.name}) has no result`});const v=Zc({name:b.name,input:b.input,isError:!0},g());v.warning&&s.push(v.warning),v.bodies.forEach((w,T)=>m(b.ts,T===0?x:`${x}:${T}`,w,b.agentId?{agentId:b.agentId}:{}))}for(const[x,b]of o)m(u,`${b}:stop`,{kind:"subagent_stop",childId:x,ok:!0},{parentId:b});for(const x of r)s.push({code:"unknown_row_type",detail:x});return Number.isFinite(c)&&!p&&(p=!0,m(u,`${a||"session"}:end`,{kind:"session_end",reason:"stop",claimedSuccess:Jc(d)})),{events:t,warnings:s}}function Ao(i){let e=2166136261;for(let t=0;t<i.length;t++)e^=i.charCodeAt(t),e=Math.imul(e,16777619);return e>>>0}function li(i){let e=i>>>0;return()=>{e=e+1831565813>>>0;let t=e;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}}var Vx=/(^|\/)(schema\.(sql|prisma|graphql|gql)|.*\.(sql|prisma|db|sqlite)|migrations?\/|drizzle\/|models?\/.*\.(ts|js|py|rb)$)/i,jx=/(^|\/)(node_modules|\.git|dist|build|out|coverage|_site|\.next|\.turbo|target|vendor|__pycache__|\.venv|venv)(\/|$)|(^|\/)\.[^/]+$|\.(lock|map|min\.js|png|jpg|jpeg|gif|webp|svg|ico|woff2?|ttf|mp4|mp3|pdf|zip)$/i;function Xx(i){return jx.test(i)}function xg(i){return _g(i)?"beacon":Vx.test(i)?"archive":"building"}function eu(i){return typeof i.loc=="number"?i.loc:typeof i.size=="number"?Math.max(1,Math.round(i.size/40)):1}function qx(i,e){const t=i.filter(n=>!Xx(n.path)),s=Math.max(1,...t.map(eu)),r=Math.max(1,...t.map(n=>n.churn??0));return t.map(n=>{const o=eu(n),a=e.has(n.path),l=.5*Math.sqrt(o/s)+.3*((n.churn??0)/r)+(a?.2:0);return{file:n,loc:o,score:l,kind:xg(n.path),touched:a}})}function tu(i,e){const t=Math.sqrt(i/Math.max(1,e));return Math.max(1,Math.min(5,Math.ceil(t*5)))}function su(i){return i>=5?3:i>=3?2:1}var Yx={ts:"TypeScript",tsx:"TypeScript",js:"JavaScript",jsx:"JavaScript",mjs:"JavaScript",py:"Python",go:"Go",rs:"Rust",java:"Java",kt:"Kotlin",swift:"Swift",rb:"Ruby",php:"PHP",cs:"C#",cpp:"C++",cc:"C++",c:"C",h:"C",m:"Objective-C",scala:"Scala",ex:"Elixir",exs:"Elixir",dart:"Dart",lua:"Lua",zig:"Zig",sh:"Shell",sql:"SQL",md:"Markdown",mdx:"Markdown",html:"HTML",css:"CSS",scss:"CSS",vue:"Vue",svelte:"Svelte",tf:"Terraform",yaml:"YAML",yml:"YAML",ipynb:"Notebook"};function Kx(i,e={}){const t=i.map(p=>p.path.toLowerCase()),s=p=>t.some(g=>p.test(g)),r=p=>t.filter(g=>p.test(g)).length,n=new Map;for(const p of t){const g=p.slice(p.lastIndexOf(".")+1),m=Yx[g];m&&!/^(markdown|yaml|html|css|shell|sql)$/i.test(m)&&n.set(m,(n.get(m)??0)+1)}const o=[...n.entries()].sort((p,g)=>g[1]-p[1]).map(([p])=>p).slice(0,4),a=(e["package.json"]??"").toLowerCase(),l=((e["pyproject.toml"]??"")+(e["requirements.txt"]??"")).toLowerCase(),h=p=>p.test(a)||p.test(l),c=new Map,u=(p,g)=>c.set(p,(c.get(p)??0)+g);h(/"(react|react-dom|next|vue|nuxt|svelte|@sveltejs\/kit|@angular\/core|solid-js|astro|remix|vite)"/)&&u("web-frontend",3),r(/\.(tsx|jsx|vue|svelte)$/)>3&&u("web-frontend",2),(s(/(^|\/)(index|app)\.html$/)||r(/\.(css|scss)$/)>3)&&u("web-frontend",1),h(/"(express|fastify|hono|koa|@nestjs\/core|apollo-server|prisma|drizzle-orm|django|flask|fastapi|sqlalchemy|gin|fiber|actix|axum|rails|spring)"/)&&u("backend-api",3),(s(/(^|\/)(routes?|controllers?|api|handlers?|migrations?)\//)||s(/\.(sql|prisma)$/))&&u("backend-api",2),(a.includes('"bin"')||s(/(^|\/)(cli|cmd|bin)\//)||h(/"(commander|yargs|clap|cobra|click|typer)"/))&&u("cli-tool",3),(h(/"(torch|tensorflow|jax|pandas|numpy|scikit-learn|sklearn|transformers|xgboost|lightgbm|polars)"/)||r(/\.ipynb$/)>0||s(/(^|\/)(notebooks?|models?|datasets?|training)\//))&&u("data-ml",3),(s(/\.(swift|kt)$/)||s(/(^|\/)(ios|android)\//)||s(/package\.swift$/)||s(/build\.gradle(\.kts)?$/)||h(/"(react-native|expo|flutter)"/)||s(/\.dart$/))&&u("mobile",3),(s(/\.(unity|unitypackage|godot|tscn|gd)$/)||s(/(^|\/)assets\/.*\.(prefab|fbx)$/)||h(/"(phaser|pixi\.js|three|babylonjs|@react-three\/fiber|excalibur|kaplay|bevy|godot)"/))&&u("game",3),(s(/\.tf$/)||s(/(^|\/)(dockerfile|docker-compose\.ya?ml|helm|k8s|kubernetes|\.github\/workflows|ansible|pulumi)/))&&u("infra-devops",s(/\.tf$/)||s(/(^|\/)(helm|k8s|kubernetes|ansible|pulumi)\//)?3:1);const d=r(/\.(md|mdx|rst)$/)/Math.max(1,t.length);(d>.4||s(/(^|\/)(mkdocs|docusaurus)\.config|(^|\/)docs\/.*\.mdx?$/)&&d>.25)&&u("docs-content",3),(s(/(^|\/)pnpm-workspace\.ya?ml$/)||s(/(^|\/)packages\/[^/]+\/package\.json$/)||s(/(^|\/)(lerna|nx|turbo)\.json$/)||s(/(^|\/)cargo\.toml$/)&&r(/(^|\/)crates\/[^/]+\//)>0)&&u("monorepo",2),r(/\.(rs|go|c|cpp|cc|h|zig)$/)>5&&!c.has("web-frontend")&&u("systems",2),a.includes('"main"')&&!a.includes('"bin"')&&!c.has("web-frontend")&&!c.has("backend-api")&&u("library",2),s(/(^|\/)(lib|src\/lib)\//)&&!c.has("web-frontend")&&u("library",1);const f=[...c.entries()].filter(([,p])=>p>=2).sort((p,g)=>g[1]-p[1]).map(([p])=>p);return{kinds:f.length?f:["unknown"],languages:o,files:i.length}}function Zx(i){const e=i.cap??60,t=i.beaconCap??8,s=i.touchedCap??48,r=new Set((i.touched??[]).map(iu).slice(0,s)),n=Ao(i.repoId),o=li(n),a=i.files.map(C=>({...C,path:iu(C.path)})),l=qx(a,r),h=Math.max(1,...l.map(C=>C.loc)),c=[...l].sort((C,D)=>D.score-C.score||C.file.path.localeCompare(D.file.path)),u=ou(c.filter(C=>C.kind==="beacon"),t),d=ou(c.filter(C=>C.kind!=="beacon"),e),f=[...d,...u],p=f.length<l.length,g=new Map;for(const C of d){const D=An(C.file.path);(g.get(D)??g.set(D,[]).get(D)).push(C)}const m=[...g.keys()].sort(),_=new Set,y=[],x=[],b={id:"forge",kind:"forge",path:"",label:"forge",district:"",gx:-1,gy:-1,footprint:2,height:2,score:0,touched:!1};y.push(b);const v=i.layout??vi[n%vi.length],w=o()*Math.PI*2,T=m.map(C=>{const D=g.get(C).sort((N,se)=>se.score-N.score||N.file.path.localeCompare(se.file.path)),R=D.reduce((N,se)=>N+su(tu(se.loc,h))**2,0),L=Math.max(3,Math.ceil(Math.sqrt(R*1.45)));return{name:C,items:D,side:L}}),k=[],E={x:-2,y:-2,w:4,h:4},A=Sg(v,T.map(C=>C.side),E,w,o);k.push(E,...A);const M=Cg(v,A);b.gx=M[0],b.gy=M[1],_.clear(),Tt(_,b),T.forEach((C,D)=>{const R=A[D],L={id:`d:${C.name}`,label:C.name===""?"/":`${C.name}/`,bounds:R,cx:R.x+Math.floor(R.w/2),cy:R.y+Math.floor(R.h/2),placeIds:[]};for(const N of C.items){const se=tu(N.loc,h),Q=su(se),re=Ro(_,L.cx,L.cy,Q,R),j={id:`p:${N.file.path}`,kind:N.kind,path:N.file.path,label:ru(N.file.path),district:L.id,gx:re[0],gy:re[1],footprint:Q,height:se,score:nu(N.score),touched:N.touched};Tt(_,j),y.push(j),L.placeIds.push(j.id)}x.push(L)}),Math.ceil(wg(k));for(const C of k)for(let D=C.x-1;D<C.x+C.w+1;D++)for(let R=C.y-1;R<C.y+C.h+1;R++)_.add(`${D},${R}`);for(const C of u){const D=x.find(N=>N.id===`d:${An(C.file.path)}`),R=D?kg(_,D,b,1):wi(_,b.gx+1,b.gy+1,o()*Math.PI*2,4,1),L={id:`p:${C.file.path}`,kind:"beacon",path:C.file.path,label:ru(C.file.path),district:D?.id??"",gx:R[0],gy:R[1],footprint:1,height:4,score:nu(C.score),touched:C.touched};Tt(_,L),y.push(L),D?.placeIds.push(L.id)}const B=wi(_,b.gx+1,b.gy+1,w+Math.PI,5,2),G={id:"dock",kind:"dock",path:"",label:"dock",district:"",gx:B[0],gy:B[1],footprint:2,height:1,score:0,touched:!1};Tt(_,G),y.push(G);const O=Mg(v,x,b,G);if(p)for(const C of x){const D=C.id.slice(2),R=l.filter(se=>se.kind!=="beacon"&&An(se.file.path)===D).length;if(R<=C.placeIds.length)continue;const L=Ro(_,C.cx,C.cy,1,C.bounds),N={id:`p:${D?D+"/":""}…`,kind:"overflow",path:`${D?D+"/":""}…`,label:`+${R-C.placeIds.length} more`,district:C.id,gx:L[0],gy:L[1],footprint:1,height:2,score:0,touched:!1};Tt(_,N),y.push(N),C.placeIds.push(N.id)}const I=Tg(y,2),P=Kx(a,i.manifests??{});return{repoId:i.repoId,seed:n,layout:v,profile:P,districts:x,places:y,paths:O,bounds:I,stats:{files:l.length,placed:f.length,capped:p}}}var iu=i=>i.replace(/\\/g,"/").replace(/^\.\//,"").replace(/^\/+/,""),ru=i=>i.slice(i.lastIndexOf("/")+1),An=i=>i.includes("/")?i.slice(0,i.indexOf("/")):"",nu=i=>Math.round(i*1e3)/1e3;function ou(i,e){const t=i.filter(r=>r.touched),s=i.filter(r=>!r.touched);return[...t,...s.slice(0,Math.max(0,e-t.length))]}function au(i,e,t){return i.x<e.x+e.w+t&&e.x<i.x+i.w+t&&i.y<e.y+e.h+t&&e.y<i.y+i.h+t}function bg(i,e,t){const s=[];for(let r=0;r<t;r++)for(let n=0;n<t;n++)s.push(`${i+r},${e+n}`);return s}function vg(i,e,t,s){return bg(e,t,s).every(r=>!i.has(r))}function Tt(i,e){for(const t of bg(e.gx,e.gy,e.footprint))i.add(t)}function Ro(i,e,t,s,r){let n=0,o=0,a=0,l=-1,h=null;for(let c=0;c<4096;c++){const u=e+n-Math.floor(s/2),d=t+o-Math.floor(s/2);if(vg(i,u,d,s)){if(u>=r.x-1&&d>=r.y-1&&u+s<=r.x+r.w+1&&d+s<=r.y+r.h+1)return[u,d];if(h??=[u,d],c>600)return h}(n===o||n<0&&n===-o||n>0&&n===1-o)&&([a,l]=[-l,a]),n+=a,o+=l}return h??[e,t]}function wg(i){return Math.max(...i.map(e=>Math.max(Math.abs(e.x),Math.abs(e.x+e.w),Math.abs(e.y),Math.abs(e.y+e.h))))}function Tg(i,e){const t=i.flatMap(o=>[o.gx,o.gx+o.footprint]),s=i.flatMap(o=>[o.gy,o.gy+o.footprint]),r=Math.min(...t)-e,n=Math.min(...s)-e;return{x:r,y:n,w:Math.max(...t)+e-r,h:Math.max(...s)+e-n}}var vi=["ring","grid","strip","scatter","terrace","spine"];function Sg(i,e,t,s,r){const n=e.length,o=[],a=Math.max(3,...e),l=c=>!au(t,c,1)&&!o.some(u=>au(u,c,1)),h=(c,u,d)=>{const f={x:c,y:u,w:d,h:d};return o.push(f),f};switch(i){case"grid":{const c=Math.max(2,Math.ceil(Math.sqrt(n+1))),u=[];let d=0,f=0;for(;f<n;){const m=e.slice(f,f+c),_=Math.max(...m)+2;let y=0;for(const x of m)u.push({x:y,y:d}),y+=x+2;d+=_,f+=c}const p=Math.max(...u.map((m,_)=>m.x+e[_])),g=d;for(let m=0;m<n;m++){let _={x:u[m].x-Math.round(p/2),y:u[m].y-Math.round(g/2),w:e[m],h:e[m]};for(;!l(_);)_={..._,x:_.x+1};o.push(_)}return o}case"strip":{const c=e.reduce((d,f)=>d+f+2,0);let u=Math.round(-c/2)+6;for(let d=0;d<n;d++){const f=Math.round((r()-.5)*3);h(u,f-Math.floor(e[d]/2),e[d]),u+=e[d]+2}return o}case"terrace":{let c=-Math.round(n*(a+1)/2),u=-Math.round(n*(a+1)*.3);for(let d=0;d<n;d++)h(c,u,e[d]),c+=e[d]+1,u+=Math.round(e[d]*.6)+1;return o}case"spine":{let c=-Math.round(n*(a+2)/4);for(let u=0;u<n;u++){const d=u%2===0;h(d?-e[u]-3:3,c,e[u]),d||(c+=a+2)}return o}case"scatter":{for(let c=0;c<n;c++){let u=5+a,d=!1;for(let f=0;f<400&&!d;f++){const p=s+r()*Math.PI*2,g=u*(.5+r()*.7),m={x:Math.round(Math.cos(p)*g),y:Math.round(Math.sin(p)*g*.8),w:e[c],h:e[c]};l(m)&&(o.push(m),d=!0),f%40===39&&(u+=2)}d||h(u+c*2,0,e[c])}return o}default:{let c=3;for(let u=0;u<n;u++){const d=e[u],f=s+u/Math.max(1,n)*Math.PI*2;let p=c+d/2,g;for(;;){const m=Math.round(Math.cos(f)*p),_=Math.round(Math.sin(f)*p*.8);if(g={x:m-Math.floor(d/2),y:_-Math.floor(d/2),w:d,h:d},l(g))break;p+=1}o.push(g),c=Math.max(c,p-d/2)}return o}}}function Cg(i,e){if(!e.length)return[-1,-1];const t=Math.min(...e.map(r=>r.x)),s=Math.min(...e.map(r=>r.y));switch(i){case"strip":return[t-5,-1];case"terrace":return[t-5,s-1];case"spine":return[-1,s-5];default:return[-1,-1]}}function Mg(i,e,t,s){const r=[t.gx+1,t.gy+1],n=[];if(i==="strip"||i==="terrace"){const o=[...e].sort((h,c)=>h.cx-c.cx||h.cy-c.cy);let a=r,l="forge";for(const h of o)n.push({from:l,to:h.id,points:[a,[h.cx,h.cy]]}),a=[h.cx,h.cy],l=h.id}else if(i==="grid"||i==="spine")for(const o of e)n.push({from:o.id,to:"forge",points:[[o.cx,o.cy],[o.cx,r[1]],r]});else for(const o of e)n.push({from:o.id,to:"forge",points:[[o.cx,o.cy],[Math.round((o.cx+r[0])/2),Math.round((o.cy+r[1])/2)],r]});return n.push({from:"dock",to:"forge",points:[[s.gx,s.gy],r]}),n}function Qx(i,e){if(i.layout===e)return i;const t=i.seed,s=li(t^1374496523^vi.indexOf(e)),r=new Set,n=[],o={...i.places.find(y=>y.kind==="forge"),gx:-1,gy:-1};n.push(o);const a=s()*Math.PI*2,h=i.districts.map(y=>({d:y,items:i.places.filter(x=>x.district===y.id&&(x.kind==="building"||x.kind==="archive"||x.kind==="overflow")).sort((x,b)=>b.score-x.score||x.path.localeCompare(b.path))})).map(y=>{const x=y.items.reduce((b,v)=>b+v.footprint**2,0);return{...y,side:Math.max(3,Math.ceil(Math.sqrt(x*1.45)))}}),c={x:-2,y:-2,w:4,h:4},u=Sg(e,h.map(y=>y.side),c,a,s),d=[c,...u],f=Cg(e,u);o.gx=f[0],o.gy=f[1],Tt(r,o);const p=h.map((y,x)=>{const b=u[x],v={...y.d,bounds:b,cx:b.x+Math.floor(b.w/2),cy:b.y+Math.floor(b.h/2),placeIds:[]};for(const w of y.items){const T=Ro(r,v.cx,v.cy,w.footprint,b),k={...w,gx:T[0],gy:T[1]};Tt(r,k),n.push(k),v.placeIds.push(k.id)}return v});Math.ceil(wg(d));for(const y of d)for(let x=y.x-1;x<y.x+y.w+1;x++)for(let b=y.y-1;b<y.y+y.h+1;b++)r.add(`${x},${b}`);for(const y of i.places.filter(x=>x.kind==="beacon")){const x=p.find(w=>w.id===y.district),b=x?kg(r,x,o,1):wi(r,o.gx+1,o.gy+1,s()*Math.PI*2,4,1),v={...y,gx:b[0],gy:b[1]};Tt(r,v),n.push(v),x?.placeIds.push(v.id)}const g=wi(r,o.gx+1,o.gy+1,a+Math.PI,5,2),m={...i.places.find(y=>y.kind==="dock"),gx:g[0],gy:g[1]};Tt(r,m),n.push(m);const _=Mg(e,p,o,m);return{...i,layout:e,districts:p,places:n,paths:_,bounds:Tg(n,2)}}function wi(i,e,t,s,r,n){for(let o=r;o<r+40;o++)for(let a=0;a<64;a++){const l=s+(a%2?1:-1)*Math.ceil(a/2)*(Math.PI/32),h=Math.round(e+Math.cos(l)*o),c=Math.round(t+Math.sin(l)*o*.85);if(vg(i,h,c,n))return[h,c]}return[e+r,t]}function kg(i,e,t,s){const r=Math.atan2(e.cy-t.gy,e.cx-t.gx),n=Math.ceil(Math.max(e.bounds.w,e.bounds.h)/2)+2;return wi(i,e.cx,e.cy,r,n,s)}var Jx=class{constructor(i){this.windowMs=i}windowMs;mood="curious";trouble=[];recordTrouble(i){return this.trouble=this.trouble.filter(e=>i-e<=this.windowMs),this.trouble.push(i),this.trouble.length>=2}onRead(){return this.mood=this.mood==="lost"?"lost":"curious"}onBuild(){return this.mood=this.mood==="lost"?"lost":"focused"}onFail(i){return this.mood=this.recordTrouble(i)?"lost":"uneasy"}onError(i){return this.mood=this.recordTrouble(i)?"lost":"uneasy"}onPass(){return this.trouble=[],this.mood="happy"}onClaimUnverified(){return this.mood="uneasy"}},eb=class{constructor(i,e={}){this.world=i;for(const t of i.places)this.places.set(t.id,t),t.path&&this.byPath.set(t.path,t);this.beacons=i.places.filter(t=>t.kind==="beacon"),this.forge=i.places.find(t=>t.kind==="forge")??i.places[0],this.dock=i.places.find(t=>t.kind==="dock")??this.forge,this.maxGap=e.maxGapMs??2500,this.msPerCell=e.walkMsPerCell??90,this.mood=new Jx(e.lostWindowMs??9e4),this.actorAt.set("pip",this.forge.id)}world;places=new Map;byPath=new Map;beacons;forge;dock;maxGap;msPerCell;mood;beats=[];sceneMs=0;lastRealTs=null;seq=0;actorAt=new Map;helpers=new Map;gremlins=new Map;lastEdited=null;pendingBeacon=null;editedSinceTurn=!1;verifiedSinceEdit=!1;everVerified=!1;claimGremlin=null;get timeline(){return this.beats}feed(i){const e=this.beats.length;this.advanceClock(i.ts,i.id);const t=i.agentId&&this.helpers.has(i.agentId)?i.agentId:"pip";switch(i.kind){case"session_start":this.emit(i,t,{kind:"curtain_up",repoId:i.repoId},1200);break;case"read_file":{const s=this.placeFor(i.path,i,t);this.walk(i,t,s),this.emit(i,t,{kind:"read",target:s.id},_s(700+(i.bytes??400)/4,900,1800),this.mood.onRead());break}case"edit_file":case"write_file":{const s=this.placeFor(i.path,i,t);this.walk(i,t,s);const r=i.kind==="edit_file"?i.added+i.removed:i.added,n=_s(Math.sqrt(r/50),.15,1),o=[...this.gremlins].find(([,a])=>a===s.id);o&&this.emit(i,t,{kind:"chase",gremlinId:o[0],target:s.id},900,this.mood.mood),i.kind==="write_file"&&i.created&&this.emit(i,t,{kind:"raise",target:s.id},900,this.mood.onBuild()),this.emit(i,t,{kind:"build",target:s.id,intensity:n},_s(600+n*1900,800,2500),this.mood.onBuild()),this.lastEdited=s,this.editedSinceTurn=!0,this.verifiedSinceEdit=!1;break}case"run_command":{if(i.intent==="test"){const s=this.beaconFor(i.touched);this.walk(i,t,s),this.pendingBeacon=s,this.emit(i,t,{kind:"run_tests",target:s.id},_s(i.durationMs??1200,900,3e3),this.mood.mood)}else if(i.intent==="search")this.emit(i,t,{kind:"search",scope:"repo"},700,this.mood.onRead());else if(i.touched.length===0||i.intent==="git"||i.intent==="install"||i.intent==="build"){this.walk(i,t,this.forge);const s=i.intent==="build"||i.intent==="install"?.8:i.intent==="git"?.4:.5;this.emit(i,t,{kind:"forge",intensity:s},_s(i.durationMs??800,700,2e3),this.mood.mood)}!i.ok&&i.intent!=="test"&&this.emit(i,t,{kind:"stumble",retrying:!1},600,this.mood.onError(i.ts));break}case"test_result":{const s=this.pendingBeacon??this.beaconFor([]);this.pendingBeacon=null;const r=(i.framework==="unknown"&&i.passed===0&&i.failed===0,i.ok?"pass":"fail");if(r==="pass"){this.emit(i,t,{kind:"test_outcome",target:s.id,outcome:r,passed:i.passed,failed:i.failed},800,this.mood.onPass()),(i.passed>0||i.framework==="unknown")&&(this.verifiedSinceEdit=!0,this.everVerified=!0);for(const[n]of this.gremlins)this.emit(i,t,{kind:"banish",gremlinId:n},700,"happy");this.gremlins.clear(),this.claimGremlin&&(this.emit(i,t,{kind:"banish",gremlinId:this.claimGremlin},700,"happy"),this.claimGremlin=null),this.emit(i,t,{kind:"celebrate",target:s.id},1600,"happy")}else{this.emit(i,t,{kind:"test_outcome",target:s.id,outcome:r,passed:i.passed,failed:i.failed},800,this.mood.onFail(i.ts));const n=this.lastEdited??s,o=`g:${i.id}`;this.gremlins.set(o,n.id),this.emit(i,t,{kind:"spawn_gremlin",gremlinId:o,target:n.id},900,this.mood.mood)}break}case"search":this.emit(i,t,{kind:"search",scope:i.scope},700,this.mood.onRead());break;case"subagent_start":this.helpers.set(i.childId,i.label?{label:i.label}:{}),this.actorAt.set(i.childId,this.dock.id),this.emit(i,"pip",{kind:"summon_helper",helperId:i.childId,...i.label?{label:i.label}:{}},1400,this.mood.mood);break;case"subagent_stop":this.helpers.has(i.childId)&&(this.emit(i,i.childId,{kind:"dismiss_helper",helperId:i.childId,ok:i.ok},1e3,this.mood.mood),this.helpers.delete(i.childId),this.actorAt.delete(i.childId));break;case"waiting_for_user":i.reason==="idle"?this.emit(i,t,{kind:"your_turn"},1e3,this.mood.mood):this.emit(i,t,{kind:"blocked_on_you",reason:i.reason},1200,this.mood.mood);break;case"error":this.emit(i,t,{kind:"stumble",retrying:i.retrying},700,this.mood.onError(i.ts));break;case"turn_end":{if(i.claimedSuccess&&this.editedSinceTurn&&!this.verifiedSinceEdit){const s=`claim:${i.id}`;this.claimGremlin=s,this.emit(i,t,{kind:"unverified_claim",gremlinId:s},1400,this.mood.onClaimUnverified())}this.editedSinceTurn=!1,this.emit(i,t,{kind:"your_turn"},1e3,this.mood.mood);break}case"session_end":this.emit(i,t,{kind:"curtain_down",verified:this.everVerified&&!this.claimGremlin},1500,this.mood.mood);break}return this.beats.slice(e)}advanceClock(i,e){if(this.lastRealTs!==null){const t=this.beats.length?Math.max(...this.beats.slice(-3).map(n=>n.atMs+n.durationMs)):this.sceneMs,s=Math.min(Math.max(0,i-this.lastRealTs),this.maxGap),r=Math.max(t,this.sceneMs)+s;if(r-t>=1e3){const n={id:`b${this.seq++}`,atMs:t,durationMs:r-t,realTs:this.lastRealTs,mood:this.mood.mood,actor:"pip",sourceEventIds:[e],kind:"idle"};this.beats.push(n)}this.sceneMs=Math.max(this.sceneMs,r)}this.lastRealTs=i}emit(i,e,t,s,r=this.mood.mood){s=Math.round(s),"intensity"in t&&(t={...t,intensity:Math.round(t.intensity*1e3)/1e3});const n={id:`b${this.seq++}`,atMs:Math.round(this.sceneMs),durationMs:s,realTs:i.ts,mood:r,actor:e,sourceEventIds:[i.id],...t};return this.beats.push(n),this.sceneMs+=s,n}walk(i,e,t){const s=this.actorAt.get(e)??this.forge.id;if(s===t.id)return;const r=this.places.get(s)??this.forge,n=Math.hypot(t.gx-r.gx,t.gy-r.gy);this.emit(i,e,{kind:"walk_to",target:t.id},_s(Math.round(n*this.msPerCell),300,2500)),this.actorAt.set(e,t.id)}raised=0;placeFor(i,e,t){const s=this.byPath.get(i);if(s)return s;const r=i.includes("/")?i.slice(0,i.indexOf("/")):"",n=this.byPath.get(`${r?r+"/":""}…`);if(n&&(this.raised>=24||this.world.stats.capped))return n;if(this.raised>=24)return n??this.forge;this.raised++;const o=this.world.districts.find(h=>h.id===`d:${r}`)??this.world.districts[0],a=o?{gx:o.cx,gy:o.cy}:{gx:this.forge.gx+3,gy:this.forge.gy},l={id:`p:${i}`,kind:xg(i),path:i,label:i.slice(i.lastIndexOf("/")+1),district:o?.id??"",gx:a.gx,gy:a.gy,footprint:1,height:1,score:0,touched:!0};return this.places.set(l.id,l),this.byPath.set(i,l),l.kind==="beacon"&&this.beacons.push(l),this.emit(e,t,{kind:"raise",target:l.id,newPlace:{path:i,label:l.label,kind:l.kind,district:l.district}},900),l}beaconFor(i){const e=i.find(t=>_g(t));if(e){const t=this.byPath.get(e);if(t)return t}if(this.lastEdited){const t=this.beacons.find(s=>s.district===this.lastEdited.district);if(t)return t}return this.beacons[0]??this.forge}};function tr(i,e,t){const s=new eb(e,t);for(const r of i)s.feed(r);return[...s.timeline]}var _s=(i,e,t)=>Math.min(t,Math.max(e,i));function tb(i){const e=new Map,t=(r,n)=>e.set(r,(e.get(r)??0)+n);for(const r of i)if(r.kind==="read_file")t(r.path,Math.max(5,Math.round((r.bytes??400)/40)));else if(r.kind==="edit_file")t(r.path,Math.max(5,(r.added+r.removed)*3));else if(r.kind==="write_file")t(r.path,Math.max(5,r.added*2));else if(r.kind==="run_command")for(const n of r.touched)t(n,5);const s=[...e.keys()].sort((r,n)=>e.get(n)-e.get(r));return{files:s.map(r=>({path:r,loc:e.get(r)})),touched:s}}class sb{ctx=null;master=null;sfxBus=null;ambBus=null;duck=0;_muted=!1;_volume=.6;_ambience=!0;get ambienceEnabled(){return this._ambience}setAmbienceEnabled(e){this._ambience=e,this.ambBus&&this.ctx&&this.ambBus.gain.setTargetAtTime(e?.35:0,this.ctx.currentTime,.1)}noiseBuf=null;get ready(){return!!this.ctx&&this.ctx.state==="running"}get muted(){return this._muted}get volume(){return this._volume}async arm(){if(!this.ctx){const e=globalThis.AudioContext??globalThis.webkitAudioContext;if(!e)return;this.ctx=new e,this.master=this.ctx.createGain(),this.sfxBus=this.ctx.createGain(),this.ambBus=this.ctx.createGain(),this.sfxBus.connect(this.master),this.ambBus.connect(this.master),this.master.connect(this.ctx.destination),this.ambBus.gain.value=this._ambience?.35:0,this.applyGain();const t=this.ctx.sampleRate*2;this.noiseBuf=this.ctx.createBuffer(1,t,this.ctx.sampleRate);const s=this.noiseBuf.getChannelData(0);for(let r=0;r<t;r++)s[r]=Math.random()*2-1}this.ctx.state==="suspended"&&await this.ctx.resume()}setMuted(e){this._muted=e,this.applyGain()}setVolume(e){this._volume=Math.max(0,Math.min(1,e)),this.applyGain()}applyGain(){this.master&&this.master.gain.setTargetAtTime(this._muted?0:this._volume,this.ctx.currentTime,.02)}duckAmbience(e=.5,t=350){if(!this.ambBus||!this.ctx)return;const s=this.ctx.currentTime;this.ambBus.gain.cancelScheduledValues(s),this._ambience&&(this.ambBus.gain.setTargetAtTime(.35*(1-e),s,.01),this.ambBus.gain.setTargetAtTime(.35,s+t/1e3,.12),this.duck++)}tone(e,t,s={}){if(!this.ready||!this.ctx||!this.sfxBus)return;const r=this.ctx,n=r.currentTime,o=r.createOscillator();o.type=s.type??"sine",o.frequency.setValueAtTime(e,n),s.detune&&(o.detune.value=s.detune),s.slideTo&&o.frequency.exponentialRampToValueAtTime(Math.max(20,s.slideTo),n+t);const a=r.createGain(),l=s.attack??.005,h=s.decay??t;a.gain.setValueAtTime(1e-4,n),a.gain.exponentialRampToValueAtTime(s.gain??.25,n+l),a.gain.exponentialRampToValueAtTime(1e-4,n+l+h);let c=o;if(s.lowpass){const d=r.createBiquadFilter();d.type="lowpass",d.frequency.value=s.lowpass,o.connect(d),c=d}const u=r.createStereoPanner();u.pan.value=s.pan??0,c.connect(a),a.connect(u),u.connect(this.sfxBus),o.start(n),o.stop(n+l+h+.05),this.duckAmbience(.35,(l+h)*1e3)}noise(e,t={}){if(!this.ready||!this.ctx||!this.sfxBus||!this.noiseBuf)return;const s=this.ctx,r=s.currentTime,n=s.createBufferSource();n.buffer=this.noiseBuf,n.loop=!0;const o=s.createBiquadFilter();o.type=t.filter??"bandpass",o.frequency.setValueAtTime(t.freq??1200,r),o.Q.value=t.q??.8,t.sweepTo&&o.frequency.exponentialRampToValueAtTime(Math.max(40,t.sweepTo),r+e);const a=s.createGain(),l=t.attack??.004;a.gain.setValueAtTime(1e-4,r),a.gain.exponentialRampToValueAtTime(t.gain??.12,r+l),a.gain.exponentialRampToValueAtTime(1e-4,r+e);const h=s.createStereoPanner();h.pan.value=t.pan??0,n.connect(o),o.connect(a),a.connect(h),h.connect(this.sfxBus),n.start(r),n.stop(r+e+.05)}pad(e,t,s="sine"){if(!this.ready||!this.ctx||!this.ambBus)return()=>{};const r=this.ctx,n=r.currentTime,o=[],a=r.createGain();a.gain.setValueAtTime(1e-4,n),a.gain.exponentialRampToValueAtTime(t,n+1.5),a.connect(this.ambBus);for(const l of e){const h=r.createOscillator();h.type=s,h.frequency.value=l,h.detune.value=(Math.random()-.5)*6,h.connect(a),h.start(n),o.push(h)}return()=>{const l=r.currentTime;a.gain.cancelScheduledValues(l),a.gain.setTargetAtTime(1e-4,l,.4);for(const h of o)h.stop(l+2)}}wash(e,t,s,r=.12,n=.5){if(!this.ready||!this.ctx||!this.ambBus||!this.noiseBuf)return()=>{};const o=this.ctx,a=o.currentTime,l=o.createBufferSource();l.buffer=this.noiseBuf,l.loop=!0;const h=o.createBiquadFilter();h.type="lowpass",h.frequency.value=e,h.Q.value=t;const c=o.createGain();c.gain.setValueAtTime(1e-4,a),c.gain.exponentialRampToValueAtTime(s,a+2);const u=o.createOscillator();u.frequency.value=r;const d=o.createGain();return d.gain.value=s*n,u.connect(d),d.connect(c.gain),l.connect(h),h.connect(c),c.connect(this.ambBus),l.start(a),u.start(a),()=>{const f=o.currentTime;c.gain.setTargetAtTime(1e-4,f,.5),l.stop(f+2.5),u.stop(f+2.5)}}now(){return this.ctx?.currentTime??0}captureStream(){if(!this.ctx||!this.master)return null;const e=this.ctx.createMediaStreamDestination();return this.master.connect(e),e.stream}note(e,t,s,r="sine",n=0){if(!this.ready||!this.ctx||!this.ambBus)return;const o=this.ctx,a=o.currentTime,l=o.createGain();l.gain.setValueAtTime(1e-4,a),l.gain.exponentialRampToValueAtTime(s,a+Math.min(.12,t*.3)),l.gain.setTargetAtTime(1e-4,a+t*.6,t*.35);const h=o.createStereoPanner();h.pan.value=n,l.connect(h),h.connect(this.ambBus);const c=o.createBiquadFilter();c.type="lowpass",c.frequency.value=Math.min(6e3,e*4),c.connect(l);for(const f of[0,4]){const p=o.createOscillator();p.type=r,p.frequency.value=e,p.detune.value=f,p.connect(c),p.start(a),p.stop(a+t*1.6)}const u=o.createOscillator();u.type="sine",u.frequency.value=e/2;const d=o.createGain();d.gain.value=.35,u.connect(d),d.connect(c),u.start(a),u.stop(a+t*1.6)}extra(e,t=(Math.random()-.5)*1.2){if(!this.ready||!this.ctx||!this.ambBus)return;const s=this.ctx,r=s.currentTime,n=(a,l,h,c,u,d=.01)=>{const f=s.createOscillator();f.type=a,f.frequency.setValueAtTime(l,r),f.frequency.exponentialRampToValueAtTime(Math.max(20,h),r+c);const p=s.createGain();p.gain.setValueAtTime(1e-4,r),p.gain.exponentialRampToValueAtTime(u,r+d),p.gain.exponentialRampToValueAtTime(1e-4,r+c);const g=s.createStereoPanner();g.pan.value=t,f.connect(p),p.connect(g),g.connect(this.ambBus),f.start(r),f.stop(r+c+.05)},o=(a,l,h,c,u,d="bandpass")=>{if(!this.noiseBuf)return;const f=s.createBufferSource();f.buffer=this.noiseBuf,f.loop=!0;const p=s.createBiquadFilter();p.type=d,p.frequency.setValueAtTime(a,r),u&&p.frequency.exponentialRampToValueAtTime(u,r+h),p.Q.value=l;const g=s.createGain();g.gain.setValueAtTime(1e-4,r),g.gain.exponentialRampToValueAtTime(c,r+.05),g.gain.exponentialRampToValueAtTime(1e-4,r+h);const m=s.createStereoPanner();m.pan.value=t,f.connect(p),p.connect(g),g.connect(m),m.connect(this.ambBus),f.start(r),f.stop(r+h+.05)};switch(e){case"gull":n("sine",1800,1100,.35,.05,.03),setTimeout(()=>n("sine",1700,1250,.3,.04,.03),260);return;case"cricket":for(let a=0;a<6;a++)setTimeout(()=>n("sine",4200,4100,.04,.02),a*70);return;case"bell":n("sine",880,870,2.2,.06,.005),n("sine",1760,1740,1.4,.03,.005),n("sine",2640,2600,.8,.015,.005);return;case"bubble":n("sine",300+Math.random()*300,900+Math.random()*600,.18,.04,.01);return;case"wind":o(500+Math.random()*400,.5,2.5+Math.random()*2,.05,300+Math.random()*300);return;case"horn":n("sawtooth",180,176,.8,.03,.08);return;case"hum":n("sine",60,60,2.5,.03,.4);return;case"chime":n("sine",1318.5,1316,1.2,.035,.005);return;case"owl":n("sine",420,380,.5,.04,.05),setTimeout(()=>n("sine",400,360,.6,.035,.05),420);return;case"rumble":o(90,1.2,2.5,.09,60,"lowpass");return;case"drip":n("sine",1200,600,.12,.04,.003);return;case"market":for(let a=0;a<4;a++)setTimeout(()=>o(600+Math.random()*1200,2,.12,.02),a*120);return}}}const ib=i=>1-Math.pow(1-i,3),Rn=i=>rb(.4,0,.2,1,i),lu=i=>1+(1.70158+1)*Math.pow(i-1,3)+1.70158*Math.pow(i-1,2),st=i=>Math.sin(Math.PI*Math.min(1,Math.max(0,i)));function rb(i,e,t,s,r){const n=3*i,o=3*(t-i)-n,a=1-n-o,l=3*e,h=3*(s-e)-l,c=1-l-h,u=g=>((a*g+o)*g+n)*g,d=g=>((c*g+h)*g+l)*g,f=g=>(3*a*g+2*o)*g+n;let p=r;for(let g=0;g<6;g++){const m=f(p);if(Math.abs(m)<1e-6)break;p-=(u(p)-r)/m}return d(Math.min(1,Math.max(0,p)))}const nb=64,Bo=32,K=(i,e)=>({x:(i-e)*nb/2,y:(i+e)*Bo/2}),F=(i,e)=>({x:i.x,y:i.y-e}),Jt=(i,e,t)=>i+(e-i)*t,Be=(i,e,t)=>({x:Jt(i.x,e.x,t),y:Jt(i.y,e.y,t)}),ob=(i,e,t)=>i<e?e:i>t?t:i,Ue=(i,e,t)=>ob((i-e)/(t-e),0,1),hu=(i,e,t=1)=>i+e+t;function De(i,e,t,s=0){return[K(i,e),K(i+t,e),K(i+t,e+t),K(i,e+t)].map(r=>F(r,s))}const X=i=>i.flatMap(e=>[e.x,e.y]);class ab{constructor(e,t){this.stage=e,this.reducedMotion=t}cx=0;cy=0;zoom=1;tx=0;ty=0;tz=1;punch=0;shakeT=0;drift=0;t=0;fit(e,t,s,r,n=1.08){this.tz=Math.min(s/(e*n),r/(t*n))}follow(e,t,s=1){this.tx=Jt(this.tx,e,s),this.ty=Jt(this.ty,t,s)}setZoomFactor(e){this.tz=e}pushIn(e=.08){this.reducedMotion||(this.punch=Math.max(this.punch,e))}shake(e=220){this.reducedMotion||(this.shakeT=e/1e3)}setDrift(e){this.drift=this.reducedMotion?0:e?1:0}snap(){this.cx=this.tx,this.cy=this.ty,this.zoom=this.tz}update(e,t,s){const r=Number.isFinite(e)?Math.max(0,Math.min(.05,e/1e3)):0;this.t+=r;const n=1-Math.pow(.012,r),o=1-Math.pow(.05,r);this.cx+=(this.tx-this.cx)*n,this.cy+=(this.ty-this.cy)*n,this.punch=Math.max(0,this.punch-r*.12),this.zoom+=(this.tz*(1+ib(this.punch/.08)*this.punch)-this.zoom)*o;let a=0,l=0;if(this.shakeT>0){this.shakeT-=r;const h=this.shakeT*18;a=Math.sin(this.t*60)*h,l=Math.cos(this.t*47)*h}this.drift&&(a+=Math.sin(this.t*.7)*2.2,l+=Math.cos(this.t*.5)*1.6),this.stage.scale.set(this.zoom),this.stage.position.set(t/2-(this.cx+a)*this.zoom,s/2-(this.cy+l)*this.zoom)}toScreen(e,t){return{x:this.stage.position.x+e*this.zoom,y:this.stage.position.y+t*this.zoom}}get scale(){return this.zoom}}const lb={roof:"pitched",eave:.14,furniture:"chimney",stripes:!1},hb={roof:"flat",eave:.05,furniture:"vent",stripes:!1},cb={roof:"capsule",eave:0,furniture:"dish",stripes:!1},Bn={island:lb,orbit:cb,metropolis:hb,harbour:{roof:"gable",eave:.16,furniture:"chimney",stripes:!1},observatory:{roof:"dome",eave:.04,furniture:"dish",stripes:!1},greenhouse:{roof:"gable",eave:.1,furniture:"vent",stripes:!1},workshop:{roof:"gable",eave:.12,furniture:"chimney",stripes:!1},arcade:{roof:"flat",eave:.08,furniture:"mast",stripes:!0},kingdom:{roof:"pitched",eave:.1,furniture:"finial",stripes:!1},outpost:{roof:"flat",eave:.12,furniture:"vent",stripes:!1},snowfield:{roof:"pitched",eave:.2,furniture:"chimney",stripes:!1},canopy:{roof:"pitched",eave:.22,furniture:"none",stripes:!1},lagoon:{roof:"tent",eave:.18,furniture:"none",stripes:!0},volcano:{roof:"flat",eave:.06,furniture:"vent",stripes:!1},cloudtop:{roof:"dome",eave:.06,furniture:"finial",stripes:!1},reef:{roof:"dome",eave:.02,furniture:"none",stripes:!1},bazaar:{roof:"tent",eave:.2,furniture:"none",stripes:!0},monastery:{roof:"onion",eave:.08,furniture:"finial",stripes:!1},moonbase:{roof:"capsule",eave:0,furniture:"dish",stripes:!1},lanterns:{roof:"tiered",eave:.26,furniture:"lantern",stripes:!1}};class Eg{constructor(e,t){this.world=e,this.theme=t,this.container.addChild(this.ripples,this.terrain,this.paths,this.labels,this.shadows,this.clouds,this.objects),this.objects.sortableChildren=!0,this.shadows.alpha=.9,this.drawTerrain(),this.drawPaths(),this.drawLabels();for(const s of e.places)this.addPlace(s);this.placeProps()}container=new _e;terrain=new Pe;ripples=new Pe;paths=new Pe;labels=new _e;shadows=new Pe;clouds=new Pe;objects=new _e;drawn=new Map;props=[];time=0;gradients=new Map;vGrad(e,t,s,r){const n=Vi(s),o=Vi(r),a=`v${e}|${t}|${n}|${o}`;let l=this.gradients.get(a);return l||(l=db(e,t,n,o),this.gradients.set(a,l)),l}hGrad(e,t,s,r){const n=Vi(s),o=Vi(r),a=`h${e}|${t}|${n}|${o}`;let l=this.gradients.get(a);return l||(l=fb(e,t,n,o),this.gradients.set(a,l)),l}destroy(){for(const e of this.gradients.values())e.destroy();this.gradients.clear(),this.container.destroy({children:!0})}positionOf(e){const t=this.drawn.get(e);if(!t)return null;const s=t.place,r=s.gx+s.footprint/2,n=s.gy+s.footprint/2,o=K(r,n);return{ground:o,top:F(o,this.heightPx(t)+10),place:s}}standingSpot(e){const t=this.drawn.get(e);if(!t)return K(0,0);const s=t.place;return K(s.gx+s.footprint/2,s.gy+s.footprint+.55)}setGlow(e,t){const s=this.drawn.get(e);s&&s.glow!==t&&(s.glow=t,s.dirty=!0)}setGrowth(e,t){const s=this.drawn.get(e);s&&s.extraH!==t&&(s.extraH=t,s.dirty=!0)}setScaffold(e,t){const s=this.drawn.get(e);s&&s.scaffold!==t&&(s.scaffold=t,s.dirty=!0)}setLamp(e,t){const s=this.drawn.get(e);s&&s.lamp!==t&&(s.lamp=t,s.dirty=!0)}lampOf(e){return this.drawn.get(e)?.lamp??"idle"}has(e){return this.drawn.has(e)}addPlace(e){if(this.drawn.has(e.id))return;const t=new Pe;t.zIndex=hu(e.gx,e.gy,e.footprint);const s=Math.max(0,this.world.districts.findIndex(u=>u.id===e.district)),r=e.kind==="beacon"?this.theme.beacon:e.kind==="archive"?this.theme.archive:e.kind==="forge"?this.theme.forge:this.theme.palettes[s%this.theme.palettes.length],n=e.kind==="building"?Ao(e.path):0,o=e.kind==="building"?(n%5-2)*.05:0,a=e.kind==="building"&&n%3===0?this.theme.palettes[(s+1+n%2)%this.theme.palettes.length]:r,l=u=>o>=0?J(u,16777215,o):J(u,0,-o),h={top:l(r.top),left:l(r.left),right:l(r.right),roof:a.roof,roofD:a.roofD,win:r.win},c={place:e,g:t,palette:h,extraH:0,glow:0,lamp:"idle",scaffold:0,dirty:!0};this.drawn.set(e.id,c),this.objects.addChild(t),this.redraw(c)}update(e){this.time+=e/1e3,this.drawRipples(),this.drawCloudShadows();for(const t of this.props)t.canopy&&(t.canopy.x=Math.sin(this.time*1.4+t.phase)*1.2);for(const t of this.drawn.values())(t.glow>0||t.lamp==="scan"||t.lamp==="fail"||t.lamp==="pass"||t.place.kind==="dock"||t.place.kind==="forge")&&(t.dirty=!0),t.dirty&&this.redraw(t)}heightPx(e){const t=e.place;return(t.kind==="beacon"?70:t.kind==="forge"?34:t.kind==="dock"?4:t.kind==="archive"?30:18+t.height*8)+e.extraH}redraw(e){const{g:t,place:s,palette:r}=e;t.clear(),e.dirty=!1;const n=this.heightPx(e),o=s.footprint,a=De(s.gx+.12,s.gy+.12,o);if(t.poly(X(a)).fill({color:this.shadowInk,alpha:.22}),s.kind!=="dock"&&this.castShadow(t,s,n),s.kind==="dock")return this.drawDock(t,s);if(s.kind==="beacon")return this.drawBeacon(e,n);const l=this.box(t,s.gx,s.gy,o,n,s.kind==="forge"?r.roof:r.top,r.left,r.right),h=e.glow>0?.6+.4*Math.sin(this.time*10):0,c=e.glow>0?J(r.win,16771496,.5+.5*h):r.win;if(s.kind!=="archive"&&s.kind!=="forge"){const u=Math.max(1,Math.round(n/28)),d=o>=3?3:2;this.windows(t,l[3],l[2],n,u,d,c,e.glow>0?1:.9),this.windows(t,l[2],l[1],n,u,d,c,e.glow>0?1:.8);const f=Be(l[3],l[2],.3);t.poly([f.x-3,f.y-1,f.x+3,f.y+1,f.x+3,f.y-9,f.x-3,f.y-11]).fill({color:r.roofD,alpha:.9})}if(s.kind==="building"&&o<=2&&this.roof(t,s,n,r),s.kind==="building"&&o>=3&&Bn[this.theme.id].roof!=="capsule"&&Bn[this.theme.id].roof!=="dome"){const u=l.map(p=>F(p,n));t.poly(X([u[3],u[2],F(u[2],4),F(u[3],4)])).fill(r.roofD),t.poly(X([u[2],u[1],F(u[1],4),F(u[2],4)])).fill(J(r.roofD,0,.2)),t.poly(X(u.map(p=>F(p,4)))).fill(r.roof);const d=De(s.gx+.8,s.gy+.8,o-1.6,n+4);t.poly(X([d[3],d[2],F(d[2],10),F(d[3],10)])).fill(r.left),t.poly(X([d[2],d[1],F(d[1],10),F(d[2],10)])).fill(r.right),t.poly(X(d.map(p=>F(p,10)))).fill(r.top);const f=F(K(s.gx+o/2,s.gy+o/2),n+14);t.moveTo(f.x,f.y).lineTo(f.x,f.y-12).stroke({width:1.6,color:r.roofD}),t.circle(f.x,f.y-13-14,2.2).fill(e.glow>0?16766571:r.roof)}if(s.kind==="archive"){for(let u=1;u<6;u++){const d=Be(l[3],l[2],u/6);t.moveTo(d.x,d.y-3).lineTo(d.x,d.y-n+5).stroke({width:1.3,color:16777215,alpha:.6})}for(let u=1;u<5;u++){const d=Be(l[2],l[1],u/5);t.moveTo(d.x,d.y-3).lineTo(d.x,d.y-n+5).stroke({width:1.3,color:16777215,alpha:.45})}this.pyramid(t,l.map(u=>F(u,n)),F(K(s.gx+o/2,s.gy+o/2),n+10),r.roof,r.roofD)}if(s.kind==="forge"){const u=this.theme.forge.ember,d=Be(l[3],l[2],.5);t.poly([d.x-7,d.y-2,d.x+7,d.y+2,d.x+7,d.y-18,d.x-7,d.y-22]).fill({color:u,alpha:.85}),this.windows(t,l[2],l[1],n,2,2,u,.9),this.pyramid(t,l.map(g=>F(g,n)),F(K(s.gx+o/2,s.gy+o/2),n+16),r.roof,r.roofD);const f=F(K(s.gx+o*.75,s.gy+o*.3),n+6);t.rect(f.x-4,f.y-16,8,16).fill(r.roofD);for(let g=0;g<3;g++){const m=(this.time*.35+g/3)%1;t.circle(f.x+Math.sin(m*6+g)*4,f.y-18-m*26,3+m*6).fill({color:16777215,alpha:.22*(1-m)})}const p=.5+.5*Math.sin(this.time*3);t.circle(d.x,d.y-8,12+p*4).fill({color:u,alpha:.12+.08*p})}e.glow>0&&this.outline(t,l,n,16762970,.4+.4*h),e.scaffold>0&&this.scaffold(t,s,n,e.scaffold)}roof(e,t,s,r){const n=Bn[this.theme.id],o=t.footprint,a=n.eave,l=Ao(t.path),h=De(t.gx-a,t.gy-a,o+a*2,s),c=K(t.gx+o/2,t.gy+o/2),u=J(r.roofD,this.shadowInk,.35);switch(a>0&&(e.poly(X([h[3],h[2],F(h[2],-3),F(h[3],-3)])).fill({color:u,alpha:.9}),e.poly(X([h[2],h[1],F(h[1],-3),F(h[2],-3)])).fill({color:J(u,0,.2),alpha:.9})),n.roof){case"pitched":{this.pyramid(e,h,F(c,s+12+o*9),r.roof,r.roofD);break}case"gable":{const f=11+o*7,p=F(Be(h[0],h[3],.5),s+f),g=F(Be(h[1],h[2],.5),s+f);e.poly(X([h[3],h[2],g,p])).fill(this.vGrad(J(r.roof,16777215,.1),r.roof,p.y,h[3].y)),e.poly(X([h[0],h[1],g,p])).fill(J(r.roofD,this.shadowInk,.2)),e.poly(X([h[2],h[1],g])).fill(J(r.right,this.shadowInk,.1)),e.poly(X([h[3],h[0],p])).fill(r.left),e.moveTo(p.x,p.y).lineTo(g.x,g.y).stroke({width:1.4,color:16777215,alpha:.4,cap:"round"});break}case"flat":{const f=h.map(g=>F(g,3));e.poly(X([h[3],h[2],f[2],f[3]])).fill(r.roofD),e.poly(X([h[2],h[1],f[1],f[2]])).fill(J(r.roofD,0,.2)),e.poly(X(f)).fill(this.hGrad(J(r.roof,16777215,.08),r.roof,f[3].x,f[1].x));const p=De(t.gx+.25+l%3*.1,t.gy+.3,.4,s+3);e.poly(X([p[3],p[2],F(p[2],6),F(p[3],6)])).fill(r.left),e.poly(X([p[2],p[1],F(p[1],6),F(p[2],6)])).fill(r.right),e.poly(X(p.map(g=>F(g,6)))).fill(r.top);break}case"dome":{const f=o*32*.78,p=c.y-s+2;e.ellipse(c.x,p,f,f*.62).fill(this.vGrad(J(r.roof,16777215,.22),J(r.roofD,this.shadowInk,.15),p-f*.62,p+f*.3)),e.rect(c.x-f,p,f*2,f*.62).fill({color:0,alpha:0}),e.ellipse(c.x-f*.3,p-f*.28,f*.28,f*.14).fill({color:16777215,alpha:.32});break}case"onion":{const f=o*16,p=c.y-s;e.moveTo(c.x-f,p).quadraticCurveTo(c.x-f*1.15,p-f*1.1,c.x,p-f*2.2).quadraticCurveTo(c.x+f*1.15,p-f*1.1,c.x+f,p).fill(this.vGrad(J(r.roof,16777215,.2),r.roofD,p-f*2.2,p)),e.moveTo(c.x-f*.4,p-f*.3).quadraticCurveTo(c.x-f*.5,p-f*1.2,c.x-f*.05,p-f*1.9).stroke({width:1.6,color:16777215,alpha:.35,cap:"round"});break}case"tiered":{for(let f=0;f<2;f++){const p=s+f*14,g=a*(1-f*.45),m=De(t.gx-g,t.gy-g,o+g*2,p);e.poly(X([m[3],m[2],F(m[2],-2),F(m[3],-2)])).fill(u);const _=F(c,p+9+o*3);e.poly(X([F(m[3],3),F(m[2],3),_])).fill(r.roof),e.poly(X([F(m[2],3),F(m[1],3),_])).fill(r.roofD),e.poly(X([F(m[3],3),F(m[0],3),_])).fill(J(r.roof,16777215,.1));for(const y of[m[1],m[2],m[3]])e.moveTo(y.x,y.y+1).quadraticCurveTo(y.x+(y.x<c.x?-4:4),y.y-1,y.x+(y.x<c.x?-5:5),y.y-6).stroke({width:2,color:r.roofD,cap:"round"})}break}case"tent":{const f=F(c,s+16+o*8);this.pyramid(e,h,f,r.roof,r.roofD);for(let p=0;p<o*3;p++){const g=Be(h[3],h[2],p/(o*3)),m=Be(h[3],h[2],(p+1)/(o*3));e.moveTo(g.x,g.y).quadraticCurveTo((g.x+m.x)/2,(g.y+m.y)/2+4,m.x,m.y).fill(r.roofD)}e.moveTo(f.x,f.y).lineTo(f.x,f.y-8).stroke({width:1.5,color:r.roofD}),e.poly([f.x,f.y-8,f.x+7,f.y-6,f.x,f.y-4]).fill(r.win);break}case"capsule":{const f=o*32*.7,p=c.y-s+1;e.ellipse(c.x,p,f*1.02,f*.5).fill(this.vGrad(J(r.top,16777215,.25),r.top,p-f*.5,p+f*.1)),e.ellipse(c.x-f*.3,p-f*.22,f*.3,f*.1).fill({color:16777215,alpha:.4}),e.ellipse(c.x,p,f*1.02,f*.5).stroke({width:1.2,color:J(r.roofD,16777215,.1),alpha:.6});break}}const d=F(K(t.gx+o*.72,t.gy+o*.3),s+(n.roof==="flat"?3:n.roof==="pitched"||n.roof==="gable"?8:0));switch(n.furniture){case"chimney":l%2===0&&(e.rect(d.x-3,d.y-12,6,12).fill(r.roofD),e.rect(d.x-4,d.y-13,8,3).fill(J(r.roofD,0,.2)));break;case"vent":e.rect(d.x-4,d.y-5,8,5).fill(J(r.left,this.shadowInk,.2)),e.ellipse(d.x,d.y-5,4,1.6).fill(r.top);break;case"mast":e.moveTo(d.x,d.y).lineTo(d.x,d.y-16).stroke({width:1.4,color:r.roofD}),e.circle(d.x,d.y-17,2).fill(r.win);break;case"finial":{const f=F(c,s+12+o*9+(n.roof==="onion"?o*16*2.2-12-o*9:0));e.moveTo(f.x,f.y).lineTo(f.x,f.y-7).stroke({width:1.4,color:16766571}),e.circle(f.x,f.y-8,2).fill(16766571);break}case"lantern":{const f=Be(h[3],h[2],.5);e.moveTo(f.x,f.y).lineTo(f.x,f.y+5).stroke({width:1,color:r.roofD}),e.roundRect(f.x-3,f.y+5,6,8,2).fill(ub(r.win));break}case"dish":e.ellipse(d.x,d.y-2,6,3).stroke({width:1.4,color:16777215,alpha:.7}),e.moveTo(d.x,d.y-2).lineTo(d.x+2,d.y-7).stroke({width:1,color:16777215,alpha:.7});break}if(n.stripes){const f=De(t.gx,t.gy,o);for(let p=0;p<o*4;p+=2){const g=Be(f[3],f[2],p/(o*4)),m=Be(f[3],f[2],(p+1)/(o*4));e.poly([g.x,g.y,m.x,m.y,m.x,m.y-s*.35,g.x,g.y-s*.35]).fill({color:16777215,alpha:.22})}}}box(e,t,s,r,n,o,a,l){const[h,c,u,d]=De(t,s,r),f=this.hazeOf(s+t),p=g=>J(g,this.theme.sky[0],f);return e.poly(X([d,u,F(u,n),F(d,n)])).fill(this.vGrad(p(J(a,16777215,.08)),p(J(a,this.shadowInk,.28)),d.y-n,d.y)),e.poly(X([u,c,F(c,n),F(u,n)])).fill(this.vGrad(p(J(l,this.coolInk,.06)),p(J(l,this.shadowInk,.38)),u.y-n,u.y)),e.poly(X([F(h,n),F(c,n),F(u,n),F(d,n)])).fill(this.hGrad(p(J(o,16777215,.16)),p(o),d.x,c.x)),e.moveTo(d.x,d.y-n).lineTo(h.x,h.y-n).lineTo(c.x,c.y-n).stroke({width:1.3,color:16777215,alpha:.42,cap:"round"}),e.moveTo(d.x,d.y-n).lineTo(d.x,d.y).stroke({width:1.1,color:16777215,alpha:.22}),[h,c,u,d]}hazeOf(e){const t=this.world.bounds,s=t.x+t.y,r=t.x+t.w+t.y+t.h;return .16*(1-Math.max(0,Math.min(1,(e-s)/Math.max(1,r-s))))}get shadowInk(){return J(this.theme.vignette,0,.3)}get coolInk(){return J(this.theme.sky[0],2768746,.5)}castShadow(e,t,s){const r=t.footprint,n=s/36,o=De(t.gx,t.gy,r),a=.55*n,l=.95*n,h=[K(t.gx+a,t.gy+l),K(t.gx+r+a,t.gy+l),K(t.gx+r+a,t.gy+r+l),K(t.gx+a,t.gy+r+l)],c=[o[1],h[1],h[2],h[3],o[3],o[2]];e.poly(X(c)).fill({color:this.shadowInk,alpha:.16});const u=[K(t.gx+a*.6,t.gy+l*.6),K(t.gx+r+a*.6,t.gy+l*.6),K(t.gx+r+a*.6,t.gy+r+l*.6)];e.poly(X([o[1],u[1],u[2],o[3],o[2]])).fill({color:this.shadowInk,alpha:.12})}drawCloudShadows(){const e=this.clouds;if(e.clear(),this.theme.terrain!=="island"&&this.theme.terrain!=="block")return;const t=this.world.bounds,s=K(t.x+t.w/2,t.y+t.h/2),r=(t.w+t.h)*24;for(let n=0;n<3;n++){const o=(this.time*.012+n*.37)%1,a=s.x-r/2+o*r*1.3-r*.15,l=s.y-90+Math.sin(n*2.1)*120;e.ellipse(a,l,150+n*30,56+n*8).fill({color:this.shadowInk,alpha:.075}),e.ellipse(a+90,l+18,110,40).fill({color:this.shadowInk,alpha:.06})}}pyramid(e,t,s,r,n){e.poly(X([t[0],t[1],s])).fill(J(n,this.shadowInk,.25)),e.poly(X([t[3],t[0],s])).fill(J(r,16777215,.12)),e.poly(X([t[3],t[2],s])).fill(this.vGrad(J(r,16777215,.06),r,s.y,t[2].y)),e.poly(X([t[2],t[1],s])).fill(this.vGrad(n,J(n,this.shadowInk,.3),s.y,t[1].y)),e.moveTo(t[3].x,t[3].y).lineTo(s.x,s.y).stroke({width:1.2,color:16777215,alpha:.35,cap:"round"})}windows(e,t,s,r,n,o,a,l){const h=(s.x-t.x)/o*.3,c=(s.y-t.y)/o*.3;for(let u=0;u<n;u++)for(let d=0;d<o;d++){const f=Be(t,s,(d+.5)/o),p=f.y-r*(u+.75)/(n+.5),g=f.x;e.poly([g-h,p-c,g+h,p+c,g+h,p+c-6,g-h,p-c-6]).fill({color:a,alpha:l}),e.poly([g-h,p-c-4.5,g+h,p+c-4.5,g+h,p+c-6,g-h,p-c-6]).fill({color:16777215,alpha:l*.45})}}outline(e,t,s,r,n){const o=t.map(a=>F(a,s));e.moveTo(t[3].x,t[3].y).lineTo(t[2].x,t[2].y).lineTo(t[1].x,t[1].y).lineTo(o[1].x,o[1].y).lineTo(o[0].x,o[0].y).lineTo(o[3].x,o[3].y).closePath().stroke({width:2,color:r,alpha:n,join:"round"}),e.moveTo(t[2].x,t[2].y).lineTo(o[2].x,o[2].y).stroke({width:2,color:r,alpha:n})}scaffold(e,t,s,r){const n=De(t.gx-.12,t.gy-.12,t.footprint+.24);for(const o of[n[1],n[2],n[3]])e.moveTo(o.x,o.y).lineTo(o.x,o.y-s-8).stroke({width:1.1,color:16768150,alpha:r});for(let o=10;o<s+8;o+=11)e.moveTo(n[3].x,n[3].y-o).lineTo(n[2].x,n[2].y-o).lineTo(n[1].x,n[1].y-o).stroke({width:1.1,color:16768150,alpha:r})}drawBeacon(e,t){const{g:s,place:r}=e,n=this.theme.beacon,o=n.lamp[e.lamp],a=this.box(s,r.gx+.2,r.gy+.2,.6,t,n.top,n.left,n.right);for(const[u,d]of[[.2,.33],[.52,.65]])s.poly(X([F(a[3],t*u),F(a[2],t*u),F(a[2],t*d),F(a[3],t*d)])).fill(n.roof),s.poly(X([F(a[2],t*u),F(a[1],t*u),F(a[1],t*d),F(a[2],t*d)])).fill(n.roofD);const l=F(K(r.gx+.5,r.gy+.5),t+6),h=e.lamp==="fail"?.55+.45*Math.sin(this.time*9):e.lamp==="scan"?.8+.2*Math.sin(this.time*20):1,c=e.lamp==="idle"?16:26;if(s.circle(l.x,l.y,c).fill({color:o,alpha:.22*h}),s.circle(l.x,l.y,c*.55).fill({color:o,alpha:.3*h}),e.lamp==="scan"||e.lamp==="pass"){const u=e.lamp==="scan"?this.time*5:this.time*1.1,d=e.lamp==="scan"?190:120,f=.2;s.moveTo(l.x,l.y).arc(l.x,l.y,d,u-f,u+f).closePath().fill({color:o,alpha:.18})}this.box(s,r.gx+.28,r.gy+.28,.44,11,2899538,o,J(o,0,.25)),this.pyramid(s,De(r.gx+.2,r.gy+.2,.6,t+11),F(K(r.gx+.5,r.gy+.5),t+22),n.roof,n.roofD)}drawDock(e,t){const s=De(t.gx,t.gy,t.footprint);e.poly(X([s[3],s[2],F(s[2],-5),F(s[3],-5)])).fill(this.theme.dock.post),e.poly(X([s[2],s[1],F(s[1],-5),F(s[2],-5)])).fill(J(this.theme.dock.post,0,.2)),e.poly(X(s)).fill(this.theme.dock.deck);for(let o=1;o<5;o++){const a=Be(s[0],s[3],o/5),l=Be(s[1],s[2],o/5);e.moveTo(a.x,a.y).lineTo(l.x,l.y).stroke({width:1,color:0,alpha:.12})}for(const o of[s[0],s[1],s[2],s[3]])e.rect(o.x-2,o.y-12,4,12).fill(this.theme.dock.post);const r=Be(s[1],s[2],.5),n=Math.sin(this.time*1.6)*1.5;e.ellipse(r.x+22,r.y+6+n,16,6).fill(this.theme.dock.vessel),e.ellipse(r.x+22,r.y+3+n,13,4).fill(J(this.theme.dock.vessel,0,.12)),e.rect(r.x+20,r.y-12+n,3,15).fill(this.theme.dock.post),e.poly([r.x+23,r.y-12+n,r.x+34,r.y-6+n,r.x+23,r.y-2+n]).fill({color:16777215,alpha:.9})}blobPath(e,t,s){const r=this.world.bounds,n=r.x+r.w/2,o=r.y+r.h/2,a=r.w/2+1.2,l=r.h/2+1.2,h=[],c=li(this.world.seed^1540483477)()*6.28;for(let u=0;u<80;u++){const d=u/80*Math.PI*2,f=1+.07*Math.sin(3*d+c)+.04*Math.sin(5*d+2.1+c)+.025*Math.sin(8*d+1.3),p=K(n+Math.cos(d)*a*f*t,o+Math.sin(d)*l*f*t);h.push(p.x,p.y+s)}return e.poly(h)}drawTerrain(){const e=this.terrain,t=this.theme.ground;if(this.theme.terrain==="island"){this.blobPath(e,1,18).fill(t.edgeDark),this.blobPath(e,1,10).fill(t.edge),this.blobPath(e,1,0).fill(t.sand),this.blobPath(e,.88,-1).fill(t.fill),this.blobPath(e,.6,-2).fill({color:t.fillLight,alpha:.55});const s=this.world.bounds,r=K(s.x+s.w/2,s.y+s.h/2),n=(s.w+s.h)*14;e.circle(r.x-n*.45,r.y-n*.35,n*.9).fill({color:16777215,alpha:.07}),e.circle(r.x+n*.5,r.y+n*.4,n*1.1).fill({color:this.shadowInk,alpha:.08})}else if(this.theme.terrain==="platform"){const s=this.world.bounds,r=De(s.x,s.y,Math.max(s.w,s.h));e.poly(X([r[3],r[2],F(r[2],-14),F(r[3],-14)])).fill(t.edgeDark),e.poly(X([r[2],r[1],F(r[1],-14),F(r[2],-14)])).fill(t.edge),e.poly(X(r)).fill(t.fill),e.poly(X(De(s.x+1,s.y+1,Math.max(s.w,s.h)-2))).fill({color:t.fillLight,alpha:.25}),e.poly(X(r)).stroke({width:2,color:t.sand,alpha:.6})}else{const s=this.world.bounds,r=Math.max(s.w,s.h),n=De(s.x,s.y,r);e.poly(X([n[3],n[2],F(n[2],-10),F(n[3],-10)])).fill(t.edgeDark),e.poly(X([n[2],n[1],F(n[1],-10),F(n[2],-10)])).fill(t.edge),e.poly(X(n)).fill(t.fill);for(let o=1;o<r;o+=2){const a=K(s.x+o,s.y),l=K(s.x+o,s.y+r);e.moveTo(a.x,a.y).lineTo(l.x,l.y).stroke({width:1,color:t.sand,alpha:.12})}for(let o=1;o<r;o+=2){const a=K(s.x,s.y+o),l=K(s.x+r,s.y+o);e.moveTo(a.x,a.y).lineTo(l.x,l.y).stroke({width:1,color:t.sand,alpha:.12})}}}drawRipples(){const e=this.ripples;if(e.clear(),this.theme.terrain!=="island"){const t=li(this.world.seed);for(let s=0;s<70;s++){const r=(t()-.5)*2600,n=(t()-.5)*1600,o=.5+.5*Math.sin(this.time*(.6+t())+s);e.circle(r,n,.8+t()*1.2).fill({color:this.theme.water.ripple,alpha:this.theme.water.rippleAlpha*o})}return}for(let t=0;t<3;t++){const s=(this.time*.06+t/3)%1;this.blobPath(e,1.04+s*.45,8).stroke({width:1.4,color:this.theme.water.ripple,alpha:this.theme.water.rippleAlpha*.7*(1-s)})}}drawPaths(){const e=this.paths;for(const t of this.world.paths){const s=t.points.map(([r,n])=>K(r+.5,n+.5));e.moveTo(s[0].x,s[0].y);for(const r of s.slice(1))e.lineTo(r.x,r.y);e.stroke({width:7,color:this.theme.pathColor,alpha:.9,cap:"round",join:"round"})}}drawLabels(){const e=new As({fontFamily:"Fredoka, Trebuchet MS, sans-serif",fontSize:22,fontWeight:"700",fill:16777215,letterSpacing:2,stroke:{color:this.theme.vignette,width:4,join:"round"}});for(const t of this.world.districts){const s=new Sp({text:t.label,style:e});s.anchor.set(.5,.5);const r=K(t.bounds.x+t.bounds.w/2+.5,t.bounds.y+t.bounds.h+.55);s.position.set(r.x,r.y),s.alpha=.55,s.skew.set(-.35,.17),this.labels.addChild(s)}}placeProps(){const e=li(this.world.seed^2654435769),t=new Set;for(const a of this.world.places)for(let l=0;l<a.footprint;l++)for(let h=0;h<a.footprint;h++)t.add(`${a.gx+l},${a.gy+h}`);const s=this.world.bounds;let r=0,n=0;const o=Math.min(18,5+Math.floor(this.world.places.length/5));for(;n<o&&r++<700;){const a=Math.floor(s.x+1+e()*(s.w-2)),l=Math.floor(s.y+1+e()*(s.h-2));if(t.has(`${a},${l}`)||this.world.districts.some(_=>a>=_.bounds.x&&a<_.bounds.x+_.bounds.w&&l>=_.bounds.y&&l<_.bounds.y+_.bounds.h))continue;t.add(`${a},${l}`);const h=new _e;h.zIndex=hu(a,l);const c=new Pe;h.addChild(c);const u=K(a+.5,l+.5),d=(.85+e()*.4)*1.25,[f,p,g]=this.theme.propColors;let m;this.theme.prop==="tree"?(c.ellipse(u.x+3,u.y+1,9*d,4*d).fill({color:666138,alpha:.18}),c.rect(u.x-1.5,u.y-10*d,3,10*d).fill(g),m=new Pe,m.ellipse(u.x+1*d,u.y-13*d,9.5*d,7.5*d).fill(J(f,this.shadowInk,.25)),m.ellipse(u.x,u.y-16*d,9*d,8.5*d).fill(f),m.ellipse(u.x-4*d,u.y-19*d,6.5*d,6*d).fill(p),m.ellipse(u.x+4.5*d,u.y-20*d,5.5*d,5*d).fill(p),m.ellipse(u.x-3.5*d,u.y-22*d,3.2*d,2.4*d).fill({color:16777215,alpha:.32}),h.addChild(m)):this.theme.prop==="antenna"?(c.rect(u.x-1,u.y-18*d,2,18*d).fill(f),c.circle(u.x,u.y-20*d,2.5).fill(p),c.ellipse(u.x,u.y,5*d,2.5*d).fill(g)):(c.rect(u.x-1,u.y-16*d,2,16*d).fill(g),c.circle(u.x,u.y-17*d,3).fill(f),c.circle(u.x,u.y-17*d,7).fill({color:p,alpha:.18})),this.objects.addChild(h),this.props.push({g:c,gx:a,gy:l,phase:e()*6.28,...m?{canopy:m}:{}}),n++}}}const ub=i=>J(i,16777215,.25);function db(i,e,t,s){return new je({start:{x:0,y:t},end:{x:0,y:s},colorStops:[{offset:0,color:i},{offset:1,color:e}],textureSpace:"global"})}function fb(i,e,t,s){return new je({start:{x:t,y:0},end:{x:s,y:0},colorStops:[{offset:0,color:i},{offset:1,color:e}],textureSpace:"global"})}const Vi=i=>Math.round(i/2)*2;function J(i,e,t){const s=i>>16&255,r=i>>8&255,n=i&255,o=e>>16&255,a=e>>8&255,l=e&255,h=Math.round(s+(o-s)*t),c=Math.round(r+(a-r)*t),u=Math.round(n+(l-n)*t);return h<<16|c<<8|u}class Io{constructor(e,t,s){this.id=e,this.theme=t,this.reducedMotion=s,this.container.addChild(this.g)}container=new _e;g=new Pe;t=Math.random()*10;x=0;y=0;scale=1;alpha=1;lift=0;panic=0;peek=0;update(e){this.t+=e/1e3;const t=this.t,s=this.g,r=this.theme.gremlin,n=this.reducedMotion?0:Math.abs(Math.sin(t*(7+this.panic*5)))*(6+this.panic*3);this.container.position.set(this.x,this.y),this.container.alpha=this.alpha,s.clear(),s.ellipse(0,0,7*this.scale,3*this.scale).fill({color:994600,alpha:.25}),s.position.set(0,0);const o=this.scale,a=9,l=[];for(let u=0;u<=a*2;u++){const d=u/(a*2)*Math.PI*2,f=(u%2?7.2:9.6+Math.sin(t*20+u)*.7)*o;l.push(Math.cos(d)*f,-9*o-n-this.lift+Math.sin(d)*f*.9)}s.poly(l).fill(r.body);const h=-10*o-n-this.lift;s.ellipse(-3*o,h,2.4*o,2.6*o).fill(16777215),s.ellipse(3*o,h,2.4*o,2.6*o).fill(16777215);const c=this.panic?Math.sin(t*9)*.8:.4;s.ellipse(-2.6*o+c,h+.4,1.2*o,1.3*o).fill(r.eye),s.ellipse(3.4*o+c,h+.4,1.2*o,1.3*o).fill(r.eye),s.moveTo(-5.5*o,h-4*o).lineTo(-1.2*o,h-2.4*o).moveTo(5.5*o,h-4*o).lineTo(1.2*o,h-2.4*o).stroke({width:1.3*o,color:r.eye,cap:"round"}),s.moveTo(-2.6*o,h+4.4*o).lineTo(-1.2*o,h+3.4*o).lineTo(.2*o,h+4.4*o).lineTo(1.6*o,h+3.4*o).lineTo(2.9*o,h+4.4*o).stroke({width:1.3*o,color:r.eye,cap:"round"})}}const pb=Object.freeze(Object.defineProperty({__proto__:null,Gremlin:Io},Symbol.toStringTag,{value:"Module"}));class mb{constructor(e){this.reducedMotion=e}g=new Pe;parts=[];burst(e,t,s,r,n,o=0){this.reducedMotion&&(s=Math.ceil(s/4));for(let a=0;a<s;a++){const l=Math.random()*Math.PI*2,h=n*(.4+Math.random()*.8);this.parts.push({x:e,y:t,vx:Math.cos(l)*h,vy:Math.sin(l)*h*.6-o*(.5+Math.random()),life:0,max:.7+Math.random()*.8,c:r[a%r.length],r:1.4+Math.random()*2.4})}}clear(){this.parts=[],this.g.clear()}get count(){return this.parts.length}update(e){const t=e/1e3;this.parts=this.parts.filter(s=>(s.life+=t)<s.max),this.g.clear();for(const s of this.parts)s.vy+=140*t,s.x+=s.vx*t,s.y+=s.vy*t,this.g.rect(s.x-s.r/2,s.y-s.r/2,s.r,s.r*1.3).fill({color:s.c,alpha:1-s.life/s.max})}}const wt=[{id:"pip",name:"Pip",bio:"Curious, quick, a little clumsy. The original.",shape:"round",topper:"antenna",eyes:"wide",body:16751164,bodyLight:16765566,belly:16774620,ear:14712620,cheek:16739930,ink:2759959,size:1},{id:"mo",name:"Mo",bio:"Tall, calm, measures twice.",shape:"tall",topper:"tuft",eyes:"sleepy",body:6269183,bodyLight:11129599,belly:15398143,ear:4161488,cheek:16748448,ink:1385274,size:1.1},{id:"juno",name:"Juno",bio:"Bright, chatty, finds the bug by talking to it.",shape:"bean",topper:"ears",eyes:"wide",body:8380554,bodyLight:13172672,belly:15990768,ear:5223526,cheek:16756896,ink:1456671,size:.95},{id:"rook",name:"Rook",bio:"Boxy, deliberate, never guesses.",shape:"boxy",topper:"crest",eyes:"visor",body:10134712,bodyLight:14015462,belly:15659510,ear:7239820,cheek:8188927,ink:1778224,size:1.05},{id:"fen",name:"Fen",bio:"Quiet and sharp. Reads everything first.",shape:"teardrop",topper:"leaf",eyes:"dot",body:11967743,bodyLight:14734079,belly:16183551,ear:9401062,cheek:16754392,ink:2759498,size:.9},{id:"sol",name:"Sol",bio:"Warm, loud, celebrates everything.",shape:"round",topper:"halo",eyes:"wide",body:16765503,bodyLight:16773288,belly:16776166,ear:14723072,cheek:16747610,ink:3811845,size:1.08},{id:"ivy",name:"Ivy",bio:"Patient gardener of code. Hates loose ends.",shape:"bean",topper:"leaf",eyes:"sleepy",body:4177818,bodyLight:10481880,belly:15400952,ear:2788464,cheek:16756896,ink:997934,size:1},{id:"bolt",name:"Bolt",bio:"Fast. Sometimes too fast.",shape:"teardrop",topper:"crest",eyes:"dot",body:16734878,bodyLight:16756944,belly:16773366,ear:13645178,cheek:16765566,ink:3804962,size:.92},{id:"ash",name:"Ash",bio:"Dry wit, steady hands.",shape:"tall",topper:"ears",eyes:"sleepy",body:8024976,bodyLight:12104396,belly:15657973,ear:5656684,cheek:16758087,ink:1709872,size:1.06},{id:"nimbus",name:"Nimbus",bio:"Soft, cloud-headed, surprisingly precise.",shape:"round",topper:"halo",eyes:"wide",body:15660287,bodyLight:16777215,belly:16777215,ear:13228272,cheek:16756936,ink:2767442,size:1.02},{id:"ember",name:"Ember",bio:"Runs hot. Loves a red lighthouse.",shape:"boxy",topper:"antenna",eyes:"visor",body:16739133,bodyLight:16756874,belly:16773606,ear:12862506,cheek:16769899,ink:3805704,size:1},{id:"tove",name:"Tove",bio:"Small, brave, follows the map.",shape:"bean",topper:"tuft",eyes:"dot",body:13214827,bodyLight:15653293,belly:16775142,ear:10254916,cheek:16747610,ink:3811856,size:.85}],Pg=i=>wt.find(e=>e.id===i),cu=i=>(.2126*(i>>16&255)+.7152*(i>>8&255)+.0722*(i&255))/255,Ag=(i,e)=>Math.abs(cu(i.body)-cu(e))>.22;function Rg(i,e,t){const s=a=>t===void 0||Ag(a,t);let r=Pg(e)??wt[i%wt.length];s(r)||(r=wt.find((a,l)=>l>=i%wt.length&&s(a))??wt.find(s)??r);const n=wt.filter(a=>a.id!==r.id&&s(a)),o=n.length?(i>>>3)%n.length:0;return{lead:r,helpers:[...n.slice(o),...n.slice(0,o)]}}const gb=Object.freeze(Object.defineProperty({__proto__:null,CAST:wt,castById:Pg,pickCompany:Rg,readableOn:Ag},Symbol.toStringTag,{value:"Module"}));class Go{constructor(e,t,s=wt[0]){this.theme=e,this.reducedMotion=t,this.spec=s,this.container.addChild(this.shadow,this.body),this.container.scale.set(1.75*s.size)}container=new _e;shadow=new Pe;body=new Pe;t=0;pose={x:0,y:0,lift:0,sx:1,sy:1,lean:0,face:1,moving:!1,look:"fwd",mood:"curious",hiding:0};shown={x:0,y:0,lift:0,sx:1,sy:1,lean:0,face:1,faceK:1};snapNext=!0;snap(){this.snapNext=!0}get drawn(){return{x:this.shown.x,y:this.shown.y}}setTheme(e){this.theme=e}update(e){this.t+=e/1e3;const t=this.pose,s=this.spec,r=this.t,n=this.shown,o=Math.min(.05,e/1e3);this.snapNext&&(Object.assign(n,{x:t.x,y:t.y,lift:t.lift,sx:t.sx,sy:t.sy,lean:t.lean,face:t.face,faceK:1}),this.snapNext=!1);const a=1-Math.pow(5e-4,o),l=1-Math.pow(.002,o);n.x+=(t.x-n.x)*l,n.y+=(t.y-n.y)*l,n.lift+=(t.lift-n.lift)*a,n.sx+=(t.sx-n.sx)*a,n.sy+=(t.sy-n.sy)*a,n.lean+=(t.lean-n.lean)*a,n.face!==t.face?(n.faceK-=o*9,n.faceK<=0&&(n.face=t.face,n.faceK=.01)):n.faceK=Math.min(1,n.faceK+o*9);const h={...t,x:n.x,y:n.y,lift:n.lift,sx:n.sx*Math.max(.15,n.faceK),sy:n.sy,lean:n.lean,face:n.face};this.container.position.set(h.x,h.y),this.container.zIndex=1e6;const c=1-Math.min(.6,h.lift/90);this.shadow.clear().ellipse(0,0,11*c,5*c).fill({color:0,alpha:.28}),this.shadow.ellipse(0,0,14*c,7*c).fill({color:0,alpha:.1});const u=this.body;u.clear(),u.position.set(0,-h.lift),u.rotation=h.lean,u.scale.set(h.sx,h.sy);const d=h.moving||this.reducedMotion?0:Math.sin(r*2.2)*.012;u.scale.set(h.sx*(1-d),h.sy*(1+d));const f=h.moving?Math.sin(r*11)*3:0;switch(u.ellipse(-5+f,-1.5,4.2,2.6).fill(s.ear),u.ellipse(5-f,-1.5,4.2,2.6).fill(s.ear),s.shape){case"tall":u.ellipse(0,-16,9.5,16.5).fill(s.body),u.ellipse(-1.5,-21,7.5,9).fill({color:s.bodyLight,alpha:.55});break;case"boxy":u.roundRect(-11,-26,22,26,6).fill(s.body),u.roundRect(-9,-24,12,10,4).fill({color:s.bodyLight,alpha:.5});break;case"teardrop":u.moveTo(0,-30).quadraticCurveTo(13,-16,11,-6).quadraticCurveTo(0,2,-11,-6).quadraticCurveTo(-13,-16,0,-30).fill(s.body),u.ellipse(-2,-16,6,7).fill({color:s.bodyLight,alpha:.5});break;case"bean":u.ellipse(0,-12,12.5,11.5).fill(s.body),u.ellipse(-2,-18,8,6).fill({color:s.bodyLight,alpha:.55});break;default:u.ellipse(0,-13.5,11.5,13.5).fill(s.body),u.ellipse(-1.5,-17,9.5,9).fill({color:s.bodyLight,alpha:.55})}const p=s.shape==="tall"?9.5:s.shape==="boxy"?11:s.shape==="bean"?12.5:11.5,g=s.shape==="tall"?-16:s.shape==="boxy"?-13:s.shape==="bean"?-12:-13.5;u.moveTo(-p*.9,g-p*.2).quadraticCurveTo(-p*.75,g-p*.95,p*.1,g-p*1.02).stroke({width:2.2,color:16777215,alpha:.5,cap:"round"}),u.moveTo(p*.95,g+p*.1).quadraticCurveTo(p*.8,g+p*.8,p*.1,g+p*.98).stroke({width:2.4,color:this.theme.sky[0],alpha:.28,cap:"round"}),u.ellipse(h.face*1.2,-7.5,6.5,5.5).fill({color:s.belly,alpha:.92}),u.ellipse(-8+h.face*1.5,-11,2.4,1.5).fill({color:s.cheek,alpha:.45}),u.ellipse(8+h.face*1.5,-11,2.4,1.5).fill({color:s.cheek,alpha:.45});const m=h.moving?Math.sin(r*14)*.25:0,_=s.shape==="tall"?-33:s.shape==="teardrop"?-30:-27;switch(s.topper){case"ears":u.ellipse(-9,_+4+m*6,3.2,5).fill(s.ear),u.ellipse(9,_+4-m*6,3.2,5).fill(s.ear);break;case"tuft":u.moveTo(-3,_+1).quadraticCurveTo(-6,_-9,1,_-12).moveTo(0,_).quadraticCurveTo(4,_-10,8,_-8).stroke({width:2.2,color:s.ear,cap:"round"});break;case"leaf":u.moveTo(0,_).quadraticCurveTo(2+m*10,_-8,8,_-12).quadraticCurveTo(4,_-4,0,_).fill(s.ear),u.moveTo(0,_).lineTo(5,_-7).stroke({width:1,color:s.belly,alpha:.7});break;case"crest":for(const T of[-6,-2,2,6])u.moveTo(T,_+1).lineTo(T*1.4,_-7-Math.abs(T)*.3).stroke({width:2.4,color:s.ear,cap:"round"});break;case"halo":u.ellipse(0,_-7,9,2.6).stroke({width:1.8,color:this.theme.mood[h.mood],alpha:.9});break;case"antenna":u.ellipse(-9,_+4+m*6,3.2,5).fill(s.ear),u.ellipse(9,_+4-m*6,3.2,5).fill(s.ear);break}const y=h.face*1.8,x=-16,b=!this.reducedMotion&&r%3.3<.13&&h.mood!=="happy";for(const T of[-1,1]){const k=y+T*4.6;if(h.mood==="happy"){u.beginPath(),u.arc(k,x+1.5,2.8,Math.PI*1.1,Math.PI*1.9).stroke({width:1.6,color:s.ink,cap:"round"});continue}if(b){u.moveTo(k-2.6,x).lineTo(k+2.6,x).stroke({width:1.6,color:s.ink,cap:"round"});continue}if(s.eyes==="visor"){T<0&&(u.roundRect(y-8.5,x-3,17,6,3).fill(16777215),u.roundRect(y-7+(h.look==="up"?0:1),x-1.5,5,3,1.5).fill(s.ink),u.roundRect(y+2+(h.look==="up"?0:1),x-1.5,5,3,1.5).fill(s.ink));continue}const E=s.eyes==="dot"?2.6:s.eyes==="sleepy"?2.4:h.mood==="focused"?3:4.3;u.ellipse(k,x,s.eyes==="dot"?2.6:3.4,E).fill(16777215),s.eyes==="sleepy"&&u.moveTo(k-3.4,x-2.2).lineTo(k+3.4,x-2.2).stroke({width:2,color:s.body});const A=!h.moving&&!this.reducedMotion&&r%4.1>3.3?Math.sin((r%4.1-3.3)/.8*Math.PI):0;let M=h.face*1.1+A*1.6,B=(h.look==="up"?-1.6:h.look==="down"?1.4:.3)-A*.8;h.mood==="lost"&&(M=Math.sin(r*3)*1.4,B=-1.2),u.ellipse(k+M,x+B,1.9,h.mood==="focused"?1.8:2.2).fill(s.ink),u.ellipse(k+M+.7,x+B-.8,.6,.6).fill(16777215),h.mood==="lost"&&u.moveTo(k-3,x-5.6-(T>0?0:1.3)).lineTo(k+3,x-5.6-(T>0?1.3:0)).stroke({width:1.6,color:s.ink,cap:"round"}),h.mood==="focused"&&u.moveTo(k-3.2,x-3.7-(T>0?1:0)).lineTo(k+3.2,x-3.7-(T>0?0:1)).stroke({width:1.6,color:s.ink,cap:"round"}),h.mood==="uneasy"&&u.moveTo(k-3,x-5).lineTo(k+3,x-6+(T>0?1.5:-1.5)).stroke({width:1.4,color:s.ink,cap:"round"})}u.beginPath(),h.mood==="happy"?u.arc(y,-10.5,3.2,0,Math.PI).fill(8007202):h.mood==="lost"||h.mood==="uneasy"?u.arc(y,-8.4,2.2,Math.PI*1.15,Math.PI*1.85).stroke({width:1.6,color:s.ink,cap:"round"}):u.arc(y,-11.2,1.9,Math.PI*.15,Math.PI*.85).stroke({width:1.6,color:s.ink,cap:"round"});const v=(this.reducedMotion?0:Math.sin(r*5)*2)-h.lean*10,w=this.theme.mood[h.mood];if(s.topper==="antenna"?(u.moveTo(0,_+.5).quadraticCurveTo(v*.5,_-5,v+1.5,_-9).stroke({width:1.4,color:s.ear}),u.circle(v+1.5,_-10,9).fill({color:w,alpha:.28}),u.circle(v+1.5,_-10,5.5).fill({color:w,alpha:.35}),u.circle(v+1.5,_-10,2.8).fill(w)):s.topper!=="halo"&&(u.circle(0,_-2,7).fill({color:w,alpha:.22}),u.circle(0,_-2,2.2).fill({color:w,alpha:.9})),h.hiding>0){const T=st(r*.5%1)*h.hiding;u.rotation=h.lean+T*.06}}}const _b=Object.freeze(Object.defineProperty({__proto__:null,Pip:Go},Symbol.toStringTag,{value:"Module"})),xt=[0,2,4,7,9],yb=[0,3,5,7,10],uu=[0,2,4,6,7,9,11],du=[0,2,3,5,7,9,10],xb=[0,2,4,5,7,9,10],bb=[0,2,4,6,8,10],vb=[0,1,4,5,7,8,11],In=[0,2,3,5,7,8,10],wb={island:{scale:xt,root:261.6,wave:"sine",gain:.05,every:16,len:[.45,.9]},orbit:{scale:uu,root:220,wave:"triangle",gain:.035,every:20,len:[.8,1.6]},metropolis:{scale:du,root:196,wave:"triangle",gain:.04,every:18,len:[.3,.7]},harbour:{scale:xb,root:233,wave:"sine",gain:.045,every:17,len:[.5,1.1]},observatory:{scale:bb,root:329.6,wave:"sine",gain:.035,every:22,len:[.9,1.8]},greenhouse:{scale:xt,root:293.7,wave:"triangle",gain:.045,every:15,len:[.35,.8]},workshop:{scale:xt,root:220,wave:"triangle",gain:.045,every:16,len:[.3,.6]},arcade:{scale:yb,root:261.6,wave:"square",gain:.025,every:12,len:[.15,.35]},kingdom:{scale:du,root:174.6,wave:"triangle",gain:.045,every:19,len:[.6,1.2]},outpost:{scale:In,root:196,wave:"sine",gain:.04,every:21,len:[.8,1.6]},snowfield:{scale:xt,root:392,wave:"sine",gain:.04,every:18,len:[.7,1.5]},canopy:{scale:xt,root:246.9,wave:"triangle",gain:.045,every:14,len:[.3,.7]},lagoon:{scale:xt,root:329.6,wave:"sine",gain:.045,every:15,len:[.4,.9]},volcano:{scale:In,root:146.8,wave:"sawtooth",gain:.03,every:20,len:[.9,1.8]},cloudtop:{scale:uu,root:392,wave:"sine",gain:.04,every:17,len:[.8,1.6]},reef:{scale:xt,root:174.6,wave:"sine",gain:.045,every:14,len:[.9,2]},bazaar:{scale:vb,root:220,wave:"triangle",gain:.045,every:13,len:[.25,.6]},monastery:{scale:xt,root:196,wave:"sine",gain:.05,every:24,len:[1.2,2.4]},moonbase:{scale:In,root:164.8,wave:"sine",gain:.035,every:23,len:[1,2]},lanterns:{scale:xt,root:523.3,wave:"sine",gain:.04,every:14,len:[.3,.7]}},Xe={wave:"triangle",pitch:1,decay:1,tone:3200,surface:"grass"},Gn={wave:"square",pitch:1.18,decay:.8,tone:2600,surface:"metal"},fu={wave:"sawtooth",pitch:.95,decay:1.1,tone:2200,surface:"stone"},Tb={island:"pluck",orbit:"blip",metropolis:"synth",harbour:"wood",observatory:"glass",greenhouse:"marimba",workshop:"wood",arcade:"blip",kingdom:"bell",outpost:"pluck",snowfield:"glass",canopy:"marimba",lagoon:"drop",volcano:"synth",cloudtop:"glass",reef:"drop",bazaar:"pluck",monastery:"bell",moonbase:"blip",lanterns:"bell"},Sb={island:"relax",orbit:"focus",metropolis:"focus",harbour:"relax",observatory:"focus",greenhouse:"relax",workshop:"fun",arcade:"fun",kingdom:"fun",outpost:"focus",snowfield:"relax",canopy:"fun",lagoon:"relax",volcano:"focus",cloudtop:"relax",reef:"relax",bazaar:"fun",monastery:"focus",moonbase:"focus",lanterns:"fun"},Cb={island:{voice:Xe,ambience:{washes:[{hz:520,q:.6,gain:.09,lfoHz:.11,depth:.6},{hz:240,q:.9,gain:.05,lfoHz:.07,depth:.8}],extras:["gull","cricket"],every:9}},orbit:{voice:Gn,ambience:{washes:[{hz:900,q:2,gain:.015,lfoHz:.05,depth:.9}],pad:{chord:[55,110,164.8],gain:.05,wave:"sine"},extras:["hum","chime"],every:11}},metropolis:{voice:fu,ambience:{washes:[{hz:380,q:.5,gain:.07,lfoHz:.2,depth:.5}],pad:{chord:[65.4,98],gain:.03,wave:"triangle"},extras:["horn","hum"],every:10}},harbour:{voice:{...Xe,surface:"wood",decay:1.3},ambience:{washes:[{hz:420,q:.6,gain:.1,lfoHz:.09,depth:.7}],extras:["gull","bell","horn"],every:8}},observatory:{voice:{...Gn,wave:"sine",pitch:1.3,decay:1.6,tone:4e3,surface:"stone"},ambience:{washes:[{hz:300,q:.8,gain:.04,lfoHz:.04,depth:.9}],pad:{chord:[49,98,146.8],gain:.04,wave:"sine"},extras:["wind","chime"],every:12}},greenhouse:{voice:{...Xe,pitch:1.1,decay:1.2},ambience:{washes:[{hz:600,q:.6,gain:.05,lfoHz:.1,depth:.5}],extras:["cricket","drip","bell"],every:7}},workshop:{voice:{...Xe,wave:"triangle",pitch:.9,decay:.8,tone:2800,surface:"wood"},ambience:{washes:[{hz:500,q:.6,gain:.05,lfoHz:.12,depth:.5}],extras:["cricket","bell"],every:9}},arcade:{voice:{wave:"square",pitch:1.35,decay:.6,tone:3600,surface:"neon"},ambience:{washes:[{hz:300,q:.5,gain:.05,lfoHz:.25,depth:.4}],pad:{chord:[65.4,82.4,98],gain:.03,wave:"square"},extras:["chime","horn"],every:6}},kingdom:{voice:{...Xe,wave:"triangle",pitch:.85,decay:1.5,tone:2400,surface:"stone"},ambience:{washes:[{hz:450,q:.6,gain:.07,lfoHz:.1,depth:.6}],extras:["bell","wind","owl"],every:10}},outpost:{voice:{...Xe,pitch:.92,decay:1.4,tone:2600,surface:"sand"},ambience:{washes:[{hz:700,q:.4,gain:.08,lfoHz:.06,depth:.9}],extras:["wind","hum"],every:9}},snowfield:{voice:{...Xe,wave:"sine",pitch:1.15,decay:1.7,tone:3400,surface:"snow"},ambience:{washes:[{hz:800,q:.4,gain:.05,lfoHz:.05,depth:.9}],extras:["wind","chime","owl"],every:11}},canopy:{voice:{...Xe,pitch:1.05,decay:1.2,tone:3e3,surface:"wood"},ambience:{washes:[{hz:650,q:.7,gain:.07,lfoHz:.09,depth:.5}],extras:["cricket","owl","drip"],every:6}},lagoon:{voice:{...Xe,wave:"sine",pitch:1.2,decay:1.3,tone:3600,surface:"sand"},ambience:{washes:[{hz:480,q:.6,gain:.1,lfoHz:.1,depth:.7}],extras:["gull","bubble"],every:8}},volcano:{voice:{wave:"sawtooth",pitch:.75,decay:1.6,tone:1600,surface:"stone"},ambience:{washes:[{hz:160,q:1,gain:.1,lfoHz:.08,depth:.8}],pad:{chord:[41.2,61.7],gain:.04,wave:"sawtooth"},extras:["rumble","wind"],every:8}},cloudtop:{voice:{...Xe,wave:"sine",pitch:1.25,decay:1.8,tone:4200,surface:"grass"},ambience:{washes:[{hz:900,q:.4,gain:.05,lfoHz:.04,depth:.9}],pad:{chord:[130.8,196,261.6],gain:.025,wave:"sine"},extras:["wind","chime"],every:12}},reef:{voice:{wave:"sine",pitch:.9,decay:1.9,tone:1400,surface:"water"},ambience:{washes:[{hz:220,q:1.2,gain:.09,lfoHz:.09,depth:.7}],extras:["bubble","drip"],every:5}},bazaar:{voice:{...Xe,pitch:1.05,decay:.9,tone:3e3,surface:"sand"},ambience:{washes:[{hz:500,q:.5,gain:.06,lfoHz:.3,depth:.4}],extras:["market","bell","chime"],every:6}},monastery:{voice:{...Xe,wave:"sine",pitch:.95,decay:2,tone:2600,surface:"stone"},ambience:{washes:[{hz:420,q:.5,gain:.05,lfoHz:.05,depth:.8}],extras:["bell","wind","owl"],every:12}},moonbase:{voice:{...Gn,pitch:1.05,decay:1.2,tone:2200},ambience:{washes:[{hz:240,q:1.5,gain:.03,lfoHz:.03,depth:.9}],pad:{chord:[55,82.4],gain:.04,wave:"sine"},extras:["hum","chime"],every:13}},lanterns:{voice:{...fu,wave:"triangle",pitch:1.1,decay:1.2,tone:3e3,surface:"stone"},ambience:{washes:[{hz:400,q:.5,gain:.05,lfoHz:.2,depth:.5}],extras:["market","chime","bell"],every:6}}},Do=Object.fromEntries(Object.entries(Cb).map(([i,e])=>[i,{...e,voice:{...e.voice,instrument:Tb[i]},ambience:{...e.ambience,mood:Sb[i]},tune:wb[i]}])),Mb=i=>i,kb=new Set(["curtain_up","curtain_down","test_outcome","celebrate","blocked_on_you","unverified_claim","spawn_gremlin","banish"]),Eb=[523.25,659.25,783.99,1046.5],Ie=(i,e)=>i+Math.random()*(e-i);class ji{constructor(e){this.a=e}footstep(e,t){const s=this.a;switch(e){case"stone":s.noise(.04,{filter:"bandpass",freq:Ie(1400,1900),q:2,gain:.05,pan:t}),s.tone(Ie(160,200),.03,{type:"triangle",gain:.03,pan:t});return;case"metal":s.tone(Ie(700,900),.05,{type:"square",gain:.03,lowpass:2e3,pan:t}),s.noise(.03,{filter:"highpass",freq:3e3,gain:.03,pan:t});return;case"sand":s.noise(.09,{filter:"lowpass",freq:Ie(700,1e3),q:.5,gain:.05,pan:t});return;case"snow":s.noise(.08,{filter:"bandpass",freq:Ie(2500,3500),q:.8,gain:.04,pan:t});return;case"wood":s.tone(Ie(220,300),.05,{type:"triangle",gain:.05,slideTo:120,pan:t});return;case"water":s.noise(.08,{filter:"bandpass",freq:Ie(400,700),q:1,gain:.05,sweepTo:1200,pan:t});return;case"neon":s.tone(Ie(900,1200),.035,{type:"square",gain:.025,lowpass:3e3,pan:t});return;default:s.noise(.05,{filter:"bandpass",freq:Ie(900,1300),q:1.2,gain:.05,pan:t});return}}static plays(e,t){return t<=1.01||kb.has(e)}take={pitch:.92+Math.random()*.18,decay:.85+Math.random()*.4,tone:.8+Math.random()*.5,swap:Math.random()<.3};play(e,t){const s=this.a,r=t.pan??0,n=t.intensity??.5,o=Do[t.theme.id].voice,a=this.take,l={sine:"triangle",triangle:"sine",square:"sawtooth",sawtooth:"square",custom:"sine"},h={...o,pitch:o.pitch*a.pitch,decay:o.decay*a.decay,tone:o.tone*a.tone,wave:a.swap?l[o.wave]:o.wave},c={tone:(u,d,f={})=>{const p=.97+Math.random()*.06,g=.85+Math.random()*.3,m=u*h.pitch*p,_=d*h.decay*g,y=f.gain??.25,x={...f,lowpass:Math.min(f.lowpass??h.tone,h.tone),...f.slideTo?{slideTo:f.slideTo*h.pitch*p}:{}};switch(Mb(h.instrument)){case"pluck":s.tone(m,_*.6,{...x,type:"triangle",attack:.003,gain:y}),s.tone(m*2,_*.25,{...x,type:"sine",attack:.002,gain:y*.35}),s.noise(.012,{filter:"highpass",freq:3e3,gain:y*.3});return;case"bell":s.tone(m,_*1.8,{...x,type:"sine",attack:.004,gain:y}),s.tone(m*2.76,_*1.1,{...x,type:"sine",attack:.004,gain:y*.3}),s.tone(m*5.4,_*.5,{...x,type:"sine",attack:.004,gain:y*.12});return;case"marimba":s.tone(m,_*.5,{...x,type:"sine",attack:.003,gain:y}),s.tone(m*4,_*.12,{...x,type:"sine",attack:.002,gain:y*.25}),s.noise(.02,{filter:"bandpass",freq:1800,q:2,gain:y*.25});return;case"blip":s.tone(m,_*.35,{...x,type:"square",attack:.002,gain:y*.7}),s.tone(m*1.5,_*.2,{...x,type:"square",attack:.002,gain:y*.2});return;case"glass":s.tone(m,_*2,{...x,type:"sine",attack:.02,gain:y*.9}),s.tone(m*1.005,_*2,{...x,type:"sine",attack:.02,gain:y*.6}),s.tone(m*3,_*.8,{...x,type:"sine",attack:.01,gain:y*.15});return;case"wood":s.tone(m*.5,_*.3,{...x,type:"triangle",attack:.002,gain:y*.9,slideTo:m*.35}),s.noise(.04,{filter:"lowpass",freq:1200,gain:y*.5});return;case"drop":s.tone(m*.8,_*.7,{...x,type:"sine",attack:.006,gain:y,slideTo:m*1.6}),s.noise(.05,{filter:"bandpass",freq:900,q:1.5,gain:y*.25,sweepTo:2400});return;default:s.tone(m,_,{...x,type:f.type??h.wave,gain:y}),s.tone(m*.5,_*.8,{...x,type:"sawtooth",attack:.01,gain:y*.25,lowpass:900});return}},noise:s.noise.bind(s)};if(e==="footstep")return this.footstep(h.surface,r);switch(e){case"curtain_up":c.tone(392,1.2,{attack:.3,gain:.14}),c.tone(587.3,1.3,{attack:.5,gain:.1}),c.tone(784,1.4,{attack:.7,gain:.08});return;case"curtain_down":c.tone(523.25,1.6,{attack:.2,gain:.12}),c.tone(392,1.8,{attack:.4,gain:.1});return;case"walk_to":return;case"read":c.noise(.14,{filter:"highpass",freq:2500,sweepTo:6e3,gain:.07,pan:r}),c.tone(2200,.05,{gain:.04,pan:r});return;case"hammer":c.tone(Ie(180,240)*(1+n*.4),.06,{type:"triangle",gain:.12+n*.1,slideTo:90,pan:r}),c.noise(.03,{filter:"bandpass",freq:3e3,q:2,gain:.05,pan:r});return;case"build":return;case"raise":c.tone(220,.7,{type:"sawtooth",slideTo:660,gain:.08,lowpass:1800,pan:r}),c.tone(440,.3,{gain:.06,pan:r,attack:.3});return;case"forge":c.tone(620,.25,{type:"square",gain:.06,slideTo:580,lowpass:2400,pan:r}),c.tone(1240,.18,{type:"triangle",gain:.05,detune:30,pan:r}),c.noise(.08,{filter:"highpass",freq:4e3,gain:.04,pan:r});return;case"spark":c.tone(Ie(2500,4200),.04,{gain:.03,pan:r});return;case"search":c.noise(.35,{filter:"bandpass",freq:700,sweepTo:2600,q:1.5,gain:.08,pan:r}),c.tone(1568,.12,{gain:.05,pan:r,attack:.02});return;case"run_tests":c.tone(330,.9,{attack:.15,gain:.06,type:"triangle",lowpass:1200,pan:r}),c.tone(495,.9,{attack:.25,gain:.04,type:"triangle",lowpass:1200,pan:r});return;case"test_outcome":t.outcome==="pass"?Eb.forEach((u,d)=>setTimeout(()=>c.tone(u,.5,{gain:.12,attack:.01,pan:r}),d*70)):(c.tone(311,.35,{type:"sawtooth",gain:.09,lowpass:900,slideTo:262,pan:r}),setTimeout(()=>c.tone(233,.5,{type:"sawtooth",gain:.09,lowpass:700,slideTo:196,pan:r}),170));return;case"spawn_gremlin":for(let u=0;u<4;u++)setTimeout(()=>c.tone(Ie(900,1300)+u*80,.07,{type:"square",gain:.05,lowpass:2600,slideTo:Ie(700,1100),pan:r}),u*60);return;case"chase":for(let u=0;u<3;u++)setTimeout(()=>c.tone(600+u*120,.08,{type:"triangle",gain:.06,pan:r}),u*90);return;case"banish":c.noise(.06,{filter:"lowpass",freq:1500,gain:.14,pan:r}),setTimeout(()=>c.tone(2093,.25,{gain:.07,pan:r}),40),setTimeout(()=>c.tone(2637,.3,{gain:.05,pan:r}),90);return;case"celebrate":[523.25,659.25,783.99,1046.5,1318.5].forEach((u,d)=>setTimeout(()=>c.tone(u,.45,{gain:.11,attack:.01,pan:r}),d*60));for(let u=0;u<10;u++)setTimeout(()=>c.tone(Ie(1800,4e3),.05,{gain:.03,pan:Ie(-.8,.8)}),200+u*55);return;case"summon_helper":t.theme.id==="orbit"?c.noise(.7,{filter:"bandpass",freq:300,sweepTo:1800,q:1.2,gain:.1,pan:r}):t.theme.id==="metropolis"?(c.tone(880,.12,{type:"square",gain:.06,lowpass:2500,pan:r}),setTimeout(()=>c.tone(880,.12,{type:"square",gain:.06,lowpass:2500,pan:r}),180)):(c.tone(146.8,.8,{type:"triangle",attack:.08,gain:.12,lowpass:800,pan:r}),c.tone(147.5,.8,{type:"triangle",attack:.08,gain:.08,lowpass:800,pan:r}));return;case"dismiss_helper":c.noise(.5,{filter:"bandpass",freq:1800,sweepTo:300,q:1.2,gain:.07,pan:r});return;case"blocked_on_you":c.tone(880,.35,{gain:.16,attack:.01}),setTimeout(()=>c.tone(659.25,.6,{gain:.16,attack:.01}),220);return;case"your_turn":c.tone(1046.5,.5,{gain:.07,attack:.02});return;case"stumble":c.noise(.12,{filter:"lowpass",freq:400,gain:.14,pan:r}),c.tone(120,.25,{type:"triangle",gain:.1,slideTo:70,pan:r});return;case"unverified_claim":c.tone(196,.14,{type:"triangle",gain:.07,lowpass:900,pan:r}),setTimeout(()=>c.tone(185,.14,{type:"triangle",gain:.07,lowpass:900,pan:r}),240),setTimeout(()=>c.tone(174.6,.24,{type:"triangle",gain:.06,lowpass:900,pan:r}),480);return;case"idle":return}}}class Pb{constructor(e){this.a=e}stops=[];current=null;padStop=null;padMood=null;extraTimer=null;tuneTimer=null;moodTimer=null;start(e){if(!this.a.ready||this.current===e.id)return;this.stop(),this.current=e.id;const t=Do[e.id].ambience,s=Math.floor(Math.random()*8)-3,r=Math.pow(2,s/12),n={...t,washes:t.washes.map(d=>({...d,hz:d.hz*(.85+Math.random()*.35),lfoHz:d.lfoHz*(.7+Math.random()*.6),gain:d.gain*(.8+Math.random()*.4)})),pad:t.pad?{...t.pad,chord:t.pad.chord.map((d,f)=>d*r*(f>0&&Math.random()<.35?2:1))}:void 0,extras:[...t.extras].sort(()=>Math.random()-.5).slice(0,Math.max(1,Math.ceil(t.extras.length*(.5+Math.random()*.5)))),every:t.every*(.7+Math.random()*.6)};for(const d of n.washes)this.stops.push(this.a.wash(d.hz,d.q,d.gain,d.lfoHz,d.depth));n.pad&&this.stops.push(this.a.pad(n.pad.chord,n.pad.gain,n.pad.wave));const o=()=>{if(this.current!==e.id)return;const d=n.extras[Math.floor(Math.random()*n.extras.length)];d&&this.a.extra(d),this.extraTimer=setTimeout(o,n.every*1e3*(.5+Math.random()))};this.extraTimer=setTimeout(o,2e3+Math.random()*3e3);const a=Do[e.id].tune,l=Math.floor(Math.random()*a.scale.length),h={...a,root:a.root*r,scale:a.scale.map((d,f)=>(a.scale[(f+l)%a.scale.length]-a.scale[l]+12)%12).sort((d,f)=>d-f),every:a.every*(.7+Math.random()*.6)},c=()=>{if(this.current!==e.id)return;const d=4+Math.floor(Math.random()*4);let f=Math.floor(Math.random()*h.scale.length),p=Math.random()<.3?1:0,g=0;for(let m=0;m<d;m++){const _=m===d-1?-(f%3):Math.round((Math.random()-.5)*4);f+=_,f<0&&(f+=h.scale.length,p=Math.max(0,p-1)),f>=h.scale.length&&(f-=h.scale.length,p=Math.min(1,p+1));const y=h.root*Math.pow(2,(h.scale[f]+12*p)/12),x=h.len[0]+Math.random()*(h.len[1]-h.len[0]),b=m===d-1?x*2.2:x;setTimeout(()=>{this.current===e.id&&this.a.note(y,b,h.gain*(.8+Math.random()*.4),h.wave,(Math.random()-.5)*.8)},g*1e3),g+=x*(Math.random()<.2?1.5:1)}this.tuneTimer=setTimeout(c,(g+h.every*(.6+Math.random()*.9))*1e3)};this.tuneTimer=setTimeout(c,4e3+Math.random()*4e3);const u=n.pad?.chord??[h.root/2,h.root*.75,h.root];if(n.mood==="focus"){const d=56+Math.random()*10,f=u[0]/2,p=()=>{this.current===e.id&&(this.a.note(f,.18,.035,"sine",0),this.moodTimer=setTimeout(p,6e4/d))};this.moodTimer=setTimeout(p,1500)}else if(n.mood==="fun"){const d=()=>{if(this.current!==e.id)return;const f=[...u,...u.slice(0,-1).reverse()].map(p=>p*(Math.random()<.5?2:4));f.forEach((p,g)=>setTimeout(()=>{this.current===e.id&&this.a.note(p,.22,.03,"triangle",(g/f.length-.5)*.8)},g*(150+g%2*40))),this.moodTimer=setTimeout(d,9e3+Math.random()*12e3)};this.moodTimer=setTimeout(d,3e3+Math.random()*3e3)}}setMood(e){if(!this.a.ready||e===this.padMood)return;this.padMood=e,this.padStop?.();const t=e==="happy"?[261.6,329.6,392]:e==="lost"?[261.6,311.1,370]:e==="uneasy"?[261.6,311.1,392]:e==="focused"?[261.6,392]:[261.6,329.6];this.padStop=this.a.pad(t.map(s=>s/2),.022,"sine")}stop(){this.extraTimer&&clearTimeout(this.extraTimer),this.extraTimer=null,this.tuneTimer&&clearTimeout(this.tuneTimer),this.tuneTimer=null,this.moodTimer&&clearTimeout(this.moodTimer),this.moodTimer=null;for(const e of this.stops)e();this.stops=[],this.padStop?.(),this.padStop=null,this.padMood=null,this.current=null}}class Ys{constructor(e,t,s,r,n,o){this.app=e,this.world=t,this.theme=s,this.audio=r,this.reducedMotion=n,this.worldLayer=new Eg(t,s),this.particles=new mb(n),this.company=Rg(t.seed,o,s.ground.fill),this.pip=new Go(s,n,this.company.lead),this.camera=new ab(this.stage,n),this.sfx=new ji(r),this.amb=new Pb(r),this.stage.sortableChildren=!0,this.stage.addChild(this.worldLayer.container),this.worldLayer.container.sortableChildren=!0,this.worldLayer.container.addChild(this.pip.container,this.particles.g),this.particles.g.zIndex=1e7,e.stage.addChild(this.stage),this.actorAt.set("pip","forge"),this.fitCamera(),this.camera.snap()}stage=new _e;worldLayer;camera;pip;helpers=new Map;gremlins=new Map;particles;sfx;amb;beats=[];t=0;prevT=-1;_playing=!1;rate=1;duration=0;mood="curious";actorAt=new Map;walkFrom=new Map;growth=new Map;lastPass=0;signal="ok";footT=0;hammerT=0;claimGremlinId=null;evidenceCount=null;company;helperIndex=0;load(e){this.beats=e,this.duration=e.length?Math.max(...e.map(t=>t.atMs+t.durationMs)):0,this.seek(0)}get beatCount(){return this.beats.length}append(e){this.beats.push(...e),this.duration=Math.max(this.duration,...e.map(t=>t.atMs+t.durationMs))}get playing(){return this._playing}play(){this._playing=!0,this.amb.start(this.theme)}audioReady(){this.amb.stop(),this._playing&&this.amb.start(this.theme)}pause(){this._playing=!1}setRate(e){this.rate=e}setSignal(e){this.signal=e}seek(e){this.t=Math.max(0,Math.min(this.duration,e)),this.rebuild(this.t),this.prevT=this.t,this.particles.clear()}get leadName(){return this.company.lead.name}get state(){const e=this.currentBeat();return{t:this.t,duration:this.duration,playing:this._playing,rate:this.rate,current:e,mood:this.mood,bubble:this.bubble(e),labels:this.labels(e),evidence:this.evidenceCount!==null?{passed:this.evidenceCount}:null,signal:this.signal}}update(e){this._playing&&(this.t=Math.min(this.duration,this.t+e*this.rate),this.t>=this.duration&&this.duration>0&&(this._playing=!1),this.triggerBetween(this.prevT,this.t),this.prevT=this.t);const t=this.currentBeat();this.pose(t,e),this.worldState(t),this.worldLayer.update(e),this.pip.update(e);for(const s of this.helpers.values())s.update(e);for(const s of this.gremlins.values())s.update(e);this.particles.update(e),this.cameraStep(t,e),this.amb.setMood(this.mood)}currentBeat(){let e=null;for(const t of this.beats)if(t.atMs<=this.t)(!e||t.atMs>=e.atMs)&&(t.kind==="idle"&&e&&e.kind!=="idle"&&e.atMs+e.durationMs>this.t||(e=t));else break;return e}completed(){return this.beats.filter(e=>e.atMs+e.durationMs<=this.t)}rebuild(e){this.actorAt.clear(),this.actorAt.set("pip","forge"),this.growth.clear(),this.lastPass=0,this.evidenceCount=null,this.mood="curious",this.claimGremlinId=null,this.helperIndex=0;for(const s of this.gremlins.values())s.container.destroy();this.gremlins.clear();for(const s of this.helpers.values())s.container.destroy();this.helpers.clear();for(const s of this.world.places)this.worldLayer.setLamp(s.id,"idle"),this.worldLayer.setGrowth(s.id,0),this.worldLayer.setGlow(s.id,0),this.worldLayer.setScaffold(s.id,0);for(const s of this.beats){if(s.atMs>e)break;this.onStart(s,!0),s.atMs+s.durationMs<=e&&this.onEnd(s,!0)}this.pip.pose.mood=this.mood;const t=this.worldLayer.standingSpot(this.actorAt.get("pip")??"forge");this.pip.pose.x=t.x,this.pip.pose.y=t.y,this.pip.snap(),this.camTarget=null,this.fitCamera(),this.cameraStep(this.currentBeat(),0),this.camera.snap()}triggerBetween(e,t){for(const s of this.beats){s.atMs>e&&s.atMs<=t&&this.onStart(s,!1);const r=s.atMs+s.durationMs;r>e&&r<=t&&this.onEnd(s,!1)}}onStart(e,t){this.mood=e.mood;const s=this.theme,r=o=>{const a=this.worldLayer.positionOf(o);return a?Math.max(-.8,Math.min(.8,a.ground.x/600)):0},n=(o,a={})=>{!t&&ji.plays(o,this.rate)&&this.sfx.play(o,{theme:s,...a})};switch(e.kind){case"curtain_up":n("curtain_up"),t||this.camera.pushIn(.12);break;case"walk_to":{const o=this.worldLayer.standingSpot(this.actorAt.get(e.actor)??"forge");this.walkFrom.set(e.actor,o);break}case"read":n("read",{pan:r(e.target)});break;case"raise":{if(e.newPlace&&!this.worldLayer.has(e.target)){const o=this.world.districts.find(l=>l.id===e.newPlace.district)??this.world.districts[0],a={id:e.target,kind:e.newPlace.kind,path:e.newPlace.path,label:e.newPlace.label,district:e.newPlace.district,gx:(o?.cx??2)+1,gy:(o?.cy??2)+1,footprint:1,height:1,score:0,touched:!0};this.world.places.push(a),this.worldLayer.addPlace(a)}n("raise",{pan:r(e.target)});break}case"build":n("build");break;case"forge":n("forge");break;case"search":n("search",{pan:r("forge")});break;case"run_tests":this.worldLayer.setLamp(e.target,"scan"),n("run_tests",{pan:r(e.target)});break;case"test_outcome":{const o=e.outcome==="pass"?"pass":e.outcome==="fail"?"fail":"idle";if(this.worldLayer.setLamp(e.target,o),e.outcome==="pass"&&(this.lastPass=e.atMs,this.evidenceCount=e.passed),n("test_outcome",{outcome:e.outcome,pan:r(e.target)}),!t&&e.outcome==="fail"&&this.camera.shake(200),!t&&e.outcome==="pass"){const a=this.worldLayer.positionOf(e.target);a&&this.particles.burst(a.top.x,a.top.y,16,[s.beacon.lamp.pass,14090217],70,40)}break}case"spawn_gremlin":{const o=new Io(e.gremlinId,s,this.reducedMotion),a=this.worldLayer.positionOf(e.target),l=a?a.ground:K(0,0);o.x=l.x+18,o.y=l.y+8,o.scale=t?1:.01,this.worldLayer.container.addChild(o.container),this.gremlins.set(e.gremlinId,o),n("spawn_gremlin",{pan:r(e.target)}),t||(this.camera.pushIn(.06),this.particles.burst(o.x,o.y-10,18,[s.gremlin.body,11967743],60,30));break}case"chase":{const o=this.gremlins.get(e.gremlinId);o&&(o.panic=1),n("chase",{pan:r(e.target)});break}case"banish":{const o=this.gremlins.get(e.gremlinId);o&&(t||this.particles.burst(o.x,o.y-10,30,[16777215,s.gremlin.body],80,35),o.container.destroy(),this.gremlins.delete(e.gremlinId)),this.claimGremlinId===e.gremlinId&&(this.claimGremlinId=null,this.pip.pose.hiding=0),n("banish");break}case"celebrate":{if(n("celebrate"),!t){this.camera.pushIn(.1);const o=this.worldLayer.standingSpot(this.actorAt.get("pip")??"forge");this.particles.burst(o.x,o.y-30,56,[16758087,6287526,8177919,16743273,11967743,16777215],130,90)}break}case"summon_helper":{const o=this.company.helpers[this.helperIndex++%this.company.helpers.length],a=new Go(s,this.reducedMotion,o);a.container.scale.set(.82*o.size);const l=this.worldLayer.standingSpot("dock");a.pose.x=l.x,a.pose.y=l.y,this.worldLayer.container.addChild(a.container),this.helpers.set(e.helperId,a),this.actorAt.set(e.helperId,"dock"),n("summon_helper",{pan:r("dock")});break}case"dismiss_helper":n("dismiss_helper",{pan:r("dock")});break;case"blocked_on_you":n("blocked_on_you");break;case"your_turn":n("your_turn");break;case"stumble":n("stumble"),t||this.camera.shake(160);break;case"unverified_claim":{const o=new Io(e.gremlinId,s,this.reducedMotion);o.scale=.8,o.alpha=.95,this.worldLayer.container.addChild(o.container),this.gremlins.set(e.gremlinId,o),this.claimGremlinId=e.gremlinId,this.pip.pose.hiding=1,n("unverified_claim");break}case"curtain_down":n("curtain_down");break}}onEnd(e,t){switch(e.kind){case"walk_to":this.actorAt.set(e.actor,e.target),this.walkFrom.delete(e.actor);break;case"build":this.growth.set(e.target,Math.min(18,(this.growth.get(e.target)??0)+3+Math.round(e.intensity*6))),this.worldLayer.setGrowth(e.target,this.growth.get(e.target)),this.worldLayer.setScaffold(e.target,0);break;case"dismiss_helper":{const s=this.helpers.get(e.helperId);s&&(s.container.destroy(),this.helpers.delete(e.helperId),this.actorAt.delete(e.helperId));break}}}pose(e,t){const s=t/1e3;for(const[r,n]of[["pip",this.pip],...this.helpers.entries()]){const o=n.pose;o.moving=!1,o.lift=0,o.sx=1,o.sy=1,o.lean=0,o.look="fwd",o.mood=this.mood;const a=e&&e.actor===r?e:null,l=this.worldLayer.standingSpot(this.actorAt.get(r)??(r==="pip"?"forge":"dock"));if(o.x=l.x,o.y=l.y,!a){r!=="pip"&&(o.sy=.96);continue}const h=Ue(this.t,a.atMs,a.atMs+a.durationMs),c="target"in a?this.worldLayer.standingSpot(a.target):l;switch(a.kind){case"curtain_up":{o.lift=(1-Math.min(1,h/.5))**2*150,o.sy=h<.5?1.1:1-.25*st(Ue(h,.5,.75)),o.sx=1/o.sy;break}case"walk_to":{const u=this.walkFrom.get(r)??l,d=Math.min(.22,140/a.durationMs),f=h<d?0:Rn((h-d)/(1-d));if(o.x=Jt(u.x,c.x,f),o.y=Jt(u.y,c.y,f),o.moving=h>=d&&h<.98,o.face=c.x>=u.x?1:-1,h<d){const p=st(h/d);o.sy=1-.1*p,o.sx=1+.08*p,o.lean=-o.face*.12*p}else{const p=this.t/1e3*(this.mood==="lost"?16:11);o.lift=Math.abs(Math.sin(p))*3.5;const g=Math.cos(p*2);if(o.sy=1+.05*g,o.sx=1-.05*g,o.lean=o.face*.07,h>.86){const m=st((h-.86)/.14);o.lean=o.face*.16*m,o.sy=1-.06*m,o.sx=1+.05*m}}r==="pip"&&this._playing&&(this.footT+=s,this.footT>.19&&ji.plays("footstep",this.rate)&&(this.footT=0,this.sfx.play("footstep",{theme:this.theme,pan:Math.max(-.8,Math.min(.8,o.x/600))})));break}case"read":{const u=st(this.t/1e3%1.4/.25);o.lean=-.17+Math.sin(this.t/1e3*3)*.03-u*.05,o.sy=1-u*.03,o.face=this.facing(o,a.target);break}case"build":case"forge":{const u=a.kind==="build"?.28-a.intensity*.1:.34,d=this.t/1e3%u/u,f=d<.7?d/.7:1-(d-.7)/.3;if(o.lift=f*4,o.lean=d<.7?-.06*f:.12*(1-f),o.sy=d<.7?1+.04*f:1-.08*(1-f),o.sx=1/o.sy,"target"in a&&(o.face=this.facing(o,a.target)),r==="pip"&&this._playing&&!this.reducedMotion){this.hammerT+=s;const p=a.kind==="build"?.28-a.intensity*.1:.34;if(this.hammerT>p){this.hammerT=0,ji.plays("hammer",this.rate)&&this.sfx.play(a.kind==="build"?"hammer":"spark",{theme:this.theme,intensity:a.kind==="build"?a.intensity:.5});const g="target"in a?this.worldLayer.positionOf(a.target):this.worldLayer.positionOf("forge");g&&Math.random()<.7&&this.particles.burst(g.top.x+(Math.random()*24-12),g.top.y+10,2,[16766571,16774084],50,60)}}break}case"raise":o.look="up",o.sy=1+.05*st(h);break;case"search":o.look="up",o.lean=Math.sin(this.t/1e3*1.5)*.12;break;case"run_tests":o.look="up",o.lean=Math.sin(this.t/1e3*2)*.04;break;case"test_outcome":if(a.outcome==="fail"){const u=st(Ue(h,0,.5));o.lean=-.25*u,o.sy=1-.1*u,o.sx=1+.08*u}else o.lift=st(h)*14;break;case"spawn_gremlin":{const u=st(Ue(h,0,.5));o.lift=Math.sin(Math.PI*Ue(h,.05,.45))*12,o.lean=-.22*u,o.sx=1+.1*u,o.sy=1-.1*u,o.look="down",o.x=l.x-o.face*10*u;break}case"chase":{const u=this.gremlins.get(a.gremlinId),d=c,f=h*Math.PI*2*1.5,p=26,g=d.x+Math.cos(f)*p,m=d.y+Math.sin(f)*p*.5;u&&(u.x=g,u.y=m,u.panic=1);const _=f-1.1;o.x=d.x+Math.cos(_)*p,o.y=d.y+Math.sin(_)*p*.5,o.moving=!0,o.face=Math.cos(f)>Math.cos(_)?1:-1;const y=this.t/1e3*16;o.lift=Math.abs(Math.sin(y))*4,o.lean=o.face*.12;break}case"banish":{o.sy=1-.2*st(Ue(h,0,.4)),o.sx=1/o.sy;break}case"celebrate":{const u=(this.t-a.atMs)%1300/1300;if(u<.22){const d=Math.sin(Math.PI*u/.22);o.sy=1-.24*d,o.sx=1+.2*d}else if(u<.8){const d=(u-.22)/.58;o.lift=Math.sin(Math.PI*d)*32,o.sy=d<.5?1+.14*(1-d*2):1,o.sx=1/o.sy}else{const d=Math.sin(Math.PI*(u-.8)/.2);o.sy=1-.2*d,o.sx=1+.16*d}break}case"blocked_on_you":o.face=1,o.look="fwd",o.sy=1+.03*Math.sin(this.t/1e3*6),o.sx=1/o.sy;break;case"your_turn":o.sy=.86,o.sx=1.08;break;case"stumble":{const u=st(Ue(h,0,.7));o.lean=Math.sin(this.t/1e3*40)*.12*u,o.sy=1-.08*u,o.sx=1+.06*u;break}case"unverified_claim":{o.face=1,o.hiding=1;const u=this.claimGremlinId?this.gremlins.get(this.claimGremlinId):null;u&&(u.x=o.x-o.face*14,u.y=o.y-2,u.peek=1);break}case"curtain_down":o.lean=Math.sin(this.t/1e3*6)*.15,o.face=1;break}if(this.claimGremlinId&&a.kind!=="unverified_claim"){const u=this.gremlins.get(this.claimGremlinId);u&&(u.x=o.x-o.face*14,u.y=o.y-2)}n.container.zIndex=o.y/(Bo/2)+.6,r!=="pip"&&(o.mood="focused")}for(const r of this.gremlins.values())r.container.zIndex=r.y/(Bo/2)+.7}facing(e,t){const s=this.worldLayer.positionOf(t);return s&&s.ground.x<e.x?-1:1}worldState(e){for(const t of this.world.places)this.worldLayer.setGlow(t.id,0);if(e){if((e.kind==="read"||e.kind==="build"||e.kind==="chase"||e.kind==="raise")&&this.worldLayer.setGlow(e.target,e.kind==="read"?.5:1),e.kind==="build"){const t=Ue(this.t,e.atMs,e.atMs+e.durationMs);this.worldLayer.setScaffold(e.target,.85*Math.min(Ue(t,0,.12),1-Ue(t,.85,1))),this.worldLayer.setGrowth(e.target,(this.growth.get(e.target)??0)+Math.round((3+e.intensity*6)*Rn(t)))}if(e.kind==="raise"){const t=Ue(this.t,e.atMs,e.atMs+e.durationMs);this.worldLayer.positionOf(e.target)&&this.worldLayer.setGrowth(e.target,Math.round(-30*(1-lu(t))))}if(e.kind==="spawn_gremlin"){const t=this.gremlins.get(e.gremlinId);t&&(t.scale=Math.max(.01,lu(Ue(this.t,e.atMs,e.atMs+400))))}for(const t of this.world.places)t.kind==="beacon"&&this.worldLayer.lampOf(t.id)==="pass"&&this.t-this.lastPass>12e3&&this.worldLayer.setLamp(t.id,"idle")}}fitCamera(){this.camera.setZoomFactor(this.fitZoom()),this.baseZoom=this.fitZoom()}baseZoom=1;camTarget=null;overview=!1;userZoom=1;setOverview(e){this.overview=e,this.userZoom=1}zoomBy(e){this.userZoom=Math.max(.4,Math.min(3,this.userZoom*e))}cameraStep(e,t){const s={w:this.app.renderer.screen.width,h:this.app.renderer.screen.height},r=s.w<640,n=!e||e.kind==="curtain_up"||e.kind==="curtain_down"||e.kind==="celebrate",o=this.world.places.map(w=>K(w.gx+w.footprint/2,w.gy+w.footprint/2)),a=Math.min(...o.map(w=>w.x))-70,l=Math.max(...o.map(w=>w.x))+70,h=Math.min(...o.map(w=>w.y))-110,c=Math.max(...o.map(w=>w.y))+50,u={x:(a+l)/2,y:(h+c)/2},d=Math.max(.05,this.camera.scale),f=s.w/d/2,p=s.h/d/2,g=(w,T,k)=>T+f>k-f?(T+k)/2:Math.max(T+f,Math.min(k-f,w)),m=(w,T,k)=>T+p>k-p?(T+k)/2:Math.max(T+p,Math.min(k-p,w)),_=this.pip.drawn,y=this.pip.pose.moving?this.pip.pose.face*f*.18:0,x={x:_.x+y,y:_.y-24};if(n||r)this.camTarget=n?{x:u.x,y:u.y}:x;else{this.camTarget||(this.camTarget=x);const w=f*.28,T=p*.26,k=x.x-this.camTarget.x,E=x.y-this.camTarget.y;Math.abs(k)>w&&(this.camTarget.x+=k-Math.sign(k)*w),Math.abs(E)>T&&(this.camTarget.y+=E-Math.sign(E)*T)}const b=g(this.camTarget.x,a,l),v=m(this.camTarget.y,h,c);this.camera.follow(b,v,1),this.camera.setDrift(this.mood==="lost"),this.overview&&(this.camTarget={x:u.x,y:u.y},this.camera.follow(u.x,u.y,1)),this.camera.setZoomFactor((this.overview?this.fitZoom()*.96:this.zoomFor(e,s.h))*this.userZoom),this.camera.update(t,s.w,s.h)}zoomFor(e,t){const s=this.fitZoom();if(!e)return s;const r=Math.max(s,Math.min(1.7,Math.max(.95,t/430)));switch(e.kind){case"curtain_up":return s*Jt(1.08,1,Rn(Ue(this.t,e.atMs,e.atMs+e.durationMs)));case"curtain_down":return s*1.05;case"celebrate":return s*1.15;default:return r}}fitZoom(){const e=this.world.places.flatMap(l=>[K(l.gx,l.gy),K(l.gx+l.footprint,l.gy+l.footprint)]),t=e.map(l=>l.x),s=e.map(l=>l.y),r=Math.max(60,Math.max(...t)-Math.min(...t)+140),n=Math.max(60,Math.max(...s)-Math.min(...s)+150),o=this.app.renderer.screen.width,a=this.app.renderer.screen.height;return Math.min(o/(r*1.05),a/(n*1.05),2.2)}bubble(e){if(!e)return null;const t=this.pip.pose,s=this.camera.toScreen(t.x+16,t.y-t.lift-52);return e.kind==="read"||e.kind==="search"?{text:"…",color:4219274,screen:s}:e.kind==="spawn_gremlin"||this.mood==="lost"&&e.kind!=="celebrate"?{text:"?",color:14833484,screen:s}:e.kind==="celebrate"?{text:"!",color:2071139,screen:s}:e.kind==="blocked_on_you"?{text:"!",color:16758087,screen:s}:e.kind==="unverified_claim"?{text:"…",color:8215807,screen:s}:null}labels(e){const t=[],s=e&&"target"in e?e.target:null;for(const r of this.world.places){if(r.kind==="forge"||r.kind==="dock")continue;const n=r.id===s,o=r.kind==="beacon"?this.worldLayer.lampOf(r.id):"idle";if(!n&&o==="idle")continue;const a=this.worldLayer.positionOf(r.id);a&&t.push({text:r.label,screen:this.camera.toScreen(a.top.x,a.top.y-2),active:n})}return t}destroy(){this.amb.stop(),this.worldLayer.destroy(),this.stage.destroy({children:!0})}}const ke={id:"island",name:"Island",tagline:"A warm little island at golden hour.",fits:["cli-tool","library","unknown"],flagship:!0,sky:[2191498,1195610],terrain:"island",ground:{fill:6073960,fillLight:10740879,edge:9070154,edgeDark:6966328,sand:15915942},water:{ripple:16777215,rippleAlpha:.24},pathColor:16245940,labelColor:1592880,palettes:[{top:16310456,left:15382917,right:13605734,roof:15495007,roofD:12735050,win:9067068},{top:14478328,left:11455462,right:9153999,roof:5934020,roofD:4616351,win:4219274},{top:13625820,left:9226664,right:6464387,roof:3122570,roofD:2393199,win:3106389},{top:16507860,left:15908774,right:14261124,roof:14248828,roofD:11554657,win:8014418},{top:16774086,left:16112010,right:14268778,roof:14916398,roofD:12220959,win:8018476}],beacon:{top:16514040,left:15855592,right:14276043,roof:14833484,roofD:12141627,win:3820122,lamp:{idle:16766571,scan:16777215,fail:16734798,pass:6287526}},archive:{top:15327743,left:12891376,right:10916824,roof:9073359,roofD:7231664,win:5062278},forge:{top:7041664,left:4937059,right:3621201,roof:10265519,roofD:7041664,win:16758087,ember:16751164},dock:{deck:11569754,post:8018490,vessel:15855592},prop:"tree",propColors:[4168284,6472819,9067066],gremlin:{body:8215807,eye:1773616},pip:{body:16751164,bodyLight:16765566,belly:16774620,ear:14712620,cheek:16739930,ink:2759959},mood:{curious:16769899,focused:8177919,lost:16743273,happy:6287526,uneasy:16754250},vignette:332832},Bs={...ke,id:"orbit",name:"Orbit",tagline:"A quiet station turning above a blue planet.",fits:["backend-api","infra-devops","systems"],flagship:!0,sky:[725030,1780309],terrain:"platform",ground:{fill:3885675,fillLight:7045032,edge:2568522,edgeDark:1712695,sand:9082808},water:{ripple:10473727,rippleAlpha:.18},pathColor:13624319,labelColor:14411775,palettes:[{top:15266303,left:12571890,right:9678036,roof:6280191,roofD:3844566,win:8188927},{top:16054011,left:14015464,right:11187143,roof:11967743,roofD:9401062,win:13481983},{top:15138806,left:12185820,right:9423800,roof:6287526,roofD:4177795,win:11075542}],beacon:{top:16777215,left:15133685,right:12174038,roof:6280191,roofD:3844566,win:8188927,lamp:{idle:10473727,scan:16777215,fail:16734798,pass:6287526}},forge:{top:10134712,left:7239820,right:5133930,roof:12634328,roofD:9081768,win:8188927,ember:8188927},dock:{deck:7239820,post:5133930,vessel:16777215},prop:"antenna",propColors:[12174038,8188927,5133930],gremlin:{body:16734878,eye:1773616},vignette:198162},mr={...ke,id:"metropolis",name:"Metropolis",tagline:"A warm night city, lights just coming on.",fits:["web-frontend","monorepo"],flagship:!0,sky:[1708080,3874127],terrain:"block",ground:{fill:3814736,fillLight:5919864,edge:2762304,edgeDark:1709872,sand:6972296},water:{ripple:16758087,rippleAlpha:.1},pathColor:16767392,labelColor:16771527,palettes:[{top:16769730,left:15907216,right:13208422,roof:16743273,roofD:13916746,win:16766571},{top:14933247,left:12036592,right:9075664,roof:11967743,roofD:9401062,win:16771496},{top:14087423,left:10147568,right:7318220,roof:6280191,roofD:3844566,win:16774084},{top:16770799,left:16234188,right:13929126,roof:16740261,roofD:14241919,win:16766571}],beacon:{top:16119285,left:14277081,right:11579568,roof:16740261,roofD:14241919,win:3355443,lamp:{idle:16758087,scan:16777215,fail:16734798,pass:6287526}},forge:{top:8024976,left:5656684,right:3946572,roof:10656699,roofD:7301256,win:16758087,ember:16758087},dock:{deck:5656684,post:3946572,vessel:16766571},prop:"lamp",propColors:[16766571,16774084,3946572],gremlin:{body:6287526,eye:993820},vignette:525332},Ab={...ke,id:"harbour",name:"Harbour",tagline:"Fog lifting off a working port.",fits:["backend-api","infra-devops"],flagship:!1,sky:[2841971,995135],ground:{fill:8032106,fillLight:11124115,edge:6052434,edgeDark:4012853,sand:13222829},water:{ripple:14283263,rippleAlpha:.3},pathColor:14275261,labelColor:2046506,palettes:[{top:16051424,left:14273459,right:11772806,roof:4090762,roofD:2969446,win:5917242},{top:16247268,left:14925746,right:12556423,roof:13195850,roofD:10503482,win:7027248},{top:15331298,left:12898743,right:10201996,roof:5209950,roofD:3825990,win:3099192}],dock:{deck:9203532,post:5916210,vessel:15223612},prop:"lamp",propColors:[16767392,16773590,4868682],vignette:398879},Rb={...Bs,id:"observatory",name:"Observatory",tagline:"A mountaintop under a hard, clear sky.",fits:["data-ml","systems"],flagship:!1,sky:[659504,2367562],terrain:"block",ground:{fill:4867942,fillLight:7236495,edge:3091781,edgeDark:1907502,sand:9275818},water:{ripple:16777215,rippleAlpha:.22},pathColor:14276336,labelColor:15394815,palettes:[{top:15855615,left:13617646,right:10722761,roof:11967743,roofD:9401062,win:16773544},{top:15135743,left:12375795,right:9415113,roof:6280191,roofD:3844566,win:16773544}],beacon:{...Bs.beacon,roof:11967743,roofD:9401062},prop:"antenna",propColors:[13617646,16773544,3091781],vignette:329756},Bb={...ke,id:"greenhouse",name:"Greenhouse",tagline:"Glass, leaves and warm afternoon light.",fits:["data-ml","library"],flagship:!1,sky:[9423280,4098938],ground:{fill:8175466,fillLight:11985823,edge:8020552,edgeDark:5916212,sand:15129779},water:{ripple:16777215,rippleAlpha:.18},pathColor:15985874,labelColor:1985843,palettes:[{top:15794166,left:13496029,right:10735033,roof:8115107,roofD:5220732,win:14286832},{top:16775654,left:15918008,right:13483407,roof:15774556,roofD:13077307,win:8018476},{top:16183551,left:14470131,right:11903953,roof:11832575,roofD:9070294,win:5062278}],prop:"tree",propColors:[5223530,9429132,8018490],vignette:731676},Bg={...ke,id:"workshop",name:"Workshop",tagline:"A village of makers, sawdust in the air.",fits:["cli-tool","library","systems"],flagship:!1,sky:[14264428,9064238],ground:{fill:10404970,fillLight:13624221,edge:9067066,edgeDark:6701098,sand:15323811},water:{ripple:16771527,rippleAlpha:.2},pathColor:15916982,labelColor:4860432,palettes:[{top:16245699,left:14727562,right:12160867,roof:10902330,roofD:8340265,win:16765566},{top:15919320,left:14206894,right:11574144,roof:6057866,roofD:4543594,win:16765566},{top:16508889,left:15712936,right:13343362,roof:13190970,roofD:10499372,win:16765566}],forge:{...ke.forge,ember:16758087},prop:"tree",propColors:[5940060,8832366,8014378],vignette:2757640},Ib={...mr,id:"arcade",name:"Arcade",tagline:"Neon rain on a late-night strip.",fits:["game","web-frontend"],flagship:!1,sky:[1181734,2756426],ground:{fill:2366012,fillLight:3811932,edge:1445930,edgeDark:788506,sand:5913228},water:{ripple:16732120,rippleAlpha:.12},pathColor:8188927,labelColor:16773375,palettes:[{top:16766710,left:16748512,right:13916856,roof:8188927,roofD:3848406,win:8188927},{top:14284543,left:9430271,right:5944532,roof:16732120,roofD:12987048,win:16773227},{top:16774604,left:16769899,right:14071882,roof:11967743,roofD:9401062,win:16732120}],beacon:{...mr.beacon,roof:16732120,roofD:12987048,lamp:{idle:8188927,scan:16777215,fail:16734798,pass:6287526}},gremlin:{body:16773227,eye:2759173},prop:"lamp",propColors:[16732120,16766710,1445930],vignette:328206},Ig={...ke,id:"kingdom",name:"Kingdom",tagline:"Stone walls, banners, a river below.",fits:["monorepo","backend-api","unknown"],flagship:!1,sky:[8369113,3894937],ground:{fill:7319134,fillLight:10933647,edge:8354410,edgeDark:6117709,sand:14209725},water:{ripple:16777215,rippleAlpha:.22},pathColor:13616813,labelColor:2828834,palettes:[{top:15855075,left:13880767,right:11248791,roof:4153231,roofD:3032683,win:5917242},{top:15855075,left:13880767,right:11248791,roof:11024954,roofD:8465452,win:5917242},{top:15855075,left:13880767,right:11248791,roof:4882258,roofD:3563581,win:5917242}],beacon:{...ke.beacon,top:15328470,left:13617334,right:10722701,roof:4153231,roofD:3032683},prop:"tree",propColors:[4165458,7323498,5916212],vignette:858662},Gb={...ke,id:"outpost",name:"Outpost",tagline:"A desert station at dusk, dust in the light.",fits:["infra-devops","cli-tool","systems"],flagship:!1,sky:[15770458,7024458],ground:{fill:14267502,fillLight:15848346,edge:10842175,edgeDark:8016429,sand:15980451},water:{ripple:16769200,rippleAlpha:.14},pathColor:16509124,labelColor:4860432,palettes:[{top:16509392,left:15255450,right:12885875,roof:14246463,roofD:11094061,win:5913120},{top:16182752,left:14667960,right:12101261,roof:3116938,roofD:2321255,win:5913120}],prop:"antenna",propColors:[12885875,16769200,8016429],vignette:2756372},Db={...ke,id:"snowfield",name:"Snowfield",tagline:"Blue hour, fresh snow, chimney smoke.",fits:["library","docs-content","unknown"],flagship:!1,sky:[10470374,4153231],ground:{fill:15397370,fillLight:16777215,edge:9346485,edgeDark:6714764,sand:14082802},water:{ripple:16777215,rippleAlpha:.3},pathColor:12833768,labelColor:2767442,palettes:[{top:16183526,left:14470070,right:11969164,roof:12077626,roofD:9188648,win:16765566},{top:15791352,left:13358560,right:10661564,roof:4090762,roofD:2969446,win:16765566},{top:15661040,left:13032912,right:10467498,roof:4882258,roofD:3563581,win:16765566}],prop:"tree",propColors:[3107658,5216874,5916212],vignette:858666},Fb={...ke,id:"canopy",name:"Canopy",tagline:"Treehouses strung through an old forest.",fits:["docs-content","data-ml","library"],flagship:!1,sky:[6266731,2050611],ground:{fill:5214031,fillLight:8372074,edge:5916212,edgeDark:4075556,sand:11050866},water:{ripple:14218704,rippleAlpha:.18},pathColor:14076314,labelColor:15398879,palettes:[{top:15918793,left:14271643,right:11770482,roof:6983487,roofD:5139245,win:16765566},{top:16181976,left:14927782,right:12558206,roof:12085818,roofD:9195306,win:16765566}],prop:"tree",propColors:[3111487,6075226,4863268],vignette:398860},Ob={...ke,id:"lagoon",name:"Lagoon",tagline:"Turquoise shallows and white sand at noon.",fits:["web-frontend","library","docs-content"],flagship:!1,sky:[8378351,2068408],ground:{fill:10147978,fillLight:13890493,edge:13218430,edgeDark:10719327,sand:16774102},water:{ripple:16777215,rippleAlpha:.36},pathColor:16774620,labelColor:1002074,palettes:[{top:16777215,left:15790056,right:13618628,roof:3126217,roofD:2133923,win:3107450},{top:16774886,left:16769464,right:14728332,roof:16747610,roofD:14051902,win:8014380},{top:15925240,left:13235165,right:10473913,roof:4177818,roofD:2788464,win:2054730}],prop:"tree",propColors:[4169564,9166970,10254916],vignette:536640},Lb={...ke,id:"volcano",name:"Volcano",tagline:"Black rock, red sky, light from below.",fits:["systems","infra-devops","game"],flagship:!1,sky:[5904922,1705992],ground:{fill:3813167,fillLight:5917256,edge:2365978,edgeDark:1182218,sand:6969942},water:{ripple:16743226,rippleAlpha:.22},pathColor:16751194,labelColor:16769479,palettes:[{top:4866114,left:3813940,right:2761766,roof:16739133,roofD:12864036,win:16758087},{top:5917266,left:4602432,right:3353135,roof:16758087,roofD:14257186,win:16739133}],beacon:{...ke.beacon,top:3813940,left:2761766,right:2038300,roof:16739133,roofD:12864036,lamp:{idle:16758087,scan:16777215,fail:16734798,pass:6287526}},forge:{...ke.forge,ember:16739133},dock:{deck:4602432,post:2761766,vessel:16758087},prop:"antenna",propColors:[5917256,16739133,2365978],gremlin:{body:8188927,eye:666160},vignette:655874},Ub={...Bs,id:"cloudtop",name:"Cloudtop",tagline:"A floating town above a sea of cloud.",fits:["web-frontend","mobile","docs-content"],flagship:!1,sky:[13625087,8368358],terrain:"platform",ground:{fill:15988475,fillLight:16777215,edge:14147822,edgeDark:12043480,sand:16777215},water:{ripple:16777215,rippleAlpha:.5},pathColor:16771496,labelColor:2767442,palettes:[{top:16777215,left:15791354,right:13621478,roof:16748448,roofD:14051964,win:16765566},{top:16777215,left:15791354,right:13621478,roof:8177919,roofD:5216982,win:16765566},{top:16777215,left:15791354,right:13621478,roof:11967743,roofD:9401062,win:16765566}],beacon:{...Bs.beacon,roof:16748448,roofD:14051964,lamp:{idle:16765566,scan:16777215,fail:16734798,pass:6287526}},dock:{deck:15791354,post:12043480,vessel:16748448},prop:"tree",propColors:[9426848,13168832,12043480],vignette:4876954},Nb={...ke,id:"reef",name:"Reef",tagline:"Underwater, where the light comes in ribbons.",fits:["data-ml","game","library"],flagship:!1,sky:[1802144,404032],terrain:"island",ground:{fill:13220234,fillLight:15326384,edge:9075290,edgeDark:5918266,sand:14930854},water:{ripple:10479871,rippleAlpha:.3},pathColor:15984579,labelColor:15137791,palettes:[{top:16767462,left:16752320,right:14052498,roof:16740261,roofD:14241919,win:8006218},{top:16773577,left:16765566,right:14265690,roof:16747610,roofD:14051902,win:8014380},{top:14286838,left:10481880,right:7129520,roof:4177818,roofD:2788464,win:2054730}],prop:"antenna",propColors:[16752320,10481880,9075290],gremlin:{body:1773616,eye:10479871},vignette:136224},Hb={...Bg,id:"bazaar",name:"Bazaar",tagline:"Ochre walls, striped awnings, late light.",fits:["monorepo","web-frontend","backend-api"],flagship:!1,sky:[15909498,11033146],ground:{fill:14200945,fillLight:15849120,edge:9067066,edgeDark:6701098,sand:15981742},water:{ripple:16773577,rippleAlpha:.16},pathColor:16773577,labelColor:4860432,palettes:[{top:16640463,left:15386528,right:12885875,roof:14240570,roofD:11024940,win:5913120},{top:16640463,left:15386528,right:12885875,roof:3116938,roofD:2321255,win:5913120},{top:16640463,left:15386528,right:12885875,roof:4153231,roofD:3032683,win:5913120},{top:16640463,left:15386528,right:12885875,roof:14916398,roofD:12220959,win:5913120}],prop:"lamp",propColors:[16765566,16773577,6701098],vignette:2757640},zb={...Ig,id:"monastery",name:"Monastery",tagline:"Mist on the mountain, a bell somewhere.",fits:["docs-content","library","systems"],flagship:!1,sky:[12110276,5204842],ground:{fill:8363898,fillLight:11585958,edge:6975334,edgeDark:4869703,sand:13093309},water:{ripple:16777215,rippleAlpha:.2},pathColor:14275520,labelColor:2042408,palettes:[{top:15855075,left:13880767,right:11248791,roof:5917242,roofD:4076072,win:16765566},{top:15855075,left:13880767,right:11248791,roof:9058858,roofD:6695454,win:16765566}],prop:"tree",propColors:[4157258,6986346,4863268],vignette:1055256},Wb={...Bs,id:"moonbase",name:"Moonbase",tagline:"Grey dust, black sky, one blue marble.",fits:["systems","infra-devops","data-ml"],flagship:!1,sky:[329228,724248],terrain:"platform",ground:{fill:9276821,fillLight:12105920,edge:6184550,edgeDark:3816e3,sand:11053232},water:{ripple:16777215,rippleAlpha:.28},pathColor:14474468,labelColor:15790326,palettes:[{top:16185082,left:14474468,right:11842750,roof:8188927,roofD:3848406,win:16765566},{top:16185082,left:14474468,right:11842750,roof:16758087,roofD:14257186,win:8188927}],prop:"antenna",propColors:[12105920,8188927,3816e3],vignette:0},$b={...mr,id:"lanterns",name:"Lanterns",tagline:"A night festival, paper light everywhere.",fits:["web-frontend","game","unknown"],flagship:!1,sky:[1706542,3805232],terrain:"block",ground:{fill:3811908,fillLight:5915750,edge:2365998,edgeDark:1314332,sand:6969976},water:{ripple:16751194,rippleAlpha:.14},pathColor:16767392,labelColor:16771527,palettes:[{top:16771535,left:15910816,right:13211758,roof:14240570,roofD:11024940,win:16765566},{top:16180223,left:14268402,right:11177161,roof:16740261,roofD:14241919,win:16765566},{top:16774870,left:16769952,right:14268778,roof:14916398,roofD:12220959,win:16751194}],prop:"lamp",propColors:[16751194,16769952,2365998],vignette:656404},Ct=[ke,Bs,mr,Ab,Rb,Bb,Bg,Ib,Ig,Gb,Db,Fb,Ob,Lb,Ub,Nb,Hb,zb,Wb,$b],sr=i=>Ct.find(e=>e.id===i)??ke;function Fo(i,e=0){const t=i?.kinds?.length?i.kinds:["unknown"],s=l=>t.reduce((h,c,u)=>h+(l.fits.includes(c)?(t.length-u)*2:0),0)+(l.flagship?1:0),r=Ct.filter(l=>s(l)>1),n=r.length>=3?r:Ct;let o=e>>>0||1;const a=()=>(o^=o<<13,o^=o>>>17,o^=o<<5,(o>>>0)%1e3/1e3);return[...n].map(l=>({s:l,k:s(l)+a()*.5})).sort((l,h)=>h.k-l.k).map(({s:l})=>l)}class ch{constructor(e){this.payload=e}mode="replay";onReady(e){queueMicrotask(()=>e(this.payload))}onBeats(){}}class Vb{constructor(e=""){this.base=e,this.connect()}mode="live";readyCb=null;beatsCb=null;signalCb=null;pending=null;async connect(){const e=await(await fetch(`${this.base}/api/scene`)).json(),t={world:e.world,events:e.events,beats:e.beats,repoId:e.repoId};this.readyCb?this.readyCb(t):this.pending=t,e.signal&&this.signalCb?.(e.signal);const s=()=>{const r=/^https?:/.test(this.base)?this.base:location.origin+this.base,n=new WebSocket(`${r.replace(/^http/,"ws")}/live`);n.onmessage=o=>{const a=JSON.parse(String(o.data));a.type==="beats"&&a.beats&&this.beatsCb?.(a.beats,a.events??[]),a.type==="signal"&&a.state&&this.signalCb?.(a.state)},n.onclose=()=>{this.signalCb?.("lost"),setTimeout(s,2e3)}};s()}onReady(e){if(this.readyCb=e,this.pending){const t=this.pending;this.pending=null,e(t)}}onBeats(e){this.beatsCb=e}onSignal(e){this.signalCb=e}}class jb{constructor(e,t){this.host=e,this.session=t,addEventListener("message",s=>{const r=s.data;if(r?.type==="scene"&&r.payload){const n=r.payload,o={world:n.world,events:n.events,beats:n.beats,repoId:n.title?`${n.repoId} — ${n.title}`:n.repoId};this.readyCb?this.readyCb(o):this.pending=o,n.signal&&this.signalCb?.(n.signal)}r?.type==="beats"&&r.beats&&this.beatsCb?.(r.beats,r.events??[]),r?.type==="signal"&&r.state&&this.signalCb?.(r.state)}),e.postMessage(t?{type:"replay",id:t}:{type:"scene"})}mode="live";readyCb=null;beatsCb=null;signalCb=null;pending=null;onReady(e){if(this.readyCb=e,this.pending){const t=this.pending;this.pending=null,e(t)}}onBeats(e){this.beatsCb=e}onSignal(e){this.signalCb=e}}async function Xb(i,e=""){const t=await fetch(`${e}/api/replay/${encodeURIComponent(i)}`);if(!t.ok)throw new Error(`session not found: ${i}`);const s=await t.json();return new ch({world:s.world,events:s.events,beats:s.beats,repoId:s.title?`${s.repoId} — ${s.title}`:s.repoId})}function qb(i,e,t){const s=n=>e.places.find(o=>o.id===n)?.label??n.replace(/^p:/,""),r=i.actor==="pip"?"Pip":t?`A helper (${t})`:"A helper";switch(i.kind){case"curtain_up":return`${i.repoId}. Every building on this stage is a file in the repo.`;case"curtain_down":return i.verified?"Curtain. Every claim in this session was backed by a passing test.":"Curtain. Something was called done without a passing test to show for it.";case"walk_to":return`${r} heads to ${s(i.target)}.`;case"read":return`${r} reads ${s(i.target)}.`;case"build":return`${r} is working on ${s(i.target)}${i.intensity>.6?" — a big change":""}.`;case"raise":return`A new file rises: ${s(i.target)}.`;case"forge":return`${r} runs a command at the forge.`;case"search":return i.scope==="web"?`${r} looks something up on the web.`:`${r} searches the repo.`;case"run_tests":return`Running the tests at ${s(i.target)}…`;case"test_outcome":return i.outcome==="pass"?`${i.passed} tests pass.`:i.outcome==="fail"?`${i.failed} test${i.failed===1?"":"s"} fail${i.failed===1?"s":""}.`:"Tests ran — the runner didn't say how many.";case"spawn_gremlin":return`A bug gremlin pops out of ${s(i.target)}.`;case"chase":return`${r} chases the gremlin around ${s(i.target)}.`;case"banish":return"Caught. The gremlin is gone.";case"summon_helper":return`A helper arrives at the dock${i.label?` to ${i.label.toLowerCase()}`:""}.`;case"dismiss_helper":return i.ok?"The helper reports back and leaves.":"The helper leaves without finishing.";case"blocked_on_you":return i.reason==="permission"?"Pip needs your permission to continue.":"Pip has a question for you.";case"your_turn":return"Pip is done for now. Your turn.";case"stumble":return i.retrying?"Something went wrong. Pip tries again.":"Something went wrong.";case"celebrate":return"All green. Pip celebrates.";case"idle":return"";case"unverified_claim":return"Pip says it's done — but no test has passed since the last change. Something's hiding."}}function Yb(i){if(!i.length)return[{label:"Scene",fromMs:0,toMs:0}];const e=Math.max(...i.map(l=>l.atMs+l.durationMs));let t=0,s=!1;const r=[];for(const l of i){let h=null;switch(l.kind){case"curtain_up":h="Arrive";break;case"curtain_down":h="Curtain";break;case"read":case"search":h=t?"Fix":s?"Explore":"Arrive",s=!0;break;case"build":case"raise":case"forge":h=t?"Fix":"Build";break;case"run_tests":h=t?"Fix":"Build";break;case"test_outcome":{h=l.outcome==="fail"?"Trouble":"Finale";const c=r.at(-1);c&&c.kind==="run_tests"&&(c.phase=h);break}case"spawn_gremlin":t++,h="Trouble";break;case"chase":h="Fix";break;case"banish":t=Math.max(0,t-1),h="Finale";break;case"celebrate":h="Finale";break;case"summon_helper":case"dismiss_helper":h="Help";break;case"blocked_on_you":h="Waiting";break;case"unverified_claim":h="Hmm";break;case"stumble":h="Trouble";break;case"your_turn":case"walk_to":case"idle":h=null;break}h&&r.push({phase:h,at:l.atMs,end:l.atMs+l.durationMs,kind:l.kind})}const n=[];for(const l of r){const h=n.at(-1);h&&h.phase===l.phase?h.to=Math.max(h.to,l.end):n.push({phase:l.phase,from:h?h.to:0,to:l.end})}n.length&&(n[0].from=0,n.at(-1).to=e);const o=2200;for(let l=n.length-1;l>=0&&n.length>1;l--){const h=n[l];h.to-h.from>=o||(l>0?(n[l-1].to=h.to,n.splice(l,1)):(n[1].from=h.from,n.splice(0,1)))}const a=n.at(-1);return a&&a.phase==="Curtain"&&n.length>1&&(n[n.length-2].to=a.to,n.pop()),n.map(l=>({label:l.phase==="Curtain"?"Finale":l.phase,fromMs:l.from,toMs:l.to}))}const Dn=i=>{const e=Math.floor(i/1e3);return`${Math.floor(e/60)}:${String(e%60).padStart(2,"0")}`},Fn=i=>`#${i.toString(16).padStart(6,"0")}`,$=(i,e,t)=>{const s=document.createElement(i);return e&&(s.className=e),t!==void 0&&(s.innerHTML=t),s},Kb='<svg viewBox="0 0 16 16" fill="currentColor"><path d="M4.5 2.8v10.4a.6.6 0 0 0 .9.5l8.3-5.2a.6.6 0 0 0 0-1L5.4 2.3a.6.6 0 0 0-.9.5z"/></svg>',pu='<svg viewBox="0 0 16 16" fill="currentColor"><rect x="3.5" y="3" width="3" height="10" rx="1"/><rect x="9.5" y="3" width="3" height="10" rx="1"/></svg>',Zb='<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 8.5l3.2 3L13 4.5"/></svg>';class Qb{constructor(e,t){this.h=t,this.root=$("div","wrap");const s=$("header"),r=$("div","brand",'<a class="eyebrow" href="https://agenttheatre.dev/" title="Back to agenttheatre.dev">← Agent Theatre</a><h1 id="title">Loading…</h1>'),n=$("div","toolbar");this.setBtn=$("button","btn ghost","Set"),this.setBtn.type="button",this.setBtn.onclick=()=>this.showPicker(!0),this.muteBtn=$("button","btn ghost","Effects on"),this.muteBtn.type="button",this.muteBtn.title="Sound effects",this.muteBtn.onclick=()=>t.onMute(),this.ambBtn=$("button","btn ghost","Ambience on"),this.ambBtn.type="button",this.ambBtn.title="Background sound",this.ambBtn.onclick=()=>t.onAmbience(),this.overviewBtn=$("button","btn ghost","Whole repo"),this.overviewBtn.type="button",this.overviewBtn.title="Pull back to see every building (follow camera off)",this.overviewBtn.onclick=()=>{this.overviewOn=!this.overviewOn,this.overviewBtn.textContent=this.overviewOn?"Follow":"Whole repo",this.overviewBtn.setAttribute("aria-pressed",String(this.overviewOn)),t.onOverview(this.overviewOn)},this.exportBtn=$("button","btn ghost","Export clip"),this.exportBtn.type="button",this.exportBtn.title="Record the stage (with sound) to a .webm you can share",this.exportBtn.onclick=()=>t.onExport(),n.append(this.setBtn,this.overviewBtn,this.muteBtn,this.ambBtn,this.exportBtn),this.nudge=$("div","nudge","Sound is off — turn on effects and ambience to hear the stage"),this.nudge.hidden=!0,n.append(this.nudge),s.append(r,n);const o=$("div","grid"),a=$("div","stage-col");this.stageEl=$("div","stage"),this.overlay=$("div","overlay"),this.bubbleEl=$("div","bubble"),this.bubbleEl.hidden=!0,this.overlay.append(this.bubbleEl),this.signal=$("div","signal","<i></i><span>live</span>"),this.signal.hidden=!0,this.chip=$("div","chip ok"),this.chip.hidden=!0,this.caption=$("div","caption","<span></span>"),this.title=$("div","card",'<div class="small">Agent Theatre</div><div class="big" id="titleBig">…</div>'),this.end=$("div","card",'<div class="big">Every agent run has a story.</div><div class="small">Agent Theatre</div>'),this.end.style.opacity="0",this.picker=$("div","picker"),this.picker.hidden=!0,this.waiting=$("div","waiting",'<div class="wt"><b></b><span></span></div><button type="button" class="go"></button>'),this.waiting.hidden=!0,this.vscode=globalThis.__vsapi??null,this.waiting.querySelector(".go").onclick=()=>{this.vscode?this.vscode.postMessage({type:"focus-agent"}):this.notify()},this.prompt=$("form","prompt",'<input type="text" placeholder="" autocomplete="off" spellcheck="false"><button type="submit">Send</button><span class="st"></span>'),this.prompt.hidden=!0,this.prompt.addEventListener("submit",f=>{f.preventDefault();const p=this.prompt.querySelector("input"),g=this.prompt.querySelector(".st"),m=p.value.trim();m&&(g.textContent="sending…",t.onPrompt(m).then(_=>{g.textContent=_,p.value=""}))}),this.stageEl.append($("div","vignette"),this.overlay,this.signal,this.chip,this.caption,this.title,this.end,this.picker,this.waiting,this.prompt),this.stageEl.addEventListener("wheel",f=>{!f.ctrlKey&&Math.abs(f.deltaY)<1||(f.preventDefault(),t.onZoom(Math.exp(-f.deltaY*.0015)))},{passive:!1});const l=$("div","controls");this.playBtn=$("button","btn",`${pu}<span>Pause</span>`),this.playBtn.type="button",this.playBtn.onclick=()=>t.onPlayPause();const h=$("div","track");this.actsEl=$("div","acts"),this.labelsEl=$("div","actlabels"),this.head=$("div","head"),h.append(this.actsEl,this.labelsEl,this.head),h.addEventListener("pointerdown",f=>{const p=this.actsEl.getBoundingClientRect(),g=(f.clientX-p.left)/p.width;t.onSeek(g*this.durationMs)}),this.time=$("div","time","0:00 / 0:00"),this.rateBtn=$("button","btn ghost","1×"),this.rateBtn.type="button",this.rateBtn.onclick=()=>t.onRate(),l.append(this.playBtn,h,this.time,this.rateBtn),a.append(this.stageEl,l);const c=$("aside"),u=$("section","panel",'<h2>Event log</h2><p class="sub">Every scene is driven by one of these agent events. Tap one to jump there.</p>');this.logEl=$("ul","log"),u.append(this.logEl);const d=$("section","panel",`<h2>How to read the stage</h2><p class="sub">Buildings are files, districts are folders, beacons are test suites. Gremlins are failing tests. The lead character is the agent; its light shows its mood. Helpers are subagents. If the agent says it's done without a passing test, something hides behind it.</p>`);c.append(u,d),o.append(a,c),this.root.append(s,o,$("p","note","Everything you see is generated locally from agent events. No code, prompts or file contents are shown or sent anywhere.")),e.append(this.root)}root;stageEl;nudge;showNudge(){this.nudge.hidden=!1}showShare(e){const t=URL.createObjectURL(e.blob),s=new File([e.blob],e.name,{type:e.blob.type}),r=typeof navigator.share=="function"&&typeof navigator.canShare=="function"&&navigator.canShare({files:[s]}),n=$("div","share",`<div class="sh-head"><b>Your clip is ready</b><span>${(e.blob.size/1048576).toFixed(1)} MB · ${e.name.split(".").pop()}</span></div>
956
956
  <div class="sh-row"><a class="btn primary" download="${e.name}" href="${t}">Download</a>${r?'<button type="button" class="btn ghost" data-act="share">Share…</button>':""}<a class="btn ghost" target="_blank" rel="noopener" href="https://x.com/intent/post?text=${encodeURIComponent(e.caption)}">Post on X</a><a class="btn ghost" target="_blank" rel="noopener" href="https://www.linkedin.com/feed/?shareActive=true&text=${encodeURIComponent(e.caption)}">Post on LinkedIn</a><button type="button" class="btn ghost" data-act="caption">Copy caption</button><button type="button" class="btn ghost" data-act="close">Close</button></div>
957
- <p class="sh-note">Posts open with the caption; attach the downloaded clip there.</p>`);n.addEventListener("click",o=>{const a=o.target.closest("[data-act]")?.getAttribute("data-act");a==="share"&&navigator.share({files:[s],title:"Agent Theatre",text:e.caption}).catch(()=>{}),a==="caption"&&navigator.clipboard?.writeText(e.caption),a==="close"&&(n.remove(),setTimeout(()=>URL.revokeObjectURL(t),1e3))}),this.stageEl.append(n)}nudgeSeen(){this.nudge.hidden=!0;try{localStorage.setItem("at:nudged","1")}catch{}}overviewBtn;overviewOn=!1;exportBtn;prompt;waiting;vscode;notifiedFor="";overlay;caption;chip;signal;title;end;picker;playBtn;rateBtn;muteBtn;ambBtn;setBtn;actsEl;labelsEl;head;time;logEl;acts=[];actBtns=[];actLabels=[];logBtns=[];lastCaption="";lastBeatId="";lastAct=-1;lastEv=-2;tagPool=[];bubbleEl;durationMs=0;repoId="";promptEnabled=!1;setTitle(e,t){const s=e.replace(/\/+$/,"").split(/[/\\]/).filter(Boolean).pop()??e,r=this.root.querySelector("#title");r.textContent=s,r.title=e,this.root.querySelector("#titleBig").textContent=t??s}setMuted(e){this.muteBtn.textContent=e?"Effects off":"Effects on",this.muteBtn.setAttribute("aria-pressed",String(!e))}setAmbience(e){this.ambBtn.textContent=e?"Ambience on":"Ambience off",this.ambBtn.setAttribute("aria-pressed",String(e))}setRate(e){this.rateBtn.textContent=`${e}×`}loadTimeline(e,t,s){this.durationMs=e.length?Math.max(...e.map(n=>n.atMs+n.durationMs)):0,this.acts=Yb(e),this.actsEl.innerHTML="",this.labelsEl.innerHTML="",this.actBtns=[],this.actLabels=[];for(const n of this.acts){const o=(n.toMs-n.fromMs)/Math.max(1,this.durationMs)*100,a=$("button");a.type="button",a.style.flex=`0 0 calc(${o}% - 3px)`,a.setAttribute("aria-label",`Jump to ${n.label}`),a.onclick=h=>{h.stopPropagation(),this.h.onSeek(n.fromMs+1)};const l=$("span","",n.label);l.style.flex=`0 0 calc(${o}% - 3px)`,this.actsEl.append(a),this.labelsEl.append(l),this.actBtns.push(a),this.actLabels.push(l)}this.logEl.innerHTML="",this.logBtns=[],t[0]?.ts;const r=n=>e.find(o=>o.sourceEventIds.includes(n));for(const n of t){if(n.kind==="session_start"||n.kind==="session_end")continue;const o=r(n.id);if(!o)continue;const a=$("li"),l=$("button");l.type="button";const[h,c]=Jb(n),u=n.kind==="test_result"&&!n.ok;l.innerHTML=`<time>${Dn(o.atMs)}</time><span class="dot k-${n.kind}${u?" fail":""}"></span><span class="ev"><b>${mu(h)}</b><code>${mu(c)}</code></span>`,l.onclick=()=>this.h.onSeek(o.atMs+1),a.append(l),this.logEl.append(a),this.logBtns.push({btn:l,ms:o.atMs})}}previews=new Map;get pickerOpen(){return!this.picker.hidden}profile;leadName="Pip";showAll=!1;showPicker(e,t){if(this.picker.hidden=!e,!e)return;this.picker.innerHTML="";const s=this.profile?.kinds?.[0],r=s&&s!=="unknown"?{"web-frontend":"a web app","backend-api":"a backend","cli-tool":"a CLI",library:"a library","data-ml":"data & ML work",mobile:"a mobile app",game:"a game","infra-devops":"infrastructure","docs-content":"documentation",monorepo:"a monorepo",systems:"systems code"}[s]:null,n=Fo(this.profile,e1(this.repoId)).slice(0,3),o=this.showAll?[...Ct]:n;this.picker.append($("h3","",this.showAll?"All sets":"Choose your set"),$("p","",r&&!this.showAll?`This looks like ${r}${this.profile?.languages?.[0]?` in ${this.profile.languages[0]}`:""}. These stages suit it — or browse them all.`:"Same repo, same story — pick the stage. You can change it any time."));const a=$("div","setcards");for(const u of o){const d=$("button","setcard");d.type="button";const f=this.previews.get(u.id);d.innerHTML=`<div class="sw" style="--a:${Fn(u.sky[0])};--b:${Fn(u.palettes[0].left)}">${f?`<img src="${f}" alt="" />`:""}</div><div class="nm">${u.name}${u.id===t?" ✓":""}</div><div class="tg">${u.tagline}</div>`,d.onclick=()=>{this.h.onPickSet(u.id),this.showPicker(!1)},a.append(d)}const l=$("div","toolbar"),h=$("button","btn ghost","Surprise me");h.type="button",h.onclick=()=>this.h.onShuffle();const c=$("button","btn ghost",this.showAll?"Suggested":`All ${Ct.length} sets`);c.type="button",c.onclick=()=>{this.showAll=!this.showAll,this.showPicker(!0,t)},l.append(h,c),this.picker.append(a,l)}update(e,t,s,r){this.time.textContent=`${Dn(e.t)} / ${Dn(e.duration)}`,this.head.style.left=`${e.t/Math.max(1,e.duration)*100}%`,this.playBtn.innerHTML=e.playing?`${pu}<span>Pause</span>`:`${Kb}<span>${e.t>=e.duration-1?"Replay":"Play"}</span>`;const n=e.current;this.title.style.opacity=String(n&&n.kind==="curtain_up"?1-Math.min(1,Math.max(0,(e.t-n.atMs-600)/700)):e.t<600?1:0);const o=n&&n.kind==="curtain_down"?n:null;this.end.style.opacity=String(o?Math.min(1,Math.max(0,(e.t-o.atMs-400)/600)):0);const a=n?qb(n,t,r).replace(/\bPip\b/g,this.leadName):"";n&&n.id!==this.lastBeatId&&(this.lastBeatId=n.id,a&&(this.lastCaption=a));const l=this.caption.firstElementChild;l.textContent=this.lastCaption,l.style.opacity=this.lastCaption&&!(n?.kind==="curtain_up"&&e.t-(n?.atMs??0)<900)?"1":"0",e.evidence?(this.chip.hidden=!1,this.chip.className="chip ok",this.chip.innerHTML=`${Zb}Evidence · ${e.evidence.passed} tests passed`):n?.kind==="unverified_claim"||n?.kind==="curtain_down"&&!n.verified?(this.chip.hidden=!1,this.chip.className="chip warn",this.chip.textContent="No test evidence"):this.chip.hidden=!0;const h=this.liveMode&&n?.kind==="your_turn"&&this.promptEnabled;this.prompt.hidden=!h,h&&(this.prompt.querySelector("input").placeholder=`${this.leadName||"The agent"} is done. What's next?`);const c=this.liveMode&&n?.kind==="blocked_on_you";if(this.waiting.hidden=!c,c&&n?.kind==="blocked_on_you"){const m=n.reason==="permission"?"needs your permission to continue":"has a question for you";this.waiting.querySelector("b").textContent=`${this.leadName||"The agent"} ${m}.`,this.waiting.querySelector("span").textContent=this.vscode?"Answer in Claude Code.":"Answer in the terminal or editor where Claude Code is running.",this.waiting.querySelector(".go").textContent=this.vscode?"Go to Claude Code":"Notify me next time",this.notifiedFor!==n.id&&(this.notifiedFor=n.id,!this.vscode&&"Notification"in globalThis&&Notification.permission==="granted"&&new Notification("Agent Theatre",{body:`${this.leadName||"The agent"} ${m}.`}))}if(this.liveMode&&e.duration===0){const m=(this.repoId||"this folder").split(/[/\\]/).filter(Boolean).pop();this.caption.hidden=!1,this.caption.firstElementChild.textContent=`Waiting for a Claude Code session in ${m}. Run \`claude\` in that folder and the stage comes alive.`}this.signal.hidden=e.signal==="ok"||!this.liveMode,this.signal.className=`signal ${e.signal}`,this.signal.lastElementChild.textContent=e.signal==="lost"?"quiet — no events for 90 s":"live";let u=0;this.acts.forEach((m,_)=>{e.t>=m.fromMs&&(u=_)}),u!==this.lastAct&&(this.lastAct=u,this.actBtns.forEach((m,_)=>{m.classList.toggle("on",_<u),m.classList.toggle("now",_===u)}),this.actLabels.forEach((m,_)=>m.classList.toggle("now",_===u)));let d=-1;this.logBtns.forEach((m,_)=>{e.t>=m.ms&&(d=_)}),d!==this.lastEv&&(this.lastEv=d,this.logBtns.forEach((m,_)=>{m.btn.classList.toggle("done",_<d),m.btn.classList.toggle("now",_===d)}),this.logBtns[d]?.btn.scrollIntoView({block:"nearest",behavior:"smooth"}));const p=this.stageEl.getBoundingClientRect().width<600,g=e.labels.filter(m=>m.active||!p).sort((m,_)=>m.screen.y-_.screen.y||m.screen.x-_.screen.x);for(let m=0;m<g.length;m++)for(let _=0;_<m;_++){const y=g[_],x=g[m];Math.abs(y.screen.x-x.screen.x)<76&&Math.abs(y.screen.y-x.screen.y)<20&&(x.screen={x:x.screen.x,y:y.screen.y-20})}for(;this.tagPool.length<g.length;){const m=$("div","tag");this.overlay.append(m),this.tagPool.push(m)}this.tagPool.forEach((m,_)=>{const y=g[_];if(!y){m.hidden=!0;return}m.hidden=!1,m.textContent=y.text;const x=t.places.find(v=>v.label===y.text)?.id??"",b=s(x);m.className=`tag${y.active?" active":""}${b!=="idle"?` lamp-${b}`:""}`,m.style.left=`${y.screen.x}px`,m.style.top=`${y.screen.y}px`}),e.bubble?(this.bubbleEl.hidden=!1,this.bubbleEl.textContent=e.bubble.text,this.bubbleEl.style.color=Fn(e.bubble.color),this.bubbleEl.style.left=`${e.bubble.screen.x}px`,this.bubbleEl.style.top=`${e.bubble.screen.y}px`,this.bubbleEl.classList.toggle("pulse",n?.kind==="blocked_on_you")):this.bubbleEl.hidden=!0}liveMode=!1;async notify(){if(!("Notification"in globalThis))return;(Notification.permission==="default"?await Notification.requestPermission():Notification.permission)==="granted"&&new Notification("Agent Theatre",{body:"You'll get a notification whenever the agent waits on you."})}}function Jb(i,e){const t=s=>s.split("/").pop()??s;switch(i.kind){case"read_file":return["Read",i.path];case"edit_file":return["Edit",`${i.path} · +${i.added} −${i.removed}`];case"write_file":return[i.created?"Create":"Write",i.path];case"run_command":return[i.intent==="test"?"Run tests":i.intent==="git"?"Git":i.intent==="build"?"Build":i.intent==="install"?"Install":"Run",`${i.argv0}${i.touched.length?" · "+i.touched.map(t).join(", "):""}`];case"test_result":return[i.ok?`${i.passed} passed`:`${i.failed} failed`,i.framework?`${i.framework}`:""];case"search":return["Search",i.scope];case"subagent_start":return["Helper",i.label??i.childId];case"subagent_stop":return["Helper done",i.childId];case"waiting_for_user":return[i.reason==="permission"?"Needs permission":i.reason==="question"?"Has a question":"Waiting",""];case"error":return["Error",i.where];case"turn_end":return[i.claimedSuccess?"Says it's done":"Turn ends",""];default:return[i.kind,""]}}const e1=i=>{let e=2166136261;for(let t=0;t<i.length;t++)e^=i.charCodeAt(t),e=Math.imul(e,16777619);return e>>>0},mu=i=>i.replace(/[&<>"]/g,e=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"})[e]??e);async function t1(i,e,t,s=360,r=200){const n=new Eg(e,t);n.update(0);const o=new _e,a=e.places.flatMap(g=>[K(g.gx,g.gy),K(g.gx+g.footprint,g.gy+g.footprint)]),l=a.map(g=>g.x),h=a.map(g=>g.y),c=Math.max(...l)-Math.min(...l)+160,u=Math.max(...h)-Math.min(...h)+170,d=Math.min(s/c,r/u);o.scale.set(d),o.position.set(s/2-(Math.min(...l)+Math.max(...l))/2*d,r/2-((Math.min(...h)+Math.max(...h))/2-20)*d),o.addChild(n.container);const f=Ti.create({width:s,height:r,resolution:1});i.renderer.render({container:o,target:f,clear:!0,clearColor:t.sky[1]});const p=await i.renderer.extract.base64(f);return f.destroy(!0),n.destroy(),o.destroy({children:!0}),p}const ne=new URLSearchParams(location.search||globalThis.__AT_QUERY||""),Is=ne.get("base")??"",Ss=globalThis.acquireVsCodeApi?.()??null;globalThis.__vsapi=Ss;const Xi=matchMedia("(prefers-reduced-motion: reduce)").matches,tt={get:i=>{try{return localStorage.getItem(i)}catch{return null}},set:(i,e)=>{try{localStorage.setItem(i,e)}catch{}}};async function s1(i){try{const e=await(await fetch("/demo/demos.json")).json();return i==="any"?e[Math.floor(Math.random()*e.length)]??null:e.find(t=>t.id===i)??null}catch{return null}}async function i1(i){const e=await s1(i);e&&(i=e.id,ne.has("episode")||ne.set("episode",`${e.title} · ${e.kind}`),!ne.has("set")&&ne.has("cinema")&&ne.set("set",e.set));const t=await(await fetch(`/demo/${i}.jsonl`)).text(),{events:s}=Wx(t),r=tb(s);let n=r.files,o=s[0]?.repoId??i;try{const h=await(await fetch(`/demo/${i}.files.json`)).json();if(Array.isArray(h.files)){const c=new Set(h.files.map(u=>u.path));n=[...h.files,...r.files.filter(u=>!c.has(u.path))],h.repoId&&(o=h.repoId)}}catch{}const a=Zx({repoId:o,files:n,touched:r.touched}),l=tr(s,a);return new ch({world:a,events:s,beats:l,repoId:o})}async function r1(i,e){const t=new sb;let s=()=>{};const r=async()=>{await t.arm(),t.ready&&a?.audioReady()};let n=!1;for(const I of["pointerdown","keydown"])addEventListener(I,()=>{t.ready||(n=!0,setTimeout(()=>{n=!1},700),r())},{passive:!0});let o=sr(ne.get("set")),a=null,l=Number(ne.get("rate"))||1,h=tt.get("at:muted")!=="0",c=tt.get("at:ambience")==="1";t.setMuted(h),t.setAmbienceEnabled(c);const u=new Qb(i,{onPlayPause:()=>{a&&(r(),a.playing?a.pause():(a.state.t>=a.state.duration-1&&a.seek(0),a.play()))},onSeek:I=>{a?.seek(I)},onRate:()=>{l=l>=4?1:l*2,a?.setRate(l),u.setRate(l)},onMute:()=>{if(!t.ready||n){r(),h&&(h=!1,t.setMuted(!1),tt.set("at:muted","0"),u.setMuted(!1)),u.nudgeSeen();return}h=!h,u.nudgeSeen(),t.setMuted(h),tt.set("at:muted",h?"1":"0"),u.setMuted(h)},onAmbience:()=>{if(!t.ready||n){r(),c||(c=!0,t.setAmbienceEnabled(!0),tt.set("at:ambience","1"),u.setAmbience(!0)),u.nudgeSeen();return}c=!c,u.nudgeSeen(),t.setAmbienceEnabled(c),tt.set("at:ambience",c?"1":"0"),u.setAmbience(c)},onPickSet:I=>{o=sr(I),a&&(tt.set(`at:set:${a.world.repoId}`,I),v())},onOverview:I=>{a?.setOverview(I),s()},onZoom:I=>{a?.zoomBy(I),s()},onExport:()=>{p()},onPrompt:async I=>{if(Ss)return Ss.postMessage({type:"prompt",text:I}),"sent — watch the stage";try{const P=await fetch(`${Is}/api/prompt`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({text:I})}),C=await P.json();return C.ok?"sent — watch the stage":`couldn't send: ${C.error??P.status}`}catch(P){return`couldn't send: ${String(P)}`}},onShuffle:()=>{const I=Fo(m?.world.profile).filter(C=>C.id!==o.id),P=I.slice(0,Math.max(3,Math.min(5,I.length)));o=P[Math.floor(Math.random()*P.length)]??Ct[0],a&&(tt.set(`at:set:${a.world.repoId}`,o.id),v()),u.showPicker(!1)}});u.setMuted(h),u.setAmbience(c),u.setRate(l),h&&c===!1&&!tt.get("at:nudged")&&u.showNudge(),u.liveMode=e.mode==="live";const d=ne.has("cinema");d&&(document.documentElement.classList.add("cinema"),h=!0,t.setMuted(!0));let f=null;async function p(){if(f){f.stop();return}await r();const P=g.canvas.captureStream(30),C=t.captureStream();if(C)for(const N of C.getAudioTracks())P.addTrack(N);const D=[],R=["video/mp4;codecs=avc1.42E01E,mp4a.40.2","video/mp4","video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/webm"].find(N=>MediaRecorder.isTypeSupported(N))??"",L=R.startsWith("video/mp4")?"mp4":"webm";f=new MediaRecorder(P,R?{mimeType:R,videoBitsPerSecond:6e6}:void 0),f.ondataavailable=N=>{N.data.size&&D.push(N.data)},f.onstop=()=>{f=null,u.exportBtn.textContent="Export clip";const N=new Blob(D,{type:R.split(";")[0]||"video/webm"}),se=`agent-theatre-${(m?.repoId??"stage").split(/[/\\]/).pop()}-${new Date().toISOString().slice(0,19).replace(/[:T]/g,"-")}.${L}`,Q=`${a?.leadName??"The agent"} on the ${o.name} stage — ${(m?.repoId??"my repo").split(/[/\\]/).pop()} in Agent Theatre. Watch your coding agent work, as a film, not a log. https://agenttheatre.dev`;u.showShare({blob:N,name:se,caption:Q})},f.start(500),u.exportBtn.textContent="■ Stop & save",a&&!a.playing&&a.play()}const g=new ha;await g.init({resizeTo:u.stageEl,antialias:!0,backgroundAlpha:1,background:o.sky[1],preference:"webgl",resolution:Math.min(2,devicePixelRatio||1),autoDensity:!0}),u.stageEl.prepend(g.canvas);let m=null;const _=(I,P)=>Qx(I,vi[(I.seed+Ct.findIndex(C=>C.id===P.id)*7)%vi.length]);let y=0,x=!1,b="";function v(){if(!m)return;a&&(y=a.state.t,x=a.playing,a.destroy()),g.renderer.background.color=o.sky[1];const I=_(m.world,o),P=I===m.world?m.beats:tr(m.events,I);a=new Ys(g,I,o,t,Xi,ne.get("cast")??tt.get(`at:cast:${m.repoId}`)),globalThis.__agentTheatre={app:g,get player(){return a},panel:u},u.leadName=a.leadName,a.load(P),a.setRate(l),a.theme.id!==b?(a.seek(0),a.play()):(a.seek(y),x&&a.play()),b=a.theme.id,u.loadTimeline(P,m.events,I)}e.onReady(I=>{m=I;const P=tt.get(`at:set:${I.repoId}`),C=ne.get("set")??P;u.profile=I.world.profile,u.repoId=I.repoId,C?o=sr(C):o=Fo(I.world.profile,I.world.seed)[0]??Ct[0],u.setTitle(I.repoId,ne.get("episode")??void 0),Ss?u.promptEnabled=!0:e.mode==="live"&&fetch(`${Is}/api/prompt`).then(L=>L.json()).then(L=>{u.promptEnabled=!!L.available}).catch(()=>{}),u.loadTimeline(I.beats,I.events,I.world),v();const D=Number(ne.get("t"));D>0&&a&&a.seek(D*1e3);const R=(async()=>{if(!ne.has("nopreview")){for(const L of Ct)try{u.previews.set(L.id,await t1(g,_(I.world,L),L))}catch(N){console.warn("set preview failed",L.id,N)}u.pickerOpen&&u.showPicker(!0,o.id),s()}})();!C&&!ne.has("t")&&R.then(()=>u.showPicker(!0,o.id)),ne.get("paused")!=="1"&&!Xi&&a?.play(),d&&a&&!Xi&&a.play(),Xi&&!ne.has("t")&&a?.seek(Math.min(a.state.duration,25400))}),e.onBeats((I,P)=>{if(!(!a||!m)){if(m.beats.push(...I),m.events.push(...P),a.world===m.world)a.append(I);else{const C=tr(m.events,a.world);a.append(C.slice(a.beatCount))}u.loadTimeline(a.world===m.world?m.beats:tr(m.events,a.world),m.events,a.world),a.playing||a.play(),s()}}),e.onSignal?.(I=>a?.setSignal(I));const w=Number(ne.get("step"))||0;let T=performance.now(),k=0,E=!1,A=null;const M=I=>{E=!1;const P=w||Math.min(50,I-T);T=I,a&&!document.hidden&&((d||ne.has("loop"))&&a.state.t>=a.state.duration-1&&a.state.duration>0&&(A||(A=setTimeout(()=>{A=null,a?.seek(0),a?.play()},600))),a.update(P),u.update(a.state,a.world,C=>a.worldLayer.lampOf(C)),a.playing?k=45:k--),(a?.playing||k>0)&&!document.hidden&&B()},B=()=>{E||(E=!0,requestAnimationFrame(M))};s=()=>{k=45,T=performance.now(),B()},s();for(const I of["pointerdown","keydown","resize"])addEventListener(I,s,{passive:!0});document.addEventListener("visibilitychange",()=>{document.hidden||s()});const G=Ys.prototype.play;Ys.prototype.play=function(){G.call(this),s()};const O=Ys.prototype.seek;Ys.prototype.seek=function(I){O.call(this,I),s()}}async function n1(i){const{Application:e}=await St(async()=>{const{Application:l}=await Promise.resolve().then(()=>wx);return{Application:l}},void 0),{Pip:t}=await St(async()=>{const{Pip:l}=await Promise.resolve().then(()=>_b);return{Pip:l}},void 0),{castById:s,CAST:r}=await St(async()=>{const{castById:l,CAST:h}=await Promise.resolve().then(()=>gb);return{castById:l,CAST:h}},void 0),n=s(i)??r[0],o=sr(ne.get("set")??"island");document.documentElement.style.background="transparent",document.body.style.background="transparent",document.body.style.margin="0";const a=new e;if(await a.init({width:320,height:320,backgroundAlpha:0,antialias:!0,resolution:2,autoDensity:!0,preference:"webgl"}),document.body.replaceChildren(a.canvas),i==="gremlin"){const{Gremlin:l}=await St(async()=>{const{Gremlin:c}=await Promise.resolve().then(()=>pb);return{Gremlin:c}},void 0),h=new l("g",o,!1);h.scale=7,h.x=160,h.y=250,a.stage.addChild(h.container),a.ticker.add(c=>h.update(c.deltaMS))}else{const l=new t(o,!1,n);l.container.scale.set(6*n.size),l.pose.x=160,l.pose.y=272,a.stage.addChild(l.container),l.pose.mood=ne.get("mood")??"curious",a.ticker.add(h=>l.update(h.deltaMS))}globalThis.__agentTheatre={app:a,player:!0}}const On=document.getElementById("app"),o1=ne.has("portrait")?Promise.resolve(new ch({world:null,events:[],beats:[],repoId:""})):Ss&&(ne.has("live")||ne.get("session"))?Promise.resolve(new jb(Ss,ne.get("session"))):ne.has("live")?Promise.resolve(new Vb(Is)):ne.get("session")?Xb(ne.get("session"),Is):i1(ne.get("demo")??"episode-1");ne.has("portrait")?n1(ne.get("portrait")).catch(i=>{On.textContent=`Could not start: ${i}`}):o1.then(i=>r1(On,i)).catch(i=>{On.textContent=`Could not start: ${i}${Is?` (server: ${Is})`:""}`});export{C_ as A,_e as C,Hf as D,Wf as E,ty as F,M_ as a,Kf as b,Vf as c,Yf as d,q as e};
958
- //# sourceMappingURL=index-CO8a_HgY.js.map
957
+ <p class="sh-note">Posts open with the caption; attach the downloaded clip there.</p>`);n.addEventListener("click",o=>{const a=o.target.closest("[data-act]")?.getAttribute("data-act");a==="share"&&navigator.share({files:[s],title:"Agent Theatre",text:e.caption}).catch(()=>{}),a==="caption"&&navigator.clipboard?.writeText(e.caption),a==="close"&&(n.remove(),setTimeout(()=>URL.revokeObjectURL(t),1e3))}),this.stageEl.append(n)}nudgeSeen(){this.nudge.hidden=!0;try{localStorage.setItem("at:nudged","1")}catch{}}overviewBtn;overviewOn=!1;exportBtn;prompt;waiting;vscode;notifiedFor="";overlay;caption;chip;signal;title;end;picker;playBtn;rateBtn;muteBtn;ambBtn;setBtn;actsEl;labelsEl;head;time;logEl;acts=[];actBtns=[];actLabels=[];logBtns=[];lastCaption="";lastBeatId="";lastAct=-1;lastEv=-2;tagPool=[];bubbleEl;durationMs=0;repoId="";promptEnabled=!1;setTitle(e,t){const s=e.replace(/\/+$/,"").split(/[/\\]/).filter(Boolean).pop()??e,r=this.root.querySelector("#title");r.textContent=s,r.title=e,this.root.querySelector("#titleBig").textContent=t??s}setMuted(e){this.muteBtn.textContent=e?"Effects off":"Effects on",this.muteBtn.setAttribute("aria-pressed",String(!e))}setAmbience(e){this.ambBtn.textContent=e?"Ambience on":"Ambience off",this.ambBtn.setAttribute("aria-pressed",String(e))}setRate(e){this.rateBtn.textContent=`${e}×`}loadTimeline(e,t,s){this.durationMs=e.length?Math.max(...e.map(n=>n.atMs+n.durationMs)):0,this.acts=Yb(e),this.actsEl.innerHTML="",this.labelsEl.innerHTML="",this.actBtns=[],this.actLabels=[];for(const n of this.acts){const o=(n.toMs-n.fromMs)/Math.max(1,this.durationMs)*100,a=$("button");a.type="button",a.style.flex=`0 0 calc(${o}% - 3px)`,a.setAttribute("aria-label",`Jump to ${n.label}`),a.onclick=h=>{h.stopPropagation(),this.h.onSeek(n.fromMs+1)};const l=$("span","",n.label);l.style.flex=`0 0 calc(${o}% - 3px)`,this.actsEl.append(a),this.labelsEl.append(l),this.actBtns.push(a),this.actLabels.push(l)}this.logEl.innerHTML="",this.logBtns=[],t[0]?.ts;const r=n=>e.find(o=>o.sourceEventIds.includes(n));for(const n of t){if(n.kind==="session_start"||n.kind==="session_end")continue;const o=r(n.id);if(!o)continue;const a=$("li"),l=$("button");l.type="button";const[h,c]=Jb(n),u=n.kind==="test_result"&&!n.ok;l.innerHTML=`<time>${Dn(o.atMs)}</time><span class="dot k-${n.kind}${u?" fail":""}"></span><span class="ev"><b>${mu(h)}</b><code>${mu(c)}</code></span>`,l.onclick=()=>this.h.onSeek(o.atMs+1),a.append(l),this.logEl.append(a),this.logBtns.push({btn:l,ms:o.atMs})}}previews=new Map;get pickerOpen(){return!this.picker.hidden}profile;leadName="Pip";showAll=!1;showPicker(e,t){if(this.picker.hidden=!e,!e)return;this.picker.innerHTML="";const s=this.profile?.kinds?.[0],r=s&&s!=="unknown"?{"web-frontend":"a web app","backend-api":"a backend","cli-tool":"a CLI",library:"a library","data-ml":"data & ML work",mobile:"a mobile app",game:"a game","infra-devops":"infrastructure","docs-content":"documentation",monorepo:"a monorepo",systems:"systems code"}[s]:null,n=Fo(this.profile,e1(this.repoId)).slice(0,3),o=this.showAll?[...Ct]:n;this.picker.append($("h3","",this.showAll?"All sets":"Choose your set"),$("p","",r&&!this.showAll?`This looks like ${r}${this.profile?.languages?.[0]?` in ${this.profile.languages[0]}`:""}. These stages suit it — or browse them all.`:"Same repo, same story — pick the stage. You can change it any time."));const a=$("div","setcards");for(const u of o){const d=$("button","setcard");d.type="button";const f=this.previews.get(u.id);d.innerHTML=`<div class="sw" style="--a:${Fn(u.sky[0])};--b:${Fn(u.palettes[0].left)}">${f?`<img src="${f}" alt="" />`:""}</div><div class="nm">${u.name}${u.id===t?" ✓":""}</div><div class="tg">${u.tagline}</div>`,d.onclick=()=>{this.h.onPickSet(u.id),this.showPicker(!1)},a.append(d)}const l=$("div","toolbar"),h=$("button","btn ghost","Surprise me");h.type="button",h.onclick=()=>this.h.onShuffle();const c=$("button","btn ghost",this.showAll?"Suggested":`All ${Ct.length} sets`);c.type="button",c.onclick=()=>{this.showAll=!this.showAll,this.showPicker(!0,t)},l.append(h,c),this.picker.append(a,l)}update(e,t,s,r){this.time.textContent=`${Dn(e.t)} / ${Dn(e.duration)}`,this.head.style.left=`${e.t/Math.max(1,e.duration)*100}%`,this.playBtn.innerHTML=e.playing?`${pu}<span>Pause</span>`:`${Kb}<span>${e.t>=e.duration-1?"Replay":"Play"}</span>`;const n=e.current;this.title.style.opacity=String(n&&n.kind==="curtain_up"?1-Math.min(1,Math.max(0,(e.t-n.atMs-600)/700)):e.t<600?1:0);const o=n&&n.kind==="curtain_down"?n:null;this.end.style.opacity=String(o?Math.min(1,Math.max(0,(e.t-o.atMs-400)/600)):0);const a=n?qb(n,t,r).replace(/\bPip\b/g,this.leadName):"";n&&n.id!==this.lastBeatId&&(this.lastBeatId=n.id,a&&(this.lastCaption=a));const l=this.caption.firstElementChild;l.textContent=this.lastCaption,l.style.opacity=this.lastCaption&&!(n?.kind==="curtain_up"&&e.t-(n?.atMs??0)<900)?"1":"0",e.evidence?(this.chip.hidden=!1,this.chip.className="chip ok",this.chip.innerHTML=`${Zb}Evidence · ${e.evidence.passed} tests passed`):n?.kind==="unverified_claim"||n?.kind==="curtain_down"&&!n.verified?(this.chip.hidden=!1,this.chip.className="chip warn",this.chip.textContent="No test evidence"):this.chip.hidden=!0;const h=this.liveMode&&n?.kind==="your_turn"&&this.promptEnabled;this.prompt.hidden=!h,h&&(this.prompt.querySelector("input").placeholder=`${this.leadName||"The agent"} is done. What's next?`);const c=this.liveMode&&n?.kind==="blocked_on_you";if(this.waiting.hidden=!c,c&&n?.kind==="blocked_on_you"){const m=n.reason==="permission"?"needs your permission to continue":"has a question for you";this.waiting.querySelector("b").textContent=`${this.leadName||"The agent"} ${m}.`,this.waiting.querySelector("span").textContent=this.vscode?"Answer in Claude Code.":"Answer in the terminal or editor where Claude Code is running.",this.waiting.querySelector(".go").textContent=this.vscode?"Go to Claude Code":"Notify me next time",this.notifiedFor!==n.id&&(this.notifiedFor=n.id,!this.vscode&&"Notification"in globalThis&&Notification.permission==="granted"&&new Notification("Agent Theatre",{body:`${this.leadName||"The agent"} ${m}.`}))}if(this.liveMode&&e.duration===0){const m=(this.repoId||"this folder").split(/[/\\]/).filter(Boolean).pop();this.caption.hidden=!1,this.caption.firstElementChild.textContent=`Waiting for a Claude Code session in ${m}. Run \`claude\` in that folder and the stage comes alive.`}this.signal.hidden=e.signal==="ok"||!this.liveMode,this.signal.className=`signal ${e.signal}`,this.signal.lastElementChild.textContent=e.signal==="lost"?"quiet — no events for 90 s":"live";let u=0;this.acts.forEach((m,_)=>{e.t>=m.fromMs&&(u=_)}),u!==this.lastAct&&(this.lastAct=u,this.actBtns.forEach((m,_)=>{m.classList.toggle("on",_<u),m.classList.toggle("now",_===u)}),this.actLabels.forEach((m,_)=>m.classList.toggle("now",_===u)));let d=-1;this.logBtns.forEach((m,_)=>{e.t>=m.ms&&(d=_)}),d!==this.lastEv&&(this.lastEv=d,this.logBtns.forEach((m,_)=>{m.btn.classList.toggle("done",_<d),m.btn.classList.toggle("now",_===d)}),this.logBtns[d]?.btn.scrollIntoView({block:"nearest",behavior:"smooth"}));const p=this.stageEl.getBoundingClientRect().width<600,g=e.labels.filter(m=>m.active||!p).sort((m,_)=>m.screen.y-_.screen.y||m.screen.x-_.screen.x);for(let m=0;m<g.length;m++)for(let _=0;_<m;_++){const y=g[_],x=g[m];Math.abs(y.screen.x-x.screen.x)<76&&Math.abs(y.screen.y-x.screen.y)<20&&(x.screen={x:x.screen.x,y:y.screen.y-20})}for(;this.tagPool.length<g.length;){const m=$("div","tag");this.overlay.append(m),this.tagPool.push(m)}this.tagPool.forEach((m,_)=>{const y=g[_];if(!y){m.hidden=!0;return}m.hidden=!1,m.textContent=y.text;const x=t.places.find(v=>v.label===y.text)?.id??"",b=s(x);m.className=`tag${y.active?" active":""}${b!=="idle"?` lamp-${b}`:""}`,m.style.left=`${y.screen.x}px`,m.style.top=`${y.screen.y}px`}),e.bubble?(this.bubbleEl.hidden=!1,this.bubbleEl.textContent=e.bubble.text,this.bubbleEl.style.color=Fn(e.bubble.color),this.bubbleEl.style.left=`${e.bubble.screen.x}px`,this.bubbleEl.style.top=`${e.bubble.screen.y}px`,this.bubbleEl.classList.toggle("pulse",n?.kind==="blocked_on_you")):this.bubbleEl.hidden=!0}liveMode=!1;async notify(){if(!("Notification"in globalThis))return;(Notification.permission==="default"?await Notification.requestPermission():Notification.permission)==="granted"&&new Notification("Agent Theatre",{body:"You'll get a notification whenever the agent waits on you."})}}function Jb(i,e){const t=s=>s.split("/").pop()??s;switch(i.kind){case"read_file":return["Read",i.path];case"edit_file":return["Edit",`${i.path} · +${i.added} −${i.removed}`];case"write_file":return[i.created?"Create":"Write",i.path];case"run_command":return[i.intent==="test"?"Run tests":i.intent==="git"?"Git":i.intent==="build"?"Build":i.intent==="install"?"Install":"Run",`${i.argv0}${i.touched.length?" · "+i.touched.map(t).join(", "):""}`];case"test_result":return[i.ok?`${i.passed} passed`:`${i.failed} failed`,i.framework?`${i.framework}`:""];case"search":return["Search",i.scope];case"subagent_start":return["Helper",i.label??i.childId];case"subagent_stop":return["Helper done",i.childId];case"waiting_for_user":return[i.reason==="permission"?"Needs permission":i.reason==="question"?"Has a question":"Waiting",""];case"error":return["Error",i.where];case"turn_end":return[i.claimedSuccess?"Says it's done":"Turn ends",""];default:return[i.kind,""]}}const e1=i=>{let e=2166136261;for(let t=0;t<i.length;t++)e^=i.charCodeAt(t),e=Math.imul(e,16777619);return e>>>0},mu=i=>i.replace(/[&<>"]/g,e=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"})[e]??e);async function t1(i,e,t,s=360,r=200){const n=new Eg(e,t);n.update(0);const o=new _e,a=e.places.flatMap(g=>[K(g.gx,g.gy),K(g.gx+g.footprint,g.gy+g.footprint)]),l=a.map(g=>g.x),h=a.map(g=>g.y),c=Math.max(...l)-Math.min(...l)+160,u=Math.max(...h)-Math.min(...h)+170,d=Math.min(s/c,r/u);o.scale.set(d),o.position.set(s/2-(Math.min(...l)+Math.max(...l))/2*d,r/2-((Math.min(...h)+Math.max(...h))/2-20)*d),o.addChild(n.container);const f=Ti.create({width:s,height:r,resolution:1});i.renderer.render({container:o,target:f,clear:!0,clearColor:t.sky[1]});const p=await i.renderer.extract.base64(f);return f.destroy(!0),n.destroy(),o.destroy({children:!0}),p}const ne=new URLSearchParams(globalThis.__AT_QUERY??location.search),Is=ne.get("base")??"",Ss=globalThis.acquireVsCodeApi?.()??null;globalThis.__vsapi=Ss;const Xi=matchMedia("(prefers-reduced-motion: reduce)").matches,tt={get:i=>{try{return localStorage.getItem(i)}catch{return null}},set:(i,e)=>{try{localStorage.setItem(i,e)}catch{}}};async function s1(i){try{const e=await(await fetch("/demo/demos.json")).json();return i==="any"?e[Math.floor(Math.random()*e.length)]??null:e.find(t=>t.id===i)??null}catch{return null}}async function i1(i){const e=await s1(i);e&&(i=e.id,ne.has("episode")||ne.set("episode",`${e.title} · ${e.kind}`),!ne.has("set")&&ne.has("cinema")&&ne.set("set",e.set));const t=await(await fetch(`/demo/${i}.jsonl`)).text(),{events:s}=Wx(t),r=tb(s);let n=r.files,o=s[0]?.repoId??i;try{const h=await(await fetch(`/demo/${i}.files.json`)).json();if(Array.isArray(h.files)){const c=new Set(h.files.map(u=>u.path));n=[...h.files,...r.files.filter(u=>!c.has(u.path))],h.repoId&&(o=h.repoId)}}catch{}const a=Zx({repoId:o,files:n,touched:r.touched}),l=tr(s,a);return new ch({world:a,events:s,beats:l,repoId:o})}async function r1(i,e){const t=new sb;let s=()=>{};const r=async()=>{await t.arm(),t.ready&&a?.audioReady()};let n=!1;for(const I of["pointerdown","keydown"])addEventListener(I,()=>{t.ready||(n=!0,setTimeout(()=>{n=!1},700),r())},{passive:!0});let o=sr(ne.get("set")),a=null,l=Number(ne.get("rate"))||1,h=tt.get("at:muted")!=="0",c=tt.get("at:ambience")==="1";t.setMuted(h),t.setAmbienceEnabled(c);const u=new Qb(i,{onPlayPause:()=>{a&&(r(),a.playing?a.pause():(a.state.t>=a.state.duration-1&&a.seek(0),a.play()))},onSeek:I=>{a?.seek(I)},onRate:()=>{l=l>=4?1:l*2,a?.setRate(l),u.setRate(l)},onMute:()=>{if(!t.ready||n){r(),h&&(h=!1,t.setMuted(!1),tt.set("at:muted","0"),u.setMuted(!1)),u.nudgeSeen();return}h=!h,u.nudgeSeen(),t.setMuted(h),tt.set("at:muted",h?"1":"0"),u.setMuted(h)},onAmbience:()=>{if(!t.ready||n){r(),c||(c=!0,t.setAmbienceEnabled(!0),tt.set("at:ambience","1"),u.setAmbience(!0)),u.nudgeSeen();return}c=!c,u.nudgeSeen(),t.setAmbienceEnabled(c),tt.set("at:ambience",c?"1":"0"),u.setAmbience(c)},onPickSet:I=>{o=sr(I),a&&(tt.set(`at:set:${a.world.repoId}`,I),v())},onOverview:I=>{a?.setOverview(I),s()},onZoom:I=>{a?.zoomBy(I),s()},onExport:()=>{p()},onPrompt:async I=>{if(Ss)return Ss.postMessage({type:"prompt",text:I}),"sent — watch the stage";try{const P=await fetch(`${Is}/api/prompt`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({text:I})}),C=await P.json();return C.ok?"sent — watch the stage":`couldn't send: ${C.error??P.status}`}catch(P){return`couldn't send: ${String(P)}`}},onShuffle:()=>{const I=Fo(m?.world.profile).filter(C=>C.id!==o.id),P=I.slice(0,Math.max(3,Math.min(5,I.length)));o=P[Math.floor(Math.random()*P.length)]??Ct[0],a&&(tt.set(`at:set:${a.world.repoId}`,o.id),v()),u.showPicker(!1)}});u.setMuted(h),u.setAmbience(c),u.setRate(l),h&&c===!1&&!tt.get("at:nudged")&&u.showNudge(),u.liveMode=e.mode==="live";const d=ne.has("cinema");d&&(document.documentElement.classList.add("cinema"),h=!0,t.setMuted(!0));let f=null;async function p(){if(f){f.stop();return}await r();const P=g.canvas.captureStream(30),C=t.captureStream();if(C)for(const N of C.getAudioTracks())P.addTrack(N);const D=[],R=["video/mp4;codecs=avc1.42E01E,mp4a.40.2","video/mp4","video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/webm"].find(N=>MediaRecorder.isTypeSupported(N))??"",L=R.startsWith("video/mp4")?"mp4":"webm";f=new MediaRecorder(P,R?{mimeType:R,videoBitsPerSecond:6e6}:void 0),f.ondataavailable=N=>{N.data.size&&D.push(N.data)},f.onstop=()=>{f=null,u.exportBtn.textContent="Export clip";const N=new Blob(D,{type:R.split(";")[0]||"video/webm"}),se=`agent-theatre-${(m?.repoId??"stage").split(/[/\\]/).pop()}-${new Date().toISOString().slice(0,19).replace(/[:T]/g,"-")}.${L}`,Q=`${a?.leadName??"The agent"} on the ${o.name} stage — ${(m?.repoId??"my repo").split(/[/\\]/).pop()} in Agent Theatre. Watch your coding agent work, as a film, not a log. https://agenttheatre.dev`;u.showShare({blob:N,name:se,caption:Q})},f.start(500),u.exportBtn.textContent="■ Stop & save",a&&!a.playing&&a.play()}const g=new ha;await g.init({resizeTo:u.stageEl,antialias:!0,backgroundAlpha:1,background:o.sky[1],preference:"webgl",resolution:Math.min(2,devicePixelRatio||1),autoDensity:!0}),u.stageEl.prepend(g.canvas);let m=null;const _=(I,P)=>Qx(I,vi[(I.seed+Ct.findIndex(C=>C.id===P.id)*7)%vi.length]);let y=0,x=!1,b="";function v(){if(!m)return;a&&(y=a.state.t,x=a.playing,a.destroy()),g.renderer.background.color=o.sky[1];const I=_(m.world,o),P=I===m.world?m.beats:tr(m.events,I);a=new Ys(g,I,o,t,Xi,ne.get("cast")??tt.get(`at:cast:${m.repoId}`)),globalThis.__agentTheatre={app:g,get player(){return a},panel:u},u.leadName=a.leadName,a.load(P),a.setRate(l),a.theme.id!==b?(a.seek(0),a.play()):(a.seek(y),x&&a.play()),b=a.theme.id,u.loadTimeline(P,m.events,I)}e.onReady(I=>{m=I;const P=tt.get(`at:set:${I.repoId}`),C=ne.get("set")??P;u.profile=I.world.profile,u.repoId=I.repoId,C?o=sr(C):o=Fo(I.world.profile,I.world.seed)[0]??Ct[0],u.setTitle(I.repoId,ne.get("episode")??void 0),Ss?u.promptEnabled=!0:e.mode==="live"&&fetch(`${Is}/api/prompt`).then(L=>L.json()).then(L=>{u.promptEnabled=!!L.available}).catch(()=>{}),u.loadTimeline(I.beats,I.events,I.world),v();const D=Number(ne.get("t"));D>0&&a&&a.seek(D*1e3);const R=(async()=>{if(!ne.has("nopreview")){for(const L of Ct)try{u.previews.set(L.id,await t1(g,_(I.world,L),L))}catch(N){console.warn("set preview failed",L.id,N)}u.pickerOpen&&u.showPicker(!0,o.id),s()}})();!C&&!ne.has("t")&&R.then(()=>u.showPicker(!0,o.id)),ne.get("paused")!=="1"&&!Xi&&a?.play(),d&&a&&!Xi&&a.play(),Xi&&!ne.has("t")&&a?.seek(Math.min(a.state.duration,25400))}),e.onBeats((I,P)=>{if(!(!a||!m)){if(m.beats.push(...I),m.events.push(...P),a.world===m.world)a.append(I);else{const C=tr(m.events,a.world);a.append(C.slice(a.beatCount))}u.loadTimeline(a.world===m.world?m.beats:tr(m.events,a.world),m.events,a.world),a.playing||a.play(),s()}}),e.onSignal?.(I=>a?.setSignal(I));const w=Number(ne.get("step"))||0;let T=performance.now(),k=0,E=!1,A=null;const M=I=>{E=!1;const P=w||Math.min(50,I-T);T=I,a&&!document.hidden&&((d||ne.has("loop"))&&a.state.t>=a.state.duration-1&&a.state.duration>0&&(A||(A=setTimeout(()=>{A=null,a?.seek(0),a?.play()},600))),a.update(P),u.update(a.state,a.world,C=>a.worldLayer.lampOf(C)),a.playing?k=45:k--),(a?.playing||k>0)&&!document.hidden&&B()},B=()=>{E||(E=!0,requestAnimationFrame(M))};s=()=>{k=45,T=performance.now(),B()},s();for(const I of["pointerdown","keydown","resize"])addEventListener(I,s,{passive:!0});document.addEventListener("visibilitychange",()=>{document.hidden||s()});const G=Ys.prototype.play;Ys.prototype.play=function(){G.call(this),s()};const O=Ys.prototype.seek;Ys.prototype.seek=function(I){O.call(this,I),s()}}async function n1(i){const{Application:e}=await St(async()=>{const{Application:l}=await Promise.resolve().then(()=>wx);return{Application:l}},void 0),{Pip:t}=await St(async()=>{const{Pip:l}=await Promise.resolve().then(()=>_b);return{Pip:l}},void 0),{castById:s,CAST:r}=await St(async()=>{const{castById:l,CAST:h}=await Promise.resolve().then(()=>gb);return{castById:l,CAST:h}},void 0),n=s(i)??r[0],o=sr(ne.get("set")??"island");document.documentElement.style.background="transparent",document.body.style.background="transparent",document.body.style.margin="0";const a=new e;if(await a.init({width:320,height:320,backgroundAlpha:0,antialias:!0,resolution:2,autoDensity:!0,preference:"webgl"}),document.body.replaceChildren(a.canvas),i==="gremlin"){const{Gremlin:l}=await St(async()=>{const{Gremlin:c}=await Promise.resolve().then(()=>pb);return{Gremlin:c}},void 0),h=new l("g",o,!1);h.scale=7,h.x=160,h.y=250,a.stage.addChild(h.container),a.ticker.add(c=>h.update(c.deltaMS))}else{const l=new t(o,!1,n);l.container.scale.set(6*n.size),l.pose.x=160,l.pose.y=272,a.stage.addChild(l.container),l.pose.mood=ne.get("mood")??"curious",a.ticker.add(h=>l.update(h.deltaMS))}globalThis.__agentTheatre={app:a,player:!0}}const On=document.getElementById("app"),o1=ne.has("portrait")?Promise.resolve(new ch({world:null,events:[],beats:[],repoId:""})):Ss&&(ne.has("live")||ne.get("session"))?Promise.resolve(new jb(Ss,ne.get("session"))):ne.has("live")?Promise.resolve(new Vb(Is)):ne.get("session")?Xb(ne.get("session"),Is):i1(ne.get("demo")??"episode-1");ne.has("portrait")?n1(ne.get("portrait")).catch(i=>{On.textContent=`Could not start: ${i}`}):o1.then(i=>r1(On,i)).catch(i=>{On.textContent=`Could not start: ${i}${Is?` (server: ${Is})`:""}`});export{C_ as A,_e as C,Hf as D,Wf as E,ty as F,M_ as a,Kf as b,Vf as c,Yf as d,q as e};
958
+ //# sourceMappingURL=index-vIjrCnHW.js.map