import{q as O,r as y,j as i,v as me,s as Ce,t as ne,u as q,a as te,w as Oe,C as ve,R as ye,b as T,x as Ee,B as H,d as Pe,h as _e,e as we,i as De,y as ke,z as ae,A as Ie,D as Ne,M as Le,E as $e}from"./index-05c4d3d2.js";import{a as Te,c as se,D as Me,b as Fe,d as X,h as V,j as Re,A as Be,k as K,l as We,m as Q,n as ze,o as Ke,p as Ue,q as ge,r as oe,u as Ge,E as Ve,g as qe,X as xe,Y as be,f as Ye,R as He,T as Xe,s as ie,t as le,L as Je,e as Qe,G as Ze,C as et,i as tt}from"./GraphEmpty-b5d9d77a.js";var rt=["type","layout","connectNulls","ref"],nt=["key"];function B(e){"@babel/helpers - typeof";return B=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},B(e)}function ce(e,r){if(e==null)return{};var t=at(e,r),n,a;if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(a=0;a<l.length;a++)n=l[a],!(r.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(t[n]=e[n])}return t}function at(e,r){if(e==null)return{};var t={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(r.indexOf(n)>=0)continue;t[n]=e[n]}return t}function U(){return U=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},U.apply(this,arguments)}function ue(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),t.push.apply(t,n)}return t}function E(e){for(var r=1;r<arguments.length;r++){var t=arguments[r]!=null?arguments[r]:{};r%2?ue(Object(t),!0).forEach(function(n){D(e,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ue(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))})}return e}function R(e){return lt(e)||it(e)||ot(e)||st()}function st(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ot(e,r){if(e){if(typeof e=="string")return Z(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set")return Array.from(e);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Z(e,r)}}function it(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function lt(e){if(Array.isArray(e))return Z(e)}function Z(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function ct(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function de(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,je(n.key),n)}}function ut(e,r,t){return r&&de(e.prototype,r),t&&de(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function dt(e,r,t){return r=Y(r),pt(e,Ae()?Reflect.construct(r,t||[],Y(e).constructor):r.apply(e,t))}function pt(e,r){if(r&&(B(r)==="object"||typeof r=="function"))return r;if(r!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return ft(e)}function ft(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Ae(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Ae=function(){return!!e})()}function Y(e){return Y=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Y(e)}function ht(e,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(r&&r.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),r&&ee(e,r)}function ee(e,r){return ee=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,a){return n.__proto__=a,n},ee(e,r)}function D(e,r,t){return r=je(r),r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function je(e){var r=mt(e,"string");return B(r)=="symbol"?r:r+""}function mt(e,r){if(B(e)!="object"||!e)return e;var t=e[Symbol.toPrimitive];if(t!==void 0){var n=t.call(e,r||"default");if(B(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}var G=function(e){function r(){var t;ct(this,r);for(var n=arguments.length,a=new Array(n),l=0;l<n;l++)a[l]=arguments[l];return t=dt(this,r,[].concat(a)),D(t,"state",{isAnimationFinished:!0,totalLength:0}),D(t,"generateSimpleStrokeDasharray",function(s,u){return"".concat(u,"px ").concat(s-u,"px")}),D(t,"getStrokeDasharray",function(s,u,c){var v=c.reduce(function(p,A){return p+A});if(!v)return t.generateSimpleStrokeDasharray(u,s);for(var b=Math.floor(s/v),g=s%v,h=u-s,f=[],o=0,d=0;o<c.length;d+=c[o],++o)if(d+c[o]>g){f=[].concat(R(c.slice(0,o)),[g-d]);break}var m=f.length%2===0?[0,h]:[h];return[].concat(R(r.repeat(c,b)),R(f),m).map(function(p){return"".concat(p,"px")}).join(", ")}),D(t,"id",Ge("recharts-line-")),D(t,"pathRef",function(s){t.mainCurve=s}),D(t,"handleAnimationEnd",function(){t.setState({isAnimationFinished:!0}),t.props.onAnimationEnd&&t.props.onAnimationEnd()}),D(t,"handleAnimationStart",function(){t.setState({isAnimationFinished:!1}),t.props.onAnimationStart&&t.props.onAnimationStart()}),t}return ht(r,e),ut(r,[{key:"componentDidMount",value:function(){if(this.props.isAnimationActive){var n=this.getTotalLength();this.setState({totalLength:n})}}},{key:"componentDidUpdate",value:function(){if(this.props.isAnimationActive){var n=this.getTotalLength();n!==this.state.totalLength&&this.setState({totalLength:n})}}},{key:"getTotalLength",value:function(){var n=this.mainCurve;try{return n&&n.getTotalLength&&n.getTotalLength()||0}catch{return 0}}},{key:"renderErrorBar",value:function(n,a){if(this.props.isAnimationActive&&!this.state.isAnimationFinished)return null;var l=this.props,s=l.points,u=l.xAxis,c=l.yAxis,v=l.layout,b=l.children,g=Fe(b,Ve);if(!g)return null;var h=function(d,m){return{x:d.x,y:d.y,value:d.value,errorVal:ge(d.payload,m)}},f={clipPath:n?"url(#clipPath-".concat(a,")"):null};return O.createElement(X,f,g.map(function(o){return O.cloneElement(o,{key:"bar-".concat(o.props.dataKey),data:s,xAxis:u,yAxis:c,layout:v,dataPointFormatter:h})}))}},{key:"renderDots",value:function(n,a,l){var s=this.props.isAnimationActive;if(s&&!this.state.isAnimationFinished)return null;var u=this.props,c=u.dot,v=u.points,b=u.dataKey,g=V(this.props,!1),h=V(c,!0),f=v.map(function(d,m){var p=E(E(E({key:"dot-".concat(m),r:3},g),h),{},{value:d.value,dataKey:b,cx:d.x,cy:d.y,index:m,payload:d.payload});return r.renderDotItem(c,p)}),o={clipPath:n?"url(#clipPath-".concat(a?"":"dots-").concat(l,")"):null};return O.createElement(X,U({className:"recharts-line-dots",key:"dots"},o),f)}},{key:"renderCurveStatically",value:function(n,a,l,s){var u=this.props,c=u.type,v=u.layout,b=u.connectNulls;u.ref;var g=ce(u,rt),h=E(E(E({},V(g,!0)),{},{fill:"none",className:"recharts-line-curve",clipPath:a?"url(#clipPath-".concat(l,")"):null,points:n},s),{},{type:c,layout:v,connectNulls:b});return O.createElement(Re,U({},h,{pathRef:this.pathRef}))}},{key:"renderCurveWithAnimation",value:function(n,a){var l=this,s=this.props,u=s.points,c=s.strokeDasharray,v=s.isAnimationActive,b=s.animationBegin,g=s.animationDuration,h=s.animationEasing,f=s.animationId,o=s.animateNewValues,d=s.width,m=s.height,p=this.state,A=p.prevPoints,S=p.totalLength;return O.createElement(Be,{begin:b,duration:g,isActive:v,easing:h,from:{t:0},to:{t:1},key:"line-".concat(f),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(I){var P=I.t;if(A){var N=A.length/u.length,k=u.map(function(C,W){var $=Math.floor(W*N);if(A[$]){var x=A[$],j=K(x.x,C.x),F=K(x.y,C.y);return E(E({},C),{},{x:j(P),y:F(P)})}if(o){var z=K(d*2,C.x),Se=K(m/2,C.y);return E(E({},C),{},{x:z(P),y:Se(P)})}return E(E({},C),{},{x:C.x,y:C.y})});return l.renderCurveStatically(k,n,a)}var L=K(0,S),_=L(P),w;if(c){var M="".concat(c).split(/[,\s]+/gim).map(function(C){return parseFloat(C)});w=l.getStrokeDasharray(_,S,M)}else w=l.generateSimpleStrokeDasharray(S,_);return l.renderCurveStatically(u,n,a,{strokeDasharray:w})})}},{key:"renderCurve",value:function(n,a){var l=this.props,s=l.points,u=l.isAnimationActive,c=this.state,v=c.prevPoints,b=c.totalLength;return u&&s&&s.length&&(!v&&b>0||!We(v,s))?this.renderCurveWithAnimation(n,a):this.renderCurveStatically(s,n,a)}},{key:"render",value:function(){var n,a=this.props,l=a.hide,s=a.dot,u=a.points,c=a.className,v=a.xAxis,b=a.yAxis,g=a.top,h=a.left,f=a.width,o=a.height,d=a.isAnimationActive,m=a.id;if(l||!u||!u.length)return null;var p=this.state.isAnimationFinished,A=u.length===1,S=se("recharts-line",c),I=v&&v.allowDataOverflow,P=b&&b.allowDataOverflow,N=I||P,k=Q(m)?this.id:m,L=(n=V(s,!1))!==null&&n!==void 0?n:{r:3,strokeWidth:2},_=L.r,w=_===void 0?3:_,M=L.strokeWidth,C=M===void 0?2:M,W=ze(s)?s:{},$=W.clipDot,x=$===void 0?!0:$,j=w*2+C;return O.createElement(X,{className:S},I||P?O.createElement("defs",null,O.createElement("clipPath",{id:"clipPath-".concat(k)},O.createElement("rect",{x:I?h:h-f/2,y:P?g:g-o/2,width:I?f:f*2,height:P?o:o*2})),!x&&O.createElement("clipPath",{id:"clipPath-dots-".concat(k)},O.createElement("rect",{x:h-j/2,y:g-j/2,width:f+j,height:o+j}))):null,!A&&this.renderCurve(N,k),this.renderErrorBar(N,k),(A||s)&&this.renderDots(N,x,k),(!d||p)&&Ke.renderCallByParent(this.props,u))}}],[{key:"getDerivedStateFromProps",value:function(n,a){return n.animationId!==a.prevAnimationId?{prevAnimationId:n.animationId,curPoints:n.points,prevPoints:a.curPoints}:n.points!==a.curPoints?{curPoints:n.points}:null}},{key:"repeat",value:function(n,a){for(var l=n.length%2!==0?[].concat(R(n),[0]):n,s=[],u=0;u<a;++u)s=[].concat(R(s),R(l));return s}},{key:"renderDotItem",value:function(n,a){var l;if(O.isValidElement(n))l=O.cloneElement(n,a);else if(Te(n))l=n(a);else{var s=a.key,u=ce(a,nt),c=se("recharts-line-dot",typeof n!="boolean"?n.className:"");l=O.createElement(Me,U({key:s},u,{className:c}))}return l}}])}(y.PureComponent);D(G,"displayName","Line");D(G,"defaultProps",{xAxisId:0,yAxisId:0,connectNulls:!1,activeDot:!0,dot:!0,legendType:"line",stroke:"#3182bd",strokeWidth:1,fill:"#fff",points:[],isAnimationActive:!Ue.isSsr,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",hide:!1,label:!1});D(G,"getComposedData",function(e){var r=e.props,t=e.xAxis,n=e.yAxis,a=e.xAxisTicks,l=e.yAxisTicks,s=e.dataKey,u=e.bandSize,c=e.displayedData,v=e.offset,b=r.layout,g=c.map(function(h,f){var o=ge(h,s);return b==="horizontal"?{x:oe({axis:t,ticks:a,bandSize:u,entry:h,index:f}),y:Q(o)?null:n.scale(o),value:o,payload:h}:{x:Q(o)?null:t.scale(o),y:oe({axis:n,ticks:l,bandSize:u,entry:h,index:f}),value:o,payload:h}});return E({points:g,layout:b},v)});var vt=qe({chartName:"LineChart",GraphicalChild:G,axisComponents:[{axisType:"xAxis",AxisComp:xe},{axisType:"yAxis",AxisComp:be}],formatAxisMap:Ye});const yt=e=>i.jsx("div",{className:"graph-empty",children:i.jsxs("div",{className:"graph-empty-content",children:[i.jsx("img",{className:"graph-empty-image",src:Qe,alt:"empty state"}),i.jsxs("h3",{className:"graph-empty-heading",children:["You have not added any ",i.jsx("br",{})," classes yet."]})]})});function pe(e){let r=-1;return e.forEach(t=>{Object.keys(t).forEach(function(n){n!=="name"&&parseFloat(t[n])>r&&(r=parseFloat(t[n]))})}),r}function gt(e){let r=25;e<=100&&(e=100);let t=Array.from(new Array(Math.floor(e/r)),(n,a)=>r*(a+1));return e%r>0&&t.push(r*(Math.floor(e/r)+1)),t}function xt({graphData:e,enrollmentData:r,updateLineHover:t,updateGraphHover:n,isMobile:a,graphEmpty:l,selectedCourses:s}){const u={textAnchor:"middle",fontSize:"12px"};return i.jsxs("div",{children:[i.jsx("div",{className:"enrollment-recharts-container",children:i.jsx(He,{width:a?500:"100%",height:400,children:i.jsxs(vt,{data:e,onMouseMove:n,margin:{top:0,right:0,left:-15,bottom:0},children:[i.jsx(xe,{dataKey:"name",interval:19}),i.jsx(be,{type:"number",unit:"%",domain:[0,Math.max(pe(e),100)],ticks:gt(Math.max(pe(e),100))}),i.jsx(Xe,{formatter:c=>`${c}%`,labelFormatter:c=>`Day ${c-1}`,cursor:!l}),!l&&r.map((c,v)=>i.jsx(G,{name:`${c.title}`,type:"monotone",dataKey:c.id,stroke:me.colors[c.colorId],strokeWidth:3,dot:!1,activeDot:{onMouseOver:(b,g)=>t(g.dataKey,g.payload.name)},connectNulls:!0},v)),!l&&i.jsx(ie,{x:r[0].telebears.phase2_start_day,stroke:"black",strokeDasharray:"3 3",children:i.jsx(le,{angle:-90,position:"insideLeft",style:u,offset:10,children:`Phase II Start (${s[0].semester})`})}),!l&&i.jsx(ie,{x:r[0].telebears.adj_start_day,stroke:"black",strokeDasharray:"3 3",children:i.jsx(le,{angle:-90,position:"insideLeft",style:u,offset:10,children:`Adjustment Start (${s[0].semester})`})}),a&&i.jsx(Je,{height:10,horizontalAlign:"left",layout:"vertical",iconType:"circle"})]})})}),l&&i.jsx(yt,{})]})}function bt({title:e,subtitle:r,semester:t,instructor:n,selectedPoint:a,telebears:l,color:s,enrolledMax:u,waitlistedMax:c}){const{period:v,daysAfterPeriodStarts:b}=y.useMemo(()=>Ce(a,l),[a,l]);return i.jsxs("div",{className:"enrollment-info",children:[i.jsxs("div",{className:"header",children:[i.jsx("div",{className:"square",style:{backgroundColor:s}}),i.jsx("div",{className:"course",children:e})]}),i.jsx("div",{className:"title",children:r}),i.jsx("div",{className:"info",children:`${t} • ${n}`}),i.jsxs("div",{className:"stat-section",children:[i.jsxs("div",{className:"date",children:[b," Days After ",v]}),i.jsxs("div",{className:"enrolled-stat",children:[i.jsx("span",{className:"text",children:"Enrolled:"})," ",ne(a.enrolled,u,a.enrolled_percent)]}),i.jsxs("div",{className:"waitlisted-stat",children:[i.jsx("span",{className:"text",children:"Waitlisted:"})," ",ne(a.waitlisted,c,a.waitlisted_percent)]})]})]})}function At({isMobile:e,updateClassCardEnrollment:r}){const[t,n]=y.useState(!1),{enrollmentData:a,graphData:l,selectedCourses:s}=q(f=>f.enrollment),u=te();y.useEffect(()=>{u(Oe(s))},[s,u]);const c=y.useCallback((f,o)=>{if(!f||!a||a.length===0)return;const d=a.filter(A=>f.id===A.id)[0];if(!(d&&d.data.filter(A=>A.day===o).length))return;const p={...f,...d,hoverDay:o};n(p)},[a]);y.useEffect(()=>{a.length>0&&c(s[0],1);const f=a.map(p=>p.data[p.data.length-1]),o=a.map(p=>p.telebears),d=f.map(p=>[p.enrolled,p.enrolled_max,p.enrolled_percent]),m=f.map(p=>[p.waitlisted,p.waitlisted_max,p.waitlisted_percent]);r(f,o,d,m)},[a,r,s,c]);const v=y.useCallback((f,o)=>{const d=s.filter(m=>f===m.id)[0];c(d,o)},[s,c]),b=y.useCallback(f=>{const{isTooltipActive:o,activeLabel:d}=f;if(!o||s.length!==1)return;const m=s[0];c(m,d)},[s,c]),g=y.useMemo(()=>a.length?a[0].telebears:{},[a]),h=y.useMemo(()=>a.length===0||s.length===0,[a,s]);return i.jsx("div",{className:"enrollment-graph",children:i.jsx(ve,{fluid:!0,children:i.jsxs(ye,{children:[i.jsxs(T,{xs:{span:12,order:2},sm:{span:12,order:2},md:{span:8,order:1},lg:{span:8,order:1},children:[e&&i.jsx("div",{className:"enrollment-mobile-heading",children:" Enrollment "}),i.jsx(xt,{graphData:l,enrollmentData:a,selectedCourses:s,updateLineHover:v,updateGraphHover:b,graphEmpty:h,isMobile:e})]}),h&&i.jsx(T,{xs:{span:12,order:1},sm:{span:12,order:1},md:{span:4,order:2},lg:{span:4,order:2},children:i.jsx(Ze,{pageType:"enrollment"})}),!e&&!h&&i.jsx(T,{md:{span:4,order:2},lg:{span:4,order:2},children:t&&i.jsx(bt,{title:t.title,subtitle:t.subtitle,semester:t.semester,instructor:t.instructor==="all"?"All Instructors":t.instructor,selectedPoint:t.data.filter(f=>f.day===t.hoverDay)[0],todayPoint:t.data[t.data.length-1],telebears:g,color:me.colors[t.colorId],enrolledMax:t.enrolled_max,waitlistedMax:t.waitlisted_max})})]})})})}const jt=e=>e?e.map(t=>({value:t.id,label:`${t.abbreviation} ${t.course_number}`,course:t})):[],St=e=>e.charAt(0).toUpperCase()+e.slice(1),re=e=>`${St(e.semester)} ${e.year}`,Ct=e=>{const r=[],t=new Map;for(const n of e){let a=re(n);t.has(a)||(t.set(a,!0),r.push({value:a,label:a}))}return r},fe=(e,r)=>{if(e.length===0||r===void 0||r==="")return[];const t=[];let n=e.filter(l=>re(l)===r)[0].sections;n.length>1&&t.push({value:"all",label:"All Instructors"});for(var a of n){let l=`${a.instructor===null||a.instructor===""?"None":a.instructor} / ${a.section_number}`;t.push({value:l,label:l,sectionNumber:l.split(" / ")[1],sectionId:a.section_id})}return t},J={clearIndicator:e=>({...e,marginRight:0,paddingRight:0})};function Ot({classes:e,isFull:r,isMobile:t,addCourse:n,sectionNumber:a,fromCatalog:l}){const[s,u]=y.useState(0),{sections:c,selectPrimary:v,selectSecondary:b,selectedCourses:g}=q(x=>x.enrollment),[h,f]=y.useState(v),[o,d]=y.useState(b),[m,p]=y.useState(void 0),A=te(),S=y.useCallback(x=>{if(x===null){L(),u(0);return}u(x.value),p(x),f(""),d(""),A(Ee(x))},[A]);y.useEffect(()=>{l&&S({value:l.id,addSelected:!0})},[l,S]),y.useEffect(()=>f(v),[v]),y.useEffect(()=>d(b),[b]),y.useEffect(()=>{if(g&&g.length>0){const x=g[g.length-1],j={value:x.courseID,label:x.course,course:x};S(j)}},[g]);const I=x=>{f(x?x.value:""),d(x?{value:"all",label:"All Instructors"}:"")},P=x=>{d(x||{value:"all",label:"All Instructors"})},N=()=>{let x;return x=c.filter(j=>re(j)===h)[0].sections.filter(j=>o.value==="all"?!0:j.instructor===o.value.split(" / ")[0]).filter(j=>a?j.section_number===a:!0).map(j=>j.section_id),x},k=()=>{let x=fe(c,h),j="",F=[];x.length===1?(j=x[0].value,F=[x[0].sectionId]):(o.value==="all"?j="all":j=o.value,o.sectionId?F=[o.sectionId]:F=N());let z={courseID:s,instructor:j,semester:h,sections:F};z.id=_e(z),n(z),L()},L=()=>{f(""),d("")},_=y.useMemo(()=>Ct(c),[c]),w=y.useMemo(()=>fe(c,h),[c,h]),M=y.useMemo(()=>_&&_.length===1&&h,[_,h]),C=y.useMemo(()=>w&&w.length===1&&o.value,[w,o]),W=y.useMemo(()=>h===""?"":{value:h,label:h},[h]),$=y.useMemo(()=>o===""?"":o===""?{value:"all",label:"All Instructors"}:o,[o]);return i.jsx(ve,{fluid:!0,className:"enrollment-search-bar",children:i.jsxs(ye,{style:{marginBottom:10},children:[i.jsx(T,{lg:4,children:i.jsx(H,{courseSearch:!0,name:"selectClass",placeholder:"Choose a class...",value:m,options:jt(e),onChange:S,components:{IndicatorSeparator:()=>null},styles:J})}),i.jsx(T,{xs:6,sm:6,lg:3,children:i.jsx(H,{name:"instrSems",placeholder:t?"Select...":"Select an option...",value:M?_[0]:W,options:_,onChange:I,isDisabled:!s,isClearable:!1,components:{IndicatorSeparator:()=>null},styles:J})}),i.jsx(T,{xs:6,sm:6,lg:3,children:i.jsx(H,{name:"section",placeholder:t?"Select...":"Select an option...",value:C?w[0]:$,options:w,onChange:P,isDisabled:!s,isClearable:!1,components:{IndicatorSeparator:()=>null},styles:J})}),i.jsx(T,{lg:2,children:i.jsx(Pe,{className:"btn-bt-green",onClick:k,disabled:!s||!(h&&o)||r,children:"Add Class"})})]})})}const he=e=>e.toLowerCase().split(" ").join("-"),Et=e=>`Enrollment ${e.length>0?`| ${e.map(r=>` ${r.course}`)}`:""}`;function wt(){const[e,r]=y.useState([]),{context:t,selectedCourses:n,usedColorIds:a}=q(o=>o.enrollment),{mobile:l}=q(o=>o.common),s=te(),u=we(),c=De();y.useEffect(()=>{const o=()=>{try{let d=u.pathname;d&&(d==="/enrollment/"||d==="/enrollment")?s(ae()):d&&s($e(d,c))}catch{c("/error")}};s(ke()),s(ae()),o()},[]);const v=y.useCallback(o=>{let d=o.instructor==="all"?"all":o.sections[0],m=`${o.colorId}-${o.courseID}-${he(o.semester)}-${d}`,p=u.pathname;p&&!p.includes(m)&&(p+=p==="/enrollment"?"/":"",p+=p==="/enrollment/"?"":"&",p+=m,c(p,{replace:!0}))},[c,u.pathname]),b=y.useCallback(o=>{for(let m of n)if(m.id===o.id)return;let d="";for(let m=0;m<4;m++)if(!a.includes(m.toString())){d=m.toString();break}o.colorId=d,v(o),s(Ie(o))},[s,v,n,a]),g=y.useCallback(o=>{let d=n.filter(p=>p.id!==o),m="/enrollment/";for(let p=0;p<d.length;p++){let A=d[p];p!==0&&(m+="&");let S=A.instructor==="all"?"all":A.sections[0];m+=`${A.colorId}-${A.courseID}-${he(A.semester)}-${S}`}c(m,{replace:!0})},[c,n]),h=y.useCallback((o,d)=>{g(o),s(Ne(o,d))},[g,s]),f=y.useCallback((o,d,m,p)=>{for(var A=[],S=0;S<o.length;S++)A.push([o[S],d[S],m[S],p[S]]);r(A)},[]);return i.jsxs("div",{className:"viewport-app",children:[i.jsx(Le,{title:Et(n)}),i.jsxs("div",{className:"enrollment",children:[i.jsx(Ot,{classes:t.courses,addCourse:b,fromCatalog:u.state?u.state.course:!1,isFull:n.length===4,isMobile:l}),i.jsx(et,{selectedCourses:n,removeCourse:h,additionalInfo:e,type:"enrollment",isMobile:l}),i.jsx(At,{id:"gradesGraph",title:"Enrollment",updateClassCardEnrollment:f,isMobile:l}),!l&&i.jsxs("div",{className:"xlabel",children:["% of Class Filled ",i.jsx("span",{style:{fontWeight:"normal"},children:"vs"})," Days After Phase 1"]}),i.jsxs("div",{className:"disclaimer",children:[i.jsx("img",{src:tt,className:"info",alt:""}),i.jsxs("p",{children:["We source our historic course and enrollment data directly from Berkeley"," ",i.jsx("a",{href:"https://sis.berkeley.edu/",children:"Student Information System's"})," Course and Class APIs."]})]})]})]})}export{wt as Component};