PageSourceSearch

https://club.touchtight.com/assets/index-cyL-f_lR.js

js touchtight.com collected 2026-09-24 13:37:03 UTC 47,907 bytes, 1 lines download raw bytes

1import{a as t,j as e}from"./react-vendor-DJtAp8P_.js";import{ac as ts,ad as ns,ab as os,b as we,q as is,ae as rs,A as ls,X as cs}from"./swiper-react-BdHqbMUq.js";import{cV as Re,$ as Ve,q as Ee,an as Be,dQ as qe,d as Me,e as Ye,dR as as,dS as ds,dT as us,dU as hs,I as Ge,M as _e,h as fs,j as xs,T as gs,u as ps}from"./index-D7JOLfRZ.js";import{ax as ms,$ as Ss,o as Cs,G as ys,ao as bs,ay as js,a as vs}from"./query-C7Xvvnmk.js";import{b2 as ws}from"./mutation-CBAS9dQ5.js";import{d as ue,u as Ts,b as Es}from"./dayjs-CeefjyDY.js";import"./moment-Bj79pgB5.js";import{u as Xe,c as ks,e as Ie,d as Ae}from"./index.esm-M6qXUo6E.js";import{s as As}from"./SessionPlannerMobile-btstsT3g.js";import{V as Ue}from"./VideoPlayerModal-BmqvMACS.js";import{u as Ke,z as a,E as te,T as N,B as $e,a0 as Os,co as _s,cp as Bs,cq as Ps,ao as Is,aq as Ls,bh as Ws,cr as Fs,cs as je,ct as Rs,aJ as zs,aQ as Ns,w as Ze}from"./mui-DM4FB6Od.js";import{s as Je}from"./mui-styles-Cs1eTw1A.js";import{M as Qe}from"./Modal-BMf2ZRZ1.js";import{B as De}from"./Button-C12sdXE_.js";import{CreateEditSeasonModal as Ms}from"./CreateEditSeasonModal-PHjup6ny.js";import{DatePicker as Hs}from"./DatePicker-EVZZ-tOu.js";import{v as ze}from"./values-KC-0YRfW.js";import{c as Ne}from"./compact-DZdspzxW.js";import{u as Pe,e as Vs,n as $s}from"./apollo-WxVwhmyD.js";import{A as He}from"./AlertModal-CX5pWvCn.js";import{T as qs}from"./Tabs-DlA0lKPi.js";import{S as Ys}from"./SearchHeader-C61GLxal.js";import"./imageOptimization-zUL1CBPb.js";import"./Search-DtNbnsKK.js";import"./lodash-CKgJFN-2.js";import"./merge-BSbDH-s2.js";import"./_baseAssignValue-DA5RZPFC.js";import"./_baseClone-CI_UATaE.js";import"./isArrayLikeObject-BWZNxdtJ.js";import"./map-DazS0jXn.js";import"./babel-helpers-GYAhpWPp.js";import"./browser-CbB-A17s.js";import"./hello-pangea-dnd-V9uYMV7h.js";import"./some-DWTvIxlZ.js";import"./_baseIndexOf-DqPIyCu4.js";import"./index-DCj5Y0Ve.js";import"./_baseDifference-DAp4QVb4.js";import"./_arrayIncludes-Ck-iFXGO.js";import"./omit-BVrVjzv1.js";import"./index-DH6i3Hvs.js";import"./mui-x-YwRs-dk2.js";import"./s3FileHandler-C17YuASz.js";import"./_baseUniq-CmchZ_xr.js";import"./cloneDeep-DBd8ERDR.js";import"./SortMenu-CF1gRMfw.js";import"./DeleteModal-DGIY4vv1.js";import"./Filter-D0LZmDHe.js";import"./SearchBlue-L5ACR53r.js";import"./omitBy-BCozY_Ti.js";import"./_basePickBy-Dc16HIWF.js";try{let s=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},o=new s.Error().stack;o&&(s._sentryDebugIds=s._sentryDebugIds||{},s._sentryDebugIds[o]="2864af46-0856-4c39-a048-bac0c87e102f",s._sentryDebugIdIdentifier="sentry-dbid-2864af46-0856-4c39-a048-bac0c87e102f")}catch{}const Gs=s=>t.createElement("svg",{width:18,height:18,viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",...s},t.createElement("g",{clipPath:"url(#clip0_24227_5611)"},t.createElement("path",{d:"M12 2.25L15 5.25L12 8.25",stroke:"#1A222F",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),t.createElement("path",{d:"M7.5 5.25H15",stroke:"#1A222F",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),t.createElement("path",{d:"M6 9.75L3 12.75L6 15.75",stroke:"#1A222F",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),t.createElement("path",{d:"M3 12.75H9.75",stroke:"#1A222F",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})),t.createElement("defs",null,t.createElement("clipPath",{id:"clip0_24227_5611"},t.createElement("rect",{width:18,height:18,fill:"white"})))),xe={practiceCard:{gap:3,width:"100%",position:"relative",padding:{xs:"16px",md:"40px"},backgroundColor:s=>s.palette.common.white,borderBottom:s=>`1px solid ${s.palette.divider}`,"&:last-child":{borderBottom:"none"}},videoContainer:{width:{xs:"100%",sm:"256px",md:"343px"},height:"auto",aspectRatio:"16/9",borderRadius:"8px",position:"relative",cursor:"pointer",flexShrink:0},videoPlayer:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"8px"},skeleton:{borderRadius:"8px",width:"100%",height:"100%",backgroundColor:"#f5f5f5",display:"flex",alignItems:"center",justifyContent:"center"},swapButton:{display:"flex",justifyContent:"center",alignItems:"center",padding:"4px 10px",backgroundColor:s=>s.palette.common.white,border:s=>`1px solid ${s.palette.divider}`,color:s=>s.palette.text.primary,borderRadius:"8px",fontSize:"13px",fontWeight:700,lineHeight:"22px",textTransform:"none","&:hover":{backgroundColor:s=>s.palette.grey[50]},"& .MuiButton-startIcon":{marginRight:.5}},practiceContent:{display:"flex",flexDirection:"column",gap:2},practiceTitle:{color:"text.primary",fontSize:"18px",fontWeight:700,lineHeight:"28px"},collapse:{padding:"16px",borderRadius:"8px",backgroundColor:"#F4F6F8",height:"100%"},practiceDescription:{fontSize:"16px",lineHeight:"24px",color:"text.primary"},expandButton:{fontSize:"13px",fontWeight:700,lineHeight:"22px",color:"text.primary",justifyContent:"flex-start",padding:0,textTransform:"none","&:hover":{backgroundColor:"unset"}}},Xs=({practice:s,showSwapButton:o=!0,onSwap:c})=>{const g=t.useRef(null),[h,F]=t.useState(!1),[R,V]=t.useState(null),[v,j]=t.useState(!1),[O,W]=t.useState(0),[Q,A]=t.useState({}),[D,S]=t.useState(!1),B=Ke(w=>w.breakpoints.down("md")),l=()=>{S(!0),A({...s,url:Re(s==null?void 0:s.source_hd,s==null?void 0:s.source_hls)})},C=()=>{S(!1),A({})},Y=()=>{V(null),j(!1)},P=()=>{V({source_hls:s==null?void 0:s.source_hls,source_hd:s==null?void 0:s.source_hd})};return s==null||s.source,`${s==null?void 0:s.duration}`,s==null||s.type,t.useEffect(()=>{g.current&&W(g.current.offsetWidth)},[g]),e.jsxs(e.Fragment,{children:[e.jsxs(a,{container:!0,sx:xe.practiceCard,flexWrap:{xs:"wrap",sm:"nowrap"},children:[e.jsx(a,{ref:g,sx:xe.videoContainer,onMouseOver:P,onMouseLeave:Y,onClick:l,children:e.jsx(te,{sx:{position:"relative",borderRadius:"8px",height:"100%",width:"100%"},children:s.preview_image_url?e.jsx(ns,{poster:s.preview_image_url,videoSrc:Re(R==null?void 0:R.source_hd,R==null?void 0:R.source_hls),customStyleVideo:xe.videoPlayer,customStylePoster:xe.videoPlayer,isVideoLoaded:v,onPlaying:()=>j(!0),onEnded:Y}):e.jsx(a,{container:!0,justifyContent:"center",alignItems:"center",sx:xe.skeleton,children:e.jsx(ts,{style:{height:"112px",width:"112px"}})})})}),e.jsxs(a,{size:12,sx:xe.practiceContent,children:[e.jsxs(a,{container:!0,justifyContent:"space-between",alignItems:"flex-start",flexWrap:"nowrap",children:[e.jsx(a,{size:9,children:e.jsx(N,{sx:xe.practiceTitle,children:s.title})}),o&&e.jsx(a,{container:!0,justifyContent:"flex-end",size:3,children:e.jsx($e,{sx:xe.swap
1Button,size:"small",startIcon:e.jsx(Gs,{}),onClick:()=>c(s),children:"Swap"})})]}),e.jsxs(a,{container:!0,direction:"column",gap:1,flexWrap:"nowrap",sx:xe.collapse,children:[e.jsx(Os,{in:h,timeout:"auto",collapsedSize:B?"42px":"83px",children:e.jsx(a,{container:!0,direction:"column",children:e.jsx(N,{sx:[xe.practiceDescription,s.description?{}:{color:"text.secondary"},B?{fontSize:"14px",lineHeight:"22px"}:{}],children:s.description||"No description available"})})}),!!(s!=null&&s.description)&&e.jsx($e,{disableRipple:!0,sx:xe.expandButton,onClick:()=>F(!h),children:h?"Show Less":"Show More"})]})]})]}),e.jsx(Ue,{open:D,handleClose:C,videoData:Q})]})},Us=s=>t.createElement("svg",{width:25,height:24,viewBox:"0 0 25 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...s},t.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2.28516 12C2.28516 6.47715 6.76231 2 12.2852 2C14.9373 2 17.4809 3.05357 19.3562 4.92893C21.2316 6.8043 22.2852 9.34784 22.2852 12C22.2852 17.5228 17.808 22 12.2852 22C6.76231 22 2.28516 17.5228 2.28516 12ZM12.0152 15.61L16.5852 9.61V9.58C16.8031 9.29419 16.852 8.91382 16.7134 8.58218C16.5749 8.25054 16.2699 8.01801 15.9134 7.97218C15.5569 7.92635 15.2031 8.07419 14.9852 8.36L11.2052 13.36L9.57516 11.28C9.35544 10.9978 9.00184 10.8542 8.64755 10.9033C8.29326 10.9525 7.99212 11.1869 7.85755 11.5183C7.72298 11.8497 7.77544 12.2278 7.99516 12.51L10.4352 15.62C10.626 15.8615 10.9174 16.0017 11.2252 16C11.5347 15.9993 11.8264 15.8552 12.0152 15.61Z",fill:"#2E7D32"})),Ks=Je(Fs)(({theme:s})=>({[`&.${je.alternativeLabel}`]:{top:10,left:"calc(-50% + 16px)",right:"calc(50% + 16px)"},[`&.${je.active}`]:{[`& .${je.line}`]:{borderColor:"#2F80ED"}},[`&.${je.completed}`]:{[`& .${je.line}`]:{borderColor:"#2F80ED"}},[`& .${je.line}`]:{borderColor:"#919EAB3D",borderTopWidth:2,borderRadius:1}})),Zs=Je("div")(({theme:s,ownerState:o})=>({color:"#919EAB",display:"flex",height:22,alignItems:"center","& .StepIcon-completedIcon":{color:"#2F80ED",zIndex:1,fontSize:18},"& .StepIcon-circle":{width:8,height:8,borderRadius:"50%",backgroundColor:"#919EAB"},...o.active&&{color:"#2F80ED"}})),Js=s=>{const{active:o,completed:c,className:g}=s;return e.jsx(Zs,{ownerState:{active:o},className:g,children:c?e.jsx(Ws,{className:"StepIcon-completedIcon"}):e.jsx("div",{className:"StepIcon-circle"})})},me={sessionSection:{display:"flex",py:2,flexDirection:"column",gap:1,borderTop:"1px solid #919eab3d",borderBottom:"1px solid #919eab3d",background:"#292f4c14",overflowX:"auto",width:"100%",minWidth:"max-content","&::-webkit-scrollbar":{display:"none"}},sessionCardsContainer:{display:"flex",alignItems:"center",mx:2,gap:1.5},sessionCard:{minWidth:"280px",cursor:"pointer",borderRadius:"8px",background:"#FFFFFF",boxShadow:"none",border:"2px solid transparent",outline:"none","&:hover, &:focus-visible":{border:"2px solid #2F80ED",background:"#EFF5FE"}},activeSessionCard:{border:"2px solid #2F80ED",background:"#EFF5FE"},acceptedSessionCard:{background:"#EFF5FE"},sessionCardContent:{padding:"8px !important",display:"flex",flexDirection:"column",alignItems:"flex-start",gap:.5},sessionCardTitle:{color:"#212B36",fontSize:"16px",fontWeight:600,lineHeight:"24px"},sessionCardMetaContainer:{display:"flex",alignItems:"center",gap:1,flexWrap:"wrap"},sessionCardMeta:{fontSize:"14px",color:"#637381",lineHeight:"22px"},stepperContainer:{minWidth:"max-content","& .MuiStepLabel-root":{cursor:"inherit !important"}}},Qs=({session:s,isActive:o,onClick:c,activeCardRef:g})=>e.jsx(Is,{sx:{...me.sessionCard,...o?me.activeSessionCard:{},...s.accepted?me.acceptedSessionCard:{}},onClick:c,ref:g,children:e.jsxs(Ls,{sx:me.sessionCardContent,children:[e.jsxs(te,{display:"flex",justifyContent:"space-between",width:"100%",children:[e.jsx(N,{sx:me.sessionCardTitle,children:ue(s.sessionDate).format("MMM DD, YYYY hh:mm a")}),s.accepted&&e.jsx(Us,{})]}),e.jsx(te,{sx:me.sessionCardMetaContainer,children:e.jsx(N,{sx:me.sessionCardMeta,children:s.sessionName})})]})}),Ds=({sessionStates:s,activeSessionIndex:o,onSessionClick:c,activeCardRef:g})=>e.jsxs(te,{sx:me.sessionSection,children:[e.jsx(te,{sx:me.sessionCardsContainer,children:s.map((h,F)=>e.jsx(Qs,{session:h,isActive:F===o,onClick:()=>c(F),activeCardRef:F===o?g:null},`${h.sessionName}-${F}`))}),e.jsx(te,{sx:me.stepperContainer,children:e.jsx(_s,{alternativeLabel:!0,activeStep:o,connector:e.jsx(Ks,{}),children:s.map((h,F)=>e.jsx(Bs,{completed:h.accepted,children:e.jsx(Ps,{slots:{stepIcon:Js}})},h.id))})})]}),Le={practiceGrid:{padding:{xs:"16px",md:"24px"},minHeight:"60vh",overflowY:"auto"},actionBtn:{height:"48px"},cancelBtn:{border:"none","&:hover":{border:"none",background:"none"}}},et=({open:s,onClose:o,availablePractices:c,onConfirm:g})=>{const[h,F]=t.useState({}),[R,V]=t.useState(!1),[v,j]=t.useState(null),O=S=>{F({...S,url:Re(S.source_hd,S.source_hls)}),V(!0)},W=()=>{V(!1),F({})},Q=()=>{j(null),o()},A=()=>{v&&(g(v),Q())},D=(S,B)=>{j(S?B:null)};return e.jsxs(Qe,{open:s,showDialogActions:!0,padding:"0px",cancelBtn:!1,dialogMaxWidth:"lg",title:"Swap Practice",secondaryBtnTitle:"Cancel",actionBtnTitle:"Confirm Swap",handleClose:Q,actionHandler:A,secondaryBtnHandler:Q,secondaryBtnStyle:Le.cancelBtn,saveButtonStyle:Le.actionBtn,children:[e.jsxs(te,{sx:Le.practiceGrid,children:[e.jsx(a,{container:!0,spacing:2,children:c==null?void 0:c.map(S=>e.jsx(a,{size:{xs:12,sm:4},children:e.jsx(os,{checkable:!0,hoverGradient:!0,hoverDelay:0,headingFontSize:"13px",cardType:"engine-room",id:S.id,sourceHd:S.source_hd,sourceHls:S.source_hls,imageUrl:S==null?void 0:S.preview_image_url,checked:(v==null?void 0:v.id)===S.id,handleChangeCheckbox:B=>D(B,S),handleClick:()=>O(S)})},S.id))}),(c==null?void 0:c.length)===0&&e.jsx(te,{sx:{textAlign:"center",padding:4},children:e.jsx(N,{color:"text.secondary",children:"No practices available."})})]}),e.jsx(Ue,{open:R,handleClose:W,videoData:h})]})},Te={headerSection:{overflowX:"hidden",display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px 24px"},headerTitle:{fontSize:"16px",fontWeight:600,lineHeight:"24px",color:"#212B36"},sessionCounter:{color:"#637381",fontSize:"14px",fontWeight:700,lineHeight:"24px"},sessionReviewSection:{overflowX:"auto",overflowY:"hidden",userSelect:"none","&::-webkit-scrollbar":{display:"none"}},practiceList:{padding:"0",width:"100%",flexGrow:1,"&::-webkit-scrollbar":{display:"none"}}},st=({sessions:s=[],stepForward:o,stepBackward:c,setStepForward:g,setStepBackward:h,handleNextStep:F,handleStepBack:R,onAccept:V})=>{var i;const v=t.useRef(null),j=t.useRef(null),[O,W]=t.useState(0),[Q,A]=t.useState(!1),[D,S]=t.useState(null),[B,l]=t.useState(s.map(u=>({...u,accepted:u.accepted||!1}
1))),C=B[O],Y=u=>{W(u)},P=u=>{S(u),A(!0)},w=()=>{A(!1),S(null)},z=u=>{var x,m;const I=(x=C==null?void 0:C.practices)==null?void 0:x.findIndex(E=>E.id===D.id),M=(m=C==null?void 0:C.practices)==null?void 0:m.findIndex(E=>E.id===u.id);if(I===-1||M===-1)return;const p=[...C.practices],$={...p[I],videoAdded:!1},n={...p[M],videoAdded:!0};p[I]=n,p[M]=$,l(E=>E.map((d,L)=>L===O?{...d,practices:p}:d)),w()},U=()=>{const u=B.map((M,p)=>p===O?{...M,accepted:!0}:M);l(u);const I=O===B.length-1;return Y(I?0:O+1),u},se=()=>{const u=B.map(I=>({...I,accepted:!0}));return l(u),u};return t.useEffect(()=>{V==null||V({acceptCurrent:U,acceptAll:se,sessionStates:B,activeSessionIndex:O})},[B,O]),t.useEffect(()=>{o&&(F(),g(!1))},[o,F,g]),t.useEffect(()=>{c&&(R(),h(!1))},[c,R,h]),t.useEffect(()=>{const u=v.current;if(!u)return;let I={isDown:!1,startX:0,scrollLeft:0};const M={wheel:p=>{Math.abs(p.deltaX)<Math.abs(p.deltaY)&&p.deltaX===0&&(p.preventDefault(),u.scrollLeft+=p.deltaY)},mousedown:p=>{I={isDown:!0,startX:p.pageX-u.offsetLeft,scrollLeft:u.scrollLeft},u.style.cursor="grabbing"},mouseleave:()=>{I.isDown=!1,u.style.cursor="grab"},mouseup:()=>{I.isDown=!1,u.style.cursor="grab"},mousemove:p=>{if(!I.isDown)return;p.preventDefault();const $=(p.pageX-u.offsetLeft-I.startX)*2;u.scrollLeft=I.scrollLeft-$}};return u.style.cursor="grab",Object.entries(M).forEach(([p,$])=>{u.addEventListener(p,$,p==="wheel"?{passive:!1}:void 0)}),()=>{Object.entries(M).forEach(([p,$])=>{u.removeEventListener(p,$)})}},[]),t.useEffect(()=>{const u=v.current,I=j.current;if(u&&I){const M=I.offsetLeft,p=I.offsetWidth,$=u.offsetWidth,n=M-($-p)/2;u.scrollTo({left:n,behavior:"smooth"})}},[O]),e.jsxs(te,{display:"flex",flexDirection:"column",width:"100%",children:[e.jsxs(te,{sx:Te.headerSection,children:[e.jsx(N,{sx:Te.headerTitle,children:"Review Sessions"}),e.jsxs(N,{sx:Te.sessionCounter,children:[O+1," of ",B.length]})]}),e.jsx(te,{ref:v,sx:Te.sessionReviewSection,children:e.jsx(Ds,{activeCardRef:j,sessionStates:B,activeSessionIndex:O,onSessionClick:Y})}),e.jsx(a,{container:!0,sx:Te.practiceList,children:C==null?void 0:C.practices.filter(u=>u.videoAdded).map(u=>e.jsx(Xs,{practice:u,showSwapButton:C.practices.some(I=>!I.videoAdded),onSwap:P},u.id))}),e.jsx(et,{open:Q,practice:D,onConfirm:z,onClose:w,availablePractices:(i=C==null?void 0:C.practices)==null?void 0:i.filter(u=>!u.videoAdded)})]})},es=s=>t.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...s},t.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22C17.5228 22 22 17.5228 22 12C22 9.34784 20.9464 6.8043 19.0711 4.92893C17.1957 3.05357 14.6522 2 12 2ZM13 16C13 16.5523 12.5523 17 12 17C11.4477 17 11 16.5523 11 16V11C11 10.4477 11.4477 10 12 10C12.5523 10 13 10.4477 13 11V16ZM11 8C11 8.55228 11.4477 9 12 9C12.5523 9 13 8.55228 13 8C13 7.44772 12.5523 7 12 7C11.4477 7 11 7.44772 11 8Z",fill:"#F44336"})),ve={heading:{color:s=>s.error.text.primaryColor,fontWeight:700,fontSize:"18px"},description:{color:s=>s.error.text.primaryColor,fontSize:"16px",marginBottom:"4px"},alertContainer:{padding:{xs:"16px 16px",md:"16px 24px"},borderRadius:"12px",backgroundColor:s=>s.error.container.backgroundColor},button:{backgroundColor:s=>s.error.button.backgroundColor,color:"#fff",fontWeight:700,borderRadius:"8px",padding:{xs:"12px 16px",md:"12px 24px"},fontSize:"16px",boxShadow:"none","&:hover":{boxShadow:"none",backgroundColor:s=>s.error.button.backgroundColor}},buttonIcon:{marginRight:"8px",fontSize:22}},tt=({teamName:s="",handleMapToExistingSession:o})=>e.jsxs(a,{container:!0,width:"100%",sx:ve.alertContainer,gap:2,children:[e.jsxs(a,{container:!0,gap:2,flexWrap:"nowrap",children:[e.jsx(a,{children:e.jsx(es,{style:{width:"35px",height:"35px"}})}),e.jsxs(a,{container:!0,width:"100%",gap:3,mt:"4px",children:[e.jsx(N,{sx:ve.heading,children:"Map to Existing Sessions?"}),e.jsxs(a,{size:12,children:[e.jsxs(N,{sx:ve.description,children:["You currently have sessions for ",e.jsx("strong",{children:s})," during this period."]}),e.jsx(N,{sx:ve.description,children:"You must either change your start date above or map the Season Plan to your sessions?"})]})]})]}),e.jsx(a,{container:!0,size:12,justifyContent:"flex-end",children:e.jsx(De,{text:e.jsxs(e.Fragment,{children:[e.jsx(Rs,{sx:ve.buttonIcon})," Map to Sessions"]}),customStyles:ve.button,size:"large",variant:"contained",onClick:o})})]});ue.extend(Ts);const Ce={warningContainer:{padding:"16px",borderRadius:"8px",backgroundColor:s=>s.error.container.backgroundColor},warningHeading:{fontSize:"16px",lineHeight:"24px",fontWeight:600,color:s=>s.error.text.primaryColor},warningText:{fontSize:"14px",lineHeight:"22px",color:s=>s.error.text.primaryColor},warningSubHeading:{fontSize:"12px",lineHeight:"18px",color:s=>s.error.text.secondaryColor},clubSettingButton:{borderRadius:"8px",color:s=>s.palette.common.white,borderColor:s=>s.error.button.backgroundColor,backgroundColor:s=>s.error.button.backgroundColor}},nt=({currentSeason:s,entityName:o="Session",sessionDate:c})=>{const[g,h]=t.useState(!1),F=()=>{h(!0)},R=()=>{h(!1)};return e.jsxs(e.Fragment,{children:[e.jsxs(a,{container:!0,width:"100%",flexWrap:"nowrap",sx:Ce.warningContainer,children:[e.jsx(a,{container:!0,width:"35px",children:e.jsx(es,{})}),e.jsx(a,{size:12,children:e.jsxs(a,{container:!0,direction:"column",width:"100%",gap:2,children:[e.jsx(N,{sx:Ce.warningHeading,children:`${o} Date is Outside Season`}),e.jsxs(N,{sx:Ce.warningText,children:[`Update the season dates in your club settings to add a ${o.toLowerCase()} or reduce the number of sessions.`,e.jsx("br",{}),"Last session date is ",e.jsx(te,{component:"span",fontWeight:"bold",children:ue(c).format("MMM D, YYYY")})]}),e.jsxs(a,{container:!0,width:"100%",gap:2,children:[e.jsxs(a,{children:[e.jsx(N,{sx:Ce.warningSubHeading,children:"Season Start Date"}),e.jsx(N,{sx:Ce.warningHeading,children:Ve(s==null?void 0:s.start_date)})]}),e.jsx(a,{container:!0,alignItems:"flex-end",mb:"4px",children:e.jsx(N,{sx:Ce.warningSubHeading,children:"—"})}),e.jsxs(a,{children:[e.jsx(N,{sx:Ce.warningSubHeading,children:"Season End Date"}),e.jsx(N,{sx:Ce.warningHeading,children:Ve(s==null?void 0:s.end_date)})]})]}),e.jsx(a,{container:!0,width:"100%",justifyContent:"flex-end",children:e.jsx(De,{text:"Update Season",startIcon:e.jsx(zs,{}),customStyles:Ce.clubSettingButton,onClick:F})})]})})]}),e.jsx(Ms,{disableName:!0,seasonToEdit:s,open:g,handleClose:R})]})},Oe={alertContainer:{color:"#fff",padding:{xs:"16px 16px",md:"16px 24px"},borderRadius:"16px",position:"relative",backgroundColor:s=>s.palette.primary.main},icon:{fontSize:"24px",marginRight:{xs:"4px",md:"12px"},color:s=>s.palette.common.white},heading:{fontWeight:700,fontSize:"18px",marginBottom:"2px"},description:{fontSize:"14px",color:s=>s.palette.common.white}},ot=({})=>e.jsxs(a,{container:!0,alignItems:"flex-start",sx:Oe.alertContainer,flexWrap:"nowrap",children:[e.jsx(Ns,{sx:Oe.icon}),e.jsxs(a,{size:12,children:[e.jsx(N,{sx:Oe.heading,children:"Congrats! Your Sessions have been added"}),e.jsx(N,{sx:Oe.description,children:"Click continue below to view your mapped Season Plan"})]})]});ue.extend(Es);const We={heading:{fontWeight:600,fontSize:"18px",color:"text.primary"},title:{fontWeight:500,color:"text.secondary"},datePicker:{"& .MuiOutlinedInput-root":{backgroundColor:s=>s.palette.common.white,borderRadius:"12px","& .MuiOutlinedInput-notchedOutline":{borderColor:s=>s.border},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:s=>s.palette.primary.main}}}},it=({currentSeason:s,sessionMappedData:o,teamSettings:c,stepForward:g,stepBackward:h,setStepForward:F,setStepBackward:R,handleNextStep:V,handleStepBack:v,collection:j,numberOfWeeks:O,collectionLoading:W,handleSetPlanData:Q})=>{var H,ee,G,re,ae,he,ge,pe,le;const A=Pe(),[D,S]=t.useState([]),[B,l]=t.useState({}),[C,Y]=t.useState(!0),[P,w]=t.useState([]),[z,U]=t.useState([]),[se,i]=t.useState(!1),[u,I]=t.useState(!1),[M,p]=t.useState(!1),$={Sun:0,Mon:1,Tues:2,Tue:2,Wed:3,Thu:4,Thurs:4,Fri:5,Sat:6},n=Xe({initialValues:Ee(o)?{startDate:"",sessions:[],numberOfSessions:""}:{sessions:o==null?void 0:o.sessions,startDate:o==null?void 0:o.startDate,numberOfSessions:o==null?void 0:o.numberOfSessions},enableReinitialize:!0,onSubmit:f=>{Q({sessionMappedData:{...f,matchingSessions:z,mapToExistingSession:se}}),V()}}),x=async()=>{Y(!0);const{data:f}=await A.query({query:ms,variables:{getAllTrainingSessionsByTeamInput:{teamId:+c.team}},fetchPolicy:"no-cache"}),{success:T,data:K}=f.getAllTrainingSessionsByTeam;T&&S(K),Y(!1)},m=f=>{const T=ue(),Z=($[f]+7-T.day())%7||7;return T.add(Z,"day")},E=(f,T,K,Z,de)=>{var ye;const oe={},fe=ue(f),J=Z==null?void 0:Z.filter(r=>T==null?void 0:T.includes(r.day));if((J==null?void 0:J.length)===0)return oe;let ce=0,be=0,Se=0;for(;be<K;){const r=`Week ${Se+1}`,y=[];for(let b=0;b<de&&be<K;b++){const _=J==null?void 0:J[ce%(J==null?void 0:J.length)],ne=$[_.day];let ie=fe.add(Se,"week"),k=ie.day(ne);if(k=ue(k),!k.isValid())continue;k.isBefore(ie,"day")&&(k=k.add(7,"day"));const[X,ke]=(ye=_==null?void 0:_.time)==null?void 0:ye.split(":");k=k.hour(Number(X)).minute(Number(ke)),y.push(k.format("YYYY-MM-DD HH:mm")),ce++,be++}y.sort((b,_)=>ue(b,"YYYY-MM-DD HH:mm").valueOf()-ue(_,"YYYY-MM-DD HH:mm").valueOf()),oe[r]=y,Se++}return oe},d=f=>{const T=Object.entries(f).map(([Z,de])=>{const oe=de.map(fe=>{const J=D.find(ce=>new Date(ce.session_date_time).getTime()===new Date(fe).getTime());return{date:fe,session:J||null,found:!!J}});return{[Z]:oe}}),K=Ne(T.map(Z=>{const de=Object.keys(Z),oe={};return de.forEach(fe=>{const J=Z[fe].filter(ce=>ce.found);J.length>0&&(oe[fe]=J)}),Object.keys(oe).length>0?oe:null}));U(K),l(f)},L=(f,T,K)=>{const Z=[],de=qe(T,K);let oe=0;return Object.values(f).forEach(fe=>{fe.forEach(J=>{var Se,ye,r,y;const ce=(ye=(Se=z==null?void 0:z.flatMap(b=>ze(b).flat()))==null?void 0:Se.find(b=>b.date===J))==null?void 0:ye.session,be={sessionName:(r=de[oe])==null?void 0:r.divider,sessionDate:ue(J).valueOf(),practices:((y=de[oe])==null?void 0:y.practices)||[],sessionDuration:c.sessionDuration,coaches:c.coaches,...(ce==null?void 0:ce.id)&&{id:ce.id}};Z.push(be),oe++})}),Z},q=f=>{f.target.name==="numberOfSessions"?n.setFieldValue("numberOfSessions",f.target.value):n.handleChange(f)};return t.useEffect(()=>{var f,T,K,Z;P!=null&&P.length&&((f=n.values)!=null&&f.numberOfSessions)&&+((T=n.values)==null?void 0:T.numberOfSessions)!==((Z=(K=n.values)==null?void 0:K.sessions)==null?void 0:Z.length)&&n.setFieldValue("sessions",P.slice(0,parseInt(n.values.numberOfSessions)))},[n.values,P==null?void 0:P.length]),t.useEffect(()=>{var f;if((f=n.values.sessions)!=null&&f.length){const K=ue(s==null?void 0:s.end_date).endOf("day"),Z=n.values.sessions.some(de=>
1ue(de.sessionDate).isAfter(K));p(Z)}else p(!1)},[s==null?void 0:s.end_date,P,(H=n.values.sessions)==null?void 0:H.length]),t.useEffect(()=>{var f,T;(f=o==null?void 0:o.matchingSessions)!=null&&f.length&&U(o.matchingSessions),o!=null&&o.mapToExistingSession&&i(o.mapToExistingSession),(T=o==null?void 0:o.allSessions)!=null&&T.length&&w(o.allSessions)},[(ee=o==null?void 0:o.matchingSessions)==null?void 0:ee.length,o==null?void 0:o.mapToExistingSession,(G=o==null?void 0:o.allSessions)==null?void 0:G.length]),t.useEffect(()=>{if(!Ee(B)&&(!n.values.numberOfSessions||(o==null?void 0:o.startDate)!==n.values.startDate)){const f=L(B,j,c.numberOfActivities);w(f),n.setFieldValue("sessions",f),n.setFieldValue("numberOfSessions",f.length.toString())}},[se,B,c.numberOfActivities,n.values.startDate]),t.useEffect(()=>{c.team&&x()},[c.team]),t.useEffect(()=>{var f;if(!(P!=null&&P.length)&&n.values.numberOfSessions&&((f=o==null?void 0:o.sessions)==null?void 0:f.length)!==+n.values.numberOfSessions){const T=E(n.values.startDate,c.trainingDays,O,c.trainingTimes,c.sessionsPerWeek),K=L(T,j,c.numberOfActivities);l(T),w(K)}},[n.values.numberOfSessions,(re=o==null?void 0:o.sessions)==null?void 0:re.length]),t.useEffect(()=>{var f,T;if(O&&((f=c.trainingDays)!=null&&f.length)&&c.sessionsPerWeek&&((T=c.trainingTimes)!=null&&T.length)&&n.values.startDate&&!C&&!W&&(Ee(o)||(o==null?void 0:o.startDate)!==n.values.startDate)){const K=E(n.values.startDate,c.trainingDays,O,c.trainingTimes,c.sessionsPerWeek);d(K)}},[O,o,c.sessionsPerWeek,(ae=c.trainingDays)==null?void 0:ae.length,(he=c.trainingTimes)==null?void 0:he.length,C,n.values.startDate,W]),t.useEffect(()=>{var f;if((f=c==null?void 0:c.trainingDays)!=null&&f.length&&!n.values.startDate&&Ee(o)){const T=m(c.trainingDays[0]);n.setFieldValue("startDate",T.format("YYYY-MM-DD"))}},[c==null?void 0:c.trainingDays,n.values.startDate,o]),t.useEffect(()=>{g&&(F(!1),(z.length>0&&se||z.length===0&&!se&&!W&&!C)&&!M&&n.handleSubmit())},[g,W,C]),t.useEffect(()=>{h&&(R(!1),v(),Q({sessionMappedData:{...n.values,matchingSessions:z,mapToExistingSession:se,allSessions:P},shouldMoveToNextStep:!1}))},[h]),e.jsxs(a,{container:!0,gap:2,children:[e.jsx(a,{size:12,padding:{xs:"32px 16px 8px",sm:"32px 24px 8px",md:"32px 32px 8px"},children:e.jsx(N,{sx:We.title,children:"Select your start date:"})}),e.jsx(a,{size:{xs:12,sm:8,md:6},padding:{xs:"0px 16px 16px",sm:"0px 24px 16px",md:"0px 32px 16px"},children:e.jsx(Hs,{name:"startDate",label:"Start Date",customStyle:We.datePicker,value:n.values.startDate,onChange:q})}),e.jsx(a,{size:12,pb:1,children:e.jsx(Ze,{})}),e.jsx(a,{container:!0,width:"100%",padding:{xs:"0px 16px 16px",sm:"0px 24px 16px",md:"0px 32px 16px"},gap:3,children:W||C?e.jsx(a,{container:!0,justifyContent:"center",py:2,width:"100%",children:e.jsx(Be,{showText:!0,text:"Loading..."})}):e.jsxs(e.Fragment,{children:[e.jsx(a,{size:12,children:e.jsx(N,{sx:We.heading,children:"Plan Confirmation"})}),e.jsx(a,{size:{xs:12,md:7},children:z.length>0&&!se?e.jsx(tt,{teamName:c==null?void 0:c.teamName,handleMapToExistingSession:()=>i(!0)}):e.jsxs(a,{container:!0,gap:2,width:"100%",children:[e.jsx(a,{size:{xs:12},children:e.jsx(we,{fullWidth:!0,isShowClearable:!1,name:"numberOfSessions",label:"Number of Sessions",options:is(O),value:n.values.numberOfSessions,onChange:q})}),e.jsx(a,{size:{xs:12},children:M?e.jsx(nt,{currentSeason:s,sessionDate:(le=(pe=n.values.sessions)==null?void 0:pe[((ge=n.values.sessions)==null?void 0:ge.length)-1])==null?void 0:le.sessionDate}):e.jsx(ot,{})})]})})]})})]})},rt={sessionText:{fontSize:"16px",fontWeight:500,lineHeight:"24px",color:"text.secondary"}},lt={team:"",sessionsPerWeek:"",sessionDuration:"",numberOfActivities:"",trainingDays:[],trainingTimes:[],coaches:[],teamSettingChanged:!1},ct=({teams:s,clubId:o,stepForward:c,setStepForward:g,teamDetailData:h,selectedTeams:F,handleNextStep:R,handleSetPlanData:V})=>{var x,m,E;const v=Pe();Me();const{currentSeason:j,isAllSeasonSelected:O}=Ye(),[W,Q]=t.useState([]),[A,D]=t.useState({}),[S,B]=t.useState(!1),[l,C]=t.useState(null),[Y,P]=t.useState(!1),[w,z]=t.useState(!1),[U,se]=t.useState(""),i=Xe({initialValues:{...lt,...h},validationSchema:ks({team:Ae().required("Team is required"),sessionsPerWeek:Ae().required("Sessions Per Week is required"),sessionDuration:Ae().required("Session Duration is required"),numberOfActivities:Ae().required("Number of Activities is required"),trainingDays:Ie().min(1,"At least one training day is required").required("Training Days is required"),trainingTimes:Ie().min(1,"At least one training time is required").required("Training Times is required").test("trainingTimes-match-sessionsPerWeek","Total training times selected must equal sessions per week.",function(d){const{sessionsPerWeek:L}=this.parent;return!L||!d?!0:d.length===Number(L)}).test("trainingTimes-each-day","At least one training time must be selected for each training day.",function(d){const{trainingDays:L}=this.parent;
1if(!L||!Array.isArray(L)||!d)return!0;const q=L.reduce((H,ee)=>(H[ee]=d.filter(G=>G.day===ee).length,H),{});return L.every(H=>q[H]>=1)}),coaches:Ie().min(1,"At least one coach is required").required("Coaches is required")}),onSubmit:d=>{var he,ge,pe;const{trainingTimes:L,trainingDays:q,...H}=d,ee=(he=s.find(le=>le.id===d.team))==null?void 0:he.name,G=["Mon","Tues","Tue","Wed","Thu","Fri","Sat","Sun"],re=((ge=d==null?void 0:d.trainingTimes)==null?void 0:ge.sort((le,f)=>{const T=G.indexOf(le.day)-G.indexOf(f.day);return T!==0?T:le.time.localeCompare(f.time)}))||[],ae=((pe=d==null?void 0:d.trainingDays)==null?void 0:pe.sort((le,f)=>G.indexOf(le)-G.indexOf(f)))||[];V({teamSettings:{...H,trainingTimes:re,trainingDays:ae,teamName:ee}},Y,1,!1,(h==null?void 0:h.numberOfActivities)!==d.numberOfActivities),R()}}),u=async()=>{const{data:{coachListNew:d}}=await v.query({query:Cs,variables:{coachListInput:{club_id:o}},fetchPolicy:"no-cache"}),{success:L}=d;if(L){const q=d==null?void 0:d.data.map(({id:H,username:ee,lastname:G,profile_image:re})=>({id:H,name:`${ee} ${G}`,avatar:re?`${Ge}/${re}`:""}));Q(q)}},I=async()=>{var ee;z(!0);const d=await v.query({query:Ss,fetchPolicy:"no-cache",variables:{club_id:o,team_ids:i.values.team,...O?{}:{season_id:j==null?void 0:j.id}}});let{success:L,data:q}=(ee=d==null?void 0:d.data)==null?void 0:ee.teamDetails;const[H]=JSON.parse(q);D(H),z(!1)},M=()=>{B(!0)},p=()=>{B(!1)},$=()=>{i.handleChange(l),p(),i.setFieldValue("teamSettingChanged",!0)},n=d=>{d.target.name==="team"?(D({}),i.setValues({...i.values,team:d.target.value||"",coaches:[],trainingDays:[],trainingTimes:[],sessionsPerWeek:"",sessionDuration:"",numberOfActivities:"",teamSettingChanged:!1})):i.values.teamSettingChanged?i.handleChange(d):(C(d),M()),h&&!Y&&P(!0)};return t.useEffect(()=>{var d,L,q,H,ee,G;!Y&&((L=(d=i==null?void 0:i.values)==null?void 0:d.trainingTimes)!=null&&L.length)&&((q=h==null?void 0:h.trainingTimes)!=null&&q.length)&&((H=h==null?void 0:h.trainingTimes)==null?void 0:H.length)!==((G=(ee=i==null?void 0:i.values)==null?void 0:ee.trainingTimes)==null?void 0:G.length)&&P(!0)},[(x=h==null?void 0:h.trainingTimes)==null?void 0:x.length,(E=(m=i==null?void 0:i.values)==null?void 0:m.trainingTimes)==null?void 0:E.length,Y]),t.useEffect(()=>{i.values.team||(D({}),i.setValues({...i.values,sessionsPerWeek:"",sessionDuration:"",numberOfActivities:"",trainingDays:[],trainingTimes:[],coaches:[]},!1))},[i.values.team]),t.useEffect(()=>{if(A&&(W!=null&&W.length)&&i.values.team&&(!h||!h.team||h.team!==i.values.team)){const d=W.filter(he=>{var ge;return(ge=A==null?void 0:A.team_coaches)==null?void 0:ge.includes(he.id)}),{session_per_week:L,session_focus:q,number_of_practices:H,session_duration:ee,training_days:G,training_times:re}=A,ae={...i.values,sessionsPerWeek:L,numberOfActivities:H,sessionDuration:ee,trainingDays:G?G.split(","):[],trainingTimes:re&&re.length>0?re:G?G.split(",").map(he=>({day:he.trim(),time:"18:00"})):[],coaches:d};JSON.stringify(i.values)!==JSON.stringify(ae)&&i.setValues(ae)}},[W,A,i.values.team,h]),t.useEffect(()=>{!i.values.team&&F.length===1&&i.setFieldValue("team",F[0].toString())},[F.length,i.values.team]),t.useEffect(()=>{i.values.team&&I()},[i.values.team]),t.useEffect(()=>{o&&u()},[o]),t.useEffect(()=>{c&&(i.handleSubmit(),g(!1))},[c]),e.jsxs(e.Fragment,{children:[e.jsxs(a,{container:!0,gap:2,width:"100%",children:[e.jsx(a,{size:{xs:12,md:8},padding:{xs:"32px 16px 16px",sm:"32px 24px 16px",md:"32px 32px 16px"},children:e.jsx(we,{fullWidth:!0,label:"Team",name:"team",options:s,value:i.values.team,onChange:n,error:i.touched.team&&!!i.errors.team,helperText:i.touched.team&&i.errors.team})}),e.jsx(a,{size:12,children:e.jsx(Ze,{})}),i.values.team?e.jsxs(e.Fragment,{children:[e.jsx(a,{size:12,padding:{xs:"24px 16px 0px",sm:"24px 24px 0px",md:"24px 32px 0px"},children:e.jsx(N,{sx:rt.sessionText,children:"Session Setting"})}),w?e.jsx(a,{size:12,height:"240px",children:e.jsx(Be,{showText:!0,text:"Loading details..."})}):e.jsxs(e.Fragment,{children:[e.jsxs(a,{container:!0,width:"100%",spacing:3,px:{xs:2,sm:3,md:4},children:[e.jsx(a,{size:{xs:12,sm:6,md:4},children:e.jsx(we,{isShowClearable:!1,name:"sessionsPerWeek",label:"Sessions Per Week",onChange:n,value:i.values.sessionsPerWeek,options:as,
1customStyle:{minWidth:"100%"},error:i.touched.sessionsPerWeek&&!!i.errors.sessionsPerWeek,helperText:i.touched.sessionsPerWeek&&i.errors.sessionsPerWeek})}),e.jsx(a,{size:{xs:12,sm:6,md:4},children:e.jsx(we,{isShowClearable:!1,label:"Sessions Duration (Minutes)",name:"sessionDuration",onChange:n,value:i.values.sessionDuration,options:ds.map(d=>({...d,name:d.name.replace(" minutes","")})),customStyle:{minWidth:"100%"}})}),e.jsx(a,{size:{xs:12,sm:6,md:4},children:e.jsx(we,{isShowClearable:!1,label:"Number of Activities",name:"numberOfActivities",onChange:n,options:us,value:i.values.numberOfActivities,customStyle:{minWidth:"100%"}})}),e.jsx(a,{size:{xs:12,sm:6},children:e.jsx(we,{multiple:!0,isShowClearable:!1,label:"Training Days",name:"trainingDays",onChange:n,value:i.values.trainingDays,options:hs,error:i.touched.trainingDays&&!!i.errors.trainingDays,helperText:i.touched.trainingDays&&i.errors.trainingDays,customStyle:{minWidth:"100%"}})}),e.jsx(a,{size:{xs:12,md:6},children:e.jsx(rs,{name:"trainingTimes",label:"Training Times",value:i.values.trainingTimes,onChange:i.handleChange,selectedDays:i.values.trainingDays,error:!!(i.touched.trainingTimes&&(i.errors.trainingTimes||U)),helperText:i.touched.trainingTimes&&(i.errors.trainingTimes||U)})})]}),e.jsx(a,{size:12,px:{xs:2,sm:3,md:4},pb:4,children:e.jsx(ls,{label:"Coaches",name:"coaches",onChange:n,options:W.filter(d=>{var L;return(L=A==null?void 0:A.team_coaches)==null?void 0:L.includes(d.id)}),value:i.values.coaches,error:i.touched.coaches&&!!i.errors.coaches,helperText:i.touched.coaches&&i.errors.coaches})})]})]}):e.jsx(te,{height:"305px"})]}),e.jsx(He,{open:S,title:"Changing Team Settings",description:"Are you sure you wish to change the team settings for your plan?",handleClose:p,actionHandler:$})]})},at=({error:s,categoryId:o,selectedCollection:c,setSelectedCollection:g})=>{const h=Me(),F=Pe(),R=t.useRef(null),[V,v]=t.useState(""),[j,O]=t.useState([]),[W,Q]=t.useState(0),[A,D]=t.useState(!0),[S,B]=t.useState([]),[l,C]=t.useState([]),[Y,P]=t.useState(!1),[w,z]=t.useState({page:0,sortBy:"created_at",sortOrder:"DESC",selectedSortBy:"2"}),{data:U}=Vs(ys,{variables:{validSearchFiltersInput:{categoryId:o}},skip:l==null?void 0:l.length,fetchPolicy:"no-cache"}),se=(n,x,m)=>{w.sortOrder!==m&&O([]),z(E=>({...E,selectedSortBy:n,sortBy:x,sortOrder:m,page:0}))},i=()=>{O([]),B({}),P(!1),z(n=>({...n,page:0})),v("")},u=n=>{Ne(ze(n)).length===0&&V===""?P(!1):P(!0),B({...n}),O([]),g(null),z(x=>({...x,page:0}))},I=async n=>{var d,L;D(!0);const x=[...Ne(ze(S))],m=await F.query({query:bs,variables:{listCategoryCollectionsInput:{userId:h==null?void 0:h.id,limit:12,offset:w.page*12,sortBy:w.sortBy,sortOrder:w.sortOrder,filter:{tagIds:x,title:n,categoryIds:[o]}}},fetchPolicy:"no-cache"}),E=(L=(d=m==null?void 0:m.data)==null?void 0:d.getCategoryCollections)==null?void 0:L.data;w.page===0?O(E==null?void 0:E.rows):O(q=>[...q,...E==null?void 0:E.rows]),Q(E==null?void 0:E.count),D(!1)},M=t.useCallback(n=>{n[0].isIntersecting&&!A&&W>j.length&&!A&&z(m=>({...m,page:m.page+1}))},[A,j,W,w,A]),p=(n,x)=>{g(x?n.id:null)},$=n=>{v(n),P(!0),z(x=>({...x,page:0}))};return t.useEffect(()=>{let n=null;const x={root:null,threshold:1,rootMargin:"0px"},m=new IntersectionObserver(M,x);return R.current&&(m.observe(R.current),n=R.current),()=>{n&&m.unobserve(n)}},[M]),t.useEffect(()=>{var n,x;U&&C((x=(n=U==null?void 0:U.getValidSearchFilters)==null?void 0:n.data)==null?void 0:x[o])},[U,o]),t.useEffect(()=>{I(V)},[V,w.page,w.selectedSortBy,w.sortBy,w.sortOrder,S,o]),e.jsxs(a,{container:!0,spacing:2,width:"100%",children:[_e.WEEK_PLANS_46===o&&e.jsx(a,{size:12,children:e.jsx(Ys,{totalRecordsCount:W||0,flexWrap:"nowrap",removeTopBorder:!0,reduxSearchValue:V,btnSelectSelectId:w.selectedSortBy,isFilterApplied:Y,handleClearFilter:i,handleChangeBtnSelect:se,searchFilters:l,initialFilters:S,handleFiltersApplied:u,onChangeParentCallback:n=>$(n)})}),s.state&&e.jsx(a,{container:!0,pl:3,pt:_e.WEEK_PLANS_46===o?0:2,children:e.jsx(a,{item:!0,children:e.jsxs(N,{sx:{color:"error.main",fontWeight:700},children:["* ",s.message]})})}),!(j!=null&&j.length)&&!A&&e.jsx(a,{container:!0,width:"100%",justifyContent:"center",children:e.jsx(a,{item:!0,size:12,children:e.jsx(N,{sx:{textAlign:"center"},children:"The coaching vault is empty… for now. Try changing your filters!"})})}),e.jsxs(te,{width:"100%",children:[e.jsx(a,{container:!0,p:"16px 24px",spacing:5,width:"100%",children:j==null?void 0:j.filter(n=>n.content_type==="collection").map((n,x)=>{var m,E;return e.jsx(a,{size:{xs:12,sm:6,md:6,lg:4,xl:3},children:e.jsx(cs,{checkBox:!0,isModifiable:!0,showOverlay:!0,engineRoomBuilder:!0,showPracticeDetails:!0,showRemoveIcon:!1,id:n.id,title:n==null?void 0:n.title,shortDe
1scription:n==null?void 0:n.short_description,trailerText1:n==null?void 0:n.trailer_text1,trailerText2:n==null?void 0:n.trailer_text2,trailerText3:n==null?void 0:n.trailer_text3,duration:n.content_type==="video"?(m=n.videos[0])==null?void 0:m.duration:!1,collectionVideosCount:n.content_type==="collection"?(E=n==null?void 0:n.videos)==null?void 0:E.length:!1,imageUrl:n.main_poster_url,checked:c===n.id,handleClickCheckbox:d=>p(n,d),contentType:n==null?void 0:n.content_type})},n.id)})}),A&&e.jsxs(te,{sx:[Y?{marginTop:"100px"}:{marginTop:"20px"}],children:[" ",e.jsx(Be,{})," "]}),e.jsx(te,{ref:R,sx:{margin:"-10px"}})]})]})},dt=({planData:s,stepForward:o,stepBackward:c,collection:g=[],collectionId:h,setCollectionId:F,handleNextStep:R,numberOfActivities:V,handleStepBack:v,setStepForward:j,setStepBackward:O,collectionLoading:W,handleSetPlanData:Q})=>{var p,$,n;const[A,D]=t.useState(((p=s==null?void 0:s.planSelection)==null?void 0:p.selectedTab)||0),[S,B]=t.useState((($=s==null?void 0:s.planSelection)==null?void 0:$.selectedCollectionId)||null),[l,C]=t.useState(!1),[Y,P]=t.useState({state:!1,message:""}),w=(x,m)=>{D(m),B(null)},z=()=>{C(!0)},U=x=>{x||Q({shouldMoveToNextStep:!1}),C(!1)},se=(x,m)=>{Q({planSelection:{selectedCollectionId:S,selectedTab:A,overFlowPracticesAccepted:S!==h?!1:x},...S!==h&&{sessionMappedData:{}},shouldMoveToNextStep:m})},i=(x,m)=>qe(x,m).some(d=>d.practices.length!==m),u=(x,m)=>{se(x,m),R()},I=()=>{se(!0,!0),U(!0)},M=()=>{U(!1),v()};return t.useEffect(()=>{var x,m;s!=null&&s.shouldMoveToNextStep&&!W&&(g==null?void 0:g.length)>0&&(i(g,V)&&!((x=s==null?void 0:s.planSelection)!=null&&x.overFlowPracticesAccepted)?z():u(((m=s==null?void 0:s.planSelection)==null?void 0:m.overFlowPracticesAccepted)||!1,!0))},[W,g==null?void 0:g.length,s==null?void 0:s.shouldMoveToNextStep,(n=s==null?void 0:s.planSelection)==null?void 0:n.overFlowPracticesAccepted]),t.useEffect(()=>{var x;o&&(j(!1),S?se(((x=s==null?void 0:s.planSelection)==null?void 0:x.overFlowPracticesAccepted)||!1,!0):P({state:!0,message:"Please select a collection"}))},[o]),t.useEffect(()=>{c&&(O(!1),v(),Y.state&&P({state:!1,message:""}))},[c]),e.jsxs(e.Fragment,{children:[e.jsx(qs,{padding:0,tabHeaderPadding:"0",labels:[{name:"Season Plans"},{name:"4-6 Week Plans"}],selectedTab:A,handleTabChange:w,components:[_e.SEASON_PLANS,_e.WEEK_PLANS_46].map(x=>e.jsx(te,{height:"100%",children:e.jsx(at,{error:Y,categoryId:x,selectedCollection:S,setSelectedCollection:B})},x))}),e.jsx(He,{open:l,title:"Validating Number of Activities per Session",description:"The number of activities in your team’s session does not match the number of activities in the selected plan. If you map these sessions, they may not sync correctly.",cancelBtnTitle:"Update Team Settings",actionBtnTitle:"Continue",cancelBtnHandler:M,handleClose:()=>U(!1),actionHandler:I})]})},Fe={actionBtn:{height:"48px"},backBtn:{height:"48px",color:"text.primary",borderColor:s=>s.legend,"&:hover":{background:"none",borderColor:s=>s.legend}},cancelBtn:{border:"none","&:hover":{border:"none",background:"none"}}},cn=({open:s,handleClose:o,selectedCollectionId:c,dugout:g=!1})=>{var Se,ye;const h=Pe(),F=fs(),R=xs(),[V]=gs(),v=Me(),{currentSeason:j,isAllSeasonSelected:O}=Ye(),W=ps(r=>r.teams.team),[Q]=$s(ws),[A,D]=t.useState([]),[S,B]=t.useState(null),[l,C]=t.useState({}),[Y,P]=t.useState(!1),[w,z]=t.useState(0),[U,se]=t.useState([]),[i,u]=t.useState(!1),[I,M]=t.useState(0),[p,$]=t.useState(!1),[n,x]=t.useState(!1),[m,E]=t.useState(!1),[d,L]=t.useState(null),[q,H]=t.useState(c);Ke(r=>r.breakpoints.down("md"));const ee=async()=>{const{data:r}=await h.query({query:vs,variables:{club_id:v==null?void 0:v.club_id,...O?{}:{season_id:j==null?void 0:j.id}},fetchPolicy:"no-cache"}),{success:y,data:b}=r==null?void 0:r.getClubTeamsLite;if(y){const _=b==null?void 0:b.map(({id:ne,name:ie,logo:k})=>({id:ne.toString(),name:ie,avatar:`${Ge}/${k}`}));D(_)}},G=r=>{var b;let y=0;for(let _=0;_<(r==null?void 0:r.length);_++){const ne=r[_];if(ne.type==="divider"&&ne.divider.toLowerCase().includes("week")){let ie=!1;for(let k=_+1;k<r.length;k++){const X=r[k];if(X.type==="divider")break;if(X.type==="video"&&((b=X.video)!=null&&b.title)&&!X.video.title.toLowerCase().includes("trailer")){ie=!0;break}}ie&&y++}}return y},re=async()=>{var _,ne;$(!0);const r=await h.query({query:js,variables:{collectionLinkedChaptersInput:{collectionId:q,type:["video","divider"],addSource:!0}},fetchPolicy:"no-cache"}),y=((ne=(_=r==null?void 0:r.data)==null?void 0:_.collectionChapters)==null?void 0:ne.data)||[];se(y);const b=G(y);M(b),$(!1),ae({planSelection:{...l==null?void 0:l.planSelection,shouldMoveToNextStep:!0}})},ae=(r={},y,b,_,ne)=>{var ie,k;if(y&&b===1&&C(X=>({...X,sessionMappedData:{},...ne&&g&&{planSelection:{...X.planSelection,overFlowPracticesAccepted:!1}}})),_){C(r);return}g&&q&&((ie=r==null?void 0:r.planSelection)!=null&&ie.selectedCollectionId)&&((k=r==null?void 0:r.planSelection)==null?void 0:k.selectedCollectionId)!==q&&se([]),C(X=>({...X,...r}))},he=()=>{u(!0)},ge=()=>{E(!0)},pe=()=>{z(r=>r+1)},le=()=>{z(r=>r-1)},f=()=>{o(),z(0),C({}),H(null)},T=()=>{x(!1)},K=()=>{x(!0)},Z=async()=>{var ne,ie;K(),P(!0);const r={teamId:+((ne=l==null?void 0:l.teamSettings)==null?void 0:ne.team),season_id:j==null?void 0:j.id,sessions:(ie=l==null?void 0:l.sessionMappedData)==null?void 0:ie.sessions.map(k=>({...k.id?{id:k.id}:{},sessionName:k.sessionName,sessionDateTime:k.sessionDate,sessionDuration:k.sessionDuration,coaches:k.coaches.map(X=>X.id),practices:k.practices.filter(X=>X.videoAdded).map(X=>({id:X.id,source:X.source}))}))},{data:y}=await Q({variables:{createBulkSessionsInput:r}}),{success:b,ids:_}=y==null?void 0:y.createBulkSessions;b?(R(As({dugout:4})),F(`/dugout/session/${_[0]}`,{state:{notification:{msg:"Sessions added successfully",variant:"success"}}}),f()):V({msg:"Failed to add sessions.",variant:"error"}),P(!1),T()},de=()=>{if(d!=null&&d.acceptCurrent){const r=d.acceptCurrent();r!=null&&r.length&&C(y=>({...y,sessionMappedData:{...y.sessionMappedData,sessions:r},allSessionsAccepted:!1}))}},oe=()=>{if(d!=null&&d.acceptAll){const r=d.acceptAll();r!=null&&r.length&&C(y=>({...y,sessionMappedData:{...y.sessionMappedData,sessions:r},allSessionsAccepted:!0}))}},fe=r=>{L(r)},J=()=>{let r={teamSelection:!1,planSelection:!1,sessionMapping:!1,planBuilderResults:!1};return g?w===0?r.teamSelection=!0:w===1?r.planSelection=!0:w===2?r.sessionMapping=!0:w===3&&(r.planBuilderResults=!0):w===0?r.teamSelection=!0:w===1?r.sessionMapping=!0:w===2&&(r.planBuilderResults=!0),{config:r}},ce=()=>{var y,b;const{config:r}=J();return e.jsxs(e.Fragment,{children:[r.teamSelection&&e.jsx(ct,{teams:A,clubId:v==null?void 0:v.club_id,teamDetailData:l==null?void 0:l.teamSettings,stepForward:i,selectedTeam
1s:W,setStepForward:u,handleNextStep:pe,handleSetPlanData:ae}),g&&r.planSelection&&e.jsx(dt,{planData:l,stepForward:i,stepBackward:m,collectionId:q,collection:U,collectionLoading:p,numberOfActivities:((y=l==null?void 0:l.teamSettings)==null?void 0:y.numberOfActivities)||1,handleNextStep:pe,handleStepBack:le,setStepForward:u,setStepBackward:E,setCollectionId:H,handleSetPlanData:ae}),r.sessionMapping&&e.jsx(it,{currentSeason:j,collection:U,stepForward:i,stepBackward:m,teamSettings:l==null?void 0:l.teamSettings,sessionMappedData:l==null?void 0:l.sessionMappedData,numberOfWeeks:I,collectionLoading:p,setStepForward:u,setStepBackward:E,handleNextStep:pe,handleStepBack:le,handleSetPlanData:ae}),r.planBuilderResults&&e.jsx(st,{stepForward:i,stepBackward:m,teamSettings:l==null?void 0:l.teamSettings,sessions:(b=l==null?void 0:l.sessionMappedData)==null?void 0:b.sessions,setStepForward:u,setStepBackward:E,handleNextStep:pe,handleStepBack:le,onAccept:fe})]})},be=(r,y,b,_)=>{var X,ke;const ne=(ke=(X=b==null?void 0:b.sessionMappedData)==null?void 0:X.sessions)==null?void 0:ke.some(ss=>ss.accepted),k=y===(r?3:2);return{title:k?"Plan Builder Results":"Plan Builder",actionHandler:k?b!=null&&b.allSessionsAccepted?_.handleCreateSession:_.handleAcceptCurrent:_.handleContinue,actionBtnTitle:k?b!=null&&b.allSessionsAccepted?"Create Plan":"Accept":"Continue",primaryBtnHandler:k?_.handleAcceptAll:_.handlePrevious,primaryBtnTitle:k?"Accept All":"Previous",...k&&!ne&&{tertiaryBtnTitle:"Previous",tertiaryBtnHandler:_.handlePrevious}}};return t.useEffect(()=>{c&&Ee(l)&&H(c)},[c,l]),t.useEffect(()=>{var r,y;(r=l==null?void 0:l.planSelection)!=null&&r.selectedCollectionId&&H((y=l==null?void 0:l.planSelection)==null?void 0:y.selectedCollectionId)},[(Se=l==null?void 0:l.planSelection)==null?void 0:Se.selectedCollectionId]),t.useEffect(()=>{var y,b;const r=(b=(y=l==null?void 0:l.sessionMappedData)==null?void 0:y.sessions)==null?void 0:b.every(_=>_.accepted);r&&C(_=>({..._,allSessionsAccepted:r}))},[(ye=l==null?void 0:l.sessionMappedData)==null?void 0:ye.sessions]),t.useEffect(()=>{q&&s&&re()},[q,s]),t.useEffect(()=>{v!=null&&v.club_id&&ee()},[v==null?void 0:v.club_id]),t.useEffect(()=>{const r=ce();B(r)},[s,i,m,w,l,A,p,W.length,j]),e.jsxs(e.Fragment,{children:[e.jsx(Qe,{open:s,padding:"0px",showActionButtons:!0,loading:g&&p,handleClose:f,dialogMaxWidth:"lg",cancelBtn:!1,primaryBtn:!!w,primaryBtnStyle:Fe.backBtn,secondaryBtnTitle:"Cancel",secondaryBtnHandler:f,secondaryBtnStyle:Fe.cancelBtn,saveButtonStyle:Fe.actionBtn,...be(g,w,l,{handleCreateSession:Z,handleAcceptCurrent:de,handleContinue:he,handleAcceptAll:oe,handlePrevious:ge}),children:e.jsx(te,{height:{xs:"100vh",sm:"80vh",md:"70vh"},children:S})}),e.jsx(He,{open:n,showActionButtons:!1,title:"Populating Team Dugout",handleClose:Y?null:T,children:e.jsxs(a,{container:!0,justifyContent:"center",alignItems:"center",height:"100%",width:"100%",gap:2,children:[e.jsx(Be,{}),e.jsx(N,{sx:{fontSize:"16px",lineHeight:"24px",color:"text.primary"},children:"We are working our magic and populating your team’s sessions."})]})})]})};export{cn as PlanBuilder};

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.