mario-education 2.0.211-staging → 2.0.213-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,2744 @@
1
+ import { jsxs as n, jsx as e, Fragment as Re } from "react/jsx-runtime";
2
+ import { useState as M, useCallback as We, useEffect as se, useMemo as G, useRef as ke } from "react";
3
+ import { Box as i, Button as Y, Stack as $, Typography as b, Chip as ae, Grid as qe, TableContainer as bt, Table as Ne, TableHead as Se, TableRow as j, TableCell as I, TableBody as ve, Dialog as He, DialogTitle as Qe, DialogContent as Oe, DialogContentText as yt, DialogActions as Tt, TextField as J, FormControl as we, Select as xe, MenuItem as Fe, InputAdornment as Nt, Autocomplete as St, Checkbox as De, TableSortLabel as me, TablePagination as vt, Tooltip as Me, tooltipClasses as Ae, styled as wt, IconButton as xt, Avatar as Ft } from "@mui/material";
4
+ import { useDispatch as Ge, useSelector as Ye } from "react-redux";
5
+ import { useNavigate as $e } from "react-router-dom";
6
+ import Pe from "moment";
7
+ import { setLoading as re, setAlert as he, getFileUrl as At, getStaticFileUrl as It } from "mario-core";
8
+ import { q as Bt, s as Lt, r as Rt } from "./surveyService-CaYOE76V.js";
9
+ import { e as Et } from "./questionCategoryService-Cy4o2SXv.js";
10
+ import { A as Ue } from "./ArrowBack-DytrysgX.js";
11
+ import { C as Ve } from "./Check-D8k_l7WO.js";
12
+ import { A as Ke } from "./ArrowForward-DxhjtaZw.js";
13
+ import { d as Ie, b as kt } from "./createSvgIcon-Bge4D-o7.js";
14
+ import { A as je } from "./Add-6ex8DhwL.js";
15
+ import { LocalizationProvider as Pt, DateTimePicker as qt } from "@mui/x-date-pickers";
16
+ import { A as Dt } from "./AdapterMoment-CeMS9jLD.js";
17
+ import { S as zt } from "./Search-srkT1jtT.js";
18
+ import { C as Wt } from "./Close-Z8xNZb_y.js";
19
+ import { a as Ht, M as Qt, S as Ot, D as Mt } from "./DropDownComponent-DL9tCQO-.js";
20
+ const ye = [
21
+ { stepNumber: 1, stepCode: "CHOOSE_TEMPLATE", label: "Choose Template" },
22
+ { stepNumber: 2, stepCode: "CHECK_DETAILS", label: "Check Details" },
23
+ { stepNumber: 3, stepCode: "CREATE_SURVEY", label: "Create Survey" },
24
+ { stepNumber: 4, stepCode: "SELECT_STUDENTS", label: "Select Students" },
25
+ { stepNumber: 5, stepCode: "REVIEW_PUBLISH", label: "Review & Publish" }
26
+ ], Gt = [
27
+ "All",
28
+ "School Climate",
29
+ "Well-being",
30
+ "Health & Wellness"
31
+ ], Yt = [
32
+ {
33
+ id: 1,
34
+ title: "Stress",
35
+ description: "Assess stress levels and identify stressors affecting students",
36
+ questionCount: 13,
37
+ category: "Well-being"
38
+ },
39
+ {
40
+ id: 2,
41
+ title: "Grows",
42
+ description: "Measure student growth mindset and learning attitudes",
43
+ questionCount: 6,
44
+ category: "School Climate"
45
+ },
46
+ {
47
+ id: 3,
48
+ title: "Climate Survey",
49
+ description: "Evaluate overall school climate and student experiences",
50
+ questionCount: 9,
51
+ category: "School Climate"
52
+ },
53
+ {
54
+ id: 4,
55
+ title: "Happiness",
56
+ description: "Track student happiness and emotional well-being",
57
+ questionCount: 8,
58
+ category: "Well-being"
59
+ },
60
+ {
61
+ id: 5,
62
+ title: "Climate Survey: Connections with Adults & Peers",
63
+ description: "Assess the quality of relationships with adults and peers in school",
64
+ questionCount: 14,
65
+ category: "School Climate"
66
+ },
67
+ {
68
+ id: 6,
69
+ title: "Climate Survey: Holistic Learning Experiences",
70
+ description: "Evaluate overall school climate and student experiences",
71
+ questionCount: 18,
72
+ category: "Well-being"
73
+ },
74
+ {
75
+ id: 7,
76
+ title: "Climate Survey: My Health and Well-being",
77
+ description: "Monitor student physical and mental health and wellness",
78
+ questionCount: 21,
79
+ category: "Health & Wellness"
80
+ },
81
+ {
82
+ id: 8,
83
+ title: "Well-being",
84
+ description: "General assessment of student wellness and quality of life",
85
+ questionCount: 10,
86
+ category: "Well-being"
87
+ }
88
+ ], $t = (a) => {
89
+ const s = Ge(), c = $e(), g = Ye((u) => u?.common?.language || "en"), [r, l] = M(a?.activeStep ?? 0), [T, m] = M(a?.selectedCategory ?? "All"), [d, y] = M(a?.selectedTemplateId ?? null), [C, h] = M(Yt), [_, k] = M(!1), [P, E] = M(a?.editingTemplate ?? null), v = We(async () => {
90
+ try {
91
+ k(!0), s(re(!0));
92
+ const u = await Bt(g);
93
+ if (u?.data && Array.isArray(u.data) && u.data.length > 0) {
94
+ const F = u.data.map((o) => {
95
+ let w = "Well-being";
96
+ const A = (o.name || "").toLowerCase();
97
+ A.includes("climate") || A.includes("grow") ? w = "School Climate" : A.includes("health") && (w = "Health & Wellness");
98
+ const Q = /* @__PURE__ */ new Set();
99
+ o.questionTemplates && Array.isArray(o.questionTemplates) && o.questionTemplates.forEach((q) => {
100
+ const K = q.category ?? q.categoryName ?? q.categoryTitle ?? q.title ?? w;
101
+ K && typeof K == "string" && Q.add(K.trim());
102
+ });
103
+ const f = Array.from(Q);
104
+ return {
105
+ id: o.id,
106
+ title: o.name,
107
+ description: o.description,
108
+ questionCount: o.numberQuestion ?? o.questionTemplates?.length ?? 0,
109
+ category: w,
110
+ categories: f.length > 0 ? f : [w],
111
+ rawTemplate: o
112
+ };
113
+ });
114
+ h(F), a?.selectedTemplateId || y((o) => o || (F.length > 0 ? F[0].id : null));
115
+ }
116
+ } catch (u) {
117
+ console.error("Error fetching survey templates:", u), s(
118
+ he({
119
+ type: "danger",
120
+ message: u?.message || "Failed to fetch survey templates"
121
+ })
122
+ );
123
+ } finally {
124
+ k(!1), s(re(!1));
125
+ }
126
+ }, [g, s]);
127
+ se(() => {
128
+ v();
129
+ }, [v]);
130
+ const R = G(() => {
131
+ const u = /* @__PURE__ */ new Set();
132
+ return C.forEach((F) => {
133
+ F.categories && Array.isArray(F.categories) ? F.categories.forEach((o) => u.add(o)) : F.category && u.add(F.category);
134
+ }), u.size === 0 ? Gt : ["All", ...Array.from(u)];
135
+ }, [C]), x = G(() => T === "All" ? C : C.filter((u) => u.categories && Array.isArray(u.categories) ? u.categories.some((F) => F.toLowerCase() === T.toLowerCase()) : u.category?.toLowerCase() === T.toLowerCase()), [C, T]), p = G(() => C.find((u) => u.id === d) || null, [C, d]), L = (u) => {
136
+ m(u);
137
+ }, W = (u) => {
138
+ y(u);
139
+ }, H = () => {
140
+ y("BLANK"), l((u) => Math.min(u + 1, ye.length - 1));
141
+ }, Z = (u, F) => {
142
+ F.stopPropagation(), E(u), y(u.id);
143
+ }, V = () => {
144
+ E(null);
145
+ }, ee = async (u) => {
146
+ try {
147
+ s(re(!0));
148
+ const F = u.rawTemplate?.questionTemplates?.map((A) => A.questionId || A.id)?.filter((A) => typeof A == "number" || !String(A).startsWith("q-"))?.map((A) => Number(A)) || [], o = {
149
+ id: u.id,
150
+ name: u.title,
151
+ description: u.description,
152
+ isFavorite: u.rawTemplate?.isFavorite ?? !1,
153
+ questionIds: F
154
+ };
155
+ await Et(o), h(
156
+ (A) => A.map((Q) => Q.id === u.id ? u : Q)
157
+ ), E(null);
158
+ const w = localStorage.getItem("create_survey_draft");
159
+ if (w)
160
+ try {
161
+ const A = JSON.parse(w);
162
+ A.editingTemplateFormData && (delete A.editingTemplateFormData, localStorage.setItem("create_survey_draft", JSON.stringify(A)));
163
+ } catch {
164
+ }
165
+ await v(), s(he({ type: "success", message: "Update template successfully" }));
166
+ } catch (F) {
167
+ s(he({ type: "danger", message: F.response?.data?.title || "Update template failed" }));
168
+ } finally {
169
+ s(re(!1));
170
+ }
171
+ }, X = () => {
172
+ c("/admin/survey-dashboard/list-survey");
173
+ };
174
+ return {
175
+ steps: ye,
176
+ activeStep: r,
177
+ categories: R,
178
+ selectedCategory: T,
179
+ selectedTemplateId: d,
180
+ selectedTemplate: p,
181
+ templates: x,
182
+ rawTemplates: C,
183
+ isLoading: _,
184
+ editingTemplate: P,
185
+ handleSelectCategory: L,
186
+ handleSelectTemplate: W,
187
+ handleCreateBlankSurvey: H,
188
+ handleEditTemplate: Z,
189
+ handleCloseEditTemplate: V,
190
+ handleSaveEditTemplate: ee,
191
+ handleGoBackToDashboard: X,
192
+ handlePreviousStep: () => {
193
+ r > 0 ? l((u) => u - 1) : X();
194
+ },
195
+ handleNextStep: () => {
196
+ r < ye.length - 1 && l((u) => u + 1);
197
+ },
198
+ handleGoToStep: (u) => {
199
+ u >= 0 && u < ye.length && l(u);
200
+ },
201
+ refetchTemplates: v
202
+ };
203
+ }, Te = (a, s) => !a || !Array.isArray(a) || a.length === 0 ? [] : a.map((c, g) => {
204
+ let r = [];
205
+ 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()))), {
206
+ id: c.questionId ?? c.id ?? `q-${g + 1}`,
207
+ orderNumber: c.orderDefaultQuestionTemplate ?? c.orderNumber ?? g + 1,
208
+ questionText: c.questionText ?? c.text ?? `Question ${g + 1}`,
209
+ type: String(c.type || "Text"),
210
+ category: c.category ?? c.categoryName ?? c.categoryTitle ?? c.title ?? s ?? "General",
211
+ options: r,
212
+ numberOfStars: c.numberOfStars ?? 5,
213
+ fromLabel: c.fromLabel,
214
+ toLabel: c.toLabel
215
+ };
216
+ }), Ee = [
217
+ {
218
+ id: "q-1",
219
+ orderNumber: 1,
220
+ questionText: "How would you rate your overall well-being?",
221
+ type: "Rating",
222
+ category: "Overall Well-being"
223
+ },
224
+ {
225
+ id: "q-2",
226
+ orderNumber: 2,
227
+ questionText: "Do you feel balanced in your daily life?",
228
+ type: "YesNo",
229
+ category: "Life Balance"
230
+ },
231
+ {
232
+ id: "q-3",
233
+ orderNumber: 3,
234
+ questionText: "What contributes most to your well-being?",
235
+ type: "Text",
236
+ category: "Well-being Factors"
237
+ },
238
+ {
239
+ id: "q-4",
240
+ orderNumber: 4,
241
+ questionText: "How satisfied are you with your life?",
242
+ type: "Rating",
243
+ category: "Life Satisfaction"
244
+ },
245
+ {
246
+ id: "q-5",
247
+ orderNumber: 5,
248
+ questionText: "Do you have people who support you?",
249
+ type: "YesNo",
250
+ category: "Social Support"
251
+ }
252
+ ], Ut = (a, s, c) => {
253
+ const g = G(() => s?.rawTemplate ? Te(s.rawTemplate.questionTemplates, s?.category || "Well-being") : Ee, [s]), [r, l] = M(() => c?.step2FormData ? c.step2FormData : a === "BLANK" ? {
254
+ templateName: "",
255
+ description: "",
256
+ showLandingPageFlag: !1,
257
+ questions: [],
258
+ selectedCategoryFilter: "All"
259
+ } : {
260
+ templateName: s?.title || "Well-being",
261
+ description: s?.description || "General assessment of student wellness and quality of life",
262
+ showLandingPageFlag: !1,
263
+ questions: g,
264
+ selectedCategoryFilter: "All"
265
+ }), T = ke(c?.selectedTemplateId ?? (a === "BLANK" ? "BLANK" : s ? s.id : null));
266
+ se(() => {
267
+ if (s) {
268
+ if (T.current === s.id)
269
+ return;
270
+ T.current = s.id;
271
+ const v = s.rawTemplate ? Te(s.rawTemplate.questionTemplates, s.category || "Well-being") : Ee;
272
+ l((R) => ({
273
+ ...R,
274
+ templateName: s.title || "",
275
+ description: s.description || "",
276
+ questions: v,
277
+ selectedCategoryFilter: "All"
278
+ }));
279
+ } else if (a === "BLANK") {
280
+ if (T.current === "BLANK") return;
281
+ T.current = "BLANK", l((v) => ({
282
+ ...v,
283
+ templateName: "",
284
+ description: "",
285
+ questions: [],
286
+ selectedCategoryFilter: "All"
287
+ }));
288
+ }
289
+ }, [s, a]);
290
+ const m = G(() => {
291
+ const v = /* @__PURE__ */ new Set();
292
+ r.questions.forEach((x) => {
293
+ const p = x.category?.trim();
294
+ p && v.add(p);
295
+ });
296
+ const R = Array.from(v);
297
+ return R.length > 0 ? ["All", ...R] : ["All"];
298
+ }, [r.questions]), d = G(() => r.selectedCategoryFilter === "All" ? r.questions : r.questions.filter(
299
+ (v) => v.category === r.selectedCategoryFilter
300
+ ), [r.questions, r.selectedCategoryFilter]), y = (v) => {
301
+ l((R) => ({ ...R, templateName: v }));
302
+ }, C = (v) => {
303
+ l((R) => ({ ...R, description: v }));
304
+ }, h = (v) => {
305
+ l((R) => ({ ...R, selectedCategoryFilter: v }));
306
+ }, _ = (v) => {
307
+ console.log("Edit question:", v);
308
+ }, k = (v) => {
309
+ l((R) => ({
310
+ ...R,
311
+ questions: R.questions.filter((x) => x.id !== v).map((x, p) => ({ ...x, orderNumber: p + 1 }))
312
+ }));
313
+ }, P = () => {
314
+ const v = `q-${Date.now()}`, R = r.questions.length + 1, x = {
315
+ id: v,
316
+ orderNumber: R,
317
+ questionText: "New Question",
318
+ type: "Rating",
319
+ category: "General"
320
+ };
321
+ l((p) => ({
322
+ ...p,
323
+ questions: [...p.questions, x]
324
+ }));
325
+ }, E = (v) => {
326
+ const R = v.rawTemplate ? Te(v.rawTemplate.questionTemplates, v.category || "Well-being") : Ee;
327
+ l({
328
+ templateName: v.title || "",
329
+ description: v.description || "",
330
+ showLandingPageFlag: !1,
331
+ questions: R,
332
+ selectedCategoryFilter: "All"
333
+ }), T.current = v.id;
334
+ };
335
+ return {
336
+ formData: r,
337
+ questionCategories: m,
338
+ filteredQuestions: d,
339
+ totalQuestionsCount: r.questions.length,
340
+ handleTemplateNameChange: y,
341
+ handleDescriptionChange: C,
342
+ handleCategoryFilterChange: h,
343
+ handleEditQuestion: _,
344
+ handleRemoveQuestion: k,
345
+ handleAddQuestion: P,
346
+ resetFormDataWithTemplate: E
347
+ };
348
+ }, Vt = (a, {
349
+ initialTitle: s = "",
350
+ initialDeadline: c = Pe().add(1, "days").format("DD.MM.YYYY hh:mm A")
351
+ } = {}) => {
352
+ const [g, r] = M(() => a?.step3FormData ? a.step3FormData : {
353
+ title: s || "",
354
+ deadline: c || ""
355
+ });
356
+ return {
357
+ formData: g,
358
+ handleTitleChange: (m) => {
359
+ r((d) => ({ ...d, title: m }));
360
+ },
361
+ handleDeadlineChange: (m) => {
362
+ r((d) => ({ ...d, deadline: m }));
363
+ }
364
+ };
365
+ }, Kt = It("/images/image-default.png"), jt = [
366
+ { label: "All Flags", value: "all" },
367
+ { label: "Red Flag", value: "red" },
368
+ { label: "Yellow Flag", value: "yellow" },
369
+ { label: "Green Flag", value: "green" }
370
+ ], Jt = (a) => {
371
+ const [s, c] = M([]), [g, r] = M(a?.selectedStudentIds ?? []), [l, T] = M([]), [m, d] = M(jt), [y, C] = M(["All Teachers"]), [h, _] = M({
372
+ searchQuery: "",
373
+ selectedGrade: "All Grades",
374
+ selectedFlag: "all",
375
+ selectedTeacher: "All Teachers",
376
+ page: 0,
377
+ rowsPerPage: 10,
378
+ sortBy: "name",
379
+ sortOrder: "asc"
380
+ }), k = We(async () => {
381
+ try {
382
+ const N = await Lt({
383
+ roles: ["Admin"]
384
+ });
385
+ if (N?.data?.items && Array.isArray(N.data.items) && N.data.items.length > 0) {
386
+ const S = N.data.items.map((f) => {
387
+ let q = "none";
388
+ if (typeof f.flag == "string") {
389
+ const oe = f.flag.toLowerCase();
390
+ oe.includes("red") ? q = "red" : oe.includes("yellow") ? q = "yellow" : oe.includes("green") && (q = "green");
391
+ } else
392
+ f.redFlags > 0 || f.flag === 1 ? q = "red" : f.yellowFlags > 0 || f.flag === 2 ? q = "yellow" : (f.greenFlags > 0 || f.flag === 3) && (q = "green");
393
+ const K = f.fullName || f.studentName, te = f.gradeLevel, ne = f.email, _e = f.userId || (typeof f.id == "string" ? f.id : ""), ie = typeof f.studentId == "number" ? f.studentId : typeof f.id == "number" ? f.id : void 0, Be = _e || (ie !== void 0 ? String(ie) : `student-${Math.random()}`), Le = (f.schoolLevel || (f.userId && f.id === void 0 ? "ES" : "MS")).toUpperCase();
394
+ return {
395
+ id: Be,
396
+ userId: _e,
397
+ studentId: ie,
398
+ schoolLevel: Le,
399
+ name: K,
400
+ avatarUrl: f.profileImageFileName ? At(f.profileImageFileName) : Kt,
401
+ flag: q,
402
+ flagTooltip: f.flagTooltip || void 0,
403
+ flagDetail: f.flagDetail,
404
+ lastSafetyAnswer: f.lastSafetyAnswer,
405
+ lastStressAnswer: f.lastStressAnswer,
406
+ flagSessionId: f.flagSessionId,
407
+ flagSessionResultId: f.flagSessionResultId,
408
+ grade: te,
409
+ email: ne,
410
+ listTeachers: f.listTeachers || []
411
+ };
412
+ });
413
+ c(S);
414
+ const u = Array.from(new Set(S.map((f) => f.grade))).filter((f) => f && f !== "N/A"), F = (f) => {
415
+ if (!f || f === "N/A") return -999;
416
+ const q = f.toString().toUpperCase().replace(/TH|RD|ND|ST/g, "").trim();
417
+ if (q === "PK") return -2;
418
+ if (q === "K") return -1;
419
+ if (q === "G") return 0;
420
+ const K = q.match(/^(\d+)/);
421
+ return K ? parseInt(K[1], 10) : 999;
422
+ };
423
+ u.sort((f, q) => F(f) - F(q)), T(["All Grades", ...u]);
424
+ const o = Array.from(new Set(S.map((f) => f.flag))), w = [{ label: "All Flags", value: "all" }];
425
+ o.includes("red") && w.push({ label: "Red Flag", value: "red" }), o.includes("yellow") && w.push({ label: "Yellow Flag", value: "yellow" }), o.includes("green") && w.push({ label: "Green Flag", value: "green" }), d(w);
426
+ const A = /* @__PURE__ */ new Set();
427
+ S.forEach((f) => {
428
+ f.listTeachers && f.listTeachers.length > 0 && f.listTeachers.forEach((q) => {
429
+ q.name && A.add(q.name.trim());
430
+ });
431
+ });
432
+ const Q = Array.from(A).sort((f, q) => f.localeCompare(q));
433
+ C(["All Teachers", ...Q]);
434
+ }
435
+ } catch (N) {
436
+ console.error("Error fetching students list:", N);
437
+ }
438
+ }, []);
439
+ se(() => {
440
+ k();
441
+ }, [k]);
442
+ const P = (N) => {
443
+ _((S) => ({ ...S, searchQuery: N, page: 0 }));
444
+ }, E = (N) => {
445
+ _((S) => ({ ...S, selectedGrade: N, page: 0 }));
446
+ }, v = (N) => {
447
+ _((S) => ({ ...S, selectedFlag: N, page: 0 }));
448
+ }, R = (N) => {
449
+ _((S) => ({ ...S, selectedTeacher: N, page: 0 }));
450
+ }, x = (N, S) => {
451
+ _((u) => ({ ...u, page: S }));
452
+ }, p = (N) => {
453
+ _((S) => ({ ...S, rowsPerPage: parseInt(N.target.value, 10), page: 0 }));
454
+ }, L = G(() => s.filter((N) => {
455
+ if (h.searchQuery.trim()) {
456
+ const S = (w) => (w || "").normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase(), u = S(h.searchQuery.trim()), F = S(N.name).includes(u), o = S(N.email).includes(u);
457
+ if (!F && !o) return !1;
458
+ }
459
+ return !(h.selectedGrade !== "All Grades" && (N.grade || "").toLowerCase() !== (h.selectedGrade || "").toLowerCase() || h.selectedFlag !== "all" && N.flag !== h.selectedFlag || h.selectedTeacher && h.selectedTeacher !== "All Teachers" && (!N.listTeachers || N.listTeachers.length === 0 || !N.listTeachers.some((u) => u.name && u.name.trim() === h.selectedTeacher)));
460
+ }), [s, h]), W = (N) => {
461
+ _((S) => ({
462
+ ...S,
463
+ sortBy: N,
464
+ sortOrder: S.sortBy === N && S.sortOrder === "asc" ? "desc" : "asc"
465
+ }));
466
+ }, H = G(() => [...L].sort((S, u) => {
467
+ let F = S[h.sortBy], o = u[h.sortBy];
468
+ if (h.sortBy === "flag") {
469
+ const w = { red: 3, yellow: 2, green: 1, none: 0 };
470
+ F = w[S.flag] || 0, o = w[u.flag] || 0;
471
+ } else if (h.sortBy === "grade") {
472
+ const w = (A) => {
473
+ if (!A || A === "N/A") return -999;
474
+ const Q = A.toString().toUpperCase().replace(/TH|RD|ND|ST/g, "").trim();
475
+ if (Q === "PK") return -2;
476
+ if (Q === "K") return -1;
477
+ if (Q === "G") return 0;
478
+ const f = Q.match(/^(\d+)/);
479
+ return f ? parseInt(f[1], 10) : 999;
480
+ };
481
+ F = w(S.grade), o = w(u.grade);
482
+ } else h.sortBy === "teacher" ? (F = S.listTeachers && S.listTeachers.length > 0 ? S.listTeachers.map((w) => w.name).join(", ").toLowerCase() : "", o = u.listTeachers && u.listTeachers.length > 0 ? u.listTeachers.map((w) => w.name).join(", ").toLowerCase() : "") : typeof F == "string" && typeof o == "string" && (F = F.toLowerCase(), o = o.toLowerCase());
483
+ return F < o ? h.sortOrder === "asc" ? -1 : 1 : F > o ? h.sortOrder === "asc" ? 1 : -1 : 0;
484
+ }), [L, h.sortBy, h.sortOrder]), Z = G(() => {
485
+ const N = h.page * h.rowsPerPage;
486
+ return H.slice(N, N + h.rowsPerPage);
487
+ }, [H, h.page, h.rowsPerPage]), V = G(() => L.length === 0 ? !1 : L.every((N) => g.includes(N.id)), [L, g]), ee = G(() => {
488
+ if (L.length === 0) return !1;
489
+ const N = L.filter((S) => g.includes(S.id));
490
+ return N.length > 0 && N.length < L.length;
491
+ }, [L, g]), X = () => {
492
+ if (V) {
493
+ const N = L.map((S) => S.id);
494
+ r((S) => S.filter((u) => !N.includes(u)));
495
+ } else {
496
+ const N = /* @__PURE__ */ new Set([...g, ...L.map((S) => S.id)]);
497
+ r(Array.from(N));
498
+ }
499
+ }, le = (N) => {
500
+ r((S) => S.includes(N) ? S.filter((u) => u !== N) : [...S, N]);
501
+ };
502
+ return {
503
+ students: Z,
504
+ allFilteredStudents: L,
505
+ allStudents: s,
506
+ totalStudentsCount: L.length,
507
+ totalSelectedCount: g.length,
508
+ selectedStudentIds: g,
509
+ filters: h,
510
+ gradeOptions: l,
511
+ flagOptions: m,
512
+ teacherOptions: y,
513
+ isAllSelected: V,
514
+ isIndeterminate: ee,
515
+ handleSortChange: W,
516
+ handleSearchChange: P,
517
+ handleGradeFilterChange: E,
518
+ handleFlagFilterChange: v,
519
+ handleTeacherFilterChange: R,
520
+ handlePageChange: x,
521
+ handleRowsPerPageChange: p,
522
+ handleToggleSelectAll: X,
523
+ handleToggleStudent: le
524
+ };
525
+ }, Zt = "_createSurveyPage_16fff_1", Xt = "_headerTopBar_16fff_16", en = "_contentBody_16fff_28", tn = "_stepperContainer_16fff_39", nn = "_backButton_16fff_44", an = "_stepperProgress_16fff_58", sn = "_stepColumn_16fff_66", ln = "_stepColumnLast_16fff_72", rn = "_stepCircleRow_16fff_77", on = "_stepCircle_16fff_77", cn = "_active_16fff_96", dn = "_completed_16fff_100", un = "_stepConnectorLine_16fff_105", mn = "_stepLabelStack_16fff_115", hn = "_stepInnerDot_16fff_119", fn = "_stepNumberLabel_16fff_133", pn = "_stepTextLabel_16fff_145", gn = "_chooseTemplateCard_16fff_157", _n = "_headerSection_16fff_173", Cn = "_headerTitle_16fff_177", bn = "_headerSubtitle_16fff_192", yn = "_bannerContainer_16fff_199", Tn = "_bannerIconBox_16fff_219", Nn = "_bannerTitle_16fff_228", Sn = "_bannerSubtitle_16fff_235", vn = "_bannerActionBtn_16fff_240", wn = "_sectionTitle_16fff_258", xn = "_filterPillsContainer_16fff_266", Fn = "_filterPill_16fff_266", An = "_templateCard_16fff_301", In = "_selected_16fff_319", Bn = "_templateCardTitle_16fff_324", Ln = "_templateEditBtn_16fff_332", Rn = "_templateDescription_16fff_346", En = "_chipItem_16fff_353", kn = "_wizardFooter_16fff_367", Pn = "_previousBtn_16fff_387", qn = "_disabled_16fff_409", Dn = "_stepCounterText_16fff_427", zn = "_nextBtn_16fff_433", Wn = "_editTemplateHeaderSection_16fff_453", Hn = "_editTemplateCancelBtn_16fff_460", Qn = "_editTemplateSaveBtn_16fff_472", On = "_formFieldBlock_16fff_514", Mn = "_formFieldLabel_16fff_520", Gn = "_requiredAsterisk_16fff_528", Yn = "_customTextField_16fff_532", $n = "_formFieldHelperText_16fff_549", Un = "_questionsHeaderSection_16fff_577", Vn = "_questionsTitle_16fff_585", Kn = "_questionsCountNumber_16fff_591", jn = "_filterByRow_16fff_597", Jn = "_filterByLabel_16fff_605", Zn = "_categoryFilterFormControl_16fff_611", Xn = "_categorySelectInput_16fff_616", ea = "_tableContainerWrapper_16fff_634", ta = "_questionsTable_16fff_642", na = "_tableHeaderRow_16fff_647", aa = "_tableBodyRow_16fff_660", sa = "_thNumber_16fff_674", la = "_tdNumber_16fff_675", ra = "_thQuestion_16fff_684", ia = "_tdQuestion_16fff_685", oa = "_questionText_16fff_691", ca = "_thType_16fff_710", da = "_tdType_16fff_711", ua = "_thCategory_16fff_717", ma = "_tdCategory_16fff_718", ha = "_categoryText_16fff_724", fa = "_thActions_16fff_731", pa = "_tdActions_16fff_732", ga = "_questionTypeBadge_16fff_738", _a = "_badgeTextLabel_16fff_748", Ca = "_badgeRating_16fff_754", ba = "_badgeYesNo_16fff_761", ya = "_badgeText_16fff_748", Ta = "_tableEditBtn_16fff_782", Na = "_tableRemoveBtn_16fff_797", Sa = "_addQuestionWrapper_16fff_812", va = "_addQuestionBtn_16fff_820", wa = "_selectedCountSection_16fff_839", xa = "_selectedCountText_16fff_844", Fa = "_selectedCountHighlight_16fff_850", Aa = "_studentsToolbar_16fff_856", Ia = "_searchBarContainer_16fff_864", Ba = "_studentSearchInput_16fff_869", La = "_filterDropdownWrapper_16fff_895", Ra = "_teacherFilterWrapper_16fff_899", Ea = "_teacherAutocomplete_16fff_903", ka = "_teacherAutocompletePaper_16fff_960", Pa = "_teacherAutocompleteListbox_16fff_968", qa = "_teacherOptionItem_16fff_985", Da = "_filterSelectBox_16fff_1029", za = "_studentsTableContainer_16fff_1055", Wa = "_studentsTable_16fff_1055", Ha = "_studentsTableHeaderRow_16fff_1069", Qa = "_checkboxHeaderCell_16fff_1080", Oa = "_tableHeaderCell_16fff_1088", Ma = "_checkboxBodyCell_16fff_1104", Ga = "_studentTableRow_16fff_1112", Ya = "_selectedRow_16fff_1119", $a = "_studentNameCell_16fff_1126", Ua = "_studentNameText_16fff_1131", Va = "_flagCell_16fff_1137", Ka = "_gradeCell_16fff_1142", ja = "_gradeText_16fff_1147", Ja = "_emailCell_16fff_1152", Za = "_emailText_16fff_1157", Xa = "_studentsPagination_16fff_1162", es = "_reviewSectionBlock_16fff_1180", ts = "_reviewSectionHeader_16fff_1189", ns = "_reviewSectionTitle_16fff_1196", as = "_reviewEditSectionBtn_16fff_1202", ss = "_reviewFieldGroup_16fff_1213", ls = "_reviewFieldLabel_16fff_1217", rs = "_reviewFieldValue_16fff_1225", is = "_reviewQuestionsTableContainer_16fff_1231", os = "_previewSurveyBtn_16fff_1237", cs = "_publishBtn_16fff_1253", t = {
526
+ createSurveyPage: Zt,
527
+ headerTopBar: Xt,
528
+ contentBody: en,
529
+ stepperContainer: tn,
530
+ backButton: nn,
531
+ stepperProgress: an,
532
+ stepColumn: sn,
533
+ stepColumnLast: ln,
534
+ stepCircleRow: rn,
535
+ stepCircle: on,
536
+ active: cn,
537
+ completed: dn,
538
+ stepConnectorLine: un,
539
+ stepLabelStack: mn,
540
+ stepInnerDot: hn,
541
+ stepNumberLabel: fn,
542
+ stepTextLabel: pn,
543
+ chooseTemplateCard: gn,
544
+ headerSection: _n,
545
+ headerTitle: Cn,
546
+ headerSubtitle: bn,
547
+ bannerContainer: yn,
548
+ bannerIconBox: Tn,
549
+ bannerTitle: Nn,
550
+ bannerSubtitle: Sn,
551
+ bannerActionBtn: vn,
552
+ sectionTitle: wn,
553
+ filterPillsContainer: xn,
554
+ filterPill: Fn,
555
+ templateCard: An,
556
+ selected: In,
557
+ templateCardTitle: Bn,
558
+ templateEditBtn: Ln,
559
+ templateDescription: Rn,
560
+ chipItem: En,
561
+ wizardFooter: kn,
562
+ previousBtn: Pn,
563
+ disabled: qn,
564
+ stepCounterText: Dn,
565
+ nextBtn: zn,
566
+ editTemplateHeaderSection: Wn,
567
+ editTemplateCancelBtn: Hn,
568
+ editTemplateSaveBtn: Qn,
569
+ formFieldBlock: On,
570
+ formFieldLabel: Mn,
571
+ requiredAsterisk: Gn,
572
+ customTextField: Yn,
573
+ formFieldHelperText: $n,
574
+ questionsHeaderSection: Un,
575
+ questionsTitle: Vn,
576
+ questionsCountNumber: Kn,
577
+ filterByRow: jn,
578
+ filterByLabel: Jn,
579
+ categoryFilterFormControl: Zn,
580
+ categorySelectInput: Xn,
581
+ tableContainerWrapper: ea,
582
+ questionsTable: ta,
583
+ tableHeaderRow: na,
584
+ tableBodyRow: aa,
585
+ thNumber: sa,
586
+ tdNumber: la,
587
+ thQuestion: ra,
588
+ tdQuestion: ia,
589
+ questionText: oa,
590
+ thType: ca,
591
+ tdType: da,
592
+ thCategory: ua,
593
+ tdCategory: ma,
594
+ categoryText: ha,
595
+ thActions: fa,
596
+ tdActions: pa,
597
+ questionTypeBadge: ga,
598
+ badgeTextLabel: _a,
599
+ badgeRating: Ca,
600
+ badgeYesNo: ba,
601
+ badgeText: ya,
602
+ tableEditBtn: Ta,
603
+ tableRemoveBtn: Na,
604
+ addQuestionWrapper: Sa,
605
+ addQuestionBtn: va,
606
+ selectedCountSection: wa,
607
+ selectedCountText: xa,
608
+ selectedCountHighlight: Fa,
609
+ studentsToolbar: Aa,
610
+ searchBarContainer: Ia,
611
+ studentSearchInput: Ba,
612
+ filterDropdownWrapper: La,
613
+ teacherFilterWrapper: Ra,
614
+ teacherAutocomplete: Ea,
615
+ teacherAutocompletePaper: ka,
616
+ teacherAutocompleteListbox: Pa,
617
+ teacherOptionItem: qa,
618
+ filterSelectBox: Da,
619
+ studentsTableContainer: za,
620
+ studentsTable: Wa,
621
+ studentsTableHeaderRow: Ha,
622
+ checkboxHeaderCell: Qa,
623
+ tableHeaderCell: Oa,
624
+ checkboxBodyCell: Ma,
625
+ studentTableRow: Ga,
626
+ selectedRow: Ya,
627
+ studentNameCell: $a,
628
+ studentNameText: Ua,
629
+ flagCell: Va,
630
+ gradeCell: Ka,
631
+ gradeText: ja,
632
+ emailCell: Ja,
633
+ emailText: Za,
634
+ studentsPagination: Xa,
635
+ reviewSectionBlock: es,
636
+ reviewSectionHeader: ts,
637
+ reviewSectionTitle: ns,
638
+ reviewEditSectionBtn: as,
639
+ reviewFieldGroup: ss,
640
+ reviewFieldLabel: ls,
641
+ reviewFieldValue: rs,
642
+ reviewQuestionsTableContainer: is,
643
+ previewSurveyBtn: os,
644
+ publishBtn: cs
645
+ }, ds = ({
646
+ steps: a,
647
+ activeStep: s,
648
+ onBack: c
649
+ }) => /* @__PURE__ */ n(i, { className: t.stepperContainer, children: [
650
+ /* @__PURE__ */ e(
651
+ Y,
652
+ {
653
+ onClick: c,
654
+ startIcon: /* @__PURE__ */ e(Ue, { fontSize: "small" }),
655
+ className: t.backButton,
656
+ children: "Back to Surveys Dashboard"
657
+ }
658
+ ),
659
+ /* @__PURE__ */ e(i, { className: t.stepperProgress, children: a.map((g, r) => {
660
+ const l = r === s, T = r < s, m = r === a.length - 1;
661
+ return /* @__PURE__ */ n(
662
+ i,
663
+ {
664
+ className: `${t.stepColumn} ${m ? t.stepColumnLast : ""}`,
665
+ children: [
666
+ /* @__PURE__ */ n(i, { className: t.stepCircleRow, children: [
667
+ /* @__PURE__ */ n(
668
+ i,
669
+ {
670
+ className: `${t.stepCircle} ${l ? t.active : T ? t.completed : ""}`,
671
+ children: [
672
+ l && /* @__PURE__ */ e(i, { className: t.stepInnerDot }),
673
+ T && /* @__PURE__ */ e(Ve, { sx: { fontSize: 16, color: "#ffffff" } })
674
+ ]
675
+ }
676
+ ),
677
+ !m && /* @__PURE__ */ e(
678
+ i,
679
+ {
680
+ className: `${t.stepConnectorLine} ${T ? t.completed : ""}`
681
+ }
682
+ )
683
+ ] }),
684
+ /* @__PURE__ */ n(
685
+ $,
686
+ {
687
+ alignItems: "flex-start",
688
+ spacing: 0.25,
689
+ className: t.stepLabelStack,
690
+ children: [
691
+ /* @__PURE__ */ n(
692
+ b,
693
+ {
694
+ variant: "caption",
695
+ className: `${t.stepNumberLabel} ${l ? t.active : ""}`,
696
+ children: [
697
+ "STEP ",
698
+ g.stepNumber
699
+ ]
700
+ }
701
+ ),
702
+ /* @__PURE__ */ e(
703
+ b,
704
+ {
705
+ variant: "body2",
706
+ className: `${t.stepTextLabel} ${l ? t.active : ""}`,
707
+ children: g.label
708
+ }
709
+ )
710
+ ]
711
+ }
712
+ )
713
+ ]
714
+ },
715
+ g.stepCode
716
+ );
717
+ }) })
718
+ ] }), us = ({
719
+ onCreateBlank: a
720
+ }) => /* @__PURE__ */ n(i, { className: t.bannerContainer, children: [
721
+ /* @__PURE__ */ n($, { direction: "row", spacing: 2, alignItems: "center", children: [
722
+ /* @__PURE__ */ e(i, { className: t.bannerIconBox, children: /* @__PURE__ */ e("img", { src: "/images/scratch-icon.png", alt: "Start from Scratch" }) }),
723
+ /* @__PURE__ */ n(i, { children: [
724
+ /* @__PURE__ */ e(b, { variant: "subtitle1", className: t.bannerTitle, children: "Start from Scratch" }),
725
+ /* @__PURE__ */ e(b, { variant: "body2", className: t.bannerSubtitle, children: "Create a custom survey tailored to your specific needs" })
726
+ ] })
727
+ ] }),
728
+ /* @__PURE__ */ e(
729
+ Y,
730
+ {
731
+ onClick: a,
732
+ endIcon: /* @__PURE__ */ e(Ke, { sx: { fontSize: 16 } }),
733
+ className: t.bannerActionBtn,
734
+ children: "CREATE BLANK SURVEY"
735
+ }
736
+ )
737
+ ] }), ms = ({
738
+ categories: a,
739
+ selectedCategory: s,
740
+ onSelectCategory: c
741
+ }) => /* @__PURE__ */ e(i, { className: t.filterPillsContainer, children: /* @__PURE__ */ e($, { direction: "row", spacing: 1.5, alignItems: "center", children: a.map((g) => {
742
+ const r = s.toLowerCase() === g.toLowerCase();
743
+ return /* @__PURE__ */ e(
744
+ ae,
745
+ {
746
+ label: g,
747
+ onClick: () => c(g),
748
+ className: `${t.filterPill} ${r ? t.active : ""}`
749
+ },
750
+ g
751
+ );
752
+ }) }) }), fe = Ie(/* @__PURE__ */ e("path", {
753
+ 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"
754
+ }), "EditOutlined"), hs = ({
755
+ template: a,
756
+ isSelected: s,
757
+ onSelect: c,
758
+ onEdit: g
759
+ }) => {
760
+ const r = a.categories && a.categories.length > 0 ? a.categories : a.category ? [a.category] : [], l = ke(null), T = ke(null), [m, d] = M(r.length);
761
+ return se(() => {
762
+ const y = l.current, C = T.current;
763
+ if (!y || !C) return;
764
+ const h = () => {
765
+ const k = y.clientWidth, P = Array.from(C.children);
766
+ if (P.length === 0) return;
767
+ const E = 6;
768
+ let v = 0;
769
+ const R = P[0].getBoundingClientRect().width, x = P[P.length - 1].getBoundingClientRect().width;
770
+ v += R;
771
+ let p = 0;
772
+ const L = P.length - 2;
773
+ for (let W = 0; W < L; W++) {
774
+ const H = P[W + 1].getBoundingClientRect().width;
775
+ if ((W === L - 1 ? v + E + H : v + E + H + E + x) <= k)
776
+ v += E + H, p++;
777
+ else
778
+ break;
779
+ }
780
+ d(p);
781
+ }, _ = new ResizeObserver(() => {
782
+ h();
783
+ });
784
+ return _.observe(y), h(), () => _.disconnect();
785
+ }, [r]), /* @__PURE__ */ n(
786
+ i,
787
+ {
788
+ onClick: () => c(a.id),
789
+ className: `${t.templateCard} ${s ? t.selected : ""}`,
790
+ children: [
791
+ /* @__PURE__ */ n(i, { children: [
792
+ /* @__PURE__ */ n(
793
+ $,
794
+ {
795
+ direction: "row",
796
+ alignItems: "flex-start",
797
+ justifyContent: "space-between",
798
+ spacing: 1,
799
+ children: [
800
+ /* @__PURE__ */ e(b, { variant: "h6", className: t.templateCardTitle, children: a.title }),
801
+ /* @__PURE__ */ e(
802
+ Y,
803
+ {
804
+ size: "small",
805
+ onClick: (y) => g(a, y),
806
+ startIcon: /* @__PURE__ */ e(fe, { sx: { fontSize: 14 } }),
807
+ className: t.templateEditBtn,
808
+ children: "EDIT"
809
+ }
810
+ )
811
+ ]
812
+ }
813
+ ),
814
+ /* @__PURE__ */ e(b, { variant: "body2", className: t.templateDescription, children: a.description })
815
+ ] }),
816
+ /* @__PURE__ */ n(i, { ref: l, sx: { position: "relative", width: "100%", height: 24, overflow: "hidden" }, children: [
817
+ /* @__PURE__ */ n($, { direction: "row", spacing: 1, alignItems: "center", sx: { gap: 0.75, flexWrap: "nowrap" }, children: [
818
+ /* @__PURE__ */ e(
819
+ ae,
820
+ {
821
+ label: `${a.questionCount} questions`,
822
+ size: "small",
823
+ className: t.chipItem,
824
+ sx: { flexShrink: 0 }
825
+ }
826
+ ),
827
+ r.slice(0, m).map((y, C) => /* @__PURE__ */ e(
828
+ ae,
829
+ {
830
+ label: y,
831
+ size: "small",
832
+ className: t.chipItem,
833
+ sx: { flexShrink: 0 }
834
+ },
835
+ C
836
+ )),
837
+ m < r.length && /* @__PURE__ */ e(
838
+ ae,
839
+ {
840
+ label: "...",
841
+ size: "small",
842
+ className: t.chipItem,
843
+ sx: { flexShrink: 0 }
844
+ }
845
+ )
846
+ ] }),
847
+ /* @__PURE__ */ n(
848
+ $,
849
+ {
850
+ ref: T,
851
+ direction: "row",
852
+ spacing: 1,
853
+ alignItems: "center",
854
+ sx: {
855
+ gap: 0.75,
856
+ flexWrap: "nowrap",
857
+ position: "absolute",
858
+ top: 0,
859
+ left: 0,
860
+ visibility: "hidden",
861
+ pointerEvents: "none",
862
+ zIndex: -1,
863
+ width: "max-content"
864
+ },
865
+ children: [
866
+ /* @__PURE__ */ e(
867
+ ae,
868
+ {
869
+ label: `${a.questionCount} questions`,
870
+ size: "small",
871
+ className: t.chipItem
872
+ }
873
+ ),
874
+ r.map((y, C) => /* @__PURE__ */ e(
875
+ ae,
876
+ {
877
+ label: y,
878
+ size: "small",
879
+ className: t.chipItem
880
+ },
881
+ C
882
+ )),
883
+ /* @__PURE__ */ e(
884
+ ae,
885
+ {
886
+ label: "...",
887
+ size: "small",
888
+ className: t.chipItem
889
+ }
890
+ )
891
+ ]
892
+ }
893
+ )
894
+ ] })
895
+ ]
896
+ }
897
+ );
898
+ }, fs = Ie(/* @__PURE__ */ e("path", {
899
+ 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"
900
+ }), "RemoveRedEyeOutlined"), ge = ({
901
+ currentStep: a,
902
+ totalSteps: s,
903
+ onPrevious: c,
904
+ onNext: g,
905
+ isNextDisabled: r = !1,
906
+ isLastStep: l = !1,
907
+ nextLabel: T = "NEXT",
908
+ onPreview: m
909
+ }) => /* @__PURE__ */ n(i, { className: t.wizardFooter, children: [
910
+ /* @__PURE__ */ e(
911
+ Y,
912
+ {
913
+ variant: "outlined",
914
+ onClick: c,
915
+ startIcon: /* @__PURE__ */ e(Ue, { sx: { fontSize: 16 } }),
916
+ className: `${t.previousBtn} ${a === 1 ? t.disabled : ""}`,
917
+ children: "PREVIOUS"
918
+ }
919
+ ),
920
+ /* @__PURE__ */ n(b, { variant: "body2", className: t.stepCounterText, children: [
921
+ "Step ",
922
+ a,
923
+ " of ",
924
+ s
925
+ ] }),
926
+ l ? /* @__PURE__ */ n($, { direction: "row", spacing: 1.5, alignItems: "center", children: [
927
+ m && /* @__PURE__ */ e(
928
+ Y,
929
+ {
930
+ variant: "outlined",
931
+ onClick: m,
932
+ startIcon: /* @__PURE__ */ e(fs, { sx: { fontSize: 18 } }),
933
+ className: t.previewSurveyBtn,
934
+ children: "SURVEY PREVIEW"
935
+ }
936
+ ),
937
+ /* @__PURE__ */ e(
938
+ Y,
939
+ {
940
+ variant: "contained",
941
+ onClick: g,
942
+ disabled: r,
943
+ className: t.publishBtn,
944
+ children: T || "PUBLISH"
945
+ }
946
+ )
947
+ ] }) : /* @__PURE__ */ e(
948
+ Y,
949
+ {
950
+ variant: "contained",
951
+ onClick: g,
952
+ disabled: r,
953
+ endIcon: /* @__PURE__ */ e(Ke, { sx: { fontSize: 16 } }),
954
+ className: t.nextBtn,
955
+ children: T
956
+ }
957
+ )
958
+ ] }), ps = ({
959
+ categories: a,
960
+ selectedCategory: s,
961
+ templates: c,
962
+ selectedTemplateId: g,
963
+ currentStepNumber: r,
964
+ totalSteps: l,
965
+ onSelectCategory: T,
966
+ onSelectTemplate: m,
967
+ onCreateBlank: d,
968
+ onEditTemplate: y,
969
+ onPrevious: C,
970
+ onNext: h
971
+ }) => /* @__PURE__ */ n(i, { className: t.chooseTemplateCard, children: [
972
+ /* @__PURE__ */ n(i, { children: [
973
+ /* @__PURE__ */ e(b, { variant: "h4", className: t.headerTitle, children: "Choose a Template" }),
974
+ /* @__PURE__ */ e(b, { variant: "body1", className: t.headerSubtitle, children: "Start with a template or create from scratch" })
975
+ ] }),
976
+ /* @__PURE__ */ e(us, { onCreateBlank: d }),
977
+ /* @__PURE__ */ n($, { spacing: 1, children: [
978
+ /* @__PURE__ */ e(b, { variant: "h6", className: t.sectionTitle, children: "Survey Templates" }),
979
+ /* @__PURE__ */ e(
980
+ ms,
981
+ {
982
+ categories: a,
983
+ selectedCategory: s,
984
+ onSelectCategory: T
985
+ }
986
+ )
987
+ ] }),
988
+ /* @__PURE__ */ e(qe, { container: !0, spacing: 2.5, sx: { mt: 1 }, children: c.map((_) => /* @__PURE__ */ e(qe, { item: !0, xs: 12, sm: 6, md: 4, children: /* @__PURE__ */ e(
989
+ hs,
990
+ {
991
+ template: _,
992
+ isSelected: g === _.id,
993
+ onSelect: m,
994
+ onEdit: y
995
+ }
996
+ ) }, _.id)) }),
997
+ /* @__PURE__ */ e(
998
+ ge,
999
+ {
1000
+ currentStep: r,
1001
+ totalSteps: l,
1002
+ onPrevious: C,
1003
+ onNext: h
1004
+ }
1005
+ )
1006
+ ] }), gs = Ie(/* @__PURE__ */ e("path", {
1007
+ d: "M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6zM8 9h8v10H8zm7.5-5-1-1h-5l-1 1H5v2h14V4z"
1008
+ }), "DeleteOutlineOutlined"), Je = ({ type: a }) => {
1009
+ const s = (r) => {
1010
+ if (typeof r == "number" || !isNaN(Number(r))) {
1011
+ const l = Number(r);
1012
+ if (l === 0) return "Text";
1013
+ if (l === 1) return "MultipleChoice";
1014
+ if (l === 2 || l === 3) return "Slider";
1015
+ if (l === 4) return "YesNo";
1016
+ if (l === 5) return "SingleChoice";
1017
+ if (l === 6) return "Date";
1018
+ }
1019
+ return String(r);
1020
+ }, c = (r) => {
1021
+ switch (s(r)) {
1022
+ case "Rating":
1023
+ case "StarRating":
1024
+ case "Slider":
1025
+ return t.badgeRating;
1026
+ case "YesNo":
1027
+ case "SingleChoice":
1028
+ return t.badgeYesNo;
1029
+ case "Text":
1030
+ case "TextInput":
1031
+ case "OpenField":
1032
+ return t.badgeText;
1033
+ default:
1034
+ return t.badgeText;
1035
+ }
1036
+ }, g = (r) => {
1037
+ const l = s(r);
1038
+ switch (l) {
1039
+ case "YesNo":
1040
+ return "Yes/No";
1041
+ case "SingleChoice":
1042
+ return "Single Choice";
1043
+ case "StarRating":
1044
+ case "Rating":
1045
+ return "Rating";
1046
+ case "TextInput":
1047
+ case "OpenField":
1048
+ case "Text":
1049
+ return "Text";
1050
+ case "MultipleChoice":
1051
+ return "Multiple Choice";
1052
+ default:
1053
+ return l;
1054
+ }
1055
+ };
1056
+ return /* @__PURE__ */ e(i, { className: `${t.questionTypeBadge} ${c(a)}`, children: /* @__PURE__ */ e(b, { variant: "caption", className: t.badgeTextLabel, children: g(a) }) });
1057
+ }, Ze = ({
1058
+ questions: a,
1059
+ onEditQuestion: s,
1060
+ onRemoveQuestion: c
1061
+ }) => {
1062
+ const [g, r] = M(null), [l, T] = M(!1), m = (C) => {
1063
+ r(C), T(!0);
1064
+ }, d = () => {
1065
+ g !== null && c(g), T(!1), r(null);
1066
+ }, y = () => {
1067
+ T(!1), r(null);
1068
+ };
1069
+ return /* @__PURE__ */ n(bt, { className: t.tableContainerWrapper, children: [
1070
+ /* @__PURE__ */ n(Ne, { className: t.questionsTable, children: [
1071
+ /* @__PURE__ */ e(Se, { children: /* @__PURE__ */ n(j, { className: t.tableHeaderRow, children: [
1072
+ /* @__PURE__ */ e(I, { className: t.thNumber, children: "#" }),
1073
+ /* @__PURE__ */ e(I, { className: t.thQuestion, children: "Question" }),
1074
+ /* @__PURE__ */ e(I, { className: t.thType, children: "Type" }),
1075
+ /* @__PURE__ */ e(I, { className: t.thCategory, children: "Category" }),
1076
+ /* @__PURE__ */ e(I, { className: t.thActions, children: "Actions" })
1077
+ ] }) }),
1078
+ /* @__PURE__ */ e(ve, { children: a.map((C, h) => /* @__PURE__ */ n(j, { className: t.tableBodyRow, children: [
1079
+ /* @__PURE__ */ n(I, { className: t.tdNumber, children: [
1080
+ h + 1,
1081
+ "."
1082
+ ] }),
1083
+ /* @__PURE__ */ e(I, { className: t.tdQuestion, children: /* @__PURE__ */ e(
1084
+ b,
1085
+ {
1086
+ variant: "body2",
1087
+ className: t.questionText,
1088
+ dangerouslySetInnerHTML: {
1089
+ __html: C.questionText || ""
1090
+ }
1091
+ }
1092
+ ) }),
1093
+ /* @__PURE__ */ e(I, { className: t.tdType, children: /* @__PURE__ */ e(Je, { type: C.type }) }),
1094
+ /* @__PURE__ */ e(I, { className: t.tdCategory, children: /* @__PURE__ */ e(b, { variant: "body2", className: t.categoryText, children: C.category }) }),
1095
+ /* @__PURE__ */ e(I, { className: t.tdActions, children: /* @__PURE__ */ n($, { direction: "row", spacing: 1.5, alignItems: "center", children: [
1096
+ /* @__PURE__ */ e(
1097
+ Y,
1098
+ {
1099
+ onClick: () => s(C.id),
1100
+ startIcon: /* @__PURE__ */ e(fe, { fontSize: "small" }),
1101
+ className: t.tableEditBtn,
1102
+ children: "Edit"
1103
+ }
1104
+ ),
1105
+ /* @__PURE__ */ e(
1106
+ Y,
1107
+ {
1108
+ onClick: () => m(C.id),
1109
+ startIcon: /* @__PURE__ */ e(gs, { fontSize: "small" }),
1110
+ className: t.tableRemoveBtn,
1111
+ children: "Remove"
1112
+ }
1113
+ )
1114
+ ] }) })
1115
+ ] }, C.id)) })
1116
+ ] }),
1117
+ /* @__PURE__ */ n(
1118
+ He,
1119
+ {
1120
+ open: l,
1121
+ onClose: y,
1122
+ "aria-labelledby": "confirm-delete-dialog-title",
1123
+ "aria-describedby": "confirm-delete-dialog-description",
1124
+ children: [
1125
+ /* @__PURE__ */ e(Qe, { id: "confirm-delete-dialog-title", sx: { fontWeight: "bold" }, children: "Confirm Remove" }),
1126
+ /* @__PURE__ */ e(Oe, { children: /* @__PURE__ */ e(yt, { id: "confirm-delete-dialog-description", children: "Are you sure you want to remove this question?" }) }),
1127
+ /* @__PURE__ */ n(Tt, { children: [
1128
+ /* @__PURE__ */ e(Y, { onClick: y, color: "inherit", children: "Cancel" }),
1129
+ /* @__PURE__ */ e(Y, { onClick: d, color: "error", autoFocus: !0, children: "Remove" })
1130
+ ] })
1131
+ ]
1132
+ }
1133
+ )
1134
+ ] });
1135
+ }, _s = ({
1136
+ formData: a,
1137
+ questionCategories: s,
1138
+ filteredQuestions: c,
1139
+ totalQuestionsCount: g,
1140
+ currentStepNumber: r,
1141
+ totalSteps: l,
1142
+ onTemplateNameChange: T,
1143
+ onDescriptionChange: m,
1144
+ onCategoryFilterChange: d,
1145
+ onEditQuestion: y,
1146
+ onRemoveQuestion: C,
1147
+ onAddQuestion: h,
1148
+ onPrevious: _,
1149
+ onNext: k
1150
+ }) => {
1151
+ const P = (E) => {
1152
+ d(E.target.value);
1153
+ };
1154
+ return /* @__PURE__ */ n(i, { className: t.chooseTemplateCard, children: [
1155
+ /* @__PURE__ */ n(i, { className: t.headerSection, children: [
1156
+ /* @__PURE__ */ e(b, { variant: "h5", className: t.headerTitle, children: "Check Details" }),
1157
+ /* @__PURE__ */ e(b, { variant: "body2", className: t.headerSubtitle, children: "Review and edit the details below." })
1158
+ ] }),
1159
+ /* @__PURE__ */ n(i, { className: t.formFieldBlock, children: [
1160
+ /* @__PURE__ */ n(b, { variant: "subtitle2", className: t.formFieldLabel, children: [
1161
+ "Template Name ",
1162
+ /* @__PURE__ */ e("span", { className: t.requiredAsterisk, children: "*" })
1163
+ ] }),
1164
+ /* @__PURE__ */ e(
1165
+ J,
1166
+ {
1167
+ fullWidth: !0,
1168
+ variant: "outlined",
1169
+ value: a.templateName,
1170
+ onChange: (E) => T(E.target.value),
1171
+ placeholder: "Enter template name",
1172
+ className: t.customTextField
1173
+ }
1174
+ )
1175
+ ] }),
1176
+ /* @__PURE__ */ n(i, { className: t.formFieldBlock, children: [
1177
+ /* @__PURE__ */ e(b, { variant: "subtitle2", className: t.formFieldLabel, children: "Description and instructions of when to use" }),
1178
+ /* @__PURE__ */ e(
1179
+ J,
1180
+ {
1181
+ fullWidth: !0,
1182
+ multiline: !0,
1183
+ rows: 3,
1184
+ variant: "outlined",
1185
+ value: a.description,
1186
+ onChange: (E) => m(E.target.value),
1187
+ placeholder: "Enter description and instructions",
1188
+ className: t.customTextField
1189
+ }
1190
+ )
1191
+ ] }),
1192
+ /* @__PURE__ */ n(i, { className: t.questionsHeaderSection, children: [
1193
+ /* @__PURE__ */ n($, { direction: "row", alignItems: "center", spacing: 0.75, sx: { mb: 1.5 }, children: [
1194
+ /* @__PURE__ */ e(b, { variant: "subtitle1", className: t.questionsTitle, children: "Questions" }),
1195
+ /* @__PURE__ */ e(b, { variant: "subtitle1", className: t.questionsCountNumber, children: g })
1196
+ ] }),
1197
+ /* @__PURE__ */ n($, { direction: "row", alignItems: "center", spacing: 1.5, className: t.filterByRow, children: [
1198
+ /* @__PURE__ */ e(b, { variant: "body2", className: t.filterByLabel, children: "Filter by category" }),
1199
+ /* @__PURE__ */ e(we, { size: "small", className: t.categoryFilterFormControl, children: /* @__PURE__ */ e(
1200
+ xe,
1201
+ {
1202
+ value: a.selectedCategoryFilter,
1203
+ onChange: P,
1204
+ className: t.categorySelectInput,
1205
+ children: s.map((E) => /* @__PURE__ */ e(Fe, { value: E, children: E }, E))
1206
+ }
1207
+ ) })
1208
+ ] })
1209
+ ] }),
1210
+ /* @__PURE__ */ e(
1211
+ Ze,
1212
+ {
1213
+ questions: c,
1214
+ onEditQuestion: y,
1215
+ onRemoveQuestion: C
1216
+ }
1217
+ ),
1218
+ /* @__PURE__ */ e(i, { className: t.addQuestionWrapper, children: /* @__PURE__ */ e(
1219
+ Y,
1220
+ {
1221
+ onClick: h,
1222
+ startIcon: /* @__PURE__ */ e(je, {}),
1223
+ className: t.addQuestionBtn,
1224
+ children: "ADD QUESTION"
1225
+ }
1226
+ ) }),
1227
+ /* @__PURE__ */ e(
1228
+ ge,
1229
+ {
1230
+ currentStep: r,
1231
+ totalSteps: l,
1232
+ onPrevious: _,
1233
+ onNext: k,
1234
+ isNextDisabled: !a.templateName || a.templateName.trim() === ""
1235
+ }
1236
+ )
1237
+ ] });
1238
+ }, Cs = ({
1239
+ formData: a,
1240
+ currentStepNumber: s,
1241
+ totalSteps: c,
1242
+ onTitleChange: g,
1243
+ onDeadlineChange: r,
1244
+ onPrevious: l,
1245
+ onNext: T
1246
+ }) => /* @__PURE__ */ n(i, { className: t.chooseTemplateCard, children: [
1247
+ /* @__PURE__ */ n(i, { className: t.headerSection, children: [
1248
+ /* @__PURE__ */ e(b, { variant: "h5", className: t.headerTitle, children: "Create Survey" }),
1249
+ /* @__PURE__ */ e(b, { variant: "body2", className: t.headerSubtitle, children: "Set the title and deadline for your survey" })
1250
+ ] }),
1251
+ /* @__PURE__ */ n(i, { className: t.formFieldBlock, children: [
1252
+ /* @__PURE__ */ n(b, { variant: "subtitle2", className: t.formFieldLabel, children: [
1253
+ "Title ",
1254
+ /* @__PURE__ */ e("span", { className: t.requiredAsterisk, children: "*" })
1255
+ ] }),
1256
+ /* @__PURE__ */ e(
1257
+ J,
1258
+ {
1259
+ fullWidth: !0,
1260
+ variant: "outlined",
1261
+ value: a.title,
1262
+ onChange: (m) => g(m.target.value),
1263
+ placeholder: "Enter survey title",
1264
+ className: t.customTextField
1265
+ }
1266
+ )
1267
+ ] }),
1268
+ /* @__PURE__ */ n(i, { className: t.formFieldBlock, children: [
1269
+ /* @__PURE__ */ n(b, { variant: "subtitle2", className: t.formFieldLabel, children: [
1270
+ "Deadline ",
1271
+ /* @__PURE__ */ e("span", { className: t.requiredAsterisk, children: "*" })
1272
+ ] }),
1273
+ /* @__PURE__ */ e(Pt, { dateAdapter: Dt, children: /* @__PURE__ */ e(
1274
+ qt,
1275
+ {
1276
+ value: a.deadline ? Pe(a.deadline, "DD.MM.YYYY hh:mm A") : null,
1277
+ onChange: (m) => {
1278
+ r(m ? m.format("DD.MM.YYYY hh:mm A") : "");
1279
+ },
1280
+ format: "DD.MM.YYYY hh:mm A",
1281
+ slotProps: {
1282
+ textField: {
1283
+ fullWidth: !0,
1284
+ variant: "outlined",
1285
+ placeholder: "DD.MM.YYYY hh:mm A",
1286
+ className: t.customTextField
1287
+ }
1288
+ }
1289
+ }
1290
+ ) }),
1291
+ /* @__PURE__ */ e(b, { variant: "caption", className: t.formFieldHelperText, children: "Select the date and time when the survey will close" })
1292
+ ] }),
1293
+ /* @__PURE__ */ e(
1294
+ ge,
1295
+ {
1296
+ currentStep: s,
1297
+ totalSteps: c,
1298
+ onPrevious: l,
1299
+ onNext: T,
1300
+ isNextDisabled: !a.title || a.title.trim() === "" || !a.deadline
1301
+ }
1302
+ )
1303
+ ] }), pe = ({ size: a = 32, color: s = "#C44140" }) => /* @__PURE__ */ e("svg", { width: a, height: a, viewBox: "0 0 32 32", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ e("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: s }) }), B = {
1304
+ "flag-of-session": "_flag-of-session_izm26_530",
1305
+ "flag-of-session__title-red": "_flag-of-session__title-red_izm26_539",
1306
+ "flag-of-session__title-red--text": "_flag-of-session__title-red--text_izm26_544",
1307
+ "flag-of-session__title-yellow": "_flag-of-session__title-yellow_izm26_561",
1308
+ "flag-of-session__title-yellow--text": "_flag-of-session__title-yellow--text_izm26_566",
1309
+ "flag-of-session__content-green": "_flag-of-session__content-green_izm26_572",
1310
+ "flag-of-session__content-green--text": "_flag-of-session__content-green--text_izm26_579",
1311
+ "flag-of-session__item": "_flag-of-session__item_izm26_586",
1312
+ "flag-of-session__item--title": "_flag-of-session__item--title_izm26_594",
1313
+ "flag-of-session__item--content": "_flag-of-session__item--content_izm26_601",
1314
+ "flag-of-session__item-column": "_flag-of-session__item-column_izm26_608",
1315
+ "flag-of-session__item-column--no-bold": "_flag-of-session__item-column--no-bold_izm26_620",
1316
+ "flag-of-session__item-column--content": "_flag-of-session__item-column--content_izm26_627"
1317
+ }, ze = (a) => {
1318
+ switch (a) {
1319
+ case "Red Flag":
1320
+ return /* @__PURE__ */ n("div", { className: B["flag-of-session__title-red"], children: [
1321
+ /* @__PURE__ */ e(pe, { color: "#C44140", size: 32 }),
1322
+ /* @__PURE__ */ e("span", { className: B["flag-of-session__title-red--text"], children: "Red Flag" })
1323
+ ] });
1324
+ case "Yellow Flag":
1325
+ return /* @__PURE__ */ n("div", { className: B["flag-of-session__title-yellow"], children: [
1326
+ /* @__PURE__ */ e(pe, { color: "#F5D500", size: 32 }),
1327
+ /* @__PURE__ */ e("span", { className: B["flag-of-session__title-yellow--text"], children: "Yellow Flag" })
1328
+ ] });
1329
+ default:
1330
+ return null;
1331
+ }
1332
+ }, bs = ({
1333
+ flag: a,
1334
+ flagDetail: s,
1335
+ lastSafetyAnswer: c,
1336
+ lastStressAnswer: g,
1337
+ showResult: r,
1338
+ defaultStress: l,
1339
+ defaultSafety: T,
1340
+ defaultDecrease: m,
1341
+ isDetailView: d,
1342
+ hasReadyToLearn: y,
1343
+ inSession: C
1344
+ }) => r ? /* @__PURE__ */ n("div", { className: B["flag-of-session"], style: { gap: "6px" }, children: [
1345
+ (a === "Green Flag" || a === "Green") && /* @__PURE__ */ n("div", { className: B["flag-of-session__content-green"], children: [
1346
+ "Everything is ",
1347
+ /* @__PURE__ */ e("p", { className: B["flag-of-session__content-green--text"], children: "fine" })
1348
+ ] }),
1349
+ d && a && ze(a || ""),
1350
+ s?.stress && (d ? /* @__PURE__ */ n("div", { className: B["flag-of-session__item"], children: [
1351
+ /* @__PURE__ */ e("p", { className: B["flag-of-session__item--title"], children: "Stress score:" }),
1352
+ /* @__PURE__ */ n("p", { className: B["flag-of-session__item--content"], children: [
1353
+ s?.stress?.score,
1354
+ "%"
1355
+ ] })
1356
+ ] }) : /* @__PURE__ */ n("div", { className: B["flag-of-session__item"], children: [
1357
+ /* @__PURE__ */ n(
1358
+ "span",
1359
+ {
1360
+ style: {
1361
+ fontWeight: 600,
1362
+ color: s?.stress?.flag === "Red Flag" ? "#C44140" : "#F5D500",
1363
+ fontSize: "12px"
1364
+ },
1365
+ children: [
1366
+ s?.stress?.score,
1367
+ "%"
1368
+ ]
1369
+ }
1370
+ ),
1371
+ "Stress vs Last check-in ",
1372
+ g,
1373
+ "%"
1374
+ ] })),
1375
+ s?.safety && (d ? /* @__PURE__ */ n("div", { className: B["flag-of-session__item"], children: [
1376
+ /* @__PURE__ */ e("p", { className: B["flag-of-session__item--title"], children: "Safety score:" }),
1377
+ /* @__PURE__ */ n("p", { className: B["flag-of-session__item--content"], children: [
1378
+ s?.safety?.score,
1379
+ "%"
1380
+ ] })
1381
+ ] }) : /* @__PURE__ */ n("div", { className: B["flag-of-session__item"], children: [
1382
+ /* @__PURE__ */ n("span", { style: { fontWeight: 600, color: s?.safety?.flag === "Red Flag" ? "#C44140" : "#F5D500" }, children: [
1383
+ s?.safety?.score,
1384
+ "%"
1385
+ ] }),
1386
+ " Safety vs Last check-in ",
1387
+ c,
1388
+ "%"
1389
+ ] })),
1390
+ s?.decrease && s?.decrease?.length > 0 && (d ? /* @__PURE__ */ n("div", { children: [
1391
+ /* @__PURE__ */ n("p", { className: B["flag-of-session__item--content"], children: [
1392
+ /* @__PURE__ */ e("span", { className: B["flag-of-session__item--title"], children: "Sudden Drop: " }),
1393
+ /* @__PURE__ */ n("span", { className: B["flag-of-session__item--title"], children: [
1394
+ s.decrease.length,
1395
+ " "
1396
+ ] }),
1397
+ "core well-being metric shows a decrease of ",
1398
+ m,
1399
+ "% comparing their average of the last four check-ins."
1400
+ ] }),
1401
+ /* @__PURE__ */ e("ul", { className: B["flag-of-session__item-column--content"], children: s.decrease?.map((h, _) => /* @__PURE__ */ e("li", { style: { color: "#242424", marginLeft: "16px" }, children: /* @__PURE__ */ e("div", { style: { display: "flex", alignItems: "center", gap: "4px" }, children: /* @__PURE__ */ n("p", { style: { margin: 0 }, children: [
1402
+ h.questionText,
1403
+ ": ",
1404
+ h.answer,
1405
+ "% ",
1406
+ h.averageOtherRatingsText ? "" : h.averageOtherRatings !== void 0 ? `vs avr ${h.averageOtherRatings}%` : "vs previous"
1407
+ ] }) }) }, _)) })
1408
+ ] }) : C ? /* @__PURE__ */ n("div", { className: B["flag-of-session__item-column"], children: [
1409
+ /* @__PURE__ */ n("p", { className: B["flag-of-session__item-column--no-bold"], children: [
1410
+ "Sudden Drop: ",
1411
+ s.decrease.length || 0,
1412
+ " core well-being metric shows a decrease compared to the average of the last four check-ins."
1413
+ ] }),
1414
+ /* @__PURE__ */ e("ul", { className: B["flag-of-session__item-column--content"], children: s.decrease?.map((h, _) => {
1415
+ const P = a?.includes("Red") ? "#C44140" : "#F5D500";
1416
+ return /* @__PURE__ */ e("li", { style: { color: "#242424", marginLeft: "16px" }, children: /* @__PURE__ */ n("div", { style: { display: "flex", alignItems: "center", gap: "4px" }, children: [
1417
+ /* @__PURE__ */ n("p", { style: { margin: 0, fontSize: "12px" }, children: [
1418
+ h.questionText,
1419
+ ":"
1420
+ ] }),
1421
+ /* @__PURE__ */ n("p", { style: { margin: 0, color: P, fontSize: "12px" }, children: [
1422
+ h.answer,
1423
+ "%"
1424
+ ] }),
1425
+ h.averageOtherRatingsText ? "" : h.averageOtherRatings !== void 0 && /* @__PURE__ */ n("p", { style: { margin: 0, fontSize: "12px", marginLeft: "4px" }, children: [
1426
+ "vs avr ",
1427
+ h.averageOtherRatings,
1428
+ "%"
1429
+ ] })
1430
+ ] }) }, _);
1431
+ }) })
1432
+ ] }) : /* @__PURE__ */ n("div", { className: B["flag-of-session__item"], children: [
1433
+ "Sudden Drop: Any core well-being metric shows a percentage decrease of ",
1434
+ m || 20,
1435
+ "% comparing their average of the last four check-ins."
1436
+ ] })),
1437
+ s?.readinessToLearn && (d ? /* @__PURE__ */ e("div", { children: /* @__PURE__ */ n("p", { className: B["flag-of-session__item--content"], children: [
1438
+ /* @__PURE__ */ e("span", { className: B["flag-of-session__item--title"], children: "Ready to learn: " }),
1439
+ s?.readinessToLearn
1440
+ ] }) }) : /* @__PURE__ */ n("div", { className: B["flag-of-session__item"], children: [
1441
+ "Ready to learn: ",
1442
+ s?.readinessToLearn
1443
+ ] }))
1444
+ ] }) : /* @__PURE__ */ n("div", { className: B["flag-of-session"], children: [
1445
+ ze(a || ""),
1446
+ T && /* @__PURE__ */ n("div", { className: B["flag-of-session__item"], children: [
1447
+ /* @__PURE__ */ e("p", { className: B["flag-of-session__item--title"], children: "Safety score:" }),
1448
+ /* @__PURE__ */ n("p", { className: B["flag-of-session__item--content"], children: [
1449
+ "Under ",
1450
+ T,
1451
+ "%"
1452
+ ] })
1453
+ ] }),
1454
+ l && /* @__PURE__ */ n("div", { className: B["flag-of-session__item"], children: [
1455
+ /* @__PURE__ */ e("p", { className: B["flag-of-session__item--title"], children: "Stress level:" }),
1456
+ /* @__PURE__ */ n("p", { className: B["flag-of-session__item--content"], children: [
1457
+ "Higher than ",
1458
+ l,
1459
+ "%"
1460
+ ] })
1461
+ ] }),
1462
+ m && /* @__PURE__ */ e("div", { children: /* @__PURE__ */ n("p", { className: B["flag-of-session__item--content"], children: [
1463
+ /* @__PURE__ */ e("span", { className: B["flag-of-session__item--title"], children: "Sudden Drop: " }),
1464
+ "Any core well-being metric shows a percentage decrease of ",
1465
+ m,
1466
+ "% comparing their average of the last four check-ins."
1467
+ ] }) }),
1468
+ y && /* @__PURE__ */ e("div", { children: /* @__PURE__ */ n("p", { className: B["flag-of-session__item--content"], children: [
1469
+ /* @__PURE__ */ e("span", { className: B["flag-of-session__item--title"], children: "Ready to learn: " }),
1470
+ "The student reported as not ready to learn in last check-in."
1471
+ ] }) })
1472
+ ] }), ys = kt(({ className: a, ...s }) => /* @__PURE__ */ e(Me, { ...s, classes: { popper: a } }))(({ theme: a }) => ({
1473
+ zIndex: 1e3,
1474
+ [`& .${Ae.tooltip}`]: {
1475
+ backgroundColor: "transparent !important",
1476
+ marginTop: "8px !important",
1477
+ fontFamily: "Poppins-Regular"
1478
+ },
1479
+ [`& .${Ae.arrow}`]: {
1480
+ color: a.palette.common.white,
1481
+ top: "4px !important"
1482
+ }
1483
+ })), Ts = (a) => {
1484
+ if (!a) return null;
1485
+ const s = a.toLowerCase();
1486
+ return s === "red" ? /* @__PURE__ */ e(pe, { size: 32, color: "#C44140" }) : s === "yellow" ? /* @__PURE__ */ e(pe, { size: 32, color: "#F5D500" }) : s === "green" ? /* @__PURE__ */ e(pe, { size: 32, color: "#10B981" }) : null;
1487
+ }, Ns = ({
1488
+ students: a,
1489
+ totalStudentsCount: s,
1490
+ totalSelectedCount: c,
1491
+ selectedStudentIds: g,
1492
+ filters: r,
1493
+ gradeOptions: l,
1494
+ flagOptions: T,
1495
+ teacherOptions: m,
1496
+ page: d,
1497
+ rowsPerPage: y,
1498
+ isAllSelected: C,
1499
+ isIndeterminate: h,
1500
+ sortBy: _,
1501
+ sortOrder: k,
1502
+ onSortChange: P,
1503
+ currentStepNumber: E,
1504
+ totalSteps: v,
1505
+ onSearchChange: R,
1506
+ onGradeChange: x,
1507
+ onFlagChange: p,
1508
+ onTeacherChange: L,
1509
+ onPageChange: W,
1510
+ onRowsPerPageChange: H,
1511
+ onToggleSelectAll: Z,
1512
+ onToggleStudent: V,
1513
+ onPrevious: ee,
1514
+ onNext: X
1515
+ }) => {
1516
+ const le = (o) => {
1517
+ x(o.target.value);
1518
+ }, N = (o) => {
1519
+ p(o.target.value);
1520
+ }, S = (o, w) => {
1521
+ L(w || "All Teachers");
1522
+ }, u = G(() => !m || m.length === 0 ? ["All Teachers"] : m.includes("All Teachers") ? m : ["All Teachers", ...m], [m]), F = (o, w) => {
1523
+ const A = (w.inputValue || "").trim().toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "");
1524
+ return A ? o.filter((Q) => Q.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "").includes(A)) : o;
1525
+ };
1526
+ return /* @__PURE__ */ n(i, { className: t.chooseTemplateCard, children: [
1527
+ /* @__PURE__ */ n(i, { className: t.headerSection, children: [
1528
+ /* @__PURE__ */ e(b, { variant: "h5", className: t.headerTitle, children: "Select Students" }),
1529
+ /* @__PURE__ */ e(b, { variant: "body2", className: t.headerSubtitle, children: "Choose the students who should participate in this survey" })
1530
+ ] }),
1531
+ /* @__PURE__ */ e(i, { className: t.selectedCountSection, children: /* @__PURE__ */ n(b, { variant: "subtitle1", className: t.selectedCountText, children: [
1532
+ "Selected students",
1533
+ " ",
1534
+ /* @__PURE__ */ e(i, { component: "span", className: t.selectedCountHighlight, children: c })
1535
+ ] }) }),
1536
+ /* @__PURE__ */ n(i, { className: t.studentsToolbar, children: [
1537
+ /* @__PURE__ */ e(i, { className: t.searchBarContainer, children: /* @__PURE__ */ e(
1538
+ J,
1539
+ {
1540
+ fullWidth: !0,
1541
+ size: "small",
1542
+ placeholder: "Search students by name or email...",
1543
+ value: r.searchQuery,
1544
+ onChange: (o) => R(o.target.value),
1545
+ className: t.studentSearchInput,
1546
+ InputProps: {
1547
+ startAdornment: /* @__PURE__ */ e(Nt, { position: "start", children: /* @__PURE__ */ e(zt, { sx: { color: "#94a3b8", fontSize: 20 } }) })
1548
+ }
1549
+ }
1550
+ ) }),
1551
+ /* @__PURE__ */ e(i, { className: t.filterDropdownWrapper, children: /* @__PURE__ */ e(we, { size: "small", fullWidth: !0, children: /* @__PURE__ */ e(
1552
+ xe,
1553
+ {
1554
+ value: r.selectedGrade,
1555
+ onChange: le,
1556
+ displayEmpty: !0,
1557
+ className: t.filterSelectBox,
1558
+ children: l.map((o) => /* @__PURE__ */ e(Fe, { value: o, children: o }, o))
1559
+ }
1560
+ ) }) }),
1561
+ /* @__PURE__ */ e(i, { className: t.filterDropdownWrapper, children: /* @__PURE__ */ e(we, { size: "small", fullWidth: !0, children: /* @__PURE__ */ e(
1562
+ xe,
1563
+ {
1564
+ value: r.selectedFlag,
1565
+ onChange: N,
1566
+ displayEmpty: !0,
1567
+ className: t.filterSelectBox,
1568
+ children: T.map((o) => /* @__PURE__ */ e(Fe, { value: o.value, children: o.label }, o.value))
1569
+ }
1570
+ ) }) }),
1571
+ /* @__PURE__ */ e(i, { className: t.teacherFilterWrapper, children: /* @__PURE__ */ e(
1572
+ St,
1573
+ {
1574
+ size: "small",
1575
+ fullWidth: !0,
1576
+ options: u,
1577
+ value: r.selectedTeacher || "All Teachers",
1578
+ onChange: S,
1579
+ disableClearable: r.selectedTeacher === "All Teachers",
1580
+ clearOnBlur: !0,
1581
+ handleHomeEndKeys: !0,
1582
+ isOptionEqualToValue: (o, w) => !w || o === w || w === "All Teachers",
1583
+ filterOptions: F,
1584
+ noOptionsText: "No teachers found",
1585
+ className: t.teacherAutocomplete,
1586
+ classes: {
1587
+ paper: t.teacherAutocompletePaper,
1588
+ listbox: t.teacherAutocompleteListbox
1589
+ },
1590
+ componentsProps: {
1591
+ paper: {
1592
+ className: t.teacherAutocompletePaper,
1593
+ sx: {
1594
+ backgroundColor: "#ffffff !important",
1595
+ color: "#000000 !important"
1596
+ }
1597
+ },
1598
+ popper: {
1599
+ sx: {
1600
+ zIndex: 1300
1601
+ }
1602
+ }
1603
+ },
1604
+ slotProps: {
1605
+ paper: {
1606
+ className: t.teacherAutocompletePaper,
1607
+ sx: {
1608
+ backgroundColor: "#ffffff !important",
1609
+ color: "#000000 !important"
1610
+ }
1611
+ },
1612
+ popper: {
1613
+ sx: {
1614
+ zIndex: 1300
1615
+ }
1616
+ }
1617
+ },
1618
+ renderOption: (o, w, { selected: A }) => {
1619
+ const { key: Q, ...f } = o;
1620
+ return /* @__PURE__ */ e(
1621
+ "li",
1622
+ {
1623
+ ...f,
1624
+ className: t.teacherOptionItem,
1625
+ style: {
1626
+ backgroundColor: A ? "#f1f5f9" : "#ffffff",
1627
+ color: "#000000",
1628
+ fontSize: "14px",
1629
+ fontWeight: A ? 600 : 500,
1630
+ padding: "9px 14px",
1631
+ cursor: "pointer"
1632
+ },
1633
+ children: w
1634
+ },
1635
+ Q || w
1636
+ );
1637
+ },
1638
+ renderInput: (o) => /* @__PURE__ */ e(
1639
+ J,
1640
+ {
1641
+ ...o,
1642
+ placeholder: "All Teachers",
1643
+ size: "small",
1644
+ inputProps: {
1645
+ ...o.inputProps,
1646
+ style: {
1647
+ color: "#000000",
1648
+ fontWeight: 500
1649
+ }
1650
+ }
1651
+ }
1652
+ )
1653
+ }
1654
+ ) })
1655
+ ] }),
1656
+ /* @__PURE__ */ n(i, { className: t.studentsTableContainer, children: [
1657
+ /* @__PURE__ */ n(Ne, { className: t.studentsTable, children: [
1658
+ /* @__PURE__ */ e(Se, { children: /* @__PURE__ */ n(j, { className: t.studentsTableHeaderRow, children: [
1659
+ /* @__PURE__ */ e(I, { className: t.checkboxHeaderCell, children: /* @__PURE__ */ e(
1660
+ De,
1661
+ {
1662
+ checked: C,
1663
+ indeterminate: h,
1664
+ onChange: Z,
1665
+ sx: {
1666
+ color: "#cbd5e1",
1667
+ "&.Mui-checked": { color: "#2563eb" },
1668
+ "&.MuiCheckbox-indeterminate": { color: "#2563eb" }
1669
+ }
1670
+ }
1671
+ ) }),
1672
+ /* @__PURE__ */ e(I, { className: t.tableHeaderCell, children: /* @__PURE__ */ e(
1673
+ me,
1674
+ {
1675
+ active: _ === "name",
1676
+ direction: _ === "name" ? k : "asc",
1677
+ onClick: () => P("name"),
1678
+ children: "Student Name"
1679
+ }
1680
+ ) }),
1681
+ /* @__PURE__ */ e(I, { className: t.tableHeaderCell, children: /* @__PURE__ */ e(
1682
+ me,
1683
+ {
1684
+ active: _ === "flag",
1685
+ direction: _ === "flag" ? k : "asc",
1686
+ onClick: () => P("flag"),
1687
+ children: "Flag"
1688
+ }
1689
+ ) }),
1690
+ /* @__PURE__ */ e(I, { className: t.tableHeaderCell, children: /* @__PURE__ */ e(
1691
+ me,
1692
+ {
1693
+ active: _ === "grade",
1694
+ direction: _ === "grade" ? k : "asc",
1695
+ onClick: () => P("grade"),
1696
+ children: "Grade"
1697
+ }
1698
+ ) }),
1699
+ /* @__PURE__ */ e(I, { className: t.tableHeaderCell, children: /* @__PURE__ */ e(
1700
+ me,
1701
+ {
1702
+ active: _ === "email",
1703
+ direction: _ === "email" ? k : "asc",
1704
+ onClick: () => P("email"),
1705
+ children: "Email"
1706
+ }
1707
+ ) }),
1708
+ /* @__PURE__ */ e(I, { className: t.tableHeaderCell, children: /* @__PURE__ */ e(
1709
+ me,
1710
+ {
1711
+ active: _ === "teacher",
1712
+ direction: _ === "teacher" ? k : "asc",
1713
+ onClick: () => P("teacher"),
1714
+ children: "Teacher"
1715
+ }
1716
+ ) })
1717
+ ] }) }),
1718
+ /* @__PURE__ */ e(ve, { children: a.length === 0 ? /* @__PURE__ */ e(j, { children: /* @__PURE__ */ e(I, { colSpan: 5, align: "center", sx: { py: 4, color: "#94a3b8" }, children: "No students found matching current filters." }) }) : a.map((o) => {
1719
+ const w = g.includes(o.id);
1720
+ return /* @__PURE__ */ n(
1721
+ j,
1722
+ {
1723
+ className: `${t.studentTableRow} ${w ? t.selectedRow : ""}`,
1724
+ onClick: () => V(o.id),
1725
+ children: [
1726
+ /* @__PURE__ */ e(
1727
+ I,
1728
+ {
1729
+ className: t.checkboxBodyCell,
1730
+ onClick: (A) => A.stopPropagation(),
1731
+ children: /* @__PURE__ */ e(
1732
+ De,
1733
+ {
1734
+ checked: w,
1735
+ onChange: () => V(o.id),
1736
+ sx: {
1737
+ color: "#cbd5e1",
1738
+ "&.Mui-checked": { color: "#2563eb" }
1739
+ }
1740
+ }
1741
+ )
1742
+ }
1743
+ ),
1744
+ /* @__PURE__ */ e(I, { className: t.studentNameCell, children: /* @__PURE__ */ n($, { direction: "row", alignItems: "center", spacing: 1.75, children: [
1745
+ /* @__PURE__ */ e(
1746
+ "img",
1747
+ {
1748
+ src: o.avatarUrl,
1749
+ alt: o.name,
1750
+ style: { width: 44, height: 44, borderRadius: "50%", objectFit: "cover" }
1751
+ }
1752
+ ),
1753
+ /* @__PURE__ */ e(b, { variant: "body2", className: t.studentNameText, children: o.name })
1754
+ ] }) }),
1755
+ /* @__PURE__ */ e(I, { className: t.flagCell, children: /* @__PURE__ */ e(
1756
+ ys,
1757
+ {
1758
+ arrow: !0,
1759
+ placement: "bottom",
1760
+ title: o?.flag && o.flag !== "none" ? /* @__PURE__ */ e(
1761
+ bs,
1762
+ {
1763
+ flag: o.flag === "red" ? "Red Flag" : o.flag === "yellow" ? "Yellow Flag" : "Green Flag",
1764
+ flagDetail: o.flagDetail,
1765
+ lastSafetyAnswer: o.lastSafetyAnswer,
1766
+ lastStressAnswer: o.lastStressAnswer,
1767
+ showResult: !0
1768
+ }
1769
+ ) : "",
1770
+ children: /* @__PURE__ */ e("span", { children: /* @__PURE__ */ e("div", { style: { display: "flex", justifyContent: "center", cursor: "pointer" }, children: Ts(o.flag) }) })
1771
+ }
1772
+ ) }),
1773
+ /* @__PURE__ */ e(I, { className: t.gradeCell, children: /* @__PURE__ */ e(b, { variant: "body2", className: t.gradeText, children: o.grade }) }),
1774
+ /* @__PURE__ */ e(I, { className: t.emailCell, children: /* @__PURE__ */ e(b, { variant: "body2", className: t.emailText, children: o.email }) }),
1775
+ /* @__PURE__ */ e(I, { children: /* @__PURE__ */ e(b, { variant: "body2", sx: { color: "#475569" }, children: o.listTeachers && o.listTeachers.length > 0 ? o.listTeachers.map((A) => A.name).filter(Boolean).join(", ") : "-" }) })
1776
+ ]
1777
+ },
1778
+ o.id
1779
+ );
1780
+ }) })
1781
+ ] }),
1782
+ s > 0 && /* @__PURE__ */ e(
1783
+ vt,
1784
+ {
1785
+ rowsPerPageOptions: [5, 10, 25, 50],
1786
+ component: "div",
1787
+ count: s,
1788
+ rowsPerPage: y,
1789
+ page: d,
1790
+ onPageChange: W,
1791
+ onRowsPerPageChange: H,
1792
+ className: t.studentsPagination
1793
+ }
1794
+ )
1795
+ ] }),
1796
+ /* @__PURE__ */ e(
1797
+ ge,
1798
+ {
1799
+ currentStep: E,
1800
+ totalSteps: v,
1801
+ onPrevious: ee,
1802
+ onNext: X
1803
+ }
1804
+ )
1805
+ ] });
1806
+ }, Ss = ({ size: a = 32, color: s = "#C44140" }) => /* @__PURE__ */ e("svg", { width: a, height: a, viewBox: "0 0 32 32", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ e("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: s }) }), vs = wt(({ className: a, ...s }) => /* @__PURE__ */ e(Me, { ...s, classes: { popper: a } }))(() => ({
1807
+ [`& .${Ae.tooltip}`]: {
1808
+ backgroundColor: "#ffffff",
1809
+ color: "#1e293b",
1810
+ maxWidth: 220,
1811
+ fontSize: "0.75rem",
1812
+ border: "1px solid #e2e8f0",
1813
+ boxShadow: "0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",
1814
+ borderRadius: "8px",
1815
+ padding: "8px 12px"
1816
+ },
1817
+ [`& .${Ae.arrow}`]: {
1818
+ color: "#ffffff",
1819
+ "&:before": {
1820
+ border: "1px solid #e2e8f0"
1821
+ }
1822
+ }
1823
+ })), ws = ({ flag: a, tooltip: s }) => {
1824
+ if (a === "none") return null;
1825
+ let c = "#10B981";
1826
+ return a === "red" ? c = "#D10530" : a === "yellow" ? c = "#F5D500" : a === "green" && (c = "#0F9655"), /* @__PURE__ */ e(vs, { title: s ? /* @__PURE__ */ e(i, { sx: { lineHeight: 1.4 }, children: s }) : /* @__PURE__ */ e(i, { sx: { lineHeight: 1.4 }, children: a === "red" ? /* @__PURE__ */ n(Re, { children: [
1827
+ /* @__PURE__ */ e(i, { component: "span", sx: { color: "#D10530", fontWeight: 700 }, children: "High" }),
1828
+ " Risk,",
1829
+ /* @__PURE__ */ e("br", {}),
1830
+ /* @__PURE__ */ e(i, { component: "span", sx: { color: "#D10530", fontWeight: 700 }, children: "Negative" }),
1831
+ " readiness to learn"
1832
+ ] }) : a === "yellow" ? /* @__PURE__ */ n(Re, { children: [
1833
+ /* @__PURE__ */ e(i, { component: "span", sx: { color: "#F5D500", fontWeight: 700 }, children: "Moderate" }),
1834
+ " Risk,",
1835
+ /* @__PURE__ */ e("br", {}),
1836
+ /* @__PURE__ */ e(i, { component: "span", sx: { color: "#F5D500", fontWeight: 700 }, children: "Caution" }),
1837
+ " readiness to learn"
1838
+ ] }) : /* @__PURE__ */ n(Re, { children: [
1839
+ /* @__PURE__ */ e(i, { component: "span", sx: { color: "#0F9655", fontWeight: 700 }, children: "Low" }),
1840
+ " Risk,",
1841
+ /* @__PURE__ */ e("br", {}),
1842
+ /* @__PURE__ */ e(i, { component: "span", sx: { color: "#0F9655", fontWeight: 700 }, children: "Positive" }),
1843
+ " readiness to learn"
1844
+ ] }) }), arrow: !0, placement: "top", children: /* @__PURE__ */ e(
1845
+ i,
1846
+ {
1847
+ component: "span",
1848
+ sx: {
1849
+ display: "inline-flex",
1850
+ alignItems: "center",
1851
+ cursor: "pointer",
1852
+ transition: "transform 0.15s ease",
1853
+ "&:hover": {
1854
+ transform: "scale(1.15)"
1855
+ }
1856
+ },
1857
+ children: /* @__PURE__ */ e(Ss, { color: c, size: 28 })
1858
+ }
1859
+ ) });
1860
+ }, xs = Ie(/* @__PURE__ */ e("path", {
1861
+ 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"
1862
+ }), "CalendarMonthOutlined"), Fs = ({
1863
+ open: a,
1864
+ title: s,
1865
+ description: c,
1866
+ deadline: g,
1867
+ questions: r,
1868
+ onClose: l
1869
+ }) => {
1870
+ const T = (d) => {
1871
+ if (typeof d == "number" || !isNaN(Number(d)) && String(d).trim() !== "") {
1872
+ const y = Number(d);
1873
+ if (y === 0) return "Text";
1874
+ if (y === 1) return "MultipleChoice";
1875
+ if (y === 2 || y === 3) return "Slider";
1876
+ if (y === 4) return "YesNo";
1877
+ if (y === 5) return "SingleChoice";
1878
+ if (y === 6) return "Date";
1879
+ if (y === 9) return "Summarize";
1880
+ if (y === 12) return "DropDown";
1881
+ }
1882
+ return String(d);
1883
+ }, m = (d) => {
1884
+ try {
1885
+ const y = document.createElement("textarea");
1886
+ return y.innerHTML = d, y.value;
1887
+ } catch {
1888
+ return d;
1889
+ }
1890
+ };
1891
+ return /* @__PURE__ */ n(
1892
+ He,
1893
+ {
1894
+ open: a,
1895
+ onClose: l,
1896
+ maxWidth: "md",
1897
+ fullWidth: !0,
1898
+ PaperProps: {
1899
+ sx: {
1900
+ borderRadius: "16px",
1901
+ p: 1,
1902
+ maxHeight: "90vh"
1903
+ }
1904
+ },
1905
+ children: [
1906
+ /* @__PURE__ */ n(
1907
+ Qe,
1908
+ {
1909
+ sx: {
1910
+ display: "flex",
1911
+ justifyContent: "space-between",
1912
+ alignItems: "center",
1913
+ pb: 1,
1914
+ fontWeight: 700,
1915
+ fontSize: "1.1rem",
1916
+ color: "#0f172a"
1917
+ },
1918
+ children: [
1919
+ "Survey preview",
1920
+ /* @__PURE__ */ e(xt, { onClick: l, size: "small", sx: { color: "#64748b" }, children: /* @__PURE__ */ e(Wt, { fontSize: "small" }) })
1921
+ ]
1922
+ }
1923
+ ),
1924
+ /* @__PURE__ */ n(Oe, { dividers: !0, sx: { p: 3 }, children: [
1925
+ /* @__PURE__ */ e(b, { variant: "h6", sx: { fontWeight: 800, color: "#0f172a", mb: 0.5 }, children: s || "Student Well Being" }),
1926
+ /* @__PURE__ */ e(b, { variant: "body2", sx: { color: "#64748b", mb: 2 }, children: c || "General assessment of student wellness and quality of life" }),
1927
+ g && /* @__PURE__ */ n($, { direction: "row", spacing: 1, alignItems: "center", sx: { color: "#64748b", mb: 3 }, children: [
1928
+ /* @__PURE__ */ e(xs, { sx: { fontSize: 16, color: "#2563eb" } }),
1929
+ /* @__PURE__ */ n(b, { variant: "caption", sx: { fontWeight: 600 }, children: [
1930
+ "Due: ",
1931
+ g
1932
+ ] })
1933
+ ] }),
1934
+ /* @__PURE__ */ e($, { spacing: 3, children: r.map((d, y) => {
1935
+ const C = T(d.type), h = d.options && d.options.length > 0 ? d.options : d.answers && Array.isArray(d.answers) ? d.answers.map((_) => typeof _ == "string" ? _ : _?.text ?? _?.answerText ?? "").filter(Boolean) : [];
1936
+ return /* @__PURE__ */ n(i, { sx: { pb: 1 }, children: [
1937
+ /* @__PURE__ */ n(i, { sx: { display: "flex", gap: "4px", fontWeight: 600, color: "#1e293b", mb: 1.5, fontSize: "0.875rem" }, children: [
1938
+ /* @__PURE__ */ n(i, { children: [
1939
+ y + 1,
1940
+ "."
1941
+ ] }),
1942
+ /* @__PURE__ */ e(i, { sx: { "& p": { m: 0, display: "inline" }, "& span": { display: "inline" } }, dangerouslySetInnerHTML: { __html: m(d.questionText || "") } })
1943
+ ] }),
1944
+ (C === "Rating" || C === "StarRating" || C === "Slider") && /* @__PURE__ */ e(i, { sx: { px: 2, py: 1 }, children: /* @__PURE__ */ e(
1945
+ Ht,
1946
+ {
1947
+ questionId: Number(d.id) || 0,
1948
+ valueText: "50",
1949
+ minText: d.fromLabel || "",
1950
+ maxText: d.toLabel || "",
1951
+ isBeforeSession: !1,
1952
+ isPageResult: !0
1953
+ }
1954
+ ) }),
1955
+ C === "MultipleChoice" && /* @__PURE__ */ e(i, { sx: { px: 2 }, children: /* @__PURE__ */ e(
1956
+ Qt,
1957
+ {
1958
+ questionId: Number(d.id) || 0,
1959
+ valueText: "",
1960
+ isUserChangeSession: !0,
1961
+ questionAnswer: h,
1962
+ isPageResult: !0
1963
+ }
1964
+ ) }),
1965
+ (C === "YesNo" || C === "SingleChoice") && /* @__PURE__ */ e(i, { sx: { px: 2 }, children: /* @__PURE__ */ e(
1966
+ Ot,
1967
+ {
1968
+ questionId: Number(d.id) || 0,
1969
+ valueText: "",
1970
+ isUserChangeSession: !0,
1971
+ questionAnswer: h.length > 0 ? h : C === "YesNo" ? ["Yes", "No"] : []
1972
+ }
1973
+ ) }),
1974
+ (C === "Text" || C === "TextInput" || C === "OpenField") && /* @__PURE__ */ e(
1975
+ J,
1976
+ {
1977
+ fullWidth: !0,
1978
+ multiline: !0,
1979
+ rows: 2,
1980
+ placeholder: "Your answer...",
1981
+ size: "small",
1982
+ sx: {
1983
+ "& .MuiOutlinedInput-root": {
1984
+ borderRadius: "8px",
1985
+ backgroundColor: "#ffffff"
1986
+ }
1987
+ }
1988
+ }
1989
+ ),
1990
+ C === "DropDown" && /* @__PURE__ */ e(i, { sx: { px: 2 }, children: /* @__PURE__ */ e(
1991
+ Mt,
1992
+ {
1993
+ questionItemName: "",
1994
+ questionId: Number(d.id) || 0,
1995
+ valueText: "",
1996
+ isUserChangeSession: !0,
1997
+ questionAnswer: h.map((_, k) => ({ id: k, text: _ }))
1998
+ }
1999
+ ) }),
2000
+ C === "Summarize" && /* @__PURE__ */ e(
2001
+ J,
2002
+ {
2003
+ fullWidth: !0,
2004
+ multiline: !0,
2005
+ rows: 4,
2006
+ placeholder: "Summarize your thoughts...",
2007
+ size: "small",
2008
+ sx: {
2009
+ "& .MuiOutlinedInput-root": {
2010
+ borderRadius: "8px",
2011
+ backgroundColor: "#ffffff"
2012
+ }
2013
+ }
2014
+ }
2015
+ )
2016
+ ] }, d.id);
2017
+ }) })
2018
+ ] })
2019
+ ]
2020
+ }
2021
+ );
2022
+ }, As = ({
2023
+ templateFormData: a,
2024
+ surveyFormData: s,
2025
+ selectedStudents: c,
2026
+ currentStepNumber: g,
2027
+ totalSteps: r,
2028
+ onEditTemplateDetails: l,
2029
+ onEditSurveyDetails: T,
2030
+ onEditSelectedStudents: m,
2031
+ onPrevious: d,
2032
+ onPublish: y
2033
+ }) => {
2034
+ const [C, h] = M(!1);
2035
+ return /* @__PURE__ */ n(i, { className: t.chooseTemplateCard, children: [
2036
+ /* @__PURE__ */ n(i, { className: t.reviewSectionBlock, children: [
2037
+ /* @__PURE__ */ n(i, { className: t.reviewSectionHeader, children: [
2038
+ /* @__PURE__ */ e(b, { variant: "h6", className: t.reviewSectionTitle, children: "Template Details" }),
2039
+ /* @__PURE__ */ e(
2040
+ Y,
2041
+ {
2042
+ variant: "text",
2043
+ onClick: l,
2044
+ startIcon: /* @__PURE__ */ e(fe, { sx: { fontSize: 16 } }),
2045
+ className: t.reviewEditSectionBtn,
2046
+ children: "EDIT"
2047
+ }
2048
+ )
2049
+ ] }),
2050
+ /* @__PURE__ */ n(i, { className: t.reviewFieldGroup, children: [
2051
+ /* @__PURE__ */ e(b, { variant: "caption", className: t.reviewFieldLabel, children: "Template Name" }),
2052
+ /* @__PURE__ */ e(b, { variant: "body2", className: t.reviewFieldValue, children: a.templateName || "Well-being" })
2053
+ ] }),
2054
+ /* @__PURE__ */ n(i, { className: t.reviewFieldGroup, children: [
2055
+ /* @__PURE__ */ e(b, { variant: "caption", className: t.reviewFieldLabel, children: "Description and instructions of when to use" }),
2056
+ /* @__PURE__ */ e(b, { variant: "body2", className: t.reviewFieldValue, children: a.description || "General assessment of student wellness and quality of life" })
2057
+ ] }),
2058
+ /* @__PURE__ */ n(i, { className: t.reviewFieldGroup, sx: { mt: 3 }, children: [
2059
+ /* @__PURE__ */ e(b, { variant: "caption", className: t.reviewFieldLabel, children: "Questions" }),
2060
+ /* @__PURE__ */ e(b, { variant: "h6", className: t.questionsHeadingText, sx: { mb: 1.5 }, children: /* @__PURE__ */ e("span", { className: t.questionCountBadge, children: a.questions.length }) }),
2061
+ /* @__PURE__ */ e(i, { className: t.reviewQuestionsTableContainer, children: /* @__PURE__ */ n(Ne, { className: t.questionsTable, children: [
2062
+ /* @__PURE__ */ e(Se, { children: /* @__PURE__ */ n(j, { className: t.tableHeaderRow, children: [
2063
+ /* @__PURE__ */ e(I, { className: t.thNumber, children: "#" }),
2064
+ /* @__PURE__ */ e(I, { className: t.thQuestion, children: "Question" }),
2065
+ /* @__PURE__ */ e(I, { className: t.thType, children: "Type" }),
2066
+ /* @__PURE__ */ e(I, { className: t.thCategory, children: "Category" })
2067
+ ] }) }),
2068
+ /* @__PURE__ */ e(ve, { children: a.questions.map((_, k) => /* @__PURE__ */ n(j, { className: t.tableBodyRow, children: [
2069
+ /* @__PURE__ */ n(I, { className: t.tdNumber, children: [
2070
+ k + 1,
2071
+ "."
2072
+ ] }),
2073
+ /* @__PURE__ */ e(I, { className: t.tdQuestion, children: /* @__PURE__ */ e(
2074
+ b,
2075
+ {
2076
+ variant: "body2",
2077
+ className: t.questionText,
2078
+ dangerouslySetInnerHTML: {
2079
+ __html: _.questionText || ""
2080
+ }
2081
+ }
2082
+ ) }),
2083
+ /* @__PURE__ */ e(I, { className: t.tdType, children: /* @__PURE__ */ e(Je, { type: _.type }) }),
2084
+ /* @__PURE__ */ e(I, { className: t.tdCategory, children: /* @__PURE__ */ e(b, { variant: "body2", className: t.categoryText, children: _.category }) })
2085
+ ] }, _.id)) })
2086
+ ] }) })
2087
+ ] })
2088
+ ] }),
2089
+ /* @__PURE__ */ n(i, { className: t.reviewSectionBlock, children: [
2090
+ /* @__PURE__ */ n(i, { className: t.reviewSectionHeader, children: [
2091
+ /* @__PURE__ */ e(b, { variant: "h6", className: t.reviewSectionTitle, children: "Survey Details" }),
2092
+ /* @__PURE__ */ e(
2093
+ Y,
2094
+ {
2095
+ variant: "text",
2096
+ onClick: T,
2097
+ startIcon: /* @__PURE__ */ e(fe, { sx: { fontSize: 16 } }),
2098
+ className: t.reviewEditSectionBtn,
2099
+ children: "EDIT"
2100
+ }
2101
+ )
2102
+ ] }),
2103
+ /* @__PURE__ */ n(i, { className: t.reviewFieldGroup, children: [
2104
+ /* @__PURE__ */ e(b, { variant: "caption", className: t.reviewFieldLabel, children: "Title" }),
2105
+ /* @__PURE__ */ e(b, { variant: "body2", className: t.reviewFieldValue, children: s.title || "Student Well Being" })
2106
+ ] }),
2107
+ /* @__PURE__ */ n(i, { className: t.reviewFieldGroup, children: [
2108
+ /* @__PURE__ */ e(b, { variant: "caption", className: t.reviewFieldLabel, children: "Deadline" }),
2109
+ /* @__PURE__ */ e(b, { variant: "body2", className: t.reviewFieldValue, children: s.deadline || "15th January 2026, 12:00 PM" })
2110
+ ] })
2111
+ ] }),
2112
+ /* @__PURE__ */ n(i, { className: t.reviewSectionBlock, children: [
2113
+ /* @__PURE__ */ n(i, { className: t.reviewSectionHeader, children: [
2114
+ /* @__PURE__ */ n(b, { variant: "h6", className: t.reviewSectionTitle, children: [
2115
+ "Selected Students",
2116
+ " ",
2117
+ /* @__PURE__ */ e(i, { component: "span", sx: { color: "#2563eb", fontWeight: 700 }, children: c.length })
2118
+ ] }),
2119
+ /* @__PURE__ */ e(
2120
+ Y,
2121
+ {
2122
+ variant: "text",
2123
+ onClick: m,
2124
+ startIcon: /* @__PURE__ */ e(fe, { sx: { fontSize: 16 } }),
2125
+ className: t.reviewEditSectionBtn,
2126
+ children: "EDIT"
2127
+ }
2128
+ )
2129
+ ] }),
2130
+ /* @__PURE__ */ e(i, { className: t.studentsTableContainer, children: /* @__PURE__ */ n(Ne, { className: t.studentsTable, children: [
2131
+ /* @__PURE__ */ e(Se, { children: /* @__PURE__ */ n(j, { className: t.tableHeaderRow, children: [
2132
+ /* @__PURE__ */ e(I, { className: t.tableHeaderCell, children: "Student Name" }),
2133
+ /* @__PURE__ */ e(I, { className: t.tableHeaderCell, children: "Flag" }),
2134
+ /* @__PURE__ */ e(I, { className: t.tableHeaderCell, children: "Grade" }),
2135
+ /* @__PURE__ */ e(I, { className: t.tableHeaderCell, children: "Email" })
2136
+ ] }) }),
2137
+ /* @__PURE__ */ e(ve, { children: c.length === 0 ? /* @__PURE__ */ e(j, { children: /* @__PURE__ */ e(I, { colSpan: 4, align: "center", sx: { py: 3, color: "#94a3b8" }, children: "No students selected." }) }) : c.map((_) => /* @__PURE__ */ n(j, { className: t.studentTableRow, children: [
2138
+ /* @__PURE__ */ e(I, { className: t.studentNameCell, children: /* @__PURE__ */ n($, { direction: "row", alignItems: "center", spacing: 1.5, children: [
2139
+ /* @__PURE__ */ e(
2140
+ Ft,
2141
+ {
2142
+ src: _.avatarUrl,
2143
+ alt: _.name,
2144
+ sx: {
2145
+ width: 28,
2146
+ height: 28,
2147
+ fontSize: "0.75rem",
2148
+ bgcolor: "#e0e7ff",
2149
+ color: "#3730a3"
2150
+ },
2151
+ children: _.name.charAt(0)
2152
+ }
2153
+ ),
2154
+ /* @__PURE__ */ e(b, { variant: "body2", className: t.studentNameText, children: _.name })
2155
+ ] }) }),
2156
+ /* @__PURE__ */ e(I, { className: t.flagCell, children: /* @__PURE__ */ e(
2157
+ ws,
2158
+ {
2159
+ flag: _.flag,
2160
+ tooltip: _.flagTooltip
2161
+ }
2162
+ ) }),
2163
+ /* @__PURE__ */ e(I, { className: t.gradeCell, children: /* @__PURE__ */ e(b, { variant: "body2", className: t.gradeText, children: _.grade }) }),
2164
+ /* @__PURE__ */ e(I, { className: t.emailCell, children: /* @__PURE__ */ e(b, { variant: "body2", className: t.emailText, children: _.email }) })
2165
+ ] }, _.id)) })
2166
+ ] }) })
2167
+ ] }),
2168
+ /* @__PURE__ */ e(
2169
+ ge,
2170
+ {
2171
+ currentStep: g,
2172
+ totalSteps: r,
2173
+ isLastStep: !0,
2174
+ nextLabel: "PUBLISH",
2175
+ onPreview: () => h(!0),
2176
+ onPrevious: d,
2177
+ onNext: y
2178
+ }
2179
+ ),
2180
+ /* @__PURE__ */ e(
2181
+ Fs,
2182
+ {
2183
+ open: C,
2184
+ title: s.title || a.templateName,
2185
+ description: a.description,
2186
+ deadline: s.deadline,
2187
+ questions: a.questions,
2188
+ onClose: () => h(!1)
2189
+ }
2190
+ )
2191
+ ] });
2192
+ }, Is = [
2193
+ {
2194
+ id: "q-1",
2195
+ orderNumber: 1,
2196
+ questionText: "How would you rate your overall well-being?",
2197
+ type: "Rating",
2198
+ category: "Overall Well-being"
2199
+ },
2200
+ {
2201
+ id: "q-2",
2202
+ orderNumber: 2,
2203
+ questionText: "Do you feel balanced in your daily life?",
2204
+ type: "YesNo",
2205
+ category: "Life Balance"
2206
+ },
2207
+ {
2208
+ id: "q-3",
2209
+ orderNumber: 3,
2210
+ questionText: "What contributes most to your well-being?",
2211
+ type: "Text",
2212
+ category: "Well-being Factors"
2213
+ }
2214
+ ], Bs = ({
2215
+ template: a,
2216
+ initialDraftData: s,
2217
+ onSave: c,
2218
+ onCancel: g,
2219
+ onAddQuestionRedirect: r,
2220
+ onEditQuestionRedirect: l
2221
+ }) => {
2222
+ const T = G(() => a.rawTemplate ? Te(a.rawTemplate.questionTemplates, a.category || "Well-being") : Is, [a]), [m, d] = M(() => s || {
2223
+ id: a.id,
2224
+ templateName: a.title,
2225
+ description: a.description || "",
2226
+ showLandingPageFlag: !1,
2227
+ selectedCategoryFilter: "All",
2228
+ questions: T
2229
+ }), y = G(() => {
2230
+ const x = /* @__PURE__ */ new Set();
2231
+ m.questions.forEach((L) => {
2232
+ const W = L.category?.trim();
2233
+ W && x.add(W);
2234
+ });
2235
+ const p = Array.from(x);
2236
+ return p.length > 0 ? ["All", ...p] : ["All"];
2237
+ }, [m.questions]), C = G(() => m.selectedCategoryFilter === "All" ? m.questions : m.questions.filter(
2238
+ (x) => x.category === m.selectedCategoryFilter
2239
+ ), [m.questions, m.selectedCategoryFilter]), h = (x) => {
2240
+ d((p) => ({ ...p, templateName: x }));
2241
+ }, _ = (x) => {
2242
+ d((p) => ({ ...p, description: x }));
2243
+ }, k = (x) => {
2244
+ d((p) => ({ ...p, selectedCategoryFilter: x }));
2245
+ }, P = (x) => {
2246
+ l && l(x, m);
2247
+ }, E = (x) => {
2248
+ d((p) => ({
2249
+ ...p,
2250
+ questions: p.questions.filter((L) => L.id !== x).map((L, W) => ({ ...L, orderNumber: W + 1 }))
2251
+ }));
2252
+ }, v = () => {
2253
+ r && r(m);
2254
+ }, R = () => {
2255
+ const x = {
2256
+ ...a,
2257
+ title: m.templateName,
2258
+ description: m.description,
2259
+ questionCount: m.questions.length,
2260
+ rawTemplate: {
2261
+ ...a.rawTemplate,
2262
+ questionTemplates: m.questions.map((p, L) => ({
2263
+ ...p,
2264
+ questionId: typeof p.id == "number" || String(p.id).startsWith("q-") ? p.id : parseInt(String(p.id)),
2265
+ questionText: p.questionText,
2266
+ type: p.type,
2267
+ category: p.category,
2268
+ fromLabel: p.fromLabel,
2269
+ toLabel: p.toLabel,
2270
+ numberOfStars: p.numberOfStars,
2271
+ orderDefaultQuestionTemplate: p.orderNumber ?? L + 1,
2272
+ options: p.options || [],
2273
+ answers: p.options && Array.isArray(p.options) && p.options.length > 0 ? p.options.map((W, H) => ({
2274
+ id: 0,
2275
+ text: typeof W == "string" ? W : W?.text || "",
2276
+ order: H
2277
+ })) : p.answers || []
2278
+ }))
2279
+ }
2280
+ };
2281
+ c(x);
2282
+ };
2283
+ return {
2284
+ formData: m,
2285
+ categoryOptions: y,
2286
+ filteredQuestions: C,
2287
+ totalQuestionsCount: m.questions.length,
2288
+ handleTemplateNameChange: h,
2289
+ handleDescriptionChange: _,
2290
+ handleCategoryFilterChange: k,
2291
+ handleEditQuestion: P,
2292
+ handleRemoveQuestion: E,
2293
+ handleAddQuestion: v,
2294
+ handleSave: R,
2295
+ handleCancel: g
2296
+ };
2297
+ }, Ls = ({
2298
+ template: a,
2299
+ initialDraftData: s,
2300
+ onSave: c,
2301
+ onCancel: g,
2302
+ onAddQuestionRedirect: r,
2303
+ onEditQuestionRedirect: l
2304
+ }) => {
2305
+ const {
2306
+ formData: T,
2307
+ categoryOptions: m,
2308
+ filteredQuestions: d,
2309
+ totalQuestionsCount: y,
2310
+ handleTemplateNameChange: C,
2311
+ handleDescriptionChange: h,
2312
+ handleCategoryFilterChange: _,
2313
+ handleEditQuestion: k,
2314
+ handleRemoveQuestion: P,
2315
+ handleAddQuestion: E,
2316
+ handleSave: v,
2317
+ handleCancel: R
2318
+ } = Bs({
2319
+ template: a,
2320
+ initialDraftData: s,
2321
+ onSave: c,
2322
+ onCancel: g,
2323
+ onAddQuestionRedirect: r,
2324
+ onEditQuestionRedirect: l
2325
+ });
2326
+ se(() => {
2327
+ window.scrollTo({ top: 0, behavior: "instant" });
2328
+ const p = document.querySelector("main");
2329
+ p && p.scrollTo({ top: 0, behavior: "instant" });
2330
+ const L = document.documentElement || document.body;
2331
+ L && (L.scrollTop = 0);
2332
+ }, []);
2333
+ const x = (p) => {
2334
+ _(p.target.value);
2335
+ };
2336
+ return /* @__PURE__ */ n(i, { className: t.chooseTemplateCard, children: [
2337
+ /* @__PURE__ */ n(i, { className: t.editTemplateHeaderSection, children: [
2338
+ /* @__PURE__ */ e(b, { variant: "h5", className: t.headerTitle, children: "Edit Template" }),
2339
+ /* @__PURE__ */ n($, { direction: "row", alignItems: "center", spacing: 2, children: [
2340
+ /* @__PURE__ */ e(
2341
+ Y,
2342
+ {
2343
+ onClick: R,
2344
+ className: t.editTemplateCancelBtn,
2345
+ children: "CANCEL"
2346
+ }
2347
+ ),
2348
+ /* @__PURE__ */ e(
2349
+ Y,
2350
+ {
2351
+ variant: "contained",
2352
+ onClick: v,
2353
+ startIcon: /* @__PURE__ */ e(Ve, {}),
2354
+ className: t.editTemplateSaveBtn,
2355
+ disabled: !T.templateName || T.templateName.trim() === "",
2356
+ children: "SAVE CHANGES"
2357
+ }
2358
+ )
2359
+ ] })
2360
+ ] }),
2361
+ /* @__PURE__ */ n(i, { className: t.formFieldBlock, children: [
2362
+ /* @__PURE__ */ n(b, { variant: "subtitle2", className: t.formFieldLabel, children: [
2363
+ "Template Name ",
2364
+ /* @__PURE__ */ e("span", { className: t.requiredAsterisk, children: "*" })
2365
+ ] }),
2366
+ /* @__PURE__ */ e(
2367
+ J,
2368
+ {
2369
+ fullWidth: !0,
2370
+ variant: "outlined",
2371
+ value: T.templateName,
2372
+ onChange: (p) => C(p.target.value),
2373
+ placeholder: "Enter template name",
2374
+ className: t.customTextField
2375
+ }
2376
+ )
2377
+ ] }),
2378
+ /* @__PURE__ */ n(i, { className: t.formFieldBlock, children: [
2379
+ /* @__PURE__ */ e(b, { variant: "subtitle2", className: t.formFieldLabel, children: "Description and instructions of when to use" }),
2380
+ /* @__PURE__ */ e(
2381
+ J,
2382
+ {
2383
+ fullWidth: !0,
2384
+ multiline: !0,
2385
+ rows: 3,
2386
+ variant: "outlined",
2387
+ value: T.description,
2388
+ onChange: (p) => h(p.target.value),
2389
+ placeholder: "Enter description and instructions",
2390
+ className: t.customTextField
2391
+ }
2392
+ )
2393
+ ] }),
2394
+ /* @__PURE__ */ n(i, { className: t.questionsHeaderSection, children: [
2395
+ /* @__PURE__ */ n($, { direction: "row", alignItems: "center", spacing: 0.75, sx: { mb: 1.5 }, children: [
2396
+ /* @__PURE__ */ e(b, { variant: "subtitle1", className: t.questionsTitle, children: "Questions" }),
2397
+ /* @__PURE__ */ e(b, { variant: "subtitle1", className: t.questionsCountNumber, children: y })
2398
+ ] }),
2399
+ /* @__PURE__ */ n($, { direction: "row", alignItems: "center", spacing: 1.5, className: t.filterByRow, children: [
2400
+ /* @__PURE__ */ e(b, { variant: "body2", className: t.filterByLabel, children: "Filter by category" }),
2401
+ /* @__PURE__ */ e(we, { size: "small", className: t.categoryFilterFormControl, children: /* @__PURE__ */ e(
2402
+ xe,
2403
+ {
2404
+ value: T.selectedCategoryFilter,
2405
+ onChange: x,
2406
+ className: t.categorySelectInput,
2407
+ children: m.map((p) => /* @__PURE__ */ e(Fe, { value: p, children: p }, p))
2408
+ }
2409
+ ) })
2410
+ ] })
2411
+ ] }),
2412
+ /* @__PURE__ */ e(
2413
+ Ze,
2414
+ {
2415
+ questions: d,
2416
+ onEditQuestion: k,
2417
+ onRemoveQuestion: P
2418
+ }
2419
+ ),
2420
+ /* @__PURE__ */ e(i, { className: t.addQuestionWrapper, children: /* @__PURE__ */ e(
2421
+ Y,
2422
+ {
2423
+ onClick: E,
2424
+ startIcon: /* @__PURE__ */ e(je, {}),
2425
+ className: t.addQuestionBtn,
2426
+ children: "ADD QUESTION"
2427
+ }
2428
+ ) })
2429
+ ] });
2430
+ }, Js = () => {
2431
+ const a = Ge(), s = Ye((D) => D?.common?.user?.roles), c = $e(), g = G(() => {
2432
+ if (localStorage.getItem("is_returning_from_question") === "true") {
2433
+ const U = localStorage.getItem("create_survey_draft");
2434
+ if (U)
2435
+ try {
2436
+ return JSON.parse(U);
2437
+ } catch {
2438
+ }
2439
+ }
2440
+ return null;
2441
+ }, []);
2442
+ se(() => {
2443
+ const D = setTimeout(() => {
2444
+ localStorage.getItem("is_returning_from_question") === "true" ? localStorage.removeItem("is_returning_from_question") : localStorage.removeItem("create_survey_draft");
2445
+ }, 500);
2446
+ return () => clearTimeout(D);
2447
+ }, []);
2448
+ const {
2449
+ steps: r,
2450
+ activeStep: l,
2451
+ categories: T,
2452
+ selectedCategory: m,
2453
+ selectedTemplateId: d,
2454
+ templates: y,
2455
+ editingTemplate: C,
2456
+ handleSelectCategory: h,
2457
+ handleSelectTemplate: _,
2458
+ handleCreateBlankSurvey: k,
2459
+ handleEditTemplate: P,
2460
+ handleCloseEditTemplate: E,
2461
+ handleSaveEditTemplate: v,
2462
+ handleGoBackToDashboard: R,
2463
+ handlePreviousStep: x,
2464
+ handleNextStep: p,
2465
+ handleGoToStep: L
2466
+ } = $t(g), W = G(() => {
2467
+ if (d === "BLANK") return null;
2468
+ if (d) {
2469
+ const D = y.find((U) => U.id === d);
2470
+ return D || null;
2471
+ }
2472
+ return y.length > 0 ? y[0] : null;
2473
+ }, [y, d]), {
2474
+ formData: H,
2475
+ questionCategories: Z,
2476
+ filteredQuestions: V,
2477
+ totalQuestionsCount: ee,
2478
+ handleTemplateNameChange: X,
2479
+ handleDescriptionChange: le,
2480
+ handleCategoryFilterChange: N,
2481
+ handleRemoveQuestion: S,
2482
+ resetFormDataWithTemplate: u
2483
+ } = Ut(d, W, g), {
2484
+ formData: F,
2485
+ handleTitleChange: o,
2486
+ handleDeadlineChange: w
2487
+ } = Vt(g), {
2488
+ students: A,
2489
+ allFilteredStudents: Q,
2490
+ allStudents: f,
2491
+ totalStudentsCount: q,
2492
+ totalSelectedCount: K,
2493
+ selectedStudentIds: te,
2494
+ filters: ne,
2495
+ gradeOptions: _e,
2496
+ flagOptions: ie,
2497
+ teacherOptions: Be,
2498
+ isAllSelected: Le,
2499
+ isIndeterminate: oe,
2500
+ handleSortChange: Xe,
2501
+ handleSearchChange: et,
2502
+ handleGradeFilterChange: tt,
2503
+ handleFlagFilterChange: nt,
2504
+ handleTeacherFilterChange: at,
2505
+ handlePageChange: st,
2506
+ handleRowsPerPageChange: lt,
2507
+ handleToggleSelectAll: rt,
2508
+ handleToggleStudent: it
2509
+ } = Jt(g), Ce = (D) => {
2510
+ const U = {
2511
+ activeStep: l,
2512
+ selectedCategory: m,
2513
+ selectedTemplateId: d,
2514
+ step2FormData: H,
2515
+ step3FormData: F,
2516
+ selectedStudentIds: te,
2517
+ editingTemplate: C,
2518
+ ...D
2519
+ };
2520
+ localStorage.setItem("create_survey_draft", JSON.stringify(U));
2521
+ }, ot = () => {
2522
+ Ce(), c("/admin/create-survey-question?type=0&from=create-survey");
2523
+ }, ct = (D) => {
2524
+ Ce(), c(`/admin/survey-question-detail/${D}?type=0&from=create-survey`);
2525
+ }, dt = G(() => (f && f.length > 0 ? f : Q || A).filter((U) => te.includes(U.id)), [f, Q, A, te]), ut = async () => {
2526
+ const D = /* @__PURE__ */ new Map();
2527
+ (f && f.length > 0 ? f : Q || A || []).forEach((z) => D.set(z.id, z));
2528
+ const ce = [], de = [], be = [];
2529
+ te.forEach((z) => {
2530
+ const O = D.get(z);
2531
+ if (O)
2532
+ O.schoolLevel === "ES" && O.userId ? (de.push(O.userId), be.push({
2533
+ userId: O.userId,
2534
+ name: O.name,
2535
+ firstName: O.name?.split(" ")?.[0] || "",
2536
+ email: O.email,
2537
+ studentId: O.studentId
2538
+ })) : O.studentId !== void 0 ? ce.push(O.studentId) : typeof z == "number" ? ce.push(z) : O.userId && (de.push(O.userId), be.push({
2539
+ userId: O.userId,
2540
+ name: O.name,
2541
+ firstName: O.name?.split(" ")?.[0] || "",
2542
+ email: O.email,
2543
+ studentId: O.studentId
2544
+ }));
2545
+ else if (typeof z == "number" || !isNaN(Number(z)) && !String(z).includes("-"))
2546
+ ce.push(Number(z));
2547
+ else {
2548
+ const ue = String(z);
2549
+ de.push(ue), be.push({
2550
+ userId: ue,
2551
+ name: `Student ${ue}`,
2552
+ firstName: "Student",
2553
+ email: ""
2554
+ });
2555
+ }
2556
+ });
2557
+ const pt = [
2558
+ {
2559
+ id: d,
2560
+ name: H.templateName,
2561
+ title: H.templateName,
2562
+ description: H.description,
2563
+ numberQuestion: H.questions.length,
2564
+ orderDefaultSurvey: 1,
2565
+ questionTemplates: H.questions.map((z, O) => ({
2566
+ questionId: typeof z.id == "string" && z.id.startsWith("q-") ? 0 : Number(z.id),
2567
+ questionText: z.questionText,
2568
+ type: z.type || "MultipleChoice",
2569
+ orderDefaultQuestionTemplate: z.orderNumber ?? O,
2570
+ answers: z.options && Array.isArray(z.options) ? z.options.map((ue, Ct) => ({
2571
+ id: 0,
2572
+ text: ue,
2573
+ order: Ct
2574
+ })) : z.answers || []
2575
+ }))
2576
+ }
2577
+ ], gt = F.deadline ? Pe(F.deadline, "DD.MM.YYYY hh:mm A").valueOf() : null, _t = {
2578
+ title: F.title,
2579
+ deadline: gt,
2580
+ studentIds: ce,
2581
+ esStudentUserIds: de,
2582
+ studentUserIds: de,
2583
+ esStudents: be,
2584
+ additionalQuestions: [],
2585
+ staffIds: [],
2586
+ summarizeQuestions: [],
2587
+ isAdmin: !0,
2588
+ isDraft: !1,
2589
+ role: Array.isArray(s) ? s.join(",") : s ? String(s) : "Admin",
2590
+ templateQuestions: pt
2591
+ };
2592
+ try {
2593
+ a(re(!0)), await Rt(_t), a(
2594
+ he({
2595
+ type: "success",
2596
+ message: "Publish survey success"
2597
+ })
2598
+ ), R();
2599
+ } catch (z) {
2600
+ console.error("Error publishing survey:", z), a(
2601
+ he({
2602
+ type: "danger",
2603
+ message: z?.response?.data?.title || z?.message || "Failed to publish survey"
2604
+ })
2605
+ );
2606
+ } finally {
2607
+ a(re(!1));
2608
+ }
2609
+ };
2610
+ se(() => {
2611
+ window.scrollTo({ top: 0, behavior: "instant" });
2612
+ const D = document.querySelector("main");
2613
+ D && D.scrollTo({ top: 0, behavior: "instant" });
2614
+ const U = document.documentElement || document.body;
2615
+ U && (U.scrollTop = 0);
2616
+ }, [l, C]);
2617
+ const mt = (D) => {
2618
+ Ce({ editingTemplateFormData: D }), c("/admin/create-survey-question?type=0&from=edit-template");
2619
+ }, ht = (D, U) => {
2620
+ Ce({ editingTemplateFormData: U }), c(`/admin/survey-question-detail/${D}?type=0&from=edit-template`);
2621
+ }, ft = async (D) => {
2622
+ await v(D), (d === D.id || !d) && u(D);
2623
+ };
2624
+ return C ? /* @__PURE__ */ e(i, { className: t.createSurveyPage, children: /* @__PURE__ */ e(i, { className: t.contentBody, children: /* @__PURE__ */ e(
2625
+ Ls,
2626
+ {
2627
+ template: C,
2628
+ initialDraftData: g?.editingTemplateFormData,
2629
+ onSave: ft,
2630
+ onCancel: E,
2631
+ onAddQuestionRedirect: mt,
2632
+ onEditQuestionRedirect: ht
2633
+ }
2634
+ ) }) }) : /* @__PURE__ */ n(i, { className: t.createSurveyPage, children: [
2635
+ /* @__PURE__ */ e(i, { className: t.headerTopBar, children: /* @__PURE__ */ e(
2636
+ ds,
2637
+ {
2638
+ steps: r,
2639
+ activeStep: l,
2640
+ onBack: R
2641
+ }
2642
+ ) }),
2643
+ /* @__PURE__ */ n(i, { className: t.contentBody, children: [
2644
+ l === 0 && /* @__PURE__ */ e(
2645
+ ps,
2646
+ {
2647
+ categories: T,
2648
+ selectedCategory: m,
2649
+ templates: y,
2650
+ selectedTemplateId: d,
2651
+ currentStepNumber: l + 1,
2652
+ totalSteps: r.length,
2653
+ onSelectCategory: h,
2654
+ onSelectTemplate: _,
2655
+ onCreateBlank: k,
2656
+ onEditTemplate: P,
2657
+ onPrevious: x,
2658
+ onNext: p
2659
+ }
2660
+ ),
2661
+ l === 1 && /* @__PURE__ */ e(
2662
+ _s,
2663
+ {
2664
+ formData: H,
2665
+ questionCategories: Z,
2666
+ filteredQuestions: V,
2667
+ totalQuestionsCount: ee,
2668
+ currentStepNumber: l + 1,
2669
+ totalSteps: r.length,
2670
+ onTemplateNameChange: X,
2671
+ onDescriptionChange: le,
2672
+ onCategoryFilterChange: N,
2673
+ onEditQuestion: ct,
2674
+ onRemoveQuestion: S,
2675
+ onAddQuestion: ot,
2676
+ onPrevious: x,
2677
+ onNext: p
2678
+ }
2679
+ ),
2680
+ l === 2 && /* @__PURE__ */ e(
2681
+ Cs,
2682
+ {
2683
+ formData: F,
2684
+ currentStepNumber: l + 1,
2685
+ totalSteps: r.length,
2686
+ onTitleChange: o,
2687
+ onDeadlineChange: w,
2688
+ onPrevious: x,
2689
+ onNext: p
2690
+ }
2691
+ ),
2692
+ l === 3 && /* @__PURE__ */ e(
2693
+ Ns,
2694
+ {
2695
+ students: A,
2696
+ totalStudentsCount: q,
2697
+ totalSelectedCount: K,
2698
+ selectedStudentIds: te,
2699
+ filters: ne,
2700
+ gradeOptions: _e,
2701
+ flagOptions: ie,
2702
+ teacherOptions: Be,
2703
+ page: ne.page,
2704
+ rowsPerPage: ne.rowsPerPage,
2705
+ isAllSelected: Le,
2706
+ isIndeterminate: oe,
2707
+ sortBy: ne.sortBy,
2708
+ sortOrder: ne.sortOrder,
2709
+ onSortChange: Xe,
2710
+ currentStepNumber: l + 1,
2711
+ totalSteps: r.length,
2712
+ onSearchChange: et,
2713
+ onGradeChange: tt,
2714
+ onFlagChange: nt,
2715
+ onTeacherChange: at,
2716
+ onPageChange: st,
2717
+ onRowsPerPageChange: lt,
2718
+ onToggleSelectAll: rt,
2719
+ onToggleStudent: it,
2720
+ onPrevious: x,
2721
+ onNext: p
2722
+ }
2723
+ ),
2724
+ l === 4 && /* @__PURE__ */ e(
2725
+ As,
2726
+ {
2727
+ templateFormData: H,
2728
+ surveyFormData: F,
2729
+ selectedStudents: dt,
2730
+ currentStepNumber: l + 1,
2731
+ totalSteps: r.length,
2732
+ onEditTemplateDetails: () => L(1),
2733
+ onEditSurveyDetails: () => L(2),
2734
+ onEditSelectedStudents: () => L(3),
2735
+ onPrevious: x,
2736
+ onPublish: ut
2737
+ }
2738
+ )
2739
+ ] })
2740
+ ] });
2741
+ };
2742
+ export {
2743
+ Js as default
2744
+ };