!function(){var e,t,n,s={"../../../node_modules/css-loader/dist/cjs.js!./src/index.module.css":function(e,t,n){"use strict";var s=n("../../../node_modules/css-loader/dist/runtime/noSourceMaps.js"),o=n.n(s),i=n("../../../node_modules/css-loader/dist/runtime/api.js"),r=n.n(i)()(o());r.push([e.id,"html,\nbody {\n margin: 0;\n height: 100%;\n min-height: 100%;\n}\n\nbody {\n background-color: black;\n}\n\n.DtpFOcfmOO_1A9_qK1jy {\n width: 100%;\n height: 100%;\n display: flex;\n flex-direction: column;\n align-items: stretch;\n justify-content: flex-start;\n}\n",""]),r.locals={root:"DtpFOcfmOO_1A9_qK1jy"},t.Z=r},"./src/index.ts":function(e,t,n){"use strict";var s=n("../../babs/core/lib/common/debug_flags.js"),o=n("../../babs/core/lib/game/game_engine.js"),i=n("../../common/lib/check.js"),r=n("../../common/lib/env.js"),a=n("../../common/lib/identity.js"),c=n("../../common/lib/logging.js"),l=JSON.parse('{"vc":{"QB":"ld51","iU":"/ld51"}}'),u=n("../../../node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js"),d=n.n(u),h=n("../../../node_modules/style-loader/dist/runtime/styleDomAPI.js"),f=n.n(h),m=n("../../../node_modules/style-loader/dist/runtime/insertBySelector.js"),p=n.n(m),b=n("../../../node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js"),g=n.n(b),y=n("../../../node_modules/style-loader/dist/runtime/insertStyleElement.js"),v=n.n(y),w=n("../../../node_modules/style-loader/dist/runtime/styleTagTransform.js"),x=n.n(w),C=n("../../../node_modules/css-loader/dist/cjs.js!./src/index.module.css"),j={};j.styleTagTransform=x(),j.setAttributes=g(),j.insert=p().bind(null,"head"),j.domAPI=f(),j.insertStyleElement=v(),d()(C.Z,j);var S=C.Z&&C.Z.locals?C.Z.locals:void 0;const _=l.vc.QB,k=l.vc.iU;function E(){const e=new Proxy(new URLSearchParams(window.location.search),{get:(e,t)=>e.get((0,i.$1)(t,a.HD))}),t=window.location.hash?window.location.hash.slice(1):void 0;return e.game??t??_}async function O(e){return console.log(`Loading game: ${e}`),(await n("../../babs/scenes/src lazy recursive ^\\.\\/.*\\/index\\.ts$ include: index\\.ts$")(`./${e}/index.ts`)).default}(async()=>{const e=document.createElement("canvas");e.className=S.root,document.body.appendChild(e);let t="/";r.P||(t="/"),await async function(e){(0,c.cM)("version",{build:s.qg,isProd:r.P});const t=new o.dA(e,O,_);await t.start(),window.addEventListener("hashchange",(()=>{t.loadApp(E())})),await t.loadApp(E())}({canvas:e,urlBase:k,assetPrefix:t})})().catch((0,c.H)("main"))},"./src/inspector.ts":function(e,t,n){"use strict";n("../../../node_modules/@babylonjs/inspector/dist/babylon.inspector.bundle.max.js")},"../../babs/scenes/src lazy recursive ^\\.\\/.*\\/index\\.ts$ include: index\\.ts$":function(e,t,n){var s={"./demolition/index.ts":["../../babs/scenes/src/demolition/index.ts",782],"./infra/index.ts":["../../babs/scenes/src/infra/index.ts",381],"./jukebox/index.ts":["../../babs/scenes/src/jukebox/index.ts",947],"./ld51/index.ts":["../../babs/scenes/src/ld51/index.ts",46],"./roguerally/index.ts":["../../babs/scenes/src/roguerally/index.ts",893],"./template/index.ts":["../../babs/scenes/src/template/index.ts",338],"./unladen/index.ts":["../../babs/scenes/src/unladen/index.ts",868]};function o(e){if(!n.o(s,e))return Promise.resolve().then((function(){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}));var t=s[e],o=t[0];return n.e(t[1]).then((function(){return n(o)}))}o.keys=function(){return Object.keys(s)},o.id="../../babs/scenes/src lazy recursive ^\\.\\/.*\\/index\\.ts$ include: index\\.ts$",e.exports=o},"?51d3":function(){},"?eb2f":function(){},"../../babs/core/lib/audio/audio_asset.js":function(e,t,n){"use strict";n.d(t,{W:function(){return l}});var s=n("../../common/lib/core.js"),o=n("../../common/lib/identity.js"),i=n("../../babs/core/lib/common/asset.js");const r=(0,o.SC)().withDefaults({loop:!1,spatial:!1,autoPlay:!1,volumeFactor:1}),a=(0,o.SC)().withDefaults({play:!1});let c=0;class l extends i.x{constructor(e,t,n,s){super(e,t,n),this.settings=r.apply(s??{}),this.onDispose((()=>delete this.sound_))}share(){return(0,s.ro)(this.sound_)}clone(e,t){const n=a.apply(t??{}),o=(0,s.ro)(this.sound_),i=o.clone();if(!i)return;e.acquire(i);const r=n?.baseName??o.name,l=n?.attachToMesh;return l?(i.attachToMesh(l),i.name=`${l.name}.${r}`):i.name=`${r}.${c++}`,n.play&&i?.play(),i}setSound(e){this.sound_=e,this.sound_.setVolume(this.settings.volumeFactor),this.settings.autoPlay&&this.sound_.play()}}},"../../babs/core/lib/audio/audio_manager.js":function(e,t,n){"use strict";n.d(t,{LN:function(){return g}});var s=n("../../../node_modules/@babylonjs/core/index.js"),o=n("../../common/lib/logging.js"),i=n("../../common/lib/units.js"),r=n("../../babs/core/lib/common/gauge.js"),a=n("../../babs/core/lib/common/manager.js"),c=n("../../babs/core/lib/common/resource.js"),l=n("../../babs/core/lib/game/game_engine.js"),u=n("../../babs/core/lib/input/input.js"),d=n("../../babs/core/lib/audio/audio_asset.js");const h=(0,u.Qw)(c.fi,"muted","KeyM",{persist:!0}),f=i.UH.of(70,i.gG),m=new r.a(c.fi,"volume",{defaultValue:f,minimum:i.gG.zero,maximum:i.UH.of(100,i.gG),persist:!0}),p=i.UH.of(10,i.gG);u.II.register(c.fi,"volume: increase",{keys:"Equal",valued:m}).onClick(c.fi,(()=>{h.value?(m.value=p,h.value=!1):m.increment(p)})),u.II.register(c.fi,"volume: decrease",{keys:"Minus",valued:m}).onClick(c.fi,(()=>{h.value||(m.value.isLessThanOrEqualTo(p)?(h.value=!0,m.value=f):m.decrement(p))}));const b=()=>s.Vector3.Zero();class g extends a.dK{constructor(e){super(e,d.W)}setSpatialAudioListener(e,t,n){(0,o.cM)("Spatial Audio",{listener:t.name}),e.audioListenerPositionProvider=n,t.onDispose((()=>{e.audioListenerPositionProvider===n&&((0,o.cM)("Spatial Audio",{listener:"[0,0,0]"}),e.audioListenerPositionProvider=b)}))}onInit(){s.Engine.audioEngine?(l.dA.Paused.onChanged(this,(()=>this.syncVolume()),{immediate:!0}),h.onChanged(this,(e=>{console.log(e?"Muted.":`Unmuted. Volume level is ${String(m.value)}`),this.syncVolume()}),{immediate:!0}),m.onChanged(this,(e=>{h.value||console.log(`Volume level is ${String(e)}`),this.syncVolume()})),this.onNotify(s.Engine.audioEngine.onAudioUnlockedObservable,(()=>{console.log("Audio unlocked."),this.syncVolume()})),this.syncVolume()):console.error("No audio engine.")}onProcess(e,t){e.fetch(t,((n,o)=>{t.setSound(new s.Sound(t.name,n,e.scene,o(),{loop:t.settings.loop,spatialSound:t.settings.spatial,distanceModel:"inverse",refDistance:i.UH.of(5,i.J4).value,maxDistance:i.UH.of(100,i.J4).value,rolloffFactor:1}))}))}syncVolume(){const e=h.value;s.Engine.audioEngine?.setGlobalVolume(e?0:m.value.value)}}g.I=new g(c.fi)},"../../babs/core/lib/common/asset.js":function(e,t,n){"use strict";n.d(t,{x:function(){return o}});var s=n("../../babs/core/lib/common/resource.js");class o extends s.$9{constructor(e,t,n){super(e,t),this.urlPath=n}}},"../../babs/core/lib/common/color.js":function(e,t,n){"use strict";n.d(t,{DG:function(){return r},H_:function(){return o},NC:function(){return i},Pf:function(){return a},nV:function(){return l}});var s=n("../../../node_modules/@babylonjs/core/index.js");function o(e){return 7===e.length?s.Color3.FromHexString(e):s.Color4.FromHexString(e)}function i(e){return e.toHexString()}function r(e,t){const n=t?.(e)??{},s={...e,...n};return Object.freeze(s)}const a=r({turquoise:"#1abc9c",emerald:"#2ecc71",peterRiver:"#3498db",amethyst:"#9b59b6",wetAsphalt:"#34495e",greenSea:"#16a085",nephritis:"#27ae60",belizeHole:"#2980b9",wisteria:"#8e44ad",midnightBlue:"#2c3e50",sunFlower:"#f1c40f",carrot:"#e67e22",alizarin:"#e74c3c",clouds:"#ecf0f1",concrete:"#95a5a6",orange:"#f39c12",pumpkin:"#d35400",pomegranate:"#c0392b",silver:"#bdc3c7",asbestos:"#7f8c8d"});const c=Object.freeze(new s.Color3(1,1,1));function l(e,t,n){return function(e,t,n,o){return o??(o=new s.Color3),n??(n=t.a??1),o.r=e.r+(t.r-e.r)*n,o.g=e.g+(t.g-e.g)*n,o.b=e.b+(t.b-e.b)*n,o}(e,c,t,n)}},"../../babs/core/lib/common/debug_flags.js":function(e,t,n){"use strict";n.d(t,{Mz:function(){return l},cG:function(){return d},qg:function(){return a}});var s=n("../../common/lib/env.js"),o=n("../../common/lib/identity.js"),i=n("../../babs/core/lib/input/input.js"),r=n("../../babs/core/lib/common/resource.js");const a="1.9",c=(0,o.Pn)()({enableHighlightLayer:{key:"Alt+H"},showAnimationChange:{key:"Alt+A"},showAxes:{key:"Alt+X"},showColliders:{key:"Alt+C"},showRays:{key:"Shift+R"},showInspector:{key:"Alt+I"},showKeyEvents:{key:"Alt+K"},showPerfMetrics:{key:"Alt+P"},showKeymap:{key:"AltLeft"},logNextFrame:{key:"Alt+F",mode:"ephemeral"},freeLook:{key:"ScrollLock",persist:!1}}),l=(0,o.Yl)(c,((e,t)=>function(e,t,n){const o=n?.mode??"stateful",r=!s.P&&(n?.persist??"stateful"===o),a=s.P?void 0:n?.key;return(0,i.Qw)(e,`debug.${t}`,a,{mode:o,persist:r,...n,validate:e=>!s.P&&e})}(r.fi,t,e))),u=(0,o.QK)(l,(e=>()=>e.value)),d=Object.freeze(Object.assign(u,{true:!0,false:!1}))},"../../babs/core/lib/common/flag.js":function(e,t,n){"use strict";n.d(t,{W:function(){return j}});var s=n("../../../node_modules/@babylonjs/core/index.js"),o=n("../../common/lib/check.js"),i=n("../../common/lib/errors.js"),r=n("../../common/lib/identity.js"),a=n("../../common/lib/iterators.js");class c extends i.sH{}function l(...e){return e.join("/")}class u{constructor(e,t){this.bucket_=e,this.prefix_=void 0!==t?t+"/":""}folder(...e){return new u(this.bucket_,this.prefix_+l(...e))}list(){const e=(0,a.NT)(this.bucket_.list(),(e=>e.startsWith(this.prefix_))),t=(0,a.lT)(e,(e=>e.slice(this.prefix_.length)));return(0,a.NT)(t,(e=>!e.includes("/")))}get(e,t){const n=this.bucket_.get(this.prefix_+e);if(void 0!==n){const e=JSON.parse(n);if(t){if(t(e))return e}else if("string"==typeof e)return e}}set(e,t){return this.bucket_.set(this.prefix_+e,JSON.stringify(t))}delete(e){return this.bucket_.delete(this.prefix_+e)}clear(){(0,a.Ed)(this.list(),(e=>this.delete(e)))}}class d{constructor(e){this.store_=e}list(){const e=(0,a.Hb)(this.store_.length),t=(0,a.lT)(e,(e=>this.store_.key(e)));return(0,a.NT)(t,r.EN)}get(e){return this.store_.getItem(e)??void 0}set(e,t){this.store_.setItem(e,t)}delete(e){this.store_.removeItem(e)}clear(){this.store_.clear()}}class h{constructor(){this.values_=new Map}list(){return this.values_.keys()}get(e){return this.values_.get(e)}set(e,t){this.values_.set(e,t)}delete(e){this.values_.delete(e)}clear(){this.values_.clear()}}function f(e){let t;try{t=window[e];const n="__storage_test__";return t.setItem(n,n),t.removeItem(n),!0}catch(e){return e instanceof DOMException&&(22===e.code||1014===e.code||"QuotaExceededError"===e.name||"NS_ERROR_DOM_QUOTA_REACHED"===e.name)&&void 0!==t&&0!==t.length}}const m=["localStorage","sessionStorage","memory"];let p;var b=n("../../babs/core/lib/common/resource.js");class g extends b._z{constructor(e,t){const n=l(e.name,t);super(e,n),this.path=t,this.store=new u(function(e,t=!0){for(let n=(0,o.vD)(m.indexOf(e),-1);n(0,r.$O)(t,g)&&t.path===e}(t))??new g(e,t)}}var y,v,w,x=function(e,t,n,s,o){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?o.call(e,n):o?o.value=n:t.set(e,n),n},C=function(e,t,n,s){if("a"===n&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?s:"a"===n?s.call(e):s?s.value:t.get(e)};class j{constructor(e,t,n){if(this.scope=e,this.name=t,y.set(this,void 0),v.set(this,new s.Observable),w.set(this,void 0),x(this,w,n.validate??r.yR,"f"),(0,r.$K)(n.defaultValue)?x(this,y,(0,o.ro)(C(this,w,"f").call(this,n.defaultValue),(()=>`Flag (${t}) defaultValue (${String(n.defaultValue)}) does not pass validation.`)),"f"):x(this,y,n.defaultValue,"f"),n.persist){const s=n.persist,o=g.get(e,"flags"),i=o.store.get(t,s.guard),a=void 0!==i?s.deserialize(i):void 0,c=(0,r.$K)(a)?C(this,w,"f").call(this,a):void 0;void 0!==c&&x(this,y,c,"f"),this.onChanged(e,(e=>{const n=s.serialize(e);void 0===n?o.store.delete(t):o.store.set(t,n)}))}}get value(){return C(this,y,"f")}set value(e){(0,r.$K)(e)&&(e=C(this,w,"f").call(this,e)??C(this,y,"f")),e!==C(this,y,"f")&&(x(this,y,e,"f"),C(this,v,"f").notifyObservers(e))}onChanged(e,t,n){if(n?.predicate){const e=t,s=n?.predicate;t=t=>s(t)?e(t):void 0}const s=e.onNotify(C(this,v,"f"),t);s&&n?.immediate&&C(this,v,"f").notifyObserver(s,C(this,y,"f"))}}y=new WeakMap,v=new WeakMap,w=new WeakMap},"../../babs/core/lib/common/gauge.js":function(e,t,n){"use strict";n.d(t,{a:function(){return a}});var s=n("../../common/lib/check.js"),o=n("../../common/lib/identity.js"),i=n("../../common/lib/units.js"),r=n("../../babs/core/lib/common/flag.js");class a extends r.W{constructor(e,t,n){const r=n.units??n.defaultValue?.unit;(0,s.cW)(r);const a={defaultValue:n.defaultValue??r.zero};n.persist&&(a.persist={guard:o.hj,serialize:e=>e.quantity,deserialize:e=>i.UH.of(e,r)}),n.minimum&&n.maximum&&(0,s.BF)(n.minimum.isLessThan(n.maximum),`minimum (${String(n.minimum)}) must be less than or equal to maximum (${String(n.maximum)})`),a.validate=e=>n.minimum&&e.isLessThan(n.minimum)?n.minimum.to(r):n.maximum&&n.maximum.isLessThan(e)?n.maximum.to(r):e.to(r),super(e,t,a),this.units=r}increment(e=this.units.one){this.value=this.value.plus(e)}decrement(e=this.units.one){this.value=this.value.minus(e)}scale(e){this.value=this.value.scale(e)}}},"../../babs/core/lib/common/group.js":function(e,t,n){"use strict";n.d(t,{P2:function(){return c},ZA:function(){return r},_9:function(){return d},fb:function(){return u},lX:function(){return f},mA:function(){return l},ul:function(){return m},uv:function(){return h}});var s=n("../../common/lib/check.js"),o=n("../../common/lib/containers.js"),i=n("../../common/lib/logging.js");class r{constructor(e){this.name=e,this.id=(0,s.r0)(r.nextGroupId++,31),this.mask=1<e|t.mask),0)}function c(...e){return{layerMask:a(...e)}}r.nextGroupId=0;const l=Object.freeze(c());function u(e,...t){const n=a(...t);(0,o._2)(e).forEach((e=>e.layerMask=n))}function d(e,...t){const n=a(...t);(0,o._2)(e).forEach((e=>e.layerMask|=n))}function h(e,...t){const n=~a(...t);(0,o._2)(e).forEach((e=>e.layerMask&=n))}function f(e,t){const n=t.mask;return 0!=(e.layerMask&n)}function m(e,t){const n=t.layerMask;return(e.layerMask&n)===n}},"../../babs/core/lib/common/logging.js":function(e,t,n){"use strict";n.d(t,{Q:function(){return r},t:function(){return a}});var s=n("../../../node_modules/@babylonjs/core/index.js"),o=n("../../common/lib/logging.js"),i=n("../../babs/core/lib/common/units.js");function r(){(0,o.hX)(s.UniformBuffer,s.Observable),(0,o.AM)(i.f,(e=>[`%c(%c${(0,o.OS)(e.x.quantity,2)}%c${e.x.unit.label}%c x %c${(0,o.OS)(e.y.quantity,2)}%c${e.y.unit.label}%c x %c${(0,o.OS)(e.z.quantity,2)}%c${e.z.unit.label}%c)`,o.B$.default,o.B$.number,o.B$.subtle,o.B$.default,o.B$.number,o.B$.subtle,o.B$.default,o.B$.number,o.B$.subtle,o.B$.default])),(0,o.AM)(i.w,(e=>[`%c(%c${(0,o.OS)(e.x.quantity,2)}%c${e.x.unit.label}%c, %c${(0,o.OS)(e.y.quantity,2)}%c${e.y.unit.label}%c, %c${(0,o.OS)(e.z.quantity,2)}%c${e.z.unit.label}%c)`,o.B$.default,o.B$.number,o.B$.subtle,o.B$.default,o.B$.number,o.B$.subtle,o.B$.default,o.B$.number,o.B$.subtle,o.B$.default])),(0,o.AM)(s.Vector2,(e=>[`%c(%c${(0,o.OS)(e.x,2)}%c, %c${(0,o.OS)(e.y,2)}%c)`,o.B$.default,o.B$.number,o.B$.default,o.B$.number,o.B$.default])),(0,o.AM)(s.Vector3,(e=>[`%c(%c${(0,o.OS)(e.x,2)}%c, %c${(0,o.OS)(e.y,2)}%c, %c${(0,o.OS)(e.z,2)}%c)`,o.B$.default,o.B$.number,o.B$.default,o.B$.number,o.B$.default,o.B$.number,o.B$.default])),(0,o.AM)(s.Color3,(e=>{let t=e.toHexString();return t=t.charAt(1)===t.charAt(2)&&t.charAt(3)===t.charAt(4)&&t.charAt(5)===t.charAt(6)?t.charAt(1)+t.charAt(3)+t.charAt(5):t.substring(1),[`%c#%c${t}`,`color: #${t}`,o.B$.subtle]})),(0,o.AM)(s.Color4,(e=>{let t=e.toHexString();return t=t.charAt(1)===t.charAt(2)&&t.charAt(3)===t.charAt(4)&&t.charAt(5)===t.charAt(6)&&t.charAt(7)===t.charAt(8)?t.charAt(1)+t.charAt(3)+t.charAt(5)+t.charAt(7):t.substring(1),[`%c#%c${t}`,`color: #${t}`,o.B$.subtle]}))}function a(e,t=2){return void 0===e?String(e):"z"in e?`(${(0,o.OS)(e.x,t)}, ${(0,o.OS)(e.y,t)}, ${(0,o.OS)(e.z,t)})`:`(${(0,o.OS)(e.x,t)}, ${(0,o.OS)(e.y,t)})`}},"../../babs/core/lib/common/manager.js":function(e,t,n){"use strict";n.d(t,{ZH:function(){return b},dK:function(){return f},pq:function(){return h},uy:function(){return d},wV:function(){return p}});var s=n("../../../node_modules/@babylonjs/core/index.js"),o=n("../../common/lib/check.js"),i=n("../../common/lib/identity.js"),r=n("../../common/lib/logging.js"),a=n("../../common/lib/units.js"),c=n("../../babs/core/lib/common/resource.js");const l=Symbol("assetLoadingLogId"),u=a.Lm.one.scale(.25);class d{constructor(e){this.unreadyAssets=0,[this.scope,this.scene,this.display,this.gameEngine,this.urlBase,this.engine]=[e.scope,e.scene,e.display,e.gameEngine,e.urlBase,e.engine],this.prototypes=new s.AssetContainer(e.scene),this.assetManager=new s.AssetsManager(e.scene),this.scope.onNotify(this.assetManager.onProgressObservable,(e=>{const t=e.totalCount-e.remainingCount;(0,r.cM)("Asset Loading",{total:e.totalCount,numCompleted:t,lastCompleted:e.task.name},{logId:l,rate:u})}))}fetch(e,t){const n=this.assetManager.addBinaryFileTask(e.name,`${this.urlBase}${e.urlPath}`);n.onSuccess=()=>t(n.data,(()=>this.onReadyToUse())),n.onError=(t,n)=>console.warn(`Failed to load asset ${e.urlPath}: ${n}`)}fetchMesh(e,t){const n=e.urlPath.lastIndexOf("/")+1,s=e.urlPath.slice(0,n),o=e.urlPath.slice(n),i=this.assetManager.addMeshTask(e.name,"",`${this.urlBase}${s}`,o);i.onSuccess=()=>{i.loadedAnimationGroups.forEach((e=>{this.prototypes.animationGroups.push(e),this.scene.removeAnimationGroup(e)})),i.loadedMeshes.forEach((e=>{this.prototypes.meshes.push(e),this.scene.removeMesh(e)})),i.loadedParticleSystems.forEach((e=>{this.prototypes.particleSystems.push(e),this.scene.removeParticleSystem(e)})),i.loadedSkeletons.forEach((e=>{this.prototypes.skeletons.push(e),this.scene.removeSkeleton(e)})),t(i.loadedMeshes,i.loadedAnimationGroups)},i.onError=(t,n)=>console.warn(`Failed to load mesh asset ${this.urlBase}${e.urlPath}: ${n}`)}fetchTexture(e,t){const n=this.assetManager.addTextureTask(e.name,`${this.urlBase}${e.urlPath}`);n.onSuccess=()=>{this.prototypes.textures.push(n.texture),this.scene.removeTexture(n.texture),t(n.texture)},n.onError=(t,n)=>console.warn(`Failed to load asset ${this.urlBase}${e.urlPath}: ${n}`)}fetchImage(e,t){const n=this.assetManager.addImageTask(e.name,e.urlPath);n.onSuccess=()=>t(n.image),n.onError=(t,n)=>console.warn(`Failed to load asset ${this.urlBase}${e.urlPath}: ${n}`)}onReadyToUse(){return this.unreadyAssets+=1,this.scope.name,this.unreadyAssets,()=>{0==--this.unreadyAssets&&(this.scope.name,this.unreadyAssets,this.allAssetsReady?.())}}async load(){this.scope.name,this.assetManager.autoHideLoadingUI=!1,await this.assetManager.loadAsync(),this.scope.name,this.unreadyAssets&&await new Promise((e=>this.allAssetsReady=e)),this.scope.name,this.engine.hideLoadingUI()}}class h extends d{constructor(e,t){super(t),this.canvas=e}}class f extends c.$9{constructor(e,t){super(e,`Manager of ${t.name}`),this.guard=(0,i.V9)(t)}onInit(e){}onScopeInit(e){}}const m=(0,i.V9)(f);function p(e){c.fi.forEachSubsidiary(m,(t=>{t.name,t.onInit(e),c.fi.forEachSubsidiary(t.guard,(n=>{e.scope.name,t.name,t.onProcess(e,n)}))}))}function b(e){(0,o.Yg)(e.scope,c.fi,"globalScope is processed in initializeManagers"),e.scope.name,c.fi.forEachSubsidiary(m,(t=>{e.scope.name,t.name,t.onScopeInit(e),e.scope.forEachSubsidiary(t.guard,(n=>{e.scope.name,t.name,t.onProcess(e,n)}))}))}},"../../babs/core/lib/common/resource.js":function(e,t,n){"use strict";n.d(t,{qd:function(){return P},$9:function(){return R},fi:function(){return I},_z:function(){return T},sX:function(){return S},f$:function(){return M},V2:function(){return j},U6:function(){return A}});var s=n("../../../node_modules/@babylonjs/core/index.js"),o=n("../../common/lib/errors.js");class i{constructor(){this.callbacks=[]}add(e){this.callbacks.push(e)}runOnce(...e){return this.doRun(e,!1)}run(...e){return this.doRun(e,!0)}doRun(e,t){const n=this.callbacks;t||(this.callbacks=[]),(0,o.f_)(n,(t=>t(...e)))}}var r,a,c,l,u,d,h=n("../../common/lib/check.js"),f=n("../../common/lib/containers.js"),m=n("../../common/lib/core.js"),p=n("../../common/lib/disposable.js"),b=n("../../common/lib/env.js"),g=n("../../common/lib/identity.js"),y=n("../../common/lib/iterators.js"),v=n("../../common/lib/units.js"),w=function(e,t,n,s,o){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?o.call(e,n):o?o.value=n:t.set(e,n),n},x=function(e,t,n,s){if("a"===n&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?s:"a"===n?s.call(e):s?s.value:t.get(e)};Symbol("Lifecycle")," ".repeat(10);const C=Symbol("This tag is for private use by the implementations in this file.");function j(e){const t=(0,g.$O)(e,s.Scene)?e:e.getScene();return t.metadata??(t.metadata={resources:new Set}),t.metadata}class S{constructor(e){r.set(this,void 0),this[a]={},void 0!==e&&w(this,r,e,"f")}get name(){return x(this,r,"f")?.startsWith(".")&&w(this,r,`${this.constructor.name}${x(this,r,"f")}`,"f"),x(this,r,"f")??this.constructor.name}typedName(){return void 0!==x(this,r,"f")?`${this.constructor.name}(${x(this,r,"f")})`:this.constructor.name}disposeResources(){this.doDisposalInternal(C,!1)}acquire(e){return e instanceof T?O(e,this):this.onAddInternal(C,e),e}forEach(e,t){this[C].disposables&&!this[C].disposalState&&(0,y.Ed)((0,y.NT)(this[C].disposables.values(),e),t)}get(e){if(!this[C].disposalState&&this[C].disposables)for(const t of this[C].disposables.values())if(e(t))return t}onDispose(e){var t;this[C].disposalState?e():((t=this[C]).callbacks??(t.callbacks=new i),this[C].callbacks.add(e))}onNotify(e,t){if(this[C].disposalState)return null;const n=e.add(t);return n&&this.onDispose((()=>{e.remove(n)})),n}onTimeout(e,t){var n;if(this[C].disposalState)return;const s=(n=this[C]).timeouts??(n.timeouts=[]);let o;o=setTimeout((()=>{(0,f.Od)(s,o),t()}),e.to(v.HA).quantity),this[C].timeouts.push(o)}onAddInternal(e,t){var n;return this[C].disposalState?(t.dispose(),!1):((n=this[C]).disposables??(n.disposables=new Set),(0,m.BF)(!this[C].disposables.has(t),(()=>`Disposable is already managed by ${this.name}.`)),this[C].disposables.add(t),!0)}onRemoveInternal(e,t){this[C].disposalState||(0,m.BF)(this[C].disposables?.delete(t)??!1)}doDisposalInternal(e,t){return this[C].disposalState?(t&&"partial"===this[C].disposalState&&(this[C].disposalState="full"),!1):(this[C].disposalState=t?"full":"partial",this[C].timeouts&&(this[C].timeouts.forEach((e=>clearTimeout(e))),delete this[C].timeouts),this[C].callbacks&&(this[C].callbacks.runOnce(),delete this[C].callbacks),this[C].disposables&&((0,o.f_)(this[C].disposables.values(),(e=>{(0,g.$O)(e,T)?k.call(e,this):e.dispose()})),delete this[C].disposables),"full"===this[C].disposalState||(delete this[C].disposalState,!1))}}r=new WeakMap,a=C;const _=new Map;function k(e){(0,h.M1)(_.get(this),e),_.delete(this),b.P||(0,g.$O)(e,S)||j(e).resources.delete(this),this.dispose()}function E(e){const t=_.get(e);t&&(_.delete(e),(0,g.$O)(t,S)?t.onRemoveInternal(C,e):(b.P||j(t).resources.delete(e),t.onDisposeObservable.removeCallback(k,e)))}function O(e,t){if(E(e),(0,g.$O)(t,S)){if(!t.onAddInternal(C,e))return}else{if(function(e){return"boolean"==typeof e.isDisposed?e.isDisposed:e.isDisposed()}(t))return void e.dispose();b.P||j(t).resources.add(e),t.onDisposeObservable.add(k,void 0,void 0,e,!0)}_.set(e,t)}class T extends S{constructor(e,t){void 0===t&&(0,g.$O)(e,s.Node)&&(t=e.name),super(t),O(this,e)}static update(e){x(T,c,"f",l).forEach((t=>t(e)))}onUpdate(e){"full"===this[C].disposalState||"disposed"===this[C].disposalState||(e?x(T,c,"f",l).set(this,e):x(T,c,"f",l).delete(this))}dispose(){return this.doDisposalInternal(C,!0),"You must call super.dispose() when overriding Resource.dispose.\nPrefer to do cleanup using onDispose() instead."}doDisposalInternal(e,t){return!!super.doDisposalInternal(C,t)&&(E(this),x(T,c,"f",l).delete(this),this[C].disposalState="disposed",Object.freeze(this),!0)}}c=T,l={value:new Map};class $ extends T{static from(e){return e.metadata?.scope??new $(e)}constructor(e){super(e),e.metadata??(e.metadata={});const t=e.metadata;(0,m.BF)(void 0===t.scope),t.scope=this}}function A(e){return(0,g.$O)(e,S)?e:$.from(e)}class M extends S{constructor(e,t){super(e),u.set(this,void 0),t?.registerSubsidiary(this)}forEachSubsidiary(e,t){x(this,u,"f")&&x(this,u,"f").forEach((n=>e(n)?t(n):void 0))}disposeResources(){x(this,u,"f")&&(0,o.f_)(x(this,u,"f"),(e=>e.disposeResources())),super.disposeResources()}registerSubsidiary(e){w(this,u,x(this,u,"f")??[],"f"),x(this,u,"f").push(e)}}u=new WeakMap;class R extends M{constructor(e,t){super(t,e)}}const I=new M("global");class P extends p.v{constructor(e){super(),d.set(this,void 0);const t=()=>{w(this,d,void 0,"f"),e()};this.scheduler=()=>{void 0===x(this,d,"f")&&w(this,d,setTimeout(t,0),"f")}}dispose(){return void 0!==x(this,d,"f")&&(clearTimeout(x(this,d,"f")),w(this,d,void 0,"f")),super.dispose()}}d=new WeakMap},"../../babs/core/lib/common/units.js":function(e,t,n){"use strict";n.d(t,{f:function(){return r},w:function(){return i}});var s=n("../../../node_modules/@babylonjs/core/index.js"),o=n("../../common/lib/units.js");class i{constructor(e,t,n){this.x=e,this.y=t,this.z=n}static of(e,t){t??(t=o.J4);const n=o.UH.from(e.x,0,t),s=o.UH.from(e.y,0,t),r=o.UH.from(e.z,0,t);return new i(n,s,r)}scale(e){return i.of({x:this.x.scale(e.x??e.factor??0),y:this.y.scale(e.y??e.factor??0),z:this.z.scale(e.z??e.factor??0)})}plus(e){return i.of({x:this.x.plus(e.x),y:this.y.plus(e.y),z:this.z.plus(e.z)})}value(){return new s.Vector3(this.x.value,this.y.value,this.z.value)}toString(){return`(${this.x}, ${this.y}, ${this.z})`}}class r{constructor(e,t,n){this.x=e,this.y=t,this.z=n}static of(e,t){t??(t=o.J4);const n=o.UH.from(e.x,0,t),s=o.UH.from(e.y,0,t),i=o.UH.from(e.z,0,t);return new r(n,s,i)}scale(e){return r.of({x:this.x.scale(e.x??e.factor??0),y:this.y.scale(e.y??e.factor??0),z:this.z.scale(e.z??e.factor??0)})}scaledOffset(e){return i.of({x:this.x.scale(e.x??e.factor??0),y:this.y.scale(e.y??e.factor??0),z:this.z.scale(e.z??e.factor??0)})}value(){return new s.Vector3(this.x.value,this.y.value,this.z.value)}toString(){return`[${this.x}x${this.y}x${this.z}]`}}},"../../babs/core/lib/game/game_engine.js":function(e,t,n){"use strict";n.d(t,{XT:function(){return ne},dA:function(){return se}});var s=n("../../../node_modules/@babylonjs/core/index.js"),o=n("../../common/lib/disposable.js"),i=n("../../common/lib/logging.js"),r=n("../../common/lib/units.js"),a=n("../../babs/core/lib/common/color.js"),c=n("../../babs/core/lib/common/debug_flags.js"),l=n("../../babs/core/lib/common/logging.js"),u=n("../../babs/core/lib/common/manager.js"),d=n("../../babs/core/lib/common/resource.js"),h=n("../../common/lib/core.js"),f=n("../../common/lib/identity.js");class m{constructor(...e){this.roots=e,[this.initialStaticScopes,this.initialDisposables]=this.computeReachable()}computeDiff(){const[e,t]=this.computeReachable();return this.initialStaticScopes.forEach((t=>e.delete(t))),this.initialDisposables.forEach((e=>t.delete(e))),[e,t]}reportEntry(e,t,n){const s=`ResourceDiff(${this.roots.map((e=>e.scope.name)).join(", ")})`;(0,i.cM)(`${s} ${e} (${n.size} ${t})`,[...n],{density:n.size?"collapsed":"inline"})}report(){const[e,t]=this.computeDiff();e.size&&(this.reportEntry("static scopes","initial",this.initialStaticScopes),this.reportEntry("static scopes","unexpected",e)),t.size&&(this.reportEntry("disposables","initial",this.initialDisposables),this.reportEntry("disposables","undisposed",t))}computeReachable(){const e=new Set;for(const t of this.roots){e.add(t.scope);const n=(0,f.Bv)((()=>!0));t.scope.forEachSubsidiary(n,(t=>{e.add(t)}))}const t=new Set,n=[...e];for(const e of this.roots)e.scene&&(0,d.V2)(e.scene).resources.forEach((e=>{(0,h.BF)(!t.has(e)),t.add(e),n.push(e)}));const s=(0,f.Bv)((()=>!0));for(;n.length;)n.pop()?.forEach(s,(e=>{(0,h.BF)(!t.has(e)),t.add(e),(0,f.$O)(e,d._z)&&n.push(e)}));return[e,t]}}var p=n("../../babs/core/lib/gui/debug.js"),b=n("../../babs/core/lib/gui/display.js"),g=n("../../babs/core/lib/input/input.js"),y=n("../../babs/core/lib/render/cameras.js"),v=n("../../common/lib/env.js"),w=(n("../../babs/core/lib/audio/audio_manager.js"),n("../../common/lib/check.js")),x=n("../../babs/core/lib/common/flag.js");class C extends x.W{constructor(e,t,n){const s=n.range,o={defaultValue:n.defaultValue??s[0]};n.persist&&(o.persist={guard:f.HD,serialize:f.yR,deserialize:e=>s.includes(e)?e:void 0}),super(e,t,o),this.range=s}next(){const e=(0,w.vD)(this.range.indexOf(this.value),-1);this.value=this.range[(e+1)%this.range.length]}previous(){const e=(0,w.vD)(this.range.indexOf(this.value),-1);this.value=this.range[(e+this.range.length-1)%this.range.length]}}class j extends x.W{constructor(e,t,n){const s={defaultValue:n.defaultValue,validate:n.validate};n.persist&&(s.persist={guard:f.HD,serialize:f.yR,deserialize:f.yR}),super(e,t,s)}}var S=n("../../common/lib/containers.js"),_=n("../../babs/core/lib/gui/table.js"),k=n("../../babs/core/lib/gui/window.js");function E(e,t,n){t[1].style=e.active?n.styles.bold:n.styles.normal,t[1].color=e.connected?_.I.content:_.I.disabled,t[2].style=!0===e.value?n.styles.bold:n.styles.normal,t[2].color=_.I.highlight}var O=n("../../babs/core/lib/input/keys.js");const T=["ShiftLeft","ShiftRight"],$=["ControlLeft","ControlRight"],A=["MetaLeft","MetaRight"],M=["AltLeft","AltRight"];class R{constructor(){this.onKeysChanged=new s.Observable,this.onStateChanged=new s.Observable,this.keyBindings=new Map}track(e){const t=(0,S.tj)(this.keyBindings,e.config.code,(()=>[]));e.priority?t.unshift(e):t.push(e),e.connected.onChanged(e,(n=>{n?e.priority&&t.forEach((t=>{!t.priority&&t.config.hasSameModifiers(e.config)&&t.signal.cancel()})):e.signal.cancel(),this.signalStateChange(e)})),this.onKeysChanged.notifyObservers()}untrack(e){const t=this.keyBindings.get(e.config.code);t&&this.keyBindings.set(e.config.code,t.filter((t=>t!==e))),e.disposeResources(),this.onKeysChanged.notifyObservers()}*enumerateKeys(){for(const[e,t]of this.keyBindings.entries())for(const e of t)yield{name:e.name,connected:e.connected.value,active:e.active,value:e.value,config:e.config}}signalStateChange(e){this.onStateChanged.notifyObservers({name:e.name,connected:e.connected.value,active:e.active,value:e.value,config:e.config})}onEvent(e,t,n){let s=!1,o=!1;for(const i of this.keyBindings.get(e.code)??[]){let r=!1;const a=i.connected.value&&i.config.hasSameModifiers(e);if(t){if(a){if(o&&!i.priority)break;n?r=!0:i.signal.activate()&&(r=!0,this.cancelModifiers(i.config))}}else(n||i.signal.deactivate())&&(r=!0);!n&&r&&this.signalStateChange(i),s||(s=r),o||(o=r&&i.priority)}return s}cancelModifiers(e){const t=[];e.wantShift&&!T.includes(e.code)&&t.push(...T),e.wantCtrl&&!$.includes(e.code)&&t.push(...$),e.wantMeta&&!A.includes(e.code)&&t.push(...A),e.wantAlt&&!M.includes(e.code)&&t.push(...M),t.forEach((e=>(this.keyBindings.get(e)??[]).forEach((e=>{e.signal.cancel()&&this.signalStateChange(e)}))))}cancelKeySignals(){this.keyBindings.forEach((e=>e.forEach((e=>{e.signal.cancel()&&this.signalStateChange(e)}))))}}class I extends u.dK{constructor(e){super(e,g.II),this.tracker=new R}onInit(e){e.display.onNotify(e.scene.onKeyboardObservable,(e=>{const t=e.event;this.onKeyEvent(t)&&(t.stopPropagation(),t.preventDefault())})),e.canvas.addEventListener("focusout",(e=>this.onFocus(e))),e.canvas.addEventListener("focusin",(e=>this.onFocus(e)));const t=function(e,t){const n=(0,_.W)(e,"table",{columnRatios:[.6,.2,.2]}),s=(0,k.jX)(e,"Key Map",n.root,{widthRatio:.8,zIndex:100}),o=new d.qd((()=>{const s=Array.from(t.enumerateKeys());!function(e,t,n){t.sort(((e,t)=>{const n=e.name.startsWith("debug."),s=t.name.startsWith("debug.");return n&&!s?1:s&&!n?-1:e.name.localeCompare(t.name)})),e.layout((e=>{for(const s of t){if(s.name.startsWith("_"))continue;const[t,o,i]=e(s.name);s.name.startsWith("debug.")?t.text=s.name.slice(6):t.text=s.name,o.text=`${s.config.toString()}`,i.text=`${s.value}`,E(s,[t,o,i],n)}}))}(n,s,e)}));return n.root.onDisposeObservable.addOnce((()=>o.dispose())),e.onNotify(t.onKeysChanged,o.scheduler),o.scheduler(),e.onNotify(t.onStateChanged,(t=>{if("boolean"==typeof t.value){const s=n.get(t.name);s[2].text=`${t.value}`,E(t,s,e)}else o.scheduler()})),s}(e.display,this.tracker);e.display.add(t,!1),c.Mz.showKeymap.onChanged(e.display,(n=>e.display.show(t,n)),{immediate:!0})}onScopeInit(e){e.scene.onDisposeObservable.addOnce((()=>{e.scope.forEachSubsidiary(this.guard,(e=>{e.bindings.forEach((e=>this.tracker.untrack(e)))}))}))}onProcess(e,t){t.bindings.forEach((e=>this.tracker.track(e)))}onKeyEvent(e){const t="keydown"===e.type,n=new O.xw(e.code,e);return c.cG.showKeyEvents&&!e.repeat&&(0,i.cM)("onKeyEvent",{key:`${n.toString()}`,isDown:t,event:e}),this.tracker.onEvent(n,t,e.repeat)}onFocus(e){c.cG.showKeyEvents&&(0,i.cM)("onFocus",{type:e.type,event:e}),this.tracker.cancelKeySignals()}}I.I=new I(d.fi),n("../../../node_modules/@babylonjs/loaders/glTF/index.d.ts"),n("../../../node_modules/@babylonjs/loaders/OBJ/index.d.ts");var P=n("../../babs/core/lib/render/constants.js"),D=n("../../babs/core/lib/render/meshes.js"),F=n("../../babs/core/lib/render/mesh_asset.js");class B extends u.dK{constructor(e){super(e,F.H)}onProcess(e,t){e.fetchMesh(t,((e,n)=>{1===e.length?t.addMeshes(e[0]):t.addMeshes(...e);for(const t of(0,D.go)(s.Mesh,...e))t.renderingGroupId=P.Y.meshDefault;if(e[0].name=t.name,n.length){n[0].stop();for(const e of n)t.animations.set(e.name,e)}}))}}new B(d.fi);var N=n("../../babs/core/lib/render/texture_asset.js");class z extends u.dK{constructor(e){super(e,N.X)}onProcess(e,t){e.fetchTexture(t,(e=>{t.setTexture(e)}))}}new z(d.fi);var L=n("../../babs/core/lib/common/asset.js");class V extends L.x{constructor(e,t,n){super(e,t,n),this.onDispose((()=>{delete this.image_}))}share(){return(0,w.ro)(this.image_)}setImage(e){this.image_=e}}class H extends u.dK{constructor(e){super(e,V)}onProcess(e,t){e.fetchImage(t,(e=>{t.setImage(e)}))}}new H(d.fi);var U,W,q,G,K=function(e,t,n,s){if("a"===n&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?s:"a"===n?s.call(e):s?s.value:t.get(e)},Q=function(e,t,n,s,o){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?o.call(e,n):o?o.value=n:t.set(e,n),n};let J;const X=new C(d.fi,"FovMode",{range:["expand","crop","horizontal","vertical"],defaultValue:"expand",persist:!0});g.II.register(d.fi,"next FovMode",{keys:"Alt+KeyV",valued:X}).onClick(d.fi,(()=>X.next()));const Z=g.II.register(d.fi,"_freeLookInput",{keys:["W","A","S","D","ArrowUp","ArrowLeft","ArrowDown","ArrowRight"],priority:!0}),Y=(0,g.Qw)(d.fi,"Reset scene","Alt+Backspace");function ee(e,t){e.physicsEnabled=!t;for(const n of e.particleSystems)t?void 0===n.unpausedUpdateSpeed&&(n.unpausedUpdateSpeed=n.updateSpeed,n.updateSpeed=0):void 0!==n.unpausedUpdateSpeed&&(n.updateSpeed=n.unpausedUpdateSpeed,delete n.unpausedUpdateSpeed)}function te(e){let t=e.activeCamera;return!t&&e.activeCameras&&e.activeCameras.length&&(t=e.activeCameras[0]),t??void 0}const ne=new j(d.fi,"CurrentApp",{persist:!0});class se{constructor(e,t,n){this.params=e,this.loadScope=t,this.defaultApp=n,U.set(this,void 0),W.set(this,[]),q.set(this,!1),G.set(this,void 0),(0,l.Q)(),[s.Color3.BlackReadOnly,s.Matrix.IdentityReadOnly,s.Vector3.LeftHandedForwardReadOnly,s.Vector3.LeftReadOnly,s.Vector3.RightHandedForwardReadOnly,s.Vector3.RightReadOnly,s.Vector3.UpReadOnly,s.Vector3.ZeroReadOnly,s.Axis.X,s.Axis.Y,s.Axis.Z].forEach(Object.freeze),(0,i.cM)("GameEngine",{params:e,debug:c.cG,paused:se.Paused.value},{density:"collapsed"}),this.engine=new s.Engine(this.params.canvas,!1,{adaptToDeviceRatio:!0,stencil:!0})}async loadApp(e){if(K(this,q,"f"))return console.log(`Deferring load of ${e}`),void Q(this,G,e,"f");Q(this,q,!0,"f"),history.pushState(void 0,document.title,e===this.defaultApp?window.location.pathname+window.location.search:`#${e}`);const t=await this.loadScope(e);await this.addScope(t),Q(this,q,!1,"f"),void 0!==K(this,G,"f")&&(e=K(this,G,"f"),Q(this,G,void 0,"f"),setTimeout((()=>{console.log(`Resuming load of ${e}`),this.loadApp(e)})))}async start(){v.P||(document.title=` ${document.title} `),window.addEventListener("resize",(()=>{(0,i.cM)("Resize",{width:this.engine.getRenderWidth(),height:this.engine.getRenderHeight()}),this.updateFoV(),this.engine.resize()})),X.onChanged(d.fi,(()=>this.updateFoV())),window.addEventListener("deviceorientation",(()=>this.updateOrientation(window.orientation))),this.updateOrientation(window.orientation),se.Paused.onChanged(d.fi,(e=>{(0,i.cM)(e?"Paused.":"Resumed."),K(this,W,"f").forEach((t=>ee(t.scene,e)))})),c.Mz.freeLook.onChanged(d.fi,(e=>{this.freeLook(e),se.Paused.value=e})),Y.onEnabled(d.fi,(()=>{ne.value=void 0,this.loadApp(this.defaultApp)}));const e=await this.initializeGlobalScope();this.engine.runRenderLoop((()=>{const t=se.Paused.value,n=r.UH.of(this.engine.getDeltaTime(),r.HA);let s=0;for(let e=0;e{})),o.speed=.75,o.keysUp=[38,87],o.keysDown=[40,83],o.keysLeft=[37,65],o.keysRight=[39,68],o.inputs.addMouseWheel(),o.attachControl(),t.activeCamera=o;const r=t.onPointerObservable.add((e=>function(e,t){e.pickInfo&&e.pickInfo.pickedMesh&&e.type===s.PointerEventTypes.POINTERDOUBLETAP&&(J?J.setTarget(e.pickInfo.pickedMesh.absolutePosition):(J=new s.ArcRotateCamera("ArcRotate",Math.PI/3,Math.PI/3,10,e.pickInfo.pickedMesh.absolutePosition,t),J.zoomToMouseLocation=!0,J.attachControl(),t.activeCamera=J))}(e,t)));this.restoreFreeLook=()=>{n.isDisposed()||(t.activeCamera=n),o.dispose(),t.onPointerObservable.remove(r),J&&(J.dispose(),J=void 0)}}async initializeGlobalScope(){const e=new s.Scene(this.engine,{virtual:!0});e.physicsEnabled=!1,e.clearColor=s.Color4.FromHexString(a.Pf.midnightBlue);const t=new b.sS(e),n=(new y.v("tween",s.Vector3.ZeroReadOnly,e),new u.pq(this.params.canvas,{engine:this.engine,scene:e,gameEngine:this,display:t,scope:d.fi,urlBase:this.params.urlBase}));return(0,u.wV)(n),await n.load(),Q(this,U,{scope:d.fi,scene:e},"f"),v.P||(K(this,U,"f").diff=new m(K(this,U,"f"))),e}async processScope(e,t,n){const s=new u.uy({engine:this.engine,scene:t,gameEngine:this,display:n,scope:e,urlBase:`${this.params.urlBase}${this.params.assetPrefix}`});(0,u.ZH)(s),await s.load()}async addScope(e,t=!0){if(!v.P&&t){const t=K(this,W,"f").length>0;if(this.clearScopes(),t){const e=o.v.snapshot();e.length&&(0,i.cM)(`Tracked(${o.v.label}) (${e.length} undisposed objects)`,e,{density:e.length?"collapsed":"inline"})}o.v.startTracking(`${e.scope.name}`)}const n=new s.Scene(this.engine);se.Paused.value&&ee(n,!0);const r={scope:e.scope,scene:n};v.P||(r.diff=new m(r));const a=new b.sS(n);r.display=a,(0,p.Lh)(a,n),p.iu.create(n,a),await this.processScope(e.scope,n,a);const c={scope:e.scope,scene:n,display:a,gameEngine:this,urlBase:`${this.params.urlBase}${this.params.assetPrefix}`};return await e.createScene(c),this.updateFoV(),await new Promise((e=>setTimeout(e))),t&&this.clearScopes(),K(this,W,"f").push(r),n}clearScopes(){const e=[...K(this,W,"f")];K(this,W,"f").length=0,e.forEach((e=>{e.scene.dispose(),e.scope.disposeResources(),v.P||(K(this,U,"f")?.diff?.report(),e.diff?.report())}))}updateFoV(){const e=this.engine.getRenderWidth()/this.engine.getRenderHeight();let t;switch(X.value){case"expand":t=e<1?s.Camera.FOVMODE_HORIZONTAL_FIXED:s.Camera.FOVMODE_VERTICAL_FIXED;break;case"crop":t=e<1?s.Camera.FOVMODE_VERTICAL_FIXED:s.Camera.FOVMODE_HORIZONTAL_FIXED;break;case"horizontal":t=s.Camera.FOVMODE_HORIZONTAL_FIXED;break;case"vertical":t=s.Camera.FOVMODE_VERTICAL_FIXED}for(let e=0;e{const n=new o.TextBlock(e);return n.resizeToFit=!0,n.horizontalAlignment=o.Control.HORIZONTAL_ALIGNMENT_RIGHT,t.addControl(n),n}}}function f(e,t){let n;l.Mz.showInspector.onChanged(e,(e=>{(0,i.cW)(window.INSPECTOR,"The Inspector code is not loaded."),e?t.debugLayer.show({embedMode:!1}):t.debugLayer.hide(),t.getEngine().getRenderingCanvas()?.focus({preventScroll:!0})}),{immediate:!d.P}),l.Mz.showAxes.onChanged(e,(e=>{e&&!n?n=new s.AxesViewer(t,5):!e&&n&&(n.dispose(),n=void 0)}),{immediate:!d.P})}const m=["onBeforeAnimations","onAfterAnimations","onBeforePhysics","onAfterPhysics","onBeforeRender","onBeforeRenderTargetsRender","onAfterRenderTargetsRender","onBeforeCameraRender","onBeforeActiveMeshesEvaluation","onAfterActiveMeshesEvaluation","onBeforeParticlesRendering","onAfterParticlesRendering","onBeforeDrawPhase","onAfterDrawPhase","onAfterCameraRender","onAfterRender","onBeforeRenderingGroup","onAfterRenderingGroup"];class p{constructor(e){this.index=0,this.total=0,this.values=new Array(e).fill(0)}push(e){this.total-=this.values[this.index],this.values[this.index]=e,this.total+=e,this.index=(this.index+1)%this.values.length}get value(){return this.total/this.values.length}}const b=(0,r.Pn)()({fps:{label:"Frames per second",init:e=>{e.scene.captureFrameTime=!0,e.scene.captureInterFrameTime=!0},value:e=>1e3/(e.scene.frameTimeCounter.current+e.scene.interFrameTimeCounter.current),units:c.XF,precision:0},idle:{label:"Time between frames",init:e=>e.scene.captureInterFrameTime=!0,value:e=>e.scene.interFrameTimeCounter},process:{label:"Time for all frame processing",init:e=>e.scene.captureFrameTime=!0,value:e=>e.scene.frameTimeCounter},physics:{label:"Time for physics simulation",init:e=>e.scene.capturePhysicsTime=!0,value:e=>e.scene.physicsTimeCounter},activeMeshes:{label:"Active Meshes Evaluation",init:e=>e.scene.captureActiveMeshesEvaluationTime=!0,value:e=>e.scene.activeMeshesEvaluationTimeCounter},totalRender:{label:"Time for all frame rendering",init:e=>e.scene.captureRenderTime=!0,value:e=>e.scene.renderTimeCounter},renderTargets:{label:"Render Target Textures",init:e=>e.scene.captureRenderTargetsRenderTime=!0,value:e=>e.scene.renderTargetsRenderTimeCounter},particleRender:{label:"Time for particle rendering",init:e=>e.scene.captureParticlesRenderTime=!0,value:e=>e.scene.particlesRenderTimeCounter},spritesRender:{label:"Time for sprite rendering",init:e=>e.scene.captureSpritesRenderTime=!0,value:e=>e.scene.spritesRenderTimeCounter},cameraRender:{label:"Time for camera rendering",init:e=>e.scene.captureCameraRenderTime=!0,value:e=>e.scene.cameraRenderTimeCounter},gpuRender:{label:"GPU frame render time (parallel with CPU work)",init:e=>e.engine.captureGPUFrameTime=!0,value:e=>e.engine.gpuFrameTimeCounter,factor:1e-6},shaderCompilation:{label:"CPU shader compilation",init:e=>e.engine.captureShaderCompilationTime=!0,value:e=>e.engine.shaderCompilationTimeCounter},drawCalls:{label:"Draw calls per frame",value:e=>e.scene.drawCallsCounter,units:c.XF}}),g=["fps","idle","process","physics","activeMeshes","totalRender","gpuRender"];class y extends u._z{constructor(e,t){super(e),this.scene=e,this.indent="",this.trackingState="inactive",this.showPerfMetrics(t),this.observePhases()}static create(e,t){const n=new y(e,t);y.instance=n,n.onDispose((()=>{y.instance===n&&delete y.instance})),l.Mz.logNextFrame.onEnabled(t,(()=>{y.debugOneFrame()}))}static currentPhase(){return(0,i.ro)(y.instance?.phase)}static get isDebuggingFrame(){return"active"===y.instance?.trackingState}static logFrame(e,t){this.isDebuggingFrame&&y.instance?.logFrame(e,t)}static debugOneFrame(e=!1){const t=(0,i.ro)(y.instance);t.trackingState=e?"waitForNextFrame":"waitForNextPhase",delete t.trackingEndPhase}showPerfMetrics(e){let t=n=>{if(!n)return;const o=h();e.add(o);const i={engine:new s.EngineInstrumentation(this.scene.getEngine()),scene:new s.SceneInstrumentation(this.scene)},a=g.map((e=>b[e])),l=g.map((e=>o.add(e))),u=g.map((()=>new p(20)));a.forEach((e=>e.init?.(i))),this.scene.registerBeforeRender((()=>{for(let e=0;ee.show(o,t)};l.Mz.showPerfMetrics.onChanged(e,(e=>t(e)),{immediate:!0})}logFrame(e,t){(0,a.cM)("Frame",{label:`${this.indent}${e}`,...t})}observePhases(){let e=[...m];const t=e.filter((e=>e.endsWith("Physics")));this.scene.isPhysicsEnabled()||(e=e.filter((e=>!t.includes(e))));for(const t of e){const n=`${t}Observable`,o=(0,i.ro)(this.scene[n],`Missing Scene.${n}()`);this.onNotify(o,(n=>{const o=this.phase;if(this.phase=t,"inactive"!==this.trackingState&&(this.trackingEndPhase===t?this.trackingState="inactive":("waitForNextPhase"===this.trackingState||"waitForNextFrame"===this.trackingState&&t===e[0])&&(this.trackingState="active",this.indent="",this.trackingEndPhase=t),"active"===this.trackingState)){t.startsWith("onBefore")&&o?.startsWith("onBefore")?this.indent+=" ":t.startsWith("onAfter")&&o?.startsWith("onAfter")&&(this.indent=this.indent.slice(0,this.indent.length-2));const e={};(0,r.$O)(n,s.Scene)||((0,r.$O)(n,s.Camera)?e.camera=n.name:(0,r.$O)(n,s.RenderingGroupInfo)&&(e.camera=n.camera?.name,e.renderingGroupId=n.renderingGroupId)),this.logFrame(this.phase,e)}}))}}}},"../../babs/core/lib/gui/display.js":function(e,t,n){"use strict";n.d(t,{sS:function(){return m},x4:function(){return d},Ov:function(){return h}});var s=n("../../../node_modules/@babylonjs/core/index.js"),o=n("../../../node_modules/@babylonjs/gui/index.js"),i=n("../../common/lib/env.js"),r=n("../../common/lib/identity.js"),a=n("../../babs/core/lib/common/group.js"),c=n("../../babs/core/lib/common/resource.js");const l=new a.ZA("gui"),u=window.devicePixelRatio;function d(e){return`${Math.ceil(e*u)}px`}function h(e){return Math.ceil(e*u)}function f(e){return{width:e.getRenderWidth(),height:e.getRenderHeight()}}class m extends c._z{constructor(e){if(super(e),this.scene=e,this.widgets=new Set,this.adt=o.AdvancedDynamicTexture.CreateFullscreenUI("gui",!0,e),this.adt.layer&&(0,a._9)(this.adt.layer,l),this.styles=function(e){const t=(t,n,s="normal")=>{const o=e.createStyle();return o.fontFamily=t,o.fontSize=d(n),o.fontWeight=s,o},n="Segoe WPC,Segoe UI,sans-serif",s=(0,r.Pn)()({normal:t(n,13,"400"),bold:t(n,13,"800"),title:t(n,11,"700")});return Object.freeze(s)}(this.adt),i.P)this.addDebugEntry=()=>{};else{const e=m.createDebug();this.adt.addControl(e.root),this.addDebugEntry=t=>e.addEntry(t)}this.onNotify(e.getEngine().onResizeObservable,(e=>{const t=f(e);this.widgets.forEach((e=>e.onResize?.(t)))}));const t=f(e.getEngine());this.widgets.forEach((e=>e.onResize?.(t))),this.onUpdate((()=>{this.widgets.forEach((e=>e.onUpdate?.()))})),this.onDispose((()=>{this.widgets.forEach((e=>e.root.dispose())),this.widgets.clear()}))}static createDebug(){const e=new o.Rectangle("debug");e.fontFamily="Consolas",e.fontSize=12,e.alpha=.7,e.color="white",e.background="black",e.adaptHeightToChildren=!0,e.adaptWidthToChildren=!0,e.verticalAlignment=o.Control.VERTICAL_ALIGNMENT_TOP,e.horizontalAlignment=o.Control.HORIZONTAL_ALIGNMENT_LEFT;const t=new o.StackPanel("panel");return t.isVertical=!0,t.adaptWidthToChildren=!0,t.paddingLeftInPixels=t.paddingRightInPixels=4,e.addControl(t),{root:e,addEntry:function(e){const n=new o.TextBlock(e);return n.resizeToFit=!0,n.horizontalAlignment=o.Control.HORIZONTAL_ALIGNMENT_LEFT,t.addControl(n),n}}}get todo(){return this.adt}coords(e,t){let n=this.scene.pointerX,o=this.scene.pointerY;return t&&(n=t.movementX,o=t.movementY),e?new s.Vector2(n,o):new s.Vector2(h(n),h(o))}onMouseMove(e,t){const n=this.scene.onPrePointerObservable.add((n=>{e(this.coords(void 0,!0===t?n.event:void 0))}),s.PointerEventTypes.POINTERMOVE);return{dispose:()=>this.scene.onPrePointerObservable.remove(n)}}add(e,t=!0){return e.onResize&&e.onResize(f(this.scene.getEngine())),this.widgets.add(e),this.show(e,t),e}remove(e){this.show(e,!1),this.widgets.delete(e)}show(e,t=!0){t?this.adt.addControl(e.root):this.adt.removeControl(e.root)}hide(e){this.show(e,!1)}}},"../../babs/core/lib/gui/table.js":function(e,t,n){"use strict";n.d(t,{I:function(){return h},W:function(){return b}});var s=n("../../../node_modules/@babylonjs/core/index.js"),o=n("../../../node_modules/@babylonjs/gui/index.js"),i=n("../../common/lib/check.js"),r=n("../../common/lib/identity.js"),a=n("../../babs/core/lib/common/color.js"),c=n("../../babs/core/lib/input/input.js"),l=n("../../babs/core/lib/gui/display.js"),u=n("../../babs/core/lib/gui/vscode.js"),d=n("../../babs/core/lib/gui/window.js");const h=(0,a.DG)({text:u.z.text,transparent:"#0000"},(e=>({content:e.text,disabled:u.z.disabledText,highlight:u.z.highlightText,tableFill:u.z.tableFill,tableRow:u.z.tableRow,hoverRowFill:u.z.hoverRowFill}))),f=(0,a.NC)((0,a.nV)((0,a.H_)(h.hoverRowFill),.2));function m(e,t){let n;switch(t){case"hovering":n=h.hoverRowFill;break;case"selecting":n=f;break;default:n=e%2==0?h.tableRow:h.transparent}return n}const p=(0,r.SC)().withDefaults({rowHeight:27,columnRatios:[1]});function b(e,t,n){const a=p.apply(n??{}),u=new o.Grid(t);u.verticalAlignment=o.Control.VERTICAL_ALIGNMENT_TOP,u.horizontalAlignment=o.Control.HORIZONTAL_ALIGNMENT_RIGHT,u.paddingTop=u.paddingBottom=(0,l.x4)(d.ld),u.paddingLeft=u.paddingRight=(0,l.x4)(d.ld),u.style=e.styles.normal,u.background=h.tableFill,a.columnRatios.forEach((e=>{(0,i.BF)(e>0&&e<=1),u.addColumnDefinition(e)}));const f=new Map,b=e=>function(e,t,n,s){const r=n.size;for((0,i.M1)(n.get(s),void 0,(()=>`Row with duplicate label: ${s}`)),n.set(s,r);e.rowCount<=r;)e.addRowDefinition((0,l.Ov)(t.rowHeight),!0);const a=[],c=m(r);for(let t=0;t{const n=[];for(let s=0;s{const t=m(e,e===y?v?"selecting":"hovering":void 0);g(e,x).forEach((e=>e.background=t))};u.onPointerMoveObservable.add((()=>{const t=y;u.getLocalCoordinatesToRef(e.coords(),w);const n=Math.floor(w.y/(0,l.Ov)(a.rowHeight));y=n<0||n>=f.size?void 0:n,t!==y&&(void 0!==t&&C(t),void 0!==y&&C(y))})),u.onPointerOutObservable.add((()=>{if(v=!1,void 0!==y){const e=y;y=void 0,C(e)}})),u.onPointerDownObservable.add((e=>{a.onClick&&e.buttonIndex===c.tc.Primary&&(v=!0,void 0!==y&&C(y))}));const j=(0,r.V9)(o.TextBlock);return u.onPointerClickObservable.add((e=>{if(a.onClick&&e.buttonIndex===c.tc.Primary&&v&&(v=!1,void 0!==y)){C(y);const e=g(y,j).at(0)?.name;a.onClick((0,i.ro)(e))}})),{root:u,layout:e=>{for(u.clearControls(),f.clear(),e(b);u.rowCount>f.size;)u.removeRowDefinition(u.rowCount-1);const t=2*(0,l.Ov)(d.ld);u.heightInPixels=(0,l.Ov)(a.rowHeight)*u.rowCount+t},get:e=>((e,t)=>{const n=(0,i.ro)(f.get(e));return g(n,t)})(e,j),list:()=>Array.from(f.keys())}}},"../../babs/core/lib/gui/vscode.js":function(e,t,n){"use strict";n.d(t,{z:function(){return s}});const s=(0,n("../../babs/core/lib/common/color.js").DG)({text:"#cccccc",panelFill:"#1e1e1e",headerFill:"#80808033",disabledText:"#808080",highlightText:"#d7ba7d",scrollBar:"#646464b3",tableRow:"#2a2d2e",tableFill:"#252526",hoverRowFill:"#094771"})},"../../babs/core/lib/gui/window.js":function(e,t,n){"use strict";n.d(t,{LW:function(){return l},jX:function(){return h},ld:function(){return u}});var s=n("../../../node_modules/@babylonjs/gui/index.js"),o=n("../../common/lib/identity.js"),i=n("../../babs/core/lib/common/color.js"),r=n("../../babs/core/lib/gui/display.js"),a=n("../../babs/core/lib/gui/vscode.js");const c=(0,i.DG)({text:a.z.text,transparent:"#0000"},(e=>({header:e.text,headerFill:a.z.headerFill,panelFill:a.z.panelFill,scrollBar:a.z.scrollBar}))),l=6,u=10,d=(0,o.SC)().withDefaults({zIndex:0,widthRatio:.5,heightRatio:.5});function h(e,t,n,o){const i=d.apply(o??{}),a=new s.Rectangle(t);a.isPointerBlocker=!0,a.zIndex=i.zIndex,a.thickness=(0,r.Ov)(1),a.color=c.text,a.background=c.panelFill,a.width=`${Math.round(100*i.widthRatio)}%`;const u=new s.StackPanel("panel");a.addControl(u);const h=new s.Rectangle("header");h.height=(0,r.x4)(24),h.thickness=0,h.color=c.header,h.background=c.headerFill,u.addControl(h);const f=new s.TextBlock("title");f.textHorizontalAlignment=s.Control.HORIZONTAL_ALIGNMENT_LEFT,f.paddingLeft=f.paddingRight=(0,r.x4)(l),f.style=e.styles.title,f.text=t.toUpperCase(),h.addControl(f);const m=new s.ScrollViewer("scroll");return m.forceVerticalBar=!0,m.thickness=0,m.barSize=(0,r.Ov)(10),m.barColor=c.scrollBar,m.barBackground=c.transparent,m.color=c.transparent,m.background=c.transparent,u.addControl(m),m.addControl(n),{root:a,onResize:function(e){const t=Math.ceil(e.height*i.heightRatio);m.height=(0,r.x4)(t),u.height=(0,r.x4)(24+t),a.height=(0,r.x4)(24+t+2)}}}},"../../babs/core/lib/input/input.js":function(e,t,n){"use strict";n.d(t,{II:function(){return _},tc:function(){return v},Qw:function(){return k}});var s,o,i=n("../../../node_modules/@babylonjs/core/index.js"),r=n("../../common/lib/check.js"),a=n("../../common/lib/containers.js"),c=function(e,t,n,s,o){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?o.call(e,n):o?o.value=n:t.set(e,n),n},l=function(e,t,n,s){if("a"===n&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?s:"a"===n?s.call(e):s?s.value:t.get(e)};class u{constructor(e){s.set(this,!1),o.set(this,void 0),c(this,o,e,"f")}activate(){return!l(this,s,"f")&&(c(this,s,!0,"f"),l(this,o,"f").call(this,"activate"),!0)}deactivate(){return!!l(this,s,"f")&&(c(this,s,!1,"f"),l(this,o,"f").call(this,"deactivate"),!0)}cancel(){return!!l(this,s,"f")&&(c(this,s,!1,"f"),l(this,o,"f").call(this,"cancel"),!0)}dispose(){this.cancel()}}s=new WeakMap,o=new WeakMap;var d=n("../../babs/core/lib/common/resource.js"),h=n("../../common/lib/identity.js"),f=n("../../babs/core/lib/common/flag.js");const m=e=>e;class p extends f.W{constructor(e,t,n){const s={defaultValue:n?.defaultEnabled??!1,validate:n?.validate};n?.persist&&(s.persist={guard:h.jn,serialize:h.yR,deserialize:h.yR}),super(e,t,s)}toggle(){this.value=!this.value}onEnabled(e,t,n){this.onChanged(e,t,{predicate:m,immediate:n})}}var b,g,y,v,w=n("../../babs/core/lib/input/keys.js"),x=function(e,t,n,s){if("a"===n&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?s:"a"===n?s.call(e):s?s.value:t.get(e)},C=function(e,t,n,s,o){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?o.call(e,n):o?o.value=n:t.set(e,n),n};!function(e){e[e.Primary=0]="Primary",e[e.Middle=1]="Middle",e[e.Secondary=2]="Secondary"}(v||(v={}));class j extends d.sX{constructor(e,t,n,s,o=!1){super(e.name),this.input=e,this.valued=t,this.signal=n,this.config=s,this.priority=o}get connected(){return this.input.connected}get active(){return this.input.active}get value(){return this.valued.value}}const S={value:void 0};class _ extends d.$9{constructor(e,t,n,s,o){super(e,t),b.add(this),this.onEvent=new i.Observable,this.connected_=new p(this,"connected"),g.set(this,0),this.bindings=(0,a._2)(n).map((e=>new j(this,s,this.createSignal(),w.xw.from(e),o)))}static register(e,t,n){return new _(e,t,n?.keys??[],n?.valued??S,n?.priority??!1)}get connected(){return this.connected_}get active(){return x(this,g,"f")>0}onDown(e,t,n,s=!0){const o=this.onEvent.add((e=>{"activate"===e?t():"deactivate"===e&&n()}));this.updateConnected_(),s&&o&&(x(this,g,"f")&&t(),e.onDispose((()=>{x(this,g,"f")&&n(),this.onEvent.remove(o),this.updateConnected_()})))}onClick(e,t,n=!0){const s=this.onEvent.add((e=>{"trigger"===e&&t()}));this.updateConnected_(),n&&s&&e.onDispose((()=>{this.onEvent.remove(s),this.updateConnected_()}))}createSignal(){return this.acquire(new u((e=>x(this,b,"m",y).call(this,e))))}updateConnected_(){this.connected_.value=this.onEvent.observers.some((e=>!e._willBeUnregistered))}}function k(e,t,n,s){const o=new p(e,t,s);if(void 0===n&&!s?.wantInput)return o;!s?.mode&&s?.persist&&(s??(s={}),s.mode="stateful");const i=_.register(e,t,{keys:n,valued:o,...s}),a=e=>{if("stateful"===s?.mode)i.onClick(e,(()=>o.toggle()),void 0!==s?.enable);else{(0,r.BF)(!0!==s?.persist,(()=>"'ephemeral' toggleInput does not support persistence"));const t=s?.defaultEnabled??!1;i.onDown(e,(()=>o.value=!t),(()=>o.value=t),void 0!==s?.enable)}};return s?.enable?s.enable.add(a):a(e),s?.wantInput?{toggle:o,input:i}:o}g=new WeakMap,b=new WeakSet,y=function(e){"activate"===e?(C(this,g,x(this,g,"f")+1,"f"),1===x(this,g,"f")&&this.onEvent.notifyObservers("activate")):(C(this,g,x(this,g,"f")-1,"f"),0===x(this,g,"f")&&this.onEvent.notifyObservers("deactivate"),"cancel"!==e&&this.onEvent.notifyObservers("trigger"))}},"../../babs/core/lib/input/keys.js":function(e,t,n){"use strict";n.d(t,{xw:function(){return r}});var s,o,i=n("../../common/lib/identity.js");!function(e){e.symbols=(0,i.lG)({"`":"Backquote","-":"Minus","=":"Equal","[":"BracketLeft","]":"BracketRight","\\":"Backslash",";":"Semicolon","'":"Quote",",":"Comma",".":"Period","/":"Slash"}),e.isSymbol=function(t){return t in e.symbols.forward};const t=/^\d$/;e.isDigit=function(e){return t.test(e)};const n=/^[A-Z]$/;e.isLetter=function(e){return n.test(e)}}(s||(s={})),function(e){e.modifiers={ShiftLeft:!0,ControlLeft:!0,MetaLeft:!0,AltLeft:!0,ShiftRight:!0,ControlRight:!0,MetaRight:!0,AltRight:!0},e.isModifier=function(t){return t in e.modifiers}}(o||(o={}));class r{constructor(e,t){this.code=e;const n=(t?.shiftKey??!1)&&"ShiftLeft"!==e&&"ShiftRight"!==e,s=(t?.ctrlKey??!1)&&"ControlLeft"!==e&&"ControlRight"!==e,o=(t?.metaKey??!1)&&"MetaLeft"!==e&&"MetaRight"!==e,i=(t?.altKey??!1)&&"AltLeft"!==e&&"AltRight"!==e;this.modifierMask=(n?1:0)|(s?2:0)|(o?4:0)|(i?8:0)}static fromString(e){const t={},n=e.split("+");for(let e=0;e{h===e&&(h=void 0)}))}}}async function p(e){h||(h=await d());const t=new o.AmmoJSPlugin(void 0,h);return new m(e,t,!0)}function b(e,t,...n){const s=n.length?n:["The Ammo physics engine is not enabled."];(0,i.cW)(h,...s);const o=e.physicsImpostor,a=o.physicsBody;if((0,r.EN)(a))return t({ammo:h,imposter:o,body:a});console.warn(`${e.name} is missing physicsImpostor or physicsBody`)}function g(e,t){const n=e=>e?1:0;b(e,(({ammo:e,body:s})=>{s.setAngularFactor(new e.btVector3(n(t?.x),n(t?.y),n(t?.z)))}),"setRotationAxes is only supported by Ammo.")}function y(e,t){b(e,(({body:e})=>{let n=e.getCollisionFlags();t?n&=~s.CF_NO_CONTACT_RESPONSE:n|=s.CF_NO_CONTACT_RESPONSE,e.setCollisionFlags(n)}),"setTangible is only supported by Ammo.")}function v(e,t){return b(e,(({ammo:e,body:n})=>{const s=e.castObject(n,e.btCollisionObject);return s.data=t,()=>{delete s.data}}))}const w=new class{constructor(){this.defaultRef="A"}from(e){return this.manifold=e,this.defaultRef="A",this}*getPoints(e){(0,i.cW)(this.manifold);const t=(0,i.vD)(this.manifold.getNumContacts(),0),n="A"===(e??this.defaultRef);for(let e=0;e{c+=1;const o={node:e,collider:s,layerMask:0,onStart:t?.onCollisionStart,onEnd:t?.onCollisionEnd};t?.groups&&(0,d._9)(o,...(0,r._2)(t?.groups)),s.physicsImpostor.data=o;const i=(0,f.xY)(s,o);i&&n.onDisposeObservable.addOnce(i)})),(0,i.vD)(c,0)}s=g;const x=l.UH.of(5*-9.81,l.lf);let C;function j(e,t,n){e.material=C,e.isVisible=u.cG.showColliders;const s=n.isTangible??!0;var i,r;i=e,r=new o.PhysicsImpostor(e,t,s?{mass:n?.mass?.value??0,restitution:n?.restitution??0,friction:n?.friction??.5}:{mass:0},n.scene),i.physicsImpostor=r;for(const t of n.children??[])n.offset&&(t.position=n.offset.scale({factor:-1}).value().addInPlace(t.position)),t.setParent(e);return s||(0,f.Sq)(e,!1),n.offset&&(e.position=n.offset.value()),n.parent&&e.setParent(n.parent),e}function S(e){return j(o.MeshBuilder.CreateBox(e.name??"box",{width:e.size.x.value,height:e.size.y.value,depth:e.size.z.value},e.scene),o.PhysicsImpostor.BoxImpostor,e)}function _(e){return j(o.MeshBuilder.CreateSphere(e.name??"sphere",{diameter:e.diameter.value},e.scene),o.PhysicsImpostor.SphereImpostor,e)}function k(e){const t=o.MeshBuilder.CreateCylinder(e.name??"cylinder",{height:e.height.value,diameter:e.diameter.value},e.scene);return"x"===e?.axis?t.rotationQuaternion=o.Quaternion.FromLookDirectionLH(o.Vector3.Up(),o.Vector3.Right()):"z"===e?.axis&&(t.rotationQuaternion=o.Quaternion.FromLookDirectionLH(o.Vector3.Up(),o.Vector3.Backward())),j(t,o.PhysicsImpostor.CylinderImpostor,e)}function E(e){return j(o.MeshBuilder.CreateCapsule(e.name??"capsule",{height:e.height.value,radius:e.diameter.value/2,...e.orientation?{orientation:e.orientation}:{}},e.scene),o.PhysicsImpostor.CapsuleImpostor,e)}function O(e,t){const n=e.physicsImpostor,s=t.physicsImpostor,o=n.friction*s.friction,i=n.mass*e.getScene().gravity.y;return l.UH.of(Math.abs(i*o),l.R2)}function T(e,t,n,s){let i=n;s?.scaleToMass&&(i=i.scale(e.physicsImpostor?.mass??1)),s?.asImpulseOverTime&&(i=i.times(s.asImpulseOverTime));const r=t.normalizeToNew().scale(i.value),a=s?.offsetFromCenterOfMass?.value()??o.Vector3.ZeroReadOnly,u=e.getAbsolutePosition().add(a);void 0!==s?.debug&&(0,c.cM)("applyForce",{label:s?.debug,velocity:(0,m.J)(e),force:r}),i.unit.label===l.ew.label?e.physicsImpostor?.applyImpulse(r,u):e.physicsImpostor?.applyForce(r,u)}class $ extends h._z{constructor(e){super(e),this.scene=e,this.collisions=new Map,this.cycle=0,this.onNotify(e.onAfterPhysicsObservable,(()=>this.checkCollisions())),this.onDispose((()=>this.collisions.clear()))}dispatch(e,t,n,s){const o=`${t.collider.uniqueId}.${n.collider.uniqueId}`,i=this.collisions.get(o);i?.lastSeen===e-1?i.lastSeen=e:(t.onStart?.({self:t,target:n,contact:s})??1)&&(i?i.lastSeen=e:this.collisions.set(o,{primary:t,secondary:n,lastSeen:e}))}checkCollisions(){const e=this.cycle,t=++this.cycle;(0,f.Pb)(this.scene,((e,n,s)=>{(e.onStart||e.onEnd)&&this.dispatch(t,e,n,s),(n.onStart||n.onEnd)&&(s.defaultRef="B",this.dispatch(t,n,e,s))}));for(const[n,s]of this.collisions.entries())s.lastSeen===e&&(s.primary.onEnd?.({self:s.primary,target:s.secondary}),s.lastSeen+60{for(const n of e.meshes)n.material===C&&(n.isVisible=t)})),new $(e),s}},"../../babs/core/lib/render/cameras.js":function(e,t,n){"use strict";n.d(t,{v:function(){return r}});var s=n("../../../node_modules/@babylonjs/core/index.js");const o=Object.freeze(s.Quaternion.RotationAxis(s.Axis.X,0)),i=Object.freeze(s.Vector3.One());class r extends s.Camera{constructor(e,t,n,i){super(e,t.clone(),n,i),this.rotationQuaternion_=o.clone(),this.rotation_=this.rotationQuaternion_.toEulerAngles(),this.viewMatrix_=s.Matrix.Zero(),this.rotationDirty_=!1}get rotationQuaternion(){return this.rotationQuaternion_}set rotationQuaternion(e){this.rotationQuaternion_.copyFrom(e),this.rotationDirty_=!0}set rotation(e){this.rotation_.copyFrom(e),s.Quaternion.RotationYawPitchRollToRef(this.rotation_.y,this.rotation_.x,this.rotation_.z,this.rotationQuaternion_),this.rotationDirty_=!1}get rotation(){return this.rotationDirty_&&(this.rotationQuaternion_.toEulerAnglesToRef(this.rotation_),this.rotationDirty_=!1),this.rotation_}_initCache(){super._initCache(),this._cache.rotationQuaternion=new s.Quaternion(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)}_updateCache(e){e||super._updateCache(),this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion_)}_isSynchronizedViewMatrix(){return!!super._isSynchronizedViewMatrix()&&this.rotationQuaternion_.equals(this._cache.rotationQuaternion)}_getViewMatrix(){if(s.Axis.Y.rotateByQuaternionToRef(this.rotationQuaternion_,this.upVector),s.Matrix.ComposeToRef(i,this.rotationQuaternion_,this.position,this.viewMatrix_),this.parent){const e=this.parent.getWorldMatrix();this.viewMatrix_.multiplyToRef(e,this.viewMatrix_),this.viewMatrix_.getTranslationToRef(this._globalPosition),this.viewMatrix_.invert(),this._markSyncedWithParent()}else this._globalPosition.copyFrom(this.position),this.viewMatrix_.invert();return this.viewMatrix_}getClassName(){return"DirectionalCamera"}}},"../../babs/core/lib/render/constants.js":function(e,t,n){"use strict";var s;n.d(t,{Y:function(){return s}}),function(e){e.prePass=0,e.opaque=1,e.other=2,e.meshDefault=e.opaque}(s||(s={}))},"../../babs/core/lib/render/mesh_asset.js":function(e,t,n){"use strict";n.d(t,{H:function(){return a}});var s=n("../../common/lib/check.js"),o=n("../../common/lib/identity.js"),i=n("../../babs/core/lib/common/asset.js"),r=n("../../babs/core/lib/render/meshes.js");class a extends i.x{constructor(e,t,n,s){super(e,t,n),this.options=s,this.allMeshes=[],this.animations=new Map,this.onDispose((()=>{this.allMeshes.length=0,this.animations.clear()}))}clone(e){return(0,r.d9)(this.allMeshes[0],e)}cloneWithAnimations(e,t){const n=this.clone(t),i=this.allMeshes[0].getDescendants(!1),r=n.getDescendants(!1),a=(0,o.Yl)(t.animations,((t,o)=>e.acquire((0,s.ro)(this.animations.get(t),(()=>`Mesh ${n.name} does not have animation ${t}`)).clone(`${n.name}.${o}`,(e=>{const t=i.indexOf(e);return r[t]})))));return{mesh:n,animations:a}}addMeshes(...e){this.allMeshes.push(...e);const t=this.options?.scale;t&&this.allMeshes.forEach((e=>e.scaling=t))}share(){return this.allMeshes[0]}}},"../../babs/core/lib/render/meshes.js":function(e,t,n){"use strict";n.d(t,{Ky:function(){return h},Tv:function(){return x},Yw:function(){return m},d9:function(){return y},du:function(){return C},go:function(){return f},iK:function(){return v},pI:function(){return j}});var s=n("../../../node_modules/@babylonjs/core/index.js"),o=n("../../common/lib/core.js"),i=n("../../common/lib/identity.js"),r=n("../../common/lib/units.js"),a=n("../../babs/core/lib/common/debug_flags.js"),c=n("../../babs/core/lib/common/resource.js"),l=n("../../babs/core/lib/common/units.js"),u=n("../../babs/core/lib/physics/physics.js"),d=n("../../babs/core/lib/render/constants.js");function h(e,t){const n=new s.TransformNode(e,t);return n.freezeWorldMatrix(),n}function f(e,...t){return function(e,...t){return t.flatMap((t=>[...e(t)?[t]:[],...t.getDescendants(!1,e)]))}((0,i.V9)(e),...t)}function m(e,t){if(t??1){const t=e.getHierarchyBoundingVectors();return{size:l.f.of(t.max.subtract(t.min),r.J4),center:l.w.of(s.Vector3.Center(t.min,t.max),r.J4),minimum:l.w.of(t.min,r.J4),maximum:l.w.of(t.max,r.J4)}}{const t=e.getBoundingInfo();return{size:l.f.of(t.boundingBox.extendSizeWorld,r.J4),center:l.w.of(t.boundingBox.centerWorld,r.J4),minimum:l.w.of(t.boundingBox.minimumWorld,r.J4),maximum:l.w.of(t.boundingBox.maximumWorld,r.J4)}}}let p,b,g=0;function y(e,t){const n=t?.baseName??e.name,s=t?.parent??null,i=`${n}.${g++}`;return(0,o.A4)(e.clone(i,s))}function v(e,t){const n=e.createInstance(t);n.isVisible=e.isVisible,n.layerMask=e.layerMask;for(const t of function(e,...t){return function(e,...t){return t.flatMap((t=>t.getDescendants(!0,e)))}((0,i.V9)(e),...t)}(s.Mesh,e)){const e=t.createInstance(t.name);e.isVisible=t.isVisible,e.layerMask=t.layerMask,e.parent=n}return n}let w=s.Color3.Green();function x(e,t){const n=p?.isEnabled??!1,o=t?.enable??!0,i=t?.color??w;if(n)for(const t of f(s.Mesh,e))a.cG.showColliders===(0,u.th)(t)&&(o?p?.addMesh(t,i):p?.removeMesh(t));else b&&(o?b.set(e,i.clone()):b.delete(e))}function C(e,t,n){b=new Map,a.Mz.enableHighlightLayer.onChanged((0,c.U6)(e),(o=>{p||(p=new s.HighlightLayer("highlights",e,{renderingGroupId:d.Y.opaque,camera:t}),p.innerGlow=!1,n&&(w=n)),p.isEnabled=o,p.isEnabled&&(b?.forEach(((e,t)=>x(t,{enable:!0,color:e}))),b?.clear())}),{immediate:!0})}function j(e){const t=e.clone(),n=s.Vector3.Cross(e,s.Vector3.UpReadOnly),o=s.Vector3.Cross(t,n);return s.Vector3.RotationFromAxis(n,o,t)}},"../../babs/core/lib/render/texture_asset.js":function(e,t,n){"use strict";n.d(t,{X:function(){return i}});var s=n("../../common/lib/check.js"),o=n("../../babs/core/lib/common/asset.js");class i extends o.x{constructor(e,t,n){super(e,t,n),this.onDispose((()=>{delete this.texture_}))}share(){return(0,s.ro)(this.texture_)}clone(){return(0,s.ro)(this.texture_).clone()}setTexture(e){this.texture_=e}}},"../../common/lib/check.js":function(e,t,n){"use strict";n.d(t,{$1:function(){return c},BF:function(){return s.BF},EQ:function(){return a},M1:function(){return l},Yg:function(){return u},cW:function(){return s.cW},r0:function(){return h},ro:function(){return s.ro},vD:function(){return d}});var s=n("../../common/lib/core.js"),o=n("../../common/lib/errors.js"),i=(n("../../common/lib/identity.js"),n("../../common/lib/logging.js"));class r extends o.sH{constructor(){super("Not implemented")}}function a(){throw console.error("Not implemented"),new r}function c(e,t,...n){return(0,s.BF)(t(e),`checkType(value: ${(0,i.Qv)(e)})`,...n),e}function l(e,t,...n){return e!==t?(0,s.Xr)(`checkEqual ${(0,i.bn)(e)} !== ${(0,i.bn)(t)}`,...n):e}function u(e,t,...n){return e===t?(0,s.Xr)(`checkNotEqual ${e} === ${t}`,...n):e}function d(e,t,...n){return e<=t?(0,s.Xr)(`checkGt ${e} <= ${t}`,...n):e}function h(e,t,...n){return e>=t?(0,s.Xr)(`checkLt ${e} >= ${t}`,...n):e}},"../../common/lib/containers.js":function(e,t,n){"use strict";n.d(t,{Od:function(){return r},_2:function(){return i},tj:function(){return o}});var s=n("../../common/lib/identity.js");function o(e,t,n){let s=e.get(t);return void 0===s&&(s=n(),e.set(t,s)),s}function i(e,t){return(0,s.kJ)(e)?e:void 0!==e?[e]:t}function r(e,t){const n=e.indexOf(t);if(n<0)return!1;const s=e.pop();return n"string"==typeof e?e:e()));throw o.P||console.info("die with error:",...n),new i(n.join(" "))}function a(e,...t){e||r("check failed.",...t)}function c(e,...t){return void 0===e&&r("checkDefined",...t),e}function l(e,...t){return null==e&&r("checkNonNull",...t),e}function u(e,...t){void 0===e&&r("assertIsDefined",...t)}function d(e){e instanceof Error||r("assertIsError",(()=>`${e}`))}},"../../common/lib/disposable.js":function(e,t,n){"use strict";n.d(t,{v:function(){return l}});var s,o,i,r=n("../../common/lib/check.js"),a=function(e,t,n,s){if("a"===n&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?s:"a"===n?s.call(e):s?s.value:t.get(e)},c=function(e,t,n,s,o){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===s?o.call(e,n):o?o.value=n:t.set(e,n),n};class l{constructor(){a(l,s,"f",o)?.add(this)}static startTracking(e){c(this,s,e,"f",i),c(this,s,new Set,"f",o)}static stopTracking(){c(this,s,void 0,"f",o)}static snapshot(){return(0,r.cW)(a(this,s,"f",o),"You must call Tracked.startTracking() to begin tracking."),Array.from(a(this,s,"f",o).values())}static get label(){return a(this,s,"f",i)??""}dispose(){return a(l,s,"f",o)?.delete(this),"You must call super.dispose() when overriding Tracked.dispose."}}s=l,o={value:void 0},i={value:void 0}},"../../common/lib/env.js":function(e,t,n){"use strict";n.d(t,{P:function(){return s}});const s=!0},"../../common/lib/errors.js":function(e,t,n){"use strict";n.d(t,{f_:function(){return i},sH:function(){return s}});class s extends Error{constructor(e,t){super(e),this.args=t,this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}}const o=Symbol("Error.cohort");function i(e,t){const n=[];for(const s of e)try{t(s)}catch(e){if(!(e instanceof Error))throw e;n.push(e)}if(n.length){const e=n[0];throw n.length>1&&function(e,...t){e[o]??(e[o]=[]),e[o].push(...t)}(e,...n.slice(1)),e}}},"../../common/lib/identity.js":function(e,t,n){"use strict";n.d(t,{yR:function(){return j},lG:function(){return w},kJ:function(){return u},jn:function(){return r},$K:function(){return o},mf:function(){return l},$O:function(){return f},V9:function(){return m},hj:function(){return a},Kn:function(){return d},EN:function(){return i},Bv:function(){return h},HD:function(){return c},uc:function(){return _},Yl:function(){return x},QK:function(){return C},Pn:function(){return y},SC:function(){return g}}),n("../../common/lib/core.js");var s=n("../../common/lib/errors.js");function o(e){return void 0!==e}function i(e){return null!=e}function r(e){return"boolean"==typeof e}function a(e){return"number"==typeof e}function c(e){return"string"==typeof e}function l(e){return"function"==typeof e}const u=Array.isArray;function d(e){return"object"==typeof e&&null!==e}function h(e){return e}function f(e,t){return e instanceof t}function m(e){return t=>t instanceof e}function p(...e){return e.reduce(((e,t)=>(Object.entries(t).forEach((([t,n])=>{if(void 0!==n){const s=e[t];u(n)?e[t]=n:d(n)&&d(s)?e[t]=p(s,n):e[t]=n}})),e)),{})}class b{constructor(e){this.defaults=e}apply(e){return Object.freeze(p(this.defaults,e))}}function g(){return{withDefaults:e=>new b(e)}}function y(){return e=>e}function v(e){const t=(n=function(e,t=!1){return(t?Reflect.ownKeys:Object.keys)(e).map((t=>[t,e[t]]))}(e).map((([e,t])=>[t,e])),Object.fromEntries(n));var n;return Object.freeze({forward:Object.freeze(e),reverse:Object.freeze(t)})}function w(e){return v(e)}function x(e,t){return Object.fromEntries(Object.entries(e).map((([e,n])=>[e,t(n,e)])))}function C(e,t){return function(e,t){return Object.defineProperties({},x(e,t))}(e,((e,n)=>({get:t(e,n)})))}function j(e){return e}function S(e){const t=[];for(;d(e)&&e!==Object.prototype;)t.push(e),e=Reflect.getPrototypeOf(e);return t}function _(e,t){const n=t?.includePrototypes??!1,s=t?.includeInternal??!1,o=t?.prioritizedKeys??[],i=t?.filterTypes??["attribute"],r=[];s||r.push((e=>!e.startsWith("__"))),i.length&&r.push((t=>i.includes(function(e,t){let n=!0;for(const s of S(e)){const e=Object.getOwnPropertyDescriptor(s,t);if(e)return e.get||e.set?"accessor":n?"attribute":"method";n=!1}}(e,t)))),o.length&&r.push((e=>!o.includes(e)));const a=(n?S(e):[e]).map((e=>function(e){return Reflect.ownKeys(e)}(e).filter((e=>c(e)&&r.every((t=>t(e)))))));var l;return a.unshift(o.filter((l=e,e=>e in l))),a.flat()}s.sH,Symbol("ReadOnlyProxy")},"../../common/lib/iterators.js":function(e,t,n){"use strict";function s(e,t){let n=0;for(const s of e)t(s,n++)}function*o(e,t=0){for(let n=t;n{(0,o.Zo)(t),console.warn(e??"Unexpected error.",t.message,t)}}function h(e){return(0,i.Kn)(e)?e.constructor.name:typeof e}var f;function m(e){let t=`${e.delims[0]} /*`;return void 0!==e.index&&(t+=` ${e.ref?"@":"#"}${e.index}`),void 0!==e.label&&(t+=` ${e.label}`),t+=" */",e.ref&&(t+=` ${e.delims[1]}`),t}!function(e){e[e.Stringify=0]="Stringify",e[e.Custom=1]="Custom"}(f||(f={}));const p=[EventTarget],b=new Array([window,"window"],[document,"document"]).map((([e,t])=>[e,m({delims:"{}",label:t,ref:!0})]));function g(...e){p.push(...e)}function y(e,t={},n){let s;if(t.impl===f.Stringify)s=JSON.stringify(e,void 0,2)??"undefined";else if(void 0===e)s="undefined";else if(null===e)s="null";else if("function"==typeof e)s="function";else if("object"==typeof e){const o=(0,i.kJ)(e),r=o?"[]":"{}";n??(n=new Map(b));const a=n.size-b.length,c=e.constructor?.name;s=m({delims:r,index:a,label:c,ref:!1}),n.set(e,m({delims:r,index:a,label:c,ref:!0}));const l=t.indent??"",u=l+" ";let d;d=o?e:p.some((t=>e instanceof t))?[]:(0,i.uc)(e,t);let h=0;for(const i of d){let r;if(!o&&"symbol"==typeof i&&!t.showSymbolKeys)continue;const a=o?i:e[i];if(r=n.get(a),void 0===r)if(r=y(a,{...t,indent:u},n),o);else if("undefined"===r&&!t.showUndefinedProperties)continue;if(++h>50){s+=`\n${u}…`;break}s+=o?`\n${u}${r}`:`\n${u}${String(i)}: ${r}`}s+=0===h?` ${r[1]}`:`\n${l}${r[1]}`}else s="string"==typeof e?`"${e}"`:"symbol"==typeof e?`${String(e)}`:`${e}`;const o=t.maxTotalLength??10024;return s.length<=o?s:"{"===s[0]?`${s.substr(0,o-2)}…}`:`${s.substr(0,o-1)}…`}function v(e,t=2){return Number(e.toFixed(t)).toString()}function w(e){return`0x${e.toString(16)}`}var x;!function(e){e[e.Call=0]="Call",e[e.Return=1]="Return",e[e.Both=2]="Both"}(x||(x={}));const C=/\/([^/]+)\)/,j=(new class{constructor(){this.map=new Map}set(e,t){return this.map.set(e,t),this}format(e){return this.map.get(e.constructor)?.(e)}}).set(r.UH,(e=>[`%c${v(e.quantity,2)}%c${e.unit.label}`,u.number,u.subtle]));function S(e,t){j.set(e,t)}function _(e,t=0,n=5){if((0,i.kJ)(e)){if(t>0){const s=[],o=[];for(const i of e){if(n<=0){s.push("%c,…}"),o.push(u.subtle);break}const[e,...r]=_(i,t-1);s.push(e),o.push(u.subtle,...r),n-=1}return[`%c[${s.join("%c, ")}%c]`,...o,u.subtle]}return["%c[…]}",u.subtle]}if((0,i.Kn)(e)){const s=j.format(e);if(s)return s;const o=[],r=[];if(e.constructor!==Object&&(o.push(`%c${e.constructor.name}`),r.push(u.type)),t>0){let s=!0;o.push("%c{"),r.push(u.subtle);for(const a of(0,i.uc)(e,{prioritizedKeys:["id","name"]})){const c=e[a];if(n<=0){o.push("%c, …}"),r.push(u.subtle);break}if(s?s=!1:(o.push(s?"%c{":"%c, "),r.push(u.subtle)),void 0===c)o.push(`%c${String(a)}%c?`),r.push(u.key,u.subtle);else if((0,i.mf)(c))o.push(`%c${String(a)}%c()`),r.push(u.method,u.subtle);else{const[e,...n]=_(c,t-1);o.push(`%c${String(a)}%c: ${e}`),r.push(u.key,u.subtle,...n)}n-=1}o.push("%c}"),r.push(u.subtle)}else o.push("%c{…}"),r.push(u.subtle);return[o.join(""),...r]}return(0,i.mf)(e)?[`%c${e.name}%c()`,u.method,u.subtle]:"number"==typeof e?[`%c${v(e,4)}`,u.number]:"string"==typeof e?e?[`%c${e}`,u.string]:["''"]:["boolean","null","undefined"].includes(typeof e)?[`%c${String(e)}`,u.keyword]:["%o",e]}const k=console.log,E={canSample:()=>!0,didSample:()=>{},skippedSamples:1,log:(e,t,n,...s)=>k(n,...s)};class O{constructor(e){this.lastSample=0,this.lastLog="",this.skippedSamples=0,e.rate?"time"===e.rate.unit.quantity.label?this.minDelay=1e3*e.rate.value:this.minDelay=1e3/e.rate.value:this.minDelay=0,this.omitDuplicates=e.omitDuplicates??!1}static from(e){if(!e?.logId)return(0,s.BF)(void 0===e?.rate&&void 0===e?.omitDuplicates,"logging `rate` and `omitDuplicates` require `logId`"),E;let t=O.stateMap[e.logId];return t||(t=new O(e),O.stateMap[e.logId]=t),t}canSample(){return this.skippedSamples+=1,Date.now()-this.lastSample>=this.minDelay}didSample(){this.skippedSamples=0,this.lastSample=Date.now()}log(e,t,n,...s){if(this.omitDuplicates){const o=[n.slice(e),...s.slice(t)].join("");if(o===this.lastLog)return;this.lastLog=o}this.didSample(),k(n,...s)}}O.stateMap={};const T=(0,i.SC)().withDefaults({density:"inline",defaultStyle:u.default,calleeDepth:2,prettyDepth:2,emitSkips:!0});function $(...e){return e.reduce(((e,t,n)=>{if(0===n)return t;let s=0;for(;s{if("string"==typeof e)return[`%c${e}`,[r]];{const[t,...n]=_(e,a);return[t,n]}}));else{const e=t;l=Object.keys(e).map((t=>{const[n,...s]=_(e[t],a);return[`%c${t}%c:${n}`,[u.highlight,u.subtle,...s]]}))}const d=function(e=1){const t=new Error;if(void 0===t.stack)return;const n=t.stack.split("\n");if(n.length<=e+1)return;const s=n[e+1].match(C);if(!s||s.length<2)return;let[o,i,r]=s[1].split(":");return"?"===o.charAt(o.length-1)&&(o=o.substring(0,o.length-1)),{file:o,line:i,column:r}}(o.calleeDepth);d&&l.push([`%c${d.file}:${d.line}:${d.column}`,[u.callSite]]);const h=[],f=[];let m=0,p=0;if(c>0&&o.emitSkips){const e=`%c${c}%c`;m=e.length+1,h.push(e),p=2,f.push(u.skipCount,r)}if(void 0!==e&&("inline"===o.density?(h.push(`%c${e}%c`),f.push(u.inlineHeader,r)):(h.push(`%c ${e} `.padEnd(80)),f.push(u.groupHeader))),"inline"===o.density)s.log(m,p,$(...h,...l.map((([e])=>e))),...f,...l.flatMap((([e,t])=>t)));else{s.didSample(),"expanded"===o.density?console.group($(...h),...f):console.groupCollapsed($(...h),...f);for(const[e,t]of l)k(e,...t);console.groupEnd()}}function M(e,t){t??(t={});const{density:n,defaultStyle:s,calleeDepth:o,prettyDepth:i,logId:a,rate:c,omitDuplicates:l,emitSkips:u,...d}=t;t.logId??(t.logId=Symbol.for(e)),t.rate??(t.rate=r.UH.of(3,r._H)),t.omitDuplicates??(t.omitDuplicates=!0),A(e,d,t)}console.log=console.info=(e,...t)=>A(void 0,[e,...t],{defaultStyle:u.console,calleeDepth:3})},"../../common/lib/units.js":function(e,t,n){"use strict";n.d(t,{HA:function(){return A},J4:function(){return k},Lm:function(){return L},ON:function(){return E},P1:function(){return R},R2:function(){return D},TT:function(){return I},T_:function(){return N},UH:function(){return _},XF:function(){return B},_H:function(){return O},ew:function(){return F},gG:function(){return z},lf:function(){return P},wI:function(){return M}});var s,o,i,r,a,c,l,u,d=n("../../common/lib/logging.js");!function(e){e.Dot="⋅",e.One="¹",e.Two="²",e.Neg="⁻",e.NegOne="⁻¹",e.NegTwo="⁻²"}(u||(u={}));class h{constructor(e){this.label=e}toString(){return this.label}}class f extends h{constructor(){super("length"),s.set(this,void 0)}}s=new WeakMap,f.i=new f;class m extends h{constructor(){super("mass"),o.set(this,void 0)}}o=new WeakMap,m.i=new m;class p extends h{constructor(){super("time"),i.set(this,void 0)}}i=new WeakMap,p.i=new p;class b extends h{constructor(){super("rotation"),r.set(this,void 0)}}r=new WeakMap,b.i=new b;class g extends h{constructor(){super("cardinality"),a.set(this,void 0)}}a=new WeakMap,g.i=new g;class y extends h{constructor(){super("ratio"),c.set(this,void 0)}}c=new WeakMap,y.i=new y;class v extends h{constructor(){super("repetitions"),l.set(this,void 0)}}l=new WeakMap,v.i=new v;class w extends h{constructor(e,t,n){super(e),this.numerator=t,this.denominator=n}}class x extends h{constructor(e,t,n){super(e),this.q1=t,this.q2=n}}const C={[`m${u.Dot}s${u.NegOne}${u.Dot}s${u.NegOne}`]:`m${u.Dot}s${u.NegTwo}`,[`kg${u.Dot}m${u.Dot}s${u.NegTwo}`]:"N",[`cyc${u.Dot}s${u.NegOne}`]:"Hz"},j={"length/time":"velocity","velocity/time":"acceleration","mass*acceleration":"force","cycles/time":"frequency"};class S{constructor(e,t,n){this.engineRatio=e,this.label=t,this.quantity=n}static of(e,t,n){return new S(e*t.engineRatio,n,t.quantity)}times(e){const t=this.engineRatio*e.engineRatio;let n=this.label&&e.label?`${this.label}${u.Dot}${e.label}`:this.label?this.label:e.label;for(;n in C;)n=C[n];let s=`${this.quantity.label} * ${e.quantity.label}`;for(;s in j;)s=j[s];return new S(t,n,new x(s,this.quantity,e.quantity))}per(e){const t=this.engineRatio/e.engineRatio;let n=`${this.label}${u.Dot}${e.label}${u.NegOne}`;for(;n in C;)n=C[n];let s=`${this.quantity.label} / ${e.quantity.label}`;for(;s in j;)s=j[s];return new S(t,n,new w(s,this.quantity,e.quantity))}}class _{constructor(e,t){this.quantity=e,this.unit=t}static of(e,t){return new _(e,t)}static from(e,t,n){return e instanceof _?e:_.of(e??t,n)}scale(e){return _.of(this.quantity*e,this.unit)}ratioTo(e){return this.value/e.value}plus(e){return _.of(this.quantity+e.getUnitQuantity(this.unit),this.unit)}minus(e){return _.of(this.quantity-e.getUnitQuantity(this.unit),this.unit)}times(e){return _.of(this.quantity*e.quantity,this.unit.times(e.unit))}per(e){return _.of(this.quantity/e.quantity,this.unit.per(e.unit))}get value(){return this.quantity*this.unit.engineRatio}isEqualTo(e){return this.value===e.value}isCloseTo(e,t){if(this.value===e.value)return!0;const n=e.minus(t),s=e.plus(t);return n.isLessThan(this)&&this.isLessThan(s)}isLessThan(e){return this.value=o)&&Object.keys(i.O).every((function(e){return i.O[e](n[c])}))?n.splice(c--,1):(a=!1,o0&&e[u-1][2]>o;u--)e[u]=e[u-1];e[u]=[n,s,o]},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,{a:t}),t},i.d=function(e,t){for(var n in t)i.o(t,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},i.f={},i.e=function(e){return Promise.all(Object.keys(i.f).reduce((function(t,n){return i.f[n](e,t),t}),[]))},i.u=function(e){return{46:"scene.ld51-index-ts",338:"scene.template-index-ts",381:"scene.infra-index-ts",782:"scene.demolition-index-ts",868:"scene.unladen-index-ts",893:"scene.roguerally-index-ts",947:"scene.jukebox-index-ts"}[e]+"."+{46:"52824ad66f62b6286d75",338:"483a38251116ada33843",381:"46777c3870752af90e6b",782:"913ae7b85bd8b27df6ea",868:"06e6231ff59664ffeae7",893:"87f6bc3d99cd311894c2",947:"a210cf6dd095324db4cb"}[e]+".js"},i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t={},n="@ld/apps.ludathon:",i.l=function(e,s,o,r){if(t[e])t[e].push(s);else{var a,c;if(void 0!==o)for(var l=document.getElementsByTagName("script"),u=0;u