@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.mjs CHANGED
@@ -1 +1 @@
1
- import {i as i$1}from'./chunk-IWAXXFXE.mjs';import {d,j,k}from'./chunk-HNGW4ITF.mjs';import {GameUnifier}from'@drincs/pixi-vn/core';import M from'@drincs/pixi-vn/pixi.js';import {filters,sound,Sound}from'@pixi/sound';function g(u,e){return u===void 0&&e===void 0?1:e===void 0?u:u===void 0?e:u*e}var i=class{constructor(){}};d(i,"mediaInstances",new Map),d(i,"channels",new Map),d(i,"delayTimeoutInstances",[]);function P(u,e,t){return new Proxy(e,{get(n,s,o){switch(s){case "volume":case "paused":case "muted":{let l=i.mediaInstances.get(u);return l?l.options[s]:Reflect.get(n,s,o)}default:return Reflect.get(n,s,o)}},set(n,s,o,l){let a=i.mediaInstances.get(u);if(a){let f=o;switch(s){case "volume":a.options[s]=o,f=g(o,t.channelOptions.volume);break;case "muted":a.options[s]=o,t.channelOptions.muted&&(f=true);break;case "paused":a.options[s]=o,t.channelOptions.paused&&(f=true);break;case "loop":case "delay":case "end":case "filters":case "singleInstance":case "speed":case "sprite":case "start":a.options[s]=o;break;}return Reflect.set(n,s,f,l)}return Reflect.set(n,s,o,l)}})}var A=class{constructor(e,t={}){d(this,"alias",e);d(this,"channelOptions",t);d(this,"_transientInstances",new Set);}async play(e,t,n){let s,o;if(typeof t=="string"?(s=e,o=t):(s=e,o=e,n=t),i.mediaInstances.has(s)){let h=i.mediaInstances.get(s);h&&(h.instance.stop(),n={...h.options,...n});}let{paused:l,...a}=n||{},f=!!this.channelOptions.paused||!!l,c=P(s,await sound.play(o,{...a??{},filters:[...this.channelOptions.filters||[],...a?.filters||[]],muted:!!this.channelOptions.muted||!!a?.muted,volume:g(a?.volume,this.channelOptions.volume)}),this);if(c.paused=f,n?.delay){c.paused=true;let h=setTimeout(()=>{c.paused=f,i.delayTimeoutInstances=i.delayTimeoutInstances.filter(p=>p[0]!==h);},n.delay*1e3);i.delayTimeoutInstances.push([h,s]);}return i.mediaInstances.set(s,{channelAlias:this.alias,soundAlias:o,instance:c,stepCounter:GameUnifier.stepCounter,options:{volume:n?.volume??1,muted:n?.muted??false,loop:n?.loop??false,...n??{},paused:f}}),c.on("end",()=>{i.mediaInstances.delete(s);}),c}async playTransient(e,t){let{paused:n,...s}=t||{},o=await sound.play(e,{...s,filters:[...this.channelOptions.filters||[],...s?.filters||[]],muted:!!this.channelOptions.muted||!!s?.muted,volume:g(s?.volume,this.channelOptions.volume)}),l=!!n||!!this.channelOptions.paused;o.paused=l;let a;return t?.delay&&(o.paused=true,a=setTimeout(()=>{o.paused=l,a=void 0;},t.delay*1e3)),this._transientInstances.add(o),o.on("end",()=>{a!==void 0&&(clearTimeout(a),a=void 0),this._transientInstances.delete(o);}),o}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,n]of i.mediaInstances.entries())n.channelAlias===this.alias&&(n.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}};function S(u){let e=[];for(let t of u)t.type==="TelephoneFilter"?e.push(new filters.TelephoneFilter):t.type==="StreamFilter"?e.push(new filters.StreamFilter):t.type==="StereoFilter"?e.push(new filters.StereoFilter(t.pan)):t.type==="ReverbFilter"?e.push(new filters.ReverbFilter(t.seconds,t.decay,t.reverse)):t.type==="MonoFilter"?e.push(new filters.MonoFilter):t.type==="EqualizerFilter"?e.push(new 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 filters.DistortionFilter(t.amount)):j.error("Unknown sound filter type");return e}function b(u){if(!u)return;let e=[];for(let t of u)t instanceof filters.TelephoneFilter?e.push({type:"TelephoneFilter"}):t instanceof filters.StreamFilter?e.push({type:"StreamFilter"}):t instanceof filters.StereoFilter?e.push({type:"StereoFilter",pan:t.pan}):t instanceof filters.ReverbFilter?e.push({type:"ReverbFilter",seconds:t.seconds,decay:t.decay,reverse:t.reverse}):t instanceof filters.MonoFilter?e.push({type:"MonoFilter"}):t instanceof 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 filters.DistortionFilter?e.push({type:"DistortionFilter",amount:t.amount}):j.error("Unknown sound filter type");return e}var F=class{constructor(){d(this,"_defaultChannelAlias",i$1);}get context(){return sound.context}get filtersAll(){return sound.filtersAll}set filtersAll(e){sound.filtersAll=e.filter(t=>!(t instanceof filters.Filter));}get supported(){return sound.supported}get defaultChannelAlias(){return this._defaultChannelAlias}set defaultChannelAlias(e){this._defaultChannelAlias=e;}add(e,t){return sound.add(e,t)}async edit(e,t){let n=sound.find(e);if(!n&&(await this.load(e),n=sound.find(e),!n)){j.error(`Sound with alias ${e} not found after loading.`);return}n.options=t;}get useLegacy(){return sound.useLegacy}set useLegacy(e){sound.useLegacy=e;}get disableAutoPause(){return sound.disableAutoPause}set disableAutoPause(e){sound.disableAutoPause=e;}get volumeAll(){return sound.volumeAll}set volumeAll(e){sound.volumeAll=e;}get speedAll(){return sound.speedAll}set speedAll(e){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.toggleMuteAll()}muteAll(){return sound.muteAll(),this}unmuteAll(){return sound.unmuteAll(),this}stopAll(){return i.mediaInstances.clear(),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.isPlaying()}async play(e,t,n){let s,o;typeof t=="string"?(s=e,o=t):(s=e,o=e,n=t),sound.exists(o)||await this.load(o);let{channel:l=this.defaultChannelAlias,...a}=n??{};return await this.findChannel(l).play(s,o,a)}async playTransient(e,t){sound.exists(e)||await this.load(e);let{channel:n=this.defaultChannelAlias,...s}=t??{};return await this.findChannel(n).playTransient(e,s)}find(e){return i.mediaInstances.get(e)?.instance}stop(e){let t=this.find(e);t?(t.stop(),i.mediaInstances.delete(e)):j.warn(`No media instance found with alias ${e} to stop.`);}pause(e){let t=this.find(e);if(!t){j.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){j.warn(`No media instance found with alias ${e} to resume.`);return}return t.paused=false,t}duration(e){return sound.duration(e)}async load(e){typeof e=="string"&&(e=[e]);let t=e.map(async n=>{let s=await M.Assets.load(n);return sound.exists(n)||sound.add(n,s),s});return await Promise.all(t)}backgroundLoad(e){let t=M.Assets.backgroundLoad(e);return t.then(()=>{typeof e=="string"&&(e=[e]),e.forEach(n=>{let s=M.Assets.get(n);sound.exists(n)||sound.add(n,s);});}),t}backgroundLoadBundle(e){let t=M.Assets.backgroundLoadBundle(e);return t.then(async()=>{try{let n=await M.Assets.loadBundle(e);for(let s in n){let o=n[s];o instanceof Sound&&(sound.exists(s)||sound.add(s,o));}}catch(n){j.error("Error loading sound bundle",n);}}),t}clear(){this.stopAll();}addChannel(e,t={}){if(typeof e!="string"){e.forEach(s=>{let o={...t,filters:t.filters?[...t.filters]:t.filters};this.addChannel(s,o);});return}if(i.channels.has(e)){j.warn(`Channel with alias ${e} already exists.`);return}let n=new A(e,t);return i.channels.set(e,n),n}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,[n,s])=>(t[n]={channelAlias:s.channelAlias,soundAlias:s.soundAlias,stepCounter:s.stepCounter,options:{...s.options,filters:b(s.options.filters)}},t),{});return {mediaInstances:k(e),filters:k(b(this.filtersAll))}}async restore(e){try{if(Object.hasOwn(e,"soundsPlaying")){let t=e.soundsPlaying;if(t){let n=Object.keys(t).map(async s=>{await this.load(s),await this.play(s);});await Promise.all(n);}}if(Object.hasOwn(e,"mediaInstances")){let t=e.mediaInstances;if(t){let n=new Set,s=Object.values(t).map(async({soundAlias:l,channelAlias:a})=>(n.add(a),await this.load(l)));await Promise.all(s),this.channels.forEach(l=>{(!l.background||!n.has(l.alias))&&l.stopAll();});let o=Object.keys(t).map(async l=>{let a=t[l],f=this.findChannel(a.channelAlias),c=a.options.paused??a.paused??!1;if(!f.background)await f.play(l,a.soundAlias,{...a.options,paused:c,filters:S(a.options.filters||[])});else if(a.stepCounter===GameUnifier.stepCounter||!this.find(l))await f.play(l,a.soundAlias,{...a.options,paused:c,filters:S(a.options.filters||[])});else {let h=i.mediaInstances.get(l);if(!h){j.warn(`No media instance found with alias ${l} while restoring background state.`);return}let p=h.instance;p.paused!==c&&(p.paused=c),p.loop!==(a.options.loop||!1)&&(p.loop=a.options.loop||!1),p.volume!==(a.options.volume??1)&&(p.volume=a.options.volume??1),p.muted!==(a.options.muted||!1)&&(p.muted=a.options.muted||!1),p.speed!==(a.options.speed??1)&&(p.speed=a.options.speed??1),h.options={...a.options,paused:c,filters:S(a.options.filters||[])};}});await Promise.all(o);}}if(Object.hasOwn(e,"filters")){let t=e.filters;t&&(this.filtersAll=S(t));}}catch(t){j.error("Error importing data",t);}}};var E={DistortionFilter:filters.DistortionFilter,EqualizerFilter:filters.EqualizerFilter,MonoFilter:filters.MonoFilter,ReverbFilter:filters.ReverbFilter,StereoFilter:filters.StereoFilter,StreamFilter:filters.StreamFilter,TelephoneFilter:filters.TelephoneFilter};var ce=new F;GameUnifier.addOnPreContinue(async()=>{try{i.delayTimeoutInstances.forEach(u=>{clearTimeout(u[0]);let e=i.mediaInstances.get(u[1]);e&&(e.instance.paused=!1);}),i.delayTimeoutInstances=[],i.channels.forEach(u=>{u.background||u.stopAll();});}catch{}});export{i as SoundManagerStatic,E as filters,ce as sound};
1
+ import {i as i$1}from'./chunk-IWAXXFXE.mjs';import {e,d,f,g as g$1}from'./chunk-6HI66YQL.mjs';import {GameUnifier,PixiError}from'@drincs/pixi-vn/core';import se from'@drincs/pixi-vn/pixi.js';import*as c from'tone';import {ToneAudioBuffer,Channel,Reverb,Time,PingPongDelay,FeedbackDelay,BitCrusher,Compressor,Delay,Distortion,FeedbackCombFilter,Freeverb,Gate,GreaterThan,GreaterThanZero,Limiter,MidSideCompressor,MultibandCompressor,Panner3D,Phaser,StereoWidener,AutoFilter,Chorus,Tremolo,Vibrato,AutoPanner,BiquadFilter,OnePoleFilter,Filter,Player,now}from'tone';var C;(o=>(o.mediaInstances=new Map,o.channels=new Map,o.transients=new Set,o.systemPausedAliases=new Set,o.bufferRegistry=new e({cacheSize:10})))(C||(C={}));var i=C;function w(a){return a.reduce((t,e)=>{switch(e.filterType){case "ReverbFilter":t.push(new Reverb({decay:e.decay,preDelay:e.preDelay,wet:e.wet}).toDestination());break;case "FeedbackDelayFilter":t.push(new FeedbackDelay({feedback:e.feedback,delayTime:e.delayTime,wet:e.wet}).toDestination());break;case "BitCrusherFilter":t.push(new BitCrusher({bits:e.bits}).toDestination());break;case "CompressorFilter":t.push(new Compressor({attack:e.attack,knee:e.knee,ratio:e.ratio,release:e.release,threshold:e.threshold}).toDestination());break;case "DelayFilter":t.push(new Delay({delayTime:e.delayTime,maxDelay:e.maxDelay}).toDestination());break;case "DistortionFilter":t.push(new Distortion({distortion:e.distortion,oversample:e.oversample,wet:e.wet}).toDestination());break;case "FeedbackCombFilterFilter":t.push(new FeedbackCombFilter({delayTime:e.delayTime,resonance:e.resonance}).toDestination());break;case "FreeverbFilter":t.push(new Freeverb({roomSize:e.roomSize,dampening:e.dampening,wet:e.wet}).toDestination());break;case "GateFilter":t.push(new Gate({threshold:e.threshold,smoothing:e.smoothing}).toDestination());break;case "GreaterThanFilter":t.push(new GreaterThan({value:e.value,convert:e.convert,maxValue:e.maxValue,minValue:e.minValue,units:e.units}).toDestination());break;case "GreaterThanZeroFilter":t.push(new GreaterThanZero);break;case "LimiterFilter":t.push(new Limiter({threshold:e.threshold}).toDestination());break;case "MidSideCompressorFilter":t.push(new MidSideCompressor({mid:e.mid,side:e.side}).toDestination());break;case "MultibandCompressorFilter":t.push(new MultibandCompressor({lowFrequency:e.lowFrequency,highFrequency:e.highFrequency,low:e.low,mid:e.mid,high:e.high}).toDestination());break;case "Panner3DFilter":t.push(new 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 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 StereoWidener({width:e.width,wet:e.wet}).toDestination());break;case "PingPongDelayFilter":t.push(new PingPongDelay({wet:e.wet,delayTime:e.delayTime,feedback:e.feedback,maxDelay:e.maxDelay}).toDestination());break;case "AutoFilterFilter":t.push(new 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 BiquadFilter({frequency:e.frequency,detune:e.detune,Q:e.Q,type:e.type,gain:e.gain}).toDestination());break;case "OnePoleFilterFilter":t.push(new OnePoleFilter({type:e.type}).toDestination());break;case "CustomFilter":t.push(new 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 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 Tremolo({frequency:e.frequency,type:e.type,depth:e.depth,spread:e.spread,wet:e.wet}).toDestination());break;case "VibratoFilter":t.push(new Vibrato({maxDelay:e.maxDelay,frequency:e.frequency,depth:e.depth,type:e.type,wet:e.wet}).toDestination());break;case "AutoPannerFilter":t.push(new AutoPanner({frequency:e.frequency,type:e.type,depth:e.depth,channelCount:e.channelCount,wet:e.wet}).toDestination());break}return t},[])}function oe(a){if(a)return Array.from(a).reduce((t,e)=>(e instanceof Reverb?t.push({filterType:"ReverbFilter",wet:e.wet.value,decay:Time(e.decay).toSeconds(),preDelay:Time(e.preDelay).toSeconds()}):e instanceof PingPongDelay?t.push({filterType:"PingPongDelayFilter",wet:e.wet.value,delayTime:e.delayTime.value,feedback:e.feedback.value}):e instanceof FeedbackDelay?t.push({filterType:"FeedbackDelayFilter",feedback:e.feedback.value,delayTime:e.delayTime.value,wet:e.wet.value}):e instanceof BitCrusher?t.push({filterType:"BitCrusherFilter",bits:e.bits.value,wet:e.wet.value}):e instanceof 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 Delay?t.push({filterType:"DelayFilter",delayTime:e.delayTime.value,maxDelay:e.maxDelay}):e instanceof Distortion?t.push({filterType:"DistortionFilter",distortion:e.distortion,oversample:e.oversample,wet:e.wet.value}):e instanceof FeedbackCombFilter?t.push({filterType:"FeedbackCombFilterFilter",delayTime:e.delayTime.value,resonance:e.resonance.value}):e instanceof Freeverb?t.push({filterType:"FreeverbFilter",roomSize:e.roomSize.value,dampening:e.dampening,wet:e.wet.value}):e instanceof Gate?t.push({filterType:"GateFilter",threshold:e.threshold,smoothing:e.smoothing}):e instanceof GreaterThan?t.push({filterType:"GreaterThanFilter",value:e.comparator.value,convert:e.convert,maxValue:e.maxValue,minValue:e.minValue}):e instanceof GreaterThanZero?t.push({filterType:"GreaterThanZeroFilter"}):e instanceof Limiter?t.push({filterType:"LimiterFilter",threshold:e.threshold.value}):e instanceof 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 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 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 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 StereoWidener?t.push({filterType:"StereoWidenerFilter",width:e.width.value,wet:e.wet.value}):e instanceof 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 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 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 Vibrato?t.push({filterType:"VibratoFilter",type:e.type,frequency:e.frequency.value,depth:e.depth.value,wet:e.wet.value}):e instanceof 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 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 OnePoleFilter?t.push({filterType:"OnePoleFilterFilter",type:e.type}):e instanceof 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}):f.warn(`Unsupported filter type for serialisation: ${e?.constructor?.name??e}, please report this to the developers if you encounter it.`),t),[])}function J(a){return a instanceof Reverb||a instanceof FeedbackDelay||a instanceof PingPongDelay||a instanceof BitCrusher||a instanceof Compressor||a instanceof Delay||a instanceof Distortion||a instanceof FeedbackCombFilter||a instanceof Freeverb||a instanceof Gate||a instanceof GreaterThan||a instanceof GreaterThanZero||a instanceof Limiter||a instanceof MidSideCompressor||a instanceof MultibandCompressor||a instanceof Panner3D||a instanceof Phaser||a instanceof StereoWidener||a instanceof AutoFilter||a instanceof Chorus||a instanceof Vibrato||a instanceof Tremolo||a instanceof AutoPanner||a instanceof BiquadFilter||a instanceof OnePoleFilter||a instanceof Filter}function m(a){return a<=0?-1/0:20*Math.log10(a)}function g(a){return a<=-1/0?0:10**(a/20)}async function T(a){if(i.bufferRegistry.has(a))return;let t=a;try{let e=se.Assets.resolver.resolve(a);e?.src&&(t=e.src);}catch{}try{let e=await ToneAudioBuffer.load(t),n=new ToneAudioBuffer(e);i.bufferRegistry.set(a,n);}catch(e){f.warn(`Failed to load audio buffer for "${a}" (url: "${t}"): ${e instanceof Error?e.message:e}`),i.bufferRegistry.set(a,new ToneAudioBuffer);}}var b=class extends Player{constructor(e,n,r,o,s={},l){super(s);d(this,"alias",e);d(this,"channelAlias",n);d(this,"soundAlias",r);d(this,"stepCounter",o);d(this,"delay",l);d(this,"options");d(this,"filters",new Set);d(this,"pausedAt");d(this,"playStartTime",now());this.options=s;}get memory(){let e=this.pausedAt?this.pausedAt-this.playStartTime:now()-this.playStartTime,n=this.paused;return n&&i.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:g(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!==m(e.volume??1)&&(this.volume.value=m(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=now(),n==="started"&&super.stop();else {let r;typeof this.pausedAt=="number"&&(r=this.pausedAt-this.playStartTime,this.pausedAt=void 0),n==="stopped"&&(this.delay?super.start(`+${this.delay}`,r):super.start(void 0,r));}}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 i.mediaInstances.delete(this.alias),super.stop(e)}chain(...e){return e.forEach(n=>{J(n)&&(n.toDestination(),this.filters.add(n));}),super.chain(...e)}disconnect(e){return J(e)&&(e.disconnect(),this.filters.delete(e)),super.disconnect(e)}};var v=class{constructor(t,e={}){d(this,"alias",t);d(this,"toneChannel");d(this,"background");this.background=e.background??false,this.toneChannel=new Channel({volume:m(e.volume??1),mute:e.muted??false,pan:e.pan??0}).toDestination(),e.filters&&this.toneChannel.chain(...e.filters);}get volume(){return g(this.toneChannel.volume.value)}set volume(t){this.toneChannel.volume.value=m(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 i.mediaInstances.values())t.channelAlias===this.alias&&!t.paused&&(t.paused=true);return this}resumeAll(){for(let t of i.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 r=i.bufferRegistry.get(e);if(!r)throw new PixiError("unregistered_asset",`Sound buffer for alias "${e}" is not loaded. Call sound.load() first.`);let{delay:o,elapsed:s,filters:l=[],muted:h,autostart:y=true,speed:p,volume:P,...f$1}=n;h!==void 0&&(f.warn(`MediaInstance "${t}" is being created with muted=${h}. This will override the channel's muted state (${this.muted}).`),f$1.mute=h),p!==void 0&&(f.warn(`MediaInstance "${t}" is being created with speed=${p}. This will override the default playback speed of 1.`),f$1.playbackRate=p);let A=new b(t,this.alias,e,GameUnifier.stepCounter,{...f$1,volume:P!==void 0?m(P):void 0,url:r},o).chain(...l,this.toneChannel);return y&&(o?A.start(`+${o}`,s):A.start(void 0,s)),A}async play(t,e,n){let r,o;if(typeof e=="string"?(r=t,o=e):(r=t,o=t,n=e),i.mediaInstances.has(r)){let l=i.mediaInstances.get(r);l&&(l.stop(),n={...l.memory,...n,filters:[...l.filters,...n?.filters||[]]});}await T(o);let s=this._createPlayer(r,o,n);return i.mediaInstances.set(r,s),s}toggleMuteAll(){return this.muted=!this.muted,this.muted}get mediaInstances(){return Array.from(i.mediaInstances.values()).reduce((t,e)=>(e.channelAlias===this.alias&&t.push(e),t),[])}stopAll(){let t=[];for(let[e,n]of i.mediaInstances.entries())n.channelAlias===this.alias&&(n.stop(),t.push(e));return t.forEach(e=>{i.mediaInstances.delete(e);}),this}};var F=class{constructor(){d(this,"_speedAll",1);d(this,"_defaultChannelAlias",i$1);}get volumeAll(){return g(c.getDestination().volume.value)}set volumeAll(t){c.getDestination().volume.value=m(t);}get speedAll(){return this._speedAll}set speedAll(t){this._speedAll=t;for(let e of i.mediaInstances.values())e.speed=t;}get defaultChannelAlias(){return this._defaultChannelAlias}set defaultChannelAlias(t){this._defaultChannelAlias=t;}add(t,e){if(!i.bufferRegistry.has(t)){let n=new c.ToneAudioBuffer(e);i.bufferRegistry.set(t,n);}}pauseAll(){for(let t of i.mediaInstances.values())t.paused||(t.paused=true);return this}resumeAll(){for(let t of i.mediaInstances.values())t.paused&&(t.paused=false);return this}get muted(){return c.getDestination().mute}toggleMuteAll(){let t=!c.getDestination().mute;return c.getDestination().mute=t,t}muteAll(){return c.getDestination().mute=true,this}unmuteAll(){return c.getDestination().mute=false,this}stopAll(){for(let t of i.mediaInstances.values())t.stop();return i.mediaInstances.clear(),this}pauseUnsavedAll(t){for(let[e,n]of i.mediaInstances.entries())t&&n.channelAlias!==t||n.paused||(n.paused=true,i.systemPausedAliases.add(e));if(!t){for(let e of i.transients)e.stop();i.transients.clear();}return this}resumeUnsavedAll(t){let e=[];for(let n of i.systemPausedAliases){let r=i.mediaInstances.get(n);if(!r){e.push(n);continue}t&&r.channelAlias!==t||(r.paused=false,e.push(n));}for(let n of e)i.systemPausedAliases.delete(n);return this}stopTransientAll(){for(let t of i.transients)t.stop();return i.transients.clear(),this}async play(t,e,n){let r,o;typeof e=="string"?(r=t,o=e):(r=t,o=t,n=e),i.bufferRegistry.has(o)||await this.load(o);let{channel:s=this.defaultChannelAlias,...l}=n??{};return await this.findChannel(s).play(r,o,l)}async playTransient(t,e){i.bufferRegistry.has(t)||await this.load(t);let n=i.bufferRegistry.get(t);if(!n)throw new PixiError("unregistered_asset",`Sound buffer for alias "${t}" is not loaded. Call sound.load() first.`);let{autostart:r=true,...o}=e??{},s=new c.Player({...o,url:n}).toDestination();return r&&s.start(),i.transients.add(s),s.onstop=()=>{s.dispose(),i.transients.delete(s);},s}find(t){return i.mediaInstances.get(t)}stop(t){let e=this.find(t);e?(e.stop(),i.mediaInstances.delete(t)):f.warn(`No media instance found with alias ${t} to stop.`);}pause(t){let e=this.find(t);if(!e){f.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){f.warn(`No media instance found with alias ${t} to resume.`);return}return e.paused=false,e}duration(t){return i.bufferRegistry.get(t)?.duration??0}async load(...t){let e=t.map(T);await Promise.all(e);}backgroundLoad(...t){return this.load(...t).catch(e=>{f.error("Error background-loading sound",e);})}backgroundLoadBundle(t){let e=se.Assets.backgroundLoadBundle(t);return e.then(async()=>{try{let n=await se.Assets.loadBundle(t),r=[];for(let o in n)i.bufferRegistry.has(o)||r.push(this.load(o));await Promise.all(r);}catch(n){f.error("Error loading sound bundle",n);}}).catch(n=>{f.error("Error background-loading sound bundle",n);}),e}clear(){this.stopAll();}addChannel(t,e={}){if(typeof t!="string"){t.forEach(r=>{let o={...e,filters:e.filters?[...e.filters]:e.filters};this.addChannel(r,o);});return}if(i.channels.has(t)){f.warn(`Channel with alias ${t} already exists.`);return}let n=new v(t,e);return i.channels.set(t,n),n}findChannel(t){let e=i.channels.get(t);return e||this.addChannel(t)}get channels(){return Array.from(i.channels.values())}export(){let t=Array.from(i.mediaInstances.entries()).reduce((e,[n,r])=>(e[n]={channelAlias:r.channelAlias,soundAlias:r.soundAlias,stepCounter:r.stepCounter,paused:r.paused,options:{...r.memory,filters:oe(r.filters)}},e),{});return {mediaInstances:g$1(t)}}async restore(t){try{if(Object.hasOwn(t,"soundsPlaying")){let e=t.soundsPlaying;if(e){let n=Object.keys(e).map(async r=>{await this.load(r),await this.play(r);});await Promise.all(n);}}if(Object.hasOwn(t,"mediaInstances")){let e=t.mediaInstances;if(e){let n=new Set,r=Object.values(e).map(async({soundAlias:s,channelAlias:l})=>(n.add(l),await this.load(s)));await Promise.all(r),this.channels.forEach(s=>{(!s.background||!n.has(s.alias))&&s.stopAll();});let o=Object.keys(e).map(async s=>{let l=e[s],h=this.findChannel(l.channelAlias),y=l.options.paused??l.paused??!1;if(h.background)if(l.stepCounter===GameUnifier.stepCounter||!this.find(s)){let p=await h.play(s,l.soundAlias,{...l.options,autostart:!y,filters:w(l.options.filters||[]),delay:l.options.delay});p.paused=y;}else {let p=i.mediaInstances.get(s);if(!p){f.warn(`No media instance found with alias ${s} while restoring background state.`);return}p.memory={...l.options,paused:y},[...p.filters].forEach(f=>{p.disconnect(f),f.dispose();}),p.chain(...w(l.options.filters||[]));}else {let p=await h.play(s,l.soundAlias,{...l.options,autostart:!y,filters:w(l.options.filters||[]),delay:l.options.delay});p.paused=y;}});await Promise.all(o);}}}catch(e){f.error("Error importing data",e);}}};var te=new F;GameUnifier.addOnPreContinue(async()=>{try{i.channels.forEach(a=>{a.background||a.stopAll();});}catch{}});if(typeof document<"u"){let a=false;document.addEventListener("visibilitychange",()=>{document.hidden?te.muted||(te.muteAll(),a=true):a&&(te.unmuteAll(),a=false);});}export{i as SoundRegistry,te as sound};
package/dist/storage.mjs CHANGED
@@ -1 +1 @@
1
- export{a as StorageManagerStatic,b as StoredClassModel,c as storage}from'./chunk-4KCAZKAJ.mjs';import'./chunk-YDNEIPJP.mjs';import'./chunk-IWAXXFXE.mjs';import'./chunk-HNGW4ITF.mjs';
1
+ export{a as StorageManagerStatic,b as StoredClassModel,c as storage}from'./chunk-XYO5SLSM.mjs';import'./chunk-IWAXXFXE.mjs';import'./chunk-6HI66YQL.mjs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drincs/pixi-vn",
3
- "version": "1.7.2",
3
+ "version": "1.8.0",
4
4
  "type": "module",
5
5
  "description": "Pixi'VN is a npm package that provides various features for creating visual novels.",
6
6
  "main": "./dist/index.cjs",
@@ -15,7 +15,8 @@
15
15
  "lint": "biome lint",
16
16
  "check": "biome check",
17
17
  "format": "biome format --write",
18
- "test": "vitest"
18
+ "test": "vitest",
19
+ "docs": "typedoc"
19
20
  },
20
21
  "exports": {
21
22
  ".": {
@@ -141,15 +142,15 @@
141
142
  "funding": "https://github.com/DRincs-Productions/pixi-vn?sponsor=1",
142
143
  "dependencies": {
143
144
  "@pixi/devtools": "^2.0.1",
144
- "@pixi/sound": "^6.0.1",
145
145
  "motion": "^12.38.0",
146
- "pixi.js": "^8.18.1"
146
+ "pixi.js": "^8.18.1",
147
+ "tone": "^15.1.22"
147
148
  },
148
149
  "peerDependencies": {
149
- "@pixi/devtools": "^2.0.0",
150
- "@pixi/sound": "^6.0.0",
151
- "motion": "^12.38.0",
152
- "pixi.js": "^8.17.0"
150
+ "@pixi/devtools": ">=2.0.0",
151
+ "motion": ">=12.38.0",
152
+ "pixi.js": ">=8.17.0",
153
+ "tone": ">=15.1.0"
153
154
  },
154
155
  "devDependencies": {
155
156
  "@biomejs/biome": "^2.4.12",
@@ -164,6 +165,8 @@
164
165
  "ts-node": "^10.9.2",
165
166
  "tsconfig-paths": "^4.2.0",
166
167
  "tsup": "^8.5.1",
168
+ "typedoc": "^0.28.19",
169
+ "typedoc-plugin-markdown": "^4.11.0",
167
170
  "typescript": "^5.9.3",
168
171
  "vite": "^8.0.9",
169
172
  "vite-tsconfig-paths": "^6.1.1",
@@ -1 +0,0 @@
1
- import {a}from'./chunk-YDNEIPJP.mjs';import {k as k$1,m,j,l,n}from'./chunk-IWAXXFXE.mjs';import {k as k$2,j as j$1,d}from'./chunk-HNGW4ITF.mjs';import {GameUnifier}from'@drincs/pixi-vn/core';var T;(s=>{s.storage=new a({cacheSize:50}),s.defaultStorage=new a({cacheSize:10}),s.tempStorageDeadlines=new Map;let n;function c(a){s.tempStorageDeadlines.forEach((l,o)=>{l>a&&(s.storage.delete(`${k$1}:${o}`),n?.onClearOldTempVariable?.(o),s.tempStorageDeadlines.delete(o));});}s.clearOldTempVariables=c;function h(a){n=a;}s.setExternalStoreHandler=h;function V(a,l,o){o==null?s.storage.delete(`${a}:${l}`):s.storage.set(`${a}:${l}`,o),n?.onSetVariable?.(l,o);}s.setVariable=V;function O(a,l){let o=s.storage.get(`${a}:${l}`);return k$2(o)}s.getVariable=O;function M(a,l){s.storage.delete(`${a}:${l}`),n?.onRemoveVariable?.(l);}s.removeVariable=M;function D(a,l){let o=s.storage.get(m)||[];if(l)o.includes(a)||o.push(a);else {let x=o.indexOf(a);x>-1&&o.splice(x,1);}s.storage.set(m,o);}s.setFlag=D;function R(a){return (s.storage.get(m)||[]).includes(a)}s.getFlag=R;})(T||(T={}));var r=T;var S=class{get base(){return r.storage.map}get cache(){return r.storage.cache}get tempStorageDeadlines(){return r.tempStorageDeadlines}set default(t){Object.entries(t).forEach(([e,n])=>{r.defaultStorage.map.set(e,n);});}set(t,e){return r.setVariable(j,t,e)}get(t){let e=r.getVariable(k$1,t);return e===void 0&&(e=r.getVariable(j,t)),e===void 0&&(e=k$2(r.defaultStorage.get(t))),e}remove(t){return this.removeTempVariable(t),r.removeVariable(j,t)}setTempVariable(t,e){if(e==null){this.removeTempVariable(t);return}else r.setVariable(k$1,t,e),this.tempStorageDeadlines.has(t)||this.tempStorageDeadlines.set(t,GameUnifier.openedLabels);}removeTempVariable(t){r.removeVariable(k$1,t),this.tempStorageDeadlines.has(t)&&this.tempStorageDeadlines.delete(t);}setFlag(t,e){return r.setFlag(t,e)}getFlag(t){return r.getFlag(t)}setStorageHandler(t){r.setExternalStoreHandler(t);}clear(){this.base.clear(),this.cache.clear(),this.tempStorageDeadlines.clear();}export(){let t=[];[...this.base.keys()].forEach(n=>{t.push({key:n,value:this.base.get(n)});});let e=[];return [...r.tempStorageDeadlines.keys()].forEach(n=>{e.push({key:n,value:this.tempStorageDeadlines.get(n)});}),k$2({main:t,tempDeadlines:e})}restore(t){this.clear();try{t?(t.base?.forEach(e=>{switch(e.key){case "___current_dialogue_memory___":r.setVariable(l,n.CURRENT_DIALOGUE_MEMORY_KEY,e.value);break;case "___last_dialogue_added_in_step_memory___":r.setVariable(l,n.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY,e.value);break;case "___current_menu_options_memory___":r.setVariable(l,n.CURRENT_MENU_OPTIONS_MEMORY_KEY,e.value);break;case "___last_menu_options_added_in_step_memory___":r.setVariable(l,n.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY,e.value);break;case "_input_value_":r.setVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY,e.value);break;case "___last_input_added_in_step_memory___":r.setVariable(l,n.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY,e.value);break;case "___current_input_info_memory___":r.setVariable(l,n.CURRENT_INPUT_INFO_MEMORY_KEY,e.value);break;case "___opened_labels_counter___":r.setVariable(l,n.OPENED_LABELS_COUNTER_KEY,e.value);break;case "___all_choices_made___":r.setVariable(l,n.ALL_CHOICES_MADE_KEY,e.value);break;case "___current_step_times_counter___":r.setVariable(l,n.CURRENT_STEP_TIMES_COUNTER_KEY,e.value);break;case "___last_step_glued___":r.setVariable(l,n.LAST_STEP_GLUED,e.value);break;default:r.setVariable(j,e.key,e.value);}}),t.temp?.forEach(e=>{r.setVariable(k$1,e.key,e.value);}),t.flags?.forEach(e=>{r.setFlag(e,!0);}),t.main?.forEach(e=>{this.base.set(e.key,e.value);}),t.tempDeadlines?.forEach(e=>{this.tempStorageDeadlines.set(e.key,e.value);})):j$1.warn("No storage data found");}catch(e){j$1.error("Error importing data",e);}}};var f=class{constructor(t,e){d(this,"id");d(this,"categoryId");this.categoryId=t,this.id=e,this.migrateOldStorage();}migrateOldStorage(t=this.categoryId){let e=r.getVariable(j,t);e&&(Object.entries(e).forEach(([n,c])=>{typeof c=="object"&&c!==null&&Object.entries(c).forEach(([h,V])=>{r.setVariable(this.categoryId,`${n}:${h}`,V);});}),r.removeVariable(j,t));}setStorageProperty(t,e){r.setVariable(this.categoryId,`${this.id}:${t}`,e);}getStorageProperty(t,e=this.id){return r.getVariable(this.categoryId,`${e}:${t}`)}};var k=new S;export{r as a,f as b,k as c};
@@ -1 +0,0 @@
1
- import {PixiError}from'@drincs/pixi-vn/core';var y=Object.create;var p=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var m=Object.getPrototypeOf,N=Object.prototype.hasOwnProperty;var x=r=>{throw TypeError(r)};var E=(r,o,n)=>o in r?p(r,o,{enumerable:true,configurable:true,writable:true,value:n}):r[o]=n;var V=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(o,n)=>(typeof require<"u"?require:o)[n]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var $=(r,o)=>()=>(o||r((o={exports:{}}).exports,o),o.exports);var P=(r,o,n,t)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of l(o))!N.call(r,e)&&e!==n&&p(r,e,{get:()=>o[e],enumerable:!(t=f(o,e))||t.enumerable});return r};var S=(r,o,n)=>(n=r!=null?y(m(r)):{},P(o||!r||!r.__esModule?p(n,"default",{value:r,enumerable:true}):n,r));var T=(r,o,n)=>E(r,typeof o!="symbol"?o+"":o,n),s=(r,o,n)=>o.has(r)||x("Cannot "+n);var b=(r,o,n)=>(s(r,o,"read from private field"),n?n.call(r):o.get(r)),d=(r,o,n)=>o.has(r)?x("Cannot add the same private member more than once"):o instanceof WeakSet?o.add(r):o.set(r,n),u=(r,o,n,t)=>(s(r,o,"write to private field"),t?t.call(r,n):o.set(r,n),n),h=(r,o,n)=>(s(r,o,"access private method"),n);var J=(r,o,n,t)=>({set _(e){u(r,o,e,n);},get _(){return b(r,o,t)}});var c;(e=>(e.log=(i,...a)=>console.log(`[Pixi\u2019VN] ${i}`,...a),e.warn=(i,...a)=>console.warn(`[Pixi\u2019VN] ${i}`,...a),e.error=(i,...a)=>console.error(`[Pixi\u2019VN] ${i}`,...a),e.info=(i,...a)=>console.info(`[Pixi\u2019VN] ${i}`,...a)))(c||(c={}));function k(r){try{if(typeof r>"u")return r;let o=JSON.stringify(r);return JSON.parse(o)}catch(o){throw c.error("Error creating exportable element",r,o),new PixiError("not_json_serializable","Error creating exportable element")}}export{V as a,$ as b,S as c,T as d,b as e,d as f,u as g,h,J as i,c as j,k};
@@ -1 +0,0 @@
1
- import {d,f,e,g,h,i}from'./chunk-HNGW4ITF.mjs';var kt=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Gt=new Set,Tt=typeof process=="object"&&process?process:{},Mt=(_,e,i,s)=>{typeof Tt.emitWarning=="function"?Tt.emitWarning(_,e,i,s):console.error(`[${i}] ${e}: ${_}`);},Ft=globalThis.AbortController,Dt=globalThis.AbortSignal;if(typeof Ft>"u"){Dt=class{constructor(){d(this,"onabort");d(this,"_onabort",[]);d(this,"reason");d(this,"aborted",false);}addEventListener(i,s){this._onabort.push(s);}},Ft=class{constructor(){d(this,"signal",new Dt);e();}abort(i){if(!this.signal.aborted){this.signal.reason=i,this.signal.aborted=true;for(let s of this.signal._onabort)s(i);this.signal.onabort?.(i);}}};let _=Tt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{_&&(_=false,Mt("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",e));};}var Ht=_=>!Gt.has(_);var tt=_=>_&&_===Math.floor(_)&&_>0&&isFinite(_),jt=_=>tt(_)?_<=Math.pow(2,8)?Uint8Array:_<=Math.pow(2,16)?Uint16Array:_<=Math.pow(2,32)?Uint32Array:_<=Number.MAX_SAFE_INTEGER?yt:null:null,yt=class extends Array{constructor(_){super(_),this.fill(0);}},J,ft,Vt=(J=class{constructor(e$1,i){d(this,"heap");d(this,"length");if(!e(J,ft))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new i(e$1),this.length=0;}static create(e){let i=jt(e);if(!i)return [];g(J,ft,true);let s=new J(e,i);return g(J,ft,false),s}push(e){this.heap[this.length++]=e;}pop(){return this.heap[--this.length]}},ft=new WeakMap,f(J,ft,false),J),Lt,Ut,k,U,H,ot,V,ct,dt,K,F,P,O,b,c,W,G,x,E,B,T,$,q,M,j,X,ht,D,gt,o,zt,rt,Q,St,I,Nt,nt,pt,bt,et,it,xt,At,Ot,S,Rt,vt,st,Ct,wt,It=(wt=class{constructor(e$1){f(this,o);f(this,k);f(this,U);f(this,H);f(this,ot);f(this,V);f(this,ct);f(this,dt);f(this,K);d(this,"ttl");d(this,"ttlResolution");d(this,"ttlAutopurge");d(this,"updateAgeOnGet");d(this,"updateAgeOnHas");d(this,"allowStale");d(this,"noDisposeOnSet");d(this,"noUpdateTTL");d(this,"maxEntrySize");d(this,"sizeCalculation");d(this,"noDeleteOnFetchRejection");d(this,"noDeleteOnStaleGet");d(this,"allowStaleOnFetchAbort");d(this,"allowStaleOnFetchRejection");d(this,"ignoreFetchAbort");f(this,F);f(this,P);f(this,O);f(this,b);f(this,c);f(this,W);f(this,G);f(this,x);f(this,E);f(this,B);f(this,T);f(this,$);f(this,q);f(this,M);f(this,j);f(this,X);f(this,ht);f(this,D);f(this,gt);f(this,rt,()=>{});f(this,Q,()=>{});f(this,St,()=>{});f(this,I,()=>false);f(this,nt,e=>{});f(this,pt,(e,i,s)=>{});f(this,bt,(e,i,s,h)=>{if(s||h)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});d(this,Lt,"LRUCache");let{max:i=0,ttl:s,ttlResolution:h$1=1,ttlAutopurge:n,updateAgeOnGet:r,updateAgeOnHas:a,allowStale:u,dispose:p,onInsert:z,disposeAfter:w,noDisposeOnSet:Z,noUpdateTTL:N,maxSize:Y=0,maxEntrySize:y=0,sizeCalculation:v,fetchMethod:d$1,memoMethod:R,noDeleteOnFetchRejection:L,noDeleteOnStaleGet:C,allowStaleOnFetchRejection:A,allowStaleOnFetchAbort:mt,ignoreFetchAbort:lt,perf:at}=e$1;if(at!==void 0&&typeof at?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(g(this,K,at??kt),i!==0&&!tt(i))throw new TypeError("max option must be a nonnegative integer");let ut=i?jt(i):Array;if(!ut)throw new Error("invalid max value: "+i);if(g(this,k,i),g(this,U,Y),this.maxEntrySize=y||e(this,U),this.sizeCalculation=v,this.sizeCalculation){if(!e(this,U)&&!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(R!==void 0&&typeof R!="function")throw new TypeError("memoMethod must be a function if defined");if(g(this,dt,R),d$1!==void 0&&typeof d$1!="function")throw new TypeError("fetchMethod must be a function if specified");if(g(this,ct,d$1),g(this,ht,!!d$1),g(this,O,new Map),g(this,b,new Array(i).fill(void 0)),g(this,c,new Array(i).fill(void 0)),g(this,W,new ut(i)),g(this,G,new ut(i)),g(this,x,0),g(this,E,0),g(this,B,Vt.create(i)),g(this,F,0),g(this,P,0),typeof p=="function"&&g(this,H,p),typeof z=="function"&&g(this,ot,z),typeof w=="function"?(g(this,V,w),g(this,T,[])):(g(this,V,void 0),g(this,T,void 0)),g(this,X,!!e(this,H)),g(this,gt,!!e(this,ot)),g(this,D,!!e(this,V)),this.noDisposeOnSet=!!Z,this.noUpdateTTL=!!N,this.noDeleteOnFetchRejection=!!L,this.allowStaleOnFetchRejection=!!A,this.allowStaleOnFetchAbort=!!mt,this.ignoreFetchAbort=!!lt,this.maxEntrySize!==0){if(e(this,U)!==0&&!tt(e(this,U)))throw new TypeError("maxSize must be a positive integer if specified");if(!tt(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");h(this,o,Nt).call(this);}if(this.allowStale=!!u,this.noDeleteOnStaleGet=!!C,this.updateAgeOnGet=!!r,this.updateAgeOnHas=!!a,this.ttlResolution=tt(h$1)||h$1===0?h$1:1,this.ttlAutopurge=!!n,this.ttl=s||0,this.ttl){if(!tt(this.ttl))throw new TypeError("ttl must be a positive integer if specified");h(this,o,zt).call(this);}if(e(this,k)===0&&this.ttl===0&&e(this,U)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!e(this,k)&&!e(this,U)){let Et="LRU_CACHE_UNBOUNDED";Ht(Et)&&(Gt.add(Et),Mt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Et,wt));}}get perf(){return e(this,K)}static unsafeExposeInternals(e$1){return {starts:e(e$1,q),ttls:e(e$1,M),autopurgeTimers:e(e$1,j),sizes:e(e$1,$),keyMap:e(e$1,O),keyList:e(e$1,b),valList:e(e$1,c),next:e(e$1,W),prev:e(e$1,G),get head(){return e(e$1,x)},get tail(){return e(e$1,E)},free:e(e$1,B),isBackgroundFetch:i=>{var s;return h(s=e$1,o,S).call(s,i)},backgroundFetch:(i,s,h$1,n)=>{var r;return h(r=e$1,o,Ot).call(r,i,s,h$1,n)},moveToTail:i=>{var s;return h(s=e$1,o,vt).call(s,i)},indexes:i=>{var s;return h(s=e$1,o,et).call(s,i)},rindexes:i=>{var s;return h(s=e$1,o,it).call(s,i)},isStale:i=>{var s;return e(s=e$1,I).call(s,i)}}}get max(){return e(this,k)}get maxSize(){return e(this,U)}get calculatedSize(){return e(this,P)}get size(){return e(this,F)}get fetchMethod(){return e(this,ct)}get memoMethod(){return e(this,dt)}get dispose(){return e(this,H)}get onInsert(){return e(this,ot)}get disposeAfter(){return e(this,V)}getRemainingTTL(e$1){return e(this,O).has(e$1)?1/0:0}*entries(){for(let e$1 of h(this,o,et).call(this))e(this,c)[e$1]!==void 0&&e(this,b)[e$1]!==void 0&&!h(this,o,S).call(this,e(this,c)[e$1])&&(yield [e(this,b)[e$1],e(this,c)[e$1]]);}*rentries(){for(let e$1 of h(this,o,it).call(this))e(this,c)[e$1]!==void 0&&e(this,b)[e$1]!==void 0&&!h(this,o,S).call(this,e(this,c)[e$1])&&(yield [e(this,b)[e$1],e(this,c)[e$1]]);}*keys(){for(let e$1 of h(this,o,et).call(this)){let i=e(this,b)[e$1];i!==void 0&&!h(this,o,S).call(this,e(this,c)[e$1])&&(yield i);}}*rkeys(){for(let e$1 of h(this,o,it).call(this)){let i=e(this,b)[e$1];i!==void 0&&!h(this,o,S).call(this,e(this,c)[e$1])&&(yield i);}}*values(){for(let e$1 of h(this,o,et).call(this))e(this,c)[e$1]!==void 0&&!h(this,o,S).call(this,e(this,c)[e$1])&&(yield e(this,c)[e$1]);}*rvalues(){for(let e$1 of h(this,o,it).call(this))e(this,c)[e$1]!==void 0&&!h(this,o,S).call(this,e(this,c)[e$1])&&(yield e(this,c)[e$1]);}[(Ut=Symbol.iterator,Lt=Symbol.toStringTag,Ut)](){return this.entries()}find(e$1,i={}){for(let s of h(this,o,et).call(this)){let h$1=e(this,c)[s],n=h(this,o,S).call(this,h$1)?h$1.__staleWhileFetching:h$1;if(n!==void 0&&e$1(n,e(this,b)[s],this))return this.get(e(this,b)[s],i)}}forEach(e$1,i=this){for(let s of h(this,o,et).call(this)){let h$1=e(this,c)[s],n=h(this,o,S).call(this,h$1)?h$1.__staleWhileFetching:h$1;n!==void 0&&e$1.call(i,n,e(this,b)[s],this);}}rforEach(e$1,i=this){for(let s of h(this,o,it).call(this)){let h$1=e(this,c)[s],n=h(this,o,S).call(this,h$1)?h$1.__staleWhileFetching:h$1;n!==void 0&&e$1.call(i,n,e(this,b)[s],this);}}purgeStale(){let e$1=false;for(let i of h(this,o,it).call(this,{allowStale:true}))e(this,I).call(this,i)&&(h(this,o,st).call(this,e(this,b)[i],"expire"),e$1=true);return e$1}info(e$1){let i=e(this,O).get(e$1);if(i===void 0)return;let s=e(this,c)[i],h$1=h(this,o,S).call(this,s)?s.__staleWhileFetching:s;if(h$1===void 0)return;let n={value:h$1};if(e(this,M)&&e(this,q)){let r=e(this,M)[i],a=e(this,q)[i];if(r&&a){let u=r-(e(this,K).now()-a);n.ttl=u,n.start=Date.now();}}return e(this,$)&&(n.size=e(this,$)[i]),n}dump(){let e$1=[];for(let i of h(this,o,et).call(this,{allowStale:true})){let s=e(this,b)[i],h$1=e(this,c)[i],n=h(this,o,S).call(this,h$1)?h$1.__staleWhileFetching:h$1;if(n===void 0||s===void 0)continue;let r={value:n};if(e(this,M)&&e(this,q)){r.ttl=e(this,M)[i];let a=e(this,K).now()-e(this,q)[i];r.start=Math.floor(Date.now()-a);}e(this,$)&&(r.size=e(this,$)[i]),e$1.unshift([s,r]);}return e$1}load(e$1){this.clear();for(let[i,s]of e$1){if(s.start){let h=Date.now()-s.start;s.start=e(this,K).now()-h;}this.set(i,s.value,s);}}set(e$1,i$1,s={}){var Z,N,Y,y;if(i$1===void 0)return this.delete(e$1),this;let{ttl:h$1=this.ttl,start:n,noDisposeOnSet:r=this.noDisposeOnSet,sizeCalculation:a=this.sizeCalculation,status:u}=s,{noUpdateTTL:p=this.noUpdateTTL}=s,z=e(this,bt).call(this,e$1,i$1,s.size||0,a);if(this.maxEntrySize&&z>this.maxEntrySize)return u&&(u.set="miss",u.maxEntrySizeExceeded=true),h(this,o,st).call(this,e$1,"set"),this;let w=e(this,F)===0?void 0:e(this,O).get(e$1);if(w===void 0)w=e(this,F)===0?e(this,E):e(this,B).length!==0?e(this,B).pop():e(this,F)===e(this,k)?h(this,o,At).call(this,false):e(this,F),e(this,b)[w]=e$1,e(this,c)[w]=i$1,e(this,O).set(e$1,w),e(this,W)[e(this,E)]=w,e(this,G)[w]=e(this,E),g(this,E,w),i(this,F)._++,e(this,pt).call(this,w,z,u),u&&(u.set="add"),p=false,e(this,gt)&&((Z=e(this,ot))==null||Z.call(this,i$1,e$1,"add"));else {h(this,o,vt).call(this,w);let v=e(this,c)[w];if(i$1!==v){if(e(this,ht)&&h(this,o,S).call(this,v)){v.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:d}=v;d!==void 0&&!r&&(e(this,X)&&((N=e(this,H))==null||N.call(this,d,e$1,"set")),e(this,D)&&e(this,T)?.push([d,e$1,"set"]));}else r||(e(this,X)&&((Y=e(this,H))==null||Y.call(this,v,e$1,"set")),e(this,D)&&e(this,T)?.push([v,e$1,"set"]));if(e(this,nt).call(this,w),e(this,pt).call(this,w,z,u),e(this,c)[w]=i$1,u){u.set="replace";let d=v&&h(this,o,S).call(this,v)?v.__staleWhileFetching:v;d!==void 0&&(u.oldValue=d);}}else u&&(u.set="update");e(this,gt)&&this.onInsert?.(i$1,e$1,i$1===v?"update":"replace");}if(h$1!==0&&!e(this,M)&&h(this,o,zt).call(this),e(this,M)&&(p||e(this,St).call(this,w,h$1,n),u&&e(this,Q).call(this,u,w)),!r&&e(this,D)&&e(this,T)){let v=e(this,T),d;for(;d=v?.shift();)(y=e(this,V))==null||y.call(this,...d);}return this}pop(){var e$1;try{for(;e(this,F);){let i=e(this,c)[e(this,x)];if(h(this,o,At).call(this,!0),h(this,o,S).call(this,i)){if(i.__staleWhileFetching)return i.__staleWhileFetching}else if(i!==void 0)return i}}finally{if(e(this,D)&&e(this,T)){let i=e(this,T),s;for(;s=i?.shift();)(e$1=e(this,V))==null||e$1.call(this,...s);}}}has(e$1,i={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:h$1}=i,n=e(this,O).get(e$1);if(n!==void 0){let r=e(this,c)[n];if(h(this,o,S).call(this,r)&&r.__staleWhileFetching===void 0)return false;if(e(this,I).call(this,n))h$1&&(h$1.has="stale",e(this,Q).call(this,h$1,n));else return s&&e(this,rt).call(this,n),h$1&&(h$1.has="hit",e(this,Q).call(this,h$1,n)),true}else h$1&&(h$1.has="miss");return false}peek(e$1,i={}){let{allowStale:s=this.allowStale}=i,h$1=e(this,O).get(e$1);if(h$1===void 0||!s&&e(this,I).call(this,h$1))return;let n=e(this,c)[h$1];return h(this,o,S).call(this,n)?n.__staleWhileFetching:n}async fetch(e$1,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:h$1=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,ttl:r=this.ttl,noDisposeOnSet:a=this.noDisposeOnSet,size:u=0,sizeCalculation:p=this.sizeCalculation,noUpdateTTL:z=this.noUpdateTTL,noDeleteOnFetchRejection:w=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:Z=this.allowStaleOnFetchRejection,ignoreFetchAbort:N=this.ignoreFetchAbort,allowStaleOnFetchAbort:Y=this.allowStaleOnFetchAbort,context:y,forceRefresh:v=false,status:d,signal:R}=i;if(!e(this,ht))return d&&(d.fetch="get"),this.get(e$1,{allowStale:s,updateAgeOnGet:h$1,noDeleteOnStaleGet:n,status:d});let L={allowStale:s,updateAgeOnGet:h$1,noDeleteOnStaleGet:n,ttl:r,noDisposeOnSet:a,size:u,sizeCalculation:p,noUpdateTTL:z,noDeleteOnFetchRejection:w,allowStaleOnFetchRejection:Z,allowStaleOnFetchAbort:Y,ignoreFetchAbort:N,status:d,signal:R},C=e(this,O).get(e$1);if(C===void 0){d&&(d.fetch="miss");let A=h(this,o,Ot).call(this,e$1,C,L,y);return A.__returned=A}else {let A=e(this,c)[C];if(h(this,o,S).call(this,A)){let ut=s&&A.__staleWhileFetching!==void 0;return d&&(d.fetch="inflight",ut&&(d.returnedStale=true)),ut?A.__staleWhileFetching:A.__returned=A}let mt=e(this,I).call(this,C);if(!v&&!mt)return d&&(d.fetch="hit"),h(this,o,vt).call(this,C),h$1&&e(this,rt).call(this,C),d&&e(this,Q).call(this,d,C),A;let lt=h(this,o,Ot).call(this,e$1,C,L,y),at=lt.__staleWhileFetching!==void 0&&s;return d&&(d.fetch=mt?"stale":"refresh",at&&mt&&(d.returnedStale=true)),at?lt.__staleWhileFetching:lt.__returned=lt}}async forceFetch(e,i={}){let s=await this.fetch(e,i);if(s===void 0)throw new Error("fetch() returned undefined");return s}memo(e$1,i={}){let s=e(this,dt);if(!s)throw new Error("no memoMethod provided to constructor");let{context:h,forceRefresh:n,...r}=i,a=this.get(e$1,r);if(!n&&a!==void 0)return a;let u=s(e$1,a,{options:r,context:h});return this.set(e$1,u,r),u}get(e$1,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:h$1=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,status:r}=i,a=e(this,O).get(e$1);if(a!==void 0){let u=e(this,c)[a],p=h(this,o,S).call(this,u);return r&&e(this,Q).call(this,r,a),e(this,I).call(this,a)?(r&&(r.get="stale"),p?(r&&s&&u.__staleWhileFetching!==void 0&&(r.returnedStale=true),s?u.__staleWhileFetching:void 0):(n||h(this,o,st).call(this,e$1,"expire"),r&&s&&(r.returnedStale=true),s?u:void 0)):(r&&(r.get="hit"),p?u.__staleWhileFetching:(h(this,o,vt).call(this,a),h$1&&e(this,rt).call(this,a),u))}else r&&(r.get="miss");}delete(e){return h(this,o,st).call(this,e,"delete")}clear(){return h(this,o,Ct).call(this,"delete")}},k=new WeakMap,U=new WeakMap,H=new WeakMap,ot=new WeakMap,V=new WeakMap,ct=new WeakMap,dt=new WeakMap,K=new WeakMap,F=new WeakMap,P=new WeakMap,O=new WeakMap,b=new WeakMap,c=new WeakMap,W=new WeakMap,G=new WeakMap,x=new WeakMap,E=new WeakMap,B=new WeakMap,T=new WeakMap,$=new WeakMap,q=new WeakMap,M=new WeakMap,j=new WeakMap,X=new WeakMap,ht=new WeakMap,D=new WeakMap,gt=new WeakMap,o=new WeakSet,zt=function(){let e$1=new yt(e(this,k)),i=new yt(e(this,k));g(this,M,e$1),g(this,q,i);let s=this.ttlAutopurge?new Array(e(this,k)):void 0;g(this,j,s),g(this,St,(a,u,p=e(this,K).now())=>{i[a]=u!==0?p:0,e$1[a]=u,h$1(a,u);}),g(this,rt,a=>{i[a]=e$1[a]!==0?e(this,K).now():0,h$1(a,e$1[a]);});let h$1=this.ttlAutopurge?(a,u)=>{if(s?.[a]&&(clearTimeout(s[a]),s[a]=void 0),u&&u!==0&&s){let p=setTimeout(()=>{e(this,I).call(this,a)&&h(this,o,st).call(this,e(this,b)[a],"expire");},u+1);p.unref&&p.unref(),s[a]=p;}}:()=>{};g(this,Q,(a,u)=>{if(e$1[u]){let p=e$1[u],z=i[u];if(!p||!z)return;a.ttl=p,a.start=z,a.now=n||r();let w=a.now-z;a.remainingTTL=p-w;}});let n=0,r=()=>{let a=e(this,K).now();if(this.ttlResolution>0){n=a;let u=setTimeout(()=>n=0,this.ttlResolution);u.unref&&u.unref();}return a};this.getRemainingTTL=a=>{let u=e(this,O).get(a);if(u===void 0)return 0;let p=e$1[u],z=i[u];if(!p||!z)return 1/0;let w=(n||r())-z;return p-w},g(this,I,a=>{let u=i[a],p=e$1[a];return !!p&&!!u&&(n||r())-u>p});},rt=new WeakMap,Q=new WeakMap,St=new WeakMap,I=new WeakMap,Nt=function(){let e$1=new yt(e(this,k));g(this,P,0),g(this,$,e$1),g(this,nt,i=>{g(this,P,e(this,P)-e$1[i]),e$1[i]=0;}),g(this,bt,(i,s,h$1,n)=>{if(h(this,o,S).call(this,s))return 0;if(!tt(h$1))if(n){if(typeof n!="function")throw new TypeError("sizeCalculation must be a function");if(h$1=n(s,i),!tt(h$1))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 h$1}),g(this,pt,(i,s,h$1)=>{if(e$1[i]=s,e(this,U)){let n=e(this,U)-e$1[i];for(;e(this,P)>n;)h(this,o,At).call(this,true);}g(this,P,e(this,P)+e$1[i]),h$1&&(h$1.entrySize=s,h$1.totalCalculatedSize=e(this,P));});},nt=new WeakMap,pt=new WeakMap,bt=new WeakMap,et=function*({allowStale:e$1=this.allowStale}={}){if(e(this,F))for(let i=e(this,E);!(!h(this,o,xt).call(this,i)||((e$1||!e(this,I).call(this,i))&&(yield i),i===e(this,x)));)i=e(this,G)[i];},it=function*({allowStale:e$1=this.allowStale}={}){if(e(this,F))for(let i=e(this,x);!(!h(this,o,xt).call(this,i)||((e$1||!e(this,I).call(this,i))&&(yield i),i===e(this,E)));)i=e(this,W)[i];},xt=function(e$1){return e$1!==void 0&&e(this,O).get(e(this,b)[e$1])===e$1},At=function(e$1){var n;let i$1=e(this,x),s=e(this,b)[i$1],h$1=e(this,c)[i$1];return e(this,ht)&&h(this,o,S).call(this,h$1)?h$1.__abortController.abort(new Error("evicted")):(e(this,X)||e(this,D))&&(e(this,X)&&((n=e(this,H))==null||n.call(this,h$1,s,"evict")),e(this,D)&&e(this,T)?.push([h$1,s,"evict"])),e(this,nt).call(this,i$1),e(this,j)?.[i$1]&&(clearTimeout(e(this,j)[i$1]),e(this,j)[i$1]=void 0),e$1&&(e(this,b)[i$1]=void 0,e(this,c)[i$1]=void 0,e(this,B).push(i$1)),e(this,F)===1?(g(this,x,g(this,E,0)),e(this,B).length=0):g(this,x,e(this,W)[i$1]),e(this,O).delete(s),i(this,F)._--,i$1},Ot=function(e$1,i,s,h$1){let n=i===void 0?void 0:e(this,c)[i];if(h(this,o,S).call(this,n))return n;let r=new Ft,{signal:a}=s;a?.addEventListener("abort",()=>r.abort(a.reason),{signal:r.signal});let u={signal:r.signal,options:s,context:h$1},p=(y,v=false)=>{let{aborted:d}=r.signal,R=s.ignoreFetchAbort&&y!==void 0,L=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&y!==void 0);if(s.status&&(d&&!v?(s.status.fetchAborted=true,s.status.fetchError=r.signal.reason,R&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),d&&!R&&!v)return w(r.signal.reason,L);let C=N,A=e(this,c)[i];return (A===N||R&&v&&A===void 0)&&(y===void 0?C.__staleWhileFetching!==void 0?e(this,c)[i]=C.__staleWhileFetching:h(this,o,st).call(this,e$1,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(e$1,y,u.options))),y},z=y=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=y),w(y,false)),w=(y,v)=>{let{aborted:d}=r.signal,R=d&&s.allowStaleOnFetchAbort,L=R||s.allowStaleOnFetchRejection,C=L||s.noDeleteOnFetchRejection,A=N;if(e(this,c)[i]===N&&(!C||!v&&A.__staleWhileFetching===void 0?h(this,o,st).call(this,e$1,"fetch"):R||(e(this,c)[i]=A.__staleWhileFetching)),L)return s.status&&A.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),A.__staleWhileFetching;if(A.__returned===A)throw y},Z=(y,v)=>{var R;let d=(R=e(this,ct))==null?void 0:R.call(this,e$1,n,u);d&&d instanceof Promise&&d.then(L=>y(L===void 0?void 0:L),v),r.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(y(void 0),s.allowStaleOnFetchAbort&&(y=L=>p(L,true)));});};s.status&&(s.status.fetchDispatched=true);let N=new Promise(Z).then(p,z),Y=Object.assign(N,{__abortController:r,__staleWhileFetching:n,__returned:void 0});return i===void 0?(this.set(e$1,Y,{...u.options,status:void 0}),i=e(this,O).get(e$1)):e(this,c)[i]=Y,Y},S=function(e$1){if(!e(this,ht))return false;let i=e$1;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof Ft},Rt=function(e$1,i){e(this,G)[i]=e$1,e(this,W)[e$1]=i;},vt=function(e$1){e$1!==e(this,E)&&(e$1===e(this,x)?g(this,x,e(this,W)[e$1]):h(this,o,Rt).call(this,e(this,G)[e$1],e(this,W)[e$1]),h(this,o,Rt).call(this,e(this,E),e$1),g(this,E,e$1));},st=function(e$1,i$1){var h$1,n;let s=false;if(e(this,F)!==0){let r=e(this,O).get(e$1);if(r!==void 0)if(e(this,j)?.[r]&&(clearTimeout(e(this,j)?.[r]),e(this,j)[r]=void 0),s=true,e(this,F)===1)h(this,o,Ct).call(this,i$1);else {e(this,nt).call(this,r);let a=e(this,c)[r];if(h(this,o,S).call(this,a)?a.__abortController.abort(new Error("deleted")):(e(this,X)||e(this,D))&&(e(this,X)&&((h$1=e(this,H))==null||h$1.call(this,a,e$1,i$1)),e(this,D)&&e(this,T)?.push([a,e$1,i$1])),e(this,O).delete(e$1),e(this,b)[r]=void 0,e(this,c)[r]=void 0,r===e(this,E))g(this,E,e(this,G)[r]);else if(r===e(this,x))g(this,x,e(this,W)[r]);else {let u=e(this,G)[r];e(this,W)[u]=e(this,W)[r];let p=e(this,W)[r];e(this,G)[p]=e(this,G)[r];}i(this,F)._--,e(this,B).push(r);}}if(e(this,D)&&e(this,T)?.length){let r=e(this,T),a;for(;a=r?.shift();)(n=e(this,V))==null||n.call(this,...a);}return s},Ct=function(e$1){var i,s;for(let h$1 of h(this,o,it).call(this,{allowStale:true})){let n=e(this,c)[h$1];if(h(this,o,S).call(this,n))n.__abortController.abort(new Error("deleted"));else {let r=e(this,b)[h$1];e(this,X)&&((i=e(this,H))==null||i.call(this,n,r,e$1)),e(this,D)&&e(this,T)?.push([n,r,e$1]);}}if(e(this,O).clear(),e(this,c).fill(void 0),e(this,b).fill(void 0),e(this,M)&&e(this,q)){e(this,M).fill(0),e(this,q).fill(0);for(let h of e(this,j)??[])h!==void 0&&clearTimeout(h);e(this,j)?.fill(void 0);}if(e(this,$)&&e(this,$).fill(0),g(this,x,0),g(this,E,0),e(this,B).length=0,g(this,P,0),g(this,F,0),e(this,D)&&e(this,T)){let h=e(this,T),n;for(;n=h?.shift();)(s=e(this,V))==null||s.call(this,...n);}},wt);var Wt=class{constructor(e){d(this,"cache");d(this,"map",new Map);this.cache=new It({max:e.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(e){let i=this.map.delete(e);return i&&this.cache.delete(e),i}get forEach(){return this.map.forEach}get(e){let i=this.cache.get(e);return i||this.map.get(e)}has(e){return this.map.has(e)}set(e,i){return this.map.set(e,i),this.cache.set(e,i),this}get size(){return this.map.size}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}};export{Wt as a};