mario-education 2.0.202-staging → 2.0.204-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"),S=require("react"),t=require("@mui/material"),pe=require("react-redux"),Te=require("react-router-dom"),xe=require("moment"),W=require("mario-core"),fe=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=pe.useDispatch(),c=Te.useNavigate(),h=pe.useSelector(u=>u?.common?.language||"en"),[r,l]=S.useState(a?.activeStep??0),[y,g]=S.useState(a?.selectedCategory??"All"),[d,C]=S.useState(a?.selectedTemplateId??null),[f,m]=S.useState(Ze),[x,A]=S.useState(!1),[q,E]=S.useState(a?.editingTemplate??null),j=S.useCallback(async()=>{try{A(!0),n(W.setLoading(!0));const u=await fe.getTemplateSurvey(h);if(u?.data&&Array.isArray(u.data)&&u.data.length>0){const B=u.data.map(o=>{let N="Well-being";const v=(o.name||"").toLowerCase();v.includes("climate")||v.includes("grow")?N="School Climate":v.includes("health")&&(N="Health & Wellness");const D=new Set;o.questionTemplates&&Array.isArray(o.questionTemplates)&&o.questionTemplates.forEach(L=>{const M=L.category??L.categoryName??L.categoryTitle??L.title??N;M&&typeof M=="string"&&D.add(M.trim())});const p=Array.from(D);return{id:o.id,title:o.name,description:o.description,questionCount:o.numberQuestion??o.questionTemplates?.length??0,category:N,categories:p.length>0?p:[N],rawTemplate:o}});m(B),a?.selectedTemplateId||C(o=>o||(B.length>0?B[0].id:null))}}catch(u){console.error("Error fetching survey templates:",u),n(W.setAlert({type:"danger",message:u?.message||"Failed to fetch survey templates"}))}finally{A(!1),n(W.setLoading(!1))}},[h,n]);S.useEffect(()=>{j()},[j]);const _=S.useMemo(()=>{const u=new Set;return f.forEach(B=>{B.category&&u.add(B.category)}),u.size===0?Je:["All",...Array.from(u)]},[f]),i=S.useMemo(()=>y==="All"?f:f.filter(u=>u.category.toLowerCase()===y.toLowerCase()),[f,y]),I=S.useMemo(()=>f.find(u=>u.id===d)||null,[f,d]),F=u=>{g(u)},Q=u=>{C(u)},H=()=>{C("BLANK"),l(u=>Math.min(u+1,de.length-1))},Y=(u,B)=>{B.stopPropagation(),E(u)},O=()=>{E(null)},$=async u=>{try{n(W.setLoading(!0));const B=u.rawTemplate?.questionTemplates?.map(v=>v.questionId||v.id)?.filter(v=>typeof v=="number"||!String(v).startsWith("q-"))?.map(v=>Number(v))||[],o={id:u.id,name:u.title,description:u.description,isFavorite:u.rawTemplate?.isFavorite??!1,questionIds:B};await $e.updateSurvey(o),m(v=>v.map(D=>D.id===u.id?u:D)),E(null);const N=localStorage.getItem("create_survey_draft");if(N)try{const v=JSON.parse(N);v.editingTemplateFormData&&(delete v.editingTemplateFormData,localStorage.setItem("create_survey_draft",JSON.stringify(v)))}catch{}await j(),n(W.setAlert({type:"success",message:"Update template successfully"}))}catch(B){n(W.setAlert({type:"danger",message:B.response?.data?.title||"Update template failed"}))}finally{n(W.setLoading(!1))}},G=()=>{c("/admin/survey-dashboard/list-survey")};return{steps:de,activeStep:r,categories:_,selectedCategory:y,selectedTemplateId:d,selectedTemplate:I,templates:i,rawTemplates:f,isLoading:x,editingTemplate:q,handleSelectCategory:F,handleSelectTemplate:Q,handleCreateBlankSurvey:H,handleEditTemplate:Y,handleCloseEditTemplate:O,handleSaveEditTemplate:$,handleGoBackToDashboard:G,handlePreviousStep:()=>{r>0?l(u=>u-1):G()},handleNextStep:()=>{r<de.length-1&&l(u=>u+1)},handleGoToStep:u=>{u>=0&&u<de.length&&l(u)},refetchTemplates:j}},ue=(a,n)=>!a||!Array.isArray(a)||a.length===0?[]:a.map((c,h)=>{let r=[];return Array.isArray(c.options)&&c.options.length>0?r=c.options.map(l=>typeof l=="string"?l:l?.text??l?.answerText??l?.name??l?.title??String(l)).filter(l=>!!(l&&l.trim())):Array.isArray(c.answers)&&c.answers.length>0&&(r=c.answers.map(l=>typeof l=="string"?l:l?.text??l?.answerText??l?.name??l?.title??String(l)).filter(l=>!!(l&&l.trim()))),{id:c.questionId??c.id??`q-${h+1}`,orderNumber:c.orderDefaultQuestionTemplate??c.orderNumber??h+1,questionText:c.questionText??c.text??`Question ${h+1}`,type:String(c.type||"Text"),category:c.category??c.categoryName??c.categoryTitle??c.title??n??"General",options:r,numberOfStars:c.numberOfStars??5,fromLabel:c.fromLabel,toLabel:c.toLabel}}),ge=[{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,c)=>{const h=S.useMemo(()=>{const j=n?.rawTemplate?.questionTemplates,_=ue(j,n?.category||"Well-being");return _.length>0?_:ge},[n]),[r,l]=S.useState(()=>c?.step2FormData?c.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:h,selectedCategoryFilter:"All"}),y=S.useRef(c?.selectedTemplateId??(a==="BLANK"?"BLANK":n?n.id:null));S.useEffect(()=>{if(n){if(y.current===n.id)return;y.current=n.id;const j=n.rawTemplate?.questionTemplates,_=ue(j,n.category||"Well-being");l(i=>({...i,templateName:n.title||"",description:n.description||"",questions:_.length>0?_:i.questions.length>0?i.questions:ge,selectedCategoryFilter:"All"}))}else if(a==="BLANK"){if(y.current==="BLANK")return;y.current="BLANK",l(j=>({...j,templateName:"",description:"",questions:[],selectedCategoryFilter:"All"}))}},[n,a]);const g=S.useMemo(()=>{const j=new Set;r.questions.forEach(i=>{const I=i.category?.trim();I&&j.add(I)});const _=Array.from(j);return _.length>0?["All",..._]:["All"]},[r.questions]),d=S.useMemo(()=>r.selectedCategoryFilter==="All"?r.questions:r.questions.filter(j=>j.category===r.selectedCategoryFilter),[r.questions,r.selectedCategoryFilter]),C=j=>{l(_=>({..._,templateName:j}))},f=j=>{l(_=>({..._,description:j}))},m=j=>{l(_=>({..._,selectedCategoryFilter:j}))},x=j=>{console.log("Edit question:",j)},A=j=>{l(_=>({..._,questions:_.questions.filter(i=>i.id!==j).map((i,I)=>({...i,orderNumber:I+1}))}))},q=()=>{const j=`q-${Date.now()}`,_=r.questions.length+1,i={id:j,orderNumber:_,questionText:"New Question",type:"Rating",category:"General"};l(I=>({...I,questions:[...I.questions,i]}))},E=j=>{const _=j.rawTemplate?.questionTemplates,i=ue(_,j.category||"Well-being");l({templateName:j.title||"",description:j.description||"",showLandingPageFlag:!1,questions:i.length>0?i:ge,selectedCategoryFilter:"All"}),y.current=j.id};return{formData:r,questionCategories:g,filteredQuestions:d,totalQuestionsCount:r.questions.length,handleTemplateNameChange:C,handleDescriptionChange:f,handleCategoryFilterChange:m,handleEditQuestion:x,handleRemoveQuestion:A,handleAddQuestion:q,resetFormDataWithTemplate:E}},tt=(a,{initialTitle:n="",initialDeadline:c=xe().add(1,"days").format("DD.MM.YYYY hh:mm A")}={})=>{const[h,r]=S.useState(()=>a?.step3FormData?a.step3FormData:{title:n||"",deadline:c||""});return{formData:h,handleTitleChange:g=>{r(d=>({...d,title:g}))},handleDeadlineChange:g=>{r(d=>({...d,deadline:g}))}}},st=W.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,c]=S.useState([]),[h,r]=S.useState(a?.selectedStudentIds??[]),[l,y]=S.useState([]),[g,d]=S.useState(at),[C,f]=S.useState(["All Teachers"]),[m,x]=S.useState({searchQuery:"",selectedGrade:"All Grades",selectedFlag:"all",selectedTeacher:"All Teachers",page:0,rowsPerPage:10,sortBy:"name",sortOrder:"asc"}),A=S.useCallback(async()=>{try{const T=await fe.searchStudents({roles:["Admin"]});if(T?.data?.items&&Array.isArray(T.data.items)&&T.data.items.length>0){const b=T.data.items.map(p=>{let L="none";if(typeof p.flag=="string"){const Z=p.flag.toLowerCase();Z.includes("red")?L="red":Z.includes("yellow")?L="yellow":Z.includes("green")&&(L="green")}else p.redFlags>0||p.flag===1?L="red":p.yellowFlags>0||p.flag===2?L="yellow":(p.greenFlags>0||p.flag===3)&&(L="green");const M=p.fullName||p.studentName,U=p.gradeLevel,V=p.email,re=p.userId||(typeof p.id=="string"?p.id:""),J=typeof p.studentId=="number"?p.studentId:typeof p.id=="number"?p.id:void 0,he=re||(J!==void 0?String(J):`student-${Math.random()}`),me=(p.schoolLevel||(p.userId&&p.id===void 0?"ES":"MS")).toUpperCase();return{id:he,userId:re,studentId:J,schoolLevel:me,name:M,avatarUrl:p.profileImageFileName?W.getFileUrl(p.profileImageFileName):st,flag:L,flagTooltip:p.flagTooltip||void 0,flagDetail:p.flagDetail,lastSafetyAnswer:p.lastSafetyAnswer,lastStressAnswer:p.lastStressAnswer,flagSessionId:p.flagSessionId,flagSessionResultId:p.flagSessionResultId,grade:U,email:V,listTeachers:p.listTeachers||[]}});c(b);const u=Array.from(new Set(b.map(p=>p.grade))).filter(p=>p&&p!=="N/A"),B=p=>{if(!p||p==="N/A")return-999;const L=p.toString().toUpperCase().replace(/TH|RD|ND|ST/g,"").trim();if(L==="PK")return-2;if(L==="K")return-1;if(L==="G")return 0;const M=L.match(/^(\d+)/);return M?parseInt(M[1],10):999};u.sort((p,L)=>B(p)-B(L)),y(["All Grades",...u]);const o=Array.from(new Set(b.map(p=>p.flag))),N=[{label:"All Flags",value:"all"}];o.includes("red")&&N.push({label:"Red Flag",value:"red"}),o.includes("yellow")&&N.push({label:"Yellow Flag",value:"yellow"}),o.includes("green")&&N.push({label:"Green Flag",value:"green"}),d(N);const v=new Set;b.forEach(p=>{p.listTeachers&&p.listTeachers.length>0&&p.listTeachers.forEach(L=>{L.name&&v.add(L.name.trim())})});const D=Array.from(v).sort((p,L)=>p.localeCompare(L));f(["All Teachers",...D])}}catch(T){console.error("Error fetching students list:",T)}},[]);S.useEffect(()=>{A()},[A]);const q=T=>{x(b=>({...b,searchQuery:T,page:0}))},E=T=>{x(b=>({...b,selectedGrade:T,page:0}))},j=T=>{x(b=>({...b,selectedFlag:T,page:0}))},_=T=>{x(b=>({...b,selectedTeacher:T,page:0}))},i=(T,b)=>{x(u=>({...u,page:b}))},I=T=>{x(b=>({...b,rowsPerPage:parseInt(T.target.value,10),page:0}))},F=S.useMemo(()=>n.filter(T=>{if(m.searchQuery.trim()){const b=N=>(N||"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase(),u=b(m.searchQuery.trim()),B=b(T.name).includes(u),o=b(T.email).includes(u);if(!B&&!o)return!1}return!(m.selectedGrade!=="All Grades"&&(T.grade||"").toLowerCase()!==(m.selectedGrade||"").toLowerCase()||m.selectedFlag!=="all"&&T.flag!==m.selectedFlag||m.selectedTeacher&&m.selectedTeacher!=="All Teachers"&&(!T.listTeachers||T.listTeachers.length===0||!T.listTeachers.some(u=>u.name&&u.name.trim()===m.selectedTeacher)))}),[n,m]),Q=T=>{x(b=>({...b,sortBy:T,sortOrder:b.sortBy===T&&b.sortOrder==="asc"?"desc":"asc"}))},H=S.useMemo(()=>[...F].sort((b,u)=>{let B=b[m.sortBy],o=u[m.sortBy];if(m.sortBy==="flag"){const N={red:3,yellow:2,green:1,none:0};B=N[b.flag]||0,o=N[u.flag]||0}else if(m.sortBy==="grade"){const N=v=>{if(!v||v==="N/A")return-999;const D=v.toString().toUpperCase().replace(/TH|RD|ND|ST/g,"").trim();if(D==="PK")return-2;if(D==="K")return-1;if(D==="G")return 0;const p=D.match(/^(\d+)/);return p?parseInt(p[1],10):999};B=N(b.grade),o=N(u.grade)}else m.sortBy==="teacher"?(B=b.listTeachers&&b.listTeachers.length>0?b.listTeachers.map(N=>N.name).join(", ").toLowerCase():"",o=u.listTeachers&&u.listTeachers.length>0?u.listTeachers.map(N=>N.name).join(", ").toLowerCase():""):typeof B=="string"&&typeof o=="string"&&(B=B.toLowerCase(),o=o.toLowerCase());return B<o?m.sortOrder==="asc"?-1:1:B>o?m.sortOrder==="asc"?1:-1:0}),[F,m.sortBy,m.sortOrder]),Y=S.useMemo(()=>{const T=m.page*m.rowsPerPage;return H.slice(T,T+m.rowsPerPage)},[H,m.page,m.rowsPerPage]),O=S.useMemo(()=>F.length===0?!1:F.every(T=>h.includes(T.id)),[F,h]),$=S.useMemo(()=>{if(F.length===0)return!1;const T=F.filter(b=>h.includes(b.id));return T.length>0&&T.length<F.length},[F,h]),G=()=>{if(O){const T=F.map(b=>b.id);r(b=>b.filter(u=>!T.includes(u)))}else{const T=new Set([...h,...F.map(b=>b.id)]);r(Array.from(T))}},K=T=>{r(b=>b.includes(T)?b.filter(u=>u!==T):[...b,T])};return{students:Y,allFilteredStudents:F,allStudents:n,totalStudentsCount:F.length,totalSelectedCount:h.length,selectedStudentIds:h,filters:m,gradeOptions:l,flagOptions:g,teacherOptions:C,isAllSelected:O,isIndeterminate:$,handleSortChange:Q,handleSearchChange:q,handleGradeFilterChange:E,handleFlagFilterChange:j,handleTeacherFilterChange:_,handlePageChange:i,handleRowsPerPageChange:I,handleToggleSelectAll:G,handleToggleStudent:K}},lt="_createSurveyPage_c6c7p_1",rt="_headerTopBar_c6c7p_16",ot="_contentBody_c6c7p_28",it="_stepperContainer_c6c7p_39",ct="_backButton_c6c7p_44",dt="_stepperProgress_c6c7p_58",ut="_stepColumn_c6c7p_66",pt="_stepColumnLast_c6c7p_72",ht="_stepCircleRow_c6c7p_77",mt="_stepCircle_c6c7p_77",gt="_active_c6c7p_96",xt="_completed_c6c7p_100",ft="_stepConnectorLine_c6c7p_105",yt="_stepLabelStack_c6c7p_115",_t="_stepInnerDot_c6c7p_119",Tt="_stepNumberLabel_c6c7p_133",bt="_stepTextLabel_c6c7p_145",Ct="_chooseTemplateCard_c6c7p_157",St="_headerSection_c6c7p_173",jt="_headerTitle_c6c7p_177",Nt="_headerSubtitle_c6c7p_192",vt="_bannerContainer_c6c7p_199",wt="_bannerIconBox_c6c7p_219",Bt="_bannerTitle_c6c7p_228",Ft="_bannerSubtitle_c6c7p_235",It="_bannerActionBtn_c6c7p_240",At="_sectionTitle_c6c7p_258",Lt="_filterPillsContainer_c6c7p_266",Rt="_filterPill_c6c7p_266",kt="_templateCard_c6c7p_301",Et="_selected_c6c7p_319",qt="_templateCardTitle_c6c7p_324",Dt="_templateEditBtn_c6c7p_332",Pt="_templateDescription_c6c7p_346",Ht="_chipItem_c6c7p_353",zt="_wizardFooter_c6c7p_367",Wt="_previousBtn_c6c7p_387",Mt="_disabled_c6c7p_409",Qt="_stepCounterText_c6c7p_427",Ot="_nextBtn_c6c7p_433",Gt="_editTemplateHeaderSection_c6c7p_453",Yt="_editTemplateCancelBtn_c6c7p_460",$t="_editTemplateSaveBtn_c6c7p_472",Ut="_templateCategorySelect_c6c7p_495",Vt="_formFieldBlock_c6c7p_514",Kt="_formFieldLabel_c6c7p_520",Jt="_requiredAsterisk_c6c7p_528",Zt="_customTextField_c6c7p_532",Xt="_formFieldHelperText_c6c7p_549",es="_questionsHeaderSection_c6c7p_577",ts="_questionsTitle_c6c7p_585",ss="_questionsCountNumber_c6c7p_591",as="_filterByRow_c6c7p_597",ns="_filterByLabel_c6c7p_605",ls="_categoryFilterFormControl_c6c7p_611",rs="_categorySelectInput_c6c7p_615",os="_tableContainerWrapper_c6c7p_633",is="_questionsTable_c6c7p_641",cs="_tableHeaderRow_c6c7p_646",ds="_tableBodyRow_c6c7p_659",us="_thNumber_c6c7p_673",ps="_tdNumber_c6c7p_674",hs="_thQuestion_c6c7p_683",ms="_tdQuestion_c6c7p_684",gs="_questionText_c6c7p_690",xs="_thType_c6c7p_709",fs="_tdType_c6c7p_710",ys="_thCategory_c6c7p_716",_s="_tdCategory_c6c7p_717",Ts="_categoryText_c6c7p_723",bs="_thActions_c6c7p_730",Cs="_tdActions_c6c7p_731",Ss="_questionTypeBadge_c6c7p_737",js="_badgeTextLabel_c6c7p_747",Ns="_badgeRating_c6c7p_753",vs="_badgeYesNo_c6c7p_760",ws="_badgeText_c6c7p_747",Bs="_tableEditBtn_c6c7p_781",Fs="_tableRemoveBtn_c6c7p_796",Is="_addQuestionWrapper_c6c7p_811",As="_addQuestionBtn_c6c7p_819",Ls="_selectedCountSection_c6c7p_838",Rs="_selectedCountText_c6c7p_843",ks="_selectedCountHighlight_c6c7p_849",Es="_studentsToolbar_c6c7p_855",qs="_searchBarContainer_c6c7p_863",Ds="_studentSearchInput_c6c7p_868",Ps="_filterDropdownWrapper_c6c7p_894",Hs="_teacherFilterWrapper_c6c7p_898",zs="_teacherAutocomplete_c6c7p_902",Ws="_teacherAutocompletePaper_c6c7p_959",Ms="_teacherAutocompleteListbox_c6c7p_967",Qs="_teacherOptionItem_c6c7p_984",Os="_filterSelectBox_c6c7p_1028",Gs="_studentsTableContainer_c6c7p_1054",Ys="_studentsTable_c6c7p_1054",$s="_studentsTableHeaderRow_c6c7p_1068",Us="_checkboxHeaderCell_c6c7p_1079",Vs="_tableHeaderCell_c6c7p_1087",Ks="_checkboxBodyCell_c6c7p_1103",Js="_studentTableRow_c6c7p_1111",Zs="_selectedRow_c6c7p_1118",Xs="_studentNameCell_c6c7p_1125",ea="_studentNameText_c6c7p_1130",ta="_flagCell_c6c7p_1136",sa="_gradeCell_c6c7p_1141",aa="_gradeText_c6c7p_1146",na="_emailCell_c6c7p_1151",la="_emailText_c6c7p_1156",ra="_studentsPagination_c6c7p_1161",oa="_reviewSectionBlock_c6c7p_1179",ia="_reviewSectionHeader_c6c7p_1188",ca="_reviewSectionTitle_c6c7p_1195",da="_reviewEditSectionBtn_c6c7p_1201",ua="_reviewFieldGroup_c6c7p_1212",pa="_reviewFieldLabel_c6c7p_1216",ha="_reviewFieldValue_c6c7p_1224",ma="_reviewQuestionsTableContainer_c6c7p_1230",ga="_previewSurveyBtn_c6c7p_1236",xa="_publishBtn_c6c7p_1252",s={createSurveyPage:lt,headerTopBar:rt,contentBody:ot,stepperContainer:it,backButton:ct,stepperProgress:dt,stepColumn:ut,stepColumnLast:pt,stepCircleRow:ht,stepCircle:mt,active:gt,completed:xt,stepConnectorLine:ft,stepLabelStack:yt,stepInnerDot:_t,stepNumberLabel:Tt,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:Ht,wizardFooter:zt,previousBtn:Wt,disabled:Mt,stepCounterText:Qt,nextBtn:Ot,editTemplateHeaderSection:Gt,editTemplateCancelBtn:Yt,editTemplateSaveBtn:$t,templateCategorySelect:Ut,formFieldBlock:Vt,formFieldLabel:Kt,requiredAsterisk:Jt,customTextField:Zt,formFieldHelperText:Xt,questionsHeaderSection:es,questionsTitle:ts,questionsCountNumber:ss,filterByRow:as,filterByLabel:ns,categoryFilterFormControl:ls,categorySelectInput:rs,tableContainerWrapper:os,questionsTable:is,tableHeaderRow:cs,tableBodyRow:ds,thNumber:us,tdNumber:ps,thQuestion:hs,tdQuestion:ms,questionText:gs,thType:xs,tdType:fs,thCategory:ys,tdCategory:_s,categoryText:Ts,thActions:bs,tdActions:Cs,questionTypeBadge:Ss,badgeTextLabel:js,badgeRating:Ns,badgeYesNo:vs,badgeText:ws,tableEditBtn:Bs,tableRemoveBtn:Fs,addQuestionWrapper:Is,addQuestionBtn:As,selectedCountSection:Ls,selectedCountText:Rs,selectedCountHighlight:ks,studentsToolbar:Es,searchBarContainer:qs,studentSearchInput:Ds,filterDropdownWrapper:Ps,teacherFilterWrapper:Hs,teacherAutocomplete:zs,teacherAutocompletePaper:Ws,teacherAutocompleteListbox:Ms,teacherOptionItem:Qs,filterSelectBox:Os,studentsTableContainer:Gs,studentsTable:Ys,studentsTableHeaderRow:$s,checkboxHeaderCell:Us,tableHeaderCell:Vs,checkboxBodyCell:Ks,studentTableRow:Js,selectedRow:Zs,studentNameCell:Xs,studentNameText:ea,flagCell:ta,gradeCell:sa,gradeText:aa,emailCell:na,emailText:la,studentsPagination:ra,reviewSectionBlock:oa,reviewSectionHeader:ia,reviewSectionTitle:ca,reviewEditSectionBtn:da,reviewFieldGroup:ua,reviewFieldLabel:pa,reviewFieldValue:ha,reviewQuestionsTableContainer:ma,previewSurveyBtn:ga,publishBtn:xa},fa=({steps:a,activeStep:n,onBack:c})=>e.jsxs(t.Box,{className:s.stepperContainer,children:[e.jsx(t.Button,{onClick:c,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((h,r)=>{const l=r===n,y=r<n,g=r===a.length-1;return e.jsxs(t.Box,{className:`${s.stepColumn} ${g?s.stepColumnLast:""}`,children:[e.jsxs(t.Box,{className:s.stepCircleRow,children:[e.jsxs(t.Box,{className:`${s.stepCircle} ${l?s.active:y?s.completed:""}`,children:[l&&e.jsx(t.Box,{className:s.stepInnerDot}),y&&e.jsx(Ce.CheckIcon,{sx:{fontSize:16,color:"#ffffff"}})]}),!g&&e.jsx(t.Box,{className:`${s.stepConnectorLine} ${y?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 ",h.stepNumber]}),e.jsx(t.Typography,{variant:"body2",className:`${s.stepTextLabel} ${l?s.active:""}`,children:h.label})]})]},h.stepCode)})})]}),ya=({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"})]}),_a=({categories:a,selectedCategory:n,onSelectCategory:c})=>e.jsx(t.Box,{className:s.filterPillsContainer,children:e.jsx(t.Stack,{direction:"row",spacing:1.5,alignItems:"center",children:a.map(h=>{const r=n.toLowerCase()===h.toLowerCase();return e.jsx(t.Chip,{label:h,onClick:()=>c(h),className:`${s.filterPill} ${r?s.active:""}`},h)})})}),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:c,onEdit:h})=>e.jsxs(t.Box,{onClick:()=>c(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:r=>h(a,r),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.Stack,{direction:"row",spacing:1,alignItems:"center",sx:{gap:.75,flexWrap:"nowrap",overflow:"hidden"},children:[e.jsx(t.Chip,{label:`${a.questionCount} questions`,size:"small",className:s.chipItem,sx:{flexShrink:0}}),(a.categories||[a.category]).slice(0,2).map((r,l)=>e.jsx(t.Chip,{label:r,size:"small",className:s.chipItem,sx:{flexShrink:0,maxWidth:"120px","& .MuiChip-label":{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}}},l)),(a.categories?.length??1)>2&&e.jsx(t.Chip,{label:"...",size:"small",className:s.chipItem,sx:{flexShrink:0}})]})]}),ba=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:c,onNext:h,isNextDisabled:r=!1,isLastStep:l=!1,nextLabel:y="NEXT",onPreview:g})=>e.jsxs(t.Box,{className:s.wizardFooter,children:[e.jsx(t.Button,{variant:"outlined",onClick:c,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:[g&&e.jsx(t.Button,{variant:"outlined",onClick:g,startIcon:e.jsx(ba,{sx:{fontSize:18}}),className:s.previewSurveyBtn,children:"SURVEY PREVIEW"}),e.jsx(t.Button,{variant:"contained",onClick:h,disabled:r,className:s.publishBtn,children:y||"PUBLISH"})]}):e.jsx(t.Button,{variant:"contained",onClick:h,disabled:r,endIcon:e.jsx(Se.ArrowForwardIcon,{sx:{fontSize:16}}),className:s.nextBtn,children:y})]}),Ca=({categories:a,selectedCategory:n,templates:c,selectedTemplateId:h,currentStepNumber:r,totalSteps:l,onSelectCategory:y,onSelectTemplate:g,onCreateBlank:d,onEditTemplate:C,onPrevious:f,onNext:m})=>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(ya,{onCreateBlank:d}),e.jsxs(t.Stack,{spacing:1,children:[e.jsx(t.Typography,{variant:"h6",className:s.sectionTitle,children:"Survey Templates"}),e.jsx(_a,{categories:a,selectedCategory:n,onSelectCategory:y})]}),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(Ta,{template:x,isSelected:h===x.id,onSelect:g,onEdit:C})},x.id))}),e.jsx(le,{currentStep:r,totalSteps:l,onPrevious:f,onNext:m})]}),Sa=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)},c=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}},h=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} ${c(a)}`,children:e.jsx(t.Typography,{variant:"caption",className:s.badgeTextLabel,children:h(a)})})},ve=({questions:a,onEditQuestion:n,onRemoveQuestion:c})=>{const[h,r]=S.useState(null),[l,y]=S.useState(!1),g=f=>{r(f),y(!0)},d=()=>{h!==null&&c(h),y(!1),r(null)},C=()=>{y(!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((f,m)=>e.jsxs(t.TableRow,{className:s.tableBodyRow,children:[e.jsxs(t.TableCell,{className:s.tdNumber,children:[m+1,"."]}),e.jsx(t.TableCell,{className:s.tdQuestion,children:e.jsx(t.Typography,{variant:"body2",className:s.questionText,dangerouslySetInnerHTML:{__html:f.questionText||""}})}),e.jsx(t.TableCell,{className:s.tdType,children:e.jsx(Ne,{type:f.type})}),e.jsx(t.TableCell,{className:s.tdCategory,children:e.jsx(t.Typography,{variant:"body2",className:s.categoryText,children:f.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(f.id),startIcon:e.jsx(se,{fontSize:"small"}),className:s.tableEditBtn,children:"Edit"}),e.jsx(t.Button,{onClick:()=>g(f.id),startIcon:e.jsx(Sa,{fontSize:"small"}),className:s.tableRemoveBtn,children:"Remove"})]})})]},f.id))})]}),e.jsxs(t.Dialog,{open:l,onClose:C,"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:C,color:"inherit",children:"Cancel"}),e.jsx(t.Button,{onClick:d,color:"error",autoFocus:!0,children:"Remove"})]})]})]})},ja=({formData:a,questionCategories:n,filteredQuestions:c,totalQuestionsCount:h,currentStepNumber:r,totalSteps:l,onTemplateNameChange:y,onDescriptionChange:g,onCategoryFilterChange:d,onEditQuestion:C,onRemoveQuestion:f,onAddQuestion:m,onPrevious:x,onNext:A})=>{const q=E=>{d(E.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:E=>y(E.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:E=>g(E.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:h})]}),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:q,className:s.categorySelectInput,children:n.map(E=>e.jsx(t.MenuItem,{value:E,children:E},E))})})]})]}),e.jsx(ve,{questions:c,onEditQuestion:C,onRemoveQuestion:f}),e.jsx(t.Box,{className:s.addQuestionWrapper,children:e.jsx(t.Button,{onClick:m,startIcon:e.jsx(je.AddIcon,{}),className:s.addQuestionBtn,children:"ADD QUESTION"})}),e.jsx(le,{currentStep:r,totalSteps:l,onPrevious:x,onNext:A,isNextDisabled:!a.templateName||a.templateName.trim()===""})]})},Na=({formData:a,currentStepNumber:n,totalSteps:c,onTitleChange:h,onDeadlineChange:r,onPrevious:l,onNext:y})=>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:g=>h(g.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?xe(a.deadline,"DD.MM.YYYY hh:mm A"):null,onChange:g=>{r(g?g.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:c,onPrevious:l,onNext:y,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})}),w={"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"},_e=a=>{switch(a){case"Red Flag":return e.jsxs("div",{className:w["flag-of-session__title-red"],children:[e.jsx(ae,{color:"#C44140",size:32}),e.jsx("span",{className:w["flag-of-session__title-red--text"],children:"Red Flag"})]});case"Yellow Flag":return e.jsxs("div",{className:w["flag-of-session__title-yellow"],children:[e.jsx(ae,{color:"#F5D500",size:32}),e.jsx("span",{className:w["flag-of-session__title-yellow--text"],children:"Yellow Flag"})]});default:return null}},va=({flag:a,flagDetail:n,lastSafetyAnswer:c,lastStressAnswer:h,showResult:r,defaultStress:l,defaultSafety:y,defaultDecrease:g,isDetailView:d,hasReadyToLearn:C,inSession:f})=>r?e.jsxs("div",{className:w["flag-of-session"],style:{gap:"6px"},children:[(a==="Green Flag"||a==="Green")&&e.jsxs("div",{className:w["flag-of-session__content-green"],children:["Everything is ",e.jsx("p",{className:w["flag-of-session__content-green--text"],children:"fine"})]}),d&&a&&_e(a||""),n?.stress&&(d?e.jsxs("div",{className:w["flag-of-session__item"],children:[e.jsx("p",{className:w["flag-of-session__item--title"],children:"Stress score:"}),e.jsxs("p",{className:w["flag-of-session__item--content"],children:[n?.stress?.score,"%"]})]}):e.jsxs("div",{className:w["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 ",h,"%"]})),n?.safety&&(d?e.jsxs("div",{className:w["flag-of-session__item"],children:[e.jsx("p",{className:w["flag-of-session__item--title"],children:"Safety score:"}),e.jsxs("p",{className:w["flag-of-session__item--content"],children:[n?.safety?.score,"%"]})]}):e.jsxs("div",{className:w["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 ",c,"%"]})),n?.decrease&&n?.decrease?.length>0&&(d?e.jsxs("div",{children:[e.jsxs("p",{className:w["flag-of-session__item--content"],children:[e.jsx("span",{className:w["flag-of-session__item--title"],children:"Sudden Drop: "}),e.jsxs("span",{className:w["flag-of-session__item--title"],children:[n.decrease.length," "]}),"core well-being metric shows a decrease of ",g,"% comparing their average of the last four check-ins."]}),e.jsx("ul",{className:w["flag-of-session__item-column--content"],children:n.decrease?.map((m,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:[m.questionText,": ",m.answer,"% ",m.averageOtherRatingsText?"":m.averageOtherRatings!==void 0?`vs avr ${m.averageOtherRatings}%`:"vs previous"]})})},x))})]}):f?e.jsxs("div",{className:w["flag-of-session__item-column"],children:[e.jsxs("p",{className:w["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:w["flag-of-session__item-column--content"],children:n.decrease?.map((m,x)=>{const q=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:[m.questionText,":"]}),e.jsxs("p",{style:{margin:0,color:q,fontSize:"12px"},children:[m.answer,"%"]}),m.averageOtherRatingsText?"":m.averageOtherRatings!==void 0&&e.jsxs("p",{style:{margin:0,fontSize:"12px",marginLeft:"4px"},children:["vs avr ",m.averageOtherRatings,"%"]})]})},x)})})]}):e.jsxs("div",{className:w["flag-of-session__item"],children:["Sudden Drop: Any core well-being metric shows a percentage decrease of ",g||20,"% comparing their average of the last four check-ins."]})),n?.readinessToLearn&&(d?e.jsx("div",{children:e.jsxs("p",{className:w["flag-of-session__item--content"],children:[e.jsx("span",{className:w["flag-of-session__item--title"],children:"Ready to learn: "}),n?.readinessToLearn]})}):e.jsxs("div",{className:w["flag-of-session__item"],children:["Ready to learn: ",n?.readinessToLearn]}))]}):e.jsxs("div",{className:w["flag-of-session"],children:[_e(a||""),y&&e.jsxs("div",{className:w["flag-of-session__item"],children:[e.jsx("p",{className:w["flag-of-session__item--title"],children:"Safety score:"}),e.jsxs("p",{className:w["flag-of-session__item--content"],children:["Under ",y,"%"]})]}),l&&e.jsxs("div",{className:w["flag-of-session__item"],children:[e.jsx("p",{className:w["flag-of-session__item--title"],children:"Stress level:"}),e.jsxs("p",{className:w["flag-of-session__item--content"],children:["Higher than ",l,"%"]})]}),g&&e.jsx("div",{children:e.jsxs("p",{className:w["flag-of-session__item--content"],children:[e.jsx("span",{className:w["flag-of-session__item--title"],children:"Sudden Drop: "}),"Any core well-being metric shows a percentage decrease of ",g,"% comparing their average of the last four check-ins."]})}),C&&e.jsx("div",{children:e.jsxs("p",{className:w["flag-of-session__item--content"],children:[e.jsx("span",{className:w["flag-of-session__item--title"],children:"Ready to learn: "}),"The student reported as not ready to learn in last check-in."]})})]}),wa=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"}})),Ba=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},Fa=({students:a,totalStudentsCount:n,totalSelectedCount:c,selectedStudentIds:h,filters:r,gradeOptions:l,flagOptions:y,teacherOptions:g,page:d,rowsPerPage:C,isAllSelected:f,isIndeterminate:m,sortBy:x,sortOrder:A,onSortChange:q,currentStepNumber:E,totalSteps:j,onSearchChange:_,onGradeChange:i,onFlagChange:I,onTeacherChange:F,onPageChange:Q,onRowsPerPageChange:H,onToggleSelectAll:Y,onToggleStudent:O,onPrevious:$,onNext:G})=>{const K=o=>{i(o.target.value)},T=o=>{I(o.target.value)},b=(o,N)=>{F(N||"All Teachers")},u=S.useMemo(()=>!g||g.length===0?["All Teachers"]:g.includes("All Teachers")?g:["All Teachers",...g],[g]),B=(o,N)=>{const v=(N.inputValue||"").trim().toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"");return v?o.filter(D=>D.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").includes(v)):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: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:o=>_(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:T,displayEmpty:!0,className:s.filterSelectBox,children:y.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:u,value:r.selectedTeacher||"All Teachers",onChange:b,disableClearable:r.selectedTeacher==="All Teachers",clearOnBlur:!0,handleHomeEndKeys:!0,isOptionEqualToValue:(o,N)=>!N||o===N||N==="All Teachers",filterOptions:B,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,N,{selected:v})=>{const{key:D,...p}=o;return e.jsx("li",{...p,className:s.teacherOptionItem,style:{backgroundColor:v?"#f1f5f9":"#ffffff",color:"#000000",fontSize:"14px",fontWeight:v?600:500,padding:"9px 14px",cursor:"pointer"},children:N},D||N)},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:f,indeterminate:m,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"?A:"asc",onClick:()=>q("name"),children:"Student Name"})}),e.jsx(t.TableCell,{className:s.tableHeaderCell,children:e.jsx(t.TableSortLabel,{active:x==="flag",direction:x==="flag"?A:"asc",onClick:()=>q("flag"),children:"Flag"})}),e.jsx(t.TableCell,{className:s.tableHeaderCell,children:e.jsx(t.TableSortLabel,{active:x==="grade",direction:x==="grade"?A:"asc",onClick:()=>q("grade"),children:"Grade"})}),e.jsx(t.TableCell,{className:s.tableHeaderCell,children:e.jsx(t.TableSortLabel,{active:x==="email",direction:x==="email"?A:"asc",onClick:()=>q("email"),children:"Email"})}),e.jsx(t.TableCell,{className:s.tableHeaderCell,children:e.jsx(t.TableSortLabel,{active:x==="teacher",direction:x==="teacher"?A:"asc",onClick:()=>q("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 N=h.includes(o.id);return e.jsxs(t.TableRow,{className:`${s.studentTableRow} ${N?s.selectedRow:""}`,onClick:()=>O(o.id),children:[e.jsx(t.TableCell,{className:s.checkboxBodyCell,onClick:v=>v.stopPropagation(),children:e.jsx(t.Checkbox,{checked:N,onChange:()=>O(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(wa,{arrow:!0,placement:"bottom",title:o?.flag&&o.flag!=="none"?e.jsx(va,{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:Ba(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(v=>v.name).filter(Boolean).join(", "):"-"})})]},o.id)})})]}),n>0&&e.jsx(t.TablePagination,{rowsPerPageOptions:[5,10,25,50],component:"div",count:n,rowsPerPage:C,page:d,onPageChange:Q,onRowsPerPageChange:H,className:s.studentsPagination})]}),e.jsx(le,{currentStep:E,totalSteps:j,onPrevious:$,onNext:G})]})},Ia=({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})}),Aa=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"}}})),La=({flag:a,tooltip:n})=>{if(a==="none")return null;let c="#10B981";a==="red"?c="#D10530":a==="yellow"?c="#F5D500":a==="green"&&(c="#0F9655");const h=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(Aa,{title:h,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(Ia,{color:c,size:28})})})},Ra=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"),ka=({open:a,title:n,description:c,deadline:h,questions:r,onClose:l})=>{const y=d=>{if(typeof d=="number"||!isNaN(Number(d))&&String(d).trim()!==""){const C=Number(d);if(C===0)return"Text";if(C===1)return"MultipleChoice";if(C===2||C===3)return"Slider";if(C===4)return"YesNo";if(C===5)return"SingleChoice";if(C===6)return"Date";if(C===9)return"Summarize";if(C===12)return"DropDown"}return String(d)},g=d=>{try{const C=document.createElement("textarea");return C.innerHTML=d,C.value}catch{return d}};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:c||"General assessment of student wellness and quality of life"}),h&&e.jsxs(t.Stack,{direction:"row",spacing:1,alignItems:"center",sx:{color:"#64748b",mb:3},children:[e.jsx(Ra,{sx:{fontSize:16,color:"#2563eb"}}),e.jsxs(t.Typography,{variant:"caption",sx:{fontWeight:600},children:["Due: ",h]})]}),e.jsx(t.Stack,{spacing:3,children:r.map((d,C)=>{const f=y(d.type),m=d.options&&d.options.length>0?d.options:d.answers&&Array.isArray(d.answers)?d.answers.map(x=>typeof x=="string"?x:x?.text??x?.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:[C+1,"."]}),e.jsx(t.Box,{sx:{"& p":{m:0,display:"inline"},"& span":{display:"inline"}},dangerouslySetInnerHTML:{__html:g(d.questionText||"")}})]}),(f==="Rating"||f==="StarRating"||f==="Slider")&&e.jsx(t.Box,{sx:{px:2,py:1},children:e.jsx(ce.SliderSurveyComponent,{questionId:Number(d.id)||0,valueText:"50",minText:d.fromLabel||"",maxText:d.toLabel||"",isBeforeSession:!1,isPageResult:!0})}),f==="MultipleChoice"&&e.jsx(t.Box,{sx:{px:2},children:e.jsx(ce.MultiChoiceComponent,{questionId:Number(d.id)||0,valueText:"",isUserChangeSession:!0,questionAnswer:m,isPageResult:!0})}),(f==="YesNo"||f==="SingleChoice")&&e.jsx(t.Box,{sx:{px:2},children:e.jsx(ce.SingleChoiceComponent,{questionId:Number(d.id)||0,valueText:"",isUserChangeSession:!0,questionAnswer:m.length>0?m:f==="YesNo"?["Yes","No"]:[]})}),(f==="Text"||f==="TextInput"||f==="OpenField")&&e.jsx(t.TextField,{fullWidth:!0,multiline:!0,rows:2,placeholder:"Your answer...",size:"small",sx:{"& .MuiOutlinedInput-root":{borderRadius:"8px",backgroundColor:"#ffffff"}}}),f==="DropDown"&&e.jsx(t.Box,{sx:{px:2},children:e.jsx(ce.DropDownComponent,{questionItemName:"",questionId:Number(d.id)||0,valueText:"",isUserChangeSession:!0,questionAnswer:m.map((x,A)=>({id:A,text:x}))})}),f==="Summarize"&&e.jsx(t.TextField,{fullWidth:!0,multiline:!0,rows:4,placeholder:"Summarize your thoughts...",size:"small",sx:{"& .MuiOutlinedInput-root":{borderRadius:"8px",backgroundColor:"#ffffff"}}})]},d.id)})})]})]})},Ea=({templateFormData:a,surveyFormData:n,selectedStudents:c,currentStepNumber:h,totalSteps:r,onEditTemplateDetails:l,onEditSurveyDetails:y,onEditSelectedStudents:g,onPrevious:d,onPublish:C})=>{const[f,m]=S.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((x,A)=>e.jsxs(t.TableRow,{className:s.tableBodyRow,children:[e.jsxs(t.TableCell,{className:s.tdNumber,children:[A+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})})]},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:y,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:c.length})]}),e.jsx(t.Button,{variant:"text",onClick:g,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: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(La,{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(le,{currentStep:h,totalSteps:r,isLastStep:!0,nextLabel:"PUBLISH",onPreview:()=>m(!0),onPrevious:d,onNext:C}),e.jsx(ka,{open:f,title:n.title||a.templateName,description:a.description,deadline:n.deadline,questions:a.questions,onClose:()=>m(!1)})]})},qa=[{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"}],Da=({template:a,initialDraftData:n,onSave:c,onCancel:h,onAddQuestionRedirect:r,onEditQuestionRedirect:l})=>{const y=S.useMemo(()=>{const _=a.rawTemplate?.questionTemplates,i=ue(_,a.category||"Well-being");return i.length>0?i:qa},[a]),[g,d]=S.useState(()=>n||{id:a.id,templateName:a.title,description:a.description||"",showLandingPageFlag:!1,category:a.category||"Well-being",questions:y}),C=S.useMemo(()=>{const _=new Set;g.category?.trim()&&_.add(g.category.trim()),g.questions.forEach(I=>{const F=I.category?.trim();F&&_.add(F)});const i=Array.from(_);return i.length>0?i:["General"]},[g.category,g.questions]),f=_=>{d(i=>({...i,templateName:_}))},m=_=>{d(i=>({...i,description:_}))},x=_=>{d(i=>({...i,category:_}))},A=_=>{l&&l(_,g)},q=_=>{d(i=>({...i,questions:i.questions.filter(I=>I.id!==_).map((I,F)=>({...I,orderNumber:F+1}))}))},E=()=>{r&&r(g)},j=()=>{const _={...a,title:g.templateName,description:g.description,category:g.category,questionCount:g.questions.length,rawTemplate:{...a.rawTemplate,questionTemplates:g.questions.map((i,I)=>({...i,questionId:typeof i.id=="number"||String(i.id).startsWith("q-")?i.id:parseInt(String(i.id)),questionText:i.questionText,type:i.type,category:i.category,fromLabel:i.fromLabel,toLabel:i.toLabel,numberOfStars:i.numberOfStars,orderDefaultQuestionTemplate:i.orderNumber??I+1,options:i.options||[],answers:i.options&&Array.isArray(i.options)&&i.options.length>0?i.options.map((F,Q)=>({id:0,text:typeof F=="string"?F:F?.text||"",order:Q})):i.answers||[]}))}};c(_)};return{formData:g,categoryOptions:C,totalQuestionsCount:g.questions.length,handleTemplateNameChange:f,handleDescriptionChange:m,handleCategoryChange:x,handleEditQuestion:A,handleRemoveQuestion:q,handleAddQuestion:E,handleSave:j,handleCancel:h}},Pa=({template:a,initialDraftData:n,onSave:c,onCancel:h,onAddQuestionRedirect:r,onEditQuestionRedirect:l})=>{const{formData:y,categoryOptions:g,totalQuestionsCount:d,handleTemplateNameChange:C,handleDescriptionChange:f,handleCategoryChange:m,handleEditQuestion:x,handleRemoveQuestion:A,handleAddQuestion:q,handleSave:E,handleCancel:j}=Da({template:a,initialDraftData:n,onSave:c,onCancel:h,onAddQuestionRedirect:r,onEditQuestionRedirect:l});S.useEffect(()=>{window.scrollTo({top:0,behavior:"instant"});const i=document.querySelector("main");i&&i.scrollTo({top:0,behavior:"instant"});const I=document.documentElement||document.body;I&&(I.scrollTop=0)},[]);const _=i=>{m(i.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:j,className:s.editTemplateCancelBtn,children:"CANCEL"}),e.jsx(t.Button,{variant:"contained",onClick:E,startIcon:e.jsx(Ce.CheckIcon,{}),className:s.editTemplateSaveBtn,disabled:!y.templateName||y.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:y.templateName,onChange:i=>C(i.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:y.description,onChange:i=>f(i.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:y.category,onChange:_,className:s.templateCategorySelect,children:g.map(i=>e.jsx(t.MenuItem,{value:i,children:i},i))})})]}),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:d})]})}),e.jsx(ve,{questions:y.questions,onEditQuestion:x,onRemoveQuestion:A}),e.jsx(t.Box,{className:s.addQuestionWrapper,children:e.jsx(t.Button,{onClick:q,startIcon:e.jsx(je.AddIcon,{}),className:s.addQuestionBtn,children:"ADD QUESTION"})})]})},Ha=()=>{const a=pe.useDispatch(),n=pe.useSelector(R=>R?.common?.user?.roles),c=Te.useNavigate(),h=S.useMemo(()=>{if(localStorage.getItem("is_returning_from_question")==="true"){const z=localStorage.getItem("create_survey_draft");if(z)try{return JSON.parse(z)}catch{}}return null},[]);S.useEffect(()=>{const R=setTimeout(()=>{localStorage.getItem("is_returning_from_question")==="true"?localStorage.removeItem("is_returning_from_question"):localStorage.removeItem("create_survey_draft")},500);return()=>clearTimeout(R)},[]);const{steps:r,activeStep:l,categories:y,selectedCategory:g,selectedTemplateId:d,templates:C,editingTemplate:f,handleSelectCategory:m,handleSelectTemplate:x,handleCreateBlankSurvey:A,handleEditTemplate:q,handleCloseEditTemplate:E,handleSaveEditTemplate:j,handleGoBackToDashboard:_,handlePreviousStep:i,handleNextStep:I,handleGoToStep:F}=Xe(h),Q=S.useMemo(()=>{if(d==="BLANK")return null;if(d){const R=C.find(z=>z.id===d);return R||null}return C.length>0?C[0]:null},[C,d]),{formData:H,questionCategories:Y,filteredQuestions:O,totalQuestionsCount:$,handleTemplateNameChange:G,handleDescriptionChange:K,handleCategoryFilterChange:T,handleRemoveQuestion:b,resetFormDataWithTemplate:u}=et(d,Q,h),{formData:B,handleTitleChange:o,handleDeadlineChange:N}=tt(h),{students:v,allFilteredStudents:D,allStudents:p,totalStudentsCount:L,totalSelectedCount:M,selectedStudentIds:U,filters:V,gradeOptions:re,flagOptions:J,teacherOptions:he,isAllSelected:me,isIndeterminate:Z,handleSortChange:we,handleSearchChange:Be,handleGradeFilterChange:Fe,handleFlagFilterChange:Ie,handleTeacherFilterChange:Ae,handlePageChange:Le,handleRowsPerPageChange:Re,handleToggleSelectAll:ke,handleToggleStudent:Ee}=nt(h),oe=R=>{const z={activeStep:l,selectedCategory:g,selectedTemplateId:d,step2FormData:H,step3FormData:B,selectedStudentIds:U,editingTemplate:f,...R};localStorage.setItem("create_survey_draft",JSON.stringify(z))},qe=()=>{oe(),c("/admin/create-survey-question?type=0&from=create-survey")},De=R=>{oe(),c(`/admin/survey-question-detail/${R}?type=0&from=create-survey`)},Pe=S.useMemo(()=>(p&&p.length>0?p:D||v).filter(z=>U.includes(z.id)),[p,D,v,U]),He=async()=>{const R=new Map;(p&&p.length>0?p:D||v||[]).forEach(k=>R.set(k.id,k));const X=[],ee=[],ie=[];U.forEach(k=>{const P=R.get(k);if(P)P.schoolLevel==="ES"&&P.userId?(ee.push(P.userId),ie.push({userId:P.userId,name:P.name,firstName:P.name?.split(" ")?.[0]||"",email:P.email,studentId:P.studentId})):P.studentId!==void 0?X.push(P.studentId):typeof k=="number"?X.push(k):P.userId&&(ee.push(P.userId),ie.push({userId:P.userId,name:P.name,firstName:P.name?.split(" ")?.[0]||"",email:P.email,studentId:P.studentId}));else if(typeof k=="number"||!isNaN(Number(k))&&!String(k).includes("-"))X.push(Number(k));else{const te=String(k);ee.push(te),ie.push({userId:te,name:`Student ${te}`,firstName:"Student",email:""})}});const Qe=[{id:d,name:H.templateName,title:H.templateName,description:H.description,numberQuestion:H.questions.length,orderDefaultSurvey:1,questionTemplates:H.questions.map((k,P)=>({questionId:typeof k.id=="string"&&k.id.startsWith("q-")?0:Number(k.id),questionText:k.questionText,type:k.type||"MultipleChoice",orderDefaultQuestionTemplate:k.orderNumber??P,answers:k.options&&Array.isArray(k.options)?k.options.map((te,Ye)=>({id:0,text:te,order:Ye})):k.answers||[]}))}],Oe=B.deadline?xe(B.deadline,"DD.MM.YYYY hh:mm A").valueOf():null,Ge={title:B.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(W.setLoading(!0)),await fe.createSurvey(Ge),a(W.setAlert({type:"success",message:"Publish survey success"})),_()}catch(k){console.error("Error publishing survey:",k),a(W.setAlert({type:"danger",message:k?.response?.data?.title||k?.message||"Failed to publish survey"}))}finally{a(W.setLoading(!1))}};S.useEffect(()=>{window.scrollTo({top:0,behavior:"instant"});const R=document.querySelector("main");R&&R.scrollTo({top:0,behavior:"instant"});const z=document.documentElement||document.body;z&&(z.scrollTop=0)},[l,f]);const ze=R=>{oe({editingTemplateFormData:R}),c("/admin/create-survey-question?type=0&from=edit-template")},We=(R,z)=>{oe({editingTemplateFormData:z}),c(`/admin/survey-question-detail/${R}?type=0&from=edit-template`)},Me=async R=>{await j(R),(d===R.id||!d)&&u(R)};return f?e.jsx(t.Box,{className:s.createSurveyPage,children:e.jsx(t.Box,{className:s.contentBody,children:e.jsx(Pa,{template:f,initialDraftData:h?.editingTemplateFormData,onSave:Me,onCancel:E,onAddQuestionRedirect:ze,onEditQuestionRedirect:We})})}):e.jsxs(t.Box,{className:s.createSurveyPage,children:[e.jsx(t.Box,{className:s.headerTopBar,children:e.jsx(fa,{steps:r,activeStep:l,onBack:_})}),e.jsxs(t.Box,{className:s.contentBody,children:[l===0&&e.jsx(Ca,{categories:y,selectedCategory:g,templates:C,selectedTemplateId:d,currentStepNumber:l+1,totalSteps:r.length,onSelectCategory:m,onSelectTemplate:x,onCreateBlank:A,onEditTemplate:q,onPrevious:i,onNext:I}),l===1&&e.jsx(ja,{formData:H,questionCategories:Y,filteredQuestions:O,totalQuestionsCount:$,currentStepNumber:l+1,totalSteps:r.length,onTemplateNameChange:G,onDescriptionChange:K,onCategoryFilterChange:T,onEditQuestion:De,onRemoveQuestion:b,onAddQuestion:qe,onPrevious:i,onNext:I}),l===2&&e.jsx(Na,{formData:B,currentStepNumber:l+1,totalSteps:r.length,onTitleChange:o,onDeadlineChange:N,onPrevious:i,onNext:I}),l===3&&e.jsx(Fa,{students:v,totalStudentsCount:L,totalSelectedCount:M,selectedStudentIds:U,filters:V,gradeOptions:re,flagOptions:J,teacherOptions:he,page:V.page,rowsPerPage:V.rowsPerPage,isAllSelected:me,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:i,onNext:I}),l===4&&e.jsx(Ea,{templateFormData:H,surveyFormData:B,selectedStudents:Pe,currentStepNumber:l+1,totalSteps:r.length,onEditTemplateDetails:()=>F(1),onEditSurveyDetails:()=>F(2),onEditSelectedStudents:()=>F(3),onPrevious:i,onPublish:He})]})]})};exports.default=Ha;
|