1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ViewFileModal-BK83w1wk.js","assets/react-vendor-DJtAp8P_.js","assets/index-DEYzTw8S.js","assets/app-DT7WuczB.js","assets/index-CyS3LFy6.js","assets/apollo-DL0KWP0Y.js","assets/mui-styles-C9F12l22.js","assets/babel-helpers-D2wBBc1I.js","assets/index-CV9OfG1C.css","assets/dayjs-CFxoC4n5.js","assets/app-Cg4Kd3Rp.css","assets/index-Qwitn9cN.css","assets/mui-DvP2hOwX.js"])))=>i.map(i=>d[i]); 2import{j as e,a as o}from"./react-vendor-DJtAp8P_.js";import{ab as zo,m as It,a4 as hn,ai as Ns,at as Rs,aj as Rn,ax as Fo,c as At,e as gn,al as Bn,a3 as Bs,V as zs,F as Ut,d as Yt,a0 as Sn,u as dt,I as xo,ao as Fs,_ as Hs,ay as $s,az as ho,ak as fo,x as Vs,D as go,o as Ws,k as Gs,g as Us,ad as cn,ac as So,z as Ys,w as qs}from"./app-DT7WuczB.js";import{T as Zs,P as Ho,I as Ks,b as tt,q as $o,B as Pn,D as zn,E as Js,s as Qs,z as Xs,w as ea}from"./swiper-react-DcF17yCe.js";import{B as Fe}from"./Button-C4goEOKP.js";import{aa as Vo,B as ta,ab as na,ac as oa,ad as sa,ae as aa,af as ia,ag as ra,ah as la,ai as ca}from"./query-CcmDMjHA.js";import{c8 as bt,bo as da,aW as Vt,bC as Fn,ck as bo,bQ as Co,bI as ua,bK as ma,bi as pa,aT as xa,bm as ha,cl as fa,bB as ga,cm as Sa,cn as ba,cj as Ca}from"./index-CyS3LFy6.js";import{au as Wo,av as ja,aw as ya,ax as va,T as _a,ay as wa,az as Ea,aA as Ia,aB as Ta,aC as Aa,aD as ka,aE as Pa,aF as Ma,ao as Da,aG as Oa,aq as La,as as Na,at as Ra,ar as Ba,ap as za}from"./mutation--iSLlBrt.js";import"./dayjs-CFxoC4n5.js";import{D as Vn}from"./DeleteModal-BX6BaNP3.js";import{M as Go}from"./Modal-BzPnYVEi.js";import{e as Fa,a as Mn,M as Ha,b as $a,i as Va}from"./index-fdBQ6KwP.js";import{T as S,u as Je,E as ee,H as Uo,M as Pt,aQ as Yo,bC as qo,by as Zo,J as mt,a8 as Wt,ao as Ft,aq as Ht,an as Tt,z as p,aU as fn,w as Ko,ag as Wa,ah as Ga,aV as Ua,ai as Ya,ar as qa,P as Za,as as Ka,b0 as Ja,au as Hn,av as Ke,at as Qa,b1 as Xa,j as Gt,a0 as Jo,ak as $t,K as ei,C as ut,aC as ti,a$ as Dn,aX as jo,aW as ni,bD as yo,bE as vo,bF as _o}from"./mui-DvP2hOwX.js";import{h as oi}from"./moment-Bj79pgB5.js";import{u as bn,c as Qo,f as Xo}from"./index.esm-CWqXbt53.js";import{M as Cn,S as si,e as ai}from"./SessionPlannerMobile-85wkJ1ZS.js";import{T as es}from"./Tabs-lVcpmzV2.js";import{T as ii}from"./ToggleButton-mhLknYBH.js";import{A as zt}from"./AlertModal-CGXcj45Q.js";import{V as ri,S as li}from"./VideoAnalysisStates-DzUIQxFV.js";import{D as ci}from"./hello-pangea-dnd-1bhs5THC.js";import{A as di}from"./AddClubSessionToTeamModal-BpGusS2T.js";import{D as ui}from"./DuplicateSessionModal-FOTI7xd1.js";import{GeneratePdfModal as mi}from"./index-BUKBONWq.js";import{M as pi}from"./ManageSessionModal-Bj6CF5E5.js";import{T as ct}from"./Search-BEYvHCFs.js";import{u as qt,n as De,e as jn}from"./apollo-DL0KWP0Y.js";import{e as xi}from"./evictPlayerCaches-DGsy6cw4.js";import{S as ts}from"./AddBlack-qFPS8CaB.js";import{b as hi,c as fi,d as gi,e as Si,f as wo}from"./sessionConstants-SlYbNrWq.js";import{r as $n}from"./reverse-DAxmyBuF.js";import{f as Eo}from"./findIndex-DCshQyVE.js";import{u as Io,s as To}from"./update-Cd1lH7gX.js";import{S as Ao}from"./Download-Bk4TTf4W.js";import{S as ko}from"./Pdf-BkIpCvcL.js";import{S as ns}from"./DeleteGray-K_LbbGcc.js";import{f as Po}from"./findKey-Gt-tDAVi.js";import{B as os}from"./index-_emSioTI.js";import{i as bi}from"./isEqual-SawseRfU.js";import{s as Ci}from"./imageOptimization-zUL1CBPb.js";import{U as ji}from"./UpgradePlanModal-Cx-12O2U.js";import{V as yi}from"./VideoPlayerModal-BgJm66DJ.js";import{D as vi}from"./DroppableWrapper-BV3SYTIO.js";import{D as _i}from"./DraggableWrapper-C7z6XFG8.js";import{A as wi}from"./AddPracticeToSessionModalGate-BB6n61YO.js";import{P as Ei}from"./PracticeCard-CxYO6tgo.js";import{s as Ii}from"./startCase-BXgY2jSl.js";import{P as Ti,s as Ai,a as dn}from"./playbackAnalytics-BS68FQAv.js";import{f as ki}from"./flatMap-DZaaYYaA.js";import{G as Pi}from"./replayQuery-CrjZRCmu.js";import{S as Mi}from"./AddToGlobalLibrary-D0Dz9Ui3.js";import{S as Mo}from"./TeamSession-D26LimVZ.js";import{S as Do}from"./Copy-Bx2E8fMZ.js";import{S as Di}from"./Manage-BcZiAr0H.js";import{S as Oi}from"./PDFGray-nAIXNVuQ.js";import{m as Li}
2from"./mapKeys-BOig4Tgf.js";import"./mui-styles-C9F12l22.js";import"./babel-helpers-D2wBBc1I.js";import"./lodash-icp7yO-G.js";import"./merge-TfBrBrIh.js";import"./_baseAssignValue-CjtYt4eh.js";import"./_baseClone-DByvJCmO.js";import"./isArrayLikeObject-CcVCHQro.js";import"./map-BI8CQ8np.js";import"./browser-B3fhYDhb.js";import"./_arrayIncludes-DFQcso6E.js";import"./_baseIndexOf-DqPIyCu4.js";import"./some-YFJAbcVi.js";import"./values-DeBIqcD0.js";import"./index-B79atc36.js";import"./_baseDifference-BHjDay7E.js";import"./omit-BaIHraq0.js";import"./index-bEsv4Yks.js";import"./mui-x-DMY3qA32.js";import"./s3FileHandler-Bp64keCt.js";import"./compact-DZdspzxW.js";import"./Filter-vdZeYdaV.js";import"./SortMenu-CjsJdGGV.js";import"./UnChecked-CFhuOM22.js";import"./PlaylistThumbnail-BQGQtBTO.js";import"./isNil-R7kYXCYw.js";import"./sessionSections-a-lprBoU.js";import"./omitBy-CVfI2Mdq.js";import"./_basePickBy-jHhPNsuZ.js";import"./cloneDeep-mVQ3twB2.js";import"./index-DJ6G58M6.js";import"./UploadModal-DPGYHwV1.js";import"./replayMutation-DqoP36SS.js";import"./VideoGrid-C9V1_kLD.js";import"./ArrowLeft-Da6iFsoD.js";import"./FileSaver.min-CVXvx7px.js";import"./switch-DVTTALDv.js";import"./imageUrl-gCnBcCAn.js";import"./ArrowRightUp-CfAFwt7J.js";import"./Graphic-BzX0DM42.js";import"./seededSessionFill-BljGszd4.js";import"./popover-DQmY_bgT.js";import"./index-C53T7JDS.js";import"./floating-ui.dom-CpqR1Q5s.js";import"./index-CrwW5ro-.js";import"./subMonths-CpZP7vPB.js";import"./chevron-left-hHkvU2-n.js";import"./chevron-right-Bx281FLM.js";import"./index-CvVUxn0l.js";import"./check-njpSxvzl.js";import"./index-Cor9x_UP.js";import"./checkbox-BCFY1QRf.js";import"./input-CuTRSUQZ.js";import"./editable-input-BbmoAFqJ.js";import"./chevron-down-D9vZfud1.js";import"./label-DlgL8a7V.js";import"./plus-jTnJ9Ylg.js";import"./arrow-right-CPcr9UUY.js";import"./funnel-CHKnj2yC.js";import"./Checkbox-BfyNlPRU.js";import"./TextareaAutosize-t2TCv3sg.js";try{let n=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},s=new n.Error().stack;s&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[s]="8eb111d0-233a-4db0-a1ca-05056ef7f268",n._sentryDebugIdIdentifier="sentry-dbid-8eb111d0-233a-4db0-a1ca-05056ef7f268")}catch{}const un={description:{fontSize:"16px",lineHeight:"24px",color:"text.primary"},emphasis:{fontWeight:700}},Ni=({open:n,handleClose:s,handleConfirm:_,practiceTypeId:c,tabTitle:m,practiceName:l})=>{const O=Fa(c);return e.jsx(Go,{open:n,title:"Practice type mismatch",handleClose:s,actionHandler:_,actionBtnTitle:"Add anyway",children:e.jsxs(S,{sx:un.description,children:[l?e.jsxs(e.Fragment,{children:[e.jsx(S,{component:"span",sx:un.emphasis,children:l})," ","is a"," "]}):e.jsx(e.Fragment,{children:"This practice is a "}),e.jsx(S,{component:"span",sx:un.emphasis,children:O||"different type"})," ","practice, but you're adding it to the"," ",e.jsx(S,{component:"span",sx:un.emphasis,children:m})," ","section. Add anyway?"]})})},mn={paper:{borderRadius:"4px","& .MuiList-root":{p:0}},menuItem:{height:"56px",padding:"22px 24px","&:hover":{backgroundColor:n=>n.chip.draw.backgroundColor}},selectField:{borderRadius:"8px",height:"55px",border:n=>`1px solid ${n.border}`,display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"white","&:hover":{border:n=>`1px solid ${n.palette.primary.main}`}}},Ri=({disabled:n=!1,value:s,options:_=[],optionKey:c="name",tooltipOptionKey:m="name",name:l="",onChange:O=()=>{}})=>{const[_e,g]=o.useState(null),L=_.find(I=>I.id===s);Je(I=>I.breakpoints.down("md"));const te=I=>{I.stopPropagation(),g(null)},je=I=>{O({target:{name:l,value:I.id}})};return e.jsxs(e.Fragment,{children:[e.jsx(Zs,{data:[{name:(L==null?void 0:L[m])||""}],children:e.jsx(ee,{sx:mn.selectField,onClick:I=>{I.stopPropagation(),n||g(I.currentTarget)},children:e.jsx(S,{color:"text.primary",children:(L==null?void 0:L[c])||""})})}),e.jsx(Uo,{anchorEl:_e,onClose:te,open:!!_e,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},slotProps:{paper:{sx:{...mn.paper}}},children:_.map(I=>e.jsx(Pt,{onClick:ne=>{ne.stopPropagation(),je(I),te(ne)},divider:!0,sx:mn.menuItem,selected:s===I.id,children:e.jsx(S,{sx:{...mn.textEllipsis,paddingLeft:"0px"},children:I[c]})},I.id))})]})},Bi=({isExpanded:n,cardCursorPointer:s})=>({container:{height:n?"100%":"unset",position:"relative"},card:{width:"100%",borderRadius:"16px",backgroundColor:"common.white",border:_=>`1px solid ${_.palette.divider}`,"&:hover":{cursor:s?"pointer":"unset","& .hoverBorderColor":{borderColor:_=>_.palette.primary.main}}},cardContent:{padding:0,height:"100%","&:last-child":{paddingBottom:0}},avatarContainer:{width:"96px",height:"96px",top:0,left:"50%",position:"absolute",boxShadow:"none",borderRadius:"50%",transform:"translate(-50%, -50%)",backgroundColor:_=>_.palette.common.white},avatar:{zIndex:1e3,width:"96px",height:"96px",position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)"},textPrimary:{fontWeight:600,lineHeight:"24px",textAlign:"center",color:"text.primary",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},accordion:{width:"100%",boxShadow:"none",position:"unset","& .MuiAccordionSummary-root":{"& .MuiAccordionSummary-content":{my:"4px"}}},accordionSummary:{"& .MuiAccordionSummary-expandIconWrapper":{order:-1,marginRight:"8px"}}
2,btnSelect:{width:"100%",height:"55px",padding:"0px 5px",fontSize:"14px",fontWeight:"400",lineHeight:"22px",color:"text.primary",justifyContent:"space-between",backgroundColor:"white",border:_=>`1px solid ${_.border}`,"&:hover":{backgroundColor:"white"}},performance:{height:"20px",width:"20px",borderRadius:"50%"},textFieldLabel:{fontSize:"12px",textAlign:"center",color:"text.secondary",paddingBottom:"8px"},targetMet:{borderRadius:"8px",height:"55px",border:_=>`1px solid ${_.border}`,display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"white"},availability:{position:"absolute",top:10,right:10},notAvailable:{borderRadius:"8px",height:"55px",border:_=>`1px solid ${_.border}`,display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"white"},objectiveTextField:{color:"text.secondary",fontSize:"14px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},objectiveTextFieldContainer:{borderRadius:"8px",height:"24px",border:_=>`1px solid ${_.border}`,padding:"8px 14px",backgroundColor:"white"},selectCustomStyle:{"& .MuiSelect-select":{textAlign:"center",paddingRight:"14px !important"}},performanceSelect:{height:"56px",minWidth:"65px","& .MuiSelect-icon":{display:"none"},"& .MuiSelect-select":{textAlign:"center"},"& .MuiSelect-outlined":{padding:"16.5px 0px !important"}}}),On={tooltip:{sx:{maxWidth:350,backgroundColor:"#1A2027",borderRadius:"10px",px:1.5,py:1}},arrow:{sx:{color:"#1A2027"}}},Oo=[{id:2,name:"Targets in Progress"},{id:1,name:"Targets Met"},{id:0,name:"Targets not Met"},{id:-1,name:"No Targets"}],zi=({canManage:n=!0,players:s=[],sessionId:_,playerId:c,player:m,positionsList:l,isExpandedAccordion:O,setIsExpandedAccordion:_e,handleOpenObjectiveModal:g,handleUpdatePlayerData:L,handleInputChange:te=()=>{},handleViewSession:je=()=>{},handleUpdateAvailability:I=()=>{}})=>{var me,ae;const ne=qt(),f=Bi({isExpanded:O,cardCursorPointer:!n}),[de,X]=o.useState([]),[M]=De(Wo),w=bn({initialValues:{...m,performance:m!=null&&m.performance?Math.round(m==null?void 0:m.performance):0,punctual:m==null?void 0:m.punctual,minutes:(m==null?void 0:m.minutes)||0,attended:m.attended},enableReinitialize:!0,validationSchema:Qo({performance:Xo().min(1,"Performance must be at least 1").max(10,"Performance must be at most 10")})}),he=Oo[Oo.findIndex(A=>A.id===w.values.objectivesMet)||0],b=async()=>{const{data:A}=await ne.query({query:Vo,variables:{session_id:_,player_id:c},fetchPolicy:"no-cache"}),{data:oe}=A.sessionPlayerObjectives;if(oe){const B=JSON.parse(oe),ie=B.map(z=>({id:z.id,sessionId:z.sessionId,objectiveId:z.objectiveId,name:z==null?void 0:z.player_objective.title,description:z==null?void 0:z.player_objective.description,score:z.score?z.score:7,feedback:z.feedback?z.feedback:""}));X(ie);const Se=B.map(z=>({...z,performance:z.score}));te({target:{name:"objectives",value:Se}},c);const j=B.map(({id:z,score:i,objectiveId:h})=>({id:z,score:i,objectiveId:h}));te({target:{name:"objectivesScore",value:j}},c)}};o.useEffect(()=>{O&&b()},[O]);const T=async(A,oe)=>{var h;const{value:B}=A.target,ie=de.map(t=>t.id===oe?{...t,score:+B}:t),Se=ie.map(({id:t,score:F,objectiveId:E})=>({id:t,score:F,objectiveId:E}));te({target:{name:"objectivesScore",value:Se}},c),X(ie);const j=ie.find(t=>t.id===oe),z=await M({variables:{id:j.id,feedback:(j==null?void 0:j.feedback)||"",score:j.score===null?7:+j.score}}),{success:i}=(h=z==null?void 0:z.data)==null?void 0:h.updateSessionPlayerObjective;if(i){const t=Fo(ie);te({target:{name:"objectivesMet",value:t}},c);const E=ie.reduce((v,ke)=>v+ +ke.score,0)/ie.length;q({target:{name:"performance",value:Math.round(E)}})}},le=o.useCallback(zo(A=>{const{target:{value:oe,name:B}}=A,ie=!It(w.errors);if(B==="minutes"){const Se={target:{name:B,value:oe?parseInt(oe):0}};te(Se,c),L(Se,c,ie)}else if(B==="performance"){const Se=oe,j={target:{name:B,value:Se}};w.setFieldValue(B,Se),te(j,c),L(j,c,ie)}else te(A,c),L(A,c,ie)},1e3),[w.errors,s]),q=A=>{w.handleChange(A),le(A)},C=()=>e.jsx(ee,{sx:f.notAvailable,children:e.jsx(S,{sx:{color:"rgba(0, 0, 0, 0.26)"},fontSize:14,children:"N/A"})}),R=()=>w.values.availability===2||w.values.availability===4,D=((me=m==null?void 0:m.objectivesScore)==null?void 0:me.length)||de.length||0,we=e.jsxs(ee,{sx:{display:"flex",flexDirection:"column",gap:.75,py:.25}
2,children:[w.values.performance>0&&e.jsxs(ee,{sx:{display:"flex",alignItems:"center",gap:.75},children:[e.jsx(Yo,{sx:{fontSize:16,flexShrink:0,color:"#FFD54F"}}),e.jsxs(S,{sx:{fontSize:"13px",lineHeight:1.4},children:["Performance: ",w.values.performance,"/10"]})]}),D>0&&e.jsxs(ee,{sx:{display:"flex",alignItems:"center",gap:.75},children:[e.jsx(qo,{sx:{fontSize:16,flexShrink:0,color:"#81C784"}}),e.jsxs(S,{sx:{fontSize:"13px",lineHeight:1.4},children:["Objectives: ",D," Set"]})]}),w.values.minutes>0&&e.jsxs(ee,{sx:{display:"flex",alignItems:"center",gap:.75},children:[e.jsx(Zo,{sx:{fontSize:16,flexShrink:0,color:"#90CAF9"}}),e.jsxs(S,{sx:{fontSize:"13px",lineHeight:1.4},children:["Training Time: ",w.values.minutes," Minutes"]})]})]}),N=w.values.performance>0||D>0||w.values.minutes>0;return e.jsx(e.Fragment,{children:e.jsx(mt,{title:N?we:"",arrow:!0,placement:"top",enterDelay:400,slotProps:On,children:e.jsxs(ee,{sx:f.container,children:[e.jsx(ee,{sx:f.availability,children:e.jsx(Ho,{value:w.values.availability,playerId:c,handleUpdateAvailability:I,disabled:!n})}),e.jsx(ee,{sx:f.avatarContainer,children:e.jsx(Wt,{sx:f.avatar,alt:m.name,children:e.jsx(S,{children:hn(m.name)})})}),e.jsx(Ft,{sx:f.card,elevation:0,p:0,onClick:je,children:e.jsxs(Ht,{sx:f.cardContent,children:[e.jsx(Tt,{container:!0,direction:"column",justifyContent:"center",pt:8,gap:2,children:e.jsx(p,{children:e.jsxs(Tt,{container:!0,direction:"column",gap:3,px:2,pb:"30px",alignItems:"center",children:[e.jsxs(p,{container:!0,justifyContent:"center",gap:1,flexWrap:"nowrap",children:[e.jsx(S,{sx:f.textPrimary,children:m.name}),l.length>0&&e.jsx(Ks,{label:Ns(l,m.position),colorType:"blue"})]}),e.jsxs(p,{container:!0,justifyContent:"center",gap:2,flexWrap:"nowrap",width:"100%",children:[e.jsxs(p,{size:4,children:[e.jsx(S,{sx:f.textFieldLabel,children:"Attendance"}),w.values.attended===0||R()?e.jsx(C,{}):e.jsx(Ri,{name:"attended",optionKey:"shortName",value:w.values.attended,options:bt.ATTENDANCE,disabled:!n,onChange:q})]}),e.jsxs(p,{size:4,children:[e.jsx(S,{sx:f.textFieldLabel,children:"Punctual"}),w.values.punctual===0||R()?e.jsx(C,{}):e.jsx(tt,{name:"punctual",options:bt.PUNCTUAL,value:w.values.punctual,onChange:q,isShowClearable:!1,disabled:!n,showDropdownIcon:!1,customStyle:f.selectCustomStyle})]}),e.jsxs(p,{size:4,children:[e.jsx(S,{sx:f.textFieldLabel,children:"Fitness"}),e.jsx(tt,{name:"fitness",options:bt.FITNESS,value:w.values.fitness,onChange:q,isShowClearable:!1,disabled:!n||R(),showDropdownIcon:!1,customStyle:f.selectCustomStyle})]})]}),e.jsxs(p,{container:!0,justifyContent:"center",gap:2,flexWrap:"nowrap",width:"100%",children:[e.jsxs(p,{size:4,children:[e.jsx(S,{sx:f.textFieldLabel,children:"Minutes"}),e.jsx(tt,{useNullishCoalescing:!0,name:"minutes",disabled:!n||R(),isShowClearable:!1,onClick:A=>A.stopPropagation(),onChange:q,value:w.values.minutes,customStyle:f.performanceSelect,options:$o(200,!1,!0,"number")})]}),e.jsxs(p,{size:4,children:[e.jsx(S,{sx:f.textFieldLabel,children:"Performance"}),R()?e.jsx(C,{}):e.jsx(tt,{useNullishCoalescing:!0,name:"performance",disabled:!n,isShowClearable:!1,onChange:q,value:w.values.performance,error:!!w.errors.performance,helperText:w.errors.performance,customStyle:f.performanceSelect,options:[{id:0,name:"0"},{id:1,name:"1"},{id:2,name:"2"},{id:3,name:"3"},{id:4,name:"4"},{id:5,name:"5"},{id:6,name:"6"},{id:7,name:"7"},{id:8,name:"8"},{id:9,name:"9"},{id:10,name:"10"}]})]}),e.jsxs(p,{size:4,children:[e.jsx(S,{sx:f.textFieldLabel,children:"Targets Met"}),e.jsx(mt,{title:(he==null?void 0:he.name)||"",arrow:!0,enterDelay:300,slotProps:On,children:e.jsx(ee,{sx:f.targetMet,children:e.jsx(fn,{fontSize:"small",sx:{color:A=>Rs(A,w.values.objectivesMet)}})})})]})]})]})})}),e.jsx(Ko,{}),e.jsx(Tt,{container:!0,direction:"column",p:1,children:e.jsxs(Wa,{disableGutters:!0,sx:f.accordion,expanded:O,onChange:(A,oe)=>{A.stopPropagation(),_e(oe)},children:[e.jsx(Ga,{expandIcon:e.jsx(Ua,{}),sx:f.accordionSummary,children:e.jsxs(p,{container:!0,gap:1,alignItems:"center",width:"100%",children:[e.jsx(p,{flex:1,children:e.jsxs(p,{container:!0,gap:1,alignItems:"center",children:[e.jsx(S,{sx:f.accordionHeading,children:"Objectives"}),(ae=m==null?void 0:m.objectivesScore)==null?void 0:ae.slice(0,3).map((A,oe)=>e.jsx(fn,{fontSize:"small",sx:{color:B=>Rn(B.performance,A.score)}},oe))]})}),n&&e.jsx(S,{sx:{color:"primary.main",fontSize:"14px",cursor:"pointer"},onClick:A=>{A.stopPropagation(),g(c),b()},children:"Manage"})]})}),e.jsx(Ya,{children:O&&e.jsxs(p,{container:!0,gap:2,children:[[...de.slice(0,3),...Array(Math.max(3-de.length,0)).fill({})].map((A,oe)=>It(A)?null:e.jsx(p,{size:12,children:e.jsxs(p,{container:!0,gap:2,alignItems:"center",children:[e.jsx(p,{width:"calc(100% - 86px)",children:e.jsx(mt,{title:(A==null?void 0:A.name)||"",arrow:!0,enterDelay:300,slotProps:On,children:e.jsx(ee,{sx:f.objectiveTextFieldContainer,children:e.jsx(S,{sx:f.objectiveTextField,children:(A==null?void 0:A.name)||""})})})}
2),e.jsx(p,{children:e.jsx(tt,{size:"small",isShowClearable:!1,customStyle:{minWidth:"70px"},options:[{id:1,name:"1"},{id:2,name:"2"},{id:3,name:"3"},{id:4,name:"4"},{id:5,name:"5"},{id:6,name:"6"},{id:7,name:"7"},{id:8,name:"8"},{id:9,name:"9"},{id:10,name:"10"}],value:(A==null?void 0:A.score)||"",name:"score",disabled:A&&Object.keys(A).length===0||!n,onChange:B=>T(B,A.id)})})]})},oe)),e.jsx(p,{size:12,children:e.jsx(ct,{multiline:!0,rows:4,disabled:!n,value:w.values.comment,handleChange:A=>{w.setFieldValue("comment",A.target.value,!1),le(A)},name:"comment",label:"General Feedback",customStyle:{backgroundColor:"#fff"}})})]})})]})})]})})]})})})},Fi=({playerId:n="",players:s,session:_,canManage:c,positionsList:m=[],toggleAccordion:l,expandedAccordions:O,handleInputChange:_e,handleOpenObjectiveModal:g,handleUpdatePlayerData:L,handleViewSession:te=()=>{},handleUpdateAvailability:je=()=>{},isOpenManageDrawer:I})=>{const ne=o.useRef(null),[f,de]=o.useState(1),X=M=>{const w=Math.max(1,M||1);return Math.max(1,Math.floor(12/w))};return o.useEffect(()=>{var M,w;if((M=ne==null?void 0:ne.current)!=null&&M.offsetWidth){const he=Math.floor(((w=ne==null?void 0:ne.current)==null?void 0:w.offsetWidth)/300);de(X(he))}},[ne==null?void 0:ne.current,I]),e.jsx(e.Fragment,{children:e.jsx(p,{container:!0,spacing:3,p:3,ref:ne,children:s==null?void 0:s.map((M,w)=>e.jsx(p,{mt:6,size:{xs:I?f:12,sm:I?f:6,lg:I?f:4,xl:I?f:3},children:e.jsx(zi,{sessionId:(_==null?void 0:_.id)||(M==null?void 0:M.id),playerId:M.playerId||n,player:M,canManage:c,positionsList:m,isExpandedAccordion:!!O[M.playerId||M.id],setIsExpandedAccordion:()=>l(M.playerId||M.id),handleInputChange:_e,handleUpdatePlayerData:L,handleOpenObjectiveModal:g,handleViewSession:()=>te(s[w].id),handleUpdateAvailability:je,players:s})},M.playerId||M.id||w))},f)})},Hi=n=>o.createElement("svg",{width:60,height:60,viewBox:"0 0 60 60",fill:"none",xmlns:"http://www.w3.org/2000/svg",...n},o.createElement("g",{clipPath:"url(#clip0_26632_372232)"},o.createElement("path",{d:"M55.2117 49.8896L51.9929 46.657C51.0082 45.668 50.6553 44.2474 50.2796 42.7411C49.8669 41.0805 49.3974 39.1998 47.9686 37.765C47.9686 37.765 39.1493 28.8959 39.1179 28.8674C38.4748 28.2214 37.6181 27.8641 36.7017 27.8641C35.7882 27.8641 34.9287 28.2186 34.2855 28.8674C33.8557 29.299 33.5654 29.8192 33.4118 30.3708C33.1727 30.3194 32.9251 30.2908 32.6747 30.2908C31.8692 30.2908 31.1066 30.568 30.4975 31.0739V26.395C30.9984 26.275 31.3683 25.8234 31.3683 25.2832C31.3683 24.743 30.9955 24.2942 30.4975 24.1714L30.5003 22.9966C30.5003 21.1045 28.9692 19.5667 27.0852 19.5667H25.9154C25.7959 19.0637 25.3462 18.6921 24.8084 18.6921C24.2705 18.6921 23.8236 19.0666 23.7013 19.5667H8.87123C6.98722 19.5667 5.45605 21.1045 5.45605 22.9966V41.2893C5.45605 43.1814 6.98722 44.7192 8.87123 44.7192H20.9866C21.0265 45.3051 21.2684 45.9397 21.5188 46.497C23.1667 50.1527 28.5086 57.0921 33.6088 57.0921C33.7283 57.0921 33.8478 57.0893 33.9702 57.0807C34.5138 57.0464 35.1855 56.9206 35.9624 56.7777C37.6074 56.4748 40.3566 55.9688 41.1364 56.752L44.7594 60.3906C44.9785 60.6135 45.2688 60.725 45.562 60.725C45.8523 60.725 46.1454 60.6135 46.3674 60.3906L55.213 51.5069C55.4265 51.2925 55.546 51.001 55.546 50.698C55.546 50.395 55.4265 50.1035 55.213 49.8891L55.2117 49.8896ZM7.73218 41.2891V22.9965C7.73218 22.3648 8.24161 21.8532 8.87057 21.8532H27.0849C27.7138 21.8532 28.2233 22.3648 28.2233 22.9965V33.7548C27.785 33.9234 27.3837 34.1806 27.0422 34.5236C26.7633 34.8037 26.5384 35.1239 26.3762 35.4697L18.9936 28.0553C18.3504 27.4094 17.4938 27.0521 16.5774 27.0521C15.6638 27.0521 14.8043 27.4065 14.1611 28.0525C13.5179 28.6984 13.1622 29.5588 13.1622 30.4791C13.1622 31.3966 13.5151 32.2598 14.1583 32.9029C14.2294 32.9744 21.1793 39.9885 23.0148 41.7975L22.3858 42.4321H8.87011C8.24115 42.4321 7.73218 41.9208 7.73218 41.2891ZM45.5611 57.964L42.7435 55.1344C41.9239 54.3112 40.7314 54.0482 39.4336 54.0482C38.1586 54.0482 36.7812 54.3026 35.5517 54.5284C34.8744 54.6542 34.234 54.7714 33.8214 54.7971C32.3443 54.8914 30.5258 53.991 28.5563 52.1818C25.6249 49.4893 23.573 45.8994 23.2883 44.7616L24.4865 43.5583C25.8013 45.4047 26.7974 47.5398 26.7177 48.1601C26.6153 48.7831 27.0336 49.3719 27.6541 49.4777C28.2745 49.5806 28.8608 49.160
25 28.9661 48.5373C29.3275 46.365 26.362 41.8891 24.6232 40.1739C22.8103 38.3847 15.849 31.362 15.7747 31.2873C15.5612 31.073 15.4445 30.7871 15.4445 30.4784C15.4445 30.1726 15.5612 29.8839 15.7747 29.6695C15.9881 29.4551 16.2727 29.338 16.5801 29.338C16.8846 29.338 17.1721 29.4552 17.3855 29.6695L27.0449 39.3705C27.4889 39.8164 28.209 39.8164 28.6557 39.3705C28.8777 39.1476 28.9887 38.856 28.9887 38.5616C28.9887 38.2701 28.8777 37.9757 28.6557 37.7527C28.4423 37.5383 28.3256 37.2525 28.3256 36.9438C28.3256 36.638 28.4423 36.3493 28.6557 36.1349C28.8692 35.9205 29.1538 35.8033 29.4612 35.8033C29.7657 35.8033 30.0531 35.9205 30.2666 36.1349C30.7106 36.5808 31.4306 36.5808 31.8774 36.1349C32.0994 35.9119 32.2104 35.6204 32.2104 35.326C32.2104 35.0344 32.0994 34.74 31.8774 34.5171C31.4334 34.0712 31.4334 33.3452 31.8774 32.8993C32.0909 32.685 32.3754 32.5678 32.6828 32.5678C32.9874 32.5678 33.2748 32.685 33.4883 32.8993L34.2937 33.7083C34.7377 34.1541 35.4577 34.1541 35.9045 33.7083C36.1265 33.4853 36.2375 33.1938 36.2375 32.8993C36.2375 32.6078 36.1265 32.3134 35.9045 32.0904C35.4605 31.6446 35.4605 30.9185 35.9045 30.4727C36.118 30.2583 36.4025 30.1412 36.7099 30.1412C36.986 30.1412 37.245 30.2383 37.4499 30.4127C37.4698 30.4356 46.3632 39.3703 46.3632 39.3703C47.348 40.3592 47.7008 41.7798 48.0765 43.2861C48.4892 44.9467 48.9588 46.8274 50.3875 48.2623L52.8037 50.6889L45.5611 57.964Z",fill:"currentColor"}),o.createElement("path",{d:"M31.6379 13.8503C31.6379 14.4819 32.1474 14.9936 32.7763 14.9936H35.0531V17.2801C35.0531 17.9118 35.5626 18.4234 36.1915 18.4234C36.8205 18.4234 37.3299 17.9118 37.3299 17.2801V14.9936H39.6067C40.2357 14.9936 40.7451 14.4819 40.7451 13.8503C40.7451 13.2186 40.2357 12.707 39.6067 12.707H37.3299V10.4204C37.3299 9.78872 36.8205 9.2771 36.1915 9.2771C35.5626 9.2771 35.0531 9.78872 35.0531 10.4204V12.707H32.7763C32.1474 12.707 31.6379 13.2186 31.6379 13.8503Z",fill:"currentColor"}),o.createElement("path",{d:"M45.4698 26.421C45.4983 26.421 45.5268 26.421 45.5552 26.4182C46.409 26.3524 47.203 25.9694 47.7893 25.3406C48.2191 24.8804 48.1963 24.1573 47.7352 23.7257C47.277 23.2941 46.557 23.317 46.1273 23.78C45.9309 23.9915 45.6662 24.1201 45.3845 24.1401C44.7584 24.1887 44.2888 24.7375 44.3343 25.3663C44.3799 25.9637 44.8779 26.421 45.4698 26.421Z",fill:"currentColor"}),o.createElement("path",{d:"M45.7518 3.65534C46.0108 3.76966 46.2271 3.98403 46.3409 4.24699C46.5288 4.67286 46.9443 4.92725 47.3826 4.92725C47.5363 4.92725 47.6928 4.89581 47.8436 4.82721C48.4185 4.56997 48.6775 3.89545 48.4214 3.31806C48.0741 2.53206 47.4509 1.90894 46.6683 1.56314C46.0934 1.30875 45.4218 1.57171 45.1684 2.14907C44.9151 2.72643 45.1769 3.40092 45.7518 3.65534Z",fill:"currentColor"}),o.createElement("path",{d:"M39.8293 24.1401C39.2003 24.1401 38.6909 24.6518 38.6909 25.2834C38.6909 25.9151 39.2003 26.4267 39.8293 26.4267H41.5227C42.1516 26.4267 42.6611 25.9151 42.6611 25.2834C42.6611 24.6518 42.1516 24.1401 41.5227 24.1401H39.8293Z",fill:"currentColor"}),o.createElement("path",{d:"M48.7143 13.385C48.7143 12.7533 48.2049 12.2417 47.5759 12.2417C46.9469 12.2417 46.4375 12.7533 46.4375 13.385V15.0856C46.4375 15.7173 46.9469 16.2289 47.5759 16.2289C48.2049 16.2289 48.7143 15.7173 48.7143 15.0856V13.385Z",fill:"currentColor"}),o.createElement("path",{d:"M47.5764 17.906C46.9474 17.906 46.438 18.4176 46.438 19.0493V20.7499C46.438 21.3816 46.9474 21.8932 47.5764 21.8932C48.2053 21.8932 48.7148 21.3816 48.7148 20.7499V19.0493C48.7148 18.4205 48.2053 17.906 47.5764 17.906Z",fill:"currentColor"}),o.createElement("path",{d:"M48.7143 7.71995C48.7143 7.08828 48.2049 6.57666 47.5759 6.57666C46.9469 6.57666 46.4375 7.08828 46.4375 7.71995V9.42059C46.4375 10.0523 46.9469 10.5639 47.5759 10.5639C48.2049 10.5639 48.7143 10.0523 48.7143 9.42059V7.71995Z",fill:"currentColor"}),o.createElement("path",{d:"M40.5974 3.561H42.2907C42.9197 3.561 43.4291 3.04938 43.4291 2.41771C43.4291 1.78604 42.9197 1.27441 42.2907 1.27441H40.5974C39.9684 1.27441 39.459 1.78604 39.459 2.41771C39.459 3.04938 39.9684 3.561 40.5974 3.561Z",fill:"currentColor"}),o.createElement("path",{d:"M24.8083 11.3472C25.4373 11.3472 25.9467 10.8355 25.9467 10.2039V8.50609C25.9467 7.87442 25.4373 7.36279 24.8083 7.36279C24.1794 7.36279 23.6699 7.87442 23.6699 8.50609V10.2067C23.6699 10.8355 24.1794 11.3472 24.8083 11.3472Z",fill:"currentColor"}),o.createElement("path",{d:"M34.9568 3.561H36.6501C37.2791 3.561 37.7885 3.04938 37.7885 2.41771C37.7885 1.78604 37.2791 1.27441 36.6501 1.27441H34.9568C34.3278 1.27441 33.8184 1.78604 33.8184 2.41771C33.8184 3.04938 34.3278 3.561 34.9568 3.561Z",fill:"currentColor"}),o.createElement("path",{d:"M24.8083 17.012C25.4373 17.012 25.9467 16.5003 25.9467 15.8687V14.1709C25.9467 13.5392 25.4373 13.0276 24.8083 13.0276C24.1794 13.0276 23.6699 13.5392 23.6699 14.1709V15.8715C23.6699 16.5003 24.1794 17.012 24.8083 17.012Z",fill:"currentColor"}),o.createElement("path",{d:"M24.7313 5.67937C24.7597 5.68223 24.7882 5.68223 24.8138 5.68223C25.4057 5.68223 25.9038 5.22205 25.9493 4.62184C25.9693 4.33887 26.0973 4.07306 26.3079 3.87301C26.7661 3.43856 26.7861 2.71545 26.3563 2.25813C25.9237 1.79795 25.2037 1.77795 24.7484 2.20954C24.1222 2.80119 23.7437 3.60147 23.6811 4.4561C23.6328 5.08777 24.1051 5.63364 24.7313 5.67937Z",fill:"currentColor"}),o.createElement("path",{d:"M29.3132 3.561H31.0065C31.6355 3.561 32.1449 3.04938 32.1449 2.41771C32.1449 1.78604 31.6355 1.27441 31.0065 1.27441H29.3132C28.6842 1.27441 28.1748 1.78604 28.1748 2.41771C28.1748 3.04938 28.6871 3.561 29.3132 3.561Z",fill:"currentColor"}),o.createElement("path",{d:"M35.882 24.1401H34.1887C33.5597 24.1401 33.0503 24.6518 33.0503 25.2834C33.0503 25.9
2151 33.5597 26.4267 34.1887 26.4267H35.882C36.511 26.4267 37.0204 25.9151 37.0204 25.2834C37.0204 24.6518 36.511 24.1401 35.882 24.1401Z",fill:"currentColor"})),o.createElement("defs",null,o.createElement("clipPath",{id:"clip0_26632_372232"},o.createElement("rect",{width:60,height:60,fill:"white"})))),pn=n=>o.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...n},o.createElement("path",{d:"M8.70956 11.71L11.2996 14.3C11.6896 14.69 12.3196 14.69 12.7096 14.3L15.2996 11.71C15.9296 11.08 15.4796 10 14.5896 10H9.40956C8.51956 10 8.07956 11.08 8.70956 11.71Z",fill:"#212B36"})),$i=n=>o.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...n},o.createElement("rect",{width:24,height:24,rx:12,fill:"#637381"}),o.createElement("path",{d:"M19 13H5C4.44772 13 4 12.5523 4 12C4 11.4477 4.44772 11 5 11H19C19.5523 11 20 11.4477 20 12C20 12.5523 19.5523 13 19 13Z",fill:"white"})),ze={paper:{overflow:"auto",boxShadow:"none",maxHeight:{xs:"unset",lg:"750px"},width:"100%"},headerCellLabel:{width:"100%",whiteSpace:"nowrap",justifyContent:"space-between","&.MuiButtonBase-root":{color:"text.secondary"}},headerTableCell:{py:0,backgroundColor:n=>n.backgroundColor.body,color:"text.secondary",fontWeight:600,fontSize:"13px",lineHeight:"24px",padding:"16px"},avatar:{height:"40px",width:"40px",fontSize:"14px"},heading:{fontSize:"15px",fontWeight:600,lineHeight:"24px"},text:{fontSize:"14px",lineHeight:"22px"},btnSelect:{width:"100%",padding:"0px 5px",fontSize:"14px",fontWeight:"400",lineHeight:"22px",color:"text.primary",justifyContent:"space-between",backgroundColor:"unset","&:hover":{backgroundColor:"unset"}},newSessionBtn:{height:"48px",padding:"11px 22px",fontSize:"13px",fontWeight:700,lineHeight:"22px",color:"text.primary",borderColor:n=>n.border,"&:hover":{color:"text.primary",borderColor:n=>n.border}},tableSecondaryHeading:{fontSize:"14px",fontWeight:600,lineHeight:"22px"},tableSecondaryText:{color:n=>n.palette.text.secondary,fontSize:"14px",fontWeight:400,lineHeight:"22px",maxHeight:"100px",overflow:"hidden",width:{xs:"250px",sm:"500px"},textOverflow:"ellipsis",whiteSpace:"nowrap"},select:{background:n=>n.palette.common.white},notAvailable:{borderRadius:"8px",height:"55px",width:"80px",border:n=>`1px solid ${n.border}`,display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"white"},performanceSelect:{height:"56px",width:"85px","& .MuiSelect-select":{textAlign:"center"},"& .MuiSelect-icon":{display:"none"},"& .MuiSelect-outlined":{padding:"16.5px 0px !important"}}},Ln={tooltip:{sx:{maxWidth:350,backgroundColor:"#1A2027",borderRadius:"10px",px:1.5,py:1}},arrow:{sx:{color:"#1A2027"}}},Vi=(n,s,_,c,m)=>n.map(l=>e.jsx(Ke,{sortDirection:s===l.id?_:!1,sx:ze.headerTableCell,children:e.jsxs(p,{container:!0,flexWrap:"nowrap",alignItems:"center",justifyContent:"space-between",children:[e.jsx(Xa,{active:l.sort,direction:s===l.id?_:"asc",onClick:O=>m(O,l.id),sx:ze.headerCellLabel,hideSortIcon:!l.sort,children:e.jsx(p,{children:l.label})}),l.icon&&e.jsx(p,{height:"18px",sx:{cursor:"pointer"},onClick:O=>{c(O.currentTarget,l.id)},children:l.icon})]})},l.id)),Wi=({sessionId:n,player:s,players:_,canManagePlayer:c,handleInputChange:m,handleUpdatePlayerData:l,handleOpenObjectiveModal:O,handleUpdateAvailability:_e,attendanceSubHeadCells:g})=>{var ie,Se,j,z;const L=Je(i=>i.breakpoints.down("md")),[te]=De(Wo),[je]=De(ja),[I,ne]=o.useState(!1),f=s.playerId,de=Bs(s.position),[X,M]=o.useState(null),[w,he]=o.useState(""),b=bn({initialValues:{...s,performance:s!=null&&s.performance?Math.round(s==null?void 0:s.performance):0,punctual:s==null?void 0:s.punctual,minutes:(s==null?void 0:s.minutes)||0,attended:s.attended,comment:s.comment||""},enableReinitialize:!0,validationSchema:Qo({performance:Xo().min(1,"Performance must be at least 1").max(10,"Performance must be at most 10")})}),{data:T,refetch:le}=jn(Vo,{variables:{session_id:n,player_id:f},fetchPolicy:"no-cache",skip:!I});o.useEffect(()=>{var i,h;if(T){const{success:t}=T==null?void 0:T.sessionPlayerObjectives;if(t&&(i=T==null?void 0:T.sessionPlayerObjectives)!=null&&i.data){const F=JSON.parse((h=T==null?void 0:T.sessionPlayerObjectives)==null?void 0:h.data),E=F.map(ke=>({...ke,performance:ke.score}));m({target:{name:"objectives",value:E}},f);const v=F.map(({id:ke,score:Le,objectiveId:We})=>({id:ke,score:Le,objectiveId:We}));m({target:{name:"objectivesScore",value:v}},f)}}},[T]);const q=async({target:{value:i}},h)=>{var ke;let t=null;const F=s.objectives.map(Le=>Le.id===h?(t={...Le,score:+i},t):Le);m({target:{name:"objectives",value:F}},f);const E=await te({variables:{id:t.id,feedback:(t==null?void 0:t.feedback)||"",score:t.score===null?7:+t.score}}),{success:v}=(ke=E==null?void 0:E.data)==null?void 0:ke.updateSessionPlayerObjective;if(v){const We=F.reduce((k,Ve)=>k+ +Ve.score,0)/F.length;N({target:{name:"performance",value:Math.round(We)}})}},C=async({target:{value:i}},h)=>{let t=null;const F=s.objectives.map(E=>E.id===h?(t={...E,feedback:i},t):E);m({target:{name:"objectives",value:F}},f)},R=async i=>{var E;const h=s.objectives.find(v=>v.id===i),t=await te({variables:{id:h.id,feedback:(h==null?void 0:h.feedback)||"",score:h.score===null?7:+h.score}}),{success:F}=(E=t==null?void 0:t.data)==null?void 0:E.updateSessionPlayerObjective;return F&&le(),F},D=async i=>{var F;const h=await je({variables:{id:i}}),{success:t}=(F=h==null?void 0:h.data)==null?void 0:F.deleteSessionPlayerObjective;return t&&le(),t},we=o.useCallback(zo(i=>{const{target:{value:h,name:t}}=i,F=!It(b.errors);if(t==="minutes"){const E={target:{name:t,value:h?parseInt(h):0}};m(E,f),l(E,f,F)}else if(t==="performance"){const E=h,v={target:{name:t,value:E}};b.setFieldValue(t,E),m(v,f),l(v,f,F)}else m(i,f),l(i,f,F)},1e3),[b.errors,_]),N=i=>{b.handleChange(i),we(i)},me=i=>i==null?void 0:i.map(h=>{var t,F,E;return{id:h.id,detail:e.jsxs(Tt,{container:!0,direction:"column","align-content":"flex-start",ga
2p:.5,width:{xs:"250px",sm:"500px"},children:[e.jsx(S,{sx:ze.tableSecondaryHeading,children:(t=h==null?void 0:h.player_objective)==null?void 0:t.title}),e.jsx(mt,{title:(F=h==null?void 0:h.player_objective)==null?void 0:F.description,arrow:!0,enterDelay:300,slotProps:Ln,children:e.jsx(S,{sx:ze.tableSecondaryText,children:(E=h==null?void 0:h.player_objective)==null?void 0:E.description})})]}),performance:e.jsx(tt,{disabled:!c,isShowClearable:!1,label:"Performance",name:"performance",size:"small",customStyle:{"& .MuiInputLabel-root":{fontSize:"12px"},"& .MuiSelect-select":{"& .MuiBox-root":{width:"16px",height:"16px",minWidth:"16px"},"& .MuiTypography-root":{fontSize:"13px"}}},options:[{id:10,name:"Outstanding",indicator:!0},{id:9,name:"Excellent",indicator:!0},{id:8,name:"Very Good",indicator:!0},{id:7,name:"Good",indicator:!0},{id:6,name:"Fair",indicator:!0},{id:5,name:"Not Great",indicator:!0},{id:4,name:"Poor",indicator:!0}],onChange:v=>q(v,h.id),value:(h==null?void 0:h.score)<4?4:h==null?void 0:h.score}),score:e.jsx(tt,{disabled:!c,isShowClearable:!1,sx:ze.select,size:"small",customStyle:{"& .MuiInputBase-input":{fontSize:"13px"}},options:[{id:1,name:"1"},{id:2,name:"2"},{id:3,name:"3"},{id:4,name:"4"},{id:5,name:"5"},{id:6,name:"6"},{id:7,name:"7"},{id:8,name:"8"},{id:9,name:"9"},{id:10,name:"10"}],value:(h==null?void 0:h.score)||"",name:"score",onChange:v=>q(v,h.id)}),feedback:e.jsx(ct,{disabled:!c,multiline:!0,maxRows:4,size:"small",name:"feedback",value:h.feedback,label:"Feedback",customStyle:{"& .MuiInputBase-input":{fontSize:"13px"},"& .MuiInputLabel-root":{fontSize:"12px"}},onChange:v=>C(v,h.id),onBlur:()=>R(h.id)}),minus:c&&e.jsx(Gt,{onClick:()=>D(h.id),children:e.jsx($i,{height:22,width:22})})}}),ae=()=>e.jsxs(p,{container:!0,justifyContent:"space-between",p:"11px 22px",children:[e.jsx(S,{sx:{color:"rgba(0, 0, 0, 0.26)"},fontSize:14,children:"N/A"}),e.jsx(pn,{})]}),A=()=>e.jsx(ee,{sx:ze.notAvailable,children:e.jsx(S,{sx:{color:"rgba(0, 0, 0, 0.26)"},fontSize:14,children:"N/A"})}),oe=()=>b.values.availability===2||b.values.availability===4,B=(i=[])=>{const h=i.slice(0,3);return h.length?h.map((t,F)=>{var E;return e.jsx(mt,{title:((E=t==null?void 0:t.player_objective)==null?void 0:E.title)||t["player_objective.title"]||`Score: ${t.score}/10`,arrow:!0,enterDelay:300,slotProps:Ln,children:e.jsx(fn,{fontSize:"small",sx:{color:v=>Rn(v.performance,t.score)},onClick:v=>{v.stopPropagation(),M(v.currentTarget),he(t.id)}})},t.id||F)}):e.jsx(S,{children:"-"})};return e.jsxs(o.Fragment,{children:[e.jsxs(Hn,{sx:i=>({"& > *":{borderBottom:"unset"},bgcolor:h=>I?h.backgroundColor.table:"","&:hover":{cursor:"pointer",backgroundColor:i.backgroundColor.body}}),onClick:()=>ne(!I),children:[e.jsx(Ke,{sx:[{p:{xs:0,sm:2}},I?{borderBottom:"none"}:{borderBottom:""}
2],children:e.jsx(Gt,{"aria-label":"expand row",size:"small",children:I?e.jsx(si,{}):e.jsx(ai,{})})}),e.jsx(Ke,{sx:[{pl:{xs:0,sm:2}},I?{borderBottom:"none"}:{borderBottom:""}],children:e.jsxs(p,{container:!0,alignItems:"center",gap:2,flexWrap:"nowrap",minWidth:{xs:"150px",md:"350px"},children:[e.jsx(Wt,{alt:s.name,src:"",sx:[ze.avatar,de?{color:i=>{var h;return(h=i.playerCategories[de])==null?void 0:h.color},backgroundColor:i=>{var h;return(h=i.playerCategories[de])==null?void 0:h.backgroundColor}}:{}],children:s.name.split(" ").slice(0,2).map(i=>i[0]).join("").toUpperCase()}),e.jsxs(ee,{children:[e.jsx(mt,{title:e.jsxs(ee,{sx:{display:"flex",flexDirection:"column",gap:.75,py:.25},children:[s.performance>0&&e.jsxs(ee,{sx:{display:"flex",alignItems:"center",gap:.75},children:[e.jsx(Yo,{sx:{fontSize:16,flexShrink:0,color:"#FFD54F"}}),e.jsxs(S,{sx:{fontSize:"13px",lineHeight:1.4},children:["Performance: ",s.performance,"/10"]})]}),((ie=s.objectives)==null?void 0:ie.length)>0&&e.jsxs(ee,{sx:{display:"flex",alignItems:"center",gap:.75},children:[e.jsx(qo,{sx:{fontSize:16,flexShrink:0,color:"#81C784"}}),e.jsxs(S,{sx:{fontSize:"13px",lineHeight:1.4},children:["Objectives: ",s.objectives.length," Set"]})]}),s.minutes>0&&e.jsxs(ee,{sx:{display:"flex",alignItems:"center",gap:.75},children:[e.jsx(Zo,{sx:{fontSize:16,flexShrink:0,color:"#90CAF9"}}),e.jsxs(S,{sx:{fontSize:"13px",lineHeight:1.4},children:["Training Time: ",s.minutes," Minutes"]})]})]}),arrow:!0,placement:"top-start",enterDelay:400,slotProps:Ln,children:e.jsx(S,{sx:ze.text,children:s.name})}),s.availability_response!==null&&s.availability_response!==void 0&&e.jsxs(S,{sx:{fontSize:"12px",lineHeight:"16px",fontWeight:600,color:s.availability_response?"success.main":"error.main"},children:["Parent: ",s.availability_response?"Available":"Unavailable"]})]})]})}),e.jsx(Ke,{sx:{p:0,textAlign:"center"},children:e.jsx(Ho,{value:s.availability,disabled:!c,playerId:f,handleUpdateAvailability:_e})}),e.jsx(Ke,{sx:[I?{borderBottom:"none"}:{borderBottom:""}],children:b.values.attended===0||oe()?e.jsx(ae,{}):e.jsx(Pn,{disable:!c,showIcon:!1,menuWidth:"200px",buttonIcon:e.jsx(pn,{}),buttonCustomStyles:ze.btnSelect,showCustomText:L,selectedMenuItemId:[b.values.attended],text:(Se=bt.ATTENDANCE.find(i=>i.id===b.values.attended))==null?void 0:Se.name,menuItems:bt.ATTENDANCE.map(i=>({id:i.id,name:i.name,onClick:()=>N({target:{name:"attended",value:i.id}})}))})}),e.jsx(Ke,{sx:[I?{borderBottom:"none"}:{borderBottom:""}],children:b.values.punctual===0||oe()?e.jsx(ae,{}):e.jsx(Pn,{name:"punctual",disable:!c,showIcon:!1,menuWidth:"200px",buttonIcon:e.jsx(pn,{}),buttonCustomStyles:ze.btnSelect,showCustomText:L,selectedMenuItemId:[b.values.punctual],text:((j=bt.PUNCTUAL.find(i=>i.id===b.values.punctual))==null?void 0:j.name)||"Yes",menuItems:bt.PUNCTUAL.map(i=>({id:i.id,name:i.name,onClick:()=>N({target:{name:"punctual",value:i.id}})}))})}),e.jsx(Ke,{sx:[I?{borderBottom:"none"}:{borderBottom:""}],children:e.jsx(Pn,{name:"fitness",disable:!c||oe(),showIcon:!1,menuWidth:"200px",buttonIcon:e.jsx(pn,{}),buttonCustomStyles:ze.btnSelect,showCustomText:L,selectedMenuItemId:[b.values.fitness],text:((z=bt.FITNESS.find(i=>i.id===b.values.fitness))==null?void 0:z.name)||"Fit",menuItems:bt.FITNESS.map(i=>({id:i.id,name:i.name,onClick:()=>N({target:{name:"fitness",value:i.id}})}))})}),e.jsx(Ke,{children:e.jsx(p,{container:!0,gap:1,justifyContent:"center",children:B(s==null?void 0:s.objectives,s.id)})}),e.jsx(Ke,{sx:[I?{borderBottom:"none"}:{borderBottom:""}],children:e.jsx(tt,{useNullishCoalescing:!0,name:"minutes",disabled:!c||oe(),isShowClearable:!1,onClick:i=>i.stopPropagation(),onChange:N,value:b.values.minutes,customStyle:ze.performanceSelect,options:$o(200,!1,!0,"number")})}),e.jsx(Ke,{sx:[I?{borderBottom:"none"}:{borderBottom:""}],children:oe()?e.jsx(A,{}):e.jsx(tt,{useNullishCoalescing:!0,name:"performance",disabled:!c||oe(),isShowClearable:!1,onClick:i=>i.stopPropagation(),onChange:N,value:b.values.performance,error:!!b.errors.performance,helperText:b.errors.performance,customStyle:ze.performanceSelect,options:[{id:0,name:"0"},{id:1,name:"1"},{id:2,name:"2"},{id:3,name:"3"},{id:4,name:"4"},{id:5,name:"5"},{id:6,name:"6"},{id:7,name:"7"},{id:8,name:"8"},{id:9,name:"9"},{id:10,name:"10"}]})})]}),e.jsx(Hn,{sx:{bgcolor:i=>I?i.backgroundColor.table:""},children:e.jsx(Ke,{style:{paddingBottom:0,paddingTop:0},colSpan:9,children:e.jsx(Jo,{in:I,timeout:"auto",unmountOnExit:!0,children:e.jsxs(Tt,{container:!0,direction:"column",gap:1,py:2,borderRadius:"16px",children:[e.jsxs(p,{container:!0,alignItems:"center",p:{xs:1,md:3},bgcolor:"#fff",borderRadius:"16px 16px 0px 0px",children:[e.jsx(S,{sx:ze.heading,children:"Objectives"}),c&&e.jsx(p,{container:!0,gap:2,flex:1,justifyContent:"flex-end",children:e.jsx(Fe,{variant:"outlined",text:"Manage Ob
2jectives",customStyles:ze.newSessionBtn,startIcon:e.jsx(ts,{height:"18px",width:"18px"}),onClick:i=>{i.stopPropagation(),O(f),le()}})})]}),e.jsx(ee,{sx:{"& .MuiPaper-root":{borderRadius:"0px 0px 16px 16px"}},children:e.jsx(zn,{data:me(s==null?void 0:s.objectives),headCells:g,showPagination:!1,emptyContentTitle:"No Objectives Added",emptyContentCompact:!0})}),e.jsx(Tt,{container:!0,direction:"column",pb:2,children:e.jsx(ct,{disabled:!c,multiline:!0,rows:4,size:"small",value:b.values.comment,handleChange:N,name:"comment",label:"General Feedback",customStyle:{backgroundColor:"#fff","& .MuiInputBase-input":{fontSize:"13px"},"& .MuiInputLabel-root":{fontSize:"13px"}}})})]})})})}),e.jsx(Cn,{width:"52px",itemHeight:"52px",enableDividers:!1,anchorEl:X,customStyles:ze.objectivesMenu,handleClose:i=>{i.stopPropagation(),M(null),he("")},items:[10,9,8,7,6,5,4].map(i=>({id:i,component:e.jsx(fn,{fontSize:"small",sx:{color:h=>Rn(h.performance,i)}},`${i}`),onClick:()=>q({target:{value:i}},w)}))})]})},Gi=({session:n,players:s=[],activeFilter:_="all",handleInputChange:c,handleOpenObjectiveModal:m,handleUpdatePlayerData:l,handleUpdateAvailability:O,canEdit:_e})=>{var me,ae,A,oe;const g=At(),{t:L}=gn("dugout"),te=hi(L),je=fi(L),[I,ne]=o.useState("desc"),[f,de]=o.useState("name"),[X,M]=o.useState(null),[w,he]=o.useState(null),b=o.useRef(null),T=["yes","limited"].includes((oe=(A=(ae=(me=g==null?void 0:g.userRolesPermissions)==null?void 0:me.permissions)==null?void 0:ae.dugout)==null?void 0:A.sessions)==null?void 0:oe.manage),le=_e??T,q=[{key:"all",label:"All"},{key:"present",label:"Present",match:B=>[1,2,3].includes(B.attended)},{key:"absent",label:"Absent",match:B=>[4,5].includes(B.attended)},{key:"injured",label:"Injured",match:B=>B.fitness==="Injured"},{key:"unmarked",label:"Unmarked",match:B=>![1,2,3,4,5].includes(B.attended)}],C=o.useMemo(()=>{if(!X)return null;const B=q.find(ie=>ie.key===_);return B!=null&&B.match?X.filter(B.match):X},[X,_]),R=[],D=B=>{he(B)},we=()=>{he(null)},N=(B,ie)=>{const Se=I==="asc"&&ie===f?"desc":"asc",j=Bn(s,ie);de(ie),ne(Se),M(Se==="asc"?j:$n(j))};return o.useEffect(()=>{if(s.length){const B=Bn(s,f);M(I==="asc"?B:$n(B))}},[s]),o.useEffect(()=>{b.current={players:s}},[s]),o.useEffect(()=>()=>{b.current.isUpdated},[]),e.jsxs(ee,{sx:{width:"100%"},children:[e.jsx(qa,{component:Za,sx:ze.paper,children:e.jsxs(Ka,{"aria-label":"collapsible table",children:[e.jsx(Ja,{children:e.jsxs(Hn,{children:[e.jsx(Ke,{sx:{...ze.headerTableCell,width:"34px",p:{xs:0,sm:2}}}),Vi(te,f,I,D,N)]})}),e.jsx(Qa,{children:C==null?void 0:C.map(B=>e.jsx(Wi,{sessionId:n==null?void 0:n.id,player:B,players:X,canManagePlayer:le,handleInputChange:c,handleUpdatePlayerData:l,handleOpenObjectiveModal:m,handleUpdateAvailability:O,attendanceSubHeadCells:je},`${B.playerId}`))})]})}),e.jsx(Cn,{height:"58px",width:"120px",itemPadding:"14px 24px",enableDividers:!1,items:R,anchorEl:w,handleClose:we})]})},xn={checkbox:{padding:0,mr:1},menuItem:{padding:2,maxWidth:"600px"},objectiveMenuItemText:{whiteSpace:"pre-wrap",fontSize:"14px"}},Ui=({loading:n,open:s,handleClose:_,sessionId:c,playerId:m,players:l,currentObjectives:O,handleUpdatePlayerData:_e})=>{const g=At(),[L,te]=o.useState([]),[je]=De(ya),{data:I}=jn(ta,{variables:{club_id:g==null?void 0:g.club_id,coach_id:g==null?void 0:g.id,player_id:+m,checked:0,includePastObjectives:!1},skip:!s||+m==-1,fetchPolicy:"no-cache"});o.useEffect(()=>{if(I){const b=JSON.parse(I.getPlayerObjectives.data),T=b.filter(le=>O.find(q=>q.objectiveId===le.id));te([...b]),X.setFieldValue("objective",T.map(le=>le.id))}},[I,s]);const ne=L.filter(b=>b.objective_completion_status===2&&new Date(b.review_end_date)>=new Date).sort((b,T)=>new Date(b.review_end_date)-new Date(T.review_end_date)),f=new Set(ne.slice(0,3).map(b=>b.id)),de=new Set(ne.slice(3).map(b=>b.id)),X=bn({initialValues:{objective:[]},enableReinitialize:!0,onSubmit:b=>{w()}}),M=b=>{const T=b.reduce((le,q)=>le+(q==null?void 0:q.score)||0,0);return b.length?T/b.length:0},w=async()=>{const{data:b}=await je({variables:{session_id:+c,player_id:+m,objective_ids:X.values.objective,currentObjective_Ids:O.map(N=>N.objectiveId)}}),T=l==null?void 0:l.findIndex(N=>N.playerId===+m),le=JSON.parse(b.createSessionPlayerObjective.data),q=le.map(N=>({...N,performance:N.score})),C=le.map(({id:N,score:me,objectiveId:ae})=>({id:N,score:me,objectiveId:ae})),R=Fo(q),D=M(q),we={...l[T],objectives:q,performance:D,objectivesScore:C,objectivesMet:R};l.splice(T,1,we),_e({target:{name:"performance",value:+D}},m),he()},he=()=>{X.resetForm(),_()};
2return e.jsx(Go,{open:s,title:"Manage Objective",loading:n,handleClose:he,actionBtnTitle:"Save Objective",actionHandler:X.handleSubmit,disabledBtn:zs(X.touched,X.errors)||L.length===0,children:e.jsx(p,{container:!0,spacing:3,children:e.jsx(p,{size:12,children:e.jsx(tt,{multiple:!0,name:"objective",value:X.values.objective||[],label:"Search & Select Objective",options:L,optionKey:"title",onChange:X.handleChange,customMenuItem:(()=>{const b=L.filter(D=>f.has(D.id)),T=L.filter(D=>de.has(D.id)),le=L.filter(D=>!f.has(D.id)&&!de.has(D.id)),q=[...b,...le,...T],C=[];let R=!1;return q.forEach((D,we)=>{var ae;const N=f.has(D.id),me=de.has(D.id);me&&!R&&T.length>0&&(R=!0,C.push(e.jsx($t,{sx:{fontSize:"11px",fontWeight:700,color:"#1565C0",lineHeight:"28px",px:2,backgroundColor:"#FAFAFA"},children:"In Reserve"},"on-deck-header"))),C.push(e.jsxs(Pt,{divider:!0,value:D.id,sx:{...xn.menuItem,...me?{opacity:.6}:{}},children:[e.jsx(ei,{checked:(ae=X.values.objective)==null?void 0:ae.includes(D.id),sx:xn.checkbox}),e.jsxs(ee,{width:"100%",children:[e.jsxs(p,{container:!0,alignItems:"center",gap:1,wrap:"nowrap",children:[e.jsx(S,{color:"text.primary",fontWeight:600,sx:xn.objectiveMenuItemText,children:D.title}),N&&e.jsx(ut,{label:"Active",size:"small",sx:{fontSize:"10px",height:"20px",fontWeight:700,backgroundColor:"#E3F2FD",color:"#1565C0"}}),me&&e.jsx(ut,{label:"In Reserve",size:"small",sx:{fontSize:"10px",height:"20px",fontWeight:700,backgroundColor:"#E3F2FD",color:"#1565C0",borderStyle:"dashed",borderWidth:"1px",borderColor:"#90CAF9"}})]}),e.jsx(S,{color:"text.secondary",sx:xn.objectiveMenuItemText,children:D.description})]})]},`${D.id}-${we}`))}),C})()})})})})},Yi=({session:n,refetchSessionPlayers:s,setRefetchSessionPlayers:_,view:c,isExpandedAllPlayerCards:m,isOpenManageDrawer:l})=>{var be,nt,ot,pt,xt;const O=qt(),{t:_e}=gn("dugout"),[g,L]=o.useState([]),[te,je]=o.useState(!1),[I]=De(va),[ne]=De(_a,{update:xi}),[f]=De(wa),[de,X]=o.useState({}),M=At(),[w,he]=o.useState([]),[b]=Ut(),[T,le]=o.useState(!1),[q,C]=o.useState(-1),{currentSeason:R,isReadOnlyMode:D,isUpcomingSeason:we}=Yt(),[N,me]=o.useState(null),[ae,A]=o.useState("all"),[oe,B]=o.useState(null),Se=["yes","limited"].includes((pt=(ot=(nt=(be=M==null?void 0:M.userRolesPermissions)==null?void 0:be.permissions)==null?void 0:nt.dugout)==null?void 0:ot.sessions)==null?void 0:pt.manage)&&(!D||we),j=async()=>{try{je(!0);const{data:x}=await O.query({query:na,variables:{session_id:(n==null?void 0:n.id)??0,includeSoftDeleted:!0,teamId:(n==null?void 0:n.team_id)??0},fetchPolicy:"no-cache"}),{success:U,data:K}=x==null?void 0:x.sessionPlayerListing;if(U){const ue=K.map(V=>({...V,name:`${V.player_name} ${V.player_surname} ${V!=null&&V.playerDeletedAt||!(V!=null&&V.playerCurrentAssociatedSessionTeamId)?_e("sessions.formerSuffix"):""}`}));L([...ue])}}catch(x){console.error("Error fetching session players:",x)}finally{je(!1)}};o.useEffect(()=>{j()},[n==null?void 0:n.id]),o.useEffect(()=>{s&&(j(),_(!1))},[s]);const z=x=>{X(U=>({...U,[x]:!U[x]}))};o.useEffect(()=>{const x=g.reduce((U,K)=>(U[K.playerId]=m,U),{});X(x)},[m]);const{data:i}=jn(da,{variables:{club_id:M!=null&&M.club_id?M==null?void 0:M.club_id:0},skip:!(M!=null&&M.club_id),fetchPolicy:"no-cache"});o.useEffect(()=>{var x;if(i!=null&&i.getPositions){const{success:U}=i==null?void 0:i.getPositions;if(U){const K=JSON.parse((x=i==null?void 0:i.getPositions)==null?void 0:x.data);he(K)}}},[i]);const h=({target:{name:x,value:U}},K)=>{const ue=[...g],V=Eo(ue,{playerId:K});Io(ue,V,()=>To(ue[V],x,U)),x==="attended"&&Io(ue,V,()=>To(ue[V],"minutes",[1,2,3].includes(U)&&(n==null?void 0:n.duration)||0)),L([...ue])},t=x=>{c==="grid"&&X({...de,[x]:!1}),C(x),le(!0)},F=()=>{C(-1),le(!1)},E=async({comment:x,attended:U,playerId:K,isComment:ue,target_id:V,performance:Ie,punctual:Z,fitness:He,minutes:Pe,description:ht,player_target:Ge})=>{var at;const qe=await I({variables:{type:{inputUpdateSessionPlayerList:{session_id:n==null?void 0:n.id,player_id:K,player_target:Ge,attended:U,performance:Ie,target_id:V,description:ht,comment:x,punctual:Z,fitness:He,minutes:Pe,isComment:ue}}}}),{success:Qe,message:st}=(at=qe==null?void 0:qe.data)==null?void 0:at.updateSessionPlayer;return Qe&&b({msg:st||"Updated Successfully",variant:"success"}),Qe},v=async({target:{value:x,name:U}},K,ue=!1)=>
2{if(ue)return;const Ie={...g.find(He=>He.playerId===K),[U]:x};if(await E(Ie)){const He=[...g];He.splice(Eo(He,{playerId:K}),1,Ie),L(He)}},ke=async(x,U)=>{var Ie;const K=await ne({variables:{updatePlayerAvailabilityInput:{playerIds:[U],availability:x,season_id:R==null?void 0:R.id}}}),{status:ue,message:V}=(Ie=K==null?void 0:K.data)==null?void 0:Ie.updatePlayerAvailability;ue&&(Le(x,U),b({msg:V||"Player availability updated successfully.",variant:"success"}))},Le=async(x,U)=>{var Ie;const K={sessionId:n.id,playerId:U,punctual:x===1||x===3?1:0,fitness:x===2?"Injured":"Fit",attended:x===1?1:x===3?3:0,performance:x===1||x===3?7:0},ue=await f({variables:{updateSessionPlayerDataInput:K}}),{status:V}=(Ie=ue==null?void 0:ue.data)==null?void 0:Ie.updateSessionPlayerData;V&&j()},We=async(x,U,K)=>{B(null);const ue=g;let V,Ie;if(x==="attended")V=ue.filter(Z=>Z.attended!==U),Ie=Z=>({attended:U,punctual:[1,2,3].includes(U)?Z.punctual||1:0,fitness:Z.fitness||"Fit",performance:[1,2,3].includes(U)?Z.performance||7:0});else if(x==="punctual")V=ue.filter(Z=>[1,2,3].includes(Z.attended)&&Z.punctual!==U),Ie=Z=>({attended:Z.attended,punctual:U,fitness:Z.fitness||"Fit",performance:Z.performance||7});else if(x==="fitness")V=ue.filter(Z=>[1,2,3].includes(Z.attended)&&Z.fitness!==U),Ie=Z=>({attended:Z.attended,punctual:Z.punctual??1,fitness:U,performance:Z.performance||7});else if(x==="availability"){if(V=ue.filter(Z=>Z.availability!==U),!V.length)return;me(K);try{for(const Z of V)await ne({variables:{updatePlayerAvailabilityInput:{playerIds:[Z.playerId],availability:U,season_id:R==null?void 0:R.id}}});await j(),b({msg:`${V.length} players marked as ${K}`,variant:"success"})}catch{b({msg:"Failed to update players",variant:"error"})}finally{me(null)}return}if(V!=null&&V.length){me(K);try{for(const Z of V)await f({variables:{updateSessionPlayerDataInput:{sessionId:n.id,playerId:Z.playerId,...Ie(Z)}}});await j(),b({msg:`${V.length} players marked as ${K}`,variant:"success"})}catch{b({msg:"Failed to update players",variant:"error"})}finally{me(null)}}},k=o.useMemo(()=>{const x=g.length,U=g.filter(Pe=>[1,2,3].includes(Pe.attended)),K=U.length,ue=g.filter(Pe=>[4,5].includes(Pe.attended)).length,V=g.filter(Pe=>Pe.fitness==="Injured").length,Ie=x-K-ue,Z=U.filter(Pe=>Pe.punctual!==1).length,He=U.filter(Pe=>Pe.fitness!=="Fit").length;return{total:x,present:K,absent:ue,injured:V,unmarked:Ie,notOnTime:Z,notFit:He}},[g]),Ve=o.useMemo(()=>{if(ae==="all")return g;const U={present:K=>[1,2,3].includes(K.attended),absent:K=>[4,5].includes(K.attended),injured:K=>K.fitness==="Injured",unmarked:K=>![1,2,3,4,5].includes(K.attended)}[ae];return U?g.filter(U):g},[g,ae]);return te?e.jsx(Sn,{}):e.jsxs(e.Fragment,{children:[e.jsx(Ui,{open:T,handleClose:F,sessionId:n.id,playerId:q,players:g,setPlayers:L,handleUpdatePlayerData:v,currentObjectives:((xt=g.find(x=>x.playerId===q))==null?void 0:xt.objectives)||[]}),g.length>0&&e.jsxs(ee,{sx:{display:"flex",flexWrap:"wrap",gap:1,mt:2,mb:1,ml:2,alignItems:"center"},children:[e.jsx(ut,{size:"small",label:`Total: ${k.total}`,onClick:()=>A("all"),sx:{fontWeight:600,fontSize:"12px",cursor:"pointer",...ae==="all"&&{outline:"2px solid",outlineColor:"text.primary"}}}),e.jsx(ut,{size:"small",label:`Present: ${k.present}`,onClick:()=>A(ae==="present"?"all":"present"),sx:{fontWeight:600,fontSize:"12px",backgroundColor:"#E8F5E9",color:"#2E7D32",cursor:"pointer",...ae==="present"&&{outline:"2px solid #2E7D32"}}}),e.jsx(ut,{size:"small",label:`Absent: ${k.absent}`,onClick:()=>A(ae==="absent"?"all":"absent"),sx:{fontWeight:600,fontSize:"12px",backgroundColor:"#FFEBEE",color:"#C62828",cursor:"pointer",...ae==="absent"&&{outline:"2px solid #C62828"}}}),e.jsx(ut,{size:"small",label:`Injured: ${k.injured}`,onClick:()=>A(ae==="injured"?"all":"injured"),sx:{fontWeight:600,fontSize:"12px",backgroundColor:"#FFF3E0",color:"#E65100",cursor:"pointer",...ae==="injured"&&{outline:"2px solid #E65100"}}}),k.unmarked>0&&e.jsx(ut,{size:"small",label:`Unmarked: ${k.unmarked}`,onClick:()=>A(ae==="unmarked"?"all":"unmarked"),sx:{fontWeight:600,fontSize:"12px",backgroundColor:"#F5F5F5",color:"#757575",cursor:"pointer",...ae==="unmarked"&&{outline:"2px s
2olid #757575"}}}),Se&&e.jsxs(e.Fragment,{children:[e.jsx(ut,{size:"small",label:N?`${N}...`:"Mark All",onClick:x=>B(x.currentTarget),disabled:!!N,sx:{fontWeight:600,fontSize:"12px",backgroundColor:"#E3F2FD",color:"#1565C0",cursor:"pointer","&:hover":{backgroundColor:"#BBDEFB"}}}),e.jsxs(Uo,{anchorEl:oe,open:!!oe,onClose:()=>B(null),slotProps:{paper:{sx:{width:"220px",borderRadius:"12px",mt:1,"& .MuiList-root":{py:.5}}}},children:[e.jsx($t,{sx:{fontSize:"11px",fontWeight:700,lineHeight:"28px",color:"text.secondary",textTransform:"uppercase"},children:"Attendance"}),[{id:1,label:"Yes"},{id:2,label:"Yes - Non Contact"},{id:3,label:"Yes - Physio"},{id:4,label:"No - Authorised"},{id:5,label:"No - Unauthorised"}].map(x=>e.jsx(Pt,{onClick:()=>We("attended",x.id,x.label),sx:{fontSize:"13px",py:.75,minHeight:"unset"},children:x.label},`att-${x.id}`)),e.jsx($t,{sx:{fontSize:"11px",fontWeight:700,lineHeight:"28px",color:"text.secondary",textTransform:"uppercase"},children:"Punctual"}),[{id:1,label:"Yes"},{id:2,label:"Late"}].map(x=>e.jsx(Pt,{onClick:()=>We("punctual",x.id,x.label),sx:{fontSize:"13px",py:.75,minHeight:"unset"},children:x.label},`pun-${x.id}`)),e.jsx($t,{sx:{fontSize:"11px",fontWeight:700,lineHeight:"28px",color:"text.secondary",textTransform:"uppercase"},children:"Fitness"}),[{id:"Fit",label:"Fit"},{id:"Injured",label:"Injured"}].map(x=>e.jsx(Pt,{onClick:()=>We("fitness",x.id,x.label),sx:{fontSize:"13px",py:.75,minHeight:"unset"},children:x.label},`fit-${x.id}`)),e.jsx($t,{sx:{fontSize:"11px",fontWeight:700,lineHeight:"28px",color:"text.secondary",textTransform:"uppercase"},children:"Availability"}),[{id:1,label:"Available"},{id:3,label:"Undecided (Testing)"},{id:2,label:"Unavailable (Injured)"},{id:4,label:"Unavailable (Other)"}].map(x=>e.jsx(Pt,{onClick:()=>We("availability",x.id,x.label),sx:{fontSize:"13px",py:.75,minHeight:"unset"},children:x.label},`avail-${x.id}`))]})]})]}),e.jsx(Tt,{container:!0,direction:"column",gap:3,height:"100%",children:g.length===0?e.jsx(Js,{title:"No Players added to session",description:"The Players value is empty ... for now. Please click button below to start adding players!"}):c==="list"?e.jsx(Gi,{session:n,players:Ve,activeFilter:ae,handleInputChange:h,handleOpenObjectiveModal:t,handleUpdatePlayerData:v,handleUpdateAvailability:ke,canEdit:Se}):e.jsx(Fi,{session:n,players:Ve,positionsList:w,toggleAccordion:z,expandedAccordions:de,handleInputChange:h,handleOpenObjectiveModal:t,handleUpdatePlayerData:v,handleUpdateAvailability:ke,isOpenManageDrawer:l,canManage:Se})})]})},qi=o.lazy(()=>Hs(()=>import("./ViewFileModal-BK83w1wk.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12]))),Lo={tableContainer:{border:n=>`1px solid ${n.border}`,borderRadius:"8px 8px 0px 0px","& .MuiPaper-root":{borderRadius:"8px 8px 0px 0px"},margin:{xs:"10px",sm:"24px"},height:"calc(100% - 52px)"}},No=({session:n})=>{var qe,Qe,st,at;const s=qt(),{t:_}=gn("dugout"),c=gi(_),m=Si(_),[l,O]=o.useState(0),_e=dt($=>$.club),g=At(),[L,te]=o.useState([]),[je,I]=o.useState([]),[ne,f]=o.useState(!1),[de,X]=o.useState(!1),[M,w]=o.useState(0),[he,b]=o.useState(0),[T,le]=o.useState(0),[q,C]=o.useState(10),[R,D]=o.useState(wo),[we,N]=o.useState("asc"),[me,ae]=o.useState(null),[A,oe]=o.useState(!1),[B,ie]=o.useState(!1),[Se]=De(Ea),[j]=De(Ia),[z,i]=o.useState(),[h]=Ut(),{isReadOnlyMode:t,isUpcomingSeason:F}=Yt(),v=((at=(st=(Qe=(qe=g==null?void 0:g.userRolesPermissions)==null?void 0:qe.permissions)==null?void 0:Qe.dugout)==null?void 0:st.sessions)==null?void 0:at.manage)!==Vt.NO&&(!t||F),ke=async()=>{var fe,Te,Ne,Me;X(!0);const $=await s.query({query:oa,variables:{club_id:g.club_id?g.club_id:_e.club_id,session_id:(n==null?void 0:n.id)??0,limit:q,offset:M*q},fetchPolicy:"no-cache"}),G=(Te=(fe=$==null?void 0:$.data)==null?void 0:fe.sessionDocuments)==null?void 0:Te.data;if(G){const Mt=JSON.parse(G);te(Mt),b((Me=(Ne=$==null?void 0:$.data)==null?void 0:Ne.sessionDocuments)==null?void 0:Me.totalRecords)}X(!1)};o.useEffect(()=>{n!=null&&n.id&&l===0&&!de&&ke()},[n==null?void 0:n.id,l,q,M]);const Le=async($,G)=>{var Ne,Me;f(!0);const fe=await s.query({query:sa,variables:{sessionPracticeDocumentListingInput:{limit:q,offset:M*q,session_id:n.id,sortBy:$,sortOrder:G}},fetchPolicy:"no-cache"}),Te=(Me=(Ne=fe==null?void 0:fe.data)==null?void 0:Ne.sessionPracticeDocumentListing)==null?void 0:Me.data;Te&&(I(Te.documents),le(Te.count)),f(!1)};o.useEffect(()=>{n!=null&&n.id&&l===1&&!ne&&Le(Po(R,$=>$===!0),we)},[n==null?void 0:n.id,l,q,M]);const We=($,G)=>{w(G)},k=({target:{value:$}})=>{C($),w(0)},Ve=async($,G)=>{const Te=await(await fetch($)).blob(),Ne=URL.createObjectURL(Te),Me=document.createElement("a");Me.href=Ne,Me.download=G,document.body.appendChild(Me),Me.click(),document.body.removeChild(Me)},be=$=>{const fe=R[$]&&we==="asc"?"desc":"asc";N(fe),D({...wo,[$]:!0}
2),l===0?nt($,fe):Le($,fe)},nt=($,G)=>{const fe=Bn(L,$);te(G==="asc"?fe:$n(fe))},ot=($,G)=>{ae($);const fe=l===0?L[G]:je[G];i(fe)},pt=()=>{ae(null)},xt=()=>{ie(!0)},x=()=>{oe(!0)},U=()=>{oe(!1),i(null)},K=$=>{i(L[$]),x()},ue=()=>{ie(!1)},V=async()=>{var Te;const $=await Se({variables:{ids:[z==null?void 0:z.id]}}),{message:G,success:fe}=(Te=$==null?void 0:$.data)==null?void 0:Te.deleteSessionDocuments;fe&&(h({msg:G||"Document deleted successfully",variant:"success"}),ke(),ie(!1))},Ie=async()=>{var Te;const $=await j({variables:{ids:[z==null?void 0:z.id]}}),{message:G,success:fe}=(Te=$==null?void 0:$.data)==null?void 0:Te.deleteSessionPracticeDocument;fe&&(Le(Po(R,Ne=>Ne===!0),we),h({msg:G||"Document deleted successfully",variant:"success"}),ie(!1))},Z=($,G)=>{w(0),C(10),O(G)},He=async({id:$})=>{var Ne,Me;const G=await s.query({query:aa,variables:{id:+$},fetchPolicy:"no-cache"}),fe=(Me=(Ne=G==null?void 0:G.data)==null?void 0:Ne.documentDetails)==null?void 0:Me.data,Te=document.createElement("a");Te.href=fe==null?void 0:fe.file_url,Te.download=!0,Te.click()},Pe=[...l===0?[{name:"View",icon:ti,iconCustomStyles:{width:"20px",height:"20px"},onClick:x}]:[],...v?[{name:"Delete",icon:ns,onClick:xt}]:[]],ht=$=>$.map(G=>({id:G.id,name:e.jsxs(p,{container:!0,gap:2,wrap:"nowrap",alignItems:"center",children:[e.jsx(p,{children:e.jsx(ko,{})}),e.jsx(p,{children:e.jsx(S,{fontSize:14,color:"text.primary",children:G.title})})]}),createdAt:e.jsx(p,{children:e.jsx(S,{fontSize:14,color:"text.primary",children:G.createdAt?xo(G.createdAt):"-"})}),download:e.jsx(Gt,{onClick:()=>He(G),children:e.jsx(Ao,{})})})),Ge=$=>$.map(G=>({id:G.id,name:e.jsxs(p,{container:!0,gap:2,wrap:"nowrap",alignItems:"center",children:[e.jsx(p,{children:e.jsx(ko,{})}),e.jsx(p,{children:e.jsx(S,{fontSize:14,color:"text.primary",children:G.name?G.name:"Sample"})})]}),docType:e.jsx(p,{children:e.jsx(S,{fontSize:14,color:"text.primary",children:G.docType?G.docType.toUpperCase():"File"})}),size:e.jsx(p,{children:e.jsx(S,{fontSize:14,color:"text.primary",children:G.size?Fs(G.size):"0 MB"})}),createdAt:e.jsx(p,{children:e.jsx(S,{fontSize:14,color:"text.primary",children:G.createdAt?xo(G.createdAt):"-"})}),download:e.jsx(Gt,{onClick:fe=>{fe.stopPropagation(),Ve(G.url,G.name)},children:e.jsx(Ao,{})})}));return de||ne?e.jsx(Sn,{}):e.jsxs(e.Fragment,{children:[e.jsx(es,{padding:0,labels:["Session","Session Practice"],selectedTab:l,handleTabChange:Z,components:[e.jsx(ee,{sx:Lo.tableContainer,children:e.jsx(zn,{isRowClickable:!0,page:M,sort:R,sortOrder:we,rowsPerPage:q,count:he||0,canEdit:v,headCells:c,sortHandler:be,setAnchorEl:ot,handleChangePage:We,handleChangeRowsPerPage:k,handleRowClick:K,data:Ge(L.length?L:[]),emptyContentTitle:"No Session Documents Found"})},"Session"),e.jsx(ee,{sx:Lo.tableContainer,children:e.jsx(zn,{page:M,count:T||0,data:ht(je.length?je:[]),headCells:m,rowsPerPage:q,handleChangePage:We,handleChangeRowsPerPage:k,sortOrder:we,sort:R,sortHandler:be,setAnchorEl:ot,canEdit:v,emptyContentTitle:"No Session Practice Documents Found"})},"Session Practice")]}),e.jsx(qi,{selectedFile:z,open:A,handleClose:U}),e.jsx(Cn,{height:"55px",width:"180px",items:Pe,anchorEl:me,enableDividers:!1,itemPadding:"14px 24px",handleClose:pt}),e.jsx(Vn,{handleDelete:l===0?V:Ie,handleClose:ue,open:B,title:"Delete Document?",actionBtnTitle:"Delete Document",entityName:(z==null?void 0:z.name)||(z==null?void 0:z.title)})]})},$e={textField:{height:"145px",backgroundColor:n=>n.palette.common.white},slider:{marginTop:2,marginLeft:1,padding:"0px !important",height:"2px","& .MuiSlider-thumb":{height:"10px",width:"10px","&.Mui-active":{boxShadow:"unset"}}},scoreInput:{width:"48px","& .MuiOutlinedInput-root":{height:"40px",padding:0,backgroundColor:n=>n.palette.common.white,"&:hover fieldset":{borderColor:n=>n.palette.primary.main},"& input":{textAlign:"center",fontSize:"14px",padding:0}}},heading:{fontSize:"18px",fontWeight:700,lineHeight:"28px",whiteSpace:"nowrap"},saveButton:{padding:"6px 16px",borderRadius:"8px",fontSize:"14px",fontWeight:700,lineHeight:"24px"},card:{height:"100%",borderRadius:"16px",border:n=>`1px solid ${n.palette.divider}`,boxShadow:n=>`0px 12px 24px -4px ${n.palette.divider} , 0px 0px 2px 0px ${n.palette.divider}`}},Nn={sessionOrganization:"",playerEngagement:"",coachBehaviors:"",actionPoints:"",sessionOrganizationScore:0,playerEngagementScore:0,coachBehaviorsScore:0,session_status:"incomplete"},Zi=({session:n,refetchSession:s})=>{var oe,B,ie,Se;const _=At(),{id:c,session_organisation:m,player_engagement:l,coach_behaviours:O,action_points:_e,session_status:g,session_organization_score:L,player_engagement_score:te,coach_behaviors_score:je}
2=n,I=Je("(max-width: 600px)"),ne=o.useRef(),f=o.useRef(),[de]=Ut(),[X]=De(Ta),[M,w]=o.useState(!1),[he,b]=o.useState(!1),T={sessionOrganization:m??"",playerEngagement:l??"",coachBehaviors:O??"",actionPoints:_e??"",sessionOrganizationScore:L??0,playerEngagementScore:te??0,coachBehaviorsScore:je??0,session_status:g?"complete":"incomplete"},{isReadOnlyMode:le,isUpcomingSeason:q}=Yt(),R=["yes","limited"].includes((Se=(ie=(B=(oe=_==null?void 0:_.userRolesPermissions)==null?void 0:oe.permissions)==null?void 0:B.dugout)==null?void 0:ie.sessions)==null?void 0:Se.manage)&&(!le||q),D=bn({initialValues:Mn(T,It)?Nn:T,enableReinitialize:!0}),we=async({sessionOrganization:j,playerEngagement:z,coachBehaviors:i,actionPoints:h,sessionOrganizationScore:t,playerEngagementScore:F,coachBehaviorsScore:E,session_status:v})=>{var Le;w(!0);const{data:ke}=await X({variables:{id:c,session_organisation:j,player_engagement:z,coach_behaviours:i,action_points:h,coach_behaviors_score:E,player_engagement_score:F,session_organization_score:t,session_status:v==="complete"}});(Le=ke==null?void 0:ke.updateSessionEvaluation)!=null&&Le.success&&(s(!1),de({msg:"Session evaluation saved successfully.",variant:"success"})),f.current={sessionOrganization:j,playerEngagement:z,coachBehaviors:i,actionPoints:h,sessionOrganizationScore:t,playerEngagementScore:F,coachBehaviorsScore:E,session_status:v},b(!1),w(!1)},N=j=>{D.handleChange(j)},me=j=>(z,i)=>{D.setFieldValue(j,i)},ae=j=>z=>{const i=z.target.value,h=i===""?0:Number(i),t=Number.isNaN(h)?0:Math.min(10,Math.max(0,h));D.setFieldValue(j,t)},A=()=>$s([D.values.sessionOrganizationScore,D.values.playerEngagementScore,D.values.coachBehaviorsScore]);return o.useEffect(()=>{ne.current=D.values},[D.values]),o.useEffect(()=>{f.current=Mn(T,It)?Nn:T},[m,l,O,_e,g,L,te,je]),o.useEffect(()=>{f.current||(f.current=Mn(T,It)?Nn:T),b(!bi(D.values,f.current))},[D.values,T]),o.useEffect(()=>()=>{R&&we(ne.current)},[]),e.jsxs(p,{container:!0,p:{xs:"10px",sm:3},gap:3,justifyContent:"center",direction:{xs:"column",md:"row"},children:[e.jsxs(p,{container:!0,width:"100%",gap:2,alignItems:"center",justifyContent:"space-between",direction:{xs:"column",sm:"row"},children:[e.jsxs(p,{container:!0,gap:2,alignItems:"center",flexWrap:"nowrap",flex:1,direction:{xs:"column",sm:"row"},width:"100%",children:[e.jsxs(S,{sx:$e.heading,children:["Total Evaluation: ",A()]}),e.jsx(tt,{disabled:!R,isShowClearable:!1,name:"session_status",label:"Session Status",value:D.values.session_status,options:[{id:"complete",name:"Complete"},{id:"incomplete",name:"Incomplete"}],onChange:N,customStyle:{height:"40px",maxWidth:{xs:"100%",sm:"200px"}}})]}),e.jsx(Fe,{text:"Save Session Evaluation",fullWidth:I,startIcon:e.jsx(os,{style:{fontSize:"14px"}}),customStyles:$e.saveButton,onClick:()=>we(D.values),loading:M,disabled:!R||!he})]}),e.jsxs(p,{container:!0,spacing:3,sx:{width:"100%"},children:[e.jsx(p,{size:{xs:12,sm:6},children:e.jsx(Ft,{sx:$e.card,children:e.jsx(Ht,{children:e.jsxs(p,{container:!0,direction:"column",gap:2,children:[e.jsxs(p,{container:!0,direction:"row",alignItems:"center",gap:2,flexWrap:"nowrap",children:[e.jsx(Dn,{step:1,min:0,max:10,marks:!0,value:D.values.sessionOrganizationScore,onChange:me("sessionOrganizationScore"),disabled:!R,sx:$e.slider}),e.jsx(ct,{disabled:!R,name:"sessionOrganizationScore",customStyle:$e.scoreInput,value:D.values.sessionOrganizationScore,inputProps:{style:{textAlign:"center"}},onKeyDown:j=>{!/[0-9]/.test(j.key)&&j.key!=="Backspace"&&j.key!=="Delete"&&j.key!=="ArrowLeft"&&j.key!=="ArrowRight"&&j.key!=="Tab"&&j.preventDefault()},handleChange:ae("sessionOrganizationScore")})]}),e.jsx(ct,{disabled:!R,multiline:!0,rows:5,name:"sessionOrganization",label:"Session Organization",customStyle:$e.textField,value:D.values.sessionOrganization,handleChange:N})]})})})}),e.jsx(p,{size:{xs:12,sm:6},children:e.jsx(Ft,{sx:$e.card,children:e.jsx(Ht,{children:e.jsxs(p,{container:!0,direction:"column",gap:2,children:[e.jsxs(p,{container:!0,direction:"row",alignItems:"center",gap:2,flexWrap:"nowrap",children:[e.jsx(Dn,{step:1,min:0,max:10,marks:!0,value:D.values.playerEngagementScore,onChange:me("playerEngagementScore"),disabled:!R,sx:$e.slider}),e.jsx(ct,{disabled:!R,name:"playerEngagementScore",customStyle:$e.scoreInput,value:D.values.playerEngagementScore,inputProps:{style:{textAlign:"center"}},onKeyDown:j=>{!/[0-9]/.test(j.key)&&j.key!=="Backspace"&&j.key!=="Delete"&&j.key!=="ArrowLeft"&&j.key!=="ArrowRight"&&j.key!=="Tab"&&j.preventDefault()},handleChange:ae("playerEngagementScore")})]}),e.jsx(ct,{disabled:!R,multiline:!0,rows:5,name:"playerEngagement",label:"Player Engagement",customStyle:$e.textField,value:D.values.playerEngagement,handleChange:N})]})})})}),e.jsx(p,{size:{xs:12,sm:6},children:e.jsx(Ft,{sx:$e.card,children:e.jsx(Ht,{children:e.jsxs(p,{container:!0,direction:"column",gap:2,children:[e.jsxs(p,{container:!0,direction:"row",alignItems:"center",gap:2,flexWrap:"nowrap",children:[e.jsx(Dn,{step:1,min:0,max:10,marks:!0,value:D.values.coachBehaviorsScore,onChange:me("coachBehaviorsScore"),disabled:!R,sx:$e.slider}),e.jsx(ct,{disabled:!R,name:"coachBehaviorsScore",customStyle:$e.scoreInput,value:D.values.coachBehaviorsScore,inputProps:{style:{textAlign:"center"}},onKeyDown:j=>{!/[0-9]/.test(j.key)&&j.key!=="Backspace"&&j.key!=="Delete"&&j.key!=="ArrowLeft"&&j.key!=="ArrowRight"&&j.key!=="Tab"&&j.preventDefault()},handleChange:ae("coachBehaviorsScore")})]}),e.jsx(ct,{disabled:!R,multiline:!0,rows:5,name:"coachBehaviors",label:"Coach Behaviors",customStyle:$e.textField,value:D.values.coachBehaviors,handleChange:N})]})})})}),e.jsx(p,{size:{xs:12,sm:6},children:e.jsx(Ft,{sx:$e.card,children:e.jsx(Ht,{children:e.jsx(ct,{disabled:!R,multiline:!0,rows:I?5:7.7,name:"actionPoints",label:"Action Points",customStyle:{...$e.textField,height:I?"auto":"145px"},value:D.values.actionPoints,handleChange:N})})})})]})]})},Ce={container:{backgroundColor:n=>n.palette.common.white,paddingX:{xs:"16px",sm:"24px"},paddingTop:{xs:2,sm:3},paddingBottom:{xs:2,sm:3}}
2,avatar:{width:{xs:"50px",md:"60px",xl:"80px"},height:{xs:"50px",md:"60px",xl:"80px"},fontSize:{xs:"20px",md:"25px",xl:"30px"}},iconButton:{height:"40px",width:"40px"},heading:{fontSize:{xs:"16px",md:"22px",xl:"28px"},fontWeight:700,lineHeight:{xs:"unset",md:"48px"},cursor:"pointer","&:hover":{color:"primary.main"}},secondaryText:{color:"text.secondary",fontSize:"14px",lineHeight:"22px"},expandBtn:{fontSize:"13px",fontWeight:700,lineHeight:"22px",color:"text.primary",backgroundColor:"unset",padding:"4px 10px","&:hover":{backgroundColor:"unset"}},chip:{"& .MuiChip-label":{fontSize:"13px",lineHeight:"18px"},backgroundColor:n=>`${n.legend}29`},secondaryBtn:{bgcolor:n=>n.backgroundColor.skeleton,"&:hover":{bgcolor:"#C4CACE"},fontSize:{xs:"12px",md:"14px"},fontWeight:500,padding:"2px 13px",color:n=>n.palette.text.primary},eventRepeatIcon:{height:"14px",width:"14px"}},Ki=({isOpenManageDrawer:n,sessionDetails:s,setAnchorEl:_,coaches:c,handleSetContainerHeight:m,handleClickName:l=()=>{},canManage:O=!0,showIconButton:_e=!0,handleOpenClubSessionModal:g,handleNextSession:L=()=>{},loading:te=!1,isCreateMode:je=!1,handleOpenGrowthModal:I})=>{var b,T,le,q;const ne=Je(C=>C.breakpoints.down("md"));dt(C=>C.user.userPermission);const f=dt(C=>C.club),de=o.useRef(null),[X,M]=o.useState(!1),w=Je("(min-width:1100px) and (max-width:1400px)");o.useEffect(()=>{var C;de.current&&m((C=de.current)==null?void 0:C.offsetHeight)},[de.current,s,c]);const he=()=>{M(!X)};return je?e.jsx(p,{container:!0,minHeight:"180px",direction:"column",justifyContent:"center",alignContent:"center"}):te?e.jsx(p,{container:!0,minHeight:"180px",direction:"column",justifyContent:"center",alignContent:"center",children:e.jsx(Sn,{})}):e.jsx(e.Fragment,{children:e.jsxs(p,{container:!0,width:"100%",sx:Ce.container,ref:de,children:[e.jsxs(p,{container:!0,gap:2,size:"grow",wrap:"nowrap",children:[s.teamId&&e.jsx(Wt,{alt:s.teamName,src:s.teamLogo?`${Fn}/${s.teamLogo}`:"",sx:{...Ce.avatar,bgcolor:(ho(f==null?void 0:f.color,s.teamName)||fo(s.teamName)).backgroundColor},children:e.jsx(S,{sx:{color:(ho(f==null?void 0:f.color,s.teamName)||fo(s.teamName)).color,fontWeight:600,fontSize:"inherit"},children:hn(s.teamName)})}),e.jsxs(p,{container:!0,direction:"column",justifyContent:"center",children:[e.jsxs(p,{container:!0,alignItems:"center",gap:2,children:[e.jsx(S,{onClick:O&&s.club_id===f.id?l:()=>{},sx:Ce.heading,children:s.session_name}),s.teamId&&e.jsx(p,{container:!0,gap:1,display:{xs:"none",...n&&w?{xl:"flex"}:{lg:"flex"}},children:c.map((C,R)=>e.jsx(p,{children:e.jsx(ut,{sx:Ce.chip,avatar:e.jsx(Wt,{alt:C.name,src:(C==null?void 0:C.url)||"/",children:e.jsx(S,{sx:{fontSize:"11px"},children:hn(C.name)})}),label:C.name})},R))})]}),e.jsxs(p,{container:!0,alignItems:"center",gap:1,display:{xs:"none",...n&&w?{xl:"flex"}:{md:"flex"}},children:[e.jsx(S,{sx:Ce.secondaryText,children:s.teamName}),e.jsx(S,{sx:Ce.secondaryText,children:"â¢"}),e.jsxs(S,{sx:Ce.secondaryText,children:["Session Type: ",(b=bo.find(C=>C.id===s.session_type))==null?void 0:b.name]}),e.jsx(S,{sx:Ce.secondaryText,children:"â¢"}),e.jsxs(S,{sx:Ce.secondaryText,children:["Duration: ",`${s.duration} Minutes`]}),e.jsx(S,{sx:Ce.secondaryText,children:"â¢"}),(s==null?void 0:s.teamId)&&e.jsxs(e.Fragment,{children:[e.jsxs(S,{sx:Ce.secondaryText,children:["Surface:"," ",(T=Co.find(C=>C.id===s.surface))==null?void 0:T.name]}),e.jsx(S,{sx:Ce.secondaryText,children:"â¢"})]}),e.jsx(S,{sx:Ce.secondaryText,children:`Area Size: ${s.area_size||0}`})]})]})]}),e.jsxs(p,{container:!0,height:"fit-content",children:[e.jsxs(p,{container:!0,gap:2,alignContent:"center",children:[!s.teamId&&!ne&&(!n||!w)&&e.jsx(Fe,{customStyles:Ce.secondaryBtn,text:"Add to Team Session",onClick:()=>g(),startIcon:ne?void 0:e.jsx(ts,{})}),O&&!ne&&(!n||!w)&&e.jsx(p,{container:!0,direction:"column",gap:2,children:s.teamId&&e.jsx(Fe,{customStyles:Ce.secondaryBtn,text:"Go to Upcoming Session",onClick:()=>L(),startIcon:e.jsx(jo,{})})})]}),_e&&e.jsx(Gt,{sx:Ce.iconButton,onClick:C=>{C.stopPropagation(),_(C.currentTarget)},children:e.jsx(ni,{})})]}),e.jsxs(p,{container:!0,display:{xs:"block",...n&&w?{xl:"none"}:{md:"none"}},bgcolor:"common.white",width:"100%",children:[e.jsxs(p,{container:!0,gap:1,children:[e.jsx(S,{sx:Ce.secondaryText,children:s.teamName}),e.jsx(S,{sx:Ce.secondaryText,children:"â¢"}),e.jsxs(S,{sx:Ce.secondaryText,children:["Session Type: ",(le=bo.find(C=>C.id===s.session_type))==null?void 0:le.name]})]}),e.jsx(Jo,{in:X,timeout:"auto",children:e.jsxs(p,{container:!0,gap:1,pt:1,children:[e.jsx(S,{sx:Ce.secondaryText,children:"â¢"}),e.jsxs(S,{sx:Ce.secondaryText,children:["Duration: ",`${s.duration} Minutes`]}),e.jsx(S,{sx:Ce.secondaryText,children:"â¢"}),e.jsxs(S,{sx:Ce.secondaryText,children:["Surface:"," ",(q=Co.find(C=>C.id===s.surface))==null?void 0:q.name]}),e.jsx(S,{sx:Ce.secondaryText,children:"â¢"}),e.jsx(S,{sx:Ce.secondaryText,children:`Area Size: ${s.area_size||0}`}),e.jsx(p,{container:!0,gap:1,width:"100%",children:c.map((C,R)=>e.jsx(p,{children:e.jsx(ut,{sx:Ce.chip,avatar:e.jsx(Wt,{alt:C.name,src:c?C==null?void 0:C.url:"/",children:e.jsx(S,{sx:{fontSize:"11px"},children:hn(C.name)})}),label:C.name})},R))})]})}),e.jsxs(p,{container:!0,justifyContent:"space-between",alignItems:"center",pt:1,children:[e.jsx(Fe,{disableRipple:!0,customStyles:Ce.expandBtn,text:`${X?"Show Less":"Show More"}`,onClick:he}),s.teamId&&e.jsx(Fe,{customStyles:Ce.secondaryBtn,text:"Go to Upcoming Session",onClick:()=>L(),startIcon:e.jsx(jo,{sx:Ce.eventRepeatIcon})})]})]})]})})},Wn=n=>o.createElement("svg",{width:20,height:20,viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",...n}
2,o.createElement("path",{d:"M3.30919 12.4731C2.93223 12.742 1.85522 13.5753 1.66675 14.543H4.95162C4.76315 13.5753 3.68614 12.742 3.30919 12.4731Z",fill:"currentColor"}),o.createElement("path",{d:"M16.3411 13.7901L15.6679 10.9675H8.34427L7.67114 13.7901H16.3411Z",fill:"currentColor"}),o.createElement("path",{d:"M5.5709 3.33325C5.19395 3.60207 4.11694 4.43539 3.92847 5.40313H7.21334C7.02486 4.43539 5.94786 3.60207 5.5709 3.33325Z",fill:"currentColor"}),o.createElement("path",{d:"M4.4398 7.90283C4.06285 8.17165 2.98584 9.00497 2.79736 9.97271H6.08224C5.89376 9.00497 4.81675 8.17165 4.4398 7.90283Z",fill:"currentColor"}),o.createElement("path",{d:"M15.5601 10.4307L14.887 7.63501H9.15189L8.47876 10.4307H15.5601Z",fill:"currentColor"}),o.createElement("path",{d:"M17.5255 17.3389H17.3909H6.62078H6.48615C6.05535 17.3389 5.70532 17.6883 5.70532 18.1184V18.3335H18.3332V18.1184C18.3332 17.6883 17.9563 17.3389 17.5255 17.3389Z",fill:"currentColor"}),o.createElement("path",{d:"M16.4756 14.3279H7.53645L6.94409 16.801H17.068L16.4756 14.3279Z",fill:"currentColor"}),o.createElement("path",{d:"M14.7523 7.09673L14.0791 4.27417H9.93265L9.25952 7.09673H14.7523Z",fill:"currentColor"}),o.createElement("path",{d:"M13.9446 3.73662L13.5138 1.8818C13.4869 1.74739 13.3792 1.66675 13.2446 1.66675H10.7674C10.6328 1.66675 10.5251 1.74739 10.4982 1.8818L10.0674 3.73662H13.9446Z",fill:"currentColor"})),Ji=(n,s,_,c,m)=>({container:{padding:3,borderRadius:"16px",bgcolor:_?l=>l.primary.lighter:l=>l.backgroundColor.light,border:c&&n===s?l=>`2px solid ${l.palette.primary.main}`:l=>`2px dashed ${l.primary.lighter}`,boxShadow:c&&n===s?"0 8px 16px 0 rgba(47, 128, 237, 0.24);":"",cursor:m?"pointer":"default",transition:"border-color 0.2s, box-shadow 0.2s, background-color 0.2s","&:hover":m?{border:l=>`2px solid ${l.palette.primary.main}`,boxShadow:"0 4px 12px 0 rgba(47, 128, 237, 0.16)",bgcolor:l=>l.primary.lighter}:{}},iconContainer:{"& svg":{color:l=>_?l.palette.primary.dark:l.legend}},heading:{fontSize:"18px",fontWeight:700,lineHeight:"28px",color:l=>l.palette.text.primary,textAlign:{xs:"center",sm:"left"}},subtext:{fontSize:"16px",fontWeight:400,lineHeight:"24px",color:l=>l.palette.text.primary,textAlign:{xs:"center",sm:"left"}},button:{borderRadius:"8px",padding:"6px 16px",fontSize:"14px",fontWeight:700,lineHeight:"24px",height:"36px",border:l=>`1px solid ${l.button.borderColor.primary}`}}),Qi=({sectionType:n,isOpenManageDrawer:s,handleOpenManageDrawer:_,selectedTabKey:c,isDragging:m=!1,canAddActivity:l=!0})=>{const O=Ji(n,c,m,s,l);return e.jsxs(p,{container:!0,sx:O.container,onClick:l?()=>_(n):null,gap:{xs:1,sm:3},alignItems:"center",flexDirection:{xs:"column",sm:"row"},children:[e.jsx(p,{sx:O.iconContainer,children:e.jsx(Hi,{})}),e.jsxs(p,{flex:1,container:!0,direction:"column",gap:{xs:1,sm:0},children:[e.jsx(S,{sx:O.heading,children:"Select or drag and drop practices to session"}),e.jsxs(S,{sx:O.subtext,children:["Any videos or images added here will form part of your ",Ii(n).toLowerCase(),"."]})]}),l&&!s&&e.jsx(Fe,{startIcon:e.jsx(Wn,{color:"primary"}),text:"Add Activity",variant:"outlined",onClick:_e=>{_e.stopPropagation(),_(n)},customStyles:O.button})]})},lt={deleteBtn:{height:"36px",fontSize:{xs:"13px",lg:"16px"},padding:"11px 16px",borderColor:n=>n.availability.unavailable,color:n=>n.availability.unavailable,"&:hover":{borderColor:n=>n.availability.unavailable}},btn:{height:"36px",color:"text.primary",padding:"11px",borderColor:n=>n.border,"&:hover":{borderColor:n=>n.border},"& span":{margin:0}},copyBtn:{height:"36px",fontSize:{xs:"13px",lg:"16px"}
2,padding:"11px 16px",whiteSpace:"nowrap"},divider:{color:n=>n.divider},secondaryBtn:{height:"48px",borderRadius:"8px",borderColor:n=>n.availability.unavailable,color:n=>n.availability.unavailable,"&:hover":{borderColor:n=>n.availability.unavailable}}};function Ro({session:n,openGrowthModal:s,handleCloseGrowthModal:_,sessionPractices:c={},setSessionPractices:m=()=>{},selectedTabKey:l="",isOpenManageDrawer:O,containerHeight:_e,sections:g=[],updatePracticesPosition:L=()=>{},selectedSessionStructure:te=[],sessionStructureLoading:je,saveInProgressLoader:I,sessionLoading:ne,handleOpenManageDrawer:f,isDragStart:de,isCreateMode:X,refetchSession:M=()=>{}}){var Jt,Lt,Qt,Xt,ye;const{t:w}=gn("engineRoom"),[he]=Ut(),b=dt(d=>d.club),T=At(),{isReadOnlyMode:le,isUpcomingSeason:q}=Yt();T.club_id?T.club_id:b.club_id&&b.club_id,b.club_created_by;const C=o.useRef({}),R=o.useRef(null),D=qt(),we=Vs(),N=o.useRef(new Ti),[me,ae]=o.useState(0),[A,oe]=o.useState(0),[B,ie]=o.useState(!1),[Se,j]=o.useState(!1),[z,i]=o.useState(!1),[h,t]=o.useState(null),[F,E]=o.useState([]),[v,ke]=o.useState(!1),[Le,We]=o.useState(!1),[k,Ve]=o.useState({}),[be,nt]=o.useState(!1);De(Aa);const[ot]=De(ka),[pt]=De(Pa),[xt]=De(Ma),x=Je(d=>d.breakpoints.down("sm")),U=Je(d=>d.breakpoints.down("md")),K=Je(d=>d.breakpoints.down("lg")),[ue,V]=o.useState(null),[Ie,Z]=o.useState(!1),[He,Pe]=o.useState(!1),ht=`${ua.CLOUDFRONT_DOMAIN}/${ma.IMAGES.SESSION_PLANNER.THUMBNAILS}`,Ge=((Xt=(Qt=(Lt=(Jt=T==null?void 0:T.userRolesPermissions)==null?void 0:Jt.permissions)==null?void 0:Lt.dugout)==null?void 0:Qt.sessions)==null?void 0:Xt.manage)===Vt.YES&&(!le||q),qe=async d=>{var J;j(!0);const H=F.length?F.map(se=>se.id):[d],P=Object.values(c).flat().filter(se=>H.includes(se.id)).map(se=>({id:se.id,source:se.source,engine_room_video_id:se.engine_room_video_id,session_planner_practice_id:se.session_planner_practice_id})),pe=await ot({variables:{deleteSessionPracticeInput:{practices:P}}});(J=pe==null?void 0:pe.data)!=null&&J.deleteSessionPractice.success&&(oe(se=>se-H.length),he({msg:`${(P==null?void 0:P.length)>1?"Practices deleted successfully":"Practice deleted successfully"}`,variant:"success"}),$(),Qe(),at()),j(!1),M()},Qe=async d=>{var pe,J;ie(!0);const H=await D.query({query:ia,variables:{sessionPracticeListingInput:{title:d,training_session_id:n.id,pagination:!1}},fetchPolicy:"no-cache"}),y=(J=(pe=H==null?void 0:H.data)==null?void 0:pe.sessionPracticeListing)==null?void 0:J.data,P=y==null?void 0:y.practices.reduce((se,Re)=>{const r=Re.training_session_structure_id?te.find(ge=>ge.structureId===Re.training_session_structure_id):te.find(ge=>+ge.id===Re.session_structure_type_id);if(r){const ge=r.sectionKey||r.title;se[ge]||(se[ge]=[]),se[ge].push(Re)}return se},{});m(P),oe(y==null?void 0:y.count),ie(!1)},st=d=>{if(typeof d=="number"){const y=Object.values(c).flat().find(P=>P.id===d);t(y)}i(!0)},at=()=>{i(!1)},$=()=>{E([])},G=()=>{E(ki(c))},fe=(d,H,y,P,pe="",J,se)=>{Ve({...J,id:d||J.id,source:H,title:y,url:P,videoCollectionId:pe,mediaType:"video",type:se,practiceId:J.id}),E([J]),Z(!0)},Te=()=>{Ve({}),E([]),Z(!1)};o.useEffect(()=>{N.current.reset()},[k==null?void 0:k.id,n==null?void 0:n.id]);const Ne=o.useCallback(()=>({session_id:dn(n==null?void 0:n.id),practice_id:dn((k==null?void 0:k.practiceId)||(k==null?void 0:k.id)),video_id:dn(k==null?void 0:k.id),collection_id:dn(k==null?void 0:k.videoCollectionId),media_source:Ai(k==null?void 0:k.source),surface:"dugout_session"}),[n==null?void 0:n.id,k==null?void 0:k.practiceId,k==null?void 0:k.id,k==null?void 0:k.source]),Me=o.useCallback(()=>{if(!N.current.markStarted())return;const d=Ne();!d.session_id||!d.practice_id||!d.video_id||we.capture(go.DUGOUT_SESSION_VIDEO_WATCHED,{customData:d})},[we,Ne]),Mt=o.useCallback(({playedSeconds:d})=>{const H=N.current.recordProgress(d),y=Ne();if(!(!y.session_id||!y.practice_id||!y.video_id))for(const P of H.milestones)we.capture(go.DUGOUT_SESSION_VIDEO_PROGRESS,{customData:{...y,milestone_percent:P}})},[we,Ne]),yn=o.useCallback(d=>{N.current.setDuration(d)},[]),vn=(d,H)=>{const y={id:d,mediaType:"image",source:"SESSION_PLANNER",type:H,practiceId:d};Ve(y),E([y]),Z(!0)},Zt=()=>{Ve({}),E([]),Z(!1)},Ue=()=>{Ve({}),E([]),Z(!1)},Xe=()=>{nt(!0)},_n=()=>{nt(!1)},it=(d,H,y)=>{const P=[...c[y]||[]],[pe]=P.splice(d,1);return P.splice(H,0,pe),{...c,[y]:P}},Ze=(d,H)=>{const y=g.findIndex(J=>
2J.type===H),P=c[H]||[];if(d===P.length-1&&y<g.length-1){const J=g[y+1].type,se=c[J]||[],Re=P[d],r=[...P];r.splice(d,1);const ge=se.some(gt=>gt.video_id===Re.video_id)?se:[Re,...se],ft={...c,[H]:r,[J]:ge};m(ft),L(ft),V(`${J}-0`)}else{const J=it(d,d+1,H);m(J),L(J),V(`${H}-${d+1}`)}},rt=(d,H)=>{const y=g.findIndex(J=>J.type===H),P=c[H]||[];if(d===0&&y>0){const J=g[y-1].type,se=c[J]||[],Re=P[d],r=[...P];r.splice(d,1);const ge=se.some(gt=>gt.video_id===Re.video_id)?se:[...se,Re],ft={...c,[H]:r,[J]:ge};m(ft),L(ft),V(`${J}-${ge.length-1}`)}else{const J=it(d,d-1,H);m(J),L(J),V(`${H}-${d-1}`)}},Ye=()=>{const d=Object.fromEntries(Object.entries(c).map(([H,y])=>[H,[...y].sort(()=>Math.random()-.5)]));m(d),L(d)},Dt=async(d,H)=>{const{data:y}=await xt({variables:{updateSessionPracticeCoachNotesInput:{id:d,coach_notes:H}}});if(y.updateSessionPracticeCoachNotes.success){const P=Object.fromEntries(Object.entries(c).map(([pe,J])=>[pe,J.map(se=>se.id===d?{...se,practice_coach_notes:H}:se)]));m(P),he({msg:"Practice coach notes updated successfully",variant:"success"})}},Ot=async(d,H,y)=>{var pe,J;const P=await pt({variables:{updateCollectionNotesInput:{collectionId:H,notes:y}}});if((J=(pe=P==null?void 0:P.data)==null?void 0:pe.updateCollectionClubNotes)!=null&&J.success){const se=Object.fromEntries(Object.entries(c).map(([Re,r])=>[Re,r.map(ge=>ge.id===d?{...ge,engine_room_practice_club_notes:y}:ge)]));m(se),he({msg:"Practice club notes updated successfully",variant:"success"})}},Kt=async(d,H,y)=>{var pe;const P=await Ws({url:"/update-practice-club-notes",method:"POST",data:{club_notes:y,id:H}});if((pe=P==null?void 0:P.data)!=null&&pe.success){const J=Object.fromEntries(Object.entries(c).map(([se,Re])=>[se,Re.map(r=>r.id===d?{...r,session_planner_practice_club_notes:y}:r)]));m(J),he({msg:"Practice club notes updated successfully",variant:"success"})}},wn=(d,H)=>{m(y=>({...y,[H]:y[H].filter(P=>P.id!==d)})),Pe(!0)};o.useEffect(()=>{n!=null&&n.id&&te.length&&!X?Qe():n!=null&&n.id&&!te.length&&!X&&ie(!1)},[me,n.id,te]),o.useEffect(()=>{if(ue){const d=document.getElementById(`practice-card-${ue}`),H=R.current;if(H&&d){V("");const y=d.getBoundingClientRect(),P=H.getBoundingClientRect();(y.top<P.top||y.bottom>P.bottom)&&H.scrollTo({top:H.scrollTop+(y.top-P.top)-H.clientHeight/2+y.height/2,behavior:"smooth"})}else if(d){const y=document.querySelector("main");if(!y)return;V("");const P=d.getBoundingClientRect(),pe=y.getBoundingClientRect();y.scrollTo({top:y.scrollTop+(P.top-pe.top)-y.clientHeight/2+P.height/2,behavior:"smooth"})}}},[ue]);const Gn=(d,H=200)=>{const y=C.current[d];if(!y)return;let P=y.parentElement;for(;P&&P!==document.body;){const pe=window.getComputedStyle(P);if(pe.overflowY==="auto"||pe.overflowY==="scroll")break;P=P.parentElement}if(P){const pe=y.offsetTop-P.offsetTop-H;P.scrollTo({top:pe>0?pe:0,behavior:"smooth"})}};return o.useEffect(()=>{l&&O&&!He&&Gn(l),Pe(!1)},[l,O,(ye=c[l])==null?void 0:ye.length]),e.jsxs(e.Fragment,{children:[!O&&!!F.length&&e.jsx(Qs,{items:F,title:"Practice",deleteBtnText:"Practices",handleDeleteMultiple:()=>{},flexDirection:x?"column":"row",secondaryElement:x?e.jsxs(yo,{children:[e.jsx(mt,{title:"Select All",children:e.jsx(Fe,{onClick:G,startIcon:e.jsx(vo,{}),variant:"outlined",customStyles:lt.btn})}),e.jsx(mt,{title:"Deselect All",children:e.jsx(Fe,{onClick:$,startIcon:e.jsx(_o,{}),variant:"outlined",customStyles:lt.btn})})]}):null,rightElement:e.jsxs(p,{container:!0,gap:{xs:1,lg:2},flexWrap:"nowrap",children:[!x&&e.jsxs(e.Fragment,{children:[e.jsxs(yo,{children:[e.jsx(mt,{title:"Select All",children:e.jsx(Fe,{onClick:G,startIcon:e.jsx(vo,{}),variant:"outlined",customStyles:lt.btn})}),e.jsx(mt,{title:"Deselect All",children:e.jsx(Fe,{onClick:$,startIcon:e.jsx(_o,{}),variant:"outlined",customStyles:lt.btn})})]}),e.jsx(Ko,{flexItem:!0,sx:lt.divider,orientation:"vertical"})]}),e.jsx(Fe,{onClick:Xe,text:"Copy to New Session",variant:"outlined",customStyles:lt.copyBtn,fullWidth:x}),e.jsx(Fe,{onClick:Ye,text:"Shuffle",variant:"outlined",customStyles:lt.copyBtn,fullWidth:x}),e.jsx(Fe,{onClick:st,text:"Delete",variant:"outlined",customStyles:lt.deleteBtn,fullWidth:x})]})}),e.jsx(ee,{height:"inherit",children:!O&&B||je||I||ne?e.jsx(Sn,{}):e.jsxs(ee,{py:2,ref:n!=null&&n.session_status&&x?R:null,sx:n!=null&&n.session_status&&x?{maxHeight:"72dvh",overflowY:"auto",overscrollBehavior:"contain"}:void 0,children:[x&&Ge&&e.jsx(p,{container:!0,px:3,justifyContent:"end",children:e.jsx(Fe,{startIcon:e.jsx(Wn,{}),text:Object.values(c).flat().length>0?"Edit Activities":"Add Activity",customStyles:lt.practiceBtn,onClick:()=>f()})}),g.map((d,H)=>{var P,pe,J,se,Re;const y=g.findIndex(r=>r.type===d.type);return e.jsx(vi,{direction:"vertical",droppableId:d.type,height:"100%",children:e.jsxs(ee,{sx:Ge?{"&:hover > .section-title-row .section-title":{color:r=>r.palette.primary.main}}:{},children:[e.jsxs(p,{container:!0,alignItems:"center",justifyContent:"space-between",pt:2,pb:1,px:3,className:"section-title-row",children:[e.jsxs(S,{fontWeight:700,fontSize:"18px",className:"section-title",sx:{color:"text.primary",transition:"color 0.2s"},children:[d.title," (",((P=c[d.type])==null?void 0:P.length)||0,")"]}),Ge&&!O&&((pe=c[d.type])==null?void 0:pe.length)>0&&e.jsx(S,{sx:{fontSize:"13px",fontWeight:600,color:r=>r.palette.primary.main,cursor:"pointer"},onClick:r=>{r.stopPropagation(),f(d.type)},children:"+ Add Activity"})]}),((J=c[d.type])==null?void 0:J.length)>0&&((se=c[d.type])==null?void 0:se.map((r,ge)=>{var en,tn,Nt,nn,vt,En,re,on,sn,_t;
2const ft=ge===0,gt=ge===((en=c[d.type])==null?void 0:en.length)-1;return e.jsx(_i,{index:ge,draggableId:`${r.id}-${d.type}-${ge}`,isDragDisabled:!Ge,children:e.jsx(ee,{p:O?"0 48px 16px 24px":"0 24px 16px",ref:((tn=c[d.type])==null?void 0:tn.length)-1===ge?Rt=>C.current[d.type]=Rt:null,sx:{},children:e.jsx(Ei,{dugout:!0,hoverable:Ge,isOpenManageDrawer:O,teamId:!O&&(n==null?void 0:n.team_id),type:d.type,index:ge,showSortArrow:K||U,isSelectable:Ge&&!O,showRemoveIcon:Ge?!F.length:!1,practice:r,chips:r==null?void 0:r.chips,title:(r==null?void 0:r.title)||(r==null?void 0:r.work_title),description:(r==null?void 0:r.short_description)||(r==null?void 0:r.description)||(r==null?void 0:r.long_description)||(r==null?void 0:r.work_description),coachNotes:(r==null?void 0:r.practice_coach_notes)||(r.source==="ENGINE_ROOM"?r==null?void 0:r.engine_room_practice_coach_notes:r==null?void 0:r.session_planner_practice_coach_notes),canManageClubNotes:(r==null?void 0:r.source)==="ENGINE_ROOM"?((En=(vt=(nn=(Nt=T==null?void 0:T.userRolesPermissions)==null?void 0:Nt.permissions)==null?void 0:nn.engineRoom)==null?void 0:vt.clubNotes)==null?void 0:En.manage)===Vt.YES:((_t=(sn=(on=(re=T==null?void 0:T.userRolesPermissions)==null?void 0:re.permissions)==null?void 0:on.sessionPlanner)==null?void 0:sn.general)==null?void 0:_t.manageClubNotes)===Vt.YES,clubNotes:r.source==="ENGINE_ROOM"?r==null?void 0:r.engine_room_practice_club_notes:r==null?void 0:r.session_planner_practice_club_notes,players:r==null?void 0:r.players,overview:r==null?void 0:r.overview,imageUrl:(r==null?void 0:r.preview_image_url)||(r==null?void 0:r.main_poster_url)||Ci(ht,r.thumbnail),checked:F.map(Rt=>Rt.id).includes(r==null?void 0:r.id),mediaType:(r==null?void 0:r.media_type)||!1,practiceSource:r.source,selectedPractices:F,setSelectedPractices:E,handleRemovePractice:O?()=>wn(r.id,d.type):()=>qe(r.id),handleOpenVideoModal:fe,handleOpenImageModal:vn,showArrowUpward:!(y===0&&ft),showArrowDownward:!(y===g.length-1&>),handleClickDownward:()=>Ze(ge,d.type),handleClickUpward:()=>rt(ge,d.type),handleUpdatePracticeCoachNotes:Dt,handleUpdatePracticeClubNotes:(r==null?void 0:r.source)==="ENGINE_ROOM"?Ot:Kt})})},`${r.id}-${d.type}-${ge}`)})),(de&&d.type===l||((Re=(c==null?void 0:c[d.type])||[])==null?void 0:Re.length)===0)&&e.jsx(ee,{px:3,ref:r=>C.current[d.type]=r,children:e.jsx(Qi,{sectionType:d.type,selectedTabKey:l,isOpenManageDrawer:O,handleOpenManageDrawer:f,isDragging:de&&d.type===l,canAddActivity:Ge})})]},d.type)})})]})}),e.jsx(Vn,{open:z,loading:Se,title:"Remove Practice?",handleClose:at,handleDelete:qe,actionBtnTitle:(F==null?void 0:F.length)>1?"Remove Practices":"Remove Practice",entityName:(F==null?void 0:F.length)>1?"Selected Practices":"Selected Practice"}),e.jsx(yi,{open:v,handleClose:Te,videoData:k,source:k==null?void 0:k.source,isMobileView:U}),e.jsx(Xs,{open:Le,handleClose:Zt,practiceId:k==null?void 0:k.id}),e.jsx(wi,{open:be,handleClose:_n,practices:F,handleDeselectAll:$,handleOpenAddPracticeToSessionModal:Xe,handleCloseMediaDetailModal:Ue}),e.jsx(ji,{open:s,handleClose:_,heading:"Unlock Unlimited Views With a Growth or Coach Bundle Max Plan",mainHeading:"Upgrade for Full Access!",description:w("limitExceeded")}),e.jsx(Ha,{title:"Add to Session",showSecondaryButton:!0,secondaryBtnTitle:"Remove Session",primaryBtnTitle:"Copy to Another Session",open:Ie,videoData:k,videoId:k==null?void 0:k.id,handleClose:Ue,handleOpenAddPracticeToSessionModal:Xe,onPlaybackStarted:Me,onPlaybackProgress:Mt,onPlaybackDuration:yn,customStylesSecondaryButton:lt.secondaryBtn,handleSecondaryButtonAction:O?()=>{wn(k.practiceId,k.type),Z(!1),E([])}:()=>{qe(k.practiceId),Z(!1),E([])}})]})}const Bo=({sessionId:n})=>{const s=Gs("replay_enabled"),{data:_,loading:c}=jn(Pi,{variables:{getVideosByContextInput:{context_type:"session",context_id:+n,limit:100,offset:0}},skip:!n||!s});return e.jsx(ri,{data:_,loading:c,contextType:"session",contextId:+n})},et={container:{height:"100%"},playerViewBtn:{height:{xs:"32px",sm:"40px"},whiteSpace:"nowrap",fontSize:{xs:"13px",sm:"16px"}},toggleBtn:{height:"40px",border:n=>({xs:0,sm:`1px solid ${n.palette.divider}`}),"& .MuiToggleButtonGroup-root ":{border:0,margin:"5px","& .MuiButtonBase-root":{border:0,margin:0,borderRadius:"8px"}}},practiceBtn:{whiteSpace:"nowrap",padding:"6px 16px",fontSize:"14px",fontWeight:700,lineHeight:"24px",height:"36px"},tab:{px:1,borderRadius:2,"&:hover":{backgroundColor:n=>`${n.palette.text.secondary}14`}},tabs:{"& .MuiTabs-flexContainer":{gap:1}}},ic=()=>{var oo,so,ao,io,ro,lo,co,uo,mo,po;const n=pa(),s=xa(),_=Us(),c=qt(),m=ha(),l=m.id==="create",O=localStorage.getItem("sessionType"),_e=dt(a=>{var u;return(u=a==null?void 0:a.teams)==null?void 0:u.team});dt(a=>{var u;return(u=a==null?void 0:a.app)==null?void 0:u.openDugoutAddPracticeModal});const[g]=Ut(),L=Je(a=>a.breakpoints.down("sm")),te=dt(a=>{var u,Y;return((Y=(u=a==null?void 0:a.app)==null?void 0:u.dataViews)==null?void 0:Y.sessionPlayerData)||"grid"}),je=dt(a=>{var u,Y;return(Y=(u=a==null?void 0:a.app)==null?void 0:u.dataViews)==null?void 0:Y.sessionPlayerDataDefaultViewSet}),[I]=De(Da),[ne]=De(Oa),f=dt(a=>a.user.userPermission),[de,X]=o.useState(null),[M,w]=o.useState(0),[he,b]=o.useState(0),[T,le]=o.useState(!1),[q,C]=o.useState(!1),R=o.useRef(0),[D,we]=o.useState(!1),[N,me]=o.useState(!1),[ae,A]=o.useState(!1),[oe,B]=o.use
2State(!1),[ie,Se]=o.useState(!1),[j,z]=o.useState(!1),[i,h]=o.useState(!1),[t,F]=o.useState({}),E=dt(a=>a.club),v=At(),ke=Je(a=>a.breakpoints.down("md")),Le=Je("(min-width:1100px) and (max-width:1400px)"),We=Je("(max-width:1200px)"),[k,Ve]=o.useState((ao=(so=(oo=v==null?void 0:v.userRolesPermissions)==null?void 0:oo.permissions)==null?void 0:so.dugout)==null?void 0:ao.sessions),{currentSeason:be,isAllSeasonSelected:nt,isReadOnlyMode:ot,isUpcomingSeason:pt}=Yt(),xt=(k==null?void 0:k.manage)===Vt.YES&&(!ot||pt),x={...k,isReadOnlySeason:ot&&!pt},[U,K]=o.useState([]),[ue,V]=o.useState(!1),[Ie,Z]=o.useState(),[He,Pe]=o.useState(!1),[ht,Ge]=o.useState(!1),[qe,Qe]=o.useState(!1),[st,at]=o.useState([]),[$]=De(La),[G]=De(Na),[fe,Te]=o.useState(!1),[Ne,Me]=o.useState(!1),[Mt]=De(Ra),[yn]=De(Ba),[vn,Zt]=o.useState(!1),[Ue,Xe]=o.useState({}),[_n,it]=o.useState(0),[Ze,rt]=o.useState(""),[Ye,Dt]=o.useState(null),[Ot,Kt]=o.useState({}),[wn,Gn]=o.useState(!1),[Jt,Lt]=o.useState(!1),[Qt,Xt]=o.useState([]),[ye,d]=o.useState([]),[H,y]=o.useState(!1),[P,pe]=o.useState(!1),[J,se]=o.useState(!1),[Re,r]=o.useState(!1),[ge,ft]=o.useState([]),[gt,en]=o.useState([]),tn=o.useRef(null),Nt=o.useRef(null),nn=o.useRef(null),vt=o.useRef(be==null?void 0:be.id),{navigator:En}=o.useContext(fa),[re,on]=o.useState(null),[sn,_t]=o.useState(!1),Rt=v==null?void 0:v.id,Un=(v==null?void 0:v.club_id)||(E==null?void 0:E.club_id)||0,[ss]=De(za),In=async()=>{var Y,Q,W;const a=await c.query({query:la,variables:{getSessionListLiteInput:{teams:_e,season_id:nt?null:be==null?void 0:be.id}},fetchPolicy:"no-cache"}),{success:u}=(Y=a==null?void 0:a.data)==null?void 0:Y.getSessionListLite;if(u){const ce=(((W=(Q=a==null?void 0:a.data)==null?void 0:Q.getSessionListLite)==null?void 0:W.data)||[]).map(Ae=>({...Ae,name:(Ae==null?void 0:Ae.team.name)||"",primaryText:Ae.name,secondaryText:Ae.practiceCount?`(${Ae.practiceCount} Activities)`:"(No Activities Added)"}));at(ce)}},Yn=async()=>{y(!0);const{data:{getTrainingSessionStructure:{data:a}}}=await c.query({query:ra,variables:{getTrainingSessionStructureInput:{session_id:+(m==null?void 0:m.id)}},fetchPolicy:"no-cache"}),u=a.map(W=>{const{session_structure_type:Ee}=W;return{...Ee,id:Ee.id.toString(),structureId:W.id,label:Ee.title,draggable:!0,sort:!0}}),Y={};u.forEach(W=>{Y[W.title]=(Y[W.title]||0)+1});const Q={};u.forEach(W=>{Q[W.title]=(Q[W.title]||0)+1,W.sectionKey=Y[W.title]>1?`${W.title} (${Q[W.title]})`:W.title}),d(u),y(!1)},an=async a=>{const u=Object.entries(a).flatMap(([Y,Q])=>{const W=ye.find(Ee=>(Ee.sectionKey||Ee.title)===Y);return Q.map((Ee,ce)=>({id:Ee.id,position:ce+1,session_structure_type_id:+(W==null?void 0:W.id),training_session_structure_id:(W==null?void 0:W.structureId)||null}))});await ne({variables:{updateSessionPracticePositionInput:{practices:u,training_session_id:t==null?void 0:t.id}}})};o.useEffect(()=>{t!=null&&t.id&&Yn()},[t]),o.useEffect(()=>{In()},[_e,t==null?void 0:t.id,be==null?void 0:be.id,nt]);const Ct=async(a=!0)=>{var Q,W,Ee;const u=+(m==null?void 0:m.id);if(!u)return;const Y=++R.current;le(a),C(!1);try{const ce=await c.query({query:ca,variables:{session_id:u},fetchPolicy:"no-cache",context:{queryDeduplication:!1}});if(Y!==R.current)return;if(((W=(Q=ce==null?void 0:ce.data)==null?void 0:Q.dugoutSessionDetail)==null?void 0:W.success)&&((Ee=ce.data.dugoutSessionDetail.data)!=null&&Ee.id)){const kt=ce.data.dugoutSessionDetail.data,ln=kt.session_coaches.map(({User:{id:wt,username:jt,lastname:yt,profile_image:Et}})=>({id:wt,name:`${jt} ${yt}`,url:Et?`${Fn}/${Et}`:""}));K([...ln]),F(wt=>({...wt,...Li(ce.data.dugoutSessionDetail.data,(jt,yt)=>yt==="team"?"teamData":yt),team_players:kt.Training_session_players.map(jt=>jt.player_id),coach_ids:Ys(ln),dugout_session_practices:kt.dugout_session_practices.sort((jt,yt)=>jt.position-yt.position)}))}else F({}),K([]),C(!0)}catch{Y===R.current&&(F({}),K([]),C(!0))}finally{Y===R.current&&le(!1)}},as=async()=>{var Q;Pe(!0);const a=await $({variables:{ids:[t==null?void 0:t.id]}}),{success:u,message:Y}=(Q=a==null?void 0:a.data)==null?void 0:Q.duplicateClubSession;u&&g({msg:Y||"Core session duplicated successfully",variant:"success"}),Qn(),Pe(!1)},qn=()=>{re!=null&&re.hasUnsavedChanges?St():Qe(!0)},is=()=>{Qe(!1)},rs=()=>{V(!0)},ls=()=>{V(!1)},Tn=()=>{Se(!0)},Zn=()=>{Se(!1)},An=()=>{h(!0)},cs=()=>{h(!1)},ds=a=>{X(a)},us=()=>{X(null)},ms=(a,u)=>{w(u)},ps=a=>{b(a)},Kn=()=>{A(!1)},xs=(a=!1)=>{we(!1),z(!0),a&&Ct()},Jn=()=>{B(!1)},hs=async()=>{var Y;var a=await ss({variables:{ids:t.id.toString(),type:1,club_id:v.club_id?v.club_id:E.club_id}});const{success:u}=(Y=a==null?void 0:a.data)==null?void 0:Y.deleteTraining;u&&(Jn(),n("/dugout/sessions",{replace:!0}))},Bt=a=>{var u,Y;if(N||(rt(((u=ye[0])==null?void 0:u.sectionKey)||((Y=ye[0])==null?void 0:Y.title)),it(0),w(0)),a){const Q=gt.findIndex(W=>W.title===a);rt(a),it(Q)}me(!0)},kn=(a=!1,u=!1)=>
2{if(u){n(-1),me(!1),le(!0);return}me(!1),it(0),z(!0),a&&Ct()},fs=()=>{A(!0)},gs=()=>{B(!0)},Ss=async a=>{var Ee;Pe(!0);const u=await I({variables:a}),{success:Y,message:Q,data:W}=(Ee=u==null?void 0:u.data)==null?void 0:Ee.duplicateSession;if(Y){const ce=JSON.parse(W);ce.length===1&&(Z(ce[0].id),rs()),In(),g({msg:Q||"Session(s) Duplicated",variant:"success"})}else g({msg:"Something went wrong, please try again later",variant:"error"});Pe(!1),Kn()};o.useEffect(()=>{je||(_(cn({sessionPlayerData:L?"grid":"list"})),L&&_(cn({sessionPlayerDataDefaultViewSet:!0})))},[L]),o.useEffect(()=>{var Y,Q,W,Ee,ce,Ae;const a=(Q=(Y=v==null?void 0:v.userRolesPermissions)==null?void 0:Y.permissions)==null?void 0:Q.dugout,u=f.planId===4?{addToGlobalLibrary:(Ae=(ce=(Ee=(W=v==null?void 0:v.userRolesPermissions)==null?void 0:W.permissions)==null?void 0:Ee.globalLibrary)==null?void 0:ce.general)==null?void 0:Ae.add}:{};t!=null&&t.teamId?Ve({...a.sessions,...u}):Ve({...a.clubSessions,...u})},[t]);const bs=(a,u)=>{_(cn({sessionPlayerData:u})),je||_(cn({sessionPlayerDataDefaultViewSet:!0}))},Cs=()=>{Ge(!ht)},js=async()=>{const{data:{createSaveForLaterEntry:{success:a,message:u,status:Y}}}=await yn({variables:{createSaveForLaterItemInput:{type:Ca.DUGOUT_CLUB_SESSION,item_id:t==null?void 0:t.id}}});a?g({msg:u||"Item saved successfully.",variant:"success"}):!a&&Y===409&&g({msg:u||"This item has already been saved.",variant:"success"})},St=()=>{Lt(!0)},ys=()=>{r(!0)},Qn=()=>{r(!1)},vs=async()=>{try{if(!(v!=null&&v.isSuperAdmin)){g({msg:"Unauthorized: Super admin access required",variant:"error"});return}if(!(t!=null&&t.id))return;const{data:a}=await G({variables:{copyTeamSessionsToClubSessionsInput:{session_ids:[+t.id]}}}),u=a==null?void 0:a.copyTeamSessionsToClubSessions;u!=null&&u.success?(c.cache.evict({id:"ROOT_QUERY",fieldName:"sessionListing"}),c.cache.gc(),g({msg:(u==null?void 0:u.message)||"Copied to Club Sessions",variant:"success"})):g({msg:(u==null?void 0:u.message)||"Failed to copy session",variant:"error"})}catch(a){g({msg:(a==null?void 0:a.message)||"Failed to copy session",variant:"error"})}},_s=()=>{Zt(!0)},Xn=()=>{Zt(!1)},eo=[{name:"Copy to Club Sessions",icon:Do,onClick:re!=null&&re.hasUnsavedChanges?St:_s,show:!!(t!=null&&t.team_id)&&(v==null?void 0:v.isSuperAdmin)},{name:"Add to Team Session",icon:Mo,onClick:re!=null&&re.hasUnsavedChanges?St:qn,show:(ke||Le&&N)&&!(t!=null&&t.team_id)},{name:"Add to Global Library",icon:Mi,onClick:()=>re!=null&&re.hasUnsavedChanges?St():Me(!0),show:!(t!=null&&t.team_id)},...(E==null?void 0:E.id)===(t==null?void 0:t.club_id)?[{name:"Manage",icon:Di,onClick:Bt,show:!0}]:[],{name:"Add New Team Session",icon:Mo,onClick:()=>{localStorage.setItem("openManageDrawerOnCreate","true"),localStorage.setItem("sessionType","teamSession"),n("/dugout/session/create")},show:!0},{name:"Add New Club Session",icon:ga,onClick:()=>{localStorage.setItem("openManageDrawerOnCreate","true"),localStorage.setItem("sessionType","clubSession"),n("/dugout/session/create")},show:!0},{name:"Export PDF",icon:Oi,onClick:re!=null&&re.hasUnsavedChanges?St:An,show:!0},{name:"Duplicate",icon:Do,onClick:()=>re!=null&&re.hasUnsavedChanges?St():t!=null&&t.team_id?fs():ys(),show:!0},{name:"Save for Later",icon:e.jsx(os,{style:{width:"14px",height:"14px"},fill:"#454F5B"}),onClick:re!=null&&re.hasUnsavedChanges?St:js,show:!(t!=null&&t.team_id)},...(E==null?void 0:E.id)===(t==null?void 0:t.club_id)?[{name:"Delete",icon:ns,onClick:re!=null&&re.hasUnsavedChanges?St:gs,show:!0}]:[]].filter(a=>a.show);o.useEffect(()=>{!l&&m.id&&Un&&Ct()},[m.id,v==null?void 0:v.club_id,E==null?void 0:E.club_id]),o.useEffect(()=>{var a,u;l&&localStorage.getItem("openManageDrawerOnCreate")==="true"&&(Xe({}),rt(((a=ye[0])==null?void 0:a.sectionKey)||((u=ye[0])==null?void 0:u.title)),me(!0),localStorage.removeItem("openManageDrawerOnCreate")),l&&!N&&me(!0)},[l]),o.useEffect(()=>{var a,u;t!=null&&t.id&&localStorage.getItem("openManageDrawerOnMange")==="true"&&(rt(((a=ye[0])==null?void 0:a.sectionKey)||((u=ye[0])==null?void 0:u.title)),me(!0),localStorage.removeItem("openManageDrawerOnMange"))},[t==null?void 0:t.id]),o.useEffect(()=>{var a,u;ye.length&&N&&(rt(((a=ye[0])==null?void 0:a.sectionKey)||((u=ye[0])==null?void 0:u.title)),it(0))},[ye]),o.useEffect(()=>{if(vt.current===void 0){vt.current=be==null?void 0:be.id;return}N&&vt.current!==(be==null?void 0:be.id)&&kn(),vt.current=be==null?void 0:be.id},[be==null?void 0:be.id,N,kn]),o.useEffect(()=>{if(ye.some(Q=>!Q.sectionKey)&&ye.length>0){const Q={};ye.forEach(ce=>{Q[ce.title]=(Q[ce.title]||0)+1});const W={},Ee=ye.map(ce=>{W[ce.title]=(W[ce.title]||0)+1;const Ae=Q[ce.title]>1?`${ce.title} (${W[ce.title]})`:ce.title;return ce.sectionKey===Ae?ce:{...ce,sectionKey:Ae}});d(Ee);return}const u=ye.map(({id:Q,title:W,sectionKey:Ee})=>({id:Number(Q),name:Ee||W,value:Ee||W}));Xt(u);const Y=ye.map(({title:Q,sectionKey:W})=>({type:W||Q,title:W||Q}));en(Y)},[JSON.stringify(ye)]);const ws=a=>{n(`/dugout/session/${a.id}`)},Es=()=>{const a=new Date,u=st.findIndex(Q=>new Date(Q.date)>a),Y=st[u];Y&&n(`/dugout/session/${Y.id}`)},Is=async()=>{var Y,Q,W;if(((Y=t==null?void 0:t.dugout_session_practices)==null?void 0:Y.length)>6){g({msg:"You can only add sessions that contain up to 6 practices.",variant:"error"}),Me(!1);return}Te(!0);const a={type:"DUGOUT_CLUB_SESSION",item_ids:[+(m==null?void 0:m.id)]},{data:u}=await Mt({variables:{createGlobalLibraryItemInput:a}});(Q=u==null?void 0:u.createGlobalLibraryEntry)!=null&&Q.success?g({msg:"Practice added to Global Library successfully",variant:"success"}):g({msg:((W=u==null?void 0:u.createGlobalLibraryEntry)==null?void 0:W.message)||"Failed to add practice to Global Library",variant:"error"}),Te(!1),Me(!1)},Ts=a=>{const{source:u}=a;u!=null&&u.droppableId&&se(!0)},to=({practice:a,tabTitle:u,source:Y,onCommit:Q})=>{if(Y==="SESSION_PLANNER"&&Va(a==null?void 0:a.practice_type_id,u)){Dt({practiceTypeId:a.practice_type_id,practiceName:a.work_title||a.title,tabTitle:u,onCommit:Q});return}Q()},As=()=>{Ye&&(Ye.onCommit(),Dt(null))},ks=()=>Dt(null),Ps=a=>
2{if(se(!1),f.planId<3){Tn();return}const{destination:u,source:Y,draggableId:Q}=a;if(!u)return;const[W,Ee]=Q.trim().split("-"),{droppableId:ce}=u,{droppableId:Ae}=Y;if(!Ae||!ce||ce==="mediaCards")return;const kt=(xe,ve)=>{if(xe.source!==ve.source)return!1;const Oe=xe.id;return xe.source==="ENGINE_ROOM"?Oe===ve.engine_room_video_id||Oe===ve.id||Oe===ve.video_id:xe.source==="SESSION_PLANNER"?Oe===ve.session_planner_practice_id||Oe===ve.id||Oe===ve.video_id:Oe===ve.id},ln=(xe,ve)=>xe.source===ve.source&&xe.id===ve.id;if(Ae!=="mediaCards"){if(Ae===ce){const xe=Array.from(Ue[Ae]||[]),[ve]=xe.splice(a.source.index,1);xe.splice(u.index,0,ve),Xe({...Ue,[Ae]:xe}),an({...Ue,[Ae]:xe})}else{const xe=Array.from(Ue[Ae]||[]),ve=Array.from(Ue[ce]||[]),[Oe]=xe.splice(a.source.index,1);ve.some(Ls=>kt(Oe,Ls))||ve.splice(u.index,0,Oe);const Be={...Ue,[Ae]:xe,[ce]:ve};Xe(Be),an(Be)}return}const wt=qs(Ze),jt=ge.filter(xe=>{var ve;return(ve=Ot[wt])!=null&&ve.length?Ot[wt].includes(xe.id):xe.id==W}).flatMap(xe=>xe.videos).filter(xe=>(xe==null?void 0:xe.source)==="ENGINE_ROOM"?!xe.title.toLowerCase().includes("trailer"):!0),yt=Ue[Ze]||[],Et=jt.filter(xe=>!yt.some(ve=>kt(xe,ve))).filter((xe,ve,Oe)=>Oe.findIndex(Be=>ln(Be,xe))===ve);if(Et.length){const xe=()=>{Xe(Be=>({...Be,[Ze]:[...Be[Ze]||[],...Et]})),Kt(Be=>({...Be,[wt]:[]}));const Oe=ye.findIndex(Be=>(Be.sectionKey||Be.title)===Ze)+1;if(Oe<ye.length){const Be=ye[Oe];rt(Be.sectionKey||Be.title),it(Oe)}};if(Et.length===1){const ve=Et[0],Oe=ye.find(Be=>(Be.sectionKey||Be.title)===Ze);to({practice:ve,tabTitle:(Oe==null?void 0:Oe.title)||Ze,source:ve.source,onCommit:xe})}else xe()}re==null||re.setHasUnsavedChanges(!0)},Ms=(a,u)=>{rt(u),it(a)},Ds=()=>{re==null||re.setHasUnsavedChanges(!1),re==null||re.handleSaveChanges(),no(),rn.state==="blocked"&&rn.proceed()},no=()=>{Lt(!1),rn.state==="blocked"&&rn.reset()};o.useEffect(()=>{var a;It((a=s.state)==null?void 0:a.notification)||g(s.state.notification)},[(io=s.state)==null?void 0:io.notification]);const rn=Sa(({currentLocation:a,nextLocation:u,historyAction:Y})=>{if(re.hasUnsavedChanges&&a.pathname!==u.pathname)return St(),!0}),Os=()=>{An(),_t(!1)};return o.useEffect(()=>{localStorage.getItem("openGeneratePdfAlertModal")&&(_t(!0),localStorage.removeItem("openGeneratePdfAlertModal"))},[localStorage.getItem("openGeneratePdfAlertModal")]),!l&&q?e.jsxs(ee,{role:"alert",p:3,children:[e.jsx(S,{children:"Session unavailable. It may have been deleted, your access may have changed, or the connection failed."}),e.jsx("button",{type:"button",onClick:()=>void Ct(),children:"Try again"}),e.jsx("a",{href:"/dugout/sessions",children:"Back to sessions"})]}):e.jsxs(p,{ref:tn,container:!0,flexDirection:"column",width:"100%",height:"100%",flexWrap:"nowrap",overflow:{xs:"none",md:"auto"},sx:{...N&&!We?{paddingRight:ba}:{}},children:[e.jsxs(ee,{sx:{backgroundColor:a=>a.palette.common.white,px:{xs:1,sm:3},pt:{xs:1,md:2},display:"flex",alignItems:"center",gap:.75},children:[e.jsx(S,{onClick:()=>n(-1),sx:{fontSize:"14px",color:"text.secondary",cursor:"pointer","&:hover":{color:"primary.main"}},children:"Sessions"}),e.jsx(S,{sx:{fontSize:"14px",color:"text.secondary"},children:"âº"}),e.jsx(S,{sx:{fontSize:"14px",color:"text.primary",fontWeight:500},noWrap:!0,children:(t==null?void 0:t.session_name)||""})]}),e.jsx(Ki,{isOpenManageDrawer:N,isCreateMode:l,loading:T,coaches:U,setAnchorEl:ds,sessionDetails:{session_name:t.session_name,session_type:t.session_type,duration:t.duration,surface:t.surface,area_size:t.area_size,description:t.session_note,...(t==null?void 0:t.team_id)&&{teamName:(ro=t==null?void 0:t.teamData)==null?void 0:ro.name},teamLogo:(lo=t==null?void 0:t.teamData)!=null&&lo.logo?(co=t==null?void 0:t.teamData)==null?void 0:co.logo:(uo=t==null?void 0:t.teamData)!=null&&uo.avatar?(mo=t==null?void 0:t.teamData)==null?void 0:mo.avatar.split(Fn)[1].substring(1):"",teamId:t==null?void 0:t.team_id,club_id:t==null?void 0:t.club_id},handleSetContainerHeight:ps,handleClickName:()=>Bt(),canManage:xt,showIconButton:!!((po=So(eo,x))!=null&&po.length),handleOpenClubSessionModal:qn,handleNextSession:Es,handleOpenGrowthModal:Tn}),(l||(t==null?void 0:t.team_id))&&e.jsx(li,{showTooltip:!0,data:st,selectedItem:m.id,onChange:ws,tabLabel:a=>oi(a.date).format("DD, MMM, YYYY")}),e.jsxs(ci,{onDragEnd:Ps,onDragStart:Ts,children:[e.jsx(ee,{height:{xs:"100%",lg:`calc(100% - ${he+(t!=null&&t.team_id?82:0)}px)`},children:e.jsx(es,{padding:0,tabHeaderPadding:"0",tabZIndex:999999,disabled:N,mobileFlexDirection:"column",labels:l&&O==="teamSession"||t!=null&&t.team_id?["Practices","Player Data","Documents","Session Evaluation","Video Analysis"]:["Practices","Documents","Video Analysis"],selectedTab:M,customStyles:{height:{xs:"unset",sm:"59px"}},contentContainerCustomStyles:{overflow:{xs:"unset",lg:M===2?"auto":"unset"}},handleTabChange:ms,customTabsStyles:et.tabs,customTabStyles:et.tab,customRightElement:M===1&&(t!=null&&t.team_id)?e.jsxs(p,{container:!0,gap:1,alignItems:"center",flexWrap:"nowrap",justifyContent:"end",children:[te==="grid"?e.jsx(p,{children:e.jsx(Fe,{text:ht?"Collapse All":"Expand All",onClick:Cs,customStyles:et.playerViewBtn})}):e.jsx(e.Fragment,{}),e.jsx(p,{children:e.jsx(ii,{value:te,handleChange:bs,iconWidth:"18px",iconHeight:"18px",customStyles:et.toggleBtn})})]}):M===0&&!L&&!N&&xt?e.jsx(Fe,{startIcon:e.jsx(Wn,{}),text:Object.values(Ue).flat().length>0?"Edit Activities":"Add Activity",customStyles:et.practiceBtn,onClick:()=>Bt()}):null,components:t!=null&&t.team_id?[e.jsx(ee,{sx:et.container,ref:Nt,children:e.jsx(Ro,{isCreateMode:l,sections:gt,isOpenManageDrawer:N,selectedTabKey:Ze,sessionPractices:Ue,setSessionPractices:Xe,session:t,openGrowthModal:ie,handleCloseGrowthModal:Zn,containerHeight:he,updatePracticesPosition:an,selectedSessionStructure:ye,sessionStructureLoading:H,saveInProgressLoader:P,sessionLoading:T,handleOpenManageDrawer:Bt,isDragStart:J})},"Practices"),e.jsx(ee,{sx:et.container,children:e.jsx(Yi,{refetchSessionPlayers:j,setRefetchSessionPlayers:z,session:t,clubId:Un,coachId:Rt,teamId:t.teamId,isExpandedAllPlayerCards:ht,view:te,isOpenManageDrawer:N})},"Player Data"),e.jsx(ee,{sx:et.container,children:e.jsx(No,{session:t})},"Documents"),e.jsx(ee,{sx:et.container,children:e.jsx(Zi,{session:t,refetchSession:Ct})},"Session Evaluation"),e.jsx(ee,{sx:{px:3},children:e.jsx(Bo,{sessionId:t==null?void 0:t.id})},"VideoAnalysis")]:[e.jsx(ee,{sx:et.container,ref:Nt,children:e.jsx(Ro,{refetchSession:Ct,isCreateMode:l,sections:gt,isOpenManageDrawer:N,selectedTabKey:Ze,sessionPractices:Ue,setSessionPractices:Xe,session:t,openGrowthModal:ie,handleCloseGrowthModal:Zn,containerHeight:he,updatePracticesPosition:an,selectedSessionStructure:ye,sessionStructureLoading:H,saveInProgressLoader:P,sessionLoading:T,handleOpenManageDrawer:Bt,isDragStart:J})},"Practices"),e.jsx(ee,{sx:et.container,children:e.jsx(No,{session:t})},"Documents"),e.jsx(ee,{sx:{px:3},children:e.jsx(Bo,{sessionId:t==null?void 0:t.id})},"VideoAnalysis")]})}),e.jsx(ee,{ref:nn,children:e.jsx($a,{collections:ge,setCollections:ft,isCreateMode:l,navigateToSe
2ssionOnCreation:!0,selectedTabKey:Ze,setSelectedTabKey:rt,sessionDrawerActiveTab:_n,setSessionDrawerActiveTab:it,practices:ge,open:N,handleCloseDrawer:kn,isUpdated:!l,selectedSession:t,refetchSession:Ct,teamId:t==null?void 0:t.team_id,sessionsType:l?O:t!=null&&t.team_id?"teamSession":"clubSession",handleChangeSessionDrawerTab:Ms,selectedPracticeIds:Ot,setSelectedPracticeIds:Kt,tabLabels:Qt,selectedSessionStructure:ye,setSelectedSessionStructure:d,onAccepted:on,sessionPractices:Ue,setSessionPractices:Xe,getTrainingSessionStructure:Yn,setSaveInProgressLoader:pe,saveInProgressLoader:P,handleOpenGrowthModal:Tn,handleOpenGeneratePdfDocumentModal:An,setOpenGeneratePdfAlertModal:_t,tryAddPractice:to})})]}),e.jsx(Ni,{open:!!Ye,handleClose:ks,handleConfirm:As,practiceTypeId:Ye==null?void 0:Ye.practiceTypeId,tabTitle:Ye==null?void 0:Ye.tabTitle,practiceName:Ye==null?void 0:Ye.practiceName}),e.jsx(Cn,{width:"220px",itemHeight:"58px",itemPadding:"22px 24px",items:So(eo,x),enableDividers:!1,anchorEl:de,handleClose:us}),e.jsx(pi,{isUpdated:!0,open:D,handleCloseModal:xs,selectedSession:t,refetchSession:Ct,teamId:t==null?void 0:t.team_id,getSessionListLite:In,sessionsType:t!=null&&t.team_id?"teamSession":"clubSession"}),e.jsx(ui,{open:ae,loading:He,selectedSession:t,handleCloseModal:Kn,handleDuplicateSession:Ss}),e.jsx(mi,{open:i,handleCloseModal:cs,session:t,isTeamSession:!!(t!=null&&t.team_id)}),e.jsx(Vn,{handleDelete:hs,handleClose:Jn,open:oe,title:"Delete Session?",actionBtnTitle:"Delete Session",entityName:`${t==null?void 0:t.session_name}`}),e.jsx(ea,{id:Ie,open:ue,redirectEntity:"session",title:"Success",primaryBtnTitle:"Cancel",actionBtnText:"Go to Session",handleClose:ls}),e.jsx(di,{open:qe,handleClose:is,clubSessionId:t.id}),e.jsx(zt,{title:"Add to Global Library",loading:fe,description:"Are you sure you want to add the selected content in the Global Library?",open:Ne,handleClose:()=>Me(!1),actionHandler:Is}),e.jsx(zt,{title:"Save Session?",actionBtnTitle:"Save and Continue",loading:fe,description:"You have unsaved changes. Click Save and continue to proceed with your action, or cancel to continue editing?",open:Jt,handleClose:no,actionHandler:Ds}),e.jsx(zt,{title:"Duplicate Session?",actionBtnTitle:"Duplicate Session",loading:He,description:e.jsxs(e.Fragment,{children:["Are you sure you want to duplicate ",e.jsx("strong",{children:"Session"}),"? This action cannot be undone."]}),open:Re,handleClose:Qn,actionHandler:as}),e.jsx(zt,{title:"Copy Session to Club Sessions?",actionBtnTitle:"Copy Session",description:e.jsxs(e.Fragment,{children:["Are you sure you want to copy ",e.jsx("strong",{children:"Session"})," to Club Sessions?"]}),open:vn,handleClose:Xn,actionHandler:async()=>{await vs(),Xn()}}),e.jsx(zt,{title:"ð Session Created - Need a Session Plan?",actionBtnTitle:"Yes",cancelBtnTitle:"No",description:"Would you like a PDF Session Plan to take to the field?",open:sn,handleClose:()=>_t(!1),actionHandler:Os})]})};export{ic as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.