{"version":3,"file":"soundbutton.DF7px6Cu.mjs","names":[],"sources":["https:/framerusercontent.com/modules/5RqEC9VsxcGgSywRgqVa/Ae8CLrZhv0oaJtWg0ISf/soundbutton.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";// 1. Audio Source\nconst SOUND_URL=\"https://cdn.uppbeat.io/audio-files/550fafd5d5403a2f6e11b6feefd0899e/5c3e7ee609171f68868d67f0edccfe95/eea5348a5bb5e6f0d19e399b8a1da794/STREAMING-alert-cute-pop-ding-bosnow-2-2-00-00.mp3\";// 2. Playback Settings\nconst START_PERCENTAGE=0// 0 to 100\n;const MAX_VOLUME=20// 0 to 100 (percentage of full volume)\n;// 3. Fade Settings\nconst ENABLE_FADE_IN=\"no\"// \"yes\" or \"no\"\n;const FADE_IN_DURATION=0// Duration in milliseconds\n;const FADE_STEPS=0// Smoothness of the fade\n;export function withClickSound(Component){return props=>{const playSound=()=>{const audio=new Audio(SOUND_URL);// Convert 0-100 scale to 0-1 for the Audio API\nconst targetVolume=MAX_VOLUME/100;audio.addEventListener(\"loadedmetadata\",()=>{// Set start position\nconst startTime=START_PERCENTAGE/100*audio.duration;audio.currentTime=startTime;if(ENABLE_FADE_IN===\"yes\"){audio.volume=0;// We calculate the increment based on the MAX_VOLUME, not 1.0\nconst volumeIncrement=targetVolume/FADE_STEPS;const intervalTime=FADE_IN_DURATION/FADE_STEPS;let currentStep=0;const fadeInterval=setInterval(()=>{currentStep++;const newVolume=Math.min(currentStep*volumeIncrement,targetVolume);audio.volume=newVolume;if(currentStep>=FADE_STEPS){clearInterval(fadeInterval);}},intervalTime);}else{// If no fade, just jump straight to the max volume\naudio.volume=targetVolume;}audio.play().catch(e=>console.error(\"Playback failed:\",e));});};return /*#__PURE__*/_jsx(Component,{...props,onClick:e=>{playSound();if(props.onClick)props.onClick(e);}});};}\nexport const __FramerMetadata__ = {\"exports\":{\"withClickSound\":{\"type\":\"reactHoc\",\"name\":\"withClickSound\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./soundbutton.map"],"mappings":"oGAQC,SAAgB,EAAe,EAAU,CAAC,MAAO,IAAO,CAAC,IAAM,MAAc,CAAC,IAAM,EAAM,IAAI,MAAM,EAAU,CACzG,EAAa,EAAW,IAAI,EAAM,iBAAiB,qBAAqB,CACE,GAA5B,EAAM,YAA1C,EAAiB,IAAI,EAAM,SAAwC,IAAiB,MAAM,CAAC,EAAM,OAAO,EACxH,IAAM,EAAgB,EAAa,EAAiB,EAAa,EAAiB,EAAe,EAAY,EAAQ,EAAa,gBAAgB,CAAC,IAAiF,EAAM,OAAzD,KAAK,IAAI,EAAY,EAAgB,EAAa,CAA2B,GAAa,GAAY,cAAc,EAAa,EAAI,EAAa,MACnU,EAAM,OAAO,EAAc,EAAM,MAAM,CAAC,MAAM,GAAG,QAAQ,MAAM,mBAAmB,EAAE,CAAC,EAAG,EAAG,OAAoB,EAAK,EAAU,CAAC,GAAG,EAAM,QAAQ,GAAG,CAAC,GAAW,CAAI,EAAM,SAAQ,EAAM,QAAQ,EAAE,EAAG,CAAC,+BAZ1J,CACrC,EAAU,2LACV,EAAiB,EAChB,EAAW,GAEZ,EAAe,KACd,EAAiB,EACjB,EAAW"}