@ivoryheart/herdr-world 0.1.0 → 0.1.1
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/lib/bridges/linux-x64/herdr-world-bridge +0 -0
- package/lib/bridges/macos-arm64/herdr-world-bridge +0 -0
- package/lib/bridges/macos-x64/herdr-world-bridge +0 -0
- package/package.json +1 -1
- package/share/herdr-world/web/assets/GraphTheme-DdAfatoM.js +1 -0
- package/share/herdr-world/web/assets/{NoteMarkdownPreview-kY-nDOxM.js → NoteMarkdownPreview-Crh3odMO.js} +1 -1
- package/share/herdr-world/web/assets/WorldSurface-4GHZpnMP.js +369 -0
- package/share/herdr-world/web/assets/WorldThemeStage-Da7LFwo3.js +1 -0
- package/share/herdr-world/web/assets/browserAll-B258yZD2.js +1 -0
- package/share/herdr-world/web/assets/{ghostty-web-teHzIxkb.js → ghostty-web-CMdhZEut.js} +1 -1
- package/share/herdr-world/web/assets/index-B8V-qiZs.js +18 -0
- package/share/herdr-world/web/assets/index-DSq8fuVk.css +1 -0
- package/share/herdr-world/web/assets/init-BCuNUfJx.js +1 -0
- package/share/herdr-world/web/assets/jsx-runtime-BWRPWl8p.js +1 -0
- package/share/herdr-world/web/assets/{web-aFNZ0VSZ.js → web-Bev77txP.js} +1 -1
- package/share/herdr-world/web/assets/{web-DjpqhiRY.js → web-CCyAvF9M.js} +1 -1
- package/share/herdr-world/web/assets/webworkerAll-B5q9qlVj.js +1 -0
- package/share/herdr-world/web/index.html +3 -2
- package/share/herdr-world/web/assets/FederatedEventTarget-CkoT1sfc.js +0 -1
- package/share/herdr-world/web/assets/FilterSystem-Cc8XEqAi.js +0 -173
- package/share/herdr-world/web/assets/WebGLRenderer-CH0L4JQe.js +0 -1
- package/share/herdr-world/web/assets/WebGPURenderer-DLQebYcV.js +0 -1
- package/share/herdr-world/web/assets/WorldSurface-FBkCkOSB.js +0 -197
- package/share/herdr-world/web/assets/browserAll-B8-kqmYE.js +0 -1
- package/share/herdr-world/web/assets/index-Bkp5BPZN.js +0 -17
- package/share/herdr-world/web/assets/index-Cuh3insr.css +0 -1
- package/share/herdr-world/web/assets/init-DeL9YIMj.js +0 -1
- package/share/herdr-world/web/assets/webworkerAll-BFZtmp1G.js +0 -1
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/browserAll-B258yZD2.js","assets/localUniformBit-BnogyqF-.js","assets/chunk-QTnfLwEv.js","assets/init-BCuNUfJx.js","assets/webworkerAll-B5q9qlVj.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{n as e,r as t,t as n}from"./chunk-QTnfLwEv.js";import{n as r,t as i}from"./jsx-runtime-BWRPWl8p.js";import{A as a,E as o,N as s,O as c,P as l,_ as u,a as d,c as f,d as p,f as m,g as h,i as g,k as _,l as v,m as y,n as b,o as x,p as S,r as C,s as w,t as T,u as E,w as D,x as O}from"./index-B8V-qiZs.js";import{$ as k,A,B as j,C as M,D as N,E as P,F,G as I,H as L,I as ee,J as te,K as ne,L as R,M as re,N as ie,O as ae,P as oe,Q as se,S as ce,T as le,U as z,V as ue,W as de,X as fe,Y as B,Z as pe,_ as me,a as he,at as V,b as ge,c as _e,ct as H,d as ve,dt as ye,et as be,f as xe,ft as U,g as Se,h as Ce,i as we,it as W,j as Te,k as Ee,l as De,lt as Oe,n as ke,nt as Ae,o as je,ot as Me,p as Ne,pt as Pe,q as Fe,r as Ie,rt as G,s as Le,st as Re,t as ze,u as Be,ut as K,v as Ve,w as He,x as Ue,y as We,z as Ge}from"./localUniformBit-BnogyqF-.js";import{n as Ke,t as qe}from"./CanvasPool-C4EP4giG.js";import{t as Je}from"./getBatchSamplersUniformGroup-D-hqfegN.js";import{a as Ye,c as Xe,d as Ze,f as Qe,g as $e,h as et,i as tt,l as nt,m as rt,n as it,o as at,p as ot,r as st,s as ct,t as lt,u as ut}from"./BufferResource-TmONtVkO.js";var dt=l(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),q=t(r(),1),ft=class e{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=e.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new Oe,this.page=new Oe,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=t}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,n){throw Error(`initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.`)}initUIEvent(e,t,n,r,i){throw 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}},pt=/iPhone/i,mt=/iPod/i,ht=/iPad/i,gt=/\biOS-universal(?:.+)Mac\b/i,_t=/\bAndroid(?:.+)Mobile\b/i,vt=/Android/i,yt=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,bt=/Silk/i,xt=/Windows Phone/i,St=/\bWindows(?:.+)ARM\b/i,Ct=/BlackBerry/i,wt=/BB10/i,Tt=/Opera Mini/i,Et=/\b(CriOS|Chrome)(?:.+)Mobile/i,Dt=/Mobile(?:.+)Firefox\b/i,Ot=function(e){return e!==void 0&&e.platform===`MacIntel`&&typeof e.maxTouchPoints==`number`&&e.maxTouchPoints>1&&typeof MSStream>`u`};function kt(e){return function(t){return t.test(e)}}function At(e){var t={userAgent:``,platform:``,maxTouchPoints:0};!e&&typeof navigator<`u`?t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof e==`string`?t.userAgent=e:e&&e.userAgent&&(t={userAgent:e.userAgent,platform:e.platform,maxTouchPoints:e.maxTouchPoints||0});var n=t.userAgent,r=n.split(`[FBAN`);r[1]!==void 0&&(n=r[0]),r=n.split(`Twitter`),r[1]!==void 0&&(n=r[0]);var i=kt(n),a={apple:{phone:i(pt)&&!i(xt),ipod:i(mt),tablet:!i(pt)&&(i(ht)||Ot(t))&&!i(xt),universal:i(gt),device:(i(pt)||i(mt)||i(ht)||i(gt)||Ot(t))&&!i(xt)},amazon:{phone:i(yt),tablet:!i(yt)&&i(bt),device:i(yt)||i(bt)},android:{phone:!i(xt)&&i(yt)||!i(xt)&&i(_t),tablet:!i(xt)&&!i(yt)&&!i(_t)&&(i(bt)||i(vt)),device:!i(xt)&&(i(yt)||i(bt)||i(_t)||i(vt))||i(/\bokhttp\b/i)},windows:{phone:i(xt),tablet:i(St),device:i(xt)||i(St)},other:{blackberry:i(Ct),blackberry10:i(wt),opera:i(Tt),firefox:i(Dt),chrome:i(Et),device:i(Ct)||i(wt)||i(Tt)||i(Dt)||i(Et)},any:!1,phone:!1,tablet:!1};return a.any=a.apple.device||a.android.device||a.windows.device||a.other.device,a.phone=a.apple.phone||a.android.phone||a.windows.phone,a.tablet=a.apple.tablet||a.android.tablet||a.windows.tablet,a}var jt=(At.default??At)(globalThis.navigator),Mt=9,Nt=100,Pt=0,Ft=0,It=2,Lt=1,Rt=-1e3,zt=-1e3,Bt=2,Vt=class{constructor(e,t=jt){this._mobileInfo=t,this.debug=!1,this._isActive=!1,this._isMobileAccessibility=!1,this._pool=[],this._renderId=0,this._children=[],this._androidUpdateCount=0,this._androidUpdateFrequency=500,this._hookDiv=null,(t.tablet||t.phone)&&this._createTouchHook();let n=document.createElement(`div`);n.style.width=`${Nt}px`,n.style.height=`${Nt}px`,n.style.position=`absolute`,n.style.top=`${Pt}px`,n.style.left=`${Ft}px`,n.style.zIndex=It.toString(),this._div=n,this._renderer=e,this._onKeyDown=this._onKeyDown.bind(this),this._onMouseMove=this._onMouseMove.bind(this),globalThis.addEventListener(`keydown`,this._onKeyDown,!1)}get isActive(){return this._isActive}get isMobileAccessibility(){return this._isMobileAccessibility}get hookDiv(){return this._hookDiv}_createTouchHook(){let e=document.createElement(`button`);e.style.width=`${Lt}px`,e.style.height=`${Lt}px`,e.style.position=`absolute`,e.style.top=`${Rt}px`,e.style.left=`${zt}px`,e.style.zIndex=Bt.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),null)}_activate(){this._isActive||(this._isActive=!0,globalThis.document.addEventListener(`mousemove`,this._onMouseMove,!0),globalThis.removeEventListener(`keydown`,this._onKeyDown,!1),this._renderer.runners.postrender.add(this),this._renderer.view.canvas.parentNode?.appendChild(this._div))}_deactivate(){!this._isActive||this._isMobileAccessibility||(this._isActive=!1,globalThis.document.removeEventListener(`mousemove`,this._onMouseMove,!0),globalThis.addEventListener(`keydown`,this._onKeyDown,!1),this._renderer.runners.postrender.remove(this),this._div.parentNode?.removeChild(this._div))}_updateAccessibleObjects(e){if(!e.visible||!e.accessibleChildren)return;e.accessible&&e.isInteractive()&&(e._accessibleActive||this._addChild(e),e._renderId=this._renderId);let t=e.children;if(t)for(let e=0;e<t.length;e++)this._updateAccessibleObjects(t[e])}init(e){this.debug=e?.debug??this.debug,this._renderer.runners.postrender.remove(this)}postrender(){let e=performance.now();if(this._mobileInfo.android.device&&e<this._androidUpdateCount||(this._androidUpdateCount=e+this._androidUpdateFrequency,!this._renderer.renderingToScreen||!this._renderer.view.canvas))return;this._renderer.lastObjectRendered&&this._updateAccessibleObjects(this._renderer.lastObjectRendered);let{x:t,y:n,width:r,height:i}=this._renderer.view.canvas.getBoundingClientRect(),{width:a,height:o,resolution:s}=this._renderer,c=r/a*s,l=i/o*s,u=this._div;u.style.left=`${t}px`,u.style.top=`${n}px`,u.style.width=`${a}px`,u.style.height=`${o}px`;for(let e=0;e<this._children.length;e++){let t=this._children[e];if(t._renderId!==this._renderId)t._accessibleActive=!1,Ae(this._children,e,1),this._div.removeChild(t._accessibleDiv),this._pool.push(t._accessibleDiv),t._accessibleDiv=null,e--;else{u=t._accessibleDiv;let e=t.hitArea,n=t.worldTransform;t.hitArea?(u.style.left=`${(n.tx+e.x*n.a)*c}px`,u.style.top=`${(n.ty+e.y*n.d)*l}px`,u.style.width=`${e.width*n.a*c}px`,u.style.height=`${e.height*n.d*l}px`):(e=t.getBounds().rectangle,this._capHitArea(e),u.style.left=`${e.x*c}px`,u.style.top=`${e.y*l}px`,u.style.width=`${e.width*c}px`,u.style.height=`${e.height*l}px`,u.title!==t.accessibleTitle&&t.accessibleTitle!==null&&(u.title=t.accessibleTitle||``),u.getAttribute(`aria-label`)!==t.accessibleHint&&t.accessibleHint!==null&&u.setAttribute(`aria-label`,t.accessibleHint||``)),(t.accessibleTitle!==u.title||t.tabIndex!==u.tabIndex)&&(u.title=t.accessibleTitle||``,u.tabIndex=t.tabIndex,this.debug&&this._updateDebugHTML(u))}}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);let{width:t,height:n}=this._renderer;e.x+e.width>t&&(e.width=t-e.x),e.y+e.height>n&&(e.height=n-e.y)}_addChild(e){let t=this._pool.pop();t||(t=document.createElement(`button`),t.style.width=`${Nt}px`,t.style.height=`${Nt}px`,t.style.backgroundColor=this.debug?`rgba(255,255,255,0.5)`:`transparent`,t.style.position=`absolute`,t.style.zIndex=It.toString(),t.style.borderStyle=`none`,navigator.userAgent.toLowerCase().includes(`chrome`)?t.setAttribute(`aria-live`,`off`):t.setAttribute(`aria-live`,`polite`),navigator.userAgent.match(/rv:.*Gecko\//)?t.setAttribute(`aria-relevant`,`additions`):t.setAttribute(`aria-relevant`,`text`),t.addEventListener(`click`,this._onClick.bind(this)),t.addEventListener(`focus`,this._onFocus.bind(this)),t.addEventListener(`focusout`,this._onFocusOut.bind(this))),t.style.pointerEvents=e.accessiblePointerEvents,t.type=e.accessibleType,e.accessibleTitle&&e.accessibleTitle!==null?t.title=e.accessibleTitle:(!e.accessibleHint||e.accessibleHint===null)&&(t.title=`container ${e.tabIndex}`),e.accessibleHint&&e.accessibleHint!==null&&t.setAttribute(`aria-label`,e.accessibleHint),this.debug&&this._updateDebugHTML(t),e._accessibleActive=!0,e._accessibleDiv=t,t.container=e,this._children.push(e),this._div.appendChild(e._accessibleDiv),e._accessibleDiv.tabIndex=e.tabIndex}_dispatchEvent(e,t){let{container:n}=e.target,r=this._renderer.events.rootBoundary,i=Object.assign(new ft(r),{target:n});r.rootTarget=this._renderer.lastObjectRendered,t.forEach(e=>r.dispatchEvent(i,e))}_onClick(e){this._dispatchEvent(e,[`click`,`pointertap`,`tap`])}_onFocus(e){e.target.getAttribute(`aria-live`)||e.target.setAttribute(`aria-live`,`assertive`),this._dispatchEvent(e,[`mouseover`])}_onFocusOut(e){e.target.getAttribute(`aria-live`)||e.target.setAttribute(`aria-live`,`polite`),this._dispatchEvent(e,[`mouseout`])}_onKeyDown(e){e.keyCode===Mt&&this._activate()}_onMouseMove(e){e.movementX===0&&e.movementY===0||this._deactivate()}destroy(){this._destroyTouchHook(),this._div=null,globalThis.document.removeEventListener(`mousemove`,this._onMouseMove,!0),globalThis.removeEventListener(`keydown`,this._onKeyDown),this._pool=null,this._children=null,this._renderer=null}};Vt.extension={type:[U.WebGLSystem,U.WebGPUSystem],name:`accessibility`};var Ht={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,_accessibleActive:!1,_accessibleDiv:null,accessibleType:`button`,accessiblePointerEvents:`auto`,accessibleChildren:!0,_renderId:-1},Ut=class{static init(e){Object.defineProperty(this,"resizeTo",{set(e){globalThis.removeEventListener(`resize`,this.queueResize),this._resizeTo=e,e&&(globalThis.addEventListener(`resize`,this.queueResize),this.resize())},get(){return this._resizeTo}}),this.queueResize=()=>{this._resizeTo&&(this._cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize()))},this._cancelResize=()=>{this._resizeId&&=(cancelAnimationFrame(this._resizeId),null)},this.resize=()=>{if(!this._resizeTo)return;this._cancelResize();let e,t;if(this._resizeTo===globalThis.window)e=globalThis.innerWidth,t=globalThis.innerHeight;else{let{clientWidth:n,clientHeight:r}=this._resizeTo;e=n,t=r}this.renderer.resize(e,t),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=e.resizeTo||null}static destroy(){globalThis.removeEventListener(`resize`,this.queueResize),this._cancelResize(),this._cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}};Ut.extension=U.Application;var Wt=class{static init(e){e=Object.assign({autoStart:!0,sharedTicker:!1},e),Object.defineProperty(this,"ticker",{set(e){this._ticker&&this._ticker.remove(this.render,this),this._ticker=e,e&&e.add(this.render,this,I.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=e.sharedTicker?de.shared:new de,e.autoStart&&this.start()}static destroy(){if(this._ticker){let e=this._ticker;this.ticker=null,e.destroy()}}};Wt.extension=U.Application;var Gt=new class{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||(de.system.add(this._tickerUpdate,this,I.INTERACTION),this._tickerAdded=!0)}removeTickerListener(){this._tickerAdded&&=(de.system.remove(this._tickerUpdate,this),!1)}pointerMoved(){this._didMove=!0}_update(){if(!this.domElement||this._pauseUpdate)return;if(this._didMove){this._didMove=!1;return}let e=this.events._rootPointerEvent;this.events.supportsTouchEvents&&e.pointerType===`touch`||globalThis.document.dispatchEvent(new PointerEvent(`pointermove`,{clientX:e.clientX,clientY:e.clientY,pointerType:e.pointerType,pointerId:e.pointerId}))}_tickerUpdate(e){this._deltaTime+=e.deltaTime,!(this._deltaTime<this.interactionFrequency)&&(this._deltaTime=0,this._update())}},Kt=class extends ft{constructor(){super(...arguments),this.client=new Oe,this.movement=new Oe,this.offset=new Oe,this.global=new Oe,this.screen=new Oe}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,n){return e.worldTransform.applyInverse(n||this.global,t)}getModifierState(e){return`getModifierState`in this.nativeEvent&&this.nativeEvent.getModifierState(e)}initMouseEvent(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m){throw Error(`Method not implemented.`)}},qt=class extends Kt{constructor(){super(...arguments),this.width=0,this.height=0,this.isPrimary=!1}getCoalescedEvents(){return this.type===`pointermove`||this.type===`mousemove`||this.type===`touchmove`?[this]:[]}getPredictedEvents(){throw Error(`getPredictedEvents is not supported!`)}},Jt=class extends Kt{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}};Jt.DOM_DELTA_PIXEL=0,Jt.DOM_DELTA_LINE=1,Jt.DOM_DELTA_PAGE=2;var Yt=2048,Xt=new Oe,Zt=new Oe,Qt=class{constructor(e){this.dispatch=new ye,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.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)}addEventMapping(e,t){this.mappingTable[e]||(this.mappingTable[e]=[]),this.mappingTable[e].push({fn:t,priority:0}),this.mappingTable[e].sort((e,t)=>e.priority-t.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;let t=this.mappingTable[e.type];if(t)for(let n=0,r=t.length;n<r;n++)t[n].fn(e);else B(`[EventBoundary]: Event mapping not defined for ${e.type}`)}hitTest(e,t){Gt.pauseUpdate=!0;let n=this._isPointerMoveEvent&&this.enableGlobalMoveEvents?`hitTestMoveRecursive`:`hitTestRecursive`,r=this[n](this.rootTarget,this.rootTarget.eventMode,Xt.set(e,t),this.hitTestFn,this.hitPruneFn);return r&&r[0]}propagate(e,t){if(!e.target)return;let n=e.composedPath();e.eventPhase=e.CAPTURING_PHASE;for(let r=0,i=n.length-1;r<i;r++)if(e.currentTarget=n[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=n.length-2;r>=0;r--)if(e.currentTarget=n[r],this.notifyTarget(e,t),e.propagationStopped||e.propagationImmediatelyStopped)return}}all(e,t,n=this._allInteractiveElements){if(n.length===0)return;e.eventPhase=e.BUBBLING_PHASE;let r=Array.isArray(t)?t:[t];for(let t=n.length-1;t>=0;t--)r.forEach(r=>{e.currentTarget=n[t],this.notifyTarget(e,r)})}propagationPath(e){let t=[e];for(let n=0;n<Yt&&e!==this.rootTarget&&e.parent;n++){if(!e.parent)throw Error(`Cannot find propagation path to disconnected target`);t.push(e.parent),e=e.parent}return t.reverse(),t}hitTestMoveRecursive(e,t,n,r,i,a=!1){let o=!1;if(this._interactivePrune(e))return null;if((e.eventMode===`dynamic`||t===`dynamic`)&&(Gt.pauseUpdate=!1),e.interactiveChildren&&e.children){let s=e.children;for(let c=s.length-1;c>=0;c--){let l=s[c],u=this.hitTestMoveRecursive(l,this._isInteractive(t)?t:l.eventMode,n,r,i,a||i(e,n));if(u){if(u.length>0&&!u[u.length-1].parent)continue;let t=e.isInteractive();(u.length>0||t)&&(t&&this._allInteractiveElements.push(e),u.push(e)),this._hitElements.length===0&&(this._hitElements=u),o=!0}}}let s=this._isInteractive(t),c=e.isInteractive();return c&&c&&this._allInteractiveElements.push(e),a||this._hitElements.length>0?null:o?this._hitElements:s&&!i(e,n)&&r(e,n)?c?[e]:[]:null}hitTestRecursive(e,t,n,r,i){if(this._interactivePrune(e)||i(e,n))return null;if((e.eventMode===`dynamic`||t===`dynamic`)&&(Gt.pauseUpdate=!1),e.interactiveChildren&&e.children){let a=e.children,o=n;for(let n=a.length-1;n>=0;n--){let s=a[n],c=this.hitTestRecursive(s,this._isInteractive(t)?t:s.eventMode,o,r,i);if(c){if(c.length>0&&!c[c.length-1].parent)continue;let t=e.isInteractive();return(c.length>0||t)&&c.push(e),c}}}let a=this._isInteractive(t),o=e.isInteractive();return a&&r(e,n)?o?[e]:[]:null}_isInteractive(e){return e===`static`||e===`dynamic`}_interactivePrune(e){return!e||!e.visible||!e.renderable||!e.includeInBuild||!e.measurable||e.eventMode===`none`||e.eventMode===`passive`&&!e.interactiveChildren}hitPruneFn(e,t){if(e.hitArea&&(e.worldTransform.applyInverse(t,Zt),!e.hitArea.contains(Zt.x,Zt.y)))return!0;if(e.effects&&e.effects.length)for(let n=0;n<e.effects.length;n++){let r=e.effects[n];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,Zt),e.containsPoint(Zt)):!1}notifyTarget(e,t){if(!e.currentTarget.isInteractive())return;t??=e.type;let n=`on${t}`;e.currentTarget[n]?.(e);let 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 qt)){B(`EventBoundary cannot map a non-pointer event as a pointer event`);return}let t=this.createPointerEvent(e);if(this.dispatchEvent(t,`pointerdown`),t.pointerType===`touch`)this.dispatchEvent(t,`touchstart`);else if(t.pointerType===`mouse`||t.pointerType===`pen`){let e=t.button===2;this.dispatchEvent(t,e?`rightdown`:`mousedown`)}let n=this.trackingData(e.pointerId);n.pressTargetsByButton[e.button]=t.composedPath(),this.freeEvent(t)}mapPointerMove(e){if(!(e instanceof qt)){B(`EventBoundary cannot map a non-pointer event as a pointer event`);return}this._allInteractiveElements.length=0,this._hitElements.length=0,this._isPointerMoveEvent=!0;let t=this.createPointerEvent(e);this._isPointerMoveEvent=!1;let n=t.pointerType===`mouse`||t.pointerType===`pen`,r=this.trackingData(e.pointerId),i=this.findMountedTarget(r.overTargets);if(r.overTargets?.length>0&&i!==t.target){let r=e.type===`mousemove`?`mouseout`:`pointerout`,a=this.createPointerEvent(e,r,i);if(this.dispatchEvent(a,`pointerout`),n&&this.dispatchEvent(a,`mouseout`),!t.composedPath().includes(i)){let r=this.createPointerEvent(e,`pointerleave`,i);for(r.eventPhase=r.AT_TARGET;r.target&&!t.composedPath().includes(r.target);)r.currentTarget=r.target,this.notifyTarget(r),n&&this.notifyTarget(r,`mouseleave`),r.target=r.target.parent;this.freeEvent(r)}this.freeEvent(a)}if(i!==t.target){let r=e.type===`mousemove`?`mouseover`:`pointerover`,a=this.clonePointerEvent(t,r);this.dispatchEvent(a,`pointerover`),n&&this.dispatchEvent(a,`mouseover`);let o=i?.parent;for(;o&&o!==this.rootTarget.parent&&o!==t.target;)o=o.parent;if(!o||o===this.rootTarget.parent){let e=this.clonePointerEvent(t,`pointerenter`);for(e.eventPhase=e.AT_TARGET;e.target&&e.target!==i&&e.target!==this.rootTarget.parent;)e.currentTarget=e.target,this.notifyTarget(e),n&&this.notifyTarget(e,`mouseenter`),e.target=e.target.parent;this.freeEvent(e)}this.freeEvent(a)}let a=[],o=this.enableGlobalMoveEvents??!0;this.moveOnAll?a.push(`pointermove`):this.dispatchEvent(t,`pointermove`),o&&a.push(`globalpointermove`),t.pointerType===`touch`&&(this.moveOnAll?a.splice(1,0,`touchmove`):this.dispatchEvent(t,`touchmove`),o&&a.push(`globaltouchmove`)),n&&(this.moveOnAll?a.splice(1,0,`mousemove`):this.dispatchEvent(t,`mousemove`),o&&a.push(`globalmousemove`),this.cursor=t.target?.cursor),a.length>0&&this.all(t,a),this._allInteractiveElements.length=0,this._hitElements.length=0,r.overTargets=t.composedPath(),this.freeEvent(t)}mapPointerOver(e){if(!(e instanceof qt)){B(`EventBoundary cannot map a non-pointer event as a pointer event`);return}let t=this.trackingData(e.pointerId),n=this.createPointerEvent(e),r=n.pointerType===`mouse`||n.pointerType===`pen`;this.dispatchEvent(n,`pointerover`),r&&this.dispatchEvent(n,`mouseover`),n.pointerType===`mouse`&&(this.cursor=n.target?.cursor);let i=this.clonePointerEvent(n,`pointerenter`);for(i.eventPhase=i.AT_TARGET;i.target&&i.target!==this.rootTarget.parent;)i.currentTarget=i.target,this.notifyTarget(i),r&&this.notifyTarget(i,`mouseenter`),i.target=i.target.parent;t.overTargets=n.composedPath(),this.freeEvent(n),this.freeEvent(i)}mapPointerOut(e){if(!(e instanceof qt)){B(`EventBoundary cannot map a non-pointer event as a pointer event`);return}let t=this.trackingData(e.pointerId);if(t.overTargets){let n=e.pointerType===`mouse`||e.pointerType===`pen`,r=this.findMountedTarget(t.overTargets),i=this.createPointerEvent(e,`pointerout`,r);this.dispatchEvent(i),n&&this.dispatchEvent(i,`mouseout`);let a=this.createPointerEvent(e,`pointerleave`,r);for(a.eventPhase=a.AT_TARGET;a.target&&a.target!==this.rootTarget.parent;)a.currentTarget=a.target,this.notifyTarget(a),n&&this.notifyTarget(a,`mouseleave`),a.target=a.target.parent;t.overTargets=null,this.freeEvent(i),this.freeEvent(a)}this.cursor=null}mapPointerUp(e){if(!(e instanceof qt)){B(`EventBoundary cannot map a non-pointer event as a pointer event`);return}let t=performance.now(),n=this.createPointerEvent(e);if(this.dispatchEvent(n,`pointerup`),n.pointerType===`touch`)this.dispatchEvent(n,`touchend`);else if(n.pointerType===`mouse`||n.pointerType===`pen`){let e=n.button===2;this.dispatchEvent(n,e?`rightup`:`mouseup`)}let r=this.trackingData(e.pointerId),i=this.findMountedTarget(r.pressTargetsByButton[e.button]),a=i;if(i&&!n.composedPath().includes(i)){let t=i;for(;t&&!n.composedPath().includes(t);){if(n.currentTarget=t,this.notifyTarget(n,`pointerupoutside`),n.pointerType===`touch`)this.notifyTarget(n,`touchendoutside`);else if(n.pointerType===`mouse`||n.pointerType===`pen`){let e=n.button===2;this.notifyTarget(n,e?`rightupoutside`:`mouseupoutside`)}t=t.parent}delete r.pressTargetsByButton[e.button],a=t}if(a){let i=this.clonePointerEvent(n,`click`);i.target=a,i.path=null,r.clicksByButton[e.button]||(r.clicksByButton[e.button]={clickCount:0,target:i.target,timeStamp:t});let o=r.clicksByButton[e.button];if(o.target===i.target&&t-o.timeStamp<200?++o.clickCount:o.clickCount=1,o.target=i.target,o.timeStamp=t,i.detail=o.clickCount,i.pointerType===`mouse`){let e=i.button===2;this.dispatchEvent(i,e?`rightclick`:`click`)}else i.pointerType===`touch`&&this.dispatchEvent(i,`tap`);this.dispatchEvent(i,`pointertap`),this.freeEvent(i)}this.freeEvent(n)}mapPointerUpOutside(e){if(!(e instanceof qt)){B(`EventBoundary cannot map a non-pointer event as a pointer event`);return}let t=this.trackingData(e.pointerId),n=this.findMountedTarget(t.pressTargetsByButton[e.button]),r=this.createPointerEvent(e);if(n){let i=n;for(;i;)r.currentTarget=i,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`),i=i.parent;delete t.pressTargetsByButton[e.button]}this.freeEvent(r)}mapWheel(e){if(!(e instanceof Jt)){B(`EventBoundary cannot map a non-wheel event as a wheel event`);return}let t=this.createWheelEvent(e);this.dispatchEvent(t),this.freeEvent(t)}findMountedTarget(e){if(!e)return null;let t=e[0];for(let n=1;n<e.length&&e[n].parent===t;n++)t=e[n];return t}createPointerEvent(e,t,n){let r=this.allocateEvent(qt);return this.copyPointerData(e,r),this.copyMouseData(e,r),this.copyData(e,r),r.nativeEvent=e.nativeEvent,r.originalEvent=e,r.target=n??this.hitTest(r.global.x,r.global.y)??this._hitElements[0],typeof t==`string`&&(r.type=t),r}createWheelEvent(e){let t=this.allocateEvent(Jt);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){let n=this.allocateEvent(qt);return n.nativeEvent=e.nativeEvent,n.originalEvent=e.originalEvent,this.copyPointerData(e,n),this.copyMouseData(e,n),this.copyData(e,n),n.target=e.target,n.path=e.composedPath().slice(),n.type=t??n.type,n}copyWheelData(e,t){t.deltaMode=e.deltaMode,t.deltaX=e.deltaX,t.deltaY=e.deltaY,t.deltaZ=e.deltaZ}copyPointerData(e,t){e instanceof qt&&t instanceof qt&&(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)}copyMouseData(e,t){e instanceof Kt&&t instanceof Kt&&(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,[]);let t=this.eventPool.get(e).pop()||new e(this);return t.eventPhase=t.NONE,t.currentTarget=null,t.path=null,t.target=null,t}freeEvent(e){if(e.manager!==this)throw Error(`It is illegal to free an event not managed by this EventBoundary!`);let t=e.constructor;this.eventPool.has(t)||this.eventPool.set(t,[]),this.eventPool.get(t).push(e)}_notifyListeners(e,t){let n=e.currentTarget._events[t];if(n)if(`fn`in n)n.once&&e.currentTarget.removeListener(t,n.fn,void 0,!0),n.fn.call(n.context,e);else for(let r=0,i=n.length;r<i&&!e.propagationImmediatelyStopped;r++)n[r].once&&e.currentTarget.removeListener(t,n[r].fn,void 0,!0),n[r].fn.call(n[r].context,e)}},$t=1,en={touchstart:`pointerdown`,touchend:`pointerup`,touchendoutside:`pointerupoutside`,touchmove:`pointermove`,touchcancel:`pointercancel`},tn=class e{constructor(t){this.supportsTouchEvents=`ontouchstart`in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new Qt(null),Gt.init(this),this.autoPreventDefault=!0,this._eventsAdded=!1,this._rootPointerEvent=new qt(null),this._rootWheelEvent=new Jt(null),this.cursorStyles={default:`inherit`,pointer:`pointer`},this.features=new Proxy({...e.defaultEventFeatures},{set:(e,t,n)=>(t===`globalMove`&&(this.rootBoundary.enableGlobalMoveEvents=n),e[t]=n,!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.onWheel=this.onWheel.bind(this)}static get defaultEventMode(){return this._defaultEventMode}init(t){let{canvas:n,resolution:r}=this.renderer;this.setTargetElement(n),this.resolution=r,e._defaultEventMode=t.eventMode??`passive`,Object.assign(this.features,t.eventFeatures??{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(e){this.resolution=e}destroy(){this.setTargetElement(null),this.renderer=null,this._currentCursor=null}setCursor(e){e||=`default`;let t=!0;if(globalThis.OffscreenCanvas&&this.domElement instanceof OffscreenCanvas&&(t=!1),this._currentCursor===e)return;this._currentCursor=e;let n=this.cursorStyles[e];if(n)switch(typeof n){case`string`:t&&(this.domElement.style.cursor=n);break;case`function`:n(e);break;case`object`:t&&Object.assign(this.domElement.style,n);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;let t=this._normalizeToPointerData(e);this.autoPreventDefault&&t[0].isNormalized&&(e.cancelable||!(`cancelable`in e))&&e.preventDefault();for(let e=0,n=t.length;e<n;e++){let n=t[e],r=this._bootstrapEvent(this._rootPointerEvent,n);this.rootBoundary.mapEvent(r)}this.setCursor(this.rootBoundary.cursor)}_onPointerMove(e){if(!this.features.move)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,Gt.pointerMoved();let t=this._normalizeToPointerData(e);for(let e=0,n=t.length;e<n;e++){let n=this._bootstrapEvent(this._rootPointerEvent,t[e]);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]);let n=t===this.domElement?``:`outside`,r=this._normalizeToPointerData(e);for(let e=0,t=r.length;e<t;e++){let t=this._bootstrapEvent(this._rootPointerEvent,r[e]);t.type+=n,this.rootBoundary.mapEvent(t)}this.setCursor(this.rootBoundary.cursor)}_onPointerOverOut(e){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;let t=this._normalizeToPointerData(e);for(let e=0,n=t.length;e<n;e++){let n=this._bootstrapEvent(this._rootPointerEvent,t[e]);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}onWheel(e){if(!this.features.wheel)return;let t=this.normalizeWheelEvent(e);this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.rootBoundary.mapEvent(t)}setTargetElement(e){this._removeEvents(),this.domElement=e,Gt.domElement=e,this._addEvents()}_addEvents(){if(this._eventsAdded||!this.domElement)return;Gt.addTickerListener();let 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._eventsAdded=!0}_removeEvents(){if(!this._eventsAdded||!this.domElement)return;Gt.removeTickerListener();let 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=null,this._eventsAdded=!1}mapPositionToPoint(e,t,n){let r=this.domElement.isConnected?this.domElement.getBoundingClientRect():{x:0,y:0,width:this.domElement.width,height:this.domElement.height,left:0,top:0},i=1/this.resolution;e.x=(t-r.left)*(this.domElement.width/r.width)*i,e.y=(n-r.top)*(this.domElement.height/r.height)*i}_normalizeToPointerData(e){let t=[];if(this.supportsTouchEvents&&e instanceof TouchEvent)for(let n=0,r=e.changedTouches.length;n<r;n++){let r=e.changedTouches[n];r.button===void 0&&(r.button=0),r.buttons===void 0&&(r.buttons=1),r.isPrimary===void 0&&(r.isPrimary=e.touches.length===1&&e.type===`touchstart`),r.width===void 0&&(r.width=r.radiusX||1),r.height===void 0&&(r.height=r.radiusY||1),r.tiltX===void 0&&(r.tiltX=0),r.tiltY===void 0&&(r.tiltY=0),r.pointerType===void 0&&(r.pointerType=`touch`),r.pointerId===void 0&&(r.pointerId=r.identifier||0),r.pressure===void 0&&(r.pressure=r.force||.5),r.twist===void 0&&(r.twist=0),r.tangentialPressure===void 0&&(r.tangentialPressure=0),r.layerX===void 0&&(r.layerX=r.offsetX=r.clientX),r.layerY===void 0&&(r.layerY=r.offsetY=r.clientY),r.isNormalized=!0,r.type=e.type,t.push(r)}else if(!globalThis.MouseEvent||e instanceof MouseEvent&&(!this.supportsPointerEvents||!(e instanceof globalThis.PointerEvent))){let n=e;n.isPrimary===void 0&&(n.isPrimary=!0),n.width===void 0&&(n.width=1),n.height===void 0&&(n.height=1),n.tiltX===void 0&&(n.tiltX=0),n.tiltY===void 0&&(n.tiltY=0),n.pointerType===void 0&&(n.pointerType=`mouse`),n.pointerId===void 0&&(n.pointerId=$t),n.pressure===void 0&&(n.pressure=.5),n.twist===void 0&&(n.twist=0),n.tangentialPressure===void 0&&(n.tangentialPressure=0),n.isNormalized=!0,t.push(n)}else t.push(e);return t}normalizeWheelEvent(e){let 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=en[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}};tn.extension={name:`events`,type:[U.WebGLSystem,U.CanvasSystem,U.WebGPUSystem],priority:-1},tn.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};var nn=tn,rn={onclick: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(e){this.eventMode=e?`static`:`passive`},_internalEventMode:void 0,get eventMode(){return this._internalEventMode??nn.defaultEventMode},set eventMode(e){this._internalEventMode=e},isInteractive(){return this.eventMode===`static`||this.eventMode===`dynamic`},interactiveChildren:!0,hitArea:null,addEventListener(e,t,n){let r=typeof n==`boolean`&&n||typeof n==`object`&&n.capture,i=typeof n==`object`?n.signal:void 0,a=typeof n==`object`?n.once===!0:!1,o=typeof t==`function`?void 0:t;e=r?`${e}capture`:e;let s=typeof t==`function`?t:t.handleEvent,c=this;i&&i.addEventListener(`abort`,()=>{c.off(e,s,o)}),a?c.once(e,s,o):c.on(e,s,o)},removeEventListener(e,t,n){let r=typeof n==`boolean`&&n||typeof n==`object`&&n.capture,i=typeof t==`function`?void 0:t;e=r?`${e}capture`:e,t=typeof t==`function`?t:t.handleEvent,this.off(e,t,i)},dispatchEvent(e){if(!(e instanceof ft))throw Error(`Container cannot propagate events outside of the Federated Events API`);return e.defaultPrevented=!1,e.path=null,e.target=this,e.manager.dispatchEvent(e),!e.defaultPrevented}},an=(e=>(e[e.Low=0]=`Low`,e[e.Normal=1]=`Normal`,e[e.High=2]=`High`,e))(an||{});function on(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received ${JSON.stringify(e)}`)}function sn(e){return e.split(`?`)[0].split(`#`)[0]}function cn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function ln(e,t,n){return e.replace(new RegExp(cn(t),`g`),n)}function un(e,t){let n=``,r=0,i=-1,a=0,o=-1;for(let s=0;s<=e.length;++s){if(s<e.length)o=e.charCodeAt(s);else if(o===47)break;else o=47;if(o===47){if(!(i===s-1||a===1))if(i!==s-1&&a===2){if(n.length<2||r!==2||n.charCodeAt(n.length-1)!==46||n.charCodeAt(n.length-2)!==46){if(n.length>2){let e=n.lastIndexOf(`/`);if(e!==n.length-1){e===-1?(n=``,r=0):(n=n.slice(0,e),r=n.length-1-n.lastIndexOf(`/`)),i=s,a=0;continue}}else if(n.length===2||n.length===1){n=``,r=0,i=s,a=0;continue}}t&&(n.length>0?n+=`/..`:n=`..`,r=2)}else n.length>0?n+=`/${e.slice(i+1,s)}`:n=e.slice(i+1,s),r=s-i-1;i=s,a=0}else o===46&&a!==-1?++a:a=-1}return n}var dn={toPosix(e){return ln(e,`\\`,`/`)},isUrl(e){return/^https?:/.test(this.toPosix(e))},isDataUrl(e){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(e)},isBlobUrl(e){return e.startsWith(`blob:`)},hasProtocol(e){return/^[^/:]+:/.test(this.toPosix(e))},getProtocol(e){on(e),e=this.toPosix(e);let t=/^file:\/\/\//.exec(e);if(t)return t[0];let n=/^[^/:]+:\/{0,2}/.exec(e);return n?n[0]:``},toAbsolute(e,t,n){if(on(e),this.isDataUrl(e)||this.isBlobUrl(e))return e;let r=sn(this.toPosix(t??z.get().getBaseUrl())),i=sn(this.toPosix(n??this.rootname(r)));return e=this.toPosix(e),e.startsWith(`/`)?dn.join(i,e.slice(1)):this.isAbsolute(e)?e:this.join(r,e)},normalize(e){if(on(e),e.length===0)return`.`;if(this.isDataUrl(e)||this.isBlobUrl(e))return e;e=this.toPosix(e);let t=``,n=e.startsWith(`/`);this.hasProtocol(e)&&(t=this.rootname(e),e=e.slice(t.length));let r=e.endsWith(`/`);return e=un(e,!1),e.length>0&&r&&(e+=`/`),n?`/${e}`:t+e},isAbsolute(e){return on(e),e=this.toPosix(e),this.hasProtocol(e)?!0:e.startsWith(`/`)},join(...e){if(e.length===0)return`.`;let t;for(let n=0;n<e.length;++n){let r=e[n];if(on(r),r.length>0)if(t===void 0)t=r;else{let i=e[n-1]??``;this.joinExtensions.includes(this.extname(i).toLowerCase())?t+=`/../${r}`:t+=`/${r}`}}return t===void 0?`.`:this.normalize(t)},dirname(e){if(on(e),e.length===0)return`.`;e=this.toPosix(e);let t=e.charCodeAt(0),n=t===47,r=-1,i=!0,a=this.getProtocol(e),o=e;e=e.slice(a.length);for(let n=e.length-1;n>=1;--n)if(t=e.charCodeAt(n),t===47){if(!i){r=n;break}}else i=!1;return r===-1?n?`/`:this.isUrl(o)?a+e:a:n&&r===1?`//`:a+e.slice(0,r)},rootname(e){on(e),e=this.toPosix(e);let t=``;if(t=e.startsWith(`/`)?`/`:this.getProtocol(e),this.isUrl(e)){let n=e.indexOf(`/`,t.length);t=n===-1?e:e.slice(0,n),t.endsWith(`/`)||(t+=`/`)}return t},basename(e,t){on(e),t&&on(t),e=sn(this.toPosix(e));let n=0,r=-1,i=!0,a;if(t!==void 0&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return``;let o=t.length-1,s=-1;for(a=e.length-1;a>=0;--a){let c=e.charCodeAt(a);if(c===47){if(!i){n=a+1;break}}else s===-1&&(i=!1,s=a+1),o>=0&&(c===t.charCodeAt(o)?--o===-1&&(r=a):(o=-1,r=s))}return n===r?r=s:r===-1&&(r=e.length),e.slice(n,r)}for(a=e.length-1;a>=0;--a)if(e.charCodeAt(a)===47){if(!i){n=a+1;break}}else r===-1&&(i=!1,r=a+1);return r===-1?``:e.slice(n,r)},extname(e){on(e),e=sn(this.toPosix(e));let t=-1,n=0,r=-1,i=!0,a=0;for(let o=e.length-1;o>=0;--o){let s=e.charCodeAt(o);if(s===47){if(!i){n=o+1;break}continue}r===-1&&(i=!1,r=o+1),s===46?t===-1?t=o:a!==1&&(a=1):t!==-1&&(a=-1)}return t===-1||r===-1||a===0||a===1&&t===r-1&&t===n+1?``:e.slice(t,r)},parse(e){on(e);let t={root:``,dir:``,base:``,ext:``,name:``};if(e.length===0)return t;e=sn(this.toPosix(e));let n=e.charCodeAt(0),r=this.isAbsolute(e),i;t.root=this.rootname(e),i=r||this.hasProtocol(e)?1:0;let a=-1,o=0,s=-1,c=!0,l=e.length-1,u=0;for(;l>=i;--l){if(n=e.charCodeAt(l),n===47){if(!c){o=l+1;break}continue}s===-1&&(c=!1,s=l+1),n===46?a===-1?a=l:u!==1&&(u=1):a!==-1&&(u=-1)}return a===-1||s===-1||u===0||u===1&&a===s-1&&a===o+1?s!==-1&&(o===0&&r?t.base=t.name=e.slice(1,s):t.base=t.name=e.slice(o,s)):(o===0&&r?(t.name=e.slice(1,a),t.base=e.slice(1,s)):(t.name=e.slice(o,a),t.base=e.slice(o,s)),t.ext=e.slice(a,s)),t.dir=this.dirname(e),t},sep:`/`,delimiter:`:`,joinExtensions:[`.html`]},fn=(e,t,n=!1)=>(Array.isArray(e)||(e=[e]),t?e.map(e=>typeof e==`string`||n?t(e):e):e);function pn(e,t,n,r,i){let a=t[n];for(let o=0;o<a.length;o++){let s=a[o];n<t.length-1?pn(e.replace(r[n],s),t,n+1,r,i):i.push(e.replace(r[n],s))}}function mn(e){let t=e.match(/\{(.*?)\}/g),n=[];if(t){let r=[];t.forEach(e=>{let t=e.substring(1,e.length-1).split(`,`);r.push(t)}),pn(e,r,0,t,n)}else n.push(e);return n}var hn=e=>!Array.isArray(e),gn=class{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 Error(`[Resolver] GenerateBundleAssetId are not working correctly`)}prefer(...e){e.forEach(e=>{this._preferredOrder.push(e),e.priority||=Object.keys(e.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{let t=e;this._defaultSearchParams=Object.keys(t).map(e=>`${encodeURIComponent(e)}=${encodeURIComponent(t[e])}`).join(`&`)}}getAlias(e){let{alias:t,src:n}=e;return fn(t||n,e=>typeof e==`string`?e:Array.isArray(e)?e.map(e=>e?.src??e):e?.src?e.src:e,!0)}addManifest(e){this._manifest&&B(`[Resolver] Manifest already exists, this will be overwritten`),this._manifest=e,e.bundles.forEach(e=>{this.addBundle(e.name,e.assets)})}addBundle(e,t){let n=[],r=t;Array.isArray(t)||(r=Object.entries(t).map(([e,t])=>typeof t==`string`||Array.isArray(t)?{alias:e,src:t}:{alias:e,...t})),r.forEach(t=>{let r=t.src,i=t.alias,a;if(typeof i==`string`){let t=this._createBundleAssetId(e,i);n.push(t),a=[i,t]}else{let t=i.map(t=>this._createBundleAssetId(e,t));n.push(...t),a=[...i,...t]}this.add({...t,alias:a,src:r})}),this._bundles[e]=n}add(e){let t=[];Array.isArray(e)?t.push(...e):t.push(e);let n=e=>{this.hasKey(e)&&B(`[Resolver] already has key: ${e} overwriting`)};fn(t).forEach(e=>{let{src:t}=e,{data:r,format:i,loadParser:a}=e,o=fn(t).map(e=>typeof e==`string`?mn(e):Array.isArray(e)?e:[e]),s=this.getAlias(e);Array.isArray(s)?s.forEach(n):n(s);let c=[];o.forEach(e=>{e.forEach(e=>{let t={};if(typeof e!=`object`){t.src=e;for(let n=0;n<this._parsers.length;n++){let r=this._parsers[n];if(r.test(e)){t=r.parse(e);break}}}else r=e.data??r,i=e.format??i,a=e.loadParser??a,t={...t,...e};if(!s)throw Error(`[Resolver] alias is undefined for this asset: ${t.src}`);t=this._buildResolvedAsset(t,{aliases:s,data:r,format:i,loadParser:a}),c.push(t)})}),s.forEach(e=>{this._assetMap[e]=c})})}resolveBundle(e){let t=hn(e);e=fn(e);let n={};return e.forEach(e=>{let t=this._bundles[e];if(t){let r=this.resolve(t),i={};for(let t in r){let n=r[t];i[this._extractAssetIdFromBundle(e,t)]=n}n[e]=i}}),t?n[e[0]]:n}resolveUrl(e){let t=this.resolve(e);if(typeof e!=`string`){let e={};for(let n in t)e[n]=t[n].src;return e}return t.src}resolve(e){let t=hn(e);e=fn(e);let n={};return e.forEach(e=>{if(!this._resolverHash[e])if(this._assetMap[e]){let t=this._assetMap[e],n=this._getPreferredOrder(t);n?.priority.forEach(e=>{n.params[e].forEach(n=>{let r=t.filter(t=>t[e]?t[e]===n:!1);r.length&&(t=r)})}),this._resolverHash[e]=t[0]}else this._resolverHash[e]=this._buildResolvedAsset({alias:[e],src:e},{});n[e]=this._resolverHash[e]}),t?n[e[0]]:n}hasKey(e){return!!this._assetMap[e]}hasBundle(e){return!!this._bundles[e]}_getPreferredOrder(e){for(let t=0;t<e.length;t++){let t=e[0],n=this._preferredOrder.find(e=>e.params.format.includes(t.format));if(n)return n}return this._preferredOrder[0]}_appendDefaultSearchParams(e){return this._defaultSearchParams?`${e}${/\?/.test(e)?`&`:`?`}${this._defaultSearchParams}`:e}_buildResolvedAsset(e,t){let{aliases:n,data:r,loadParser:i,format:a}=t;return(this._basePath||this._rootPath)&&(e.src=dn.toAbsolute(e.src,this._basePath,this._rootPath)),e.alias=n??e.alias??[e.src],e.src=this._appendDefaultSearchParams(e.src),e.data={...r||{},...e.data},e.loadParser=i??e.loadParser,e.format=a??e.format??_n(e.src),e}};gn.RETINA_PREFIX=/@([0-9\.]+)x/;function _n(e){return e.split(`.`).pop().split(`?`).shift().split(`#`).shift()}var vn=(e,t)=>{let n=t.split(`?`)[1];return n&&(e+=`?${n}`),e},yn=class e{constructor(e,t){this.linkedSheets=[],this._texture=e instanceof R?e:null,this.textureSource=e.source,this.textures={},this.animations={},this.data=t;let n=parseFloat(t.meta.scale);n?(this.resolution=n,e.source.resolution=this.resolution):this.resolution=e.source._resolution,this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}parse(){return new Promise(t=>{this._callback=t,this._batchIndex=0,this._frameKeys.length<=e.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(t){let n=t,r=e.BATCH_SIZE;for(;n-t<r&&n<this._frameKeys.length;){let e=this._frameKeys[n],t=this._frames[e],r=t.frame;if(r){let n=null,i=null,a=t.trimmed!==!1&&t.sourceSize?t.sourceSize:t.frame,o=new be(0,0,Math.floor(a.w)/this.resolution,Math.floor(a.h)/this.resolution);n=t.rotated?new be(Math.floor(r.x)/this.resolution,Math.floor(r.y)/this.resolution,Math.floor(r.h)/this.resolution,Math.floor(r.w)/this.resolution):new be(Math.floor(r.x)/this.resolution,Math.floor(r.y)/this.resolution,Math.floor(r.w)/this.resolution,Math.floor(r.h)/this.resolution),t.trimmed!==!1&&t.spriteSourceSize&&(i=new be(Math.floor(t.spriteSourceSize.x)/this.resolution,Math.floor(t.spriteSourceSize.y)/this.resolution,Math.floor(r.w)/this.resolution,Math.floor(r.h)/this.resolution)),this.textures[e]=new R({source:this.textureSource,frame:n,orig:o,trim:i,rotate:t.rotated?2:0,defaultAnchor:t.anchor,defaultBorders:t.borders,label:e.toString()})}n++}}_processAnimations(){let e=this.data.animations||{};for(let t in e){this.animations[t]=[];for(let n=0;n<e[t].length;n++){let r=e[t][n];this.animations[t].push(this.textures[r])}}}_parseComplete(){let e=this._callback;this._callback=null,this._batchIndex=0,e.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*e.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*e.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(e=!1){for(let e in this.textures)this.textures[e].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=[]}};yn.BATCH_SIZE=1e3;var bn=yn,xn=[`jpg`,`png`,`jpeg`,`avif`,`webp`,`basis`,`etc2`,`bc7`,`bc6h`,`bc5`,`bc4`,`bc3`,`bc2`,`bc1`,`eac`,`astc`];function Sn(e,t,n){let r={};if(e.forEach(e=>{r[e]=t}),Object.keys(t.textures).forEach(e=>{r[e]=t.textures[e]}),!n){let n=dn.dirname(e[0]);t.linkedSheets.forEach((e,i)=>{let a=Sn([`${n}/${t.data.meta.related_multi_packs[i]}`],e,!0);Object.assign(r,a)})}return r}var Cn={extension:U.Asset,cache:{test:e=>e instanceof bn,getCacheableAssets:(e,t)=>Sn(e,t,!1)},resolver:{extension:{type:U.ResolveParser,name:`resolveSpritesheet`},test:e=>{let t=e.split(`?`)[0].split(`.`),n=t.pop(),r=t.pop();return n===`json`&&xn.includes(r)},parse:e=>{let t=e.split(`.`);return{resolution:parseFloat(gn.RETINA_PREFIX.exec(e)?.[1]??`1`),format:t[t.length-2],src:e}}},loader:{name:`spritesheetLoader`,extension:{type:U.LoadParser,priority:an.Normal,name:`spritesheetLoader`},async testParse(e,t){return dn.extname(t.src).toLowerCase()===`.json`&&!!e.frames},async parse(e,t,n){let{texture:r,imageFilename:i}=t?.data??{},a=dn.dirname(t.src);a&&a.lastIndexOf(`/`)!==a.length-1&&(a+=`/`);let o;if(r instanceof R)o=r;else{let r=vn(a+(i??e.meta.image),t.src);o=(await n.load([r]))[r]}let s=new bn(o.source,e);await s.parse();let c=e?.meta?.related_multi_packs;if(Array.isArray(c)){let e=[];for(let r of c){if(typeof r!=`string`)continue;let i=a+r;t.data?.ignoreMultiPack||(i=vn(i,t.src),e.push(n.load({src:i,data:{ignoreMultiPack:!0}})))}let r=await Promise.all(e);s.linkedSheets=r,r.forEach(e=>{e.linkedSheets=[s].concat(s.linkedSheets.filter(t=>t!==e))})}return s},async unload(e,t,n){await n.unload(e.textureSource._sourceOrigin),e.destroy(!1)}}};Pe.add(Cn);var wn=new k;function Tn(e,t,n){let r=wn;e.measurable=!0,fe(e,n,r),t.addBoundsMask(r),e.measurable=!1}function En(e,t,n){let r=pe.get();e.measurable=!0;let i=se.get().identity();te(e,r,Dn(e,n,i)),e.measurable=!1,t.addBoundsMask(r),se.return(i),pe.return(r)}function Dn(e,t,n){return e?(e!==t&&(Dn(e.parent,t,n),e.updateLocalTransform(),n.append(e.localTransform)),n):(B(`Mask bounds, renderable is not inside the root container`),n)}var On=class{constructor(e){this.priority=0,this.pipe=`alphaMask`,e?.mask&&this.init(e.mask)}init(e){this.mask=e,this.renderMaskToTexture=!(e instanceof oe),this.mask.renderable=this.renderMaskToTexture,this.mask.includeInBuild=!this.renderMaskToTexture,this.mask.measurable=!1}reset(){this.mask.measurable=!0,this.mask=null}addBounds(e,t){Tn(this.mask,e,t)}addLocalBounds(e,t){En(this.mask,e,t)}containsPoint(e,t){let n=this.mask;return t(n,e)}destroy(){this.reset()}static test(e){return e instanceof oe}};On.extension=U.MaskEffect;var kn=class{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`}};kn.extension=U.MaskEffect;var An=class{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.measurable=!0,this.mask.includeInBuild=!0,this.mask=null}addBounds(e,t){Tn(this.mask,e,t)}addLocalBounds(e,t){En(this.mask,e,t)}containsPoint(e,t){let n=this.mask;return t(n,e)}destroy(){this.reset()}static test(e){return e instanceof ne}};An.extension=U.MaskEffect;var jn=class extends j{constructor(e){if(e.resource&&globalThis.HTMLImageElement&&e.resource instanceof HTMLImageElement){let t=z.get().createCanvas(e.resource.width,e.resource.height);t.getContext(`2d`).drawImage(e.resource,0,0,e.resource.width,e.resource.height),e.resource=t,B(`ImageSource: Image element passed, converting to canvas. Use CanvasSource instead.`)}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}};jn.extension=U.TextureSource;var Mn;async function Nn(){return Mn??=(async()=>{let e=document.createElement(`canvas`).getContext(`webgl`);if(!e)return`premultiply-alpha-on-upload`;let t=await new Promise(e=>{let t=document.createElement(`video`);t.onloadeddata=()=>e(t),t.onerror=()=>e(null),t.autoplay=!1,t.crossOrigin=`anonymous`,t.preload=`auto`,t.src=`data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=`,t.load()});if(!t)return`premultiply-alpha-on-upload`;let n=e.createTexture();e.bindTexture(e.TEXTURE_2D,n);let r=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,r),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,n,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);let i=new Uint8Array(4);return e.readPixels(0,0,1,1,e.RGBA,e.UNSIGNED_BYTE,i),e.deleteFramebuffer(r),e.deleteTexture(n),e.getExtension(`WEBGL_lose_context`)?.loseContext(),i[0]<=i[3]?`premultiplied-alpha`:`premultiply-alpha-on-upload`})(),Mn}var Pn=class e extends j{constructor(t){super(t),this.isReady=!1,this.uploadMethodId=`video`,t={...e.defaultOptions,...t},this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=t.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=t.autoPlay!==!1,this.alphaMode=t.alphaMode??`premultiply-alpha-on-upload`,this._videoFrameRequestCallback=this._videoFrameRequestCallback.bind(this),this._videoFrameRequestCallbackHandle=null,this._load=null,this._resolve=null,this._reject=null,this._onCanPlay=this._onCanPlay.bind(this),this._onCanPlayThrough=this._onCanPlayThrough.bind(this),this._onError=this._onError.bind(this),this._onPlayStart=this._onPlayStart.bind(this),this._onPlayStop=this._onPlayStop.bind(this),this._onSeeked=this._onSeeked.bind(this),t.autoLoad!==!1&&this.load()}updateFrame(){if(!this.destroyed){if(this._updateFPS){let e=de.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;let 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.alphaMode=await Nn(),this._load=new Promise((n,r)=>{this.isValid?n(this):(this._resolve=n,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(){let e=this.resource;return!e.paused&&!e.ended}_isSourceReady(){return this.resource.readyState>2}_onPlayStart(){this.isValid||this._mediaReady(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0)}_onCanPlay(){this.resource.removeEventListener(`canplay`,this._onCanPlay),this._mediaReady()}_onCanPlayThrough(){this.resource.removeEventListener(`canplaythrough`,this._onCanPlay),this._preloadTimeout&&=(clearTimeout(this._preloadTimeout),void 0),this._mediaReady()}_mediaReady(){let 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._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&this.resource.play()}destroy(){this._configureAutoUpdate();let 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(`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&&(de.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||(de.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(de.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(e){return globalThis.HTMLVideoElement&&e instanceof HTMLVideoElement}};Pn.extension=U.TextureSource,Pn.defaultOptions={...j.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1},Pn.MIME_TYPES={ogv:`video/ogg`,mov:`video/quicktime`,m4v:`video/mp4`};var Fn=Pn,In=new class{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){let t=this._cache.get(e);return t||B(`[Assets] Asset id ${e} was not found in the Cache`),t}set(e,t){let n=fn(e),r;for(let e=0;e<this.parsers.length;e++){let i=this.parsers[e];if(i.test(t)){r=i.getCacheableAssets(n,t);break}}let i=new Map(Object.entries(r||{}));r||n.forEach(e=>{i.set(e,t)});let a=[...i.keys()],o={cacheKeys:a,keys:n};n.forEach(e=>{this._cacheMap.set(e,o)}),a.forEach(e=>{let n=r?r[e]:t;this._cache.has(e)&&this._cache.get(e)!==n&&B(`[Cache] already has key:`,e),this._cache.set(e,i.get(e))})}remove(e){if(!this._cacheMap.has(e)){B(`[Assets] Asset id ${e} was not found in the Cache`);return}let t=this._cacheMap.get(e);t.cacheKeys.forEach(e=>{this._cache.delete(e)}),t.keys.forEach(e=>{this._cacheMap.delete(e)})}get parsers(){return this._parsers}},Ln=[];Pe.handleByList(U.TextureSource,Ln);function Rn(e={}){let t=e&&e.resource,n=t?e.resource:e,r=t?e:{resource:e};for(let e=0;e<Ln.length;e++){let t=Ln[e];if(t.test(n))return new t(r)}throw Error(`Could not find a source type for resource: ${r.resource}`)}function zn(e={},t=!1){let n=e&&e.resource,r=n?e.resource:e,i=n?e:{resource:e};if(!t&&In.has(r))return In.get(r);let a=new R({source:Rn(i)});return a.on(`destroy`,()=>{In.has(r)&&In.remove(r)}),t||In.set(r,a),a}function Bn(e,t=!1){return typeof e==`string`?In.get(e):e instanceof j?new R({source:e}):zn(e,t)}R.from=Bn,j.from=Rn,Pe.add(On,kn,An,Fn,jn,ie,Ge);function Vn(e,t,n,r,i,a,o,s=null){let c=0;n*=t,i*=a;let l=s.a,u=s.b,d=s.c,f=s.d,p=s.tx,m=s.ty;for(;c<o;){let o=e[n],s=e[n+1];r[i]=l*o+d*s+p,r[i+1]=u*o+f*s+m,i+=a,n+=t,c++}}function Hn(e,t,n,r){let i=0;for(t*=n;i<r;)e[t]=0,e[t+1]=0,t+=n,i++}function Un(e,t,n,r,i){let a=t.a,o=t.b,s=t.c,c=t.d,l=t.tx,u=t.ty;n||=0,r||=2,i||=e.length/r-n;let d=n*r;for(let t=0;t<i;t++){let t=e[d],n=e[d+1];e[d]=a*t+s*n+l,e[d+1]=o*t+c*n+u,d+=r}}function Wn(e,t){if(e===16777215||!t)return t;if(t===16777215||!e)return e;let n=e>>16&255,r=e>>8&255,i=e&255,a=t>>16&255,o=t>>8&255,s=t&255,c=n*a/255,l=r*o/255,u=i*s/255;return(c<<16)+(l<<8)+u}var Gn=class{constructor(){this.batcher=null,this.batch=null,this.applyTransform=!0,this.roundPixels=0}get blendMode(){return this.applyTransform?this.renderable.groupBlendMode:`normal`}packIndex(e,t,n){let r=this.geometryData.indices;for(let i=0;i<this.indexSize;i++)e[t++]=r[i+this.indexOffset]+n-this.vertexOffset}packAttributes(e,t,n,r){let i=this.geometryData,a=this.renderable,o=i.vertices,s=i.uvs,c=this.vertexOffset*2,l=(this.vertexOffset+this.vertexSize)*2,u=this.color,d=u>>16|u&65280|(u&255)<<16;if(this.applyTransform){let i=Wn(d,a.groupColor)+(this.alpha*a.groupAlpha*255<<24),u=a.groupTransform,f=r<<16|this.roundPixels&65535,p=u.a,m=u.b,h=u.c,g=u.d,_=u.tx,v=u.ty;for(let r=c;r<l;r+=2){let a=o[r],c=o[r+1];e[n]=p*a+h*c+_,e[n+1]=m*a+g*c+v,e[n+2]=s[r],e[n+3]=s[r+1],t[n+4]=i,t[n+5]=f,n+=6}}else{let i=d+(this.alpha*255<<24);for(let a=c;a<l;a+=2)e[n]=o[a],e[n+1]=o[a+1],e[n+2]=s[a],e[n+3]=s[a+1],t[n+4]=i,t[n+5]=r<<16,n+=6}}get vertSize(){return this.vertexSize}copyTo(e){e.indexOffset=this.indexOffset,e.indexSize=this.indexSize,e.vertexOffset=this.vertexOffset,e.vertexSize=this.vertexSize,e.color=this.color,e.alpha=this.alpha,e.texture=this.texture,e.geometryData=this.geometryData}reset(){this.applyTransform=!0}},Kn={extension:{type:U.ShapeBuilder,name:`circle`},build(e,t){let n,r,i,a,o,s;if(e.type===`circle`){let t=e;n=t.x,r=t.y,o=s=t.radius,i=a=0}else if(e.type===`ellipse`){let t=e;n=t.x,r=t.y,o=t.halfWidth,s=t.halfHeight,i=a=0}else{let t=e,c=t.width/2,l=t.height/2;n=t.x+c,r=t.y+l,o=s=Math.max(0,Math.min(t.radius,Math.min(c,l))),i=c-o,a=l-s}if(!(o>=0&&s>=0&&i>=0&&a>=0))return t;let c=Math.ceil(2.3*Math.sqrt(o+s)),l=c*8+(i?4:0)+(a?4:0);if(l===0)return t;if(c===0)return t[0]=t[6]=n+i,t[1]=t[3]=r+a,t[2]=t[4]=n-i,t[5]=t[7]=r-a,t;let u=0,d=c*4+(i?2:0)+2,f=d,p=l,m=i+o,h=a,g=n+m,_=n-m,v=r+h;if(t[u++]=g,t[u++]=v,t[--d]=v,t[--d]=_,a){let e=r-h;t[f++]=_,t[f++]=e,t[--p]=e,t[--p]=g}for(let e=1;e<c;e++){let l=Math.PI/2*(e/c),m=i+Math.cos(l)*o,h=a+Math.sin(l)*s,g=n+m,_=n-m,v=r+h,y=r-h;t[u++]=g,t[u++]=v,t[--d]=v,t[--d]=_,t[f++]=_,t[f++]=y,t[--p]=y,t[--p]=g}m=i,h=a+s,g=n+m,_=n-m,v=r+h;let y=r-h;return t[u++]=g,t[u++]=v,t[--p]=y,t[--p]=g,i&&(t[u++]=_,t[u++]=v,t[--p]=y,t[--p]=_),t},triangulate(e,t,n,r,i,a){if(e.length===0)return;let o=0,s=0;for(let t=0;t<e.length;t+=2)o+=e[t],s+=e[t+1];o/=e.length/2,s/=e.length/2;let c=r;t[c*n]=o,t[c*n+1]=s;let l=c++;for(let r=0;r<e.length;r+=2)t[c*n]=e[r],t[c*n+1]=e[r+1],r>0&&(i[a++]=c,i[a++]=l,i[a++]=c-1),c++;i[a++]=l+1,i[a++]=l,i[a++]=c-1}},qn={...Kn,extension:{...Kn.extension,name:`ellipse`}},Jn={...Kn,extension:{...Kn.extension,name:`roundedRectangle`}},Yn=1e-4,Xn=1e-4;function Zn(e){let t=e.length;if(t<6)return 1;let n=0;for(let r=0,i=e[t-2],a=e[t-1];r<t;r+=2){let t=e[r],o=e[r+1];n+=(t-i)*(o+a),i=t,a=o}return n<0?-1:1}function Qn(e,t,n,r,i,a,o,s){let c=e-n*i,l=t-r*i,u=e+n*a,d=t+r*a,f,p;o?(f=r,p=-n):(f=-r,p=n);let m=c+f,h=l+p,g=u+f,_=d+p;return s.push(m,h),s.push(g,_),2}function $n(e,t,n,r,i,a,o,s){let c=n-e,l=r-t,u=Math.atan2(c,l),d=Math.atan2(i-e,a-t);s&&u<d?u+=Math.PI*2:!s&&u>d&&(d+=Math.PI*2);let f=u,p=d-u,m=Math.abs(p),h=Math.sqrt(c*c+l*l),g=(15*m*Math.sqrt(h)/Math.PI>>0)+1,_=p/g;if(f+=_,s){o.push(e,t),o.push(n,r);for(let n=1,r=f;n<g;n++,r+=_)o.push(e,t),o.push(e+Math.sin(r)*h,t+Math.cos(r)*h);o.push(e,t),o.push(i,a)}else{o.push(n,r),o.push(e,t);for(let n=1,r=f;n<g;n++,r+=_)o.push(e+Math.sin(r)*h,t+Math.cos(r)*h),o.push(e,t);o.push(i,a),o.push(e,t)}return g*2}function er(e,t,n,r,i,a,o,s,c){let l=Yn;if(e.length===0)return;let u=t,d=u.alignment;if(t.alignment!==.5){let t=Zn(e);n&&(t*=-1),d=(d-.5)*t+.5}let f=new Oe(e[0],e[1]),p=new Oe(e[e.length-2],e[e.length-1]),m=r,h=Math.abs(f.x-p.x)<l&&Math.abs(f.y-p.y)<l;if(m){e=e.slice(),h&&(e.pop(),e.pop(),p.set(e[e.length-2],e[e.length-1]));let t=(f.x+p.x)*.5,n=(p.y+f.y)*.5;e.unshift(t,n),e.push(t,n)}let g=i,_=e.length/2,v=e.length,y=g.length/2,b=u.width/2,x=b*b,S=u.miterLimit*u.miterLimit,C=e[0],w=e[1],T=e[2],E=e[3],D=0,O=0,k=-(w-E),A=C-T,j=0,M=0,N=Math.sqrt(k*k+A*A);k/=N,A/=N,k*=b,A*=b;let P=d,F=(1-P)*2,I=P*2;m||(u.cap===`round`?v+=$n(C-k*(F-I)*.5,w-A*(F-I)*.5,C-k*F,w-A*F,C+k*I,w+A*I,g,!0)+2:u.cap===`square`&&(v+=Qn(C,w,k,A,F,I,!0,g))),g.push(C-k*F,w-A*F),g.push(C+k*I,w+A*I);for(let t=1;t<_-1;++t){C=e[(t-1)*2],w=e[(t-1)*2+1],T=e[t*2],E=e[t*2+1],D=e[(t+1)*2],O=e[(t+1)*2+1],k=-(w-E),A=C-T,N=Math.sqrt(k*k+A*A),k/=N,A/=N,k*=b,A*=b,j=-(E-O),M=T-D,N=Math.sqrt(j*j+M*M),j/=N,M/=N,j*=b,M*=b;let n=T-C,r=w-E,i=T-D,a=O-E,o=n*i+r*a,s=r*i-a*n,c=s<0;if(Math.abs(s)<.001*Math.abs(o)){g.push(T-k*F,E-A*F),g.push(T+k*I,E+A*I),o>=0&&(u.join===`round`?v+=$n(T,E,T-k*F,E-A*F,T-j*F,E-M*F,g,!1)+4:v+=2,g.push(T-j*I,E-M*I),g.push(T+j*F,E+M*F));continue}let l=(-k+C)*(-A+E)-(-k+T)*(-A+w),d=(-j+D)*(-M+E)-(-j+T)*(-M+O),f=(n*d-i*l)/s,p=(a*l-r*d)/s,m=(f-T)*(f-T)+(p-E)*(p-E),h=T+(f-T)*F,_=E+(p-E)*F,y=T-(f-T)*I,P=E-(p-E)*I,L=Math.min(n*n+r*r,i*i+a*a),ee=c?F:I;m<=L+ee*ee*x?u.join===`bevel`||m/x>S?(c?(g.push(h,_),g.push(T+k*I,E+A*I),g.push(h,_),g.push(T+j*I,E+M*I)):(g.push(T-k*F,E-A*F),g.push(y,P),g.push(T-j*F,E-M*F),g.push(y,P)),v+=2):u.join===`round`?c?(g.push(h,_),g.push(T+k*I,E+A*I),v+=$n(T,E,T+k*I,E+A*I,T+j*I,E+M*I,g,!0)+4,g.push(h,_),g.push(T+j*I,E+M*I)):(g.push(T-k*F,E-A*F),g.push(y,P),v+=$n(T,E,T-k*F,E-A*F,T-j*F,E-M*F,g,!1)+4,g.push(T-j*F,E-M*F),g.push(y,P)):(g.push(h,_),g.push(y,P)):(g.push(T-k*F,E-A*F),g.push(T+k*I,E+A*I),u.join===`round`?c?v+=$n(T,E,T+k*I,E+A*I,T+j*I,E+M*I,g,!0)+2:v+=$n(T,E,T-k*F,E-A*F,T-j*F,E-M*F,g,!1)+2:u.join===`miter`&&m/x<=S&&(c?(g.push(y,P),g.push(y,P)):(g.push(h,_),g.push(h,_)),v+=2),g.push(T-j*F,E-M*F),g.push(T+j*I,E+M*I),v+=2)}C=e[(_-2)*2],w=e[(_-2)*2+1],T=e[(_-1)*2],E=e[(_-1)*2+1],k=-(w-E),A=C-T,N=Math.sqrt(k*k+A*A),k/=N,A/=N,k*=b,A*=b,g.push(T-k*F,E-A*F),g.push(T+k*I,E+A*I),m||(u.cap===`round`?v+=$n(T-k*(F-I)*.5,E-A*(F-I)*.5,T-k*F,E-A*F,T+k*I,E+A*I,g,!1)+2:u.cap===`square`&&(v+=Qn(T,E,k,A,F,I,!1,g)));let L=Xn*Xn;for(let e=y;e<v+y-2;++e)C=g[e*2],w=g[e*2+1],T=g[(e+1)*2],E=g[(e+1)*2+1],D=g[(e+2)*2],O=g[(e+2)*2+1],!(Math.abs(C*(E-O)+T*(O-w)+D*(w-E))<L)&&s.push(e,e+1,e+2)}var tr=t(n(((e,t)=>{t.exports=n,t.exports.default=n;function n(e,t,n){n||=2;var i=t&&t.length,o=i?t[0]*n:e.length,s=r(e,0,o,n,!0),c=[];if(!s||s.next===s.prev)return c;var l,d,f,p,m,h,g;if(i&&(s=u(e,t,s,n)),e.length>80*n){l=f=e[0],d=p=e[1];for(var _=n;_<o;_+=n)m=e[_],h=e[_+1],m<l&&(l=m),h<d&&(d=h),m>f&&(f=m),h>p&&(p=h);g=Math.max(f-l,p-d),g=g===0?0:32767/g}return a(s,c,n,l,d,g,0),c}function r(e,t,n,r,i){var a,o;if(i===N(e,t,n,r)>0)for(a=t;a<n;a+=r)o=A(a,e[a],e[a+1],o);else for(a=n-r;a>=t;a-=r)o=A(a,e[a],e[a+1],o);return o&&S(o,o.next)&&(j(o),o=o.next),o}function i(e,t){if(!e)return e;t||=e;var n=e,r;do if(r=!1,!n.steiner&&(S(n,n.next)||x(n.prev,n,n.next)===0)){if(j(n),n=t=n.prev,n===n.next)break;r=!0}else n=n.next;while(r||n!==t);return t}function a(e,t,n,r,u,d,f){if(e){!f&&d&&h(e,r,u,d);for(var p=e,m,g;e.prev!==e.next;){if(m=e.prev,g=e.next,d?s(e,r,u,d):o(e)){t.push(m.i/n|0),t.push(e.i/n|0),t.push(g.i/n|0),j(e),e=g.next,p=g.next;continue}if(e=g,e===p){f?f===1?(e=c(i(e),t,n),a(e,t,n,r,u,d,2)):f===2&&l(e,t,n,r,u,d):a(i(e),t,n,r,u,d,1);break}}}}function o(e){var t=e.prev,n=e,r=e.next;if(x(t,n,r)>=0)return!1;for(var i=t.x,a=n.x,o=r.x,s=t.y,c=n.y,l=r.y,u=i<a?i<o?i:o:a<o?a:o,d=s<c?s<l?s:l:c<l?c:l,f=i>a?i>o?i:o:a>o?a:o,p=s>c?s>l?s:l:c>l?c:l,m=r.next;m!==t;){if(m.x>=u&&m.x<=f&&m.y>=d&&m.y<=p&&y(i,s,a,c,o,l,m.x,m.y)&&x(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function s(e,t,n,r){var i=e.prev,a=e,o=e.next;if(x(i,a,o)>=0)return!1;for(var s=i.x,c=a.x,l=o.x,u=i.y,d=a.y,f=o.y,p=s<c?s<l?s:l:c<l?c:l,m=u<d?u<f?u:f:d<f?d:f,h=s>c?s>l?s:l:c>l?c:l,g=u>d?u>f?u:f:d>f?d:f,v=_(p,m,t,n,r),b=_(h,g,t,n,r),S=e.prevZ,C=e.nextZ;S&&S.z>=v&&C&&C.z<=b;){if(S.x>=p&&S.x<=h&&S.y>=m&&S.y<=g&&S!==i&&S!==o&&y(s,u,c,d,l,f,S.x,S.y)&&x(S.prev,S,S.next)>=0||(S=S.prevZ,C.x>=p&&C.x<=h&&C.y>=m&&C.y<=g&&C!==i&&C!==o&&y(s,u,c,d,l,f,C.x,C.y)&&x(C.prev,C,C.next)>=0))return!1;C=C.nextZ}for(;S&&S.z>=v;){if(S.x>=p&&S.x<=h&&S.y>=m&&S.y<=g&&S!==i&&S!==o&&y(s,u,c,d,l,f,S.x,S.y)&&x(S.prev,S,S.next)>=0)return!1;S=S.prevZ}for(;C&&C.z<=b;){if(C.x>=p&&C.x<=h&&C.y>=m&&C.y<=g&&C!==i&&C!==o&&y(s,u,c,d,l,f,C.x,C.y)&&x(C.prev,C,C.next)>=0)return!1;C=C.nextZ}return!0}function c(e,t,n){var r=e;do{var a=r.prev,o=r.next.next;!S(a,o)&&C(a,r,r.next,o)&&D(a,o)&&D(o,a)&&(t.push(a.i/n|0),t.push(r.i/n|0),t.push(o.i/n|0),j(r),j(r.next),r=e=o),r=r.next}while(r!==e);return i(r)}function l(e,t,n,r,o,s){var c=e;do{for(var l=c.next.next;l!==c.prev;){if(c.i!==l.i&&b(c,l)){var u=k(c,l);c=i(c,c.next),u=i(u,u.next),a(c,t,n,r,o,s,0),a(u,t,n,r,o,s,0);return}l=l.next}c=c.next}while(c!==e)}function u(e,t,n,i){var a=[],o,s,c,l,u;for(o=0,s=t.length;o<s;o++)c=t[o]*i,l=o<s-1?t[o+1]*i:e.length,u=r(e,c,l,i,!1),u===u.next&&(u.steiner=!0),a.push(v(u));for(a.sort(d),o=0;o<a.length;o++)n=f(a[o],n);return n}function d(e,t){return e.x-t.x}function f(e,t){var n=p(e,t);if(!n)return t;var r=k(n,e);return i(r,r.next),i(n,n.next)}function p(e,t){var n=t,r=e.x,i=e.y,a=-1/0,o;do{if(i<=n.y&&i>=n.next.y&&n.next.y!==n.y){var s=n.x+(i-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(s<=r&&s>a&&(a=s,o=n.x<n.next.x?n:n.next,s===r))return o}n=n.next}while(n!==t);if(!o)return null;var c=o,l=o.x,u=o.y,d=1/0,f;n=o;do r>=n.x&&n.x>=l&&r!==n.x&&y(i<u?r:a,i,l,u,i<u?a:r,i,n.x,n.y)&&(f=Math.abs(i-n.y)/(r-n.x),D(n,e)&&(f<d||f===d&&(n.x>o.x||n.x===o.x&&m(o,n)))&&(o=n,d=f)),n=n.next;while(n!==c);return o}function m(e,t){return x(e.prev,e,t.prev)<0&&x(t.next,e,e.next)<0}function h(e,t,n,r){var i=e;do i.z===0&&(i.z=_(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,g(i)}function g(e){var t,n,r,i,a,o,s,c,l=1;do{for(n=e,e=null,a=null,o=0;n;){for(o++,r=n,s=0,t=0;t<l&&(s++,r=r.nextZ,r);t++);for(c=l;s>0||c>0&&r;)s!==0&&(c===0||!r||n.z<=r.z)?(i=n,n=n.nextZ,s--):(i=r,r=r.nextZ,c--),a?a.nextZ=i:e=i,i.prevZ=a,a=i;n=r}a.nextZ=null,l*=2}while(o>1);return e}function _(e,t,n,r,i){return e=(e-n)*i|0,t=(t-r)*i|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function v(e){var t=e,n=e;do(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next;while(t!==e);return n}function y(e,t,n,r,i,a,o,s){return(i-o)*(t-s)>=(e-o)*(a-s)&&(e-o)*(r-s)>=(n-o)*(t-s)&&(n-o)*(a-s)>=(i-o)*(r-s)}function b(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!E(e,t)&&(D(e,t)&&D(t,e)&&O(e,t)&&(x(e.prev,e,t.prev)||x(e,t.prev,t))||S(e,t)&&x(e.prev,e,e.next)>0&&x(t.prev,t,t.next)>0)}function x(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function S(e,t){return e.x===t.x&&e.y===t.y}function C(e,t,n,r){var i=T(x(e,t,n)),a=T(x(e,t,r)),o=T(x(n,r,e)),s=T(x(n,r,t));return!!(i!==a&&o!==s||i===0&&w(e,n,t)||a===0&&w(e,r,t)||o===0&&w(n,e,r)||s===0&&w(n,t,r))}function w(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function T(e){return e>0?1:e<0?-1:0}function E(e,t){var n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&C(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function D(e,t){return x(e.prev,e,e.next)<0?x(e,t,e.next)>=0&&x(e,e.prev,t)>=0:x(e,t,e.prev)<0||x(e,e.next,t)<0}function O(e,t){var n=e,r=!1,i=(e.x+t.x)/2,a=(e.y+t.y)/2;do n.y>a!=n.next.y>a&&n.next.y!==n.y&&i<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next;while(n!==e);return r}function k(e,t){var n=new M(e.i,e.x,e.y),r=new M(t.i,t.x,t.y),i=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,a.next=r,r.prev=a,r}function A(e,t,n,r){var i=new M(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function j(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function M(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}n.deviation=function(e,t,n,r){var i=t&&t.length,a=i?t[0]*n:e.length,o=Math.abs(N(e,0,a,n));if(i)for(var s=0,c=t.length;s<c;s++){var l=t[s]*n,u=s<c-1?t[s+1]*n:e.length;o-=Math.abs(N(e,l,u,n))}var d=0;for(s=0;s<r.length;s+=3){var f=r[s]*n,p=r[s+1]*n,m=r[s+2]*n;d+=Math.abs((e[f]-e[m])*(e[p+1]-e[f+1])-(e[f]-e[p])*(e[m+1]-e[f+1]))}return o===0&&d===0?0:Math.abs((d-o)/o)};function N(e,t,n,r){for(var i=0,a=t,o=n-r;a<n;a+=r)i+=(e[o]-e[a])*(e[a+1]+e[o+1]),o=a;return i}n.flatten=function(e){for(var t=e[0][0].length,n={vertices:[],holes:[],dimensions:t},r=0,i=0;i<e.length;i++){for(var a=0;a<e[i].length;a++)for(var o=0;o<t;o++)n.vertices.push(e[i][a][o]);i>0&&(r+=e[i-1].length,n.holes.push(r))}return n}}))(),1);function nr(e,t,n,r,i,a,o){let s=(0,tr.default)(e,t,2);if(!s)return;for(let e=0;e<s.length;e+=3)a[o++]=s[e]+i,a[o++]=s[e+1]+i,a[o++]=s[e+2]+i;let c=i*r;for(let t=0;t<e.length;t+=2)n[c]=e[t],n[c+1]=e[t+1],c+=r}var rr=[],ir={extension:{type:U.ShapeBuilder,name:`polygon`},build(e,t){for(let n=0;n<e.points.length;n++)t[n]=e.points[n];return t},triangulate(e,t,n,r,i,a){nr(e,rr,t,n,r,i,a)}},ar={extension:{type:U.ShapeBuilder,name:`rectangle`},build(e,t){let n=e,r=n.x,i=n.y,a=n.width,o=n.height;return a>=0&&o>=0?(t[0]=r,t[1]=i,t[2]=r+a,t[3]=i,t[4]=r+a,t[5]=i+o,t[6]=r,t[7]=i+o,t):t},triangulate(e,t,n,r,i,a){let o=0;r*=n,t[r+o]=e[0],t[r+o+1]=e[1],o+=n,t[r+o]=e[2],t[r+o+1]=e[3],o+=n,t[r+o]=e[6],t[r+o+1]=e[7],o+=n,t[r+o]=e[4],t[r+o+1]=e[5],o+=n;let s=r/n;i[a++]=s,i[a++]=s+1,i[a++]=s+2,i[a++]=s+1,i[a++]=s+3,i[a++]=s+2}},or={extension:{type:U.ShapeBuilder,name:`triangle`},build(e,t){return t[0]=e.x,t[1]=e.y,t[2]=e.x2,t[3]=e.y2,t[4]=e.x3,t[5]=e.y3,t},triangulate(e,t,n,r,i,a){let o=0;r*=n,t[r+o]=e[0],t[r+o+1]=e[1],o+=n,t[r+o]=e[2],t[r+o+1]=e[3],o+=n,t[r+o]=e[4],t[r+o+1]=e[5];let s=r/n;i[a++]=s,i[a++]=s+1,i[a++]=s+2}},sr={};Pe.handleByMap(U.ShapeBuilder,sr),Pe.add(ar,ir,or,Kn,qn,Jn);var cr=new be;function lr(e,t){let{geometryData:n,batches:r}=t;r.length=0,n.indices.length=0,n.vertices.length=0,n.uvs.length=0;for(let t=0;t<e.instructions.length;t++){let i=e.instructions[t];if(i.action===`texture`)ur(i.data,r,n);else if(i.action===`fill`||i.action===`stroke`){let e=i.action===`stroke`,t=i.data.path.shapePath,a=i.data.style,o=i.data.hole;e&&o&&dr(o.shapePath,a,null,!0,r,n),dr(t,a,o,e,r,n)}}}function ur(e,t,n){let{vertices:r,uvs:i,indices:a}=n,o=a.length,s=r.length/2,c=[],l=sr.rectangle,u=cr,d=e.image;u.x=e.dx,u.y=e.dy,u.width=e.dw,u.height=e.dh;let f=e.transform;l.build(u,c),f&&Un(c,f),l.triangulate(c,r,2,s,a,o);let p=d.uvs;i.push(p.x0,p.y0,p.x1,p.y1,p.x3,p.y3,p.x2,p.y2);let m=G.get(Gn);m.indexOffset=o,m.indexSize=a.length-o,m.vertexOffset=s,m.vertexSize=r.length/2-s,m.color=e.style,m.alpha=e.alpha,m.texture=d,m.geometryData=n,t.push(m)}function dr(e,t,n,r,i,a){let{vertices:o,uvs:s,indices:c}=a,l=e.shapePrimitives.length-1;e.shapePrimitives.forEach(({shape:e,transform:u},d)=>{let f=c.length,p=o.length/2,m=[],h=sr[e.type];if(h.build(e,m),u&&Un(m,u),r)er(m,t,!1,e.closePath??!0,o,2,p,c,f);else if(n&&l===d){l!==0&&console.warn(`[Pixi Graphics] only the last shape have be cut out`);let e=[],t=m.slice();fr(n.shapePath).forEach(n=>{e.push(t.length/2),t.push(...n)}),nr(t,e,o,2,p,c,f)}else h.triangulate(m,o,2,p,c,f);let g=s.length/2,_=t.texture;if(_!==R.WHITE){let e=t.matrix;e&&(u&&e.append(u.clone().invert()),Vn(o,2,p,s,g,2,o.length/2-p,e))}else Hn(s,g,2,o.length/2-p);let v=G.get(Gn);v.indexOffset=f,v.indexSize=c.length-f,v.vertexOffset=p,v.vertexSize=o.length/2-p,v.color=t.color,v.alpha=t.alpha,v.texture=_,v.geometryData=a,i.push(v)})}function fr(e){if(!e)return[];let t=e.shapePrimitives,n=[];for(let e=0;e<t.length;e++){let r=t[e].shape,i=[];sr[r.type].build(r,i),n.push(i)}return n}var pr=class{constructor(){this.batcher=new N,this.batches=[],this.geometryData={vertices:[],uvs:[],indices:[]}}},mr=class{constructor(){this.geometry=new M,this.instructions=new Fe}init(){this.instructions.reset()}},hr=class e{constructor(){this._gpuContextHash={},this._graphicsDataContextHash=Object.create(null)}init(t){e.defaultOptions.bezierSmoothness=t?.bezierSmoothness??e.defaultOptions.bezierSmoothness}getContextRenderData(e){return this._graphicsDataContextHash[e.uid]||this._initContextRenderData(e)}updateGpuContext(e){let t=this._gpuContextHash[e.uid]||this._initContext(e);if(e.dirty){t?this._cleanGraphicsContextData(e):t=this._initContext(e),lr(e,t);let n=e.batchMode;e.customShader||n===`no-batch`?t.isBatchable=!1:n===`auto`&&(t.isBatchable=t.geometryData.vertices.length<400),e.dirty=!1}return t}getGpuContext(e){return this._gpuContextHash[e.uid]||this._initContext(e)}_initContextRenderData(e){let t=G.get(mr),{batches:n,geometryData:r,batcher:i}=this._gpuContextHash[e.uid],a=r.vertices.length,o=r.indices.length;for(let e=0;e<n.length;e++)n[e].applyTransform=!1;i.ensureAttributeBuffer(a),i.ensureIndexBuffer(o),i.begin();for(let e=0;e<n.length;e++){let t=n[e];i.add(t)}i.finish(t.instructions);let s=t.geometry;s.indexBuffer.setDataWithSize(i.indexBuffer,i.indexSize,!0),s.buffers[0].setDataWithSize(i.attributeBuffer.float32View,i.attributeSize,!0);let c=i.batches;for(let e=0;e<c.length;e++){let t=c[e];t.bindGroup=Ke(t.textures.textures,t.textures.count)}return this._graphicsDataContextHash[e.uid]=t,t}_initContext(e){let t=new pr;return t.context=e,this._gpuContextHash[e.uid]=t,e.on(`destroy`,this.onGraphicsContextDestroy,this),this._gpuContextHash[e.uid]}onGraphicsContextDestroy(e){this._cleanGraphicsContextData(e),e.off(`destroy`,this.onGraphicsContextDestroy,this),this._gpuContextHash[e.uid]=null}_cleanGraphicsContextData(e){let t=this._gpuContextHash[e.uid];t.isBatchable||this._graphicsDataContextHash[e.uid]&&(G.return(this.getContextRenderData(e)),this._graphicsDataContextHash[e.uid]=null),t.batches&&t.batches.forEach(e=>{G.return(e)})}destroy(){for(let e in this._gpuContextHash)this._gpuContextHash[e]&&this.onGraphicsContextDestroy(this._gpuContextHash[e].context)}};hr.extension={type:[U.WebGLSystem,U.WebGPUSystem,U.CanvasSystem],name:`graphicsContext`},hr.defaultOptions={bezierSmoothness:.5};var gr=hr,_r=class{constructor(e,t){this.state=ce.for2d(),this._graphicsBatchesHash=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this.renderer=e,this._adaptor=t,this._adaptor.init()}validateRenderable(e){let t=e.context,n=!!this._graphicsBatchesHash[e.uid],r=this.renderer.graphicsContext.updateGpuContext(t);return!!(r.isBatchable||n!==r.isBatchable)}addRenderable(e,t){let n=this.renderer.graphicsContext.updateGpuContext(e.context);e._didGraphicsUpdate&&(e._didGraphicsUpdate=!1,this._rebuild(e)),n.isBatchable?this._addToBatcher(e):(this.renderer.renderPipes.batch.break(t),t.add(e))}updateRenderable(e){let t=this._graphicsBatchesHash[e.uid];if(t)for(let e=0;e<t.length;e++){let n=t[e];n.batcher.updateElement(n)}}destroyRenderable(e){this._graphicsBatchesHash[e.uid]&&this._removeBatchForRenderable(e.uid),e.off(`destroyed`,this._destroyRenderableBound)}execute(e){if(!e.isRenderable)return;let t=this.renderer,n=e.context;if(!t.graphicsContext.getGpuContext(n).batches.length)return;let r=n.customShader||this._adaptor.shader;this.state.blendMode=e.groupBlendMode;let i=r.resources.localUniforms.uniforms;i.uTransformMatrix=e.groupTransform,i.uRound=t._roundPixels|e._roundPixels,Ue(e.groupColorAlpha,i.uColor,0),this._adaptor.execute(this,e)}_rebuild(e){let t=!!this._graphicsBatchesHash[e.uid],n=this.renderer.graphicsContext.updateGpuContext(e.context);t&&this._removeBatchForRenderable(e.uid),n.isBatchable&&this._initBatchesForRenderable(e),e.batched=n.isBatchable}_addToBatcher(e){let t=this.renderer.renderPipes.batch,n=this._getBatchesForRenderable(e);for(let e=0;e<n.length;e++){let r=n[e];t.addToBatch(r)}}_getBatchesForRenderable(e){return this._graphicsBatchesHash[e.uid]||this._initBatchesForRenderable(e)}_initBatchesForRenderable(e){let t=e.context,n=this.renderer.graphicsContext.getGpuContext(t),r=this.renderer._roundPixels|e._roundPixels,i=n.batches.map(t=>{let n=G.get(Gn);return t.copyTo(n),n.renderable=e,n.roundPixels=r,n});return this._graphicsBatchesHash[e.uid]===void 0&&e.on(`destroyed`,this._destroyRenderableBound),this._graphicsBatchesHash[e.uid]=i,i}_removeBatchForRenderable(e){this._graphicsBatchesHash[e].forEach(e=>{G.return(e)}),this._graphicsBatchesHash[e]=null}destroy(){this.renderer=null,this._adaptor.destroy(),this._adaptor=null,this.state=null;for(let e in this._graphicsBatchesHash)this._removeBatchForRenderable(e);this._graphicsBatchesHash=null}};_r.extension={type:[U.WebGLPipes,U.WebGPUPipes,U.CanvasPipes],name:`graphics`};var vr=class{constructor(){this.batcher=null,this.batch=null,this.roundPixels=0,this._uvUpdateId=-1,this._textureMatrixUpdateId=-1}get blendMode(){return this.mesh.groupBlendMode}reset(){this.mesh=null,this.texture=null,this.batcher=null,this.batch=null,this.geometry=null,this._uvUpdateId=-1,this._textureMatrixUpdateId=-1}packIndex(e,t,n){let r=this.geometry.indices;for(let i=0;i<r.length;i++)e[t++]=r[i]+n}packAttributes(e,t,n,r){let i=this.mesh,a=this.geometry,o=i.groupTransform,s=r<<16|this.roundPixels&65535,c=o.a,l=o.b,u=o.c,d=o.d,f=o.tx,p=o.ty,m=a.positions,h=a.getBuffer(`aUV`),g=h.data,_=g,v=this.texture.textureMatrix;v.isSimple||(_=this._transformedUvs,(this._textureMatrixUpdateId!==v._updateID||this._uvUpdateId!==h._updateID)&&((!_||_.length<g.length)&&(_=this._transformedUvs=new Float32Array(g.length)),this._textureMatrixUpdateId=v._updateID,this._uvUpdateId=h._updateID,v.multiplyUvs(g,_)));let y=i.groupColorAlpha;for(let r=0;r<m.length;r+=2){let i=m[r],a=m[r+1];e[n]=c*i+u*a+f,e[n+1]=l*i+d*a+p,e[n+2]=_[r],e[n+3]=_[r+1],t[n+4]=y,t[n+5]=s,n+=6}}get vertexSize(){return this.geometry.positions.length/2}get indexSize(){return this.geometry.indices.length}},yr=class{constructor(e,t){this.localUniforms=new We({uTransformMatrix:{value:new H,type:`mat3x3<f32>`},uColor:{value:new Float32Array([1,1,1,1]),type:`vec4<f32>`},uRound:{value:0,type:`f32`}}),this.localUniformsBindGroup=new re({0:this.localUniforms}),this._meshDataHash=Object.create(null),this._gpuBatchableMeshHash=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this.renderer=e,this._adaptor=t,this._adaptor.init()}validateRenderable(e){let t=this._getMeshData(e),n=t.batched,r=e.batched;if(t.batched=r,n!==r)return!0;if(r){let n=e._geometry;if(n.indices.length!==t.indexSize||n.positions.length!==t.vertexSize)return t.indexSize=n.indices.length,t.vertexSize=n.positions.length,!0;let r=this._getBatchableMesh(e),i=e.texture;if(r.texture._source!==i._source&&r.texture._source!==i._source)return!r.batcher.checkAndUpdateTexture(r,i)}return!1}addRenderable(e,t){let n=this.renderer.renderPipes.batch,{batched:r}=this._getMeshData(e);if(r){let t=this._getBatchableMesh(e);t.texture=e._texture,t.geometry=e._geometry,n.addToBatch(t)}else n.break(t),t.add(e)}updateRenderable(e){if(e.batched){let t=this._gpuBatchableMeshHash[e.uid];t.texture=e._texture,t.geometry=e._geometry,t.batcher.updateElement(t)}}destroyRenderable(e){this._meshDataHash[e.uid]=null;let t=this._gpuBatchableMeshHash[e.uid];t&&(G.return(t),this._gpuBatchableMeshHash[e.uid]=null),e.off(`destroyed`,this._destroyRenderableBound)}execute(e){if(!e.isRenderable)return;e.state.blendMode=ae(e.groupBlendMode,e.texture._source);let t=this.localUniforms;t.uniforms.uTransformMatrix=e.groupTransform,t.uniforms.uRound=this.renderer._roundPixels|e._roundPixels,t.update(),Ue(e.groupColorAlpha,t.uniforms.uColor,0),this._adaptor.execute(this,e)}_getMeshData(e){return this._meshDataHash[e.uid]||this._initMeshData(e)}_initMeshData(e){return this._meshDataHash[e.uid]={batched:e.batched,indexSize:e._geometry.indices?.length,vertexSize:e._geometry.positions?.length},e.on(`destroyed`,this._destroyRenderableBound),this._meshDataHash[e.uid]}_getBatchableMesh(e){return this._gpuBatchableMeshHash[e.uid]||this._initBatchableMesh(e)}_initBatchableMesh(e){let t=G.get(vr);return t.mesh=e,t.texture=e._texture,t.roundPixels=this.renderer._roundPixels|e._roundPixels,this._gpuBatchableMeshHash[e.uid]=t,t.mesh=e,t}destroy(){for(let e in this._gpuBatchableMeshHash)this._gpuBatchableMeshHash[e]&&G.return(this._gpuBatchableMeshHash[e]);this._gpuBatchableMeshHash=null,this._meshDataHash=null,this.localUniforms=null,this.localUniformsBindGroup=null,this._adaptor.destroy(),this._adaptor=null,this.renderer=null}};yr.extension={type:[U.WebGLPipes,U.WebGPUPipes,U.CanvasPipes],name:`mesh`};var br=class{constructor(e){this._gpuText=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this._renderer=e,this._renderer.runners.resolutionChange.add(this)}resolutionChange(){for(let e in this._gpuText){let t=this._gpuText[e].batchableSprite.renderable;t._autoResolution&&(t._resolution=this._renderer.resolution,t.onViewUpdate())}}validateRenderable(e){let t=this._getGpuText(e),n=e._getKey();if(t.currentKey!==n){let{width:n,height:r}=this._renderer.canvasText.getTextureSize(e.text,e.resolution,e._style);return!(this._renderer.canvasText.getReferenceCount(t.currentKey)===1&&n===t.texture._source.width&&r===t.texture._source.height)}return!1}addRenderable(e,t){let n=this._getGpuText(e).batchableSprite;e._didTextUpdate&&this._updateText(e),this._renderer.renderPipes.batch.addToBatch(n)}updateRenderable(e){let t=this._getGpuText(e).batchableSprite;e._didTextUpdate&&this._updateText(e),t.batcher.updateElement(t)}destroyRenderable(e){e.off(`destroyed`,this._destroyRenderableBound),this._destroyRenderableById(e.uid)}_destroyRenderableById(e){let t=this._gpuText[e];this._renderer.canvasText.decreaseReferenceCount(t.currentKey),G.return(t.batchableSprite),this._gpuText[e]=null}_updateText(e){let t=e._getKey(),n=this._getGpuText(e),r=n.batchableSprite;n.currentKey!==t&&this._updateGpuText(e),e._didTextUpdate=!1;let i=e._style.padding;ee(r.bounds,e._anchor,r.texture,i)}_updateGpuText(e){let t=this._getGpuText(e),n=t.batchableSprite;t.texture&&this._renderer.canvasText.decreaseReferenceCount(t.currentKey),t.texture=n.texture=this._renderer.canvasText.getManagedTexture(e),t.currentKey=e._getKey(),n.texture=t.texture}_getGpuText(e){return this._gpuText[e.uid]||this.initGpuText(e)}initGpuText(e){let t={texture:null,currentKey:`--`,batchableSprite:G.get(Ve)};return t.batchableSprite.renderable=e,t.batchableSprite.bounds={minX:0,maxX:1,minY:0,maxY:0},t.batchableSprite.roundPixels=this._renderer._roundPixels|e._roundPixels,this._gpuText[e.uid]=t,e._resolution=e._autoResolution?this._renderer.resolution:e.resolution,this._updateText(e),e.on(`destroyed`,this._destroyRenderableBound),t}destroy(){for(let e in this._gpuText)this._destroyRenderableById(e);this._gpuText=null,this._renderer=null}};br.extension={type:[U.WebGLPipes,U.WebGPUPipes,U.CanvasPipes],name:`text`};function xr(e,t,n){for(let r=0,i=4*n*t;r<t;++r,i+=4)if(e[i+3]!==0)return!1;return!0}function Sr(e,t,n,r,i){let a=4*t;for(let t=r,o=r*a+4*n;t<=i;++t,o+=a)if(e[o+3]!==0)return!1;return!0}function Cr(e,t=1){let{width:n,height:r}=e,i=e.getContext(`2d`,{willReadFrequently:!0});if(i===null)throw TypeError(`Failed to get canvas 2D context`);let a=i.getImageData(0,0,n,r).data,o=0,s=0,c=n-1,l=r-1;for(;s<r&&xr(a,n,s);)++s;if(s===r)return be.EMPTY;for(;xr(a,n,l);)--l;for(;Sr(a,n,o,s,l);)++o;for(;Sr(a,n,c,s,l);)--c;return++c,++l,new be(o/t,s/t,(c-o)/t,(l-s)/t)}var wr=class e{constructor(e,t,n,r){this.uid=Me(`fillGradient`),this.type=`linear`,this.gradientStops=[],this._styleKey=null,this.x0=e,this.y0=t,this.x1=n,this.y1=r}addColorStop(e,t){return this.gradientStops.push({offset:e,color:K.shared.setValue(t).toHexa()}),this._styleKey=null,this}buildLinearGradient(){let t=e.defaultTextureSize,{gradientStops:n}=this,r=z.get().createCanvas();r.width=t,r.height=t;let i=r.getContext(`2d`),a=i.createLinearGradient(0,0,e.defaultTextureSize,1);for(let e=0;e<n.length;e++){let t=n[e];a.addColorStop(t.offset,t.color)}i.fillStyle=a,i.fillRect(0,0,t,t),this.texture=new R({source:new jn({resource:r,addressModeU:`clamp-to-edge`,addressModeV:`repeat`})});let{x0:o,y0:s,x1:c,y1:l}=this,u=new H,d=c-o,f=l-s,p=Math.sqrt(d*d+f*f),m=Math.atan2(f,d);u.translate(-o,-s),u.scale(1/t,1/t),u.rotate(-m),u.scale(256/p,1),this.transform=u,this._styleKey=null}get styleKey(){if(this._styleKey)return this._styleKey;let e=this.gradientStops.map(e=>`${e.offset}-${e.color}`).join(`-`),t=this.texture.uid,n=this.transform.toArray().join(`-`);return`fill-gradient-${this.uid}-${e}-${t}-${n}-${this.x0}-${this.y0}-${this.x1}-${this.y1}`}};wr.defaultTextureSize=256;var Tr=wr,Er={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`}},Dr=class{constructor(e,t){this.uid=Me(`fillPattern`),this.transform=new H,this._styleKey=null,this.texture=e,this.transform.scale(1/e.frame.width,1/e.frame.height),t&&(e.source.style.addressModeU=Er[t].addressModeU,e.source.style.addressModeV=Er[t].addressModeV)}setTransform(e){let t=this.texture;this.transform.copyFrom(e),this.transform.invert(),this.transform.scale(1/t.frame.width,1/t.frame.height),this._styleKey=null}get styleKey(){return this._styleKey||=`fill-pattern-${this.uid}-${this.texture.uid}-${this.transform.toArray().join(`-`)}`,this._styleKey}},Or=t(n(((e,t)=>{t.exports=i;var n={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},r=/([astvzqmhlc])([^astvzqmhlc]*)/gi;function i(e){var t=[];return e.replace(r,function(e,r,i){var a=r.toLowerCase();for(i=o(i),a==`m`&&i.length>2&&(t.push([r].concat(i.splice(0,2))),a=`l`,r=r==`m`?`l`:`L`);;){if(i.length==n[a])return i.unshift(r),t.push(i);if(i.length<n[a])throw Error(`malformed path data`);t.push([r].concat(i.splice(0,n[a])))}}),t}var a=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/gi;function o(e){var t=e.match(a);return t?t.map(Number):[]}}))(),1);function kr(e,t){let n=(0,Or.default)(e),r=[],i=null,a=0,o=0;for(let e=0;e<n.length;e++){let s=n[e],c=s[0],l=s;switch(c){case`M`:a=l[1],o=l[2],t.moveTo(a,o);break;case`m`:a+=l[1],o+=l[2],t.moveTo(a,o);break;case`H`:a=l[1],t.lineTo(a,o);break;case`h`:a+=l[1],t.lineTo(a,o);break;case`V`:o=l[1],t.lineTo(a,o);break;case`v`:o+=l[1],t.lineTo(a,o);break;case`L`:a=l[1],o=l[2],t.lineTo(a,o);break;case`l`:a+=l[1],o+=l[2],t.lineTo(a,o);break;case`C`:a=l[5],o=l[6],t.bezierCurveTo(l[1],l[2],l[3],l[4],a,o);break;case`c`:t.bezierCurveTo(a+l[1],o+l[2],a+l[3],o+l[4],a+l[5],o+l[6]),a+=l[5],o+=l[6];break;case`S`:a=l[3],o=l[4],t.bezierCurveToShort(l[1],l[2],a,o);break;case`s`:t.bezierCurveToShort(a+l[1],o+l[2],a+l[3],o+l[4]),a+=l[3],o+=l[4];break;case`Q`:a=l[3],o=l[4],t.quadraticCurveTo(l[1],l[2],a,o);break;case`q`:t.quadraticCurveTo(a+l[1],o+l[2],a+l[3],o+l[4]),a+=l[3],o+=l[4];break;case`T`:a=l[1],o=l[2],t.quadraticCurveToShort(a,o);break;case`t`:a+=l[1],o+=l[2],t.quadraticCurveToShort(a,o);break;case`A`:a=l[6],o=l[7],t.arcToSvg(l[1],l[2],l[3],l[4],l[5],a,o);break;case`a`:a+=l[6],o+=l[7],t.arcToSvg(l[1],l[2],l[3],l[4],l[5],a,o);break;case`Z`:case`z`:t.closePath(),r.length>0&&(i=r.pop(),i?(a=i.startX,o=i.startY):(a=0,o=0)),i=null;break;default:B(`Unknown SVG path command: ${c}`)}c!==`Z`&&c!==`z`&&i===null&&(i={startX:a,startY:o},r.push(i))}return t}var Ar=class e{constructor(e=0,t=0,n=0){this.type=`circle`,this.x=e,this.y=t,this.radius=n}clone(){return new e(this.x,this.y,this.radius)}contains(e,t){if(this.radius<=0)return!1;let n=this.radius*this.radius,r=this.x-e,i=this.y-t;return r*=r,i*=i,r+i<=n}strokeContains(e,t,n){if(this.radius===0)return!1;let r=this.x-e,i=this.y-t,a=this.radius,o=n/2,s=Math.sqrt(r*r+i*i);return s<a+o&&s>a-o}getBounds(e){return e||=new be,e.x=this.x-this.radius,e.y=this.y-this.radius,e.width=this.radius*2,e.height=this.radius*2,e}copyFrom(e){return this.x=e.x,this.y=e.y,this.radius=e.radius,this}copyTo(e){return e.copyFrom(this),e}toString(){return`[pixi.js/math:Circle x=${this.x} y=${this.y} radius=${this.radius}]`}},jr=class e{constructor(e=0,t=0,n=0,r=0){this.type=`ellipse`,this.x=e,this.y=t,this.halfWidth=n,this.halfHeight=r}clone(){return new e(this.x,this.y,this.halfWidth,this.halfHeight)}contains(e,t){if(this.halfWidth<=0||this.halfHeight<=0)return!1;let n=(e-this.x)/this.halfWidth,r=(t-this.y)/this.halfHeight;return n*=n,r*=r,n+r<=1}strokeContains(e,t,n){let{halfWidth:r,halfHeight:i}=this;if(r<=0||i<=0)return!1;let a=n/2,o=r-a,s=i-a,c=r+a,l=i+a,u=e-this.x,d=t-this.y,f=u*u/(o*o)+d*d/(s*s),p=u*u/(c*c)+d*d/(l*l);return f>1&&p<=1}getBounds(e){return e||=new be,e.x=this.x-this.halfWidth,e.y=this.y-this.halfHeight,e.width=this.halfWidth*2,e.height=this.halfHeight*2,e}copyFrom(e){return this.x=e.x,this.y=e.y,this.halfWidth=e.halfWidth,this.halfHeight=e.halfHeight,this}copyTo(e){return e.copyFrom(this),e}toString(){return`[pixi.js/math:Ellipse x=${this.x} y=${this.y} halfWidth=${this.halfWidth} halfHeight=${this.halfHeight}]`}};function Mr(e,t,n,r,i,a){let o=e-n,s=t-r,c=i-n,l=a-r,u=o*c+s*l,d=c*c+l*l,f=-1;d!==0&&(f=u/d);let p,m;f<0?(p=n,m=r):f>1?(p=i,m=a):(p=n+f*c,m=r+f*l);let h=e-p,g=t-m;return h*h+g*g}var Nr=class e{constructor(...e){this.type=`polygon`;let t=Array.isArray(e[0])?e[0]:e;if(typeof t[0]!=`number`){let e=[];for(let n=0,r=t.length;n<r;n++)e.push(t[n].x,t[n].y);t=e}this.points=t,this.closePath=!0}clone(){let t=new e(this.points.slice());return t.closePath=this.closePath,t}contains(e,t){let n=!1,r=this.points.length/2;for(let i=0,a=r-1;i<r;a=i++){let r=this.points[i*2],o=this.points[i*2+1],s=this.points[a*2],c=this.points[a*2+1];o>t!=c>t&&e<(s-r)*((t-o)/(c-o))+r&&(n=!n)}return n}strokeContains(e,t,n){let r=n/2,i=r*r,{points:a}=this,o=a.length-(this.closePath?0:2);for(let n=0;n<o;n+=2){let r=a[n],o=a[n+1],s=a[(n+2)%a.length],c=a[(n+3)%a.length];if(Mr(e,t,r,o,s,c)<=i)return!0}return!1}getBounds(e){e||=new be;let t=this.points,n=1/0,r=-1/0,i=1/0,a=-1/0;for(let e=0,o=t.length;e<o;e+=2){let o=t[e],s=t[e+1];n=o<n?o:n,r=o>r?o:r,i=s<i?s:i,a=s>a?s:a}return e.x=n,e.width=r-n,e.y=i,e.height=a-i,e}copyFrom(e){return this.points=e.points.slice(),this.closePath=e.closePath,this}copyTo(e){return e.copyFrom(this),e}toString(){return`[pixi.js/math:PolygoncloseStroke=${this.closePath}points=${this.points.reduce((e,t)=>`${e}, ${t}`,``)}]`}get lastX(){return this.points[this.points.length-2]}get lastY(){return this.points[this.points.length-1]}get x(){return this.points[this.points.length-2]}get y(){return this.points[this.points.length-1]}},Pr=(e,t,n,r,i,a)=>{let o=e-n,s=t-r,c=Math.sqrt(o*o+s*s);return c>=i-a&&c<=i+a},Fr=class e{constructor(e=0,t=0,n=0,r=0,i=20){this.type=`roundedRectangle`,this.x=e,this.y=t,this.width=n,this.height=r,this.radius=i}getBounds(e){return e||=new be,e.x=this.x,e.y=this.y,e.width=this.width,e.height=this.height,e}clone(){return new e(this.x,this.y,this.width,this.height,this.radius)}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){if(this.width<=0||this.height<=0)return!1;if(e>=this.x&&e<=this.x+this.width&&t>=this.y&&t<=this.y+this.height){let n=Math.max(0,Math.min(this.radius,Math.min(this.width,this.height)/2));if(t>=this.y+n&&t<=this.y+this.height-n||e>=this.x+n&&e<=this.x+this.width-n)return!0;let r=e-(this.x+n),i=t-(this.y+n),a=n*n;if(r*r+i*i<=a||(r=e-(this.x+this.width-n),r*r+i*i<=a)||(i=t-(this.y+this.height-n),r*r+i*i<=a)||(r=e-(this.x+n),r*r+i*i<=a))return!0}return!1}strokeContains(e,t,n){let{x:r,y:i,width:a,height:o,radius:s}=this,c=n/2,l=r+s,u=i+s,d=a-s*2,f=o-s*2,p=r+a,m=i+o;return(e>=r-c&&e<=r+c||e>=p-c&&e<=p+c)&&t>=u&&t<=u+f||(t>=i-c&&t<=i+c||t>=m-c&&t<=m+c)&&e>=l&&e<=l+d?!0:e<l&&t<u&&Pr(e,t,l,u,s,c)||e>p-s&&t<u&&Pr(e,t,p-s,u,s,c)||e>p-s&&t>m-s&&Pr(e,t,p-s,m-s,s,c)||e<l&&t>m-s&&Pr(e,t,l,m-s,s,c)}toString(){return`[pixi.js/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`}},Ir=8,Lr=1.1920929e-7,Rr=1;function zr(e,t,n,r,i,a,o,s,c,l){let u=(Rr-Math.min(.99,Math.max(0,l??gr.defaultOptions.bezierSmoothness)))/1;return u*=u,Br(t,n,r,i,a,o,s,c,e,u),e}function Br(e,t,n,r,i,a,o,s,c,l){Vr(e,t,n,r,i,a,o,s,c,l,0),c.push(o,s)}function Vr(e,t,n,r,i,a,o,s,c,l,u){if(u>Ir)return;let d=(e+n)/2,f=(t+r)/2,p=(n+i)/2,m=(r+a)/2,h=(i+o)/2,g=(a+s)/2,_=(d+p)/2,v=(f+m)/2,y=(p+h)/2,b=(m+g)/2,x=(_+y)/2,S=(v+b)/2;if(u>0){let u=o-e,d=s-t,f=Math.abs((n-o)*d-(r-s)*u),p=Math.abs((i-o)*d-(a-s)*u);if(f>Lr&&p>Lr){if((f+p)*(f+p)<=l*(u*u+d*d)){c.push(x,S);return}}else if(f>Lr){if(f*f<=l*(u*u+d*d)){c.push(x,S);return}}else if(p>Lr){if(p*p<=l*(u*u+d*d)){c.push(x,S);return}}else if(u=x-(e+o)/2,d=S-(t+s)/2,u*u+d*d<=l){c.push(x,S);return}}Vr(e,t,d,f,_,v,x,S,c,l,u+1),Vr(x,S,y,b,h,g,o,s,c,l,u+1)}var Hr=8,Ur=1.1920929e-7,Wr=1;function Gr(e,t,n,r,i,a,o,s){let c=(Wr-Math.min(.99,Math.max(0,s??gr.defaultOptions.bezierSmoothness)))/1;return c*=c,Kr(t,n,r,i,a,o,e,c),e}function Kr(e,t,n,r,i,a,o,s){qr(o,e,t,n,r,i,a,s,0),o.push(i,a)}function qr(e,t,n,r,i,a,o,s,c){if(c>Hr)return;let l=(t+r)/2,u=(n+i)/2,d=(r+a)/2,f=(i+o)/2,p=(l+d)/2,m=(u+f)/2,h=a-t,g=o-n,_=Math.abs((r-a)*g-(i-o)*h);if(_>Ur){if(_*_<=s*(h*h+g*g)){e.push(p,m);return}}else if(h=p-(t+a)/2,g=m-(n+o)/2,h*h+g*g<=s){e.push(p,m);return}qr(e,t,n,l,u,p,m,s,c+1),qr(e,p,m,d,f,a,o,s,c+1)}function Jr(e,t,n,r,i,a,o,s){let c=Math.abs(i-a);(!o&&i>a||o&&a>i)&&(c=2*Math.PI-c),s||=Math.max(6,Math.floor(6*r**(1/3)*(c/Math.PI))),s=Math.max(s,3);let l=c/s,u=i;l*=o?-1:1;for(let i=0;i<s+1;i++){let i=Math.cos(u),a=Math.sin(u),o=t+i*r,s=n+a*r;e.push(o,s),u+=l}}function Yr(e,t,n,r,i,a){let o=e[e.length-2],s=e[e.length-1]-n,c=o-t,l=i-n,u=r-t,d=Math.abs(s*u-c*l);if(d<1e-8||a===0){(e[e.length-2]!==t||e[e.length-1]!==n)&&e.push(t,n);return}let f=s*s+c*c,p=l*l+u*u,m=s*l+c*u,h=a*Math.sqrt(f)/d,g=a*Math.sqrt(p)/d,_=h*m/f,v=g*m/p,y=h*u+g*c,b=h*l+g*s,x=c*(g+_),S=s*(g+_),C=u*(h+v),w=l*(h+v),T=Math.atan2(S-b,x-y),E=Math.atan2(w-b,C-y);Jr(e,y+t,b+n,a,T,E,c*l>u*s)}var Xr=Math.PI*2,Zr={centerX:0,centerY:0,ang1:0,ang2:0},Qr=({x:e,y:t},n,r,i,a,o,s,c)=>{e*=n,t*=r;let l=i*e-a*t,u=a*e+i*t;return c.x=l+o,c.y=u+s,c};function $r(e,t){let n=t===-1.5707963267948966?-.551915024494:4/3*Math.tan(t/4),r=t===1.5707963267948966?.551915024494:n,i=Math.cos(e),a=Math.sin(e),o=Math.cos(e+t),s=Math.sin(e+t);return[{x:i-a*r,y:a+i*r},{x:o+s*r,y:s-o*r},{x:o,y:s}]}var ei=(e,t,n,r)=>{let i=e*r-t*n<0?-1:1,a=e*n+t*r;return a>1&&(a=1),a<-1&&(a=-1),i*Math.acos(a)},ti=(e,t,n,r,i,a,o,s,c,l,u,d,f)=>{let p=i**2,m=a**2,h=u**2,g=d**2,_=p*m-p*g-m*h;_<0&&(_=0),_/=p*g+m*h,_=Math.sqrt(_)*(o===s?-1:1);let v=_*i/a*d,y=_*-a/i*u,b=l*v-c*y+(e+n)/2,x=c*v+l*y+(t+r)/2,S=(u-v)/i,C=(d-y)/a,w=(-u-v)/i,T=(-d-y)/a,E=ei(1,0,S,C),D=ei(S,C,w,T);s===0&&D>0&&(D-=Xr),s===1&&D<0&&(D+=Xr),f.centerX=b,f.centerY=x,f.ang1=E,f.ang2=D};function ni(e,t,n,r,i,a,o,s=0,c=0,l=0){if(a===0||o===0)return;let u=Math.sin(s*Xr/360),d=Math.cos(s*Xr/360),f=d*(t-r)/2+u*(n-i)/2,p=-u*(t-r)/2+d*(n-i)/2;if(f===0&&p===0)return;a=Math.abs(a),o=Math.abs(o);let m=f**2/a**2+p**2/o**2;m>1&&(a*=Math.sqrt(m),o*=Math.sqrt(m)),ti(t,n,r,i,a,o,c,l,u,d,f,p,Zr);let{ang1:h,ang2:g}=Zr,{centerX:_,centerY:v}=Zr,y=Math.abs(g)/(Xr/4);Math.abs(1-y)<1e-7&&(y=1);let b=Math.max(Math.ceil(y),1);g/=b;let x=e[e.length-2],S=e[e.length-1],C={x:0,y:0};for(let t=0;t<b;t++){let t=$r(h,g),{x:n,y:r}=Qr(t[0],a,o,d,u,_,v,C),{x:i,y:s}=Qr(t[1],a,o,d,u,_,v,C),{x:c,y:l}=Qr(t[2],a,o,d,u,_,v,C);zr(e,x,S,n,r,i,s,c,l),x=c,S=l,h+=g}}function ri(e,t,n){let r=(e,t)=>{let n=t.x-e.x,r=t.y-e.y,i=Math.sqrt(n*n+r*r);return{len:i,nx:n/i,ny:r/i}},i=(t,n)=>{t===0?e.moveTo(n.x,n.y):e.lineTo(n.x,n.y)},a=t[t.length-1];for(let o=0;o<t.length;o++){let s=t[o%t.length],c=s.radius??n;if(c<=0){i(o,s),a=s;continue}let l=t[(o+1)%t.length],u=r(s,a),d=r(s,l);if(u.len<1e-4||d.len<1e-4){i(o,s),a=s;continue}let f=Math.asin(u.nx*d.ny-u.ny*d.nx),p=1,m=!1;u.nx*d.nx-u.ny*-d.ny<0?f<0?f=Math.PI+f:(f=Math.PI-f,p=-1,m=!0):f>0&&(p=-1,m=!0);let h=f/2,g,_=Math.abs(Math.cos(h)*c/Math.sin(h));_>Math.min(u.len/2,d.len/2)?(_=Math.min(u.len/2,d.len/2),g=Math.abs(_*Math.sin(h)/Math.cos(h))):g=c;let v=s.x+d.nx*_+-d.ny*g*p,y=s.y+d.ny*_+d.nx*g*p,b=Math.atan2(u.ny,u.nx)+Math.PI/2*p,x=Math.atan2(d.ny,d.nx)-Math.PI/2*p;o===0&&e.moveTo(v+Math.cos(b)*g,y+Math.sin(b)*g),e.arc(v,y,g,b,x,m),a=s}}function ii(e,t,n,r){let i=(e,t)=>Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2),a=(e,t,n)=>({x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}),o=t.length;for(let s=0;s<o;s++){let c=t[(s+1)%o],l=c.radius??n;if(l<=0){s===0?e.moveTo(c.x,c.y):e.lineTo(c.x,c.y);continue}let u=t[s],d=t[(s+2)%o],f=i(u,c),p;p=f<1e-4?c:a(c,u,Math.min(f/2,l)/f);let m=i(d,c),h;h=m<1e-4?c:a(c,d,Math.min(m/2,l)/m),s===0?e.moveTo(p.x,p.y):e.lineTo(p.x,p.y),e.quadraticCurveTo(c.x,c.y,h.x,h.y,r)}}var ai=new be,oi=class{constructor(e){this.shapePrimitives=[],this._currentPoly=null,this._bounds=new k,this._graphicsPath2D=e}moveTo(e,t){return this.startPoly(e,t),this}lineTo(e,t){this._ensurePoly();let n=this._currentPoly.points,r=n[n.length-2],i=n[n.length-1];return(r!==e||i!==t)&&n.push(e,t),this}arc(e,t,n,r,i,a){this._ensurePoly(!1);let o=this._currentPoly.points;return Jr(o,e,t,n,r,i,a),this}arcTo(e,t,n,r,i){this._ensurePoly();let a=this._currentPoly.points;return Yr(a,e,t,n,r,i),this}arcToSvg(e,t,n,r,i,a,o){let s=this._currentPoly.points;return ni(s,this._currentPoly.lastX,this._currentPoly.lastY,a,o,e,t,n,r,i),this}bezierCurveTo(e,t,n,r,i,a,o){this._ensurePoly();let s=this._currentPoly;return zr(this._currentPoly.points,s.lastX,s.lastY,e,t,n,r,i,a,o),this}quadraticCurveTo(e,t,n,r,i){this._ensurePoly();let a=this._currentPoly;return Gr(this._currentPoly.points,a.lastX,a.lastY,e,t,n,r,i),this}closePath(){return this.endPoly(!0),this}addPath(e,t){this.endPoly(),t&&!t.isIdentity()&&(e=e.clone(!0),e.transform(t));for(let t=0;t<e.instructions.length;t++){let n=e.instructions[t];this[n.action](...n.data)}return this}finish(e=!1){this.endPoly(e)}rect(e,t,n,r,i){return this.drawShape(new be(e,t,n,r),i),this}circle(e,t,n,r){return this.drawShape(new Ar(e,t,n),r),this}poly(e,t,n){let r=new Nr(e);return r.closePath=t,this.drawShape(r,n),this}regularPoly(e,t,n,r,i=0,a){r=Math.max(r|0,3);let o=-1*Math.PI/2+i,s=Math.PI*2/r,c=[];for(let i=0;i<r;i++){let r=i*s+o;c.push(e+n*Math.cos(r),t+n*Math.sin(r))}return this.poly(c,!0,a),this}roundPoly(e,t,n,r,i,a=0,o){if(r=Math.max(r|0,3),i<=0)return this.regularPoly(e,t,n,r,a);let s=n*Math.sin(Math.PI/r)-.001;i=Math.min(i,s);let c=-1*Math.PI/2+a,l=Math.PI*2/r,u=(r-2)*Math.PI/r/2;for(let a=0;a<r;a++){let r=a*l+c,s=e+n*Math.cos(r),d=t+n*Math.sin(r),f=r+Math.PI+u,p=r-Math.PI-u,m=s+i*Math.cos(f),h=d+i*Math.sin(f),g=s+i*Math.cos(p),_=d+i*Math.sin(p);a===0?this.moveTo(m,h):this.lineTo(m,h),this.quadraticCurveTo(s,d,g,_,o)}return this.closePath()}roundShape(e,t,n=!1,r){return e.length<3?this:(n?ii(this,e,t,r):ri(this,e,t),this.closePath())}filletRect(e,t,n,r,i){if(i===0)return this.rect(e,t,n,r);let a=Math.min(n,r)/2,o=Math.min(a,Math.max(-a,i)),s=e+n,c=t+r,l=o<0?-o:0,u=Math.abs(o);return this.moveTo(e,t+u).arcTo(e+l,t+l,e+u,t,u).lineTo(s-u,t).arcTo(s-l,t+l,s,t+u,u).lineTo(s,c-u).arcTo(s-l,c-l,e+n-u,c,u).lineTo(e+u,c).arcTo(e+l,c-l,e,c-u,u).closePath()}chamferRect(e,t,n,r,i,a){if(i<=0)return this.rect(e,t,n,r);let o=Math.min(i,Math.min(n,r)/2),s=e+n,c=t+r,l=[e+o,t,s-o,t,s,t+o,s,c-o,s-o,c,e+o,c,e,c-o,e,t+o];for(let e=l.length-1;e>=2;e-=2)l[e]===l[e-2]&&l[e-1]===l[e-3]&&l.splice(e-1,2);return this.poly(l,!0,a)}ellipse(e,t,n,r,i){return this.drawShape(new jr(e,t,n,r),i),this}roundRect(e,t,n,r,i,a){return this.drawShape(new Fr(e,t,n,r,i),a),this}drawShape(e,t){return this.endPoly(),this.shapePrimitives.push({shape:e,transform:t}),this}startPoly(e,t){let n=this._currentPoly;return n&&this.endPoly(),n=new Nr,n.points.push(e,t),this._currentPoly=n,this}endPoly(e=!1){let 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 Nr,e)){let e=this.shapePrimitives[this.shapePrimitives.length-1];if(e){let t=e.shape.x,n=e.shape.y;if(e.transform&&!e.transform.isIdentity()){let r=e.transform,i=t;t=r.a*t+r.c*n+r.tx,n=r.b*i+r.d*n+r.ty}this._currentPoly.points.push(t,n)}else this._currentPoly.points.push(0,0)}}buildPath(){let e=this._graphicsPath2D;this.shapePrimitives.length=0,this._currentPoly=null;for(let t=0;t<e.instructions.length;t++){let n=e.instructions[t];this[n.action](...n.data)}this.finish()}get bounds(){let e=this._bounds;e.clear();let t=this.shapePrimitives;for(let n=0;n<t.length;n++){let r=t[n],i=r.shape.getBounds(ai);r.transform?e.addRect(i,r.transform):e.addRect(i)}return e}},si=class e{constructor(e){this.instructions=[],this.uid=Me(`graphicsPath`),this._dirty=!0,typeof e==`string`?kr(e,this):this.instructions=e?.slice()??[]}get shapePath(){return this._shapePath||=new oi(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,n,r,i){let a=this.instructions[this.instructions.length-1],o=this.getLastPoint(Oe.shared),s=0,c=0;if(!a||a.action!==`bezierCurveTo`)s=o.x,c=o.y;else{s=a.data[2],c=a.data[3];let e=o.x,t=o.y;s=e+(e-s),c=t+(t-c)}return this.instructions.push({action:`bezierCurveTo`,data:[s,c,e,t,n,r,i]}),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,n){let r=this.instructions[this.instructions.length-1],i=this.getLastPoint(Oe.shared),a=0,o=0;if(!r||r.action!==`quadraticCurveTo`)a=i.x,o=i.y;else{a=r.data[0],o=r.data[1];let e=i.x,t=i.y;a=e+(e-a),o=t+(t-o)}return this.instructions.push({action:`quadraticCurveTo`,data:[a,o,e,t,n]}),this._dirty=!0,this}rect(e,t,n,r,i){return this.instructions.push({action:`rect`,data:[e,t,n,r,i]}),this._dirty=!0,this}circle(e,t,n,r){return this.instructions.push({action:`circle`,data:[e,t,n,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,n,r,i,a,o){i||=r/2;let s=-1*Math.PI/2+a,c=n*2,l=Math.PI*2/c,u=[];for(let n=0;n<c;n++){let a=n%2?i:r,o=n*l+s;u.push(e+a*Math.cos(o),t+a*Math.sin(o))}return this.poly(u,!0,o),this}clone(t=!1){let n=new e;if(!t)n.instructions=this.instructions.slice();else for(let e=0;e<this.instructions.length;e++){let t=this.instructions[e];n.instructions.push({action:t.action,data:t.data.slice()})}return n}clear(){return this.instructions.length=0,this._dirty=!0,this}transform(e){if(e.isIdentity())return this;let t=e.a,n=e.b,r=e.c,i=e.d,a=e.tx,o=e.ty,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0;for(let h=0;h<this.instructions.length;h++){let g=this.instructions[h],_=g.data;switch(g.action){case`moveTo`:case`lineTo`:s=_[0],c=_[1],_[0]=t*s+r*c+a,_[1]=n*s+i*c+o;break;case`bezierCurveTo`:l=_[0],u=_[1],d=_[2],f=_[3],s=_[4],c=_[5],_[0]=t*l+r*u+a,_[1]=n*l+i*u+o,_[2]=t*d+r*f+a,_[3]=n*d+i*f+o,_[4]=t*s+r*c+a,_[5]=n*s+i*c+o;break;case`quadraticCurveTo`:l=_[0],u=_[1],s=_[2],c=_[3],_[0]=t*l+r*u+a,_[1]=n*l+i*u+o,_[2]=t*s+r*c+a,_[3]=n*s+i*c+o;break;case`arcToSvg`:s=_[5],c=_[6],p=_[0],m=_[1],_[0]=t*p+r*m,_[1]=n*p+i*m,_[5]=t*s+r*c+a,_[6]=n*s+i*c+o;break;case`circle`:_[4]=ci(_[3],e);break;case`rect`:_[4]=ci(_[4],e);break;case`ellipse`:_[8]=ci(_[8],e);break;case`roundRect`:_[5]=ci(_[5],e);break;case`addPath`:_[0].transform(e);break;case`poly`:_[2]=ci(_[2],e);break;default:B(`unknown transform action`,g.action);break}}return this._dirty=!0,this}get bounds(){return this.shapePath.bounds}getLastPoint(e){let t=this.instructions.length-1,n=this.instructions[t];if(!n)return e.x=0,e.y=0,e;for(;n.action===`closePath`;){if(t--,t<0)return e.x=0,e.y=0,e;n=this.instructions[t]}switch(n.action){case`moveTo`:case`lineTo`:e.x=n.data[0],e.y=n.data[1];break;case`quadraticCurveTo`:e.x=n.data[2],e.y=n.data[3];break;case`bezierCurveTo`:e.x=n.data[4],e.y=n.data[5];break;case`arc`:case`arcToSvg`:e.x=n.data[5],e.y=n.data[6];break;case`addPath`:n.data[0].getLastPoint(e);break}return e}};function ci(e,t){return e?e.prepend(t):t.clone()}function li(e,t){if(typeof e==`string`){let t=document.createElement(`div`);t.innerHTML=e.trim(),e=t.querySelector(`svg`)}let n={context:t,path:new si};return ui(e,n,null,null),t}function ui(e,t,n,r){let i=e.children,{fillStyle:a,strokeStyle:o}=fi(e);a&&n?n={...n,...a}:a&&(n=a),o&&r?r={...r,...o}:o&&(r=o),t.context.fillStyle=n,t.context.strokeStyle=r;let s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C;switch(e.nodeName.toLowerCase()){case`path`:b=e.getAttribute(`d`),x=new si(b),t.context.path(x),n&&t.context.fill(),r&&t.context.stroke();break;case`circle`:p=di(e,`cx`,0),m=di(e,`cy`,0),h=di(e,`r`,0),t.context.ellipse(p,m,h,h),n&&t.context.fill(),r&&t.context.stroke();break;case`rect`:s=di(e,`x`,0),c=di(e,`y`,0),S=di(e,`width`,0),C=di(e,`height`,0),g=di(e,`rx`,0),_=di(e,`ry`,0),g||_?t.context.roundRect(s,c,S,C,g||_):t.context.rect(s,c,S,C),n&&t.context.fill(),r&&t.context.stroke();break;case`ellipse`:p=di(e,`cx`,0),m=di(e,`cy`,0),g=di(e,`rx`,0),_=di(e,`ry`,0),t.context.beginPath(),t.context.ellipse(p,m,g,_),n&&t.context.fill(),r&&t.context.stroke();break;case`line`:l=di(e,`x1`,0),u=di(e,`y1`,0),d=di(e,`x2`,0),f=di(e,`y2`,0),t.context.beginPath(),t.context.moveTo(l,u),t.context.lineTo(d,f),r&&t.context.stroke();break;case`polygon`:y=e.getAttribute(`points`),v=y.match(/\d+/g).map(e=>parseInt(e,10)),t.context.poly(v,!0),n&&t.context.fill(),r&&t.context.stroke();break;case`polyline`:y=e.getAttribute(`points`),v=y.match(/\d+/g).map(e=>parseInt(e,10)),t.context.poly(v,!1),r&&t.context.stroke();break;case`g`:case`svg`:break;default:console.info(`[SVG parser] <${e.nodeName}> elements unsupported`);break}for(let e=0;e<i.length;e++)ui(i[e],t,n,r)}function di(e,t,n){let r=e.getAttribute(t);return r?Number(r):n}function fi(e){let t=e.getAttribute(`style`),n={},r={},i=!1,a=!1;if(t){let e=t.split(`;`);for(let t=0;t<e.length;t++){let[o,s]=e[t].split(`:`);switch(o){case`stroke`:s!==`none`&&(n.color=K.shared.setValue(s).toNumber(),a=!0);break;case`stroke-width`:n.width=Number(s);break;case`fill`:s!==`none`&&(i=!0,r.color=K.shared.setValue(s).toNumber());break;case`fill-opacity`:r.alpha=Number(s);break;case`stroke-opacity`:n.alpha=Number(s);break;case`opacity`:r.alpha=Number(s),n.alpha=Number(s);break}}}else{let t=e.getAttribute(`stroke`);t&&t!==`none`&&(a=!0,n.color=K.shared.setValue(t).toNumber(),n.width=di(e,`stroke-width`,1));let o=e.getAttribute(`fill`);o&&o!==`none`&&(i=!0,r.color=K.shared.setValue(o).toNumber())}return{strokeStyle:a?n:null,fillStyle:i?r:null}}function pi(e){return K.isColorLike(e)}function mi(e){return e instanceof Dr}function hi(e){return e instanceof Tr}function gi(e,t,n){let r=K.shared.setValue(t??0);return e.color=r.toNumber(),e.alpha=r.alpha===1?n.alpha:r.alpha,e.texture=R.WHITE,{...n,...e}}function _i(e,t,n){return e.fill=t,e.color=16777215,e.texture=t.texture,e.matrix=t.transform,{...n,...e}}function vi(e,t,n){return t.buildLinearGradient(),e.fill=t,e.color=16777215,e.texture=t.texture,e.matrix=t.transform,{...n,...e}}function yi(e,t){let n={...t,...e};if(n.texture){if(n.texture!==R.WHITE){let e=n.matrix?.invert()||new H;e.translate(n.texture.frame.x,n.texture.frame.y),e.scale(1/n.texture.source.width,1/n.texture.source.height),n.matrix=e}let e=n.texture.source.style;e.addressMode===`clamp-to-edge`&&(e.addressMode=`repeat`,e.update())}let r=K.shared.setValue(n.color);return n.alpha*=r.alpha,n.color=r.toNumber(),n.matrix=n.matrix?n.matrix.clone():null,n}function bi(e,t){if(e==null)return null;let n={},r=e;return pi(e)?gi(n,e,t):mi(e)?_i(n,e,t):hi(e)?vi(n,e,t):r.fill&&mi(r.fill)?_i(r,r.fill,t):r.fill&&hi(r.fill)?vi(r,r.fill,t):yi(r,t)}function xi(e,t){let{width:n,alignment:r,miterLimit:i,cap:a,join:o,...s}=t,c=bi(e,s);return c?{width:n,alignment:r,miterLimit:i,cap:a,join:o,...c}:null}var Si=new Oe,Ci=new H,wi=class e extends ye{constructor(){super(...arguments),this.uid=Me(`graphicsContext`),this.dirty=!0,this.batchMode=`auto`,this.instructions=[],this._activePath=new si,this._transform=new H,this._fillStyle={...e.defaultFillStyle},this._strokeStyle={...e.defaultStrokeStyle},this._stateStack=[],this._tick=0,this._bounds=new k,this._boundsDirty=!0}clone(){let t=new e;return t.batchMode=this.batchMode,t.instructions=this.instructions.slice(),t._activePath=this._activePath.clone(),t._transform=this._transform.clone(),t._fillStyle={...this._fillStyle},t._strokeStyle={...this._strokeStyle},t._stateStack=this._stateStack.slice(),t._bounds=this._bounds.clone(),t._boundsDirty=!0,t}get fillStyle(){return this._fillStyle}set fillStyle(t){this._fillStyle=bi(t,e.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(t){this._strokeStyle=xi(t,e.defaultStrokeStyle)}setFillStyle(t){return this._fillStyle=bi(t,e.defaultFillStyle),this}setStrokeStyle(t){return this._strokeStyle=bi(t,e.defaultStrokeStyle),this}texture(e,t,n,r,i,a){return this.instructions.push({action:`texture`,data:{image:e,dx:n||0,dy:r||0,dw:i||e.frame.width,dh:a||e.frame.height,transform:this._transform.clone(),alpha:this._fillStyle.alpha,style:t?K.shared.setValue(t).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new si,this}fill(t,n){let r,i=this.instructions[this.instructions.length-1];return r=this._tick===0&&i&&i.action===`stroke`?i.data.path:this._activePath.clone(),r?(t!=null&&(n!==void 0&&typeof t==`number`&&(W(V,`GraphicsContext.fill(color, alpha) is deprecated, use GraphicsContext.fill({ color, alpha }) instead`),t={color:t,alpha:n}),this._fillStyle=bi(t,e.defaultFillStyle)),this.instructions.push({action:`fill`,data:{style:this.fillStyle,path:r}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}_initNextPathLocation(){let{x:e,y:t}=this._activePath.getLastPoint(Oe.shared);this._activePath.clear(),this._activePath.moveTo(e,t)}stroke(t){let n,r=this.instructions[this.instructions.length-1];return n=this._tick===0&&r&&r.action===`fill`?r.data.path:this._activePath.clone(),n?(t!=null&&(this._strokeStyle=xi(t,e.defaultStrokeStyle)),this.instructions.push({action:`stroke`,data:{style:this.strokeStyle,path:n}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}cut(){for(let e=0;e<2;e++){let t=this.instructions[this.instructions.length-1-e],n=this._activePath.clone();if(t&&(t.action===`stroke`||t.action===`fill`))if(t.data.hole)t.data.hole.addPath(n);else{t.data.hole=n;break}}return this._initNextPathLocation(),this}arc(e,t,n,r,i,a){this._tick++;let o=this._transform;return this._activePath.arc(o.a*e+o.c*t+o.tx,o.b*e+o.d*t+o.ty,n,r,i,a),this}arcTo(e,t,n,r,i){this._tick++;let a=this._transform;return this._activePath.arcTo(a.a*e+a.c*t+a.tx,a.b*e+a.d*t+a.ty,a.a*n+a.c*r+a.tx,a.b*n+a.d*r+a.ty,i),this}arcToSvg(e,t,n,r,i,a,o){this._tick++;let s=this._transform;return this._activePath.arcToSvg(e,t,n,r,i,s.a*a+s.c*o+s.tx,s.b*a+s.d*o+s.ty),this}bezierCurveTo(e,t,n,r,i,a,o){this._tick++;let s=this._transform;return this._activePath.bezierCurveTo(s.a*e+s.c*t+s.tx,s.b*e+s.d*t+s.ty,s.a*n+s.c*r+s.tx,s.b*n+s.d*r+s.ty,s.a*i+s.c*a+s.tx,s.b*i+s.d*a+s.ty,o),this}closePath(){return this._tick++,this._activePath?.closePath(),this}ellipse(e,t,n,r){return this._tick++,this._activePath.ellipse(e,t,n,r,this._transform.clone()),this}circle(e,t,n){return this._tick++,this._activePath.circle(e,t,n,this._transform.clone()),this}path(e){return this._tick++,this._activePath.addPath(e,this._transform.clone()),this}lineTo(e,t){this._tick++;let n=this._transform;return this._activePath.lineTo(n.a*e+n.c*t+n.tx,n.b*e+n.d*t+n.ty),this}moveTo(e,t){this._tick++;let n=this._transform,r=this._activePath.instructions,i=n.a*e+n.c*t+n.tx,a=n.b*e+n.d*t+n.ty;return r.length===1&&r[0].action===`moveTo`?(r[0].data[0]=i,r[0].data[1]=a,this):(this._activePath.moveTo(i,a),this)}quadraticCurveTo(e,t,n,r,i){this._tick++;let a=this._transform;return this._activePath.quadraticCurveTo(a.a*e+a.c*t+a.tx,a.b*e+a.d*t+a.ty,a.a*n+a.c*r+a.tx,a.b*n+a.d*r+a.ty,i),this}rect(e,t,n,r){return this._tick++,this._activePath.rect(e,t,n,r,this._transform.clone()),this}roundRect(e,t,n,r,i){return this._tick++,this._activePath.roundRect(e,t,n,r,i,this._transform.clone()),this}poly(e,t){return this._tick++,this._activePath.poly(e,t,this._transform.clone()),this}regularPoly(e,t,n,r,i=0,a){return this._tick++,this._activePath.regularPoly(e,t,n,r,i,a),this}roundPoly(e,t,n,r,i,a){return this._tick++,this._activePath.roundPoly(e,t,n,r,i,a),this}roundShape(e,t,n,r){return this._tick++,this._activePath.roundShape(e,t,n,r),this}filletRect(e,t,n,r,i){return this._tick++,this._activePath.filletRect(e,t,n,r,i),this}chamferRect(e,t,n,r,i,a){return this._tick++,this._activePath.chamferRect(e,t,n,r,i,a),this}star(e,t,n,r,i=0,a=0){return this._tick++,this._activePath.star(e,t,n,r,i,a,this._transform.clone()),this}svg(e){return this._tick++,li(e,this),this}restore(){let 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,n,r,i,a){return e instanceof H?(this._transform.set(e.a,e.b,e.c,e.d,e.tx,e.ty),this):(this._transform.set(e,t,n,r,i,a),this)}transform(e,t,n,r,i,a){return e instanceof H?(this._transform.append(e),this):(Ci.set(e,t,n,r,i,a),this._transform.append(Ci),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.dirty||(this.emit(`update`,this,16),this.dirty=!0,this._boundsDirty=!0)}get bounds(){if(!this._boundsDirty)return this._bounds;let e=this._bounds;e.clear();for(let t=0;t<this.instructions.length;t++){let n=this.instructions[t],r=n.action;if(r===`fill`){let t=n.data;e.addBounds(t.path.bounds)}else if(r===`texture`){let t=n.data;e.addFrame(t.dx,t.dy,t.dx+t.dw,t.dy+t.dh,t.transform)}if(r===`stroke`){let t=n.data,r=t.style.width/2,i=t.path.bounds;e.addFrame(i.minX-r,i.minY-r,i.maxX+r,i.maxY+r)}}return e}containsPoint(e){if(!this.bounds.containsPoint(e.x,e.y))return!1;let t=this.instructions,n=!1;for(let r=0;r<t.length;r++){let i=t[r],a=i.data,o=a.path;if(!i.action||!o)continue;let s=a.style,c=o.shapePath.shapePrimitives;for(let t=0;t<c.length;t++){let r=c[t].shape;if(!s||!r)continue;let o=c[t].transform,l=o?o.applyInverse(e,Si):e;n=i.action===`fill`?r.contains(l.x,l.y):r.strokeContains(l.x,l.y,s.width);let u=a.hole;if(u){let e=u.shapePath?.shapePrimitives;if(e)for(let t=0;t<e.length;t++)e[t].shape.contains(l.x,l.y)&&(n=!1)}if(n)return!0}}return n}destroy(e=!1){if(this._stateStack.length=0,this._transform=null,this.emit(`destroy`,this),this.removeAllListeners(),typeof e==`boolean`?e:e?.texture){let t=typeof e==`boolean`?e:e?.textureSource;this._fillStyle.texture&&this._fillStyle.texture.destroy(t),this._strokeStyle.texture&&this._strokeStyle.texture.destroy(t)}this._fillStyle=null,this._strokeStyle=null,this.instructions=null,this._activePath=null,this._bounds=null,this._stateStack=null,this.customShader=null,this._transform=null}};wi.defaultFillStyle={color:16777215,alpha:1,texture:R.WHITE,matrix:null,fill:null},wi.defaultStrokeStyle={width:1,color:16777215,alpha:1,alignment:.5,miterLimit:10,cap:`butt`,join:`miter`,texture:R.WHITE,matrix:null,fill:null};var Ti=wi,Ei=[`align`,`breakWords`,`cssOverrides`,`fontVariant`,`fontWeight`,`leading`,`letterSpacing`,`lineHeight`,`padding`,`textBaseline`,`trim`,`whiteSpace`,`wordWrap`,`wordWrapWidth`,`fontFamily`,`fontStyle`,`fontSize`];function Di(e){let t=[],n=0;for(let r=0;r<Ei.length;r++){let i=`_${Ei[r]}`;t[n++]=e[i]}return n=Oi(e._fill,t,n),n=ki(e._stroke,t,n),n=Ai(e.dropShadow,t,n),t.join(`-`)}function Oi(e,t,n){return e?(t[n++]=e.color,t[n++]=e.alpha,t[n++]=e.fill?.styleKey,n):n}function ki(e,t,n){return e?(n=Oi(e,t,n),t[n++]=e.width,t[n++]=e.alignment,t[n++]=e.cap,t[n++]=e.join,t[n++]=e.miterLimit,n):n}function Ai(e,t,n){return e?(t[n++]=e.alpha,t[n++]=e.angle,t[n++]=e.blur,t[n++]=e.distance,t[n++]=K.shared.setValue(e.color).toNumber(),n):n}var ji=class e extends ye{constructor(t={}){super(),Ni(t);let n={...e.defaultTextStyle,...t};for(let e in n){let t=e;this[t]=n[e]}this.update()}get align(){return this._align}set align(e){this._align=e,this.update()}get breakWords(){return this._breakWords}set breakWords(e){this._breakWords=e,this.update()}get dropShadow(){return this._dropShadow}set dropShadow(t){typeof t==`object`&&t?this._dropShadow=this._createProxy({...e.defaultDropShadow,...t}):this._dropShadow=t?this._createProxy({...e.defaultDropShadow}):null,this.update()}get fontFamily(){return this._fontFamily}set fontFamily(e){this._fontFamily=e,this.update()}get fontSize(){return this._fontSize}set 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.update()}get fontVariant(){return this._fontVariant}set fontVariant(e){this._fontVariant=e,this.update()}get fontWeight(){return this._fontWeight}set fontWeight(e){this._fontWeight=e,this.update()}get leading(){return this._leading}set leading(e){this._leading=e,this.update()}get letterSpacing(){return this._letterSpacing}set letterSpacing(e){this._letterSpacing=e,this.update()}get lineHeight(){return this._lineHeight}set lineHeight(e){this._lineHeight=e,this.update()}get padding(){return this._padding}set padding(e){this._padding=e,this.update()}get trim(){return this._trim}set trim(e){this._trim=e,this.update()}get textBaseline(){return this._textBaseline}set textBaseline(e){this._textBaseline=e,this.update()}get whiteSpace(){return this._whiteSpace}set whiteSpace(e){this._whiteSpace=e,this.update()}get wordWrap(){return this._wordWrap}set wordWrap(e){this._wordWrap=e,this.update()}get wordWrapWidth(){return this._wordWrapWidth}set 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({...Ti.defaultFillStyle,...e},()=>{this._fill=bi({...this._originalFill},Ti.defaultFillStyle)})),this._fill=bi(e===0?`black`:e,Ti.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(e){e!==this._originalStroke&&(this._originalStroke=e,this._isFillStyle(e)&&(this._originalStroke=this._createProxy({...Ti.defaultStrokeStyle,...e},()=>{this._stroke=xi({...this._originalStroke},Ti.defaultStrokeStyle)})),this._stroke=xi(e,Ti.defaultStrokeStyle),this.update())}_generateKey(){return this._styleKey=Di(this),this._styleKey}update(){this._styleKey=null,this.emit(`update`,this)}reset(){let t=e.defaultTextStyle;for(let e in t)this[e]=t[e]}get styleKey(){return this._styleKey||this._generateKey()}clone(){return new e({align:this.align,breakWords:this.breakWords,dropShadow:this._dropShadow?{...this._dropShadow}:null,fill:this._fill,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,textBaseline:this.textBaseline,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth})}destroy(e=!1){if(this.removeAllListeners(),typeof e==`boolean`?e:e?.texture){let t=typeof e==`boolean`?e:e?.textureSource;this._fill?.texture&&this._fill.texture.destroy(t),this._originalFill?.texture&&this._originalFill.texture.destroy(t),this._stroke?.texture&&this._stroke.texture.destroy(t),this._originalStroke?.texture&&this._originalStroke.texture.destroy(t)}this._fill=null,this._stroke=null,this.dropShadow=null,this._originalStroke=null,this._originalFill=null}_createProxy(e,t){return new Proxy(e,{set:(e,n,r)=>(e[n]=r,t?.(n,r),this.update(),!0)})}_isFillStyle(e){return(e??null)!==null&&!(K.isColorLike(e)||e instanceof Tr||e instanceof Dr)}};ji.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:`black`,distance:5},ji.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};var Mi=ji;function Ni(e){let t=e;if(typeof t.dropShadow==`boolean`&&t.dropShadow){let n=Mi.defaultDropShadow;e.dropShadow={alpha:t.dropShadowAlpha??n.alpha,angle:t.dropShadowAngle??n.angle,blur:t.dropShadowBlur??n.blur,color:t.dropShadowColor??n.color,distance:t.dropShadowDistance??n.distance}}if(t.strokeThickness!==void 0){W(V,`strokeThickness is now a part of stroke`);let n=t.stroke,r={};if(K.isColorLike(n))r.color=n;else if(n instanceof Tr||n instanceof Dr)r.fill=n;else if(Object.hasOwnProperty.call(n,`color`)||Object.hasOwnProperty.call(n,`fill`))r=n;else throw Error(`Invalid stroke value.`);e.stroke={...r,width:t.strokeThickness}}if(Array.isArray(t.fillGradientStops)){W(V,"gradient fill is now a fill pattern: `new FillGradient(...)`");let n;e.fontSize==null?e.fontSize=Mi.defaultTextStyle.fontSize:n=typeof e.fontSize==`string`?parseInt(e.fontSize,10):e.fontSize;let r=new Tr(0,0,0,n*1.7),i=t.fillGradientStops.map(e=>K.shared.setValue(e).toNumber());i.forEach((e,t)=>{let n=t/(i.length-1);r.addColorStop(n,e)}),e.fill={fill:r}}}var Pi=new k;function Fi(e,t,n,r){let i=Pi;i.minX=0,i.minY=0,i.maxX=e.width/r|0,i.maxY=e.height/r|0;let a=me.getOptimalTexture(i.width,i.height,r,!1);return a.source.uploadMethodId=`image`,a.source.resource=e,a.source.alphaMode=`premultiply-alpha-on-upload`,a.frame.width=t/r,a.frame.height=n/r,a.source.emit(`update`,a.source),a.updateUvs(),a}var Ii=[`serif`,`sans-serif`,`monospace`,`cursive`,`fantasy`,`system-ui`];function Li(e){let t=typeof e.fontSize==`number`?`${e.fontSize}px`:e.fontSize,n=e.fontFamily;Array.isArray(e.fontFamily)||(n=e.fontFamily.split(`,`));for(let e=n.length-1;e>=0;e--){let t=n[e].trim();!/([\"\'])[^\'\"]+\1/.test(t)&&!Ii.includes(t)&&(t=`"${t}"`),n[e]=t}return`${e.fontStyle} ${e.fontVariant} ${e.fontWeight} ${t} ${n.join(`,`)}`}var Ri={willReadFrequently:!0},zi=class e{static get experimentalLetterSpacingSupported(){let t=e._experimentalLetterSpacingSupported;if(t!==void 0){let n=z.get().getCanvasRenderingContext2D().prototype;t=e._experimentalLetterSpacingSupported=`letterSpacing`in n||`textLetterSpacing`in n}return t}constructor(e,t,n,r,i,a,o,s,c){this.text=e,this.style=t,this.width=n,this.height=r,this.lines=i,this.lineWidths=a,this.lineHeight=o,this.maxLineWidth=s,this.fontProperties=c}static measureText(t=` `,n,r=e._canvas,i=n.wordWrap){let a=`${t}:${n.styleKey}`;if(e._measurementCache[a])return e._measurementCache[a];let o=Li(n),s=e.measureFont(o);s.fontSize===0&&(s.fontSize=n.fontSize,s.ascent=n.fontSize);let c=e.__context;c.font=o;let l=(i?e._wordWrap(t,n,r):t).split(/(?:\r\n|\r|\n)/),u=Array(l.length),d=0;for(let t=0;t<l.length;t++){let r=e._measureText(l[t],n.letterSpacing,c);u[t]=r,d=Math.max(d,r)}let f=n._stroke?.width||0,p=d+f;n.dropShadow&&(p+=n.dropShadow.distance);let m=n.lineHeight||s.fontSize,h=Math.max(m,s.fontSize+f)+(l.length-1)*(m+n.leading);return n.dropShadow&&(h+=n.dropShadow.distance),new e(t,n,p,h,l,u,m+n.leading,d,s)}static _measureText(t,n,r){let i=!1;e.experimentalLetterSpacingSupported&&(e.experimentalLetterSpacing?(r.letterSpacing=`${n}px`,r.textLetterSpacing=`${n}px`,i=!0):(r.letterSpacing=`0px`,r.textLetterSpacing=`0px`));let a=r.measureText(t).width;return a>0&&(i?a-=n:a+=(e.graphemeSegmenter(t).length-1)*n),a}static _wordWrap(t,n,r=e._canvas){let i=r.getContext(`2d`,Ri),a=0,o=``,s=``,c=Object.create(null),{letterSpacing:l,whiteSpace:u}=n,d=e._collapseSpaces(u),f=e._collapseNewlines(u),p=!d,m=n.wordWrapWidth+l,h=e._tokenize(t);for(let t=0;t<h.length;t++){let r=h[t];if(e._isNewline(r)){if(!f){s+=e._addLine(o),p=!d,o=``,a=0;continue}r=` `}if(d){let t=e.isBreakingSpace(r),n=e.isBreakingSpace(o[o.length-1]);if(t&&n)continue}let u=e._getFromCache(r,l,c,i);if(u>m)if(o!==``&&(s+=e._addLine(o),o=``,a=0),e.canBreakWords(r,n.breakWords)){let t=e.wordWrapSplit(r);for(let u=0;u<t.length;u++){let d=t[u],f=d,h=1;for(;t[u+h];){let i=t[u+h];if(!e.canBreakChars(f,i,r,u,n.breakWords))d+=i;else break;f=i,h++}u+=h-1;let g=e._getFromCache(d,l,c,i);g+a>m&&(s+=e._addLine(o),p=!1,o=``,a=0),o+=d,a+=g}}else{o.length>0&&(s+=e._addLine(o),o=``,a=0);let n=t===h.length-1;s+=e._addLine(r,!n),p=!1,o=``,a=0}else u+a>m&&(p=!1,s+=e._addLine(o),o=``,a=0),(o.length>0||!e.isBreakingSpace(r)||p)&&(o+=r,a+=u)}return s+=e._addLine(o,!1),s}static _addLine(t,n=!0){return t=e._trimRight(t),t=n?`${t}
|
|
3
|
+
`:t,t}static _getFromCache(t,n,r,i){let a=r[t];return typeof a!=`number`&&(a=e._measureText(t,n,i)+n,r[t]=a),a}static _collapseSpaces(e){return e===`normal`||e===`pre-line`}static _collapseNewlines(e){return e===`normal`}static _trimRight(t){if(typeof t!=`string`)return``;for(let n=t.length-1;n>=0;n--){let r=t[n];if(!e.isBreakingSpace(r))break;t=t.slice(0,-1)}return t}static _isNewline(t){return typeof t==`string`?e._newlines.includes(t.charCodeAt(0)):!1}static isBreakingSpace(t,n){return typeof t==`string`?e._breakingSpaces.includes(t.charCodeAt(0)):!1}static _tokenize(t){let n=[],r=``;if(typeof t!=`string`)return n;for(let i=0;i<t.length;i++){let a=t[i],o=t[i+1];if(e.isBreakingSpace(a,o)||e._isNewline(a)){r!==``&&(n.push(r),r=``),n.push(a);continue}r+=a}return r!==``&&n.push(r),n}static canBreakWords(e,t){return t}static canBreakChars(e,t,n,r,i){return!0}static wordWrapSplit(t){return e.graphemeSegmenter(t)}static measureFont(t){if(e._fonts[t])return e._fonts[t];let n=e._context;n.font=t;let r=n.measureText(e.METRICS_STRING+e.BASELINE_SYMBOL),i={ascent:r.actualBoundingBoxAscent,descent:r.actualBoundingBoxDescent,fontSize:r.actualBoundingBoxAscent+r.actualBoundingBoxDescent};return e._fonts[t]=i,i}static clearMetrics(t=``){t?delete e._fonts[t]:e._fonts={}}static get _canvas(){if(!e.__canvas){let t;try{let n=new OffscreenCanvas(0,0);if(n.getContext(`2d`,Ri)?.measureText)return e.__canvas=n,n;t=z.get().createCanvas()}catch{t=z.get().createCanvas()}t.width=t.height=10,e.__canvas=t}return e.__canvas}static get _context(){return e.__context||=e._canvas.getContext(`2d`,Ri),e.__context}};zi.METRICS_STRING=`|ÉqÅ`,zi.BASELINE_SYMBOL=`M`,zi.BASELINE_MULTIPLIER=1.4,zi.HEIGHT_MULTIPLIER=2,zi.graphemeSegmenter=(()=>{if(typeof Intl?.Segmenter==`function`){let e=new Intl.Segmenter;return t=>[...e.segment(t)].map(e=>e.segment)}return e=>[...e]})(),zi.experimentalLetterSpacing=!1,zi._fonts={},zi._newlines=[10,13],zi._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288],zi._measurementCache={};var Bi=zi;function Vi(e,t){if(e.texture===R.WHITE&&!e.fill)return K.shared.setValue(e.color).setAlpha(e.alpha??1).toHexa();if(!e.fill){let n=t.createPattern(e.texture.source.resource,`repeat`),r=e.matrix.copyTo(H.shared);return r.scale(e.texture.frame.width,e.texture.frame.height),n.setTransform(r),n}else if(e.fill instanceof Dr){let n=e.fill,r=t.createPattern(n.texture.source.resource,`repeat`),i=n.transform.copyTo(H.shared);return i.scale(n.texture.frame.width,n.texture.frame.height),r.setTransform(i),r}else if(e.fill instanceof Tr){let n=e.fill;if(n.type===`linear`){let e=t.createLinearGradient(n.x0,n.y0,n.x1,n.y1);return n.gradientStops.forEach(t=>{e.addColorStop(t.offset,K.shared.setValue(t.color).toHex())}),e}}return B(`FillStyle not recognised`,e),`red`}var Hi=class{constructor(e){this._activeTextures={},this._renderer=e}getTextureSize(e,t,n){let r=Bi.measureText(e||` `,n),i=Math.ceil(Math.ceil(Math.max(1,r.width)+n.padding*2)*t),a=Math.ceil(Math.ceil(Math.max(1,r.height)+n.padding*2)*t);return i=Math.ceil(i-1e-6),a=Math.ceil(a-1e-6),i=L(i),a=L(a),{width:i,height:a}}getTexture(e,t,n,r){typeof e==`string`&&(W(`8.0.0`,`CanvasTextSystem.getTexture: Use object TextOptions instead of separate arguments`),e={text:e,style:n,resolution:t}),e.style instanceof Mi||(e.style=new Mi(e.style));let{texture:i,canvasAndContext:a}=this.createTextureAndCanvas(e);return this._renderer.texture.initSource(i._source),qe.returnCanvasAndContext(a),i}createTextureAndCanvas(e){let{text:t,style:n}=e,r=e.resolution??this._renderer.resolution,i=Bi.measureText(t||` `,n),a=Math.ceil(Math.ceil(Math.max(1,i.width)+n.padding*2)*r),o=Math.ceil(Math.ceil(Math.max(1,i.height)+n.padding*2)*r),s=qe.getOptimalCanvasAndContext(a,o),{canvas:c}=s;this.renderTextToCanvas(t,n,r,s);let l=Fi(c,a,o,r);if(n.trim){let e=Cr(c,r);l.frame.copyFrom(e),l.updateUvs()}return{texture:l,canvasAndContext:s}}getManagedTexture(e){e._resolution=e._autoResolution?this._renderer.resolution:e.resolution;let t=e._getKey();if(this._activeTextures[t])return this._increaseReferenceCount(t),this._activeTextures[t].texture;let{texture:n,canvasAndContext:r}=this.createTextureAndCanvas(e);return this._activeTextures[t]={canvasAndContext:r,texture:n,usageCount:1},n}_increaseReferenceCount(e){this._activeTextures[e].usageCount++}decreaseReferenceCount(e){let t=this._activeTextures[e];if(t.usageCount--,t.usageCount===0){qe.returnCanvasAndContext(t.canvasAndContext),me.returnTexture(t.texture);let n=t.texture.source;n.resource=null,n.uploadMethodId=`unknown`,n.alphaMode=`no-premultiply-alpha`,this._activeTextures[e]=null}}getReferenceCount(e){return this._activeTextures[e].usageCount}renderTextToCanvas(e,t,n,r){let{canvas:i,context:a}=r,o=Li(t),s=Bi.measureText(e||` `,t),c=s.lines,l=s.lineHeight,u=s.lineWidths,d=s.maxLineWidth,f=s.fontProperties,p=i.height;a.resetTransform(),a.scale(n,n);let m=t.padding*2;if(a.clearRect(0,0,s.width+4+m,s.height+4+m),t._stroke?.width){let e=t._stroke;a.lineWidth=e.width,a.miterLimit=e.miterLimit,a.lineJoin=e.join,a.lineCap=e.cap}a.font=o;let h,g,_=t.dropShadow?2:1;for(let e=0;e<_;++e){let i=t.dropShadow&&e===0,o=i?Math.ceil(Math.max(1,p)+t.padding*2):0,s=o*n;if(i){a.fillStyle=`black`,a.strokeStyle=`black`;let e=t.dropShadow,r=e.color,i=e.alpha;a.shadowColor=K.shared.setValue(r).setAlpha(i).toRgbaString();let o=e.blur*n,c=e.distance*n;a.shadowBlur=o,a.shadowOffsetX=Math.cos(e.angle)*c,a.shadowOffsetY=Math.sin(e.angle)*c+s}else a.globalAlpha=t._fill?.alpha??1,a.fillStyle=t._fill?Vi(t._fill,a):null,t._stroke?.width&&(a.strokeStyle=Vi(t._stroke,a)),a.shadowColor=`black`;let m=(l-f.fontSize)/2;l-f.fontSize<0&&(m=0);let _=t._stroke?.width??0;for(let e=0;e<c.length;e++)h=_/2,g=_/2+e*l+f.ascent+m,t.align===`right`?h+=d-u[e]:t.align===`center`&&(h+=(d-u[e])/2),t._stroke?.width&&this._drawLetterSpacing(c[e],t,r,h+t.padding,g+t.padding-o,!0),t._fill!==void 0&&this._drawLetterSpacing(c[e],t,r,h+t.padding,g+t.padding-o)}}_drawLetterSpacing(e,t,n,r,i,a=!1){let{context:o}=n,s=t.letterSpacing,c=!1;if(Bi.experimentalLetterSpacingSupported&&(Bi.experimentalLetterSpacing?(o.letterSpacing=`${s}px`,o.textLetterSpacing=`${s}px`,c=!0):(o.letterSpacing=`0px`,o.textLetterSpacing=`0px`)),s===0||c){a?o.strokeText(e,r,i):o.fillText(e,r,i);return}let l=r,u=Bi.graphemeSegmenter(e),d=o.measureText(e).width,f=0;for(let e=0;e<u.length;++e){let t=u[e];a?o.strokeText(t,l,i):o.fillText(t,l,i);let n=``;for(let t=e+1;t<u.length;++t)n+=u[t];f=o.measureText(n).width,l+=d-f+s,d=f}}destroy(){this._activeTextures=null}};Hi.extension={type:[U.WebGLSystem,U.WebGPUSystem,U.CanvasSystem],name:`canvasText`};var J=class e extends F{constructor(e){e instanceof Ti&&(e={context:e});let{context:t,roundPixels:n,...r}=e||{};super({label:`Graphics`,...r}),this.renderPipeId=`graphics`,t?this._context=t:this._context=this._ownedContext=new Ti,this._context.on(`update`,this.onViewUpdate,this),this.allowChildren=!1,this.roundPixels=n??!1}set context(e){e!==this._context&&(this._context.off(`update`,this.onViewUpdate,this),this._context=e,this._context.on(`update`,this.onViewUpdate,this),this.onViewUpdate())}get context(){return this._context}get bounds(){return this._context.bounds}addBounds(e){e.addBounds(this._context.bounds)}containsPoint(e){return this._context.containsPoint(e)}onViewUpdate(){if(this._didViewChangeTick++,this._didGraphicsUpdate=!0,this.didViewUpdate)return;this.didViewUpdate=!0;let e=this.renderGroup||this.parentRenderGroup;e&&e.onChildViewUpdate(this)}destroy(e){this._ownedContext&&!e?this._ownedContext.destroy(e):(e===!0||e?.context===!0)&&this._context.destroy(e),this._ownedContext=null,this._context=null,super.destroy(e)}_callContextMethod(e,t){return this.context[e](...t),this}setFillStyle(...e){return this._callContextMethod(`setFillStyle`,e)}setStrokeStyle(...e){return this._callContextMethod(`setStrokeStyle`,e)}fill(...e){return this._callContextMethod(`fill`,e)}stroke(...e){return this._callContextMethod(`stroke`,e)}texture(...e){return this._callContextMethod(`texture`,e)}beginPath(){return this._callContextMethod(`beginPath`,[])}cut(){return this._callContextMethod(`cut`,[])}arc(...e){return this._callContextMethod(`arc`,e)}arcTo(...e){return this._callContextMethod(`arcTo`,e)}arcToSvg(...e){return this._callContextMethod(`arcToSvg`,e)}bezierCurveTo(...e){return this._callContextMethod(`bezierCurveTo`,e)}closePath(){return this._callContextMethod(`closePath`,[])}ellipse(...e){return this._callContextMethod(`ellipse`,e)}circle(...e){return this._callContextMethod(`circle`,e)}path(...e){return this._callContextMethod(`path`,e)}lineTo(...e){return this._callContextMethod(`lineTo`,e)}moveTo(...e){return this._callContextMethod(`moveTo`,e)}quadraticCurveTo(...e){return this._callContextMethod(`quadraticCurveTo`,e)}rect(...e){return this._callContextMethod(`rect`,e)}roundRect(...e){return this._callContextMethod(`roundRect`,e)}poly(...e){return this._callContextMethod(`poly`,e)}regularPoly(...e){return this._callContextMethod(`regularPoly`,e)}roundPoly(...e){return this._callContextMethod(`roundPoly`,e)}roundShape(...e){return this._callContextMethod(`roundShape`,e)}filletRect(...e){return this._callContextMethod(`filletRect`,e)}chamferRect(...e){return this._callContextMethod(`chamferRect`,e)}star(...e){return this._callContextMethod(`star`,e)}svg(...e){return this._callContextMethod(`svg`,e)}restore(...e){return this._callContextMethod(`restore`,e)}save(){return this._callContextMethod(`save`,[])}getTransform(){return this.context.getTransform()}resetTransform(){return this._callContextMethod(`resetTransform`,[])}rotateTransform(...e){return this._callContextMethod(`rotate`,e)}scaleTransform(...e){return this._callContextMethod(`scale`,e)}setTransform(...e){return this._callContextMethod(`setTransform`,e)}transform(...e){return this._callContextMethod(`transform`,e)}translateTransform(...e){return this._callContextMethod(`translate`,e)}clear(){return this._callContextMethod(`clear`,[])}get fillStyle(){return this._context.fillStyle}set fillStyle(e){this._context.fillStyle=e}get strokeStyle(){return this._context.strokeStyle}set strokeStyle(e){this._context.strokeStyle=e}clone(t=!1){return t?new e(this._context.clone()):(this._ownedContext=null,new e(this._context))}lineStyle(e,t,n){W(V,`Graphics#lineStyle is no longer needed. Use Graphics#setStrokeStyle to set the stroke style.`);let r={};return e&&(r.width=e),t&&(r.color=t),n&&(r.alpha=n),this.context.strokeStyle=r,this}beginFill(e,t){W(V,`Graphics#beginFill is no longer needed. Use Graphics#fill to fill the shape with the desired style.`);let n={};return e&&(n.color=e),t&&(n.alpha=t),this.context.fillStyle=n,this}endFill(){W(V,`Graphics#endFill is no longer needed. Use Graphics#fill to fill the shape with the desired style.`),this.context.fill();let e=this.context.strokeStyle;return(e.width!==Ti.defaultStrokeStyle.width||e.color!==Ti.defaultStrokeStyle.color||e.alpha!==Ti.defaultStrokeStyle.alpha)&&this.context.stroke(),this}drawCircle(...e){return W(V,`Graphics#drawCircle has been renamed to Graphics#circle`),this._callContextMethod(`circle`,e)}drawEllipse(...e){return W(V,`Graphics#drawEllipse has been renamed to Graphics#ellipse`),this._callContextMethod(`ellipse`,e)}drawPolygon(...e){return W(V,`Graphics#drawPolygon has been renamed to Graphics#poly`),this._callContextMethod(`poly`,e)}drawRect(...e){return W(V,`Graphics#drawRect has been renamed to Graphics#rect`),this._callContextMethod(`rect`,e)}drawRoundedRect(...e){return W(V,`Graphics#drawRoundedRect has been renamed to Graphics#roundRect`),this._callContextMethod(`roundRect`,e)}drawStar(...e){return W(V,`Graphics#drawStar has been renamed to Graphics#star`),this._callContextMethod(`star`,e)}},Ui={name:`local-uniform-msdf-bit`,vertex:{header:`
|
|
4
|
+
struct LocalUniforms {
|
|
5
|
+
uColor:vec4<f32>,
|
|
6
|
+
uTransformMatrix:mat3x3<f32>,
|
|
7
|
+
uDistance: f32,
|
|
8
|
+
uRound:f32,
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
@group(2) @binding(0) var<uniform> localUniforms : LocalUniforms;
|
|
12
|
+
`,main:`
|
|
13
|
+
vColor *= localUniforms.uColor;
|
|
14
|
+
modelMatrix *= localUniforms.uTransformMatrix;
|
|
15
|
+
`,end:`
|
|
16
|
+
if(localUniforms.uRound == 1)
|
|
17
|
+
{
|
|
18
|
+
vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
|
|
19
|
+
}
|
|
20
|
+
`},fragment:{header:`
|
|
21
|
+
struct LocalUniforms {
|
|
22
|
+
uColor:vec4<f32>,
|
|
23
|
+
uTransformMatrix:mat3x3<f32>,
|
|
24
|
+
uDistance: f32
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@group(2) @binding(0) var<uniform> localUniforms : LocalUniforms;
|
|
28
|
+
`,main:`
|
|
29
|
+
outColor = vec4<f32>(calculateMSDFAlpha(outColor, localUniforms.uColor, localUniforms.uDistance));
|
|
30
|
+
`}},Wi={name:`local-uniform-msdf-bit`,vertex:{header:`
|
|
31
|
+
uniform mat3 uTransformMatrix;
|
|
32
|
+
uniform vec4 uColor;
|
|
33
|
+
uniform float uRound;
|
|
34
|
+
`,main:`
|
|
35
|
+
vColor *= uColor;
|
|
36
|
+
modelMatrix *= uTransformMatrix;
|
|
37
|
+
`,end:`
|
|
38
|
+
if(uRound == 1.)
|
|
39
|
+
{
|
|
40
|
+
gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
|
|
41
|
+
}
|
|
42
|
+
`},fragment:{header:`
|
|
43
|
+
uniform float uDistance;
|
|
44
|
+
`,main:`
|
|
45
|
+
outColor = vec4(calculateMSDFAlpha(outColor, vColor, uDistance));
|
|
46
|
+
`}},Gi={name:`msdf-bit`,fragment:{header:`
|
|
47
|
+
fn calculateMSDFAlpha(msdfColor:vec4<f32>, shapeColor:vec4<f32>, distance:f32) -> f32 {
|
|
48
|
+
|
|
49
|
+
// MSDF
|
|
50
|
+
var median = msdfColor.r + msdfColor.g + msdfColor.b -
|
|
51
|
+
min(msdfColor.r, min(msdfColor.g, msdfColor.b)) -
|
|
52
|
+
max(msdfColor.r, max(msdfColor.g, msdfColor.b));
|
|
53
|
+
|
|
54
|
+
// SDF
|
|
55
|
+
median = min(median, msdfColor.a);
|
|
56
|
+
|
|
57
|
+
var screenPxDistance = distance * (median - 0.5);
|
|
58
|
+
var alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);
|
|
59
|
+
if (median < 0.01) {
|
|
60
|
+
alpha = 0.0;
|
|
61
|
+
} else if (median > 0.99) {
|
|
62
|
+
alpha = 1.0;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Gamma correction for coverage-like alpha
|
|
66
|
+
var luma: f32 = dot(shapeColor.rgb, vec3<f32>(0.299, 0.587, 0.114));
|
|
67
|
+
var gamma: f32 = mix(1.0, 1.0 / 2.2, luma);
|
|
68
|
+
var coverage: f32 = pow(shapeColor.a * alpha, gamma);
|
|
69
|
+
|
|
70
|
+
return coverage;
|
|
71
|
+
|
|
72
|
+
}
|
|
73
|
+
`}},Ki={name:`msdf-bit`,fragment:{header:`
|
|
74
|
+
float calculateMSDFAlpha(vec4 msdfColor, vec4 shapeColor, float distance) {
|
|
75
|
+
|
|
76
|
+
// MSDF
|
|
77
|
+
float median = msdfColor.r + msdfColor.g + msdfColor.b -
|
|
78
|
+
min(msdfColor.r, min(msdfColor.g, msdfColor.b)) -
|
|
79
|
+
max(msdfColor.r, max(msdfColor.g, msdfColor.b));
|
|
80
|
+
|
|
81
|
+
// SDF
|
|
82
|
+
median = min(median, msdfColor.a);
|
|
83
|
+
|
|
84
|
+
float screenPxDistance = distance * (median - 0.5);
|
|
85
|
+
float alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);
|
|
86
|
+
|
|
87
|
+
if (median < 0.01) {
|
|
88
|
+
alpha = 0.0;
|
|
89
|
+
} else if (median > 0.99) {
|
|
90
|
+
alpha = 1.0;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Gamma correction for coverage-like alpha
|
|
94
|
+
float luma = dot(shapeColor.rgb, vec3(0.299, 0.587, 0.114));
|
|
95
|
+
float gamma = mix(1.0, 1.0 / 2.2, luma);
|
|
96
|
+
float coverage = pow(shapeColor.a * alpha, gamma);
|
|
97
|
+
|
|
98
|
+
return coverage;
|
|
99
|
+
}
|
|
100
|
+
`}},qi,Ji,Yi=class extends we{constructor(){let e=new We({uColor:{value:new Float32Array([1,1,1,1]),type:`vec4<f32>`},uTransformMatrix:{value:new H,type:`mat3x3<f32>`},uDistance:{value:4,type:`f32`},uRound:{value:0,type:`f32`}}),t=Te();qi??=Ne({name:`sdf-shader`,bits:[Be,_e(t),Ui,Gi,je]}),Ji??=xe({name:`sdf-shader`,bits:[ve,De(t),Wi,Ki,Le]}),super({glProgram:Ji,gpuProgram:qi,resources:{localUniforms:e,batchSamplers:Je(t)}})}},Xi=class extends ye{constructor(){super(...arguments),this.chars=Object.create(null),this.lineHeight=0,this.fontFamily=``,this.fontMetrics={fontSize:0,ascent:0,descent:0},this.baseLineOffset=0,this.distanceField={type:`none`,range:0},this.pages=[],this.applyFillAsTint=!0,this.baseMeasurementFontSize=100,this.baseRenderedFontSize=100}get font(){return W(V,`BitmapFont.font is deprecated, please use BitmapFont.fontFamily instead.`),this.fontFamily}get pageTextures(){return W(V,`BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead.`),this.pages}get size(){return W(V,`BitmapFont.size is deprecated, please use BitmapFont.fontMetrics.fontSize instead.`),this.fontMetrics.fontSize}get distanceFieldRange(){return W(V,`BitmapFont.distanceFieldRange is deprecated, please use BitmapFont.distanceField.range instead.`),this.distanceField.range}get distanceFieldType(){return W(V,`BitmapFont.distanceFieldType is deprecated, please use BitmapFont.distanceField.type instead.`),this.distanceField.type}destroy(e=!1){this.emit(`destroy`,this),this.removeAllListeners();for(let e in this.chars)this.chars[e].texture?.destroy();this.chars=null,e&&(this.pages.forEach(e=>e.texture.destroy(!0)),this.pages=null)}};function Zi(e){if(e===``)return[];typeof e==`string`&&(e=[e]);let t=[];for(let n=0,r=e.length;n<r;n++){let r=e[n];if(Array.isArray(r)){if(r.length!==2)throw Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${r.length}.`);if(r[0].length===0||r[1].length===0)throw Error(`[BitmapFont]: Invalid character delimiter.`);let e=r[0].charCodeAt(0),n=r[1].charCodeAt(0);if(n<e)throw Error(`[BitmapFont]: Invalid character range.`);for(let r=e,i=n;r<=i;r++)t.push(String.fromCharCode(r))}else t.push(...Array.from(r))}if(t.length===0)throw Error(`[BitmapFont]: Empty set when resolving characters.`);return t}var Qi=class e extends Xi{constructor(t){super(),this.resolution=1,this.pages=[],this._padding=0,this._measureCache=Object.create(null),this._currentChars=[],this._currentX=0,this._currentY=0,this._currentPageIndex=-1,this._skipKerning=!1;let n={...e.defaultOptions,...t};this._textureSize=n.textureSize,this._mipmap=n.mipmap;let r=n.style.clone();n.overrideFill&&(r._fill.color=16777215,r._fill.alpha=1,r._fill.texture=R.WHITE,r._fill.fill=null),this.applyFillAsTint=n.overrideFill;let i=r.fontSize;r.fontSize=this.baseMeasurementFontSize;let a=Li(r);n.overrideSize?r._stroke&&(r._stroke.width*=this.baseRenderedFontSize/i):r.fontSize=this.baseRenderedFontSize=i,this._style=r,this._skipKerning=n.skipKerning??!1,this.resolution=n.resolution??1,this._padding=n.padding??4,this.fontMetrics=Bi.measureFont(a),this.lineHeight=r.lineHeight||this.fontMetrics.fontSize||r.fontSize}ensureCharacters(e){let t=Zi(e).filter(e=>!this._currentChars.includes(e)).filter((e,t,n)=>n.indexOf(e)===t);if(!t.length)return;this._currentChars=[...this._currentChars,...t];let n;n=this._currentPageIndex===-1?this._nextPage():this.pages[this._currentPageIndex];let{canvas:r,context:i}=n.canvasAndContext,a=n.texture.source,o=this._style,s=this._currentX,c=this._currentY,l=this.baseRenderedFontSize/this.baseMeasurementFontSize,u=this._padding*l,d=o.fontStyle===`italic`?2:1,f=0,p=!1;for(let e=0;e<t.length;e++){let n=t[e],m=Bi.measureText(n,o,r,!1);m.lineHeight=m.height;let h=d*m.width*l,g=m.height*l,_=h+u*2,v=g+u*2;if(p=!1,n!==`
|
|
101
|
+
`&&n!==`\r`&&n!==` `&&n!==` `&&(p=!0,f=Math.ceil(Math.max(v,f))),s+_>this._textureSize&&(c+=f,f=v,s=0,c+f>this._textureSize)){a.update();let e=this._nextPage();r=e.canvasAndContext.canvas,i=e.canvasAndContext.context,a=e.texture.source,c=0}let y=h/l-(o.dropShadow?.distance??0)-(o._stroke?.width??0);if(this.chars[n]={id:n.codePointAt(0),xOffset:-this._padding,yOffset:-this._padding,xAdvance:y,kerning:{}},p){this._drawGlyph(i,m,s+u,c+u,l,o);let e=a.width*l,t=a.height*l,r=new be(s/e*a.width,c/t*a.height,_/e*a.width,v/t*a.height);this.chars[n].texture=new R({source:a,frame:r}),s+=Math.ceil(_)}}a.update(),this._currentX=s,this._currentY=c,this._skipKerning&&this._applyKerning(t,i)}get pageTextures(){return W(V,`BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead.`),this.pages}_applyKerning(e,t){let n=this._measureCache;for(let r=0;r<e.length;r++){let i=e[r];for(let e=0;e<this._currentChars.length;e++){let r=this._currentChars[e],a=n[i];a||=n[i]=t.measureText(i).width;let o=n[r];o||=n[r]=t.measureText(r).width;let s=t.measureText(i+r).width,c=s-(a+o);c&&(this.chars[i].kerning[r]=c),s=t.measureText(i+r).width,c=s-(a+o),c&&(this.chars[r].kerning[i]=c)}}}_nextPage(){this._currentPageIndex++;let e=this.resolution,t=qe.getOptimalCanvasAndContext(this._textureSize,this._textureSize,e);this._setupContext(t.context,this._style,e);let n=e*(this.baseRenderedFontSize/this.baseMeasurementFontSize),r={canvasAndContext:t,texture:new R({source:new jn({resource:t.canvas,resolution:n,alphaMode:`premultiply-alpha-on-upload`,autoGenerateMipmaps:this._mipmap})})};return this.pages[this._currentPageIndex]=r,r}_setupContext(e,t,n){t.fontSize=this.baseRenderedFontSize,e.scale(n,n),e.font=Li(t),t.fontSize=this.baseMeasurementFontSize,e.textBaseline=t.textBaseline;let r=t._stroke,i=r?.width??0;if(r&&(e.lineWidth=i,e.lineJoin=r.join,e.miterLimit=r.miterLimit,e.strokeStyle=Vi(r,e)),t._fill&&(e.fillStyle=Vi(t._fill,e)),t.dropShadow){let r=t.dropShadow,i=K.shared.setValue(r.color).toArray(),a=r.blur*n,o=r.distance*n;e.shadowColor=`rgba(${i[0]*255},${i[1]*255},${i[2]*255},${r.alpha})`,e.shadowBlur=a,e.shadowOffsetX=Math.cos(r.angle)*o,e.shadowOffsetY=Math.sin(r.angle)*o}else e.shadowColor=`black`,e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0}_drawGlyph(e,t,n,r,i,a){let o=t.text,s=t.fontProperties,c=(a._stroke?.width??0)*i,l=n+c/2,u=r-c/2,d=s.descent*i,f=t.lineHeight*i;a.stroke&&c&&e.strokeText(o,l,u+f-d),a._fill&&e.fillText(o,l,u+f-d)}destroy(){super.destroy();for(let e=0;e<this.pages.length;e++){let{canvasAndContext:t,texture:n}=this.pages[e];t.canvas.width=t.canvas.width,qe.returnCanvasAndContext(t),n.destroy(!0)}this.pages=null}};Qi.defaultOptions={textureSize:512,style:new Mi,mipmap:!0};var $i=Qi;function ea(e,t,n){let r={width:0,height:0,offsetY:0,scale:t.fontSize/n.baseMeasurementFontSize,lines:[{width:0,charPositions:[],spaceWidth:0,spacesIndex:[],chars:[]}]};r.offsetY=n.baseLineOffset;let i=r.lines[0],a=null,o=!0,s={spaceWord:!1,width:0,start:0,index:0,positions:[],chars:[]},c=e=>{let t=i.width;for(let n=0;n<s.index;n++){let r=e.positions[n];i.chars.push(e.chars[n]),i.charPositions.push(r+t)}i.width+=e.width,o=!1,s.width=0,s.index=0,s.chars.length=0},l=()=>{let e=i.chars.length-1,t=i.chars[e];for(;t===` `;)i.width-=n.chars[t].xAdvance,t=i.chars[--e];r.width=Math.max(r.width,i.width),i={width:0,charPositions:[],chars:[],spaceWidth:0,spacesIndex:[]},o=!0,r.lines.push(i),r.height+=n.lineHeight},u=n.baseMeasurementFontSize/t.fontSize,d=t.letterSpacing*u,f=t.wordWrapWidth*u;for(let r=0;r<e.length+1;r++){let u,p=r===e.length;p||(u=e[r]);let m=n.chars[u]||n.chars[` `];if(/(?:\s)/.test(u)||u===`\r`||u===`
|
|
102
|
+
`||p){if(!o&&t.wordWrap&&i.width+s.width-d>f?(l(),c(s),p||i.charPositions.push(0)):(s.start=i.width,c(s),p||i.charPositions.push(0)),u===`\r`||u===`
|
|
103
|
+
`)i.width!==0&&l();else if(!p){let e=m.xAdvance+(m.kerning[a]||0)+d;i.width+=e,i.spaceWidth=e,i.spacesIndex.push(i.charPositions.length),i.chars.push(u)}}else{let e=m.kerning[a]||0,t=m.xAdvance+e+d;s.positions[s.index++]=s.width+e,s.chars.push(u),s.width+=t}a=u}return l(),t.align===`center`?ta(r):t.align===`right`?na(r):t.align===`justify`&&ra(r),r}function ta(e){for(let t=0;t<e.lines.length;t++){let n=e.lines[t],r=e.width/2-n.width/2;for(let e=0;e<n.charPositions.length;e++)n.charPositions[e]+=r}}function na(e){for(let t=0;t<e.lines.length;t++){let n=e.lines[t],r=e.width-n.width;for(let e=0;e<n.charPositions.length;e++)n.charPositions[e]+=r}}function ra(e){let t=e.width;for(let n=0;n<e.lines.length;n++){let r=e.lines[n],i=0,a=r.spacesIndex[i++],o=0,s=r.spacesIndex.length,c=(t-r.width)/s;for(let e=0;e<r.charPositions.length;e++)e===a&&(a=r.spacesIndex[i++],o+=c),r.charPositions[e]+=o}}var ia=0,aa=new class{constructor(){this.ALPHA=[[`a`,`z`],[`A`,`Z`],` `],this.NUMERIC=[[`0`,`9`]],this.ALPHANUMERIC=[[`a`,`z`],[`A`,`Z`],[`0`,`9`],` `],this.ASCII=[[` `,`~`]],this.defaultOptions={chars:this.ALPHANUMERIC,resolution:1,padding:4,skipKerning:!1}}getFont(e,t){let n=`${t.fontFamily}-bitmap`,r=!0;if(t._fill.fill&&!t._stroke)n+=t._fill.fill.styleKey,r=!1;else if(t._stroke||t.dropShadow){let e=t.styleKey;e=e.substring(0,e.lastIndexOf(`-`)),n=`${e}-bitmap`,r=!1}if(!In.has(n)){let e=new $i({style:t,overrideFill:r,overrideSize:!0,...this.defaultOptions});ia++,ia>50&&B(`BitmapText`,`You have dynamically created ${ia} bitmap fonts, this can be inefficient. Try pre installing your font styles using \`BitmapFont.install({name:"style1", style})\``),e.once(`destroy`,()=>{ia--,In.remove(n)}),In.set(n,e)}let i=In.get(n);return i.ensureCharacters?.(e),i}getLayout(e,t){let n=this.getFont(e,t);return ea([...e],t,n)}measureText(e,t){return this.getLayout(e,t)}install(...e){let t=e[0];typeof t==`string`&&(t={name:t,style:e[1],chars:e[2]?.chars,resolution:e[2]?.resolution,padding:e[2]?.padding,skipKerning:e[2]?.skipKerning},W(V,`BitmapFontManager.install(name, style, options) is deprecated, use BitmapFontManager.install({name, style, ...options})`));let n=t?.name;if(!n)throw Error("[BitmapFontManager] Property `name` is required.");t={...this.defaultOptions,...t};let r=t.style,i=r instanceof Mi?r:new Mi(r),a=new $i({style:i,overrideFill:i._fill.fill!==null&&i._fill.fill!==void 0,skipKerning:t.skipKerning,padding:t.padding,resolution:t.resolution,overrideSize:!1}),o=Zi(t.chars);return a.ensureCharacters(o.join(``)),In.set(`${n}-bitmap`,a),a.once(`destroy`,()=>In.remove(`${n}-bitmap`)),a}uninstall(e){let t=`${e}-bitmap`,n=In.get(t);n&&(In.remove(t),n.destroy())}},oa=class{constructor(e){this._gpuBitmapText={},this._destroyRenderableBound=this.destroyRenderable.bind(this),this._renderer=e}validateRenderable(e){let t=this._getGpuBitmapText(e);return e._didTextUpdate&&(e._didTextUpdate=!1,this._updateContext(e,t)),this._renderer.renderPipes.graphics.validateRenderable(t)}addRenderable(e,t){let n=this._getGpuBitmapText(e);sa(e,n),e._didTextUpdate&&(e._didTextUpdate=!1,this._updateContext(e,n)),this._renderer.renderPipes.graphics.addRenderable(n,t),n.context.customShader&&this._updateDistanceField(e)}destroyRenderable(e){e.off(`destroyed`,this._destroyRenderableBound),this._destroyRenderableByUid(e.uid)}_destroyRenderableByUid(e){let t=this._gpuBitmapText[e].context;t.customShader&&=(G.return(t.customShader),null),G.return(this._gpuBitmapText[e]),this._gpuBitmapText[e]=null}updateRenderable(e){let t=this._getGpuBitmapText(e);sa(e,t),this._renderer.renderPipes.graphics.updateRenderable(t),t.context.customShader&&this._updateDistanceField(e)}_updateContext(e,t){let{context:n}=t,r=aa.getFont(e.text,e._style);n.clear(),r.distanceField.type!==`none`&&(n.customShader||=G.get(Yi));let i=Array.from(e.text),a=e._style,o=r.baseLineOffset,s=ea(i,a,r),c=0,l=a.padding,u=s.scale,d=s.width,f=s.height+s.offsetY;a._stroke&&(d+=a._stroke.width/u,f+=a._stroke.width/u),n.translate(-e._anchor._x*d-l,-e._anchor._y*f-l).scale(u,u);let p=r.applyFillAsTint?a._fill.color:16777215;for(let e=0;e<s.lines.length;e++){let t=s.lines[e];for(let e=0;e<t.charPositions.length;e++){let a=i[c++],s=r.chars[a];s?.texture&&n.texture(s.texture,p||`black`,Math.round(t.charPositions[e]+s.xOffset),Math.round(o+s.yOffset))}o+=r.lineHeight}}_getGpuBitmapText(e){return this._gpuBitmapText[e.uid]||this.initGpuText(e)}initGpuText(e){let t=G.get(J);return this._gpuBitmapText[e.uid]=t,this._updateContext(e,t),e.on(`destroyed`,this._destroyRenderableBound),this._gpuBitmapText[e.uid]}_updateDistanceField(e){let t=this._getGpuBitmapText(e).context,n=e._style.fontFamily,r=In.get(`${n}-bitmap`),{a:i,b:a,c:o,d:s}=e.groupTransform,c=Math.sqrt(i*i+a*a),l=Math.sqrt(o*o+s*s),u=(Math.abs(c)+Math.abs(l))/2,d=r.baseRenderedFontSize/e._style.fontSize,f=u*r.distanceField.range*(1/d);t.customShader.resources.localUniforms.uniforms.uDistance=f}destroy(){for(let e in this._gpuBitmapText)this._destroyRenderableByUid(e);this._gpuBitmapText=null,this._renderer=null}};oa.extension={type:[U.WebGLPipes,U.WebGPUPipes,U.CanvasPipes],name:`bitmapText`};function sa(e,t){t.groupTransform=e.groupTransform,t.groupColorAlpha=e.groupColorAlpha,t.groupColor=e.groupColor,t.groupBlendMode=e.groupBlendMode,t.globalDisplayStatus=e.globalDisplayStatus,t.groupTransform=e.groupTransform,t.localDisplayStatus=e.localDisplayStatus,t.groupAlpha=e.groupAlpha,t._roundPixels=e._roundPixels}var ca=class{constructor(e){this._gpuText=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this._renderer=e,this._renderer.runners.resolutionChange.add(this)}resolutionChange(){for(let e in this._gpuText){let t=this._gpuText[e].batchableSprite.renderable;t._autoResolution&&(t._resolution=this._renderer.resolution,t.onViewUpdate())}}validateRenderable(e){let t=this._getGpuText(e),n=e._getKey();return t.textureNeedsUploading?(t.textureNeedsUploading=!1,!0):t.currentKey!==n}addRenderable(e,t){let n=this._getGpuText(e).batchableSprite;e._didTextUpdate&&this._updateText(e),this._renderer.renderPipes.batch.addToBatch(n)}updateRenderable(e){let t=this._getGpuText(e).batchableSprite;e._didTextUpdate&&this._updateText(e),t.batcher.updateElement(t)}destroyRenderable(e){e.off(`destroyed`,this._destroyRenderableBound),this._destroyRenderableById(e.uid)}_destroyRenderableById(e){let t=this._gpuText[e];this._renderer.htmlText.decreaseReferenceCount(t.currentKey),G.return(t.batchableSprite),this._gpuText[e]=null}_updateText(e){let t=e._getKey(),n=this._getGpuText(e),r=n.batchableSprite;n.currentKey!==t&&this._updateGpuText(e).catch(e=>{console.error(e)}),e._didTextUpdate=!1;let i=e._style.padding;ee(r.bounds,e._anchor,r.texture,i)}async _updateGpuText(e){e._didTextUpdate=!1;let t=this._getGpuText(e);if(t.generatingTexture)return;let n=e._getKey();this._renderer.htmlText.decreaseReferenceCount(t.currentKey),t.generatingTexture=!0,t.currentKey=n;let r=e.resolution??this._renderer.resolution,i=await this._renderer.htmlText.getManagedTexture(e.text,r,e._style,e._getKey()),a=t.batchableSprite;a.texture=t.texture=i,t.generatingTexture=!1,t.textureNeedsUploading=!0,e.onViewUpdate();let o=e._style.padding;ee(a.bounds,e._anchor,a.texture,o)}_getGpuText(e){return this._gpuText[e.uid]||this.initGpuText(e)}initGpuText(e){let t={texture:R.EMPTY,currentKey:`--`,batchableSprite:G.get(Ve),textureNeedsUploading:!1,generatingTexture:!1},n=t.batchableSprite;return n.renderable=e,n.texture=R.EMPTY,n.bounds={minX:0,maxX:1,minY:0,maxY:0},n.roundPixels=this._renderer._roundPixels|e._roundPixels,e._resolution=e._autoResolution?this._renderer.resolution:e.resolution,this._gpuText[e.uid]=t,e.on(`destroyed`,this._destroyRenderableBound),t}destroy(){for(let e in this._gpuText)this._destroyRenderableById(e);this._gpuText=null,this._renderer=null}};ca.extension={type:[U.WebGLPipes,U.WebGPUPipes,U.CanvasPipes],name:`htmlText`};function la(){let{userAgent:e}=z.get().getNavigator();return/^((?!chrome|android).)*safari/i.test(e)}var ua=`http://www.w3.org/2000/svg`,da=`http://www.w3.org/1999/xhtml`,fa=class{constructor(){this.svgRoot=document.createElementNS(ua,`svg`),this.foreignObject=document.createElementNS(ua,`foreignObject`),this.domElement=document.createElementNS(da,`div`),this.styleElement=document.createElementNS(da,`style`),this.image=new Image;let{foreignObject:e,svgRoot:t,styleElement:n,domElement:r}=this;e.setAttribute(`width`,`10000`),e.setAttribute(`height`,`10000`),e.style.overflow=`hidden`,t.appendChild(e),e.appendChild(n),e.appendChild(r)}};function pa(e){let t=e._stroke,n=e._fill,r=[`div { ${[`color: ${K.shared.setValue(n.color).toHex()}`,`font-size: ${e.fontSize}px`,`font-family: ${e.fontFamily}`,`font-weight: ${e.fontWeight}`,`font-style: ${e.fontStyle}`,`font-variant: ${e.fontVariant}`,`letter-spacing: ${e.letterSpacing}px`,`text-align: ${e.align}`,`padding: ${e.padding}px`,`white-space: ${e.whiteSpace===`pre`&&e.wordWrap?`pre-wrap`:e.whiteSpace}`,...e.lineHeight?[`line-height: ${e.lineHeight}px`]:[],...e.wordWrap?[`word-wrap: ${e.breakWords?`break-all`:`break-word`}`,`max-width: ${e.wordWrapWidth}px`]:[],...t?[ha(t)]:[],...e.dropShadow?[ma(e.dropShadow)]:[],...e.cssOverrides].join(`;`)} }`];return va(e.tagStyles,r),r.join(` `)}function ma(e){let t=K.shared.setValue(e.color).setAlpha(e.alpha).toHexa(),n=`${Math.round(Math.cos(e.angle)*e.distance)}px ${Math.round(Math.sin(e.angle)*e.distance)}px`;return e.blur>0?`text-shadow: ${n} ${e.blur}px ${t}`:`text-shadow: ${n} ${t}`}function ha(e){return[`-webkit-text-stroke-width: ${e.width}px`,`-webkit-text-stroke-color: ${K.shared.setValue(e.color).toHex()}`,`text-stroke-width: ${e.width}px`,`text-stroke-color: ${K.shared.setValue(e.color).toHex()}`,`paint-order: stroke`].join(`;`)}var ga={fontSize:`font-size: {{VALUE}}px`,fontFamily:`font-family: {{VALUE}}`,fontWeight:`font-weight: {{VALUE}}`,fontStyle:`font-style: {{VALUE}}`,fontVariant:`font-variant: {{VALUE}}`,letterSpacing:`letter-spacing: {{VALUE}}px`,align:`text-align: {{VALUE}}`,padding:`padding: {{VALUE}}px`,whiteSpace:`white-space: {{VALUE}}`,lineHeight:`line-height: {{VALUE}}px`,wordWrapWidth:`max-width: {{VALUE}}px`},_a={fill:e=>`color: ${K.shared.setValue(e).toHex()}`,breakWords:e=>`word-wrap: ${e?`break-all`:`break-word`}`,stroke:ha,dropShadow:ma};function va(e,t){for(let n in e){let r=e[n],i=[];for(let e in r)_a[e]?i.push(_a[e](r[e])):ga[e]&&i.push(ga[e].replace(`{{VALUE}}`,r[e]));t.push(`${n} { ${i.join(`;`)} }`)}}var ya=class e extends Mi{constructor(e={}){super(e),this._cssOverrides=[],this.cssOverrides??=e.cssOverrides,this.tagStyles=e.tagStyles??{}}set cssOverrides(e){this._cssOverrides=e instanceof Array?e:[e],this.update()}get cssOverrides(){return this._cssOverrides}_generateKey(){return this._styleKey=Di(this)+this._cssOverrides.join(`-`),this._styleKey}update(){this._cssStyle=null,super.update()}clone(){return new e({align:this.align,breakWords:this.breakWords,dropShadow:this.dropShadow?{...this.dropShadow}:null,fill:this._fill,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth,cssOverrides:this.cssOverrides})}get cssStyle(){return this._cssStyle||=pa(this),this._cssStyle}addOverride(...e){let t=e.filter(e=>!this.cssOverrides.includes(e));t.length>0&&(this.cssOverrides.push(...t),this.update())}removeOverride(...e){let t=e.filter(e=>this.cssOverrides.includes(e));t.length>0&&(this.cssOverrides=this.cssOverrides.filter(e=>!t.includes(e)),this.update())}set fill(e){typeof e!=`string`&&typeof e!=`number`&&B(`[HTMLTextStyle] only color fill is not supported by HTMLText`),super.fill=e}set stroke(e){e&&typeof e!=`string`&&typeof e!=`number`&&B(`[HTMLTextStyle] only color stroke is not supported by HTMLText`),super.stroke=e}};function ba(e,t){let n=t.fontFamily,r=[],i={},a=e.match(/font-family:([^;"\s]+)/g);function o(e){i[e]||(r.push(e),i[e]=!0)}if(Array.isArray(n))for(let e=0;e<n.length;e++)o(n[e]);else o(n);a&&a.forEach(e=>{o(e.split(`:`)[1].trim())});for(let e in t.tagStyles){let n=t.tagStyles[e].fontFamily;o(n)}return r}async function xa(e){let t=await(await z.get().fetch(e)).blob(),n=new FileReader;return await new Promise((e,r)=>{n.onloadend=()=>e(n.result),n.onerror=r,n.readAsDataURL(t)})}async function Sa(e,t){let n=await xa(t);return`@font-face {
|
|
104
|
+
font-family: "${e.fontFamily}";
|
|
105
|
+
src: url('${n}');
|
|
106
|
+
font-weight: ${e.fontWeight};
|
|
107
|
+
font-style: ${e.fontStyle};
|
|
108
|
+
}`}var Ca=new Map;async function wa(e,t,n){let r=e.filter(e=>In.has(`${e}-and-url`)).map((e,r)=>{if(!Ca.has(e)){let{url:i}=In.get(`${e}-and-url`);r===0?Ca.set(e,Sa({fontWeight:t.fontWeight,fontStyle:t.fontStyle,fontFamily:e},i)):Ca.set(e,Sa({fontWeight:n.fontWeight,fontStyle:n.fontStyle,fontFamily:e},i))}return Ca.get(e)});return(await Promise.all(r)).join(`
|
|
109
|
+
`)}function Ta(e,t,n,r,i){let{domElement:a,styleElement:o,svgRoot:s}=i;a.innerHTML=`<style>${t.cssStyle}</style><div style='padding:0;'>${e}</div>`,a.setAttribute(`style`,`transform: scale(${n});transform-origin: top left; display: inline-block`),o.textContent=r;let{width:c,height:l}=i.image;return s.setAttribute(`width`,c.toString()),s.setAttribute(`height`,l.toString()),new XMLSerializer().serializeToString(s)}function Ea(e,t){let n=qe.getOptimalCanvasAndContext(e.width,e.height,t),{context:r}=n;return r.clearRect(0,0,e.width,e.height),r.drawImage(e,0,0),qe.returnCanvasAndContext(n),n.canvas}function Da(e,t,n){return new Promise(async r=>{n&&await new Promise(e=>setTimeout(e,100)),e.onload=()=>{r()},e.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(t)}`,e.crossOrigin=`anonymous`})}var Oa;function ka(e,t,n,r){r=r||Oa||(Oa=new fa);let{domElement:i,styleElement:a,svgRoot:o}=r;i.innerHTML=`<style>${t.cssStyle};</style><div style='padding:0'>${e}</div>`,i.setAttribute(`style`,`transform-origin: top left; display: inline-block`),n&&(a.textContent=n),document.body.appendChild(o);let s=i.getBoundingClientRect();o.remove();let c=Bi.measureFont(t.fontStyle).descent,l=t.padding*2;return{width:s.width-l,height:s.height+c-l}}var Aa=class{constructor(e){this._activeTextures={},this._renderer=e,this._createCanvas=e.type===he.WEBGPU}getTexture(e){return this._buildTexturePromise(e.text,e.resolution,e.style)}getManagedTexture(e,t,n,r){if(this._activeTextures[r])return this._increaseReferenceCount(r),this._activeTextures[r].promise;let i=this._buildTexturePromise(e,t,n).then(e=>(this._activeTextures[r].texture=e,e));return this._activeTextures[r]={texture:null,promise:i,usageCount:1},i}async _buildTexturePromise(e,t,n){let r=G.get(fa),i=ba(e,n),a=await wa(i,n,ya.defaultTextStyle),o=ka(e,n,a,r),s=Math.ceil(Math.ceil(Math.max(1,o.width)+n.padding*2)*t),c=Math.ceil(Math.ceil(Math.max(1,o.height)+n.padding*2)*t),l=r.image;l.width=(s|0)+2,l.height=(c|0)+2,await Da(l,Ta(e,n,t,a,r),la()&&i.length>0);let u=l;this._createCanvas&&(u=Ea(l,t));let d=Fi(u,l.width-2,l.height-2,t);return this._createCanvas&&this._renderer.texture.initSource(d.source),G.return(r),d}_increaseReferenceCount(e){this._activeTextures[e].usageCount++}decreaseReferenceCount(e){let t=this._activeTextures[e];t&&(t.usageCount--,t.usageCount===0&&(t.texture?this._cleanUp(t):t.promise.then(e=>{t.texture=e,this._cleanUp(t)}).catch(()=>{B(`HTMLTextSystem: Failed to clean texture`)}),this._activeTextures[e]=null))}_cleanUp(e){me.returnTexture(e.texture),e.texture.source.resource=null,e.texture.source.uploadMethodId=`unknown`}getReferenceCount(e){return this._activeTextures[e].usageCount}destroy(){this._activeTextures=null}};Aa.extension={type:[U.WebGLSystem,U.WebGPUSystem,U.CanvasSystem],name:`htmlText`},Aa.defaultFontOptions={fontFamily:`Arial`,fontStyle:`normal`,fontWeight:`normal`};var ja=class e extends He{constructor(...t){let n=t[0]??{};n instanceof Float32Array&&(W(V,`use new MeshGeometry({ positions, uvs, indices }) instead`),n={positions:n,uvs:t[1],indices:t[2]}),n={...e.defaultOptions,...n};let r=n.positions||new Float32Array([0,0,1,0,1,1,0,1]),i=n.uvs||new Float32Array([0,0,1,0,1,1,0,1]),a=n.indices||new Uint32Array([0,1,2,0,2,3]),o=n.shrinkBuffersToFit,s=new le({data:r,label:`attribute-mesh-positions`,shrinkToFit:o,usage:P.VERTEX|P.COPY_DST}),c=new le({data:i,label:`attribute-mesh-uvs`,shrinkToFit:o,usage:P.VERTEX|P.COPY_DST}),l=new le({data:a,label:`index-mesh-buffer`,shrinkToFit:o,usage:P.INDEX|P.COPY_DST});super({attributes:{aPosition:{buffer:s,format:`float32x2`,stride:8,offset:0},aUV:{buffer:c,format:`float32x2`,stride:8,offset:0}},indexBuffer:l,topology:n.topology}),this.batchMode=`auto`}get positions(){return this.attributes.aPosition.buffer.data}set positions(e){this.attributes.aPosition.buffer.data=e}get uvs(){return this.attributes.aUV.buffer.data}set uvs(e){this.attributes.aUV.buffer.data=e}get indices(){return this.indexBuffer.data}set indices(e){this.indexBuffer.data=e}};ja.defaultOptions={topology:`triangle-list`,shrinkBuffersToFit:!1};var Ma=ja,Na={name:`tiling-bit`,vertex:{header:`
|
|
110
|
+
struct TilingUniforms {
|
|
111
|
+
uMapCoord:mat3x3<f32>,
|
|
112
|
+
uClampFrame:vec4<f32>,
|
|
113
|
+
uClampOffset:vec2<f32>,
|
|
114
|
+
uTextureTransform:mat3x3<f32>,
|
|
115
|
+
uSizeAnchor:vec4<f32>
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
@group(2) @binding(0) var<uniform> tilingUniforms: TilingUniforms;
|
|
119
|
+
@group(2) @binding(1) var uTexture: texture_2d<f32>;
|
|
120
|
+
@group(2) @binding(2) var uSampler: sampler;
|
|
121
|
+
`,main:`
|
|
122
|
+
uv = (tilingUniforms.uTextureTransform * vec3(uv, 1.0)).xy;
|
|
123
|
+
|
|
124
|
+
position = (position - tilingUniforms.uSizeAnchor.zw) * tilingUniforms.uSizeAnchor.xy;
|
|
125
|
+
`},fragment:{header:`
|
|
126
|
+
struct TilingUniforms {
|
|
127
|
+
uMapCoord:mat3x3<f32>,
|
|
128
|
+
uClampFrame:vec4<f32>,
|
|
129
|
+
uClampOffset:vec2<f32>,
|
|
130
|
+
uTextureTransform:mat3x3<f32>,
|
|
131
|
+
uSizeAnchor:vec4<f32>
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
@group(2) @binding(0) var<uniform> tilingUniforms: TilingUniforms;
|
|
135
|
+
@group(2) @binding(1) var uTexture: texture_2d<f32>;
|
|
136
|
+
@group(2) @binding(2) var uSampler: sampler;
|
|
137
|
+
`,main:`
|
|
138
|
+
|
|
139
|
+
var coord = vUV + ceil(tilingUniforms.uClampOffset - vUV);
|
|
140
|
+
coord = (tilingUniforms.uMapCoord * vec3(coord, 1.0)).xy;
|
|
141
|
+
var unclamped = coord;
|
|
142
|
+
coord = clamp(coord, tilingUniforms.uClampFrame.xy, tilingUniforms.uClampFrame.zw);
|
|
143
|
+
|
|
144
|
+
var bias = 0.;
|
|
145
|
+
|
|
146
|
+
if(unclamped.x == coord.x && unclamped.y == coord.y)
|
|
147
|
+
{
|
|
148
|
+
bias = -32.;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
outColor = textureSampleBias(uTexture, uSampler, coord, bias);
|
|
152
|
+
`}},Pa={name:`tiling-bit`,vertex:{header:`
|
|
153
|
+
uniform mat3 uTextureTransform;
|
|
154
|
+
uniform vec4 uSizeAnchor;
|
|
155
|
+
|
|
156
|
+
`,main:`
|
|
157
|
+
uv = (uTextureTransform * vec3(aUV, 1.0)).xy;
|
|
158
|
+
|
|
159
|
+
position = (position - uSizeAnchor.zw) * uSizeAnchor.xy;
|
|
160
|
+
`},fragment:{header:`
|
|
161
|
+
uniform sampler2D uTexture;
|
|
162
|
+
uniform mat3 uMapCoord;
|
|
163
|
+
uniform vec4 uClampFrame;
|
|
164
|
+
uniform vec2 uClampOffset;
|
|
165
|
+
`,main:`
|
|
166
|
+
|
|
167
|
+
vec2 coord = vUV + ceil(uClampOffset - vUV);
|
|
168
|
+
coord = (uMapCoord * vec3(coord, 1.0)).xy;
|
|
169
|
+
vec2 unclamped = coord;
|
|
170
|
+
coord = clamp(coord, uClampFrame.xy, uClampFrame.zw);
|
|
171
|
+
|
|
172
|
+
outColor = texture(uTexture, coord, unclamped == coord ? 0.0 : -32.0);// lod-bias very negative to force lod 0
|
|
173
|
+
|
|
174
|
+
`}},Fa,Ia,La=class extends we{constructor(){Fa??=Ne({name:`tiling-sprite-shader`,bits:[ze,Na,je]}),Ia??=xe({name:`tiling-sprite-shader`,bits:[ke,Pa,Le]});let e=new We({uMapCoord:{value:new H,type:`mat3x3<f32>`},uClampFrame:{value:new Float32Array([0,0,1,1]),type:`vec4<f32>`},uClampOffset:{value:new Float32Array([0,0]),type:`vec2<f32>`},uTextureTransform:{value:new H,type:`mat3x3<f32>`},uSizeAnchor:{value:new Float32Array([100,100,.5,.5]),type:`vec4<f32>`}});super({glProgram:Ia,gpuProgram:Fa,resources:{localUniforms:new We({uTransformMatrix:{value:new H,type:`mat3x3<f32>`},uColor:{value:new Float32Array([1,1,1,1]),type:`vec4<f32>`},uRound:{value:0,type:`f32`}}),tilingUniforms:e,uTexture:R.EMPTY.source,uSampler:R.EMPTY.source.style}})}updateUniforms(e,t,n,r,i,a){let o=this.resources.tilingUniforms,s=a.width,c=a.height,l=a.textureMatrix,u=o.uniforms.uTextureTransform;u.set(n.a*s/e,n.b*s/t,n.c*c/e,n.d*c/t,n.tx/e,n.ty/t),u.invert(),o.uniforms.uMapCoord=l.mapCoord,o.uniforms.uClampFrame=l.uClampFrame,o.uniforms.uClampOffset=l.uClampOffset,o.uniforms.uTextureTransform=u,o.uniforms.uSizeAnchor[0]=e,o.uniforms.uSizeAnchor[1]=t,o.uniforms.uSizeAnchor[2]=r,o.uniforms.uSizeAnchor[3]=i,a&&(this.resources.uTexture=a.source,this.resources.uSampler=a.source.style)}},Ra=class extends Ma{constructor(){super({positions:new Float32Array([0,0,1,0,1,1,0,1]),uvs:new Float32Array([0,0,1,0,1,1,0,1]),indices:new Uint32Array([0,1,2,0,2,3])})}};function za(e,t){let n=e.anchor.x,r=e.anchor.y;t[0]=-n*e.width,t[1]=-r*e.height,t[2]=(1-n)*e.width,t[3]=-r*e.height,t[4]=(1-n)*e.width,t[5]=(1-r)*e.height,t[6]=-n*e.width,t[7]=(1-r)*e.height}function Ba(e,t,n,r){let i=0,a=e.length/(t||2),o=r.a,s=r.b,c=r.c,l=r.d,u=r.tx,d=r.ty;for(n*=t;i<a;){let r=e[n],a=e[n+1];e[n]=o*r+c*a+u,e[n+1]=s*r+l*a+d,n+=t,i++}}function Va(e,t){let n=e.texture,r=n.frame.width,i=n.frame.height,a=0,o=0;e._applyAnchorToTexture&&(a=e.anchor.x,o=e.anchor.y),t[0]=t[6]=-a,t[2]=t[4]=1-a,t[1]=t[3]=-o,t[5]=t[7]=1-o;let s=H.shared;s.copyFrom(e._tileTransform.matrix),s.tx/=e.width,s.ty/=e.height,s.invert(),s.scale(e.width/r,e.height/i),Ba(t,2,0,s)}var Ha=new Ra,Ua=class{constructor(e){this._state=ce.default2d,this._tilingSpriteDataHash=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this._renderer=e}validateRenderable(e){let t=this._getTilingSpriteData(e),n=t.canBatch;this._updateCanBatch(e);let r=t.canBatch;if(r&&r===n){let{batchableMesh:n}=t;if(n&&n.texture._source!==e.texture._source)return!n.batcher.checkAndUpdateTexture(n,e.texture)}return n!==r}addRenderable(e,t){let n=this._renderer.renderPipes.batch;this._updateCanBatch(e);let r=this._getTilingSpriteData(e),{geometry:i,canBatch:a}=r;if(a){r.batchableMesh||=new vr;let t=r.batchableMesh;e._didTilingSpriteUpdate&&(e._didTilingSpriteUpdate=!1,this._updateBatchableMesh(e),t.geometry=i,t.mesh=e,t.texture=e._texture),t.roundPixels=this._renderer._roundPixels|e._roundPixels,n.addToBatch(t)}else n.break(t),r.shader||=new La,this.updateRenderable(e),t.add(e)}execute(e){let{shader:t}=this._tilingSpriteDataHash[e.uid];t.groups[0]=this._renderer.globalUniforms.bindGroup;let n=t.resources.localUniforms.uniforms;n.uTransformMatrix=e.groupTransform,n.uRound=this._renderer._roundPixels|e._roundPixels,Ue(e.groupColorAlpha,n.uColor,0),this._state.blendMode=ae(e.groupBlendMode,e.texture._source),this._renderer.encoder.draw({geometry:Ha,shader:t,state:this._state})}updateRenderable(e){let t=this._getTilingSpriteData(e),{canBatch:n}=t;if(n){let{batchableMesh:n}=t;e._didTilingSpriteUpdate&&this._updateBatchableMesh(e),n.batcher.updateElement(n)}else if(e._didTilingSpriteUpdate){let{shader:n}=t;n.updateUniforms(e.width,e.height,e._tileTransform.matrix,e.anchor.x,e.anchor.y,e.texture)}e._didTilingSpriteUpdate=!1}destroyRenderable(e){let t=this._getTilingSpriteData(e);t.batchableMesh=null,t.shader?.destroy(),this._tilingSpriteDataHash[e.uid]=null,e.off(`destroyed`,this._destroyRenderableBound)}_getTilingSpriteData(e){return this._tilingSpriteDataHash[e.uid]||this._initTilingSpriteData(e)}_initTilingSpriteData(e){let t=new Ma({indices:Ha.indices,positions:Ha.positions.slice(),uvs:Ha.uvs.slice()});return this._tilingSpriteDataHash[e.uid]={canBatch:!0,renderable:e,geometry:t},e.on(`destroyed`,this._destroyRenderableBound),this._tilingSpriteDataHash[e.uid]}_updateBatchableMesh(e){let{geometry:t}=this._getTilingSpriteData(e),n=e.texture.source.style;n.addressMode!==`repeat`&&(n.addressMode=`repeat`,n.update()),Va(e,t.uvs),za(e,t.positions)}destroy(){for(let e in this._tilingSpriteDataHash)this.destroyRenderable(this._tilingSpriteDataHash[e].renderable);this._tilingSpriteDataHash=null,this._renderer=null}_updateCanBatch(e){let t=this._getTilingSpriteData(e),n=e.texture,r=!0;return this._renderer.type===he.WEBGL&&(r=this._renderer.context.supports.nonPowOf2wrapping),t.canBatch=n.textureMatrix.isSimple&&(r||n.source.isPowerOfTwo),t.canBatch}};Ua.extension={type:[U.WebGLPipes,U.WebGPUPipes,U.CanvasPipes],name:`tilingSprite`};var Wa=class e extends Ma{constructor(...e){super({});let t=e[0]??{};typeof t==`number`&&(W(V,`PlaneGeometry constructor changed please use { width, height, verticesX, verticesY } instead`),t={width:t,height:e[1],verticesX:e[2],verticesY:e[3]}),this.build(t)}build(t){t={...e.defaultOptions,...t},this.verticesX=this.verticesX??t.verticesX,this.verticesY=this.verticesY??t.verticesY,this.width=this.width??t.width,this.height=this.height??t.height;let n=this.verticesX*this.verticesY,r=[],i=[],a=[],o=this.verticesX-1,s=this.verticesY-1,c=this.width/o,l=this.height/s;for(let e=0;e<n;e++){let t=e%this.verticesX,n=e/this.verticesX|0;r.push(t*c,n*l),i.push(t/o,n/s)}let u=o*s;for(let e=0;e<u;e++){let t=e%o,n=e/o|0,r=n*this.verticesX+t,i=n*this.verticesX+t+1,s=(n+1)*this.verticesX+t,c=(n+1)*this.verticesX+t+1;a.push(r,i,s,i,c,s)}this.buffers[0].data=new Float32Array(r),this.buffers[1].data=new Float32Array(i),this.indexBuffer.data=new Uint32Array(a),this.buffers[0].update(),this.buffers[1].update(),this.indexBuffer.update()}};Wa.defaultOptions={width:100,height:100,verticesX:10,verticesY:10};var Ga=Wa,Ka=class e extends Ga{constructor(t={}){t={...e.defaultOptions,...t},super({width:t.width,height:t.height,verticesX:4,verticesY:4}),this.update(t)}update(e){this.width=e.width??this.width,this.height=e.height??this.height,this._originalWidth=e.originalWidth??this._originalWidth,this._originalHeight=e.originalHeight??this._originalHeight,this._leftWidth=e.leftWidth??this._leftWidth,this._rightWidth=e.rightWidth??this._rightWidth,this._topHeight=e.topHeight??this._topHeight,this._bottomHeight=e.bottomHeight??this._bottomHeight,this.updateUvs(),this.updatePositions()}updatePositions(){let e=this.positions,t=this._leftWidth+this._rightWidth,n=this.width>t?1:this.width/t,r=this._topHeight+this._bottomHeight,i=this.height>r?1:this.height/r,a=Math.min(n,i);e[9]=e[11]=e[13]=e[15]=this._topHeight*a,e[17]=e[19]=e[21]=e[23]=this.height-this._bottomHeight*a,e[25]=e[27]=e[29]=e[31]=this.height,e[2]=e[10]=e[18]=e[26]=this._leftWidth*a,e[4]=e[12]=e[20]=e[28]=this.width-this._rightWidth*a,e[6]=e[14]=e[22]=e[30]=this.width,this.getBuffer(`aPosition`).update()}updateUvs(){let e=this.uvs;e[0]=e[8]=e[16]=e[24]=0,e[1]=e[3]=e[5]=e[7]=0,e[6]=e[14]=e[22]=e[30]=1,e[25]=e[27]=e[29]=e[31]=1;let t=1/this._originalWidth,n=1/this._originalHeight;e[2]=e[10]=e[18]=e[26]=t*this._leftWidth,e[9]=e[11]=e[13]=e[15]=n*this._topHeight,e[4]=e[12]=e[20]=e[28]=1-t*this._rightWidth,e[17]=e[19]=e[21]=e[23]=1-n*this._bottomHeight,this.getBuffer(`aUV`).update()}};Ka.defaultOptions={width:100,height:100,leftWidth:10,topHeight:10,rightWidth:10,bottomHeight:10,originalWidth:100,originalHeight:100};var qa=Ka,Ja=class{constructor(e){this._gpuSpriteHash=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this._renderer=e}addRenderable(e,t){let n=this._getGpuSprite(e);e._didSpriteUpdate&&this._updateBatchableSprite(e,n),this._renderer.renderPipes.batch.addToBatch(n)}updateRenderable(e){let t=this._gpuSpriteHash[e.uid];e._didSpriteUpdate&&this._updateBatchableSprite(e,t),t.batcher.updateElement(t)}validateRenderable(e){let t=e._texture,n=this._getGpuSprite(e);return n.texture._source===t._source?!1:!n.batcher.checkAndUpdateTexture(n,t)}destroyRenderable(e){let t=this._gpuSpriteHash[e.uid];G.return(t.geometry),G.return(t),this._gpuSpriteHash[e.uid]=null,e.off(`destroyed`,this._destroyRenderableBound)}_updateBatchableSprite(e,t){e._didSpriteUpdate=!1,t.geometry.update(e),t.texture=e._texture}_getGpuSprite(e){return this._gpuSpriteHash[e.uid]||this._initGPUSprite(e)}_initGPUSprite(e){let t=G.get(vr);return t.geometry=G.get(qa),t.mesh=e,t.texture=e._texture,t.roundPixels=this._renderer._roundPixels|e._roundPixels,e._didSpriteUpdate=!0,this._gpuSpriteHash[e.uid]=t,e.on(`destroyed`,this._destroyRenderableBound),t}destroy(){for(let e in this._gpuSpriteHash)this._gpuSpriteHash[e].geometry.destroy();this._gpuSpriteHash=null,this._renderer=null}};Ja.extension={type:[U.WebGLPipes,U.WebGPUPipes,U.CanvasPipes],name:`nineSliceSprite`};var Ya=class{constructor(e){this._renderer=e}push(e,t,n){this._renderer.renderPipes.batch.break(n),n.add({renderPipeId:`filter`,canBundle:!1,action:`pushFilter`,container:t,filterEffect:e})}pop(e,t,n){this._renderer.renderPipes.batch.break(n),n.add({renderPipeId:`filter`,action:`popFilter`,canBundle:!1})}execute(e){e.action===`pushFilter`?this._renderer.filter.push(e):e.action===`popFilter`&&this._renderer.filter.pop()}destroy(){this._renderer=null}};Ya.extension={type:[U.WebGLPipes,U.WebGPUPipes,U.CanvasPipes],name:`filter`};var Xa=new H;function Za(e,t){return t.clear(),Qa(e,t),t.isValid||t.set(0,0,0,0),e.renderGroup?t.applyMatrix(e.renderGroup.localTransform):t.applyMatrix(e.parentRenderGroup.worldTransform),t}function Qa(e,t){if(e.localDisplayStatus!==7||!e.measurable)return;let n=!!e.effects.length,r=t;if((e.renderGroup||n)&&(r=pe.get().clear()),e.boundsArea)t.addRect(e.boundsArea,e.worldTransform);else{if(e.renderPipeId){let t=e.bounds;r.addFrame(t.minX,t.minY,t.maxX,t.maxY,e.groupTransform)}let t=e.children;for(let e=0;e<t.length;e++)Qa(t[e],r)}if(n){let n=!1;for(let t=0;t<e.effects.length;t++)e.effects[t].addBounds&&(n||(n=!0,r.applyMatrix(e.parentRenderGroup.worldTransform)),e.effects[t].addBounds(r,!0));n&&(r.applyMatrix(e.parentRenderGroup.worldTransform.copyTo(Xa).invert()),t.addBounds(r,e.relativeGroupTransform)),t.addBounds(r),pe.return(r)}else e.renderGroup&&(t.addBounds(r,e.relativeGroupTransform),pe.return(r))}function $a(e,t){t.clear();let n=t.matrix;for(let n=0;n<e.length;n++){let r=e[n];r.globalDisplayStatus<7||(t.matrix=r.worldTransform,r.addBounds(t))}return t.matrix=n,t}var eo=new He({attributes:{aPosition:{buffer:new Float32Array([0,0,1,0,1,1,0,1]),format:`float32x2`,stride:8,offset:0}},indexBuffer:new Uint32Array([0,1,2,0,2,3])}),to=class{constructor(e){this._filterStackIndex=0,this._filterStack=[],this._filterGlobalUniforms=new We({uInputSize:{value:new Float32Array(4),type:`vec4<f32>`},uInputPixel:{value:new Float32Array(4),type:`vec4<f32>`},uInputClamp:{value:new Float32Array(4),type:`vec4<f32>`},uOutputFrame:{value:new Float32Array(4),type:`vec4<f32>`},uGlobalFrame:{value:new Float32Array(4),type:`vec4<f32>`},uOutputTexture:{value:new Float32Array(4),type:`vec4<f32>`}}),this._globalFilterBindGroup=new re({}),this.renderer=e}get activeBackTexture(){return this._activeFilterData?.backTexture}push(e){let t=this.renderer,n=e.filterEffect.filters;this._filterStack[this._filterStackIndex]||(this._filterStack[this._filterStackIndex]=this._getFilterData());let r=this._filterStack[this._filterStackIndex];if(this._filterStackIndex++,n.length===0){r.skip=!0;return}let i=r.bounds;e.renderables?$a(e.renderables,i):e.filterEffect.filterArea?(i.clear(),i.addRect(e.filterEffect.filterArea),i.applyMatrix(e.container.worldTransform)):Za(e.container,i);let a=t.renderTarget.renderTarget.colorTexture.source,o=1/0,s=0,c=!0,l=!1,u=!1;for(let e=0;e<n.length;e++){let r=n[e];if(o=Math.min(o,r.resolution===`inherit`?a._resolution:r.resolution),s+=r.padding,r.antialias===`off`?c=!1:r.antialias===`inherit`&&(c&&=a.antialias),!(r.compatibleRenderers&t.type)){u=!1;break}if(r.blendRequired&&!(t.backBuffer?.useBackBuffer??!0)){B("Blend filter requires backBuffer on WebGL renderer to be enabled. Set `useBackBuffer: true` in the renderer options."),u=!1;break}u=r.enabled||u,l||=r.blendRequired}if(!u){r.skip=!0;return}let d=t.renderTarget.rootViewPort;if(i.scale(o).fitBounds(0,d.width,0,d.height).ceil().scale(1/o).pad(s|0),!i.isPositive){r.skip=!0;return}r.skip=!1,r.bounds=i,r.blendRequired=l,r.container=e.container,r.filterEffect=e.filterEffect,r.previousRenderSurface=t.renderTarget.renderSurface,r.inputTexture=me.getOptimalTexture(i.width,i.height,o,c),t.renderTarget.bind(r.inputTexture,!0),t.globalUniforms.push({offset:i})}pop(){let e=this.renderer;this._filterStackIndex--;let t=this._filterStack[this._filterStackIndex];if(t.skip)return;this._activeFilterData=t;let n=t.inputTexture,r=t.bounds,i=R.EMPTY;if(e.renderTarget.finishRenderPass(),t.blendRequired){let n=this._filterStackIndex>0?this._filterStack[this._filterStackIndex-1].bounds:null,a=e.renderTarget.getRenderTarget(t.previousRenderSurface);i=this.getBackTexture(a,r,n)}t.backTexture=i;let a=t.filterEffect.filters;if(this._globalFilterBindGroup.setResource(n.source.style,2),this._globalFilterBindGroup.setResource(i.source,3),e.globalUniforms.pop(),a.length===1)a[0].apply(this,n,t.previousRenderSurface,!1),me.returnTexture(n);else{let e=t.inputTexture,n=me.getOptimalTexture(r.width,r.height,e.source._resolution,!1),i=0;for(i=0;i<a.length-1;++i){a[i].apply(this,e,n,!0);let t=e;e=n,n=t}a[i].apply(this,e,t.previousRenderSurface,!1),me.returnTexture(e),me.returnTexture(n)}t.blendRequired&&me.returnTexture(i)}getBackTexture(e,t,n){let r=e.colorTexture.source._resolution,i=me.getOptimalTexture(t.width,t.height,r,!1),a=t.minX,o=t.minY;n&&(a-=n.minX,o-=n.minY),a=Math.floor(a*r),o=Math.floor(o*r);let s=Math.ceil(t.width*r),c=Math.ceil(t.height*r);return this.renderer.renderTarget.copyToTexture(e,i,{x:a,y:o},{width:s,height:c},{x:0,y:0}),i}applyFilter(e,t,n,r){let i=this.renderer,a=this._filterStack[this._filterStackIndex],o=a.bounds,s=Oe.shared,c=a.previousRenderSurface===n,l=this.renderer.renderTarget.rootRenderTarget.colorTexture.source._resolution,u=this._filterStackIndex-1;for(;u>0&&this._filterStack[u].skip;)--u;u>0&&(l=this._filterStack[u].inputTexture.source._resolution);let d=this._filterGlobalUniforms,f=d.uniforms,p=f.uOutputFrame,m=f.uInputSize,h=f.uInputPixel,g=f.uInputClamp,_=f.uGlobalFrame,v=f.uOutputTexture;if(c){let e=this._filterStackIndex;for(;e>0;){e--;let t=this._filterStack[this._filterStackIndex-1];if(!t.skip){s.x=t.bounds.minX,s.y=t.bounds.minY;break}}p[0]=o.minX-s.x,p[1]=o.minY-s.y}else p[0]=0,p[1]=0;p[2]=t.frame.width,p[3]=t.frame.height,m[0]=t.source.width,m[1]=t.source.height,m[2]=1/m[0],m[3]=1/m[1],h[0]=t.source.pixelWidth,h[1]=t.source.pixelHeight,h[2]=1/h[0],h[3]=1/h[1],g[0]=.5*h[2],g[1]=.5*h[3],g[2]=t.frame.width*m[2]-.5*h[2],g[3]=t.frame.height*m[3]-.5*h[3];let y=this.renderer.renderTarget.rootRenderTarget.colorTexture;_[0]=s.x*l,_[1]=s.y*l,_[2]=y.source.width*l,_[3]=y.source.height*l;let b=this.renderer.renderTarget.getRenderTarget(n);if(i.renderTarget.bind(n,!!r),n instanceof R?(v[0]=n.frame.width,v[1]=n.frame.height):(v[0]=b.width,v[1]=b.height),v[2]=b.isRoot?-1:1,d.update(),i.renderPipes.uniformBatch){let e=i.renderPipes.uniformBatch.getUboResource(d);this._globalFilterBindGroup.setResource(e,0)}else this._globalFilterBindGroup.setResource(d,0);this._globalFilterBindGroup.setResource(t.source,1),this._globalFilterBindGroup.setResource(t.source.style,2),e.groups[0]=this._globalFilterBindGroup,i.encoder.draw({geometry:eo,shader:e,state:e._state,topology:`triangle-list`}),i.type===he.WEBGL&&i.renderTarget.finishRenderPass()}_getFilterData(){return{skip:!1,inputTexture:null,bounds:new k,container:null,filterEffect:null,blendRequired:!1,previousRenderSurface:null}}calculateSpriteMatrix(e,t){let n=this._activeFilterData,r=e.set(n.inputTexture._source.width,0,0,n.inputTexture._source.height,n.bounds.minX,n.bounds.minY),i=t.worldTransform.copyTo(H.shared);return i.invert(),r.prepend(i),r.scale(1/t.texture.frame.width,1/t.texture.frame.height),r.translate(t.anchor.x,t.anchor.y),r}};to.extension={type:[U.WebGLSystem,U.WebGPUSystem],name:`filter`};var no=class{init(){let e=new We({uColor:{value:new Float32Array([1,1,1,1]),type:`vec4<f32>`},uTransformMatrix:{value:new H,type:`mat3x3<f32>`},uRound:{value:0,type:`f32`}}),t=Te(),n=xe({name:`graphics`,bits:[ve,De(t),ke,Le]});this.shader=new we({glProgram:n,resources:{localUniforms:e,batchSamplers:Je(t)}})}execute(e,t){let n=t.context,r=n.customShader||this.shader,i=e.renderer,{geometry:a,instructions:o}=i.graphicsContext.getContextRenderData(n);r.groups[0]=i.globalUniforms.bindGroup,i.state.set(e.state),i.shader.bind(r),i.geometry.bind(a,r.glProgram);let s=o.instructions;for(let e=0;e<o.instructionSize;e++){let t=s[e];if(t.size){for(let e=0;e<t.textures.count;e++)i.texture.bind(t.textures.textures[e],e);i.geometry.draw(`triangle-list`,t.size,t.start)}}}destroy(){this.shader.destroy(!0),this.shader=null}};no.extension={type:[U.WebGLPipesAdaptor],name:`graphics`};var ro=class{init(){let e=xe({name:`mesh`,bits:[ke,$e,Le]});this._shader=new we({glProgram:e,resources:{uTexture:R.EMPTY.source,textureUniforms:{uTextureMatrix:{type:`mat3x3<f32>`,value:new H}}}})}execute(e,t){let n=e.renderer,r=t._shader;if(!r){r=this._shader;let e=t.texture,n=e.source;r.resources.uTexture=n,r.resources.uSampler=n.style,r.resources.textureUniforms.uniforms.uTextureMatrix=e.textureMatrix.mapCoord}else if(!r.glProgram){B(`Mesh shader has no glProgram`,t.shader);return}r.groups[100]=n.globalUniforms.bindGroup,r.groups[101]=e.localUniformsBindGroup,n.encoder.draw({geometry:t._geometry,shader:r,state:t.state})}destroy(){this._shader.destroy(!0),this._shader=null}};ro.extension={type:[U.WebGLPipesAdaptor],name:`mesh`};var io=class{constructor(){this._didUpload=!1,this._tempState=ce.for2d()}init(e){let t=Te(),n=xe({name:`batch`,bits:[ve,De(t),Le]});this._shader=new we({glProgram:n,resources:{batchSamplers:Je(t)}}),e.renderer.runners.contextChange.add(this)}contextChange(){this._didUpload=!1}start(e,t){let n=e.renderer;n.shader.bind(this._shader,this._didUpload),n.shader.updateUniformGroup(n.globalUniforms.uniformGroup),n.geometry.bind(t,this._shader.glProgram)}execute(e,t){let n=e.renderer;this._didUpload=!0,this._tempState.blendMode=t.blendMode,n.state.set(this._tempState);let r=t.textures.textures;for(let e=0;e<t.textures.count;e++)n.texture.bind(r[e],e);n.geometry.draw(`triangle-list`,t.size,t.start)}destroy(){this._shader.destroy(!0),this._shader=null}};io.extension={type:[U.WebGLPipesAdaptor],name:`batch`};var ao=(e=>(e[e.ELEMENT_ARRAY_BUFFER=34963]=`ELEMENT_ARRAY_BUFFER`,e[e.ARRAY_BUFFER=34962]=`ARRAY_BUFFER`,e[e.UNIFORM_BUFFER=35345]=`UNIFORM_BUFFER`,e))(ao||{}),oo=class{constructor(e,t){this.buffer=e||null,this.updateID=-1,this.byteLength=-1,this.type=t}},so=class{constructor(e){this._gpuBuffers=Object.create(null),this._boundBufferBases=Object.create(null),this._renderer=e}destroy(){this._renderer=null,this._gl=null,this._gpuBuffers=null,this._boundBufferBases=null}contextChange(){this._gpuBuffers=Object.create(null),this._gl=this._renderer.gl}getGlBuffer(e){return this._gpuBuffers[e.uid]||this.createGLBuffer(e)}bind(e){let{_gl:t}=this,n=this.getGlBuffer(e);t.bindBuffer(n.type,n.buffer)}bindBufferBase(e,t){let{_gl:n}=this;if(this._boundBufferBases[t]!==e){let r=this.getGlBuffer(e);this._boundBufferBases[t]=e,n.bindBufferBase(n.UNIFORM_BUFFER,t,r.buffer)}}bindBufferRange(e,t,n){let{_gl:r}=this;n||=0;let i=this.getGlBuffer(e);r.bindBufferRange(r.UNIFORM_BUFFER,t||0,i.buffer,n*256,256)}updateBuffer(e){let{_gl:t}=this,n=this.getGlBuffer(e);if(e._updateID===n.updateID)return n;n.updateID=e._updateID,t.bindBuffer(n.type,n.buffer);let r=e.data;if(n.byteLength>=e.data.byteLength)t.bufferSubData(n.type,0,r,0,e._updateSize/r.BYTES_PER_ELEMENT);else{let i=e.descriptor.usage&P.STATIC?t.STATIC_DRAW:t.DYNAMIC_DRAW;n.byteLength=r.byteLength,t.bufferData(n.type,r,i)}return n}destroyAll(){let e=this._gl;for(let t in this._gpuBuffers)e.deleteBuffer(this._gpuBuffers[t].buffer);this._gpuBuffers=Object.create(null)}onBufferDestroy(e,t){let n=this._gpuBuffers[e.uid],r=this._gl;t||r.deleteBuffer(n.buffer),this._gpuBuffers[e.uid]=null}createGLBuffer(e){let{_gl:t}=this,n=ao.ARRAY_BUFFER;e.descriptor.usage&P.INDEX?n=ao.ELEMENT_ARRAY_BUFFER:e.descriptor.usage&P.UNIFORM&&(n=ao.UNIFORM_BUFFER);let r=new oo(t.createBuffer(),n);return this._gpuBuffers[e.uid]=r,e.on(`destroy`,this.onBufferDestroy,this),r}};so.extension={type:[U.WebGLSystem],name:`buffer`};var co=class e{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(t){if(t={...e.defaultOptions,...t},t.context)this.initFromContext(t.context);else{let e=this._renderer.background.alpha<1,n=t.premultipliedAlpha??!0,r=t.antialias&&!this._renderer.backBuffer.useBackBuffer;this.createContext(t.preferWebGLVersion,{alpha:e,premultipliedAlpha:n,antialias:r,stencil:!0,preserveDrawingBuffer:t.preserveDrawingBuffer,powerPreference:t.powerPreference??`default`})}}initFromContext(e){this.gl=e,this.webGLVersion=e instanceof z.get().getWebGLRenderingContext()?1:2,this.getExtensions(),this.validateContext(e),this._renderer.runners.contextChange.emit(e);let t=this._renderer.view.canvas;t.addEventListener(`webglcontextlost`,this.handleContextLost,!1),t.addEventListener(`webglcontextrestored`,this.handleContextRestored,!1)}createContext(e,t){let n,r=this._renderer.view.canvas;if(e===2&&(n=r.getContext(`webgl2`,t)),!n&&(n=r.getContext(`webgl`,t),!n))throw Error(`This browser does not support WebGL. Try using the canvas renderer`);this.gl=n,this.initFromContext(this.gl)}getExtensions(){let{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`)};let n=e.getExtension(`WEBGL_provoking_vertex`);n&&n.provokingVertexWEBGL(n.FIRST_VERTEX_CONVENTION_WEBGL)}}handleContextLost(e){e.preventDefault(),this._contextLossForced&&(this._contextLossForced=!1,setTimeout(()=>{this.gl.isContextLost()&&this.extensions.loseContext?.restoreContext()},0))}handleContextRestored(){this._renderer.runners.contextChange.emit(this.gl)}destroy(){let 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){let t=e.getContextAttributes();t&&!t.stencil&&B(`Provided WebGL context does not have a stencil buffer, masks may not render correctly`);let n=this.supports,r=this.webGLVersion===2,i=this.extensions;n.uint32Indices=r||!!i.uint32ElementIndex,n.uniformBufferObject=r,n.vertexArrayObject=r||!!i.vertexArrayObject,n.srgbTextures=r||!!i.srgb,n.nonPowOf2wrapping=r,n.nonPowOf2mipmaps=r,n.msaa=r,n.uint32Indices||B(`Provided WebGL context does not support 32 index buffer, large scenes may not render correctly`)}};co.extension={type:[U.WebGLSystem],name:`context`},co.defaultOptions={context:null,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:void 0,preferWebGLVersion:2};var lo=co,uo=(e=>(e[e.RGBA=6408]=`RGBA`,e[e.RGB=6407]=`RGB`,e[e.RG=33319]=`RG`,e[e.RED=6403]=`RED`,e[e.RGBA_INTEGER=36249]=`RGBA_INTEGER`,e[e.RGB_INTEGER=36248]=`RGB_INTEGER`,e[e.RG_INTEGER=33320]=`RG_INTEGER`,e[e.RED_INTEGER=36244]=`RED_INTEGER`,e[e.ALPHA=6406]=`ALPHA`,e[e.LUMINANCE=6409]=`LUMINANCE`,e[e.LUMINANCE_ALPHA=6410]=`LUMINANCE_ALPHA`,e[e.DEPTH_COMPONENT=6402]=`DEPTH_COMPONENT`,e[e.DEPTH_STENCIL=34041]=`DEPTH_STENCIL`,e))(uo||{}),fo=(e=>(e[e.TEXTURE_2D=3553]=`TEXTURE_2D`,e[e.TEXTURE_CUBE_MAP=34067]=`TEXTURE_CUBE_MAP`,e[e.TEXTURE_2D_ARRAY=35866]=`TEXTURE_2D_ARRAY`,e[e.TEXTURE_CUBE_MAP_POSITIVE_X=34069]=`TEXTURE_CUBE_MAP_POSITIVE_X`,e[e.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]=`TEXTURE_CUBE_MAP_NEGATIVE_X`,e[e.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]=`TEXTURE_CUBE_MAP_POSITIVE_Y`,e[e.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]=`TEXTURE_CUBE_MAP_NEGATIVE_Y`,e[e.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]=`TEXTURE_CUBE_MAP_POSITIVE_Z`,e[e.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]=`TEXTURE_CUBE_MAP_NEGATIVE_Z`,e))(fo||{}),Y=(e=>(e[e.UNSIGNED_BYTE=5121]=`UNSIGNED_BYTE`,e[e.UNSIGNED_SHORT=5123]=`UNSIGNED_SHORT`,e[e.UNSIGNED_SHORT_5_6_5=33635]=`UNSIGNED_SHORT_5_6_5`,e[e.UNSIGNED_SHORT_4_4_4_4=32819]=`UNSIGNED_SHORT_4_4_4_4`,e[e.UNSIGNED_SHORT_5_5_5_1=32820]=`UNSIGNED_SHORT_5_5_5_1`,e[e.UNSIGNED_INT=5125]=`UNSIGNED_INT`,e[e.UNSIGNED_INT_10F_11F_11F_REV=35899]=`UNSIGNED_INT_10F_11F_11F_REV`,e[e.UNSIGNED_INT_2_10_10_10_REV=33640]=`UNSIGNED_INT_2_10_10_10_REV`,e[e.UNSIGNED_INT_24_8=34042]=`UNSIGNED_INT_24_8`,e[e.UNSIGNED_INT_5_9_9_9_REV=35902]=`UNSIGNED_INT_5_9_9_9_REV`,e[e.BYTE=5120]=`BYTE`,e[e.SHORT=5122]=`SHORT`,e[e.INT=5124]=`INT`,e[e.FLOAT=5126]=`FLOAT`,e[e.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]=`FLOAT_32_UNSIGNED_INT_24_8_REV`,e[e.HALF_FLOAT=36193]=`HALF_FLOAT`,e))(Y||{}),po={uint8x2:Y.UNSIGNED_BYTE,uint8x4:Y.UNSIGNED_BYTE,sint8x2:Y.BYTE,sint8x4:Y.BYTE,unorm8x2:Y.UNSIGNED_BYTE,unorm8x4:Y.UNSIGNED_BYTE,snorm8x2:Y.BYTE,snorm8x4:Y.BYTE,uint16x2:Y.UNSIGNED_SHORT,uint16x4:Y.UNSIGNED_SHORT,sint16x2:Y.SHORT,sint16x4:Y.SHORT,unorm16x2:Y.UNSIGNED_SHORT,unorm16x4:Y.UNSIGNED_SHORT,snorm16x2:Y.SHORT,snorm16x4:Y.SHORT,float16x2:Y.HALF_FLOAT,float16x4:Y.HALF_FLOAT,float32:Y.FLOAT,float32x2:Y.FLOAT,float32x3:Y.FLOAT,float32x4:Y.FLOAT,uint32:Y.UNSIGNED_INT,uint32x2:Y.UNSIGNED_INT,uint32x3:Y.UNSIGNED_INT,uint32x4:Y.UNSIGNED_INT,sint32:Y.INT,sint32x2:Y.INT,sint32x3:Y.INT,sint32x4:Y.INT};function mo(e){return po[e]??po.float32}var ho={"point-list":0,"line-list":1,"line-strip":3,"triangle-list":4,"triangle-strip":5},go=class{constructor(e){this._geometryVaoHash=Object.create(null),this._renderer=e,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0}contextChange(){let e=this.gl=this._renderer.gl;if(!this._renderer.context.supports.vertexArrayObject)throw Error(`[PixiJS] Vertex Array Objects are not supported on this device`);let t=this._renderer.context.extensions.vertexArrayObject;t&&(e.createVertexArray=()=>t.createVertexArrayOES(),e.bindVertexArray=e=>t.bindVertexArrayOES(e),e.deleteVertexArray=e=>t.deleteVertexArrayOES(e));let n=this._renderer.context.extensions.vertexAttribDivisorANGLE;n&&(e.drawArraysInstanced=(e,t,r,i)=>{n.drawArraysInstancedANGLE(e,t,r,i)},e.drawElementsInstanced=(e,t,r,i,a)=>{n.drawElementsInstancedANGLE(e,t,r,i,a)},e.vertexAttribDivisor=(e,t)=>n.vertexAttribDivisorANGLE(e,t)),this._activeGeometry=null,this._activeVao=null,this._geometryVaoHash=Object.create(null)}bind(e,t){let n=this.gl;this._activeGeometry=e;let r=this.getVao(e,t);this._activeVao!==r&&(this._activeVao=r,n.bindVertexArray(r)),this.updateBuffers()}reset(){this.unbind()}updateBuffers(){let e=this._activeGeometry,t=this._renderer.buffer;for(let n=0;n<e.buffers.length;n++){let r=e.buffers[n];t.updateBuffer(r)}}checkCompatibility(e,t){let n=e.attributes,r=t._attributeData;for(let e in r)if(!n[e])throw Error(`shader and geometry incompatible, geometry missing the "${e}" attribute`)}getSignature(e,t){let n=e.attributes,r=t._attributeData,i=[`g`,e.uid];for(let e in n)r[e]&&i.push(e,r[e].location);return i.join(`-`)}getVao(e,t){return this._geometryVaoHash[e.uid]?.[t._key]||this.initGeometryVao(e,t)}initGeometryVao(e,t,n=!0){let r=this._renderer.gl,i=this._renderer.buffer;this._renderer.shader._getProgramData(t),this.checkCompatibility(e,t);let a=this.getSignature(e,t);this._geometryVaoHash[e.uid]||(this._geometryVaoHash[e.uid]=Object.create(null),e.on(`destroy`,this.onGeometryDestroy,this));let o=this._geometryVaoHash[e.uid],s=o[a];if(s)return o[t._key]=s,s;nt(e,t._attributeData);let c=e.buffers;s=r.createVertexArray(),r.bindVertexArray(s);for(let e=0;e<c.length;e++){let t=c[e];i.bind(t)}return this.activateVao(e,t),o[t._key]=s,o[a]=s,r.bindVertexArray(null),s}onGeometryDestroy(e,t){let n=this._geometryVaoHash[e.uid],r=this.gl;if(n){if(t)for(let e in n)this._activeVao!==n[e]&&this.unbind(),r.deleteVertexArray(n[e]);this._geometryVaoHash[e.uid]=null}}destroyAll(e=!1){let t=this.gl;for(let n in this._geometryVaoHash){if(e)for(let e in this._geometryVaoHash[n]){let r=this._geometryVaoHash[n];this._activeVao!==r&&this.unbind(),t.deleteVertexArray(r[e])}this._geometryVaoHash[n]=null}}activateVao(e,t){let n=this._renderer.gl,r=this._renderer.buffer,i=e.attributes;e.indexBuffer&&r.bind(e.indexBuffer);let a=null;for(let e in i){let o=i[e],s=o.buffer,c=r.getGlBuffer(s),l=t._attributeData[e];if(l){a!==c&&(r.bind(s),a=c);let e=l.location;n.enableVertexAttribArray(e);let t=Ce(o.format),i=mo(o.format);if(l.format?.substring(1,4)===`int`?n.vertexAttribIPointer(e,t.size,i,o.stride,o.offset):n.vertexAttribPointer(e,t.size,i,t.normalised,o.stride,o.offset),o.instance)if(this.hasInstance){let t=o.divisor??1;n.vertexAttribDivisor(e,t)}else throw Error(`geometry error, GPU Instancing is not supported on this device`)}}}draw(e,t,n,r){let{gl:i}=this._renderer,a=this._activeGeometry,o=ho[a.topology||e];if(r||=a.instanceCount,a.indexBuffer){let e=a.indexBuffer.data.BYTES_PER_ELEMENT,s=e===2?i.UNSIGNED_SHORT:i.UNSIGNED_INT;r>1?i.drawElementsInstanced(o,t||a.indexBuffer.data.length,s,(n||0)*e,r):i.drawElements(o,t||a.indexBuffer.data.length,s,(n||0)*e)}else r>1?i.drawArraysInstanced(o,n||0,t||a.getSize(),r):i.drawArrays(o,n||0,t||a.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this._renderer=null,this.gl=null,this._activeVao=null,this._activeGeometry=null}};go.extension={type:[U.WebGLSystem],name:`geometry`};var _o=new He({attributes:{aPosition:[-1,-1,3,-1,-1,3]}}),vo=class e{constructor(e){this.useBackBuffer=!1,this._useBackBufferThisRender=!1,this._renderer=e}init(t={}){let{useBackBuffer:n,antialias:r}={...e.defaultOptions,...t};this.useBackBuffer=n,this._antialias=r,this._renderer.context.supports.msaa||(B(`antialiasing, is not supported on when using the back buffer`),this._antialias=!1),this._state=ce.for2d();let i=new Se({vertex:`
|
|
175
|
+
attribute vec2 aPosition;
|
|
176
|
+
out vec2 vUv;
|
|
177
|
+
|
|
178
|
+
void main() {
|
|
179
|
+
gl_Position = vec4(aPosition, 0.0, 1.0);
|
|
180
|
+
|
|
181
|
+
vUv = (aPosition + 1.0) / 2.0;
|
|
182
|
+
|
|
183
|
+
// flip dem UVs
|
|
184
|
+
vUv.y = 1.0 - vUv.y;
|
|
185
|
+
}`,fragment:`
|
|
186
|
+
in vec2 vUv;
|
|
187
|
+
out vec4 finalColor;
|
|
188
|
+
|
|
189
|
+
uniform sampler2D uTexture;
|
|
190
|
+
|
|
191
|
+
void main() {
|
|
192
|
+
finalColor = texture(uTexture, vUv);
|
|
193
|
+
}`,name:`big-triangle`});this._bigTriangleShader=new we({glProgram:i,resources:{uTexture:R.WHITE.source}})}renderStart(e){let t=this._renderer.renderTarget.getRenderTarget(e.target);if(this._useBackBufferThisRender=this.useBackBuffer&&!!t.isRoot,this._useBackBufferThisRender){let t=this._renderer.renderTarget.getRenderTarget(e.target);this._targetTexture=t.colorTexture,e.target=this._getBackBufferTexture(t.colorTexture)}}renderEnd(){this._presentBackBuffer()}_presentBackBuffer(){let e=this._renderer;e.renderTarget.finishRenderPass(),this._useBackBufferThisRender&&(e.renderTarget.bind(this._targetTexture,!1),this._bigTriangleShader.resources.uTexture=this._backBufferTexture.source,e.encoder.draw({geometry:_o,shader:this._bigTriangleShader,state:this._state}))}_getBackBufferTexture(e){return this._backBufferTexture=this._backBufferTexture||new R({source:new j({width:e.width,height:e.height,resolution:e._resolution,antialias:this._antialias})}),this._backBufferTexture.source.resize(e.width,e.height,e._resolution),this._backBufferTexture}destroy(){this._backBufferTexture&&=(this._backBufferTexture.destroy(),null)}};vo.extension={type:[U.WebGLSystem],name:`backBuffer`,priority:1},vo.defaultOptions={useBackBuffer:!1};var yo=vo,bo=class{constructor(e){this._colorMaskCache=15,this._renderer=e}setMask(e){this._colorMaskCache!==e&&(this._colorMaskCache=e,this._renderer.gl.colorMask(!!(e&8),!!(e&4),!!(e&2),!!(e&1)))}};bo.extension={type:[U.WebGLSystem],name:`colorMask`};var xo=class{constructor(e){this.commandFinished=Promise.resolve(),this._renderer=e}setGeometry(e,t){this._renderer.geometry.bind(e,t.glProgram)}finishRenderPass(){}draw(e){let t=this._renderer,{geometry:n,shader:r,state:i,skipSync:a,topology:o,size:s,start:c,instanceCount:l}=e;t.shader.bind(r,a),t.geometry.bind(n,t.shader._activeProgram),i&&t.state.set(i),t.geometry.draw(o,s,c,l??n.instanceCount)}destroy(){this._renderer=null}};xo.extension={type:[U.WebGLSystem],name:`encoder`};var So=class{constructor(e){this._stencilCache={enabled:!1,stencilReference:0,stencilMode:Ee.NONE},this._renderTargetStencilState=Object.create(null),e.renderTarget.onRenderTargetChange.add(this)}contextChange(e){this._gl=e,this._comparisonFuncMapping={always:e.ALWAYS,never:e.NEVER,equal:e.EQUAL,"not-equal":e.NOTEQUAL,less:e.LESS,"less-equal":e.LEQUAL,greater:e.GREATER,"greater-equal":e.GEQUAL},this._stencilOpsMapping={keep:e.KEEP,zero:e.ZERO,replace:e.REPLACE,invert:e.INVERT,"increment-clamp":e.INCR,"decrement-clamp":e.DECR,"increment-wrap":e.INCR_WRAP,"decrement-wrap":e.DECR_WRAP},this._stencilCache.enabled=!1,this._stencilCache.stencilMode=Ee.NONE,this._stencilCache.stencilReference=0}onRenderTargetChange(e){if(this._activeRenderTarget===e)return;this._activeRenderTarget=e;let t=this._renderTargetStencilState[e.uid];t||=this._renderTargetStencilState[e.uid]={stencilMode:Ee.DISABLED,stencilReference:0},this.setStencilMode(t.stencilMode,t.stencilReference)}setStencilMode(e,t){let n=this._renderTargetStencilState[this._activeRenderTarget.uid],r=this._gl,i=Xe[e],a=this._stencilCache;if(n.stencilMode=e,n.stencilReference=t,e===Ee.DISABLED){this._stencilCache.enabled&&(this._stencilCache.enabled=!1,r.disable(r.STENCIL_TEST));return}this._stencilCache.enabled||(this._stencilCache.enabled=!0,r.enable(r.STENCIL_TEST)),(e!==a.stencilMode||a.stencilReference!==t)&&(a.stencilMode=e,a.stencilReference=t,r.stencilFunc(this._comparisonFuncMapping[i.stencilBack.compare],t,255),r.stencilOp(r.KEEP,r.KEEP,this._stencilOpsMapping[i.stencilBack.passOp]))}};So.extension={type:[U.WebGLSystem],name:`stencil`};var Co={f32:4,"vec2<f32>":8,"vec3<f32>":12,"vec4<f32>":16,"mat2x2<f32>":32,"mat3x3<f32>":48,"mat4x4<f32>":64};function wo(e){let t=e.map(e=>({data:e,offset:0,size:0})),n=0,r=0,i=0;for(let e=0;e<t.length;e++){let a=t[e];if(n=Co[a.data.type],!n)throw Error(`Unknown type ${a.data.type}`);if(a.data.size>1&&(n=Math.max(n,16)*a.data.size),a.size=n,r%n!==0&&r<16){let e=r%n%16;r+=e,i+=e}r+n>16?(i=Math.ceil(i/16)*16,a.offset=i,i+=n,r=n):(a.offset=i,r+=n,i+=n)}return i=Math.ceil(i/16)*16,{uboElements:t,size:i}}function To(e,t){let n=Math.max(Co[e.data.type]/16,1),r=e.data.value.length/e.data.size,i=(4-r%4)%4;return`
|
|
194
|
+
v = uv.${e.data.name};
|
|
195
|
+
offset += ${t};
|
|
196
|
+
|
|
197
|
+
arrayOffset = offset;
|
|
198
|
+
|
|
199
|
+
t = 0;
|
|
200
|
+
|
|
201
|
+
for(var i=0; i < ${e.data.size*n}; i++)
|
|
202
|
+
{
|
|
203
|
+
for(var j = 0; j < ${r}; j++)
|
|
204
|
+
{
|
|
205
|
+
data[arrayOffset++] = v[t++];
|
|
206
|
+
}
|
|
207
|
+
${i===0?``:`arrayOffset += ${i};`}
|
|
208
|
+
}
|
|
209
|
+
`}function Eo(e){return Ye(e,`uboStd40`,To,st)}var Do=class extends ct{constructor(){super({createUboElements:wo,generateUboSync:Eo})}};Do.extension={type:[U.WebGLSystem],name:`ubo`};var Oo=class{constructor(){this.width=-1,this.height=-1,this.msaa=!1,this.msaaRenderBuffer=[]}},ko=class{constructor(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new be}init(e,t){this._renderer=e,this._renderTargetSystem=t,e.runners.contextChange.add(this)}contextChange(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new be}copyToTexture(e,t,n,r,i){let a=this._renderTargetSystem,o=this._renderer,s=a.getGpuRenderTarget(e),c=o.gl;return this.finishRenderPass(e),c.bindFramebuffer(c.FRAMEBUFFER,s.resolveTargetFramebuffer),o.texture.bind(t,0),c.copyTexSubImage2D(c.TEXTURE_2D,0,i.x,i.y,n.x,n.y,r.width,r.height),t}startRenderPass(e,t=!0,n,r){let i=this._renderTargetSystem,a=e.colorTexture,o=i.getGpuRenderTarget(e),s=r.y;e.isRoot&&(s=a.pixelHeight-r.height),e.colorTextures.forEach(e=>{this._renderer.texture.unbind(e)});let c=this._renderer.gl;c.bindFramebuffer(c.FRAMEBUFFER,o.framebuffer);let l=this._viewPortCache;(l.x!==r.x||l.y!==s||l.width!==r.width||l.height!==r.height)&&(l.x=r.x,l.y=s,l.width=r.width,l.height=r.height,c.viewport(r.x,s,r.width,r.height)),!o.depthStencilRenderBuffer&&(e.stencil||e.depth)&&this._initStencil(o),this.clear(e,t,n)}finishRenderPass(e){let t=this._renderTargetSystem.getGpuRenderTarget(e);if(!t.msaa)return;let n=this._renderer.gl;n.bindFramebuffer(n.FRAMEBUFFER,t.resolveTargetFramebuffer),n.bindFramebuffer(n.READ_FRAMEBUFFER,t.framebuffer),n.blitFramebuffer(0,0,t.width,t.height,0,0,t.width,t.height,n.COLOR_BUFFER_BIT,n.NEAREST),n.bindFramebuffer(n.FRAMEBUFFER,t.framebuffer)}initGpuRenderTarget(e){let t=this._renderer,n=t.gl,r=new Oo;return e.colorTexture.resource===t.gl.canvas?(r.framebuffer=null,r):(this._initColor(e,r),n.bindFramebuffer(n.FRAMEBUFFER,null),r)}destroyGpuRenderTarget(e){let t=this._renderer.gl;e.framebuffer&&=(t.deleteFramebuffer(e.framebuffer),null),e.resolveTargetFramebuffer&&=(t.deleteFramebuffer(e.resolveTargetFramebuffer),null),e.depthStencilRenderBuffer&&=(t.deleteRenderbuffer(e.depthStencilRenderBuffer),null),e.msaaRenderBuffer.forEach(e=>{t.deleteRenderbuffer(e)}),e.msaaRenderBuffer=null}clear(e,t,n){if(!t)return;let r=this._renderTargetSystem;typeof t==`boolean`&&(t=t?rt.ALL:rt.NONE);let i=this._renderer.gl;if(t&rt.COLOR){n??=r.defaultClearColor;let e=this._clearColorCache,t=n;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3])&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],i.clearColor(t[0],t[1],t[2],t[3]))}i.clear(t)}resizeGpuRenderTarget(e){if(e.isRoot)return;let t=this._renderTargetSystem.getGpuRenderTarget(e);this._resizeColor(e,t),(e.stencil||e.depth)&&this._resizeStencil(t)}_initColor(e,t){let n=this._renderer,r=n.gl,i=r.createFramebuffer();if(t.resolveTargetFramebuffer=i,r.bindFramebuffer(r.FRAMEBUFFER,i),t.width=e.colorTexture.source.pixelWidth,t.height=e.colorTexture.source.pixelHeight,e.colorTextures.forEach((e,i)=>{let a=e.source;a.antialias&&(n.context.supports.msaa?t.msaa=!0:B(`[RenderTexture] Antialiasing on textures is not supported in WebGL1`)),n.texture.bindSource(a,0);let o=n.texture.getGlSource(a).texture;r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+i,3553,o,0)}),t.msaa){let n=r.createFramebuffer();t.framebuffer=n,r.bindFramebuffer(r.FRAMEBUFFER,n),e.colorTextures.forEach((e,n)=>{let i=r.createRenderbuffer();t.msaaRenderBuffer[n]=i})}else t.framebuffer=i;this._resizeColor(e,t)}_resizeColor(e,t){let n=e.colorTexture.source;if(t.width=n.pixelWidth,t.height=n.pixelHeight,e.colorTextures.forEach((e,t)=>{t!==0&&e.source.resize(n.width,n.height,n._resolution)}),t.msaa){let n=this._renderer,r=n.gl,i=t.framebuffer;r.bindFramebuffer(r.FRAMEBUFFER,i),e.colorTextures.forEach((e,i)=>{let a=e.source;n.texture.bindSource(a,0);let o=n.texture.getGlSource(a).internalFormat,s=t.msaaRenderBuffer[i];r.bindRenderbuffer(r.RENDERBUFFER,s),r.renderbufferStorageMultisample(r.RENDERBUFFER,4,o,a.pixelWidth,a.pixelHeight),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+i,r.RENDERBUFFER,s)})}}_initStencil(e){if(e.framebuffer===null)return;let t=this._renderer.gl,n=t.createRenderbuffer();e.depthStencilRenderBuffer=n,t.bindRenderbuffer(t.RENDERBUFFER,n),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,n),this._resizeStencil(e)}_resizeStencil(e){let t=this._renderer.gl;t.bindRenderbuffer(t.RENDERBUFFER,e.depthStencilRenderBuffer),e.msaa?t.renderbufferStorageMultisample(t.RENDERBUFFER,4,t.DEPTH24_STENCIL8,e.width,e.height):t.renderbufferStorage(t.RENDERBUFFER,this._renderer.context.webGLVersion===2?t.DEPTH24_STENCIL8:t.DEPTH_STENCIL,e.width,e.height)}},Ao=class extends it{constructor(e){super(e),this.adaptor=new ko,this.adaptor.init(e,this)}};Ao.extension={type:[U.WebGLSystem],name:`renderTarget`};function jo(e,t){let n=[],r=[`
|
|
210
|
+
var g = s.groups;
|
|
211
|
+
var sS = r.shader;
|
|
212
|
+
var p = s.glProgram;
|
|
213
|
+
var ugS = r.uniformGroup;
|
|
214
|
+
var resources;
|
|
215
|
+
`],i=!1,a=0,o=0,s=t._getProgramData(e.glProgram);for(let c in e.groups){let l=e.groups[c];n.push(`
|
|
216
|
+
resources = g[${c}].resources;
|
|
217
|
+
`);for(let u in l.resources){let d=l.resources[u];if(d instanceof We)d.ubo?n.push(`
|
|
218
|
+
sS.bindUniformBlock(
|
|
219
|
+
resources[${u}],
|
|
220
|
+
sS._uniformBindMap[${c}[${u}],
|
|
221
|
+
${a++}
|
|
222
|
+
);
|
|
223
|
+
`):n.push(`
|
|
224
|
+
ugS.updateUniformGroup(resources[${u}], p, sD);
|
|
225
|
+
`);else if(d instanceof lt)n.push(`
|
|
226
|
+
sS.bindUniformBlock(
|
|
227
|
+
resources[${u}],
|
|
228
|
+
sS._uniformBindMap[${c}[${u}],
|
|
229
|
+
${a++}
|
|
230
|
+
);
|
|
231
|
+
`);else if(d instanceof j){let a=e._uniformBindMap[c][u],l=s.uniformData[a];l&&(i||(i=!0,r.push(`
|
|
232
|
+
var tS = r.texture;
|
|
233
|
+
`)),t._gl.uniform1i(l.location,o),n.push(`
|
|
234
|
+
tS.bind(resources[${u}], ${o});
|
|
235
|
+
`),o++)}}}let c=[...r,...n].join(`
|
|
236
|
+
`);return Function(`r`,`s`,`sD`,c)}var Mo=class{constructor(e,t){this.program=e,this.uniformData=t,this.uniformGroups={},this.uniformDirtyGroups={},this.uniformBlockBindings={}}destroy(){this.uniformData=null,this.uniformGroups=null,this.uniformDirtyGroups=null,this.uniformBlockBindings=null,this.program=null}};function No(e,t,n){let r=e.createShader(t);return e.shaderSource(r,n),e.compileShader(r),r}function Po(e){let t=Array(e);for(let e=0;e<t.length;e++)t[e]=!1;return t}function Fo(e,t){switch(e){case`float`:return 0;case`vec2`:return new Float32Array(2*t);case`vec3`:return new Float32Array(3*t);case`vec4`:return new Float32Array(4*t);case`int`:case`uint`:case`sampler2D`:case`sampler2DArray`:return 0;case`ivec2`:return new Int32Array(2*t);case`ivec3`:return new Int32Array(3*t);case`ivec4`:return new Int32Array(4*t);case`uvec2`:return new Uint32Array(2*t);case`uvec3`:return new Uint32Array(3*t);case`uvec4`:return new Uint32Array(4*t);case`bool`:return!1;case`bvec2`:return Po(2*t);case`bvec3`:return Po(3*t);case`bvec4`:return Po(4*t);case`mat2`:return new Float32Array([1,0,0,1]);case`mat3`:return new Float32Array([1,0,0,0,1,0,0,0,1]);case`mat4`:return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}var Io=null,Lo={FLOAT:`float`,FLOAT_VEC2:`vec2`,FLOAT_VEC3:`vec3`,FLOAT_VEC4:`vec4`,INT:`int`,INT_VEC2:`ivec2`,INT_VEC3:`ivec3`,INT_VEC4:`ivec4`,UNSIGNED_INT:`uint`,UNSIGNED_INT_VEC2:`uvec2`,UNSIGNED_INT_VEC3:`uvec3`,UNSIGNED_INT_VEC4:`uvec4`,BOOL:`bool`,BOOL_VEC2:`bvec2`,BOOL_VEC3:`bvec3`,BOOL_VEC4:`bvec4`,FLOAT_MAT2:`mat2`,FLOAT_MAT3:`mat3`,FLOAT_MAT4:`mat4`,SAMPLER_2D:`sampler2D`,INT_SAMPLER_2D:`sampler2D`,UNSIGNED_INT_SAMPLER_2D:`sampler2D`,SAMPLER_CUBE:`samplerCube`,INT_SAMPLER_CUBE:`samplerCube`,UNSIGNED_INT_SAMPLER_CUBE:`samplerCube`,SAMPLER_2D_ARRAY:`sampler2DArray`,INT_SAMPLER_2D_ARRAY:`sampler2DArray`,UNSIGNED_INT_SAMPLER_2D_ARRAY:`sampler2DArray`},Ro={float:`float32`,vec2:`float32x2`,vec3:`float32x3`,vec4:`float32x4`,int:`sint32`,ivec2:`sint32x2`,ivec3:`sint32x3`,ivec4:`sint32x4`,uint:`uint32`,uvec2:`uint32x2`,uvec3:`uint32x3`,uvec4:`uint32x4`,bool:`uint32`,bvec2:`uint32x2`,bvec3:`uint32x3`,bvec4:`uint32x4`};function zo(e,t){if(!Io){let t=Object.keys(Lo);Io={};for(let n=0;n<t.length;++n){let r=t[n];Io[e[r]]=Lo[r]}}return Io[t]}function Bo(e,t){return Ro[zo(e,t)]||`float32`}function Vo(e,t,n=!1){let r={},i=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let n=0;n<i;n++){let i=t.getActiveAttrib(e,n);if(i.name.startsWith(`gl_`))continue;let a=Bo(t,i.type);r[i.name]={location:0,format:a,stride:Ce(a).stride,offset:0,instance:!1,start:0}}let a=Object.keys(r);if(n){a.sort((e,t)=>e>t?1:-1);for(let n=0;n<a.length;n++)r[a[n]].location=n,t.bindAttribLocation(e,n,a[n]);t.linkProgram(e)}else for(let n=0;n<a.length;n++)r[a[n]].location=t.getAttribLocation(e,a[n]);return r}function Ho(e,t){if(!t.ACTIVE_UNIFORM_BLOCKS)return{};let n={},r=t.getProgramParameter(e,t.ACTIVE_UNIFORM_BLOCKS);for(let i=0;i<r;i++){let r=t.getActiveUniformBlockName(e,i);n[r]={name:r,index:t.getUniformBlockIndex(e,r),size:t.getActiveUniformBlockParameter(e,i,t.UNIFORM_BLOCK_DATA_SIZE)}}return n}function Uo(e,t){let n={},r=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let i=0;i<r;i++){let r=t.getActiveUniform(e,i),a=r.name.replace(/\[.*?\]$/,``),o=!!r.name.match(/\[.*?\]$/),s=zo(t,r.type);n[a]={name:a,index:i,type:s,size:r.size,isArray:o,value:Fo(s,r.size)}}return n}function Wo(e,t){let n=e.getShaderSource(t).split(`
|
|
237
|
+
`).map((e,t)=>`${t}: ${e}`),r=e.getShaderInfoLog(t),i=r.split(`
|
|
238
|
+
`),a={},o=i.map(e=>parseFloat(e.replace(/^ERROR\: 0\:([\d]+)\:.*$/,`$1`))).filter(e=>e&&!a[e]?(a[e]=!0,!0):!1),s=[``];o.forEach(e=>{n[e-1]=`%c${n[e-1]}%c`,s.push(`background: #FF0000; color:#FFFFFF; font-size: 10px`,`font-size: 10px`)}),s[0]=n.join(`
|
|
239
|
+
`),console.error(r),console.groupCollapsed(`click to view full shader code`),console.warn(...s),console.groupEnd()}function Go(e,t,n,r){e.getProgramParameter(t,e.LINK_STATUS)||(e.getShaderParameter(n,e.COMPILE_STATUS)||Wo(e,n),e.getShaderParameter(r,e.COMPILE_STATUS)||Wo(e,r),console.error(`PixiJS Error: Could not initialize shader.`),e.getProgramInfoLog(t)!==``&&console.warn(`PixiJS Warning: gl.getProgramInfoLog()`,e.getProgramInfoLog(t)))}function Ko(e,t){let n=No(e,e.VERTEX_SHADER,t.vertex),r=No(e,e.FRAGMENT_SHADER,t.fragment),i=e.createProgram();e.attachShader(i,n),e.attachShader(i,r);let a=t.transformFeedbackVaryings;a&&(typeof e.transformFeedbackVaryings==`function`?e.transformFeedbackVaryings(i,a.names,a.bufferMode===`separate`?e.SEPARATE_ATTRIBS:e.INTERLEAVED_ATTRIBS):B(`TransformFeedback is not supported but TransformFeedbackVaryings are given.`)),e.linkProgram(i),e.getProgramParameter(i,e.LINK_STATUS)||Go(e,i,n,r),t._attributeData=Vo(i,e,!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(t.vertex)),t._uniformData=Uo(i,e),t._uniformBlockData=Ho(i,e),e.deleteShader(n),e.deleteShader(r);let o={};for(let n in t._uniformData){let r=t._uniformData[n];o[n]={location:e.getUniformLocation(i,n),value:Fo(r.type,r.size)}}return new Mo(i,o)}var qo={textureCount:0,blockIndex:0},Jo=class{constructor(e){this._activeProgram=null,this._programDataHash=Object.create(null),this._nextIndex=0,this._boundUniformsIdsToIndexHash=Object.create(null),this._boundIndexToUniformsHash=Object.create(null),this._shaderSyncFunctions=Object.create(null),this._renderer=e}contextChange(e){this._gl=e,this._maxBindings=e.MAX_UNIFORM_BUFFER_BINDINGS?e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS):0,this._programDataHash=Object.create(null),this._boundUniformsIdsToIndexHash=Object.create(null),this._boundIndexToUniformsHash=Object.create(null),this._shaderSyncFunctions=Object.create(null),this._activeProgram=null,this.maxTextures=Te()}bind(e,t){if(this._setProgram(e.glProgram),t)return;qo.textureCount=0,qo.blockIndex=0;let n=this._shaderSyncFunctions[e.glProgram._key];n||=this._shaderSyncFunctions[e.glProgram._key]=this._generateShaderSync(e,this),n(this._renderer,e,qo)}updateUniformGroup(e){this._renderer.uniformGroup.updateUniformGroup(e,this._activeProgram,qo)}bindUniformBlock(e,t,n=0){let r=this._renderer.buffer,i=this._getProgramData(this._activeProgram),a=e._bufferResource;a&&this._renderer.ubo.updateUniformGroup(e),r.updateBuffer(e.buffer);let o=this._boundUniformsIdsToIndexHash[e.uid];if(o===void 0){let t=this._nextIndex++%this._maxBindings,n=this._boundIndexToUniformsHash[t];n&&(this._boundUniformsIdsToIndexHash[n.uid]=void 0),o=this._boundUniformsIdsToIndexHash[e.uid]=t,this._boundIndexToUniformsHash[t]=e,a?r.bindBufferRange(e.buffer,t,e.offset):r.bindBufferBase(e.buffer,t)}let s=this._gl,c=this._activeProgram._uniformBlockData[t].index;i.uniformBlockBindings[n]!==o&&(i.uniformBlockBindings[n]=o,s.uniformBlockBinding(i.program,c,o))}_setProgram(e){if(this._activeProgram===e)return;this._activeProgram=e;let t=this._getProgramData(e);this._gl.useProgram(t.program)}_getProgramData(e){return this._programDataHash[e._key]||this._createProgramData(e)}_createProgramData(e){let t=e._key;return this._programDataHash[t]=Ko(this._gl,e),this._programDataHash[t]}destroy(){for(let e of Object.keys(this._programDataHash))this._programDataHash[e].destroy(),this._programDataHash[e]=null;this._programDataHash=null,this._boundUniformsIdsToIndexHash=null}_generateShaderSync(e,t){return jo(e,t)}};Jo.extension={type:[U.WebGLSystem],name:`shader`};var Yo={f32:`if (cv !== v) {
|
|
240
|
+
cu.value = v;
|
|
241
|
+
gl.uniform1f(location, v);
|
|
242
|
+
}`,"vec2<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
|
|
243
|
+
cv[0] = v[0];
|
|
244
|
+
cv[1] = v[1];
|
|
245
|
+
gl.uniform2f(location, v[0], v[1]);
|
|
246
|
+
}`,"vec3<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
|
|
247
|
+
cv[0] = v[0];
|
|
248
|
+
cv[1] = v[1];
|
|
249
|
+
cv[2] = v[2];
|
|
250
|
+
gl.uniform3f(location, v[0], v[1], v[2]);
|
|
251
|
+
}`,"vec4<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
|
|
252
|
+
cv[0] = v[0];
|
|
253
|
+
cv[1] = v[1];
|
|
254
|
+
cv[2] = v[2];
|
|
255
|
+
cv[3] = v[3];
|
|
256
|
+
gl.uniform4f(location, v[0], v[1], v[2], v[3]);
|
|
257
|
+
}`,i32:`if (cv !== v) {
|
|
258
|
+
cu.value = v;
|
|
259
|
+
gl.uniform1i(location, v);
|
|
260
|
+
}`,"vec2<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
|
|
261
|
+
cv[0] = v[0];
|
|
262
|
+
cv[1] = v[1];
|
|
263
|
+
gl.uniform2i(location, v[0], v[1]);
|
|
264
|
+
}`,"vec3<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
|
|
265
|
+
cv[0] = v[0];
|
|
266
|
+
cv[1] = v[1];
|
|
267
|
+
cv[2] = v[2];
|
|
268
|
+
gl.uniform3i(location, v[0], v[1], v[2]);
|
|
269
|
+
}`,"vec4<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
|
|
270
|
+
cv[0] = v[0];
|
|
271
|
+
cv[1] = v[1];
|
|
272
|
+
cv[2] = v[2];
|
|
273
|
+
cv[3] = v[3];
|
|
274
|
+
gl.uniform4i(location, v[0], v[1], v[2], v[3]);
|
|
275
|
+
}`,u32:`if (cv !== v) {
|
|
276
|
+
cu.value = v;
|
|
277
|
+
gl.uniform1ui(location, v);
|
|
278
|
+
}`,"vec2<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
|
|
279
|
+
cv[0] = v[0];
|
|
280
|
+
cv[1] = v[1];
|
|
281
|
+
gl.uniform2ui(location, v[0], v[1]);
|
|
282
|
+
}`,"vec3<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
|
|
283
|
+
cv[0] = v[0];
|
|
284
|
+
cv[1] = v[1];
|
|
285
|
+
cv[2] = v[2];
|
|
286
|
+
gl.uniform3ui(location, v[0], v[1], v[2]);
|
|
287
|
+
}`,"vec4<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
|
|
288
|
+
cv[0] = v[0];
|
|
289
|
+
cv[1] = v[1];
|
|
290
|
+
cv[2] = v[2];
|
|
291
|
+
cv[3] = v[3];
|
|
292
|
+
gl.uniform4ui(location, v[0], v[1], v[2], v[3]);
|
|
293
|
+
}`,bool:`if (cv !== v) {
|
|
294
|
+
cu.value = v;
|
|
295
|
+
gl.uniform1i(location, v);
|
|
296
|
+
}`,"vec2<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
|
|
297
|
+
cv[0] = v[0];
|
|
298
|
+
cv[1] = v[1];
|
|
299
|
+
gl.uniform2i(location, v[0], v[1]);
|
|
300
|
+
}`,"vec3<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
|
|
301
|
+
cv[0] = v[0];
|
|
302
|
+
cv[1] = v[1];
|
|
303
|
+
cv[2] = v[2];
|
|
304
|
+
gl.uniform3i(location, v[0], v[1], v[2]);
|
|
305
|
+
}`,"vec4<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
|
|
306
|
+
cv[0] = v[0];
|
|
307
|
+
cv[1] = v[1];
|
|
308
|
+
cv[2] = v[2];
|
|
309
|
+
cv[3] = v[3];
|
|
310
|
+
gl.uniform4i(location, v[0], v[1], v[2], v[3]);
|
|
311
|
+
}`,"mat2x2<f32>":`gl.uniformMatrix2fv(location, false, v);`,"mat3x3<f32>":`gl.uniformMatrix3fv(location, false, v);`,"mat4x4<f32>":`gl.uniformMatrix4fv(location, false, v);`},Xo={f32:`gl.uniform1fv(location, v);`,"vec2<f32>":`gl.uniform2fv(location, v);`,"vec3<f32>":`gl.uniform3fv(location, v);`,"vec4<f32>":`gl.uniform4fv(location, v);`,"mat2x2<f32>":`gl.uniformMatrix2fv(location, false, v);`,"mat3x3<f32>":`gl.uniformMatrix3fv(location, false, v);`,"mat4x4<f32>":`gl.uniformMatrix4fv(location, false, v);`,i32:`gl.uniform1iv(location, v);`,"vec2<i32>":`gl.uniform2iv(location, v);`,"vec3<i32>":`gl.uniform3iv(location, v);`,"vec4<i32>":`gl.uniform4iv(location, v);`,u32:`gl.uniform1iv(location, v);`,"vec2<u32>":`gl.uniform2iv(location, v);`,"vec3<u32>":`gl.uniform3iv(location, v);`,"vec4<u32>":`gl.uniform4iv(location, v);`,bool:`gl.uniform1iv(location, v);`,"vec2<bool>":`gl.uniform2iv(location, v);`,"vec3<bool>":`gl.uniform3iv(location, v);`,"vec4<bool>":`gl.uniform4iv(location, v);`};function Zo(e,t){let n=[`
|
|
312
|
+
var v = null;
|
|
313
|
+
var cv = null;
|
|
314
|
+
var cu = null;
|
|
315
|
+
var t = 0;
|
|
316
|
+
var gl = renderer.gl;
|
|
317
|
+
var name = null;
|
|
318
|
+
`];for(let r in e.uniforms){if(!t[r]){e.uniforms[r]instanceof We?e.uniforms[r].ubo?n.push(`
|
|
319
|
+
renderer.shader.bindUniformBlock(uv.${r}, "${r}");
|
|
320
|
+
`):n.push(`
|
|
321
|
+
renderer.shader.updateUniformGroup(uv.${r});
|
|
322
|
+
`):e.uniforms[r]instanceof lt&&n.push(`
|
|
323
|
+
renderer.shader.bindBufferResource(uv.${r}, "${r}");
|
|
324
|
+
`);continue}let i=e.uniformStructures[r],a=!1;for(let e=0;e<at.length;e++){let t=at[e];if(i.type===t.type&&t.test(i)){n.push(`name = "${r}";`,at[e].uniform),a=!0;break}}if(!a){let e=(i.size===1?Yo:Xo)[i.type].replace(`location`,`ud["${r}"].location`);n.push(`
|
|
325
|
+
cu = ud["${r}"];
|
|
326
|
+
cv = cu.value;
|
|
327
|
+
v = uv["${r}"];
|
|
328
|
+
${e};`)}}return Function(`ud`,`uv`,`renderer`,`syncData`,n.join(`
|
|
329
|
+
`))}var Qo=class{constructor(e){this._cache={},this._uniformGroupSyncHash={},this._renderer=e,this.gl=null,this._cache={}}contextChange(e){this.gl=e}updateUniformGroup(e,t,n){let r=this._renderer.shader._getProgramData(t);(!e.isStatic||e._dirtyId!==r.uniformDirtyGroups[e.uid])&&(r.uniformDirtyGroups[e.uid]=e._dirtyId,this._getUniformSyncFunction(e,t)(r.uniformData,e.uniforms,this._renderer,n))}_getUniformSyncFunction(e,t){return this._uniformGroupSyncHash[e._signature]?.[t._key]||this._createUniformSyncFunction(e,t)}_createUniformSyncFunction(e,t){let n=this._uniformGroupSyncHash[e._signature]||(this._uniformGroupSyncHash[e._signature]={}),r=this._getSignature(e,t._uniformData,`u`);return this._cache[r]||(this._cache[r]=this._generateUniformsSync(e,t._uniformData)),n[t._key]=this._cache[r],n[t._key]}_generateUniformsSync(e,t){return Zo(e,t)}_getSignature(e,t,n){let r=e.uniforms,i=[`${n}-`];for(let e in r)i.push(e),t[e]&&i.push(t[e].type);return i.join(`-`)}destroy(){this._renderer=null,this._cache=null}};Qo.extension={type:[U.WebGLSystem],name:`uniformGroup`};function $o(e){let t={};if(t.normal=[e.ONE,e.ONE_MINUS_SRC_ALPHA],t.add=[e.ONE,e.ONE],t.multiply=[e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA],t.screen=[e.ONE,e.ONE_MINUS_SRC_COLOR,e.ONE,e.ONE_MINUS_SRC_ALPHA],t.none=[0,0],t[`normal-npm`]=[e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA],t[`add-npm`]=[e.SRC_ALPHA,e.ONE,e.ONE,e.ONE],t[`screen-npm`]=[e.SRC_ALPHA,e.ONE_MINUS_SRC_COLOR,e.ONE,e.ONE_MINUS_SRC_ALPHA],t.erase=[e.ZERO,e.ONE_MINUS_SRC_ALPHA],!(e instanceof z.get().getWebGLRenderingContext()))t.min=[e.ONE,e.ONE,e.ONE,e.ONE,e.MIN,e.MIN],t.max=[e.ONE,e.ONE,e.ONE,e.ONE,e.MAX,e.MAX];else{let n=e.getExtension(`EXT_blend_minmax`);n&&(t.min=[e.ONE,e.ONE,e.ONE,e.ONE,n.MIN_EXT,n.MIN_EXT],t.max=[e.ONE,e.ONE,e.ONE,e.ONE,n.MAX_EXT,n.MAX_EXT])}return t}var es=0,ts=1,ns=2,rs=3,is=4,as=5,os=class e{constructor(){this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode=`none`,this._blendEq=!1,this.map=[],this.map[es]=this.setBlend,this.map[ts]=this.setOffset,this.map[ns]=this.setCullFace,this.map[rs]=this.setDepthTest,this.map[is]=this.setFrontFace,this.map[as]=this.setDepthMask,this.checks=[],this.defaultState=ce.for2d()}contextChange(e){this.gl=e,this.blendModesMap=$o(e),this.reset()}set(e){if(e||=this.defaultState,this.stateId!==e.data){let t=this.stateId^e.data,n=0;for(;t;)t&1&&this.map[n].call(this,!!(e.data&1<<n)),t>>=1,n++;this.stateId=e.data}for(let t=0;t<this.checks.length;t++)this.checks[t](this,e)}forceState(e){e||=this.defaultState;for(let t=0;t<this.map.length;t++)this.map[t].call(this,!!(e.data&1<<t));for(let t=0;t<this.checks.length;t++)this.checks[t](this,e);this.stateId=e.data}setBlend(t){this._updateCheck(e._checkBlendMode,t),this.gl[t?`enable`:`disable`](this.gl.BLEND)}setOffset(t){this._updateCheck(e._checkPolygonOffset,t),this.gl[t?`enable`:`disable`](this.gl.POLYGON_OFFSET_FILL)}setDepthTest(e){this.gl[e?`enable`:`disable`](this.gl.DEPTH_TEST)}setDepthMask(e){this.gl.depthMask(e)}setCullFace(e){this.gl[e?`enable`:`disable`](this.gl.CULL_FACE)}setFrontFace(e){this.gl.frontFace(this.gl[e?`CW`:`CCW`])}setBlendMode(e){if(this.blendModesMap[e]||(e=`normal`),e===this.blendMode)return;this.blendMode=e;let t=this.blendModesMap[e],n=this.gl;t.length===2?n.blendFunc(t[0],t[1]):n.blendFuncSeparate(t[0],t[1],t[2],t[3]),t.length===6?(this._blendEq=!0,n.blendEquationSeparate(t[4],t[5])):this._blendEq&&(this._blendEq=!1,n.blendEquationSeparate(n.FUNC_ADD,n.FUNC_ADD))}setPolygonOffset(e,t){this.gl.polygonOffset(e,t)}reset(){this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,!1),this.forceState(this.defaultState),this._blendEq=!0,this.blendMode=``,this.setBlendMode(`normal`)}_updateCheck(e,t){let n=this.checks.indexOf(e);t&&n===-1?this.checks.push(e):!t&&n!==-1&&this.checks.splice(n,1)}static _checkBlendMode(e,t){e.setBlendMode(t.blendMode)}static _checkPolygonOffset(e,t){e.setPolygonOffset(1,t.polygonOffset)}destroy(){this.gl=null,this.checks.length=0}};os.extension={type:[U.WebGLSystem],name:`state`};var ss=os,cs=class{constructor(e){this.target=fo.TEXTURE_2D,this.texture=e,this.width=-1,this.height=-1,this.type=Y.UNSIGNED_BYTE,this.internalFormat=uo.RGBA,this.format=uo.RGBA,this.samplerType=0}},ls={id:`buffer`,upload(e,t,n){t.width===e.width||t.height===e.height?n.texSubImage2D(n.TEXTURE_2D,0,0,0,e.width,e.height,t.format,t.type,e.resource):n.texImage2D(t.target,0,t.internalFormat,e.width,e.height,0,t.format,t.type,e.resource),t.width=e.width,t.height=e.height}},us={"bc1-rgba-unorm":!0,"bc1-rgba-unorm-srgb":!0,"bc2-rgba-unorm":!0,"bc2-rgba-unorm-srgb":!0,"bc3-rgba-unorm":!0,"bc3-rgba-unorm-srgb":!0,"bc4-r-unorm":!0,"bc4-r-snorm":!0,"bc5-rg-unorm":!0,"bc5-rg-snorm":!0,"bc6h-rgb-ufloat":!0,"bc6h-rgb-float":!0,"bc7-rgba-unorm":!0,"bc7-rgba-unorm-srgb":!0,"etc2-rgb8unorm":!0,"etc2-rgb8unorm-srgb":!0,"etc2-rgb8a1unorm":!0,"etc2-rgb8a1unorm-srgb":!0,"etc2-rgba8unorm":!0,"etc2-rgba8unorm-srgb":!0,"eac-r11unorm":!0,"eac-r11snorm":!0,"eac-rg11unorm":!0,"eac-rg11snorm":!0,"astc-4x4-unorm":!0,"astc-4x4-unorm-srgb":!0,"astc-5x4-unorm":!0,"astc-5x4-unorm-srgb":!0,"astc-5x5-unorm":!0,"astc-5x5-unorm-srgb":!0,"astc-6x5-unorm":!0,"astc-6x5-unorm-srgb":!0,"astc-6x6-unorm":!0,"astc-6x6-unorm-srgb":!0,"astc-8x5-unorm":!0,"astc-8x5-unorm-srgb":!0,"astc-8x6-unorm":!0,"astc-8x6-unorm-srgb":!0,"astc-8x8-unorm":!0,"astc-8x8-unorm-srgb":!0,"astc-10x5-unorm":!0,"astc-10x5-unorm-srgb":!0,"astc-10x6-unorm":!0,"astc-10x6-unorm-srgb":!0,"astc-10x8-unorm":!0,"astc-10x8-unorm-srgb":!0,"astc-10x10-unorm":!0,"astc-10x10-unorm-srgb":!0,"astc-12x10-unorm":!0,"astc-12x10-unorm-srgb":!0,"astc-12x12-unorm":!0,"astc-12x12-unorm-srgb":!0},ds={id:`compressed`,upload(e,t,n){n.pixelStorei(n.UNPACK_ALIGNMENT,4);let r=e.pixelWidth,i=e.pixelHeight,a=!!us[e.format];for(let o=0;o<e.resource.length;o++){let s=e.resource[o];a?n.compressedTexImage2D(n.TEXTURE_2D,o,t.internalFormat,r,i,0,s):n.texImage2D(n.TEXTURE_2D,o,t.internalFormat,r,i,0,t.format,t.type,s),r=Math.max(r>>1,1),i=Math.max(i>>1,1)}}},fs={id:`image`,upload(e,t,n,r){let i=e.alphaMode===`premultiply-alpha-on-upload`;n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i);let a=t.width,o=t.height,s=e.pixelWidth,c=e.pixelHeight,l=e.resourceWidth,u=e.resourceHeight;l<s||u<c?((a!==s||o!==c)&&n.texImage2D(t.target,0,t.internalFormat,s,c,0,t.format,t.type,null),r===2?n.texSubImage2D(n.TEXTURE_2D,0,0,0,l,u,t.format,t.type,e.resource):n.texSubImage2D(n.TEXTURE_2D,0,0,0,t.format,t.type,e.resource)):a===s||o===c?n.texSubImage2D(n.TEXTURE_2D,0,0,0,t.format,t.type,e.resource):r===2?n.texImage2D(t.target,0,t.internalFormat,s,c,0,t.format,t.type,e.resource):n.texImage2D(t.target,0,t.internalFormat,t.format,t.type,e.resource),t.width=s,t.height=c}},ps={id:`video`,upload(e,t,n,r){if(!e.isValid){n.texImage2D(t.target,0,t.internalFormat,1,1,0,t.format,t.type,null);return}fs.upload(e,t,n,r)}},ms={linear:9729,nearest:9728},hs={linear:{linear:9987,nearest:9985},nearest:{linear:9986,nearest:9984}},gs={"clamp-to-edge":33071,repeat:10497,"mirror-repeat":33648},_s={never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519};function vs(e,t,n,r,i,a,o,s){let c=a;if(!s||e.addressModeU!==`repeat`||e.addressModeV!==`repeat`||e.addressModeW!==`repeat`){let n=gs[o?`clamp-to-edge`:e.addressModeU],r=gs[o?`clamp-to-edge`:e.addressModeV],a=gs[o?`clamp-to-edge`:e.addressModeW];t[i](c,t.TEXTURE_WRAP_S,n),t[i](c,t.TEXTURE_WRAP_T,r),t.TEXTURE_WRAP_R&&t[i](c,t.TEXTURE_WRAP_R,a)}if((!s||e.magFilter!==`linear`)&&t[i](c,t.TEXTURE_MAG_FILTER,ms[e.magFilter]),n){if(!s||e.mipmapFilter!==`linear`){let n=hs[e.minFilter][e.mipmapFilter];t[i](c,t.TEXTURE_MIN_FILTER,n)}}else t[i](c,t.TEXTURE_MIN_FILTER,ms[e.minFilter]);if(r&&e.maxAnisotropy>1){let n=Math.min(e.maxAnisotropy,t.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT));t[i](c,r.TEXTURE_MAX_ANISOTROPY_EXT,n)}e.compare&&t[i](c,t.TEXTURE_COMPARE_FUNC,_s[e.compare])}function ys(e){return{r8unorm:e.RED,r8snorm:e.RED,r8uint:e.RED,r8sint:e.RED,r16uint:e.RED,r16sint:e.RED,r16float:e.RED,rg8unorm:e.RG,rg8snorm:e.RG,rg8uint:e.RG,rg8sint:e.RG,r32uint:e.RED,r32sint:e.RED,r32float:e.RED,rg16uint:e.RG,rg16sint:e.RG,rg16float:e.RG,rgba8unorm:e.RGBA,"rgba8unorm-srgb":e.RGBA,rgba8snorm:e.RGBA,rgba8uint:e.RGBA,rgba8sint:e.RGBA,bgra8unorm:e.RGBA,"bgra8unorm-srgb":e.RGBA,rgb9e5ufloat:e.RGB,rgb10a2unorm:e.RGBA,rg11b10ufloat:e.RGB,rg32uint:e.RG,rg32sint:e.RG,rg32float:e.RG,rgba16uint:e.RGBA,rgba16sint:e.RGBA,rgba16float:e.RGBA,rgba32uint:e.RGBA,rgba32sint:e.RGBA,rgba32float:e.RGBA,stencil8:e.STENCIL_INDEX8,depth16unorm:e.DEPTH_COMPONENT,depth24plus:e.DEPTH_COMPONENT,"depth24plus-stencil8":e.DEPTH_STENCIL,depth32float:e.DEPTH_COMPONENT,"depth32float-stencil8":e.DEPTH_STENCIL}}function bs(e,t){let n={},r=e.RGBA;return e instanceof z.get().getWebGLRenderingContext()?t.srgb&&(n={"rgba8unorm-srgb":t.srgb.SRGB8_ALPHA8_EXT,"bgra8unorm-srgb":t.srgb.SRGB8_ALPHA8_EXT}):(n={"rgba8unorm-srgb":e.SRGB8_ALPHA8,"bgra8unorm-srgb":e.SRGB8_ALPHA8},r=e.RGBA8),{r8unorm:e.R8,r8snorm:e.R8_SNORM,r8uint:e.R8UI,r8sint:e.R8I,r16uint:e.R16UI,r16sint:e.R16I,r16float:e.R16F,rg8unorm:e.RG8,rg8snorm:e.RG8_SNORM,rg8uint:e.RG8UI,rg8sint:e.RG8I,r32uint:e.R32UI,r32sint:e.R32I,r32float:e.R32F,rg16uint:e.RG16UI,rg16sint:e.RG16I,rg16float:e.RG16F,rgba8unorm:e.RGBA,...n,rgba8snorm:e.RGBA8_SNORM,rgba8uint:e.RGBA8UI,rgba8sint:e.RGBA8I,bgra8unorm:r,rgb9e5ufloat:e.RGB9_E5,rgb10a2unorm:e.RGB10_A2,rg11b10ufloat:e.R11F_G11F_B10F,rg32uint:e.RG32UI,rg32sint:e.RG32I,rg32float:e.RG32F,rgba16uint:e.RGBA16UI,rgba16sint:e.RGBA16I,rgba16float:e.RGBA16F,rgba32uint:e.RGBA32UI,rgba32sint:e.RGBA32I,rgba32float:e.RGBA32F,stencil8:e.STENCIL_INDEX8,depth16unorm:e.DEPTH_COMPONENT16,depth24plus:e.DEPTH_COMPONENT24,"depth24plus-stencil8":e.DEPTH24_STENCIL8,depth32float:e.DEPTH_COMPONENT32F,"depth32float-stencil8":e.DEPTH32F_STENCIL8,...t.s3tc?{"bc1-rgba-unorm":t.s3tc.COMPRESSED_RGBA_S3TC_DXT1_EXT,"bc2-rgba-unorm":t.s3tc.COMPRESSED_RGBA_S3TC_DXT3_EXT,"bc3-rgba-unorm":t.s3tc.COMPRESSED_RGBA_S3TC_DXT5_EXT}:{},...t.s3tc_sRGB?{"bc1-rgba-unorm-srgb":t.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,"bc2-rgba-unorm-srgb":t.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,"bc3-rgba-unorm-srgb":t.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}:{},...t.rgtc?{"bc4-r-unorm":t.rgtc.COMPRESSED_RED_RGTC1_EXT,"bc4-r-snorm":t.rgtc.COMPRESSED_SIGNED_RED_RGTC1_EXT,"bc5-rg-unorm":t.rgtc.COMPRESSED_RED_GREEN_RGTC2_EXT,"bc5-rg-snorm":t.rgtc.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}:{},...t.bptc?{"bc6h-rgb-float":t.bptc.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,"bc6h-rgb-ufloat":t.bptc.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,"bc7-rgba-unorm":t.bptc.COMPRESSED_RGBA_BPTC_UNORM_EXT,"bc7-rgba-unorm-srgb":t.bptc.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT}:{},...t.etc?{"etc2-rgb8unorm":t.etc.COMPRESSED_RGB8_ETC2,"etc2-rgb8unorm-srgb":t.etc.COMPRESSED_SRGB8_ETC2,"etc2-rgb8a1unorm":t.etc.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,"etc2-rgb8a1unorm-srgb":t.etc.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,"etc2-rgba8unorm":t.etc.COMPRESSED_RGBA8_ETC2_EAC,"etc2-rgba8unorm-srgb":t.etc.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,"eac-r11unorm":t.etc.COMPRESSED_R11_EAC,"eac-rg11unorm":t.etc.COMPRESSED_SIGNED_RG11_EAC}:{},...t.astc?{"astc-4x4-unorm":t.astc.COMPRESSED_RGBA_ASTC_4x4_KHR,"astc-4x4-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,"astc-5x4-unorm":t.astc.COMPRESSED_RGBA_ASTC_5x4_KHR,"astc-5x4-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,"astc-5x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_5x5_KHR,"astc-5x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,"astc-6x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_6x5_KHR,"astc-6x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,"astc-6x6-unorm":t.astc.COMPRESSED_RGBA_ASTC_6x6_KHR,"astc-6x6-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,"astc-8x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_8x5_KHR,"astc-8x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,"astc-8x6-unorm":t.astc.COMPRESSED_RGBA_ASTC_8x6_KHR,"astc-8x6-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,"astc-8x8-unorm":t.astc.COMPRESSED_RGBA_ASTC_8x8_KHR,"astc-8x8-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,"astc-10x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x5_KHR,"astc-10x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,"astc-10x6-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x6_KHR,"astc-10x6-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,"astc-10x8-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x8_KHR,"astc-10x8-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,"astc-10x10-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x10_KHR,"astc-10x10-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,"astc-12x10-unorm":t.astc.COMPRESSED_RGBA_ASTC_12x10_KHR,"astc-12x10-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,"astc-12x12-unorm":t.astc.COMPRESSED_RGBA_ASTC_12x12_KHR,"astc-12x12-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR}:{}}}function xs(e){return{r8unorm:e.UNSIGNED_BYTE,r8snorm:e.BYTE,r8uint:e.UNSIGNED_BYTE,r8sint:e.BYTE,r16uint:e.UNSIGNED_SHORT,r16sint:e.SHORT,r16float:e.HALF_FLOAT,rg8unorm:e.UNSIGNED_BYTE,rg8snorm:e.BYTE,rg8uint:e.UNSIGNED_BYTE,rg8sint:e.BYTE,r32uint:e.UNSIGNED_INT,r32sint:e.INT,r32float:e.FLOAT,rg16uint:e.UNSIGNED_SHORT,rg16sint:e.SHORT,rg16float:e.HALF_FLOAT,rgba8unorm:e.UNSIGNED_BYTE,"rgba8unorm-srgb":e.UNSIGNED_BYTE,rgba8snorm:e.BYTE,rgba8uint:e.UNSIGNED_BYTE,rgba8sint:e.BYTE,bgra8unorm:e.UNSIGNED_BYTE,"bgra8unorm-srgb":e.UNSIGNED_BYTE,rgb9e5ufloat:e.UNSIGNED_INT_5_9_9_9_REV,rgb10a2unorm:e.UNSIGNED_INT_2_10_10_10_REV,rg11b10ufloat:e.UNSIGNED_INT_10F_11F_11F_REV,rg32uint:e.UNSIGNED_INT,rg32sint:e.INT,rg32float:e.FLOAT,rgba16uint:e.UNSIGNED_SHORT,rgba16sint:e.SHORT,rgba16float:e.HALF_FLOAT,rgba32uint:e.UNSIGNED_INT,rgba32sint:e.INT,rgba32float:e.FLOAT,stencil8:e.UNSIGNED_BYTE,depth16unorm:e.UNSIGNED_SHORT,depth24plus:e.UNSIGNED_INT,"depth24plus-stencil8":e.UNSIGNED_INT_24_8,depth32float:e.FLOAT,"depth32float-stencil8":e.FLOAT_32_UNSIGNED_INT_24_8_REV}}var Ss=4,Cs=class{constructor(e){this.managedTextures=[],this._glTextures=Object.create(null),this._glSamplers=Object.create(null),this._boundTextures=[],this._activeTextureLocation=-1,this._boundSamplers=Object.create(null),this._uploads={image:fs,buffer:ls,video:ps,compressed:ds},this._useSeparateSamplers=!1,this._renderer=e}contextChange(e){this._gl=e,this._mapFormatToInternalFormat||(this._mapFormatToInternalFormat=bs(e,this._renderer.context.extensions),this._mapFormatToType=xs(e),this._mapFormatToFormat=ys(e)),this._glTextures=Object.create(null),this._glSamplers=Object.create(null),this._boundSamplers=Object.create(null);for(let e=0;e<16;e++)this.bind(R.EMPTY,e)}initSource(e){this.bind(e)}bind(e,t=0){let n=e.source;e?(this.bindSource(n,t),this._useSeparateSamplers&&this._bindSampler(n.style,t)):(this.bindSource(null,t),this._useSeparateSamplers&&this._bindSampler(null,t))}bindSource(e,t=0){let n=this._gl;if(e._touched=this._renderer.textureGC.count,this._boundTextures[t]!==e){this._boundTextures[t]=e,this._activateLocation(t),e||=R.EMPTY.source;let r=this.getGlSource(e);n.bindTexture(r.target,r.texture)}}_bindSampler(e,t=0){let n=this._gl;if(!e){this._boundSamplers[t]=null,n.bindSampler(t,null);return}let r=this._getGlSampler(e);this._boundSamplers[t]!==r&&(this._boundSamplers[t]=r,n.bindSampler(t,r))}unbind(e){let t=e.source,n=this._boundTextures,r=this._gl;for(let e=0;e<n.length;e++)if(n[e]===t){this._activateLocation(e);let i=this.getGlSource(t);r.bindTexture(i.target,null),n[e]=null}}_activateLocation(e){this._activeTextureLocation!==e&&(this._activeTextureLocation=e,this._gl.activeTexture(this._gl.TEXTURE0+e))}_initSource(e){let t=this._gl,n=new cs(t.createTexture());if(n.type=this._mapFormatToType[e.format],n.internalFormat=this._mapFormatToInternalFormat[e.format],n.format=this._mapFormatToFormat[e.format],e.autoGenerateMipmaps&&(this._renderer.context.supports.nonPowOf2mipmaps||e.isPowerOfTwo)){let t=Math.max(e.width,e.height);e.mipLevelCount=Math.floor(Math.log2(t))+1}return this._glTextures[e.uid]=n,this.managedTextures.includes(e)||(e.on(`update`,this.onSourceUpdate,this),e.on(`resize`,this.onSourceUpdate,this),e.on(`styleChange`,this.onStyleChange,this),e.on(`destroy`,this.onSourceDestroy,this),e.on(`unload`,this.onSourceUnload,this),e.on(`updateMipmaps`,this.onUpdateMipmaps,this),this.managedTextures.push(e)),this.onSourceUpdate(e),this.updateStyle(e,!1),n}onStyleChange(e){this.updateStyle(e,!1)}updateStyle(e,t){let n=this._gl,r=this.getGlSource(e);n.bindTexture(n.TEXTURE_2D,r.texture),this._boundTextures[this._activeTextureLocation]=e,vs(e.style,n,e.mipLevelCount>1,this._renderer.context.extensions.anisotropicFiltering,`texParameteri`,n.TEXTURE_2D,!this._renderer.context.supports.nonPowOf2wrapping&&!e.isPowerOfTwo,t)}onSourceUnload(e){let t=this._glTextures[e.uid];t&&(this.unbind(e),this._glTextures[e.uid]=null,this._gl.deleteTexture(t.texture))}onSourceUpdate(e){let t=this._gl,n=this.getGlSource(e);t.bindTexture(t.TEXTURE_2D,n.texture),this._boundTextures[this._activeTextureLocation]=e,this._uploads[e.uploadMethodId]?this._uploads[e.uploadMethodId].upload(e,n,t,this._renderer.context.webGLVersion):t.texImage2D(t.TEXTURE_2D,0,t.RGBA,e.pixelWidth,e.pixelHeight,0,t.RGBA,t.UNSIGNED_BYTE,null),e.autoGenerateMipmaps&&e.mipLevelCount>1&&this.onUpdateMipmaps(e,!1)}onUpdateMipmaps(e,t=!0){t&&this.bindSource(e,0);let n=this.getGlSource(e);this._gl.generateMipmap(n.target)}onSourceDestroy(e){e.off(`destroy`,this.onSourceDestroy,this),e.off(`update`,this.onSourceUpdate,this),e.off(`resize`,this.onSourceUpdate,this),e.off(`unload`,this.onSourceUnload,this),e.off(`styleChange`,this.onStyleChange,this),e.off(`updateMipmaps`,this.onUpdateMipmaps,this),this.managedTextures.splice(this.managedTextures.indexOf(e),1),this.onSourceUnload(e)}_initSampler(e){let t=this._gl,n=this._gl.createSampler();return this._glSamplers[e._resourceId]=n,vs(e,t,this._boundTextures[this._activeTextureLocation].mipLevelCount>1,this._renderer.context.extensions.anisotropicFiltering,`samplerParameteri`,n,!1,!0),this._glSamplers[e._resourceId]}_getGlSampler(e){return this._glSamplers[e._resourceId]||this._initSampler(e)}getGlSource(e){return this._glTextures[e.uid]||this._initSource(e)}generateCanvas(e){let{pixels:t,width:n,height:r}=this.getPixels(e),i=z.get().createCanvas();i.width=n,i.height=r;let a=i.getContext(`2d`);if(a){let e=a.createImageData(n,r);e.data.set(t),a.putImageData(e,0,0)}return i}getPixels(e){let t=e.source.resolution,n=e.frame,r=Math.max(Math.round(n.width*t),1),i=Math.max(Math.round(n.height*t),1),a=new Uint8Array(Ss*r*i),o=this._renderer,s=o.renderTarget.getRenderTarget(e),c=o.renderTarget.getGpuRenderTarget(s),l=o.gl;return l.bindFramebuffer(l.FRAMEBUFFER,c.resolveTargetFramebuffer),l.readPixels(Math.round(n.x*t),Math.round(n.y*t),r,i,l.RGBA,l.UNSIGNED_BYTE,a),{pixels:new Uint8ClampedArray(a.buffer),width:r,height:i}}destroy(){this.managedTextures.slice().forEach(e=>this.onSourceDestroy(e)),this.managedTextures=null,this._renderer=null}};Cs.extension={type:[U.WebGLSystem],name:`texture`};var ws=e({WebGLRenderer:()=>js}),Ts=[...Ze,Do,yo,lo,so,Cs,Ao,go,Qo,Jo,xo,ss,So,bo],Es=[...ut],Ds=[io,ro,no],Os=[],ks=[],As=[];Pe.handleByNamedList(U.WebGLSystem,Os),Pe.handleByNamedList(U.WebGLPipes,ks),Pe.handleByNamedList(U.WebGLPipesAdaptor,As),Pe.add(...Ts,...Es,...Ds);var js=class extends ot{constructor(){let e={name:`webgl`,type:he.WEBGL,systems:Os,renderPipes:ks,renderPipeAdaptors:As};super(e)}},Ms=class{init(){let e=new We({uTransformMatrix:{value:new H,type:`mat3x3<f32>`},uColor:{value:new Float32Array([1,1,1,1]),type:`vec4<f32>`},uRound:{value:0,type:`f32`}}),t=Ne({name:`graphics`,bits:[Be,_e(Te()),Ie,je]});this.shader=new we({gpuProgram:t,resources:{localUniforms:e}})}execute(e,t){let n=t.context,r=n.customShader||this.shader,i=e.renderer,{geometry:a,instructions:o}=i.graphicsContext.getContextRenderData(n),s=i.encoder;s.setPipelineFromGeometryProgramAndState(a,r.gpuProgram,e.state),s.setGeometry(a,r.gpuProgram);let c=i.globalUniforms.bindGroup;s.setBindGroup(0,c,r.gpuProgram);let l=i.renderPipes.uniformBatch.getUniformBindGroup(r.resources.localUniforms,!0);s.setBindGroup(2,l,r.gpuProgram);let u=o.instructions;for(let e=0;e<o.instructionSize;e++){let t=u[e];if(r.groups[1]=t.bindGroup,!t.gpuBindGroup){let e=t.textures;t.bindGroup=Ke(e.textures,e.count),t.gpuBindGroup=i.bindGroup.getBindGroup(t.bindGroup,r.gpuProgram,1)}s.setBindGroup(1,t.bindGroup,r.gpuProgram),s.renderPassEncoder.drawIndexed(t.size,1,t.start)}}destroy(){this.shader.destroy(!0),this.shader=null}};Ms.extension={type:[U.WebGPUPipesAdaptor],name:`graphics`};var Ns=class{init(){let e=Ne({name:`mesh`,bits:[ze,et,je]});this._shader=new we({gpuProgram:e,resources:{uTexture:R.EMPTY._source,uSampler:R.EMPTY._source.style,textureUniforms:{uTextureMatrix:{type:`mat3x3<f32>`,value:new H}}}})}execute(e,t){let n=e.renderer,r=t._shader;if(!r)r=this._shader,r.groups[2]=n.texture.getTextureBindGroup(t.texture);else if(!r.gpuProgram){B(`Mesh shader has no gpuProgram`,t.shader);return}let i=r.gpuProgram;if(i.autoAssignGlobalUniforms&&(r.groups[0]=n.globalUniforms.bindGroup),i.autoAssignLocalUniforms){let t=e.localUniforms;r.groups[1]=n.renderPipes.uniformBatch.getUniformBindGroup(t,!0)}n.encoder.draw({geometry:t._geometry,shader:r,state:t.state})}destroy(){this._shader.destroy(!0),this._shader=null}};Ns.extension={type:[U.WebGPUPipesAdaptor],name:`mesh`};var Ps=ce.for2d(),Fs=class{init(){let e=Ne({name:`batch`,bits:[Be,_e(Te()),je]});this._shader=new we({gpuProgram:e,groups:{}})}start(e,t){let n=e.renderer,r=n.encoder,i=this._shader.gpuProgram;this._geometry=t,r.setGeometry(t,i),Ps.blendMode=`normal`,n.pipeline.getPipeline(t,i,Ps);let a=n.globalUniforms.bindGroup;r.resetBindGroup(1),r.setBindGroup(0,a,i)}execute(e,t){let n=this._shader.gpuProgram,r=e.renderer,i=r.encoder;if(!t.bindGroup){let e=t.textures;t.bindGroup=Ke(e.textures,e.count)}Ps.blendMode=t.blendMode;let a=r.bindGroup.getBindGroup(t.bindGroup,n,1),o=r.pipeline.getPipeline(this._geometry,n,Ps);t.bindGroup._touch(r.textureGC.count),i.setPipeline(o),i.renderPassEncoder.setBindGroup(1,a),i.renderPassEncoder.drawIndexed(t.size,1,t.start)}destroy(){this._shader.destroy(!0),this._shader=null}};Fs.extension={type:[U.WebGPUPipesAdaptor],name:`batch`};var Is=class{constructor(e){this._hash=Object.create(null),this._renderer=e}contextChange(e){this._gpu=e}getBindGroup(e,t,n){return e._updateKey(),this._hash[e._key]||this._createBindGroup(e,t,n)}_createBindGroup(e,t,n){let r=this._gpu.device,i=t.layout[n],a=[],o=this._renderer;for(let t in i){let n=e.resources[t]??e.resources[i[t]],r;if(n._resourceType===`uniformGroup`){let e=n;o.ubo.updateUniformGroup(e);let t=e.buffer;r={buffer:o.buffer.getGPUBuffer(t),offset:0,size:t.descriptor.size}}else if(n._resourceType===`buffer`){let e=n;r={buffer:o.buffer.getGPUBuffer(e),offset:0,size:e.descriptor.size}}else if(n._resourceType===`bufferResource`){let e=n;r={buffer:o.buffer.getGPUBuffer(e.buffer),offset:e.offset,size:e.size}}else if(n._resourceType===`textureSampler`){let e=n;r=o.texture.getGpuSampler(e)}else if(n._resourceType===`textureSource`){let e=n;r=o.texture.getGpuSource(e).createView({})}a.push({binding:i[t],resource:r})}let s=o.shader.getProgramData(t).bindGroups[n],c=r.createBindGroup({layout:s,entries:a});return this._hash[e._key]=c,c}destroy(){for(let e of Object.keys(this._hash))this._hash[e]=null;this._hash=null,this._renderer=null}};Is.extension={type:[U.WebGPUSystem],name:`bindGroup`};var Ls=class{constructor(){this._gpuBuffers=Object.create(null),this._managedBuffers=[]}contextChange(e){this._gpu=e}getGPUBuffer(e){return this._gpuBuffers[e.uid]||this.createGPUBuffer(e)}updateBuffer(e){let t=this._gpuBuffers[e.uid]||this.createGPUBuffer(e),n=e.data;return e._updateID&&n&&(e._updateID=0,this._gpu.device.queue.writeBuffer(t,0,n.buffer,0,(e._updateSize||n.byteLength)+3&-4)),t}destroyAll(){for(let e in this._gpuBuffers)this._gpuBuffers[e].destroy();this._gpuBuffers={}}createGPUBuffer(e){this._gpuBuffers[e.uid]||(e.on(`update`,this.updateBuffer,this),e.on(`change`,this.onBufferChange,this),e.on(`destroy`,this.onBufferDestroy,this),this._managedBuffers.push(e));let t=this._gpu.device.createBuffer(e.descriptor);return e._updateID=0,e.data&&(A(e.data.buffer,t.getMappedRange()),t.unmap()),this._gpuBuffers[e.uid]=t,t}onBufferChange(e){this._gpuBuffers[e.uid].destroy(),e._updateID=0,this._gpuBuffers[e.uid]=this.createGPUBuffer(e)}onBufferDestroy(e){this._managedBuffers.splice(this._managedBuffers.indexOf(e),1),this._destroyBuffer(e)}destroy(){this._managedBuffers.forEach(e=>this._destroyBuffer(e)),this._managedBuffers=null,this._gpuBuffers=null}_destroyBuffer(e){this._gpuBuffers[e.uid].destroy(),e.off(`update`,this.updateBuffer,this),e.off(`change`,this.onBufferChange,this),e.off(`destroy`,this.onBufferDestroy,this),this._gpuBuffers[e.uid]=null}};Ls.extension={type:[U.WebGPUSystem],name:`buffer`};var Rs=class{constructor(e){this._colorMaskCache=15,this._renderer=e}setMask(e){this._colorMaskCache!==e&&(this._colorMaskCache=e,this._renderer.pipeline.setColorMask(e))}destroy(){this._renderer=null,this._colorMaskCache=null}};Rs.extension={type:[U.WebGPUSystem],name:`colorMask`};var zs=class{constructor(e){this._renderer=e}async init(e){return this._initPromise||=this._createDeviceAndAdaptor(e).then(e=>{this.gpu=e,this._renderer.runners.contextChange.emit(this.gpu)}),this._initPromise}contextChange(e){this._renderer.gpu=e}async _createDeviceAndAdaptor(e){let t=await z.get().getNavigator().gpu.requestAdapter({powerPreference:e.powerPreference,forceFallbackAdapter:e.forceFallbackAdapter}),n=[`texture-compression-bc`,`texture-compression-astc`,`texture-compression-etc2`].filter(e=>t.features.has(e));return{adapter:t,device:await t.requestDevice({requiredFeatures:n})}}destroy(){this.gpu=null,this._renderer=null}};zs.extension={type:[U.WebGPUSystem],name:`device`},zs.defaultOptions={powerPreference:void 0,forceFallbackAdapter:!1};var Bs=class{constructor(e){this._boundBindGroup=Object.create(null),this._boundVertexBuffer=Object.create(null),this._renderer=e}renderStart(){this.commandFinished=new Promise(e=>{this._resolveCommandFinished=e}),this.commandEncoder=this._renderer.gpu.device.createCommandEncoder()}beginRenderPass(e){this.endRenderPass(),this._clearCache(),this.renderPassEncoder=this.commandEncoder.beginRenderPass(e.descriptor)}endRenderPass(){this.renderPassEncoder&&this.renderPassEncoder.end(),this.renderPassEncoder=null}setViewport(e){this.renderPassEncoder.setViewport(e.x,e.y,e.width,e.height,0,1)}setPipelineFromGeometryProgramAndState(e,t,n,r){let i=this._renderer.pipeline.getPipeline(e,t,n,r);this.setPipeline(i)}setPipeline(e){this._boundPipeline!==e&&(this._boundPipeline=e,this.renderPassEncoder.setPipeline(e))}_setVertexBuffer(e,t){this._boundVertexBuffer[e]!==t&&(this._boundVertexBuffer[e]=t,this.renderPassEncoder.setVertexBuffer(e,this._renderer.buffer.updateBuffer(t)))}_setIndexBuffer(e){if(this._boundIndexBuffer===e)return;this._boundIndexBuffer=e;let t=e.data.BYTES_PER_ELEMENT===2?`uint16`:`uint32`;this.renderPassEncoder.setIndexBuffer(this._renderer.buffer.updateBuffer(e),t)}resetBindGroup(e){this._boundBindGroup[e]=null}setBindGroup(e,t,n){if(this._boundBindGroup[e]===t)return;this._boundBindGroup[e]=t,t._touch(this._renderer.textureGC.count);let r=this._renderer.bindGroup.getBindGroup(t,n,e);this.renderPassEncoder.setBindGroup(e,r)}setGeometry(e,t){let n=this._renderer.pipeline.getBufferNamesToBind(e,t);for(let t in n)this._setVertexBuffer(t,e.attributes[n[t]].buffer);e.indexBuffer&&this._setIndexBuffer(e.indexBuffer)}_setShaderBindGroups(e,t){for(let n in e.groups){let r=e.groups[n];t||this._syncBindGroup(r),this.setBindGroup(n,r,e.gpuProgram)}}_syncBindGroup(e){for(let t in e.resources){let n=e.resources[t];n.isUniformGroup&&this._renderer.ubo.updateUniformGroup(n)}}draw(e){let{geometry:t,shader:n,state:r,topology:i,size:a,start:o,instanceCount:s,skipSync:c}=e;this.setPipelineFromGeometryProgramAndState(t,n.gpuProgram,r,i),this.setGeometry(t,n.gpuProgram),this._setShaderBindGroups(n,c),t.indexBuffer?this.renderPassEncoder.drawIndexed(a||t.indexBuffer.data.length,s||t.instanceCount,o||0):this.renderPassEncoder.draw(a||t.getSize(),s||t.instanceCount,o||0)}finishRenderPass(){this.renderPassEncoder&&=(this.renderPassEncoder.end(),null)}postrender(){this.finishRenderPass(),this._gpu.device.queue.submit([this.commandEncoder.finish()]),this._resolveCommandFinished(),this.commandEncoder=null}restoreRenderPass(){let e=this._renderer.renderTarget.adaptor.getDescriptor(this._renderer.renderTarget.renderTarget,!1,[0,0,0,1]);this.renderPassEncoder=this.commandEncoder.beginRenderPass(e);let t=this._boundPipeline,n={...this._boundVertexBuffer},r=this._boundIndexBuffer,i={...this._boundBindGroup};this._clearCache();let a=this._renderer.renderTarget.viewport;this.renderPassEncoder.setViewport(a.x,a.y,a.width,a.height,0,1),this.setPipeline(t);for(let e in n)this._setVertexBuffer(e,n[e]);for(let e in i)this.setBindGroup(e,i[e],null);this._setIndexBuffer(r)}_clearCache(){for(let e=0;e<16;e++)this._boundBindGroup[e]=null,this._boundVertexBuffer[e]=null;this._boundIndexBuffer=null,this._boundPipeline=null}destroy(){this._renderer=null,this._gpu=null,this._boundBindGroup=null,this._boundVertexBuffer=null,this._boundIndexBuffer=null,this._boundPipeline=null}contextChange(e){this._gpu=e}};Bs.extension={type:[U.WebGPUSystem],name:`encoder`,priority:1};var Vs=class{constructor(e){this._renderTargetStencilState=Object.create(null),this._renderer=e,e.renderTarget.onRenderTargetChange.add(this)}onRenderTargetChange(e){let t=this._renderTargetStencilState[e.uid];t||=this._renderTargetStencilState[e.uid]={stencilMode:Ee.DISABLED,stencilReference:0},this._activeRenderTarget=e,this.setStencilMode(t.stencilMode,t.stencilReference)}setStencilMode(e,t){let n=this._renderTargetStencilState[this._activeRenderTarget.uid];n.stencilMode=e,n.stencilReference=t;let r=this._renderer;r.pipeline.setStencilMode(e),r.encoder.renderPassEncoder.setStencilReference(t)}destroy(){this._renderer.renderTarget.onRenderTargetChange.remove(this),this._renderer=null,this._activeRenderTarget=null,this._renderTargetStencilState=null}};Vs.extension={type:[U.WebGPUSystem],name:`stencil`};var Hs={i32:{align:4,size:4},u32:{align:4,size:4},f32:{align:4,size:4},f16:{align:2,size:2},"vec2<i32>":{align:8,size:8},"vec2<u32>":{align:8,size:8},"vec2<f32>":{align:8,size:8},"vec2<f16>":{align:4,size:4},"vec3<i32>":{align:16,size:12},"vec3<u32>":{align:16,size:12},"vec3<f32>":{align:16,size:12},"vec3<f16>":{align:8,size:6},"vec4<i32>":{align:16,size:16},"vec4<u32>":{align:16,size:16},"vec4<f32>":{align:16,size:16},"vec4<f16>":{align:8,size:8},"mat2x2<f32>":{align:8,size:16},"mat2x2<f16>":{align:4,size:8},"mat3x2<f32>":{align:8,size:24},"mat3x2<f16>":{align:4,size:12},"mat4x2<f32>":{align:8,size:32},"mat4x2<f16>":{align:4,size:16},"mat2x3<f32>":{align:16,size:32},"mat2x3<f16>":{align:8,size:16},"mat3x3<f32>":{align:16,size:48},"mat3x3<f16>":{align:8,size:24},"mat4x3<f32>":{align:16,size:64},"mat4x3<f16>":{align:8,size:32},"mat2x4<f32>":{align:16,size:32},"mat2x4<f16>":{align:8,size:16},"mat3x4<f32>":{align:16,size:48},"mat3x4<f16>":{align:8,size:24},"mat4x4<f32>":{align:16,size:64},"mat4x4<f16>":{align:8,size:32}};function Us(e){let t=e.map(e=>({data:e,offset:0,size:0})),n=0;for(let e=0;e<t.length;e++){let r=t[e],i=Hs[r.data.type].size,a=Hs[r.data.type].align;if(!Hs[r.data.type])throw Error(`[Pixi.js] WebGPU UniformBuffer: Unknown type ${r.data.type}`);r.data.size>1&&(i=Math.max(i,a)*r.data.size),n=Math.ceil(n/a)*a,r.size=i,r.offset=n,n+=i}return n=Math.ceil(n/16)*16,{uboElements:t,size:n}}function Ws(e,t){let{size:n,align:r}=Hs[e.data.type],i=(r-n)/4;return`
|
|
330
|
+
v = uv.${e.data.name};
|
|
331
|
+
${t===0?``:`offset += ${t};`}
|
|
332
|
+
|
|
333
|
+
arrayOffset = offset;
|
|
334
|
+
|
|
335
|
+
t = 0;
|
|
336
|
+
|
|
337
|
+
for(var i=0; i < ${e.data.size*(n/4)}; i++)
|
|
338
|
+
{
|
|
339
|
+
for(var j = 0; j < ${n/4}; j++)
|
|
340
|
+
{
|
|
341
|
+
data[arrayOffset++] = v[t++];
|
|
342
|
+
}
|
|
343
|
+
${i===0?``:`arrayOffset += ${i};`}
|
|
344
|
+
}
|
|
345
|
+
`}function Gs(e){return Ye(e,`uboWgsl`,Ws,tt)}var Ks=class extends ct{constructor(){super({createUboElements:Us,generateUboSync:Gs})}};Ks.extension={type:[U.WebGPUSystem],name:`ubo`};var qs=class{constructor({minUniformOffsetAlignment:e}){this._minUniformOffsetAlignment=256,this.byteIndex=0,this._minUniformOffsetAlignment=e,this.data=new Float32Array(65535)}clear(){this.byteIndex=0}addEmptyGroup(e){if(e>this._minUniformOffsetAlignment/4)throw Error(`UniformBufferBatch: array is too large: ${e*4}`);let t=this.byteIndex,n=t+e*4;if(n=Math.ceil(n/this._minUniformOffsetAlignment)*this._minUniformOffsetAlignment,n>this.data.length*4)throw Error(`UniformBufferBatch: ubo batch got too big`);return this.byteIndex=n,t}addGroup(e){let t=this.addEmptyGroup(e.length);for(let n=0;n<e.length;n++)this.data[t/4+n]=e[n];return t}destroy(){this._buffer.destroy(),this._buffer=null,this.data=null}},Js=128,Ys=class{constructor(e){this._bindGroupHash=Object.create(null),this._buffers=[],this._bindGroups=[],this._bufferResources=[],this._renderer=e,this._batchBuffer=new qs({minUniformOffsetAlignment:Js});let t=256/Js;for(let e=0;e<t;e++){let t=P.UNIFORM|P.COPY_DST;e===0&&(t|=P.COPY_SRC),this._buffers.push(new le({data:this._batchBuffer.data,usage:t}))}}renderEnd(){this._uploadBindGroups(),this._resetBindGroups()}_resetBindGroups(){for(let e in this._bindGroupHash)this._bindGroupHash[e]=null;this._batchBuffer.clear()}getUniformBindGroup(e,t){if(!t&&this._bindGroupHash[e.uid])return this._bindGroupHash[e.uid];this._renderer.ubo.ensureUniformGroup(e);let n=e.buffer.data,r=this._batchBuffer.addEmptyGroup(n.length);return this._renderer.ubo.syncUniformGroup(e,this._batchBuffer.data,r/4),this._bindGroupHash[e.uid]=this._getBindGroup(r/Js),this._bindGroupHash[e.uid]}getUboResource(e){this._renderer.ubo.updateUniformGroup(e);let t=e.buffer.data,n=this._batchBuffer.addGroup(t);return this._getBufferResource(n/Js)}getArrayBindGroup(e){let t=this._batchBuffer.addGroup(e);return this._getBindGroup(t/Js)}getArrayBufferResource(e){let t=this._batchBuffer.addGroup(e)/Js;return this._getBufferResource(t)}_getBufferResource(e){if(!this._bufferResources[e]){let t=this._buffers[e%2];this._bufferResources[e]=new lt({buffer:t,offset:(e/2|0)*256,size:Js})}return this._bufferResources[e]}_getBindGroup(e){if(!this._bindGroups[e]){let t=new re({0:this._getBufferResource(e)});this._bindGroups[e]=t}return this._bindGroups[e]}_uploadBindGroups(){let e=this._renderer.buffer,t=this._buffers[0];t.update(this._batchBuffer.byteIndex),e.updateBuffer(t);let n=this._renderer.gpu.device.createCommandEncoder();for(let r=1;r<this._buffers.length;r++){let i=this._buffers[r];n.copyBufferToBuffer(e.getGPUBuffer(t),Js,e.getGPUBuffer(i),0,this._batchBuffer.byteIndex)}this._renderer.gpu.device.queue.submit([n.finish()])}destroy(){for(let e=0;e<this._bindGroups.length;e++)this._bindGroups[e].destroy();this._bindGroups=null,this._bindGroupHash=null;for(let e=0;e<this._buffers.length;e++)this._buffers[e].destroy();this._buffers=null;for(let e=0;e<this._bufferResources.length;e++)this._bufferResources[e].destroy();this._bufferResources=null,this._batchBuffer.destroy(),this._bindGroupHash=null,this._renderer=null}};Ys.extension={type:[U.WebGPUPipes],name:`uniformBatch`};var Xs={"point-list":0,"line-list":1,"line-strip":2,"triangle-list":3,"triangle-strip":4};function Zs(e,t,n,r,i){return e<<24|t<<16|n<<10|r<<5|i}function Qs(e,t,n,r){return n<<6|e<<3|r<<1|t}var $s=class{constructor(e){this._moduleCache=Object.create(null),this._bufferLayoutsCache=Object.create(null),this._bindingNamesCache=Object.create(null),this._pipeCache=Object.create(null),this._pipeStateCaches=Object.create(null),this._colorMask=15,this._multisampleCount=1,this._renderer=e}contextChange(e){this._gpu=e,this.setStencilMode(Ee.DISABLED),this._updatePipeHash()}setMultisampleCount(e){this._multisampleCount!==e&&(this._multisampleCount=e,this._updatePipeHash())}setRenderTarget(e){this._multisampleCount=e.msaaSamples,this._depthStencilAttachment=+!!e.descriptor.depthStencilAttachment,this._updatePipeHash()}setColorMask(e){this._colorMask!==e&&(this._colorMask=e,this._updatePipeHash())}setStencilMode(e){this._stencilMode!==e&&(this._stencilMode=e,this._stencilState=Xe[e],this._updatePipeHash())}setPipeline(e,t,n,r){let i=this.getPipeline(e,t,n);r.setPipeline(i)}getPipeline(e,t,n,r){e._layoutKey||(nt(e,t.attributeData),this._generateBufferKey(e)),r||=e.topology;let i=Zs(e._layoutKey,t._layoutKey,n.data,n._blendModeId,Xs[r]);return this._pipeCache[i]||(this._pipeCache[i]=this._createPipeline(e,t,n,r)),this._pipeCache[i]}_createPipeline(e,t,n,r){let i=this._gpu.device,a=this._createVertexBufferLayouts(e,t),o=this._renderer.state.getColorTargets(n);o[0].writeMask=this._stencilMode===Ee.RENDERING_MASK_ADD?0:this._colorMask;let s=this._renderer.shader.getProgramData(t).pipeline,c={vertex:{module:this._getModule(t.vertex.source),entryPoint:t.vertex.entryPoint,buffers:a},fragment:{module:this._getModule(t.fragment.source),entryPoint:t.fragment.entryPoint,targets:o},primitive:{topology:r,cullMode:n.cullMode},layout:s,multisample:{count:this._multisampleCount},label:`PIXI Pipeline`};return this._depthStencilAttachment&&(c.depthStencil={...this._stencilState,format:`depth24plus-stencil8`,depthWriteEnabled:n.depthTest,depthCompare:n.depthTest?`less`:`always`}),i.createRenderPipeline(c)}_getModule(e){return this._moduleCache[e]||this._createModule(e)}_createModule(e){let t=this._gpu.device;return this._moduleCache[e]=t.createShaderModule({code:e}),this._moduleCache[e]}_generateBufferKey(e){let t=[],n=0,r=Object.keys(e.attributes).sort();for(let i=0;i<r.length;i++){let a=e.attributes[r[i]];t[n++]=a.offset,t[n++]=a.format,t[n++]=a.stride,t[n++]=a.instance}return e._layoutKey=ge(t.join(`|`),`geometry`),e._layoutKey}_generateAttributeLocationsKey(e){let t=[],n=0,r=Object.keys(e.attributeData).sort();for(let i=0;i<r.length;i++){let a=e.attributeData[r[i]];t[n++]=a.location}return e._attributeLocationsKey=ge(t.join(`|`),`programAttributes`),e._attributeLocationsKey}getBufferNamesToBind(e,t){let n=e._layoutKey<<16|t._attributeLocationsKey;if(this._bindingNamesCache[n])return this._bindingNamesCache[n];let r=this._createVertexBufferLayouts(e,t),i=Object.create(null),a=t.attributeData;for(let e=0;e<r.length;e++)for(let t in a)if(a[t].location===e){i[e]=t;break}return this._bindingNamesCache[n]=i,i}_createVertexBufferLayouts(e,t){t._attributeLocationsKey||this._generateAttributeLocationsKey(t);let n=e._layoutKey<<16|t._attributeLocationsKey;if(this._bufferLayoutsCache[n])return this._bufferLayoutsCache[n];let r=[];return e.buffers.forEach(n=>{let i={arrayStride:0,stepMode:`vertex`,attributes:[]},a=i.attributes;for(let r in t.attributeData){let o=e.attributes[r];(o.divisor??1)!==1&&B(`Attribute ${r} has an invalid divisor value of '${o.divisor}'. WebGPU only supports a divisor value of 1`),o.buffer===n&&(i.arrayStride=o.stride,i.stepMode=o.instance?`instance`:`vertex`,a.push({shaderLocation:t.attributeData[r].location,offset:o.offset,format:o.format}))}a.length&&r.push(i)}),this._bufferLayoutsCache[n]=r,r}_updatePipeHash(){let e=Qs(this._stencilMode,this._multisampleCount,this._colorMask,this._depthStencilAttachment);this._pipeStateCaches[e]||(this._pipeStateCaches[e]=Object.create(null)),this._pipeCache=this._pipeStateCaches[e]}destroy(){this._renderer=null,this._bufferLayoutsCache=null}};$s.extension={type:[U.WebGPUSystem],name:`pipeline`};var ec=class{constructor(){this.contexts=[],this.msaaTextures=[],this.msaaSamples=1}},tc=class{init(e,t){this._renderer=e,this._renderTargetSystem=t}copyToTexture(e,t,n,r,i){let a=this._renderer,o=this._getGpuColorTexture(e),s=a.texture.getGpuSource(t.source);return a.encoder.commandEncoder.copyTextureToTexture({texture:o,origin:n},{texture:s,origin:i},r),t}startRenderPass(e,t=!0,n,r){let i=this._renderTargetSystem.getGpuRenderTarget(e);i.descriptor=this.getDescriptor(e,t,n),this._renderer.pipeline.setRenderTarget(i),this._renderer.encoder.beginRenderPass(i),this._renderer.encoder.setViewport(r)}finishRenderPass(){this._renderer.encoder.endRenderPass()}_getGpuColorTexture(e){let t=this._renderTargetSystem.getGpuRenderTarget(e);return t.contexts[0]?t.contexts[0].getCurrentTexture():this._renderer.texture.getGpuSource(e.colorTextures[0].source)}getDescriptor(e,t,n){typeof t==`boolean`&&(t=t?rt.ALL:rt.NONE);let r=this._renderTargetSystem,i=r.getGpuRenderTarget(e),a=e.colorTextures.map((e,a)=>{let o=i.contexts[a],s,c;s=o?o.getCurrentTexture().createView():this._renderer.texture.getGpuSource(e).createView({mipLevelCount:1}),i.msaaTextures[a]&&(c=s,s=this._renderer.texture.getTextureView(i.msaaTextures[a]));let l=t&rt.COLOR?`clear`:`load`;return n??=r.defaultClearColor,{view:s,resolveTarget:c,clearValue:n,storeOp:`store`,loadOp:l}}),o;if((e.stencil||e.depth)&&!e.depthStencilTexture&&(e.ensureDepthStencilTexture(),e.depthStencilTexture.source.sampleCount=i.msaa?4:1),e.depthStencilTexture){let n=t&rt.STENCIL?`clear`:`load`,r=t&rt.DEPTH?`clear`:`load`;o={view:this._renderer.texture.getGpuSource(e.depthStencilTexture.source).createView(),stencilStoreOp:`store`,stencilLoadOp:n,depthClearValue:1,depthLoadOp:r,depthStoreOp:`store`}}return{colorAttachments:a,depthStencilAttachment:o}}clear(e,t=!0,n,r){if(!t)return;let{gpu:i,encoder:a}=this._renderer,o=i.device;if(a.commandEncoder===null){let i=o.createCommandEncoder(),a=this.getDescriptor(e,t,n),s=i.beginRenderPass(a);s.setViewport(r.x,r.y,r.width,r.height,0,1),s.end();let c=i.finish();o.queue.submit([c])}else this.startRenderPass(e,t,n,r)}initGpuRenderTarget(e){e.isRoot=!0;let t=new ec;return e.colorTextures.forEach((e,n)=>{if(ie.test(e.resource)){let r=e.resource.getContext(`webgpu`),i=e.transparent?`premultiplied`:`opaque`;try{r.configure({device:this._renderer.gpu.device,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,format:`bgra8unorm`,alphaMode:i})}catch(e){console.error(e)}t.contexts[n]=r}if(t.msaa=e.source.antialias,e.source.antialias){let e=new j({width:0,height:0,sampleCount:4});t.msaaTextures[n]=e}}),t.msaa&&(t.msaaSamples=4,e.depthStencilTexture&&(e.depthStencilTexture.source.sampleCount=4)),t}destroyGpuRenderTarget(e){e.contexts.forEach(e=>{e.unconfigure()}),e.msaaTextures.forEach(e=>{e.destroy()}),e.msaaTextures.length=0,e.contexts.length=0}ensureDepthStencilTexture(e){let t=this._renderTargetSystem.getGpuRenderTarget(e);e.depthStencilTexture&&t.msaa&&(e.depthStencilTexture.source.sampleCount=4)}resizeGpuRenderTarget(e){let t=this._renderTargetSystem.getGpuRenderTarget(e);t.width=e.width,t.height=e.height,t.msaa&&e.colorTextures.forEach((e,n)=>{t.msaaTextures[n]?.resize(e.source.width,e.source.height,e.source._resolution)})}},nc=class extends it{constructor(e){super(e),this.adaptor=new tc,this.adaptor.init(e,this)}};nc.extension={type:[U.WebGPUSystem],name:`renderTarget`};var rc=class{constructor(){this._gpuProgramData=Object.create(null)}contextChange(e){this._gpu=e,this.maxTextures=e.device.limits.maxSampledTexturesPerShaderStage}getProgramData(e){return this._gpuProgramData[e._layoutKey]||this._createGPUProgramData(e)}_createGPUProgramData(e){let t=this._gpu.device,n=e.gpuLayout.map(e=>t.createBindGroupLayout({entries:e})),r={bindGroupLayouts:n};return this._gpuProgramData[e._layoutKey]={bindGroups:n,pipeline:t.createPipelineLayout(r)},this._gpuProgramData[e._layoutKey]}destroy(){this._gpu=null,this._gpuProgramData=null}};rc.extension={type:[U.WebGPUSystem],name:`shader`};var ic={};ic.normal={alpha:{srcFactor:`one`,dstFactor:`one-minus-src-alpha`,operation:`add`},color:{srcFactor:`one`,dstFactor:`one-minus-src-alpha`,operation:`add`}},ic.add={alpha:{srcFactor:`src-alpha`,dstFactor:`one-minus-src-alpha`,operation:`add`},color:{srcFactor:`one`,dstFactor:`one`,operation:`add`}},ic.multiply={alpha:{srcFactor:`one`,dstFactor:`one-minus-src-alpha`,operation:`add`},color:{srcFactor:`dst`,dstFactor:`one-minus-src-alpha`,operation:`add`}},ic.screen={alpha:{srcFactor:`one`,dstFactor:`one-minus-src-alpha`,operation:`add`},color:{srcFactor:`one`,dstFactor:`one-minus-src`,operation:`add`}},ic.overlay={alpha:{srcFactor:`one`,dstFactor:`one-minus-src-alpha`,operation:`add`},color:{srcFactor:`one`,dstFactor:`one-minus-src`,operation:`add`}},ic.none={alpha:{srcFactor:`one`,dstFactor:`one-minus-src-alpha`,operation:`add`},color:{srcFactor:`zero`,dstFactor:`zero`,operation:`add`}},ic[`normal-npm`]={alpha:{srcFactor:`one`,dstFactor:`one-minus-src-alpha`,operation:`add`},color:{srcFactor:`src-alpha`,dstFactor:`one-minus-src-alpha`,operation:`add`}},ic[`add-npm`]={alpha:{srcFactor:`one`,dstFactor:`one`,operation:`add`},color:{srcFactor:`src-alpha`,dstFactor:`one`,operation:`add`}},ic[`screen-npm`]={alpha:{srcFactor:`one`,dstFactor:`one-minus-src-alpha`,operation:`add`},color:{srcFactor:`src-alpha`,dstFactor:`one-minus-src`,operation:`add`}},ic.erase={alpha:{srcFactor:`zero`,dstFactor:`one-minus-src-alpha`,operation:`add`},color:{srcFactor:`zero`,dstFactor:`one-minus-src`,operation:`add`}},ic.min={alpha:{srcFactor:`one`,dstFactor:`one`,operation:`min`},color:{srcFactor:`one`,dstFactor:`one`,operation:`min`}},ic.max={alpha:{srcFactor:`one`,dstFactor:`one`,operation:`max`},color:{srcFactor:`one`,dstFactor:`one`,operation:`max`}};var ac=class{constructor(){this.defaultState=new ce,this.defaultState.blend=!0}contextChange(e){this.gpu=e}getColorTargets(e){return[{format:`bgra8unorm`,writeMask:0,blend:ic[e.blendMode]||ic.normal}]}destroy(){this.gpu=null}};ac.extension={type:[U.WebGPUSystem],name:`state`};var oc={type:`image`,upload(e,t,n){let r=e.resource,i=(e.pixelWidth|0)*(e.pixelHeight|0),a=r.byteLength/i;n.device.queue.writeTexture({texture:t},r,{offset:0,rowsPerImage:e.pixelHeight,bytesPerRow:e.pixelHeight*a},{width:e.pixelWidth,height:e.pixelHeight,depthOrArrayLayers:1})}},sc={"bc1-rgba-unorm":{blockBytes:8,blockWidth:4,blockHeight:4},"bc2-rgba-unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"bc3-rgba-unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"bc7-rgba-unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"etc1-rgb-unorm":{blockBytes:8,blockWidth:4,blockHeight:4},"etc2-rgba8unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"astc-4x4-unorm":{blockBytes:16,blockWidth:4,blockHeight:4}},cc={blockBytes:4,blockWidth:1,blockHeight:1},lc={type:`compressed`,upload(e,t,n){let r=e.pixelWidth,i=e.pixelHeight,a=sc[e.format]||cc;for(let o=0;o<e.resource.length;o++){let s=e.resource[o],c=Math.ceil(r/a.blockWidth)*a.blockBytes;n.device.queue.writeTexture({texture:t,mipLevel:o},s,{offset:0,bytesPerRow:c},{width:Math.ceil(r/a.blockWidth)*a.blockWidth,height:Math.ceil(i/a.blockHeight)*a.blockHeight,depthOrArrayLayers:1}),r=Math.max(r>>1,1),i=Math.max(i>>1,1)}}},uc={type:`image`,upload(e,t,n){let r=e.resource;if(!r)return;let i=Math.min(t.width,e.resourceWidth||e.pixelWidth),a=Math.min(t.height,e.resourceHeight||e.pixelHeight),o=e.alphaMode===`premultiply-alpha-on-upload`;n.device.queue.copyExternalImageToTexture({source:r},{texture:t,premultipliedAlpha:o},{width:i,height:a})}},dc={type:`video`,upload(e,t,n){uc.upload(e,t,n)}},fc=class{constructor(e){this.device=e,this.sampler=e.createSampler({minFilter:`linear`}),this.pipelines={}}_getMipmapPipeline(e){let t=this.pipelines[e];return t||(this.mipmapShaderModule||=this.device.createShaderModule({code:`
|
|
346
|
+
var<private> pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
|
|
347
|
+
vec2<f32>(-1.0, -1.0), vec2<f32>(-1.0, 3.0), vec2<f32>(3.0, -1.0));
|
|
348
|
+
|
|
349
|
+
struct VertexOutput {
|
|
350
|
+
@builtin(position) position : vec4<f32>,
|
|
351
|
+
@location(0) texCoord : vec2<f32>,
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
@vertex
|
|
355
|
+
fn vertexMain(@builtin(vertex_index) vertexIndex : u32) -> VertexOutput {
|
|
356
|
+
var output : VertexOutput;
|
|
357
|
+
output.texCoord = pos[vertexIndex] * vec2<f32>(0.5, -0.5) + vec2<f32>(0.5);
|
|
358
|
+
output.position = vec4<f32>(pos[vertexIndex], 0.0, 1.0);
|
|
359
|
+
return output;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
@group(0) @binding(0) var imgSampler : sampler;
|
|
363
|
+
@group(0) @binding(1) var img : texture_2d<f32>;
|
|
364
|
+
|
|
365
|
+
@fragment
|
|
366
|
+
fn fragmentMain(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {
|
|
367
|
+
return textureSample(img, imgSampler, texCoord);
|
|
368
|
+
}
|
|
369
|
+
`}),t=this.device.createRenderPipeline({layout:`auto`,vertex:{module:this.mipmapShaderModule,entryPoint:`vertexMain`},fragment:{module:this.mipmapShaderModule,entryPoint:`fragmentMain`,targets:[{format:e}]}}),this.pipelines[e]=t),t}generateMipmap(e){let t=this._getMipmapPipeline(e.format);if(e.dimension===`3d`||e.dimension===`1d`)throw Error(`Generating mipmaps for non-2d textures is currently unsupported!`);let n=e,r=e.depthOrArrayLayers||1,i=e.usage&GPUTextureUsage.RENDER_ATTACHMENT;if(!i){let t={size:{width:Math.ceil(e.width/2),height:Math.ceil(e.height/2),depthOrArrayLayers:r},format:e.format,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.RENDER_ATTACHMENT,mipLevelCount:e.mipLevelCount-1};n=this.device.createTexture(t)}let a=this.device.createCommandEncoder({}),o=t.getBindGroupLayout(0);for(let s=0;s<r;++s){let r=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:`2d`,baseArrayLayer:s,arrayLayerCount:1}),c=+!!i;for(let i=1;i<e.mipLevelCount;++i){let e=n.createView({baseMipLevel:c++,mipLevelCount:1,dimension:`2d`,baseArrayLayer:s,arrayLayerCount:1}),i=a.beginRenderPass({colorAttachments:[{view:e,storeOp:`store`,loadOp:`clear`,clearValue:{r:0,g:0,b:0,a:0}}]}),l=this.device.createBindGroup({layout:o,entries:[{binding:0,resource:this.sampler},{binding:1,resource:r}]});i.setPipeline(t),i.setBindGroup(0,l),i.draw(3,1,0,0),i.end(),r=e}}if(!i){let t={width:Math.ceil(e.width/2),height:Math.ceil(e.height/2),depthOrArrayLayers:r};for(let r=1;r<e.mipLevelCount;++r)a.copyTextureToTexture({texture:n,mipLevel:r-1},{texture:e,mipLevel:r},t),t.width=Math.ceil(t.width/2),t.height=Math.ceil(t.height/2)}return this.device.queue.submit([a.finish()]),i||n.destroy(),e}},pc=class{constructor(e){this.managedTextures=[],this._gpuSources=Object.create(null),this._gpuSamplers=Object.create(null),this._bindGroupHash=Object.create(null),this._textureViewHash=Object.create(null),this._uploads={image:uc,buffer:oc,video:dc,compressed:lc},this._renderer=e}contextChange(e){this._gpu=e}initSource(e){if(e.autoGenerateMipmaps){let t=Math.max(e.pixelWidth,e.pixelHeight);e.mipLevelCount=Math.floor(Math.log2(t))+1}let t=GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST;e.uploadMethodId!==`compressed`&&(t|=GPUTextureUsage.RENDER_ATTACHMENT,t|=GPUTextureUsage.COPY_SRC);let n=sc[e.format]||{blockBytes:4,blockWidth:1,blockHeight:1},r=Math.ceil(e.pixelWidth/n.blockWidth)*n.blockWidth,i=Math.ceil(e.pixelHeight/n.blockHeight)*n.blockHeight,a={label:e.label,size:{width:r,height:i},format:e.format,sampleCount:e.sampleCount,mipLevelCount:e.mipLevelCount,dimension:e.dimension,usage:t},o=this._gpu.device.createTexture(a);return this._gpuSources[e.uid]=o,this.managedTextures.includes(e)||(e.on(`update`,this.onSourceUpdate,this),e.on(`resize`,this.onSourceResize,this),e.on(`destroy`,this.onSourceDestroy,this),e.on(`unload`,this.onSourceUnload,this),e.on(`updateMipmaps`,this.onUpdateMipmaps,this),this.managedTextures.push(e)),this.onSourceUpdate(e),o}onSourceUpdate(e){let t=this.getGpuSource(e);t&&(this._uploads[e.uploadMethodId]&&this._uploads[e.uploadMethodId].upload(e,t,this._gpu),e.autoGenerateMipmaps&&e.mipLevelCount>1&&this.onUpdateMipmaps(e))}onSourceUnload(e){let t=this._gpuSources[e.uid];t&&(this._gpuSources[e.uid]=null,t.destroy())}onUpdateMipmaps(e){this._mipmapGenerator||=new fc(this._gpu.device);let t=this.getGpuSource(e);this._mipmapGenerator.generateMipmap(t)}onSourceDestroy(e){e.off(`update`,this.onSourceUpdate,this),e.off(`unload`,this.onSourceUnload,this),e.off(`destroy`,this.onSourceDestroy,this),e.off(`resize`,this.onSourceResize,this),e.off(`updateMipmaps`,this.onUpdateMipmaps,this),this.managedTextures.splice(this.managedTextures.indexOf(e),1),this.onSourceUnload(e)}onSourceResize(e){let t=this._gpuSources[e.uid];t?(t.width!==e.pixelWidth||t.height!==e.pixelHeight)&&(this._textureViewHash[e.uid]=null,this._bindGroupHash[e.uid]=null,this.onSourceUnload(e),this.initSource(e)):this.initSource(e)}_initSampler(e){return this._gpuSamplers[e._resourceId]=this._gpu.device.createSampler(e),this._gpuSamplers[e._resourceId]}getGpuSampler(e){return this._gpuSamplers[e._resourceId]||this._initSampler(e)}getGpuSource(e){return this._gpuSources[e.uid]||this.initSource(e)}getTextureBindGroup(e){return this._bindGroupHash[e.uid]??this._createTextureBindGroup(e)}_createTextureBindGroup(e){let t=e.source;return this._bindGroupHash[e.uid]=new re({0:t,1:t.style,2:new We({uTextureMatrix:{type:`mat3x3<f32>`,value:e.textureMatrix.mapCoord}})}),this._bindGroupHash[e.uid]}getTextureView(e){let t=e.source;return this._textureViewHash[t.uid]??this._createTextureView(t)}_createTextureView(e){return this._textureViewHash[e.uid]=this.getGpuSource(e).createView(),this._textureViewHash[e.uid]}generateCanvas(e){let t=this._renderer,n=t.gpu.device.createCommandEncoder(),r=z.get().createCanvas();r.width=e.source.pixelWidth,r.height=e.source.pixelHeight;let i=r.getContext(`webgpu`);return i.configure({device:t.gpu.device,usage:GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC,format:z.get().getNavigator().gpu.getPreferredCanvasFormat(),alphaMode:`premultiplied`}),n.copyTextureToTexture({texture:t.texture.getGpuSource(e.source),origin:{x:0,y:0}},{texture:i.getCurrentTexture()},{width:r.width,height:r.height}),t.gpu.device.queue.submit([n.finish()]),r}getPixels(e){let t=this.generateCanvas(e),n=qe.getOptimalCanvasAndContext(t.width,t.height),r=n.context;r.drawImage(t,0,0);let{width:i,height:a}=t,o=r.getImageData(0,0,i,a),s=new Uint8ClampedArray(o.data.buffer);return qe.returnCanvasAndContext(n),{pixels:s,width:i,height:a}}destroy(){this.managedTextures.slice().forEach(e=>this.onSourceDestroy(e)),this.managedTextures=null;for(let e of Object.keys(this._bindGroupHash)){let t=Number(e);this._bindGroupHash[t]?.destroy(),this._bindGroupHash[t]=null}this._gpu=null,this._mipmapGenerator=null,this._gpuSources=null,this._bindGroupHash=null,this._textureViewHash=null,this._gpuSamplers=null}};pc.extension={type:[U.WebGPUSystem],name:`texture`};var mc=e({WebGPURenderer:()=>xc}),hc=[...Ze,Ks,Bs,zs,Ls,pc,nc,rc,ac,$s,Rs,Vs,Is],gc=[...ut,Ys],_c=[Fs,Ns,Ms],vc=[],yc=[],bc=[];Pe.handleByNamedList(U.WebGPUSystem,vc),Pe.handleByNamedList(U.WebGPUPipes,yc),Pe.handleByNamedList(U.WebGPUPipesAdaptor,bc),Pe.add(...hc,...gc,..._c);var xc=class extends ot{constructor(){let e={name:`webgpu`,type:he.WEBGPU,systems:vc,renderPipes:yc,renderPipeAdaptors:bc};super(e)}};function Sc(){return Cc}function Cc(e,t,n){let r=e.gl,i=e.shader,a=i._getProgramData(t.glProgram);for(let o in t.groups){let s=t.groups[o];for(let c in s.resources){let l=s.resources[c];if(l instanceof We)l.ubo?i.bindUniformBlock(l,t._uniformBindMap[o][c],n.blockIndex++):i.updateUniformGroup(l);else if(l instanceof lt)i.bindUniformBlock(l,t._uniformBindMap[o][c],n.blockIndex++);else if(l instanceof j){e.texture.bind(l,n.textureCount);let i=t._uniformBindMap[o][c],s=a.uniformData[i];s&&(s.value!==n.textureCount&&r.uniform1i(s.location,n.textureCount),n.textureCount++)}else l instanceof ue}}}var wc=[(e,t,n,r,i)=>{let a=r[e].toArray(!0);t[n]=a[0],t[n+1]=a[1],t[n+2]=a[2],t[n+4]=a[3],t[n+5]=a[4],t[n+6]=a[5],t[n+8]=a[6],t[n+9]=a[7],t[n+10]=a[8]},(e,t,n,r,i)=>{i=r[e],t[n]=i.x,t[n+1]=i.y,t[n+2]=i.width,t[n+3]=i.height},(e,t,n,r,i)=>{i=r[e],t[n]=i.x,t[n+1]=i.y},(e,t,n,r,i)=>{i=r[e],t[n]=i.red,t[n+1]=i.green,t[n+2]=i.blue,t[n+3]=i.alpha},(e,t,n,r,i)=>{i=r[e],t[n]=i.red,t[n+1]=i.green,t[n+2]=i.blue}],Tc={f32:(e,t,n,r,i)=>{t[n]=i},i32:(e,t,n,r,i)=>{t[n]=i},"vec2<f32>":(e,t,n,r,i)=>{t[n]=i[0],t[n+1]=i[1]},"vec3<f32>":(e,t,n,r,i)=>{t[n]=i[0],t[n+1]=i[1],t[n+2]=i[2]},"vec4<f32>":(e,t,n,r,i)=>{t[n]=i[0],t[n+1]=i[1],t[n+2]=i[2],t[n+3]=i[3]},"mat2x2<f32>":(e,t,n,r,i)=>{t[n]=i[0],t[n+1]=i[1],t[n+2]=i[2],t[n+3]=i[3]},"mat3x3<f32>":(e,t,n,r,i)=>{t[n]=i[0],t[n+1]=i[1],t[n+2]=i[2],t[n+4]=i[3],t[n+5]=i[4],t[n+6]=i[5],t[n+8]=i[6],t[n+9]=i[7],t[n+10]=i[8]},"mat4x4<f32>":(e,t,n,r,i)=>{for(let e=0;e<16;e++)t[n+e]=i[e]},"mat3x2<f32>":(e,t,n,r,i)=>{for(let e=0;e<6;e++)t[n+(e/3|0)*4+e%3]=i[e]},"mat4x2<f32>":(e,t,n,r,i)=>{for(let e=0;e<8;e++)t[n+(e/4|0)*4+e%4]=i[e]},"mat2x3<f32>":(e,t,n,r,i)=>{for(let e=0;e<6;e++)t[n+(e/2|0)*4+e%2]=i[e]},"mat4x3<f32>":(e,t,n,r,i)=>{for(let e=0;e<12;e++)t[n+(e/4|0)*4+e%4]=i[e]},"mat2x4<f32>":(e,t,n,r,i)=>{for(let e=0;e<8;e++)t[n+(e/2|0)*4+e%2]=i[e]},"mat3x4<f32>":(e,t,n,r,i)=>{for(let e=0;e<12;e++)t[n+(e/3|0)*4+e%3]=i[e]}},Ec={f32:(e,t,n,r,i)=>{t[n]=i},i32:(e,t,n,r,i)=>{t[n]=i},"vec2<f32>":(e,t,n,r,i)=>{t[n]=i[0],t[n+1]=i[1]},"vec3<f32>":(e,t,n,r,i)=>{t[n]=i[0],t[n+1]=i[1],t[n+2]=i[2]},"vec4<f32>":(e,t,n,r,i)=>{t[n]=i[0],t[n+1]=i[1],t[n+2]=i[2],t[n+3]=i[3]},"mat2x2<f32>":(e,t,n,r,i)=>{t[n]=i[0],t[n+1]=i[1],t[n+4]=i[2],t[n+5]=i[3]},"mat3x3<f32>":(e,t,n,r,i)=>{t[n]=i[0],t[n+1]=i[1],t[n+2]=i[2],t[n+4]=i[3],t[n+5]=i[4],t[n+6]=i[5],t[n+8]=i[6],t[n+9]=i[7],t[n+10]=i[8]},"mat4x4<f32>":(e,t,n,r,i)=>{for(let e=0;e<16;e++)t[n+e]=i[e]},"mat3x2<f32>":(e,t,n,r,i)=>{for(let e=0;e<6;e++)t[n+(e/3|0)*4+e%3]=i[e]},"mat4x2<f32>":(e,t,n,r,i)=>{for(let e=0;e<8;e++)t[n+(e/4|0)*4+e%4]=i[e]},"mat2x3<f32>":(e,t,n,r,i)=>{for(let e=0;e<6;e++)t[n+(e/2|0)*4+e%2]=i[e]},"mat4x3<f32>":(e,t,n,r,i)=>{for(let e=0;e<12;e++)t[n+(e/4|0)*4+e%4]=i[e]},"mat2x4<f32>":(e,t,n,r,i)=>{for(let e=0;e<8;e++)t[n+(e/2|0)*4+e%2]=i[e]},"mat3x4<f32>":(e,t,n,r,i)=>{for(let e=0;e<12;e++)t[n+(e/3|0)*4+e%3]=i[e]}};function Dc(e){return kc(e,Ec,e=>{let t=Math.max(Co[e.data.type]/16,1),n=e.data.value.length/e.data.size,r=(4-n%4)%4;return(i,a,o,s,c)=>{let l=0;for(let i=0;i<e.data.size*t;i++){for(let e=0;e<n;e++)a[o++]=c[l++];o+=r}}})}function Oc(e){return kc(e,Tc,e=>{let{size:t,align:n}=Hs[e.data.type],r=(t-n)/4;return(n,i,a,o,s)=>{let c=0;for(let n=0;n<e.data.size*(t/4);n++){for(let e=0;e<t/4;e++)i[a++]=s[c++];a+=r}}})}function kc(e,t,n){let r={};for(let i in e){let a=e[i],o=a.data,s=!1;r[o.name]={offset:a.offset/4,func:null};for(let e=0;e<at.length;e++){let t=at[e];if(o.type===t.type&&t.test(o)){r[o.name].func=wc[e],s=!0;break}}s||(o.size===1?r[o.name].func=t[o.type]:r[o.name].func=n(a))}return(e,t,n)=>{for(let i in r)r[i].func(i,t,n+r[i].offset,e,e[i])}}var Ac={f32(e,t,n,r,i,a,o){n!==r&&(t.value=r,o.uniform1f(i[e].location,r))},"vec2<f32>"(e,t,n,r,i,a,o){(n[0]!==r[0]||n[1]!==r[1])&&(n[0]=r[0],n[1]=r[1],o.uniform2f(i[e].location,r[0],r[1]))},"vec3<f32>"(e,t,n,r,i,a,o){(n[0]!==r[0]||n[1]!==r[1]||n[2]!==r[2])&&(n[0]=r[0],n[1]=r[1],n[2]=r[2],o.uniform3f(i[e].location,r[0],r[1],r[2]))},"vec4<f32>"(e,t,n,r,i,a,o){(n[0]!==r[0]||n[1]!==r[1]||n[2]!==r[2]||n[3]!==r[3])&&(n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],o.uniform4f(i[e].location,r[0],r[1],r[2],r[3]))},i32(e,t,n,r,i,a,o){n!==r&&(t.value=r,o.uniform1i(i[e].location,r))},"vec2<i32>"(e,t,n,r,i,a,o){(n[0]!==r[0]||n[1]!==r[1])&&(n[0]=r[0],n[1]=r[1],o.uniform2i(i[e].location,r[0],r[1]))},"vec3<i32>"(e,t,n,r,i,a,o){(n[0]!==r[0]||n[1]!==r[1]||n[2]!==r[2])&&(n[0]=r[0],n[1]=r[1],n[2]=r[2],o.uniform3i(i[e].location,r[0],r[1],r[2]))},"vec4<i32>"(e,t,n,r,i,a,o){(n[0]!==r[0]||n[1]!==r[1]||n[2]!==r[2]||n[3]!==r[3])&&(n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],o.uniform4i(i[e].location,r[0],r[1],r[2],r[3]))},u32(e,t,n,r,i,a,o){n!==r&&(t.value=r,o.uniform1ui(i[e].location,r))},"vec2<u32>"(e,t,n,r,i,a,o){(n[0]!==r[0]||n[1]!==r[1])&&(n[0]=r[0],n[1]=r[1],o.uniform2ui(i[e].location,r[0],r[1]))},"vec3<u32>"(e,t,n,r,i,a,o){(n[0]!==r[0]||n[1]!==r[1]||n[2]!==r[2])&&(n[0]=r[0],n[1]=r[1],n[2]=r[2],o.uniform3ui(i[e].location,r[0],r[1],r[2]))},"vec4<u32>"(e,t,n,r,i,a,o){(n[0]!==r[0]||n[1]!==r[1]||n[2]!==r[2]||n[3]!==r[3])&&(n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],o.uniform4ui(i[e].location,r[0],r[1],r[2],r[3]))},bool(e,t,n,r,i,a,o){n!==r&&(t.value=r,o.uniform1i(i[e].location,r))},"vec2<bool>"(e,t,n,r,i,a,o){(n[0]!==r[0]||n[1]!==r[1])&&(n[0]=r[0],n[1]=r[1],o.uniform2i(i[e].location,r[0],r[1]))},"vec3<bool>"(e,t,n,r,i,a,o){(n[0]!==r[0]||n[1]!==r[1]||n[2]!==r[2])&&(n[0]=r[0],n[1]=r[1],n[2]=r[2],o.uniform3i(i[e].location,r[0],r[1],r[2]))},"vec4<bool>"(e,t,n,r,i,a,o){(n[0]!==r[0]||n[1]!==r[1]||n[2]!==r[2]||n[3]!==r[3])&&(n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],o.uniform4i(i[e].location,r[0],r[1],r[2],r[3]))},"mat2x2<f32>"(e,t,n,r,i,a,o){o.uniformMatrix2fv(i[e].location,!1,r)},"mat3x3<f32>"(e,t,n,r,i,a,o){o.uniformMatrix3fv(i[e].location,!1,r)},"mat4x4<f32>"(e,t,n,r,i,a,o){o.uniformMatrix4fv(i[e].location,!1,r)}},jc={f32(e,t,n,r,i,a,o){o.uniform1fv(i[e].location,r)},"vec2<f32>"(e,t,n,r,i,a,o){o.uniform2fv(i[e].location,r)},"vec3<f32>"(e,t,n,r,i,a,o){o.uniform3fv(i[e].location,r)},"vec4<f32>"(e,t,n,r,i,a,o){o.uniform4fv(i[e].location,r)},"mat2x2<f32>"(e,t,n,r,i,a,o){o.uniformMatrix2fv(i[e].location,!1,r)},"mat3x3<f32>"(e,t,n,r,i,a,o){o.uniformMatrix3fv(i[e].location,!1,r)},"mat4x4<f32>"(e,t,n,r,i,a,o){o.uniformMatrix4fv(i[e].location,!1,r)},i32(e,t,n,r,i,a,o){o.uniform1iv(i[e].location,r)},"vec2<i32>"(e,t,n,r,i,a,o){o.uniform2iv(i[e].location,r)},"vec3<i32>"(e,t,n,r,i,a,o){o.uniform3iv(i[e].location,r)},"vec4<i32>"(e,t,n,r,i,a,o){o.uniform4iv(i[e].location,r)},u32(e,t,n,r,i,a,o){o.uniform1iv(i[e].location,r)},"vec2<u32>"(e,t,n,r,i,a,o){o.uniform2iv(i[e].location,r)},"vec3<u32>"(e,t,n,r,i,a,o){o.uniform3iv(i[e].location,r)},"vec4<u32>"(e,t,n,r,i,a,o){o.uniform4iv(i[e].location,r)},bool(e,t,n,r,i,a,o){o.uniform1iv(i[e].location,r)},"vec2<bool>"(e,t,n,r,i,a,o){o.uniform2iv(i[e].location,r)},"vec3<bool>"(e,t,n,r,i,a,o){o.uniform3iv(i[e].location,r)},"vec4<bool>"(e,t,n,r,i,a,o){o.uniform4iv(i[e].location,r)}},Mc=[(e,t,n,r,i,a,o)=>{o.uniformMatrix3fv(i[e].location,!1,a[e].toArray(!0))},(e,t,n,r,i,a,o)=>{n=i[e].value,r=a[e],(n[0]!==r.x||n[1]!==r.y||n[2]!==r.width||n[3]!==r.height)&&(n[0]=r.x,n[1]=r.y,n[2]=r.width,n[3]=r.height,o.uniform4f(i[e].location,r.x,r.y,r.width,r.height))},(e,t,n,r,i,a,o)=>{n=i[e].value,r=a[e],(n[0]!==r.x||n[1]!==r.y)&&(n[0]=r.x,n[1]=r.y,o.uniform2f(i[e].location,r.x,r.y))},(e,t,n,r,i,a,o)=>{n=i[e].value,r=a[e],(n[0]!==r.red||n[1]!==r.green||n[2]!==r.blue||n[3]!==r.alpha)&&(n[0]=r.red,n[1]=r.green,n[2]=r.blue,n[3]=r.alpha,o.uniform4f(i[e].location,r.red,r.green,r.blue,r.alpha))},(e,t,n,r,i,a,o)=>{n=i[e].value,r=a[e],(n[0]!==r.red||n[1]!==r.green||n[2]!==r.blue)&&(n[0]=r.red,n[1]=r.green,n[2]=r.blue,o.uniform3f(i[e].location,r.red,r.green,r.blue))}];function Nc(e,t){let n={};for(let r in e.uniformStructures){if(!t[r])continue;let i=e.uniformStructures[r],a=!1;for(let e=0;e<at.length;e++){let t=at[e];if(i.type===t.type&&t.test(i)){n[r]=Mc[e],a=!0;break}}a||(n[r]=(i.size===1?Ac:jc)[i.type])}return(e,t,r)=>{let i=r.gl;for(let r in n){let a=t[r],o=e[r],s=e[r].value;n[r](r,o,s,a,e,t,i)}}}function Pc(){Object.assign(ot.prototype,{_unsafeEvalCheck(){}}),Object.assign(ct.prototype,{_systemCheck(){}}),Object.assign(Qo.prototype,{_generateUniformsSync:Nc}),Object.assign(Do.prototype,{_generateUboSync:Dc}),Object.assign(Ks.prototype,{_generateUboSync:Oc}),Object.assign(Jo.prototype,{_generateShaderSync:Sc})}Pc();var Fc={extension:{type:U.Environment,name:`browser`,priority:-1},test:()=>!0,load:async()=>{await D(()=>import(`./browserAll-B258yZD2.js`),__vite__mapDeps([0,1,2,3]))}},Ic={extension:{type:U.Environment,name:`webworker`,priority:0},test:()=>typeof self<`u`&&self.WorkerGlobalScope!==void 0,load:async()=>{await D(()=>import(`./webworkerAll-B5q9qlVj.js`),__vite__mapDeps([4,3,1,2]))}},Lc;function Rc(e){return Lc===void 0&&(Lc=(()=>{let t={stencil:!0,failIfMajorPerformanceCaveat:e??ot.defaultOptions.failIfMajorPerformanceCaveat};try{if(!z.get().getWebGLRenderingContext())return!1;let e=z.get().createCanvas().getContext(`webgl`,t),n=!!e?.getContextAttributes()?.stencil;if(e){let t=e.getExtension(`WEBGL_lose_context`);t&&t.loseContext()}return e=null,n}catch{return!1}})()),Lc}var zc;async function Bc(e={}){return zc===void 0&&(zc=await(async()=>{let t=z.get().getNavigator().gpu;if(!t)return!1;try{return await(await t.requestAdapter(e)).requestDevice(),!0}catch{return!1}})()),zc}var Vc=[`webgl`,`webgpu`,`canvas`];async function Hc(e){let t=[];e.preference?(t.push(e.preference),Vc.forEach(n=>{n!==e.preference&&t.push(n)})):t=Vc.slice();let n,r={};for(let i=0;i<t.length;i++){let a=t[i];if(a===`webgpu`&&await Bc()){let{WebGPURenderer:t}=await D(async()=>{let{WebGPURenderer:e}=await Promise.resolve().then(()=>mc);return{WebGPURenderer:e}},void 0);n=t,r={...e,...e.webgpu};break}else if(a===`webgl`&&Rc(e.failIfMajorPerformanceCaveat??ot.defaultOptions.failIfMajorPerformanceCaveat)){let{WebGLRenderer:t}=await D(async()=>{let{WebGLRenderer:e}=await Promise.resolve().then(()=>ws);return{WebGLRenderer:e}},void 0);n=t,r={...e,...e.webgl};break}else if(a===`canvas`)throw r={...e},Error(`CanvasRenderer is not yet implemented`)}if(delete r.webgpu,delete r.webgl,!n)throw Error(`No available renderer for the current environment`);let i=new n;return await i.init(r),i}var Uc=class e{constructor(...e){this.stage=new ne,e[0]!==void 0&&W(V,`Application constructor options are deprecated, please use Application.init() instead.`)}async init(t){t={...t},this.renderer=await Hc(t),e._plugins.forEach(e=>{e.init.call(this,t)})}render(){this.renderer.render({container:this.stage})}get canvas(){return this.renderer.canvas}get view(){return W(V,`Application.view is deprecated, please use Application.canvas instead.`),this.renderer.canvas}get screen(){return this.renderer.screen}destroy(t=!1,n=!1){let r=e._plugins.slice(0);r.reverse(),r.forEach(e=>{e.destroy.call(this)}),this.stage.destroy(n),this.stage=null,this.renderer.destroy(t),this.renderer=null}};Uc._plugins=[];var Wc=Uc;Pe.handleByList(U.Application,Wc._plugins),Pe.add(Qe);var Gc=class extends F{constructor(e,t){let{text:n,resolution:r,style:i,anchor:a,width:o,height:s,roundPixels:c,...l}=e;super({...l}),this.batched=!0,this._resolution=null,this._autoResolution=!0,this._didTextUpdate=!0,this._styleClass=t,this.text=n??``,this.style=i,this.resolution=r??null,this.allowChildren=!1,this._anchor=new Re({_onUpdate:()=>{this.onViewUpdate()}}),a&&(this.anchor=a),this.roundPixels=c??!1,o!==void 0&&(this.width=o),s!==void 0&&(this.height=s)}get anchor(){return this._anchor}set anchor(e){typeof e==`number`?this._anchor.set(e):this._anchor.copyFrom(e)}set text(e){e=e.toString(),this._text!==e&&(this._text=e,this.onViewUpdate())}get text(){return this._text}set resolution(e){this._autoResolution=e===null,this._resolution=e,this.onViewUpdate()}get resolution(){return this._resolution}get style(){return this._style}set style(e){e||={},this._style?.off(`update`,this.onViewUpdate,this),e instanceof this._styleClass?this._style=e:this._style=new this._styleClass(e),this._style.on(`update`,this.onViewUpdate,this),this.onViewUpdate()}get bounds(){return this._boundsDirty&&=(this._updateBounds(),!1),this._bounds}get width(){return Math.abs(this.scale.x)*this.bounds.width}set width(e){this._setWidth(e,this.bounds.width)}get height(){return Math.abs(this.scale.y)*this.bounds.height}set height(e){this._setHeight(e,this.bounds.height)}getSize(e){return e||={},e.width=Math.abs(this.scale.x)*this.bounds.width,e.height=Math.abs(this.scale.y)*this.bounds.height,e}setSize(e,t){typeof e==`object`?(t=e.height??e.width,e=e.width):t??=e,e!==void 0&&this._setWidth(e,this.bounds.width),t!==void 0&&this._setHeight(t,this.bounds.height)}addBounds(e){let t=this.bounds;e.addFrame(t.minX,t.minY,t.maxX,t.maxY)}containsPoint(e){let t=this.bounds.width,n=this.bounds.height,r=-t*this.anchor.x,i=0;return e.x>=r&&e.x<=r+t&&(i=-n*this.anchor.y,e.y>=i&&e.y<=i+n)}onViewUpdate(){if(this._didViewChangeTick++,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0,this._didTextUpdate=!0;let e=this.renderGroup||this.parentRenderGroup;e&&e.onChildViewUpdate(this)}_getKey(){return`${this.text}:${this._style.styleKey}:${this._resolution}`}destroy(e=!1){super.destroy(e),this.owner=null,this._bounds=null,this._anchor=null,(typeof e==`boolean`?e:e?.style)&&this._style.destroy(e),this._style=null,this._text=null}};function Kc(e,t){let n=e[0]??{};return(typeof n==`string`||e[1])&&(W(V,`use new ${t}({ text: "hi!", style }) instead`),n={text:n,style:e[1]}),n}var qc=class extends Gc{constructor(...e){let t=Kc(e,`Text`);super(t,Mi),this.renderPipeId=`text`}_updateBounds(){let e=this._bounds,t=this._anchor,{width:n,height:r}=Bi.measureText(this._text,this._style);e.minX=-t._x*n,e.maxX=e.minX+n,e.minY=-t._y*r,e.maxY=e.minY+r}};Pe.add(Fc,Ic);var Jc=8,Yc=d.maxContentItems,Xc=d.maxLogicalCanvasWidth,Zc=d.maxLogicalCanvasHeight,Qc=d.maxExpandedRoomWidth,$c=d.maxExpandedRoomHeight,el=d.maxLayoutRows;function tl(e){let t={fixedHeaderChromeWidth:X(e.style?.fixedHeaderChromeWidth,d.roomHeaderChromeWidth,Qc),fixedHeaderChromeHeight:X(e.style?.fixedHeaderChromeHeight,d.roomHeaderChromeHeight,$c),overflowMarkerMinWidth:X(e.style?.overflowMarkerMinWidth,d.overflowMarkerMinWidth,Qc),overflowMarkerMinHeight:X(e.style?.overflowMarkerMinHeight,d.overflowMarkerMinHeight,$c),overflowMarkerGap:X(e.style?.overflowMarkerGap,d.overflowMarkerGap,$c),roomSafeInset:X(e.style?.roomSafeInset,d.roomHeaderSafeInset,Qc)},n=hl(t.fixedHeaderChromeWidth,t.roomSafeInset),r=Math.min(Qc,Math.max(d.minRoomWidth,n,t.overflowMarkerMinWidth)),i=Math.min($c,Math.max(d.minRoomHeight,t.fixedHeaderChromeHeight+t.overflowMarkerMinHeight+t.overflowMarkerGap)),a=X(e.maximumExpandedRoomWidth,Qc,Qc),o=X(e.maximumExpandedCanvasWidth,Xc,Xc),s=X(e.maximumExpandedRoomHeight,$c,$c),c=X(e.maximumExpandedCanvasHeight,Zc,Zc),l=X(e.minimumLogicalCanvasWidth,d.minOfficeWidth,Xc),u=X(e.minimumLogicalCanvasHeight,d.ceoBandHeight+d.hallwayHeight,Zc),f=Math.min(Xc,Math.max(l,r,X(e.maximumExpandedCanvasWidth,Xc,Xc))),p=Math.min(Zc,Math.max(u,i,X(e.maximumExpandedCanvasHeight,Zc,Zc))),m=Math.min(Qc,f,Math.max(r,X(e.maximumExpandedRoomWidth,Qc,Qc))),h=Math.min($c,p,Math.max(i,X(e.maximumExpandedRoomHeight,$c,$c))),g=Dl(e.maxContentItems,Yc),_=Math.max(1,Math.min(el,X(e.maxLayoutRows,el,el))),v=e.rooms.map((e,t)=>bl(e,t,m,h)).sort(xl).slice(0,d.maxRooms);return{availableViewportWidth:X(e.availableViewportWidth,0,f),availableViewportHeight:X(e.availableViewportHeight,0,p),minimumLogicalCanvasWidth:l,minimumLogicalCanvasHeight:u,minimumRoomWidth:r,minimumRoomHeight:i,maximumExpandedCanvasWidth:f,maximumExpandedCanvasHeight:p,maximumExpandedRoomWidth:m,maximumExpandedRoomHeight:h,maxContentItems:g,maxLayoutRows:_,overflowMode:`logical-scroll`,fontKey:e.fontKey??`Inter, ui-sans-serif, system-ui, sans-serif`,fontReady:e.fontReady!==!1,titleMode:e.titleMode===`compact`?`compact`:`expand`,roomAlignment:e.roomAlignment===`center`||e.roomAlignment===`right`?e.roomAlignment:`left`,ceoReceptionCount:X(e.ceoReceptionCount,0,d.maxReceptionDesks),ceoContentItems:(e.ceoContentItems??[]).map((e,t)=>Cl(e,t)),ceoContentItemCount:e.ceoContentItems?.length??0,styleCapacityInvalid:n>Qc||a<n||o<n||a<r||o<r||s<i||c<i,style:t,rooms:v}}function nl(e){let t=tl(e),n=Tl(wl(t)),r=Sl(t),i=t.minimumRoomWidth>t.maximumExpandedRoomWidth||t.styleCapacityInvalid||t.style.fixedHeaderChromeHeight+t.style.overflowMarkerMinHeight+t.style.overflowMarkerGap>t.maximumExpandedRoomHeight,a=Math.min(t.maximumExpandedCanvasWidth,Math.max(t.minimumLogicalCanvasWidth,t.availableViewportWidth,...t.rooms.map(e=>Math.max(rl(e,t).width,e.headerMinWidth??0,e.headerMinTitleBoxWidth??0,e.contentMinWidth??0,El(e.contentItems,e.flow,t.maxContentItems)+d.roomPadding*2,e.preferredWidth??0)+24),El(t.ceoContentItems,`wrap-row`,t.maxContentItems)+d.ceoEdgePadding*2)),o=t.minimumRoomWidth>t.maximumExpandedRoomWidth||t.minimumRoomHeight>t.maximumExpandedRoomHeight;if(i||o){let e=p(t.minimumLogicalCanvasWidth,[],t.roomAlignment,d.ceoBandHeight,0,t.maximumExpandedCanvasHeight),i=pl({...e,totalHeight:Math.min(t.maximumExpandedCanvasHeight,e.totalHeight),fallbackMessage:`Office layout unavailable`},[]);return i.ceoOverflowMarkerRect=gl(fl(i,i.ceoContentRect,-1),t),{inputDigest:n,normalizedInput:r,layout:{...i,overflowMarker:{label:`Office layout unavailable`,required:!0}},roomHeaders:[],rows:[],contentItems:[],omissions:[],omissionSummary:vl(),normalizationErrors:[`invalid-style-capacity`],fallbackMessage:`Office layout unavailable`,accessibleOverflow:{label:`Office layout unavailable`,required:!0},resolvedCanvasWidth:i.officeWidth,resolvedCanvasHeight:i.totalHeight}}let s=E(a,t.ceoReceptionCount,Math.min(t.maximumExpandedCanvasHeight,t.maximumExpandedRoomHeight)),c=dl(t.ceoContentItems,s.ceoContentWidth,t,s.ceoBandHeight),l=p(a,t.rooms.map(e=>({sourceIndex:e.sourceIndex,deskCount:e.deskCount,standingCount:e.standingCount,headerMinWidth:rl(e,t).width,headerMinTitleBoxWidth:e.headerMinTitleBoxWidth,headerMinHeight:e.headerMinHeight,contentMinWidth:Math.max(e.contentMinWidth??0,El(e.contentItems,e.flow,t.maxContentItems)+d.roomPadding*2),preferredWidth:Math.min(t.maximumExpandedRoomWidth,Math.max(e.preferredWidth??0,t.minimumRoomWidth)),preferredHeight:Math.min(t.maximumExpandedRoomHeight,Math.max(e.preferredHeight??0,t.minimumRoomHeight)),maximumWidth:t.maximumExpandedRoomWidth,maximumHeight:t.maximumExpandedRoomHeight})),t.roomAlignment,c,t.ceoReceptionCount,Math.min(t.maximumExpandedCanvasHeight,t.maximumExpandedRoomHeight)),u=_l(),f=l.rooms.filter(e=>e.row<t.maxLayoutRows&&e.y+e.height<=t.maximumExpandedCanvasHeight);t.rooms.forEach(e=>{f.some(t=>t.index===e.sourceIndex)||u.add({reason:`canvas-capacity-exhausted`,importance:`required`,id:e.id})});let m=pl({...l,officeWidth:a,totalHeight:Math.min(t.maximumExpandedCanvasHeight,Math.max(l.totalHeight,t.minimumLogicalCanvasHeight)),rooms:f},t.rooms.reduce((e,n)=>(e[n.sourceIndex]=rl(n,t),e),[])),h=[];t.rooms.forEach(e=>{let n=m.rooms.find(({index:t})=>t===e.sourceIndex);if(!n)return;let r=cl(e.contentItems??[],t.maxContentItems);r.omitted.forEach(e=>u.add({reason:`content-item-count-cap`,importance:e.importance,id:e.id}));let i=ll(n,e,r.selected,t);i.items.forEach(e=>h.push(e)),i.omissions.forEach(e=>u.add(e)),(i.requiredOverflow||r.omitted.some(({importance:e})=>e===`required`))&&(n.overflowMarkerRect=gl(n,t))});let g=new Set(m.ceoBlocks.receptions.map(({index:e})=>e));for(let e=0;e<t.ceoReceptionCount;e+=1)g.has(e)||u.add({reason:`canvas-capacity-exhausted`,importance:`required`,id:`reception-${e}`});let _={id:`ceo-office`,role:`ceo`,region:`ceo`,order:0,flow:`wrap-row`,spanPolicy:`multi-row`,title:`CEO Office`,hostTitle:`CEO`,deskCount:0,standingCount:0,contentItems:t.ceoContentItems},v=cl(t.ceoContentItems,t.maxContentItems);v.omitted.forEach(e=>u.add({reason:`content-item-count-cap`,importance:e.importance,id:e.id}));let y=ll(fl(m,m.ceoContentRect,-1),_,v.selected,t);y.items.forEach(e=>h.push(e)),y.omissions.forEach(e=>u.add(e)),(y.requiredOverflow||v.omitted.some(({importance:e})=>e===`required`)||g.size<t.ceoReceptionCount)&&(m.ceoOverflowMarkerRect=gl(fl(m,m.ceoContentRect,-1),t));let b=ul(m),x=u.records(),S=u.summary(),C=S.byImportance.required?{label:`Some required Office content is not shown.`,required:!0}:null,w=C?{...m,overflowMarker:C}:m;return{inputDigest:n,normalizedInput:r,layout:w,roomHeaders:m.rooms.map(e=>e.header??null),rows:b,contentItems:h,omissions:x,omissionSummary:S,normalizationErrors:[],fallbackMessage:null,accessibleOverflow:C,resolvedCanvasWidth:w.officeWidth,resolvedCanvasHeight:w.totalHeight}}function rl(e,t){let{workspace:n,host:r}=il(String(e.title??`ROOM`),String(e.hostTitle??`HOST`),t.titleMode),i=e.visualTitle??n,a=e.visualHostTitle??r,o=t.style.fixedHeaderChromeWidth,s=d.roomHeaderActionWidth,c=d.roomHeaderActionGap,l=d.roomHeaderCloseGap,u=Math.max(hl(o,t.style.roomSafeInset),t.maximumExpandedRoomWidth),f=Math.max(o,u-t.style.roomSafeInset*2-2*(s+c+s+l)),p=Math.max(o,e.headerMinTitleBoxWidth??0,o+Ml(i)+Ml(a)),m=hl(p,t.style.roomSafeInset),h=!1;if(p>f){h=!0;let e=Math.max(0,f-o),n=Math.floor(e*.52),r=Math.max(0,e-n);i=jl(i,n),a=jl(a,r),p=Math.min(f,o+Ml(i)+Ml(a)),m=hl(p,t.style.roomSafeInset)}return m=Math.max(m,e.headerMinWidth??0),{workspace:i,host:a,width:Math.min(u,Math.ceil(m)),titleBoxX:0,titleBoxWidth:Math.max(o,Math.ceil(p)),renameX:0,closeX:0,renameWidth:s,closeWidth:s,actionWidth:s,actionGap:c,closeGap:l,height:Math.max(d.roomHeaderHeight,t.style.fixedHeaderChromeHeight),emergencyEllipsis:h}}function il(e,t,n){return{workspace:n===`compact`?Al(e,18):e,host:n===`compact`?Al(t,16):t}}var al=class{revision=0;currentDigest=null;currentLayout=null;renderedRevision=0;publish(e,t){if(t.inputDigest!==e.canonicalDigest)throw Error(`Office layout geometry does not match its input generation.`);if(this.currentLayout&&this.currentDigest===e.canonicalDigest)return this.currentLayout;this.revision+=1,this.currentDigest=e.canonicalDigest;let n={...t.layout,generationId:e.canonicalDigest,layoutRevision:this.revision,inputDigest:e.canonicalDigest,normalizedInput:t.normalizedInput,roomHeaders:t.roomHeaders,rows:t.rows,contentItems:t.contentItems,omissions:t.omissions,omissionSummary:t.omissionSummary,normalizationErrors:t.normalizationErrors,fallbackMessage:t.fallbackMessage,accessibleOverflow:t.accessibleOverflow,resolvedCanvasWidth:t.resolvedCanvasWidth,resolvedCanvasHeight:t.resolvedCanvasHeight};return this.currentLayout=sl(ol(n)),this.currentLayout}ackCanvasRendered(e){return!this.currentLayout||e!==this.currentLayout.layoutRevision?!1:(this.renderedRevision=e,!0)}get canvasRenderedRevision(){return this.renderedRevision}isCanvasReady(e){return this.currentLayout?.layoutRevision===e&&this.renderedRevision===e}};function ol(e){if(Array.isArray(e))return e.map(e=>ol(e));if(e&&typeof e==`object`){let t={};return Object.entries(e).forEach(([e,n])=>{t[e]=ol(n)}),t}return e}function sl(e){return e&&typeof e==`object`&&!Object.isFrozen(e)&&(Object.values(e).forEach(e=>sl(e)),Object.freeze(e)),e}function cl(e,t){let n=[...e.map((e,t)=>Cl(e,t))].sort((e,t)=>{let n=Ol(kl(e.importance)?e.importance:`optional`)-Ol(kl(t.importance)?t.importance:`optional`);return n===0?e.importance===`required`&&t.importance===`required`?e.order-t.order||e.id.localeCompare(t.id):t.priority-e.priority||e.order-t.order||e.id.localeCompare(t.id):n});return{selected:n.slice(0,t),omitted:n.slice(t)}}function ll(e,t,n,r){let i=[],a=[],o=e.contentSafeRect.x,s=e.contentSafeRect.y,c=0,l=0,u=0,d=!1,f=t.flow??`wrap-row`;return n.forEach(n=>{let p=kl(n.importance)?n.importance:`optional`;if(!n.valid){a.push({reason:`invalid-content-descriptor`,importance:p,id:n.id}),p===`required`&&(d=!0);return}if(n.minWidth>r.maximumExpandedRoomWidth||n.minHeight>r.maximumExpandedRoomHeight||n.minWidth>e.contentSafeRect.width||n.minHeight>e.contentSafeRect.height){let e=p===`required`?`required-minimum-exceeds-room-cap`:`non-required-minimum-exceeds-room-cap`;a.push({reason:e,importance:p,id:n.id}),p===`required`&&(d=!0);return}let m=e.contentSafeRect.width,h=Math.max(n.minWidth,Math.min(n.preferredWidth,m)),g=Math.max(0,e.contentSafeRect.x+m-o),_=t.spanPolicy===`multi-row`?m:t.spanPolicy===`remaining`&&u>0?Math.max(n.minWidth,Math.min(h,g)):h,v=Math.max(n.minHeight,Math.min(n.preferredHeight,r.maximumExpandedRoomHeight)),y=f===`column`?u>0:f===`wrap-row`||f===`grid`?u>0&&o+_>e.contentSafeRect.x+m:!1,b=t.spanPolicy===`multi-row`&&u>0;if((y||b)&&(l+=1,o=e.contentSafeRect.x,s+=c+8,c=0,u=0),f===`row`&&u>0&&o+_>e.contentSafeRect.x+m){a.push({reason:`canvas-capacity-exhausted`,importance:p,id:n.id}),p===`required`&&(d=!0);return}if(l>=r.maxLayoutRows||s+v>e.contentSafeRect.y+e.contentSafeRect.height){a.push({reason:`canvas-capacity-exhausted`,importance:p,id:n.id}),p===`required`&&(d=!0);return}let x={x:o,y:s,width:_,height:v},S={x:Math.max(e.clipRect.x,x.x),y:Math.max(e.clipRect.y,x.y),width:Math.min(x.width,e.clipRect.x+e.clipRect.width-x.x),height:Math.min(x.height,e.clipRect.y+e.clipRect.height-x.y)};i.push({...x,roomIndex:e.index,id:n.id,kind:n.kind,importance:p,clipRect:S,inkBounds:S}),o+=_+8,c=Math.max(c,v),u+=1}),{items:i,omissions:a,requiredOverflow:d}}function ul(e){let t=new Map;return e.rooms.forEach(e=>{let n=`${e.row}`,r=t.get(n),i=r?yl(r.rect,e.outerRect):e.outerRect;t.set(n,{roomIndex:e.index,index:e.row,rect:i})}),[...t.values()].sort((e,t)=>e.index-t.index)}function dl(e,t,n,r){let i=cl(e,n.maxContentItems).selected,a=Math.max(1,t-16),o=0,s=0,c=0;return i.forEach(e=>{if(!e.valid||e.minWidth>a||e.minHeight>n.maximumExpandedRoomHeight)return;let t=Math.min(e.preferredWidth,a),r=Math.min(e.preferredHeight,n.maximumExpandedRoomHeight);o>0&&o+t>a&&(s+=c+8,o=0,c=0),o+=t+8,c=Math.max(c,r)}),s+=c,Math.min(n.maximumExpandedCanvasHeight,n.maximumExpandedRoomHeight,Math.max(r,s+56))}function fl(e,t,n){return{index:n,column:0,row:0,x:e.ceoRect.x,y:e.ceoRect.y,width:e.ceoRect.width,height:e.ceoRect.height,deskColumns:0,standingColumns:0,deskRows:0,standingRows:0,outerRect:e.ceoRect,wallRect:e.ceoRect,headerRect:e.ceoRect,contentSafeRect:t,clipRect:e.ceoRect,inkBounds:e.ceoRect,shadowAllowance:0,selectionStrokeAllowance:0}}function pl(e,t){let n=e.rooms.map(e=>({...e,header:t[e.index]?ml(e.headerRect,t[e.index]):e.header}));return{...e,rooms:n}}function ml(e,t){let n=Math.max(0,(e.width-t.titleBoxWidth)/2);return{...t,titleBoxX:n,renameX:n+t.titleBoxWidth+t.actionGap,closeX:Math.max(0,e.width-t.closeWidth)}}function hl(e,t=d.roomHeaderSafeInset){return Math.ceil(Math.max(0,e)+2*(d.roomHeaderActionWidth+d.roomHeaderActionGap+d.roomHeaderActionWidth+d.roomHeaderCloseGap)+Math.max(0,t)*2)}function gl(e,t){let n=Math.min(t.style.overflowMarkerMinWidth,e.contentSafeRect.width),r=Math.min(t.style.overflowMarkerMinHeight,e.contentSafeRect.height);return{x:e.contentSafeRect.x,y:Math.max(e.contentSafeRect.y,e.contentSafeRect.y+e.contentSafeRect.height-r),width:n,height:r}}function _l(){let e=[],t={},n={},r={},i={},a=0;return{add({reason:o,importance:s,id:c}){a+=1,t[o]=(t[o]??0)+1,n[s]=(n[s]??0)+1,c&&(r[o]?.length??0)<Jc&&(r[o]=[...r[o]??[],c]),c&&(i[s]?.length??0)<Jc&&(i[s]=[...i[s]??[],c]),e.filter(e=>e.reason===o&&e.importance===s).length<Jc&&e.push({reason:o,importance:s,id:c})},records(){return e.slice()},summary(){return{total:a,byReason:t,byImportance:n,samples:r,samplesByImportance:i}}}}function vl(){return{total:0,byReason:{},byImportance:{},samples:{},samplesByImportance:{}}}function yl(e,t){let n=Math.min(e.x,t.x),r=Math.min(e.y,t.y),i=Math.max(e.x+e.width,t.x+t.width),a=Math.max(e.y+e.height,t.y+t.height);return{x:n,y:r,width:i-n,height:a-r}}function X(e,t,n){return Math.max(0,Math.min(n,Math.floor(typeof e==`number`&&Number.isFinite(e)?e:t)))}function bl(e,t,n,r){let i=e.flow===`row`||e.flow===`column`||e.flow===`grid`||e.flow===`wrap-row`?e.flow:void 0,a=e.spanPolicy===`single`||e.spanPolicy===`multi-row`||e.spanPolicy===`remaining`?e.spanPolicy:void 0,o=e.region===`ceo`||e.region===`agent-bar`||e.region===`work`?e.region:void 0;return{id:typeof e.id==`string`&&e.id.trim().length>0?e.id:`room-${t}`,role:typeof e.role==`string`?e.role:void 0,precedence:X(e.precedence,0,d.maxRooms),region:o,order:X(e.order,t,d.maxRooms),flow:i,spanPolicy:a,title:String(e.title??`ROOM`),hostTitle:String(e.hostTitle??`HOST`),visualTitle:typeof e.visualTitle==`string`?e.visualTitle:void 0,visualHostTitle:typeof e.visualHostTitle==`string`?e.visualHostTitle:void 0,actions:{rename:!!e.actions?.rename,close:!!e.actions?.close,createSeat:!!e.actions?.createSeat},deskCount:X(e.deskCount,0,d.desksPerRoom),standingCount:X(e.standingCount,0,d.standingColumns*2),headerMinWidth:X(e.headerMinWidth,0,n),headerMinTitleBoxWidth:X(e.headerMinTitleBoxWidth,0,n),headerMinHeight:X(e.headerMinHeight,d.roomHeaderHeight,r),contentMinWidth:X(e.contentMinWidth,0,n),preferredWidth:X(e.preferredWidth,0,n),preferredHeight:X(e.preferredHeight,0,r),contentItems:(e.contentItems??[]).map((e,t)=>Cl(e,t)),contentItemCount:e.contentItems?.length??0,sourceIndex:t}}function xl(e,t){let n=e=>e===`ceo`?0:e===`agent-bar`?1:e===`work`?2:3;return n(e.region)-n(t.region)||(e.precedence??0)-(t.precedence??0)||(e.order??0)-(t.order??0)||e.id.localeCompare(t.id)||e.sourceIndex-t.sourceIndex}function Sl(e){return{...e,ceoContentItems:cl(e.ceoContentItems,e.maxContentItems).selected,rooms:e.rooms.map(t=>({...t,contentItems:cl(t.contentItems,e.maxContentItems).selected}))}}function Cl(e,t){let n=e.valid!==!1&&typeof e.id==`string`&&e.id.trim().length>0&&typeof e.kind==`string`&&e.kind.trim().length>0&&kl(e.importance)&&typeof e.order==`number`&&Number.isFinite(e.order)&&e.order>=0&&typeof e.minWidth==`number`&&Number.isFinite(e.minWidth)&&e.minWidth>=0&&typeof e.minHeight==`number`&&Number.isFinite(e.minHeight)&&e.minHeight>=0,r=X(e.minWidth,0,Qc),i=X(e.minHeight,0,$c);return{id:typeof e.id==`string`&&e.id.trim().length>0?e.id:`item-${t}`,kind:typeof e.kind==`string`&&e.kind.trim().length>0?e.kind:`unknown`,importance:kl(e.importance)?e.importance:`optional`,order:X(e.order,t,el),priority:X(e.priority,0,el),minWidth:r,minHeight:i,preferredWidth:X(e.preferredWidth,r,Qc),preferredHeight:X(e.preferredHeight,i,$c),valid:n}}function wl(e){if(e==null)return`null`;if(typeof e==`string`||typeof e==`number`||typeof e==`boolean`)return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(e=>wl(e)).join(`,`)}]`;if(typeof e==`object`){let t=e;return`{${Object.keys(t).sort().map(e=>`${JSON.stringify(e)}:${wl(t[e])}`).join(`,`)}}`}return`null`}function Tl(e){let t=14695981039346656037n;for(let n=0;n<e.length;n+=1)t^=BigInt(e.charCodeAt(n)),t=BigInt.asUintN(64,t*1099511628211n);return`office-v1-${t.toString(16).padStart(16,`0`)}`}function El(e,t,n){let{selected:r}=cl(e,n),i=r.filter(e=>e.valid);if(i.length===0)return 0;let a=i.map(e=>e.minWidth);return t===`row`?a.reduce((e,t)=>e+t,0)+Math.max(0,a.length-1)*8:Math.max(...a)}function Dl(e,t){return Math.max(1,Math.min(Yc,typeof e==`number`&&Number.isFinite(e)?Math.floor(e):t))}function Ol(e){return e===`required`?0:e===`preferred`?1:2}function kl(e){return e===`required`||e===`preferred`||e===`optional`}function Al(e,t){return jl(e,Ml(e.slice(0,t)),t)}function jl(e,t,n=256){let r=[...e];if(t<=0)return``;if(r.length===0||Ml(e)<=t)return e;if(Ml(`…`)>t)return``;let i=Math.max(1,Math.min(r.length,n));for(;i>1&&Ml(`${r.slice(0,i).join(``)}…`)>t;)--i;return Ml(`${r[0]}…`)>t?`…`:`${r.slice(0,i).join(``)}…`}function Ml(e){return[...e.toUpperCase()].reduce((e,t)=>{let n=t.codePointAt(0)??0;return e+(n>11904||n>=126976?13:t===` `?4:8.1)},0)}function Nl({layout:e,projection:t,selectedKey:n,completionSeenKeys:r=new Set,observability:i,visibleRoomIndices:a}){return JSON.stringify({selectedKey:n,completionSeenKeys:[...r].sort(),layout:{officeWidth:e.officeWidth,totalHeight:e.totalHeight,layoutRevision:e.layoutRevision,inputDigest:e.inputDigest??null,rooms:a.map(t=>e.rooms.find(({index:e})=>e===t)??null)},hosts:t.hosts,rooms:a.map(e=>t.rooms[e]??null),receptions:t.receptions,barAgents:t.barAgents,coverage:t.coverage,observability:i?{health:i.health,observedAt:i.observedAt,windowSeconds:i.windowSeconds,models:i.models,totalCostUsd:i.totalCostUsd,totalUsage:i.totalUsage}:null})}var Pl=Object.freeze({children:!0,context:!0,style:!0});function Fl(e){for(let t of e.removeChildren())t.destroy(Pl)}var Il=Array.from({length:12},(e,t)=>`/world/characters/${t+1}-D-1.png`),Ll=13,Rl=new WeakMap,zl=new WeakMap,Bl=Object.freeze([{floorA:792096,floorB:659996,wall:1978448,accent:4891608},{floorA:1182752,floorB:1051166,wall:3416410,accent:10120145},{floorA:1577996,floorB:1446410,wall:4601122,accent:14062912},{floorA:793112,floorB:661012,wall:2117693,accent:5355127},{floorA:1707024,floorB:1575438,wall:5317419,accent:13917552},{floorA:1576972,floorB:1445386,wall:4730146,accent:13596996}]),Vl=Object.freeze({working:{label:`WORKING`,color:6805184},idle:{label:`IDLE`,color:9280174},blocked:{label:`NEEDS INPUT`,color:15501209},done:{label:`DONE`,color:15779960},unknown:{label:`UNKNOWN`,color:12753629}}),Hl=4;async function Ul(e,t,n,r,i,a,o,s,c,l,u,f,p,m,h){if(O(`renderer:create-start`,{rooms:t.rooms.length,agents:t.roster.length,desks:t.deskRoster.length}),window.__HERDR_WORLD_FORCE_RENDERER_FAILURE__)throw Error(`renderer unavailable`);let g=Pu();g.mounts+=1,g.activeApplications+=1,g.activeTickers+=1,g.ready=!1;let _=new Wc,v=!1,y=t,b=n,x=r,S=i,C=m,w=h,T=new al,E=null,D=0,k=null,A={width:0,height:0},j=null,M=0,N=0,P=Du(),F=[],L=e.closest(`.world-stage-scroll`),ee=window.matchMedia(`(prefers-reduced-motion: reduce)`),te=ee.matches;try{await _.init({width:d.minOfficeWidth,height:640,backgroundAlpha:0,antialias:!0,autoDensity:!0,resolution:Math.min(2,window.devicePixelRatio||1),roundPixels:!0,preference:`webgl`})}catch(e){throw g.activeApplications=Math.max(0,g.activeApplications-1),g.activeTickers=Math.max(0,g.activeTickers-1),e}if(v)throw _.destroy(!0,Pl),Error(`renderer disposed`);O(`renderer:pixi-ready`);let ne=_.canvas;e.replaceChildren(ne),ne.setAttribute(`aria-hidden`,`true`),ne.setAttribute(`data-office-canvas`,`true`),ne.style.imageRendering=`auto`,g.canvases=document.querySelectorAll(`canvas[data-office-canvas='true']`).length,g.lastError=null;let re=await Promise.all(Il.map(e=>Fu(e).catch(()=>R.EMPTY)));if(O(`renderer:textures-ready`,{textures:re.filter(e=>e!==R.EMPTY).length}),v)throw _.destroy(!0,Pl),Iu(re),g.destroys+=1,g.activeApplications=Math.max(0,g.activeApplications-1),g.activeTickers=Math.max(0,g.activeTickers-1),Error(`renderer disposed`);let ie=e=>{v||a(e)},ae=e=>{v||o(e)},oe=e=>{v||s(e)},se=e=>{let t=_.renderer.events.rootBoundary.hitTest(e.offsetX,e.offsetY);for(;t&&!t.label;)t=t.parent;if(!t?.label){u(null);return}u({key:t.label,clientX:e.clientX,clientY:e.clientY})},ce=()=>u(null);_.canvas.addEventListener(`pointermove`,se),_.canvas.addEventListener(`pointerleave`,ce);let le=e=>{let t=zl.get(ie);if(!t)return;let n=Math.hypot(e.offsetX-t.x,e.offsetY-t.y)<=12,r=window.performance.now()-t.at<=1e3;Rl.delete(ie),zl.delete(ie),n&&r&&t.activate(t.key)};_.canvas.addEventListener(`dblclick`,le),g.activeListeners+=3;let z=e=>{if(v)return;let t=L?.scrollTop??0,n=Math.min(e.totalHeight,Math.max(1,L?.clientHeight??e.totalHeight)),r=(Math.max(d.minRoomHeight,...e.rooms.map(({height:e})=>e))+Math.max(d.roomGap,d.roomRowGap))*Hl,i=e.rooms.filter(e=>e.y+e.height>=t-r&&e.y<=t+n+r),a=Nl({layout:e,projection:y,selectedKey:b,completionSeenKeys:x,observability:S,visibleRoomIndices:i.map(({index:e})=>e)});if(a===j){g.sceneSkips+=1;return}j=a,g.sceneRenders+=1,F.splice(0),Fl(_.stage),ql(_.stage,e),Jl(_.stage,e,y,S,b,re,F,ie,ae),eu(_.stage,e),i.forEach(e=>{let t=y.rooms[e.index];t&&su(_.stage,t,e,y,b,x,re,F,ie,ae,oe,c,l)}),tu(_.stage,e),g.ready||O(`renderer:scene-ready`,{rooms:e.rooms.length,officeWidth:e.officeWidth}),g.ready=!0,g.reducedMotion=te,g.animation={characters:F.filter(({kind:e})=>e===`character`).length,monitors:F.filter(({kind:e})=>e===`monitor`).length,statuses:F.filter(({kind:e})=>e===`status`).length},g.completionMarkers=y.rooms.reduce((e,t)=>e+t.desks.reduce((e,t)=>e+t.completionAgentKeys.filter(e=>!x.has(e)).length,0),0)},ue=()=>{_.stage.position.y=-(L?.scrollTop??0),E&&z(E)};L&&(L.addEventListener(`scroll`,ue,{passive:!0}),g.activeListeners+=1);let de=e=>{N=e,_.ticker.addOnce(()=>{v||N!==e||E?.layoutRevision!==e||T.ackCanvasRendered(e)&&p(e)},void 0,I.UTILITY)},fe=(t=e.clientWidth)=>{if(v)return;let n=L?.clientWidth??e.clientWidth,r=Math.floor(n||t||0),i=y.rooms.map(e=>{let t=y.hosts.find(({key:t})=>t===e.hostKey),n=e.accessibleLabel??e.displayLabel,r=t?.accessibleLabel??t?.displayLabel??`host`,i=Ou(n,r,w);return{id:e.key,role:`work`,region:`work`,title:n,hostTitle:r,visualTitle:i.workspace,visualHostTitle:i.host,headerMinTitleBoxWidth:i.titleBoxWidth,headerMinWidth:i.roomWidth,deskCount:e.desks.length+(c(e.key)&&e.desks.length<d.desksPerRoom?1:0),standingCount:e.roomAgents.filter(({placement:e})=>e===`standing`).length,actions:{rename:!0,close:!0,createSeat:c(e.key)}}}),a=nl({availableViewportWidth:r,availableViewportHeight:L?.clientHeight??0,titleMode:w,roomAlignment:C,ceoReceptionCount:y.receptions.length,fontKey:`Inter, ui-sans-serif, system-ui, sans-serif`,fontReady:P,rooms:i}),o=T.publish({canonicalDigest:a.inputDigest},a),s=Math.min(o.totalHeight,Math.max(1,L?.clientHeight??o.totalHeight));E=o,g.publishedLayout=o,f(o),D=o.officeWidth,(A.width!==o.officeWidth||A.height!==s)&&(_.renderer.resize(o.officeWidth,s),A={width:o.officeWidth,height:s}),e.style.width=`${o.officeWidth}px`,e.style.height=`${o.totalHeight}px`,_.stage.position.y=-(L?.scrollTop??0),z(o),de(o.layoutRevision),g.layout={officeWidth:o.officeWidth,totalHeight:o.totalHeight,rooms:o.rooms.length,characterHeight:d.characterHeight,ceoBandHeight:o.ceoBandHeight,viewportHeight:s}},B=()=>{if(g.frames+=1,M+=1,!te)for(let e of F){let t=Math.sin(M*.075+e.phase);e.kind===`character`?e.node.y=e.baseY+t*2:e.kind===`monitor`?e.node.alpha=e.baseAlpha+(t+1)*.15:e.node.alpha=.82+(t+1)*.09}};_.ticker.add(B);let pe=document.fonts,me=()=>{v||(P=Du(),j=null,fe(D||e.clientWidth))};pe?.addEventListener(`loadingdone`,me),pe&&(pe.ready.then(me),g.activeListeners+=1);let he=e=>{if(te=e.matches,g.reducedMotion=te,te)for(let e of F)e.kind===`character`?e.node.y=e.baseY:e.node.alpha=e.baseAlpha};ee.addEventListener(`change`,he),g.activeListeners+=1;let V=new ResizeObserver(e=>{let t=Math.max(d.minOfficeWidth,Math.floor(e[0]?.contentRect.width||0));Math.abs(t-D)<=10||(k!==null&&window.clearTimeout(k),k=window.setTimeout(()=>{k=null,fe(t)},80))});V.observe(L??e),g.activeObservers+=1;try{fe()}catch(e){throw V.disconnect(),ee.removeEventListener(`change`,he),pe?.removeEventListener(`loadingdone`,me),L?.removeEventListener(`scroll`,ue),_.canvas.removeEventListener(`pointermove`,se),_.canvas.removeEventListener(`pointerleave`,ce),_.canvas.removeEventListener(`dblclick`,le),Rl.delete(ie),zl.delete(ie),_.ticker.remove(B),_.destroy(!0,Pl),Iu(re),g.activeApplications=Math.max(0,g.activeApplications-1),g.activeTickers=Math.max(0,g.activeTickers-1),g.activeObservers=Math.max(0,g.activeObservers-1),g.activeListeners=Math.max(0,g.activeListeners-(L?6:5)),e}return{update(t,n,r=x,i=S,a=C,o=w){(a!==C||o!==w)&&(C=a,w=o,j=null),y=t,b=n,x=r,S=i,fe(D||e.clientWidth)},getAnchors(e,t){return E?Wl(y,E,e,t):{agent:null,workbench:null}},destroy(){if(v)return;v=!0;let t=e.contains(ne);k!==null&&window.clearTimeout(k),V.disconnect(),ee.removeEventListener(`change`,he),pe?.removeEventListener(`loadingdone`,me),L?.removeEventListener(`scroll`,ue),_.canvas.removeEventListener(`pointermove`,se),_.canvas.removeEventListener(`pointerleave`,ce),_.canvas.removeEventListener(`dblclick`,le),Rl.delete(ie),zl.delete(ie),_.ticker.remove(B),_.destroy(!0,Pl),Iu(re),t&&e.replaceChildren(),e.style.removeProperty(`width`),e.style.removeProperty(`height`),g.destroys+=1,g.activeApplications=Math.max(0,g.activeApplications-1),g.activeTickers=Math.max(0,g.activeTickers-1),g.activeObservers=Math.max(0,g.activeObservers-1),g.activeListeners=Math.max(0,g.activeListeners-(L?6:5)),g.canvases=document.querySelectorAll(`canvas[data-office-canvas='true']`).length,g.ready=!1,g.publishedLayout=null,f(null)}}}function Wl(e,t,n,r){let i=n?e.roster.find(({agent:e})=>e.key===n)??null:null,a=r?e.deskRoster.find(({desk:e})=>e.key===r)?.desk??null:null,o=!i&&n?e.deskRoster.find(({desk:e})=>e.key===n)?.desk??null:null,s=i?.agent.deskKey?e.deskRoster.find(({desk:e})=>e.key===i.agent.deskKey)?.desk??null:null;return{agent:i?Kl(e,t,i.agent.key):null,workbench:Gl(e,t,a??s??o)}}function Gl(e,t,n){if(!n)return null;let r=e.rooms.findIndex(({key:e})=>e===n.roomKey),i=e.rooms[r],a=t.rooms.find(({index:e})=>e===r);if(!i||!a)return null;let o=i.desks.findIndex(({key:e})=>e===n.key);if(o<0)return null;let s=w(a,o);return{x:s.x,y:s.deskY+10}}function Kl(e,t,n){let r=e.roster.find(({agent:e})=>e.key===n);if(!r)return null;let i=r.agent;if(i.destination===`reception`){let r=e.receptions.findIndex(e=>e.hostKey===i.hostKey),a=e.receptions[r],o=t.ceoBlocks.receptions[r];if(!a||!o)return null;let s=a.waitingAgents.findIndex(({key:e})=>e===n);if(s<0)return null;let c=f(o,s);return{x:c.x,y:c.characterFeetY-42}}if(i.destination===`bar`){let r=e.barAgents.findIndex(({key:e})=>e===n);if(r<0)return null;let i=x(t.ceoBlocks,r);return{x:i.x,y:i.characterFeetY-42}}let a=e.rooms.findIndex(({key:e})=>e===i.roomKey),o=e.rooms[a],s=t.rooms.find(({index:e})=>e===a);if(!o||!s)return null;if(i.placement===`seated`){let e=o.desks.findIndex(({occupantAgentKey:e})=>e===n);if(e>=0){let t=w(s,e);return{x:t.x,y:t.characterFeetY-42}}}let c=o.roomAgents.filter(({placement:e})=>e===`standing`).findIndex(({key:e})=>e===n);if(c>=0){let e=m(s,c);return{x:e.x,y:e.characterFeetY-42}}return null}function ql(e,t){let n=new J;n.roundRect(0,0,t.officeWidth,t.totalHeight,6).fill(921116);for(let e=0;e<14;e+=1)n.rect(2,2+(t.totalHeight-4)*(e/14),t.officeWidth-4,t.totalHeight/14+1).fill({color:Nu(1381674,592148,e/13),alpha:.9});n.roundRect(2,2,t.officeWidth-4,t.totalHeight-4,5).stroke({width:2,color:2763336,alpha:.8}),e.addChild(n)}function Jl(e,t,n,r,i,a,o,s,c){let l=new ne;if(t.fallbackMessage){t.ceoOverflowMarkerRect&&cu(l,t.ceoOverflowMarkerRect,15779960),e.addChild(l);return}let u=t.ceoBlocks,d=t.ceoRect.x+t.ceoRect.width,f=new J;Tu(f,4,4,d-4,t.ceoRect.height,1250088,921117),f.roundRect(4,4,d-4,t.ceoRect.height,4).stroke({width:2,color:9269557,alpha:.8}),l.addChild(f),Yl(l,d,4,Math.max(0,t.agentBarRect.x-d),t.ceoRect.height);let p=new ne;p.position.x=u.ceoOriginX,p.scale.x=u.ceoScale,Eu(p,u.ceoContentWidth/2-88,8,`CEO OFFICE`,7755548,176,void 0,void 0,void 0,13),Xl(p,a,u.localCeoX),Ql(p,r,u.localOtelBoardX),Zl(p,n,u.localBoardX);let m=u.localReceptions;if(n.receptions.forEach((e,t)=>{let r=m[t];r&&$l(p,e,n,r,i,a,o,s,c)}),n.coverage.omittedReceptionDesks>0){let e=Q(`+${n.coverage.omittedReceptionDesks} host desks in roster`,{size:10,color:14140308,anchor:{x:1,y:0}});e.position.set(u.ceoContentWidth-18,13),p.addChild(e)}l.addChild(p),t.ceoOverflowMarkerRect&&cu(l,t.ceoOverflowMarkerRect,15779960),mu(l,u,n,i,a,o,s,c),e.addChild(l)}function Yl(e,t,n,r,i){let a=new J;a.rect(t,n,r,i).fill(2434359),a.rect(t,n,1,i).fill({color:7104912,alpha:.35}),a.rect(t+r-1,n,1,i).fill({color:7104912,alpha:.35});for(let e=n+14;e<n+i-8;e+=18)a.rect(t+r/2,e,1,6).fill({color:7828634,alpha:.38});e.addChild(a)}function Xl(e,t,n){let r=d.ceoDeskWidth,i=n+r/2,a=Q(`YOU · CEO`,{size:11,color:16180146,anchor:.5});a.position.set(i,48),e.addChild(a),xu(e,i,136,9203253);let o=new ne;o.position.set(i,148),bu(o,t[0]??R.EMPTY),e.addChild(o),Su(e,i,136,9203253);let s=new J;s.roundRect(n,130,r,44,5).fill(4798248),s.roundRect(n+4,134,r-8,36,4).fill(7361076),s.roundRect(n+50,138,60,25,3).fill(1581105),s.roundRect(n+57,144,46,13,2).fill(3501214),s.rect(n+4,168,r-8,2).fill({color:12819029,alpha:.72}),e.addChild(s)}function Zl(e,t,n){let{ceoBoardY:r,ceoBoardWidth:i,ceoBoardHeight:a}=d,o=new J;o.roundRect(n+4,r+5,i,a,5).fill({color:0,alpha:.34}),o.roundRect(n,r,i,a,5).fill(5585701),o.roundRect(n+4,r+4,i-8,a-8,3).fill(1516831),o.roundRect(n+4,r+4,i-8,a-8,3).stroke({width:1,color:10188098,alpha:.78}),o.rect(n+10,r+18,i-20,1).fill({color:14215368,alpha:.2}),o.rect(n+8,r+a-10,i-16,2).fill({color:9399868,alpha:.58}),e.addChild(o);let s=Q(`WORKFORCE`,{size:12,color:14873041,anchor:.5});s.position.set(n+i/2,r+12),e.addChild(s);let c=[[`HOSTS`,t.coverage.observedHosts],[`SPACES`,t.coverage.observedWorkspaces],[`AGENTS`,t.coverage.observedAgents],[`WORKING`,t.coverage.status.working],[`INPUT`,t.coverage.status.blocked],[`STALE`,t.coverage.staleHosts]],l=(i-20)/3;c.forEach(([t,i],a)=>{let o=a%3,s=Math.floor(a/3),c=n+10+l*(o+.5),u=r+52+s*44,d=Q(String(i),{size:20,color:t===`STALE`&&typeof i==`number`&&i>0?16756922:15854013,anchor:.5});d.position.set(c,u),e.addChild(d);let f=Q(t,{size:11,color:11126948,anchor:.5});f.position.set(c,u+13),e.addChild(f)})}function Ql(e,t,n){let{ceoBoardY:r,ceoOtelBoardWidth:i,ceoBoardHeight:a}=d,o=new J;o.roundRect(n+4,r+5,i,a,5).fill({color:0,alpha:.34}),o.roundRect(n,r,i,a,5).fill(5585701),o.roundRect(n+4,r+4,i-8,a-8,3).fill(1516831),o.roundRect(n+4,r+4,i-8,a-8,3).stroke({width:1,color:10188098,alpha:.78}),o.rect(n+10,r+34,i-20,1).fill({color:14215368,alpha:.2}),o.rect(n+8,r+a-10,i-16,2).fill({color:9399868,alpha:.58}),e.addChild(o);let s=Q(`ECONOMY`,{size:12,color:14873041,anchor:.5});s.position.set(n+i/2,r+12),e.addChild(s);let c=Q(`MODEL`,{size:11,color:11126948,anchor:{x:0,y:.5},weight:`700`});c.position.set(n+12,r+26),e.addChild(c);let l=n+100,u=new J;u.circle(l-4,r+25,5).fill({color:13940332,alpha:.62}),u.circle(l+3,r+24,5).fill({color:13940332,alpha:.82}),u.circle(l,r+28,5).fill(15854013),u.circle(l,r+28,2).fill({color:9071421,alpha:.8}),e.addChild(u);let f=Q(`$$$`,{size:12,color:11126948,anchor:{x:1,y:.5},weight:`700`});if(f.position.set(n+i-12,r+26),e.addChild(f),t.health!==`available`||t.models.length===0){let a=Q(t.health===`degraded`?`DEGRADED`:`NO DATA`,{size:14,color:t.health===`degraded`?16756922:14140308,anchor:.5});a.position.set(n+i/2,r+78),e.addChild(a);return}t.models.slice(0,4).forEach((t,a)=>{let o=r+48+a*22,s=Q(b(t.model),{size:11,color:15789285,anchor:{x:0,y:.5}});s.position.set(n+12,o),e.addChild(s);let c=Q(C(g(t.usage)),{size:12,color:15854013,anchor:.5});c.position.set(l,o),e.addChild(c);let u=Q(T(t.costUsd,t.costKind),{size:12,color:15854013,anchor:{x:1,y:.5}});u.position.set(n+i-12,o),e.addChild(u)}),o.rect(n+10,r+a-31,i-20,1).fill({color:14215368,alpha:.2});let p=Q(`TOTAL`,{size:11,color:11126948,anchor:{x:0,y:.5},weight:`700`});p.position.set(n+12,r+a-20),e.addChild(p);let m=Q(C(t.totalUsage),{size:12,color:15854013,anchor:.5,weight:`700`});m.position.set(l,r+a-20),e.addChild(m);let h=t.models.some(({costKind:e})=>e!==null&&e!==`reported`)?`estimated`:null,_=Q(T(t.totalCostUsd,h),{size:12,color:15854013,anchor:{x:1,y:.5},weight:`700`});_.position.set(n+i-12,r+a-20),e.addChild(_)}function $l(e,t,n,r,i,a,o,s,c){let l=n.hosts.find(({key:e})=>e===t.hostKey);if(!l)return;let u=Mu(l),p=r.x+r.width/2,m=new J;if(m.rect(r.x,r.y,r.width,r.height).fill({color:i===l.key?u:0,alpha:i===l.key?.08:.001}),Z(m,l.key,s),e.addChild(m),r.index>0){let t=new J;t.rect(r.x-r.gapBefore/2,r.y+8,1,r.height-20).fill({color:7828634,alpha:.22}),e.addChild(t)}let h=t.waitingAgents,g=v(r),_=Array.from({length:4},(t,n)=>{let i=f(r,n),a=i.characterFeetY-d.characterHeight*.18;return xu(e,i.x,a,u),{anchor:i,chairY:a}});Array.from({length:4},(e,t)=>g.x+g.width*((t+.5)/4)).forEach(t=>{let n=g.y+g.height+10;xu(e,t,n,u),Su(e,t,n,u)}),h.forEach((t,n)=>{let{anchor:r,chairY:l}=_[n],d=Q(ju(t.displayLabel,12),{size:8,color:15920625,anchor:.5});d.position.set(r.x,r.nameY),Z(d,t.key,s,c),e.addChild(d);let f=yu(e,a[t.characterIndex]??R.EMPTY,r.x,r.characterFeetY,!1,t.stale,o,t.key,s,i,c);f.alpha=t.stale?.56:1,Su(e,r.x,l,u)}),_.slice(h.length).forEach(({anchor:t,chairY:n})=>{Su(e,t.x,n,u)});let y=new J;y.ellipse(g.x+g.width/2,g.y+g.height+3,Math.max(1,g.width*.38),5).fill({color:0,alpha:.24}),y.roundRect(g.x,g.y,g.width,g.height,16).fill(4863270),y.roundRect(g.x+4,g.y+4,g.width-8,g.height-8,13).fill(7754807),y.roundRect(g.x+g.width*.32,g.y+8,g.width*.36,7,3).fill(2960178),y.roundRect(g.x+6,g.y+6,g.width-12,g.height-12,11).stroke({width:1,color:u,alpha:.68}),Z(y,l.key,s),e.addChild(y);let b=Q(ju(l.displayLabel,20),{size:10,color:16049856,anchor:.5});if(b.position.set(p,g.y+g.height/2),e.addChild(b),t.overflowCount>0){let n=Q(`+${t.overflowCount} waiting in roster`,{size:8,color:15779960,anchor:.5});n.position.set(p,g.y+g.height-7),e.addChild(n)}}function eu(e,t){let n=new J,r=t.ceoBandHeight;n.rect(4,r,t.officeWidth-8,d.hallwayHeight).fill(2434359),n.rect(4,r,t.officeWidth-8,1).fill({color:7104912,alpha:.35});for(let e=20;e<t.officeWidth-20;e+=18)n.rect(e,r+16,7,1).fill({color:7828634,alpha:.38});e.addChild(n)}function tu(e,t){let n=new J,r=new Map;t.rooms.forEach(e=>{let t=r.get(e.row)??[];t.push(e),r.set(e.row,t)});let i=[...r.values()].map(e=>e.sort((e,t)=>e.x-t.x)).sort((e,t)=>e[0].y-t[0].y);i.forEach(e=>{e.slice(0,-1).forEach((t,r)=>{let i=e[r+1],a=i.x-(t.x+t.width);a>0&&Yl(n,t.x+t.width,t.y,a,Math.min(t.height,i.height))})}),i.slice(0,-1).forEach((e,r)=>{let a=i[r+1],o=Math.max(...e.map(({y:e,height:t})=>e+t)),s=Math.min(...a.map(({y:e})=>e));s>o&&nu(n,4,o,t.officeWidth-8,s-o)}),e.addChild(n)}function nu(e,t,n,r,i){if(!(r<=0||i<=0)){e.rect(t,n,r,i).fill(2434359),e.rect(t,n,r,1).fill({color:7104912,alpha:.35}),e.rect(t,n+i-1,r,1).fill({color:7104912,alpha:.35});for(let a=t+14;a<t+r-8;a+=18)e.rect(a,n+i/2,7,1).fill({color:7828634,alpha:.38})}}function ru(e){let t=new Set(e.roomAgents.filter(({semanticStatus:e})=>e!==`idle`).map(({key:e})=>e));return e.roomAgents.some(({semanticStatus:e})=>e!==`idle`)||e.desks.some(({occupantAgentKey:e})=>!!(e&&t.has(e)))}function iu(e,t,n,r,i,a,o,s){let c=d.roomHeaderActionWidth,l=Math.max(0,r.headerRect.width-2*(c+d.roomHeaderActionGap+c+d.roomHeaderCloseGap)),u=Math.max(0,(r.headerRect.width-l)/2),f=r.header??{workspace:ju(t.displayLabel,18),host:ju(n.displayLabel,16),width:r.headerRect.width,titleBoxX:u,titleBoxWidth:l,renameX:u+l+d.roomHeaderActionGap,closeX:Math.max(0,r.headerRect.width-c),renameWidth:c,closeWidth:c,actionWidth:c,actionGap:d.roomHeaderActionGap,closeGap:d.roomHeaderCloseGap,height:r.headerRect.height,emergencyEllipsis:!1},p=r.headerRect.x+f.titleBoxX,m=r.headerRect.y,h=Q(f.workspace.toUpperCase(),{size:Ll,color:16777215,anchor:{x:0,y:.5}}),g=Q(f.host.toUpperCase(),{size:Ll,color:16111762,anchor:{x:0,y:.5}}),_=Q(`-`,{size:Ll,color:15787718,anchor:.5}),v=Q(`-`,{size:Ll,color:15787718,anchor:.5}),y=Math.min(Math.max(0,r.headerRect.width-f.titleBoxX),Math.max(0,f.titleBoxWidth)),b=new J;b.roundRect(p,m,y,Math.min(22,r.headerRect.height),4).fill(a===t.key?i:Nu(i,1185058,.5)),b.roundRect(p,m,y,Math.min(22,r.headerRect.height),4).stroke({width:a===t.key?2:1,color:Nu(i,16777215,.35),alpha:.84}),Z(b,t.key,o,s),e.addChild(b);let x=p+10;au(e,x,m+3,16180146,t.key,o,s),x+=16,_.position.set(x+_.width/2,m+11),Z(_,t.key,o,s),e.addChild(_),x+=_.width,h.position.set(x,m+11),Z(h,t.key,o,s),e.addChild(h),x+=h.width+12,ou(e,x,m+4,15003903,t.key,o,s),x+=20,v.position.set(x+v.width/2,m+11),Z(v,t.key,o,s),e.addChild(v),x+=v.width,g.position.set(x,m+11),Z(g,t.key,o,s),e.addChild(g)}function au(e,t,n,r,i,a,o){let s=new J;s.roundRect(t+2,n,12,16,2).fill({color:r,alpha:.94}),s.rect(t+4,n+4,7,1).fill(6311477),s.rect(t+4,n+7,7,1).fill(6311477),s.rect(t+4,n+10,5,1).fill(6311477),s.rect(t,n+3,2,10).fill(Nu(r,790554,.35)),Z(s,i,a,o),e.addChild(s)}function ou(e,t,n,r,i,a,o){let s=new J;s.roundRect(t,n,17,11,2).fill({color:r,alpha:.94}),s.roundRect(t+3,n+3,11,5,1).fill(3426910),s.rect(t+7,n+11,3,3).fill(r),s.rect(t+4,n+14,9,1).fill(r),Z(s,i,a,o),e.addChild(s)}function su(e,t,n,r,i,a,o,s,c,l,u,f,p){let m=r.hosts.find(({key:e})=>e===t.hostKey);if(!m)return;let h=Bl[m.deterministicSkin.themeIndex%Bl.length],g=ru(t),_=t.desks.some(e=>e.completionAgentKeys.some(e=>!a.has(e))),v=t.desks.some(e=>e.completionAgentKeys.includes(i??``)),y=i===t.key||v,b=new ne,x=new J,S=g?Nu(h.floorA,6115640,.34):h.floorA,C=g?Nu(h.floorB,4471338,.32):h.floorB;Tu(x,n.wallRect.x,n.wallRect.y,n.wallRect.width,n.wallRect.height,S,C),x.rect(n.wallRect.x,n.wallRect.y,n.wallRect.width,Math.min(34,n.wallRect.height)).fill({color:h.wall,alpha:.76}),x.roundRect(n.x+3,n.y+3,Math.max(0,n.width-6),Math.max(0,n.height-6),4).stroke({width:y||_?2:1,color:y?16777215:_?15779960:h.accent,alpha:y||_?.92:.78}),Z(x,t.key,c,u),b.addChild(x),iu(b,t,m,n,h.accent,i,c,u),n.overflowMarkerRect&&cu(b,n.overflowMarkerRect,h.accent),wu(b,n.x+14,n.y+n.height-18,h.accent),wu(b,n.x+n.width-16,n.y+n.height-18,h.accent);let w=new Map(t.roomAgents.map(e=>[e.key,e]));t.desks.forEach((e,t)=>{du(b,e,e.occupantAgentKey?w.get(e.occupantAgentKey):void 0,n,t,h.accent,i,a,o,s,c,l)}),t.roomAgents.filter(({placement:e})=>e===`standing`).forEach((e,t)=>{pu(b,e,n,t,i,o,s,c,l)}),f(t.key)&&(t.desks.length<d.desksPerRoom?lu(b,t,n,t.desks.length,h.accent,p):uu(b,n,h.accent));let T=[];if(t.omittedDeskCount>0&&T.push(`+${t.omittedDeskCount} desks`),t.omittedAgentCount>0&&T.push(`+${t.omittedAgentCount} agents`),T.length>0){let e=Q(`${T.join(` · `)} in roster`,{size:9,color:14147306,anchor:{x:1,y:0}});e.position.set(n.x+n.width-18,n.y+n.height-18),b.addChild(e)}if(t.stale){b.alpha=.68;let e=new J;e.rect(n.x,n.y,n.width,n.height).fill({color:8070965,alpha:.08}),b.addChild(e)}e.addChild(b)}function cu(e,t,n){if(t.width<=0||t.height<=0)return;let r=new J;r.roundRect(t.x,t.y,t.width,t.height,3).fill({color:1777707,alpha:.96}).stroke({width:1,color:n,alpha:.86}),e.addChild(r);let i=Q(`MORE`,{size:7,color:15779960,anchor:.5});i.position.set(t.x+t.width/2,t.y+t.height/2),e.addChild(i)}function lu(e,t,n,r,i,a){let o=w(n,r),s=new ne;s.label=t.key,s.eventMode=`static`,s.cursor=`pointer`,s.on(`pointertap`,e=>{e.stopPropagation(),a(t.key)});let c=new J;c.label=t.key,c.eventMode=`static`,c.roundRect(o.x-25,o.deskY,50,27,5).fill({color:i,alpha:.1}).stroke({width:1,color:i,alpha:.8}),s.addChild(c);let l=Q(`+`,{size:19,color:16049856,anchor:.5,weight:`700`});l.eventMode=`none`,l.position.set(o.x,o.deskY+13),s.addChild(l);let u=Q(`NEW SEAT`,{size:7,color:11126948,anchor:.5});u.eventMode=`none`,u.position.set(o.x,o.nameY+7),s.addChild(u),e.addChild(s)}function uu(e,t,n){let r=t.x+t.width/2,i=t.y+t.height-40,a=new J;a.roundRect(r-25,i,50,27,5).fill({color:n,alpha:.04}).stroke({width:1,color:n,alpha:.38}),e.addChild(a);let o=Q(`+`,{size:19,color:10261631,anchor:.5});o.alpha=.62,o.position.set(r,i+13),e.addChild(o);let s=Q(`ROOM FULL`,{size:7,color:9344394,anchor:.5});s.position.set(r,i+35),e.addChild(s)}function du(e,t,n,r,i,a,o,s,c,l,u,f){let p=w(r,i),m=o===t.key||o===n?.key||t.completionAgentKeys.includes(o??``),h=Q(ju(t.displayLabel,18),{size:9,color:m?16777215:14477043,anchor:.5}),g=Math.max(58,Math.min(p.stationSpan-6,h.width+14)),_=new J;_.roundRect(p.x-g/2,p.nameY,g,16,4).fill({color:m?a:1845046,alpha:.96}),_.roundRect(p.x-g/2,p.nameY,g,16,4).stroke({width:m?2:1,color:a,alpha:.82}),Z(_,t.key,u),e.addChild(_),h.position.set(p.x,p.nameY+8),Z(h,t.key,u),e.addChild(h);let v=p.characterFeetY-d.characterHeight*.18;if(xu(e,p.x,v,a),n){let t=n.stale?{label:`STALE`,color:7964314}:Vl[n.semanticStatus],r=Q(`${ju(n.displayLabel,14)} · ${t.label}`,{size:9,color:1120034,anchor:.5}),i=Math.max(54,Math.min(p.stationSpan-4,r.width+10)),s=new J;s.roundRect(p.x-i/2,p.nameY+18,i,15,3).fill({color:t.color,alpha:.96}),Z(s,n.key,u,f),e.addChild(s),r.position.set(p.x,p.nameY+25.5),Z(r,n.key,u,f),e.addChild(r),n.semanticStatus===`working`&&!n.stale&&l.push({kind:`status`,node:s,baseAlpha:1,phase:l.length*7});let d=yu(e,c[n.characterIndex]??R.EMPTY,p.x,p.characterFeetY,n.semanticStatus===`working`,n.stale,l,n.key,u,m?n.key:o,f);d.alpha=n.stale?.56:1,Su(e,p.x,v,a)}else{Su(e,p.x,v,a);let t=Q(`EMPTY`,{size:8,color:8359329,anchor:.5});t.position.set(p.x,p.nameY+25),e.addChild(t)}Z(Cu(e,p.x-d.deskWidth/2,p.deskY,a,n?.semanticStatus===`working`&&!n.stale,l,m),t.key,u),t.completionAgentKeys.some(e=>!s.has(e))&&fu(e,t,p,s,u,f)}function fu(e,t,n,r,i,a){let o=t.completionAgentKeys.filter(e=>!r.has(e)),s=o[0];if(!s)return;let c=o.length,l=new ne;l.position.set(n.x+17,n.deskY-16),l.alpha=c>0?1:.48;let u=new J;if(u.roundRect(-10,-7,18,13,2).fill(15918013),u.roundRect(-7,-10,18,13,2).fill(16774352),u.rect(-3,-6,9,1).fill(11701592),u.rect(-3,-3,7,1).fill(11701592),u.rect(-3,0,9,1).fill(11701592),u.poly([4,3,8,0,8,4]).fill(7846025),u.moveTo(4,2).lineTo(5.5,3.5).lineTo(8,.5).stroke({width:1.6,color:3108939,alpha:1}),l.addChild(u),c>1){let e=Q(`+${c-1}`,{size:7,color:2432018,anchor:.5}),t=new J;t.circle(11,-9,7).fill(15779960),l.addChild(t),e.position.set(11,-9),l.addChild(e)}Z(l,s,i,a),e.addChild(l)}function pu(e,t,n,r,i,a,o,s,c){let l=m(n,r),u=t.stale?{label:`STALE`,color:7964314}:Vl[t.semanticStatus],d=Q(ju(t.displayLabel,13),{size:9,color:15922424,anchor:.5});d.position.set(l.x,l.nameY+6),Z(d,t.key,s,c),e.addChild(d);let f=Q(u.label,{size:7,color:u.color,anchor:.5});f.position.set(l.x,l.nameY+18),Z(f,t.key,s,c),e.addChild(f);let p=yu(e,a[t.characterIndex]??R.EMPTY,l.x,l.characterFeetY,t.semanticStatus===`working`,t.stale,o,t.key,s,i,c);p.alpha=t.stale?.56:1}function mu(e,t,n,r,i,a,o,s){let c=t.agentBarX,l=t.agentBarWidth,u=t.agentBarHeight,f=new ne,p=new J;Tu(p,c,4,l,u,1512463,1118221),p.roundRect(c,4,l,u,4).stroke({width:2,color:11898952,alpha:.72}),f.addChild(p),Eu(f,c+l/2-58,12,`AGENT BAR`,10583351,116,void 0,void 0,void 0,10);let m=c+10,h=Math.min(76,l*.25),g=u-86,_=x(t,0),v=m+h+10,y=Math.max(0,c+l-10-v),b=4+u-d.agentBarCounterBottomClearance,S=_.capacity,C=n.barAgents.slice(0,S);hu(f,m,46,h,g,C.length),C.forEach((e,n)=>{let c=x(t,n),l=c.x,u=c.rowY,d=e.stale?{label:`STALE`,color:7964314}:Vl[e.semanticStatus],p=Q(ju(e.displayLabel,10),{size:8,color:15789285,anchor:.5});p.position.set(l,u+1),Z(p,e.key,o,s),f.addChild(p);let m=Q(d.label,{size:6,color:d.color,anchor:.5});m.position.set(l,u+12),Z(m,e.key,o,s),f.addChild(m);let h=c.characterFeetY,g=yu(f,i[e.characterIndex]??R.EMPTY,l,h,!1,e.stale,a,e.key,o,r,s);g.alpha=e.stale?.56:1}),vu(f,v,b,y,C.map((e,n)=>x(t,n).x)),_u(f,v,4+u,y);let w=n.coverage.omittedBarAgents+Math.max(0,n.barAgents.length-S);if(w>0){let e=Q(`+${w} more`,{size:8,color:15060888,anchor:{x:1,y:0}});e.position.set(c+l-10,16),f.addChild(e)}e.addChild(f)}function hu(e,t,n,r,i,a){let o=new J;o.roundRect(t+3,n+4,r,i,4).fill({color:0,alpha:.28}),o.roundRect(t,n,r,i,4).fill(5585701),o.roundRect(t+4,n+4,r-8,i-8,2).fill(1516831),o.roundRect(t+4,n+4,r-8,i-8,2).stroke({width:1,color:10188098,alpha:.72}),e.addChild(o);let s=Q(`PARTY`,{size:11,color:15914895,anchor:.5});s.position.set(t+r/2,n+17),e.addChild(s);let c=Q(String(a),{size:26,color:15854013,anchor:.5});c.position.set(t+r/2,n+i/2-4),e.addChild(c),gu(e,t,n,r,i)}function gu(e,t,n,r,i){let a=new J;[[10,25,14850918],[r-14,23,9419224],[16,58,10473132],[r-20,68,14460103],[10,i-32,15974526],[r-14,i-30,14850918]].forEach(([e,r,i],o)=>{o%2==0?a.rect(t+e,n+r,3,7).fill(i):a.circle(t+e,n+r,2.5).fill(i)});let o=t+r/2-4,s=n+i-30;a.roundRect(o-6,s,12,9,3).stroke({width:1.5,color:15847834,alpha:.9}),a.rect(o-1,s+9,2,9).fill(15847834),a.rect(o-7,s+18,14,2).fill(15847834),e.addChild(a)}function _u(e,t,n,r){let i=new J,a=n-30,o=a+18,s=Math.max(0,r-16);i.rect(t+8,o,s,3).fill({color:5979179,alpha:.72}),i.rect(t+8,o+3,s,1).fill({color:13674616,alpha:.36}),e.addChild(i);let c=new J,l=Math.max(3,Math.min(12,Math.floor(r/42)));for(let e=0;e<l;e+=1){let n=t+14+(s-12)*e/Math.max(1,l-1),r=a,i=[13856343,8042948,14066254,12092630][e%4];c.roundRect(n-4,r,8,13,2).fill({color:i,alpha:.86}).stroke({width:1,color:15847834,alpha:.78}),c.rect(n-2,r-4,4,4).fill(15847834)}e.addChild(c)}function vu(e,t,n,r,i){let a=new J;a.roundRect(t+3,n+6,r,34,8).fill({color:0,alpha:.28}),a.roundRect(t,n,r,32,7).fill(4993314),a.roundRect(t+4,n+4,r-8,9,4).fill(9132853),a.rect(t+8,n+7,r-16,2).fill({color:13674616,alpha:.54}),a.roundRect(t+8,n+16,r-16,12,4).fill(3679005);for(let e=t+24;e<t+r-18;e+=52)a.rect(e,n+19,1,7).fill({color:11565381,alpha:.4});for(let e=t+24;e<t+r-20;e+=74)a.circle(e,n+10,3).fill(13674616),a.rect(e-1,n+9,2,7).fill(5979179);e.addChild(a);let o=new J;i.forEach((e,t)=>{let r=n-9,i=[13856343,8042948,14066254,12092630][t%4];o.roundRect(e-5,r,10,8,2).fill({color:i,alpha:.9}).stroke({width:1,color:15847834,alpha:.9}),o.rect(e-1,r+8,2,7).fill(15847834),o.rect(e-6,r+15,12,2).fill(15847834)}),e.addChild(o)}function yu(e,t,n,r,i,a,o,s,c,l,u){let f=new ne;f.position.set(n,r),f.hitArea=new be(-30,-d.characterHeight-8,60,d.characterHeight+18),bu(f,t);let p=new J;if(p.rect(-30,-d.characterHeight-8,60,d.characterHeight+18).fill({color:16777215,alpha:1e-4}),Z(p,s,c,u),f.addChild(p),l===s){let e=new J;e.ellipse(0,-2,25,8).stroke({width:2,color:16777215,alpha:.9}),f.addChildAt(e,0)}return Z(f,s,c,u),i&&!a&&o.push({kind:`character`,node:f,baseY:r,phase:o.length*7}),e.addChild(f),f}function bu(e,t){if(t!==R.EMPTY){let n=new oe(t);n.anchor.set(.5,1),n.scale.set(d.characterHeight/Math.max(1,t.height)),n.roundPixels=!0,e.addChild(n)}else{let t=Q(`◆`,{size:22,color:11845374,anchor:.5});t.position.y=-22,e.addChild(t)}}function xu(e,t,n,r){let i=new J,a=Nu(r,724246,.3),o=Nu(r,2106426,.38);i.ellipse(t,n+13,28,7).fill({color:0,alpha:.24}),i.rect(t-2,n+1,4,11).fill(a),i.rect(t-13,n+10,26,3).fill(a),i.circle(t-13,n+13,3).fill(a),i.circle(t+13,n+13,3).fill(a),i.ellipse(t,n,27,11).fill(o),i.roundRect(t-20,n-31,40,22,7).fill(a),i.roundRect(t-16,n-28,32,15,5).fill(o),i.roundRect(t-13,n-25,26,3,2).fill({color:r,alpha:.48}),e.addChild(i)}function Su(e,t,n,r){let i=new J,a=Nu(r,921632,.18);i.roundRect(t-20,n-14,6,17,3).fill(a),i.roundRect(t+14,n-14,6,17,3).fill(a),e.addChild(i)}function Cu(e,t,n,r,i,a,o=!1){let s=new J;if(s.ellipse(t+24,n+30,30,6).fill({color:0,alpha:.22}),s.roundRect(t,n,48,26,3).fill(7756600),s.roundRect(t+2,n+2,44,22,2).fill(11438941),s.roundRect(t+14,n+10,21,13,2).fill(Nu(r,1054498,.7)),s.roundRect(t+16,n+12,17,8,1).fill(i?3440006:1515825),s.rect(t+1,n+24,46,2).fill({color:r,alpha:.78}),o&&s.roundRect(t-3,n-3,54,32,5).stroke({width:2,color:16777215,alpha:.92}),e.addChild(s),i){let r=new J;r.roundRect(t+16,n+12,17,8,1).fill({color:13238260,alpha:.18}),r.eventMode=`none`,e.addChild(r),a.push({kind:`monitor`,node:r,baseAlpha:.18,phase:a.length*7})}return s}function wu(e,t,n,r){let i=new J;i.roundRect(t-6,n,12,8,2).fill(10902598),i.circle(t,n-4,7).fill(Nu(r,5215599,.7)),i.circle(t-5,n-7,4).fill(6003832),i.circle(t+5,n-7,4).fill(6924933),e.addChild(i)}function Tu(e,t,n,r,i,a,o){for(let s=0;s<i;s+=d.tile)for(let i=0;i<r;i+=d.tile)e.rect(t+i,n+s,d.tile,d.tile).fill((i+s)/d.tile%2==0?a:o)}function Eu(e,t,n,r,i,a,o,s,c,l=10){let u=new J;u.roundRect(t,n,a,19,4).fill(i),u.roundRect(t,n,a,19,4).stroke({width:1,color:Nu(i,16777215,.32),alpha:.72}),o&&s&&Z(u,o,s,c),e.addChild(u);let d=Q(r,{size:l,color:16777215,anchor:.5});d.position.set(t+a/2,n+9.5),o&&s&&Z(d,o,s,c),e.addChild(d)}function Z(e,t,n,r){e.label=t,e.eventMode=`static`,e.cursor=`pointer`,e.on(`pointertap`,e=>{if(e.stopPropagation(),O(`renderer:pointertap`,{key:t,detail:e.detail,hasActivation:!!r}),e.detail===0){Rl.delete(n),zl.delete(n),n(t);return}let i=window.performance.now(),a=Rl.get(n),o=a?.key===t&&(e.detail===2||i-a.at<=500);if(n(t),o){Rl.delete(n),zl.delete(n),r?.(t);return}Rl.set(n,{key:t,at:i,x:e.global.x,y:e.global.y,activate:r});let s=zl.get(n);r&&(!s||i-s.at>1e3)&&zl.set(n,{key:t,at:i,x:e.global.x,y:e.global.y,activate:r})})}function Q(e,t={}){let n=new qc({text:e,resolution:4,style:new Mi({fontSize:t.size??9,fill:t.color??16777215,fontWeight:t.weight??`600`,fontFamily:`Inter, ui-sans-serif, system-ui, sans-serif`,dropShadow:{alpha:.24,distance:1,color:0}})});return typeof t.anchor==`number`?n.anchor.set(t.anchor):t.anchor&&n.anchor.set(t.anchor.x,t.anchor.y),n}function Du(){let e=document.fonts;return!e||e.status===`loaded`&&e.check(`600 ${Ll}px Inter`)}function Ou(e,t,n){let r=il(e,t,n),i=ku(`-`),a=26+i+12+20+i+10,o=Math.max(0,d.maxExpandedRoomWidth-2*d.roomHeaderSafeInset-2*(d.roomHeaderActionWidth+d.roomHeaderActionGap+d.roomHeaderActionWidth+d.roomHeaderCloseGap)),s=r.workspace,c=r.host;if(a+ku(s)+ku(c)>o){let e=Math.max(0,o-a),t=Math.floor(e*.52);s=Au(s,t),c=Au(c,Math.max(0,e-t))}let l=Math.ceil(a+ku(s)+ku(c));return{titleBoxWidth:l,roomWidth:hl(l),workspace:s,host:c}}function ku(e){let t=new qc({text:e.toUpperCase(),resolution:4,style:new Mi({fontSize:Ll,fill:16777215,fontWeight:`600`,fontFamily:`Inter, ui-sans-serif, system-ui, sans-serif`,dropShadow:{alpha:.24,distance:1,color:0}})}),n=t.width;return t.destroy(),n}function Au(e,t){if(t<=0)return``;if(ku(e)<=t)return e;if(ku(`…`)>t)return``;let n=[...e],r=n.length;for(;r>0&&ku(`${n.slice(0,r).join(``)}…`)>t;)--r;return r>0?`${n.slice(0,r).join(``)}…`:`…`}function ju(e,t){let n=[...e];return n.length<=t?e:`${n.slice(0,Math.max(1,t-1)).join(``)}…`}function Mu(e){return Bl[e.deterministicSkin.themeIndex%Bl.length].accent}function Nu(e,t,n){let r=Math.max(0,Math.min(1,n)),i=e>>16&255,a=e>>8&255,o=e&255,s=t>>16&255,c=t>>8&255,l=t&255;return Math.round(i+(s-i)*r)<<16|Math.round(a+(c-a)*r)<<8|Math.round(o+(l-o)*r)}function Pu(){return window.__HERDR_WORLD_RENDERER__||(window.__HERDR_WORLD_RENDERER__={mounts:0,destroys:0,activeApplications:0,activeTickers:0,activeObservers:0,activeListeners:0,canvases:0,frames:0,sceneRenders:0,sceneSkips:0,ready:!1,reducedMotion:!1,lastError:null,animation:{characters:0,monitors:0,statuses:0},layout:null,publishedLayout:null,completionMarkers:0}),window.__HERDR_WORLD_RENDERER__}async function Fu(e){let t=new Image;if(t.decoding=`async`,t.src=e,typeof t.decode==`function`?await t.decode():await new Promise((e,n)=>{t.addEventListener(`load`,()=>e(),{once:!0}),t.addEventListener(`error`,()=>n(Error(`character asset unavailable`)),{once:!0})}),typeof globalThis.createImageBitmap==`function`)return R.from(await globalThis.createImageBitmap(t));let n=document.createElement(`canvas`);n.width=t.naturalWidth||t.width,n.height=t.naturalHeight||t.height;let r=n.getContext(`2d`);if(!r)throw Error(`character asset canvas unavailable`);return r.drawImage(t,0,0),new R({source:new ie({resource:n})})}function Iu(e){for(let t of e)t!==R.EMPTY&&t.destroy(!0)}var $=i();function Lu({projection:e,selectedKey:t,completionSeenKeys:n,observability:r,conversationTargets:i,onSelect:a,onActivateAgent:o,onActivateRoom:s,canCreateSeat:c,onNewSeat:l,onHover:u,onAnchorChange:d,onSelectedAnchorChange:f,onLayoutChange:p,onCanvasRendered:m,roomAlignment:h,longRoomTitleMode:g,children:_}){let v=(0,q.useRef)(null),y=(0,q.useRef)(null),b=(0,q.useRef)({projection:e,selectedKey:t,completionSeenKeys:n,observability:r,conversationTargets:i,onSelect:a,onActivateAgent:o,onActivateRoom:s,canCreateSeat:c,onNewSeat:l,onHover:u,onAnchorChange:d,onSelectedAnchorChange:f,onLayoutChange:p,onCanvasRendered:m,roomAlignment:h,longRoomTitleMode:g}),[x,S]=(0,q.useState)(!1);b.current={projection:e,selectedKey:t,completionSeenKeys:n,observability:r,conversationTargets:i,onSelect:a,onActivateAgent:o,onActivateRoom:s,canCreateSeat:c,onNewSeat:l,onHover:u,onAnchorChange:d,onSelectedAnchorChange:f,onLayoutChange:p,onCanvasRendered:m,roomAlignment:h,longRoomTitleMode:g};let C=()=>{let e=b.current.onAnchorChange,t=b.current.onSelectedAnchorChange;if(!e&&!t)return;let n=y.current,r=v.current,i=r?.closest(`.world-stage-scroll`),a=r?.querySelector(`canvas[data-office-canvas='true']`);if(!i||!a||!n){e?.(null),t?.(null);return}let o=a.getBoundingClientRect(),s=i.getBoundingClientRect(),c=e=>{if(!e)return null;let t=o.left+e.x,n=o.top+e.y-i.scrollTop,r=t>=s.left&&t<=s.right&&n>=s.top&&n<=s.bottom,a=t<s.left?s.left-t:t>s.right?t-s.right:0,c=n<s.top?s.top-n:n>s.bottom?n-s.bottom:0,l=r?null:a>c?t<s.left?`left`:`right`:n<s.top?`top`:`bottom`;return{x:l===`left`?s.left+10:l===`right`?s.right-10:t,y:l===`top`?s.top+10:l===`bottom`?s.bottom-10:n,visible:r,edge:l}},l={};for(let e of b.current.conversationTargets){let t=n.getAnchors(e.selectedKey,e.targetKey);t&&(l[e.id]={agent:c(t.agent),workbench:c(t.workbench)})}e?.(l);let u=n.getAnchors(b.current.selectedKey,null);t?.(c(u.agent??u.workbench))},w=(0,q.useRef)(C);w.current=C;let T=(0,q.useRef)(null),E=()=>{T.current===null&&(T.current=window.requestAnimationFrame(()=>{T.current=null,w.current()}))},D=(0,q.useRef)(E);return D.current=E,(0,q.useEffect)(()=>()=>{T.current!==null&&(window.cancelAnimationFrame(T.current),T.current=null)},[]),(0,q.useEffect)(()=>{let e=v.current;if(!e)return;let t=!1;return O(`renderer:mount-request`,{rooms:b.current.projection.rooms.length,agents:b.current.projection.roster.length,desks:b.current.projection.deskRoster.length}),Ul(e,b.current.projection,b.current.selectedKey,b.current.completionSeenKeys,b.current.observability,e=>b.current.onSelect(e),e=>b.current.onActivateAgent(e),e=>b.current.onActivateRoom(e),e=>b.current.canCreateSeat(e),e=>b.current.onNewSeat(e),e=>b.current.onHover?.(e),e=>b.current.onLayoutChange?.(e),e=>b.current.onCanvasRendered?.(e),b.current.roomAlignment,b.current.longRoomTitleMode).then(e=>{if(t){e.destroy();return}y.current=e,O(`renderer:ready`,{rooms:b.current.projection.rooms.length,agents:b.current.projection.roster.length,desks:b.current.projection.deskRoster.length});let n=b.current;e.update(n.projection,n.selectedKey,n.completionSeenKeys,n.observability,n.roomAlignment,n.longRoomTitleMode),D.current()}).catch(e=>{t||(O(`renderer:error`,{error:e instanceof Error?e.message:String(e)}),window.__HERDR_WORLD_RENDERER__&&(window.__HERDR_WORLD_RENDERER__.lastError=e instanceof Error?e.message.slice(0,160):`renderer initialization failed`),S(!0))}),()=>{t=!0,O(`renderer:destroy`),y.current?.destroy(),y.current=null}},[]),(0,q.useEffect)(()=>{y.current?.update(e,t,n,r,h,g),D.current()},[n,g,r,e,h,t]),(0,q.useEffect)(()=>{D.current()},[i]),(0,q.useEffect)(()=>{let e=v.current?.closest(`.world-stage-scroll`);if(!e)return;let t=()=>D.current();return e.addEventListener(`scroll`,t,{passive:!0}),window.addEventListener(`resize`,t),()=>{e.removeEventListener(`scroll`,t),window.removeEventListener(`resize`,t)}},[]),(0,$.jsxs)(`div`,{className:`world-canvas-shell`,children:[x?(0,$.jsxs)(`div`,{className:`world-renderer-fallback`,role:`status`,children:[(0,$.jsx)(`strong`,{children:`Visual scene unavailable`}),(0,$.jsx)(`span`,{children:`The complete roster and inspector remain available.`})]}):null,(0,$.jsx)(`div`,{ref:v,className:`world-canvas-host`,"data-renderer":x?`unavailable`:`pixi`,hidden:x}),_]})}var Ru=720,zu=430;function Bu(e,t){let n=Ku(e*.72,560,960,e),r=Ku(t*.6,340,560,t);return Uu({left:(e-n)/2,top:(t-r)/2,width:n,height:r},e,t)}function Vu(e,t){let{width:n,height:r}=Bu(e,t);return Uu({left:e-12-n,top:t-12-r,width:n,height:r},e,t)}function Hu(e,t,n,r){let i=Ku(t*.52,560,Ru,t),a=Ku(n*.48,340,zu,n),o=Uu({left:t-12-i-r*34,top:n-12-a-r*28,width:i,height:a},t,n);return Math.abs(e.left-o.left)<1&&Math.abs(e.top-o.top)<1&&Math.abs(e.width-o.width)<1&&Math.abs(e.height-o.height)<1}function Uu(e,t,n){let r=Math.max(0,t-24),i=Math.max(0,n-24),a=Math.min(560,r),o=Math.min(340,i),s=Ju(qu(e.width,a),a,r),c=Ju(qu(e.height,o),o,i),l=Math.max(12,t-12-s),u=Math.max(12,n-12-c);return{left:Ju(qu(e.left,12),12,l),top:Ju(qu(e.top,12),12,u),width:s,height:c}}function Wu(e,t,n,r,i){return Uu({...e,left:e.left+t,top:e.top+n},r,i)}function Gu(e,t,n,r,i){return Uu({...e,width:e.width+t,height:e.height+n},r,i)}function Ku(e,t,n,r){let i=Math.max(0,r-24);return Ju(e,Math.min(t,i),Math.min(n,i))}function qu(e,t){return Number.isFinite(e)?e:t}function Ju(e,t,n){return Math.max(t,Math.min(n,e))}var Yu=`herdrWeb.worldView.v1`,Xu=8,Zu=1e4;function Qu(){return{geometry:{},themeGeometry:{},order:[],scrollTop:0}}function $u(e,t){return t===`office`?e.geometry:e.themeGeometry[t]??{}}function ed(e,t,n){return t===`office`?{...e,geometry:n}:{...e,themeGeometry:{...e.themeGeometry,[t]:n}}}function td(e=cd()){if(!e)return Qu();try{let t=e.getItem(Yu);return t?rd(JSON.parse(t)):Qu()}catch{return Qu()}}function nd(e,t=cd()){if(t)try{t.setItem(Yu,JSON.stringify(rd(e)))}catch{}}function rd(e){if(!e||typeof e!=`object`||Array.isArray(e))return Qu();let t=e,n=id(t.geometry),r={};if(t.themeGeometry&&typeof t.themeGeometry==`object`&&!Array.isArray(t.themeGeometry)){for(let[e,n]of Object.entries(t.themeGeometry))if(/^[a-z0-9-]{1,40}$/.test(e)&&(r[e]=id(n),Object.keys(r).length>=Xu))break}return{geometry:n,themeGeometry:r,order:Array.isArray(t.order)?sd(t.order).slice(0,5):[],scrollTop:typeof t.scrollTop==`number`&&Number.isFinite(t.scrollTop)?Math.max(0,Math.min(Zu,t.scrollTop)):0}}function id(e){let t={};if(!e||typeof e!=`object`||Array.isArray(e))return t;for(let[n,r]of Object.entries(e)){let e=ad(r);if(e&&(t[n.slice(0,160)]=e),Object.keys(t).length>=5)break}return t}function ad(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e;return[t.left,t.top,t.width,t.height].every(e=>typeof e==`number`&&Number.isFinite(e))?{left:od(t.left),top:od(t.top),width:od(t.width),height:od(t.height)}:null}function od(e){return Math.max(0,Math.min(Zu,e))}function sd(e){let t=new Set,n=[];for(let r of e)typeof r!=`string`||!r||t.has(r)||(t.add(r),n.push(r.slice(0,160)));return n}function cd(){try{return globalThis.localStorage??null}catch{return null}}var ld=(0,q.createContext)({rects:{}}),ud=120,dd=8,fd=1;function pd(){return(0,q.useContext)(ld)}function md({activeThemeId:e,panels:t,compact:n,onFocus:r,onClose:i,children:a}){let o=(0,q.useRef)(null),s=(0,q.useRef)({}),c=(0,q.useRef)(t);c.current=t;let[l]=(0,q.useState)(td),u=(0,q.useRef)(l),[d,f]=(0,q.useState)({}),p=(0,q.useRef)(``),[m,h]=(0,q.useState)({}),g=(0,q.useRef)(m);g.current=m;let[_,v]=(0,q.useState)(null),[y,b]=(0,q.useState)(()=>u.current.order),x=(0,q.useRef)({}),S=(0,q.useRef)(e),C=(0,q.useRef)(null),w=(0,q.useRef)(null),T=(0,q.useRef)(0),E=(0,q.useRef)(()=>{}),D=(0,q.useRef)(null),O=(0,q.useRef)(null),k=(0,q.useRef)(()=>null),A=(0,q.useRef)(null),j=t.map(({id:e})=>e),M=j.join(`|`),N=(0,q.useCallback)(e=>{let t=td(),n=ed({...t,order:e.order},e.themeId,{...$u(t,e.themeId),...e.geometry});u.current=n,nd(n)},[]);k.current=()=>n?null:{themeId:e,geometry:_d(x.current),order:y.filter(Boolean).slice(0,5)};let P=(0,q.useCallback)(()=>{D.current!==null&&(window.clearTimeout(D.current),D.current=null);let e=O.current,t=k.current();O.current=null,e&&e.themeId!==t?.themeId&&N(e),t?N(t):e&&N(e)},[N]),F=(0,q.useCallback)(()=>{let e=k.current();if(!e)return;let t=O.current;t&&t.themeId!==e.themeId&&N(t),D.current!==null&&window.clearTimeout(D.current),O.current=e,D.current=window.setTimeout(()=>{D.current=null;let e=O.current;O.current=null,e&&N(e)},ud)},[N]),I=()=>{C.current===null&&(C.current=window.requestAnimationFrame(()=>{C.current=null,h({...x.current})}))},L=(e,t)=>{let r=o.current;if(!r||n)return;let i=Uu(t,r.clientWidth,r.clientHeight),a=x.current[e];a&&a.left===i.left&&a.top===i.top&&a.width===i.width&&a.height===i.height||(x.current={...x.current,[e]:i},I())},ee=e=>{let t=o.current,n=s.current[e];if(!t||!n)return null;let r=t.getBoundingClientRect(),i=n.getBoundingClientRect();return Uu({left:i.left-r.left,top:i.top-r.top,width:i.width,height:i.height},t.clientWidth,t.clientHeight)},te=(0,q.useCallback)(()=>{let t=o.current;if(!t||n||t.clientWidth<=0||t.clientHeight<=0)return;let r={};for(let[n,i]of c.current.entries()){let a=x.current[i.id];if(a){r[i.id]=Uu(a,t.clientWidth,t.clientHeight);continue}let o=e===`graph`,s=o?Vu(t.clientWidth,t.clientHeight):Bu(t.clientWidth,t.clientHeight);r[i.id]=Uu({...s,left:s.left+n*34*(o?-1:1),top:s.top+n*28*(o?-1:1)},t.clientWidth,t.clientHeight)}(Object.keys(x.current).length!==Object.keys(r).length||Object.entries(r).some(([e,t])=>{let n=x.current[e];return!n||n.left!==t.left||n.top!==t.top||n.width!==t.width||n.height!==t.height}))&&(x.current=r,h(r))},[e,n,M]),ne=(0,q.useCallback)(()=>{p.current=``,f(e=>Object.keys(e).length===0?e:{})},[]),R=(0,q.useCallback)(()=>{w.current!==null||T.current>=dd||(T.current+=1,w.current=window.requestAnimationFrame(()=>{w.current=null,E.current()}))},[]),re=(0,q.useCallback)(()=>{te();let e=g.current;if(!n&&(!hd(x.current,e)||c.current.some(({id:t})=>e[t]===void 0))){ne();return}let t=o.current;if(!t)return;let r=t.getBoundingClientRect(),i={};for(let t of c.current){let a=s.current[t.id];if(!a)continue;let o=a.getBoundingClientRect(),c=e[t.id];if(!n&&c&&!gd(r,o,c)){ne(),R();return}i[t.id]=o}T.current=0;let a=Object.entries(i).map(([e,t])=>`${e}:${t.left}:${t.top}:${t.width}:${t.height}`).join(`|`);a!==p.current&&(p.current=a,f(i))},[n,R,te,ne]);E.current=re,(0,q.useEffect)(()=>()=>{C.current!==null&&window.cancelAnimationFrame(C.current),w.current!==null&&window.cancelAnimationFrame(w.current),P()},[P]),(0,q.useLayoutEffect)(()=>{let t=new Set(j),r=o.current,i=S.current!==e;T.current=0;let a=$u(u.current,e);if(n)x.current={},h({});else{let t=Object.fromEntries(j.flatMap((t,n)=>{let o=(i?void 0:x.current[t])??a[t],s=e===`graph`&&o&&r&&Hu(o,r.clientWidth,r.clientHeight,n)?void 0:o;return s?[[t,s]]:[]}));x.current=t,h(t)}S.current=e,i&&(p.current=``),f(e=>Object.fromEntries(i?[]:Object.entries(e).filter(([e])=>t.has(e)))),b(e=>{let n=e.length>0?e:u.current.order;return[...n.filter(e=>t.has(e)),...j.filter(e=>!n.includes(e))]}),j.length===0&&(A.current=null,v(null))},[e,n,M]),(0,q.useLayoutEffect)(()=>{T.current=0,re()},[m,re]),(0,q.useEffect)(()=>{let n=o.current;if(!n||(re(),t.length===0)||typeof ResizeObserver>`u`)return;let r=new ResizeObserver(re);r.observe(n);for(let e of c.current){let t=s.current[e.id];t&&r.observe(t)}let i=e===`graph`&&window.__HERDR_GRAPH_RENDERER__;return i&&(i.activeConversationObservers+=1),window.addEventListener(`resize`,re),()=>{r.disconnect(),window.removeEventListener(`resize`,re),i&&--i.activeConversationObservers}},[e,re,M]),(0,q.useEffect)(()=>{n||F()},[e,n,m,y,F]),(0,q.useEffect)(()=>{let e=e=>{if(e.key!==`Escape`)return;let t=e.target instanceof Element?e.target:null,n=document.activeElement;if(t?.closest(`.world-conversation-terminal`)||n instanceof Element&&n.closest(`.world-conversation-terminal`))return;let r=[...y].reverse().find(e=>j.includes(e));r&&(e.preventDefault(),e.stopPropagation(),i(r))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[i,y,M]);let ie=e=>{b(t=>[...t.filter(t=>t!==e),e]),r(e)},ae=(e,t)=>{if(n||t.button!==0)return;ie(e);let r=t.target instanceof Element?t.target:null,i=r?.closest(`[data-world-conversation-resize='true']`),a=r?.closest(`.world-conversation-header`);if(!i&&!a||a&&r?.closest(`button, a, input, textarea, select`))return;let o=s.current[e],c=x.current[e]??ee(e);if(!o||!c)return;t.preventDefault(),t.stopPropagation(),o.setPointerCapture(t.pointerId);let l=i?`resizing`:`moving`;A.current={id:e,mode:l,pointerId:t.pointerId,startX:t.clientX,startY:t.clientY,geometry:c},v({id:e,mode:l})},oe=e=>{let t=A.current;if(!t||t.pointerId!==e.pointerId)return;e.preventDefault(),e.stopPropagation();let n=o.current;if(!n)return;let r=e.clientX-t.startX,i=e.clientY-t.startY;L(t.id,t.mode===`moving`?Wu(t.geometry,r,i,n.clientWidth,n.clientHeight):Gu(t.geometry,r,i,n.clientWidth,n.clientHeight))},se=e=>{let t=A.current;!t||t.pointerId!==e.pointerId||(e.preventDefault(),e.stopPropagation(),e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId),A.current=null,v(null),P())},ce=(e,t)=>{if(n||![`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`].includes(t.key))return;let r=t.target instanceof Element?t.target:null,i=!!r?.closest(`.world-conversation-header`),a=!!r?.closest(`[data-world-conversation-resize='true']`);if(!i&&!a||!a&&r?.closest(`button, a, input, textarea, select`))return;let s=o.current,c=x.current[e]??ee(e);if(!s||!c)return;y[y.length-1]!==e&&ie(e),t.preventDefault();let l=t.shiftKey?48:16,u=t.key===`ArrowRight`?l:t.key===`ArrowLeft`?-l:0,d=t.key===`ArrowDown`?l:t.key===`ArrowUp`?-l:0;L(e,a?Gu(c,u,d,s.clientWidth,s.clientHeight):Wu(c,u,d,s.clientWidth,s.clientHeight))};return(0,$.jsx)(ld.Provider,{value:{rects:d},children:(0,$.jsxs)(`div`,{ref:o,className:`world-theme-layer`,children:[a,t.map(t=>{let r=m[t.id],i=y.indexOf(t.id),a=_?.id===t.id?_.mode:void 0;return(0,$.jsxs)(`div`,{ref:e=>{e?s.current[t.id]=e:delete s.current[t.id]},className:e===`graph`?`world-conversation-slot graph-conversation-slot`:`world-conversation-slot`,"data-window-id":t.id,"data-positioned":r?`true`:`false`,"data-active":i===y.length-1?`true`:void 0,"data-interaction":a,"aria-busy":a!==void 0,style:r&&!n?{left:`${r.left}px`,top:`${r.top}px`,width:`${r.width}px`,height:`${r.height}px`,zIndex:20+Math.max(0,i)}:void 0,onPointerDown:e=>{ie(t.id),ae(t.id,e)},onPointerMove:oe,onPointerUp:se,onPointerCancel:se,onKeyDown:e=>ce(t.id,e),children:[t.content,n?null:(0,$.jsx)(`button`,{type:`button`,className:`world-conversation-resize`,"data-world-conversation-resize":`true`,"aria-label":`Resize agent conversation`,title:`Resize conversation`,onPointerDown:e=>ae(t.id,e)})]},t.id)})]})})}function hd(e,t){let n=Object.keys(e);return n.length===Object.keys(t).length?n.every(n=>{let r=e[n],i=t[n];return i!==void 0&&r.left===i.left&&r.top===i.top&&r.width===i.width&&r.height===i.height}):!1}function gd(e,t,n){return Math.abs(t.left-e.left-n.left)<fd&&Math.abs(t.top-e.top-n.top)<fd&&Math.abs(t.width-n.width)<fd&&Math.abs(t.height-n.height)<fd}function _d(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,{...t}]))}function vd(e,t){if(t.fallbackMessage)return[];let n=[];return e.receptions.forEach((r,i)=>{let a=t.ceoBlocks.receptions.find(({index:e})=>e===i);a&&r.waitingAgents.forEach((t,r)=>{let i=f(a,r);n.push(bd(e,t,yd(i.x,i.nameY-5,i.stationSpan-4,i.characterFeetY-i.nameY+10)))})}),e.rooms.forEach((r,i)=>{let a=t.rooms.find(({index:e})=>e===i);if(!a)return;let o=a.header,s=Math.max(48,Math.min(a.headerRect.width,o?.titleBoxWidth??a.headerRect.width-d.roomHeaderChromeWidth));n.push({key:r.key,kind:`room`,label:Sd(e,r),rect:yd(a.headerRect.x+(o?.titleBoxX??(a.headerRect.width-s)/2)+s/2,a.headerRect.y-(48-a.headerRect.height)/2,s,48),canActivate:r.canOpenInSpaces}),r.desks.forEach((t,i)=>{let o=w(a,i),s=t.occupantAgentKey?r.roomAgents.find(({key:e})=>e===t.occupantAgentKey):void 0,c=yd(o.x,o.nameY-5,o.stationSpan-4,o.characterFeetY-o.nameY+d.deskHeight+8);n.push(s?bd(e,s,c,t):{key:t.key,kind:`desk`,label:xd(e,t),rect:c,canActivate:!1})}),r.roomAgents.filter(({placement:e})=>e===`standing`).forEach((t,r)=>{let i=m(a,r);n.push(bd(e,t,yd(i.x,i.nameY-5,i.stationSpan-4,i.characterFeetY-i.nameY+10)))})}),n}function yd(e,t,n,r){let i=Math.max(48,n),a=Math.max(48,r);return{x:e-i/2,y:t,width:i,height:a}}function bd(e,t,n,r){let i=e.roster.find(({agent:e})=>e.key===t.key),a=t.stale?`stale`:t.stateLabels[t.semanticStatus]??t.semanticStatus,o=r?`desk ${r.displayLabel}, ${i?.roomLabel??`Office`}`:i?.roomLabel??`Office`,s=i?.hostLabel??e.hosts.find(({key:e})=>e===t.hostKey)?.displayLabel??`host`,c=t.taskSummary?`, ${t.taskSummary}`:``;return{key:t.key,kind:`agent`,label:`${t.displayLabel}, ${a}, ${o}, ${s}${c}`,rect:n,canActivate:t.canOpenInSpaces}}function xd(e,t){let n=e.deskRoster.find(({desk:e})=>e.key===t.key);return`Empty desk ${t.displayLabel}, ${n?.roomLabel??`Office`}, ${n?.hostLabel??`host`}`}function Sd(e,t){let n=e.roomRoster.find(({key:e})=>e===t.key);return`Room ${t.accessibleLabel??t.displayLabel}, ${n?.hostLabel??`host`}`}var Cd=e({default:()=>Td,isWorldSurfaceContext:()=>Nd}),wd={projection:{version:1,generatedAt:0,hosts:[],rooms:[],receptions:[],barAgents:[],roomRoster:[],deskRoster:[],roster:[],unresolved:[],coverage:{configuredHosts:0,observedHosts:0,compatibleHosts:0,connectingHosts:0,staleHosts:0,incompatibleHosts:0,disabledHosts:0,observedWorkspaces:0,observedDesks:0,observedAgents:0,status:{working:0,idle:0,blocked:0,done:0,unknown:0},omittedRooms:0,omittedDesks:0,omittedRoomAgents:0,omittedReceptionDesks:0,omittedWaitingAgents:0,omittedBarAgents:0},presentationBounds:{...y,totalRooms:0,renderedRooms:0,totalDesks:0,renderedDesks:0,totalRoomAgents:0,renderedRoomAgents:0,totalReceptionDesks:0,renderedReceptionDesks:0,totalWaitingAgents:0,renderedWaitingAgents:0,totalBarAgents:0,renderedBarAgents:0}},selectedKey:null,observability:{health:`unavailable`,providerId:null,sourceCount:0,configuredSourceCount:0,failedSourceCount:0,observedAt:0,windowSeconds:null,models:[],totalCostUsd:null,totalUsage:0},completionSeenKeys:new Set,onSelect:()=>{},compact:!1,onBackToSidebar:()=>{},onToggleSidebar:()=>{},onOpenInSpaces:()=>{},handoffStatus:null,conversationBubbles:[],onCloseConversation:()=>{},onFocusConversation:()=>{},agentActivityTransitions:new Map,roomAlignment:`left`,longRoomTitleMode:`expand`,canCreateSeat:()=>!1,onNewSeat:()=>{},canCreateRoom:()=>!1,onCreateRoom:()=>{},canRenameRoom:()=>!1,onRenameRoom:()=>{},canCloseRoom:()=>!1,onCloseRoom:()=>{}};function Td({context:e}){let t=Nd(e)?e:wd;return(0,$.jsx)(Ed,{projection:t.projection,context:t,onActivateAgent:e=>{let n=t.projection.roster.find(t=>t.agent.key===e)?.agent;n&&(t.onSelect(e),t.onOpenInSpaces(h(n)))},onActivateRoom:e=>{let n=t.projection.roomRoster.find(t=>t.key===e);n&&(t.onSelect(e),t.onOpenInSpaces(u(n)))}})}function Ed({projection:e,context:t,onActivateAgent:n,onActivateRoom:r}){let i=(0,q.useRef)(null),o=(0,q.useRef)(null),l=(0,q.useRef)(!1),u=(0,q.useRef)(null),{rects:f}=pd(),[p,m]=(0,q.useState)({}),[h,g]=(0,q.useState)(null),[_,v]=(0,q.useState)(0),[y,b]=(0,q.useState)({width:0,height:0}),[x,C]=(0,q.useState)(null),[w,T]=(0,q.useState)(null),E=(0,q.useCallback)(()=>{let e=td();nd({...e,scrollTop:Math.max(0,i.current?.scrollTop??e.scrollTop)})},[]),D=(0,q.useCallback)(()=>{u.current!==null&&window.clearTimeout(u.current),u.current=window.setTimeout(()=>{u.current=null,E()},120)},[E]),O=(0,q.useMemo)(()=>t.conversationBubbles.map(e=>({id:e.id,selectedKey:e.selectedKey,targetKey:e.targetKey})),[t.conversationBubbles]),k=e.rooms.find(({key:e})=>e===t.selectedKey)?.key??e.deskRoster.find(({desk:e})=>e.key===t.selectedKey)?.desk.roomKey??e.roster.find(({agent:e})=>e.key===t.selectedKey)?.agent.roomKey??null,A=h?.agentBarRect,j=!!(h&&!h.fallbackMessage&&h.layoutRevision>0&&h.layoutRevision===_),M=e=>{if(!e){C(null);return}let t=o.current;if(!t)return;let n=t.getBoundingClientRect();C({...e,left:e.clientX-n.left,top:e.clientY-n.top})},N=e=>{if(!e){T(null);return}let t=o.current;if(!t)return;let n=t.getBoundingClientRect();T({...e,left:e.x-n.left,top:e.y-n.top})};(0,q.useEffect)(()=>()=>{u.current!==null&&(window.clearTimeout(u.current),u.current=null)},[]),(0,q.useEffect)(()=>{let e=o.current;if(!e)return;let t=()=>{let t={width:e.clientWidth,height:e.clientHeight};b(e=>e.width===t.width&&e.height===t.height?e:t)};t();let n=new ResizeObserver(t);return n.observe(e),window.addEventListener(`resize`,t),()=>{n.disconnect(),window.removeEventListener(`resize`,t)}},[]),(0,q.useEffect)(()=>{if(t.compact||l.current)return;let e=i.current;if(!e)return;let n=()=>{e.scrollTop=td().scrollTop,l.current=!0},r=window.requestAnimationFrame(()=>{n(),window.requestAnimationFrame(n)});return()=>window.cancelAnimationFrame(r)},[t.compact,e.generatedAt]),(0,q.useEffect)(()=>{if(t.compact)return;let e=i.current;if(!e)return;let n=()=>D();return e.addEventListener(`scroll`,n,{passive:!0}),()=>e.removeEventListener(`scroll`,n)},[t.compact,D]),(0,q.useEffect)(()=>{let e=new Set(t.conversationBubbles.map(({id:e})=>e));m(t=>Object.fromEntries(Object.entries(t).filter(([t])=>e.has(t))))},[t.conversationBubbles]);let P=(()=>{let e=o.current;if(!e||t.conversationBubbles.length===0||y.width<=0||y.height<=0)return null;let n=e.getBoundingClientRect(),r=t.conversationBubbles.flatMap(e=>{let t=f[e.id],r=p[e.id];if(!t||!r)return[];let i=t.left-n.left,a=t.right-n.left,o=t.top-n.top,s=t.bottom-n.top,c=(i+a)/2;return[`workbench`,`agent`].flatMap(t=>{let l=r[t];if(!l)return[];let u=l.x-n.left,d=l.y-n.top,f=u<=c?i:a,p=d+(t===`workbench`?-10:10),m=Math.max(o+22,Math.min(s-22,p)),h=u+(f-u)*.55,g=`M ${u.toFixed(1)} ${d.toFixed(1)} C ${h.toFixed(1)} ${d.toFixed(1)}, ${h.toFixed(1)} ${m.toFixed(1)}, ${f.toFixed(1)} ${m.toFixed(1)}`;return[{id:`${e.id}:${t}`,windowId:e.id,kind:t,path:g,targetX:u,targetY:d,offscreen:l.edge}]})});return r.length===0?null:(0,$.jsx)(`svg`,{className:`world-conversation-connector`,"aria-hidden":`true`,width:y.width,height:y.height,viewBox:`0 0 ${y.width} ${y.height}`,preserveAspectRatio:`none`,children:r.map(({id:e,windowId:t,kind:n,path:r,targetX:i,targetY:a,offscreen:o})=>(0,$.jsxs)(`g`,{"data-anchor":n,"data-window-id":t,"data-offscreen":o??void 0,children:[(0,$.jsx)(`path`,{"data-anchor":n,"data-window-id":t,"data-offscreen":o??void 0,d:r}),(0,$.jsx)(`circle`,{"data-anchor":n,"data-window-id":t,"data-offscreen":o??void 0,cx:i,cy:a,r:`4`})]},e))})})();return(0,$.jsxs)(`div`,{ref:o,className:`world-stage-shell`,children:[(0,$.jsxs)(`header`,{className:`stage-bar world-stage-bar`,children:[(0,$.jsx)(`button`,{className:`icon-btn`,type:`button`,"aria-label":t.compact?`Back to Herdr sidebar`:`Toggle sidebar`,title:t.compact?`Back to sidebar`:`Toggle sidebar`,onClick:t.compact?t.onBackToSidebar:t.onToggleSidebar,children:t.compact?(0,$.jsx)(s,{size:20}):(0,$.jsx)(a,{size:18})}),(0,$.jsxs)(`div`,{className:`stage-id`,children:[(0,$.jsx)(`span`,{className:`stage-title`,children:`Pixel Office`}),(0,$.jsx)(`span`,{className:`stage-sub`,children:`Shared Herdr state · live board in CEO Office`})]}),(0,$.jsx)(`button`,{className:`icon-btn`,type:`button`,"aria-label":`Reset office view`,title:`Reset view`,onClick:()=>i.current?.scrollTo({top:0,left:0,behavior:`auto`}),children:(0,$.jsx)(c,{size:16})})]}),t.compact?(0,$.jsx)(kd,{projection:e,selectedKey:t.selectedKey,onSelect:t.onSelect,onActivateAgent:n,onActivateRoom:r}):null,(0,$.jsx)(`div`,{ref:i,className:`world-stage-scroll`,role:`region`,"aria-label":`Scrollable Pixel Office scene`,tabIndex:0,children:(0,$.jsxs)(Lu,{projection:e,observability:t.observability,selectedKey:t.selectedKey,completionSeenKeys:t.completionSeenKeys,conversationTargets:O,onSelect:t.onSelect,onActivateAgent:n,onActivateRoom:r,canCreateSeat:t.canCreateSeat,onNewSeat:t.onNewSeat,onLayoutChange:g,onCanvasRendered:v,roomAlignment:t.roomAlignment,longRoomTitleMode:t.longRoomTitleMode,onHover:M,onAnchorChange:e=>m(e??{}),onSelectedAnchorChange:N,children:[(0,$.jsx)(Pd,{className:`world-canvas-agent-bar`,projection:e,selectedKey:t.selectedKey,barWidth:A?.width??d.agentBarPreferredWidth,barHeight:A?.height??d.ceoBandHeight-4,left:A?.x,top:A?.y,interactive:j,onSelect:t.onSelect,onActivateAgent:n}),h?(0,$.jsx)(Dd,{layout:h,projection:e,selectedKey:t.selectedKey,interactive:j,onSelect:t.onSelect,onActivateAgent:n,onActivateRoom:r,onHover:M}):null,h?(0,$.jsx)(Md,{layout:h,projection:e,selectedRoomKey:k,context:t,canvasRenderedRevision:_}):null]})}),t.selectedKey&&w?(0,$.jsx)(jd,{callout:S(e,t.selectedKey),left:w.left,top:w.top,persistent:!0}):null,x&&!(x.key===t.selectedKey&&S(e,x.key)?.summary)?(0,$.jsx)(jd,{callout:S(e,x.key),left:x.left,top:x.top}):null,P]})}function Dd({layout:e,projection:t,selectedKey:n,interactive:r,onSelect:i,onActivateAgent:a,onActivateRoom:o,onHover:s}){let c=vd(t,e);return(0,$.jsx)(`div`,{className:`world-semantic-targets-overlay`,"aria-label":`Office scene targets`,"aria-hidden":!r,children:c.map(e=>(0,$.jsx)(`button`,{className:`world-semantic-target`,type:`button`,"data-kind":e.kind,"data-target-key":e.key,"aria-label":e.label,"aria-pressed":n===e.key,disabled:!r,title:e.label,style:{left:`${e.rect.x}px`,top:`${e.rect.y}px`,width:`${e.rect.width}px`,height:`${e.rect.height}px`},onClick:()=>i(e.key),onPointerMove:t=>s({key:e.key,clientX:t.clientX,clientY:t.clientY}),onPointerLeave:()=>s(null),onDoubleClick:()=>{e.canActivate&&(e.kind===`agent`?a(e.key):e.kind===`room`&&o(e.key))}},`${e.kind}:${e.key}`))})}var Od=y.rosterPage;function kd({projection:e,selectedKey:t,onSelect:n,onActivateAgent:r,onActivateRoom:i}){let a=(0,q.useRef)(null),o=e.roster.slice(0,Od),s=e.roomRoster.slice(0,Od),c=e.deskRoster.slice(0,Od),l=e=>{n(e),a.current?.removeAttribute(`open`)},u=e=>{e(),a.current?.removeAttribute(`open`)};return(0,$.jsxs)(`details`,{ref:a,className:`world-compact-target-chooser`,children:[(0,$.jsxs)(`summary`,{children:[(0,$.jsx)(`span`,{children:`Office targets`}),(0,$.jsxs)(`small`,{children:[e.roster.length,` agents · `,e.roomRoster.length,` rooms`]})]}),(0,$.jsxs)(`div`,{className:`world-compact-target-panel`,children:[(0,$.jsx)(Ad,{title:`Agents`,total:e.roster.length,shown:o.length,children:o.map(({agent:e,roomLabel:n,hostLabel:i})=>{let a=e.stale?`stale`:e.stateLabels[e.semanticStatus]??e.semanticStatus;return(0,$.jsxs)(`li`,{children:[(0,$.jsxs)(`button`,{type:`button`,className:`world-compact-target-select`,"data-target-key":e.key,"aria-pressed":t===e.key,onClick:()=>l(e.key),children:[(0,$.jsx)(`strong`,{children:e.displayLabel}),(0,$.jsxs)(`span`,{children:[a,` · `,n,` · `,i]}),e.taskSummary?(0,$.jsx)(`small`,{children:e.taskSummary}):null]}),e.canOpenInSpaces?(0,$.jsx)(`button`,{type:`button`,className:`world-compact-target-open`,"aria-label":`Open ${e.displayLabel} in Spaces`,onClick:()=>u(()=>r(e.key)),children:`Open`}):null]},e.key)})}),(0,$.jsx)(Ad,{title:`Rooms`,total:e.roomRoster.length,shown:s.length,children:s.map(e=>(0,$.jsxs)(`li`,{children:[(0,$.jsxs)(`button`,{type:`button`,className:`world-compact-target-select`,"data-target-key":e.key,"aria-pressed":t===e.key,onClick:()=>l(e.key),children:[(0,$.jsx)(`strong`,{children:e.displayLabel}),(0,$.jsxs)(`span`,{children:[e.stale?`stale · `:``,e.hostLabel]})]}),e.canOpenInSpaces?(0,$.jsx)(`button`,{type:`button`,className:`world-compact-target-open`,"aria-label":`Open room ${e.displayLabel} in Spaces`,onClick:()=>u(()=>i(e.key)),children:`Open`}):null]},e.key))}),(0,$.jsx)(Ad,{title:`Desks`,total:e.deskRoster.length,shown:c.length,children:c.map(({desk:e,roomLabel:n,hostLabel:r})=>(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,className:`world-compact-target-select`,"data-target-key":e.key,"aria-pressed":t===e.key,onClick:()=>l(e.key),children:[(0,$.jsx)(`strong`,{children:e.displayLabel}),(0,$.jsxs)(`span`,{children:[n,` · `,r]})]})},e.key))})]})]})}function Ad({title:e,total:t,shown:n,children:r}){return t===0?null:(0,$.jsxs)(`section`,{className:`world-compact-target-section`,"aria-labelledby":`world-targets-${e.toLowerCase()}`,children:[(0,$.jsx)(`h3`,{id:`world-targets-${e.toLowerCase()}`,children:e}),(0,$.jsx)(`ul`,{children:r}),t>n?(0,$.jsxs)(`p`,{children:[`Showing `,n,` of `,t,` `,e.toLowerCase(),`.`]}):null]})}function jd({callout:e,left:t,top:n,persistent:r=!1}){return e?(0,$.jsxs)(`div`,{className:`world-canvas-callout${r?` world-canvas-callout-persistent`:``}`,"data-kind":e.kind,"data-status":e.status??void 0,style:{left:`${t}px`,top:`${n}px`},role:r?`status`:`tooltip`,"aria-live":r?`polite`:void 0,children:[(0,$.jsx)(`strong`,{children:e.title}),e.summary?(0,$.jsx)(`span`,{className:`world-canvas-callout-summary`,children:e.summary}):null,(0,$.jsx)(`span`,{children:e.detail})]}):null}function Md({layout:e,projection:t,selectedRoomKey:n,context:r,canvasRenderedRevision:i}){let a=e.layoutRevision>0&&e.layoutRevision===i,s=e.rooms.reduce((e,t)=>Math.max(e,t.y+t.height),e.roomStartY);return(0,$.jsxs)(`div`,{className:`world-room-actions-overlay`,"aria-label":`Office room actions`,children:[e.overflowMarker?(0,$.jsx)(`div`,{className:`sr-only`,role:`status`,"aria-live":`polite`,children:e.overflowMarker.label}):null,t.rooms.map((t,n)=>{let i=e.rooms.find(({index:e})=>e===n);if(!i)return null;let s=a,c=i.header;return(0,$.jsxs)(`div`,{className:`world-room-actions${s?``:` world-room-actions-stale`}`,"aria-hidden":!s,style:{left:`${i.headerRect.x}px`,top:`${i.headerRect.y}px`,width:`${i.headerRect.width}px`,height:`${i.headerRect.height}px`},children:[(0,$.jsx)(`button`,{className:`world-room-overlay-action world-room-overlay-action-rename`,type:`button`,"aria-label":`Rename room ${t.accessibleLabel??t.displayLabel}`,title:`Rename ${t.accessibleLabel??t.displayLabel}`,disabled:!s||!r.canRenameRoom(t.key),style:{left:`${c?.renameX??Math.max(0,i.headerRect.width-52)}px`,top:`2px`},onClick:()=>r.onRenameRoom(t.key),children:(0,$.jsx)(dt,{size:12,"aria-hidden":`true`})}),(0,$.jsx)(`button`,{className:`world-room-overlay-action world-room-overlay-action-danger`,type:`button`,"aria-label":`Close room ${t.accessibleLabel??t.displayLabel}`,title:`Close ${t.accessibleLabel??t.displayLabel}`,disabled:!s||!r.canCloseRoom(t.key),style:{left:`${c?.closeX??Math.max(0,i.headerRect.width-d.roomHeaderActionWidth)}px`,top:`2px`},onClick:()=>r.onCloseRoom(t.key),children:(0,$.jsx)(o,{size:12,"aria-hidden":`true`})})]},t.key)}),t.rooms.map((t,n)=>{let i=e.rooms.find(({index:e})=>e===n);if(!i||!r.canCreateSeat(t.key))return null;let o=t.desks.length>=d.desksPerRoom,s=o?{x:i.x+i.width/2,deskY:i.y+i.height-40}:w(i,t.desks.length);return(0,$.jsx)(`button`,{className:`world-new-seat-canvas-action${o?` world-new-seat-canvas-action-full`:``}`,type:`button`,"aria-label":o?`${t.accessibleLabel??t.displayLabel} room full`:`New seat in ${t.accessibleLabel??t.displayLabel}`,title:o?`${t.accessibleLabel??t.displayLabel} is full`:`Start a new seat in ${t.accessibleLabel??t.displayLabel}`,disabled:!a||o,style:{left:`${s.x-25}px`,top:`${s.deskY}px`},onClick:()=>r.onNewSeat(t.key)},`${t.key}:new-seat`)}),(0,$.jsx)(`div`,{className:`sr-only`,"aria-label":`Office room names`,children:t.rooms.map(e=>{let n=t.hosts.find(({key:t})=>t===e.hostKey);return(0,$.jsxs)(`span`,{children:[e.accessibleLabel??e.displayLabel,` — `,n?.accessibleLabel??n?.displayLabel??`host unavailable`]},`${e.key}:semantic-name`)})}),r.canCreateRoom(n??void 0)?(0,$.jsxs)(`button`,{className:`world-new-room-canvas-action`,type:`button`,"aria-label":`New room`,title:`Create a new Herdr workspace`,disabled:!a,style:{left:`${e.officeWidth/2-28}px`,top:`${s+8}px`},onClick:()=>r.onCreateRoom(n??void 0),children:[(0,$.jsx)(_,{size:24,"aria-hidden":`true`}),(0,$.jsx)(`span`,{children:`NEW ROOM`})]}):null]})}function Nd(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.onSelect==`function`&&typeof t.onBackToSidebar==`function`&&typeof t.onToggleSidebar==`function`&&typeof t.onOpenInSpaces==`function`&&(t.roomAlignment===`left`||t.roomAlignment===`center`||t.roomAlignment===`right`)&&(t.longRoomTitleMode===`expand`||t.longRoomTitleMode===`compact`)&&typeof t.canCreateSeat==`function`&&typeof t.onNewSeat==`function`&&typeof t.canCreateRoom==`function`&&typeof t.onCreateRoom==`function`&&typeof t.canRenameRoom==`function`&&typeof t.onRenameRoom==`function`&&typeof t.canCloseRoom==`function`&&typeof t.onCloseRoom==`function`&&!!t.projection}function Pd({className:e,projection:t,selectedKey:n,barWidth:r,barHeight:i,left:a,top:o,interactive:s,onSelect:c,onActivateAgent:l}){let u=t.barAgents.filter(({semanticStatus:e})=>e===`idle`).length,d=t.barAgents.filter(({semanticStatus:e})=>e===`blocked`).length,f=t.coverage.omittedBarAgents,p=Math.max(3,Math.floor(Math.max(0,r-106)/56)),m=Math.max(2,Math.floor(Math.max(1,i-102)/56));return(0,$.jsxs)(`section`,{className:`world-office-overview${e?` ${e}`:``}`,"aria-label":`Agent Bar`,"aria-hidden":!s,style:{width:`${r}px`,height:`${i}px`,...a===void 0?{}:{left:`${a}px`,right:`auto`},...o===void 0?{}:{top:`${o}px`},visibility:s?`visible`:`hidden`},children:[(0,$.jsxs)(`div`,{className:`world-overview-heading`,children:[(0,$.jsx)(`strong`,{children:`Agent Bar`}),(0,$.jsxs)(`span`,{children:[t.barAgents.length,` visible · `,u,` idle · `,d,` needs input`]})]}),(0,$.jsxs)(`ul`,{className:`world-agent-bar`,"aria-label":`Agent Bar`,style:{gridTemplateColumns:`repeat(${p}, minmax(0, 1fr))`,gridTemplateRows:`repeat(${m}, minmax(0, 1fr))`},children:[t.barAgents.length===0?(0,$.jsx)(`li`,{className:`world-agent-bar-empty`,children:`No completed or waiting agents`}):t.barAgents.map(e=>{let t=e.stale?`stale`:e.semanticStatus,r=e.stale?`STALE`:e.stateLabels[e.semanticStatus]??e.semanticStatus.toUpperCase();return(0,$.jsx)(`li`,{className:`world-agent-bar-item-shell`,children:(0,$.jsxs)(`button`,{className:`world-agent-bar-item`,type:`button`,"aria-pressed":n===e.key,"data-status":t,disabled:!s,title:e.taskSummary??`${e.displayLabel} · ${r}`,onClick:()=>c(e.key),onDoubleClick:()=>l(e.key),children:[(0,$.jsx)(`img`,{className:`world-agent-bar-avatar`,src:`/world/characters/${e.characterIndex+1}-D-1.png`,alt:``,"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:`world-agent-bar-name`,children:e.displayLabel}),(0,$.jsx)(`span`,{className:`world-agent-bar-state`,children:r})]})},e.key)}),f>0?(0,$.jsxs)(`li`,{className:`world-agent-bar-overflow`,children:[`+`,f,` more in roster`]}):null]})]})}export{Vt as S,rn as _,to as a,Ut as b,Ua as c,oa as d,Hi as f,gr as g,_r as h,pd as i,Aa as l,yr as m,Nd as n,Ya as o,br as p,md as r,Ja as s,Cd as t,ca as u,nn as v,Ht as x,Wt as y};
|