agent-theatre 1.3.1 → 1.3.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.
- package/dist/cli.js +13 -4
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +13 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/web/assets/browserAll-eGDH56DF.js +2 -0
- package/web/assets/{browserAll-jpKtMttp.js.map → browserAll-eGDH56DF.js.map} +1 -1
- package/web/assets/{index-DoUA_XxG.js → index-HehktIj0.js} +12 -12
- package/web/assets/index-HehktIj0.js.map +1 -0
- package/web/assets/webworkerAll-2M7wVkAJ.js +2 -0
- package/web/assets/{webworkerAll-eBrHhNNp.js.map → webworkerAll-2M7wVkAJ.js.map} +1 -1
- package/web/index.html +1 -1
- package/web/assets/browserAll-jpKtMttp.js +0 -2
- package/web/assets/index-DoUA_XxG.js.map +0 -1
- package/web/assets/webworkerAll-eBrHhNNp.js +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/browserAll-
|
|
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 Hg="modulepreload",Wg=function(i){return"/"+i},vh={},Et=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=Wg(h),h in vh)return;vh[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":Hg,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 jn=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},Js=(i,e)=>jn(i).priority??e,Y={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...i){return i.map(jn).forEach(e=>{e.type.forEach(t=>this._removeHandlers[t]?.(e))}),this},add(...i){return i.map(jn).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)=>Js(o.value,t)-Js(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)=>Js(n,t)-Js(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))}},bu={extension:{type:S.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await Et(()=>import("./browserAll-jpKtMttp.js"),__vite__mapDeps([0,1]))}},vu={extension:{type:S.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await Et(()=>import("./webworkerAll-eBrHhNNp.js"),[])}};class Me{constructor(e,t,s){this._x=t||0,this._y=s||0,this._observer=e}clone(e){return new Me(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 $g(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var an={exports:{}},wh;function Vg(){return wh||(wh=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 m=t?t+h:h;if(!this._events[m])return!1;var g=this._events[m],_=arguments.length,y,x;if(g.fn){switch(g.once&&this.removeListener(h,g.fn,void 0,!0),_){case 1:return g.fn.call(g.context),!0;case 2:return g.fn.call(g.context,c),!0;case 3:return g.fn.call(g.context,c,u),!0;case 4:return g.fn.call(g.context,c,u,d),!0;case 5:return g.fn.call(g.context,c,u,d,f),!0;case 6:return g.fn.call(g.context,c,u,d,f,p),!0}for(x=1,y=new Array(_-1);x<_;x++)y[x-1]=arguments[x];g.fn.apply(g.context,y)}else{var b=g.length,v;for(x=0;x<b;x++)switch(g[x].once&&this.removeListener(h,g[x].fn,void 0,!0),_){case 1:g[x].fn.call(g[x].context);break;case 2:g[x].fn.call(g[x].context,c);break;case 3:g[x].fn.call(g[x].context,c,u);break;case 4:g[x].fn.call(g[x].context,c,u,d);break;default:if(!y)for(v=1,y=new Array(_-1);v<_;v++)y[v-1]=arguments[v];g[x].fn.apply(g[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 m=0,g=[],_=p.length;m<_;m++)(p[m].fn!==c||d&&!p[m].once||u&&p[m].context!==u)&&g.push(p[m]);g.length?this._events[f]=g.length===1?g[0]:g: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})(an)),an.exports}var jg=Vg();const Re=$g(jg),wu=Math.PI*2,Tu=180/Math.PI,Su=Math.PI/180;class ce{constructor(e=0,t=0){this.x=0,this.y=0,this.x=e,this.y=t}clone(){return new ce(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 ln.x=0,ln.y=0,ln}}const ln=new ce;class L{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 ce;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 ce;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(wu-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 L;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 qg.identity()}static get shared(){return Xg.identity()}}const Xg=new L,qg=new L,$t=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],Vt=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],jt=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],Xt=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],Xn=[],Mu=[],Pi=Math.sign;function Yg(){for(let i=0;i<16;i++){const e=[];Xn.push(e);for(let t=0;t<16;t++){const s=Pi($t[i]*$t[t]+jt[i]*Vt[t]),r=Pi(Vt[i]*$t[t]+Xt[i]*Vt[t]),n=Pi($t[i]*jt[t]+jt[i]*Xt[t]),o=Pi(Vt[i]*jt[t]+Xt[i]*Xt[t]);for(let a=0;a<16;a++)if($t[a]===s&&Vt[a]===r&&jt[a]===n&&Xt[a]===o){e.push(a);break}}}for(let i=0;i<16;i++){const e=new L;e.set($t[i],Vt[i],jt[i],Xt[i],0,0),Mu.push(e)}}Yg();const Q={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=>$t[i],uY:i=>Vt[i],vX:i=>jt[i],vY:i=>Xt[i],inv:i=>i&8?i&15:-i&7,add:(i,e)=>Xn[i][e],sub:(i,e)=>Xn[i][Q.inv(e)],rotate180:i=>i^4,isVertical:i=>(i&3)===2,byDirection:(i,e)=>Math.abs(i)*2<=Math.abs(e)?e>=0?Q.S:Q.N:Math.abs(e)*2<=Math.abs(i)?i>0?Q.E:Q.W:e>0?i>0?Q.SE:Q.SW:i>0?Q.NE:Q.NW,matrixAppendRotationInv:(i,e,t=0,s=0,r=0,n=0)=>{const o=Mu[Q.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,m=i.c,g=i.d;i.a=a*f+l*m,i.b=a*p+l*g,i.c=h*f+c*m,i.d=h*p+c*g,i.tx=u*f+d*m+i.tx,i.ty=u*p+d*g+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===Q.E?(s.set(r+l,n+h,o,a),s):t===Q.S?s.set(c-n-a+l,r+h,a,o):t===Q.W?s.set(c-r-o+l,u-n-a+h,o,a):t===Q.N?s.set(n+l,u-r-o+h,a,o):s.set(r+l,n+h,o,a)}},Ai=[new ce,new ce,new ce,new ce];class se{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 se(0,0,0,0)}clone(){return new se(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,m=a+c,g=a+n-c,_=l+c,y=l+o-c;return e>=u&&e<=d&&t>=f&&t<=p&&!(e>m&&e<g&&t>_&&t<y)}intersects(e,t){if(!t){const E=this.x<e.x?e.x:this.x;if((this.right>e.right?e.right:this.right)<=E)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=Ai[0].set(e.left,e.top),l=Ai[1].set(e.left,e.bottom),h=Ai[2].set(e.right,e.top),c=Ai[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,m=d*r+f*n,g=d*s+f*o,_=d*r+f*o;if(Math.max(p,m,g,_)<=d*a.x+f*a.y||Math.min(p,m,g,_)>=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 se),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 hn={default:-1};function oe(i="default"){return hn[i]===void 0&&(hn[i]=-1),++hn[i]}const Th=new Set,de="8.0.0",Cu="8.3.4",dt="8.21.0",ku="8.22.0",Cs={quiet:!1,noColor:!1},N=((i,e,t=3)=>{if(Cs.quiet||Th.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-eGDH56DF.js","assets/webworkerAll-2M7wVkAJ.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 Hg="modulepreload",Wg=function(i){return"/"+i},vh={},Et=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=Wg(h),h in vh)return;vh[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":Hg,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 jn=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},Js=(i,e)=>jn(i).priority??e,Y={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...i){return i.map(jn).forEach(e=>{e.type.forEach(t=>this._removeHandlers[t]?.(e))}),this},add(...i){return i.map(jn).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)=>Js(o.value,t)-Js(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)=>Js(n,t)-Js(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))}},bu={extension:{type:S.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await Et(()=>import("./browserAll-eGDH56DF.js"),__vite__mapDeps([0,1]))}},vu={extension:{type:S.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await Et(()=>import("./webworkerAll-2M7wVkAJ.js"),[])}};class Me{constructor(e,t,s){this._x=t||0,this._y=s||0,this._observer=e}clone(e){return new Me(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 $g(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var an={exports:{}},wh;function Vg(){return wh||(wh=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 m=t?t+h:h;if(!this._events[m])return!1;var g=this._events[m],_=arguments.length,y,x;if(g.fn){switch(g.once&&this.removeListener(h,g.fn,void 0,!0),_){case 1:return g.fn.call(g.context),!0;case 2:return g.fn.call(g.context,c),!0;case 3:return g.fn.call(g.context,c,u),!0;case 4:return g.fn.call(g.context,c,u,d),!0;case 5:return g.fn.call(g.context,c,u,d,f),!0;case 6:return g.fn.call(g.context,c,u,d,f,p),!0}for(x=1,y=new Array(_-1);x<_;x++)y[x-1]=arguments[x];g.fn.apply(g.context,y)}else{var b=g.length,v;for(x=0;x<b;x++)switch(g[x].once&&this.removeListener(h,g[x].fn,void 0,!0),_){case 1:g[x].fn.call(g[x].context);break;case 2:g[x].fn.call(g[x].context,c);break;case 3:g[x].fn.call(g[x].context,c,u);break;case 4:g[x].fn.call(g[x].context,c,u,d);break;default:if(!y)for(v=1,y=new Array(_-1);v<_;v++)y[v-1]=arguments[v];g[x].fn.apply(g[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 m=0,g=[],_=p.length;m<_;m++)(p[m].fn!==c||d&&!p[m].once||u&&p[m].context!==u)&&g.push(p[m]);g.length?this._events[f]=g.length===1?g[0]:g: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})(an)),an.exports}var jg=Vg();const Re=$g(jg),wu=Math.PI*2,Tu=180/Math.PI,Su=Math.PI/180;class ce{constructor(e=0,t=0){this.x=0,this.y=0,this.x=e,this.y=t}clone(){return new ce(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 ln.x=0,ln.y=0,ln}}const ln=new ce;class L{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 ce;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 ce;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(wu-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 L;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 qg.identity()}static get shared(){return Xg.identity()}}const Xg=new L,qg=new L,$t=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],Vt=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],jt=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],Xt=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],Xn=[],Mu=[],Pi=Math.sign;function Yg(){for(let i=0;i<16;i++){const e=[];Xn.push(e);for(let t=0;t<16;t++){const s=Pi($t[i]*$t[t]+jt[i]*Vt[t]),r=Pi(Vt[i]*$t[t]+Xt[i]*Vt[t]),n=Pi($t[i]*jt[t]+jt[i]*Xt[t]),o=Pi(Vt[i]*jt[t]+Xt[i]*Xt[t]);for(let a=0;a<16;a++)if($t[a]===s&&Vt[a]===r&&jt[a]===n&&Xt[a]===o){e.push(a);break}}}for(let i=0;i<16;i++){const e=new L;e.set($t[i],Vt[i],jt[i],Xt[i],0,0),Mu.push(e)}}Yg();const Q={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=>$t[i],uY:i=>Vt[i],vX:i=>jt[i],vY:i=>Xt[i],inv:i=>i&8?i&15:-i&7,add:(i,e)=>Xn[i][e],sub:(i,e)=>Xn[i][Q.inv(e)],rotate180:i=>i^4,isVertical:i=>(i&3)===2,byDirection:(i,e)=>Math.abs(i)*2<=Math.abs(e)?e>=0?Q.S:Q.N:Math.abs(e)*2<=Math.abs(i)?i>0?Q.E:Q.W:e>0?i>0?Q.SE:Q.SW:i>0?Q.NE:Q.NW,matrixAppendRotationInv:(i,e,t=0,s=0,r=0,n=0)=>{const o=Mu[Q.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,m=i.c,g=i.d;i.a=a*f+l*m,i.b=a*p+l*g,i.c=h*f+c*m,i.d=h*p+c*g,i.tx=u*f+d*m+i.tx,i.ty=u*p+d*g+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===Q.E?(s.set(r+l,n+h,o,a),s):t===Q.S?s.set(c-n-a+l,r+h,a,o):t===Q.W?s.set(c-r-o+l,u-n-a+h,o,a):t===Q.N?s.set(n+l,u-r-o+h,a,o):s.set(r+l,n+h,o,a)}},Ai=[new ce,new ce,new ce,new ce];class se{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 se(0,0,0,0)}clone(){return new se(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,m=a+c,g=a+n-c,_=l+c,y=l+o-c;return e>=u&&e<=d&&t>=f&&t<=p&&!(e>m&&e<g&&t>_&&t<y)}intersects(e,t){if(!t){const E=this.x<e.x?e.x:this.x;if((this.right>e.right?e.right:this.right)<=E)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=Ai[0].set(e.left,e.top),l=Ai[1].set(e.left,e.bottom),h=Ai[2].set(e.right,e.top),c=Ai[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,m=d*r+f*n,g=d*s+f*o,_=d*r+f*o;if(Math.max(p,m,g,_)<=d*a.x+f*a.y||Math.min(p,m,g,_)>=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 se),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 hn={default:-1};function oe(i="default"){return hn[i]===void 0&&(hn[i]=-1),++hn[i]}const Th=new Set,de="8.0.0",Cu="8.3.4",dt="8.21.0",ku="8.22.0",Cs={quiet:!1,noColor:!1},N=((i,e,t=3)=>{if(Cs.quiet||Th.has(e))return;let s=new Error().stack;const r=`${e}
|
|
3
3
|
Deprecated since v${i}`,n=typeof console.groupCollapsed=="function"&&!Cs.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))),Th.add(e)});Object.defineProperties(N,{quiet:{get:()=>Cs.quiet,set:i=>{Cs.quiet=i},enumerable:!0,configurable:!1},noColor:{get:()=>Cs.noColor,set:i=>{Cs.noColor=i},enumerable:!0,configurable:!1}});const Vo=()=>{};function ar(i){return i.endsWith("int")}function rs(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 ns(i){return!(i&i-1)&&!!i}function jo(i){const e={};for(const t in i)i[t]!==void 0&&(e[t]=i[t]);return e}const Sh=Object.create(null);function Kg(i){const e=Sh[i];return e===void 0&&(Sh[i]=oe("resource")),e}const Eu=class Pu extends Re{constructor(e={}){super(),this._resourceType="textureSampler",this._maxAnisotropy=1,this.destroyed=!1,e={...Pu.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){N(de,"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=Kg(e),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};Eu.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let Lt=Eu;const Au=class Ru 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={...Ru.defaultOptions,...e};const s=Zg(e),r=s==="3d"||s==="1d"?s:"2d";Qg(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 Lt(jo(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=ns(this.pixelWidth)&&ns(this.pixelHeight)}static test(e){throw new Error("Unimplemented")}};Au.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",arrayLayerCount:1,mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};let ue=Au;function Zg(i){return i.viewDimension?i.viewDimension:i.depth?"3d":i.arrayLayerCount>1?"2d-array":"2d"}function Qg(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&&N(ku,"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 br extends ue{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=ar(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}}br.extension=S.TextureSource;const Mh=new L;class Xo{constructor(e,t){this.mapCoord=new L,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&&(Mh.set(s.width/r.width,0,0,s.height/r.height,-r.x/r.width,-r.y/r.height),this.mapCoord.append(Mh));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 H 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 se,this.noFrame=!1,this.dynamic=!1,this.isTexture=!0,this.label=t,this.source=e?.source??new ue,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 Xo(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=Q.add(h,Q.NW),e.x0=d+c*Q.uX(h),e.y0=f+u*Q.uY(h),h=Q.add(h,2),e.x1=d+c*Q.uX(h),e.y1=f+u*Q.uY(h),h=Q.add(h,2),e.x2=d+c*Q.uX(h),e.y2=f+u*Q.uY(h),h=Q.add(h,2),e.x3=d+c*Q.uX(h),e.y3=f+u*Q.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 N(de,"Texture.baseTexture is now Texture.source"),this._source}}H.EMPTY=new H({label:"EMPTY",source:new ue({label:"EMPTY"})});H.EMPTY.destroy=Vo;H.WHITE=new H({source:new br({resource:new Uint8Array([255,255,255,255]),width:1,height:1,alphaMode:"premultiply-alpha-on-upload",label:"WHITE"}),label:"WHITE"});H.WHITE.destroy=Vo;function qo(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 Ch=new L;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=Ch,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 se);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=Ch,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,m=this.maxY,g=o*e+l*t+c,_=a*e+h*t+u;g<d&&(d=g),_<f&&(f=_),g>p&&(p=g),_>m&&(m=_),g=o*s+l*t+c,_=a*s+h*t+u,g<d&&(d=g),_<f&&(f=_),g>p&&(p=g),_>m&&(m=_),g=o*e+l*r+c,_=a*e+h*r+u,g<d&&(d=g),_<f&&(f=_),g>p&&(p=g),_>m&&(m=_),g=o*s+l*r+c,_=a*s+h*r+u,g<d&&(d=g),_<f&&(f=_),g>p&&(p=g),_>m&&(m=_),this.minX=d,this.minY=f,this.maxX=p,this.maxY=m}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 m=t;m<s;m+=2){const g=e[m],_=e[m+1],y=h*g+u*_+f,x=c*g+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 Jg={grad:.9,turn:360,rad:360/(2*Math.PI)},vt=function(i){return typeof i=="string"?i.length>0:typeof i=="number"},Ce=function(i,e,t){return e===void 0&&(e=0),t===void 0&&(t=Math.pow(10,e)),Math.round(t*i)/t+0},Ke=function(i,e,t){return e===void 0&&(e=0),t===void 0&&(t=1),i>t?t:i>e?i:e},Bu=function(i){return(i=isFinite(i)?i%360:0)>0?i:i+360},kh=function(i){return{r:Ke(i.r,0,255),g:Ke(i.g,0,255),b:Ke(i.b,0,255),a:Ke(i.a)}},cn=function(i){return{r:Ce(i.r),g:Ce(i.g),b:Ce(i.b),a:Ce(i.a,3)}},e_=/^#([0-9a-f]{3,8})$/i,Ri=function(i){var e=i.toString(16);return e.length<2?"0"+e:e},Iu=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}},Gu=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}},Eh=function(i){return{h:Bu(i.h),s:Ke(i.s,0,100),l:Ke(i.l,0,100),a:Ke(i.a)}},Ph=function(i){return{h:Ce(i.h),s:Ce(i.s),l:Ce(i.l),a:Ce(i.a,3)}},Ah=function(i){return Gu((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},ii=function(i){return{h:(e=Iu(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},t_=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,s_=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,i_=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,r_=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,qn={string:[[function(i){var e=e_.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?Ce(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?Ce(parseInt(i.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(i){var e=i_.exec(i)||r_.exec(i);return e?e[2]!==e[4]||e[4]!==e[6]?null:kh({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=t_.exec(i)||s_.exec(i);if(!e)return null;var t,s,r=Eh({h:(t=e[1],s=e[2],s===void 0&&(s="deg"),Number(t)*(Jg[s]||1)),s:Number(e[3]),l:Number(e[4]),a:e[5]===void 0?1:Number(e[5])/(e[6]?100:1)});return Ah(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 vt(e)&&vt(t)&&vt(s)?kh({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(!vt(e)||!vt(t)||!vt(s))return null;var o=Eh({h:Number(e),s:Number(t),l:Number(s),a:Number(n)});return Ah(o)},"hsl"],[function(i){var e=i.h,t=i.s,s=i.v,r=i.a,n=r===void 0?1:r;if(!vt(e)||!vt(t)||!vt(s))return null;var o=(function(a){return{h:Bu(a.h),s:Ke(a.s,0,100),v:Ke(a.v,0,100),a:Ke(a.a)}})({h:Number(e),s:Number(t),v:Number(s),a:Number(n)});return Gu(o)},"hsv"]]},Rh=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]},n_=function(i){return typeof i=="string"?Rh(i.trim(),qn.string):typeof i=="object"&&i!==null?Rh(i,qn.object):[null,void 0]},un=function(i,e){var t=ii(i);return{h:t.h,s:Ke(t.s+100*e,0,100),l:t.l,a:t.a}},dn=function(i){return(299*i.r+587*i.g+114*i.b)/1e3/255},Bh=function(i,e){var t=ii(i);return{h:t.h,s:t.s,l:Ke(t.l+100*e,0,100),a:t.a}},Yn=(function(){function i(e){this.parsed=n_(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 Ce(dn(this.rgba),2)},i.prototype.isDark=function(){return dn(this.rgba)<.5},i.prototype.isLight=function(){return dn(this.rgba)>=.5},i.prototype.toHex=function(){return e=cn(this.rgba),t=e.r,s=e.g,r=e.b,o=(n=e.a)<1?Ri(Ce(255*n)):"","#"+Ri(t)+Ri(s)+Ri(r)+o;var e,t,s,r,n,o},i.prototype.toRgb=function(){return cn(this.rgba)},i.prototype.toRgbString=function(){return e=cn(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 Ph(ii(this.rgba))},i.prototype.toHslString=function(){return e=Ph(ii(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=Iu(this.rgba),{h:Ce(e.h),s:Ce(e.s),v:Ce(e.v),a:Ce(e.a,3)};var e},i.prototype.invert=function(){return ht({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),ht(un(this.rgba,e))},i.prototype.desaturate=function(e){return e===void 0&&(e=.1),ht(un(this.rgba,-e))},i.prototype.grayscale=function(){return ht(un(this.rgba,-1))},i.prototype.lighten=function(e){return e===void 0&&(e=.1),ht(Bh(this.rgba,e))},i.prototype.darken=function(e){return e===void 0&&(e=.1),ht(Bh(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"?ht({r:(t=this.rgba).r,g:t.g,b:t.b,a:e}):Ce(this.rgba.a,3);var t},i.prototype.hue=function(e){var t=ii(this.rgba);return typeof e=="number"?ht({h:e,s:t.s,l:t.l,a:t.a}):Ce(t.h)},i.prototype.isEqual=function(e){return this.toHex()===ht(e).toHex()},i})(),ht=function(i){return i instanceof Yn?i:new Yn(i)},Ih=[],o_=function(i){i.forEach(function(e){Ih.indexOf(e)<0&&(e(Yn,qn),Ih.push(e))})};function a_(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 m=(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));m<u&&(u=m,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"])}o_([a_]);const As=class ei{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 ei)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]=ei._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=ei.HEX_PATTERN.exec(e);a&&(e=`#${a[2]}`)}const o=ht(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 ei||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}};As.shared=new As;As._temp=new As;As.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let le=As;const Du={cullArea:null,cullable:!1,cullableChildren:!0};let fn=0;const Gh=500;function z(...i){fn!==Gh&&(fn++,fn===Gh?console.warn("PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS."):console.warn("PixiJS Warning: ",...i))}const us={_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 Fu{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 Ou{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 Fu(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 Ou;us.register(Se);const Lu={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){N("v8.6.0","cacheAsBitmap is deprecated, use cacheAsTexture instead."),this.cacheAsTexture(i)}};function Yo(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 Uu={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)}Yo(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||N(de,"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)}},Nu={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 ui{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 zu{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 lr=new zu;Y.handleByList(S.MaskEffect,lr._effectClasses);const Hu={_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),lr.returnMaskEffect(e),this._maskEffect=null),i!=null&&(this._maskEffect=lr.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 ui);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 ui),this._filterEffect.filterArea=i},get filterArea(){return this._filterEffect?.filterArea}},Wu={label:null,get name(){return N(de,"Container.name property has been removed, use Container.label instead"),this.label},set name(i){N(de,"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(L),pt=Se.getPool(Ee),l_=new L,$u={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=pt.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(l_).invert()),e.addBounds(s),pt.return(s)}else this.renderGroup&&(e.addBounds(s,this.relativeGroupTransform),pt.return(s))}};function vr(i,e,t){t.clear();let s,r;return i.parent?e?s=i.parent.worldTransform:(r=Ae.get().identity(),s=wr(i,r)):s=L.IDENTITY,Vu(i,t,s,e),r&&Ae.return(r),t.isValid||t.set(0,0,0,0),t}function Vu(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=pt.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++)Vu(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,L.IDENTITY),pt.return(e)}s||Ae.return(r)}function wr(i,e){const t=i.parent;return t&&(wr(t,e),t.updateLocalTransform(),e.append(t.localTransform)),e}function ts(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 Dh=16777215;function di(i,e){return i===Dh?e:e===Dh?i:ts(i,e)}function ss(i){return((i&255)<<16)+(i&65280)+(i>>16&255)}const ju={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 L,e){if(e)return i.copyFrom(this.worldTransform);this.updateLocalTransform();const t=wr(this,Ae.get().identity());return i.appendFrom(this.localTransform,t),Ae.return(t),i},getGlobalTint(i){if(i)return this.renderGroup?ss(this.renderGroup.worldColor):this.parentRenderGroup?ss(di(this.localColor,this.parentRenderGroup.worldColor)):this.tint;let e=this.localColor,t=this.parent;for(;t;)e=di(e,t.localColor),t=t.parent;return ss(e)}};function Tr(i,e,t){return e.clear(),t||(t=L.IDENTITY),Xu(i,e,t,i,!0),e.isValid||e.set(0,0,0,0),e}function Xu(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=pt.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++)Xu(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,L.IDENTITY),pt.return(e)}Ae.return(n)}function Ko(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&&Ko(r,e)}return e.didChange}const h_=new L,qu={_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),Ko(this,i),i.didChange&&Tr(this,i.localBounds,h_),i.localBounds},getBounds(i,e){return vr(this,i,e||new Ee)}},Yu={_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}},Ku={_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(c_))}};function c_(i,e){return i._zIndex-e._zIndex}const Zu={getGlobalPosition(i=new ce,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 Sr{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 Zo{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 u_=0;const pn=32767,d_=4294967296,f_=8589934592,Fh=Object.create(null);let p_=0;function m_(i){const e=Fh[i];return e!==void 0?e:Fh[i]=p_++}function g_(i,e,t,s,r,n){return(i<<17)+(e<<2)+((s?1:0)<<1)+(t?1:0)+(n==="nearest"?1:0)*d_+m_(r)*f_}class Qu{constructor(e){this._buckets=new Map,this._poolKey=Object.create(null),this._poolStyle=Object.create(null),this._screens=new Zo,this._enableFullScreen=!1,this.textureOptions=e||{}}get textureStyle(){return N(dt,"TexturePool.textureStyle is no longer used, pooled textures carry their own style. Pass scaleMode in the request instead."),this._textureStyle||(this._textureStyle=new Lt(this.textureOptions)),this._textureStyle}set textureStyle(e){N(dt,"TexturePool.textureStyle is no longer used, pooled textures carry their own style. Pass scaleMode in the request instead."),this._textureStyle=e}get enableFullScreen(){return N(dt,"TexturePool.enableFullScreen is no longer used, the pool sizes textures to the screens registered with setScreenSize."),this._enableFullScreen}set enableFullScreen(e){N(dt,"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"&&(N(dt,"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??ue.defaultOptions.format,r=t.scaleMode??this.textureOptions.scaleMode??Lt.defaultOptions.scaleMode,n=new ue({...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 H({source:n,label:`texturePool_${u_++}`})}getOptimalTexture(...e){let t=e[0];typeof t=="number"&&(N(dt,"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??ue.defaultOptions.format,h=t.scaleMode??this.textureOptions.scaleMode??Lt.defaultOptions.scaleMode,{width:c,height:u}=this.getOptimalSize(s,r,n);(c>pn||u>pn)&&z(`TexturePool: ${c}x${u} is larger than the ${pn}px pool key limit, textures of this size may be pooled together`);const d=g_(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=rs(r),a=this._screens.getFittingWidth(r),l=rs(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;(ns(r)||this._screens.hasWidth(r))&&(ns(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;us.register(Te);class hr{constructor(){this.renderPipeId="renderGroup",this.root=null,this.canBundle=!1,this.renderGroupParent=null,this.renderGroupChildren=[],this.worldTransform=new L,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 Sr,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 L),this._inverseWorldTransform.copyFrom(this.worldTransform).invert())}get textureOffsetInverseTransform(){return(this._matrixDirty&2)===0?this._textureOffsetInverseTransform:(this._matrixDirty&=-3,this._textureOffsetInverseTransform||(this._textureOffsetInverseTransform=new L),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 L),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 Ju(i,e,t={}){for(const s in e)!t[s]&&e[s]!==void 0&&(i[s]=e[s])}const mn=new Me(null),Bi=new Me(null),gn=new Me(null,1,1),Ii=new Me(null),fi=1,Mr=2,ks=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 L,this.relativeGroupTransform=new L,this.groupTransform=this.relativeGroupTransform,this.destroyed=!1,this._position=new Me(this,0,0),this._scale=gn,this._pivot=Bi,this._origin=Ii,this._skew=mn,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=[],Ju(this,e,{children:!0,parent:!0,effects:!0}),e.children?.forEach(t=>this.addChild(t)),e.parent?.addChild(this)}static mixin(e){N("8.8.0","Container.mixin is deprecated, please use extensions.mixin instead."),Y.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||N(de,"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(hr,this),this.groupTransform=L.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 L),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*Tu}set angle(e){this.rotation=e*Su}get pivot(){return this._pivot===Bi&&(this._pivot=new Me(this,0,0)),this._pivot}set pivot(e){this._pivot===Bi&&(this._pivot=new Me(this,0,0),this._origin!==Ii&&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===mn&&(this._skew=new Me(this,0,0)),this._skew}set skew(e){this._skew===mn&&(this._skew=new Me(this,0,0)),this._skew.copyFrom(e)}get scale(){return this._scale===gn&&(this._scale=new Me(this,1,1)),this._scale}set scale(e){this._scale===gn&&(this._scale=new Me(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===Ii&&(this._origin=new Me(this,0,0)),this._origin}set origin(e){this._origin===Ii&&(this._origin=new Me(this,0,0),this._pivot!==Bi&&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|=fi,this._onUpdate())}get alpha(){return this.localAlpha}set tint(e){const s=le.shared.setValue(e??16777215).toBgrNumber();s!==this.localColor&&(this.localColor=s,this._updateFlags|=fi,this._onUpdate())}get tint(){return ss(this.localColor)}set blendMode(e){this.localBlendMode!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=Mr,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|=ks,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|=ks,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|=ks,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}}Y.mixin(_e,Uu,$u,Zu,Yu,qu,Hu,Wu,Ku,Du,Lu,ju,Nu);class Cr 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 os extends Cr{constructor(e=H.EMPTY){e instanceof H&&(e={texture:e});const{texture:t=H.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 Me({_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 H?new os(e):new os(H.from(e,t))}set texture(e){e||(e=H.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 qo(this._visualBounds,this._anchor,this._texture),this._visualBounds}get sourceBounds(){return N("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 __=new Ee;function Qo(i,e,t){const s=__;i.measurable=!0,vr(i,t,s),e.addBoundsMask(s),i.measurable=!1}function Jo(i,e,t){const s=pt.get();i.measurable=!0;const r=Ae.get().identity(),n=ed(i,t,r);Tr(i,s,n),i.measurable=!1,e.addBoundsMask(s),Ae.return(r),pt.return(s)}function ed(i,e,t){return i?(i!==e&&(ed(i.parent,e,t),i.updateLocalTransform(),t.append(i.localTransform)),t):(z("Mask bounds, renderable is not inside the root container"),t)}class ea{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 os),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||Qo(this.mask,e,t)}addLocalBounds(e,t){Jo(this.mask,e,t)}containsPoint(e,t){const s=this.mask;return t(s,e)}destroy(){this.reset()}static test(e){return e instanceof os}}ea.extension=S.MaskEffect;class ta{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"}}ta.extension=S.MaskEffect;class sa{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){Qo(this.mask,e,t)}addLocalBounds(e,t){Jo(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}}sa.extension=S.MaskEffect;const td={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 Oh=td;const te={get(){return Oh},set(i){Oh=i}};class je extends ue{constructor(e){e.resource||(e.resource=te.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"))}}je.extension=S.TextureSource;class pi extends ue{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}}pi.extension=S.TextureSource;var as=(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))(as||{});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 sd=class ze{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/ze.targetFPMS,this.elapsedMS=1/ze.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=as.NORMAL){return this._addListener(new Qi(e,t,s))}addOnce(e,t,s=as.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*ze.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,ze.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(!ze._shared){const e=ze._shared=new ze;e.autoStart=!0,e._protected=!0}return ze._shared}static get system(){if(!ze._system){const e=ze._system=new ze;e.autoStart=!0,e._protected=!0}return ze._system}};sd.targetFPMS=.06;let $e=sd,_n;async function id(){return _n??(_n=(async()=>{const e=te.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"})()),_n}const kr=class rd extends ue{constructor(e){super(e),this.isReady=!1,this.uploadMethodId="video",e={...rd.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=$e.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 id(),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&&($e.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||($e.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&($e.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(e){return globalThis.HTMLVideoElement&&e instanceof HTMLVideoElement}};kr.extension=S.TextureSource;kr.defaultOptions={...ue.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1};kr.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let nd=kr;const Kt=(i,e,t=!1)=>(Array.isArray(i)||(i=[i]),e?i.map(s=>typeof s=="string"||t?e(s):s):i);class y_{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=Kt(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 Zt=new y_,Kn=[];Y.handleByList(S.TextureSource,Kn);function od(i={}){const e=i&&i.resource,t=e?i.resource:i,s=e?i:{resource:i};for(let r=0;r<Kn.length;r++){const n=Kn[r];if(n.test(t))return new n(s)}throw new Error(`Could not find a source type for resource: ${s.resource}`)}function ad(i={},e=!1){const t=i&&i.resource,s=t?i.resource:i,r=t?i:{resource:i};if(!e&&Zt.has(s))return Zt.get(s);const n=new H({source:od(r)});return n.on("destroy",()=>{Zt.has(s)&&Zt.remove(s)}),e||Zt.set(s,n),n}function ld(i,e=!1){return typeof i=="string"?Zt.get(i):i instanceof ue?new H({source:i}):ad(i,e)}H.from=ld;ue.from=od;Y.add(ea,ta,sa,nd,pi,je,br);var ia=(i=>(i[i.Low=0]="Low",i[i.Normal=1]="Normal",i[i.High=2]="High",i))(ia||{});function st(i){if(typeof i!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(i)}`)}function Ws(i){return i.split("?")[0].split("#")[0]}function x_(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function b_(i,e,t){return i.replace(new RegExp(x_(e),"g"),t)}function v_(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 Rs={toPosix(i){return b_(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){st(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(st(i),this.isDataUrl(i)||this.isBlobUrl(i))return i;const s=Ws(this.toPosix(e??te.get().getBaseUrl())),r=Ws(this.toPosix(t??this.rootname(s)));return i=this.toPosix(i),i.startsWith("/")?Rs.join(r,i.slice(1)):this.isAbsolute(i)?i:this.join(s,i)},normalize(i){if(st(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=v_(i),i.length>0&&s&&(i+="/"),t?`/${i}`:e+i},isAbsolute(i){return st(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(st(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(st(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){st(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){st(i),e&&st(e),i=Ws(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){st(i),i=Ws(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){st(i);const e={root:"",dir:"",base:"",ext:"",name:""};if(i.length===0)return e;i=Ws(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 hd(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?hd(i.replace(s[t],a),e,t+1,s,r):r.push(i.replace(s[t],a))}}function cd(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)}),hd(i,r,0,t,s)}else s.push(i);return s}const Zn=i=>!Array.isArray(i);class ra{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 Kt(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`)},Kt(t).forEach(n=>{const{src:o}=n;let{data:a,format:l,loadParser:h,parser:c}=n;const u=Kt(o).map(m=>typeof m=="string"?cd(m):Array.isArray(m)?m:[m]),d=this.getAlias(n);Array.isArray(d)?d.forEach(s):s(d);const f=[],p=m=>{const g=this._parsers.find(_=>_.test(m));return{src:m,...g?.parse(m)}};u.forEach(m=>{m.forEach(g=>{let _={};if(typeof g!="object"?_=p(g):(a=g.data??a,l=g.format??l,(g.loadParser||g.parser)&&(h=g.loadParser??h,c=g.parser??c),_={...p(g.src),...g}),!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(m=>{this._assetMap[m]=f})})}resolveBundle(e){const t=Zn(e);e=Kt(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=Zn(e);e=Kt(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=Rs.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??ud(e.src),l!==void 0&&(e.progressSize=l),e}}ra.RETINA_PREFIX=/@([0-9\.]+)x/;function ud(i){return i.split(".").pop().split("?").shift().split("#").shift()}const Qn=(i,e)=>{const t=e.split("?")[1];return t&&(i+=`?${t}`),i},dd=class ti{constructor(e,t){this.linkedSheets=[];let s=e;e?.source instanceof ue&&(s={texture:e,data:t});const{texture:r,data:n,cachePrefix:o=""}=s;this.cachePrefix=o,this._texture=r instanceof H?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<=ti.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:ti.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 se(0,0,Math.floor(c.w)/this.resolution,Math.floor(c.h)/this.resolution);o.rotated?l=new se(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 se(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 se(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 H({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*ti.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*ti.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=[]}};dd.BATCH_SIZE=1e3;let Jn=dd;const w_=["jpg","png","jpeg","avif","webp","basis","etc2","bc7","bc6h","bc5","bc4","bc3","bc2","bc1","eac","astc"];function fd(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=Rs.dirname(i[0]);e.linkedSheets.forEach((n,o)=>{const a=fd([`${r}/${e.data.meta.related_multi_packs[o]}`],n,!0);Object.assign(s,a)})}return s}const pd={extension:S.Asset,cache:{test:i=>i instanceof Jn,getCacheableAssets:(i,e)=>fd(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"&&w_.includes(r)},parse:i=>{const e=i.split(".");return{resolution:parseFloat(ra.RETINA_PREFIX.exec(i)?.[1]??"1"),format:e[e.length-2],src:i}}},loader:{name:"spritesheetLoader",id:"spritesheet",extension:{type:S.LoadParser,priority:ia.Normal,name:"spritesheetLoader"},async testParse(i,e){return Rs.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=Rs.dirname(e.src);a&&a.lastIndexOf("/")!==a.length-1&&(a+="/");let l;if(s instanceof H)l=s;else{const u=Qn(a+(r??i.meta.image),e.src);l=(await t.load([{src:u,data:n}]))[u]}const h=new Jn({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=Qn(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)}}};Y.add(pd);class na{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||$e.shared.add(this.updateTranslation,this,as.HIGH)}destroy(){this._observer?(this._observer.disconnect(),this._observer=null):this._tickerAttached&&$e.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 Ls{constructor(e){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=Ls.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new ce,this.page=new ce,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 yn=/iPhone/i,Lh=/iPod/i,Uh=/iPad/i,Nh=/\biOS-universal(?:.+)Mac\b/i,xn=/\bAndroid(?:.+)Mobile\b/i,zh=/Android/i,ms=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,Gi=/Silk/i,wt=/Windows Phone/i,Hh=/\bWindows(?:.+)ARM\b/i,Wh=/BlackBerry/i,$h=/BB10/i,Vh=/Opera Mini/i,jh=/\b(CriOS|Chrome)(?:.+)Mobile/i,Xh=/Mobile(?:.+)Firefox\b/i,qh=function(i){return typeof i<"u"&&i.platform==="MacIntel"&&typeof i.maxTouchPoints=="number"&&i.maxTouchPoints>1&&typeof MSStream>"u"};function T_(i){return function(e){return e.test(i)}}function Yh(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_(t),n={apple:{phone:r(yn)&&!r(wt),ipod:r(Lh),tablet:!r(yn)&&(r(Uh)||qh(e))&&!r(wt),universal:r(Nh),device:(r(yn)||r(Lh)||r(Uh)||r(Nh)||qh(e))&&!r(wt)},amazon:{phone:r(ms),tablet:!r(ms)&&r(Gi),device:r(ms)||r(Gi)},android:{phone:!r(wt)&&r(ms)||!r(wt)&&r(xn),tablet:!r(wt)&&!r(ms)&&!r(xn)&&(r(Gi)||r(zh)),device:!r(wt)&&(r(ms)||r(Gi)||r(xn)||r(zh))||r(/\bokhttp\b/i)},windows:{phone:r(wt),tablet:r(Hh),device:r(wt)||r(Hh)},other:{blackberry:r(Wh),blackberry10:r($h),opera:r(Vh),firefox:r(Xh),chrome:r(jh),device:r(Wh)||r($h)||r(Vh)||r(Xh)||r(jh)},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 S_=Yh.default??Yh,md=S_(globalThis.navigator),M_=9,Kh=100,C_=0,k_=0,Zh=2,Qh=1,E_=-1e3,P_=-1e3,A_=2,oa=class gd{constructor(e,t=md){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=`${Qh}px`,e.style.height=`${Qh}px`,e.style.position="absolute",e.style.top=`${E_}px`,e.style.left=`${P_}px`,e.style.zIndex=A_.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=`${C_}px`,this._div.style.left=`${k_}px`,this._div.style.pointerEvents="none",this._div.style.zIndex=Zh.toString(),this._canvasObserver=new na({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:{...gd.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,Yo(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=`
|
|
@@ -250,7 +250,7 @@ ${r.join(`
|
|
|
250
250
|
{
|
|
251
251
|
return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
|
|
252
252
|
}
|
|
253
|
-
`}},dc={};function Ma(i){let e=dc[i];if(e)return e;const t=new Int32Array(i);for(let s=0;s<i;s++)t[s]=s;return e=dc[i]=new Qe({uTextures:{value:t,type:"i32",size:i}},{isStatic:!0}),e}class yo extends _t{constructor(e){const t=Ir({name:"batch",bits:[wa,Sa(e),Dr]}),s=Br({name:"batch",bits:[va,Ta(e),Gr]});super({glProgram:t,gpuProgram:s,resources:{batchSamplers:Ma(e)}}),this.maxTextures=e}}let Ks=null;const _f=class yf extends sf{constructor(e){super(e),this.geometry=new nf,this.name=yf.extension.name,this.vertexSize=6,Ks??(Ks=new yo(e.maxTextures)),this.shader=Ks}packAttributes(e,t,s,r,n){const o=n<<16|e.roundPixels&65535,a=e.transform,l=a.a,h=a.b,c=a.c,u=a.d,d=a.tx,f=a.ty,{positions:p,uvs:m}=e,g=e.color,_=e.attributeOffset,y=_+e.attributeSize;for(let x=_;x<y;x++){const b=x*2,v=p[b],w=p[b+1];t[r++]=l*v+c*w+d,t[r++]=u*w+h*v+f,t[r++]=m[b],t[r++]=m[b+1],s[r++]=g,s[r++]=o}}packQuadAttributes(e,t,s,r,n){const o=e.texture,a=e.transform,l=a.a,h=a.b,c=a.c,u=a.d,d=a.tx,f=a.ty,p=e.bounds,m=p.maxX,g=p.minX,_=p.maxY,y=p.minY,x=o.uvs,b=e.color,v=n<<16|e.roundPixels&65535;t[r+0]=l*g+c*y+d,t[r+1]=u*y+h*g+f,t[r+2]=x.x0,t[r+3]=x.y0,s[r+4]=b,s[r+5]=v,t[r+6]=l*m+c*y+d,t[r+7]=u*y+h*m+f,t[r+8]=x.x1,t[r+9]=x.y1,s[r+10]=b,s[r+11]=v,t[r+12]=l*m+c*_+d,t[r+13]=u*_+h*m+f,t[r+14]=x.x2,t[r+15]=x.y2,s[r+16]=b,s[r+17]=v,t[r+18]=l*g+c*_+d,t[r+19]=u*_+h*g+f,t[r+20]=x.x3,t[r+21]=x.y3,s[r+22]=b,s[r+23]=v}_updateMaxTextures(e){this.shader.maxTextures!==e&&(Ks=new yo(e),this.shader=Ks)}destroy(){this.shader=null,super.destroy()}};_f.extension={type:[S.Batcher],name:"default"};let Fr=_f;class lt{constructor(e){this.items=Object.create(null);const{renderer:t,type:s,onUnload:r,priority:n,name:o}=e;this._renderer=t,t.gc.addResourceHash(this,"items",s,n??0),this._onUnload=r,this.name=o}add(e){return this.items[e.uid]?!1:(this.items[e.uid]=e,e.once("unload",this.remove,this),e._gcLastUsed=this._renderer.gc.now,!0)}remove(e,...t){if(!this.items[e.uid])return;const s=e._gpuData[this._renderer.uid];s&&(this._onUnload?.(e,...t),e.off("unload",this.remove,this),s.destroy(),e._gpuData[this._renderer.uid]=null,this.items[e.uid]=null)}removeAll(...e){Object.values(this.items).forEach(t=>t&&this.remove(t,...e))}destroy(...e){this.removeAll(...e),this.items=Object.create(null),this._renderer=null,this._onUnload=null}}function xf(i,e,t,s,r,n,o,a=null){let l=0;t*=e,r*=n;const h=a.a,c=a.b,u=a.c,d=a.d,f=a.tx,p=a.ty;for(;l<o;){const m=i[t],g=i[t+1];s[r]=h*m+u*g+f,s[r+1]=c*m+d*g+p,r+=n,t+=e,l++}}function bf(i,e,t,s){let r=0;for(e*=t;r<s;)i[e]=0,i[e+1]=0,e+=t,r++}function Ca(i,e,t,s,r){const n=e.a,o=e.b,a=e.c,l=e.d,h=e.tx,c=e.ty;t||(t=0),s||(s=2),r||(r=i.length/s-t);let u=t*s;for(let d=0;d<r;d++){const f=i[u],p=i[u+1];i[u]=n*f+a*p+h,i[u+1]=o*f+l*p+c,u+=s}}const k0=new L;class Or{constructor(){this.packAsQuad=!1,this.batcherName="default",this.topology="triangle-list",this.applyTransform=!0,this.roundPixels=0,this._batcher=null,this._batch=null}get uvs(){return this.geometryData.uvs}get positions(){return this.geometryData.vertices}get indices(){return this.geometryData.indices}get blendMode(){return this.renderable&&this.applyTransform?this.renderable.groupBlendMode:"normal"}get color(){const e=this.baseColor,t=e>>16|e&65280|(e&255)<<16,s=this.renderable;return s?ts(t,s.groupColor)+(this.alpha*s.groupAlpha*255<<24):t+(this.alpha*255<<24)}get transform(){return this.renderable?.groupTransform||k0}copyTo(e){e.indexOffset=this.indexOffset,e.indexSize=this.indexSize,e.attributeOffset=this.attributeOffset,e.attributeSize=this.attributeSize,e.baseColor=this.baseColor,e.alpha=this.alpha,e.texture=this.texture,e.geometryData=this.geometryData,e.topology=this.topology}reset(){this.applyTransform=!0,this.renderable=null,this.topology="triangle-list"}destroy(){this.renderable=null,this.texture=null,this.geometryData=null,this._batcher=null,this._batch=null}}const Is={extension:{type:S.ShapeBuilder,name:"circle"},build(i,e){let t,s,r,n,o,a;if(i.type==="circle"){const b=i;if(o=a=b.radius,o<=0)return!1;t=b.x,s=b.y,r=n=0}else if(i.type==="ellipse"){const b=i;if(o=b.halfWidth,a=b.halfHeight,o<=0||a<=0)return!1;t=b.x,s=b.y,r=n=0}else{const b=i,v=b.width/2,w=b.height/2;t=b.x+v,s=b.y+w,o=a=Math.max(0,Math.min(b.radius,Math.min(v,w))),r=v-o,n=w-a}if(r<0||n<0)return!1;const l=Math.ceil(2.3*Math.sqrt(o+a)),h=l*8+(r?4:0)+(n?4:0);if(h===0)return!1;if(l===0)return e[0]=e[6]=t+r,e[1]=e[3]=s+n,e[2]=e[4]=t-r,e[5]=e[7]=s-n,!0;let c=0,u=l*4+(r?2:0)+2,d=u,f=h,p=r+o,m=n,g=t+p,_=t-p,y=s+m;if(e[c++]=g,e[c++]=y,e[--u]=y,e[--u]=_,n){const b=s-m;e[d++]=_,e[d++]=b,e[--f]=b,e[--f]=g}for(let b=1;b<l;b++){const v=Math.PI/2*(b/l),w=r+Math.cos(v)*o,T=n+Math.sin(v)*a,E=t+w,P=t-w,A=s+T,k=s-T;e[c++]=E,e[c++]=A,e[--u]=A,e[--u]=P,e[d++]=P,e[d++]=k,e[--f]=k,e[--f]=E}p=r,m=n+a,g=t+p,_=t-p,y=s+m;const x=s-m;return e[c++]=g,e[c++]=y,e[--f]=x,e[--f]=g,r&&(e[c++]=_,e[c++]=y,e[--f]=x,e[--f]=_),!0},triangulate(i,e,t,s,r,n){if(i.length===0)return;let o=0,a=0;for(let c=0;c<i.length;c+=2)o+=i[c],a+=i[c+1];o/=i.length/2,a/=i.length/2;let l=s;e[l*t]=o,e[l*t+1]=a;const h=l++;for(let c=0;c<i.length;c+=2)e[l*t]=i[c],e[l*t+1]=i[c+1],c>0&&(r[n++]=l,r[n++]=h,r[n++]=l-1),l++;r[n++]=h+1,r[n++]=h,r[n++]=l-1}},vf={...Is,extension:{...Is.extension,name:"ellipse"}},wf={...Is,extension:{...Is.extension,name:"roundedRectangle"}},ka=1e-4,xo=1e-4;function fc(i,e,t,s,r,n,o,a){const l=i-t*r,h=e-s*r,c=i+t*n,u=e+s*n;let d,f;o?(d=s,f=-t):(d=-s,f=t);const p=l+d,m=h+f,g=c+d,_=u+f;return a.push(p,m),a.push(g,_),2}function Ht(i,e,t,s,r,n,o,a){const l=t-i,h=s-e;let c=Math.atan2(l,h),u=Math.atan2(r-i,n-e);a&&c<u?c+=Math.PI*2:!a&&c>u&&(u+=Math.PI*2);let d=c;const f=u-c,p=Math.abs(f),m=Math.sqrt(l*l+h*h),g=(15*p*Math.sqrt(m)/Math.PI>>0)+1,_=f/g;if(d+=_,a){o.push(i,e),o.push(t,s);for(let y=1,x=d;y<g;y++,x+=_)o.push(i,e),o.push(i+Math.sin(x)*m,e+Math.cos(x)*m);o.push(i,e),o.push(r,n)}else{o.push(t,s),o.push(i,e);for(let y=1,x=d;y<g;y++,x+=_)o.push(i+Math.sin(x)*m,e+Math.cos(x)*m),o.push(i,e);o.push(r,n),o.push(i,e)}return g*2}function Lr(i,e,t,s,r,n){const o=ka;if(i.length===0)return;const a=e;let l=a.alignment;if(e.alignment!==.5){let R=ya(i);l=(l-.5)*R+.5}const h=new ce(i[0],i[1]),c=new ce(i[i.length-2],i[i.length-1]),u=s,d=Math.abs(h.x-c.x)<o&&Math.abs(h.y-c.y)<o;if(u){i=i.slice(),d&&(i.pop(),i.pop(),c.set(i[i.length-2],i[i.length-1]));const R=(h.x+c.x)*.5,O=(c.y+h.y)*.5;i.unshift(R,O),i.push(R,O)}const f=r,p=i.length/2;let m=i.length;const g=f.length/2,_=a.width/2,y=_*_,x=a.miterLimit*a.miterLimit;let b=i[0],v=i[1],w=i[2],T=i[3],E=0,P=0,A=-(v-T),k=b-w,I=0,G=0,F=Math.sqrt(A*A+k*k);A/=F,k/=F,A*=_,k*=_;const X=l,C=(1-X)*2,M=X*2;u||(a.cap==="round"?m+=Ht(b-A*(C-M)*.5,v-k*(C-M)*.5,b-A*C,v-k*C,b+A*M,v+k*M,f,!0)+2:a.cap==="square"&&(m+=fc(b,v,A,k,C,M,!0,f))),f.push(b-A*C,v-k*C),f.push(b+A*M,v+k*M);for(let R=1;R<p-1;++R){b=i[(R-1)*2],v=i[(R-1)*2+1],w=i[R*2],T=i[R*2+1],E=i[(R+1)*2],P=i[(R+1)*2+1],A=-(v-T),k=b-w,F=Math.sqrt(A*A+k*k),A/=F,k/=F,A*=_,k*=_,I=-(T-P),G=w-E,F=Math.sqrt(I*I+G*G),I/=F,G/=F,I*=_,G*=_;const O=w-b,U=v-T,q=w-E,J=P-T,ie=O*q+U*J,V=U*q-J*O,Je=V<0;if(Math.abs(V)<.001*Math.abs(ie)){f.push(w-A*C,T-k*C),f.push(w+A*M,T+k*M),ie>=0&&(a.join==="round"?m+=Ht(w,T,w-A*C,T-k*C,w-I*C,T-G*C,f,!1)+4:m+=2,f.push(w-I*M,T-G*M),f.push(w+I*C,T+G*C));continue}const Ei=(-A+b)*(-k+T)-(-A+w)*(-k+v),Ns=(-I+E)*(-G+T)-(-I+w)*(-G+P),zs=(O*Ns-q*Ei)/V,xt=(J*Ei-U*Ns)/V,Nt=(zs-w)*(zs-w)+(xt-T)*(xt-T),et=w+(zs-w)*C,Oe=T+(xt-T)*C,Le=w-(zs-w)*M,tt=T-(xt-T)*M,Gt=Math.min(O*O+U*U,q*q+J*J),bt=Je?C:M,Hs=Gt+bt*bt*y;Nt<=Hs?a.join==="bevel"||Nt/y>x?(Je?(f.push(et,Oe),f.push(w+A*M,T+k*M),f.push(et,Oe),f.push(w+I*M,T+G*M)):(f.push(w-A*C,T-k*C),f.push(Le,tt),f.push(w-I*C,T-G*C),f.push(Le,tt)),m+=2):a.join==="round"?Je?(f.push(et,Oe),f.push(w+A*M,T+k*M),m+=Ht(w,T,w+A*M,T+k*M,w+I*M,T+G*M,f,!0)+4,f.push(et,Oe),f.push(w+I*M,T+G*M)):(f.push(w-A*C,T-k*C),f.push(Le,tt),m+=Ht(w,T,w-A*C,T-k*C,w-I*C,T-G*C,f,!1)+4,f.push(w-I*C,T-G*C),f.push(Le,tt)):(f.push(et,Oe),f.push(Le,tt)):(f.push(w-A*C,T-k*C),f.push(w+A*M,T+k*M),a.join==="round"?Je?m+=Ht(w,T,w+A*M,T+k*M,w+I*M,T+G*M,f,!0)+2:m+=Ht(w,T,w-A*C,T-k*C,w-I*C,T-G*C,f,!1)+2:a.join==="miter"&&Nt/y<=x&&(Je?(f.push(Le,tt),f.push(Le,tt)):(f.push(et,Oe),f.push(et,Oe)),m+=2),f.push(w-I*C,T-G*C),f.push(w+I*M,T+G*M),m+=2)}b=i[(p-2)*2],v=i[(p-2)*2+1],w=i[(p-1)*2],T=i[(p-1)*2+1],A=-(v-T),k=b-w,F=Math.sqrt(A*A+k*k),A/=F,k/=F,A*=_,k*=_,f.push(w-A*C,T-k*C),f.push(w+A*M,T+k*M),u||(a.cap==="round"?m+=Ht(w-A*(C-M)*.5,T-k*(C-M)*.5,w-A*C,T-k*C,w+A*M,T+k*M,f,!1)+2:a.cap==="square"&&(m+=fc(w,T,A,k,C,M,!1,f)));const B=xo*xo;for(let R=g;R<m+g-2;++R)b=f[R*2],v=f[R*2+1],w=f[(R+1)*2],T=f[(R+1)*2+1],E=f[(R+2)*2],P=f[(R+2)*2+1],!(Math.abs(b*(T-P)+w*(P-v)+E*(v-T))<B)&&n.push(R,R+1,R+2)}function Tf(i,e,t,s){const r=ka;if(i.length===0)return;const n=i[0],o=i[1],a=i[i.length-2],l=i[i.length-1],h=e||Math.abs(n-a)<r&&Math.abs(o-l)<r,c=t,u=i.length/2,d=c.length/2;for(let f=0;f<u;f++)c.push(i[f*2]),c.push(i[f*2+1]);for(let f=0;f<u-1;f++)s.push(d+f,d+f+1);h&&s.push(d+u-1,d)}function Ea(i,e,t,s,r,n,o){const a=Nd(i,e,2);if(!a)return;for(let h=0;h<a.length;h+=3)n[o++]=a[h]+r,n[o++]=a[h+1]+r,n[o++]=a[h+2]+r;let l=r*s;for(let h=0;h<i.length;h+=2)t[l]=i[h],t[l+1]=i[h+1],l+=s}const E0=[],Sf={extension:{type:S.ShapeBuilder,name:"polygon"},build(i,e){for(let t=0;t<i.points.length;t++)e[t]=i.points[t];return!0},triangulate(i,e,t,s,r,n){Ea(i,E0,e,t,s,r,n)}},Mf={extension:{type:S.ShapeBuilder,name:"rectangle"},build(i,e){const t=i,s=t.x,r=t.y,n=t.width,o=t.height;return n>0&&o>0?(e[0]=s,e[1]=r,e[2]=s+n,e[3]=r,e[4]=s+n,e[5]=r+o,e[6]=s,e[7]=r+o,!0):!1},triangulate(i,e,t,s,r,n){let o=0;s*=t,e[s+o]=i[0],e[s+o+1]=i[1],o+=t,e[s+o]=i[2],e[s+o+1]=i[3],o+=t,e[s+o]=i[6],e[s+o+1]=i[7],o+=t,e[s+o]=i[4],e[s+o+1]=i[5],o+=t;const a=s/t;r[n++]=a,r[n++]=a+1,r[n++]=a+2,r[n++]=a+1,r[n++]=a+3,r[n++]=a+2}},Cf={extension:{type:S.ShapeBuilder,name:"triangle"},build(i,e){return e[0]=i.x,e[1]=i.y,e[2]=i.x2,e[3]=i.y2,e[4]=i.x3,e[5]=i.y3,!0},triangulate(i,e,t,s,r,n){let o=0;s*=t,e[s+o]=i[0],e[s+o+1]=i[1],o+=t,e[s+o]=i[2],e[s+o+1]=i[3],o+=t,e[s+o]=i[4],e[s+o+1]=i[5];const a=s/t;r[n++]=a,r[n++]=a+1,r[n++]=a+2}},pc=[{offset:0,color:"white"},{offset:1,color:"black"}],Pa=class bo{constructor(...e){this.uid=oe("fillGradient"),this._tick=0,this.type="linear",this.colorStops=[];let t=P0(e);t={...t.type==="radial"?bo.defaultRadialOptions:bo.defaultLinearOptions,...jo(t)},this._textureSize=t.textureSize,this._wrapMode=t.wrapMode,t.type==="radial"?(this.center=t.center,this.outerCenter=t.outerCenter??this.center,this.innerRadius=t.innerRadius,this.outerRadius=t.outerRadius,this.scale=t.scale,this.rotation=t.rotation):(this.start=t.start,this.end=t.end),this.textureSpace=t.textureSpace,this.type=t.type,t.colorStops.forEach(r=>{this.addColorStop(r.offset,r.color)})}addColorStop(e,t){return this.colorStops.push({offset:e,color:le.shared.setValue(t).toHexa()}),this}buildLinearGradient(){if(this.texture)return;let{x:e,y:t}=this.start,{x:s,y:r}=this.end,n=s-e,o=r-t;const a=n<0||o<0;if(this._wrapMode==="clamp-to-edge"){if(n<0){const g=e;e=s,s=g,n*=-1}if(o<0){const g=t;t=r,r=g,o*=-1}}const l=this.colorStops.length?this.colorStops:pc,h=this._textureSize,{canvas:c,context:u}=gc(h,1),d=a?u.createLinearGradient(this._textureSize,0,0,0):u.createLinearGradient(0,0,this._textureSize,0);mc(d,l),u.fillStyle=d,u.fillRect(0,0,h,1),this.texture=new H({source:new pi({resource:c,addressMode:this._wrapMode})});const f=Math.sqrt(n*n+o*o),p=Math.atan2(o,n),m=new L;m.scale(f/h,1),m.rotate(p),m.translate(e,t),this.textureSpace==="local"&&m.scale(h,h),this.transform=m}buildGradient(){this.texture||this._tick++,this.type==="linear"?this.buildLinearGradient():this.buildRadialGradient()}buildRadialGradient(){if(this.texture)return;const e=this.colorStops.length?this.colorStops:pc,t=this._textureSize,{canvas:s,context:r}=gc(t,t),{x:n,y:o}=this.center,{x:a,y:l}=this.outerCenter,h=this.innerRadius,c=this.outerRadius,u=a-c,d=l-c,f=t/(c*2),p=(n-u)*f,m=(o-d)*f,g=r.createRadialGradient(p,m,h*f,(a-u)*f,(l-d)*f,c*f);mc(g,e),r.fillStyle=e[e.length-1].color,r.fillRect(0,0,t,t),r.fillStyle=g,r.translate(p,m),r.rotate(this.rotation),r.scale(1,this.scale),r.translate(-p,-m),r.fillRect(0,0,t,t),this.texture=new H({source:new pi({resource:s,addressMode:this._wrapMode})});const _=new L;this.textureSpace==="local"?_.scale(2*c,2*c):_.scale(1/f,1/f),_.translate(u,d),this.transform=_}destroy(){this.texture?.destroy(!0),this.texture=null,this.transform=null,this.colorStops=[],this.start=null,this.end=null,this.center=null,this.outerCenter=null}get styleKey(){return`fill-gradient-${this.uid}-${this._tick}`}};Pa.defaultLinearOptions={start:{x:0,y:0},end:{x:0,y:1},colorStops:[],textureSpace:"local",type:"linear",textureSize:256,wrapMode:"clamp-to-edge"};Pa.defaultRadialOptions={center:{x:.5,y:.5},innerRadius:0,outerRadius:.5,colorStops:[],scale:1,rotation:0,textureSpace:"local",type:"radial",textureSize:256,wrapMode:"clamp-to-edge"};let Xe=Pa;function mc(i,e){for(let t=0;t<e.length;t++){const s=e[t];i.addColorStop(s.offset,s.color)}}function gc(i,e){const t=te.get().createCanvas(i,e),s=t.getContext("2d");return{canvas:t,context:s}}function P0(i){let e=i[0]??{};return(typeof e=="number"||i[1])&&(N("8.5.2","use options object instead"),e={type:"linear",start:{x:i[0],y:i[1]},end:{x:i[2],y:i[3]},textureSpace:i[4],textureSize:i[5]??Xe.defaultLinearOptions.textureSize}),e}const A0=new L,R0=new se,B0=new L;function Aa(i,e,t,s){const r=e.matrix?i.copyFrom(e.matrix).invert():i.identity();if(e.textureSpace==="local"){const o=t.getBounds(R0);e.width&&o.pad(e.width);const{x:a,y:l}=o,h=1/o.width,c=1/o.height,u=-a*h,d=-l*c,f=r.a,p=r.b,m=r.c,g=r.d;r.a*=h,r.b*=h,r.c*=c,r.d*=c,r.tx=u*f+d*m+r.tx,r.ty=u*p+d*g+r.ty}else if(e.texture.rotate){const{uvs:o,orig:a}=e.texture;r.scale(1/a.width,1/a.height),r.prepend(B0.set(o.x1-o.x0,o.y1-o.y0,o.x3-o.x0,o.y3-o.y0,o.x0,o.y0))}else r.translate(e.texture.frame.x,e.texture.frame.y),r.scale(1/e.texture.source.width,1/e.texture.source.height);const n=e.texture.source.style;return!(e.fill instanceof Xe)&&n.addressMode==="clamp-to-edge"&&(n.addressMode="repeat",n.update()),s&&r.append(A0.copyFrom(s).invert()),r}const ps={};Y.handleByMap(S.ShapeBuilder,ps);Y.add(Mf,Sf,Cf,Is,vf,wf);const I0=new se,G0=new L;function kf(i,e){const{geometryData:t,batches:s}=e;s.length=0,t.indices.length=0,t.vertices.length=0,t.uvs.length=0;for(let r=0;r<i.instructions.length;r++){const n=i.instructions[r];if(n.action==="texture")D0(n.data,s,t);else if(n.action==="fill"||n.action==="stroke"){const o=n.action==="stroke",a=n.data.path.shapePath,l=n.data.style,h=n.data.hole;o&&h&&_c(h.shapePath,l,!0,s,t),h&&(a.shapePrimitives[a.shapePrimitives.length-1].holes=h.shapePath.shapePrimitives),_c(a,l,o,s,t)}}}function D0(i,e,t){const s=[],r=ps.rectangle,n=I0;n.x=i.dx,n.y=i.dy,n.width=i.dw,n.height=i.dh;const o=i.transform;if(!r.build(n,s))return;const{vertices:a,uvs:l,indices:h}=t,c=h.length,u=a.length/2;o&&Ca(s,o),r.triangulate(s,a,2,u,h,c);const d=i.image,f=d.uvs;l.push(f.x0,f.y0,f.x1,f.y1,f.x3,f.y3,f.x2,f.y2);const p=Se.get(Or);p.indexOffset=c,p.indexSize=h.length-c,p.attributeOffset=u,p.attributeSize=a.length/2-u,p.baseColor=i.style,p.alpha=i.alpha,p.texture=d,p.geometryData=t,e.push(p)}function _c(i,e,t,s,r){const{vertices:n,uvs:o,indices:a}=r;i.shapePrimitives.forEach(({shape:l,transform:h,holes:c})=>{const u=[],d=ps[l.type];if(!d.build(l,u))return;const f=a.length,p=n.length/2;let m="triangle-list";if(h&&Ca(u,h),t){const x=l.closePath??!0,b=e;b.pixelLine?(Tf(u,x,n,a),m="line-list"):Lr(u,b,!1,x,n,a)}else if(c){const x=[],b=u.slice();F0(c).forEach(w=>{x.push(b.length/2),b.push(...w)}),Ea(b,x,n,2,p,a,f)}else d.triangulate(u,n,2,p,a,f);const g=o.length/2,_=e.texture;if(_!==H.WHITE){const x=Aa(G0,e,l,h);xf(n,2,p,o,g,2,n.length/2-p,x)}else bf(o,g,2,n.length/2-p);const y=Se.get(Or);y.indexOffset=f,y.indexSize=a.length-f,y.attributeOffset=p,y.attributeSize=n.length/2-p,y.baseColor=e.color,y.alpha=e.alpha,y.texture=_,y.geometryData=r,y.topology=m,s.push(y)})}function F0(i){const e=[];for(let t=0;t<i.length;t++){const s=i[t].shape,r=[];ps[s.type].build(s,r)&&e.push(r)}return e}class Ef{constructor(){this.batches=[],this.geometryData={vertices:[],uvs:[],indices:[]}}reset(){this.batches&&this.batches.forEach(e=>{Se.return(e)}),this.graphicsData&&Se.return(this.graphicsData),this.isBatchable=!1,this.context=null,this.batches.length=0,this.geometryData.indices.length=0,this.geometryData.vertices.length=0,this.geometryData.uvs.length=0,this.graphicsData=null}destroy(){this.reset(),this.batches=null,this.geometryData=null}}class Pf{constructor(){this.instructions=new Sr}init(e){const t=e.maxTextures;this.batcher?this.batcher._updateMaxTextures(t):this.batcher=new Fr({maxTextures:t}),this.instructions.reset()}get geometry(){return N(Cu,"GraphicsContextRenderData#geometry is deprecated, please use batcher.geometry instead."),this.batcher.geometry}destroy(){this.batcher.destroy(),this.instructions.destroy(),this.batcher=null,this.instructions=null}}const Ra=class vo{constructor(e){this._renderer=e,this._managedContexts=new lt({renderer:e,type:"resource",name:"graphicsContext"})}init(e){vo.defaultOptions.bezierSmoothness=e?.bezierSmoothness??vo.defaultOptions.bezierSmoothness}getContextRenderData(e){return e._gpuData[this._renderer.uid].graphicsData||this._initContextRenderData(e)}updateGpuContext(e){const t=!!e._gpuData[this._renderer.uid],s=e._gpuData[this._renderer.uid]||this._initContext(e);if(e.dirty||!t){t&&s.reset(),kf(e,s);const r=e.batchMode;e.customShader||r==="no-batch"?s.isBatchable=!1:r==="auto"?s.isBatchable=s.geometryData.vertices.length<400:s.isBatchable=!0,e.dirty=!1}return s}getGpuContext(e){return e._gpuData[this._renderer.uid]||this._initContext(e)}_initContextRenderData(e){const t=Se.get(Pf,{maxTextures:this._renderer.limits.maxBatchableTextures}),s=e._gpuData[this._renderer.uid],{batches:r,geometryData:n}=s;s.graphicsData=t;const o=n.vertices.length,a=n.indices.length;for(let u=0;u<r.length;u++)r[u].applyTransform=!1;const l=t.batcher;l.ensureAttributeBuffer(o),l.ensureIndexBuffer(a),l.begin();for(let u=0;u<r.length;u++){const d=r[u];l.add(d)}l.finish(t.instructions);const h=l.geometry;h.indexBuffer.setDataWithSize(l.indexBuffer,l.indexSize,!0),h.buffers[0].setDataWithSize(l.attributeBuffer.float32View,l.attributeSize,!0);const c=l.batches;for(let u=0;u<l.batchIndex;u++){const d=c[u];d.bindGroup=Rr(d.textures.textures,d.textures.count,this._renderer.limits.maxBatchableTextures)}return t}_initContext(e){const t=new Ef;return t.context=e,e._gpuData[this._renderer.uid]=t,this._managedContexts.add(e),t}destroy(){this._managedContexts.destroy(),this._renderer=null}};Ra.extension={type:[S.WebGLSystem,S.WebGPUSystem],name:"graphicsContext"};Ra.defaultOptions={bezierSmoothness:.5};let Ur=Ra;const O0=8,Wi=11920929e-14,L0=1;function Ba(i,e,t,s,r,n,o,a,l,h){const u=Math.min(.99,Math.max(0,h??Ur.defaultOptions.bezierSmoothness));let d=(L0-u)/1;return d*=d,U0(e,t,s,r,n,o,a,l,i,d),i}function U0(i,e,t,s,r,n,o,a,l,h){wo(i,e,t,s,r,n,o,a,l,h,0),l.push(o,a)}function wo(i,e,t,s,r,n,o,a,l,h,c){if(c>O0)return;const u=(i+t)/2,d=(e+s)/2,f=(t+r)/2,p=(s+n)/2,m=(r+o)/2,g=(n+a)/2,_=(u+f)/2,y=(d+p)/2,x=(f+m)/2,b=(p+g)/2,v=(_+x)/2,w=(y+b)/2;if(c>0){let T=o-i,E=a-e;const P=Math.abs((t-o)*E-(s-a)*T),A=Math.abs((r-o)*E-(n-a)*T);if(P>Wi&&A>Wi){if((P+A)*(P+A)<=h*(T*T+E*E)){l.push(v,w);return}}else if(P>Wi){if(P*P<=h*(T*T+E*E)){l.push(v,w);return}}else if(A>Wi){if(A*A<=h*(T*T+E*E)){l.push(v,w);return}}else if(T=v-(i+o)/2,E=w-(e+a)/2,T*T+E*E<=h){l.push(v,w);return}}wo(i,e,u,d,_,y,v,w,l,h,c+1),wo(v,w,x,b,m,g,o,a,l,h,c+1)}const N0=8,z0=11920929e-14,H0=1;function Af(i,e,t,s,r,n,o,a){const h=Math.min(.99,Math.max(0,a??Ur.defaultOptions.bezierSmoothness));let c=(H0-h)/1;return c*=c,W0(e,t,s,r,n,o,i,c),i}function W0(i,e,t,s,r,n,o,a){To(o,i,e,t,s,r,n,a,0),o.push(r,n)}function To(i,e,t,s,r,n,o,a,l){if(l>N0)return;const h=(e+s)/2,c=(t+r)/2,u=(s+n)/2,d=(r+o)/2,f=(h+u)/2,p=(c+d)/2;let m=n-e,g=o-t;const _=Math.abs((s-n)*g-(r-o)*m);if(_>z0){if(_*_<=a*(m*m+g*g)){i.push(f,p);return}}else if(m=f-(e+n)/2,g=p-(t+o)/2,m*m+g*g<=a){i.push(f,p);return}To(i,e,t,h,c,f,p,a,l+1),To(i,f,p,u,d,n,o,a,l+1)}function Ia(i,e,t,s,r,n,o,a){let l=Math.abs(r-n);(!o&&r>n||o&&n>r)&&(l=2*Math.PI-l),a||(a=Math.max(6,Math.floor(6*Math.pow(s,1/3)*(l/Math.PI)))),a=Math.max(a,3);let h=l/a,c=r;h*=o?-1:1;for(let u=0;u<a+1;u++){const d=Math.cos(c),f=Math.sin(c),p=e+d*s,m=t+f*s;i.push(p,m),c+=h}}function Rf(i,e,t,s,r,n){const o=i[i.length-2],l=i[i.length-1]-t,h=o-e,c=r-t,u=s-e,d=Math.abs(l*u-h*c);if(d<1e-8||n===0){(i[i.length-2]!==e||i[i.length-1]!==t)&&i.push(e,t);return}const f=l*l+h*h,p=c*c+u*u,m=l*c+h*u,g=n*Math.sqrt(f)/d,_=n*Math.sqrt(p)/d,y=g*m/f,x=_*m/p,b=g*u+_*h,v=g*c+_*l,w=h*(_+y),T=l*(_+y),E=u*(g+x),P=c*(g+x),A=Math.atan2(T-v,w-b),k=Math.atan2(P-v,E-b);Ia(i,b+e,v+t,n,A,k,h*c>u*l)}const ni=Math.PI*2,Bn={centerX:0,centerY:0,ang1:0,ang2:0},In=({x:i,y:e},t,s,r,n,o,a,l)=>{i*=t,e*=s;const h=r*i-n*e,c=n*i+r*e;return l.x=h+o,l.y=c+a,l};function $0(i,e){const t=e===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(e/4),s=e===1.5707963267948966?.551915024494:t,r=Math.cos(i),n=Math.sin(i),o=Math.cos(i+e),a=Math.sin(i+e);return[{x:r-n*s,y:n+r*s},{x:o+a*s,y:a-o*s},{x:o,y:a}]}const yc=(i,e,t,s)=>{const r=i*s-e*t<0?-1:1;let n=i*t+e*s;return n>1&&(n=1),n<-1&&(n=-1),r*Math.acos(n)},V0=(i,e,t,s,r,n,o,a,l,h,c,u,d)=>{const f=Math.pow(r,2),p=Math.pow(n,2),m=Math.pow(c,2),g=Math.pow(u,2);let _=f*p-f*g-p*m;_<0&&(_=0),_/=f*g+p*m,_=Math.sqrt(_)*(o===a?-1:1);const y=_*r/n*u,x=_*-n/r*c,b=h*y-l*x+(i+t)/2,v=l*y+h*x+(e+s)/2,w=(c-y)/r,T=(u-x)/n,E=(-c-y)/r,P=(-u-x)/n,A=yc(1,0,w,T);let k=yc(w,T,E,P);a===0&&k>0&&(k-=ni),a===1&&k<0&&(k+=ni),d.centerX=b,d.centerY=v,d.ang1=A,d.ang2=k};function Bf(i,e,t,s,r,n,o,a=0,l=0,h=0){if(n===0||o===0)return;const c=Math.sin(a*ni/360),u=Math.cos(a*ni/360),d=u*(e-s)/2+c*(t-r)/2,f=-c*(e-s)/2+u*(t-r)/2;if(d===0&&f===0)return;n=Math.abs(n),o=Math.abs(o);const p=Math.pow(d,2)/Math.pow(n,2)+Math.pow(f,2)/Math.pow(o,2);p>1&&(n*=Math.sqrt(p),o*=Math.sqrt(p)),V0(e,t,s,r,n,o,l,h,c,u,d,f,Bn);let{ang1:m,ang2:g}=Bn;const{centerX:_,centerY:y}=Bn;let x=Math.abs(g)/(ni/4);Math.abs(1-x)<1e-7&&(x=1);const b=Math.max(Math.ceil(x),1);g/=b;let v=i[i.length-2],w=i[i.length-1];const T={x:0,y:0};for(let E=0;E<b;E++){const P=$0(m,g),{x:A,y:k}=In(P[0],n,o,u,c,_,y,T),{x:I,y:G}=In(P[1],n,o,u,c,_,y,T),{x:F,y:X}=In(P[2],n,o,u,c,_,y,T);Ba(i,v,w,A,k,I,G,F,X),v=F,w=X,m+=g}}function If(i,e,t){const s=(o,a)=>{const l=a.x-o.x,h=a.y-o.y,c=Math.sqrt(l*l+h*h),u=l/c,d=h/c;return{len:c,nx:u,ny:d}},r=(o,a)=>{o===0?i.moveTo(a.x,a.y):i.lineTo(a.x,a.y)};let n=e[e.length-1];for(let o=0;o<e.length;o++){const a=e[o%e.length],l=a.radius??t;if(l<=0){r(o,a),n=a;continue}const h=e[(o+1)%e.length],c=s(a,n),u=s(a,h);if(c.len<1e-4||u.len<1e-4){r(o,a),n=a;continue}let d=Math.asin(c.nx*u.ny-c.ny*u.nx),f=1,p=!1;c.nx*u.nx-c.ny*-u.ny<0?d<0?d=Math.PI+d:(d=Math.PI-d,f=-1,p=!0):d>0&&(f=-1,p=!0);const m=d/2;let g,_=Math.abs(Math.cos(m)*l/Math.sin(m));_>Math.min(c.len/2,u.len/2)?(_=Math.min(c.len/2,u.len/2),g=Math.abs(_*Math.sin(m)/Math.cos(m))):g=l;const y=a.x+u.nx*_+-u.ny*g*f,x=a.y+u.ny*_+u.nx*g*f,b=Math.atan2(c.ny,c.nx)+Math.PI/2*f,v=Math.atan2(u.ny,u.nx)-Math.PI/2*f;o===0&&i.moveTo(y+Math.cos(b)*g,x+Math.sin(b)*g),i.arc(y,x,g,b,v,p),n=a}}function Gf(i,e,t,s){const r=(a,l)=>Math.sqrt((a.x-l.x)**2+(a.y-l.y)**2),n=(a,l,h)=>({x:a.x+(l.x-a.x)*h,y:a.y+(l.y-a.y)*h}),o=e.length;for(let a=0;a<o;a++){const l=e[(a+1)%o],h=l.radius??t;if(h<=0){a===0?i.moveTo(l.x,l.y):i.lineTo(l.x,l.y);continue}const c=e[a],u=e[(a+2)%o],d=r(c,l);let f;if(d<1e-4)f=l;else{const g=Math.min(d/2,h);f=n(l,c,g/d)}const p=r(u,l);let m;if(p<1e-4)m=l;else{const g=Math.min(p/2,h);m=n(l,u,g/p)}a===0?i.moveTo(f.x,f.y):i.lineTo(f.x,f.y),i.quadraticCurveTo(l.x,l.y,m.x,m.y,s)}}const j0=new se;class Df{constructor(e){this.shapePrimitives=[],this._currentPoly=null,this._bounds=new Ee,this._graphicsPath2D=e,this.signed=e.checkForHoles}moveTo(e,t){return this.startPoly(e,t),this}lineTo(e,t){this._ensurePoly();const s=this._currentPoly.points,r=s[s.length-2],n=s[s.length-1];return(r!==e||n!==t)&&s.push(e,t),this}arc(e,t,s,r,n,o){this._ensurePoly(!1);const a=this._currentPoly.points;return Ia(a,e,t,s,r,n,o),this}arcTo(e,t,s,r,n){this._ensurePoly();const o=this._currentPoly.points;return Rf(o,e,t,s,r,n),this}arcToSvg(e,t,s,r,n,o,a){const l=this._currentPoly.points;return Bf(l,this._currentPoly.lastX,this._currentPoly.lastY,o,a,e,t,s,r,n),this}bezierCurveTo(e,t,s,r,n,o,a){this._ensurePoly();const l=this._currentPoly;return Ba(this._currentPoly.points,l.lastX,l.lastY,e,t,s,r,n,o,a),this}quadraticCurveTo(e,t,s,r,n){this._ensurePoly();const o=this._currentPoly;return Af(this._currentPoly.points,o.lastX,o.lastY,e,t,s,r,n),this}closePath(){return this.endPoly(!0),this}addPath(e,t){this.endPoly(),t&&!t.isIdentity()&&(e=e.clone(!0),e.transform(t));const s=this.shapePrimitives,r=s.length;for(let n=0;n<e.instructions.length;n++){const o=e.instructions[n];this[o.action](...o.data)}if(e.checkForHoles&&s.length-r>1){let n=null;for(let o=r;o<s.length;o++){const a=s[o];if(a.shape.type==="polygon"){const l=a.shape,h=n?.shape;h&&h.containsPolygon(l)?(n.holes||(n.holes=[]),n.holes.push(a),s.copyWithin(o,o+1),s.length--,o--):n=a}}}return this}finish(e=!1){this.endPoly(e)}rect(e,t,s,r,n){return this.drawShape(new se(e,t,s,r),n),this}circle(e,t,s,r){return this.drawShape(new Er(e,t,s),r),this}poly(e,t,s){const r=new Es(e);return r.closePath=t,this.drawShape(r,s),this}regularPoly(e,t,s,r,n=0,o){r=Math.max(r|0,3);const a=-1*Math.PI/2+n,l=Math.PI*2/r,h=[];for(let c=0;c<r;c++){const u=a-c*l;h.push(e+s*Math.cos(u),t+s*Math.sin(u))}return this.poly(h,!0,o),this}roundPoly(e,t,s,r,n,o=0,a){if(r=Math.max(r|0,3),n<=0)return this.regularPoly(e,t,s,r,o);const l=s*Math.sin(Math.PI/r)-.001;n=Math.min(n,l);const h=-1*Math.PI/2+o,c=Math.PI*2/r,u=(r-2)*Math.PI/r/2;for(let d=0;d<r;d++){const f=d*c+h,p=e+s*Math.cos(f),m=t+s*Math.sin(f),g=f+Math.PI+u,_=f-Math.PI-u,y=p+n*Math.cos(g),x=m+n*Math.sin(g),b=p+n*Math.cos(_),v=m+n*Math.sin(_);d===0?this.moveTo(y,x):this.lineTo(y,x),this.quadraticCurveTo(p,m,b,v,a)}return this.closePath()}roundShape(e,t,s=!1,r){return e.length<3?this:(s?Gf(this,e,t,r):If(this,e,t),this.closePath())}filletRect(e,t,s,r,n){if(n===0)return this.rect(e,t,s,r);const o=Math.min(s,r)/2,a=Math.min(o,Math.max(-o,n)),l=e+s,h=t+r,c=a<0?-a:0,u=Math.abs(a);return this.moveTo(e,t+u).arcTo(e+c,t+c,e+u,t,u).lineTo(l-u,t).arcTo(l-c,t+c,l,t+u,u).lineTo(l,h-u).arcTo(l-c,h-c,e+s-u,h,u).lineTo(e+u,h).arcTo(e+c,h-c,e,h-u,u).closePath()}chamferRect(e,t,s,r,n,o){if(n<=0)return this.rect(e,t,s,r);const a=Math.min(n,Math.min(s,r)/2),l=e+s,h=t+r,c=[e+a,t,l-a,t,l,t+a,l,h-a,l-a,h,e+a,h,e,h-a,e,t+a];for(let u=c.length-1;u>=2;u-=2)c[u]===c[u-2]&&c[u-1]===c[u-3]&&c.splice(u-1,2);return this.poly(c,!0,o)}ellipse(e,t,s,r,n){return this.drawShape(new Pr(e,t,s,r),n),this}roundRect(e,t,s,r,n,o){return this.drawShape(new Ar(e,t,s,r,n),o),this}drawShape(e,t){return this.endPoly(),this.shapePrimitives.push({shape:e,transform:t}),this}startPoly(e,t){let s=this._currentPoly;return s&&this.endPoly(),s=new Es,s.points.push(e,t),this._currentPoly=s,this}endPoly(e=!1){const t=this._currentPoly;return t&&t.points.length>2&&(t.closePath=e,this.shapePrimitives.push({shape:t})),this._currentPoly=null,this}_ensurePoly(e=!0){if(!this._currentPoly&&(this._currentPoly=new Es,e)){const t=this.shapePrimitives[this.shapePrimitives.length-1];if(t){let s=t.shape.x,r=t.shape.y;if(t.transform&&!t.transform.isIdentity()){const n=t.transform,o=s;s=n.a*s+n.c*r+n.tx,r=n.b*o+n.d*r+n.ty}this._currentPoly.points.push(s,r)}else this._currentPoly.points.push(0,0)}}buildPath(){const e=this._graphicsPath2D;this.shapePrimitives.length=0,this._currentPoly=null;for(let t=0;t<e.instructions.length;t++){const s=e.instructions[t];this[s.action](...s.data)}this.finish()}get bounds(){const e=this._bounds;e.clear();const t=this.shapePrimitives;for(let s=0;s<t.length;s++){const r=t[s],n=r.shape.getBounds(j0);r.transform?e.addRect(n,r.transform):e.addRect(n)}return e}}class mt{constructor(e,t=!1){this.instructions=[],this.uid=oe("graphicsPath"),this._dirty=!0,this.checkForHoles=t,typeof e=="string"?Xd(e,this):this.instructions=e?.slice()??[]}get shapePath(){return this._shapePath||(this._shapePath=new Df(this)),this._dirty&&(this._dirty=!1,this._shapePath.buildPath()),this._shapePath}addPath(e,t){return e=e.clone(),this.instructions.push({action:"addPath",data:[e,t]}),this._dirty=!0,this}arc(...e){return this.instructions.push({action:"arc",data:e}),this._dirty=!0,this}arcTo(...e){return this.instructions.push({action:"arcTo",data:e}),this._dirty=!0,this}arcToSvg(...e){return this.instructions.push({action:"arcToSvg",data:e}),this._dirty=!0,this}bezierCurveTo(...e){return this.instructions.push({action:"bezierCurveTo",data:e}),this._dirty=!0,this}bezierCurveToShort(e,t,s,r,n){const o=this.instructions[this.instructions.length-1],a=this.getLastPoint(ce.shared);let l=0,h=0;if(!o||o.action!=="bezierCurveTo")l=a.x,h=a.y;else{l=o.data[2],h=o.data[3];const c=a.x,u=a.y;l=c+(c-l),h=u+(u-h)}return this.instructions.push({action:"bezierCurveTo",data:[l,h,e,t,s,r,n]}),this._dirty=!0,this}closePath(){return this.instructions.push({action:"closePath",data:[]}),this._dirty=!0,this}ellipse(...e){return this.instructions.push({action:"ellipse",data:e}),this._dirty=!0,this}lineTo(...e){return this.instructions.push({action:"lineTo",data:e}),this._dirty=!0,this}moveTo(...e){return this.instructions.push({action:"moveTo",data:e}),this}quadraticCurveTo(...e){return this.instructions.push({action:"quadraticCurveTo",data:e}),this._dirty=!0,this}quadraticCurveToShort(e,t,s){const r=this.instructions[this.instructions.length-1],n=this.getLastPoint(ce.shared);let o=0,a=0;if(!r||r.action!=="quadraticCurveTo")o=n.x,a=n.y;else{o=r.data[0],a=r.data[1];const l=n.x,h=n.y;o=l+(l-o),a=h+(h-a)}return this.instructions.push({action:"quadraticCurveTo",data:[o,a,e,t,s]}),this._dirty=!0,this}rect(e,t,s,r,n){return this.instructions.push({action:"rect",data:[e,t,s,r,n]}),this._dirty=!0,this}circle(e,t,s,r){return this.instructions.push({action:"circle",data:[e,t,s,r]}),this._dirty=!0,this}roundRect(...e){return this.instructions.push({action:"roundRect",data:e}),this._dirty=!0,this}poly(...e){return this.instructions.push({action:"poly",data:e}),this._dirty=!0,this}regularPoly(...e){return this.instructions.push({action:"regularPoly",data:e}),this._dirty=!0,this}roundPoly(...e){return this.instructions.push({action:"roundPoly",data:e}),this._dirty=!0,this}roundShape(...e){return this.instructions.push({action:"roundShape",data:e}),this._dirty=!0,this}filletRect(...e){return this.instructions.push({action:"filletRect",data:e}),this._dirty=!0,this}chamferRect(...e){return this.instructions.push({action:"chamferRect",data:e}),this._dirty=!0,this}star(e,t,s,r,n,o,a){n||(n=r/2);const l=-1*Math.PI/2+o,h=s*2,c=Math.PI*2/h,u=[];for(let d=0;d<h;d++){const f=d%2?n:r,p=d*c+l;u.push(e+f*Math.cos(p),t+f*Math.sin(p))}return this.poly(u,!0,a),this}clone(e=!1){const t=new mt;if(t.checkForHoles=this.checkForHoles,!e)t.instructions=this.instructions.slice();else for(let s=0;s<this.instructions.length;s++){const r=this.instructions[s];t.instructions.push({action:r.action,data:r.data.slice()})}return t}clear(){return this.instructions.length=0,this._dirty=!0,this}transform(e){if(e.isIdentity())return this;const t=e.a,s=e.b,r=e.c,n=e.d,o=e.tx,a=e.ty;let l=0,h=0,c=0,u=0,d=0,f=0,p=0,m=0;for(let g=0;g<this.instructions.length;g++){const _=this.instructions[g],y=_.data;switch(_.action){case"moveTo":case"lineTo":l=y[0],h=y[1],y[0]=t*l+r*h+o,y[1]=s*l+n*h+a;break;case"bezierCurveTo":c=y[0],u=y[1],d=y[2],f=y[3],l=y[4],h=y[5],y[0]=t*c+r*u+o,y[1]=s*c+n*u+a,y[2]=t*d+r*f+o,y[3]=s*d+n*f+a,y[4]=t*l+r*h+o,y[5]=s*l+n*h+a;break;case"quadraticCurveTo":c=y[0],u=y[1],l=y[2],h=y[3],y[0]=t*c+r*u+o,y[1]=s*c+n*u+a,y[2]=t*l+r*h+o,y[3]=s*l+n*h+a;break;case"arcToSvg":l=y[5],h=y[6],p=y[0],m=y[1],y[0]=t*p+r*m,y[1]=s*p+n*m,y[5]=t*l+r*h+o,y[6]=s*l+n*h+a;break;case"circle":y[4]=_s(y[3],e);break;case"rect":y[4]=_s(y[4],e);break;case"ellipse":y[8]=_s(y[8],e);break;case"roundRect":y[5]=_s(y[5],e);break;case"addPath":y[0].transform(e);break;case"poly":y[2]=_s(y[2],e);break;case"regularPoly":case"chamferRect":y[5]=_s(y[5],e);break;case"closePath":break;default:z("unknown transform action",_.action);break}}return this._dirty=!0,this}get bounds(){return this.shapePath.bounds}getLastPoint(e){let t=this.instructions.length-1,s=this.instructions[t];if(!s)return e.x=0,e.y=0,e;for(;s.action==="closePath";){if(t--,t<0)return e.x=0,e.y=0,e;s=this.instructions[t]}switch(s.action){case"moveTo":case"lineTo":e.x=s.data[0],e.y=s.data[1];break;case"quadraticCurveTo":e.x=s.data[2],e.y=s.data[3];break;case"bezierCurveTo":e.x=s.data[4],e.y=s.data[5];break;case"arc":case"arcToSvg":e.x=s.data[5],e.y=s.data[6];break;case"addPath":s.data[0].getLastPoint(e);break}return e}}function _s(i,e){return i?i.prepend(e):e.clone()}function ve(i,e,t){const s=i.getAttribute(e);return s?Number(s):t}function Ff(i,e){const t=i.querySelectorAll("defs");for(let s=0;s<t.length;s++){const r=t[s];for(let n=0;n<r.children.length;n++){const o=r.children[n];switch(o.nodeName.toLowerCase()){case"lineargradient":e.defs[o.id]=X0(o);break;case"radialgradient":e.defs[o.id]=q0(o);break}}}}function nt(i,e,t){const s=i.getAttribute(e);if(s?.trim().endsWith("%")){const r=Number(s.trim().slice(0,-1));return Number.isNaN(r)?t:r/100}return ve(i,e,t)}function Of(i){return(i.getAttribute("gradientUnits")||"objectBoundingBox")==="objectBoundingBox"?"local":"global"}function Lf(i){const e=[];for(let t=0;t<i.children.length;t++){const s=i.children[t],r=nt(s,"offset",0),n=le.shared.setValue(s.getAttribute("stop-color")).toNumber();e.push({offset:r,color:n})}return e}function X0(i){const e=nt(i,"x1",0),t=nt(i,"y1",0),s=nt(i,"x2",1),r=nt(i,"y2",0);return new Xe({type:"linear",start:{x:e,y:t},end:{x:s,y:r},textureSpace:Of(i),colorStops:Lf(i)})}function q0(i){const e=nt(i,"cx",.5),t=nt(i,"cy",.5),s=nt(i,"r",.5),r=nt(i,"fx",e),n=nt(i,"fy",t),o=nt(i,"fr",0);return new Xe({type:"radial",center:{x:r,y:n},innerRadius:o,outerCenter:{x:e,y:t},outerRadius:s,textureSpace:Of(i),colorStops:Lf(i)})}function So(i){const e=i.match(/url\s*\(\s*['"]?\s*#([^'"\s)]+)\s*['"]?\s*\)/i);return e?e[1]:""}const Mo={fill:{type:"paint",default:0},"fill-opacity":{type:"number",default:1},stroke:{type:"paint",default:0},"stroke-width":{type:"number",default:1},"stroke-opacity":{type:"number",default:1},"stroke-linecap":{type:"string",default:"butt"},"stroke-linejoin":{type:"string",default:"miter"},"stroke-miterlimit":{type:"number",default:10},"stroke-dasharray":{type:"string",default:"none"},"stroke-dashoffset":{type:"number",default:0},opacity:{type:"number",default:1}};function Ga(i,e){const t=i.getAttribute("style"),s={},r={},n={strokeStyle:s,fillStyle:r,useFill:!1,useStroke:!1};for(const o in Mo){const a=i.getAttribute(o);a&&xc(e,n,o,a.trim())}if(t){const o=t.split(";");for(let a=0;a<o.length;a++){const l=o[a].trim(),[h,c]=l.split(":");Mo[h]&&xc(e,n,h,c.trim())}}return{strokeStyle:n.useStroke?s:null,fillStyle:n.useFill?r:null,useFill:n.useFill,useStroke:n.useStroke}}function xc(i,e,t,s){switch(t){case"stroke":if(s!=="none"){if(s.startsWith("url(")){const r=So(s);e.strokeStyle.fill=i.defs[r]}else e.strokeStyle.color=le.shared.setValue(s).toNumber();e.useStroke=!0}break;case"stroke-width":e.strokeStyle.width=Number(s);break;case"fill":if(s!=="none"){if(s.startsWith("url(")){const r=So(s);e.fillStyle.fill=i.defs[r]}else e.fillStyle.color=le.shared.setValue(s).toNumber();e.useFill=!0}break;case"fill-opacity":e.fillStyle.alpha=Number(s);break;case"stroke-opacity":e.strokeStyle.alpha=Number(s);break;case"opacity":e.fillStyle.alpha=Number(s),e.strokeStyle.alpha=Number(s);break}}function Uf(i){if(i.length<=2)return!0;const e=i.map(a=>a.area).sort((a,l)=>l-a),[t,s]=e,r=e[e.length-1],n=t/s,o=s/r;return!(n>3&&o<2)}function Nf(i){return i.split(/(?=[Mm])/).filter(s=>s.trim().length>0)}function zf(i){const e=i.match(/[-+]?[0-9]*\.?[0-9]+/g);if(!e||e.length<4)return 0;const t=e.map(Number),s=[],r=[];for(let c=0;c<t.length;c+=2)c+1<t.length&&(s.push(t[c]),r.push(t[c+1]));if(s.length===0||r.length===0)return 0;const n=Math.min(...s),o=Math.max(...s),a=Math.min(...r),l=Math.max(...r);return(o-n)*(l-a)}function Co(i,e){const t=new mt(i,!1);for(const s of t.instructions)e.instructions.push(s)}function Hf(i,e){if(typeof i=="string"){const o=document.createElement("div");o.innerHTML=i.trim(),i=o.querySelector("svg")}const t={context:e,defs:{},path:new mt};Ff(i,t);const s=i.children,{fillStyle:r,strokeStyle:n}=Ga(i,t);for(let o=0;o<s.length;o++){const a=s[o];a.nodeName.toLowerCase()!=="defs"&&Wf(a,t,r,n)}return e}function Wf(i,e,t,s){const r=i.children,{fillStyle:n,strokeStyle:o}=Ga(i,e);n&&t?t={...t,...n}:n&&(t=n),o&&s?s={...s,...o}:o&&(s=o);const a=!t&&!s;a&&(t={color:0});let l,h,c,u,d,f,p,m,g,_,y,x,b,v,w,T,E;switch(i.nodeName.toLowerCase()){case"path":{v=i.getAttribute("d");const P=i.getAttribute("fill-rule"),A=Nf(v),k=P==="evenodd",I=A.length>1;if(k&&I){const F=A.map(C=>({path:C,area:zf(C)}));if(F.sort((C,M)=>M.area-C.area),A.length>3||!Uf(F))for(let C=0;C<F.length;C++){const M=F[C],B=C===0;e.context.beginPath();const R=new mt(void 0,!0);Co(M.path,R),e.context.path(R),B?(t&&e.context.fill(t),s&&e.context.stroke(s)):e.context.cut()}else for(let C=0;C<F.length;C++){const M=F[C],B=C%2===1;e.context.beginPath();const R=new mt(void 0,!0);Co(M.path,R),e.context.path(R),B?e.context.cut():(t&&e.context.fill(t),s&&e.context.stroke(s))}}else{const F=P?P==="evenodd":!0;w=new mt(v,F),e.context.path(w),t&&e.context.fill(t),s&&e.context.stroke(s)}break}case"circle":p=ve(i,"cx",0),m=ve(i,"cy",0),g=ve(i,"r",0),e.context.ellipse(p,m,g,g),t&&e.context.fill(t),s&&e.context.stroke(s);break;case"rect":l=ve(i,"x",0),h=ve(i,"y",0),T=ve(i,"width",0),E=ve(i,"height",0),_=ve(i,"rx",0),y=ve(i,"ry",0),_||y?e.context.roundRect(l,h,T,E,_||y):e.context.rect(l,h,T,E),t&&e.context.fill(t),s&&e.context.stroke(s);break;case"ellipse":p=ve(i,"cx",0),m=ve(i,"cy",0),_=ve(i,"rx",0),y=ve(i,"ry",0),e.context.beginPath(),e.context.ellipse(p,m,_,y),t&&e.context.fill(t),s&&e.context.stroke(s);break;case"line":c=ve(i,"x1",0),u=ve(i,"y1",0),d=ve(i,"x2",0),f=ve(i,"y2",0),e.context.beginPath(),e.context.moveTo(c,u),e.context.lineTo(d,f),s&&e.context.stroke(s);break;case"polygon":b=i.getAttribute("points"),x=b.match(/-?\d+/g).map(P=>parseInt(P,10)),e.context.poly(x,!0),t&&e.context.fill(t),s&&e.context.stroke(s);break;case"polyline":b=i.getAttribute("points"),x=b.match(/-?\d+/g).map(P=>parseInt(P,10)),e.context.poly(x,!1),s&&e.context.stroke(s);break;case"g":case"svg":break;default:{z(`[SVG parser] <${i.nodeName}> elements unsupported`);break}}a&&(t=null);for(let P=0;P<r.length;P++)Wf(r[P],e,t,s)}function Y0(i){return i.texture!==void 0}const bc={repeat:{addressModeU:"repeat",addressModeV:"repeat"},"repeat-x":{addressModeU:"repeat",addressModeV:"clamp-to-edge"},"repeat-y":{addressModeU:"clamp-to-edge",addressModeV:"repeat"},"no-repeat":{addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}};class Us{constructor(e,t){this.uid=oe("fillPattern"),this._tick=0,this.transform=new L;const s=Y0(e)?e:{texture:e,repetition:t};this.texture=s.texture,this.textureSpace=s.textureSpace??"global";const r=s.repetition;r&&(this.texture.source.style.addressModeU=bc[r].addressModeU,this.texture.source.style.addressModeV=bc[r].addressModeV)}setTransform(e){if(e){if(this.transform.equals(e))return;this.transform.copyFrom(e)}else{if(this.transform.isIdentity())return;this.transform.identity()}this._tick++}get texture(){return this._texture}set texture(e){this._texture!==e&&(this._texture=e,this._tick++)}get styleKey(){return`fill-pattern-${this.uid}-${this._tick}`}destroy(){this.texture.destroy(!0),this.texture=null}}function K0(i){return le.isColorLike(i)}function vc(i){return i instanceof Us}function wc(i){return i instanceof Xe}function Z0(i){return i instanceof H}function Q0(i,e,t){const s=le.shared.setValue(e??0);return i.color=s.toNumber(),i.alpha=s.alpha===1?t.alpha:s.alpha,i.texture=H.WHITE,{...t,...i}}function J0(i,e,t){return i.texture=e,{...t,...i}}function Tc(i,e,t){return i.fill=e,i.color=16777215,i.texture=e.texture,i.matrix=e.transform,i.textureSpace=e.textureSpace,{...t,...i}}function Sc(i,e,t){return e.buildGradient(),i.fill=e,i.color=16777215,i.texture=e.texture,i.matrix=e.transform,i.textureSpace=e.textureSpace,{...t,...i}}function ey(i,e){const t={...e,...i},s=le.shared.setValue(t.color);return t.alpha*=s.alpha,t.color=s.toNumber(),t}function Ot(i,e){if(i==null)return null;const t={},s=i;return K0(i)?Q0(t,i,e):Z0(i)?J0(t,i,e):vc(i)?Tc(t,i,e):wc(i)?Sc(t,i,e):s.fill&&vc(s.fill)?Tc(s,s.fill,e):s.fill&&wc(s.fill)?Sc(s,s.fill,e):ey(s,e)}function bi(i,e){const{width:t,alignment:s,miterLimit:r,cap:n,join:o,pixelLine:a,...l}=e,h=Ot(i,l);return h?{width:t,alignment:s,miterLimit:r,cap:n,join:o,pixelLine:a,...h}:null}function $f(i,e){let t=1;const s=i.shapePath.shapePrimitives;for(let r=0;r<s.length;r++){const n=s[r].shape;if(n.type!=="polygon")continue;const o=n.points,a=o.length;if(a<6)continue;const l=n.closePath;for(let h=0;h<a;h+=2){if(!l&&(h===0||h===a-2))continue;const c=(h-2+a)%a,u=(h+2)%a,d=o[c],f=o[c+1],p=o[h],m=o[h+1],g=o[u],_=o[u+1],y=d-p,x=f-m,b=g-p,v=_-m,w=y*y+x*x,T=b*b+v*v;if(w<1e-12||T<1e-12)continue;let A=(y*b+x*v)/Math.sqrt(w*T);A<-1?A=-1:A>1&&(A=1);const k=Math.sqrt((1-A)*.5);if(k<1e-6)continue;const I=Math.min(1/k,e);I>t&&(t=I)}}return t}const ty=new ce,Mc=new L,Da=class ct extends Re{constructor(){super(...arguments),this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this.uid=oe("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this.destroyed=!1,this._activePath=new mt,this._transform=new L,this._fillStyle={...ct.defaultFillStyle},this._strokeStyle={...ct.defaultStrokeStyle},this._stateStack=[],this._tick=0,this._bounds=new Ee,this._boundsDirty=!0}clone(){const e=new ct;return e.batchMode=this.batchMode,e.instructions=this.instructions.slice(),e._activePath=this._activePath.clone(),e._transform=this._transform.clone(),e._fillStyle={...this._fillStyle},e._strokeStyle={...this._strokeStyle},e._stateStack=this._stateStack.slice(),e._bounds=this._bounds.clone(),e._boundsDirty=!0,e}get fillStyle(){return this._fillStyle}set fillStyle(e){this._fillStyle=Ot(e,ct.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(e){this._strokeStyle=bi(e,ct.defaultStrokeStyle)}setFillStyle(e){return this._fillStyle=Ot(e,ct.defaultFillStyle),this}setStrokeStyle(e){return this._strokeStyle=Ot(e,ct.defaultStrokeStyle),this}texture(e,t,s,r,n,o){return this.instructions.push({action:"texture",data:{image:e,dx:s||0,dy:r||0,dw:n||e.frame.width,dh:o||e.frame.height,transform:this._transform.clone(),alpha:this._fillStyle.alpha,style:t||t===0?le.shared.setValue(t).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new mt,this}fill(e,t){let s;const r=this.instructions[this.instructions.length-1];return this._tick===0&&r?.action==="stroke"?s=r.data.path:s=this._activePath.clone(),s?(e!=null&&(t!==void 0&&typeof e=="number"&&(N(de,"GraphicsContext.fill(color, alpha) is deprecated, use GraphicsContext.fill({ color, alpha }) instead"),e={color:e,alpha:t}),this._fillStyle=Ot(e,ct.defaultFillStyle)),this.instructions.push({action:"fill",data:{style:this.fillStyle,path:s}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}_initNextPathLocation(){const{x:e,y:t}=this._activePath.getLastPoint(ce.shared);this._activePath.clear(),this._activePath.moveTo(e,t)}stroke(e){let t;const s=this.instructions[this.instructions.length-1];return this._tick===0&&s?.action==="fill"?t=s.data.path:t=this._activePath.clone(),t?(e!=null&&(this._strokeStyle=bi(e,ct.defaultStrokeStyle)),this.instructions.push({action:"stroke",data:{style:this.strokeStyle,path:t}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}cut(){for(let e=0;e<2;e++){const t=this.instructions[this.instructions.length-1-e],s=this._activePath.clone();if(t&&(t.action==="stroke"||t.action==="fill"))if(t.data.hole)t.data.hole.addPath(s);else{t.data.hole=s;break}}return this._initNextPathLocation(),this}arc(e,t,s,r,n,o){this._tick++;const a=this._transform;return this._activePath.arc(a.a*e+a.c*t+a.tx,a.b*e+a.d*t+a.ty,s,r,n,o),this}arcTo(e,t,s,r,n){this._tick++;const o=this._transform;return this._activePath.arcTo(o.a*e+o.c*t+o.tx,o.b*e+o.d*t+o.ty,o.a*s+o.c*r+o.tx,o.b*s+o.d*r+o.ty,n),this}arcToSvg(e,t,s,r,n,o,a){this._tick++;const l=this._transform;return this._activePath.arcToSvg(e,t,s,r,n,l.a*o+l.c*a+l.tx,l.b*o+l.d*a+l.ty),this}bezierCurveTo(e,t,s,r,n,o,a){this._tick++;const l=this._transform;return this._activePath.bezierCurveTo(l.a*e+l.c*t+l.tx,l.b*e+l.d*t+l.ty,l.a*s+l.c*r+l.tx,l.b*s+l.d*r+l.ty,l.a*n+l.c*o+l.tx,l.b*n+l.d*o+l.ty,a),this}closePath(){return this._tick++,this._activePath?.closePath(),this}ellipse(e,t,s,r){return this._tick++,this._activePath.ellipse(e,t,s,r,this._transform.clone()),this}circle(e,t,s){return this._tick++,this._activePath.circle(e,t,s,this._transform.clone()),this}path(e){return this._tick++,this._activePath.addPath(e,this._transform.clone()),this}lineTo(e,t){this._tick++;const s=this._transform;return this._activePath.lineTo(s.a*e+s.c*t+s.tx,s.b*e+s.d*t+s.ty),this}moveTo(e,t){this._tick++;const s=this._transform,r=this._activePath.instructions,n=s.a*e+s.c*t+s.tx,o=s.b*e+s.d*t+s.ty;return r.length===1&&r[0].action==="moveTo"?(r[0].data[0]=n,r[0].data[1]=o,this):(this._activePath.moveTo(n,o),this)}quadraticCurveTo(e,t,s,r,n){this._tick++;const o=this._transform;return this._activePath.quadraticCurveTo(o.a*e+o.c*t+o.tx,o.b*e+o.d*t+o.ty,o.a*s+o.c*r+o.tx,o.b*s+o.d*r+o.ty,n),this}rect(e,t,s,r){return this._tick++,this._activePath.rect(e,t,s,r,this._transform.clone()),this}roundRect(e,t,s,r,n){return this._tick++,this._activePath.roundRect(e,t,s,r,n,this._transform.clone()),this}poly(e,t){return this._tick++,this._activePath.poly(e,t,this._transform.clone()),this}regularPoly(e,t,s,r,n=0,o){return this._tick++,this._activePath.regularPoly(e,t,s,r,n,o),this}roundPoly(e,t,s,r,n,o){return this._tick++,this._activePath.roundPoly(e,t,s,r,n,o),this}roundShape(e,t,s,r){return this._tick++,this._activePath.roundShape(e,t,s,r),this}filletRect(e,t,s,r,n){return this._tick++,this._activePath.filletRect(e,t,s,r,n),this}chamferRect(e,t,s,r,n,o){return this._tick++,this._activePath.chamferRect(e,t,s,r,n,o),this}star(e,t,s,r,n=0,o=0){return this._tick++,this._activePath.star(e,t,s,r,n,o,this._transform.clone()),this}svg(e){return this._tick++,Hf(e,this),this}restore(){const e=this._stateStack.pop();return e&&(this._transform=e.transform,this._fillStyle=e.fillStyle,this._strokeStyle=e.strokeStyle),this}save(){return this._stateStack.push({transform:this._transform.clone(),fillStyle:{...this._fillStyle},strokeStyle:{...this._strokeStyle}}),this}getTransform(){return this._transform}resetTransform(){return this._transform.identity(),this}rotate(e){return this._transform.rotate(e),this}scale(e,t=e){return this._transform.scale(e,t),this}setTransform(e,t,s,r,n,o){return e instanceof L?(this._transform.set(e.a,e.b,e.c,e.d,e.tx,e.ty),this):(this._transform.set(e,t,s,r,n,o),this)}transform(e,t,s,r,n,o){return e instanceof L?(this._transform.append(e),this):(Mc.set(e,t,s,r,n,o),this._transform.append(Mc),this)}translate(e,t=e){return this._transform.translate(e,t),this}clear(){return this._activePath.clear(),this.instructions.length=0,this.resetTransform(),this.onUpdate(),this}onUpdate(){this._boundsDirty=!0,this.dirty=!0,this.emit("update",this,16)}get bounds(){if(!this._boundsDirty)return this._bounds;this._boundsDirty=!1;const e=this._bounds;e.clear();for(let t=0;t<this.instructions.length;t++){const s=this.instructions[t],r=s.action;if(r==="fill"){const n=s.data;e.addBounds(n.path.bounds)}else if(r==="texture"){const n=s.data;e.addFrame(n.dx,n.dy,n.dx+n.dw,n.dy+n.dh,n.transform)}if(r==="stroke"){const n=s.data,o=n.style.alignment;let a=n.style.width*(1-o);n.style.join==="miter"&&(a*=$f(n.path,n.style.miterLimit));const l=n.path.bounds;e.addFrame(l.minX-a,l.minY-a,l.maxX+a,l.maxY+a)}}return e.isValid||e.set(0,0,0,0),e}containsPoint(e){if(!this.bounds.containsPoint(e.x,e.y))return!1;const t=this.instructions;let s=!1;for(let r=0;r<t.length;r++){const n=t[r],o=n.data,a=o.path;if(!n.action||!a)continue;const l=o.style,h=a.shapePath.shapePrimitives;for(let c=0;c<h.length;c++){const u=h[c].shape;if(!l||!u)continue;const d=h[c].transform,f=d?d.applyInverse(e,ty):e;if(n.action==="fill")s=u.contains(f.x,f.y);else{const m=l;s=u.strokeContains(f.x,f.y,m.width,m.alignment)}const p=o.hole;if(p){const m=p.shapePath?.shapePrimitives;if(m)for(let g=0;g<m.length;g++)m[g].shape.contains(f.x,f.y)&&(s=!1)}if(s)return!0}}return s}unload(){this.emit("unload",this);for(const e in this._gpuData)this._gpuData[e]?.destroy();this._gpuData=Object.create(null)}destroy(e=!1){if(this.destroyed)return;if(this.destroyed=!0,this._stateStack.length=0,this._transform=null,this.unload(),this.emit("destroy",this),this.removeAllListeners(),typeof e=="boolean"?e:e?.texture){const s=typeof e=="boolean"?e:e?.textureSource;this._fillStyle.texture&&(this._fillStyle.fill&&"uid"in this._fillStyle.fill?this._fillStyle.fill.destroy():this._fillStyle.texture.destroy(s)),this._strokeStyle.texture&&(this._strokeStyle.fill&&"uid"in this._strokeStyle.fill?this._strokeStyle.fill.destroy():this._strokeStyle.texture.destroy(s))}this._fillStyle=null,this._strokeStyle=null,this.instructions=null,this._activePath=null,this._bounds=null,this._stateStack=null,this.customShader=null,this._transform=null}};Da.defaultFillStyle={color:16777215,alpha:1,texture:H.WHITE,matrix:null,fill:null,textureSpace:"local"};Da.defaultStrokeStyle={width:1,color:16777215,alpha:1,alignment:.5,miterLimit:10,cap:"butt",join:"miter",texture:H.WHITE,matrix:null,fill:null,textureSpace:"local",pixelLine:!1};let Ye=Da;class Vf{constructor(e){this._attachedDomElements=[],this._renderer=e,this._renderer.runners.postrender.add(this),this._renderer.runners.init.add(this),this._domElement=document.createElement("div"),this._domElement.style.position="absolute",this._domElement.style.top="0",this._domElement.style.left="0",this._domElement.style.pointerEvents="none",this._domElement.style.zIndex="1000"}init(){this._canvasObserver=new na({domElement:this._domElement,renderer:this._renderer})}addRenderable(e,t){this._attachedDomElements.includes(e)||this._attachedDomElements.push(e)}updateRenderable(e){}validateRenderable(e){return!0}postrender(){const e=this._attachedDomElements;if(e.length===0){this._domElement.remove();return}this._canvasObserver.ensureAttached();for(let t=0;t<e.length;t++){const s=e[t],r=s.element;if(!s.parent||s.globalDisplayStatus<7)r?.remove(),e.splice(t,1),t--;else{this._domElement.contains(r)||(r.style.position="absolute",r.style.pointerEvents="auto",this._domElement.appendChild(r));const n=s.worldTransform,o=s._anchor,a=s.width*o.x,l=s.height*o.y;r.style.transformOrigin=`${a}px ${l}px`,r.style.transform=`matrix(${n.a}, ${n.b}, ${n.c}, ${n.d}, ${n.tx-a}, ${n.ty-l})`,r.style.opacity=s.groupAlpha.toString()}}}destroy(){this._renderer.runners.postrender.remove(this);for(let e=0;e<this._attachedDomElements.length;e++)this._attachedDomElements[e].element?.remove();this._attachedDomElements.length=0,this._domElement.remove(),this._canvasObserver.destroy(),this._renderer=null}}Vf.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"dom"};class sy{constructor(){this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}init(e){this.removeTickerListener(),this.events=e,this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}get pauseUpdate(){return this._pauseUpdate}set pauseUpdate(e){this._pauseUpdate=e}addTickerListener(){this._tickerAdded||!this.domElement||($e.system.add(this._tickerUpdate,this,as.INTERACTION),this._tickerAdded=!0)}removeTickerListener(){this._tickerAdded&&($e.system.remove(this._tickerUpdate,this),this._tickerAdded=!1)}pointerMoved(){this._didMove=!0}_update(){if(!this.domElement||this._pauseUpdate)return;if(this._didMove){this._didMove=!1;return}const e=this.events._rootPointerEvent;this.events.supportsTouchEvents&&e.pointerType==="touch"||globalThis.document.dispatchEvent(this.events.supportsPointerEvents?new PointerEvent("pointermove",{clientX:e.clientX,clientY:e.clientY,pointerType:e.pointerType,pointerId:e.pointerId}):new MouseEvent("mousemove",{clientX:e.clientX,clientY:e.clientY}))}_tickerUpdate(e){this._deltaTime+=e.deltaTime,!(this._deltaTime<this.interactionFrequency)&&(this._deltaTime=0,this._update())}destroy(){this.removeTickerListener(),this.events=null,this.domElement=null,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}}const ft=new sy;class vi extends Ls{constructor(){super(...arguments),this.client=new ce,this.movement=new ce,this.offset=new ce,this.global=new ce,this.screen=new ce}get clientX(){return this.client.x}get clientY(){return this.client.y}get x(){return this.clientX}get y(){return this.clientY}get movementX(){return this.movement.x}get movementY(){return this.movement.y}get offsetX(){return this.offset.x}get offsetY(){return this.offset.y}get globalX(){return this.global.x}get globalY(){return this.global.y}get screenX(){return this.screen.x}get screenY(){return this.screen.y}getLocalPosition(e,t,s){return e.worldTransform.applyInverse(s||this.global,t)}getModifierState(e){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(e)}initMouseEvent(e,t,s,r,n,o,a,l,h,c,u,d,f,p,m){throw new Error("Method not implemented.")}}class Fe extends vi{constructor(){super(...arguments),this.width=0,this.height=0,this.isPrimary=!1,this.persistentDeviceId=0}getCoalescedEvents(){return this.type==="pointermove"||this.type==="mousemove"||this.type==="touchmove"?[this]:[]}getPredictedEvents(){throw new Error("getPredictedEvents is not supported!")}}class cs extends vi{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}cs.DOM_DELTA_PIXEL=0;cs.DOM_DELTA_LINE=1;cs.DOM_DELTA_PAGE=2;const iy=2048,ry=new ce,Zs=new ce;class jf{constructor(e){this.dispatch=new Re,this.moveOnAll=!1,this.enableGlobalMoveEvents=!0,this.mappingState={trackingData:{}},this.eventPool=new Map,this._allInteractiveElements=[],this._hitElements=[],this._isPointerMoveEvent=!1,this.rootTarget=e,this.hitPruneFn=this.hitPruneFn.bind(this),this.hitTestFn=this.hitTestFn.bind(this),this.mapPointerDown=this.mapPointerDown.bind(this),this.mapPointerMove=this.mapPointerMove.bind(this),this.mapPointerOut=this.mapPointerOut.bind(this),this.mapPointerOver=this.mapPointerOver.bind(this),this.mapPointerUp=this.mapPointerUp.bind(this),this.mapPointerUpOutside=this.mapPointerUpOutside.bind(this),this.mapWheel=this.mapWheel.bind(this),this.mapContextMenu=this.mapContextMenu.bind(this),this.mappingTable={},this.addEventMapping("pointerdown",this.mapPointerDown),this.addEventMapping("pointermove",this.mapPointerMove),this.addEventMapping("pointerout",this.mapPointerOut),this.addEventMapping("pointerleave",this.mapPointerOut),this.addEventMapping("pointerover",this.mapPointerOver),this.addEventMapping("pointerup",this.mapPointerUp),this.addEventMapping("pointerupoutside",this.mapPointerUpOutside),this.addEventMapping("wheel",this.mapWheel),this.addEventMapping("contextmenu",this.mapContextMenu)}addEventMapping(e,t){this.mappingTable[e]||(this.mappingTable[e]=[]),this.mappingTable[e].push({fn:t,priority:0}),this.mappingTable[e].sort((s,r)=>s.priority-r.priority)}dispatchEvent(e,t){e.propagationStopped=!1,e.propagationImmediatelyStopped=!1,this.propagate(e,t),this.dispatch.emit(t||e.type,e)}mapEvent(e){if(!this.rootTarget)return;const t=this.mappingTable[e.type];if(t)for(let s=0,r=t.length;s<r;s++)t[s].fn(e);else z(`[EventBoundary]: Event mapping not defined for ${e.type}`)}hitTest(e,t){ft.pauseUpdate=!0;const r=this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive",n=this[r](this.rootTarget,this.rootTarget.eventMode,ry.set(e,t),this.hitTestFn,this.hitPruneFn);return n&&n[0]}propagate(e,t){if(!e.target)return;const s=e.composedPath();e.eventPhase=e.CAPTURING_PHASE;for(let r=0,n=s.length-1;r<n;r++)if(e.currentTarget=s[r],this.notifyTarget(e,t),e.propagationStopped||e.propagationImmediatelyStopped)return;if(e.eventPhase=e.AT_TARGET,e.currentTarget=e.target,this.notifyTarget(e,t),!(e.propagationStopped||e.propagationImmediatelyStopped)){e.eventPhase=e.BUBBLING_PHASE;for(let r=s.length-2;r>=0;r--)if(e.currentTarget=s[r],this.notifyTarget(e,t),e.propagationStopped||e.propagationImmediatelyStopped)return}}all(e,t,s=this._allInteractiveElements){if(s.length===0)return;e.eventPhase=e.BUBBLING_PHASE;const r=Array.isArray(t)?t:[t];for(let n=s.length-1;n>=0;n--)r.forEach(o=>{e.currentTarget=s[n],this.notifyTarget(e,o)})}propagationPath(e){const t=[e];for(let s=0;s<iy&&e!==this.rootTarget&&e.parent;s++){if(!e.parent)throw new Error("Cannot find propagation path to disconnected target");t.push(e.parent),e=e.parent}return t.reverse(),t}hitTestMoveRecursive(e,t,s,r,n,o=!1){let a=!1;if(this._interactivePrune(e))return null;if((e.eventMode==="dynamic"||t==="dynamic")&&(ft.pauseUpdate=!1),e.interactiveChildren&&e.children){const c=e.children;for(let u=c.length-1;u>=0;u--){const d=c[u],f=this.hitTestMoveRecursive(d,this._isInteractive(t)?t:d.eventMode,s,r,n,o||n(e,s));if(f){if(f.length>0&&!f[f.length-1].parent)continue;const p=e.isInteractive();(f.length>0||p)&&(p&&this._allInteractiveElements.push(e),f.push(e)),this._hitElements.length===0&&(this._hitElements=f),a=!0}}}const l=this._isInteractive(t),h=e.isInteractive();return h&&h&&this._allInteractiveElements.push(e),o||this._hitElements.length>0?null:a?this._hitElements:l&&!n(e,s)&&r(e,s)?h?[e]:[]:null}hitTestRecursive(e,t,s,r,n){if(this._interactivePrune(e)||n(e,s))return null;if((e.eventMode==="dynamic"||t==="dynamic")&&(ft.pauseUpdate=!1),e.interactiveChildren&&e.children){const l=e.children,h=s;for(let c=l.length-1;c>=0;c--){const u=l[c],d=this.hitTestRecursive(u,this._isInteractive(t)?t:u.eventMode,h,r,n);if(d){if(d.length>0&&!d[d.length-1].parent)continue;const f=e.isInteractive();return(d.length>0||f)&&d.push(e),d}}}const o=this._isInteractive(t),a=e.isInteractive();return o&&r(e,s)?a?[e]:[]:null}_isInteractive(e){return e==="static"||e==="dynamic"}_interactivePrune(e){return!e||!e.visible||!e.renderable||!e.measurable||e.eventMode==="none"||e.eventMode==="passive"&&!e.interactiveChildren}hitPruneFn(e,t){if(e.hitArea&&(e.worldTransform.applyInverse(t,Zs),!e.hitArea.contains(Zs.x,Zs.y)))return!0;if(e.effects&&e.effects.length)for(let s=0;s<e.effects.length;s++){const r=e.effects[s];if(r.containsPoint&&!r.containsPoint(t,this.hitTestFn))return!0}return!1}hitTestFn(e,t){return e.hitArea?!0:e?.containsPoint?(e.worldTransform.applyInverse(t,Zs),e.containsPoint(Zs)):!1}notifyTarget(e,t){if(!e.currentTarget.isInteractive())return;t??(t=e.type);const s=`on${t}`;e.currentTarget[s]?.(e);const r=e.eventPhase===e.CAPTURING_PHASE||e.eventPhase===e.AT_TARGET?`${t}capture`:t;this._notifyListeners(e,r),e.eventPhase===e.AT_TARGET&&this._notifyListeners(e,t)}mapPointerDown(e){if(!(e instanceof Fe)){z("EventBoundary cannot map a non-pointer event as a pointer event");return}const t=this.createPointerEvent(e);if(this.dispatchEvent(t,"pointerdown"),t.pointerType==="touch")this.dispatchEvent(t,"touchstart");else if(t.pointerType==="mouse"||t.pointerType==="pen"){const r=t.button===2;this.dispatchEvent(t,r?"rightdown":"mousedown")}const s=this.trackingData(e.pointerId);s.pressTargetsByButton[e.button]=t.composedPath(),this.freeEvent(t)}mapPointerMove(e){if(!(e instanceof Fe)){z("EventBoundary cannot map a non-pointer event as a pointer event");return}this._allInteractiveElements.length=0,this._hitElements.length=0,this._isPointerMoveEvent=!0;const t=this.createPointerEvent(e);this._isPointerMoveEvent=!1;const s=t.pointerType==="mouse"||t.pointerType==="pen",r=this.trackingData(e.pointerId),n=this.findMountedTarget(r.overTargets);if(r.overTargets?.length>0&&n!==t.target){const l=e.type==="mousemove"?"mouseout":"pointerout",h=this.createPointerEvent(e,l,n);if(this.dispatchEvent(h,"pointerout"),s&&this.dispatchEvent(h,"mouseout"),!t.composedPath().includes(n)){const c=this.createPointerEvent(e,"pointerleave",n);for(c.eventPhase=c.AT_TARGET;c.target&&!t.composedPath().includes(c.target);)c.currentTarget=c.target,this.notifyTarget(c),s&&this.notifyTarget(c,"mouseleave"),c.target=c.target.parent;this.freeEvent(c)}this.freeEvent(h)}if(n!==t.target){const l=e.type==="mousemove"?"mouseover":"pointerover",h=this.clonePointerEvent(t,l);this.dispatchEvent(h,"pointerover"),s&&this.dispatchEvent(h,"mouseover");let c=n?.parent;for(;c&&c!==this.rootTarget.parent&&c!==t.target;)c=c.parent;if(!c||c===this.rootTarget.parent){const d=this.clonePointerEvent(t,"pointerenter");for(d.eventPhase=d.AT_TARGET;d.target&&d.target!==n&&d.target!==this.rootTarget.parent;)d.currentTarget=d.target,this.notifyTarget(d),s&&this.notifyTarget(d,"mouseenter"),d.target=d.target.parent;this.freeEvent(d)}this.freeEvent(h)}const o=[],a=this.enableGlobalMoveEvents??!0;this.moveOnAll?o.push("pointermove"):this.dispatchEvent(t,"pointermove"),a&&o.push("globalpointermove"),t.pointerType==="touch"&&(this.moveOnAll?o.splice(1,0,"touchmove"):this.dispatchEvent(t,"touchmove"),a&&o.push("globaltouchmove")),s&&(this.moveOnAll?o.splice(1,0,"mousemove"):this.dispatchEvent(t,"mousemove"),a&&o.push("globalmousemove"),this.cursor=t.target?.cursor),o.length>0&&this.all(t,o),this._allInteractiveElements.length=0,this._hitElements.length=0,r.overTargets=t.composedPath(),this.freeEvent(t)}mapPointerOver(e){if(!(e instanceof Fe)){z("EventBoundary cannot map a non-pointer event as a pointer event");return}const t=this.trackingData(e.pointerId),s=this.createPointerEvent(e),r=s.pointerType==="mouse"||s.pointerType==="pen";this.dispatchEvent(s,"pointerover"),r&&this.dispatchEvent(s,"mouseover"),s.pointerType==="mouse"&&(this.cursor=s.target?.cursor);const n=this.clonePointerEvent(s,"pointerenter");for(n.eventPhase=n.AT_TARGET;n.target&&n.target!==this.rootTarget.parent;)n.currentTarget=n.target,this.notifyTarget(n),r&&this.notifyTarget(n,"mouseenter"),n.target=n.target.parent;t.overTargets=s.composedPath(),this.freeEvent(s),this.freeEvent(n)}mapPointerOut(e){if(!(e instanceof Fe)){z("EventBoundary cannot map a non-pointer event as a pointer event");return}const t=this.trackingData(e.pointerId);if(t.overTargets){const s=e.pointerType==="mouse"||e.pointerType==="pen",r=this.findMountedTarget(t.overTargets),n=this.createPointerEvent(e,"pointerout",r);this.dispatchEvent(n),s&&this.dispatchEvent(n,"mouseout");const o=this.createPointerEvent(e,"pointerleave",r);for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==this.rootTarget.parent;)o.currentTarget=o.target,this.notifyTarget(o),s&&this.notifyTarget(o,"mouseleave"),o.target=o.target.parent;t.overTargets=null,this.freeEvent(n),this.freeEvent(o)}this.cursor=null}mapPointerUp(e){if(!(e instanceof Fe)){z("EventBoundary cannot map a non-pointer event as a pointer event");return}const t=performance.now(),s=this.createPointerEvent(e);if(this.dispatchEvent(s,"pointerup"),s.pointerType==="touch")this.dispatchEvent(s,"touchend");else if(s.pointerType==="mouse"||s.pointerType==="pen"){const a=s.button===2;this.dispatchEvent(s,a?"rightup":"mouseup")}const r=this.trackingData(e.pointerId),n=this.findMountedTarget(r.pressTargetsByButton[e.button]);let o=n;if(n&&!s.composedPath().includes(n)){let a=n;for(;a&&!s.composedPath().includes(a);){if(s.currentTarget=a,this.notifyTarget(s,"pointerupoutside"),s.pointerType==="touch")this.notifyTarget(s,"touchendoutside");else if(s.pointerType==="mouse"||s.pointerType==="pen"){const l=s.button===2;this.notifyTarget(s,l?"rightupoutside":"mouseupoutside")}a=a.parent}delete r.pressTargetsByButton[e.button],o=a}if(o){const a=this.clonePointerEvent(s,"click");a.target=o,a.path=null,r.clicksByButton[e.button]||(r.clicksByButton[e.button]={clickCount:0,target:a.target,timeStamp:t});const l=r.clicksByButton[e.button];if(l.target===a.target&&t-l.timeStamp<200?++l.clickCount:l.clickCount=1,l.target=a.target,l.timeStamp=t,a.detail=l.clickCount,a.pointerType==="mouse"){const h=a.button===2;this.dispatchEvent(a,h?"rightclick":"click")}else a.pointerType==="touch"&&this.dispatchEvent(a,"tap");this.dispatchEvent(a,"pointertap"),this.freeEvent(a)}this.freeEvent(s)}mapPointerUpOutside(e){if(!(e instanceof Fe)){z("EventBoundary cannot map a non-pointer event as a pointer event");return}const t=this.trackingData(e.pointerId),s=this.findMountedTarget(t.pressTargetsByButton[e.button]),r=this.createPointerEvent(e);if(s){let n=s;for(;n;)r.currentTarget=n,this.notifyTarget(r,"pointerupoutside"),r.pointerType==="touch"?this.notifyTarget(r,"touchendoutside"):(r.pointerType==="mouse"||r.pointerType==="pen")&&this.notifyTarget(r,r.button===2?"rightupoutside":"mouseupoutside"),n=n.parent;delete t.pressTargetsByButton[e.button]}this.freeEvent(r)}mapWheel(e){if(!(e instanceof cs)){z("EventBoundary cannot map a non-wheel event as a wheel event");return}const t=this.createWheelEvent(e);this.dispatchEvent(t),this.freeEvent(t)}mapContextMenu(e){if(!(e instanceof Fe)){z("EventBoundary cannot map a non-pointer event as a pointer event");return}const t=this.createPointerEvent(e);this.dispatchEvent(t,"contextmenu"),this.freeEvent(t)}findMountedTarget(e){if(!e)return null;let t=e[0];for(let s=1;s<e.length&&e[s].parent===t;s++)t=e[s];return t}createPointerEvent(e,t,s){const r=this.allocateEvent(Fe);return this.copyPointerData(e,r),this.copyMouseData(e,r),this.copyData(e,r),r.nativeEvent=e.nativeEvent,r.originalEvent=e,r.target=s??this.hitTest(r.global.x,r.global.y)??this._hitElements[0],typeof t=="string"&&(r.type=t),r}createWheelEvent(e){const t=this.allocateEvent(cs);return this.copyWheelData(e,t),this.copyMouseData(e,t),this.copyData(e,t),t.nativeEvent=e.nativeEvent,t.originalEvent=e,t.target=this.hitTest(t.global.x,t.global.y),t}clonePointerEvent(e,t){const s=this.allocateEvent(Fe);return s.nativeEvent=e.nativeEvent,s.originalEvent=e.originalEvent,this.copyPointerData(e,s),this.copyMouseData(e,s),this.copyData(e,s),s.target=e.target,s.path=e.composedPath().slice(),s.type=t??s.type,s}copyWheelData(e,t){t.deltaMode=e.deltaMode,t.deltaX=e.deltaX,t.deltaY=e.deltaY,t.deltaZ=e.deltaZ}copyPointerData(e,t){e instanceof Fe&&t instanceof Fe&&(t.pointerId=e.pointerId,t.width=e.width,t.height=e.height,t.isPrimary=e.isPrimary,t.pointerType=e.pointerType,t.pressure=e.pressure,t.tangentialPressure=e.tangentialPressure,t.tiltX=e.tiltX,t.tiltY=e.tiltY,t.twist=e.twist,t.persistentDeviceId=e.persistentDeviceId)}copyMouseData(e,t){e instanceof vi&&t instanceof vi&&(t.altKey=e.altKey,t.button=e.button,t.buttons=e.buttons,t.client.copyFrom(e.client),t.ctrlKey=e.ctrlKey,t.metaKey=e.metaKey,t.movement.copyFrom(e.movement),t.screen.copyFrom(e.screen),t.shiftKey=e.shiftKey,t.global.copyFrom(e.global))}copyData(e,t){t.isTrusted=e.isTrusted,t.srcElement=e.srcElement,t.timeStamp=performance.now(),t.type=e.type,t.detail=e.detail,t.view=e.view,t.which=e.which,t.layer.copyFrom(e.layer),t.page.copyFrom(e.page)}trackingData(e){return this.mappingState.trackingData[e]||(this.mappingState.trackingData[e]={pressTargetsByButton:{},clicksByButton:{},overTarget:null}),this.mappingState.trackingData[e]}allocateEvent(e){this.eventPool.has(e)||this.eventPool.set(e,[]);const t=this.eventPool.get(e).pop()||new e(this);return t.eventPhase=t.NONE,t.currentTarget=null,t.defaultPrevented=!1,t.path=null,t.target=null,t}freeEvent(e){if(e.manager!==this)throw new Error("It is illegal to free an event not managed by this EventBoundary!");const t=e.constructor;this.eventPool.has(t)||this.eventPool.set(t,[]),this.eventPool.get(t).push(e)}_notifyListeners(e,t){const s=e.currentTarget._events[t];if(s)if("fn"in s)s.once&&e.currentTarget.removeListener(t,s.fn,void 0,!0),s.fn.call(s.context,e);else for(let r=0,n=s.length;r<n&&!e.propagationImmediatelyStopped;r++)s[r].once&&e.currentTarget.removeListener(t,s[r].fn,void 0,!0),s[r].fn.call(s[r].context,e)}}const ny=1,oy={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},Fa=class ko{constructor(e){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=e,this.rootBoundary=new jf(null),ft.init(this),this.autoPreventDefault=!0,this._eventsAdded=!1,this._rootPointerEvent=new Fe(null),this._rootWheelEvent=new cs(null),this._rootContextMenuEvent=new Fe(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy({...ko.defaultEventFeatures},{set:(t,s,r)=>(s==="globalMove"&&(this.rootBoundary.enableGlobalMoveEvents=r),t[s]=r,!0)}),this._onPointerDown=this._onPointerDown.bind(this),this._onPointerMove=this._onPointerMove.bind(this),this._onPointerUp=this._onPointerUp.bind(this),this._onPointerOverOut=this._onPointerOverOut.bind(this),this._onContextMenu=this._onContextMenu.bind(this),this.onWheel=this.onWheel.bind(this)}static get defaultEventMode(){return this._defaultEventMode}init(e){const{canvas:t,resolution:s}=this.renderer;this.setTargetElement(t),this.resolution=s,ko._defaultEventMode=e.eventMode??"passive",Object.assign(this.features,e.eventFeatures??{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(e){this.resolution=e}destroy(){ft.destroy(),this.setTargetElement(null),this.renderer=null,this._currentCursor=null}setCursor(e){e||(e="default");let t=!0;if(globalThis.OffscreenCanvas&&this.domElement instanceof OffscreenCanvas&&(t=!1),this._currentCursor===e)return;this._currentCursor=e;const s=this.cursorStyles[e];if(s)switch(typeof s){case"string":t&&(this.domElement.style.cursor=s);break;case"function":s(e);break;case"object":t&&Object.assign(this.domElement.style,s);break}else t&&typeof e=="string"&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,e)&&(this.domElement.style.cursor=e)}get pointer(){return this._rootPointerEvent}_onPointerDown(e){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const t=this._normalizeToPointerData(e);this.autoPreventDefault&&t[0].isNormalized&&(e.cancelable||!("cancelable"in e))&&e.preventDefault();for(let s=0,r=t.length;s<r;s++){const n=t[s],o=this._bootstrapEvent(this._rootPointerEvent,n);this.rootBoundary.mapEvent(o)}this.setCursor(this.rootBoundary.cursor)}_onPointerMove(e){if(!this.features.move)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,ft.pointerMoved();const t=this._normalizeToPointerData(e);for(let s=0,r=t.length;s<r;s++){const n=this._bootstrapEvent(this._rootPointerEvent,t[s]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}_onPointerUp(e){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;let t=e.target;e.composedPath&&e.composedPath().length>0&&(t=e.composedPath()[0]);const s=t!==this.domElement?"outside":"",r=this._normalizeToPointerData(e);for(let n=0,o=r.length;n<o;n++){const a=this._bootstrapEvent(this._rootPointerEvent,r[n]);a.type+=s,this.rootBoundary.mapEvent(a)}this.setCursor(this.rootBoundary.cursor)}_onPointerOverOut(e){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const t=this._normalizeToPointerData(e);for(let s=0,r=t.length;s<r;s++){const n=this._bootstrapEvent(this._rootPointerEvent,t[s]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}_onContextMenu(e){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const t=this._normalizeToPointerData(e);for(let s=0,r=t.length;s<r;s++){const n=this._bootstrapEvent(this._rootContextMenuEvent,t[s]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}onWheel(e){if(!this.features.wheel)return;const t=this.normalizeWheelEvent(e);this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.rootBoundary.mapEvent(t)}setTargetElement(e){this._removeEvents(),this.domElement=e,ft.domElement=e,this._addEvents()}_addEvents(){if(this._eventsAdded||!this.domElement)return;ft.addTickerListener();const e=this.domElement.style;e&&(globalThis.navigator.msPointerEnabled?(e.msContentZooming="none",e.msTouchAction="none"):this.supportsPointerEvents&&(e.touchAction="none")),this.supportsPointerEvents?(globalThis.document.addEventListener("pointermove",this._onPointerMove,!0),this.domElement.addEventListener("pointerdown",this._onPointerDown,!0),this.domElement.addEventListener("pointerleave",this._onPointerOverOut,!0),this.domElement.addEventListener("pointerover",this._onPointerOverOut,!0),globalThis.addEventListener("pointerup",this._onPointerUp,!0)):(globalThis.document.addEventListener("mousemove",this._onPointerMove,!0),this.domElement.addEventListener("mousedown",this._onPointerDown,!0),this.domElement.addEventListener("mouseout",this._onPointerOverOut,!0),this.domElement.addEventListener("mouseover",this._onPointerOverOut,!0),globalThis.addEventListener("mouseup",this._onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.addEventListener("touchstart",this._onPointerDown,!0),this.domElement.addEventListener("touchend",this._onPointerUp,!0),this.domElement.addEventListener("touchmove",this._onPointerMove,!0))),this.domElement.addEventListener("wheel",this.onWheel,{passive:!0,capture:!0}),this.domElement.addEventListener("contextmenu",this._onContextMenu,!0),this._eventsAdded=!0}_removeEvents(){if(!this._eventsAdded||!this.domElement)return;ft.removeTickerListener();const e=this.domElement.style;e&&(globalThis.navigator.msPointerEnabled?(e.msContentZooming="",e.msTouchAction=""):this.supportsPointerEvents&&(e.touchAction="")),this.supportsPointerEvents?(globalThis.document.removeEventListener("pointermove",this._onPointerMove,!0),this.domElement.removeEventListener("pointerdown",this._onPointerDown,!0),this.domElement.removeEventListener("pointerleave",this._onPointerOverOut,!0),this.domElement.removeEventListener("pointerover",this._onPointerOverOut,!0),globalThis.removeEventListener("pointerup",this._onPointerUp,!0)):(globalThis.document.removeEventListener("mousemove",this._onPointerMove,!0),this.domElement.removeEventListener("mousedown",this._onPointerDown,!0),this.domElement.removeEventListener("mouseout",this._onPointerOverOut,!0),this.domElement.removeEventListener("mouseover",this._onPointerOverOut,!0),globalThis.removeEventListener("mouseup",this._onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.removeEventListener("touchstart",this._onPointerDown,!0),this.domElement.removeEventListener("touchend",this._onPointerUp,!0),this.domElement.removeEventListener("touchmove",this._onPointerMove,!0))),this.domElement.removeEventListener("wheel",this.onWheel,!0),this.domElement.removeEventListener("contextmenu",this._onContextMenu,!0),this.domElement=null,this._eventsAdded=!1}mapPositionToPoint(e,t,s){const r=this.domElement.isConnected?this.domElement.getBoundingClientRect():{width:this.domElement.width,height:this.domElement.height,left:0,top:0},n=1/this.resolution;e.x=(t-r.left)*(this.domElement.width/r.width)*n,e.y=(s-r.top)*(this.domElement.height/r.height)*n}_normalizeToPointerData(e){const t=[];if(this.supportsTouchEvents&&e instanceof TouchEvent)for(let s=0,r=e.changedTouches.length;s<r;s++){const n=e.changedTouches[s];typeof n.button>"u"&&(n.button=0),typeof n.buttons>"u"&&(n.buttons=1),typeof n.isPrimary>"u"&&(n.isPrimary=e.touches.length===1&&e.type==="touchstart"),typeof n.width>"u"&&(n.width=n.radiusX||1),typeof n.height>"u"&&(n.height=n.radiusY||1),typeof n.tiltX>"u"&&(n.tiltX=0),typeof n.tiltY>"u"&&(n.tiltY=0),typeof n.pointerType>"u"&&(n.pointerType="touch"),typeof n.pointerId>"u"&&(n.pointerId=n.identifier||0),typeof n.pressure>"u"&&(n.pressure=n.force||.5),typeof n.twist>"u"&&(n.twist=0),typeof n.tangentialPressure>"u"&&(n.tangentialPressure=0),typeof n.layerX>"u"&&(n.layerX=n.offsetX=n.clientX),typeof n.layerY>"u"&&(n.layerY=n.offsetY=n.clientY),n.isNormalized=!0,n.type=e.type,n.altKey??(n.altKey=e.altKey),n.ctrlKey??(n.ctrlKey=e.ctrlKey),n.metaKey??(n.metaKey=e.metaKey),n.shiftKey??(n.shiftKey=e.shiftKey),t.push(n)}else if(!globalThis.MouseEvent||e instanceof MouseEvent&&(!this.supportsPointerEvents||!(e instanceof globalThis.PointerEvent))){const s=e;typeof s.isPrimary>"u"&&(s.isPrimary=!0),typeof s.width>"u"&&(s.width=1),typeof s.height>"u"&&(s.height=1),typeof s.tiltX>"u"&&(s.tiltX=0),typeof s.tiltY>"u"&&(s.tiltY=0),typeof s.pointerType>"u"&&(s.pointerType="mouse"),typeof s.pointerId>"u"&&(s.pointerId=ny),typeof s.pressure>"u"&&(s.pressure=.5),typeof s.twist>"u"&&(s.twist=0),typeof s.tangentialPressure>"u"&&(s.tangentialPressure=0),s.isNormalized=!0,t.push(s)}else t.push(e);return t}normalizeWheelEvent(e){const t=this._rootWheelEvent;return this._transferMouseData(t,e),t.deltaX=e.deltaX,t.deltaY=e.deltaY,t.deltaZ=e.deltaZ,t.deltaMode=e.deltaMode,this.mapPositionToPoint(t.screen,e.clientX,e.clientY),t.global.copyFrom(t.screen),t.offset.copyFrom(t.screen),t.nativeEvent=e,t.type=e.type,t}_bootstrapEvent(e,t){return e.originalEvent=null,e.nativeEvent=t,e.pointerId=t.pointerId,e.width=t.width,e.height=t.height,e.isPrimary=t.isPrimary,e.pointerType=t.pointerType,e.pressure=t.pressure,e.tangentialPressure=t.tangentialPressure,e.tiltX=t.tiltX,e.tiltY=t.tiltY,e.twist=t.twist,this._transferMouseData(e,t),this.mapPositionToPoint(e.screen,t.clientX,t.clientY),e.global.copyFrom(e.screen),e.offset.copyFrom(e.screen),e.isTrusted=t.isTrusted,e.type==="pointerleave"&&(e.type="pointerout"),e.type.startsWith("mouse")&&(e.type=e.type.replace("mouse","pointer")),e.type.startsWith("touch")&&(e.type=oy[e.type]||e.type),e}_transferMouseData(e,t){e.isTrusted=t.isTrusted,e.srcElement=t.srcElement,e.timeStamp=performance.now(),e.type=t.type,e.altKey=t.altKey,e.button=t.button,e.buttons=t.buttons,e.client.x=t.clientX,e.client.y=t.clientY,e.ctrlKey=t.ctrlKey,e.metaKey=t.metaKey,e.movement.x=t.movementX,e.movement.y=t.movementY,e.page.x=t.pageX,e.page.y=t.pageY,e.relatedTarget=null,e.shiftKey=t.shiftKey}};Fa.extension={name:"events",type:[S.WebGLSystem,S.CanvasSystem,S.WebGPUSystem],priority:-1};Fa.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let Xf=Fa;const ay={onclick:null,oncontextmenu:null,onmousedown:null,onmouseenter:null,onmouseleave:null,onmousemove:null,onglobalmousemove:null,onmouseout:null,onmouseover:null,onmouseup:null,onmouseupoutside:null,onpointercancel:null,onpointerdown:null,onpointerenter:null,onpointerleave:null,onpointermove:null,onglobalpointermove:null,onpointerout:null,onpointerover:null,onpointertap:null,onpointerup:null,onpointerupoutside:null,onrightclick:null,onrightdown:null,onrightup:null,onrightupoutside:null,ontap:null,ontouchcancel:null,ontouchend:null,ontouchendoutside:null,ontouchmove:null,onglobaltouchmove:null,ontouchstart:null,onwheel:null,get interactive(){return this.eventMode==="dynamic"||this.eventMode==="static"},set interactive(i){this.eventMode=i?"static":"passive"},_internalEventMode:void 0,get eventMode(){return this._internalEventMode??Xf.defaultEventMode},set eventMode(i){this._internalEventMode=i},isInteractive(){return this.eventMode==="static"||this.eventMode==="dynamic"},interactiveChildren:!0,hitArea:null,addEventListener(i,e,t){const s=typeof t=="boolean"&&t||typeof t=="object"&&t.capture,r=typeof t=="object"?t.signal:void 0,n=typeof t=="object"?t.once===!0:!1,o=typeof e=="function"?void 0:e;i=s?`${i}capture`:i;const a=typeof e=="function"?e:e.handleEvent,l=this;r&&r.addEventListener("abort",()=>{l.off(i,a,o)}),n?l.once(i,a,o):l.on(i,a,o)},removeEventListener(i,e,t){const s=typeof t=="boolean"&&t||typeof t=="object"&&t.capture,r=typeof e=="function"?void 0:e;i=s?`${i}capture`:i,e=typeof e=="function"?e:e.handleEvent,this.off(i,e,r)},dispatchEvent(i){if(!(i instanceof Ls))throw new Error("Container cannot propagate events outside of the Federated Events API");return i.defaultPrevented=!1,i.path=null,i.target=this,i.manager.dispatchEvent(i),!i.defaultPrevented}};let ys;function Cc(i){const e=te.get().createCanvas(6,1),t=e.getContext("2d");return t.fillStyle=i,t.fillRect(0,0,6,1),e}function Oa(){if(ys!==void 0)return ys;try{const i=Cc("#ff00ff"),e=Cc("#ffff00"),s=te.get().createCanvas(6,1).getContext("2d");s.globalCompositeOperation="multiply",s.drawImage(i,0,0),s.drawImage(e,2,0);const r=s.getImageData(2,0,1,1);if(!r)ys=!1;else{const n=r.data;ys=n[0]===255&&n[1]===0&&n[2]===0}}catch{ys=!1}return ys}const K={canvas:null,convertTintToImage:!1,cacheStepsPerColorChannel:8,canUseMultiply:Oa(),tintMethod:null,_canvasSourceCache:new WeakMap,_unpremultipliedCache:new WeakMap,getCanvasSource:i=>{const e=i.source,t=e?.resource;if(!t)return null;const s=e.alphaMode==="premultiplied-alpha",r=e.resourceWidth??e.pixelWidth,n=e.resourceHeight??e.pixelHeight,o=r!==e.pixelWidth||n!==e.pixelHeight;if(s){if((t instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas)&&!o)return t;const a=K._unpremultipliedCache.get(e);if(a?.resourceId===e._resourceId)return a.canvas}if(t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int8Array||t instanceof Uint16Array||t instanceof Int16Array||t instanceof Uint32Array||t instanceof Int32Array||t instanceof Float32Array||t instanceof ArrayBuffer){const a=K._canvasSourceCache.get(e);if(a?.resourceId===e._resourceId)return a.canvas;const l=te.get().createCanvas(e.pixelWidth,e.pixelHeight),h=l.getContext("2d"),c=h.createImageData(e.pixelWidth,e.pixelHeight),u=c.data,d=t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength);if(e.format==="bgra8unorm")for(let f=0;f<u.length&&f+3<d.length;f+=4)u[f]=d[f+2],u[f+1]=d[f+1],u[f+2]=d[f],u[f+3]=d[f+3];else u.set(d.subarray(0,u.length));return h.putImageData(c,0,0),K._canvasSourceCache.set(e,{canvas:l,resourceId:e._resourceId}),l}if(s){const a=te.get().createCanvas(e.pixelWidth,e.pixelHeight),l=a.getContext("2d",{willReadFrequently:!0});a.width=e.pixelWidth,a.height=e.pixelHeight,l.drawImage(t,0,0);const h=l.getImageData(0,0,a.width,a.height),c=h.data;for(let u=0;u<c.length;u+=4){const d=c[u+3];if(d>0){const f=255/d;c[u]=Math.min(255,c[u]*f+.5),c[u+1]=Math.min(255,c[u+1]*f+.5),c[u+2]=Math.min(255,c[u+2]*f+.5)}}return l.putImageData(h,0,0),K._unpremultipliedCache.set(e,{canvas:a,resourceId:e._resourceId}),a}if(o){const a=K._canvasSourceCache.get(e);if(a?.resourceId===e._resourceId)return a.canvas;const l=te.get().createCanvas(e.pixelWidth,e.pixelHeight),h=l.getContext("2d");return l.width=e.pixelWidth,l.height=e.pixelHeight,h.drawImage(t,0,0),K._canvasSourceCache.set(e,{canvas:l,resourceId:e._resourceId}),l}return t},getTintedCanvas:(i,e)=>{const t=i.texture,s=le.shared.setValue(e).toHex(),r=t.tintCache||(t.tintCache={}),n=r[s],o=t.source._resourceId;if(n?.tintId===o)return n;const a=n&&"getContext"in n?n:te.get().createCanvas();return K.tintMethod(t,e,a),a.tintId=o,r[s]=a,r[s]},getTintedPattern:(i,e)=>{const t=le.shared.setValue(e).toHex(),s=i.patternCache||(i.patternCache={}),r=i.source._resourceId;let n=s[t];return n?.tintId===r||(K.canvas||(K.canvas=te.get().createCanvas()),K.tintMethod(i,e,K.canvas),n=K.canvas.getContext("2d").createPattern(K.canvas,"repeat"),n.tintId=r,s[t]=n),n},applyPatternTransform:(i,e,t=!0)=>{if(!e)return;const s=i;if(!s.setTransform)return;const r=globalThis.DOMMatrix;if(!r)return;const n=new r([e.a,e.b,e.c,e.d,e.tx,e.ty]);s.setTransform(t?n.inverse():n)},tintWithMultiply:(i,e,t)=>{const s=t.getContext("2d"),r=i.frame.clone(),n=i.source._resolution??i.source.resolution??1,o=i.rotate;r.x*=n,r.y*=n,r.width*=n,r.height*=n;const a=Q.isVertical(o),l=a?r.height:r.width,h=a?r.width:r.height;t.width=Math.ceil(l),t.height=Math.ceil(h),s.save(),e!==16777215&&(s.fillStyle=le.shared.setValue(e).toHex(),s.fillRect(0,0,l,h),s.globalCompositeOperation="multiply");const c=K.getCanvasSource(i);if(!c){s.restore();return}o&&K._applyInverseRotation(s,o,r.width,r.height),s.drawImage(c,r.x,r.y,r.width,r.height,0,0,r.width,r.height),e!==16777215&&(s.globalCompositeOperation="destination-atop",s.drawImage(c,r.x,r.y,r.width,r.height,0,0,r.width,r.height)),s.restore()},tintWithOverlay:(i,e,t)=>{const s=t.getContext("2d"),r=i.frame.clone(),n=i.source._resolution??i.source.resolution??1,o=i.rotate;r.x*=n,r.y*=n,r.width*=n,r.height*=n;const a=Q.isVertical(o),l=a?r.height:r.width,h=a?r.width:r.height;t.width=Math.ceil(l),t.height=Math.ceil(h),s.save(),s.globalCompositeOperation="copy",s.fillStyle=le.shared.setValue(e).toHex(),s.fillRect(0,0,l,h),s.globalCompositeOperation="destination-atop";const c=K.getCanvasSource(i);if(!c){s.restore();return}o&&K._applyInverseRotation(s,o,r.width,r.height),s.drawImage(c,r.x,r.y,r.width,r.height,0,0,r.width,r.height),s.restore()},tintWithPerPixel:(i,e,t)=>{const s=t.getContext("2d"),r=i.frame.clone(),n=i.source._resolution??i.source.resolution??1,o=i.rotate;r.x*=n,r.y*=n,r.width*=n,r.height*=n;const a=Q.isVertical(o),l=a?r.height:r.width,h=a?r.width:r.height;t.width=Math.ceil(l),t.height=Math.ceil(h),s.save(),s.globalCompositeOperation="copy";const c=K.getCanvasSource(i);if(!c){s.restore();return}o&&K._applyInverseRotation(s,o,r.width,r.height),s.drawImage(c,r.x,r.y,r.width,r.height,0,0,r.width,r.height),s.restore();const u=e>>16&255,d=e>>8&255,f=e&255,p=s.getImageData(0,0,l,h),m=p.data;for(let g=0;g<m.length;g+=4)m[g]=m[g]*u/255,m[g+1]=m[g+1]*d/255,m[g+2]=m[g+2]*f/255;s.putImageData(p,0,0)},_applyInverseRotation:(i,e,t,s)=>{const r=Q.inv(e),n=Q.uX(r),o=Q.uY(r),a=Q.vX(r),l=Q.vY(r),h=-Math.min(0,n*t,a*s,n*t+a*s),c=-Math.min(0,o*t,l*s,o*t+l*s);i.transform(n,o,a,l,h,c)}};K.tintMethod=K.canUseMultiply?K.tintWithMultiply:K.tintWithPerPixel;const Gn=32767;function kc(i,e){return(i<<17)+(e<<2)}class qf{constructor(e){this._buckets=new Map,this._screens=new Zo,this._enableFullScreen=!1,this.canvasOptions=e||{}}get enableFullScreen(){return N(dt,"CanvasPool.enableFullScreen is no longer used, the pool sizes canvases to the screens registered with setScreenSize."),this._enableFullScreen}set enableFullScreen(e){N(dt,"CanvasPool.enableFullScreen is no longer used, the pool sizes canvases to the screens registered with setScreenSize."),this._enableFullScreen=e}_createCanvasAndContext(e,t){const s=te.get().createCanvas();s.width=e,s.height=t;const r=s.getContext("2d");return{canvas:s,context:r}}getOptimalCanvasAndContext(e,t,s=1){const{width:r,height:n}=this.getOptimalSize(e,t,s);(r>Gn||n>Gn)&&z(`CanvasPool: ${r}x${n} is larger than the ${Gn}px pool key limit, canvases of this size may be pooled together`);const o=kc(r,n);let a=this._buckets.get(o);a||(a=[],this._buckets.set(o,a));let l=a.pop();return l||(l=this._createCanvasAndContext(r,n)),l}getOptimalSize(e,t,s=1){const r=Math.ceil(e*s-1e-6),n=Math.ceil(t*s-1e-6),o=rs(r),a=this._screens.getFittingWidth(r),l=rs(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}}returnCanvasAndContext(e){const t=e.canvas,{width:s,height:r}=t,n=this._buckets.get(kc(s,r));n&&(e.context.resetTransform(),e.context.clearRect(0,0,s,r),n.push(e))}setScreenSize(e,t,s){this._screens.set(e,t,s)&&this._pruneScreenCanvases()}removeScreen(e){this._screens.remove(e)&&this._pruneScreenCanvases()}clear(){this._buckets.clear()}_pruneScreenCanvases(){for(const[e]of this._buckets){const t=e>>>17,s=e>>>2&32767;(ns(t)||this._screens.hasWidth(t))&&(ns(s)||this._screens.hasHeight(s))||this._buckets.delete(e)}}}const Rt=new qf;us.register(Rt);const Ec=new L;function La(i,e){e.clear();const t=e.matrix;for(let s=0;s<i.length;s++){const r=i[s];if(r.globalDisplayStatus<7)continue;const n=r.renderGroup??r.parentRenderGroup;n?.isCachedAsTexture?e.matrix=Ec.copyFrom(n.textureOffsetInverseTransform).append(r.worldTransform):n?._parentCacheAsTextureRenderGroup?e.matrix=Ec.copyFrom(n._parentCacheAsTextureRenderGroup.inverseWorldTransform).append(r.groupTransform):e.matrix=r.worldTransform,e.addBounds(r.bounds)}return e.matrix=t,e}const ly=new Ee;function Ua(i,e,t,s,r=!1,n){const o=ly;o.minX=0,o.minY=0,o.maxX=i.width/s|0,o.maxY=i.height/s|0;const a=Te.getOptimalTexture({width:o.width,height:o.height,resolution:s,autoGenerateMipmaps:r,scaleMode:n});return a.source.uploadMethodId="image",a.source.resource=i,a.source.alphaMode="premultiply-alpha-on-upload",a.frame.width=e/s,a.frame.height=t/s,a.source.emit("update",a.source),a.updateUvs(),a}function Eo(i){return typeof i.getCanvasFilterString=="function"}class hy{constructor(){this.skip=!1,this.useClip=!1,this.filters=null,this.container=null,this.bounds=new Ee,this.cssFilterString=""}}class Yf{constructor(e){this._filterStack=[],this._filterStackIndex=0,this._savedStates=[],this._alphaMultiplier=1,this._warnedFilterTypes=new Set,this.renderer=e}push(e){const t=this._pushFilterFrame(),s=e.filterEffect.filters;if(t.skip=!1,t.useClip=!1,t.filters=s,t.container=e.container,t.cssFilterString="",s.every(l=>!l.enabled)){t.skip=!0;return}const r=[],n=1;for(const l of s){if(!l.enabled)continue;if(!Eo(l)){this._warnUnsupportedFilter(l);continue}const h=l.getCanvasFilterString();if(h===null){this._warnUnsupportedFilter(l);continue}h&&r.push(h)}if(r.length===0&&n===1){t.skip=!0;return}t.cssFilterString=r.join(" "),this._calculateFilterArea(e,t.bounds),t.useClip=!!e.filterEffect.filterArea;const o=this.renderer.canvasContext.activeContext,a=o.filter||"none";if(this._savedStates.push({filter:a,alphaMultiplier:this._alphaMultiplier}),t.useClip&&Number.isFinite(t.bounds.width)&&Number.isFinite(t.bounds.height)&&t.bounds.width>0&&t.bounds.height>0){const l=this.renderer.canvasContext.activeResolution||1;o.save(),o.setTransform(1,0,0,1,0,0),o.beginPath(),o.rect(t.bounds.x*l,t.bounds.y*l,t.bounds.width*l,t.bounds.height*l),o.clip()}else t.useClip=!1;t.cssFilterString&&(o.filter=a!=="none"?`${a} ${t.cssFilterString}`:t.cssFilterString)}pop(){const e=this._popFilterFrame();if(e.skip)return;const t=this._savedStates.pop();if(!t)return;const s=this.renderer.canvasContext.activeContext;e.useClip?s.restore():s.filter=t.filter,this._alphaMultiplier=t.alphaMultiplier}generateFilteredTexture({texture:e,filters:t}){if(!t?.length||t.every(_=>!_.enabled))return e;const s=[],r=1;for(const _ of t){if(!_.enabled)continue;if(!Eo(_)){this._warnUnsupportedFilter(_);continue}const y=_.getCanvasFilterString();if(y===null){this._warnUnsupportedFilter(_);continue}y&&s.push(y)}if(s.length===0&&r===1)return e;const n=K.getCanvasSource(e);if(!n)return e;const o=e.frame,a=e.source._resolution??e.source.resolution??1,l=o.width,h=o.height,c=Rt.getOptimalCanvasAndContext(l,h,a),{canvas:u,context:d}=c;d.setTransform(1,0,0,1,0,0),d.clearRect(0,0,u.width,u.height),s.length&&(d.filter=s.join(" "));const f=o.x*a,p=o.y*a,m=l*a,g=h*a;return d.drawImage(n,f,p,m,g,0,0,m,g),d.filter="none",d.globalAlpha=1,Ua(u,l,h,a)}_calculateFilterArea(e,t){if(e.renderables?La(e.renderables,t):e.filterEffect.filterArea?(t.clear(),t.addRect(e.filterEffect.filterArea),t.applyMatrix(e.container.worldTransform)):e.container.getFastGlobalBounds(!0,t),e.container){const r=(e.container.renderGroup||e.container.parentRenderGroup)?.cacheToLocalTransform;r&&t.applyMatrix(r)}}_warnUnsupportedFilter(e){const t=e?.constructor?.name||"Filter";this._warnedFilterTypes.has(t)||(this._warnedFilterTypes.add(t),console.warn(`CanvasRenderer: filter "${t}" is not supported in Canvas2D and will be skipped.`))}get alphaMultiplier(){return this._alphaMultiplier}_pushFilterFrame(){let e=this._filterStack[this._filterStackIndex];return e||(e=this._filterStack[this._filterStackIndex]=new hy),this._filterStackIndex++,e}_popFilterFrame(){return this._filterStackIndex<=0?this._filterStack[0]:(this._filterStackIndex--,this._filterStack[this._filterStackIndex])}destroy(){this._filterStack=null,this._savedStates=null,this._warnedFilterTypes=null,this._alphaMultiplier=1}}Yf.extension={type:[S.CanvasSystem],name:"filter"};var Kf=`in vec2 aPosition;
|
|
253
|
+
`}},dc={};function Ma(i){let e=dc[i];if(e)return e;const t=new Int32Array(i);for(let s=0;s<i;s++)t[s]=s;return e=dc[i]=new Qe({uTextures:{value:t,type:"i32",size:i}},{isStatic:!0}),e}class yo extends _t{constructor(e){const t=Ir({name:"batch",bits:[wa,Sa(e),Dr]}),s=Br({name:"batch",bits:[va,Ta(e),Gr]});super({glProgram:t,gpuProgram:s,resources:{batchSamplers:Ma(e)}}),this.maxTextures=e}}let Ks=null;const _f=class yf extends sf{constructor(e){super(e),this.geometry=new nf,this.name=yf.extension.name,this.vertexSize=6,Ks??(Ks=new yo(e.maxTextures)),this.shader=Ks}packAttributes(e,t,s,r,n){const o=n<<16|e.roundPixels&65535,a=e.transform,l=a.a,h=a.b,c=a.c,u=a.d,d=a.tx,f=a.ty,{positions:p,uvs:m}=e,g=e.color,_=e.attributeOffset,y=_+e.attributeSize;for(let x=_;x<y;x++){const b=x*2,v=p[b],w=p[b+1];t[r++]=l*v+c*w+d,t[r++]=u*w+h*v+f,t[r++]=m[b],t[r++]=m[b+1],s[r++]=g,s[r++]=o}}packQuadAttributes(e,t,s,r,n){const o=e.texture,a=e.transform,l=a.a,h=a.b,c=a.c,u=a.d,d=a.tx,f=a.ty,p=e.bounds,m=p.maxX,g=p.minX,_=p.maxY,y=p.minY,x=o.uvs,b=e.color,v=n<<16|e.roundPixels&65535;t[r+0]=l*g+c*y+d,t[r+1]=u*y+h*g+f,t[r+2]=x.x0,t[r+3]=x.y0,s[r+4]=b,s[r+5]=v,t[r+6]=l*m+c*y+d,t[r+7]=u*y+h*m+f,t[r+8]=x.x1,t[r+9]=x.y1,s[r+10]=b,s[r+11]=v,t[r+12]=l*m+c*_+d,t[r+13]=u*_+h*m+f,t[r+14]=x.x2,t[r+15]=x.y2,s[r+16]=b,s[r+17]=v,t[r+18]=l*g+c*_+d,t[r+19]=u*_+h*g+f,t[r+20]=x.x3,t[r+21]=x.y3,s[r+22]=b,s[r+23]=v}_updateMaxTextures(e){this.shader.maxTextures!==e&&(Ks=new yo(e),this.shader=Ks)}destroy(){this.shader=null,super.destroy()}};_f.extension={type:[S.Batcher],name:"default"};let Fr=_f;class lt{constructor(e){this.items=Object.create(null);const{renderer:t,type:s,onUnload:r,priority:n,name:o}=e;this._renderer=t,t.gc.addResourceHash(this,"items",s,n??0),this._onUnload=r,this.name=o}add(e){return this.items[e.uid]?!1:(this.items[e.uid]=e,e.once("unload",this.remove,this),e._gcLastUsed=this._renderer.gc.now,!0)}remove(e,...t){if(!this.items[e.uid])return;const s=e._gpuData[this._renderer.uid];s&&(this._onUnload?.(e,...t),e.off("unload",this.remove,this),s.destroy(),e._gpuData[this._renderer.uid]=null,this.items[e.uid]=null)}removeAll(...e){Object.values(this.items).forEach(t=>t&&this.remove(t,...e))}destroy(...e){this.removeAll(...e),this.items=Object.create(null),this._renderer=null,this._onUnload=null}}function xf(i,e,t,s,r,n,o,a=null){let l=0;t*=e,r*=n;const h=a.a,c=a.b,u=a.c,d=a.d,f=a.tx,p=a.ty;for(;l<o;){const m=i[t],g=i[t+1];s[r]=h*m+u*g+f,s[r+1]=c*m+d*g+p,r+=n,t+=e,l++}}function bf(i,e,t,s){let r=0;for(e*=t;r<s;)i[e]=0,i[e+1]=0,e+=t,r++}function Ca(i,e,t,s,r){const n=e.a,o=e.b,a=e.c,l=e.d,h=e.tx,c=e.ty;t||(t=0),s||(s=2),r||(r=i.length/s-t);let u=t*s;for(let d=0;d<r;d++){const f=i[u],p=i[u+1];i[u]=n*f+a*p+h,i[u+1]=o*f+l*p+c,u+=s}}const k0=new L;class Or{constructor(){this.packAsQuad=!1,this.batcherName="default",this.topology="triangle-list",this.applyTransform=!0,this.roundPixels=0,this._batcher=null,this._batch=null}get uvs(){return this.geometryData.uvs}get positions(){return this.geometryData.vertices}get indices(){return this.geometryData.indices}get blendMode(){return this.renderable&&this.applyTransform?this.renderable.groupBlendMode:"normal"}get color(){const e=this.baseColor,t=e>>16|e&65280|(e&255)<<16,s=this.renderable;return s?ts(t,s.groupColor)+(this.alpha*s.groupAlpha*255<<24):t+(this.alpha*255<<24)}get transform(){return this.renderable?.groupTransform||k0}copyTo(e){e.indexOffset=this.indexOffset,e.indexSize=this.indexSize,e.attributeOffset=this.attributeOffset,e.attributeSize=this.attributeSize,e.baseColor=this.baseColor,e.alpha=this.alpha,e.texture=this.texture,e.geometryData=this.geometryData,e.topology=this.topology}reset(){this.applyTransform=!0,this.renderable=null,this.topology="triangle-list"}destroy(){this.renderable=null,this.texture=null,this.geometryData=null,this._batcher=null,this._batch=null}}const Is={extension:{type:S.ShapeBuilder,name:"circle"},build(i,e){let t,s,r,n,o,a;if(i.type==="circle"){const b=i;if(o=a=b.radius,o<=0)return!1;t=b.x,s=b.y,r=n=0}else if(i.type==="ellipse"){const b=i;if(o=b.halfWidth,a=b.halfHeight,o<=0||a<=0)return!1;t=b.x,s=b.y,r=n=0}else{const b=i,v=b.width/2,w=b.height/2;t=b.x+v,s=b.y+w,o=a=Math.max(0,Math.min(b.radius,Math.min(v,w))),r=v-o,n=w-a}if(r<0||n<0)return!1;const l=Math.ceil(2.3*Math.sqrt(o+a)),h=l*8+(r?4:0)+(n?4:0);if(h===0)return!1;if(l===0)return e[0]=e[6]=t+r,e[1]=e[3]=s+n,e[2]=e[4]=t-r,e[5]=e[7]=s-n,!0;let c=0,u=l*4+(r?2:0)+2,d=u,f=h,p=r+o,m=n,g=t+p,_=t-p,y=s+m;if(e[c++]=g,e[c++]=y,e[--u]=y,e[--u]=_,n){const b=s-m;e[d++]=_,e[d++]=b,e[--f]=b,e[--f]=g}for(let b=1;b<l;b++){const v=Math.PI/2*(b/l),w=r+Math.cos(v)*o,T=n+Math.sin(v)*a,E=t+w,P=t-w,A=s+T,k=s-T;e[c++]=E,e[c++]=A,e[--u]=A,e[--u]=P,e[d++]=P,e[d++]=k,e[--f]=k,e[--f]=E}p=r,m=n+a,g=t+p,_=t-p,y=s+m;const x=s-m;return e[c++]=g,e[c++]=y,e[--f]=x,e[--f]=g,r&&(e[c++]=_,e[c++]=y,e[--f]=x,e[--f]=_),!0},triangulate(i,e,t,s,r,n){if(i.length===0)return;let o=0,a=0;for(let c=0;c<i.length;c+=2)o+=i[c],a+=i[c+1];o/=i.length/2,a/=i.length/2;let l=s;e[l*t]=o,e[l*t+1]=a;const h=l++;for(let c=0;c<i.length;c+=2)e[l*t]=i[c],e[l*t+1]=i[c+1],c>0&&(r[n++]=l,r[n++]=h,r[n++]=l-1),l++;r[n++]=h+1,r[n++]=h,r[n++]=l-1}},vf={...Is,extension:{...Is.extension,name:"ellipse"}},wf={...Is,extension:{...Is.extension,name:"roundedRectangle"}},ka=1e-4,xo=1e-4;function fc(i,e,t,s,r,n,o,a){const l=i-t*r,h=e-s*r,c=i+t*n,u=e+s*n;let d,f;o?(d=s,f=-t):(d=-s,f=t);const p=l+d,m=h+f,g=c+d,_=u+f;return a.push(p,m),a.push(g,_),2}function Ht(i,e,t,s,r,n,o,a){const l=t-i,h=s-e;let c=Math.atan2(l,h),u=Math.atan2(r-i,n-e);a&&c<u?c+=Math.PI*2:!a&&c>u&&(u+=Math.PI*2);let d=c;const f=u-c,p=Math.abs(f),m=Math.sqrt(l*l+h*h),g=(15*p*Math.sqrt(m)/Math.PI>>0)+1,_=f/g;if(d+=_,a){o.push(i,e),o.push(t,s);for(let y=1,x=d;y<g;y++,x+=_)o.push(i,e),o.push(i+Math.sin(x)*m,e+Math.cos(x)*m);o.push(i,e),o.push(r,n)}else{o.push(t,s),o.push(i,e);for(let y=1,x=d;y<g;y++,x+=_)o.push(i+Math.sin(x)*m,e+Math.cos(x)*m),o.push(i,e);o.push(r,n),o.push(i,e)}return g*2}function Lr(i,e,t,s,r,n){const o=ka;if(i.length===0)return;const a=e;let l=a.alignment;if(e.alignment!==.5){let R=ya(i);l=(l-.5)*R+.5}const h=new ce(i[0],i[1]),c=new ce(i[i.length-2],i[i.length-1]),u=s,d=Math.abs(h.x-c.x)<o&&Math.abs(h.y-c.y)<o;if(u){i=i.slice(),d&&(i.pop(),i.pop(),c.set(i[i.length-2],i[i.length-1]));const R=(h.x+c.x)*.5,O=(c.y+h.y)*.5;i.unshift(R,O),i.push(R,O)}const f=r,p=i.length/2;let m=i.length;const g=f.length/2,_=a.width/2,y=_*_,x=a.miterLimit*a.miterLimit;let b=i[0],v=i[1],w=i[2],T=i[3],E=0,P=0,A=-(v-T),k=b-w,I=0,G=0,F=Math.sqrt(A*A+k*k);A/=F,k/=F,A*=_,k*=_;const X=l,M=(1-X)*2,C=X*2;u||(a.cap==="round"?m+=Ht(b-A*(M-C)*.5,v-k*(M-C)*.5,b-A*M,v-k*M,b+A*C,v+k*C,f,!0)+2:a.cap==="square"&&(m+=fc(b,v,A,k,M,C,!0,f))),f.push(b-A*M,v-k*M),f.push(b+A*C,v+k*C);for(let R=1;R<p-1;++R){b=i[(R-1)*2],v=i[(R-1)*2+1],w=i[R*2],T=i[R*2+1],E=i[(R+1)*2],P=i[(R+1)*2+1],A=-(v-T),k=b-w,F=Math.sqrt(A*A+k*k),A/=F,k/=F,A*=_,k*=_,I=-(T-P),G=w-E,F=Math.sqrt(I*I+G*G),I/=F,G/=F,I*=_,G*=_;const O=w-b,U=v-T,q=w-E,J=P-T,ie=O*q+U*J,V=U*q-J*O,Je=V<0;if(Math.abs(V)<.001*Math.abs(ie)){f.push(w-A*M,T-k*M),f.push(w+A*C,T+k*C),ie>=0&&(a.join==="round"?m+=Ht(w,T,w-A*M,T-k*M,w-I*M,T-G*M,f,!1)+4:m+=2,f.push(w-I*C,T-G*C),f.push(w+I*M,T+G*M));continue}const Ei=(-A+b)*(-k+T)-(-A+w)*(-k+v),Ns=(-I+E)*(-G+T)-(-I+w)*(-G+P),zs=(O*Ns-q*Ei)/V,xt=(J*Ei-U*Ns)/V,Nt=(zs-w)*(zs-w)+(xt-T)*(xt-T),et=w+(zs-w)*M,Oe=T+(xt-T)*M,Le=w-(zs-w)*C,tt=T-(xt-T)*C,Gt=Math.min(O*O+U*U,q*q+J*J),bt=Je?M:C,Hs=Gt+bt*bt*y;Nt<=Hs?a.join==="bevel"||Nt/y>x?(Je?(f.push(et,Oe),f.push(w+A*C,T+k*C),f.push(et,Oe),f.push(w+I*C,T+G*C)):(f.push(w-A*M,T-k*M),f.push(Le,tt),f.push(w-I*M,T-G*M),f.push(Le,tt)),m+=2):a.join==="round"?Je?(f.push(et,Oe),f.push(w+A*C,T+k*C),m+=Ht(w,T,w+A*C,T+k*C,w+I*C,T+G*C,f,!0)+4,f.push(et,Oe),f.push(w+I*C,T+G*C)):(f.push(w-A*M,T-k*M),f.push(Le,tt),m+=Ht(w,T,w-A*M,T-k*M,w-I*M,T-G*M,f,!1)+4,f.push(w-I*M,T-G*M),f.push(Le,tt)):(f.push(et,Oe),f.push(Le,tt)):(f.push(w-A*M,T-k*M),f.push(w+A*C,T+k*C),a.join==="round"?Je?m+=Ht(w,T,w+A*C,T+k*C,w+I*C,T+G*C,f,!0)+2:m+=Ht(w,T,w-A*M,T-k*M,w-I*M,T-G*M,f,!1)+2:a.join==="miter"&&Nt/y<=x&&(Je?(f.push(Le,tt),f.push(Le,tt)):(f.push(et,Oe),f.push(et,Oe)),m+=2),f.push(w-I*M,T-G*M),f.push(w+I*C,T+G*C),m+=2)}b=i[(p-2)*2],v=i[(p-2)*2+1],w=i[(p-1)*2],T=i[(p-1)*2+1],A=-(v-T),k=b-w,F=Math.sqrt(A*A+k*k),A/=F,k/=F,A*=_,k*=_,f.push(w-A*M,T-k*M),f.push(w+A*C,T+k*C),u||(a.cap==="round"?m+=Ht(w-A*(M-C)*.5,T-k*(M-C)*.5,w-A*M,T-k*M,w+A*C,T+k*C,f,!1)+2:a.cap==="square"&&(m+=fc(w,T,A,k,M,C,!1,f)));const B=xo*xo;for(let R=g;R<m+g-2;++R)b=f[R*2],v=f[R*2+1],w=f[(R+1)*2],T=f[(R+1)*2+1],E=f[(R+2)*2],P=f[(R+2)*2+1],!(Math.abs(b*(T-P)+w*(P-v)+E*(v-T))<B)&&n.push(R,R+1,R+2)}function Tf(i,e,t,s){const r=ka;if(i.length===0)return;const n=i[0],o=i[1],a=i[i.length-2],l=i[i.length-1],h=e||Math.abs(n-a)<r&&Math.abs(o-l)<r,c=t,u=i.length/2,d=c.length/2;for(let f=0;f<u;f++)c.push(i[f*2]),c.push(i[f*2+1]);for(let f=0;f<u-1;f++)s.push(d+f,d+f+1);h&&s.push(d+u-1,d)}function Ea(i,e,t,s,r,n,o){const a=Nd(i,e,2);if(!a)return;for(let h=0;h<a.length;h+=3)n[o++]=a[h]+r,n[o++]=a[h+1]+r,n[o++]=a[h+2]+r;let l=r*s;for(let h=0;h<i.length;h+=2)t[l]=i[h],t[l+1]=i[h+1],l+=s}const E0=[],Sf={extension:{type:S.ShapeBuilder,name:"polygon"},build(i,e){for(let t=0;t<i.points.length;t++)e[t]=i.points[t];return!0},triangulate(i,e,t,s,r,n){Ea(i,E0,e,t,s,r,n)}},Mf={extension:{type:S.ShapeBuilder,name:"rectangle"},build(i,e){const t=i,s=t.x,r=t.y,n=t.width,o=t.height;return n>0&&o>0?(e[0]=s,e[1]=r,e[2]=s+n,e[3]=r,e[4]=s+n,e[5]=r+o,e[6]=s,e[7]=r+o,!0):!1},triangulate(i,e,t,s,r,n){let o=0;s*=t,e[s+o]=i[0],e[s+o+1]=i[1],o+=t,e[s+o]=i[2],e[s+o+1]=i[3],o+=t,e[s+o]=i[6],e[s+o+1]=i[7],o+=t,e[s+o]=i[4],e[s+o+1]=i[5],o+=t;const a=s/t;r[n++]=a,r[n++]=a+1,r[n++]=a+2,r[n++]=a+1,r[n++]=a+3,r[n++]=a+2}},Cf={extension:{type:S.ShapeBuilder,name:"triangle"},build(i,e){return e[0]=i.x,e[1]=i.y,e[2]=i.x2,e[3]=i.y2,e[4]=i.x3,e[5]=i.y3,!0},triangulate(i,e,t,s,r,n){let o=0;s*=t,e[s+o]=i[0],e[s+o+1]=i[1],o+=t,e[s+o]=i[2],e[s+o+1]=i[3],o+=t,e[s+o]=i[4],e[s+o+1]=i[5];const a=s/t;r[n++]=a,r[n++]=a+1,r[n++]=a+2}},pc=[{offset:0,color:"white"},{offset:1,color:"black"}],Pa=class bo{constructor(...e){this.uid=oe("fillGradient"),this._tick=0,this.type="linear",this.colorStops=[];let t=P0(e);t={...t.type==="radial"?bo.defaultRadialOptions:bo.defaultLinearOptions,...jo(t)},this._textureSize=t.textureSize,this._wrapMode=t.wrapMode,t.type==="radial"?(this.center=t.center,this.outerCenter=t.outerCenter??this.center,this.innerRadius=t.innerRadius,this.outerRadius=t.outerRadius,this.scale=t.scale,this.rotation=t.rotation):(this.start=t.start,this.end=t.end),this.textureSpace=t.textureSpace,this.type=t.type,t.colorStops.forEach(r=>{this.addColorStop(r.offset,r.color)})}addColorStop(e,t){return this.colorStops.push({offset:e,color:le.shared.setValue(t).toHexa()}),this}buildLinearGradient(){if(this.texture)return;let{x:e,y:t}=this.start,{x:s,y:r}=this.end,n=s-e,o=r-t;const a=n<0||o<0;if(this._wrapMode==="clamp-to-edge"){if(n<0){const g=e;e=s,s=g,n*=-1}if(o<0){const g=t;t=r,r=g,o*=-1}}const l=this.colorStops.length?this.colorStops:pc,h=this._textureSize,{canvas:c,context:u}=gc(h,1),d=a?u.createLinearGradient(this._textureSize,0,0,0):u.createLinearGradient(0,0,this._textureSize,0);mc(d,l),u.fillStyle=d,u.fillRect(0,0,h,1),this.texture=new H({source:new pi({resource:c,addressMode:this._wrapMode})});const f=Math.sqrt(n*n+o*o),p=Math.atan2(o,n),m=new L;m.scale(f/h,1),m.rotate(p),m.translate(e,t),this.textureSpace==="local"&&m.scale(h,h),this.transform=m}buildGradient(){this.texture||this._tick++,this.type==="linear"?this.buildLinearGradient():this.buildRadialGradient()}buildRadialGradient(){if(this.texture)return;const e=this.colorStops.length?this.colorStops:pc,t=this._textureSize,{canvas:s,context:r}=gc(t,t),{x:n,y:o}=this.center,{x:a,y:l}=this.outerCenter,h=this.innerRadius,c=this.outerRadius,u=a-c,d=l-c,f=t/(c*2),p=(n-u)*f,m=(o-d)*f,g=r.createRadialGradient(p,m,h*f,(a-u)*f,(l-d)*f,c*f);mc(g,e),r.fillStyle=e[e.length-1].color,r.fillRect(0,0,t,t),r.fillStyle=g,r.translate(p,m),r.rotate(this.rotation),r.scale(1,this.scale),r.translate(-p,-m),r.fillRect(0,0,t,t),this.texture=new H({source:new pi({resource:s,addressMode:this._wrapMode})});const _=new L;this.textureSpace==="local"?_.scale(2*c,2*c):_.scale(1/f,1/f),_.translate(u,d),this.transform=_}destroy(){this.texture?.destroy(!0),this.texture=null,this.transform=null,this.colorStops=[],this.start=null,this.end=null,this.center=null,this.outerCenter=null}get styleKey(){return`fill-gradient-${this.uid}-${this._tick}`}};Pa.defaultLinearOptions={start:{x:0,y:0},end:{x:0,y:1},colorStops:[],textureSpace:"local",type:"linear",textureSize:256,wrapMode:"clamp-to-edge"};Pa.defaultRadialOptions={center:{x:.5,y:.5},innerRadius:0,outerRadius:.5,colorStops:[],scale:1,rotation:0,textureSpace:"local",type:"radial",textureSize:256,wrapMode:"clamp-to-edge"};let Xe=Pa;function mc(i,e){for(let t=0;t<e.length;t++){const s=e[t];i.addColorStop(s.offset,s.color)}}function gc(i,e){const t=te.get().createCanvas(i,e),s=t.getContext("2d");return{canvas:t,context:s}}function P0(i){let e=i[0]??{};return(typeof e=="number"||i[1])&&(N("8.5.2","use options object instead"),e={type:"linear",start:{x:i[0],y:i[1]},end:{x:i[2],y:i[3]},textureSpace:i[4],textureSize:i[5]??Xe.defaultLinearOptions.textureSize}),e}const A0=new L,R0=new se,B0=new L;function Aa(i,e,t,s){const r=e.matrix?i.copyFrom(e.matrix).invert():i.identity();if(e.textureSpace==="local"){const o=t.getBounds(R0);e.width&&o.pad(e.width);const{x:a,y:l}=o,h=1/o.width,c=1/o.height,u=-a*h,d=-l*c,f=r.a,p=r.b,m=r.c,g=r.d;r.a*=h,r.b*=h,r.c*=c,r.d*=c,r.tx=u*f+d*m+r.tx,r.ty=u*p+d*g+r.ty}else if(e.texture.rotate){const{uvs:o,orig:a}=e.texture;r.scale(1/a.width,1/a.height),r.prepend(B0.set(o.x1-o.x0,o.y1-o.y0,o.x3-o.x0,o.y3-o.y0,o.x0,o.y0))}else r.translate(e.texture.frame.x,e.texture.frame.y),r.scale(1/e.texture.source.width,1/e.texture.source.height);const n=e.texture.source.style;return!(e.fill instanceof Xe)&&n.addressMode==="clamp-to-edge"&&(n.addressMode="repeat",n.update()),s&&r.append(A0.copyFrom(s).invert()),r}const ps={};Y.handleByMap(S.ShapeBuilder,ps);Y.add(Mf,Sf,Cf,Is,vf,wf);const I0=new se,G0=new L;function kf(i,e){const{geometryData:t,batches:s}=e;s.length=0,t.indices.length=0,t.vertices.length=0,t.uvs.length=0;for(let r=0;r<i.instructions.length;r++){const n=i.instructions[r];if(n.action==="texture")D0(n.data,s,t);else if(n.action==="fill"||n.action==="stroke"){const o=n.action==="stroke",a=n.data.path.shapePath,l=n.data.style,h=n.data.hole;o&&h&&_c(h.shapePath,l,!0,s,t),h&&(a.shapePrimitives[a.shapePrimitives.length-1].holes=h.shapePath.shapePrimitives),_c(a,l,o,s,t)}}}function D0(i,e,t){const s=[],r=ps.rectangle,n=I0;n.x=i.dx,n.y=i.dy,n.width=i.dw,n.height=i.dh;const o=i.transform;if(!r.build(n,s))return;const{vertices:a,uvs:l,indices:h}=t,c=h.length,u=a.length/2;o&&Ca(s,o),r.triangulate(s,a,2,u,h,c);const d=i.image,f=d.uvs;l.push(f.x0,f.y0,f.x1,f.y1,f.x3,f.y3,f.x2,f.y2);const p=Se.get(Or);p.indexOffset=c,p.indexSize=h.length-c,p.attributeOffset=u,p.attributeSize=a.length/2-u,p.baseColor=i.style,p.alpha=i.alpha,p.texture=d,p.geometryData=t,e.push(p)}function _c(i,e,t,s,r){const{vertices:n,uvs:o,indices:a}=r;i.shapePrimitives.forEach(({shape:l,transform:h,holes:c})=>{const u=[],d=ps[l.type];if(!d.build(l,u))return;const f=a.length,p=n.length/2;let m="triangle-list";if(h&&Ca(u,h),t){const x=l.closePath??!0,b=e;b.pixelLine?(Tf(u,x,n,a),m="line-list"):Lr(u,b,!1,x,n,a)}else if(c){const x=[],b=u.slice();F0(c).forEach(w=>{x.push(b.length/2),b.push(...w)}),Ea(b,x,n,2,p,a,f)}else d.triangulate(u,n,2,p,a,f);const g=o.length/2,_=e.texture;if(_!==H.WHITE){const x=Aa(G0,e,l,h);xf(n,2,p,o,g,2,n.length/2-p,x)}else bf(o,g,2,n.length/2-p);const y=Se.get(Or);y.indexOffset=f,y.indexSize=a.length-f,y.attributeOffset=p,y.attributeSize=n.length/2-p,y.baseColor=e.color,y.alpha=e.alpha,y.texture=_,y.geometryData=r,y.topology=m,s.push(y)})}function F0(i){const e=[];for(let t=0;t<i.length;t++){const s=i[t].shape,r=[];ps[s.type].build(s,r)&&e.push(r)}return e}class Ef{constructor(){this.batches=[],this.geometryData={vertices:[],uvs:[],indices:[]}}reset(){this.batches&&this.batches.forEach(e=>{Se.return(e)}),this.graphicsData&&Se.return(this.graphicsData),this.isBatchable=!1,this.context=null,this.batches.length=0,this.geometryData.indices.length=0,this.geometryData.vertices.length=0,this.geometryData.uvs.length=0,this.graphicsData=null}destroy(){this.reset(),this.batches=null,this.geometryData=null}}class Pf{constructor(){this.instructions=new Sr}init(e){const t=e.maxTextures;this.batcher?this.batcher._updateMaxTextures(t):this.batcher=new Fr({maxTextures:t}),this.instructions.reset()}get geometry(){return N(Cu,"GraphicsContextRenderData#geometry is deprecated, please use batcher.geometry instead."),this.batcher.geometry}destroy(){this.batcher.destroy(),this.instructions.destroy(),this.batcher=null,this.instructions=null}}const Ra=class vo{constructor(e){this._renderer=e,this._managedContexts=new lt({renderer:e,type:"resource",name:"graphicsContext"})}init(e){vo.defaultOptions.bezierSmoothness=e?.bezierSmoothness??vo.defaultOptions.bezierSmoothness}getContextRenderData(e){return e._gpuData[this._renderer.uid].graphicsData||this._initContextRenderData(e)}updateGpuContext(e){const t=!!e._gpuData[this._renderer.uid],s=e._gpuData[this._renderer.uid]||this._initContext(e);if(e.dirty||!t){t&&s.reset(),kf(e,s);const r=e.batchMode;e.customShader||r==="no-batch"?s.isBatchable=!1:r==="auto"?s.isBatchable=s.geometryData.vertices.length<400:s.isBatchable=!0,e.dirty=!1}return s}getGpuContext(e){return e._gpuData[this._renderer.uid]||this._initContext(e)}_initContextRenderData(e){const t=Se.get(Pf,{maxTextures:this._renderer.limits.maxBatchableTextures}),s=e._gpuData[this._renderer.uid],{batches:r,geometryData:n}=s;s.graphicsData=t;const o=n.vertices.length,a=n.indices.length;for(let u=0;u<r.length;u++)r[u].applyTransform=!1;const l=t.batcher;l.ensureAttributeBuffer(o),l.ensureIndexBuffer(a),l.begin();for(let u=0;u<r.length;u++){const d=r[u];l.add(d)}l.finish(t.instructions);const h=l.geometry;h.indexBuffer.setDataWithSize(l.indexBuffer,l.indexSize,!0),h.buffers[0].setDataWithSize(l.attributeBuffer.float32View,l.attributeSize,!0);const c=l.batches;for(let u=0;u<l.batchIndex;u++){const d=c[u];d.bindGroup=Rr(d.textures.textures,d.textures.count,this._renderer.limits.maxBatchableTextures)}return t}_initContext(e){const t=new Ef;return t.context=e,e._gpuData[this._renderer.uid]=t,this._managedContexts.add(e),t}destroy(){this._managedContexts.destroy(),this._renderer=null}};Ra.extension={type:[S.WebGLSystem,S.WebGPUSystem],name:"graphicsContext"};Ra.defaultOptions={bezierSmoothness:.5};let Ur=Ra;const O0=8,Wi=11920929e-14,L0=1;function Ba(i,e,t,s,r,n,o,a,l,h){const u=Math.min(.99,Math.max(0,h??Ur.defaultOptions.bezierSmoothness));let d=(L0-u)/1;return d*=d,U0(e,t,s,r,n,o,a,l,i,d),i}function U0(i,e,t,s,r,n,o,a,l,h){wo(i,e,t,s,r,n,o,a,l,h,0),l.push(o,a)}function wo(i,e,t,s,r,n,o,a,l,h,c){if(c>O0)return;const u=(i+t)/2,d=(e+s)/2,f=(t+r)/2,p=(s+n)/2,m=(r+o)/2,g=(n+a)/2,_=(u+f)/2,y=(d+p)/2,x=(f+m)/2,b=(p+g)/2,v=(_+x)/2,w=(y+b)/2;if(c>0){let T=o-i,E=a-e;const P=Math.abs((t-o)*E-(s-a)*T),A=Math.abs((r-o)*E-(n-a)*T);if(P>Wi&&A>Wi){if((P+A)*(P+A)<=h*(T*T+E*E)){l.push(v,w);return}}else if(P>Wi){if(P*P<=h*(T*T+E*E)){l.push(v,w);return}}else if(A>Wi){if(A*A<=h*(T*T+E*E)){l.push(v,w);return}}else if(T=v-(i+o)/2,E=w-(e+a)/2,T*T+E*E<=h){l.push(v,w);return}}wo(i,e,u,d,_,y,v,w,l,h,c+1),wo(v,w,x,b,m,g,o,a,l,h,c+1)}const N0=8,z0=11920929e-14,H0=1;function Af(i,e,t,s,r,n,o,a){const h=Math.min(.99,Math.max(0,a??Ur.defaultOptions.bezierSmoothness));let c=(H0-h)/1;return c*=c,W0(e,t,s,r,n,o,i,c),i}function W0(i,e,t,s,r,n,o,a){To(o,i,e,t,s,r,n,a,0),o.push(r,n)}function To(i,e,t,s,r,n,o,a,l){if(l>N0)return;const h=(e+s)/2,c=(t+r)/2,u=(s+n)/2,d=(r+o)/2,f=(h+u)/2,p=(c+d)/2;let m=n-e,g=o-t;const _=Math.abs((s-n)*g-(r-o)*m);if(_>z0){if(_*_<=a*(m*m+g*g)){i.push(f,p);return}}else if(m=f-(e+n)/2,g=p-(t+o)/2,m*m+g*g<=a){i.push(f,p);return}To(i,e,t,h,c,f,p,a,l+1),To(i,f,p,u,d,n,o,a,l+1)}function Ia(i,e,t,s,r,n,o,a){let l=Math.abs(r-n);(!o&&r>n||o&&n>r)&&(l=2*Math.PI-l),a||(a=Math.max(6,Math.floor(6*Math.pow(s,1/3)*(l/Math.PI)))),a=Math.max(a,3);let h=l/a,c=r;h*=o?-1:1;for(let u=0;u<a+1;u++){const d=Math.cos(c),f=Math.sin(c),p=e+d*s,m=t+f*s;i.push(p,m),c+=h}}function Rf(i,e,t,s,r,n){const o=i[i.length-2],l=i[i.length-1]-t,h=o-e,c=r-t,u=s-e,d=Math.abs(l*u-h*c);if(d<1e-8||n===0){(i[i.length-2]!==e||i[i.length-1]!==t)&&i.push(e,t);return}const f=l*l+h*h,p=c*c+u*u,m=l*c+h*u,g=n*Math.sqrt(f)/d,_=n*Math.sqrt(p)/d,y=g*m/f,x=_*m/p,b=g*u+_*h,v=g*c+_*l,w=h*(_+y),T=l*(_+y),E=u*(g+x),P=c*(g+x),A=Math.atan2(T-v,w-b),k=Math.atan2(P-v,E-b);Ia(i,b+e,v+t,n,A,k,h*c>u*l)}const ni=Math.PI*2,Bn={centerX:0,centerY:0,ang1:0,ang2:0},In=({x:i,y:e},t,s,r,n,o,a,l)=>{i*=t,e*=s;const h=r*i-n*e,c=n*i+r*e;return l.x=h+o,l.y=c+a,l};function $0(i,e){const t=e===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(e/4),s=e===1.5707963267948966?.551915024494:t,r=Math.cos(i),n=Math.sin(i),o=Math.cos(i+e),a=Math.sin(i+e);return[{x:r-n*s,y:n+r*s},{x:o+a*s,y:a-o*s},{x:o,y:a}]}const yc=(i,e,t,s)=>{const r=i*s-e*t<0?-1:1;let n=i*t+e*s;return n>1&&(n=1),n<-1&&(n=-1),r*Math.acos(n)},V0=(i,e,t,s,r,n,o,a,l,h,c,u,d)=>{const f=Math.pow(r,2),p=Math.pow(n,2),m=Math.pow(c,2),g=Math.pow(u,2);let _=f*p-f*g-p*m;_<0&&(_=0),_/=f*g+p*m,_=Math.sqrt(_)*(o===a?-1:1);const y=_*r/n*u,x=_*-n/r*c,b=h*y-l*x+(i+t)/2,v=l*y+h*x+(e+s)/2,w=(c-y)/r,T=(u-x)/n,E=(-c-y)/r,P=(-u-x)/n,A=yc(1,0,w,T);let k=yc(w,T,E,P);a===0&&k>0&&(k-=ni),a===1&&k<0&&(k+=ni),d.centerX=b,d.centerY=v,d.ang1=A,d.ang2=k};function Bf(i,e,t,s,r,n,o,a=0,l=0,h=0){if(n===0||o===0)return;const c=Math.sin(a*ni/360),u=Math.cos(a*ni/360),d=u*(e-s)/2+c*(t-r)/2,f=-c*(e-s)/2+u*(t-r)/2;if(d===0&&f===0)return;n=Math.abs(n),o=Math.abs(o);const p=Math.pow(d,2)/Math.pow(n,2)+Math.pow(f,2)/Math.pow(o,2);p>1&&(n*=Math.sqrt(p),o*=Math.sqrt(p)),V0(e,t,s,r,n,o,l,h,c,u,d,f,Bn);let{ang1:m,ang2:g}=Bn;const{centerX:_,centerY:y}=Bn;let x=Math.abs(g)/(ni/4);Math.abs(1-x)<1e-7&&(x=1);const b=Math.max(Math.ceil(x),1);g/=b;let v=i[i.length-2],w=i[i.length-1];const T={x:0,y:0};for(let E=0;E<b;E++){const P=$0(m,g),{x:A,y:k}=In(P[0],n,o,u,c,_,y,T),{x:I,y:G}=In(P[1],n,o,u,c,_,y,T),{x:F,y:X}=In(P[2],n,o,u,c,_,y,T);Ba(i,v,w,A,k,I,G,F,X),v=F,w=X,m+=g}}function If(i,e,t){const s=(o,a)=>{const l=a.x-o.x,h=a.y-o.y,c=Math.sqrt(l*l+h*h),u=l/c,d=h/c;return{len:c,nx:u,ny:d}},r=(o,a)=>{o===0?i.moveTo(a.x,a.y):i.lineTo(a.x,a.y)};let n=e[e.length-1];for(let o=0;o<e.length;o++){const a=e[o%e.length],l=a.radius??t;if(l<=0){r(o,a),n=a;continue}const h=e[(o+1)%e.length],c=s(a,n),u=s(a,h);if(c.len<1e-4||u.len<1e-4){r(o,a),n=a;continue}let d=Math.asin(c.nx*u.ny-c.ny*u.nx),f=1,p=!1;c.nx*u.nx-c.ny*-u.ny<0?d<0?d=Math.PI+d:(d=Math.PI-d,f=-1,p=!0):d>0&&(f=-1,p=!0);const m=d/2;let g,_=Math.abs(Math.cos(m)*l/Math.sin(m));_>Math.min(c.len/2,u.len/2)?(_=Math.min(c.len/2,u.len/2),g=Math.abs(_*Math.sin(m)/Math.cos(m))):g=l;const y=a.x+u.nx*_+-u.ny*g*f,x=a.y+u.ny*_+u.nx*g*f,b=Math.atan2(c.ny,c.nx)+Math.PI/2*f,v=Math.atan2(u.ny,u.nx)-Math.PI/2*f;o===0&&i.moveTo(y+Math.cos(b)*g,x+Math.sin(b)*g),i.arc(y,x,g,b,v,p),n=a}}function Gf(i,e,t,s){const r=(a,l)=>Math.sqrt((a.x-l.x)**2+(a.y-l.y)**2),n=(a,l,h)=>({x:a.x+(l.x-a.x)*h,y:a.y+(l.y-a.y)*h}),o=e.length;for(let a=0;a<o;a++){const l=e[(a+1)%o],h=l.radius??t;if(h<=0){a===0?i.moveTo(l.x,l.y):i.lineTo(l.x,l.y);continue}const c=e[a],u=e[(a+2)%o],d=r(c,l);let f;if(d<1e-4)f=l;else{const g=Math.min(d/2,h);f=n(l,c,g/d)}const p=r(u,l);let m;if(p<1e-4)m=l;else{const g=Math.min(p/2,h);m=n(l,u,g/p)}a===0?i.moveTo(f.x,f.y):i.lineTo(f.x,f.y),i.quadraticCurveTo(l.x,l.y,m.x,m.y,s)}}const j0=new se;class Df{constructor(e){this.shapePrimitives=[],this._currentPoly=null,this._bounds=new Ee,this._graphicsPath2D=e,this.signed=e.checkForHoles}moveTo(e,t){return this.startPoly(e,t),this}lineTo(e,t){this._ensurePoly();const s=this._currentPoly.points,r=s[s.length-2],n=s[s.length-1];return(r!==e||n!==t)&&s.push(e,t),this}arc(e,t,s,r,n,o){this._ensurePoly(!1);const a=this._currentPoly.points;return Ia(a,e,t,s,r,n,o),this}arcTo(e,t,s,r,n){this._ensurePoly();const o=this._currentPoly.points;return Rf(o,e,t,s,r,n),this}arcToSvg(e,t,s,r,n,o,a){const l=this._currentPoly.points;return Bf(l,this._currentPoly.lastX,this._currentPoly.lastY,o,a,e,t,s,r,n),this}bezierCurveTo(e,t,s,r,n,o,a){this._ensurePoly();const l=this._currentPoly;return Ba(this._currentPoly.points,l.lastX,l.lastY,e,t,s,r,n,o,a),this}quadraticCurveTo(e,t,s,r,n){this._ensurePoly();const o=this._currentPoly;return Af(this._currentPoly.points,o.lastX,o.lastY,e,t,s,r,n),this}closePath(){return this.endPoly(!0),this}addPath(e,t){this.endPoly(),t&&!t.isIdentity()&&(e=e.clone(!0),e.transform(t));const s=this.shapePrimitives,r=s.length;for(let n=0;n<e.instructions.length;n++){const o=e.instructions[n];this[o.action](...o.data)}if(e.checkForHoles&&s.length-r>1){let n=null;for(let o=r;o<s.length;o++){const a=s[o];if(a.shape.type==="polygon"){const l=a.shape,h=n?.shape;h&&h.containsPolygon(l)?(n.holes||(n.holes=[]),n.holes.push(a),s.copyWithin(o,o+1),s.length--,o--):n=a}}}return this}finish(e=!1){this.endPoly(e)}rect(e,t,s,r,n){return this.drawShape(new se(e,t,s,r),n),this}circle(e,t,s,r){return this.drawShape(new Er(e,t,s),r),this}poly(e,t,s){const r=new Es(e);return r.closePath=t,this.drawShape(r,s),this}regularPoly(e,t,s,r,n=0,o){r=Math.max(r|0,3);const a=-1*Math.PI/2+n,l=Math.PI*2/r,h=[];for(let c=0;c<r;c++){const u=a-c*l;h.push(e+s*Math.cos(u),t+s*Math.sin(u))}return this.poly(h,!0,o),this}roundPoly(e,t,s,r,n,o=0,a){if(r=Math.max(r|0,3),n<=0)return this.regularPoly(e,t,s,r,o);const l=s*Math.sin(Math.PI/r)-.001;n=Math.min(n,l);const h=-1*Math.PI/2+o,c=Math.PI*2/r,u=(r-2)*Math.PI/r/2;for(let d=0;d<r;d++){const f=d*c+h,p=e+s*Math.cos(f),m=t+s*Math.sin(f),g=f+Math.PI+u,_=f-Math.PI-u,y=p+n*Math.cos(g),x=m+n*Math.sin(g),b=p+n*Math.cos(_),v=m+n*Math.sin(_);d===0?this.moveTo(y,x):this.lineTo(y,x),this.quadraticCurveTo(p,m,b,v,a)}return this.closePath()}roundShape(e,t,s=!1,r){return e.length<3?this:(s?Gf(this,e,t,r):If(this,e,t),this.closePath())}filletRect(e,t,s,r,n){if(n===0)return this.rect(e,t,s,r);const o=Math.min(s,r)/2,a=Math.min(o,Math.max(-o,n)),l=e+s,h=t+r,c=a<0?-a:0,u=Math.abs(a);return this.moveTo(e,t+u).arcTo(e+c,t+c,e+u,t,u).lineTo(l-u,t).arcTo(l-c,t+c,l,t+u,u).lineTo(l,h-u).arcTo(l-c,h-c,e+s-u,h,u).lineTo(e+u,h).arcTo(e+c,h-c,e,h-u,u).closePath()}chamferRect(e,t,s,r,n,o){if(n<=0)return this.rect(e,t,s,r);const a=Math.min(n,Math.min(s,r)/2),l=e+s,h=t+r,c=[e+a,t,l-a,t,l,t+a,l,h-a,l-a,h,e+a,h,e,h-a,e,t+a];for(let u=c.length-1;u>=2;u-=2)c[u]===c[u-2]&&c[u-1]===c[u-3]&&c.splice(u-1,2);return this.poly(c,!0,o)}ellipse(e,t,s,r,n){return this.drawShape(new Pr(e,t,s,r),n),this}roundRect(e,t,s,r,n,o){return this.drawShape(new Ar(e,t,s,r,n),o),this}drawShape(e,t){return this.endPoly(),this.shapePrimitives.push({shape:e,transform:t}),this}startPoly(e,t){let s=this._currentPoly;return s&&this.endPoly(),s=new Es,s.points.push(e,t),this._currentPoly=s,this}endPoly(e=!1){const t=this._currentPoly;return t&&t.points.length>2&&(t.closePath=e,this.shapePrimitives.push({shape:t})),this._currentPoly=null,this}_ensurePoly(e=!0){if(!this._currentPoly&&(this._currentPoly=new Es,e)){const t=this.shapePrimitives[this.shapePrimitives.length-1];if(t){let s=t.shape.x,r=t.shape.y;if(t.transform&&!t.transform.isIdentity()){const n=t.transform,o=s;s=n.a*s+n.c*r+n.tx,r=n.b*o+n.d*r+n.ty}this._currentPoly.points.push(s,r)}else this._currentPoly.points.push(0,0)}}buildPath(){const e=this._graphicsPath2D;this.shapePrimitives.length=0,this._currentPoly=null;for(let t=0;t<e.instructions.length;t++){const s=e.instructions[t];this[s.action](...s.data)}this.finish()}get bounds(){const e=this._bounds;e.clear();const t=this.shapePrimitives;for(let s=0;s<t.length;s++){const r=t[s],n=r.shape.getBounds(j0);r.transform?e.addRect(n,r.transform):e.addRect(n)}return e}}class mt{constructor(e,t=!1){this.instructions=[],this.uid=oe("graphicsPath"),this._dirty=!0,this.checkForHoles=t,typeof e=="string"?Xd(e,this):this.instructions=e?.slice()??[]}get shapePath(){return this._shapePath||(this._shapePath=new Df(this)),this._dirty&&(this._dirty=!1,this._shapePath.buildPath()),this._shapePath}addPath(e,t){return e=e.clone(),this.instructions.push({action:"addPath",data:[e,t]}),this._dirty=!0,this}arc(...e){return this.instructions.push({action:"arc",data:e}),this._dirty=!0,this}arcTo(...e){return this.instructions.push({action:"arcTo",data:e}),this._dirty=!0,this}arcToSvg(...e){return this.instructions.push({action:"arcToSvg",data:e}),this._dirty=!0,this}bezierCurveTo(...e){return this.instructions.push({action:"bezierCurveTo",data:e}),this._dirty=!0,this}bezierCurveToShort(e,t,s,r,n){const o=this.instructions[this.instructions.length-1],a=this.getLastPoint(ce.shared);let l=0,h=0;if(!o||o.action!=="bezierCurveTo")l=a.x,h=a.y;else{l=o.data[2],h=o.data[3];const c=a.x,u=a.y;l=c+(c-l),h=u+(u-h)}return this.instructions.push({action:"bezierCurveTo",data:[l,h,e,t,s,r,n]}),this._dirty=!0,this}closePath(){return this.instructions.push({action:"closePath",data:[]}),this._dirty=!0,this}ellipse(...e){return this.instructions.push({action:"ellipse",data:e}),this._dirty=!0,this}lineTo(...e){return this.instructions.push({action:"lineTo",data:e}),this._dirty=!0,this}moveTo(...e){return this.instructions.push({action:"moveTo",data:e}),this}quadraticCurveTo(...e){return this.instructions.push({action:"quadraticCurveTo",data:e}),this._dirty=!0,this}quadraticCurveToShort(e,t,s){const r=this.instructions[this.instructions.length-1],n=this.getLastPoint(ce.shared);let o=0,a=0;if(!r||r.action!=="quadraticCurveTo")o=n.x,a=n.y;else{o=r.data[0],a=r.data[1];const l=n.x,h=n.y;o=l+(l-o),a=h+(h-a)}return this.instructions.push({action:"quadraticCurveTo",data:[o,a,e,t,s]}),this._dirty=!0,this}rect(e,t,s,r,n){return this.instructions.push({action:"rect",data:[e,t,s,r,n]}),this._dirty=!0,this}circle(e,t,s,r){return this.instructions.push({action:"circle",data:[e,t,s,r]}),this._dirty=!0,this}roundRect(...e){return this.instructions.push({action:"roundRect",data:e}),this._dirty=!0,this}poly(...e){return this.instructions.push({action:"poly",data:e}),this._dirty=!0,this}regularPoly(...e){return this.instructions.push({action:"regularPoly",data:e}),this._dirty=!0,this}roundPoly(...e){return this.instructions.push({action:"roundPoly",data:e}),this._dirty=!0,this}roundShape(...e){return this.instructions.push({action:"roundShape",data:e}),this._dirty=!0,this}filletRect(...e){return this.instructions.push({action:"filletRect",data:e}),this._dirty=!0,this}chamferRect(...e){return this.instructions.push({action:"chamferRect",data:e}),this._dirty=!0,this}star(e,t,s,r,n,o,a){n||(n=r/2);const l=-1*Math.PI/2+o,h=s*2,c=Math.PI*2/h,u=[];for(let d=0;d<h;d++){const f=d%2?n:r,p=d*c+l;u.push(e+f*Math.cos(p),t+f*Math.sin(p))}return this.poly(u,!0,a),this}clone(e=!1){const t=new mt;if(t.checkForHoles=this.checkForHoles,!e)t.instructions=this.instructions.slice();else for(let s=0;s<this.instructions.length;s++){const r=this.instructions[s];t.instructions.push({action:r.action,data:r.data.slice()})}return t}clear(){return this.instructions.length=0,this._dirty=!0,this}transform(e){if(e.isIdentity())return this;const t=e.a,s=e.b,r=e.c,n=e.d,o=e.tx,a=e.ty;let l=0,h=0,c=0,u=0,d=0,f=0,p=0,m=0;for(let g=0;g<this.instructions.length;g++){const _=this.instructions[g],y=_.data;switch(_.action){case"moveTo":case"lineTo":l=y[0],h=y[1],y[0]=t*l+r*h+o,y[1]=s*l+n*h+a;break;case"bezierCurveTo":c=y[0],u=y[1],d=y[2],f=y[3],l=y[4],h=y[5],y[0]=t*c+r*u+o,y[1]=s*c+n*u+a,y[2]=t*d+r*f+o,y[3]=s*d+n*f+a,y[4]=t*l+r*h+o,y[5]=s*l+n*h+a;break;case"quadraticCurveTo":c=y[0],u=y[1],l=y[2],h=y[3],y[0]=t*c+r*u+o,y[1]=s*c+n*u+a,y[2]=t*l+r*h+o,y[3]=s*l+n*h+a;break;case"arcToSvg":l=y[5],h=y[6],p=y[0],m=y[1],y[0]=t*p+r*m,y[1]=s*p+n*m,y[5]=t*l+r*h+o,y[6]=s*l+n*h+a;break;case"circle":y[4]=_s(y[3],e);break;case"rect":y[4]=_s(y[4],e);break;case"ellipse":y[8]=_s(y[8],e);break;case"roundRect":y[5]=_s(y[5],e);break;case"addPath":y[0].transform(e);break;case"poly":y[2]=_s(y[2],e);break;case"regularPoly":case"chamferRect":y[5]=_s(y[5],e);break;case"closePath":break;default:z("unknown transform action",_.action);break}}return this._dirty=!0,this}get bounds(){return this.shapePath.bounds}getLastPoint(e){let t=this.instructions.length-1,s=this.instructions[t];if(!s)return e.x=0,e.y=0,e;for(;s.action==="closePath";){if(t--,t<0)return e.x=0,e.y=0,e;s=this.instructions[t]}switch(s.action){case"moveTo":case"lineTo":e.x=s.data[0],e.y=s.data[1];break;case"quadraticCurveTo":e.x=s.data[2],e.y=s.data[3];break;case"bezierCurveTo":e.x=s.data[4],e.y=s.data[5];break;case"arc":case"arcToSvg":e.x=s.data[5],e.y=s.data[6];break;case"addPath":s.data[0].getLastPoint(e);break}return e}}function _s(i,e){return i?i.prepend(e):e.clone()}function ve(i,e,t){const s=i.getAttribute(e);return s?Number(s):t}function Ff(i,e){const t=i.querySelectorAll("defs");for(let s=0;s<t.length;s++){const r=t[s];for(let n=0;n<r.children.length;n++){const o=r.children[n];switch(o.nodeName.toLowerCase()){case"lineargradient":e.defs[o.id]=X0(o);break;case"radialgradient":e.defs[o.id]=q0(o);break}}}}function nt(i,e,t){const s=i.getAttribute(e);if(s?.trim().endsWith("%")){const r=Number(s.trim().slice(0,-1));return Number.isNaN(r)?t:r/100}return ve(i,e,t)}function Of(i){return(i.getAttribute("gradientUnits")||"objectBoundingBox")==="objectBoundingBox"?"local":"global"}function Lf(i){const e=[];for(let t=0;t<i.children.length;t++){const s=i.children[t],r=nt(s,"offset",0),n=le.shared.setValue(s.getAttribute("stop-color")).toNumber();e.push({offset:r,color:n})}return e}function X0(i){const e=nt(i,"x1",0),t=nt(i,"y1",0),s=nt(i,"x2",1),r=nt(i,"y2",0);return new Xe({type:"linear",start:{x:e,y:t},end:{x:s,y:r},textureSpace:Of(i),colorStops:Lf(i)})}function q0(i){const e=nt(i,"cx",.5),t=nt(i,"cy",.5),s=nt(i,"r",.5),r=nt(i,"fx",e),n=nt(i,"fy",t),o=nt(i,"fr",0);return new Xe({type:"radial",center:{x:r,y:n},innerRadius:o,outerCenter:{x:e,y:t},outerRadius:s,textureSpace:Of(i),colorStops:Lf(i)})}function So(i){const e=i.match(/url\s*\(\s*['"]?\s*#([^'"\s)]+)\s*['"]?\s*\)/i);return e?e[1]:""}const Mo={fill:{type:"paint",default:0},"fill-opacity":{type:"number",default:1},stroke:{type:"paint",default:0},"stroke-width":{type:"number",default:1},"stroke-opacity":{type:"number",default:1},"stroke-linecap":{type:"string",default:"butt"},"stroke-linejoin":{type:"string",default:"miter"},"stroke-miterlimit":{type:"number",default:10},"stroke-dasharray":{type:"string",default:"none"},"stroke-dashoffset":{type:"number",default:0},opacity:{type:"number",default:1}};function Ga(i,e){const t=i.getAttribute("style"),s={},r={},n={strokeStyle:s,fillStyle:r,useFill:!1,useStroke:!1};for(const o in Mo){const a=i.getAttribute(o);a&&xc(e,n,o,a.trim())}if(t){const o=t.split(";");for(let a=0;a<o.length;a++){const l=o[a].trim(),[h,c]=l.split(":");Mo[h]&&xc(e,n,h,c.trim())}}return{strokeStyle:n.useStroke?s:null,fillStyle:n.useFill?r:null,useFill:n.useFill,useStroke:n.useStroke}}function xc(i,e,t,s){switch(t){case"stroke":if(s!=="none"){if(s.startsWith("url(")){const r=So(s);e.strokeStyle.fill=i.defs[r]}else e.strokeStyle.color=le.shared.setValue(s).toNumber();e.useStroke=!0}break;case"stroke-width":e.strokeStyle.width=Number(s);break;case"fill":if(s!=="none"){if(s.startsWith("url(")){const r=So(s);e.fillStyle.fill=i.defs[r]}else e.fillStyle.color=le.shared.setValue(s).toNumber();e.useFill=!0}break;case"fill-opacity":e.fillStyle.alpha=Number(s);break;case"stroke-opacity":e.strokeStyle.alpha=Number(s);break;case"opacity":e.fillStyle.alpha=Number(s),e.strokeStyle.alpha=Number(s);break}}function Uf(i){if(i.length<=2)return!0;const e=i.map(a=>a.area).sort((a,l)=>l-a),[t,s]=e,r=e[e.length-1],n=t/s,o=s/r;return!(n>3&&o<2)}function Nf(i){return i.split(/(?=[Mm])/).filter(s=>s.trim().length>0)}function zf(i){const e=i.match(/[-+]?[0-9]*\.?[0-9]+/g);if(!e||e.length<4)return 0;const t=e.map(Number),s=[],r=[];for(let c=0;c<t.length;c+=2)c+1<t.length&&(s.push(t[c]),r.push(t[c+1]));if(s.length===0||r.length===0)return 0;const n=Math.min(...s),o=Math.max(...s),a=Math.min(...r),l=Math.max(...r);return(o-n)*(l-a)}function Co(i,e){const t=new mt(i,!1);for(const s of t.instructions)e.instructions.push(s)}function Hf(i,e){if(typeof i=="string"){const o=document.createElement("div");o.innerHTML=i.trim(),i=o.querySelector("svg")}const t={context:e,defs:{},path:new mt};Ff(i,t);const s=i.children,{fillStyle:r,strokeStyle:n}=Ga(i,t);for(let o=0;o<s.length;o++){const a=s[o];a.nodeName.toLowerCase()!=="defs"&&Wf(a,t,r,n)}return e}function Wf(i,e,t,s){const r=i.children,{fillStyle:n,strokeStyle:o}=Ga(i,e);n&&t?t={...t,...n}:n&&(t=n),o&&s?s={...s,...o}:o&&(s=o);const a=!t&&!s;a&&(t={color:0});let l,h,c,u,d,f,p,m,g,_,y,x,b,v,w,T,E;switch(i.nodeName.toLowerCase()){case"path":{v=i.getAttribute("d");const P=i.getAttribute("fill-rule"),A=Nf(v),k=P==="evenodd",I=A.length>1;if(k&&I){const F=A.map(M=>({path:M,area:zf(M)}));if(F.sort((M,C)=>C.area-M.area),A.length>3||!Uf(F))for(let M=0;M<F.length;M++){const C=F[M],B=M===0;e.context.beginPath();const R=new mt(void 0,!0);Co(C.path,R),e.context.path(R),B?(t&&e.context.fill(t),s&&e.context.stroke(s)):e.context.cut()}else for(let M=0;M<F.length;M++){const C=F[M],B=M%2===1;e.context.beginPath();const R=new mt(void 0,!0);Co(C.path,R),e.context.path(R),B?e.context.cut():(t&&e.context.fill(t),s&&e.context.stroke(s))}}else{const F=P?P==="evenodd":!0;w=new mt(v,F),e.context.path(w),t&&e.context.fill(t),s&&e.context.stroke(s)}break}case"circle":p=ve(i,"cx",0),m=ve(i,"cy",0),g=ve(i,"r",0),e.context.ellipse(p,m,g,g),t&&e.context.fill(t),s&&e.context.stroke(s);break;case"rect":l=ve(i,"x",0),h=ve(i,"y",0),T=ve(i,"width",0),E=ve(i,"height",0),_=ve(i,"rx",0),y=ve(i,"ry",0),_||y?e.context.roundRect(l,h,T,E,_||y):e.context.rect(l,h,T,E),t&&e.context.fill(t),s&&e.context.stroke(s);break;case"ellipse":p=ve(i,"cx",0),m=ve(i,"cy",0),_=ve(i,"rx",0),y=ve(i,"ry",0),e.context.beginPath(),e.context.ellipse(p,m,_,y),t&&e.context.fill(t),s&&e.context.stroke(s);break;case"line":c=ve(i,"x1",0),u=ve(i,"y1",0),d=ve(i,"x2",0),f=ve(i,"y2",0),e.context.beginPath(),e.context.moveTo(c,u),e.context.lineTo(d,f),s&&e.context.stroke(s);break;case"polygon":b=i.getAttribute("points"),x=b.match(/-?\d+/g).map(P=>parseInt(P,10)),e.context.poly(x,!0),t&&e.context.fill(t),s&&e.context.stroke(s);break;case"polyline":b=i.getAttribute("points"),x=b.match(/-?\d+/g).map(P=>parseInt(P,10)),e.context.poly(x,!1),s&&e.context.stroke(s);break;case"g":case"svg":break;default:{z(`[SVG parser] <${i.nodeName}> elements unsupported`);break}}a&&(t=null);for(let P=0;P<r.length;P++)Wf(r[P],e,t,s)}function Y0(i){return i.texture!==void 0}const bc={repeat:{addressModeU:"repeat",addressModeV:"repeat"},"repeat-x":{addressModeU:"repeat",addressModeV:"clamp-to-edge"},"repeat-y":{addressModeU:"clamp-to-edge",addressModeV:"repeat"},"no-repeat":{addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}};class Us{constructor(e,t){this.uid=oe("fillPattern"),this._tick=0,this.transform=new L;const s=Y0(e)?e:{texture:e,repetition:t};this.texture=s.texture,this.textureSpace=s.textureSpace??"global";const r=s.repetition;r&&(this.texture.source.style.addressModeU=bc[r].addressModeU,this.texture.source.style.addressModeV=bc[r].addressModeV)}setTransform(e){if(e){if(this.transform.equals(e))return;this.transform.copyFrom(e)}else{if(this.transform.isIdentity())return;this.transform.identity()}this._tick++}get texture(){return this._texture}set texture(e){this._texture!==e&&(this._texture=e,this._tick++)}get styleKey(){return`fill-pattern-${this.uid}-${this._tick}`}destroy(){this.texture.destroy(!0),this.texture=null}}function K0(i){return le.isColorLike(i)}function vc(i){return i instanceof Us}function wc(i){return i instanceof Xe}function Z0(i){return i instanceof H}function Q0(i,e,t){const s=le.shared.setValue(e??0);return i.color=s.toNumber(),i.alpha=s.alpha===1?t.alpha:s.alpha,i.texture=H.WHITE,{...t,...i}}function J0(i,e,t){return i.texture=e,{...t,...i}}function Tc(i,e,t){return i.fill=e,i.color=16777215,i.texture=e.texture,i.matrix=e.transform,i.textureSpace=e.textureSpace,{...t,...i}}function Sc(i,e,t){return e.buildGradient(),i.fill=e,i.color=16777215,i.texture=e.texture,i.matrix=e.transform,i.textureSpace=e.textureSpace,{...t,...i}}function ey(i,e){const t={...e,...i},s=le.shared.setValue(t.color);return t.alpha*=s.alpha,t.color=s.toNumber(),t}function Ot(i,e){if(i==null)return null;const t={},s=i;return K0(i)?Q0(t,i,e):Z0(i)?J0(t,i,e):vc(i)?Tc(t,i,e):wc(i)?Sc(t,i,e):s.fill&&vc(s.fill)?Tc(s,s.fill,e):s.fill&&wc(s.fill)?Sc(s,s.fill,e):ey(s,e)}function bi(i,e){const{width:t,alignment:s,miterLimit:r,cap:n,join:o,pixelLine:a,...l}=e,h=Ot(i,l);return h?{width:t,alignment:s,miterLimit:r,cap:n,join:o,pixelLine:a,...h}:null}function $f(i,e){let t=1;const s=i.shapePath.shapePrimitives;for(let r=0;r<s.length;r++){const n=s[r].shape;if(n.type!=="polygon")continue;const o=n.points,a=o.length;if(a<6)continue;const l=n.closePath;for(let h=0;h<a;h+=2){if(!l&&(h===0||h===a-2))continue;const c=(h-2+a)%a,u=(h+2)%a,d=o[c],f=o[c+1],p=o[h],m=o[h+1],g=o[u],_=o[u+1],y=d-p,x=f-m,b=g-p,v=_-m,w=y*y+x*x,T=b*b+v*v;if(w<1e-12||T<1e-12)continue;let A=(y*b+x*v)/Math.sqrt(w*T);A<-1?A=-1:A>1&&(A=1);const k=Math.sqrt((1-A)*.5);if(k<1e-6)continue;const I=Math.min(1/k,e);I>t&&(t=I)}}return t}const ty=new ce,Mc=new L,Da=class ct extends Re{constructor(){super(...arguments),this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this.uid=oe("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this.destroyed=!1,this._activePath=new mt,this._transform=new L,this._fillStyle={...ct.defaultFillStyle},this._strokeStyle={...ct.defaultStrokeStyle},this._stateStack=[],this._tick=0,this._bounds=new Ee,this._boundsDirty=!0}clone(){const e=new ct;return e.batchMode=this.batchMode,e.instructions=this.instructions.slice(),e._activePath=this._activePath.clone(),e._transform=this._transform.clone(),e._fillStyle={...this._fillStyle},e._strokeStyle={...this._strokeStyle},e._stateStack=this._stateStack.slice(),e._bounds=this._bounds.clone(),e._boundsDirty=!0,e}get fillStyle(){return this._fillStyle}set fillStyle(e){this._fillStyle=Ot(e,ct.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(e){this._strokeStyle=bi(e,ct.defaultStrokeStyle)}setFillStyle(e){return this._fillStyle=Ot(e,ct.defaultFillStyle),this}setStrokeStyle(e){return this._strokeStyle=Ot(e,ct.defaultStrokeStyle),this}texture(e,t,s,r,n,o){return this.instructions.push({action:"texture",data:{image:e,dx:s||0,dy:r||0,dw:n||e.frame.width,dh:o||e.frame.height,transform:this._transform.clone(),alpha:this._fillStyle.alpha,style:t||t===0?le.shared.setValue(t).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new mt,this}fill(e,t){let s;const r=this.instructions[this.instructions.length-1];return this._tick===0&&r?.action==="stroke"?s=r.data.path:s=this._activePath.clone(),s?(e!=null&&(t!==void 0&&typeof e=="number"&&(N(de,"GraphicsContext.fill(color, alpha) is deprecated, use GraphicsContext.fill({ color, alpha }) instead"),e={color:e,alpha:t}),this._fillStyle=Ot(e,ct.defaultFillStyle)),this.instructions.push({action:"fill",data:{style:this.fillStyle,path:s}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}_initNextPathLocation(){const{x:e,y:t}=this._activePath.getLastPoint(ce.shared);this._activePath.clear(),this._activePath.moveTo(e,t)}stroke(e){let t;const s=this.instructions[this.instructions.length-1];return this._tick===0&&s?.action==="fill"?t=s.data.path:t=this._activePath.clone(),t?(e!=null&&(this._strokeStyle=bi(e,ct.defaultStrokeStyle)),this.instructions.push({action:"stroke",data:{style:this.strokeStyle,path:t}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}cut(){for(let e=0;e<2;e++){const t=this.instructions[this.instructions.length-1-e],s=this._activePath.clone();if(t&&(t.action==="stroke"||t.action==="fill"))if(t.data.hole)t.data.hole.addPath(s);else{t.data.hole=s;break}}return this._initNextPathLocation(),this}arc(e,t,s,r,n,o){this._tick++;const a=this._transform;return this._activePath.arc(a.a*e+a.c*t+a.tx,a.b*e+a.d*t+a.ty,s,r,n,o),this}arcTo(e,t,s,r,n){this._tick++;const o=this._transform;return this._activePath.arcTo(o.a*e+o.c*t+o.tx,o.b*e+o.d*t+o.ty,o.a*s+o.c*r+o.tx,o.b*s+o.d*r+o.ty,n),this}arcToSvg(e,t,s,r,n,o,a){this._tick++;const l=this._transform;return this._activePath.arcToSvg(e,t,s,r,n,l.a*o+l.c*a+l.tx,l.b*o+l.d*a+l.ty),this}bezierCurveTo(e,t,s,r,n,o,a){this._tick++;const l=this._transform;return this._activePath.bezierCurveTo(l.a*e+l.c*t+l.tx,l.b*e+l.d*t+l.ty,l.a*s+l.c*r+l.tx,l.b*s+l.d*r+l.ty,l.a*n+l.c*o+l.tx,l.b*n+l.d*o+l.ty,a),this}closePath(){return this._tick++,this._activePath?.closePath(),this}ellipse(e,t,s,r){return this._tick++,this._activePath.ellipse(e,t,s,r,this._transform.clone()),this}circle(e,t,s){return this._tick++,this._activePath.circle(e,t,s,this._transform.clone()),this}path(e){return this._tick++,this._activePath.addPath(e,this._transform.clone()),this}lineTo(e,t){this._tick++;const s=this._transform;return this._activePath.lineTo(s.a*e+s.c*t+s.tx,s.b*e+s.d*t+s.ty),this}moveTo(e,t){this._tick++;const s=this._transform,r=this._activePath.instructions,n=s.a*e+s.c*t+s.tx,o=s.b*e+s.d*t+s.ty;return r.length===1&&r[0].action==="moveTo"?(r[0].data[0]=n,r[0].data[1]=o,this):(this._activePath.moveTo(n,o),this)}quadraticCurveTo(e,t,s,r,n){this._tick++;const o=this._transform;return this._activePath.quadraticCurveTo(o.a*e+o.c*t+o.tx,o.b*e+o.d*t+o.ty,o.a*s+o.c*r+o.tx,o.b*s+o.d*r+o.ty,n),this}rect(e,t,s,r){return this._tick++,this._activePath.rect(e,t,s,r,this._transform.clone()),this}roundRect(e,t,s,r,n){return this._tick++,this._activePath.roundRect(e,t,s,r,n,this._transform.clone()),this}poly(e,t){return this._tick++,this._activePath.poly(e,t,this._transform.clone()),this}regularPoly(e,t,s,r,n=0,o){return this._tick++,this._activePath.regularPoly(e,t,s,r,n,o),this}roundPoly(e,t,s,r,n,o){return this._tick++,this._activePath.roundPoly(e,t,s,r,n,o),this}roundShape(e,t,s,r){return this._tick++,this._activePath.roundShape(e,t,s,r),this}filletRect(e,t,s,r,n){return this._tick++,this._activePath.filletRect(e,t,s,r,n),this}chamferRect(e,t,s,r,n,o){return this._tick++,this._activePath.chamferRect(e,t,s,r,n,o),this}star(e,t,s,r,n=0,o=0){return this._tick++,this._activePath.star(e,t,s,r,n,o,this._transform.clone()),this}svg(e){return this._tick++,Hf(e,this),this}restore(){const e=this._stateStack.pop();return e&&(this._transform=e.transform,this._fillStyle=e.fillStyle,this._strokeStyle=e.strokeStyle),this}save(){return this._stateStack.push({transform:this._transform.clone(),fillStyle:{...this._fillStyle},strokeStyle:{...this._strokeStyle}}),this}getTransform(){return this._transform}resetTransform(){return this._transform.identity(),this}rotate(e){return this._transform.rotate(e),this}scale(e,t=e){return this._transform.scale(e,t),this}setTransform(e,t,s,r,n,o){return e instanceof L?(this._transform.set(e.a,e.b,e.c,e.d,e.tx,e.ty),this):(this._transform.set(e,t,s,r,n,o),this)}transform(e,t,s,r,n,o){return e instanceof L?(this._transform.append(e),this):(Mc.set(e,t,s,r,n,o),this._transform.append(Mc),this)}translate(e,t=e){return this._transform.translate(e,t),this}clear(){return this._activePath.clear(),this.instructions.length=0,this.resetTransform(),this.onUpdate(),this}onUpdate(){this._boundsDirty=!0,this.dirty=!0,this.emit("update",this,16)}get bounds(){if(!this._boundsDirty)return this._bounds;this._boundsDirty=!1;const e=this._bounds;e.clear();for(let t=0;t<this.instructions.length;t++){const s=this.instructions[t],r=s.action;if(r==="fill"){const n=s.data;e.addBounds(n.path.bounds)}else if(r==="texture"){const n=s.data;e.addFrame(n.dx,n.dy,n.dx+n.dw,n.dy+n.dh,n.transform)}if(r==="stroke"){const n=s.data,o=n.style.alignment;let a=n.style.width*(1-o);n.style.join==="miter"&&(a*=$f(n.path,n.style.miterLimit));const l=n.path.bounds;e.addFrame(l.minX-a,l.minY-a,l.maxX+a,l.maxY+a)}}return e.isValid||e.set(0,0,0,0),e}containsPoint(e){if(!this.bounds.containsPoint(e.x,e.y))return!1;const t=this.instructions;let s=!1;for(let r=0;r<t.length;r++){const n=t[r],o=n.data,a=o.path;if(!n.action||!a)continue;const l=o.style,h=a.shapePath.shapePrimitives;for(let c=0;c<h.length;c++){const u=h[c].shape;if(!l||!u)continue;const d=h[c].transform,f=d?d.applyInverse(e,ty):e;if(n.action==="fill")s=u.contains(f.x,f.y);else{const m=l;s=u.strokeContains(f.x,f.y,m.width,m.alignment)}const p=o.hole;if(p){const m=p.shapePath?.shapePrimitives;if(m)for(let g=0;g<m.length;g++)m[g].shape.contains(f.x,f.y)&&(s=!1)}if(s)return!0}}return s}unload(){this.emit("unload",this);for(const e in this._gpuData)this._gpuData[e]?.destroy();this._gpuData=Object.create(null)}destroy(e=!1){if(this.destroyed)return;if(this.destroyed=!0,this._stateStack.length=0,this._transform=null,this.unload(),this.emit("destroy",this),this.removeAllListeners(),typeof e=="boolean"?e:e?.texture){const s=typeof e=="boolean"?e:e?.textureSource;this._fillStyle.texture&&(this._fillStyle.fill&&"uid"in this._fillStyle.fill?this._fillStyle.fill.destroy():this._fillStyle.texture.destroy(s)),this._strokeStyle.texture&&(this._strokeStyle.fill&&"uid"in this._strokeStyle.fill?this._strokeStyle.fill.destroy():this._strokeStyle.texture.destroy(s))}this._fillStyle=null,this._strokeStyle=null,this.instructions=null,this._activePath=null,this._bounds=null,this._stateStack=null,this.customShader=null,this._transform=null}};Da.defaultFillStyle={color:16777215,alpha:1,texture:H.WHITE,matrix:null,fill:null,textureSpace:"local"};Da.defaultStrokeStyle={width:1,color:16777215,alpha:1,alignment:.5,miterLimit:10,cap:"butt",join:"miter",texture:H.WHITE,matrix:null,fill:null,textureSpace:"local",pixelLine:!1};let Ye=Da;class Vf{constructor(e){this._attachedDomElements=[],this._renderer=e,this._renderer.runners.postrender.add(this),this._renderer.runners.init.add(this),this._domElement=document.createElement("div"),this._domElement.style.position="absolute",this._domElement.style.top="0",this._domElement.style.left="0",this._domElement.style.pointerEvents="none",this._domElement.style.zIndex="1000"}init(){this._canvasObserver=new na({domElement:this._domElement,renderer:this._renderer})}addRenderable(e,t){this._attachedDomElements.includes(e)||this._attachedDomElements.push(e)}updateRenderable(e){}validateRenderable(e){return!0}postrender(){const e=this._attachedDomElements;if(e.length===0){this._domElement.remove();return}this._canvasObserver.ensureAttached();for(let t=0;t<e.length;t++){const s=e[t],r=s.element;if(!s.parent||s.globalDisplayStatus<7)r?.remove(),e.splice(t,1),t--;else{this._domElement.contains(r)||(r.style.position="absolute",r.style.pointerEvents="auto",this._domElement.appendChild(r));const n=s.worldTransform,o=s._anchor,a=s.width*o.x,l=s.height*o.y;r.style.transformOrigin=`${a}px ${l}px`,r.style.transform=`matrix(${n.a}, ${n.b}, ${n.c}, ${n.d}, ${n.tx-a}, ${n.ty-l})`,r.style.opacity=s.groupAlpha.toString()}}}destroy(){this._renderer.runners.postrender.remove(this);for(let e=0;e<this._attachedDomElements.length;e++)this._attachedDomElements[e].element?.remove();this._attachedDomElements.length=0,this._domElement.remove(),this._canvasObserver.destroy(),this._renderer=null}}Vf.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"dom"};class sy{constructor(){this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}init(e){this.removeTickerListener(),this.events=e,this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}get pauseUpdate(){return this._pauseUpdate}set pauseUpdate(e){this._pauseUpdate=e}addTickerListener(){this._tickerAdded||!this.domElement||($e.system.add(this._tickerUpdate,this,as.INTERACTION),this._tickerAdded=!0)}removeTickerListener(){this._tickerAdded&&($e.system.remove(this._tickerUpdate,this),this._tickerAdded=!1)}pointerMoved(){this._didMove=!0}_update(){if(!this.domElement||this._pauseUpdate)return;if(this._didMove){this._didMove=!1;return}const e=this.events._rootPointerEvent;this.events.supportsTouchEvents&&e.pointerType==="touch"||globalThis.document.dispatchEvent(this.events.supportsPointerEvents?new PointerEvent("pointermove",{clientX:e.clientX,clientY:e.clientY,pointerType:e.pointerType,pointerId:e.pointerId}):new MouseEvent("mousemove",{clientX:e.clientX,clientY:e.clientY}))}_tickerUpdate(e){this._deltaTime+=e.deltaTime,!(this._deltaTime<this.interactionFrequency)&&(this._deltaTime=0,this._update())}destroy(){this.removeTickerListener(),this.events=null,this.domElement=null,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}}const ft=new sy;class vi extends Ls{constructor(){super(...arguments),this.client=new ce,this.movement=new ce,this.offset=new ce,this.global=new ce,this.screen=new ce}get clientX(){return this.client.x}get clientY(){return this.client.y}get x(){return this.clientX}get y(){return this.clientY}get movementX(){return this.movement.x}get movementY(){return this.movement.y}get offsetX(){return this.offset.x}get offsetY(){return this.offset.y}get globalX(){return this.global.x}get globalY(){return this.global.y}get screenX(){return this.screen.x}get screenY(){return this.screen.y}getLocalPosition(e,t,s){return e.worldTransform.applyInverse(s||this.global,t)}getModifierState(e){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(e)}initMouseEvent(e,t,s,r,n,o,a,l,h,c,u,d,f,p,m){throw new Error("Method not implemented.")}}class Fe extends vi{constructor(){super(...arguments),this.width=0,this.height=0,this.isPrimary=!1,this.persistentDeviceId=0}getCoalescedEvents(){return this.type==="pointermove"||this.type==="mousemove"||this.type==="touchmove"?[this]:[]}getPredictedEvents(){throw new Error("getPredictedEvents is not supported!")}}class cs extends vi{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}cs.DOM_DELTA_PIXEL=0;cs.DOM_DELTA_LINE=1;cs.DOM_DELTA_PAGE=2;const iy=2048,ry=new ce,Zs=new ce;class jf{constructor(e){this.dispatch=new Re,this.moveOnAll=!1,this.enableGlobalMoveEvents=!0,this.mappingState={trackingData:{}},this.eventPool=new Map,this._allInteractiveElements=[],this._hitElements=[],this._isPointerMoveEvent=!1,this.rootTarget=e,this.hitPruneFn=this.hitPruneFn.bind(this),this.hitTestFn=this.hitTestFn.bind(this),this.mapPointerDown=this.mapPointerDown.bind(this),this.mapPointerMove=this.mapPointerMove.bind(this),this.mapPointerOut=this.mapPointerOut.bind(this),this.mapPointerOver=this.mapPointerOver.bind(this),this.mapPointerUp=this.mapPointerUp.bind(this),this.mapPointerUpOutside=this.mapPointerUpOutside.bind(this),this.mapWheel=this.mapWheel.bind(this),this.mapContextMenu=this.mapContextMenu.bind(this),this.mappingTable={},this.addEventMapping("pointerdown",this.mapPointerDown),this.addEventMapping("pointermove",this.mapPointerMove),this.addEventMapping("pointerout",this.mapPointerOut),this.addEventMapping("pointerleave",this.mapPointerOut),this.addEventMapping("pointerover",this.mapPointerOver),this.addEventMapping("pointerup",this.mapPointerUp),this.addEventMapping("pointerupoutside",this.mapPointerUpOutside),this.addEventMapping("wheel",this.mapWheel),this.addEventMapping("contextmenu",this.mapContextMenu)}addEventMapping(e,t){this.mappingTable[e]||(this.mappingTable[e]=[]),this.mappingTable[e].push({fn:t,priority:0}),this.mappingTable[e].sort((s,r)=>s.priority-r.priority)}dispatchEvent(e,t){e.propagationStopped=!1,e.propagationImmediatelyStopped=!1,this.propagate(e,t),this.dispatch.emit(t||e.type,e)}mapEvent(e){if(!this.rootTarget)return;const t=this.mappingTable[e.type];if(t)for(let s=0,r=t.length;s<r;s++)t[s].fn(e);else z(`[EventBoundary]: Event mapping not defined for ${e.type}`)}hitTest(e,t){ft.pauseUpdate=!0;const r=this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive",n=this[r](this.rootTarget,this.rootTarget.eventMode,ry.set(e,t),this.hitTestFn,this.hitPruneFn);return n&&n[0]}propagate(e,t){if(!e.target)return;const s=e.composedPath();e.eventPhase=e.CAPTURING_PHASE;for(let r=0,n=s.length-1;r<n;r++)if(e.currentTarget=s[r],this.notifyTarget(e,t),e.propagationStopped||e.propagationImmediatelyStopped)return;if(e.eventPhase=e.AT_TARGET,e.currentTarget=e.target,this.notifyTarget(e,t),!(e.propagationStopped||e.propagationImmediatelyStopped)){e.eventPhase=e.BUBBLING_PHASE;for(let r=s.length-2;r>=0;r--)if(e.currentTarget=s[r],this.notifyTarget(e,t),e.propagationStopped||e.propagationImmediatelyStopped)return}}all(e,t,s=this._allInteractiveElements){if(s.length===0)return;e.eventPhase=e.BUBBLING_PHASE;const r=Array.isArray(t)?t:[t];for(let n=s.length-1;n>=0;n--)r.forEach(o=>{e.currentTarget=s[n],this.notifyTarget(e,o)})}propagationPath(e){const t=[e];for(let s=0;s<iy&&e!==this.rootTarget&&e.parent;s++){if(!e.parent)throw new Error("Cannot find propagation path to disconnected target");t.push(e.parent),e=e.parent}return t.reverse(),t}hitTestMoveRecursive(e,t,s,r,n,o=!1){let a=!1;if(this._interactivePrune(e))return null;if((e.eventMode==="dynamic"||t==="dynamic")&&(ft.pauseUpdate=!1),e.interactiveChildren&&e.children){const c=e.children;for(let u=c.length-1;u>=0;u--){const d=c[u],f=this.hitTestMoveRecursive(d,this._isInteractive(t)?t:d.eventMode,s,r,n,o||n(e,s));if(f){if(f.length>0&&!f[f.length-1].parent)continue;const p=e.isInteractive();(f.length>0||p)&&(p&&this._allInteractiveElements.push(e),f.push(e)),this._hitElements.length===0&&(this._hitElements=f),a=!0}}}const l=this._isInteractive(t),h=e.isInteractive();return h&&h&&this._allInteractiveElements.push(e),o||this._hitElements.length>0?null:a?this._hitElements:l&&!n(e,s)&&r(e,s)?h?[e]:[]:null}hitTestRecursive(e,t,s,r,n){if(this._interactivePrune(e)||n(e,s))return null;if((e.eventMode==="dynamic"||t==="dynamic")&&(ft.pauseUpdate=!1),e.interactiveChildren&&e.children){const l=e.children,h=s;for(let c=l.length-1;c>=0;c--){const u=l[c],d=this.hitTestRecursive(u,this._isInteractive(t)?t:u.eventMode,h,r,n);if(d){if(d.length>0&&!d[d.length-1].parent)continue;const f=e.isInteractive();return(d.length>0||f)&&d.push(e),d}}}const o=this._isInteractive(t),a=e.isInteractive();return o&&r(e,s)?a?[e]:[]:null}_isInteractive(e){return e==="static"||e==="dynamic"}_interactivePrune(e){return!e||!e.visible||!e.renderable||!e.measurable||e.eventMode==="none"||e.eventMode==="passive"&&!e.interactiveChildren}hitPruneFn(e,t){if(e.hitArea&&(e.worldTransform.applyInverse(t,Zs),!e.hitArea.contains(Zs.x,Zs.y)))return!0;if(e.effects&&e.effects.length)for(let s=0;s<e.effects.length;s++){const r=e.effects[s];if(r.containsPoint&&!r.containsPoint(t,this.hitTestFn))return!0}return!1}hitTestFn(e,t){return e.hitArea?!0:e?.containsPoint?(e.worldTransform.applyInverse(t,Zs),e.containsPoint(Zs)):!1}notifyTarget(e,t){if(!e.currentTarget.isInteractive())return;t??(t=e.type);const s=`on${t}`;e.currentTarget[s]?.(e);const r=e.eventPhase===e.CAPTURING_PHASE||e.eventPhase===e.AT_TARGET?`${t}capture`:t;this._notifyListeners(e,r),e.eventPhase===e.AT_TARGET&&this._notifyListeners(e,t)}mapPointerDown(e){if(!(e instanceof Fe)){z("EventBoundary cannot map a non-pointer event as a pointer event");return}const t=this.createPointerEvent(e);if(this.dispatchEvent(t,"pointerdown"),t.pointerType==="touch")this.dispatchEvent(t,"touchstart");else if(t.pointerType==="mouse"||t.pointerType==="pen"){const r=t.button===2;this.dispatchEvent(t,r?"rightdown":"mousedown")}const s=this.trackingData(e.pointerId);s.pressTargetsByButton[e.button]=t.composedPath(),this.freeEvent(t)}mapPointerMove(e){if(!(e instanceof Fe)){z("EventBoundary cannot map a non-pointer event as a pointer event");return}this._allInteractiveElements.length=0,this._hitElements.length=0,this._isPointerMoveEvent=!0;const t=this.createPointerEvent(e);this._isPointerMoveEvent=!1;const s=t.pointerType==="mouse"||t.pointerType==="pen",r=this.trackingData(e.pointerId),n=this.findMountedTarget(r.overTargets);if(r.overTargets?.length>0&&n!==t.target){const l=e.type==="mousemove"?"mouseout":"pointerout",h=this.createPointerEvent(e,l,n);if(this.dispatchEvent(h,"pointerout"),s&&this.dispatchEvent(h,"mouseout"),!t.composedPath().includes(n)){const c=this.createPointerEvent(e,"pointerleave",n);for(c.eventPhase=c.AT_TARGET;c.target&&!t.composedPath().includes(c.target);)c.currentTarget=c.target,this.notifyTarget(c),s&&this.notifyTarget(c,"mouseleave"),c.target=c.target.parent;this.freeEvent(c)}this.freeEvent(h)}if(n!==t.target){const l=e.type==="mousemove"?"mouseover":"pointerover",h=this.clonePointerEvent(t,l);this.dispatchEvent(h,"pointerover"),s&&this.dispatchEvent(h,"mouseover");let c=n?.parent;for(;c&&c!==this.rootTarget.parent&&c!==t.target;)c=c.parent;if(!c||c===this.rootTarget.parent){const d=this.clonePointerEvent(t,"pointerenter");for(d.eventPhase=d.AT_TARGET;d.target&&d.target!==n&&d.target!==this.rootTarget.parent;)d.currentTarget=d.target,this.notifyTarget(d),s&&this.notifyTarget(d,"mouseenter"),d.target=d.target.parent;this.freeEvent(d)}this.freeEvent(h)}const o=[],a=this.enableGlobalMoveEvents??!0;this.moveOnAll?o.push("pointermove"):this.dispatchEvent(t,"pointermove"),a&&o.push("globalpointermove"),t.pointerType==="touch"&&(this.moveOnAll?o.splice(1,0,"touchmove"):this.dispatchEvent(t,"touchmove"),a&&o.push("globaltouchmove")),s&&(this.moveOnAll?o.splice(1,0,"mousemove"):this.dispatchEvent(t,"mousemove"),a&&o.push("globalmousemove"),this.cursor=t.target?.cursor),o.length>0&&this.all(t,o),this._allInteractiveElements.length=0,this._hitElements.length=0,r.overTargets=t.composedPath(),this.freeEvent(t)}mapPointerOver(e){if(!(e instanceof Fe)){z("EventBoundary cannot map a non-pointer event as a pointer event");return}const t=this.trackingData(e.pointerId),s=this.createPointerEvent(e),r=s.pointerType==="mouse"||s.pointerType==="pen";this.dispatchEvent(s,"pointerover"),r&&this.dispatchEvent(s,"mouseover"),s.pointerType==="mouse"&&(this.cursor=s.target?.cursor);const n=this.clonePointerEvent(s,"pointerenter");for(n.eventPhase=n.AT_TARGET;n.target&&n.target!==this.rootTarget.parent;)n.currentTarget=n.target,this.notifyTarget(n),r&&this.notifyTarget(n,"mouseenter"),n.target=n.target.parent;t.overTargets=s.composedPath(),this.freeEvent(s),this.freeEvent(n)}mapPointerOut(e){if(!(e instanceof Fe)){z("EventBoundary cannot map a non-pointer event as a pointer event");return}const t=this.trackingData(e.pointerId);if(t.overTargets){const s=e.pointerType==="mouse"||e.pointerType==="pen",r=this.findMountedTarget(t.overTargets),n=this.createPointerEvent(e,"pointerout",r);this.dispatchEvent(n),s&&this.dispatchEvent(n,"mouseout");const o=this.createPointerEvent(e,"pointerleave",r);for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==this.rootTarget.parent;)o.currentTarget=o.target,this.notifyTarget(o),s&&this.notifyTarget(o,"mouseleave"),o.target=o.target.parent;t.overTargets=null,this.freeEvent(n),this.freeEvent(o)}this.cursor=null}mapPointerUp(e){if(!(e instanceof Fe)){z("EventBoundary cannot map a non-pointer event as a pointer event");return}const t=performance.now(),s=this.createPointerEvent(e);if(this.dispatchEvent(s,"pointerup"),s.pointerType==="touch")this.dispatchEvent(s,"touchend");else if(s.pointerType==="mouse"||s.pointerType==="pen"){const a=s.button===2;this.dispatchEvent(s,a?"rightup":"mouseup")}const r=this.trackingData(e.pointerId),n=this.findMountedTarget(r.pressTargetsByButton[e.button]);let o=n;if(n&&!s.composedPath().includes(n)){let a=n;for(;a&&!s.composedPath().includes(a);){if(s.currentTarget=a,this.notifyTarget(s,"pointerupoutside"),s.pointerType==="touch")this.notifyTarget(s,"touchendoutside");else if(s.pointerType==="mouse"||s.pointerType==="pen"){const l=s.button===2;this.notifyTarget(s,l?"rightupoutside":"mouseupoutside")}a=a.parent}delete r.pressTargetsByButton[e.button],o=a}if(o){const a=this.clonePointerEvent(s,"click");a.target=o,a.path=null,r.clicksByButton[e.button]||(r.clicksByButton[e.button]={clickCount:0,target:a.target,timeStamp:t});const l=r.clicksByButton[e.button];if(l.target===a.target&&t-l.timeStamp<200?++l.clickCount:l.clickCount=1,l.target=a.target,l.timeStamp=t,a.detail=l.clickCount,a.pointerType==="mouse"){const h=a.button===2;this.dispatchEvent(a,h?"rightclick":"click")}else a.pointerType==="touch"&&this.dispatchEvent(a,"tap");this.dispatchEvent(a,"pointertap"),this.freeEvent(a)}this.freeEvent(s)}mapPointerUpOutside(e){if(!(e instanceof Fe)){z("EventBoundary cannot map a non-pointer event as a pointer event");return}const t=this.trackingData(e.pointerId),s=this.findMountedTarget(t.pressTargetsByButton[e.button]),r=this.createPointerEvent(e);if(s){let n=s;for(;n;)r.currentTarget=n,this.notifyTarget(r,"pointerupoutside"),r.pointerType==="touch"?this.notifyTarget(r,"touchendoutside"):(r.pointerType==="mouse"||r.pointerType==="pen")&&this.notifyTarget(r,r.button===2?"rightupoutside":"mouseupoutside"),n=n.parent;delete t.pressTargetsByButton[e.button]}this.freeEvent(r)}mapWheel(e){if(!(e instanceof cs)){z("EventBoundary cannot map a non-wheel event as a wheel event");return}const t=this.createWheelEvent(e);this.dispatchEvent(t),this.freeEvent(t)}mapContextMenu(e){if(!(e instanceof Fe)){z("EventBoundary cannot map a non-pointer event as a pointer event");return}const t=this.createPointerEvent(e);this.dispatchEvent(t,"contextmenu"),this.freeEvent(t)}findMountedTarget(e){if(!e)return null;let t=e[0];for(let s=1;s<e.length&&e[s].parent===t;s++)t=e[s];return t}createPointerEvent(e,t,s){const r=this.allocateEvent(Fe);return this.copyPointerData(e,r),this.copyMouseData(e,r),this.copyData(e,r),r.nativeEvent=e.nativeEvent,r.originalEvent=e,r.target=s??this.hitTest(r.global.x,r.global.y)??this._hitElements[0],typeof t=="string"&&(r.type=t),r}createWheelEvent(e){const t=this.allocateEvent(cs);return this.copyWheelData(e,t),this.copyMouseData(e,t),this.copyData(e,t),t.nativeEvent=e.nativeEvent,t.originalEvent=e,t.target=this.hitTest(t.global.x,t.global.y),t}clonePointerEvent(e,t){const s=this.allocateEvent(Fe);return s.nativeEvent=e.nativeEvent,s.originalEvent=e.originalEvent,this.copyPointerData(e,s),this.copyMouseData(e,s),this.copyData(e,s),s.target=e.target,s.path=e.composedPath().slice(),s.type=t??s.type,s}copyWheelData(e,t){t.deltaMode=e.deltaMode,t.deltaX=e.deltaX,t.deltaY=e.deltaY,t.deltaZ=e.deltaZ}copyPointerData(e,t){e instanceof Fe&&t instanceof Fe&&(t.pointerId=e.pointerId,t.width=e.width,t.height=e.height,t.isPrimary=e.isPrimary,t.pointerType=e.pointerType,t.pressure=e.pressure,t.tangentialPressure=e.tangentialPressure,t.tiltX=e.tiltX,t.tiltY=e.tiltY,t.twist=e.twist,t.persistentDeviceId=e.persistentDeviceId)}copyMouseData(e,t){e instanceof vi&&t instanceof vi&&(t.altKey=e.altKey,t.button=e.button,t.buttons=e.buttons,t.client.copyFrom(e.client),t.ctrlKey=e.ctrlKey,t.metaKey=e.metaKey,t.movement.copyFrom(e.movement),t.screen.copyFrom(e.screen),t.shiftKey=e.shiftKey,t.global.copyFrom(e.global))}copyData(e,t){t.isTrusted=e.isTrusted,t.srcElement=e.srcElement,t.timeStamp=performance.now(),t.type=e.type,t.detail=e.detail,t.view=e.view,t.which=e.which,t.layer.copyFrom(e.layer),t.page.copyFrom(e.page)}trackingData(e){return this.mappingState.trackingData[e]||(this.mappingState.trackingData[e]={pressTargetsByButton:{},clicksByButton:{},overTarget:null}),this.mappingState.trackingData[e]}allocateEvent(e){this.eventPool.has(e)||this.eventPool.set(e,[]);const t=this.eventPool.get(e).pop()||new e(this);return t.eventPhase=t.NONE,t.currentTarget=null,t.defaultPrevented=!1,t.path=null,t.target=null,t}freeEvent(e){if(e.manager!==this)throw new Error("It is illegal to free an event not managed by this EventBoundary!");const t=e.constructor;this.eventPool.has(t)||this.eventPool.set(t,[]),this.eventPool.get(t).push(e)}_notifyListeners(e,t){const s=e.currentTarget._events[t];if(s)if("fn"in s)s.once&&e.currentTarget.removeListener(t,s.fn,void 0,!0),s.fn.call(s.context,e);else for(let r=0,n=s.length;r<n&&!e.propagationImmediatelyStopped;r++)s[r].once&&e.currentTarget.removeListener(t,s[r].fn,void 0,!0),s[r].fn.call(s[r].context,e)}}const ny=1,oy={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},Fa=class ko{constructor(e){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=e,this.rootBoundary=new jf(null),ft.init(this),this.autoPreventDefault=!0,this._eventsAdded=!1,this._rootPointerEvent=new Fe(null),this._rootWheelEvent=new cs(null),this._rootContextMenuEvent=new Fe(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy({...ko.defaultEventFeatures},{set:(t,s,r)=>(s==="globalMove"&&(this.rootBoundary.enableGlobalMoveEvents=r),t[s]=r,!0)}),this._onPointerDown=this._onPointerDown.bind(this),this._onPointerMove=this._onPointerMove.bind(this),this._onPointerUp=this._onPointerUp.bind(this),this._onPointerOverOut=this._onPointerOverOut.bind(this),this._onContextMenu=this._onContextMenu.bind(this),this.onWheel=this.onWheel.bind(this)}static get defaultEventMode(){return this._defaultEventMode}init(e){const{canvas:t,resolution:s}=this.renderer;this.setTargetElement(t),this.resolution=s,ko._defaultEventMode=e.eventMode??"passive",Object.assign(this.features,e.eventFeatures??{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(e){this.resolution=e}destroy(){ft.destroy(),this.setTargetElement(null),this.renderer=null,this._currentCursor=null}setCursor(e){e||(e="default");let t=!0;if(globalThis.OffscreenCanvas&&this.domElement instanceof OffscreenCanvas&&(t=!1),this._currentCursor===e)return;this._currentCursor=e;const s=this.cursorStyles[e];if(s)switch(typeof s){case"string":t&&(this.domElement.style.cursor=s);break;case"function":s(e);break;case"object":t&&Object.assign(this.domElement.style,s);break}else t&&typeof e=="string"&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,e)&&(this.domElement.style.cursor=e)}get pointer(){return this._rootPointerEvent}_onPointerDown(e){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const t=this._normalizeToPointerData(e);this.autoPreventDefault&&t[0].isNormalized&&(e.cancelable||!("cancelable"in e))&&e.preventDefault();for(let s=0,r=t.length;s<r;s++){const n=t[s],o=this._bootstrapEvent(this._rootPointerEvent,n);this.rootBoundary.mapEvent(o)}this.setCursor(this.rootBoundary.cursor)}_onPointerMove(e){if(!this.features.move)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,ft.pointerMoved();const t=this._normalizeToPointerData(e);for(let s=0,r=t.length;s<r;s++){const n=this._bootstrapEvent(this._rootPointerEvent,t[s]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}_onPointerUp(e){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;let t=e.target;e.composedPath&&e.composedPath().length>0&&(t=e.composedPath()[0]);const s=t!==this.domElement?"outside":"",r=this._normalizeToPointerData(e);for(let n=0,o=r.length;n<o;n++){const a=this._bootstrapEvent(this._rootPointerEvent,r[n]);a.type+=s,this.rootBoundary.mapEvent(a)}this.setCursor(this.rootBoundary.cursor)}_onPointerOverOut(e){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const t=this._normalizeToPointerData(e);for(let s=0,r=t.length;s<r;s++){const n=this._bootstrapEvent(this._rootPointerEvent,t[s]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}_onContextMenu(e){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const t=this._normalizeToPointerData(e);for(let s=0,r=t.length;s<r;s++){const n=this._bootstrapEvent(this._rootContextMenuEvent,t[s]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}onWheel(e){if(!this.features.wheel)return;const t=this.normalizeWheelEvent(e);this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.rootBoundary.mapEvent(t)}setTargetElement(e){this._removeEvents(),this.domElement=e,ft.domElement=e,this._addEvents()}_addEvents(){if(this._eventsAdded||!this.domElement)return;ft.addTickerListener();const e=this.domElement.style;e&&(globalThis.navigator.msPointerEnabled?(e.msContentZooming="none",e.msTouchAction="none"):this.supportsPointerEvents&&(e.touchAction="none")),this.supportsPointerEvents?(globalThis.document.addEventListener("pointermove",this._onPointerMove,!0),this.domElement.addEventListener("pointerdown",this._onPointerDown,!0),this.domElement.addEventListener("pointerleave",this._onPointerOverOut,!0),this.domElement.addEventListener("pointerover",this._onPointerOverOut,!0),globalThis.addEventListener("pointerup",this._onPointerUp,!0)):(globalThis.document.addEventListener("mousemove",this._onPointerMove,!0),this.domElement.addEventListener("mousedown",this._onPointerDown,!0),this.domElement.addEventListener("mouseout",this._onPointerOverOut,!0),this.domElement.addEventListener("mouseover",this._onPointerOverOut,!0),globalThis.addEventListener("mouseup",this._onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.addEventListener("touchstart",this._onPointerDown,!0),this.domElement.addEventListener("touchend",this._onPointerUp,!0),this.domElement.addEventListener("touchmove",this._onPointerMove,!0))),this.domElement.addEventListener("wheel",this.onWheel,{passive:!0,capture:!0}),this.domElement.addEventListener("contextmenu",this._onContextMenu,!0),this._eventsAdded=!0}_removeEvents(){if(!this._eventsAdded||!this.domElement)return;ft.removeTickerListener();const e=this.domElement.style;e&&(globalThis.navigator.msPointerEnabled?(e.msContentZooming="",e.msTouchAction=""):this.supportsPointerEvents&&(e.touchAction="")),this.supportsPointerEvents?(globalThis.document.removeEventListener("pointermove",this._onPointerMove,!0),this.domElement.removeEventListener("pointerdown",this._onPointerDown,!0),this.domElement.removeEventListener("pointerleave",this._onPointerOverOut,!0),this.domElement.removeEventListener("pointerover",this._onPointerOverOut,!0),globalThis.removeEventListener("pointerup",this._onPointerUp,!0)):(globalThis.document.removeEventListener("mousemove",this._onPointerMove,!0),this.domElement.removeEventListener("mousedown",this._onPointerDown,!0),this.domElement.removeEventListener("mouseout",this._onPointerOverOut,!0),this.domElement.removeEventListener("mouseover",this._onPointerOverOut,!0),globalThis.removeEventListener("mouseup",this._onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.removeEventListener("touchstart",this._onPointerDown,!0),this.domElement.removeEventListener("touchend",this._onPointerUp,!0),this.domElement.removeEventListener("touchmove",this._onPointerMove,!0))),this.domElement.removeEventListener("wheel",this.onWheel,!0),this.domElement.removeEventListener("contextmenu",this._onContextMenu,!0),this.domElement=null,this._eventsAdded=!1}mapPositionToPoint(e,t,s){const r=this.domElement.isConnected?this.domElement.getBoundingClientRect():{width:this.domElement.width,height:this.domElement.height,left:0,top:0},n=1/this.resolution;e.x=(t-r.left)*(this.domElement.width/r.width)*n,e.y=(s-r.top)*(this.domElement.height/r.height)*n}_normalizeToPointerData(e){const t=[];if(this.supportsTouchEvents&&e instanceof TouchEvent)for(let s=0,r=e.changedTouches.length;s<r;s++){const n=e.changedTouches[s];typeof n.button>"u"&&(n.button=0),typeof n.buttons>"u"&&(n.buttons=1),typeof n.isPrimary>"u"&&(n.isPrimary=e.touches.length===1&&e.type==="touchstart"),typeof n.width>"u"&&(n.width=n.radiusX||1),typeof n.height>"u"&&(n.height=n.radiusY||1),typeof n.tiltX>"u"&&(n.tiltX=0),typeof n.tiltY>"u"&&(n.tiltY=0),typeof n.pointerType>"u"&&(n.pointerType="touch"),typeof n.pointerId>"u"&&(n.pointerId=n.identifier||0),typeof n.pressure>"u"&&(n.pressure=n.force||.5),typeof n.twist>"u"&&(n.twist=0),typeof n.tangentialPressure>"u"&&(n.tangentialPressure=0),typeof n.layerX>"u"&&(n.layerX=n.offsetX=n.clientX),typeof n.layerY>"u"&&(n.layerY=n.offsetY=n.clientY),n.isNormalized=!0,n.type=e.type,n.altKey??(n.altKey=e.altKey),n.ctrlKey??(n.ctrlKey=e.ctrlKey),n.metaKey??(n.metaKey=e.metaKey),n.shiftKey??(n.shiftKey=e.shiftKey),t.push(n)}else if(!globalThis.MouseEvent||e instanceof MouseEvent&&(!this.supportsPointerEvents||!(e instanceof globalThis.PointerEvent))){const s=e;typeof s.isPrimary>"u"&&(s.isPrimary=!0),typeof s.width>"u"&&(s.width=1),typeof s.height>"u"&&(s.height=1),typeof s.tiltX>"u"&&(s.tiltX=0),typeof s.tiltY>"u"&&(s.tiltY=0),typeof s.pointerType>"u"&&(s.pointerType="mouse"),typeof s.pointerId>"u"&&(s.pointerId=ny),typeof s.pressure>"u"&&(s.pressure=.5),typeof s.twist>"u"&&(s.twist=0),typeof s.tangentialPressure>"u"&&(s.tangentialPressure=0),s.isNormalized=!0,t.push(s)}else t.push(e);return t}normalizeWheelEvent(e){const t=this._rootWheelEvent;return this._transferMouseData(t,e),t.deltaX=e.deltaX,t.deltaY=e.deltaY,t.deltaZ=e.deltaZ,t.deltaMode=e.deltaMode,this.mapPositionToPoint(t.screen,e.clientX,e.clientY),t.global.copyFrom(t.screen),t.offset.copyFrom(t.screen),t.nativeEvent=e,t.type=e.type,t}_bootstrapEvent(e,t){return e.originalEvent=null,e.nativeEvent=t,e.pointerId=t.pointerId,e.width=t.width,e.height=t.height,e.isPrimary=t.isPrimary,e.pointerType=t.pointerType,e.pressure=t.pressure,e.tangentialPressure=t.tangentialPressure,e.tiltX=t.tiltX,e.tiltY=t.tiltY,e.twist=t.twist,this._transferMouseData(e,t),this.mapPositionToPoint(e.screen,t.clientX,t.clientY),e.global.copyFrom(e.screen),e.offset.copyFrom(e.screen),e.isTrusted=t.isTrusted,e.type==="pointerleave"&&(e.type="pointerout"),e.type.startsWith("mouse")&&(e.type=e.type.replace("mouse","pointer")),e.type.startsWith("touch")&&(e.type=oy[e.type]||e.type),e}_transferMouseData(e,t){e.isTrusted=t.isTrusted,e.srcElement=t.srcElement,e.timeStamp=performance.now(),e.type=t.type,e.altKey=t.altKey,e.button=t.button,e.buttons=t.buttons,e.client.x=t.clientX,e.client.y=t.clientY,e.ctrlKey=t.ctrlKey,e.metaKey=t.metaKey,e.movement.x=t.movementX,e.movement.y=t.movementY,e.page.x=t.pageX,e.page.y=t.pageY,e.relatedTarget=null,e.shiftKey=t.shiftKey}};Fa.extension={name:"events",type:[S.WebGLSystem,S.CanvasSystem,S.WebGPUSystem],priority:-1};Fa.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let Xf=Fa;const ay={onclick:null,oncontextmenu:null,onmousedown:null,onmouseenter:null,onmouseleave:null,onmousemove:null,onglobalmousemove:null,onmouseout:null,onmouseover:null,onmouseup:null,onmouseupoutside:null,onpointercancel:null,onpointerdown:null,onpointerenter:null,onpointerleave:null,onpointermove:null,onglobalpointermove:null,onpointerout:null,onpointerover:null,onpointertap:null,onpointerup:null,onpointerupoutside:null,onrightclick:null,onrightdown:null,onrightup:null,onrightupoutside:null,ontap:null,ontouchcancel:null,ontouchend:null,ontouchendoutside:null,ontouchmove:null,onglobaltouchmove:null,ontouchstart:null,onwheel:null,get interactive(){return this.eventMode==="dynamic"||this.eventMode==="static"},set interactive(i){this.eventMode=i?"static":"passive"},_internalEventMode:void 0,get eventMode(){return this._internalEventMode??Xf.defaultEventMode},set eventMode(i){this._internalEventMode=i},isInteractive(){return this.eventMode==="static"||this.eventMode==="dynamic"},interactiveChildren:!0,hitArea:null,addEventListener(i,e,t){const s=typeof t=="boolean"&&t||typeof t=="object"&&t.capture,r=typeof t=="object"?t.signal:void 0,n=typeof t=="object"?t.once===!0:!1,o=typeof e=="function"?void 0:e;i=s?`${i}capture`:i;const a=typeof e=="function"?e:e.handleEvent,l=this;r&&r.addEventListener("abort",()=>{l.off(i,a,o)}),n?l.once(i,a,o):l.on(i,a,o)},removeEventListener(i,e,t){const s=typeof t=="boolean"&&t||typeof t=="object"&&t.capture,r=typeof e=="function"?void 0:e;i=s?`${i}capture`:i,e=typeof e=="function"?e:e.handleEvent,this.off(i,e,r)},dispatchEvent(i){if(!(i instanceof Ls))throw new Error("Container cannot propagate events outside of the Federated Events API");return i.defaultPrevented=!1,i.path=null,i.target=this,i.manager.dispatchEvent(i),!i.defaultPrevented}};let ys;function Cc(i){const e=te.get().createCanvas(6,1),t=e.getContext("2d");return t.fillStyle=i,t.fillRect(0,0,6,1),e}function Oa(){if(ys!==void 0)return ys;try{const i=Cc("#ff00ff"),e=Cc("#ffff00"),s=te.get().createCanvas(6,1).getContext("2d");s.globalCompositeOperation="multiply",s.drawImage(i,0,0),s.drawImage(e,2,0);const r=s.getImageData(2,0,1,1);if(!r)ys=!1;else{const n=r.data;ys=n[0]===255&&n[1]===0&&n[2]===0}}catch{ys=!1}return ys}const K={canvas:null,convertTintToImage:!1,cacheStepsPerColorChannel:8,canUseMultiply:Oa(),tintMethod:null,_canvasSourceCache:new WeakMap,_unpremultipliedCache:new WeakMap,getCanvasSource:i=>{const e=i.source,t=e?.resource;if(!t)return null;const s=e.alphaMode==="premultiplied-alpha",r=e.resourceWidth??e.pixelWidth,n=e.resourceHeight??e.pixelHeight,o=r!==e.pixelWidth||n!==e.pixelHeight;if(s){if((t instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas)&&!o)return t;const a=K._unpremultipliedCache.get(e);if(a?.resourceId===e._resourceId)return a.canvas}if(t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int8Array||t instanceof Uint16Array||t instanceof Int16Array||t instanceof Uint32Array||t instanceof Int32Array||t instanceof Float32Array||t instanceof ArrayBuffer){const a=K._canvasSourceCache.get(e);if(a?.resourceId===e._resourceId)return a.canvas;const l=te.get().createCanvas(e.pixelWidth,e.pixelHeight),h=l.getContext("2d"),c=h.createImageData(e.pixelWidth,e.pixelHeight),u=c.data,d=t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength);if(e.format==="bgra8unorm")for(let f=0;f<u.length&&f+3<d.length;f+=4)u[f]=d[f+2],u[f+1]=d[f+1],u[f+2]=d[f],u[f+3]=d[f+3];else u.set(d.subarray(0,u.length));return h.putImageData(c,0,0),K._canvasSourceCache.set(e,{canvas:l,resourceId:e._resourceId}),l}if(s){const a=te.get().createCanvas(e.pixelWidth,e.pixelHeight),l=a.getContext("2d",{willReadFrequently:!0});a.width=e.pixelWidth,a.height=e.pixelHeight,l.drawImage(t,0,0);const h=l.getImageData(0,0,a.width,a.height),c=h.data;for(let u=0;u<c.length;u+=4){const d=c[u+3];if(d>0){const f=255/d;c[u]=Math.min(255,c[u]*f+.5),c[u+1]=Math.min(255,c[u+1]*f+.5),c[u+2]=Math.min(255,c[u+2]*f+.5)}}return l.putImageData(h,0,0),K._unpremultipliedCache.set(e,{canvas:a,resourceId:e._resourceId}),a}if(o){const a=K._canvasSourceCache.get(e);if(a?.resourceId===e._resourceId)return a.canvas;const l=te.get().createCanvas(e.pixelWidth,e.pixelHeight),h=l.getContext("2d");return l.width=e.pixelWidth,l.height=e.pixelHeight,h.drawImage(t,0,0),K._canvasSourceCache.set(e,{canvas:l,resourceId:e._resourceId}),l}return t},getTintedCanvas:(i,e)=>{const t=i.texture,s=le.shared.setValue(e).toHex(),r=t.tintCache||(t.tintCache={}),n=r[s],o=t.source._resourceId;if(n?.tintId===o)return n;const a=n&&"getContext"in n?n:te.get().createCanvas();return K.tintMethod(t,e,a),a.tintId=o,r[s]=a,r[s]},getTintedPattern:(i,e)=>{const t=le.shared.setValue(e).toHex(),s=i.patternCache||(i.patternCache={}),r=i.source._resourceId;let n=s[t];return n?.tintId===r||(K.canvas||(K.canvas=te.get().createCanvas()),K.tintMethod(i,e,K.canvas),n=K.canvas.getContext("2d").createPattern(K.canvas,"repeat"),n.tintId=r,s[t]=n),n},applyPatternTransform:(i,e,t=!0)=>{if(!e)return;const s=i;if(!s.setTransform)return;const r=globalThis.DOMMatrix;if(!r)return;const n=new r([e.a,e.b,e.c,e.d,e.tx,e.ty]);s.setTransform(t?n.inverse():n)},tintWithMultiply:(i,e,t)=>{const s=t.getContext("2d"),r=i.frame.clone(),n=i.source._resolution??i.source.resolution??1,o=i.rotate;r.x*=n,r.y*=n,r.width*=n,r.height*=n;const a=Q.isVertical(o),l=a?r.height:r.width,h=a?r.width:r.height;t.width=Math.ceil(l),t.height=Math.ceil(h),s.save(),e!==16777215&&(s.fillStyle=le.shared.setValue(e).toHex(),s.fillRect(0,0,l,h),s.globalCompositeOperation="multiply");const c=K.getCanvasSource(i);if(!c){s.restore();return}o&&K._applyInverseRotation(s,o,r.width,r.height),s.drawImage(c,r.x,r.y,r.width,r.height,0,0,r.width,r.height),e!==16777215&&(s.globalCompositeOperation="destination-atop",s.drawImage(c,r.x,r.y,r.width,r.height,0,0,r.width,r.height)),s.restore()},tintWithOverlay:(i,e,t)=>{const s=t.getContext("2d"),r=i.frame.clone(),n=i.source._resolution??i.source.resolution??1,o=i.rotate;r.x*=n,r.y*=n,r.width*=n,r.height*=n;const a=Q.isVertical(o),l=a?r.height:r.width,h=a?r.width:r.height;t.width=Math.ceil(l),t.height=Math.ceil(h),s.save(),s.globalCompositeOperation="copy",s.fillStyle=le.shared.setValue(e).toHex(),s.fillRect(0,0,l,h),s.globalCompositeOperation="destination-atop";const c=K.getCanvasSource(i);if(!c){s.restore();return}o&&K._applyInverseRotation(s,o,r.width,r.height),s.drawImage(c,r.x,r.y,r.width,r.height,0,0,r.width,r.height),s.restore()},tintWithPerPixel:(i,e,t)=>{const s=t.getContext("2d"),r=i.frame.clone(),n=i.source._resolution??i.source.resolution??1,o=i.rotate;r.x*=n,r.y*=n,r.width*=n,r.height*=n;const a=Q.isVertical(o),l=a?r.height:r.width,h=a?r.width:r.height;t.width=Math.ceil(l),t.height=Math.ceil(h),s.save(),s.globalCompositeOperation="copy";const c=K.getCanvasSource(i);if(!c){s.restore();return}o&&K._applyInverseRotation(s,o,r.width,r.height),s.drawImage(c,r.x,r.y,r.width,r.height,0,0,r.width,r.height),s.restore();const u=e>>16&255,d=e>>8&255,f=e&255,p=s.getImageData(0,0,l,h),m=p.data;for(let g=0;g<m.length;g+=4)m[g]=m[g]*u/255,m[g+1]=m[g+1]*d/255,m[g+2]=m[g+2]*f/255;s.putImageData(p,0,0)},_applyInverseRotation:(i,e,t,s)=>{const r=Q.inv(e),n=Q.uX(r),o=Q.uY(r),a=Q.vX(r),l=Q.vY(r),h=-Math.min(0,n*t,a*s,n*t+a*s),c=-Math.min(0,o*t,l*s,o*t+l*s);i.transform(n,o,a,l,h,c)}};K.tintMethod=K.canUseMultiply?K.tintWithMultiply:K.tintWithPerPixel;const Gn=32767;function kc(i,e){return(i<<17)+(e<<2)}class qf{constructor(e){this._buckets=new Map,this._screens=new Zo,this._enableFullScreen=!1,this.canvasOptions=e||{}}get enableFullScreen(){return N(dt,"CanvasPool.enableFullScreen is no longer used, the pool sizes canvases to the screens registered with setScreenSize."),this._enableFullScreen}set enableFullScreen(e){N(dt,"CanvasPool.enableFullScreen is no longer used, the pool sizes canvases to the screens registered with setScreenSize."),this._enableFullScreen=e}_createCanvasAndContext(e,t){const s=te.get().createCanvas();s.width=e,s.height=t;const r=s.getContext("2d");return{canvas:s,context:r}}getOptimalCanvasAndContext(e,t,s=1){const{width:r,height:n}=this.getOptimalSize(e,t,s);(r>Gn||n>Gn)&&z(`CanvasPool: ${r}x${n} is larger than the ${Gn}px pool key limit, canvases of this size may be pooled together`);const o=kc(r,n);let a=this._buckets.get(o);a||(a=[],this._buckets.set(o,a));let l=a.pop();return l||(l=this._createCanvasAndContext(r,n)),l}getOptimalSize(e,t,s=1){const r=Math.ceil(e*s-1e-6),n=Math.ceil(t*s-1e-6),o=rs(r),a=this._screens.getFittingWidth(r),l=rs(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}}returnCanvasAndContext(e){const t=e.canvas,{width:s,height:r}=t,n=this._buckets.get(kc(s,r));n&&(e.context.resetTransform(),e.context.clearRect(0,0,s,r),n.push(e))}setScreenSize(e,t,s){this._screens.set(e,t,s)&&this._pruneScreenCanvases()}removeScreen(e){this._screens.remove(e)&&this._pruneScreenCanvases()}clear(){this._buckets.clear()}_pruneScreenCanvases(){for(const[e]of this._buckets){const t=e>>>17,s=e>>>2&32767;(ns(t)||this._screens.hasWidth(t))&&(ns(s)||this._screens.hasHeight(s))||this._buckets.delete(e)}}}const Rt=new qf;us.register(Rt);const Ec=new L;function La(i,e){e.clear();const t=e.matrix;for(let s=0;s<i.length;s++){const r=i[s];if(r.globalDisplayStatus<7)continue;const n=r.renderGroup??r.parentRenderGroup;n?.isCachedAsTexture?e.matrix=Ec.copyFrom(n.textureOffsetInverseTransform).append(r.worldTransform):n?._parentCacheAsTextureRenderGroup?e.matrix=Ec.copyFrom(n._parentCacheAsTextureRenderGroup.inverseWorldTransform).append(r.groupTransform):e.matrix=r.worldTransform,e.addBounds(r.bounds)}return e.matrix=t,e}const ly=new Ee;function Ua(i,e,t,s,r=!1,n){const o=ly;o.minX=0,o.minY=0,o.maxX=i.width/s|0,o.maxY=i.height/s|0;const a=Te.getOptimalTexture({width:o.width,height:o.height,resolution:s,autoGenerateMipmaps:r,scaleMode:n});return a.source.uploadMethodId="image",a.source.resource=i,a.source.alphaMode="premultiply-alpha-on-upload",a.frame.width=e/s,a.frame.height=t/s,a.source.emit("update",a.source),a.updateUvs(),a}function Eo(i){return typeof i.getCanvasFilterString=="function"}class hy{constructor(){this.skip=!1,this.useClip=!1,this.filters=null,this.container=null,this.bounds=new Ee,this.cssFilterString=""}}class Yf{constructor(e){this._filterStack=[],this._filterStackIndex=0,this._savedStates=[],this._alphaMultiplier=1,this._warnedFilterTypes=new Set,this.renderer=e}push(e){const t=this._pushFilterFrame(),s=e.filterEffect.filters;if(t.skip=!1,t.useClip=!1,t.filters=s,t.container=e.container,t.cssFilterString="",s.every(l=>!l.enabled)){t.skip=!0;return}const r=[],n=1;for(const l of s){if(!l.enabled)continue;if(!Eo(l)){this._warnUnsupportedFilter(l);continue}const h=l.getCanvasFilterString();if(h===null){this._warnUnsupportedFilter(l);continue}h&&r.push(h)}if(r.length===0&&n===1){t.skip=!0;return}t.cssFilterString=r.join(" "),this._calculateFilterArea(e,t.bounds),t.useClip=!!e.filterEffect.filterArea;const o=this.renderer.canvasContext.activeContext,a=o.filter||"none";if(this._savedStates.push({filter:a,alphaMultiplier:this._alphaMultiplier}),t.useClip&&Number.isFinite(t.bounds.width)&&Number.isFinite(t.bounds.height)&&t.bounds.width>0&&t.bounds.height>0){const l=this.renderer.canvasContext.activeResolution||1;o.save(),o.setTransform(1,0,0,1,0,0),o.beginPath(),o.rect(t.bounds.x*l,t.bounds.y*l,t.bounds.width*l,t.bounds.height*l),o.clip()}else t.useClip=!1;t.cssFilterString&&(o.filter=a!=="none"?`${a} ${t.cssFilterString}`:t.cssFilterString)}pop(){const e=this._popFilterFrame();if(e.skip)return;const t=this._savedStates.pop();if(!t)return;const s=this.renderer.canvasContext.activeContext;e.useClip?s.restore():s.filter=t.filter,this._alphaMultiplier=t.alphaMultiplier}generateFilteredTexture({texture:e,filters:t}){if(!t?.length||t.every(_=>!_.enabled))return e;const s=[],r=1;for(const _ of t){if(!_.enabled)continue;if(!Eo(_)){this._warnUnsupportedFilter(_);continue}const y=_.getCanvasFilterString();if(y===null){this._warnUnsupportedFilter(_);continue}y&&s.push(y)}if(s.length===0&&r===1)return e;const n=K.getCanvasSource(e);if(!n)return e;const o=e.frame,a=e.source._resolution??e.source.resolution??1,l=o.width,h=o.height,c=Rt.getOptimalCanvasAndContext(l,h,a),{canvas:u,context:d}=c;d.setTransform(1,0,0,1,0,0),d.clearRect(0,0,u.width,u.height),s.length&&(d.filter=s.join(" "));const f=o.x*a,p=o.y*a,m=l*a,g=h*a;return d.drawImage(n,f,p,m,g,0,0,m,g),d.filter="none",d.globalAlpha=1,Ua(u,l,h,a)}_calculateFilterArea(e,t){if(e.renderables?La(e.renderables,t):e.filterEffect.filterArea?(t.clear(),t.addRect(e.filterEffect.filterArea),t.applyMatrix(e.container.worldTransform)):e.container.getFastGlobalBounds(!0,t),e.container){const r=(e.container.renderGroup||e.container.parentRenderGroup)?.cacheToLocalTransform;r&&t.applyMatrix(r)}}_warnUnsupportedFilter(e){const t=e?.constructor?.name||"Filter";this._warnedFilterTypes.has(t)||(this._warnedFilterTypes.add(t),console.warn(`CanvasRenderer: filter "${t}" is not supported in Canvas2D and will be skipped.`))}get alphaMultiplier(){return this._alphaMultiplier}_pushFilterFrame(){let e=this._filterStack[this._filterStackIndex];return e||(e=this._filterStack[this._filterStackIndex]=new hy),this._filterStackIndex++,e}_popFilterFrame(){return this._filterStackIndex<=0?this._filterStack[0]:(this._filterStackIndex--,this._filterStack[this._filterStackIndex])}destroy(){this._filterStack=null,this._savedStates=null,this._warnedFilterTypes=null,this._alphaMultiplier=1}}Yf.extension={type:[S.CanvasSystem],name:"filter"};var Kf=`in vec2 aPosition;
|
|
254
254
|
out vec2 vTextureCoord;
|
|
255
255
|
|
|
256
256
|
uniform vec4 uInputSize;
|
|
@@ -551,10 +551,10 @@ fn mainFragment(
|
|
|
551
551
|
* @version 11.4.7
|
|
552
552
|
*/class my{constructor(e=0,t=0,s=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=e,this.resetTtl=s,this.size=0,this.ttl=t}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(e){if(this.has(e)){const t=this.items[e];delete this.items[e],this.size--,t.prev!==null&&(t.prev.next=t.next),t.next!==null&&(t.next.prev=t.prev),this.first===t&&(this.first=t.next),this.last===t&&(this.last=t.prev)}return this}entries(e=this.keys()){const t=new Array(e.length);for(let s=0;s<e.length;s++){const r=e[s];t[s]=[r,this.get(r)]}return t}evict(e=!1){if(e||this.size>0){const t=this.first;delete this.items[t.key],--this.size===0?(this.first=null,this.last=null):(this.first=t.next,this.first.prev=null)}return this}expiresAt(e){let t;return this.has(e)&&(t=this.items[e].expiry),t}get(e){const t=this.items[e];if(t!==void 0){if(this.ttl>0&&t.expiry<=Date.now()){this.delete(e);return}return this.moveToEnd(t),t.value}}has(e){return e in this.items}moveToEnd(e){this.last!==e&&(e.prev!==null&&(e.prev.next=e.next),e.next!==null&&(e.next.prev=e.prev),this.first===e&&(this.first=e.next),e.prev=this.last,e.next=null,this.last!==null&&(this.last.next=e),this.last=e,this.first===null&&(this.first=e))}keys(){const e=new Array(this.size);let t=this.first,s=0;for(;t!==null;)e[s++]=t.key,t=t.next;return e}setWithEvicted(e,t,s=this.resetTtl){let r=null;if(this.has(e))this.set(e,t,!0,s);else{this.max>0&&this.size===this.max&&(r={...this.first},this.evict(!0));let n=this.items[e]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:e,prev:this.last,next:null,value:t};++this.size===1?this.first=n:this.last.next=n,this.last=n}return r}set(e,t,s=!1,r=this.resetTtl){let n=this.items[e];return s||n!==void 0?(n.value=t,s===!1&&r&&(n.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.moveToEnd(n)):(this.max>0&&this.size===this.max&&this.evict(!0),n=this.items[e]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:e,prev:this.last,next:null,value:t},++this.size===1?this.first=n:this.last.next=n,this.last=n),this}values(e=this.keys()){const t=new Array(e.length);for(let s=0;s<e.length;s++)t[s]=this.get(e[s]);return t}}function gy(i=1e3,e=0,t=!1){if(isNaN(i)||i<0)throw new TypeError("Invalid max value");if(isNaN(e)||e<0)throw new TypeError("Invalid ttl value");if(typeof t!="boolean")throw new TypeError("Invalid resetTtl value");return new my(i,e,t)}function Va(i){return!!i.tagStyles&&Object.keys(i.tagStyles).length>0}function ja(i){return i.includes("<")}function _y(i,e){return i.clone().assign(e)}function cp(i,e){const t=[],s=e.tagStyles;if(!Va(e)||!ja(i))return t.push({text:i,style:e}),t;const r=[e],n=[];let o="",a=0;for(;a<i.length;){const l=i[a];if(l==="<"){const h=i.indexOf(">",a);if(h===-1){o+=l,a++;continue}const c=i.indexOf("<",a+1);if(c!==-1&&c<h){o+=l,a++;continue}const u=i.slice(a+1,h);if(u.startsWith("/")){const d=u.slice(1).trim();if(n.length>0&&n[n.length-1]===d){o.length>0&&(t.push({text:o,style:r[r.length-1]}),o=""),r.pop(),n.pop(),a=h+1;continue}else{o+=i.slice(a,h+1),a=h+1;continue}}else{const d=u.trim();if(s[d]){o.length>0&&(t.push({text:o,style:r[r.length-1]}),o="");const f=r[r.length-1],p=_y(f,s[d]);r.push(p),n.push(d),a=h+1;continue}else{o+=i.slice(a,h+1),a=h+1;continue}}}else o+=l,a++}return o.length>0&&t.push({text:o,style:r[r.length-1]}),t}const up=[10,13],dp=new Set(up),fp=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288],pp=new Set(fp),mp=[9,32];new Set(mp);const gp=[45,8208,8211,8212,173],_p=new Set(gp),yp=/(\r\n|\r|\n)/,xp=/(?:\r\n|\r|\n)/;function wi(i){return typeof i!="string"?!1:dp.has(i.charCodeAt(0))}function Ve(i,e){return typeof i!="string"?!1:pp.has(i.charCodeAt(0))}function bp(i){return typeof i!="string"?!1:_p.has(i.charCodeAt(0))}function Xa(i){return i==="normal"||i==="pre-line"}function qa(i){return i==="normal"}function ut(i){if(typeof i!="string")return"";let e=i.length-1;for(;e>=0&&Ve(i[e]);)e--;return e<i.length-1?i.slice(0,e+1):i}function Ya(i){const e=[],t=[];if(typeof i!="string")return e;for(let s=0;s<i.length;s++){const r=i[s],n=i[s+1];if(Ve(r)||wi(r)){t.length>0&&(e.push(t.join("")),t.length=0),r==="\r"&&n===`
|
|
553
553
|
`?(e.push(`\r
|
|
554
|
-
`),s++):e.push(r);continue}t.push(r),bp(r)&&n&&!Ve(n)&&!wi(n)&&(e.push(t.join("")),t.length=0)}return t.length>0&&e.push(t.join("")),e}function Ka(i,e,t,s){const r=t(i),n=[];for(let o=0;o<r.length;o++){let a=r[o],l=a,h=1;for(;r[o+h];){const c=r[o+h];if(!s(l,c,i,o,e))a+=c,l=c,h++;else break}o+=h-1,n.push(a)}return n}const yy=/\r\n|\r|\n/g;function vp(i,e,t,s,r,n,o,a,l){const h=cp(i,e);if(qa(e.whiteSpace))for(let F=0;F<h.length;F++){const X=h[F];h[F]={text:X.text.replace(yy," "),style:X.style}}const u=[];let d=[];for(const F of h){const X=F.text.split(yp);for(let
|
|
555
|
-
`||
|
|
556
|
-
`?(u.push(d),d=[]):
|
|
557
|
-
`)}const Bc={willReadFrequently:!0},Bt=class ${static get experimentalLetterSpacingSupported(){let e=$._experimentalLetterSpacingSupported;if(e===void 0){const t=te.get().getCanvasRenderingContext2D().prototype;e=$._experimentalLetterSpacingSupported="letterSpacing"in t||"textLetterSpacing"in t}return e}constructor(e,t,s,r,n,o,a,l,h,c){this.text=e,this.style=t,this.width=s,this.height=r,this.lines=n,this.lineWidths=o,this.lineHeight=a,this.maxLineWidth=l,this.fontProperties=h,c&&(this.runsByLine=c.runsByLine,this.lineAscents=c.lineAscents,this.lineDescents=c.lineDescents,this.lineHeights=c.lineHeights,this.hasDropShadow=c.hasDropShadow)}static measureText(e=" ",t,s=$._canvas,r=t.wordWrap){const n=`${e}-${t.styleKey}-wordWrap-${r}`;if($._measurementCache.has(n))return $._measurementCache.get(n);if(Va(t)&&ja(e)){const b=vp(e,t,r,$._context,$._measureText,$._measureTextAdvance,$.measureFont,$.canBreakChars,$.wordWrapSplit),v=new $(e,t,b.width,b.height,b.lines,b.lineWidths,b.lineHeight,b.maxLineWidth,b.fontProperties,{runsByLine:b.runsByLine,lineAscents:b.lineAscents,lineDescents:b.lineDescents,lineHeights:b.lineHeights,hasDropShadow:b.hasDropShadow});return $._measurementCache.set(n,v),v}const a=t._fontString,l=$.measureFont(a);l.fontSize===0&&(l.fontSize=t.fontSize,l.ascent=t.fontSize,l.descent=0);const h=$._context;h.font=a;const u=(r?$._wordWrap(e,t,s):e).split(xp),d=new Array(u.length);let f=0;for(let b=0;b<u.length;b++){const v=$._measureText(u[b],t.letterSpacing,h);d[b]=v,f=Math.max(f,v)}const p=t._stroke?.width??0,m=t.lineHeight||l.fontSize,g=$._adjustWidthForStyle(f,t),_=Math.max(m,l.fontSize+p)+(u.length-1)*(m+t.leading),y=$._adjustHeightForStyle(_,t),x=new $(e,t,g,y,u,d,m+t.leading,f,l);return $._measurementCache.set(n,x),x}static _adjustWidthForStyle(e,t){const s=t._stroke?.width||0;let r=e+s;return t.dropShadow&&(r+=t.dropShadow.distance),r}static _adjustHeightForStyle(e,t){let s=e;return t.dropShadow&&(s+=t.dropShadow.distance),s}static _measureText(e,t,s){const{metricWidth:r,metrics:n,letterSpacingVal:o}=$._measureTextCore(e,t,s),a=-(n.actualBoundingBoxLeft??0);let h=(n.actualBoundingBoxRight??0)-a;return n.width>0&&(h+=o),Math.max(r,h)}static _measureTextAdvance(e,t,s){return $._measureTextCore(e,t,s).metricWidth}static _measureTextCore(e,t,s){let r=!1;$.experimentalLetterSpacingSupported&&($.experimentalLetterSpacing?(s.letterSpacing=`${t}px`,s.textLetterSpacing=`${t}px`,r=!0):(s.letterSpacing="0px",s.textLetterSpacing="0px"));const n=s.measureText(e);let o=n.width,a=0;return o>0&&(r?a=-t:a=($.graphemeSegmenter(e).length-1)*t,o+=a),{metricWidth:o,metrics:n,letterSpacingVal:a}}static _wordWrap(e,t,s=$._canvas){return Sp(e,t,s,$._measureTextAdvance,$.canBreakWords,$.canBreakChars,$.wordWrapSplit)}static isBreakingSpace(e,t){return Ve(e)}static canBreakWords(e,t){return t}static canBreakChars(e,t,s,r,n){return!0}static wordWrapSplit(e){return $.graphemeSegmenter(e)}static measureFont(e){if($._fonts[e])return $._fonts[e];const t=$._context;t.font=e;const s=t.measureText($.METRICS_STRING+$.BASELINE_SYMBOL),r=s.actualBoundingBoxAscent??0,n=s.actualBoundingBoxDescent??0,o={ascent:r,descent:n,fontSize:r+n};return $._fonts[e]=o,o}static clearMetrics(e=""){e?delete $._fonts[e]:$._fonts={}}static get _canvas(){if(!$.__canvas){let e;try{const t=new OffscreenCanvas(0,0);if(t.getContext("2d",Bc)?.measureText)return $.__canvas=t,t;e=te.get().createCanvas()}catch{e=te.get().createCanvas()}e.width=e.height=10,$.__canvas=e}return $.__canvas}static get _context(){return $.__context||($.__context=$._canvas.getContext("2d",Bc)),$.__context}};Bt.METRICS_STRING="|ÉqÅ";Bt.BASELINE_SYMBOL="M";Bt.BASELINE_MULTIPLIER=1.4;Bt.HEIGHT_MULTIPLIER=2;Bt.graphemeSegmenter=(()=>{if(typeof Intl?.Segmenter=="function"){const i=new Intl.Segmenter;return e=>{const t=i.segment(e),s=[];let r=0;for(const n of t)s[r++]=n.segment;return s}}return i=>[...i]})();Bt.experimentalLetterSpacing=!1;Bt._fonts={};Bt._measurementCache=gy(1e3);let St=Bt;const by=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function pr(i){const e=typeof i.fontSize=="number"?`${i.fontSize}px`:i.fontSize;let t=i.fontFamily;Array.isArray(i.fontFamily)||(t=i.fontFamily.split(","));for(let s=t.length-1;s>=0;s--){let r=t[s].trim();!/([\"\'])[^\'\"]+\1/.test(r)&&!by.includes(r)&&(r=`"${r}"`),t[s]=r}return`${i.fontStyle} ${i.fontVariant} ${i.fontWeight} ${e} ${t.join(",")}`}const Ic=1e5;function si(i,e,t,s=0,r=0,n=0){if(i.texture===H.WHITE&&!i.fill)return le.shared.setValue(i.color).setAlpha(i.alpha??1).toHexa();if(i.fill){if(i.fill instanceof Us){const o=i.fill,a=e.createPattern(o.texture.source.resource,"repeat");return K.applyPatternTransform(a,o.transform,!1),a}else if(i.fill instanceof Xe){const o=i.fill,a=o.type==="linear",l=o.textureSpace==="local";let h=1,c=1;l&&t&&(h=t.width+s,c=t.height+s);let u,d=!1;if(a){const{start:f,end:p}=o;u=e.createLinearGradient(f.x*h+r,f.y*c+n,p.x*h+r,p.y*c+n),d=Math.abs(p.x-f.x)<Math.abs((p.y-f.y)*.1)}else{const{center:f,innerRadius:p,outerCenter:m,outerRadius:g}=o;u=e.createRadialGradient(f.x*h+r,f.y*c+n,p*h,m.x*h+r,m.y*c+n,g*h)}if(d&&l&&t){const f=t.lineHeight/c;for(let p=0;p<t.lines.length;p++){const m=(p*t.lineHeight+s/2)/c;o.colorStops.forEach(g=>{let _=m+g.offset*f;_=Math.max(0,Math.min(1,_)),u.addColorStop(Math.floor(_*Ic)/Ic,le.shared.setValue(g.color).toHex())})}}else o.colorStops.forEach(f=>{u.addColorStop(f.offset,le.shared.setValue(f.color).toHex())});return u}}else{const o=e.createPattern(i.texture.source.resource,"repeat"),a=i.matrix.copyTo(L.shared);return a.scale(i.texture.source.pixelWidth,i.texture.source.pixelHeight),o.setTransform(a),o}return z("FillStyle not recognised",i),"red"}const Gc=new se;function xs(i){let e=0;for(let t=0;t<i.length;t++)i.charCodeAt(t)===32&&e++;return e}class vy{getCanvasAndContext(e){const{text:t,style:s,resolution:r=1}=e,n=s._getFinalPadding(),o=St.measureText(t||" ",s),a=Math.ceil(Math.ceil(Math.max(1,o.width)+n*2)*r),l=Math.ceil(Math.ceil(Math.max(1,o.height)+n*2)*r),h=Rt.getOptimalCanvasAndContext(a,l);this._renderTextToCanvas(s,n,r,h,o);const c=s.trim?hp({canvas:h.canvas,width:a,height:l,resolution:1,output:Gc}):Gc.set(0,0,a,l);return{canvasAndContext:h,frame:c}}returnCanvasAndContext(e){Rt.returnCanvasAndContext(e)}_renderTextToCanvas(e,t,s,r,n){if(n.runsByLine&&n.runsByLine.length>0){this._renderTaggedTextToCanvas(n,e,t,s,r);return}const{canvas:o,context:a}=r,l=pr(e),h=n.lines,c=n.lineHeight,u=n.lineWidths,d=n.maxLineWidth,f=n.fontProperties,p=o.height;if(a.resetTransform(),a.scale(s,s),a.textBaseline=e.textBaseline,e._stroke?.width){const v=e._stroke;a.lineWidth=v.width,a.miterLimit=v.miterLimit,a.lineJoin=v.join,a.lineCap=v.cap}a.font=l;let m,g;const _=e.dropShadow?2:1,x=(e._stroke?.width??0)/2;let b=(c-f.fontSize)/2;c-f.fontSize<0&&(b=0);for(let v=0;v<_;++v){const w=e.dropShadow&&v===0,T=w?Math.ceil(Math.max(1,p)+t*2):0,E=T*s;if(w)this._setupDropShadow(a,e,s,E);else{const P=e._gradientBounds,A=e._gradientOffset;if(P){const k={width:P.width,height:P.height,lineHeight:P.height,lines:n.lines};this._setFillAndStrokeStyles(a,e,k,t,x,A?.x??0,A?.y??0)}else A?this._setFillAndStrokeStyles(a,e,n,t,x,A.x,A.y):this._setFillAndStrokeStyles(a,e,n,t,x);a.shadowColor="rgba(0,0,0,0)"}for(let P=0;P<h.length;P++){m=x,g=x+P*c+f.ascent+b,m+=this._getAlignmentOffset(u[P],d,e.align);let A=0;if(e.align==="justify"&&e.wordWrap&&P<h.length-1){const k=xs(h[P]);k>0&&(A=(d-u[P])/k)}e._stroke?.width&&this._drawLetterSpacing(h[P],e,r,m+t,g+t-T,!0,A),e._fill!==void 0&&this._drawLetterSpacing(h[P],e,r,m+t,g+t-T,!1,A)}}}_renderTaggedTextToCanvas(e,t,s,r,n){const{canvas:o,context:a}=n,{runsByLine:l,lineWidths:h,maxLineWidth:c,lineAscents:u,lineHeights:d,hasDropShadow:f}=e,p=o.height;a.resetTransform(),a.scale(r,r),a.textBaseline=t.textBaseline;const m=f?2:1;let g=t._stroke?.width??0;for(const x of l)for(const b of x){const v=b.style._stroke?.width??0;v>g&&(g=v)}const _=g/2,y=[];for(let x=0;x<l.length;x++){const b=l[x],v=[];for(const w of b){const T=pr(w.style);a.font=T,v.push({width:St._measureText(w.text,w.style.letterSpacing,a),font:T})}y.push(v)}for(let x=0;x<m;++x){const b=f&&x===0,v=b?Math.ceil(Math.max(1,p)+s*2):0,w=v*r;b||(a.shadowColor="rgba(0,0,0,0)");let T=_;for(let E=0;E<l.length;E++){const P=l[E],A=h[E],k=u[E],I=d[E],G=y[E];let F=_;F+=this._getAlignmentOffset(A,c,t.align);let X=0;if(t.align==="justify"&&t.wordWrap&&E<l.length-1){let B=0;for(const R of P)B+=xs(R.text);B>0&&(X=(c-A)/B)}const C=T+k;let M=F+s;for(let B=0;B<P.length;B++){const R=P[B],{width:O,font:U}=G[B];if(a.font=U,a.textBaseline=R.style.textBaseline,R.style._stroke?.width){const J=R.style._stroke;if(a.lineWidth=J.width,a.miterLimit=J.miterLimit,a.lineJoin=J.join,a.lineCap=J.cap,b)if(R.style.dropShadow)this._setupDropShadow(a,R.style,r,w);else{const ie=xs(R.text);M+=O+ie*X;continue}else{const ie=St.measureFont(U),V=R.style.lineHeight||ie.fontSize,Je={width:O,height:V,lineHeight:V,lines:[R.text]};a.strokeStyle=si(J,a,Je,s*2,M-s,T)}this._drawLetterSpacing(R.text,R.style,n,M,C+s-v,!0,X)}const q=xs(R.text);M+=O+q*X}M=F+s;for(let B=0;B<P.length;B++){const R=P[B],{width:O,font:U}=G[B];if(a.font=U,a.textBaseline=R.style.textBaseline,R.style._fill!==void 0){if(b)if(R.style.dropShadow)this._setupDropShadow(a,R.style,r,w);else{const J=xs(R.text);M+=O+J*X;continue}else{const J=St.measureFont(U),ie=R.style.lineHeight||J.fontSize,V={width:O,height:ie,lineHeight:ie,lines:[R.text]};a.fillStyle=si(R.style._fill,a,V,s*2,M-s,T)}this._drawLetterSpacing(R.text,R.style,n,M,C+s-v,!1,X)}const q=xs(R.text);M+=O+q*X}T+=I}}}_setFillAndStrokeStyles(e,t,s,r,n,o=0,a=0){if(e.fillStyle=t._fill?si(t._fill,e,s,r*2,o,a):null,t._stroke?.width){const l=n+r*2;e.strokeStyle=si(t._stroke,e,s,l,o,a)}}_setupDropShadow(e,t,s,r){e.fillStyle="black",e.strokeStyle="black";const n=t.dropShadow,o=n.color,a=n.alpha;e.shadowColor=le.shared.setValue(o).setAlpha(a).toRgbaString();const l=n.blur*s,h=n.distance*s;e.shadowBlur=l,e.shadowOffsetX=Math.cos(n.angle)*h,e.shadowOffsetY=Math.sin(n.angle)*h+r}_getAlignmentOffset(e,t,s){return s==="right"?t-e:s==="center"?(t-e)/2:0}_drawLetterSpacing(e,t,s,r,n,o=!1,a=0){const{context:l}=s,h=t.letterSpacing;let c=!1;if(St.experimentalLetterSpacingSupported&&(St.experimentalLetterSpacing?(l.letterSpacing=`${h}px`,l.textLetterSpacing=`${h}px`,c=!0):(l.letterSpacing="0px",l.textLetterSpacing="0px")),(h===0||c)&&a===0){o?l.strokeText(e,r,n):l.fillText(e,r,n);return}if(a!==0&&(h===0||c)){const m=e.split(" ");let g=r;const _=l.measureText(" ").width;for(let y=0;y<m.length;y++)o?l.strokeText(m[y],g,n):l.fillText(m[y],g,n),g+=l.measureText(m[y]).width+_+a;return}let u=r;const d=St.graphemeSegmenter(e);let f=l.measureText(e).width,p=0;for(let m=0;m<d.length;++m){const g=d[m];o?l.strokeText(g,u,n):l.fillText(g,u,n);let _="";for(let y=m+1;y<d.length;++y)_+=d[y];p=l.measureText(_).width,u+=f-p+h,g===" "&&(u+=a),f=p}}}const Jt=new vy,Za=class qt extends Re{constructor(e={}){super(),this.uid=oe("textStyle"),this._tick=0,this._cachedFontString=null,wy(e),e instanceof qt&&(e=e._toObject());const r={...qt.defaultTextStyle,...e};for(const n in r){const o=n;this[o]=r[n]}this._tagStyles=e.tagStyles??void 0,this.update(),this._tick=0}get align(){return this._align}set align(e){this._align!==e&&(this._align=e,this.update())}get breakWords(){return this._breakWords}set breakWords(e){this._breakWords!==e&&(this._breakWords=e,this.update())}get dropShadow(){return this._dropShadow}set dropShadow(e){this._dropShadow!==e&&(e!==null&&typeof e=="object"?this._dropShadow=this._createProxy({...qt.defaultDropShadow,...e}):this._dropShadow=e?this._createProxy({...qt.defaultDropShadow}):null,this.update())}get fontFamily(){return this._fontFamily}set fontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.update())}get fontSize(){return this._fontSize}set fontSize(e){this._fontSize!==e&&(typeof e=="string"?this._fontSize=parseInt(e,10):this._fontSize=e,this.update())}get fontStyle(){return this._fontStyle}set fontStyle(e){this._fontStyle!==e&&(this._fontStyle=e.toLowerCase(),this.update())}get fontVariant(){return this._fontVariant}set fontVariant(e){this._fontVariant!==e&&(this._fontVariant=e,this.update())}get fontWeight(){return this._fontWeight}set fontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.update())}get leading(){return this._leading}set leading(e){this._leading!==e&&(this._leading=e,this.update())}get letterSpacing(){return this._letterSpacing}set letterSpacing(e){this._letterSpacing!==e&&(this._letterSpacing=e,this.update())}get lineHeight(){return this._lineHeight}set lineHeight(e){this._lineHeight!==e&&(this._lineHeight=e,this.update())}get padding(){return this._padding}set padding(e){this._padding!==e&&(this._padding=e,this.update())}get filters(){return this._filters}set filters(e){this._filters!==e&&(this._filters=Object.freeze(e),this.update())}get trim(){return this._trim}set trim(e){this._trim!==e&&(this._trim=e,this.update())}get textBaseline(){return this._textBaseline}set textBaseline(e){this._textBaseline!==e&&(this._textBaseline=e,this.update())}get whiteSpace(){return this._whiteSpace}set whiteSpace(e){this._whiteSpace!==e&&(this._whiteSpace=e,this.update())}get wordWrap(){return this._wordWrap}set wordWrap(e){this._wordWrap!==e&&(this._wordWrap=e,this.update())}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(e){this._wordWrapWidth!==e&&(this._wordWrapWidth=e,this.update())}get fill(){return this._originalFill}set fill(e){e!==this._originalFill&&(this._originalFill=e,this._isFillStyle(e)&&(this._originalFill=this._createProxy({...Ye.defaultFillStyle,...e},()=>{this._fill=Ot({...this._originalFill},Ye.defaultFillStyle)})),this._fill=Ot(e===0?"black":e,Ye.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(e){e!==this._originalStroke&&(this._originalStroke=e,this._isFillStyle(e)&&(this._originalStroke=this._createProxy({...Ye.defaultStrokeStyle,...e},()=>{this._stroke=bi({...this._originalStroke},Ye.defaultStrokeStyle)})),this._stroke=bi(e,Ye.defaultStrokeStyle),this.update())}get tagStyles(){return this._tagStyles}set tagStyles(e){this._tagStyles!==e&&(this._tagStyles=e??void 0,this.update())}update(){this._tick++,this._cachedFontString=null,this.emit("update",this)}reset(){const e=qt.defaultTextStyle;for(const t in e)this[t]=e[t]}assign(e){for(const t in e){const s=t;this[s]=e[t]}return this}get styleKey(){return`${this.uid}-${this._tick}`}get _fontString(){return this._cachedFontString===null&&(this._cachedFontString=pr(this)),this._cachedFontString}_toObject(){return{align:this.align,breakWords:this.breakWords,dropShadow:this._dropShadow?{...this._dropShadow}:null,fill:this._fill?{...this._fill}:void 0,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,leading:this.leading,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke?{...this._stroke}:void 0,textBaseline:this.textBaseline,trim:this.trim,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth,filters:this._filters?[...this._filters]:void 0,tagStyles:this._tagStyles?{...this._tagStyles}:void 0}}clone(){return new qt(this._toObject())}_getFinalPadding(){let e=0;if(this._filters)for(let t=0;t<this._filters.length;t++)e+=this._filters[t].padding;return Math.max(this._padding,e)}destroy(e=!1){if(this.removeAllListeners(),typeof e=="boolean"?e:e?.texture){const s=typeof e=="boolean"?e:e?.textureSource;this._fill?.texture&&this._fill.texture.destroy(s),this._originalFill?.texture&&this._originalFill.texture.destroy(s),this._stroke?.texture&&this._stroke.texture.destroy(s),this._originalStroke?.texture&&this._originalStroke.texture.destroy(s)}this._fill=null,this._stroke=null,this.dropShadow=null,this._originalStroke=null,this._originalFill=null}_createProxy(e,t){return new Proxy(e,{set:(s,r,n)=>(s[r]===n||(s[r]=n,t?.(r,n),this.update()),!0)})}_isFillStyle(e){return(e??null)!==null&&!(le.isColorLike(e)||e instanceof Xe||e instanceof Us)}};Za.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5};Za.defaultTextStyle={align:"left",breakWords:!1,dropShadow:null,fill:"black",fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",leading:0,letterSpacing:0,lineHeight:0,padding:0,stroke:null,textBaseline:"alphabetic",trim:!1,whiteSpace:"pre",wordWrap:!1,wordWrapWidth:100};let Gs=Za;function wy(i){const e=i;if(typeof e.dropShadow=="boolean"&&e.dropShadow){const t=Gs.defaultDropShadow;i.dropShadow={alpha:e.dropShadowAlpha??t.alpha,angle:e.dropShadowAngle??t.angle,blur:e.dropShadowBlur??t.blur,color:e.dropShadowColor??t.color,distance:e.dropShadowDistance??t.distance}}if(e.strokeThickness!==void 0){N(de,"strokeThickness is now a part of stroke");const t=e.stroke;let s={};if(le.isColorLike(t))s.color=t;else if(t instanceof Xe||t instanceof Us)s.fill=t;else if(Object.hasOwnProperty.call(t,"color")||Object.hasOwnProperty.call(t,"fill"))s=t;else throw new Error("Invalid stroke value.");i.stroke={...s,width:e.strokeThickness}}if(Array.isArray(e.fillGradientStops)){if(N(de,"gradient fill is now a fill pattern: `new FillGradient(...)`"),!Array.isArray(e.fill)||e.fill.length===0)throw new Error("Invalid fill value. Expected an array of colors for gradient fill.");e.fill.length!==e.fillGradientStops.length&&z("The number of fill colors must match the number of fill gradient stops.");const t=new Xe({start:{x:0,y:0},end:{x:0,y:1},textureSpace:"local"}),s=e.fillGradientStops.slice(),r=e.fill.map(n=>le.shared.setValue(n).toNumber());s.forEach((n,o)=>{t.addColorStop(n,r[o])}),i.fill={fill:t}}}let Dc=!1;function Mp(i){if(Dc)return;const e=new Lt({scaleMode:i.scaleMode});i._resourceId!==e._resourceId&&(Dc=!0,z("Text textureStyle: only scaleMode is applied to a text texture, the other fields are ignored"))}function Cp(i,e){const{texture:t,bounds:s}=i,r=e._style._getFinalPadding();qo(s,e._anchor,t);const n=e._anchor._x*r*2,o=e._anchor._y*r*2;s.minX-=r-n,s.minY-=r-o,s.maxX-=r-n,s.maxY-=r-o}class Nr{constructor(){this.batcherName="default",this.topology="triangle-list",this.attributeSize=4,this.indexSize=6,this.packAsQuad=!0,this.roundPixels=0,this._attributeStart=0,this._batcher=null,this._batch=null}get blendMode(){return this.renderable.groupBlendMode}get color(){return this.renderable.groupColorAlpha}reset(){this.renderable=null,this.texture=null,this._batcher=null,this._batch=null,this.bounds=null}destroy(){this.reset()}}class kp extends Nr{}class Qa{constructor(e){this._renderer=e,e.runners.resolutionChange.add(this),e.runners.contextChange.add(this),this._managedTexts=new lt({renderer:e,type:"renderable",onUnload:this.onTextUnload.bind(this),name:"canvasText"})}resolutionChange(){for(const e in this._managedTexts.items){const t=this._managedTexts.items[e];t?._autoResolution&&t.onViewUpdate()}}contextChange(){for(const e in this._managedTexts.items)this._managedTexts.items[e]?.unload()}validateRenderable(e){const t=this._getGpuText(e),s=e.styleKey;return t.currentKey!==s?!0:e._didTextUpdate}addRenderable(e,t){const s=this._getGpuText(e);if(e._didTextUpdate||s.currentKey!==e.styleKey){const r=e._autoResolution?this._renderer.resolution:e.resolution;(s.currentKey!==e.styleKey||e._resolution!==r)&&this._updateGpuText(e),e._didTextUpdate=!1,Cp(s,e)}this._renderer.renderPipes.batch.addToBatch(s,t)}updateRenderable(e){const t=this._getGpuText(e);t._batcher.updateElement(t)}_updateGpuText(e){const t=this._getGpuText(e);t.texture&&this._renderer.canvasText.decreaseReferenceCount(t.currentKey),e._resolution=e._autoResolution?this._renderer.resolution:e.resolution,t.texture=this._renderer.canvasText.getManagedTexture(e),t.currentKey=e.styleKey}_getGpuText(e){return e._gpuData[this._renderer.uid]||this.initGpuText(e)}initGpuText(e){const t=new kp;return t.currentKey="--",t.renderable=e,t.transform=e.groupTransform,t.bounds={minX:0,maxX:1,minY:0,maxY:0},t.roundPixels=this._renderer._roundPixels|e._roundPixels,e._gpuData[this._renderer.uid]=t,this._managedTexts.add(e),t}onTextUnload(e){const t=e._gpuData[this._renderer.uid];if(!t)return;const{canvasText:s}=this._renderer;s.getReferenceCount(t.currentKey)>0?s.decreaseReferenceCount(t.currentKey):t.texture&&s.returnTexture(t.texture)}destroy(){this._managedTexts.destroy(),this._renderer=null}}Qa.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"text"};class Ja{constructor(e,t){this._activeTextures={},this._renderer=e,this._retainCanvasContext=t}getTexture(e,t,s,r){typeof e=="string"&&(N("8.0.0","CanvasTextSystem.getTexture: Use object TextOptions instead of separate arguments"),e={text:e,style:s,resolution:t}),e.style instanceof Gs||(e.style=new Gs(e.style)),typeof e.text!="string"&&(e.text=e.text.toString());const{text:n,style:o,textureStyle:a,autoGenerateMipmaps:l}=e,h=e.resolution??this._renderer.resolution,{frame:c,canvasAndContext:u}=Jt.getCanvasAndContext({text:n,style:o,resolution:h}),d=Ua(u.canvas,c.width,c.height,h,l,a?.scaleMode);if(o.trim&&(c.pad(o.padding),d.frame.copyFrom(c),d.frame.scale(1/h),d.updateUvs()),o.filters){const f=this._applyFilters(d,o.filters);return this.returnTexture(d),Jt.returnCanvasAndContext(u),f}return this._renderer.texture.initSource(d._source),this._retainCanvasContext||Jt.returnCanvasAndContext(u),d}returnTexture(e){const t=e.source,s=t.resource;if(this._retainCanvasContext&&s?.getContext){const r=s.getContext("2d");r&&Jt.returnCanvasAndContext({canvas:s,context:r})}t.resource=null,t.uploadMethodId="unknown",t.alphaMode="no-premultiply-alpha",Te.returnTexture(e)}renderTextToCanvas(){N("8.10.0","CanvasTextSystem.renderTextToCanvas: no longer supported, use CanvasTextSystem.getTexture instead")}getManagedTexture(e){e._resolution=e._autoResolution?this._renderer.resolution:e.resolution;const t=e.styleKey;if(this._activeTextures[t])return this._increaseReferenceCount(t),this._activeTextures[t].texture;const s=this.getTexture({text:e.text,style:e.style,resolution:e._resolution,textureStyle:e.textureStyle,autoGenerateMipmaps:e.autoGenerateMipmaps});return this._activeTextures[t]={texture:s,usageCount:1},s}decreaseReferenceCount(e){const t=this._activeTextures[e];t&&(t.usageCount--,t.usageCount===0&&(this.returnTexture(t.texture),this._activeTextures[e]=null))}getReferenceCount(e){return this._activeTextures[e]?.usageCount??0}_increaseReferenceCount(e){this._activeTextures[e].usageCount++}_applyFilters(e,t){const s=this._renderer.renderTarget.renderTarget,r=this._renderer.filter.generateFilteredTexture({texture:e,filters:t});return this._renderer.renderTarget.bind({target:s,clear:!1}),r}destroy(){this._renderer=null;for(const e in this._activeTextures)this._activeTextures[e]&&this.returnTexture(this._activeTextures[e].texture);this._activeTextures=null}}class el extends Ja{constructor(e){super(e,!0)}}el.extension={type:[S.CanvasSystem],name:"canvasText"};class tl extends Ja{constructor(e){super(e,!1)}}tl.extension={type:[S.WebGLSystem,S.WebGPUSystem],name:"canvasText"};Y.add(el);Y.add(tl);Y.add(Qa);class Ep extends ap{constructor(...e){const t=lp(e,"Text");super(t,Gs),this.renderPipeId="text",t.textureStyle&&(this.textureStyle=t.textureStyle instanceof Lt?t.textureStyle:new Lt(t.textureStyle),Mp(this.textureStyle)),this.autoGenerateMipmaps=t.autoGenerateMipmaps??ue.defaultOptions.autoGenerateMipmaps}updateBounds(){const e=this._bounds,t=this._anchor;let s=0,r=0;if(this._style.trim){const{frame:n,canvasAndContext:o}=Jt.getCanvasAndContext({text:this.text,style:this._style,resolution:1});Jt.returnCanvasAndContext(o),s=n.width,r=n.height}else{const n=St.measureText(this._text,this._style);s=n.width,r=n.height}e.minX=-t._x*s,e.maxX=e.minX+s,e.minY=-t._y*r,e.maxY=e.minY+r}}function Pp(){const{userAgent:i}=te.get().getNavigator();return/^((?!chrome|android).)*safari/i.test(i)}const sl=class Yt{static _getPatternRepeat(e,t){const s=e&&e!=="clamp-to-edge",r=t&&t!=="clamp-to-edge";return s&&r?"repeat":s?"repeat-x":r?"repeat-y":"no-repeat"}start(e,t,s){}execute(e,t){const s=t.elements;if(!s||!s.length)return;const r=e.renderer,n=r.canvasContext,o=n.activeContext;for(let a=0;a<s.length;a++){const l=s[a];if(!l.packAsQuad)continue;const h=l,c=h.texture,u=c?K.getCanvasSource(c):null;if(!u)continue;const d=c.source.style,f=n.smoothProperty,p=d.scaleMode!=="nearest";o[f]!==p&&(o[f]=p),n.setBlendMode(t.blendMode);const m=r.globalUniforms.globalUniformData?.worldColor??4294967295,g=h.color,_=(m>>>24&255)/255,y=(g>>>24&255)/255,x=r.filter?.alphaMultiplier??1,b=_*y*x;if(b<=0)continue;o.globalAlpha=b;const v=m&16777215,w=g&16777215,T=ss(ts(w,v)),E=c.frame,P=d.addressModeU??d.addressMode,A=d.addressModeV??d.addressMode,k=Yt._getPatternRepeat(P,A),I=c.source._resolution??c.source.resolution??1,G=h.renderable?.renderGroup?.isCachedAsTexture,F=E.x*I,X=E.y*I,C=E.width*I,M=E.height*I,B=h.bounds,R=r.renderTarget.renderTarget.isRoot,O=B.minX,U=B.minY,q=B.maxX-B.minX,J=B.maxY-B.minY,ie=c.rotate,V=c.uvs,Je=Math.min(V.x0,V.x1,V.x2,V.x3,V.y0,V.y1,V.y2,V.y3),Ei=Math.max(V.x0,V.x1,V.x2,V.x3,V.y0,V.y1,V.y2,V.y3),Ns=k!=="no-repeat"&&(Je<0||Ei>1),xt=ie&&!(!Ns&&(T!==16777215||ie));xt?(Yt._tempPatternMatrix.copyFrom(h.transform),Q.matrixAppendRotationInv(Yt._tempPatternMatrix,ie,O,U,q,J),n.setContextTransform(Yt._tempPatternMatrix,h.roundPixels===1,void 0,G&&R)):n.setContextTransform(h.transform,h.roundPixels===1,void 0,G&&R);const Nt=q,et=J;let Oe=xt?0:O,Le=xt?0:U;if(!xt&&h.roundPixels===1&&(Oe|=0,Le|=0),Ns){let tt=u;const Gt=T!==16777215&&!ie,bt=E.width<=c.source.width&&E.height<=c.source.height;Gt&&bt&&(tt=K.getTintedCanvas({texture:c},T));const Hs=o.createPattern(tt,k);if(!Hs)continue;const rn=Nt,ph=et;if(rn===0||ph===0)continue;const mh=1/rn,gh=1/ph,_h=(V.x1-V.x0)*mh,yh=(V.y1-V.y0)*mh,xh=(V.x3-V.x0)*gh,bh=(V.y3-V.y0)*gh,Ng=V.x0-_h*Oe-xh*Le,zg=V.y0-yh*Oe-bh*Le,nn=c.source.pixelWidth,on=c.source.pixelHeight;Yt._tempPatternMatrix.set(_h*nn,yh*on,xh*nn,bh*on,Ng*nn,zg*on),K.applyPatternTransform(Hs,Yt._tempPatternMatrix),o.fillStyle=Hs,o.fillRect(Oe,Le,Nt,et)}else{const Gt=T!==16777215||ie?K.getTintedCanvas({texture:c},T):u,bt=Gt!==u;o.drawImage(Gt,bt?0:F,bt?0:X,bt?Gt.width:C,bt?Gt.height:M,Oe,Le,Nt,et)}}}};sl._tempPatternMatrix=new L;sl.extension={type:[S.CanvasPipesAdaptor],name:"batch"};let Ap=sl;class il{constructor(){this._tempState=yt.for2d(),this._didUploadHash={}}init(e){e.renderer.runners.contextChange.add(this)}contextChange(){this._didUploadHash={}}start(e,t,s){const r=e.renderer,n=this._didUploadHash[s.uid];r.shader.bind(s,n),n||(this._didUploadHash[s.uid]=!0),r.shader.updateUniformGroup(r.globalUniforms.uniformGroup),r.geometry.bind(t,s.glProgram)}execute(e,t){const s=e.renderer;this._tempState.blendMode=t.blendMode,s.state.set(this._tempState);const r=t.textures.textures;for(let n=0;n<t.textures.count;n++)s.texture.bind(r[n],n);s.texture.unbindIntegerTextures(t.textures.count),s.geometry.draw(t.topology,t.size,t.start)}}il.extension={type:[S.WebGLPipesAdaptor],name:"batch"};const $i=yt.for2d();class rl{start(e,t,s){const r=e.renderer,n=r.encoder,o=s.gpuProgram;this._shader=s,this._geometry=t,n.setGeometry(t,o),$i.blendMode="normal",r.pipeline.getPipeline(t,o,$i,void 0,s._overrides);const a=r.globalUniforms.bindGroup;n.resetBindGroup(1),n.setBindGroup(0,a,o)}execute(e,t){const s=this._shader.gpuProgram,r=e.renderer,n=r.encoder;if(!t.bindGroup){const l=t.textures;t.bindGroup=Rr(l.textures,l.count,r.limits.maxBatchableTextures)}$i.blendMode=t.blendMode;const o=r.bindGroup.getBindGroup(t.bindGroup,s,1),a=r.pipeline.getPipeline(this._geometry,s,$i,t.topology,this._shader._overrides);t.bindGroup._touch(r.gc.now),n.setPipeline(a),n.renderPassEncoder.setBindGroup(1,o),n.renderPassEncoder.drawIndexed(t.size,1,t.start)}}rl.extension={type:[S.WebGPUPipesAdaptor],name:"batch"};const nl=class Rp{constructor(e,t){this.state=yt.for2d(),this._batchersByInstructionSet=Object.create(null),this._activeBatches=Object.create(null),this.renderer=e,this._adaptor=t,this._adaptor.init?.(this)}static getBatcher(e,t){return new this._availableBatchers[e]({maxTextures:t})}buildStart(e){let t=this._batchersByInstructionSet[e.uid];t||(t=this._batchersByInstructionSet[e.uid]=Object.create(null),t.default||(t.default=new Fr({maxTextures:this.renderer.limits.maxBatchableTextures}))),this._activeBatches=t,this._activeBatch=this._activeBatches.default;for(const s in this._activeBatches)this._activeBatches[s].begin()}addToBatch(e,t){if(this._activeBatch.name!==e.batcherName){this._activeBatch.break(t);let s=this._activeBatches[e.batcherName];s||(s=this._activeBatches[e.batcherName]=Rp.getBatcher(e.batcherName,this.renderer.limits.maxBatchableTextures),s.begin()),this._activeBatch=s}this._activeBatch.add(e)}break(e){this._activeBatch.break(e)}buildEnd(e){this._activeBatch.break(e);const t=this._activeBatches;for(const s in t){const r=t[s],n=r.geometry;n.indexBuffer.setDataWithSize(r.indexBuffer,r.indexSize,!0),n.buffers[0].setDataWithSize(r.attributeBuffer.float32View,r.attributeSize,!1)}}upload(e){const t=this._batchersByInstructionSet[e.uid];for(const s in t){const r=t[s],n=r.geometry;r.dirty&&(r.dirty=!1,n.buffers[0].update(r.attributeSize*4))}}execute(e){if(e.action==="startBatch"){const t=e.batcher,s=t.geometry,r=t.shader;this._adaptor.start(this,s,r)}this._adaptor.execute(this,e)}destroyInstructionSet(e){const t=this._batchersByInstructionSet[e.uid];if(t){for(const s in t)t[s].destroy();delete this._batchersByInstructionSet[e.uid],this._activeBatches===t&&(this._activeBatches=Object.create(null),this._activeBatch=null)}}destroy(){this.state=null,this.renderer=null,this._adaptor=null;for(const e in this._activeBatches)this._activeBatches[e].destroy();this._activeBatches=null}};nl.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"batch"};nl._availableBatchers=Object.create(null);let zr=nl;Y.handleByMap(S.Batcher,zr._availableBatchers);Y.add(Fr);const Bp={name:"texture-bit",vertex:{header:`
|
|
554
|
+
`),s++):e.push(r);continue}t.push(r),bp(r)&&n&&!Ve(n)&&!wi(n)&&(e.push(t.join("")),t.length=0)}return t.length>0&&e.push(t.join("")),e}function Ka(i,e,t,s){const r=t(i),n=[];for(let o=0;o<r.length;o++){let a=r[o],l=a,h=1;for(;r[o+h];){const c=r[o+h];if(!s(l,c,i,o,e))a+=c,l=c,h++;else break}o+=h-1,n.push(a)}return n}const yy=/\r\n|\r|\n/g;function vp(i,e,t,s,r,n,o,a,l){const h=cp(i,e);if(qa(e.whiteSpace))for(let F=0;F<h.length;F++){const X=h[F];h[F]={text:X.text.replace(yy," "),style:X.style}}const u=[];let d=[];for(const F of h){const X=F.text.split(yp);for(let M=0;M<X.length;M++){const C=X[M];C===`\r
|
|
555
|
+
`||C==="\r"||C===`
|
|
556
|
+
`?(u.push(d),d=[]):C.length>0&&d.push({text:C,style:F.style})}}(d.length>0||u.length===0)&&u.push(d);const f=t?wp(u,e,s,n,a,l):u,p=[],m=[],g=[],_=[],y=[];let x=0;const b=e._fontString,v=o(b);v.fontSize===0&&(v.fontSize=e.fontSize,v.ascent=e.fontSize);let w="",T=!!e.dropShadow,E=e._stroke?.width||0;for(const F of f){let X=0,M=v.ascent,C=v.descent,B="";for(const O of F){const U=O.style._fontString,q=o(U);U!==w&&(s.font=U,w=U);const J=r(O.text,O.style.letterSpacing,s);X+=J,M=Math.max(M,q.ascent),C=Math.max(C,q.descent),B+=O.text;const ie=O.style._stroke?.width||0;ie>E&&(E=ie),!T&&O.style.dropShadow&&(T=!0)}F.length===0&&(M=v.ascent,C=v.descent),p.push(X),m.push(M),g.push(C),y.push(B);const R=e.lineHeight||M+C;_.push(R+e.leading),x=Math.max(x,X)}const P=E,A=x+P+(e.dropShadow?e.dropShadow.distance:0);let k=0;for(let F=0;F<_.length;F++)k+=_[F];k=Math.max(k,_[0]+P);const I=k+(e.dropShadow?e.dropShadow.distance:0),G=e.lineHeight||v.fontSize;return{width:A,height:I,lines:y,lineWidths:p,lineHeight:G+e.leading,maxLineWidth:x,fontProperties:v,runsByLine:f,lineAscents:m,lineDescents:g,lineHeights:_,hasDropShadow:T}}function wp(i,e,t,s,r,n){const{letterSpacing:o,whiteSpace:a,wordWrapWidth:l,breakWords:h}=e,c=Xa(a),u=l+o,d={};let f="";const p=(g,_)=>{const y=`${g}|${_.styleKey}`;let x=d[y];if(x===void 0){const b=_._fontString;b!==f&&(t.font=b,f=b),x=s(g,_.letterSpacing,t)+_.letterSpacing,d[y]=x}return x},m=[];for(const g of i){const _=Tp(g),y=m.length,x=k=>{let I=0,G=k;do{const{token:F,style:X}=_[G];I+=p(F,X),G++}while(G<_.length&&_[G].continuesFromPrevious);return I},b=k=>{const I=[];let G=k;do I.push({token:_[G].token,style:_[G].style}),G++;while(G<_.length&&_[G].continuesFromPrevious);return I};let v=[],w=0,T=!c,E=null;const P=()=>{E&&E.text.length>0&&v.push(E),E=null},A=()=>{if(P(),v.length>0){const k=v[v.length-1];k.text=ut(k.text),k.text.length===0&&v.pop()}m.push(v),v=[],w=0,T=!1};for(let k=0;k<_.length;k++){const{token:I,style:G,continuesFromPrevious:F}=_[k],X=p(I,G);if(c){const B=Ve(I),R=E?.text[E.text.length-1]??v[v.length-1]?.text.slice(-1)??"",O=R?Ve(R):!1;if(B&&O)continue}const M=!F,C=M?x(k):X;if(C>u&&M)if(w>0&&A(),h){const B=b(k);for(let R=0;R<B.length;R++){const O=B[R].token,U=B[R].style,q=Ka(O,h,n,r);for(const J of q){const ie=p(J,U);ie+w>u&&A(),!E||E.style!==U?(P(),E={text:J,style:U}):E.text+=J,w+=ie}}k+=B.length-1}else{const B=b(k);P(),m.push(B.map(R=>({text:R.token,style:R.style}))),T=!1,k+=B.length-1}else if(C+w>u&&M){if(Ve(I)){T=!1;continue}A(),E={text:I,style:G},w=X}else if(F&&!h)!E||E.style!==G?(P(),E={text:I,style:G}):E.text+=I,w+=X;else{const B=Ve(I);if(w===0&&B&&!T)continue;!E||E.style!==G?(P(),E={text:I,style:G}):E.text+=I,w+=X}}if(P(),v.length>0){const k=v[v.length-1];k.text=ut(k.text),k.text.length===0&&v.pop()}(v.length>0||m.length===y)&&m.push(v)}return m}function Tp(i){const e=[];let t=!1;for(const s of i){const r=Ya(s.text);let n=!0;for(const o of r){const a=Ve(o)||wi(o),l=n&&t&&!a;e.push({token:o,style:s.style,continuesFromPrevious:l}),t=!a,n=!1}}return e}const xy={willReadFrequently:!0};function Rc(i,e,t,s,r){let n=t[i];return typeof n!="number"&&(n=r(i,e,s)+e,t[i]=n),n}function Sp(i,e,t,s,r,n,o){const a=t.getContext("2d",xy);a.font=e._fontString;let l=0,h="";const c=[],u=Object.create(null),{letterSpacing:d,whiteSpace:f}=e,p=Xa(f),m=qa(f);let g=!p;const _=e.wordWrapWidth+d,y=Ya(i);for(let b=0;b<y.length;b++){let v=y[b];if(wi(v)){if(!m){c.push(ut(h)),g=!p,h="",l=0;continue}v=" "}if(p){const T=Ve(v),E=Ve(h[h.length-1]);if(T&&E)continue}const w=Rc(v,d,u,a,s);if(w>_)if(h!==""&&(c.push(ut(h)),h="",l=0),r(v,e.breakWords)){const T=Ka(v,e.breakWords,o,n);for(const E of T){const P=Rc(E,d,u,a,s);P+l>_&&(c.push(ut(h)),g=!1,h="",l=0),h+=E,l+=P}}else h.length>0&&(c.push(ut(h)),h="",l=0),c.push(ut(v)),g=!1,h="",l=0;else w+l>_&&(g=!1,c.push(ut(h)),h="",l=0),(h.length>0||!Ve(v)||g)&&(h+=v,l+=w)}const x=ut(h);return x.length>0&&c.push(x),c.join(`
|
|
557
|
+
`)}const Bc={willReadFrequently:!0},Bt=class ${static get experimentalLetterSpacingSupported(){let e=$._experimentalLetterSpacingSupported;if(e===void 0){const t=te.get().getCanvasRenderingContext2D().prototype;e=$._experimentalLetterSpacingSupported="letterSpacing"in t||"textLetterSpacing"in t}return e}constructor(e,t,s,r,n,o,a,l,h,c){this.text=e,this.style=t,this.width=s,this.height=r,this.lines=n,this.lineWidths=o,this.lineHeight=a,this.maxLineWidth=l,this.fontProperties=h,c&&(this.runsByLine=c.runsByLine,this.lineAscents=c.lineAscents,this.lineDescents=c.lineDescents,this.lineHeights=c.lineHeights,this.hasDropShadow=c.hasDropShadow)}static measureText(e=" ",t,s=$._canvas,r=t.wordWrap){const n=`${e}-${t.styleKey}-wordWrap-${r}`;if($._measurementCache.has(n))return $._measurementCache.get(n);if(Va(t)&&ja(e)){const b=vp(e,t,r,$._context,$._measureText,$._measureTextAdvance,$.measureFont,$.canBreakChars,$.wordWrapSplit),v=new $(e,t,b.width,b.height,b.lines,b.lineWidths,b.lineHeight,b.maxLineWidth,b.fontProperties,{runsByLine:b.runsByLine,lineAscents:b.lineAscents,lineDescents:b.lineDescents,lineHeights:b.lineHeights,hasDropShadow:b.hasDropShadow});return $._measurementCache.set(n,v),v}const a=t._fontString,l=$.measureFont(a);l.fontSize===0&&(l.fontSize=t.fontSize,l.ascent=t.fontSize,l.descent=0);const h=$._context;h.font=a;const u=(r?$._wordWrap(e,t,s):e).split(xp),d=new Array(u.length);let f=0;for(let b=0;b<u.length;b++){const v=$._measureText(u[b],t.letterSpacing,h);d[b]=v,f=Math.max(f,v)}const p=t._stroke?.width??0,m=t.lineHeight||l.fontSize,g=$._adjustWidthForStyle(f,t),_=Math.max(m,l.fontSize+p)+(u.length-1)*(m+t.leading),y=$._adjustHeightForStyle(_,t),x=new $(e,t,g,y,u,d,m+t.leading,f,l);return $._measurementCache.set(n,x),x}static _adjustWidthForStyle(e,t){const s=t._stroke?.width||0;let r=e+s;return t.dropShadow&&(r+=t.dropShadow.distance),r}static _adjustHeightForStyle(e,t){let s=e;return t.dropShadow&&(s+=t.dropShadow.distance),s}static _measureText(e,t,s){const{metricWidth:r,metrics:n,letterSpacingVal:o}=$._measureTextCore(e,t,s),a=-(n.actualBoundingBoxLeft??0);let h=(n.actualBoundingBoxRight??0)-a;return n.width>0&&(h+=o),Math.max(r,h)}static _measureTextAdvance(e,t,s){return $._measureTextCore(e,t,s).metricWidth}static _measureTextCore(e,t,s){let r=!1;$.experimentalLetterSpacingSupported&&($.experimentalLetterSpacing?(s.letterSpacing=`${t}px`,s.textLetterSpacing=`${t}px`,r=!0):(s.letterSpacing="0px",s.textLetterSpacing="0px"));const n=s.measureText(e);let o=n.width,a=0;return o>0&&(r?a=-t:a=($.graphemeSegmenter(e).length-1)*t,o+=a),{metricWidth:o,metrics:n,letterSpacingVal:a}}static _wordWrap(e,t,s=$._canvas){return Sp(e,t,s,$._measureTextAdvance,$.canBreakWords,$.canBreakChars,$.wordWrapSplit)}static isBreakingSpace(e,t){return Ve(e)}static canBreakWords(e,t){return t}static canBreakChars(e,t,s,r,n){return!0}static wordWrapSplit(e){return $.graphemeSegmenter(e)}static measureFont(e){if($._fonts[e])return $._fonts[e];const t=$._context;t.font=e;const s=t.measureText($.METRICS_STRING+$.BASELINE_SYMBOL),r=s.actualBoundingBoxAscent??0,n=s.actualBoundingBoxDescent??0,o={ascent:r,descent:n,fontSize:r+n};return $._fonts[e]=o,o}static clearMetrics(e=""){e?delete $._fonts[e]:$._fonts={}}static get _canvas(){if(!$.__canvas){let e;try{const t=new OffscreenCanvas(0,0);if(t.getContext("2d",Bc)?.measureText)return $.__canvas=t,t;e=te.get().createCanvas()}catch{e=te.get().createCanvas()}e.width=e.height=10,$.__canvas=e}return $.__canvas}static get _context(){return $.__context||($.__context=$._canvas.getContext("2d",Bc)),$.__context}};Bt.METRICS_STRING="|ÉqÅ";Bt.BASELINE_SYMBOL="M";Bt.BASELINE_MULTIPLIER=1.4;Bt.HEIGHT_MULTIPLIER=2;Bt.graphemeSegmenter=(()=>{if(typeof Intl?.Segmenter=="function"){const i=new Intl.Segmenter;return e=>{const t=i.segment(e),s=[];let r=0;for(const n of t)s[r++]=n.segment;return s}}return i=>[...i]})();Bt.experimentalLetterSpacing=!1;Bt._fonts={};Bt._measurementCache=gy(1e3);let St=Bt;const by=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function pr(i){const e=typeof i.fontSize=="number"?`${i.fontSize}px`:i.fontSize;let t=i.fontFamily;Array.isArray(i.fontFamily)||(t=i.fontFamily.split(","));for(let s=t.length-1;s>=0;s--){let r=t[s].trim();!/([\"\'])[^\'\"]+\1/.test(r)&&!by.includes(r)&&(r=`"${r}"`),t[s]=r}return`${i.fontStyle} ${i.fontVariant} ${i.fontWeight} ${e} ${t.join(",")}`}const Ic=1e5;function si(i,e,t,s=0,r=0,n=0){if(i.texture===H.WHITE&&!i.fill)return le.shared.setValue(i.color).setAlpha(i.alpha??1).toHexa();if(i.fill){if(i.fill instanceof Us){const o=i.fill,a=e.createPattern(o.texture.source.resource,"repeat");return K.applyPatternTransform(a,o.transform,!1),a}else if(i.fill instanceof Xe){const o=i.fill,a=o.type==="linear",l=o.textureSpace==="local";let h=1,c=1;l&&t&&(h=t.width+s,c=t.height+s);let u,d=!1;if(a){const{start:f,end:p}=o;u=e.createLinearGradient(f.x*h+r,f.y*c+n,p.x*h+r,p.y*c+n),d=Math.abs(p.x-f.x)<Math.abs((p.y-f.y)*.1)}else{const{center:f,innerRadius:p,outerCenter:m,outerRadius:g}=o;u=e.createRadialGradient(f.x*h+r,f.y*c+n,p*h,m.x*h+r,m.y*c+n,g*h)}if(d&&l&&t){const f=t.lineHeight/c;for(let p=0;p<t.lines.length;p++){const m=(p*t.lineHeight+s/2)/c;o.colorStops.forEach(g=>{let _=m+g.offset*f;_=Math.max(0,Math.min(1,_)),u.addColorStop(Math.floor(_*Ic)/Ic,le.shared.setValue(g.color).toHex())})}}else o.colorStops.forEach(f=>{u.addColorStop(f.offset,le.shared.setValue(f.color).toHex())});return u}}else{const o=e.createPattern(i.texture.source.resource,"repeat"),a=i.matrix.copyTo(L.shared);return a.scale(i.texture.source.pixelWidth,i.texture.source.pixelHeight),o.setTransform(a),o}return z("FillStyle not recognised",i),"red"}const Gc=new se;function xs(i){let e=0;for(let t=0;t<i.length;t++)i.charCodeAt(t)===32&&e++;return e}class vy{getCanvasAndContext(e){const{text:t,style:s,resolution:r=1}=e,n=s._getFinalPadding(),o=St.measureText(t||" ",s),a=Math.ceil(Math.ceil(Math.max(1,o.width)+n*2)*r),l=Math.ceil(Math.ceil(Math.max(1,o.height)+n*2)*r),h=Rt.getOptimalCanvasAndContext(a,l);this._renderTextToCanvas(s,n,r,h,o);const c=s.trim?hp({canvas:h.canvas,width:a,height:l,resolution:1,output:Gc}):Gc.set(0,0,a,l);return{canvasAndContext:h,frame:c}}returnCanvasAndContext(e){Rt.returnCanvasAndContext(e)}_renderTextToCanvas(e,t,s,r,n){if(n.runsByLine&&n.runsByLine.length>0){this._renderTaggedTextToCanvas(n,e,t,s,r);return}const{canvas:o,context:a}=r,l=pr(e),h=n.lines,c=n.lineHeight,u=n.lineWidths,d=n.maxLineWidth,f=n.fontProperties,p=o.height;if(a.resetTransform(),a.scale(s,s),a.textBaseline=e.textBaseline,e._stroke?.width){const v=e._stroke;a.lineWidth=v.width,a.miterLimit=v.miterLimit,a.lineJoin=v.join,a.lineCap=v.cap}a.font=l;let m,g;const _=e.dropShadow?2:1,x=(e._stroke?.width??0)/2;let b=(c-f.fontSize)/2;c-f.fontSize<0&&(b=0);for(let v=0;v<_;++v){const w=e.dropShadow&&v===0,T=w?Math.ceil(Math.max(1,p)+t*2):0,E=T*s;if(w)this._setupDropShadow(a,e,s,E);else{const P=e._gradientBounds,A=e._gradientOffset;if(P){const k={width:P.width,height:P.height,lineHeight:P.height,lines:n.lines};this._setFillAndStrokeStyles(a,e,k,t,x,A?.x??0,A?.y??0)}else A?this._setFillAndStrokeStyles(a,e,n,t,x,A.x,A.y):this._setFillAndStrokeStyles(a,e,n,t,x);a.shadowColor="rgba(0,0,0,0)"}for(let P=0;P<h.length;P++){m=x,g=x+P*c+f.ascent+b,m+=this._getAlignmentOffset(u[P],d,e.align);let A=0;if(e.align==="justify"&&e.wordWrap&&P<h.length-1){const k=xs(h[P]);k>0&&(A=(d-u[P])/k)}e._stroke?.width&&this._drawLetterSpacing(h[P],e,r,m+t,g+t-T,!0,A),e._fill!==void 0&&this._drawLetterSpacing(h[P],e,r,m+t,g+t-T,!1,A)}}}_renderTaggedTextToCanvas(e,t,s,r,n){const{canvas:o,context:a}=n,{runsByLine:l,lineWidths:h,maxLineWidth:c,lineAscents:u,lineHeights:d,hasDropShadow:f}=e,p=o.height;a.resetTransform(),a.scale(r,r),a.textBaseline=t.textBaseline;const m=f?2:1;let g=t._stroke?.width??0;for(const x of l)for(const b of x){const v=b.style._stroke?.width??0;v>g&&(g=v)}const _=g/2,y=[];for(let x=0;x<l.length;x++){const b=l[x],v=[];for(const w of b){const T=pr(w.style);a.font=T,v.push({width:St._measureText(w.text,w.style.letterSpacing,a),font:T})}y.push(v)}for(let x=0;x<m;++x){const b=f&&x===0,v=b?Math.ceil(Math.max(1,p)+s*2):0,w=v*r;b||(a.shadowColor="rgba(0,0,0,0)");let T=_;for(let E=0;E<l.length;E++){const P=l[E],A=h[E],k=u[E],I=d[E],G=y[E];let F=_;F+=this._getAlignmentOffset(A,c,t.align);let X=0;if(t.align==="justify"&&t.wordWrap&&E<l.length-1){let B=0;for(const R of P)B+=xs(R.text);B>0&&(X=(c-A)/B)}const M=T+k;let C=F+s;for(let B=0;B<P.length;B++){const R=P[B],{width:O,font:U}=G[B];if(a.font=U,a.textBaseline=R.style.textBaseline,R.style._stroke?.width){const J=R.style._stroke;if(a.lineWidth=J.width,a.miterLimit=J.miterLimit,a.lineJoin=J.join,a.lineCap=J.cap,b)if(R.style.dropShadow)this._setupDropShadow(a,R.style,r,w);else{const ie=xs(R.text);C+=O+ie*X;continue}else{const ie=St.measureFont(U),V=R.style.lineHeight||ie.fontSize,Je={width:O,height:V,lineHeight:V,lines:[R.text]};a.strokeStyle=si(J,a,Je,s*2,C-s,T)}this._drawLetterSpacing(R.text,R.style,n,C,M+s-v,!0,X)}const q=xs(R.text);C+=O+q*X}C=F+s;for(let B=0;B<P.length;B++){const R=P[B],{width:O,font:U}=G[B];if(a.font=U,a.textBaseline=R.style.textBaseline,R.style._fill!==void 0){if(b)if(R.style.dropShadow)this._setupDropShadow(a,R.style,r,w);else{const J=xs(R.text);C+=O+J*X;continue}else{const J=St.measureFont(U),ie=R.style.lineHeight||J.fontSize,V={width:O,height:ie,lineHeight:ie,lines:[R.text]};a.fillStyle=si(R.style._fill,a,V,s*2,C-s,T)}this._drawLetterSpacing(R.text,R.style,n,C,M+s-v,!1,X)}const q=xs(R.text);C+=O+q*X}T+=I}}}_setFillAndStrokeStyles(e,t,s,r,n,o=0,a=0){if(e.fillStyle=t._fill?si(t._fill,e,s,r*2,o,a):null,t._stroke?.width){const l=n+r*2;e.strokeStyle=si(t._stroke,e,s,l,o,a)}}_setupDropShadow(e,t,s,r){e.fillStyle="black",e.strokeStyle="black";const n=t.dropShadow,o=n.color,a=n.alpha;e.shadowColor=le.shared.setValue(o).setAlpha(a).toRgbaString();const l=n.blur*s,h=n.distance*s;e.shadowBlur=l,e.shadowOffsetX=Math.cos(n.angle)*h,e.shadowOffsetY=Math.sin(n.angle)*h+r}_getAlignmentOffset(e,t,s){return s==="right"?t-e:s==="center"?(t-e)/2:0}_drawLetterSpacing(e,t,s,r,n,o=!1,a=0){const{context:l}=s,h=t.letterSpacing;let c=!1;if(St.experimentalLetterSpacingSupported&&(St.experimentalLetterSpacing?(l.letterSpacing=`${h}px`,l.textLetterSpacing=`${h}px`,c=!0):(l.letterSpacing="0px",l.textLetterSpacing="0px")),(h===0||c)&&a===0){o?l.strokeText(e,r,n):l.fillText(e,r,n);return}if(a!==0&&(h===0||c)){const m=e.split(" ");let g=r;const _=l.measureText(" ").width;for(let y=0;y<m.length;y++)o?l.strokeText(m[y],g,n):l.fillText(m[y],g,n),g+=l.measureText(m[y]).width+_+a;return}let u=r;const d=St.graphemeSegmenter(e);let f=l.measureText(e).width,p=0;for(let m=0;m<d.length;++m){const g=d[m];o?l.strokeText(g,u,n):l.fillText(g,u,n);let _="";for(let y=m+1;y<d.length;++y)_+=d[y];p=l.measureText(_).width,u+=f-p+h,g===" "&&(u+=a),f=p}}}const Jt=new vy,Za=class qt extends Re{constructor(e={}){super(),this.uid=oe("textStyle"),this._tick=0,this._cachedFontString=null,wy(e),e instanceof qt&&(e=e._toObject());const r={...qt.defaultTextStyle,...e};for(const n in r){const o=n;this[o]=r[n]}this._tagStyles=e.tagStyles??void 0,this.update(),this._tick=0}get align(){return this._align}set align(e){this._align!==e&&(this._align=e,this.update())}get breakWords(){return this._breakWords}set breakWords(e){this._breakWords!==e&&(this._breakWords=e,this.update())}get dropShadow(){return this._dropShadow}set dropShadow(e){this._dropShadow!==e&&(e!==null&&typeof e=="object"?this._dropShadow=this._createProxy({...qt.defaultDropShadow,...e}):this._dropShadow=e?this._createProxy({...qt.defaultDropShadow}):null,this.update())}get fontFamily(){return this._fontFamily}set fontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.update())}get fontSize(){return this._fontSize}set fontSize(e){this._fontSize!==e&&(typeof e=="string"?this._fontSize=parseInt(e,10):this._fontSize=e,this.update())}get fontStyle(){return this._fontStyle}set fontStyle(e){this._fontStyle!==e&&(this._fontStyle=e.toLowerCase(),this.update())}get fontVariant(){return this._fontVariant}set fontVariant(e){this._fontVariant!==e&&(this._fontVariant=e,this.update())}get fontWeight(){return this._fontWeight}set fontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.update())}get leading(){return this._leading}set leading(e){this._leading!==e&&(this._leading=e,this.update())}get letterSpacing(){return this._letterSpacing}set letterSpacing(e){this._letterSpacing!==e&&(this._letterSpacing=e,this.update())}get lineHeight(){return this._lineHeight}set lineHeight(e){this._lineHeight!==e&&(this._lineHeight=e,this.update())}get padding(){return this._padding}set padding(e){this._padding!==e&&(this._padding=e,this.update())}get filters(){return this._filters}set filters(e){this._filters!==e&&(this._filters=Object.freeze(e),this.update())}get trim(){return this._trim}set trim(e){this._trim!==e&&(this._trim=e,this.update())}get textBaseline(){return this._textBaseline}set textBaseline(e){this._textBaseline!==e&&(this._textBaseline=e,this.update())}get whiteSpace(){return this._whiteSpace}set whiteSpace(e){this._whiteSpace!==e&&(this._whiteSpace=e,this.update())}get wordWrap(){return this._wordWrap}set wordWrap(e){this._wordWrap!==e&&(this._wordWrap=e,this.update())}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(e){this._wordWrapWidth!==e&&(this._wordWrapWidth=e,this.update())}get fill(){return this._originalFill}set fill(e){e!==this._originalFill&&(this._originalFill=e,this._isFillStyle(e)&&(this._originalFill=this._createProxy({...Ye.defaultFillStyle,...e},()=>{this._fill=Ot({...this._originalFill},Ye.defaultFillStyle)})),this._fill=Ot(e===0?"black":e,Ye.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(e){e!==this._originalStroke&&(this._originalStroke=e,this._isFillStyle(e)&&(this._originalStroke=this._createProxy({...Ye.defaultStrokeStyle,...e},()=>{this._stroke=bi({...this._originalStroke},Ye.defaultStrokeStyle)})),this._stroke=bi(e,Ye.defaultStrokeStyle),this.update())}get tagStyles(){return this._tagStyles}set tagStyles(e){this._tagStyles!==e&&(this._tagStyles=e??void 0,this.update())}update(){this._tick++,this._cachedFontString=null,this.emit("update",this)}reset(){const e=qt.defaultTextStyle;for(const t in e)this[t]=e[t]}assign(e){for(const t in e){const s=t;this[s]=e[t]}return this}get styleKey(){return`${this.uid}-${this._tick}`}get _fontString(){return this._cachedFontString===null&&(this._cachedFontString=pr(this)),this._cachedFontString}_toObject(){return{align:this.align,breakWords:this.breakWords,dropShadow:this._dropShadow?{...this._dropShadow}:null,fill:this._fill?{...this._fill}:void 0,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,leading:this.leading,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke?{...this._stroke}:void 0,textBaseline:this.textBaseline,trim:this.trim,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth,filters:this._filters?[...this._filters]:void 0,tagStyles:this._tagStyles?{...this._tagStyles}:void 0}}clone(){return new qt(this._toObject())}_getFinalPadding(){let e=0;if(this._filters)for(let t=0;t<this._filters.length;t++)e+=this._filters[t].padding;return Math.max(this._padding,e)}destroy(e=!1){if(this.removeAllListeners(),typeof e=="boolean"?e:e?.texture){const s=typeof e=="boolean"?e:e?.textureSource;this._fill?.texture&&this._fill.texture.destroy(s),this._originalFill?.texture&&this._originalFill.texture.destroy(s),this._stroke?.texture&&this._stroke.texture.destroy(s),this._originalStroke?.texture&&this._originalStroke.texture.destroy(s)}this._fill=null,this._stroke=null,this.dropShadow=null,this._originalStroke=null,this._originalFill=null}_createProxy(e,t){return new Proxy(e,{set:(s,r,n)=>(s[r]===n||(s[r]=n,t?.(r,n),this.update()),!0)})}_isFillStyle(e){return(e??null)!==null&&!(le.isColorLike(e)||e instanceof Xe||e instanceof Us)}};Za.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5};Za.defaultTextStyle={align:"left",breakWords:!1,dropShadow:null,fill:"black",fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",leading:0,letterSpacing:0,lineHeight:0,padding:0,stroke:null,textBaseline:"alphabetic",trim:!1,whiteSpace:"pre",wordWrap:!1,wordWrapWidth:100};let Gs=Za;function wy(i){const e=i;if(typeof e.dropShadow=="boolean"&&e.dropShadow){const t=Gs.defaultDropShadow;i.dropShadow={alpha:e.dropShadowAlpha??t.alpha,angle:e.dropShadowAngle??t.angle,blur:e.dropShadowBlur??t.blur,color:e.dropShadowColor??t.color,distance:e.dropShadowDistance??t.distance}}if(e.strokeThickness!==void 0){N(de,"strokeThickness is now a part of stroke");const t=e.stroke;let s={};if(le.isColorLike(t))s.color=t;else if(t instanceof Xe||t instanceof Us)s.fill=t;else if(Object.hasOwnProperty.call(t,"color")||Object.hasOwnProperty.call(t,"fill"))s=t;else throw new Error("Invalid stroke value.");i.stroke={...s,width:e.strokeThickness}}if(Array.isArray(e.fillGradientStops)){if(N(de,"gradient fill is now a fill pattern: `new FillGradient(...)`"),!Array.isArray(e.fill)||e.fill.length===0)throw new Error("Invalid fill value. Expected an array of colors for gradient fill.");e.fill.length!==e.fillGradientStops.length&&z("The number of fill colors must match the number of fill gradient stops.");const t=new Xe({start:{x:0,y:0},end:{x:0,y:1},textureSpace:"local"}),s=e.fillGradientStops.slice(),r=e.fill.map(n=>le.shared.setValue(n).toNumber());s.forEach((n,o)=>{t.addColorStop(n,r[o])}),i.fill={fill:t}}}let Dc=!1;function Mp(i){if(Dc)return;const e=new Lt({scaleMode:i.scaleMode});i._resourceId!==e._resourceId&&(Dc=!0,z("Text textureStyle: only scaleMode is applied to a text texture, the other fields are ignored"))}function Cp(i,e){const{texture:t,bounds:s}=i,r=e._style._getFinalPadding();qo(s,e._anchor,t);const n=e._anchor._x*r*2,o=e._anchor._y*r*2;s.minX-=r-n,s.minY-=r-o,s.maxX-=r-n,s.maxY-=r-o}class Nr{constructor(){this.batcherName="default",this.topology="triangle-list",this.attributeSize=4,this.indexSize=6,this.packAsQuad=!0,this.roundPixels=0,this._attributeStart=0,this._batcher=null,this._batch=null}get blendMode(){return this.renderable.groupBlendMode}get color(){return this.renderable.groupColorAlpha}reset(){this.renderable=null,this.texture=null,this._batcher=null,this._batch=null,this.bounds=null}destroy(){this.reset()}}class kp extends Nr{}class Qa{constructor(e){this._renderer=e,e.runners.resolutionChange.add(this),e.runners.contextChange.add(this),this._managedTexts=new lt({renderer:e,type:"renderable",onUnload:this.onTextUnload.bind(this),name:"canvasText"})}resolutionChange(){for(const e in this._managedTexts.items){const t=this._managedTexts.items[e];t?._autoResolution&&t.onViewUpdate()}}contextChange(){for(const e in this._managedTexts.items)this._managedTexts.items[e]?.unload()}validateRenderable(e){const t=this._getGpuText(e),s=e.styleKey;return t.currentKey!==s?!0:e._didTextUpdate}addRenderable(e,t){const s=this._getGpuText(e);if(e._didTextUpdate||s.currentKey!==e.styleKey){const r=e._autoResolution?this._renderer.resolution:e.resolution;(s.currentKey!==e.styleKey||e._resolution!==r)&&this._updateGpuText(e),e._didTextUpdate=!1,Cp(s,e)}this._renderer.renderPipes.batch.addToBatch(s,t)}updateRenderable(e){const t=this._getGpuText(e);t._batcher.updateElement(t)}_updateGpuText(e){const t=this._getGpuText(e);t.texture&&this._renderer.canvasText.decreaseReferenceCount(t.currentKey),e._resolution=e._autoResolution?this._renderer.resolution:e.resolution,t.texture=this._renderer.canvasText.getManagedTexture(e),t.currentKey=e.styleKey}_getGpuText(e){return e._gpuData[this._renderer.uid]||this.initGpuText(e)}initGpuText(e){const t=new kp;return t.currentKey="--",t.renderable=e,t.transform=e.groupTransform,t.bounds={minX:0,maxX:1,minY:0,maxY:0},t.roundPixels=this._renderer._roundPixels|e._roundPixels,e._gpuData[this._renderer.uid]=t,this._managedTexts.add(e),t}onTextUnload(e){const t=e._gpuData[this._renderer.uid];if(!t)return;const{canvasText:s}=this._renderer;s.getReferenceCount(t.currentKey)>0?s.decreaseReferenceCount(t.currentKey):t.texture&&s.returnTexture(t.texture)}destroy(){this._managedTexts.destroy(),this._renderer=null}}Qa.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"text"};class Ja{constructor(e,t){this._activeTextures={},this._renderer=e,this._retainCanvasContext=t}getTexture(e,t,s,r){typeof e=="string"&&(N("8.0.0","CanvasTextSystem.getTexture: Use object TextOptions instead of separate arguments"),e={text:e,style:s,resolution:t}),e.style instanceof Gs||(e.style=new Gs(e.style)),typeof e.text!="string"&&(e.text=e.text.toString());const{text:n,style:o,textureStyle:a,autoGenerateMipmaps:l}=e,h=e.resolution??this._renderer.resolution,{frame:c,canvasAndContext:u}=Jt.getCanvasAndContext({text:n,style:o,resolution:h}),d=Ua(u.canvas,c.width,c.height,h,l,a?.scaleMode);if(o.trim&&(c.pad(o.padding),d.frame.copyFrom(c),d.frame.scale(1/h),d.updateUvs()),o.filters){const f=this._applyFilters(d,o.filters);return this.returnTexture(d),Jt.returnCanvasAndContext(u),f}return this._renderer.texture.initSource(d._source),this._retainCanvasContext||Jt.returnCanvasAndContext(u),d}returnTexture(e){const t=e.source,s=t.resource;if(this._retainCanvasContext&&s?.getContext){const r=s.getContext("2d");r&&Jt.returnCanvasAndContext({canvas:s,context:r})}t.resource=null,t.uploadMethodId="unknown",t.alphaMode="no-premultiply-alpha",Te.returnTexture(e)}renderTextToCanvas(){N("8.10.0","CanvasTextSystem.renderTextToCanvas: no longer supported, use CanvasTextSystem.getTexture instead")}getManagedTexture(e){e._resolution=e._autoResolution?this._renderer.resolution:e.resolution;const t=e.styleKey;if(this._activeTextures[t])return this._increaseReferenceCount(t),this._activeTextures[t].texture;const s=this.getTexture({text:e.text,style:e.style,resolution:e._resolution,textureStyle:e.textureStyle,autoGenerateMipmaps:e.autoGenerateMipmaps});return this._activeTextures[t]={texture:s,usageCount:1},s}decreaseReferenceCount(e){const t=this._activeTextures[e];t&&(t.usageCount--,t.usageCount===0&&(this.returnTexture(t.texture),this._activeTextures[e]=null))}getReferenceCount(e){return this._activeTextures[e]?.usageCount??0}_increaseReferenceCount(e){this._activeTextures[e].usageCount++}_applyFilters(e,t){const s=this._renderer.renderTarget.renderTarget,r=this._renderer.filter.generateFilteredTexture({texture:e,filters:t});return this._renderer.renderTarget.bind({target:s,clear:!1}),r}destroy(){this._renderer=null;for(const e in this._activeTextures)this._activeTextures[e]&&this.returnTexture(this._activeTextures[e].texture);this._activeTextures=null}}class el extends Ja{constructor(e){super(e,!0)}}el.extension={type:[S.CanvasSystem],name:"canvasText"};class tl extends Ja{constructor(e){super(e,!1)}}tl.extension={type:[S.WebGLSystem,S.WebGPUSystem],name:"canvasText"};Y.add(el);Y.add(tl);Y.add(Qa);class Ep extends ap{constructor(...e){const t=lp(e,"Text");super(t,Gs),this.renderPipeId="text",t.textureStyle&&(this.textureStyle=t.textureStyle instanceof Lt?t.textureStyle:new Lt(t.textureStyle),Mp(this.textureStyle)),this.autoGenerateMipmaps=t.autoGenerateMipmaps??ue.defaultOptions.autoGenerateMipmaps}updateBounds(){const e=this._bounds,t=this._anchor;let s=0,r=0;if(this._style.trim){const{frame:n,canvasAndContext:o}=Jt.getCanvasAndContext({text:this.text,style:this._style,resolution:1});Jt.returnCanvasAndContext(o),s=n.width,r=n.height}else{const n=St.measureText(this._text,this._style);s=n.width,r=n.height}e.minX=-t._x*s,e.maxX=e.minX+s,e.minY=-t._y*r,e.maxY=e.minY+r}}function Pp(){const{userAgent:i}=te.get().getNavigator();return/^((?!chrome|android).)*safari/i.test(i)}const sl=class Yt{static _getPatternRepeat(e,t){const s=e&&e!=="clamp-to-edge",r=t&&t!=="clamp-to-edge";return s&&r?"repeat":s?"repeat-x":r?"repeat-y":"no-repeat"}start(e,t,s){}execute(e,t){const s=t.elements;if(!s||!s.length)return;const r=e.renderer,n=r.canvasContext,o=n.activeContext;for(let a=0;a<s.length;a++){const l=s[a];if(!l.packAsQuad)continue;const h=l,c=h.texture,u=c?K.getCanvasSource(c):null;if(!u)continue;const d=c.source.style,f=n.smoothProperty,p=d.scaleMode!=="nearest";o[f]!==p&&(o[f]=p),n.setBlendMode(t.blendMode);const m=r.globalUniforms.globalUniformData?.worldColor??4294967295,g=h.color,_=(m>>>24&255)/255,y=(g>>>24&255)/255,x=r.filter?.alphaMultiplier??1,b=_*y*x;if(b<=0)continue;o.globalAlpha=b;const v=m&16777215,w=g&16777215,T=ss(ts(w,v)),E=c.frame,P=d.addressModeU??d.addressMode,A=d.addressModeV??d.addressMode,k=Yt._getPatternRepeat(P,A),I=c.source._resolution??c.source.resolution??1,G=h.renderable?.renderGroup?.isCachedAsTexture,F=E.x*I,X=E.y*I,M=E.width*I,C=E.height*I,B=h.bounds,R=r.renderTarget.renderTarget.isRoot,O=B.minX,U=B.minY,q=B.maxX-B.minX,J=B.maxY-B.minY,ie=c.rotate,V=c.uvs,Je=Math.min(V.x0,V.x1,V.x2,V.x3,V.y0,V.y1,V.y2,V.y3),Ei=Math.max(V.x0,V.x1,V.x2,V.x3,V.y0,V.y1,V.y2,V.y3),Ns=k!=="no-repeat"&&(Je<0||Ei>1),xt=ie&&!(!Ns&&(T!==16777215||ie));xt?(Yt._tempPatternMatrix.copyFrom(h.transform),Q.matrixAppendRotationInv(Yt._tempPatternMatrix,ie,O,U,q,J),n.setContextTransform(Yt._tempPatternMatrix,h.roundPixels===1,void 0,G&&R)):n.setContextTransform(h.transform,h.roundPixels===1,void 0,G&&R);const Nt=q,et=J;let Oe=xt?0:O,Le=xt?0:U;if(!xt&&h.roundPixels===1&&(Oe|=0,Le|=0),Ns){let tt=u;const Gt=T!==16777215&&!ie,bt=E.width<=c.source.width&&E.height<=c.source.height;Gt&&bt&&(tt=K.getTintedCanvas({texture:c},T));const Hs=o.createPattern(tt,k);if(!Hs)continue;const rn=Nt,ph=et;if(rn===0||ph===0)continue;const mh=1/rn,gh=1/ph,_h=(V.x1-V.x0)*mh,yh=(V.y1-V.y0)*mh,xh=(V.x3-V.x0)*gh,bh=(V.y3-V.y0)*gh,Ng=V.x0-_h*Oe-xh*Le,zg=V.y0-yh*Oe-bh*Le,nn=c.source.pixelWidth,on=c.source.pixelHeight;Yt._tempPatternMatrix.set(_h*nn,yh*on,xh*nn,bh*on,Ng*nn,zg*on),K.applyPatternTransform(Hs,Yt._tempPatternMatrix),o.fillStyle=Hs,o.fillRect(Oe,Le,Nt,et)}else{const Gt=T!==16777215||ie?K.getTintedCanvas({texture:c},T):u,bt=Gt!==u;o.drawImage(Gt,bt?0:F,bt?0:X,bt?Gt.width:M,bt?Gt.height:C,Oe,Le,Nt,et)}}}};sl._tempPatternMatrix=new L;sl.extension={type:[S.CanvasPipesAdaptor],name:"batch"};let Ap=sl;class il{constructor(){this._tempState=yt.for2d(),this._didUploadHash={}}init(e){e.renderer.runners.contextChange.add(this)}contextChange(){this._didUploadHash={}}start(e,t,s){const r=e.renderer,n=this._didUploadHash[s.uid];r.shader.bind(s,n),n||(this._didUploadHash[s.uid]=!0),r.shader.updateUniformGroup(r.globalUniforms.uniformGroup),r.geometry.bind(t,s.glProgram)}execute(e,t){const s=e.renderer;this._tempState.blendMode=t.blendMode,s.state.set(this._tempState);const r=t.textures.textures;for(let n=0;n<t.textures.count;n++)s.texture.bind(r[n],n);s.texture.unbindIntegerTextures(t.textures.count),s.geometry.draw(t.topology,t.size,t.start)}}il.extension={type:[S.WebGLPipesAdaptor],name:"batch"};const $i=yt.for2d();class rl{start(e,t,s){const r=e.renderer,n=r.encoder,o=s.gpuProgram;this._shader=s,this._geometry=t,n.setGeometry(t,o),$i.blendMode="normal",r.pipeline.getPipeline(t,o,$i,void 0,s._overrides);const a=r.globalUniforms.bindGroup;n.resetBindGroup(1),n.setBindGroup(0,a,o)}execute(e,t){const s=this._shader.gpuProgram,r=e.renderer,n=r.encoder;if(!t.bindGroup){const l=t.textures;t.bindGroup=Rr(l.textures,l.count,r.limits.maxBatchableTextures)}$i.blendMode=t.blendMode;const o=r.bindGroup.getBindGroup(t.bindGroup,s,1),a=r.pipeline.getPipeline(this._geometry,s,$i,t.topology,this._shader._overrides);t.bindGroup._touch(r.gc.now),n.setPipeline(a),n.renderPassEncoder.setBindGroup(1,o),n.renderPassEncoder.drawIndexed(t.size,1,t.start)}}rl.extension={type:[S.WebGPUPipesAdaptor],name:"batch"};const nl=class Rp{constructor(e,t){this.state=yt.for2d(),this._batchersByInstructionSet=Object.create(null),this._activeBatches=Object.create(null),this.renderer=e,this._adaptor=t,this._adaptor.init?.(this)}static getBatcher(e,t){return new this._availableBatchers[e]({maxTextures:t})}buildStart(e){let t=this._batchersByInstructionSet[e.uid];t||(t=this._batchersByInstructionSet[e.uid]=Object.create(null),t.default||(t.default=new Fr({maxTextures:this.renderer.limits.maxBatchableTextures}))),this._activeBatches=t,this._activeBatch=this._activeBatches.default;for(const s in this._activeBatches)this._activeBatches[s].begin()}addToBatch(e,t){if(this._activeBatch.name!==e.batcherName){this._activeBatch.break(t);let s=this._activeBatches[e.batcherName];s||(s=this._activeBatches[e.batcherName]=Rp.getBatcher(e.batcherName,this.renderer.limits.maxBatchableTextures),s.begin()),this._activeBatch=s}this._activeBatch.add(e)}break(e){this._activeBatch.break(e)}buildEnd(e){this._activeBatch.break(e);const t=this._activeBatches;for(const s in t){const r=t[s],n=r.geometry;n.indexBuffer.setDataWithSize(r.indexBuffer,r.indexSize,!0),n.buffers[0].setDataWithSize(r.attributeBuffer.float32View,r.attributeSize,!1)}}upload(e){const t=this._batchersByInstructionSet[e.uid];for(const s in t){const r=t[s],n=r.geometry;r.dirty&&(r.dirty=!1,n.buffers[0].update(r.attributeSize*4))}}execute(e){if(e.action==="startBatch"){const t=e.batcher,s=t.geometry,r=t.shader;this._adaptor.start(this,s,r)}this._adaptor.execute(this,e)}destroyInstructionSet(e){const t=this._batchersByInstructionSet[e.uid];if(t){for(const s in t)t[s].destroy();delete this._batchersByInstructionSet[e.uid],this._activeBatches===t&&(this._activeBatches=Object.create(null),this._activeBatch=null)}}destroy(){this.state=null,this.renderer=null,this._adaptor=null;for(const e in this._activeBatches)this._activeBatches[e].destroy();this._activeBatches=null}};nl.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"batch"};nl._availableBatchers=Object.create(null);let zr=nl;Y.handleByMap(S.Batcher,zr._availableBatchers);Y.add(Fr);const Bp={name:"texture-bit",vertex:{header:`
|
|
558
558
|
|
|
559
559
|
struct TextureUniforms {
|
|
560
560
|
uTextureMatrix:mat3x3<f32>,
|
|
@@ -580,7 +580,7 @@ fn mainFragment(
|
|
|
580
580
|
|
|
581
581
|
`,main:`
|
|
582
582
|
outColor = texture(uTexture, vUV);
|
|
583
|
-
`}},Ty=new Ee;class Sy extends ui{constructor(){super(),this._placeholderSprite=new os(H.EMPTY),this.filters=[new ip({sprite:this._placeholderSprite,inverse:!1,resolution:"inherit",antialias:"inherit"})]}get sprite(){return this.filters[0].sprite}set sprite(e){this.filters[0].setSprite(e)}get inverse(){return this.filters[0].inverse}set inverse(e){this.filters[0].inverse=e}get channel(){return this.filters[0].channel}set channel(e){this.filters[0].channel=e}reset(){this._placeholderSprite.texture=H.EMPTY,this.sprite=this._placeholderSprite}}class Hr{constructor(e){this._activeMaskStage=[],this._usedEffects=[],this._renderer=e,e.runners.postrender.add(this)}push(e,t,s){const r=this._renderer;if(r.renderPipes.batch.break(s),s.add({renderPipeId:"alphaMask",action:"pushMaskBegin",mask:e,inverse:t._maskOptions.inverse,canBundle:!1,maskedContainer:t}),e.inverse=t._maskOptions.inverse,e.channel=t._maskOptions.channel??"red",e.renderMaskToTexture){const n=e.mask;n.includeInBuild=!0,n.collectRenderables(s,r,null),n.includeInBuild=!1}r.renderPipes.batch.break(s),s.add({renderPipeId:"alphaMask",action:"pushMaskEnd",mask:e,maskedContainer:t,inverse:t._maskOptions.inverse,canBundle:!1})}pop(e,t,s){this._renderer.renderPipes.batch.break(s),s.add({renderPipeId:"alphaMask",action:"popMaskEnd",mask:e,inverse:t._maskOptions.inverse,canBundle:!1})}execute(e){const t=this._renderer,s=e.mask.renderMaskToTexture;if(e.action==="pushMaskBegin"){const r=Se.get(Sy);if(r.inverse=e.inverse,r.channel=e.mask.channel,s){e.mask.mask.measurable=!0;const n=vr(e.mask.mask,!0,Ty);e.mask.mask.measurable=!1,n.ceil();const o=t.renderTarget.renderTarget.colorTexture.source,a=Te.getOptimalTexture({width:n.width,height:n.height,resolution:o._resolution,antialias:o.antialias});t.renderTarget.push({target:a,clear:!0}),t.globalUniforms.push({offset:n,worldColor:4294967295});const l=r.sprite;l.texture=a,l.worldTransform.tx=n.minX,l.worldTransform.ty=n.minY,this._activeMaskStage.push({filterEffect:r,maskedContainer:e.maskedContainer,filterTexture:a})}else r.sprite=e.mask.mask,this._activeMaskStage.push({filterEffect:r,maskedContainer:e.maskedContainer})}else if(e.action==="pushMaskEnd"){const r=this._activeMaskStage[this._activeMaskStage.length-1];s&&(t.type===Ze.WEBGL&&t.renderTarget.finishRenderPass(),t.renderTarget.pop(),t.globalUniforms.pop()),t.filter.push({renderPipeId:"filter",action:"pushFilter",container:r.maskedContainer,filterEffect:r.filterEffect,canBundle:!1})}else if(e.action==="popMaskEnd"){t.filter.pop();const r=this._activeMaskStage.pop();s&&Te.returnTexture(r.filterTexture),this._usedEffects.push(r.filterEffect)}}postrender(){const e=this._usedEffects;for(let t=0;t<e.length;t++)Se.return(e[t]);e.length=0}destroy(){this.postrender(),this._renderer.runners.postrender.remove(this),this._renderer=null,this._activeMaskStage=null,this._usedEffects=null}}Hr.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"alphaMask"};class ol{constructor(e){this._colorStack=[],this._colorStackIndex=0,this._currentColor=0,this._renderer=e}buildStart(){this._colorStack[0]=15,this._colorStackIndex=1,this._currentColor=15}push(e,t,s){this._renderer.renderPipes.batch.break(s);const r=this._colorStack;r[this._colorStackIndex]=r[this._colorStackIndex-1]&e.mask;const n=this._colorStack[this._colorStackIndex];n!==this._currentColor&&(this._currentColor=n,s.add({renderPipeId:"colorMask",colorMask:n,canBundle:!1})),this._colorStackIndex++}pop(e,t,s){this._renderer.renderPipes.batch.break(s);const r=this._colorStack;this._colorStackIndex--;const n=r[this._colorStackIndex-1];n!==this._currentColor&&(this._currentColor=n,s.add({renderPipeId:"colorMask",colorMask:n,canBundle:!1}))}execute(e){}destroy(){this._renderer=null,this._colorStack=null}}ol.extension={type:[S.CanvasPipes],name:"colorMask"};class al{constructor(e){this._colorStack=[],this._colorStackIndex=0,this._currentColor=0,this._renderer=e}buildStart(){this._colorStack[0]=15,this._colorStackIndex=1,this._currentColor=15}push(e,t,s){this._renderer.renderPipes.batch.break(s);const n=this._colorStack;n[this._colorStackIndex]=n[this._colorStackIndex-1]&e.mask;const o=this._colorStack[this._colorStackIndex];o!==this._currentColor&&(this._currentColor=o,s.add({renderPipeId:"colorMask",colorMask:o,canBundle:!1})),this._colorStackIndex++}pop(e,t,s){this._renderer.renderPipes.batch.break(s);const n=this._colorStack;this._colorStackIndex--;const o=n[this._colorStackIndex-1];o!==this._currentColor&&(this._currentColor=o,s.add({renderPipeId:"colorMask",colorMask:o,canBundle:!1}))}execute(e){this._renderer.colorMask.setMask(e.colorMask)}destroy(){this._renderer=null,this._colorStack=null}}al.extension={type:[S.WebGLPipes,S.WebGPUPipes],name:"colorMask"};function My(i,e,t,s,r,n){n=Math.max(0,Math.min(n,Math.min(s,r)/2)),i.moveTo(e+n,t),i.lineTo(e+s-n,t),i.quadraticCurveTo(e+s,t,e+s,t+n),i.lineTo(e+s,t+r-n),i.quadraticCurveTo(e+s,t+r,e+s-n,t+r),i.lineTo(e+n,t+r),i.quadraticCurveTo(e,t+r,e,t+r-n),i.lineTo(e,t+n),i.quadraticCurveTo(e,t,e+n,t)}function Gp(i,e){switch(e.type){case"rectangle":{const t=e;i.rect(t.x,t.y,t.width,t.height);break}case"roundedRectangle":{const t=e;My(i,t.x,t.y,t.width,t.height,t.radius);break}case"circle":{const t=e;i.moveTo(t.x+t.radius,t.y),i.arc(t.x,t.y,t.radius,0,Math.PI*2);break}case"ellipse":{const t=e;i.ellipse?(i.moveTo(t.x+t.halfWidth,t.y),i.ellipse(t.x,t.y,t.halfWidth,t.halfHeight,0,0,Math.PI*2)):(i.save(),i.translate(t.x,t.y),i.scale(t.halfWidth,t.halfHeight),i.moveTo(1,0),i.arc(0,0,1,0,Math.PI*2),i.restore());break}case"triangle":{const t=e;i.moveTo(t.x,t.y),i.lineTo(t.x2,t.y2),i.lineTo(t.x3,t.y3),i.closePath();break}case"polygon":default:{const t=e,s=t.points;if(!s?.length)break;i.moveTo(s[0],s[1]);for(let r=2;r<s.length;r+=2)i.lineTo(s[r],s[r+1]);t.closePath&&i.closePath();break}}}function Cy(i,e,t){const s=[],r=[],n=[];if(!ps[e.type]?.build(e,s))return!1;const a=e.closePath??!0;Lr(s,t,!1,a,r,n);for(let l=0;l<n.length;l+=3){const h=n[l]*2,c=n[l+1]*2,u=n[l+2]*2;i.moveTo(r[h],r[h+1]),i.lineTo(r[c],r[c+1]),i.lineTo(r[u],r[u+1]),i.closePath()}return!0}function ky(i,e){if(!e?.length)return!1;for(let t=0;t<e.length;t++){const s=e[t];if(!s?.shape)continue;const r=s.transform,n=r&&!r.isIdentity();n&&(i.save(),i.transform(r.a,r.b,r.c,r.d,r.tx,r.ty)),Gp(i,s.shape),n&&i.restore()}return!0}class ll{constructor(e){this._warnedMaskTypes=new Set,this._canvasMaskStack=[],this._renderer=e}push(e,t,s){this._renderer.renderPipes.batch.break(s),s.add({renderPipeId:"stencilMask",action:"pushMaskBegin",mask:e,inverse:t._maskOptions.inverse,canBundle:!1})}pop(e,t,s){this._renderer.renderPipes.batch.break(s),s.add({renderPipeId:"stencilMask",action:"popMaskEnd",mask:e,inverse:t._maskOptions.inverse,canBundle:!1})}execute(e){if(e.action!=="pushMaskBegin"&&e.action!=="popMaskEnd")return;const t=this._renderer,s=t.canvasContext,r=s?.activeContext;if(!r)return;if(e.action==="popMaskEnd"){this._canvasMaskStack.pop()&&r.restore();return}e.inverse&&this._warnOnce("inverse","CanvasRenderer: inverse masks are not supported on Canvas2D; ignoring inverse flag.");const n=e.mask.mask;if(!(n instanceof Pe)){this._warnOnce("nonGraphics","CanvasRenderer: only Graphics masks are supported in Canvas2D; skipping mask."),this._canvasMaskStack.push(!1);return}const o=n,a=o.context?.instructions;if(!a?.length){this._canvasMaskStack.push(!1);return}r.save(),s.setContextTransform(o.groupTransform,(t._roundPixels|o._roundPixels)===1),r.beginPath();let l=!1,h=!1;for(let c=0;c<a.length;c++){const u=a[c],d=u.action;if(d!=="fill"&&d!=="stroke")continue;const f=u.data,p=f?.path?.shapePath;if(!p?.shapePrimitives?.length)continue;const m=d==="stroke",g=p.shapePrimitives;for(let _=0;_<g.length;_++){const y=g[_];if(!y?.shape)continue;const x=y.transform,b=x&&!x.isIdentity();b&&(r.save(),r.transform(x.a,x.b,x.c,x.d,x.tx,x.ty)),m&&f.style?l=Cy(r,y.shape,f.style)||l:(Gp(r,y.shape),h=ky(r,y.holes)||h,l=!0),b&&r.restore()}}if(!l){r.restore(),this._canvasMaskStack.push(!1);return}h?r.clip("evenodd"):r.clip(),this._canvasMaskStack.push(!0)}destroy(){this._renderer=null,this._warnedMaskTypes=null,this._canvasMaskStack=null}_warnOnce(e,t){this._warnedMaskTypes.has(e)||(this._warnedMaskTypes.add(e),z(t))}}ll.extension={type:[S.CanvasPipes],name:"stencilMask"};class hl{constructor(e){this._maskHash=new WeakMap,this._renderer=e}push(e,t,s){const r=e,n=this._renderer;n.renderPipes.batch.break(s),n.renderPipes.blendMode.setBlendMode(r.mask,"none",s),s.add({renderPipeId:"stencilMask",action:"pushMaskBegin",mask:e,inverse:t._maskOptions.inverse,canBundle:!1});const o=r.mask;o.includeInBuild=!0,this._maskHash.has(r)||this._maskHash.set(r,{instructionsStart:0,instructionsLength:0});const a=this._maskHash.get(r);a.instructionsStart=s.instructionSize,o.collectRenderables(s,n,null),o.includeInBuild=!1,n.renderPipes.batch.break(s),s.add({renderPipeId:"stencilMask",action:"pushMaskEnd",mask:e,inverse:t._maskOptions.inverse,canBundle:!1});const l=s.instructionSize-a.instructionsStart-1;a.instructionsLength=l}pop(e,t,s){const r=e,n=this._renderer;n.renderPipes.batch.break(s),n.renderPipes.blendMode.setBlendMode(r.mask,"none",s),s.add({renderPipeId:"stencilMask",action:"popMaskBegin",inverse:t._maskOptions.inverse,canBundle:!1});const o=this._maskHash.get(e);for(let a=0;a<o.instructionsLength;a++)s.instructions[s.instructionSize++]=s.instructions[o.instructionsStart++];s.add({renderPipeId:"stencilMask",action:"popMaskEnd",canBundle:!1})}execute(e){const s=this._renderer,r=s.renderTarget.getGpuRenderTarget(s.renderTarget.renderTarget);let n=r.maskStackIndex;e.action==="pushMaskBegin"?(s.renderTarget.ensureDepthStencil(),s.stencil.setStencilMode(me.RENDERING_MASK_ADD,n),n++,s.colorMask.setMask(0)):e.action==="pushMaskEnd"?(e.inverse?s.stencil.setStencilMode(me.INVERSE_MASK_ACTIVE,n):s.stencil.setStencilMode(me.MASK_ACTIVE,n),s.colorMask.setMask(15)):e.action==="popMaskBegin"?(s.colorMask.setMask(0),n!==0?s.stencil.setStencilMode(me.RENDERING_MASK_REMOVE,n):(s.renderTarget.clear(null,ye.STENCIL),s.stencil.setStencilMode(me.DISABLED,n)),n--):e.action==="popMaskEnd"&&(e.inverse?s.stencil.setStencilMode(me.INVERSE_MASK_ACTIVE,n):s.stencil.setStencilMode(me.MASK_ACTIVE,n),s.colorMask.setMask(15)),r.maskStackIndex=n}destroy(){this._renderer=null,this._maskHash=null}}hl.extension={type:[S.WebGLPipes,S.WebGPUPipes],name:"stencilMask"};const he="source-over";function Dp(){const i=Oa(),e=Object.create(null);return e.inherit=he,e.none=he,e.normal="source-over",e.add="lighter",e.multiply=i?"multiply":he,e.screen=i?"screen":he,e.overlay=i?"overlay":he,e.darken=i?"darken":he,e.lighten=i?"lighten":he,e["color-dodge"]=i?"color-dodge":he,e["color-burn"]=i?"color-burn":he,e["hard-light"]=i?"hard-light":he,e["soft-light"]=i?"soft-light":he,e.difference=i?"difference":he,e.exclusion=i?"exclusion":he,e.saturation=i?"saturation":he,e.color=i?"color":he,e.luminosity=i?"luminosity":he,e["linear-burn"]=i?"color-burn":he,e["linear-dodge"]=i?"color-dodge":he,e["linear-light"]=i?"hard-light":he,e["pin-light"]=i?"hard-light":he,e["vivid-light"]=i?"hard-light":he,e["hard-mix"]=he,e.negation=i?"difference":he,e["normal-npm"]=e.normal,e["add-npm"]=e.add,e["screen-npm"]=e.screen,e.erase="destination-out",e.subtract=he,e.divide=he,e.min=he,e.max=he,e}const Ey=new L;class cl{constructor(e){this.activeResolution=1,this.smoothProperty="imageSmoothingEnabled",this.blendModes=Dp(),this._activeBlendMode="normal",this._projTransform=null,this._outerBlend=!1,this._warnedBlendModes=new Set,this._renderer=e}resolutionChange(e){this.activeResolution=e}init(){const e=this._renderer.background.alpha<1;if(this.rootContext=this._renderer.canvas.getContext("2d",{alpha:e}),this.activeContext=this.rootContext,this.activeResolution=this._renderer.resolution,!this.rootContext.imageSmoothingEnabled){const t=this.rootContext;t.webkitImageSmoothingEnabled?this.smoothProperty="webkitImageSmoothingEnabled":t.mozImageSmoothingEnabled?this.smoothProperty="mozImageSmoothingEnabled":t.oImageSmoothingEnabled?this.smoothProperty="oImageSmoothingEnabled":t.msImageSmoothingEnabled&&(this.smoothProperty="msImageSmoothingEnabled")}}setContextTransform(e,t,s,r){const n=r?L.IDENTITY:this._renderer.globalUniforms.globalUniformData?.worldTransformMatrix||L.IDENTITY;let o=Ey;o.copyFrom(n),o.append(e);const a=this._projTransform,l=this.activeResolution;if(s=s||l,a){const h=L.shared;h.copyFrom(o),h.prepend(a),o=h}t?this.activeContext.setTransform(o.a*s,o.b*s,o.c*s,o.d*s,o.tx*l|0,o.ty*l|0):this.activeContext.setTransform(o.a*s,o.b*s,o.c*s,o.d*s,o.tx*l,o.ty*l)}clear(e,t){const s=this.activeContext,r=this._renderer;if(s.clearRect(0,0,r.width,r.height),e){const n=le.shared.setValue(e);s.globalAlpha=t??n.alpha,s.fillStyle=n.toHex(),s.fillRect(0,0,r.width,r.height),s.globalAlpha=1}}setBlendMode(e){if(this._activeBlendMode===e)return;this._activeBlendMode=e,this._outerBlend=!1;const t=this.blendModes[e];if(!t){this._warnedBlendModes.has(e)||(console.warn(`CanvasRenderer: blend mode "${e}" is not supported in Canvas2D; falling back to "source-over".`),this._warnedBlendModes.add(e)),this.activeContext.globalCompositeOperation="source-over";return}this.activeContext.globalCompositeOperation=t}destroy(){this.rootContext=null,this.activeContext=null,this._warnedBlendModes.clear()}}cl.extension={type:[S.CanvasSystem],name:"canvasContext"};class ul{constructor(){this.maxTextures=16,this.maxBatchableTextures=16,this.maxUniformBindings=0}init(){}}ul.extension={type:[S.CanvasSystem],name:"limits"};class Wr{constructor(e){this._renderer=e}updateRenderable(){}destroyRenderable(){}validateRenderable(){return!1}addRenderable(e,t){this._renderer.renderPipes.batch.break(t),t.add(e)}execute(e){e.isRenderable&&e.render(this._renderer)}destroy(){this._renderer=null}}Wr.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"customRender"};function mr(i,e){const t=i.instructionSet,s=t.instructions;for(let r=0;r<t.instructionSize;r++){const n=s[r];e[n.renderPipeId].execute(n)}}class $r{constructor(e){this._renderer=e}addRenderGroup(e,t){e.isCachedAsTexture?this._addRenderableCacheAsTexture(e,t):this._addRenderableDirect(e,t)}execute(e){e.isRenderable&&(e.isCachedAsTexture?this._executeCacheAsTexture(e):this._executeDirect(e))}destroy(){this._renderer=null}_addRenderableDirect(e,t){this._renderer.renderPipes.batch.break(t),e._batchableRenderGroup&&(Se.return(e._batchableRenderGroup),e._batchableRenderGroup=null),t.add(e)}_addRenderableCacheAsTexture(e,t){const s=e._batchableRenderGroup??(e._batchableRenderGroup=Se.get(Nr));s.renderable=e.root,s.transform=e.root.relativeGroupTransform,s.texture=e.texture,s.bounds=e._textureBounds,t.add(e),this._renderer.renderPipes.blendMode.pushBlendMode(e,e.root.groupBlendMode,t),this._renderer.renderPipes.batch.addToBatch(s,t),this._renderer.renderPipes.blendMode.popBlendMode(t)}_executeCacheAsTexture(e){if(e.textureNeedsUpdate){e.textureNeedsUpdate=!1;const t=new L().translate(-e._textureBounds.x,-e._textureBounds.y);this._renderer.renderTarget.push({target:e.texture,clear:!0,frame:e.texture.frame}),this._renderer.globalUniforms.push({worldTransformMatrix:t,worldColor:4294967295,offset:{x:0,y:0}}),mr(e,this._renderer.renderPipes),this._renderer.renderTarget.finishRenderPass(),this._renderer.renderTarget.pop(),this._renderer.globalUniforms.pop()}e._batchableRenderGroup._batcher.updateElement(e._batchableRenderGroup),e._batchableRenderGroup._batcher.geometry.buffers[0].update()}_executeDirect(e){this._renderer.globalUniforms.push({worldTransformMatrix:e.inverseParentTextureTransform,worldColor:e.worldColorAlpha}),mr(e,this._renderer.renderPipes),this._renderer.globalUniforms.pop()}}$r.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"renderGroup"};const Py="#808080",Vi=new L,Ay=new L,Ry=new L,Dn=new L,By=new L;function Iy(i,e,t){i.beginPath();for(let s=0;s<t.length;s+=3){const r=t[s]*2,n=t[s+1]*2,o=t[s+2]*2;i.moveTo(e[r],e[r+1]),i.lineTo(e[n],e[n+1]),i.lineTo(e[o],e[o+1]),i.closePath()}i.fill()}function Gy(i){return`#${(i&16777215).toString(16).padStart(6,"0")}`}function Dy(i,e,t,s,r,n){n=Math.max(0,Math.min(n,Math.min(s,r)/2)),i.moveTo(e+n,t),i.lineTo(e+s-n,t),i.quadraticCurveTo(e+s,t,e+s,t+n),i.lineTo(e+s,t+r-n),i.quadraticCurveTo(e+s,t+r,e+s-n,t+r),i.lineTo(e+n,t+r),i.quadraticCurveTo(e,t+r,e,t+r-n),i.lineTo(e,t+n),i.quadraticCurveTo(e,t,e+n,t)}function er(i,e){switch(e.type){case"rectangle":{const t=e;i.rect(t.x,t.y,t.width,t.height);break}case"roundedRectangle":{const t=e;Dy(i,t.x,t.y,t.width,t.height,t.radius);break}case"circle":{const t=e;i.arc(t.x,t.y,t.radius,0,Math.PI*2);break}case"ellipse":{const t=e;i.ellipse?i.ellipse(t.x,t.y,t.halfWidth,t.halfHeight,0,0,Math.PI*2):(i.save(),i.translate(t.x,t.y),i.scale(t.halfWidth,t.halfHeight),i.arc(0,0,1,0,Math.PI*2),i.restore());break}case"triangle":{const t=e;i.moveTo(t.x,t.y),i.lineTo(t.x2,t.y2),i.lineTo(t.x3,t.y3),i.closePath();break}case"polygon":default:{const t=e,s=t.points;if(!s?.length)break;i.moveTo(s[0],s[1]);for(let r=2;r<s.length;r+=2)i.lineTo(s[r],s[r+1]);t.closePath&&i.closePath();break}}}function Fy(i,e){if(!e?.length)return!1;for(let t=0;t<e.length;t++){const s=e[t];if(!s?.shape)continue;const r=s.transform,n=r&&!r.isIdentity();n&&(i.save(),i.transform(r.a,r.b,r.c,r.d,r.tx,r.ty)),er(i,s.shape),n&&i.restore()}return!0}function Oy(i,e,t,s){const r=i.fill;if(r instanceof Xe){r.buildGradient();const o=r.texture;if(o){const a=K.getTintedPattern(o,e),l=t?Dn.copyFrom(t).scale(o.source.pixelWidth,o.source.pixelHeight):Dn.copyFrom(r.transform);return s&&!i.textureSpace&&l.append(s),K.applyPatternTransform(a,l),a}}if(r instanceof Us){const o=K.getTintedPattern(r.texture,e);return K.applyPatternTransform(o,r.transform,!1),o}const n=i.texture;if(n&&n!==H.WHITE){if(!n.source.resource)return Py;const o=K.getTintedPattern(n,e);let a=i.matrix;if(t){const{resolution:l}=n.source;if(a=Dn.copyFrom(t),n.rotate){const{uvs:h,orig:c}=n;a.prepend(By.set(h.x1-h.x0,h.y1-h.y0,h.x3-h.x0,h.y3-h.y0,h.x0,h.y0).invert()).scale(c.width*l,c.height*l)}else a.scale(n.source.pixelWidth,n.source.pixelHeight).translate(-n.frame.x*l,-n.frame.y*l)}return K.applyPatternTransform(o,a),o}return Gy(e)}class dl{constructor(){this.shader=null}contextChange(e){}execute(e,t){const s=e.renderer,r=s.canvasContext,n=r.activeContext,o=t.groupTransform,a=s.globalUniforms.globalUniformData?.worldColor??4294967295,l=t.groupColorAlpha,h=(a>>>24&255)/255,c=(l>>>24&255)/255,u=s.filter?.alphaMultiplier??1,d=h*c*u;if(d<=0)return;const f=a&16777215,p=l&16777215,m=ss(ts(p,f)),g=s._roundPixels|t._roundPixels;n.save(),r.setContextTransform(o,g===1),r.setBlendMode(t.groupBlendMode);const _=t.context.instructions;for(let y=0;y<_.length;y++){const x=_[y];if(x.action==="texture"){const k=x.data,I=k.image,G=I?K.getCanvasSource(I):null;if(!G)continue;const F=k.alpha*d;if(F<=0)continue;const X=ts(k.style,m);n.globalAlpha=F;let C=G;X!==16777215&&(C=K.getTintedCanvas({texture:I},X));const M=I.frame,B=I.source._resolution??I.source.resolution??1;let R=M.x*B,O=M.y*B;const U=M.width*B,q=M.height*B;C!==G&&(R=0,O=0);const J=k.transform,ie=J&&!J.isIdentity(),V=I.rotate;ie||V?(Vi.copyFrom(o),ie&&Vi.append(J),V&&Q.matrixAppendRotationInv(Vi,V,k.dx,k.dy,k.dw,k.dh),r.setContextTransform(Vi,g===1)):r.setContextTransform(o,g===1),n.drawImage(C,R,O,C===G?U:C.width,C===G?q:C.height,V?0:k.dx,V?0:k.dy,k.dw,k.dh),(ie||V)&&r.setContextTransform(o,g===1);continue}const b=x.data,v=b?.path?.shapePath;if(!v?.shapePrimitives?.length)continue;const w=b.style,T=ts(w.color,m),E=w.alpha*d;if(E<=0)continue;const P=x.action==="stroke";if(n.globalAlpha=E,P){const k=w;n.lineWidth=k.width,n.lineCap=k.cap,n.lineJoin=k.join,n.miterLimit=k.miterLimit}const A=v.shapePrimitives;if(!P&&b.hole?.shapePath?.shapePrimitives?.length){const k=A[A.length-1];k.holes=b.hole.shapePath.shapePrimitives}for(let k=0;k<A.length;k++){const I=A[k];if(!I?.shape)continue;const G=I.transform,F=G&&!G.isIdentity(),X=w.texture&&w.texture!==H.WHITE,C=w.textureSpace==="global"?G:null,M=X?Aa(Ay,w,I.shape,C):null,B=F?Ry.copyFrom(o).append(G):o,R=Oy(w,T,M,B);if(F&&(n.save(),n.transform(G.a,G.b,G.c,G.d,G.tx,G.ty)),P){const O=w;if(O.alignment!==.5&&!O.pixelLine){const q=[],J=[],ie=[];if(ps[I.shape.type]?.build(I.shape,q)){const Je=I.shape.closePath??!0;Lr(q,O,!1,Je,J,ie),n.fillStyle=R,Iy(n,J,ie)}else n.strokeStyle=R,n.beginPath(),er(n,I.shape),n.stroke()}else n.strokeStyle=R,n.beginPath(),er(n,I.shape),n.stroke()}else n.fillStyle=R,n.beginPath(),er(n,I.shape),Fy(n,I.holes)?n.fill("evenodd"):n.fill();F&&n.restore()}}n.restore()}destroy(){this.shader=null}}dl.extension={type:[S.CanvasPipesAdaptor],name:"graphics"};class Vr{constructor(e){this._renderer=e}addRenderable(e,t){const s=this._getGpuSprite(e);e.didViewUpdate&&this._updateBatchableSprite(e,s),this._renderer.renderPipes.batch.addToBatch(s,t)}updateRenderable(e){const t=this._getGpuSprite(e);e.didViewUpdate&&this._updateBatchableSprite(e,t),t._batcher.updateElement(t)}validateRenderable(e){const t=this._getGpuSprite(e);return!t._batcher.checkAndUpdateTexture(t,e._texture)}_updateBatchableSprite(e,t){t.bounds=e.visualBounds,t.texture=e._texture}_getGpuSprite(e){return e._gpuData[this._renderer.uid]||this._initGPUSprite(e)}_initGPUSprite(e){const t=new Nr;return t.renderable=e,t.transform=e.groupTransform,t.texture=e._texture,t.bounds=e.visualBounds,t.roundPixels=this._renderer._roundPixels|e._roundPixels,e._gpuData[this._renderer.uid]=t,t}destroy(){this._renderer=null}}Vr.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"sprite"};const ai={};Y.handle(S.BlendMode,i=>{if(!i.name)throw new Error("BlendMode extension must have a name property");ai[i.name]=i.ref},i=>{delete ai[i.name]});class jr{constructor(e){this._blendModeStack=[],this._isAdvanced=!1,this._filterHash=Object.create(null),this._renderer=e,this._renderer.runners.prerender.add(this)}prerender(){this._activeBlendMode="normal",this._isAdvanced=!1}pushBlendMode(e,t,s){this._blendModeStack.push(t),this.setBlendMode(e,t,s)}popBlendMode(e){this._blendModeStack.pop();const t=this._blendModeStack[this._activeBlendMode.length-1]??"normal";this.setBlendMode(null,t,e)}setBlendMode(e,t,s){const r=e instanceof hr;if(this._activeBlendMode===t){this._isAdvanced&&e&&!r&&this._renderableList?.push(e);return}this._isAdvanced&&this._endAdvancedBlendMode(s),this._activeBlendMode=t,e&&(this._isAdvanced=!!ai[t],this._isAdvanced&&this._beginAdvancedBlendMode(e,s))}_beginAdvancedBlendMode(e,t){this._renderer.renderPipes.batch.break(t);const s=this._activeBlendMode;if(!ai[s]){z(`Unable to assign BlendMode: '${s}'. You may want to include: import 'pixi.js/advanced-blend-modes'`);return}const r=this._ensureFilterEffect(s),n=e instanceof hr,o={renderPipeId:"filter",action:"pushFilter",filterEffect:r,renderables:n?null:[e],container:n?e.root:null,canBundle:!1};this._renderableList=o.renderables,t.add(o)}_ensureFilterEffect(e){let t=this._filterHash[e];return t||(t=this._filterHash[e]=new ui,t.filters=[new ai[e]]),t}_endAdvancedBlendMode(e){this._isAdvanced=!1,this._renderableList=null,this._renderer.renderPipes.batch.break(e),e.add({renderPipeId:"filter",action:"popFilter",canBundle:!1})}buildStart(){this._isAdvanced=!1}buildEnd(e){this._isAdvanced&&this._endAdvancedBlendMode(e)}destroy(){this._renderer=null,this._renderableList=null;for(const e in this._filterHash)this._filterHash[e].destroy();this._filterHash=null}}jr.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"blendMode"};function gr(i,e){e||(e=0);for(let t=e;t<i.length&&i[t];t++)i[t]=null}const Ly=new _e,Fc=ks|fi|Mr;function fl(i,e=!1){Fp(i);const t=i.childrenToUpdate,s=i.updateTick++;for(const r in t){const n=Number(r),o=t[r],a=o.list,l=o.index;for(let h=0;h<l;h++){const c=a[h];c.parentRenderGroup===i&&c.relativeRenderGroupDepth===n&&pl(c,s,0)}gr(a,l),o.index=0}if(e)for(let r=0;r<i.renderGroupChildren.length;r++)fl(i.renderGroupChildren[r],e)}function Fp(i){const e=i.root;let t;if(i.renderGroupParent){const s=i.renderGroupParent;i.worldTransform.appendFrom(e.relativeGroupTransform,s.worldTransform),i.worldColor=di(e.groupColor,s.worldColor),t=e.groupAlpha*s.worldAlpha}else i.worldTransform.copyFrom(e.localTransform),i.worldColor=e.localColor,t=e.localAlpha;t=t<0?0:t>1?1:t,i.worldAlpha=t,i.worldColorAlpha=i.worldColor+((t*255|0)<<24)}function pl(i,e,t){if(e===i.updateTick)return;i.updateTick=e,i.didChange=!1;const s=i.localTransform;i.updateLocalTransform();const r=i.parent;if(r&&!r.renderGroup?(t|=i._updateFlags,i.relativeGroupTransform.appendFrom(s,r.relativeGroupTransform),t&Fc&&Oc(i,r,t)):(t=i._updateFlags,i.relativeGroupTransform.copyFrom(s),t&Fc&&Oc(i,Ly,t)),!i.renderGroup){const n=i.children,o=n.length;for(let h=0;h<o;h++)pl(n[h],e,t);const a=i.parentRenderGroup,l=i;l.renderPipeId&&!a.structureDidChange&&a.updateRenderable(l)}}function Oc(i,e,t){if(t&fi){i.groupColor=di(i.localColor,e.groupColor);let s=i.localAlpha*e.groupAlpha;s=s<0?0:s>1?1:s,i.groupAlpha=s,i.groupColorAlpha=i.groupColor+((s*255|0)<<24)}t&Mr&&(i.groupBlendMode=i.localBlendMode==="inherit"?e.groupBlendMode:i.localBlendMode),t&ks&&(i.globalDisplayStatus=i.localDisplayStatus&e.globalDisplayStatus),i._updateFlags=0}function Op(i,e){const{list:t}=i.childrenRenderablesToUpdate;let s=!1;for(let r=0;r<i.childrenRenderablesToUpdate.index;r++){const n=t[r];if(s=e[n.renderPipeId].validateRenderable(n),s)break}return i.structureDidChange=s,s}const Uy=new L;class ml{constructor(e){this._renderer=e}render({container:e,transform:t}){const s=e.parent,r=e.renderGroup.renderGroupParent;e.parent=null,e.renderGroup.renderGroupParent=null;const n=this._renderer,o=Uy;t&&(o.copyFrom(e.renderGroup.localTransform),e.renderGroup.localTransform.copyFrom(t));const a=n.renderPipes;this._updateCachedRenderGroups(e.renderGroup,null),this._updateRenderGroups(e.renderGroup),n.globalUniforms.start({worldTransformMatrix:t?e.renderGroup.localTransform:e.renderGroup.worldTransform,worldColor:e.renderGroup.worldColorAlpha}),mr(e.renderGroup,a),a.uniformBatch&&a.uniformBatch.renderEnd(),t&&e.renderGroup.localTransform.copyFrom(o),e.parent=s,e.renderGroup.renderGroupParent=r}destroy(){this._renderer=null}_updateCachedRenderGroups(e,t){if(e._parentCacheAsTextureRenderGroup=t,e.isCachedAsTexture){if(!e.textureNeedsUpdate)return;t=e}for(let s=e.renderGroupChildren.length-1;s>=0;s--)this._updateCachedRenderGroups(e.renderGroupChildren[s],t);if(e.invalidateMatrices(),e.isCachedAsTexture){if(e.textureNeedsUpdate){const s=e.root.getLocalBounds(),r=this._renderer,n=e.textureOptions.resolution||r.view.resolution,o=e.textureOptions.antialias??r.view.antialias,a=e.textureOptions.scaleMode??"linear",l=e.texture;s.ceil(),e.texture&&Te.returnTexture(e.texture);const h=Te.getOptimalTexture({width:s.width,height:s.height,resolution:n,antialias:o,scaleMode:a});e.texture=h,e._textureBounds||(e._textureBounds=new Ee),e._textureBounds.copyFrom(s),l!==e.texture&&e.renderGroupParent&&(e.renderGroupParent.structureDidChange=!0)}}else e.texture&&(Te.returnTexture(e.texture),e.texture=null)}_updateRenderGroups(e){const t=this._renderer,s=t.renderPipes;if(e.runOnRender(t),e.instructionSet.renderPipes=s,e.structureDidChange?gr(e.childrenRenderablesToUpdate.list,0):Op(e,s),fl(e),e.structureDidChange?(e.structureDidChange=!1,this._buildInstructions(e,t)):this._updateRenderables(e),e.childrenRenderablesToUpdate.index=0,t.renderPipes.batch.upload(e.instructionSet),!(e.isCachedAsTexture&&!e.textureNeedsUpdate))for(let r=0;r<e.renderGroupChildren.length;r++)this._updateRenderGroups(e.renderGroupChildren[r])}_updateRenderables(e){const{list:t,index:s}=e.childrenRenderablesToUpdate;for(let r=0;r<s;r++){const n=t[r];n.didViewUpdate&&e.updateRenderable(n)}gr(t,s)}_buildInstructions(e,t){const s=e.root,r=e.instructionSet;r.reset();const n=t.renderPipes?t:t.batch.renderer,o=n.renderPipes;o.batch.buildStart(r),o.blendMode.buildStart(),o.colorMask.buildStart(),s.sortableChildren&&s.sortChildren(),s.collectRenderablesWithEffects(r,n,null),o.batch.buildEnd(r),o.blendMode.buildEnd(r)}}ml.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"renderGroup"};const gl=class Lp{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new le(0),this.color=this._backgroundColor,this.alpha=1}init(e){e={...Lp.defaultOptions,...e},this.clearBeforeRender=e.clearBeforeRender,this.color=e.background||e.backgroundColor||this._backgroundColor,this.alpha=e.backgroundAlpha,this._backgroundColor.setAlpha(e.backgroundAlpha)}get color(){return this._backgroundColor}set color(e){le.shared.setValue(e).alpha<1&&this._backgroundColor.alpha===1&&z("Cannot set a transparent background on an opaque canvas. To enable transparency, set backgroundAlpha < 1 when initializing your Application."),this._backgroundColor.setValue(e)}get alpha(){return this._backgroundColor.alpha}set alpha(e){this._backgroundColor.setAlpha(e)}get colorRgba(){return this._backgroundColor.toArray()}destroy(){}};gl.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"background",priority:0};gl.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0};let Up=gl;const Fn={png:"image/png",jpg:"image/jpeg",webp:"image/webp"},_l=class Np{constructor(e){this._renderer=e}_normalizeOptions(e,t={}){return e instanceof _e||e instanceof H?{target:e,...t}:{...t,...e}}async image(e){const t=te.get().createImage();return t.src=await this.base64(e),t}async base64(e){e=this._normalizeOptions(e,Np.defaultImageOptions);const{format:t,quality:s}=e,r=this.canvas(e);if(r.toBlob!==void 0)return new Promise((n,o)=>{r.toBlob(a=>{if(!a){o(new Error("ICanvas.toBlob failed!"));return}const l=new FileReader;l.onload=()=>n(l.result),l.onerror=o,l.readAsDataURL(a)},Fn[t],s)});if(r.toDataURL!==void 0)return r.toDataURL(Fn[t],s);if(r.convertToBlob!==void 0){const n=await r.convertToBlob({type:Fn[t],quality:s});return new Promise((o,a)=>{const l=new FileReader;l.onload=()=>o(l.result),l.onerror=a,l.readAsDataURL(n)})}throw new Error("Extract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented")}canvas(e){e=this._normalizeOptions(e);const t=e.target,s=this._renderer;if(t instanceof H)return s.texture.generateCanvas(t);const r=s.textureGenerator.generateTexture(e),n=s.texture.generateCanvas(r);return r.destroy(!0),n}pixels(e){e=this._normalizeOptions(e);const t=e.target,s=this._renderer,r=t instanceof H?t:s.textureGenerator.generateTexture(e),n=s.texture.getPixels(r);return t instanceof _e&&r.destroy(!0),n}texture(e){return e=this._normalizeOptions(e),e.target instanceof H?e.target:this._renderer.textureGenerator.generateTexture(e)}download(e){e=this._normalizeOptions(e);const t=this.canvas(e),s=document.createElement("a");s.download=e.filename??"image.png",s.href=t.toDataURL("image/png"),document.body.appendChild(s),s.click(),document.body.removeChild(s)}log(e){const t=e.width??200;e=this._normalizeOptions(e);const s=this.canvas(e),r=s.toDataURL();console.log(`[Pixi Texture] ${s.width}px ${s.height}px`);const n=["font-size: 1px;",`padding: ${t}px 300px;`,`background: url(${r}) no-repeat;`,"background-size: contain;"].join(" ");console.log("%c ",n)}destroy(){this._renderer=null}};_l.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"extract"};_l.defaultImageOptions={format:"png",quality:1};let zp=_l;class Ci extends H{static create(e){const{dynamic:t,textureOptions:s,...r}=e;return new Ci({...s,source:new ue(r),dynamic:t??!1})}resize(e,t,s){return this.source.resize(e,t,s),this}}const Ny=new se,zy=new Ee,Hy=[0,0,0,0];class yl{constructor(e){this._renderer=e}generateTexture(e){e instanceof _e&&(e={target:e,frame:void 0,textureSourceOptions:{},resolution:void 0});const t=e.resolution||this._renderer.resolution,s=e.antialias||this._renderer.view.antialias,r=e.target;let n=e.clearColor;n?n=Array.isArray(n)&&n.length===4?n:le.shared.setValue(n).toArray():n=Hy;const o=e.frame?.copyTo(Ny)||Tr(r,zy).rectangle,a=e.defaultAnchor&&{defaultAnchor:e.defaultAnchor};o.width=Math.max(o.width,1/t)|0,o.height=Math.max(o.height,1/t)|0;const l=Ci.create({...e.textureSourceOptions,width:o.width,height:o.height,resolution:t,antialias:s,textureOptions:a}),h=L.shared.translate(-o.x,-o.y);return this._renderer.render({container:r,transform:h,target:l,clearColor:n}),l.source.updateMipmaps(),l}destroy(){this._renderer=null}}yl.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"textureGenerator"};function Hp(i){let e=!1;for(const s in i)if(i[s]==null){e=!0;break}if(!e)return i;const t=Object.create(null);for(const s in i){const r=i[s];r&&(t[s]=r)}return t}function Wp(i){let e=0;for(let t=0;t<i.length;t++)i[t]==null?e++:i[t-e]=i[t];return i.length-=e,i}const xl=class $p{constructor(e){this._managedResources=[],this._managedResourceHashes=[],this._managedCollections=[],this._ready=!1,this._running=!1,this._renderer=e}init(e){e={...$p.defaultOptions,...e},this.maxUnusedTime=e.gcMaxUnusedTime,this._frequency=e.gcFrequency,this.enabled=e.gcActive,this.now=performance.now()}get enabled(){return!!this._handler}set enabled(e){this.enabled!==e&&(e?(this._handler=this._renderer.scheduler.repeat(()=>{this._ready=!0},this._frequency,!1),this._collectionsHandler=this._renderer.scheduler.repeat(()=>{for(const t of this._managedCollections){const{context:s,collection:r,type:n}=t;n==="hash"?s[r]=Hp(s[r]):s[r]=Wp(s[r])}},this._frequency)):(this._renderer.scheduler.cancel(this._handler),this._renderer.scheduler.cancel(this._collectionsHandler),this._handler=0,this._collectionsHandler=0))}prerender({container:e}){this.now=performance.now(),e.renderGroup.gcTick=this._renderer.tick++,this._updateInstructionGCTick(e.renderGroup,e.renderGroup.gcTick)}postrender(){!this._ready||!this.enabled||(this.run(),this._ready=!1)}_updateInstructionGCTick(e,t){e.instructionSet.gcTick=t,e.gcTick=t;for(const s of e.renderGroupChildren)this._updateInstructionGCTick(s,t)}addCollection(e,t,s){this._managedCollections.push({context:e,collection:t,type:s})}addResource(e,t){if(e._gcLastUsed!==-1){e._gcLastUsed=this.now,e._onTouch?.(this.now);return}const s=this._managedResources.length;e._gcData={index:s,type:t},e._gcLastUsed=this.now,e._onTouch?.(this.now),e.once("unload",this.removeResource,this),this._managedResources.push(e)}removeResource(e){const t=e._gcData;if(!t)return;const s=t.index,r=this._managedResources.length-1;if(this._running)this._managedResources[s]=null;else{if(s!==r){const n=this._managedResources[r];this._managedResources[s]=n,n._gcData.index=s}this._managedResources.length--}e._gcData=null,e._gcLastUsed=-1}addResourceHash(e,t,s,r=0){this._managedResourceHashes.push({context:e,hash:t,type:s,priority:r}),this._managedResourceHashes.sort((n,o)=>n.priority-o.priority)}run(){if(this._running)return;const e=performance.now(),t=this._managedResourceHashes,s=this._managedResources;this._running=!0;try{for(const n of t)this.runOnHash(n,e);const r=s.length;for(let n=0;n<r;n++){const o=s[n];o&&this.runOnResource(o,e)}}finally{let r=0;for(let n=0;n<s.length;n++){const o=s[n];o&&(r!==n&&(s[r]=o,o._gcData.index=r),r++)}s.length=r,this._running=!1}}updateRenderableGCTick(e,t){const s=e.renderGroup??e.parentRenderGroup,r=s?.instructionSet?.gcTick??-1;(s?.gcTick??0)===r&&(e._gcLastUsed=t,e._onTouch?.(t))}runOnResource(e,t){e._gcData.type==="renderable"&&this.updateRenderableGCTick(e,t),!(t-e._gcLastUsed<this.maxUnusedTime||!e.autoGarbageCollect)&&(e.off("unload",this.removeResource,this),e.unload(),this.removeResource(e))}_createHashClone(e,t){const s=Object.create(null);for(const r in e){if(r===t)break;e[r]!==null&&(s[r]=e[r])}return s}runOnHash(e,t){const{context:s,hash:r,type:n}=e,o=s[r];let a=null,l=0;for(const h in o){const c=o[h];if(c===null){l++,l===1e4&&!a&&(a=this._createHashClone(o,h));continue}if(c._gcLastUsed===-1){c._gcLastUsed=t,c._onTouch?.(t),a&&(a[h]=c);continue}if(n==="renderable"&&this.updateRenderableGCTick(c,t),!(t-c._gcLastUsed<this.maxUnusedTime)&&c.autoGarbageCollect){if(n==="renderable"){const d=c,f=d.renderGroup??d.parentRenderGroup;f&&(f.structureDidChange=!0)}c.unload(),c._gcData=null,c._gcLastUsed=-1,a||(l+1!==1e4?(o[h]=null,l++):a=this._createHashClone(o,h))}else a&&(a[h]=c)}a&&(s[r]=a)}destroy(){this.enabled=!1,this._managedResources.forEach(e=>{e?.off("unload",this.removeResource,this)}),this._managedResources.length=0,this._managedResourceHashes.length=0,this._managedCollections.length=0,this._renderer=null}};xl.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"gc",priority:0};xl.defaultOptions={gcActive:!0,gcMaxUnusedTime:6e4,gcFrequency:3e4};let Vp=xl;class bl{constructor(e){this._stackIndex=0,this._globalUniformDataStack=[],this._uniformsPool=[],this._activeUniforms=[],this._bindGroupPool=[],this._activeBindGroups=[],this._renderer=e}reset(){this._stackIndex=0;for(let e=0;e<this._activeUniforms.length;e++)this._uniformsPool.push(this._activeUniforms[e]);for(let e=0;e<this._activeBindGroups.length;e++)this._bindGroupPool.push(this._activeBindGroups[e]);this._activeUniforms.length=0,this._activeBindGroups.length=0}start(e){this.reset(),this.push(e)}bind({size:e,projectionMatrix:t,worldTransformMatrix:s,worldColor:r,offset:n}){const o=this._renderer.renderTarget.renderTarget,a=this._stackIndex?this._globalUniformDataStack[this._stackIndex-1]:{worldTransformMatrix:new L,worldColor:4294967295,offset:new ce},l={projectionMatrix:t||this._renderer.renderTarget.projectionMatrix,resolution:e||o.size,worldTransformMatrix:s||a.worldTransformMatrix,worldColor:r||a.worldColor,offset:n||a.offset,bindGroup:null},h=this._uniformsPool.pop()||this._createUniforms();this._activeUniforms.push(h);const c=h.uniforms;c.uProjectionMatrix=l.projectionMatrix,c.uResolution=l.resolution,c.uWorldTransformMatrix.copyFrom(l.worldTransformMatrix),c.uWorldTransformMatrix.tx-=l.offset.x,c.uWorldTransformMatrix.ty-=l.offset.y,Ha(l.worldColor,c.uWorldColorAlpha,0),h.update();let u;this._renderer.renderPipes.uniformBatch?u=this._renderer.renderPipes.uniformBatch.getUniformBindGroup(h,!1):(u=this._bindGroupPool.pop()||new At,this._activeBindGroups.push(u),u.setResource(h,0)),l.bindGroup=u,this._currentGlobalUniformData=l}push(e){this.bind(e),this._globalUniformDataStack[this._stackIndex++]=this._currentGlobalUniformData}pop(){this._currentGlobalUniformData=this._globalUniformDataStack[--this._stackIndex-1],this._renderer.type===Ze.WEBGL&&this._currentGlobalUniformData.bindGroup.resources[0].update()}get bindGroup(){return this._currentGlobalUniformData.bindGroup}get globalUniformData(){return this._currentGlobalUniformData}get uniformGroup(){return this._currentGlobalUniformData.bindGroup.resources[0]}_createUniforms(){return new Qe({uProjectionMatrix:{value:new L,type:"mat3x3<f32>"},uWorldTransformMatrix:{value:new L,type:"mat3x3<f32>"},uWorldColorAlpha:{value:new Float32Array(4),type:"vec4<f32>"},uResolution:{value:[0,0],type:"vec2<f32>"}},{isStatic:!0})}destroy(){this._renderer=null,this._globalUniformDataStack.length=0,this._uniformsPool.length=0,this._activeUniforms.length=0,this._bindGroupPool.length=0,this._activeBindGroups.length=0,this._currentGlobalUniformData=null}}bl.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"globalUniforms"};let Wy=1;class vl{constructor(){this._tasks=[],this._offset=0}init(){$e.system.add(this._update,this)}repeat(e,t,s=!0){const r=Wy++;let n=0;return s&&(this._offset+=1e3,n=this._offset),this._tasks.push({func:e,duration:t,start:performance.now(),offset:n,last:performance.now(),repeat:!0,id:r}),r}cancel(e){for(let t=0;t<this._tasks.length;t++)if(this._tasks[t].id===e){this._tasks.splice(t,1);return}}_update(){const e=performance.now();for(let t=0;t<this._tasks.length;t++){const s=this._tasks[t];if(e-s.offset-s.last>=s.duration){const r=e-s.start;s.func(r),s.last=e}}}destroy(){$e.system.remove(this._update,this),this._tasks.length=0}}vl.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"scheduler",priority:0};let Lc=!1;function jp(i){if(!Lc){if(te.get().getNavigator().userAgent.toLowerCase().indexOf("chrome")>-1){const e=[`%c %c %c %c %c PixiJS %c v${xi} (${i}) http://www.pixijs.com/
|
|
583
|
+
`}},Ty=new Ee;class Sy extends ui{constructor(){super(),this._placeholderSprite=new os(H.EMPTY),this.filters=[new ip({sprite:this._placeholderSprite,inverse:!1,resolution:"inherit",antialias:"inherit"})]}get sprite(){return this.filters[0].sprite}set sprite(e){this.filters[0].setSprite(e)}get inverse(){return this.filters[0].inverse}set inverse(e){this.filters[0].inverse=e}get channel(){return this.filters[0].channel}set channel(e){this.filters[0].channel=e}reset(){this._placeholderSprite.texture=H.EMPTY,this.sprite=this._placeholderSprite}}class Hr{constructor(e){this._activeMaskStage=[],this._usedEffects=[],this._renderer=e,e.runners.postrender.add(this)}push(e,t,s){const r=this._renderer;if(r.renderPipes.batch.break(s),s.add({renderPipeId:"alphaMask",action:"pushMaskBegin",mask:e,inverse:t._maskOptions.inverse,canBundle:!1,maskedContainer:t}),e.inverse=t._maskOptions.inverse,e.channel=t._maskOptions.channel??"red",e.renderMaskToTexture){const n=e.mask;n.includeInBuild=!0,n.collectRenderables(s,r,null),n.includeInBuild=!1}r.renderPipes.batch.break(s),s.add({renderPipeId:"alphaMask",action:"pushMaskEnd",mask:e,maskedContainer:t,inverse:t._maskOptions.inverse,canBundle:!1})}pop(e,t,s){this._renderer.renderPipes.batch.break(s),s.add({renderPipeId:"alphaMask",action:"popMaskEnd",mask:e,inverse:t._maskOptions.inverse,canBundle:!1})}execute(e){const t=this._renderer,s=e.mask.renderMaskToTexture;if(e.action==="pushMaskBegin"){const r=Se.get(Sy);if(r.inverse=e.inverse,r.channel=e.mask.channel,s){e.mask.mask.measurable=!0;const n=vr(e.mask.mask,!0,Ty);e.mask.mask.measurable=!1,n.ceil();const o=t.renderTarget.renderTarget.colorTexture.source,a=Te.getOptimalTexture({width:n.width,height:n.height,resolution:o._resolution,antialias:o.antialias});t.renderTarget.push({target:a,clear:!0}),t.globalUniforms.push({offset:n,worldColor:4294967295});const l=r.sprite;l.texture=a,l.worldTransform.tx=n.minX,l.worldTransform.ty=n.minY,this._activeMaskStage.push({filterEffect:r,maskedContainer:e.maskedContainer,filterTexture:a})}else r.sprite=e.mask.mask,this._activeMaskStage.push({filterEffect:r,maskedContainer:e.maskedContainer})}else if(e.action==="pushMaskEnd"){const r=this._activeMaskStage[this._activeMaskStage.length-1];s&&(t.type===Ze.WEBGL&&t.renderTarget.finishRenderPass(),t.renderTarget.pop(),t.globalUniforms.pop()),t.filter.push({renderPipeId:"filter",action:"pushFilter",container:r.maskedContainer,filterEffect:r.filterEffect,canBundle:!1})}else if(e.action==="popMaskEnd"){t.filter.pop();const r=this._activeMaskStage.pop();s&&Te.returnTexture(r.filterTexture),this._usedEffects.push(r.filterEffect)}}postrender(){const e=this._usedEffects;for(let t=0;t<e.length;t++)Se.return(e[t]);e.length=0}destroy(){this.postrender(),this._renderer.runners.postrender.remove(this),this._renderer=null,this._activeMaskStage=null,this._usedEffects=null}}Hr.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"alphaMask"};class ol{constructor(e){this._colorStack=[],this._colorStackIndex=0,this._currentColor=0,this._renderer=e}buildStart(){this._colorStack[0]=15,this._colorStackIndex=1,this._currentColor=15}push(e,t,s){this._renderer.renderPipes.batch.break(s);const r=this._colorStack;r[this._colorStackIndex]=r[this._colorStackIndex-1]&e.mask;const n=this._colorStack[this._colorStackIndex];n!==this._currentColor&&(this._currentColor=n,s.add({renderPipeId:"colorMask",colorMask:n,canBundle:!1})),this._colorStackIndex++}pop(e,t,s){this._renderer.renderPipes.batch.break(s);const r=this._colorStack;this._colorStackIndex--;const n=r[this._colorStackIndex-1];n!==this._currentColor&&(this._currentColor=n,s.add({renderPipeId:"colorMask",colorMask:n,canBundle:!1}))}execute(e){}destroy(){this._renderer=null,this._colorStack=null}}ol.extension={type:[S.CanvasPipes],name:"colorMask"};class al{constructor(e){this._colorStack=[],this._colorStackIndex=0,this._currentColor=0,this._renderer=e}buildStart(){this._colorStack[0]=15,this._colorStackIndex=1,this._currentColor=15}push(e,t,s){this._renderer.renderPipes.batch.break(s);const n=this._colorStack;n[this._colorStackIndex]=n[this._colorStackIndex-1]&e.mask;const o=this._colorStack[this._colorStackIndex];o!==this._currentColor&&(this._currentColor=o,s.add({renderPipeId:"colorMask",colorMask:o,canBundle:!1})),this._colorStackIndex++}pop(e,t,s){this._renderer.renderPipes.batch.break(s);const n=this._colorStack;this._colorStackIndex--;const o=n[this._colorStackIndex-1];o!==this._currentColor&&(this._currentColor=o,s.add({renderPipeId:"colorMask",colorMask:o,canBundle:!1}))}execute(e){this._renderer.colorMask.setMask(e.colorMask)}destroy(){this._renderer=null,this._colorStack=null}}al.extension={type:[S.WebGLPipes,S.WebGPUPipes],name:"colorMask"};function My(i,e,t,s,r,n){n=Math.max(0,Math.min(n,Math.min(s,r)/2)),i.moveTo(e+n,t),i.lineTo(e+s-n,t),i.quadraticCurveTo(e+s,t,e+s,t+n),i.lineTo(e+s,t+r-n),i.quadraticCurveTo(e+s,t+r,e+s-n,t+r),i.lineTo(e+n,t+r),i.quadraticCurveTo(e,t+r,e,t+r-n),i.lineTo(e,t+n),i.quadraticCurveTo(e,t,e+n,t)}function Gp(i,e){switch(e.type){case"rectangle":{const t=e;i.rect(t.x,t.y,t.width,t.height);break}case"roundedRectangle":{const t=e;My(i,t.x,t.y,t.width,t.height,t.radius);break}case"circle":{const t=e;i.moveTo(t.x+t.radius,t.y),i.arc(t.x,t.y,t.radius,0,Math.PI*2);break}case"ellipse":{const t=e;i.ellipse?(i.moveTo(t.x+t.halfWidth,t.y),i.ellipse(t.x,t.y,t.halfWidth,t.halfHeight,0,0,Math.PI*2)):(i.save(),i.translate(t.x,t.y),i.scale(t.halfWidth,t.halfHeight),i.moveTo(1,0),i.arc(0,0,1,0,Math.PI*2),i.restore());break}case"triangle":{const t=e;i.moveTo(t.x,t.y),i.lineTo(t.x2,t.y2),i.lineTo(t.x3,t.y3),i.closePath();break}case"polygon":default:{const t=e,s=t.points;if(!s?.length)break;i.moveTo(s[0],s[1]);for(let r=2;r<s.length;r+=2)i.lineTo(s[r],s[r+1]);t.closePath&&i.closePath();break}}}function Cy(i,e,t){const s=[],r=[],n=[];if(!ps[e.type]?.build(e,s))return!1;const a=e.closePath??!0;Lr(s,t,!1,a,r,n);for(let l=0;l<n.length;l+=3){const h=n[l]*2,c=n[l+1]*2,u=n[l+2]*2;i.moveTo(r[h],r[h+1]),i.lineTo(r[c],r[c+1]),i.lineTo(r[u],r[u+1]),i.closePath()}return!0}function ky(i,e){if(!e?.length)return!1;for(let t=0;t<e.length;t++){const s=e[t];if(!s?.shape)continue;const r=s.transform,n=r&&!r.isIdentity();n&&(i.save(),i.transform(r.a,r.b,r.c,r.d,r.tx,r.ty)),Gp(i,s.shape),n&&i.restore()}return!0}class ll{constructor(e){this._warnedMaskTypes=new Set,this._canvasMaskStack=[],this._renderer=e}push(e,t,s){this._renderer.renderPipes.batch.break(s),s.add({renderPipeId:"stencilMask",action:"pushMaskBegin",mask:e,inverse:t._maskOptions.inverse,canBundle:!1})}pop(e,t,s){this._renderer.renderPipes.batch.break(s),s.add({renderPipeId:"stencilMask",action:"popMaskEnd",mask:e,inverse:t._maskOptions.inverse,canBundle:!1})}execute(e){if(e.action!=="pushMaskBegin"&&e.action!=="popMaskEnd")return;const t=this._renderer,s=t.canvasContext,r=s?.activeContext;if(!r)return;if(e.action==="popMaskEnd"){this._canvasMaskStack.pop()&&r.restore();return}e.inverse&&this._warnOnce("inverse","CanvasRenderer: inverse masks are not supported on Canvas2D; ignoring inverse flag.");const n=e.mask.mask;if(!(n instanceof Pe)){this._warnOnce("nonGraphics","CanvasRenderer: only Graphics masks are supported in Canvas2D; skipping mask."),this._canvasMaskStack.push(!1);return}const o=n,a=o.context?.instructions;if(!a?.length){this._canvasMaskStack.push(!1);return}r.save(),s.setContextTransform(o.groupTransform,(t._roundPixels|o._roundPixels)===1),r.beginPath();let l=!1,h=!1;for(let c=0;c<a.length;c++){const u=a[c],d=u.action;if(d!=="fill"&&d!=="stroke")continue;const f=u.data,p=f?.path?.shapePath;if(!p?.shapePrimitives?.length)continue;const m=d==="stroke",g=p.shapePrimitives;for(let _=0;_<g.length;_++){const y=g[_];if(!y?.shape)continue;const x=y.transform,b=x&&!x.isIdentity();b&&(r.save(),r.transform(x.a,x.b,x.c,x.d,x.tx,x.ty)),m&&f.style?l=Cy(r,y.shape,f.style)||l:(Gp(r,y.shape),h=ky(r,y.holes)||h,l=!0),b&&r.restore()}}if(!l){r.restore(),this._canvasMaskStack.push(!1);return}h?r.clip("evenodd"):r.clip(),this._canvasMaskStack.push(!0)}destroy(){this._renderer=null,this._warnedMaskTypes=null,this._canvasMaskStack=null}_warnOnce(e,t){this._warnedMaskTypes.has(e)||(this._warnedMaskTypes.add(e),z(t))}}ll.extension={type:[S.CanvasPipes],name:"stencilMask"};class hl{constructor(e){this._maskHash=new WeakMap,this._renderer=e}push(e,t,s){const r=e,n=this._renderer;n.renderPipes.batch.break(s),n.renderPipes.blendMode.setBlendMode(r.mask,"none",s),s.add({renderPipeId:"stencilMask",action:"pushMaskBegin",mask:e,inverse:t._maskOptions.inverse,canBundle:!1});const o=r.mask;o.includeInBuild=!0,this._maskHash.has(r)||this._maskHash.set(r,{instructionsStart:0,instructionsLength:0});const a=this._maskHash.get(r);a.instructionsStart=s.instructionSize,o.collectRenderables(s,n,null),o.includeInBuild=!1,n.renderPipes.batch.break(s),s.add({renderPipeId:"stencilMask",action:"pushMaskEnd",mask:e,inverse:t._maskOptions.inverse,canBundle:!1});const l=s.instructionSize-a.instructionsStart-1;a.instructionsLength=l}pop(e,t,s){const r=e,n=this._renderer;n.renderPipes.batch.break(s),n.renderPipes.blendMode.setBlendMode(r.mask,"none",s),s.add({renderPipeId:"stencilMask",action:"popMaskBegin",inverse:t._maskOptions.inverse,canBundle:!1});const o=this._maskHash.get(e);for(let a=0;a<o.instructionsLength;a++)s.instructions[s.instructionSize++]=s.instructions[o.instructionsStart++];s.add({renderPipeId:"stencilMask",action:"popMaskEnd",canBundle:!1})}execute(e){const s=this._renderer,r=s.renderTarget.getGpuRenderTarget(s.renderTarget.renderTarget);let n=r.maskStackIndex;e.action==="pushMaskBegin"?(s.renderTarget.ensureDepthStencil(),s.stencil.setStencilMode(me.RENDERING_MASK_ADD,n),n++,s.colorMask.setMask(0)):e.action==="pushMaskEnd"?(e.inverse?s.stencil.setStencilMode(me.INVERSE_MASK_ACTIVE,n):s.stencil.setStencilMode(me.MASK_ACTIVE,n),s.colorMask.setMask(15)):e.action==="popMaskBegin"?(s.colorMask.setMask(0),n!==0?s.stencil.setStencilMode(me.RENDERING_MASK_REMOVE,n):(s.renderTarget.clear(null,ye.STENCIL),s.stencil.setStencilMode(me.DISABLED,n)),n--):e.action==="popMaskEnd"&&(e.inverse?s.stencil.setStencilMode(me.INVERSE_MASK_ACTIVE,n):s.stencil.setStencilMode(me.MASK_ACTIVE,n),s.colorMask.setMask(15)),r.maskStackIndex=n}destroy(){this._renderer=null,this._maskHash=null}}hl.extension={type:[S.WebGLPipes,S.WebGPUPipes],name:"stencilMask"};const he="source-over";function Dp(){const i=Oa(),e=Object.create(null);return e.inherit=he,e.none=he,e.normal="source-over",e.add="lighter",e.multiply=i?"multiply":he,e.screen=i?"screen":he,e.overlay=i?"overlay":he,e.darken=i?"darken":he,e.lighten=i?"lighten":he,e["color-dodge"]=i?"color-dodge":he,e["color-burn"]=i?"color-burn":he,e["hard-light"]=i?"hard-light":he,e["soft-light"]=i?"soft-light":he,e.difference=i?"difference":he,e.exclusion=i?"exclusion":he,e.saturation=i?"saturation":he,e.color=i?"color":he,e.luminosity=i?"luminosity":he,e["linear-burn"]=i?"color-burn":he,e["linear-dodge"]=i?"color-dodge":he,e["linear-light"]=i?"hard-light":he,e["pin-light"]=i?"hard-light":he,e["vivid-light"]=i?"hard-light":he,e["hard-mix"]=he,e.negation=i?"difference":he,e["normal-npm"]=e.normal,e["add-npm"]=e.add,e["screen-npm"]=e.screen,e.erase="destination-out",e.subtract=he,e.divide=he,e.min=he,e.max=he,e}const Ey=new L;class cl{constructor(e){this.activeResolution=1,this.smoothProperty="imageSmoothingEnabled",this.blendModes=Dp(),this._activeBlendMode="normal",this._projTransform=null,this._outerBlend=!1,this._warnedBlendModes=new Set,this._renderer=e}resolutionChange(e){this.activeResolution=e}init(){const e=this._renderer.background.alpha<1;if(this.rootContext=this._renderer.canvas.getContext("2d",{alpha:e}),this.activeContext=this.rootContext,this.activeResolution=this._renderer.resolution,!this.rootContext.imageSmoothingEnabled){const t=this.rootContext;t.webkitImageSmoothingEnabled?this.smoothProperty="webkitImageSmoothingEnabled":t.mozImageSmoothingEnabled?this.smoothProperty="mozImageSmoothingEnabled":t.oImageSmoothingEnabled?this.smoothProperty="oImageSmoothingEnabled":t.msImageSmoothingEnabled&&(this.smoothProperty="msImageSmoothingEnabled")}}setContextTransform(e,t,s,r){const n=r?L.IDENTITY:this._renderer.globalUniforms.globalUniformData?.worldTransformMatrix||L.IDENTITY;let o=Ey;o.copyFrom(n),o.append(e);const a=this._projTransform,l=this.activeResolution;if(s=s||l,a){const h=L.shared;h.copyFrom(o),h.prepend(a),o=h}t?this.activeContext.setTransform(o.a*s,o.b*s,o.c*s,o.d*s,o.tx*l|0,o.ty*l|0):this.activeContext.setTransform(o.a*s,o.b*s,o.c*s,o.d*s,o.tx*l,o.ty*l)}clear(e,t){const s=this.activeContext,r=this._renderer;if(s.clearRect(0,0,r.width,r.height),e){const n=le.shared.setValue(e);s.globalAlpha=t??n.alpha,s.fillStyle=n.toHex(),s.fillRect(0,0,r.width,r.height),s.globalAlpha=1}}setBlendMode(e){if(this._activeBlendMode===e)return;this._activeBlendMode=e,this._outerBlend=!1;const t=this.blendModes[e];if(!t){this._warnedBlendModes.has(e)||(console.warn(`CanvasRenderer: blend mode "${e}" is not supported in Canvas2D; falling back to "source-over".`),this._warnedBlendModes.add(e)),this.activeContext.globalCompositeOperation="source-over";return}this.activeContext.globalCompositeOperation=t}destroy(){this.rootContext=null,this.activeContext=null,this._warnedBlendModes.clear()}}cl.extension={type:[S.CanvasSystem],name:"canvasContext"};class ul{constructor(){this.maxTextures=16,this.maxBatchableTextures=16,this.maxUniformBindings=0}init(){}}ul.extension={type:[S.CanvasSystem],name:"limits"};class Wr{constructor(e){this._renderer=e}updateRenderable(){}destroyRenderable(){}validateRenderable(){return!1}addRenderable(e,t){this._renderer.renderPipes.batch.break(t),t.add(e)}execute(e){e.isRenderable&&e.render(this._renderer)}destroy(){this._renderer=null}}Wr.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"customRender"};function mr(i,e){const t=i.instructionSet,s=t.instructions;for(let r=0;r<t.instructionSize;r++){const n=s[r];e[n.renderPipeId].execute(n)}}class $r{constructor(e){this._renderer=e}addRenderGroup(e,t){e.isCachedAsTexture?this._addRenderableCacheAsTexture(e,t):this._addRenderableDirect(e,t)}execute(e){e.isRenderable&&(e.isCachedAsTexture?this._executeCacheAsTexture(e):this._executeDirect(e))}destroy(){this._renderer=null}_addRenderableDirect(e,t){this._renderer.renderPipes.batch.break(t),e._batchableRenderGroup&&(Se.return(e._batchableRenderGroup),e._batchableRenderGroup=null),t.add(e)}_addRenderableCacheAsTexture(e,t){const s=e._batchableRenderGroup??(e._batchableRenderGroup=Se.get(Nr));s.renderable=e.root,s.transform=e.root.relativeGroupTransform,s.texture=e.texture,s.bounds=e._textureBounds,t.add(e),this._renderer.renderPipes.blendMode.pushBlendMode(e,e.root.groupBlendMode,t),this._renderer.renderPipes.batch.addToBatch(s,t),this._renderer.renderPipes.blendMode.popBlendMode(t)}_executeCacheAsTexture(e){if(e.textureNeedsUpdate){e.textureNeedsUpdate=!1;const t=new L().translate(-e._textureBounds.x,-e._textureBounds.y);this._renderer.renderTarget.push({target:e.texture,clear:!0,frame:e.texture.frame}),this._renderer.globalUniforms.push({worldTransformMatrix:t,worldColor:4294967295,offset:{x:0,y:0}}),mr(e,this._renderer.renderPipes),this._renderer.renderTarget.finishRenderPass(),this._renderer.renderTarget.pop(),this._renderer.globalUniforms.pop()}e._batchableRenderGroup._batcher.updateElement(e._batchableRenderGroup),e._batchableRenderGroup._batcher.geometry.buffers[0].update()}_executeDirect(e){this._renderer.globalUniforms.push({worldTransformMatrix:e.inverseParentTextureTransform,worldColor:e.worldColorAlpha}),mr(e,this._renderer.renderPipes),this._renderer.globalUniforms.pop()}}$r.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"renderGroup"};const Py="#808080",Vi=new L,Ay=new L,Ry=new L,Dn=new L,By=new L;function Iy(i,e,t){i.beginPath();for(let s=0;s<t.length;s+=3){const r=t[s]*2,n=t[s+1]*2,o=t[s+2]*2;i.moveTo(e[r],e[r+1]),i.lineTo(e[n],e[n+1]),i.lineTo(e[o],e[o+1]),i.closePath()}i.fill()}function Gy(i){return`#${(i&16777215).toString(16).padStart(6,"0")}`}function Dy(i,e,t,s,r,n){n=Math.max(0,Math.min(n,Math.min(s,r)/2)),i.moveTo(e+n,t),i.lineTo(e+s-n,t),i.quadraticCurveTo(e+s,t,e+s,t+n),i.lineTo(e+s,t+r-n),i.quadraticCurveTo(e+s,t+r,e+s-n,t+r),i.lineTo(e+n,t+r),i.quadraticCurveTo(e,t+r,e,t+r-n),i.lineTo(e,t+n),i.quadraticCurveTo(e,t,e+n,t)}function er(i,e){switch(e.type){case"rectangle":{const t=e;i.rect(t.x,t.y,t.width,t.height);break}case"roundedRectangle":{const t=e;Dy(i,t.x,t.y,t.width,t.height,t.radius);break}case"circle":{const t=e;i.arc(t.x,t.y,t.radius,0,Math.PI*2);break}case"ellipse":{const t=e;i.ellipse?i.ellipse(t.x,t.y,t.halfWidth,t.halfHeight,0,0,Math.PI*2):(i.save(),i.translate(t.x,t.y),i.scale(t.halfWidth,t.halfHeight),i.arc(0,0,1,0,Math.PI*2),i.restore());break}case"triangle":{const t=e;i.moveTo(t.x,t.y),i.lineTo(t.x2,t.y2),i.lineTo(t.x3,t.y3),i.closePath();break}case"polygon":default:{const t=e,s=t.points;if(!s?.length)break;i.moveTo(s[0],s[1]);for(let r=2;r<s.length;r+=2)i.lineTo(s[r],s[r+1]);t.closePath&&i.closePath();break}}}function Fy(i,e){if(!e?.length)return!1;for(let t=0;t<e.length;t++){const s=e[t];if(!s?.shape)continue;const r=s.transform,n=r&&!r.isIdentity();n&&(i.save(),i.transform(r.a,r.b,r.c,r.d,r.tx,r.ty)),er(i,s.shape),n&&i.restore()}return!0}function Oy(i,e,t,s){const r=i.fill;if(r instanceof Xe){r.buildGradient();const o=r.texture;if(o){const a=K.getTintedPattern(o,e),l=t?Dn.copyFrom(t).scale(o.source.pixelWidth,o.source.pixelHeight):Dn.copyFrom(r.transform);return s&&!i.textureSpace&&l.append(s),K.applyPatternTransform(a,l),a}}if(r instanceof Us){const o=K.getTintedPattern(r.texture,e);return K.applyPatternTransform(o,r.transform,!1),o}const n=i.texture;if(n&&n!==H.WHITE){if(!n.source.resource)return Py;const o=K.getTintedPattern(n,e);let a=i.matrix;if(t){const{resolution:l}=n.source;if(a=Dn.copyFrom(t),n.rotate){const{uvs:h,orig:c}=n;a.prepend(By.set(h.x1-h.x0,h.y1-h.y0,h.x3-h.x0,h.y3-h.y0,h.x0,h.y0).invert()).scale(c.width*l,c.height*l)}else a.scale(n.source.pixelWidth,n.source.pixelHeight).translate(-n.frame.x*l,-n.frame.y*l)}return K.applyPatternTransform(o,a),o}return Gy(e)}class dl{constructor(){this.shader=null}contextChange(e){}execute(e,t){const s=e.renderer,r=s.canvasContext,n=r.activeContext,o=t.groupTransform,a=s.globalUniforms.globalUniformData?.worldColor??4294967295,l=t.groupColorAlpha,h=(a>>>24&255)/255,c=(l>>>24&255)/255,u=s.filter?.alphaMultiplier??1,d=h*c*u;if(d<=0)return;const f=a&16777215,p=l&16777215,m=ss(ts(p,f)),g=s._roundPixels|t._roundPixels;n.save(),r.setContextTransform(o,g===1),r.setBlendMode(t.groupBlendMode);const _=t.context.instructions;for(let y=0;y<_.length;y++){const x=_[y];if(x.action==="texture"){const k=x.data,I=k.image,G=I?K.getCanvasSource(I):null;if(!G)continue;const F=k.alpha*d;if(F<=0)continue;const X=ts(k.style,m);n.globalAlpha=F;let M=G;X!==16777215&&(M=K.getTintedCanvas({texture:I},X));const C=I.frame,B=I.source._resolution??I.source.resolution??1;let R=C.x*B,O=C.y*B;const U=C.width*B,q=C.height*B;M!==G&&(R=0,O=0);const J=k.transform,ie=J&&!J.isIdentity(),V=I.rotate;ie||V?(Vi.copyFrom(o),ie&&Vi.append(J),V&&Q.matrixAppendRotationInv(Vi,V,k.dx,k.dy,k.dw,k.dh),r.setContextTransform(Vi,g===1)):r.setContextTransform(o,g===1),n.drawImage(M,R,O,M===G?U:M.width,M===G?q:M.height,V?0:k.dx,V?0:k.dy,k.dw,k.dh),(ie||V)&&r.setContextTransform(o,g===1);continue}const b=x.data,v=b?.path?.shapePath;if(!v?.shapePrimitives?.length)continue;const w=b.style,T=ts(w.color,m),E=w.alpha*d;if(E<=0)continue;const P=x.action==="stroke";if(n.globalAlpha=E,P){const k=w;n.lineWidth=k.width,n.lineCap=k.cap,n.lineJoin=k.join,n.miterLimit=k.miterLimit}const A=v.shapePrimitives;if(!P&&b.hole?.shapePath?.shapePrimitives?.length){const k=A[A.length-1];k.holes=b.hole.shapePath.shapePrimitives}for(let k=0;k<A.length;k++){const I=A[k];if(!I?.shape)continue;const G=I.transform,F=G&&!G.isIdentity(),X=w.texture&&w.texture!==H.WHITE,M=w.textureSpace==="global"?G:null,C=X?Aa(Ay,w,I.shape,M):null,B=F?Ry.copyFrom(o).append(G):o,R=Oy(w,T,C,B);if(F&&(n.save(),n.transform(G.a,G.b,G.c,G.d,G.tx,G.ty)),P){const O=w;if(O.alignment!==.5&&!O.pixelLine){const q=[],J=[],ie=[];if(ps[I.shape.type]?.build(I.shape,q)){const Je=I.shape.closePath??!0;Lr(q,O,!1,Je,J,ie),n.fillStyle=R,Iy(n,J,ie)}else n.strokeStyle=R,n.beginPath(),er(n,I.shape),n.stroke()}else n.strokeStyle=R,n.beginPath(),er(n,I.shape),n.stroke()}else n.fillStyle=R,n.beginPath(),er(n,I.shape),Fy(n,I.holes)?n.fill("evenodd"):n.fill();F&&n.restore()}}n.restore()}destroy(){this.shader=null}}dl.extension={type:[S.CanvasPipesAdaptor],name:"graphics"};class Vr{constructor(e){this._renderer=e}addRenderable(e,t){const s=this._getGpuSprite(e);e.didViewUpdate&&this._updateBatchableSprite(e,s),this._renderer.renderPipes.batch.addToBatch(s,t)}updateRenderable(e){const t=this._getGpuSprite(e);e.didViewUpdate&&this._updateBatchableSprite(e,t),t._batcher.updateElement(t)}validateRenderable(e){const t=this._getGpuSprite(e);return!t._batcher.checkAndUpdateTexture(t,e._texture)}_updateBatchableSprite(e,t){t.bounds=e.visualBounds,t.texture=e._texture}_getGpuSprite(e){return e._gpuData[this._renderer.uid]||this._initGPUSprite(e)}_initGPUSprite(e){const t=new Nr;return t.renderable=e,t.transform=e.groupTransform,t.texture=e._texture,t.bounds=e.visualBounds,t.roundPixels=this._renderer._roundPixels|e._roundPixels,e._gpuData[this._renderer.uid]=t,t}destroy(){this._renderer=null}}Vr.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"sprite"};const ai={};Y.handle(S.BlendMode,i=>{if(!i.name)throw new Error("BlendMode extension must have a name property");ai[i.name]=i.ref},i=>{delete ai[i.name]});class jr{constructor(e){this._blendModeStack=[],this._isAdvanced=!1,this._filterHash=Object.create(null),this._renderer=e,this._renderer.runners.prerender.add(this)}prerender(){this._activeBlendMode="normal",this._isAdvanced=!1}pushBlendMode(e,t,s){this._blendModeStack.push(t),this.setBlendMode(e,t,s)}popBlendMode(e){this._blendModeStack.pop();const t=this._blendModeStack[this._activeBlendMode.length-1]??"normal";this.setBlendMode(null,t,e)}setBlendMode(e,t,s){const r=e instanceof hr;if(this._activeBlendMode===t){this._isAdvanced&&e&&!r&&this._renderableList?.push(e);return}this._isAdvanced&&this._endAdvancedBlendMode(s),this._activeBlendMode=t,e&&(this._isAdvanced=!!ai[t],this._isAdvanced&&this._beginAdvancedBlendMode(e,s))}_beginAdvancedBlendMode(e,t){this._renderer.renderPipes.batch.break(t);const s=this._activeBlendMode;if(!ai[s]){z(`Unable to assign BlendMode: '${s}'. You may want to include: import 'pixi.js/advanced-blend-modes'`);return}const r=this._ensureFilterEffect(s),n=e instanceof hr,o={renderPipeId:"filter",action:"pushFilter",filterEffect:r,renderables:n?null:[e],container:n?e.root:null,canBundle:!1};this._renderableList=o.renderables,t.add(o)}_ensureFilterEffect(e){let t=this._filterHash[e];return t||(t=this._filterHash[e]=new ui,t.filters=[new ai[e]]),t}_endAdvancedBlendMode(e){this._isAdvanced=!1,this._renderableList=null,this._renderer.renderPipes.batch.break(e),e.add({renderPipeId:"filter",action:"popFilter",canBundle:!1})}buildStart(){this._isAdvanced=!1}buildEnd(e){this._isAdvanced&&this._endAdvancedBlendMode(e)}destroy(){this._renderer=null,this._renderableList=null;for(const e in this._filterHash)this._filterHash[e].destroy();this._filterHash=null}}jr.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"blendMode"};function gr(i,e){e||(e=0);for(let t=e;t<i.length&&i[t];t++)i[t]=null}const Ly=new _e,Fc=ks|fi|Mr;function fl(i,e=!1){Fp(i);const t=i.childrenToUpdate,s=i.updateTick++;for(const r in t){const n=Number(r),o=t[r],a=o.list,l=o.index;for(let h=0;h<l;h++){const c=a[h];c.parentRenderGroup===i&&c.relativeRenderGroupDepth===n&&pl(c,s,0)}gr(a,l),o.index=0}if(e)for(let r=0;r<i.renderGroupChildren.length;r++)fl(i.renderGroupChildren[r],e)}function Fp(i){const e=i.root;let t;if(i.renderGroupParent){const s=i.renderGroupParent;i.worldTransform.appendFrom(e.relativeGroupTransform,s.worldTransform),i.worldColor=di(e.groupColor,s.worldColor),t=e.groupAlpha*s.worldAlpha}else i.worldTransform.copyFrom(e.localTransform),i.worldColor=e.localColor,t=e.localAlpha;t=t<0?0:t>1?1:t,i.worldAlpha=t,i.worldColorAlpha=i.worldColor+((t*255|0)<<24)}function pl(i,e,t){if(e===i.updateTick)return;i.updateTick=e,i.didChange=!1;const s=i.localTransform;i.updateLocalTransform();const r=i.parent;if(r&&!r.renderGroup?(t|=i._updateFlags,i.relativeGroupTransform.appendFrom(s,r.relativeGroupTransform),t&Fc&&Oc(i,r,t)):(t=i._updateFlags,i.relativeGroupTransform.copyFrom(s),t&Fc&&Oc(i,Ly,t)),!i.renderGroup){const n=i.children,o=n.length;for(let h=0;h<o;h++)pl(n[h],e,t);const a=i.parentRenderGroup,l=i;l.renderPipeId&&!a.structureDidChange&&a.updateRenderable(l)}}function Oc(i,e,t){if(t&fi){i.groupColor=di(i.localColor,e.groupColor);let s=i.localAlpha*e.groupAlpha;s=s<0?0:s>1?1:s,i.groupAlpha=s,i.groupColorAlpha=i.groupColor+((s*255|0)<<24)}t&Mr&&(i.groupBlendMode=i.localBlendMode==="inherit"?e.groupBlendMode:i.localBlendMode),t&ks&&(i.globalDisplayStatus=i.localDisplayStatus&e.globalDisplayStatus),i._updateFlags=0}function Op(i,e){const{list:t}=i.childrenRenderablesToUpdate;let s=!1;for(let r=0;r<i.childrenRenderablesToUpdate.index;r++){const n=t[r];if(s=e[n.renderPipeId].validateRenderable(n),s)break}return i.structureDidChange=s,s}const Uy=new L;class ml{constructor(e){this._renderer=e}render({container:e,transform:t}){const s=e.parent,r=e.renderGroup.renderGroupParent;e.parent=null,e.renderGroup.renderGroupParent=null;const n=this._renderer,o=Uy;t&&(o.copyFrom(e.renderGroup.localTransform),e.renderGroup.localTransform.copyFrom(t));const a=n.renderPipes;this._updateCachedRenderGroups(e.renderGroup,null),this._updateRenderGroups(e.renderGroup),n.globalUniforms.start({worldTransformMatrix:t?e.renderGroup.localTransform:e.renderGroup.worldTransform,worldColor:e.renderGroup.worldColorAlpha}),mr(e.renderGroup,a),a.uniformBatch&&a.uniformBatch.renderEnd(),t&&e.renderGroup.localTransform.copyFrom(o),e.parent=s,e.renderGroup.renderGroupParent=r}destroy(){this._renderer=null}_updateCachedRenderGroups(e,t){if(e._parentCacheAsTextureRenderGroup=t,e.isCachedAsTexture){if(!e.textureNeedsUpdate)return;t=e}for(let s=e.renderGroupChildren.length-1;s>=0;s--)this._updateCachedRenderGroups(e.renderGroupChildren[s],t);if(e.invalidateMatrices(),e.isCachedAsTexture){if(e.textureNeedsUpdate){const s=e.root.getLocalBounds(),r=this._renderer,n=e.textureOptions.resolution||r.view.resolution,o=e.textureOptions.antialias??r.view.antialias,a=e.textureOptions.scaleMode??"linear",l=e.texture;s.ceil(),e.texture&&Te.returnTexture(e.texture);const h=Te.getOptimalTexture({width:s.width,height:s.height,resolution:n,antialias:o,scaleMode:a});e.texture=h,e._textureBounds||(e._textureBounds=new Ee),e._textureBounds.copyFrom(s),l!==e.texture&&e.renderGroupParent&&(e.renderGroupParent.structureDidChange=!0)}}else e.texture&&(Te.returnTexture(e.texture),e.texture=null)}_updateRenderGroups(e){const t=this._renderer,s=t.renderPipes;if(e.runOnRender(t),e.instructionSet.renderPipes=s,e.structureDidChange?gr(e.childrenRenderablesToUpdate.list,0):Op(e,s),fl(e),e.structureDidChange?(e.structureDidChange=!1,this._buildInstructions(e,t)):this._updateRenderables(e),e.childrenRenderablesToUpdate.index=0,t.renderPipes.batch.upload(e.instructionSet),!(e.isCachedAsTexture&&!e.textureNeedsUpdate))for(let r=0;r<e.renderGroupChildren.length;r++)this._updateRenderGroups(e.renderGroupChildren[r])}_updateRenderables(e){const{list:t,index:s}=e.childrenRenderablesToUpdate;for(let r=0;r<s;r++){const n=t[r];n.didViewUpdate&&e.updateRenderable(n)}gr(t,s)}_buildInstructions(e,t){const s=e.root,r=e.instructionSet;r.reset();const n=t.renderPipes?t:t.batch.renderer,o=n.renderPipes;o.batch.buildStart(r),o.blendMode.buildStart(),o.colorMask.buildStart(),s.sortableChildren&&s.sortChildren(),s.collectRenderablesWithEffects(r,n,null),o.batch.buildEnd(r),o.blendMode.buildEnd(r)}}ml.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"renderGroup"};const gl=class Lp{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new le(0),this.color=this._backgroundColor,this.alpha=1}init(e){e={...Lp.defaultOptions,...e},this.clearBeforeRender=e.clearBeforeRender,this.color=e.background||e.backgroundColor||this._backgroundColor,this.alpha=e.backgroundAlpha,this._backgroundColor.setAlpha(e.backgroundAlpha)}get color(){return this._backgroundColor}set color(e){le.shared.setValue(e).alpha<1&&this._backgroundColor.alpha===1&&z("Cannot set a transparent background on an opaque canvas. To enable transparency, set backgroundAlpha < 1 when initializing your Application."),this._backgroundColor.setValue(e)}get alpha(){return this._backgroundColor.alpha}set alpha(e){this._backgroundColor.setAlpha(e)}get colorRgba(){return this._backgroundColor.toArray()}destroy(){}};gl.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"background",priority:0};gl.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0};let Up=gl;const Fn={png:"image/png",jpg:"image/jpeg",webp:"image/webp"},_l=class Np{constructor(e){this._renderer=e}_normalizeOptions(e,t={}){return e instanceof _e||e instanceof H?{target:e,...t}:{...t,...e}}async image(e){const t=te.get().createImage();return t.src=await this.base64(e),t}async base64(e){e=this._normalizeOptions(e,Np.defaultImageOptions);const{format:t,quality:s}=e,r=this.canvas(e);if(r.toBlob!==void 0)return new Promise((n,o)=>{r.toBlob(a=>{if(!a){o(new Error("ICanvas.toBlob failed!"));return}const l=new FileReader;l.onload=()=>n(l.result),l.onerror=o,l.readAsDataURL(a)},Fn[t],s)});if(r.toDataURL!==void 0)return r.toDataURL(Fn[t],s);if(r.convertToBlob!==void 0){const n=await r.convertToBlob({type:Fn[t],quality:s});return new Promise((o,a)=>{const l=new FileReader;l.onload=()=>o(l.result),l.onerror=a,l.readAsDataURL(n)})}throw new Error("Extract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented")}canvas(e){e=this._normalizeOptions(e);const t=e.target,s=this._renderer;if(t instanceof H)return s.texture.generateCanvas(t);const r=s.textureGenerator.generateTexture(e),n=s.texture.generateCanvas(r);return r.destroy(!0),n}pixels(e){e=this._normalizeOptions(e);const t=e.target,s=this._renderer,r=t instanceof H?t:s.textureGenerator.generateTexture(e),n=s.texture.getPixels(r);return t instanceof _e&&r.destroy(!0),n}texture(e){return e=this._normalizeOptions(e),e.target instanceof H?e.target:this._renderer.textureGenerator.generateTexture(e)}download(e){e=this._normalizeOptions(e);const t=this.canvas(e),s=document.createElement("a");s.download=e.filename??"image.png",s.href=t.toDataURL("image/png"),document.body.appendChild(s),s.click(),document.body.removeChild(s)}log(e){const t=e.width??200;e=this._normalizeOptions(e);const s=this.canvas(e),r=s.toDataURL();console.log(`[Pixi Texture] ${s.width}px ${s.height}px`);const n=["font-size: 1px;",`padding: ${t}px 300px;`,`background: url(${r}) no-repeat;`,"background-size: contain;"].join(" ");console.log("%c ",n)}destroy(){this._renderer=null}};_l.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"extract"};_l.defaultImageOptions={format:"png",quality:1};let zp=_l;class Ci extends H{static create(e){const{dynamic:t,textureOptions:s,...r}=e;return new Ci({...s,source:new ue(r),dynamic:t??!1})}resize(e,t,s){return this.source.resize(e,t,s),this}}const Ny=new se,zy=new Ee,Hy=[0,0,0,0];class yl{constructor(e){this._renderer=e}generateTexture(e){e instanceof _e&&(e={target:e,frame:void 0,textureSourceOptions:{},resolution:void 0});const t=e.resolution||this._renderer.resolution,s=e.antialias||this._renderer.view.antialias,r=e.target;let n=e.clearColor;n?n=Array.isArray(n)&&n.length===4?n:le.shared.setValue(n).toArray():n=Hy;const o=e.frame?.copyTo(Ny)||Tr(r,zy).rectangle,a=e.defaultAnchor&&{defaultAnchor:e.defaultAnchor};o.width=Math.max(o.width,1/t)|0,o.height=Math.max(o.height,1/t)|0;const l=Ci.create({...e.textureSourceOptions,width:o.width,height:o.height,resolution:t,antialias:s,textureOptions:a}),h=L.shared.translate(-o.x,-o.y);return this._renderer.render({container:r,transform:h,target:l,clearColor:n}),l.source.updateMipmaps(),l}destroy(){this._renderer=null}}yl.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"textureGenerator"};function Hp(i){let e=!1;for(const s in i)if(i[s]==null){e=!0;break}if(!e)return i;const t=Object.create(null);for(const s in i){const r=i[s];r&&(t[s]=r)}return t}function Wp(i){let e=0;for(let t=0;t<i.length;t++)i[t]==null?e++:i[t-e]=i[t];return i.length-=e,i}const xl=class $p{constructor(e){this._managedResources=[],this._managedResourceHashes=[],this._managedCollections=[],this._ready=!1,this._running=!1,this._renderer=e}init(e){e={...$p.defaultOptions,...e},this.maxUnusedTime=e.gcMaxUnusedTime,this._frequency=e.gcFrequency,this.enabled=e.gcActive,this.now=performance.now()}get enabled(){return!!this._handler}set enabled(e){this.enabled!==e&&(e?(this._handler=this._renderer.scheduler.repeat(()=>{this._ready=!0},this._frequency,!1),this._collectionsHandler=this._renderer.scheduler.repeat(()=>{for(const t of this._managedCollections){const{context:s,collection:r,type:n}=t;n==="hash"?s[r]=Hp(s[r]):s[r]=Wp(s[r])}},this._frequency)):(this._renderer.scheduler.cancel(this._handler),this._renderer.scheduler.cancel(this._collectionsHandler),this._handler=0,this._collectionsHandler=0))}prerender({container:e}){this.now=performance.now(),e.renderGroup.gcTick=this._renderer.tick++,this._updateInstructionGCTick(e.renderGroup,e.renderGroup.gcTick)}postrender(){!this._ready||!this.enabled||(this.run(),this._ready=!1)}_updateInstructionGCTick(e,t){e.instructionSet.gcTick=t,e.gcTick=t;for(const s of e.renderGroupChildren)this._updateInstructionGCTick(s,t)}addCollection(e,t,s){this._managedCollections.push({context:e,collection:t,type:s})}addResource(e,t){if(e._gcLastUsed!==-1){e._gcLastUsed=this.now,e._onTouch?.(this.now);return}const s=this._managedResources.length;e._gcData={index:s,type:t},e._gcLastUsed=this.now,e._onTouch?.(this.now),e.once("unload",this.removeResource,this),this._managedResources.push(e)}removeResource(e){const t=e._gcData;if(!t)return;const s=t.index,r=this._managedResources.length-1;if(this._running)this._managedResources[s]=null;else{if(s!==r){const n=this._managedResources[r];this._managedResources[s]=n,n._gcData.index=s}this._managedResources.length--}e._gcData=null,e._gcLastUsed=-1}addResourceHash(e,t,s,r=0){this._managedResourceHashes.push({context:e,hash:t,type:s,priority:r}),this._managedResourceHashes.sort((n,o)=>n.priority-o.priority)}run(){if(this._running)return;const e=performance.now(),t=this._managedResourceHashes,s=this._managedResources;this._running=!0;try{for(const n of t)this.runOnHash(n,e);const r=s.length;for(let n=0;n<r;n++){const o=s[n];o&&this.runOnResource(o,e)}}finally{let r=0;for(let n=0;n<s.length;n++){const o=s[n];o&&(r!==n&&(s[r]=o,o._gcData.index=r),r++)}s.length=r,this._running=!1}}updateRenderableGCTick(e,t){const s=e.renderGroup??e.parentRenderGroup,r=s?.instructionSet?.gcTick??-1;(s?.gcTick??0)===r&&(e._gcLastUsed=t,e._onTouch?.(t))}runOnResource(e,t){e._gcData.type==="renderable"&&this.updateRenderableGCTick(e,t),!(t-e._gcLastUsed<this.maxUnusedTime||!e.autoGarbageCollect)&&(e.off("unload",this.removeResource,this),e.unload(),this.removeResource(e))}_createHashClone(e,t){const s=Object.create(null);for(const r in e){if(r===t)break;e[r]!==null&&(s[r]=e[r])}return s}runOnHash(e,t){const{context:s,hash:r,type:n}=e,o=s[r];let a=null,l=0;for(const h in o){const c=o[h];if(c===null){l++,l===1e4&&!a&&(a=this._createHashClone(o,h));continue}if(c._gcLastUsed===-1){c._gcLastUsed=t,c._onTouch?.(t),a&&(a[h]=c);continue}if(n==="renderable"&&this.updateRenderableGCTick(c,t),!(t-c._gcLastUsed<this.maxUnusedTime)&&c.autoGarbageCollect){if(n==="renderable"){const d=c,f=d.renderGroup??d.parentRenderGroup;f&&(f.structureDidChange=!0)}c.unload(),c._gcData=null,c._gcLastUsed=-1,a||(l+1!==1e4?(o[h]=null,l++):a=this._createHashClone(o,h))}else a&&(a[h]=c)}a&&(s[r]=a)}destroy(){this.enabled=!1,this._managedResources.forEach(e=>{e?.off("unload",this.removeResource,this)}),this._managedResources.length=0,this._managedResourceHashes.length=0,this._managedCollections.length=0,this._renderer=null}};xl.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"gc",priority:0};xl.defaultOptions={gcActive:!0,gcMaxUnusedTime:6e4,gcFrequency:3e4};let Vp=xl;class bl{constructor(e){this._stackIndex=0,this._globalUniformDataStack=[],this._uniformsPool=[],this._activeUniforms=[],this._bindGroupPool=[],this._activeBindGroups=[],this._renderer=e}reset(){this._stackIndex=0;for(let e=0;e<this._activeUniforms.length;e++)this._uniformsPool.push(this._activeUniforms[e]);for(let e=0;e<this._activeBindGroups.length;e++)this._bindGroupPool.push(this._activeBindGroups[e]);this._activeUniforms.length=0,this._activeBindGroups.length=0}start(e){this.reset(),this.push(e)}bind({size:e,projectionMatrix:t,worldTransformMatrix:s,worldColor:r,offset:n}){const o=this._renderer.renderTarget.renderTarget,a=this._stackIndex?this._globalUniformDataStack[this._stackIndex-1]:{worldTransformMatrix:new L,worldColor:4294967295,offset:new ce},l={projectionMatrix:t||this._renderer.renderTarget.projectionMatrix,resolution:e||o.size,worldTransformMatrix:s||a.worldTransformMatrix,worldColor:r||a.worldColor,offset:n||a.offset,bindGroup:null},h=this._uniformsPool.pop()||this._createUniforms();this._activeUniforms.push(h);const c=h.uniforms;c.uProjectionMatrix=l.projectionMatrix,c.uResolution=l.resolution,c.uWorldTransformMatrix.copyFrom(l.worldTransformMatrix),c.uWorldTransformMatrix.tx-=l.offset.x,c.uWorldTransformMatrix.ty-=l.offset.y,Ha(l.worldColor,c.uWorldColorAlpha,0),h.update();let u;this._renderer.renderPipes.uniformBatch?u=this._renderer.renderPipes.uniformBatch.getUniformBindGroup(h,!1):(u=this._bindGroupPool.pop()||new At,this._activeBindGroups.push(u),u.setResource(h,0)),l.bindGroup=u,this._currentGlobalUniformData=l}push(e){this.bind(e),this._globalUniformDataStack[this._stackIndex++]=this._currentGlobalUniformData}pop(){this._currentGlobalUniformData=this._globalUniformDataStack[--this._stackIndex-1],this._renderer.type===Ze.WEBGL&&this._currentGlobalUniformData.bindGroup.resources[0].update()}get bindGroup(){return this._currentGlobalUniformData.bindGroup}get globalUniformData(){return this._currentGlobalUniformData}get uniformGroup(){return this._currentGlobalUniformData.bindGroup.resources[0]}_createUniforms(){return new Qe({uProjectionMatrix:{value:new L,type:"mat3x3<f32>"},uWorldTransformMatrix:{value:new L,type:"mat3x3<f32>"},uWorldColorAlpha:{value:new Float32Array(4),type:"vec4<f32>"},uResolution:{value:[0,0],type:"vec2<f32>"}},{isStatic:!0})}destroy(){this._renderer=null,this._globalUniformDataStack.length=0,this._uniformsPool.length=0,this._activeUniforms.length=0,this._bindGroupPool.length=0,this._activeBindGroups.length=0,this._currentGlobalUniformData=null}}bl.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"globalUniforms"};let Wy=1;class vl{constructor(){this._tasks=[],this._offset=0}init(){$e.system.add(this._update,this)}repeat(e,t,s=!0){const r=Wy++;let n=0;return s&&(this._offset+=1e3,n=this._offset),this._tasks.push({func:e,duration:t,start:performance.now(),offset:n,last:performance.now(),repeat:!0,id:r}),r}cancel(e){for(let t=0;t<this._tasks.length;t++)if(this._tasks[t].id===e){this._tasks.splice(t,1);return}}_update(){const e=performance.now();for(let t=0;t<this._tasks.length;t++){const s=this._tasks[t];if(e-s.offset-s.last>=s.duration){const r=e-s.start;s.func(r),s.last=e}}}destroy(){$e.system.remove(this._update,this),this._tasks.length=0}}vl.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"scheduler",priority:0};let Lc=!1;function jp(i){if(!Lc){if(te.get().getNavigator().userAgent.toLowerCase().indexOf("chrome")>-1){const e=[`%c %c %c %c %c PixiJS %c v${xi} (${i}) http://www.pixijs.com/
|
|
584
584
|
|
|
585
585
|
`,"background: #E72264; padding:5px 0;","background: #6CA2EA; padding:5px 0;","background: #B5D33D; padding:5px 0;","background: #FED23F; padding:5px 0;","color: #FFFFFF; background: #E72264; padding:5px 0;","color: #E72264; background: #FFFFFF; padding:5px 0;"];globalThis.console.log(...e)}else globalThis.console&&globalThis.console.log(`PixiJS ${xi} - ${i} - http://www.pixijs.com/`);Lc=!0}}class Xr{constructor(e){this._renderer=e}init(e){if(e.hello){let t=this._renderer.name;this._renderer.type===Ze.WEBGL&&(t+=` ${this._renderer.context.webGLVersion}`),jp(t)}}}Xr.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"hello",priority:-2};Xr.defaultOptions={hello:!1};const wl=class Xp{constructor(e){this._renderer=e}init(e){e={...Xp.defaultOptions,...e},this.maxUnusedTime=e.renderableGCMaxUnusedTime}get enabled(){return N("8.15.0","RenderableGCSystem.enabled is deprecated, please use the GCSystem.enabled instead."),this._renderer.gc.enabled}set enabled(e){N("8.15.0","RenderableGCSystem.enabled is deprecated, please use the GCSystem.enabled instead."),this._renderer.gc.enabled=e}addManagedHash(e,t){N("8.15.0","RenderableGCSystem.addManagedHash is deprecated, please use the GCSystem.addCollection instead."),this._renderer.gc.addCollection(e,t,"hash")}addManagedArray(e,t){N("8.15.0","RenderableGCSystem.addManagedArray is deprecated, please use the GCSystem.addCollection instead."),this._renderer.gc.addCollection(e,t,"array")}addRenderable(e){N("8.15.0","RenderableGCSystem.addRenderable is deprecated, please use the GCSystem instead."),this._renderer.gc.addResource(e,"renderable")}run(){N("8.15.0","RenderableGCSystem.run is deprecated, please use the GCSystem instead."),this._renderer.gc.run()}destroy(){this._renderer=null}};wl.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"renderableGC",priority:0};wl.defaultOptions={renderableGCActive:!0,renderableGCMaxUnusedTime:6e4,renderableGCFrequency:3e4};let qp=wl;const Tl=class tr{get count(){return this._renderer.tick}get checkCount(){return this._checkCount}set checkCount(e){N("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead."),this._checkCount=e}get maxIdle(){return this._renderer.gc.maxUnusedTime/1e3*60}set maxIdle(e){N("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead."),this._renderer.gc.maxUnusedTime=e/60*1e3}get checkCountMax(){return Math.floor(this._renderer.gc._frequency/1e3)}set checkCountMax(e){N("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead.")}get active(){return this._renderer.gc.enabled}set active(e){N("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead."),this._renderer.gc.enabled=e}constructor(e){this._renderer=e,this._checkCount=0}init(e){e.textureGCActive!==tr.defaultOptions.textureGCActive&&(this.active=e.textureGCActive),e.textureGCMaxIdle!==tr.defaultOptions.textureGCMaxIdle&&(this.maxIdle=e.textureGCMaxIdle),e.textureGCCheckCountMax!==tr.defaultOptions.textureGCCheckCountMax&&(this.checkCountMax=e.textureGCCheckCountMax)}run(){N("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead."),this._renderer.gc.run()}destroy(){this._renderer=null}};Tl.extension={type:[S.WebGLSystem,S.WebGPUSystem],name:"textureGC"};Tl.defaultOptions={textureGCActive:!0,textureGCAMaxIdle:null,textureGCMaxIdle:3600,textureGCCheckCountMax:600};let Yp=Tl;const Kp=class Zp extends Re{constructor(e={}){super(),this.uid=oe("renderTarget"),this.colorAttachments=[],this.dirtyId=0,this.isRoot=!1,this._size=new Float32Array(2),this._managedColorTextures=!1,this._depth=!1,this._stencil=!1,this._colorTextures=null;const t="colorAttachments"in e?e:this._normalizeOptions(e);if(this.isRoot=t.isRoot??!1,this.label=t.label,this.colorAttachments=t.colorAttachments,this.depthStencilAttachment=t.depthStencilAttachment,this.depthStencilAttachment){const s=this.depthStencilAttachment.texture.format;this._depth||(this._depth=s.includes("depth")),this._stencil||(this._stencil=s.includes("stencil"))}if(this.colorAttachments.length===0&&!this.depthStencilAttachment)throw new Error("[RenderTarget] no color textures or depth textures were provided. Provide a depthStencilTexture or set depth/stencil to true when using colorTextures: 0.");if(this.colorAttachments.length>0){const s=this.colorTexture;this.resize(s.width,s.height,s._resolution)}this.sizeSource&&this.sizeSource.on("resize",this.onSourceResize,this)}_normalizeOptions(e){const t={...Zp.defaultOptions,...e},s=[];let r;if(typeof t.colorTextures=="number"){if(t.colorTextures>0){this._managedColorTextures=!0;for(let o=0;o<t.colorTextures;o++)s.push({texture:new ue({width:t.width,height:t.height,resolution:t.resolution,antialias:t.antialias}),loadOp:"clear",storeOp:"store"})}}else t.colorTextures.forEach(o=>{s.push({texture:o.source,loadOp:"clear",storeOp:"store"})});const n=t.depthStencilTexture===!0;if(this._depth=!!(t.depth||n),this._stencil=!!(t.stencil||n),t.depthStencilTexture instanceof H||t.depthStencilTexture instanceof ue){if(t.isRoot)throw new Error("[RenderTarget] cannot attach a depth-stencil texture to the screen — the canvas owns its own depth/stencil buffers. Render to a texture target instead.");r={texture:t.depthStencilTexture.source}}else(n&&!t.isRoot||(t.stencil||t.depth)&&s.length===0)&&(r=this._createDepthStencilTexture(t.width,t.height,t.resolution));return{colorAttachments:s,depthStencilAttachment:r,isRoot:t.isRoot,label:t.label}}get size(){const e=this._size;return e[0]=this.pixelWidth,e[1]=this.pixelHeight,e}get width(){return this.sizeSource.width}get height(){return this.sizeSource.height}get pixelWidth(){return this.sizeSource.pixelWidth}get pixelHeight(){return this.sizeSource.pixelHeight}get resolution(){return this.sizeSource._resolution}get colorTextures(){return this._colorTextures||(this._colorTextures=this.colorAttachments.map(e=>e.texture)),this._colorTextures}get depthStencilTexture(){return this.depthStencilAttachment?.texture??null}get depth(){return this._depth}get stencil(){return this._stencil}get colorTexture(){return this.colorAttachments[0]?.texture}get sizeSource(){return this.colorAttachments[0]?.texture??this.depthStencilAttachment?.texture}onSourceResize(e){this.resize(e.width,e.height,e._resolution,!0)}ensureDepthStencilTexture(){this._createDepthStencilTexture(this.sizeSource.width,this.sizeSource.height,this.sizeSource._resolution),this._depth=!0,this._stencil=!0}resize(e,t,s=this.resolution,r=!1){if(this.dirtyId++,this.colorAttachments.forEach((n,o)=>{r&&o===0||n.texture.resize(e,t,s)}),this.depthStencilAttachment){if(r&&this.colorAttachments.length===0)return;this.depthStencilAttachment.texture.resize(e,t,s)}}destroy(){!this.colorAttachments&&!this.depthStencilAttachment||(this.emit("destroy",this),this.sizeSource.off("resize",this.onSourceResize,this),this._managedColorTextures&&this.colorAttachments.forEach(e=>{e.texture.destroy()}),this.depthStencilAttachment&&(this.depthStencilAttachment.texture.destroy(),delete this.depthStencilAttachment),this.colorAttachments=null,this._colorTextures=null,this.removeAllListeners())}_createDepthStencilTexture(e,t,s){return this.depthStencilAttachment??(this.depthStencilAttachment={texture:new ue({width:e,height:t,resolution:s,format:"depth24plus-stencil8",autoGenerateMipmaps:!1,antialias:!1,mipLevelCount:1})}),this.depthStencilAttachment}};Kp.defaultOptions={width:0,height:0,resolution:1,colorTextures:1,stencil:!1,depth:!1,antialias:!1,isRoot:!1};let li=Kp;const Ss=new Map;us.register(Ss);function Sl(i,e){if(!Ss.has(i)){const t=new H({source:new je({resource:i,...e})}),s=()=>{Ss.get(i)===t&&Ss.delete(i)};t.once("destroy",s),t.source.once("destroy",s),Ss.set(i,t)}return Ss.get(i)}const Ml=class Qp{get autoDensity(){return this.texture.source.autoDensity}set autoDensity(e){this.texture.source.autoDensity=e}get resolution(){return this.texture.source._resolution}set resolution(e){this.texture.source.resize(this.texture.source.width,this.texture.source.height,e)}constructor(e){this._renderer=e}init(e){e={...Qp.defaultOptions,...e},e.view&&(N(de,"ViewSystem.view has been renamed to ViewSystem.canvas"),e.canvas=e.view),this.screen=new se(0,0,e.width,e.height),this.canvas=e.canvas||te.get().createCanvas(),this.antialias=!!e.antialias;const{depth:t,...s}=e;this.texture=Sl(this.canvas,s),this.renderTarget=new li({colorTextures:[this.texture],depth:!!t,isRoot:!0}),this.texture.source.transparent=e.backgroundAlpha<1,this.texture.source.on("resize",this._updateScreenSize,this),this.resolution=e.resolution,this._updateScreenSize()}resize(e,t,s){this.texture.source.resize(e,t,s),this.screen.width=this.texture.frame.width,this.screen.height=this.texture.frame.height}destroy(e=!1){(typeof e=="boolean"?e:!!e?.removeView)&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this.texture.source.off("resize",this._updateScreenSize,this),Te.removeScreen(this._renderer.uid),Rt.removeScreen(this._renderer.uid),this.texture.destroy()}_updateScreenSize(){const{pixelWidth:e,pixelHeight:t}=this.texture.source,s=this._renderer.uid;Te.setScreenSize(s,e,t),Rt.setScreenSize(s,e,t)}};Ml.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"view",priority:0};Ml.defaultOptions={width:800,height:600,autoDensity:!1,antialias:!1};let Jp=Ml;const qr=[Up,bl,Xr,Jp,ml,Vp,Yp,yl,zp,pa,qp,vl],Cl=[jr,zr,Vr,$r,Hr,hl,al,Wr];function em(i,e,t,s,r,n){const o=n?1:-1;return i.identity(),i.a=1/s*2,i.d=o*(1/r*2),i.tx=-1-e*i.a,i.ty=-o-t*i.d,i}function tm(i){if(i.colorAttachments.length===0)return!1;const e=i.colorTexture.resource;return globalThis.HTMLCanvasElement&&e instanceof HTMLCanvasElement&&document.body.contains(e)}class Yr{constructor(e){this.rootViewPort=new se,this.viewport=new se,this.onRenderTargetChange=new da("onRenderTargetChange"),this.projectionMatrix=new L,this.defaultClearColor=[0,0,0,0],this._renderSurfaceToRenderTargetHash=new Map,this._gpuRenderTargetHash=Object.create(null),this._renderTargetStack=[],this._bindState={target:null,frame:void 0,mipLevel:0,layer:0,flipY:!1},this._bindFrame=new se,this._renderer=e,e.gc.addCollection(this,"_gpuRenderTargetHash","hash")}get renderSurface(){return this._bindState.target}get mipLevel(){return this._bindState.mipLevel}get layer(){return this._bindState.layer}finishRenderPass(){this.adaptor.finishRenderPass(this.renderTarget)}renderStart(e){this._renderTargetStack.length=0,this.push(e),this.rootViewPort.copyFrom(this.viewport),this.rootRenderTarget=this.renderTarget,this.renderingToScreen=tm(this.rootRenderTarget),this.adaptor.prerender?.(this.rootRenderTarget)}postrender(){this.adaptor.postrender?.(this.rootRenderTarget)}bind(e,t=!0,s,r,n=0,o=0,a){let l;"target"in e?l=e:(N("8.20.0","RenderTargetSystem.bind: positional arguments are deprecated, please use an options object instead: bind({ target, clear, clearColor, frame, mipLevel, layer, flipY })"),l={target:e,clear:t,clearColor:s,frame:r,mipLevel:n,layer:o,flipY:a});const h=l.target;t=l.clear??!0,s=l.clearColor,n=(l.mipLevel??0)|0,o=(l.layer??0)|0,a=l.flipY,r=l.frame;const c=this.getRenderTarget(h),u=this.renderTarget!==c||!!c.flipY!=!!a;this.renderTarget=c;const d=this.getGpuRenderTarget(c);(c.pixelWidth!==d.width||c.pixelHeight!==d.height)&&(this.adaptor.resizeGpuRenderTarget(c),d.width=c.pixelWidth,d.height=c.pixelHeight);const f=c.colorAttachments[0]?.texture||c.depthStencilAttachment?.texture,p=this.viewport,m=f.dimension==="3d"?Math.max(f.depth>>n,1):f.depthOrArrayLayers;if(o<0||o>=m)throw new Error(`[RenderTargetSystem] layer ${o} is out of bounds (layer count=${m}).`);const g=this._bindState;g.target=h,g.frame=r?this._bindFrame.copyFrom(r):void 0,g.mipLevel=n,g.layer=o,g.flipY=a;const _=Math.max(f.pixelWidth>>n,1),y=Math.max(f.pixelHeight>>n,1);if(!r&&h instanceof H&&(r=h.frame),r){const x=f._resolution,b=1<<Math.max(n,0),v=r.x*x+.5|0,w=r.y*x+.5|0,T=r.width*x+.5|0,E=r.height*x+.5|0;let P=Math.floor(v/b),A=Math.floor(w/b),k=Math.ceil(T/b),I=Math.ceil(E/b);P<0&&(k+=P,P=0),A<0&&(I+=A,A=0),P=Math.min(P,_-1),A=Math.min(A,y-1),k=Math.min(k,_-P),I=Math.min(I,y-A),k=Math.max(k,1),I=Math.max(I,1),p.x=P,p.y=A,p.width=k,p.height=I}else p.x=0,p.y=0,p.width=_,p.height=y;return c.flipY=a,em(this.projectionMatrix,0,0,p.width/f.resolution,p.height/f.resolution,!c.isRoot!=!!c.flipY),this.adaptor.startRenderPass(c,t,s,p,n,o),u&&this.onRenderTargetChange.emit(c),c}getBindState(e){if(!this.renderTarget)throw new Error("[RenderTargetSystem] getBindState is only valid while a render surface is bound");const t=this._bindState;return e??(e={}),e.target=t.target,e.clear=ye.NONE,e.clearColor=void 0,t.frame?e.frame?e.frame.copyFrom(t.frame):e.frame=t.frame.clone():e.frame=void 0,e.mipLevel=t.mipLevel,e.layer=t.layer,e.flipY=!!t.flipY,e}isFrontFaceInverted(e,t){if(!e){if(e=this.renderTarget,!e)return!1;t=e.flipY}return!!t!=(this._renderer.type===Ze.WEBGL&&!e.isRoot)}get frontFaceInverted(){return N(dt,"RenderTargetSystem.frontFaceInverted is deprecated, use isFrontFaceInverted() instead"),this.isFrontFaceInverted()}clear(e,t=ye.ALL,s,r=this.mipLevel,n=this.layer){t&&(e&&(e=this.getRenderTarget(e)),this.adaptor.clear(e||this.renderTarget,t,s,this.viewport,r,n))}contextChange(){this._gpuRenderTargetHash=Object.create(null)}push(e,t=ye.ALL,s,r,n=0,o=0,a){let l;"target"in e?l=e:(N("8.20.0","RenderTargetSystem.push: positional arguments are deprecated, please use an options object instead: push({ target, clear, clearColor, frame, mipLevel, layer, flipY })"),l={target:e,clear:t,clearColor:s,frame:r,mipLevel:n,layer:o,flipY:a});const h=this.bind(l);return this._renderTargetStack.push({target:l.target,clear:!1,clearColor:void 0,frame:l.frame?l.frame.clone():void 0,mipLevel:l.mipLevel,layer:l.layer,flipY:l.flipY}),h}pop(){this._renderTargetStack.pop();const e=this._renderTargetStack[this._renderTargetStack.length-1];if(!e)throw new Error("[RenderTargetSystem] pop: no previous binding to restore (unbalanced pop)");return this.bind(e)}getRenderTarget(e){return e.isTexture&&(e=e.source),this._renderSurfaceToRenderTargetHash.get(e)??this._initRenderTarget(e)}copyToTexture(e,t,s,r,n){const o=this.getRenderTarget(e);s.x<0&&(r.width+=s.x,n.x-=s.x,s.x=0),s.y<0&&(r.height+=s.y,n.y-=s.y,s.y=0);const{pixelWidth:a,pixelHeight:l}=o;return r.width=Math.min(r.width,a-s.x),r.height=Math.min(r.height,l-s.y),this.adaptor.copyToTexture(o,t,s,r,n)}copyDepthTexture(e,t,s,r,n={x:0,y:0}){const o=this.getRenderTarget(e);if(!o.depthStencilAttachment){z("[RenderTargetSystem] copyDepthTexture: the source render target has no depth attachment to copy from");return}const a=t.source;if(!a.format.includes("depth")&&!a.format.includes("stencil")){z(`[RenderTargetSystem] copyDepthTexture: the destination texture must have a depth/stencil format (got '${a.format}')`);return}let l=s.x,h=s.y,c=n.x,u=n.y,d=r.width,f=r.height;l<0&&(d+=l,c-=l,l=0),h<0&&(f+=h,u-=h,h=0),d=Math.min(d,o.pixelWidth-l),f=Math.min(f,o.pixelHeight-h),d=Math.min(d,a.pixelWidth-c),f=Math.min(f,a.pixelHeight-u),!(d<=0||f<=0)&&this.adaptor.copyDepthTexture(o,t,{x:l,y:h},{width:d,height:f},{x:c,y:u})}ensureDepthStencil(){if(!this.renderTarget.stencil){if(this.renderTarget.depthStencilTexture){z(`[RenderTargetSystem] a stencil mask is being used, but the render target's depthStencilTexture format '${this.renderTarget.depthStencilTexture.format}' has no stencil aspect, so masking cannot work here. Use a 'depth24plus-stencil8' texture instead.`);return}this.renderTarget._depth=!0,this.renderTarget._stencil=!0,this.adaptor.startRenderPass(this.renderTarget,!1,null,this.viewport,0,this.layer)}}destroy(){this._renderer=null,this._renderSurfaceToRenderTargetHash.forEach((e,t)=>{e!==t?this._releaseRenderTarget(t,e):e.off("destroy",this._onRenderTargetDestroy,this)}),this._renderSurfaceToRenderTargetHash.clear();for(const e of Object.values(this._gpuRenderTargetHash))e&&this.adaptor.destroyGpuRenderTarget(e);this._gpuRenderTargetHash=Object.create(null)}_initRenderTarget(e){let t=null;if(je.test(e)&&(e=Sl(e).source),e instanceof li)t=e,e.once("destroy",this._onRenderTargetDestroy,this);else if(e instanceof ue){const s=e.format;t=s.includes("depth")||s.includes("stencil")?new li({colorTextures:0,depthStencilTexture:e}):new li({colorTextures:[e]}),e.source instanceof je&&(t.isRoot=!0),e.once("destroy",this._onRenderSurfaceDestroy,this)}return this._renderSurfaceToRenderTargetHash.set(e,t),t}_onRenderSurfaceDestroy(e){const t=this._renderSurfaceToRenderTargetHash.get(e);t&&this._releaseRenderTarget(e,t)}_onRenderTargetDestroy(e){this._renderSurfaceToRenderTargetHash.delete(e),this._releaseGpuRenderTarget(e)}_releaseRenderTarget(e,t){t.destroy(),this._renderSurfaceToRenderTargetHash.delete(e),e.off("destroy",this._onRenderSurfaceDestroy,this),this._releaseGpuRenderTarget(t)}_releaseGpuRenderTarget(e){const t=this._gpuRenderTargetHash[e.uid];t&&(this._gpuRenderTargetHash[e.uid]=null,this.adaptor.destroyGpuRenderTarget(t))}getGpuRenderTarget(e){return this._gpuRenderTargetHash[e.uid]||(this._gpuRenderTargetHash[e.uid]=this.adaptor.initGpuRenderTarget(e))}resetState(){this.renderTarget=null,this._bindState.target=null}}class sm{init(e,t){this._renderer=e,this._renderTargetSystem=t}initGpuRenderTarget(e){const t=e.colorTexture,{canvas:s,context:r}=this._ensureCanvas(t);return{canvas:s,context:r,width:s.width,height:s.height}}resizeGpuRenderTarget(e){const t=e.colorTexture,{canvas:s}=this._ensureCanvas(t);s.width=e.pixelWidth,s.height=e.pixelHeight}startRenderPass(e,t,s,r){const n=this._renderTargetSystem.getGpuRenderTarget(e);this._renderer.canvasContext.activeContext=n.context,this._renderer.canvasContext.activeResolution=e.resolution,t&&this.clear(e,t,s,r)}clear(e,t,s,r){const o=this._renderTargetSystem.getGpuRenderTarget(e).context,a=r||{x:0,y:0,width:e.pixelWidth,height:e.pixelHeight};if(o.setTransform(1,0,0,1,0,0),o.clearRect(a.x,a.y,a.width,a.height),s){const l=le.shared.setValue(s);l.alpha>0&&(o.globalAlpha=l.alpha,o.fillStyle=l.toHex(),o.fillRect(a.x,a.y,a.width,a.height),o.globalAlpha=1)}}finishRenderPass(){}copyToTexture(e,t,s,r,n){const a=this._renderTargetSystem.getGpuRenderTarget(e).canvas,l=t.source,{context:h}=this._ensureCanvas(l),c=n?.x??0,u=n?.y??0;return h.drawImage(a,s.x,s.y,r.width,r.height,c,u,r.width,r.height),l.update(),t}copyDepthTexture(e,t,s,r,n){z("[CanvasRenderTargetAdaptor] copyDepthTexture is not supported in the canvas renderer")}destroyGpuRenderTarget(e){}_ensureCanvas(e){let t=e.resource;(!t||!je.test(t))&&(t=te.get().createCanvas(e.pixelWidth,e.pixelHeight),e.resource=t),(t.width!==e.pixelWidth||t.height!==e.pixelHeight)&&(t.width=e.pixelWidth,t.height=e.pixelHeight);const s=t.getContext("2d");return{canvas:t,context:s}}}class kl extends Yr{constructor(e){super(e),this.adaptor=new sm,this.adaptor.init(e,this)}}kl.extension={type:[S.CanvasSystem],name:"renderTarget"};class El{constructor(e){}init(){}initSource(e){}generateCanvas(e){const t=te.get().createCanvas(),s=t.getContext("2d"),r=K.getCanvasSource(e);if(!r)return t;const n=e.frame,o=e.source._resolution??e.source.resolution??1,a=n.x*o,l=n.y*o,h=n.width*o,c=n.height*o;return t.width=Math.ceil(h),t.height=Math.ceil(c),s.drawImage(r,a,l,h,c,0,0,h,c),t}getPixels(e){const t=this.generateCanvas(e);return{pixels:t.getContext("2d",{willReadFrequently:!0}).getImageData(0,0,t.width,t.height).data,width:t.width,height:t.height}}destroy(){}}El.extension={type:[S.CanvasSystem],name:"texture"};const $y=[...qr,cl,ul,El,kl],Vy=[jr,zr,Vr,$r,Hr,ll,ol,Wr],jy=[Ap,dl],im=[],rm=[],nm=[],om=[];Y.handleByNamedList(S.CanvasSystem,im);Y.handleByNamedList(S.CanvasPipes,rm);Y.handleByNamedList(S.CanvasPipesAdaptor,nm);Y.handleByNamedList(S.CanvasLoader,om);Y.add(...$y,...Vy,...jy);class am extends fs{constructor(){const e={name:"canvas",type:Ze.CANVAS,systems:im,renderPipes:rm,renderPipeAdaptors:nm,loaders:om};super(e)}}const Xy=Object.freeze(Object.defineProperty({__proto__:null,CanvasRenderer:am},Symbol.toStringTag,{value:"Module"}));var hi=(i=>(i[i.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",i[i.ARRAY_BUFFER=34962]="ARRAY_BUFFER",i[i.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",i))(hi||{});class lm{constructor(e,t){this._lastBindBaseLocation=-1,this._lastBindCallId=-1,this.buffer=e||null,this.updateID=-1,this.byteLength=-1,this.type=t}destroy(){this.buffer=null,this.updateID=-1,this.byteLength=-1,this.type=-1,this._lastBindBaseLocation=-1,this._lastBindCallId=-1}}class Pl{constructor(e){this._boundBufferBases=Object.create(null),this._minBaseLocation=0,this._nextBindBaseIndex=this._minBaseLocation,this._bindCallId=0,this._renderer=e,this._managedBuffers=new lt({renderer:e,type:"resource",onUnload:this.onBufferUnload.bind(this),name:"glBuffer"})}destroy(){this._managedBuffers.destroy(),this._renderer=null,this._gl=null,this._boundBufferBases={}}contextChange(){this._gl=this._renderer.gl,this.destroyAll(!0),this._maxBindings=this._renderer.limits.maxUniformBindings}getGlBuffer(e){return e._gcLastUsed=this._renderer.gc.now,e._gpuData[this._renderer.uid]||this.createGLBuffer(e)}bind(e){const{_gl:t}=this,s=this.getGlBuffer(e);t.bindBuffer(s.type,s.buffer)}bindBufferBase(e,t){const{_gl:s}=this;this._boundBufferBases[t]!==e&&(this._boundBufferBases[t]=e,e._lastBindBaseLocation=t,s.bindBufferBase(s.UNIFORM_BUFFER,t,e.buffer))}nextBindBase(e){this._bindCallId++,this._minBaseLocation=0,e&&(this._boundBufferBases[0]=null,this._minBaseLocation=1,this._nextBindBaseIndex<1&&(this._nextBindBaseIndex=1))}freeLocationForBufferBase(e){let t=this.getLastBindBaseLocation(e);if(t>=this._minBaseLocation)return e._lastBindCallId=this._bindCallId,t;let s=0,r=this._nextBindBaseIndex;for(;s<2;){r>=this._maxBindings&&(r=this._minBaseLocation,s++);const n=this._boundBufferBases[r];if(n&&n._lastBindCallId===this._bindCallId){r++;continue}break}return t=r,this._nextBindBaseIndex=r+1,s>=2?-1:(e._lastBindCallId=this._bindCallId,this._boundBufferBases[t]=null,t)}getLastBindBaseLocation(e){const t=e._lastBindBaseLocation;return this._boundBufferBases[t]===e?t:-1}bindBufferRange(e,t,s,r){const{_gl:n}=this;s||(s=0),t||(t=0),this._boundBufferBases[t]=null,n.bindBufferRange(n.UNIFORM_BUFFER,t||0,e.buffer,s*256,r||256)}updateBuffer(e){const{_gl:t}=this,s=this.getGlBuffer(e);if(e._updateID===s.updateID)return s;s.updateID=e._updateID,t.bindBuffer(s.type,s.buffer);const r=e.data,n=e.descriptor.usage&ae.STATIC?t.STATIC_DRAW:t.DYNAMIC_DRAW;return r?s.byteLength>=r.byteLength?t.bufferSubData(s.type,e._updateOffset,r,e._updateOffset/r.BYTES_PER_ELEMENT,(e._updateSize||r.byteLength)/r.BYTES_PER_ELEMENT):(s.byteLength=r.byteLength,t.bufferData(s.type,r,n)):(s.byteLength=e.descriptor.size,t.bufferData(s.type,s.byteLength,n)),s}destroyAll(e=!1){this._managedBuffers.removeAll(e)}onBufferUnload(e,t=!1){const s=e._gpuData[this._renderer.uid];s&&(t||this._gl.deleteBuffer(s.buffer))}createGLBuffer(e){const{_gl:t}=this;let s=hi.ARRAY_BUFFER;e.descriptor.usage&ae.INDEX?s=hi.ELEMENT_ARRAY_BUFFER:e.descriptor.usage&ae.UNIFORM&&(s=hi.UNIFORM_BUFFER);const r=new lm(t.createBuffer(),s);return e._gpuData[this._renderer.uid]=r,this._managedBuffers.add(e),r}resetState(){this._boundBufferBases=Object.create(null)}}Pl.extension={type:[S.WebGLSystem],name:"buffer"};const Al=class hm{constructor(e){this.supports={uint32Indices:!0,uniformBufferObject:!0,vertexArrayObject:!0,srgbTextures:!0,nonPowOf2wrapping:!0,msaa:!0,nonPowOf2mipmaps:!0},this._renderer=e,this.extensions=Object.create(null),this.handleContextLost=this.handleContextLost.bind(this),this.handleContextRestored=this.handleContextRestored.bind(this)}get isLost(){return!this.gl||this.gl.isContextLost()}contextChange(e){this.gl=e,this._renderer.gl=e}init(e){e={...hm.defaultOptions,...e};let t=this.multiView=e.multiView;if(e.context&&t&&(z("Renderer created with both a context and multiview enabled. Disabling multiView as both cannot work together."),t=!1),t?this.canvas=te.get().createCanvas(this._renderer.canvas.width,this._renderer.canvas.height):this.canvas=this._renderer.view.canvas,e.context)this.initFromContext(e.context);else{const s=this._renderer.background.alpha<1,r=e.premultipliedAlpha??!0,n=e.antialias&&!this._renderer.backBuffer.useBackBuffer;this.createContext(e.preferWebGLVersion,{alpha:s,premultipliedAlpha:r,antialias:n,stencil:!0,preserveDrawingBuffer:e.preserveDrawingBuffer,powerPreference:e.powerPreference??"default"})}}ensureCanvasSize(e){if(!this.multiView){e!==this.canvas&&z("multiView is disabled, but targetCanvas is not the main canvas");return}const{canvas:t}=this;(t.width<e.width||t.height<e.height)&&(t.width=Math.max(e.width,e.width),t.height=Math.max(e.height,e.height))}initFromContext(e){this.gl=e,this.webGLVersion=e instanceof te.get().getWebGLRenderingContext()?1:2,this.getExtensions(),this.validateContext(e),this._renderer.runners.contextChange.emit(e);const t=this._renderer.view.canvas;t.addEventListener("webglcontextlost",this.handleContextLost,!1),t.addEventListener("webglcontextrestored",this.handleContextRestored,!1)}createContext(e,t){let s;const r=this.canvas;if(e===2&&(s=r.getContext("webgl2",t)),!s&&(s=r.getContext("webgl",t),!s))throw new Error("This browser does not support WebGL. Try using the canvas renderer");this.gl=s,this.initFromContext(this.gl)}getExtensions(){const{gl:e}=this,t={anisotropicFiltering:e.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:e.getExtension("OES_texture_float_linear"),s3tc:e.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:e.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:e.getExtension("WEBGL_compressed_texture_etc"),etc1:e.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:e.getExtension("WEBGL_compressed_texture_atc"),astc:e.getExtension("WEBGL_compressed_texture_astc"),bptc:e.getExtension("EXT_texture_compression_bptc"),rgtc:e.getExtension("EXT_texture_compression_rgtc"),loseContext:e.getExtension("WEBGL_lose_context")};if(this.webGLVersion===1)this.extensions={...t,drawBuffers:e.getExtension("WEBGL_draw_buffers"),depthTexture:e.getExtension("WEBGL_depth_texture"),vertexArrayObject:e.getExtension("OES_vertex_array_object")||e.getExtension("MOZ_OES_vertex_array_object")||e.getExtension("WEBKIT_OES_vertex_array_object"),uint32ElementIndex:e.getExtension("OES_element_index_uint"),floatTexture:e.getExtension("OES_texture_float"),floatTextureLinear:e.getExtension("OES_texture_float_linear"),textureHalfFloat:e.getExtension("OES_texture_half_float"),textureHalfFloatLinear:e.getExtension("OES_texture_half_float_linear"),vertexAttribDivisorANGLE:e.getExtension("ANGLE_instanced_arrays"),srgb:e.getExtension("EXT_sRGB")};else{this.extensions={...t,colorBufferFloat:e.getExtension("EXT_color_buffer_float")};const s=e.getExtension("WEBGL_provoking_vertex");s&&s.provokingVertexWEBGL(s.FIRST_VERTEX_CONVENTION_WEBGL)}}handleContextLost(e){e.preventDefault(),this._contextLossForced&&(this._contextLossForced=!1,setTimeout(()=>{this.gl.isContextLost()&&this.extensions.loseContext?.restoreContext()},0))}handleContextRestored(){this.getExtensions(),this._renderer.runners.contextChange.emit(this.gl)}destroy(){const e=this._renderer.view.canvas;this._renderer=null,e.removeEventListener("webglcontextlost",this.handleContextLost),e.removeEventListener("webglcontextrestored",this.handleContextRestored),this.gl.useProgram(null),this.extensions.loseContext?.loseContext()}forceContextLoss(){this.extensions.loseContext?.loseContext(),this._contextLossForced=!0}validateContext(e){const t=e.getContextAttributes();t&&!t.stencil&&z("Provided WebGL context does not have a stencil buffer, masks may not render correctly");const s=this.supports,r=this.webGLVersion===2,n=this.extensions;s.uint32Indices=r||!!n.uint32ElementIndex,s.uniformBufferObject=r,s.vertexArrayObject=r||!!n.vertexArrayObject,s.srgbTextures=r||!!n.srgb,s.nonPowOf2wrapping=r,s.nonPowOf2mipmaps=r,s.msaa=r,s.uint32Indices||z("Provided WebGL context does not support 32 index buffer, large scenes may not render correctly")}};Al.extension={type:[S.WebGLSystem],name:"context"};Al.defaultOptions={context:null,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:void 0,preferWebGLVersion:2,multiView:!1};let cm=Al;function _r(i,e){for(const t in i.attributes){const s=i.attributes[t],r=e[t];r?(s.format??(s.format=r.format),s.offset??(s.offset=r.offset),s.instance??(s.instance=r.instance)):s.format||z(`Attribute ${t} is not present in the shader, but is present in the geometry. Unable to infer attribute details.`)}qy(i)}function qy(i){const{buffers:e,attributes:t}=i,s={},r={};for(const n in e){const o=e[n];s[o.uid]=0,r[o.uid]=0}for(const n in t){const o=t[n];s[o.buffer.uid]+=gt(o.format).stride}for(const n in t){const o=t[n];o.stride??(o.stride=s[o.buffer.uid]),o.start??(o.start=r[o.buffer.uid]),r[o.buffer.uid]+=gt(o.format).stride}}var yr=(i=>(i[i.RGBA=6408]="RGBA",i[i.RGB=6407]="RGB",i[i.RG=33319]="RG",i[i.RED=6403]="RED",i[i.RGBA_INTEGER=36249]="RGBA_INTEGER",i[i.RGB_INTEGER=36248]="RGB_INTEGER",i[i.RG_INTEGER=33320]="RG_INTEGER",i[i.RED_INTEGER=36244]="RED_INTEGER",i[i.ALPHA=6406]="ALPHA",i[i.LUMINANCE=6409]="LUMINANCE",i[i.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",i[i.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",i[i.DEPTH_STENCIL=34041]="DEPTH_STENCIL",i))(yr||{}),Ds=(i=>(i[i.TEXTURE_2D=3553]="TEXTURE_2D",i[i.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",i[i.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",i[i.TEXTURE_3D=32879]="TEXTURE_3D",i[i.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",i[i.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",i[i.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",i[i.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",i[i.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",i[i.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",i))(Ds||{}),re=(i=>(i[i.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",i[i.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",i[i.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",i[i.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",i[i.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",i[i.UNSIGNED_INT=5125]="UNSIGNED_INT",i[i.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",i[i.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",i[i.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",i[i.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",i[i.BYTE=5120]="BYTE",i[i.SHORT=5122]="SHORT",i[i.INT=5124]="INT",i[i.FLOAT=5126]="FLOAT",i[i.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",i[i.HALF_FLOAT=36193]="HALF_FLOAT",i))(re||{});const Uc={uint8x2:re.UNSIGNED_BYTE,uint8x4:re.UNSIGNED_BYTE,sint8x2:re.BYTE,sint8x4:re.BYTE,unorm8x2:re.UNSIGNED_BYTE,unorm8x4:re.UNSIGNED_BYTE,snorm8x2:re.BYTE,snorm8x4:re.BYTE,uint16x2:re.UNSIGNED_SHORT,uint16x4:re.UNSIGNED_SHORT,sint16x2:re.SHORT,sint16x4:re.SHORT,unorm16x2:re.UNSIGNED_SHORT,unorm16x4:re.UNSIGNED_SHORT,snorm16x2:re.SHORT,snorm16x4:re.SHORT,float16x2:re.HALF_FLOAT,float16x4:re.HALF_FLOAT,float32:re.FLOAT,float32x2:re.FLOAT,float32x3:re.FLOAT,float32x4:re.FLOAT,uint32:re.UNSIGNED_INT,uint32x2:re.UNSIGNED_INT,uint32x3:re.UNSIGNED_INT,uint32x4:re.UNSIGNED_INT,sint32:re.INT,sint32x2:re.INT,sint32x3:re.INT,sint32x4:re.INT};function um(i){return Uc[i]??Uc.float32}const Yy={"point-list":0,"line-list":1,"line-strip":3,"triangle-list":4,"triangle-strip":5};class dm{constructor(){this.vaoCache=Object.create(null)}destroy(){this.vaoCache=Object.create(null)}}class Rl{constructor(e){this._renderer=e,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this._managedGeometries=new lt({renderer:e,type:"resource",onUnload:this.onGeometryUnload.bind(this),name:"glGeometry"})}contextChange(){const e=this.gl=this._renderer.gl;if(!this._renderer.context.supports.vertexArrayObject)throw new Error("[PixiJS] Vertex Array Objects are not supported on this device");this.destroyAll(!0);const t=this._renderer.context.extensions.vertexArrayObject;t&&(e.createVertexArray=()=>t.createVertexArrayOES(),e.bindVertexArray=r=>t.bindVertexArrayOES(r),e.deleteVertexArray=r=>t.deleteVertexArrayOES(r));const s=this._renderer.context.extensions.vertexAttribDivisorANGLE;s&&(e.drawArraysInstanced=(r,n,o,a)=>{s.drawArraysInstancedANGLE(r,n,o,a)},e.drawElementsInstanced=(r,n,o,a,l)=>{s.drawElementsInstancedANGLE(r,n,o,a,l)},e.vertexAttribDivisor=(r,n)=>s.vertexAttribDivisorANGLE(r,n)),this._activeGeometry=null,this._activeVao=null}bind(e,t){const s=this.gl;this._activeGeometry=e;const r=this.getVao(e,t);this._activeVao!==r&&(this._activeVao=r,s.bindVertexArray(r)),this.updateBuffers()}resetState(){this.unbind()}updateBuffers(){const e=this._activeGeometry,t=this._renderer.buffer;for(let s=0;s<e.buffers.length;s++){const r=e.buffers[s];t.updateBuffer(r)}e._gcLastUsed=this._renderer.gc.now}checkCompatibility(e,t){const s=e.attributes,r=t._attributeData;for(const n in r)if(!s[n])throw new Error(`shader and geometry incompatible, geometry missing the "${n}" attribute`)}getSignature(e,t){const s=e.attributes,r=t._attributeData,n=["g",e.uid];for(const o in s)r[o]&&n.push(o,r[o].location);return n.join("-")}getVao(e,t){return e._gpuData[this._renderer.uid]?.vaoCache[t._key]||this.initGeometryVao(e,t)}initGeometryVao(e,t,s=!0){const r=this._renderer.gl,n=this._renderer.buffer;this._renderer.shader._getProgramData(t),this.checkCompatibility(e,t);const o=this.getSignature(e,t);let a=e._gpuData[this._renderer.uid];a||(a=new dm,e._gpuData[this._renderer.uid]=a,this._managedGeometries.add(e));const l=a.vaoCache;let h=l[o];if(h)return l[t._key]=h,h;_r(e,t._attributeData);const c=e.buffers;h=r.createVertexArray(),r.bindVertexArray(h);for(let u=0;u<c.length;u++){const d=c[u];n.bind(d)}return this.activateVao(e,t),l[t._key]=h,l[o]=h,r.bindVertexArray(null),h}onGeometryUnload(e,t=!1){const s=e._gpuData[this._renderer.uid];if(!s)return;const r=s.vaoCache;if(!t)for(const n in r)this._activeVao===r[n]&&this.resetState(),this.gl.deleteVertexArray(r[n])}destroyAll(e=!1){this._managedGeometries.removeAll(e)}activateVao(e,t){const s=this._renderer.gl,r=this._renderer.buffer,n=e.attributes;e.indexBuffer&&r.bind(e.indexBuffer);let o=null;for(const a in n){const l=n[a],h=l.buffer,c=r.getGlBuffer(h),u=t._attributeData[a];if(u){o!==c&&(r.bind(h),o=c);const d=u.location;s.enableVertexAttribArray(d);const f=gt(l.format),p=um(l.format);if(u.format?.substring(1,4)==="int"?s.vertexAttribIPointer(d,f.size,p,l.stride,l.offset):s.vertexAttribPointer(d,f.size,p,f.normalised,l.stride,l.offset),l.instance)if(this.hasInstance){const m=l.divisor??1;s.vertexAttribDivisor(d,m)}else throw new Error("geometry error, GPU Instancing is not supported on this device")}}}draw(e,t,s,r){const{gl:n}=this._renderer,o=this._activeGeometry,a=Yy[e||o.topology];if(r??(r=o.instanceCount),o.indexBuffer){const l=o.indexBuffer.data.BYTES_PER_ELEMENT,h=l===2?n.UNSIGNED_SHORT:n.UNSIGNED_INT,c=t||o.indexCount||o.indexBuffer.data.length,u=(s||0)*l;r!==1?n.drawElementsInstanced(a,c,h,u,r):n.drawElements(a,c,h,u)}else r!==1?n.drawArraysInstanced(a,s||0,t||o.vertexCount,r):n.drawArrays(a,s||0,t||o.vertexCount);return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this._managedGeometries.destroy(),this._renderer=null,this.gl=null,this._activeVao=null,this._activeGeometry=null}}Rl.extension={type:[S.WebGLSystem],name:"geometry"};const Ky=new Mi({attributes:{aPosition:[-1,-1,3,-1,-1,3]}}),Bl=class fm{constructor(e){this.useBackBuffer=!1,this._useBackBufferThisRender=!1,this._renderer=e}init(e={}){const{useBackBuffer:t,antialias:s}={...fm.defaultOptions,...e};this.useBackBuffer=t,this._antialias=s,this._renderer.context.supports.msaa||(z("antialiasing, is not supported on when using the back buffer"),this._antialias=!1),this._state=yt.for2d();const r=new ds({vertex:`
|
|
586
586
|
attribute vec2 aPosition;
|
|
@@ -963,10 +963,10 @@ fn mainFragment(
|
|
|
963
963
|
`),t.unshift(`
|
|
964
964
|
var stride = ${s};
|
|
965
965
|
`);const r=t.join(`
|
|
966
|
-
`);return new Function("ps","f32v","u32v",r)}class vg{constructor(e){this._size=0,this._generateParticleUpdateCache={};const t=this._size=e.size??1e3,s=e.properties;let r=0,n=0;for(const c in s){const u=s[c],d=gt(u.format);u.dynamic?n+=d.stride:r+=d.stride}this._dynamicStride=n/4,this._staticStride=r/4,this.staticAttributeBuffer=new Qt(t*4*r),this.dynamicAttributeBuffer=new Qt(t*4*n),this.indexBuffer=Oo(t);const o=new Mi;let a=0,l=0;this._staticBuffer=new at({data:new Float32Array(1),label:"static-particle-buffer",shrinkToFit:!1,usage:ae.VERTEX|ae.COPY_DST}),this._dynamicBuffer=new at({data:new Float32Array(1),label:"dynamic-particle-buffer",shrinkToFit:!1,usage:ae.VERTEX|ae.COPY_DST});for(const c in s){const u=s[c],d=gt(u.format);u.dynamic?(o.addAttribute(u.attributeName,{buffer:this._dynamicBuffer,stride:this._dynamicStride*4,offset:a*4,format:u.format}),a+=d.size):(o.addAttribute(u.attributeName,{buffer:this._staticBuffer,stride:this._staticStride*4,offset:l*4,format:u.format}),l+=d.size)}o.addIndex(this.indexBuffer);const h=this.getParticleUpdate(s);this._dynamicUpload=h.dynamicUpdate,this._staticUpload=h.staticUpdate,this.geometry=o}getParticleUpdate(e){const t=Ex(e);return this._generateParticleUpdateCache[t]?this._generateParticleUpdateCache[t]:(this._generateParticleUpdateCache[t]=this.generateParticleUpdate(e),this._generateParticleUpdateCache[t])}generateParticleUpdate(e){return bg(e)}update(e,t){e.length>this._size&&(t=!0,this._size=Math.max(e.length,this._size*1.5|0),this.staticAttributeBuffer=new Qt(this._size*this._staticStride*4*4),this.dynamicAttributeBuffer=new Qt(this._size*this._dynamicStride*4*4),this.indexBuffer=Oo(this._size),this.geometry.indexBuffer.setDataWithSize(this.indexBuffer,this.indexBuffer.byteLength,!0));const s=this.dynamicAttributeBuffer;if(this._dynamicUpload(e,s.float32View,s.uint32View),this._dynamicBuffer.setDataWithSize(this.dynamicAttributeBuffer.float32View,e.length*this._dynamicStride*4,!0),t){const r=this.staticAttributeBuffer;this._staticUpload(e,r.float32View,r.uint32View),this._staticBuffer.setDataWithSize(r.float32View,e.length*this._staticStride*4,!0)}}destroy(){this._staticBuffer.destroy(),this._dynamicBuffer.destroy(),this.geometry.destroy()}}function Ex(i){const e=[];for(const t in i){const s=i[t];e.push(t,s.code,s.dynamic?"d":"s")}return e.join("_")}Y.add(bu,vu);const Px=Object.freeze(Object.defineProperty({__proto__:null,AbstractRenderer:fs,AbstractText:ap,AbstractTextSystem:Ja,AccessibilitySystem:R_,AlphaMask:ea,AlphaMaskPipe:Hr,Application:_a,ApplicationInitHook:fa,BLEND_TO_NPM:Kd,BREAKING_SPACES:fp,BREAKING_SPACES_SET:pp,BREAK_AFTER_CHARS:gp,BREAK_AFTER_CHARS_SET:_p,BUFFER_TYPE:hi,BackgroundSystem:Up,Batch:Jd,BatchGeometry:nf,BatchTextureArray:Qd,BatchableGraphics:Or,BatchableSprite:Nr,BatchableText:kp,Batcher:sf,BatcherPipe:zr,BigPool:Se,BindGroup:At,BindGroupSystem:Yl,BlendModePipe:jr,Bounds:Ee,BrowserAdapter:td,Buffer:at,BufferImageSource:br,BufferResource:ki,BufferUsage:ae,CLEAR:ye,COLLAPSIBLE_SPACES:mp,Cache:Zt,CanvasBatchAdaptor:Ap,CanvasColorMaskPipe:ol,CanvasContextSystem:cl,CanvasFilterSystem:Yf,CanvasGraphicsAdaptor:dl,CanvasGraphicsContextSystem:rp,CanvasGraphicsPipe:za,CanvasLimitsSystem:ul,CanvasObserver:na,CanvasPool:Rt,CanvasPoolClass:qf,CanvasRenderTargetAdaptor:sm,CanvasRenderTargetSystem:kl,CanvasRenderer:am,CanvasRendererTextSystem:el,CanvasSource:je,CanvasStencilMaskPipe:ll,CanvasTextGenerator:Jt,CanvasTextMetrics:St,CanvasTextPipe:Qa,CanvasTextSystem:tl,CanvasTextureSystem:El,Circle:Er,Color:le,ColorMask:ta,ColorMaskPipe:al,Container:_e,CustomRenderPipe:Wr,DEG_TO_RAD:Su,DOMAdapter:te,DOMPipe:Vf,DefaultBatcher:Fr,DefaultShader:yo,Ellipse:Pr,EventBoundary:jf,EventEmitter:Re,EventSystem:Xf,EventsTicker:ft,ExtensionType:S,ExtractSystem:zp,FederatedContainer:ay,FederatedEvent:Ls,FederatedMouseEvent:vi,FederatedPointerEvent:Fe,FederatedWheelEvent:cs,FillGradient:Xe,FillPattern:Us,Filter:ca,FilterEffect:ui,FilterPipe:Jf,FilterSystem:ep,GCManagedHash:lt,GCSystem:Vp,GL_FORMATS:yr,GL_TARGETS:Ds,GL_TYPES:re,GPUTextureGpuData:fg,GenerateTextureSystem:yl,Geometry:Mi,GlBackBufferSystem:pm,GlBatchAdaptor:il,GlBuffer:lm,GlBufferSystem:Pl,GlColorMaskSystem:Il,GlContextSystem:cm,GlEncoderSystem:Gl,GlGeometryGpuData:dm,GlGeometrySystem:Rl,GlGraphicsAdaptor:Xl,GlLimitsSystem:Dl,GlMeshAdaptor:ql,GlProgram:ds,GlProgramData:wm,GlRenderTarget:mm,GlRenderTargetAdaptor:bm,GlRenderTargetSystem:Ul,GlShaderSystem:Jr,GlStateSystem:Gm,GlStencilSystem:Fl,GlTexture:Dm,GlTextureSystem:jl,GlUboSystem:Qr,GlUniformGroupSystem:en,GlobalResourceRegistry:us,GlobalUniformSystem:bl,Gpu3dMipmapGenerator:ug,GpuBatchAdaptor:rl,GpuBlendModesToPixi:Ge,GpuBufferData:Qm,GpuBufferSystem:Kl,GpuColorMaskSystem:Zl,GpuDeviceSystem:tn,GpuEncoderSystem:Ql,GpuGraphicsAdaptor:uh,GpuGraphicsContext:Ef,GpuLimitsSystem:Jl,GpuMeshAdapter:dh,GpuMipmapGenerator:dg,GpuMsaaRestore:rg,GpuProgram:Ut,GpuRenderTarget:ng,GpuRenderTargetAdaptor:og,GpuRenderTargetSystem:ih,GpuShaderSystem:rh,GpuStateSystem:nh,GpuStencilModesToPixi:It,GpuStencilSystem:eh,GpuTextureSystem:ch,GpuUboSystem:sn,GpuUniformBatchPipe:th,Graphics:Pe,GraphicsContext:Ye,GraphicsContextRenderData:Pf,GraphicsContextSystem:Ur,GraphicsGpuData:np,GraphicsPath:mt,GraphicsPipe:Wa,HelloSystem:Xr,ImageSource:pi,InstructionSet:Sr,LoaderParserPriority:ia,MaskEffectManager:lr,MaskEffectManagerClass:zu,MaskFilter:ip,Matrix:L,NEWLINES:up,NEWLINES_SET:dp,NEWLINE_MATCH_REGEX:xp,NEWLINE_SPLIT_REGEX:yp,NOOP:Vo,ObservablePoint:Me,PI_2:wu,ParticleBuffer:vg,PassthroughFilter:Qf,PipelineSystem:sh,Point:ce,Polygon:Es,Pool:Fu,PoolGroupClass:Ou,RAD_TO_DEG:Tu,Rectangle:se,RenderBundle:eg,RenderGroup:hr,RenderGroupPipe:$r,RenderGroupSystem:ml,RenderTarget:li,RenderTargetSystem:Yr,RenderTexture:Ci,RenderableGCSystem:qp,RendererInitHook:pa,RendererType:Ze,ResizePlugin:ma,Resolver:ra,RoundedRectangle:Ar,STATE_BITS:ha,STENCIL_MODES:me,SVGParser:Hf,SchedulerSystem:vl,ScreenSizeRegistry:Zo,Shader:_t,ShaderOverrides:Bs,ShaderStage:fe,ShapePath:Df,SharedRenderPipes:Cl,SharedSystems:qr,Sprite:os,SpritePipe:Vr,Spritesheet:Jn,State:yt,StencilMask:sa,StencilMaskPipe:hl,SystemRunner:da,Text:Ep,TextStyle:Gs,Texture:H,TextureGCSystem:Yp,TextureMatrix:Xo,TexturePool:Te,TexturePoolClass:Qu,TextureSource:ue,TextureStyle:Lt,TextureView:Nl,Ticker:$e,TickerListener:Qi,TickerPlugin:ga,UNIFORM_TO_ARRAY_SETTERS:Am,UNIFORM_TO_SINGLE_SETTERS:Pm,UNIFORM_TYPES_MAP:Ed,UNIFORM_TYPES_VALUES:la,UPDATE_BLEND:Mr,UPDATE_COLOR:fi,UPDATE_PRIORITY:as,UPDATE_VISIBLE:ks,UboBatch:Jm,UboSystem:Kr,UniformGroup:Qe,VERSION:xi,VideoSource:nd,ViewContainer:Cr,ViewSystem:Jp,ViewableBuffer:Qt,WGSL_ALIGN_SIZE_DATA:Ps,WGSL_TO_STD40_SIZE:Zr,WebGLRenderer:Zm,WebGPURenderer:xg,accessibilityTarget:B_,addBits:po,addMaskBounds:Qo,addMaskLocalBounds:Jo,addProgramDefines:yd,appendSVGPath:Co,applyStyleParams:Do,assertMipmap3dTexture:lh,assignWithIgnore:Ju,autoDetectRenderer:Vd,bakeOverridesIntoSource:Fo,bgr2rgb:ss,blockDataMap:oh,boundsPool:pt,browserExt:bu,buildAdaptiveBezier:Ba,buildAdaptiveQuadratic:Af,buildArc:Ia,buildArcTo:Rf,buildArcToSvg:Bf,buildCircle:Is,buildContextBatches:kf,buildEllipse:vf,buildLine:Lr,buildPixelLine:Tf,buildPolygon:Sf,buildRectangle:Mf,buildRoundedRectangle:wf,buildSimpleUvs:bf,buildTriangle:Cf,buildUvs:xf,cacheAsTextureMixin:Lu,calculatePathArea:zf,calculateProjection:em,canUseNewCanvasBlendModes:Oa,canvasUtils:K,checkChildrenDidChange:Ko,checkForNestedPattern:Uf,checkMaxIfStatementsInShader:xa,childrenHelperMixin:Uu,cleanArray:Wp,cleanHash:Hp,clearList:gr,closePointEps:ka,collapseNewlines:qa,collapseSpaces:Xa,collectRenderablesMixin:Nu,color32BitToUniform:Ha,colorBit:va,colorBitGl:wa,compareModeToGlCompare:zm,compileBufferSync:Ol,compileHighShader:af,compileHighShaderGl:lf,compileHighShaderGlProgram:Ir,compileHighShaderGpuProgram:Br,compileHooks:mo,compileInputs:go,compileOutputs:of,compileShader:Bo,convertToList:Kt,copySearchParams:Qn,createGlUploadCubeTextureResource:Lm,createGpuUploadCubeTextureResource:hg,createIdFromString:ls,createIndicesForQuads:Oo,createStringVariations:cd,createUboElementsSTD40:gm,createUboElementsWGSL:tg,createUboSyncFunctionSTD40:xm,createUboSyncFunctionWGSL:ig,cullingMixin:Du,curveEps:xo,defaultFilterVert:Kf,defaultValue:zl,definedProps:jo,deprecation:N,detectVideoAlphaMode:id,earcut:Nd,effectsMixin:Hu,ensureAttributes:_r,ensureIsBuffer:ba,ensurePrecision:xd,ensureTextOptions:lp,executeInstructions:mr,extensions:Y,extractAttributesFromGlProgram:Sm,extractAttributesFromGpuProgram:Sd,extractStructAndGroups:Ji,extractSubpaths:Nf,extractSvgUrlId:So,fastCopy:dr,findMixin:Wu,fontStringFromTextStyle:pr,fragmentGPUTemplate:df,fragmentGlTemplate:pf,generateArraySyncSTD40:ym,generateArraySyncWGSL:sg,generateGpuLayoutGroups:Md,generateLayoutHash:Cd,generateParticleUpdateFunction:bg,generateProgram:Em,generateShaderSyncCode:vm,generateTextureBatchBit:Ta,generateTextureBatchBitGl:Sa,generateTextureMatrix:Aa,generateUniformsSync:Rm,getAdjustedBlendModeBlend:fo,getAttributeInfoFromFormat:gt,getBatchSamplersUniformGroup:Ma,getCanvasBoundingBox:hp,getCanvasFillStyle:si,getCanvasTexture:Sl,getCharacterGroups:Ka,getDefaultUniformValue:Pd,getFastGlobalBoundsMixin:$u,getGeometryBounds:rf,getGlTypeFromFormat:um,getGlobalBounds:vr,getGlobalMixin:ju,getGlobalRenderableBounds:La,getLocalBounds:Tr,getMaxFragmentPrecision:_d,getMaxMiterRatio:$f,getMaxTexturesPerBatch:Zd,getOrientationOfPoints:ya,getPo2TextureFromSource:Ua,getTestContext:aa,getTexelRangeRects:Wl,getTextureBatchBindGroup:Rr,getUboData:Mm,getUniformData:Cm,getUrlExtension:ud,glUploadBufferImageResource:Fm,glUploadCompressedTextureResource:Om,glUploadImageResource:$l,glUploadVideoResource:Um,globalUniformsBit:mf,globalUniformsBitGl:gf,gpuUploadBufferImageResource:ag,gpuUploadCompressedTextureResource:lg,gpuUploadImageResource:ah,gpuUploadVideoResource:cg,groupD8:Q,hasTagMarkup:ja,hasTagStyles:Va,injectBits:_o,insertVersion:bd,isBreakAfterChar:bp,isBreakingSpace:Ve,isCanvasFilterCapable:Eo,isIntegerFormat:ar,isMobile:md,isNewline:wi,isPow2:ns,isRenderingToScreen:tm,isSafari:Pp,isSingleItem:Zn,isWebGLSupported:Wd,isWebGPUSupported:$d,loadEnvironmentExtensions:Gd,localUniformBit:oi,localUniformBitGl:$a,localUniformBitGroup2:op,logProgramError:km,mapCanvasBlendModesToPixi:Dp,mapFormatToGlFormat:Hm,mapFormatToGlInternalFormat:Wm,mapFormatToGlType:$m,mapGlToVertexFormat:Tm,mapType:Hl,mapViewDimensionToGlTarget:Vm,mapWebGLBlendModesToPixi:Bm,maskFrag:tp,maskVert:sp,maskWgsl:Ao,matrixPool:Ae,measureMixin:qu,measureTaggedText:vp,mipmapScaleModeToGlFilter:Nm,multiplyColors:di,multiplyHexColors:ts,nextPow2:rs,normalizeExtensionPriority:Js,onRenderMixin:Yu,parseSVGDefinitions:Ff,parseSVGFloatAttribute:ve,parseSVGPath:Xd,parseSVGStyle:Ga,parseTaggedText:cp,passthroughFrag:Zf,passthroughWgsl:Po,path:Rs,removeItems:Yo,removeStructAndGroupDuplicates:kd,resourceToTexture:ad,roundPixelsBit:Gr,roundPixelsBitGl:Dr,roundedShapeArc:If,roundedShapeQuadraticCurve:Gf,sayHello:jp,scaleModeToGlFilter:Go,setProgramName:vd,shapeBuilders:ps,sortMixin:Ku,spritesheetAsset:pd,squaredDistanceToLineSegment:qd,stripVersion:wd,styleAttributes:Mo,textureBit:Bp,textureBitGl:Ip,textureFrom:ld,toFillStyle:Ot,toLocalGlobalMixin:Zu,toStrokeStyle:bi,tokenize:Ya,tokenizeTaggedRuns:Tp,transformVertices:Ca,triangulateWithHoles:Ea,trimRight:ut,uboSyncFunctionsSTD40:Ll,uboSyncFunctionsWGSL:_m,uid:oe,uniformParsers:ot,unsafeEvalSupported:ua,updateQuadBounds:qo,updateRenderGroupTransform:Fp,updateRenderGroupTransforms:fl,updateTextBounds:Cp,updateTransformAndChildren:pl,updateTransformBackwards:wr,v8_0_0:de,v8_21_0:dt,v8_22_0:ku,v8_3_4:Cu,validateRenderables:Op,vertexGPUTemplate:uf,vertexGlTemplate:ff,warn:z,warnIgnoredTextureStyle:Mp,webworkerExt:vu,wordWrap:Sp,wordWrapTaggedLines:wp,wrapModeToGlAddress:sr},Symbol.toStringTag,{value:"Module"}));function ir(i){return i.replace(/\\/g,"/").replace(/\/+$/,"")}function Ax(i,e){const t=ir(i),s=ir(e.cwd);if(s&&(t===s||t.startsWith(s+"/")))return t.slice(s.length+1)||".";if(e.home){const n=ir(e.home);if(n&&(t===n||t.startsWith(n+"/")))return"~/"+t.slice(n.length+1)}return t.startsWith("/")?`//ext/${t.slice(t.lastIndexOf("/")+1)}`:t}function Rx(i){const e=ir(i);return e.slice(e.lastIndexOf("/")+1)}function wg(i){return/(^|\/)(tests?|__tests__|spec|specs)\//i.test(i)||/\.(test|spec)\.[cm]?[jt]sx?$/i.test(i)||/(^|\/)test_[^/]+\.py$/i.test(i)||/_test\.(go|rs|py)$/i.test(i)}var Bx=/\b(vitest|jest|mocha|pytest|py\.test|go\s+test|cargo\s+test|npm\s+test|pnpm\s+test|yarn\s+test|bun\s+test|npx\s+(vitest|jest|playwright)|rspec|phpunit|dotnet\s+test|mvn\s+test|gradle\s+test|make\s+test)\b/,Ix=/\b(tsc|tsup|vite\s+build|webpack|esbuild|rollup|next\s+build|cargo\s+build|go\s+build|make\b(?!\s+test)|npm\s+run\s+build|pnpm\s+(run\s+)?build|yarn\s+build|gradle\s+build|mvn\s+package|docker\s+build)\b/,Gx=/\b(npm\s+(i|install|ci)|pnpm\s+(i|install|add)|yarn(\s+add|\s+install)?|pip3?\s+install|poetry\s+(add|install)|cargo\s+add|go\s+get|brew\s+install|apt(-get)?\s+install|bun\s+(i|install|add))\b/,Dx=/\b(grep|rg|ag|ack|find|fd|locate)\b/,Fx=/^\s*(cat|head|tail|less|more|bat|wc|stat|jq)\b/;function Tg(i){const t=(i.split(/\s*(?:&&|\|\||;|\|)\s*/)[0]??"").trim().split(/\s+/).map(n=>n.replace(/^[({]+/,"")).filter(Boolean);let s=0;for(;s<t.length&&/^[A-Za-z_][A-Za-z0-9_]*=/.test(t[s]);)s++;if(t[s]==="cd"&&t.length>s+1){const n=i.split(/\s*&&\s*/)[1];if(n)return Tg(n)}return(t[s]??"").replace(/^.*\//,"").slice(0,40)||"sh"}function Ms(i){const e=i.replace(/^["']|["']$/g,"").trim();return!e||e.startsWith("-")||e==="/dev/null"||e.includes("$(")||e.startsWith("$")||/^\/dev\//.test(e)||/^&\d/.test(e)?null:e}function Ox(i){const e=new Set;for(const t of i.matchAll(/(?:^|[\s)])\d?>{1,2}\s*([^\s|&;<>]+)/g)){const s=Ms(t[1]??"");s&&e.add(s)}for(const t of i.matchAll(/\btee\s+(?:-[a-z]+\s+)*((?:[^\s|&;<>]+\s*)+)/g))for(const s of(t[1]??"").split(/\s+/)){const r=Ms(s);r&&e.add(r)}for(const t of i.matchAll(/\bsed\s+-i\S*\s+(.+?)(?=\s*(?:&&|\|\||;|\||$))/g)){const r=((t[1]??"").match(/"[^"]*"|'[^']*'|\S+/g)??[]).filter(n=>!n.startsWith("-")&&!n.startsWith("'")&&!n.startsWith('"')&&!/^s[/|#]/.test(n)&&!/^-e$/.test(n));for(const n of r){const o=Ms(n);o&&e.add(o)}}for(const t of i.matchAll(/\b(?:cp|mv)\s+(?:-[a-zA-Z]+\s+)*((?:[^\s|&;<>]+\s+)+)([^\s|&;<>]+)/g)){const s=Ms(t[2]??"");s&&e.add(s)}for(const t of i.matchAll(/\btouch\s+((?:[^\s|&;<>]+\s*)+)/g))for(const s of(t[1]??"").split(/\s+/)){const r=Ms(s);r&&e.add(r)}return[...e]}function Lx(i){const e=new Set;for(const t of i.split(/\s*(?:&&|\|\||;|\|)\s*/)){const s=t.match(/^\s*(?:cat|head|tail|less|more|bat|wc)\s+(?:-[^\s]+\s+)*((?:[^\s|&;<>]+\s*)+)/);if(s)for(const r of(s[1]??"").split(/\s+/)){const n=Ms(r);n&&!/^\d+$/.test(n)&&e.add(n)}}return[...e]}function Ux(i){const e=Tg(i),t=Ox(i),s=Lx(i);let r="other";return Bx.test(i)?r="test":Ix.test(i)?r="build":Gx.test(i)?r="install":/^\s*git\b/.test(i)||e==="git"||e==="gh"?r="git":t.length?r="write_file":Dx.test(i)&&e!=="cd"?r="search":Fx.test(i)&&s.length&&(r="read_file"),{argv0:e,intent:r,writes:t,reads:s}}var ge=i=>i?parseInt(i,10):0;function Nx(i){const e=i.length>2e4?i.slice(-2e4):i;let t=e.match(/Tests\s+(?:(\d+)\s+failed\s*\|\s*)?(\d+)\s+passed(?:\s*\|\s*(\d+)\s+skipped)?/);if(t)return{failed:ge(t[1]),passed:ge(t[2]),...t[3]?{skipped:ge(t[3])}:{},framework:"vitest"};if(t=e.match(/Tests\s+(\d+)\s+failed\s*\((\d+)\)/),t)return{failed:ge(t[1]),passed:Math.max(0,ge(t[2])-ge(t[1])),framework:"vitest"};if(t=e.match(/Tests:\s+(?:(\d+)\s+failed,\s*)?(?:(\d+)\s+skipped,\s*)?(\d+)\s+passed,\s*(?:(\d+)\s+skipped,\s*)?\d+\s+total/),t)return{failed:ge(t[1]),passed:ge(t[3]),...t[2]??t[4]?{skipped:ge(t[2]??t[4])}:{},framework:"jest"};if(t=e.match(/Tests:\s+(\d+)\s+failed,\s*\d+\s+total/),t)return{failed:ge(t[1]),passed:0,framework:"jest"};if(t=e.match(/=+\s*(?:(\d+)\s+failed,?\s*)?(?:(\d+)\s+passed,?\s*)?(?:(\d+)\s+skipped,?\s*)?(?:\d+\s+(?:error|errors|warnings?|deselected|xfailed|xpassed),?\s*)*in\s+[\d.]+s/),t&&(t[1]||t[2]))return{failed:ge(t[1]),passed:ge(t[2]),...t[3]?{skipped:ge(t[3])}:{},framework:"pytest"};if(/^--- (?:PASS|FAIL):/m.test(e)||/^(?:ok|FAIL)\s+\S+\s+(?:[\d.]+s|\(cached\))/m.test(e)){const a=(e.match(/^--- FAIL:/gm)??[]).length||(e.match(/^FAIL\s+\S+\s+[\d.]+s/gm)??[]).length,l=(e.match(/^--- PASS:/gm)??[]).length||(e.match(/^ok\s+\S+/gm)??[]).length;return{failed:a,passed:l,framework:"go"}}if(t=e.match(/test result:\s*\w+\.\s*(\d+)\s+passed;\s*(\d+)\s+failed;\s*(\d+)\s+ignored/),t)return{passed:ge(t[1]),failed:ge(t[2]),skipped:ge(t[3]),framework:"cargo"};const s=e.match(/^\s*(\d+)\s+passing\b/m),r=e.match(/^\s*(\d+)\s+failing\b/m);if(s||r){const a=e.match(/^\s*(\d+)\s+pending\b/m);return{passed:ge(s?.[1]),failed:ge(r?.[1]),...a?{skipped:ge(a[1])}:{},framework:"mocha"}}const n=e.match(/^\s*(\d+)\s+passed\s*\(/m),o=e.match(/^\s*(\d+)\s+failed\b/m);return n||o?{passed:ge(n?.[1]),failed:ge(o?.[1]),framework:"playwright"}:null}var We=i=>i&&typeof i=="object"?i:{},we=i=>typeof i=="string"?i:void 0,rr=i=>i?(i.match(/\n/g)?.length??0)+(i.endsWith(`
|
|
966
|
+
`);return new Function("ps","f32v","u32v",r)}class vg{constructor(e){this._size=0,this._generateParticleUpdateCache={};const t=this._size=e.size??1e3,s=e.properties;let r=0,n=0;for(const c in s){const u=s[c],d=gt(u.format);u.dynamic?n+=d.stride:r+=d.stride}this._dynamicStride=n/4,this._staticStride=r/4,this.staticAttributeBuffer=new Qt(t*4*r),this.dynamicAttributeBuffer=new Qt(t*4*n),this.indexBuffer=Oo(t);const o=new Mi;let a=0,l=0;this._staticBuffer=new at({data:new Float32Array(1),label:"static-particle-buffer",shrinkToFit:!1,usage:ae.VERTEX|ae.COPY_DST}),this._dynamicBuffer=new at({data:new Float32Array(1),label:"dynamic-particle-buffer",shrinkToFit:!1,usage:ae.VERTEX|ae.COPY_DST});for(const c in s){const u=s[c],d=gt(u.format);u.dynamic?(o.addAttribute(u.attributeName,{buffer:this._dynamicBuffer,stride:this._dynamicStride*4,offset:a*4,format:u.format}),a+=d.size):(o.addAttribute(u.attributeName,{buffer:this._staticBuffer,stride:this._staticStride*4,offset:l*4,format:u.format}),l+=d.size)}o.addIndex(this.indexBuffer);const h=this.getParticleUpdate(s);this._dynamicUpload=h.dynamicUpdate,this._staticUpload=h.staticUpdate,this.geometry=o}getParticleUpdate(e){const t=Ex(e);return this._generateParticleUpdateCache[t]?this._generateParticleUpdateCache[t]:(this._generateParticleUpdateCache[t]=this.generateParticleUpdate(e),this._generateParticleUpdateCache[t])}generateParticleUpdate(e){return bg(e)}update(e,t){e.length>this._size&&(t=!0,this._size=Math.max(e.length,this._size*1.5|0),this.staticAttributeBuffer=new Qt(this._size*this._staticStride*4*4),this.dynamicAttributeBuffer=new Qt(this._size*this._dynamicStride*4*4),this.indexBuffer=Oo(this._size),this.geometry.indexBuffer.setDataWithSize(this.indexBuffer,this.indexBuffer.byteLength,!0));const s=this.dynamicAttributeBuffer;if(this._dynamicUpload(e,s.float32View,s.uint32View),this._dynamicBuffer.setDataWithSize(this.dynamicAttributeBuffer.float32View,e.length*this._dynamicStride*4,!0),t){const r=this.staticAttributeBuffer;this._staticUpload(e,r.float32View,r.uint32View),this._staticBuffer.setDataWithSize(r.float32View,e.length*this._staticStride*4,!0)}}destroy(){this._staticBuffer.destroy(),this._dynamicBuffer.destroy(),this.geometry.destroy()}}function Ex(i){const e=[];for(const t in i){const s=i[t];e.push(t,s.code,s.dynamic?"d":"s")}return e.join("_")}Y.add(bu,vu);const Px=Object.freeze(Object.defineProperty({__proto__:null,AbstractRenderer:fs,AbstractText:ap,AbstractTextSystem:Ja,AccessibilitySystem:R_,AlphaMask:ea,AlphaMaskPipe:Hr,Application:_a,ApplicationInitHook:fa,BLEND_TO_NPM:Kd,BREAKING_SPACES:fp,BREAKING_SPACES_SET:pp,BREAK_AFTER_CHARS:gp,BREAK_AFTER_CHARS_SET:_p,BUFFER_TYPE:hi,BackgroundSystem:Up,Batch:Jd,BatchGeometry:nf,BatchTextureArray:Qd,BatchableGraphics:Or,BatchableSprite:Nr,BatchableText:kp,Batcher:sf,BatcherPipe:zr,BigPool:Se,BindGroup:At,BindGroupSystem:Yl,BlendModePipe:jr,Bounds:Ee,BrowserAdapter:td,Buffer:at,BufferImageSource:br,BufferResource:ki,BufferUsage:ae,CLEAR:ye,COLLAPSIBLE_SPACES:mp,Cache:Zt,CanvasBatchAdaptor:Ap,CanvasColorMaskPipe:ol,CanvasContextSystem:cl,CanvasFilterSystem:Yf,CanvasGraphicsAdaptor:dl,CanvasGraphicsContextSystem:rp,CanvasGraphicsPipe:za,CanvasLimitsSystem:ul,CanvasObserver:na,CanvasPool:Rt,CanvasPoolClass:qf,CanvasRenderTargetAdaptor:sm,CanvasRenderTargetSystem:kl,CanvasRenderer:am,CanvasRendererTextSystem:el,CanvasSource:je,CanvasStencilMaskPipe:ll,CanvasTextGenerator:Jt,CanvasTextMetrics:St,CanvasTextPipe:Qa,CanvasTextSystem:tl,CanvasTextureSystem:El,Circle:Er,Color:le,ColorMask:ta,ColorMaskPipe:al,Container:_e,CustomRenderPipe:Wr,DEG_TO_RAD:Su,DOMAdapter:te,DOMPipe:Vf,DefaultBatcher:Fr,DefaultShader:yo,Ellipse:Pr,EventBoundary:jf,EventEmitter:Re,EventSystem:Xf,EventsTicker:ft,ExtensionType:S,ExtractSystem:zp,FederatedContainer:ay,FederatedEvent:Ls,FederatedMouseEvent:vi,FederatedPointerEvent:Fe,FederatedWheelEvent:cs,FillGradient:Xe,FillPattern:Us,Filter:ca,FilterEffect:ui,FilterPipe:Jf,FilterSystem:ep,GCManagedHash:lt,GCSystem:Vp,GL_FORMATS:yr,GL_TARGETS:Ds,GL_TYPES:re,GPUTextureGpuData:fg,GenerateTextureSystem:yl,Geometry:Mi,GlBackBufferSystem:pm,GlBatchAdaptor:il,GlBuffer:lm,GlBufferSystem:Pl,GlColorMaskSystem:Il,GlContextSystem:cm,GlEncoderSystem:Gl,GlGeometryGpuData:dm,GlGeometrySystem:Rl,GlGraphicsAdaptor:Xl,GlLimitsSystem:Dl,GlMeshAdaptor:ql,GlProgram:ds,GlProgramData:wm,GlRenderTarget:mm,GlRenderTargetAdaptor:bm,GlRenderTargetSystem:Ul,GlShaderSystem:Jr,GlStateSystem:Gm,GlStencilSystem:Fl,GlTexture:Dm,GlTextureSystem:jl,GlUboSystem:Qr,GlUniformGroupSystem:en,GlobalResourceRegistry:us,GlobalUniformSystem:bl,Gpu3dMipmapGenerator:ug,GpuBatchAdaptor:rl,GpuBlendModesToPixi:Ge,GpuBufferData:Qm,GpuBufferSystem:Kl,GpuColorMaskSystem:Zl,GpuDeviceSystem:tn,GpuEncoderSystem:Ql,GpuGraphicsAdaptor:uh,GpuGraphicsContext:Ef,GpuLimitsSystem:Jl,GpuMeshAdapter:dh,GpuMipmapGenerator:dg,GpuMsaaRestore:rg,GpuProgram:Ut,GpuRenderTarget:ng,GpuRenderTargetAdaptor:og,GpuRenderTargetSystem:ih,GpuShaderSystem:rh,GpuStateSystem:nh,GpuStencilModesToPixi:It,GpuStencilSystem:eh,GpuTextureSystem:ch,GpuUboSystem:sn,GpuUniformBatchPipe:th,Graphics:Pe,GraphicsContext:Ye,GraphicsContextRenderData:Pf,GraphicsContextSystem:Ur,GraphicsGpuData:np,GraphicsPath:mt,GraphicsPipe:Wa,HelloSystem:Xr,ImageSource:pi,InstructionSet:Sr,LoaderParserPriority:ia,MaskEffectManager:lr,MaskEffectManagerClass:zu,MaskFilter:ip,Matrix:L,NEWLINES:up,NEWLINES_SET:dp,NEWLINE_MATCH_REGEX:xp,NEWLINE_SPLIT_REGEX:yp,NOOP:Vo,ObservablePoint:Me,PI_2:wu,ParticleBuffer:vg,PassthroughFilter:Qf,PipelineSystem:sh,Point:ce,Polygon:Es,Pool:Fu,PoolGroupClass:Ou,RAD_TO_DEG:Tu,Rectangle:se,RenderBundle:eg,RenderGroup:hr,RenderGroupPipe:$r,RenderGroupSystem:ml,RenderTarget:li,RenderTargetSystem:Yr,RenderTexture:Ci,RenderableGCSystem:qp,RendererInitHook:pa,RendererType:Ze,ResizePlugin:ma,Resolver:ra,RoundedRectangle:Ar,STATE_BITS:ha,STENCIL_MODES:me,SVGParser:Hf,SchedulerSystem:vl,ScreenSizeRegistry:Zo,Shader:_t,ShaderOverrides:Bs,ShaderStage:fe,ShapePath:Df,SharedRenderPipes:Cl,SharedSystems:qr,Sprite:os,SpritePipe:Vr,Spritesheet:Jn,State:yt,StencilMask:sa,StencilMaskPipe:hl,SystemRunner:da,Text:Ep,TextStyle:Gs,Texture:H,TextureGCSystem:Yp,TextureMatrix:Xo,TexturePool:Te,TexturePoolClass:Qu,TextureSource:ue,TextureStyle:Lt,TextureView:Nl,Ticker:$e,TickerListener:Qi,TickerPlugin:ga,UNIFORM_TO_ARRAY_SETTERS:Am,UNIFORM_TO_SINGLE_SETTERS:Pm,UNIFORM_TYPES_MAP:Ed,UNIFORM_TYPES_VALUES:la,UPDATE_BLEND:Mr,UPDATE_COLOR:fi,UPDATE_PRIORITY:as,UPDATE_VISIBLE:ks,UboBatch:Jm,UboSystem:Kr,UniformGroup:Qe,VERSION:xi,VideoSource:nd,ViewContainer:Cr,ViewSystem:Jp,ViewableBuffer:Qt,WGSL_ALIGN_SIZE_DATA:Ps,WGSL_TO_STD40_SIZE:Zr,WebGLRenderer:Zm,WebGPURenderer:xg,accessibilityTarget:B_,addBits:po,addMaskBounds:Qo,addMaskLocalBounds:Jo,addProgramDefines:yd,appendSVGPath:Co,applyStyleParams:Do,assertMipmap3dTexture:lh,assignWithIgnore:Ju,autoDetectRenderer:Vd,bakeOverridesIntoSource:Fo,bgr2rgb:ss,blockDataMap:oh,boundsPool:pt,browserExt:bu,buildAdaptiveBezier:Ba,buildAdaptiveQuadratic:Af,buildArc:Ia,buildArcTo:Rf,buildArcToSvg:Bf,buildCircle:Is,buildContextBatches:kf,buildEllipse:vf,buildLine:Lr,buildPixelLine:Tf,buildPolygon:Sf,buildRectangle:Mf,buildRoundedRectangle:wf,buildSimpleUvs:bf,buildTriangle:Cf,buildUvs:xf,cacheAsTextureMixin:Lu,calculatePathArea:zf,calculateProjection:em,canUseNewCanvasBlendModes:Oa,canvasUtils:K,checkChildrenDidChange:Ko,checkForNestedPattern:Uf,checkMaxIfStatementsInShader:xa,childrenHelperMixin:Uu,cleanArray:Wp,cleanHash:Hp,clearList:gr,closePointEps:ka,collapseNewlines:qa,collapseSpaces:Xa,collectRenderablesMixin:Nu,color32BitToUniform:Ha,colorBit:va,colorBitGl:wa,compareModeToGlCompare:zm,compileBufferSync:Ol,compileHighShader:af,compileHighShaderGl:lf,compileHighShaderGlProgram:Ir,compileHighShaderGpuProgram:Br,compileHooks:mo,compileInputs:go,compileOutputs:of,compileShader:Bo,convertToList:Kt,copySearchParams:Qn,createGlUploadCubeTextureResource:Lm,createGpuUploadCubeTextureResource:hg,createIdFromString:ls,createIndicesForQuads:Oo,createStringVariations:cd,createUboElementsSTD40:gm,createUboElementsWGSL:tg,createUboSyncFunctionSTD40:xm,createUboSyncFunctionWGSL:ig,cullingMixin:Du,curveEps:xo,defaultFilterVert:Kf,defaultValue:zl,definedProps:jo,deprecation:N,detectVideoAlphaMode:id,earcut:Nd,effectsMixin:Hu,ensureAttributes:_r,ensureIsBuffer:ba,ensurePrecision:xd,ensureTextOptions:lp,executeInstructions:mr,extensions:Y,extractAttributesFromGlProgram:Sm,extractAttributesFromGpuProgram:Sd,extractStructAndGroups:Ji,extractSubpaths:Nf,extractSvgUrlId:So,fastCopy:dr,findMixin:Wu,fontStringFromTextStyle:pr,fragmentGPUTemplate:df,fragmentGlTemplate:pf,generateArraySyncSTD40:ym,generateArraySyncWGSL:sg,generateGpuLayoutGroups:Md,generateLayoutHash:Cd,generateParticleUpdateFunction:bg,generateProgram:Em,generateShaderSyncCode:vm,generateTextureBatchBit:Ta,generateTextureBatchBitGl:Sa,generateTextureMatrix:Aa,generateUniformsSync:Rm,getAdjustedBlendModeBlend:fo,getAttributeInfoFromFormat:gt,getBatchSamplersUniformGroup:Ma,getCanvasBoundingBox:hp,getCanvasFillStyle:si,getCanvasTexture:Sl,getCharacterGroups:Ka,getDefaultUniformValue:Pd,getFastGlobalBoundsMixin:$u,getGeometryBounds:rf,getGlTypeFromFormat:um,getGlobalBounds:vr,getGlobalMixin:ju,getGlobalRenderableBounds:La,getLocalBounds:Tr,getMaxFragmentPrecision:_d,getMaxMiterRatio:$f,getMaxTexturesPerBatch:Zd,getOrientationOfPoints:ya,getPo2TextureFromSource:Ua,getTestContext:aa,getTexelRangeRects:Wl,getTextureBatchBindGroup:Rr,getUboData:Mm,getUniformData:Cm,getUrlExtension:ud,glUploadBufferImageResource:Fm,glUploadCompressedTextureResource:Om,glUploadImageResource:$l,glUploadVideoResource:Um,globalUniformsBit:mf,globalUniformsBitGl:gf,gpuUploadBufferImageResource:ag,gpuUploadCompressedTextureResource:lg,gpuUploadImageResource:ah,gpuUploadVideoResource:cg,groupD8:Q,hasTagMarkup:ja,hasTagStyles:Va,injectBits:_o,insertVersion:bd,isBreakAfterChar:bp,isBreakingSpace:Ve,isCanvasFilterCapable:Eo,isIntegerFormat:ar,isMobile:md,isNewline:wi,isPow2:ns,isRenderingToScreen:tm,isSafari:Pp,isSingleItem:Zn,isWebGLSupported:Wd,isWebGPUSupported:$d,loadEnvironmentExtensions:Gd,localUniformBit:oi,localUniformBitGl:$a,localUniformBitGroup2:op,logProgramError:km,mapCanvasBlendModesToPixi:Dp,mapFormatToGlFormat:Hm,mapFormatToGlInternalFormat:Wm,mapFormatToGlType:$m,mapGlToVertexFormat:Tm,mapType:Hl,mapViewDimensionToGlTarget:Vm,mapWebGLBlendModesToPixi:Bm,maskFrag:tp,maskVert:sp,maskWgsl:Ao,matrixPool:Ae,measureMixin:qu,measureTaggedText:vp,mipmapScaleModeToGlFilter:Nm,multiplyColors:di,multiplyHexColors:ts,nextPow2:rs,normalizeExtensionPriority:Js,onRenderMixin:Yu,parseSVGDefinitions:Ff,parseSVGFloatAttribute:ve,parseSVGPath:Xd,parseSVGStyle:Ga,parseTaggedText:cp,passthroughFrag:Zf,passthroughWgsl:Po,path:Rs,removeItems:Yo,removeStructAndGroupDuplicates:kd,resourceToTexture:ad,roundPixelsBit:Gr,roundPixelsBitGl:Dr,roundedShapeArc:If,roundedShapeQuadraticCurve:Gf,sayHello:jp,scaleModeToGlFilter:Go,setProgramName:vd,shapeBuilders:ps,sortMixin:Ku,spritesheetAsset:pd,squaredDistanceToLineSegment:qd,stripVersion:wd,styleAttributes:Mo,textureBit:Bp,textureBitGl:Ip,textureFrom:ld,toFillStyle:Ot,toLocalGlobalMixin:Zu,toStrokeStyle:bi,tokenize:Ya,tokenizeTaggedRuns:Tp,transformVertices:Ca,triangulateWithHoles:Ea,trimRight:ut,uboSyncFunctionsSTD40:Ll,uboSyncFunctionsWGSL:_m,uid:oe,uniformParsers:ot,unsafeEvalSupported:ua,updateQuadBounds:qo,updateRenderGroupTransform:Fp,updateRenderGroupTransforms:fl,updateTextBounds:Cp,updateTransformAndChildren:pl,updateTransformBackwards:wr,v8_0_0:de,v8_21_0:dt,v8_22_0:ku,v8_3_4:Cu,validateRenderables:Op,vertexGPUTemplate:uf,vertexGlTemplate:ff,warn:z,warnIgnoredTextureStyle:Mp,webworkerExt:vu,wordWrap:Sp,wordWrapTaggedLines:wp,wrapModeToGlAddress:sr},Symbol.toStringTag,{value:"Module"}));function ir(i){return i.replace(/\\/g,"/").replace(/\/+$/,"")}function Ax(i,e){const t=ir(i),s=ir(e.cwd);if(s&&(t===s||t.startsWith(s+"/")))return t.slice(s.length+1)||".";if(e.home){const n=ir(e.home);if(n&&(t===n||t.startsWith(n+"/")))return"~/"+t.slice(n.length+1)}return t.startsWith("/")?`//ext/${t.slice(t.lastIndexOf("/")+1)}`:t}function Rx(i){const e=ir(i);return e.slice(e.lastIndexOf("/")+1)}function wg(i){return/(^|\/)(tests?|__tests__|spec|specs)\//i.test(i)||/\.(test|spec)\.[cm]?[jt]sx?$/i.test(i)||/(^|\/)test_[^/]+\.py$/i.test(i)||/_test\.(go|rs|py)$/i.test(i)}var Bx=/\b(vitest|jest|mocha|pytest|py\.test|go\s+test|cargo\s+test|npm\s+test|pnpm\s+test|yarn\s+test|bun\s+test|npx\s+(vitest|jest|playwright)|rspec|phpunit|dotnet\s+test|mvn\s+test|gradle\s+test|make\s+test)\b/,Ix=/\b(tsc|tsup|vite\s+build|webpack|esbuild|rollup|next\s+build|cargo\s+build|go\s+build|make\b(?!\s+test)|npm\s+run\s+build|pnpm\s+(run\s+)?build|yarn\s+build|gradle\s+build|mvn\s+package|docker\s+build)\b/,Gx=/\b(npm\s+(i|install|ci)|pnpm\s+(i|install|add)|yarn(\s+add|\s+install)?|pip3?\s+install|poetry\s+(add|install)|cargo\s+add|go\s+get|brew\s+install|apt(-get)?\s+install|bun\s+(i|install|add))\b/,Dx=/\b(grep|rg|ag|ack|find|fd|locate)\b/,Fx=/^\s*(cat|head|tail|less|more|bat|wc|stat|jq)\b/;function Tg(i){const e=i.split(/\s*(?:&&|\|\||;|\|)\s*/),s=(e.find(o=>!/^\s*(\[|test\b|!)/.test(o))??e[0]??"").replace(/^\s*!\s*/,"").trim().split(/\s+/).map(o=>o.replace(/^[({]+/,"")).filter(Boolean);let r=0;for(;r<s.length&&/^[A-Za-z_][A-Za-z0-9_]*=/.test(s[r]);)r++;if(s[r]==="cd"&&s.length>r+1){const o=i.split(/\s*&&\s*/)[1];if(o)return Tg(o)}return(s[r]??"").replace(/^.*\//,"").slice(0,40)||"sh"}function Ms(i){const e=i.replace(/^["']|["']$/g,"").trim();return!e||e.startsWith("-")||e==="/dev/null"||e.includes("$(")||e.startsWith("$")||/^\/dev\//.test(e)||/^&\d/.test(e)?null:e}function Ox(i){const e=new Set;for(const t of i.matchAll(/(?:^|[\s)])\d?>{1,2}\s*([^\s|&;<>]+)/g)){const s=Ms(t[1]??"");s&&e.add(s)}for(const t of i.matchAll(/\btee\s+(?:-[a-z]+\s+)*((?:[^\s|&;<>]+\s*)+)/g))for(const s of(t[1]??"").split(/\s+/)){const r=Ms(s);r&&e.add(r)}for(const t of i.matchAll(/\bsed\s+-i\S*\s+(.+?)(?=\s*(?:&&|\|\||;|\||$))/g)){const r=((t[1]??"").match(/"[^"]*"|'[^']*'|\S+/g)??[]).filter(n=>!n.startsWith("-")&&!n.startsWith("'")&&!n.startsWith('"')&&!/^s[/|#]/.test(n)&&!/^-e$/.test(n));for(const n of r){const o=Ms(n);o&&e.add(o)}}for(const t of i.matchAll(/\b(?:cp|mv)\s+(?:-[a-zA-Z]+\s+)*((?:[^\s|&;<>]+\s+)+)([^\s|&;<>]+)/g)){const s=Ms(t[2]??"");s&&e.add(s)}for(const t of i.matchAll(/\btouch\s+((?:[^\s|&;<>]+\s*)+)/g))for(const s of(t[1]??"").split(/\s+/)){const r=Ms(s);r&&e.add(r)}return[...e]}function Lx(i){const e=new Set;for(const t of i.split(/\s*(?:&&|\|\||;|\|)\s*/)){const s=t.match(/^\s*(?:cat|head|tail|less|more|bat|wc)\s+(?:-[^\s]+\s+)*((?:[^\s|&;<>]+\s*)+)/);if(s)for(const r of(s[1]??"").split(/\s+/)){const n=Ms(r);n&&!/^\d+$/.test(n)&&e.add(n)}}return[...e]}function Ux(i){const e=Tg(i),t=Ox(i),s=Lx(i);let r="other";return Bx.test(i)?r="test":Ix.test(i)?r="build":Gx.test(i)?r="install":/^\s*git\b/.test(i)||e==="git"||e==="gh"?r="git":t.length?r="write_file":Dx.test(i)&&e!=="cd"?r="search":Fx.test(i)&&s.length&&(r="read_file"),{argv0:e,intent:r,writes:t,reads:s}}var ge=i=>i?parseInt(i,10):0;function Nx(i){const e=i.length>2e4?i.slice(-2e4):i;let t=e.match(/Tests\s+(?:(\d+)\s+failed\s*\|\s*)?(\d+)\s+passed(?:\s*\|\s*(\d+)\s+skipped)?/);if(t)return{failed:ge(t[1]),passed:ge(t[2]),...t[3]?{skipped:ge(t[3])}:{},framework:"vitest"};if(t=e.match(/Tests\s+(\d+)\s+failed\s*\((\d+)\)/),t)return{failed:ge(t[1]),passed:Math.max(0,ge(t[2])-ge(t[1])),framework:"vitest"};if(t=e.match(/Tests:\s+(?:(\d+)\s+failed,\s*)?(?:(\d+)\s+skipped,\s*)?(\d+)\s+passed,\s*(?:(\d+)\s+skipped,\s*)?\d+\s+total/),t)return{failed:ge(t[1]),passed:ge(t[3]),...t[2]??t[4]?{skipped:ge(t[2]??t[4])}:{},framework:"jest"};if(t=e.match(/Tests:\s+(\d+)\s+failed,\s*\d+\s+total/),t)return{failed:ge(t[1]),passed:0,framework:"jest"};if(t=e.match(/=+\s*(?:(\d+)\s+failed,?\s*)?(?:(\d+)\s+passed,?\s*)?(?:(\d+)\s+skipped,?\s*)?(?:\d+\s+(?:error|errors|warnings?|deselected|xfailed|xpassed),?\s*)*in\s+[\d.]+s/),t&&(t[1]||t[2]))return{failed:ge(t[1]),passed:ge(t[2]),...t[3]?{skipped:ge(t[3])}:{},framework:"pytest"};if(/^--- (?:PASS|FAIL):/m.test(e)||/^(?:ok|FAIL)\s+\S+\s+(?:[\d.]+s|\(cached\))/m.test(e)){const a=(e.match(/^--- FAIL:/gm)??[]).length||(e.match(/^FAIL\s+\S+\s+[\d.]+s/gm)??[]).length,l=(e.match(/^--- PASS:/gm)??[]).length||(e.match(/^ok\s+\S+/gm)??[]).length;return{failed:a,passed:l,framework:"go"}}if(t=e.match(/test result:\s*\w+\.\s*(\d+)\s+passed;\s*(\d+)\s+failed;\s*(\d+)\s+ignored/),t)return{passed:ge(t[1]),failed:ge(t[2]),skipped:ge(t[3]),framework:"cargo"};const s=e.match(/^\s*(\d+)\s+passing\b/m),r=e.match(/^\s*(\d+)\s+failing\b/m);if(s||r){const a=e.match(/^\s*(\d+)\s+pending\b/m);return{passed:ge(s?.[1]),failed:ge(r?.[1]),...a?{skipped:ge(a[1])}:{},framework:"mocha"}}const n=e.match(/^\s*(\d+)\s+passed\s*\(/m),o=e.match(/^\s*(\d+)\s+failed\b/m);return n||o?{passed:ge(n?.[1]),failed:ge(o?.[1]),framework:"playwright"}:null}var We=i=>i&&typeof i=="object"?i:{},we=i=>typeof i=="string"?i:void 0,rr=i=>i?(i.match(/\n/g)?.length??0)+(i.endsWith(`
|
|
967
967
|
`)?0:1):0;function zx(i){const e=We(i).structuredPatch;if(!Array.isArray(e))return null;let t=0,s=0;for(const r of e){const n=We(r).lines;if(Array.isArray(n))for(const o of n)typeof o=="string"&&(o.startsWith("+")?t++:o.startsWith("-")&&s++)}return{added:t,removed:s,hunks:e.length}}function Hx(i){if(typeof i=="string")return i;const e=We(i),t=[we(e.stdout),we(e.stderr),we(e.output)].filter(s=>!!s);return t.length?t.join(`
|
|
968
968
|
`):Array.isArray(i)?i.map(s=>we(We(s).text)??"").join(`
|
|
969
|
-
`):""}function Wx(i){let e=0;for(const t of i.matchAll(/<<-?\s*(['"]?)(\w+)\1[^\n]*\n([\s\S]*?)\n\2(?=\n|$)/g))e+=rr(t[3]);return e===0&&/(?:^|[\s)])\d?>{1,2}\s*[^\s|&;<>]+/.test(i)&&!/>\s*\/dev\/null/.test(i)&&(e=1),e}var $x=new Set(["Grep","Glob","LS","ToolSearch"]),Vx=new Set(["WebSearch","WebFetch"]),jx=new Set(["TodoWrite","TodoRead","Skill","EnterPlanMode","ExitPlanMode","EnterWorktree","ExitWorktree","NotebookRead","ListAgents","SendMessage","TaskStop","Monitor","ScheduleWakeup","ReportFindings"]);function tu(i,e){const t=We(i.input),s=i.response,r=!i.isError&&We(s).interrupted!==!0,n=a=>Ax(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(We(We(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=zx(s)??{added:rr(we(t.new_string)??we(t.new_source)),removed:rr(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=We(s),h=l.type==="create"||l.type===void 0&&l.originalFile===null;return{bodies:[{kind:"write_file",path:n(a),added:rr(we(t.content)),created:h}]}}case"Bash":{const a=we(t.command)??"",l=Ux(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=Wx(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=Nx(Hx(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=We(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($x.has(i.name)){const a=We(s).numFiles??We(s).numLines??We(s).count;return{bodies:[{kind:"search",scope:"repo",...typeof a=="number"?{hits:a}:{}}]}}return Vx.has(i.name)?{bodies:[{kind:"search",scope:"web"}]}:jx.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 Xx=[/\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,/✅/],qx=[/\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],su=600;function iu(i){if(!i)return!1;const e=i.length>su?i.slice(-su):i;return qx.some(t=>t.test(e))?!1:Xx.some(t=>t.test(e))}function Yx(i){if(!i)return{};const e=i.trim().split(/\n{2,}/).filter(t=>t.trim()).pop()?.replace(/\s+/g," ").trim()??"";return e?{note:e.length>240?"…"+e.slice(-239):e}:{}}var Kx=new Set(["user","assistant","system"]),qi=i=>i&&typeof i=="object"?i:{},be=i=>typeof i=="string"?i:void 0;function Zx(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=Qx(t,e);return{events:n.events,warnings:[...s,...n.warnings]}}function Qx(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 m=()=>({cwd:l,...e.home?{home:e.home}:{}}),g=(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=qi(x),v=be(b.type)??"";if(!Kx.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,g(w,`${a||"session"}:start`,{kind:"session_start",repoId:Rx(l)||"repo",...h?{branch:h}:{}})),u=w;const T=y(b),E=qi(b.message),P=E.content;if(v==="system"){if(b.subtype==="api_error"){const k=typeof b.retryAttempt=="number"?b.retryAttempt:0,I=typeof b.maxRetries=="number"?b.maxRetries:0;g(w,be(b.uuid)??`sys:${f}`,{kind:"error",where:"api",retrying:k<I},T?{agentId:T}:{})}continue}if(v==="assistant"){const k=Array.isArray(P)?P:[];for(const I of k){const G=qi(I);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 F=be(G.text);F&&(d=F)}}typeof P=="string"&&!T&&(d=P),E.stop_reason==="end_turn"&&!T&&g(w,`${be(b.uuid)??f}:turn`,{kind:"turn_end",claimedSuccess:iu(d),...Yx(d)});continue}b.toolDenialKind!==void 0&&g(w,`${be(b.uuid)??f}:deny`,{kind:"waiting_for_user",reason:"permission"});const A=Array.isArray(P)?P:[];for(const k of A){const I=qi(k);if(I.type!=="tool_result")continue;const G=be(I.tool_use_id);if(!G)continue;const F=n.get(G);if(!F){s.push({code:"unpaired_result",detail:G});continue}n.delete(G);const X=b.toolUseResult??I.content,C=tu({name:F.name,input:F.input,response:X,isError:I.is_error===!0,durationMs:Math.max(0,w-F.ts)},m());C.warning&&s.push(C.warning);const M=F.agentId??T,B=M?o.get(M):void 0,R={...M?{agentId:M}:{},...B?{parentId:B}:{}};C.bodies.forEach((O,U)=>g(F.ts,U===0?G:`${G}:${U}`,O,R)),C.pendingSubagent&&o.set(C.pendingSubagent.childId,G)}A.length===0&&typeof P=="string"&&/\[Request interrupted by user/i.test(P)&&g(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=tu({name:b.name,input:b.input,isError:!0},m());v.warning&&s.push(v.warning),v.bodies.forEach((w,T)=>g(b.ts,T===0?x:`${x}:${T}`,w,b.agentId?{agentId:b.agentId}:{}))}for(const[x,b]of o)g(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,g(u,`${a||"session"}:end`,{kind:"session_end",reason:"stop",claimedSuccess:iu(d)})),{events:t,warnings:s}}function Lo(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 ci(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 Jx=/(^|\/)(schema\.(sql|prisma|graphql|gql)|.*\.(sql|prisma|db|sqlite)|migrations?\/|drizzle\/|models?\/.*\.(ts|js|py|rb)$)/i,eb=/(^|\/)(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 tb(i){return eb.test(i)}function Sg(i){return wg(i)?"beacon":Jx.test(i)?"archive":"building"}function ru(i){return typeof i.loc=="number"?i.loc:typeof i.size=="number"?Math.max(1,Math.round(i.size/40)):1}function sb(i,e){const t=i.filter(n=>!tb(n.path)),s=Math.max(1,...t.map(ru)),r=Math.max(1,...t.map(n=>n.churn??0));return t.map(n=>{const o=ru(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:Sg(n.path),touched:a}})}function nu(i,e){const t=Math.sqrt(i/Math.max(1,e));return Math.max(1,Math.min(5,Math.ceil(t*5)))}function ou(i){return i>=5?3:i>=3?2:1}var ib={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 rb(i,e={}){const t=i.map(p=>p.path.toLowerCase()),s=p=>t.some(m=>p.test(m)),r=p=>t.filter(m=>p.test(m)).length,n=new Map;for(const p of t){const m=p.slice(p.lastIndexOf(".")+1),g=ib[m];g&&!/^(markdown|yaml|html|css|shell|sql)$/i.test(g)&&n.set(g,(n.get(g)??0)+1)}const o=[...n.entries()].sort((p,m)=>m[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,m)=>c.set(p,(c.get(p)??0)+m);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,m)=>m[1]-p[1]).map(([p])=>p);return{kinds:f.length?f:["unknown"],languages:o,files:i.length}}function nb(i){const e=i.cap??60,t=i.beaconCap??8,s=i.touchedCap??48,r=new Set((i.touched??[]).map(au).slice(0,s)),n=Lo(i.repoId),o=ci(n),a=i.files.map(M=>({...M,path:au(M.path)})),l=sb(a,r),h=Math.max(1,...l.map(M=>M.loc)),c=[...l].sort((M,B)=>B.score-M.score||M.file.path.localeCompare(B.file.path)),u=cu(c.filter(M=>M.kind==="beacon"),t),d=cu(c.filter(M=>M.kind!=="beacon"),e),f=[...d,...u],p=f.length<l.length,m=new Map;for(const M of d){const B=Ln(M.file.path);(m.get(B)??m.set(B,[]).get(B)).push(M)}const g=[...m.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??Ti[n%Ti.length],w=o()*Math.PI*2,T=g.map(M=>{const B=m.get(M).sort((U,q)=>q.score-U.score||U.file.path.localeCompare(q.file.path)),R=B.reduce((U,q)=>U+ou(nu(q.loc,h))**2,0),O=Math.max(3,Math.ceil(Math.sqrt(R*1.45)));return{name:M,items:B,side:O}}),E=[],P={x:-2,y:-2,w:4,h:4},A=Pg(v,T.map(M=>M.side),P,w,o);E.push(P,...A);const k=Ag(v,A);b.gx=k[0],b.gy=k[1],_.clear(),kt(_,b),T.forEach((M,B)=>{const R=A[B],O={id:`d:${M.name}`,label:M.name===""?"/":`${M.name}/`,bounds:R,cx:R.x+Math.floor(R.w/2),cy:R.y+Math.floor(R.h/2),placeIds:[]};for(const U of M.items){const q=nu(U.loc,h),J=ou(q),ie=Uo(_,O.cx,O.cy,J,R),V={id:`p:${U.file.path}`,kind:U.kind,path:U.file.path,label:lu(U.file.path),district:O.id,gx:ie[0],gy:ie[1],footprint:J,height:q,score:hu(U.score),touched:U.touched};kt(_,V),y.push(V),O.placeIds.push(V.id)}x.push(O)}),Math.ceil(kg(E));for(const M of E)for(let B=M.x-1;B<M.x+M.w+1;B++)for(let R=M.y-1;R<M.y+M.h+1;R++)_.add(`${B},${R}`);for(const M of u){const B=x.find(U=>U.id===`d:${Ln(M.file.path)}`),R=B?Bg(_,B,b,1):Si(_,b.gx+1,b.gy+1,o()*Math.PI*2,4,1),O={id:`p:${M.file.path}`,kind:"beacon",path:M.file.path,label:lu(M.file.path),district:B?.id??"",gx:R[0],gy:R[1],footprint:1,height:4,score:hu(M.score),touched:M.touched};kt(_,O),y.push(O),B?.placeIds.push(O.id)}const I=Si(_,b.gx+1,b.gy+1,w+Math.PI,5,2),G={id:"dock",kind:"dock",path:"",label:"dock",district:"",gx:I[0],gy:I[1],footprint:2,height:1,score:0,touched:!1};kt(_,G),y.push(G);const F=Rg(v,x,b,G);if(p)for(const M of x){const B=M.id.slice(2),R=l.filter(q=>q.kind!=="beacon"&&Ln(q.file.path)===B).length;if(R<=M.placeIds.length)continue;const O=Uo(_,M.cx,M.cy,1,M.bounds),U={id:`p:${B?B+"/":""}…`,kind:"overflow",path:`${B?B+"/":""}…`,label:`+${R-M.placeIds.length} more`,district:M.id,gx:O[0],gy:O[1],footprint:1,height:2,score:0,touched:!1};kt(_,U),y.push(U),M.placeIds.push(U.id)}const X=Eg(y,2),C=rb(a,i.manifests??{});return{repoId:i.repoId,seed:n,layout:v,profile:C,districts:x,places:y,paths:F,bounds:X,stats:{files:l.length,placed:f.length,capped:p}}}var au=i=>i.replace(/\\/g,"/").replace(/^\.\//,"").replace(/^\/+/,""),lu=i=>i.slice(i.lastIndexOf("/")+1),Ln=i=>i.includes("/")?i.slice(0,i.indexOf("/")):"",hu=i=>Math.round(i*1e3)/1e3;function cu(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 uu(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 Mg(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 Cg(i,e,t,s){return Mg(e,t,s).every(r=>!i.has(r))}function kt(i,e){for(const t of Mg(e.gx,e.gy,e.footprint))i.add(t)}function Uo(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(Cg(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 kg(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 Eg(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 Ti=["ring","grid","strip","scatter","terrace","spine"];function Pg(i,e,t,s,r){const n=e.length,o=[],a=Math.max(3,...e),l=c=>!uu(t,c,1)&&!o.some(u=>uu(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 g=e.slice(f,f+c),_=Math.max(...g)+2;let y=0;for(const x of g)u.push({x:y,y:d}),y+=x+2;d+=_,f+=c}const p=Math.max(...u.map((g,_)=>g.x+e[_])),m=d;for(let g=0;g<n;g++){let _={x:u[g].x-Math.round(p/2),y:u[g].y-Math.round(m/2),w:e[g],h:e[g]};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,m=u*(.5+r()*.7),g={x:Math.round(Math.cos(p)*m),y:Math.round(Math.sin(p)*m*.8),w:e[c],h:e[c]};l(g)&&(o.push(g),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,m;for(;;){const g=Math.round(Math.cos(f)*p),_=Math.round(Math.sin(f)*p*.8);if(m={x:g-Math.floor(d/2),y:_-Math.floor(d/2),w:d,h:d},l(m))break;p+=1}o.push(m),c=Math.max(c,p-d/2)}return o}}}function Ag(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 Rg(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 ob(i,e){if(i.layout===e)return i;const t=i.seed,s=ci(t^1374496523^Ti.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=Pg(e,h.map(y=>y.side),c,a,s),d=[c,...u],f=Ag(e,u);o.gx=f[0],o.gy=f[1],kt(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=Uo(r,v.cx,v.cy,w.footprint,b),E={...w,gx:T[0],gy:T[1]};kt(r,E),n.push(E),v.placeIds.push(E.id)}return v});Math.ceil(kg(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?Bg(r,x,o,1):Si(r,o.gx+1,o.gy+1,s()*Math.PI*2,4,1),v={...y,gx:b[0],gy:b[1]};kt(r,v),n.push(v),x?.placeIds.push(v.id)}const m=Si(r,o.gx+1,o.gy+1,a+Math.PI,5,2),g={...i.places.find(y=>y.kind==="dock"),gx:m[0],gy:m[1]};kt(r,g),n.push(g);const _=Rg(e,p,o,g);return{...i,layout:e,districts:p,places:n,paths:_,bounds:Eg(n,2)}}function Si(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(Cg(i,h,c,n))return[h,c]}return[e+r,t]}function Bg(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 Si(i,e.cx,e.cy,r,n,s)}var ab=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"}},lb=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 ab(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},ws(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=ws(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},ws(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},ws(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},ws(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",...i.note?{note:i.note}:{}},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},ws(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:Sg(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=>wg(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 nr(i,e,t){const s=new lb(e,t);for(const r of i)s.feed(r);return[...s.timeline]}var ws=(i,e,t)=>Math.min(t,Math.max(e,i));function hb(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 cb{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 m=s.createStereoPanner();m.pan.value=t,f.connect(p),p.connect(m),m.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 m=s.createGain();m.gain.setValueAtTime(1e-4,r),m.gain.exponentialRampToValueAtTime(c,r+.05),m.gain.exponentialRampToValueAtTime(1e-4,r+h);const g=s.createStereoPanner();g.pan.value=t,f.connect(p),p.connect(m),m.connect(g),g.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 ub=i=>1-Math.pow(1-i,3),Un=i=>db(.4,0,.2,1,i),du=i=>1+(1.70158+1)*Math.pow(i-1,3)+1.70158*Math.pow(i-1,2),rt=i=>Math.sin(Math.PI*Math.min(1,Math.max(0,i)));function db(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=m=>((a*m+o)*m+n)*m,d=m=>((c*m+h)*m+l)*m,f=m=>(3*a*m+2*o)*m+n;let p=r;for(let m=0;m<6;m++){const g=f(p);if(Math.abs(g)<1e-6)break;p-=(u(p)-r)/g}return d(Math.min(1,Math.max(0,p)))}const fb=64,No=32,Z=(i,e)=>({x:(i-e)*fb/2,y:(i+e)*No/2}),D=(i,e)=>({x:i.x,y:i.y-e}),is=(i,e,t)=>i+(e-i)*t,Be=(i,e,t)=>({x:is(i.x,e.x,t),y:is(i.y,e.y,t)}),pb=(i,e,t)=>i<e?e:i>t?t:i,Ue=(i,e,t)=>pb((i-e)/(t-e),0,1),fu=(i,e,t=1)=>i+e+t;function De(i,e,t,s=0){return[Z(i,e),Z(i+t,e),Z(i+t,e+t),Z(i,e+t)].map(r=>D(r,s))}const j=i=>i.flatMap(e=>[e.x,e.y]);class mb{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=is(this.tx,e,s),this.ty=is(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+ub(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 gb={roof:"pitched",eave:.14,furniture:"chimney",stripes:!1},_b={roof:"flat",eave:.05,furniture:"vent",stripes:!1},yb={roof:"capsule",eave:0,furniture:"dish",stripes:!1},Nn={island:gb,orbit:yb,metropolis:_b,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 Ig{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=Yi(s),o=Yi(r),a=`v${e}|${t}|${n}|${o}`;let l=this.gradients.get(a);return l||(l=bb(e,t,n,o),this.gradients.set(a,l)),l}hGrad(e,t,s,r){const n=Yi(s),o=Yi(r),a=`h${e}|${t}|${n}|${o}`;let l=this.gradients.get(a);return l||(l=vb(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=Z(r,n);return{ground:o,top:D(o,this.heightPx(t)+10),place:s}}standingSpot(e){const t=this.drawn.get(e);if(!t)return Z(0,0);const s=t.place;return Z(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=fu(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"?Lo(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?ee(u,16777215,o):ee(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(j(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?ee(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&&Nn[this.theme.id].roof!=="capsule"&&Nn[this.theme.id].roof!=="dome"){const u=l.map(p=>D(p,n));t.poly(j([u[3],u[2],D(u[2],4),D(u[3],4)])).fill(r.roofD),t.poly(j([u[2],u[1],D(u[1],4),D(u[2],4)])).fill(ee(r.roofD,0,.2)),t.poly(j(u.map(p=>D(p,4)))).fill(r.roof);const d=De(s.gx+.8,s.gy+.8,o-1.6,n+4);t.poly(j([d[3],d[2],D(d[2],10),D(d[3],10)])).fill(r.left),t.poly(j([d[2],d[1],D(d[1],10),D(d[2],10)])).fill(r.right),t.poly(j(d.map(p=>D(p,10)))).fill(r.top);const f=D(Z(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=>D(u,n)),D(Z(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(m=>D(m,n)),D(Z(s.gx+o/2,s.gy+o/2),n+16),r.roof,r.roofD);const f=D(Z(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 m=0;m<3;m++){const g=(this.time*.35+m/3)%1;t.circle(f.x+Math.sin(g*6+m)*4,f.y-18-g*26,3+g*6).fill({color:16777215,alpha:.22*(1-g)})}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=Nn[this.theme.id],o=t.footprint,a=n.eave,l=Lo(t.path),h=De(t.gx-a,t.gy-a,o+a*2,s),c=Z(t.gx+o/2,t.gy+o/2),u=ee(r.roofD,this.shadowInk,.35);switch(a>0&&(e.poly(j([h[3],h[2],D(h[2],-3),D(h[3],-3)])).fill({color:u,alpha:.9}),e.poly(j([h[2],h[1],D(h[1],-3),D(h[2],-3)])).fill({color:ee(u,0,.2),alpha:.9})),n.roof){case"pitched":{this.pyramid(e,h,D(c,s+12+o*9),r.roof,r.roofD);break}case"gable":{const f=11+o*7,p=D(Be(h[0],h[3],.5),s+f),m=D(Be(h[1],h[2],.5),s+f);e.poly(j([h[3],h[2],m,p])).fill(this.vGrad(ee(r.roof,16777215,.1),r.roof,p.y,h[3].y)),e.poly(j([h[0],h[1],m,p])).fill(ee(r.roofD,this.shadowInk,.2)),e.poly(j([h[2],h[1],m])).fill(ee(r.right,this.shadowInk,.1)),e.poly(j([h[3],h[0],p])).fill(r.left),e.moveTo(p.x,p.y).lineTo(m.x,m.y).stroke({width:1.4,color:16777215,alpha:.4,cap:"round"});break}case"flat":{const f=h.map(m=>D(m,3));e.poly(j([h[3],h[2],f[2],f[3]])).fill(r.roofD),e.poly(j([h[2],h[1],f[1],f[2]])).fill(ee(r.roofD,0,.2)),e.poly(j(f)).fill(this.hGrad(ee(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(j([p[3],p[2],D(p[2],6),D(p[3],6)])).fill(r.left),e.poly(j([p[2],p[1],D(p[1],6),D(p[2],6)])).fill(r.right),e.poly(j(p.map(m=>D(m,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(ee(r.roof,16777215,.22),ee(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(ee(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,m=a*(1-f*.45),g=De(t.gx-m,t.gy-m,o+m*2,p);e.poly(j([g[3],g[2],D(g[2],-2),D(g[3],-2)])).fill(u);const _=D(c,p+9+o*3);e.poly(j([D(g[3],3),D(g[2],3),_])).fill(r.roof),e.poly(j([D(g[2],3),D(g[1],3),_])).fill(r.roofD),e.poly(j([D(g[3],3),D(g[0],3),_])).fill(ee(r.roof,16777215,.1));for(const y of[g[1],g[2],g[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=D(c,s+16+o*8);this.pyramid(e,h,f,r.roof,r.roofD);for(let p=0;p<o*3;p++){const m=Be(h[3],h[2],p/(o*3)),g=Be(h[3],h[2],(p+1)/(o*3));e.moveTo(m.x,m.y).quadraticCurveTo((m.x+g.x)/2,(m.y+g.y)/2+4,g.x,g.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(ee(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:ee(r.roofD,16777215,.1),alpha:.6});break}}const d=D(Z(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(ee(r.roofD,0,.2)));break;case"vent":e.rect(d.x-4,d.y-5,8,5).fill(ee(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=D(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(xb(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 m=Be(f[3],f[2],p/(o*4)),g=Be(f[3],f[2],(p+1)/(o*4));e.poly([m.x,m.y,g.x,g.y,g.x,g.y-s*.35,m.x,m.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=m=>ee(m,this.theme.sky[0],f);return e.poly(j([d,u,D(u,n),D(d,n)])).fill(this.vGrad(p(ee(a,16777215,.08)),p(ee(a,this.shadowInk,.28)),d.y-n,d.y)),e.poly(j([u,c,D(c,n),D(u,n)])).fill(this.vGrad(p(ee(l,this.coolInk,.06)),p(ee(l,this.shadowInk,.38)),u.y-n,u.y)),e.poly(j([D(h,n),D(c,n),D(u,n),D(d,n)])).fill(this.hGrad(p(ee(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 ee(this.theme.vignette,0,.3)}get coolInk(){return ee(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=[Z(t.gx+a,t.gy+l),Z(t.gx+r+a,t.gy+l),Z(t.gx+r+a,t.gy+r+l),Z(t.gx+a,t.gy+r+l)],c=[o[1],h[1],h[2],h[3],o[3],o[2]];e.poly(j(c)).fill({color:this.shadowInk,alpha:.16});const u=[Z(t.gx+a*.6,t.gy+l*.6),Z(t.gx+r+a*.6,t.gy+l*.6),Z(t.gx+r+a*.6,t.gy+r+l*.6)];e.poly(j([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=Z(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(j([t[0],t[1],s])).fill(ee(n,this.shadowInk,.25)),e.poly(j([t[3],t[0],s])).fill(ee(r,16777215,.12)),e.poly(j([t[3],t[2],s])).fill(this.vGrad(ee(r,16777215,.06),r,s.y,t[2].y)),e.poly(j([t[2],t[1],s])).fill(this.vGrad(n,ee(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),m=f.x;e.poly([m-h,p-c,m+h,p+c,m+h,p+c-6,m-h,p-c-6]).fill({color:a,alpha:l}),e.poly([m-h,p-c-4.5,m+h,p+c-4.5,m+h,p+c-6,m-h,p-c-6]).fill({color:16777215,alpha:l*.45})}}outline(e,t,s,r,n){const o=t.map(a=>D(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(j([D(a[3],t*u),D(a[2],t*u),D(a[2],t*d),D(a[3],t*d)])).fill(n.roof),s.poly(j([D(a[2],t*u),D(a[1],t*u),D(a[1],t*d),D(a[2],t*d)])).fill(n.roofD);const l=D(Z(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,ee(o,0,.25)),this.pyramid(s,De(r.gx+.2,r.gy+.2,.6,t+11),D(Z(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(j([s[3],s[2],D(s[2],-5),D(s[3],-5)])).fill(this.theme.dock.post),e.poly(j([s[2],s[1],D(s[1],-5),D(s[2],-5)])).fill(ee(this.theme.dock.post,0,.2)),e.poly(j(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(ee(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=ci(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=Z(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=Z(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(j([r[3],r[2],D(r[2],-14),D(r[3],-14)])).fill(t.edgeDark),e.poly(j([r[2],r[1],D(r[1],-14),D(r[2],-14)])).fill(t.edge),e.poly(j(r)).fill(t.fill),e.poly(j(De(s.x+1,s.y+1,Math.max(s.w,s.h)-2))).fill({color:t.fillLight,alpha:.25}),e.poly(j(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(j([n[3],n[2],D(n[2],-10),D(n[3],-10)])).fill(t.edgeDark),e.poly(j([n[2],n[1],D(n[1],-10),D(n[2],-10)])).fill(t.edge),e.poly(j(n)).fill(t.fill);for(let o=1;o<r;o+=2){const a=Z(s.x+o,s.y),l=Z(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=Z(s.x,s.y+o),l=Z(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=ci(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])=>Z(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 Gs({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 Ep({text:t.label,style:e});s.anchor.set(.5,.5);const r=Z(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=ci(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=fu(a,l);const c=new Pe;h.addChild(c);const u=Z(a+.5,l+.5),d=(.85+e()*.4)*1.25,[f,p,m]=this.theme.propColors;let g;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(m),g=new Pe,g.ellipse(u.x+1*d,u.y-13*d,9.5*d,7.5*d).fill(ee(f,this.shadowInk,.25)),g.ellipse(u.x,u.y-16*d,9*d,8.5*d).fill(f),g.ellipse(u.x-4*d,u.y-19*d,6.5*d,6*d).fill(p),g.ellipse(u.x+4.5*d,u.y-20*d,5.5*d,5*d).fill(p),g.ellipse(u.x-3.5*d,u.y-22*d,3.2*d,2.4*d).fill({color:16777215,alpha:.32}),h.addChild(g)):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(m)):(c.rect(u.x-1,u.y-16*d,2,16*d).fill(m),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,...g?{canopy:g}:{}}),n++}}}const xb=i=>ee(i,16777215,.25);function bb(i,e,t,s){return new Xe({start:{x:0,y:t},end:{x:0,y:s},colorStops:[{offset:0,color:i},{offset:1,color:e}],textureSpace:"global"})}function vb(i,e,t,s){return new Xe({start:{x:t,y:0},end:{x:s,y:0},colorStops:[{offset:0,color:i},{offset:1,color:e}],textureSpace:"global"})}const Yi=i=>Math.round(i/2)*2;function ee(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 zo{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 wb=Object.freeze(Object.defineProperty({__proto__:null,Gremlin:zo},Symbol.toStringTag,{value:"Module"}));class Tb{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 Ct=[{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}],Gg=i=>Ct.find(e=>e.id===i),pu=i=>(.2126*(i>>16&255)+.7152*(i>>8&255)+.0722*(i&255))/255,Dg=(i,e)=>Math.abs(pu(i.body)-pu(e))>.22;function Fg(i,e,t){const s=a=>t===void 0||Dg(a,t);let r=Gg(e)??Ct[i%Ct.length];s(r)||(r=Ct.find((a,l)=>l>=i%Ct.length&&s(a))??Ct.find(s)??r);const n=Ct.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 Sb=Object.freeze(Object.defineProperty({__proto__:null,CAST:Ct,castById:Gg,pickCompany:Fg,readableOn:Dg},Symbol.toStringTag,{value:"Module"}));class Ho{constructor(e,t,s=Ct[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,m=s.shape==="tall"?-16:s.shape==="boxy"?-13:s.shape==="bean"?-12:-13.5;u.moveTo(-p*.9,m-p*.2).quadraticCurveTo(-p*.75,m-p*.95,p*.1,m-p*1.02).stroke({width:2.2,color:16777215,alpha:.5,cap:"round"}),u.moveTo(p*.95,m+p*.1).quadraticCurveTo(p*.8,m+p*.8,p*.1,m+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 g=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+g*6,3.2,5).fill(s.ear),u.ellipse(9,_+4-g*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+g*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+g*6,3.2,5).fill(s.ear),u.ellipse(9,_+4-g*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 E=y+T*4.6;if(h.mood==="happy"){u.beginPath(),u.arc(E,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(E-2.6,x).lineTo(E+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 P=s.eyes==="dot"?2.6:s.eyes==="sleepy"?2.4:h.mood==="focused"?3:4.3;u.ellipse(E,x,s.eyes==="dot"?2.6:3.4,P).fill(16777215),s.eyes==="sleepy"&&u.moveTo(E-3.4,x-2.2).lineTo(E+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 k=h.face*1.1+A*1.6,I=(h.look==="up"?-1.6:h.look==="down"?1.4:.3)-A*.8;h.mood==="lost"&&(k=Math.sin(r*3)*1.4,I=-1.2),u.ellipse(E+k,x+I,1.9,h.mood==="focused"?1.8:2.2).fill(s.ink),u.ellipse(E+k+.7,x+I-.8,.6,.6).fill(16777215),h.mood==="lost"&&u.moveTo(E-3,x-5.6-(T>0?0:1.3)).lineTo(E+3,x-5.6-(T>0?1.3:0)).stroke({width:1.6,color:s.ink,cap:"round"}),h.mood==="focused"&&u.moveTo(E-3.2,x-3.7-(T>0?1:0)).lineTo(E+3.2,x-3.7-(T>0?0:1)).stroke({width:1.6,color:s.ink,cap:"round"}),h.mood==="uneasy"&&u.moveTo(E-3,x-5).lineTo(E+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=rt(r*.5%1)*h.hiding;u.rotation=h.lean+T*.06}}}const Mb=Object.freeze(Object.defineProperty({__proto__:null,Pip:Ho},Symbol.toStringTag,{value:"Module"})),Tt=[0,2,4,7,9],Cb=[0,3,5,7,10],mu=[0,2,4,6,7,9,11],gu=[0,2,3,5,7,9,10],kb=[0,2,4,5,7,9,10],Eb=[0,2,4,6,8,10],Pb=[0,1,4,5,7,8,11],zn=[0,2,3,5,7,8,10],Ab={island:{scale:Tt,root:261.6,wave:"sine",gain:.05,every:16,len:[.45,.9]},orbit:{scale:mu,root:220,wave:"triangle",gain:.035,every:20,len:[.8,1.6]},metropolis:{scale:gu,root:196,wave:"triangle",gain:.04,every:18,len:[.3,.7]},harbour:{scale:kb,root:233,wave:"sine",gain:.045,every:17,len:[.5,1.1]},observatory:{scale:Eb,root:329.6,wave:"sine",gain:.035,every:22,len:[.9,1.8]},greenhouse:{scale:Tt,root:293.7,wave:"triangle",gain:.045,every:15,len:[.35,.8]},workshop:{scale:Tt,root:220,wave:"triangle",gain:.045,every:16,len:[.3,.6]},arcade:{scale:Cb,root:261.6,wave:"square",gain:.025,every:12,len:[.15,.35]},kingdom:{scale:gu,root:174.6,wave:"triangle",gain:.045,every:19,len:[.6,1.2]},outpost:{scale:zn,root:196,wave:"sine",gain:.04,every:21,len:[.8,1.6]},snowfield:{scale:Tt,root:392,wave:"sine",gain:.04,every:18,len:[.7,1.5]},canopy:{scale:Tt,root:246.9,wave:"triangle",gain:.045,every:14,len:[.3,.7]},lagoon:{scale:Tt,root:329.6,wave:"sine",gain:.045,every:15,len:[.4,.9]},volcano:{scale:zn,root:146.8,wave:"sawtooth",gain:.03,every:20,len:[.9,1.8]},cloudtop:{scale:mu,root:392,wave:"sine",gain:.04,every:17,len:[.8,1.6]},reef:{scale:Tt,root:174.6,wave:"sine",gain:.045,every:14,len:[.9,2]},bazaar:{scale:Pb,root:220,wave:"triangle",gain:.045,every:13,len:[.25,.6]},monastery:{scale:Tt,root:196,wave:"sine",gain:.05,every:24,len:[1.2,2.4]},moonbase:{scale:zn,root:164.8,wave:"sine",gain:.035,every:23,len:[1,2]},lanterns:{scale:Tt,root:523.3,wave:"sine",gain:.04,every:14,len:[.3,.7]}},qe={wave:"triangle",pitch:1,decay:1,tone:3200,surface:"grass"},Hn={wave:"square",pitch:1.18,decay:.8,tone:2600,surface:"metal"},_u={wave:"sawtooth",pitch:.95,decay:1.1,tone:2200,surface:"stone"},Rb={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"},Bb={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"},Ib={island:{voice:qe,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:Hn,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:_u,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:{...qe,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:{...Hn,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:{...qe,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:{...qe,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:{...qe,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:{...qe,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:{...qe,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:{...qe,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:{...qe,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:{...qe,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:{...qe,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:{...qe,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:{...Hn,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:{..._u,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}}},Wo=Object.fromEntries(Object.entries(Ib).map(([i,e])=>[i,{...e,voice:{...e.voice,instrument:Rb[i]},ambience:{...e.ambience,mood:Bb[i]},tune:Ab[i]}])),Gb=i=>i,Db=new Set(["curtain_up","curtain_down","test_outcome","celebrate","blocked_on_you","unverified_claim","spawn_gremlin","banish"]),Fb=[523.25,659.25,783.99,1046.5],Ie=(i,e)=>i+Math.random()*(e-i);class Ki{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||Db.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=Wo[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,m=.85+Math.random()*.3,g=u*h.pitch*p,_=d*h.decay*m,y=f.gain??.25,x={...f,lowpass:Math.min(f.lowpass??h.tone,h.tone),...f.slideTo?{slideTo:f.slideTo*h.pitch*p}:{}};switch(Gb(h.instrument)){case"pluck":s.tone(g,_*.6,{...x,type:"triangle",attack:.003,gain:y}),s.tone(g*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(g,_*1.8,{...x,type:"sine",attack:.004,gain:y}),s.tone(g*2.76,_*1.1,{...x,type:"sine",attack:.004,gain:y*.3}),s.tone(g*5.4,_*.5,{...x,type:"sine",attack:.004,gain:y*.12});return;case"marimba":s.tone(g,_*.5,{...x,type:"sine",attack:.003,gain:y}),s.tone(g*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(g,_*.35,{...x,type:"square",attack:.002,gain:y*.7}),s.tone(g*1.5,_*.2,{...x,type:"square",attack:.002,gain:y*.2});return;case"glass":s.tone(g,_*2,{...x,type:"sine",attack:.02,gain:y*.9}),s.tone(g*1.005,_*2,{...x,type:"sine",attack:.02,gain:y*.6}),s.tone(g*3,_*.8,{...x,type:"sine",attack:.01,gain:y*.15});return;case"wood":s.tone(g*.5,_*.3,{...x,type:"triangle",attack:.002,gain:y*.9,slideTo:g*.35}),s.noise(.04,{filter:"lowpass",freq:1200,gain:y*.5});return;case"drop":s.tone(g*.8,_*.7,{...x,type:"sine",attack:.006,gain:y,slideTo:g*1.6}),s.noise(.05,{filter:"bandpass",freq:900,q:1.5,gain:y*.25,sweepTo:2400});return;default:s.tone(g,_,{...x,type:f.type??h.wave,gain:y}),s.tone(g*.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"?Fb.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 Ob{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=Wo[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=Wo[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,m=0;for(let g=0;g<d;g++){const _=g===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=g===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)},m*1e3),m+=x*(Math.random()<.2?1.5:1)}this.tuneTimer=setTimeout(c,(m+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,m)=>setTimeout(()=>{this.current===e.id&&this.a.note(p,.22,.03,"triangle",(m/f.length-.5)*.8)},m*(150+m%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 Qs{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 Ig(t,s),this.particles=new Tb(n),this.company=Fg(t.seed,o,s.ground.fill),this.pip=new Ho(s,n,this.company.lead),this.camera=new mb(this.stage,n),this.sfx=new Ki(r),this.amb=new Ob(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}hitTest(e,t){const s=this.camera.scale,r=(a,l)=>{const h=this.camera.toScreen(a.x,a.y);return Math.hypot(h.x-e,h.y-t)<l*s},n=this.pip.drawn;if(r({x:n.x,y:n.y-18},26))return{kind:"lead",name:this.company.lead.name,mood:this.pip.pose.mood};for(const[a,l]of this.helpers){const h=l.drawn;if(r({x:h.x,y:h.y-14},22))return{kind:"helper",name:this.company.helpers.find(c=>c.id===a)?.name??"Helper"}}let o=null;for(const a of this.world.places){const l=this.worldLayer.positionOf(a.id);if(!l)continue;const h=this.camera.toScreen(l.ground.x,l.ground.y),c=this.camera.toScreen(l.top.x,l.top.y),u=(a.footprint*32+8)*s,d=h.y+a.footprint*16*s,f=c.y-6*s;if(e>=h.x-u&&e<=h.x+u&&t>=f&&t<=d){const p=u*(d-f);(!o||p<o.area)&&(o={place:a,area:p})}}return o?{kind:"place",place:o.place}:null}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&&Ki.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 zo(e.gremlinId,s,this.reducedMotion),a=this.worldLayer.positionOf(e.target),l=a?a.ground:Z(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 Ho(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 zo(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*rt(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:Un((h-d)/(1-d));if(o.x=is(u.x,c.x,f),o.y=is(u.y,c.y,f),o.moving=h>=d&&h<.98,o.face=c.x>=u.x?1:-1,h<d){const p=rt(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 m=Math.cos(p*2);if(o.sy=1+.05*m,o.sx=1-.05*m,o.lean=o.face*.07,h>.86){const g=rt((h-.86)/.14);o.lean=o.face*.16*g,o.sy=1-.06*g,o.sx=1+.05*g}}r==="pip"&&this._playing&&(this.footT+=s,this.footT>.19&&Ki.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=rt(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,Ki.plays("hammer",this.rate)&&this.sfx.play(a.kind==="build"?"hammer":"spark",{theme:this.theme,intensity:a.kind==="build"?a.intensity:.5});const m="target"in a?this.worldLayer.positionOf(a.target):this.worldLayer.positionOf("forge");m&&Math.random()<.7&&this.particles.burst(m.top.x+(Math.random()*24-12),m.top.y+10,2,[16766571,16774084],50,60)}}break}case"raise":o.look="up",o.sy=1+.05*rt(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=rt(Ue(h,0,.5));o.lean=-.25*u,o.sy=1-.1*u,o.sx=1+.08*u}else o.lift=rt(h)*14;break;case"spawn_gremlin":{const u=rt(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,m=d.x+Math.cos(f)*p,g=d.y+Math.sin(f)*p*.5;u&&(u.x=m,u.y=g,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*rt(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=rt(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/(No/2)+.6,r!=="pip"&&(o.mood="focused")}for(const r of this.gremlins.values())r.container.zIndex=r.y/(No/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)*Un(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-du(t))))}if(e.kind==="spawn_gremlin"){const t=this.gremlins.get(e.gremlinId);t&&(t.scale=Math.max(.01,du(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=>Z(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,m=(w,T,E)=>T+f>E-f?(T+E)/2:Math.max(T+f,Math.min(E-f,w)),g=(w,T,E)=>T+p>E-p?(T+E)/2:Math.max(T+p,Math.min(E-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,E=x.x-this.camTarget.x,P=x.y-this.camTarget.y;Math.abs(E)>w&&(this.camTarget.x+=E-Math.sign(E)*w),Math.abs(P)>T&&(this.camTarget.y+=P-Math.sign(P)*T)}const b=m(this.camTarget.x,a,l),v=g(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*is(1.08,1,Un(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=>[Z(l.gx,l.gy),Z(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},Fs={...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},xr={...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},Lb={...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},Ub={...Fs,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:{...Fs.beacon,roof:11967743,roofD:9401062},prop:"antenna",propColors:[13617646,16773544,3091781],vignette:329756},Nb={...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},Og={...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},zb={...xr,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:{...xr.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},Lg={...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},Hb={...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},Wb={...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},$b={...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},Vb={...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},jb={...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},Xb={...Fs,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:{...Fs.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},qb={...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},Yb={...Og,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},Kb={...Lg,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},Zb={...Fs,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},Qb={...xr,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},Pt=[ke,Fs,xr,Lb,Ub,Nb,Og,zb,Lg,Hb,Wb,$b,Vb,jb,Xb,qb,Yb,Kb,Zb,Qb],or=i=>Pt.find(e=>e.id===i)??ke;function $o(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=Pt.filter(l=>s(l)>1),n=r.length>=3?r:Pt;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)}const Jb={aVertex:(i,e,t,s,r)=>{let n=0,o=0,a=0,l=0;for(let h=0;h<i.length;++h){const c=i[h],u=c.texture,d=c.scaleX,f=c.scaleY,p=c.anchorX,m=c.anchorY,g=u.trim,_=u.orig;g?(o=g.x-p*_.width,n=o+g.width,l=g.y-m*_.height,a=l+g.height):(n=_.width*(1-p),o=_.width*-p,a=_.height*(1-m),l=_.height*-m),e[s]=o*d,e[s+1]=l*f,e[s+r]=n*d,e[s+r+1]=l*f,e[s+r*2]=n*d,e[s+r*2+1]=a*f,e[s+r*3]=o*d,e[s+r*3+1]=a*f,s+=r*4}},aPosition:(i,e,t,s,r)=>{for(let n=0;n<i.length;++n){const o=i[n],a=o.x,l=o.y;e[s]=a,e[s+1]=l,e[s+r]=a,e[s+r+1]=l,e[s+r*2]=a,e[s+r*2+1]=l,e[s+r*3]=a,e[s+r*3+1]=l,s+=r*4}},aRotation:(i,e,t,s,r)=>{for(let n=0;n<i.length;++n){const o=i[n].rotation;e[s]=o,e[s+r]=o,e[s+r*2]=o,e[s+r*3]=o,s+=r*4}},aUV:(i,e,t,s,r)=>{for(let n=0;n<i.length;++n){const o=i[n].texture.uvs;e[s]=o.x0,e[s+1]=o.y0,e[s+r]=o.x1,e[s+r+1]=o.y1,e[s+r*2]=o.x2,e[s+r*2+1]=o.y2,e[s+r*3]=o.x3,e[s+r*3+1]=o.y3,s+=r*4}},aColor:(i,e,t,s,r)=>{for(let n=0;n<i.length;++n){const o=i[n].color;t[s]=o,t[s+r]=o,t[s+r*2]=o,t[s+r*3]=o,s+=r*4}}};function e1(i){const e=Object.values(i),t=e.filter(r=>r.dynamic),s=e.filter(r=>!r.dynamic);return{dynamicUpdate:yu(t),staticUpdate:yu(s)}}function yu(i){let e=0;const t=[];for(let s=0;s<i.length;s++){const r=i[s],n=gt(r.format).stride/4;e+=n,t.push({stride:n,updateFunction:r.updateFunction||Jb[r.attributeName]})}return(s,r,n)=>{let o=0;for(let a=0;a<t.length;a++){const l=t[a];l.updateFunction(s,r,n,o,e),o+=l.stride}}}function t1(){return s1}function s1(i,e,t){const s=i.gl,r=i.shader,n=r._getProgramData(e.glProgram);for(const o in e.groups){const a=e.groups[o];for(const l in a.resources){const h=a.resources[l];if(h instanceof Qe)h.ubo?r.bindUniformBlock(h,e._uniformBindMap[o][l],t.blockIndex++):r.updateUniformGroup(h);else if(h instanceof ki)r.bindUniformBlock(h,e._uniformBindMap[o][l],t.blockIndex++);else if(h instanceof ue||h instanceof Nl){i.texture.bind(h,t.textureCount);const c=e._uniformBindMap[o][l],u=n.uniformData[c];u&&(u.value!==t.textureCount&&s.uniform1i(u.location,t.textureCount),t.textureCount++)}}}}const i1=[(i,e,t,s,r)=>{const n=s[i].toArray(!0);e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+4]=n[3],e[t+5]=n[4],e[t+6]=n[5],e[t+8]=n[6],e[t+9]=n[7],e[t+10]=n[8]},(i,e,t,s,r)=>{r=s[i],e[t]=r.x,e[t+1]=r.y,e[t+2]=r.width,e[t+3]=r.height},(i,e,t,s,r)=>{r=s[i],e[t]=r.x,e[t+1]=r.y},(i,e,t,s,r)=>{r=s[i],e[t]=r.red,e[t+1]=r.green,e[t+2]=r.blue,e[t+3]=r.alpha},(i,e,t,s,r)=>{r=s[i],e[t]=r.red,e[t+1]=r.green,e[t+2]=r.blue}],r1={f32:(i,e,t,s,r)=>{e[t]=r},i32:(i,e,t,s,r)=>{e[t]=r},"vec2<f32>":(i,e,t,s,r)=>{e[t]=r[0],e[t+1]=r[1]},"vec3<f32>":(i,e,t,s,r)=>{e[t]=r[0],e[t+1]=r[1],e[t+2]=r[2]},"vec4<f32>":(i,e,t,s,r)=>{e[t]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3]},"mat2x2<f32>":(i,e,t,s,r)=>{e[t]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3]},"mat3x3<f32>":(i,e,t,s,r)=>{e[t]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+4]=r[3],e[t+5]=r[4],e[t+6]=r[5],e[t+8]=r[6],e[t+9]=r[7],e[t+10]=r[8]},"mat4x4<f32>":(i,e,t,s,r)=>{for(let n=0;n<16;n++)e[t+n]=r[n]},"mat3x2<f32>":(i,e,t,s,r)=>{for(let n=0;n<6;n++)e[t+(n/3|0)*4+n%3]=r[n]},"mat4x2<f32>":(i,e,t,s,r)=>{for(let n=0;n<8;n++)e[t+(n/4|0)*4+n%4]=r[n]},"mat2x3<f32>":(i,e,t,s,r)=>{for(let n=0;n<6;n++)e[t+(n/2|0)*4+n%2]=r[n]},"mat4x3<f32>":(i,e,t,s,r)=>{for(let n=0;n<12;n++)e[t+(n/4|0)*4+n%4]=r[n]},"mat2x4<f32>":(i,e,t,s,r)=>{for(let n=0;n<8;n++)e[t+(n/2|0)*4+n%2]=r[n]},"mat3x4<f32>":(i,e,t,s,r)=>{for(let n=0;n<12;n++)e[t+(n/3|0)*4+n%3]=r[n]}},n1={f32:(i,e,t,s,r)=>{e[t]=r},i32:(i,e,t,s,r)=>{e[t]=r},"vec2<f32>":(i,e,t,s,r)=>{e[t]=r[0],e[t+1]=r[1]},"vec3<f32>":(i,e,t,s,r)=>{e[t]=r[0],e[t+1]=r[1],e[t+2]=r[2]},"vec4<f32>":(i,e,t,s,r)=>{e[t]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3]},"mat2x2<f32>":(i,e,t,s,r)=>{e[t]=r[0],e[t+1]=r[1],e[t+4]=r[2],e[t+5]=r[3]},"mat3x3<f32>":(i,e,t,s,r)=>{e[t]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+4]=r[3],e[t+5]=r[4],e[t+6]=r[5],e[t+8]=r[6],e[t+9]=r[7],e[t+10]=r[8]},"mat4x4<f32>":(i,e,t,s,r)=>{for(let n=0;n<16;n++)e[t+n]=r[n]},"mat3x2<f32>":(i,e,t,s,r)=>{for(let n=0;n<6;n++)e[t+(n/3|0)*4+n%3]=r[n]},"mat4x2<f32>":(i,e,t,s,r)=>{for(let n=0;n<8;n++)e[t+(n/4|0)*4+n%4]=r[n]},"mat2x3<f32>":(i,e,t,s,r)=>{for(let n=0;n<6;n++)e[t+(n/2|0)*4+n%2]=r[n]},"mat4x3<f32>":(i,e,t,s,r)=>{for(let n=0;n<12;n++)e[t+(n/4|0)*4+n%4]=r[n]},"mat2x4<f32>":(i,e,t,s,r)=>{for(let n=0;n<8;n++)e[t+(n/2|0)*4+n%2]=r[n]},"mat3x4<f32>":(i,e,t,s,r)=>{for(let n=0;n<12;n++)e[t+(n/3|0)*4+n%3]=r[n]}};function o1(i){return Ug(i,n1,e=>{const t=Math.max(Zr[e.data.type]/16,1),s=e.data.value.length/e.data.size,r=(4-s%4)%4;return(n,o,a,l,h)=>{let c=0;for(let u=0;u<e.data.size*t;u++){for(let d=0;d<s;d++)o[a++]=h[c++];a+=r}}})}function a1(i){return Ug(i,r1,e=>{const{size:t,align:s}=Ps[e.data.type],r=(Math.max(t,s)-t)/4;return(n,o,a,l,h)=>{let c=0;for(let u=0;u<e.data.size;u++){for(let d=0;d<t/4;d++)o[a++]=h[c++];a+=r}}})}function Ug(i,e,t){const s={};for(const r in i){const n=i[r],o=n.data;let a=!1;s[o.name]={offset:n.offset/4,func:null};for(let l=0;l<ot.length;l++){const h=ot[l];if(o.type===h.type&&h.test(o)){s[o.name].func=i1[l],a=!0;break}}a||(o.size===1?s[o.name].func=e[o.type]:s[o.name].func=t(n))}return(r,n,o,a)=>{for(const l in s)s[l].func(l,n,a+s[l].offset,r,r[l])}}const l1={f32(i,e,t,s,r,n,o){t!==s&&(e.value=s,o.uniform1f(r[i].location,s))},"vec2<f32>"(i,e,t,s,r,n,o){(t[0]!==s[0]||t[1]!==s[1])&&(t[0]=s[0],t[1]=s[1],o.uniform2f(r[i].location,s[0],s[1]))},"vec3<f32>"(i,e,t,s,r,n,o){(t[0]!==s[0]||t[1]!==s[1]||t[2]!==s[2])&&(t[0]=s[0],t[1]=s[1],t[2]=s[2],o.uniform3f(r[i].location,s[0],s[1],s[2]))},"vec4<f32>"(i,e,t,s,r,n,o){(t[0]!==s[0]||t[1]!==s[1]||t[2]!==s[2]||t[3]!==s[3])&&(t[0]=s[0],t[1]=s[1],t[2]=s[2],t[3]=s[3],o.uniform4f(r[i].location,s[0],s[1],s[2],s[3]))},i32(i,e,t,s,r,n,o){t!==s&&(e.value=s,o.uniform1i(r[i].location,s))},"vec2<i32>"(i,e,t,s,r,n,o){(t[0]!==s[0]||t[1]!==s[1])&&(t[0]=s[0],t[1]=s[1],o.uniform2i(r[i].location,s[0],s[1]))},"vec3<i32>"(i,e,t,s,r,n,o){(t[0]!==s[0]||t[1]!==s[1]||t[2]!==s[2])&&(t[0]=s[0],t[1]=s[1],t[2]=s[2],o.uniform3i(r[i].location,s[0],s[1],s[2]))},"vec4<i32>"(i,e,t,s,r,n,o){(t[0]!==s[0]||t[1]!==s[1]||t[2]!==s[2]||t[3]!==s[3])&&(t[0]=s[0],t[1]=s[1],t[2]=s[2],t[3]=s[3],o.uniform4i(r[i].location,s[0],s[1],s[2],s[3]))},u32(i,e,t,s,r,n,o){t!==s&&(e.value=s,o.uniform1ui(r[i].location,s))},"vec2<u32>"(i,e,t,s,r,n,o){(t[0]!==s[0]||t[1]!==s[1])&&(t[0]=s[0],t[1]=s[1],o.uniform2ui(r[i].location,s[0],s[1]))},"vec3<u32>"(i,e,t,s,r,n,o){(t[0]!==s[0]||t[1]!==s[1]||t[2]!==s[2])&&(t[0]=s[0],t[1]=s[1],t[2]=s[2],o.uniform3ui(r[i].location,s[0],s[1],s[2]))},"vec4<u32>"(i,e,t,s,r,n,o){(t[0]!==s[0]||t[1]!==s[1]||t[2]!==s[2]||t[3]!==s[3])&&(t[0]=s[0],t[1]=s[1],t[2]=s[2],t[3]=s[3],o.uniform4ui(r[i].location,s[0],s[1],s[2],s[3]))},bool(i,e,t,s,r,n,o){t!==s&&(e.value=s,o.uniform1i(r[i].location,s))},"vec2<bool>"(i,e,t,s,r,n,o){(t[0]!==s[0]||t[1]!==s[1])&&(t[0]=s[0],t[1]=s[1],o.uniform2i(r[i].location,s[0],s[1]))},"vec3<bool>"(i,e,t,s,r,n,o){(t[0]!==s[0]||t[1]!==s[1]||t[2]!==s[2])&&(t[0]=s[0],t[1]=s[1],t[2]=s[2],o.uniform3i(r[i].location,s[0],s[1],s[2]))},"vec4<bool>"(i,e,t,s,r,n,o){(t[0]!==s[0]||t[1]!==s[1]||t[2]!==s[2]||t[3]!==s[3])&&(t[0]=s[0],t[1]=s[1],t[2]=s[2],t[3]=s[3],o.uniform4i(r[i].location,s[0],s[1],s[2],s[3]))},"mat2x2<f32>"(i,e,t,s,r,n,o){o.uniformMatrix2fv(r[i].location,!1,s)},"mat3x3<f32>"(i,e,t,s,r,n,o){o.uniformMatrix3fv(r[i].location,!1,s)},"mat4x4<f32>"(i,e,t,s,r,n,o){o.uniformMatrix4fv(r[i].location,!1,s)}},h1={f32(i,e,t,s,r,n,o){o.uniform1fv(r[i].location,s)},"vec2<f32>"(i,e,t,s,r,n,o){o.uniform2fv(r[i].location,s)},"vec3<f32>"(i,e,t,s,r,n,o){o.uniform3fv(r[i].location,s)},"vec4<f32>"(i,e,t,s,r,n,o){o.uniform4fv(r[i].location,s)},"mat2x2<f32>"(i,e,t,s,r,n,o){o.uniformMatrix2fv(r[i].location,!1,s)},"mat3x3<f32>"(i,e,t,s,r,n,o){o.uniformMatrix3fv(r[i].location,!1,s)},"mat4x4<f32>"(i,e,t,s,r,n,o){o.uniformMatrix4fv(r[i].location,!1,s)},i32(i,e,t,s,r,n,o){o.uniform1iv(r[i].location,s)},"vec2<i32>"(i,e,t,s,r,n,o){o.uniform2iv(r[i].location,s)},"vec3<i32>"(i,e,t,s,r,n,o){o.uniform3iv(r[i].location,s)},"vec4<i32>"(i,e,t,s,r,n,o){o.uniform4iv(r[i].location,s)},u32(i,e,t,s,r,n,o){o.uniform1iv(r[i].location,s)},"vec2<u32>"(i,e,t,s,r,n,o){o.uniform2iv(r[i].location,s)},"vec3<u32>"(i,e,t,s,r,n,o){o.uniform3iv(r[i].location,s)},"vec4<u32>"(i,e,t,s,r,n,o){o.uniform4iv(r[i].location,s)},bool(i,e,t,s,r,n,o){o.uniform1iv(r[i].location,s)},"vec2<bool>"(i,e,t,s,r,n,o){o.uniform2iv(r[i].location,s)},"vec3<bool>"(i,e,t,s,r,n,o){o.uniform3iv(r[i].location,s)},"vec4<bool>"(i,e,t,s,r,n,o){o.uniform4iv(r[i].location,s)}},c1=[(i,e,t,s,r,n,o)=>{o.uniformMatrix3fv(r[i].location,!1,n[i].toArray(!0))},(i,e,t,s,r,n,o)=>{t=r[i].value,s=n[i],(t[0]!==s.x||t[1]!==s.y||t[2]!==s.width||t[3]!==s.height)&&(t[0]=s.x,t[1]=s.y,t[2]=s.width,t[3]=s.height,o.uniform4f(r[i].location,s.x,s.y,s.width,s.height))},(i,e,t,s,r,n,o)=>{t=r[i].value,s=n[i],(t[0]!==s.x||t[1]!==s.y)&&(t[0]=s.x,t[1]=s.y,o.uniform2f(r[i].location,s.x,s.y))},(i,e,t,s,r,n,o)=>{t=r[i].value,s=n[i],(t[0]!==s.red||t[1]!==s.green||t[2]!==s.blue||t[3]!==s.alpha)&&(t[0]=s.red,t[1]=s.green,t[2]=s.blue,t[3]=s.alpha,o.uniform4f(r[i].location,s.red,s.green,s.blue,s.alpha))},(i,e,t,s,r,n,o)=>{t=r[i].value,s=n[i],(t[0]!==s.red||t[1]!==s.green||t[2]!==s.blue)&&(t[0]=s.red,t[1]=s.green,t[2]=s.blue,o.uniform3f(r[i].location,s.red,s.green,s.blue))}];function u1(i,e){const t={};for(const s in i.uniformStructures){if(!e[s])continue;const r=i.uniformStructures[s];let n=!1;for(let o=0;o<ot.length;o++){const a=ot[o];if(r.type===a.type&&a.test(r)){t[s]=c1[o],n=!0;break}}if(!n){const o=r.size===1?l1:h1;t[s]=o[r.type]}}return(s,r,n)=>{const o=n.gl;for(const a in t){const l=r[a],h=s[a],c=s[a].value;t[a](a,h,c,l,s,r,o)}}}function d1(){Object.assign(fs.prototype,{_unsafeEvalCheck(){}}),Object.assign(Kr.prototype,{_systemCheck(){}}),Object.assign(en.prototype,{_generateUniformsSync:u1}),Object.assign(Qr.prototype,{_generateUboSync:o1}),Object.assign(sn.prototype,{_generateUboSync:a1}),Object.assign(Jr.prototype,{_generateShaderSync:t1}),Object.assign(vg.prototype,{generateParticleUpdate:e1})}d1();class fh{constructor(e){this.payload=e}mode="replay";onReady(e){queueMicrotask(()=>e(this.payload))}onBeats(){}}class f1{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 p1{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 m1(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 fh({world:s.world,events:s.events,beats:s.beats,repoId:s.title?`${s.repoId} — ${s.title}`:s.repoId})}function g1(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 _1(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 Wn=i=>{const e=Math.floor(i/1e3);return`${Math.floor(e/60)}:${String(e%60).padStart(2,"0")}`},$n=i=>`#${i.toString(16).padStart(6,"0")}`,W=(i,e,t)=>{const s=document.createElement(i);return e&&(s.className=e),t!==void 0&&(s.innerHTML=t),s},y1='<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>',xu='<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>',x1='<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 b1{constructor(e,t){this.h=t,this.root=W("div","wrap");const s=W("header"),r=W("div","brand",'<div class="eyebrow"><a href="https://agenttheatre.dev/" title="Back to agenttheatre.dev">← Agent Theatre</a><span class="for"> · the stage for</span></div><h1 id="title">Loading…</h1>'),n=W("div","toolbar");this.setBtn=W("button","btn ghost","Set"),this.setBtn.type="button",this.setBtn.onclick=()=>this.showPicker(!0),this.muteBtn=W("button","btn ghost","Effects on"),this.muteBtn.type="button",this.muteBtn.title="Sound effects",this.muteBtn.onclick=()=>t.onMute(),this.ambBtn=W("button","btn ghost","Ambience on"),this.ambBtn.type="button",this.ambBtn.title="Background sound",this.ambBtn.onclick=()=>t.onAmbience(),this.overviewBtn=W("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=W("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=W("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=W("div","grid"),a=W("div","stage-col");this.stageEl=W("div","stage"),this.overlay=W("div","overlay"),this.bubbleEl=W("div","bubble"),this.bubbleEl.hidden=!0,this.overlay.append(this.bubbleEl),this.signal=W("div","signal","<i></i><span>live</span>"),this.signal.hidden=!0,this.chip=W("div","chip ok"),this.chip.hidden=!0,this.caption=W("div","caption","<span></span>"),this.title=W("div","card",'<div class="small">Agent Theatre</div><div class="big" id="titleBig">…</div>'),this.end=W("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=W("div","picker"),this.picker.hidden=!0,this.waiting=W("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=W("form","prompt",'<div class="note" hidden></div><div class="row"><input type="text" placeholder="" autocomplete="off" spellcheck="false"><button type="submit">Send</button><span class="st"></span></div>'),this.prompt.hidden=!0,this.prompt.addEventListener("submit",f=>{f.preventDefault();const p=this.prompt.querySelector("input"),m=this.prompt.querySelector(".st"),g=p.value.trim();g&&(m.textContent="sending…",t.onPrompt(g).then(_=>{m.textContent=_,p.value=""}))}),this.tip=W("div","tip"),this.tip.hidden=!0,this.stageEl.append(W("div","vignette"),this.overlay,this.signal,this.chip,this.caption,this.title,this.end,this.picker,this.waiting,this.prompt,this.tip),this.stageEl.addEventListener("pointermove",f=>{const p=this.stageEl.getBoundingClientRect(),m=this.hitTester?.(f.clientX-p.left,f.clientY-p.top)??null;if(!m){this.tip.hidden=!0;return}this.tip.innerHTML=this.describeHit(m),this.tip.hidden=!1;const g=Math.min(f.clientX-p.left+14,p.width-this.tip.offsetWidth-10),_=f.clientY-p.top+16;this.tip.style.left=`${Math.max(8,g)}px`,this.tip.style.top=`${Math.min(_,p.height-this.tip.offsetHeight-10)}px`}),this.stageEl.addEventListener("pointerleave",()=>{this.tip.hidden=!0}),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=W("div","controls");this.playBtn=W("button","btn",`${xu}<span>Pause</span>`),this.playBtn.type="button",this.playBtn.onclick=()=>t.onPlayPause();const h=W("div","track");this.actsEl=W("div","acts"),this.labelsEl=W("div","actlabels"),this.head=W("div","head"),h.append(this.actsEl,this.labelsEl,this.head),h.addEventListener("pointerdown",f=>{const p=this.actsEl.getBoundingClientRect(),m=(f.clientX-p.left)/p.width;t.onSeek(m*this.durationMs)}),this.time=W("div","time","0:00 / 0:00"),this.liveBtn=W("button","btn golive",'<i class="dot"></i><span>Go live</span>'),this.liveBtn.type="button",this.liveBtn.title="Jump back to what is happening now",this.liveBtn.hidden=!0,this.liveBtn.onclick=()=>t.onGoLive(),this.rateBtn=W("button","btn ghost","1×"),this.rateBtn.type="button",this.rateBtn.onclick=()=>t.onRate(),l.append(this.playBtn,h,this.time,this.liveBtn,this.rateBtn),a.append(this.stageEl,l);const c=W("aside"),u=W("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=W("ul","log"),u.append(this.logEl);const d=W("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,W("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=W("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>
|
|
969
|
+
`):""}function Wx(i){let e=0;for(const t of i.matchAll(/<<-?\s*(['"]?)(\w+)\1[^\n]*\n([\s\S]*?)\n\2(?=\n|$)/g))e+=rr(t[3]);return e===0&&/(?:^|[\s)])\d?>{1,2}\s*[^\s|&;<>]+/.test(i)&&!/>\s*\/dev\/null/.test(i)&&(e=1),e}var $x=new Set(["Grep","Glob","LS","ToolSearch"]),Vx=new Set(["WebSearch","WebFetch"]),jx=new Set(["TodoWrite","TodoRead","Skill","EnterPlanMode","ExitPlanMode","EnterWorktree","ExitWorktree","NotebookRead","ListAgents","SendMessage","TaskStop","Monitor","ScheduleWakeup","ReportFindings"]);function tu(i,e){const t=We(i.input),s=i.response,r=!i.isError&&We(s).interrupted!==!0,n=a=>Ax(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(We(We(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=zx(s)??{added:rr(we(t.new_string)??we(t.new_source)),removed:rr(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=We(s),h=l.type==="create"||l.type===void 0&&l.originalFile===null;return{bodies:[{kind:"write_file",path:n(a),added:rr(we(t.content)),created:h}]}}case"Bash":{const a=we(t.command)??"",l=Ux(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=Wx(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=Nx(Hx(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=We(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($x.has(i.name)){const a=We(s).numFiles??We(s).numLines??We(s).count;return{bodies:[{kind:"search",scope:"repo",...typeof a=="number"?{hits:a}:{}}]}}return Vx.has(i.name)?{bodies:[{kind:"search",scope:"web"}]}:jx.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 Xx=[/\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,/✅/],qx=[/\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],su=600;function iu(i){if(!i)return!1;const e=i.length>su?i.slice(-su):i;return qx.some(t=>t.test(e))?!1:Xx.some(t=>t.test(e))}function Yx(i){if(!i)return{};const e=i.trim().split(/\n{2,}/).filter(t=>t.trim()).pop()?.replace(/\s+/g," ").trim()??"";return e?{note:e.length>240?"…"+e.slice(-239):e}:{}}var Kx=new Set(["user","assistant","system"]),qi=i=>i&&typeof i=="object"?i:{},be=i=>typeof i=="string"?i:void 0;function Zx(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=Qx(t,e);return{events:n.events,warnings:[...s,...n.warnings]}}function Qx(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 m=()=>({cwd:l,...e.home?{home:e.home}:{}}),g=(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=qi(x),v=be(b.type)??"";if(!Kx.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,g(w,`${a||"session"}:start`,{kind:"session_start",repoId:Rx(l)||"repo",...h?{branch:h}:{}})),u=w;const T=y(b),E=qi(b.message),P=E.content;if(v==="system"){if(b.subtype==="api_error"){const k=typeof b.retryAttempt=="number"?b.retryAttempt:0,I=typeof b.maxRetries=="number"?b.maxRetries:0;g(w,be(b.uuid)??`sys:${f}`,{kind:"error",where:"api",retrying:k<I},T?{agentId:T}:{})}continue}if(v==="assistant"){const k=Array.isArray(P)?P:[];for(const I of k){const G=qi(I);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 F=be(G.text);F&&(d=F)}}typeof P=="string"&&!T&&(d=P),E.stop_reason==="end_turn"&&!T&&g(w,`${be(b.uuid)??f}:turn`,{kind:"turn_end",claimedSuccess:iu(d),...Yx(d)});continue}b.toolDenialKind!==void 0&&g(w,`${be(b.uuid)??f}:deny`,{kind:"waiting_for_user",reason:"permission"});const A=Array.isArray(P)?P:[];for(const k of A){const I=qi(k);if(I.type!=="tool_result")continue;const G=be(I.tool_use_id);if(!G)continue;const F=n.get(G);if(!F){s.push({code:"unpaired_result",detail:G});continue}n.delete(G);const X=b.toolUseResult??I.content,M=tu({name:F.name,input:F.input,response:X,isError:I.is_error===!0,durationMs:Math.max(0,w-F.ts)},m());M.warning&&s.push(M.warning);const C=F.agentId??T,B=C?o.get(C):void 0,R={...C?{agentId:C}:{},...B?{parentId:B}:{}};M.bodies.forEach((O,U)=>g(F.ts,U===0?G:`${G}:${U}`,O,R)),M.pendingSubagent&&o.set(M.pendingSubagent.childId,G)}A.length===0&&typeof P=="string"&&/\[Request interrupted by user/i.test(P)&&g(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=tu({name:b.name,input:b.input,isError:!0},m());v.warning&&s.push(v.warning),v.bodies.forEach((w,T)=>g(b.ts,T===0?x:`${x}:${T}`,w,b.agentId?{agentId:b.agentId}:{}))}for(const[x,b]of o)g(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,g(u,`${a||"session"}:end`,{kind:"session_end",reason:"stop",claimedSuccess:iu(d)})),{events:t,warnings:s}}function Lo(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 ci(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 Jx=/(^|\/)(schema\.(sql|prisma|graphql|gql)|.*\.(sql|prisma|db|sqlite)|migrations?\/|drizzle\/|models?\/.*\.(ts|js|py|rb)$)/i,eb=/(^|\/)(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 tb(i){return eb.test(i)}function Sg(i){return wg(i)?"beacon":Jx.test(i)?"archive":"building"}function ru(i){return typeof i.loc=="number"?i.loc:typeof i.size=="number"?Math.max(1,Math.round(i.size/40)):1}function sb(i,e){const t=i.filter(n=>!tb(n.path)),s=Math.max(1,...t.map(ru)),r=Math.max(1,...t.map(n=>n.churn??0));return t.map(n=>{const o=ru(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:Sg(n.path),touched:a}})}function nu(i,e){const t=Math.sqrt(i/Math.max(1,e));return Math.max(1,Math.min(5,Math.ceil(t*5)))}function ou(i){return i>=5?3:i>=3?2:1}var ib={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 rb(i,e={}){const t=i.map(p=>p.path.toLowerCase()),s=p=>t.some(m=>p.test(m)),r=p=>t.filter(m=>p.test(m)).length,n=new Map;for(const p of t){const m=p.slice(p.lastIndexOf(".")+1),g=ib[m];g&&!/^(markdown|yaml|html|css|shell|sql)$/i.test(g)&&n.set(g,(n.get(g)??0)+1)}const o=[...n.entries()].sort((p,m)=>m[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,m)=>c.set(p,(c.get(p)??0)+m);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,m)=>m[1]-p[1]).map(([p])=>p);return{kinds:f.length?f:["unknown"],languages:o,files:i.length}}function nb(i){const e=i.cap??60,t=i.beaconCap??8,s=i.touchedCap??48,r=new Set((i.touched??[]).map(au).slice(0,s)),n=Lo(i.repoId),o=ci(n),a=i.files.map(C=>({...C,path:au(C.path)})),l=sb(a,r),h=Math.max(1,...l.map(C=>C.loc)),c=[...l].sort((C,B)=>B.score-C.score||C.file.path.localeCompare(B.file.path)),u=cu(c.filter(C=>C.kind==="beacon"),t),d=cu(c.filter(C=>C.kind!=="beacon"),e),f=[...d,...u],p=f.length<l.length,m=new Map;for(const C of d){const B=Ln(C.file.path);(m.get(B)??m.set(B,[]).get(B)).push(C)}const g=[...m.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??Ti[n%Ti.length],w=o()*Math.PI*2,T=g.map(C=>{const B=m.get(C).sort((U,q)=>q.score-U.score||U.file.path.localeCompare(q.file.path)),R=B.reduce((U,q)=>U+ou(nu(q.loc,h))**2,0),O=Math.max(3,Math.ceil(Math.sqrt(R*1.45)));return{name:C,items:B,side:O}}),E=[],P={x:-2,y:-2,w:4,h:4},A=Pg(v,T.map(C=>C.side),P,w,o);E.push(P,...A);const k=Ag(v,A);b.gx=k[0],b.gy=k[1],_.clear(),kt(_,b),T.forEach((C,B)=>{const R=A[B],O={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 U of C.items){const q=nu(U.loc,h),J=ou(q),ie=Uo(_,O.cx,O.cy,J,R),V={id:`p:${U.file.path}`,kind:U.kind,path:U.file.path,label:lu(U.file.path),district:O.id,gx:ie[0],gy:ie[1],footprint:J,height:q,score:hu(U.score),touched:U.touched};kt(_,V),y.push(V),O.placeIds.push(V.id)}x.push(O)}),Math.ceil(kg(E));for(const C of E)for(let B=C.x-1;B<C.x+C.w+1;B++)for(let R=C.y-1;R<C.y+C.h+1;R++)_.add(`${B},${R}`);for(const C of u){const B=x.find(U=>U.id===`d:${Ln(C.file.path)}`),R=B?Bg(_,B,b,1):Si(_,b.gx+1,b.gy+1,o()*Math.PI*2,4,1),O={id:`p:${C.file.path}`,kind:"beacon",path:C.file.path,label:lu(C.file.path),district:B?.id??"",gx:R[0],gy:R[1],footprint:1,height:4,score:hu(C.score),touched:C.touched};kt(_,O),y.push(O),B?.placeIds.push(O.id)}const I=Si(_,b.gx+1,b.gy+1,w+Math.PI,5,2),G={id:"dock",kind:"dock",path:"",label:"dock",district:"",gx:I[0],gy:I[1],footprint:2,height:1,score:0,touched:!1};kt(_,G),y.push(G);const F=Rg(v,x,b,G);if(p)for(const C of x){const B=C.id.slice(2),R=l.filter(q=>q.kind!=="beacon"&&Ln(q.file.path)===B).length;if(R<=C.placeIds.length)continue;const O=Uo(_,C.cx,C.cy,1,C.bounds),U={id:`p:${B?B+"/":""}…`,kind:"overflow",path:`${B?B+"/":""}…`,label:`+${R-C.placeIds.length} more`,district:C.id,gx:O[0],gy:O[1],footprint:1,height:2,score:0,touched:!1};kt(_,U),y.push(U),C.placeIds.push(U.id)}const X=Eg(y,2),M=rb(a,i.manifests??{});return{repoId:i.repoId,seed:n,layout:v,profile:M,districts:x,places:y,paths:F,bounds:X,stats:{files:l.length,placed:f.length,capped:p}}}var au=i=>i.replace(/\\/g,"/").replace(/^\.\//,"").replace(/^\/+/,""),lu=i=>i.slice(i.lastIndexOf("/")+1),Ln=i=>i.includes("/")?i.slice(0,i.indexOf("/")):"",hu=i=>Math.round(i*1e3)/1e3;function cu(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 uu(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 Mg(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 Cg(i,e,t,s){return Mg(e,t,s).every(r=>!i.has(r))}function kt(i,e){for(const t of Mg(e.gx,e.gy,e.footprint))i.add(t)}function Uo(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(Cg(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 kg(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 Eg(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 Ti=["ring","grid","strip","scatter","terrace","spine"];function Pg(i,e,t,s,r){const n=e.length,o=[],a=Math.max(3,...e),l=c=>!uu(t,c,1)&&!o.some(u=>uu(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 g=e.slice(f,f+c),_=Math.max(...g)+2;let y=0;for(const x of g)u.push({x:y,y:d}),y+=x+2;d+=_,f+=c}const p=Math.max(...u.map((g,_)=>g.x+e[_])),m=d;for(let g=0;g<n;g++){let _={x:u[g].x-Math.round(p/2),y:u[g].y-Math.round(m/2),w:e[g],h:e[g]};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,m=u*(.5+r()*.7),g={x:Math.round(Math.cos(p)*m),y:Math.round(Math.sin(p)*m*.8),w:e[c],h:e[c]};l(g)&&(o.push(g),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,m;for(;;){const g=Math.round(Math.cos(f)*p),_=Math.round(Math.sin(f)*p*.8);if(m={x:g-Math.floor(d/2),y:_-Math.floor(d/2),w:d,h:d},l(m))break;p+=1}o.push(m),c=Math.max(c,p-d/2)}return o}}}function Ag(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 Rg(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 ob(i,e){if(i.layout===e)return i;const t=i.seed,s=ci(t^1374496523^Ti.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=Pg(e,h.map(y=>y.side),c,a,s),d=[c,...u],f=Ag(e,u);o.gx=f[0],o.gy=f[1],kt(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=Uo(r,v.cx,v.cy,w.footprint,b),E={...w,gx:T[0],gy:T[1]};kt(r,E),n.push(E),v.placeIds.push(E.id)}return v});Math.ceil(kg(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?Bg(r,x,o,1):Si(r,o.gx+1,o.gy+1,s()*Math.PI*2,4,1),v={...y,gx:b[0],gy:b[1]};kt(r,v),n.push(v),x?.placeIds.push(v.id)}const m=Si(r,o.gx+1,o.gy+1,a+Math.PI,5,2),g={...i.places.find(y=>y.kind==="dock"),gx:m[0],gy:m[1]};kt(r,g),n.push(g);const _=Rg(e,p,o,g);return{...i,layout:e,districts:p,places:n,paths:_,bounds:Eg(n,2)}}function Si(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(Cg(i,h,c,n))return[h,c]}return[e+r,t]}function Bg(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 Si(i,e.cx,e.cy,r,n,s)}var ab=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"}},lb=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 ab(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},ws(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=ws(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},ws(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},ws(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},ws(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",...i.note?{note:i.note}:{}},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},ws(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:Sg(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=>wg(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 nr(i,e,t){const s=new lb(e,t);for(const r of i)s.feed(r);return[...s.timeline]}var ws=(i,e,t)=>Math.min(t,Math.max(e,i));function hb(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 cb{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 m=s.createStereoPanner();m.pan.value=t,f.connect(p),p.connect(m),m.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 m=s.createGain();m.gain.setValueAtTime(1e-4,r),m.gain.exponentialRampToValueAtTime(c,r+.05),m.gain.exponentialRampToValueAtTime(1e-4,r+h);const g=s.createStereoPanner();g.pan.value=t,f.connect(p),p.connect(m),m.connect(g),g.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 ub=i=>1-Math.pow(1-i,3),Un=i=>db(.4,0,.2,1,i),du=i=>1+(1.70158+1)*Math.pow(i-1,3)+1.70158*Math.pow(i-1,2),rt=i=>Math.sin(Math.PI*Math.min(1,Math.max(0,i)));function db(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=m=>((a*m+o)*m+n)*m,d=m=>((c*m+h)*m+l)*m,f=m=>(3*a*m+2*o)*m+n;let p=r;for(let m=0;m<6;m++){const g=f(p);if(Math.abs(g)<1e-6)break;p-=(u(p)-r)/g}return d(Math.min(1,Math.max(0,p)))}const fb=64,No=32,Z=(i,e)=>({x:(i-e)*fb/2,y:(i+e)*No/2}),D=(i,e)=>({x:i.x,y:i.y-e}),is=(i,e,t)=>i+(e-i)*t,Be=(i,e,t)=>({x:is(i.x,e.x,t),y:is(i.y,e.y,t)}),pb=(i,e,t)=>i<e?e:i>t?t:i,Ue=(i,e,t)=>pb((i-e)/(t-e),0,1),fu=(i,e,t=1)=>i+e+t;function De(i,e,t,s=0){return[Z(i,e),Z(i+t,e),Z(i+t,e+t),Z(i,e+t)].map(r=>D(r,s))}const j=i=>i.flatMap(e=>[e.x,e.y]);class mb{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=is(this.tx,e,s),this.ty=is(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+ub(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 gb={roof:"pitched",eave:.14,furniture:"chimney",stripes:!1},_b={roof:"flat",eave:.05,furniture:"vent",stripes:!1},yb={roof:"capsule",eave:0,furniture:"dish",stripes:!1},Nn={island:gb,orbit:yb,metropolis:_b,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 Ig{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=Yi(s),o=Yi(r),a=`v${e}|${t}|${n}|${o}`;let l=this.gradients.get(a);return l||(l=bb(e,t,n,o),this.gradients.set(a,l)),l}hGrad(e,t,s,r){const n=Yi(s),o=Yi(r),a=`h${e}|${t}|${n}|${o}`;let l=this.gradients.get(a);return l||(l=vb(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=Z(r,n);return{ground:o,top:D(o,this.heightPx(t)+10),place:s}}standingSpot(e){const t=this.drawn.get(e);if(!t)return Z(0,0);const s=t.place;return Z(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=fu(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"?Lo(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?ee(u,16777215,o):ee(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(j(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?ee(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&&Nn[this.theme.id].roof!=="capsule"&&Nn[this.theme.id].roof!=="dome"){const u=l.map(p=>D(p,n));t.poly(j([u[3],u[2],D(u[2],4),D(u[3],4)])).fill(r.roofD),t.poly(j([u[2],u[1],D(u[1],4),D(u[2],4)])).fill(ee(r.roofD,0,.2)),t.poly(j(u.map(p=>D(p,4)))).fill(r.roof);const d=De(s.gx+.8,s.gy+.8,o-1.6,n+4);t.poly(j([d[3],d[2],D(d[2],10),D(d[3],10)])).fill(r.left),t.poly(j([d[2],d[1],D(d[1],10),D(d[2],10)])).fill(r.right),t.poly(j(d.map(p=>D(p,10)))).fill(r.top);const f=D(Z(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=>D(u,n)),D(Z(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(m=>D(m,n)),D(Z(s.gx+o/2,s.gy+o/2),n+16),r.roof,r.roofD);const f=D(Z(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 m=0;m<3;m++){const g=(this.time*.35+m/3)%1;t.circle(f.x+Math.sin(g*6+m)*4,f.y-18-g*26,3+g*6).fill({color:16777215,alpha:.22*(1-g)})}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=Nn[this.theme.id],o=t.footprint,a=n.eave,l=Lo(t.path),h=De(t.gx-a,t.gy-a,o+a*2,s),c=Z(t.gx+o/2,t.gy+o/2),u=ee(r.roofD,this.shadowInk,.35);switch(a>0&&(e.poly(j([h[3],h[2],D(h[2],-3),D(h[3],-3)])).fill({color:u,alpha:.9}),e.poly(j([h[2],h[1],D(h[1],-3),D(h[2],-3)])).fill({color:ee(u,0,.2),alpha:.9})),n.roof){case"pitched":{this.pyramid(e,h,D(c,s+12+o*9),r.roof,r.roofD);break}case"gable":{const f=11+o*7,p=D(Be(h[0],h[3],.5),s+f),m=D(Be(h[1],h[2],.5),s+f);e.poly(j([h[3],h[2],m,p])).fill(this.vGrad(ee(r.roof,16777215,.1),r.roof,p.y,h[3].y)),e.poly(j([h[0],h[1],m,p])).fill(ee(r.roofD,this.shadowInk,.2)),e.poly(j([h[2],h[1],m])).fill(ee(r.right,this.shadowInk,.1)),e.poly(j([h[3],h[0],p])).fill(r.left),e.moveTo(p.x,p.y).lineTo(m.x,m.y).stroke({width:1.4,color:16777215,alpha:.4,cap:"round"});break}case"flat":{const f=h.map(m=>D(m,3));e.poly(j([h[3],h[2],f[2],f[3]])).fill(r.roofD),e.poly(j([h[2],h[1],f[1],f[2]])).fill(ee(r.roofD,0,.2)),e.poly(j(f)).fill(this.hGrad(ee(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(j([p[3],p[2],D(p[2],6),D(p[3],6)])).fill(r.left),e.poly(j([p[2],p[1],D(p[1],6),D(p[2],6)])).fill(r.right),e.poly(j(p.map(m=>D(m,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(ee(r.roof,16777215,.22),ee(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(ee(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,m=a*(1-f*.45),g=De(t.gx-m,t.gy-m,o+m*2,p);e.poly(j([g[3],g[2],D(g[2],-2),D(g[3],-2)])).fill(u);const _=D(c,p+9+o*3);e.poly(j([D(g[3],3),D(g[2],3),_])).fill(r.roof),e.poly(j([D(g[2],3),D(g[1],3),_])).fill(r.roofD),e.poly(j([D(g[3],3),D(g[0],3),_])).fill(ee(r.roof,16777215,.1));for(const y of[g[1],g[2],g[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=D(c,s+16+o*8);this.pyramid(e,h,f,r.roof,r.roofD);for(let p=0;p<o*3;p++){const m=Be(h[3],h[2],p/(o*3)),g=Be(h[3],h[2],(p+1)/(o*3));e.moveTo(m.x,m.y).quadraticCurveTo((m.x+g.x)/2,(m.y+g.y)/2+4,g.x,g.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(ee(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:ee(r.roofD,16777215,.1),alpha:.6});break}}const d=D(Z(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(ee(r.roofD,0,.2)));break;case"vent":e.rect(d.x-4,d.y-5,8,5).fill(ee(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=D(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(xb(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 m=Be(f[3],f[2],p/(o*4)),g=Be(f[3],f[2],(p+1)/(o*4));e.poly([m.x,m.y,g.x,g.y,g.x,g.y-s*.35,m.x,m.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=m=>ee(m,this.theme.sky[0],f);return e.poly(j([d,u,D(u,n),D(d,n)])).fill(this.vGrad(p(ee(a,16777215,.08)),p(ee(a,this.shadowInk,.28)),d.y-n,d.y)),e.poly(j([u,c,D(c,n),D(u,n)])).fill(this.vGrad(p(ee(l,this.coolInk,.06)),p(ee(l,this.shadowInk,.38)),u.y-n,u.y)),e.poly(j([D(h,n),D(c,n),D(u,n),D(d,n)])).fill(this.hGrad(p(ee(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 ee(this.theme.vignette,0,.3)}get coolInk(){return ee(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=[Z(t.gx+a,t.gy+l),Z(t.gx+r+a,t.gy+l),Z(t.gx+r+a,t.gy+r+l),Z(t.gx+a,t.gy+r+l)],c=[o[1],h[1],h[2],h[3],o[3],o[2]];e.poly(j(c)).fill({color:this.shadowInk,alpha:.16});const u=[Z(t.gx+a*.6,t.gy+l*.6),Z(t.gx+r+a*.6,t.gy+l*.6),Z(t.gx+r+a*.6,t.gy+r+l*.6)];e.poly(j([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=Z(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(j([t[0],t[1],s])).fill(ee(n,this.shadowInk,.25)),e.poly(j([t[3],t[0],s])).fill(ee(r,16777215,.12)),e.poly(j([t[3],t[2],s])).fill(this.vGrad(ee(r,16777215,.06),r,s.y,t[2].y)),e.poly(j([t[2],t[1],s])).fill(this.vGrad(n,ee(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),m=f.x;e.poly([m-h,p-c,m+h,p+c,m+h,p+c-6,m-h,p-c-6]).fill({color:a,alpha:l}),e.poly([m-h,p-c-4.5,m+h,p+c-4.5,m+h,p+c-6,m-h,p-c-6]).fill({color:16777215,alpha:l*.45})}}outline(e,t,s,r,n){const o=t.map(a=>D(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(j([D(a[3],t*u),D(a[2],t*u),D(a[2],t*d),D(a[3],t*d)])).fill(n.roof),s.poly(j([D(a[2],t*u),D(a[1],t*u),D(a[1],t*d),D(a[2],t*d)])).fill(n.roofD);const l=D(Z(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,ee(o,0,.25)),this.pyramid(s,De(r.gx+.2,r.gy+.2,.6,t+11),D(Z(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(j([s[3],s[2],D(s[2],-5),D(s[3],-5)])).fill(this.theme.dock.post),e.poly(j([s[2],s[1],D(s[1],-5),D(s[2],-5)])).fill(ee(this.theme.dock.post,0,.2)),e.poly(j(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(ee(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=ci(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=Z(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=Z(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(j([r[3],r[2],D(r[2],-14),D(r[3],-14)])).fill(t.edgeDark),e.poly(j([r[2],r[1],D(r[1],-14),D(r[2],-14)])).fill(t.edge),e.poly(j(r)).fill(t.fill),e.poly(j(De(s.x+1,s.y+1,Math.max(s.w,s.h)-2))).fill({color:t.fillLight,alpha:.25}),e.poly(j(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(j([n[3],n[2],D(n[2],-10),D(n[3],-10)])).fill(t.edgeDark),e.poly(j([n[2],n[1],D(n[1],-10),D(n[2],-10)])).fill(t.edge),e.poly(j(n)).fill(t.fill);for(let o=1;o<r;o+=2){const a=Z(s.x+o,s.y),l=Z(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=Z(s.x,s.y+o),l=Z(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=ci(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])=>Z(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 Gs({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 Ep({text:t.label,style:e});s.anchor.set(.5,.5);const r=Z(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=ci(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=fu(a,l);const c=new Pe;h.addChild(c);const u=Z(a+.5,l+.5),d=(.85+e()*.4)*1.25,[f,p,m]=this.theme.propColors;let g;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(m),g=new Pe,g.ellipse(u.x+1*d,u.y-13*d,9.5*d,7.5*d).fill(ee(f,this.shadowInk,.25)),g.ellipse(u.x,u.y-16*d,9*d,8.5*d).fill(f),g.ellipse(u.x-4*d,u.y-19*d,6.5*d,6*d).fill(p),g.ellipse(u.x+4.5*d,u.y-20*d,5.5*d,5*d).fill(p),g.ellipse(u.x-3.5*d,u.y-22*d,3.2*d,2.4*d).fill({color:16777215,alpha:.32}),h.addChild(g)):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(m)):(c.rect(u.x-1,u.y-16*d,2,16*d).fill(m),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,...g?{canopy:g}:{}}),n++}}}const xb=i=>ee(i,16777215,.25);function bb(i,e,t,s){return new Xe({start:{x:0,y:t},end:{x:0,y:s},colorStops:[{offset:0,color:i},{offset:1,color:e}],textureSpace:"global"})}function vb(i,e,t,s){return new Xe({start:{x:t,y:0},end:{x:s,y:0},colorStops:[{offset:0,color:i},{offset:1,color:e}],textureSpace:"global"})}const Yi=i=>Math.round(i/2)*2;function ee(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 zo{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 wb=Object.freeze(Object.defineProperty({__proto__:null,Gremlin:zo},Symbol.toStringTag,{value:"Module"}));class Tb{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 Ct=[{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}],Gg=i=>Ct.find(e=>e.id===i),pu=i=>(.2126*(i>>16&255)+.7152*(i>>8&255)+.0722*(i&255))/255,Dg=(i,e)=>Math.abs(pu(i.body)-pu(e))>.22;function Fg(i,e,t){const s=a=>t===void 0||Dg(a,t);let r=Gg(e)??Ct[i%Ct.length];s(r)||(r=Ct.find((a,l)=>l>=i%Ct.length&&s(a))??Ct.find(s)??r);const n=Ct.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 Sb=Object.freeze(Object.defineProperty({__proto__:null,CAST:Ct,castById:Gg,pickCompany:Fg,readableOn:Dg},Symbol.toStringTag,{value:"Module"}));class Ho{constructor(e,t,s=Ct[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,m=s.shape==="tall"?-16:s.shape==="boxy"?-13:s.shape==="bean"?-12:-13.5;u.moveTo(-p*.9,m-p*.2).quadraticCurveTo(-p*.75,m-p*.95,p*.1,m-p*1.02).stroke({width:2.2,color:16777215,alpha:.5,cap:"round"}),u.moveTo(p*.95,m+p*.1).quadraticCurveTo(p*.8,m+p*.8,p*.1,m+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 g=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+g*6,3.2,5).fill(s.ear),u.ellipse(9,_+4-g*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+g*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+g*6,3.2,5).fill(s.ear),u.ellipse(9,_+4-g*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 E=y+T*4.6;if(h.mood==="happy"){u.beginPath(),u.arc(E,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(E-2.6,x).lineTo(E+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 P=s.eyes==="dot"?2.6:s.eyes==="sleepy"?2.4:h.mood==="focused"?3:4.3;u.ellipse(E,x,s.eyes==="dot"?2.6:3.4,P).fill(16777215),s.eyes==="sleepy"&&u.moveTo(E-3.4,x-2.2).lineTo(E+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 k=h.face*1.1+A*1.6,I=(h.look==="up"?-1.6:h.look==="down"?1.4:.3)-A*.8;h.mood==="lost"&&(k=Math.sin(r*3)*1.4,I=-1.2),u.ellipse(E+k,x+I,1.9,h.mood==="focused"?1.8:2.2).fill(s.ink),u.ellipse(E+k+.7,x+I-.8,.6,.6).fill(16777215),h.mood==="lost"&&u.moveTo(E-3,x-5.6-(T>0?0:1.3)).lineTo(E+3,x-5.6-(T>0?1.3:0)).stroke({width:1.6,color:s.ink,cap:"round"}),h.mood==="focused"&&u.moveTo(E-3.2,x-3.7-(T>0?1:0)).lineTo(E+3.2,x-3.7-(T>0?0:1)).stroke({width:1.6,color:s.ink,cap:"round"}),h.mood==="uneasy"&&u.moveTo(E-3,x-5).lineTo(E+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=rt(r*.5%1)*h.hiding;u.rotation=h.lean+T*.06}}}const Mb=Object.freeze(Object.defineProperty({__proto__:null,Pip:Ho},Symbol.toStringTag,{value:"Module"})),Tt=[0,2,4,7,9],Cb=[0,3,5,7,10],mu=[0,2,4,6,7,9,11],gu=[0,2,3,5,7,9,10],kb=[0,2,4,5,7,9,10],Eb=[0,2,4,6,8,10],Pb=[0,1,4,5,7,8,11],zn=[0,2,3,5,7,8,10],Ab={island:{scale:Tt,root:261.6,wave:"sine",gain:.05,every:16,len:[.45,.9]},orbit:{scale:mu,root:220,wave:"triangle",gain:.035,every:20,len:[.8,1.6]},metropolis:{scale:gu,root:196,wave:"triangle",gain:.04,every:18,len:[.3,.7]},harbour:{scale:kb,root:233,wave:"sine",gain:.045,every:17,len:[.5,1.1]},observatory:{scale:Eb,root:329.6,wave:"sine",gain:.035,every:22,len:[.9,1.8]},greenhouse:{scale:Tt,root:293.7,wave:"triangle",gain:.045,every:15,len:[.35,.8]},workshop:{scale:Tt,root:220,wave:"triangle",gain:.045,every:16,len:[.3,.6]},arcade:{scale:Cb,root:261.6,wave:"square",gain:.025,every:12,len:[.15,.35]},kingdom:{scale:gu,root:174.6,wave:"triangle",gain:.045,every:19,len:[.6,1.2]},outpost:{scale:zn,root:196,wave:"sine",gain:.04,every:21,len:[.8,1.6]},snowfield:{scale:Tt,root:392,wave:"sine",gain:.04,every:18,len:[.7,1.5]},canopy:{scale:Tt,root:246.9,wave:"triangle",gain:.045,every:14,len:[.3,.7]},lagoon:{scale:Tt,root:329.6,wave:"sine",gain:.045,every:15,len:[.4,.9]},volcano:{scale:zn,root:146.8,wave:"sawtooth",gain:.03,every:20,len:[.9,1.8]},cloudtop:{scale:mu,root:392,wave:"sine",gain:.04,every:17,len:[.8,1.6]},reef:{scale:Tt,root:174.6,wave:"sine",gain:.045,every:14,len:[.9,2]},bazaar:{scale:Pb,root:220,wave:"triangle",gain:.045,every:13,len:[.25,.6]},monastery:{scale:Tt,root:196,wave:"sine",gain:.05,every:24,len:[1.2,2.4]},moonbase:{scale:zn,root:164.8,wave:"sine",gain:.035,every:23,len:[1,2]},lanterns:{scale:Tt,root:523.3,wave:"sine",gain:.04,every:14,len:[.3,.7]}},qe={wave:"triangle",pitch:1,decay:1,tone:3200,surface:"grass"},Hn={wave:"square",pitch:1.18,decay:.8,tone:2600,surface:"metal"},_u={wave:"sawtooth",pitch:.95,decay:1.1,tone:2200,surface:"stone"},Rb={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"},Bb={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"},Ib={island:{voice:qe,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:Hn,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:_u,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:{...qe,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:{...Hn,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:{...qe,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:{...qe,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:{...qe,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:{...qe,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:{...qe,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:{...qe,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:{...qe,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:{...qe,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:{...qe,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:{...qe,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:{...Hn,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:{..._u,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}}},Wo=Object.fromEntries(Object.entries(Ib).map(([i,e])=>[i,{...e,voice:{...e.voice,instrument:Rb[i]},ambience:{...e.ambience,mood:Bb[i]},tune:Ab[i]}])),Gb=i=>i,Db=new Set(["curtain_up","curtain_down","test_outcome","celebrate","blocked_on_you","unverified_claim","spawn_gremlin","banish"]),Fb=[523.25,659.25,783.99,1046.5],Ie=(i,e)=>i+Math.random()*(e-i);class Ki{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||Db.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=Wo[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,m=.85+Math.random()*.3,g=u*h.pitch*p,_=d*h.decay*m,y=f.gain??.25,x={...f,lowpass:Math.min(f.lowpass??h.tone,h.tone),...f.slideTo?{slideTo:f.slideTo*h.pitch*p}:{}};switch(Gb(h.instrument)){case"pluck":s.tone(g,_*.6,{...x,type:"triangle",attack:.003,gain:y}),s.tone(g*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(g,_*1.8,{...x,type:"sine",attack:.004,gain:y}),s.tone(g*2.76,_*1.1,{...x,type:"sine",attack:.004,gain:y*.3}),s.tone(g*5.4,_*.5,{...x,type:"sine",attack:.004,gain:y*.12});return;case"marimba":s.tone(g,_*.5,{...x,type:"sine",attack:.003,gain:y}),s.tone(g*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(g,_*.35,{...x,type:"square",attack:.002,gain:y*.7}),s.tone(g*1.5,_*.2,{...x,type:"square",attack:.002,gain:y*.2});return;case"glass":s.tone(g,_*2,{...x,type:"sine",attack:.02,gain:y*.9}),s.tone(g*1.005,_*2,{...x,type:"sine",attack:.02,gain:y*.6}),s.tone(g*3,_*.8,{...x,type:"sine",attack:.01,gain:y*.15});return;case"wood":s.tone(g*.5,_*.3,{...x,type:"triangle",attack:.002,gain:y*.9,slideTo:g*.35}),s.noise(.04,{filter:"lowpass",freq:1200,gain:y*.5});return;case"drop":s.tone(g*.8,_*.7,{...x,type:"sine",attack:.006,gain:y,slideTo:g*1.6}),s.noise(.05,{filter:"bandpass",freq:900,q:1.5,gain:y*.25,sweepTo:2400});return;default:s.tone(g,_,{...x,type:f.type??h.wave,gain:y}),s.tone(g*.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"?Fb.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 Ob{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=Wo[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=Wo[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,m=0;for(let g=0;g<d;g++){const _=g===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=g===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)},m*1e3),m+=x*(Math.random()<.2?1.5:1)}this.tuneTimer=setTimeout(c,(m+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,m)=>setTimeout(()=>{this.current===e.id&&this.a.note(p,.22,.03,"triangle",(m/f.length-.5)*.8)},m*(150+m%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 Qs{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 Ig(t,s),this.particles=new Tb(n),this.company=Fg(t.seed,o,s.ground.fill),this.pip=new Ho(s,n,this.company.lead),this.camera=new mb(this.stage,n),this.sfx=new Ki(r),this.amb=new Ob(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}hitTest(e,t){const s=this.camera.scale,r=(a,l)=>{const h=this.camera.toScreen(a.x,a.y);return Math.hypot(h.x-e,h.y-t)<l*s},n=this.pip.drawn;if(r({x:n.x,y:n.y-18},26))return{kind:"lead",name:this.company.lead.name,mood:this.pip.pose.mood};for(const[a,l]of this.helpers){const h=l.drawn;if(r({x:h.x,y:h.y-14},22))return{kind:"helper",name:this.company.helpers.find(c=>c.id===a)?.name??"Helper"}}let o=null;for(const a of this.world.places){const l=this.worldLayer.positionOf(a.id);if(!l)continue;const h=this.camera.toScreen(l.ground.x,l.ground.y),c=this.camera.toScreen(l.top.x,l.top.y),u=(a.footprint*32+8)*s,d=h.y+a.footprint*16*s,f=c.y-6*s;if(e>=h.x-u&&e<=h.x+u&&t>=f&&t<=d){const p=u*(d-f);(!o||p<o.area)&&(o={place:a,area:p})}}return o?{kind:"place",place:o.place}:null}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&&Ki.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 zo(e.gremlinId,s,this.reducedMotion),a=this.worldLayer.positionOf(e.target),l=a?a.ground:Z(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 Ho(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 zo(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*rt(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:Un((h-d)/(1-d));if(o.x=is(u.x,c.x,f),o.y=is(u.y,c.y,f),o.moving=h>=d&&h<.98,o.face=c.x>=u.x?1:-1,h<d){const p=rt(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 m=Math.cos(p*2);if(o.sy=1+.05*m,o.sx=1-.05*m,o.lean=o.face*.07,h>.86){const g=rt((h-.86)/.14);o.lean=o.face*.16*g,o.sy=1-.06*g,o.sx=1+.05*g}}r==="pip"&&this._playing&&(this.footT+=s,this.footT>.19&&Ki.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=rt(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,Ki.plays("hammer",this.rate)&&this.sfx.play(a.kind==="build"?"hammer":"spark",{theme:this.theme,intensity:a.kind==="build"?a.intensity:.5});const m="target"in a?this.worldLayer.positionOf(a.target):this.worldLayer.positionOf("forge");m&&Math.random()<.7&&this.particles.burst(m.top.x+(Math.random()*24-12),m.top.y+10,2,[16766571,16774084],50,60)}}break}case"raise":o.look="up",o.sy=1+.05*rt(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=rt(Ue(h,0,.5));o.lean=-.25*u,o.sy=1-.1*u,o.sx=1+.08*u}else o.lift=rt(h)*14;break;case"spawn_gremlin":{const u=rt(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,m=d.x+Math.cos(f)*p,g=d.y+Math.sin(f)*p*.5;u&&(u.x=m,u.y=g,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*rt(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=rt(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/(No/2)+.6,r!=="pip"&&(o.mood="focused")}for(const r of this.gremlins.values())r.container.zIndex=r.y/(No/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)*Un(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-du(t))))}if(e.kind==="spawn_gremlin"){const t=this.gremlins.get(e.gremlinId);t&&(t.scale=Math.max(.01,du(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=>Z(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,m=(w,T,E)=>T+f>E-f?(T+E)/2:Math.max(T+f,Math.min(E-f,w)),g=(w,T,E)=>T+p>E-p?(T+E)/2:Math.max(T+p,Math.min(E-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,E=x.x-this.camTarget.x,P=x.y-this.camTarget.y;Math.abs(E)>w&&(this.camTarget.x+=E-Math.sign(E)*w),Math.abs(P)>T&&(this.camTarget.y+=P-Math.sign(P)*T)}const b=m(this.camTarget.x,a,l),v=g(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*is(1.08,1,Un(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=>[Z(l.gx,l.gy),Z(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},Fs={...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},xr={...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},Lb={...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},Ub={...Fs,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:{...Fs.beacon,roof:11967743,roofD:9401062},prop:"antenna",propColors:[13617646,16773544,3091781],vignette:329756},Nb={...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},Og={...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},zb={...xr,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:{...xr.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},Lg={...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},Hb={...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},Wb={...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},$b={...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},Vb={...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},jb={...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},Xb={...Fs,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:{...Fs.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},qb={...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},Yb={...Og,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},Kb={...Lg,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},Zb={...Fs,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},Qb={...xr,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},Pt=[ke,Fs,xr,Lb,Ub,Nb,Og,zb,Lg,Hb,Wb,$b,Vb,jb,Xb,qb,Yb,Kb,Zb,Qb],or=i=>Pt.find(e=>e.id===i)??ke;function $o(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=Pt.filter(l=>s(l)>1),n=r.length>=3?r:Pt;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)}const Jb={aVertex:(i,e,t,s,r)=>{let n=0,o=0,a=0,l=0;for(let h=0;h<i.length;++h){const c=i[h],u=c.texture,d=c.scaleX,f=c.scaleY,p=c.anchorX,m=c.anchorY,g=u.trim,_=u.orig;g?(o=g.x-p*_.width,n=o+g.width,l=g.y-m*_.height,a=l+g.height):(n=_.width*(1-p),o=_.width*-p,a=_.height*(1-m),l=_.height*-m),e[s]=o*d,e[s+1]=l*f,e[s+r]=n*d,e[s+r+1]=l*f,e[s+r*2]=n*d,e[s+r*2+1]=a*f,e[s+r*3]=o*d,e[s+r*3+1]=a*f,s+=r*4}},aPosition:(i,e,t,s,r)=>{for(let n=0;n<i.length;++n){const o=i[n],a=o.x,l=o.y;e[s]=a,e[s+1]=l,e[s+r]=a,e[s+r+1]=l,e[s+r*2]=a,e[s+r*2+1]=l,e[s+r*3]=a,e[s+r*3+1]=l,s+=r*4}},aRotation:(i,e,t,s,r)=>{for(let n=0;n<i.length;++n){const o=i[n].rotation;e[s]=o,e[s+r]=o,e[s+r*2]=o,e[s+r*3]=o,s+=r*4}},aUV:(i,e,t,s,r)=>{for(let n=0;n<i.length;++n){const o=i[n].texture.uvs;e[s]=o.x0,e[s+1]=o.y0,e[s+r]=o.x1,e[s+r+1]=o.y1,e[s+r*2]=o.x2,e[s+r*2+1]=o.y2,e[s+r*3]=o.x3,e[s+r*3+1]=o.y3,s+=r*4}},aColor:(i,e,t,s,r)=>{for(let n=0;n<i.length;++n){const o=i[n].color;t[s]=o,t[s+r]=o,t[s+r*2]=o,t[s+r*3]=o,s+=r*4}}};function e1(i){const e=Object.values(i),t=e.filter(r=>r.dynamic),s=e.filter(r=>!r.dynamic);return{dynamicUpdate:yu(t),staticUpdate:yu(s)}}function yu(i){let e=0;const t=[];for(let s=0;s<i.length;s++){const r=i[s],n=gt(r.format).stride/4;e+=n,t.push({stride:n,updateFunction:r.updateFunction||Jb[r.attributeName]})}return(s,r,n)=>{let o=0;for(let a=0;a<t.length;a++){const l=t[a];l.updateFunction(s,r,n,o,e),o+=l.stride}}}function t1(){return s1}function s1(i,e,t){const s=i.gl,r=i.shader,n=r._getProgramData(e.glProgram);for(const o in e.groups){const a=e.groups[o];for(const l in a.resources){const h=a.resources[l];if(h instanceof Qe)h.ubo?r.bindUniformBlock(h,e._uniformBindMap[o][l],t.blockIndex++):r.updateUniformGroup(h);else if(h instanceof ki)r.bindUniformBlock(h,e._uniformBindMap[o][l],t.blockIndex++);else if(h instanceof ue||h instanceof Nl){i.texture.bind(h,t.textureCount);const c=e._uniformBindMap[o][l],u=n.uniformData[c];u&&(u.value!==t.textureCount&&s.uniform1i(u.location,t.textureCount),t.textureCount++)}}}}const i1=[(i,e,t,s,r)=>{const n=s[i].toArray(!0);e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+4]=n[3],e[t+5]=n[4],e[t+6]=n[5],e[t+8]=n[6],e[t+9]=n[7],e[t+10]=n[8]},(i,e,t,s,r)=>{r=s[i],e[t]=r.x,e[t+1]=r.y,e[t+2]=r.width,e[t+3]=r.height},(i,e,t,s,r)=>{r=s[i],e[t]=r.x,e[t+1]=r.y},(i,e,t,s,r)=>{r=s[i],e[t]=r.red,e[t+1]=r.green,e[t+2]=r.blue,e[t+3]=r.alpha},(i,e,t,s,r)=>{r=s[i],e[t]=r.red,e[t+1]=r.green,e[t+2]=r.blue}],r1={f32:(i,e,t,s,r)=>{e[t]=r},i32:(i,e,t,s,r)=>{e[t]=r},"vec2<f32>":(i,e,t,s,r)=>{e[t]=r[0],e[t+1]=r[1]},"vec3<f32>":(i,e,t,s,r)=>{e[t]=r[0],e[t+1]=r[1],e[t+2]=r[2]},"vec4<f32>":(i,e,t,s,r)=>{e[t]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3]},"mat2x2<f32>":(i,e,t,s,r)=>{e[t]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3]},"mat3x3<f32>":(i,e,t,s,r)=>{e[t]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+4]=r[3],e[t+5]=r[4],e[t+6]=r[5],e[t+8]=r[6],e[t+9]=r[7],e[t+10]=r[8]},"mat4x4<f32>":(i,e,t,s,r)=>{for(let n=0;n<16;n++)e[t+n]=r[n]},"mat3x2<f32>":(i,e,t,s,r)=>{for(let n=0;n<6;n++)e[t+(n/3|0)*4+n%3]=r[n]},"mat4x2<f32>":(i,e,t,s,r)=>{for(let n=0;n<8;n++)e[t+(n/4|0)*4+n%4]=r[n]},"mat2x3<f32>":(i,e,t,s,r)=>{for(let n=0;n<6;n++)e[t+(n/2|0)*4+n%2]=r[n]},"mat4x3<f32>":(i,e,t,s,r)=>{for(let n=0;n<12;n++)e[t+(n/4|0)*4+n%4]=r[n]},"mat2x4<f32>":(i,e,t,s,r)=>{for(let n=0;n<8;n++)e[t+(n/2|0)*4+n%2]=r[n]},"mat3x4<f32>":(i,e,t,s,r)=>{for(let n=0;n<12;n++)e[t+(n/3|0)*4+n%3]=r[n]}},n1={f32:(i,e,t,s,r)=>{e[t]=r},i32:(i,e,t,s,r)=>{e[t]=r},"vec2<f32>":(i,e,t,s,r)=>{e[t]=r[0],e[t+1]=r[1]},"vec3<f32>":(i,e,t,s,r)=>{e[t]=r[0],e[t+1]=r[1],e[t+2]=r[2]},"vec4<f32>":(i,e,t,s,r)=>{e[t]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3]},"mat2x2<f32>":(i,e,t,s,r)=>{e[t]=r[0],e[t+1]=r[1],e[t+4]=r[2],e[t+5]=r[3]},"mat3x3<f32>":(i,e,t,s,r)=>{e[t]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+4]=r[3],e[t+5]=r[4],e[t+6]=r[5],e[t+8]=r[6],e[t+9]=r[7],e[t+10]=r[8]},"mat4x4<f32>":(i,e,t,s,r)=>{for(let n=0;n<16;n++)e[t+n]=r[n]},"mat3x2<f32>":(i,e,t,s,r)=>{for(let n=0;n<6;n++)e[t+(n/3|0)*4+n%3]=r[n]},"mat4x2<f32>":(i,e,t,s,r)=>{for(let n=0;n<8;n++)e[t+(n/4|0)*4+n%4]=r[n]},"mat2x3<f32>":(i,e,t,s,r)=>{for(let n=0;n<6;n++)e[t+(n/2|0)*4+n%2]=r[n]},"mat4x3<f32>":(i,e,t,s,r)=>{for(let n=0;n<12;n++)e[t+(n/4|0)*4+n%4]=r[n]},"mat2x4<f32>":(i,e,t,s,r)=>{for(let n=0;n<8;n++)e[t+(n/2|0)*4+n%2]=r[n]},"mat3x4<f32>":(i,e,t,s,r)=>{for(let n=0;n<12;n++)e[t+(n/3|0)*4+n%3]=r[n]}};function o1(i){return Ug(i,n1,e=>{const t=Math.max(Zr[e.data.type]/16,1),s=e.data.value.length/e.data.size,r=(4-s%4)%4;return(n,o,a,l,h)=>{let c=0;for(let u=0;u<e.data.size*t;u++){for(let d=0;d<s;d++)o[a++]=h[c++];a+=r}}})}function a1(i){return Ug(i,r1,e=>{const{size:t,align:s}=Ps[e.data.type],r=(Math.max(t,s)-t)/4;return(n,o,a,l,h)=>{let c=0;for(let u=0;u<e.data.size;u++){for(let d=0;d<t/4;d++)o[a++]=h[c++];a+=r}}})}function Ug(i,e,t){const s={};for(const r in i){const n=i[r],o=n.data;let a=!1;s[o.name]={offset:n.offset/4,func:null};for(let l=0;l<ot.length;l++){const h=ot[l];if(o.type===h.type&&h.test(o)){s[o.name].func=i1[l],a=!0;break}}a||(o.size===1?s[o.name].func=e[o.type]:s[o.name].func=t(n))}return(r,n,o,a)=>{for(const l in s)s[l].func(l,n,a+s[l].offset,r,r[l])}}const l1={f32(i,e,t,s,r,n,o){t!==s&&(e.value=s,o.uniform1f(r[i].location,s))},"vec2<f32>"(i,e,t,s,r,n,o){(t[0]!==s[0]||t[1]!==s[1])&&(t[0]=s[0],t[1]=s[1],o.uniform2f(r[i].location,s[0],s[1]))},"vec3<f32>"(i,e,t,s,r,n,o){(t[0]!==s[0]||t[1]!==s[1]||t[2]!==s[2])&&(t[0]=s[0],t[1]=s[1],t[2]=s[2],o.uniform3f(r[i].location,s[0],s[1],s[2]))},"vec4<f32>"(i,e,t,s,r,n,o){(t[0]!==s[0]||t[1]!==s[1]||t[2]!==s[2]||t[3]!==s[3])&&(t[0]=s[0],t[1]=s[1],t[2]=s[2],t[3]=s[3],o.uniform4f(r[i].location,s[0],s[1],s[2],s[3]))},i32(i,e,t,s,r,n,o){t!==s&&(e.value=s,o.uniform1i(r[i].location,s))},"vec2<i32>"(i,e,t,s,r,n,o){(t[0]!==s[0]||t[1]!==s[1])&&(t[0]=s[0],t[1]=s[1],o.uniform2i(r[i].location,s[0],s[1]))},"vec3<i32>"(i,e,t,s,r,n,o){(t[0]!==s[0]||t[1]!==s[1]||t[2]!==s[2])&&(t[0]=s[0],t[1]=s[1],t[2]=s[2],o.uniform3i(r[i].location,s[0],s[1],s[2]))},"vec4<i32>"(i,e,t,s,r,n,o){(t[0]!==s[0]||t[1]!==s[1]||t[2]!==s[2]||t[3]!==s[3])&&(t[0]=s[0],t[1]=s[1],t[2]=s[2],t[3]=s[3],o.uniform4i(r[i].location,s[0],s[1],s[2],s[3]))},u32(i,e,t,s,r,n,o){t!==s&&(e.value=s,o.uniform1ui(r[i].location,s))},"vec2<u32>"(i,e,t,s,r,n,o){(t[0]!==s[0]||t[1]!==s[1])&&(t[0]=s[0],t[1]=s[1],o.uniform2ui(r[i].location,s[0],s[1]))},"vec3<u32>"(i,e,t,s,r,n,o){(t[0]!==s[0]||t[1]!==s[1]||t[2]!==s[2])&&(t[0]=s[0],t[1]=s[1],t[2]=s[2],o.uniform3ui(r[i].location,s[0],s[1],s[2]))},"vec4<u32>"(i,e,t,s,r,n,o){(t[0]!==s[0]||t[1]!==s[1]||t[2]!==s[2]||t[3]!==s[3])&&(t[0]=s[0],t[1]=s[1],t[2]=s[2],t[3]=s[3],o.uniform4ui(r[i].location,s[0],s[1],s[2],s[3]))},bool(i,e,t,s,r,n,o){t!==s&&(e.value=s,o.uniform1i(r[i].location,s))},"vec2<bool>"(i,e,t,s,r,n,o){(t[0]!==s[0]||t[1]!==s[1])&&(t[0]=s[0],t[1]=s[1],o.uniform2i(r[i].location,s[0],s[1]))},"vec3<bool>"(i,e,t,s,r,n,o){(t[0]!==s[0]||t[1]!==s[1]||t[2]!==s[2])&&(t[0]=s[0],t[1]=s[1],t[2]=s[2],o.uniform3i(r[i].location,s[0],s[1],s[2]))},"vec4<bool>"(i,e,t,s,r,n,o){(t[0]!==s[0]||t[1]!==s[1]||t[2]!==s[2]||t[3]!==s[3])&&(t[0]=s[0],t[1]=s[1],t[2]=s[2],t[3]=s[3],o.uniform4i(r[i].location,s[0],s[1],s[2],s[3]))},"mat2x2<f32>"(i,e,t,s,r,n,o){o.uniformMatrix2fv(r[i].location,!1,s)},"mat3x3<f32>"(i,e,t,s,r,n,o){o.uniformMatrix3fv(r[i].location,!1,s)},"mat4x4<f32>"(i,e,t,s,r,n,o){o.uniformMatrix4fv(r[i].location,!1,s)}},h1={f32(i,e,t,s,r,n,o){o.uniform1fv(r[i].location,s)},"vec2<f32>"(i,e,t,s,r,n,o){o.uniform2fv(r[i].location,s)},"vec3<f32>"(i,e,t,s,r,n,o){o.uniform3fv(r[i].location,s)},"vec4<f32>"(i,e,t,s,r,n,o){o.uniform4fv(r[i].location,s)},"mat2x2<f32>"(i,e,t,s,r,n,o){o.uniformMatrix2fv(r[i].location,!1,s)},"mat3x3<f32>"(i,e,t,s,r,n,o){o.uniformMatrix3fv(r[i].location,!1,s)},"mat4x4<f32>"(i,e,t,s,r,n,o){o.uniformMatrix4fv(r[i].location,!1,s)},i32(i,e,t,s,r,n,o){o.uniform1iv(r[i].location,s)},"vec2<i32>"(i,e,t,s,r,n,o){o.uniform2iv(r[i].location,s)},"vec3<i32>"(i,e,t,s,r,n,o){o.uniform3iv(r[i].location,s)},"vec4<i32>"(i,e,t,s,r,n,o){o.uniform4iv(r[i].location,s)},u32(i,e,t,s,r,n,o){o.uniform1iv(r[i].location,s)},"vec2<u32>"(i,e,t,s,r,n,o){o.uniform2iv(r[i].location,s)},"vec3<u32>"(i,e,t,s,r,n,o){o.uniform3iv(r[i].location,s)},"vec4<u32>"(i,e,t,s,r,n,o){o.uniform4iv(r[i].location,s)},bool(i,e,t,s,r,n,o){o.uniform1iv(r[i].location,s)},"vec2<bool>"(i,e,t,s,r,n,o){o.uniform2iv(r[i].location,s)},"vec3<bool>"(i,e,t,s,r,n,o){o.uniform3iv(r[i].location,s)},"vec4<bool>"(i,e,t,s,r,n,o){o.uniform4iv(r[i].location,s)}},c1=[(i,e,t,s,r,n,o)=>{o.uniformMatrix3fv(r[i].location,!1,n[i].toArray(!0))},(i,e,t,s,r,n,o)=>{t=r[i].value,s=n[i],(t[0]!==s.x||t[1]!==s.y||t[2]!==s.width||t[3]!==s.height)&&(t[0]=s.x,t[1]=s.y,t[2]=s.width,t[3]=s.height,o.uniform4f(r[i].location,s.x,s.y,s.width,s.height))},(i,e,t,s,r,n,o)=>{t=r[i].value,s=n[i],(t[0]!==s.x||t[1]!==s.y)&&(t[0]=s.x,t[1]=s.y,o.uniform2f(r[i].location,s.x,s.y))},(i,e,t,s,r,n,o)=>{t=r[i].value,s=n[i],(t[0]!==s.red||t[1]!==s.green||t[2]!==s.blue||t[3]!==s.alpha)&&(t[0]=s.red,t[1]=s.green,t[2]=s.blue,t[3]=s.alpha,o.uniform4f(r[i].location,s.red,s.green,s.blue,s.alpha))},(i,e,t,s,r,n,o)=>{t=r[i].value,s=n[i],(t[0]!==s.red||t[1]!==s.green||t[2]!==s.blue)&&(t[0]=s.red,t[1]=s.green,t[2]=s.blue,o.uniform3f(r[i].location,s.red,s.green,s.blue))}];function u1(i,e){const t={};for(const s in i.uniformStructures){if(!e[s])continue;const r=i.uniformStructures[s];let n=!1;for(let o=0;o<ot.length;o++){const a=ot[o];if(r.type===a.type&&a.test(r)){t[s]=c1[o],n=!0;break}}if(!n){const o=r.size===1?l1:h1;t[s]=o[r.type]}}return(s,r,n)=>{const o=n.gl;for(const a in t){const l=r[a],h=s[a],c=s[a].value;t[a](a,h,c,l,s,r,o)}}}function d1(){Object.assign(fs.prototype,{_unsafeEvalCheck(){}}),Object.assign(Kr.prototype,{_systemCheck(){}}),Object.assign(en.prototype,{_generateUniformsSync:u1}),Object.assign(Qr.prototype,{_generateUboSync:o1}),Object.assign(sn.prototype,{_generateUboSync:a1}),Object.assign(Jr.prototype,{_generateShaderSync:t1}),Object.assign(vg.prototype,{generateParticleUpdate:e1})}d1();class fh{constructor(e){this.payload=e}mode="replay";onReady(e){queueMicrotask(()=>e(this.payload))}onBeats(){}}class f1{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,...e.cwd?{cwd:e.cwd}:{},elsewhere:e.elsewhere??null};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),a.type==="elsewhere"&&a.cwd&&this.elsewhereCb?.(a.cwd)},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}elsewhereCb=null;onElsewhere(e){this.elsewhereCb=e}}class p1{constructor(e,t){this.host=e,this.session=t,addEventListener("message",s=>{const r=s.data;if(r?.type==="elsewhere"&&r.cwd&&this.elsewhereCb?.(r.cwd),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,...n.cwd?{cwd:n.cwd}:{},elsewhere:n.elsewhere??null};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}elsewhereCb=null;onElsewhere(e){this.elsewhereCb=e}}async function m1(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 fh({world:s.world,events:s.events,beats:s.beats,repoId:s.title?`${s.repoId} — ${s.title}`:s.repoId})}function g1(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 _1(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 Wn=i=>{const e=Math.floor(i/1e3);return`${Math.floor(e/60)}:${String(e%60).padStart(2,"0")}`},$n=i=>`#${i.toString(16).padStart(6,"0")}`,W=(i,e,t)=>{const s=document.createElement(i);return e&&(s.className=e),t!==void 0&&(s.innerHTML=t),s},y1='<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>',xu='<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>',x1='<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 b1{constructor(e,t){this.h=t,this.root=W("div","wrap");const s=W("header"),r=W("div","brand",'<div class="eyebrow"><a href="https://agenttheatre.dev/" title="Back to agenttheatre.dev">← Agent Theatre</a><span class="for"> · the stage for</span></div><h1 id="title">Loading…</h1>'),n=W("div","toolbar");this.setBtn=W("button","btn ghost","Set"),this.setBtn.type="button",this.setBtn.onclick=()=>this.showPicker(!0),this.muteBtn=W("button","btn ghost","Effects on"),this.muteBtn.type="button",this.muteBtn.title="Sound effects",this.muteBtn.onclick=()=>t.onMute(),this.ambBtn=W("button","btn ghost","Ambience on"),this.ambBtn.type="button",this.ambBtn.title="Background sound",this.ambBtn.onclick=()=>t.onAmbience(),this.overviewBtn=W("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=W("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=W("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=W("div","grid"),a=W("div","stage-col");this.stageEl=W("div","stage"),this.overlay=W("div","overlay"),this.bubbleEl=W("div","bubble"),this.bubbleEl.hidden=!0,this.overlay.append(this.bubbleEl),this.signal=W("div","signal","<i></i><span>live</span>"),this.signal.hidden=!0,this.chip=W("div","chip ok"),this.chip.hidden=!0,this.caption=W("div","caption","<span></span>"),this.title=W("div","card",'<div class="small">Agent Theatre</div><div class="big" id="titleBig">…</div>'),this.end=W("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=W("div","picker"),this.picker.hidden=!0,this.waiting=W("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=W("form","prompt",'<div class="note" hidden></div><div class="row"><input type="text" placeholder="" autocomplete="off" spellcheck="false"><button type="submit">Send</button><span class="st"></span></div>'),this.prompt.hidden=!0,this.prompt.addEventListener("submit",f=>{f.preventDefault();const p=this.prompt.querySelector("input"),m=this.prompt.querySelector(".st"),g=p.value.trim();g&&(m.textContent="sending…",t.onPrompt(g).then(_=>{m.textContent=_,p.value=""}))}),this.tip=W("div","tip"),this.tip.hidden=!0,this.stageEl.append(W("div","vignette"),this.overlay,this.signal,this.chip,this.caption,this.title,this.end,this.picker,this.waiting,this.prompt,this.tip),this.stageEl.addEventListener("pointermove",f=>{const p=this.stageEl.getBoundingClientRect(),m=this.hitTester?.(f.clientX-p.left,f.clientY-p.top)??null;if(!m){this.tip.hidden=!0;return}this.tip.innerHTML=this.describeHit(m),this.tip.hidden=!1;const g=Math.min(f.clientX-p.left+14,p.width-this.tip.offsetWidth-10),_=f.clientY-p.top+16;this.tip.style.left=`${Math.max(8,g)}px`,this.tip.style.top=`${Math.min(_,p.height-this.tip.offsetHeight-10)}px`}),this.stageEl.addEventListener("pointerleave",()=>{this.tip.hidden=!0}),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=W("div","controls");this.playBtn=W("button","btn",`${xu}<span>Pause</span>`),this.playBtn.type="button",this.playBtn.onclick=()=>t.onPlayPause();const h=W("div","track");this.actsEl=W("div","acts"),this.labelsEl=W("div","actlabels"),this.head=W("div","head"),h.append(this.actsEl,this.labelsEl,this.head),h.addEventListener("pointerdown",f=>{const p=this.actsEl.getBoundingClientRect(),m=(f.clientX-p.left)/p.width;t.onSeek(m*this.durationMs)}),this.time=W("div","time","0:00 / 0:00"),this.liveBtn=W("button","btn golive",'<i class="dot"></i><span>Go live</span>'),this.liveBtn.type="button",this.liveBtn.title="Jump back to what is happening now",this.liveBtn.hidden=!0,this.liveBtn.onclick=()=>t.onGoLive(),this.rateBtn=W("button","btn ghost","1×"),this.rateBtn.type="button",this.rateBtn.onclick=()=>t.onRate(),l.append(this.playBtn,h,this.time,this.liveBtn,this.rateBtn),a.append(this.stageEl,l);const c=W("aside"),u=W("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=W("ul","log"),u.append(this.logEl);const d=W("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,W("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=W("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>
|
|
970
970
|
<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>
|
|
971
|
-
<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;liveBtn;tip;hitTester=null;fileStats=new Map;describeHit(e){if(e.kind==="lead")return`<b>${Ne(e.name)}</b> — the agent, your lead.<br><span>Mood: ${Ne(e.mood)}. The light on its head shows it.</span>`;if(e.kind==="helper")return`<b>${Ne(e.name)}</b> — a helper (subagent).<br><span>Arrived at the dock; working on its own task.</span>`;const t=e.place,s=this.fileStats.get(t.path),r=s?[s.reads?`read ${s.reads}×`:"",s.edits?`edited ${s.edits}× (+${s.added} −${s.removed})`:""].filter(Boolean).join(" · "):"";switch(t.kind){case"forge":return"<b>The forge</b> — shell work.<br><span>Commands that touch no particular file (installs, builds, git) happen here.</span>";case"dock":return"<b>The dock</b> — where helpers arrive.<br><span>Subagents row in here and fan out to their districts.</span>";case"beacon":return`<b>${Ne(t.label)}</b> — a test suite.<br><span>${Ne(t.path)}${s?.tests?` · last run: ${Ne(s.tests)}`:""}. Its lamp scans while tests run, goes red on failure, green on a pass.</span>`;case"archive":return`<b>${Ne(t.label)}</b> — docs / data.<br><span>${Ne(t.path)}${r?" · "+r:""}</span>`;case"overflow":return`<b>${Ne(t.label)}</b> — the rest of this folder.<br><span>Files below the relevance cap share this building; activity on them lands here.</span>`;default:return`<b>${Ne(t.label)}</b> — a file.<br><span>${Ne(t.path)} · size class ${t.height}/5${r?" · "+r:" · untouched this session"}</span>`}}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.fileStats=new Map;const r=o=>{let a=this.fileStats.get(o);return a||(a={reads:0,edits:0,added:0,removed:0},this.fileStats.set(o,a)),a};for(const o of t)if(o.kind==="read_file")r(o.path).reads++;else if(o.kind==="edit_file"){const a=r(o.path);a.edits++,a.added+=o.added,a.removed+=o.removed}else if(o.kind==="write_file"){const a=r(o.path);a.edits++,a.added+=o.added}else if(o.kind==="test_result"){const a=o.failed?`${o.failed} failed, ${o.passed} passed`:`${o.passed} passed`;for(const l of s.places)l.kind==="beacon"&&(r(l.path).tests=a)}this.durationMs=e.length?Math.max(...e.map(o=>o.atMs+o.durationMs)):0,this.acts=_1(e),this.actsEl.innerHTML="",this.labelsEl.innerHTML="",this.actBtns=[],this.actLabels=[];for(const o of this.acts){const a=(o.toMs-o.fromMs)/Math.max(1,this.durationMs)*100,l=W("button");l.type="button",l.style.flex=`0 0 calc(${a}% - 3px)`,l.setAttribute("aria-label",`Jump to ${o.label}`),l.onclick=c=>{c.stopPropagation(),this.h.onSeek(o.fromMs+1)};const h=W("span","",o.label);h.style.flex=`0 0 calc(${a}% - 3px)`,this.actsEl.append(l),this.labelsEl.append(h),this.actBtns.push(l),this.actLabels.push(h)}this.logEl.innerHTML="",this.logBtns=[],t[0]?.ts;const n=o=>e.find(a=>a.sourceEventIds.includes(o));for(const o of t){if(o.kind==="session_start"||o.kind==="session_end")continue;const a=n(o.id);if(!a)continue;const l=W("li"),h=W("button");h.type="button";const[c,u]=v1(o),d=o.kind==="test_result"&&!o.ok;h.innerHTML=`<time>${Wn(a.atMs)}</time><span class="dot k-${o.kind}${d?" fail":""}"></span><span class="ev"><b>${Ne(c)}</b><code>${Ne(u)}</code></span>`,h.onclick=()=>this.h.onSeek(a.atMs+1),l.append(h),this.logEl.append(l),this.logBtns.push({btn:h,ms:a.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=$o(this.profile,w1(this.repoId)).slice(0,3),o=this.showAll?[...Pt]:n;this.picker.append(W("h3","",this.showAll?"All sets":"Choose your set"),W("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=W("div","setcards");for(const u of o){const d=W("button","setcard");d.type="button";const f=this.previews.get(u.id);d.innerHTML=`<div class="sw" style="--a:${$n(u.sky[0])};--b:${$n(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=W("div","toolbar"),h=W("button","btn ghost","Surprise me");h.type="button",h.onclick=()=>this.h.onShuffle();const c=W("button","btn ghost",this.showAll?"Suggested":`All ${Pt.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=`${Wn(e.t)} / ${Wn(e.duration)}`,this.head.style.left=`${e.t/Math.max(1,e.duration)*100}%`;const n=e.t>=e.duration-1;this.liveBtn.hidden=!(this.liveMode&&e.duration-e.t>1500),this.playBtn.innerHTML=this.liveMode&&n?'<i class="dot"></i><span>Live</span>':e.playing?`${xu}<span>Pause</span>`:`${y1}<span>${n?"Replay":"Play"}</span>`,this.playBtn.title=this.liveMode&&n?"You are watching the live edge; new events play as they arrive":"";const o=e.current;this.title.style.opacity=String(o&&o.kind==="curtain_up"?1-Math.min(1,Math.max(0,(e.t-o.atMs-600)/700)):e.t<600?1:0);const a=o&&o.kind==="curtain_down"?o:null;this.end.style.opacity=String(a?Math.min(1,Math.max(0,(e.t-a.atMs-400)/600)):0);const l=o?g1(o,t,r).replace(/\bPip\b/g,this.leadName):"";o&&o.id!==this.lastBeatId&&(this.lastBeatId=o.id,l&&(this.lastCaption=l));const h=this.caption.firstElementChild;h.textContent=this.lastCaption,h.style.opacity=this.lastCaption&&!(o?.kind==="curtain_up"&&e.t-(o?.atMs??0)<900)?"1":"0",e.evidence?(this.chip.hidden=!1,this.chip.className="chip ok",this.chip.innerHTML=`${x1}Evidence · ${e.evidence.passed} tests passed`):o?.kind==="unverified_claim"||o?.kind==="curtain_down"&&!o.verified?(this.chip.hidden=!1,this.chip.className="chip warn",this.chip.textContent="No test evidence"):this.chip.hidden=!0;const c=this.liveMode&&o?.kind==="your_turn"&&this.promptEnabled;if(this.prompt.hidden=!c,c&&o?.kind==="your_turn"){this.prompt.querySelector("input").placeholder=`${this.leadName||"The agent"} is done. What's next?`;const _=this.prompt.querySelector(".note");_.hidden=!o.note,_.textContent=o.note?`${this.leadName||"The agent"}: ${o.note}`:""}const u=this.liveMode&&o?.kind==="blocked_on_you";if(this.waiting.hidden=!u,u&&o?.kind==="blocked_on_you"){const _=o.reason==="permission"?"needs your permission to continue":"has a question for you";this.waiting.querySelector("b").textContent=`${this.leadName||"The agent"} ${_}.`,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!==o.id&&(this.notifiedFor=o.id,!this.vscode&&"Notification"in globalThis&&Notification.permission==="granted"&&new Notification("Agent Theatre",{body:`${this.leadName||"The agent"} ${_}.`}))}if(this.liveMode&&e.duration===0){const _=(this.repoId||"this folder").split(/[/\\]/).filter(Boolean).pop();this.caption.hidden=!1,this.caption.firstElementChild.textContent=`Waiting for a Claude Code session in ${_}. 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 d=0;this.acts.forEach((_,y)=>{e.t>=_.fromMs&&(d=y)}),d!==this.lastAct&&(this.lastAct=d,this.actBtns.forEach((_,y)=>{_.classList.toggle("on",y<d),_.classList.toggle("now",y===d)}),this.actLabels.forEach((_,y)=>_.classList.toggle("now",y===d)));let f=-1;if(this.logBtns.forEach((_,y)=>{e.t>=_.ms&&(f=y)}),f!==this.lastEv){this.lastEv=f,this.logBtns.forEach((y,x)=>{y.btn.classList.toggle("done",x<f),y.btn.classList.toggle("now",x===f)});const _=this.logBtns[f]?.btn;_&&T1(_)}const m=this.stageEl.getBoundingClientRect().width<600,g=e.labels.filter(_=>_.active||!m).sort((_,y)=>_.screen.y-y.screen.y||_.screen.x-y.screen.x);for(let _=0;_<g.length;_++)for(let y=0;y<_;y++){const x=g[y],b=g[_];Math.abs(x.screen.x-b.screen.x)<76&&Math.abs(x.screen.y-b.screen.y)<20&&(b.screen={x:b.screen.x,y:x.screen.y-20})}for(;this.tagPool.length<g.length;){const _=W("div","tag");this.overlay.append(_),this.tagPool.push(_)}this.tagPool.forEach((_,y)=>{const x=g[y];if(!x){_.hidden=!0;return}_.hidden=!1,_.textContent=x.text;const b=t.places.find(w=>w.label===x.text)?.id??"",v=s(b);_.className=`tag${x.active?" active":""}${v!=="idle"?` lamp-${v}`:""}`,_.style.left=`${x.screen.x}px`,_.style.top=`${x.screen.y}px`}),e.bubble?(this.bubbleEl.hidden=!1,this.bubbleEl.textContent=e.bubble.text,this.bubbleEl.style.color=$n(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",o?.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 v1(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 w1=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 T1(i){let e=i.parentElement;for(;e&&!/(auto|scroll)/.test(getComputedStyle(e).overflowY);)e=e.parentElement;if(!e)return;const t=i.offsetTop-e.offsetTop,s=t+i.offsetHeight;t<e.scrollTop?e.scrollTo({top:t,behavior:"smooth"}):s>e.scrollTop+e.clientHeight&&e.scrollTo({top:s-e.clientHeight,behavior:"smooth"})}const Ne=i=>i.replace(/[&<>"]/g,e=>({"&":"&","<":"<",">":">",'"':"""})[e]??e);async function S1(i,e,t,s=360,r=200){const n=new Ig(e,t);n.update(0);const o=new _e,a=e.places.flatMap(m=>[Z(m.gx,m.gy),Z(m.gx+m.footprint,m.gy+m.footprint)]),l=a.map(m=>m.x),h=a.map(m=>m.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=Ci.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),Os=ne.get("base")??"",es=globalThis.acquireVsCodeApi?.()??null;globalThis.__vsapi=es;const Zi=matchMedia("(prefers-reduced-motion: reduce)").matches,it={get:i=>{try{return localStorage.getItem(i)}catch{return null}},set:(i,e)=>{try{localStorage.setItem(i,e)}catch{}}};async function M1(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 C1(i){const e=await M1(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}=Zx(t),r=hb(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=nb({repoId:o,files:n,touched:r.touched}),l=nr(s,a);return new fh({world:a,events:s,beats:l,repoId:o})}async function k1(i,e){const t=new cb;let s=()=>{};const r=async()=>{await t.arm(),t.ready&&a?.audioReady()};let n=!1;for(const C of["pointerdown","keydown"])addEventListener(C,()=>{t.ready||(n=!0,setTimeout(()=>{n=!1},700),r())},{passive:!0});let o=or(ne.get("set")),a=null,l=Number(ne.get("rate"))||1,h=it.get("at:muted")!=="0",c=it.get("at:ambience")==="1";t.setMuted(h),t.setAmbienceEnabled(c);const u=new b1(i,{onPlayPause:()=>{if(!a)return;r();const C=a.state.t>=a.state.duration-1;if(e.mode==="live"&&C){v=!0,a.seek(Math.max(0,a.state.duration-1)),a.play();return}a.playing?a.pause():(C&&e.mode!=="live"&&a.seek(0),a.play())},onSeek:C=>{a&&e.mode==="live"&&(v=C>=a.state.duration-1500),a?.seek(C)},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),it.set("at:muted","0"),u.setMuted(!1)),u.nudgeSeen();return}h=!h,u.nudgeSeen(),t.setMuted(h),it.set("at:muted",h?"1":"0"),u.setMuted(h)},onAmbience:()=>{if(!t.ready||n){r(),c||(c=!0,t.setAmbienceEnabled(!0),it.set("at:ambience","1"),u.setAmbience(!0)),u.nudgeSeen();return}c=!c,u.nudgeSeen(),t.setAmbienceEnabled(c),it.set("at:ambience",c?"1":"0"),u.setAmbience(c)},onPickSet:C=>{o=or(C),a&&(it.set(`at:set:${a.world.repoId}`,C),w())},onGoLive:()=>{v=!0,a&&(a.seek(Math.max(0,a.state.duration-1)),a.play()),s()},onOverview:C=>{a?.setOverview(C),s()},onZoom:C=>{a?.zoomBy(C),s()},onExport:()=>{p()},onPrompt:async C=>{if(es)return es.postMessage({type:"prompt",text:C}),"sent — watch the stage";try{const M=await fetch(`${Os}/api/prompt`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({text:C})}),B=await M.json();return B.ok?"sent — watch the stage":`couldn't send: ${B.error??M.status}`}catch(M){return`couldn't send: ${String(M)}`}},onShuffle:()=>{const C=$o(g?.world.profile).filter(B=>B.id!==o.id),M=C.slice(0,Math.max(3,Math.min(5,C.length)));o=M[Math.floor(Math.random()*M.length)]??Pt[0],a&&(it.set(`at:set:${a.world.repoId}`,o.id),w()),u.showPicker(!1)}});u.setMuted(h),u.setAmbience(c),u.setRate(l),h&&c===!1&&!it.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 M=m.canvas.captureStream(30),B=t.captureStream();if(B)for(const q of B.getAudioTracks())M.addTrack(q);const R=[],O=["video/mp4;codecs=avc1.42E01E,mp4a.40.2","video/mp4","video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/webm"].find(q=>MediaRecorder.isTypeSupported(q))??"",U=O.startsWith("video/mp4")?"mp4":"webm";f=new MediaRecorder(M,O?{mimeType:O,videoBitsPerSecond:6e6}:void 0),f.ondataavailable=q=>{q.data.size&&R.push(q.data)},f.onstop=()=>{f=null,u.exportBtn.textContent="Export clip";const q=new Blob(R,{type:O.split(";")[0]||"video/webm"}),J=`agent-theatre-${(g?.repoId??"stage").split(/[/\\]/).pop()}-${new Date().toISOString().slice(0,19).replace(/[:T]/g,"-")}.${U}`,ie=`${a?.leadName??"The agent"} on the ${o.name} stage — ${(g?.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:q,name:J,caption:ie})},f.start(500),u.exportBtn.textContent="■ Stop & save",a&&!a.playing&&a.play()}const m=new _a;await m.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(m.canvas);let g=null;const _=(C,M)=>ob(C,Ti[(C.seed+Pt.findIndex(B=>B.id===M.id)*7)%Ti.length]);let y=0,x=!1,b="",v=!0;function w(){if(!g)return;a&&(y=a.state.t,x=a.playing,a.destroy()),m.renderer.background.color=o.sky[1];const C=_(g.world,o),M=C===g.world?g.beats:nr(g.events,C);a=new Qs(m,C,o,t,Zi,ne.get("cast")??it.get(`at:cast:${g.repoId}`)),globalThis.__agentTheatre={app:m,get player(){return a},panel:u},es?.postMessage({type:"ready",places:C.places.length}),u.leadName=a.leadName,u.hitTester=(B,R)=>a?.hitTest(B,R)??null,a.load(M),a.setRate(l),a.theme.id!==b?(a.seek(0),a.play()):(a.seek(y),x&&a.play()),b=a.theme.id,u.loadTimeline(M,g.events,C)}e.onReady(C=>{g=C;const M=it.get(`at:set:${C.repoId}`),B=ne.get("set")??M;u.profile=C.world.profile,u.repoId=C.repoId,B?o=or(B):o=$o(C.world.profile,C.world.seed)[0]??Pt[0],u.setTitle(C.repoId,ne.get("episode")??void 0),es?u.promptEnabled=!0:e.mode==="live"&&fetch(`${Os}/api/prompt`).then(U=>U.json()).then(U=>{u.promptEnabled=!!U.available}).catch(()=>{}),u.loadTimeline(C.beats,C.events,C.world),w();const R=Number(ne.get("t"));R>0&&a&&a.seek(R*1e3),e.mode==="live"&&a&&!ne.has("t")&&a.state.duration>1500&&a.seek(Math.max(0,a.state.duration-1200));const O=(async()=>{if(!ne.has("nopreview")){for(const U of Pt)try{u.previews.set(U.id,await S1(m,_(C.world,U),U))}catch(q){console.warn("set preview failed",U.id,q)}u.pickerOpen&&u.showPicker(!0,o.id),s()}})();!B&&!ne.has("t")&&O.then(()=>u.showPicker(!0,o.id)),ne.get("paused")!=="1"&&!Zi&&a?.play(),d&&a&&!Zi&&a.play(),Zi&&!ne.has("t")&&a?.seek(Math.min(a.state.duration,25400))}),e.onBeats((C,M)=>{if(!a||!g)return;if(g.beats.push(...C),g.events.push(...M),a.world===g.world)a.append(C);else{const R=nr(g.events,a.world);a.append(R.slice(a.beatCount))}const B=Math.max(...C.map(R=>R.atMs),0);v&&a.state.duration-a.state.t>1200&&B>a.state.t&&a.seek(B),u.loadTimeline(a.world===g.world?g.beats:nr(g.events,a.world),g.events,a.world),a.playing||a.play(),s()}),e.onSignal?.(C=>a?.setSignal(C));const T=Number(ne.get("step"))||0;let E=performance.now(),P=0,A=!1,k=null;const I=C=>{A=!1;const M=T||Math.min(50,C-E);if(E=C,a&&!document.hidden){if(e.mode==="live"&&a.playing&&v){const B=a.state.duration-a.state.t;B>6e3?a.state.rate!==4&&a.setRate(4):B<1500&&a.state.rate!==l&&a.setRate(l)}(d||ne.has("loop"))&&a.state.t>=a.state.duration-1&&a.state.duration>0&&(k||(k=setTimeout(()=>{k=null,a?.seek(0),a?.play()},600))),a.update(M),u.update(a.state,a.world,B=>a.worldLayer.lampOf(B)),a.playing?P=45:P--}(a?.playing||P>0)&&!document.hidden&&G()},G=()=>{A||(A=!0,requestAnimationFrame(I))};s=()=>{P=45,E=performance.now(),G()},s();for(const C of["pointerdown","keydown","resize"])addEventListener(C,s,{passive:!0});document.addEventListener("visibilitychange",()=>{document.hidden||s()});const F=Qs.prototype.play;Qs.prototype.play=function(){F.call(this),s()};const X=Qs.prototype.seek;Qs.prototype.seek=function(C){X.call(this,C),s()}}async function E1(i){const{Application:e}=await Et(async()=>{const{Application:l}=await Promise.resolve().then(()=>Px);return{Application:l}},void 0),{Pip:t}=await Et(async()=>{const{Pip:l}=await Promise.resolve().then(()=>Mb);return{Pip:l}},void 0),{castById:s,CAST:r}=await Et(async()=>{const{castById:l,CAST:h}=await Promise.resolve().then(()=>Sb);return{castById:l,CAST:h}},void 0),n=s(i)??r[0],o=or(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 Et(async()=>{const{Gremlin:c}=await Promise.resolve().then(()=>wb);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 Vn=document.getElementById("app"),P1=ne.has("portrait")?Promise.resolve(new fh({world:null,events:[],beats:[],repoId:""})):es&&(ne.has("live")||ne.get("session"))?Promise.resolve(new p1(es,ne.get("session"))):ne.has("live")?Promise.resolve(new f1(Os)):ne.get("session")?m1(ne.get("session"),Os):C1(ne.get("demo")??"episode-1");ne.has("portrait")?E1(ne.get("portrait")).catch(i=>{Vn.textContent=`Could not start: ${i}`}):P1.then(i=>k1(Vn,i)).catch(i=>{Vn.textContent=`Could not start: ${i}${Os?` (server: ${Os})`:""}`});export{R_ as A,_e as C,Vf as D,Xf as E,ay as F,B_ as a,ep as b,Yf as c,Jf as d,Y as e};
|
|
972
|
-
//# sourceMappingURL=index-
|
|
971
|
+
<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;liveBtn;tip;hitTester=null;fileStats=new Map;describeHit(e){if(e.kind==="lead")return`<b>${Ne(e.name)}</b> — the agent, your lead.<br><span>Mood: ${Ne(e.mood)}. The light on its head shows it.</span>`;if(e.kind==="helper")return`<b>${Ne(e.name)}</b> — a helper (subagent).<br><span>Arrived at the dock; working on its own task.</span>`;const t=e.place,s=this.fileStats.get(t.path),r=s?[s.reads?`read ${s.reads}×`:"",s.edits?`edited ${s.edits}× (+${s.added} −${s.removed})`:""].filter(Boolean).join(" · "):"";switch(t.kind){case"forge":return"<b>The forge</b> — shell work.<br><span>Commands that touch no particular file (installs, builds, git) happen here.</span>";case"dock":return"<b>The dock</b> — where helpers arrive.<br><span>Subagents row in here and fan out to their districts.</span>";case"beacon":return`<b>${Ne(t.label)}</b> — a test suite.<br><span>${Ne(t.path)}${s?.tests?` · last run: ${Ne(s.tests)}`:""}. Its lamp scans while tests run, goes red on failure, green on a pass.</span>`;case"archive":return`<b>${Ne(t.label)}</b> — docs / data.<br><span>${Ne(t.path)}${r?" · "+r:""}</span>`;case"overflow":return`<b>${Ne(t.label)}</b> — the rest of this folder.<br><span>Files below the relevance cap share this building; activity on them lands here.</span>`;default:return`<b>${Ne(t.label)}</b> — a file.<br><span>${Ne(t.path)} · size class ${t.height}/5${r?" · "+r:" · untouched this session"}</span>`}}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="";cwd="";elsewhere="";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.fileStats=new Map;const r=o=>{let a=this.fileStats.get(o);return a||(a={reads:0,edits:0,added:0,removed:0},this.fileStats.set(o,a)),a};for(const o of t)if(o.kind==="read_file")r(o.path).reads++;else if(o.kind==="edit_file"){const a=r(o.path);a.edits++,a.added+=o.added,a.removed+=o.removed}else if(o.kind==="write_file"){const a=r(o.path);a.edits++,a.added+=o.added}else if(o.kind==="test_result"){const a=o.failed?`${o.failed} failed, ${o.passed} passed`:`${o.passed} passed`;for(const l of s.places)l.kind==="beacon"&&(r(l.path).tests=a)}this.durationMs=e.length?Math.max(...e.map(o=>o.atMs+o.durationMs)):0,this.acts=_1(e),this.actsEl.innerHTML="",this.labelsEl.innerHTML="",this.actBtns=[],this.actLabels=[];for(const o of this.acts){const a=(o.toMs-o.fromMs)/Math.max(1,this.durationMs)*100,l=W("button");l.type="button",l.style.flex=`0 0 calc(${a}% - 3px)`,l.setAttribute("aria-label",`Jump to ${o.label}`),l.onclick=c=>{c.stopPropagation(),this.h.onSeek(o.fromMs+1)};const h=W("span","",o.label);h.style.flex=`0 0 calc(${a}% - 3px)`,this.actsEl.append(l),this.labelsEl.append(h),this.actBtns.push(l),this.actLabels.push(h)}this.logEl.innerHTML="",this.logBtns=[],t[0]?.ts;const n=o=>e.find(a=>a.sourceEventIds.includes(o));for(const o of t){if(o.kind==="session_start"||o.kind==="session_end")continue;const a=n(o.id);if(!a)continue;const l=W("li"),h=W("button");h.type="button";const[c,u]=v1(o),d=o.kind==="test_result"&&!o.ok;h.innerHTML=`<time>${Wn(a.atMs)}</time><span class="dot k-${o.kind}${d?" fail":""}"></span><span class="ev"><b>${Ne(c)}</b><code>${Ne(u)}</code></span>`,h.onclick=()=>this.h.onSeek(a.atMs+1),l.append(h),this.logEl.append(l),this.logBtns.push({btn:h,ms:a.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=$o(this.profile,w1(this.repoId)).slice(0,3),o=this.showAll?[...Pt]:n;this.picker.append(W("h3","",this.showAll?"All sets":"Choose your set"),W("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=W("div","setcards");for(const u of o){const d=W("button","setcard");d.type="button";const f=this.previews.get(u.id);d.innerHTML=`<div class="sw" style="--a:${$n(u.sky[0])};--b:${$n(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=W("div","toolbar"),h=W("button","btn ghost","Surprise me");h.type="button",h.onclick=()=>this.h.onShuffle();const c=W("button","btn ghost",this.showAll?"Suggested":`All ${Pt.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=`${Wn(e.t)} / ${Wn(e.duration)}`,this.head.style.left=`${e.t/Math.max(1,e.duration)*100}%`;const n=e.t>=e.duration-1;this.liveBtn.hidden=!(this.liveMode&&e.duration-e.t>1500),this.playBtn.innerHTML=this.liveMode&&n?'<i class="dot"></i><span>Live</span>':e.playing?`${xu}<span>Pause</span>`:`${y1}<span>${n?"Replay":"Play"}</span>`,this.playBtn.title=this.liveMode&&n?"You are watching the live edge; new events play as they arrive":"";const o=e.current;this.title.style.opacity=String(o&&o.kind==="curtain_up"?1-Math.min(1,Math.max(0,(e.t-o.atMs-600)/700)):e.t<600?1:0);const a=o&&o.kind==="curtain_down"?o:null;this.end.style.opacity=String(a?Math.min(1,Math.max(0,(e.t-a.atMs-400)/600)):0);const l=o?g1(o,t,r).replace(/\bPip\b/g,this.leadName):"";o&&o.id!==this.lastBeatId&&(this.lastBeatId=o.id,l&&(this.lastCaption=l));const h=this.caption.firstElementChild;h.textContent=this.lastCaption,h.style.opacity=this.lastCaption&&!(o?.kind==="curtain_up"&&e.t-(o?.atMs??0)<900)?"1":"0",e.evidence?(this.chip.hidden=!1,this.chip.className="chip ok",this.chip.innerHTML=`${x1}Evidence · ${e.evidence.passed} tests passed`):o?.kind==="unverified_claim"||o?.kind==="curtain_down"&&!o.verified?(this.chip.hidden=!1,this.chip.className="chip warn",this.chip.textContent="No test evidence"):this.chip.hidden=!0;const c=this.liveMode&&o?.kind==="your_turn"&&this.promptEnabled;if(this.prompt.hidden=!c,c&&o?.kind==="your_turn"){this.prompt.querySelector("input").placeholder=`${this.leadName||"The agent"} is done. What's next?`;const _=this.prompt.querySelector(".note");_.hidden=!o.note,_.textContent=o.note?`${this.leadName||"The agent"}: ${o.note}`:""}const u=this.liveMode&&o?.kind==="blocked_on_you";if(this.waiting.hidden=!u,u&&o?.kind==="blocked_on_you"){const _=o.reason==="permission"?"needs your permission to continue":"has a question for you";this.waiting.querySelector("b").textContent=`${this.leadName||"The agent"} ${_}.`,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!==o.id&&(this.notifiedFor=o.id,!this.vscode&&"Notification"in globalThis&&Notification.permission==="granted"&&new Notification("Agent Theatre",{body:`${this.leadName||"The agent"} ${_}.`}))}if(this.liveMode&&e.duration===0){const _=(this.repoId||"this folder").split(/[/\\]/).filter(Boolean).pop(),y=this.elsewhere&&this.elsewhere!==this.cwd?this.elsewhere.split(/[/\\]/).filter(Boolean).pop():"";this.caption.hidden=!1,this.caption.firstElementChild.textContent=y?`This stage watches ${_}, but Claude Code is working in ${y}. Start a stage there: cd ${this.elsewhere} && npx agent-theatre`:`Waiting for a Claude Code session in ${_}. 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 d=0;this.acts.forEach((_,y)=>{e.t>=_.fromMs&&(d=y)}),d!==this.lastAct&&(this.lastAct=d,this.actBtns.forEach((_,y)=>{_.classList.toggle("on",y<d),_.classList.toggle("now",y===d)}),this.actLabels.forEach((_,y)=>_.classList.toggle("now",y===d)));let f=-1;if(this.logBtns.forEach((_,y)=>{e.t>=_.ms&&(f=y)}),f!==this.lastEv){this.lastEv=f,this.logBtns.forEach((y,x)=>{y.btn.classList.toggle("done",x<f),y.btn.classList.toggle("now",x===f)});const _=this.logBtns[f]?.btn;_&&T1(_)}const m=this.stageEl.getBoundingClientRect().width<600,g=e.labels.filter(_=>_.active||!m).sort((_,y)=>_.screen.y-y.screen.y||_.screen.x-y.screen.x);for(let _=0;_<g.length;_++)for(let y=0;y<_;y++){const x=g[y],b=g[_];Math.abs(x.screen.x-b.screen.x)<76&&Math.abs(x.screen.y-b.screen.y)<20&&(b.screen={x:b.screen.x,y:x.screen.y-20})}for(;this.tagPool.length<g.length;){const _=W("div","tag");this.overlay.append(_),this.tagPool.push(_)}this.tagPool.forEach((_,y)=>{const x=g[y];if(!x){_.hidden=!0;return}_.hidden=!1,_.textContent=x.text;const b=t.places.find(w=>w.label===x.text)?.id??"",v=s(b);_.className=`tag${x.active?" active":""}${v!=="idle"?` lamp-${v}`:""}`,_.style.left=`${x.screen.x}px`,_.style.top=`${x.screen.y}px`}),e.bubble?(this.bubbleEl.hidden=!1,this.bubbleEl.textContent=e.bubble.text,this.bubbleEl.style.color=$n(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",o?.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 v1(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 w1=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 T1(i){let e=i.parentElement;for(;e&&!/(auto|scroll)/.test(getComputedStyle(e).overflowY);)e=e.parentElement;if(!e)return;const t=i.offsetTop-e.offsetTop,s=t+i.offsetHeight;t<e.scrollTop?e.scrollTo({top:t,behavior:"smooth"}):s>e.scrollTop+e.clientHeight&&e.scrollTo({top:s-e.clientHeight,behavior:"smooth"})}const Ne=i=>i.replace(/[&<>"]/g,e=>({"&":"&","<":"<",">":">",'"':"""})[e]??e);async function S1(i,e,t,s=360,r=200){const n=new Ig(e,t);n.update(0);const o=new _e,a=e.places.flatMap(m=>[Z(m.gx,m.gy),Z(m.gx+m.footprint,m.gy+m.footprint)]),l=a.map(m=>m.x),h=a.map(m=>m.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=Ci.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),Os=ne.get("base")??"",es=globalThis.acquireVsCodeApi?.()??null;globalThis.__vsapi=es;const Zi=matchMedia("(prefers-reduced-motion: reduce)").matches,it={get:i=>{try{return localStorage.getItem(i)}catch{return null}},set:(i,e)=>{try{localStorage.setItem(i,e)}catch{}}};async function M1(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 C1(i){const e=await M1(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}=Zx(t),r=hb(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=nb({repoId:o,files:n,touched:r.touched}),l=nr(s,a);return new fh({world:a,events:s,beats:l,repoId:o})}async function k1(i,e){const t=new cb;let s=()=>{};const r=async()=>{await t.arm(),t.ready&&a?.audioReady()};let n=!1;for(const M of["pointerdown","keydown"])addEventListener(M,()=>{t.ready||(n=!0,setTimeout(()=>{n=!1},700),r())},{passive:!0});let o=or(ne.get("set")),a=null,l=Number(ne.get("rate"))||1,h=it.get("at:muted")!=="0",c=it.get("at:ambience")==="1";t.setMuted(h),t.setAmbienceEnabled(c);const u=new b1(i,{onPlayPause:()=>{if(!a)return;r();const M=a.state.t>=a.state.duration-1;if(e.mode==="live"&&M){v=!0,a.seek(Math.max(0,a.state.duration-1)),a.play();return}a.playing?a.pause():(M&&e.mode!=="live"&&a.seek(0),a.play())},onSeek:M=>{a&&e.mode==="live"&&(v=M>=a.state.duration-1500),a?.seek(M)},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),it.set("at:muted","0"),u.setMuted(!1)),u.nudgeSeen();return}h=!h,u.nudgeSeen(),t.setMuted(h),it.set("at:muted",h?"1":"0"),u.setMuted(h)},onAmbience:()=>{if(!t.ready||n){r(),c||(c=!0,t.setAmbienceEnabled(!0),it.set("at:ambience","1"),u.setAmbience(!0)),u.nudgeSeen();return}c=!c,u.nudgeSeen(),t.setAmbienceEnabled(c),it.set("at:ambience",c?"1":"0"),u.setAmbience(c)},onPickSet:M=>{o=or(M),a&&(it.set(`at:set:${a.world.repoId}`,M),w())},onGoLive:()=>{v=!0,a&&(a.seek(Math.max(0,a.state.duration-1)),a.play()),s()},onOverview:M=>{a?.setOverview(M),s()},onZoom:M=>{a?.zoomBy(M),s()},onExport:()=>{p()},onPrompt:async M=>{if(es)return es.postMessage({type:"prompt",text:M}),"sent — watch the stage";try{const C=await fetch(`${Os}/api/prompt`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({text:M})}),B=await C.json();return B.ok?"sent — watch the stage":`couldn't send: ${B.error??C.status}`}catch(C){return`couldn't send: ${String(C)}`}},onShuffle:()=>{const M=$o(g?.world.profile).filter(B=>B.id!==o.id),C=M.slice(0,Math.max(3,Math.min(5,M.length)));o=C[Math.floor(Math.random()*C.length)]??Pt[0],a&&(it.set(`at:set:${a.world.repoId}`,o.id),w()),u.showPicker(!1)}});u.setMuted(h),u.setAmbience(c),u.setRate(l),h&&c===!1&&!it.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 C=m.canvas.captureStream(30),B=t.captureStream();if(B)for(const q of B.getAudioTracks())C.addTrack(q);const R=[],O=["video/mp4;codecs=avc1.42E01E,mp4a.40.2","video/mp4","video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/webm"].find(q=>MediaRecorder.isTypeSupported(q))??"",U=O.startsWith("video/mp4")?"mp4":"webm";f=new MediaRecorder(C,O?{mimeType:O,videoBitsPerSecond:6e6}:void 0),f.ondataavailable=q=>{q.data.size&&R.push(q.data)},f.onstop=()=>{f=null,u.exportBtn.textContent="Export clip";const q=new Blob(R,{type:O.split(";")[0]||"video/webm"}),J=`agent-theatre-${(g?.repoId??"stage").split(/[/\\]/).pop()}-${new Date().toISOString().slice(0,19).replace(/[:T]/g,"-")}.${U}`,ie=`${a?.leadName??"The agent"} on the ${o.name} stage — ${(g?.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:q,name:J,caption:ie})},f.start(500),u.exportBtn.textContent="■ Stop & save",a&&!a.playing&&a.play()}const m=new _a;await m.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(m.canvas);let g=null;const _=(M,C)=>ob(M,Ti[(M.seed+Pt.findIndex(B=>B.id===C.id)*7)%Ti.length]);let y=0,x=!1,b="",v=!0;function w(){if(!g)return;a&&(y=a.state.t,x=a.playing,a.destroy()),m.renderer.background.color=o.sky[1];const M=_(g.world,o),C=M===g.world?g.beats:nr(g.events,M);a=new Qs(m,M,o,t,Zi,ne.get("cast")??it.get(`at:cast:${g.repoId}`)),globalThis.__agentTheatre={app:m,get player(){return a},panel:u},es?.postMessage({type:"ready",places:M.places.length}),u.leadName=a.leadName,u.hitTester=(B,R)=>a?.hitTest(B,R)??null,a.load(C),a.setRate(l),a.theme.id!==b?(a.seek(0),a.play()):(a.seek(y),x&&a.play()),b=a.theme.id,u.loadTimeline(C,g.events,M)}e.onReady(M=>{g=M;const C=it.get(`at:set:${M.repoId}`),B=ne.get("set")??C;u.profile=M.world.profile,u.repoId=M.repoId,u.cwd=M.cwd??"",u.elsewhere=M.elsewhere??"",B?o=or(B):o=$o(M.world.profile,M.world.seed)[0]??Pt[0],u.setTitle(M.repoId,ne.get("episode")??void 0),es?u.promptEnabled=!0:e.mode==="live"&&fetch(`${Os}/api/prompt`).then(U=>U.json()).then(U=>{u.promptEnabled=!!U.available}).catch(()=>{}),u.loadTimeline(M.beats,M.events,M.world),w();const R=Number(ne.get("t"));R>0&&a&&a.seek(R*1e3),e.mode==="live"&&a&&!ne.has("t")&&a.state.duration>1500&&a.seek(Math.max(0,a.state.duration-1200));const O=(async()=>{if(!ne.has("nopreview")){for(const U of Pt)try{u.previews.set(U.id,await S1(m,_(M.world,U),U))}catch(q){console.warn("set preview failed",U.id,q)}u.pickerOpen&&u.showPicker(!0,o.id),s()}})();!B&&!ne.has("t")&&O.then(()=>u.showPicker(!0,o.id)),ne.get("paused")!=="1"&&!Zi&&a?.play(),d&&a&&!Zi&&a.play(),Zi&&!ne.has("t")&&a?.seek(Math.min(a.state.duration,25400))}),e.onBeats((M,C)=>{if(!a||!g)return;if(g.beats.push(...M),g.events.push(...C),a.world===g.world)a.append(M);else{const R=nr(g.events,a.world);a.append(R.slice(a.beatCount))}const B=Math.max(...M.map(R=>R.atMs),0);v&&a.state.duration-a.state.t>1200&&B>a.state.t&&a.seek(B),u.loadTimeline(a.world===g.world?g.beats:nr(g.events,a.world),g.events,a.world),a.playing||a.play(),s()}),e.onSignal?.(M=>a?.setSignal(M)),e.onElsewhere?.(M=>{u.elsewhere=M,s()});const T=Number(ne.get("step"))||0;let E=performance.now(),P=0,A=!1,k=null;const I=M=>{A=!1;const C=T||Math.min(50,M-E);if(E=M,a&&!document.hidden){if(e.mode==="live"&&a.playing&&v){const B=a.state.duration-a.state.t;B>6e3?a.state.rate!==4&&a.setRate(4):B<1500&&a.state.rate!==l&&a.setRate(l)}(d||ne.has("loop"))&&a.state.t>=a.state.duration-1&&a.state.duration>0&&(k||(k=setTimeout(()=>{k=null,a?.seek(0),a?.play()},600))),a.update(C),u.update(a.state,a.world,B=>a.worldLayer.lampOf(B)),a.playing?P=45:P--}(a?.playing||P>0)&&!document.hidden&&G()},G=()=>{A||(A=!0,requestAnimationFrame(I))};s=()=>{P=45,E=performance.now(),G()},s();for(const M of["pointerdown","keydown","resize"])addEventListener(M,s,{passive:!0});document.addEventListener("visibilitychange",()=>{document.hidden||s()});const F=Qs.prototype.play;Qs.prototype.play=function(){F.call(this),s()};const X=Qs.prototype.seek;Qs.prototype.seek=function(M){X.call(this,M),s()}}async function E1(i){const{Application:e}=await Et(async()=>{const{Application:l}=await Promise.resolve().then(()=>Px);return{Application:l}},void 0),{Pip:t}=await Et(async()=>{const{Pip:l}=await Promise.resolve().then(()=>Mb);return{Pip:l}},void 0),{castById:s,CAST:r}=await Et(async()=>{const{castById:l,CAST:h}=await Promise.resolve().then(()=>Sb);return{castById:l,CAST:h}},void 0),n=s(i)??r[0],o=or(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 Et(async()=>{const{Gremlin:c}=await Promise.resolve().then(()=>wb);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 Vn=document.getElementById("app"),P1=ne.has("portrait")?Promise.resolve(new fh({world:null,events:[],beats:[],repoId:""})):es&&(ne.has("live")||ne.get("session"))?Promise.resolve(new p1(es,ne.get("session"))):ne.has("live")?Promise.resolve(new f1(Os)):ne.get("session")?m1(ne.get("session"),Os):C1(ne.get("demo")??"episode-1");ne.has("portrait")?E1(ne.get("portrait")).catch(i=>{Vn.textContent=`Could not start: ${i}`}):P1.then(i=>k1(Vn,i)).catch(i=>{Vn.textContent=`Could not start: ${i}${Os?` (server: ${Os})`:""}`});export{R_ as A,_e as C,Vf as D,Xf as E,ay as F,B_ as a,ep as b,Yf as c,Jf as d,Y as e};
|
|
972
|
+
//# sourceMappingURL=index-HehktIj0.js.map
|