1import{r as V,H as w,I,j as s,g as m,l as b,i as u,A as v,m as c,q as r,J as M,h as f,k as i,p as $,K as N,L as W,M as Y,v as A}from"./BYlBEFbx.js";import D from"./C4rWy1uU.js";import O from"./DHTeSyBp.js";import z from"./fLatutv9.js";import H from"./CHNOS_zR.js";import{r as k,e as J,c as K,u as G,f as S}from"./BIH668td.js";import{d as x}from"./Jhv4hoG7.js";const Q={key:0},X={class:"contact-form__content"},Z={class:"flow"},ee={key:0},te=["action"],ne={class:"conversational-form t-lede"},oe={key:0,class:"conversational-form__errors fw-b"},ae={key:0},se={key:1},re={key:2},ie={class:"form__fields flow"},le={key:1},me={class:"form__submit"},_e={__name:"ContactForm",props:{title:String,content:String,imageSrc:String,imageAlt:String,nameLabel:String,emailLabel:String,subjectLabel:String,subjects:{type:Array,default:()=>[]},formUrl:{type:String,required:!0},idPrefix:{type:String,default:"contact"},submitText:String,termsConditionsUrl:String,antiForgeryCookieToken:String,antiForgeryFormToken:String},setup(t){const g=t,y=V(null),C=V(null),n=w({name:"",email:"",subject:null,message:"",consent:!1}),l=w({sending:!1,submitted:!1,submitError:!1}),j=I(()=>({name:n.name,email:n.email,subject:n.subject,message:n.message,consent:n.consent})),P={name:{required:k},subject:{required:k},email:{required:k,email:J},message:{required:k},consent:{required:K.withMessage("You must accept the terms and conditions",d=>d===!0)}},o=G(P,n),T=()=>{const d=g.subjects.find(e=>e.id===n.subject);return d?d.label:"Subject id not recognized"},F=async()=>await o.value.$validate()?!0:(S(y.value),x({event:"formSubmitFail",formFailReason:Object.keys(j.value).map(e=>{var _;return(_=o.value[e])!=null&&_.$error?`Missing ${e}`:null}).filter(e=>e!==null).join(", ")}),!1),L=async()=>{if(await F()){l.sending=!0;try{document.cookie=`__RequestVerificationToken=${g.antiForgeryCookieToken};path=/`,await $fetch(`/api${g.formUrl}`,{method:"POST",body:j.value,withCredentials:!0,headers:{__RequestVerificationToken:g.antiForgeryFormToken}}),S(y.value),x({event:"formSubmitSuccess",formData:{formType:"Contact",subject:T()}}),l.submitted=!0}catch{S(y.value),l.submitError=!0}finally{document.cookie="__RequestVerificationToken=;max-age=-9999999",l.sending=!1}}};return(d,e)=>{const _=N,p=D,U=O,q=z,R=W,B=H,E=Y,h=A;return s(),m("div",{ref_key:"containerRef",ref:y,class:"contact-form"},[!l.submitted&&!l.submitError?(s(),b(h,{key:0,width:"inner"},{default:u(()=>[t.title?(s(),b(_,{key:0,"image-src":t.imageSrc,"image-alt":t.imageAlt},{default:u(()=>[t.title?(s(),m("h2",Q,v(t.title),1)):c("",!0)]),_:1},8,["image-src","image-alt"])):c("",!0),r("div",X,[r("div",Z,[t.content?(s(),m("p",ee,v(t.content),1)):c("",!0)])]),r("form",{action:t.formUrl,method:"post",class:"contact-form__form form flow",onSubmit:M(L,["prevent"])},[r("div",ne,[f(p,{id:`${t.idPrefix}-name`,modelValue:n.name,"onUpdate:modelValue":e[0]||(e[0]=a=>n.name=a),name:"contact-name",label:t.nameLabel,class:"contact-form__name",placeholder:"Your name...",onBlur:e[1]||(e[1]=a=>i(o).name.$touch())},null,8,["id","modelValue","label"]),f(U,{id:`${t.idPrefix}-subject`,modelValue:n.subject,"onUpdate:modelValue":e[2]||(e[2]=a=>n.subject=a),name:"contact-subject",label:t.subjectLabel,options:t.subjects,placeholder:"Please select ...",class:"contact-form__subject",onBlur:e[3]||(e[3]=a=>i(o).subject.$touch())},null,8,["id","modelValue","label","options"]),f(p,{id:`${t.idPrefix}-email`,modelValue:n.email,"onUpdate:modelValue":e[4]||(e[4]=a=>n.email=a),name:"contact-email",label:t.emailLabel,class:"contact-form__email",placeholder:"Your email address...",onBlur:e[5]||(e[5]=a=>i(o).email.$touch())},null,8,["id","modelValue","label"]),i(o).name.$error||i(o).subject.$error||i(o).email.$error?(s(),m("ul",oe,[i(o).name.$error?(s(),m("li",ae,"Please enter your name")):c("",!0),i(o).subject.$error?(s(),m("li",se,"Please choose a subject")):c("",!0),i(o).email.$error?(s(),m("li",re,"Please enter a valid email address")):c("",!0)])):c("",!0)]),r("div",ie,[r("div",{ref_key:"messageRef",ref:C},[f(q,{id:`${t.idPrefix}-message`,modelValue:n.message,"onUpdate:modelValue":e[6]||(e[6]=a=>n.message=a),name:"message",label:"Enter your message","hide-label":!0,placeholder:"Your message here...",error:i(o).message.$error?"Please tell us how we
1can help":null,onBlur:e[7]||(e[7]=a=>i(o).message.$touch())},null,8,["id","modelValue","error"])],512),f(B,{id:`${t.idPrefix}-consent`,modelValue:n.consent,"onUpdate:modelValue":e[8]||(e[8]=a=>n.consent=a),name:"consent",error:i(o).consent.$error?"You must accept the terms and conditions":null,class:"form__terms"},{default:u(()=>[e[10]||(e[10]=$(" I hereby accept ")),t.termsConditionsUrl?(s(),b(R,{key:0,class:"fw-bb",to:t.termsConditionsUrl},{default:u(()=>e[9]||(e[9]=[$("terms & conditions")])),_:1},8,["to"])):(s(),m("span",le,"terms & conditions"))]),_:1},8,["id","modelValue","error"])]),r("div",me,[f(E,{type:"submit",waiting:l.sending},{default:u(()=>[$(v(t.submitText||"Submit"),1)]),_:1},8,["waiting"])])],40,te)]),_:1})):l.submitError?(s(),b(h,{key:1,width:"inner"},{default:u(()=>e[11]||(e[11]=[r("div",{class:"contact-form__thanks flow ta-center"},[r("h3",null,"Someone shot the messenger"),r("p",null," We're sorry but there's a technical hitch and your enquiry hasn't been sent. Please come back and try again soon. If it's urgent pick up the dog and bone and give us a ring on: 0117 984 8485 ")],-1)])),_:1})):(s(),b(h,{key:2,width:"inner"},{default:u(()=>e[12]||(e[12]=[r("div",{class:"contact-form__thanks flow ta-center"},[r("h3",null,"Cracking Lad"),r("p",null," Thanks for your enquiry. We love to meet new folk but we're also very busy, so please forgive us if we're a little tardy. We'll try and respond in good time. ")],-1)])),_:1}))],512)}}};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.