{"version":3,"file":"HeicToPDFConvertor.nMZlTYo7.mjs","names":["useState","useRef","Spinner","__esmMin","window","init_ssg_sandbox_shims","_e","de","init_jsx_runtime","c","p","init_npm_react_18_3_1","addPropertyControls","init_framer_BWFVvmND","ControlType","init_Button_idp4gz","Button","BaseConvertor","init_BaseConvertor_OKuE","HeicToPDFConvertor","status","setStatus","outputUrl","setOutputUrl","previewImage","setPreviewImage","fileName","setFileName","fileInputRef","convertHEICtoPDF","heic2any","jsPDF","blob","file","imageUrl","img","pdf","pdfBlob","pdfUrl","handleFileChange","handleDrop","handleDragOver","reset","convertedFileName","name","format","selectText","dropHint","convertingText","convertingSubtitle","resultColor","resultTitle","messagesByFormat","timeStamp","convertedAtText","list","downloadText","init_HeicToPDFConvertor"],"sources":["https:/framerusercontent.com/modules/Y0Lyg4Khqm2cnr55qHLK/Kvw40wZNrfHp6PwGu9ux/HeicToPDFConvertor.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useRef,useState}from\"react\";import{addPropertyControls,ControlType}from\"framer\";import Spinner from\"https://framer.com/m/BaseConvertor-OKuE.js\";import Button from\"https://framer.com/m/Button-idp4gz.js\";export default function HeicToPDFConvertor({resultTitle=\"Your PDF document is ready 🎉\",resultColor=\"#EA8D49\",selectText=\"Select your HEIC\",dropHint=\"or drop images here\",convertingText=\"Converting to PDF\",convertingSubtitle=\"Getting your image ready.\",downloadText=\"Download\",convertedAtText=\"Converted at\"}){const[status,setStatus]=useState(\"idle\");const[outputUrl,setOutputUrl]=useState(null);const[previewImage,setPreviewImage]=useState(null);const[fileName,setFileName]=useState(null);const fileInputRef=useRef(null);const outputFormat=\"pdf\";const convertHEICtoPDF=async file=>{if(typeof window===\"undefined\")return;setStatus(\"loading\");try{const heic2any=(await import(\"heic2any\")).default;const jsPDF=(await import(\"jspdf\")).jsPDF;const blob=await heic2any({blob:file,toType:\"image/png\"});const imageUrl=URL.createObjectURL(blob);const img=new Image;img.src=imageUrl;img.onload=()=>{const pdf=new jsPDF({orientation:img.width>img.height?\"landscape\":\"portrait\",unit:\"px\",format:[img.width,img.height]});pdf.addImage(img,\"PNG\",0,0,img.width,img.height);const pdfBlob=pdf.output(\"blob\");const pdfUrl=URL.createObjectURL(pdfBlob);setPreviewImage(imageUrl);setOutputUrl(pdfUrl);setStatus(\"done\");};img.onerror=()=>{throw new Error(\"Image failed to load for PDF generation.\");};}catch(e){console.error(\"PDF conversion error:\",e);setStatus(\"idle\");}};const handleFileChange=e=>{const file=e.target.files?.[0];if(file){setFileName(file.name);convertHEICtoPDF(file);e.target.value=\"\";}};const handleDrop=e=>{e.preventDefault();const file=e.dataTransfer.files?.[0];if(file){setFileName(file.name);convertHEICtoPDF(file);e.dataTransfer.clearData();}};const handleDragOver=e=>e.preventDefault();const reset=()=>{setStatus(\"idle\");setOutputUrl(null);setFileName(null);setPreviewImage(null);if(fileInputRef.current)fileInputRef.current.value=\"\";};const convertedFileName=(name,format)=>{if(!name)return`converted.${format}`;const baseName=name.replace(/\\.[^/.]+$/,\"\");return`${baseName}.${format}`;};const getConvertedMetaInfo=format=>{const messagesByFormat={default:[timeStamp()]};function timeStamp(){return`${convertedAtText} ${new Date().toLocaleTimeString([],{hour:\"2-digit\",minute:\"2-digit\"})}`;}const list=messagesByFormat[format]??messagesByFormat.default;return list[Math.floor(Math.random()*list.length)];};return /*#__PURE__*/_jsxs(\"div\",{style:{position:\"relative\"},children:[/*#__PURE__*/_jsxs(\"div\",{onDrop:handleDrop,onDragOver:handleDragOver,onClick:()=>fileInputRef.current?.click(),style:{boxSizing:\"border-box\",width:278,maxWidth:\"90vw\",minHeight:150,opacity:status===\"idle\"?1:.4,pointerEvents:status===\"idle\"?\"auto\":\"none\",padding:\"24px 34px\",display:\"flex\",flexDirection:\"column\",justifyContent:\"center\",alignItems:\"center\",borderRadius:15,border:\"1px dashed #9d9ca2\",cursor:\"pointer\",gap:16},children:[/*#__PURE__*/_jsx(Button,{title:selectText,onClick:()=>fileInputRef.current?.click(),style:{width:\"100%\"}}),/*#__PURE__*/_jsx(\"p\",{style:{color:\"#9d9ca2\",fontSize:14,fontWeight:800,fontFamily:'\"Avenir Next W1G Demi\", \"Avenir Next W1G Demi Placeholder\", sans-serif'},children:dropHint}),/*#__PURE__*/_jsx(\"input\",{type:\"file\",accept:\".heic\",onChange:handleFileChange,ref:fileInputRef,style:{display:\"none\"}})]}),status!==\"idle\"&&/*#__PURE__*/_jsxs(\"div\",{style:{position:\"fixed\",top:0,left:0,width:\"100vw\",height:\"100vh\",backgroundColor:\"rgba(0, 0, 0, 0.6)\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",zIndex:1e3},children:[status===\"loading\"&&/*#__PURE__*/_jsxs(\"div\",{style:{padding:40,background:\"white\",borderRadius:20,textAlign:\"center\",width:400,boxShadow:\"0px 8px 30px rgba(0, 0, 0, 0.1)\"},children:[/*#__PURE__*/_jsx(\"div\",{style:{display:\"flex\",justifyContent:\"center\",marginBottom:24},children:/*#__PURE__*/_jsx(Spinner,{})}),/*#__PURE__*/_jsx(\"div\",{style:{fontSize:24,fontWeight:600,color:\"#26262B\",marginBottom:8,fontFamily:'\"Avenir Next W1G Bold\", \"Avenir Next W1G Bold Placeholder\", sans-serif'},children:convertingText}),/*#__PURE__*/_jsx(\"div\",{style:{fontSize:16,color:\"#6C6C73\",fontFamily:'\"Avenir Next W1G Regular\", \"Avenir Next W1G Regular Placeholder\", sans-serif'},children:convertingSubtitle})]}),status===\"done\"&&outputUrl&&/*#__PURE__*/_jsxs(\"div\",{style:{position:\"relative\",padding:40,background:\"white\",borderRadius:20,textAlign:\"center\",width:460,boxShadow:\"0px 8px 30px rgba(0, 0, 0, 0.1)\"},children:[/*#__PURE__*/_jsx(\"button\",{onClick:reset,style:{position:\"absolute\",top:24,right:24,background:\"transparent\",border:\"none\",fontSize:24,cursor:\"pointer\",color:\"#6C6C73\"},children:\"✕\"}),/*#__PURE__*/_jsx(\"div\",{style:{width:56,height:56,borderRadius:\"50%\",backgroundColor:resultColor,display:\"flex\",alignItems:\"center\",justifyContent:\"center\",margin:\"0 auto 24px auto\"},children:/*#__PURE__*/_jsx(\"span\",{style:{fontSize:28,color:\"white\"},children:\"✔\"})}),/*#__PURE__*/_jsx(\"div\",{style:{fontSize:36,fontFamily:'\"Avenir Next W1G Bold\", \"Avenir Next W1G Bold Placeholder\", sans-serif',color:\"#26262B\",fontWeight:700,marginBottom:24},children:resultTitle}),/*#__PURE__*/_jsxs(\"div\",{style:{border:\"1px solid #E4E4E7\",borderRadius:12,padding:\"12px 16px\",display:\"flex\",alignItems:\"center\",gap:12,backgroundColor:\"#FAFAFA\",marginBottom:24},children:[/*#__PURE__*/_jsx(\"img\",{src:previewImage??\"\",alt:\"Preview\",style:{width:40,height:40,borderRadius:8,objectFit:\"cover\"}}),/*#__PURE__*/_jsxs(\"div\",{style:{fontSize:16,fontFamily:'\"Avenir Next W1G Regular\", \"Avenir Next W1G Regular Placeholder\", sans-serif',color:\"#26262B\"},children:[convertedFileName(fileName,outputFormat),\" \",\"\\xa0\",/*#__PURE__*/_jsx(\"span\",{style:{color:\"#6C6C73\"},children:getConvertedMetaInfo(outputFormat)})]})]}),/*#__PURE__*/_jsx(Button,{title:downloadText,href:outputUrl,download:convertedFileName(fileName,outputFormat)})]})]})]});}addPropertyControls(HeicToPDFConvertor,{resultTitle:{type:ControlType.String,title:\"Result Title\",defaultValue:\"Your PDF document is ready 🎉\"},resultColor:{type:ControlType.Color,title:\"Result Color\",defaultValue:\"#EA8D49\"},selectText:{type:ControlType.String,title:\"Select Text\",defaultValue:\"Select your HEIC\"},dropHint:{type:ControlType.String,title:\"Drop Hint\",defaultValue:\"or drop images here\"},convertingText:{type:ControlType.String,title:\"Converting Text\",defaultValue:\"Converting to PDF\"},convertingSubtitle:{type:ControlType.String,title:\"Converting Subtitle\",defaultValue:\"Getting your image ready.\"},downloadText:{type:ControlType.String,title:\"Download Button\",defaultValue:\"Download\"},convertedAtText:{type:ControlType.String,title:'\"Converted at\" Label',defaultValue:\"Converted at\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"HeicToPDFConvertor\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./HeicToPDFConvertor.map"],"mappings":"A,qWAA0Q,SAAwBmB,EAAmB,CAAC,cAAY,gCAAgC,cAAY,UAAU,aAAW,mBAAmB,WAAS,sBAAsB,iBAAe,oBAAoB,qBAAmB,4BAA4B,eAAa,WAAW,kBAAgB,gBAAgB,CAAC,GAAK,CAACC,EAAOC,GAAWrB,EAAS,MAAM,EAAO,CAACsB,EAAUC,GAAcvB,EAAS,IAAI,EAAO,CAACwB,EAAaC,GAAiBzB,EAAS,IAAI,EAAO,CAAC0B,EAASC,GAAa3B,EAAS,IAAI,EAAQ4B,EAAa3B,EAAO,IAAI,EAAiC4B,EAAiB,KAAM,IAAM,CAAC,GAAUzB,IAAS,OAAmB,GAAU,SAAS,EAAE,GAAG,CAAC,IAAM0B,GAAU,MAAM,OAAO,2BAAA,CAAa,QAAcC,GAAO,MAAM,OAAO,+BAAA,CAAU,MAAYC,EAAK,MAAMF,EAAS,CAAC,KAAKG,EAAK,OAAO,WAAW,CAAC,EAAQC,EAAS,IAAI,gBAAgBF,CAAI,EAAQG,EAAI,IAAI,MAAM,EAAI,IAAID,EAAS,EAAI,WAAW,CAAC,IAAME,EAAI,IAAIL,EAAM,CAAC,YAAYI,EAAI,MAAMA,EAAI,OAAO,YAAY,WAAW,KAAK,KAAK,OAAO,CAACA,EAAI,MAAMA,EAAI,MAAM,CAAC,CAAC,EAAEC,EAAI,SAASD,EAAI,MAAM,EAAE,EAAEA,EAAI,MAAMA,EAAI,MAAM,EAAE,IAAME,EAAQD,EAAI,OAAO,MAAM,EAAQE,EAAO,IAAI,gBAAgBD,CAAO,EAAEZ,EAAgBS,CAAQ,EAAEX,EAAae,CAAM,EAAEjB,EAA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