{"version":3,"file":"SP_SLForm.CXD497Fr.mjs","names":["useState","Suspense","_Fragment","__esmMin","_e","init_jsx_runtime","L","c","p","init_npm_react_18_3_1","e","ce","addPropertyControls","init_framer_BisrWwwE","ControlType","SPSLForm","statusUrl","taskId","isClient","setIsClient","formData","setFormData","formStatus","setFormStatus","responseData","setResponseData","handleInputChange","event","prev","name","type","checked","value","pollTaskStatus","attempt","resolve","res","data","handleSubmit","response","handleCloseCard","contentTextStyle","formWrapperStyle","formContainerStyle","SLInputText","SLInputCheckBox","ButtonCopy2","props","l","blurredBackgroundStyle","SLCard","init_SP_SLForm"],"sources":["https:/framerusercontent.com/modules/qcCf3Dd8fc4EDjbpofZk/deegHN2POt0hhLnSI3dD/SP_SLForm.js"],"sourcesContent":["/**\n * SPSLForm.tsx\n *\n * This component handles a serial number form submission and displays the result in a card.\n * It uses a polling mechanism to check the status of a long-running task on the server.\n *\n * Key Points:\n * - On submit, it sends formData to the API via POST.\n * - If the API indicates the task is still \"PROCESSING\", we poll the status in intervals.\n * - We handle three main states: \"loading\", \"submitted\", and \"error\".\n * - The CardDev component displays different UI states based on the status prop.\n */import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from\"react/jsx-runtime\";import React,{Suspense,useState,useEffect}from\"react\";import{addPropertyControls,ControlType}from\"framer\";// Dynamically import components only on the client side\nconst SLCard=/*#__PURE__*/React.lazy(()=>import(\"https://framer.com/m/SLCard-hOZQ.js@6Vmezv1SUQWycZ9d0Ell\"));const ButtonCopy2=/*#__PURE__*/React.lazy(()=>import(\"https://framer.com/m/Button-idp4gz.js@wUVQ8p1v8ZQz6SmCCVKV\"));const SLInputCheckBox=/*#__PURE__*/React.lazy(()=>import(\"https://framer.com/m/SP-SLInputCheckBox-ei7U.js\"));const SLInputText=/*#__PURE__*/React.lazy(()=>import(\"https://framer.com/m/SLInputText-loCW.js@oIwWul9GqpMO9i4VL7lG\"));/**\n * Main component: FormDev\n * - Manages form data and submission.\n * - Polls for task status if needed.\n * - Displays the CardDev component for loading, submitted, and error states.\n */export default function SPSLForm(props){// API Endpoints\nconst formUrl=\"https://free-tools.macpaw.com/api/serial-lookup/processing/\";const statusUrl=taskId=>`https://free-tools.macpaw.com/api/serial-lookup/processing/status/${taskId}`;const[isClient,setIsClient]=useState(false);// Polling Config\nconst MAX_ATTEMPTS=40;const POLL_INTERVAL=2e3// in ms\n;// State\nconst[formData,setFormData]=useState({email:\"\",serialNumber:\"\",agreePrivacyPolicy:false,subscribeNewsletter:false});const[formStatus,setFormStatus]=useState(\"unsubmitted\");const[responseData,setResponseData]=useState(null);/**\n     * handleInputChange\n     * Updates formData on every keystroke or checkbox toggle.\n     */const handleInputChange=event=>{const{name,value,type,checked}=event.target;setFormData(prev=>({...prev,[name]:type===\"checkbox\"?checked:value}));};/**\n     * pollTaskStatus\n     * Polls the server for task status until completion or error.\n     */const pollTaskStatus=async taskId=>{for(let attempt=1;attempt<=MAX_ATTEMPTS;attempt++){await new Promise(resolve=>setTimeout(resolve,POLL_INTERVAL));try{const res=await fetch(statusUrl(taskId),{mode:\"cors\",headers:{Accept:\"application/json\"}});if(!res.ok)throw new Error(\"Status check failed\");const data=await res.json();if(data.status===\"COMPLETED\"){setResponseData(data);setFormStatus(\"submitted\");return;}if(data.status===\"ERROR\"){setResponseData(null);setFormStatus(\"error\");return;}// If still \"PROCESSING\", continue polling\n}catch(err){setFormStatus(\"error\");return;}}// Exceeded maximum attempts\nsetFormStatus(\"error\");};/**\n     * handleSubmit\n     * Submits the form data to the server for processing.\n     * If processing is long-running, we start polling for status.\n     */const handleSubmit=async event=>{event.preventDefault();setFormStatus(\"loading\");try{const response=await fetch(formUrl,{mode:\"cors\",method:\"POST\",headers:{\"Content-Type\":\"application/json\",Accept:\"application/json\"},body:JSON.stringify({email:formData.email,serial_number:formData.serialNumber,subscribe_newsletter:formData.subscribeNewsletter})});if(!response.ok)throw new Error(\"Network response was not ok\");const data=await response.json();// If the task completed immediately\nif(data.status===\"COMPLETED\"){setResponseData(data);setFormStatus(\"submitted\");return;}// If there's an error\nif(data.status===\"ERROR\"){setFormStatus(\"error\");return;}// If the task is still processing, poll the status endpoint\nif(data.status===\"PROCESSING\"&&data.task_id){await pollTaskStatus(data.task_id);}else{// Unexpected status\nsetFormStatus(\"error\");}}catch(error){setFormStatus(\"error\");}};/**\n     * handleCloseCard\n     * Resets the UI state, hiding the card and clearing response data.\n     */const handleCloseCard=()=>{setFormStatus(\"unsubmitted\");setResponseData(null);};useEffect(()=>{setIsClient(true);},[]);if(!isClient){return null;}// Render\nreturn /*#__PURE__*/_jsx(Suspense,{fallback:/*#__PURE__*/_jsx(\"div\",{style:contentTextStyle,children:\"Loading...\"}),children:/*#__PURE__*/_jsxs(\"div\",{style:formWrapperStyle,children:[/*#__PURE__*/_jsxs(\"form\",{onSubmit:handleSubmit,style:formContainerStyle,children:[/*#__PURE__*/_jsx(SLInputText,{name1:\"email\",type:\"email\",value:formData.email,placeholder:\"Email\",onChange:handleInputChange,style:{width:\"100%\"}}),/*#__PURE__*/_jsx(SLInputText,{name1:\"serialNumber\",placeholder:\"Serial Number\",value:formData.serialNumber,onChange:handleInputChange,style:{width:\"100%\"}}),/*#__PURE__*/_jsx(SLInputCheckBox,{style:{width:\"100%\"},name1:\"agreePrivacyPolicy\",checked:formData.agreePrivacyPolicy,onChange:handleInputChange}),/*#__PURE__*/_jsx(SLInputCheckBox,{style:{width:\"100%\"},name1:\"subscribeNewsletter\",checked:formData.subscribeNewsletter,onChange:handleInputChange,content:\"Inscr\\xedbeme para recibir actualizaciones y boletines sobre herramientas y servicios similares.\",required:false}),/*#__PURE__*/_jsx(ButtonCopy2,{title:\"Buscar ahora\",style:{width:props.buttonWidth}})]}),formStatus===\"loading\"&&/*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx(\"div\",{style:blurredBackgroundStyle}),/*#__PURE__*/_jsx(SLCard,{status:\"loading\",onClose:handleCloseCard})]}),formStatus===\"submitted\"&&responseData&&/*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx(\"div\",{style:blurredBackgroundStyle}),/*#__PURE__*/_jsx(SLCard,{rawContent:responseData.result,onClose:handleCloseCard,status:\"submitted\"})]}),formStatus===\"error\"&&/*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx(\"div\",{style:blurredBackgroundStyle}),/*#__PURE__*/_jsx(SLCard,{status:\"error\",onClose:handleCloseCard})]})]})});}// =====================\n//      STYLES\n// =====================\nconst formWrapperStyle={maxWidth:\"100%\",margin:\"0 auto\",padding:0};const formContainerStyle={display:\"flex\",flexDirection:\"column\",alignItems:\"flex-start\",gap:20,width:\"100%\"};const blurredBackgroundStyle={position:\"fixed\",top:0,left:0,width:\"100vw\",height:\"100vh\",backgroundColor:\"rgba(0, 0, 0, 0.5)\",backdropFilter:\"blur(5px)\",zIndex:9};const contentTextStyle={whiteSpace:\"pre-wrap\",wordWrap:\"break-word\",wordBreak:\"break-word\",fontFamily:'\"Avenir Next W1G Regular\", \"Avenir Next W1G Regular Placeholder\", sans-serif',color:\"#26262b\",fontSize:20,lineHeight:\"28px\",marginBottom:10};addPropertyControls(SPSLForm,{buttonWidth:{type:ControlType.String}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"SPSLForm\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./SP_SLForm.map"],"mappings":"A,6MAiBG,SAAwBe,EAAS,EAAM,CAC1C,IAAkFC,EAAU,GAAQ,qEAAqEC,IAAc,CAACC,EAASC,GAAanB,EAAS,EAAK,EAGvN,CAACoB,EAASC,GAAarB,EAAS,CAAC,MAAM,GAAG,aAAa,GAAG,mBAAmB,GAAM,oBAAoB,EAAK,CAAC,EAAO,CAACsB,EAAWC,GAAevB,EAAS,aAAa,EAAO,CAACwB,EAAaC,GAAiBzB,EAAS,IAAI,EAGhN0B,EAAkB,GAAO,CA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