import{A as n}from"./abstractSoundSource-D3oGzC3p.js";import{_ as r,a as u,b as _,c as d}from"./spatialWebAudio-CBDS0rWd.js";import"./webAudioBaseSubGraph-CNNuTFUE.js";import"./audioEngine-C797_5QL.js";import"./index-DWyDLubb.js";import"./index-CDrXokXW.js";class s extends n{constructor(e,t,i,o){super(e,i,o),this._stereo=null,this._audioContext=this.engine._audioContext,this._webAudioNode=t,this._subGraph=new s._SubGraph(this)}async _initAsync(e){e.outBus?this.outBus=e.outBus:e.outBusAutoDefault!==!1&&(await this.engine.isReadyPromise,this.outBus=this.engine.defaultMainBus),await this._subGraph.initAsync(e),r(e)&&this._initSpatialProperty(),this.engine._addNode(this)}get _inNode(){return this._webAudioNode}get _outNode(){return this._subGraph._outNode}get stereo(){return this._stereo??(this._stereo=new u(this._subGraph))}dispose(){super.dispose(),this._stereo=null,this._subGraph.dispose(),this.engine._removeNode(this)}getClassName(){return"_WebAudioSoundSource"}_connect(e){return super._connect(e)?(e._inNode&&this._outNode?.connect(e._inNode),!0):!1}_disconnect(e){return super._disconnect(e)?(e._inNode&&this._outNode?.disconnect(e._inNode),!0):!1}_createSpatialProperty(e,t){return new _(this._subGraph,e,t)}}s._SubGraph=class extends d{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};
