@cuemath/leap 2.8.61 → 2.8.62-aa0
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 +18 -18
- 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 +10 -10
- package/dist/features/chapters/lpar-chapter/block-section/sheet-item/rewards-n-actions/teacher-actions/teacher-actions.js.map +1 -1
- package/dist/features/circle-games/games/web-view/web-view-types.js.map +1 -1
- package/dist/features/circle-games/games/web-view/web-view.js +47 -53
- package/dist/features/circle-games/games/web-view/web-view.js.map +1 -1
- package/dist/features/cue-canvas/cue-canvas-provider.js +9 -8
- package/dist/features/cue-canvas/cue-canvas-provider.js.map +1 -1
- package/dist/features/sheets/lessons-list/lesson-item/lesson-item-cta-info.js +41 -41
- 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 +20 -20
- 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 +33 -33
- 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 +30 -30
- 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 +9 -14
- package/dist/features/sheets/utils/is-v3-worksheet.js.map +1 -1
- package/dist/features/ui/section-list/section-list.js +12 -12
- package/dist/features/ui/section-list/section-list.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +44 -43
- package/dist/library/polypad.js +24965 -0
- package/dist/library/polypad.js.map +1 -0
- package/package.json +4 -2
@@ -10,7 +10,7 @@ import K from "../../context-menu-helper/menu-element.js";
|
|
10
10
|
import Q from "../../context-menu-helper/target-element.js";
|
11
11
|
import { StyledButton as N, RewardImage as Y, RewardAccuracy as ee } from "../reward-n-actions-styled.js";
|
12
12
|
import { getPrimaryCtaLabel as te } from "./student-actions-utils.js";
|
13
|
-
const we = ({ sheet:
|
13
|
+
const we = ({ sheet: n, isLastSheet: O, onStartOrResume: m, onReview: l }) => {
|
14
14
|
var A;
|
15
15
|
const { onEvent: w } = H(), {
|
16
16
|
permissions: S,
|
@@ -29,14 +29,14 @@ const we = ({ sheet: t, isLastSheet: O, onStartOrResume: m, onReview: l }) => {
|
|
29
29
|
ceremony_completed_on_ts: R,
|
30
30
|
can_reattempt_block: U,
|
31
31
|
node_id: b,
|
32
|
-
id:
|
33
|
-
} =
|
32
|
+
id: C
|
33
|
+
} = n, { access: h } = S.can_do, t = J(d), r = W || t, k = a && Z(a), z = a && ((A = a[0]) == null ? void 0 : A.performance), L = !o && !c && typeof y == "number" && !(F && _ && _ === "WAIT_FOR_REVIEW"), v = U && !g, I = o || c || j || V, X = h && I || !r && v, p = !!(i && g && !R), s = f(
|
34
34
|
() => ({
|
35
|
-
user_node_id:
|
35
|
+
user_node_id: C,
|
36
36
|
nodeId: b
|
37
37
|
}),
|
38
|
-
[b,
|
39
|
-
),
|
38
|
+
[b, C]
|
39
|
+
), T = f(
|
40
40
|
() => te({
|
41
41
|
canStart: o,
|
42
42
|
canResume: c,
|
@@ -48,34 +48,34 @@ const we = ({ sheet: t, isLastSheet: O, onStartOrResume: m, onReview: l }) => {
|
|
48
48
|
), x = $(() => {
|
49
49
|
if (typeof m != "function")
|
50
50
|
throw new Error("onStartOrResume is not a function");
|
51
|
-
m(
|
52
|
-
}, [m,
|
51
|
+
m(n, P());
|
52
|
+
}, [m, n]), E = $(() => {
|
53
53
|
if (typeof l != "function")
|
54
54
|
throw new Error("onReview is not a function");
|
55
55
|
w("clicked", {
|
56
|
-
cta:
|
56
|
+
cta: t ? "View" : "Review sheet",
|
57
57
|
...s
|
58
|
-
}), l(
|
59
|
-
}, [s,
|
58
|
+
}), l(n, P());
|
59
|
+
}, [s, t, l, n, w]), D = r ? !!R : i, G = f(
|
60
60
|
() => [
|
61
61
|
{
|
62
62
|
key: "review-sheet",
|
63
|
-
label:
|
63
|
+
label: t ? "View" : "Review sheet",
|
64
64
|
visible: !!i,
|
65
65
|
onClick: E
|
66
66
|
}
|
67
67
|
],
|
68
|
-
[i, E,
|
68
|
+
[i, E, t]
|
69
69
|
);
|
70
|
-
return
|
71
|
-
|
70
|
+
return t ? null : /* @__PURE__ */ u(M, { $flexDirection: "row", $alignItems: "center", $flexGap: 8, children: [
|
71
|
+
h && r ? /* @__PURE__ */ e(B, { children: (I || p) && /* @__PURE__ */ e(
|
72
72
|
N,
|
73
73
|
{
|
74
74
|
renderAs: "primary",
|
75
75
|
size: "small",
|
76
76
|
widthX: 6,
|
77
77
|
onClick: x,
|
78
|
-
label:
|
78
|
+
label: T,
|
79
79
|
analyticsProps: s
|
80
80
|
}
|
81
81
|
) }) : /* @__PURE__ */ u(B, { children: [
|
@@ -89,8 +89,8 @@ const we = ({ sheet: t, isLastSheet: O, onStartOrResume: m, onReview: l }) => {
|
|
89
89
|
renderAs: "primary",
|
90
90
|
size: "small",
|
91
91
|
widthX: 6,
|
92
|
-
label:
|
93
|
-
disabled:
|
92
|
+
label: T,
|
93
|
+
disabled: v,
|
94
94
|
onClick: x,
|
95
95
|
analyticsProps: s
|
96
96
|
}
|
@@ -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 { isV3Worksheet } from '../../../../../../sheets/utils/is-v3-worksheet';\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, isV3Worksheet(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, isV3Worksheet(sheet, 'review'));\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","isV3Worksheet","handleOnReview","isMenuVisible","options","FlexView","jsx","Fragment","StyledButton","jsxs","RewardImage","RewardAccuracy","ContextMenu","ContextMenuTargetElement","ContextMenuElement"],"mappings":";;;;;;;;;;;;AAqBA,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,YAAYC;AAAA,IACZ,eAAeC;AAAA,IACf,UAAAC;AAAA,IACA,UAAUC;AAAA,IACV,SAAAC;AAAA,IACA,eAAeC;AAAA,IACf,eAAeC;AAAA,IACf,WAAWC;AAAA,IACX,cAAcC;AAAA,IACd,WAAWC;AAAA,IACX,0BAA0BC;AAAA,IAC1B,qBAAqBC;AAAA,IACrB,SAASC;AAAA,IACT,IAAIC;AAAA,EACF,IAAAtB,GACE,EAAE,QAAAuB,EAAO,IAAIjB,EAAY,QACzBkB,IAAgBC,EAAmBP,CAAQ,GAC3CQ,IAAwBV,KAAYQ,GACpCG,IAAkBd,KAAWe,EAAmBf,CAAO,GAEvDgB,IAAchB,OAAWiB,IAAAjB,EAAQ,CAAC,MAAT,gBAAAiB,EAAY,cAErCC,IACJ,CAACxB,KAAY,CAACC,KAAa,OAAOG,KAAa,YAAY,EAFlCI,KAAgBD,KAAgBA,MAAiB,oBAGtEkB,IAAmBZ,KAAqB,CAACH,GACzCgB,IAAmB1B,KAAYC,KAAaI,KAAWF,GACvDwB,IACHX,KAAUU,KAAsB,CAACP,KAAyBM,GACvDG,IAA4B,GAAQ1B,KAAaQ,KAAe,CAACE,IAEjEiB,IAAiBC;AAAA,IACrB,OAAO;AAAA,MACL,cAAcf;AAAA,MACd,QAAAD;AAAA,IAAA;AAAA,IAEF,CAACA,GAAQC,CAAU;AAAA,EAAA,GAGfgB,IAAkBD;AAAA,IACtB,MACEE,GAAmB;AAAA,MACjB,UAAAhC;AAAA,MACA,WAAAC;AAAA,MACA,uBAAAkB;AAAA,MACA,2BAAAS;AAAA,MACA,UAAAjB;AAAA,IAAA,CACD;AAAA,IACH,CAACV,GAAWD,GAAUmB,GAAuBR,GAAUiB,CAAyB;AAAA,EAAA,GAG5EK,IAAsBC,EAAY,MAAM;AACxC,QAAA,OAAOvC,KAAoB;AACvB,YAAA,IAAI,MAAM,mCAAmC;AAGrC,IAAAA,EAAAF,GAAO0C,
|
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 { isV3Worksheet } from '../../../../../../sheets/utils/is-v3-worksheet';\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, isV3Worksheet(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, isV3Worksheet(sheet, 'review'));\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","isV3Worksheet","handleOnReview","isMenuVisible","options","FlexView","jsx","Fragment","StyledButton","jsxs","RewardImage","RewardAccuracy","ContextMenu","ContextMenuTargetElement","ContextMenuElement"],"mappings":";;;;;;;;;;;;AAqBA,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,YAAYC;AAAA,IACZ,eAAeC;AAAA,IACf,UAAAC;AAAA,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QAACE;AAAA,QAAA;AAAA,UACC,UAAS;AAAA,UACT,MAAK;AAAA,UACL,QAAQ;AAAA,UACR,OAAOX;AAAA,UACP,UAAUN;AAAA,UACV,SAASQ;AAAA,UACT,gBAAAJ;AAAA,QAAA;AAAA,MACF;AAAA,IAAA,GAEJ;AAAA,IAGDQ,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,UAAU5C;AAAA,MAAA;AAAA,IACZ;AAAA,EAEJ,EAAA,CAAA;AAEJ;"}
|
@@ -14,7 +14,7 @@ import { StyledEyeIcon as $, RewardImage as Z, RewardAccuracy as q } from "../re
|
|
14
14
|
const se = ({
|
15
15
|
isLastSheet: M,
|
16
16
|
isClassOngoing: N,
|
17
|
-
sheet:
|
17
|
+
sheet: n,
|
18
18
|
...v
|
19
19
|
}) => {
|
20
20
|
var h;
|
@@ -29,7 +29,7 @@ const se = ({
|
|
29
29
|
completed_on: y,
|
30
30
|
can_reattempt_block: _,
|
31
31
|
node_id: g
|
32
|
-
} =
|
32
|
+
} = n, { code: p } = P.can_do, I = i === D.HIDDEN_BASIC, S = c && ((h = c[0]) == null ? void 0 : h.performance), A = c && G(c), C = W(i), B = k && typeof f == "number" && !C, U = d && !I, b = C && N && p === "IN_PROGRESS", O = !!(p && L(p)), t = E(
|
33
33
|
() => ({
|
34
34
|
node_id: g,
|
35
35
|
user_node_id: d
|
@@ -39,12 +39,12 @@ const se = ({
|
|
39
39
|
(o) => {
|
40
40
|
if (r("clicked", {
|
41
41
|
cta: o,
|
42
|
-
...
|
42
|
+
...t
|
43
43
|
}), typeof m != "function")
|
44
44
|
throw new Error("onMenuActionAttempt must be a function");
|
45
|
-
m(o,
|
45
|
+
m(o, n);
|
46
46
|
},
|
47
|
-
[
|
47
|
+
[t, m, n, r]
|
48
48
|
), V = E(
|
49
49
|
() => [
|
50
50
|
{
|
@@ -69,11 +69,11 @@ const se = ({
|
|
69
69
|
[_, y, w, i, l]
|
70
70
|
), a = T(
|
71
71
|
(o) => {
|
72
|
-
if (o && r(o,
|
72
|
+
if (o && r(o, t), typeof s != "function")
|
73
73
|
throw new Error("onView must be a function");
|
74
|
-
s(
|
74
|
+
s(n, H());
|
75
75
|
},
|
76
|
-
[
|
76
|
+
[t, s, n, r]
|
77
77
|
);
|
78
78
|
return I ? /* @__PURE__ */ e(u, { $flexGap: 8, $flexDirection: "row", $alignItems: "center", children: O ? /* @__PURE__ */ e($, { onClick: () => a("clicked") }) : /* @__PURE__ */ e(
|
79
79
|
R,
|
@@ -82,7 +82,7 @@ const se = ({
|
|
82
82
|
size: "small",
|
83
83
|
label: "Start",
|
84
84
|
onClick: a,
|
85
|
-
analyticsProps:
|
85
|
+
analyticsProps: t
|
86
86
|
}
|
87
87
|
) }) : /* @__PURE__ */ x(u, { $flexGap: 8, $flexDirection: "row", $alignItems: "center", children: [
|
88
88
|
B && /* @__PURE__ */ x(u, { $justifyContent: "center", $alignItems: "center", children: [
|
@@ -96,7 +96,7 @@ const se = ({
|
|
96
96
|
size: "small",
|
97
97
|
label: "Resume",
|
98
98
|
onClick: a,
|
99
|
-
analyticsProps:
|
99
|
+
analyticsProps: t
|
100
100
|
}
|
101
101
|
),
|
102
102
|
!b && /* @__PURE__ */ e($, { onClick: () => a("clicked") }),
|
@@ -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 { isV3Worksheet } from '../../../../../../sheets/utils/is-v3-worksheet';\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, isV3Worksheet(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","isV3Worksheet","FlexView","jsx","StyledEyeIcon","Button","jsxs","RewardImage","RewardAccuracy","ContextMenu","ContextMenuTargetElement","ContextMenuElement"],"mappings":";;;;;;;;;;;;;AAsBA,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,IACX,cAAcC;AAAA,IACd,qBAAqBC;AAAA,IACrB,SAASC;AAAA,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AA,IACA,CAAClB,GAAmBD,GAAaD,GAAUH,GAAUuB,CAAyB;AAAA,EAAA,GAG1EI,IAAeH;AAAA,IACnB,CAACC,MAAoB;AAKf,UAJAA,KACF9B,EAAW8B,GAAQJ,CAAc,GAG/B,OAAO5B,KAAW;AACd,cAAA,IAAI,MAAM,2BAA2B;AAGtC,MAAAA,EAAAF,GAAOqC,
|
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 { isV3Worksheet } from '../../../../../../sheets/utils/is-v3-worksheet';\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, isV3Worksheet(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","isV3Worksheet","FlexView","jsx","StyledEyeIcon","Button","jsxs","RewardImage","RewardAccuracy","ContextMenu","ContextMenuTargetElement","ContextMenuElement"],"mappings":";;;;;;;;;;;;;AAsBA,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,IACX,cAAcC;AAAA,IACd,qBAAqBC;AAAA,IACrB,SAASC;AAAA,EACP,IAAAf,GACE,EAAE,MAAAgB,EAAK,IAAIN,EAAY,QACvBO,IAAeR,MAAaS,EAAU,cACtCC,IAAcR,OAAWS,IAAAT,EAAQ,CAAC,MAAT,gBAAAS,EAAY,cACrCC,IAAkBV,KAAWW,EAAmBX,CAAO,GACvDY,IAAgBC,EAAmBf,CAAQ,GAC3CgB,IAAiBlB,KAAoB,OAAOD,KAAa,YAAY,CAACiB,GACtEG,IAAgBlB,KAAc,CAACS,GAC/BU,IAA6BJ,KAAiBxB,KAAkBiB,MAAS,eACzEY,IAAmB,GAAQZ,KAAQa,EAAwBb,CAAI,IAE/Dc,IAAiBC;AAAA,IACrB,OAAO;AAAA,MACL,SAAShB;AAAA,MACT,cAAcP;AAAA,IAAA;AAAA,IAEhB,CAACO,GAAQP,CAAU;AAAA,EAAA,GAGfwB,IAA4BC;AAAA,IAChC,CAACC,MAAmB;AAMd,UALJ9B,EAAW,WAAW;AAAA,QACpB,KAAK8B;AAAA,QACL,GAAGJ;AAAA,MAAA,CACJ,GAEG,OAAO3B,KAAwB;AAC3B,cAAA,IAAI,MAAM,wCAAwC;AAG1D,MAAAA,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E,gBAAAiB,EAAAJ,GAAA,EAAS,iBAAgB,UAAS,aAAY,UAC5C,UAAA;AAAA,MAAAjB,KAAoB,gBAAAkB,EAAAI,GAAA,EAAY,KAAKtB,GAAiB,KAAI,UAAS;AAAA,MACnE,gBAAAkB,EAAAK,GAAA,EAAe,WAAU,YAAW,QAAO,UACzC,UAAezB,KAAA,GAAG,KAAK,KAAKb,CAAQ,CAAC,KACxC;AAAA,IAAA,GACF;AAAA,IAGDC,KAAoBoB,KACnB,gBAAAY;AAAA,MAACE;AAAA,MAAA;AAAA,QACC,UAAS;AAAA,QACT,MAAK;AAAA,QACL,OAAM;AAAA,QACN,SAASL;AAAA,QACT,gBAAAN;AAAA,MAAA;AAAA,IACF;AAAA,IAGD,CAACH,KAA+B,gBAAAY,EAAAC,GAAA,EAAc,SAAS,MAAMJ,EAAa,SAAS,GAAG;AAAA,IAEtFV,KACC,gBAAAa;AAAA,MAACM;AAAA,MAAA;AAAA,QACC,iCAAgBC,GAAyB,EAAA;AAAA,QACzC,aAAc,gBAAAP,EAAAQ,GAAA,EAAmB,SAAAZ,EAAkB,CAAA;AAAA,QACnD,YAAY;AAAA,QACZ,YAAY;AAAA,QACZ,UAAUrC;AAAA,MAAA;AAAA,IACZ;AAAA,EAEJ,EAAA,CAAA;AAEJ;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"web-view-types.js","sources":["../../../../../src/features/circle-games/games/web-view/web-view-types.ts"],"sourcesContent":["import type { IAvatarLayer } from '../../../ui/avatar/avatar-types';\nimport type { TUserTypes } from '../../../ui/types';\nimport type { WebViewEvent, ProjectOutcome, ProjectType } from './enums';\nimport type { WEBVIEW_ANALYTICS_EVENTS } from './web-view-analytics-events';\nimport type { IframeHTMLAttributes } from 'react';\n\nexport interface IPlayer {\n id: string;\n username: string;\n grade?: string;\n avatar?: IAvatarLayer[] | null;\n playerType: TUserTypes;\n countryCode: string;\n}\n\ninterface ISyncableWebGameProps {\n joinByRoomId?: string;\n enableSync?: boolean; // applicable for all except multiplayer games and tables\n}\n\ninterface IBaseWebGameProps {\n projectId: string;\n variant: string;\n projectType: ProjectType;\n enableCloseButton?: boolean;\n}\n\nexport interface IMultiplayerWebGameProps extends IBaseWebGameProps, ISyncableWebGameProps {\n enablePlayerTurnIndicators?: boolean;\n}\n\nexport interface IPuzzleWebGameProps extends IBaseWebGameProps, ISyncableWebGameProps {\n question: string;\n askHintPermission?: boolean;\n}\n\nexport interface ILessonWebGameProps extends IBaseWebGameProps, ISyncableWebGameProps {\n miniGameIdentifier: string;\n sessionId: string;\n targetQuestions: number;\n}\n\nexport interface ITableWebGameProps extends IBaseWebGameProps {\n tableNumber: number;\n infiniteModeHighScore?: number;\n}\n\nexport interface IVibrationPattern {\n pattern: number[] | number;\n}\n\nexport enum IStatsToAwardErrorCode {\n DEFAULT = 'default',\n SUCCESS = 'success',\n FAIL = 'fail',\n}\n\nexport interface IPlayerStats {\n points: number;\n accuracy: number;\n timeSpent: number;\n streakDays: number;\n streakStatusToday: 'pending' | 'completed';\n errorCode: IStatsToAwardErrorCode;\n outcome: ProjectOutcome;\n value: string;\n starEligibleTime?: number;\n starEligibleAccuracy?: number;\n starRewarded?: boolean;\n}\n\nexport interface IInfoMessage {\n message: string;\n position: 'top' | 'bottom';\n}\n\nexport interface ITrackEvent {\n eventName: typeof WEBVIEW_ANALYTICS_EVENTS;\n properties: Record<string, unknown>;\n}\n\nexport interface IWebViewProps extends IframeHTMLAttributes<HTMLIFrameElement> {\n baseUrl: string;\n projectDetails:\n | IMultiplayerWebGameProps\n | IPuzzleWebGameProps\n | ILessonWebGameProps\n | ITableWebGameProps;\n parentDomain: string;\n playerDetails: IPlayer;\n onBack?: () => void;\n onGameLoad?: () => void;\n onGamePlayFinish?: (playerStats: IPlayerStats) => void;\n handleInfoMessage?: (infoMessage: IInfoMessage) => void;\n}\n\nexport interface IMessageProps {\n event: `${WebViewEvent}`;\n payload: IVibrationPattern | IPlayerStats | IInfoMessage | null;\n}\n"],"names":["IStatsToAwardErrorCode"],"mappings":"
|
1
|
+
{"version":3,"file":"web-view-types.js","sources":["../../../../../src/features/circle-games/games/web-view/web-view-types.ts"],"sourcesContent":["import type { IAvatarLayer } from '../../../ui/avatar/avatar-types';\nimport type { TUserTypes } from '../../../ui/types';\nimport type { WebViewEvent, ProjectOutcome, ProjectType } from './enums';\nimport type { WEBVIEW_ANALYTICS_EVENTS } from './web-view-analytics-events';\nimport type { IframeHTMLAttributes } from 'react';\n\nexport interface IPlayer {\n id: string;\n username: string;\n grade?: string;\n avatar?: IAvatarLayer[] | null;\n playerType: TUserTypes;\n countryCode: string;\n isAdmin?: boolean;\n}\n\ninterface ISyncableWebGameProps {\n joinByRoomId?: string;\n enableSync?: boolean; // applicable for all except multiplayer games and tables\n}\n\ninterface IBaseWebGameProps {\n projectId: string;\n variant: string;\n projectType: ProjectType;\n enableCloseButton?: boolean;\n}\n\nexport interface IMultiplayerWebGameProps extends IBaseWebGameProps, ISyncableWebGameProps {\n enablePlayerTurnIndicators?: boolean;\n}\n\nexport interface IPuzzleWebGameProps extends IBaseWebGameProps, ISyncableWebGameProps {\n question: string;\n askHintPermission?: boolean;\n}\n\nexport interface ILessonWebGameProps extends IBaseWebGameProps, ISyncableWebGameProps {\n miniGameIdentifier: string;\n sessionId: string;\n targetQuestions: number;\n}\n\nexport interface ITableWebGameProps extends IBaseWebGameProps {\n tableNumber: number;\n infiniteModeHighScore?: number;\n}\n\nexport interface IVibrationPattern {\n pattern: number[] | number;\n}\n\nexport enum IStatsToAwardErrorCode {\n DEFAULT = 'default',\n SUCCESS = 'success',\n FAIL = 'fail',\n}\n\nexport interface IPlayerStats {\n points: number;\n accuracy: number;\n timeSpent: number;\n streakDays: number;\n streakStatusToday: 'pending' | 'completed';\n errorCode: IStatsToAwardErrorCode;\n outcome: ProjectOutcome;\n value: string;\n starEligibleTime?: number;\n starEligibleAccuracy?: number;\n starRewarded?: boolean;\n}\n\nexport interface IInfoMessage {\n message: string;\n position: 'top' | 'bottom';\n}\n\nexport interface ITrackEvent {\n eventName: typeof WEBVIEW_ANALYTICS_EVENTS;\n properties: Record<string, unknown>;\n}\n\nexport interface IWebViewProps extends IframeHTMLAttributes<HTMLIFrameElement> {\n baseUrl: string;\n projectDetails:\n | IMultiplayerWebGameProps\n | IPuzzleWebGameProps\n | ILessonWebGameProps\n | ITableWebGameProps;\n parentDomain: string;\n playerDetails: IPlayer;\n onBack?: () => void;\n onGameLoad?: () => void;\n onGamePlayFinish?: (playerStats: IPlayerStats) => void;\n handleInfoMessage?: (infoMessage: IInfoMessage) => void;\n}\n\nexport interface IMessageProps {\n event: `${WebViewEvent}`;\n payload: IVibrationPattern | IPlayerStats | IInfoMessage | null;\n}\n"],"names":["IStatsToAwardErrorCode"],"mappings":"AAoDY,IAAAA,sBAAAA,OACVA,EAAA,UAAU,WACVA,EAAA,UAAU,WACVA,EAAA,OAAO,QAHGA,IAAAA,KAAA,CAAA,CAAA;"}
|
@@ -1,28 +1,28 @@
|
|
1
1
|
import { jsx as P } from "react/jsx-runtime";
|
2
|
-
import { forwardRef as
|
3
|
-
import { useUIContext as
|
4
|
-
import { ALLOWED_ORIGIN as
|
2
|
+
import { forwardRef as V, useRef as G, useMemo as R, useCallback as v, useImperativeHandle as $, useEffect as B } from "react";
|
3
|
+
import { useUIContext as J } from "../../../ui/context/context.js";
|
4
|
+
import { ALLOWED_ORIGIN as C } from "./constants.js";
|
5
5
|
import { ProjectType as s } from "./enums/project-type-enum.js";
|
6
6
|
import { WebViewEvent as o } from "./enums/web-view-events-enum.js";
|
7
|
-
const
|
7
|
+
const Z = V((I, b) => {
|
8
8
|
const {
|
9
|
-
baseUrl:
|
10
|
-
projectDetails:
|
11
|
-
playerDetails:
|
9
|
+
baseUrl: y,
|
10
|
+
projectDetails: T,
|
11
|
+
playerDetails: w,
|
12
12
|
onGameLoad: a,
|
13
|
-
onGamePlayFinish:
|
14
|
-
handleInfoMessage:
|
13
|
+
onGamePlayFinish: c,
|
14
|
+
handleInfoMessage: p,
|
15
15
|
onBack: f,
|
16
|
-
parentDomain:
|
17
|
-
...
|
18
|
-
} =
|
16
|
+
parentDomain: g,
|
17
|
+
...L
|
18
|
+
} = I, l = G(null), N = R(() => w, [w]), t = R(() => T, [T]);
|
19
19
|
let A = "";
|
20
|
-
const { onEvent: O } =
|
20
|
+
const { onEvent: O } = J();
|
21
21
|
t.projectType === s.LESSON && (A = t.miniGameIdentifier);
|
22
|
-
const m =
|
23
|
-
const { enableCloseButton:
|
22
|
+
const m = v(() => {
|
23
|
+
const { enableCloseButton: i = !0 } = t;
|
24
24
|
let e = {
|
25
|
-
enableCloseButton:
|
25
|
+
enableCloseButton: i
|
26
26
|
};
|
27
27
|
return t.projectType === s.GAME && (e = {
|
28
28
|
...e,
|
@@ -37,66 +37,60 @@ const F = G((C, I) => {
|
|
37
37
|
...e,
|
38
38
|
...t
|
39
39
|
}), e;
|
40
|
-
}, [t]),
|
40
|
+
}, [t]), d = v(() => {
|
41
41
|
var e, r;
|
42
|
-
const
|
42
|
+
const i = m();
|
43
43
|
(r = (e = l.current) == null ? void 0 : e.contentWindow) == null || r.postMessage(
|
44
44
|
JSON.stringify({
|
45
45
|
event: o.GAME_DATA,
|
46
|
-
payload:
|
46
|
+
payload: i
|
47
47
|
}),
|
48
|
-
|
48
|
+
C
|
49
49
|
);
|
50
|
-
}, [m]),
|
50
|
+
}, [m]), D = v(() => {
|
51
51
|
var e, r;
|
52
|
-
const
|
52
|
+
const i = m();
|
53
53
|
(r = (e = l.current) == null ? void 0 : e.contentWindow) == null || r.postMessage(
|
54
54
|
JSON.stringify({
|
55
55
|
event: o.SET_CONFIG,
|
56
56
|
payload: {
|
57
|
-
user:
|
58
|
-
projectConfig:
|
59
|
-
parentDomain:
|
57
|
+
user: N,
|
58
|
+
projectConfig: i,
|
59
|
+
parentDomain: g
|
60
60
|
}
|
61
61
|
}),
|
62
|
-
|
62
|
+
C
|
63
63
|
);
|
64
|
-
}, [
|
65
|
-
|
66
|
-
const
|
67
|
-
var j,
|
68
|
-
const r = e.data,
|
69
|
-
if (
|
70
|
-
const { pattern: u } =
|
71
|
-
(S = (j = window.navigator).vibrate) == null ||
|
64
|
+
}, [N, m, g]);
|
65
|
+
$(b, () => l.current, []), B(() => {
|
66
|
+
const i = (e) => {
|
67
|
+
var j, _;
|
68
|
+
const r = e.data, S = typeof r == "string" ? JSON.parse(r) : r, { event: n, payload: E = null } = S;
|
69
|
+
if (n === o.VIBRATE) {
|
70
|
+
const { pattern: u } = E;
|
71
|
+
window.ReactNativeWebView ? window.ReactNativeWebView.postMessage(JSON.stringify(S)) : (_ = (j = window.navigator).vibrate) == null || _.call(j, u);
|
72
72
|
}
|
73
|
-
if (
|
74
|
-
const { eventName: u, properties:
|
75
|
-
O(u,
|
73
|
+
if (n === o.GAME_BACK && (f == null || f()), n === o.HIDE_LOADER && (a == null || a()), n === o.LOAD_DATA_FROM_APP && (d == null || d()), n === o.GET_CONFIG && D(), n === o.UPDATE_STATS && (c == null || c(E)), n === o.SHOW_SNACKBAR && (p == null || p(E)), n === o.TRACK_EVENT) {
|
74
|
+
const { eventName: u, properties: W } = E;
|
75
|
+
O(u, W);
|
76
76
|
}
|
77
77
|
};
|
78
|
-
return window.addEventListener("message",
|
79
|
-
window.removeEventListener("message",
|
78
|
+
return window.addEventListener("message", i), () => {
|
79
|
+
window.removeEventListener("message", i);
|
80
80
|
};
|
81
81
|
}, [
|
82
|
-
c,
|
83
|
-
f,
|
84
82
|
p,
|
83
|
+
f,
|
84
|
+
c,
|
85
85
|
a,
|
86
|
-
|
87
|
-
|
86
|
+
D,
|
87
|
+
d,
|
88
88
|
O
|
89
|
-
])
|
90
|
-
|
91
|
-
|
92
|
-
...R,
|
93
|
-
ref: l,
|
94
|
-
src: `${L}/play-game/${t.projectId}/${t.variant}${A ? `/${A}` : ""}?version=2`,
|
95
|
-
allow: "autoplay"
|
96
|
-
}
|
97
|
-
);
|
89
|
+
]);
|
90
|
+
const M = w.isAdmin ? y : `${y}/play-game/${t.projectId}/${t.variant}${A ? `/${A}` : ""}`;
|
91
|
+
return /* @__PURE__ */ P("iframe", { ...L, ref: l, src: `${M}?version=2`, allow: "autoplay" });
|
98
92
|
});
|
99
93
|
export {
|
100
|
-
|
94
|
+
Z as WebView
|
101
95
|
};
|
102
96
|
//# sourceMappingURL=web-view.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"web-view.js","sources":["../../../../../src/features/circle-games/games/web-view/web-view.tsx"],"sourcesContent":["
|
1
|
+
{"version":3,"file":"web-view.js","sources":["../../../../../src/features/circle-games/games/web-view/web-view.tsx"],"sourcesContent":["declare global {\n interface IReactNativeWebview {\n postMessage: (data: string) => void;\n }\n\n interface Window {\n ReactNativeWebView?: IReactNativeWebview;\n }\n}\n\nimport type {\n IInfoMessage,\n ILessonWebGameProps,\n IMessageProps,\n IMultiplayerWebGameProps,\n IPlayerStats,\n IPuzzleWebGameProps,\n ITableWebGameProps,\n IVibrationPattern,\n IWebViewProps,\n} from './web-view-types';\nimport type { ForwardedRef } from 'react';\n\nimport { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef } from 'react';\n\nimport { useUIContext } from '../../../ui/context/context';\nimport { ALLOWED_ORIGIN } from './constants';\nimport { ProjectType, WebViewEvent } from './enums';\n\nexport const WebView = forwardRef((props: IWebViewProps, ref: ForwardedRef<HTMLIFrameElement>) => {\n const {\n baseUrl,\n projectDetails,\n playerDetails,\n onGameLoad,\n onGamePlayFinish,\n handleInfoMessage,\n onBack,\n parentDomain,\n ...rest\n } = props;\n const webViewRef = useRef<HTMLIFrameElement>(null);\n const memoizedPlayerDetails = useMemo(() => playerDetails, [playerDetails]);\n const memoizedProjectDetails = useMemo(() => projectDetails, [projectDetails]);\n\n let miniGameIdentifier = '';\n const { onEvent: trackEvent } = useUIContext();\n\n if (memoizedProjectDetails.projectType === ProjectType.LESSON) {\n miniGameIdentifier = (memoizedProjectDetails as ILessonWebGameProps).miniGameIdentifier;\n }\n\n const getProjectDetails = useCallback(() => {\n const { enableCloseButton = true } = memoizedProjectDetails;\n\n let payload = {\n enableCloseButton,\n } as IMultiplayerWebGameProps | IPuzzleWebGameProps | ILessonWebGameProps;\n\n if (memoizedProjectDetails.projectType === ProjectType.GAME) {\n payload = {\n ...payload,\n ...memoizedProjectDetails,\n } as IMultiplayerWebGameProps;\n }\n\n if (memoizedProjectDetails.projectType === ProjectType.PUZZLE) {\n payload = {\n ...payload,\n ...memoizedProjectDetails,\n } as IPuzzleWebGameProps;\n }\n\n if (memoizedProjectDetails.projectType === ProjectType.LESSON) {\n payload = {\n ...payload,\n ...memoizedProjectDetails,\n } as ILessonWebGameProps;\n }\n\n if (memoizedProjectDetails.projectType === ProjectType.TABLE) {\n payload = {\n ...payload,\n ...memoizedProjectDetails,\n } as ITableWebGameProps;\n }\n\n return payload;\n }, [memoizedProjectDetails]);\n\n const sendGamesData = useCallback(() => {\n const payload = getProjectDetails();\n\n webViewRef.current?.contentWindow?.postMessage(\n JSON.stringify({\n event: WebViewEvent.GAME_DATA,\n payload,\n }),\n ALLOWED_ORIGIN,\n );\n }, [getProjectDetails]);\n\n const setConfig = useCallback(() => {\n const projectConfig = getProjectDetails();\n\n webViewRef.current?.contentWindow?.postMessage(\n JSON.stringify({\n event: WebViewEvent.SET_CONFIG,\n payload: {\n user: memoizedPlayerDetails,\n projectConfig,\n parentDomain,\n },\n }),\n ALLOWED_ORIGIN,\n );\n }, [memoizedPlayerDetails, getProjectDetails, parentDomain]);\n\n useImperativeHandle(ref, () => webViewRef.current as HTMLIFrameElement, []);\n\n useEffect(() => {\n const handleMessage = (e: MessageEvent) => {\n const data: string = e.data;\n const parsedData = typeof data === 'string' ? JSON.parse(data) : (data as IMessageProps);\n\n const { event, payload = null } = parsedData;\n\n if (event === WebViewEvent.VIBRATE) {\n const { pattern } = payload as IVibrationPattern;\n\n if (window.ReactNativeWebView) {\n window.ReactNativeWebView.postMessage(JSON.stringify(parsedData));\n } else {\n window.navigator.vibrate?.(pattern);\n }\n }\n\n if (event === WebViewEvent.GAME_BACK) {\n onBack?.();\n }\n\n if (event === WebViewEvent.HIDE_LOADER) {\n onGameLoad?.();\n }\n\n if (event === WebViewEvent.LOAD_DATA_FROM_APP) {\n sendGamesData?.();\n }\n\n if (event === WebViewEvent.GET_CONFIG) {\n setConfig();\n }\n\n if (event === WebViewEvent.UPDATE_STATS) {\n onGamePlayFinish?.(payload as IPlayerStats);\n }\n\n if (event === WebViewEvent.SHOW_SNACKBAR) {\n handleInfoMessage?.(payload as IInfoMessage);\n }\n\n if (event === WebViewEvent.TRACK_EVENT) {\n const { eventName, properties } = payload;\n\n trackEvent(eventName, properties);\n }\n };\n\n window.addEventListener('message', handleMessage);\n\n return () => {\n window.removeEventListener('message', handleMessage);\n };\n }, [\n handleInfoMessage,\n onBack,\n onGamePlayFinish,\n onGameLoad,\n setConfig,\n sendGamesData,\n trackEvent,\n ]);\n\n const url = playerDetails.isAdmin\n ? baseUrl\n : `${baseUrl}/play-game/${memoizedProjectDetails.projectId}/${memoizedProjectDetails.variant}${\n miniGameIdentifier ? `/${miniGameIdentifier}` : ''\n }`;\n\n return <iframe {...rest} ref={webViewRef} src={`${url}?version=2`} allow=\"autoplay\" />;\n});\n"],"names":["WebView","forwardRef","props","ref","baseUrl","projectDetails","playerDetails","onGameLoad","onGamePlayFinish","handleInfoMessage","onBack","parentDomain","rest","webViewRef","useRef","memoizedPlayerDetails","useMemo","memoizedProjectDetails","miniGameIdentifier","trackEvent","useUIContext","ProjectType","getProjectDetails","useCallback","enableCloseButton","payload","sendGamesData","_b","_a","WebViewEvent","ALLOWED_ORIGIN","setConfig","projectConfig","useImperativeHandle","useEffect","handleMessage","data","parsedData","event","pattern","eventName","properties","url","jsx"],"mappings":";;;;;;AA6BO,MAAMA,IAAUC,EAAW,CAACC,GAAsBC,MAAyC;AAC1F,QAAA;AAAA,IACJ,SAAAC;AAAA,IACA,gBAAAC;AAAA,IACA,eAAAC;AAAA,IACA,YAAAC;AAAA,IACA,kBA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M;AACJ,aAAA,oBAAoB,WAAWA,CAAa;AAAA,IAAA;AAAA,EACrD,GACC;AAAA,IACD1B;AAAA,IACAC;AAAA,IACAF;AAAA,IACAD;AAAA,IACAwB;AAAA,IACAL;AAAA,IACAP;AAAA,EAAA,CACD;AAED,QAAMuB,IAAMpC,EAAc,UACtBF,IACA,GAAGA,CAAO,cAAca,EAAuB,SAAS,IAAIA,EAAuB,OAAO,GACxFC,IAAqB,IAAIA,CAAkB,KAAK,EAClD;AAEG,SAAA,gBAAAyB,EAAC,UAAQ,EAAA,GAAG/B,GAAM,KAAKC,GAAY,KAAK,GAAG6B,CAAG,cAAc,OAAM,WAAW,CAAA;AACtF,CAAC;"}
|
@@ -1,10 +1,11 @@
|
|
1
1
|
import { jsx as d } from "react/jsx-runtime";
|
2
|
-
import
|
3
|
-
import p from "
|
2
|
+
import "../../library/polypad.js";
|
3
|
+
import { memo as p, useMemo as i, useState as o } from "react";
|
4
|
+
import f from "./cue-canvas-context.js";
|
4
5
|
import { getColorsForUser as x } from "./cue-canvas-helpers.js";
|
5
|
-
const A =
|
6
|
-
({ children:
|
7
|
-
const
|
6
|
+
const A = p(
|
7
|
+
({ children: n, userType: t }) => {
|
8
|
+
const a = i(() => x(t), [t]), [e, v] = o(), [r, m] = o("pen"), [s, l] = o(), [c, C] = o(a[0]), u = i(
|
8
9
|
() => ({
|
9
10
|
activeInstance: e,
|
10
11
|
setActiveInstance: v,
|
@@ -17,10 +18,10 @@ const A = f(
|
|
17
18
|
}),
|
18
19
|
[c, e, s, r]
|
19
20
|
);
|
20
|
-
return /* @__PURE__ */ d(
|
21
|
+
return /* @__PURE__ */ d(f.Provider, { value: u, children: n });
|
21
22
|
}
|
22
|
-
),
|
23
|
+
), j = A;
|
23
24
|
export {
|
24
|
-
|
25
|
+
j as default
|
25
26
|
};
|
26
27
|
//# sourceMappingURL=cue-canvas-provider.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"cue-canvas-provider.js","sources":["../../../src/features/cue-canvas/cue-canvas-provider.tsx"],"sourcesContent":["import type { TUserTypes } from '../ui/types';\nimport type { CueCanvasCore } from './cue-canvas-core';\nimport type { TCueCanvasColors, TCueCanvasSidebar, TCueCanvasTool } from './types/cue-canvas';\nimport '../../library/polypad';\nimport type { FC, PropsWithChildren } from 'react';\n\nimport { useState, memo, useMemo } from 'react';\n\nimport CueCanvasContext from './cue-canvas-context';\nimport { getColorsForUser } from './cue-canvas-helpers';\n\nconst CueCanvasProvider: FC<PropsWithChildren<{ userType: TUserTypes }>> = memo(\n ({ children, userType }) => {\n const colors = useMemo(() => getColorsForUser(userType), [userType]);\n\n const [activeInstance, setActiveInstance] = useState<CueCanvasCore>();\n const [activeTool, setActiveTool] = useState<TCueCanvasTool>('pen');\n const [activeSidebar, setActiveSidebar] = useState<TCueCanvasSidebar>();\n const [activeColor, setActiveColor] = useState<TCueCanvasColors>(colors[0] as TCueCanvasColors);\n const contextValue = useMemo(\n () => ({\n activeInstance: activeInstance,\n setActiveInstance: setActiveInstance,\n activeTool: activeTool,\n setActiveTool: setActiveTool,\n activeColor,\n setActiveColor,\n activeSidebar,\n setActiveSidebar,\n }),\n [activeColor, activeInstance, activeSidebar, activeTool],\n );\n\n return <CueCanvasContext.Provider value={contextValue}>{children}</CueCanvasContext.Provider>;\n },\n);\n\nexport default CueCanvasProvider;\n"],"names":["CueCanvasProvider","memo","children","userType","colors","useMemo","getColorsForUser","activeInstance","setActiveInstance","useState","activeTool","setActiveTool","activeSidebar","setActiveSidebar","activeColor","setActiveColor","contextValue","CueCanvasContext","CueCanvasProvider$1"],"mappings":"
|
1
|
+
{"version":3,"file":"cue-canvas-provider.js","sources":["../../../src/features/cue-canvas/cue-canvas-provider.tsx"],"sourcesContent":["import type { TUserTypes } from '../ui/types';\nimport type { CueCanvasCore } from './cue-canvas-core';\nimport type { TCueCanvasColors, TCueCanvasSidebar, TCueCanvasTool } from './types/cue-canvas';\nimport '../../library/polypad';\nimport type { FC, PropsWithChildren } from 'react';\n\nimport { useState, memo, useMemo } from 'react';\n\nimport CueCanvasContext from './cue-canvas-context';\nimport { getColorsForUser } from './cue-canvas-helpers';\n\nconst CueCanvasProvider: FC<PropsWithChildren<{ userType: TUserTypes }>> = memo(\n ({ children, userType }) => {\n const colors = useMemo(() => getColorsForUser(userType), [userType]);\n\n const [activeInstance, setActiveInstance] = useState<CueCanvasCore>();\n const [activeTool, setActiveTool] = useState<TCueCanvasTool>('pen');\n const [activeSidebar, setActiveSidebar] = useState<TCueCanvasSidebar>();\n const [activeColor, setActiveColor] = useState<TCueCanvasColors>(colors[0] as TCueCanvasColors);\n const contextValue = useMemo(\n () => ({\n activeInstance: activeInstance,\n setActiveInstance: setActiveInstance,\n activeTool: activeTool,\n setActiveTool: setActiveTool,\n activeColor,\n setActiveColor,\n activeSidebar,\n setActiveSidebar,\n }),\n [activeColor, activeInstance, activeSidebar, activeTool],\n );\n\n return <CueCanvasContext.Provider value={contextValue}>{children}</CueCanvasContext.Provider>;\n },\n);\n\nexport default CueCanvasProvider;\n"],"names":["CueCanvasProvider","memo","children","userType","colors","useMemo","getColorsForUser","activeInstance","setActiveInstance","useState","activeTool","setActiveTool","activeSidebar","setActiveSidebar","activeColor","setActiveColor","contextValue","CueCanvasContext","CueCanvasProvider$1"],"mappings":";;;;;AAWA,MAAMA,IAAqEC;AAAA,EACzE,CAAC,EAAE,UAAAC,GAAU,UAAAC,QAAe;AACpB,UAAAC,IAASC,EAAQ,MAAMC,EAAiBH,CAAQ,GAAG,CAACA,CAAQ,CAAC,GAE7D,CAACI,GAAgBC,CAAiB,IAAIC,EAAwB,GAC9D,CAACC,GAAYC,CAAa,IAAIF,EAAyB,KAAK,GAC5D,CAACG,GAAeC,CAAgB,IAAIJ,EAA4B,GAChE,CAACK,GAAaC,CAAc,IAAIN,EAA2BL,EAAO,CAAC,CAAqB,GACxFY,IAAeX;AAAA,MACnB,OAAO;AAAA,QACL,gBAAAE;AAAA,QACA,mBAAAC;AAAA,QACA,YAAAE;AAAA,QACA,eAAAC;AAAA,QACA,aAAAG;AAAA,QACA,gBAAAC;AAAA,QACA,eAAAH;AAAA,QACA,kBAAAC;AAAA,MAAA;AAAA,MAEF,CAACC,GAAaP,GAAgBK,GAAeF,CAAU;AAAA,IAAA;AAGzD,6BAAQO,EAAiB,UAAjB,EAA0B,OAAOD,GAAe,UAAAd,EAAS,CAAA;AAAA,EACnE;AACF,GAEAgB,IAAelB;"}
|