@cuemath/leap 2.8.62-aa0 → 2.8.62-aa1
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.
- package/dist/features/chapters/lpar-chapter/block-section/sheet-item/rewards-n-actions/student-actions/student-actions.js +35 -36
- package/dist/features/chapters/lpar-chapter/block-section/sheet-item/rewards-n-actions/student-actions/student-actions.js.map +1 -1
- package/dist/features/chapters/lpar-chapter/block-section/sheet-item/rewards-n-actions/teacher-actions/teacher-actions.js +17 -18
- package/dist/features/chapters/lpar-chapter/block-section/sheet-item/rewards-n-actions/teacher-actions/teacher-actions.js.map +1 -1
- package/dist/features/sheets/lessons-list/lesson-item/lesson-item-cta-info.js +48 -49
- package/dist/features/sheets/lessons-list/lesson-item/lesson-item-cta-info.js.map +1 -1
- package/dist/features/sheets/resources-list/resource-item/resource-item.js +90 -91
- package/dist/features/sheets/resources-list/resource-item/resource-item.js.map +1 -1
- package/dist/features/sheets/sheets-list/sheet-item/reward-n-actions/student-actions/student-actions.js +53 -54
- package/dist/features/sheets/sheets-list/sheet-item/reward-n-actions/student-actions/student-actions.js.map +1 -1
- package/dist/features/sheets/sheets-list/sheet-item/reward-n-actions/teacher-actions/teacher-actions.js +41 -42
- package/dist/features/sheets/sheets-list/sheet-item/reward-n-actions/teacher-actions/teacher-actions.js.map +1 -1
- package/dist/features/sheets/utils/is-v3-worksheet.js +5 -10
- package/dist/features/sheets/utils/is-v3-worksheet.js.map +1 -1
- package/dist/index.d.ts +8 -12
- package/dist/index.js +73 -75
- package/package.json +1 -1
@@ -1,43 +1,42 @@
|
|
1
1
|
import { jsxs as u, jsx as e, Fragment as B } from "react/jsx-runtime";
|
2
2
|
import { useMemo as f, useCallback as $ } from "react";
|
3
|
-
import { getRewardsBadgeUrl as
|
4
|
-
import
|
5
|
-
import q from "../../../../../../ui/context
|
6
|
-
import
|
7
|
-
import
|
8
|
-
import
|
9
|
-
import K from "../../context-menu-helper/
|
10
|
-
import Q from "
|
11
|
-
import {
|
12
|
-
|
13
|
-
const we = ({ sheet: n, isLastSheet: O, onStartOrResume: m, onReview: l }) => {
|
3
|
+
import { getRewardsBadgeUrl as G } from "../../../../../../sheets/sheets-list/sheet-item/reward-n-actions/reward-n-actions-utils.js";
|
4
|
+
import Z from "../../../../../../ui/context-menu/context-menu.js";
|
5
|
+
import { useUIContext as q } from "../../../../../../ui/context/context.js";
|
6
|
+
import P from "../../../../../../ui/layout/flex-view.js";
|
7
|
+
import { checkIfPPTNodeType as H } from "../../../../utils/index.js";
|
8
|
+
import J from "../../context-menu-helper/menu-element.js";
|
9
|
+
import K from "../../context-menu-helper/target-element.js";
|
10
|
+
import { StyledButton as M, RewardImage as Q, RewardAccuracy as Y } from "../reward-n-actions-styled.js";
|
11
|
+
import { getPrimaryCtaLabel as ee } from "./student-actions-utils.js";
|
12
|
+
const ue = ({ sheet: n, isLastSheet: N, onStartOrResume: m, onReview: l }) => {
|
14
13
|
var A;
|
15
|
-
const { onEvent: w } =
|
16
|
-
permissions:
|
14
|
+
const { onEvent: w } = q(), {
|
15
|
+
permissions: O,
|
17
16
|
can_start: o,
|
18
17
|
can_resume: c,
|
19
18
|
can_review: i,
|
20
|
-
can_reattempt:
|
19
|
+
can_reattempt: S,
|
21
20
|
accuracy: y,
|
22
21
|
can_redo: j,
|
23
22
|
rewards: a,
|
24
23
|
attempt_state: _,
|
25
24
|
is_subjective: F,
|
26
|
-
is_turing:
|
25
|
+
is_turing: V,
|
27
26
|
completed_on: g,
|
28
27
|
node_type: d,
|
29
28
|
ceremony_completed_on_ts: R,
|
30
|
-
can_reattempt_block:
|
29
|
+
can_reattempt_block: W,
|
31
30
|
node_id: b,
|
32
31
|
id: C
|
33
|
-
} = n, { access:
|
32
|
+
} = n, { access: v } = O.can_do, t = H(d), r = V || t, h = a && G(a), U = a && ((A = a[0]) == null ? void 0 : A.performance), z = !o && !c && typeof y == "number" && !(F && _ && _ === "WAIT_FOR_REVIEW"), k = W && !g, I = o || c || j || S, L = v && I || !r && k, p = !!(i && g && !R), s = f(
|
34
33
|
() => ({
|
35
34
|
user_node_id: C,
|
36
35
|
nodeId: b
|
37
36
|
}),
|
38
37
|
[b, C]
|
39
38
|
), T = f(
|
40
|
-
() =>
|
39
|
+
() => ee({
|
41
40
|
canStart: o,
|
42
41
|
canResume: c,
|
43
42
|
isInstructionNodeType: r,
|
@@ -48,15 +47,15 @@ const we = ({ sheet: n, isLastSheet: O, onStartOrResume: m, onReview: l }) => {
|
|
48
47
|
), x = $(() => {
|
49
48
|
if (typeof m != "function")
|
50
49
|
throw new Error("onStartOrResume is not a function");
|
51
|
-
m(n
|
50
|
+
m(n);
|
52
51
|
}, [m, n]), E = $(() => {
|
53
52
|
if (typeof l != "function")
|
54
53
|
throw new Error("onReview is not a function");
|
55
54
|
w("clicked", {
|
56
55
|
cta: t ? "View" : "Review sheet",
|
57
56
|
...s
|
58
|
-
}), l(n
|
59
|
-
}, [s, t, l, n, w]),
|
57
|
+
}), l(n);
|
58
|
+
}, [s, t, l, n, w]), X = r ? !!R : i, D = f(
|
60
59
|
() => [
|
61
60
|
{
|
62
61
|
key: "review-sheet",
|
@@ -67,9 +66,9 @@ const we = ({ sheet: n, isLastSheet: O, onStartOrResume: m, onReview: l }) => {
|
|
67
66
|
],
|
68
67
|
[i, E, t]
|
69
68
|
);
|
70
|
-
return t ? null : /* @__PURE__ */ u(
|
71
|
-
|
72
|
-
|
69
|
+
return t ? null : /* @__PURE__ */ u(P, { $flexDirection: "row", $alignItems: "center", $flexGap: 8, children: [
|
70
|
+
v && r ? /* @__PURE__ */ e(B, { children: (I || p) && /* @__PURE__ */ e(
|
71
|
+
M,
|
73
72
|
{
|
74
73
|
renderAs: "primary",
|
75
74
|
size: "small",
|
@@ -79,36 +78,36 @@ const we = ({ sheet: n, isLastSheet: O, onStartOrResume: m, onReview: l }) => {
|
|
79
78
|
analyticsProps: s
|
80
79
|
}
|
81
80
|
) }) : /* @__PURE__ */ u(B, { children: [
|
82
|
-
|
83
|
-
|
84
|
-
/* @__PURE__ */ e(
|
81
|
+
z && /* @__PURE__ */ u(P, { $justifyContent: "center", $alignItems: "center", children: [
|
82
|
+
h && /* @__PURE__ */ e(Q, { src: h, alt: "Reward" }),
|
83
|
+
/* @__PURE__ */ e(Y, { $renderAs: "eyebrow2", $align: "center", children: U || `${Math.ceil(y)}%` })
|
85
84
|
] }),
|
86
|
-
|
87
|
-
|
85
|
+
L && /* @__PURE__ */ e(
|
86
|
+
M,
|
88
87
|
{
|
89
88
|
renderAs: "primary",
|
90
89
|
size: "small",
|
91
90
|
widthX: 6,
|
92
91
|
label: T,
|
93
|
-
disabled:
|
92
|
+
disabled: k,
|
94
93
|
onClick: x,
|
95
94
|
analyticsProps: s
|
96
95
|
}
|
97
96
|
)
|
98
97
|
] }),
|
99
|
-
|
100
|
-
|
98
|
+
X && /* @__PURE__ */ e(
|
99
|
+
Z,
|
101
100
|
{
|
102
|
-
targetElement: /* @__PURE__ */ e(
|
103
|
-
menuElement: /* @__PURE__ */ e(
|
101
|
+
targetElement: /* @__PURE__ */ e(K, {}),
|
102
|
+
menuElement: /* @__PURE__ */ e(J, { options: D }),
|
104
103
|
menuOffset: 5,
|
105
104
|
menuZIndex: 1,
|
106
|
-
placeTop:
|
105
|
+
placeTop: N
|
107
106
|
}
|
108
107
|
)
|
109
108
|
] });
|
110
109
|
};
|
111
110
|
export {
|
112
|
-
|
111
|
+
ue as default
|
113
112
|
};
|
114
113
|
//# sourceMappingURL=student-actions.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"student-actions.js","sources":["../../../../../../../../src/features/chapters/lpar-chapter/block-section/sheet-item/rewards-n-actions/student-actions/student-actions.tsx"],"sourcesContent":["import type { ILPARSheetCallbacks, TLPARSheetData } from '../../sheet-item-type';\n\nimport { useCallback, type FC, useMemo } from 'react';\n\nimport { getRewardsBadgeUrl } from '../../../../../../sheets/sheets-list/sheet-item/reward-n-actions/reward-n-actions-utils';\nimport
|
1
|
+
{"version":3,"file":"student-actions.js","sources":["../../../../../../../../src/features/chapters/lpar-chapter/block-section/sheet-item/rewards-n-actions/student-actions/student-actions.tsx"],"sourcesContent":["import type { ILPARSheetCallbacks, TLPARSheetData } from '../../sheet-item-type';\n\nimport { useCallback, type FC, useMemo } from 'react';\n\nimport { getRewardsBadgeUrl } from '../../../../../../sheets/sheets-list/sheet-item/reward-n-actions/reward-n-actions-utils';\nimport ContextMenu from '../../../../../../ui/context-menu/context-menu';\nimport { useUIContext } from '../../../../../../ui/context/context';\nimport FlexView from '../../../../../../ui/layout/flex-view';\nimport { checkIfPPTNodeType } from '../../../../utils';\nimport ContextMenuElement from '../../context-menu-helper/menu-element';\nimport ContextMenuTargetElement from '../../context-menu-helper/target-element';\nimport { RewardAccuracy, RewardImage, StyledButton } from '../reward-n-actions-styled';\nimport { getPrimaryCtaLabel } from './student-actions-utils';\n\ninterface IStudentActions extends ILPARSheetCallbacks {\n sheet: TLPARSheetData;\n isLastSheet: boolean;\n isClassOngoing: boolean;\n}\n\nconst StudentActions: FC<IStudentActions> = ({ sheet, isLastSheet, onStartOrResume, onReview }) => {\n const { onEvent: trackEvent } = useUIContext();\n\n const {\n permissions,\n can_start: canStart,\n can_resume: canResume,\n can_review: canReview,\n can_reattempt: canReattempt,\n accuracy,\n can_redo: canRedo,\n rewards,\n attempt_state: attemptState,\n is_subjective: isSubjective,\n is_turing: isTuring,\n completed_on: completedOn,\n node_type: nodeType,\n ceremony_completed_on_ts: ceremonyCompletedOnTS,\n can_reattempt_block: canReattemptBlock,\n node_id: nodeId,\n id: userNodeId,\n } = sheet;\n const { access } = permissions.can_do;\n const isPPTNodeType = checkIfPPTNodeType(nodeType);\n const isInstructionNodeType = isTuring || isPPTNodeType;\n const rewardsBadgeUrl = rewards && getRewardsBadgeUrl(rewards);\n\n const performance = rewards && rewards[0]?.performance;\n const isWaitingForReview = isSubjective && attemptState && attemptState === 'WAIT_FOR_REVIEW';\n const renderAccuracy =\n !canStart && !canResume && typeof accuracy === 'number' && !isWaitingForReview;\n const reattemptBlocked = canReattemptBlock && !completedOn;\n const canStartOrResume = canStart || canResume || canRedo || canReattempt;\n const renderAccuracyNPrimaryCta =\n (access && canStartOrResume) || (!isInstructionNodeType && reattemptBlocked);\n const reviewInstructionNodeType = Boolean(canReview && completedOn && !ceremonyCompletedOnTS);\n\n const analyticsProps = useMemo(\n () => ({\n user_node_id: userNodeId,\n nodeId: nodeId,\n }),\n [nodeId, userNodeId],\n );\n\n const primaryCtaLabel = useMemo(\n () =>\n getPrimaryCtaLabel({\n canStart,\n canResume,\n isInstructionNodeType,\n reviewInstructionNodeType,\n nodeType,\n }),\n [canResume, canStart, isInstructionNodeType, nodeType, reviewInstructionNodeType],\n );\n\n const handleOnActionClick = useCallback(() => {\n if (typeof onStartOrResume !== 'function') {\n throw new Error(`onStartOrResume is not a function`);\n }\n\n onStartOrResume(sheet);\n }, [onStartOrResume, sheet]);\n\n const handleOnReview = useCallback(() => {\n if (typeof onReview !== 'function') {\n throw new Error(`onReview is not a function`);\n }\n\n trackEvent('clicked', {\n cta: isPPTNodeType ? 'View' : 'Review sheet',\n ...analyticsProps,\n });\n\n onReview(sheet);\n }, [analyticsProps, isPPTNodeType, onReview, sheet, trackEvent]);\n\n const isMenuVisible = isInstructionNodeType ? Boolean(ceremonyCompletedOnTS) : canReview;\n const options = useMemo(\n () => [\n {\n key: 'review-sheet',\n label: isPPTNodeType ? 'View' : 'Review sheet',\n visible: Boolean(canReview),\n onClick: handleOnReview,\n },\n ],\n [canReview, handleOnReview, isPPTNodeType],\n );\n\n if (isPPTNodeType) return null;\n\n return (\n <FlexView $flexDirection=\"row\" $alignItems=\"center\" $flexGap={8}>\n {access && isInstructionNodeType ? (\n <>\n {(canStartOrResume || reviewInstructionNodeType) && (\n <StyledButton\n renderAs=\"primary\"\n size=\"small\"\n widthX={6}\n onClick={handleOnActionClick}\n label={primaryCtaLabel}\n analyticsProps={analyticsProps}\n />\n )}\n </>\n ) : (\n <>\n {renderAccuracy && (\n <FlexView $justifyContent=\"center\" $alignItems=\"center\">\n {rewardsBadgeUrl && <RewardImage src={rewardsBadgeUrl} alt=\"Reward\" />}\n <RewardAccuracy $renderAs=\"eyebrow2\" $align=\"center\">\n {performance || `${Math.ceil(accuracy)}%`}\n </RewardAccuracy>\n </FlexView>\n )}\n\n {renderAccuracyNPrimaryCta && (\n <StyledButton\n renderAs=\"primary\"\n size=\"small\"\n widthX={6}\n label={primaryCtaLabel}\n disabled={reattemptBlocked}\n onClick={handleOnActionClick}\n analyticsProps={analyticsProps}\n />\n )}\n </>\n )}\n\n {isMenuVisible && (\n <ContextMenu\n targetElement={<ContextMenuTargetElement />}\n menuElement={<ContextMenuElement options={options} />}\n menuOffset={5}\n menuZIndex={1}\n placeTop={isLastSheet}\n />\n )}\n </FlexView>\n );\n};\n\nexport default StudentActions;\n"],"names":["StudentActions","sheet","isLastSheet","onStartOrResume","onReview","trackEvent","useUIContext","permissions","canStart","canResume","canReview","canReattempt","accuracy","canRedo","rewards","attemptState","isSubjective","isTuring","completedOn","nodeType","ceremonyCompletedOnTS","canReattemptBlock","nodeId","userNodeId","access","isPPTNodeType","checkIfPPTNodeType","isInstructionNodeType","rewardsBadgeUrl","getRewardsBadgeUrl","performance","_a","renderAccuracy","reattemptBlocked","canStartOrResume","renderAccuracyNPrimaryCta","reviewInstructionNodeType","analyticsProps","useMemo","primaryCtaLabel","getPrimaryCtaLabel","handleOnActionClick","useCallback","handleOnReview","isMenuVisible","options","FlexView","jsx","Fragment","StyledButton","jsxs","RewardImage","RewardAccuracy","ContextMenu","ContextMenuTargetElement","ContextMenuElement"],"mappings":";;;;;;;;;;;AAoBA,MAAMA,KAAsC,CAAC,EAAE,OAAAC,GAAO,aAAAC,GAAa,iBAAAC,GAAiB,UAAAC,QAAe;;AACjG,QAAM,EAAE,SAASC,EAAW,IAAIC,EAAa,GAEvC;AAAA,IACJ,aAAAC;AAAA,IACA,WAAWC;AAAA,IACX,YAAYC;AAAA,IACZ,Y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,gBAAAY;AAAA,QAACE;AAAA,QAAA;AAAA,UACC,UAAS;AAAA,UACT,MAAK;AAAA,UACL,QAAQ;AAAA,UACR,OAAOV;AAAA,UACP,UAAUN;AAAA,UACV,SAASQ;AAAA,UACT,gBAAAJ;AAAA,QAAA;AAAA,MACF;AAAA,IAAA,GAEJ;AAAA,IAGDO,KACC,gBAAAG;AAAA,MAACM;AAAA,MAAA;AAAA,QACC,iCAAgBC,GAAyB,EAAA;AAAA,QACzC,aAAc,gBAAAP,EAAAQ,GAAA,EAAmB,SAAAV,EAAkB,CAAA;AAAA,QACnD,YAAY;AAAA,QACZ,YAAY;AAAA,QACZ,UAAU3C;AAAA,MAAA;AAAA,IACZ;AAAA,EAEJ,EAAA,CAAA;AAEJ;"}
|
@@ -1,24 +1,23 @@
|
|
1
1
|
import { jsx as e, jsxs as x } from "react/jsx-runtime";
|
2
2
|
import { useMemo as E, useCallback as T } from "react";
|
3
|
-
import { NODE_TYPE as
|
3
|
+
import { NODE_TYPE as V } from "../../../../../../sheets/constants/sheet.js";
|
4
4
|
import { getRewardsBadgeUrl as G } from "../../../../../../sheets/sheets-list/sheet-item/reward-n-actions/reward-n-actions-utils.js";
|
5
|
-
import { isV3Worksheet as H } from "../../../../../../sheets/utils/is-v3-worksheet.js";
|
6
5
|
import R from "../../../../../../ui/buttons/button/button.js";
|
7
|
-
import
|
8
|
-
import { useUIContext as
|
6
|
+
import H from "../../../../../../ui/context-menu/context-menu.js";
|
7
|
+
import { useUIContext as j } from "../../../../../../ui/context/context.js";
|
9
8
|
import u from "../../../../../../ui/layout/flex-view.js";
|
10
|
-
import { checkIfIsHiddenUnlocked as
|
9
|
+
import { checkIfIsHiddenUnlocked as z, checkIfPPTNodeType as L } from "../../../../utils/index.js";
|
11
10
|
import F from "../../context-menu-helper/menu-element.js";
|
12
|
-
import
|
13
|
-
import { StyledEyeIcon as $, RewardImage as
|
14
|
-
const
|
11
|
+
import W from "../../context-menu-helper/target-element.js";
|
12
|
+
import { StyledEyeIcon as $, RewardImage as Y, RewardAccuracy as Z } from "../reward-n-actions-styled.js";
|
13
|
+
const le = ({
|
15
14
|
isLastSheet: M,
|
16
15
|
isClassOngoing: N,
|
17
16
|
sheet: n,
|
18
17
|
...v
|
19
18
|
}) => {
|
20
19
|
var h;
|
21
|
-
const { onView: s, onMenuActionAttempt: m } = v, { onEvent: r } =
|
20
|
+
const { onView: s, onMenuActionAttempt: m } = v, { onEvent: r } = j(), {
|
22
21
|
accuracy: f,
|
23
22
|
can_teacher_review: k,
|
24
23
|
id: d,
|
@@ -29,7 +28,7 @@ const se = ({
|
|
29
28
|
completed_on: y,
|
30
29
|
can_reattempt_block: _,
|
31
30
|
node_id: g
|
32
|
-
} = n, { code: p } = P.can_do, I = i ===
|
31
|
+
} = n, { code: p } = P.can_do, I = i === V.HIDDEN_BASIC, S = c && ((h = c[0]) == null ? void 0 : h.performance), A = c && G(c), C = L(i), B = k && typeof f == "number" && !C, U = d && !I, b = C && N && p === "IN_PROGRESS", O = !!(p && z(p)), t = E(
|
33
32
|
() => ({
|
34
33
|
node_id: g,
|
35
34
|
user_node_id: d
|
@@ -45,7 +44,7 @@ const se = ({
|
|
45
44
|
m(o, n);
|
46
45
|
},
|
47
46
|
[t, m, n, r]
|
48
|
-
),
|
47
|
+
), D = E(
|
49
48
|
() => [
|
50
49
|
{
|
51
50
|
key: "change-location",
|
@@ -71,7 +70,7 @@ const se = ({
|
|
71
70
|
(o) => {
|
72
71
|
if (o && r(o, t), typeof s != "function")
|
73
72
|
throw new Error("onView must be a function");
|
74
|
-
s(n
|
73
|
+
s(n);
|
75
74
|
},
|
76
75
|
[t, s, n, r]
|
77
76
|
);
|
@@ -86,8 +85,8 @@ const se = ({
|
|
86
85
|
}
|
87
86
|
) }) : /* @__PURE__ */ x(u, { $flexGap: 8, $flexDirection: "row", $alignItems: "center", children: [
|
88
87
|
B && /* @__PURE__ */ x(u, { $justifyContent: "center", $alignItems: "center", children: [
|
89
|
-
A && /* @__PURE__ */ e(
|
90
|
-
/* @__PURE__ */ e(
|
88
|
+
A && /* @__PURE__ */ e(Y, { src: A, alt: "Reward" }),
|
89
|
+
/* @__PURE__ */ e(Z, { $renderAs: "eyebrow2", $align: "center", children: S || `${Math.ceil(f)}%` })
|
91
90
|
] }),
|
92
91
|
k && b && /* @__PURE__ */ e(
|
93
92
|
R,
|
@@ -101,10 +100,10 @@ const se = ({
|
|
101
100
|
),
|
102
101
|
!b && /* @__PURE__ */ e($, { onClick: () => a("clicked") }),
|
103
102
|
U && /* @__PURE__ */ e(
|
104
|
-
|
103
|
+
H,
|
105
104
|
{
|
106
|
-
targetElement: /* @__PURE__ */ e(
|
107
|
-
menuElement: /* @__PURE__ */ e(F, { options:
|
105
|
+
targetElement: /* @__PURE__ */ e(W, {}),
|
106
|
+
menuElement: /* @__PURE__ */ e(F, { options: D }),
|
108
107
|
menuOffset: 5,
|
109
108
|
menuZIndex: 1,
|
110
109
|
placeTop: M
|
@@ -113,6 +112,6 @@ const se = ({
|
|
113
112
|
] });
|
114
113
|
};
|
115
114
|
export {
|
116
|
-
|
115
|
+
le as default
|
117
116
|
};
|
118
117
|
//# sourceMappingURL=teacher-actions.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"teacher-actions.js","sources":["../../../../../../../../src/features/chapters/lpar-chapter/block-section/sheet-item/rewards-n-actions/teacher-actions/teacher-actions.tsx"],"sourcesContent":["import type { ILPARSheetCallbacks, TLPARSheetData } from '../../sheet-item-type';\n\nimport { useCallback, type FC, useMemo } from 'react';\n\nimport { NODE_TYPE } from '../../../../../../sheets/constants/sheet';\nimport { getRewardsBadgeUrl } from '../../../../../../sheets/sheets-list/sheet-item/reward-n-actions/reward-n-actions-utils';\nimport
|
1
|
+
{"version":3,"file":"teacher-actions.js","sources":["../../../../../../../../src/features/chapters/lpar-chapter/block-section/sheet-item/rewards-n-actions/teacher-actions/teacher-actions.tsx"],"sourcesContent":["import type { ILPARSheetCallbacks, TLPARSheetData } from '../../sheet-item-type';\n\nimport { useCallback, type FC, useMemo } from 'react';\n\nimport { NODE_TYPE } from '../../../../../../sheets/constants/sheet';\nimport { getRewardsBadgeUrl } from '../../../../../../sheets/sheets-list/sheet-item/reward-n-actions/reward-n-actions-utils';\nimport Button from '../../../../../../ui/buttons/button/button';\nimport ContextMenu from '../../../../../../ui/context-menu/context-menu';\nimport { useUIContext } from '../../../../../../ui/context/context';\nimport FlexView from '../../../../../../ui/layout/flex-view';\nimport { checkIfIsHiddenUnlocked, checkIfPPTNodeType } from '../../../../utils';\nimport ContextMenuElement from '../../context-menu-helper/menu-element';\nimport ContextMenuTargetElement from '../../context-menu-helper/target-element';\nimport { RewardAccuracy, RewardImage, StyledEyeIcon } from '../reward-n-actions-styled';\n\nexport interface ITeacherActions extends ILPARSheetCallbacks {\n sheet: TLPARSheetData;\n isClassOngoing: boolean;\n isLastSheet: boolean;\n}\n\nconst TeacherActions: FC<ITeacherActions> = ({\n isLastSheet,\n isClassOngoing,\n sheet,\n ...restTeacherActionsProps\n}) => {\n const { onView, onMenuActionAttempt } = restTeacherActionsProps;\n\n const { onEvent: trackEvent } = useUIContext();\n\n const {\n accuracy,\n can_teacher_review: canTeacherReview,\n id: userNodeId,\n node_type: nodeType,\n permissions,\n rewards,\n is_turing: isTuring,\n completed_on: completedOn,\n can_reattempt_block: canReattemptBlock,\n node_id: nodeId,\n } = sheet;\n const { code } = permissions.can_do;\n const isHiddenNode = nodeType === NODE_TYPE.HIDDEN_BASIC;\n const performance = rewards && rewards[0]?.performance;\n const rewardsBadgeUrl = rewards && getRewardsBadgeUrl(rewards);\n const isPPTNodeType = checkIfPPTNodeType(nodeType);\n const renderAccuracy = canTeacherReview && typeof accuracy === 'number' && !isPPTNodeType;\n const isMenuVisible = userNodeId && !isHiddenNode;\n const pptNodeTypeSheetInProgress = isPPTNodeType && isClassOngoing && code === 'IN_PROGRESS';\n const isHiddenUnlocked = Boolean(code && checkIfIsHiddenUnlocked(code));\n\n const analyticsProps = useMemo(\n () => ({\n node_id: nodeId,\n user_node_id: userNodeId,\n }),\n [nodeId, userNodeId],\n );\n\n const handleOnMenuActionAttempt = useCallback(\n (action: string) => {\n trackEvent('clicked', {\n cta: action,\n ...analyticsProps,\n });\n\n if (typeof onMenuActionAttempt !== 'function') {\n throw new Error('onMenuActionAttempt must be a function');\n }\n\n onMenuActionAttempt(action, sheet);\n },\n [analyticsProps, onMenuActionAttempt, sheet, trackEvent],\n );\n\n const options = useMemo(\n () => [\n {\n key: 'change-location',\n label: 'Change Location',\n visible: true,\n onClick: () => handleOnMenuActionAttempt('change_attempt_location'),\n },\n {\n key: 'turing-option',\n label: completedOn && nodeType !== 'TURING_BASIC' ? 'Student Work Url' : 'Activity Link',\n visible: isTuring,\n onClick: () => handleOnMenuActionAttempt('turing_attempt'),\n },\n {\n key: 'allow-reattempt',\n label: 'Allow Reattempt',\n visible: canReattemptBlock,\n onClick: () => handleOnMenuActionAttempt('allow_reattempt'),\n },\n ],\n [canReattemptBlock, completedOn, isTuring, nodeType, handleOnMenuActionAttempt],\n );\n\n const handleOnView = useCallback(\n (action?: string) => {\n if (action) {\n trackEvent(action, analyticsProps);\n }\n\n if (typeof onView !== 'function') {\n throw new Error('onView must be a function');\n }\n\n onView(sheet);\n },\n [analyticsProps, onView, sheet, trackEvent],\n );\n\n if (isHiddenNode) {\n return (\n <FlexView $flexGap={8} $flexDirection=\"row\" $alignItems=\"center\">\n {isHiddenUnlocked ? (\n <StyledEyeIcon onClick={() => handleOnView('clicked')} />\n ) : (\n <Button\n renderAs=\"primary\"\n size=\"small\"\n label=\"Start\"\n onClick={handleOnView}\n analyticsProps={analyticsProps}\n />\n )}\n </FlexView>\n );\n }\n\n return (\n <FlexView $flexGap={8} $flexDirection=\"row\" $alignItems=\"center\">\n {renderAccuracy && (\n <FlexView $justifyContent=\"center\" $alignItems=\"center\">\n {rewardsBadgeUrl && <RewardImage src={rewardsBadgeUrl} alt=\"Reward\" />}\n <RewardAccuracy $renderAs=\"eyebrow2\" $align=\"center\">\n {performance || `${Math.ceil(accuracy)}%`}\n </RewardAccuracy>\n </FlexView>\n )}\n\n {canTeacherReview && pptNodeTypeSheetInProgress && (\n <Button\n renderAs=\"primary\"\n size=\"small\"\n label=\"Resume\"\n onClick={handleOnView}\n analyticsProps={analyticsProps}\n />\n )}\n\n {!pptNodeTypeSheetInProgress && <StyledEyeIcon onClick={() => handleOnView('clicked')} />}\n\n {isMenuVisible && (\n <ContextMenu\n targetElement={<ContextMenuTargetElement />}\n menuElement={<ContextMenuElement options={options} />}\n menuOffset={5}\n menuZIndex={1}\n placeTop={isLastSheet}\n />\n )}\n </FlexView>\n );\n};\n\nexport default TeacherActions;\n"],"names":["TeacherActions","isLastSheet","isClassOngoing","sheet","restTeacherActionsProps","onView","onMenuActionAttempt","trackEvent","useUIContext","accuracy","canTeacherReview","userNodeId","nodeType","permissions","rewards","isTuring","completedOn","canReattemptBlock","nodeId","code","isHiddenNode","NODE_TYPE","performance","_a","rewardsBadgeUrl","getRewardsBadgeUrl","isPPTNodeType","checkIfPPTNodeType","renderAccuracy","isMenuVisible","pptNodeTypeSheetInProgress","isHiddenUnlocked","checkIfIsHiddenUnlocked","analyticsProps","useMemo","handleOnMenuActionAttempt","useCallback","action","options","handleOnView","FlexView","jsx","StyledEyeIcon","Button","jsxs","RewardImage","RewardAccuracy","ContextMenu","ContextMenuTargetElement","ContextMenuElement"],"mappings":";;;;;;;;;;;;AAqBA,MAAMA,KAAsC,CAAC;AAAA,EAC3C,aAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,OAAAC;AAAA,EACA,GAAGC;AACL,MAAM;;AACE,QAAA,EAAE,QAAAC,GAAQ,qBAAAC,EAAwB,IAAAF,GAElC,EAAE,SAASG,EAAW,IAAIC,EAAa,GAEvC;AAAA,IACJ,UAAAC;AAAA,IACA,oBAAoBC;AAAA,IACpB,IAAIC;AAAA,IACJ,WAAWC;AAAA,IACX,aAAAC;AAAA,IACA,SAAAC;AAAA,IACA,WAAWC;AAAA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AAAC,GAAA,EAAc,SAAS,MAAMH,EAAa,SAAS,GAAG;AAAA,IAEtFV,KACC,gBAAAY;AAAA,MAACM;AAAA,MAAA;AAAA,QACC,iCAAgBC,GAAyB,EAAA;AAAA,QACzC,aAAc,gBAAAP,EAAAQ,GAAA,EAAmB,SAAAX,EAAkB,CAAA;AAAA,QACnD,YAAY;AAAA,QACZ,YAAY;AAAA,QACZ,UAAUrC;AAAA,MAAA;AAAA,IACZ;AAAA,EAEJ,EAAA,CAAA;AAEJ;"}
|
@@ -1,20 +1,19 @@
|
|
1
|
-
import { jsx as
|
2
|
-
import { memo as
|
1
|
+
import { jsx as m } from "react/jsx-runtime";
|
2
|
+
import { memo as G, useMemo as O, useCallback as $, Fragment as M } from "react";
|
3
3
|
import B from "../../../../assets/line-icons/icons/bulb2.js";
|
4
4
|
import F from "../../../../assets/line-icons/icons/practice.js";
|
5
|
-
import { IS_CHAPTER_COMPLETED_STATES as
|
5
|
+
import { IS_CHAPTER_COMPLETED_STATES as A } from "../../../milestone/create/milestone-create-constants.js";
|
6
6
|
import H from "../../../ui/arrow-tooltip/arrow-tooltip.js";
|
7
|
-
import
|
8
|
-
import
|
9
|
-
import { NODE_TYPE as
|
10
|
-
|
11
|
-
|
12
|
-
if (n === v || I.some((p) => p === n))
|
7
|
+
import V from "../../../ui/layout/flex-view.js";
|
8
|
+
import j from "../../comps/sheet-button/index.js";
|
9
|
+
import { NODE_TYPE as K, SHEET_STATE as U } from "../../constants/sheet.js";
|
10
|
+
const { TARGET_PRACTICE: I, PRACTICE: b, LEARNING: X } = K, { COMPLETED: y, IN_PROGRESS: Y } = U, q = (n, o, i) => {
|
11
|
+
if (n === y || A.some((f) => f === n))
|
13
12
|
return {
|
14
13
|
state: "completed",
|
15
14
|
renderAs: "secondary_black"
|
16
15
|
};
|
17
|
-
if ((o ===
|
16
|
+
if ((o === b || o === I) && i === "PENDING_TARGET_PRACTICE")
|
18
17
|
return {
|
19
18
|
state: "overdue",
|
20
19
|
renderAs: "tertiary"
|
@@ -24,85 +23,85 @@ const { TARGET_PRACTICE: b, PRACTICE: y, LEARNING: X } = U, { COMPLETED: v, IN_P
|
|
24
23
|
state: "in_progress",
|
25
24
|
renderAs: "primary"
|
26
25
|
};
|
27
|
-
},
|
28
|
-
({ sheetsListData: n, userType: o, isLessonDisabled:
|
29
|
-
const { lessonTagType:
|
26
|
+
}, ae = G(
|
27
|
+
({ sheetsListData: n, userType: o, isLessonDisabled: i, ...T }) => {
|
28
|
+
const { lessonTagType: f, onStart: d, onResume: p, onReattempt: u, onReview: l, onPreview: _ } = T, r = O(() => o === "STUDENT", [o]), v = $(
|
30
29
|
(s) => {
|
31
|
-
const { permissions:
|
32
|
-
can_start:
|
33
|
-
can_resume:
|
30
|
+
const { permissions: E, node_id: t, user_node_id: e } = s, {
|
31
|
+
can_start: a,
|
32
|
+
can_resume: c,
|
34
33
|
can_reattempt: w,
|
35
34
|
can_review: C,
|
36
|
-
can_teacher_review:
|
37
|
-
} =
|
35
|
+
can_teacher_review: h
|
36
|
+
} = E, R = r ? C : h;
|
38
37
|
if (r) {
|
39
|
-
if (
|
40
|
-
if (
|
41
|
-
d(t,
|
38
|
+
if (a || c) {
|
39
|
+
if (a && typeof d == "function") {
|
40
|
+
d(t, e);
|
42
41
|
return;
|
43
42
|
}
|
44
|
-
if (
|
45
|
-
|
43
|
+
if (c && typeof p == "function") {
|
44
|
+
p(t, e);
|
46
45
|
return;
|
47
46
|
}
|
48
47
|
throw new Error("No callback is available");
|
49
48
|
} else if (w) {
|
50
|
-
if (typeof
|
49
|
+
if (typeof u != "function")
|
51
50
|
throw new Error("canReattempt must be a function");
|
52
|
-
|
51
|
+
u(t, e);
|
53
52
|
return;
|
54
53
|
}
|
55
54
|
}
|
56
|
-
if (
|
57
|
-
if (typeof
|
55
|
+
if (R) {
|
56
|
+
if (typeof l != "function")
|
58
57
|
throw new Error("onReview must be a function");
|
59
58
|
if (!e)
|
60
59
|
throw new Error("user node id must be present to review the sheet");
|
61
|
-
|
60
|
+
l(e);
|
62
61
|
return;
|
63
62
|
}
|
64
|
-
if (typeof
|
63
|
+
if (typeof _ != "function")
|
65
64
|
throw new Error("onPreview must be a function");
|
66
|
-
|
65
|
+
_(s);
|
67
66
|
},
|
68
|
-
[r,
|
67
|
+
[r, l, d, _, u, p]
|
69
68
|
);
|
70
|
-
return /* @__PURE__ */
|
69
|
+
return /* @__PURE__ */ m(V, { $flexDirection: "row", $flexGapX: 1, $alignItems: "center", children: n.map((s, E) => {
|
71
70
|
const {
|
72
71
|
node_type: t,
|
73
72
|
state: e,
|
74
|
-
permissions:
|
75
|
-
sheet_statement:
|
73
|
+
permissions: a,
|
74
|
+
sheet_statement: c
|
76
75
|
} = s, {
|
77
76
|
can_start: w,
|
78
77
|
can_resume: C,
|
79
|
-
can_reattempt:
|
80
|
-
can_review:
|
81
|
-
} =
|
82
|
-
return /* @__PURE__ */
|
78
|
+
can_reattempt: h,
|
79
|
+
can_review: R
|
80
|
+
} = a, S = t === I ? b : t, P = t === X, N = e === "LOCKED", D = q(e, t, f), { state: g, renderAs: L } = D || {}, k = !(e === y || A.some((x) => x === e)) && !(w || C || R || h);
|
81
|
+
return /* @__PURE__ */ m(M, { children: /* @__PURE__ */ m(
|
83
82
|
H,
|
84
83
|
{
|
85
84
|
renderAs: "secondary",
|
86
85
|
position: "bottom",
|
87
|
-
tooltipItem:
|
86
|
+
tooltipItem: c,
|
88
87
|
textVariant: "ab3",
|
89
|
-
children: /* @__PURE__ */
|
90
|
-
|
88
|
+
children: /* @__PURE__ */ m(
|
89
|
+
j,
|
91
90
|
{
|
92
|
-
renderAs: L ?? (
|
93
|
-
label:
|
94
|
-
Icon:
|
95
|
-
onClick: () =>
|
96
|
-
disabled: r && (
|
97
|
-
state:
|
91
|
+
renderAs: L ?? (i || !r && N ? "secondary_grey" : "primary"),
|
92
|
+
label: S,
|
93
|
+
Icon: P ? B : F,
|
94
|
+
onClick: () => v(s),
|
95
|
+
disabled: r && (i || k),
|
96
|
+
state: g
|
98
97
|
}
|
99
98
|
)
|
100
99
|
}
|
101
|
-
) }, `${
|
100
|
+
) }, `${S}__lesson_button__${E}`);
|
102
101
|
}) });
|
103
102
|
}
|
104
103
|
);
|
105
104
|
export {
|
106
|
-
|
105
|
+
ae as default
|
107
106
|
};
|
108
107
|
//# sourceMappingURL=lesson-item-cta-info.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"lesson-item-cta-info.js","sources":["../../../../../src/features/sheets/lessons-list/lesson-item/lesson-item-cta-info.tsx"],"sourcesContent":["import type { TSheetButtonVariant } from '../../comps/sheet-button/types';\nimport type { ISheetDataProps } from '../../sheets-list/sheet-item/sheet-item-types';\nimport type { IGetLessonCtaInfo, ILessonItemCtaInfoProps } from './lesson-item-types';\nimport type { FC } from 'react';\n\nimport { Fragment, memo, useCallback, useMemo } from 'react';\n\nimport Bulb2Icon from '../../../../assets/line-icons/icons/bulb2';\nimport PracticeIcon from '../../../../assets/line-icons/icons/practice';\nimport { IS_CHAPTER_COMPLETED_STATES } from '../../../milestone/create/milestone-create-constants';\nimport ArrowTooltip from '../../../ui/arrow-tooltip/arrow-tooltip';\nimport FlexView from '../../../ui/layout/flex-view';\nimport SheetButton from '../../comps/sheet-button';\nimport { NODE_TYPE, SHEET_STATE } from '../../constants/sheet';\
|
1
|
+
{"version":3,"file":"lesson-item-cta-info.js","sources":["../../../../../src/features/sheets/lessons-list/lesson-item/lesson-item-cta-info.tsx"],"sourcesContent":["import type { TSheetButtonVariant } from '../../comps/sheet-button/types';\nimport type { ISheetDataProps } from '../../sheets-list/sheet-item/sheet-item-types';\nimport type { IGetLessonCtaInfo, ILessonItemCtaInfoProps } from './lesson-item-types';\nimport type { FC } from 'react';\n\nimport { Fragment, memo, useCallback, useMemo } from 'react';\n\nimport Bulb2Icon from '../../../../assets/line-icons/icons/bulb2';\nimport PracticeIcon from '../../../../assets/line-icons/icons/practice';\nimport { IS_CHAPTER_COMPLETED_STATES } from '../../../milestone/create/milestone-create-constants';\nimport ArrowTooltip from '../../../ui/arrow-tooltip/arrow-tooltip';\nimport FlexView from '../../../ui/layout/flex-view';\nimport SheetButton from '../../comps/sheet-button';\nimport { NODE_TYPE, SHEET_STATE } from '../../constants/sheet';\n\nconst { TARGET_PRACTICE, PRACTICE, LEARNING } = NODE_TYPE;\nconst { COMPLETED, IN_PROGRESS } = SHEET_STATE;\n\nconst getLessonCtaInfo: IGetLessonCtaInfo = (state, nodeType, lessonTagType) => {\n const isSheetCompleted =\n state === COMPLETED || IS_CHAPTER_COMPLETED_STATES.some(sheetState => sheetState === state);\n\n if (isSheetCompleted) {\n return {\n state: 'completed',\n renderAs: 'secondary_black',\n };\n }\n\n if (\n (nodeType === PRACTICE || nodeType === TARGET_PRACTICE) &&\n lessonTagType === 'PENDING_TARGET_PRACTICE'\n ) {\n return {\n state: 'overdue',\n renderAs: 'tertiary',\n };\n }\n\n if (state === IN_PROGRESS) {\n return {\n state: 'in_progress',\n renderAs: 'primary',\n };\n }\n\n return undefined;\n};\n\nconst LessonItemCtaInfo: FC<ILessonItemCtaInfoProps> = memo(\n ({ sheetsListData, userType, isLessonDisabled, ...restLessonItemCtaInfoProps }) => {\n const { lessonTagType, onStart, onResume, onReattempt, onReview, onPreview } =\n restLessonItemCtaInfoProps;\n\n const isStudent = useMemo(() => userType === 'STUDENT', [userType]);\n\n const handleOnClick = useCallback(\n (sheetInfo: ISheetDataProps) => {\n const { permissions, node_id: nodeId, user_node_id: userNodeId } = sheetInfo;\n const {\n can_start: canStart,\n can_resume: canResume,\n can_reattempt: canReattempt,\n can_review: canReview,\n can_teacher_review: canTeacherReview,\n } = permissions;\n const canReviewSheet = isStudent ? canReview : canTeacherReview;\n\n if (isStudent) {\n //* Student actions\n\n if (canStart || canResume) {\n if (canStart && typeof onStart === 'function') {\n onStart(nodeId, userNodeId);\n\n return;\n }\n\n if (canResume && typeof onResume === 'function') {\n onResume(nodeId, userNodeId);\n\n return;\n }\n\n throw new Error('No callback is available');\n } else if (canReattempt) {\n if (typeof onReattempt !== 'function') {\n throw new Error('canReattempt must be a function');\n }\n\n onReattempt(nodeId, userNodeId);\n\n return;\n }\n }\n\n if (canReviewSheet) {\n if (typeof onReview !== 'function') {\n throw new Error('onReview must be a function');\n }\n\n if (!userNodeId) {\n throw new Error('user node id must be present to review the sheet');\n }\n\n onReview(userNodeId);\n\n return;\n }\n\n if (typeof onPreview !== 'function') {\n throw new Error('onPreview must be a function');\n }\n\n onPreview(sheetInfo);\n\n return;\n },\n [isStudent, onReview, onStart, onPreview, onReattempt, onResume],\n );\n\n return (\n <FlexView $flexDirection=\"row\" $flexGapX={1} $alignItems=\"center\">\n {sheetsListData.map((sheet, idx) => {\n const {\n node_type: nodeType,\n state,\n permissions,\n sheet_statement: sheetStatement,\n } = sheet;\n const {\n can_start: canStart,\n can_resume: canResume,\n can_reattempt: canReattempt,\n can_review: canReview,\n } = permissions;\n const sheetType = nodeType === TARGET_PRACTICE ? PRACTICE : nodeType;\n const isLearningNodeType = nodeType === LEARNING;\n const isSheetLocked = state === 'LOCKED';\n\n const lessonCtaInfo = getLessonCtaInfo(state, nodeType, lessonTagType);\n const { state: lessonCtaState, renderAs } = lessonCtaInfo || {};\n\n const isSheetCompleted =\n state === COMPLETED ||\n IS_CHAPTER_COMPLETED_STATES.some(sheetState => sheetState === state);\n const sheetPermissionDisability =\n !isSheetCompleted && !(canStart || canResume || canReview || canReattempt);\n const disableCta = isStudent && (isLessonDisabled || sheetPermissionDisability);\n const sheetCtaDefaultRenderAs: TSheetButtonVariant =\n isLessonDisabled || (!isStudent && isSheetLocked) ? 'secondary_grey' : 'primary';\n\n return (\n <Fragment key={`${sheetType}__lesson_button__${idx}`}>\n <ArrowTooltip\n renderAs=\"secondary\"\n position=\"bottom\"\n tooltipItem={sheetStatement}\n textVariant=\"ab3\"\n >\n <SheetButton\n renderAs={renderAs ?? sheetCtaDefaultRenderAs}\n label={sheetType}\n Icon={isLearningNodeType ? Bulb2Icon : PracticeIcon}\n onClick={() => handleOnClick(sheet)}\n disabled={disableCta}\n state={lessonCtaState}\n />\n </ArrowTooltip>\n </Fragment>\n );\n })}\n </FlexView>\n );\n },\n);\n\nexport default LessonItemCtaInfo;\n"],"names":["TARGET_PRACTICE","PRACTICE","LEARNING","NODE_TYPE","COMPLETED","IN_PROGRESS","SHEET_STATE","getLessonCtaInfo","state","nodeType","lessonTagType","IS_CHAPTER_COMPLETED_STATES","sheetState","LessonItemCtaInfo","memo","sheetsListData","userType","isLessonDisabled","restLessonItemCtaInfoProps","onStart","onResume","onReattempt","onReview","onPreview","isStudent","useMemo","handleOnClick","useCallback","sheetInfo","permissions","nodeId","userNodeId","canStart","canResume","canReattempt","canReview","canTeacherReview","canReviewSheet","jsx","FlexView","sheet","idx","sheetStatement","sheetType","isLearningNodeType","isSheetLocked","lessonCtaInfo","lessonCtaState","renderAs","sheetPermissionDisability","Fragment","ArrowTooltip","SheetButton","Bulb2Icon","PracticeIcon"],"mappings":";;;;;;;;;AAeA,MAAM,EAAE,iBAAAA,GAAiB,UAAAC,GAAU,UAAAC,EAAA,IAAaC,GAC1C,EAAE,WAAAC,GAAW,aAAAC,EAAgB,IAAAC,GAE7BC,IAAsC,CAACC,GAAOC,GAAUC,MAAkB;AAI9E,MAFEF,MAAUJ,KAAaO,EAA4B,KAAK,CAAAC,MAAcA,MAAeJ,CAAK;AAGnF,WAAA;AAAA,MACL,OAAO;AAAA,MACP,UAAU;AAAA,IAAA;AAId,OACGC,MAAaR,KAAYQ,MAAaT,MACvCU,MAAkB;AAEX,WAAA;AAAA,MACL,OAAO;AAAA,MACP,UAAU;AAAA,IAAA;AAId,MAAIF,MAAUH;AACL,WAAA;AAAA,MACL,OAAO;AAAA,MACP,UAAU;AAAA,IAAA;AAKhB,GAEMQ,KAAiDC;AAAA,EACrD,CAAC,EAAE,gBAAAC,GAAgB,UAAAC,GAAU,kBAAAC,GAAkB,GAAGC,QAAiC;AACjF,UAAM,EAAE,eAAAR,GAAe,SAAAS,GAAS,U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