{"version":3,"file":"DownloadButton.DfvbOynp.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/02BqZLx9fg23kMPFVuvg/WQzUGd8rmk6qLcEUpvAy/DownloadButton.js"],"sourcesContent":["// Framer Download Button Component - A customizable button for downloading files with icon options and hover states\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useState}from\"react\";/**\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */export default function DownloadButton(props){const{buttonText,sourceType,fileUrl,uploadedFile=\"https://framerusercontent.com/assets/N8rycCxFgkANGzlI0U0qPu2n0dc.png\",downloadFileName,fontSize,fontFamily,fontWeight,textColor,backgroundColor,borderRadius,paddingVertical,paddingHorizontal,icon,iconPosition,gap,hoverBackgroundColor,hoverTextColor,trackingId}=props;const[isHovered,setIsHovered]=useState(false);const fileSource=sourceType===\"url\"?fileUrl:uploadedFile;const handleDownload=async()=>{if(!fileSource||typeof window===\"undefined\")return;try{// Fetch the file as a blob\nconst response=await fetch(fileSource);const blob=await response.blob();// Create a blob URL\nconst blobUrl=window.URL.createObjectURL(blob);// Create a temporary link element\nconst link=document.createElement(\"a\");link.href=blobUrl;// Determine the filename\nlet filename=\"file\";if(downloadFileName&&downloadFileName.trim()!==\"\"){// Use custom download name if provided\nfilename=downloadFileName;}else{// Extract filename from URL\ntry{const url=new URL(fileSource);const pathname=url.pathname;const extractedName=pathname.substring(pathname.lastIndexOf(\"/\")+1);if(extractedName){filename=decodeURIComponent(extractedName);}}catch{// If URL parsing fails, try to get from Content-Disposition header\nconst contentDisposition=response.headers.get(\"content-disposition\");if(contentDisposition){const filenameMatch=contentDisposition.match(/filename=\"?(.+)\"?/i);if(filenameMatch){filename=filenameMatch[1];}}}}link.download=filename;// Trigger download\ndocument.body.appendChild(link);link.click();// Cleanup\ndocument.body.removeChild(link);window.URL.revokeObjectURL(blobUrl);}catch(error){console.error(\"Download failed:\",error);}};const buttonStyle={gap:`${gap}px`,fontSize:`${fontSize}px`,lineHeight:1,fontFamily:fontFamily,fontWeight:fontWeight,width:\"max-content\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",textDecoration:\"none\",padding:`${paddingVertical}px ${paddingHorizontal}px`,color:isHovered&&hoverTextColor?hoverTextColor:textColor,backgroundColor:isHovered&&hoverBackgroundColor?hoverBackgroundColor:backgroundColor,borderRadius:`${borderRadius}px`,userSelect:\"none\",whiteSpace:\"nowrap\",cursor:\"pointer\",transition:\"all 0.2s ease\",border:\"none\"};const iconStyle={width:`${fontSize*1.2}px`,height:`${fontSize*1.2}px`,flexShrink:0};const renderIcon=()=>{if(!icon||icon===\"none\")return null;const icons={download:/*#__PURE__*/_jsxs(\"svg\",{style:iconStyle,viewBox:\"0 0 24 24\",fill:\"none\",stroke:\"currentColor\",strokeWidth:\"2\",children:[/*#__PURE__*/_jsx(\"path\",{d:\"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4\"}),/*#__PURE__*/_jsx(\"polyline\",{points:\"7 10 12 15 17 10\"}),/*#__PURE__*/_jsx(\"line\",{x1:\"12\",y1:\"15\",x2:\"12\",y2:\"3\"})]}),arrow:/*#__PURE__*/_jsxs(\"svg\",{style:iconStyle,viewBox:\"0 0 24 24\",fill:\"none\",stroke:\"currentColor\",strokeWidth:\"2\",children:[/*#__PURE__*/_jsx(\"line\",{x1:\"12\",y1:\"5\",x2:\"12\",y2:\"19\"}),/*#__PURE__*/_jsx(\"polyline\",{points:\"19 12 12 19 5 12\"})]}),cloud:/*#__PURE__*/_jsxs(\"svg\",{style:iconStyle,viewBox:\"0 0 24 24\",fill:\"none\",stroke:\"currentColor\",strokeWidth:\"2\",children:[/*#__PURE__*/_jsx(\"path\",{d:\"M20.88 18.09A5 5 0 0 0 18 9h-1.26A8 8 0 1 0 3 16.29\"}),/*#__PURE__*/_jsx(\"polyline\",{points:\"8 16 12 20 16 16\"}),/*#__PURE__*/_jsx(\"line\",{x1:\"12\",y1:\"12\",x2:\"12\",y2:\"20\"})]})};return icons[icon];};return /*#__PURE__*/_jsxs(\"button\",{onClick:handleDownload,title:`Download ${downloadFileName||\"file\"}`,style:buttonStyle,onMouseEnter:()=>setIsHovered(true),onMouseLeave:()=>setIsHovered(false),\"data-tracking-id\":trackingId||undefined,children:[iconPosition===\"left\"&&renderIcon(),buttonText,iconPosition===\"right\"&&renderIcon()]});}addPropertyControls(DownloadButton,{buttonText:{type:ControlType.String,title:\"Text\",defaultValue:\"Download\"},sourceType:{type:ControlType.Enum,title:\"Source\",options:[\"upload\",\"url\"],optionTitles:[\"Upload\",\"URL\"],defaultValue:\"upload\"},uploadedFile:{type:ControlType.File,title:\"File\",allowedFileTypes:[\"pdf\"],hidden:props=>props.sourceType!==\"upload\"},fileUrl:{type:ControlType.String,title:\"URL\",defaultValue:\"https://framerusercontent.com/assets/N8rycCxFgkANGzlI0U0qPu2n0dc.png\",hidden:props=>props.sourceType!==\"url\"},downloadFileName:{type:ControlType.String,title:\"Download Name\",description:\"Name of the downloaded file\"},fontSize:{type:ControlType.Number,title:\"Font Size\",min:8,max:72,defaultValue:16,displayStepper:true},fontFamily:{type:ControlType.String,title:\"Font\",defaultValue:\"Inter\"},fontWeight:{type:ControlType.Enum,title:\"Weight\",options:[300,400,500,600,700,800],optionTitles:[\"Light\",\"Regular\",\"Medium\",\"Semibold\",\"Bold\",\"Extra Bold\"],defaultValue:500},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"rgb(255, 255, 255)\"},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"rgb(17, 17, 17)\"},borderRadius:{type:ControlType.Number,title:\"Radius\",min:0,max:100,defaultValue:50,displayStepper:true},paddingVertical:{type:ControlType.Number,title:\"Padding Y\",min:0,max:50,defaultValue:10,displayStepper:true},paddingHorizontal:{type:ControlType.Number,title:\"Padding X\",min:0,max:100,defaultValue:20,displayStepper:true},icon:{type:ControlType.Enum,title:\"Icon\",options:[\"none\",\"download\",\"arrow\",\"cloud\"],optionTitles:[\"None\",\"Download\",\"Arrow\",\"Cloud\"],defaultValue:\"download\"},iconPosition:{type:ControlType.Enum,title:\"Icon Position\",options:[\"left\",\"right\"],optionTitles:[\"Left\",\"Right\"],defaultValue:\"left\",hidden:props=>props.icon===\"none\"},gap:{type:ControlType.Number,title:\"Gap\",min:0,max:30,defaultValue:8,displayStepper:true,hidden:props=>props.icon===\"none\"},hoverBackgroundColor:{type:ControlType.Color,title:\"Hover BG\",defaultValue:\"rgb(40, 40, 40)\",optional:true},hoverTextColor:{type:ControlType.Color,title:\"Hover Text\",optional:true},trackingId:{type:ControlType.String,title:\"Tracking ID\",defaultValue:\"\",optional:true}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"DownloadButton\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"auto\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./DownloadButton.map"],"mappings":"+LAIG,SAAwB,EAAe,EAAM,CAAC,GAAK,CAAC,aAAW,aAAW,UAAQ,eAAa,uEAAuE,mBAAiB,WAAS,aAAW,aAAW,YAAU,kBAAgB,eAAa,kBAAgB,oBAAkB,OAAK,eAAa,MAAI,uBAAqB,iBAAe,cAAY,EAAW,CAAC,EAAU,GAAcA,EAAS,GAAM,CAAO,EAAW,IAAa,MAAM,EAAQ,EAAmB,EAAe,SAAS,CAAI,MAAC,GAAmB,IAAS,QAAmB,GAAG,CAC1iB,IAAM,EAAS,MAAM,MAAM,EAAW,CAAO,EAAK,MAAM,EAAS,MAAM,CACjE,EAAQ,EAAO,IAAI,gBAAgB,EAAK,CACxC,EAAK,SAAS,cAAc,IAAI,CAAC,EAAK,KAAK,EACjD,IAAI,EAAS,OAAO,GAAG,GAAkB,EAAiB,MAAM,GAAG,GACnE,EAAS,OACT,GAAG,CAA+B,IAAM,EAA1B,IAAI,IA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