import{j as e,b as A,r as n,f as xe,L as fe,e as ve}from"./vendor-react-DgEFbQIi.js";import{S as _,C as Ae,j as We,z as pe,B as G,_ as be,u as Se,w as le,W as _e,E as Be,m as Oe,D as Ge,A as ze,F as Ke,$ as ce,a0 as de,a1 as ue,d as Ve,e as He,f as Xe,h as Ye,U as Ze,o as Je,y as he,Z as Qe,a2 as et}from"./index-DFVuS8SP.js";import{u as tt}from"./useSeo-eyKuqwK1.js";import"./vendor-maps-bOuA10hf.js";import{e as st,g as me,i as Y,h as rt,s as nt,j as ge,r as at,u as it,k as ot,a as lt,f as Z,d as ct,C as dt,R as ut,U as ht,L as mt}from"./UnifiedMobileNavbar-BPabqAHd.js";import"./vendor-amplify-BBi2B1tW.js";import{u as ye,t as Ne}from"./useHoverRipple-CBPqdLxA.js";import{L as je}from"./ListingCard-Cw2aMm7U.js";import{S as gt,a as xt,b as ft,c as vt}from"./sheet-BzPTO6EG.js";import{C as pt}from"./calendar-days-CNTt1Q2P.js";import"./vendor-radix-kdo0k_bv.js";import"./vendor-motion-CzLrDd6y.js";import"./circle-plus-DGhVgDs7.js";import"./star-C0MTo9W6.js";import"./dollar-sign-Cz68EQu2.js";import"./venues-BaWtNBkC.js";import"./listing-utils-CICni2H8.js";import"./listingFeeInput-DmvcA6E5.js";import"./listing-B0peEtEB.js";import"./city-coordinates-9wKWO0xx.js";import"./claimRequests-54T7aAUE.js";import"./OptimizedImage-BZrGLn_7.js";import"./badges-B7hHNwsz.js";import"./wishlists-NNbira8h.js";import"./authHeaders-C650O0HP.js";import"./ImageWithFallback-C1HTj5IA.js";import"./parseISO-C4sM-PC7.js";import"./badge-check-D5e4IH5i.js";const bt=({count:t=5,showFullStructure:r=!0,isMobile:s=!1})=>{const o=Array.from({length:t}),m=()=>e.jsxs("div",{className:"group flex h-full flex-col rounded-2xl bg-white",children:[e.jsx(_,{className:"aspect-square w-full rounded-2xl"}),e.jsxs("div",{className:"flex flex-1 flex-col gap-0.5 pt-2 px-0.5 pb-3 md:px-1.5 bg-white rounded-b-2xl",children:[e.jsx(_,{className:"h-4 w-3/4"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[e.jsx(_,{className:"h-3 w-20"}),e.jsx(_,{className:"h-3 w-12"})]})]})]});return r?e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(_,{className:"h-9 w-64"})," ",e.jsx(_,{className:"h-4 w-48"})," "]}),Array.from({length:2}).map((S,v)=>e.jsxs("section",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(_,{className:"h-8 w-8"})," ",e.jsxs("div",{children:[e.jsx(_,{className:"h-6 w-32 mb-1"})," ",e.jsx(_,{className:"h-3 w-40"})," "]})]})}),e.jsx("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5",children:o.map((j,f)=>e.jsx("div",{children:m()},f))})]},v))]}):e.jsx("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5",children:o.map((S,v)=>e.jsx("div",{children:m()},v))})},J=12,St=400,yt=16,Nt="[data-carousel-item='true']";function jt({items:t,renderItem:r,getItemKey:s,header:o,onReachEnd:m,reachEndThresholdPx:S=0,edgeLoadEnabled:v=!1,trailing:j,scrollButtonsDisabled:f=!1,itemSelector:p=Nt,enableHoverRipple:h=!1}){const b=A.useRef(null),{onItemHover:d,getStyle:L}=ye(),[E,C]=A.useState(!1),[w,F]=A.useState(!1),[N,D]=A.useState(1),I=A.useRef({onReachEnd:m,reachEndThresholdPx:S,edgeLoadEnabled:v});I.current={onReachEnd:m,reachEndThresholdPx:S,edgeLoadEnabled:v};const q=A.useRef(p);q.current=p;const R=A.useCallback(()=>{const c=b.current;if(!c)return;const u=c.clientWidth-(h?yt*2:0);let y=1;u>=1200?y=5:u>=950?y=4:u>=700?y=3:u>=480||u>=360?y=2:y=1,D(y)},[h]),P=A.useCallback(()=>{const c=b.current;if(!c)return;const{scrollLeft:u,scrollWidth:y,clientWidth:k}=c;C(u>4),F(u+k<y-4);const{onReachEnd:M,reachEndThresholdPx:$,edgeLoadEnabled:U}=I.current;U&&M&&u+k>=y-$&&M()},[]);A.useLayoutEffect(()=>{const c=b.current;if(!c)return;const u=()=>{R(),P()};R(),P(),c.addEventListener("scroll",P,{passive:!0}),window.addEventListener("resize",u);const y=new ResizeObserver(u);return y.observe(c),()=>{c.removeEventListener("scroll",P),window.removeEventListener("resize",u),y.disconnect()}},[R,P]),A.useEffect(()=>{P()},[t.length,P]),A.useEffect(()=>{const c=b.current;if(!c)return;const u=c.querySelector(q.current);if(!u)return;const y=parseFloat(getComputedStyle(c).columnGap||`${J}`),M=u.getBoundingClientRect().width+y,$=c.scrollWidth-c.clientWidth,U=Math.min(Math.round(c.scrollLeft/M)*M,$);c.scrollTo({left:U,behavior:"auto"}),P()},[N,P]);const B=c=>{const u=b.current;if(!u)return;const y=u.querySelector(q.current);if(!y)return;const k=parseFloat(getComputedStyle(u).columnGap||`${J}`),$=y.getBoundingClientRect().width+k,U=u.scrollWidth-u.clientWidth,z=c==="left"?Math.max(0,u.scrollLeft-$):Math.min(U,u.scrollLeft+$);u.scrollTo({left:z,behavior:"smooth"})},l=A.useMemo(()=>N<=1?"100%":`calc((100% - ${(N-1)*J}px) / ${N})`,[N]),g=!f&&E,a=!f&&w;return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[o,e.jsxs("div",{className:"hidden gap-2 lg:flex",children:[e.jsx("button",{type:"button",onClick:()=>B("left"),className:`grid h-10 w-10 place-items-center rounded-full border border-gray-200 bg-white text-gray-900 shadow-sm transition hover:scale-105 hover:shadow-md ${g?"opacity-100":"opacity-40 pointer-events-none"}`,"aria-label":"Scroll left",children:e.jsx(Ae,{className:"h-4 w-4"})}),e.jsx("button",{type:"button",onClick:()=>B("right"),className:`grid h-10 w-10 place-items-center rounded-full border border-gray-200 bg-white text-gray-900 shadow-sm transition hover:scale-105 hover:shadow-md ${a?"opacity-100":"opacity-40 pointer-events-none"}`,"aria-label":"Scroll right",children:e.jsx(We,{className:"h-4 w-4"})})]})]}),e.jsx("div",{className:"relative",children:e.jsxs("div",{ref:b,className:"grid grid-flow-col gap-3 overflow-x-auto [-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden"+(h?" pt-5 pb-5 px-4 -mt-5 -mb-5 -mx-4":""),style:{gridAutoColumns:l},onMouseLeave:h?()=>d(null):void 0,children:[t.map((c,u)=>e.jsx("div",{"data-carousel-item":"true",className:h?"w-full snap-start transition-[transform,box-shadow] duration-300 ease-out will-change-transform":"w-full snap-start",style:h?L(u):void 0,onMouseEnter:h?()=>d(u):void 0,children:r(c,u)},s(c,u))),j]})})]})}const we=12;function Ce({serviceType:t,query:r,city:s,state:o,searchLat:m,searchLng:S,date:v,enabled:j}){var F;const f=st({queryKey:["published-services-by-type",t,(r==null?void 0:r.trim())??"",s??"",o??"",m??"",S??"",v??""],initialPageParam:void 0,queryFn:({pageParam:N})=>pe({listingKind:"service",serviceType:t,query:(r==null?void 0:r.trim())||void 0,city:s||void 0,state:o?o.toUpperCase().trim().substring(0,2):void 0,searchLat:m,searchLng:S,date:v,limit:we,cursor:N}),getNextPageParam:N=>N.nextCursor,enabled:j,staleTime:12e4,refetchOnWindowFocus:!1}),p=n.useMemo(()=>{var N;return((N=f.data)==null?void 0:N.pages.flatMap(D=>D.items))??[]},[f.data]),h=(F=f.data)==null?void 0:F.pages,b=h==null?void 0:h[h.length-1],d=!!v||!!(r!=null&&r.trim()),L=j&&d&&b!==void 0&&b.items.length===0&&f.hasNextPage===!0&&!f.isFetchingNextPage&&!f.isLoading,E=j&&d&&p.length===0&&(L||f.isFetchingNextPage),{fetchNextPage:C}=f;n.useEffect(()=>{L&&C()},[L,C]);const w=f.isLoading||E;return{items:p,fetchNextPage:C,hasNextPage:f.hasNextPage,isFetchingNextPage:f.isFetchingNextPage,isLoading:w,isError:f.isError,isResolved:j&&!w}}const Le=({serviceTypeInfo:t})=>e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-2xl",children:t.icon}),e.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:t.label})]}),e.jsx("div",{className:"grid grid-flow-col gap-3",style:{gridAutoColumns:"minmax(0, 1fr)"},children:Array.from({length:5}).map((r,s)=>e.jsx("div",{className:"h-56 w-full animate-pulse rounded-xl bg-gray-100","aria-hidden":"true"},s))})]}),wt=({serviceTypeInfo:t,type:r,services:s,buildServicesLink:o,serializedSearchParams:m,onLoadMore:S,hasMore:v,isLoadingMore:j})=>{const f=v||s.length>we;return e.jsx(jt,{items:s,getItemKey:p=>p.listingId,renderItem:(p,h)=>e.jsx("div",{className:"contents",onClickCapture:b=>Ne({listingId:p.listingId,category:"service",position:h+1,source:"carousel",searchQuery:m},b),children:e.jsx(je,{kind:"service",service:p,className:"h-full",searchQuery:m})}),header:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-2xl",children:t.icon}),e.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:t.label}),f&&e.jsxs(fe,{to:o(r),className:"text-sm font-medium text-[hsl(var(--brand))] hover:underline",children:["See all ",t.label.toLowerCase()]})]}),onReachEnd:S,reachEndThresholdPx:St,edgeLoadEnabled:v&&!j,enableHoverRipple:!0,trailing:v&&j?e.jsx("div",{className:"grid w-16 place-items-center","aria-hidden":"true",children:e.jsx(be,{className:"h-5 w-5 animate-spin text-gray-400"})}):null})},Ct=({serviceTypeInfo:t,cityForApi:r,stateForApi:s,searchLatForApi:o,searchLngForApi:m,dateForApi:S,textQuery:v,locationReady:j,buildServicesLink:f,serializedSearchParams:p,onResolve:h})=>{const{items:b,fetchNextPage:d,hasNextPage:L,isFetchingNextPage:E,isLoading:C,isResolved:w}=Ce({serviceType:t.id,query:v,city:r,state:s,searchLat:o,searchLng:m,date:S,enabled:j});n.useEffect(()=>{w&&h(t.id,b.length>0)},[w,b.length,h,t.id]);const F=n.useCallback(()=>{L&&!E&&d()},[L,E,d]);return C?e.jsx(Le,{serviceTypeInfo:t}):b.length===0?null:e.jsx("section",{children:e.jsx(wt,{serviceTypeInfo:t,type:t.id,services:b,buildServicesLink:f,serializedSearchParams:p,onLoadMore:F,hasMore:!!L,isLoadingMore:E})})},Lt=({serviceTypeInfo:t,cityForApi:r,stateForApi:s,searchLatForApi:o,searchLngForApi:m,dateForApi:S,textQuery:v,locationReady:j,serializedSearchParams:f,onResolve:p})=>{const{items:h,fetchNextPage:b,hasNextPage:d,isFetchingNextPage:L,isLoading:E,isResolved:C}=Ce({serviceType:t.id,query:v,city:r,state:s,searchLat:o,searchLng:m,date:S,enabled:j}),{onItemHover:w,getStyle:F}=ye("grid");return n.useEffect(()=>{C&&p(t.id,h.length>0)},[C,h.length,p,t.id]),E?e.jsx(Le,{serviceTypeInfo:t}):h.length===0?null:e.jsxs("section",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-3xl",children:t.icon}),e.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:t.label})]}),e.jsx("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5",onMouseLeave:()=>w(null),children:h.map((N,D)=>e.jsx("div",{className:"h-full transition-[transform,box-shadow] duration-300 ease-out will-change-transform",style:F(D),onMouseEnter:()=>w(D),onClickCapture:I=>Ne({listingId:N.listingId,category:"service",position:D+1,source:"search",searchQuery:f},I),children:e.jsx(je,{kind:"service",service:N,className:"h-full",searchQuery:f})},N.listingId))}),d&&e.jsx("div",{className:"flex justify-center pt-2",children:e.jsx(G,{variant:"outline",onClick:()=>void b(),disabled:L,children:L?e.jsx(be,{className:"h-4 w-4 animate-spin"}):`Show more ${t.label.toLowerCase()}`})})]})},kt=({serviceTypes:t,selectedServiceTypes:r,serializedSearchParams:s,userCity:o,locationParam:m,cityForApi:S,stateForApi:v,searchLatForApi:j,searchLngForApi:f,dateForApi:p,textQuery:h,locationReady:b})=>{const[d]=xe(),L=g=>{const a=new URLSearchParams(d);return a.set("services",g),`/services?${a.toString()}`},E=()=>{const g=new URLSearchParams(d);return g.delete("services"),g.delete("serviceType"),`/services?${g.toString()}`},C=r.length>0,w=(h==null?void 0:h.trim())||void 0,F=n.useMemo(()=>C?r.map(g=>t.find(a=>a.id===g)).filter(g=>g!==void 0):t,[C,r,t]),[N,D]=n.useState({});n.useEffect(()=>{D({})},[s]);const I=n.useCallback((g,a)=>{D(c=>c[g]===a?c:{...c,[g]:a})},[]),q=F.map(g=>g.id),R=q.every(g=>g in N),P=q.some(g=>N[g]),B=R&&!P,l=n.useMemo(()=>{const g=C?r.map(k=>{var M;return(M=t.find($=>$.id===k))==null?void 0:M.label}).filter(k=>k!==void 0):[],a=g.length>0?g.join(", "):null,c=(()=>{const k=m==null?void 0:m.toLowerCase();return k==="nearby"||k==="current location"?"nearby":m?`in ${m}`:o?`in ${o}`:""})(),u=w?` matching “${w}”`:"";return[`${a?`${a} services`:"Services"}${u}`,c].filter(Boolean).join(" ")},[C,m,w,r,t,o]);return e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h1",{className:"text-2xl md:text-3xl font-semibold text-gray-900",children:l}),(m==null?void 0:m.trim())&&m.toLowerCase()!=="nearby"&&m.toLowerCase()!=="current location"&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Includes providers based here and those who travel to this area."})]}),B?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx("p",{className:"text-lg font-medium text-muted-foreground mb-2",children:w?`No services match “${w}”`:C?"No services available for selected types":"No services available yet"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:o?`Check back soon for services in ${o}`:"Check back soon for new services"}),C&&e.jsx(G,{variant:"outline",asChild:!0,className:"mt-4",children:e.jsx(fe,{to:E(),children:"View all services"})})]}):e.jsx("div",{className:"space-y-8",children:F.map(g=>C?e.jsx(Lt,{serviceTypeInfo:g,cityForApi:S,stateForApi:v,searchLatForApi:j,searchLngForApi:f,dateForApi:p,textQuery:w,locationReady:b,serializedSearchParams:s,onResolve:I},g.id):e.jsx(Ct,{serviceTypeInfo:g,cityForApi:S,stateForApi:v,searchLatForApi:j,searchLngForApi:f,dateForApi:p,textQuery:w,locationReady:b,buildServicesLink:L,serializedSearchParams:s,onResolve:I},g.id))})]})},Et=({open:t,onOpenChange:r,initialWhen:s,onApply:o})=>{const m=Se(),[S,v]=n.useState(()=>le(s));return n.useEffect(()=>{t&&v(le(s))},[t,s]),e.jsx(gt,{open:t,onOpenChange:r,children:e.jsxs(xt,{side:m?"bottom":"right",className:"flex flex-col gap-0 p-0 sm:max-w-md",children:[e.jsx(ft,{className:"border-b border-border px-4 py-4",children:e.jsx(vt,{children:"When"})}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain px-4 py-4",children:e.jsx(_e,{value:S,onChange:v})}),e.jsxs("div",{className:"flex items-center gap-3 border-t border-border bg-background px-4 py-4",children:[e.jsx(G,{variant:"outline",className:"flex-1",onClick:()=>v(Be),children:"Clear"}),e.jsx(G,{className:"flex-1 bg-brand hover:bg-brand/90 text-brand-foreground",onClick:()=>{o(Oe(S)),r(!1)},children:"Apply"})]})]})})},Rt=()=>e.jsxs("div",{className:"flex flex-col gap-3 rounded-2xl border border-brand-100 bg-brand-50/60 p-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Ge,{className:"mt-0.5 h-5 w-5 flex-shrink-0 text-brand-600","aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-[#0F0F0F]",children:"Need a custom route?"}),e.jsx("p",{className:"text-xs text-[#4B4B4B]",children:"Send us your details and we'll find you exactly what you want at unbeatable prices. We'll get back to you with a quote within 72 hours."})]})]}),e.jsx(G,{asChild:!0,size:"sm",className:"flex-shrink-0 self-start rounded-full sm:self-auto",children:e.jsxs("a",{href:Ke("/quote"),children:["Get a free quote",e.jsx(ze,{className:"ml-1.5 h-4 w-4"})]})})]});function Ft(t,r){const s=(t==null?void 0:t.trim())??"";if(!s)return{kind:"browse"};const o=s.toLocaleLowerCase();return o==="nearby"||o==="current location"?{kind:"nearby",location:"Nearby"}:r==="confirmed-location"?{kind:"location",location:s}:{kind:"free-text",q:s}}function Q(t){if(!t||t.trim().toLowerCase()==="all day")return["",""];const r=t.indexOf(" - ");return r<0?["",""]:[t.slice(0,r).trim(),t.slice(r+3).trim()]}function Pt(t,r,s){if(!t||!r||!/^\d{4}-\d{2}-\d{2}$/.test(s))return null;const o=new Date(t),m=new Date(r),S=m.getTime()-o.getTime();if(Number.isNaN(o.getTime())||Number.isNaN(m.getTime())||S<=0)return null;const[v,j,f]=s.split("-").map(Number),p=new Date(Date.UTC(v,j-1,f,o.getUTCHours(),o.getUTCMinutes(),o.getUTCSeconds(),o.getUTCMilliseconds())),h=new Date(p.getTime()+S);return{start:p.toISOString(),end:h.toISOString()}}const Mt=()=>{const[t]=xe(),r=ve(),s=t.get("location"),o=t.get("q"),m=!s&&!o&&me()||"",[S,v]=n.useState(()=>s||o||m),[j,f]=n.useState(s||m?"confirmed-location":"free-text"),[p,h]=n.useState(()=>t.get("date")||""),[b,d]=n.useState(()=>Q(t.get("duration"))[0]),[L,E]=n.useState(()=>Q(t.get("duration"))[1]),[C,w]=n.useState(!1),[F,N]=n.useState(t.get("serviceType"));n.useEffect(()=>{const a=t.get("location"),c=t.get("q"),u=!a&&!c&&me()||"";v(a||c||u),f(a||u?"confirmed-location":"free-text"),h(t.get("date")||"");const[y,k]=Q(t.get("duration"));d(y),E(k),w(!1),N(t.get("serviceType"))},[t]);const D=n.useCallback(a=>{v(a),f("free-text")},[]),I=n.useCallback(a=>{v(a),f("confirmed-location")},[]),q=n.useCallback(a=>{d(a),w(!0)},[]),R=n.useCallback(a=>{E(a),w(!0)},[]),P=n.useMemo(()=>new URLSearchParams(t).toString(),[t]),B=n.useCallback(()=>{const a=Ft(S,j),c=t.get("date")||"",u=t.get("duration"),y=p.trim(),k=y!==c;let M=null,$=null,U=null;if(y)if(!k&&!C)M=t.get("start"),$=t.get("end"),U=u;else if(C){const W=b.trim(),K=L.trim();U=W&&K?`${W} - ${K}`:"All day"}else{const W=Pt(t.get("start"),t.get("end"),y);M=(W==null?void 0:W.start)??null,$=(W==null?void 0:W.end)??null,U=u}const z=ce(t,de,{q:a.kind==="free-text"?a.q:null,location:a.kind==="location"||a.kind==="nearby"?a.location:null,date:y,start:M,end:$,duration:U,serviceType:F});r(`/services?${z.toString()}`)},[C,L,b,j,S,r,t,F,p]),l=n.useCallback(()=>{D(""),h(""),d(""),E(""),w(!1),N(null);const a=ce(t,de,{});r(`/services?${a.toString()}`)},[r,t,D]),g=n.useCallback(a=>a==="services"||a==="venues"?ue(a,t):ue("venues",t),[t]);return{searchParams:t,navigate:r,locationInput:S,setLocationInput:D,confirmLocationInput:I,inputIntent:j,whenValue:p,setWhenValue:h,durationStart:b,setDurationStart:q,durationEnd:L,setDurationEnd:R,selectedServiceType:F,setSelectedServiceType:N,serializedSearchParams:P,applySearch:B,handleClearAll:l,buildCategoryUrl:g}},os=()=>{var re,ne,ae,ie;const t=Se(),r=ve();tt({title:"Event services & vendors | PLEC",description:"Find photographers, caterers, DJs, florists, and more for your next event. Browse event service providers on PLEC."});const{searchParams:s,serializedSearchParams:o}=Mt(),[m,S]=n.useState(!1),v=n.useMemo(()=>{const i=Ve(s.get("date"),s.get("start"));if(!i)return"When";const x=He(s.get("start"),s.get("end")),T=Xe(i,"MMM d");return x?`${T} · ${Ye(x.start)}`:T},[s]),j=v!=="When",f=n.useCallback(i=>{const x=new URLSearchParams(s);i.date?x.set("date",i.date):x.delete("date"),i.date&&i.start?x.set("start",i.start):x.delete("start"),i.date&&i.end?x.set("end",i.end):x.delete("end");const T=x.toString();r(T?`/services?${T}`:"/services")},[r,s]),p=n.useMemo(()=>{const i=s.get("services"),x=s.get("serviceType");return i?i.split(",").filter(Boolean):x?[x]:[]},[s]),h=((re=s.get("q"))==null?void 0:re.trim())||"",b=h.length>0,d=s.get("location"),L=Y(d),[E,C]=n.useState(null),[w,F]=n.useState(!1);n.useEffect(()=>{if(!L)return;let i=!1;const x=T=>{i||(C(T),F(!0))};return rt().then(x).catch(()=>x(null)),()=>{i=!0}},[L]),n.useEffect(()=>{const i=d==null?void 0:d.trim();!i||Y(i)||nt(i)},[d]);const[N,D]=n.useState(0),I=n.useMemo(()=>{const i=ge(),x=at({urlLocation:d,deviceLocation:E,storedLocation:i});if(!x)return null;const T=d!=null&&d.trim()?E:i,oe=T==null?void 0:T.coordinates;return oe?{...x,coordinates:oe}:x},[d,E,N]),q=!L||w,{notice:R,reportResults:P,searchRealLocationAnyway:B}=it({realLocation:I,resetKey:`${o}|${N}`,enabled:q}),l=R?R.fallbackLocation:I,g=n.useMemo(()=>{if(l){if(!R){const i=ge(),x=d!=null&&d.trim()?E:i;if(x!=null&&x.coordinates)return x.coordinates}return ot(l)}},[l,R,d,E,N]),{searchResults:a,venues:c,outsideAreaVenues:u,crossKindVenues:y,searchLoading:k,searchError:M,refetch:$,fetchNextPage:U,hasNextPage:z,isFetchingNextPage:W}=lt({listingKind:"service",location:b&&R?Z(R.fallbackLocation):d,effectiveQuery:h,sortBy:"relevance",boundsSearchParams:null,filters:{},date:s.get("date"),serviceType:p.length===1?p[0]:void 0}),K=n.useRef(null);n.useEffect(()=>{var x;if(!b||k||!a||K.current===o)return;K.current=o;const i=s.get("date");Ze("search_performed",{query:h,category:"services",city:d||void 0,dateRange:i?{date:i}:void 0,filters:p.length>0?{serviceTypes:p}:void 0,resultsCount:((x=a.meta)==null?void 0:x.total)??c.length})},[b,k,a,o,s,h,d,p,c.length]);const O=Je({queryKey:["services-location-probe",(l==null?void 0:l.city.toLowerCase())??"",(l==null?void 0:l.state)??""],queryFn:()=>pe({listingKind:"service",city:l==null?void 0:l.city.toLowerCase(),state:l==null?void 0:l.state,limit:1}),enabled:!b&&q&&!!(l!=null&&l.city),staleTime:2*60*1e3,refetchOnWindowFocus:!1});n.useEffect(()=>{var i;if(b){P({loading:k,settled:!!a&&!M,count:c.length});return}l!=null&&l.city&&P({loading:O.isLoading||O.isFetching,settled:O.isSuccess,count:((i=O.data)==null?void 0:i.items.length)??0})},[b,P,k,a,M,c.length,l==null?void 0:l.city,O.isLoading,O.isFetching,O.isSuccess,O.data]);const ee=n.useCallback(()=>{ct(),D(T=>T+1);const i=new URLSearchParams(s);i.delete("location");const x=i.toString();r(x?`/services?${x}`:"/services")},[r,s]),ke=l==null?void 0:l.city.toLowerCase(),Ee=l==null?void 0:l.state,V=((ne=s.get("date"))==null?void 0:ne.trim())||void 0,te=(ae=s.get("start"))==null?void 0:ae.trim(),H=te?new Date(te):null,Re=H&&!Number.isNaN(H.getTime())?H.toISOString().slice(0,10):void 0,Fe=V&&/^\d{4}-\d{2}-\d{2}$/.test(V)?V:Re,Pe=((ie=s.get("q"))==null?void 0:ie.trim())||void 0,X=l?Z(l):null,Me=R?Z(R.fallbackLocation):d!=null&&d.trim()&&!Y(d)?d:"",De=l?e.jsxs(G,{type:"button",variant:"outline",size:"sm",className:"h-9 flex-shrink-0 gap-2 rounded-full",onClick:ee,children:[e.jsx(et,{className:"h-4 w-4"}),X]}):null,Te=R?e.jsx(mt,{notice:R,onSearchRealLocation:B,onChangeLocation:ee}):null,$e=n.useMemo(()=>he.filter(i=>i.id!=="other").map(i=>({id:i.id,label:i.label,icon:e.jsx("span",{className:"text-base leading-none",children:i.icon})})),[]),se=p.length===1?p[0]:void 0,qe=n.useCallback(i=>{const x=new URLSearchParams(s);x.delete("serviceType"),i?x.set("services",i):x.delete("services");const T=x.toString();r(T?`/services?${T}`:"/services")},[r,s]),Ie=e.jsx(ht,{}),Ue=e.jsx(bt,{count:5,showFullStructure:!0,isMobile:t});return e.jsxs(Qe,{showSearch:!0,showFooter:!0,children:[e.jsxs("div",{className:"min-h-screen bg-white",children:[t&&Ie,e.jsxs("div",{className:"container mx-auto px-4 py-8 space-y-8",children:[e.jsx(dt,{items:$e,selectedId:se,onSelect:qe,className:"sticky top-0 z-20 -mx-4 border-b border-border bg-white/95 px-4 py-3 backdrop-blur"}),e.jsxs("div",{className:"flex items-center gap-2",children:[De,e.jsxs(G,{type:"button",variant:"outline",size:"sm",className:`h-9 flex-shrink-0 gap-2 rounded-full ${j?"border-brand text-brand":""}`,onClick:()=>S(!0),children:[e.jsx(pt,{className:"h-4 w-4"}),v]})]}),se==="chartered_bus"&&e.jsx(Rt,{}),Te,q?b?e.jsx(ut,{searchResults:a??null,venues:c,outsideAreaVenues:u,crossKindVenues:y,crossKindLabel:"venues",resultNoun:{one:"service",many:"services"},searchLoading:k,searchError:M,onRetry:$,displayLocation:Me,query:h,sortBy:"relevance",effectiveSort:"relevance",canSortByDistance:!1,onSortChange:()=>{},isMobile:t,hasSearchParams:!0,activeVenueId:null,onVenueHighlight:()=>{},serializedSearchParams:o,onLoadMore:U,hasNextPage:z,isFetchingNextPage:W}):e.jsx(kt,{serviceTypes:he,selectedServiceTypes:p,serializedSearchParams:o,userCity:(l==null?void 0:l.city)??null,locationParam:X,isMobile:t,cityForApi:ke,stateForApi:Ee,searchLatForApi:g==null?void 0:g.lat,searchLngForApi:g==null?void 0:g.lng,dateForApi:Fe,textQuery:Pe,locationReady:q},X??"everywhere"):Ue]})]}),e.jsx(Et,{open:m,onOpenChange:S,initialWhen:{date:s.get("date")||void 0,start:s.get("start")||void 0,end:s.get("end")||void 0},onApply:f})]})};export{os as Services,os as default};