{"version":3,"file":"DownloadButton.BM4e_Wo5.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/m79LI1JH8vgKNH9VCTtX/Se3oudKvLAuXI9VtM25p/DownloadButton.js"],"sourcesContent":["// File Component - Ermöglicht das Herunterladen von Dateien mit angepasstem Dateinamen\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useState,startTransition}from\"react\";/**\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function FilenameDownload(props){const{uploadedFile=\"https://framerusercontent.com/assets/8w3IUatLX9a5JVJ6XPCVuHi94.mp3\",saveAs=\"download\",align=\"center\",stretch=false,buttonSlot,style}=props;const[isDownloading,setIsDownloading]=useState(false);const handleDownload=async()=>{if(!uploadedFile||isDownloading)return;startTransition(()=>setIsDownloading(true));try{const response=await fetch(uploadedFile);const blob=await response.blob();const fileExtension=uploadedFile.split(\".\").pop()?.split(\"?\")[0]||\"file\";const filename=saveAs.includes(\".\")?saveAs:`${saveAs}.${fileExtension}`;const url=window.URL.createObjectURL(blob);const link=document.createElement(\"a\");link.href=url;link.download=filename;document.body.appendChild(link);link.click();document.body.removeChild(link);window.URL.revokeObjectURL(url);}catch(error){console.error(\"Download failed:\",error);}finally{startTransition(()=>setIsDownloading(false));}};const alignmentStyles={left:{justifyContent:\"flex-start\"},center:{justifyContent:\"center\"},right:{justifyContent:\"flex-end\"}};return /*#__PURE__*/_jsx(\"div\",{style:{...style,display:\"flex\",width:\"100%\",minHeight:5,...alignmentStyles[align]},children:/*#__PURE__*/_jsx(\"div\",{onClick:handleDownload,style:{cursor:isDownloading?\"wait\":\"pointer\",width:stretch?\"100%\":\"auto\",opacity:isDownloading?.6:1,transition:\"opacity 0.2s ease\"},children:buttonSlot||/*#__PURE__*/_jsx(\"div\",{style:{padding:\"12px 24px\",backgroundColor:\"#0099FF\",color:\"#FFFFFF\",borderRadius:8,fontSize:16,fontWeight:600,textAlign:\"center\",userSelect:\"none\"},children:isDownloading?\"Processing...\":\"Get File\"})})});}addPropertyControls(FilenameDownload,{uploadedFile:{type:ControlType.File,title:\"Upload File\",allowedFileTypes:[\"pdf\",\"jpg\",\"jpeg\",\"png\",\"gif\",\"webp\",\"svg\",\"mp4\",\"webm\",\"mov\",\"mp3\",\"wav\",\"ogg\",\"doc\",\"docx\",\"txt\",\"zip\"]},saveAs:{type:ControlType.String,title:\"Save As\",defaultValue:\"download\",placeholder:\"filename.pdf\",description:\"Name your file\"},align:{type:ControlType.Enum,title:\"Align\",options:[\"left\",\"center\",\"right\"],optionTitles:[\"Left\",\"Center\",\"Right\"],defaultValue:\"center\",displaySegmentedControl:true},stretch:{type:ControlType.Boolean,title:\"Stretch\",defaultValue:false,enabledTitle:\"Auto\",disabledTitle:\"Fill width\"},buttonSlot:{type:ControlType.ComponentInstance,title:\"Button\",description:\"Connect an existing button component here\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"FilenameDownload\",\"slots\":[\"buttonSlot\"],\"annotations\":{\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./DownloadButton.map"],"mappings":"2LAIG,SAAwB,EAAiB,EAAM,CAAC,GAAK,CAAC,eAAa,qEAAqE,SAAO,WAAW,QAAM,SAAS,UAAQ,GAAM,aAAW,SAAO,EAAW,CAAC,EAAc,GAAkBA,EAAS,GAAM,CAAO,EAAe,SAAS,CAAI,MAAC,GAAc,GAAqB,OAAoB,EAAiB,GAAK,CAAC,CAAC,GAAG,CAA0C,IAAM,EAAK,MAArC,MAAM,MAAM,EAAa,EAA2B,MAAM,CAAO,EAAc,EAAa,MAAM,IAAI,CAAC,KAAK,EAAE,MAAM,IAAI,CAAC,IAAI,OAAa,EAAS,EAAO,SAAS,IAAI,CAAC,EAA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