1import{r as m,j as e,c as j,F}from"./index-Dumoso4n.js";const w={name:100,email:100,message:500},N=/^(?=.{1,254}$)(?=.{1,64}@.{1,255}$)([a-zA-Z\d!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z\d!#$%&'*+/=?^_`{|}~-]+)*@[a-zA-Z\d](?:[a-zA-Z\d-]{0,61}[a-zA-Z\d])?\.)+[a-zA-Z]{2,}$/,v=()=>{const[t,p]=m.useState({nameContactForm:"",emailContactForm:"",messageContactForm:"",botFieldContactForm:""}),[d,l]=m.useState(null),[n,x]=m.useState({}),[g,f]=m.useState({name:!1,email:!1,message:!1}),[b,C]=m.useState(Date.now());m.useEffect(()=>{C(Date.now())},[]);const c=o=>{const{name:a,value:i}=o.target,s=a.replace("ContactForm","");i.length<=w[s]?(p(r=>({...r,[a]:i})),n[a]&&x(r=>({...r,[a]:""})),f(r=>({...r,[s]:!1}))):f(r=>({...r,[s]:!0}))},y=async o=>{o.preventDefault();const a={};if(t.nameContactForm.trim()||(a.nameContactForm="This field is required"),(!t.emailContactForm.trim()||!N.test(t.emailContactForm.trim()))&&(a.emailContactForm="Enter a valid Email Id"),t.messageContactForm.trim()||(a.messageContactForm="This field is required"),Object.keys(a).length>0){x(a);return}const i=Date.now()-b;if(!(t.botFieldContactForm!==""||i<2e3))try{l("loading");const s=await fetch("/api/contact",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),r=await s.json();s.ok?(l("success"),p({nameContactForm:"",emailContactForm:"",messageContactForm:"",botFieldContactForm:""}),x({}),C(Date.now())):(console.error("Server error:",r.message||"Unknown error"),l("error"))}catch(s){console.error("Network or parsing error:",s),l("error")}},u=o=>n[o]&&e.jsxs("p",{className:"flex items-center text-red-500 mt-1 text-sm",children:[e.jsx(F,{className:"mr-1"}),n[o]]}),h=o=>g[o]&&e.jsxs("p",{className:"flex items-center text-yellow-500 mt-1 text-sm",children:[e.jsx(F,{className:"mr-1"}),"Maximum character limit reached"]});return e.jsxs("div",{className:"border border-gray-300 rounded-md shadow-md px-8 py-6",children:[e.jsx("h1",{className:"text-3xl font-semibold text-gray-800 mb-8 text-center",children:"Get in Touch"}),e.jsxs("form",{onSubmit:y,className:"space-y-6",autoComplete:"off",children:[e.jsxs("div",{style:{position:"absolute",left:"-9999px",opacity:0},children:[e.jsx("label",{htmlFor:"botFieldContactForm",children:"Do not fill this field"}),e.jsx("input",{type:"text",name:"botFieldContactForm",id:"botFieldContactForm",value:t.botFieldContactForm,onChange:c,tabIndex:"-1",autoComplete:"off","aria-hidden":"true"})]}),e.jsxs("div",{className:"flex flex-col space-y-6 sm:flex-row sm:space-y-0 sm:space-x-4",children:[e.jsxs("div",{className:"w-full",children:[e.jsx("input",{type:"text",name:"nameContactForm",value:t.nameContactForm,onChange:c,className:`w-full px-4 p-2 border rounded-md bg-white text-gray-800 focus:outline-none ${n.nameContactForm?"border-red-600":"border-gray-300"}`,placeholder:"Name"}),u("nameContactForm"),h("name")]}),e.jsxs("div",{className:"w-full",children:[e.jsx("input",{type:"text",name:"emailContactForm",value:t.emailContactForm,onChange:c,className:`w-full px-4 p-2 border rounded-md bg-white text-gray-800 focus:outline-none ${n.emailContactForm?"border-red-600":"border-gray-300"}`,placeholder:"Email"}),u("emailContactForm"),h("email")]})]}),e.jsxs("div",{children:[e.jsx("textarea",{name:"messageContactForm",value:t.messageContactForm,onChange:c,rows:"6",className:`w-full px-4 p-2 border rounded-md bg-white text-gray-800 focus:outline-none ${n.messageContactForm?"border-red-600":"border-gray-300"}`,placeholder:"Message"}),u("messageContactForm"),h("message")]}),e.jsx("div",{className:"text-center",children:e.jsx(j,{type:"submit",loading:d==="loading",children:"Submit"})}),d==="success"&&e.jsx("p",{className:"text-green-600 mt-2",children:"Thanks! I'll get back to you shortly."}),d==="error"&&e.jsx("p",{className:"text-red-600 mt-2",children:"Something went wrong. Please try again later. If the issue persists, feel free to send an email."})]})]})},E=()=>e.jsx("div",{className:"max-w-4xl mx-auto px-8 sm:px-6 lg:px-16 py-16",children:e.jsx(v,{})});export{E as default};
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.