1import{r as n,j as s,I as R}from"./index-D9jIKKOn.js";import{s as A,a as C}from"./geocode-DSCffeoo.js";import{M as v}from"./map-pin-B4c6Sg0R.js";function M({value:c,onChange:d,onSelect:j,countries:u=["DE","AT","CH"],placeholder:y="Ort, PLZ oder Region",className:N="",inputClassName:E="",withIcon:k=!1}){const[o,i]=n.useState([]),[p,r]=n.useState(!1),[g,l]=n.useState(0),[D,f]=n.useState(!1),m=n.useRef(!1),x=n.useRef(null),h=n.useRef(null);n.useEffect(()=>{if(m.current){m.current=!1;return}const e=c.trim();if(e.length<2){i([]),r(!1),f(!1);return}const t=A(e,u,6);t.length>0&&(i(t),l(0),r(!0)),f(!0),h.current?.abort();const a=new AbortController;h.current=a;const $=setTimeout(async()=>{try{const w=await C(e,u,6,a.signal);if(a.signal.aborted)return;i(w),l(0),r(w.length>0)}catch{}finally{a.signal.aborted||f(!1)}},150);return()=>{clearTimeout($),a.abort()}},[c,u.join(",")]),n.useEffect(()=>{const e=t=>{x.current?.contains(t.target)||r(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);const b=e=>{m.current=!0;const t=e.postcode?`${e.postcode} ${e.name}`:e.name;d(t),j?.(e),r(!1)};return s.jsxs("div",{ref:x,className:`relative ${N}`,children:[s.jsxs("div",{className:"flex items-center gap-2",children:[k&&s.jsx(v,{className:"h-4 w-4 text-muted-foreground shrink-0"}),s.jsx(R,{value:c,onChange:e=>d(e.target.value),onFocus:()=>o.length>0&&r(!0),onKeyDown:e=>{!p||o.length===0||(e.key==="ArrowDown"?(e.preventDefault(),l(t=>(t+1)%o.length)):e.key==="ArrowUp"?(e.preventDefault(),l(t=>(t-1+o.length)%o.length)):e.key==="Enter"?(e.preventDefault(),b(o[g])):e.key==="Escape"&&r(!1))},placeholder:y,className:E,autoComplete:"off"})]}),p&&s.jsxs("div",{className:"absolute z-50 mt-1 w-full rounded-md border border-border bg-popover shadow-lg max-h-72 overflow-auto",children:[D&&o.length===0&&s.jsx("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"Sucheâ¦"}),o.map((e,t)=>s.jsxs("button",{type:"button",onMouseDown:a=>{a.preventDefault(),b(e)},onMouseEnter:()=>l(t),className:`w-full text-left px-3 py-2 text-sm flex items-start gap-2 ${t===g?"bg-accent":"hover:bg-accent/60"}`,children:[s.jsx(v,{className:"h-3.5 w-3.5 mt-0.5 text-muted-foreground shrink-0"}),s.jsxs("span",{className:"min-w-0",children:[s.jsx("span",{className:"font-medium",children:e.postcode?`${e.postcode} ${e.name}`:e.name}),s.jsx("span",{className:"block text-xs text-muted-foreground truncate",children:[e.region,e.country].filter(Boolean).join(" · ")})]})]},`${e.lat}-${e.lng}-${t}`))]})]})}export{M as P};
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.