{"version":3,"file":"Download.B59AP248.mjs","names":["React.useCallback"],"sources":["https:/framerusercontent.com/modules/xn7Yrb0oy2whXd7y694V/VM7nWXkh3y8f7g3MA7iU/Download.js"],"sourcesContent":["// DownloadButton.tsx  — same download logic, new layout controls\nimport{jsx as _jsx}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType}from\"framer\";/* ──────── Helpers ──────── */const nameFromURL=url=>decodeURIComponent(url.split(\"/\").pop()||\"download\");const justifyMap={Left:\"flex-start\",Center:\"center\",Right:\"flex-end\"};function triggerDirect(url,name){const a=document.createElement(\"a\");a.href=url;a.download=name;a.rel=\"noopener noreferrer\";document.body.appendChild(a);a.click();document.body.removeChild(a);}/**\n *\n * @framerIntrinsicWidth 1400\n * @framerIntrinsicHeight 1000\n *\n * @framerDisableUnlink\n *\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight fixed\n *//* ──────── Props ──────── *//* ──────── Component ──────── */export function DownloadButton(props){const{source,linkUrl,uploadUrl,fileName,align,fillWidth,button}=props;const src=source===\"Upload\"?uploadUrl:linkUrl;const saveAs=fileName||nameFromURL(src||\"\");const handleClick=React.useCallback(async()=>{if(!src){console.warn(\"DownloadButton: no link or upload provided.\");return;}const sameOrigin=src.startsWith(window.location.origin);if(sameOrigin){triggerDirect(src,saveAs);return;}try{const res=await fetch(src,{mode:\"cors\"});if(!res.ok)throw new Error(`HTTP ${res.status}`);const blob=await res.blob();const blobURL=URL.createObjectURL(blob);triggerDirect(blobURL,saveAs);URL.revokeObjectURL(blobURL);}catch(e){console.warn(\"DownloadButton: CORS blocked. Opening link in new tab.\",e);window.open(src,\"_blank\",\"noopener,noreferrer\");}},[src,saveAs]);/* Build child element */const visual=button??/*#__PURE__*/_jsx(Fallback,{label:saveAs||\"Download\"});const child=fillWidth?/*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\"},children:visual}):visual;return /*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",height:\"100%\",display:\"flex\",justifyContent:justifyMap[align],alignItems:\"center\"},onClick:handleClick,children:child});}/* Default fallback look */function Fallback({label}){return /*#__PURE__*/_jsx(\"div\",{style:{padding:\"8px 16px\",background:\"#0055FF\",color:\"#fff\",borderRadius:8,fontSize:16,cursor:\"pointer\",userSelect:\"none\",textAlign:\"center\"},children:label});}/* ──────── Defaults ──────── */DownloadButton.defaultProps={source:\"Link\",linkUrl:\"\",uploadUrl:\"\",fileName:\"\",align:\"Center\",fillWidth:false,width:160,height:48};/* ──────── Property Controls ──────── */addPropertyControls(DownloadButton,{/* Switch between Link & Upload */source:{type:ControlType.Enum,title:\"Source\",optionTitles:[\"Link / URL\",\"Upload File\"],options:[\"Link\",\"Upload\"],description:\"Choose where the file comes from.\"},/* Shown when Source = Link */linkUrl:{type:ControlType.String,title:\"File URL\",placeholder:\"https://example.com/file.pdf\",hidden:p=>p.source===\"Upload\",description:\"Paste ANY public link here.\"},/* Shown when Source = Upload */uploadUrl:{type:ControlType.File,title:\"Upload File\",allowedFileTypes:[\"pdf\",\"doc\",\"docx\",\"xls\",\"xlsx\",\"csv\",\"txt\",\"zip\",\"rar\",\"jpg\",\"jpeg\",\"png\",\"gif\",\"svg\",\"mp4\",\"mov\",\"webm\"],hidden:p=>p.source===\"Link\",description:\"Drag a file here; Framer hosts it automatically.\"},fileName:{type:ControlType.String,title:\"Save As\",placeholder:\"custom-name.ext\",description:\"Override the filename (optional).\"},/* New layout controls */align:{type:ControlType.Enum,title:\"Align\",optionTitles:[\"Left\",\"Center\",\"Right\"],options:[\"Left\",\"Center\",\"Right\"],description:\"Horizontal alignment inside the component’s frame.\"},fillWidth:{type:ControlType.Boolean,title:\"Stretch\",enabledTitle:\"Fill width\",disabledTitle:\"Auto\",description:\"Make the button stretch to the component’s full width.\"},button:{type:ControlType.ComponentInstance,title:\"Button\",description:\"Drop ANY Framer component here (variants & animations intact) \\n\\nMade with 🖤 for [Framer](https://framer.link/harshupadhyay) by [Harsh](https://harshworks.framer.website)\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"DownloadButton\":{\"type\":\"reactComponent\",\"name\":\"DownloadButton\",\"slots\":[],\"annotations\":{\"framerIntrinsicWidth\":\"1400\",\"framerIntrinsicHeight\":\"1000\",\"framerDisableUnlink\":\"*\",\"framerSupportedLayoutWidth\":\"fixed\",\"framerSupportedLayoutHeight\":\"fixed\",\"framerContractVersion\":\"1\"}},\"DownloadButtonProps\":{\"type\":\"tsType\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Download.map"],"mappings":"yLAC4S,SAAS,EAAc,EAAI,EAAK,CAAC,IAAM,EAAE,SAAS,cAAc,GAAG,EAAE,EAAE,KAAK,EAAI,EAAE,SAAS,EAAK,EAAE,IAAI,sBAAsB,SAAS,KAAK,YAAY,CAAC,EAAE,EAAE,MAAM,EAAE,SAAS,KAAK,YAAY,CAAC,CAAE,CAS3a,SAAgB,EAAe,EAAM,CAAC,GAAK,CAAC,SAAO,UAAQ,YAAU,WAAS,QAAM,YAAU,UAAQ,EAAY,EAAI,IAAS,SAAS,EAAU,EAAc,EAAO,GAAU,EAAY,GAAK,EAAE,EAAQ,EAAYA,EAAkB,SAAS,CAAC,GAAG,CAAC,EAAI,CAAC,QAAQ,KAAK,6CAA6C,EAAE,MAAO,CAAyD,GAAvC,EAAI,WAAW,EAAO,SAAS,MAAoB,EAAE,CAAC,EAAc,EAAI,CAAM,EAAE,MAAO,CAAC,GAAG,CAAC,IAAM,EAAI,MAAM,MAAM,EAAI,CAAC,KAAK,MAAM,CAAC,EAAE,GAAG,CAAC,EAAI,GAAG,MAAU,MAAM,QAAQ,EAAI,QAAQ,EAAE,IAAM,EAAK,MAAM,EAAI,KAAK,EAAQ,EAAQ,IAAI,gBAAgB,CAAI,EAAE,EAAc,EAAQ,CAAM,EAAE,IAAI,gBAAgB,CAAO,CAAE,OAAO,EAAE,CAAC,QAAQ,KAAK,yDAAyD,CAAC,EAAE,EAA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