1import{f as B,r as g,j as s}from"./index-D887yY7W.js";import{N as V}from"./Navbar-UQ2aki0x.js";import{c as W}from"./metaTags-CqC5Ub1V.js";import{g as K,a as P,b as R,c as U,K as G}from"./schemas-CnWnbiKB.js";import{B as H}from"./Button-WZUXlL4R.js";import{I as Q}from"./Icon-CC2AfKYw.js";import{m as Y,F as X,n as J,o as Z}from"./components-MBz8aSJ3.js";import{u as E}from"./useTranslation-CDB9Olyp.js";import"./context-iGC1l65B.js";const L=e=>e.toLowerCase().replace(/&/g," and ").replace(/[^a-z0-9]+/g," ").replace(/\s+/g," ").trim(),k=e=>{const o=new Map;for(const n of e)o.has(n.path)||o.set(n.path,{label:n.label,path:n.path});return Array.from(o.values())},A=(e,o,n=6)=>{const u=L(e);if(!u)return[];const a=u.split(" ").filter(r=>r.length>1),l=o.map(r=>{let d=0;return(r.normalizedCity.startsWith(u)||r.searchableValues.some(i=>i.startsWith(u)))&&(d+=100),(r.normalizedCity.includes(u)||r.searchableValues.some(i=>i.includes(u)))&&(d+=40),d+=a.reduce((i,f)=>{const h=r.normalizedCity.includes(f)||r.searchableValues.some(p=>p.includes(f));return i+(h?12:0)},0),{location:r,score:d}}).filter(r=>r.score>0).sort((r,d)=>d.score!==r.score?d.score-r.score:r.location.label.localeCompare(d.location.label)).map(r=>r.location);return k(l).slice(0,n)},D=(e,o)=>{const n=L(e);if(!n)return{status:"empty",suggestions:[]};const u=o.filter(l=>l.searchableValues.some(r=>r===n));if(u.length===1)return{location:u[0],status:"matched"};if(u.length>1)return{status:"ambiguous",suggestions:k(u).slice(0,6)};const a=o.filter(l=>l.normalizedCity===n);return a.length===1?{location:a[0],status:"matched"}:a.length>1?{status:"ambiguous",suggestions:k(a).slice(0,6)}:{status:"not_found",suggestions:A(n,o)}},y=-1,ee=({actionData:e,locations:o})=>{const n=B(),u=Y(),{t:a}=E(),[l,r]=g.useState((e==null?void 0:e.submittedArea)||""),[d,i]=g.useState(!1),[f,h]=g.useState(y),[p,w]=g.useState(null),b=g.useRef(null),z=g.useId(),j=`${z}-listbox`,C=A(l,o),T=!p&&(e==null?void 0:e.submittedArea)===l.trim()?e.suggestions:null,x=p&&p.query===l.trim()?p.suggestions:T&&T.length>0?T:C,N=d&&l.trim().length>0&&x.length>0,v=f>=0&&x[f]||null;g.useEffect(()=>{if(!l.trim()){i(!1),h(y);return}h(t=>t>=x.length?y:t)},[l,x.length]),g.useEffect(()=>()=>{b.current&&window.clearTimeout(b.current)},[]),g.useEffect(()=>{e!=null&&e.submittedArea&&e.suggestions&&e.suggestions.length>0&&i(!0)},[e]);const M=!p&&(e==null?void 0:e.submittedArea)===l.trim()?e.status:null,I=(p==null?void 0:p.status)??M,_=(()=>{switch(I){case"empty":return a("home.errorEmpty");case"ambiguous":return a("home.errorAmbiguous");case"not_found":return N?null:a("home.errorNotFound");case"unavailable":return a("home.errorUnavailable");default:return null}})(),S=t=>{r(t.label),i(!1),w(null),n(t.path)},F=t=>{r(t),i(t.trim().length>0),h(y),w(null)},q=t=>{if(t.key==="Escape"){i(!1);return}if(x.length!==0){if(t.key==="ArrowDown"){t.preventDefault(),i(!0),h(c=>Math.min(c+1,x.length-1));return}if(t.key==="ArrowUp"){t.preventDefault(),i(!0),h(c=>Math.max(c-1,-1));return}(t.key==="Enter"||t.key==="Tab")&&v&&(t.preventDefault(),S(v))}},O=t=>{if(t.preventDefault(),b.current&&(window.clearTimeout(b.current),b.current=null),v){S(v);return}if(o.length===0){u(t.currentTarget);return}const c=l.trim();if(!c){w({query:"",status:"empty",suggestions:[]});return}const m=D(c,o);if(m.status==="matched"){S({label:m.location.label,path:m.location.path});return}if(m.status==="ambiguous"){w({query:c,status:"ambiguous",suggestions:m.suggestions}),h(y),i(!0);return}w({query:c,status:m.status,suggestions:m.suggestions}),h(y),i(m.suggestions.length>0)};return s.jsxs(X,{method:"post",onSubmit:O,className:"flex flex-col gap-4",children:[s.jsx("label",{htmlFor:z,className:"sr-only",children:a("home.searchLabel")}),s.jsxs("div",{className:"flex flex-col gap-3 laptop:flex-row",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsxs("div",{className:"flex min-h-16 items-center gap-3 rounded-[1.5rem] border border-zinc-200 bg-zinc-50 px-5",children:[s.jsx(Q,{name:"MapPinOutline",alt:a("home.searchLabel"),className:"size-5 text-violet-500"}),s.jsx("input",{id:z,name:"area",type:"text",value:l,placeholder:a("home.searchPlaceholder"),className:"w-full bg-transparent py-4 text-base text-zinc-900 outline-none placeholder:text-zinc-400",role:"combobox","aria-autocomplete":"list","aria-controls":j,"aria-expanded":N,"aria-activedescendant":N&&v?`${j}-${f}`:void 0,"aria-invalid":_?!0:void 0,onChange:t=>F(t.target.value),onFocus:()=>{l.trim()&&i(!0)},onBlur:()=>{b.current=window.setTimeout(()=>{i(!1)},120)},onKeyDown:q})]}),N?s.jsx("div",{id:j,role:"listbox",className:"absolute left-0 right-0 top-[calc(100%+0.75rem)] z-20 overflow-hidden rounded-[1.5rem] border border-violet-100 bg-white p-2 shadow-[0_24px_60px_rgba(31,41,55,0.14)]",children:x.map((t,c)=>{const m=c===f;return s.jsxs("button",{id:`${j}-${c}`,type:"button",role:"option","aria-selected":m,className:`flex w-full items-center justify-between rounded-[1rem] px-4 py-3 text-left transition-colors ${m?"bg-violet-50 text-violet-900":"text-zinc-700 laptop:hover:bg-zinc-50"}`,onMouseEnter:()=>{h(c)},onMouseDown:$=>{$.preventDefault(),S(t)},children:[s.jsx("span",{className:"font-medium",children:t.label}),s.jsx("span",{className:"text-xs uppercase tracking-[0.18em] text-zinc-400",children:a("home.liveLocationTag")})]},t.path)})}):null]}),s.jsx(H,{type:"submit",size:"large",className:"h-16 min-w-[220px] rounded-[1.5rem] px-7 text-base font-semibold shadow-lg shadow-violet-300/40",children:a("home.searchButton")})]}),_?s.jsx("p",{role:"alert",className:"text-sm font-medium text-rose-600",children:_}):null]})},ce=({data:e})=>{const o=(e==null?void 0:e.canonicalUrl)||"https://trusty.app",n="Trusty - Find Contractors You Can Trust",u="Find contractors you can trust. Browse verified contractor profiles, view their work, and read reviews from real customers.",a=[K(),P({url:o,name:n,description:u}),R({name:"Trusty",url:"https://trusty.app",description:"Find contractors you can trust. Trusty connects homeowners with professional, verified contractors."})],l=U(a);return W({title:n,description:u,keywords:[...G.home],url:o,schemas:[l]})};function me(){const{homeLocations:e}=J(),o=Z(),{t:n}=E();return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"pointer-events-none fixed inset-0 z-0 bg-[radial-gradient(circle_at_top_left,rgba(139,92,246,0.22),transparent_40%),radial-gradient(circle_at_85%_8%,rgba(245,158,11,0.26),transparent_28%),linear-gradient(180deg,rgba(245,243,255,0.95)_0%,rgba(255,255,255,1)_50%,rgba(255,247,237,0.75)_100%)]"}),s.jsx(V,{}),s.jsx("main",{className:"relative z-10 flex flex-1 text-primary",children:s.jsx("div",{className:"relative mx-auto flex w-full max-w-6xl flex-1 px-4 pb-16 pt-6 ipad:px-8 laptop:px-10",children:s.jsxs("section",{className:"mx-auto flex w-full max-w-4xl flex-1 flex-col justify-center gap-8 py-10 laptop:py-16",children:[s.jsx("h1",{className:"max-w-4xl font-rubik text-[clamp(3.25rem,7vw,6rem)] leading-[0.92] font-black tracking-[-0.05em] text-zinc-900",children:n("home.heading")}),s.jsx("p",{className:"text-lg leading-8 text-zinc-600",children:n("home.subtitle")}),s.jsx(ee,{actionData:o,locations:e})]})})})]})}export{me as default,ce as meta};
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.