@drincs/pixi-vn 1.7.2 → 1.8.0

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/dist/sound.cjs CHANGED
@@ -1 +1 @@
1
- 'use strict';var core=require('@drincs/pixi-vn/core'),_=require('@drincs/pixi-vn/pixi.js'),sound=require('@pixi/sound');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var ___default=/*#__PURE__*/_interopDefault(_);var F=Object.defineProperty;var b=(r,e,t)=>e in r?F(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t;var y=(r,e,t)=>b(r,typeof e!="symbol"?e+"":e,t);var O="general";function A(r,e){return r===void 0&&e===void 0?1:e===void 0?r:r===void 0?e:r*e}var i=class{constructor(){}};y(i,"mediaInstances",new Map),y(i,"channels",new Map),y(i,"delayTimeoutInstances",[]);function T(r,e,t){return new Proxy(e,{get(s,n,a){switch(n){case "volume":case "paused":case "muted":{let l=i.mediaInstances.get(r);return l?l.options[n]:Reflect.get(s,n,a)}default:return Reflect.get(s,n,a)}},set(s,n,a,l){let o=i.mediaInstances.get(r);if(o){let f=a;switch(n){case "volume":o.options[n]=a,f=A(a,t.channelOptions.volume);break;case "muted":o.options[n]=a,t.channelOptions.muted&&(f=true);break;case "paused":o.options[n]=a,t.channelOptions.paused&&(f=true);break;case "loop":case "delay":case "end":case "filters":case "singleInstance":case "speed":case "sprite":case "start":o.options[n]=a;break;}return Reflect.set(s,n,f,l)}return Reflect.set(s,n,a,l)}})}var g=class{constructor(e,t={}){y(this,"alias",e);y(this,"channelOptions",t);y(this,"_transientInstances",new Set);}async play(e,t,s){let n,a;if(typeof t=="string"?(n=e,a=t):(n=e,a=e,s=t),i.mediaInstances.has(n)){let h=i.mediaInstances.get(n);h&&(h.instance.stop(),s={...h.options,...s});}let{paused:l,...o}=s||{},f=!!this.channelOptions.paused||!!l,p=T(n,await sound.sound.play(a,{...o??{},filters:[...this.channelOptions.filters||[],...o?.filters||[]],muted:!!this.channelOptions.muted||!!o?.muted,volume:A(o?.volume,this.channelOptions.volume)}),this);if(p.paused=f,s?.delay){p.paused=true;let h=setTimeout(()=>{p.paused=f,i.delayTimeoutInstances=i.delayTimeoutInstances.filter(m=>m[0]!==h);},s.delay*1e3);i.delayTimeoutInstances.push([h,n]);}return i.mediaInstances.set(n,{channelAlias:this.alias,soundAlias:a,instance:p,stepCounter:core.GameUnifier.stepCounter,options:{volume:s?.volume??1,muted:s?.muted??false,loop:s?.loop??false,...s??{},paused:f}}),p.on("end",()=>{i.mediaInstances.delete(n);}),p}async playTransient(e,t){let{paused:s,...n}=t||{},a=await sound.sound.play(e,{...n,filters:[...this.channelOptions.filters||[],...n?.filters||[]],muted:!!this.channelOptions.muted||!!n?.muted,volume:A(n?.volume,this.channelOptions.volume)}),l=!!s||!!this.channelOptions.paused;a.paused=l;let o;return t?.delay&&(a.paused=true,o=setTimeout(()=>{a.paused=l,o=void 0;},t.delay*1e3)),this._transientInstances.add(a),a.on("end",()=>{o!==void 0&&(clearTimeout(o),o=void 0),this._transientInstances.delete(a);}),a}stopTransientAll(){for(let e of this._transientInstances)e.stop();return this._transientInstances.clear(),this}updateMediaVolume(){for(let e of i.mediaInstances.values())if(e.channelAlias===this.alias){let t=e.options.volume??1;e.instance.volume=t;}}get volume(){return this.channelOptions.volume??1}set volume(e){this.channelOptions.volume=e,this.updateMediaVolume();}updateMediaMuted(){for(let e of i.mediaInstances.values())if(e.channelAlias===this.alias){let t=e.options.muted??false;e.instance.muted=t;}}get muted(){return this.channelOptions.muted??false}set muted(e){this.channelOptions.muted=e,this.updateMediaMuted();}toggleMuteAll(){return this.muted=!this.muted,this.muted}get mediaInstances(){return Array.from(i.mediaInstances.values()).reduce((e,t)=>(t.channelAlias===this.alias&&e.push(t.instance),e),[])}get background(){return this.channelOptions.background||false}stopAll(){let e=[];for(let[t,s]of i.mediaInstances.entries())s.channelAlias===this.alias&&(s.instance.stop(),e.push(t));return e.forEach(t=>{i.mediaInstances.delete(t);}),this}pauseAll(){for(let e of i.mediaInstances.values())e.channelAlias===this.alias&&!e.instance.paused&&(e.instance.paused=true);return this}resumeAll(){for(let e of i.mediaInstances.values())e.channelAlias===this.alias&&e.instance.paused&&(e.instance.paused=false);return this}updateMediaPaused(){for(let e of i.mediaInstances.values())if(e.channelAlias===this.alias){let t=e.options.paused??false;e.instance.paused=t;}}get paused(){return this.channelOptions.paused??false}set paused(e){this.channelOptions.paused=e,this.updateMediaPaused();}pauseUnsavedAll(){return this.paused=true,this}resumeUnsavedAll(){return this.paused=false,this}};var d;(n=>(n.log=(a,...l)=>console.log(`[Pixi\u2019VN] ${a}`,...l),n.warn=(a,...l)=>console.warn(`[Pixi\u2019VN] ${a}`,...l),n.error=(a,...l)=>console.error(`[Pixi\u2019VN] ${a}`,...l),n.info=(a,...l)=>console.info(`[Pixi\u2019VN] ${a}`,...l)))(d||(d={}));function S(r){let e=[];for(let t of r)t.type==="TelephoneFilter"?e.push(new sound.filters.TelephoneFilter):t.type==="StreamFilter"?e.push(new sound.filters.StreamFilter):t.type==="StereoFilter"?e.push(new sound.filters.StereoFilter(t.pan)):t.type==="ReverbFilter"?e.push(new sound.filters.ReverbFilter(t.seconds,t.decay,t.reverse)):t.type==="MonoFilter"?e.push(new sound.filters.MonoFilter):t.type==="EqualizerFilter"?e.push(new sound.filters.EqualizerFilter(t.f32,t.f64,t.f125,t.f250,t.f500,t.f1k,t.f2k,t.f4k,t.f8k,t.f16k)):t.type==="DistortionFilter"?e.push(new sound.filters.DistortionFilter(t.amount)):d.error("Unknown sound filter type");return e}function M(r){if(!r)return;let e=[];for(let t of r)t instanceof sound.filters.TelephoneFilter?e.push({type:"TelephoneFilter"}):t instanceof sound.filters.StreamFilter?e.push({type:"StreamFilter"}):t instanceof sound.filters.StereoFilter?e.push({type:"StereoFilter",pan:t.pan}):t instanceof sound.filters.ReverbFilter?e.push({type:"ReverbFilter",seconds:t.seconds,decay:t.decay,reverse:t.reverse}):t instanceof sound.filters.MonoFilter?e.push({type:"MonoFilter"}):t instanceof sound.filters.EqualizerFilter?e.push({type:"EqualizerFilter",f32:t.f32,f64:t.f64,f125:t.f125,f250:t.f250,f500:t.f500,f1k:t.f1k,f2k:t.f2k,f4k:t.f4k,f8k:t.f8k,f16k:t.f16k}):t instanceof sound.filters.DistortionFilter?e.push({type:"DistortionFilter",amount:t.amount}):d.error("Unknown sound filter type");return e}function C(r){try{if(typeof r>"u")return r;let e=JSON.stringify(r);return JSON.parse(e)}catch(e){throw d.error("Error creating exportable element",r,e),new core.PixiError("not_json_serializable","Error creating exportable element")}}var E=class{constructor(){y(this,"_defaultChannelAlias",O);}get context(){return sound.sound.context}get filtersAll(){return sound.sound.filtersAll}set filtersAll(e){sound.sound.filtersAll=e.filter(t=>!(t instanceof sound.filters.Filter));}get supported(){return sound.sound.supported}get defaultChannelAlias(){return this._defaultChannelAlias}set defaultChannelAlias(e){this._defaultChannelAlias=e;}add(e,t){return sound.sound.add(e,t)}async edit(e,t){let s=sound.sound.find(e);if(!s&&(await this.load(e),s=sound.sound.find(e),!s)){d.error(`Sound with alias ${e} not found after loading.`);return}s.options=t;}get useLegacy(){return sound.sound.useLegacy}set useLegacy(e){sound.sound.useLegacy=e;}get disableAutoPause(){return sound.sound.disableAutoPause}set disableAutoPause(e){sound.sound.disableAutoPause=e;}get volumeAll(){return sound.sound.volumeAll}set volumeAll(e){sound.sound.volumeAll=e;}get speedAll(){return sound.sound.speedAll}set speedAll(e){sound.sound.speedAll=e;}pauseAll(){for(let e of i.mediaInstances.values())e.instance.paused||(e.instance.paused=true);return this}resumeAll(){for(let e of i.mediaInstances.values())e.instance.paused&&(e.instance.paused=false);return this}toggleMuteAll(){return sound.sound.toggleMuteAll()}muteAll(){return sound.sound.muteAll(),this}unmuteAll(){return sound.sound.unmuteAll(),this}stopAll(){return i.mediaInstances.clear(),sound.sound.stopAll(),this}pauseUnsavedAll(e){if(e!==void 0)this.findChannel(e).pauseUnsavedAll();else for(let t of i.channels.values())t.pauseUnsavedAll();return this}resumeUnsavedAll(e){if(e!==void 0)this.findChannel(e).resumeUnsavedAll();else for(let t of i.channels.values())t.resumeUnsavedAll();return this}stopTransientAll(e){if(e!==void 0)this.findChannel(e).stopTransientAll();else for(let t of i.channels.values())t.stopTransientAll();return this}isPlaying(){return sound.sound.isPlaying()}async play(e,t,s){let n,a;typeof t=="string"?(n=e,a=t):(n=e,a=e,s=t),sound.sound.exists(a)||await this.load(a);let{channel:l=this.defaultChannelAlias,...o}=s??{};return await this.findChannel(l).play(n,a,o)}async playTransient(e,t){sound.sound.exists(e)||await this.load(e);let{channel:s=this.defaultChannelAlias,...n}=t??{};return await this.findChannel(s).playTransient(e,n)}find(e){return i.mediaInstances.get(e)?.instance}stop(e){let t=this.find(e);t?(t.stop(),i.mediaInstances.delete(e)):d.warn(`No media instance found with alias ${e} to stop.`);}pause(e){let t=this.find(e);if(!t){d.warn(`No media instance found with alias ${e} to pause.`);return}return t.paused=true,t}resume(e){let t=this.find(e);if(!t){d.warn(`No media instance found with alias ${e} to resume.`);return}return t.paused=false,t}duration(e){return sound.sound.duration(e)}async load(e){typeof e=="string"&&(e=[e]);let t=e.map(async s=>{let n=await ___default.default.Assets.load(s);return sound.sound.exists(s)||sound.sound.add(s,n),n});return await Promise.all(t)}backgroundLoad(e){let t=___default.default.Assets.backgroundLoad(e);return t.then(()=>{typeof e=="string"&&(e=[e]),e.forEach(s=>{let n=___default.default.Assets.get(s);sound.sound.exists(s)||sound.sound.add(s,n);});}),t}backgroundLoadBundle(e){let t=___default.default.Assets.backgroundLoadBundle(e);return t.then(async()=>{try{let s=await ___default.default.Assets.loadBundle(e);for(let n in s){let a=s[n];a instanceof sound.Sound&&(sound.sound.exists(n)||sound.sound.add(n,a));}}catch(s){d.error("Error loading sound bundle",s);}}),t}clear(){this.stopAll();}addChannel(e,t={}){if(typeof e!="string"){e.forEach(n=>{let a={...t,filters:t.filters?[...t.filters]:t.filters};this.addChannel(n,a);});return}if(i.channels.has(e)){d.warn(`Channel with alias ${e} already exists.`);return}let s=new g(e,t);return i.channels.set(e,s),s}findChannel(e){let t=i.channels.get(e);return t||this.addChannel(e)}get channels(){return Array.from(i.channels.values())}export(){let e=Array.from(i.mediaInstances.entries()).reduce((t,[s,n])=>(t[s]={channelAlias:n.channelAlias,soundAlias:n.soundAlias,stepCounter:n.stepCounter,options:{...n.options,filters:M(n.options.filters)}},t),{});return {mediaInstances:C(e),filters:C(M(this.filtersAll))}}async restore(e){try{if(Object.hasOwn(e,"soundsPlaying")){let t=e.soundsPlaying;if(t){let s=Object.keys(t).map(async n=>{await this.load(n),await this.play(n);});await Promise.all(s);}}if(Object.hasOwn(e,"mediaInstances")){let t=e.mediaInstances;if(t){let s=new Set,n=Object.values(t).map(async({soundAlias:l,channelAlias:o})=>(s.add(o),await this.load(l)));await Promise.all(n),this.channels.forEach(l=>{(!l.background||!s.has(l.alias))&&l.stopAll();});let a=Object.keys(t).map(async l=>{let o=t[l],f=this.findChannel(o.channelAlias),p=o.options.paused??o.paused??!1;if(!f.background)await f.play(l,o.soundAlias,{...o.options,paused:p,filters:S(o.options.filters||[])});else if(o.stepCounter===core.GameUnifier.stepCounter||!this.find(l))await f.play(l,o.soundAlias,{...o.options,paused:p,filters:S(o.options.filters||[])});else {let h=i.mediaInstances.get(l);if(!h){d.warn(`No media instance found with alias ${l} while restoring background state.`);return}let m=h.instance;m.paused!==p&&(m.paused=p),m.loop!==(o.options.loop||!1)&&(m.loop=o.options.loop||!1),m.volume!==(o.options.volume??1)&&(m.volume=o.options.volume??1),m.muted!==(o.options.muted||!1)&&(m.muted=o.options.muted||!1),m.speed!==(o.options.speed??1)&&(m.speed=o.options.speed??1),h.options={...o.options,paused:p,filters:S(o.options.filters||[])};}});await Promise.all(a);}}if(Object.hasOwn(e,"filters")){let t=e.filters;t&&(this.filtersAll=S(t));}}catch(t){d.error("Error importing data",t);}}};var k={DistortionFilter:sound.filters.DistortionFilter,EqualizerFilter:sound.filters.EqualizerFilter,MonoFilter:sound.filters.MonoFilter,ReverbFilter:sound.filters.ReverbFilter,StereoFilter:sound.filters.StereoFilter,StreamFilter:sound.filters.StreamFilter,TelephoneFilter:sound.filters.TelephoneFilter};var _e=new E;core.GameUnifier.addOnPreContinue(async()=>{try{i.delayTimeoutInstances.forEach(r=>{clearTimeout(r[0]);let e=i.mediaInstances.get(r[1]);e&&(e.instance.paused=!1);}),i.delayTimeoutInstances=[],i.channels.forEach(r=>{r.background||r.stopAll();});}catch{}});exports.SoundManagerStatic=i;exports.filters=k;exports.sound=_e;
1
+ 'use strict';var core=require('@drincs/pixi-vn/core'),kt=require('@drincs/pixi-vn/pixi.js'),j=require('tone');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var kt__default=/*#__PURE__*/_interopDefault(kt);var j__namespace=/*#__PURE__*/_interopNamespace(j);var Rt=Object.defineProperty;var Tt=r=>{throw TypeError(r)};var Nt=(r,t,e)=>t in r?Rt(r,t,{enumerable:true,configurable:true,writable:true,value:e}):r[t]=e;var m=(r,t,e)=>Nt(r,typeof t!="symbol"?t+"":t,e),Le=(r,t,e)=>t.has(r)||Tt("Cannot "+e);var i=(r,t,e)=>(Le(r,t,"read from private field"),e?e.call(r):t.get(r)),v=(r,t,e)=>t.has(r)?Tt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(r):t.set(r,e),c=(r,t,e,n)=>(Le(r,t,"write to private field"),t.set(r,e),e),d=(r,t,e)=>(Le(r,t,"access private method"),e);var xe=(r,t,e,n)=>({set _(s){c(r,t,s);},get _(){return i(r,t,n)}});var At="general";var Gt=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,_t=new Set,ze=typeof process=="object"&&process?process:{},Ct=(r,t,e,n)=>{typeof ze.emitWarning=="function"?ze.emitWarning(r,t,e,n):console.error(`[${e}] ${t}: ${r}`);},ke=globalThis.AbortController,Ft=globalThis.AbortSignal;if(typeof ke>"u"){Ft=class{constructor(){m(this,"onabort");m(this,"_onabort",[]);m(this,"reason");m(this,"aborted",false);}addEventListener(e,n){this._onabort.push(n);}},ke=class{constructor(){m(this,"signal",new Ft);t();}abort(e){if(!this.signal.aborted){this.signal.reason=e,this.signal.aborted=true;for(let n of this.signal._onabort)n(e);this.signal.onabort?.(e);}}};let r=ze.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{r&&(r=false,Ct("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",t));};}var Lt=r=>!_t.has(r);var se=r=>r&&r===Math.floor(r)&&r>0&&isFinite(r),Et=r=>se(r)?r<=Math.pow(2,8)?Uint8Array:r<=Math.pow(2,16)?Uint16Array:r<=Math.pow(2,32)?Uint32Array:r<=Number.MAX_SAFE_INTEGER?Ie:null:null,Ie=class extends Array{constructor(r){super(r),this.fill(0);}},te,fe,zt=(te=class{constructor(t,e){m(this,"heap");m(this,"length");if(!i(te,fe))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new e(t),this.length=0;}static create(t){let e=Et(t);if(!e)return [];c(te,fe,true);let n=new te(t,e);return c(te,fe,false),n}push(t){this.heap[this.length++]=t;}pop(){return this.heap[--this.length]}},fe=new WeakMap,v(te,fe,false),te),St,Ot,Y,z,B,he,K,ye,ge,$,E,H,C,F,f,N,q,D,P,X,x,Q,Z,U,W,J,le,G,ve,h,qe,ue,ie,Se,V,xt,de,be,Oe,ae,re,Ue,De,Me,A,We,Fe,oe,Ve,we,Pt=(we=class{constructor(t){v(this,h);v(this,Y);v(this,z);v(this,B);v(this,he);v(this,K);v(this,ye);v(this,ge);v(this,$);m(this,"ttl");m(this,"ttlResolution");m(this,"ttlAutopurge");m(this,"updateAgeOnGet");m(this,"updateAgeOnHas");m(this,"allowStale");m(this,"noDisposeOnSet");m(this,"noUpdateTTL");m(this,"maxEntrySize");m(this,"sizeCalculation");m(this,"noDeleteOnFetchRejection");m(this,"noDeleteOnStaleGet");m(this,"allowStaleOnFetchAbort");m(this,"allowStaleOnFetchRejection");m(this,"ignoreFetchAbort");v(this,E);v(this,H);v(this,C);v(this,F);v(this,f);v(this,N);v(this,q);v(this,D);v(this,P);v(this,X);v(this,x);v(this,Q);v(this,Z);v(this,U);v(this,W);v(this,J);v(this,le);v(this,G);v(this,ve);v(this,ue,()=>{});v(this,ie,()=>{});v(this,Se,()=>{});v(this,V,()=>false);v(this,de,t=>{});v(this,be,(t,e,n)=>{});v(this,Oe,(t,e,n,s)=>{if(n||s)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});m(this,St,"LRUCache");let{max:e=0,ttl:n,ttlResolution:s=1,ttlAutopurge:o,updateAgeOnGet:a,updateAgeOnHas:l,allowStale:u,dispose:g,onInsert:w,disposeAfter:b,noDisposeOnSet:M,noUpdateTTL:I,maxSize:ee=0,maxEntrySize:S=0,sizeCalculation:T,fetchMethod:y,memoMethod:k,noDeleteOnFetchRejection:L,noDeleteOnStaleGet:R,allowStaleOnFetchRejection:O,allowStaleOnFetchAbort:Ae,ignoreFetchAbort:ce,perf:pe}=t;if(pe!==void 0&&typeof pe?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(c(this,$,pe??Gt),e!==0&&!se(e))throw new TypeError("max option must be a nonnegative integer");let me=e?Et(e):Array;if(!me)throw new Error("invalid max value: "+e);if(c(this,Y,e),c(this,z,ee),this.maxEntrySize=S||i(this,z),this.sizeCalculation=T,this.sizeCalculation){if(!i(this,z)&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(k!==void 0&&typeof k!="function")throw new TypeError("memoMethod must be a function if defined");if(c(this,ge,k),y!==void 0&&typeof y!="function")throw new TypeError("fetchMethod must be a function if specified");if(c(this,ye,y),c(this,le,!!y),c(this,C,new Map),c(this,F,new Array(e).fill(void 0)),c(this,f,new Array(e).fill(void 0)),c(this,N,new me(e)),c(this,q,new me(e)),c(this,D,0),c(this,P,0),c(this,X,zt.create(e)),c(this,E,0),c(this,H,0),typeof g=="function"&&c(this,B,g),typeof w=="function"&&c(this,he,w),typeof b=="function"?(c(this,K,b),c(this,x,[])):(c(this,K,void 0),c(this,x,void 0)),c(this,J,!!i(this,B)),c(this,ve,!!i(this,he)),c(this,G,!!i(this,K)),this.noDisposeOnSet=!!M,this.noUpdateTTL=!!I,this.noDeleteOnFetchRejection=!!L,this.allowStaleOnFetchRejection=!!O,this.allowStaleOnFetchAbort=!!Ae,this.ignoreFetchAbort=!!ce,this.maxEntrySize!==0){if(i(this,z)!==0&&!se(i(this,z)))throw new TypeError("maxSize must be a positive integer if specified");if(!se(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");d(this,h,xt).call(this);}if(this.allowStale=!!u,this.noDeleteOnStaleGet=!!R,this.updateAgeOnGet=!!a,this.updateAgeOnHas=!!l,this.ttlResolution=se(s)||s===0?s:1,this.ttlAutopurge=!!o,this.ttl=n||0,this.ttl){if(!se(this.ttl))throw new TypeError("ttl must be a positive integer if specified");d(this,h,qe).call(this);}if(i(this,Y)===0&&this.ttl===0&&i(this,z)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!i(this,Y)&&!i(this,z)){let Ge="LRU_CACHE_UNBOUNDED";Lt(Ge)&&(_t.add(Ge),Ct("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Ge,we));}}get perf(){return i(this,$)}static unsafeExposeInternals(t){return {starts:i(t,Z),ttls:i(t,U),autopurgeTimers:i(t,W),sizes:i(t,Q),keyMap:i(t,C),keyList:i(t,F),valList:i(t,f),next:i(t,N),prev:i(t,q),get head(){return i(t,D)},get tail(){return i(t,P)},free:i(t,X),isBackgroundFetch:e=>{var n;return d(n=t,h,A).call(n,e)},backgroundFetch:(e,n,s,o)=>{var a;return d(a=t,h,Me).call(a,e,n,s,o)},moveToTail:e=>{var n;return d(n=t,h,Fe).call(n,e)},indexes:e=>{var n;return d(n=t,h,ae).call(n,e)},rindexes:e=>{var n;return d(n=t,h,re).call(n,e)},isStale:e=>{var n;return i(n=t,V).call(n,e)}}}get max(){return i(this,Y)}get maxSize(){return i(this,z)}get calculatedSize(){return i(this,H)}get size(){return i(this,E)}get fetchMethod(){return i(this,ye)}get memoMethod(){return i(this,ge)}get dispose(){return i(this,B)}get onInsert(){return i(this,he)}get disposeAfter(){return i(this,K)}getRemainingTTL(t){return i(this,C).has(t)?1/0:0}*entries(){for(let t of d(this,h,ae).call(this))i(this,f)[t]!==void 0&&i(this,F)[t]!==void 0&&!d(this,h,A).call(this,i(this,f)[t])&&(yield [i(this,F)[t],i(this,f)[t]]);}*rentries(){for(let t of d(this,h,re).call(this))i(this,f)[t]!==void 0&&i(this,F)[t]!==void 0&&!d(this,h,A).call(this,i(this,f)[t])&&(yield [i(this,F)[t],i(this,f)[t]]);}*keys(){for(let t of d(this,h,ae).call(this)){let e=i(this,F)[t];e!==void 0&&!d(this,h,A).call(this,i(this,f)[t])&&(yield e);}}*rkeys(){for(let t of d(this,h,re).call(this)){let e=i(this,F)[t];e!==void 0&&!d(this,h,A).call(this,i(this,f)[t])&&(yield e);}}*values(){for(let t of d(this,h,ae).call(this))i(this,f)[t]!==void 0&&!d(this,h,A).call(this,i(this,f)[t])&&(yield i(this,f)[t]);}*rvalues(){for(let t of d(this,h,re).call(this))i(this,f)[t]!==void 0&&!d(this,h,A).call(this,i(this,f)[t])&&(yield i(this,f)[t]);}[(Ot=Symbol.iterator,St=Symbol.toStringTag,Ot)](){return this.entries()}find(t,e={}){for(let n of d(this,h,ae).call(this)){let s=i(this,f)[n],o=d(this,h,A).call(this,s)?s.__staleWhileFetching:s;if(o!==void 0&&t(o,i(this,F)[n],this))return this.get(i(this,F)[n],e)}}forEach(t,e=this){for(let n of d(this,h,ae).call(this)){let s=i(this,f)[n],o=d(this,h,A).call(this,s)?s.__staleWhileFetching:s;o!==void 0&&t.call(e,o,i(this,F)[n],this);}}rforEach(t,e=this){for(let n of d(this,h,re).call(this)){let s=i(this,f)[n],o=d(this,h,A).call(this,s)?s.__staleWhileFetching:s;o!==void 0&&t.call(e,o,i(this,F)[n],this);}}purgeStale(){let t=false;for(let e of d(this,h,re).call(this,{allowStale:true}))i(this,V).call(this,e)&&(d(this,h,oe).call(this,i(this,F)[e],"expire"),t=true);return t}info(t){let e=i(this,C).get(t);if(e===void 0)return;let n=i(this,f)[e],s=d(this,h,A).call(this,n)?n.__staleWhileFetching:n;if(s===void 0)return;let o={value:s};if(i(this,U)&&i(this,Z)){let a=i(this,U)[e],l=i(this,Z)[e];if(a&&l){let u=a-(i(this,$).now()-l);o.ttl=u,o.start=Date.now();}}return i(this,Q)&&(o.size=i(this,Q)[e]),o}dump(){let t=[];for(let e of d(this,h,ae).call(this,{allowStale:true})){let n=i(this,F)[e],s=i(this,f)[e],o=d(this,h,A).call(this,s)?s.__staleWhileFetching:s;if(o===void 0||n===void 0)continue;let a={value:o};if(i(this,U)&&i(this,Z)){a.ttl=i(this,U)[e];let l=i(this,$).now()-i(this,Z)[e];a.start=Math.floor(Date.now()-l);}i(this,Q)&&(a.size=i(this,Q)[e]),t.unshift([n,a]);}return t}load(t){this.clear();for(let[e,n]of t){if(n.start){let s=Date.now()-n.start;n.start=i(this,$).now()-s;}this.set(e,n.value,n);}}set(t,e,n={}){var M,I,ee,S;if(e===void 0)return this.delete(t),this;let{ttl:s=this.ttl,start:o,noDisposeOnSet:a=this.noDisposeOnSet,sizeCalculation:l=this.sizeCalculation,status:u}=n,{noUpdateTTL:g=this.noUpdateTTL}=n,w=i(this,Oe).call(this,t,e,n.size||0,l);if(this.maxEntrySize&&w>this.maxEntrySize)return u&&(u.set="miss",u.maxEntrySizeExceeded=true),d(this,h,oe).call(this,t,"set"),this;let b=i(this,E)===0?void 0:i(this,C).get(t);if(b===void 0)b=i(this,E)===0?i(this,P):i(this,X).length!==0?i(this,X).pop():i(this,E)===i(this,Y)?d(this,h,De).call(this,false):i(this,E),i(this,F)[b]=t,i(this,f)[b]=e,i(this,C).set(t,b),i(this,N)[i(this,P)]=b,i(this,q)[b]=i(this,P),c(this,P,b),xe(this,E)._++,i(this,be).call(this,b,w,u),u&&(u.set="add"),g=false,i(this,ve)&&((M=i(this,he))==null||M.call(this,e,t,"add"));else {d(this,h,Fe).call(this,b);let T=i(this,f)[b];if(e!==T){if(i(this,le)&&d(this,h,A).call(this,T)){T.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:y}=T;y!==void 0&&!a&&(i(this,J)&&((I=i(this,B))==null||I.call(this,y,t,"set")),i(this,G)&&i(this,x)?.push([y,t,"set"]));}else a||(i(this,J)&&((ee=i(this,B))==null||ee.call(this,T,t,"set")),i(this,G)&&i(this,x)?.push([T,t,"set"]));if(i(this,de).call(this,b),i(this,be).call(this,b,w,u),i(this,f)[b]=e,u){u.set="replace";let y=T&&d(this,h,A).call(this,T)?T.__staleWhileFetching:T;y!==void 0&&(u.oldValue=y);}}else u&&(u.set="update");i(this,ve)&&this.onInsert?.(e,t,e===T?"update":"replace");}if(s!==0&&!i(this,U)&&d(this,h,qe).call(this),i(this,U)&&(g||i(this,Se).call(this,b,s,o),u&&i(this,ie).call(this,u,b)),!a&&i(this,G)&&i(this,x)){let T=i(this,x),y;for(;y=T?.shift();)(S=i(this,K))==null||S.call(this,...y);}return this}pop(){var t;try{for(;i(this,E);){let e=i(this,f)[i(this,D)];if(d(this,h,De).call(this,!0),d(this,h,A).call(this,e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(i(this,G)&&i(this,x)){let e=i(this,x),n;for(;n=e?.shift();)(t=i(this,K))==null||t.call(this,...n);}}}has(t,e={}){let{updateAgeOnHas:n=this.updateAgeOnHas,status:s}=e,o=i(this,C).get(t);if(o!==void 0){let a=i(this,f)[o];if(d(this,h,A).call(this,a)&&a.__staleWhileFetching===void 0)return false;if(i(this,V).call(this,o))s&&(s.has="stale",i(this,ie).call(this,s,o));else return n&&i(this,ue).call(this,o),s&&(s.has="hit",i(this,ie).call(this,s,o)),true}else s&&(s.has="miss");return false}peek(t,e={}){let{allowStale:n=this.allowStale}=e,s=i(this,C).get(t);if(s===void 0||!n&&i(this,V).call(this,s))return;let o=i(this,f)[s];return d(this,h,A).call(this,o)?o.__staleWhileFetching:o}async fetch(t,e={}){let{allowStale:n=this.allowStale,updateAgeOnGet:s=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:a=this.ttl,noDisposeOnSet:l=this.noDisposeOnSet,size:u=0,sizeCalculation:g=this.sizeCalculation,noUpdateTTL:w=this.noUpdateTTL,noDeleteOnFetchRejection:b=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:M=this.allowStaleOnFetchRejection,ignoreFetchAbort:I=this.ignoreFetchAbort,allowStaleOnFetchAbort:ee=this.allowStaleOnFetchAbort,context:S,forceRefresh:T=false,status:y,signal:k}=e;if(!i(this,le))return y&&(y.fetch="get"),this.get(t,{allowStale:n,updateAgeOnGet:s,noDeleteOnStaleGet:o,status:y});let L={allowStale:n,updateAgeOnGet:s,noDeleteOnStaleGet:o,ttl:a,noDisposeOnSet:l,size:u,sizeCalculation:g,noUpdateTTL:w,noDeleteOnFetchRejection:b,allowStaleOnFetchRejection:M,allowStaleOnFetchAbort:ee,ignoreFetchAbort:I,status:y,signal:k},R=i(this,C).get(t);if(R===void 0){y&&(y.fetch="miss");let O=d(this,h,Me).call(this,t,R,L,S);return O.__returned=O}else {let O=i(this,f)[R];if(d(this,h,A).call(this,O)){let me=n&&O.__staleWhileFetching!==void 0;return y&&(y.fetch="inflight",me&&(y.returnedStale=true)),me?O.__staleWhileFetching:O.__returned=O}let Ae=i(this,V).call(this,R);if(!T&&!Ae)return y&&(y.fetch="hit"),d(this,h,Fe).call(this,R),s&&i(this,ue).call(this,R),y&&i(this,ie).call(this,y,R),O;let ce=d(this,h,Me).call(this,t,R,L,S),pe=ce.__staleWhileFetching!==void 0&&n;return y&&(y.fetch=Ae?"stale":"refresh",pe&&Ae&&(y.returnedStale=true)),pe?ce.__staleWhileFetching:ce.__returned=ce}}async forceFetch(t,e={}){let n=await this.fetch(t,e);if(n===void 0)throw new Error("fetch() returned undefined");return n}memo(t,e={}){let n=i(this,ge);if(!n)throw new Error("no memoMethod provided to constructor");let{context:s,forceRefresh:o,...a}=e,l=this.get(t,a);if(!o&&l!==void 0)return l;let u=n(t,l,{options:a,context:s});return this.set(t,u,a),u}get(t,e={}){let{allowStale:n=this.allowStale,updateAgeOnGet:s=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:a}=e,l=i(this,C).get(t);if(l!==void 0){let u=i(this,f)[l],g=d(this,h,A).call(this,u);return a&&i(this,ie).call(this,a,l),i(this,V).call(this,l)?(a&&(a.get="stale"),g?(a&&n&&u.__staleWhileFetching!==void 0&&(a.returnedStale=true),n?u.__staleWhileFetching:void 0):(o||d(this,h,oe).call(this,t,"expire"),a&&n&&(a.returnedStale=true),n?u:void 0)):(a&&(a.get="hit"),g?u.__staleWhileFetching:(d(this,h,Fe).call(this,l),s&&i(this,ue).call(this,l),u))}else a&&(a.get="miss");}delete(t){return d(this,h,oe).call(this,t,"delete")}clear(){return d(this,h,Ve).call(this,"delete")}},Y=new WeakMap,z=new WeakMap,B=new WeakMap,he=new WeakMap,K=new WeakMap,ye=new WeakMap,ge=new WeakMap,$=new WeakMap,E=new WeakMap,H=new WeakMap,C=new WeakMap,F=new WeakMap,f=new WeakMap,N=new WeakMap,q=new WeakMap,D=new WeakMap,P=new WeakMap,X=new WeakMap,x=new WeakMap,Q=new WeakMap,Z=new WeakMap,U=new WeakMap,W=new WeakMap,J=new WeakMap,le=new WeakMap,G=new WeakMap,ve=new WeakMap,h=new WeakSet,qe=function(){let t=new Ie(i(this,Y)),e=new Ie(i(this,Y));c(this,U,t),c(this,Z,e);let n=this.ttlAutopurge?new Array(i(this,Y)):void 0;c(this,W,n),c(this,Se,(l,u,g=i(this,$).now())=>{e[l]=u!==0?g:0,t[l]=u,s(l,u);}),c(this,ue,l=>{e[l]=t[l]!==0?i(this,$).now():0,s(l,t[l]);});let s=this.ttlAutopurge?(l,u)=>{if(n?.[l]&&(clearTimeout(n[l]),n[l]=void 0),u&&u!==0&&n){let g=setTimeout(()=>{i(this,V).call(this,l)&&d(this,h,oe).call(this,i(this,F)[l],"expire");},u+1);g.unref&&g.unref(),n[l]=g;}}:()=>{};c(this,ie,(l,u)=>{if(t[u]){let g=t[u],w=e[u];if(!g||!w)return;l.ttl=g,l.start=w,l.now=o||a();let b=l.now-w;l.remainingTTL=g-b;}});let o=0,a=()=>{let l=i(this,$).now();if(this.ttlResolution>0){o=l;let u=setTimeout(()=>o=0,this.ttlResolution);u.unref&&u.unref();}return l};this.getRemainingTTL=l=>{let u=i(this,C).get(l);if(u===void 0)return 0;let g=t[u],w=e[u];if(!g||!w)return 1/0;let b=(o||a())-w;return g-b},c(this,V,l=>{let u=e[l],g=t[l];return !!g&&!!u&&(o||a())-u>g});},ue=new WeakMap,ie=new WeakMap,Se=new WeakMap,V=new WeakMap,xt=function(){let t=new Ie(i(this,Y));c(this,H,0),c(this,Q,t),c(this,de,e=>{c(this,H,i(this,H)-t[e]),t[e]=0;}),c(this,Oe,(e,n,s,o)=>{if(d(this,h,A).call(this,n))return 0;if(!se(s))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(s=o(n,e),!se(s))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return s}),c(this,be,(e,n,s)=>{if(t[e]=n,i(this,z)){let o=i(this,z)-t[e];for(;i(this,H)>o;)d(this,h,De).call(this,true);}c(this,H,i(this,H)+t[e]),s&&(s.entrySize=n,s.totalCalculatedSize=i(this,H));});},de=new WeakMap,be=new WeakMap,Oe=new WeakMap,ae=function*({allowStale:t=this.allowStale}={}){if(i(this,E))for(let e=i(this,P);!(!d(this,h,Ue).call(this,e)||((t||!i(this,V).call(this,e))&&(yield e),e===i(this,D)));)e=i(this,q)[e];},re=function*({allowStale:t=this.allowStale}={}){if(i(this,E))for(let e=i(this,D);!(!d(this,h,Ue).call(this,e)||((t||!i(this,V).call(this,e))&&(yield e),e===i(this,P)));)e=i(this,N)[e];},Ue=function(t){return t!==void 0&&i(this,C).get(i(this,F)[t])===t},De=function(t){var o;let e=i(this,D),n=i(this,F)[e],s=i(this,f)[e];return i(this,le)&&d(this,h,A).call(this,s)?s.__abortController.abort(new Error("evicted")):(i(this,J)||i(this,G))&&(i(this,J)&&((o=i(this,B))==null||o.call(this,s,n,"evict")),i(this,G)&&i(this,x)?.push([s,n,"evict"])),i(this,de).call(this,e),i(this,W)?.[e]&&(clearTimeout(i(this,W)[e]),i(this,W)[e]=void 0),t&&(i(this,F)[e]=void 0,i(this,f)[e]=void 0,i(this,X).push(e)),i(this,E)===1?(c(this,D,c(this,P,0)),i(this,X).length=0):c(this,D,i(this,N)[e]),i(this,C).delete(n),xe(this,E)._--,e},Me=function(t,e,n,s){let o=e===void 0?void 0:i(this,f)[e];if(d(this,h,A).call(this,o))return o;let a=new ke,{signal:l}=n;l?.addEventListener("abort",()=>a.abort(l.reason),{signal:a.signal});let u={signal:a.signal,options:n,context:s},g=(S,T=false)=>{let{aborted:y}=a.signal,k=n.ignoreFetchAbort&&S!==void 0,L=n.ignoreFetchAbort||!!(n.allowStaleOnFetchAbort&&S!==void 0);if(n.status&&(y&&!T?(n.status.fetchAborted=true,n.status.fetchError=a.signal.reason,k&&(n.status.fetchAbortIgnored=true)):n.status.fetchResolved=true),y&&!k&&!T)return b(a.signal.reason,L);let R=I,O=i(this,f)[e];return (O===I||k&&T&&O===void 0)&&(S===void 0?R.__staleWhileFetching!==void 0?i(this,f)[e]=R.__staleWhileFetching:d(this,h,oe).call(this,t,"fetch"):(n.status&&(n.status.fetchUpdated=true),this.set(t,S,u.options))),S},w=S=>(n.status&&(n.status.fetchRejected=true,n.status.fetchError=S),b(S,false)),b=(S,T)=>{let{aborted:y}=a.signal,k=y&&n.allowStaleOnFetchAbort,L=k||n.allowStaleOnFetchRejection,R=L||n.noDeleteOnFetchRejection,O=I;if(i(this,f)[e]===I&&(!R||!T&&O.__staleWhileFetching===void 0?d(this,h,oe).call(this,t,"fetch"):k||(i(this,f)[e]=O.__staleWhileFetching)),L)return n.status&&O.__staleWhileFetching!==void 0&&(n.status.returnedStale=true),O.__staleWhileFetching;if(O.__returned===O)throw S},M=(S,T)=>{var k;let y=(k=i(this,ye))==null?void 0:k.call(this,t,o,u);y&&y instanceof Promise&&y.then(L=>S(L===void 0?void 0:L),T),a.signal.addEventListener("abort",()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(S(void 0),n.allowStaleOnFetchAbort&&(S=L=>g(L,true)));});};n.status&&(n.status.fetchDispatched=true);let I=new Promise(M).then(g,w),ee=Object.assign(I,{__abortController:a,__staleWhileFetching:o,__returned:void 0});return e===void 0?(this.set(t,ee,{...u.options,status:void 0}),e=i(this,C).get(t)):i(this,f)[e]=ee,ee},A=function(t){if(!i(this,le))return false;let e=t;return !!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof ke},We=function(t,e){i(this,q)[e]=t,i(this,N)[t]=e;},Fe=function(t){t!==i(this,P)&&(t===i(this,D)?c(this,D,i(this,N)[t]):d(this,h,We).call(this,i(this,q)[t],i(this,N)[t]),d(this,h,We).call(this,i(this,P),t),c(this,P,t));},oe=function(t,e){var s,o;let n=false;if(i(this,E)!==0){let a=i(this,C).get(t);if(a!==void 0)if(i(this,W)?.[a]&&(clearTimeout(i(this,W)?.[a]),i(this,W)[a]=void 0),n=true,i(this,E)===1)d(this,h,Ve).call(this,e);else {i(this,de).call(this,a);let l=i(this,f)[a];if(d(this,h,A).call(this,l)?l.__abortController.abort(new Error("deleted")):(i(this,J)||i(this,G))&&(i(this,J)&&((s=i(this,B))==null||s.call(this,l,t,e)),i(this,G)&&i(this,x)?.push([l,t,e])),i(this,C).delete(t),i(this,F)[a]=void 0,i(this,f)[a]=void 0,a===i(this,P))c(this,P,i(this,q)[a]);else if(a===i(this,D))c(this,D,i(this,N)[a]);else {let u=i(this,q)[a];i(this,N)[u]=i(this,N)[a];let g=i(this,N)[a];i(this,q)[g]=i(this,q)[a];}xe(this,E)._--,i(this,X).push(a);}}if(i(this,G)&&i(this,x)?.length){let a=i(this,x),l;for(;l=a?.shift();)(o=i(this,K))==null||o.call(this,...l);}return n},Ve=function(t){var e,n;for(let s of d(this,h,re).call(this,{allowStale:true})){let o=i(this,f)[s];if(d(this,h,A).call(this,o))o.__abortController.abort(new Error("deleted"));else {let a=i(this,F)[s];i(this,J)&&((e=i(this,B))==null||e.call(this,o,a,t)),i(this,G)&&i(this,x)?.push([o,a,t]);}}if(i(this,C).clear(),i(this,f).fill(void 0),i(this,F).fill(void 0),i(this,U)&&i(this,Z)){i(this,U).fill(0),i(this,Z).fill(0);for(let s of i(this,W)??[])s!==void 0&&clearTimeout(s);i(this,W)?.fill(void 0);}if(i(this,Q)&&i(this,Q).fill(0),c(this,D,0),c(this,P,0),i(this,X).length=0,c(this,H,0),c(this,E,0),i(this,G)&&i(this,x)){let s=i(this,x),o;for(;o=s?.shift();)(n=i(this,K))==null||n.call(this,...o);}},we);var _e=class{constructor(t){m(this,"cache");m(this,"map",new Map);this.cache=new Pt({max:t.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){return this.cache.clear(),this.map.clear()}delete(t){let e=this.map.delete(t);return e&&this.cache.delete(t),e}get forEach(){return this.map.forEach}get(t){let e=this.cache.get(t);return e||this.map.get(t)}has(t){return this.map.has(t)}set(t,e){return this.map.set(t,e),this.cache.set(t,e),this}get size(){return this.map.size}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}};var Ye;(o=>(o.mediaInstances=new Map,o.channels=new Map,o.transients=new Set,o.systemPausedAliases=new Set,o.bufferRegistry=new _e({cacheSize:10})))(Ye||(Ye={}));var p=Ye;var _;(s=>(s.log=(o,...a)=>console.log(`[Pixi\u2019VN] ${o}`,...a),s.warn=(o,...a)=>console.warn(`[Pixi\u2019VN] ${o}`,...a),s.error=(o,...a)=>console.error(`[Pixi\u2019VN] ${o}`,...a),s.info=(o,...a)=>console.info(`[Pixi\u2019VN] ${o}`,...a)))(_||(_={}));function Re(r){return r.reduce((t,e)=>{switch(e.filterType){case "ReverbFilter":t.push(new j.Reverb({decay:e.decay,preDelay:e.preDelay,wet:e.wet}).toDestination());break;case "FeedbackDelayFilter":t.push(new j.FeedbackDelay({feedback:e.feedback,delayTime:e.delayTime,wet:e.wet}).toDestination());break;case "BitCrusherFilter":t.push(new j.BitCrusher({bits:e.bits}).toDestination());break;case "CompressorFilter":t.push(new j.Compressor({attack:e.attack,knee:e.knee,ratio:e.ratio,release:e.release,threshold:e.threshold}).toDestination());break;case "DelayFilter":t.push(new j.Delay({delayTime:e.delayTime,maxDelay:e.maxDelay}).toDestination());break;case "DistortionFilter":t.push(new j.Distortion({distortion:e.distortion,oversample:e.oversample,wet:e.wet}).toDestination());break;case "FeedbackCombFilterFilter":t.push(new j.FeedbackCombFilter({delayTime:e.delayTime,resonance:e.resonance}).toDestination());break;case "FreeverbFilter":t.push(new j.Freeverb({roomSize:e.roomSize,dampening:e.dampening,wet:e.wet}).toDestination());break;case "GateFilter":t.push(new j.Gate({threshold:e.threshold,smoothing:e.smoothing}).toDestination());break;case "GreaterThanFilter":t.push(new j.GreaterThan({value:e.value,convert:e.convert,maxValue:e.maxValue,minValue:e.minValue,units:e.units}).toDestination());break;case "GreaterThanZeroFilter":t.push(new j.GreaterThanZero);break;case "LimiterFilter":t.push(new j.Limiter({threshold:e.threshold}).toDestination());break;case "MidSideCompressorFilter":t.push(new j.MidSideCompressor({mid:e.mid,side:e.side}).toDestination());break;case "MultibandCompressorFilter":t.push(new j.MultibandCompressor({lowFrequency:e.lowFrequency,highFrequency:e.highFrequency,low:e.low,mid:e.mid,high:e.high}).toDestination());break;case "Panner3DFilter":t.push(new j.Panner3D({positionX:e.positionX,positionY:e.positionY,positionZ:e.positionZ,orientationX:e.orientationX,orientationY:e.orientationY,orientationZ:e.orientationZ,coneInnerAngle:e.coneInnerAngle,coneOuterAngle:e.coneOuterAngle,coneOuterGain:e.coneOuterGain,distanceModel:e.distanceModel,maxDistance:e.maxDistance,refDistance:e.refDistance,rolloffFactor:e.rolloffFactor,panningModel:e.panningModel}).toDestination());break;case "PhaserFilter":t.push(new j.Phaser({frequency:e.frequency,octaves:e.octaves,baseFrequency:e.baseFrequency,wet:e.wet,Q:e.Q,stages:e.stages}).toDestination());break;case "StereoWidenerFilter":t.push(new j.StereoWidener({width:e.width,wet:e.wet}).toDestination());break;case "PingPongDelayFilter":t.push(new j.PingPongDelay({wet:e.wet,delayTime:e.delayTime,feedback:e.feedback,maxDelay:e.maxDelay}).toDestination());break;case "AutoFilterFilter":t.push(new j.AutoFilter({frequency:e.frequency,depth:e.depth,baseFrequency:e.baseFrequency,octaves:e.octaves,filter:e.filter,wet:e.wet,type:e.type}).toDestination());break;case "BiquadFilterFilter":t.push(new j.BiquadFilter({frequency:e.frequency,detune:e.detune,Q:e.Q,type:e.type,gain:e.gain}).toDestination());break;case "OnePoleFilterFilter":t.push(new j.OnePoleFilter({type:e.type}).toDestination());break;case "CustomFilter":t.push(new j.Filter({frequency:e.frequency,Q:e.Q,type:e.type,detune:e.detune,gain:e.gain,rolloff:e.rolloff}).toDestination());break;case "ChorusFilter":t.push(new j.Chorus({frequency:e.frequency,delayTime:e.delayTime,depth:e.depth,type:e.type,spread:e.spread,feedback:e.feedback,wet:e.wet}).toDestination());break;case "TremoloFilter":t.push(new j.Tremolo({frequency:e.frequency,type:e.type,depth:e.depth,spread:e.spread,wet:e.wet}).toDestination());break;case "VibratoFilter":t.push(new j.Vibrato({maxDelay:e.maxDelay,frequency:e.frequency,depth:e.depth,type:e.type,wet:e.wet}).toDestination());break;case "AutoPannerFilter":t.push(new j.AutoPanner({frequency:e.frequency,type:e.type,depth:e.depth,channelCount:e.channelCount,wet:e.wet}).toDestination());break}return t},[])}function Dt(r){if(r)return Array.from(r).reduce((t,e)=>(e instanceof j.Reverb?t.push({filterType:"ReverbFilter",wet:e.wet.value,decay:j.Time(e.decay).toSeconds(),preDelay:j.Time(e.preDelay).toSeconds()}):e instanceof j.PingPongDelay?t.push({filterType:"PingPongDelayFilter",wet:e.wet.value,delayTime:e.delayTime.value,feedback:e.feedback.value}):e instanceof j.FeedbackDelay?t.push({filterType:"FeedbackDelayFilter",feedback:e.feedback.value,delayTime:e.delayTime.value,wet:e.wet.value}):e instanceof j.BitCrusher?t.push({filterType:"BitCrusherFilter",bits:e.bits.value,wet:e.wet.value}):e instanceof j.Compressor?t.push({filterType:"CompressorFilter",attack:e.attack.value,knee:e.knee.value,ratio:e.ratio.value,release:e.release.value,threshold:e.threshold.value}):e instanceof j.Delay?t.push({filterType:"DelayFilter",delayTime:e.delayTime.value,maxDelay:e.maxDelay}):e instanceof j.Distortion?t.push({filterType:"DistortionFilter",distortion:e.distortion,oversample:e.oversample,wet:e.wet.value}):e instanceof j.FeedbackCombFilter?t.push({filterType:"FeedbackCombFilterFilter",delayTime:e.delayTime.value,resonance:e.resonance.value}):e instanceof j.Freeverb?t.push({filterType:"FreeverbFilter",roomSize:e.roomSize.value,dampening:e.dampening,wet:e.wet.value}):e instanceof j.Gate?t.push({filterType:"GateFilter",threshold:e.threshold,smoothing:e.smoothing}):e instanceof j.GreaterThan?t.push({filterType:"GreaterThanFilter",value:e.comparator.value,convert:e.convert,maxValue:e.maxValue,minValue:e.minValue}):e instanceof j.GreaterThanZero?t.push({filterType:"GreaterThanZeroFilter"}):e instanceof j.Limiter?t.push({filterType:"LimiterFilter",threshold:e.threshold.value}):e instanceof j.MidSideCompressor?t.push({filterType:"MidSideCompressorFilter",mid:{attack:e.mid.attack.value,knee:e.mid.knee.value,ratio:e.mid.ratio.value,release:e.mid.release.value,threshold:e.mid.threshold.value},side:{attack:e.side.attack.value,knee:e.side.knee.value,ratio:e.side.ratio.value,release:e.side.release.value,threshold:e.side.threshold.value}}):e instanceof j.MultibandCompressor?t.push({filterType:"MultibandCompressorFilter",lowFrequency:e.lowFrequency.value,highFrequency:e.highFrequency.value,low:{attack:e.low.attack.value,knee:e.low.knee.value,ratio:e.low.ratio.value,release:e.low.release.value,threshold:e.low.threshold.value},mid:{attack:e.mid.attack.value,knee:e.mid.knee.value,ratio:e.mid.ratio.value,release:e.mid.release.value,threshold:e.mid.threshold.value},high:{attack:e.high.attack.value,knee:e.high.knee.value,ratio:e.high.ratio.value,release:e.high.release.value,threshold:e.high.threshold.value}}):e instanceof j.Panner3D?t.push({filterType:"Panner3DFilter",positionX:e.positionX.value,positionY:e.positionY.value,positionZ:e.positionZ.value,orientationX:e.orientationX.value,orientationY:e.orientationY.value,orientationZ:e.orientationZ.value,coneInnerAngle:e.coneInnerAngle,coneOuterAngle:e.coneOuterAngle,coneOuterGain:e.coneOuterGain,distanceModel:e.distanceModel,maxDistance:e.maxDistance,refDistance:e.refDistance,rolloffFactor:e.rolloffFactor,panningModel:e.panningModel}):e instanceof j.Phaser?t.push({filterType:"PhaserFilter",frequency:e.frequency.value,octaves:e.octaves,baseFrequency:e.baseFrequency,wet:e.wet.value,Q:e.Q.value}):e instanceof j.StereoWidener?t.push({filterType:"StereoWidenerFilter",width:e.width.value,wet:e.wet.value}):e instanceof j.AutoFilter?t.push({filterType:"AutoFilterFilter",type:e.type,frequency:e.frequency.value,depth:e.depth.value,baseFrequency:e.baseFrequency,octaves:e.octaves,filter:{Q:e.filter.Q.value,type:e.filter.type,rolloff:e.filter.rolloff},wet:e.wet.value}):e instanceof j.Chorus?t.push({filterType:"ChorusFilter",type:e.type,frequency:e.frequency.value,delayTime:e.delayTime,depth:e.depth,spread:e.spread,feedback:e.feedback.value,wet:e.wet.value}):e instanceof j.Tremolo?t.push({filterType:"TremoloFilter",type:e.type,frequency:e.frequency.value,depth:e.depth.value,spread:e.spread,wet:e.wet.value}):e instanceof j.Vibrato?t.push({filterType:"VibratoFilter",type:e.type,frequency:e.frequency.value,depth:e.depth.value,wet:e.wet.value}):e instanceof j.AutoPanner?t.push({filterType:"AutoPannerFilter",type:e.type,frequency:e.frequency.value,depth:e.depth.value,channelCount:e.channelCount,wet:e.wet.value}):e instanceof j.BiquadFilter?t.push({filterType:"BiquadFilterFilter",type:e.type,frequency:e.frequency.value,detune:e.detune.value,Q:e.Q.value,gain:e.gain.value}):e instanceof j.OnePoleFilter?t.push({filterType:"OnePoleFilterFilter",type:e.type}):e instanceof j.Filter?t.push({filterType:"CustomFilter",type:e.type,frequency:e.frequency.value,Q:e.Q.value,detune:e.detune.value,gain:e.gain.value,rolloff:e.rolloff}):_.warn(`Unsupported filter type for serialisation: ${e?.constructor?.name??e}, please report this to the developers if you encounter it.`),t),[])}function gt(r){return r instanceof j.Reverb||r instanceof j.FeedbackDelay||r instanceof j.PingPongDelay||r instanceof j.BitCrusher||r instanceof j.Compressor||r instanceof j.Delay||r instanceof j.Distortion||r instanceof j.FeedbackCombFilter||r instanceof j.Freeverb||r instanceof j.Gate||r instanceof j.GreaterThan||r instanceof j.GreaterThanZero||r instanceof j.Limiter||r instanceof j.MidSideCompressor||r instanceof j.MultibandCompressor||r instanceof j.Panner3D||r instanceof j.Phaser||r instanceof j.StereoWidener||r instanceof j.AutoFilter||r instanceof j.Chorus||r instanceof j.Vibrato||r instanceof j.Tremolo||r instanceof j.AutoPanner||r instanceof j.BiquadFilter||r instanceof j.OnePoleFilter||r instanceof j.Filter}function ne(r){return r<=0?-1/0:20*Math.log10(r)}function Te(r){return r<=-1/0?0:10**(r/20)}async function Ne(r){if(p.bufferRegistry.has(r))return;let t=r;try{let e=kt__default.default.Assets.resolver.resolve(r);e?.src&&(t=e.src);}catch{}try{let e=await j.ToneAudioBuffer.load(t),n=new j.ToneAudioBuffer(e);p.bufferRegistry.set(r,n);}catch(e){_.warn(`Failed to load audio buffer for "${r}" (url: "${t}"): ${e instanceof Error?e.message:e}`),p.bufferRegistry.set(r,new j.ToneAudioBuffer);}}var Ce=class extends j.Player{constructor(e,n,s,o,a={},l){super(a);m(this,"alias",e);m(this,"channelAlias",n);m(this,"soundAlias",s);m(this,"stepCounter",o);m(this,"delay",l);m(this,"options");m(this,"filters",new Set);m(this,"pausedAt");m(this,"playStartTime",j.now());this.options=a;}get memory(){let e=this.pausedAt?this.pausedAt-this.playStartTime:j.now()-this.playStartTime,n=this.paused;return n&&p.systemPausedAliases.has(this.alias)&&(n=false),{...this.options,fadeIn:this.fadeIn,loop:this.loop,loopEnd:this.loopEnd,loopStart:this.loopStart,mute:this.mute,playbackRate:this.playbackRate,reverse:this.reverse,volume:Te(this.volume.value),autostart:!this.paused,elapsed:e,paused:n,delay:this.delay}}set memory(e){this.paused=e.paused,this.loop!==(e.loop||false)&&(this.loop=e.loop||false),this.volume.value!==ne(e.volume??1)&&(this.volume.value=ne(e.volume??1)),this.mute!==(e.mute||false)&&(this.mute=e.mute||false),this.playbackRate!==(e.playbackRate??1)&&(this.playbackRate=e.playbackRate??1),this.reverse!==(e.reverse||false)&&(this.reverse=e.reverse||false),this.fadeIn!==(e.fadeIn||0)&&(this.fadeIn=e.fadeIn||0),this.loopStart!==(e.loopStart||0)&&(this.loopStart=e.loopStart||0),this.loopEnd!==(e.loopEnd||0)&&(this.loopEnd=e.loopEnd||0);}get paused(){return typeof this.pausedAt=="number"}set paused(e){let n=this.state;if(e)this.pausedAt=j.now(),n==="started"&&super.stop();else {let s;typeof this.pausedAt=="number"&&(s=this.pausedAt-this.playStartTime,this.pausedAt=void 0),n==="stopped"&&(this.delay?super.start(`+${this.delay}`,s):super.start(void 0,s));}}get muted(){return this.mute}set muted(e){this.mute=e;}get speed(){return this.playbackRate}set speed(e){this.playbackRate=e;}stop(e){return p.mediaInstances.delete(this.alias),super.stop(e)}chain(...e){return e.forEach(n=>{gt(n)&&(n.toDestination(),this.filters.add(n));}),super.chain(...e)}disconnect(e){return gt(e)&&(e.disconnect(),this.filters.delete(e)),super.disconnect(e)}};var Ee=class{constructor(t,e={}){m(this,"alias",t);m(this,"toneChannel");m(this,"background");this.background=e.background??false,this.toneChannel=new j.Channel({volume:ne(e.volume??1),mute:e.muted??false,pan:e.pan??0}).toDestination(),e.filters&&this.toneChannel.chain(...e.filters);}get volume(){return Te(this.toneChannel.volume.value)}set volume(t){this.toneChannel.volume.value=ne(t);}get volumeParam(){return this.toneChannel.volume}get pan(){return this.toneChannel.pan.value}set pan(t){this.toneChannel.pan.value=t;}get panParam(){return this.toneChannel.pan}get muted(){return this.toneChannel.mute}set muted(t){this.toneChannel.mute=t;}pauseAll(){for(let t of p.mediaInstances.values())t.channelAlias===this.alias&&!t.paused&&(t.paused=true);return this}resumeAll(){for(let t of p.mediaInstances.values())t.channelAlias===this.alias&&t.paused&&(t.paused=false);return this}chain(...t){return this.toneChannel.chain(...t),this}_createPlayer(t,e,n={}){let s=p.bufferRegistry.get(e);if(!s)throw new core.PixiError("unregistered_asset",`Sound buffer for alias "${e}" is not loaded. Call sound.load() first.`);let{delay:o,elapsed:a,filters:l=[],muted:u,autostart:g=true,speed:w,volume:b,...M}=n;u!==void 0&&(_.warn(`MediaInstance "${t}" is being created with muted=${u}. This will override the channel's muted state (${this.muted}).`),M.mute=u),w!==void 0&&(_.warn(`MediaInstance "${t}" is being created with speed=${w}. This will override the default playback speed of 1.`),M.playbackRate=w);let I=new Ce(t,this.alias,e,core.GameUnifier.stepCounter,{...M,volume:b!==void 0?ne(b):void 0,url:s},o).chain(...l,this.toneChannel);return g&&(o?I.start(`+${o}`,a):I.start(void 0,a)),I}async play(t,e,n){let s,o;if(typeof e=="string"?(s=t,o=e):(s=t,o=t,n=e),p.mediaInstances.has(s)){let l=p.mediaInstances.get(s);l&&(l.stop(),n={...l.memory,...n,filters:[...l.filters,...n?.filters||[]]});}await Ne(o);let a=this._createPlayer(s,o,n);return p.mediaInstances.set(s,a),a}toggleMuteAll(){return this.muted=!this.muted,this.muted}get mediaInstances(){return Array.from(p.mediaInstances.values()).reduce((t,e)=>(e.channelAlias===this.alias&&t.push(e),t),[])}stopAll(){let t=[];for(let[e,n]of p.mediaInstances.entries())n.channelAlias===this.alias&&(n.stop(),t.push(e));return t.forEach(e=>{p.mediaInstances.delete(e);}),this}};function Mt(r){try{if(typeof r>"u")return r;let t=JSON.stringify(r);return JSON.parse(t)}catch(t){throw _.error("Error creating exportable element",r,t),new core.PixiError("not_json_serializable","Error creating exportable element")}}var Pe=class{constructor(){m(this,"_speedAll",1);m(this,"_defaultChannelAlias",At);}get volumeAll(){return Te(j__namespace.getDestination().volume.value)}set volumeAll(t){j__namespace.getDestination().volume.value=ne(t);}get speedAll(){return this._speedAll}set speedAll(t){this._speedAll=t;for(let e of p.mediaInstances.values())e.speed=t;}get defaultChannelAlias(){return this._defaultChannelAlias}set defaultChannelAlias(t){this._defaultChannelAlias=t;}add(t,e){if(!p.bufferRegistry.has(t)){let n=new j__namespace.ToneAudioBuffer(e);p.bufferRegistry.set(t,n);}}pauseAll(){for(let t of p.mediaInstances.values())t.paused||(t.paused=true);return this}resumeAll(){for(let t of p.mediaInstances.values())t.paused&&(t.paused=false);return this}get muted(){return j__namespace.getDestination().mute}toggleMuteAll(){let t=!j__namespace.getDestination().mute;return j__namespace.getDestination().mute=t,t}muteAll(){return j__namespace.getDestination().mute=true,this}unmuteAll(){return j__namespace.getDestination().mute=false,this}stopAll(){for(let t of p.mediaInstances.values())t.stop();return p.mediaInstances.clear(),this}pauseUnsavedAll(t){for(let[e,n]of p.mediaInstances.entries())t&&n.channelAlias!==t||n.paused||(n.paused=true,p.systemPausedAliases.add(e));if(!t){for(let e of p.transients)e.stop();p.transients.clear();}return this}resumeUnsavedAll(t){let e=[];for(let n of p.systemPausedAliases){let s=p.mediaInstances.get(n);if(!s){e.push(n);continue}t&&s.channelAlias!==t||(s.paused=false,e.push(n));}for(let n of e)p.systemPausedAliases.delete(n);return this}stopTransientAll(){for(let t of p.transients)t.stop();return p.transients.clear(),this}async play(t,e,n){let s,o;typeof e=="string"?(s=t,o=e):(s=t,o=t,n=e),p.bufferRegistry.has(o)||await this.load(o);let{channel:a=this.defaultChannelAlias,...l}=n??{};return await this.findChannel(a).play(s,o,l)}async playTransient(t,e){p.bufferRegistry.has(t)||await this.load(t);let n=p.bufferRegistry.get(t);if(!n)throw new core.PixiError("unregistered_asset",`Sound buffer for alias "${t}" is not loaded. Call sound.load() first.`);let{autostart:s=true,...o}=e??{},a=new j__namespace.Player({...o,url:n}).toDestination();return s&&a.start(),p.transients.add(a),a.onstop=()=>{a.dispose(),p.transients.delete(a);},a}find(t){return p.mediaInstances.get(t)}stop(t){let e=this.find(t);e?(e.stop(),p.mediaInstances.delete(t)):_.warn(`No media instance found with alias ${t} to stop.`);}pause(t){let e=this.find(t);if(!e){_.warn(`No media instance found with alias ${t} to pause.`);return}return e.paused=true,e}resume(t){let e=this.find(t);if(!e){_.warn(`No media instance found with alias ${t} to resume.`);return}return e.paused=false,e}duration(t){return p.bufferRegistry.get(t)?.duration??0}async load(...t){let e=t.map(Ne);await Promise.all(e);}backgroundLoad(...t){return this.load(...t).catch(e=>{_.error("Error background-loading sound",e);})}backgroundLoadBundle(t){let e=kt__default.default.Assets.backgroundLoadBundle(t);return e.then(async()=>{try{let n=await kt__default.default.Assets.loadBundle(t),s=[];for(let o in n)p.bufferRegistry.has(o)||s.push(this.load(o));await Promise.all(s);}catch(n){_.error("Error loading sound bundle",n);}}).catch(n=>{_.error("Error background-loading sound bundle",n);}),e}clear(){this.stopAll();}addChannel(t,e={}){if(typeof t!="string"){t.forEach(s=>{let o={...e,filters:e.filters?[...e.filters]:e.filters};this.addChannel(s,o);});return}if(p.channels.has(t)){_.warn(`Channel with alias ${t} already exists.`);return}let n=new Ee(t,e);return p.channels.set(t,n),n}findChannel(t){let e=p.channels.get(t);return e||this.addChannel(t)}get channels(){return Array.from(p.channels.values())}export(){let t=Array.from(p.mediaInstances.entries()).reduce((e,[n,s])=>(e[n]={channelAlias:s.channelAlias,soundAlias:s.soundAlias,stepCounter:s.stepCounter,paused:s.paused,options:{...s.memory,filters:Dt(s.filters)}},e),{});return {mediaInstances:Mt(t)}}async restore(t){try{if(Object.hasOwn(t,"soundsPlaying")){let e=t.soundsPlaying;if(e){let n=Object.keys(e).map(async s=>{await this.load(s),await this.play(s);});await Promise.all(n);}}if(Object.hasOwn(t,"mediaInstances")){let e=t.mediaInstances;if(e){let n=new Set,s=Object.values(e).map(async({soundAlias:a,channelAlias:l})=>(n.add(l),await this.load(a)));await Promise.all(s),this.channels.forEach(a=>{(!a.background||!n.has(a.alias))&&a.stopAll();});let o=Object.keys(e).map(async a=>{let l=e[a],u=this.findChannel(l.channelAlias),g=l.options.paused??l.paused??!1;if(u.background)if(l.stepCounter===core.GameUnifier.stepCounter||!this.find(a)){let w=await u.play(a,l.soundAlias,{...l.options,autostart:!g,filters:Re(l.options.filters||[]),delay:l.options.delay});w.paused=g;}else {let w=p.mediaInstances.get(a);if(!w){_.warn(`No media instance found with alias ${a} while restoring background state.`);return}w.memory={...l.options,paused:g},[...w.filters].forEach(M=>{w.disconnect(M),M.dispose();}),w.chain(...Re(l.options.filters||[]));}else {let w=await u.play(a,l.soundAlias,{...l.options,autostart:!g,filters:Re(l.options.filters||[]),delay:l.options.delay});w.paused=g;}});await Promise.all(o);}}}catch(e){_.error("Error importing data",e);}}};var wt=new Pe;core.GameUnifier.addOnPreContinue(async()=>{try{p.channels.forEach(r=>{r.background||r.stopAll();});}catch{}});if(typeof document<"u"){let r=false;document.addEventListener("visibilitychange",()=>{document.hidden?wt.muted||(wt.muteAll(),r=true):r&&(wt.unmuteAll(),r=false);});}exports.SoundRegistry=p;exports.sound=wt;