{"version":3,"file":"PDF_Button.-o7XzuDI.mjs","names":["useState","useCallback"],"sources":["https:/framerusercontent.com/modules/DEGWZ5F5zwi3gBZKpQeD/DtSXjpqzhyBUmQ3sWLVr/PDF_Button.js"],"sourcesContent":["// PdfButton — Open New (Google/Mozilla/Browser) or Download\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useCallback,useState}from\"react\";/**\n * @framerIntrinsicWidth 160\n * @framerIntrinsicHeight 48\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n * @framerDisableUnlink\n */export default function PdfButton({label=\"Open PDF\",pdfFile,action=\"openNew\",viewer=\"google\",fileName=\"document.pdf\",padding=\"12px 28px\",borderRadius=\"8px\",textColor=\"#FFFFFF\",backgroundColor=\"#111111\",style,font,hover={scale:1.05,opacity:1,transition:.25}}){const url=(pdfFile||\"\").trim();const downloadName=(fileName||\"\").trim();const resolvedDownloadName=downloadName?/\\.pdf$/i.test(downloadName)?downloadName:`${downloadName}.pdf`:\"\";// Build viewer URL for opening in a new tab\nconst viewerUrl=url?viewer===\"google\"?`https://docs.google.com/gview?embedded=1&url=${encodeURIComponent(url)}`:viewer===\"mozilla\"?`https://mozilla.github.io/pdf.js/web/viewer.html?file=${encodeURIComponent(url)}`:url// browser native (raw PDF)\n:\"\";const[isHover,setIsHover]=useState(false);const handleClick=useCallback(async()=>{if(!url)return;if(action===\"openNew\"){if(viewer===\"browser\"){try{const res=await fetch(url,{mode:\"cors\"});if(!res.ok)throw new Error(\"Fetch failed\");const blob=await res.blob();const blobUrl=URL.createObjectURL(blob);window.open(blobUrl,\"_blank\",\"noopener,noreferrer\");setTimeout(()=>URL.revokeObjectURL(blobUrl),1e4);return;}catch{// Fall back to direct open if CORS blocks or fetch fails\n}}window.open(viewerUrl,\"_blank\",\"noopener,noreferrer\");return;}// action === \"download\"\ntry{const res=await fetch(url,{mode:\"cors\"});if(!res.ok)throw new Error(\"Fetch failed\");const blob=await res.blob();const blobUrl=URL.createObjectURL(blob);const a=document.createElement(\"a\");a.href=blobUrl;a.download=resolvedDownloadName;document.body.appendChild(a);a.click();document.body.removeChild(a);setTimeout(()=>URL.revokeObjectURL(blobUrl),1e4);return;}catch{// Fall back to direct download if CORS blocks or fetch fails\n}const a=document.createElement(\"a\");a.href=url;a.download=resolvedDownloadName;document.body.appendChild(a);a.click();document.body.removeChild(a);},[action,resolvedDownloadName,url,viewerUrl]);return /*#__PURE__*/_jsx(\"button\",{type:\"button\",\"aria-label\":label,onClick:handleClick,onMouseEnter:()=>setIsHover(true),onMouseLeave:()=>setIsHover(false),style:{...style,width:\"100%\",height:\"100%\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",background:backgroundColor,color:textColor,border:\"none\",borderRadius,padding,cursor:\"pointer\",...font,transform:isHover?`scale(${hover?.scale??1.05})`:\"scale(1)\",opacity:isHover?hover?.opacity??1:1,transition:`transform ${hover?.transition??.25}s ease, opacity ${hover?.transition??.25}s ease`,willChange:\"transform, opacity\"},children:label});}addPropertyControls(PdfButton,{label:{type:ControlType.String,title:\"Label\",defaultValue:\"Open PDF\"},pdfFile:{type:ControlType.File,allowedFileTypes:[\"pdf\"],title:\"PDF\"},viewer:{type:ControlType.Enum,title:\"Viewer\",options:[\"google\",\"mozilla\",\"browser\"],optionTitles:[\"Google Docs\",\"Mozilla pdf.js\",\"Browser Native\"],defaultValue:\"google\",hidden:props=>props.action!==\"openNew\"},action:{type:ControlType.Enum,title:\"Action\",options:[\"openNew\",\"download\"],optionTitles:[\"New Tab\",\"Download\"],defaultValue:\"openNew\",displaySegmentedControl:true},fileName:{type:ControlType.String,title:\"File Name\",defaultValue:\"document.pdf\",hidden:props=>props.action!==\"download\"},padding:{type:ControlType.Padding,title:\"Padding\",defaultValue:\"12px 28px\"},borderRadius:{type:ControlType.BorderRadius,title:\"Radius\",defaultValue:\"8px\"},textColor:{type:ControlType.Color,title:\"Text\",defaultValue:\"#FFFFFF\"},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#111111\"},hover:{type:ControlType.Object,title:\"Hover\",controls:{scale:{type:ControlType.Number,title:\"Scale\",defaultValue:1.05,min:.8,max:1.5,step:.01},opacity:{type:ControlType.Number,title:\"Opacity\",defaultValue:1,min:.1,max:1,step:.05},transition:{type:ControlType.Number,title:\"Transition (s)\",defaultValue:.25,min:0,max:2,step:.05}}},// Group: Font\nfont:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"16px\",variant:\"Semibold\",letterSpacing:\"-0.01em\",lineHeight:\"1em\"},group:\"Font\",description:`Made with ❤️ by [camillehaidar.com](https://camillehaidar.com)`}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"PdfButton\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerDisableUnlink\":\"\",\"framerIntrinsicWidth\":\"160\",\"framerIntrinsicHeight\":\"48\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./PDF_Button.map"],"mappings":"gMAOG,SAAwB,EAAU,CAAC,QAAM,WAAW,UAAQ,SAAO,UAAU,SAAO,SAAS,WAAS,eAAe,UAAQ,YAAY,eAAa,MAAM,YAAU,UAAU,kBAAgB,UAAU,QAAM,OAAK,QAAM,CAAC,MAAM,KAAK,QAAQ,EAAE,WAAW,GAAG,GAAG,CAAC,IAAM,GAAK,GAAS,GAAA,CAAI,KAAK,EAAQ,GAAc,GAAU,GAAA,CAAI,KAAK,EAAQ,EAAqB,EAAa,UAAU,KAAK,CAAY,EAAE,EAAa,GAAG,EAAa,MAAM,GAChb,EAAU,EAAI,IAAS,SAAS,gDAAgD,mBAAmB,CAAG,IAAI,IAAS,UAAU,yDAAyD,mBAAmB,CAAG,IAAI,EACrN,GAAQ,CAA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