1import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{p as t}from"./sentry-C5mSwRLu.js";import{r as n,t as r}from"./locale-messages-Cyk8Fozq.js";import{C as i}from"./shared-runtime-BrPBoBo3.js";import{n as a,p as o}from"./queryOptions-D5n76UJu.js";import{cn as s,ln as c}from"./api-client-DlxYM9mr.js";import{t as l}from"./loader-circle-URrqod4L.js";import{t as u}from"./map-pin-DSsverxJ.js";import{t as d}from"./search-BKvBwK8E.js";import{t as f}from"./x-mbh47l0d.js";import{t as p}from"./utils-DqNhCx4L.js";import{r as m}from"./runtime-DtptkwDy.js";import{t as h}from"./input-BL4Peq-K.js";var g=(e,t={})=>(r(t.locale??m()).search_location_all1??n(`search_location_all1`))(e),_=(e,t={})=>(r(t.locale??m()).search_location_clear1??n(`search_location_clear1`))(e),v=(e,t={})=>(r(t.locale??m()).search_location_searching1??n(`search_location_searching1`))(e),y=e(t(),1),b=i(),x={sm:`sm:absolute sm:left-0 sm:right-0 sm:top-[calc(100%+6px)] sm:z-50 sm:mt-0 sm:max-h-none sm:overflow-hidden`,lg:`lg:absolute lg:left-0 lg:right-0 lg:top-[calc(100%+6px)] lg:z-50 lg:mt-0 lg:max-h-none lg:overflow-hidden`};function S({value:e,onChange:t,placeholder:n,className:r,inputClassName:i,inputId:S,inputAriaLabel:w,inputAriaLabelledBy:T,onValidityChange:E,onUnresolvedBlur:D,error:O,errorClassName:k,showSearchIcon:A=!0,searchIcon:j,clearIcon:M,overlayFrom:N=`lg`}){let P=o(),F=(0,y.useId)(),[I,L]=(0,y.useState)(e?.label??``),[R,z]=(0,y.useState)(``),[B,V]=(0,y.useState)(!1),[H,U]=(0,y.useState)(null),W=(0,y.useRef)(null),G=(0,y.useRef)(null),K=(0,y.useRef)(null),q=(0,y.useRef)(!1),J=(0,y.useRef)(0),Y=(0,y.useRef)(!1);(0,y.useEffect)(()=>{if(e?.label){Y.current=!1,L(e.label);return}if(Y.current){Y.current=!1;return}L(``)},[e?.label]),(0,y.useEffect)(()=>()=>{W.current&&clearTimeout(W.current)},[]),(0,y.useEffect)(()=>{let e=()=>{q.current=!1,V(!1)},t=t=>{if(!(t.target instanceof Node)||G.current?.contains(t.target))return;let n=K.current;if(n!==null&&![`absolute`,`fixed`].includes(getComputedStyle(n).position)&&n.compareDocumentPosition(t.target)&Node.DOCUMENT_POSITION_FOLLOWING){q.current=!0;return}e()},n=()=>{q.current&&e()};return document.addEventListener(`pointerdown`,t,{capture:!0}),document.addEventListener(`click`,n,{capture:!0}),document.addEventListener(`pointercancel`,n,{capture:!0}),()=>{document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`click`,n,{capture:!0}),document.removeEventListener(`pointercancel`,n,{capture:!0})}},[]);let X=R.trim(),{data:Z=[],isLoading:Q}=a({...c({query:{query:X,locale:m()}}),select:e=>e??[],enabled:B&&X.length>=2,staleTime:3e4}),$=e=>{J.current+=1,U(null),L(e),V(e.trim().length>=2);let n=e.trim().length>0;if(E?.(!n),W.current&&=(clearTimeout(W.current),null),!n){Y.current=!1,z(``),t(null);return}Y.current=!0,t(null),W.current=setTimeout(()=>{z(e),W.current=null},250)},ee=async e=>{let n=++J.current;U(e.id);try{let r=e.center?e:await P.fetchQuery(s({query:{id:e.id,locale:m()}}));if(n!==J.current||!r.center)return;let[i,a]=r.center,o=C(r);L(o),z(``),V(!1),t({label:o,lat:a,lng:i}),E?.(!0)}catch{n===J.current&&V(!0)}finally{U(t=>t===e.id?null:t)}};return(0,b.jsxs)(`div`,{ref:G,className:r,onBlur:t=>{let n=t.relatedTarget,r=I.trim().length>0&&I!==e?.label;!t.currentTarget.contains(n)&&r&&D?.()},children:[(0,b.jsxs)(`div`,{className:`relative`,children:[(0,b.jsxs)(`div`,{className:`relative`,children:[A&&(j?(0,b.jsx)(`span`,{className:`pointer-events-none absolute left-4 top-1/2 flex size-4 -translate-y-1/2 text-muted-foreground`,children:j}):(0,b.jsx)(d,{className:`pointer-events-none absolute left-4 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`})),(0,b.jsx)(h,{id:S,value:I,onChange:e=>$(e.target.value),onFocus:()=>{I.trim().length>=2&&(V(!0),z(I))},placeholder:n??g(),"aria-label":T?void 0:w,"aria-labelledby":T,"aria-describedby":O?F:void 0,"aria-invalid":O?!0:void 0,className:p(i,A&&`pl-10`,`pr-10`)}),I&&(0,b.jsx)(`button`,{type:`button`,"aria-label":_(),onPointerDown:e=>e.preventDefault(),onMouseDown:e=>e.preventDefault(),onClick:()=>$(``),className:`absolute right-3 top-1/2 inline-flex size-6 -translate-y-1/2 items-center justify-center rounded-full text-muted-foreground hover:bg-muted hover:text-foreground`,children:M??(0,b.jsx)(f,{className:`size-4`})})]}),B&&(Q||Z.length>0)&&(0,b.jsx)(`div`,{ref:K,"data-testid":`search-location-suggestions`,className:p(`mt-1.5 max-h-[40dvh] overflow-y-auto overscroll-y-contain rounded-2xl border border-border bg-popover shadow-xl`,x[N]),children:Q?(0,b.jsxs)(`div`,{className:`flex min-h-12 items-center gap-2 px-4 py-3 text-sm text-muted-foreground`,children:[(0,b.jsx)(l,{className:`size-4 animate-spin`}),v()]}):Z.map(e=>(0,b.jsxs)(`button`,{type:`button`,onPointerDown:e=>e.preventDefault(),onMouseDown:e=>e.preventDefault(),onClick:()=>{ee(e)},disabled:H!==null,className:`flex min-h-12 w-full items-center gap-3 px-4 py-3 text-left text-sm transition-colors hover:bg-muted/70 disabled:cursor-wait disabled:opacity-70`,children:[H===e.id?(0,b.jsx)(l,{className:`size-4 shrink-0 animate-spin text-muted-foreground`}):(0,b.jsx)(u,{className:`size-4 shrink-0 text-[var(--icon-accent-primary)]`}),(0,b.jsx)(`span`,{className:`line-clamp-2 text-foreground`,children:C(e)})]},e.id))})]}),O&&(0,b.jsx)(`p`,{id:F,role:`alert`,className:p(`mt-1 text-sm text-[var(--text-destructive)]`,k),children:O})]})}function C(e){let t=e.address;
1return e.place_name||[t?.city,t?.district,t?.country].filter(Boolean).join(`, `)||e.id}export{g as n,S as t};
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.