{"version":3,"file":"SoundIconButton.6_DntJOj.mjs","names":["useState","useRef","p"],"sources":["https:/framerusercontent.com/modules/8nGT5Ss8BFFeWeoMDLrY/WCHB1zIeYYZJClQ1d8Sl/SoundIconButton.js"],"sourcesContent":["// Sound icon button that toggles sound on/off, plays sound, lets user manage icon and volume\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useState,useRef,useEffect,startTransition}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * SoundIconButton\n * Toggle sound on/off with icon, play/pause sound, manage icon and volume.\n * @framerDisableUnlink\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function SoundIconButton(props){// Defaults for icons and audio file\nconst{iconOn={src:\"https://framerusercontent.com/images/BYnxEV1zjYb9bhWh1IwBZ1ZoS60.jpg\",alt:\"On Icon\"},iconOff={src:\"https://framerusercontent.com/images/aNsAT3jCvt4zglbWCUoFe33Q.jpg\",alt:\"Off Icon\"},audioFile=\"https://framerusercontent.com/assets/8w3IUatLX9a5JVJ6XPCVuHi94.mp3\",initialVolume=.5,style}=props;const[playing,setPlaying]=useState(false);const[volume,setVolume]=useState(initialVolume);const audioRef=useRef(null);// Only create Audio object after mount, never SSR\nuseEffect(()=>{if(typeof window===\"undefined\")return;if(!audioRef.current){audioRef.current=new window.Audio(audioFile);audioRef.current.loop=true;audioRef.current.volume=volume;}else{audioRef.current.src=audioFile;audioRef.current.volume=volume;}if(playing){audioRef.current.play().catch(()=>{});}else{audioRef.current.pause();audioRef.current.currentTime=0// rewind on stop\n;}audioRef.current.volume=volume;return()=>{audioRef.current?.pause();};// eslint-disable-next-line react-hooks/exhaustive-deps\n},[audioFile,playing]);// Update volume separately to avoid flicks\nuseEffect(()=>{if(audioRef.current)audioRef.current.volume=volume;},[volume]);// Toggle play/pause\nfunction handleClick(){startTransition(()=>setPlaying(p=>!p));}// Volume change handler\nfunction handleVolume(e){const v=Number(e.target.value);startTransition(()=>setVolume(v));}const icon=playing?iconOn:iconOff;return /*#__PURE__*/_jsx(\"div\",{style:{display:\"flex\",flexDirection:\"column\",alignItems:\"center\",gap:8,width:\"100%\",height:\"100%\",...style},children:/*#__PURE__*/_jsx(\"button\",{style:{background:\"none\",border:\"none\",padding:0,cursor:\"pointer\"},onClick:handleClick,\"aria-label\":playing?\"Pause sound\":\"Play sound\",children:/*#__PURE__*/_jsx(\"img\",{src:icon?.src||\"\",alt:icon?.alt||\"Icon\",width:\"100%\",height:\"100%\",style:{display:\"block\",pointerEvents:\"none\",objectFit:\"contain\",width:\"100%\",height:\"100%\"}})})});}addPropertyControls(SoundIconButton,{iconOn:{type:ControlType.ResponsiveImage,title:\"On Icon\"},iconOff:{type:ControlType.ResponsiveImage,title:\"Off Icon\"},audioFile:{type:ControlType.File,allowedFileTypes:[\"mp3\",\"wav\",\"ogg\"],title:\"Audio File\"},initialVolume:{type:ControlType.Number,title:\"Initial Volume\",defaultValue:.5,min:0,max:1,step:.01,unit:\"\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"SoundIconButton\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerDisableUnlink\":\"* @framerSupportedLayoutWidth any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./SoundIconButton.map"],"mappings":"6MAOG,SAAwB,EAAgB,EAAM,CACjD,GAAK,CAAC,SAAO,CAAC,IAAI,uEAAuE,IAAI,UAAU,CAAC,UAAQ,CAAC,IAAI,oEAAoE,IAAI,WAAW,CAAC,YAAU,qEAAqE,gBAAc,GAAG,SAAO,EAAW,CAAC,EAAQ,GAAYA,EAAS,GAAM,CAAM,CAAC,EAAO,GAAWA,EAAS,EAAc,CAAO,EAASC,EAAO,KAAK,CAC3a,MAAc,CAAI,GAAO,IAAS,OACD,OADwB,EAAS,SAAsH,EAAS,QAAQ,IAAI,EAAU,E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