import{i as e}from"./chunk-aKtaBQYM.js";import{Ft as t,t as n,vt as r}from"./mui-BgU4WrXF.js";import{l as i,t as a,u as o}from"./IconButton-oialqkv3.js";import{t as s}from"./Typography-7EcQ2i3p.js";import{t as c}from"./AppBar-BDMWinc3.js";import{V as l,o as u,pt as d,st as f,w as p,yt as m}from"./index-bel1r0Sr.js";import{t as h}from"./BackIcon-CSBDQ_HZ.js";import{t as g}from"./MapView-Bhqzv-Oc.js";import{t as _}from"./MapGeofence-B_elFORD.js";import{t as v}from"./MapPositions-DtWkadAy.js";import{t as y}from"./MapScale-BXKn6Q3F.js";import{t as b}from"./MapCamera-iXfOxITp.js";var x=e(t(),1),S=r(),C=n()(()=>({root:{height:`100%`,display:`flex`,flexDirection:`column`},toolbar:{zIndex:1},mapContainer:{flexGrow:1}})),w=()=>{let{classes:e}=C(),t=i(),n=d(),{id:r}=o(),[w,T]=(0,x.useState)(),[E,D]=(0,x.useState)(),[O,k]=(0,x.useState)(!1),A=e=>l(n,{type:e.type,attributes:{alarms:e.attributes.alarm}}),j=(0,x.useCallback)(e=>{k(!!e)},[k]);return f(async({signal:e})=>{r&&T(await(await p(`/api/events/${r}`,{signal:e})).json())},[r]),f(async({signal:e})=>{if(w&&w.positionId){let t=await(await p(`/api/positions?id=${w.positionId}`,{signal:e})).json();t.length>0&&D(t[0])}},[w]),(0,S.jsxs)(`div`,{className:e.root,children:[(0,S.jsx)(c,{color:`inherit`,position:`static`,className:e.toolbar,children:(0,S.jsxs)(m,{children:[(0,S.jsx)(a,{color:`inherit`,edge:`start`,sx:{mr:2},onClick:()=>t(`/`),children:(0,S.jsx)(h,{})}),(0,S.jsx)(s,{variant:`h6`,children:w&&A(w)})]})}),(0,S.jsxs)(`div`,{className:e.mapContainer,children:[(0,S.jsxs)(g,{children:[(0,S.jsx)(_,{}),E&&(0,S.jsx)(v,{positions:[E],onMarkerClick:j,titleField:`fixTime`})]}),(0,S.jsx)(y,{}),E&&(0,S.jsx)(b,{latitude:E.latitude,longitude:E.longitude}),E&&O&&(0,S.jsx)(u,{deviceId:E.deviceId,position:E,onClose:()=>k(!1),disableActions:!0})]})]})};export{w as default};