{"version":3,"file":"DistributorForm.XPDTLPFv.mjs","names":["useMemo","p","useState","useCallback","useRef"],"sources":["https:/framerusercontent.com/modules/4GBCQSTjrCrT997yrXlC/Gjj8Q7XjBtxnolcHoTCp/DistributorForm.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useState,useMemo,useCallback,useRef,useEffect}from\"react\";import{addPropertyControls,ControlType}from\"framer\";import{COUNTRIES}from\"https://framerusercontent.com/modules/26tW3wht6cCHMtLFsWPb/9nt0rpKQnFpVhA2w21bm/Countries.js\";import{APP_OPTIONS}from\"https://framerusercontent.com/modules/Dcc4EvuzA6WVcKJno9rT/COyTcNsp699FkxwEb2UQ/ApplicationsData.js\";import{PRODUCTS}from\"https://framerusercontent.com/modules/N8ep1avyJhbbB65fw2ui/QlSg3G6v13Tgz4lJwBdJ/ProductsData.js\";import{FormField,checkFieldVisibility,THEME_COLORS,useIsMobile,hasValue}from\"https://framerusercontent.com/modules/IxciSQ48dfZf9BmXh1XA/aLeCwnYOsc8YSVhCHY4J/StandardSmartForm.js\";export default function DistributorForm(props){const{gapHorizontal=12,gapVertical=20,submitButtonText=\"Become a Partner →\",successMessage=\"Thank you! Your information has been submitted. We'll connect with you soon.\",hideFormOnSubmit=true,webhookUrl=\"\",marginTop=0,marginBottom=0,source=\"distributor-enquiry\"}=props;const fields=useMemo(()=>[{id:\"fname\",label:\"First Name *\",type:\"text\",placeholder:\"Your first name\",width:50,required:true},{id:\"lname\",label:\"Last Name\",type:\"text\",placeholder:\"Your last name\",width:50},{id:\"company\",label:\"Company Name *\",type:\"text\",placeholder:\"Your company name\",width:50,required:true},{id:\"email\",label:\"Work Email *\",type:\"email\",placeholder:\"Enter your email\",width:50,required:true},{id:\"phone\",label:\"Phone number *\",type:\"tel\",placeholder:\"Your phone number\",width:50,required:true},{id:\"country\",label:\"Country *\",type:\"select\",placeholder:\"\",width:50,required:true,options:COUNTRIES.map(c=>({value:c.name,name:c.name,enabled:true}))},{id:\"products\",label:\"What products are you interested in? *\",type:\"multi-select\",placeholder:\"Select Products\",width:50,options:PRODUCTS.map(p=>({value:p.title,name:p.title,enabled:true}))},{id:\"app\",label:\"What application are you looking to automate? *\",type:\"select\",placeholder:\"\",width:50,options:APP_OPTIONS.map(opt=>({value:opt.value,name:opt.label,enabled:true}))},{id:\"message\",label:\"Your message\",type:\"textarea\",placeholder:\"Enter your message\",width:100,required:false},// {\n    //     id: \"opt_in\",\n    //     label: \"I agree to receive emails and marketing communications about products, services, and offers\",\n    //     type: \"checkbox\",\n    //     width: 100,\n    //     required: false // Usually marketing is optional\n    // },\n    {id:\"privacy_policy\",label:\"By continuing, you agree to our Privacy Policy and acknowledge the use of cookies\",type:\"checkbox\",width:100,required:true}],[]);const getInitialValues=useCallback(()=>{const initial={};fields.forEach(f=>{initial[f.id]=f.value||\"\";});return initial;},[fields]);const[values,setValues]=useState(getInitialValues);const[errors,setErrors]=useState({});const[isSubmitted,setIsSubmitted]=useState(false);const[isLoading,setIsLoading]=useState(false);const[formHeight,setFormHeight]=useState(null);const formRef=useRef(null);const handleChange=useCallback((id,val)=>{setValues(prev=>({...prev,[id]:val}));setErrors(prev=>{if(prev[id]){const newErrors={...prev};delete newErrors[id];return newErrors;}return prev;});},[]);const isMobile=useIsMobile();const visibleFields=useMemo(()=>fields.filter(f=>checkFieldVisibility(f,values)),[fields,values]);useEffect(()=>{if(isSubmitted||!formRef.current)return;const parentForm=formRef.current.closest(\"form\");if(!parentForm)return;const handleFormSubmit=e=>{if(parentForm.checkValidity()&&!e.defaultPrevented&&!isSubmitted){setTimeout(()=>setIsSubmitted(true),500);}};parentForm.addEventListener(\"submit\",handleFormSubmit);return()=>parentForm.removeEventListener(\"submit\",handleFormSubmit);},[isSubmitted]);const validate=()=>{const newErrors={};visibleFields.forEach(f=>{if(f.required){if(f.type===\"checkbox\"){if(!values[f.id]){newErrors[f.id]=\"This field is required\";}}else if(!hasValue(values[f.id])){newErrors[f.id]=\"This field is required\";}}if(f.type===\"email\"&&values[f.id]){const emailRegex=/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;if(!emailRegex.test(values[f.id])){newErrors[f.id]=\"Please enter a valid email address\";}}// Phone validation logic can be kept if needed, but removed to stick to basic validation for now or generic check\nif(f.type===\"tel\"&&values[f.id]){const phoneDigits=values[f.id].replace(/\\D/g,\"\");if(phoneDigits.length<7){newErrors[f.id]=\"Please enter a valid phone number\";}}});setErrors(newErrors);return Object.keys(newErrors).length===0;};const handleSubmit=async e=>{const parentForm=formRef.current?.closest(\"form\");if(!validate()){e.preventDefault();return;}if(formRef.current){setFormHeight(formRef.current.offsetHeight);}if(webhookUrl){e.preventDefault();if(parentForm&&!parentForm.reportValidity()){return;}setIsLoading(true);try{const payload={source};fields.forEach(f=>{payload[f.id]=values[f.id]??\"\";});await fetch(webhookUrl,{method:\"POST\",headers:{\"Content-Type\":\"application/json\"},body:JSON.stringify(payload)});}catch(error){console.error(\"Form webhook submission failed:\",error);}finally{setIsLoading(false);}if(parentForm){const submitBtn=document.createElement(\"input\");submitBtn.type=\"submit\";submitBtn.style.display=\"none\";parentForm.appendChild(submitBtn);submitBtn.click();parentForm.removeChild(submitBtn);}else{setIsSubmitted(true);}}else{if(!parentForm){e.preventDefault();setIsSubmitted(true);}}};if(isSubmitted&&hideFormOnSubmit){return /*#__PURE__*/_jsx(\"div\",{style:{padding:\"40px 24px\",margin:\"32px 0\",textAlign:\"center\",border:\"1px solid #111\",fontFamily:\"Inter, system-ui, sans-serif\",color:THEME_COLORS.text,fontSize:\"18px\",fontWeight:\"500\",minHeight:formHeight?`${formHeight}px`:\"auto\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",boxSizing:\"border-box\"},children:successMessage});}return /*#__PURE__*/_jsxs(\"div\",{ref:formRef,style:{width:\"100%\",fontFamily:\"Inter, system-ui, sans-serif\",display:\"flex\",flexDirection:\"column\",alignItems:\"flex-start\",marginTop:`${marginTop}px`,marginBottom:`${marginBottom}px`},children:[/*#__PURE__*/_jsx(\"div\",{style:{display:\"grid\",gridTemplateColumns:isMobile?\"1fr\":\"repeat(2, minmax(0, 1fr))\",columnGap:gapHorizontal,rowGap:gapVertical,width:\"100%\",alignItems:\"start\"},children:visibleFields.map(field=>/*#__PURE__*/_jsx(FormField,{field:field,values:values,handleChange:handleChange,showLabels:true,errors:errors,isMobile:isMobile},field.id))}),/*#__PURE__*/_jsx(\"button\",{type:\"submit\",onClick:handleSubmit,style:{marginTop:32,width:\"auto\",height:54,padding:\"0 48px\",backgroundColor:\"#FF0000\",color:\"#FFFFFF\",border:\"none\",borderRadius:\"27px\",fontSize:\"16px\",fontWeight:\"700\",cursor:\"pointer\",textTransform:\"uppercase\",letterSpacing:\"0.5px\",transition:\"all 0.2s ease-in-out\",alignSelf:\"flex-start\",boxShadow:isLoading?\"none\":\"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)\",opacity:isLoading?.7:1,pointerEvents:isLoading?\"none\":\"auto\"},disabled:isLoading,onMouseEnter:e=>{if(isLoading)return;e.currentTarget.style.backgroundColor=\"#E60000\";e.currentTarget.style.transform=\"translateY(-1px)\";e.currentTarget.style.boxShadow=\"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)\";},onMouseLeave:e=>{if(isLoading)return;e.currentTarget.style.backgroundColor=\"#FF0000\";e.currentTarget.style.transform=\"translateY(0)\";e.currentTarget.style.boxShadow=\"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)\";},children:isLoading?\"Submitting...\":submitButtonText})]});}addPropertyControls(DistributorForm,{submitButtonText:{type:ControlType.String,title:\"Button Text\",defaultValue:\"Become a Partner →\"},successMessage:{type:ControlType.String,title:\"Success Message\",defaultValue:\"Thank you! Your information has been submitted. We'll connect with you soon.\"},gapHorizontal:{type:ControlType.Number,title:\"Horizontal Gap\",defaultValue:12},gapVertical:{type:ControlType.Number,title:\"Vertical Gap\",defaultValue:20},webhookUrl:{type:ControlType.String,defaultValue:\"https://impaqt-backend.atlasprods.com/api/framer\",title:\"Webhook URL\",placeholder:\"https://your-webhook-url.com\"},marginTop:{type:ControlType.Number,title:\"Margin Top\",defaultValue:0,step:4},marginBottom:{type:ControlType.Number,title:\"Margin Bottom\",defaultValue:0,step:4},source:{type:ControlType.String,title:\"Source\",defaultValue:\"distributor-enquiry\",description:\"Source identifier for this form\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"DistributorForm\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./DistributorForm.map"],"mappings":"oXAAwsB,SAAwB,EAAgB,EAAM,CAAC,GAAK,CAAC,gBAAc,GAAG,cAAY,GAAG,mBAAiB,qBAAqB,iBAAe,+EAA+E,mBAAiB,GAAK,aAAW,GAAG,YAAU,EAAE,eAAa,EAAE,SAAO,uBAAuB,EAAY,EAAOA,MAAY,CAAC,CAAC,GAAG,QAAQ,MAAM,eAAe,KAAK,OAAO,YAAY,kBAAkB,MAAM,GAAG,SAAS,GAAK,CAAC,CAAC,GAAG,QAAQ,MAAM,YAAY,KAAK,OAAO,YAAY,iBAAiB,MAAM,GAAG,CAAC,CAAC,GAAG,UAAU,MAAM,iBAAiB,KAAK,OAAO,YAAY,oBAAoB,MAAM,GAAG,SAAS,GAAK,CAAC,CAAC,GAAG,QAAQ,MAAM,eAAe,KAAK,QAAQ,YAAY,mBAAmB,MAAM,GAAG,SAAS,GAAK,CAAC,CAAC,GAAG,QAAQ,MAAM,iBAAiB,KAAK,MAAM,YAAY,oBAAoB,MAAM,GAAG,SAAS,GAAK,CAAC,CAAC,GAAG,UAAU,MAAM,YAAY,KAAK,SAAS,YAAY,GAAG,MAAM,GAAG,SAAS,GAAK,QAAQ,EAAU,IAAI,IAAI,CAAC,MAAM,EAAE,KAAK,KAA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