(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,51626,o=>{"use strict";o.s(["default",()=>d]);var e=o.i(43476),t=o.i(71645),i=o.i(34382),n=o.i(46932),l=o.i(94245),r=o.i(18566),a=o.i(69620),s=o.i(67696);let p={width:"100%",height:"500px",borderRadius:"16px"},c={lat:24.7136,lng:46.6753},d=t.default.memo(o=>{var d;let{Arabic:u,filters:g,onLocationSelect:x}=o,h=(0,l.useTranslations)("MapPage"),m=(0,r.useRouter)(),{isLoaded:b}=(0,i.useJsApiLoader)({id:"google-map-script",googleMapsApiKey:"AIzaSyA5uCMsffpxvv7inIY3x4_rcrq2c3Yjktk"}),{data:y,isLoading:j,error:C}=(0,s.useGetAllHospitals)(g),[v,w]=(0,t.useState)(null),[f,k]=(0,t.useState)(null),[S,T]=(0,t.useState)(null),M=(null==y?void 0:y.data)||[],z=(0,t.useCallback)(()=>{if(!navigator.geolocation)return void alert(h("noGeoSupport"));navigator.geolocation.getCurrentPosition(o=>{let e={lat:o.coords.latitude,lng:o.coords.longitude};k(e),null==v||v.panTo(e),null==v||v.setZoom(12),null==x||x(e)},()=>alert(h("locateError")))},[v,x,h]),A=(0,t.useCallback)(o=>{m.push("/hospital/".concat(o))},[m]);if(j)return(0,e.jsx)("p",{className:"text-center py-10 text-gray-600",children:h("loading")});if(C)return(0,e.jsx)("p",{className:"text-center py-10 text-red-500",children:h("error")});let P=b?{url:"/icons/Map Point.png",scaledSize:new google.maps.Size(32,32),anchor:new google.maps.Point(16,32)}:void 0,F=b?{url:"/icons/Map Point.png",scaledSize:new google.maps.Size(28,28),anchor:new google.maps.Point(14,28)}:void 0;return(0,e.jsx)(n.motion.div,{initial:{opacity:0,scale:.98},animate:{opacity:1,scale:1},transition:{duration:.5},style:{position:"relative"},children:b&&(0,e.jsxs)(i.GoogleMap,{mapContainerStyle:p,center:f||c,zoom:6,onLoad:o=>w(o),options:{streetViewControl:!1,mapTypeControl:!1,fullscreenControl:!1},children:[(0,e.jsx)(n.motion.button,{onClick:z,whileHover:{scale:1.05},whileTap:{scale:.95},initial:{opacity:0,y:-10},animate:{opacity:1,y:0},transition:{duration:.4},style:{position:"absolute",top:"10px",right:"10px",zIndex:1e3,background:"#2563eb",color:"white",border:"none",borderRadius:"8px",padding:"8px 12px",cursor:"pointer",fontWeight:"bold",boxShadow:"0 2px 8px rgba(0,0,0,0.2)"},children:h("locateButton")}),f&&(0,e.jsx)(i.Marker,{position:f,icon:F,title:h("yourLocation")}),M.map(o=>{let t=parseFloat(o.lat),n=parseFloat(o.lng);return isNaN(t)||isNaN(n)?null:(0,e.jsx)(i.Marker,{position:{lat:t,lng:n},icon:P,onClick:()=>T(o)},o.id)}),S&&(0,e.jsx)(i.InfoWindow,{position:{lat:parseFloat(S.lat),lng:parseFloat(S.lng)},onCloseClick:()=>T(null),children:(0,e.jsxs)("div",{style:{width:"300px"},children:[(0,e.jsx)("h3",{style:{fontSize:"1rem",fontWeight:"bold",marginBottom:"4px"},children:S.name}),(0,e.jsxs)("p",{style:{marginBottom:"4px"},children:["📍 ",(null==(d=S.city)?void 0:d.name)||"غير محدد"]}),(0,e.jsx)("p",{children:S.address||"بدون عنوان"}),S.image&&(0,e.jsx)("img",{src:S.image,alt:S.name,style:{width:"100%",height:"100px",objectFit:"cover",borderRadius:"8px",marginTop:"6px"}}),(0,e.jsx)("button",{onClick:()=>A(S.id),style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",width:"100%",padding:"8px 12px",marginTop:"12px",backgroundColor:"#2F537D",color:"white",border:"none",borderRadius:"8px",cursor:"pointer",fontWeight:"bold",transition:"background-color 0.2s"},onMouseOver:o=>o.currentTarget.style.backgroundColor="#1d4ed8",onMouseOut:o=>o.currentTarget.style.backgroundColor="#2563eb",children:(0,e.jsx)(a.IoArrowForward,{size:16})})]})})]})})})},58059,o=>{o.n(o.i(51626))}]);