import{A as a}from"./abstractSoundSource-Ao26OVlO.js";import{_ as r,a as n,b as u,c as p}from"./spatialWebAudio-DZSznhH0.js";import"./webAudioBaseSubGraph-ymNBfs1g.js";import"./audioEngine-CbOwYhF1.js";import"./index-6jOCfdig.js";import"./index-Ds2meNS5.js";import"./svelte/svelte_svelte.js";import"./svelte/svelte_animate.js";import"./svelte/svelte_attachments.js";import"./svelte/svelte_easing.js";import"./svelte/svelte_internal_client.js";import"./svelte/svelte_internal_flags_async.js";import"./svelte/svelte_internal_flags_legacy.js";import"./svelte/svelte_internal_flags_tracing.js";import"./svelte/svelte_internal_server.js";import"./svelte/svelte_legacy.js";import"./svelte/svelte_motion.js";import"./svelte/svelte_reactivity.js";import"./svelte/svelte_reactivity_window.js";import"./svelte/svelte_server.js";import"./svelte/svelte_store.js";import"./svelte/svelte_transition.js";import"./svelte/svelte_events.js";class s extends a{constructor(t,e,o,i){super(t,o),this._spatial=null,this._spatialAutoUpdate=!0,this._spatialMinUpdateTime=0,this._stereo=null,typeof i.spatialAutoUpdate=="boolean"&&(this._spatialAutoUpdate=i.spatialAutoUpdate),typeof i.spatialMinUpdateTime=="number"&&(this._spatialMinUpdateTime=i.spatialMinUpdateTime),this._audioContext=this.engine._audioContext,this._webAudioNode=e,this._subGraph=new s._SubGraph(this)}async _initAsync(t){t.outBus?this.outBus=t.outBus:t.outBusAutoDefault!==!1&&(await this.engine.isReadyPromise,this.outBus=this.engine.defaultMainBus),await this._subGraph.initAsync(t),r(t)&&this._initSpatialProperty(),this.engine._addNode(this)}get _inNode(){return this._webAudioNode}get _outNode(){return this._subGraph._outNode}get spatial(){return this._spatial?this._spatial:this._initSpatialProperty()}get stereo(){return this._stereo??(this._stereo=new n(this._subGraph))}dispose(){super.dispose(),this._spatial?.dispose(),this._spatial=null,this._stereo=null,this._subGraph.dispose(),this.engine._removeNode(this)}getClassName(){return"_WebAudioSoundSource"}_connect(t){return super._connect(t)?(t._inNode&&this._outNode?.connect(t._inNode),!0):!1}_disconnect(t){return super._disconnect(t)?(t._inNode&&this._outNode?.disconnect(t._inNode),!0):!1}_initSpatialProperty(){return this._spatial||(this._spatial=new u(this._subGraph,this._spatialAutoUpdate,this._spatialMinUpdateTime)),this._spatial}}s._SubGraph=class extends p{get _downstreamNodes(){return this._owner._downstreamNodes??null}get _upstreamNodes(){return this._owner._upstreamNodes??null}_onSubNodesChanged(){super._onSubNodesChanged(),this._owner._inNode.disconnect(),this._owner._subGraph._inNode&&this._owner._inNode.connect(this._owner._subGraph._inNode)}};export{s as _WebAudioSoundSource};
