@drincs/pixi-vn 1.9.2 → 1.9.4
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/README.md +1 -1
- package/dist/{ContainerMemory-BpDgacyr.d.cts → ContainerMemory-DNqSVzLY.d.cts} +12 -116
- package/dist/{ContainerMemory-BpDgacyr.d.ts → ContainerMemory-DNqSVzLY.d.ts} +12 -116
- package/dist/canvas.cjs +2 -2
- package/dist/canvas.d.cts +1279 -551
- package/dist/canvas.d.ts +1279 -551
- package/dist/canvas.mjs +2 -2
- package/dist/characters.cjs +1 -1
- package/dist/characters.mjs +1 -1
- package/dist/{chunk-6GLWL3NH.mjs → chunk-5MVDNAT4.mjs} +1 -1
- package/dist/chunk-6OABTG5R.mjs +1 -0
- package/dist/chunk-AW5XWF24.mjs +1 -0
- package/dist/chunk-LXIKP2K5.mjs +1 -0
- package/dist/chunk-S7HZUIEI.mjs +1 -0
- package/dist/core.cjs +1 -1
- package/dist/core.d.cts +61 -5
- package/dist/core.d.ts +61 -5
- package/dist/core.mjs +1 -1
- package/dist/filters.cjs +1 -0
- package/dist/filters.d.cts +182 -0
- package/dist/filters.d.ts +182 -0
- package/dist/filters.mjs +1 -0
- package/dist/history.cjs +1 -1
- package/dist/history.d.cts +2 -2
- package/dist/history.d.ts +2 -2
- package/dist/history.mjs +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +43 -3
- package/dist/index.d.ts +43 -3
- package/dist/index.mjs +2 -2
- package/dist/motion.cjs +1 -1
- package/dist/motion.d.cts +30 -8
- package/dist/motion.d.ts +30 -8
- package/dist/motion.mjs +1 -1
- package/dist/narration.cjs +1 -1
- package/dist/narration.d.cts +2 -1
- package/dist/narration.d.ts +2 -1
- package/dist/narration.mjs +1 -1
- package/dist/pixi/browser.js +170 -169
- package/dist/sound.mjs +1 -1
- package/dist/storage.cjs +1 -1
- package/dist/storage.d.cts +1 -1
- package/dist/storage.d.ts +1 -1
- package/dist/storage.mjs +1 -1
- package/dist/tickers.cjs +1 -0
- package/dist/tickers.d.cts +555 -0
- package/dist/tickers.d.ts +555 -0
- package/dist/tickers.mjs +1 -0
- package/dist/vite.cjs +6 -4
- package/dist/vite.d.cts +64 -0
- package/dist/vite.d.ts +64 -0
- package/dist/vite.mjs +6 -4
- package/dist/worker.cjs +1 -0
- package/dist/worker.d.cts +153 -0
- package/dist/worker.d.ts +153 -0
- package/dist/worker.mjs +1 -0
- package/package.json +28 -1
- package/dist/chunk-HQQ5WH6C.mjs +0 -1
- package/dist/chunk-I7DOUH5V.mjs +0 -1
package/dist/sound.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {h}from'./chunk-HD353M4B.mjs';import {d,e,f as f$1}from'./chunk-HQQ5WH6C.mjs';import {GameUnifier,PixiError}from'@drincs/pixi-vn/core';import oe from'@drincs/pixi-vn/pixi.js';import*as p 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 ie;(s=>(s.mediaInstances=new Map,s.channels=new Map,s.transients=new Set,s.systemPausedAliases=new Set,s.bufferRegistry=new d({cacheSize:10})))(ie||={});var i=ie;function T(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 se(a){if(a)return Array.from(a).reduce((t,e$1)=>(e$1 instanceof Reverb?t.push({filterType:"ReverbFilter",wet:e$1.wet.value,decay:Time(e$1.decay).toSeconds(),preDelay:Time(e$1.preDelay).toSeconds()}):e$1 instanceof PingPongDelay?t.push({filterType:"PingPongDelayFilter",wet:e$1.wet.value,delayTime:e$1.delayTime.value,feedback:e$1.feedback.value}):e$1 instanceof FeedbackDelay?t.push({filterType:"FeedbackDelayFilter",feedback:e$1.feedback.value,delayTime:e$1.delayTime.value,wet:e$1.wet.value}):e$1 instanceof BitCrusher?t.push({filterType:"BitCrusherFilter",bits:e$1.bits.value,wet:e$1.wet.value}):e$1 instanceof Compressor?t.push({filterType:"CompressorFilter",attack:e$1.attack.value,knee:e$1.knee.value,ratio:e$1.ratio.value,release:e$1.release.value,threshold:e$1.threshold.value}):e$1 instanceof Delay?t.push({filterType:"DelayFilter",delayTime:e$1.delayTime.value,maxDelay:e$1.maxDelay}):e$1 instanceof Distortion?t.push({filterType:"DistortionFilter",distortion:e$1.distortion,oversample:e$1.oversample,wet:e$1.wet.value}):e$1 instanceof FeedbackCombFilter?t.push({filterType:"FeedbackCombFilterFilter",delayTime:e$1.delayTime.value,resonance:e$1.resonance.value}):e$1 instanceof Freeverb?t.push({filterType:"FreeverbFilter",roomSize:e$1.roomSize.value,dampening:e$1.dampening,wet:e$1.wet.value}):e$1 instanceof Gate?t.push({filterType:"GateFilter",threshold:e$1.threshold,smoothing:e$1.smoothing}):e$1 instanceof GreaterThan?t.push({filterType:"GreaterThanFilter",value:e$1.comparator.value,convert:e$1.convert,maxValue:e$1.maxValue,minValue:e$1.minValue}):e$1 instanceof GreaterThanZero?t.push({filterType:"GreaterThanZeroFilter"}):e$1 instanceof Limiter?t.push({filterType:"LimiterFilter",threshold:e$1.threshold.value}):e$1 instanceof MidSideCompressor?t.push({filterType:"MidSideCompressorFilter",mid:{attack:e$1.mid.attack.value,knee:e$1.mid.knee.value,ratio:e$1.mid.ratio.value,release:e$1.mid.release.value,threshold:e$1.mid.threshold.value},side:{attack:e$1.side.attack.value,knee:e$1.side.knee.value,ratio:e$1.side.ratio.value,release:e$1.side.release.value,threshold:e$1.side.threshold.value}}):e$1 instanceof MultibandCompressor?t.push({filterType:"MultibandCompressorFilter",lowFrequency:e$1.lowFrequency.value,highFrequency:e$1.highFrequency.value,low:{attack:e$1.low.attack.value,knee:e$1.low.knee.value,ratio:e$1.low.ratio.value,release:e$1.low.release.value,threshold:e$1.low.threshold.value},mid:{attack:e$1.mid.attack.value,knee:e$1.mid.knee.value,ratio:e$1.mid.ratio.value,release:e$1.mid.release.value,threshold:e$1.mid.threshold.value},high:{attack:e$1.high.attack.value,knee:e$1.high.knee.value,ratio:e$1.high.ratio.value,release:e$1.high.release.value,threshold:e$1.high.threshold.value}}):e$1 instanceof Panner3D?t.push({filterType:"Panner3DFilter",positionX:e$1.positionX.value,positionY:e$1.positionY.value,positionZ:e$1.positionZ.value,orientationX:e$1.orientationX.value,orientationY:e$1.orientationY.value,orientationZ:e$1.orientationZ.value,coneInnerAngle:e$1.coneInnerAngle,coneOuterAngle:e$1.coneOuterAngle,coneOuterGain:e$1.coneOuterGain,distanceModel:e$1.distanceModel,maxDistance:e$1.maxDistance,refDistance:e$1.refDistance,rolloffFactor:e$1.rolloffFactor,panningModel:e$1.panningModel}):e$1 instanceof Phaser?t.push({filterType:"PhaserFilter",frequency:e$1.frequency.value,octaves:e$1.octaves,baseFrequency:e$1.baseFrequency,wet:e$1.wet.value,Q:e$1.Q.value}):e$1 instanceof StereoWidener?t.push({filterType:"StereoWidenerFilter",width:e$1.width.value,wet:e$1.wet.value}):e$1 instanceof AutoFilter?t.push({filterType:"AutoFilterFilter",type:e$1.type,frequency:e$1.frequency.value,depth:e$1.depth.value,baseFrequency:e$1.baseFrequency,octaves:e$1.octaves,filter:{Q:e$1.filter.Q.value,type:e$1.filter.type,rolloff:e$1.filter.rolloff},wet:e$1.wet.value}):e$1 instanceof Chorus?t.push({filterType:"ChorusFilter",type:e$1.type,frequency:e$1.frequency.value,delayTime:e$1.delayTime,depth:e$1.depth,spread:e$1.spread,feedback:e$1.feedback.value,wet:e$1.wet.value}):e$1 instanceof Tremolo?t.push({filterType:"TremoloFilter",type:e$1.type,frequency:e$1.frequency.value,depth:e$1.depth.value,spread:e$1.spread,wet:e$1.wet.value}):e$1 instanceof Vibrato?t.push({filterType:"VibratoFilter",type:e$1.type,frequency:e$1.frequency.value,depth:e$1.depth.value,wet:e$1.wet.value}):e$1 instanceof AutoPanner?t.push({filterType:"AutoPannerFilter",type:e$1.type,frequency:e$1.frequency.value,depth:e$1.depth.value,channelCount:e$1.channelCount,wet:e$1.wet.value}):e$1 instanceof BiquadFilter?t.push({filterType:"BiquadFilterFilter",type:e$1.type,frequency:e$1.frequency.value,detune:e$1.detune.value,Q:e$1.Q.value,gain:e$1.gain.value}):e$1 instanceof OnePoleFilter?t.push({filterType:"OnePoleFilterFilter",type:e$1.type}):e$1 instanceof Filter?t.push({filterType:"CustomFilter",type:e$1.type,frequency:e$1.frequency.value,Q:e$1.Q.value,detune:e$1.detune.value,gain:e$1.gain.value,rolloff:e$1.rolloff}):e.warn(`Unsupported filter type for serialisation: ${e$1?.constructor?.name??e$1}, please report this to the developers if you encounter it.`),t),[])}function H(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 f(a){return a<=-1/0?0:10**(a/20)}async function w(a){if(i.bufferRegistry.has(a))return;let t=a;try{let e=oe.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$1){e.warn(`Failed to load audio buffer for "${a}" (url: "${t}"): ${e$1 instanceof Error?e$1.message:e$1}`),i.bufferRegistry.set(a,new ToneAudioBuffer);}}var v=class extends Player{constructor(e,n,r,s,o={},l){super(o);this.alias=e;this.channelAlias=n;this.soundAlias=r;this.stepCounter=s;this.delay=l;this.options=o,this.playStartTime=now()+(l??0);}alias;channelAlias;soundAlias;stepCounter;delay;options;filters=new Set;pausedAt=void 0;playStartTime=now();get memory(){let e=Math.max(0,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:f(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,s=false;typeof this.pausedAt=="number"&&(s=true,r=this.pausedAt-this.playStartTime,this.pausedAt=void 0),s&&n==="stopped"&&(this.delay?this.start(`+${this.delay}`,r):this.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)}start(e,n,r){let s=now(),o=s;if(typeof e=="number")o=e;else if(typeof e=="string"&&e.startsWith("+")){let c=Number(e.slice(1));Number.isNaN(c)||(o=s+c);}let l=typeof n=="number"?n:0;return this.playStartTime=o-l,super.start(e,n,r)}chain(...e){return e.forEach(n=>{H(n)&&(n.toDestination(),this.filters.add(n));}),super.chain(...e)}disconnect(e){return H(e)&&(e.disconnect(),this.filters.delete(e)),super.disconnect(e)}};var b=class{constructor(t,e={}){this.alias=t;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);}alias;toneChannel;get volume(){return f(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}background;_createPlayer(t,e$1,n={}){let r=i.bufferRegistry.get(e$1);if(!r)throw new PixiError("unregistered_asset",`Sound buffer for alias "${e$1}" is not loaded. Call sound.load() first.`);let{delay:s,elapsed:o,filters:l=[],muted:c,autostart:h=true,speed:d,volume:P,...y}=n;c!==void 0&&(e.warn(`MediaInstance "${t}" is being created with muted=${c}. This will override the channel's muted state (${this.muted}).`),y.mute=c),d!==void 0&&(e.warn(`MediaInstance "${t}" is being created with speed=${d}. This will override the default playback speed of 1.`),y.playbackRate=d);let I=new v(t,this.alias,e$1,GameUnifier.stepCounter,{...y,volume:P!==void 0?m(P):void 0,url:r},s).chain(...l,this.toneChannel),ee=o!==void 0?Math.max(0,o):void 0;return h&&(s?I.start(`+${s}`,ee):I.start(void 0,ee)),I}async play(t,e,n){let r,s;if(typeof e=="string"?(r=t,s=e):(r=t,s=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 w(s);let o=this._createPlayer(r,s,n);return i.mediaInstances.set(r,o),o}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{get volumeAll(){return f(p.getDestination().volume.value)}set volumeAll(t){p.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;}_speedAll=1;_defaultChannelAlias=h;get defaultChannelAlias(){return this._defaultChannelAlias}set defaultChannelAlias(t){this._defaultChannelAlias=t;}add(t,e){if(!i.bufferRegistry.has(t)){let n=new p.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 p.getDestination().mute}toggleMuteAll(){let t=!p.getDestination().mute;return p.getDestination().mute=t,t}muteAll(){return p.getDestination().mute=true,this}unmuteAll(){return p.getDestination().mute=false,this}stopAll(){for(let t of i.mediaInstances.values())t.stop();return i.mediaInstances.clear(),this}pauseUnsavedAllInternal(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();}}resumeUnsavedAllInternal(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);}stopTransientAllInternal(){for(let t of i.transients)t.stop();i.transients.clear();}async playTransientInternal(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,...s}=e??{},o=new p.Player({...s,url:n}).toDestination();return r&&o.start(),i.transients.add(o),o.onstop=()=>{o.dispose(),i.transients.delete(o);},o}unsaved={playTransient:(t,e)=>this.playTransientInternal(t,e),pauseAll:t=>(this.pauseUnsavedAllInternal(t),this.unsaved),resumeAll:t=>(this.resumeUnsavedAllInternal(t),this.unsaved),stopTransientAll:()=>(this.stopTransientAllInternal(),this.unsaved)};pauseUnsavedAll(t){return this.pauseUnsavedAllInternal(t),this}resumeUnsavedAll(t){return this.resumeUnsavedAllInternal(t),this}stopTransientAll(){return this.stopTransientAllInternal(),this}async play(t,e,n){let r,s;typeof e=="string"?(r=t,s=e):(r=t,s=t,n=e),i.bufferRegistry.has(s)||await this.load(s);let{channel:o=this.defaultChannelAlias,...l}=n??{};return await this.findChannelInternal(o).play(r,s,l)}async playTransient(t,e){return this.playTransientInternal(t,e)}find(t){return i.mediaInstances.get(t)}stop(t){let e$1=this.find(t);e$1?(e$1.stop(),i.mediaInstances.delete(t)):e.warn(`No media instance found with alias ${t} to stop.`);}pause(t){let e$1=this.find(t);if(!e$1){e.warn(`No media instance found with alias ${t} to pause.`);return}return e$1.paused=true,e$1}resume(t){let e$1=this.find(t);if(!e$1){e.warn(`No media instance found with alias ${t} to resume.`);return}return e$1.paused=false,e$1}duration(t){return i.bufferRegistry.get(t)?.duration??0}async load(...t){let e=t.map(w);await Promise.all(e);}backgroundLoad(...t){return this.load(...t).catch(e$1=>{e.error("Error background-loading sound",e$1);})}backgroundLoadBundle(t){let e$1=oe.Assets.backgroundLoadBundle(t);return e$1.then(async()=>{try{let n=await oe.Assets.loadBundle(t),r=[];for(let s in n)i.bufferRegistry.has(s)||r.push(this.load(s));await Promise.all(r);}catch(n){e.error("Error loading sound bundle",n);}}).catch(n=>{e.error("Error background-loading sound bundle",n);}),e$1}clear(){this.stopAll();}addChannelInternal(t,e$1={}){if(typeof t!="string"){t.forEach(r=>{let s={...e$1,filters:e$1.filters?[...e$1.filters]:e$1.filters};this.addChannelInternal(r,s);});return}if(i.channels.has(t)){e.warn(`Channel with alias ${t} already exists.`);return}let n=new b(t,e$1);return i.channels.set(t,n),n}findChannelInternal(t){let e=i.channels.get(t);return e||this.addChannelInternal(t)}channels={add:(t,e)=>this.addChannelInternal(t,e),find:t=>this.findChannelInternal(t),get values(){return Array.from(i.channels.values())}};addChannel(t,e={}){return this.channels.add(t,e)}findChannel(t){return this.channels.find(t)}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:se(r.filters)}},e),{});return {mediaInstances:f$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$1=t.mediaInstances;if(e$1){let n=new Set,r=Object.values(e$1).map(async({soundAlias:o,channelAlias:l})=>(n.add(l),await this.load(o)));await Promise.all(r),this.channels.values.forEach(o=>{(!o.background||!n.has(o.alias))&&o.stopAll();});let s=Object.keys(e$1).map(async o=>{let l=e$1[o],c=this.findChannelInternal(l.channelAlias),h=l.options.paused??l.paused??!1;if(c.background)if(l.stepCounter===GameUnifier.stepCounter||!this.find(o)){let d=await c.play(o,l.soundAlias,{...l.options,autostart:!h,filters:T(l.options.filters||[]),delay:l.options.delay});d.paused=h;}else {let d=i.mediaInstances.get(o);if(!d){e.warn(`No media instance found with alias ${o} while restoring background state.`);return}d.memory={...l.options,paused:h},[...d.filters].forEach(y=>{d.disconnect(y),y.dispose();}),d.chain(...T(l.options.filters||[]));}else {let d=await c.play(o,l.soundAlias,{...l.options,autostart:!h,filters:T(l.options.filters||[]),delay:l.options.delay});d.paused=h;}});await Promise.all(s);}}}catch(e$1){e.error("Error importing data",e$1);}}};var K=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?K.muted||(K.muteAll(),a=true):a&&(K.unmuteAll(),a=false);});}export{i as SoundRegistry,K as sound};
|
|
1
|
+
import {h}from'./chunk-HD353M4B.mjs';import {a}from'./chunk-S7HZUIEI.mjs';import {d,e}from'./chunk-AW5XWF24.mjs';import {GameUnifier,PixiError}from'@drincs/pixi-vn/core';import oe from'@drincs/pixi-vn/pixi.js';import*as p 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 ie;(s=>(s.mediaInstances=new Map,s.channels=new Map,s.transients=new Set,s.systemPausedAliases=new Set,s.bufferRegistry=new d({cacheSize:10})))(ie||={});var i=ie;function T(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 se(a){if(a)return Array.from(a).reduce((t,e$1)=>(e$1 instanceof Reverb?t.push({filterType:"ReverbFilter",wet:e$1.wet.value,decay:Time(e$1.decay).toSeconds(),preDelay:Time(e$1.preDelay).toSeconds()}):e$1 instanceof PingPongDelay?t.push({filterType:"PingPongDelayFilter",wet:e$1.wet.value,delayTime:e$1.delayTime.value,feedback:e$1.feedback.value}):e$1 instanceof FeedbackDelay?t.push({filterType:"FeedbackDelayFilter",feedback:e$1.feedback.value,delayTime:e$1.delayTime.value,wet:e$1.wet.value}):e$1 instanceof BitCrusher?t.push({filterType:"BitCrusherFilter",bits:e$1.bits.value,wet:e$1.wet.value}):e$1 instanceof Compressor?t.push({filterType:"CompressorFilter",attack:e$1.attack.value,knee:e$1.knee.value,ratio:e$1.ratio.value,release:e$1.release.value,threshold:e$1.threshold.value}):e$1 instanceof Delay?t.push({filterType:"DelayFilter",delayTime:e$1.delayTime.value,maxDelay:e$1.maxDelay}):e$1 instanceof Distortion?t.push({filterType:"DistortionFilter",distortion:e$1.distortion,oversample:e$1.oversample,wet:e$1.wet.value}):e$1 instanceof FeedbackCombFilter?t.push({filterType:"FeedbackCombFilterFilter",delayTime:e$1.delayTime.value,resonance:e$1.resonance.value}):e$1 instanceof Freeverb?t.push({filterType:"FreeverbFilter",roomSize:e$1.roomSize.value,dampening:e$1.dampening,wet:e$1.wet.value}):e$1 instanceof Gate?t.push({filterType:"GateFilter",threshold:e$1.threshold,smoothing:e$1.smoothing}):e$1 instanceof GreaterThan?t.push({filterType:"GreaterThanFilter",value:e$1.comparator.value,convert:e$1.convert,maxValue:e$1.maxValue,minValue:e$1.minValue}):e$1 instanceof GreaterThanZero?t.push({filterType:"GreaterThanZeroFilter"}):e$1 instanceof Limiter?t.push({filterType:"LimiterFilter",threshold:e$1.threshold.value}):e$1 instanceof MidSideCompressor?t.push({filterType:"MidSideCompressorFilter",mid:{attack:e$1.mid.attack.value,knee:e$1.mid.knee.value,ratio:e$1.mid.ratio.value,release:e$1.mid.release.value,threshold:e$1.mid.threshold.value},side:{attack:e$1.side.attack.value,knee:e$1.side.knee.value,ratio:e$1.side.ratio.value,release:e$1.side.release.value,threshold:e$1.side.threshold.value}}):e$1 instanceof MultibandCompressor?t.push({filterType:"MultibandCompressorFilter",lowFrequency:e$1.lowFrequency.value,highFrequency:e$1.highFrequency.value,low:{attack:e$1.low.attack.value,knee:e$1.low.knee.value,ratio:e$1.low.ratio.value,release:e$1.low.release.value,threshold:e$1.low.threshold.value},mid:{attack:e$1.mid.attack.value,knee:e$1.mid.knee.value,ratio:e$1.mid.ratio.value,release:e$1.mid.release.value,threshold:e$1.mid.threshold.value},high:{attack:e$1.high.attack.value,knee:e$1.high.knee.value,ratio:e$1.high.ratio.value,release:e$1.high.release.value,threshold:e$1.high.threshold.value}}):e$1 instanceof Panner3D?t.push({filterType:"Panner3DFilter",positionX:e$1.positionX.value,positionY:e$1.positionY.value,positionZ:e$1.positionZ.value,orientationX:e$1.orientationX.value,orientationY:e$1.orientationY.value,orientationZ:e$1.orientationZ.value,coneInnerAngle:e$1.coneInnerAngle,coneOuterAngle:e$1.coneOuterAngle,coneOuterGain:e$1.coneOuterGain,distanceModel:e$1.distanceModel,maxDistance:e$1.maxDistance,refDistance:e$1.refDistance,rolloffFactor:e$1.rolloffFactor,panningModel:e$1.panningModel}):e$1 instanceof Phaser?t.push({filterType:"PhaserFilter",frequency:e$1.frequency.value,octaves:e$1.octaves,baseFrequency:e$1.baseFrequency,wet:e$1.wet.value,Q:e$1.Q.value}):e$1 instanceof StereoWidener?t.push({filterType:"StereoWidenerFilter",width:e$1.width.value,wet:e$1.wet.value}):e$1 instanceof AutoFilter?t.push({filterType:"AutoFilterFilter",type:e$1.type,frequency:e$1.frequency.value,depth:e$1.depth.value,baseFrequency:e$1.baseFrequency,octaves:e$1.octaves,filter:{Q:e$1.filter.Q.value,type:e$1.filter.type,rolloff:e$1.filter.rolloff},wet:e$1.wet.value}):e$1 instanceof Chorus?t.push({filterType:"ChorusFilter",type:e$1.type,frequency:e$1.frequency.value,delayTime:e$1.delayTime,depth:e$1.depth,spread:e$1.spread,feedback:e$1.feedback.value,wet:e$1.wet.value}):e$1 instanceof Tremolo?t.push({filterType:"TremoloFilter",type:e$1.type,frequency:e$1.frequency.value,depth:e$1.depth.value,spread:e$1.spread,wet:e$1.wet.value}):e$1 instanceof Vibrato?t.push({filterType:"VibratoFilter",type:e$1.type,frequency:e$1.frequency.value,depth:e$1.depth.value,wet:e$1.wet.value}):e$1 instanceof AutoPanner?t.push({filterType:"AutoPannerFilter",type:e$1.type,frequency:e$1.frequency.value,depth:e$1.depth.value,channelCount:e$1.channelCount,wet:e$1.wet.value}):e$1 instanceof BiquadFilter?t.push({filterType:"BiquadFilterFilter",type:e$1.type,frequency:e$1.frequency.value,detune:e$1.detune.value,Q:e$1.Q.value,gain:e$1.gain.value}):e$1 instanceof OnePoleFilter?t.push({filterType:"OnePoleFilterFilter",type:e$1.type}):e$1 instanceof Filter?t.push({filterType:"CustomFilter",type:e$1.type,frequency:e$1.frequency.value,Q:e$1.Q.value,detune:e$1.detune.value,gain:e$1.gain.value,rolloff:e$1.rolloff}):e.warn(`Unsupported filter type for serialisation: ${e$1?.constructor?.name??e$1}, please report this to the developers if you encounter it.`),t),[])}function H(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 f(a){return a<=-1/0?0:10**(a/20)}async function w(a){if(i.bufferRegistry.has(a))return;let t=a;try{let e=oe.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$1){e.warn(`Failed to load audio buffer for "${a}" (url: "${t}"): ${e$1 instanceof Error?e$1.message:e$1}`),i.bufferRegistry.set(a,new ToneAudioBuffer);}}var v=class extends Player{constructor(e,n,r,s,o={},l){super(o);this.alias=e;this.channelAlias=n;this.soundAlias=r;this.stepCounter=s;this.delay=l;this.options=o,this.playStartTime=now()+(l??0);}alias;channelAlias;soundAlias;stepCounter;delay;options;filters=new Set;pausedAt=void 0;playStartTime=now();get memory(){let e=Math.max(0,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:f(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,s=false;typeof this.pausedAt=="number"&&(s=true,r=this.pausedAt-this.playStartTime,this.pausedAt=void 0),s&&n==="stopped"&&(this.delay?this.start(`+${this.delay}`,r):this.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)}start(e,n,r){let s=now(),o=s;if(typeof e=="number")o=e;else if(typeof e=="string"&&e.startsWith("+")){let c=Number(e.slice(1));Number.isNaN(c)||(o=s+c);}let l=typeof n=="number"?n:0;return this.playStartTime=o-l,super.start(e,n,r)}chain(...e){return e.forEach(n=>{H(n)&&(n.toDestination(),this.filters.add(n));}),super.chain(...e)}disconnect(e){return H(e)&&(e.disconnect(),this.filters.delete(e)),super.disconnect(e)}};var b=class{constructor(t,e={}){this.alias=t;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);}alias;toneChannel;get volume(){return f(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}background;_createPlayer(t,e$1,n={}){let r=i.bufferRegistry.get(e$1);if(!r)throw new PixiError("unregistered_asset",`Sound buffer for alias "${e$1}" is not loaded. Call sound.load() first.`);let{delay:s,elapsed:o,filters:l=[],muted:c,autostart:h=true,speed:d,volume:P,...y}=n;c!==void 0&&(e.warn(`MediaInstance "${t}" is being created with muted=${c}. This will override the channel's muted state (${this.muted}).`),y.mute=c),d!==void 0&&(e.warn(`MediaInstance "${t}" is being created with speed=${d}. This will override the default playback speed of 1.`),y.playbackRate=d);let I=new v(t,this.alias,e$1,GameUnifier.stepCounter,{...y,volume:P!==void 0?m(P):void 0,url:r},s).chain(...l,this.toneChannel),ee=o!==void 0?Math.max(0,o):void 0;return h&&(s?I.start(`+${s}`,ee):I.start(void 0,ee)),I}async play(t,e,n){let r,s;if(typeof e=="string"?(r=t,s=e):(r=t,s=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 w(s);let o=this._createPlayer(r,s,n);return i.mediaInstances.set(r,o),o}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{get volumeAll(){return f(p.getDestination().volume.value)}set volumeAll(t){p.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;}_speedAll=1;_defaultChannelAlias=h;get defaultChannelAlias(){return this._defaultChannelAlias}set defaultChannelAlias(t){this._defaultChannelAlias=t;}add(t,e){if(!i.bufferRegistry.has(t)){let n=new p.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 p.getDestination().mute}toggleMuteAll(){let t=!p.getDestination().mute;return p.getDestination().mute=t,t}muteAll(){return p.getDestination().mute=true,this}unmuteAll(){return p.getDestination().mute=false,this}stopAll(){for(let t of i.mediaInstances.values())t.stop();return i.mediaInstances.clear(),this}pauseUnsavedAllInternal(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();}}resumeUnsavedAllInternal(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);}stopTransientAllInternal(){for(let t of i.transients)t.stop();i.transients.clear();}async playTransientInternal(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,...s}=e??{},o=new p.Player({...s,url:n}).toDestination();return r&&o.start(),i.transients.add(o),o.onstop=()=>{o.dispose(),i.transients.delete(o);},o}unsaved={playTransient:(t,e)=>this.playTransientInternal(t,e),pauseAll:t=>(this.pauseUnsavedAllInternal(t),this.unsaved),resumeAll:t=>(this.resumeUnsavedAllInternal(t),this.unsaved),stopTransientAll:()=>(this.stopTransientAllInternal(),this.unsaved)};pauseUnsavedAll(t){return this.pauseUnsavedAllInternal(t),this}resumeUnsavedAll(t){return this.resumeUnsavedAllInternal(t),this}stopTransientAll(){return this.stopTransientAllInternal(),this}async play(t,e,n){let r,s;typeof e=="string"?(r=t,s=e):(r=t,s=t,n=e),i.bufferRegistry.has(s)||await this.load(s);let{channel:o=this.defaultChannelAlias,...l}=n??{};return await this.findChannelInternal(o).play(r,s,l)}async playTransient(t,e){return this.playTransientInternal(t,e)}find(t){return i.mediaInstances.get(t)}stop(t){let e$1=this.find(t);e$1?(e$1.stop(),i.mediaInstances.delete(t)):e.warn(`No media instance found with alias ${t} to stop.`);}pause(t){let e$1=this.find(t);if(!e$1){e.warn(`No media instance found with alias ${t} to pause.`);return}return e$1.paused=true,e$1}resume(t){let e$1=this.find(t);if(!e$1){e.warn(`No media instance found with alias ${t} to resume.`);return}return e$1.paused=false,e$1}duration(t){return i.bufferRegistry.get(t)?.duration??0}async load(...t){let e=t.map(w);await Promise.all(e);}backgroundLoad(...t){return this.load(...t).catch(e$1=>{e.error("Error background-loading sound",e$1);})}backgroundLoadBundle(t){let e$1=oe.Assets.backgroundLoadBundle(t);return e$1.then(async()=>{try{let n=await oe.Assets.loadBundle(t),r=[];for(let s in n)i.bufferRegistry.has(s)||r.push(this.load(s));await Promise.all(r);}catch(n){e.error("Error loading sound bundle",n);}}).catch(n=>{e.error("Error background-loading sound bundle",n);}),e$1}clear(){this.stopAll();}addChannelInternal(t,e$1={}){if(typeof t!="string"){t.forEach(r=>{let s={...e$1,filters:e$1.filters?[...e$1.filters]:e$1.filters};this.addChannelInternal(r,s);});return}if(i.channels.has(t)){e.warn(`Channel with alias ${t} already exists.`);return}let n=new b(t,e$1);return i.channels.set(t,n),n}findChannelInternal(t){let e=i.channels.get(t);return e||this.addChannelInternal(t)}channels={add:(t,e)=>this.addChannelInternal(t,e),find:t=>this.findChannelInternal(t),get values(){return Array.from(i.channels.values())}};addChannel(t,e={}){return this.channels.add(t,e)}findChannel(t){return this.channels.find(t)}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:se(r.filters)}},e),{});return {mediaInstances:a(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$1=t.mediaInstances;if(e$1){let n=new Set,r=Object.values(e$1).map(async({soundAlias:o,channelAlias:l})=>(n.add(l),await this.load(o)));await Promise.all(r),this.channels.values.forEach(o=>{(!o.background||!n.has(o.alias))&&o.stopAll();});let s=Object.keys(e$1).map(async o=>{let l=e$1[o],c=this.findChannelInternal(l.channelAlias),h=l.options.paused??l.paused??!1;if(c.background)if(l.stepCounter===GameUnifier.stepCounter||!this.find(o)){let d=await c.play(o,l.soundAlias,{...l.options,autostart:!h,filters:T(l.options.filters||[]),delay:l.options.delay});d.paused=h;}else {let d=i.mediaInstances.get(o);if(!d){e.warn(`No media instance found with alias ${o} while restoring background state.`);return}d.memory={...l.options,paused:h},[...d.filters].forEach(y=>{d.disconnect(y),y.dispose();}),d.chain(...T(l.options.filters||[]));}else {let d=await c.play(o,l.soundAlias,{...l.options,autostart:!h,filters:T(l.options.filters||[]),delay:l.options.delay});d.paused=h;}});await Promise.all(s);}}}catch(e$1){e.error("Error importing data",e$1);}}};var K=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?K.muted||(K.muteAll(),a=true):a&&(K.unmuteAll(),a=false);});}export{i as SoundRegistry,K as sound};
|
package/dist/storage.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var core=require('@drincs/pixi-vn/core');var te=Object.defineProperty;var Ht=f=>{throw TypeError(f)};var ee=(f,e,i)=>e in f?te(f,e,{enumerable:true,configurable:true,writable:true,value:i}):f[e]=i;var D=(f,e,i)=>ee(f,typeof e!="symbol"?e+"":e,i),Ut=(f,e,i)=>e.has(f)||Ht("Cannot "+i);var t=(f,e,i)=>(Ut(f,e,"read from private field"),i?i.call(f):e.get(f)),d=(f,e,i)=>e.has(f)?Ht("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(f):e.set(f,i),u=(f,e,i,s)=>(Ut(f,e,"write to private field"),e.set(f,i),i),l=(f,e,i)=>(Ut(f,e,"access private method"),i);var Nt=(f,e,i,s)=>({set _(r){u(f,e,r);},get _(){return t(f,e,s)}});var st="storage",ht="temp",H="narration",Ft="flags",j={CURRENT_DIALOGUE_MEMORY_KEY:"dialogue",LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY:"dialogue:step_counter",CURRENT_MENU_OPTIONS_MEMORY_KEY:"choice:options",LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY:"choice:step_counter",CURRENT_INPUT_VALUE_MEMORY_KEY:"input:value",LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY:"input:step_counter",CURRENT_INPUT_INFO_MEMORY_KEY:"input:info",CHARACTER_CATEGORY_KEY:"character",ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY:"___glue___",OPENED_LABELS_COUNTER_KEY:"label:opened",ALL_CHOICES_MADE_KEY:"choices:made",CURRENT_STEP_TIMES_COUNTER_KEY:"label:history",LAST_STEP_GLUED:"glue:last_step"};var ie=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Bt=new Set,zt=typeof process=="object"&&process?process:{},Xt=(f,e,i,s)=>{typeof zt.emitWarning=="function"?zt.emitWarning(f,e,i,s):console.error(`[${i}] ${e}: ${f}`);},Gt=globalThis.AbortController,jt=globalThis.AbortSignal;if(typeof Gt>"u"){jt=class{onabort;_onabort=[];reason;aborted=false;addEventListener(i,s){this._onabort.push(s);}},Gt=class{constructor(){e();}signal=new jt;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 f=zt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{f&&(f=false,Xt("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 se=f=>!Bt.has(f);var rt=f=>f&&f===Math.floor(f)&&f>0&&isFinite(f),Jt=f=>rt(f)?f<=Math.pow(2,8)?Uint8Array:f<=Math.pow(2,16)?Uint16Array:f<=Math.pow(2,32)?Uint32Array:f<=Number.MAX_SAFE_INTEGER?Dt:null:null,Dt=class extends Array{constructor(f){super(f),this.fill(0);}},et,dt,re=(et=class{heap;length;static create(e){let i=Jt(e);if(!i)return [];u(et,dt,true);let s=new et(e,i);return u(et,dt,false),s}constructor(e,i){if(!t(et,dt))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new i(e),this.length=0;}push(e){this.heap[this.length++]=e;}pop(){return this.heap[--this.length]}},dt=new WeakMap,d(et,dt,false),et),$t,kt,$,z,k,ct,B,mt,St,X,R,J,x,O,g,L,Y,C,N,q,F,Q,Z,K,P,tt,lt,V,Et,n,Yt,ft,it,wt,W,Qt,ut,Tt,xt,at,ot,Kt,Ct,Mt,v,Pt,Ot,nt,Wt,bt,qt=(bt=class{constructor(e){d(this,n);d(this,$);d(this,z);d(this,k);d(this,ct);d(this,B);d(this,mt);d(this,St);d(this,X);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");d(this,R);d(this,J);d(this,x);d(this,O);d(this,g);d(this,L);d(this,Y);d(this,C);d(this,N);d(this,q);d(this,F);d(this,Q);d(this,Z);d(this,K);d(this,P);d(this,tt);d(this,lt);d(this,V);d(this,Et);d(this,ft,()=>{});d(this,it,()=>{});d(this,wt,()=>{});d(this,W,()=>false);d(this,ut,e=>{});d(this,Tt,(e,i,s)=>{});d(this,xt,(e,i,s,r)=>{if(s||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});D(this,$t,"LRUCache");let{max:i=0,ttl:s,ttlResolution:r=1,ttlAutopurge:o,updateAgeOnGet:a,updateAgeOnHas:h,allowStale:c,dispose:S,onInsert:I,disposeAfter:p,noDisposeOnSet:b,noUpdateTTL:T,maxSize:E=0,maxEntrySize:y=0,sizeCalculation:A,fetchMethod:_,memoMethod:M,noDeleteOnFetchRejection:U,noDeleteOnStaleGet:G,allowStaleOnFetchRejection:w,allowStaleOnFetchAbort:vt,ignoreFetchAbort:gt,perf:pt}=e;if(pt!==void 0&&typeof pt?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(u(this,X,pt??ie),i!==0&&!rt(i))throw new TypeError("max option must be a nonnegative integer");let _t=i?Jt(i):Array;if(!_t)throw new Error("invalid max value: "+i);if(u(this,$,i),u(this,z,E),this.maxEntrySize=y||t(this,z),this.sizeCalculation=A,this.sizeCalculation){if(!t(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(M!==void 0&&typeof M!="function")throw new TypeError("memoMethod must be a function if defined");if(u(this,St,M),_!==void 0&&typeof _!="function")throw new TypeError("fetchMethod must be a function if specified");if(u(this,mt,_),u(this,lt,!!_),u(this,x,new Map),u(this,O,new Array(i).fill(void 0)),u(this,g,new Array(i).fill(void 0)),u(this,L,new _t(i)),u(this,Y,new _t(i)),u(this,C,0),u(this,N,0),u(this,q,re.create(i)),u(this,R,0),u(this,J,0),typeof S=="function"&&u(this,k,S),typeof I=="function"&&u(this,ct,I),typeof p=="function"?(u(this,B,p),u(this,F,[])):(u(this,B,void 0),u(this,F,void 0)),u(this,tt,!!t(this,k)),u(this,Et,!!t(this,ct)),u(this,V,!!t(this,B)),this.noDisposeOnSet=!!b,this.noUpdateTTL=!!T,this.noDeleteOnFetchRejection=!!U,this.allowStaleOnFetchRejection=!!w,this.allowStaleOnFetchAbort=!!vt,this.ignoreFetchAbort=!!gt,this.maxEntrySize!==0){if(t(this,z)!==0&&!rt(t(this,z)))throw new TypeError("maxSize must be a positive integer if specified");if(!rt(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");l(this,n,Qt).call(this);}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!G,this.updateAgeOnGet=!!a,this.updateAgeOnHas=!!h,this.ttlResolution=rt(r)||r===0?r:1,this.ttlAutopurge=!!o,this.ttl=s||0,this.ttl){if(!rt(this.ttl))throw new TypeError("ttl must be a positive integer if specified");l(this,n,Yt).call(this);}if(t(this,$)===0&&this.ttl===0&&t(this,z)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!t(this,$)&&!t(this,z)){let Vt="LRU_CACHE_UNBOUNDED";se(Vt)&&(Bt.add(Vt),Xt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Vt,bt));}}get perf(){return t(this,X)}static unsafeExposeInternals(e){return {starts:t(e,Z),ttls:t(e,K),autopurgeTimers:t(e,P),sizes:t(e,Q),keyMap:t(e,x),keyList:t(e,O),valList:t(e,g),next:t(e,L),prev:t(e,Y),get head(){return t(e,C)},get tail(){return t(e,N)},free:t(e,q),isBackgroundFetch:i=>{var s;return l(s=e,n,v).call(s,i)},backgroundFetch:(i,s,r,o)=>{var a;return l(a=e,n,Mt).call(a,i,s,r,o)},moveToTail:i=>{var s;return l(s=e,n,Ot).call(s,i)},indexes:i=>{var s;return l(s=e,n,at).call(s,i)},rindexes:i=>{var s;return l(s=e,n,ot).call(s,i)},isStale:i=>{var s;return t(s=e,W).call(s,i)}}}get max(){return t(this,$)}get maxSize(){return t(this,z)}get calculatedSize(){return t(this,J)}get size(){return t(this,R)}get fetchMethod(){return t(this,mt)}get memoMethod(){return t(this,St)}get dispose(){return t(this,k)}get onInsert(){return t(this,ct)}get disposeAfter(){return t(this,B)}getRemainingTTL(e){return t(this,x).has(e)?1/0:0}*entries(){for(let e of l(this,n,at).call(this))t(this,g)[e]!==void 0&&t(this,O)[e]!==void 0&&!l(this,n,v).call(this,t(this,g)[e])&&(yield [t(this,O)[e],t(this,g)[e]]);}*rentries(){for(let e of l(this,n,ot).call(this))t(this,g)[e]!==void 0&&t(this,O)[e]!==void 0&&!l(this,n,v).call(this,t(this,g)[e])&&(yield [t(this,O)[e],t(this,g)[e]]);}*keys(){for(let e of l(this,n,at).call(this)){let i=t(this,O)[e];i!==void 0&&!l(this,n,v).call(this,t(this,g)[e])&&(yield i);}}*rkeys(){for(let e of l(this,n,ot).call(this)){let i=t(this,O)[e];i!==void 0&&!l(this,n,v).call(this,t(this,g)[e])&&(yield i);}}*values(){for(let e of l(this,n,at).call(this))t(this,g)[e]!==void 0&&!l(this,n,v).call(this,t(this,g)[e])&&(yield t(this,g)[e]);}*rvalues(){for(let e of l(this,n,ot).call(this))t(this,g)[e]!==void 0&&!l(this,n,v).call(this,t(this,g)[e])&&(yield t(this,g)[e]);}[(kt=Symbol.iterator,$t=Symbol.toStringTag,kt)](){return this.entries()}find(e,i={}){for(let s of l(this,n,at).call(this)){let r=t(this,g)[s],o=l(this,n,v).call(this,r)?r.__staleWhileFetching:r;if(o!==void 0&&e(o,t(this,O)[s],this))return this.get(t(this,O)[s],i)}}forEach(e,i=this){for(let s of l(this,n,at).call(this)){let r=t(this,g)[s],o=l(this,n,v).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&e.call(i,o,t(this,O)[s],this);}}rforEach(e,i=this){for(let s of l(this,n,ot).call(this)){let r=t(this,g)[s],o=l(this,n,v).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&e.call(i,o,t(this,O)[s],this);}}purgeStale(){let e=false;for(let i of l(this,n,ot).call(this,{allowStale:true}))t(this,W).call(this,i)&&(l(this,n,nt).call(this,t(this,O)[i],"expire"),e=true);return e}info(e){let i=t(this,x).get(e);if(i===void 0)return;let s=t(this,g)[i],r=l(this,n,v).call(this,s)?s.__staleWhileFetching:s;if(r===void 0)return;let o={value:r};if(t(this,K)&&t(this,Z)){let a=t(this,K)[i],h=t(this,Z)[i];if(a&&h){let c=a-(t(this,X).now()-h);o.ttl=c,o.start=Date.now();}}return t(this,Q)&&(o.size=t(this,Q)[i]),o}dump(){let e=[];for(let i of l(this,n,at).call(this,{allowStale:true})){let s=t(this,O)[i],r=t(this,g)[i],o=l(this,n,v).call(this,r)?r.__staleWhileFetching:r;if(o===void 0||s===void 0)continue;let a={value:o};if(t(this,K)&&t(this,Z)){a.ttl=t(this,K)[i];let h=t(this,X).now()-t(this,Z)[i];a.start=Math.floor(Date.now()-h);}t(this,Q)&&(a.size=t(this,Q)[i]),e.unshift([s,a]);}return e}load(e){this.clear();for(let[i,s]of e){if(s.start){let r=Date.now()-s.start;s.start=t(this,X).now()-r;}this.set(i,s.value,s);}}set(e,i,s={}){var b,T,E,y;if(i===void 0)return this.delete(e),this;let{ttl:r=this.ttl,start:o,noDisposeOnSet:a=this.noDisposeOnSet,sizeCalculation:h=this.sizeCalculation,status:c}=s,{noUpdateTTL:S=this.noUpdateTTL}=s,I=t(this,xt).call(this,e,i,s.size||0,h);if(this.maxEntrySize&&I>this.maxEntrySize)return c&&(c.set="miss",c.maxEntrySizeExceeded=true),l(this,n,nt).call(this,e,"set"),this;let p=t(this,R)===0?void 0:t(this,x).get(e);if(p===void 0)p=t(this,R)===0?t(this,N):t(this,q).length!==0?t(this,q).pop():t(this,R)===t(this,$)?l(this,n,Ct).call(this,false):t(this,R),t(this,O)[p]=e,t(this,g)[p]=i,t(this,x).set(e,p),t(this,L)[t(this,N)]=p,t(this,Y)[p]=t(this,N),u(this,N,p),Nt(this,R)._++,t(this,Tt).call(this,p,I,c),c&&(c.set="add"),S=false,t(this,Et)&&((b=t(this,ct))==null||b.call(this,i,e,"add"));else {l(this,n,Ot).call(this,p);let A=t(this,g)[p];if(i!==A){if(t(this,lt)&&l(this,n,v).call(this,A)){A.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:_}=A;_!==void 0&&!a&&(t(this,tt)&&((T=t(this,k))==null||T.call(this,_,e,"set")),t(this,V)&&t(this,F)?.push([_,e,"set"]));}else a||(t(this,tt)&&((E=t(this,k))==null||E.call(this,A,e,"set")),t(this,V)&&t(this,F)?.push([A,e,"set"]));if(t(this,ut).call(this,p),t(this,Tt).call(this,p,I,c),t(this,g)[p]=i,c){c.set="replace";let _=A&&l(this,n,v).call(this,A)?A.__staleWhileFetching:A;_!==void 0&&(c.oldValue=_);}}else c&&(c.set="update");t(this,Et)&&this.onInsert?.(i,e,i===A?"update":"replace");}if(r!==0&&!t(this,K)&&l(this,n,Yt).call(this),t(this,K)&&(S||t(this,wt).call(this,p,r,o),c&&t(this,it).call(this,c,p)),!a&&t(this,V)&&t(this,F)){let A=t(this,F),_;for(;_=A?.shift();)(y=t(this,B))==null||y.call(this,..._);}return this}pop(){var e;try{for(;t(this,R);){let i=t(this,g)[t(this,C)];if(l(this,n,Ct).call(this,!0),l(this,n,v).call(this,i)){if(i.__staleWhileFetching)return i.__staleWhileFetching}else if(i!==void 0)return i}}finally{if(t(this,V)&&t(this,F)){let i=t(this,F),s;for(;s=i?.shift();)(e=t(this,B))==null||e.call(this,...s);}}}has(e,i={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:r}=i,o=t(this,x).get(e);if(o!==void 0){let a=t(this,g)[o];if(l(this,n,v).call(this,a)&&a.__staleWhileFetching===void 0)return false;if(t(this,W).call(this,o))r&&(r.has="stale",t(this,it).call(this,r,o));else return s&&t(this,ft).call(this,o),r&&(r.has="hit",t(this,it).call(this,r,o)),true}else r&&(r.has="miss");return false}peek(e,i={}){let{allowStale:s=this.allowStale}=i,r=t(this,x).get(e);if(r===void 0||!s&&t(this,W).call(this,r))return;let o=t(this,g)[r];return l(this,n,v).call(this,o)?o.__staleWhileFetching:o}async fetch(e,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:a=this.ttl,noDisposeOnSet:h=this.noDisposeOnSet,size:c=0,sizeCalculation:S=this.sizeCalculation,noUpdateTTL:I=this.noUpdateTTL,noDeleteOnFetchRejection:p=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:b=this.allowStaleOnFetchRejection,ignoreFetchAbort:T=this.ignoreFetchAbort,allowStaleOnFetchAbort:E=this.allowStaleOnFetchAbort,context:y,forceRefresh:A=false,status:_,signal:M}=i;if(!t(this,lt))return _&&(_.fetch="get"),this.get(e,{allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,status:_});let U={allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,ttl:a,noDisposeOnSet:h,size:c,sizeCalculation:S,noUpdateTTL:I,noDeleteOnFetchRejection:p,allowStaleOnFetchRejection:b,allowStaleOnFetchAbort:E,ignoreFetchAbort:T,status:_,signal:M},G=t(this,x).get(e);if(G===void 0){_&&(_.fetch="miss");let w=l(this,n,Mt).call(this,e,G,U,y);return w.__returned=w}else {let w=t(this,g)[G];if(l(this,n,v).call(this,w)){let _t=s&&w.__staleWhileFetching!==void 0;return _&&(_.fetch="inflight",_t&&(_.returnedStale=true)),_t?w.__staleWhileFetching:w.__returned=w}let vt=t(this,W).call(this,G);if(!A&&!vt)return _&&(_.fetch="hit"),l(this,n,Ot).call(this,G),r&&t(this,ft).call(this,G),_&&t(this,it).call(this,_,G),w;let gt=l(this,n,Mt).call(this,e,G,U,y),pt=gt.__staleWhileFetching!==void 0&&s;return _&&(_.fetch=vt?"stale":"refresh",pt&&vt&&(_.returnedStale=true)),pt?gt.__staleWhileFetching:gt.__returned=gt}}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,i={}){let s=t(this,St);if(!s)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:o,...a}=i,h=this.get(e,a);if(!o&&h!==void 0)return h;let c=s(e,h,{options:a,context:r});return this.set(e,c,a),c}get(e,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:a}=i,h=t(this,x).get(e);if(h!==void 0){let c=t(this,g)[h],S=l(this,n,v).call(this,c);return a&&t(this,it).call(this,a,h),t(this,W).call(this,h)?(a&&(a.get="stale"),S?(a&&s&&c.__staleWhileFetching!==void 0&&(a.returnedStale=true),s?c.__staleWhileFetching:void 0):(o||l(this,n,nt).call(this,e,"expire"),a&&s&&(a.returnedStale=true),s?c:void 0)):(a&&(a.get="hit"),S?c.__staleWhileFetching:(l(this,n,Ot).call(this,h),r&&t(this,ft).call(this,h),c))}else a&&(a.get="miss");}delete(e){return l(this,n,nt).call(this,e,"delete")}clear(){return l(this,n,Wt).call(this,"delete")}},$=new WeakMap,z=new WeakMap,k=new WeakMap,ct=new WeakMap,B=new WeakMap,mt=new WeakMap,St=new WeakMap,X=new WeakMap,R=new WeakMap,J=new WeakMap,x=new WeakMap,O=new WeakMap,g=new WeakMap,L=new WeakMap,Y=new WeakMap,C=new WeakMap,N=new WeakMap,q=new WeakMap,F=new WeakMap,Q=new WeakMap,Z=new WeakMap,K=new WeakMap,P=new WeakMap,tt=new WeakMap,lt=new WeakMap,V=new WeakMap,Et=new WeakMap,n=new WeakSet,Yt=function(){let e=new Dt(t(this,$)),i=new Dt(t(this,$));u(this,K,e),u(this,Z,i);let s=this.ttlAutopurge?new Array(t(this,$)):void 0;u(this,P,s),u(this,wt,(h,c,S=t(this,X).now())=>{i[h]=c!==0?S:0,e[h]=c,r(h,c);}),u(this,ft,h=>{i[h]=e[h]!==0?t(this,X).now():0,r(h,e[h]);});let r=this.ttlAutopurge?(h,c)=>{if(s?.[h]&&(clearTimeout(s[h]),s[h]=void 0),c&&c!==0&&s){let S=setTimeout(()=>{t(this,W).call(this,h)&&l(this,n,nt).call(this,t(this,O)[h],"expire");},c+1);S.unref&&S.unref(),s[h]=S;}}:()=>{};u(this,it,(h,c)=>{if(e[c]){let S=e[c],I=i[c];if(!S||!I)return;h.ttl=S,h.start=I,h.now=o||a();let p=h.now-I;h.remainingTTL=S-p;}});let o=0,a=()=>{let h=t(this,X).now();if(this.ttlResolution>0){o=h;let c=setTimeout(()=>o=0,this.ttlResolution);c.unref&&c.unref();}return h};this.getRemainingTTL=h=>{let c=t(this,x).get(h);if(c===void 0)return 0;let S=e[c],I=i[c];if(!S||!I)return 1/0;let p=(o||a())-I;return S-p},u(this,W,h=>{let c=i[h],S=e[h];return !!S&&!!c&&(o||a())-c>S});},ft=new WeakMap,it=new WeakMap,wt=new WeakMap,W=new WeakMap,Qt=function(){let e=new Dt(t(this,$));u(this,J,0),u(this,Q,e),u(this,ut,i=>{u(this,J,t(this,J)-e[i]),e[i]=0;}),u(this,xt,(i,s,r,o)=>{if(l(this,n,v).call(this,s))return 0;if(!rt(r))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(r=o(s,i),!rt(r))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 r}),u(this,Tt,(i,s,r)=>{if(e[i]=s,t(this,z)){let o=t(this,z)-e[i];for(;t(this,J)>o;)l(this,n,Ct).call(this,true);}u(this,J,t(this,J)+e[i]),r&&(r.entrySize=s,r.totalCalculatedSize=t(this,J));});},ut=new WeakMap,Tt=new WeakMap,xt=new WeakMap,at=function*({allowStale:e=this.allowStale}={}){if(t(this,R))for(let i=t(this,N);!(!l(this,n,Kt).call(this,i)||((e||!t(this,W).call(this,i))&&(yield i),i===t(this,C)));)i=t(this,Y)[i];},ot=function*({allowStale:e=this.allowStale}={}){if(t(this,R))for(let i=t(this,C);!(!l(this,n,Kt).call(this,i)||((e||!t(this,W).call(this,i))&&(yield i),i===t(this,N)));)i=t(this,L)[i];},Kt=function(e){return e!==void 0&&t(this,x).get(t(this,O)[e])===e},Ct=function(e){var o;let i=t(this,C),s=t(this,O)[i],r=t(this,g)[i];return t(this,lt)&&l(this,n,v).call(this,r)?r.__abortController.abort(new Error("evicted")):(t(this,tt)||t(this,V))&&(t(this,tt)&&((o=t(this,k))==null||o.call(this,r,s,"evict")),t(this,V)&&t(this,F)?.push([r,s,"evict"])),t(this,ut).call(this,i),t(this,P)?.[i]&&(clearTimeout(t(this,P)[i]),t(this,P)[i]=void 0),e&&(t(this,O)[i]=void 0,t(this,g)[i]=void 0,t(this,q).push(i)),t(this,R)===1?(u(this,C,u(this,N,0)),t(this,q).length=0):u(this,C,t(this,L)[i]),t(this,x).delete(s),Nt(this,R)._--,i},Mt=function(e,i,s,r){let o=i===void 0?void 0:t(this,g)[i];if(l(this,n,v).call(this,o))return o;let a=new Gt,{signal:h}=s;h?.addEventListener("abort",()=>a.abort(h.reason),{signal:a.signal});let c={signal:a.signal,options:s,context:r},S=(y,A=false)=>{let{aborted:_}=a.signal,M=s.ignoreFetchAbort&&y!==void 0,U=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&y!==void 0);if(s.status&&(_&&!A?(s.status.fetchAborted=true,s.status.fetchError=a.signal.reason,M&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),_&&!M&&!A)return p(a.signal.reason,U);let G=T,w=t(this,g)[i];return (w===T||M&&A&&w===void 0)&&(y===void 0?G.__staleWhileFetching!==void 0?t(this,g)[i]=G.__staleWhileFetching:l(this,n,nt).call(this,e,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(e,y,c.options))),y},I=y=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=y),p(y,false)),p=(y,A)=>{let{aborted:_}=a.signal,M=_&&s.allowStaleOnFetchAbort,U=M||s.allowStaleOnFetchRejection,G=U||s.noDeleteOnFetchRejection,w=T;if(t(this,g)[i]===T&&(!G||!A&&w.__staleWhileFetching===void 0?l(this,n,nt).call(this,e,"fetch"):M||(t(this,g)[i]=w.__staleWhileFetching)),U)return s.status&&w.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),w.__staleWhileFetching;if(w.__returned===w)throw y},b=(y,A)=>{var M;let _=(M=t(this,mt))==null?void 0:M.call(this,e,o,c);_&&_ instanceof Promise&&_.then(U=>y(U===void 0?void 0:U),A),a.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(y(void 0),s.allowStaleOnFetchAbort&&(y=U=>S(U,true)));});};s.status&&(s.status.fetchDispatched=true);let T=new Promise(b).then(S,I),E=Object.assign(T,{__abortController:a,__staleWhileFetching:o,__returned:void 0});return i===void 0?(this.set(e,E,{...c.options,status:void 0}),i=t(this,x).get(e)):t(this,g)[i]=E,E},v=function(e){if(!t(this,lt))return false;let i=e;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof Gt},Pt=function(e,i){t(this,Y)[i]=e,t(this,L)[e]=i;},Ot=function(e){e!==t(this,N)&&(e===t(this,C)?u(this,C,t(this,L)[e]):l(this,n,Pt).call(this,t(this,Y)[e],t(this,L)[e]),l(this,n,Pt).call(this,t(this,N),e),u(this,N,e));},nt=function(e,i){var r,o;let s=false;if(t(this,R)!==0){let a=t(this,x).get(e);if(a!==void 0)if(t(this,P)?.[a]&&(clearTimeout(t(this,P)?.[a]),t(this,P)[a]=void 0),s=true,t(this,R)===1)l(this,n,Wt).call(this,i);else {t(this,ut).call(this,a);let h=t(this,g)[a];if(l(this,n,v).call(this,h)?h.__abortController.abort(new Error("deleted")):(t(this,tt)||t(this,V))&&(t(this,tt)&&((r=t(this,k))==null||r.call(this,h,e,i)),t(this,V)&&t(this,F)?.push([h,e,i])),t(this,x).delete(e),t(this,O)[a]=void 0,t(this,g)[a]=void 0,a===t(this,N))u(this,N,t(this,Y)[a]);else if(a===t(this,C))u(this,C,t(this,L)[a]);else {let c=t(this,Y)[a];t(this,L)[c]=t(this,L)[a];let S=t(this,L)[a];t(this,Y)[S]=t(this,Y)[a];}Nt(this,R)._--,t(this,q).push(a);}}if(t(this,V)&&t(this,F)?.length){let a=t(this,F),h;for(;h=a?.shift();)(o=t(this,B))==null||o.call(this,...h);}return s},Wt=function(e){var i,s;for(let r of l(this,n,ot).call(this,{allowStale:true})){let o=t(this,g)[r];if(l(this,n,v).call(this,o))o.__abortController.abort(new Error("deleted"));else {let a=t(this,O)[r];t(this,tt)&&((i=t(this,k))==null||i.call(this,o,a,e)),t(this,V)&&t(this,F)?.push([o,a,e]);}}if(t(this,x).clear(),t(this,g).fill(void 0),t(this,O).fill(void 0),t(this,K)&&t(this,Z)){t(this,K).fill(0),t(this,Z).fill(0);for(let r of t(this,P)??[])r!==void 0&&clearTimeout(r);t(this,P)?.fill(void 0);}if(t(this,Q)&&t(this,Q).fill(0),u(this,C,0),u(this,N,0),t(this,q).length=0,u(this,J,0),u(this,R,0),t(this,V)&&t(this,F)){let r=t(this,F),o;for(;o=r?.shift();)(s=t(this,B))==null||s.call(this,...o);}},bt);var yt=class{cache;map=new Map;constructor(e){this.cache=new qt({max:e.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){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()}};var At;(r=>(r.log=(o,...a)=>console.log(`[Pixi\u2019VN] ${o}`,...a),r.warn=(o,...a)=>console.warn(`[Pixi\u2019VN] ${o}`,...a),r.error=(o,...a)=>console.error(`[Pixi\u2019VN] ${o}`,...a),r.info=(o,...a)=>console.info(`[Pixi\u2019VN] ${o}`,...a)))(At||={});function Rt(f){try{if(typeof f>"u")return f;let e=JSON.stringify(f);return JSON.parse(e)}catch(e){throw At.error("Error creating exportable element",f,e),new core.PixiError("not_json_serializable","Error creating exportable element")}}var Zt;(p=>{p.storage=new yt({cacheSize:50}),p.defaultStorage=new yt({cacheSize:10}),p.tempStorageDeadlines=new Map;let s;function r(b){p.tempStorageDeadlines.forEach((T,E)=>{T>b&&(p.storage.delete(`${ht}:${E}`),s?.onClearOldTempVariable?.(E),p.tempStorageDeadlines.delete(E));});}p.clearOldTempVariables=r;function o(b){s=b;}p.setExternalStoreHandler=o;function a(b,T,E){E==null?p.storage.delete(`${b}:${T}`):p.storage.set(`${b}:${T}`,E),s?.onSetVariable?.(T,E);}p.setVariable=a;function h(b,T){let E=p.storage.get(`${b}:${T}`);return Rt(E)}p.getVariable=h;function c(b,T){p.storage.delete(`${b}:${T}`),s?.onRemoveVariable?.(T);}p.removeVariable=c;function S(b,T){let E=p.storage.get(Ft)||[];if(T)E.includes(b)||E.push(b);else {let y=E.indexOf(b);y>-1&&E.splice(y,1);}p.storage.set(Ft,E);}p.setFlag=S;function I(b){return (p.storage.get(Ft)||[]).includes(b)}p.getFlag=I;})(Zt||={});var m=Zt;var It=class{get base(){return m.storage.map}get cache(){return m.storage.cache}get tempStorageDeadlines(){return m.tempStorageDeadlines}set default(e){Object.entries(e).forEach(([i,s])=>{m.defaultStorage.map.set(i,s);});}temp={set:(e,i)=>this.setTemp(e,i),remove:e=>this.removeTemp(e),get deadlines(){return m.tempStorageDeadlines}};flags={set:(e,i)=>m.setFlag(e,i),get:e=>m.getFlag(e)};set(e,i){return m.setVariable(st,e,i)}get(e){let i=m.getVariable(ht,e);return i===void 0&&(i=m.getVariable(st,e)),i===void 0&&(i=Rt(m.defaultStorage.get(e))),i}remove(e){return this.temp.remove(e),m.removeVariable(st,e)}setTemp(e,i){if(i==null){this.temp.remove(e);return}else m.setVariable(ht,e,i),this.temp.deadlines.has(e)||this.temp.deadlines.set(e,core.GameUnifier.openedLabels);}removeTemp(e){m.removeVariable(ht,e),this.temp.deadlines.has(e)&&this.temp.deadlines.delete(e);}setTempVariable(e,i){this.temp.set(e,i);}removeTempVariable(e){this.temp.remove(e);}setFlag(e,i){this.flags.set(e,i);}getFlag(e){return this.flags.get(e)}setStorageHandler(e){m.setExternalStoreHandler(e);}clear(){this.base.clear(),this.cache.clear(),this.temp.deadlines.clear();}export(){let e=[];[...this.base.keys()].forEach(s=>{e.push({key:s,value:this.base.get(s)});});let i=[];return [...this.temp.deadlines.keys()].forEach(s=>{i.push({key:s,value:this.temp.deadlines.get(s)});}),Rt({main:e,tempDeadlines:i})}restore(e){this.clear();try{e?(e.base?.forEach(i=>{switch(i.key){case "___current_dialogue_memory___":m.setVariable(H,j.CURRENT_DIALOGUE_MEMORY_KEY,i.value);break;case "___last_dialogue_added_in_step_memory___":m.setVariable(H,j.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY,i.value);break;case "___current_menu_options_memory___":m.setVariable(H,j.CURRENT_MENU_OPTIONS_MEMORY_KEY,i.value);break;case "___last_menu_options_added_in_step_memory___":m.setVariable(H,j.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY,i.value);break;case "_input_value_":m.setVariable(H,j.CURRENT_INPUT_VALUE_MEMORY_KEY,i.value);break;case "___last_input_added_in_step_memory___":m.setVariable(H,j.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY,i.value);break;case "___current_input_info_memory___":m.setVariable(H,j.CURRENT_INPUT_INFO_MEMORY_KEY,i.value);break;case "___opened_labels_counter___":m.setVariable(H,j.OPENED_LABELS_COUNTER_KEY,i.value);break;case "___all_choices_made___":m.setVariable(H,j.ALL_CHOICES_MADE_KEY,i.value);break;case "___current_step_times_counter___":m.setVariable(H,j.CURRENT_STEP_TIMES_COUNTER_KEY,i.value);break;case "___last_step_glued___":m.setVariable(H,j.LAST_STEP_GLUED,i.value);break;default:m.setVariable(st,i.key,i.value);}}),e.temp?.forEach(i=>{m.setVariable(ht,i.key,i.value);}),e.flags?.forEach(i=>{m.setFlag(i,!0);}),e.main?.forEach(i=>{this.base.set(i.key,i.value);}),e.tempDeadlines?.forEach(i=>{this.temp.deadlines.set(i.key,i.value);})):At.warn("No storage data found");}catch(i){At.error("Error importing data",i);}}};var Lt=class{constructor(e,i){this.categoryId=e,this.id=i,this.migrateOldStorage();}migrateOldStorage(e=this.categoryId){let i=m.getVariable(st,e);i&&(Object.entries(i).forEach(([s,r])=>{typeof r=="object"&&r!==null&&Object.entries(r).forEach(([o,a])=>{m.setVariable(this.categoryId,`${s}:${o}`,a);});}),m.removeVariable(st,e));}id;categoryId;setStorageProperty(e,i){m.setVariable(this.categoryId,`${this.id}:${e}`,i);}getStorageProperty(e,i=this.id){return m.getVariable(this.categoryId,`${i}:${e}`)}};var Me=new It;exports.StorageRegistry=m;exports.StoredClassModel=Lt;exports.storage=Me;
|
|
1
|
+
'use strict';var core=require('@drincs/pixi-vn/core'),worker=require('@drincs/pixi-vn/worker');var te=Object.defineProperty;var Ht=f=>{throw TypeError(f)};var ee=(f,e,i)=>e in f?te(f,e,{enumerable:true,configurable:true,writable:true,value:i}):f[e]=i;var D=(f,e,i)=>ee(f,typeof e!="symbol"?e+"":e,i),Ut=(f,e,i)=>e.has(f)||Ht("Cannot "+i);var t=(f,e,i)=>(Ut(f,e,"read from private field"),i?i.call(f):e.get(f)),_=(f,e,i)=>e.has(f)?Ht("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(f):e.set(f,i),u=(f,e,i,s)=>(Ut(f,e,"write to private field"),e.set(f,i),i),l=(f,e,i)=>(Ut(f,e,"access private method"),i);var It=(f,e,i,s)=>({set _(r){u(f,e,r);},get _(){return t(f,e,s)}});var st="storage",ht="temp",H="narration",Nt="flags",j={CURRENT_DIALOGUE_MEMORY_KEY:"dialogue",LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY:"dialogue:step_counter",CURRENT_MENU_OPTIONS_MEMORY_KEY:"choice:options",LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY:"choice:step_counter",CURRENT_INPUT_VALUE_MEMORY_KEY:"input:value",LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY:"input:step_counter",CURRENT_INPUT_INFO_MEMORY_KEY:"input:info",CHARACTER_CATEGORY_KEY:"character",ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY:"___glue___",OPENED_LABELS_COUNTER_KEY:"label:opened",ALL_CHOICES_MADE_KEY:"choices:made",CURRENT_STEP_TIMES_COUNTER_KEY:"label:history",LAST_STEP_GLUED:"glue:last_step"};var ie=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Bt=new Set,zt=typeof process=="object"&&process?process:{},Xt=(f,e,i,s)=>{typeof zt.emitWarning=="function"?zt.emitWarning(f,e,i,s):console.error(`[${i}] ${e}: ${f}`);},Ct=globalThis.AbortController,jt=globalThis.AbortSignal;if(typeof Ct>"u"){jt=class{onabort;_onabort=[];reason;aborted=false;addEventListener(i,s){this._onabort.push(s);}},Ct=class{constructor(){e();}signal=new jt;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 f=zt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{f&&(f=false,Xt("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 se=f=>!Bt.has(f);var rt=f=>f&&f===Math.floor(f)&&f>0&&isFinite(f),Jt=f=>rt(f)?f<=Math.pow(2,8)?Uint8Array:f<=Math.pow(2,16)?Uint16Array:f<=Math.pow(2,32)?Uint32Array:f<=Number.MAX_SAFE_INTEGER?Ft:null:null,Ft=class extends Array{constructor(f){super(f),this.fill(0);}},et,_t,re=(et=class{heap;length;static create(e){let i=Jt(e);if(!i)return [];u(et,_t,true);let s=new et(e,i);return u(et,_t,false),s}constructor(e,i){if(!t(et,_t))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new i(e),this.length=0;}push(e){this.heap[this.length++]=e;}pop(){return this.heap[--this.length]}},_t=new WeakMap,_(et,_t,false),et),$t,kt,$,z,k,ct,B,mt,St,X,R,J,x,O,g,L,Y,M,N,q,F,Q,Z,P,K,tt,lt,V,Et,n,Yt,ft,it,wt,W,Qt,ut,Tt,xt,at,ot,Pt,Dt,Mt,v,Kt,Ot,nt,Wt,bt,qt=(bt=class{constructor(e){_(this,n);_(this,$);_(this,z);_(this,k);_(this,ct);_(this,B);_(this,mt);_(this,St);_(this,X);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");_(this,R);_(this,J);_(this,x);_(this,O);_(this,g);_(this,L);_(this,Y);_(this,M);_(this,N);_(this,q);_(this,F);_(this,Q);_(this,Z);_(this,P);_(this,K);_(this,tt);_(this,lt);_(this,V);_(this,Et);_(this,ft,()=>{});_(this,it,()=>{});_(this,wt,()=>{});_(this,W,()=>false);_(this,ut,e=>{});_(this,Tt,(e,i,s)=>{});_(this,xt,(e,i,s,r)=>{if(s||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});D(this,$t,"LRUCache");let{max:i=0,ttl:s,ttlResolution:r=1,ttlAutopurge:o,updateAgeOnGet:a,updateAgeOnHas:h,allowStale:c,dispose:S,onInsert:I,disposeAfter:p,noDisposeOnSet:b,noUpdateTTL:T,maxSize:E=0,maxEntrySize:y=0,sizeCalculation:A,fetchMethod:d,memoMethod:C,noDeleteOnFetchRejection:U,noDeleteOnStaleGet:G,allowStaleOnFetchRejection:w,allowStaleOnFetchAbort:vt,ignoreFetchAbort:gt,perf:pt}=e;if(pt!==void 0&&typeof pt?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(u(this,X,pt??ie),i!==0&&!rt(i))throw new TypeError("max option must be a nonnegative integer");let dt=i?Jt(i):Array;if(!dt)throw new Error("invalid max value: "+i);if(u(this,$,i),u(this,z,E),this.maxEntrySize=y||t(this,z),this.sizeCalculation=A,this.sizeCalculation){if(!t(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(C!==void 0&&typeof C!="function")throw new TypeError("memoMethod must be a function if defined");if(u(this,St,C),d!==void 0&&typeof d!="function")throw new TypeError("fetchMethod must be a function if specified");if(u(this,mt,d),u(this,lt,!!d),u(this,x,new Map),u(this,O,new Array(i).fill(void 0)),u(this,g,new Array(i).fill(void 0)),u(this,L,new dt(i)),u(this,Y,new dt(i)),u(this,M,0),u(this,N,0),u(this,q,re.create(i)),u(this,R,0),u(this,J,0),typeof S=="function"&&u(this,k,S),typeof I=="function"&&u(this,ct,I),typeof p=="function"?(u(this,B,p),u(this,F,[])):(u(this,B,void 0),u(this,F,void 0)),u(this,tt,!!t(this,k)),u(this,Et,!!t(this,ct)),u(this,V,!!t(this,B)),this.noDisposeOnSet=!!b,this.noUpdateTTL=!!T,this.noDeleteOnFetchRejection=!!U,this.allowStaleOnFetchRejection=!!w,this.allowStaleOnFetchAbort=!!vt,this.ignoreFetchAbort=!!gt,this.maxEntrySize!==0){if(t(this,z)!==0&&!rt(t(this,z)))throw new TypeError("maxSize must be a positive integer if specified");if(!rt(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");l(this,n,Qt).call(this);}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!G,this.updateAgeOnGet=!!a,this.updateAgeOnHas=!!h,this.ttlResolution=rt(r)||r===0?r:1,this.ttlAutopurge=!!o,this.ttl=s||0,this.ttl){if(!rt(this.ttl))throw new TypeError("ttl must be a positive integer if specified");l(this,n,Yt).call(this);}if(t(this,$)===0&&this.ttl===0&&t(this,z)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!t(this,$)&&!t(this,z)){let Vt="LRU_CACHE_UNBOUNDED";se(Vt)&&(Bt.add(Vt),Xt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Vt,bt));}}get perf(){return t(this,X)}static unsafeExposeInternals(e){return {starts:t(e,Z),ttls:t(e,P),autopurgeTimers:t(e,K),sizes:t(e,Q),keyMap:t(e,x),keyList:t(e,O),valList:t(e,g),next:t(e,L),prev:t(e,Y),get head(){return t(e,M)},get tail(){return t(e,N)},free:t(e,q),isBackgroundFetch:i=>{var s;return l(s=e,n,v).call(s,i)},backgroundFetch:(i,s,r,o)=>{var a;return l(a=e,n,Mt).call(a,i,s,r,o)},moveToTail:i=>{var s;return l(s=e,n,Ot).call(s,i)},indexes:i=>{var s;return l(s=e,n,at).call(s,i)},rindexes:i=>{var s;return l(s=e,n,ot).call(s,i)},isStale:i=>{var s;return t(s=e,W).call(s,i)}}}get max(){return t(this,$)}get maxSize(){return t(this,z)}get calculatedSize(){return t(this,J)}get size(){return t(this,R)}get fetchMethod(){return t(this,mt)}get memoMethod(){return t(this,St)}get dispose(){return t(this,k)}get onInsert(){return t(this,ct)}get disposeAfter(){return t(this,B)}getRemainingTTL(e){return t(this,x).has(e)?1/0:0}*entries(){for(let e of l(this,n,at).call(this))t(this,g)[e]!==void 0&&t(this,O)[e]!==void 0&&!l(this,n,v).call(this,t(this,g)[e])&&(yield [t(this,O)[e],t(this,g)[e]]);}*rentries(){for(let e of l(this,n,ot).call(this))t(this,g)[e]!==void 0&&t(this,O)[e]!==void 0&&!l(this,n,v).call(this,t(this,g)[e])&&(yield [t(this,O)[e],t(this,g)[e]]);}*keys(){for(let e of l(this,n,at).call(this)){let i=t(this,O)[e];i!==void 0&&!l(this,n,v).call(this,t(this,g)[e])&&(yield i);}}*rkeys(){for(let e of l(this,n,ot).call(this)){let i=t(this,O)[e];i!==void 0&&!l(this,n,v).call(this,t(this,g)[e])&&(yield i);}}*values(){for(let e of l(this,n,at).call(this))t(this,g)[e]!==void 0&&!l(this,n,v).call(this,t(this,g)[e])&&(yield t(this,g)[e]);}*rvalues(){for(let e of l(this,n,ot).call(this))t(this,g)[e]!==void 0&&!l(this,n,v).call(this,t(this,g)[e])&&(yield t(this,g)[e]);}[(kt=Symbol.iterator,$t=Symbol.toStringTag,kt)](){return this.entries()}find(e,i={}){for(let s of l(this,n,at).call(this)){let r=t(this,g)[s],o=l(this,n,v).call(this,r)?r.__staleWhileFetching:r;if(o!==void 0&&e(o,t(this,O)[s],this))return this.get(t(this,O)[s],i)}}forEach(e,i=this){for(let s of l(this,n,at).call(this)){let r=t(this,g)[s],o=l(this,n,v).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&e.call(i,o,t(this,O)[s],this);}}rforEach(e,i=this){for(let s of l(this,n,ot).call(this)){let r=t(this,g)[s],o=l(this,n,v).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&e.call(i,o,t(this,O)[s],this);}}purgeStale(){let e=false;for(let i of l(this,n,ot).call(this,{allowStale:true}))t(this,W).call(this,i)&&(l(this,n,nt).call(this,t(this,O)[i],"expire"),e=true);return e}info(e){let i=t(this,x).get(e);if(i===void 0)return;let s=t(this,g)[i],r=l(this,n,v).call(this,s)?s.__staleWhileFetching:s;if(r===void 0)return;let o={value:r};if(t(this,P)&&t(this,Z)){let a=t(this,P)[i],h=t(this,Z)[i];if(a&&h){let c=a-(t(this,X).now()-h);o.ttl=c,o.start=Date.now();}}return t(this,Q)&&(o.size=t(this,Q)[i]),o}dump(){let e=[];for(let i of l(this,n,at).call(this,{allowStale:true})){let s=t(this,O)[i],r=t(this,g)[i],o=l(this,n,v).call(this,r)?r.__staleWhileFetching:r;if(o===void 0||s===void 0)continue;let a={value:o};if(t(this,P)&&t(this,Z)){a.ttl=t(this,P)[i];let h=t(this,X).now()-t(this,Z)[i];a.start=Math.floor(Date.now()-h);}t(this,Q)&&(a.size=t(this,Q)[i]),e.unshift([s,a]);}return e}load(e){this.clear();for(let[i,s]of e){if(s.start){let r=Date.now()-s.start;s.start=t(this,X).now()-r;}this.set(i,s.value,s);}}set(e,i,s={}){var b,T,E,y;if(i===void 0)return this.delete(e),this;let{ttl:r=this.ttl,start:o,noDisposeOnSet:a=this.noDisposeOnSet,sizeCalculation:h=this.sizeCalculation,status:c}=s,{noUpdateTTL:S=this.noUpdateTTL}=s,I=t(this,xt).call(this,e,i,s.size||0,h);if(this.maxEntrySize&&I>this.maxEntrySize)return c&&(c.set="miss",c.maxEntrySizeExceeded=true),l(this,n,nt).call(this,e,"set"),this;let p=t(this,R)===0?void 0:t(this,x).get(e);if(p===void 0)p=t(this,R)===0?t(this,N):t(this,q).length!==0?t(this,q).pop():t(this,R)===t(this,$)?l(this,n,Dt).call(this,false):t(this,R),t(this,O)[p]=e,t(this,g)[p]=i,t(this,x).set(e,p),t(this,L)[t(this,N)]=p,t(this,Y)[p]=t(this,N),u(this,N,p),It(this,R)._++,t(this,Tt).call(this,p,I,c),c&&(c.set="add"),S=false,t(this,Et)&&((b=t(this,ct))==null||b.call(this,i,e,"add"));else {l(this,n,Ot).call(this,p);let A=t(this,g)[p];if(i!==A){if(t(this,lt)&&l(this,n,v).call(this,A)){A.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:d}=A;d!==void 0&&!a&&(t(this,tt)&&((T=t(this,k))==null||T.call(this,d,e,"set")),t(this,V)&&t(this,F)?.push([d,e,"set"]));}else a||(t(this,tt)&&((E=t(this,k))==null||E.call(this,A,e,"set")),t(this,V)&&t(this,F)?.push([A,e,"set"]));if(t(this,ut).call(this,p),t(this,Tt).call(this,p,I,c),t(this,g)[p]=i,c){c.set="replace";let d=A&&l(this,n,v).call(this,A)?A.__staleWhileFetching:A;d!==void 0&&(c.oldValue=d);}}else c&&(c.set="update");t(this,Et)&&this.onInsert?.(i,e,i===A?"update":"replace");}if(r!==0&&!t(this,P)&&l(this,n,Yt).call(this),t(this,P)&&(S||t(this,wt).call(this,p,r,o),c&&t(this,it).call(this,c,p)),!a&&t(this,V)&&t(this,F)){let A=t(this,F),d;for(;d=A?.shift();)(y=t(this,B))==null||y.call(this,...d);}return this}pop(){var e;try{for(;t(this,R);){let i=t(this,g)[t(this,M)];if(l(this,n,Dt).call(this,!0),l(this,n,v).call(this,i)){if(i.__staleWhileFetching)return i.__staleWhileFetching}else if(i!==void 0)return i}}finally{if(t(this,V)&&t(this,F)){let i=t(this,F),s;for(;s=i?.shift();)(e=t(this,B))==null||e.call(this,...s);}}}has(e,i={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:r}=i,o=t(this,x).get(e);if(o!==void 0){let a=t(this,g)[o];if(l(this,n,v).call(this,a)&&a.__staleWhileFetching===void 0)return false;if(t(this,W).call(this,o))r&&(r.has="stale",t(this,it).call(this,r,o));else return s&&t(this,ft).call(this,o),r&&(r.has="hit",t(this,it).call(this,r,o)),true}else r&&(r.has="miss");return false}peek(e,i={}){let{allowStale:s=this.allowStale}=i,r=t(this,x).get(e);if(r===void 0||!s&&t(this,W).call(this,r))return;let o=t(this,g)[r];return l(this,n,v).call(this,o)?o.__staleWhileFetching:o}async fetch(e,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:a=this.ttl,noDisposeOnSet:h=this.noDisposeOnSet,size:c=0,sizeCalculation:S=this.sizeCalculation,noUpdateTTL:I=this.noUpdateTTL,noDeleteOnFetchRejection:p=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:b=this.allowStaleOnFetchRejection,ignoreFetchAbort:T=this.ignoreFetchAbort,allowStaleOnFetchAbort:E=this.allowStaleOnFetchAbort,context:y,forceRefresh:A=false,status:d,signal:C}=i;if(!t(this,lt))return d&&(d.fetch="get"),this.get(e,{allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,status:d});let U={allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,ttl:a,noDisposeOnSet:h,size:c,sizeCalculation:S,noUpdateTTL:I,noDeleteOnFetchRejection:p,allowStaleOnFetchRejection:b,allowStaleOnFetchAbort:E,ignoreFetchAbort:T,status:d,signal:C},G=t(this,x).get(e);if(G===void 0){d&&(d.fetch="miss");let w=l(this,n,Mt).call(this,e,G,U,y);return w.__returned=w}else {let w=t(this,g)[G];if(l(this,n,v).call(this,w)){let dt=s&&w.__staleWhileFetching!==void 0;return d&&(d.fetch="inflight",dt&&(d.returnedStale=true)),dt?w.__staleWhileFetching:w.__returned=w}let vt=t(this,W).call(this,G);if(!A&&!vt)return d&&(d.fetch="hit"),l(this,n,Ot).call(this,G),r&&t(this,ft).call(this,G),d&&t(this,it).call(this,d,G),w;let gt=l(this,n,Mt).call(this,e,G,U,y),pt=gt.__staleWhileFetching!==void 0&&s;return d&&(d.fetch=vt?"stale":"refresh",pt&&vt&&(d.returnedStale=true)),pt?gt.__staleWhileFetching:gt.__returned=gt}}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,i={}){let s=t(this,St);if(!s)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:o,...a}=i,h=this.get(e,a);if(!o&&h!==void 0)return h;let c=s(e,h,{options:a,context:r});return this.set(e,c,a),c}get(e,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:a}=i,h=t(this,x).get(e);if(h!==void 0){let c=t(this,g)[h],S=l(this,n,v).call(this,c);return a&&t(this,it).call(this,a,h),t(this,W).call(this,h)?(a&&(a.get="stale"),S?(a&&s&&c.__staleWhileFetching!==void 0&&(a.returnedStale=true),s?c.__staleWhileFetching:void 0):(o||l(this,n,nt).call(this,e,"expire"),a&&s&&(a.returnedStale=true),s?c:void 0)):(a&&(a.get="hit"),S?c.__staleWhileFetching:(l(this,n,Ot).call(this,h),r&&t(this,ft).call(this,h),c))}else a&&(a.get="miss");}delete(e){return l(this,n,nt).call(this,e,"delete")}clear(){return l(this,n,Wt).call(this,"delete")}},$=new WeakMap,z=new WeakMap,k=new WeakMap,ct=new WeakMap,B=new WeakMap,mt=new WeakMap,St=new WeakMap,X=new WeakMap,R=new WeakMap,J=new WeakMap,x=new WeakMap,O=new WeakMap,g=new WeakMap,L=new WeakMap,Y=new WeakMap,M=new WeakMap,N=new WeakMap,q=new WeakMap,F=new WeakMap,Q=new WeakMap,Z=new WeakMap,P=new WeakMap,K=new WeakMap,tt=new WeakMap,lt=new WeakMap,V=new WeakMap,Et=new WeakMap,n=new WeakSet,Yt=function(){let e=new Ft(t(this,$)),i=new Ft(t(this,$));u(this,P,e),u(this,Z,i);let s=this.ttlAutopurge?new Array(t(this,$)):void 0;u(this,K,s),u(this,wt,(h,c,S=t(this,X).now())=>{i[h]=c!==0?S:0,e[h]=c,r(h,c);}),u(this,ft,h=>{i[h]=e[h]!==0?t(this,X).now():0,r(h,e[h]);});let r=this.ttlAutopurge?(h,c)=>{if(s?.[h]&&(clearTimeout(s[h]),s[h]=void 0),c&&c!==0&&s){let S=setTimeout(()=>{t(this,W).call(this,h)&&l(this,n,nt).call(this,t(this,O)[h],"expire");},c+1);S.unref&&S.unref(),s[h]=S;}}:()=>{};u(this,it,(h,c)=>{if(e[c]){let S=e[c],I=i[c];if(!S||!I)return;h.ttl=S,h.start=I,h.now=o||a();let p=h.now-I;h.remainingTTL=S-p;}});let o=0,a=()=>{let h=t(this,X).now();if(this.ttlResolution>0){o=h;let c=setTimeout(()=>o=0,this.ttlResolution);c.unref&&c.unref();}return h};this.getRemainingTTL=h=>{let c=t(this,x).get(h);if(c===void 0)return 0;let S=e[c],I=i[c];if(!S||!I)return 1/0;let p=(o||a())-I;return S-p},u(this,W,h=>{let c=i[h],S=e[h];return !!S&&!!c&&(o||a())-c>S});},ft=new WeakMap,it=new WeakMap,wt=new WeakMap,W=new WeakMap,Qt=function(){let e=new Ft(t(this,$));u(this,J,0),u(this,Q,e),u(this,ut,i=>{u(this,J,t(this,J)-e[i]),e[i]=0;}),u(this,xt,(i,s,r,o)=>{if(l(this,n,v).call(this,s))return 0;if(!rt(r))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(r=o(s,i),!rt(r))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 r}),u(this,Tt,(i,s,r)=>{if(e[i]=s,t(this,z)){let o=t(this,z)-e[i];for(;t(this,J)>o;)l(this,n,Dt).call(this,true);}u(this,J,t(this,J)+e[i]),r&&(r.entrySize=s,r.totalCalculatedSize=t(this,J));});},ut=new WeakMap,Tt=new WeakMap,xt=new WeakMap,at=function*({allowStale:e=this.allowStale}={}){if(t(this,R))for(let i=t(this,N);!(!l(this,n,Pt).call(this,i)||((e||!t(this,W).call(this,i))&&(yield i),i===t(this,M)));)i=t(this,Y)[i];},ot=function*({allowStale:e=this.allowStale}={}){if(t(this,R))for(let i=t(this,M);!(!l(this,n,Pt).call(this,i)||((e||!t(this,W).call(this,i))&&(yield i),i===t(this,N)));)i=t(this,L)[i];},Pt=function(e){return e!==void 0&&t(this,x).get(t(this,O)[e])===e},Dt=function(e){var o;let i=t(this,M),s=t(this,O)[i],r=t(this,g)[i];return t(this,lt)&&l(this,n,v).call(this,r)?r.__abortController.abort(new Error("evicted")):(t(this,tt)||t(this,V))&&(t(this,tt)&&((o=t(this,k))==null||o.call(this,r,s,"evict")),t(this,V)&&t(this,F)?.push([r,s,"evict"])),t(this,ut).call(this,i),t(this,K)?.[i]&&(clearTimeout(t(this,K)[i]),t(this,K)[i]=void 0),e&&(t(this,O)[i]=void 0,t(this,g)[i]=void 0,t(this,q).push(i)),t(this,R)===1?(u(this,M,u(this,N,0)),t(this,q).length=0):u(this,M,t(this,L)[i]),t(this,x).delete(s),It(this,R)._--,i},Mt=function(e,i,s,r){let o=i===void 0?void 0:t(this,g)[i];if(l(this,n,v).call(this,o))return o;let a=new Ct,{signal:h}=s;h?.addEventListener("abort",()=>a.abort(h.reason),{signal:a.signal});let c={signal:a.signal,options:s,context:r},S=(y,A=false)=>{let{aborted:d}=a.signal,C=s.ignoreFetchAbort&&y!==void 0,U=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&y!==void 0);if(s.status&&(d&&!A?(s.status.fetchAborted=true,s.status.fetchError=a.signal.reason,C&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),d&&!C&&!A)return p(a.signal.reason,U);let G=T,w=t(this,g)[i];return (w===T||C&&A&&w===void 0)&&(y===void 0?G.__staleWhileFetching!==void 0?t(this,g)[i]=G.__staleWhileFetching:l(this,n,nt).call(this,e,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(e,y,c.options))),y},I=y=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=y),p(y,false)),p=(y,A)=>{let{aborted:d}=a.signal,C=d&&s.allowStaleOnFetchAbort,U=C||s.allowStaleOnFetchRejection,G=U||s.noDeleteOnFetchRejection,w=T;if(t(this,g)[i]===T&&(!G||!A&&w.__staleWhileFetching===void 0?l(this,n,nt).call(this,e,"fetch"):C||(t(this,g)[i]=w.__staleWhileFetching)),U)return s.status&&w.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),w.__staleWhileFetching;if(w.__returned===w)throw y},b=(y,A)=>{var C;let d=(C=t(this,mt))==null?void 0:C.call(this,e,o,c);d&&d instanceof Promise&&d.then(U=>y(U===void 0?void 0:U),A),a.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(y(void 0),s.allowStaleOnFetchAbort&&(y=U=>S(U,true)));});};s.status&&(s.status.fetchDispatched=true);let T=new Promise(b).then(S,I),E=Object.assign(T,{__abortController:a,__staleWhileFetching:o,__returned:void 0});return i===void 0?(this.set(e,E,{...c.options,status:void 0}),i=t(this,x).get(e)):t(this,g)[i]=E,E},v=function(e){if(!t(this,lt))return false;let i=e;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof Ct},Kt=function(e,i){t(this,Y)[i]=e,t(this,L)[e]=i;},Ot=function(e){e!==t(this,N)&&(e===t(this,M)?u(this,M,t(this,L)[e]):l(this,n,Kt).call(this,t(this,Y)[e],t(this,L)[e]),l(this,n,Kt).call(this,t(this,N),e),u(this,N,e));},nt=function(e,i){var r,o;let s=false;if(t(this,R)!==0){let a=t(this,x).get(e);if(a!==void 0)if(t(this,K)?.[a]&&(clearTimeout(t(this,K)?.[a]),t(this,K)[a]=void 0),s=true,t(this,R)===1)l(this,n,Wt).call(this,i);else {t(this,ut).call(this,a);let h=t(this,g)[a];if(l(this,n,v).call(this,h)?h.__abortController.abort(new Error("deleted")):(t(this,tt)||t(this,V))&&(t(this,tt)&&((r=t(this,k))==null||r.call(this,h,e,i)),t(this,V)&&t(this,F)?.push([h,e,i])),t(this,x).delete(e),t(this,O)[a]=void 0,t(this,g)[a]=void 0,a===t(this,N))u(this,N,t(this,Y)[a]);else if(a===t(this,M))u(this,M,t(this,L)[a]);else {let c=t(this,Y)[a];t(this,L)[c]=t(this,L)[a];let S=t(this,L)[a];t(this,Y)[S]=t(this,Y)[a];}It(this,R)._--,t(this,q).push(a);}}if(t(this,V)&&t(this,F)?.length){let a=t(this,F),h;for(;h=a?.shift();)(o=t(this,B))==null||o.call(this,...h);}return s},Wt=function(e){var i,s;for(let r of l(this,n,ot).call(this,{allowStale:true})){let o=t(this,g)[r];if(l(this,n,v).call(this,o))o.__abortController.abort(new Error("deleted"));else {let a=t(this,O)[r];t(this,tt)&&((i=t(this,k))==null||i.call(this,o,a,e)),t(this,V)&&t(this,F)?.push([o,a,e]);}}if(t(this,x).clear(),t(this,g).fill(void 0),t(this,O).fill(void 0),t(this,P)&&t(this,Z)){t(this,P).fill(0),t(this,Z).fill(0);for(let r of t(this,K)??[])r!==void 0&&clearTimeout(r);t(this,K)?.fill(void 0);}if(t(this,Q)&&t(this,Q).fill(0),u(this,M,0),u(this,N,0),t(this,q).length=0,u(this,J,0),u(this,R,0),t(this,V)&&t(this,F)){let r=t(this,F),o;for(;o=r?.shift();)(s=t(this,B))==null||s.call(this,...o);}},bt);var yt=class{cache;map=new Map;constructor(e){this.cache=new qt({max:e.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){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()}};var At;(r=>(r.log=(o,...a)=>console.log(`[Pixi\u2019VN] ${o}`,...a),r.warn=(o,...a)=>console.warn(`[Pixi\u2019VN] ${o}`,...a),r.error=(o,...a)=>console.error(`[Pixi\u2019VN] ${o}`,...a),r.info=(o,...a)=>console.info(`[Pixi\u2019VN] ${o}`,...a)))(At||={});function Gt(f){try{if(typeof f>"u")return f;let e=JSON.stringify(f);return JSON.parse(e)}catch(e){throw At.error("Error creating exportable element",f,e),new core.PixiError("not_json_serializable","Error creating exportable element")}}var Zt;(p=>{p.storage=new yt({cacheSize:50}),p.defaultStorage=new yt({cacheSize:10}),p.tempStorageDeadlines=new Map;let s;function r(b){p.tempStorageDeadlines.forEach((T,E)=>{T>b&&(p.storage.delete(`${ht}:${E}`),s?.onClearOldTempVariable?.(E),p.tempStorageDeadlines.delete(E));});}p.clearOldTempVariables=r;function o(b){s=b;}p.setExternalStoreHandler=o;function a(b,T,E){E==null?p.storage.delete(`${b}:${T}`):p.storage.set(`${b}:${T}`,E),s?.onSetVariable?.(T,E);}p.setVariable=a;function h(b,T){let E=p.storage.get(`${b}:${T}`);return Gt(E)}p.getVariable=h;function c(b,T){p.storage.delete(`${b}:${T}`),s?.onRemoveVariable?.(T);}p.removeVariable=c;function S(b,T){let E=p.storage.get(Nt)||[];if(T)E.includes(b)||E.push(b);else {let y=E.indexOf(b);y>-1&&E.splice(y,1);}p.storage.set(Nt,E);}p.setFlag=S;function I(b){return (p.storage.get(Nt)||[]).includes(b)}p.getFlag=I;})(Zt||={});var m=Zt;var Rt=class{get base(){return m.storage.map}get cache(){return m.storage.cache}get tempStorageDeadlines(){return m.tempStorageDeadlines}set default(e){Object.entries(e).forEach(([i,s])=>{m.defaultStorage.map.set(i,s);});}temp={set:(e,i)=>this.setTemp(e,i),remove:e=>this.removeTemp(e),get deadlines(){return m.tempStorageDeadlines}};flags={set:(e,i)=>m.setFlag(e,i),get:e=>m.getFlag(e)};set(e,i){return m.setVariable(st,e,i)}get(e){let i=m.getVariable(ht,e);return i===void 0&&(i=m.getVariable(st,e)),i===void 0&&(i=Gt(m.defaultStorage.get(e))),i}remove(e){return this.temp.remove(e),m.removeVariable(st,e)}setTemp(e,i){if(i==null){this.temp.remove(e);return}else m.setVariable(ht,e,i),this.temp.deadlines.has(e)||this.temp.deadlines.set(e,core.GameUnifier.openedLabels);}removeTemp(e){m.removeVariable(ht,e),this.temp.deadlines.has(e)&&this.temp.deadlines.delete(e);}setTempVariable(e,i){this.temp.set(e,i);}removeTempVariable(e){this.temp.remove(e);}setFlag(e,i){this.flags.set(e,i);}getFlag(e){return this.flags.get(e)}setStorageHandler(e){m.setExternalStoreHandler(e);}clear(){this.base.clear(),this.cache.clear(),this.temp.deadlines.clear();}async export(){let e=[];[...this.base.keys()].forEach(s=>{e.push({key:s,value:this.base.get(s)});});let i=[];return [...this.temp.deadlines.keys()].forEach(s=>{i.push({key:s,value:this.temp.deadlines.get(s)});}),worker.cloneMaybeOffloaded({main:e,tempDeadlines:i})}restore(e){this.clear();try{e?(e.base?.forEach(i=>{switch(i.key){case "___current_dialogue_memory___":m.setVariable(H,j.CURRENT_DIALOGUE_MEMORY_KEY,i.value);break;case "___last_dialogue_added_in_step_memory___":m.setVariable(H,j.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY,i.value);break;case "___current_menu_options_memory___":m.setVariable(H,j.CURRENT_MENU_OPTIONS_MEMORY_KEY,i.value);break;case "___last_menu_options_added_in_step_memory___":m.setVariable(H,j.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY,i.value);break;case "_input_value_":m.setVariable(H,j.CURRENT_INPUT_VALUE_MEMORY_KEY,i.value);break;case "___last_input_added_in_step_memory___":m.setVariable(H,j.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY,i.value);break;case "___current_input_info_memory___":m.setVariable(H,j.CURRENT_INPUT_INFO_MEMORY_KEY,i.value);break;case "___opened_labels_counter___":m.setVariable(H,j.OPENED_LABELS_COUNTER_KEY,i.value);break;case "___all_choices_made___":m.setVariable(H,j.ALL_CHOICES_MADE_KEY,i.value);break;case "___current_step_times_counter___":m.setVariable(H,j.CURRENT_STEP_TIMES_COUNTER_KEY,i.value);break;case "___last_step_glued___":m.setVariable(H,j.LAST_STEP_GLUED,i.value);break;default:m.setVariable(st,i.key,i.value);}}),e.temp?.forEach(i=>{m.setVariable(ht,i.key,i.value);}),e.flags?.forEach(i=>{m.setFlag(i,!0);}),e.main?.forEach(i=>{this.base.set(i.key,i.value);}),e.tempDeadlines?.forEach(i=>{this.temp.deadlines.set(i.key,i.value);})):At.warn("No storage data found");}catch(i){At.error("Error importing data",i);}}};var Lt=class{constructor(e,i){this.categoryId=e,this.id=i,this.migrateOldStorage();}migrateOldStorage(e=this.categoryId){let i=m.getVariable(st,e);i&&(Object.entries(i).forEach(([s,r])=>{typeof r=="object"&&r!==null&&Object.entries(r).forEach(([o,a])=>{m.setVariable(this.categoryId,`${s}:${o}`,a);});}),m.removeVariable(st,e));}id;categoryId;setStorageProperty(e,i){m.setVariable(this.categoryId,`${this.id}:${e}`,i);}getStorageProperty(e,i=this.id){return m.getVariable(this.categoryId,`${i}:${e}`)}};var Le=new Rt;exports.StorageRegistry=m;exports.StoredClassModel=Lt;exports.storage=Le;
|
package/dist/storage.d.cts
CHANGED
|
@@ -187,7 +187,7 @@ interface StorageManagerInterface {
|
|
|
187
187
|
* Export the storage to an object
|
|
188
188
|
* @returns The object
|
|
189
189
|
*/
|
|
190
|
-
export(): StorageGameState
|
|
190
|
+
export(): Promise<StorageGameState>;
|
|
191
191
|
/**
|
|
192
192
|
* Restore the storage from an object
|
|
193
193
|
* @param data The object
|
package/dist/storage.d.ts
CHANGED
|
@@ -187,7 +187,7 @@ interface StorageManagerInterface {
|
|
|
187
187
|
* Export the storage to an object
|
|
188
188
|
* @returns The object
|
|
189
189
|
*/
|
|
190
|
-
export(): StorageGameState
|
|
190
|
+
export(): Promise<StorageGameState>;
|
|
191
191
|
/**
|
|
192
192
|
* Restore the storage from an object
|
|
193
193
|
* @param data The object
|
package/dist/storage.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{a as StorageRegistry,b as StoredClassModel,c as storage}from'./chunk-
|
|
1
|
+
export{a as StorageRegistry,b as StoredClassModel,c as storage}from'./chunk-6OABTG5R.mjs';import'./chunk-HD353M4B.mjs';import'./chunk-S7HZUIEI.mjs';import'./chunk-AW5XWF24.mjs';
|
package/dist/tickers.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var core=require('@drincs/pixi-vn/core'),At=require('@drincs/pixi-vn/pixi.js');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var At__default=/*#__PURE__*/_interopDefault(At);var mt=Object.create;var He=Object.defineProperty;var Tt=Object.getOwnPropertyDescriptor;var kt=Object.getOwnPropertyNames;var yt=Object.getPrototypeOf,vt=Object.prototype.hasOwnProperty;var Je=s=>{throw TypeError(s)};var St=(s,e,i)=>e in s?He(s,e,{enumerable:true,configurable:true,writable:true,value:i}):s[e]=i;var qe=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(e,i)=>(typeof require<"u"?require:e)[i]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+s+'" is not supported')});var Xe=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports);var _t=(s,e,i,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of kt(e))!vt.call(s,n)&&n!==i&&He(s,n,{get:()=>e[n],enumerable:!(r=Tt(e,n))||r.enumerable});return s};var Qe=(s,e,i)=>(i=s!=null?mt(yt(s)):{},_t(He(i,"default",{value:s,enumerable:true}),s));var U=(s,e,i)=>St(s,typeof e!="symbol"?e+"":e,i),Le=(s,e,i)=>e.has(s)||Je("Cannot "+i);var t=(s,e,i)=>(Le(s,e,"read from private field"),i?i.call(s):e.get(s)),b=(s,e,i)=>e.has(s)?Je("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(s):e.set(s,i),m=(s,e,i,r)=>(Le(s,e,"write to private field"),e.set(s,i),i),d=(s,e,i)=>(Le(s,e,"access private method"),i);var Oe=(s,e,i,r)=>({set _(n){m(s,e,n);},get _(){return t(s,e,r)}});var et=Xe((Re,Ze)=>{(function(s,e){typeof Re=="object"?Ze.exports=Re=e():typeof define=="function"&&define.amd?define([],e):s.CryptoJS=e();})(Re,function(){var s=s||(function(e,i){var r;if(typeof window<"u"&&window.crypto&&(r=window.crypto),typeof self<"u"&&self.crypto&&(r=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(r=globalThis.crypto),!r&&typeof window<"u"&&window.msCrypto&&(r=window.msCrypto),!r&&typeof global<"u"&&global.crypto&&(r=global.crypto),!r&&typeof qe=="function")try{r=qe("crypto");}catch{}var n=function(){if(r){if(typeof r.getRandomValues=="function")try{return r.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof r.randomBytes=="function")try{return r.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},o=Object.create||(function(){function c(){}return function(u){var w;return c.prototype=u,w=new c,c.prototype=null,w}})(),a={},l=a.lib={},h=l.Base=(function(){return {extend:function(c){var u=o(this);return c&&u.mixIn(c),(!u.hasOwnProperty("init")||this.init===u.init)&&(u.init=function(){u.$super.init.apply(this,arguments);}),u.init.prototype=u,u.$super=this,u},create:function(){var c=this.extend();return c.init.apply(c,arguments),c},init:function(){},mixIn:function(c){for(var u in c)c.hasOwnProperty(u)&&(this[u]=c[u]);c.hasOwnProperty("toString")&&(this.toString=c.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),g=l.WordArray=h.extend({init:function(c,u){c=this.words=c||[],u!=i?this.sigBytes=u:this.sigBytes=c.length*4;},toString:function(c){return (c||T).stringify(this)},concat:function(c){var u=this.words,w=c.words,_=this.sigBytes,E=c.sigBytes;if(this.clamp(),_%4)for(var I=0;I<E;I++){var re=w[I>>>2]>>>24-I%4*8&255;u[_+I>>>2]|=re<<24-(_+I)%4*8;}else for(var P=0;P<E;P+=4)u[_+P>>>2]=w[P>>>2];return this.sigBytes+=E,this},clamp:function(){var c=this.words,u=this.sigBytes;c[u>>>2]&=4294967295<<32-u%4*8,c.length=e.ceil(u/4);},clone:function(){var c=h.clone.call(this);return c.words=this.words.slice(0),c},random:function(c){for(var u=[],w=0;w<c;w+=4)u.push(n());return new g.init(u,c)}}),k=a.enc={},T=k.Hex={stringify:function(c){for(var u=c.words,w=c.sigBytes,_=[],E=0;E<w;E++){var I=u[E>>>2]>>>24-E%4*8&255;_.push((I>>>4).toString(16)),_.push((I&15).toString(16));}return _.join("")},parse:function(c){for(var u=c.length,w=[],_=0;_<u;_+=2)w[_>>>3]|=parseInt(c.substr(_,2),16)<<24-_%8*4;return new g.init(w,u/2)}},y=k.Latin1={stringify:function(c){for(var u=c.words,w=c.sigBytes,_=[],E=0;E<w;E++){var I=u[E>>>2]>>>24-E%4*8&255;_.push(String.fromCharCode(I));}return _.join("")},parse:function(c){for(var u=c.length,w=[],_=0;_<u;_++)w[_>>>2]|=(c.charCodeAt(_)&255)<<24-_%4*8;return new g.init(w,u)}},A=k.Utf8={stringify:function(c){try{return decodeURIComponent(escape(y.stringify(c)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(c){return y.parse(unescape(encodeURIComponent(c)))}},O=l.BufferedBlockAlgorithm=h.extend({reset:function(){this._data=new g.init,this._nDataBytes=0;},_append:function(c){typeof c=="string"&&(c=A.parse(c)),this._data.concat(c),this._nDataBytes+=c.sigBytes;},_process:function(c){var u,w=this._data,_=w.words,E=w.sigBytes,I=this.blockSize,re=I*4,P=E/re;c?P=e.ceil(P):P=e.max((P|0)-this._minBufferSize,0);var Y=P*I,ge=e.min(Y*4,E);if(Y){for(var Ue=0;Ue<Y;Ue+=I)this._doProcessBlock(_,Ue);u=_.splice(0,Y),w.sigBytes-=ge;}return new g.init(u,ge)},clone:function(){var c=h.clone.call(this);return c._data=this._data.clone(),c},_minBufferSize:0});l.Hasher=O.extend({cfg:h.extend(),init:function(c){this.cfg=this.cfg.extend(c),this.reset();},reset:function(){O.reset.call(this),this._doReset();},update:function(c){return this._append(c),this._process(),this},finalize:function(c){c&&this._append(c);var u=this._doFinalize();return u},blockSize:512/32,_createHelper:function(c){return function(u,w){return new c.init(w).finalize(u)}},_createHmacHelper:function(c){return function(u,w){return new v.HMAC.init(c,w).finalize(u)}}});var v=a.algo={};return a})(Math);return s});});var je=Xe((Ce,tt)=>{(function(s,e){typeof Ce=="object"?tt.exports=Ce=e(et()):typeof define=="function"&&define.amd?define(["./core"],e):e(s.CryptoJS);})(Ce,function(s){return (function(){var e=s,i=e.lib,r=i.WordArray,n=i.Hasher,o=e.algo,a=[],l=o.SHA1=n.extend({_doReset:function(){this._hash=new r.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(h,g){for(var k=this._hash.words,T=k[0],y=k[1],A=k[2],O=k[3],x=k[4],v=0;v<80;v++){if(v<16)a[v]=h[g+v]|0;else {var c=a[v-3]^a[v-8]^a[v-14]^a[v-16];a[v]=c<<1|c>>>31;}var u=(T<<5|T>>>27)+x+a[v];v<20?u+=(y&A|~y&O)+1518500249:v<40?u+=(y^A^O)+1859775393:v<60?u+=(y&A|y&O|A&O)-1894007588:u+=(y^A^O)-899497514,x=O,O=A,A=y<<30|y>>>2,y=T,T=u;}k[0]=k[0]+T|0,k[1]=k[1]+y|0,k[2]=k[2]+A|0,k[3]=k[3]+O|0,k[4]=k[4]+x|0;},_doFinalize:function(){var h=this._data,g=h.words,k=this._nDataBytes*8,T=h.sigBytes*8;return g[T>>>5]|=128<<24-T%32,g[(T+64>>>9<<4)+14]=Math.floor(k/4294967296),g[(T+64>>>9<<4)+15]=k,h.sigBytes=g.length*4,this._process(),this._hash},clone:function(){var h=n.clone.call(this);return h._hash=this._hash.clone(),h}});e.SHA1=n._createHelper(l),e.HmacSHA1=n._createHmacHelper(l);})(),s.SHA1});});var it=Qe(je());var B;(n=>(n.log=(o,...a)=>console.log(`[Pixi\u2019VN] ${o}`,...a),n.warn=(o,...a)=>console.warn(`[Pixi\u2019VN] ${o}`,...a),n.error=(o,...a)=>console.error(`[Pixi\u2019VN] ${o}`,...a),n.info=(o,...a)=>console.info(`[Pixi\u2019VN] ${o}`,...a)))(B||={});var Ie=class{constructor(e,i){this.alias=this.constructor.prototype.id;let{duration:r,priority:n,id:o=this.generateTickerId(this.alias,i),canvasElementAliases:a=[]}=i||{};this.args=e,this.duration=r,this.priority=n,this.id=o,this.canvasElementAliases=a;}alias;id;args;duration;priority;ticker=new At__default.default.Ticker;canvasElementAliases=[];generateTickerId(...e){try{return (0,it.default)(JSON.stringify(e)).toString()+"_"+Math.random().toString(36).substring(7)}catch(i){throw new core.PixiError("not_json_serializable",`Error to generate ticker id: ${i}`)}}fnValue;complete(e){this.stop();}stop(){let e=this.fnValue;if(!e){B.warn("TickerBase.stop() called without fnValue set. This may cause issues.");return}this.ticker.remove(e,null);}start(){let e=this.id,i=()=>this.fn(this.ticker,this.args,this.canvasElementAliases,e);this.fnValue=i,this.ticker.add(i,null,this.priority),this.ticker.start();}pause(){this.ticker.stop();}play(){this.ticker.start();}get paused(){return !this.ticker.started}};var Et=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,ot=new Set,Ne=typeof process=="object"&&process?process:{},at=(s,e,i,r)=>{typeof Ne.emitWarning=="function"?Ne.emitWarning(s,e,i,r):console.error(`[${i}] ${e}: ${s}`);},De=globalThis.AbortController,rt=globalThis.AbortSignal;if(typeof De>"u"){rt=class{onabort;_onabort=[];reason;aborted=false;addEventListener(i,r){this._onabort.push(r);}},De=class{constructor(){e();}signal=new rt;abort(i){if(!this.signal.aborted){this.signal.reason=i,this.signal.aborted=true;for(let r of this.signal._onabort)r(i);this.signal.onabort?.(i);}}};let s=Ne.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{s&&(s=false,at("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 bt=s=>!ot.has(s);var oe=s=>s&&s===Math.floor(s)&&s>0&&isFinite(s),ct=s=>oe(s)?s<=Math.pow(2,8)?Uint8Array:s<=Math.pow(2,16)?Uint16Array:s<=Math.pow(2,32)?Uint32Array:s<=Number.MAX_SAFE_INTEGER?Fe:null:null,Fe=class extends Array{constructor(s){super(s),this.fill(0);}},se,me,xt=(se=class{heap;length;static create(e){let i=ct(e);if(!i)return [];m(se,me,true);let r=new se(e,i);return m(se,me,false),r}constructor(e,i){if(!t(se,me))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new i(e),this.length=0;}push(e){this.heap[this.length++]=e;}pop(){return this.heap[--this.length]}},me=new WeakMap,b(se,me,false),se),st,nt,$,j,K,fe,J,Te,ke,X,z,Q,F,C,S,q,N,H,D,Z,W,ee,te,M,V,ie,le,L,ye,f,Me,ue,ne,Ee,G,lt,de,ve,be,ae,ce,Ve,ze,Be,R,Ge,Ae,he,$e,Se,ht=(Se=class{constructor(e){b(this,f);b(this,$);b(this,j);b(this,K);b(this,fe);b(this,J);b(this,Te);b(this,ke);b(this,X);U(this,"ttl");U(this,"ttlResolution");U(this,"ttlAutopurge");U(this,"updateAgeOnGet");U(this,"updateAgeOnHas");U(this,"allowStale");U(this,"noDisposeOnSet");U(this,"noUpdateTTL");U(this,"maxEntrySize");U(this,"sizeCalculation");U(this,"noDeleteOnFetchRejection");U(this,"noDeleteOnStaleGet");U(this,"allowStaleOnFetchAbort");U(this,"allowStaleOnFetchRejection");U(this,"ignoreFetchAbort");b(this,z);b(this,Q);b(this,F);b(this,C);b(this,S);b(this,q);b(this,N);b(this,H);b(this,D);b(this,Z);b(this,W);b(this,ee);b(this,te);b(this,M);b(this,V);b(this,ie);b(this,le);b(this,L);b(this,ye);b(this,ue,()=>{});b(this,ne,()=>{});b(this,Ee,()=>{});b(this,G,()=>false);b(this,de,e=>{});b(this,ve,(e,i,r)=>{});b(this,be,(e,i,r,n)=>{if(r||n)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});U(this,st,"LRUCache");let{max:i=0,ttl:r,ttlResolution:n=1,ttlAutopurge:o,updateAgeOnGet:a,updateAgeOnHas:l,allowStale:h,dispose:g,onInsert:k,disposeAfter:T,noDisposeOnSet:y,noUpdateTTL:A,maxSize:O=0,maxEntrySize:x=0,sizeCalculation:v,fetchMethod:c,memoMethod:u,noDeleteOnFetchRejection:w,noDeleteOnStaleGet:_,allowStaleOnFetchRejection:E,allowStaleOnFetchAbort:I,ignoreFetchAbort:re,perf:P}=e;if(P!==void 0&&typeof P?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(m(this,X,P??Et),i!==0&&!oe(i))throw new TypeError("max option must be a nonnegative integer");let Y=i?ct(i):Array;if(!Y)throw new Error("invalid max value: "+i);if(m(this,$,i),m(this,j,O),this.maxEntrySize=x||t(this,j),this.sizeCalculation=v,this.sizeCalculation){if(!t(this,j)&&!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(u!==void 0&&typeof u!="function")throw new TypeError("memoMethod must be a function if defined");if(m(this,ke,u),c!==void 0&&typeof c!="function")throw new TypeError("fetchMethod must be a function if specified");if(m(this,Te,c),m(this,le,!!c),m(this,F,new Map),m(this,C,new Array(i).fill(void 0)),m(this,S,new Array(i).fill(void 0)),m(this,q,new Y(i)),m(this,N,new Y(i)),m(this,H,0),m(this,D,0),m(this,Z,xt.create(i)),m(this,z,0),m(this,Q,0),typeof g=="function"&&m(this,K,g),typeof k=="function"&&m(this,fe,k),typeof T=="function"?(m(this,J,T),m(this,W,[])):(m(this,J,void 0),m(this,W,void 0)),m(this,ie,!!t(this,K)),m(this,ye,!!t(this,fe)),m(this,L,!!t(this,J)),this.noDisposeOnSet=!!y,this.noUpdateTTL=!!A,this.noDeleteOnFetchRejection=!!w,this.allowStaleOnFetchRejection=!!E,this.allowStaleOnFetchAbort=!!I,this.ignoreFetchAbort=!!re,this.maxEntrySize!==0){if(t(this,j)!==0&&!oe(t(this,j)))throw new TypeError("maxSize must be a positive integer if specified");if(!oe(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");d(this,f,lt).call(this);}if(this.allowStale=!!h,this.noDeleteOnStaleGet=!!_,this.updateAgeOnGet=!!a,this.updateAgeOnHas=!!l,this.ttlResolution=oe(n)||n===0?n:1,this.ttlAutopurge=!!o,this.ttl=r||0,this.ttl){if(!oe(this.ttl))throw new TypeError("ttl must be a positive integer if specified");d(this,f,Me).call(this);}if(t(this,$)===0&&this.ttl===0&&t(this,j)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!t(this,$)&&!t(this,j)){let ge="LRU_CACHE_UNBOUNDED";bt(ge)&&(ot.add(ge),at("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",ge,Se));}}get perf(){return t(this,X)}static unsafeExposeInternals(e){return {starts:t(e,te),ttls:t(e,M),autopurgeTimers:t(e,V),sizes:t(e,ee),keyMap:t(e,F),keyList:t(e,C),valList:t(e,S),next:t(e,q),prev:t(e,N),get head(){return t(e,H)},get tail(){return t(e,D)},free:t(e,Z),isBackgroundFetch:i=>{var r;return d(r=e,f,R).call(r,i)},backgroundFetch:(i,r,n,o)=>{var a;return d(a=e,f,Be).call(a,i,r,n,o)},moveToTail:i=>{var r;return d(r=e,f,Ae).call(r,i)},indexes:i=>{var r;return d(r=e,f,ae).call(r,i)},rindexes:i=>{var r;return d(r=e,f,ce).call(r,i)},isStale:i=>{var r;return t(r=e,G).call(r,i)}}}get max(){return t(this,$)}get maxSize(){return t(this,j)}get calculatedSize(){return t(this,Q)}get size(){return t(this,z)}get fetchMethod(){return t(this,Te)}get memoMethod(){return t(this,ke)}get dispose(){return t(this,K)}get onInsert(){return t(this,fe)}get disposeAfter(){return t(this,J)}getRemainingTTL(e){return t(this,F).has(e)?1/0:0}*entries(){for(let e of d(this,f,ae).call(this))t(this,S)[e]!==void 0&&t(this,C)[e]!==void 0&&!d(this,f,R).call(this,t(this,S)[e])&&(yield [t(this,C)[e],t(this,S)[e]]);}*rentries(){for(let e of d(this,f,ce).call(this))t(this,S)[e]!==void 0&&t(this,C)[e]!==void 0&&!d(this,f,R).call(this,t(this,S)[e])&&(yield [t(this,C)[e],t(this,S)[e]]);}*keys(){for(let e of d(this,f,ae).call(this)){let i=t(this,C)[e];i!==void 0&&!d(this,f,R).call(this,t(this,S)[e])&&(yield i);}}*rkeys(){for(let e of d(this,f,ce).call(this)){let i=t(this,C)[e];i!==void 0&&!d(this,f,R).call(this,t(this,S)[e])&&(yield i);}}*values(){for(let e of d(this,f,ae).call(this))t(this,S)[e]!==void 0&&!d(this,f,R).call(this,t(this,S)[e])&&(yield t(this,S)[e]);}*rvalues(){for(let e of d(this,f,ce).call(this))t(this,S)[e]!==void 0&&!d(this,f,R).call(this,t(this,S)[e])&&(yield t(this,S)[e]);}[(nt=Symbol.iterator,st=Symbol.toStringTag,nt)](){return this.entries()}find(e,i={}){for(let r of d(this,f,ae).call(this)){let n=t(this,S)[r],o=d(this,f,R).call(this,n)?n.__staleWhileFetching:n;if(o!==void 0&&e(o,t(this,C)[r],this))return this.get(t(this,C)[r],i)}}forEach(e,i=this){for(let r of d(this,f,ae).call(this)){let n=t(this,S)[r],o=d(this,f,R).call(this,n)?n.__staleWhileFetching:n;o!==void 0&&e.call(i,o,t(this,C)[r],this);}}rforEach(e,i=this){for(let r of d(this,f,ce).call(this)){let n=t(this,S)[r],o=d(this,f,R).call(this,n)?n.__staleWhileFetching:n;o!==void 0&&e.call(i,o,t(this,C)[r],this);}}purgeStale(){let e=false;for(let i of d(this,f,ce).call(this,{allowStale:true}))t(this,G).call(this,i)&&(d(this,f,he).call(this,t(this,C)[i],"expire"),e=true);return e}info(e){let i=t(this,F).get(e);if(i===void 0)return;let r=t(this,S)[i],n=d(this,f,R).call(this,r)?r.__staleWhileFetching:r;if(n===void 0)return;let o={value:n};if(t(this,M)&&t(this,te)){let a=t(this,M)[i],l=t(this,te)[i];if(a&&l){let h=a-(t(this,X).now()-l);o.ttl=h,o.start=Date.now();}}return t(this,ee)&&(o.size=t(this,ee)[i]),o}dump(){let e=[];for(let i of d(this,f,ae).call(this,{allowStale:true})){let r=t(this,C)[i],n=t(this,S)[i],o=d(this,f,R).call(this,n)?n.__staleWhileFetching:n;if(o===void 0||r===void 0)continue;let a={value:o};if(t(this,M)&&t(this,te)){a.ttl=t(this,M)[i];let l=t(this,X).now()-t(this,te)[i];a.start=Math.floor(Date.now()-l);}t(this,ee)&&(a.size=t(this,ee)[i]),e.unshift([r,a]);}return e}load(e){this.clear();for(let[i,r]of e){if(r.start){let n=Date.now()-r.start;r.start=t(this,X).now()-n;}this.set(i,r.value,r);}}set(e,i,r={}){var y,A,O,x;if(i===void 0)return this.delete(e),this;let{ttl:n=this.ttl,start:o,noDisposeOnSet:a=this.noDisposeOnSet,sizeCalculation:l=this.sizeCalculation,status:h}=r,{noUpdateTTL:g=this.noUpdateTTL}=r,k=t(this,be).call(this,e,i,r.size||0,l);if(this.maxEntrySize&&k>this.maxEntrySize)return h&&(h.set="miss",h.maxEntrySizeExceeded=true),d(this,f,he).call(this,e,"set"),this;let T=t(this,z)===0?void 0:t(this,F).get(e);if(T===void 0)T=t(this,z)===0?t(this,D):t(this,Z).length!==0?t(this,Z).pop():t(this,z)===t(this,$)?d(this,f,ze).call(this,false):t(this,z),t(this,C)[T]=e,t(this,S)[T]=i,t(this,F).set(e,T),t(this,q)[t(this,D)]=T,t(this,N)[T]=t(this,D),m(this,D,T),Oe(this,z)._++,t(this,ve).call(this,T,k,h),h&&(h.set="add"),g=false,t(this,ye)&&((y=t(this,fe))==null||y.call(this,i,e,"add"));else {d(this,f,Ae).call(this,T);let v=t(this,S)[T];if(i!==v){if(t(this,le)&&d(this,f,R).call(this,v)){v.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:c}=v;c!==void 0&&!a&&(t(this,ie)&&((A=t(this,K))==null||A.call(this,c,e,"set")),t(this,L)&&t(this,W)?.push([c,e,"set"]));}else a||(t(this,ie)&&((O=t(this,K))==null||O.call(this,v,e,"set")),t(this,L)&&t(this,W)?.push([v,e,"set"]));if(t(this,de).call(this,T),t(this,ve).call(this,T,k,h),t(this,S)[T]=i,h){h.set="replace";let c=v&&d(this,f,R).call(this,v)?v.__staleWhileFetching:v;c!==void 0&&(h.oldValue=c);}}else h&&(h.set="update");t(this,ye)&&this.onInsert?.(i,e,i===v?"update":"replace");}if(n!==0&&!t(this,M)&&d(this,f,Me).call(this),t(this,M)&&(g||t(this,Ee).call(this,T,n,o),h&&t(this,ne).call(this,h,T)),!a&&t(this,L)&&t(this,W)){let v=t(this,W),c;for(;c=v?.shift();)(x=t(this,J))==null||x.call(this,...c);}return this}pop(){var e;try{for(;t(this,z);){let i=t(this,S)[t(this,H)];if(d(this,f,ze).call(this,!0),d(this,f,R).call(this,i)){if(i.__staleWhileFetching)return i.__staleWhileFetching}else if(i!==void 0)return i}}finally{if(t(this,L)&&t(this,W)){let i=t(this,W),r;for(;r=i?.shift();)(e=t(this,J))==null||e.call(this,...r);}}}has(e,i={}){let{updateAgeOnHas:r=this.updateAgeOnHas,status:n}=i,o=t(this,F).get(e);if(o!==void 0){let a=t(this,S)[o];if(d(this,f,R).call(this,a)&&a.__staleWhileFetching===void 0)return false;if(t(this,G).call(this,o))n&&(n.has="stale",t(this,ne).call(this,n,o));else return r&&t(this,ue).call(this,o),n&&(n.has="hit",t(this,ne).call(this,n,o)),true}else n&&(n.has="miss");return false}peek(e,i={}){let{allowStale:r=this.allowStale}=i,n=t(this,F).get(e);if(n===void 0||!r&&t(this,G).call(this,n))return;let o=t(this,S)[n];return d(this,f,R).call(this,o)?o.__staleWhileFetching:o}async fetch(e,i={}){let{allowStale:r=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:a=this.ttl,noDisposeOnSet:l=this.noDisposeOnSet,size:h=0,sizeCalculation:g=this.sizeCalculation,noUpdateTTL:k=this.noUpdateTTL,noDeleteOnFetchRejection:T=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:y=this.allowStaleOnFetchRejection,ignoreFetchAbort:A=this.ignoreFetchAbort,allowStaleOnFetchAbort:O=this.allowStaleOnFetchAbort,context:x,forceRefresh:v=false,status:c,signal:u}=i;if(!t(this,le))return c&&(c.fetch="get"),this.get(e,{allowStale:r,updateAgeOnGet:n,noDeleteOnStaleGet:o,status:c});let w={allowStale:r,updateAgeOnGet:n,noDeleteOnStaleGet:o,ttl:a,noDisposeOnSet:l,size:h,sizeCalculation:g,noUpdateTTL:k,noDeleteOnFetchRejection:T,allowStaleOnFetchRejection:y,allowStaleOnFetchAbort:O,ignoreFetchAbort:A,status:c,signal:u},_=t(this,F).get(e);if(_===void 0){c&&(c.fetch="miss");let E=d(this,f,Be).call(this,e,_,w,x);return E.__returned=E}else {let E=t(this,S)[_];if(d(this,f,R).call(this,E)){let Y=r&&E.__staleWhileFetching!==void 0;return c&&(c.fetch="inflight",Y&&(c.returnedStale=true)),Y?E.__staleWhileFetching:E.__returned=E}let I=t(this,G).call(this,_);if(!v&&!I)return c&&(c.fetch="hit"),d(this,f,Ae).call(this,_),n&&t(this,ue).call(this,_),c&&t(this,ne).call(this,c,_),E;let re=d(this,f,Be).call(this,e,_,w,x),P=re.__staleWhileFetching!==void 0&&r;return c&&(c.fetch=I?"stale":"refresh",P&&I&&(c.returnedStale=true)),P?re.__staleWhileFetching:re.__returned=re}}async forceFetch(e,i={}){let r=await this.fetch(e,i);if(r===void 0)throw new Error("fetch() returned undefined");return r}memo(e,i={}){let r=t(this,ke);if(!r)throw new Error("no memoMethod provided to constructor");let{context:n,forceRefresh:o,...a}=i,l=this.get(e,a);if(!o&&l!==void 0)return l;let h=r(e,l,{options:a,context:n});return this.set(e,h,a),h}get(e,i={}){let{allowStale:r=this.allowStale,updateAgeOnGet:n=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:a}=i,l=t(this,F).get(e);if(l!==void 0){let h=t(this,S)[l],g=d(this,f,R).call(this,h);return a&&t(this,ne).call(this,a,l),t(this,G).call(this,l)?(a&&(a.get="stale"),g?(a&&r&&h.__staleWhileFetching!==void 0&&(a.returnedStale=true),r?h.__staleWhileFetching:void 0):(o||d(this,f,he).call(this,e,"expire"),a&&r&&(a.returnedStale=true),r?h:void 0)):(a&&(a.get="hit"),g?h.__staleWhileFetching:(d(this,f,Ae).call(this,l),n&&t(this,ue).call(this,l),h))}else a&&(a.get="miss");}delete(e){return d(this,f,he).call(this,e,"delete")}clear(){return d(this,f,$e).call(this,"delete")}},$=new WeakMap,j=new WeakMap,K=new WeakMap,fe=new WeakMap,J=new WeakMap,Te=new WeakMap,ke=new WeakMap,X=new WeakMap,z=new WeakMap,Q=new WeakMap,F=new WeakMap,C=new WeakMap,S=new WeakMap,q=new WeakMap,N=new WeakMap,H=new WeakMap,D=new WeakMap,Z=new WeakMap,W=new WeakMap,ee=new WeakMap,te=new WeakMap,M=new WeakMap,V=new WeakMap,ie=new WeakMap,le=new WeakMap,L=new WeakMap,ye=new WeakMap,f=new WeakSet,Me=function(){let e=new Fe(t(this,$)),i=new Fe(t(this,$));m(this,M,e),m(this,te,i);let r=this.ttlAutopurge?new Array(t(this,$)):void 0;m(this,V,r),m(this,Ee,(l,h,g=t(this,X).now())=>{i[l]=h!==0?g:0,e[l]=h,n(l,h);}),m(this,ue,l=>{i[l]=e[l]!==0?t(this,X).now():0,n(l,e[l]);});let n=this.ttlAutopurge?(l,h)=>{if(r?.[l]&&(clearTimeout(r[l]),r[l]=void 0),h&&h!==0&&r){let g=setTimeout(()=>{t(this,G).call(this,l)&&d(this,f,he).call(this,t(this,C)[l],"expire");},h+1);g.unref&&g.unref(),r[l]=g;}}:()=>{};m(this,ne,(l,h)=>{if(e[h]){let g=e[h],k=i[h];if(!g||!k)return;l.ttl=g,l.start=k,l.now=o||a();let T=l.now-k;l.remainingTTL=g-T;}});let o=0,a=()=>{let l=t(this,X).now();if(this.ttlResolution>0){o=l;let h=setTimeout(()=>o=0,this.ttlResolution);h.unref&&h.unref();}return l};this.getRemainingTTL=l=>{let h=t(this,F).get(l);if(h===void 0)return 0;let g=e[h],k=i[h];if(!g||!k)return 1/0;let T=(o||a())-k;return g-T},m(this,G,l=>{let h=i[l],g=e[l];return !!g&&!!h&&(o||a())-h>g});},ue=new WeakMap,ne=new WeakMap,Ee=new WeakMap,G=new WeakMap,lt=function(){let e=new Fe(t(this,$));m(this,Q,0),m(this,ee,e),m(this,de,i=>{m(this,Q,t(this,Q)-e[i]),e[i]=0;}),m(this,be,(i,r,n,o)=>{if(d(this,f,R).call(this,r))return 0;if(!oe(n))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(n=o(r,i),!oe(n))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 n}),m(this,ve,(i,r,n)=>{if(e[i]=r,t(this,j)){let o=t(this,j)-e[i];for(;t(this,Q)>o;)d(this,f,ze).call(this,true);}m(this,Q,t(this,Q)+e[i]),n&&(n.entrySize=r,n.totalCalculatedSize=t(this,Q));});},de=new WeakMap,ve=new WeakMap,be=new WeakMap,ae=function*({allowStale:e=this.allowStale}={}){if(t(this,z))for(let i=t(this,D);!(!d(this,f,Ve).call(this,i)||((e||!t(this,G).call(this,i))&&(yield i),i===t(this,H)));)i=t(this,N)[i];},ce=function*({allowStale:e=this.allowStale}={}){if(t(this,z))for(let i=t(this,H);!(!d(this,f,Ve).call(this,i)||((e||!t(this,G).call(this,i))&&(yield i),i===t(this,D)));)i=t(this,q)[i];},Ve=function(e){return e!==void 0&&t(this,F).get(t(this,C)[e])===e},ze=function(e){var o;let i=t(this,H),r=t(this,C)[i],n=t(this,S)[i];return t(this,le)&&d(this,f,R).call(this,n)?n.__abortController.abort(new Error("evicted")):(t(this,ie)||t(this,L))&&(t(this,ie)&&((o=t(this,K))==null||o.call(this,n,r,"evict")),t(this,L)&&t(this,W)?.push([n,r,"evict"])),t(this,de).call(this,i),t(this,V)?.[i]&&(clearTimeout(t(this,V)[i]),t(this,V)[i]=void 0),e&&(t(this,C)[i]=void 0,t(this,S)[i]=void 0,t(this,Z).push(i)),t(this,z)===1?(m(this,H,m(this,D,0)),t(this,Z).length=0):m(this,H,t(this,q)[i]),t(this,F).delete(r),Oe(this,z)._--,i},Be=function(e,i,r,n){let o=i===void 0?void 0:t(this,S)[i];if(d(this,f,R).call(this,o))return o;let a=new De,{signal:l}=r;l?.addEventListener("abort",()=>a.abort(l.reason),{signal:a.signal});let h={signal:a.signal,options:r,context:n},g=(x,v=false)=>{let{aborted:c}=a.signal,u=r.ignoreFetchAbort&&x!==void 0,w=r.ignoreFetchAbort||!!(r.allowStaleOnFetchAbort&&x!==void 0);if(r.status&&(c&&!v?(r.status.fetchAborted=true,r.status.fetchError=a.signal.reason,u&&(r.status.fetchAbortIgnored=true)):r.status.fetchResolved=true),c&&!u&&!v)return T(a.signal.reason,w);let _=A,E=t(this,S)[i];return (E===A||u&&v&&E===void 0)&&(x===void 0?_.__staleWhileFetching!==void 0?t(this,S)[i]=_.__staleWhileFetching:d(this,f,he).call(this,e,"fetch"):(r.status&&(r.status.fetchUpdated=true),this.set(e,x,h.options))),x},k=x=>(r.status&&(r.status.fetchRejected=true,r.status.fetchError=x),T(x,false)),T=(x,v)=>{let{aborted:c}=a.signal,u=c&&r.allowStaleOnFetchAbort,w=u||r.allowStaleOnFetchRejection,_=w||r.noDeleteOnFetchRejection,E=A;if(t(this,S)[i]===A&&(!_||!v&&E.__staleWhileFetching===void 0?d(this,f,he).call(this,e,"fetch"):u||(t(this,S)[i]=E.__staleWhileFetching)),w)return r.status&&E.__staleWhileFetching!==void 0&&(r.status.returnedStale=true),E.__staleWhileFetching;if(E.__returned===E)throw x},y=(x,v)=>{var u;let c=(u=t(this,Te))==null?void 0:u.call(this,e,o,h);c&&c instanceof Promise&&c.then(w=>x(w===void 0?void 0:w),v),a.signal.addEventListener("abort",()=>{(!r.ignoreFetchAbort||r.allowStaleOnFetchAbort)&&(x(void 0),r.allowStaleOnFetchAbort&&(x=w=>g(w,true)));});};r.status&&(r.status.fetchDispatched=true);let A=new Promise(y).then(g,k),O=Object.assign(A,{__abortController:a,__staleWhileFetching:o,__returned:void 0});return i===void 0?(this.set(e,O,{...h.options,status:void 0}),i=t(this,F).get(e)):t(this,S)[i]=O,O},R=function(e){if(!t(this,le))return false;let i=e;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof De},Ge=function(e,i){t(this,N)[i]=e,t(this,q)[e]=i;},Ae=function(e){e!==t(this,D)&&(e===t(this,H)?m(this,H,t(this,q)[e]):d(this,f,Ge).call(this,t(this,N)[e],t(this,q)[e]),d(this,f,Ge).call(this,t(this,D),e),m(this,D,e));},he=function(e,i){var n,o;let r=false;if(t(this,z)!==0){let a=t(this,F).get(e);if(a!==void 0)if(t(this,V)?.[a]&&(clearTimeout(t(this,V)?.[a]),t(this,V)[a]=void 0),r=true,t(this,z)===1)d(this,f,$e).call(this,i);else {t(this,de).call(this,a);let l=t(this,S)[a];if(d(this,f,R).call(this,l)?l.__abortController.abort(new Error("deleted")):(t(this,ie)||t(this,L))&&(t(this,ie)&&((n=t(this,K))==null||n.call(this,l,e,i)),t(this,L)&&t(this,W)?.push([l,e,i])),t(this,F).delete(e),t(this,C)[a]=void 0,t(this,S)[a]=void 0,a===t(this,D))m(this,D,t(this,N)[a]);else if(a===t(this,H))m(this,H,t(this,q)[a]);else {let h=t(this,N)[a];t(this,q)[h]=t(this,q)[a];let g=t(this,q)[a];t(this,N)[g]=t(this,N)[a];}Oe(this,z)._--,t(this,Z).push(a);}}if(t(this,L)&&t(this,W)?.length){let a=t(this,W),l;for(;l=a?.shift();)(o=t(this,J))==null||o.call(this,...l);}return r},$e=function(e){var i,r;for(let n of d(this,f,ce).call(this,{allowStale:true})){let o=t(this,S)[n];if(d(this,f,R).call(this,o))o.__abortController.abort(new Error("deleted"));else {let a=t(this,C)[n];t(this,ie)&&((i=t(this,K))==null||i.call(this,o,a,e)),t(this,L)&&t(this,W)?.push([o,a,e]);}}if(t(this,F).clear(),t(this,S).fill(void 0),t(this,C).fill(void 0),t(this,M)&&t(this,te)){t(this,M).fill(0),t(this,te).fill(0);for(let n of t(this,V)??[])n!==void 0&&clearTimeout(n);t(this,V)?.fill(void 0);}if(t(this,ee)&&t(this,ee).fill(0),m(this,H,0),m(this,D,0),t(this,Z).length=0,m(this,Q,0),m(this,z,0),t(this,L)&&t(this,W)){let n=t(this,W),o;for(;o=n?.shift();)(r=t(this,J))==null||r.call(this,...o);}},Se);var xe=class{cache;map=new Map;constructor(e){this.cache=new ht({max:e.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){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()}};var pe=new xe({cacheSize:5});function Ot(s){return function(e){Ye.add(e,s);}}var Ye;(a=>{function s(l,h){h||(h=l.name),pe.get(h)&&B.info(`Ticker "${h}" already exists, it will be overwritten`),l.prototype.id=h,pe.set(h,l);}a.add=s;function e(l){try{let h=pe.get(l);if(!h){B.error(`Event "${l}" not found, did you forget to register it with the tickerDecorator?`);return}return h}catch(h){B.error(`Error while getting Event "${l}"`,h);return}}a.get=e;function i(l,h,g){try{let k=pe.get(l);if(!k){B.error(`Ticker "${l}" not found, did you forget to register it with the tickerDecorator?`);return}return new k(h,g)}catch(k){B.error(`Error while getting Ticker "${l}"`,k);return}}a.getInstance=i;function r(){return Array.from(pe.values())}a.values=r;function n(l){return pe.has(l)}a.has=n;function o(){return Array.from(pe.keys())}a.keys=o;})(Ye||={});var _e=Ye;function We(s){try{if(typeof s>"u")return s;let e=JSON.stringify(s);return JSON.parse(e)}catch(e){throw B.error("Error creating exportable element",s,e),new core.PixiError("not_json_serializable","Error creating exportable element")}}var ft=Qe(je());exports.TickersManagerStatic=void 0;(T=>{function s(){return Object.fromEntries(Array.from(T._currentTickers.entries()).filter(([y,A])=>!A.createdByTicketSteps).map(([y,A])=>[y,{id:A.ticker.alias,args:A.ticker.args,canvasElementAliases:A.ticker.canvasElementAliases,priority:A.ticker.priority,duration:A.ticker.duration,paused:A.ticker.paused}]))}T.currentTickersWithoutCreatedBySteps=s,T._currentTickers=new Map,T._currentTickersSequence=new Map;function r(){return Object.fromEntries(Array.from(T._currentTickersSequence.entries()).map(([y,A])=>[y,Object.fromEntries(A)]))}T.currentTickersSequence=r,T._currentTickersTimeouts=new Map,T._tickersToCompleteOnStepEnd={tikersIds:[],stepAlias:[]};function a(...y){try{return `${(0,ft.default)(JSON.stringify(y)).toString()}_${Math.random().toString(36).substring(7)}`}catch(A){throw new core.PixiError("not_json_serializable",`Error to generate ticker id: ${A}`)}}T.generateTickerId=a;function l(y,A,O,x){typeof y=="string"&&(y=[y]),T._currentTickersTimeouts.set(O,{aliases:y,ticker:A,canBeDeletedBeforeEnd:x});}T.addTickerTimeoutInfo=l;function h(y){typeof y!="string"&&(y=y.toString()),T._currentTickersTimeouts.delete(y);}T.removeTickerTimeoutInfo=h;function g(y){typeof y!="string"&&(y=y.toString()),clearTimeout(Number(y)),h(y);}T.removeTickerTimeout=g;function k(y,A){T._currentTickersTimeouts.forEach((O,x)=>{let v=O.aliases.filter(c=>c!==y);if(v.length===0){let c=O.canBeDeletedBeforeEnd;(!A||c)&&g(x);}else O.aliases=v;});}T.removeTickerTimeoutsByAlias=k;})(exports.TickersManagerStatic||={});var ut="aliasToRemoveAfter";function It(s){let e=exports.TickersManagerStatic._currentTickers.get(s);if(e)return e.ticker}function pt(s,e){let i=e.id,r=e.alias;if(typeof s=="string"&&(s=[s]),e.canvasElementAliases=s,!_e.has(r)){B.error(`Ticker ${r} not found`);return}let n={ticker:e};if(exports.TickersManagerStatic._currentTickers.set(i,n),n.ticker.start(),e.duration){let o=setTimeout(()=>{exports.TickersManagerStatic.removeTickerTimeoutInfo(o),exports.TickersManagerStatic._currentTickersTimeouts.get(o.toString())&&n.ticker.complete({ignoreTickerSteps:true});},e.duration*1e3);exports.TickersManagerStatic.addTickerTimeoutInfo(s,r,o.toString(),true);}return i}function Ft(s,e,i=0){if(e.length===0){B.warn("The steps of the tickers is empty");return}exports.TickersManagerStatic._currentTickersSequence.has(s)||exports.TickersManagerStatic._currentTickersSequence.set(s,new Map);let r={currentStepNumber:i,steps:e.map(o=>({ticker:o.alias,args:We(o.args),duration:o.duration}))},n=exports.TickersManagerStatic.generateTickerId(r);return exports.TickersManagerStatic._currentTickersSequence.get(s)?.set(n,r),Pe(s,n),n}function Pe(s,e){let i=exports.TickersManagerStatic._currentTickersSequence.get(s);if(!i?.has(e))return;let r=i.get(e).steps[i.get(e).currentStepNumber],n=_e.getInstance(r.ticker,r.args,{canvasElementAliases:[s],duration:r.duration,priority:r.priority});if(!n){B.error(`Ticker ${r.ticker} not found`);return}let o=n.alias,a=n.id;n.canvasElementAliases=[s];let l={createdByTicketSteps:{canvasElementAlias:s,id:e},ticker:n};if(exports.TickersManagerStatic._currentTickers.set(a,l),l.ticker.start(),n.duration){let h=setTimeout(()=>{let g=exports.TickersManagerStatic._currentTickersTimeouts.get(h.toString());g&&(l.ticker.complete({ignoreTickerSteps:true}),g.aliases.forEach(k=>{gt(k,e);})),exports.TickersManagerStatic.removeTickerTimeoutInfo(h);},n.duration*1e3);exports.TickersManagerStatic.addTickerTimeoutInfo(s,o,h.toString(),false);}}function gt(s,e){let i=exports.TickersManagerStatic._currentTickersSequence.get(s);if(i?.has(e)){let r=i.get(e);r.currentStepNumber+1<r.steps.length?(r.currentStepNumber++,i.set(e,r),Pe(s,e)):e&&i.has(e)&&(i.delete(e),exports.TickersManagerStatic._currentTickers.forEach((n,o)=>{n.createdByTicketSteps?.canvasElementAlias===s&&n.createdByTicketSteps.id===e&&we(o);}));}}function zt(s,e){let{stopTicker:i=true,aliasToRemoveAfter:r,tickerAliasToResume:n,tickerIdToResume:o}=e,a=exports.TickersManagerStatic._currentTickers.get(s),l=e.ignoreTickerSteps||false;core.GameUnifier.removeCanvasComponent(r),n.forEach(h=>{Ke({canvasAlias:h});}),Ke({id:o}),a&&(we(s,{stopTicker:i}),!l&&a.ticker.duration===void 0&&a.createdByTicketSteps&>(a.createdByTicketSteps.canvasElementAlias,a.createdByTicketSteps.id));}function Bt(s,e){if(typeof s=="string"&&(s=[s]),!e){s.forEach(r=>{exports.TickersManagerStatic._currentTickers.forEach((n,o)=>{n.ticker.canvasElementAliases.includes(r)&&(n.ticker.canvasElementAliases.length===1?we(o):n.ticker.canvasElementAliases=n.ticker.canvasElementAliases.filter(a=>a!==r));}),exports.TickersManagerStatic._currentTickersSequence.has(r)&&exports.TickersManagerStatic._currentTickersSequence.delete(r),exports.TickersManagerStatic.removeTickerTimeoutsByAlias(r,false);});return}let i;typeof e=="string"?i=e:i=e.prototype.id,s.forEach(r=>{let n=exports.TickersManagerStatic._currentTickersSequence.get(r);n&&n.forEach((o,a)=>{o.steps.find(l=>typeof l=="object"&&"ticker"in l&&l.ticker===i)&&n.delete(a);});}),exports.TickersManagerStatic._currentTickers.forEach(r=>{r.ticker.alias===i&&(r.ticker.canvasElementAliases=r.ticker.canvasElementAliases.filter(n=>!s.includes(n)));}),exports.TickersManagerStatic._currentTickersTimeouts.forEach(r=>{r.ticker===i&&r.canBeDeletedBeforeEnd&&(r.aliases=r.aliases.filter(n=>!s.includes(n)));}),Dt();}function Dt(){exports.TickersManagerStatic._currentTickers.forEach(s=>{s.ticker.canvasElementAliases=s.ticker.canvasElementAliases.filter(e=>core.GameUnifier.canvasComponentExists(e)),s.ticker.canvasElementAliases.length===0&&s.ticker.complete({ignoreTickerSteps:true});}),exports.TickersManagerStatic._currentTickersSequence.forEach((s,e)=>{s===void 0&&exports.TickersManagerStatic._currentTickersSequence.delete(e);}),Array.from(exports.TickersManagerStatic._currentTickersTimeouts.keys()).forEach(s=>{let e=exports.TickersManagerStatic._currentTickersTimeouts.get(s);e&&e.aliases.length===0&&exports.TickersManagerStatic.removeTickerTimeout(s);});}function Wt(){exports.TickersManagerStatic._currentTickersSequence.clear(),Array.from(exports.TickersManagerStatic._currentTickers.keys()).forEach(s=>{we(s);}),exports.TickersManagerStatic._currentTickers.clear(),Array.from(exports.TickersManagerStatic._currentTickersTimeouts.keys()).forEach(s=>{exports.TickersManagerStatic.removeTickerTimeout(s);}),exports.TickersManagerStatic._tickersToCompleteOnStepEnd.tikersIds.length=0,exports.TickersManagerStatic._tickersToCompleteOnStepEnd.stepAlias.length=0;}function we(s,e={stopTicker:true}){typeof s=="string"&&(s=[s]),s.forEach(i=>{let r=exports.TickersManagerStatic._currentTickers.get(i);r&&(e.stopTicker&&r.ticker.stop(),exports.TickersManagerStatic._currentTickers.delete(i));});}function Pt(s){let e=[];if("canvasAlias"in s){let{canvasAlias:i,tickerIdsExcluded:r=[]}=s;exports.TickersManagerStatic._currentTickers.forEach((n,o)=>{n.ticker.canvasElementAliases.includes(i)&&!r.includes(n.ticker.alias)&&n.ticker.paused===false&&(n.ticker.pause(),e.push(o));});}else if("id"in s){let{id:i}=s;typeof i=="string"&&(i=[i]),[...new Set(i)].forEach(r=>{let n=exports.TickersManagerStatic._currentTickers.get(r);n?n.ticker.paused===false&&(n.ticker.pause(),e.push(r)):B.error(`Ticker with id ${r} not found`);});}return e}function Ke(s){if("canvasAlias"in s){let{canvasAlias:e}=s;exports.TickersManagerStatic._currentTickers.forEach(i=>{i.ticker.canvasElementAliases.includes(e)&&i.ticker.play();});}else if("id"in s){let{id:e}=s;typeof e=="string"&&(e=[e]),[...new Set(e)].forEach(i=>{let r=exports.TickersManagerStatic._currentTickers.get(i);r?r.ticker.play():B.error(`Ticker with id ${i} not found`);});}}function Ut(s,e){return false}function Ht(s,e,i="move"){let r=exports.TickersManagerStatic._currentTickersSequence.get(s);if(r){let o=new Map(Array.from(r.entries()).map(([a,l])=>[a,We(l)]));exports.TickersManagerStatic._currentTickersSequence.set(e,o);}exports.TickersManagerStatic._currentTickers.forEach((o,a)=>{if(o.createdByTicketSteps?.canvasElementAlias===s&&we(a),o.ticker.canvasElementAliases.includes(s)){let l=_e.getInstance(o.ticker.alias,We(o.ticker.args),{duration:o.ticker.duration,priority:o.ticker.priority,canvasElementAliases:[e]});if(l?(pt(e,l),o.ticker.paused&&l.pause()):B.error(`Ticker ${o.ticker.alias} not found`),i==="move"&&(o.ticker.canvasElementAliases=o.ticker.canvasElementAliases.filter(h=>h!==s)),Object.hasOwn(o.ticker.args,ut)){let h=o.ticker.args.aliasToRemoveAfter;typeof h=="string"&&(h=[h]),Array.isArray(h)&&(i==="move"?o.ticker.args.aliasToRemoveAfter=h.map(g=>g===s?e:g):i==="duplicate"&&h.find(g=>g===s)&&(o.ticker.args.aliasToRemoveAfter=[...h,e]));}}}),exports.TickersManagerStatic._currentTickersTimeouts.forEach(o=>{o.aliases.includes(s)&&(i==="move"?o.aliases=o.aliases.map(a=>a===s?e:a):i==="duplicate"&&o.aliases.find(a=>a===s)&&o.aliases.push(e));});let n=exports.TickersManagerStatic._currentTickersSequence.get(e);if(n&&n.forEach((o,a)=>{Pe(e,a);}),i==="duplicate"){let o=exports.TickersManagerStatic._currentTickersSequence.get(s);o&&o.forEach((a,l)=>{Pe(s,l);});}}function qt(s){s.alias?exports.TickersManagerStatic._tickersToCompleteOnStepEnd.stepAlias.push({id:s.id,alias:s.alias}):exports.TickersManagerStatic._tickersToCompleteOnStepEnd.tikersIds.push({id:s.id});}async function Lt(s,e){if(e){let i=exports.TickersManagerStatic._currentTickersSequence.get(e),r=i?.get(s);if(i&&r){let n=r.steps.map(o=>{if(typeof o=="object"&&"ticker"in o){let a=_e.getInstance(o.ticker,o.args,{duration:o.duration,canvasElementAliases:[e],priority:o.priority});if(a)return a.complete()}return Promise.resolve()});await Promise.all(n);}}else {let i=exports.TickersManagerStatic._currentTickers.get(s);i&&await i.ticker.complete();}}function Ti(){let s=exports.TickersManagerStatic._tickersToCompleteOnStepEnd.tikersIds.splice(0,exports.TickersManagerStatic._tickersToCompleteOnStepEnd.tikersIds.length),e=exports.TickersManagerStatic._tickersToCompleteOnStepEnd.stepAlias.splice(0,exports.TickersManagerStatic._tickersToCompleteOnStepEnd.stepAlias.length);return {tikersIds:s,stepAlias:e}}var ki={transfer:Ht,get currentTickers(){return exports.TickersManagerStatic._currentTickers},get currentTickersSteps(){return exports.TickersManagerStatic._currentTickersSequence},find:It,add:pt,addSequence:Ft,unlinkComponent:Bt,removeAll:Wt,remove:we,pause:Pt,resume:Ke,isPaused:Ut,completeOnStepEnd:qt,forceCompletion:Lt,onComplete:zt};exports.RegisteredTickers=_e;exports.TickerBase=Ie;exports.drainCompleteOnStepEndQueue=Ti;exports.removeTicker=we;exports.runTickersSequence=Pe;exports.tickerDecorator=Ot;exports.tickers=ki;
|