mario-education 2.0.210-staging → 2.0.211-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"),he=require("react-redux"),_e=require("react-router-dom"),ge=require("moment"),M=require("mario-core"),xe=require("./surveyService-Lks0sWq4.cjs"),$e=require("./questionCategoryService-CjXNe6xV.cjs"),be=require("./ArrowBack-C4WIF8bZ.cjs"),Ce=require("./Check-CYAVgIcj.cjs"),Se=require("./ArrowForward-D4TtLiX5.cjs"),ne=require("./createSvgIcon-CRp0VXvr.cjs"),je=require("./Add-DE-4A91A.cjs"),ye=require("@mui/x-date-pickers"),Ue=require("./AdapterMoment-B-q0UCj0.cjs"),Ve=require("./Search-CZp6DUOA.cjs"),Ke=require("./Close-BqvQ2Wpz.cjs"),ce=require("./DropDownComponent-BzsJ_Gac.cjs"),de=[{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"}],Je=["All","School Climate","Well-being","Health & Wellness"],Ze=[{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"}],Xe=a=>{const n=he.useDispatch(),i=_e.useNavigate(),p=he.useSelector(d=>d?.common?.language||"en"),[r,l]=C.useState(a?.activeStep??0),[T,u]=C.useState(a?.selectedCategory??"All"),[c,y]=C.useState(a?.selectedTemplateId??null),[x,h]=C.useState(Ze),[g,L]=C.useState(!1),[R,A]=C.useState(a?.editingTemplate??null),S=C.useCallback(async()=>{try{L(!0),n(M.setLoading(!0));const d=await xe.getTemplateSurvey(p);if(d?.data&&Array.isArray(d.data)&&d.data.length>0){const v=d.data.map(o=>{let j="Well-being";const w=(o.name||"").toLowerCase();w.includes("climate")||w.includes("grow")?j="School Climate":w.includes("health")&&(j="Health & Wellness");const z=new Set;o.questionTemplates&&Array.isArray(o.questionTemplates)&&o.questionTemplates.forEach(k=>{const O=k.category??k.categoryName??k.categoryTitle??k.title??j;O&&typeof O=="string"&&z.add(O.trim())});const m=Array.from(z);return{id:o.id,title:o.name,description:o.description,questionCount:o.numberQuestion??o.questionTemplates?.length??0,category:j,categories:m.length>0?m:[j],rawTemplate:o}});h(v),a?.selectedTemplateId||y(o=>o||(v.length>0?v[0].id:null))}}catch(d){console.error("Error fetching survey templates:",d),n(M.setAlert({type:"danger",message:d?.message||"Failed to fetch survey templates"}))}finally{L(!1),n(M.setLoading(!1))}},[p,n]);C.useEffect(()=>{S()},[S]);const I=C.useMemo(()=>{const d=new Set;return x.forEach(v=>{v.categories&&Array.isArray(v.categories)?v.categories.forEach(o=>d.add(o)):v.category&&d.add(v.category)}),d.size===0?Je:["All",...Array.from(d)]},[x]),N=C.useMemo(()=>T==="All"?x:x.filter(d=>d.categories&&Array.isArray(d.categories)?d.categories.some(v=>v.toLowerCase()===T.toLowerCase()):d.category?.toLowerCase()===T.toLowerCase()),[x,T]),f=C.useMemo(()=>x.find(d=>d.id===c)||null,[x,c]),F=d=>{u(d)},D=d=>{y(d)},P=()=>{y("BLANK"),l(d=>Math.min(d+1,de.length-1))},G=(d,v)=>{v.stopPropagation(),A(d)},Q=()=>{A(null)},$=async d=>{try{n(M.setLoading(!0));const v=d.rawTemplate?.questionTemplates?.map(w=>w.questionId||w.id)?.filter(w=>typeof w=="number"||!String(w).startsWith("q-"))?.map(w=>Number(w))||[],o={id:d.id,name:d.title,description:d.description,isFavorite:d.rawTemplate?.isFavorite??!1,questionIds:v};await $e.updateSurvey(o),h(w=>w.map(z=>z.id===d.id?d:z)),A(null);const j=localStorage.getItem("create_survey_draft");if(j)try{const w=JSON.parse(j);w.editingTemplateFormData&&(delete w.editingTemplateFormData,localStorage.setItem("create_survey_draft",JSON.stringify(w)))}catch{}await S(),n(M.setAlert({type:"success",message:"Update template successfully"}))}catch(v){n(M.setAlert({type:"danger",message:v.response?.data?.title||"Update template failed"}))}finally{n(M.setLoading(!1))}},Y=()=>{i("/admin/survey-dashboard/list-survey")};return{steps:de,activeStep:r,categories:I,selectedCategory:T,selectedTemplateId:c,selectedTemplate:f,templates:N,rawTemplates:x,isLoading:g,editingTemplate:R,handleSelectCategory:F,handleSelectTemplate:D,handleCreateBlankSurvey:P,handleEditTemplate:G,handleCloseEditTemplate:Q,handleSaveEditTemplate:$,handleGoBackToDashboard:Y,handlePreviousStep:()=>{r>0?l(d=>d-1):Y()},handleNextStep:()=>{r<de.length-1&&l(d=>d+1)},handleGoToStep:d=>{d>=0&&d<de.length&&l(d)},refetchTemplates:S}},ue=(a,n)=>!a||!Array.isArray(a)||a.length===0?[]:a.map((i,p)=>{let r=[];return Array.isArray(i.options)&&i.options.length>0?r=i.options.map(l=>typeof l=="string"?l:l?.text??l?.answerText??l?.name??l?.title??String(l)).filter(l=>!!(l&&l.trim())):Array.isArray(i.answers)&&i.answers.length>0&&(r=i.answers.map(l=>typeof l=="string"?l:l?.text??l?.answerText??l?.name??l?.title??String(l)).filter(l=>!!(l&&l.trim()))),{id:i.questionId??i.id??`q-${p+1}`,orderNumber:i.orderDefaultQuestionTemplate??i.orderNumber??p+1,questionText:i.questionText??i.text??`Question ${p+1}`,type:String(i.type||"Text"),category:i.category??i.categoryName??i.categoryTitle??i.title??n??"General",options:r,numberOfStars:i.numberOfStars??5,fromLabel:i.fromLabel,toLabel:i.toLabel}}),pe=[{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"}],et=(a,n,i)=>{const p=C.useMemo(()=>n?.rawTemplate?ue(n.rawTemplate.questionTemplates,n?.category||"Well-being"):pe,[n]),[r,l]=C.useState(()=>i?.step2FormData?i.step2FormData:a==="BLANK"?{templateName:"",description:"",showLandingPageFlag:!1,questions:[],selectedCategoryFilter:"All"}:{templateName:n?.title||"Well-being",description:n?.description||"General assessment of student wellness and quality of life",showLandingPageFlag:!1,questions:p,selectedCategoryFilter:"All"}),T=C.useRef(i?.selectedTemplateId??(a==="BLANK"?"BLANK":n?n.id:null));C.useEffect(()=>{if(n){if(T.current===n.id)return;T.current=n.id;const S=n.rawTemplate?ue(n.rawTemplate.questionTemplates,n.category||"Well-being"):pe;l(I=>({...I,templateName:n.title||"",description:n.description||"",questions:S,selectedCategoryFilter:"All"}))}else if(a==="BLANK"){if(T.current==="BLANK")return;T.current="BLANK",l(S=>({...S,templateName:"",description:"",questions:[],selectedCategoryFilter:"All"}))}},[n,a]);const u=C.useMemo(()=>{const S=new Set;r.questions.forEach(N=>{const f=N.category?.trim();f&&S.add(f)});const I=Array.from(S);return I.length>0?["All",...I]:["All"]},[r.questions]),c=C.useMemo(()=>r.selectedCategoryFilter==="All"?r.questions:r.questions.filter(S=>S.category===r.selectedCategoryFilter),[r.questions,r.selectedCategoryFilter]),y=S=>{l(I=>({...I,templateName:S}))},x=S=>{l(I=>({...I,description:S}))},h=S=>{l(I=>({...I,selectedCategoryFilter:S}))},g=S=>{console.log("Edit question:",S)},L=S=>{l(I=>({...I,questions:I.questions.filter(N=>N.id!==S).map((N,f)=>({...N,orderNumber:f+1}))}))},R=()=>{const S=`q-${Date.now()}`,I=r.questions.length+1,N={id:S,orderNumber:I,questionText:"New Question",type:"Rating",category:"General"};l(f=>({...f,questions:[...f.questions,N]}))},A=S=>{const I=S.rawTemplate?ue(S.rawTemplate.questionTemplates,S.category||"Well-being"):pe;l({templateName:S.title||"",description:S.description||"",showLandingPageFlag:!1,questions:I,selectedCategoryFilter:"All"}),T.current=S.id};return{formData:r,questionCategories:u,filteredQuestions:c,totalQuestionsCount:r.questions.length,handleTemplateNameChange:y,handleDescriptionChange:x,handleCategoryFilterChange:h,handleEditQuestion:g,handleRemoveQuestion:L,handleAddQuestion:R,resetFormDataWithTemplate:A}},tt=(a,{initialTitle:n="",initialDeadline:i=ge().add(1,"days").format("DD.MM.YYYY hh:mm A")}={})=>{const[p,r]=C.useState(()=>a?.step3FormData?a.step3FormData:{title:n||"",deadline:i||""});return{formData:p,handleTitleChange:u=>{r(c=>({...c,title:u}))},handleDeadlineChange:u=>{r(c=>({...c,deadline:u}))}}},st=M.getStaticFileUrl("/images/image-default.png"),at=[{label:"All Flags",value:"all"},{label:"Red Flag",value:"red"},{label:"Yellow Flag",value:"yellow"},{label:"Green Flag",value:"green"}],nt=a=>{const[n,i]=C.useState([]),[p,r]=C.useState(a?.selectedStudentIds??[]),[l,T]=C.useState([]),[u,c]=C.useState(at),[y,x]=C.useState(["All Teachers"]),[h,g]=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 _=await xe.searchStudents({roles:["Admin"]});if(_?.data?.items&&Array.isArray(_.data.items)&&_.data.items.length>0){const b=_.data.items.map(m=>{let k="none";if(typeof m.flag=="string"){const Z=m.flag.toLowerCase();Z.includes("red")?k="red":Z.includes("yellow")?k="yellow":Z.includes("green")&&(k="green")}else m.redFlags>0||m.flag===1?k="red":m.yellowFlags>0||m.flag===2?k="yellow":(m.greenFlags>0||m.flag===3)&&(k="green");const O=m.fullName||m.studentName,U=m.gradeLevel,V=m.email,re=m.userId||(typeof m.id=="string"?m.id:""),J=typeof m.studentId=="number"?m.studentId:typeof m.id=="number"?m.id:void 0,me=re||(J!==void 0?String(J):`student-${Math.random()}`),fe=(m.schoolLevel||(m.userId&&m.id===void 0?"ES":"MS")).toUpperCase();return{id:me,userId:re,studentId:J,schoolLevel:fe,name:O,avatarUrl:m.profileImageFileName?M.getFileUrl(m.profileImageFileName):st,flag:k,flagTooltip:m.flagTooltip||void 0,flagDetail:m.flagDetail,lastSafetyAnswer:m.lastSafetyAnswer,lastStressAnswer:m.lastStressAnswer,flagSessionId:m.flagSessionId,flagSessionResultId:m.flagSessionResultId,grade:U,email:V,listTeachers:m.listTeachers||[]}});i(b);const d=Array.from(new Set(b.map(m=>m.grade))).filter(m=>m&&m!=="N/A"),v=m=>{if(!m||m==="N/A")return-999;const k=m.toString().toUpperCase().replace(/TH|RD|ND|ST/g,"").trim();if(k==="PK")return-2;if(k==="K")return-1;if(k==="G")return 0;const O=k.match(/^(\d+)/);return O?parseInt(O[1],10):999};d.sort((m,k)=>v(m)-v(k)),T(["All Grades",...d]);const o=Array.from(new Set(b.map(m=>m.flag))),j=[{label:"All Flags",value:"all"}];o.includes("red")&&j.push({label:"Red Flag",value:"red"}),o.includes("yellow")&&j.push({label:"Yellow Flag",value:"yellow"}),o.includes("green")&&j.push({label:"Green Flag",value:"green"}),c(j);const w=new Set;b.forEach(m=>{m.listTeachers&&m.listTeachers.length>0&&m.listTeachers.forEach(k=>{k.name&&w.add(k.name.trim())})});const z=Array.from(w).sort((m,k)=>m.localeCompare(k));x(["All Teachers",...z])}}catch(_){console.error("Error fetching students list:",_)}},[]);C.useEffect(()=>{L()},[L]);const R=_=>{g(b=>({...b,searchQuery:_,page:0}))},A=_=>{g(b=>({...b,selectedGrade:_,page:0}))},S=_=>{g(b=>({...b,selectedFlag:_,page:0}))},I=_=>{g(b=>({...b,selectedTeacher:_,page:0}))},N=(_,b)=>{g(d=>({...d,page:b}))},f=_=>{g(b=>({...b,rowsPerPage:parseInt(_.target.value,10),page:0}))},F=C.useMemo(()=>n.filter(_=>{if(h.searchQuery.trim()){const b=j=>(j||"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase(),d=b(h.searchQuery.trim()),v=b(_.name).includes(d),o=b(_.email).includes(d);if(!v&&!o)return!1}return!(h.selectedGrade!=="All Grades"&&(_.grade||"").toLowerCase()!==(h.selectedGrade||"").toLowerCase()||h.selectedFlag!=="all"&&_.flag!==h.selectedFlag||h.selectedTeacher&&h.selectedTeacher!=="All Teachers"&&(!_.listTeachers||_.listTeachers.length===0||!_.listTeachers.some(d=>d.name&&d.name.trim()===h.selectedTeacher)))}),[n,h]),D=_=>{g(b=>({...b,sortBy:_,sortOrder:b.sortBy===_&&b.sortOrder==="asc"?"desc":"asc"}))},P=C.useMemo(()=>[...F].sort((b,d)=>{let v=b[h.sortBy],o=d[h.sortBy];if(h.sortBy==="flag"){const j={red:3,yellow:2,green:1,none:0};v=j[b.flag]||0,o=j[d.flag]||0}else if(h.sortBy==="grade"){const j=w=>{if(!w||w==="N/A")return-999;const z=w.toString().toUpperCase().replace(/TH|RD|ND|ST/g,"").trim();if(z==="PK")return-2;if(z==="K")return-1;if(z==="G")return 0;const m=z.match(/^(\d+)/);return m?parseInt(m[1],10):999};v=j(b.grade),o=j(d.grade)}else h.sortBy==="teacher"?(v=b.listTeachers&&b.listTeachers.length>0?b.listTeachers.map(j=>j.name).join(", ").toLowerCase():"",o=d.listTeachers&&d.listTeachers.length>0?d.listTeachers.map(j=>j.name).join(", ").toLowerCase():""):typeof v=="string"&&typeof o=="string"&&(v=v.toLowerCase(),o=o.toLowerCase());return v<o?h.sortOrder==="asc"?-1:1:v>o?h.sortOrder==="asc"?1:-1:0}),[F,h.sortBy,h.sortOrder]),G=C.useMemo(()=>{const _=h.page*h.rowsPerPage;return P.slice(_,_+h.rowsPerPage)},[P,h.page,h.rowsPerPage]),Q=C.useMemo(()=>F.length===0?!1:F.every(_=>p.includes(_.id)),[F,p]),$=C.useMemo(()=>{if(F.length===0)return!1;const _=F.filter(b=>p.includes(b.id));return _.length>0&&_.length<F.length},[F,p]),Y=()=>{if(Q){const _=F.map(b=>b.id);r(b=>b.filter(d=>!_.includes(d)))}else{const _=new Set([...p,...F.map(b=>b.id)]);r(Array.from(_))}},K=_=>{r(b=>b.includes(_)?b.filter(d=>d!==_):[...b,_])};return{students:G,allFilteredStudents:F,allStudents:n,totalStudentsCount:F.length,totalSelectedCount:p.length,selectedStudentIds:p,filters:h,gradeOptions:l,flagOptions:u,teacherOptions:y,isAllSelected:Q,isIndeterminate:$,handleSortChange:D,handleSearchChange:R,handleGradeFilterChange:A,handleFlagFilterChange:S,handleTeacherFilterChange:I,handlePageChange:N,handleRowsPerPageChange:f,handleToggleSelectAll:Y,handleToggleStudent:K}},lt="_createSurveyPage_16fff_1",rt="_headerTopBar_16fff_16",ot="_contentBody_16fff_28",it="_stepperContainer_16fff_39",ct="_backButton_16fff_44",dt="_stepperProgress_16fff_58",ut="_stepColumn_16fff_66",ht="_stepColumnLast_16fff_72",mt="_stepCircleRow_16fff_77",ft="_stepCircle_16fff_77",pt="_active_16fff_96",gt="_completed_16fff_100",xt="_stepConnectorLine_16fff_105",yt="_stepLabelStack_16fff_115",Tt="_stepInnerDot_16fff_119",_t="_stepNumberLabel_16fff_133",bt="_stepTextLabel_16fff_145",Ct="_chooseTemplateCard_16fff_157",St="_headerSection_16fff_173",jt="_headerTitle_16fff_177",Nt="_headerSubtitle_16fff_192",vt="_bannerContainer_16fff_199",wt="_bannerIconBox_16fff_219",Bt="_bannerTitle_16fff_228",Ft="_bannerSubtitle_16fff_235",It="_bannerActionBtn_16fff_240",At="_sectionTitle_16fff_258",Lt="_filterPillsContainer_16fff_266",Rt="_filterPill_16fff_266",kt="_templateCard_16fff_301",Et="_selected_16fff_319",qt="_templateCardTitle_16fff_324",Dt="_templateEditBtn_16fff_332",Pt="_templateDescription_16fff_346",zt="_chipItem_16fff_353",Ht="_wizardFooter_16fff_367",Wt="_previousBtn_16fff_387",Mt="_disabled_16fff_409",Qt="_stepCounterText_16fff_427",Ot="_nextBtn_16fff_433",Gt="_editTemplateHeaderSection_16fff_453",Yt="_editTemplateCancelBtn_16fff_460",$t="_editTemplateSaveBtn_16fff_472",Ut="_formFieldBlock_16fff_514",Vt="_formFieldLabel_16fff_520",Kt="_requiredAsterisk_16fff_528",Jt="_customTextField_16fff_532",Zt="_formFieldHelperText_16fff_549",Xt="_questionsHeaderSection_16fff_577",es="_questionsTitle_16fff_585",ts="_questionsCountNumber_16fff_591",ss="_filterByRow_16fff_597",as="_filterByLabel_16fff_605",ns="_categoryFilterFormControl_16fff_611",ls="_categorySelectInput_16fff_616",rs="_tableContainerWrapper_16fff_634",os="_questionsTable_16fff_642",is="_tableHeaderRow_16fff_647",cs="_tableBodyRow_16fff_660",ds="_thNumber_16fff_674",us="_tdNumber_16fff_675",hs="_thQuestion_16fff_684",ms="_tdQuestion_16fff_685",fs="_questionText_16fff_691",ps="_thType_16fff_710",gs="_tdType_16fff_711",xs="_thCategory_16fff_717",ys="_tdCategory_16fff_718",Ts="_categoryText_16fff_724",_s="_thActions_16fff_731",bs="_tdActions_16fff_732",Cs="_questionTypeBadge_16fff_738",Ss="_badgeTextLabel_16fff_748",js="_badgeRating_16fff_754",Ns="_badgeYesNo_16fff_761",vs="_badgeText_16fff_748",ws="_tableEditBtn_16fff_782",Bs="_tableRemoveBtn_16fff_797",Fs="_addQuestionWrapper_16fff_812",Is="_addQuestionBtn_16fff_820",As="_selectedCountSection_16fff_839",Ls="_selectedCountText_16fff_844",Rs="_selectedCountHighlight_16fff_850",ks="_studentsToolbar_16fff_856",Es="_searchBarContainer_16fff_864",qs="_studentSearchInput_16fff_869",Ds="_filterDropdownWrapper_16fff_895",Ps="_teacherFilterWrapper_16fff_899",zs="_teacherAutocomplete_16fff_903",Hs="_teacherAutocompletePaper_16fff_960",Ws="_teacherAutocompleteListbox_16fff_968",Ms="_teacherOptionItem_16fff_985",Qs="_filterSelectBox_16fff_1029",Os="_studentsTableContainer_16fff_1055",Gs="_studentsTable_16fff_1055",Ys="_studentsTableHeaderRow_16fff_1069",$s="_checkboxHeaderCell_16fff_1080",Us="_tableHeaderCell_16fff_1088",Vs="_checkboxBodyCell_16fff_1104",Ks="_studentTableRow_16fff_1112",Js="_selectedRow_16fff_1119",Zs="_studentNameCell_16fff_1126",Xs="_studentNameText_16fff_1131",ea="_flagCell_16fff_1137",ta="_gradeCell_16fff_1142",sa="_gradeText_16fff_1147",aa="_emailCell_16fff_1152",na="_emailText_16fff_1157",la="_studentsPagination_16fff_1162",ra="_reviewSectionBlock_16fff_1180",oa="_reviewSectionHeader_16fff_1189",ia="_reviewSectionTitle_16fff_1196",ca="_reviewEditSectionBtn_16fff_1202",da="_reviewFieldGroup_16fff_1213",ua="_reviewFieldLabel_16fff_1217",ha="_reviewFieldValue_16fff_1225",ma="_reviewQuestionsTableContainer_16fff_1231",fa="_previewSurveyBtn_16fff_1237",pa="_publishBtn_16fff_1253",s={createSurveyPage:lt,headerTopBar:rt,contentBody:ot,stepperContainer:it,backButton:ct,stepperProgress:dt,stepColumn:ut,stepColumnLast:ht,stepCircleRow:mt,stepCircle:ft,active:pt,completed:gt,stepConnectorLine:xt,stepLabelStack:yt,stepInnerDot:Tt,stepNumberLabel:_t,stepTextLabel:bt,chooseTemplateCard:Ct,headerSection:St,headerTitle:jt,headerSubtitle:Nt,bannerContainer:vt,bannerIconBox:wt,bannerTitle:Bt,bannerSubtitle:Ft,bannerActionBtn:It,sectionTitle:At,filterPillsContainer:Lt,filterPill:Rt,templateCard:kt,selected:Et,templateCardTitle:qt,templateEditBtn:Dt,templateDescription:Pt,chipItem:zt,wizardFooter:Ht,previousBtn:Wt,disabled:Mt,stepCounterText:Qt,nextBtn:Ot,editTemplateHeaderSection:Gt,editTemplateCancelBtn:Yt,editTemplateSaveBtn:$t,formFieldBlock:Ut,formFieldLabel:Vt,requiredAsterisk:Kt,customTextField:Jt,formFieldHelperText:Zt,questionsHeaderSection:Xt,questionsTitle:es,questionsCountNumber:ts,filterByRow:ss,filterByLabel:as,categoryFilterFormControl:ns,categorySelectInput:ls,tableContainerWrapper:rs,questionsTable:os,tableHeaderRow:is,tableBodyRow:cs,thNumber:ds,tdNumber:us,thQuestion:hs,tdQuestion:ms,questionText:fs,thType:ps,tdType:gs,thCategory:xs,tdCategory:ys,categoryText:Ts,thActions:_s,tdActions:bs,questionTypeBadge:Cs,badgeTextLabel:Ss,badgeRating:js,badgeYesNo:Ns,badgeText:vs,tableEditBtn:ws,tableRemoveBtn:Bs,addQuestionWrapper:Fs,addQuestionBtn:Is,selectedCountSection:As,selectedCountText:Ls,selectedCountHighlight:Rs,studentsToolbar:ks,searchBarContainer:Es,studentSearchInput:qs,filterDropdownWrapper:Ds,teacherFilterWrapper:Ps,teacherAutocomplete:zs,teacherAutocompletePaper:Hs,teacherAutocompleteListbox:Ws,teacherOptionItem:Ms,filterSelectBox:Qs,studentsTableContainer:Os,studentsTable:Gs,studentsTableHeaderRow:Ys,checkboxHeaderCell:$s,tableHeaderCell:Us,checkboxBodyCell:Vs,studentTableRow:Ks,selectedRow:Js,studentNameCell:Zs,studentNameText:Xs,flagCell:ea,gradeCell:ta,gradeText:sa,emailCell:aa,emailText:na,studentsPagination:la,reviewSectionBlock:ra,reviewSectionHeader:oa,reviewSectionTitle:ia,reviewEditSectionBtn:ca,reviewFieldGroup:da,reviewFieldLabel:ua,reviewFieldValue:ha,reviewQuestionsTableContainer:ma,previewSurveyBtn:fa,publishBtn:pa},ga=({steps:a,activeStep:n,onBack:i})=>e.jsxs(t.Box,{className:s.stepperContainer,children:[e.jsx(t.Button,{onClick:i,startIcon:e.jsx(be.ArrowBackIcon,{fontSize:"small"}),className:s.backButton,children:"Back to Surveys Dashboard"}),e.jsx(t.Box,{className:s.stepperProgress,children:a.map((p,r)=>{const l=r===n,T=r<n,u=r===a.length-1;return e.jsxs(t.Box,{className:`${s.stepColumn} ${u?s.stepColumnLast:""}`,children:[e.jsxs(t.Box,{className:s.stepCircleRow,children:[e.jsxs(t.Box,{className:`${s.stepCircle} ${l?s.active:T?s.completed:""}`,children:[l&&e.jsx(t.Box,{className:s.stepInnerDot}),T&&e.jsx(Ce.CheckIcon,{sx:{fontSize:16,color:"#ffffff"}})]}),!u&&e.jsx(t.Box,{className:`${s.stepConnectorLine} ${T?s.completed:""}`})]}),e.jsxs(t.Stack,{alignItems:"flex-start",spacing:.25,className:s.stepLabelStack,children:[e.jsxs(t.Typography,{variant:"caption",className:`${s.stepNumberLabel} ${l?s.active:""}`,children:["STEP ",p.stepNumber]}),e.jsx(t.Typography,{variant:"body2",className:`${s.stepTextLabel} ${l?s.active:""}`,children:p.label})]})]},p.stepCode)})})]}),xa=({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(Se.ArrowForwardIcon,{sx:{fontSize:16}}),className:s.bannerActionBtn,children:"CREATE BLANK SURVEY"})]}),ya=({categories:a,selectedCategory:n,onSelectCategory:i})=>e.jsx(t.Box,{className:s.filterPillsContainer,children:e.jsx(t.Stack,{direction:"row",spacing:1.5,alignItems:"center",children:a.map(p=>{const r=n.toLowerCase()===p.toLowerCase();return e.jsx(t.Chip,{label:p,onClick:()=>i(p),className:`${s.filterPill} ${r?s.active:""}`},p)})})}),se=ne.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"),Ta=({template:a,isSelected:n,onSelect:i,onEdit:p})=>{const r=a.categories&&a.categories.length>0?a.categories:a.category?[a.category]:[],l=C.useRef(null),T=C.useRef(null),[u,c]=C.useState(r.length);return C.useEffect(()=>{const y=l.current,x=T.current;if(!y||!x)return;const h=()=>{const L=y.clientWidth,R=Array.from(x.children);if(R.length===0)return;const A=6;let S=0;const I=R[0].getBoundingClientRect().width,N=R[R.length-1].getBoundingClientRect().width;S+=I;let f=0;const F=R.length-2;for(let D=0;D<F;D++){const P=R[D+1].getBoundingClientRect().width;if((D===F-1?S+A+P:S+A+P+A+N)<=L)S+=A+P,f++;else break}c(f)},g=new ResizeObserver(()=>{h()});return g.observe(y),h(),()=>g.disconnect()},[r]),e.jsxs(t.Box,{onClick:()=>i(a.id),className:`${s.templateCard} ${n?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:y=>p(a,y),startIcon:e.jsx(se,{sx:{fontSize:14}}),className:s.templateEditBtn,children:"EDIT"})]}),e.jsx(t.Typography,{variant:"body2",className:s.templateDescription,children:a.description})]}),e.jsxs(t.Box,{ref:l,sx:{position:"relative",width:"100%",height:24,overflow:"hidden"},children:[e.jsxs(t.Stack,{direction:"row",spacing:1,alignItems:"center",sx:{gap:.75,flexWrap:"nowrap"},children:[e.jsx(t.Chip,{label:`${a.questionCount} questions`,size:"small",className:s.chipItem,sx:{flexShrink:0}}),r.slice(0,u).map((y,x)=>e.jsx(t.Chip,{label:y,size:"small",className:s.chipItem,sx:{flexShrink:0}},x)),u<r.length&&e.jsx(t.Chip,{label:"...",size:"small",className:s.chipItem,sx:{flexShrink:0}})]}),e.jsxs(t.Stack,{ref:T,direction:"row",spacing:1,alignItems:"center",sx:{gap:.75,flexWrap:"nowrap",position:"absolute",top:0,left:0,visibility:"hidden",pointerEvents:"none",zIndex:-1,width:"max-content"},children:[e.jsx(t.Chip,{label:`${a.questionCount} questions`,size:"small",className:s.chipItem}),r.map((y,x)=>e.jsx(t.Chip,{label:y,size:"small",className:s.chipItem},x)),e.jsx(t.Chip,{label:"...",size:"small",className:s.chipItem})]})]})]})},_a=ne.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"),le=({currentStep:a,totalSteps:n,onPrevious:i,onNext:p,isNextDisabled:r=!1,isLastStep:l=!1,nextLabel:T="NEXT",onPreview:u})=>e.jsxs(t.Box,{className:s.wizardFooter,children:[e.jsx(t.Button,{variant:"outlined",onClick:i,startIcon:e.jsx(be.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 ",n]}),l?e.jsxs(t.Stack,{direction:"row",spacing:1.5,alignItems:"center",children:[u&&e.jsx(t.Button,{variant:"outlined",onClick:u,startIcon:e.jsx(_a,{sx:{fontSize:18}}),className:s.previewSurveyBtn,children:"SURVEY PREVIEW"}),e.jsx(t.Button,{variant:"contained",onClick:p,disabled:r,className:s.publishBtn,children:T||"PUBLISH"})]}):e.jsx(t.Button,{variant:"contained",onClick:p,disabled:r,endIcon:e.jsx(Se.ArrowForwardIcon,{sx:{fontSize:16}}),className:s.nextBtn,children:T})]}),ba=({categories:a,selectedCategory:n,templates:i,selectedTemplateId:p,currentStepNumber:r,totalSteps:l,onSelectCategory:T,onSelectTemplate:u,onCreateBlank:c,onEditTemplate:y,onPrevious:x,onNext:h})=>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(xa,{onCreateBlank:c}),e.jsxs(t.Stack,{spacing:1,children:[e.jsx(t.Typography,{variant:"h6",className:s.sectionTitle,children:"Survey Templates"}),e.jsx(ya,{categories:a,selectedCategory:n,onSelectCategory:T})]}),e.jsx(t.Grid,{container:!0,spacing:2.5,sx:{mt:1},children:i.map(g=>e.jsx(t.Grid,{item:!0,xs:12,sm:6,md:4,children:e.jsx(Ta,{template:g,isSelected:p===g.id,onSelect:u,onEdit:y})},g.id))}),e.jsx(le,{currentStep:r,totalSteps:l,onPrevious:x,onNext:h})]}),Ca=ne.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"),Ne=({type:a})=>{const n=r=>{if(typeof r=="number"||!isNaN(Number(r))){const l=Number(r);if(l===0)return"Text";if(l===1)return"MultipleChoice";if(l===2||l===3)return"Slider";if(l===4)return"YesNo";if(l===5)return"SingleChoice";if(l===6)return"Date"}return String(r)},i=r=>{switch(n(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}},p=r=>{const l=n(r);switch(l){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 l}};return e.jsx(t.Box,{className:`${s.questionTypeBadge} ${i(a)}`,children:e.jsx(t.Typography,{variant:"caption",className:s.badgeTextLabel,children:p(a)})})},ve=({questions:a,onEditQuestion:n,onRemoveQuestion:i})=>{const[p,r]=C.useState(null),[l,T]=C.useState(!1),u=x=>{r(x),T(!0)},c=()=>{p!==null&&i(p),T(!1),r(null)},y=()=>{T(!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((x,h)=>e.jsxs(t.TableRow,{className:s.tableBodyRow,children:[e.jsxs(t.TableCell,{className:s.tdNumber,children:[h+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(Ne,{type:x.type})}),e.jsx(t.TableCell,{className:s.tdCategory,children:e.jsx(t.Typography,{variant:"body2",className:s.categoryText,children:x.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:()=>n(x.id),startIcon:e.jsx(se,{fontSize:"small"}),className:s.tableEditBtn,children:"Edit"}),e.jsx(t.Button,{onClick:()=>u(x.id),startIcon:e.jsx(Ca,{fontSize:"small"}),className:s.tableRemoveBtn,children:"Remove"})]})})]},x.id))})]}),e.jsxs(t.Dialog,{open:l,onClose:y,"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:y,color:"inherit",children:"Cancel"}),e.jsx(t.Button,{onClick:c,color:"error",autoFocus:!0,children:"Remove"})]})]})]})},Sa=({formData:a,questionCategories:n,filteredQuestions:i,totalQuestionsCount:p,currentStepNumber:r,totalSteps:l,onTemplateNameChange:T,onDescriptionChange:u,onCategoryFilterChange:c,onEditQuestion:y,onRemoveQuestion:x,onAddQuestion:h,onPrevious:g,onNext:L})=>{const R=A=>{c(A.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:A=>T(A.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:A=>u(A.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:p})]}),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:R,className:s.categorySelectInput,children:n.map(A=>e.jsx(t.MenuItem,{value:A,children:A},A))})})]})]}),e.jsx(ve,{questions:i,onEditQuestion:y,onRemoveQuestion:x}),e.jsx(t.Box,{className:s.addQuestionWrapper,children:e.jsx(t.Button,{onClick:h,startIcon:e.jsx(je.AddIcon,{}),className:s.addQuestionBtn,children:"ADD QUESTION"})}),e.jsx(le,{currentStep:r,totalSteps:l,onPrevious:g,onNext:L,isNextDisabled:!a.templateName||a.templateName.trim()===""})]})},ja=({formData:a,currentStepNumber:n,totalSteps:i,onTitleChange:p,onDeadlineChange:r,onPrevious:l,onNext:T})=>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:u=>p(u.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(ye.LocalizationProvider,{dateAdapter:Ue.AdapterMoment,children:e.jsx(ye.DateTimePicker,{value:a.deadline?ge(a.deadline,"DD.MM.YYYY hh:mm A"):null,onChange:u=>{r(u?u.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(le,{currentStep:n,totalSteps:i,onPrevious:l,onNext:T,isNextDisabled:!a.title||a.title.trim()===""||!a.deadline})]}),ae=({size:a=32,color:n="#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:n})}),B={"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"},Te=a=>{switch(a){case"Red Flag":return e.jsxs("div",{className:B["flag-of-session__title-red"],children:[e.jsx(ae,{color:"#C44140",size:32}),e.jsx("span",{className:B["flag-of-session__title-red--text"],children:"Red Flag"})]});case"Yellow Flag":return e.jsxs("div",{className:B["flag-of-session__title-yellow"],children:[e.jsx(ae,{color:"#F5D500",size:32}),e.jsx("span",{className:B["flag-of-session__title-yellow--text"],children:"Yellow Flag"})]});default:return null}},Na=({flag:a,flagDetail:n,lastSafetyAnswer:i,lastStressAnswer:p,showResult:r,defaultStress:l,defaultSafety:T,defaultDecrease:u,isDetailView:c,hasReadyToLearn:y,inSession:x})=>r?e.jsxs("div",{className:B["flag-of-session"],style:{gap:"6px"},children:[(a==="Green Flag"||a==="Green")&&e.jsxs("div",{className:B["flag-of-session__content-green"],children:["Everything is ",e.jsx("p",{className:B["flag-of-session__content-green--text"],children:"fine"})]}),c&&a&&Te(a||""),n?.stress&&(c?e.jsxs("div",{className:B["flag-of-session__item"],children:[e.jsx("p",{className:B["flag-of-session__item--title"],children:"Stress score:"}),e.jsxs("p",{className:B["flag-of-session__item--content"],children:[n?.stress?.score,"%"]})]}):e.jsxs("div",{className:B["flag-of-session__item"],children:[e.jsxs("span",{style:{fontWeight:600,color:n?.stress?.flag==="Red Flag"?"#C44140":"#F5D500",fontSize:"12px"},children:[n?.stress?.score,"%"]}),"Stress vs Last check-in ",p,"%"]})),n?.safety&&(c?e.jsxs("div",{className:B["flag-of-session__item"],children:[e.jsx("p",{className:B["flag-of-session__item--title"],children:"Safety score:"}),e.jsxs("p",{className:B["flag-of-session__item--content"],children:[n?.safety?.score,"%"]})]}):e.jsxs("div",{className:B["flag-of-session__item"],children:[e.jsxs("span",{style:{fontWeight:600,color:n?.safety?.flag==="Red Flag"?"#C44140":"#F5D500"},children:[n?.safety?.score,"%"]})," Safety vs Last check-in ",i,"%"]})),n?.decrease&&n?.decrease?.length>0&&(c?e.jsxs("div",{children:[e.jsxs("p",{className:B["flag-of-session__item--content"],children:[e.jsx("span",{className:B["flag-of-session__item--title"],children:"Sudden Drop: "}),e.jsxs("span",{className:B["flag-of-session__item--title"],children:[n.decrease.length," "]}),"core well-being metric shows a decrease of ",u,"% comparing their average of the last four check-ins."]}),e.jsx("ul",{className:B["flag-of-session__item-column--content"],children:n.decrease?.map((h,g)=>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:[h.questionText,": ",h.answer,"% ",h.averageOtherRatingsText?"":h.averageOtherRatings!==void 0?`vs avr ${h.averageOtherRatings}%`:"vs previous"]})})},g))})]}):x?e.jsxs("div",{className:B["flag-of-session__item-column"],children:[e.jsxs("p",{className:B["flag-of-session__item-column--no-bold"],children:["Sudden Drop: ",n.decrease.length||0," core well-being metric shows a decrease compared to the average of the last four check-ins."]}),e.jsx("ul",{className:B["flag-of-session__item-column--content"],children:n.decrease?.map((h,g)=>{const R=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:[h.questionText,":"]}),e.jsxs("p",{style:{margin:0,color:R,fontSize:"12px"},children:[h.answer,"%"]}),h.averageOtherRatingsText?"":h.averageOtherRatings!==void 0&&e.jsxs("p",{style:{margin:0,fontSize:"12px",marginLeft:"4px"},children:["vs avr ",h.averageOtherRatings,"%"]})]})},g)})})]}):e.jsxs("div",{className:B["flag-of-session__item"],children:["Sudden Drop: Any core well-being metric shows a percentage decrease of ",u||20,"% comparing their average of the last four check-ins."]})),n?.readinessToLearn&&(c?e.jsx("div",{children:e.jsxs("p",{className:B["flag-of-session__item--content"],children:[e.jsx("span",{className:B["flag-of-session__item--title"],children:"Ready to learn: "}),n?.readinessToLearn]})}):e.jsxs("div",{className:B["flag-of-session__item"],children:["Ready to learn: ",n?.readinessToLearn]}))]}):e.jsxs("div",{className:B["flag-of-session"],children:[Te(a||""),T&&e.jsxs("div",{className:B["flag-of-session__item"],children:[e.jsx("p",{className:B["flag-of-session__item--title"],children:"Safety score:"}),e.jsxs("p",{className:B["flag-of-session__item--content"],children:["Under ",T,"%"]})]}),l&&e.jsxs("div",{className:B["flag-of-session__item"],children:[e.jsx("p",{className:B["flag-of-session__item--title"],children:"Stress level:"}),e.jsxs("p",{className:B["flag-of-session__item--content"],children:["Higher than ",l,"%"]})]}),u&&e.jsx("div",{children:e.jsxs("p",{className:B["flag-of-session__item--content"],children:[e.jsx("span",{className:B["flag-of-session__item--title"],children:"Sudden Drop: "}),"Any core well-being metric shows a percentage decrease of ",u,"% comparing their average of the last four check-ins."]})}),y&&e.jsx("div",{children:e.jsxs("p",{className:B["flag-of-session__item--content"],children:[e.jsx("span",{className:B["flag-of-session__item--title"],children:"Ready to learn: "}),"The student reported as not ready to learn in last check-in."]})})]}),va=ne.styled$1(({className:a,...n})=>e.jsx(t.Tooltip,{...n,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"}})),wa=a=>{if(!a)return null;const n=a.toLowerCase();return n==="red"?e.jsx(ae,{size:32,color:"#C44140"}):n==="yellow"?e.jsx(ae,{size:32,color:"#F5D500"}):n==="green"?e.jsx(ae,{size:32,color:"#10B981"}):null},Ba=({students:a,totalStudentsCount:n,totalSelectedCount:i,selectedStudentIds:p,filters:r,gradeOptions:l,flagOptions:T,teacherOptions:u,page:c,rowsPerPage:y,isAllSelected:x,isIndeterminate:h,sortBy:g,sortOrder:L,onSortChange:R,currentStepNumber:A,totalSteps:S,onSearchChange:I,onGradeChange:N,onFlagChange:f,onTeacherChange:F,onPageChange:D,onRowsPerPageChange:P,onToggleSelectAll:G,onToggleStudent:Q,onPrevious:$,onNext:Y})=>{const K=o=>{N(o.target.value)},_=o=>{f(o.target.value)},b=(o,j)=>{F(j||"All Teachers")},d=C.useMemo(()=>!u||u.length===0?["All Teachers"]:u.includes("All Teachers")?u:["All Teachers",...u],[u]),v=(o,j)=>{const w=(j.inputValue||"").trim().toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"");return w?o.filter(z=>z.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").includes(w)):o};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:i})]})}),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:o=>I(o.target.value),className:s.studentSearchInput,InputProps:{startAdornment:e.jsx(t.InputAdornment,{position:"start",children:e.jsx(Ve.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:K,displayEmpty:!0,className:s.filterSelectBox,children:l.map(o=>e.jsx(t.MenuItem,{value:o,children:o},o))})})}),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:_,displayEmpty:!0,className:s.filterSelectBox,children:T.map(o=>e.jsx(t.MenuItem,{value:o.value,children:o.label},o.value))})})}),e.jsx(t.Box,{className:s.teacherFilterWrapper,children:e.jsx(t.Autocomplete,{size:"small",fullWidth:!0,options:d,value:r.selectedTeacher||"All Teachers",onChange:b,disableClearable:r.selectedTeacher==="All Teachers",clearOnBlur:!0,handleHomeEndKeys:!0,isOptionEqualToValue:(o,j)=>!j||o===j||j==="All Teachers",filterOptions:v,noOptionsText:"No teachers found",className:s.teacherAutocomplete,classes:{paper:s.teacherAutocompletePaper,listbox:s.teacherAutocompleteListbox},componentsProps:{paper:{className:s.teacherAutocompletePaper,sx:{backgroundColor:"#ffffff !important",color:"#000000 !important"}},popper:{sx:{zIndex:1300}}},slotProps:{paper:{className:s.teacherAutocompletePaper,sx:{backgroundColor:"#ffffff !important",color:"#000000 !important"}},popper:{sx:{zIndex:1300}}},renderOption:(o,j,{selected:w})=>{const{key:z,...m}=o;return e.jsx("li",{...m,className:s.teacherOptionItem,style:{backgroundColor:w?"#f1f5f9":"#ffffff",color:"#000000",fontSize:"14px",fontWeight:w?600:500,padding:"9px 14px",cursor:"pointer"},children:j},z||j)},renderInput:o=>e.jsx(t.TextField,{...o,placeholder:"All Teachers",size:"small",inputProps:{...o.inputProps,style:{color:"#000000",fontWeight:500}}})})})]}),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:x,indeterminate:h,onChange:G,sx:{color:"#cbd5e1","&.Mui-checked":{color:"#2563eb"},"&.MuiCheckbox-indeterminate":{color:"#2563eb"}}})}),e.jsx(t.TableCell,{className:s.tableHeaderCell,children:e.jsx(t.TableSortLabel,{active:g==="name",direction:g==="name"?L:"asc",onClick:()=>R("name"),children:"Student Name"})}),e.jsx(t.TableCell,{className:s.tableHeaderCell,children:e.jsx(t.TableSortLabel,{active:g==="flag",direction:g==="flag"?L:"asc",onClick:()=>R("flag"),children:"Flag"})}),e.jsx(t.TableCell,{className:s.tableHeaderCell,children:e.jsx(t.TableSortLabel,{active:g==="grade",direction:g==="grade"?L:"asc",onClick:()=>R("grade"),children:"Grade"})}),e.jsx(t.TableCell,{className:s.tableHeaderCell,children:e.jsx(t.TableSortLabel,{active:g==="email",direction:g==="email"?L:"asc",onClick:()=>R("email"),children:"Email"})}),e.jsx(t.TableCell,{className:s.tableHeaderCell,children:e.jsx(t.TableSortLabel,{active:g==="teacher",direction:g==="teacher"?L:"asc",onClick:()=>R("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(o=>{const j=p.includes(o.id);return e.jsxs(t.TableRow,{className:`${s.studentTableRow} ${j?s.selectedRow:""}`,onClick:()=>Q(o.id),children:[e.jsx(t.TableCell,{className:s.checkboxBodyCell,onClick:w=>w.stopPropagation(),children:e.jsx(t.Checkbox,{checked:j,onChange:()=>Q(o.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:o.avatarUrl,alt:o.name,style:{width:44,height:44,borderRadius:"50%",objectFit:"cover"}}),e.jsx(t.Typography,{variant:"body2",className:s.studentNameText,children:o.name})]})}),e.jsx(t.TableCell,{className:s.flagCell,children:e.jsx(va,{arrow:!0,placement:"bottom",title:o?.flag&&o.flag!=="none"?e.jsx(Na,{flag:o.flag==="red"?"Red Flag":o.flag==="yellow"?"Yellow Flag":"Green Flag",flagDetail:o.flagDetail,lastSafetyAnswer:o.lastSafetyAnswer,lastStressAnswer:o.lastStressAnswer,showResult:!0}):"",children:e.jsx("span",{children:e.jsx("div",{style:{display:"flex",justifyContent:"center",cursor:"pointer"},children:wa(o.flag)})})})}),e.jsx(t.TableCell,{className:s.gradeCell,children:e.jsx(t.Typography,{variant:"body2",className:s.gradeText,children:o.grade})}),e.jsx(t.TableCell,{className:s.emailCell,children:e.jsx(t.Typography,{variant:"body2",className:s.emailText,children:o.email})}),e.jsx(t.TableCell,{children:e.jsx(t.Typography,{variant:"body2",sx:{color:"#475569"},children:o.listTeachers&&o.listTeachers.length>0?o.listTeachers.map(w=>w.name).filter(Boolean).join(", "):"-"})})]},o.id)})})]}),n>0&&e.jsx(t.TablePagination,{rowsPerPageOptions:[5,10,25,50],component:"div",count:n,rowsPerPage:y,page:c,onPageChange:D,onRowsPerPageChange:P,className:s.studentsPagination})]}),e.jsx(le,{currentStep:A,totalSteps:S,onPrevious:$,onNext:Y})]})},Fa=({size:a=32,color:n="#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:n})}),Ia=t.styled(({className:a,...n})=>e.jsx(t.Tooltip,{...n,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"}}})),Aa=({flag:a,tooltip:n})=>{if(a==="none")return null;let i="#10B981";a==="red"?i="#D10530":a==="yellow"?i="#F5D500":a==="green"&&(i="#0F9655");const p=n?e.jsx(t.Box,{sx:{lineHeight:1.4},children:n}):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(Ia,{title:p,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(Fa,{color:i,size:28})})})},La=ne.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"),Ra=({open:a,title:n,description:i,deadline:p,questions:r,onClose:l})=>{const T=c=>{if(typeof c=="number"||!isNaN(Number(c))&&String(c).trim()!==""){const y=Number(c);if(y===0)return"Text";if(y===1)return"MultipleChoice";if(y===2||y===3)return"Slider";if(y===4)return"YesNo";if(y===5)return"SingleChoice";if(y===6)return"Date";if(y===9)return"Summarize";if(y===12)return"DropDown"}return String(c)},u=c=>{try{const y=document.createElement("textarea");return y.innerHTML=c,y.value}catch{return c}};return e.jsxs(t.Dialog,{open:a,onClose:l,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:l,size:"small",sx:{color:"#64748b"},children:e.jsx(Ke.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:n||"Student Well Being"}),e.jsx(t.Typography,{variant:"body2",sx:{color:"#64748b",mb:2},children:i||"General assessment of student wellness and quality of life"}),p&&e.jsxs(t.Stack,{direction:"row",spacing:1,alignItems:"center",sx:{color:"#64748b",mb:3},children:[e.jsx(La,{sx:{fontSize:16,color:"#2563eb"}}),e.jsxs(t.Typography,{variant:"caption",sx:{fontWeight:600},children:["Due: ",p]})]}),e.jsx(t.Stack,{spacing:3,children:r.map((c,y)=>{const x=T(c.type),h=c.options&&c.options.length>0?c.options:c.answers&&Array.isArray(c.answers)?c.answers.map(g=>typeof g=="string"?g:g?.text??g?.answerText??"").filter(Boolean):[];return 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:[y+1,"."]}),e.jsx(t.Box,{sx:{"& p":{m:0,display:"inline"},"& span":{display:"inline"}},dangerouslySetInnerHTML:{__html:u(c.questionText||"")}})]}),(x==="Rating"||x==="StarRating"||x==="Slider")&&e.jsx(t.Box,{sx:{px:2,py:1},children:e.jsx(ce.SliderSurveyComponent,{questionId:Number(c.id)||0,valueText:"50",minText:c.fromLabel||"",maxText:c.toLabel||"",isBeforeSession:!1,isPageResult:!0})}),x==="MultipleChoice"&&e.jsx(t.Box,{sx:{px:2},children:e.jsx(ce.MultiChoiceComponent,{questionId:Number(c.id)||0,valueText:"",isUserChangeSession:!0,questionAnswer:h,isPageResult:!0})}),(x==="YesNo"||x==="SingleChoice")&&e.jsx(t.Box,{sx:{px:2},children:e.jsx(ce.SingleChoiceComponent,{questionId:Number(c.id)||0,valueText:"",isUserChangeSession:!0,questionAnswer:h.length>0?h:x==="YesNo"?["Yes","No"]:[]})}),(x==="Text"||x==="TextInput"||x==="OpenField")&&e.jsx(t.TextField,{fullWidth:!0,multiline:!0,rows:2,placeholder:"Your answer...",size:"small",sx:{"& .MuiOutlinedInput-root":{borderRadius:"8px",backgroundColor:"#ffffff"}}}),x==="DropDown"&&e.jsx(t.Box,{sx:{px:2},children:e.jsx(ce.DropDownComponent,{questionItemName:"",questionId:Number(c.id)||0,valueText:"",isUserChangeSession:!0,questionAnswer:h.map((g,L)=>({id:L,text:g}))})}),x==="Summarize"&&e.jsx(t.TextField,{fullWidth:!0,multiline:!0,rows:4,placeholder:"Summarize your thoughts...",size:"small",sx:{"& .MuiOutlinedInput-root":{borderRadius:"8px",backgroundColor:"#ffffff"}}})]},c.id)})})]})]})},ka=({templateFormData:a,surveyFormData:n,selectedStudents:i,currentStepNumber:p,totalSteps:r,onEditTemplateDetails:l,onEditSurveyDetails:T,onEditSelectedStudents:u,onPrevious:c,onPublish:y})=>{const[x,h]=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:l,startIcon:e.jsx(se,{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((g,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:g.questionText||""}})}),e.jsx(t.TableCell,{className:s.tdType,children:e.jsx(Ne,{type:g.type})}),e.jsx(t.TableCell,{className:s.tdCategory,children:e.jsx(t.Typography,{variant:"body2",className:s.categoryText,children:g.category})})]},g.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:T,startIcon:e.jsx(se,{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:n.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:n.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:i.length})]}),e.jsx(t.Button,{variant:"text",onClick:u,startIcon:e.jsx(se,{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:i.length===0?e.jsx(t.TableRow,{children:e.jsx(t.TableCell,{colSpan:4,align:"center",sx:{py:3,color:"#94a3b8"},children:"No students selected."})}):i.map(g=>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:g.avatarUrl,alt:g.name,sx:{width:28,height:28,fontSize:"0.75rem",bgcolor:"#e0e7ff",color:"#3730a3"},children:g.name.charAt(0)}),e.jsx(t.Typography,{variant:"body2",className:s.studentNameText,children:g.name})]})}),e.jsx(t.TableCell,{className:s.flagCell,children:e.jsx(Aa,{flag:g.flag,tooltip:g.flagTooltip})}),e.jsx(t.TableCell,{className:s.gradeCell,children:e.jsx(t.Typography,{variant:"body2",className:s.gradeText,children:g.grade})}),e.jsx(t.TableCell,{className:s.emailCell,children:e.jsx(t.Typography,{variant:"body2",className:s.emailText,children:g.email})})]},g.id))})]})})]}),e.jsx(le,{currentStep:p,totalSteps:r,isLastStep:!0,nextLabel:"PUBLISH",onPreview:()=>h(!0),onPrevious:c,onNext:y}),e.jsx(Ra,{open:x,title:n.title||a.templateName,description:a.description,deadline:n.deadline,questions:a.questions,onClose:()=>h(!1)})]})},Ea=[{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"}],qa=({template:a,initialDraftData:n,onSave:i,onCancel:p,onAddQuestionRedirect:r,onEditQuestionRedirect:l})=>{const T=C.useMemo(()=>a.rawTemplate?ue(a.rawTemplate.questionTemplates,a.category||"Well-being"):Ea,[a]),[u,c]=C.useState(()=>n||{id:a.id,templateName:a.title,description:a.description||"",showLandingPageFlag:!1,selectedCategoryFilter:"All",questions:T}),y=C.useMemo(()=>{const N=new Set;u.questions.forEach(F=>{const D=F.category?.trim();D&&N.add(D)});const f=Array.from(N);return f.length>0?["All",...f]:["All"]},[u.questions]),x=C.useMemo(()=>u.selectedCategoryFilter==="All"?u.questions:u.questions.filter(N=>N.category===u.selectedCategoryFilter),[u.questions,u.selectedCategoryFilter]),h=N=>{c(f=>({...f,templateName:N}))},g=N=>{c(f=>({...f,description:N}))},L=N=>{c(f=>({...f,selectedCategoryFilter:N}))},R=N=>{l&&l(N,u)},A=N=>{c(f=>({...f,questions:f.questions.filter(F=>F.id!==N).map((F,D)=>({...F,orderNumber:D+1}))}))},S=()=>{r&&r(u)},I=()=>{const N={...a,title:u.templateName,description:u.description,questionCount:u.questions.length,rawTemplate:{...a.rawTemplate,questionTemplates:u.questions.map((f,F)=>({...f,questionId:typeof f.id=="number"||String(f.id).startsWith("q-")?f.id:parseInt(String(f.id)),questionText:f.questionText,type:f.type,category:f.category,fromLabel:f.fromLabel,toLabel:f.toLabel,numberOfStars:f.numberOfStars,orderDefaultQuestionTemplate:f.orderNumber??F+1,options:f.options||[],answers:f.options&&Array.isArray(f.options)&&f.options.length>0?f.options.map((D,P)=>({id:0,text:typeof D=="string"?D:D?.text||"",order:P})):f.answers||[]}))}};i(N)};return{formData:u,categoryOptions:y,filteredQuestions:x,totalQuestionsCount:u.questions.length,handleTemplateNameChange:h,handleDescriptionChange:g,handleCategoryFilterChange:L,handleEditQuestion:R,handleRemoveQuestion:A,handleAddQuestion:S,handleSave:I,handleCancel:p}},Da=({template:a,initialDraftData:n,onSave:i,onCancel:p,onAddQuestionRedirect:r,onEditQuestionRedirect:l})=>{const{formData:T,categoryOptions:u,filteredQuestions:c,totalQuestionsCount:y,handleTemplateNameChange:x,handleDescriptionChange:h,handleCategoryFilterChange:g,handleEditQuestion:L,handleRemoveQuestion:R,handleAddQuestion:A,handleSave:S,handleCancel:I}=qa({template:a,initialDraftData:n,onSave:i,onCancel:p,onAddQuestionRedirect:r,onEditQuestionRedirect:l});C.useEffect(()=>{window.scrollTo({top:0,behavior:"instant"});const f=document.querySelector("main");f&&f.scrollTo({top:0,behavior:"instant"});const F=document.documentElement||document.body;F&&(F.scrollTop=0)},[]);const N=f=>{g(f.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:I,className:s.editTemplateCancelBtn,children:"CANCEL"}),e.jsx(t.Button,{variant:"contained",onClick:S,startIcon:e.jsx(Ce.CheckIcon,{}),className:s.editTemplateSaveBtn,disabled:!T.templateName||T.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:T.templateName,onChange:f=>x(f.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:T.description,onChange:f=>h(f.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:y})]}),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:T.selectedCategoryFilter,onChange:N,className:s.categorySelectInput,children:u.map(f=>e.jsx(t.MenuItem,{value:f,children:f},f))})})]})]}),e.jsx(ve,{questions:c,onEditQuestion:L,onRemoveQuestion:R}),e.jsx(t.Box,{className:s.addQuestionWrapper,children:e.jsx(t.Button,{onClick:A,startIcon:e.jsx(je.AddIcon,{}),className:s.addQuestionBtn,children:"ADD QUESTION"})})]})},Pa=()=>{const a=he.useDispatch(),n=he.useSelector(E=>E?.common?.user?.roles),i=_e.useNavigate(),p=C.useMemo(()=>{if(localStorage.getItem("is_returning_from_question")==="true"){const W=localStorage.getItem("create_survey_draft");if(W)try{return JSON.parse(W)}catch{}}return null},[]);C.useEffect(()=>{const E=setTimeout(()=>{localStorage.getItem("is_returning_from_question")==="true"?localStorage.removeItem("is_returning_from_question"):localStorage.removeItem("create_survey_draft")},500);return()=>clearTimeout(E)},[]);const{steps:r,activeStep:l,categories:T,selectedCategory:u,selectedTemplateId:c,templates:y,editingTemplate:x,handleSelectCategory:h,handleSelectTemplate:g,handleCreateBlankSurvey:L,handleEditTemplate:R,handleCloseEditTemplate:A,handleSaveEditTemplate:S,handleGoBackToDashboard:I,handlePreviousStep:N,handleNextStep:f,handleGoToStep:F}=Xe(p),D=C.useMemo(()=>{if(c==="BLANK")return null;if(c){const E=y.find(W=>W.id===c);return E||null}return y.length>0?y[0]:null},[y,c]),{formData:P,questionCategories:G,filteredQuestions:Q,totalQuestionsCount:$,handleTemplateNameChange:Y,handleDescriptionChange:K,handleCategoryFilterChange:_,handleRemoveQuestion:b,resetFormDataWithTemplate:d}=et(c,D,p),{formData:v,handleTitleChange:o,handleDeadlineChange:j}=tt(p),{students:w,allFilteredStudents:z,allStudents:m,totalStudentsCount:k,totalSelectedCount:O,selectedStudentIds:U,filters:V,gradeOptions:re,flagOptions:J,teacherOptions:me,isAllSelected:fe,isIndeterminate:Z,handleSortChange:we,handleSearchChange:Be,handleGradeFilterChange:Fe,handleFlagFilterChange:Ie,handleTeacherFilterChange:Ae,handlePageChange:Le,handleRowsPerPageChange:Re,handleToggleSelectAll:ke,handleToggleStudent:Ee}=nt(p),oe=E=>{const W={activeStep:l,selectedCategory:u,selectedTemplateId:c,step2FormData:P,step3FormData:v,selectedStudentIds:U,editingTemplate:x,...E};localStorage.setItem("create_survey_draft",JSON.stringify(W))},qe=()=>{oe(),i("/admin/create-survey-question?type=0&from=create-survey")},De=E=>{oe(),i(`/admin/survey-question-detail/${E}?type=0&from=create-survey`)},Pe=C.useMemo(()=>(m&&m.length>0?m:z||w).filter(W=>U.includes(W.id)),[m,z,w,U]),ze=async()=>{const E=new Map;(m&&m.length>0?m:z||w||[]).forEach(q=>E.set(q.id,q));const X=[],ee=[],ie=[];U.forEach(q=>{const H=E.get(q);if(H)H.schoolLevel==="ES"&&H.userId?(ee.push(H.userId),ie.push({userId:H.userId,name:H.name,firstName:H.name?.split(" ")?.[0]||"",email:H.email,studentId:H.studentId})):H.studentId!==void 0?X.push(H.studentId):typeof q=="number"?X.push(q):H.userId&&(ee.push(H.userId),ie.push({userId:H.userId,name:H.name,firstName:H.name?.split(" ")?.[0]||"",email:H.email,studentId:H.studentId}));else if(typeof q=="number"||!isNaN(Number(q))&&!String(q).includes("-"))X.push(Number(q));else{const te=String(q);ee.push(te),ie.push({userId:te,name:`Student ${te}`,firstName:"Student",email:""})}});const Qe=[{id:c,name:P.templateName,title:P.templateName,description:P.description,numberQuestion:P.questions.length,orderDefaultSurvey:1,questionTemplates:P.questions.map((q,H)=>({questionId:typeof q.id=="string"&&q.id.startsWith("q-")?0:Number(q.id),questionText:q.questionText,type:q.type||"MultipleChoice",orderDefaultQuestionTemplate:q.orderNumber??H,answers:q.options&&Array.isArray(q.options)?q.options.map((te,Ye)=>({id:0,text:te,order:Ye})):q.answers||[]}))}],Oe=v.deadline?ge(v.deadline,"DD.MM.YYYY hh:mm A").valueOf():null,Ge={title:v.title,deadline:Oe,studentIds:X,esStudentUserIds:ee,studentUserIds:ee,esStudents:ie,additionalQuestions:[],staffIds:[],summarizeQuestions:[],isAdmin:!0,isDraft:!1,role:Array.isArray(n)?n.join(","):n?String(n):"Admin",templateQuestions:Qe};try{a(M.setLoading(!0)),await xe.createSurvey(Ge),a(M.setAlert({type:"success",message:"Publish survey success"})),I()}catch(q){console.error("Error publishing survey:",q),a(M.setAlert({type:"danger",message:q?.response?.data?.title||q?.message||"Failed to publish survey"}))}finally{a(M.setLoading(!1))}};C.useEffect(()=>{window.scrollTo({top:0,behavior:"instant"});const E=document.querySelector("main");E&&E.scrollTo({top:0,behavior:"instant"});const W=document.documentElement||document.body;W&&(W.scrollTop=0)},[l,x]);const He=E=>{oe({editingTemplateFormData:E}),i("/admin/create-survey-question?type=0&from=edit-template")},We=(E,W)=>{oe({editingTemplateFormData:W}),i(`/admin/survey-question-detail/${E}?type=0&from=edit-template`)},Me=async E=>{await S(E),(c===E.id||!c)&&d(E)};return x?e.jsx(t.Box,{className:s.createSurveyPage,children:e.jsx(t.Box,{className:s.contentBody,children:e.jsx(Da,{template:x,initialDraftData:p?.editingTemplateFormData,onSave:Me,onCancel:A,onAddQuestionRedirect:He,onEditQuestionRedirect:We})})}):e.jsxs(t.Box,{className:s.createSurveyPage,children:[e.jsx(t.Box,{className:s.headerTopBar,children:e.jsx(ga,{steps:r,activeStep:l,onBack:I})}),e.jsxs(t.Box,{className:s.contentBody,children:[l===0&&e.jsx(ba,{categories:T,selectedCategory:u,templates:y,selectedTemplateId:c,currentStepNumber:l+1,totalSteps:r.length,onSelectCategory:h,onSelectTemplate:g,onCreateBlank:L,onEditTemplate:R,onPrevious:N,onNext:f}),l===1&&e.jsx(Sa,{formData:P,questionCategories:G,filteredQuestions:Q,totalQuestionsCount:$,currentStepNumber:l+1,totalSteps:r.length,onTemplateNameChange:Y,onDescriptionChange:K,onCategoryFilterChange:_,onEditQuestion:De,onRemoveQuestion:b,onAddQuestion:qe,onPrevious:N,onNext:f}),l===2&&e.jsx(ja,{formData:v,currentStepNumber:l+1,totalSteps:r.length,onTitleChange:o,onDeadlineChange:j,onPrevious:N,onNext:f}),l===3&&e.jsx(Ba,{students:w,totalStudentsCount:k,totalSelectedCount:O,selectedStudentIds:U,filters:V,gradeOptions:re,flagOptions:J,teacherOptions:me,page:V.page,rowsPerPage:V.rowsPerPage,isAllSelected:fe,isIndeterminate:Z,sortBy:V.sortBy,sortOrder:V.sortOrder,onSortChange:we,currentStepNumber:l+1,totalSteps:r.length,onSearchChange:Be,onGradeChange:Fe,onFlagChange:Ie,onTeacherChange:Ae,onPageChange:Le,onRowsPerPageChange:Re,onToggleSelectAll:ke,onToggleStudent:Ee,onPrevious:N,onNext:f}),l===4&&e.jsx(ka,{templateFormData:P,surveyFormData:v,selectedStudents:Pe,currentStepNumber:l+1,totalSteps:r.length,onEditTemplateDetails:()=>F(1),onEditSurveyDetails:()=>F(2),onEditSelectedStudents:()=>F(3),onPrevious:N,onPublish:ze})]})]})};exports.default=Pa;