import{a as t}from"./rolldown-runtime-C_ttsnZz.js";import{St as e,q as i}from"./index-BT8Vuu3B.js";import{a as r,s as o}from"./index.modern-tyEdEbjo.js";import{n}from"./context-BrD4AniQ-_nW8oMsv.js";import{n as l,t as s}from"./styles-hx5_Dz4D-CjeaMkGu.js";var a=t(e(),1),u=i();function d({latitude:t,longitude:e,offset:i=[0,-25],onClose:d,children:h}){let[g,f]=(0,a.useState)(null),c=o(),{mapPadding:m,activeMarker:p,clusterPoints:w}=n(),v=(0,a.useRef)(w),b=(0,a.useRef)(p),x=(0,a.useCallback)(t=>{f(t)},[]);(0,a.useEffect)(()=>{let t=v.current!==w,e=b.current===p;t&&e&&void 0!==p&&d?.(),v.current=w,b.current=p},[w,p,d]),(0,a.useEffect)(()=>{let t,e={width:0,height:0},i=new ResizeObserver(()=>{t&&clearTimeout(t),t=window.setTimeout(()=>{(()=>{if(!c||!g||void 0===p)return;let t=c.getBounds(),i=c.getCenter(),r=c.getDiv(),o=g?.getBoundingClientRect();if(!t||!i||!o)return;let n=Math.abs(o.width-e.width),s=Math.abs(o.height-e.height);if(0!==e.width&&n<15&&s<15)return;e={width:o.width,height:o.height};let a=r.getBoundingClientRect(),u={width:r.clientWidth,height:r.clientHeight,top:a.top,left:a.left};l(o,{latitude:i.lat(),longitude:i.lng()},{left:t.getSouthWest().lng(),right:t.getNorthEast().lng(),top:t.getNorthEast().lat(),bottom:t.getSouthWest().lat()},u,m,t=>{c.panTo(new google.maps.LatLng(t.latitude,t.longitude))})})()},100)});return g&&i.observe(g),()=>{t&&clearTimeout(t),i.disconnect()}},[c,g,p,m.top,m.bottom,m.left,m.right]),(0,a.useEffect)(()=>{if(!c)return;let t=c.addListener("click",()=>{d?.()});return()=>{t.remove()}},[c]);let j=(0,a.useMemo)(()=>Array.isArray(i)?[i[0],i[1]]:[i,i],[i]);return void 0===t||void 0===e?null:(0,u.jsx)(r,{shouldFocus:!0,disableAutoPan:!0,position:{lat:t,lng:e},pixelOffset:j,children:(0,u.jsx)("div",{ref:x,className:s,children:h})})}export{d as default};
//# sourceMappingURL=Google-DScXSvYv-Bl_OXbmT.js.map