{"version":3,"file":"SP_SLForm.CAT0D-e1.mjs","names":["useState","Suspense","_Fragment"],"sources":["https:/framerusercontent.com/modules/qcCf3Dd8fc4EDjbpofZk/PUIZjoPiwKNMcvVjFJaA/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-Copy-2-TmW7.js@3bP2yKq5XfD4LZ2nZYW6\"));const SLInputCheckBox=/*#__PURE__*/React.lazy(()=>import(\"https://framer.com/m/SP-SLInputCheckBox-ei7U.js@5LW3rx4iXxBHTFbWvS2W\"));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,content:()=>/*#__PURE__*/_jsx(_Fragment,{children:\" \"})}),/*#__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":"6MAiBG,SAAwB,EAAS,EAAM,CAC1C,IAAkF,EAAU,GAAQ,qEAAqE,IAAc,CAAC,EAAS,GAAaA,EAAS,GAAM,CAGxN,CAAC,EAAS,GAAaA,EAAS,CAAC,MAAM,GAAG,aAAa,GAAG,mBAAmB,GAAM,oBAAoB,GAAM,CAAC,CAAM,CAAC,EAAW,GAAeA,EAAS,cAAc,CAAM,CAAC,EAAa,GAAiBA,EAAS,KAAK,CAGjN,EAAkB,GAAO,CAAC,GAAK,CAAC,OAAK,QAAM,OAAK,WAAS,EAAM,OAAO,EAAY,IAAO,CAAC,GAAG,GAAM,GAAM,IAAO,WAAW,EAAQ,EAAM,EAAE,EAG3I,EAAe,KAAM,IAAQ,CAAC,IAAI,IAAI,EAAQ,EAAE,GAAS,GAAa,IAAU,CAAC,MAAM,IAAI,QAAQ,GAAS,WAAW,EAAQ,IAAc,CAAC,CAAC,G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