@cuemath/leap 4.0.1 → 4.0.2
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.
|
@@ -1,44 +1,49 @@
|
|
|
1
1
|
import { jsx as o } from "react/jsx-runtime";
|
|
2
|
-
import { useRef as i, useCallback as
|
|
3
|
-
import
|
|
4
|
-
import { getHasDownloadBlock as
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import { JOURNEY_ID_STUDENT as
|
|
8
|
-
import { BLOCK_MOCKS_WITH_DOWNLOAD_NODE as
|
|
9
|
-
import { IndicatorType as
|
|
10
|
-
import { useJourney as
|
|
11
|
-
import
|
|
12
|
-
const
|
|
13
|
-
const e =
|
|
14
|
-
|
|
15
|
-
}, [e,
|
|
2
|
+
import { useRef as i, useCallback as h, useMemo as J, useEffect as S } from "react";
|
|
3
|
+
import L from "../../../chapters-v2/chapter-details/block-sections/block-section-view.js";
|
|
4
|
+
import { getHasDownloadBlock as x } from "../../../chapters-v2/utils/index.js";
|
|
5
|
+
import c from "../../../ui/layout/flex-view.js";
|
|
6
|
+
import T from "../../../ui/text/text.js";
|
|
7
|
+
import { JOURNEY_ID_STUDENT as g } from "../../journey-id/journey-id-student.js";
|
|
8
|
+
import { BLOCK_MOCKS_WITH_DOWNLOAD_NODE as K, DOWNLOAD_BLOCK_MOCKS as H } from "../../mocks/chapter-page-journey-mock-data.js";
|
|
9
|
+
import { IndicatorType as D } from "../../use-journey/constants.js";
|
|
10
|
+
import { useJourney as U } from "../../use-journey/use-journey.js";
|
|
11
|
+
import E from "../use-home-page-journey/tooltip-item.js";
|
|
12
|
+
const F = () => {
|
|
13
|
+
const e = g.DOWNLOAD_NODE_JOURNEY, a = i(null), s = i(null), t = i(null), r = i([]), { nextCoachmark: f, setJourney: p, endJourney: n } = U(), d = h(() => {
|
|
14
|
+
f(e, !1, 0, !0);
|
|
15
|
+
}, [e, f]), u = h(() => {
|
|
16
16
|
document.body.style.overflow = "unset", n(e);
|
|
17
|
-
}, [n, e]), O =
|
|
17
|
+
}, [n, e]), O = h(
|
|
18
18
|
({
|
|
19
19
|
chapterDetails: l,
|
|
20
20
|
userType: C,
|
|
21
21
|
canStartDownloadBlockJourney: _
|
|
22
22
|
}) => {
|
|
23
|
+
var w;
|
|
23
24
|
if (!l || !s.current)
|
|
24
25
|
return;
|
|
25
|
-
const { image_hue:
|
|
26
|
+
const { image_hue: b, blocks: A } = l, m = _ && x(A);
|
|
26
27
|
if (m && !t.current) return;
|
|
27
|
-
|
|
28
|
+
(w = t.current) == null || w.scrollIntoView({
|
|
29
|
+
behavior: "smooth",
|
|
30
|
+
block: "nearest"
|
|
31
|
+
});
|
|
32
|
+
const N = [
|
|
28
33
|
{
|
|
29
34
|
originalElementToHighlightRef: s,
|
|
30
|
-
elementToHighlight: /* @__PURE__ */ o(
|
|
31
|
-
|
|
35
|
+
elementToHighlight: /* @__PURE__ */ o(c, { $widthX: 50, ref: a, children: /* @__PURE__ */ o(
|
|
36
|
+
L,
|
|
32
37
|
{
|
|
33
|
-
blockData:
|
|
38
|
+
blockData: K,
|
|
34
39
|
userType: C,
|
|
35
40
|
isLastBlock: !0,
|
|
36
41
|
lessonIdx: 0,
|
|
37
|
-
imageHue:
|
|
42
|
+
imageHue: b,
|
|
38
43
|
isGoalBlock: !0
|
|
39
44
|
}
|
|
40
45
|
) }),
|
|
41
|
-
type:
|
|
46
|
+
type: D.TOOLTIP,
|
|
42
47
|
indicator: {
|
|
43
48
|
position: "bottom",
|
|
44
49
|
tooltipYCoOrdinates: -84,
|
|
@@ -52,24 +57,24 @@ const z = () => {
|
|
|
52
57
|
children: null,
|
|
53
58
|
renderAs: "primary",
|
|
54
59
|
tooltipItem: /* @__PURE__ */ o(
|
|
55
|
-
|
|
60
|
+
E,
|
|
56
61
|
{
|
|
57
|
-
element: /* @__PURE__ */ o(
|
|
62
|
+
element: /* @__PURE__ */ o(c, { children: /* @__PURE__ */ o(T, { $renderAs: "ab2-black", children: "Introducing downloadable study material." }) }),
|
|
58
63
|
buttonLabel: m ? "Next" : "Got it",
|
|
59
64
|
onButtonClick: () => {
|
|
60
65
|
if (m) {
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}),
|
|
66
|
+
const k = document.getElementById("tooltip-root");
|
|
67
|
+
k && Array.from(k.children).forEach((R) => {
|
|
68
|
+
R.style.display = "none";
|
|
69
|
+
}), a.current && (a.current.style.display = "none"), t.current && t.current.scrollIntoView({
|
|
65
70
|
behavior: "smooth",
|
|
66
71
|
block: "center",
|
|
67
72
|
inline: "center"
|
|
68
73
|
});
|
|
69
|
-
const
|
|
70
|
-
clearTimeout(
|
|
74
|
+
const B = setTimeout(() => {
|
|
75
|
+
clearTimeout(B), d();
|
|
71
76
|
}, 800);
|
|
72
|
-
r.current.push(
|
|
77
|
+
r.current.push(B);
|
|
73
78
|
} else
|
|
74
79
|
u();
|
|
75
80
|
}
|
|
@@ -79,17 +84,17 @@ const z = () => {
|
|
|
79
84
|
},
|
|
80
85
|
{
|
|
81
86
|
originalElementToHighlightRef: t,
|
|
82
|
-
elementToHighlight: /* @__PURE__ */ o(
|
|
83
|
-
|
|
87
|
+
elementToHighlight: /* @__PURE__ */ o(c, { $widthX: 50, children: /* @__PURE__ */ o(
|
|
88
|
+
L,
|
|
84
89
|
{
|
|
85
|
-
blockData:
|
|
90
|
+
blockData: H,
|
|
86
91
|
userType: C,
|
|
87
92
|
isLastBlock: !0,
|
|
88
93
|
lessonIdx: 0,
|
|
89
|
-
imageHue:
|
|
94
|
+
imageHue: b
|
|
90
95
|
}
|
|
91
96
|
) }),
|
|
92
|
-
type:
|
|
97
|
+
type: D.TOOLTIP,
|
|
93
98
|
indicator: {
|
|
94
99
|
position: "top",
|
|
95
100
|
tooltipYCoOrdinates: 14,
|
|
@@ -103,26 +108,26 @@ const z = () => {
|
|
|
103
108
|
children: null,
|
|
104
109
|
renderAs: "primary",
|
|
105
110
|
tooltipItem: /* @__PURE__ */ o(
|
|
106
|
-
|
|
111
|
+
E,
|
|
107
112
|
{
|
|
108
|
-
element: /* @__PURE__ */ o(
|
|
113
|
+
element: /* @__PURE__ */ o(c, { children: /* @__PURE__ */ o(T, { $renderAs: "ab2-black", children: "Also available in the Downloads section." }) }),
|
|
109
114
|
buttonLabel: "Got it",
|
|
110
115
|
onButtonClick: () => {
|
|
111
|
-
u(), n(
|
|
116
|
+
u(), n(g.DOWNLOAD_BLOCK_JOURNEY);
|
|
112
117
|
}
|
|
113
118
|
}
|
|
114
119
|
)
|
|
115
120
|
}
|
|
116
121
|
}
|
|
117
122
|
];
|
|
118
|
-
p(e,
|
|
119
|
-
const
|
|
120
|
-
clearTimeout(
|
|
123
|
+
p(e, N);
|
|
124
|
+
const y = setTimeout(() => {
|
|
125
|
+
clearTimeout(y), document.body.style.overflow = "hidden", d();
|
|
121
126
|
}, 800);
|
|
122
|
-
r.current.push(
|
|
127
|
+
r.current.push(y);
|
|
123
128
|
},
|
|
124
129
|
[n, u, d, e, p]
|
|
125
|
-
),
|
|
130
|
+
), I = J(
|
|
126
131
|
() => ({
|
|
127
132
|
blockSectionRef: t,
|
|
128
133
|
downloadCoreBlockRef: s,
|
|
@@ -130,11 +135,11 @@ const z = () => {
|
|
|
130
135
|
}),
|
|
131
136
|
[O]
|
|
132
137
|
);
|
|
133
|
-
return
|
|
138
|
+
return S(() => () => {
|
|
134
139
|
r.current.forEach((l) => clearTimeout(l)), r.current = [];
|
|
135
|
-
}, []),
|
|
140
|
+
}, []), I;
|
|
136
141
|
};
|
|
137
142
|
export {
|
|
138
|
-
|
|
143
|
+
F as useDownloadNodeJourney
|
|
139
144
|
};
|
|
140
145
|
//# sourceMappingURL=use-download-node-journey.js.map
|
package/dist/features/journey/hooks/use-chapter-page-journey/use-download-node-journey.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-download-node-journey.js","sources":["../../../../../src/features/journey/hooks/use-chapter-page-journey/use-download-node-journey.tsx"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef } from 'react';\n\nimport BlockSectionView from '../../../chapters-v2/chapter-details/block-sections/block-section-view';\nimport { getHasDownloadBlock } from '../../../chapters-v2/utils';\nimport type { IArrowTooltipProps } from '../../../ui/arrow-tooltip/arrow-tooltip-types';\nimport FlexView from '../../../ui/layout/flex-view';\nimport Text from '../../../ui/text/text';\nimport { JOURNEY_ID_STUDENT } from '../../journey-id/journey-id-student';\nimport {\n BLOCK_MOCKS_WITH_DOWNLOAD_NODE,\n DOWNLOAD_BLOCK_MOCKS,\n} from '../../mocks/chapter-page-journey-mock-data';\nimport { IndicatorType } from '../../use-journey/constants';\nimport type { TCoachmarkJourneyProps } from '../../use-journey/journey-context-types';\nimport { useJourney } from '../../use-journey/use-journey';\nimport TooltipItem from '../use-home-page-journey/tooltip-item';\nimport type { IChallengeArenaStartJourneyProps } from './chapter-page-types';\n\nexport const useDownloadNodeJourney = () => {\n const journeyId = JOURNEY_ID_STUDENT.DOWNLOAD_NODE_JOURNEY;\n\n const journeyRef = useRef<HTMLDivElement>(null) as React.RefObject<HTMLDivElement>;\n\n const downloadCoreBlockRef = useRef<HTMLDivElement>(null) as React.RefObject<HTMLDivElement>;\n const blockSectionRef = useRef<HTMLDivElement>(null) as React.RefObject<HTMLDivElement>;\n const timerRefs = useRef<ReturnType<typeof setTimeout>[]>([]);\n\n const { nextCoachmark, setJourney, endJourney } = useJourney();\n\n const handleNextCoachmark = useCallback(() => {\n nextCoachmark(journeyId, false, 0, true);\n }, [journeyId, nextCoachmark]);\n\n const handleEndJourney = useCallback(() => {\n document.body.style.overflow = 'unset';\n endJourney(journeyId);\n }, [endJourney, journeyId]);\n\n const startJourney = useCallback(\n ({\n chapterDetails,\n userType,\n canStartDownloadBlockJourney,\n }: IChallengeArenaStartJourneyProps) => {\n if (!chapterDetails || !downloadCoreBlockRef.current) {\n return;\n }\n\n const { image_hue: imageHue, blocks } = chapterDetails;\n const hasDownloadBlock = canStartDownloadBlockJourney && getHasDownloadBlock(blocks);\n\n if (hasDownloadBlock && !blockSectionRef.current) return;\n\n const downloadNodeJourneySteps: TCoachmarkJourneyProps[] = [\n {\n originalElementToHighlightRef: downloadCoreBlockRef,\n elementToHighlight: (\n <FlexView $widthX={50} ref={journeyRef}>\n <BlockSectionView\n blockData={BLOCK_MOCKS_WITH_DOWNLOAD_NODE}\n userType={userType}\n isLastBlock={true}\n lessonIdx={0}\n imageHue={imageHue}\n isGoalBlock\n />\n </FlexView>\n ),\n type: IndicatorType.TOOLTIP,\n indicator: {\n position: 'bottom',\n tooltipYCoOrdinates: -84,\n tooltipXCoOrdinates: '127%',\n backgroundColor: 'PURPLE_4',\n borderColor: 'BLACK',\n arrowColor: 'BLACK',\n arrowSize: 12,\n arrowXCoOrdinates: -100,\n width: 264,\n children: null,\n renderAs: 'primary',\n tooltipItem: (\n <TooltipItem\n element={\n <FlexView>\n <Text $renderAs=\"ab2-black\">Introducing downloadable study material.</Text>\n </FlexView>\n }\n buttonLabel={hasDownloadBlock ? 'Next' : 'Got it'}\n onButtonClick={() => {\n if (hasDownloadBlock) {\n const $parentEle = document.getElementById('tooltip-root');\n\n if ($parentEle) {\n // Hide all direct children of tooltip-root\n Array.from($parentEle.children).forEach(child => {\n (child as HTMLElement).style.display = 'none';\n });\n }\n\n if (journeyRef.current) {\n journeyRef.current.style.display = 'none';\n }\n\n if (blockSectionRef.current) {\n blockSectionRef.current.scrollIntoView({\n behavior: 'smooth',\n block: 'center',\n inline: 'center',\n });\n }\n\n const delayBeforeStart = setTimeout(() => {\n clearTimeout(delayBeforeStart);\n\n handleNextCoachmark();\n }, 800);\n\n timerRefs.current.push(delayBeforeStart);\n } else {\n handleEndJourney();\n }\n }}\n />\n ),\n } as IArrowTooltipProps,\n },\n {\n originalElementToHighlightRef: blockSectionRef,\n elementToHighlight: (\n <FlexView $widthX={50}>\n <BlockSectionView\n blockData={DOWNLOAD_BLOCK_MOCKS}\n userType={userType}\n isLastBlock={true}\n lessonIdx={0}\n imageHue={imageHue}\n />\n </FlexView>\n ),\n type: IndicatorType.TOOLTIP,\n indicator: {\n position: 'top',\n tooltipYCoOrdinates: 14,\n tooltipXCoOrdinates: '-100%',\n backgroundColor: 'BLUE_4',\n borderColor: 'BLACK',\n arrowColor: 'BLACK',\n arrowSize: 12,\n arrowXCoOrdinates: -100,\n width: 264,\n children: null,\n renderAs: 'primary',\n tooltipItem: (\n <TooltipItem\n element={\n <FlexView>\n <Text $renderAs=\"ab2-black\">Also available in the Downloads section.</Text>\n </FlexView>\n }\n buttonLabel=\"Got it\"\n onButtonClick={() => {\n handleEndJourney();\n endJourney(JOURNEY_ID_STUDENT.DOWNLOAD_BLOCK_JOURNEY);\n }}\n />\n ),\n } as IArrowTooltipProps,\n },\n ];\n\n setJourney(journeyId, downloadNodeJourneySteps);\n\n const delayBeforeStart = setTimeout(() => {\n clearTimeout(delayBeforeStart);\n\n document.body.style.overflow = 'hidden';\n handleNextCoachmark();\n }, 800);\n\n timerRefs.current.push(delayBeforeStart);\n },\n [endJourney, handleEndJourney, handleNextCoachmark, journeyId, setJourney],\n );\n\n const data = useMemo(\n () => ({\n blockSectionRef,\n downloadCoreBlockRef,\n startJourney,\n }),\n [startJourney],\n );\n\n useEffect(() => {\n return () => {\n timerRefs.current.forEach(timer => clearTimeout(timer));\n timerRefs.current = [];\n };\n }, []);\n\n return data;\n};\n"],"names":["useDownloadNodeJourney","journeyId","JOURNEY_ID_STUDENT","journeyRef","useRef","downloadCoreBlockRef","blockSectionRef","timerRefs","nextCoachmark","setJourney","endJourney","useJourney","handleNextCoachmark","useCallback","handleEndJourney","startJourney","chapterDetails","userType","canStartDownloadBlockJourney","imageHue","blocks","hasDownloadBlock","getHasDownloadBlock","downloadNodeJourneySteps","jsx","FlexView","BlockSectionView","BLOCK_MOCKS_WITH_DOWNLOAD_NODE","IndicatorType","TooltipItem","Text","$parentEle","child","delayBeforeStart","DOWNLOAD_BLOCK_MOCKS","data","useMemo","useEffect","timer"],"mappings":";;;;;;;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;AAAA,YACb,YAAY;AAAA,YACZ,WAAW;AAAA,YACX,mBAAmB;AAAA,YACnB,OAAO;AAAA,YACP,UAAU;AAAA,YACV,UAAU;AAAA,YACV,aACE,gBAAAJ;AAAA,cAACK;AAAA,cAAA;AAAA,gBACC,2BACGJ,GACC,EAAA,UAAA,gBAAAD,EAACM,KAAK,WAAU,aAAY,sDAAwC,EACtE,CAAA;AAAA,gBAEF,aAAY;AAAA,gBACZ,eAAe,MAAM;AACF,kBAAAhB,KACjBJ,EAAWR,EAAmB,sBAAsB;AAAA,gBACtD;AAAA,cAAA;AAAA,YACF;AAAA,UAEJ;AAAA,QACF;AAAA,MAAA;AAGF,MAAAO,EAAWR,GAAWsB,CAAwB;AAExC,YAAAU,IAAmB,WAAW,MAAM;AACxC,qBAAaA,CAAgB,GAEpB,SAAA,KAAK,MAAM,WAAW,UACXrB;SACnB,GAAG;AAEI,MAAAL,EAAA,QAAQ,KAAK0B,CAAgB;AAAA,IACzC;AAAA,IACA,CAACvB,GAAYI,GAAkBF,GAAqBX,GAAWQ,CAAU;AAAA,EAAA,GAGrE0B,IAAOC;AAAA,IACX,OAAO;AAAA,MACL,iBAAA9B;AAAA,MACA,sBAAAD;AAAA,MACA,cAAAU;AAAA,IAAA;AAAA,IAEF,CAACA,CAAY;AAAA,EAAA;AAGf,SAAAsB,EAAU,MACD,MAAM;AACX,IAAA9B,EAAU,QAAQ,QAAQ,CAAS+B,MAAA,aAAaA,CAAK,CAAC,GACtD/B,EAAU,UAAU;EAAC,GAEtB,CAAE,CAAA,GAEE4B;AACT;"}
|
|
1
|
+
{"version":3,"file":"use-download-node-journey.js","sources":["../../../../../src/features/journey/hooks/use-chapter-page-journey/use-download-node-journey.tsx"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef } from 'react';\n\nimport BlockSectionView from '../../../chapters-v2/chapter-details/block-sections/block-section-view';\nimport { getHasDownloadBlock } from '../../../chapters-v2/utils';\nimport type { IArrowTooltipProps } from '../../../ui/arrow-tooltip/arrow-tooltip-types';\nimport FlexView from '../../../ui/layout/flex-view';\nimport Text from '../../../ui/text/text';\nimport { JOURNEY_ID_STUDENT } from '../../journey-id/journey-id-student';\nimport {\n BLOCK_MOCKS_WITH_DOWNLOAD_NODE,\n DOWNLOAD_BLOCK_MOCKS,\n} from '../../mocks/chapter-page-journey-mock-data';\nimport { IndicatorType } from '../../use-journey/constants';\nimport type { TCoachmarkJourneyProps } from '../../use-journey/journey-context-types';\nimport { useJourney } from '../../use-journey/use-journey';\nimport TooltipItem from '../use-home-page-journey/tooltip-item';\nimport type { IChallengeArenaStartJourneyProps } from './chapter-page-types';\n\nexport const useDownloadNodeJourney = () => {\n const journeyId = JOURNEY_ID_STUDENT.DOWNLOAD_NODE_JOURNEY;\n\n const journeyRef = useRef<HTMLDivElement>(null) as React.RefObject<HTMLDivElement>;\n\n const downloadCoreBlockRef = useRef<HTMLDivElement>(null) as React.RefObject<HTMLDivElement>;\n const blockSectionRef = useRef<HTMLDivElement>(null) as React.RefObject<HTMLDivElement>;\n const timerRefs = useRef<ReturnType<typeof setTimeout>[]>([]);\n\n const { nextCoachmark, setJourney, endJourney } = useJourney();\n\n const handleNextCoachmark = useCallback(() => {\n nextCoachmark(journeyId, false, 0, true);\n }, [journeyId, nextCoachmark]);\n\n const handleEndJourney = useCallback(() => {\n document.body.style.overflow = 'unset';\n endJourney(journeyId);\n }, [endJourney, journeyId]);\n\n const startJourney = useCallback(\n ({\n chapterDetails,\n userType,\n canStartDownloadBlockJourney,\n }: IChallengeArenaStartJourneyProps) => {\n if (!chapterDetails || !downloadCoreBlockRef.current) {\n return;\n }\n\n const { image_hue: imageHue, blocks } = chapterDetails;\n const hasDownloadBlock = canStartDownloadBlockJourney && getHasDownloadBlock(blocks);\n\n if (hasDownloadBlock && !blockSectionRef.current) return;\n\n blockSectionRef.current?.scrollIntoView({\n behavior: 'smooth',\n block: 'nearest',\n });\n\n const downloadNodeJourneySteps: TCoachmarkJourneyProps[] = [\n {\n originalElementToHighlightRef: downloadCoreBlockRef,\n elementToHighlight: (\n <FlexView $widthX={50} ref={journeyRef}>\n <BlockSectionView\n blockData={BLOCK_MOCKS_WITH_DOWNLOAD_NODE}\n userType={userType}\n isLastBlock={true}\n lessonIdx={0}\n imageHue={imageHue}\n isGoalBlock\n />\n </FlexView>\n ),\n type: IndicatorType.TOOLTIP,\n indicator: {\n position: 'bottom',\n tooltipYCoOrdinates: -84,\n tooltipXCoOrdinates: '127%',\n backgroundColor: 'PURPLE_4',\n borderColor: 'BLACK',\n arrowColor: 'BLACK',\n arrowSize: 12,\n arrowXCoOrdinates: -100,\n width: 264,\n children: null,\n renderAs: 'primary',\n tooltipItem: (\n <TooltipItem\n element={\n <FlexView>\n <Text $renderAs=\"ab2-black\">Introducing downloadable study material.</Text>\n </FlexView>\n }\n buttonLabel={hasDownloadBlock ? 'Next' : 'Got it'}\n onButtonClick={() => {\n if (hasDownloadBlock) {\n const $parentEle = document.getElementById('tooltip-root');\n\n if ($parentEle) {\n // Hide all direct children of tooltip-root\n Array.from($parentEle.children).forEach(child => {\n (child as HTMLElement).style.display = 'none';\n });\n }\n\n if (journeyRef.current) {\n journeyRef.current.style.display = 'none';\n }\n\n if (blockSectionRef.current) {\n blockSectionRef.current.scrollIntoView({\n behavior: 'smooth',\n block: 'center',\n inline: 'center',\n });\n }\n\n const delayBeforeStart = setTimeout(() => {\n clearTimeout(delayBeforeStart);\n\n handleNextCoachmark();\n }, 800);\n\n timerRefs.current.push(delayBeforeStart);\n } else {\n handleEndJourney();\n }\n }}\n />\n ),\n } as IArrowTooltipProps,\n },\n {\n originalElementToHighlightRef: blockSectionRef,\n elementToHighlight: (\n <FlexView $widthX={50}>\n <BlockSectionView\n blockData={DOWNLOAD_BLOCK_MOCKS}\n userType={userType}\n isLastBlock={true}\n lessonIdx={0}\n imageHue={imageHue}\n />\n </FlexView>\n ),\n type: IndicatorType.TOOLTIP,\n indicator: {\n position: 'top',\n tooltipYCoOrdinates: 14,\n tooltipXCoOrdinates: '-100%',\n backgroundColor: 'BLUE_4',\n borderColor: 'BLACK',\n arrowColor: 'BLACK',\n arrowSize: 12,\n arrowXCoOrdinates: -100,\n width: 264,\n children: null,\n renderAs: 'primary',\n tooltipItem: (\n <TooltipItem\n element={\n <FlexView>\n <Text $renderAs=\"ab2-black\">Also available in the Downloads section.</Text>\n </FlexView>\n }\n buttonLabel=\"Got it\"\n onButtonClick={() => {\n handleEndJourney();\n endJourney(JOURNEY_ID_STUDENT.DOWNLOAD_BLOCK_JOURNEY);\n }}\n />\n ),\n } as IArrowTooltipProps,\n },\n ];\n\n setJourney(journeyId, downloadNodeJourneySteps);\n\n const delayBeforeStart = setTimeout(() => {\n clearTimeout(delayBeforeStart);\n\n document.body.style.overflow = 'hidden';\n handleNextCoachmark();\n }, 800);\n\n timerRefs.current.push(delayBeforeStart);\n },\n [endJourney, handleEndJourney, handleNextCoachmark, journeyId, setJourney],\n );\n\n const data = useMemo(\n () => ({\n blockSectionRef,\n downloadCoreBlockRef,\n startJourney,\n }),\n [startJourney],\n );\n\n useEffect(() => {\n return () => {\n timerRefs.current.forEach(timer => clearTimeout(timer));\n timerRefs.current = [];\n };\n }, []);\n\n return data;\n};\n"],"names":["useDownloadNodeJourney","journeyId","JOURNEY_ID_STUDENT","journeyRef","useRef","downloadCoreBlockRef","blockSectionRef","timerRefs","nextCoachmark","setJourney","endJourney","useJourney","handleNextCoachmark","useCallback","handleEndJourney","startJourney","chapterDetails","userType","canStartDownloadBlockJourney","imageHue","blocks","hasDownloadBlock","getHasDownloadBlock","_a","downloadNodeJourneySteps","jsx","FlexView","BlockSectionView","BLOCK_MOCKS_WITH_DOWNLOAD_NODE","IndicatorType","TooltipItem","Text","$parentEle","child","delayBeforeStart","DOWNLOAD_BLOCK_MOCKS","data","useMemo","useEffect","timer"],"mappings":";;;;;;;;;;;AAkBO,MAAMA,IAAyB,MAAM;AAC1C,QAAMC,IAAYC,EAAmB,uBAE/BC,IAAaC,EAAuB,IAAI,GAExCC,IA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