lyb-pixi-js 1.2.3 → 1.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Utils/LibPixiAudio.js +5 -4
- package/lyb-pixi.js +1 -1
- package/package.json +1 -1
package/Utils/LibPixiAudio.js
CHANGED
|
@@ -98,8 +98,7 @@ export class LibPixiAudio {
|
|
|
98
98
|
src: url,
|
|
99
99
|
loop: true,
|
|
100
100
|
volume: 0,
|
|
101
|
-
|
|
102
|
-
mute: this._isBackground || !this.effectEnabled,
|
|
101
|
+
mute: this._isBackground || !this.musicEnabled,
|
|
103
102
|
});
|
|
104
103
|
this._musicPlayer.play();
|
|
105
104
|
this._isMusicPaused = false;
|
|
@@ -119,9 +118,11 @@ export class LibPixiAudio {
|
|
|
119
118
|
}
|
|
120
119
|
/** @description 继续播放音乐 */
|
|
121
120
|
resumeMusic() {
|
|
122
|
-
var _a;
|
|
121
|
+
var _a, _b;
|
|
123
122
|
this._isMusicPaused = false;
|
|
124
|
-
(_a = this._musicPlayer) === null || _a === void 0 ? void 0 : _a.
|
|
123
|
+
if ((_a = this._musicPlayer) === null || _a === void 0 ? void 0 : _a.playing())
|
|
124
|
+
return;
|
|
125
|
+
(_b = this._musicPlayer) === null || _b === void 0 ? void 0 : _b.play();
|
|
125
126
|
}
|
|
126
127
|
/** @description 停止播放指定音效
|
|
127
128
|
* @param key 音效资源Key,内部会使用Assets.get(key)获取音频资源进行停止
|
package/lyb-pixi.js
CHANGED
|
@@ -1186,7 +1186,7 @@ Most likely your texture failed to load.`),x(b)}),w=await v;return t.parseData(u
|
|
|
1186
1186
|
* goldfirestudios.com
|
|
1187
1187
|
*
|
|
1188
1188
|
* MIT License
|
|
1189
|
-
*/(function(){HowlerGlobal.prototype._pos=[0,0,0],HowlerGlobal.prototype._orientation=[0,0,-1,0,1,0],HowlerGlobal.prototype.stereo=function(e){var s=this;if(!s.ctx||!s.ctx.listener)return s;for(var r=s._howls.length-1;r>=0;r--)s._howls[r].stereo(e);return s},HowlerGlobal.prototype.pos=function(e,s,r){var n=this;if(!n.ctx||!n.ctx.listener)return n;if(s=typeof s!="number"?n._pos[1]:s,r=typeof r!="number"?n._pos[2]:r,typeof e=="number")n._pos=[e,s,r],typeof n.ctx.listener.positionX<"u"?(n.ctx.listener.positionX.setTargetAtTime(n._pos[0],Howler.ctx.currentTime,.1),n.ctx.listener.positionY.setTargetAtTime(n._pos[1],Howler.ctx.currentTime,.1),n.ctx.listener.positionZ.setTargetAtTime(n._pos[2],Howler.ctx.currentTime,.1)):n.ctx.listener.setPosition(n._pos[0],n._pos[1],n._pos[2]);else return n._pos;return n},HowlerGlobal.prototype.orientation=function(e,s,r,n,a,h){var o=this;if(!o.ctx||!o.ctx.listener)return o;var l=o._orientation;if(s=typeof s!="number"?l[1]:s,r=typeof r!="number"?l[2]:r,n=typeof n!="number"?l[3]:n,a=typeof a!="number"?l[4]:a,h=typeof h!="number"?l[5]:h,typeof e=="number")o._orientation=[e,s,r,n,a,h],typeof o.ctx.listener.forwardX<"u"?(o.ctx.listener.forwardX.setTargetAtTime(e,Howler.ctx.currentTime,.1),o.ctx.listener.forwardY.setTargetAtTime(s,Howler.ctx.currentTime,.1),o.ctx.listener.forwardZ.setTargetAtTime(r,Howler.ctx.currentTime,.1),o.ctx.listener.upX.setTargetAtTime(n,Howler.ctx.currentTime,.1),o.ctx.listener.upY.setTargetAtTime(a,Howler.ctx.currentTime,.1),o.ctx.listener.upZ.setTargetAtTime(h,Howler.ctx.currentTime,.1)):o.ctx.listener.setOrientation(e,s,r,n,a,h);else return l;return o},Howl.prototype.init=function(e){return function(s){var r=this;return r._orientation=s.orientation||[1,0,0],r._stereo=s.stereo||null,r._pos=s.pos||null,r._pannerAttr={coneInnerAngle:typeof s.coneInnerAngle<"u"?s.coneInnerAngle:360,coneOuterAngle:typeof s.coneOuterAngle<"u"?s.coneOuterAngle:360,coneOuterGain:typeof s.coneOuterGain<"u"?s.coneOuterGain:0,distanceModel:typeof s.distanceModel<"u"?s.distanceModel:"inverse",maxDistance:typeof s.maxDistance<"u"?s.maxDistance:1e4,panningModel:typeof s.panningModel<"u"?s.panningModel:"HRTF",refDistance:typeof s.refDistance<"u"?s.refDistance:1,rolloffFactor:typeof s.rolloffFactor<"u"?s.rolloffFactor:1},r._onstereo=s.onstereo?[{fn:s.onstereo}]:[],r._onpos=s.onpos?[{fn:s.onpos}]:[],r._onorientation=s.onorientation?[{fn:s.onorientation}]:[],e.call(this,s)}}(Howl.prototype.init),Howl.prototype.stereo=function(e,s){var r=this;if(!r._webAudio)return r;if(r._state!=="loaded")return r._queue.push({event:"stereo",action:function(){r.stereo(e,s)}}),r;var n=typeof Howler.ctx.createStereoPanner>"u"?"spatial":"stereo";if(typeof s>"u")if(typeof e=="number")r._stereo=e,r._pos=[e,0,0];else return r._stereo;for(var a=r._getSoundIds(s),h=0;h<a.length;h++){var o=r._soundById(a[h]);if(o)if(typeof e=="number")o._stereo=e,o._pos=[e,0,0],o._node&&(o._pannerAttr.panningModel="equalpower",(!o._panner||!o._panner.pan)&&t(o,n),n==="spatial"?typeof o._panner.positionX<"u"?(o._panner.positionX.setValueAtTime(e,Howler.ctx.currentTime),o._panner.positionY.setValueAtTime(0,Howler.ctx.currentTime),o._panner.positionZ.setValueAtTime(0,Howler.ctx.currentTime)):o._panner.setPosition(e,0,0):o._panner.pan.setValueAtTime(e,Howler.ctx.currentTime)),r._emit("stereo",o._id);else return o._stereo}return r},Howl.prototype.pos=function(e,s,r,n){var a=this;if(!a._webAudio)return a;if(a._state!=="loaded")return a._queue.push({event:"pos",action:function(){a.pos(e,s,r,n)}}),a;if(s=typeof s!="number"?0:s,r=typeof r!="number"?-.5:r,typeof n>"u")if(typeof e=="number")a._pos=[e,s,r];else return a._pos;for(var h=a._getSoundIds(n),o=0;o<h.length;o++){var l=a._soundById(h[o]);if(l)if(typeof e=="number")l._pos=[e,s,r],l._node&&((!l._panner||l._panner.pan)&&t(l,"spatial"),typeof l._panner.positionX<"u"?(l._panner.positionX.setValueAtTime(e,Howler.ctx.currentTime),l._panner.positionY.setValueAtTime(s,Howler.ctx.currentTime),l._panner.positionZ.setValueAtTime(r,Howler.ctx.currentTime)):l._panner.setPosition(e,s,r)),a._emit("pos",l._id);else return l._pos}return a},Howl.prototype.orientation=function(e,s,r,n){var a=this;if(!a._webAudio)return a;if(a._state!=="loaded")return a._queue.push({event:"orientation",action:function(){a.orientation(e,s,r,n)}}),a;if(s=typeof s!="number"?a._orientation[1]:s,r=typeof r!="number"?a._orientation[2]:r,typeof n>"u")if(typeof e=="number")a._orientation=[e,s,r];else return a._orientation;for(var h=a._getSoundIds(n),o=0;o<h.length;o++){var l=a._soundById(h[o]);if(l)if(typeof e=="number")l._orientation=[e,s,r],l._node&&(l._panner||(l._pos||(l._pos=a._pos||[0,0,-.5]),t(l,"spatial")),typeof l._panner.orientationX<"u"?(l._panner.orientationX.setValueAtTime(e,Howler.ctx.currentTime),l._panner.orientationY.setValueAtTime(s,Howler.ctx.currentTime),l._panner.orientationZ.setValueAtTime(r,Howler.ctx.currentTime)):l._panner.setOrientation(e,s,r)),a._emit("orientation",l._id);else return l._orientation}return a},Howl.prototype.pannerAttr=function(){var e=this,s=arguments,r,n,a;if(!e._webAudio)return e;if(s.length===0)return e._pannerAttr;if(s.length===1)if(typeof s[0]=="object")r=s[0],typeof n>"u"&&(r.pannerAttr||(r.pannerAttr={coneInnerAngle:r.coneInnerAngle,coneOuterAngle:r.coneOuterAngle,coneOuterGain:r.coneOuterGain,distanceModel:r.distanceModel,maxDistance:r.maxDistance,refDistance:r.refDistance,rolloffFactor:r.rolloffFactor,panningModel:r.panningModel}),e._pannerAttr={coneInnerAngle:typeof r.pannerAttr.coneInnerAngle<"u"?r.pannerAttr.coneInnerAngle:e._coneInnerAngle,coneOuterAngle:typeof r.pannerAttr.coneOuterAngle<"u"?r.pannerAttr.coneOuterAngle:e._coneOuterAngle,coneOuterGain:typeof r.pannerAttr.coneOuterGain<"u"?r.pannerAttr.coneOuterGain:e._coneOuterGain,distanceModel:typeof r.pannerAttr.distanceModel<"u"?r.pannerAttr.distanceModel:e._distanceModel,maxDistance:typeof r.pannerAttr.maxDistance<"u"?r.pannerAttr.maxDistance:e._maxDistance,refDistance:typeof r.pannerAttr.refDistance<"u"?r.pannerAttr.refDistance:e._refDistance,rolloffFactor:typeof r.pannerAttr.rolloffFactor<"u"?r.pannerAttr.rolloffFactor:e._rolloffFactor,panningModel:typeof r.pannerAttr.panningModel<"u"?r.pannerAttr.panningModel:e._panningModel});else return a=e._soundById(parseInt(s[0],10)),a?a._pannerAttr:e._pannerAttr;else s.length===2&&(r=s[0],n=parseInt(s[1],10));for(var h=e._getSoundIds(n),o=0;o<h.length;o++)if(a=e._soundById(h[o]),a){var l=a._pannerAttr;l={coneInnerAngle:typeof r.coneInnerAngle<"u"?r.coneInnerAngle:l.coneInnerAngle,coneOuterAngle:typeof r.coneOuterAngle<"u"?r.coneOuterAngle:l.coneOuterAngle,coneOuterGain:typeof r.coneOuterGain<"u"?r.coneOuterGain:l.coneOuterGain,distanceModel:typeof r.distanceModel<"u"?r.distanceModel:l.distanceModel,maxDistance:typeof r.maxDistance<"u"?r.maxDistance:l.maxDistance,refDistance:typeof r.refDistance<"u"?r.refDistance:l.refDistance,rolloffFactor:typeof r.rolloffFactor<"u"?r.rolloffFactor:l.rolloffFactor,panningModel:typeof r.panningModel<"u"?r.panningModel:l.panningModel};var u=a._panner;u||(a._pos||(a._pos=e._pos||[0,0,-.5]),t(a,"spatial"),u=a._panner),u.coneInnerAngle=l.coneInnerAngle,u.coneOuterAngle=l.coneOuterAngle,u.coneOuterGain=l.coneOuterGain,u.distanceModel=l.distanceModel,u.maxDistance=l.maxDistance,u.refDistance=l.refDistance,u.rolloffFactor=l.rolloffFactor,u.panningModel=l.panningModel}return e},Sound.prototype.init=function(e){return function(){var s=this,r=s._parent;s._orientation=r._orientation,s._stereo=r._stereo,s._pos=r._pos,s._pannerAttr=r._pannerAttr,e.call(this),s._stereo?r.stereo(s._stereo):s._pos&&r.pos(s._pos[0],s._pos[1],s._pos[2],s._id)}}(Sound.prototype.init),Sound.prototype.reset=function(e){return function(){var s=this,r=s._parent;return s._orientation=r._orientation,s._stereo=r._stereo,s._pos=r._pos,s._pannerAttr=r._pannerAttr,s._stereo?r.stereo(s._stereo):s._pos?r.pos(s._pos[0],s._pos[1],s._pos[2],s._id):s._panner&&(s._panner.disconnect(0),s._panner=void 0,r._refreshBuffer(s)),e.call(this)}}(Sound.prototype.reset);var t=function(e,s){s=s||"spatial",s==="spatial"?(e._panner=Howler.ctx.createPanner(),e._panner.coneInnerAngle=e._pannerAttr.coneInnerAngle,e._panner.coneOuterAngle=e._pannerAttr.coneOuterAngle,e._panner.coneOuterGain=e._pannerAttr.coneOuterGain,e._panner.distanceModel=e._pannerAttr.distanceModel,e._panner.maxDistance=e._pannerAttr.maxDistance,e._panner.refDistance=e._pannerAttr.refDistance,e._panner.rolloffFactor=e._pannerAttr.rolloffFactor,e._panner.panningModel=e._pannerAttr.panningModel,typeof e._panner.positionX<"u"?(e._panner.positionX.setValueAtTime(e._pos[0],Howler.ctx.currentTime),e._panner.positionY.setValueAtTime(e._pos[1],Howler.ctx.currentTime),e._panner.positionZ.setValueAtTime(e._pos[2],Howler.ctx.currentTime)):e._panner.setPosition(e._pos[0],e._pos[1],e._pos[2]),typeof e._panner.orientationX<"u"?(e._panner.orientationX.setValueAtTime(e._orientation[0],Howler.ctx.currentTime),e._panner.orientationY.setValueAtTime(e._orientation[1],Howler.ctx.currentTime),e._panner.orientationZ.setValueAtTime(e._orientation[2],Howler.ctx.currentTime)):e._panner.setOrientation(e._orientation[0],e._orientation[1],e._orientation[2])):(e._panner=Howler.ctx.createStereoPanner(),e._panner.pan.setValueAtTime(e._stereo,Howler.ctx.currentTime)),e._panner.connect(e._node),e._paused||e._parent.pause(e._id,!0).play(e._id,!0)}})()})(cd);let $0;function fI(i){return $0=i,i}function ko(){return $0}let pI=0;const ud=class extends Gs{constructor(i){super(),this.id=pI++,this.init(i)}set(i,t){if(this[i]===void 0)throw new Error(`Property with name ${i} does not exist.`);switch(i){case"speed":this.speed=t;break;case"volume":this.volume=t;break;case"paused":this.paused=t;break;case"loop":this.loop=t;break;case"muted":this.muted=t;break}return this}get progress(){const{currentTime:i}=this._source;return i/this._duration}get paused(){return this._paused}set paused(i){this._paused=i,this.refreshPaused()}_onPlay(){this._playing=!0}_onPause(){this._playing=!1}init(i){this._playing=!1,this._duration=i.source.duration;const t=this._source=i.source.cloneNode(!1);t.src=i.parent.url,t.onplay=this._onPlay.bind(this),t.onpause=this._onPause.bind(this),i.context.on("refresh",this.refresh,this),i.context.on("refreshPaused",this.refreshPaused,this),this._media=i}_internalStop(){this._source&&this._playing&&(this._source.onended=null,this._source.pause())}stop(){this._internalStop(),this._source&&this.emit("stop")}get speed(){return this._speed}set speed(i){this._speed=i,this.refresh()}get volume(){return this._volume}set volume(i){this._volume=i,this.refresh()}get loop(){return this._loop}set loop(i){this._loop=i,this.refresh()}get muted(){return this._muted}set muted(i){this._muted=i,this.refresh()}get filters(){return console.warn("HTML Audio does not support filters"),null}set filters(i){console.warn("HTML Audio does not support filters")}refresh(){const i=this._media.context,t=this._media.parent;this._source.loop=this._loop||t.loop;const e=i.volume*(i.muted?0:1),s=t.volume*(t.muted?0:1),r=this._volume*(this._muted?0:1);this._source.volume=r*e*s,this._source.playbackRate=this._speed*i.speed*t.speed}refreshPaused(){const i=this._media.context,t=this._media.parent,e=this._paused||t.paused||i.paused;e!==this._pausedReal&&(this._pausedReal=e,e?(this._internalStop(),this.emit("paused")):(this.emit("resumed"),this.play({start:this._source.currentTime,end:this._end,volume:this._volume,speed:this._speed,loop:this._loop})),this.emit("pause",e))}play(i){const{start:t,end:e,speed:s,loop:r,volume:n,muted:a}=i;e&&console.assert(e>t,"End time is before start time"),this._speed=s,this._volume=n,this._loop=!!r,this._muted=a,this.refresh(),this.loop&&e!==null&&(console.warn('Looping not support when specifying an "end" time'),this.loop=!1),this._start=t,this._end=e||this._duration,this._start=Math.max(0,this._start-ud.PADDING),this._end=Math.min(this._end+ud.PADDING,this._duration),this._source.onloadedmetadata=()=>{this._source&&(this._source.currentTime=t,this._source.onloadedmetadata=null,this.emit("progress",t,this._duration),Tt.shared.add(this._onUpdate,this))},this._source.onended=this._onComplete.bind(this),this._source.play(),this.emit("start")}_onUpdate(){this.emit("progress",this.progress,this._duration),this._source.currentTime>=this._end&&!this._source.loop&&this._onComplete()}_onComplete(){Tt.shared.remove(this._onUpdate,this),this._internalStop(),this.emit("progress",1,this._duration),this.emit("end",this)}destroy(){Tt.shared.remove(this._onUpdate,this),this.removeAllListeners();const i=this._source;i&&(i.onended=null,i.onplay=null,i.onpause=null,this._internalStop()),this._source=null,this._speed=1,this._volume=1,this._loop=!1,this._end=null,this._start=0,this._duration=0,this._playing=!1,this._pausedReal=!1,this._paused=!1,this._muted=!1,this._media&&(this._media.context.off("refresh",this.refresh,this),this._media.context.off("refreshPaused",this.refreshPaused,this),this._media=null)}toString(){return`[HTMLAudioInstance id=${this.id}]`}};let Y0=ud;Y0.PADDING=.1;class mI extends Gs{init(t){this.parent=t,this._source=t.options.source||new Audio,t.url&&(this._source.src=t.url)}create(){return new Y0(this)}get isPlayable(){return!!this._source&&this._source.readyState===4}get duration(){return this._source.duration}get context(){return this.parent.context}get filters(){return null}set filters(t){console.warn("HTML Audio does not support filters")}destroy(){this.removeAllListeners(),this.parent=null,this._source&&(this._source.src="",this._source.load(),this._source=null)}get source(){return this._source}load(t){const e=this._source,s=this.parent;if(e.readyState===4){s.isLoaded=!0;const o=s.autoPlayStart();t&&setTimeout(()=>{t(null,s,o)},0);return}if(!s.url){t(new Error("sound.url or sound.source must be set"));return}e.src=s.url;const r=()=>{h(),s.isLoaded=!0;const o=s.autoPlayStart();t&&t(null,s,o)},n=()=>{h(),t&&t(new Error("Sound loading has been aborted"))},a=()=>{h();const o=`Failed to load audio element (code: ${e.error.code})`;t?t(new Error(o)):console.error(o)},h=()=>{e.removeEventListener("canplaythrough",r),e.removeEventListener("load",r),e.removeEventListener("abort",n),e.removeEventListener("error",a)};e.addEventListener("canplaythrough",r,!1),e.addEventListener("load",r,!1),e.addEventListener("abort",n,!1),e.addEventListener("error",a,!1),e.load()}}class gI{constructor(t,e){this.parent=t,Object.assign(this,e),this.duration=this.end-this.start,console.assert(this.duration>0,"End time must be after start time")}play(t){return this.parent.play({complete:t,speed:this.speed||this.parent.speed,end:this.end,start:this.start,loop:this.loop})}destroy(){this.parent=null}}const xl=["ogg","oga","opus","m4a","mp3","mpeg","wav","aiff","wma","mid","caf"],_I=["audio/mpeg","audio/ogg"],vl={};function yI(i){const t={m4a:"audio/mp4",oga:"audio/ogg",opus:'audio/ogg; codecs="opus"',caf:'audio/x-caf; codecs="opus"',...i||{}},e=document.createElement("audio"),s={},r=/^no$/;xl.forEach(n=>{const a=e.canPlayType(`audio/${n}`).replace(r,""),h=t[n]?e.canPlayType(t[n]).replace(r,""):"";s[n]=!!a||!!h}),Object.assign(vl,s)}yI();class dd{static setParamValue(t,e){if(t.setValueAtTime){const s=ko().context;t.setValueAtTime(e,s.audioContext.currentTime)}else t.value=e;return e}}let xI=0;class vI extends Gs{constructor(t){super(),this.id=xI++,this._media=null,this._paused=!1,this._muted=!1,this._elapsed=0,this.init(t)}set(t,e){if(this[t]===void 0)throw new Error(`Property with name ${t} does not exist.`);switch(t){case"speed":this.speed=e;break;case"volume":this.volume=e;break;case"muted":this.muted=e;break;case"loop":this.loop=e;break;case"paused":this.paused=e;break}return this}stop(){this._source&&(this._internalStop(),this.emit("stop"))}get speed(){return this._speed}set speed(t){this._speed=t,this.refresh(),this._update(!0)}get volume(){return this._volume}set volume(t){this._volume=t,this.refresh()}get muted(){return this._muted}set muted(t){this._muted=t,this.refresh()}get loop(){return this._loop}set loop(t){this._loop=t,this.refresh()}get filters(){return this._filters}set filters(t){var e;this._filters&&((e=this._filters)==null||e.filter(s=>s).forEach(s=>s.disconnect()),this._filters=null,this._source.connect(this._gain)),this._filters=t!=null&&t.length?t.slice(0):null,this.refresh()}refresh(){if(!this._source)return;const t=this._media.context,e=this._media.parent;this._source.loop=this._loop||e.loop;const s=t.volume*(t.muted?0:1),r=e.volume*(e.muted?0:1),n=this._volume*(this._muted?0:1);dd.setParamValue(this._gain.gain,n*r*s),dd.setParamValue(this._source.playbackRate,this._speed*e.speed*t.speed),this.applyFilters()}applyFilters(){var t;if((t=this._filters)!=null&&t.length){this._source.disconnect();let e=this._source;this._filters.forEach(s=>{e.connect(s.destination),e=s}),e.connect(this._gain)}}refreshPaused(){const t=this._media.context,e=this._media.parent,s=this._paused||e.paused||t.paused;s!==this._pausedReal&&(this._pausedReal=s,s?(this._internalStop(),this.emit("paused")):(this.emit("resumed"),this.play({start:this._elapsed%this._duration,end:this._end,speed:this._speed,loop:this._loop,volume:this._volume})),this.emit("pause",s))}play(t){const{start:e,end:s,speed:r,loop:n,volume:a,muted:h,filters:o}=t;s&&console.assert(s>e,"End time is before start time"),this._paused=!1;const{source:l,gain:u}=this._media.nodes.cloneBufferSource();this._source=l,this._gain=u,this._speed=r,this._volume=a,this._loop=!!n,this._muted=h,this._filters=o,this.refresh();const c=this._source.buffer.duration;this._duration=c,this._end=s,this._lastUpdate=this._now(),this._elapsed=e,this._source.onended=this._onComplete.bind(this),this._loop?(this._source.loopEnd=s,this._source.loopStart=e,this._source.start(0,e)):s?this._source.start(0,e,s-e):this._source.start(0,e),this.emit("start"),this._update(!0),this.enableTicker(!0)}enableTicker(t){Tt.shared.remove(this._updateListener,this),t&&Tt.shared.add(this._updateListener,this)}get progress(){return this._progress}get paused(){return this._paused}set paused(t){this._paused=t,this.refreshPaused()}destroy(){var t;this.removeAllListeners(),this._internalStop(),this._gain&&(this._gain.disconnect(),this._gain=null),this._media&&(this._media.context.events.off("refresh",this.refresh,this),this._media.context.events.off("refreshPaused",this.refreshPaused,this),this._media=null),(t=this._filters)==null||t.forEach(e=>e.disconnect()),this._filters=null,this._end=null,this._speed=1,this._volume=1,this._loop=!1,this._elapsed=0,this._duration=0,this._paused=!1,this._muted=!1,this._pausedReal=!1}toString(){return`[WebAudioInstance id=${this.id}]`}_now(){return this._media.context.audioContext.currentTime}_updateListener(){this._update()}_update(t=!1){if(this._source){const e=this._now(),s=e-this._lastUpdate;if(s>0||t){const r=this._source.playbackRate.value;this._elapsed+=s*r,this._lastUpdate=e;const n=this._duration;let a;if(this._source.loopStart){const h=this._source.loopEnd-this._source.loopStart;a=(this._source.loopStart+this._elapsed%h)/n}else a=this._elapsed%n/n;this._progress=a,this.emit("progress",this._progress,n)}}}init(t){this._media=t,t.context.events.on("refresh",this.refresh,this),t.context.events.on("refreshPaused",this.refreshPaused,this)}_internalStop(){if(this._source){this.enableTicker(!1),this._source.onended=null,this._source.stop(0),this._source.disconnect();try{this._source.buffer=null}catch(t){console.warn("Failed to set AudioBufferSourceNode.buffer to null:",t)}this._source=null}}_onComplete(){if(this._source){this.enableTicker(!1),this._source.onended=null,this._source.disconnect();try{this._source.buffer=null}catch(t){console.warn("Failed to set AudioBufferSourceNode.buffer to null:",t)}}this._source=null,this._progress=1,this.emit("progress",1,this._duration),this.emit("end",this)}}class H0{constructor(t,e){this._output=e,this._input=t}get destination(){return this._input}get filters(){return this._filters}set filters(t){if(this._filters&&(this._filters.forEach(e=>{e&&e.disconnect()}),this._filters=null,this._input.connect(this._output)),t&&t.length){this._filters=t.slice(0),this._input.disconnect();let e=null;t.forEach(s=>{e===null?this._input.connect(s.destination):e.connect(s.destination),e=s}),e.connect(this._output)}}destroy(){this.filters=null,this._input=null,this._output=null}}const W0=class extends H0{constructor(i){const t=i.audioContext,e=t.createBufferSource(),s=t.createGain(),r=t.createAnalyser();e.connect(r),r.connect(s),s.connect(i.destination),super(r,s),this.context=i,this.bufferSource=e,this.gain=s,this.analyser=r}get script(){return this._script||(this._script=this.context.audioContext.createScriptProcessor(W0.BUFFER_SIZE),this._script.connect(this.context.destination)),this._script}destroy(){super.destroy(),this.bufferSource.disconnect(),this._script&&this._script.disconnect(),this.gain.disconnect(),this.analyser.disconnect(),this.bufferSource=null,this._script=null,this.gain=null,this.analyser=null,this.context=null}cloneBufferSource(){const i=this.bufferSource,t=this.context.audioContext.createBufferSource();t.buffer=i.buffer,dd.setParamValue(t.playbackRate,i.playbackRate.value),t.loop=i.loop;const e=this.context.audioContext.createGain();return t.connect(e),e.connect(this.destination),{source:t,gain:e}}get bufferSize(){return this.script.bufferSize}};let z0=W0;z0.BUFFER_SIZE=0;class bI{init(t){this.parent=t,this._nodes=new z0(this.context),this._source=this._nodes.bufferSource,this.source=t.options.source}destroy(){this.parent=null,this._nodes.destroy(),this._nodes=null;try{this._source.buffer=null}catch(t){console.warn("Failed to set AudioBufferSourceNode.buffer to null:",t)}this._source=null,this.source=null}create(){return new vI(this)}get context(){return this.parent.context}get isPlayable(){return!!this._source&&!!this._source.buffer}get filters(){return this._nodes.filters}set filters(t){this._nodes.filters=t}get duration(){return console.assert(this.isPlayable,"Sound not yet playable, no duration"),this._source.buffer.duration}get buffer(){return this._source.buffer}set buffer(t){this._source.buffer=t}get nodes(){return this._nodes}load(t){this.source?this._decode(this.source,t):this.parent.url?this._loadUrl(t):t?t(new Error("sound.url or sound.source must be set")):console.error("sound.url or sound.source must be set")}async _loadUrl(t){const e=this.parent.url,s=await z.ADAPTER.fetch(e);this._decode(await s.arrayBuffer(),t)}_decode(t,e){const s=(r,n)=>{if(r)e&&e(r);else{this.parent.isLoaded=!0,this.buffer=n;const a=this.parent.autoPlayStart();e&&e(null,this.parent,a)}};t instanceof AudioBuffer?s(null,t):this.parent.context.decode(t,s)}}const Fn=class{static from(i){let t={};typeof i=="string"?t.url=i:i instanceof ArrayBuffer||i instanceof AudioBuffer||i instanceof HTMLAudioElement?t.source=i:Array.isArray(i)?t.url=i:t=i,t={autoPlay:!1,singleInstance:!1,url:null,source:null,preload:!1,volume:1,speed:1,complete:null,loaded:null,loop:!1,...t},Object.freeze(t);const e=ko().useLegacy?new mI:new bI;return new Fn(e,t)}constructor(i,t){this.media=i,this.options=t,this._instances=[],this._sprites={},this.media.init(this);const e=t.complete;this._autoPlayOptions=e?{complete:e}:null,this.isLoaded=!1,this._preloadQueue=null,this.isPlaying=!1,this.autoPlay=t.autoPlay,this.singleInstance=t.singleInstance,this.preload=t.preload||this.autoPlay,this.url=Array.isArray(t.url)?this.preferUrl(t.url):t.url,this.speed=t.speed,this.volume=t.volume,this.loop=t.loop,t.sprites&&this.addSprites(t.sprites),this.preload&&this._preload(t.loaded)}preferUrl(i){const[t]=i.map(e=>({url:e,ext:bt.extname(e).slice(1)})).filter(({ext:e})=>vl[e]).sort((e,s)=>xl.indexOf(e.ext)-xl.indexOf(s.ext));if(!t)throw new Error("No supported file type found");return t.url}get context(){return ko().context}pause(){return this.isPlaying=!1,this.paused=!0,this}resume(){return this.isPlaying=this._instances.length>0,this.paused=!1,this}get paused(){return this._paused}set paused(i){this._paused=i,this.refreshPaused()}get speed(){return this._speed}set speed(i){this._speed=i,this.refresh()}get filters(){return this.media.filters}set filters(i){this.media.filters=i}addSprites(i,t){if(typeof i=="object"){const s={};for(const r in i)s[r]=this.addSprites(r,i[r]);return s}console.assert(!this._sprites[i],`Alias ${i} is already taken`);const e=new gI(this,t);return this._sprites[i]=e,e}destroy(){this._removeInstances(),this.removeSprites(),this.media.destroy(),this.media=null,this._sprites=null,this._instances=null}removeSprites(i){if(i){const t=this._sprites[i];t!==void 0&&(t.destroy(),delete this._sprites[i])}else for(const t in this._sprites)this.removeSprites(t);return this}get isPlayable(){return this.isLoaded&&this.media&&this.media.isPlayable}stop(){if(!this.isPlayable)return this.autoPlay=!1,this._autoPlayOptions=null,this;this.isPlaying=!1;for(let i=this._instances.length-1;i>=0;i--)this._instances[i].stop();return this}play(i,t){let e;if(typeof i=="string"?e={sprite:i,loop:this.loop,complete:t}:typeof i=="function"?(e={},e.complete=i):e=i,e={complete:null,loaded:null,sprite:null,end:null,start:0,volume:1,speed:1,muted:!1,loop:!1,...e||{}},e.sprite){const r=e.sprite;console.assert(!!this._sprites[r],`Alias ${r} is not available`);const n=this._sprites[r];e.start=n.start+(e.start||0),e.end=n.end,e.speed=n.speed||1,e.loop=n.loop||e.loop,delete e.sprite}if(e.offset&&(e.start=e.offset),!this.isLoaded)return this._preloadQueue?new Promise(r=>{this._preloadQueue.push(()=>{r(this.play(e))})}):(this._preloadQueue=[],this.autoPlay=!0,this._autoPlayOptions=e,new Promise((r,n)=>{this._preload((a,h,o)=>{this._preloadQueue.forEach(l=>l()),this._preloadQueue=null,a?n(a):(e.loaded&&e.loaded(a,h,o),r(o))})}));(this.singleInstance||e.singleInstance)&&this._removeInstances();const s=this._createInstance();return this._instances.push(s),this.isPlaying=!0,s.once("end",()=>{e.complete&&e.complete(this),this._onComplete(s)}),s.once("stop",()=>{this._onComplete(s)}),s.play(e),s}refresh(){const i=this._instances.length;for(let t=0;t<i;t++)this._instances[t].refresh()}refreshPaused(){const i=this._instances.length;for(let t=0;t<i;t++)this._instances[t].refreshPaused()}get volume(){return this._volume}set volume(i){this._volume=i,this.refresh()}get muted(){return this._muted}set muted(i){this._muted=i,this.refresh()}get loop(){return this._loop}set loop(i){this._loop=i,this.refresh()}_preload(i){this.media.load(i)}get instances(){return this._instances}get sprites(){return this._sprites}get duration(){return this.media.duration}autoPlayStart(){let i;return this.autoPlay&&(i=this.play(this._autoPlayOptions)),i}_removeInstances(){for(let i=this._instances.length-1;i>=0;i--)this._poolInstance(this._instances[i]);this._instances.length=0}_onComplete(i){if(this._instances){const t=this._instances.indexOf(i);t>-1&&this._instances.splice(t,1),this.isPlaying=this._instances.length>0}this._poolInstance(i)}_createInstance(){if(Fn._pool.length>0){const i=Fn._pool.pop();return i.init(this.media),i}return this.media.create()}_poolInstance(i){i.destroy(),Fn._pool.indexOf(i)<0&&Fn._pool.push(i)}};let bl=Fn;bl._pool=[];class wI extends Gs{constructor(){super(...arguments),this.speed=1,this.muted=!1,this.volume=1,this.paused=!1}refresh(){this.emit("refresh")}refreshPaused(){this.emit("refreshPaused")}get filters(){return console.warn("HTML Audio does not support filters"),null}set filters(t){console.warn("HTML Audio does not support filters")}get audioContext(){return console.warn("HTML Audio does not support audioContext"),null}toggleMute(){return this.muted=!this.muted,this.refresh(),this.muted}togglePause(){return this.paused=!this.paused,this.refreshPaused(),this.paused}destroy(){this.removeAllListeners()}}class Bo extends H0{constructor(){const t=window,e=new Bo.AudioContext,s=e.createDynamicsCompressor(),r=e.createAnalyser();r.connect(s),s.connect(e.destination),super(r,s),this.autoPause=!0,this._ctx=e,this._offlineCtx=new Bo.OfflineAudioContext(1,2,t.OfflineAudioContext?Math.max(8e3,Math.min(96e3,e.sampleRate)):44100),this.compressor=s,this.analyser=r,this.events=new Gs,this.volume=1,this.speed=1,this.muted=!1,this.paused=!1,this._locked=e.state==="suspended"&&("ontouchstart"in globalThis||"onclick"in globalThis),this._locked&&(this._unlock(),this._unlock=this._unlock.bind(this),document.addEventListener("mousedown",this._unlock,!0),document.addEventListener("touchstart",this._unlock,!0),document.addEventListener("touchend",this._unlock,!0)),this.onFocus=this.onFocus.bind(this),this.onBlur=this.onBlur.bind(this),globalThis.addEventListener("focus",this.onFocus),globalThis.addEventListener("blur",this.onBlur)}onFocus(){if(!this.autoPause)return;const t=this._ctx.state;(t==="suspended"||t==="interrupted"||!this._locked)&&(this.paused=this._pausedOnBlur,this.refreshPaused())}onBlur(){this.autoPause&&(this._locked||(this._pausedOnBlur=this._paused,this.paused=!0,this.refreshPaused()))}_unlock(){this._locked&&(this.playEmptySound(),this._ctx.state==="running"&&(document.removeEventListener("mousedown",this._unlock,!0),document.removeEventListener("touchend",this._unlock,!0),document.removeEventListener("touchstart",this._unlock,!0),this._locked=!1))}playEmptySound(){const t=this._ctx.createBufferSource();t.buffer=this._ctx.createBuffer(1,1,22050),t.connect(this._ctx.destination),t.start(0,0,0),t.context.state==="suspended"&&t.context.resume()}static get AudioContext(){const t=window;return t.AudioContext||t.webkitAudioContext||null}static get OfflineAudioContext(){const t=window;return t.OfflineAudioContext||t.webkitOfflineAudioContext||null}destroy(){super.destroy();const t=this._ctx;typeof t.close<"u"&&t.close(),globalThis.removeEventListener("focus",this.onFocus),globalThis.removeEventListener("blur",this.onBlur),this.events.removeAllListeners(),this.analyser.disconnect(),this.compressor.disconnect(),this.analyser=null,this.compressor=null,this.events=null,this._offlineCtx=null,this._ctx=null}get audioContext(){return this._ctx}get offlineContext(){return this._offlineCtx}set paused(t){t&&this._ctx.state==="running"?this._ctx.suspend():!t&&this._ctx.state==="suspended"&&this._ctx.resume(),this._paused=t}get paused(){return this._paused}refresh(){this.events.emit("refresh")}refreshPaused(){this.events.emit("refreshPaused")}toggleMute(){return this.muted=!this.muted,this.refresh(),this.muted}togglePause(){return this.paused=!this.paused,this.refreshPaused(),this._paused}decode(t,e){const s=n=>{e(new Error((n==null?void 0:n.message)||"Unable to decode file"))},r=this._offlineCtx.decodeAudioData(t,n=>{e(null,n)},s);r&&r.catch(s)}}class EI{constructor(){this.init()}init(){return this.supported&&(this._webAudioContext=new Bo),this._htmlAudioContext=new wI,this._sounds={},this.useLegacy=!this.supported,this}get context(){return this._context}get filtersAll(){return this.useLegacy?[]:this._context.filters}set filtersAll(t){this.useLegacy||(this._context.filters=t)}get supported(){return Bo.AudioContext!==null}add(t,e){if(typeof t=="object"){const n={};for(const a in t){const h=this._getOptions(t[a],e);n[a]=this.add(a,h)}return n}if(console.assert(!this._sounds[t],`Sound with alias ${t} already exists.`),e instanceof bl)return this._sounds[t]=e,e;const s=this._getOptions(e),r=bl.from(s);return this._sounds[t]=r,r}_getOptions(t,e){let s;return typeof t=="string"?s={url:t}:Array.isArray(t)?s={url:t}:t instanceof ArrayBuffer||t instanceof AudioBuffer||t instanceof HTMLAudioElement?s={source:t}:s=t,s={...s,...e||{}},s}get useLegacy(){return this._useLegacy}set useLegacy(t){this._useLegacy=t,this._context=!t&&this.supported?this._webAudioContext:this._htmlAudioContext}get disableAutoPause(){return!this._webAudioContext.autoPause}set disableAutoPause(t){this._webAudioContext.autoPause=!t}remove(t){return this.exists(t,!0),this._sounds[t].destroy(),delete this._sounds[t],this}get volumeAll(){return this._context.volume}set volumeAll(t){this._context.volume=t,this._context.refresh()}get speedAll(){return this._context.speed}set speedAll(t){this._context.speed=t,this._context.refresh()}togglePauseAll(){return this._context.togglePause()}pauseAll(){return this._context.paused=!0,this._context.refreshPaused(),this}resumeAll(){return this._context.paused=!1,this._context.refreshPaused(),this}toggleMuteAll(){return this._context.toggleMute()}muteAll(){return this._context.muted=!0,this._context.refresh(),this}unmuteAll(){return this._context.muted=!1,this._context.refresh(),this}removeAll(){for(const t in this._sounds)this._sounds[t].destroy(),delete this._sounds[t];return this}stopAll(){for(const t in this._sounds)this._sounds[t].stop();return this}exists(t,e=!1){const s=!!this._sounds[t];return e&&console.assert(s,`No sound matching alias '${t}'.`),s}isPlaying(){for(const t in this._sounds)if(this._sounds[t].isPlaying)return!0;return!1}find(t){return this.exists(t,!0),this._sounds[t]}play(t,e){return this.find(t).play(e)}stop(t){return this.find(t).stop()}pause(t){return this.find(t).pause()}resume(t){return this.find(t).resume()}volume(t,e){const s=this.find(t);return e!==void 0&&(s.volume=e),s.volume}speed(t,e){const s=this.find(t);return e!==void 0&&(s.speed=e),s.speed}duration(t){return this.find(t).duration}close(){return this.removeAll(),this._sounds=null,this._webAudioContext&&(this._webAudioContext.destroy(),this._webAudioContext=null),this._htmlAudioContext&&(this._htmlAudioContext.destroy(),this._htmlAudioContext=null),this._context=null,this}}const j0=i=>{var e;const t=i.src;return((e=i==null?void 0:i.alias)==null?void 0:e[0])??bt.basename(t,bt.extname(t))},TI={extension:Y.Asset,detection:{test:async()=>!0,add:async i=>[...i,...xl.filter(t=>vl[t])],remove:async i=>i.filter(t=>i.includes(t))},loader:{extension:{type:[Y.LoadParser],priority:Ne.High},test(i){const t=bt.extname(i).slice(1);return!!vl[t]||_I.some(e=>i.startsWith(`data:${e}`))},async load(i,t){const e=await new Promise((s,r)=>bl.from({...t.data,url:i,preload:!0,loaded(n,a){var h,o;n?r(n):s(a),(o=(h=t.data)==null?void 0:h.loaded)==null||o.call(h,n,a)}}));return ko().add(j0(t),e),e},async unload(i,t){ko().remove(j0(t))}}};K.add(TI),fI(new EI);class AI{constructor(){this.effectEnabled=!0,this.musicEnabled=!0,this._isMusicPaused=!1,this._isBackground=!1,this._playingList=[],this._setPlayStatus=t=>{var e,s;t?!this._isMusicPaused&&((e=this._musicPlayer)==null||e.play()):(s=this._musicPlayer)==null||s.pause(),this._playingList.forEach(r=>{t?r.audio.play():r.audio.pause()})},document.addEventListener("visibilitychange",()=>{this._isBackground=document.hidden,this._setPlayStatus(!document.hidden)})}playEffect(t,e){return new Promise(s=>{const r=new Date().getTime(),n=Gr.get(t).url,a=new cd.Howl({src:n,mute:this._isBackground||!this.effectEnabled});if(a.play(),a.on("end",()=>{this._playingList=this._playingList.filter(h=>h.id!==r),s()}),e){const o=a.duration()-e;a.seek(o)}this._playingList.push({id:r,audio:a,url:n})})}async playMusic(t){const e=Gr.get(t).url;this._musicPlayer&&(xt.killTweensOf(this._musicPlayer),await xt.to(this._musicPlayer,{volume:0,duration:1,ease:"linear"}),this._musicPlayer.stop()),this._musicPlayer=new cd.Howl({src:e,loop:!0,volume:0,html5:!0,mute:this._isBackground||!this.effectEnabled}),this._musicPlayer.play(),this._isMusicPaused=!1,xt.killTweensOf(this._musicPlayer),xt.to(this._musicPlayer,{volume:1,duration:1,ease:"linear"})}pauseMusic(){var t;this._isMusicPaused=!0,(t=this._musicPlayer)==null||t.pause()}resumeMusic(){var t;this._isMusicPaused=!1,(t=this._musicPlayer)==null||t.play()}stopEffect(t){const e=Gr.get(t).url;this._playingList.forEach(s=>{s.url===e&&s.audio.pause()}),this._playingList=this._playingList.filter(s=>s.url!==e)}setEffectEnabled(t){this.effectEnabled=t,this._setEffectMute(!t)}setMusicEnabled(t){this.musicEnabled=t,this._setMusicMute(!t)}_setMusicMute(t){var e;(e=this._musicPlayer)==null||e.mute(t||!this.musicEnabled)}_setEffectMute(t){this._playingList.forEach(e=>{e.audio.mute(t||!this.effectEnabled)})}}const SI=i=>{const{texture:t,dotWidth:e,width:s,height:r}=i;let n=[];Array.isArray(e)?n=e:n=[e,e,e,e];const a=new PT(t,n[0],n[1],n[2],n[3]);return a.width=s,a.height=r,a},CI=(i,t,e)=>{let s=!1;return i.cursor="pointer",i.eventMode="static",i.on(t,r=>{s||r.button!==2&&e(r)}),()=>{s=!0}},II=(i,t,e=0)=>parseFloat((Math.random()*(t-i)+i).toFixed(e)),PI=(i,t)=>{let e=0;const s=new Tt,r=n=>{e+=n*s.deltaMS;let a=0;Array.isArray(t)?a=II(t[0],t[1],2):a=t,e>=a&&(i(),e=0)};return s.add(r),s.start(),()=>{s.remove(r),s.stop()}},RI=(i,t,e)=>{const s=r=>{const n=t.getBounds().contains(r.clientX,r.clientY),a=i.getBounds().contains(r.clientX,r.clientY);!n&&!a&&i.visible&&(e(),window.removeEventListener("pointerdown",s))};return window.addEventListener("pointerdown",s),()=>{window.removeEventListener("pointerdown",s)}},MI=(i=1,t)=>new Promise(e=>{let s=0;const r=new Tt,n=()=>{s+=r.deltaMS,s>=i&&(t==null||t(),r.destroy(),e())};r.add(n),r.start()}),FI=(i,t)=>{let e;if(i==="brightness")e=new hn,e.brightness(t,!1);else if(i==="blur")e=new um;else if(i==="desaturate")e=new hn,e.desaturate();else if(i==="contrast")e=new hn,e.contrast(t,!1);else throw new Error("未知滤镜名称");return e.resolution=window.devicePixelRatio||1,e};var kI=`attribute vec2 aVertexPosition;
|
|
1189
|
+
*/(function(){HowlerGlobal.prototype._pos=[0,0,0],HowlerGlobal.prototype._orientation=[0,0,-1,0,1,0],HowlerGlobal.prototype.stereo=function(e){var s=this;if(!s.ctx||!s.ctx.listener)return s;for(var r=s._howls.length-1;r>=0;r--)s._howls[r].stereo(e);return s},HowlerGlobal.prototype.pos=function(e,s,r){var n=this;if(!n.ctx||!n.ctx.listener)return n;if(s=typeof s!="number"?n._pos[1]:s,r=typeof r!="number"?n._pos[2]:r,typeof e=="number")n._pos=[e,s,r],typeof n.ctx.listener.positionX<"u"?(n.ctx.listener.positionX.setTargetAtTime(n._pos[0],Howler.ctx.currentTime,.1),n.ctx.listener.positionY.setTargetAtTime(n._pos[1],Howler.ctx.currentTime,.1),n.ctx.listener.positionZ.setTargetAtTime(n._pos[2],Howler.ctx.currentTime,.1)):n.ctx.listener.setPosition(n._pos[0],n._pos[1],n._pos[2]);else return n._pos;return n},HowlerGlobal.prototype.orientation=function(e,s,r,n,a,h){var o=this;if(!o.ctx||!o.ctx.listener)return o;var l=o._orientation;if(s=typeof s!="number"?l[1]:s,r=typeof r!="number"?l[2]:r,n=typeof n!="number"?l[3]:n,a=typeof a!="number"?l[4]:a,h=typeof h!="number"?l[5]:h,typeof e=="number")o._orientation=[e,s,r,n,a,h],typeof o.ctx.listener.forwardX<"u"?(o.ctx.listener.forwardX.setTargetAtTime(e,Howler.ctx.currentTime,.1),o.ctx.listener.forwardY.setTargetAtTime(s,Howler.ctx.currentTime,.1),o.ctx.listener.forwardZ.setTargetAtTime(r,Howler.ctx.currentTime,.1),o.ctx.listener.upX.setTargetAtTime(n,Howler.ctx.currentTime,.1),o.ctx.listener.upY.setTargetAtTime(a,Howler.ctx.currentTime,.1),o.ctx.listener.upZ.setTargetAtTime(h,Howler.ctx.currentTime,.1)):o.ctx.listener.setOrientation(e,s,r,n,a,h);else return l;return o},Howl.prototype.init=function(e){return function(s){var r=this;return r._orientation=s.orientation||[1,0,0],r._stereo=s.stereo||null,r._pos=s.pos||null,r._pannerAttr={coneInnerAngle:typeof s.coneInnerAngle<"u"?s.coneInnerAngle:360,coneOuterAngle:typeof s.coneOuterAngle<"u"?s.coneOuterAngle:360,coneOuterGain:typeof s.coneOuterGain<"u"?s.coneOuterGain:0,distanceModel:typeof s.distanceModel<"u"?s.distanceModel:"inverse",maxDistance:typeof s.maxDistance<"u"?s.maxDistance:1e4,panningModel:typeof s.panningModel<"u"?s.panningModel:"HRTF",refDistance:typeof s.refDistance<"u"?s.refDistance:1,rolloffFactor:typeof s.rolloffFactor<"u"?s.rolloffFactor:1},r._onstereo=s.onstereo?[{fn:s.onstereo}]:[],r._onpos=s.onpos?[{fn:s.onpos}]:[],r._onorientation=s.onorientation?[{fn:s.onorientation}]:[],e.call(this,s)}}(Howl.prototype.init),Howl.prototype.stereo=function(e,s){var r=this;if(!r._webAudio)return r;if(r._state!=="loaded")return r._queue.push({event:"stereo",action:function(){r.stereo(e,s)}}),r;var n=typeof Howler.ctx.createStereoPanner>"u"?"spatial":"stereo";if(typeof s>"u")if(typeof e=="number")r._stereo=e,r._pos=[e,0,0];else return r._stereo;for(var a=r._getSoundIds(s),h=0;h<a.length;h++){var o=r._soundById(a[h]);if(o)if(typeof e=="number")o._stereo=e,o._pos=[e,0,0],o._node&&(o._pannerAttr.panningModel="equalpower",(!o._panner||!o._panner.pan)&&t(o,n),n==="spatial"?typeof o._panner.positionX<"u"?(o._panner.positionX.setValueAtTime(e,Howler.ctx.currentTime),o._panner.positionY.setValueAtTime(0,Howler.ctx.currentTime),o._panner.positionZ.setValueAtTime(0,Howler.ctx.currentTime)):o._panner.setPosition(e,0,0):o._panner.pan.setValueAtTime(e,Howler.ctx.currentTime)),r._emit("stereo",o._id);else return o._stereo}return r},Howl.prototype.pos=function(e,s,r,n){var a=this;if(!a._webAudio)return a;if(a._state!=="loaded")return a._queue.push({event:"pos",action:function(){a.pos(e,s,r,n)}}),a;if(s=typeof s!="number"?0:s,r=typeof r!="number"?-.5:r,typeof n>"u")if(typeof e=="number")a._pos=[e,s,r];else return a._pos;for(var h=a._getSoundIds(n),o=0;o<h.length;o++){var l=a._soundById(h[o]);if(l)if(typeof e=="number")l._pos=[e,s,r],l._node&&((!l._panner||l._panner.pan)&&t(l,"spatial"),typeof l._panner.positionX<"u"?(l._panner.positionX.setValueAtTime(e,Howler.ctx.currentTime),l._panner.positionY.setValueAtTime(s,Howler.ctx.currentTime),l._panner.positionZ.setValueAtTime(r,Howler.ctx.currentTime)):l._panner.setPosition(e,s,r)),a._emit("pos",l._id);else return l._pos}return a},Howl.prototype.orientation=function(e,s,r,n){var a=this;if(!a._webAudio)return a;if(a._state!=="loaded")return a._queue.push({event:"orientation",action:function(){a.orientation(e,s,r,n)}}),a;if(s=typeof s!="number"?a._orientation[1]:s,r=typeof r!="number"?a._orientation[2]:r,typeof n>"u")if(typeof e=="number")a._orientation=[e,s,r];else return a._orientation;for(var h=a._getSoundIds(n),o=0;o<h.length;o++){var l=a._soundById(h[o]);if(l)if(typeof e=="number")l._orientation=[e,s,r],l._node&&(l._panner||(l._pos||(l._pos=a._pos||[0,0,-.5]),t(l,"spatial")),typeof l._panner.orientationX<"u"?(l._panner.orientationX.setValueAtTime(e,Howler.ctx.currentTime),l._panner.orientationY.setValueAtTime(s,Howler.ctx.currentTime),l._panner.orientationZ.setValueAtTime(r,Howler.ctx.currentTime)):l._panner.setOrientation(e,s,r)),a._emit("orientation",l._id);else return l._orientation}return a},Howl.prototype.pannerAttr=function(){var e=this,s=arguments,r,n,a;if(!e._webAudio)return e;if(s.length===0)return e._pannerAttr;if(s.length===1)if(typeof s[0]=="object")r=s[0],typeof n>"u"&&(r.pannerAttr||(r.pannerAttr={coneInnerAngle:r.coneInnerAngle,coneOuterAngle:r.coneOuterAngle,coneOuterGain:r.coneOuterGain,distanceModel:r.distanceModel,maxDistance:r.maxDistance,refDistance:r.refDistance,rolloffFactor:r.rolloffFactor,panningModel:r.panningModel}),e._pannerAttr={coneInnerAngle:typeof r.pannerAttr.coneInnerAngle<"u"?r.pannerAttr.coneInnerAngle:e._coneInnerAngle,coneOuterAngle:typeof r.pannerAttr.coneOuterAngle<"u"?r.pannerAttr.coneOuterAngle:e._coneOuterAngle,coneOuterGain:typeof r.pannerAttr.coneOuterGain<"u"?r.pannerAttr.coneOuterGain:e._coneOuterGain,distanceModel:typeof r.pannerAttr.distanceModel<"u"?r.pannerAttr.distanceModel:e._distanceModel,maxDistance:typeof r.pannerAttr.maxDistance<"u"?r.pannerAttr.maxDistance:e._maxDistance,refDistance:typeof r.pannerAttr.refDistance<"u"?r.pannerAttr.refDistance:e._refDistance,rolloffFactor:typeof r.pannerAttr.rolloffFactor<"u"?r.pannerAttr.rolloffFactor:e._rolloffFactor,panningModel:typeof r.pannerAttr.panningModel<"u"?r.pannerAttr.panningModel:e._panningModel});else return a=e._soundById(parseInt(s[0],10)),a?a._pannerAttr:e._pannerAttr;else s.length===2&&(r=s[0],n=parseInt(s[1],10));for(var h=e._getSoundIds(n),o=0;o<h.length;o++)if(a=e._soundById(h[o]),a){var l=a._pannerAttr;l={coneInnerAngle:typeof r.coneInnerAngle<"u"?r.coneInnerAngle:l.coneInnerAngle,coneOuterAngle:typeof r.coneOuterAngle<"u"?r.coneOuterAngle:l.coneOuterAngle,coneOuterGain:typeof r.coneOuterGain<"u"?r.coneOuterGain:l.coneOuterGain,distanceModel:typeof r.distanceModel<"u"?r.distanceModel:l.distanceModel,maxDistance:typeof r.maxDistance<"u"?r.maxDistance:l.maxDistance,refDistance:typeof r.refDistance<"u"?r.refDistance:l.refDistance,rolloffFactor:typeof r.rolloffFactor<"u"?r.rolloffFactor:l.rolloffFactor,panningModel:typeof r.panningModel<"u"?r.panningModel:l.panningModel};var u=a._panner;u||(a._pos||(a._pos=e._pos||[0,0,-.5]),t(a,"spatial"),u=a._panner),u.coneInnerAngle=l.coneInnerAngle,u.coneOuterAngle=l.coneOuterAngle,u.coneOuterGain=l.coneOuterGain,u.distanceModel=l.distanceModel,u.maxDistance=l.maxDistance,u.refDistance=l.refDistance,u.rolloffFactor=l.rolloffFactor,u.panningModel=l.panningModel}return e},Sound.prototype.init=function(e){return function(){var s=this,r=s._parent;s._orientation=r._orientation,s._stereo=r._stereo,s._pos=r._pos,s._pannerAttr=r._pannerAttr,e.call(this),s._stereo?r.stereo(s._stereo):s._pos&&r.pos(s._pos[0],s._pos[1],s._pos[2],s._id)}}(Sound.prototype.init),Sound.prototype.reset=function(e){return function(){var s=this,r=s._parent;return s._orientation=r._orientation,s._stereo=r._stereo,s._pos=r._pos,s._pannerAttr=r._pannerAttr,s._stereo?r.stereo(s._stereo):s._pos?r.pos(s._pos[0],s._pos[1],s._pos[2],s._id):s._panner&&(s._panner.disconnect(0),s._panner=void 0,r._refreshBuffer(s)),e.call(this)}}(Sound.prototype.reset);var t=function(e,s){s=s||"spatial",s==="spatial"?(e._panner=Howler.ctx.createPanner(),e._panner.coneInnerAngle=e._pannerAttr.coneInnerAngle,e._panner.coneOuterAngle=e._pannerAttr.coneOuterAngle,e._panner.coneOuterGain=e._pannerAttr.coneOuterGain,e._panner.distanceModel=e._pannerAttr.distanceModel,e._panner.maxDistance=e._pannerAttr.maxDistance,e._panner.refDistance=e._pannerAttr.refDistance,e._panner.rolloffFactor=e._pannerAttr.rolloffFactor,e._panner.panningModel=e._pannerAttr.panningModel,typeof e._panner.positionX<"u"?(e._panner.positionX.setValueAtTime(e._pos[0],Howler.ctx.currentTime),e._panner.positionY.setValueAtTime(e._pos[1],Howler.ctx.currentTime),e._panner.positionZ.setValueAtTime(e._pos[2],Howler.ctx.currentTime)):e._panner.setPosition(e._pos[0],e._pos[1],e._pos[2]),typeof e._panner.orientationX<"u"?(e._panner.orientationX.setValueAtTime(e._orientation[0],Howler.ctx.currentTime),e._panner.orientationY.setValueAtTime(e._orientation[1],Howler.ctx.currentTime),e._panner.orientationZ.setValueAtTime(e._orientation[2],Howler.ctx.currentTime)):e._panner.setOrientation(e._orientation[0],e._orientation[1],e._orientation[2])):(e._panner=Howler.ctx.createStereoPanner(),e._panner.pan.setValueAtTime(e._stereo,Howler.ctx.currentTime)),e._panner.connect(e._node),e._paused||e._parent.pause(e._id,!0).play(e._id,!0)}})()})(cd);let $0;function fI(i){return $0=i,i}function ko(){return $0}let pI=0;const ud=class extends Gs{constructor(i){super(),this.id=pI++,this.init(i)}set(i,t){if(this[i]===void 0)throw new Error(`Property with name ${i} does not exist.`);switch(i){case"speed":this.speed=t;break;case"volume":this.volume=t;break;case"paused":this.paused=t;break;case"loop":this.loop=t;break;case"muted":this.muted=t;break}return this}get progress(){const{currentTime:i}=this._source;return i/this._duration}get paused(){return this._paused}set paused(i){this._paused=i,this.refreshPaused()}_onPlay(){this._playing=!0}_onPause(){this._playing=!1}init(i){this._playing=!1,this._duration=i.source.duration;const t=this._source=i.source.cloneNode(!1);t.src=i.parent.url,t.onplay=this._onPlay.bind(this),t.onpause=this._onPause.bind(this),i.context.on("refresh",this.refresh,this),i.context.on("refreshPaused",this.refreshPaused,this),this._media=i}_internalStop(){this._source&&this._playing&&(this._source.onended=null,this._source.pause())}stop(){this._internalStop(),this._source&&this.emit("stop")}get speed(){return this._speed}set speed(i){this._speed=i,this.refresh()}get volume(){return this._volume}set volume(i){this._volume=i,this.refresh()}get loop(){return this._loop}set loop(i){this._loop=i,this.refresh()}get muted(){return this._muted}set muted(i){this._muted=i,this.refresh()}get filters(){return console.warn("HTML Audio does not support filters"),null}set filters(i){console.warn("HTML Audio does not support filters")}refresh(){const i=this._media.context,t=this._media.parent;this._source.loop=this._loop||t.loop;const e=i.volume*(i.muted?0:1),s=t.volume*(t.muted?0:1),r=this._volume*(this._muted?0:1);this._source.volume=r*e*s,this._source.playbackRate=this._speed*i.speed*t.speed}refreshPaused(){const i=this._media.context,t=this._media.parent,e=this._paused||t.paused||i.paused;e!==this._pausedReal&&(this._pausedReal=e,e?(this._internalStop(),this.emit("paused")):(this.emit("resumed"),this.play({start:this._source.currentTime,end:this._end,volume:this._volume,speed:this._speed,loop:this._loop})),this.emit("pause",e))}play(i){const{start:t,end:e,speed:s,loop:r,volume:n,muted:a}=i;e&&console.assert(e>t,"End time is before start time"),this._speed=s,this._volume=n,this._loop=!!r,this._muted=a,this.refresh(),this.loop&&e!==null&&(console.warn('Looping not support when specifying an "end" time'),this.loop=!1),this._start=t,this._end=e||this._duration,this._start=Math.max(0,this._start-ud.PADDING),this._end=Math.min(this._end+ud.PADDING,this._duration),this._source.onloadedmetadata=()=>{this._source&&(this._source.currentTime=t,this._source.onloadedmetadata=null,this.emit("progress",t,this._duration),Tt.shared.add(this._onUpdate,this))},this._source.onended=this._onComplete.bind(this),this._source.play(),this.emit("start")}_onUpdate(){this.emit("progress",this.progress,this._duration),this._source.currentTime>=this._end&&!this._source.loop&&this._onComplete()}_onComplete(){Tt.shared.remove(this._onUpdate,this),this._internalStop(),this.emit("progress",1,this._duration),this.emit("end",this)}destroy(){Tt.shared.remove(this._onUpdate,this),this.removeAllListeners();const i=this._source;i&&(i.onended=null,i.onplay=null,i.onpause=null,this._internalStop()),this._source=null,this._speed=1,this._volume=1,this._loop=!1,this._end=null,this._start=0,this._duration=0,this._playing=!1,this._pausedReal=!1,this._paused=!1,this._muted=!1,this._media&&(this._media.context.off("refresh",this.refresh,this),this._media.context.off("refreshPaused",this.refreshPaused,this),this._media=null)}toString(){return`[HTMLAudioInstance id=${this.id}]`}};let Y0=ud;Y0.PADDING=.1;class mI extends Gs{init(t){this.parent=t,this._source=t.options.source||new Audio,t.url&&(this._source.src=t.url)}create(){return new Y0(this)}get isPlayable(){return!!this._source&&this._source.readyState===4}get duration(){return this._source.duration}get context(){return this.parent.context}get filters(){return null}set filters(t){console.warn("HTML Audio does not support filters")}destroy(){this.removeAllListeners(),this.parent=null,this._source&&(this._source.src="",this._source.load(),this._source=null)}get source(){return this._source}load(t){const e=this._source,s=this.parent;if(e.readyState===4){s.isLoaded=!0;const o=s.autoPlayStart();t&&setTimeout(()=>{t(null,s,o)},0);return}if(!s.url){t(new Error("sound.url or sound.source must be set"));return}e.src=s.url;const r=()=>{h(),s.isLoaded=!0;const o=s.autoPlayStart();t&&t(null,s,o)},n=()=>{h(),t&&t(new Error("Sound loading has been aborted"))},a=()=>{h();const o=`Failed to load audio element (code: ${e.error.code})`;t?t(new Error(o)):console.error(o)},h=()=>{e.removeEventListener("canplaythrough",r),e.removeEventListener("load",r),e.removeEventListener("abort",n),e.removeEventListener("error",a)};e.addEventListener("canplaythrough",r,!1),e.addEventListener("load",r,!1),e.addEventListener("abort",n,!1),e.addEventListener("error",a,!1),e.load()}}class gI{constructor(t,e){this.parent=t,Object.assign(this,e),this.duration=this.end-this.start,console.assert(this.duration>0,"End time must be after start time")}play(t){return this.parent.play({complete:t,speed:this.speed||this.parent.speed,end:this.end,start:this.start,loop:this.loop})}destroy(){this.parent=null}}const xl=["ogg","oga","opus","m4a","mp3","mpeg","wav","aiff","wma","mid","caf"],_I=["audio/mpeg","audio/ogg"],vl={};function yI(i){const t={m4a:"audio/mp4",oga:"audio/ogg",opus:'audio/ogg; codecs="opus"',caf:'audio/x-caf; codecs="opus"',...i||{}},e=document.createElement("audio"),s={},r=/^no$/;xl.forEach(n=>{const a=e.canPlayType(`audio/${n}`).replace(r,""),h=t[n]?e.canPlayType(t[n]).replace(r,""):"";s[n]=!!a||!!h}),Object.assign(vl,s)}yI();class dd{static setParamValue(t,e){if(t.setValueAtTime){const s=ko().context;t.setValueAtTime(e,s.audioContext.currentTime)}else t.value=e;return e}}let xI=0;class vI extends Gs{constructor(t){super(),this.id=xI++,this._media=null,this._paused=!1,this._muted=!1,this._elapsed=0,this.init(t)}set(t,e){if(this[t]===void 0)throw new Error(`Property with name ${t} does not exist.`);switch(t){case"speed":this.speed=e;break;case"volume":this.volume=e;break;case"muted":this.muted=e;break;case"loop":this.loop=e;break;case"paused":this.paused=e;break}return this}stop(){this._source&&(this._internalStop(),this.emit("stop"))}get speed(){return this._speed}set speed(t){this._speed=t,this.refresh(),this._update(!0)}get volume(){return this._volume}set volume(t){this._volume=t,this.refresh()}get muted(){return this._muted}set muted(t){this._muted=t,this.refresh()}get loop(){return this._loop}set loop(t){this._loop=t,this.refresh()}get filters(){return this._filters}set filters(t){var e;this._filters&&((e=this._filters)==null||e.filter(s=>s).forEach(s=>s.disconnect()),this._filters=null,this._source.connect(this._gain)),this._filters=t!=null&&t.length?t.slice(0):null,this.refresh()}refresh(){if(!this._source)return;const t=this._media.context,e=this._media.parent;this._source.loop=this._loop||e.loop;const s=t.volume*(t.muted?0:1),r=e.volume*(e.muted?0:1),n=this._volume*(this._muted?0:1);dd.setParamValue(this._gain.gain,n*r*s),dd.setParamValue(this._source.playbackRate,this._speed*e.speed*t.speed),this.applyFilters()}applyFilters(){var t;if((t=this._filters)!=null&&t.length){this._source.disconnect();let e=this._source;this._filters.forEach(s=>{e.connect(s.destination),e=s}),e.connect(this._gain)}}refreshPaused(){const t=this._media.context,e=this._media.parent,s=this._paused||e.paused||t.paused;s!==this._pausedReal&&(this._pausedReal=s,s?(this._internalStop(),this.emit("paused")):(this.emit("resumed"),this.play({start:this._elapsed%this._duration,end:this._end,speed:this._speed,loop:this._loop,volume:this._volume})),this.emit("pause",s))}play(t){const{start:e,end:s,speed:r,loop:n,volume:a,muted:h,filters:o}=t;s&&console.assert(s>e,"End time is before start time"),this._paused=!1;const{source:l,gain:u}=this._media.nodes.cloneBufferSource();this._source=l,this._gain=u,this._speed=r,this._volume=a,this._loop=!!n,this._muted=h,this._filters=o,this.refresh();const c=this._source.buffer.duration;this._duration=c,this._end=s,this._lastUpdate=this._now(),this._elapsed=e,this._source.onended=this._onComplete.bind(this),this._loop?(this._source.loopEnd=s,this._source.loopStart=e,this._source.start(0,e)):s?this._source.start(0,e,s-e):this._source.start(0,e),this.emit("start"),this._update(!0),this.enableTicker(!0)}enableTicker(t){Tt.shared.remove(this._updateListener,this),t&&Tt.shared.add(this._updateListener,this)}get progress(){return this._progress}get paused(){return this._paused}set paused(t){this._paused=t,this.refreshPaused()}destroy(){var t;this.removeAllListeners(),this._internalStop(),this._gain&&(this._gain.disconnect(),this._gain=null),this._media&&(this._media.context.events.off("refresh",this.refresh,this),this._media.context.events.off("refreshPaused",this.refreshPaused,this),this._media=null),(t=this._filters)==null||t.forEach(e=>e.disconnect()),this._filters=null,this._end=null,this._speed=1,this._volume=1,this._loop=!1,this._elapsed=0,this._duration=0,this._paused=!1,this._muted=!1,this._pausedReal=!1}toString(){return`[WebAudioInstance id=${this.id}]`}_now(){return this._media.context.audioContext.currentTime}_updateListener(){this._update()}_update(t=!1){if(this._source){const e=this._now(),s=e-this._lastUpdate;if(s>0||t){const r=this._source.playbackRate.value;this._elapsed+=s*r,this._lastUpdate=e;const n=this._duration;let a;if(this._source.loopStart){const h=this._source.loopEnd-this._source.loopStart;a=(this._source.loopStart+this._elapsed%h)/n}else a=this._elapsed%n/n;this._progress=a,this.emit("progress",this._progress,n)}}}init(t){this._media=t,t.context.events.on("refresh",this.refresh,this),t.context.events.on("refreshPaused",this.refreshPaused,this)}_internalStop(){if(this._source){this.enableTicker(!1),this._source.onended=null,this._source.stop(0),this._source.disconnect();try{this._source.buffer=null}catch(t){console.warn("Failed to set AudioBufferSourceNode.buffer to null:",t)}this._source=null}}_onComplete(){if(this._source){this.enableTicker(!1),this._source.onended=null,this._source.disconnect();try{this._source.buffer=null}catch(t){console.warn("Failed to set AudioBufferSourceNode.buffer to null:",t)}}this._source=null,this._progress=1,this.emit("progress",1,this._duration),this.emit("end",this)}}class H0{constructor(t,e){this._output=e,this._input=t}get destination(){return this._input}get filters(){return this._filters}set filters(t){if(this._filters&&(this._filters.forEach(e=>{e&&e.disconnect()}),this._filters=null,this._input.connect(this._output)),t&&t.length){this._filters=t.slice(0),this._input.disconnect();let e=null;t.forEach(s=>{e===null?this._input.connect(s.destination):e.connect(s.destination),e=s}),e.connect(this._output)}}destroy(){this.filters=null,this._input=null,this._output=null}}const W0=class extends H0{constructor(i){const t=i.audioContext,e=t.createBufferSource(),s=t.createGain(),r=t.createAnalyser();e.connect(r),r.connect(s),s.connect(i.destination),super(r,s),this.context=i,this.bufferSource=e,this.gain=s,this.analyser=r}get script(){return this._script||(this._script=this.context.audioContext.createScriptProcessor(W0.BUFFER_SIZE),this._script.connect(this.context.destination)),this._script}destroy(){super.destroy(),this.bufferSource.disconnect(),this._script&&this._script.disconnect(),this.gain.disconnect(),this.analyser.disconnect(),this.bufferSource=null,this._script=null,this.gain=null,this.analyser=null,this.context=null}cloneBufferSource(){const i=this.bufferSource,t=this.context.audioContext.createBufferSource();t.buffer=i.buffer,dd.setParamValue(t.playbackRate,i.playbackRate.value),t.loop=i.loop;const e=this.context.audioContext.createGain();return t.connect(e),e.connect(this.destination),{source:t,gain:e}}get bufferSize(){return this.script.bufferSize}};let z0=W0;z0.BUFFER_SIZE=0;class bI{init(t){this.parent=t,this._nodes=new z0(this.context),this._source=this._nodes.bufferSource,this.source=t.options.source}destroy(){this.parent=null,this._nodes.destroy(),this._nodes=null;try{this._source.buffer=null}catch(t){console.warn("Failed to set AudioBufferSourceNode.buffer to null:",t)}this._source=null,this.source=null}create(){return new vI(this)}get context(){return this.parent.context}get isPlayable(){return!!this._source&&!!this._source.buffer}get filters(){return this._nodes.filters}set filters(t){this._nodes.filters=t}get duration(){return console.assert(this.isPlayable,"Sound not yet playable, no duration"),this._source.buffer.duration}get buffer(){return this._source.buffer}set buffer(t){this._source.buffer=t}get nodes(){return this._nodes}load(t){this.source?this._decode(this.source,t):this.parent.url?this._loadUrl(t):t?t(new Error("sound.url or sound.source must be set")):console.error("sound.url or sound.source must be set")}async _loadUrl(t){const e=this.parent.url,s=await z.ADAPTER.fetch(e);this._decode(await s.arrayBuffer(),t)}_decode(t,e){const s=(r,n)=>{if(r)e&&e(r);else{this.parent.isLoaded=!0,this.buffer=n;const a=this.parent.autoPlayStart();e&&e(null,this.parent,a)}};t instanceof AudioBuffer?s(null,t):this.parent.context.decode(t,s)}}const Fn=class{static from(i){let t={};typeof i=="string"?t.url=i:i instanceof ArrayBuffer||i instanceof AudioBuffer||i instanceof HTMLAudioElement?t.source=i:Array.isArray(i)?t.url=i:t=i,t={autoPlay:!1,singleInstance:!1,url:null,source:null,preload:!1,volume:1,speed:1,complete:null,loaded:null,loop:!1,...t},Object.freeze(t);const e=ko().useLegacy?new mI:new bI;return new Fn(e,t)}constructor(i,t){this.media=i,this.options=t,this._instances=[],this._sprites={},this.media.init(this);const e=t.complete;this._autoPlayOptions=e?{complete:e}:null,this.isLoaded=!1,this._preloadQueue=null,this.isPlaying=!1,this.autoPlay=t.autoPlay,this.singleInstance=t.singleInstance,this.preload=t.preload||this.autoPlay,this.url=Array.isArray(t.url)?this.preferUrl(t.url):t.url,this.speed=t.speed,this.volume=t.volume,this.loop=t.loop,t.sprites&&this.addSprites(t.sprites),this.preload&&this._preload(t.loaded)}preferUrl(i){const[t]=i.map(e=>({url:e,ext:bt.extname(e).slice(1)})).filter(({ext:e})=>vl[e]).sort((e,s)=>xl.indexOf(e.ext)-xl.indexOf(s.ext));if(!t)throw new Error("No supported file type found");return t.url}get context(){return ko().context}pause(){return this.isPlaying=!1,this.paused=!0,this}resume(){return this.isPlaying=this._instances.length>0,this.paused=!1,this}get paused(){return this._paused}set paused(i){this._paused=i,this.refreshPaused()}get speed(){return this._speed}set speed(i){this._speed=i,this.refresh()}get filters(){return this.media.filters}set filters(i){this.media.filters=i}addSprites(i,t){if(typeof i=="object"){const s={};for(const r in i)s[r]=this.addSprites(r,i[r]);return s}console.assert(!this._sprites[i],`Alias ${i} is already taken`);const e=new gI(this,t);return this._sprites[i]=e,e}destroy(){this._removeInstances(),this.removeSprites(),this.media.destroy(),this.media=null,this._sprites=null,this._instances=null}removeSprites(i){if(i){const t=this._sprites[i];t!==void 0&&(t.destroy(),delete this._sprites[i])}else for(const t in this._sprites)this.removeSprites(t);return this}get isPlayable(){return this.isLoaded&&this.media&&this.media.isPlayable}stop(){if(!this.isPlayable)return this.autoPlay=!1,this._autoPlayOptions=null,this;this.isPlaying=!1;for(let i=this._instances.length-1;i>=0;i--)this._instances[i].stop();return this}play(i,t){let e;if(typeof i=="string"?e={sprite:i,loop:this.loop,complete:t}:typeof i=="function"?(e={},e.complete=i):e=i,e={complete:null,loaded:null,sprite:null,end:null,start:0,volume:1,speed:1,muted:!1,loop:!1,...e||{}},e.sprite){const r=e.sprite;console.assert(!!this._sprites[r],`Alias ${r} is not available`);const n=this._sprites[r];e.start=n.start+(e.start||0),e.end=n.end,e.speed=n.speed||1,e.loop=n.loop||e.loop,delete e.sprite}if(e.offset&&(e.start=e.offset),!this.isLoaded)return this._preloadQueue?new Promise(r=>{this._preloadQueue.push(()=>{r(this.play(e))})}):(this._preloadQueue=[],this.autoPlay=!0,this._autoPlayOptions=e,new Promise((r,n)=>{this._preload((a,h,o)=>{this._preloadQueue.forEach(l=>l()),this._preloadQueue=null,a?n(a):(e.loaded&&e.loaded(a,h,o),r(o))})}));(this.singleInstance||e.singleInstance)&&this._removeInstances();const s=this._createInstance();return this._instances.push(s),this.isPlaying=!0,s.once("end",()=>{e.complete&&e.complete(this),this._onComplete(s)}),s.once("stop",()=>{this._onComplete(s)}),s.play(e),s}refresh(){const i=this._instances.length;for(let t=0;t<i;t++)this._instances[t].refresh()}refreshPaused(){const i=this._instances.length;for(let t=0;t<i;t++)this._instances[t].refreshPaused()}get volume(){return this._volume}set volume(i){this._volume=i,this.refresh()}get muted(){return this._muted}set muted(i){this._muted=i,this.refresh()}get loop(){return this._loop}set loop(i){this._loop=i,this.refresh()}_preload(i){this.media.load(i)}get instances(){return this._instances}get sprites(){return this._sprites}get duration(){return this.media.duration}autoPlayStart(){let i;return this.autoPlay&&(i=this.play(this._autoPlayOptions)),i}_removeInstances(){for(let i=this._instances.length-1;i>=0;i--)this._poolInstance(this._instances[i]);this._instances.length=0}_onComplete(i){if(this._instances){const t=this._instances.indexOf(i);t>-1&&this._instances.splice(t,1),this.isPlaying=this._instances.length>0}this._poolInstance(i)}_createInstance(){if(Fn._pool.length>0){const i=Fn._pool.pop();return i.init(this.media),i}return this.media.create()}_poolInstance(i){i.destroy(),Fn._pool.indexOf(i)<0&&Fn._pool.push(i)}};let bl=Fn;bl._pool=[];class wI extends Gs{constructor(){super(...arguments),this.speed=1,this.muted=!1,this.volume=1,this.paused=!1}refresh(){this.emit("refresh")}refreshPaused(){this.emit("refreshPaused")}get filters(){return console.warn("HTML Audio does not support filters"),null}set filters(t){console.warn("HTML Audio does not support filters")}get audioContext(){return console.warn("HTML Audio does not support audioContext"),null}toggleMute(){return this.muted=!this.muted,this.refresh(),this.muted}togglePause(){return this.paused=!this.paused,this.refreshPaused(),this.paused}destroy(){this.removeAllListeners()}}class Bo extends H0{constructor(){const t=window,e=new Bo.AudioContext,s=e.createDynamicsCompressor(),r=e.createAnalyser();r.connect(s),s.connect(e.destination),super(r,s),this.autoPause=!0,this._ctx=e,this._offlineCtx=new Bo.OfflineAudioContext(1,2,t.OfflineAudioContext?Math.max(8e3,Math.min(96e3,e.sampleRate)):44100),this.compressor=s,this.analyser=r,this.events=new Gs,this.volume=1,this.speed=1,this.muted=!1,this.paused=!1,this._locked=e.state==="suspended"&&("ontouchstart"in globalThis||"onclick"in globalThis),this._locked&&(this._unlock(),this._unlock=this._unlock.bind(this),document.addEventListener("mousedown",this._unlock,!0),document.addEventListener("touchstart",this._unlock,!0),document.addEventListener("touchend",this._unlock,!0)),this.onFocus=this.onFocus.bind(this),this.onBlur=this.onBlur.bind(this),globalThis.addEventListener("focus",this.onFocus),globalThis.addEventListener("blur",this.onBlur)}onFocus(){if(!this.autoPause)return;const t=this._ctx.state;(t==="suspended"||t==="interrupted"||!this._locked)&&(this.paused=this._pausedOnBlur,this.refreshPaused())}onBlur(){this.autoPause&&(this._locked||(this._pausedOnBlur=this._paused,this.paused=!0,this.refreshPaused()))}_unlock(){this._locked&&(this.playEmptySound(),this._ctx.state==="running"&&(document.removeEventListener("mousedown",this._unlock,!0),document.removeEventListener("touchend",this._unlock,!0),document.removeEventListener("touchstart",this._unlock,!0),this._locked=!1))}playEmptySound(){const t=this._ctx.createBufferSource();t.buffer=this._ctx.createBuffer(1,1,22050),t.connect(this._ctx.destination),t.start(0,0,0),t.context.state==="suspended"&&t.context.resume()}static get AudioContext(){const t=window;return t.AudioContext||t.webkitAudioContext||null}static get OfflineAudioContext(){const t=window;return t.OfflineAudioContext||t.webkitOfflineAudioContext||null}destroy(){super.destroy();const t=this._ctx;typeof t.close<"u"&&t.close(),globalThis.removeEventListener("focus",this.onFocus),globalThis.removeEventListener("blur",this.onBlur),this.events.removeAllListeners(),this.analyser.disconnect(),this.compressor.disconnect(),this.analyser=null,this.compressor=null,this.events=null,this._offlineCtx=null,this._ctx=null}get audioContext(){return this._ctx}get offlineContext(){return this._offlineCtx}set paused(t){t&&this._ctx.state==="running"?this._ctx.suspend():!t&&this._ctx.state==="suspended"&&this._ctx.resume(),this._paused=t}get paused(){return this._paused}refresh(){this.events.emit("refresh")}refreshPaused(){this.events.emit("refreshPaused")}toggleMute(){return this.muted=!this.muted,this.refresh(),this.muted}togglePause(){return this.paused=!this.paused,this.refreshPaused(),this._paused}decode(t,e){const s=n=>{e(new Error((n==null?void 0:n.message)||"Unable to decode file"))},r=this._offlineCtx.decodeAudioData(t,n=>{e(null,n)},s);r&&r.catch(s)}}class EI{constructor(){this.init()}init(){return this.supported&&(this._webAudioContext=new Bo),this._htmlAudioContext=new wI,this._sounds={},this.useLegacy=!this.supported,this}get context(){return this._context}get filtersAll(){return this.useLegacy?[]:this._context.filters}set filtersAll(t){this.useLegacy||(this._context.filters=t)}get supported(){return Bo.AudioContext!==null}add(t,e){if(typeof t=="object"){const n={};for(const a in t){const h=this._getOptions(t[a],e);n[a]=this.add(a,h)}return n}if(console.assert(!this._sounds[t],`Sound with alias ${t} already exists.`),e instanceof bl)return this._sounds[t]=e,e;const s=this._getOptions(e),r=bl.from(s);return this._sounds[t]=r,r}_getOptions(t,e){let s;return typeof t=="string"?s={url:t}:Array.isArray(t)?s={url:t}:t instanceof ArrayBuffer||t instanceof AudioBuffer||t instanceof HTMLAudioElement?s={source:t}:s=t,s={...s,...e||{}},s}get useLegacy(){return this._useLegacy}set useLegacy(t){this._useLegacy=t,this._context=!t&&this.supported?this._webAudioContext:this._htmlAudioContext}get disableAutoPause(){return!this._webAudioContext.autoPause}set disableAutoPause(t){this._webAudioContext.autoPause=!t}remove(t){return this.exists(t,!0),this._sounds[t].destroy(),delete this._sounds[t],this}get volumeAll(){return this._context.volume}set volumeAll(t){this._context.volume=t,this._context.refresh()}get speedAll(){return this._context.speed}set speedAll(t){this._context.speed=t,this._context.refresh()}togglePauseAll(){return this._context.togglePause()}pauseAll(){return this._context.paused=!0,this._context.refreshPaused(),this}resumeAll(){return this._context.paused=!1,this._context.refreshPaused(),this}toggleMuteAll(){return this._context.toggleMute()}muteAll(){return this._context.muted=!0,this._context.refresh(),this}unmuteAll(){return this._context.muted=!1,this._context.refresh(),this}removeAll(){for(const t in this._sounds)this._sounds[t].destroy(),delete this._sounds[t];return this}stopAll(){for(const t in this._sounds)this._sounds[t].stop();return this}exists(t,e=!1){const s=!!this._sounds[t];return e&&console.assert(s,`No sound matching alias '${t}'.`),s}isPlaying(){for(const t in this._sounds)if(this._sounds[t].isPlaying)return!0;return!1}find(t){return this.exists(t,!0),this._sounds[t]}play(t,e){return this.find(t).play(e)}stop(t){return this.find(t).stop()}pause(t){return this.find(t).pause()}resume(t){return this.find(t).resume()}volume(t,e){const s=this.find(t);return e!==void 0&&(s.volume=e),s.volume}speed(t,e){const s=this.find(t);return e!==void 0&&(s.speed=e),s.speed}duration(t){return this.find(t).duration}close(){return this.removeAll(),this._sounds=null,this._webAudioContext&&(this._webAudioContext.destroy(),this._webAudioContext=null),this._htmlAudioContext&&(this._htmlAudioContext.destroy(),this._htmlAudioContext=null),this._context=null,this}}const j0=i=>{var e;const t=i.src;return((e=i==null?void 0:i.alias)==null?void 0:e[0])??bt.basename(t,bt.extname(t))},TI={extension:Y.Asset,detection:{test:async()=>!0,add:async i=>[...i,...xl.filter(t=>vl[t])],remove:async i=>i.filter(t=>i.includes(t))},loader:{extension:{type:[Y.LoadParser],priority:Ne.High},test(i){const t=bt.extname(i).slice(1);return!!vl[t]||_I.some(e=>i.startsWith(`data:${e}`))},async load(i,t){const e=await new Promise((s,r)=>bl.from({...t.data,url:i,preload:!0,loaded(n,a){var h,o;n?r(n):s(a),(o=(h=t.data)==null?void 0:h.loaded)==null||o.call(h,n,a)}}));return ko().add(j0(t),e),e},async unload(i,t){ko().remove(j0(t))}}};K.add(TI),fI(new EI);class AI{constructor(){this.effectEnabled=!0,this.musicEnabled=!0,this._isMusicPaused=!1,this._isBackground=!1,this._playingList=[],this._setPlayStatus=t=>{var e,s;t?!this._isMusicPaused&&((e=this._musicPlayer)==null||e.play()):(s=this._musicPlayer)==null||s.pause(),this._playingList.forEach(r=>{t?r.audio.play():r.audio.pause()})},document.addEventListener("visibilitychange",()=>{this._isBackground=document.hidden,this._setPlayStatus(!document.hidden)})}playEffect(t,e){return new Promise(s=>{const r=new Date().getTime(),n=Gr.get(t).url,a=new cd.Howl({src:n,mute:this._isBackground||!this.effectEnabled});if(a.play(),a.on("end",()=>{this._playingList=this._playingList.filter(h=>h.id!==r),s()}),e){const o=a.duration()-e;a.seek(o)}this._playingList.push({id:r,audio:a,url:n})})}async playMusic(t){const e=Gr.get(t).url;this._musicPlayer&&(xt.killTweensOf(this._musicPlayer),await xt.to(this._musicPlayer,{volume:0,duration:1,ease:"linear"}),this._musicPlayer.stop()),this._musicPlayer=new cd.Howl({src:e,loop:!0,volume:0,mute:this._isBackground||!this.musicEnabled}),this._musicPlayer.play(),this._isMusicPaused=!1,xt.killTweensOf(this._musicPlayer),xt.to(this._musicPlayer,{volume:1,duration:1,ease:"linear"})}pauseMusic(){var t;this._isMusicPaused=!0,(t=this._musicPlayer)==null||t.pause()}resumeMusic(){var t,e;this._isMusicPaused=!1,!((t=this._musicPlayer)!=null&&t.playing())&&((e=this._musicPlayer)==null||e.play())}stopEffect(t){const e=Gr.get(t).url;this._playingList.forEach(s=>{s.url===e&&s.audio.pause()}),this._playingList=this._playingList.filter(s=>s.url!==e)}setEffectEnabled(t){this.effectEnabled=t,this._setEffectMute(!t)}setMusicEnabled(t){this.musicEnabled=t,this._setMusicMute(!t)}_setMusicMute(t){var e;(e=this._musicPlayer)==null||e.mute(t||!this.musicEnabled)}_setEffectMute(t){this._playingList.forEach(e=>{e.audio.mute(t||!this.effectEnabled)})}}const SI=i=>{const{texture:t,dotWidth:e,width:s,height:r}=i;let n=[];Array.isArray(e)?n=e:n=[e,e,e,e];const a=new PT(t,n[0],n[1],n[2],n[3]);return a.width=s,a.height=r,a},CI=(i,t,e)=>{let s=!1;return i.cursor="pointer",i.eventMode="static",i.on(t,r=>{s||r.button!==2&&e(r)}),()=>{s=!0}},II=(i,t,e=0)=>parseFloat((Math.random()*(t-i)+i).toFixed(e)),PI=(i,t)=>{let e=0;const s=new Tt,r=n=>{e+=n*s.deltaMS;let a=0;Array.isArray(t)?a=II(t[0],t[1],2):a=t,e>=a&&(i(),e=0)};return s.add(r),s.start(),()=>{s.remove(r),s.stop()}},RI=(i,t,e)=>{const s=r=>{const n=t.getBounds().contains(r.clientX,r.clientY),a=i.getBounds().contains(r.clientX,r.clientY);!n&&!a&&i.visible&&(e(),window.removeEventListener("pointerdown",s))};return window.addEventListener("pointerdown",s),()=>{window.removeEventListener("pointerdown",s)}},MI=(i=1,t)=>new Promise(e=>{let s=0;const r=new Tt,n=()=>{s+=r.deltaMS,s>=i&&(t==null||t(),r.destroy(),e())};r.add(n),r.start()}),FI=(i,t)=>{let e;if(i==="brightness")e=new hn,e.brightness(t,!1);else if(i==="blur")e=new um;else if(i==="desaturate")e=new hn,e.desaturate();else if(i==="contrast")e=new hn,e.contrast(t,!1);else throw new Error("未知滤镜名称");return e.resolution=window.devicePixelRatio||1,e};var kI=`attribute vec2 aVertexPosition;
|
|
1190
1190
|
attribute vec2 aTextureCoord;
|
|
1191
1191
|
|
|
1192
1192
|
uniform mat3 projectionMatrix;
|