{"version":3,"file":"DownloadButton.CJaW6jBG.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/vHCRC9NWbaC75t7X0Gln/lnH8CnZxc7Qi9KhdVFe1/DownloadButton.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{motion}from\"framer-motion\";import{addPropertyControls,ControlType}from\"framer\";import{useState,useEffect}from\"react\";/**\n * @framerDisableUnlink\n * @framerIntrinsicWidth 36\n * @framerSupportedLayoutWidth fixed\n * @framerIntrinsicHeight 36\n * @framerSupportedLayoutHeight fixed\n */const SrcType={Upload:\"Upload\",URL:\"URL\"};FileDownloadButton.variables={cmsFile:{type:\"file\",title:\"CMS File Upload\"}};export default function FileDownloadButton(props){const[blobUrl,setBlobUrl]=useState(null);const{srcType,srcFile,srcURL,fileName}=props;const isPublishedSiteOrSSG=()=>{if(typeof document===\"undefined\")return true;const metaTag=document.querySelector('meta[name=\"framer-search-index\"]');return!!metaTag;};const initializeBlob=async()=>{const fileUrl=srcType===SrcType.URL?srcURL:srcFile;if(fileUrl){try{const response=await fetch(fileUrl);const blob=await response.blob();const blobUrl=URL.createObjectURL(blob);setBlobUrl(blobUrl);}catch(error){console.error(\"Error creating blob URL:\",error);}}};useEffect(()=>{initializeBlob();return()=>{if(blobUrl){URL.revokeObjectURL(blobUrl);}};},[srcType,srcFile,srcURL]);const getCursor=()=>{if(srcType===SrcType.URL&&srcURL)return\"pointer\";if(srcType===SrcType.Upload&&srcFile)return\"pointer\";return\"auto\";};const isInPublishedSiteOrSSG=isPublishedSiteOrSSG();const downloadURL=isInPublishedSiteOrSSG&&srcType===SrcType.URL?srcURL:srcType===SrcType.Upload?srcFile:null;const buttonTitle=isInPublishedSiteOrSSG?\"Download File\":\"Publish to Download\";return /*#__PURE__*/_jsx(motion.a,{target:\"_blank\",href:blobUrl||downloadURL,download:fileName||\"download\",title:buttonTitle,style:{backgroundColor:\"transparent\",display:\"block\",width:\"100%\",height:\"100%\",cursor:getCursor(),userSelect:\"none\"},children:props.children});}FileDownloadButton.displayName=\"File Download Button\";addPropertyControls(FileDownloadButton,{srcType:{type:ControlType.Enum,displaySegmentedControl:true,title:\"Source\",options:[SrcType.Upload,SrcType.URL]},srcURL:{type:ControlType.String,title:\" \",placeholder:\"../example.pdf\",hidden:props=>props.srcType===SrcType.Upload},srcFile:{type:ControlType.File,title:\" \",allowedFileTypes:[],hidden:props=>props.srcType===SrcType.URL},fileName:{type:ControlType.String,placeholder:\"File Name\",defaultValue:\"downloaded-file\",title:\"File Name\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"FileDownloadButton\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./DownloadButton.map"],"mappings":"mOAM0H,SAAwB,EAAmB,EAAM,CAAC,GAAK,CAAC,EAAQ,GAAYA,EAAS,IAAI,EAAO,CAAC,UAAQ,UAAQ,SAAO,YAAU,EAAY,MAA6B,OAAO,SAAW,KAAuG,CAAC,CAAlE,SAAS,cAAc,kCAAkD,EAAU,EAAe,SAAS,CAAC,IAAM,EAAQ,IAAU,EAAQ,IAAI,EAAO,EAAQ,GAAG,EAAS,GAAG,CAAqC,IAAM,EAAK,MAAM,MAAhC,MAAM,CAAO,EAAA,CAA4B,KAAK,EAAQ,EAAQ,IAAI,gBAAgB,CAAI,EAAE,EAAW,CAAO,CAAE,OAAO,EAAM,CAAC,QAAQ,MAAM,2BAA2B,CAAK,CAAE,CAAE,EAAE,OAAe,EAAe,MAAY,CAAI,GAAS,IAAI,gBAAgB,CAAO,CAAG,GAAI,CAAC,EAAQ,EAAQ,CAAM,CAAC,EAAE,IAAM,MAAkB,IAAU,EAAQ,KAAK,GAA0B,IAAU,EAAQ,QAAQ,EAAc,UAAgB,OAAe,EAAuB,EAAqB,EAAQ,EAAY,GAAwB,IAAU,EAAQ,IAAI,EAAO,IAAU,EAAQ,OAAO,EAAQ,KAAW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