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