import{i as e,n as t}from"./rolldown-runtime-BKYq3fBv.js";import{a as n,n as r,r as i,t as a}from"./vendor-other-BnH5nyVX.js";import{an as o,i as s,in as c,r as l}from"./api-z_dXWY_S.js";var u,useAudioService,d=t((()=>{i(),r(),c(),s(),u=!1,useAudioService=()=>{let handleError=(e,t,n)=>{console.error(`Audio Service Error (${e}):`,t,n)},stopAllTracks=e=>{e&&=(e.getTracks().forEach(e=>{e.stop()}),null)},registerWavEncoder=async()=>{if(!u)try{await n(await a()),u=!0}catch(e){e instanceof Error&&e.message.includes(`already an encoder stored`)?u=!0:handleError(`encoder`,`Failed to register WAV encoder`,e)}},convertBlobToFileAndSubmit=async e=>{let t=`recording-${Date.now()}.wav`,n=new File([e],t,{type:e.type||`audio/wav`}),r=new FormData;r.append(`image`,n),r.append(`subfolder`,`audio`),r.append(`type`,`temp`);let i=await l.fetchApi(`/upload/image`,{method:`POST`,body:r});if(i.status!==200){let e=`Error uploading temp file: ${i.status} - ${i.statusText}`;throw o().addAlert(e),Error(e)}return`audio/${(await i.json()).name} [temp]`};return{convertBlobToFileAndSubmit,registerWavEncoder,stopAllTracks}}}));export{useAudioService as n,d as t};
//# sourceMappingURL=audioService-BeWIC_zI.js.map