import{A as e,Fr as t,Jt as n,X as r,cr as i,ft as a,gn as o,kr as s,xr as c}from"./three@0.169.19.js";import{Ka as l,Mt as u,Ua as d,Vn as f,Xi as p,Zi as m,aa as ee,co as h,eo as te,gr as g,mt as ne,na as re,ot as ie,qr as ae,ra as oe,z as _}from"./needle-engine-ui.B3WhUziG.js";import{B as se}from"./postprocessing.Wy71DpiM.js";var v=h(`debugpost`),y=null;function ce(e){y=e}function le(e){let t=e.gameObject;for(;t;){for(let e of u(t))if(e.isPostProcessingManager===!0)return e;t=t.parent}return null}function ue(e){let t=le(e);if(!t)if(y){v&&console.warn(`Adding postprocessing manager to the scene.`);let n=e.scene;t=ne(n,y)}else l()&&console.warn(`No post processing manager found`);return t}var b={AT_START:-1e4,NormalPass:0,DepthDownsamplingPass:10,SSAO:20,SMAA:30,TiltShift:40,DepthOfField:50,ChromaticAberration:60,Bloom:70,Vignette:80,Pixelation:90,ToneMapping:100,HueSaturation:110,BrightnessContrast:120,Sharpening:130,AT_END:1e4},x=null;function de(e){if(v===`verbose`&&console.debug(`Before ordering effects`,[...e]),!x){x=new Map,x.set(g.POSTPROCESSING.MODULE.NormalPass,b.NormalPass),x.set(g.POSTPROCESSING.MODULE.DepthDownsamplingPass,b.DepthDownsamplingPass),x.set(g.POSTPROCESSING.MODULE.SMAAEffect,b.SMAA),x.set(g.POSTPROCESSING.MODULE.SSAOEffect,b.SSAO);let e=g.POSTPROCESSING_AO.MAYBEMODULE;e&&(x.set(e.N8AOPostPass,b.SSAO),x.set(e.N8AOPass,b.SSAO)),x.set(g.POSTPROCESSING.MODULE.TiltShiftEffect,b.TiltShift),x.set(g.POSTPROCESSING.MODULE.DepthOfFieldEffect,b.DepthOfField),x.set(g.POSTPROCESSING.MODULE.ChromaticAberrationEffect,b.ChromaticAberration),x.set(g.POSTPROCESSING.MODULE.BloomEffect,b.Bloom),x.set(g.POSTPROCESSING.MODULE.SelectiveBloomEffect,b.Bloom),x.set(g.POSTPROCESSING.MODULE.VignetteEffect,b.Vignette),x.set(g.POSTPROCESSING.MODULE.PixelationEffect,b.Pixelation),x.set(g.POSTPROCESSING.MODULE.ToneMappingEffect,b.ToneMapping),x.set(g.POSTPROCESSING.MODULE.HueSaturationEffect,b.HueSaturation),x.set(g.POSTPROCESSING.MODULE.BrightnessContrastEffect,b.BrightnessContrast)}e.sort((e,t)=>{let n=typeof e.priority==`number`?e.priority:x.get(e.effect.constructor)??-1/0,r=typeof t.priority==`number`?t.priority:x.get(t.effect.constructor)??-1/0;return n===-1/0?(v&&console.warn(`Unknown effect found: `,e.constructor.name,e),1):r===-1/0?(v&&console.warn(`Unknown effect found: `,t.constructor.name,t),-1):n-r}),v===`verbose`&&console.debug(`After ordering effects`,[...e])}var fe=function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},pe=h(`debugpost`),S=class{isVolumeParameter=!0;constructor(e){e!==void 0&&this.initialize(e)}_isInitialized=!1;get isInitialized(){return this._isInitialized}initialize(e){e!==void 0&&(this._value=e,this._defaultValue=e,this._valueRaw=e,this._isInitialized=!0)}get overrideState(){return this._active}set overrideState(e){if(this._active===e)return;this._active=e;let t=e?this._valueRaw:this._defaultValue;this.processValue(t,!0)}_active=!0;get value(){return this._valueRaw}set value(e){this.isInitialized||this.initialize(e),this.processValue(e,!1)}_value;_valueRaw;set defaultValue(e){this._defaultValue=e}_defaultValue=void 0;__init(){this.processValue(this._valueRaw,!0)}valueProcessor;onValueChanged;processValue(e,t){if(e==null||!t&&this.testIfValueChanged(e)===!1)return;let n=this._value;pe&&typeof n==`number`&&typeof e==`number`&&(n?.toFixed(4),e?.toFixed(4)),!this._active&&this._defaultValue!==void 0?(this._value=this._defaultValue,e=this._defaultValue,this._valueRaw=e):(this._valueRaw=e,this._active&&this.valueProcessor&&(e=this.valueProcessor(e)),this._value=e),this.onValueChanged&&this.onValueChanged(e,n,this)}testIfValueChanged(e){return this._valueRaw!==e}};fe([p()],S.prototype,`overrideState`,null),fe([p()],S.prototype,`value`,null),new class extends ae{constructor(){super([S])}onSerialize(e,t){}onDeserialize(e,t){let n=t.target,r=t.path,i;if(n&&r&&(i=n[r]),(typeof i!=`object`||typeof i==`object`&&i.isVolumeParameter!==!0)&&(i=new S),typeof e==`object`&&`value`in e){let t=e.value;i.initialize(t),i.overrideState=e.overrideState}else i.value=e;return i}};var me=function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},C=h(`debugpost`),w=class extends ie{get isPostProcessingEffect(){return!0}order=void 0;constructor(e=void 0){if(super(),e)for(let t of Object.keys(e)){let n=e[t],r=this[t];r instanceof S?r.initialize(n):r!==void 0&&(this[t]=n)}}active=!0;_manager=null;onEnable(){super.onEnable(),C&&console.warn(`Enable`,this.constructor.name+(this.__internalDidAwakeAndStart?``:` (awake)`)),this.__internalDidAwakeAndStart&&(this.active=!0),this.onEffectEnabled()}onDisable(){super.onDisable(),C&&console.warn(`Disable`,this.constructor.name),this._manager?.removeEffect(this),this.active=!1}onEffectEnabled(e){e&&e.isPostProcessingManager===!0?this._manager=e:this._manager||=ue(this),this._manager.addEffect(this),this._manager.dirty=!0}init(){}_result;_postprocessingContext=null;get postprocessingContext(){return this._postprocessingContext}apply(e){return this._postprocessingContext=e,this._result||=(this.initParameters(),this.onCreateEffect?.call(this)),this._result&&this.initParameters(),this._result}unapply(){}dispose(){C&&console.warn(`DISPOSE`,this),this._result&&(Array.isArray(this._result)?this._result.forEach(e=>e.dispose()):this._result.dispose()),this._result=void 0}initParameters(){let e=Object.keys(this);for(let t of e){let e=this[t];e instanceof S&&e.__init()}}onEditorModification(e){let t=e.propertyName;if(this[t]instanceof S){let n=e.value;return this[t].value=n,!0}}};me([p()],w.prototype,`active`,void 0);var he=function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},ge=h(`debugpost`),_e={};function T(e,t){_e[e]=t}function ve(e){return e.__type in _e?_e[e.__type]:(ge&&e.__type&&console.warn(`Unknown postprocessing type`,e.__type,e),w)}var ye=class{components=[];__init(e){this.components?.forEach(t=>{t.gameObject===void 0&&e.gameObject.addComponent(t),t.init()})}addEffect(e){this.components.push(e)}removeEffect(e){let t=this.components.indexOf(e);t>=0&&this.components.splice(t,1)}};he([m([e=>ve(e),w])],ye.prototype,`components`,void 0);var be=function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},xe=h(`debugpost`),Se;(function(e){e[e.LOW=0]=`LOW`,e[e.MEDIUM=1]=`MEDIUM`,e[e.HIGH=2]=`HIGH`,e[e.ULTRA=3]=`ULTRA`})(Se||={});var Ce=class extends w{get typeName(){return`Antialiasing`}preset=new S(2);onCreateEffect(){let e=new g.POSTPROCESSING.MODULE.SMAAEffect({preset:this.preset?.value??g.POSTPROCESSING.MODULE.SMAAPreset.HIGH,edgeDetectionMode:g.POSTPROCESSING.MODULE.EdgeDetectionMode.LUMA});return this.preset.onValueChanged=t=>{xe&&console.log(`Antialiasing preset changed to`,t),e.applyPreset(t)},e}};be([p(S)],Ce.prototype,`preset`,void 0),T(`Antialiasing`,Ce);var we=function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},E=class e extends w{static useSelectiveBloom=!1;get typeName(){return`Bloom`}threshold=new S(.9);intensity=new S(1);scatter=new S(.7);selectiveBloom;init(){this.threshold.valueProcessor=e=>e,this.intensity.valueProcessor=e=>e,this.scatter.valueProcessor=e=>e}onCreateEffect(){let t;if(this.selectiveBloom??=e.useSelectiveBloom,this.selectiveBloom){let e=t=new g.POSTPROCESSING.MODULE.SelectiveBloomEffect(this.context.scene,this.context.mainCamera,{blendFunction:g.POSTPROCESSING.MODULE.BlendFunction.ADD,mipmapBlur:!0,luminanceThreshold:this.threshold.value,luminanceSmoothing:this.scatter.value,radius:.85,intensity:this.intensity.value});e.inverted=!0}else t=new g.POSTPROCESSING.MODULE.BloomEffect({blendFunction:g.POSTPROCESSING.MODULE.BlendFunction.ADD,mipmapBlur:!0,luminanceThreshold:this.threshold.value,luminanceSmoothing:this.scatter.value,radius:.85,intensity:this.intensity.value});return this.intensity.onValueChanged=e=>{t.intensity=e},this.threshold.onValueChanged=e=>{t.luminanceMaterial.threshold=e**2.2},this.scatter.onValueChanged=e=>{t.luminancePass.enabled=!0,t.luminanceMaterial.smoothing=e,t.mipmapBlurPass&&(t.mipmapBlurPass.radius=n.lerp(.1,.9,e))},t}};we([p(S)],E.prototype,`threshold`,void 0),we([p(S)],E.prototype,`intensity`,void 0),we([p(S)],E.prototype,`scatter`,void 0),T(`Bloom`,E);var Te=function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},D=class extends w{get typeName(){return`ChromaticAberration`}intensity=new S(0);onCreateEffect(){let e=new g.POSTPROCESSING.MODULE.ChromaticAberrationEffect;return e.offset=new s(0,0),e.radialModulation=!0,e.modulationOffset=.15,this.intensity.valueProcessor=e=>e*.02,this.intensity.onValueChanged=t=>{e.offset.x=-t,e.offset.y=t},e}};Te([p(S)],D.prototype,`intensity`,void 0),T(`ChromaticAberration`,D);var O;(function(e){e[e.None=0]=`None`,e[e.Neutral=1]=`Neutral`,e[e.ACES=2]=`ACES`,e[e.AgX=3]=`AgX`,e[e.KhronosNeutral=4]=`KhronosNeutral`})(O||={});var Ee=new Map;function k(e){switch(e){case O.None:return 1;case O.Neutral:return 2;case O.ACES:return 4;case O.AgX:return 6;case O.KhronosNeutral:return 7;default:return Ee.has(e)||(Ee.set(e,!0),console.warn(`[Postprocessing] Unknown tone mapping mode`,e)),7}}function De(e){switch(e){case 1:return O.None;case 4:return O.ACES;case 6:return O.AgX;case 7:return O.Neutral;case 2:return O.Neutral;default:return O.None}}function A(e){switch(e){case 1:return g.POSTPROCESSING.MODULE.ToneMappingMode.LINEAR;case 4:return g.POSTPROCESSING.MODULE.ToneMappingMode.ACES_FILMIC;case 6:return g.POSTPROCESSING.MODULE.ToneMappingMode.AGX;case 7:return g.POSTPROCESSING.MODULE.ToneMappingMode.NEUTRAL;case 2:return g.POSTPROCESSING.MODULE.ToneMappingMode.REINHARD;default:return g.POSTPROCESSING.MODULE.ToneMappingMode.LINEAR}}var Oe=function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},j=h(`debugpost`),M=class extends w{get typeName(){return`ToneMapping`}mode=new S(void 0);exposure=new S(1);setMode(e){let t=O[e];return t===void 0?(console.error(`[PostProcessing] Invalid ToneMapping mode`,e),this):(this.mode.value=t,this)}get isToneMapping(){return!0}onEffectEnabled(){let e=le(this);e&&super.onEffectEnabled(e)}_tonemappingEffect=null;onCreateEffect(){if(this.mode.isInitialized==0){let e=De(this.context.renderer.toneMapping);j&&console.log(`[PostProcessing] Initializing ToneMapping mode to renderer.toneMapping`,this.context.renderer.toneMapping+` → `+e),this.mode.initialize(e)}this._tonemappingEffect?.dispose();let e=k(this.mode.value),t=this._tonemappingEffect=new g.POSTPROCESSING.MODULE.ToneMappingEffect({mode:A(e)});return this.mode.onValueChanged=n=>{typeof n==`string`?(n=f(n),t.mode=A(n)):t.mode=A(k(n)),t.name=`ToneMapping (`+O[n]+`)`,j&&console.log(`[PostProcessing] ToneMapping mode changed to`,O[n],e,t.mode)},j&&console.log(`[PostProcessing] Use ToneMapping`,O[this.mode.value],e,t.mode,`renderer.tonemapping: `+this.context.renderer.toneMapping),t}onBeforeRender(){if(this._tonemappingEffect&&this.postprocessingContext?.handler.getEffectIsActive(this._tonemappingEffect)&&(this.mode.overrideState&&(this.context.renderer.toneMapping=k(this.mode.value)),this.exposure.overrideState&&this.exposure.value!==void 0)){let e=Math.max(0,this.exposure.value);this.context.renderer.toneMappingExposure=e}}};Oe([p(S)],M.prototype,`mode`,void 0),Oe([p(S)],M.prototype,`exposure`,void 0),T(`Tonemapping`,M);var N=function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},P=class extends w{get typeName(){return`ColorAdjustments`}remap=!0;postExposure=new S(1);contrast=new S(0);hueShift=new S(0);saturation=new S(0);init(){this.postExposure.valueProcessor=e=>(this.remap&&(e=2**e),e),this.contrast.valueProcessor=e=>{if(!this.remap)return e;let t=1;return e>0?t=200:e<0&&(t=100),e/t},this.contrast.defaultValue=0,this.hueShift.valueProcessor=e=>this.remap?Math.PI*e/180:e,this.hueShift.defaultValue=0,this.saturation.valueProcessor=e=>this.remap?e<0?e/100:e/(100*Math.PI):e,this.saturation.defaultValue=0}onCreateEffect(){let e=[],t=this.postprocessingContext?.components.find(e=>e instanceof M);t||(t=new M,this.postprocessingContext?.components.push(t)),this.postExposure.onValueChanged=e=>{this.postExposure.overrideState&&t?t.exposure.value=e:console.warn(`[PostProcessing] PostExposure is set to override but no ToneMappingEffect found in the postprocessing stack. Please add a ToneMappingEffect to your postprocessing stack to use PostExposure.`)};let n=new g.POSTPROCESSING.MODULE.BrightnessContrastEffect;this.contrast.onValueChanged=e=>n.contrast=e;let r=new g.POSTPROCESSING.MODULE.HueSaturationEffect;return this.hueShift.onValueChanged=e=>r.hue=e,this.saturation.onValueChanged=e=>r.saturation=e,e.push(n),e.push(r),e}};N([p(S)],P.prototype,`postExposure`,void 0),N([p(S)],P.prototype,`contrast`,void 0),N([p(S)],P.prototype,`hueShift`,void 0),N([p(S)],P.prototype,`saturation`,void 0),T(`ColorAdjustments`,P);var F=function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},ke;(function(e){e[e.Off=0]=`Off`,e[e.Gaussian=1]=`Gaussian`,e[e.Bokeh=2]=`Bokeh`})(ke||={});var Ae=h(`debugpost`),I=class extends w{get typeName(){return`DepthOfField`}mode;focusDistance=new S(1);focalLength=new S(.2);aperture=new S(20);gaussianMaxRadius=new S;resolutionScale=new S(1/window.devicePixelRatio);bokehScale=new S;init(){this.focalLength.valueProcessor=e=>{let t=e/300;return d.lerp(2,.01,t)},this.aperture.valueProcessor=e=>{let t=1-e/32;return d.lerp(1,20,t)}}onCreateEffect(){if(this.mode===ke.Off){Ae&&console.warn(`DepthOfField: Mode is set to Off`);return}let e=new g.POSTPROCESSING.MODULE.DepthOfFieldEffect(this.context.mainCamera,{worldFocusRange:.2,focalLength:1,bokehScale:20,resolutionScale:this.resolutionScale.value});return this.focusDistance.onValueChanged=t=>{e.cocMaterial.worldFocusDistance=t},this.focalLength.onValueChanged=t=>e.cocMaterial.worldFocusRange=t,this.aperture.onValueChanged=t=>e.bokehScale=t,this.resolutionScale&&(this.resolutionScale.onValueChanged=t=>e.resolution.scale=t),[e]}unapply(){}};F([p()],I.prototype,`mode`,void 0),F([p(S)],I.prototype,`focusDistance`,void 0),F([p(S)],I.prototype,`focalLength`,void 0),F([p(S)],I.prototype,`aperture`,void 0),F([p(S)],I.prototype,`gaussianMaxRadius`,void 0),F([p(S)],I.prototype,`resolutionScale`,void 0),F([p(S)],I.prototype,`bokehScale`,void 0),T(`DepthOfField`,I);var je=class extends w{effect;constructor(e){super(),this.effect=e}get typeName(){return this.effect.constructor.name}onCreateEffect(){return this.effect}},Me=function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},L=class extends w{get typeName(){return`PixelationEffect`}granularity=new S(10);onCreateEffect(){let e=new g.POSTPROCESSING.MODULE.PixelationEffect;return this.granularity.onValueChanged=t=>{e.granularity=t},e}};Me([p(S)],L.prototype,`granularity`,void 0),T(`PixelationEffect`,L);var R=function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},z=class extends w{get typeName(){return`ScreenSpaceAmbientOcclusion`}intensity=new S(2);falloff=new S(1);samples=new S(9);color=new S(new e(0,0,0));luminanceInfluence=new S(.7);onBeforeRender(){if(this._ssao&&this.context.mainCamera instanceof o){let e=this.context.mainCamera.far-this.context.mainCamera.near;this._ssao.ssaoMaterial.worldDistanceFalloff=e*.01,this._ssao.ssaoMaterial.worldDistanceThreshold=this.context.mainCamera.far}}_ssao;onCreateEffect(){let t=this.context.mainCamera,n=new g.POSTPROCESSING.MODULE.NormalPass(this.context.scene,t),r=new g.POSTPROCESSING.MODULE.DepthDownsamplingPass({normalBuffer:n.texture,resolutionScale:.5}),i=this._ssao=new g.POSTPROCESSING.MODULE.SSAOEffect(t,n.texture,{normalDepthBuffer:r.texture,worldDistanceThreshold:1,worldDistanceFalloff:1,worldProximityThreshold:.1,worldProximityFalloff:2,intensity:1,blendFunction:g.POSTPROCESSING.MODULE.BlendFunction.MULTIPLY,luminanceInfluence:.5});this.intensity.onValueChanged=e=>{i.intensity=e},this.falloff.onValueChanged=e=>{i.ssaoMaterial.radius=e*.1},this.samples.onValueChanged=e=>{i.ssaoMaterial.samples=e},this.color.onValueChanged=t=>{i.color||=new e,i.color.copy(t)},this.luminanceInfluence.onValueChanged=e=>{i.luminanceInfluence=e};let a=[];return a.push(n),a.push(r),a.push(i),a}};R([p(S)],z.prototype,`intensity`,void 0),R([p(S)],z.prototype,`falloff`,void 0),R([p(S)],z.prototype,`samples`,void 0),R([p(S)],z.prototype,`color`,void 0),R([p(S)],z.prototype,`luminanceInfluence`,void 0),T(`ScreenSpaceAmbientOcclusion`,z);var B=function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},Ne=h(`debugN8AO`),V;(function(e){e[e.Performance=0]=`Performance`,e[e.Low=1]=`Low`,e[e.Medium=2]=`Medium`,e[e.High=3]=`High`,e[e.Ultra=4]=`Ultra`})(V||={});var H=class extends w{get typeName(){return`ScreenSpaceAmbientOcclusionN8`}get pass(){return this._ssao}gammaCorrection=!0;aoRadius=new S(1);falloff=new S(1);intensity=new S(1);color=new S(new e(0,0,0));screenspaceRadius=!1;quality=V.Medium;_ssao;onValidate(){this._ssao&&(this._ssao.setQualityMode(V[this.quality]),this._ssao.configuration.gammaCorrection=this.gammaCorrection,this._ssao.configuration.screenSpaceRadius=this.screenspaceRadius)}onCreateEffect(){let n=this.context.mainCamera,r=this.context.domWidth,i=this.context.domHeight,a=this._ssao=new g.POSTPROCESSING_AO.MODULE.N8AOPostPass(this.context.scene,n,r,i);a.name=`SSAO_N8`;let o=V[this.quality];if(a.setQualityMode(o),a.configuration.transparencyAware=!1,a.configuration.halfRes=window.devicePixelRatio>1,a.effectCompositerQuad?.material){let e=a.effectCompositerQuad.material;e.fragmentShader=e.fragmentShader.replace(`if (depth == 1.0) { texel = vec4(0.0, 0.0, 0.0, 1.0);`,`if (depth == 1.0) { gl_FragColor = sceneTexel; return;`),e.needsUpdate=!0}let s=new t(r,i);return a.configuration.beautyRenderTarget=s,a.configuration.autoRenderBeauty=!1,a.configuration.gammaCorrection=this.gammaCorrection,a.configuration.screenSpaceRadius=this.screenspaceRadius,Ne&&(a.enableDebugMode(),console.log(a),setInterval(()=>{console.log(`SSAO`,a.lastTime)},1e3),setInterval(()=>{console.log(`SSAO`,a.enabled,{ssao:a,autoRenderBeauty:a.configuration.autoRenderBeauty})},4e3)),this.intensity.onValueChanged=e=>{a.configuration.intensity=e},this.falloff.onValueChanged=e=>{a.configuration.distanceFalloff=e},this.aoRadius.onValueChanged=e=>{a.configuration.aoRadius=e},this.color.onValueChanged=t=>{a.color||=new e,a.configuration.color.copy(t)},a}};B([_(),p()],H.prototype,`gammaCorrection`,void 0),B([p(S)],H.prototype,`aoRadius`,void 0),B([p(S)],H.prototype,`falloff`,void 0),B([p(S)],H.prototype,`intensity`,void 0),B([p(S)],H.prototype,`color`,void 0),B([_(),p()],H.prototype,`screenspaceRadius`,void 0),B([_(),p()],H.prototype,`quality`,void 0),T(`ScreenSpaceAmbientOcclusionN8`,H);var Pe=function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},U=class extends w{get typeName(){return`Sharpening`}order=b.Sharpening;_effect;onCreateEffect(){return this._effect??=new(Fe()),this.effect}get effect(){return this._effect}set amount(e){this._amount=e,this._effect&&(this._effect.uniforms.get(`amount`).value=e)}get amount(){return this._effect?this._effect.uniforms.get(`amount`).value:this._amount}_amount=1;set radius(e){this._radius=e,this._effect&&(this._effect.uniforms.get(`radius`).value=e)}get radius(){return this._effect?this._effect.uniforms.get(`radius`).value:this._radius}_radius=1};Pe([p()],U.prototype,`amount`,null),Pe([p()],U.prototype,`radius`,null);function Fe(){class e extends g.POSTPROCESSING.MODULE.Effect{constructor(){super(`Sharpening`,` uniform sampler2D tDiffuse; uniform float amount; uniform float radius; void mainImage(const in vec4 inputColor, const in vec2 uv, out vec4 outputColor) { float tx = 1.0 / resolution.x; float ty = 1.0 / resolution.y; vec2 texelSize = vec2(tx, ty); vec4 blurred = vec4(0.0); float total = 0.0; for (float x = -radius; x <= radius; x++) { for (float y = -radius; y <= radius; y++) { vec2 offset = vec2(x, y) * texelSize; vec4 diffuse = texture2D(tDiffuse, uv + offset); float weight = exp(-length(offset) * amount); blurred += diffuse * weight; total += weight; } } if (total > 0.0) { blurred /= total; } // Calculate the sharpened color using inputColor vec4 sharp = inputColor + clamp(inputColor - blurred, 0.0, 1.0) * amount; // Keep original alpha sharp.a = inputColor.a; // Ensure the sharp color does not go below 0 or above 1 // This means: sharpening must happen AFTER tonemapping. sharp = clamp(sharp, 0.0, 1.0); outputColor = sharp; } `,{vertexShader:` void mainSupport() { vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); } `,blendFunction:g.POSTPROCESSING.MODULE.BlendFunction.NORMAL,uniforms:new Map([[`amount`,new c(1)],[`radius`,new c(1)]]),attributes:se.CONVOLUTION})}}return e}var W=function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},G=class extends w{get typeName(){return`TiltShiftEffect`}offset=new S(0);rotation=new S(0);focusArea=new S(.4);feather=new S(.3);kernelSize=new S(2);resolutionScale=new S(1/window.devicePixelRatio);init(){this.offset.defaultValue=0,this.rotation.defaultValue=0,this.focusArea.defaultValue=.4,this.feather.defaultValue=.3,this.kernelSize.defaultValue=g.POSTPROCESSING.MODULE.KernelSize.MEDIUM,this.resolutionScale.defaultValue=1/window.devicePixelRatio}onCreateEffect(){let e=new g.POSTPROCESSING.MODULE.TiltShiftEffect({kernelSize:g.POSTPROCESSING.MODULE.KernelSize.VERY_LARGE,offset:this.offset.value,rotation:this.rotation.value,focusArea:this.focusArea.value,feather:this.feather.value});return this.offset.onValueChanged=t=>e.offset=t,this.rotation.onValueChanged=t=>e.rotation=t,this.focusArea.onValueChanged=t=>e.focusArea=t,this.feather.onValueChanged=t=>e.feather=t,this.kernelSize.onValueChanged=t=>e.blurPass.kernelSize=t,this.resolutionScale.onValueChanged=t=>e.resolution.scale=t/window.devicePixelRatio,e}};W([p(S)],G.prototype,`offset`,void 0),W([p(S)],G.prototype,`rotation`,void 0),W([p(S)],G.prototype,`focusArea`,void 0),W([p(S)],G.prototype,`feather`,void 0),W([p(S)],G.prototype,`kernelSize`,void 0),W([p(S)],G.prototype,`resolutionScale`,void 0),T(`TiltShiftEffect`,G);var K=function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},q=class extends w{get typeName(){return`Vignette`}color=new S({r:0,g:0,b:0,a:1});intensity=new S(0);center=new S({x:.5,y:.5});init(){this.color.defaultValue={r:0,g:0,b:0,a:1},this.intensity.defaultValue=0,this.center.defaultValue={x:.5,y:.5}}onCreateEffect(){let e=new g.POSTPROCESSING.MODULE.VignetteEffect;return this.intensity.onValueChanged=t=>{e.offset=t,this.updateDarkness(e)},this.color.onValueChanged=t=>{this.updateDarkness(e)},e}updateDarkness(e){e.darkness=this.intensity.value}};K([p(S)],q.prototype,`color`,void 0),K([p(S)],q.prototype,`intensity`,void 0),K([p(S)],q.prototype,`center`,void 0),T(`Vignette`,q),globalThis.NEEDLE_USE_POSTPROCESSING=globalThis.NEEDLE_USE_POSTPROCESSING===void 0?!0:globalThis.NEEDLE_USE_POSTPROCESSING;var J=h(`debugpost`),Ie=Symbol(`needle:postprocessing-handler`),Y=Symbol(`needle:previous-autoclear-state`),X=Symbol(`needle:previous-tone-mapping`),Le=class e{_composer=null;_lastVolumeComponents;_effects=[];getEffectIsActive(e){return e?this._isActive&&this._effects.some(t=>t.effect===e):!1}get isActive(){return this._isActive}get composer(){return this._composer}_isActive=!1;context;constructor(e){this.context=e}apply(e){return`env`in import.meta,this._isActive=!0,this.onApply(this.context,e)}unapply(e=!0){if(J&&console.log(`Unapplying postprocessing effects`),this._isActive=!1,this._lastVolumeComponents){for(let e of this._lastVolumeComponents)e.unapply();this._lastVolumeComponents.length=0}let t=this.context;t[Ie]===this&&(delete t[Ie],typeof t.renderer[Y]==`boolean`&&(t.renderer.autoClear=t.renderer[Y]),typeof t.renderer[X]==`number`&&(t.renderer.toneMapping=t.renderer[X])),this._composer?.removeAllPasses(),e&&this._composer?.dispose(),t.composer===this._composer&&(t.composer=null),this._adaptiveDPR_OverrideActive&&(this._adaptiveDPR_OverrideActive=!1,t.devicePixelRatio=`auto`),this.handleDevicePixelRatio()}dispose(){this.unapply(!0);for(let e of this._effects)e.effect.dispose();this._effects.length=0,this._composer=null}async onApply(e,t){if(!t)return;await Promise.all([g.POSTPROCESSING.load(),g.POSTPROCESSING_AO.load()]),e[Ie]=this,J&&console.log(`Apply Postprocessing Effects`,t),this._lastVolumeComponents=[...t],this._effects.length=0;let n={handler:this,components:this._lastVolumeComponents};for(let t=0;t1){let e=Math.max(1,Math.round((a-o)*10)/10);e=59&&r>1&&n-this._adaptiveDPR_LastDecreaseTime>10&&aa?(this._adaptiveDPR_LastChangeTime=n,this.context.devicePixelRatio=e,J&&console.debug(`[PostProcessing] Increased pixel ratio from ${a.toFixed(1)} to ${e}`)):this._adaptiveDPR_OverrideActive&&(this._adaptiveDPR_OverrideActive=!1,this._adaptiveDPR_LastChangeTime=n,this.context.devicePixelRatio=`auto`,J&&console.debug(`[PostProcessing] Restored pixel ratio to auto`))}}applyEffects(e){if(this._anyPassHasDepth=!1,this._anyPassHasNormal=!1,this._hasSmaaEffect=!1,this._effects.length<=0)return;let n=e.mainCameraComponent,o=e.renderer,s=e.scene,c=n.threeCamera;if(typeof o[Y]==`boolean`&&(o.autoClear=o[Y]),o[Y]=o.autoClear,typeof o[X]==`number`&&(o.toneMapping=o[X]),o[X]=o.toneMapping,o.toneMapping!=0&&!this._effects.find(e=>e instanceof g.POSTPROCESSING.MODULE.ToneMappingEffect)){let e=new g.POSTPROCESSING.MODULE.ToneMappingEffect;e.name=`ToneMapping (${o.toneMapping})`,e.mode=A(o.toneMapping),this._effects.push({typeName:`ToneMapping`,effect:e,priority:b.ToneMapping})}this._composer||=new g.POSTPROCESSING.MODULE.EffectComposer(o,{frameBufferType:a,stencilBuffer:!0}),e.composer&&e.composer!==this._composer&&console.warn(`There's already an active EffectComposer in your scene: replacing it with a new one. This might cause unexpected behaviour. Make sure to only use one PostprocessingManager/Volume in your scene.`),e.composer=this._composer;let l=e.composer;l.setMainCamera(c),l.setRenderer(o),l.setMainScene(s),l.autoRenderToScreen=!0,l.multisampling=0;for(let e of l.passes)e.dispose();l.removeAllPasses();let u=new g.POSTPROCESSING.MODULE.RenderPass(s,c);u.name=`RenderPass`,u.mainScene=s,l.addPass(u);let d=u.render;this._customInputBuffer?.dispose(),this._customInputBuffer=null,u.render=(e,n,i,o,s)=>{if(n){if(this._multisampling<=0){d.call(u,e,n,i,o,s);return}n.samples=0,i&&(i.samples=0),(!this._customInputBuffer||this._customInputBuffer.width!==n.width||this._customInputBuffer.height!==n.height||this._customInputBuffer.samples!==this._multisampling||this._customInputBuffer.texture.format!==n.texture.format||this._customInputBuffer.texture.type!==1016)&&(this._customInputBuffer?.dispose(),this._customInputBuffer=new t(n.width,n.height,{format:n.texture.format,type:a,depthBuffer:n.depthBuffer,depthTexture:n.depthTexture?new r(n.width,n.height):void 0,stencilBuffer:n.stencilBuffer,samples:Math.max(0,this._multisampling),minFilter:n.texture.minFilter??1006,magFilter:n.texture.magFilter??1006,generateMipmaps:n.texture.generateMipmaps}),this._customInputBufferId++,this._customInputBuffer.texture.name=`CustomInputBuffer-${this._customInputBufferId}`,this._customInputBuffer.depthTexture&&n.depthTexture&&(this._customInputBuffer.depthTexture.format=n.depthTexture.format,this._customInputBuffer.depthTexture.type=n.depthTexture.type),J&&console.warn(`[PostProcessing] Input buffer created with size ${this._customInputBuffer.width}x${this._customInputBuffer.height} and samples ${this._customInputBuffer.samples}`)),d.call(u,e,this._customInputBuffer,i,o,s),e.setRenderTarget(n),ee.blit(this._customInputBuffer.texture,n,{renderer:e,depthTexture:this._customInputBuffer.depthTexture,depthWrite:!0,depthTest:!0})}};try{de(this._effects);let e=!1,t=null;for(let n=this._effects.length-1;n>=0;n--){let r=this._effects[n].effect;if(r instanceof g.POSTPROCESSING.MODULE.ToneMappingEffect){if(e){J&&console.warn(`[PostProcessing] Found multiple tonemapping effects in the scene: ${r.name} and ${t?.name}. Only the last one added will be used.`),this._effects.splice(n,1);continue}t=r,e=!0}}let n=[],r=!1;for(let e=0;ee.name).join(`, `)+`]`),this.createPassForMergeableEffects(n,l,c,s)),r=!0),n.push(i)):i instanceof g.POSTPROCESSING.MODULE.Pass?(r=!1,this.createPassForMergeableEffects(n,l,c,s),i.renderToScreen=!1,l.addPass(i)):(r=!1,this.createPassForMergeableEffects(n,l,c,s),l.addPass(i)))}this.createPassForMergeableEffects(n,l,c,s)}catch(e){console.error(`Error while applying postprocessing effects`,e),l.passes.forEach(e=>e.dispose()),l.removeAllPasses()}let f=!1;for(let e=l.passes.length-1;e>=0;e--){let t=l.passes[e],n=!1,r=!1;t.enabled&&(f||(n=!0,r=!0),f=!0),t.renderToScreen=r,t?.configuration===void 0?`autosetGamma`in t&&(t.autosetGamma=n):t.configuration.gammaCorrection=n,this._anyPassHasDepth||=t.needsDepthTexture}let p=l.depthTexture;p&&(p.source=new i({width:0,height:0}),p.needsUpdate=!0),this.handleDevicePixelRatio(),J&&console.log(`[PostProcessing] Passes →`,[...l.passes],` --------------------------------- • `+l.passes.map(e=>e.name||e.constructor.name+`*`).join(` • `)+` `),J&&this._onCreateEffectsDebug(this._composer,c)}createPassForMergeableEffects(e,t,n,r){if(e.length>0){let i=new g.POSTPROCESSING.MODULE.EffectPass(n,...e);i.name=e.map(e=>e.name).join(`, `),i.mainScene=r,i.enabled=!0,i.renderToScreen=!1,t.addPass(i),e.length=0}}handleDevicePixelRatio(){typeof this.context.devicePixelRatio==`number`&&this.context.requestSizeUpdate()}_menuEntry=null;_passIndices=null;_onCreateEffectsDebug(e,t){if(J===`passes`){let n=new g.POSTPROCESSING.MODULE.DepthEffect({blendFunction:g.POSTPROCESSING.MODULE.BlendFunction.NORMAL,inverted:!0});n.name=`Depth Effect`;let r=new g.POSTPROCESSING.MODULE.EffectPass(t,n);if(r.name=`Depth Effect Pass`,r.enabled=!1,e.passes.push(r),this._passIndices!==null){let t=[e.passes[0]];this._passIndices.length>0&&t.push(...this._passIndices.filter(e=>e!==0).map(t=>e.passes[t]).filter(e=>e)),t.length>0&&console.log(`[PostProcessing] Passes (selected) →`,t),e.passes.length=0;for(let n of t)n.enabled=!0,n.renderToScreen=!1,e.addPass(n)}let i=this.context.menu;if(i&&this._passIndices===null){this._menuEntry&&this._menuEntry.remove();let t=document.createElement(`select`);t.multiple=!0;let n=document.createElement(`option`);n.innerText=`Final Output`,n.value=`-1`,t.appendChild(n);for(let n of e.passes){let r=document.createElement(`option`);r.innerText=n.name,r.value=`${e.passes.indexOf(n)}`,r.title=n.name,t.appendChild(r)}i.appendChild(t),this._menuEntry=t,t.addEventListener(`change`,()=>{let e=Array.from(t.selectedOptions).map(e=>parseInt(e.value));e.length===1&&e[0]===-1?this._passIndices=null:this._passIndices=e,this.applyEffects(this.context)})}}}},Re=function(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},Z=h(`debugpost`),Q=class extends ie{get isPostProcessingManager(){return!0}get effects(){return this._activeEffects}get dirty(){return this._isDirty}set dirty(e){this._isDirty=e}sharedProfile;multisampling=`auto`;adaptiveResolution=!0;addEffect(e){let t=e;return t instanceof w||(t=new je(t),typeof e.order==`number`&&(t.order=e.order)),t.gameObject===void 0&&this.gameObject.addComponent(t),this._effects.includes(t)?e:(this._effects.push(t),this._isDirty=!0,e)}removeEffect(e){let t=-1;if(t=e instanceof w?this._effects.indexOf(e):this._effects.findIndex(t=>t instanceof je&&t.effect===e),t!==-1)return this._effects.splice(t,1),this._isDirty=!0,e;if(e instanceof w){let t=this.sharedProfile?.components?.indexOf(e);t!==void 0&&t!==-1&&(this._isDirty=!0,this.sharedProfile?.components?.splice(t,1))}return e}_postprocessing;_activeEffects=[];_effects=[];markDirty(){this._isDirty=!0}awake(){Z&&(console.log(`PostprocessingManager Awake`,this),console.log(`Press P to toggle post processing`),window.addEventListener(`keydown`,e=>{e.key===`p`&&(this.enabled=!this.enabled,re(`Toggle PostProcessing `+this.name+`: Enabled=`+this.enabled),this.markDirty())})),this.sharedProfile?.__init(this)}_componentEnabledTime=-1;_multisampleAutoChangeTime=0;_multisampleAutoDecreaseTime=0;onEnable(){this._componentEnabledTime=this.context.time.realtimeSinceStartup,this._isDirty=!0}onDisable(){this._postprocessing?.unapply(),this._isDirty=!1}onBeforeRender(){if(!this.context.isInXR&&(this.context.mainCamera&&this._isDirty&&this.apply(),this.context.composer&&this._postprocessing&&this._postprocessing.composer===this.context.composer)){if(this.context.renderer.getContext().isContextLost()&&this.context.renderer.forceContextRestore(),this.context.composer.getRenderer()!==this.context.renderer&&this.context.composer.setRenderer(this.context.renderer),this.context.composer.setMainScene(this.context.scene),this.multisampling===`auto`)if(this._postprocessing&&this._postprocessing.hasSmaaEffect)this._postprocessing.multisampling!==0&&(this._postprocessing.multisampling=0,(Z||l())&&console.log(`[PostProcessing] multisampling is disabled because it's set to 'auto' on your PostprocessingManager/Volume component that also has an SMAA effect. If you need multisampling consider changing 'auto' to a fixed value (e.g. 4).`));else{let e=this.context.time.realtimeSinceStartup-this._multisampleAutoChangeTime;if(this.context.time.realtimeSinceStartup-this._componentEnabledTime>2&&e>.5){let t=this._postprocessing.multisampling;if(this._postprocessing.multisampling>0&&this.context.time.smoothedFps<=50){this._multisampleAutoChangeTime=this.context.time.realtimeSinceStartup,this._multisampleAutoDecreaseTime=this.context.time.realtimeSinceStartup;let e=this._postprocessing.multisampling*.5;e=Math.floor(e),e!=this._postprocessing.multisampling&&(this._postprocessing.multisampling=e),Z&&console.debug(`[PostProcessing] Reduced multisampling from ${t} to ${this._postprocessing.multisampling}`)}else if(e>1&&this.context.time.smoothedFps>=59&&this._postprocessing.multisampling10){this._multisampleAutoChangeTime=this.context.time.realtimeSinceStartup;let e=this._postprocessing.multisampling<=0?1:this._postprocessing.multisampling*2;e=Math.floor(e),e!==this._postprocessing.multisampling&&(this._postprocessing.multisampling=e),Z&&console.debug(`[PostProcessing] Increased multisampling from ${t} to ${this._postprocessing.multisampling}`)}}}else{let e=Math.max(0,Math.min(this.multisampling,this.context.renderer.capabilities.maxSamples));e!==this._postprocessing.multisampling&&(this._postprocessing.multisampling=e)}if(this._postprocessing.adaptivePixelRatio=this.adaptiveResolution,this._postprocessing.updateAdaptivePixelRatio(),this.context.mainCamera){let e=this.context.composer.passes;for(let t of e)if(t.mainCamera&&t.mainCamera!==this.context.mainCamera){this.context.composer.setMainCamera(this.context.mainCamera);break}}}}onDestroy(){this._postprocessing?.dispose()}_lastApplyTime;_rapidApplyCount=0;_isDirty=!1;apply(){if(Z&&console.log(`Apply PostProcessing "${this.name||`unnamed`}"`),l()&&(this._lastApplyTime!==void 0&&Date.now()-this._lastApplyTime<100&&(this._rapidApplyCount++,this._rapidApplyCount===5&&console.warn(`Detected rapid post processing modifications - this might be a bug`,this)),this._lastApplyTime=Date.now()),this._isDirty=!1,this._activeEffects.length=0,this.sharedProfile?.components){let e=this.sharedProfile.components;for(let t of e)t.active&&t.enabled&&!this._activeEffects.includes(t)&&this._activeEffects.push(t)}for(let e of this._effects)e.active&&e.enabled&&!this._activeEffects.includes(e)&&this._activeEffects.push(e);this._activeEffects.length>0?(this._postprocessing||=new Le(this.context),this._postprocessing.apply(this._activeEffects)?.then(()=>{this.activeAndEnabled&&(this._applyPostQueue(),this._postprocessing?(this.multisampling===`auto`?this._postprocessing.multisampling=te.isMobileDevice()?2:4:this._postprocessing.multisampling=Math.max(0,Math.min(this.multisampling,this.context.renderer.capabilities.maxSamples)),Z&&console.debug(`[PostProcessing] Set multisampling to ${this._postprocessing.multisampling} (Is Mobile: ${te.isMobileDevice()})`)):Z&&console.warn(`[PostProcessing] No composer found`))})):this._postprocessing?.unapply(!1)}_applyPostQueue(){if(this._modificationQueue){for(let e of this._modificationQueue.values())this.onEditorModification(e);this._modificationQueue.clear()}}onEditorModification(e){if(e.propertyName.startsWith(`postprocessing.`)){if(!this._postprocessing)return this._modificationQueue||=new Map,this._modificationQueue.set(e.propertyName,e),!0;if(!this._activeEffects?.length)return;let t=e.propertyName.split(`.`);if(t.length===3||t.length===4){let n=t[1],r=t[2];for(let i of this._activeEffects)if(i.typeName?.toLowerCase()===n.toLowerCase()){if(r===`active`){i.active=e.value,this.scheduleRecreate();return}if(!$.has(n)){let e=[];$.set(n,e);let t=Object.keys(i);for(let n of t)i[n]instanceof S&&e.push(n)}if($.has(n)){let a=r.toLowerCase(),o=$.get(n);for(let n of o)if(n.toLowerCase()===a){let r=i[n];r instanceof S&&(t.length===4&&t[3]===`active`?(r.overrideState=e.value,this.scheduleRecreate()):r&&r.value!==void 0&&(r.value=e.value));return}}console.warn(`Unknown modification`,r);return}}return!0}return!1}_modificationQueue;_recreateId=-1;scheduleRecreate(){let e=++this._recreateId;setTimeout(()=>{e===this._recreateId&&(this.onDisable(),this.onEnable())},200)}};Re([m(ye)],Q.prototype,`sharedProfile`,void 0),Re([m()],Q.prototype,`multisampling`,void 0),Re([m()],Q.prototype,`adaptiveResolution`,void 0);var $=new Map;ce(Q);export{T as _,U as a,b,L as c,P as d,M as f,ye as g,Ce as h,G as i,je as l,E as m,Le as n,H as o,D as p,q as r,z as s,Q as t,I as u,w as v,S as y};