{"version":3,"file":"File_Downloader.FDefKcCq.mjs","names":["styled"],"sources":["https:/framerusercontent.com/modules/t1r4bGkVI90pTY9lA2ld/DtODXk26AbNUjJP1tgao/File_Downloader.js"],"sourcesContent":["\"use client\";import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{styled}from\"@stitches/react\";import{addPropertyControls,ControlType}from\"framer\";export default function File_Downloader(props){if(!props.data)return null;const pairedURL=props.data.split(\";\");const IndividualTab=styled(\"div\",{width:\"100%\",height:`${props.tileHeight}`,borderRadius:\"14px\",backgroundColor:`${props.tileBg}`,display:\"flex\",alignItems:\"center\",justifyContent:\"space-between\",gap:\"12px\",padding:\"18px 16px\",boxSizing:\"border-box\",overflow:\"hidden\",flexWrap:\"nowrap\"});const ComponentWrapper=styled(\"div\",{display:\"flex\",flexDirection:\"column\",gap:\"12px\",maxWidth:\"100%\"});const Wrapper=styled(\"div\",{display:\"flex\",alignItems:\"center\",gap:\"12px\",flex:1,minWidth:0});const FilenameWrapper=styled(\"div\",{display:\"flex\",flexDirection:\"column\",overflow:\"hidden\",whiteSpace:\"nowrap\",textOverflow:\"ellipsis\",minWidth:0});const handleDownload=async(url,filename)=>{if(!url){console.error(\"Download failed: No URL provided\");return;}try{const response=await fetch(url);if(!response.ok)throw new Error(\"Network response was not ok\");const blob=await response.blob();const link=document.createElement(\"a\");link.href=URL.createObjectURL(blob);link.setAttribute(\"download\",filename||\"download.pdf\");document.body.appendChild(link);link.click();document.body.removeChild(link);URL.revokeObjectURL(link.href);}catch(error){console.error(\"Download failed:\",error);}};const truncateFilename=(name,maxLength=25)=>{return name.length>maxLength?name.slice(0,maxLength-3)+\"...\":name;};return /*#__PURE__*/_jsx(ComponentWrapper,{style:{width:props.width?`${props.width}px`:\"100%\",height:props.height?`${props.height}px`:\"auto\",overflowY:props.height?\"auto\":\"visible\"},children:pairedURL.map((element,index)=>{const[name,,url]=element.split(\":\");const rawName=name.length>0?name:\"Unknown\";const limit=props.charLimit??25;return /*#__PURE__*/_jsxs(IndividualTab,{children:[/*#__PURE__*/_jsxs(Wrapper,{children:[/*#__PURE__*/_jsx(\"img\",{src:\"https://res.cloudinary.com/omc-electronics/image/upload/v1746410363/konec/pdf-icon_ycnrnl.png\",width:props.imageSize,height:props.imageSize,alt:\"PDF Icon\"}),/*#__PURE__*/_jsx(FilenameWrapper,{children:/*#__PURE__*/_jsx(\"p\",{style:{fontFamily:typeof props.font===\"object\"?props.font.fontFamily||\"monospace\":props.font||\"monospace\",fontSize:typeof props.font===\"object\"&&props.font.fontSize?props.font.fontSize:\"20px\",margin:0,overflow:\"hidden\",textOverflow:\"ellipsis\"},title:rawName,children:truncateFilename(rawName,limit)})})]}),/*#__PURE__*/_jsxs(Wrapper,{style:{flex:\"none\"},children:[/*#__PURE__*/_jsxs(\"svg\",{width:\"29\",height:\"29\",viewBox:\"0 0 29 29\",fill:\"none\",stroke:\"black\",strokeWidth:\"2\",strokeLinecap:\"round\",strokeLinejoin:\"round\",style:{transition:\"stroke 0.2s\"},onMouseEnter:e=>e.currentTarget.style.stroke=\"#FFD500\",onMouseLeave:e=>e.currentTarget.style.stroke=\"black\",onTouchEnd:e=>e.currentTarget.style.stroke=\"black\",onClick:()=>window.open(url,\"_blank\"),children:[/*#__PURE__*/_jsx(\"path\",{d:\"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0\"}),/*#__PURE__*/_jsx(\"circle\",{cx:\"12\",cy:\"12\",r:\"3\"})]}),/*#__PURE__*/_jsx(\"button\",{onClick:()=>handleDownload(url,rawName),style:{background:\"none\",border:\"none\",cursor:\"pointer\"},children:/*#__PURE__*/_jsxs(\"svg\",{width:\"29\",height:\"29\",viewBox:\"0 0 29 29\",fill:\"none\",stroke:\"black\",strokeWidth:\"2\",strokeLinecap:\"round\",strokeLinejoin:\"round\",style:{transition:\"stroke 0.2s\"},onMouseEnter:e=>e.currentTarget.style.stroke=\"#FFD500\",onMouseLeave:e=>e.currentTarget.style.stroke=\"black\",onTouchEnd:e=>e.currentTarget.style.stroke=\"black\",children:[/*#__PURE__*/_jsx(\"path\",{d:\"M12 17V3\"}),/*#__PURE__*/_jsx(\"path\",{d:\"m6 11 6 6 6-6\"}),/*#__PURE__*/_jsx(\"path\",{d:\"M19 21H5\"})]})})]})]},index);})});}addPropertyControls(File_Downloader,{font:{type:ControlType.Font,controls:\"extended\",displayFontSize:true,displayTextAlignment:false,defaultFontType:\"monospace\",defaultValue:{fontSize:14,lineHeight:\"1.5em\"}},data:{type:ControlType.String},charLimit:{type:ControlType.Number,title:\"Filename Limit\",min:5,max:100,defaultValue:25,displayStepper:true},tileBg:{type:ControlType.String,title:\"Tile Background\",defaultValue:\"#F2F2F2\"},tileHeight:{type:ControlType.String,title:\"Title Height\",default:\"100%\"},imageSize:{type:ControlType.Number,title:\"PDF Image Width\",defaultValue:29}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"File_Downloader\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./File_Downloader.map"],"mappings":"gOAA8J,SAAwB,EAAgB,EAAM,CAAC,GAAG,CAAC,EAAM,KAAK,OAAO,KAAK,IAAM,EAAU,EAAM,KAAK,MAAM,IAAI,CAAO,EAAcA,EAAO,MAAM,CAAC,MAAM,OAAO,OAAO,GAAG,EAAM,aAAa,aAAa,OAAO,gBAAgB,GAAG,EAAM,SAAS,QAAQ,OAAO,WAAW,SAAS,eAAe,gBAAgB,IAAI,OAAO,QAAQ,YAAY,UAAU,aAAa,SAAS,SAAS,SAAS,SAAS,CAAC,CAAO,EAAiBA,EAAO,MAAM,CAAC,QAAQ,OAAO,cAAc,SAAS,IAAI,OAAO,SAAS,OAAO,CAAC,CAAO,EAAQA,EAAO,MAAM,CAAC,QAAQ,OAAO,WAAW,SAAS,IAAI,OAAO,KAAK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