!function(){"use strict";function s(n){return new Promise(function(t,e){var u=new XMLHttpRequest;u.open("GET",n),u.responseType="arraybuffer",u.onload=function(){var n,o;200===u.status?(n=new Blob([u.response],{type:"audio/mpeg"}),o=n,new Promise(function(t,e){var n=new FileReader;n.onload=function(n){t(n.target.result)},n.onerror=function(n){e(n)},n.readAsDataURL(o)}).then(t).catch(e)):e({message:"Failed to download audio",xmlHttpRequest:u})},u.onerror=function(n){e(n)},u.send()})}function t(n){function t(){for(;0<c.length;){var t=c.shift();try{t.resolve({paused:0<o.currentTime&&o.currentTime<o.duration})}catch(n){try{t.reject(n)}catch(n){}}}}function e(n){for(u=n;0<c.length;){var t=c.shift();try{t.reject(n)}catch(n){}}}var o=new Audio,u=null,i=!1,r=!1,c=[],a={src:n,isPlaying:function(){return!u&&!o.paused},play:function(){return new Promise(function(n,t){var e;u?t(u):(e=c.length<1,c.push({resolve:n,reject:t}),e&&(i=!0,r&&o.play()))})},pause:function(){i=!1,r&&o.pause()},stop:function(){this.pause(),r&&(o.currentTime=0)}};return o.addEventListener("pause",t),o.addEventListener("ended",t),o.addEventListener("error",e),o.addEventListener("canplaythrough",function(){r=!0,i?o.play():t()}),s(n).then(function(n){o.src=n}).catch(e),a}var e="icon-play",o="icon-pause",u={},i=null,r={getAudioPlayer:function(n){return u[n]||(u[n]=t(n))},pauseRunningPlayer:function(){i&&(i.pause(),i=null)},getRunningPlayer:function(){return i},setRunningPlayer:function(n){i=n}},c="MediaPlayerIcon",a="data-mediathumb-url",l={getAudioButtons:function(n){return document.querySelectorAll(".".concat(c,"[").concat(a,"='").concat(n,"']"))},getAudioUrl:function(n){return n.getAttribute(a)},setButtonIcon:function(n,t){n.classList.toggle(o,t===o),n.classList.toggle(e,t===e)},setAllButtonIconsByAudioUrl:function(n,t){var e=this;this.getAudioButtons(n).forEach(function(n){e.setButtonIcon(n,t)})},playAudio:function(n){var t=this;r.pauseRunningPlayer(),this.setAllButtonIconsByAudioUrl(n.src,o),r.setRunningPlayer(n),n.play().then(function(){}).catch(function(n){console.error(n)}).finally(function(){t.setAllButtonIconsByAudioUrl(n.src,e),r.getRunningPlayer()===n&&r.setRunningPlayer(null)})},clickAudioButton:function(n){!n.classList.contains(c)||(n=this.getAudioUrl(n))&&((n=r.getAudioPlayer(n)).isPlaying()?n.pause():this.playAudio(n))},verifyRunningAudio:function(){var n=r.getRunningPlayer();n&&n.isPlaying()&&this.getAudioButtons(n.src).length<1&&n.stop()}};document.addEventListener("click",function(n){return l.clickAudioButton(n.target)}),new MutationObserver(l.verifyRunningAudio.bind(l)).observe(document,{childList:!0,subtree:!0});var n=l;window.Roblox=window.Roblox||{},window.Roblox.Audio={AudioService:r,AudioButtonService:n}}();
//# sourceMappingURL=https://js.rbxcdn.com/610aa2a152fc739ffcb0-audioButton.js.map

/* Bundle detector */
window.Roblox && window.Roblox.BundleDetector && window.Roblox.BundleDetector.bundleDetected("AudioButton");