import{a as e}from"../../shared/js/rolldown-runtime.WmLfqUcM.js";import{d as t,n}from"./vendor-query.DdXA9l73.js";import{i as r}from"./vendor-react.C_maUxYk.js";import{Jt as i,Kt as a,Nt as o,O as s,Ut as c,Wt as l,an as u,k as d,qt as f,t as p,tn as m}from"./shared.6NMKG8zy.js";import{Ct as h,b as g}from"./vendor-date-fns.Dc-7KSd7.js";import{Ft as _,Ot as v,d as y,ht as b,t as x}from"./vendor-ui.DXm-99Gq.js";import{t as S}from"./zoom_conference.F0RBvTEO.js";import{t as C}from"./student-progress-google-meet.CiJq8bI-.js";import{t as w}from"./zoom-notice.wUbxljuj.js";var T=e(t(),1),E=`zoom_reports`,D=`this_year`,O=()=>h(g(new Date,1)),k=()=>new Date,A=()=>{let e=c(E,D,k(),O());return l(e.startDate,e.endDate)},j=r(),M=()=>(0,j.jsxs)(y,{background:`white`,children:[(0,j.jsx)(f,{children:(0,j.jsx)(a,{w:`120px`,h:`20px`})}),(0,j.jsx)(f,{children:(0,j.jsx)(a,{w:`40px`,h:`20px`})}),(0,j.jsx)(f,{children:(0,j.jsxs)(b,{align:`center`,gap:`8px`,children:[(0,j.jsx)(a,{fixedWidth:!0,w:`18px`,h:`18px`,borderRadius:`4px`}),(0,j.jsx)(a,{w:`90px`,h:`20px`})]})}),(0,j.jsx)(f,{children:(0,j.jsx)(a,{w:`50px`,h:`20px`})}),(0,j.jsx)(f,{children:(0,j.jsx)(a,{w:`50px`,h:`20px`})}),(0,j.jsx)(f,{children:(0,j.jsx)(a,{w:`80px`,h:`20px`})})]}),N=(e,t=``)=>(0,j.jsxs)(x,{color:e?`dark`:`dark50`,children:[e||0,t]}),P=()=>({mutateAsync:async()=>void 0,isLoading:!1}),F=({rows:e,total:t,page:n,perPage:r,initialDatePreset:i,allTimeStartDate:a,allTimeEndDate:c,isLoading:l,onPageChange:d,onPerPageChange:f,onDateRangeChange:m})=>{let{__:h,sprintf:g}=u(),y=(0,T.useMemo)(()=>[{label:h(`Date`),key:`date`,minWidth:`180px`,isTruncated:!0,rowRenderer:e=>(0,j.jsx)(p,{noOfLines:1,children:e.date_formatted||e.date||`—`})},{label:h(`Meetings`),key:`meetings`,width:`120px`,rowRenderer:e=>N(e.meetings)},{label:h(`Provider`),key:`provider`,width:`160px`,rowRenderer:e=>(0,j.jsxs)(b,{align:`center`,gap:`8px`,children:[(0,j.jsx)(_,{as:e.provider===`google_meet`?C:S,boxSize:`18px`}),(0,j.jsx)(x,{children:e.provider===`google_meet`?h(`Google Meet`):h(`Zoom`)})]})},{label:h(`Participants`),key:`participants`,width:`130px`,rowRenderer:e=>N(e.participants)},{label:h(`New Users`),key:`new_users`,width:`120px`,rowRenderer:e=>N(e.new_users)},{label:h(`Meeting Minutes`),key:`meeting_minutes`,width:`160px`,rowRenderer:e=>N(e.meeting_minutes,` ${h(`min`)}`)}],[h]);return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(o,{selectedItems:[],setSelectedItems:()=>void 0,getItemId:e=>e.id,totalItems:t,dataItems:e,showBulkActions:!1,bulkActions:[],useBulkAction:P,datePickerLocalStorageKey:E,datePickerDefaultPreset:i,allTimeStartDate:a,allTimeEndDate:c,onDateRangeChange:m,children:(0,j.jsx)(v,{color:`secondary`,fontSize:`sm`,alignSelf:`center`,children:g(h(`All Time is capped to the last %d years.`),1)})}),(0,j.jsx)(v,{children:(0,j.jsx)(s,{headers:y,data:e,SkeletonCells:(0,j.jsx)(M,{}),page:n,total:t,perPage:r,isLoading:l,isSelectable:!1,sort:null,onPageChange:d,onPerPageChange:f,noItemsTitle:h(`No statistics available`),noItemsSubTitle:h(`Try changing your date range`)})})]})},I=e=>{let t=m(),[r,i]=e.split(`,`);return n({queryKey:[`zoom-conference-reports`,r,i],queryFn:async()=>{try{return await t.zoomConference.getReports(r,i)}catch(e){return{items:[],summary:{meetings:0,participants:0,new_users:0,meeting_minutes:0},source_error:typeof e==`string`?e:void 0}}},keepPreviousData:!0})},L=(0,T.createContext)(null),R=({children:e})=>{let{page:t,perPage:n}=d(),[r,i]=(0,T.useState)(t||1),[a,o]=(0,T.useState)(n||20),[s,c]=(0,T.useState)(A),[l,u]=(0,T.useState)(0),f=D,p=(0,T.useMemo)(()=>O(),[]),m=(0,T.useMemo)(()=>k(),[]),h=I(s),g=h.data?.items||[],_=(0,T.useMemo)(()=>{let e=(r-1)*a;return g.slice(e,e+a)},[g,r,a]);return(0,T.useEffect)(()=>{u(g.length)},[g]),(0,j.jsx)(L.Provider,{value:{page:r,setPage:i,perPage:a,setPerPage:o,total:l,rows:_,dateRange:s,setDateRange:c,initialDatePreset:f,allTimeStartDate:p,allTimeEndDate:m,reportsQuery:h},children:e})},z=()=>{let e=(0,T.useContext)(L);if(!e)throw Error(`useZoomConferenceReportsContext must be used within ZoomConferenceReportsProvider`);return e},B=()=>{let{__:e}=u(),{page:t,setPage:n,perPage:r,setPerPage:a,total:o,rows:s,initialDatePreset:c,allTimeStartDate:d,allTimeEndDate:f,reportsQuery:p,setDateRange:m}=z();return(0,j.jsxs)(i,{title:e(`Zoom Conference Statistics`),children:[p.data?.source_error&&(0,j.jsx)(w,{tone:`error`,mx:`20px`,mb:`12px`,children:(0,j.jsx)(x,{color:`error`,fontSize:`sm`,fontWeight:`semibold`,lineHeight:`1.5`,children:p.data.source_error})}),(0,j.jsx)(F,{rows:s,total:o,page:t,perPage:r,initialDatePreset:c,allTimeStartDate:d,allTimeEndDate:f,isLoading:p.isLoading||p.isRefetching,onPageChange:n,onPerPageChange:e=>{n(1),a(e)},onDateRangeChange:(e,t)=>{n(1),m(l(e,t))}})]})},V=()=>(0,j.jsx)(R,{children:(0,j.jsx)(B,{})});export{V as default};