import{aT as E,r as f,j as e,aS as b,cw as o}from"./react-vendor-xYZnmIII.js";import{B as u}from"./ui-components-CQM92IK3.js";const T=({courseId:S,liveClass:t,zoomConfig:d})=>{var m;const{props:x}=E(),{translate:g}=x,{frontend:l}=g,[w,h]=f.useState(new Date),r=(n=>{var c;const i=w,s=new Date(n.class_date_and_time),a=(c=n.additional_info)!=null&&c.end_time?new Date(n.additional_info.end_time):new Date(s.getTime()+3600*1e3);return i>a?"ended":i>=s&&i<=a?"live":s>i?"upcoming":"scheduled"})(t);f.useEffect(()=>{const n=()=>{var _;const a=new Date;h(a);const c=(_=t.additional_info)!=null&&_.end_time?new Date(t.additional_info.end_time):new Date(new Date(t.class_date_and_time).getTime()+3600*1e3);return a>c};if(n())return;const s=setInterval(()=>{n()&&clearInterval(s)},6e4);return()=>{clearInterval(s)}},[t.class_date_and_time,(m=t.additional_info)==null?void 0:m.end_time]);const p=!!(d.zoom_web_sdk&&d.zoom_sdk_client_id&&d.zoom_sdk_client_secret),j=n=>{switch(n){case"live":return"text-green-600 bg-green-100";case"upcoming":return"text-blue-600 bg-blue-100";case"ended":return"text-muted-foreground bg-gray-100";default:return"text-orange-600 bg-orange-100"}};return e.jsxs(e.Fragment,{children:[e.jsx("span",{className:`rounded-full px-2 py-1 text-center text-xs font-medium capitalize ${j(r)}`,children:r}),r==="live"?p?e.jsx(b,{href:route("live-class.start",t.id),children:e.jsxs(u,{size:"sm",variant:r==="live"?"default":"outline",className:"flex w-full items-center gap-2",children:[e.jsx(o,{className:"h-4 w-4"}),l.join_class]})}):e.jsx("a",{href:t.additional_info.join_url,target:"_blank",children:e.jsxs(u,{size:"sm",variant:r==="live"?"default":"outline",className:"flex w-full items-center gap-2",children:[e.jsx(o,{className:"h-4 w-4"}),l.join_class]})}):e.jsxs(u,{disabled:!0,variant:"outline",size:"sm",className:"flex w-full items-center gap-2",children:[e.jsx(o,{className:"h-4 w-4"}),l.join_class]})]})};export{T as L};
