mario-education 2.0.180-staging → 2.0.182-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 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),C=require("react"),t=require("@mui/material"),oe=require("react-redux"),_e=require("react-router-dom"),ge=require("moment"),z=require("mario-core"),pe=require("./surveyService-BKooa1m-.cjs"),Qe=require("./questionCategoryService-CjXNe6xV.cjs"),Te=require("./ArrowBack-C4WIF8bZ.cjs"),Ce=require("./Check-CYAVgIcj.cjs"),be=require("./ArrowForward-D4TtLiX5.cjs"),te=require("./createSvgIcon-CRp0VXvr.cjs"),Se=require("./Add-DE-4A91A.cjs"),xe=require("@mui/x-date-pickers"),Oe=require("./AdapterMoment-B-q0UCj0.cjs"),Ge=require("./Search-CZp6DUOA.cjs"),Ye=require("./Close-BqvQ2Wpz.cjs"),he=require("./MultiChoiceComponent-BUoQ4vbg.cjs"),re=[{stepNumber:1,stepCode:"CHOOSE_TEMPLATE",label:"Choose Template"},{stepNumber:2,stepCode:"CHECK_DETAILS",label:"Check Details"},{stepNumber:3,stepCode:"CREATE_SURVEY",label:"Create Survey"},{stepNumber:4,stepCode:"SELECT_STUDENTS",label:"Select Students"},{stepNumber:5,stepCode:"REVIEW_PUBLISH",label:"Review & Publish"}],$e=["All","School Climate","Well-being","Health & Wellness"],Ue=[{id:1,title:"Stress",description:"Assess stress levels and identify stressors affecting students",questionCount:13,category:"Well-being"},{id:2,title:"Grows",description:"Measure student growth mindset and learning attitudes",questionCount:6,category:"School Climate"},{id:3,title:"Climate Survey",description:"Evaluate overall school climate and student experiences",questionCount:9,category:"School Climate"},{id:4,title:"Happiness",description:"Track student happiness and emotional well-being",questionCount:8,category:"Well-being"},{id:5,title:"Climate Survey: Connections with Adults & Peers",description:"Assess the quality of relationships with adults and peers in school",questionCount:14,category:"School Climate"},{id:6,title:"Climate Survey: Holistic Learning Experiences",description:"Evaluate overall school climate and student experiences",questionCount:18,category:"Well-being"},{id:7,title:"Climate Survey: My Health and Well-being",description:"Monitor student physical and mental health and wellness",questionCount:21,category:"Health & Wellness"},{id:8,title:"Well-being",description:"General assessment of student wellness and quality of life",questionCount:10,category:"Well-being"}],Ve=a=>{const l=oe.useDispatch(),c=_e.useNavigate(),d=oe.useSelector(n=>n?.common?.language||"en"),[r,i]=C.useState(a?.activeStep??0),[h,m]=C.useState(a?.selectedCategory??"All"),[o,T]=C.useState(a?.selectedTemplateId??null),[b,u]=C.useState(Ue),[x,L]=C.useState(!1),[E,_]=C.useState(a?.editingTemplate??null),N=C.useCallback(async()=>{try{L(!0),l(z.setLoading(!0));const n=await pe.getTemplateSurvey(d);if(n?.data&&Array.isArray(n.data)&&n.data.length>0){const w=n.data.map(v=>{let F="Well-being";const B=(v.name||"").toLowerCase();return B.includes("climate")||B.includes("grow")?F="School Climate":B.includes("health")&&(F="Health & Wellness"),{id:v.id,title:v.name,description:v.description,questionCount:v.numberQuestion??v.questionTemplates?.length??0,category:F,rawTemplate:v}});u(w),a?.selectedTemplateId||T(v=>v||(w.length>0?w[0].id:null))}}catch(n){console.error("Error fetching survey templates:",n),l(z.setAlert({type:"danger",message:n?.message||"Failed to fetch survey templates"}))}finally{L(!1),l(z.setLoading(!1))}},[d,l]);C.useEffect(()=>{N()},[N]);const S=C.useMemo(()=>{const n=new Set;return b.forEach(w=>{w.category&&n.add(w.category)}),n.size===0?$e:["All",...Array.from(n)]},[b]),g=C.useMemo(()=>h==="All"?b:b.filter(n=>n.category.toLowerCase()===h.toLowerCase()),[b,h]),D=C.useMemo(()=>b.find(n=>n.id===o)||null,[b,o]),I=n=>{m(n)},G=n=>{T(n)},H=()=>{T("BLANK"),i(n=>Math.min(n+1,re.length-1))},Y=(n,w)=>{w.stopPropagation(),_(n)},Q=()=>{_(null)},$=async n=>{try{l(z.setLoading(!0));const w=n.rawTemplate?.questionTemplates?.map(B=>B.questionId||B.id)?.filter(B=>typeof B=="number"||!String(B).startsWith("q-"))?.map(B=>Number(B))||[],v={id:n.id,name:n.title,description:n.description,isFavorite:n.rawTemplate?.isFavorite??!1,questionIds:w};await Qe.updateSurvey(v),u(B=>B.map(W=>W.id===n.id?n:W)),_(null);const F=localStorage.getItem("create_survey_draft");if(F)try{const B=JSON.parse(F);B.editingTemplateFormData&&(delete B.editingTemplateFormData,localStorage.setItem("create_survey_draft",JSON.stringify(B)))}catch{}l(z.setAlert({type:"success",message:"Update template successfully"}))}catch(w){l(z.setAlert({type:"danger",message:w.response?.data?.title||"Update template failed"}))}finally{l(z.setLoading(!1))}},O=()=>{c("/admin/survey-dashboard/list-survey")};return{steps:re,activeStep:r,categories:S,selectedCategory:h,selectedTemplateId:o,selectedTemplate:D,templates:g,rawTemplates:b,isLoading:x,editingTemplate:E,handleSelectCategory:I,handleSelectTemplate:G,handleCreateBlankSurvey:H,handleEditTemplate:Y,handleCloseEditTemplate:Q,handleSaveEditTemplate:$,handleGoBackToDashboard:O,handlePreviousStep:()=>{r>0?i(n=>n-1):O()},handleNextStep:()=>{r<re.length-1&&i(n=>n+1)},handleGoToStep:n=>{n>=0&&n<re.length&&i(n)},refetchTemplates:N}},me=(a,l)=>!a||!Array.isArray(a)||a.length===0?[]:a.map((c,d)=>({id:c.questionId??c.id??`q-${d+1}`,orderNumber:c.orderDefaultQuestionTemplate??d+1,questionText:c.questionText??c.text??`Question ${d+1}`,type:String(c.type||"Text"),category:c.category??c.categoryName??c.categoryTitle??c.title??l??"General",options:c.answers?.map(r=>r.text)||[],numberOfStars:c.numberOfStars??5,fromLabel:c.fromLabel,toLabel:c.toLabel})),fe=[{id:"q-1",orderNumber:1,questionText:"How would you rate your overall well-being?",type:"Rating",category:"Overall Well-being"},{id:"q-2",orderNumber:2,questionText:"Do you feel balanced in your daily life?",type:"YesNo",category:"Life Balance"},{id:"q-3",orderNumber:3,questionText:"What contributes most to your well-being?",type:"Text",category:"Well-being Factors"},{id:"q-4",orderNumber:4,questionText:"How satisfied are you with your life?",type:"Rating",category:"Life Satisfaction"},{id:"q-5",orderNumber:5,questionText:"Do you have people who support you?",type:"YesNo",category:"Social Support"}],Ke=(a,l,c)=>{const d=C.useMemo(()=>{const _=l?.rawTemplate?.questionTemplates,N=me(_,l?.category||"Well-being");return N.length>0?N:fe},[l]),[r,i]=C.useState(()=>c?.step2FormData?c.step2FormData:a==="BLANK"?{templateName:"",description:"",showLandingPageFlag:!1,questions:[],selectedCategoryFilter:"All"}:{templateName:l?.title||"Well-being",description:l?.description||"General assessment of student wellness and quality of life",showLandingPageFlag:!1,questions:d,selectedCategoryFilter:"All"}),h=C.useRef(c?.selectedTemplateId??(a==="BLANK"?"BLANK":l?l.id:null));C.useEffect(()=>{if(l){if(h.current===l.id)return;h.current=l.id;const _=l.rawTemplate?.questionTemplates,N=me(_,l.category||"Well-being");i(S=>({...S,templateName:l.title||"",description:l.description||"",questions:N.length>0?N:S.questions.length>0?S.questions:fe,selectedCategoryFilter:"All"}))}else if(a==="BLANK"){if(h.current==="BLANK")return;h.current="BLANK",i(_=>({..._,templateName:"",description:"",questions:[],selectedCategoryFilter:"All"}))}},[l,a]);const m=C.useMemo(()=>{const _=new Set;r.questions.forEach(S=>{const g=S.category?.trim();g&&_.add(g)});const N=Array.from(_);return N.length>0?["All",...N]:["All"]},[r.questions]),o=C.useMemo(()=>r.selectedCategoryFilter==="All"?r.questions:r.questions.filter(_=>_.category===r.selectedCategoryFilter),[r.questions,r.selectedCategoryFilter]),T=_=>{i(N=>({...N,templateName:_}))},b=_=>{i(N=>({...N,description:_}))},u=_=>{i(N=>({...N,selectedCategoryFilter:_}))},x=_=>{console.log("Edit question:",_)},L=_=>{i(N=>({...N,questions:N.questions.filter(S=>S.id!==_).map((S,g)=>({...S,orderNumber:g+1}))}))},E=()=>{const _=`q-${Date.now()}`,N=r.questions.length+1,S={id:_,orderNumber:N,questionText:"New Question",type:"Rating",category:"General"};i(g=>({...g,questions:[...g.questions,S]}))};return{formData:r,questionCategories:m,filteredQuestions:o,totalQuestionsCount:r.questions.length,handleTemplateNameChange:T,handleDescriptionChange:b,handleCategoryFilterChange:u,handleEditQuestion:x,handleRemoveQuestion:L,handleAddQuestion:E}},Je=(a,{initialTitle:l="",initialDeadline:c=ge().add(1,"days").format("DD.MM.YYYY hh:mm A")}={})=>{const[d,r]=C.useState(()=>a?.step3FormData?a.step3FormData:{title:l||"",deadline:c||""});return{formData:d,handleTitleChange:m=>{r(o=>({...o,title:m}))},handleDeadlineChange:m=>{r(o=>({...o,deadline:m}))}}},Ze=z.getStaticFileUrl("/images/image-default.png"),Xe=[{label:"All Flags",value:"all"},{label:"Red Flag",value:"red"},{label:"Yellow Flag",value:"yellow"},{label:"Green Flag",value:"green"}],et=a=>{const[l,c]=C.useState([]),[d,r]=C.useState(a?.selectedStudentIds??[]),[i,h]=C.useState([]),[m,o]=C.useState(Xe),[T,b]=C.useState([]),[u,x]=C.useState({searchQuery:"",selectedGrade:"All Grades",selectedFlag:"all",selectedTeacher:"All Teachers",page:0,rowsPerPage:10,sortBy:"name",sortOrder:"asc"}),L=C.useCallback(async()=>{try{const f=await pe.searchStudents({roles:["Admin"]});if(f?.data?.items&&Array.isArray(f.data.items)&&f.data.items.length>0){const y=f.data.items.map(p=>{let R="none";if(typeof p.flag=="string"){const J=p.flag.toLowerCase();J.includes("red")?R="red":J.includes("yellow")?R="yellow":J.includes("green")&&(R="green")}else p.redFlags>0||p.flag===1?R="red":p.yellowFlags>0||p.flag===2?R="yellow":(p.greenFlags>0||p.flag===3)&&(R="green");const M=p.fullName||p.studentName,ie=p.gradeLevel,ce=p.email,ae=p.userId||(typeof p.id=="string"?p.id:""),K=typeof p.studentId=="number"?p.studentId:typeof p.id=="number"?p.id:void 0,de=ae||(K!==void 0?String(K):`student-${Math.random()}`),ue=(p.schoolLevel||(p.userId&&p.id===void 0?"ES":"MS")).toUpperCase();return{id:de,userId:ae,studentId:K,schoolLevel:ue,name:M,avatarUrl:p.profileImageFileName?z.getFileUrl(p.profileImageFileName):Ze,flag:R,flagTooltip:p.flagTooltip||void 0,flagDetail:p.flagDetail,lastSafetyAnswer:p.lastSafetyAnswer,lastStressAnswer:p.lastStressAnswer,flagSessionId:p.flagSessionId,flagSessionResultId:p.flagSessionResultId,grade:ie,email:ce,listTeachers:p.listTeachers||[]}});c(y);const n=Array.from(new Set(y.map(p=>p.grade))).filter(p=>p&&p!=="N/A"),w=p=>{if(!p||p==="N/A")return-999;const R=p.toString().toUpperCase().replace(/TH|RD|ND|ST/g,"").trim();if(R==="PK")return-2;if(R==="K")return-1;if(R==="G")return 0;const M=R.match(/^(\d+)/);return M?parseInt(M[1],10):999};n.sort((p,R)=>w(p)-w(R)),h(["All Grades",...n]);const v=Array.from(new Set(y.map(p=>p.flag))),F=[{label:"All Flags",value:"all"}];v.includes("red")&&F.push({label:"Red Flag",value:"red"}),v.includes("yellow")&&F.push({label:"Yellow Flag",value:"yellow"}),v.includes("green")&&F.push({label:"Green Flag",value:"green"}),o(F);const B=new Set;y.forEach(p=>{p.listTeachers&&p.listTeachers.length>0&&p.listTeachers.forEach(R=>{R.name&&B.add(R.name.trim())})});const W=Array.from(B).sort((p,R)=>p.localeCompare(R));b(["All Teachers",...W])}}catch(f){console.error("Error fetching students list:",f)}},[]);C.useEffect(()=>{L()},[L]);const E=f=>{x(y=>({...y,searchQuery:f,page:0}))},_=f=>{x(y=>({...y,selectedGrade:f,page:0}))},N=f=>{x(y=>({...y,selectedFlag:f,page:0}))},S=f=>{x(y=>({...y,selectedTeacher:f,page:0}))},g=(f,y)=>{x(n=>({...n,page:y}))},D=f=>{x(y=>({...y,rowsPerPage:parseInt(f.target.value,10),page:0}))},I=C.useMemo(()=>l.filter(f=>{if(u.searchQuery.trim()){const y=F=>(F||"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase(),n=y(u.searchQuery.trim()),w=y(f.name).includes(n),v=y(f.email).includes(n);if(!w&&!v)return!1}return!(u.selectedGrade!=="All Grades"&&(f.grade||"").toLowerCase()!==(u.selectedGrade||"").toLowerCase()||u.selectedFlag!=="all"&&f.flag!==u.selectedFlag||u.selectedTeacher!=="All Teachers"&&(!f.listTeachers||f.listTeachers.length===0||!f.listTeachers.some(n=>n.name&&n.name.trim()===u.selectedTeacher)))}),[l,u]),G=f=>{x(y=>({...y,sortBy:f,sortOrder:y.sortBy===f&&y.sortOrder==="asc"?"desc":"asc"}))},H=C.useMemo(()=>[...I].sort((y,n)=>{let w=y[u.sortBy],v=n[u.sortBy];if(u.sortBy==="flag"){const F={red:3,yellow:2,green:1,none:0};w=F[y.flag]||0,v=F[n.flag]||0}else if(u.sortBy==="grade"){const F=B=>{if(!B||B==="N/A")return-999;const W=B.toString().toUpperCase().replace(/TH|RD|ND|ST/g,"").trim();if(W==="PK")return-2;if(W==="K")return-1;if(W==="G")return 0;const p=W.match(/^(\d+)/);return p?parseInt(p[1],10):999};w=F(y.grade),v=F(n.grade)}else u.sortBy==="teacher"?(w=y.listTeachers&&y.listTeachers.length>0?y.listTeachers.map(F=>F.name).join(", ").toLowerCase():"",v=n.listTeachers&&n.listTeachers.length>0?n.listTeachers.map(F=>F.name).join(", ").toLowerCase():""):typeof w=="string"&&typeof v=="string"&&(w=w.toLowerCase(),v=v.toLowerCase());return w<v?u.sortOrder==="asc"?-1:1:w>v?u.sortOrder==="asc"?1:-1:0}),[I,u.sortBy,u.sortOrder]),Y=C.useMemo(()=>{const f=u.page*u.rowsPerPage;return H.slice(f,f+u.rowsPerPage)},[H,u.page,u.rowsPerPage]),Q=C.useMemo(()=>I.length===0?!1:I.every(f=>d.includes(f.id)),[I,d]),$=C.useMemo(()=>{if(I.length===0)return!1;const f=I.filter(y=>d.includes(y.id));return f.length>0&&f.length<I.length},[I,d]),O=()=>{if(Q){const f=I.map(y=>y.id);r(y=>y.filter(n=>!f.includes(n)))}else{const f=new Set([...d,...I.map(y=>y.id)]);r(Array.from(f))}},U=f=>{r(y=>y.includes(f)?y.filter(n=>n!==f):[...y,f])};return{students:Y,allFilteredStudents:I,totalStudentsCount:I.length,totalSelectedCount:d.length,selectedStudentIds:d,filters:u,gradeOptions:i,flagOptions:m,teacherOptions:T,isAllSelected:Q,isIndeterminate:$,handleSortChange:G,handleSearchChange:E,handleGradeFilterChange:_,handleFlagFilterChange:N,handleTeacherFilterChange:S,handlePageChange:g,handleRowsPerPageChange:D,handleToggleSelectAll:O,handleToggleStudent:U}},tt="_createSurveyPage_254g3_1",st="_headerTopBar_254g3_16",at="_contentBody_254g3_28",nt="_stepperContainer_254g3_39",lt="_backButton_254g3_44",rt="_stepperProgress_254g3_58",ot="_stepColumn_254g3_66",it="_stepColumnLast_254g3_72",ct="_stepCircleRow_254g3_77",dt="_stepCircle_254g3_77",ut="_active_254g3_96",ht="_completed_254g3_100",mt="_stepConnectorLine_254g3_105",gt="_stepLabelStack_254g3_115",pt="_stepInnerDot_254g3_119",xt="_stepNumberLabel_254g3_133",ft="_stepTextLabel_254g3_145",yt="_chooseTemplateCard_254g3_157",_t="_headerSection_254g3_173",Tt="_headerTitle_254g3_177",Ct="_headerSubtitle_254g3_192",bt="_bannerContainer_254g3_199",St="_bannerIconBox_254g3_219",jt="_bannerTitle_254g3_228",Nt="_bannerSubtitle_254g3_235",vt="_bannerActionBtn_254g3_240",wt="_sectionTitle_254g3_258",Bt="_filterPillsContainer_254g3_266",Ft="_filterPill_254g3_266",It="_templateCard_254g3_301",At="_selected_254g3_319",Rt="_templateCardTitle_254g3_324",Lt="_templateEditBtn_254g3_332",kt="_templateDescription_254g3_346",Et="_chipItem_254g3_353",qt="_wizardFooter_254g3_367",Dt="_previousBtn_254g3_387",Pt="_disabled_254g3_409",Ht="_stepCounterText_254g3_427",zt="_nextBtn_254g3_433",Wt="_editTemplateHeaderSection_254g3_453",Mt="_editTemplateCancelBtn_254g3_460",Qt="_editTemplateSaveBtn_254g3_472",Ot="_templateCategorySelect_254g3_495",Gt="_formFieldBlock_254g3_514",Yt="_formFieldLabel_254g3_520",$t="_requiredAsterisk_254g3_528",Ut="_customTextField_254g3_532",Vt="_formFieldHelperText_254g3_549",Kt="_questionsHeaderSection_254g3_577",Jt="_questionsTitle_254g3_585",Zt="_questionsCountNumber_254g3_591",Xt="_filterByRow_254g3_597",es="_filterByLabel_254g3_605",ts="_categoryFilterFormControl_254g3_611",ss="_categorySelectInput_254g3_615",as="_tableContainerWrapper_254g3_633",ns="_questionsTable_254g3_641",ls="_tableHeaderRow_254g3_646",rs="_tableBodyRow_254g3_659",os="_thNumber_254g3_673",is="_tdNumber_254g3_674",cs="_thQuestion_254g3_683",ds="_tdQuestion_254g3_684",us="_questionText_254g3_690",hs="_thType_254g3_709",ms="_tdType_254g3_710",gs="_thCategory_254g3_716",ps="_tdCategory_254g3_717",xs="_categoryText_254g3_723",fs="_thActions_254g3_730",ys="_tdActions_254g3_731",_s="_questionTypeBadge_254g3_737",Ts="_badgeTextLabel_254g3_747",Cs="_badgeRating_254g3_753",bs="_badgeYesNo_254g3_760",Ss="_badgeText_254g3_747",js="_tableEditBtn_254g3_781",Ns="_tableRemoveBtn_254g3_796",vs="_addQuestionWrapper_254g3_811",ws="_addQuestionBtn_254g3_819",Bs="_selectedCountSection_254g3_838",Fs="_selectedCountText_254g3_843",Is="_selectedCountHighlight_254g3_849",As="_studentsToolbar_254g3_855",Rs="_searchBarContainer_254g3_863",Ls="_studentSearchInput_254g3_868",ks="_filterDropdownWrapper_254g3_894",Es="_filterSelectBox_254g3_898",qs="_studentsTableContainer_254g3_924",Ds="_studentsTable_254g3_924",Ps="_studentsTableHeaderRow_254g3_938",Hs="_checkboxHeaderCell_254g3_949",zs="_tableHeaderCell_254g3_957",Ws="_checkboxBodyCell_254g3_973",Ms="_studentTableRow_254g3_981",Qs="_selectedRow_254g3_988",Os="_studentNameCell_254g3_995",Gs="_studentNameText_254g3_1000",Ys="_flagCell_254g3_1006",$s="_gradeCell_254g3_1011",Us="_gradeText_254g3_1016",Vs="_emailCell_254g3_1021",Ks="_emailText_254g3_1026",Js="_studentsPagination_254g3_1031",Zs="_reviewSectionBlock_254g3_1049",Xs="_reviewSectionHeader_254g3_1058",ea="_reviewSectionTitle_254g3_1065",ta="_reviewEditSectionBtn_254g3_1071",sa="_reviewFieldGroup_254g3_1082",aa="_reviewFieldLabel_254g3_1086",na="_reviewFieldValue_254g3_1094",la="_reviewQuestionsTableContainer_254g3_1100",ra="_previewSurveyBtn_254g3_1106",oa="_publishBtn_254g3_1122",s={createSurveyPage:tt,headerTopBar:st,contentBody:at,stepperContainer:nt,backButton:lt,stepperProgress:rt,stepColumn:ot,stepColumnLast:it,stepCircleRow:ct,stepCircle:dt,active:ut,completed:ht,stepConnectorLine:mt,stepLabelStack:gt,stepInnerDot:pt,stepNumberLabel:xt,stepTextLabel:ft,chooseTemplateCard:yt,headerSection:_t,headerTitle:Tt,headerSubtitle:Ct,bannerContainer:bt,bannerIconBox:St,bannerTitle:jt,bannerSubtitle:Nt,bannerActionBtn:vt,sectionTitle:wt,filterPillsContainer:Bt,filterPill:Ft,templateCard:It,selected:At,templateCardTitle:Rt,templateEditBtn:Lt,templateDescription:kt,chipItem:Et,wizardFooter:qt,previousBtn:Dt,disabled:Pt,stepCounterText:Ht,nextBtn:zt,editTemplateHeaderSection:Wt,editTemplateCancelBtn:Mt,editTemplateSaveBtn:Qt,templateCategorySelect:Ot,formFieldBlock:Gt,formFieldLabel:Yt,requiredAsterisk:$t,customTextField:Ut,formFieldHelperText:Vt,questionsHeaderSection:Kt,questionsTitle:Jt,questionsCountNumber:Zt,filterByRow:Xt,filterByLabel:es,categoryFilterFormControl:ts,categorySelectInput:ss,tableContainerWrapper:as,questionsTable:ns,tableHeaderRow:ls,tableBodyRow:rs,thNumber:os,tdNumber:is,thQuestion:cs,tdQuestion:ds,questionText:us,thType:hs,tdType:ms,thCategory:gs,tdCategory:ps,categoryText:xs,thActions:fs,tdActions:ys,questionTypeBadge:_s,badgeTextLabel:Ts,badgeRating:Cs,badgeYesNo:bs,badgeText:Ss,tableEditBtn:js,tableRemoveBtn:Ns,addQuestionWrapper:vs,addQuestionBtn:ws,selectedCountSection:Bs,selectedCountText:Fs,selectedCountHighlight:Is,studentsToolbar:As,searchBarContainer:Rs,studentSearchInput:Ls,filterDropdownWrapper:ks,filterSelectBox:Es,studentsTableContainer:qs,studentsTable:Ds,studentsTableHeaderRow:Ps,checkboxHeaderCell:Hs,tableHeaderCell:zs,checkboxBodyCell:Ws,studentTableRow:Ms,selectedRow:Qs,studentNameCell:Os,studentNameText:Gs,flagCell:Ys,gradeCell:$s,gradeText:Us,emailCell:Vs,emailText:Ks,studentsPagination:Js,reviewSectionBlock:Zs,reviewSectionHeader:Xs,reviewSectionTitle:ea,reviewEditSectionBtn:ta,reviewFieldGroup:sa,reviewFieldLabel:aa,reviewFieldValue:na,reviewQuestionsTableContainer:la,previewSurveyBtn:ra,publishBtn:oa},ia=({steps:a,activeStep:l,onBack:c})=>e.jsxs(t.Box,{className:s.stepperContainer,children:[e.jsx(t.Button,{onClick:c,startIcon:e.jsx(Te.ArrowBackIcon,{fontSize:"small"}),className:s.backButton,children:"Back to Surveys Dashboard"}),e.jsx(t.Box,{className:s.stepperProgress,children:a.map((d,r)=>{const i=r===l,h=r<l,m=r===a.length-1;return e.jsxs(t.Box,{className:`${s.stepColumn} ${m?s.stepColumnLast:""}`,children:[e.jsxs(t.Box,{className:s.stepCircleRow,children:[e.jsxs(t.Box,{className:`${s.stepCircle} ${i?s.active:h?s.completed:""}`,children:[i&&e.jsx(t.Box,{className:s.stepInnerDot}),h&&e.jsx(Ce.CheckIcon,{sx:{fontSize:16,color:"#ffffff"}})]}),!m&&e.jsx(t.Box,{className:`${s.stepConnectorLine} ${h?s.completed:""}`})]}),e.jsxs(t.Stack,{alignItems:"flex-start",spacing:.25,className:s.stepLabelStack,children:[e.jsxs(t.Typography,{variant:"caption",className:`${s.stepNumberLabel} ${i?s.active:""}`,children:["STEP ",d.stepNumber]}),e.jsx(t.Typography,{variant:"body2",className:`${s.stepTextLabel} ${i?s.active:""}`,children:d.label})]})]},d.stepCode)})})]}),ca=({onCreateBlank:a})=>e.jsxs(t.Box,{className:s.bannerContainer,children:[e.jsxs(t.Stack,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(t.Box,{className:s.bannerIconBox,children:e.jsx("img",{src:"/images/scratch-icon.png",alt:"Start from Scratch"})}),e.jsxs(t.Box,{children:[e.jsx(t.Typography,{variant:"subtitle1",className:s.bannerTitle,children:"Start from Scratch"}),e.jsx(t.Typography,{variant:"body2",className:s.bannerSubtitle,children:"Create a custom survey tailored to your specific needs"})]})]}),e.jsx(t.Button,{onClick:a,endIcon:e.jsx(be.ArrowForwardIcon,{sx:{fontSize:16}}),className:s.bannerActionBtn,children:"CREATE BLANK SURVEY"})]}),da=({categories:a,selectedCategory:l,onSelectCategory:c})=>e.jsx(t.Box,{className:s.filterPillsContainer,children:e.jsx(t.Stack,{direction:"row",spacing:1.5,alignItems:"center",children:a.map(d=>{const r=l.toLowerCase()===d.toLowerCase();return e.jsx(t.Chip,{label:d,onClick:()=>c(d),className:`${s.filterPill} ${r?s.active:""}`},d)})})}),X=te.createSvgIcon(e.jsx("path",{d:"m14.06 9.02.92.92L5.92 19H5v-.92zM17.66 3c-.25 0-.51.1-.7.29l-1.83 1.83 3.75 3.75 1.83-1.83c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.2-.2-.45-.29-.71-.29m-3.6 3.19L3 17.25V21h3.75L17.81 9.94z"}),"EditOutlined"),ua=({template:a,isSelected:l,onSelect:c,onEdit:d})=>e.jsxs(t.Box,{onClick:()=>c(a.id),className:`${s.templateCard} ${l?s.selected:""}`,children:[e.jsxs(t.Box,{children:[e.jsxs(t.Stack,{direction:"row",alignItems:"flex-start",justifyContent:"space-between",spacing:1,children:[e.jsx(t.Typography,{variant:"h6",className:s.templateCardTitle,children:a.title}),e.jsx(t.Button,{size:"small",onClick:r=>d(a,r),startIcon:e.jsx(X,{sx:{fontSize:14}}),className:s.templateEditBtn,children:"EDIT"})]}),e.jsx(t.Typography,{variant:"body2",className:s.templateDescription,children:a.description})]}),e.jsxs(t.Stack,{direction:"row",spacing:1,alignItems:"center",flexWrap:"wrap",sx:{gap:.75},children:[e.jsx(t.Chip,{label:`${a.questionCount} questions`,size:"small",className:s.chipItem}),e.jsx(t.Chip,{label:a.category,size:"small",className:s.chipItem})]})]}),ha=te.createSvgIcon(e.jsx("path",{d:"M12 6.5c3.79 0 7.17 2.13 8.82 5.5-1.65 3.37-5.02 5.5-8.82 5.5S4.83 15.37 3.18 12C4.83 8.63 8.21 6.5 12 6.5m0-2C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5m0 5c1.38 0 2.5 1.12 2.5 2.5s-1.12 2.5-2.5 2.5-2.5-1.12-2.5-2.5 1.12-2.5 2.5-2.5m0-2c-2.48 0-4.5 2.02-4.5 4.5s2.02 4.5 4.5 4.5 4.5-2.02 4.5-4.5-2.02-4.5-4.5-4.5"}),"RemoveRedEyeOutlined"),se=({currentStep:a,totalSteps:l,onPrevious:c,onNext:d,isNextDisabled:r=!1,isLastStep:i=!1,nextLabel:h="NEXT",onPreview:m})=>e.jsxs(t.Box,{className:s.wizardFooter,children:[e.jsx(t.Button,{variant:"outlined",onClick:c,startIcon:e.jsx(Te.ArrowBackIcon,{sx:{fontSize:16}}),className:`${s.previousBtn} ${a===1?s.disabled:""}`,children:"PREVIOUS"}),e.jsxs(t.Typography,{variant:"body2",className:s.stepCounterText,children:["Step ",a," of ",l]}),i?e.jsxs(t.Stack,{direction:"row",spacing:1.5,alignItems:"center",children:[m&&e.jsx(t.Button,{variant:"outlined",onClick:m,startIcon:e.jsx(ha,{sx:{fontSize:18}}),className:s.previewSurveyBtn,children:"SURVEY PREVIEW"}),e.jsx(t.Button,{variant:"contained",onClick:d,disabled:r,className:s.publishBtn,children:h||"PUBLISH"})]}):e.jsx(t.Button,{variant:"contained",onClick:d,disabled:r,endIcon:e.jsx(be.ArrowForwardIcon,{sx:{fontSize:16}}),className:s.nextBtn,children:h})]}),ma=({categories:a,selectedCategory:l,templates:c,selectedTemplateId:d,currentStepNumber:r,totalSteps:i,onSelectCategory:h,onSelectTemplate:m,onCreateBlank:o,onEditTemplate:T,onPrevious:b,onNext:u})=>e.jsxs(t.Box,{className:s.chooseTemplateCard,children:[e.jsxs(t.Box,{children:[e.jsx(t.Typography,{variant:"h4",className:s.headerTitle,children:"Choose a Template"}),e.jsx(t.Typography,{variant:"body1",className:s.headerSubtitle,children:"Start with a template or create from scratch"})]}),e.jsx(ca,{onCreateBlank:o}),e.jsxs(t.Stack,{spacing:1,children:[e.jsx(t.Typography,{variant:"h6",className:s.sectionTitle,children:"Survey Templates"}),e.jsx(da,{categories:a,selectedCategory:l,onSelectCategory:h})]}),e.jsx(t.Grid,{container:!0,spacing:2.5,sx:{mt:1},children:c.map(x=>e.jsx(t.Grid,{item:!0,xs:12,sm:6,md:4,children:e.jsx(ua,{template:x,isSelected:d===x.id,onSelect:m,onEdit:T})},x.id))}),e.jsx(se,{currentStep:r,totalSteps:i,onPrevious:b,onNext:u})]}),ga=te.createSvgIcon(e.jsx("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6zM8 9h8v10H8zm7.5-5-1-1h-5l-1 1H5v2h14V4z"}),"DeleteOutlineOutlined"),je=({type:a})=>{const l=r=>{if(typeof r=="number"||!isNaN(Number(r))){const i=Number(r);if(i===0)return"Text";if(i===1)return"MultipleChoice";if(i===2||i===3)return"Slider";if(i===4)return"YesNo";if(i===5)return"SingleChoice";if(i===6)return"Date"}return String(r)},c=r=>{switch(l(r)){case"Rating":case"StarRating":case"Slider":return s.badgeRating;case"YesNo":case"SingleChoice":return s.badgeYesNo;case"Text":case"TextInput":case"OpenField":return s.badgeText;default:return s.badgeText}},d=r=>{const i=l(r);switch(i){case"YesNo":return"Yes/No";case"SingleChoice":return"Single Choice";case"StarRating":case"Rating":return"Rating";case"TextInput":case"OpenField":case"Text":return"Text";case"MultipleChoice":return"Multiple Choice";default:return i}};return e.jsx(t.Box,{className:`${s.questionTypeBadge} ${c(a)}`,children:e.jsx(t.Typography,{variant:"caption",className:s.badgeTextLabel,children:d(a)})})},Ne=({questions:a,onEditQuestion:l,onRemoveQuestion:c})=>{const[d,r]=C.useState(null),[i,h]=C.useState(!1),m=b=>{r(b),h(!0)},o=()=>{d!==null&&c(d),h(!1),r(null)},T=()=>{h(!1),r(null)};return e.jsxs(t.TableContainer,{className:s.tableContainerWrapper,children:[e.jsxs(t.Table,{className:s.questionsTable,children:[e.jsx(t.TableHead,{children:e.jsxs(t.TableRow,{className:s.tableHeaderRow,children:[e.jsx(t.TableCell,{className:s.thNumber,children:"#"}),e.jsx(t.TableCell,{className:s.thQuestion,children:"Question"}),e.jsx(t.TableCell,{className:s.thType,children:"Type"}),e.jsx(t.TableCell,{className:s.thCategory,children:"Category"}),e.jsx(t.TableCell,{className:s.thActions,children:"Actions"})]})}),e.jsx(t.TableBody,{children:a.map((b,u)=>e.jsxs(t.TableRow,{className:s.tableBodyRow,children:[e.jsxs(t.TableCell,{className:s.tdNumber,children:[u+1,"."]}),e.jsx(t.TableCell,{className:s.tdQuestion,children:e.jsx(t.Typography,{variant:"body2",className:s.questionText,dangerouslySetInnerHTML:{__html:b.questionText||""}})}),e.jsx(t.TableCell,{className:s.tdType,children:e.jsx(je,{type:b.type})}),e.jsx(t.TableCell,{className:s.tdCategory,children:e.jsx(t.Typography,{variant:"body2",className:s.categoryText,children:b.category})}),e.jsx(t.TableCell,{className:s.tdActions,children:e.jsxs(t.Stack,{direction:"row",spacing:1.5,alignItems:"center",children:[e.jsx(t.Button,{onClick:()=>l(b.id),startIcon:e.jsx(X,{fontSize:"small"}),className:s.tableEditBtn,children:"Edit"}),e.jsx(t.Button,{onClick:()=>m(b.id),startIcon:e.jsx(ga,{fontSize:"small"}),className:s.tableRemoveBtn,children:"Remove"})]})})]},b.id))})]}),e.jsxs(t.Dialog,{open:i,onClose:T,"aria-labelledby":"confirm-delete-dialog-title","aria-describedby":"confirm-delete-dialog-description",children:[e.jsx(t.DialogTitle,{id:"confirm-delete-dialog-title",sx:{fontWeight:"bold"},children:"Confirm Remove"}),e.jsx(t.DialogContent,{children:e.jsx(t.DialogContentText,{id:"confirm-delete-dialog-description",children:"Are you sure you want to remove this question?"})}),e.jsxs(t.DialogActions,{children:[e.jsx(t.Button,{onClick:T,color:"inherit",children:"Cancel"}),e.jsx(t.Button,{onClick:o,color:"error",autoFocus:!0,children:"Remove"})]})]})]})},pa=({formData:a,questionCategories:l,filteredQuestions:c,totalQuestionsCount:d,currentStepNumber:r,totalSteps:i,onTemplateNameChange:h,onDescriptionChange:m,onCategoryFilterChange:o,onEditQuestion:T,onRemoveQuestion:b,onAddQuestion:u,onPrevious:x,onNext:L})=>{const E=_=>{o(_.target.value)};return e.jsxs(t.Box,{className:s.chooseTemplateCard,children:[e.jsxs(t.Box,{className:s.headerSection,children:[e.jsx(t.Typography,{variant:"h5",className:s.headerTitle,children:"Check Details"}),e.jsx(t.Typography,{variant:"body2",className:s.headerSubtitle,children:"Review and edit the details below."})]}),e.jsxs(t.Box,{className:s.formFieldBlock,children:[e.jsxs(t.Typography,{variant:"subtitle2",className:s.formFieldLabel,children:["Template Name ",e.jsx("span",{className:s.requiredAsterisk,children:"*"})]}),e.jsx(t.TextField,{fullWidth:!0,variant:"outlined",value:a.templateName,onChange:_=>h(_.target.value),placeholder:"Enter template name",className:s.customTextField})]}),e.jsxs(t.Box,{className:s.formFieldBlock,children:[e.jsx(t.Typography,{variant:"subtitle2",className:s.formFieldLabel,children:"Description and instructions of when to use"}),e.jsx(t.TextField,{fullWidth:!0,multiline:!0,rows:3,variant:"outlined",value:a.description,onChange:_=>m(_.target.value),placeholder:"Enter description and instructions",className:s.customTextField})]}),e.jsxs(t.Box,{className:s.questionsHeaderSection,children:[e.jsxs(t.Stack,{direction:"row",alignItems:"center",spacing:.75,sx:{mb:1.5},children:[e.jsx(t.Typography,{variant:"subtitle1",className:s.questionsTitle,children:"Questions"}),e.jsx(t.Typography,{variant:"subtitle1",className:s.questionsCountNumber,children:d})]}),e.jsxs(t.Stack,{direction:"row",alignItems:"center",spacing:1.5,className:s.filterByRow,children:[e.jsx(t.Typography,{variant:"body2",className:s.filterByLabel,children:"Filter by category"}),e.jsx(t.FormControl,{size:"small",className:s.categoryFilterFormControl,children:e.jsx(t.Select,{value:a.selectedCategoryFilter,onChange:E,className:s.categorySelectInput,children:l.map(_=>e.jsx(t.MenuItem,{value:_,children:_},_))})})]})]}),e.jsx(Ne,{questions:c,onEditQuestion:T,onRemoveQuestion:b}),e.jsx(t.Box,{className:s.addQuestionWrapper,children:e.jsx(t.Button,{onClick:u,startIcon:e.jsx(Se.AddIcon,{}),className:s.addQuestionBtn,children:"ADD QUESTION"})}),e.jsx(se,{currentStep:r,totalSteps:i,onPrevious:x,onNext:L,isNextDisabled:!a.templateName||a.templateName.trim()===""})]})},xa=({formData:a,currentStepNumber:l,totalSteps:c,onTitleChange:d,onDeadlineChange:r,onPrevious:i,onNext:h})=>e.jsxs(t.Box,{className:s.chooseTemplateCard,children:[e.jsxs(t.Box,{className:s.headerSection,children:[e.jsx(t.Typography,{variant:"h5",className:s.headerTitle,children:"Create Survey"}),e.jsx(t.Typography,{variant:"body2",className:s.headerSubtitle,children:"Set the title and deadline for your survey"})]}),e.jsxs(t.Box,{className:s.formFieldBlock,children:[e.jsxs(t.Typography,{variant:"subtitle2",className:s.formFieldLabel,children:["Title ",e.jsx("span",{className:s.requiredAsterisk,children:"*"})]}),e.jsx(t.TextField,{fullWidth:!0,variant:"outlined",value:a.title,onChange:m=>d(m.target.value),placeholder:"Enter survey title",className:s.customTextField})]}),e.jsxs(t.Box,{className:s.formFieldBlock,children:[e.jsxs(t.Typography,{variant:"subtitle2",className:s.formFieldLabel,children:["Deadline ",e.jsx("span",{className:s.requiredAsterisk,children:"*"})]}),e.jsx(xe.LocalizationProvider,{dateAdapter:Oe.AdapterMoment,children:e.jsx(xe.DateTimePicker,{value:a.deadline?ge(a.deadline,"DD.MM.YYYY hh:mm A"):null,onChange:m=>{r(m?m.format("DD.MM.YYYY hh:mm A"):"")},format:"DD.MM.YYYY hh:mm A",slotProps:{textField:{fullWidth:!0,variant:"outlined",placeholder:"DD.MM.YYYY hh:mm A",className:s.customTextField}}})}),e.jsx(t.Typography,{variant:"caption",className:s.formFieldHelperText,children:"Select the date and time when the survey will close"})]}),e.jsx(se,{currentStep:l,totalSteps:c,onPrevious:i,onNext:h,isNextDisabled:!a.title||a.title.trim()===""||!a.deadline})]}),ee=({size:a=32,color:l="#C44140"})=>e.jsx("svg",{width:a,height:a,viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M28.2409 -0.141754C25.4195 3.28575 25.0819 7.25702 25.2536 11.6181C25.4635 16.9475 26.3117 24.291 27.1324 29.5842C27.2535 30.3658 26.3405 30.8232 25.7942 30.2545C22.7477 27.0829 19.2078 23.33 16.0196 19.1775C13.2409 22.6735 11.0153 26.7226 8.60824 31.0487C8.37898 31.4608 7.83452 31.5433 7.47943 31.2194C7.07049 30.8465 6.80209 30.3374 6.72382 29.7869C5.03439 17.9028 4.08511 12.0405 3.95375 -0.206989L28.2409 -0.141754Z",fill:l})}),j={"flag-of-session":"_flag-of-session_izm26_530","flag-of-session__title-red":"_flag-of-session__title-red_izm26_539","flag-of-session__title-red--text":"_flag-of-session__title-red--text_izm26_544","flag-of-session__title-yellow":"_flag-of-session__title-yellow_izm26_561","flag-of-session__title-yellow--text":"_flag-of-session__title-yellow--text_izm26_566","flag-of-session__content-green":"_flag-of-session__content-green_izm26_572","flag-of-session__content-green--text":"_flag-of-session__content-green--text_izm26_579","flag-of-session__item":"_flag-of-session__item_izm26_586","flag-of-session__item--title":"_flag-of-session__item--title_izm26_594","flag-of-session__item--content":"_flag-of-session__item--content_izm26_601","flag-of-session__item-column":"_flag-of-session__item-column_izm26_608","flag-of-session__item-column--no-bold":"_flag-of-session__item-column--no-bold_izm26_620","flag-of-session__item-column--content":"_flag-of-session__item-column--content_izm26_627"},ye=a=>{switch(a){case"Red Flag":return e.jsxs("div",{className:j["flag-of-session__title-red"],children:[e.jsx(ee,{color:"#C44140",size:32}),e.jsx("span",{className:j["flag-of-session__title-red--text"],children:"Red Flag"})]});case"Yellow Flag":return e.jsxs("div",{className:j["flag-of-session__title-yellow"],children:[e.jsx(ee,{color:"#F5D500",size:32}),e.jsx("span",{className:j["flag-of-session__title-yellow--text"],children:"Yellow Flag"})]});default:return null}},fa=({flag:a,flagDetail:l,lastSafetyAnswer:c,lastStressAnswer:d,showResult:r,defaultStress:i,defaultSafety:h,defaultDecrease:m,isDetailView:o,hasReadyToLearn:T,inSession:b})=>r?e.jsxs("div",{className:j["flag-of-session"],style:{gap:"6px"},children:[(a==="Green Flag"||a==="Green")&&e.jsxs("div",{className:j["flag-of-session__content-green"],children:["Everything is ",e.jsx("p",{className:j["flag-of-session__content-green--text"],children:"fine"})]}),o&&a&&ye(a||""),l?.stress&&(o?e.jsxs("div",{className:j["flag-of-session__item"],children:[e.jsx("p",{className:j["flag-of-session__item--title"],children:"Stress score:"}),e.jsxs("p",{className:j["flag-of-session__item--content"],children:[l?.stress?.score,"%"]})]}):e.jsxs("div",{className:j["flag-of-session__item"],children:[e.jsxs("span",{style:{fontWeight:600,color:l?.stress?.flag==="Red Flag"?"#C44140":"#F5D500",fontSize:"12px"},children:[l?.stress?.score,"%"]}),"Stress vs Last check-in ",d,"%"]})),l?.safety&&(o?e.jsxs("div",{className:j["flag-of-session__item"],children:[e.jsx("p",{className:j["flag-of-session__item--title"],children:"Safety score:"}),e.jsxs("p",{className:j["flag-of-session__item--content"],children:[l?.safety?.score,"%"]})]}):e.jsxs("div",{className:j["flag-of-session__item"],children:[e.jsxs("span",{style:{fontWeight:600,color:l?.safety?.flag==="Red Flag"?"#C44140":"#F5D500"},children:[l?.safety?.score,"%"]})," Safety vs Last check-in ",c,"%"]})),l?.decrease&&l?.decrease?.length>0&&(o?e.jsxs("div",{children:[e.jsxs("p",{className:j["flag-of-session__item--content"],children:[e.jsx("span",{className:j["flag-of-session__item--title"],children:"Sudden Drop: "}),e.jsxs("span",{className:j["flag-of-session__item--title"],children:[l.decrease.length," "]}),"core well-being metric shows a decrease of ",m,"% comparing their average of the last four check-ins."]}),e.jsx("ul",{className:j["flag-of-session__item-column--content"],children:l.decrease?.map((u,x)=>e.jsx("li",{style:{color:"#242424",marginLeft:"16px"},children:e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:e.jsxs("p",{style:{margin:0},children:[u.questionText,": ",u.answer,"% ",u.averageOtherRatingsText?"":u.averageOtherRatings!==void 0?`vs avr ${u.averageOtherRatings}%`:"vs previous"]})})},x))})]}):b?e.jsxs("div",{className:j["flag-of-session__item-column"],children:[e.jsxs("p",{className:j["flag-of-session__item-column--no-bold"],children:["Sudden Drop: ",l.decrease.length||0," core well-being metric shows a decrease compared to the average of the last four check-ins."]}),e.jsx("ul",{className:j["flag-of-session__item-column--content"],children:l.decrease?.map((u,x)=>{const E=a?.includes("Red")?"#C44140":"#F5D500";return e.jsx("li",{style:{color:"#242424",marginLeft:"16px"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[e.jsxs("p",{style:{margin:0,fontSize:"12px"},children:[u.questionText,":"]}),e.jsxs("p",{style:{margin:0,color:E,fontSize:"12px"},children:[u.answer,"%"]}),u.averageOtherRatingsText?"":u.averageOtherRatings!==void 0&&e.jsxs("p",{style:{margin:0,fontSize:"12px",marginLeft:"4px"},children:["vs avr ",u.averageOtherRatings,"%"]})]})},x)})})]}):e.jsxs("div",{className:j["flag-of-session__item"],children:["Sudden Drop: Any core well-being metric shows a percentage decrease of ",m||20,"% comparing their average of the last four check-ins."]})),l?.readinessToLearn&&(o?e.jsx("div",{children:e.jsxs("p",{className:j["flag-of-session__item--content"],children:[e.jsx("span",{className:j["flag-of-session__item--title"],children:"Ready to learn: "}),l?.readinessToLearn]})}):e.jsxs("div",{className:j["flag-of-session__item"],children:["Ready to learn: ",l?.readinessToLearn]}))]}):e.jsxs("div",{className:j["flag-of-session"],children:[ye(a||""),h&&e.jsxs("div",{className:j["flag-of-session__item"],children:[e.jsx("p",{className:j["flag-of-session__item--title"],children:"Safety score:"}),e.jsxs("p",{className:j["flag-of-session__item--content"],children:["Under ",h,"%"]})]}),i&&e.jsxs("div",{className:j["flag-of-session__item"],children:[e.jsx("p",{className:j["flag-of-session__item--title"],children:"Stress level:"}),e.jsxs("p",{className:j["flag-of-session__item--content"],children:["Higher than ",i,"%"]})]}),m&&e.jsx("div",{children:e.jsxs("p",{className:j["flag-of-session__item--content"],children:[e.jsx("span",{className:j["flag-of-session__item--title"],children:"Sudden Drop: "}),"Any core well-being metric shows a percentage decrease of ",m,"% comparing their average of the last four check-ins."]})}),T&&e.jsx("div",{children:e.jsxs("p",{className:j["flag-of-session__item--content"],children:[e.jsx("span",{className:j["flag-of-session__item--title"],children:"Ready to learn: "}),"The student reported as not ready to learn in last check-in."]})})]}),ya=te.styled$1(({className:a,...l})=>e.jsx(t.Tooltip,{...l,classes:{popper:a}}))(({theme:a})=>({zIndex:1e3,[`& .${t.tooltipClasses.tooltip}`]:{backgroundColor:"transparent !important",marginTop:"8px !important",fontFamily:"Poppins-Regular"},[`& .${t.tooltipClasses.arrow}`]:{color:a.palette.common.white,top:"4px !important"}})),_a=a=>{if(!a)return null;const l=a.toLowerCase();return l==="red"?e.jsx(ee,{size:32,color:"#C44140"}):l==="yellow"?e.jsx(ee,{size:32,color:"#F5D500"}):l==="green"?e.jsx(ee,{size:32,color:"#10B981"}):null},Ta=({students:a,totalStudentsCount:l,totalSelectedCount:c,selectedStudentIds:d,filters:r,gradeOptions:i,flagOptions:h,teacherOptions:m,page:o,rowsPerPage:T,isAllSelected:b,isIndeterminate:u,sortBy:x,sortOrder:L,onSortChange:E,currentStepNumber:_,totalSteps:N,onSearchChange:S,onGradeChange:g,onFlagChange:D,onTeacherChange:I,onPageChange:G,onRowsPerPageChange:H,onToggleSelectAll:Y,onToggleStudent:Q,onPrevious:$,onNext:O})=>{const U=n=>{g(n.target.value)},f=n=>{D(n.target.value)},y=n=>{I(n.target.value)};return e.jsxs(t.Box,{className:s.chooseTemplateCard,children:[e.jsxs(t.Box,{className:s.headerSection,children:[e.jsx(t.Typography,{variant:"h5",className:s.headerTitle,children:"Select Students"}),e.jsx(t.Typography,{variant:"body2",className:s.headerSubtitle,children:"Choose the students who should participate in this survey"})]}),e.jsx(t.Box,{className:s.selectedCountSection,children:e.jsxs(t.Typography,{variant:"subtitle1",className:s.selectedCountText,children:["Selected students"," ",e.jsx(t.Box,{component:"span",className:s.selectedCountHighlight,children:c})]})}),e.jsxs(t.Box,{className:s.studentsToolbar,children:[e.jsx(t.Box,{className:s.searchBarContainer,children:e.jsx(t.TextField,{fullWidth:!0,size:"small",placeholder:"Search students by name or email...",value:r.searchQuery,onChange:n=>S(n.target.value),className:s.studentSearchInput,InputProps:{startAdornment:e.jsx(t.InputAdornment,{position:"start",children:e.jsx(Ge.SearchIcon,{sx:{color:"#94a3b8",fontSize:20}})})}})}),e.jsx(t.Box,{className:s.filterDropdownWrapper,children:e.jsx(t.FormControl,{size:"small",fullWidth:!0,children:e.jsx(t.Select,{value:r.selectedGrade,onChange:U,displayEmpty:!0,className:s.filterSelectBox,children:i.map(n=>e.jsx(t.MenuItem,{value:n,children:n},n))})})}),e.jsx(t.Box,{className:s.filterDropdownWrapper,children:e.jsx(t.FormControl,{size:"small",fullWidth:!0,children:e.jsx(t.Select,{value:r.selectedFlag,onChange:f,displayEmpty:!0,className:s.filterSelectBox,children:h.map(n=>e.jsx(t.MenuItem,{value:n.value,children:n.label},n.value))})})}),e.jsx(t.Box,{className:s.filterDropdownWrapper,children:e.jsx(t.FormControl,{size:"small",fullWidth:!0,children:e.jsx(t.Select,{value:r.selectedTeacher,onChange:y,displayEmpty:!0,className:s.filterSelectBox,children:m.map(n=>e.jsx(t.MenuItem,{value:n,children:n},n))})})})]}),e.jsxs(t.Box,{className:s.studentsTableContainer,children:[e.jsxs(t.Table,{className:s.studentsTable,children:[e.jsx(t.TableHead,{children:e.jsxs(t.TableRow,{className:s.studentsTableHeaderRow,children:[e.jsx(t.TableCell,{className:s.checkboxHeaderCell,children:e.jsx(t.Checkbox,{checked:b,indeterminate:u,onChange:Y,sx:{color:"#cbd5e1","&.Mui-checked":{color:"#2563eb"},"&.MuiCheckbox-indeterminate":{color:"#2563eb"}}})}),e.jsx(t.TableCell,{className:s.tableHeaderCell,children:e.jsx(t.TableSortLabel,{active:x==="name",direction:x==="name"?L:"asc",onClick:()=>E("name"),children:"Student Name"})}),e.jsx(t.TableCell,{className:s.tableHeaderCell,children:e.jsx(t.TableSortLabel,{active:x==="flag",direction:x==="flag"?L:"asc",onClick:()=>E("flag"),children:"Flag"})}),e.jsx(t.TableCell,{className:s.tableHeaderCell,children:e.jsx(t.TableSortLabel,{active:x==="grade",direction:x==="grade"?L:"asc",onClick:()=>E("grade"),children:"Grade"})}),e.jsx(t.TableCell,{className:s.tableHeaderCell,children:e.jsx(t.TableSortLabel,{active:x==="email",direction:x==="email"?L:"asc",onClick:()=>E("email"),children:"Email"})}),e.jsx(t.TableCell,{className:s.tableHeaderCell,children:e.jsx(t.TableSortLabel,{active:x==="teacher",direction:x==="teacher"?L:"asc",onClick:()=>E("teacher"),children:"Teacher"})})]})}),e.jsx(t.TableBody,{children:a.length===0?e.jsx(t.TableRow,{children:e.jsx(t.TableCell,{colSpan:5,align:"center",sx:{py:4,color:"#94a3b8"},children:"No students found matching current filters."})}):a.map(n=>{const w=d.includes(n.id);return e.jsxs(t.TableRow,{className:`${s.studentTableRow} ${w?s.selectedRow:""}`,onClick:()=>Q(n.id),children:[e.jsx(t.TableCell,{className:s.checkboxBodyCell,onClick:v=>v.stopPropagation(),children:e.jsx(t.Checkbox,{checked:w,onChange:()=>Q(n.id),sx:{color:"#cbd5e1","&.Mui-checked":{color:"#2563eb"}}})}),e.jsx(t.TableCell,{className:s.studentNameCell,children:e.jsxs(t.Stack,{direction:"row",alignItems:"center",spacing:1.75,children:[e.jsx("img",{src:n.avatarUrl,alt:n.name,style:{width:44,height:44,borderRadius:"50%",objectFit:"cover"}}),e.jsx(t.Typography,{variant:"body2",className:s.studentNameText,children:n.name})]})}),e.jsx(t.TableCell,{className:s.flagCell,children:e.jsx(ya,{arrow:!0,placement:"bottom",title:n?.flag&&n.flag!=="none"?e.jsx(fa,{flag:n.flag==="red"?"Red Flag":n.flag==="yellow"?"Yellow Flag":"Green Flag",flagDetail:n.flagDetail,lastSafetyAnswer:n.lastSafetyAnswer,lastStressAnswer:n.lastStressAnswer,showResult:!0}):"",children:e.jsx("span",{children:e.jsx("div",{style:{display:"flex",justifyContent:"center",cursor:"pointer"},children:_a(n.flag)})})})}),e.jsx(t.TableCell,{className:s.gradeCell,children:e.jsx(t.Typography,{variant:"body2",className:s.gradeText,children:n.grade})}),e.jsx(t.TableCell,{className:s.emailCell,children:e.jsx(t.Typography,{variant:"body2",className:s.emailText,children:n.email})}),e.jsx(t.TableCell,{children:e.jsx(t.Typography,{variant:"body2",sx:{color:"#475569"},children:n.listTeachers&&n.listTeachers.length>0?n.listTeachers.map(v=>v.name).filter(Boolean).join(", "):"-"})})]},n.id)})})]}),l>0&&e.jsx(t.TablePagination,{rowsPerPageOptions:[5,10,25,50],component:"div",count:l,rowsPerPage:T,page:o,onPageChange:G,onRowsPerPageChange:H,className:s.studentsPagination})]}),e.jsx(se,{currentStep:_,totalSteps:N,onPrevious:$,onNext:O})]})},Ca=({size:a=32,color:l="#C44140"})=>e.jsx("svg",{width:a,height:a,viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M28.2409 -0.141754C25.4195 3.28575 25.0819 7.25702 25.2536 11.6181C25.4635 16.9475 26.3117 24.291 27.1324 29.5842C27.2535 30.3658 26.3405 30.8232 25.7942 30.2545C22.7477 27.0829 19.2078 23.33 16.0196 19.1775C13.2409 22.6735 11.0153 26.7226 8.60824 31.0487C8.37898 31.4608 7.83452 31.5433 7.47943 31.2194C7.07049 30.8465 6.80209 30.3374 6.72382 29.7869C5.03439 17.9028 4.08511 12.0405 3.95375 -0.206989L28.2409 -0.141754Z",fill:l})}),ba=t.styled(({className:a,...l})=>e.jsx(t.Tooltip,{...l,classes:{popper:a}}))(()=>({[`& .${t.tooltipClasses.tooltip}`]:{backgroundColor:"#ffffff",color:"#1e293b",maxWidth:220,fontSize:"0.75rem",border:"1px solid #e2e8f0",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",borderRadius:"8px",padding:"8px 12px"},[`& .${t.tooltipClasses.arrow}`]:{color:"#ffffff","&:before":{border:"1px solid #e2e8f0"}}})),Sa=({flag:a,tooltip:l})=>{if(a==="none")return null;let c="#10B981";a==="red"?c="#D10530":a==="yellow"?c="#F5D500":a==="green"&&(c="#0F9655");const d=l?e.jsx(t.Box,{sx:{lineHeight:1.4},children:l}):e.jsx(t.Box,{sx:{lineHeight:1.4},children:a==="red"?e.jsxs(e.Fragment,{children:[e.jsx(t.Box,{component:"span",sx:{color:"#D10530",fontWeight:700},children:"High"})," Risk,",e.jsx("br",{}),e.jsx(t.Box,{component:"span",sx:{color:"#D10530",fontWeight:700},children:"Negative"})," readiness to learn"]}):a==="yellow"?e.jsxs(e.Fragment,{children:[e.jsx(t.Box,{component:"span",sx:{color:"#F5D500",fontWeight:700},children:"Moderate"})," Risk,",e.jsx("br",{}),e.jsx(t.Box,{component:"span",sx:{color:"#F5D500",fontWeight:700},children:"Caution"})," readiness to learn"]}):e.jsxs(e.Fragment,{children:[e.jsx(t.Box,{component:"span",sx:{color:"#0F9655",fontWeight:700},children:"Low"})," Risk,",e.jsx("br",{}),e.jsx(t.Box,{component:"span",sx:{color:"#0F9655",fontWeight:700},children:"Positive"})," readiness to learn"]})});return e.jsx(ba,{title:d,arrow:!0,placement:"top",children:e.jsx(t.Box,{component:"span",sx:{display:"inline-flex",alignItems:"center",cursor:"pointer",transition:"transform 0.15s ease","&:hover":{transform:"scale(1.15)"}},children:e.jsx(Ca,{color:c,size:28})})})},ja=te.createSvgIcon(e.jsx("path",{d:"M19 4h-1V2h-2v2H8V2H6v2H5c-1.11 0-1.99.9-1.99 2L3 20c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2m0 16H5V10h14zm0-12H5V6h14zM9 14H7v-2h2zm4 0h-2v-2h2zm4 0h-2v-2h2zm-8 4H7v-2h2zm4 0h-2v-2h2zm4 0h-2v-2h2z"}),"CalendarMonthOutlined"),Na=({open:a,title:l,description:c,deadline:d,questions:r,onClose:i})=>{const h=o=>{if(typeof o=="number"||!isNaN(Number(o))){const T=Number(o);if(T===0)return"Text";if(T===1)return"MultipleChoice";if(T===2||T===3)return"Slider";if(T===4)return"YesNo";if(T===5)return"SingleChoice";if(T===6)return"Date"}return String(o)},m=o=>{try{const T=document.createElement("textarea");return T.innerHTML=o,T.value}catch{return o}};return e.jsxs(t.Dialog,{open:a,onClose:i,maxWidth:"md",fullWidth:!0,PaperProps:{sx:{borderRadius:"16px",p:1,maxHeight:"90vh"}},children:[e.jsxs(t.DialogTitle,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",pb:1,fontWeight:700,fontSize:"1.1rem",color:"#0f172a"},children:["Survey preview",e.jsx(t.IconButton,{onClick:i,size:"small",sx:{color:"#64748b"},children:e.jsx(Ye.CloseIcon,{fontSize:"small"})})]}),e.jsxs(t.DialogContent,{dividers:!0,sx:{p:3},children:[e.jsx(t.Typography,{variant:"h6",sx:{fontWeight:800,color:"#0f172a",mb:.5},children:l||"Student Well Being"}),e.jsx(t.Typography,{variant:"body2",sx:{color:"#64748b",mb:2},children:c||"General assessment of student wellness and quality of life"}),d&&e.jsxs(t.Stack,{direction:"row",spacing:1,alignItems:"center",sx:{color:"#64748b",mb:3},children:[e.jsx(ja,{sx:{fontSize:16,color:"#2563eb"}}),e.jsxs(t.Typography,{variant:"caption",sx:{fontWeight:600},children:["Due: ",d]})]}),e.jsx(t.Stack,{spacing:3,children:r.map((o,T)=>e.jsxs(t.Box,{sx:{pb:1},children:[e.jsxs(t.Box,{sx:{display:"flex",gap:"4px",fontWeight:600,color:"#1e293b",mb:1.5,fontSize:"0.875rem"},children:[e.jsxs(t.Box,{children:[T+1,"."]}),e.jsx(t.Box,{sx:{"& p":{m:0,display:"inline"},"& span":{display:"inline"}},dangerouslySetInnerHTML:{__html:m(o.questionText||"")}})]}),(h(o.type)==="Rating"||h(o.type)==="StarRating"||h(o.type)==="Slider")&&e.jsx(t.Box,{sx:{px:2,py:1},children:e.jsx(he.SliderSurveyComponent,{questionId:Number(o.id)||0,valueText:"50",minText:o.fromLabel||"",maxText:o.toLabel||"",isBeforeSession:!1,isPageResult:!0})}),h(o.type)==="MultipleChoice"&&e.jsx(t.Box,{sx:{px:2},children:e.jsx(he.MultiChoiceComponent,{questionId:Number(o.id)||0,valueText:"",isUserChangeSession:!0,questionAnswer:o.options&&o.options.length>0?o.options:[],isPageResult:!0})}),(h(o.type)==="YesNo"||h(o.type)==="SingleChoice")&&e.jsx(t.Box,{sx:{px:2},children:e.jsx(he.SingleChoiceComponent,{questionId:Number(o.id)||0,valueText:"",isUserChangeSession:!0,questionAnswer:o.options&&o.options.length>0?o.options:["Yes","No"]})}),(h(o.type)==="Text"||h(o.type)==="TextInput"||h(o.type)==="OpenField")&&e.jsx(t.TextField,{fullWidth:!0,multiline:!0,rows:2,placeholder:"Your answer...",size:"small",sx:{"& .MuiOutlinedInput-root":{borderRadius:"8px",backgroundColor:"#ffffff"}}})]},o.id))})]})]})},va=({templateFormData:a,surveyFormData:l,selectedStudents:c,currentStepNumber:d,totalSteps:r,onEditTemplateDetails:i,onEditSurveyDetails:h,onEditSelectedStudents:m,onPrevious:o,onPublish:T})=>{const[b,u]=C.useState(!1);return e.jsxs(t.Box,{className:s.chooseTemplateCard,children:[e.jsxs(t.Box,{className:s.reviewSectionBlock,children:[e.jsxs(t.Box,{className:s.reviewSectionHeader,children:[e.jsx(t.Typography,{variant:"h6",className:s.reviewSectionTitle,children:"Template Details"}),e.jsx(t.Button,{variant:"text",onClick:i,startIcon:e.jsx(X,{sx:{fontSize:16}}),className:s.reviewEditSectionBtn,children:"EDIT"})]}),e.jsxs(t.Box,{className:s.reviewFieldGroup,children:[e.jsx(t.Typography,{variant:"caption",className:s.reviewFieldLabel,children:"Template Name"}),e.jsx(t.Typography,{variant:"body2",className:s.reviewFieldValue,children:a.templateName||"Well-being"})]}),e.jsxs(t.Box,{className:s.reviewFieldGroup,children:[e.jsx(t.Typography,{variant:"caption",className:s.reviewFieldLabel,children:"Description and instructions of when to use"}),e.jsx(t.Typography,{variant:"body2",className:s.reviewFieldValue,children:a.description||"General assessment of student wellness and quality of life"})]}),e.jsxs(t.Box,{className:s.reviewFieldGroup,sx:{mt:3},children:[e.jsx(t.Typography,{variant:"caption",className:s.reviewFieldLabel,children:"Questions"}),e.jsx(t.Typography,{variant:"h6",className:s.questionsHeadingText,sx:{mb:1.5},children:e.jsx("span",{className:s.questionCountBadge,children:a.questions.length})}),e.jsx(t.Box,{className:s.reviewQuestionsTableContainer,children:e.jsxs(t.Table,{className:s.questionsTable,children:[e.jsx(t.TableHead,{children:e.jsxs(t.TableRow,{className:s.tableHeaderRow,children:[e.jsx(t.TableCell,{className:s.thNumber,children:"#"}),e.jsx(t.TableCell,{className:s.thQuestion,children:"Question"}),e.jsx(t.TableCell,{className:s.thType,children:"Type"}),e.jsx(t.TableCell,{className:s.thCategory,children:"Category"})]})}),e.jsx(t.TableBody,{children:a.questions.map((x,L)=>e.jsxs(t.TableRow,{className:s.tableBodyRow,children:[e.jsxs(t.TableCell,{className:s.tdNumber,children:[L+1,"."]}),e.jsx(t.TableCell,{className:s.tdQuestion,children:e.jsx(t.Typography,{variant:"body2",className:s.questionText,dangerouslySetInnerHTML:{__html:x.questionText||""}})}),e.jsx(t.TableCell,{className:s.tdType,children:e.jsx(je,{type:x.type})}),e.jsx(t.TableCell,{className:s.tdCategory,children:e.jsx(t.Typography,{variant:"body2",className:s.categoryText,children:x.category})})]},x.id))})]})})]})]}),e.jsxs(t.Box,{className:s.reviewSectionBlock,children:[e.jsxs(t.Box,{className:s.reviewSectionHeader,children:[e.jsx(t.Typography,{variant:"h6",className:s.reviewSectionTitle,children:"Survey Details"}),e.jsx(t.Button,{variant:"text",onClick:h,startIcon:e.jsx(X,{sx:{fontSize:16}}),className:s.reviewEditSectionBtn,children:"EDIT"})]}),e.jsxs(t.Box,{className:s.reviewFieldGroup,children:[e.jsx(t.Typography,{variant:"caption",className:s.reviewFieldLabel,children:"Title"}),e.jsx(t.Typography,{variant:"body2",className:s.reviewFieldValue,children:l.title||"Student Well Being"})]}),e.jsxs(t.Box,{className:s.reviewFieldGroup,children:[e.jsx(t.Typography,{variant:"caption",className:s.reviewFieldLabel,children:"Deadline"}),e.jsx(t.Typography,{variant:"body2",className:s.reviewFieldValue,children:l.deadline||"15th January 2026, 12:00 PM"})]})]}),e.jsxs(t.Box,{className:s.reviewSectionBlock,children:[e.jsxs(t.Box,{className:s.reviewSectionHeader,children:[e.jsxs(t.Typography,{variant:"h6",className:s.reviewSectionTitle,children:["Selected Students"," ",e.jsx(t.Box,{component:"span",sx:{color:"#2563eb",fontWeight:700},children:c.length})]}),e.jsx(t.Button,{variant:"text",onClick:m,startIcon:e.jsx(X,{sx:{fontSize:16}}),className:s.reviewEditSectionBtn,children:"EDIT"})]}),e.jsx(t.Box,{className:s.studentsTableContainer,children:e.jsxs(t.Table,{className:s.studentsTable,children:[e.jsx(t.TableHead,{children:e.jsxs(t.TableRow,{className:s.tableHeaderRow,children:[e.jsx(t.TableCell,{className:s.tableHeaderCell,children:"Student Name"}),e.jsx(t.TableCell,{className:s.tableHeaderCell,children:"Flag"}),e.jsx(t.TableCell,{className:s.tableHeaderCell,children:"Grade"}),e.jsx(t.TableCell,{className:s.tableHeaderCell,children:"Email"})]})}),e.jsx(t.TableBody,{children:c.length===0?e.jsx(t.TableRow,{children:e.jsx(t.TableCell,{colSpan:4,align:"center",sx:{py:3,color:"#94a3b8"},children:"No students selected."})}):c.map(x=>e.jsxs(t.TableRow,{className:s.studentTableRow,children:[e.jsx(t.TableCell,{className:s.studentNameCell,children:e.jsxs(t.Stack,{direction:"row",alignItems:"center",spacing:1.5,children:[e.jsx(t.Avatar,{src:x.avatarUrl,alt:x.name,sx:{width:28,height:28,fontSize:"0.75rem",bgcolor:"#e0e7ff",color:"#3730a3"},children:x.name.charAt(0)}),e.jsx(t.Typography,{variant:"body2",className:s.studentNameText,children:x.name})]})}),e.jsx(t.TableCell,{className:s.flagCell,children:e.jsx(Sa,{flag:x.flag,tooltip:x.flagTooltip})}),e.jsx(t.TableCell,{className:s.gradeCell,children:e.jsx(t.Typography,{variant:"body2",className:s.gradeText,children:x.grade})}),e.jsx(t.TableCell,{className:s.emailCell,children:e.jsx(t.Typography,{variant:"body2",className:s.emailText,children:x.email})})]},x.id))})]})})]}),e.jsx(se,{currentStep:d,totalSteps:r,isLastStep:!0,nextLabel:"PUBLISH",onPreview:()=>u(!0),onPrevious:o,onNext:T}),e.jsx(Na,{open:b,title:l.title||a.templateName,description:a.description,deadline:l.deadline,questions:a.questions,onClose:()=>u(!1)})]})},wa=[{id:"q-1",orderNumber:1,questionText:"How would you rate your overall well-being?",type:"Rating",category:"Overall Well-being"},{id:"q-2",orderNumber:2,questionText:"Do you feel balanced in your daily life?",type:"YesNo",category:"Life Balance"},{id:"q-3",orderNumber:3,questionText:"What contributes most to your well-being?",type:"Text",category:"Well-being Factors"}],Ba=({template:a,initialDraftData:l,onSave:c,onCancel:d,onAddQuestionRedirect:r,onEditQuestionRedirect:i})=>{const h=C.useMemo(()=>{const S=a.rawTemplate?.questionTemplates,g=me(S,a.category||"Well-being");return g.length>0?g:wa},[a]),[m,o]=C.useState(()=>l||{id:a.id,templateName:a.title,description:a.description||"",showLandingPageFlag:!1,category:a.category||"Well-being",questions:h}),T=C.useMemo(()=>{const S=new Set;m.category?.trim()&&S.add(m.category.trim()),m.questions.forEach(D=>{const I=D.category?.trim();I&&S.add(I)});const g=Array.from(S);return g.length>0?g:["General"]},[m.category,m.questions]),b=S=>{o(g=>({...g,templateName:S}))},u=S=>{o(g=>({...g,description:S}))},x=S=>{o(g=>({...g,category:S}))},L=S=>{i&&i(S,m)},E=S=>{o(g=>({...g,questions:g.questions.filter(D=>D.id!==S).map((D,I)=>({...D,orderNumber:I+1}))}))},_=()=>{r&&r(m)},N=()=>{const S={...a,title:m.templateName,description:m.description,category:m.category,questionCount:m.questions.length,rawTemplate:{...a.rawTemplate,questionTemplates:m.questions.map(g=>({questionId:typeof g.id=="number"||String(g.id).startsWith("q-")?g.id:parseInt(String(g.id)),questionText:g.questionText,type:g.type,category:g.category}))}};c(S)};return{formData:m,categoryOptions:T,totalQuestionsCount:m.questions.length,handleTemplateNameChange:b,handleDescriptionChange:u,handleCategoryChange:x,handleEditQuestion:L,handleRemoveQuestion:E,handleAddQuestion:_,handleSave:N,handleCancel:d}},Fa=({template:a,initialDraftData:l,onSave:c,onCancel:d,onAddQuestionRedirect:r,onEditQuestionRedirect:i})=>{const{formData:h,categoryOptions:m,totalQuestionsCount:o,handleTemplateNameChange:T,handleDescriptionChange:b,handleCategoryChange:u,handleEditQuestion:x,handleRemoveQuestion:L,handleAddQuestion:E,handleSave:_,handleCancel:N}=Ba({template:a,initialDraftData:l,onSave:c,onCancel:d,onAddQuestionRedirect:r,onEditQuestionRedirect:i});C.useEffect(()=>{window.scrollTo({top:0,behavior:"instant"});const g=document.querySelector("main");g&&g.scrollTo({top:0,behavior:"instant"});const D=document.documentElement||document.body;D&&(D.scrollTop=0)},[]);const S=g=>{u(g.target.value)};return e.jsxs(t.Box,{className:s.chooseTemplateCard,children:[e.jsxs(t.Box,{className:s.editTemplateHeaderSection,children:[e.jsx(t.Typography,{variant:"h5",className:s.headerTitle,children:"Edit Template"}),e.jsxs(t.Stack,{direction:"row",alignItems:"center",spacing:2,children:[e.jsx(t.Button,{onClick:N,className:s.editTemplateCancelBtn,children:"CANCEL"}),e.jsx(t.Button,{variant:"contained",onClick:_,startIcon:e.jsx(Ce.CheckIcon,{}),className:s.editTemplateSaveBtn,disabled:!h.templateName||h.templateName.trim()==="",children:"SAVE CHANGES"})]})]}),e.jsxs(t.Box,{className:s.formFieldBlock,children:[e.jsxs(t.Typography,{variant:"subtitle2",className:s.formFieldLabel,children:["Template Name ",e.jsx("span",{className:s.requiredAsterisk,children:"*"})]}),e.jsx(t.TextField,{fullWidth:!0,variant:"outlined",value:h.templateName,onChange:g=>T(g.target.value),placeholder:"Enter template name",className:s.customTextField})]}),e.jsxs(t.Box,{className:s.formFieldBlock,children:[e.jsx(t.Typography,{variant:"subtitle2",className:s.formFieldLabel,children:"Description and instructions of when to use"}),e.jsx(t.TextField,{fullWidth:!0,multiline:!0,rows:3,variant:"outlined",value:h.description,onChange:g=>b(g.target.value),placeholder:"Enter description and instructions",className:s.customTextField})]}),e.jsxs(t.Box,{className:s.formFieldBlock,children:[e.jsxs(t.Typography,{variant:"subtitle2",className:s.formFieldLabel,children:["Category ",e.jsx("span",{className:s.requiredAsterisk,children:"*"})]}),e.jsx(t.FormControl,{fullWidth:!0,size:"small",children:e.jsx(t.Select,{value:h.category,onChange:S,className:s.templateCategorySelect,children:m.map(g=>e.jsx(t.MenuItem,{value:g,children:g},g))})})]}),e.jsx(t.Box,{className:s.questionsHeaderSection,children:e.jsxs(t.Stack,{direction:"row",alignItems:"center",spacing:.75,children:[e.jsx(t.Typography,{variant:"subtitle1",className:s.questionsTitle,children:"Questions"}),e.jsx(t.Typography,{variant:"subtitle1",className:s.questionsCountNumber,children:o})]})}),e.jsx(Ne,{questions:h.questions,onEditQuestion:x,onRemoveQuestion:L}),e.jsx(t.Box,{className:s.addQuestionWrapper,children:e.jsx(t.Button,{onClick:E,startIcon:e.jsx(Se.AddIcon,{}),className:s.addQuestionBtn,children:"ADD QUESTION"})})]})},Ia=()=>{const a=oe.useDispatch(),l=oe.useSelector(k=>k?.common?.user?.roles),c=_e.useNavigate(),d=C.useMemo(()=>{if(localStorage.getItem("is_returning_from_question")==="true"){const P=localStorage.getItem("create_survey_draft");if(P)try{return JSON.parse(P)}catch{}}return null},[]);C.useEffect(()=>{const k=setTimeout(()=>{localStorage.getItem("is_returning_from_question")==="true"?localStorage.removeItem("is_returning_from_question"):localStorage.removeItem("create_survey_draft")},500);return()=>clearTimeout(k)},[]);const{steps:r,activeStep:i,categories:h,selectedCategory:m,selectedTemplateId:o,templates:T,editingTemplate:b,handleSelectCategory:u,handleSelectTemplate:x,handleCreateBlankSurvey:L,handleEditTemplate:E,handleCloseEditTemplate:_,handleSaveEditTemplate:N,handleGoBackToDashboard:S,handlePreviousStep:g,handleNextStep:D,handleGoToStep:I}=Ve(d),G=C.useMemo(()=>{if(o==="BLANK")return null;if(o){const k=T.find(P=>P.id===o);return k||null}return T.length>0?T[0]:null},[T,o]),{formData:H,questionCategories:Y,filteredQuestions:Q,totalQuestionsCount:$,handleTemplateNameChange:O,handleDescriptionChange:U,handleCategoryFilterChange:f,handleRemoveQuestion:y}=Ke(o,G,d),{formData:n,handleTitleChange:w,handleDeadlineChange:v}=Je(d),{students:F,allFilteredStudents:B,totalStudentsCount:W,totalSelectedCount:p,selectedStudentIds:R,filters:M,gradeOptions:ie,flagOptions:ce,teacherOptions:ae,isAllSelected:K,isIndeterminate:de,handleSortChange:ue,handleSearchChange:J,handleGradeFilterChange:ve,handleFlagFilterChange:we,handleTeacherFilterChange:Be,handlePageChange:Fe,handleRowsPerPageChange:Ie,handleToggleSelectAll:Ae,handleToggleStudent:Re}=et(d),ne=k=>{const P={activeStep:i,selectedCategory:m,selectedTemplateId:o,step2FormData:H,step3FormData:n,selectedStudentIds:R,editingTemplate:b,...k};localStorage.setItem("create_survey_draft",JSON.stringify(P))},Le=()=>{ne(),c("/admin/create-survey-question?type=0&from=create-survey")},ke=k=>{ne(),c(`/admin/survey-question-detail/${k}?type=0&from=create-survey`)},Ee=C.useMemo(()=>(B||F).filter(k=>R.includes(k.id)),[B,F,R]),qe=async()=>{const k=new Map;(B||F||[]).forEach(A=>k.set(A.id,A));const P=[],V=[],le=[];R.forEach(A=>{const q=k.get(A);if(q)q.schoolLevel==="ES"&&q.userId?(V.push(q.userId),le.push({userId:q.userId,name:q.name,firstName:q.name?.split(" ")?.[0]||"",email:q.email,studentId:q.studentId})):q.studentId!==void 0?P.push(q.studentId):typeof A=="number"?P.push(A):q.userId&&(V.push(q.userId),le.push({userId:q.userId,name:q.name,firstName:q.name?.split(" ")?.[0]||"",email:q.email,studentId:q.studentId}));else if(typeof A=="number"||!isNaN(Number(A))&&!String(A).includes("-"))P.push(Number(A));else{const Z=String(A);V.push(Z),le.push({userId:Z,name:`Student ${Z}`,firstName:"Student",email:""})}});const He=[{id:o,name:H.templateName,title:H.templateName,description:H.description,numberQuestion:H.questions.length,orderDefaultSurvey:1,questionTemplates:H.questions.map((A,q)=>({questionId:typeof A.id=="string"&&A.id.startsWith("q-")?0:Number(A.id),questionText:A.questionText,type:A.type||"MultipleChoice",orderDefaultQuestionTemplate:A.orderNumber??q,answers:A.options&&Array.isArray(A.options)?A.options.map((Z,Me)=>({id:0,text:Z,order:Me})):A.answers||[]}))}],ze=n.deadline?ge(n.deadline,"DD.MM.YYYY hh:mm A").valueOf():null,We={title:n.title,deadline:ze,studentIds:P,esStudentUserIds:V,studentUserIds:V,esStudents:le,additionalQuestions:[],staffIds:[],summarizeQuestions:[],isAdmin:!0,isDraft:!1,role:Array.isArray(l)?l.join(","):l?String(l):"Admin",templateQuestions:He};try{a(z.setLoading(!0)),await pe.createSurvey(We),a(z.setAlert({type:"success",message:"Publish survey success"})),S()}catch(A){console.error("Error publishing survey:",A),a(z.setAlert({type:"danger",message:A?.response?.data?.title||A?.message||"Failed to publish survey"}))}finally{a(z.setLoading(!1))}};C.useEffect(()=>{window.scrollTo({top:0,behavior:"instant"});const k=document.querySelector("main");k&&k.scrollTo({top:0,behavior:"instant"});const P=document.documentElement||document.body;P&&(P.scrollTop=0)},[i,b]);const De=k=>{ne({editingTemplateFormData:k}),c("/admin/create-survey-question?type=0&from=edit-template")},Pe=(k,P)=>{ne({editingTemplateFormData:P}),c(`/admin/survey-question-detail/${k}?type=0&from=edit-template`)};return b?e.jsx(t.Box,{className:s.createSurveyPage,children:e.jsx(t.Box,{className:s.contentBody,children:e.jsx(Fa,{template:b,initialDraftData:d?.editingTemplateFormData,onSave:N,onCancel:_,onAddQuestionRedirect:De,onEditQuestionRedirect:Pe})})}):e.jsxs(t.Box,{className:s.createSurveyPage,children:[e.jsx(t.Box,{className:s.headerTopBar,children:e.jsx(ia,{steps:r,activeStep:i,onBack:S})}),e.jsxs(t.Box,{className:s.contentBody,children:[i===0&&e.jsx(ma,{categories:h,selectedCategory:m,templates:T,selectedTemplateId:o,currentStepNumber:i+1,totalSteps:r.length,onSelectCategory:u,onSelectTemplate:x,onCreateBlank:L,onEditTemplate:E,onPrevious:g,onNext:D}),i===1&&e.jsx(pa,{formData:H,questionCategories:Y,filteredQuestions:Q,totalQuestionsCount:$,currentStepNumber:i+1,totalSteps:r.length,onTemplateNameChange:O,onDescriptionChange:U,onCategoryFilterChange:f,onEditQuestion:ke,onRemoveQuestion:y,onAddQuestion:Le,onPrevious:g,onNext:D}),i===2&&e.jsx(xa,{formData:n,currentStepNumber:i+1,totalSteps:r.length,onTitleChange:w,onDeadlineChange:v,onPrevious:g,onNext:D}),i===3&&e.jsx(Ta,{students:F,totalStudentsCount:W,totalSelectedCount:p,selectedStudentIds:R,filters:M,gradeOptions:ie,flagOptions:ce,teacherOptions:ae,page:M.page,rowsPerPage:M.rowsPerPage,isAllSelected:K,isIndeterminate:de,sortBy:M.sortBy,sortOrder:M.sortOrder,onSortChange:ue,currentStepNumber:i+1,totalSteps:r.length,onSearchChange:J,onGradeChange:ve,onFlagChange:we,onTeacherChange:Be,onPageChange:Fe,onRowsPerPageChange:Ie,onToggleSelectAll:Ae,onToggleStudent:Re,onPrevious:g,onNext:D}),i===4&&e.jsx(va,{templateFormData:H,surveyFormData:n,selectedStudents:Ee,currentStepNumber:i+1,totalSteps:r.length,onEditTemplateDetails:()=>I(1),onEditSurveyDetails:()=>I(2),onEditSelectedStudents:()=>I(3),onPrevious:g,onPublish:qe})]})]})};exports.default=Ia;