{"version":3,"file":"DownloadButton.D7KTNVPF.mjs","names":["useState","startTransition"],"sources":["https:/framerusercontent.com/modules/EZn2JZ6gMv0Cdru1D3ML/9LS7NGLUJtctgWoXfK8a/DownloadButton.js"],"sourcesContent":["// Download button component with file upload and download functionality\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useState,startTransition}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * Download Button with File Upload\n * \n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */export default function DownloadButton(props){const{uploadedFile=\"https://framerusercontent.com/images/GfGkADagM4KEibNcIiRUWlfrR0.jpg\",customFileName=\"download\",downloadText=\"Download\",loadingText=\"Downloading...\",successText=\"Downloaded!\",backgroundColor=\"#0066FF\",textColor=\"#FFFFFF\",hoverColor=\"#0052CC\",borderRadius=8,buttonFont,showIcon=true,iconColor=\"#FFFFFF\",style}=props;const[isHovered,setIsHovered]=useState(false);const[downloadState,setDownloadState]=useState(\"idle\");const handleDownload=async()=>{if(!uploadedFile||downloadState===\"loading\")return;try{startTransition(()=>setDownloadState(\"loading\"));const response=await fetch(uploadedFile);const blob=await response.blob();// Extract file extension from the uploaded file URL\nconst urlParts=uploadedFile.split(\".\");const extension=urlParts[urlParts.length-1].split(\"?\")[0]// Remove query params if any\n;// Use custom filename and ensure it has the correct extension\nlet filename=customFileName||\"download\";// Check if filename already has an extension\nconst hasExtension=filename.includes(\".\");if(!hasExtension&&extension){filename=`${filename}.${extension}`;}// Create download link\nconst url=window.URL.createObjectURL(blob);const link=document.createElement(\"a\");link.href=url;link.download=filename;document.body.appendChild(link);link.click();// Cleanup\ndocument.body.removeChild(link);window.URL.revokeObjectURL(url);startTransition(()=>setDownloadState(\"success\"));// Reset to idle after 2 seconds\nsetTimeout(()=>{startTransition(()=>setDownloadState(\"idle\"));},2e3);}catch(error){console.error(\"Download failed:\",error);startTransition(()=>setDownloadState(\"idle\"));}};const getIcon=()=>{if(!showIcon)return null;const iconStyle={width:\"24px\",height:\"24px\",marginRight:\"8px\",fill:iconColor};if(downloadState===\"loading\"){return /*#__PURE__*/_jsxs(\"svg\",{viewBox:\"0 0 24 24\",style:iconStyle,children:[/*#__PURE__*/_jsx(\"circle\",{cx:\"12\",cy:\"12\",r:\"10\",stroke:iconColor,strokeWidth:\"2\",fill:\"none\",opacity:\"0.3\"}),/*#__PURE__*/_jsx(\"path\",{d:\"M12 2a10 10 0 0 1 10 10\",stroke:iconColor,strokeWidth:\"2\",fill:\"none\",children:/*#__PURE__*/_jsx(\"animateTransform\",{attributeName:\"transform\",type:\"rotate\",values:\"0 12 12;360 12 12\",dur:\"1s\",repeatCount:\"indefinite\"})})]});}if(downloadState===\"success\"){return /*#__PURE__*/_jsxs(\"svg\",{viewBox:\"0 0 24 24\",style:iconStyle,children:[/*#__PURE__*/_jsx(\"circle\",{cx:\"12\",cy:\"12\",r:\"10\",stroke:iconColor,strokeWidth:\"2\",fill:\"none\"}),/*#__PURE__*/_jsx(\"path\",{d:\"M9 12l2 2 4-4\",stroke:iconColor,strokeWidth:\"2\",fill:\"none\"})]});}return /*#__PURE__*/_jsxs(\"svg\",{viewBox:\"0 0 24 24\",style:iconStyle,children:[/*#__PURE__*/_jsx(\"circle\",{cx:\"12\",cy:\"12\",r:\"10\",stroke:iconColor,strokeWidth:\"2\",fill:\"none\"}),/*#__PURE__*/_jsx(\"path\",{d:\"M8 12l4 4 4-4M12 8v8\",stroke:iconColor,strokeWidth:\"2\",fill:\"none\"})]});};const getCurrentText=()=>{switch(downloadState){case\"loading\":return loadingText;case\"success\":return successText;default:return downloadText;}};const buttonStyle={display:\"inline-flex\",alignItems:\"center\",justifyContent:\"center\",padding:\"12px 24px\",backgroundColor:downloadState===\"success\"?\"#22CC66\":isHovered?hoverColor:backgroundColor,color:textColor,border:\"none\",borderRadius:`${borderRadius}px`,cursor:downloadState===\"loading\"?\"not-allowed\":\"pointer\",transition:\"background-color 0.2s ease\",...buttonFont,minWidth:\"max-content\",opacity:downloadState===\"loading\"?.7:1};return /*#__PURE__*/_jsx(\"div\",{style:{...style,position:\"relative\"},children:/*#__PURE__*/_jsxs(\"button\",{style:buttonStyle,onClick:handleDownload,onMouseEnter:()=>downloadState===\"idle\"&&startTransition(()=>setIsHovered(true)),onMouseLeave:()=>startTransition(()=>setIsHovered(false)),disabled:downloadState===\"loading\",children:[getIcon(),getCurrentText()]})});}addPropertyControls(DownloadButton,{uploadedFile:{type:ControlType.File,title:\"Upload File\",allowedFileTypes:[\"mp3\",\"wav\",\"ogg\",\"m4a\",\"mp4\",\"webm\",\"mov\",\"avi\",\"pdf\",\"doc\",\"docx\",\"xls\",\"xlsx\",\"csv\",\"zip\"]},customFileName:{type:ControlType.String,title:\"File Name\",defaultValue:\"download\",placeholder:\"e.g., brand-assets (no extension needed)\"},downloadText:{type:ControlType.String,title:\"Download Text\",defaultValue:\"Download\"},loadingText:{type:ControlType.String,title:\"Loading Text\",defaultValue:\"Downloading...\"},successText:{type:ControlType.String,title:\"Success Text\",defaultValue:\"Downloaded!\"},backgroundColor:{type:ControlType.Color,title:\"Background Color\",defaultValue:\"#0066FF\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#FFFFFF\"},hoverColor:{type:ControlType.Color,title:\"Hover Color\",defaultValue:\"#0052CC\"},borderRadius:{type:ControlType.Number,title:\"Border Radius\",defaultValue:8,min:0,max:50,step:1,unit:\"px\"},buttonFont:{type:ControlType.Font,title:\"Button Font\",defaultValue:{fontSize:\"14px\",variant:\"Semibold\",letterSpacing:\"-0.01em\",lineHeight:\"1em\"},controls:\"extended\",defaultFontType:\"sans-serif\"},showIcon:{type:ControlType.Boolean,title:\"Show Icon\",defaultValue:true,enabledTitle:\"Show\",disabledTitle:\"Hide\"},iconColor:{type:ControlType.Color,title:\"Icon Color\",defaultValue:\"#FFFFFF\",hidden:({showIcon})=>!showIcon}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"DownloadButton\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"auto\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./DownloadButton.map"],"mappings":"kMAMG,SAAwB,EAAe,EAAM,CAAC,GAAK,CAAC,eAAa,sEAAsE,iBAAe,WAAW,eAAa,WAAW,cAAY,iBAAiB,cAAY,cAAc,kBAAgB,UAAU,YAAU,UAAU,aAAW,UAAU,eAAa,EAAE,aAAW,WAAS,GAAK,YAAU,UAAU,SAAO,EAAW,CAAC,EAAU,GAAcA,EAAS,EAAK,EAAO,CAAC,EAAc,GAAkBA,EAAS,MAAM,EAAQ,EAAe,SAAS,CAAI,MAAC,GAAc,IAAgB,WAAiB,GAAG,CAAC,MAAoB,EAAiB,SAAS,CAAC,EAA2C,IAAM,EAAK,MAAM,MAArC,MAAM,CAAY,EAAA,CAA4B,KAAK,EAC7qB,EAAS,EAAa,MAAM,GAAG,EAAQ,EAAU,EAAS,EAAS,OAAO,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,GAE1F,EAAS,GAAgB,WACgB,CAA1B,EAAS,SAAS,GAAoB,GAAG,IAAW,EAAS,GAAG,EAAS,GAAG,KAC/F,IAAM,EAAI,EAAO,IAAI,gBAAgB,CAAI,EAAQ,EAAK,SAAS,cAAc,GAAG,EAAE,EAAK,KAAK,EAAI,EAAK,SAAS,EAAS,SAAS,KAAK,YAAY,CAAI,EAAE,EAAK,MAAM,EAClK,SAAS,KAAK,YAAY,CAAI,EAAE,EAAO,IAAI,gBAAgB,CAAG,EAAE,MAAoB,EAAiB,SAAS,CAAC,EAC/G,eAAe,CAAC,MAAoB,EAAiB,MAAM,CAAC,CAAE,EAAE,GAAG,CAAE,OAAO,EAAM,CAAC,QAAQ,MAAM,mBAAmB,CAAK,EAAE,MAAoB,EAAiB,MAAM,CAAC,CAAE,CAAC,EAAQ,MAAY,CAAC,GAAG,CAAC,EAAS,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