1import{r as e,j as a}from"./framer-DNXtdBgj.js";import{o as s,s as l,b as t,u as r,c as o,g as n,a3 as m,I as i,B as c,L as d,e as u,f as h}from"./index-XTUkK5WH.js";import{T as p}from"./textarea-x1LPr9Af.js";import{L as x}from"./label-DF-Tz1WR.js";import{g}from"./content-BimL-lKb.js";import{g as j,a as v,t as f}from"./lpTracking-CBo5n6Uj.js";import{C as y}from"./calendar-C5w0UWVn.js";import{M as _}from"./message-square-D4sVdRit.js";import"./supabase-CVkO6afG.js";const b=s({name:l().trim().min(2).max(120),email:l().trim().email().max(255),phone:l().trim().max(40).optional(),company:l().trim().max(160).optional(),role:l().trim().min(1).max(120),annual_revenue:l().min(1),details:l().trim().max(2e3).optional()});function N(){const{locale:s,t:l}=t(),{toast:N}=r(),{tracking:F}=o("home.lead_form.submit"),w=l("home.leadForm.eyebrow"),k=l("home.leadForm.title"),C=l("home.leadForm.subtitle"),L=l("home.leadForm.disclaimer"),S=e=>l(`home.leadForm.fields.${e}`),T=g(s).bant.options.annualRevenue,[z,q]=e.useState({name:"",email:"",phone:"",company:"",role:"",annual_revenue:"",details:""}),[D,R]=e.useState(null),[E,I]=e.useState(!1),[P,U]=e.useState(""),[B]=e.useState(n()),M=e.useRef(0);e.useEffect(()=>{M.current=Date.now()},[]);const O=(e,a)=>q(s=>({...s,[e]:a})),A=async e=>{if(D)return;const a=Date.now()-M.current;if(""!==P.trim()||3e3>a)return;const s=b.safeParse(z);if(s.success){R(e);try{const a="schedule_demo"===e?"home_schedule_demo":"home_talk_to_specialist",s=l("schedule_demo"===e?"home.leadForm.ctaScheduleDemo":"home.leadForm.ctaTalkToSpecialist"),t=j(),r=v(),o=crypto.randomUUID(),{error:n}=await u.from("leads").insert([{id:o,name:z.name,email:z.email,phone:z.phone||null,company:z.company||null,message:z.details?.trim()||null,source_page:"/",form_type:a,utm_source:t.utm_source??null,utm_medium:t.utm_medium??null,utm_campaign:t.utm_campaign??null,form_data:{role:z.role,annual_revenue:z.annual_revenue,intent:e,action_label:s,...z.details?.trim()?{details:z.details.trim()}:{},...t.utm_term?{utm_term:t.utm_term}:{},...t.utm_content?{utm_content:t.utm_content}:{},...r?{zc_gad:r}:{},...B?{gclid:B}:{}}}]);if(n)throw n;u.functions.invoke("zoho-sync-lead",{body:{source_key:a,lead_id:o,gclid:B}}).then(({error:e})=>{e&&console.error("zoho sync failed",e)}).catch(e=>console.error("zoho sync exception",e));try{f("home","form_submit",{form_type:a,intent:e})}catch{}I(!0),N({title:l("home.leadForm.successTitle")||"Recebemos seu contato!"}),h(F,{cta_key:"home.lead_form.submit",label:"Home Lead Form",form_type:a,intent:e})}catch(t){console.error("home lead form submit error",t),N({title:"Erro",description:"Não foi possÃvel enviar. Tente novamente.",variant:"destructive"})}finally{R(null)}}else N({title:l("home.leadForm.errors.invalid")||"Verifique os campos",description:s.error.issues[0]?.message,variant:"destructive"})};return a.jsx("section",{id:"lead-form",className:"py-16 md:py-24 bg-background scroll-mt-24",children:a.jsx("div",{className:"container mx-auto px-4",children:a.jsx(m,{children:a.jsxs("div",{className:"max-w-2xl mx-auto space-y-6",children:[a.jsxs("div",{className:"space-y-2 text-center",children:[w&&a.jsx("div",{className:"text-xs uppercase tracking-wider text-accent font-medium",children:w}),a.jsx("h2",{className:"font-display text-2xl md:text-3xl font-bold",children:k}),C&&a.jsx("p",{className:"text-muted-foreground text-sm",children:C})]}),E?a.jsxs("div",{className:"rounded-2xl border bg-card p-8 text-center space-y-3 shadow-sm",children:[a.jsx("h3",{className:"font-display text-2xl font-bold text-foreground",children:l("home.leadForm.successTitle")||"Obrigado!"}),a.jsx("p",{className:"text-muted-foreground",children:l("home.leadForm.successMessage")||"Em breve um especialista entrará em contato."})]}):a.jsxs("form",{className:"rounded-2xl border bg-card p-6 md:p-8 space-y-5 shadow-sm",onSubmit:e=>{e.preventDefault(),A("schedule_demo")},children:[a.jsx("input",{type:"hidden",id:"zc_gad",name:"zc_gad",value:B,readOnly:!0}),a.jsxs("div",{"aria-hidden":"true",className:"absolute left-[-10000px] top-auto w-px h-px overflow-hidden",children:[a.jsx("label",{htmlFor:"hl-website",children:"Website"}),a.jsx("input",{id:"hl-website",type:"text",tabIndex:-1,autoComplete:"off",value:P,onChange:e=>U(e.target.value)})]}),a.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[a.jsxs("div",{className:"space-y-1.5",children:[a.jsxs(x,{htmlFor:"hl-name",children:[S("name")," *"]}),a.jsx(i,{id:"hl-name",value:z.name,onChange:e=>O("name",e.target.value),maxLength:120,required:!0})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsxs(x,{htmlFor:"hl-email",children:[S("email")," *"]}),a.jsx(i,{id:"hl-email",type:"email",value:z.email,onChange:e=>O("email",e.target.value),maxLength:255,required:!0})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(x,{htmlFor:"hl-phone",children:S("phone")}),a.jsx(i,{id:"hl-phone",value:z.phone,onChange:e=>O("phone",e.target.value),maxLength:40})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(x,{htmlFor:"hl-company",children:S("company")}),a.jsx(i,{id:"hl-company",value:z.company,onChange:e=>O("company",e.target.value),maxLength:160})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsxs(x,{htmlFor:"hl-role",children:[S("role")," *"]}),a.jsx(i,{id:"hl-role",value:z.role,onChange:e=>O("role",e.target.value),maxLength:120,required:!0})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsxs(x,{htmlFor:"hl-revenue",children:[S("annualRevenue")," *"]}),a.jsxs("select",{id:"hl-revenue",className:"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm",value:z.annual_revenue,onChange:e=>O("annual_revenue",e.target.value),required:!0,children:[a.jsx("option",{value:"",children:S("annualRevenuePlaceholder")}),T.map(e=>a.jsx("option",{children:e},e))]})]})]}),a.jsxs("div",{className:"space-y-1.5",children:[a.jsx(x,{htmlFor:"hl-details",children:S("details")}),a.jsx(p,{id:"hl-details",value:z.details,onChange:e=>O("details",e.target.value),placeholder:S("detailsPlaceholder"),maxLength:2e3,rows:4})]}),a.jsxs("div",{className:"grid sm:grid-cols-2 gap-3 pt-2",children:[a.jsxs(c,{type:"submit",size:"lg",variant:"accent",className:"w-full gap-2",disabled:null!==D,children:["schedule_demo"===D?a.jsx(d,{className:"h-4 w-4 animate-spin"}):a.jsx(y,{className:"h-4 w-4"}),l("home.leadForm.ctaScheduleDemo")]}),a.jsxs(c,{type:"button",size:"lg",variant:"outline",className:"w-full gap-2",disabled:null!==D,onClick:()=>A("talk_to_specialist"),children:["talk_to_specialist"===D?a.jsx(d,{className:"h-4 w-4 animate-spin"}):a.jsx(_,{className:"h-4 w-4"}),l("home.leadForm.ctaTalkToSpecialist")]})]}),L&&a.jsx("p",{className:"text-xs text-muted-foreground text-center",children:L})]})]})})})})}export{N as HomeLeadFormSection};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.