function audioBufferToWav(e,t){var n=e.numberOfChannels,a=e.sampleRate,t=(t=t||{}).float32?3:1,r=3==t?32:16,e=2===n?interleave(e.getChannelData(0),e.getChannelData(1)):e.getChannelData(0);return encodeWAV(e,t,a,n,r)}function encodeWAV(e,t,n,a,r){var o=r/8,d=a*o,i=new ArrayBuffer(44+e.length*o),l=new DataView(i);return writeString(l,0,"RIFF"),l.setUint32(4,36+e.length*o,!0),writeString(l,8,"WAVE"),writeString(l,12,"fmt "),l.setUint32(16,16,!0),l.setUint16(20,t,!0),l.setUint16(22,a,!0),l.setUint32(24,n,!0),l.setUint32(28,n*d,!0),l.setUint16(32,d,!0),l.setUint16(34,r,!0),writeString(l,36,"data"),l.setUint32(40,e.length*o,!0),(1===t?floatTo16BitPCM:writeFloat32)(l,44,e),i}function interleave(e,t){for(var n=e.length+t.length,a=new Float32Array(n),r=0,o=0;r<n;)a[r++]=e[o],a[r++]=t[o],o++;return a}function writeFloat32(e,t,n){for(var a=0;a<n.length;a++,t+=4)e.setFloat32(t,n[a],!0)}function floatTo16BitPCM(e,t,n){for(var a=0;a<n.length;a++,t+=2){var r=Math.max(-1,Math.min(1,n[a]));e.setInt16(t,r<0?32768*r:32767*r,!0)}}function writeString(e,t,n){for(var a=0;a<n.length;a++)e.setUint8(t+a,n.charCodeAt(a))}function daextrevopMain(){var e=document.getElementById("daextrevop-play-icon");const t=document.getElementById("daextrevop-audio-player-container"),n=document.getElementById("daextrevop-seek-slider");var a=document.getElementById("daextrevop-volume-slider"),r=document.getElementById("daextrevop-mute-icon");const o=document.getElementById("daextrevop-play-circle"),d=document.getElementById("daextrevop-pause-circle"),i=document.getElementById("daextrevop-volume-max"),l=document.getElementById("daextrevop-volume-x");let u="play",s="unmute";if(void 0===e||null==e)return;e.addEventListener("click",()=>{u="play"===u?(m.play(),o.classList.add("daextrevop-display-none"),d.classList.remove("daextrevop-display-none"),requestAnimationFrame(E),"pause"):(m.pause(),o.classList.remove("daextrevop-display-none"),d.classList.add("daextrevop-display-none"),cancelAnimationFrame(y),"play")}),r.addEventListener("click",()=>{s="unmute"===s?(i.classList.add("daextrevop-display-none"),l.classList.remove("daextrevop-display-none"),m.muted=!0,"mute"):(i.classList.remove("daextrevop-display-none"),l.classList.add("daextrevop-display-none"),m.muted=!1,"unmute")});const c=e=>{e===n?t.style.setProperty("--seek-before-width",e.value/e.max*100+"%"):t.style.setProperty("--volume-before-width",e.value/e.max*100+"%")},m=(n.addEventListener("input",e=>{c(e.target)}),a.addEventListener("input",e=>{c(e.target)}),document.querySelector("audio")),v=document.getElementById("daextrevop-duration"),p=document.getElementById("daextrevop-current-time"),f=document.getElementById("daextrevop-volume-output");let y=null;const h=e=>{var t=Math.floor(e/60),e=Math.floor(e%60);return t+":"+(e<10?"0"+e:""+e)},g=()=>{v.textContent=h(m.duration)},x=()=>{n.max=Math.floor(m.duration)},w=()=>{var e;0<m.buffered.length&&(e=Math.floor(m.buffered.end(m.buffered.length-1)),t.style.setProperty("--buffered-width",e/n.max*100+" % "))},E=()=>{n.value=Math.floor(m.currentTime),p.textContent=h(n.value),t.style.setProperty("--seek-before-width",n.value/n.max*100+" % "),y=requestAnimationFrame(E)};0<m.readyState?(g(),x(),w()):m.addEventListener("loadedmetadata",()=>{g(),x(),w()}),m.addEventListener("progress",w),m.addEventListener("ended",()=>{o.classList.remove("daextrevop-display-none"),d.classList.add("daextrevop-display-none"),u="play"}),n.addEventListener("input",()=>{p.textContent=h(n.value),m.paused||cancelAnimationFrame(y)}),n.addEventListener("change",()=>{m.currentTime=n.value,m.paused||requestAnimationFrame(E)}),a.addEventListener("input",e=>{e=e.target.value;f.textContent=e,m.volume=e/100})}async function fetchAudio(e){var t=await fetch(e);if(t.ok)return t.arrayBuffer();throw new Error("Failed to fetch "+e)}async function concatenateAudioFiles(e){let t=null;if(1<e.length){const o=new(window.AudioContext||window.webkitAudioContext);var a=await Promise.all(e.map(async e=>{e=await fetchAudio(e);return o.decodeAudioData(e)}));const d=a[0].sampleRate;if(!a.every(e=>e.sampleRate===d))throw new Error("Audio files have different sample rates");var r=a.reduce((e,t)=>e+t.length,0);const i=o.createBuffer(2,r,d);let n=0;a.forEach(t=>{for(let e=0;e<t.numberOfChannels;e++)i.getChannelData(e).set(t.getChannelData(e),n);n+=t.length});r=audioBufferToWav(i),a=new Blob([r],{type:"audio/wav"});t=URL.createObjectURL(a)}else t=e[0];document.querySelector("#daextrevop-audio-player-container > audio").src=t;r=document.getElementById("daextrevop-download-button");r&&(r.href=t),daextrevopMain()}window.DAEXTREVOP_PHPDATA.audioFileUrl&&Array.isArray(window.DAEXTREVOP_PHPDATA.audioFileUrl)&&0<window.DAEXTREVOP_PHPDATA.audioFileUrl.length&&concatenateAudioFiles(window.DAEXTREVOP_PHPDATA.audioFileUrl);