import{b as o}from"./formatters-jmx2pV9o.js";const g=(t,e=Date.now())=>{if(!(t!=null&&t.is_active)||!(t!=null&&t.last_seen))return!1;const a=new Date(t.last_seen).getTime();if(!Number.isFinite(a))return!1;const r=Math.max(2,Number((t==null?void 0:t.offline_threshold_minutes)||5))*60*1e3;return e-a>r?!1:!!(t!=null&&t.is_online)},f=(t,e=Date.now())=>t!=null&&t.is_active?t!=null&&t.last_seen?g(t,e)?{key:"online",label:"En ligne",dot:"🟢",badgeClass:"bg-emerald-100 text-emerald-700"}:{key:"offline",label:"Hors ligne",dot:"🔴",badgeClass:"bg-red-100 text-red-700"}:{key:"never_connected",label:"Jamais connecté",dot:"🟡",badgeClass:"bg-amber-100 text-amber-700"}:{key:"disabled",label:"Désactivé",dot:"⚫",badgeClass:"bg-slate-200 text-slate-700"},m=t=>{if(!t)return"jamais";const e=new Date(t),a=new Date,i=a.getTime()-e.getTime(),r=Math.max(0,Math.floor(i/1e3));if(r<60)return`il y a ${r}s`;const s=Math.floor(r/60);if(s<60)return`il y a ${s} min`;const l=Math.floor(s/60);if(l<24&&e.getDate()===a.getDate())return`il y a ${l} h`;const n=new Date(a);return n.setDate(a.getDate()-1),e.getDate()===n.getDate()&&e.getMonth()===n.getMonth()&&e.getFullYear()===n.getFullYear()?`hier ${e.toLocaleTimeString("fr-DZ",{hour:"2-digit",minute:"2-digit"})}`:o(t)},u=t=>String(t||"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9\s.-]/g," ").trim().split(/\s+/).filter(Boolean).slice(0,3).join(".")||"",c=()=>{const t="ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz23456789";return Array.from({length:8},()=>t[Math.floor(Math.random()*t.length)]).join("")},h=t=>{const e=Number(t);return Number.isFinite(e)?e<20?{label:`${e}%`,width:`${Math.max(0,Math.min(100,e))}%`,barClass:"bg-red-500"}:e<=50?{label:`${e}%`,width:`${Math.max(0,Math.min(100,e))}%`,barClass:"bg-amber-500"}:{label:`${e}%`,width:`${Math.max(0,Math.min(100,e))}%`,barClass:"bg-emerald-500"}:{label:"—",width:"0%",barClass:"bg-slate-300"}},M=t=>{const e=String(t||"");return e==="offline"?{label:"Hors ligne",criticality:"critical",badgeClass:"bg-red-100 text-red-700",icon:"🔴"}:e==="geofence_exit"?{label:"Zone géographique",criticality:"critical",badgeClass:"bg-red-100 text-red-700",icon:"🔴"}:e==="low_battery"?{label:"Batterie faible",criticality:"warning",badgeClass:"bg-amber-100 text-amber-700",icon:"🟡"}:e==="speed"?{label:"Vitesse",criticality:"warning",badgeClass:"bg-amber-100 text-amber-700",icon:"🟡"}:e==="geofence_enter"?{label:"Zone géographique",criticality:"info",badgeClass:"bg-sky-100 text-sky-700",icon:"🔵"}:{label:e||"Alerte",criticality:"info",badgeClass:"bg-slate-100 text-slate-700",icon:"🔵"}};export{h as a,c as b,u as c,M as d,m as f,f as g,g as i};
