import{az as d,be as C,b2 as R,aA as S,aB as g,M as F,b3 as v,aj as T,bw as f,ax as A,e9 as M}from"./app-k0jcl5PQ.js";import{I as b}from"./s-4A5pEU.chunk.js";import{u as q}from"./CAxN5LKv.chunk.js";import{C as y}from"./_XP6hjk3.chunk.js";function E(s){return{sessionId:s.sessionId,name:s.sessionName}}function w(s){var e;const i=d(C.getAnonSessions(s));return{items:((e=i.data)==null?void 0:e.reduce((a,t)=>({...a,[t.sessionId]:E(t)}),{}))||{},hasCompleted:i.hasCompleted,isFetching:i.isFetching}}function U(s){var u,o,l,h;const i=R(),r=d(S.getShare(s)),e=((u=r.data)==null?void 0:u.type)===g.Classroom&&((h=(l=(o=r.data)==null?void 0:o.recipients)==null?void 0:l.find(c=>c.recipientTypeId===F.Classroom))==null?void 0:h.recipientId),a=c=>y.getClassroomStudents(e,c),t=v(e&&a,c=>i(a(c)));return{...t,hasCompleted:!e||t.hasCompleted}}function _(s,i,r){var o;const e=d(T.currentUser()),a=d(!!s&&f.interactiveMetadata(s)),t=d(!!((o=a.data)!=null&&o.interactiveId)&&f.interactive(a.data.interactiveId)),u=!!e.data&&!!t.data;return d(u&&b.interactiveResultSet(a.data.interactiveId,a.data.id,e.data,i,r))}const j=[{id:"0",attempts:[{id:"0",answeredAt:0,answers:[]}]}];function N(s){var c,m;const[i]=A(M.HIDE_STAFF_RESULTS),r=d(S.getShare(s)),e=_((c=r.data)==null?void 0:c.objectId,null,s),a=w(s),t=U(s);q(e);const u=e.hasCompleted&&a.hasCompleted&&t.hasCompleted;if(!u)return{data:null,hasCompleted:!1};const o=new Set,l=e.data.students.map(n=>{var p;const I=(p=n.user)==null?void 0:p.userType;return i&&I===1?null:n.user?(o.add(n.user.id),n):{...n,user:a.items[n.sessionId]||{sessionId:n.sessionId}}}).filter(n=>!!n);(m=t==null?void 0:t.items)!=null&&m.length&&l.push(...t.items.filter(n=>!o.has(n.id)).map(n=>({user:n,results:j,isPlaceholder:!0})));const h=r.isFetching||e.isFetching||a.isFetching||t.isFetching;return{hasCompleted:u,isFetching:h,data:{...e.data,students:l}}}export{U as a,N as b,w as u};
//# sourceMappingURL=Bc38NwUJ.chunk.js.map
