(function (root) { "use strict"; const TRACKS = Object.freeze({ village: "village-theme", forest: "forest-theme", ruins: "forest-theme", mountain: "mountain-theme", camp: "mountain-theme", fortressExterior: "fortress-theme", fortressInterior: "fortress-theme", bossArena: "boss-theme", chamber: "victory-theme" }); function create(getState) { let scene = null; let ambience = null; let unlocked = false; function attach(nextScene, region) { scene = nextScene; if (ambience) ambience.stop(); const key = TRACKS[region] || "village-theme"; ambience = scene.cache.audio.exists(key) ? scene.sound.add(key, { loop: true }) : null; apply(); } function unlock() { unlocked = true; if (scene && scene.sound.locked && scene.sound.unlock) scene.sound.unlock(); apply(); } function apply() { if (!scene) return; const state = getState(); const enabled = Boolean(unlocked && state && state.settings.soundEnabled); scene.sound.mute = !enabled; if (ambience) { ambience.setVolume((state.settings.master || 0) * (state.settings.music || 0)); if (enabled && !ambience.isPlaying) ambience.play(); if (!enabled && ambience.isPlaying) ambience.pause(); } } function play(key, volume) { const state = getState(); if (!scene || !unlocked || !state.settings.soundEnabled || !scene.cache.audio.exists(key)) return; scene.sound.play(key, { volume: state.settings.master * state.settings.effects * (volume || 1) }); } function suspend() { if (ambience && ambience.isPlaying) ambience.pause(); } function resume() { apply(); } function stop() { if (ambience) ambience.stop(); ambience = null; scene = null; } return Object.freeze({ attach, unlock, apply, play, suspend, resume, stop, isUnlocked: () => unlocked }); } root.PrincessLimaAudio = Object.freeze({ create, TRACKS }); }(typeof globalThis !== "undefined" ? globalThis : this));