mario-education 2.0.272-staging → 2.0.274-staging

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),q=require("react"),Ls=require("react-redux"),fe=require("mario-core"),Tt=require("./constants-Y_C_gYKV.cjs"),n=require("./createSvgIcon-80BYZRkM.cjs"),kt=require("./Lock-sb5A7lQ_.cjs"),us=require("./createSimplePaletteValueFilter-AdJXc3lg.cjs"),ls=require("./useFormControl-BEoQDwMi.cjs"),Oe=require("./useSlot-BmOOxdUo.cjs"),Xe=require("./Popper-z5NQBMki.cjs"),je=require("./ButtonBase-ccqaGb1E.cjs"),Ye=require("./index-C4Qk4LM5.cjs"),it=require("./useTheme-CpZul6o1.cjs"),Fs=require("./useForkRef-DslX1IAY.cjs"),St=require("./assertThisInitialized-CrnpFIv9.cjs"),ms=require("react-dom"),We=require("@mui/x-date-pickers"),ze=require("moment"),ts=require("./Check-CXQoiPU8.cjs"),Pe=require("@mui/material"),os=require("@dnd-kit/core"),vs=require("@dnd-kit/sortable"),Pt=require("./utilities.esm-DImhXrxQ.cjs"),ns=require("./Close-BIATKP7y.cjs"),Nt=require("./Add-CZVVrSLp.cjs"),at=require("./AdapterMoment-B-q0UCj0.cjs"),Ct=require("./CheckCircle-DBI85rV-.cjs"),js=require("./ownerDocument-4MViGo3k.cjs"),rs=require("./EmotionIcons-CG5Kgp0c.cjs"),ve=require("./LockIcon-BtijFlNm.cjs"),Et=require("./ArrowBack-CarS3Fo5.cjs");function Dt(s){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const r in s)if(r!=="default"){const i=Object.getOwnPropertyDescriptor(s,r);Object.defineProperty(o,r,i.get?i:{enumerable:!0,get:()=>s[r]})}}return o.default=s,Object.freeze(o)}const xe=Dt(q);function Lt(s){const{prototype:o={}}=s;return!!o.isReactComponent}function lt(s,o,r,i,l){const a=s[o],u=l||o;if(a==null||typeof window>"u")return null;let c;const y=a.type;return typeof y=="function"&&!Lt(y)&&(c="Did you accidentally use a plain function component for an element instead?"),c!==void 0?new Error(`Invalid ${i} \`${u}\` supplied to \`${r}\`. Expected an element that can hold a ref. ${c} For more information see https://mui.com/r/caveat-with-refs-guide`):null}const Qs=je.chainPropTypes(n.PropTypes.element,lt);Qs.isRequired=je.chainPropTypes(n.PropTypes.element.isRequired,lt);const Mt={border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"absolute",whiteSpace:"nowrap",width:"1px"},Bs={disabled:!1};var It=process.env.NODE_ENV!=="production"?n.PropTypes.oneOfType([n.PropTypes.number,n.PropTypes.shape({enter:n.PropTypes.number,exit:n.PropTypes.number,appear:n.PropTypes.number}).isRequired]):null;process.env.NODE_ENV!=="production"&&n.PropTypes.oneOfType([n.PropTypes.string,n.PropTypes.shape({enter:n.PropTypes.string,exit:n.PropTypes.string,active:n.PropTypes.string}),n.PropTypes.shape({enter:n.PropTypes.string,enterDone:n.PropTypes.string,enterActive:n.PropTypes.string,exit:n.PropTypes.string,exitDone:n.PropTypes.string,exitActive:n.PropTypes.string})]);var Rt=function(o){return o.scrollTop},as="unmounted",Je="exited",Ke="entering",ss="entered",Ms="exiting",Be=(function(s){je._inheritsLoose(o,s);function o(i,l){var a;a=s.call(this,i,l)||this;var u=l,c=u&&!u.isMounting?i.enter:i.appear,y;return a.appearStatus=null,i.in?c?(y=Je,a.appearStatus=Ke):y=ss:i.unmountOnExit||i.mountOnEnter?y=as:y=Je,a.state={status:y},a.nextCallback=null,a}o.getDerivedStateFromProps=function(l,a){var u=l.in;return u&&a.status===as?{status:Je}:null};var r=o.prototype;return r.componentDidMount=function(){this.updateStatus(!0,this.appearStatus)},r.componentDidUpdate=function(l){var a=null;if(l!==this.props){var u=this.state.status;this.props.in?u!==Ke&&u!==ss&&(a=Ke):(u===Ke||u===ss)&&(a=Ms)}this.updateStatus(!1,a)},r.componentWillUnmount=function(){this.cancelNextCallback()},r.getTimeouts=function(){var l=this.props.timeout,a,u,c;return a=u=c=l,l!=null&&typeof l!="number"&&(a=l.exit,u=l.enter,c=l.appear!==void 0?l.appear:u),{exit:a,enter:u,appear:c}},r.updateStatus=function(l,a){if(l===void 0&&(l=!1),a!==null)if(this.cancelNextCallback(),a===Ke){if(this.props.unmountOnExit||this.props.mountOnEnter){var u=this.props.nodeRef?this.props.nodeRef.current:ms.findDOMNode(this);u&&Rt(u)}this.performEnter(l)}else this.performExit();else this.props.unmountOnExit&&this.state.status===Je&&this.setState({status:as})},r.performEnter=function(l){var a=this,u=this.props.enter,c=this.context?this.context.isMounting:l,y=this.props.nodeRef?[c]:[ms.findDOMNode(this),c],m=y[0],g=y[1],M=this.getTimeouts(),F=c?M.appear:M.enter;if(!l&&!u||Bs.disabled){this.safeSetState({status:ss},function(){a.props.onEntered(m)});return}this.props.onEnter(m,g),this.safeSetState({status:Ke},function(){a.props.onEntering(m,g),a.onTransitionEnd(F,function(){a.safeSetState({status:ss},function(){a.props.onEntered(m,g)})})})},r.performExit=function(){var l=this,a=this.props.exit,u=this.getTimeouts(),c=this.props.nodeRef?void 0:ms.findDOMNode(this);if(!a||Bs.disabled){this.safeSetState({status:Je},function(){l.props.onExited(c)});return}this.props.onExit(c),this.safeSetState({status:Ms},function(){l.props.onExiting(c),l.onTransitionEnd(u.exit,function(){l.safeSetState({status:Je},function(){l.props.onExited(c)})})})},r.cancelNextCallback=function(){this.nextCallback!==null&&(this.nextCallback.cancel(),this.nextCallback=null)},r.safeSetState=function(l,a){a=this.setNextCallback(a),this.setState(l,a)},r.setNextCallback=function(l){var a=this,u=!0;return this.nextCallback=function(c){u&&(u=!1,a.nextCallback=null,l(c))},this.nextCallback.cancel=function(){u=!1},this.nextCallback},r.onTransitionEnd=function(l,a){this.setNextCallback(a);var u=this.props.nodeRef?this.props.nodeRef.current:ms.findDOMNode(this),c=l==null&&!this.props.addEndListener;if(!u||c){setTimeout(this.nextCallback,0);return}if(this.props.addEndListener){var y=this.props.nodeRef?[this.nextCallback]:[u,this.nextCallback],m=y[0],g=y[1];this.props.addEndListener(m,g)}l!=null&&setTimeout(this.nextCallback,l)},r.render=function(){var l=this.state.status;if(l===as)return null;var a=this.props,u=a.children;a.in,a.mountOnEnter,a.unmountOnExit,a.appear,a.enter,a.exit,a.timeout,a.addEndListener,a.onEnter,a.onEntering,a.onEntered,a.onExit,a.onExiting,a.onExited,a.nodeRef;var c=St._objectWithoutPropertiesLoose(a,["children","in","mountOnEnter","unmountOnExit","appear","enter","exit","timeout","addEndListener","onEnter","onEntering","onEntered","onExit","onExiting","onExited","nodeRef"]);return q.createElement(je.TransitionGroupContext.Provider,{value:null},typeof u=="function"?u(l,c):q.cloneElement(q.Children.only(u),c))},o})(q.Component);Be.contextType=je.TransitionGroupContext;Be.propTypes=process.env.NODE_ENV!=="production"?{nodeRef:n.PropTypes.shape({current:typeof Element>"u"?n.PropTypes.any:function(s,o,r,i,l,a){var u=s[o];return n.PropTypes.instanceOf(u&&"ownerDocument"in u?u.ownerDocument.defaultView.Element:Element)(s,o,r,i,l,a)}}),children:n.PropTypes.oneOfType([n.PropTypes.func.isRequired,n.PropTypes.element.isRequired]).isRequired,in:n.PropTypes.bool,mountOnEnter:n.PropTypes.bool,unmountOnExit:n.PropTypes.bool,appear:n.PropTypes.bool,enter:n.PropTypes.bool,exit:n.PropTypes.bool,timeout:function(o){var r=It;o.addEndListener||(r=r.isRequired);for(var i=arguments.length,l=new Array(i>1?i-1:0),a=1;a<i;a++)l[a-1]=arguments[a];return r.apply(void 0,[o].concat(l))},addEndListener:n.PropTypes.func,onEnter:n.PropTypes.func,onEntering:n.PropTypes.func,onEntered:n.PropTypes.func,onExit:n.PropTypes.func,onExiting:n.PropTypes.func,onExited:n.PropTypes.func}:{};function Ze(){}Be.defaultProps={in:!1,mountOnEnter:!1,unmountOnExit:!1,appear:!1,enter:!0,exit:!0,onEnter:Ze,onEntering:Ze,onEntered:Ze,onExit:Ze,onExiting:Ze,onExited:Ze};Be.UNMOUNTED=as;Be.EXITED=Je;Be.ENTERING=Ke;Be.ENTERED=ss;Be.EXITING=Ms;function qe(s,o){return`${s.toLowerCase()}-${o}`}const Ot=({color:s="#242424",size:o=24,className:r})=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:o,height:o,viewBox:"0 0 24 24",fill:"none",stroke:s,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:r,children:[e.jsx("path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z"}),e.jsx("path",{d:"M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z"}),e.jsx("path",{d:"M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4"}),e.jsx("path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375"}),e.jsx("path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5"}),e.jsx("path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396"}),e.jsx("path",{d:"M19.938 10.5a4 4 0 0 1 .585.396"}),e.jsx("path",{d:"M6 18a4 4 0 0 1-1.967-.516"}),e.jsx("path",{d:"M19.967 17.484A4 4 0 0 1 18 18"})]}),$t=({color:s="#242424",size:o=24,className:r})=>e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:o,height:o,viewBox:"0 0 24 24",fill:"none",stroke:s,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:r,children:e.jsx("path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"})}),At=({color:s="#242424",size:o=24,className:r})=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:o,height:o,viewBox:"0 0 24 24",fill:"none",stroke:s,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:r,children:[e.jsx("path",{d:"M5 22h14"}),e.jsx("path",{d:"M5 2h14"}),e.jsx("path",{d:"M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22"}),e.jsx("path",{d:"M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2"})]}),Is=[{id:"ai_literacy",title:"AI Literacy (Eblana Learning)",description:"Educate students about responsible and safe AI usage, and monitor how they use AI.",questions:[{id:"m_ai_1",text:"How often do you use generative AI tools like ChatGPT or Gemini?",type:"mcq",options:["Never","Rarely","Sometimes","Often","Always"]},{id:"m_ai_2",text:"Which AI tools do you use most frequently for your school projects?",type:"text"},{id:"m_ai_3",text:"What is one thing you keep in mind to ensure you use AI safely and ethically?",type:"text"},{id:"m_ai_4",text:"How confident do you feel in identifying biased or incorrect information generated by AI? (1-5)",type:"scale"}]},{id:"bullying",title:"Bullying & Safety (Escalation Engaged)",description:"Designed to identify bullying immediately so school counselors can intervene.",questions:[{id:"m_bull_1",text:"Have you experienced or witnessed any form of bullying this past week?",type:"yes_no"},{id:"m_bull_2",text:"How safe and comfortable do you feel reporting bullying to school staff? (1-5)",type:"scale"},{id:"m_bull_3",text:"Describe the incident or detail any safety concern you want us to be aware of.",type:"text"}]},{id:"digital_wellbeing",title:"Digital Wellbeing & Habits",description:"Evaluate students' digital habits and screen time balance.",questions:[{id:"m_dig_1",text:"How often do you use digital devices in the hour before going to sleep? (1-5)",type:"scale"},{id:"m_dig_2",text:"How often do you feel distracted by social media notifications during homework? (1-5)",type:"scale"},{id:"m_dig_3",text:"How do you feel after spending more than 2 hours on social media? (1-5)",type:"scale"},{id:"m_dig_4",text:"Do you feel you have a healthy balance between screen time and offline activities?",type:"yes_no"}]}],Rs=[{id:"world_wonder",title:"World Wonder",description:"Travel through wonders of the world.",prompt:"Which country would you love to visit next? Tell us why!"},{id:"pop_art",title:"Pop & Art",description:"Colorful, pop-art themed visual patterns.",prompt:"If you could design a new mural for our school, what would you paint?"},{id:"music",title:"Music",description:"Explore musical instruments and notes.",prompt:"What song makes you feel happy and ready to study? Why?"},{id:"sports",title:"Sports & Action",description:"Athletic actions and energy themes.",prompt:"What is your favorite sport or physical activity to do after school?"},{id:"technology",title:"Tech Frontiers",description:"Future tech, robotics and space travel.",prompt:"What is a futuristic gadget you wish existed and how would it help you?"},{id:"community_cosmos",title:"Community Cosmos",description:"Community building and constellation maps.",prompt:"What is one nice thing a classmate or friend did for you recently?"}],Ss={system:"US",grades:{early_years:!1,elementary:!0,secondary:!0,middle_school:!0,high_school:!0},routine:{"us-early_elementary":{logic:"full",schedule:"weekly",customQuestions:[]},"us-elementary":{logic:"rotated",schedule:"weekly",customQuestions:[]},"us-secondary":{logic:"rotated",schedule:"weekly",customQuestions:[]},"us-middle_school":{logic:"rotated",schedule:"weekly",customQuestions:[]},"us-high_school":{logic:"rotated",schedule:"weekly",customQuestions:[]},"uk-early_elementary":{logic:"full",schedule:"weekly",customQuestions:[]},"uk-elementary":{logic:"rotated",schedule:"weekly",customQuestions:[]},"uk-secondary":{logic:"rotated",schedule:"weekly",customQuestions:[]},"uk-middle_school":{logic:"rotated",schedule:"weekly",customQuestions:[]},"uk-high_school":{logic:"rotated",schedule:"weekly",customQuestions:[]}},modules:{ai_literacy:!0,bullying:!1,digital_wellbeing:!1},journeys:{themes:["world_wonder"]},bonusXp:{elementary:!0,secondary:!0,elementaryTopic:"geography",secondaryTopic:"math"}},Ft={title:"Unlock Early Years Check-ins",description:"The Early Years check-in flow is part of our Safeguarding Premium tier. It provides developmentally-appropriate questions with a visual emoji interface specifically designed for students aged 3–7. Contact our team to enable this module for your campus.",includedItems:["3 developmentally-appropriate check-in questions","Visual emoji interface designed for young learners (Ages 3–7)","Age-appropriate safeguarding language","Curriculum alignment: EYFS, Pre-K to Grade 1"],feature:"Early Years Check-ins"},Vs="#0f9655",Qt="#D0D5DD",Yt=[{key:"early_years",title:"Early Years",ageInfo:"(Ages 3-7)",locked:!1,usTag:"Pre-K to Grade 1",ukTag:"Nursery - Year 2 · EYFS / Key Stage 1",description:"3 developmentally-appropriate questions with a visual emoji interface designed specifically for young learners",includesText:"3 developmentally-appropriate questions · Visual emoji interface · Age-appropriate language",themeColor:"blue"},{key:"elementary",title:"Elementary",ageInfo:"(Ages 7-11)",locked:!1,usTag:"Grades 2-5",ukTag:"Years 3-6 · Key Stage 2",description:"Age-appropriate questions focused on learning support, personal well-being, and campus safety metrics",themeColor:"blue"},{key:"middle_school",title:"Middle School",ageInfo:"(Ages 11–14)",locked:!1,usTag:"Grades 6–8 · Middle School",ukTag:"Years 7–9 · KS3",description:"Comprehensive metrics covering stress tracking, student cognitive mindsets, and well-being index scales for middle school students",themeColor:"purple"},{key:"high_school",title:"High School",ageInfo:"(Ages 14–18)",locked:!1,usTag:"Grades 9–12 · High School",ukTag:"Years 10–13 · KS4 & KS5 / GCSE & Sixth Form",description:"Comprehensive metrics covering advanced stress tracking, student cognitive mindsets, and mature well-being index scales for high school students",themeColor:"green"}],zt={Safety:{color:"#c54140",backgroundColor:"#c5414020"},"Safety and Stress":{color:"#c54140",backgroundColor:"#c5414020"},"Resilience and Stress":{color:"#c54140",backgroundColor:"#c5414020"},"About my learning":{color:"#316cd9",backgroundColor:"#316cd920"},Productivity:{color:"#316cd9",backgroundColor:"#316cd920"},"About me":{color:"#ffb04f",backgroundColor:"#ffb04f20"},Academics:{color:"#ffb04f",backgroundColor:"#ffb04f20"},Readiness:{color:"#316cd9",backgroundColor:"#316cd920"},"Well-Being":{color:"#316cd9",backgroundColor:"#316cd920"},"Open Field":{color:"#ffb04f",backgroundColor:"#ffb04f20"},"Custom Open Field Questions":{color:"#ffb04f",backgroundColor:"#ffb04f20"}},Gt=[1,2,3,4,5,6,7,8,9,10,11,12],cs=[2,3,4,5],Os=[6,7,8],$s=[9,10,11,12],ds=[6,7,8,9,10,11,12],Ys=(s,o)=>{switch(s){case"elementary":return o?[1,2,3,4,5]:cs;case"middle_school":return Os;case"high_school":return $s;case"secondary":return ds;default:return Gt}},Ht=[{age:"3-4",us:"Pre-K / Nursery",uk:"Nursery",ks:"EYFS",category:"early"},{age:"4-5",us:"Kindergarten",uk:"Reception",ks:"EYFS",category:"early"},{age:"5-6",us:"Grade 1",uk:"Year 1",ks:"KS1",category:"elem"},{age:"6-7",us:"Grade 2",uk:"Year 2",ks:"KS1",category:"elem"},{age:"7-8",us:"Grade 3",uk:"Year 3",ks:"KS2",category:"elem"},{age:"8-9",us:"Grade 4",uk:"Year 4",ks:"KS2",category:"elem"},{age:"9-10",us:"Grade 5",uk:"Year 5",ks:"KS2",category:"elem"},{age:"10-11",us:"Grade 6",uk:"Year 6",ks:"KS2",category:"elem"},{age:"11-12",us:"Grade 7",uk:"Year 7",ks:"KS3",category:"sec"},{age:"12-13",us:"Grade 8",uk:"Year 8",ks:"KS3",category:"sec"},{age:"13-14",us:"Grade 9",uk:"Year 9",ks:"KS3",category:"sec"},{age:"14-15",us:"Grade 10",uk:"Year 10",ks:"KS4 (GCSE)",category:"sec"},{age:"15-16",us:"Grade 11",uk:"Year 11",ks:"KS4 (GCSE)",category:"sec"},{age:"16-17",us:"Grade 12",uk:"Year 12",ks:"KS5 / Sixth Form",category:"sec"},{age:"17-18",us:"—",uk:"Year 13",ks:"KS5 / Sixth Form",category:"sec"}],ct={ai_literacy:{displayTitle:"AI Literacy",tag:"Eblana Learning",iconColor:"#316CD9",IconComponent:Ot},bullying:{displayTitle:"Bullying & Safety",tag:"Escalation Engaged",iconColor:"#DC2626",IconComponent:$t},digital_wellbeing:{displayTitle:"Digital Wellbeing & Habits",iconColor:"#0EA5E9",IconComponent:At}},dt={height:8,padding:"13px 0","& .MuiSlider-track":{border:"none",background:"transparent"},"& .MuiSlider-rail":{opacity:1,background:"linear-gradient(90deg, #ff8b8b 0%, #ffd08b 50%, #8bffb8 100%)",height:8,borderRadius:4},"& .MuiSlider-thumb":{height:16,width:16,backgroundColor:"#56CCF2",border:"2px solid #ffffff","&:focus, &:hover, &.Mui-active, &.Mui-focusVisible":{boxShadow:"none"},"&::before":{display:"none"}}},Ut={...dt,"& .MuiSlider-rail":{opacity:1,background:"linear-gradient(90deg, #8bffb8 0%, #ffd08b 50%, #ff8b8b 100%)",height:8,borderRadius:4}},qt=["😢","🙁","😐","🙂","😃"],Bt=["Very Low","Low","Moderate","High","Very High"],ps=`${fe.BASE_URL}/api/question`,Ps=s=>{const o={ms:"ms",es:"es",ey:"ey"};return fe.api.get(`${ps}/checkin-questions`,{headers:{"X-School-Level":o[s]}})},Ns=(s,o,r)=>{const i={ms:"ms",es:"es",ey:"ey"};return fe.api.put(`${ps}/checkin-config/${o}`,r,{headers:{"X-School-Level":i[s]}})},Ws=(s,o,r)=>{const i={ms:"ms",es:"es",ey:"ey"};return fe.api.put(`${ps}/checkin-routine-config/${o}`,r,{headers:{"X-School-Level":i[s]}})},Vt=(s,o,r)=>{const i={ms:"ms",es:"es",ey:"ey"};return fe.api.put(`${ps}/checkin-custom-question/${o}`,r,{headers:{"X-School-Level":i[s]}})},Wt=(s,o)=>{const r={ms:"ms",es:"es",ey:"ey"};return fe.api.delete(`${ps}/checkin-custom-question/${o}`,{headers:{"X-School-Level":r[s]}})},ut=`${fe.BASE_URL}/api/Journeys`,Jt=()=>fe.api.get(`${ut}/admin`),Kt=s=>fe.api.put(`${ut}/admin/batch`,s),Se=s=>{const o=s.toLowerCase();return o.includes("ai")?"ai_literacy":o.includes("bullying")?"bullying":o.includes("digital")?"digital_wellbeing":null},Xt=()=>{const s=Ls.useDispatch(),o=Ls.useSelector(d=>d.common.user),r=o?.hasEsSchool!==!1,{msRoles:i,esRoles:l}=q.useMemo(()=>Tt.getAccessibleRoles(o?.appType,o?.msRoles,o?.esRoles),[o?.appType,o?.msRoles,o?.esRoles]),a=i.includes("Admin"),u=l.includes("Admin"),[c,y]=q.useState(1),[m,g]=q.useState(()=>({...Ss,grades:{...Ss.grades,elementary:r&&u,secondary:a,middle_school:a,high_school:a}})),[M,F]=q.useState(!1),[R,z]=q.useState(!1),[P,te]=q.useState(!1),ne=q.useRef(!1),[p,N]=q.useState({}),[j,I]=q.useState({}),[A,Q]=q.useState("elementary"),[ce,ge]=q.useState(!1),Y=q.useMemo(()=>{const d=p.es?p.es.isEarlyYearsEnabled:p.ms?.isEarlyYearsEnabled??!1,C=p.es?r&&p.es.isElementaryEnabled:p.ms?r&&p.ms.isElementaryEnabled:r,D=p.ms?p.ms.isSecondaryEnabled:p.es?.isSecondaryEnabled??!0,h=p.ms?p.ms.isHighSchoolEnabled??p.ms.isSecondaryEnabled:p.es?.isHighSchoolEnabled??p.es?.isSecondaryEnabled??!0,x=p.ms||p.es||p.ey;return{configId:x?x.configId:0,system:x&&x.system===1?"UK":"US",isEarlyYearsEnabled:d,isElementaryEnabled:C,isSecondaryEnabled:D,isHighSchoolEnabled:h}},[p,r]);q.useEffect(()=>{if(P)return;const d=p.es,C=p.ms;if(r?!!d&&!!C:!!C){const h=(u?d:C)||d||C;if(!h)return;const x=h.system===1?"UK":"US",b=p.es?.routines?.find(oe=>oe.gradeLevel===0),v=p.es?.routines?.find(oe=>oe.gradeLevel===1),_=p.ms?.routines?.find(oe=>oe.gradeLevel===2),S=p.ms?.routines?.find(oe=>oe.gradeLevel===3),L=oe=>{const re=oe?.clusters?.find(ie=>ie.title==="Custom Open Field Questions");return!re||!re.questions?[]:re.questions.map(ie=>({id:String(ie.questionId),text:ie.name,type:"text",isCustom:!0,selectedGrades:ie.grade||[],startDate:ie.schedule?.startDate||void 0,endDate:ie.schedule?.endDate||void 0}))},E={ai_literacy:!1,bullying:!1,digital_wellbeing:!1};v&&v.extraModules&&v.extraModules.forEach(oe=>{const re=Se(oe.title);re&&oe.status&&(E[re]=!0)}),_&&_.extraModules&&_.extraModules.forEach(oe=>{const re=Se(oe.title);re&&oe.status&&(E[re]=!0)}),S&&S.extraModules&&S.extraModules.forEach(oe=>{const re=Se(oe.title);re&&oe.status&&(E[re]=!0)});const T=p.es?p.es.isEarlyYearsEnabled:p.ms?.isEarlyYearsEnabled??!1,G=u?r?h.isElementaryEnabled:!1:p.es?.isElementaryEnabled??p.ms?.isElementaryEnabled??(r&&h.isElementaryEnabled),Z=a?h.isSecondaryEnabled:p.ms?.isSecondaryEnabled??p.es?.isSecondaryEnabled??h.isSecondaryEnabled,U=u?T:p.es?.isEarlyYearsEnabled??p.ms?.isEarlyYearsEnabled??!1,K=a?h.isHighSchoolEnabled??h.isSecondaryEnabled:p.ms?.isHighSchoolEnabled??p.es?.isHighSchoolEnabled??Z;g(oe=>{const re={...oe,system:x,grades:{early_years:U,elementary:G,secondary:Z,middle_school:Z,high_school:K},modules:E};if(b){const ie=x==="UK"?"uk-early_elementary":"us-early_elementary";re.routine[ie]={...re.routine[ie],logic:"full",schedule:b.schedule===1?"weekly":b.schedule===2?"biweekly":"monthly",customQuestions:L(b)}}if(v){const ie=x==="UK"?"uk-elementary":"us-elementary";re.routine[ie]={...re.routine[ie],logic:v.logic===1?"full":"rotated",schedule:v.schedule===1?"weekly":v.schedule===2?"biweekly":"monthly",customQuestions:L(v)}}if(_){const ie=x==="UK"?"uk-secondary":"us-secondary",le=_.logic===1?"full":"rotated",Ee=_.schedule===1?"weekly":_.schedule===2?"biweekly":"monthly",Ue={...re.routine[ie],logic:le,schedule:Ee,customQuestions:L(_)};re.routine[ie]=Ue;const Ie=x==="UK"?"uk-middle_school":"us-middle_school";re.routine[Ie]={...Ue};const pe=S||_,Qe=pe.logic===1?"full":"rotated",wt=pe.schedule===1?"weekly":pe.schedule===2?"biweekly":"monthly",qs=x==="UK"?"uk-high_school":"us-high_school";re.routine[qs]={...re.routine[qs],logic:Qe,schedule:wt,customQuestions:L(pe)}}return re});const O=r&&u&&h.isElementaryEnabled;let ae="elementary";O?ae="elementary":a&&(ae=Z?"middle_school":"secondary"),Q(ae),te(!0)}},[p,P,r,u,a]),q.useEffect(()=>{if(P){const d=u&&m.grades.early_years,C=u&&m.grades.elementary,D=a&&m.grades.middle_school,h=a&&m.grades.high_school;A==="early_elementary"&&!d?C?Q("elementary"):D?Q("middle_school"):h?Q("high_school"):m.grades.secondary&&Q("secondary"):A==="elementary"&&!C?d?Q("early_elementary"):D?Q("middle_school"):h?Q("high_school"):m.grades.secondary&&Q("secondary"):A==="middle_school"&&!D?h?Q("high_school"):C?Q("elementary"):d?Q("early_elementary"):m.grades.secondary&&Q("secondary"):A==="high_school"&&!h&&(D?Q("middle_school"):C?Q("elementary"):d?Q("early_elementary"):m.grades.secondary&&Q("secondary"))}},[m.grades.early_years,m.grades.elementary,m.grades.middle_school,m.grades.high_school,m.grades.secondary,P,A,u,a]);const B=q.useMemo(()=>{const d=[];return m.grades.early_years&&d.push("ey"),m.grades.elementary&&d.push("es"),m.grades.secondary&&d.push("ms"),d},[m.grades.early_years,m.grades.elementary,m.grades.secondary]),w=q.useCallback(async d=>{const C=Ps(d);if(C)try{const D=await C;N(h=>({...h,[d]:D.data})),I(h=>({...h,[d]:JSON.parse(JSON.stringify(D.data))})),!ne.current&&D.data?.isSetup&&(ne.current=!0,y(5))}catch(D){console.error(`[CheckInSetup] Failed to fetch check-in questions for source "${d}":`,D)}},[]);q.useEffect(()=>{let d=!0;ge(!0);const C=[r?w("es"):Promise.resolve(),w("ms")];return Promise.all(C).finally(()=>{d&&(ge(!1),ne.current=!0)}),()=>{d=!1}},[w,r]);const[J,me]=q.useState([]),ee=async()=>{try{s(fe.setLoading(!0));const d=await Jt();me(d.data)}catch(d){console.error("Failed to load journeys from API:",d)}finally{s(fe.setLoading(!1))}};q.useEffect(()=>{ee()},[]);const f=d=>{const D=!d.isEnabled;let h=[];D&&(m.grades.elementary&&(h=[...h,...cs]),m.grades.middle_school&&(h=[...h,...Os]),m.grades.high_school&&(h=[...h,...$s]),m.grades.secondary&&!m.grades.middle_school&&!m.grades.high_school&&(h=[...h,...ds])),me(x=>x.map(b=>b.id===d.id?{...b,isEnabled:D,activeGrades:h}:b))},$=(d,C)=>{let D=[...d.activeGrades],h=[];C==="elementary"?h=cs:C==="middle_school"?h=Os:C==="high_school"?h=$s:h=ds,h.some(b=>D.includes(b))?D=D.filter(b=>!h.includes(b)):D=[...D,...h],me(b=>b.map(v=>v.id===d.id?{...v,activeGrades:D}:v))},W=d=>{g(C=>({...C,system:d}))},se=d=>{const C=p.es?p.es.isEarlyYearsEnabled:p.ms?.isEarlyYearsEnabled??!1;d==="early_years"&&(!u||!C)||d==="elementary"&&(!u||!r)||(d==="secondary"||d==="middle_school"||d==="high_school")&&!a||g(D=>{const h={...D.grades,[d]:!D.grades[d]};return(d==="middle_school"||d==="high_school")&&(h.secondary=!!(h.middle_school||h.high_school)),{...D,grades:h}})},X=(d,C)=>{g(b=>({...b,routine:{...b.routine,[d]:{...b.routine[d],logic:C}}}));const D=d.includes("high_school"),h=d.includes("early_elementary"),x=d.includes("elementary")||d.includes("early_elementary")?"es":"ms";N(b=>{const v={...b};if(v[x]){const _=[...v[x].routines],S=h?0:x==="es"?1:D&&_.some(E=>E.gradeLevel===3)?3:2,L=_.findIndex(E=>E.gradeLevel===S);if(L!==-1){const E={..._[L]};E.logic=C==="full"?1:0,_[L]=E,v[x]={...v[x],routines:_}}}return v})},H=(d,C)=>{g(b=>({...b,routine:{...b.routine,[d]:{...b.routine[d],schedule:C}}}));const D=d.includes("high_school"),h=d.includes("early_elementary"),x=d.includes("elementary")||d.includes("early_elementary")?"es":"ms";N(b=>{const v={...b};if(v[x]){const _=[...v[x].routines],S=h?0:x==="es"?1:D&&_.some(E=>E.gradeLevel===3)?3:2,L=_.findIndex(E=>E.gradeLevel===S);if(L!==-1){const E={..._[L]};E.schedule=C==="weekly"?1:C==="biweekly"?2:0,_[L]=E,v[x]={...v[x],routines:_}}}return v})},ye=(d,C,D)=>{const h=D||A;N(x=>{const b={...x};if(b[d]){const v=[...b[d].routines],L=h==="early_elementary"?0:d==="es"?1:h==="high_school"&&v.some(T=>T.gradeLevel===3)?3:2,E=v.findIndex(T=>T.gradeLevel===L);if(E!==-1){const T={...v[E]},G=Number(C);let Z=!1;const U=T.clusters.find(O=>O.questions.some(ae=>ae.questionId===G));if(U){const O=U.title.toLowerCase();(O==="safety"||O==="safety and stress"||O==="resilience and stress"||U.order===1)&&(Z=!0)}T.coreQuestionIds.includes(G)||T.otherPinnedQuestionIds.includes(G)?(T.coreQuestionIds=T.coreQuestionIds.filter(O=>O!==G),T.otherPinnedQuestionIds=T.otherPinnedQuestionIds.filter(O=>O!==G)):Z?T.coreQuestionIds=[...T.coreQuestionIds.filter(O=>O!==G),G]:T.otherPinnedQuestionIds=[...T.otherPinnedQuestionIds.filter(O=>O!==G),G],v[E]=T,b[d]={...b[d],routines:v}}}return b})},Ne=(d,C,D)=>{const h=D||A;N(x=>{const b={...x};if(b[d]){const v=[...b[d].routines],L=h==="early_elementary"?0:d==="es"?1:h==="high_school"&&v.some(T=>T.gradeLevel===3)?3:2,E=v.findIndex(T=>T.gradeLevel===L);if(E!==-1){const T={...v[E]},G=Number(C);T.clusters=T.clusters.map(Z=>({...Z,questions:Z.questions.map(U=>U.questionId===G||String(U.questionId)===String(C)?{...U,statusEnable:U.statusEnable===!1}:U)})),v[E]=T,b[d]={...b[d],routines:v}}}return b})},k=(d,C,D,h,x,b)=>{if(!C.trim())return;const v={id:`custom_${d}_${Date.now()}_${Math.random().toString(36).substring(2,9)}`,text:C,type:D,isCustom:!0,selectedGrades:h,startDate:x,endDate:b};g(_=>({..._,routine:{..._.routine,[d]:{..._.routine[d],customQuestions:[..._.routine[d].customQuestions,v]}}}))},V=async(d,C)=>{if(C.startsWith("custom_"))g(D=>({...D,routine:{...D.routine,[d]:{...D.routine[d],customQuestions:D.routine[d].customQuestions.filter(h=>h.id!==C)}}}));else try{s(fe.setLoading(!0));const D=d.includes("early_elementary"),h=d.includes("elementary")&&!D,x=D||h?"es":"ms",b=d.includes("high_school");await Wt(x,C),g(S=>({...S,routine:{...S.routine,[d]:{...S.routine[d],customQuestions:S.routine[d].customQuestions.filter(L=>L.id!==C)}}}));const v=Number(C),_=S=>{const L=S[x];if(!L||!L.routines)return S;const E=D?0:x==="es"?1:b&&L.routines.some(Z=>Z.gradeLevel===3)?3:2,T=[...L.routines],G=T.findIndex(Z=>Z.gradeLevel===E);if(G>=0){const Z={...T[G]},K=Z.clusters.map(oe=>{if(oe.title==="Custom Open Field Questions"){const re=oe.questions.filter(ie=>String(ie.questionId)!==C);return{...oe,questions:re}}return oe}).filter(oe=>oe.title!=="Custom Open Field Questions"||oe.questions.length>0),O=(Z.coreQuestionIds||[]).filter(oe=>oe!==v),ae=(Z.otherPinnedQuestionIds||[]).filter(oe=>oe!==v);return T[G]={...Z,clusters:K,coreQuestionIds:O,otherPinnedQuestionIds:ae},{...S,[x]:{...L,routines:T}}}return S};N(S=>_(S)),I(S=>_(S))}catch(D){console.error("[CheckInSetup] Failed to delete custom question:",D)}finally{s(fe.setLoading(!1))}},he=async(d,C,D,h,x,b)=>{if(D.trim())if(C.startsWith("custom_"))g(v=>({...v,routine:{...v.routine,[d]:{...v.routine[d],customQuestions:v.routine[d].customQuestions.map(_=>_.id===C?{..._,text:D,selectedGrades:h,startDate:x,endDate:b}:_)}}}));else try{s(fe.setLoading(!0));const v=d.includes("early_elementary"),_=d.includes("elementary")&&!v,S=v||_?"es":"ms",L=d.includes("high_school");await Vt(S,C,{id:C,questionText:D,selectGrades:h||[],startDate:x||null,endDate:b||null}),g(G=>({...G,routine:{...G.routine,[d]:{...G.routine[d],customQuestions:G.routine[d].customQuestions.map(Z=>Z.id===C?{...Z,text:D,selectedGrades:h,startDate:x,endDate:b}:Z)}}}));const T=G=>{const Z=G[S];if(!Z||!Z.routines)return G;const U=v?0:S==="es"?1:L&&Z.routines.some(ae=>ae.gradeLevel===3)?3:2,K=[...Z.routines],O=K.findIndex(ae=>ae.gradeLevel===U);if(O>=0){const ae={...K[O]},oe=ae.clusters.map(re=>{if(re.title==="Custom Open Field Questions"){const ie=re.questions.map(le=>String(le.questionId)===C?{...le,name:D,grade:h||[],schedule:{startDate:x||null,endDate:b||null}}:le);return{...re,questions:ie}}return re});return K[O]={...ae,clusters:oe},{...G,[S]:{...Z,routines:K}}}return G};N(G=>T(G)),I(G=>T(G))}catch(v){console.error("[CheckInSetup] Failed to update custom question:",v)}finally{s(fe.setLoading(!1))}},de=(d,C,D)=>{const h=D||A;N(x=>{const b=x[d];if(!b||!b.routines)return x;const S=h==="early_elementary"?0:d==="es"?1:h==="high_school"&&b.routines.some(T=>T.gradeLevel===3)?3:2,L=[...b.routines],E=L.findIndex(T=>T.gradeLevel===S);if(E>=0){const T={...L[E]},G=[...T.clusters].sort((Z,U)=>{const K=C.indexOf(Z.title),O=C.indexOf(U.title);return K>=0&&O>=0?K-O:0});return T.clusters=G.map((Z,U)=>({...Z,order:U+1})),L[E]=T,{...x,[d]:{...b,routines:L}}}return x})},ue=async(d,C,D,h,x)=>{const b=p[d];if(!b)return;const v=x!==void 0?x:d==="es"?1:2,_=b.routines?.find(K=>K.gradeLevel===v);if(!_)return;N(K=>{const O={...K};if(O[d]){const ae=[...O[d].routines],oe=ae.findIndex(re=>re.gradeLevel===v);if(oe!==-1){const re={...ae[oe]};re.extraModules&&(re.extraModules=re.extraModules.map(ie=>Se(ie.title)===C?{...ie,status:D,periods:h.map(le=>({startDate:le.startDate,endDate:le.endDate}))}:ie)),ae[oe]=re,O[d]={...O[d],routines:ae}}}return O});const S=d==="es"?"elementary":v===3?"high_school":"secondary",L=qe(m.system,S),T=(m.routine[L]?.customQuestions||[]).map(K=>({id:K.id,questionText:K.text,selectGrades:K.selectedGrades||[],startDate:K.startDate||null,endDate:K.endDate||null})),G=_.clusters.filter(K=>K.title!=="Custom Open Field Questions").map(K=>({title:K.title,order:K.order,questions:K.questions.map(O=>({questionId:O.questionId,statusEnable:O.statusEnable!==!1})),customQuestionIds:K.customQuestionIds||[],isCustomCluster:K.isCustomCluster||!1})),Z=_.extraModules?_.extraModules.map(K=>{const O=Se(K.title)===C,ae=O?D:K.status,oe=O?h:K.periods||[];return{title:K.title,status:ae,questionids:K.questions.map(re=>re.questionId),optionalids:K.questions.filter(re=>re.description.includes("Optional")).map(re=>re.questionId),periods:oe.map(re=>({startDate:re.startDate||null,endDate:re.endDate||null}))}}):[],U={logic:_.logic,schedule:_.schedule,coreQuestionIds:_.coreQuestionIds.join(","),otherPinnedQuestionIds:_.otherPinnedQuestionIds.join(","),clustersJson:JSON.stringify(G),customOpenFieldQuestions:T,extraModulesJson:JSON.stringify(Z)};try{s(fe.setLoading(!0)),await Ws(d,_.id,U);const K=Ps(d);if(K){const O=await K;N(ae=>({...ae,[d]:O.data})),I(ae=>({...ae,[d]:JSON.parse(JSON.stringify(O.data))}))}}catch(K){console.error(`[CheckInSetup] Failed to update extra module config for ${d}:`,K)}finally{s(fe.setLoading(!1))}},_e=async d=>{const D=!m.modules[d];g(E=>({...E,modules:{...E.modules,[d]:D}}));const h=p.es?.routines?.find(E=>E.gradeLevel===1),x=p.ms?.routines?.find(E=>E.gradeLevel===2),b=p.ms?.routines?.find(E=>E.gradeLevel===3),v=h?.extraModules?.find(E=>Se(E.title)===d),_=x?.extraModules?.find(E=>Se(E.title)===d),S=b?.extraModules?.find(E=>Se(E.title)===d),L=[];if(D){if(d==="ai_literacy"){if(r&&v){const E=(v.periods||[]).map(T=>({startDate:T.startDate||"",endDate:T.endDate||""}));L.push(ue("es",d,!0,E,1))}if(_){const E=(_.periods||[]).map(T=>({startDate:T.startDate||"",endDate:T.endDate||""}));L.push(ue("ms",d,!0,E,2))}if(S){const E=(S.periods||[]).map(T=>({startDate:T.startDate||"",endDate:T.endDate||""}));L.push(ue("ms",d,!0,E,3))}}}else{if(r&&v&&v.status){const E=(v.periods||[]).map(T=>({startDate:T.startDate||"",endDate:T.endDate||""}));L.push(ue("es",d,!1,E,1))}if(_&&_.status){const E=(_.periods||[]).map(T=>({startDate:T.startDate||"",endDate:T.endDate||""}));L.push(ue("ms",d,!1,E,2))}if(S&&S.status){const E=(S.periods||[]).map(T=>({startDate:T.startDate||"",endDate:T.endDate||""}));L.push(ue("ms",d,!1,E,3))}}L.length>0&&await Promise.all(L)},Me=d=>{g(C=>({...C,bonusXp:{...C.bonusXp,[d]:!C.bonusXp[d]}}))},Le=(d,C)=>{g(D=>({...D,bonusXp:{...D.bonusXp,[d==="elementary"?"elementaryTopic":"secondaryTopic"]:C}}))},we=(d,C)=>{const D=C||(d==="es"?A==="early_elementary"?"early_elementary":"elementary":"middle_school"),h=qe(m.system,D),x=m.routine[h]?.customQuestions||[],b=j[d],S=D==="early_elementary"?0:d==="es"?1:D==="high_school"&&b?.routines?.some(G=>G.gradeLevel===3)?3:2,T=b?.routines?.find(G=>G.gradeLevel===S)?.clusters?.find(G=>G.title==="Custom Open Field Questions")?.questions||[];if(x.length!==T.length)return!0;for(let G=0;G<x.length;G++){const Z=x[G],U=T.find(ae=>String(ae.questionId)===Z.id||ae.name===Z.text);if(!U||U.name!==Z.text)return!0;const K=[...Z.selectedGrades||[]].sort().join(","),O=[...U.grade||[]].sort().join(",");if(K!==O||(U.schedule?.startDate||null)!==(Z.startDate||null)||(U.schedule?.endDate||null)!==(Z.endDate||null))return!0}return!1},be=(d,C)=>{const D=p[d],h=j[d];if(!D||!h)return!1;const x=C||(d==="es"?A==="early_elementary"?"early_elementary":"elementary":"middle_school"),_=x==="early_elementary"?0:d==="es"?1:x==="high_school"&&D.routines?.some(O=>O.gradeLevel===3)?3:2,S=D.routines?.find(O=>O.gradeLevel===_),L=h.routines?.find(O=>O.gradeLevel===_);if(!S||!L)return!1;if(S.logic!==L.logic||S.schedule!==L.schedule)return!0;const E=[...S.coreQuestionIds].sort().join(","),T=[...L.coreQuestionIds].sort().join(",");if(E!==T)return!0;const G=[...S.otherPinnedQuestionIds].sort().join(","),Z=[...L.otherPinnedQuestionIds].sort().join(",");if(G!==Z)return!0;const U=S.clusters.filter(O=>!O.isCustomCluster).map(O=>O.title).join(","),K=L.clusters.filter(O=>!O.isCustomCluster).map(O=>O.title).join(",");if(U!==K)return!0;for(const O of S.clusters){if(O.isCustomCluster)continue;const ae=L.clusters.find(oe=>oe.title===O.title);if(!ae)return!0;for(const oe of O.questions){const re=ae.questions.find(Ee=>Ee.questionId===oe.questionId);if(!re)return!0;const ie=oe.statusEnable!==!1,le=re.statusEnable!==!1;if(ie!==le)return!0}}if(we(d,x))return!0;if(S.extraModules&&L.extraModules)for(const O of S.extraModules){const ae=L.extraModules.find(Ee=>Ee.title===O.title);if(!ae)return!0;const oe=Se(O.title);if((oe?O.status&&!!m.modules[oe]:O.status)!==ae.status)return!0;const ie=(O.periods||[]).map(Ee=>`${Ee.startDate}_${Ee.endDate}`).sort().join(","),le=(ae.periods||[]).map(Ee=>`${Ee.startDate}_${Ee.endDate}`).sort().join(",");if(ie!==le)return!0}return!1},Ce=async(d,C)=>{const D=p[d];if(!D)return;const h=C||(d==="es"?A==="early_elementary"?"early_elementary":"elementary":"middle_school"),v=h==="early_elementary"?0:d==="es"?1:h==="high_school"&&D.routines?.some(U=>U.gradeLevel===3)?3:2,_=D.routines?.find(U=>U.gradeLevel===v);if(!_)return;const S=qe(m.system,h),E=(m.routine[S]?.customQuestions||[]).map(U=>({id:U.id,questionText:U.text,selectGrades:U.selectedGrades||[],startDate:U.startDate||null,endDate:U.endDate||null})),T=_.clusters.filter(U=>U.title!=="Custom Open Field Questions").map(U=>({title:U.title,order:U.order,questions:U.questions.map(K=>({questionId:K.questionId,statusEnable:K.statusEnable!==!1})),customQuestionIds:U.customQuestionIds||[],isCustomCluster:U.isCustomCluster||!1})),G=_.extraModules?_.extraModules.map(U=>{const K=Se(U.title),O=K?U.status&&!!m.modules[K]:U.status;return{title:U.title,status:O,questionids:U.questions.map(ae=>ae.questionId),optionalids:U.questions.filter(ae=>ae.description.includes("Optional")).map(ae=>ae.questionId),periods:U.periods?U.periods.map(ae=>({startDate:ae.startDate||null,endDate:ae.endDate||null})):[]}}):[],Z={logic:_.logic,schedule:_.schedule,coreQuestionIds:_.coreQuestionIds.join(","),otherPinnedQuestionIds:_.otherPinnedQuestionIds.join(","),clustersJson:JSON.stringify(T),customOpenFieldQuestions:E,extraModulesJson:JSON.stringify(G)};try{s(fe.setLoading(!0)),await Ws(d,_.id,Z);const U=Ps(d);if(U){const O=(await U).data;N(le=>({...le,[d]:O})),I(le=>({...le,[d]:JSON.parse(JSON.stringify(O))}));const ie=(O.routines?.find(le=>le.gradeLevel===v)?.clusters?.find(le=>le.title==="Custom Open Field Questions")?.questions||[]).map(le=>({id:String(le.questionId),text:le.name,type:"text",isCustom:!0,selectedGrades:le.grade||[],startDate:le.schedule?.startDate||void 0,endDate:le.schedule?.endDate||void 0}));g(le=>({...le,routine:{...le.routine,[S]:{...le.routine[S],customQuestions:ie}}}))}console.log(`[CheckInSetup] Successfully saved routine config for ${d} (${h})`)}catch(U){console.error(`[CheckInSetup] Failed to save routine config for ${d} (${h}):`,U)}finally{s(fe.setLoading(!1))}},Ae=async()=>{u&&m.grades.early_years&&be("es","early_elementary")&&await Ce("es","early_elementary"),u&&m.grades.elementary&&be("es","elementary")&&await Ce("es","elementary"),a&&m.grades.middle_school&&be("ms","middle_school")&&await Ce("ms","middle_school"),a&&m.grades.high_school&&be("ms","high_school")&&await Ce("ms","high_school"),a&&!m.grades.middle_school&&!m.grades.high_school&&m.grades.secondary&&be("ms","secondary")&&await Ce("ms","secondary")},Ge=async d=>{const C=A==="elementary"||A==="early_elementary"?"es":"ms";be(C,A)&&await Ce(C,A),Q(d)},Te=async()=>{if(c===1){if(Y.configId>0){const d=!!(m.grades.middle_school||m.grades.secondary),C=!!m.grades.high_school;if(m.system!==Y.system||u&&m.grades.early_years!==Y.isEarlyYearsEnabled||u&&m.grades.elementary!==Y.isElementaryEnabled||a&&d!==Y.isSecondaryEnabled||a&&C!==Y.isHighSchoolEnabled)try{s(fe.setLoading(!0));const h=[],x=u?r?m.grades.elementary:!1:p.es?.isElementaryEnabled??p.ms?.isElementaryEnabled??Y.isElementaryEnabled,b=a?d:p.ms?.isSecondaryEnabled??p.es?.isSecondaryEnabled??Y.isSecondaryEnabled,v=a?C:p.ms?.isHighSchoolEnabled??p.es?.isHighSchoolEnabled??Y.isHighSchoolEnabled,_=u?m.grades.early_years:p.es?.isEarlyYearsEnabled??Y.isEarlyYearsEnabled,S={system:m.system==="UK"?1:0,isEarlyYearsEnabled:_,isElementaryEnabled:x,isSecondaryEnabled:b,isHighSchoolEnabled:v},L=p.ms?.configId||Y.configId,E=p.es?.configId||Y.configId;if(L>0&&h.push(Ns("ms",L,S)),r&&E>0&&h.push(Ns("es",E,S)),m.grades.early_years){const T=p.ey?.configId||E||L;T>0&&h.push(Ns("ey",T,S))}h.length>0&&await Promise.all(h),N(T=>{const G={...T},Z=r?["ms","es"]:["ms"];return m.grades.early_years&&Z.push("ey"),Z.forEach(U=>{G[U]&&(G[U]={...G[U],system:m.system==="UK"?1:0,isEarlyYearsEnabled:_,isElementaryEnabled:x,isSecondaryEnabled:b,isHighSchoolEnabled:v})}),G})}catch(h){console.error("Failed to save step 1 config:",h)}finally{s(fe.setLoading(!1))}}}else c===2&&await Ae();c<5&&y(d=>d+1)},Re=async()=>{c===2&&await Ae(),c>1&&(y(d=>d-1),setTimeout(()=>{const d=document.querySelector("main");d&&d.scrollTo({top:0,behavior:"smooth"}),window.scrollTo({top:0,behavior:"smooth"})},50))},Fe=async()=>{try{s(fe.setLoading(!0));const d=J.map(C=>({id:C.id,isEnabled:C.isEnabled,activeGrades:C.activeGrades}));await Kt(d),y(5)}catch(d){console.error("Failed to save journeys configuration:",d)}finally{s(fe.setLoading(!1))}},He=q.useMemo(()=>J.filter(d=>d.isEnabled).length===1,[J]);return{activeStep:c,setActiveStep:y,config:m,previewOpen:M,setPreviewOpen:F,upgradeModalOpen:R,setUpgradeModalOpen:z,onChangeSystem:W,onToggleGrade:se,onChangeRoutineLogic:X,onChangeRoutineSchedule:H,onAddCustomQuestion:k,onRemoveCustomQuestion:V,onEditCustomQuestion:he,onToggleModule:_e,onToggleBonusXp:Me,onChangeBonusXpTopic:Le,journeys:J,hasSingleJourneyEnabled:He,handleToggleJourney:f,handleToggleGrade:$,nextStep:Te,prevStep:Re,completeSetup:Fe,resetSetup:()=>{g(Ss),y(1)},checkInQuestionsMap:p,isLoadingQuestions:ce,activeSources:B,fetchCheckInQuestions:w,apiState:Y,activeTab:A,onTabChange:Ge,onToggleQuestionPin:ye,onToggleQuestionEnable:Ne,onReorderClusters:de,onUpdateModuleConfig:ue,hasEsSchool:r,isAdminEs:u,isAdminMs:a}},Zt="_completed_1gnxi_79",en="_active_1gnxi_82",sn="_locked_1gnxi_495",tn="_green_1gnxi_864",nn="_disabled_1gnxi_1259",on="_checked_1gnxi_1325",rn="_s2ModalScale_1gnxi_1",an="_inactive_1gnxi_1826",ln="_selected_1gnxi_1858",cn="_ai_literacy_1gnxi_3421",dn="_bullying_1gnxi_3424",un="_digital_wellbeing_1gnxi_3427",pn="_heart_1gnxi_3796",mn="_correct_1gnxi_3893",hn="_wrong_1gnxi_3897",t={"checkin-setup-container":"_checkin-setup-container_1gnxi_25","setup-header":"_setup-header_1gnxi_35","stepper-wrapper":"_stepper-wrapper_1gnxi_50","step-label-sub":"_step-label-sub_1gnxi_63","step-label-title":"_step-label-title_1gnxi_72",completed:Zt,active:en,"step-icon-completed":"_step-icon-completed_1gnxi_87","step-icon-check-completed":"_step-icon-check-completed_1gnxi_97","step-icon-active":"_step-icon-active_1gnxi_102","step-icon-active-inner":"_step-icon-active-inner_1gnxi_112","step-icon-inactive":"_step-icon-inactive_1gnxi_119","step-description-text":"_step-description-text_1gnxi_127","setup-wizard-layout":"_setup-wizard-layout_1gnxi_136","sidebar-steps":"_sidebar-steps_1gnxi_149","step-item":"_step-item_1gnxi_160","step-number":"_step-number_1gnxi_175","step-title":"_step-title_1gnxi_180","step-info":"_step-info_1gnxi_207","step-label":"_step-label_1gnxi_63","content-card":"_content-card_1gnxi_223","step-content-wrapper":"_step-content-wrapper_1gnxi_234","step-title-section":"_step-title-section_1gnxi_238","navigation-footer":"_navigation-footer_1gnxi_258","modal-box":"_modal-box_1gnxi_272","modal-icon-row":"_modal-icon-row_1gnxi_287","modal-info-icon":"_modal-info-icon_1gnxi_293","modal-title":"_modal-title_1gnxi_298","modal-description":"_modal-description_1gnxi_305","modal-action-btn":"_modal-action-btn_1gnxi_312","step1-wrapper":"_step1-wrapper_1gnxi_320","step-card-title-block":"_step-card-title-block_1gnxi_325","step-card-title":"_step-card-title_1gnxi_325","step-card-subtitle":"_step-card-subtitle_1gnxi_338","curriculum-row":"_curriculum-row_1gnxi_344","curriculum-label":"_curriculum-label_1gnxi_351","system-toggle":"_system-toggle_1gnxi_360","system-btn":"_system-btn_1gnxi_369","system-btn--active":"_system-btn--active_1gnxi_384","system-flag":"_system-flag_1gnxi_390","system-code":"_system-code_1gnxi_394","info-btn":"_info-btn_1gnxi_400","warning-banner":"_warning-banner_1gnxi_420","warning-icon":"_warning-icon_1gnxi_433","grade-cards-list":"_grade-cards-list_1gnxi_439","grade-cards-grid":"_grade-cards-grid_1gnxi_445","grade-card":"_grade-card_1gnxi_439","grade-card--active":"_grade-card--active_1gnxi_462","grade-card--purple":"_grade-card--purple_1gnxi_467","grade-tag--active":"_grade-tag--active_1gnxi_472","grade-card--green":"_grade-card--green_1gnxi_477","grade-card--locked":"_grade-card--locked_1gnxi_487",locked:sn,"grade-card-header":"_grade-card-header_1gnxi_499","grade-title-row":"_grade-title-row_1gnxi_505","grade-title":"_grade-title_1gnxi_505","grade-title-age":"_grade-title-age_1gnxi_519","grade-badge-active":"_grade-badge-active_1gnxi_526","grade-badge-locked":"_grade-badge-locked_1gnxi_539","lock-icon":"_lock-icon_1gnxi_552","lock-badge":"_lock-badge_1gnxi_557","grade-tags":"_grade-tags_1gnxi_567","grade-tag--us":"_grade-tag--us_1gnxi_573","grade-tag--inactive":"_grade-tag--inactive_1gnxi_584","grade-tag--uk":"_grade-tag--uk_1gnxi_584","grade-card-body":"_grade-card-body_1gnxi_595","grade-includes":"_grade-includes_1gnxi_602","unlock-btn":"_unlock-btn_1gnxi_612","s2-wrapper":"_s2-wrapper_1gnxi_637","s2-page-title":"_s2-page-title_1gnxi_643","s2-page-subtitle":"_s2-page-subtitle_1gnxi_649","s2-tab-bar-wrapper":"_s2-tab-bar-wrapper_1gnxi_656","s2-tab-bar":"_s2-tab-bar_1gnxi_656","s2-tab":"_s2-tab_1gnxi_656","s2-tab-header-row":"_s2-tab-header-row_1gnxi_685","s2-tab-emoji":"_s2-tab-emoji_1gnxi_693","s2-tab-label":"_s2-tab-label_1gnxi_699","s2-tab-check-tick":"_s2-tab-check-tick_1gnxi_705","s2-tab-title-row":"_s2-tab-title-row_1gnxi_710","s2-tab-text":"_s2-tab-text_1gnxi_717","s2-now-editing":"_s2-now-editing_1gnxi_744","s2-now-editing-emoji":"_s2-now-editing-emoji_1gnxi_753","s2-now-editing-wrapper":"_s2-now-editing-wrapper_1gnxi_756","s2-now-editing-label":"_s2-now-editing-label_1gnxi_762","s2-now-editing-text":"_s2-now-editing-text_1gnxi_768","s2-freq-card":"_s2-freq-card_1gnxi_774","s2-freq-title":"_s2-freq-title_1gnxi_781","s2-freq-subtitle":"_s2-freq-subtitle_1gnxi_786","s2-logic-label":"_s2-logic-label_1gnxi_792","s2-logic-row":"_s2-logic-row_1gnxi_799","s2-logic-row-single":"_s2-logic-row-single_1gnxi_805","s2-logic-card":"_s2-logic-card_1gnxi_815","s2-logic-card-rotated":"_s2-logic-card-rotated_1gnxi_831","s2-logic-card-header":"_s2-logic-card-header_1gnxi_836","s2-logic-card-title":"_s2-logic-card-title_1gnxi_842","s2-header-right":"_s2-header-right_1gnxi_847","s2-radio-dot":"_s2-radio-dot_1gnxi_852",green:tn,"s2-logic-card-desc":"_s2-logic-card-desc_1gnxi_869","s2-badge-recommended":"_s2-badge-recommended_1gnxi_875","s2-callout-yellow":"_s2-callout-yellow_1gnxi_885","s2-callout-green":"_s2-callout-green_1gnxi_898","s2-callout-text":"_s2-callout-text_1gnxi_913","s2-callout-icon":"_s2-callout-icon_1gnxi_918","s2-total-info":"_s2-total-info_1gnxi_922","s2-total-count":"_s2-total-count_1gnxi_930","s2-schedule-label":"_s2-schedule-label_1gnxi_936","s2-schedule-pills":"_s2-schedule-pills_1gnxi_943","s2-schedule-pill":"_s2-schedule-pill_1gnxi_943","s2-core-section":"_s2-core-section_1gnxi_969","s2-core-header":"_s2-core-header_1gnxi_974","s2-core-title":"_s2-core-title_1gnxi_980","s2-badge-pink":"_s2-badge-pink_1gnxi_986","s2-core-subheader":"_s2-core-subheader_1gnxi_994","s2-core-circle-icon":"_s2-core-circle-icon_1gnxi_1000","s2-core-subtitle":"_s2-core-subtitle_1gnxi_1004","s2-badge-red":"_s2-badge-red_1gnxi_1010","s2-core-cards-grid":"_s2-core-cards-grid_1gnxi_1018","s2-core-card":"_s2-core-card_1gnxi_1018","s2-core-card-top":"_s2-core-card-top_1gnxi_1039","s2-core-card-title":"_s2-core-card-title_1gnxi_1046","s2-badge-pinned":"_s2-badge-pinned_1gnxi_1051","s2-core-card-emotions":"_s2-core-card-emotions_1gnxi_1064","s2-emotions-label":"_s2-emotions-label_1gnxi_1071","s2-emotion-item":"_s2-emotion-item_1gnxi_1076","s2-core-card-range":"_s2-core-card-range_1gnxi_1083","s2-core-card-text":"_s2-core-card-text_1gnxi_1093","s2-core-card-followup":"_s2-core-card-followup_1gnxi_1099","s2-core-card-response":"_s2-core-card-response_1gnxi_1105","s2-core-card-kpi":"_s2-core-card-kpi_1gnxi_1110","s2-core-empty-message":"_s2-core-empty-message_1gnxi_1122","s2-core-info-banner":"_s2-core-info-banner_1gnxi_1131","s2-cluster-section":"_s2-cluster-section_1gnxi_1148","s2-cluster-header":"_s2-cluster-header_1gnxi_1154","s2-cluster-drag-icon":"_s2-cluster-drag-icon_1gnxi_1160","s2-cluster-title":"_s2-cluster-title_1gnxi_1164","s2-badge-blue":"_s2-badge-blue_1gnxi_1170","s2-cluster-item":"_s2-cluster-item_1gnxi_1178","s2-cluster-item-header":"_s2-cluster-item-header_1gnxi_1186","s2-cluster-item-left":"_s2-cluster-item-left_1gnxi_1193","s2-cluster-grip":"_s2-cluster-grip_1gnxi_1198","s2-cluster-number":"_s2-cluster-number_1gnxi_1203","s2-cluster-item-info":"_s2-cluster-item-info_1gnxi_1215","s2-cluster-item-title":"_s2-cluster-item-title_1gnxi_1221","s2-cluster-item-count":"_s2-cluster-item-count_1gnxi_1226","s2-cluster-badge":"_s2-cluster-badge_1gnxi_1230","s2-cluster-questions":"_s2-cluster-questions_1gnxi_1238","s2-cluster-q-row":"_s2-cluster-q-row_1gnxi_1246",disabled:nn,"s2-cluster-q-title":"_s2-cluster-q-title_1gnxi_1262","s2-cluster-q-desc":"_s2-cluster-q-desc_1gnxi_1265","s2-kpi-tag":"_s2-kpi-tag_1gnxi_1268","s2-cluster-q-type":"_s2-cluster-q-type_1gnxi_1273","s2-cluster-q-left":"_s2-cluster-q-left_1gnxi_1276","s2-cluster-q-text-group":"_s2-cluster-q-text-group_1gnxi_1282","s2-cluster-q-top-row":"_s2-cluster-q-top-row_1gnxi_1288","s2-checkbox-container":"_s2-checkbox-container_1gnxi_1307","s2-custom-checkbox":"_s2-custom-checkbox_1gnxi_1314",checked:on,"s2-checkbox-label":"_s2-checkbox-label_1gnxi_1328","s2-cluster-q-right":"_s2-cluster-q-right_1gnxi_1332","s2-badge-pinned-sm":"_s2-badge-pinned-sm_1gnxi_1353","s2-badge-pin-to-core":"_s2-badge-pin-to-core_1gnxi_1374","s2-badge-pin-disabled":"_s2-badge-pin-disabled_1gnxi_1399","s2-modal-overlay":"_s2-modal-overlay_1gnxi_1424","s2-modal-container":"_s2-modal-container_1gnxi_1438",s2ModalScale:rn,"s2-modal-close-btn":"_s2-modal-close-btn_1gnxi_1459","s2-modal-header":"_s2-modal-header_1gnxi_1479","s2-modal-warning-icon-wrapper":"_s2-modal-warning-icon-wrapper_1gnxi_1487","s2-modal-title":"_s2-modal-title_1gnxi_1499","s2-modal-subtitle":"_s2-modal-subtitle_1gnxi_1506","s2-modal-body-card":"_s2-modal-body-card_1gnxi_1512","s2-modal-info-item":"_s2-modal-info-item_1gnxi_1522","info-label":"_info-label_1gnxi_1527","info-value":"_info-value_1gnxi_1532","s2-modal-divider":"_s2-modal-divider_1gnxi_1537","s2-modal-warning-msg":"_s2-modal-warning-msg_1gnxi_1541","s2-modal-footer":"_s2-modal-footer_1gnxi_1554","s2-btn-cancel":"_s2-btn-cancel_1gnxi_1568","s2-btn-disable":"_s2-btn-disable_1gnxi_1575","s2-btn-delete":"_s2-btn-delete_1gnxi_1582","s2-custom-section":"_s2-custom-section_1gnxi_1591","s2-custom-header":"_s2-custom-header_1gnxi_1598","s2-custom-title":"_s2-custom-title_1gnxi_1603","s2-custom-info-card":"_s2-custom-info-card_1gnxi_1610","s2-info-icon-left":"_s2-info-icon-left_1gnxi_1619","s2-info-content-right":"_s2-info-content-right_1gnxi_1625","s2-custom-info-header":"_s2-custom-info-header_1gnxi_1631","s2-info-emoji":"_s2-info-emoji_1gnxi_1636","s2-info-title":"_s2-info-title_1gnxi_1639","s2-custom-info-text":"_s2-custom-info-text_1gnxi_1644","s2-custom-info-tip":"_s2-custom-info-tip_1gnxi_1652","s2-tip-header-row":"_s2-tip-header-row_1gnxi_1661","s2-tip-emoji":"_s2-tip-emoji_1gnxi_1666","s2-tip-title":"_s2-tip-title_1gnxi_1669","s2-tip-desc":"_s2-tip-desc_1gnxi_1674","s2-custom-list":"_s2-custom-list_1gnxi_1684","s2-custom-q-row":"_s2-custom-q-row_1gnxi_1691","s2-custom-q-text":"_s2-custom-q-text_1gnxi_1701","s2-custom-q-right":"_s2-custom-q-right_1gnxi_1706","s2-custom-q-type":"_s2-custom-q-type_1gnxi_1711","s2-custom-q-remove":"_s2-custom-q-remove_1gnxi_1719","s2-add-custom-btn":"_s2-add-custom-btn_1gnxi_1734","s2-creator-form":"_s2-creator-form_1gnxi_1755","s2-creator-title":"_s2-creator-title_1gnxi_1764","s2-creator-label":"_s2-creator-label_1gnxi_1770","s2-creator-input-wrapper":"_s2-creator-input-wrapper_1gnxi_1776","s2-creator-input":"_s2-creator-input_1gnxi_1776","s2-grades-selector-box":"_s2-grades-selector-box_1gnxi_1797","s2-grades-selector-actions":"_s2-grades-selector-actions_1gnxi_1806",inactive:an,"s2-grades-grid":"_s2-grades-grid_1gnxi_1833","s2-grade-btn":"_s2-grade-btn_1gnxi_1843",selected:ln,"s2-grades-warning":"_s2-grades-warning_1gnxi_1866","s2-schedule-date-box":"_s2-schedule-date-box_1gnxi_1875","s2-date-inputs-row":"_s2-date-inputs-row_1gnxi_1884","s2-date-input-group":"_s2-date-input-group_1gnxi_1894","s2-schedule-helper-text":"_s2-schedule-helper-text_1gnxi_1904","s2-grades-selected-summary":"_s2-grades-selected-summary_1gnxi_1909","s2-creator-actions":"_s2-creator-actions_1gnxi_1920","btn-secondary":"_btn-secondary_1gnxi_1935","btn-primary":"_btn-primary_1gnxi_1942","s2-custom-cluster-box":"_s2-custom-cluster-box_1gnxi_1957","s2-custom-cluster-header":"_s2-custom-cluster-header_1gnxi_1967","s2-custom-cluster-header-left":"_s2-custom-cluster-header-left_1gnxi_1972","s2-custom-cluster-grip":"_s2-custom-cluster-grip_1gnxi_1977","s2-custom-cluster-number":"_s2-custom-cluster-number_1gnxi_1983","s2-custom-cluster-info":"_s2-custom-cluster-info_1gnxi_1995","s2-custom-cluster-title":"_s2-custom-cluster-title_1gnxi_2002","s2-custom-cluster-count":"_s2-custom-cluster-count_1gnxi_2007","s2-custom-cluster-badge":"_s2-custom-cluster-badge_1gnxi_2011","s2-custom-cluster-banner":"_s2-custom-cluster-banner_1gnxi_2018","s2-banner-icon":"_s2-banner-icon_1gnxi_2029","s2-custom-cluster-list":"_s2-custom-cluster-list_1gnxi_2037","s2-custom-cluster-row":"_s2-custom-cluster-row_1gnxi_2043","s2-custom-cluster-row-left":"_s2-custom-cluster-row-left_1gnxi_2053","s2-custom-cluster-row-top":"_s2-custom-cluster-row-top_1gnxi_2059","s2-custom-cluster-row-text":"_s2-custom-cluster-row-text_1gnxi_2065","s2-custom-cluster-row-tags":"_s2-custom-cluster-row-tags_1gnxi_2070","s2-custom-tag-format":"_s2-custom-tag-format_1gnxi_2075","s2-custom-tag-grades":"_s2-custom-tag-grades_1gnxi_2083","s2-custom-tag-schedule-weekly":"_s2-custom-tag-schedule-weekly_1gnxi_2090","s2-custom-tag-schedule-range":"_s2-custom-tag-schedule-range_1gnxi_2100","s2-custom-cluster-row-right":"_s2-custom-cluster-row-right_1gnxi_2115","s2-custom-cluster-edit-btn":"_s2-custom-cluster-edit-btn_1gnxi_2120","s2-custom-cluster-delete-btn":"_s2-custom-cluster-delete-btn_1gnxi_2135","s3-wrapper":"_s3-wrapper_1gnxi_2154","s3-header":"_s3-header_1gnxi_2160","s3-title":"_s3-title_1gnxi_2164","s3-subtitle":"_s3-subtitle_1gnxi_2171","s3-info-banner":"_s3-info-banner_1gnxi_2177","s3-info-icon":"_s3-info-icon_1gnxi_2188","s3-info-banner-title":"_s3-info-banner-title_1gnxi_2195","s3-info-banner-desc":"_s3-info-banner-desc_1gnxi_2203","s3-module-list":"_s3-module-list_1gnxi_2212","s3-module-wrapper":"_s3-module-wrapper_1gnxi_2218","s3-module-wrapper--active":"_s3-module-wrapper--active_1gnxi_2223","s3-module-card":"_s3-module-card_1gnxi_2230","s3-module-tag":"_s3-module-tag_1gnxi_2237","s3-active-grades-container":"_s3-active-grades-container_1gnxi_2242","s3-periods-container":"_s3-periods-container_1gnxi_2246","s3-period-row":"_s3-period-row_1gnxi_2251","s3-module-card--active":"_s3-module-card--active_1gnxi_2266","s3-card-top":"_s3-card-top_1gnxi_2271","s3-icon-box":"_s3-icon-box_1gnxi_2278","s3-module-info":"_s3-module-info_1gnxi_2289","s3-module-title":"_s3-module-title_1gnxi_2297","s3-module-desc":"_s3-module-desc_1gnxi_2304","s3-expand-btn":"_s3-expand-btn_1gnxi_2324","s3-toggle-col":"_s3-toggle-col_1gnxi_2344","s3-questions-panel":"_s3-questions-panel_1gnxi_2349","s3-question-item":"_s3-question-item_1gnxi_2358","s3-question-num":"_s3-question-num_1gnxi_2366","s3-question-header":"_s3-question-header_1gnxi_2379","s3-list-question-header":"_s3-list-question-header_1gnxi_2386","s3-list-question-title":"_s3-list-question-title_1gnxi_2393","es-header":"_es-header_1gnxi_2401","ms-header":"_ms-header_1gnxi_2406","s3-list-question-desc":"_s3-list-question-desc_1gnxi_2415","s3-questions":"_s3-questions_1gnxi_2349","s3-question-body":"_s3-question-body_1gnxi_2423","s3-question-text":"_s3-question-text_1gnxi_2429","s3-question-type":"_s3-question-type_1gnxi_2436","s3-divider":"_s3-divider_1gnxi_2441","s3-grades-label":"_s3-grades-label_1gnxi_2461","s3-checkbox-row":"_s3-checkbox-row_1gnxi_2467","s3-checkbox-label":"_s3-checkbox-label_1gnxi_2473","s3-periods-header":"_s3-periods-header_1gnxi_2499","s3-periods-title":"_s3-periods-title_1gnxi_2506","s3-add-period-btn":"_s3-add-period-btn_1gnxi_2512","s3-period-row-header":"_s3-period-row-header_1gnxi_2541","s3-period-row-title":"_s3-period-row-title_1gnxi_2548","s3-delete-period-btn":"_s3-delete-period-btn_1gnxi_2554","s3-period-dates":"_s3-period-dates_1gnxi_2570","s3-period-date-input":"_s3-period-date-input_1gnxi_2581","s3-no-periods-text":"_s3-no-periods-text_1gnxi_2593","module-cards-column":"_module-cards-column_1gnxi_2599","module-card":"_module-card_1gnxi_2599","module-info":"_module-info_1gnxi_2620","module-title":"_module-title_1gnxi_2627","module-desc":"_module-desc_1gnxi_2632","view-questions-btn":"_view-questions-btn_1gnxi_2637","module-questions-list":"_module-questions-list_1gnxi_2653","journey-header-block":"_journey-header-block_1gnxi_2664","journey-badge-engagement":"_journey-badge-engagement_1gnxi_2669","journey-step-title":"_journey-step-title_1gnxi_2679","journey-step-subtitle":"_journey-step-subtitle_1gnxi_2686","journey-grid":"_journey-grid_1gnxi_2692","journey-card":"_journey-card_1gnxi_2709","journey-icon-circle":"_journey-icon-circle_1gnxi_2730","journey-name":"_journey-name_1gnxi_2741","journey-desc":"_journey-desc_1gnxi_2749","journey-xp-badge":"_journey-xp-badge_1gnxi_2761","custom-switch":"_custom-switch_1gnxi_2772","custom-switch__thumb":"_custom-switch__thumb_1gnxi_2784","active-grades-box":"_active-grades-box_1gnxi_2800","active-grades-title":"_active-grades-title_1gnxi_2810","active-grades-list":"_active-grades-list_1gnxi_2817","grade-item":"_grade-item_1gnxi_2823","check-square":"_check-square_1gnxi_2832","journey-benefits-box-new":"_journey-benefits-box-new_1gnxi_2857","benefits-title-new":"_benefits-title-new_1gnxi_2866","benefits-list-new":"_benefits-list-new_1gnxi_2874","tick-icon":"_tick-icon_1gnxi_2890","bonus-header-block":"_bonus-header-block_1gnxi_2899","bonus-badge":"_bonus-badge_1gnxi_2904","bonus-step-title":"_bonus-step-title_1gnxi_2914","bonus-step-subtitle":"_bonus-step-subtitle_1gnxi_2920","bonus-tab-row":"_bonus-tab-row_1gnxi_2926","bonus-tab-btn":"_bonus-tab-btn_1gnxi_2933","tab-title-line":"_tab-title-line_1gnxi_2948","tab-sub-line":"_tab-sub-line_1gnxi_2953","bonus-editing-banner":"_bonus-editing-banner_1gnxi_2971","bonus-enable-box":"_bonus-enable-box_1gnxi_2988","bonus-enable-title":"_bonus-enable-title_1gnxi_3000","bonus-enable-desc":"_bonus-enable-desc_1gnxi_3011","custom-orange-switch":"_custom-orange-switch_1gnxi_3018","custom-orange-switch__thumb":"_custom-orange-switch__thumb_1gnxi_3031","bonus-topics-section":"_bonus-topics-section_1gnxi_3047","bonus-topics-title":"_bonus-topics-title_1gnxi_3056","bonus-topics-subtitle":"_bonus-topics-subtitle_1gnxi_3064","bonus-topics-grid":"_bonus-topics-grid_1gnxi_3070","bonus-topic-card":"_bonus-topic-card_1gnxi_3081","bonus-topic-icon-info":"_bonus-topic-icon-info_1gnxi_3103","bonus-topic-name":"_bonus-topic-name_1gnxi_3114","bonus-topic-desc":"_bonus-topic-desc_1gnxi_3121","round-checkbox":"_round-checkbox_1gnxi_3128","bonus-status-banner":"_bonus-status-banner_1gnxi_3157","tick-icon-green":"_tick-icon-green_1gnxi_3168","status-title":"_status-title_1gnxi_3174","status-text":"_status-text_1gnxi_3180","summary-container":"_summary-container_1gnxi_3189","success-icon-wrapper":"_success-icon-wrapper_1gnxi_3198","success-icon":"_success-icon_1gnxi_3198","summary-heading":"_summary-heading_1gnxi_3209","summary-subtext":"_summary-subtext_1gnxi_3217","summary-grid-2x2":"_summary-grid-2x2_1gnxi_3227","summary-box":"_summary-box_1gnxi_3241","summary-box--routine":"_summary-box--routine_1gnxi_3250","summary-box--journeys":"_summary-box--journeys_1gnxi_3254","summary-box--bonus":"_summary-box--bonus_1gnxi_3258","summary-box--modules":"_summary-box--modules_1gnxi_3262","box-header":"_box-header_1gnxi_3267","box-header-left":"_box-header-left_1gnxi_3274","box-title":"_box-title_1gnxi_3280","box-subtitle":"_box-subtitle_1gnxi_3288","btn-edit":"_btn-edit_1gnxi_3295","box-content-list":"_box-content-list_1gnxi_3311","sub-card":"_sub-card_1gnxi_3318","sub-card__title":"_sub-card__title_1gnxi_3328","sub-card__info":"_sub-card__info_1gnxi_3335","sub-card__muted":"_sub-card__muted_1gnxi_3341","sub-card-row":"_sub-card-row_1gnxi_3349","theme-item":"_theme-item_1gnxi_3358","theme-item__icon":"_theme-item__icon_1gnxi_3368","theme-item__emoji":"_theme-item__emoji_1gnxi_3373","theme-item__info":"_theme-item__info_1gnxi_3382","theme-item__title":"_theme-item__title_1gnxi_3387","theme-item__status":"_theme-item__status_1gnxi_3394","module-item":"_module-item_1gnxi_3401","module-item__icon-box":"_module-item__icon-box_1gnxi_3411",ai_literacy:cn,bullying:dn,digital_wellbeing:un,"module-item__info":"_module-item__info_1gnxi_3430","module-item__title":"_module-item__title_1gnxi_3435","module-item__status":"_module-item__status_1gnxi_3442","summary-buttons":"_summary-buttons_1gnxi_3454","btn-preview-large":"_btn-preview-large_1gnxi_3461","preview-modal-overlay":"_preview-modal-overlay_1gnxi_3486","preview-modal-content":"_preview-modal-content_1gnxi_3500","preview-modal-content--success":"_preview-modal-content--success_1gnxi_3514","close-preview-btn-dialog":"_close-preview-btn-dialog_1gnxi_3519","preview-header":"_preview-header_1gnxi_3544","preview-title":"_preview-title_1gnxi_3552","preview-page-indicator":"_preview-page-indicator_1gnxi_3560","preview-body-container":"_preview-body-container_1gnxi_3567","preview-step-card":"_preview-step-card_1gnxi_3584","preview-step-card--purple":"_preview-step-card--purple_1gnxi_3594","preview-step-card--trivia":"_preview-step-card--trivia_1gnxi_3598","slider-group":"_slider-group_1gnxi_3611","slider-header":"_slider-header_1gnxi_3617","info-icon":"_info-icon_1gnxi_3625","slider-labels-row":"_slider-labels-row_1gnxi_3631","card-header-purple":"_card-header-purple_1gnxi_3651","purple-icon":"_purple-icon_1gnxi_3657","purple-title":"_purple-title_1gnxi_3660","mcq-box":"_mcq-box_1gnxi_3668","mcq-question":"_mcq-question_1gnxi_3675","mcq-options-list":"_mcq-options-list_1gnxi_3684","mcq-option-item":"_mcq-option-item_1gnxi_3691","mcq-option-item--correct":"_mcq-option-item--correct_1gnxi_3716","mcq-option-item--wrong":"_mcq-option-item--wrong_1gnxi_3721","mcq-option-item--disabled":"_mcq-option-item--disabled_1gnxi_3726","opt-indicator-icon":"_opt-indicator-icon_1gnxi_3730","preview-challenge-card":"_preview-challenge-card_1gnxi_3734","challenge-title":"_challenge-title_1gnxi_3744","challenge-inner-card":"_challenge-inner-card_1gnxi_3755","challenge-question":"_challenge-question_1gnxi_3765","challenge-textarea":"_challenge-textarea_1gnxi_3774","challenge-footer-text":"_challenge-footer-text_1gnxi_3790",heart:pn,"challenge-button-wrapper":"_challenge-button-wrapper_1gnxi_3800","btn-submit-xp":"_btn-submit-xp_1gnxi_3806","trivia-intro-box":"_trivia-intro-box_1gnxi_3822","trivia-gift-icon":"_trivia-gift-icon_1gnxi_3830","trivia-intro-title":"_trivia-intro-title_1gnxi_3834","trivia-intro-desc":"_trivia-intro-desc_1gnxi_3842","trivia-intro-actions":"_trivia-intro-actions_1gnxi_3850","btn-play-trivia":"_btn-play-trivia_1gnxi_3858","btn-skip-trivia":"_btn-skip-trivia_1gnxi_3872","trivia-answer-result":"_trivia-answer-result_1gnxi_3886",correct:mn,wrong:hn,"preview-success-card":"_preview-success-card_1gnxi_3902","success-title":"_success-title_1gnxi_3910","success-subtitle":"_success-subtitle_1gnxi_3918","success-xp-text":"_success-xp-text_1gnxi_3925","xp-hl":"_xp-hl_1gnxi_3931","success-box-green":"_success-box-green_1gnxi_3936","btn-thanks-large":"_btn-thanks-large_1gnxi_3949","preview-footer-buttons":"_preview-footer-buttons_1gnxi_3965","btn-next":"_btn-next_1gnxi_3972","btn-success":"_btn-success_1gnxi_4047","tooltip-popper":"_tooltip-popper_1gnxi_4083","mapping-tooltip-container":"_mapping-tooltip-container_1gnxi_4101","mapping-title-row":"_mapping-title-row_1gnxi_4113","mapping-emoji":"_mapping-emoji_1gnxi_4119","mapping-title":"_mapping-title_1gnxi_4113","mapping-table-wrapper":"_mapping-table-wrapper_1gnxi_4131","mapping-table":"_mapping-table_1gnxi_4131","flag-us":"_flag-us_1gnxi_4155","flag-gb":"_flag-gb_1gnxi_4163","us-grade-cell":"_us-grade-cell_1gnxi_4171","us-grade-header":"_us-grade-header_1gnxi_4176","row-early":"_row-early_1gnxi_4180","row-elem":"_row-elem_1gnxi_4187","row-sec":"_row-sec_1gnxi_4187","mapping-legend":"_mapping-legend_1gnxi_4194","legend-item":"_legend-item_1gnxi_4204","legend-dot":"_legend-dot_1gnxi_4210","dot-early":"_dot-early_1gnxi_4217","dot-elem":"_dot-elem_1gnxi_4220","dot-sec":"_dot-sec_1gnxi_4223","journey-selecting-alert":"_journey-selecting-alert_1gnxi_4227"},gn=n.createSvgIcon(e.jsx("path",{d:"M1 21h22L12 2zm12-3h-2v-2h2zm0-4h-2v-4h2z"}),"ReportProblem"),xn=s=>s.scrollTop;function Js(s,o){const{timeout:r,easing:i,style:l={}}=s;return{duration:l.transitionDuration??(typeof r=="number"?r:r[o.mode]||0),easing:l.transitionTimingFunction??(typeof i=="object"?i[o.mode]:i),delay:l.transitionDelay}}function As(s){return`scale(${s}, ${s**2})`}const yn={entering:{opacity:1,transform:As(1)},entered:{opacity:1,transform:"none"}},Cs=typeof navigator<"u"&&/^((?!chrome|android).)*(safari|mobile)/i.test(navigator.userAgent)&&/(os |version\/)15(.|_)4/i.test(navigator.userAgent),ws=xe.forwardRef(function(o,r){const{addEndListener:i,appear:l=!0,children:a,easing:u,in:c,onEnter:y,onEntered:m,onEntering:g,onExit:M,onExited:F,onExiting:R,style:z,timeout:P="auto",TransitionComponent:te=Be,...ne}=o,p=je.useTimeout(),N=xe.useRef(),j=it.useTheme(),I=xe.useRef(null),A=Fs.useForkRef(I,Xe.getReactElementRef(a),r),Q=ee=>f=>{if(ee){const $=I.current;f===void 0?ee($):ee($,f)}},ce=Q(g),ge=Q((ee,f)=>{xn(ee);const{duration:$,delay:W,easing:se}=Js({style:z,timeout:P,easing:u},{mode:"enter"});let X;P==="auto"?(X=j.transitions.getAutoHeightDuration(ee.clientHeight),N.current=X):X=$,ee.style.transition=[j.transitions.create("opacity",{duration:X,delay:W}),j.transitions.create("transform",{duration:Cs?X:X*.666,delay:W,easing:se})].join(","),y&&y(ee,f)}),Y=Q(m),B=Q(R),w=Q(ee=>{const{duration:f,delay:$,easing:W}=Js({style:z,timeout:P,easing:u},{mode:"exit"});let se;P==="auto"?(se=j.transitions.getAutoHeightDuration(ee.clientHeight),N.current=se):se=f,ee.style.transition=[j.transitions.create("opacity",{duration:se,delay:$}),j.transitions.create("transform",{duration:Cs?se:se*.666,delay:Cs?$:$||se*.333,easing:W})].join(","),ee.style.opacity=0,ee.style.transform=As(.75),M&&M(ee)}),J=Q(F),me=ee=>{P==="auto"&&p.start(N.current||0,ee),i&&i(I.current,ee)};return e.jsx(te,{appear:l,in:c,nodeRef:I,onEnter:ge,onEntered:Y,onEntering:ce,onExit:w,onExited:J,onExiting:B,addEndListener:me,timeout:P==="auto"?null:P,...ne,children:(ee,{ownerState:f,...$})=>xe.cloneElement(a,{style:{opacity:0,transform:As(.75),visibility:ee==="exited"&&!c?"hidden":void 0,...yn[ee],...z,...a.props.style},ref:A,...$})})});process.env.NODE_ENV!=="production"&&(ws.propTypes={addEndListener:n.PropTypes.func,appear:n.PropTypes.bool,children:Qs.isRequired,easing:n.PropTypes.oneOfType([n.PropTypes.shape({enter:n.PropTypes.string,exit:n.PropTypes.string}),n.PropTypes.string]),in:n.PropTypes.bool,onEnter:n.PropTypes.func,onEntered:n.PropTypes.func,onEntering:n.PropTypes.func,onExit:n.PropTypes.func,onExited:n.PropTypes.func,onExiting:n.PropTypes.func,style:n.PropTypes.object,timeout:n.PropTypes.oneOfType([n.PropTypes.oneOf(["auto"]),n.PropTypes.number,n.PropTypes.shape({appear:n.PropTypes.number,enter:n.PropTypes.number,exit:n.PropTypes.number})])});ws&&(ws.muiSupportAuto=!0);function fn(s){return n.generateUtilityClass("MuiTooltip",s)}const ke=n.generateUtilityClasses("MuiTooltip",["popper","popperInteractive","popperArrow","popperClose","tooltip","tooltipArrow","touch","tooltipPlacementLeft","tooltipPlacementRight","tooltipPlacementTop","tooltipPlacementBottom","arrow"]);function _n(s){return Math.round(s*1e5)/1e5}const bn=s=>{const{classes:o,disableInteractive:r,arrow:i,touch:l,placement:a}=s,u={popper:["popper",!r&&"popperInteractive",i&&"popperArrow"],tooltip:["tooltip",i&&"tooltipArrow",l&&"touch",`tooltipPlacement${n.capitalize(a.split("-")[0])}`],arrow:["arrow"]};return n.composeClasses(u,fn,o)},vn=n.styled$1(Xe.Popper,{name:"MuiTooltip",slot:"Popper",overridesResolver:(s,o)=>{const{ownerState:r}=s;return[o.popper,!r.disableInteractive&&o.popperInteractive,r.arrow&&o.popperArrow,!r.open&&o.popperClose]}})(n.memoTheme(({theme:s})=>({zIndex:(s.vars||s).zIndex.tooltip,pointerEvents:"none",variants:[{props:({ownerState:o})=>!o.disableInteractive,style:{pointerEvents:"auto"}},{props:({open:o})=>!o,style:{pointerEvents:"none"}},{props:({ownerState:o})=>o.arrow,style:{[`&[data-popper-placement*="bottom"] .${ke.arrow}`]:{top:0,marginTop:"-0.71em","&::before":{transformOrigin:"0 100%"}},[`&[data-popper-placement*="top"] .${ke.arrow}`]:{bottom:0,marginBottom:"-0.71em","&::before":{transformOrigin:"100% 0"}},[`&[data-popper-placement*="right"] .${ke.arrow}`]:{height:"1em",width:"0.71em","&::before":{transformOrigin:"100% 100%"}},[`&[data-popper-placement*="left"] .${ke.arrow}`]:{height:"1em",width:"0.71em","&::before":{transformOrigin:"0 0"}}}},{props:({ownerState:o})=>o.arrow&&!o.isRtl,style:{[`&[data-popper-placement*="right"] .${ke.arrow}`]:{left:0,marginLeft:"-0.71em"}}},{props:({ownerState:o})=>o.arrow&&!!o.isRtl,style:{[`&[data-popper-placement*="right"] .${ke.arrow}`]:{right:0,marginRight:"-0.71em"}}},{props:({ownerState:o})=>o.arrow&&!o.isRtl,style:{[`&[data-popper-placement*="left"] .${ke.arrow}`]:{right:0,marginRight:"-0.71em"}}},{props:({ownerState:o})=>o.arrow&&!!o.isRtl,style:{[`&[data-popper-placement*="left"] .${ke.arrow}`]:{left:0,marginLeft:"-0.71em"}}}]}))),jn=n.styled$1("div",{name:"MuiTooltip",slot:"Tooltip",overridesResolver:(s,o)=>{const{ownerState:r}=s;return[o.tooltip,r.touch&&o.touch,r.arrow&&o.tooltipArrow,o[`tooltipPlacement${n.capitalize(r.placement.split("-")[0])}`]]}})(n.memoTheme(({theme:s})=>({backgroundColor:s.vars?s.vars.palette.Tooltip.bg:n.alpha(s.palette.grey[700],.92),borderRadius:(s.vars||s).shape.borderRadius,color:(s.vars||s).palette.common.white,fontFamily:s.typography.fontFamily,padding:"4px 8px",fontSize:s.typography.pxToRem(11),maxWidth:300,margin:2,wordWrap:"break-word",fontWeight:s.typography.fontWeightMedium,[`.${ke.popper}[data-popper-placement*="left"] &`]:{transformOrigin:"right center"},[`.${ke.popper}[data-popper-placement*="right"] &`]:{transformOrigin:"left center"},[`.${ke.popper}[data-popper-placement*="top"] &`]:{transformOrigin:"center bottom",marginBottom:"14px"},[`.${ke.popper}[data-popper-placement*="bottom"] &`]:{transformOrigin:"center top",marginTop:"14px"},variants:[{props:({ownerState:o})=>o.arrow,style:{position:"relative",margin:0}},{props:({ownerState:o})=>o.touch,style:{padding:"8px 16px",fontSize:s.typography.pxToRem(14),lineHeight:`${_n(16/14)}em`,fontWeight:s.typography.fontWeightRegular}},{props:({ownerState:o})=>!o.isRtl,style:{[`.${ke.popper}[data-popper-placement*="left"] &`]:{marginRight:"14px"},[`.${ke.popper}[data-popper-placement*="right"] &`]:{marginLeft:"14px"}}},{props:({ownerState:o})=>!o.isRtl&&o.touch,style:{[`.${ke.popper}[data-popper-placement*="left"] &`]:{marginRight:"24px"},[`.${ke.popper}[data-popper-placement*="right"] &`]:{marginLeft:"24px"}}},{props:({ownerState:o})=>!!o.isRtl,style:{[`.${ke.popper}[data-popper-placement*="left"] &`]:{marginLeft:"14px"},[`.${ke.popper}[data-popper-placement*="right"] &`]:{marginRight:"14px"}}},{props:({ownerState:o})=>!!o.isRtl&&o.touch,style:{[`.${ke.popper}[data-popper-placement*="left"] &`]:{marginLeft:"24px"},[`.${ke.popper}[data-popper-placement*="right"] &`]:{marginRight:"24px"}}},{props:({ownerState:o})=>o.touch,style:{[`.${ke.popper}[data-popper-placement*="top"] &`]:{marginBottom:"24px"}}},{props:({ownerState:o})=>o.touch,style:{[`.${ke.popper}[data-popper-placement*="bottom"] &`]:{marginTop:"24px"}}}]}))),wn=n.styled$1("span",{name:"MuiTooltip",slot:"Arrow",overridesResolver:(s,o)=>o.arrow})(n.memoTheme(({theme:s})=>({overflow:"hidden",position:"absolute",width:"1em",height:"0.71em",boxSizing:"border-box",color:s.vars?s.vars.palette.Tooltip.bg:n.alpha(s.palette.grey[700],.9),"&::before":{content:'""',margin:"auto",display:"block",width:"100%",height:"100%",backgroundColor:"currentColor",transform:"rotate(45deg)"}})));let hs=!1;const Ks=new je.Timeout;let is={x:0,y:0};function gs(s,o){return(r,...i)=>{o&&o(r,...i),s(r,...i)}}const pt=xe.forwardRef(function(o,r){const i=n.useDefaultProps({props:o,name:"MuiTooltip"}),{arrow:l=!1,children:a,classes:u,components:c={},componentsProps:y={},describeChild:m=!1,disableFocusListener:g=!1,disableHoverListener:M=!1,disableInteractive:F=!1,disableTouchListener:R=!1,enterDelay:z=100,enterNextDelay:P=0,enterTouchDelay:te=700,followCursor:ne=!1,id:p,leaveDelay:N=0,leaveTouchDelay:j=1500,onClose:I,onOpen:A,open:Q,placement:ce="bottom",PopperComponent:ge,PopperProps:Y={},slotProps:B={},slots:w={},title:J,TransitionComponent:me,TransitionProps:ee,...f}=i,$=xe.isValidElement(a)?a:e.jsx("span",{children:a}),W=it.useTheme(),se=Ye.useRtl(),[X,H]=xe.useState(),[ye,Ne]=xe.useState(null),k=xe.useRef(!1),V=F||ne,he=je.useTimeout(),de=je.useTimeout(),ue=je.useTimeout(),_e=je.useTimeout(),[Me,Le]=Xe.useControlled({controlled:Q,default:!1,name:"Tooltip",state:"open"});let we=Me;if(process.env.NODE_ENV!=="production"){const{current:pe}=xe.useRef(Q!==void 0);xe.useEffect(()=>{X&&X.disabled&&!pe&&J!==""&&X.tagName.toLowerCase()==="button"&&console.warn(["MUI: You are providing a disabled `button` child to the Tooltip component.","A disabled element does not fire events.","Tooltip needs to listen to the child element's events to display the title.","","Add a simple wrapper element, such as a `span`."].join(`
2
+ `))},[J,X,pe])}const be=us.useId(p),Ce=xe.useRef(),Ae=je.useEventCallback(()=>{Ce.current!==void 0&&(document.body.style.WebkitUserSelect=Ce.current,Ce.current=void 0),_e.clear()});xe.useEffect(()=>Ae,[Ae]);const Ge=pe=>{Ks.clear(),hs=!0,Le(!0),A&&!we&&A(pe)},Te=je.useEventCallback(pe=>{Ks.start(800+N,()=>{hs=!1}),Le(!1),I&&we&&I(pe),he.start(W.transitions.duration.shortest,()=>{k.current=!1})}),Re=pe=>{k.current&&pe.type!=="touchstart"||(X&&X.removeAttribute("title"),de.clear(),ue.clear(),z||hs&&P?de.start(hs?P:z,()=>{Ge(pe)}):Ge(pe))},Fe=pe=>{de.clear(),ue.start(N,()=>{Te(pe)})},[,He]=xe.useState(!1),Ve=pe=>{je.isFocusVisible(pe.target)||(He(!1),Fe(pe))},d=pe=>{X||H(pe.currentTarget),je.isFocusVisible(pe.target)&&(He(!0),Re(pe))},C=pe=>{k.current=!0;const Qe=$.props;Qe.onTouchStart&&Qe.onTouchStart(pe)},D=pe=>{C(pe),ue.clear(),he.clear(),Ae(),Ce.current=document.body.style.WebkitUserSelect,document.body.style.WebkitUserSelect="none",_e.start(te,()=>{document.body.style.WebkitUserSelect=Ce.current,Re(pe)})},h=pe=>{$.props.onTouchEnd&&$.props.onTouchEnd(pe),Ae(),ue.start(j,()=>{Te(pe)})};xe.useEffect(()=>{if(!we)return;function pe(Qe){Qe.key==="Escape"&&Te(Qe)}return document.addEventListener("keydown",pe),()=>{document.removeEventListener("keydown",pe)}},[Te,we]);const x=Fs.useForkRef(Xe.getReactElementRef($),H,r);!J&&J!==0&&(we=!1);const b=xe.useRef(),v=pe=>{const Qe=$.props;Qe.onMouseMove&&Qe.onMouseMove(pe),is={x:pe.clientX,y:pe.clientY},b.current&&b.current.update()},_={},S=typeof J=="string";m?(_.title=!we&&S&&!M?J:null,_["aria-describedby"]=we?be:null):(_["aria-label"]=S?J:null,_["aria-labelledby"]=we&&!S?be:null);const L={..._,...f,...$.props,className:n.clsx(f.className,$.props.className),onTouchStart:C,ref:x,...ne?{onMouseMove:v}:{}};process.env.NODE_ENV!=="production"&&(L["data-mui-internal-clone-element"]=!0,xe.useEffect(()=>{X&&!X.getAttribute("data-mui-internal-clone-element")&&console.error(["MUI: The `children` component of the Tooltip is not forwarding its props correctly.","Please make sure that props are spread on the same element that the ref is applied to."].join(`
3
+ `))},[X]));const E={};R||(L.onTouchStart=D,L.onTouchEnd=h),M||(L.onMouseOver=gs(Re,L.onMouseOver),L.onMouseLeave=gs(Fe,L.onMouseLeave),V||(E.onMouseOver=Re,E.onMouseLeave=Fe)),g||(L.onFocus=gs(d,L.onFocus),L.onBlur=gs(Ve,L.onBlur),V||(E.onFocus=d,E.onBlur=Ve)),process.env.NODE_ENV!=="production"&&$.props.title&&console.error(["MUI: You have provided a `title` prop to the child of <Tooltip />.",`Remove this title prop \`${$.props.title}\` or the Tooltip component.`].join(`
4
+ `));const T={...i,isRtl:se,arrow:l,disableInteractive:V,placement:ce,PopperComponentProp:ge,touch:k.current},G=typeof B.popper=="function"?B.popper(T):B.popper,Z=xe.useMemo(()=>{let pe=[{name:"arrow",enabled:!!ye,options:{element:ye,padding:4}}];return Y.popperOptions?.modifiers&&(pe=pe.concat(Y.popperOptions.modifiers)),G?.popperOptions?.modifiers&&(pe=pe.concat(G.popperOptions.modifiers)),{...Y.popperOptions,...G?.popperOptions,modifiers:pe}},[ye,Y.popperOptions,G?.popperOptions]),U=bn(T),K=typeof B.transition=="function"?B.transition(T):B.transition,O={slots:{popper:c.Popper,transition:c.Transition??me,tooltip:c.Tooltip,arrow:c.Arrow,...w},slotProps:{arrow:B.arrow??y.arrow,popper:{...Y,...G??y.popper},tooltip:B.tooltip??y.tooltip,transition:{...ee,...K??y.transition}}},[ae,oe]=Oe.useSlot("popper",{elementType:vn,externalForwardedProps:O,ownerState:T,className:n.clsx(U.popper,Y?.className)}),[re,ie]=Oe.useSlot("transition",{elementType:ws,externalForwardedProps:O,ownerState:T}),[le,Ee]=Oe.useSlot("tooltip",{elementType:jn,className:U.tooltip,externalForwardedProps:O,ownerState:T}),[Ue,Ie]=Oe.useSlot("arrow",{elementType:wn,className:U.arrow,externalForwardedProps:O,ownerState:T,ref:Ne});return e.jsxs(xe.Fragment,{children:[xe.cloneElement($,L),e.jsx(ae,{as:ge??Xe.Popper,placement:ce,anchorEl:ne?{getBoundingClientRect:()=>({top:is.y,left:is.x,right:is.x,bottom:is.y,width:0,height:0})}:X,popperRef:b,open:X?we:!1,id:be,transition:!0,...E,...oe,popperOptions:Z,children:({TransitionProps:pe})=>e.jsx(re,{timeout:W.transitions.duration.shorter,...pe,...ie,children:e.jsxs(le,{...Ee,children:[J,l?e.jsx(Ue,{...Ie}):null]})})})]})});process.env.NODE_ENV!=="production"&&(pt.propTypes={arrow:n.PropTypes.bool,children:Qs.isRequired,classes:n.PropTypes.object,className:n.PropTypes.string,components:n.PropTypes.shape({Arrow:n.PropTypes.elementType,Popper:n.PropTypes.elementType,Tooltip:n.PropTypes.elementType,Transition:n.PropTypes.elementType}),componentsProps:n.PropTypes.shape({arrow:n.PropTypes.object,popper:n.PropTypes.object,tooltip:n.PropTypes.object,transition:n.PropTypes.object}),describeChild:n.PropTypes.bool,disableFocusListener:n.PropTypes.bool,disableHoverListener:n.PropTypes.bool,disableInteractive:n.PropTypes.bool,disableTouchListener:n.PropTypes.bool,enterDelay:n.PropTypes.number,enterNextDelay:n.PropTypes.number,enterTouchDelay:n.PropTypes.number,followCursor:n.PropTypes.bool,id:n.PropTypes.string,leaveDelay:n.PropTypes.number,leaveTouchDelay:n.PropTypes.number,onClose:n.PropTypes.func,onOpen:n.PropTypes.func,open:n.PropTypes.bool,placement:n.PropTypes.oneOf(["auto-end","auto-start","auto","bottom-end","bottom-start","bottom","left-end","left-start","left","right-end","right-start","right","top-end","top-start","top"]),PopperComponent:n.PropTypes.elementType,PopperProps:n.PropTypes.object,slotProps:n.PropTypes.shape({arrow:n.PropTypes.oneOfType([n.PropTypes.func,n.PropTypes.object]),popper:n.PropTypes.oneOfType([n.PropTypes.func,n.PropTypes.object]),tooltip:n.PropTypes.oneOfType([n.PropTypes.func,n.PropTypes.object]),transition:n.PropTypes.oneOfType([n.PropTypes.func,n.PropTypes.object])}),slots:n.PropTypes.shape({arrow:n.PropTypes.elementType,popper:n.PropTypes.elementType,tooltip:n.PropTypes.elementType,transition:n.PropTypes.elementType}),sx:n.PropTypes.oneOfType([n.PropTypes.arrayOf(n.PropTypes.oneOfType([n.PropTypes.func,n.PropTypes.object,n.PropTypes.bool])),n.PropTypes.func,n.PropTypes.object]),title:n.PropTypes.node,TransitionComponent:n.PropTypes.elementType,TransitionProps:n.PropTypes.object});const zs=({width:s=22,height:o=16,style:r,...i})=>e.jsx("svg",{viewBox:"0 0 640 480",width:s,height:o,style:{borderRadius:"2px",display:"inline-block",verticalAlign:"middle",marginRight:"6px",flexShrink:0,...r},...i,children:e.jsxs("g",{fillRule:"evenodd",children:[e.jsx("path",{fill:"#bd3d44",d:"M0 0h640v480H0z"}),e.jsx("path",{fill:"#fff",d:"M0 36.9h640v36.9H0zm0 73.8h640v36.9H0zm0 73.9h640v36.9H0zm0 73.8h640v36.9H0zm0 73.9h640v36.9H0zm0 73.8h640v36.9H0z"}),e.jsx("path",{fill:"#192f5d",d:"M0 0h280v258.5H0z"}),e.jsxs("g",{fill:"#fff",children:[e.jsx("polygon",{points:"28,13 32,25 45,25 35,32 39,44 28,37 17,44 21,32 11,25 24,25"}),e.jsx("polygon",{points:"84,13 88,25 101,25 91,32 95,44 84,37 73,44 77,32 67,25 80,25"}),e.jsx("polygon",{points:"140,13 144,25 157,25 147,32 151,44 140,37 129,44 133,32 123,25 136,25"}),e.jsx("polygon",{points:"196,13 200,25 213,25 203,32 207,44 196,37 185,44 189,32 179,25 192,25"})]})]})}),Gs=({width:s=22,height:o=16,style:r,...i})=>e.jsxs("svg",{viewBox:"0 0 600 400",width:s,height:o,style:{borderRadius:"2px",display:"inline-block",verticalAlign:"middle",marginRight:"6px",flexShrink:0,...r},...i,children:[e.jsx("clipPath",{id:"gb-flag-clip-shared",children:e.jsx("path",{d:"M0 0h600v400H0z"})}),e.jsxs("g",{clipPath:"url(#gb-flag-clip-shared)",children:[e.jsx("path",{d:"M0 0h600v400H0z",fill:"#012169"}),e.jsx("path",{d:"M0 0l600 400M600 0L0 400",stroke:"#fff",strokeWidth:"60"}),e.jsx("path",{d:"M0 0l600 400M600 0L0 400",stroke:"#C8102E",strokeWidth:"40"}),e.jsx("path",{d:"M300 0v400M0 200h600",stroke:"#fff",strokeWidth:"100"}),e.jsx("path",{d:"M300 0v400M0 200h600",stroke:"#C8102E",strokeWidth:"60"})]})]}),Tn=()=>e.jsxs("div",{className:t["mapping-tooltip-container"],children:[e.jsxs("div",{className:t["mapping-title-row"],children:[e.jsx("span",{className:t["mapping-emoji"],children:"📋"}),e.jsx("h4",{className:t["mapping-title"],children:"US ↔ UK Curriculum Mapping"})]}),e.jsx("div",{className:t["mapping-table-wrapper"],children:e.jsxs("table",{className:t["mapping-table"],children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Age"}),e.jsxs("th",{className:t["us-grade-header"],children:[e.jsx(zs,{width:16,height:12,style:{marginRight:"4px"}})," US Grade"]}),e.jsxs("th",{children:[e.jsx(Gs,{width:16,height:12,style:{marginRight:"4px"}})," UK Year"]}),e.jsx("th",{children:"Key Stage"})]})}),e.jsx("tbody",{children:Ht.map((s,o)=>e.jsxs("tr",{className:t[`row-${s.category}`],children:[e.jsx("td",{children:s.age}),e.jsx("td",{className:s.us!=="—"?t["us-grade-cell"]:"",children:s.us}),e.jsx("td",{children:s.uk}),e.jsx("td",{children:s.ks})]},o))})]})}),e.jsxs("div",{className:t["mapping-legend"],children:[e.jsxs("div",{className:t["legend-item"],children:[e.jsx("span",{className:`${t["legend-dot"]} ${t["dot-early"]}`}),e.jsx("span",{children:"Early Years (Locked)"})]}),e.jsxs("div",{className:t["legend-item"],children:[e.jsx("span",{className:`${t["legend-dot"]} ${t["dot-elem"]}`}),e.jsx("span",{children:"Elementary / Primary"})]}),e.jsxs("div",{className:t["legend-item"],children:[e.jsx("span",{className:`${t["legend-dot"]} ${t["dot-sec"]}`}),e.jsx("span",{children:"Secondary / High School"})]})]})]});function kn(s){return n.generateUtilityClass("PrivateSwitchBase",s)}n.generateUtilityClasses("PrivateSwitchBase",["root","checked","disabled","input","edgeStart","edgeEnd"]);const Sn=s=>{const{classes:o,checked:r,disabled:i,edge:l}=s,a={root:["root",r&&"checked",i&&"disabled",l&&`edge${n.capitalize(l)}`],input:["input"]};return n.composeClasses(a,kn,o)},Pn=n.styled$1(je.ButtonBase,{name:"MuiSwitchBase"})({padding:9,borderRadius:"50%",variants:[{props:{edge:"start",size:"small"},style:{marginLeft:-3}},{props:({edge:s,ownerState:o})=>s==="start"&&o.size!=="small",style:{marginLeft:-12}},{props:{edge:"end",size:"small"},style:{marginRight:-3}},{props:({edge:s,ownerState:o})=>s==="end"&&o.size!=="small",style:{marginRight:-12}}]}),Nn=n.styled$1("input",{name:"MuiSwitchBase",shouldForwardProp:n.rootShouldForwardProp})({cursor:"inherit",position:"absolute",opacity:0,width:"100%",height:"100%",top:0,left:0,margin:0,padding:0,zIndex:1}),mt=xe.forwardRef(function(o,r){const{autoFocus:i,checked:l,checkedIcon:a,defaultChecked:u,disabled:c,disableFocusRipple:y=!1,edge:m=!1,icon:g,id:M,inputProps:F,inputRef:R,name:z,onBlur:P,onChange:te,onFocus:ne,readOnly:p,required:N=!1,tabIndex:j,type:I,value:A,slots:Q={},slotProps:ce={},...ge}=o,[Y,B]=Xe.useControlled({controlled:l,default:!!u,name:"SwitchBase",state:"checked"}),w=ls.useFormControl(),J=V=>{ne&&ne(V),w&&w.onFocus&&w.onFocus(V)},me=V=>{P&&P(V),w&&w.onBlur&&w.onBlur(V)},ee=V=>{if(V.nativeEvent.defaultPrevented)return;const he=V.target.checked;B(he),te&&te(V,he)};let f=c;w&&typeof f>"u"&&(f=w.disabled);const $=I==="checkbox"||I==="radio",W={...o,checked:Y,disabled:f,disableFocusRipple:y,edge:m},se=Sn(W),X={slots:Q,slotProps:{input:F,...ce}},[H,ye]=Oe.useSlot("root",{ref:r,elementType:Pn,className:se.root,shouldForwardComponentProp:!0,externalForwardedProps:{...X,component:"span",...ge},getSlotProps:V=>({...V,onFocus:he=>{V.onFocus?.(he),J(he)},onBlur:he=>{V.onBlur?.(he),me(he)}}),ownerState:W,additionalProps:{centerRipple:!0,focusRipple:!y,disabled:f,role:void 0,tabIndex:null}}),[Ne,k]=Oe.useSlot("input",{ref:R,elementType:Nn,className:se.input,externalForwardedProps:X,getSlotProps:V=>({onChange:he=>{V.onChange?.(he),ee(he)}}),ownerState:W,additionalProps:{autoFocus:i,checked:l,defaultChecked:u,disabled:f,id:$?M:void 0,name:z,readOnly:p,required:N,tabIndex:j,type:I,...I==="checkbox"&&A===void 0?{}:{value:A}}});return e.jsxs(H,{...ye,children:[e.jsx(Ne,{...k}),Y?a:g]})});process.env.NODE_ENV!=="production"&&(mt.propTypes={autoFocus:n.PropTypes.bool,checked:n.PropTypes.bool,checkedIcon:n.PropTypes.node.isRequired,classes:n.PropTypes.object,className:n.PropTypes.string,defaultChecked:n.PropTypes.bool,disabled:n.PropTypes.bool,disableFocusRipple:n.PropTypes.bool,edge:n.PropTypes.oneOf(["end","start",!1]),icon:n.PropTypes.node.isRequired,id:n.PropTypes.string,inputProps:n.PropTypes.object,inputRef:je.refType,name:n.PropTypes.string,onBlur:n.PropTypes.func,onChange:n.PropTypes.func,onFocus:n.PropTypes.func,readOnly:n.PropTypes.bool,required:n.PropTypes.bool,slotProps:n.PropTypes.shape({input:n.PropTypes.oneOfType([n.PropTypes.func,n.PropTypes.object]),root:n.PropTypes.oneOfType([n.PropTypes.func,n.PropTypes.object])}),slots:n.PropTypes.shape({input:n.PropTypes.elementType,root:n.PropTypes.elementType}),sx:n.PropTypes.object,tabIndex:n.PropTypes.oneOfType([n.PropTypes.number,n.PropTypes.string]),type:n.PropTypes.string.isRequired,value:n.PropTypes.any});function Cn(s){return n.generateUtilityClass("MuiSwitch",s)}const De=n.generateUtilityClasses("MuiSwitch",["root","edgeStart","edgeEnd","switchBase","colorPrimary","colorSecondary","sizeSmall","sizeMedium","checked","disabled","input","thumb","track"]),En=s=>{const{classes:o,edge:r,size:i,color:l,checked:a,disabled:u}=s,c={root:["root",r&&`edge${n.capitalize(r)}`,`size${n.capitalize(i)}`],switchBase:["switchBase",`color${n.capitalize(l)}`,a&&"checked",u&&"disabled"],thumb:["thumb"],track:["track"],input:["input"]},y=n.composeClasses(c,Cn,o);return{...o,...y}},Dn=n.styled$1("span",{name:"MuiSwitch",slot:"Root",overridesResolver:(s,o)=>{const{ownerState:r}=s;return[o.root,r.edge&&o[`edge${n.capitalize(r.edge)}`],o[`size${n.capitalize(r.size)}`]]}})({display:"inline-flex",width:58,height:38,overflow:"hidden",padding:12,boxSizing:"border-box",position:"relative",flexShrink:0,zIndex:0,verticalAlign:"middle","@media print":{colorAdjust:"exact"},variants:[{props:{edge:"start"},style:{marginLeft:-8}},{props:{edge:"end"},style:{marginRight:-8}},{props:{size:"small"},style:{width:40,height:24,padding:7,[`& .${De.thumb}`]:{width:16,height:16},[`& .${De.switchBase}`]:{padding:4,[`&.${De.checked}`]:{transform:"translateX(16px)"}}}}]}),Ln=n.styled$1(mt,{name:"MuiSwitch",slot:"SwitchBase",overridesResolver:(s,o)=>{const{ownerState:r}=s;return[o.switchBase,{[`& .${De.input}`]:o.input},r.color!=="default"&&o[`color${n.capitalize(r.color)}`]]}})(n.memoTheme(({theme:s})=>({position:"absolute",top:0,left:0,zIndex:1,color:s.vars?s.vars.palette.Switch.defaultColor:`${s.palette.mode==="light"?s.palette.common.white:s.palette.grey[300]}`,transition:s.transitions.create(["left","transform"],{duration:s.transitions.duration.shortest}),[`&.${De.checked}`]:{transform:"translateX(20px)"},[`&.${De.disabled}`]:{color:s.vars?s.vars.palette.Switch.defaultDisabledColor:`${s.palette.mode==="light"?s.palette.grey[100]:s.palette.grey[600]}`},[`&.${De.checked} + .${De.track}`]:{opacity:.5},[`&.${De.disabled} + .${De.track}`]:{opacity:s.vars?s.vars.opacity.switchTrackDisabled:`${s.palette.mode==="light"?.12:.2}`},[`& .${De.input}`]:{left:"-100%",width:"300%"}})),n.memoTheme(({theme:s})=>({"&:hover":{backgroundColor:s.vars?`rgba(${s.vars.palette.action.activeChannel} / ${s.vars.palette.action.hoverOpacity})`:n.alpha(s.palette.action.active,s.palette.action.hoverOpacity),"@media (hover: none)":{backgroundColor:"transparent"}},variants:[...Object.entries(s.palette).filter(us.createSimplePaletteValueFilter(["light"])).map(([o])=>({props:{color:o},style:{[`&.${De.checked}`]:{color:(s.vars||s).palette[o].main,"&:hover":{backgroundColor:s.vars?`rgba(${s.vars.palette[o].mainChannel} / ${s.vars.palette.action.hoverOpacity})`:n.alpha(s.palette[o].main,s.palette.action.hoverOpacity),"@media (hover: none)":{backgroundColor:"transparent"}},[`&.${De.disabled}`]:{color:s.vars?s.vars.palette.Switch[`${o}DisabledColor`]:`${s.palette.mode==="light"?n.lighten(s.palette[o].main,.62):n.darken(s.palette[o].main,.55)}`}},[`&.${De.checked} + .${De.track}`]:{backgroundColor:(s.vars||s).palette[o].main}}}))]}))),Mn=n.styled$1("span",{name:"MuiSwitch",slot:"Track",overridesResolver:(s,o)=>o.track})(n.memoTheme(({theme:s})=>({height:"100%",width:"100%",borderRadius:14/2,zIndex:-1,transition:s.transitions.create(["opacity","background-color"],{duration:s.transitions.duration.shortest}),backgroundColor:s.vars?s.vars.palette.common.onBackground:`${s.palette.mode==="light"?s.palette.common.black:s.palette.common.white}`,opacity:s.vars?s.vars.opacity.switchTrack:`${s.palette.mode==="light"?.38:.3}`}))),In=n.styled$1("span",{name:"MuiSwitch",slot:"Thumb",overridesResolver:(s,o)=>o.thumb})(n.memoTheme(({theme:s})=>({boxShadow:(s.vars||s).shadows[1],backgroundColor:"currentColor",width:20,height:20,borderRadius:"50%"}))),Hs=xe.forwardRef(function(o,r){const i=n.useDefaultProps({props:o,name:"MuiSwitch"}),{className:l,color:a="primary",edge:u=!1,size:c="medium",sx:y,slots:m={},slotProps:g={},...M}=i,F={...i,color:a,edge:u,size:c},R=En(F),z={slots:m,slotProps:g},[P,te]=Oe.useSlot("root",{className:n.clsx(R.root,l),elementType:Dn,externalForwardedProps:z,ownerState:F,additionalProps:{sx:y}}),[ne,p]=Oe.useSlot("thumb",{className:R.thumb,elementType:In,externalForwardedProps:z,ownerState:F}),N=e.jsx(ne,{...p}),[j,I]=Oe.useSlot("track",{className:R.track,elementType:Mn,externalForwardedProps:z,ownerState:F});return e.jsxs(P,{...te,children:[e.jsx(Ln,{type:"checkbox",icon:N,checkedIcon:N,ref:r,ownerState:F,...M,classes:{...R,root:R.switchBase},slots:{...m.switchBase&&{root:m.switchBase},...m.input&&{input:m.input}},slotProps:{...g.switchBase&&{root:typeof g.switchBase=="function"?g.switchBase(F):g.switchBase},...g.input&&{input:typeof g.input=="function"?g.input(F):g.input}}}),e.jsx(j,{...I})]})});process.env.NODE_ENV!=="production"&&(Hs.propTypes={checked:n.PropTypes.bool,checkedIcon:n.PropTypes.node,classes:n.PropTypes.object,className:n.PropTypes.string,color:n.PropTypes.oneOfType([n.PropTypes.oneOf(["default","primary","secondary","error","info","success","warning"]),n.PropTypes.string]),defaultChecked:n.PropTypes.bool,disabled:n.PropTypes.bool,disableRipple:n.PropTypes.bool,edge:n.PropTypes.oneOf(["end","start",!1]),icon:n.PropTypes.node,id:n.PropTypes.string,inputProps:n.PropTypes.object,inputRef:je.refType,onChange:n.PropTypes.func,required:n.PropTypes.bool,size:n.PropTypes.oneOfType([n.PropTypes.oneOf(["medium","small"]),n.PropTypes.string]),slotProps:n.PropTypes.shape({input:n.PropTypes.oneOfType([n.PropTypes.func,n.PropTypes.object]),root:n.PropTypes.oneOfType([n.PropTypes.func,n.PropTypes.object]),switchBase:n.PropTypes.oneOfType([n.PropTypes.func,n.PropTypes.object]),thumb:n.PropTypes.oneOfType([n.PropTypes.func,n.PropTypes.object]),track:n.PropTypes.oneOfType([n.PropTypes.func,n.PropTypes.object])}),slots:n.PropTypes.shape({input:n.PropTypes.elementType,root:n.PropTypes.elementType,switchBase:n.PropTypes.elementType,thumb:n.PropTypes.elementType,track:n.PropTypes.elementType}),sx:n.PropTypes.oneOfType([n.PropTypes.arrayOf(n.PropTypes.oneOfType([n.PropTypes.func,n.PropTypes.object,n.PropTypes.bool])),n.PropTypes.func,n.PropTypes.object]),value:n.PropTypes.any});const Rn=({option:s,config:o,onToggleGrade:r,onOpenUpgradeModal:i,forceActive:l=!1})=>{const a=!s.locked&&o.grades[s.key]||l&&!s.locked,u=s.themeColor==="purple"?t["grade-card--purple"]:s.themeColor==="green"?t["grade-card--green"]:"",y={width:52,height:30,padding:0,"& .MuiSwitch-switchBase":{padding:"3px",margin:0,transitionDuration:"250ms","&.Mui-checked":{transform:"translateX(22px)",color:"#ffffff","& + .MuiSwitch-track":{backgroundColor:`${s.themeColor==="purple"?"#9333ea":s.themeColor==="green"?"#059669":"#2563eb"} !important`,opacity:"1 !important",border:0},"&.Mui-disabled + .MuiSwitch-track":{opacity:.5}},"&.Mui-focusVisible .MuiSwitch-thumb":{color:"#ffffff",border:"6px solid #fff"}},"& .MuiSwitch-thumb":{boxSizing:"border-box",width:24,height:24,color:"#ffffff",backgroundColor:"#ffffff",boxShadow:"0 1px 3px 0 rgba(0, 0, 0, 0.15)"},"& .MuiSwitch-track":{borderRadius:30/2,backgroundColor:"#E5E7EB !important",opacity:"1 !important",transition:"background-color 250ms"}};return e.jsxs("div",{className:`${t["grade-card"]} ${u} ${s.locked?t["grade-card--locked"]:a?t["grade-card--active"]:""}`,children:[e.jsx("div",{className:t["grade-card-header"],children:s.locked?e.jsxs(e.Fragment,{children:[e.jsxs("h4",{className:t["grade-title"],children:[s.title," ",e.jsx("span",{className:t["grade-title-age"],children:s.ageInfo})]}),e.jsxs("span",{className:t["grade-badge-locked"],children:[e.jsx(kt.LockIcon,{className:t["lock-icon"]}),"Locked"]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:t["grade-title-row"],children:[e.jsxs("h4",{className:t["grade-title"],children:[s.title," ",e.jsx("span",{className:t["grade-title-age"],children:s.ageInfo})]}),a&&e.jsx("span",{className:t["grade-badge-active"],children:"ACTIVE"})]}),e.jsx(Hs,{checked:!!o.grades[s.key],onChange:()=>r(s.key),disableRipple:!0,sx:y})]})}),e.jsxs("div",{className:t["grade-tags"],children:[e.jsxs("span",{className:o.system==="US"?t["grade-tag--active"]:t["grade-tag--inactive"],children:[e.jsx(zs,{width:16,height:12,style:{marginRight:"4px"}}),s.usTag]}),e.jsxs("span",{className:o.system==="UK"?t["grade-tag--active"]:t["grade-tag--inactive"],children:[e.jsx(Gs,{width:16,height:12,style:{marginRight:"4px"}}),s.ukTag]})]}),s.locked?e.jsxs(e.Fragment,{children:[s.key==="early_years"?e.jsxs("button",{className:t["unlock-btn"],onClick:i,type:"button",children:["Unlock ",s.title," Check-ins"]}):e.jsx("div",{style:{color:"#667085",fontSize:"13px",marginTop:"12px",fontStyle:"italic"},children:"* This grade level is not active for your campus."}),s.includesText&&e.jsxs("p",{className:t["grade-includes"],children:[e.jsx("strong",{children:"Includes:"})," ",s.includesText]})]}):e.jsx("p",{className:t["grade-card-body"],children:s.description})]})},On=({config:s,onToggleGrade:o,onChangeSystem:r,onOpenUpgradeModal:i,isEarlyYearsEnabled:l,hasEsSchool:a,isAdminEs:u=!0,isAdminMs:c=!0})=>{const y=Yt.filter(M=>M.key==="early_years"||M.key==="elementary"?u:M.key==="secondary"||M.key==="middle_school"||M.key==="high_school"?c:!0),m=s.grades.middle_school||s.grades.high_school||s.grades.secondary,g=u&&(s.grades.early_years||s.grades.elementary)||c&&m;return e.jsxs("div",{className:t["step1-wrapper"],children:[e.jsxs("div",{className:t["step-card-title-block"],children:[e.jsx("h2",{className:t["step-card-title"],children:"Activate Grade Levels"}),e.jsx("p",{className:t["step-card-subtitle"],children:"Select which grade levels will use the check-in system"})]}),e.jsxs("div",{className:t["curriculum-row"],children:[e.jsx("span",{className:t["curriculum-label"],children:"Curriculum System:"}),e.jsxs("div",{className:t["system-toggle"],children:[e.jsxs("button",{className:`${t["system-btn"]} ${s.system==="US"?t["system-btn--active"]:""}`,onClick:()=>r("US"),children:[e.jsx(zs,{}),"US System (Grades)"]}),e.jsxs("button",{className:`${t["system-btn"]} ${s.system==="UK"?t["system-btn--active"]:""}`,onClick:()=>r("UK"),children:[e.jsx(Gs,{}),"UK System (Years)"]})]}),e.jsx(pt,{title:e.jsx(Tn,{}),placement:"bottom",arrow:!0,classes:{popper:t["tooltip-popper"]},PopperProps:{disablePortal:!0},children:e.jsx("button",{className:t["info-btn"],type:"button",children:"?"})})]}),e.jsxs("div",{className:t["grade-cards-list"],children:[y.map(M=>{let F=M.locked;M.key==="early_years"&&(F=!l),M.key==="elementary"&&(F=!a);const R={...M,locked:F};return e.jsx(Rn,{option:R,config:s,onToggleGrade:o,onOpenUpgradeModal:i},M.key)}),!g&&e.jsxs("div",{className:t["warning-banner"],children:[e.jsx(gn,{className:t["warning-icon"]}),e.jsx("span",{children:"Please activate at least one grade level to continue."})]})]})]})},Us=n.createSvgIcon([e.jsx("path",{d:"M12 5.99 19.53 19H4.47zM12 2 1 21h22z"},"0"),e.jsx("path",{d:"M13 16h-2v2h2zm0-6h-2v5h2z"},"1")],"WarningAmber"),Xs=s=>{if(!s)return null;const o=ze(s,["Do MMM YYYY","YYYY-MM-DD"],!0);return o.isValid()?o:null},ks=s=>({early_elementary:{label:s==="US"?"Grades 1–2 (Early Elementary)":"Years 1–2 (Key Stage 1)",emoji:"🌱"},elementary:{label:s==="US"?"Grades 3–5 (Elementary/Primary)":"Years 3–6 (Key Stage 2)",emoji:"📚"},middle_school:{label:s==="US"?"Grades 6–9 (Middle School)":"Years 7–9 (Key Stage 3)",emoji:"🔮"},high_school:{label:s==="US"?"Grades 10–12 (High School)":"Years 10–13 (Key Stage 4 & 5)",emoji:"🎓"},secondary:{label:s==="US"?"Grades 6+ (Secondary)":"Years 7+ (Key Stage 3 & 4)",emoji:"🎓"}}),$n=(s,o)=>{const r=ze(s,["YYYY-MM-DD","Do MMM YYYY"],!0),i=ze(o,["YYYY-MM-DD","Do MMM YYYY"],!0);return!r.isValid()||!i.isValid()?`${s} → ${o}`:r.year()===i.year()?`${r.format("MMM D")} → ${i.format("MMM D, YYYY")}`:`${r.format("MMM D, YYYY")} → ${i.format("MMM D, YYYY")}`},An=(s=new Date)=>ze(s).format("MMMM D, YYYY [at] hh:mm A"),Fn=(s,o)=>{if(!s.startDate||!s.endDate||!o.startDate||!o.endDate)return!1;const r=ze(s.startDate,"YYYY-MM-DD"),i=ze(s.endDate,"YYYY-MM-DD"),l=ze(o.startDate,"YYYY-MM-DD"),a=ze(o.endDate,"YYYY-MM-DD");return r.isSameOrBefore(a)&&l.isSameOrBefore(i)},Qn=s=>{const o=s.filter(r=>r.startDate&&r.endDate);for(let r=0;r<o.length;r++)for(let i=r+1;i<o.length;i++)if(Fn(o[r],o[i]))return!0;return!1},xs=s=>{const o=s.toLowerCase();return o.includes("energy")?["Exhausted","Often tired","Feeling Okay","Good energy","Bursting with energy"]:o.includes("focus")?["Always distracted","Mostly distracted","Sometimes distracted","Generally focused","Laser-focused"]:o.includes("happiness")||o.includes("happy")?["Unhappy most of the time","Unhappy some of the time","More positives than negatives","Generally happy","Optimistic and positive almost all of the time"]:Bt},Yn=(s,o,r="elementary")=>{const l=o?o[r==="early_elementary"||r==="elementary"?"es":"ms"]:void 0,a=l?.routines?.find(R=>r==="early_elementary"?R.gradeLevel===0:r==="elementary"?R.gradeLevel===1:r==="high_school"&&l.routines.some(P=>P.gradeLevel===3)?R.gradeLevel===3:R.gradeLevel===2),u=qe(s.system,r),c=s.routine[u]||(r==="middle_school"||r==="high_school"?s.routine[qe(s.system,"secondary")]:void 0),y=c?.logic==="rotated",m=new Set([...a?.coreQuestionIds||[],...a?.otherPinnedQuestionIds||[]]);let g=null;if(y&&a?.clusters)for(const R of a.clusters){if(R.title==="Custom Open Field Questions")continue;if(R.questions.some(P=>P.isFollowUp||P.statusEnable===!1?!1:!m.has(P.questionId))){g=R.title;break}}const M=!y||g==="Custom Open Field Questions",F=[];if(a&&a.clusters&&a.clusters.forEach(R=>{if(R.title==="Custom Open Field Questions")return;const z=[];R.questions.forEach(P=>{if(P.isFollowUp||P.statusEnable===!1)return;const te=m.has(P.questionId);if(y&&!te&&R.title!==g)return;const ne=(P.name||"").toLowerCase(),p=(P.responseTypeLabel||"").toLowerCase(),N=(P.type||"").toLowerCase();let j="scale";p.includes("text")||p.includes("summarize")||p.includes("open")||N.includes("text")||N.includes("summarize")||N.includes("open")||ne.includes("summarize")||ne.includes("describe")||ne.includes("tell us")||ne.includes("share")?j="text":P.type==="Emotional"||p.includes("emoji")||ne.includes("feeling")?j="emoji":p.includes("yes")||N.includes("yes")?j="yes_no":p.includes("scale")||N.includes("scale")||p.includes("slider")||N.includes("slider")||p.includes("rating")||P.answer&&P.answer.length===5&&!p.includes("mcq")?j="scale":(p.includes("mcq")||N.includes("mcq")||P.answer&&P.answer.length>0)&&(j="mcq");let I;j==="scale"&&(I=P.answer&&P.answer.length>0?P.answer:xs(P.name)),z.push({id:String(P.questionId),text:P.name||P.description,type:j,category:R.title,subName:P.subName,options:P.answer,emotions:ne.includes("feeling")||P.type==="Emotional"?P.answer:void 0,scaleLabels:I})}),z.length>0&&F.push({title:R.title,questions:z})}),F.length===0&&F.push({title:"Readiness to Learn",questions:[{id:"def_energy",text:"Energy",type:"scale",scaleLabels:xs("energy")},{id:"def_focus",text:"Focus",type:"scale",scaleLabels:xs("focus")},{id:"def_happiness",text:"Happiness",type:"scale",scaleLabels:xs("happiness")}]}),M&&c&&c.customQuestions&&c.customQuestions.length>0){const R=c.customQuestions.map(z=>({id:z.id,text:z.text,type:z.type||"text",category:"Custom Open Field Questions",options:z.options}));F.push({title:"Custom Open Field Questions",questions:R})}return F},zn=({system:s,showEarlyElementary:o,showElementary:r,showSecondary:i,showMiddleSchool:l,showHighSchool:a,activeTab:u,totalTabs:c,onTabChange:y})=>{const m=ks(s),g=q.useMemo(()=>{const F=[];return o&&F.push("early_elementary"),r&&F.push("elementary"),l&&F.push("middle_school"),a&&F.push("high_school"),!l&&!a&&i&&F.push("secondary"),F},[o,r,l,a,i]),M=m[u]||m.secondary;return e.jsxs("div",{className:t["s2-tab-bar-wrapper"],children:[e.jsx("div",{className:t["s2-tab-bar"],children:g.map((F,R)=>{const z=m[F],P=u===F;return e.jsxs("button",{className:`${t["s2-tab"]} ${P?t.active:""}`,onClick:()=>y(F),children:[e.jsxs("div",{className:t["s2-tab-header-row"],children:[e.jsx("span",{className:t["s2-tab-emoji"],children:z.emoji}),e.jsxs("span",{className:t["s2-tab-label"],children:["TAB ",R+1," of ",c]}),P&&e.jsx(ts.CheckIcon,{className:t["s2-tab-check-tick"]})]}),e.jsx("div",{className:t["s2-tab-title-row"],children:e.jsx("span",{className:t["s2-tab-text"],children:z.label})})]},F)})}),e.jsxs("div",{className:t["s2-now-editing"],children:[e.jsx("span",{className:t["s2-now-editing-emoji"],children:M.emoji}),e.jsxs("div",{className:t["s2-now-editing-wrapper"],children:[e.jsx("span",{className:t["s2-now-editing-label"],children:"NOW EDITING:"}),e.jsx("span",{className:t["s2-now-editing-text"],children:M.label})]})]})]})},Zs=({logicType:s,isActive:o,onClick:r,title:i,description:l,isRecommended:a=!1,calloutType:u,calloutTitle:c,calloutText:y,totalQuestions:m})=>{const g=`${t["s2-logic-card"]} ${s==="rotated"?t["s2-logic-card-rotated"]:""} ${o?t.active:""}`,M=`${t["s2-radio-dot"]} ${s==="rotated"?t.green:""} ${o?t.active:""}`,F=u==="green"?t["s2-callout-green"]:t["s2-callout-yellow"];return e.jsxs("div",{className:g,onClick:r,children:[e.jsxs("div",{className:t["s2-logic-card-header"],children:[e.jsx("span",{className:t["s2-logic-card-title"],children:i}),e.jsxs("div",{className:t["s2-header-right"],children:[a&&e.jsx("span",{className:t["s2-badge-recommended"],children:"RECOMMENDED"}),e.jsx("span",{className:M})]})]}),e.jsx("p",{className:t["s2-logic-card-desc"],children:l}),e.jsx("div",{className:F,children:e.jsxs("span",{className:t["s2-callout-text"],children:[e.jsxs("strong",{children:[c,":"]})," ",y]})}),m!==void 0&&e.jsxs("div",{className:t["s2-total-info"],children:["Total: ",e.jsxs("span",{className:t["s2-total-count"],children:[m," questions"]})," per session"]})]})},Gn=({logic:s,schedule:o,totalQuestions:r,onChangeLogic:i,onChangeSchedule:l,isEarlyElementary:a=!1})=>{const[u,c]=q.useState(!1),y=()=>{i("full"),o==="weekly"&&c(!0)};return e.jsxs("div",{className:t["s2-freq-card"],children:[e.jsx("h3",{className:t["s2-freq-title"],children:"Frequency Mode & Delivery Schedule"}),e.jsx("p",{className:t["s2-freq-subtitle"],children:"Choose how students receive their check-in questions and set the delivery schedule."}),e.jsx("div",{className:t["s2-logic-label"],children:"Delivery Logic"}),e.jsxs("div",{className:`${t["s2-logic-row"]} ${a?t["s2-logic-row-single"]:""}`,children:[e.jsx(Zs,{logicType:"full",isActive:a?!0:s==="full",onClick:y,title:"Full Check-in Mode",description:"Sends every active question in one single session.",calloutType:"yellow",calloutTitle:"Use Case: ",calloutText:"Best for Monthly or Quarterly comprehensive reviews.",totalQuestions:r}),!a&&e.jsx(Zs,{logicType:"rotated",isActive:s==="rotated",onClick:()=>i("rotated"),title:"Rotated Check-in Mode",description:"Questions are divided into bite-sized segments to prevent survey fatigue. The system rotates through active grade pools automatically.",isRecommended:!0,calloutType:"green",calloutTitle:"💡Pro-Tip: ",calloutText:"Sending 6 questions weekly ensures high engagement without fatigue."})]}),e.jsx("div",{className:t["s2-schedule-label"],children:"Delivery Schedule"}),e.jsx("div",{className:t["s2-schedule-pills"],children:["weekly","biweekly","monthly"].map(m=>e.jsx("button",{className:`${t["s2-schedule-pill"]} ${o===m?t.active:""}`,onClick:()=>{l(m),m==="weekly"&&s==="full"&&c(!0)},children:m==="weekly"?"Weekly":m==="biweekly"?"Bi-weekly":"Monthly"},m))}),e.jsx(Pe.Snackbar,{open:u,autoHideDuration:7e3,onClose:()=>c(!1),anchorOrigin:{vertical:"top",horizontal:"center"},children:e.jsx(Pe.Alert,{onClose:()=>c(!1),severity:"warning",variant:"filled",sx:{width:"100%",fontSize:16},children:"Sending 26 questions weekly might severely increase student survey fatigue. Consider shifting to Rotated Scaffolding Mode or a Monthly schedule."})})]})},Hn=({coreQuestions:s,otherQuestions:o,gradeRange:r,onUnpin:i})=>{const l=r==="elementary"?"Core Questions":"Safety & Stress",a=u=>u.length===0?e.jsx("div",{className:t["s2-core-empty-message"],children:"No questions pinned yet. Pin questions from clusters below to add them here."}):e.jsx("div",{className:t["s2-core-cards-grid"],children:u.map((c,y)=>e.jsxs("div",{className:t["s2-core-card"],children:[e.jsxs("div",{className:t["s2-core-card-top"],children:[e.jsx("span",{className:t["s2-core-card-title"],children:c.shortTitle}),e.jsxs("span",{className:t["s2-badge-pinned"],onClick:()=>c.kpiLabel!=="Emotional State"&&c.id&&i?.(c.id),style:c.kpiLabel!=="Emotional State"&&i?{cursor:"pointer"}:void 0,children:[e.jsx("img",{src:"/images/check-in-setup/pinned.svg",alt:"Pinned"})," Pinned"]})]}),c.emotions&&e.jsxs("div",{className:t["s2-core-card-emotions"],children:[e.jsx("span",{className:t["s2-emotions-label"],children:"Emotions:"}),c.emotions.map((m,g)=>e.jsx("span",{className:t["s2-emotion-item"],children:m},g))]}),!c.emotions&&(r==="elementary"&&c.subName||c.fullText&&c.fullText.trim()!==""&&c.fullText.trim()!==c.shortTitle?.trim())&&e.jsx("div",{className:c.shortTitle?.includes("ready to learn")?t["s2-core-card-followup"]:t["s2-core-card-text"],children:r==="elementary"&&c.subName?c.subName:c.fullText}),!c.emotions&&!(r==="secondary"&&(c.shortTitle==="Safety"||c.shortTitle==="Stress"||c.shortTitle==="Resilience"))&&e.jsxs("div",{className:t["s2-core-card-response"],children:["Response: ",c.responseType]}),e.jsxs("div",{className:t["s2-core-card-kpi"],children:["KPI: ",c.kpiLabel]})]},y))});return e.jsxs("div",{className:t["s2-core-section"],children:[e.jsxs("div",{className:t["s2-core-header"],children:[e.jsx("h3",{className:t["s2-core-title"],children:"Core Questions (Always Show)"}),e.jsx("span",{className:t["s2-badge-pink"],children:"Pinned questions appear in every check-in"})]}),e.jsxs("div",{className:t["s2-core-subheader"],children:[e.jsx("img",{src:"/images/check-in-setup/core.svg",alt:"Core Icon"}),e.jsx("span",{className:t["s2-core-subtitle"],children:l}),e.jsxs("span",{className:t["s2-badge-red"],children:[s.length," questions"]})]}),a(s),o.length>0&&e.jsxs("div",{style:{marginTop:"24px"},children:[e.jsxs("div",{className:t["s2-core-subheader"],style:{paddingLeft:0},children:[e.jsx("span",{className:t["s2-core-subtitle"],children:"Other Pinned Questions"}),e.jsxs("span",{className:t["s2-badge-red"],children:[o.length," questions"]})]}),a(o)]}),e.jsxs("div",{className:t["s2-core-info-banner"],children:[e.jsx("strong",{children:"📌 Core Questions:"})," Pinned questions appear in EVERY check-in session. Unpin a question to move it back to its cluster."]})]})},Un=n.createSvgIcon(e.jsx("path",{d:"M3 17.25V21h3.75L17.81 9.94l-3.75-3.75zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34a.996.996 0 0 0-1.41 0l-1.83 1.83 3.75 3.75z"}),"Edit"),qn=({open:s,onClose:o,onConfirm:r,questionTitle:i,kpiLabel:l})=>e.jsxs(Pe.Dialog,{open:s,onClose:o,disableEnforceFocus:!0,disableRestoreFocus:!0,PaperProps:{className:t["s2-modal-container"]},children:[e.jsx(Pe.IconButton,{onClick:o,className:t["s2-modal-close-btn"],children:e.jsx(ns.CloseIcon,{style:{fontSize:18}})}),e.jsxs("div",{className:t["s2-modal-header"],children:[e.jsx("div",{className:t["s2-modal-warning-icon-wrapper"],children:e.jsx(Us,{style:{fontSize:32}})}),e.jsx("h4",{className:t["s2-modal-title"],children:"Disable KPI Question?"}),e.jsx("p",{className:t["s2-modal-subtitle"],children:"This is a KPI question that tracks important student data"})]}),e.jsxs("div",{className:t["s2-modal-body-card"],children:[e.jsxs("div",{className:t["s2-modal-info-item"],children:[e.jsx("span",{className:t["info-label"],children:"Question:"}),e.jsx("span",{className:t["info-value"],children:i})]}),e.jsxs("div",{className:t["s2-modal-info-item"],children:[e.jsx("span",{className:t["info-label"],children:"KPI:"}),e.jsx("span",{className:t["info-value"],children:l})]}),e.jsx("div",{className:t["s2-modal-divider"]}),e.jsxs("div",{className:t["s2-modal-warning-msg"],children:[e.jsx("strong",{children:"⚠️ Warning:"}),e.jsxs("div",{children:["If you disable this question, ",e.jsx("strong",{children:"the data will not show anymore on the dashboard"}),". Students will no longer be asked this question during check-ins."]})]})]}),e.jsxs("div",{className:t["s2-modal-footer"],children:[e.jsx("button",{className:t["s2-btn-cancel"],onClick:o,children:"Cancel"}),e.jsx("button",{className:t["s2-btn-disable"],onClick:r,children:"Disable Question"})]})]}),Bn=({open:s,onClose:o,onConfirm:r,questionTitle:i,isPinned:l=!1})=>e.jsxs(Pe.Dialog,{open:s,onClose:o,disableEnforceFocus:!0,disableRestoreFocus:!0,PaperProps:{className:t["s2-modal-container"]},children:[e.jsx(Pe.IconButton,{onClick:o,className:t["s2-modal-close-btn"],children:e.jsx(ns.CloseIcon,{style:{fontSize:18}})}),e.jsxs("div",{className:t["s2-modal-header"],children:[e.jsx("div",{className:t["s2-modal-warning-icon-wrapper"],children:e.jsx(Us,{style:{fontSize:32}})}),e.jsx("h4",{className:t["s2-modal-title"],children:"Delete Custom Question?"}),e.jsx("p",{className:t["s2-modal-subtitle"],children:"Are you sure you want to delete this custom question? This action cannot be undone."})]}),e.jsxs("div",{className:t["s2-modal-body-card"],children:[e.jsxs("div",{className:t["s2-modal-info-item"],children:[e.jsx("span",{className:t["info-label"],children:"Question:"}),e.jsx("span",{className:t["info-value"],children:i})]}),l&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:t["s2-modal-divider"]}),e.jsxs("div",{className:t["s2-modal-warning-msg"],children:[e.jsx("strong",{children:"⚠️ Pinned Question Warning: "}),e.jsx("div",{children:"This question is currently pinned to routine check-in. Deleting it will also remove it from pinned questions across all grade levels."})]})]})]}),e.jsxs("div",{className:t["s2-modal-footer"],children:[e.jsx("button",{type:"button",className:t["s2-btn-cancel"],onClick:o,children:"Cancel"}),e.jsx("button",{type:"button",className:t["s2-btn-delete"],onClick:r,children:"Delete Question"})]})]}),Vn=({question:s,system:o,gradeRange:r,isEarlyYearsEnabled:i,onSave:l,onCancel:a})=>{const{getLabel:u,system:c,showBracket:y}=fe.useGradeLabel(),m=(o||c)==="UK"?"UK":"US",g=q.useMemo(()=>{const Y=Ys(r,i);if(s.selectedGrades&&s.selectedGrades.length>0){const B=[...Y];for(const w of s.selectedGrades)B.includes(w)||B.push(w);return B.sort((w,J)=>w-J)}return Y},[r,i,s.selectedGrades]),[M,F]=q.useState(s.text),[R,z]=q.useState(s.selectedGrades&&s.selectedGrades.length>0?s.selectedGrades:g),[P,te]=q.useState(Xs(s.startDate)),[ne,p]=q.useState(Xs(s.endDate)),[N,j]=q.useState(!!(s.startDate||s.endDate)),I=Y=>{z(B=>B.includes(Y)?B.filter(w=>w!==Y):[...B,Y])},A=()=>{z(g)},Q=()=>{z([])},ce=M.trim()!==""&&R.length>0,ge=()=>{ce&&l(M,R,P?P.format("YYYY-MM-DD"):void 0,ne?ne.format("YYYY-MM-DD"):void 0)};return e.jsxs("div",{className:t["s2-creator-form"],style:{border:"2px solid #2F68D0",padding:"24px",borderRadius:"12px",backgroundColor:"#FFFFFF",marginBottom:"16px"},children:[e.jsxs("div",{className:t["s2-creator-input-wrapper"],children:[e.jsx("div",{className:t["s2-creator-label"],children:"Question Text"}),e.jsx("input",{type:"text",className:t["s2-creator-input"],placeholder:"Enter your custom question...",value:M,onChange:Y=>F(Y.target.value)})]}),e.jsxs("div",{className:t["s2-creator-input-wrapper"],children:[e.jsxs("div",{className:t["s2-creator-label"],children:["Select ",m==="UK"?"Year Groups":"Grades"]}),e.jsxs("div",{className:t["s2-grades-selector-box"],children:[e.jsxs("div",{className:t["s2-grades-selector-actions"],children:[e.jsx("button",{type:"button",className:g.length>0&&R.length===g.length&&g.every(Y=>R.includes(Y))?t.active:t.inactive,onClick:A,children:"Select All"}),e.jsx("button",{type:"button",className:R.length===0?t.active:t.inactive,onClick:Q,children:"Clear All"})]}),e.jsx("div",{className:t["s2-grades-grid"],children:g.map(Y=>{const B=R.includes(Y),w=m==="UK"?u(Y,{system:"UK",showBracket:!1}):`Grade ${Y}`,J=y?u(Y,{system:m,showBracket:!0}):void 0;return e.jsx("button",{type:"button",className:`${t["s2-grade-btn"]} ${B?t.selected:""}`,onClick:()=>I(Y),title:J,children:w},Y)})}),R.length===0?e.jsxs("div",{className:t["s2-grades-warning"],children:["Please select at least one ",m==="UK"?"year group":"grade"]}):e.jsxs("div",{className:t["s2-grades-selected-summary"],children:["✓ Selected: ",R.slice().sort((Y,B)=>Y-B).map(Y=>u(Y,{system:m,showBracket:y})).join(", ")]})]})]}),e.jsxs("div",{className:t["s2-creator-input-wrapper"],children:[e.jsx("div",{className:t["s2-creator-label"],children:"Schedule for Specific Date Range (Optional)"}),e.jsxs("div",{className:t["s2-schedule-date-box"],onMouseEnter:()=>j(!0),onClick:()=>j(!0),children:[N?e.jsxs("div",{className:t["s2-date-inputs-row"],style:{display:"flex",gap:"16px"},children:[e.jsxs("div",{className:t["s2-date-input-group"],style:{flex:1},children:[e.jsx("label",{style:{display:"block",marginBottom:"8px",fontSize:"13px",color:"#344054",fontWeight:500},children:"Start Date"}),e.jsx(We.DatePicker,{value:P,onChange:te,format:"MM/DD/YYYY",slotProps:{textField:{fullWidth:!0,variant:"outlined",InputProps:{style:{height:48,borderRadius:"8px"}}}}})]}),e.jsxs("div",{className:t["s2-date-input-group"],style:{flex:1},children:[e.jsx("label",{style:{display:"block",marginBottom:"8px",fontSize:"13px",color:"#344054",fontWeight:500},children:"End Date"}),e.jsx(We.DatePicker,{value:ne,onChange:p,minDate:P||void 0,format:"MM/DD/YYYY",slotProps:{textField:{fullWidth:!0,variant:"outlined",InputProps:{style:{height:48,borderRadius:"8px"}}}}})]})]}):e.jsxs("div",{style:{display:"flex",gap:"16px"},children:[e.jsxs("div",{style:{flex:1},children:[e.jsx("label",{style:{display:"block",marginBottom:"8px",fontSize:"13px",color:"#344054",fontWeight:500},children:"Start Date"}),e.jsx("div",{style:{height:"48px",border:"1px solid #D0D5DD",borderRadius:"8px",backgroundColor:"#F9FAFB",cursor:"pointer",display:"flex",alignItems:"center",paddingLeft:"14px",color:"#667085",fontSize:"14px"},children:"Select start date..."})]}),e.jsxs("div",{style:{flex:1},children:[e.jsx("label",{style:{display:"block",marginBottom:"8px",fontSize:"13px",color:"#344054",fontWeight:500},children:"End Date"}),e.jsx("div",{style:{height:"48px",border:"1px solid #D0D5DD",borderRadius:"8px",backgroundColor:"#F9FAFB",cursor:"pointer",display:"flex",alignItems:"center",paddingLeft:"14px",color:"#667085",fontSize:"14px"},children:"Select end date..."})]})]}),e.jsx("div",{className:t["s2-schedule-helper-text"],style:{marginTop:"12px"},children:"Leave blank for questions that rotate weekly, or select a date range for one-time questions (e.g., holidays, events)."})]})]}),e.jsxs("div",{className:t["s2-creator-actions"],children:[e.jsx("button",{type:"button",className:`${t["btn-primary"]} ${ce?t.active:""}`,disabled:!ce,onClick:ge,children:"Save Changes"}),e.jsx("button",{type:"button",className:t["btn-secondary"],onClick:a,children:"Cancel"})]})]})},Es=s=>{if(!s)return"";if(!s.includes("&"))return s;try{const o=document.createElement("textarea");return o.innerHTML=s,o.value}catch{return s}},et=({cluster:s,pinnedIds:o,system:r,gradeRange:i,isEarlyYearsEnabled:l,onTogglePin:a,onToggleEnable:u,onRemoveCustomQuestion:c,onEditCustomQuestion:y})=>{const{getLabel:m,system:g}=fe.useGradeLabel(),M=(r||g)==="UK"?"UK":"US",{attributes:F,listeners:R,setNodeRef:z,transform:P,transition:te,isDragging:ne}=vs.useSortable({id:s.title,disabled:!!s.isCustomCluster}),[p,N]=q.useState(null),[j,I]=q.useState(null),[A,Q]=q.useState(null),ce=B=>{B.statusEnable!==!1?I({id:B.id||"",title:B.title,kpiLabel:B.kpiLabel}):u(B.id||B.title)},ge=()=>{j&&(u(j.id||j.title),I(null))},Y={transform:Pt.CSS.Transform.toString(P),transition:ne?"none":te,zIndex:ne?100:0,position:"relative"};if(s.isCustomCluster){const B=s.customQuestionItems||[];return e.jsxs("div",{ref:z,className:`${t["s2-custom-cluster-box"]} ${ne?t.dragging:""}`,style:{...Y,borderColor:s.color,backgroundColor:s.backgroundColor},children:[e.jsxs("div",{className:t["s2-custom-cluster-header"],children:[e.jsxs("div",{className:t["s2-custom-cluster-header-left"],children:[e.jsx("span",{className:t["s2-custom-cluster-grip"],children:"⠿"}),e.jsx("span",{className:t["s2-custom-cluster-number"],style:{backgroundColor:s.color},children:s.number}),e.jsxs("div",{className:t["s2-custom-cluster-info"],children:[e.jsx("span",{className:t["s2-custom-cluster-title"],children:s.title}),e.jsxs("span",{className:t["s2-custom-cluster-count"],children:[B.length," question",B.length!==1?"s":""]})]})]}),e.jsxs("span",{className:t["s2-custom-cluster-badge"],style:{borderColor:s.color,color:s.color},children:["Cluster ",s.number]})]}),e.jsxs("div",{className:t["s2-custom-cluster-banner"],style:{borderColor:s.color},children:[e.jsx("span",{className:t["s2-banner-icon"],children:"🔁"}),e.jsxs("span",{children:[e.jsx("strong",{children:"Rotates Weekly:"})," Questions without a scheduled date range appear in your regular check-in rotation. Questions with a scheduled date range appear only during that specific period."]})]}),e.jsx("div",{className:t["s2-custom-cluster-list"],children:B.map(w=>{if(w.id===p)return e.jsx(Vn,{question:w,system:M,gradeRange:i,isEarlyYearsEnabled:l,onSave:(W,se,X,H)=>{y(w.id,W,se,X,H),N(null)},onCancel:()=>N(null)},w.id);const J=Ys(i,l),ee=!w.selectedGrades||w.selectedGrades.length===0||J.length>0&&J.every(W=>w.selectedGrades?.includes(W))?M==="UK"?"All Year Groups":"All Grades":(w.selectedGrades||[]).slice().sort((W,se)=>W-se).map(W=>m(W,{system:M,showBracket:!1})).join(", "),f=o.includes(w.id),$=w.id.startsWith("custom_");return e.jsxs("div",{className:t["s2-custom-cluster-row"],children:[e.jsxs("div",{className:t["s2-custom-cluster-row-left"],children:[e.jsxs("div",{className:t["s2-custom-cluster-row-top"],children:[e.jsx("span",{className:t["s2-custom-cluster-row-text"],children:Es(w.text)}),$?e.jsx(Pe.Tooltip,{title:"Please save check-in setup before pinning this question",arrow:!0,placement:"top",slotProps:{tooltip:{sx:{fontSize:"14px"}}},children:e.jsxs("span",{className:t["s2-badge-pin-disabled"],children:[e.jsx("img",{src:"/images/check-in-setup/pin-to-core.svg",alt:"Pin to Core"})," Pin to Core"]})}):f?e.jsxs("span",{className:t["s2-badge-pinned-sm"],onClick:()=>a(w.id),style:{cursor:"pointer"},children:[e.jsx("img",{src:"/images/check-in-setup/pinned.svg",alt:"Pinned"})," Pinned"]}):e.jsxs("span",{className:t["s2-badge-pin-to-core"],onClick:()=>a(w.id),style:{cursor:"pointer"},children:[e.jsx("img",{src:"/images/check-in-setup/pin-to-core.svg",alt:"Pin to Core"})," Pin to Core"]})]}),e.jsxs("div",{className:t["s2-custom-cluster-row-tags"],children:[e.jsx("span",{className:t["s2-custom-tag-format"],children:"Open Text"}),e.jsx("span",{className:t["s2-custom-tag-grades"],style:{background:s.color},children:ee}),w.startDate&&w.endDate?e.jsxs("span",{className:t["s2-custom-tag-schedule-range"],children:[e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",ry:"2"}),e.jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),e.jsx("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),e.jsx("line",{x1:"3",y1:"10",x2:"21",y2:"10"})]}),$n(w.startDate,w.endDate)]}):e.jsx("span",{className:t["s2-custom-tag-schedule-weekly"],children:"Weekly Rotation"})]})]}),e.jsxs("div",{className:t["s2-custom-cluster-row-right"],children:[e.jsx("button",{className:t["s2-custom-cluster-edit-btn"],onClick:()=>N(w.id),children:e.jsx(Un,{style:{fontSize:18}})}),e.jsx("button",{className:t["s2-custom-cluster-delete-btn"],onClick:()=>Q({id:w.id,title:w.text,isPinned:f}),children:e.jsx(ns.CloseIcon,{style:{fontSize:18}})})]})]},w.id)})}),e.jsx(Bn,{open:A!==null,onClose:()=>Q(null),onConfirm:()=>{A&&(c(A.id),Q(null))},questionTitle:A?.title||"",isPinned:A?.isPinned||!1})]})}return e.jsxs("div",{ref:z,className:`${t["s2-cluster-item"]} ${ne?t.dragging:""}`,style:{...Y,borderColor:s.color},children:[e.jsxs("div",{className:t["s2-cluster-item-header"],children:[e.jsxs("div",{className:t["s2-cluster-item-left"],children:[e.jsx("span",{className:t["s2-cluster-grip"],...F,...R,children:"⠿"}),e.jsx("span",{className:t["s2-cluster-number"],style:{backgroundColor:s.color},children:s.number}),e.jsxs("div",{className:t["s2-cluster-item-info"],children:[e.jsx("span",{className:t["s2-cluster-item-title"],children:s.title}),e.jsxs("span",{className:t["s2-cluster-item-count"],children:[s.questions.length," question",s.questions.length!==1?"s":""]})]})]}),e.jsxs("span",{className:t["s2-cluster-badge"],style:{borderColor:s.color,color:s.color},children:["Cluster ",s.number]})]}),e.jsx("div",{className:t["s2-cluster-questions"],children:s.questions.map((B,w)=>{const J=B.id||B.title,me=o.includes(J),ee=B.statusEnable!==!1,f=`${t["s2-cluster-q-row"]} ${ee?"":t.disabled}`;return e.jsxs("div",{className:f,children:[e.jsx("div",{className:t["s2-cluster-q-left"],children:e.jsxs("div",{className:t["s2-cluster-q-text-group"],children:[e.jsxs("div",{className:t["s2-cluster-q-top-row"],children:[e.jsx("span",{className:t["s2-cluster-q-title"],children:B.title}),me?e.jsxs("span",{className:t["s2-badge-pinned-sm"],onClick:()=>a(J),style:{cursor:"pointer"},children:[e.jsx("img",{src:"/images/check-in-setup/pinned.svg",alt:"Pinned"})," Pinned"]}):e.jsxs("span",{className:t["s2-badge-pin-to-core"],onClick:()=>a(J),style:{cursor:"pointer"},children:[e.jsx("img",{src:"/images/check-in-setup/pin-to-core.svg",alt:"Pin to Core"})," Pin to Core"]}),e.jsxs("div",{className:t["s2-checkbox-container"],onClick:()=>ce(B),children:[e.jsx("span",{className:`${t["s2-custom-checkbox"]} ${ee?t.checked:""}`,style:ee?{backgroundColor:s.color,borderColor:s.color}:{borderColor:"#D0D5DD"},children:ee&&e.jsx(ts.CheckIcon,{style:{fontSize:11,color:"#ffffff"}})}),e.jsx("span",{className:t["s2-checkbox-label"],style:{color:ee?s.color:"#98A2B3"},children:ee?"Enabled":"Disabled"})]})]}),B.subName&&e.jsx("div",{className:t["s2-cluster-q-desc"],children:Es(B.subName)}),e.jsx("div",{className:t["s2-cluster-q-desc"],style:B.title.toLowerCase().includes("ready to learn")||B.title.toLowerCase().includes("best learning")?{color:"#D97706",fontWeight:600}:void 0,children:Es(B.text)})]})}),e.jsxs("div",{className:t["s2-cluster-q-right"],children:[e.jsx("span",{className:t["s2-kpi-tag"],style:ee?{borderColor:s.color,color:s.color,backgroundColor:s.backgroundColor}:{},children:B.kpiLabel}),e.jsx("span",{className:t["s2-cluster-q-type"],children:B.responseType})]})]},w)})}),e.jsx(qn,{open:j!==null,onClose:()=>I(null),onConfirm:ge,questionTitle:j?.title||"",kpiLabel:j?.kpiLabel||""})]})},Wn=({clusters:s,pinnedIds:o,system:r,gradeRange:i,isEarlyYearsEnabled:l,onTogglePin:a,onToggleEnable:u,onRemoveCustomQuestion:c,onEditCustomQuestion:y,onReorderClusters:m})=>{const g=s.filter(N=>!N.isCustomCluster),M=g.map(N=>`${N.title}:${N.questions.map(j=>`${j.id??j.title}:${j.statusEnable!==!1}:${j.isPinned}`).join("|")}`).join(","),[F,R]=q.useState(M),[z,P]=q.useState(g);M!==F&&(R(M),P(g));const te=os.useSensors(os.useSensor(os.PointerSensor,{activationConstraint:{distance:5}})),ne=N=>{const{active:j,over:I}=N;if(!I||j.id===I.id)return;const A=z.findIndex(ge=>ge.title===j.id),Q=z.findIndex(ge=>ge.title===I.id);if(A<0||Q<0)return;const ce=vs.arrayMove(z,A,Q);P(ce),m(ce.map(ge=>ge.title))},p=s.find(N=>N.isCustomCluster);return e.jsxs("div",{className:t["s2-cluster-section"],children:[e.jsxs("div",{className:t["s2-cluster-header"],children:[e.jsx("span",{className:t["s2-cluster-drag-icon"],children:"⠿"}),e.jsx("h3",{className:t["s2-cluster-title"],children:"Cluster Questions"}),e.jsx("span",{className:t["s2-badge-blue"],children:"Pin questions to include • Drag to reorder clusters"})]}),e.jsx(os.DndContext,{sensors:te,collisionDetection:os.rectIntersection,onDragEnd:ne,children:e.jsx(vs.SortableContext,{items:z.map(N=>N.title),strategy:vs.verticalListSortingStrategy,children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:z.map((N,j)=>e.jsx(et,{cluster:{...N,number:j+1},pinnedIds:o,system:r,gradeRange:i,isEarlyYearsEnabled:l,onTogglePin:a,onToggleEnable:u,onRemoveCustomQuestion:c,onEditCustomQuestion:y},N.title))})})}),p&&e.jsx("div",{style:{marginTop:"16px"},children:e.jsx(et,{cluster:{...p,number:z.length+1},pinnedIds:o,system:r,gradeRange:i,isEarlyYearsEnabled:l,onTogglePin:a,onToggleEnable:u,onRemoveCustomQuestion:c,onEditCustomQuestion:y})})]})},ht=q.memo(({startDate:s,endDate:o,onChangeStartDate:r,onChangeEndDate:i})=>e.jsxs("div",{className:t["s2-date-inputs-row"],style:{display:"flex",gap:"16px"},children:[e.jsxs("div",{className:t["s2-date-input-group"],style:{flex:1},children:[e.jsx("label",{style:{display:"block",marginBottom:"8px",fontSize:"13px",color:"#344054",fontWeight:500},children:"Start Date"}),e.jsx(We.DatePicker,{value:s,onChange:r,format:"MM/DD/YYYY",slotProps:{textField:{fullWidth:!0,variant:"outlined",InputProps:{style:{height:48,borderRadius:"8px"}}}}})]}),e.jsxs("div",{className:t["s2-date-input-group"],style:{flex:1},children:[e.jsx("label",{style:{display:"block",marginBottom:"8px",fontSize:"13px",color:"#344054",fontWeight:500},children:"End Date"}),e.jsx(We.DatePicker,{value:o,onChange:i,minDate:s||void 0,format:"MM/DD/YYYY",slotProps:{textField:{fullWidth:!0,variant:"outlined",InputProps:{style:{height:48,borderRadius:"8px"}}}}})]})]}),(s,o)=>{const r=s.startDate===o.startDate||s.startDate&&o.startDate&&s.startDate.isSame(o.startDate,"day"),i=s.endDate===o.endDate||s.endDate&&o.endDate&&s.endDate.isSame(o.endDate,"day");return!!(r&&i)});ht.displayName="MemoizedDateRangePicker";const Jn=({gradeRange:s,system:o,isEarlyYearsEnabled:r,onAddCustomQuestion:i})=>{const{getLabel:l,system:a,showBracket:u}=fe.useGradeLabel(),c=(o||a)==="UK"?"UK":"US",y=q.useMemo(()=>Ys(s,r),[s,r]),[m,g]=q.useState(!1),[M,F]=q.useState(""),[R,z]=q.useState([]),[P,te]=q.useState(null),[ne,p]=q.useState(null),[N,j]=q.useState(!1),I=()=>{z(y),g(!0)},A=w=>{z(J=>J.includes(w)?J.filter(me=>me!==w):[...J,w])},Q=()=>{M.trim()&&R.length>0&&(i(s,M,"text",R,P?P.format("YYYY-MM-DD"):void 0,ne?ne.format("YYYY-MM-DD"):void 0),F(""),z(y),te(null),p(null),j(!1),g(!1))},ce=()=>{z(y)},ge=()=>{z([])},Y=()=>{F(""),z(y),te(null),p(null),j(!1),g(!1)},B=M.trim()!==""&&R.length>0;return e.jsxs("div",{className:t["s2-custom-section"],children:[e.jsxs("div",{className:t["s2-custom-header"],children:[e.jsx("h3",{className:t["s2-custom-title"],children:"Custom Open Field Questions"}),e.jsx("span",{className:t["s2-badge-blue"],children:"Routine • Rotates Weekly"})]}),e.jsxs("div",{className:t["s2-custom-info-card"],children:[e.jsx("span",{className:t["s2-info-icon-left"],children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"#2F68D0",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"12",x2:"12",y1:"8",y2:"12"}),e.jsx("line",{x1:"12",x2:"12.01",y1:"16",y2:"16"})]})}),e.jsxs("div",{className:t["s2-info-content-right"],children:[e.jsxs("div",{className:t["s2-custom-info-header"],children:[e.jsx("span",{className:t["s2-info-emoji"],children:"🗓️"}),e.jsx("span",{className:t["s2-info-title"],children:"How Routine Questions Work"})]}),e.jsxs("p",{className:t["s2-custom-info-text"],children:["Questions in the ",e.jsx("strong",{children:"Open Field cluster"})," (including your custom questions) will ",e.jsx("strong",{children:"rotate weekly"})," as part of your regular check-in schedule. They appear in every check-in cycle alongside other cluster questions."]}),e.jsxs("div",{className:t["s2-custom-info-tip"],children:[e.jsxs("div",{className:t["s2-tip-header-row"],children:[e.jsx("span",{className:t["s2-tip-emoji"],children:"💡"}),e.jsx("span",{className:t["s2-tip-title"],children:"Need questions for specific dates?"})]}),e.jsxs("p",{className:t["s2-tip-desc"],children:["When adding a custom question, you can optionally schedule it for a ",e.jsx("strong",{children:"specific date range"})," (e.g., holidays, events, special occasions). Questions without a scheduled date range will rotate weekly."]})]})]})]}),m?e.jsxs("div",{className:t["s2-creator-form"],children:[e.jsxs("div",{className:t["s2-creator-input-wrapper"],children:[e.jsx("div",{className:t["s2-creator-label"],children:"Question Text"}),e.jsx("input",{type:"text",className:t["s2-creator-input"],placeholder:"Enter your custom question...",value:M,onChange:w=>F(w.target.value)})]}),e.jsxs("div",{className:t["s2-creator-input-wrapper"],children:[e.jsxs("div",{className:t["s2-creator-label"],children:["Select ",c==="UK"?"Year Groups":"Grades"]}),e.jsxs("div",{className:t["s2-grades-selector-box"],children:[e.jsxs("div",{className:t["s2-grades-selector-actions"],children:[e.jsx("button",{type:"button",className:y.length>0&&R.length===y.length&&y.every(w=>R.includes(w))?t.active:t.inactive,onClick:ce,children:"Select All"}),e.jsx("button",{type:"button",className:R.length===0?t.active:t.inactive,onClick:ge,children:"Clear All"})]}),e.jsx("div",{className:t["s2-grades-grid"],children:y.map(w=>{const J=R.includes(w),me=c==="UK"?l(w,{system:"UK",showBracket:!1}):`Grade ${w}`,ee=u?l(w,{system:c,showBracket:!0}):void 0;return e.jsx("button",{type:"button",className:`${t["s2-grade-btn"]} ${J?t.selected:""}`,onClick:()=>A(w),title:ee,children:me},w)})}),R.length===0?e.jsxs("div",{className:t["s2-grades-warning"],children:["Please select at least one ",c==="UK"?"year group":"grade"]}):e.jsxs("div",{className:t["s2-grades-selected-summary"],children:["✓ Selected: ",R.slice().sort((w,J)=>w-J).map(w=>l(w,{system:c,showBracket:u})).join(", ")]})]})]}),e.jsxs("div",{className:t["s2-creator-input-wrapper"],children:[e.jsx("div",{className:t["s2-creator-label"],children:"Schedule for Specific Date Range (Optional)"}),e.jsxs("div",{className:t["s2-schedule-date-box"],onMouseEnter:()=>j(!0),onClick:()=>j(!0),children:[N?e.jsx(ht,{startDate:P,endDate:ne,onChangeStartDate:te,onChangeEndDate:p}):e.jsxs("div",{style:{display:"flex",gap:"16px"},children:[e.jsxs("div",{style:{flex:1},children:[e.jsx("label",{style:{display:"block",marginBottom:"8px",fontSize:"13px",color:"#344054",fontWeight:500},children:"Start Date"}),e.jsx("div",{style:{height:"48px",border:"1px solid #D0D5DD",borderRadius:"8px",backgroundColor:"#F9FAFB",cursor:"pointer",display:"flex",alignItems:"center",paddingLeft:"14px",color:"#667085",fontSize:"14px"},children:"Select start date..."})]}),e.jsxs("div",{style:{flex:1},children:[e.jsx("label",{style:{display:"block",marginBottom:"8px",fontSize:"13px",color:"#344054",fontWeight:500},children:"End Date"}),e.jsx("div",{style:{height:"48px",border:"1px solid #D0D5DD",borderRadius:"8px",backgroundColor:"#F9FAFB",cursor:"pointer",display:"flex",alignItems:"center",paddingLeft:"14px",color:"#667085",fontSize:"14px"},children:"Select end date..."})]})]}),e.jsx("div",{className:t["s2-schedule-helper-text"],style:{marginTop:"12px"},children:"Leave blank for questions that rotate weekly, or select a date range for one-time questions (e.g., holidays, events)."})]})]}),e.jsxs("div",{className:t["s2-creator-actions"],children:[e.jsx("button",{type:"button",className:`${t["btn-primary"]} ${B?t.active:""}`,disabled:!B,onClick:Q,children:"Add Question"}),e.jsx("button",{type:"button",className:t["btn-secondary"],onClick:Y,children:"Cancel"})]})]}):e.jsxs("button",{className:t["s2-add-custom-btn"],onClick:I,children:[e.jsx(Nt.AddIcon,{fontSize:"large"})," Add Custom Question"]})]})},Kn=({config:s,onChangeRoutineLogic:o,onChangeRoutineSchedule:r,onAddCustomQuestion:i,onRemoveCustomQuestion:l,onEditCustomQuestion:a,checkInQuestionsMap:u,activeTab:c,onTabChange:y,onToggleQuestionPin:m,onToggleQuestionEnable:g,onReorderClusters:M,isAdminEs:F=!0,isAdminMs:R=!0})=>{const z=F&&s.grades.early_years,P=F&&s.grades.elementary,te=R&&s.grades.middle_school,ne=R&&s.grades.high_school,p=R&&!te&&!ne&&s.grades.secondary,N=(z?1:0)+(P?1:0)+(te?1:0)+(ne?1:0)+(p?1:0),j=c==="early_elementary"||c==="elementary"?"es":"ms",I=u[j],A=q.useMemo(()=>{if(I?.routines){if(c==="early_elementary")return I.routines.find(k=>k.gradeLevel===0);if(c==="elementary")return I.routines.find(k=>k.gradeLevel===1);if(c==="high_school"){const k=I.routines.find(V=>V.gradeLevel===3);if(k)return k}return I.routines.find(k=>k.gradeLevel===2)}},[I,c]),Q=q.useMemo(()=>A?[...A.coreQuestionIds,...A.otherPinnedQuestionIds].map(V=>String(V)):[],[A]),ce=q.useCallback(k=>k?k.clusters.map((V,he)=>{const de=zt[V.title]||{color:"#316cd9",backgroundColor:"#316cd920"};return{number:V.order||he+1,title:V.title,color:de.color,backgroundColor:de.backgroundColor,isCustomCluster:V.isCustomCluster,questions:V.questions.filter(ue=>!(ue.isFollowUp||c==="elementary"&&ue.type==="Emotional")).map(ue=>{const _e=ue.name,Me=(_e||"").toLowerCase(),Le=ue.kpiLabel||V.title,we=ue.responseTypeLabel;return{id:String(ue.questionId),title:_e,text:ue.description,isPinned:k.coreQuestionIds.includes(ue.questionId)||k.otherPinnedQuestionIds.includes(ue.questionId),kpiLabel:Le,responseType:we,emotions:Me.includes("feeling")?ue.answer:void 0,subName:ue.subName,type:ue.type,statusEnable:ue.statusEnable!==!1}})}}):[],[c]),ge=q.useMemo(()=>ce(A),[A,ce]);if(N===0)return e.jsxs("div",{style:{textAlign:"center",padding:"40px 20px"},children:[e.jsx(Us,{style:{fontSize:"48px",color:"#D97706",marginBottom:"16px"}}),e.jsx("h4",{style:{margin:"0 0 8px 0",fontWeight:700},children:"No Active Grade Levels"}),e.jsx("p",{style:{color:"#667085",margin:0},children:"Please go back to Step 1 and enable at least one Grade Level (Elementary, Middle School or High School) to set up check-ins."})]});const Y=qe(s.system,c),B=qe(s.system,"secondary"),w=s.routine[Y]||s.routine[B]||{logic:"rotated",schedule:"weekly",customQuestions:[]},J=(()=>{const k=ge.filter(he=>he.title!=="Custom Open Field Questions");if((w.customQuestions||[]).length===0)return k;const V=[...k];return V.push({number:V.length+1,title:"Custom Open Field Questions",color:"#ffb04f",backgroundColor:"#ffb04f20",questions:[],isCustomCluster:!0,customQuestionItems:w.customQuestions}),V})(),me=k=>{m(j,k,c)},ee=k=>{g(j,k,c)},f=A?A.clusters.flatMap(k=>k.questions.map(V=>({...V,clusterTitle:k.title}))):[],$=A?f.filter(k=>A.coreQuestionIds.includes(k.questionId)).map(k=>{const V=k.name,he=(V||"").toLowerCase(),de=k.responseTypeLabel,ue=k.kpiLabel||k.clusterTitle;return{id:String(k.questionId),shortTitle:V,fullText:k.description||V,responseType:de,kpiLabel:ue,emotions:he.includes("feeling")?k.answer:void 0,subName:k.subName,type:k.type}}):[],se=(A?$:[]).filter(k=>k.kpiLabel==="Emotional State"||Q.includes(k.id||k.shortTitle)),X=J.filter(k=>k.title!=="Safety"&&k.title!=="Safety and Stress"&&k.title!=="Resilience and Stress"&&k.number!==1&&!k.isCustomCluster).flatMap(k=>k.questions||[]).filter(k=>!A?.coreQuestionIds?.includes(Number(k.id))&&Q.includes(k.id||k.title)&&k.statusEnable!==!1).map(k=>({id:k.id,shortTitle:k.title,fullText:k.text,responseType:k.responseType,kpiLabel:k.kpiLabel})),H=J.filter(k=>k.isCustomCluster).flatMap(k=>k.customQuestionItems||[]).filter(k=>!A?.coreQuestionIds?.includes(Number(k.id))&&Q.includes(k.id)).map(k=>({id:k.id,shortTitle:k.text,fullText:"",responseType:"Open Text",kpiLabel:"Custom"})),ye=[...X,...H],Ne=q.useMemo(()=>ge.filter(V=>V.title!=="Custom Open Field Questions").reduce((V,he)=>V+he.questions.filter(de=>de.statusEnable!==!1).length,0)+w.customQuestions.length,[ge,w.customQuestions]);return e.jsx(We.LocalizationProvider,{dateAdapter:at.AdapterMoment,children:e.jsxs("div",{className:t["s2-wrapper"],children:[e.jsx("h2",{className:t["s2-page-title"],children:"Routine Check-in"}),e.jsx("p",{className:t["s2-page-subtitle"],children:"Configure questions and settings for your routine check-ins"}),N>=2&&e.jsx(zn,{system:s.system,showEarlyElementary:z,showElementary:P,showSecondary:p,showMiddleSchool:te,showHighSchool:ne,activeTab:c,totalTabs:N,onTabChange:y}),e.jsx(Gn,{logic:w.logic,schedule:w.schedule,totalQuestions:Ne,onChangeLogic:k=>o(Y,k),onChangeSchedule:k=>r(Y,k),isEarlyElementary:c==="early_elementary"}),e.jsx(Hn,{coreQuestions:se,otherQuestions:ye,gradeRange:c,onUnpin:me}),e.jsx(Wn,{clusters:J,pinnedIds:Q,system:s.system,gradeRange:c,isEarlyYearsEnabled:s.grades.early_years,onTogglePin:me,onToggleEnable:ee,onRemoveCustomQuestion:k=>l(Y,k),onEditCustomQuestion:(k,V,he,de,ue)=>a(Y,k,V,he,de,ue),onReorderClusters:k=>M(j,k,c)}),e.jsx(Jn,{gradeRange:c,system:s.system,isEarlyYearsEnabled:s.grades.early_years,onAddCustomQuestion:(k,V,he,de,ue,_e)=>i(Y,V,he,de,ue,_e)})]})})},Xn=n.createSvgIcon(e.jsx("path",{d:"M11 7h2v2h-2zm0 4h2v6h-2zm1-9C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8"}),"InfoOutlined"),Ds=s=>{const o=s.type||"";if(s.questionType?.toLowerCase()==="rating"||o.toLowerCase().includes("scale")||o.toLowerCase().includes("rating")){if(s.answers&&s.answers.length>0){const i=s.answers[0],l=s.answers[s.answers.length-1];return`Scale 1–5 · 1 = ${i} · 5 = ${l}`}return o.toLowerCase().includes("scale")?o:"Scale 1–5"}return o},Zn=({questions:s,iconColor:o,isAILiteracy:r=!1})=>{if(r){const i=s.filter(u=>!u.grades||u.grades.includes("MS")),l=s.filter(u=>u.grades&&u.grades.includes("ES")),a="#6e11b0";return e.jsxs("div",{className:t["s3-questions-panel"],style:{borderColor:o+"30",backgroundColor:o+"05"},children:[l.length>0&&e.jsxs("div",{className:t["s3-questions"],children:[e.jsxs("div",{className:`${t["s3-list-question-header"]} ${t["es-header"]}`,children:[e.jsx("span",{className:t["s3-list-question-title"],children:"Primary / Elementary"}),e.jsxs("span",{className:t["s3-list-question-desc"],children:[l.length," questions · 3 pages"]})]}),l.map((u,c)=>e.jsxs("div",{children:[c===0&&e.jsx("div",{className:t["s3-question-header"],children:"Page 1: Did I use AI, and how?"}),c===5&&e.jsx("div",{className:t["s3-question-header"],children:"Page 2: My brain and my effort"}),c===9&&e.jsx("div",{className:t["s3-question-header"],children:"Page 3: Checking and feeling confident"}),e.jsxs("div",{className:t["s3-question-item"],children:[e.jsx("span",{className:t["s3-question-num"],style:{backgroundColor:o},children:c+1}),e.jsxs("div",{className:t["s3-question-body"],children:[e.jsx("span",{className:t["s3-question-text"],children:u.text}),e.jsx("span",{className:t["s3-question-type"],children:Ds(u)})]})]})]},u.id))]}),i.length>0&&e.jsxs("div",{className:t["s3-questions"],children:[e.jsxs("div",{className:`${t["s3-list-question-header"]} ${t["ms-header"]}`,children:[e.jsx("span",{className:t["s3-list-question-title"],children:"Secondary / Middle & High School"}),e.jsxs("span",{className:t["s3-list-question-desc"],children:[i.length," questions · 3 pages"]})]}),i.map((u,c)=>e.jsxs("div",{children:[c===0&&e.jsx("div",{className:t["s3-question-header"],children:"Page 1: Use, understanding & confidence"}),c===5&&e.jsx("div",{className:t["s3-question-header"],children:"Page 2: Reliability and accountability"}),c===9&&e.jsx("div",{className:t["s3-question-header"],children:"Page 3: Reliance and well-being"}),e.jsxs("div",{className:t["s3-question-item"],children:[e.jsx("span",{className:t["s3-question-num"],style:{backgroundColor:a},children:c+1}),e.jsxs("div",{className:t["s3-question-body"],children:[e.jsx("span",{className:t["s3-question-text"],children:u.text}),e.jsx("span",{className:t["s3-question-type"],children:Ds(u)})]})]})]},u.id))]})]})}return e.jsx("div",{className:t["s3-questions-panel"],style:{borderColor:o+"30",backgroundColor:o+"05"},children:s.map((i,l)=>e.jsxs("div",{className:t["s3-question-item"],children:[e.jsx("span",{className:t["s3-question-num"],style:{backgroundColor:o},children:l+1}),e.jsxs("div",{className:t["s3-question-body"],children:[e.jsx("span",{className:t["s3-question-text"],children:i.text}),e.jsx("span",{className:t["s3-question-type"],children:Ds(i)})]})]},i.id))})},eo=({periods:s,onAddPeriod:o,onDeletePeriod:r,onPeriodDateChange:i,hasOverlapError:l})=>e.jsxs("div",{className:t["s3-periods-container"],children:[e.jsxs("div",{className:t["s3-periods-header"],children:[e.jsx("span",{className:t["s3-periods-title"],children:"Delivery Periods"}),s.length<3&&e.jsx("button",{className:t["s3-add-period-btn"],onClick:o,children:"+ Add Period"})]}),s.length===0?e.jsx("span",{className:t["s3-no-periods-text"],children:'Click "Add Period" to schedule this module'}):s.map((a,u)=>{const c=a.startDate?ze(a.startDate,"YYYY-MM-DD"):null,y=a.endDate?ze(a.endDate,"YYYY-MM-DD"):null;return e.jsxs("div",{className:t["s3-period-row"],children:[e.jsxs("div",{className:t["s3-period-row-header"],children:[e.jsxs("span",{className:t["s3-period-row-title"],children:["Period ",u+1]}),e.jsx("button",{className:t["s3-delete-period-btn"],onClick:()=>r(u),children:"×"})]}),e.jsxs("div",{className:t["s3-period-dates"],children:[e.jsxs("div",{className:t["s3-period-date-input"],children:[e.jsx("label",{children:"Start Date"}),e.jsx(We.DatePicker,{value:c,onChange:m=>i(u,"startDate",m),format:"MM/DD/YYYY",slotProps:{textField:{fullWidth:!0,variant:"outlined",InputProps:{style:{height:40,borderRadius:"8px",fontSize:"13px"}}}}})]}),e.jsxs("div",{className:t["s3-period-date-input"],children:[e.jsx("label",{children:"End Date"}),e.jsx(We.DatePicker,{value:y,onChange:m=>i(u,"endDate",m),minDate:c||void 0,format:"MM/DD/YYYY",slotProps:{textField:{fullWidth:!0,variant:"outlined",InputProps:{style:{height:40,borderRadius:"8px",fontSize:"13px"}}}}})]})]})]},u)}),l&&e.jsx("div",{className:t["s3-period-error-text"],style:{color:"#D92D20",fontSize:"13px",fontWeight:500,marginTop:"8px"},children:"⚠️ Delivery periods cannot overlap. Please adjust the dates."})]}),so=({system:s,mod:o,meta:r,isActive:i,isEsChecked:l,isMsChecked:a,isHsChecked:u=!1,isExpanded:c,showElementary:y,showMiddleSchool:m=!1,showHighSchool:g=!1,showSecondary:M,onToggleMainSwitch:F,onToggleGradeActivation:R,onToggleExpand:z,periods:P,onAddPeriod:te,onDeletePeriod:ne,onPeriodDateChange:p,hasOverlapError:N,activeTab:j="secondary"})=>{const{tag:I,iconColor:A,IconComponent:Q}=r,ce=ks(s);let ge=o.questions.length;if(o.title.toLowerCase()==="ai literacy"){const Y=o.questions.filter(w=>!w.grades||w.grades.includes("MS"));ge=o.questions.filter(w=>w.grades&&w.grades.includes("ES")).length+Y.length}return e.jsx("div",{className:[t["s3-module-wrapper"],i?t["s3-module-wrapper--active"]:""].join(" "),style:{"--theme-color":A},children:e.jsxs("div",{className:[t["s3-module-card"],i?t["s3-module-card--active"]:"",c?t["s3-module-card--expanded"]:""].join(" "),children:[e.jsxs("div",{className:t["s3-card-top"],children:[e.jsx("div",{className:t["s3-icon-box"],children:e.jsx(Q,{color:"#ffffff",size:28})}),e.jsxs("div",{className:t["s3-module-info"],children:[e.jsx("h4",{className:t["s3-module-title"],children:o.title}),e.jsx("p",{className:t["s3-module-desc"],children:o.description}),I&&e.jsx("span",{className:t["s3-module-tag"],children:I})]}),e.jsx("div",{className:t["s3-toggle-col"],children:e.jsx(Hs,{checked:i,onChange:F,color:"primary"})})]}),i&&e.jsxs("div",{className:t["s3-active-grades-container"],children:[e.jsx("span",{className:t["s3-grades-label"],children:"Active for Grade Levels:"}),e.jsxs("div",{className:t["s3-checkbox-row"],children:[y&&e.jsxs("label",{className:t["s3-checkbox-label"],children:[e.jsx("input",{type:"checkbox",checked:l,onChange:()=>R("elementary",l)}),ce.elementary.label]}),m&&e.jsxs("label",{className:t["s3-checkbox-label"],children:[e.jsx("input",{type:"checkbox",checked:a,onChange:()=>R("middle_school",a)}),ce.middle_school.label]}),g&&e.jsxs("label",{className:t["s3-checkbox-label"],children:[e.jsx("input",{type:"checkbox",checked:u,onChange:()=>R("high_school",u)}),ce.high_school.label]}),M&&e.jsxs("label",{className:t["s3-checkbox-label"],children:[e.jsx("input",{type:"checkbox",checked:a,onChange:()=>R("secondary",a)}),ce.secondary.label]})]})]}),e.jsxs("button",{className:t["s3-expand-btn"],onClick:z,children:[c?"▼":"▶"," View Extra Questions (",ge,")"]}),c&&e.jsx(Zn,{questions:o.questions,iconColor:A,isAILiteracy:o.title.toLowerCase()==="ai literacy",activeTab:j}),i&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:t["s3-divider"]}),e.jsx(eo,{periods:P,onAddPeriod:te,onDeletePeriod:ne,onPeriodDateChange:p,hasOverlapError:N})]})]})})},to=({config:s,onToggleModule:o,checkInQuestionsMap:r,activeTab:i,onUpdateModuleConfig:l,isAdminEs:a=!0,isAdminMs:u=!0})=>{const[c,y]=q.useState({}),[m,g]=q.useState({}),[M,F]=q.useState({});q.useEffect(()=>{const f={},$=r?.es?.routines?.find(X=>X.gradeLevel===1),W=r?.ms?.routines?.find(X=>X.gradeLevel===2),se=r?.ms?.routines?.find(X=>X.gradeLevel===3);Is.forEach(X=>{const H=X.id,ye=$?.extraModules?.find(_e=>Se(_e.title)===H),Ne=W?.extraModules?.find(_e=>Se(_e.title)===H),k=se?.extraModules?.find(_e=>Se(_e.title)===H),V=ye?.periods||[],he=Ne?.periods||[],de=k?.periods||[],ue=V.length>0?V:he.length>0?he:de.length>0?de:[];f[H]=ue.map(_e=>({startDate:_e.startDate||"",endDate:_e.endDate||""}))}),g(f)},[r]);const R=f=>{y($=>({...$,[f]:!$[f]}))},z=i==="elementary"?"es":"ms",P=r?.[z],te=z==="es"?1:i==="high_school"?3:2,p=(P?.routines?.find(f=>f.gradeLevel===te)||P?.routines?.find(f=>f.gradeLevel===2))?.extraModules,N=r?.es?.routines?.find(f=>f.gradeLevel===1),j=r?.ms?.routines?.find(f=>f.gradeLevel===2),I=r?.ms?.routines?.find(f=>f.gradeLevel===3),A=N?.extraModules?.find(f=>Se(f.title)==="ai_literacy")?.questions||[],Q=j?.extraModules?.find(f=>Se(f.title)==="ai_literacy")?.questions||[],ce=[...A.map(f=>({...f,grades:"ES"})),...Q.map(f=>({...f,grades:"MS"}))],ge=p&&p.length>0?p.map(f=>{const W=Se(f.title)||"ai_literacy",se=Is.find(H=>H.id===W);let X=f.questions||[];return W==="ai_literacy"&&ce.length>0&&(X=ce),{id:W,title:f.title,description:se?.description||"",questions:X.map(H=>({id:String(H.questionId),text:H.questionName,type:H.description,grades:H.grades,questionType:H.type,answers:H.answers}))}}):[],Y=async(f,$,W)=>{if($==="elementary"&&!a||($==="middle_school"||$==="high_school"||$==="secondary")&&!u)return;const se=!W,H=(m[f]||[]).filter(ye=>ye.startDate&&ye.endDate);$==="elementary"?await l("es",f,se,H,1):$==="middle_school"?await l("ms",f,se,H,2):$==="high_school"?await l("ms",f,se,H,3):await l("ms",f,se,H,2)},B=f=>{g($=>({...$,[f]:[...$[f]||[],{startDate:"",endDate:""}]}))},w=async(f,$)=>{const se=(m[f]||[]).filter((X,H)=>H!==$);g(X=>({...X,[f]:se})),await me(f,se)},J=(f,$,W,se)=>{const X=se?se.format("YYYY-MM-DD"):"",H=[...m[f]||[]];H[$]&&(H[$]={...H[$],[W]:X}),g(Ne=>({...Ne,[f]:H}));const ye=H[$];ye.startDate&&ye.endDate&&me(f,H)},me=async(f,$)=>{const W=Qn($);if(F(de=>({...de,[f]:W})),W)return;const se=N?.extraModules?.find(de=>Se(de.title)===f),X=j?.extraModules?.find(de=>Se(de.title)===f),H=I?.extraModules?.find(de=>Se(de.title)===f),ye=se?.status??!1,Ne=X?.status??!1,k=H?.status??!1,V=$.filter(de=>de.startDate&&de.endDate),he=[];s.grades.elementary&&N&&he.push(l("es",f,ye,V,1)),s.grades.middle_school&&j&&he.push(l("ms",f,Ne,V,2)),s.grades.high_school&&I&&he.push(l("ms",f,k,V,3)),s.grades.secondary&&!s.grades.middle_school&&!s.grades.high_school&&j&&he.push(l("ms",f,Ne,V,2)),await Promise.all(he)},ee=!!(s.grades.middle_school||s.grades.high_school);return e.jsx(We.LocalizationProvider,{dateAdapter:at.AdapterMoment,children:e.jsxs("div",{className:t["s3-wrapper"],children:[e.jsxs("div",{className:t["s3-header"],children:[e.jsx("h2",{className:t["s3-title"],children:"Extra Modules"}),e.jsx("p",{className:t["s3-subtitle"],children:"Specialized plugins for targeted student support"})]}),e.jsxs("div",{className:t["s3-info-banner"],children:[e.jsx(Xn,{className:t["s3-info-icon"]}),e.jsxs("div",{children:[e.jsx("span",{className:t["s3-info-banner-title"],children:"Extra Module Questions"}),e.jsxs("p",{className:t["s3-info-banner-desc"],children:["These module questions will appear ",e.jsx("strong",{children:"after the regular check-in"})," and will be shown"," ",e.jsx("strong",{children:"once per student"})," during the scheduled period. Students complete their standard check-in first, then see the extra module questions."]})]})]}),e.jsx("div",{className:t["s3-module-list"],children:ge.map(f=>{const $=ct[f.id],W=N?.extraModules?.find(de=>Se(de.title)===f.id),se=j?.extraModules?.find(de=>Se(de.title)===f.id),X=I?.extraModules?.find(de=>Se(de.title)===f.id),H=W?.status??!1,ye=se?.status??!1,Ne=X?.status??!1,k=!!s.modules[f.id],V=!!c[f.id],he=m[f.id]||[];return e.jsx(so,{system:s.system,mod:f,meta:$,isActive:k,isEsChecked:H,isMsChecked:ye,isHsChecked:Ne,isExpanded:V,showElementary:a&&s.grades.elementary,showMiddleSchool:u&&s.grades.middle_school,showHighSchool:u&&s.grades.high_school,showSecondary:u&&!ee&&s.grades.secondary,onToggleMainSwitch:()=>o(f.id),onToggleGradeActivation:(de,ue)=>Y(f.id,de,ue),onToggleExpand:()=>R(f.id),periods:he,onAddPeriod:()=>B(f.id),onDeletePeriod:de=>w(f.id,de),onPeriodDateChange:(de,ue,_e)=>J(f.id,de,ue,_e),hasOverlapError:!!M[f.id],activeTab:i},f.id)})})]})})},no=({config:s,journeys:o,onToggleJourney:r,onToggleGrade:i,hasSingleJourneyEnabled:l,isAdminEs:a=!0,isAdminMs:u=!0})=>{const c=!!(s.grades.middle_school||s.grades.high_school),y=a&&s.grades.elementary||u&&(s.grades.middle_school||s.grades.high_school||s.grades.secondary),m=s.system==="UK";return e.jsxs("div",{children:[e.jsxs("div",{className:t["journey-header-block"],children:[e.jsx("div",{className:t["journey-badge-engagement"],children:"Increases engagement by 40%"}),e.jsx("h2",{className:t["journey-step-title"],children:"Add a Splash of Fun"}),e.jsx("p",{className:t["journey-step-subtitle"],children:"Gamified journeys that boost student participation"})]}),e.jsx("div",{className:t["journey-grid"],children:o.map(g=>{const M=g.isEnabled,F=cs.some(te=>g.activeGrades.includes(te)),R=[6,7,8].some(te=>g.activeGrades.includes(te)),z=[9,10,11,12].some(te=>g.activeGrades.includes(te)),P=ds.some(te=>g.activeGrades.includes(te));return e.jsxs("div",{className:`${t["journey-card"]} ${M?t.active:""}`,children:[e.jsx("div",{className:t["journey-icon-circle"],children:e.jsx("img",{src:g.icon,alt:g.name})}),e.jsxs("div",{children:[e.jsx("h4",{className:t["journey-name"],children:g.name}),e.jsx("p",{className:t["journey-desc"],children:g.description})]}),e.jsx("div",{className:t["journey-xp-badge"],children:"+10 XP per check-in"}),e.jsx("div",{className:`${t["custom-switch"]} ${M?t.active:""}`,onClick:()=>r(g),children:e.jsx("div",{className:t["custom-switch__thumb"]})}),M&&y&&e.jsxs("div",{className:t["active-grades-box"],onClick:te=>te.stopPropagation(),children:[e.jsx("div",{className:t["active-grades-title"],children:"Active for Grade Levels:"}),e.jsxs("div",{className:t["active-grades-list"],children:[a&&s.grades.elementary&&e.jsxs("div",{className:t["grade-item"],onClick:()=>i(g,"elementary"),children:[e.jsx("div",{className:`${t["check-square"]} ${F?t.checked:""}`}),e.jsx("span",{children:m?"Years 3–6":"Grades 2–5"})]}),u&&s.grades.middle_school&&e.jsxs("div",{className:t["grade-item"],onClick:()=>i(g,"middle_school"),children:[e.jsx("div",{className:`${t["check-square"]} ${R?t.checked:""}`}),e.jsx("span",{children:m?"Years 7–9":"Grades 6–8"})]}),u&&s.grades.high_school&&e.jsxs("div",{className:t["grade-item"],onClick:()=>i(g,"high_school"),children:[e.jsx("div",{className:`${t["check-square"]} ${z?t.checked:""}`}),e.jsx("span",{children:m?"Years 10–13":"Grades 9–12"})]}),u&&!c&&s.grades.secondary&&e.jsxs("div",{className:t["grade-item"],onClick:()=>i(g,"secondary"),children:[e.jsx("div",{className:`${t["check-square"]} ${P?t.checked:""}`}),e.jsx("span",{children:m?"Years 7–13":"Grades 6+"})]})]})]})]},g.id)})}),e.jsx("div",{className:t["journey-benefits-box-new"],children:e.jsxs("div",{className:t["journey-benefits-box-new"],children:[e.jsx("div",{className:t["benefits-title-new"],children:"Journey Benefits"}),e.jsxs("ul",{className:t["benefits-list-new"],children:[e.jsxs("li",{children:[e.jsx("span",{className:t["tick-icon"],children:"✓"}),"Students earn XP for completing daily check-ins"]}),e.jsxs("li",{children:[e.jsx("span",{className:t["tick-icon"],children:"✓"}),"Progress tracking with visual milestone rewards"]}),e.jsxs("li",{children:[e.jsx("span",{className:t["tick-icon"],children:"✓"}),"The themed prompts that connect to curriculum topics"]})]})]})}),l&&e.jsx("div",{className:t["journey-selecting-alert"],children:e.jsx("span",{children:"⚠️ If selecting journeys, please choose at least 2. Currently selected: 1"})})]})},oo=n.createSvgIcon(e.jsx("path",{d:"M19 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.89-2-2-2m0 16H5V7h14zm-5.5-6c0 .83-.67 1.5-1.5 1.5s-1.5-.67-1.5-1.5.67-1.5 1.5-1.5 1.5.67 1.5 1.5M12 9c-2.73 0-5.06 1.66-6 4 .94 2.34 3.27 4 6 4s5.06-1.66 6-4c-.94-2.34-3.27-4-6-4m0 6.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5"}),"Preview"),ro=n.createSvgIcon([e.jsx("path",{d:"M13 8.57c-.79 0-1.43.64-1.43 1.43s.64 1.43 1.43 1.43 1.43-.64 1.43-1.43-.64-1.43-1.43-1.43"},"0"),e.jsx("path",{d:"M13 3C9.25 3 6.2 5.94 6.02 9.64L4.1 12.2c-.25.33-.01.8.4.8H6v3c0 1.1.9 2 2 2h1v3h7v-4.68c2.36-1.12 4-3.53 4-6.32 0-3.87-3.13-7-7-7m3 7c0 .13-.01.26-.02.39l.83.66c.08.06.1.16.05.25l-.8 1.39c-.05.09-.16.12-.24.09l-.99-.4c-.21.16-.43.29-.67.39L14 13.83c-.01.1-.1.17-.2.17h-1.6c-.1 0-.18-.07-.2-.17l-.15-1.06c-.25-.1-.47-.23-.68-.39l-.99.4c-.09.03-.2 0-.25-.09l-.8-1.39c-.05-.08-.03-.19.05-.25l.84-.66c-.01-.13-.02-.26-.02-.39s.02-.27.04-.39l-.85-.66c-.08-.06-.1-.16-.05-.26l.8-1.38c.05-.09.15-.12.24-.09l1 .4c.2-.15.43-.29.67-.39L12 6.17c.02-.1.1-.17.2-.17h1.6c.1 0 .18.07.2.17l.15 1.06c.24.1.46.23.67.39l1-.4c.09-.03.2 0 .24.09l.8 1.38c.05.09.03.2-.05.26l-.85.66c.03.12.04.25.04.39"},"1")],"Psychology"),io=n.createSvgIcon(e.jsx("path",{d:"M12 1 3 5v6c0 5.55 3.84 10.74 9 12 5.16-1.26 9-6.45 9-12V5z"}),"Shield"),ao=n.createSvgIcon(e.jsx("path",{d:"M6 2v6h.01L6 8.01 10 12l-4 4 .01.01H6V22h12v-5.99h-.01L18 16l-4-4 4-3.99-.01-.01H18V2zm10 14.5V20H8v-3.5l4-4zm-4-5-4-4V4h8v3.5z"}),"HourglassEmpty"),lo=({config:s,journeys:o=[],checkInQuestionsMap:r,isAdminEs:i=!0,isAdminMs:l=!0,onPreviewOpen:a,onEditStep:u})=>{const c=()=>`Last updated: ${An()}`,y=ks(s.system),m=i&&s.grades.early_years,g=i&&s.grades.elementary,M=l&&s.grades.middle_school,F=l&&s.grades.high_school,R=l&&!M&&!F&&s.grades.secondary,z=q.useMemo(()=>{const p=[];return m&&p.push("early_elementary"),g&&p.push("elementary"),M&&p.push("middle_school"),F&&p.push("high_school"),R&&p.push("secondary"),p},[m,g,M,F,R]),P=p=>{const N=[],j=p.activeGrades.some(ce=>cs.includes(ce)),I=p.activeGrades.some(ce=>[6,7,8].includes(ce)),A=p.activeGrades.some(ce=>[9,10,11,12].includes(ce)),Q=s.system==="UK";return j&&N.push(Q?"Years 3–6":"Grades 2–5"),s.grades.middle_school||s.grades.high_school?(I&&N.push(Q?"Years 7–9":"Grades 6–8"),A&&N.push(Q?"Years 10–13":"Grades 9–12")):p.activeGrades.some(ge=>ds.includes(ge))&&N.push(Q?"Years 7–13":"Grades 6+"),N.length>0?N.join(", "):"No grade levels selected"},te=p=>{switch(p){case"world_wonder":return"🌏";case"pop_art":case"pop_and_art":return"🎨";case"music":return"🎵";case"sports":return"⚽";case"technology":return"💻";case"community_cosmos":return"🤝";default:return"✨"}},ne=o.length>0?o.filter(p=>p.isEnabled):Rs.filter(p=>s.journeys.themes.includes(p.id)).map(p=>({id:0,name:p.title,strategicIntent:"",description:p.description,icon:p.id,isEnabled:!0,activeGrades:[]}));return e.jsxs("div",{className:t["summary-container"],children:[e.jsx("div",{className:t["success-icon-wrapper"],children:e.jsx(Ct.CheckCircleIcon,{className:t["success-icon"]})}),e.jsx("h3",{className:t["summary-heading"],children:"Setup Complete!"}),e.jsx("p",{className:t["summary-subtext"],children:"Your student check-in system is configured and ready to go"}),e.jsxs("div",{className:t["summary-grid-2x2"],children:[e.jsxs("div",{className:`${t["summary-box"]} ${t["summary-box--routine"]}`,children:[e.jsxs("div",{className:t["box-header"],children:[e.jsxs("div",{className:t["box-header-left"],children:[e.jsx("h4",{className:t["box-title"],children:"Active Routine Check-ins"}),e.jsx("p",{className:t["box-subtitle"],children:c()})]}),e.jsx("button",{className:t["btn-edit"],onClick:()=>u(2),children:"Edit"})]}),e.jsxs("div",{className:t["box-content-list"],children:[z.map(p=>{const N=y[p]||y.secondary,j=p==="early_elementary"||p==="elementary"?"es":"ms",I=p==="early_elementary"?0:p==="elementary"?1:p==="high_school"?3:2,A=r?.[j],Q=A?.routines?.find($=>$.gradeLevel===I)||(p==="high_school"?A?.routines?.find($=>$.gradeLevel===2):void 0),ce=Q?(Q.coreQuestionIds?.length||0)+(Q.otherPinnedQuestionIds?.length||0):p==="early_elementary"?3:p==="elementary"?4:3,ge=Q?.clusters?.length||(p==="early_elementary"?2:5),Y=qe(s.system,p),B=qe(s.system,"secondary"),w=s.routine[Y]||s.routine[B],J=p==="early_elementary"?"full":w?.logic||(Q?.logic===1?"full":"rotated"),me=w?.schedule||(Q?.schedule===1?"weekly":Q?.schedule===2?"biweekly":"monthly");let ee="";p==="early_elementary"?ee="Open Field -> Custom Open Field Questions":p==="elementary"?ee="Safety -> About my learning -> About me -> Readiness -> Open Field":ee="Safety and Stress -> Productivity -> Academics -> Well-Being -> Open Field";const f=Q?.clusters&&Q.clusters.length>0?Q.clusters.map($=>$.title).join(" -> "):ee;return e.jsxs("div",{className:t["sub-card"],children:[e.jsx("h5",{className:t["sub-card__title"],children:N.label}),e.jsxs("p",{className:t["sub-card__info"],children:[ce," pinned questions • ",ge," clusters"]}),e.jsx("p",{className:t["sub-card__info"],children:J==="rotated"?`Rotated: 3 questions/session • ${me}`:`Full: All questions/session • ${me}`}),e.jsx("p",{className:t["sub-card__muted"],children:`Cluster order: ${f}`})]},p)}),z.length===0&&e.jsx("p",{style:{fontStyle:"italic",color:"#667085"},children:"No routine check-ins active"})]})]}),e.jsxs("div",{className:`${t["summary-box"]} ${t["summary-box--journeys"]}`,children:[e.jsxs("div",{className:t["box-header"],children:[e.jsxs("div",{className:t["box-header-left"],children:[e.jsx("h4",{className:t["box-title"],children:"Active Journeys"}),e.jsx("p",{className:t["box-subtitle"],children:c()})]}),e.jsx("button",{className:t["btn-edit"],onClick:()=>u(4),children:"Edit"})]}),e.jsxs("div",{className:t["box-content-list"],children:[ne.map((p,N)=>e.jsxs("div",{className:t["theme-item"],children:[p.icon&&(p.icon.startsWith("/")||p.icon.startsWith("http")||p.icon.includes("."))?e.jsx("img",{src:p.icon,alt:p.name,className:t["theme-item__icon"]}):e.jsx("span",{className:t["theme-item__emoji"],children:te(p.icon)}),e.jsxs("div",{className:t["theme-item__info"],children:[e.jsx("h5",{className:t["theme-item__title"],children:p.name}),e.jsx("p",{className:t["theme-item__status"],children:p.id===0?s.grades.elementary||s.grades.secondary?"Active":"No grade levels selected":P(p)})]})]},N)),ne.length===0&&e.jsx("p",{style:{fontStyle:"italic",color:"#667085"},children:"No active journeys"})]})]}),e.jsxs("div",{className:`${t["summary-box"]} ${t["summary-box--modules"]}`,children:[e.jsxs("div",{className:t["box-header"],children:[e.jsxs("div",{className:t["box-header-left"],children:[e.jsx("h4",{className:t["box-title"],children:"Extra Modules"}),e.jsx("p",{className:t["box-subtitle"],children:c()})]}),e.jsx("button",{className:t["btn-edit"],onClick:()=>u(3),children:"Edit"})]}),e.jsxs("div",{className:t["box-content-list"],children:[e.jsxs("div",{className:t["module-item"],children:[e.jsx("div",{className:`${t["module-item__icon-box"]} ${t.ai_literacy}`,children:e.jsx(ro,{})}),e.jsxs("div",{className:t["module-item__info"],children:[e.jsx("h5",{className:t["module-item__title"],children:"AI Literacy"}),e.jsx("p",{className:`${t["module-item__status"]} ${s.modules.ai_literacy?t.active:t.inactive}`,children:s.modules.ai_literacy?"Active":"Inactive"})]})]}),e.jsxs("div",{className:t["module-item"],children:[e.jsx("div",{className:`${t["module-item__icon-box"]} ${t.bullying}`,children:e.jsx(io,{})}),e.jsxs("div",{className:t["module-item__info"],children:[e.jsx("h5",{className:t["module-item__title"],children:"Bullying & Safety"}),e.jsx("p",{className:`${t["module-item__status"]} ${s.modules.bullying?t.active:t.inactive}`,children:s.modules.bullying?"Active":"Inactive"})]})]}),e.jsxs("div",{className:t["module-item"],children:[e.jsx("div",{className:`${t["module-item__icon-box"]} ${t.digital_wellbeing}`,children:e.jsx(ao,{})}),e.jsxs("div",{className:t["module-item__info"],children:[e.jsx("h5",{className:t["module-item__title"],children:"Digital Wellbeing & Habits"}),e.jsx("p",{className:`${t["module-item__status"]} ${s.modules.digital_wellbeing?t.active:t.inactive}`,children:s.modules.digital_wellbeing?"Active":"Inactive"})]})]})]})]})]}),e.jsx("div",{className:t["summary-buttons"],children:e.jsxs("button",{className:t["btn-preview-large"],onClick:a,children:[e.jsx(oo,{})," Preview Student Check-in"]})})]})};function co(s,o,r=(i,l)=>i===l){return s.length===o.length&&s.every((i,l)=>r(i,o[l]))}const uo=2;function es(s,o,r,i,l){return r===1?Math.min(s+o,l):Math.max(s-o,i)}function gt(s,o){return s-o}function st(s,o){const{index:r}=s.reduce((i,l,a)=>{const u=Math.abs(o-l);return i===null||u<i.distance||u===i.distance?{distance:u,index:a}:i},null)??{};return r}function ys(s,o){if(o.current!==void 0&&s.changedTouches){const r=s;for(let i=0;i<r.changedTouches.length;i+=1){const l=r.changedTouches[i];if(l.identifier===o.current)return{x:l.clientX,y:l.clientY}}return!1}return{x:s.clientX,y:s.clientY}}function Ts(s,o,r){return(s-o)*100/(r-o)}function po(s,o,r){return(r-o)*s+o}function mo(s){if(Math.abs(s)<1){const r=s.toExponential().split("e-"),i=r[0].split(".")[1];return(i?i.length:0)+parseInt(r[1],10)}const o=s.toString().split(".")[1];return o?o.length:0}function ho(s,o,r){const i=Math.round((s-r)/o)*o+r;return Number(i.toFixed(mo(o)))}function tt({values:s,newValue:o,index:r}){const i=s.slice();return i[r]=o,i.sort(gt)}function fs({sliderRef:s,activeIndex:o,setActive:r}){const i=js.ownerDocument(s.current);(!s.current?.contains(i.activeElement)||Number(i?.activeElement?.getAttribute("data-index"))!==o)&&s.current?.querySelector(`[type="range"][data-index="${o}"]`).focus(),r&&r(o)}function _s(s,o){return typeof s=="number"&&typeof o=="number"?s===o:typeof s=="object"&&typeof o=="object"?co(s,o):!1}const go={horizontal:{offset:s=>({left:`${s}%`}),leap:s=>({width:`${s}%`})},"horizontal-reverse":{offset:s=>({right:`${s}%`}),leap:s=>({width:`${s}%`})},vertical:{offset:s=>({bottom:`${s}%`}),leap:s=>({height:`${s}%`})}},xo=s=>s;let bs;function nt(){return bs===void 0&&(typeof CSS<"u"&&typeof CSS.supports=="function"?bs=CSS.supports("touch-action","none"):bs=!0),bs}function yo(s){const{"aria-labelledby":o,defaultValue:r,disabled:i=!1,disableSwap:l=!1,isRtl:a=!1,marks:u=!1,max:c=100,min:y=0,name:m,onChange:g,onChangeCommitted:M,orientation:F="horizontal",rootRef:R,scale:z=xo,step:P=1,shiftStep:te=10,tabIndex:ne,value:p}=s,N=xe.useRef(void 0),[j,I]=xe.useState(-1),[A,Q]=xe.useState(-1),[ce,ge]=xe.useState(!1),Y=xe.useRef(0),B=xe.useRef(null),[w,J]=Xe.useControlled({controlled:p,default:r??y,name:"Slider"}),me=g&&((h,x,b)=>{const v=h.nativeEvent||h,_=new v.constructor(v.type,v);Object.defineProperty(_,"target",{writable:!0,value:{value:x,name:m}}),B.current=x,g(_,x,b)}),ee=Array.isArray(w);let f=ee?w.slice().sort(gt):[w];f=f.map(h=>h==null?y:n.clamp(h,y,c));const $=u===!0&&P!==null?[...Array(Math.floor((c-y)/P)+1)].map((h,x)=>({value:y+P*x})):u||[],W=$.map(h=>h.value),[se,X]=xe.useState(-1),H=xe.useRef(null),ye=Fs.useForkRef(R,H),Ne=h=>x=>{const b=Number(x.currentTarget.getAttribute("data-index"));je.isFocusVisible(x.target)&&X(b),Q(b),h?.onFocus?.(x)},k=h=>x=>{je.isFocusVisible(x.target)||X(-1),Q(-1),h?.onBlur?.(x)},V=(h,x)=>{const b=Number(h.currentTarget.getAttribute("data-index")),v=f[b],_=W.indexOf(v);let S=x;if($&&P==null){const L=W[W.length-1];S>=L?S=L:S<=W[0]?S=W[0]:S=S<v?W[_-1]:W[_+1]}if(S=n.clamp(S,y,c),ee){l&&(S=n.clamp(S,f[b-1]||-1/0,f[b+1]||1/0));const L=S;S=tt({values:f,newValue:S,index:b});let E=b;l||(E=S.indexOf(L)),fs({sliderRef:H,activeIndex:E})}J(S),X(b),me&&!_s(S,w)&&me(h,S,b),M&&M(h,B.current??S)},he=h=>x=>{if(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","PageUp","PageDown","Home","End"].includes(x.key)){x.preventDefault();const b=Number(x.currentTarget.getAttribute("data-index")),v=f[b];let _=null;if(P!=null){const S=x.shiftKey?te:P;switch(x.key){case"ArrowUp":_=es(v,S,1,y,c);break;case"ArrowRight":_=es(v,S,a?-1:1,y,c);break;case"ArrowDown":_=es(v,S,-1,y,c);break;case"ArrowLeft":_=es(v,S,a?1:-1,y,c);break;case"PageUp":_=es(v,te,1,y,c);break;case"PageDown":_=es(v,te,-1,y,c);break;case"Home":_=y;break;case"End":_=c;break}}else if($){const S=W[W.length-1],L=W.indexOf(v),E=[a?"ArrowRight":"ArrowLeft","ArrowDown","PageDown","Home"],T=[a?"ArrowLeft":"ArrowRight","ArrowUp","PageUp","End"];E.includes(x.key)?L===0?_=W[0]:_=W[L-1]:T.includes(x.key)&&(L===W.length-1?_=S:_=W[L+1])}_!=null&&V(x,_)}h?.onKeyDown?.(x)};je.useEnhancedEffect(()=>{i&&H.current.contains(document.activeElement)&&document.activeElement?.blur()},[i]),i&&j!==-1&&I(-1),i&&se!==-1&&X(-1);const de=h=>x=>{h.onChange?.(x),V(x,x.target.valueAsNumber)},ue=xe.useRef(void 0);let _e=F;a&&F==="horizontal"&&(_e+="-reverse");const Me=({finger:h,move:x=!1})=>{const{current:b}=H,{width:v,height:_,bottom:S,left:L}=b.getBoundingClientRect();let E;_e.startsWith("vertical")?E=(S-h.y)/_:E=(h.x-L)/v,_e.includes("-reverse")&&(E=1-E);let T;if(T=po(E,y,c),P)T=ho(T,P,y);else{const Z=st(W,T);T=W[Z]}T=n.clamp(T,y,c);let G=0;if(ee){x?G=ue.current:G=st(f,T),l&&(T=n.clamp(T,f[G-1]||-1/0,f[G+1]||1/0));const Z=T;T=tt({values:f,newValue:T,index:G}),l&&x||(G=T.indexOf(Z),ue.current=G)}return{newValue:T,activeIndex:G}},Le=je.useEventCallback(h=>{const x=ys(h,N);if(!x)return;if(Y.current+=1,h.type==="mousemove"&&h.buttons===0){we(h);return}const{newValue:b,activeIndex:v}=Me({finger:x,move:!0});fs({sliderRef:H,activeIndex:v,setActive:I}),J(b),!ce&&Y.current>uo&&ge(!0),me&&!_s(b,w)&&me(h,b,v)}),we=je.useEventCallback(h=>{const x=ys(h,N);if(ge(!1),!x)return;const{newValue:b}=Me({finger:x,move:!0});I(-1),h.type==="touchend"&&Q(-1),M&&M(h,B.current??b),N.current=void 0,Ce()}),be=je.useEventCallback(h=>{if(i)return;nt()||h.preventDefault();const x=h.changedTouches[0];x!=null&&(N.current=x.identifier);const b=ys(h,N);if(b!==!1){const{newValue:_,activeIndex:S}=Me({finger:b});fs({sliderRef:H,activeIndex:S,setActive:I}),J(_),me&&!_s(_,w)&&me(h,_,S)}Y.current=0;const v=js.ownerDocument(H.current);v.addEventListener("touchmove",Le,{passive:!0}),v.addEventListener("touchend",we,{passive:!0})}),Ce=xe.useCallback(()=>{const h=js.ownerDocument(H.current);h.removeEventListener("mousemove",Le),h.removeEventListener("mouseup",we),h.removeEventListener("touchmove",Le),h.removeEventListener("touchend",we)},[we,Le]);xe.useEffect(()=>{const{current:h}=H;return h.addEventListener("touchstart",be,{passive:nt()}),()=>{h.removeEventListener("touchstart",be),Ce()}},[Ce,be]),xe.useEffect(()=>{i&&Ce()},[i,Ce]);const Ae=h=>x=>{if(h.onMouseDown?.(x),i||x.defaultPrevented||x.button!==0)return;x.preventDefault();const b=ys(x,N);if(b!==!1){const{newValue:_,activeIndex:S}=Me({finger:b});fs({sliderRef:H,activeIndex:S,setActive:I}),J(_),me&&!_s(_,w)&&me(x,_,S)}Y.current=0;const v=js.ownerDocument(H.current);v.addEventListener("mousemove",Le,{passive:!0}),v.addEventListener("mouseup",we)},Ge=Ts(ee?f[0]:y,y,c),Te=Ts(f[f.length-1],y,c)-Ge,Re=(h={})=>{const x=Oe.extractEventHandlers(h),b={onMouseDown:Ae(x||{})},v={...x,...b};return{...h,ref:ye,...v}},Fe=h=>x=>{h.onMouseOver?.(x);const b=Number(x.currentTarget.getAttribute("data-index"));Q(b)},He=h=>x=>{h.onMouseLeave?.(x),Q(-1)},Ve=(h={})=>{const x=Oe.extractEventHandlers(h),b={onMouseOver:Fe(x||{}),onMouseLeave:He(x||{})};return{...h,...x,...b}},d=h=>({pointerEvents:j!==-1&&j!==h?"none":void 0});let C;return F==="vertical"&&(C=a?"vertical-rl":"vertical-lr"),{active:j,axis:_e,axisProps:go,dragging:ce,focusedThumbIndex:se,getHiddenInputProps:(h={})=>{const x=Oe.extractEventHandlers(h),b={onChange:de(x||{}),onFocus:Ne(x||{}),onBlur:k(x||{}),onKeyDown:he(x||{})},v={...x,...b};return{tabIndex:ne,"aria-labelledby":o,"aria-orientation":F,"aria-valuemax":z(c),"aria-valuemin":z(y),name:m,type:"range",min:s.min,max:s.max,step:s.step===null&&s.marks?"any":s.step??void 0,disabled:i,...h,...v,style:{...Mt,direction:a?"rtl":"ltr",width:"100%",height:"100%",writingMode:C}}},getRootProps:Re,getThumbProps:Ve,marks:$,open:A,range:ee,rootRef:ye,trackLeap:Te,trackOffset:Ge,values:f,getThumbStyle:d}}const fo=s=>!s||!ls.isHostComponent(s);function _o(s){return n.generateUtilityClass("MuiSlider",s)}const $e=n.generateUtilityClasses("MuiSlider",["root","active","colorPrimary","colorSecondary","colorError","colorInfo","colorSuccess","colorWarning","disabled","dragging","focusVisible","mark","markActive","marked","markLabel","markLabelActive","rail","sizeSmall","thumb","thumbColorPrimary","thumbColorSecondary","thumbColorError","thumbColorSuccess","thumbColorInfo","thumbColorWarning","track","trackInverted","trackFalse","thumbSizeSmall","valueLabel","valueLabelOpen","valueLabelCircle","valueLabelLabel","vertical"]),bo=s=>{const{open:o}=s;return{offset:n.clsx(o&&$e.valueLabelOpen),circle:$e.valueLabelCircle,label:$e.valueLabelLabel}};function xt(s){const{children:o,className:r,value:i}=s,l=bo(s);return o?xe.cloneElement(o,{className:n.clsx(o.props.className)},e.jsxs(xe.Fragment,{children:[o.props.children,e.jsx("span",{className:n.clsx(l.offset,r),"aria-hidden":!0,children:e.jsx("span",{className:l.circle,children:e.jsx("span",{className:l.label,children:i})})})]})):null}process.env.NODE_ENV!=="production"&&(xt.propTypes={children:n.PropTypes.element.isRequired,className:n.PropTypes.string,value:n.PropTypes.node});function ot(s){return s}const vo=n.styled$1("span",{name:"MuiSlider",slot:"Root",overridesResolver:(s,o)=>{const{ownerState:r}=s;return[o.root,o[`color${n.capitalize(r.color)}`],r.size!=="medium"&&o[`size${n.capitalize(r.size)}`],r.marked&&o.marked,r.orientation==="vertical"&&o.vertical,r.track==="inverted"&&o.trackInverted,r.track===!1&&o.trackFalse]}})(n.memoTheme(({theme:s})=>({borderRadius:12,boxSizing:"content-box",display:"inline-block",position:"relative",cursor:"pointer",touchAction:"none",WebkitTapHighlightColor:"transparent","@media print":{colorAdjust:"exact"},[`&.${$e.disabled}`]:{pointerEvents:"none",cursor:"default",color:(s.vars||s).palette.grey[400]},[`&.${$e.dragging}`]:{[`& .${$e.thumb}, & .${$e.track}`]:{transition:"none"}},variants:[...Object.entries(s.palette).filter(us.createSimplePaletteValueFilter()).map(([o])=>({props:{color:o},style:{color:(s.vars||s).palette[o].main}})),{props:{orientation:"horizontal"},style:{height:4,width:"100%",padding:"13px 0","@media (pointer: coarse)":{padding:"20px 0"}}},{props:{orientation:"horizontal",size:"small"},style:{height:2}},{props:{orientation:"horizontal",marked:!0},style:{marginBottom:20}},{props:{orientation:"vertical"},style:{height:"100%",width:4,padding:"0 13px","@media (pointer: coarse)":{padding:"0 20px"}}},{props:{orientation:"vertical",size:"small"},style:{width:2}},{props:{orientation:"vertical",marked:!0},style:{marginRight:44}}]}))),jo=n.styled$1("span",{name:"MuiSlider",slot:"Rail",overridesResolver:(s,o)=>o.rail})({display:"block",position:"absolute",borderRadius:"inherit",backgroundColor:"currentColor",opacity:.38,variants:[{props:{orientation:"horizontal"},style:{width:"100%",height:"inherit",top:"50%",transform:"translateY(-50%)"}},{props:{orientation:"vertical"},style:{height:"100%",width:"inherit",left:"50%",transform:"translateX(-50%)"}},{props:{track:"inverted"},style:{opacity:1}}]}),wo=n.styled$1("span",{name:"MuiSlider",slot:"Track",overridesResolver:(s,o)=>o.track})(n.memoTheme(({theme:s})=>({display:"block",position:"absolute",borderRadius:"inherit",border:"1px solid currentColor",backgroundColor:"currentColor",transition:s.transitions.create(["left","width","bottom","height"],{duration:s.transitions.duration.shortest}),variants:[{props:{size:"small"},style:{border:"none"}},{props:{orientation:"horizontal"},style:{height:"inherit",top:"50%",transform:"translateY(-50%)"}},{props:{orientation:"vertical"},style:{width:"inherit",left:"50%",transform:"translateX(-50%)"}},{props:{track:!1},style:{display:"none"}},...Object.entries(s.palette).filter(us.createSimplePaletteValueFilter()).map(([o])=>({props:{color:o,track:"inverted"},style:{...s.vars?{backgroundColor:s.vars.palette.Slider[`${o}Track`],borderColor:s.vars.palette.Slider[`${o}Track`]}:{backgroundColor:n.lighten(s.palette[o].main,.62),borderColor:n.lighten(s.palette[o].main,.62),...s.applyStyles("dark",{backgroundColor:n.darken(s.palette[o].main,.5)}),...s.applyStyles("dark",{borderColor:n.darken(s.palette[o].main,.5)})}}}))]}))),To=n.styled$1("span",{name:"MuiSlider",slot:"Thumb",overridesResolver:(s,o)=>{const{ownerState:r}=s;return[o.thumb,o[`thumbColor${n.capitalize(r.color)}`],r.size!=="medium"&&o[`thumbSize${n.capitalize(r.size)}`]]}})(n.memoTheme(({theme:s})=>({position:"absolute",width:20,height:20,boxSizing:"border-box",borderRadius:"50%",outline:0,backgroundColor:"currentColor",display:"flex",alignItems:"center",justifyContent:"center",transition:s.transitions.create(["box-shadow","left","bottom"],{duration:s.transitions.duration.shortest}),"&::before":{position:"absolute",content:'""',borderRadius:"inherit",width:"100%",height:"100%",boxShadow:(s.vars||s).shadows[2]},"&::after":{position:"absolute",content:'""',borderRadius:"50%",width:42,height:42,top:"50%",left:"50%",transform:"translate(-50%, -50%)"},[`&.${$e.disabled}`]:{"&:hover":{boxShadow:"none"}},variants:[{props:{size:"small"},style:{width:12,height:12,"&::before":{boxShadow:"none"}}},{props:{orientation:"horizontal"},style:{top:"50%",transform:"translate(-50%, -50%)"}},{props:{orientation:"vertical"},style:{left:"50%",transform:"translate(-50%, 50%)"}},...Object.entries(s.palette).filter(us.createSimplePaletteValueFilter()).map(([o])=>({props:{color:o},style:{[`&:hover, &.${$e.focusVisible}`]:{...s.vars?{boxShadow:`0px 0px 0px 8px rgba(${s.vars.palette[o].mainChannel} / 0.16)`}:{boxShadow:`0px 0px 0px 8px ${n.alpha(s.palette[o].main,.16)}`},"@media (hover: none)":{boxShadow:"none"}},[`&.${$e.active}`]:{...s.vars?{boxShadow:`0px 0px 0px 14px rgba(${s.vars.palette[o].mainChannel} / 0.16)`}:{boxShadow:`0px 0px 0px 14px ${n.alpha(s.palette[o].main,.16)}`}}}}))]}))),yt=n.styled$1(xt,{name:"MuiSlider",slot:"ValueLabel",overridesResolver:(s,o)=>o.valueLabel})(n.memoTheme(({theme:s})=>({zIndex:1,whiteSpace:"nowrap",...s.typography.body2,fontWeight:500,transition:s.transitions.create(["transform"],{duration:s.transitions.duration.shortest}),position:"absolute",backgroundColor:(s.vars||s).palette.grey[600],borderRadius:2,color:(s.vars||s).palette.common.white,display:"flex",alignItems:"center",justifyContent:"center",padding:"0.25rem 0.75rem",variants:[{props:{orientation:"horizontal"},style:{transform:"translateY(-100%) scale(0)",top:"-10px",transformOrigin:"bottom center","&::before":{position:"absolute",content:'""',width:8,height:8,transform:"translate(-50%, 50%) rotate(45deg)",backgroundColor:"inherit",bottom:0,left:"50%"},[`&.${$e.valueLabelOpen}`]:{transform:"translateY(-100%) scale(1)"}}},{props:{orientation:"vertical"},style:{transform:"translateY(-50%) scale(0)",right:"30px",top:"50%",transformOrigin:"right center","&::before":{position:"absolute",content:'""',width:8,height:8,transform:"translate(-50%, -50%) rotate(45deg)",backgroundColor:"inherit",right:-8,top:"50%"},[`&.${$e.valueLabelOpen}`]:{transform:"translateY(-50%) scale(1)"}}},{props:{size:"small"},style:{fontSize:s.typography.pxToRem(12),padding:"0.25rem 0.5rem"}},{props:{orientation:"vertical",size:"small"},style:{right:"20px"}}]})));process.env.NODE_ENV!=="production"&&(yt.propTypes={children:n.PropTypes.element.isRequired,index:n.PropTypes.number.isRequired,open:n.PropTypes.bool.isRequired,value:n.PropTypes.node});const ko=n.styled$1("span",{name:"MuiSlider",slot:"Mark",shouldForwardProp:s=>n.slotShouldForwardProp(s)&&s!=="markActive",overridesResolver:(s,o)=>{const{markActive:r}=s;return[o.mark,r&&o.markActive]}})(n.memoTheme(({theme:s})=>({position:"absolute",width:2,height:2,borderRadius:1,backgroundColor:"currentColor",variants:[{props:{orientation:"horizontal"},style:{top:"50%",transform:"translate(-1px, -50%)"}},{props:{orientation:"vertical"},style:{left:"50%",transform:"translate(-50%, 1px)"}},{props:{markActive:!0},style:{backgroundColor:(s.vars||s).palette.background.paper,opacity:.8}}]}))),So=n.styled$1("span",{name:"MuiSlider",slot:"MarkLabel",shouldForwardProp:s=>n.slotShouldForwardProp(s)&&s!=="markLabelActive",overridesResolver:(s,o)=>o.markLabel})(n.memoTheme(({theme:s})=>({...s.typography.body2,color:(s.vars||s).palette.text.secondary,position:"absolute",whiteSpace:"nowrap",variants:[{props:{orientation:"horizontal"},style:{top:30,transform:"translateX(-50%)","@media (pointer: coarse)":{top:40}}},{props:{orientation:"vertical"},style:{left:36,transform:"translateY(50%)","@media (pointer: coarse)":{left:44}}},{props:{markLabelActive:!0},style:{color:(s.vars||s).palette.text.primary}}]}))),Po=s=>{const{disabled:o,dragging:r,marked:i,orientation:l,track:a,classes:u,color:c,size:y}=s,m={root:["root",o&&"disabled",r&&"dragging",i&&"marked",l==="vertical"&&"vertical",a==="inverted"&&"trackInverted",a===!1&&"trackFalse",c&&`color${n.capitalize(c)}`,y&&`size${n.capitalize(y)}`],rail:["rail"],track:["track"],mark:["mark"],markActive:["markActive"],markLabel:["markLabel"],markLabelActive:["markLabelActive"],valueLabel:["valueLabel"],thumb:["thumb",o&&"disabled",y&&`thumbSize${n.capitalize(y)}`,c&&`thumbColor${n.capitalize(c)}`],active:["active"],disabled:["disabled"],focusVisible:["focusVisible"]};return n.composeClasses(m,_o,u)},No=({children:s})=>s,ft=xe.forwardRef(function(o,r){const i=n.useDefaultProps({props:o,name:"MuiSlider"}),l=Ye.useRtl(),{"aria-label":a,"aria-valuetext":u,"aria-labelledby":c,component:y="span",components:m={},componentsProps:g={},color:M="primary",classes:F,className:R,disableSwap:z=!1,disabled:P=!1,getAriaLabel:te,getAriaValueText:ne,marks:p=!1,max:N=100,min:j=0,name:I,onChange:A,onChangeCommitted:Q,orientation:ce="horizontal",shiftStep:ge=10,size:Y="medium",step:B=1,scale:w=ot,slotProps:J,slots:me,tabIndex:ee,track:f="normal",value:$,valueLabelDisplay:W="off",valueLabelFormat:se=ot,...X}=i,H={...i,isRtl:l,max:N,min:j,classes:F,disabled:P,disableSwap:z,orientation:ce,marks:p,color:M,size:Y,step:B,shiftStep:ge,scale:w,track:f,valueLabelDisplay:W,valueLabelFormat:se},{axisProps:ye,getRootProps:Ne,getHiddenInputProps:k,getThumbProps:V,open:he,active:de,axis:ue,focusedThumbIndex:_e,range:Me,dragging:Le,marks:we,values:be,trackOffset:Ce,trackLeap:Ae,getThumbStyle:Ge}=yo({...H,rootRef:r});H.marked=we.length>0&&we.some(ie=>ie.label),H.dragging=Le,H.focusedThumbIndex=_e;const Te=Po(H),Re=me?.root??m.Root??vo,Fe=me?.rail??m.Rail??jo,He=me?.track??m.Track??wo,Ve=me?.thumb??m.Thumb??To,d=me?.valueLabel??m.ValueLabel??yt,C=me?.mark??m.Mark??ko,D=me?.markLabel??m.MarkLabel??So,h=me?.input??m.Input??"input",x=J?.root??g.root,b=J?.rail??g.rail,v=J?.track??g.track,_=J?.thumb??g.thumb,S=J?.valueLabel??g.valueLabel,L=J?.mark??g.mark,E=J?.markLabel??g.markLabel,T=J?.input??g.input,G=Ye.useSlotProps({elementType:Re,getSlotProps:Ne,externalSlotProps:x,externalForwardedProps:X,additionalProps:{...fo(Re)&&{as:y}},ownerState:{...H,...x?.ownerState},className:[Te.root,R]}),Z=Ye.useSlotProps({elementType:Fe,externalSlotProps:b,ownerState:H,className:Te.rail}),U=Ye.useSlotProps({elementType:He,externalSlotProps:v,additionalProps:{style:{...ye[ue].offset(Ce),...ye[ue].leap(Ae)}},ownerState:{...H,...v?.ownerState},className:Te.track}),K=Ye.useSlotProps({elementType:Ve,getSlotProps:V,externalSlotProps:_,ownerState:{...H,..._?.ownerState},className:Te.thumb}),O=Ye.useSlotProps({elementType:d,externalSlotProps:S,ownerState:{...H,...S?.ownerState},className:Te.valueLabel}),ae=Ye.useSlotProps({elementType:C,externalSlotProps:L,ownerState:H,className:Te.mark}),oe=Ye.useSlotProps({elementType:D,externalSlotProps:E,ownerState:H,className:Te.markLabel}),re=Ye.useSlotProps({elementType:h,getSlotProps:k,externalSlotProps:T,ownerState:H});return e.jsxs(Re,{...G,children:[e.jsx(Fe,{...Z}),e.jsx(He,{...U}),we.filter(ie=>ie.value>=j&&ie.value<=N).map((ie,le)=>{const Ee=Ts(ie.value,j,N),Ue=ye[ue].offset(Ee);let Ie;return f===!1?Ie=be.includes(ie.value):Ie=f==="normal"&&(Me?ie.value>=be[0]&&ie.value<=be[be.length-1]:ie.value<=be[0])||f==="inverted"&&(Me?ie.value<=be[0]||ie.value>=be[be.length-1]:ie.value>=be[0]),e.jsxs(xe.Fragment,{children:[e.jsx(C,{"data-index":le,...ae,...!ls.isHostComponent(C)&&{markActive:Ie},style:{...Ue,...ae.style},className:n.clsx(ae.className,Ie&&Te.markActive)}),ie.label!=null?e.jsx(D,{"aria-hidden":!0,"data-index":le,...oe,...!ls.isHostComponent(D)&&{markLabelActive:Ie},style:{...Ue,...oe.style},className:n.clsx(Te.markLabel,oe.className,Ie&&Te.markLabelActive),children:ie.label}):null]},le)}),be.map((ie,le)=>{const Ee=Ts(ie,j,N),Ue=ye[ue].offset(Ee),Ie=W==="off"?No:d;return e.jsx(Ie,{...!ls.isHostComponent(Ie)&&{valueLabelFormat:se,valueLabelDisplay:W,value:typeof se=="function"?se(w(ie),le):se,index:le,open:he===le||de===le||W==="on",disabled:P},...O,children:e.jsx(Ve,{"data-index":le,...K,className:n.clsx(Te.thumb,K.className,de===le&&Te.active,_e===le&&Te.focusVisible),style:{...Ue,...Ge(le),...K.style},children:e.jsx(h,{"data-index":le,"aria-label":te?te(le):a,"aria-valuenow":w(ie),"aria-labelledby":c,"aria-valuetext":ne?ne(w(ie),le):u,value:be[le],...re})})},le)})]})});process.env.NODE_ENV!=="production"&&(ft.propTypes={"aria-label":je.chainPropTypes(n.PropTypes.string,s=>Array.isArray(s.value||s.defaultValue)&&s["aria-label"]!=null?new Error("MUI: You need to use the `getAriaLabel` prop instead of `aria-label` when using a range slider."):null),"aria-labelledby":n.PropTypes.string,"aria-valuetext":je.chainPropTypes(n.PropTypes.string,s=>Array.isArray(s.value||s.defaultValue)&&s["aria-valuetext"]!=null?new Error("MUI: You need to use the `getAriaValueText` prop instead of `aria-valuetext` when using a range slider."):null),children:n.PropTypes.node,classes:n.PropTypes.object,className:n.PropTypes.string,color:n.PropTypes.oneOfType([n.PropTypes.oneOf(["primary","secondary","error","info","success","warning"]),n.PropTypes.string]),components:n.PropTypes.shape({Input:n.PropTypes.elementType,Mark:n.PropTypes.elementType,MarkLabel:n.PropTypes.elementType,Rail:n.PropTypes.elementType,Root:n.PropTypes.elementType,Thumb:n.PropTypes.elementType,Track:n.PropTypes.elementType,ValueLabel:n.PropTypes.elementType}),componentsProps:n.PropTypes.shape({input:n.PropTypes.oneOfType([n.PropTypes.func,n.PropTypes.object]),mark:n.PropTypes.oneOfType([n.PropTypes.func,n.PropTypes.object]),markLabel:n.PropTypes.oneOfType([n.PropTypes.func,n.PropTypes.object]),rail:n.PropTypes.oneOfType([n.PropTypes.func,n.PropTypes.object]),root:n.PropTypes.oneOfType([n.PropTypes.func,n.PropTypes.object]),thumb:n.PropTypes.oneOfType([n.PropTypes.func,n.PropTypes.object]),track:n.PropTypes.oneOfType([n.PropTypes.func,n.PropTypes.object]),valueLabel:n.PropTypes.oneOfType([n.PropTypes.func,n.PropTypes.shape({children:n.PropTypes.element,className:n.PropTypes.string,open:n.PropTypes.bool,style:n.PropTypes.object,value:n.PropTypes.node,valueLabelDisplay:n.PropTypes.oneOf(["auto","off","on"])})])}),defaultValue:n.PropTypes.oneOfType([n.PropTypes.arrayOf(n.PropTypes.number),n.PropTypes.number]),disabled:n.PropTypes.bool,disableSwap:n.PropTypes.bool,getAriaLabel:n.PropTypes.func,getAriaValueText:n.PropTypes.func,marks:n.PropTypes.oneOfType([n.PropTypes.arrayOf(n.PropTypes.shape({label:n.PropTypes.node,value:n.PropTypes.number.isRequired})),n.PropTypes.bool]),max:n.PropTypes.number,min:n.PropTypes.number,name:n.PropTypes.string,onChange:n.PropTypes.func,onChangeCommitted:n.PropTypes.func,orientation:n.PropTypes.oneOf(["horizontal","vertical"]),scale:n.PropTypes.func,shiftStep:n.PropTypes.number,size:n.PropTypes.oneOfType([n.PropTypes.oneOf(["small","medium"]),n.PropTypes.string]),slotProps:n.PropTypes.shape({input:n.PropTypes.oneOfType([n.PropTypes.func,n.PropTypes.object]),mark:n.PropTypes.oneOfType([n.PropTypes.func,n.PropTypes.object]),markLabel:n.PropTypes.oneOfType([n.PropTypes.func,n.PropTypes.object]),rail:n.PropTypes.oneOfType([n.PropTypes.func,n.PropTypes.object]),root:n.PropTypes.oneOfType([n.PropTypes.func,n.PropTypes.object]),thumb:n.PropTypes.oneOfType([n.PropTypes.func,n.PropTypes.object]),track:n.PropTypes.oneOfType([n.PropTypes.func,n.PropTypes.object]),valueLabel:n.PropTypes.oneOfType([n.PropTypes.func,n.PropTypes.shape({children:n.PropTypes.element,className:n.PropTypes.string,open:n.PropTypes.bool,style:n.PropTypes.object,value:n.PropTypes.node,valueLabelDisplay:n.PropTypes.oneOf(["auto","off","on"])})])}),slots:n.PropTypes.shape({input:n.PropTypes.elementType,mark:n.PropTypes.elementType,markLabel:n.PropTypes.elementType,rail:n.PropTypes.elementType,root:n.PropTypes.elementType,thumb:n.PropTypes.elementType,track:n.PropTypes.elementType,valueLabel:n.PropTypes.elementType}),step:n.PropTypes.number,sx:n.PropTypes.oneOfType([n.PropTypes.arrayOf(n.PropTypes.oneOfType([n.PropTypes.func,n.PropTypes.object,n.PropTypes.bool])),n.PropTypes.func,n.PropTypes.object]),tabIndex:n.PropTypes.number,track:n.PropTypes.oneOf(["inverted","normal",!1]),value:n.PropTypes.oneOfType([n.PropTypes.arrayOf(n.PropTypes.number),n.PropTypes.number]),valueLabelDisplay:n.PropTypes.oneOf(["auto","off","on"]),valueLabelFormat:n.PropTypes.oneOfType([n.PropTypes.func,n.PropTypes.string])});const _t=({question:s,isDigitalWellbeingHabits:o=!1})=>{const[r,i]=q.useState(3),l=s.scaleLabels||["1","2","3","4","5"];return e.jsxs("div",{className:t["slider-group"],children:[e.jsx("div",{className:t["slider-header"],children:e.jsx("span",{children:s.text})}),e.jsx(ft,{value:r,min:1,max:5,step:1,onChange:(a,u)=>i(u),sx:o?Ut:dt}),e.jsx("div",{className:t["slider-labels-row"],children:l.map((a,u)=>e.jsx("span",{children:a},u))})]})},Co=[{key:"very_low",icon:rs.VeryLowIcon},{key:"low",icon:rs.LowIcon},{key:"normal",icon:rs.NormalIcon},{key:"high",icon:rs.HighIcon},{key:"very_high",icon:rs.VeryHighIcon}],Eo=({question:s})=>{const[o,r]=q.useState(null),i=s.scaleLabels||["Very Low","Low","Moderate","High","Very High"];return e.jsxs("div",{className:t["slider-group"],children:[e.jsx("div",{className:t["slider-header"],children:e.jsx("span",{children:s.text})}),e.jsx("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:"8px",padding:"4px 0"},children:Co.map((l,a)=>{const u=l.icon,c=o===a,y=i[a]||"";return e.jsxs("div",{onClick:()=>r(a),style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"6px",cursor:"pointer",flex:1,textAlign:"center"},children:[e.jsx("div",{style:{transform:c?"scale(1.18)":"scale(1)",transition:"transform 0.2s ease, filter 0.2s ease",filter:c?"drop-shadow(0px 4px 8px rgba(0,0,0,0.18))":"opacity(0.85)",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(u,{size:38})}),e.jsx("span",{style:{fontSize:"11px",fontWeight:c?600:500,color:c?"#101828":"#667085",lineHeight:"1.2",maxWidth:"70px"},children:y})]},a)})})]})},bt=({question:s})=>{const[o,r]=q.useState(null);return e.jsxs("div",{className:t["slider-group"],children:[e.jsx("div",{className:t["slider-header"],children:e.jsx("span",{children:s.text})}),e.jsx("div",{style:{display:"flex",gap:"12px",marginTop:"8px"},children:["Yes","No"].map(i=>{const l=o===i;return e.jsx("button",{type:"button",onClick:()=>r(i),style:{flex:1,padding:"10px 16px",borderRadius:"10px",border:l?"2px solid #316CD9":"1px solid #E5E7EB",backgroundColor:l?"#EFF6FF":"#FFFFFF",color:l?"#1E40AF":"#374151",fontWeight:l?600:500,fontSize:"14px",cursor:"pointer",transition:"all 0.2s ease"},children:i==="Yes"?"👍 Yes":"👎 No"},i)})})]})},rt={sad:{emoji:"😢",label:"Sad"},angry:{emoji:"😡",label:"Angry"},scared:{emoji:"😨",label:"Scared"},excited:{emoji:"🤩",label:"Excited"},calm:{emoji:"😌",label:"Calm"},happy:{emoji:"😃",label:"Happy"}},Do=({question:s})=>{const[o,r]=q.useState(null),l=(s.emotions&&s.emotions.length>0?s.emotions:qt).map(a=>{const u=a.toLowerCase();return rt[u]?rt[u]:{emoji:a,label:""}});return e.jsxs("div",{className:t["slider-group"],children:[e.jsx("div",{className:t["slider-header"],children:e.jsx("span",{children:s.text})}),e.jsx("div",{style:{display:"flex",justifyContent:"space-around",alignItems:"center",marginTop:"12px",padding:"4px 0"},children:l.map((a,u)=>{const c=o===u;return e.jsxs("div",{onClick:()=>r(u),style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"4px",cursor:"pointer"},children:[e.jsx("button",{type:"button",style:{fontSize:"28px",padding:"8px",borderRadius:"50%",border:c?"2px solid #56CCF2":"2px solid transparent",backgroundColor:c?"#E0F7FA":"transparent",cursor:"pointer",transform:c?"scale(1.2)":"scale(1)",transition:"all 0.2s ease",display:"flex",alignItems:"center",justifyContent:"center"},children:a.emoji}),a.label&&e.jsx("span",{style:{fontSize:"11px",color:c?"#101828":"#667085",fontWeight:c?600:500},children:a.label})]},u)})})]})},vt=({question:s})=>{const[o,r]=q.useState(null),i=s.options&&s.options.length>0?s.options:["Never","Rarely","Sometimes","Often","Always"];return e.jsxs("div",{className:t["mcq-box"],style:{width:"100%",marginBottom:"16px"},children:[e.jsx("h5",{className:t["mcq-question"],children:s.text}),e.jsx("div",{className:t["mcq-options-list"],children:i.map(l=>e.jsx("button",{type:"button",className:`${t["mcq-option-item"]} ${o===l?t.selected:""}`,onClick:()=>r(l),children:l},l))})]})},jt=({question:s})=>{const[o,r]=q.useState("");return e.jsxs("div",{className:t["slider-group"],children:[e.jsx("div",{className:t["slider-header"],children:e.jsx("span",{children:s.text})}),s.subName&&e.jsx("p",{style:{fontSize:"13px",color:"#667085",margin:"2px 0 6px 0"},children:s.subName}),e.jsx("textarea",{className:t["challenge-textarea"],style:{marginTop:"4px",minHeight:"80px"},placeholder:"Type your response here... (Preview simulation)",value:o,onChange:i=>r(i.target.value)})]})},Lo=({activeModuleIds:s})=>!s||s.length===0?null:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"20px"},children:s.map(o=>{const r=Is.find(l=>l.id===o),i=ct[o]||{displayTitle:o,iconColor:"#316CD9"};return r?e.jsxs("div",{className:`${t["preview-step-card"]} ${t["preview-step-card--purple"]}`,children:[e.jsxs("div",{className:t["card-header-purple"],style:{borderBottomColor:i.iconColor},children:[e.jsx("span",{className:t["purple-icon"],style:{color:i.iconColor},children:"🧠"}),e.jsx("h4",{className:t["purple-title"],children:i.displayTitle})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"16px",marginTop:"12px"},children:r.questions.map(l=>{const a={id:l.id,text:l.text,type:l.type,options:l.options};return l.type==="mcq"?e.jsx(vt,{question:a},l.id):l.type==="scale"?e.jsx(_t,{question:a,isDigitalWellbeingHabits:o==="digital_wellbeing"},l.id):l.type==="yes_no"?e.jsx(bt,{question:a},l.id):e.jsx(jt,{question:a},l.id)})})]},o):null})}),Mo=({config:s,journeys:o=[],onNext:r})=>{const[i,l]=q.useState(""),a=()=>{if(o.length>0){const g=o.find(M=>M.isEnabled);if(g&&g.strategicIntent)return g.strategicIntent}const y=s.journeys.themes[0]||"world_wonder",m=Rs.find(g=>g.id===y);return m?m.prompt:"Tell us something about your day!"},c=(()=>{if(o.length>0){const g=o.find(M=>M.isEnabled);if(g)return{name:g.name,emoji:"🌏"}}const y=s.journeys.themes[0]||"world_wonder",m=Rs.find(g=>g.id===y);if(m){let g="🌏";return(m.id==="pop_art"||m.id==="pop_and_art")&&(g="🎨"),m.id==="music"&&(g="🎵"),m.id==="sports"&&(g="⚽"),m.id==="technology"&&(g="💻"),m.id==="community_cosmos"&&(g="🤝"),{name:m.title,emoji:g}}return{name:"World Wanderer",emoji:"🌏"}})();return e.jsxs("div",{className:t["preview-challenge-card"],children:[e.jsxs("h4",{className:t["challenge-title"],children:["Daily Challenge for ",e.jsx("span",{className:t["challenge-emoji"],children:c.emoji})," ",c.name]}),e.jsxs("div",{className:t["challenge-inner-card"],children:[e.jsx("h5",{className:t["challenge-question"],children:a()}),e.jsx("textarea",{className:t["challenge-textarea"],placeholder:"Share your thoughts here... There are no wrong answers!",value:i,onChange:y=>l(y.target.value)}),e.jsxs("p",{className:t["challenge-footer-text"],children:["Your thoughts matter. Take your time! ",e.jsx("span",{className:t.heart,children:"💚"})]}),e.jsx("div",{className:t["challenge-button-wrapper"],children:e.jsx("button",{className:t["btn-submit-xp"],onClick:r,children:"✨ SUBMIT & EARN +5 XP"})})]})]})},Io=({config:s,journeys:o=[],checkInQuestionsMap:r,activeTab:i="elementary",onClose:l})=>{const a=s.grades.elementary,u=s.grades.middle_school,c=s.grades.high_school,y=!u&&!c&&s.grades.secondary,m=q.useMemo(()=>{const j=[];return a&&j.push("elementary"),u&&j.push("middle_school"),c&&j.push("high_school"),y&&j.push("secondary"),j},[a,u,c,y]),[g,M]=q.useState(()=>m.includes(i)?i:m[0]||"elementary"),F=ks(s.system),R=q.useMemo(()=>Yn(s,r,g),[s,r,g]),z=q.useMemo(()=>{const j=[];return s.modules.ai_literacy&&j.push("ai_literacy"),s.modules.bullying&&j.push("bullying"),s.modules.digital_wellbeing&&j.push("digital_wellbeing"),j},[s.modules]),P=q.useMemo(()=>{const j=["routine"];return z.length>0&&j.push("modules"),(o.length>0?o.filter(A=>A.isEnabled).length:s.journeys.themes.length)>0&&j.push("journey"),j.push("success"),j},[z,s.journeys.themes.length,o]),[te,ne]=q.useState(0),p=P[te]||"routine",N=()=>{te<P.length-1&&ne(j=>j+1)};return e.jsx("div",{className:t["preview-modal-overlay"],children:e.jsxs("div",{className:`${t["preview-modal-content"]} ${p==="success"?t["preview-modal-content--success"]:""}`,children:[e.jsx("button",{className:t["close-preview-btn-dialog"],onClick:l,children:e.jsx(ns.CloseIcon,{})}),p!=="success"&&e.jsxs("div",{className:t["preview-header"],children:[e.jsx("h3",{className:t["preview-title"],children:p==="journey"?"Student Journey Preview":"Student Check-in Preview"}),e.jsxs("p",{className:t["preview-page-indicator"],children:["Page ",te+1," of ",P.length-1]})]}),e.jsxs("div",{className:t["preview-body-container"],children:[p==="routine"&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:[m.length>1&&e.jsx("div",{style:{display:"flex",gap:"10px",marginBottom:"4px"},children:m.map(j=>{const I=F[j],A=g===j;return e.jsxs("button",{type:"button",onClick:()=>M(j),style:{padding:"8px 16px",borderRadius:"20px",border:A?"2px solid #2F80ED":"1px solid #E5E7EB",backgroundColor:A?"#EFF6FF":"#FFFFFF",color:A?"#1D4ED8":"#4B5563",fontWeight:A?600:500,fontSize:"13px",cursor:"pointer",display:"flex",alignItems:"center",gap:"6px",transition:"all 0.2s ease"},children:[e.jsx("span",{children:I.emoji}),e.jsx("span",{children:I.label})]},j)})}),R.map(j=>e.jsxs("div",{className:t["preview-step-card"],children:[e.jsx("h4",{className:t["step-card-title"],children:j.title}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:j.questions.map(I=>I.type==="scale"?g==="elementary"?e.jsx(Eo,{question:I},I.id):e.jsx(_t,{question:I},I.id):I.type==="emoji"?e.jsx(Do,{question:I},I.id):I.type==="yes_no"?e.jsx(bt,{question:I},I.id):I.type==="mcq"?e.jsx(vt,{question:I},I.id):e.jsx(jt,{question:I},I.id))})]},j.title))]}),p==="modules"&&e.jsx(Lo,{activeModuleIds:z}),p==="journey"&&e.jsx(Mo,{config:s,journeys:o,onNext:N}),p==="success"&&e.jsxs("div",{className:t["preview-success-card"],children:[e.jsxs("h3",{className:t["success-title"],children:["Amazing Work! ",e.jsx("span",{className:t.confetti,children:"🎉"})]}),e.jsx("p",{className:t["success-subtitle"],children:"Your check-in has been submitted!"}),e.jsxs("p",{className:t["success-xp-text"],children:["You earned ",e.jsx("span",{className:t["xp-hl"],children:"+10 XP"})]}),e.jsx("div",{className:t["success-box-green"],children:"Thank you for sharing your thoughts today! 💚"}),e.jsx("button",{className:t["btn-thanks-large"],onClick:l,children:"Thanks"})]})]}),p!=="success"&&p!=="journey"&&e.jsx("div",{className:t["preview-footer-buttons"],children:e.jsx("button",{className:t["btn-next"],onClick:N,children:"Next"})})]})})},Ro=({open:s,onClose:o,title:r})=>e.jsxs(Pe.Dialog,{open:s,onClose:o,disableEnforceFocus:!0,disableRestoreFocus:!0,PaperProps:{className:ve.styles["dialog-paper"]},maxWidth:"xs",children:[e.jsx(Pe.IconButton,{onClick:o,className:ve.styles["close-button"],children:e.jsx(ns.CloseIcon,{})}),e.jsxs("div",{className:ve.styles["modal-container"],children:[e.jsx("div",{className:ve.styles["success-circle"],children:e.jsx(ts.CheckIcon,{className:ve.styles["success-check-icon"]})}),e.jsx("h2",{className:ve.styles["modal-title"],children:"Message Sent!"}),e.jsxs("p",{className:ve.styles["modal-description"],children:["Thank you for your interest in ",r,". Our success team will contact you back shortly to help you get started."]}),e.jsxs("div",{className:ve.styles["whats-next-box"],children:[e.jsx("h3",{className:ve.styles["whats-next-title"],children:"What's next?"}),e.jsxs("p",{className:ve.styles["whats-next-text"],children:["One of our team members will reach out within 24 hours to discuss adding ",r," to your package."]})]}),e.jsx("button",{onClick:o,className:ve.styles["contact-button"],children:"Got it, thanks!"})]})]}),Oo=({open:s,onClose:o,title:r,description:i,includedItems:l,feature:a})=>{const u=Ls.useDispatch(),[c,y]=q.useState(!1),m=async()=>{u(fe.setLoading(!0));let g=!1;try{await ve.sendEmailUnlockFeatureToSuccessTeamApi(a)&&(g=!0,y(!0))}catch(M){u(fe.setAlert({type:"error",message:M?.message||"Failed to send message. Please try again."}))}u(fe.setLoading(!1)),g||o()};return c?e.jsx(Ro,{open:s,onClose:()=>{y(!1),o()},title:a}):e.jsxs(Pe.Dialog,{open:s,onClose:o,disableEnforceFocus:!0,disableRestoreFocus:!0,PaperProps:{className:ve.styles["dialog-paper"]},children:[e.jsx(Pe.IconButton,{onClick:o,className:ve.styles["close-button"],children:e.jsx(ns.CloseIcon,{})}),e.jsxs("div",{className:ve.styles["modal-container"],children:[e.jsx("div",{className:ve.styles["lock-circle"],children:e.jsx(ve.LockIcon,{color:"white",size:32})}),e.jsx("h2",{className:ve.styles["modal-title"],children:r}),e.jsx("p",{className:ve.styles["modal-description"],children:i}),e.jsxs("div",{className:ve.styles["included-box"],children:[e.jsx("h3",{className:ve.styles["included-title"],children:"What's Included:"}),l.map((g,M)=>e.jsxs("div",{className:ve.styles["included-item"],children:[e.jsx(ts.CheckIcon,{className:ve.styles["check-icon"]}),e.jsx("span",{className:ve.styles["included-text"],children:g})]},M))]}),e.jsx("button",{onClick:m,className:ve.styles["contact-button"],children:"Contact Success Team"}),e.jsx("p",{className:ve.styles["helper-text"],children:"Our team will help you unlock this feature for your campus"})]})]})},$o=n.createSvgIcon(e.jsx("path",{d:"M8.59 16.59 13.17 12 8.59 7.41 10 6l6 6-6 6z"}),"KeyboardArrowRight"),Ao=n.styled$1(Pe.StepConnector)(()=>({[`&.${Pe.stepConnectorClasses.alternativeLabel}`]:{top:13},[`&.${Pe.stepConnectorClasses.active}`]:{[`& .${Pe.stepConnectorClasses.line}`]:{borderColor:Vs}},[`&.${Pe.stepConnectorClasses.completed}`]:{[`& .${Pe.stepConnectorClasses.line}`]:{borderColor:Vs}},[`& .${Pe.stepConnectorClasses.line}`]:{borderTopWidth:2,borderColor:Qt}})),Fo=({active:s,completed:o})=>o?e.jsx("div",{className:t["step-icon-completed"],children:e.jsx(ts.CheckIcon,{className:t["step-icon-check-completed"]})}):s?e.jsx("div",{className:t["step-icon-active"],children:e.jsx("div",{className:t["step-icon-active-inner"]})}):e.jsx("div",{className:t["step-icon-inactive"]}),Qo=()=>{const{activeStep:s,config:o,previewOpen:r,setPreviewOpen:i,upgradeModalOpen:l,setUpgradeModalOpen:a,onChangeSystem:u,onToggleGrade:c,onChangeRoutineLogic:y,onChangeRoutineSchedule:m,onAddCustomQuestion:g,onRemoveCustomQuestion:M,onEditCustomQuestion:F,onToggleModule:R,nextStep:z,prevStep:P,completeSetup:te,resetSetup:ne,journeys:p,hasSingleJourneyEnabled:N,handleToggleJourney:j,handleToggleGrade:I,checkInQuestionsMap:A,apiState:Q,activeTab:ce,onTabChange:ge,onToggleQuestionPin:Y,onToggleQuestionEnable:B,setActiveStep:w,onReorderClusters:J,onUpdateModuleConfig:me,hasEsSchool:ee,isAdminEs:f,isAdminMs:$}=Xt(),W=[{num:1,title:"Grade Levels"},{num:2,title:"Routine Check-in"},{num:3,title:"Modules"},{num:4,title:"Journeys"}];return e.jsxs("div",{className:t["checkin-setup-container"],children:[s!==5&&e.jsx("div",{className:t["stepper-wrapper"],children:e.jsx(Pe.Stepper,{activeStep:s-1,alternativeLabel:!0,connector:e.jsx(Ao,{}),children:W.map(se=>{const X=se.num<s,H=se.num===s;return e.jsx(Pe.Step,{children:e.jsxs(Pe.StepLabel,{StepIconComponent:Fo,children:[e.jsxs("span",{className:t["step-label-sub"],children:["STEP ",se.num]}),e.jsx("span",{className:`${t["step-label-title"]} ${X?t.completed:H?t.active:""}`,children:se.title})]})},se.num)})})}),e.jsx("div",{className:t["setup-wizard-layout"],children:e.jsxs("div",{className:t["content-card"],children:[e.jsxs("div",{className:t["step-content-wrapper"],children:[s===1&&e.jsx(On,{config:o,onChangeSystem:u,onToggleGrade:c,onOpenUpgradeModal:()=>a(!0),isEarlyYearsEnabled:Q.isEarlyYearsEnabled,hasEsSchool:ee,isAdminEs:f,isAdminMs:$}),s===2&&e.jsx(Kn,{config:o,onChangeRoutineLogic:y,onChangeRoutineSchedule:m,onAddCustomQuestion:g,onRemoveCustomQuestion:M,onEditCustomQuestion:F,checkInQuestionsMap:A,activeTab:ce,onTabChange:ge,onToggleQuestionPin:Y,onToggleQuestionEnable:B,onReorderClusters:J,isAdminEs:f,isAdminMs:$}),s===3&&e.jsx(to,{config:o,onToggleModule:R,checkInQuestionsMap:A,activeTab:ce,onUpdateModuleConfig:me,isAdminEs:f,isAdminMs:$}),s===4&&e.jsx(no,{config:o,journeys:p,onToggleJourney:j,onToggleGrade:I,hasSingleJourneyEnabled:N,isAdminEs:f,isAdminMs:$}),s===5&&e.jsx(lo,{config:o,journeys:p,checkInQuestionsMap:A,isAdminEs:f,isAdminMs:$,onPreviewOpen:()=>i(!0),onBackToDashboard:ne,onEditStep:w})]}),s<=4&&e.jsxs("div",{className:t["navigation-footer"],children:[s!==1?e.jsxs("button",{className:t["btn-secondary"],onClick:P,disabled:s===1,children:[e.jsx(Et.ArrowBackIcon,{})," Back"]}):e.jsx("div",{}),s===4?e.jsxs("button",{className:t["btn-success"],onClick:te,disabled:N,children:[e.jsx(ts.CheckIcon,{})," Complete Setup"]}):e.jsxs("button",{className:t["btn-primary"],onClick:z,disabled:s===1?!(f&&o.grades.elementary)&&!($&&o.grades.secondary):!o.grades.elementary&&!o.grades.secondary,children:["Continue ",e.jsx($o,{})]})]})]})}),r&&e.jsx(Io,{config:o,journeys:p,checkInQuestionsMap:A,activeTab:ce,onClose:()=>i(!1)}),e.jsx(Oo,{open:l,onClose:()=>a(!1),...Ft})]})};exports.default=Qo;