{"version":3,"file":"DownloadButton.CWxtWIy2.mjs","names":["useState","startTransition","__esmMin","window","te","init_ssg_sandbox_shims","init_npm_react_18_3_1","_e","init_jsx_runtime","p","addPropertyControls","init_framer_Bf4_tcb2","ControlType","DownloadButton","props","isHovered","setIsHovered","downloadState","setDownloadState","handleDownload","uploadedFile","blob","urlParts","extension","filename","customFileName","url","link","error","getIcon","showIcon","iconStyle","iconColor","getCurrentText","loadingText","successText","downloadText","buttonStyle","hoverColor","backgroundColor","textColor","borderRadius","buttonFont","style","init_DownloadButton"],"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":"A,iMAMG,SAAwBa,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,SAAOC,EAAW,CAACC,EAAUC,GAAchB,EAAS,EAAK,EAAO,CAACiB,EAAcC,GAAkBlB,EAAS,MAAM,EAAQmB,EAAe,SAAS,CAAC,GAAIC,GAAcH,IAAgB,UAAiB,GAAG,CAACb,MAAoBc,EAAiB,SAAS,CAAC,EAA2C,IAAMG,EAAK,MAAM,MAArC,MAAMD,CAAY,EAAA,CAA4B,KAAK,EAC7qBE,EAASF,EAAa,MAAM,GAAG,EAAQG,EAAUD,EAASA,EAAS,OAAO,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,GAE1FE,EAASC,GAAgB,WACgB,CAA1BD,EAAS,SAAS,GAAoB,GAAGD,IAAW,EAAS,GAAGC,EAAS,GAAGD,KAC/F,IAAMG,EAAIvB,EAAO,IAAI,gBAAgBkB,CAAI,EAAQM,EAAK,SAAS,cAAc,GAAG,EAAE,EAAK,KAAKD,EAAI,EAAK,SAASF,EAAS,SAAS,KAAK,YA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