@graphlearning/shell 0.6.0 → 0.8.0
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/README.md +17 -0
- package/dist/NarrationBar.d.ts +4 -0
- package/dist/SectionView.d.ts +2 -1
- package/dist/index.js +324 -256
- package/dist/index.js.map +1 -1
- package/dist/styles.css +99 -4
- package/dist/useNarration.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,384 +1,452 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { SceneView as
|
|
4
|
-
import { Home as
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
function
|
|
8
|
-
return `${
|
|
1
|
+
import { jsx as t, jsxs as h, Fragment as H } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as T, useState as b, useLayoutEffect as O, useEffect as k, useCallback as I, useMemo as M } from "react";
|
|
3
|
+
import { SceneView as R } from "@graphlearning/flow";
|
|
4
|
+
import { Home as Y, Volume2 as Z, VolumeX as J, Moon as Q, Sun as U, ChevronLeft as ee, ChevronRight as te } from "lucide-react";
|
|
5
|
+
import ne from "react-markdown";
|
|
6
|
+
import ae from "remark-gfm";
|
|
7
|
+
function X(e, a) {
|
|
8
|
+
return `${e.id}-${a.id}`;
|
|
9
9
|
}
|
|
10
|
-
function
|
|
11
|
-
return
|
|
10
|
+
function D(e) {
|
|
11
|
+
return e.sections.map((a) => ({ section: a, slug: X(e, a) }));
|
|
12
12
|
}
|
|
13
|
-
const
|
|
14
|
-
function
|
|
15
|
-
const
|
|
16
|
-
return
|
|
17
|
-
const o =
|
|
13
|
+
const G = 806;
|
|
14
|
+
function re() {
|
|
15
|
+
const e = T(null), [a, s] = b(1);
|
|
16
|
+
return O(() => {
|
|
17
|
+
const o = e.current;
|
|
18
18
|
if (!o) return;
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
return
|
|
23
|
-
}, []), { ref:
|
|
19
|
+
const d = () => s(o.clientWidth / G);
|
|
20
|
+
d();
|
|
21
|
+
const g = new ResizeObserver(d);
|
|
22
|
+
return g.observe(o), () => g.disconnect();
|
|
23
|
+
}, []), { ref: e, zoom: a };
|
|
24
|
+
}
|
|
25
|
+
function se({ slide: e, open: a }) {
|
|
26
|
+
const { ref: s, zoom: o } = re();
|
|
27
|
+
return /* @__PURE__ */ t("aside", { ref: s, className: `slide-panel${a ? " slide-panel--open" : ""}`, children: /* @__PURE__ */ t("div", { className: "slide-panel__scaler", style: { width: G, zoom: o }, children: /* @__PURE__ */ t(ne, { remarkPlugins: [ae], children: e }) }) });
|
|
28
|
+
}
|
|
29
|
+
const z = 10;
|
|
30
|
+
function ie({ audio: e }) {
|
|
31
|
+
const [a, s] = b(0), [o, d] = b(0), g = T(null);
|
|
32
|
+
if (k(() => {
|
|
33
|
+
if (!e) return;
|
|
34
|
+
const n = () => {
|
|
35
|
+
s(e.currentTime), d(Number.isFinite(e.duration) ? e.duration : 0);
|
|
36
|
+
};
|
|
37
|
+
n();
|
|
38
|
+
const u = ["loadedmetadata", "durationchange", "timeupdate", "seeked", "ended", "emptied", "error"];
|
|
39
|
+
return u.forEach((r) => e.addEventListener(r, n)), () => u.forEach((r) => e.removeEventListener(r, n));
|
|
40
|
+
}, [e]), !e || !o) return null;
|
|
41
|
+
const f = (n) => {
|
|
42
|
+
const u = g.current;
|
|
43
|
+
if (!u) return;
|
|
44
|
+
const r = u.getBoundingClientRect(), m = Math.min(1, Math.max(0, (n - r.left) / r.width));
|
|
45
|
+
e.currentTime = m * o, s(e.currentTime);
|
|
46
|
+
}, l = (n) => {
|
|
47
|
+
const u = (r) => {
|
|
48
|
+
n.preventDefault(), n.stopPropagation(), e.currentTime = Math.min(o, Math.max(0, e.currentTime + r)), s(e.currentTime);
|
|
49
|
+
};
|
|
50
|
+
n.key === "ArrowLeft" ? u(-z) : n.key === "ArrowRight" ? u(z) : n.key === "Home" ? u(-o) : n.key === "End" && u(o);
|
|
51
|
+
}, p = `${Math.min(100, a / o * 100)}%`;
|
|
52
|
+
return /* @__PURE__ */ h("span", { className: "reel-foot__audio", children: [
|
|
53
|
+
/* @__PURE__ */ t("span", { className: "reel-foot__count reel-foot__time", children: A(a) }),
|
|
54
|
+
/* @__PURE__ */ h(
|
|
55
|
+
"div",
|
|
56
|
+
{
|
|
57
|
+
ref: g,
|
|
58
|
+
className: "reel-foot__track",
|
|
59
|
+
role: "slider",
|
|
60
|
+
tabIndex: 0,
|
|
61
|
+
"aria-label": "Narration position",
|
|
62
|
+
"aria-valuemin": 0,
|
|
63
|
+
"aria-valuemax": Math.round(o),
|
|
64
|
+
"aria-valuenow": Math.round(a),
|
|
65
|
+
"aria-valuetext": `${A(a)} of ${A(o)}`,
|
|
66
|
+
onKeyDown: l,
|
|
67
|
+
onPointerDown: (n) => {
|
|
68
|
+
n.currentTarget.setPointerCapture(n.pointerId), f(n.clientX);
|
|
69
|
+
},
|
|
70
|
+
onPointerMove: (n) => {
|
|
71
|
+
n.currentTarget.hasPointerCapture(n.pointerId) && f(n.clientX);
|
|
72
|
+
},
|
|
73
|
+
children: [
|
|
74
|
+
/* @__PURE__ */ t("span", { className: "reel-foot__fill", style: { width: p } }),
|
|
75
|
+
/* @__PURE__ */ t("span", { className: "reel-foot__thumb", style: { left: p } })
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
),
|
|
79
|
+
/* @__PURE__ */ t("span", { className: "reel-foot__count reel-foot__time", children: A(o) })
|
|
80
|
+
] });
|
|
24
81
|
}
|
|
25
|
-
function
|
|
26
|
-
const
|
|
27
|
-
return
|
|
82
|
+
function A(e) {
|
|
83
|
+
const a = Number.isFinite(e) && e > 0 ? e : 0;
|
|
84
|
+
return `${Math.floor(a / 60)}:${String(Math.floor(a % 60)).padStart(2, "0")}`;
|
|
28
85
|
}
|
|
29
|
-
function
|
|
30
|
-
section:
|
|
31
|
-
getScene:
|
|
86
|
+
function oe({
|
|
87
|
+
section: e,
|
|
88
|
+
getScene: a,
|
|
32
89
|
capture: s = !1,
|
|
33
90
|
eyebrow: o,
|
|
34
|
-
index:
|
|
35
|
-
total:
|
|
36
|
-
onHome:
|
|
37
|
-
onPrev:
|
|
38
|
-
onNext:
|
|
39
|
-
narrating:
|
|
40
|
-
onToggleNarration:
|
|
41
|
-
|
|
42
|
-
|
|
91
|
+
index: d = 0,
|
|
92
|
+
total: g = 0,
|
|
93
|
+
onHome: f,
|
|
94
|
+
onPrev: l,
|
|
95
|
+
onNext: p,
|
|
96
|
+
narrating: n = !1,
|
|
97
|
+
onToggleNarration: u,
|
|
98
|
+
narrationAudio: r = null,
|
|
99
|
+
theme: m = "dark",
|
|
100
|
+
onToggleTheme: v
|
|
43
101
|
}) {
|
|
44
|
-
const [
|
|
45
|
-
return
|
|
46
|
-
/* @__PURE__ */
|
|
47
|
-
o && /* @__PURE__ */
|
|
48
|
-
/* @__PURE__ */
|
|
102
|
+
const [_, w] = b(!1), E = a(e.scene);
|
|
103
|
+
return E ? /* @__PURE__ */ h("div", { className: "stage stage--section", children: [
|
|
104
|
+
/* @__PURE__ */ h("header", { className: "reel-head", children: [
|
|
105
|
+
o && /* @__PURE__ */ t("button", { className: "reel-head__eyebrow", onClick: f, "aria-label": "Back to catalog (Esc)", title: "Back to catalog (Esc)", children: o }),
|
|
106
|
+
/* @__PURE__ */ t("h1", { className: "reel-head__title", children: e.title })
|
|
49
107
|
] }),
|
|
50
|
-
!s && /* @__PURE__ */
|
|
51
|
-
/* @__PURE__ */
|
|
52
|
-
/* @__PURE__ */
|
|
53
|
-
/* @__PURE__ */
|
|
108
|
+
!s && /* @__PURE__ */ h("footer", { className: "reel-foot reel-foot--controls", children: [
|
|
109
|
+
/* @__PURE__ */ h("span", { className: "reel-foot__grp", children: [
|
|
110
|
+
/* @__PURE__ */ t("button", { className: "reel-foot__ctrl", onClick: f, "aria-label": "Back to catalog (Esc)", title: "Back to catalog (Esc)", children: /* @__PURE__ */ t(Y, { size: 17 }) }),
|
|
111
|
+
/* @__PURE__ */ t(
|
|
54
112
|
"button",
|
|
55
113
|
{
|
|
56
114
|
className: "reel-foot__ctrl",
|
|
57
|
-
onClick:
|
|
58
|
-
"aria-label":
|
|
59
|
-
title:
|
|
60
|
-
children:
|
|
115
|
+
onClick: u,
|
|
116
|
+
"aria-label": n ? "Pause narration (Space)" : "Play narration (Space)",
|
|
117
|
+
title: n ? "Pause narration (Space)" : "Play narration (Space)",
|
|
118
|
+
children: n ? /* @__PURE__ */ t(Z, { size: 18 }) : /* @__PURE__ */ t(J, { size: 18 })
|
|
61
119
|
}
|
|
62
120
|
),
|
|
63
|
-
|
|
121
|
+
v && /* @__PURE__ */ t(
|
|
64
122
|
"button",
|
|
65
123
|
{
|
|
66
124
|
className: "reel-foot__ctrl",
|
|
67
|
-
onClick:
|
|
68
|
-
"aria-label":
|
|
69
|
-
title:
|
|
70
|
-
children:
|
|
125
|
+
onClick: v,
|
|
126
|
+
"aria-label": m === "dark" ? "Dark theme. Switch to light theme." : "Light theme. Switch to dark theme.",
|
|
127
|
+
title: m === "dark" ? "Dark theme. Switch to light theme." : "Light theme. Switch to dark theme.",
|
|
128
|
+
children: m === "dark" ? /* @__PURE__ */ t(Q, { size: 17 }) : /* @__PURE__ */ t(U, { size: 17 })
|
|
71
129
|
}
|
|
72
130
|
)
|
|
73
131
|
] }),
|
|
74
|
-
/* @__PURE__ */
|
|
75
|
-
|
|
76
|
-
/* @__PURE__ */
|
|
77
|
-
|
|
132
|
+
/* @__PURE__ */ t(ie, { audio: r }),
|
|
133
|
+
/* @__PURE__ */ h("span", { className: "reel-foot__nav", children: [
|
|
134
|
+
/* @__PURE__ */ t("button", { className: "reel-foot__ctrl", onClick: l, "aria-label": "Previous section (Shift+←)", title: "Previous section (Shift+←)", children: /* @__PURE__ */ t(ee, { size: 19 }) }),
|
|
135
|
+
/* @__PURE__ */ h("span", { className: "reel-foot__count reel-foot__count--live", children: [
|
|
136
|
+
d + 1,
|
|
78
137
|
" / ",
|
|
79
|
-
|
|
138
|
+
g
|
|
80
139
|
] }),
|
|
81
|
-
/* @__PURE__ */
|
|
140
|
+
/* @__PURE__ */ t("button", { className: "reel-foot__ctrl", onClick: p, "aria-label": "Next section (Shift+→)", title: "Next section (Shift+→)", children: /* @__PURE__ */ t(te, { size: 19 }) })
|
|
82
141
|
] })
|
|
83
142
|
] }),
|
|
84
|
-
/* @__PURE__ */
|
|
85
|
-
!s && /* @__PURE__ */
|
|
143
|
+
/* @__PURE__ */ t("div", { className: "scene-area", children: /* @__PURE__ */ t(R, { scene: E, focusId: e.focus, theme: m }) }),
|
|
144
|
+
!s && /* @__PURE__ */ t(
|
|
86
145
|
"button",
|
|
87
146
|
{
|
|
88
147
|
className: "slide-toggle",
|
|
89
|
-
onClick: () =>
|
|
90
|
-
"aria-label":
|
|
91
|
-
children:
|
|
148
|
+
onClick: () => w((S) => !S),
|
|
149
|
+
"aria-label": _ ? "Hide slide" : "Show slide",
|
|
150
|
+
children: _ ? "›" : "‹"
|
|
92
151
|
}
|
|
93
152
|
),
|
|
94
|
-
/* @__PURE__ */
|
|
95
|
-
] }) : /* @__PURE__ */
|
|
153
|
+
/* @__PURE__ */ t(se, { slide: e.slide, open: _ })
|
|
154
|
+
] }) : /* @__PURE__ */ h("div", { className: "stage stage--missing", children: [
|
|
96
155
|
"no scene: ",
|
|
97
|
-
|
|
156
|
+
e.scene
|
|
98
157
|
] });
|
|
99
158
|
}
|
|
100
|
-
const
|
|
159
|
+
const le = [
|
|
101
160
|
{ id: "courses", label: "Courses" },
|
|
102
161
|
{ id: "labs", label: "Labs" },
|
|
103
162
|
{ id: "coach", label: "Coach" }
|
|
104
163
|
];
|
|
105
|
-
function
|
|
106
|
-
return /* @__PURE__ */
|
|
107
|
-
/* @__PURE__ */
|
|
108
|
-
/* @__PURE__ */
|
|
109
|
-
/* @__PURE__ */
|
|
110
|
-
/* @__PURE__ */
|
|
164
|
+
function ce() {
|
|
165
|
+
return /* @__PURE__ */ h("svg", { className: "site__logo", width: "28", height: "28", viewBox: "0 0 512 512", "aria-hidden": "true", children: [
|
|
166
|
+
/* @__PURE__ */ t("rect", { width: "512", height: "512", rx: "80", fill: "#e8804f" }),
|
|
167
|
+
/* @__PURE__ */ h("g", { fill: "none", stroke: "#ffffff", strokeWidth: "58", strokeLinecap: "butt", strokeLinejoin: "miter", children: [
|
|
168
|
+
/* @__PURE__ */ t("path", { d: "M 373 200 A 130 130 0 1 0 373 312" }),
|
|
169
|
+
/* @__PURE__ */ t("path", { d: "M 283 312 L 373 312 L 373 410" })
|
|
111
170
|
] })
|
|
112
171
|
] });
|
|
113
172
|
}
|
|
114
|
-
function
|
|
115
|
-
kind:
|
|
116
|
-
nav:
|
|
173
|
+
function de({
|
|
174
|
+
kind: e = "courses",
|
|
175
|
+
nav: a = le,
|
|
117
176
|
home: s = "/",
|
|
118
177
|
actions: o
|
|
119
178
|
}) {
|
|
120
|
-
return /* @__PURE__ */
|
|
121
|
-
/* @__PURE__ */
|
|
122
|
-
/* @__PURE__ */
|
|
123
|
-
/* @__PURE__ */
|
|
179
|
+
return /* @__PURE__ */ t("header", { className: "site", children: /* @__PURE__ */ h("div", { className: "site__inner", children: [
|
|
180
|
+
/* @__PURE__ */ h("a", { className: "site__brand", href: s, children: [
|
|
181
|
+
/* @__PURE__ */ t(ce, {}),
|
|
182
|
+
/* @__PURE__ */ t("span", { className: "site__name", children: "GraphL" })
|
|
124
183
|
] }),
|
|
125
|
-
/* @__PURE__ */
|
|
184
|
+
/* @__PURE__ */ t("nav", { className: "site__nav", "aria-label": "Sections", children: a.map((d) => /* @__PURE__ */ t(
|
|
126
185
|
"a",
|
|
127
186
|
{
|
|
128
187
|
className: "site__link",
|
|
129
|
-
href: `${s}#${
|
|
130
|
-
...
|
|
131
|
-
children:
|
|
188
|
+
href: `${s}#${d.id}`,
|
|
189
|
+
...d.id === e ? { "aria-current": "page" } : {},
|
|
190
|
+
children: d.label
|
|
132
191
|
},
|
|
133
|
-
|
|
192
|
+
d.id
|
|
134
193
|
)) }),
|
|
135
|
-
/* @__PURE__ */
|
|
194
|
+
/* @__PURE__ */ t("div", { className: "site__actions", children: o })
|
|
136
195
|
] }) });
|
|
137
196
|
}
|
|
138
|
-
function
|
|
139
|
-
courses:
|
|
140
|
-
subject:
|
|
197
|
+
function he({
|
|
198
|
+
courses: e,
|
|
199
|
+
subject: a,
|
|
141
200
|
kind: s,
|
|
142
201
|
actions: o
|
|
143
202
|
}) {
|
|
144
|
-
const [
|
|
145
|
-
const
|
|
146
|
-
return
|
|
203
|
+
const [d, g] = b(() => /* @__PURE__ */ new Set()), f = (l) => g((p) => {
|
|
204
|
+
const n = new Set(p);
|
|
205
|
+
return n.has(l) ? n.delete(l) : n.add(l), n;
|
|
147
206
|
});
|
|
148
207
|
return (
|
|
149
208
|
// The site bar is a SIBLING of .idx, not a child: it is full-bleed (its rule spans the
|
|
150
209
|
// viewport) while .idx is a 940px centred column. Both use the same width and gutters, so the
|
|
151
210
|
// brand lines up with the card edge below it.
|
|
152
|
-
/* @__PURE__ */
|
|
153
|
-
/* @__PURE__ */
|
|
154
|
-
/* @__PURE__ */
|
|
155
|
-
/* @__PURE__ */
|
|
156
|
-
|
|
157
|
-
const
|
|
158
|
-
return /* @__PURE__ */
|
|
159
|
-
/* @__PURE__ */
|
|
211
|
+
/* @__PURE__ */ h(H, { children: [
|
|
212
|
+
/* @__PURE__ */ t(de, { kind: s, actions: o }),
|
|
213
|
+
/* @__PURE__ */ h("div", { className: "idx", children: [
|
|
214
|
+
/* @__PURE__ */ t("header", { className: "idx__head", children: /* @__PURE__ */ t("h1", { className: "idx__subject", children: a }) }),
|
|
215
|
+
e.length === 0 ? /* @__PURE__ */ t("p", { className: "idx__empty", children: "No courses authored yet — the app shell is ready." }) : /* @__PURE__ */ t("ol", { className: "idx__grid", children: e.map((l, p) => {
|
|
216
|
+
const n = D(l), u = d.has(l.id);
|
|
217
|
+
return /* @__PURE__ */ h("li", { className: `idx-card${u ? " idx-card--open" : ""}`, children: [
|
|
218
|
+
/* @__PURE__ */ h(
|
|
160
219
|
"button",
|
|
161
220
|
{
|
|
162
221
|
className: "idx-card__head",
|
|
163
|
-
onClick: () =>
|
|
164
|
-
"aria-expanded":
|
|
222
|
+
onClick: () => f(l.id),
|
|
223
|
+
"aria-expanded": u,
|
|
165
224
|
children: [
|
|
166
|
-
/* @__PURE__ */
|
|
167
|
-
/* @__PURE__ */
|
|
168
|
-
/* @__PURE__ */
|
|
169
|
-
|
|
225
|
+
/* @__PURE__ */ t("span", { className: "idx-card__num", children: String(p + 1).padStart(2, "0") }),
|
|
226
|
+
/* @__PURE__ */ t("span", { className: "idx-card__title", children: l.title }),
|
|
227
|
+
/* @__PURE__ */ h("span", { className: "idx-card__count", children: [
|
|
228
|
+
n.length,
|
|
170
229
|
" sections"
|
|
171
230
|
] }),
|
|
172
|
-
/* @__PURE__ */
|
|
231
|
+
/* @__PURE__ */ t("span", { className: "idx-card__toggle", "aria-hidden": "true", children: "⌄" })
|
|
173
232
|
]
|
|
174
233
|
}
|
|
175
234
|
),
|
|
176
|
-
|
|
177
|
-
/* @__PURE__ */
|
|
178
|
-
/* @__PURE__ */
|
|
179
|
-
/* @__PURE__ */
|
|
180
|
-
] }) },
|
|
181
|
-
] },
|
|
235
|
+
u && /* @__PURE__ */ t("ol", { className: "idx-sec", children: n.map(({ section: r, slug: m }, v) => /* @__PURE__ */ t("li", { className: "idx-sec__row", children: /* @__PURE__ */ h("a", { href: `#/${m}`, children: [
|
|
236
|
+
/* @__PURE__ */ t("span", { className: "idx-sec__num", children: v + 1 }),
|
|
237
|
+
/* @__PURE__ */ t("span", { className: "idx-sec__title", children: r.title }),
|
|
238
|
+
/* @__PURE__ */ t("span", { className: "idx-sec__chev", "aria-hidden": "true", children: "›" })
|
|
239
|
+
] }) }, m)) })
|
|
240
|
+
] }, l.id);
|
|
182
241
|
}) }),
|
|
183
|
-
/* @__PURE__ */
|
|
184
|
-
/* @__PURE__ */
|
|
242
|
+
/* @__PURE__ */ t("footer", { className: "idx__foot", children: /* @__PURE__ */ h("span", { className: "idx__hint", children: [
|
|
243
|
+
/* @__PURE__ */ t("kbd", { children: "→" }),
|
|
185
244
|
" next · ",
|
|
186
|
-
/* @__PURE__ */
|
|
245
|
+
/* @__PURE__ */ t("kbd", { children: "←" }),
|
|
187
246
|
" prev · ",
|
|
188
|
-
/* @__PURE__ */
|
|
247
|
+
/* @__PURE__ */ t("kbd", { children: "Space" }),
|
|
189
248
|
" narration"
|
|
190
249
|
] }) })
|
|
191
250
|
] })
|
|
192
251
|
] })
|
|
193
252
|
);
|
|
194
253
|
}
|
|
195
|
-
function
|
|
196
|
-
const s =
|
|
197
|
-
|
|
198
|
-
const [
|
|
199
|
-
return
|
|
200
|
-
const
|
|
201
|
-
return
|
|
202
|
-
}, []),
|
|
203
|
-
const
|
|
204
|
-
|
|
205
|
-
})) : (
|
|
206
|
-
}, [
|
|
207
|
-
const
|
|
208
|
-
!
|
|
209
|
-
}),
|
|
254
|
+
function ue(e, a) {
|
|
255
|
+
const s = T(null), [o, d] = b(null), g = T(a);
|
|
256
|
+
g.current = a;
|
|
257
|
+
const [f, l] = b(!1), p = T(f);
|
|
258
|
+
return p.current = f, k(() => {
|
|
259
|
+
const r = new Audio();
|
|
260
|
+
return r.addEventListener("ended", () => g.current()), r.addEventListener("error", () => l(!1)), s.current = r, d(r), () => r.pause();
|
|
261
|
+
}, []), k(() => {
|
|
262
|
+
const r = s.current;
|
|
263
|
+
r && (r.pause(), e ? (r.src = e, r.currentTime = 0, p.current && r.play().catch(() => {
|
|
264
|
+
})) : (r.removeAttribute("src"), r.load(), l(!1)));
|
|
265
|
+
}, [e]), { playing: f, toggle: () => {
|
|
266
|
+
const r = s.current;
|
|
267
|
+
!r || !r.getAttribute("src") || (p.current ? (r.pause(), l(!1)) : (r.play().catch(() => {
|
|
268
|
+
}), l(!0)));
|
|
210
269
|
}, stop: () => {
|
|
211
|
-
var
|
|
212
|
-
(
|
|
213
|
-
} };
|
|
270
|
+
var r;
|
|
271
|
+
(r = s.current) == null || r.pause(), l(!1);
|
|
272
|
+
}, audio: o };
|
|
214
273
|
}
|
|
215
|
-
const
|
|
216
|
-
function
|
|
274
|
+
const B = "graphl:theme";
|
|
275
|
+
function F() {
|
|
217
276
|
try {
|
|
218
|
-
const
|
|
219
|
-
return
|
|
277
|
+
const e = localStorage.getItem(B);
|
|
278
|
+
return e === "light" || e === "dark" ? e : null;
|
|
220
279
|
} catch {
|
|
221
280
|
return null;
|
|
222
281
|
}
|
|
223
282
|
}
|
|
224
|
-
function
|
|
283
|
+
function me(e) {
|
|
225
284
|
try {
|
|
226
|
-
localStorage.setItem(
|
|
285
|
+
localStorage.setItem(B, e);
|
|
227
286
|
} catch {
|
|
228
287
|
}
|
|
229
288
|
}
|
|
230
|
-
const
|
|
231
|
-
function
|
|
232
|
-
const [s, o] =
|
|
233
|
-
|
|
234
|
-
if (
|
|
235
|
-
const
|
|
236
|
-
(
|
|
289
|
+
const fe = (e, a, s) => s || !a ? e : a;
|
|
290
|
+
function ge(e, a) {
|
|
291
|
+
const [s, o] = b(() => a ? null : F()), d = fe(e, s, a);
|
|
292
|
+
k(() => (document.documentElement.setAttribute("data-theme", d), () => document.documentElement.removeAttribute("data-theme")), [d]), k(() => {
|
|
293
|
+
if (a) return;
|
|
294
|
+
const f = (l) => {
|
|
295
|
+
(l.key === B || l.key === null) && o(F());
|
|
237
296
|
};
|
|
238
|
-
return window.addEventListener("storage",
|
|
239
|
-
}, [
|
|
240
|
-
const
|
|
241
|
-
const
|
|
242
|
-
|
|
243
|
-
const
|
|
244
|
-
|
|
245
|
-
}, [
|
|
246
|
-
return { theme:
|
|
297
|
+
return window.addEventListener("storage", f), () => window.removeEventListener("storage", f);
|
|
298
|
+
}, [a]);
|
|
299
|
+
const g = I(() => {
|
|
300
|
+
const f = d === "dark" ? "light" : "dark";
|
|
301
|
+
me(f);
|
|
302
|
+
const l = document.documentElement;
|
|
303
|
+
l.classList.add("theme-swap"), o(f), requestAnimationFrame(() => requestAnimationFrame(() => l.classList.remove("theme-swap")));
|
|
304
|
+
}, [d]);
|
|
305
|
+
return { theme: d, toggle: g };
|
|
247
306
|
}
|
|
248
307
|
const P = {
|
|
249
308
|
dark: { glyph: "☾", label: "Dark theme" },
|
|
250
309
|
light: { glyph: "☀", label: "Light theme" }
|
|
251
310
|
};
|
|
252
|
-
function
|
|
253
|
-
const s =
|
|
254
|
-
return /* @__PURE__ */
|
|
311
|
+
function pe({ theme: e, onToggle: a }) {
|
|
312
|
+
const s = e === "dark" ? "light" : "dark", o = `${P[e].label}. Switch to ${P[s].label.toLowerCase()}.`;
|
|
313
|
+
return /* @__PURE__ */ t("button", { className: "site__icon", type: "button", onClick: a, "aria-label": o, title: o, children: P[e].glyph });
|
|
255
314
|
}
|
|
256
|
-
function
|
|
257
|
-
subject:
|
|
258
|
-
eyebrow:
|
|
315
|
+
function ye({
|
|
316
|
+
subject: e,
|
|
317
|
+
eyebrow: a,
|
|
259
318
|
courses: s,
|
|
260
319
|
getScene: o,
|
|
261
|
-
audioBase:
|
|
262
|
-
kind:
|
|
263
|
-
theme:
|
|
320
|
+
audioBase: d = "/",
|
|
321
|
+
kind: g = "courses",
|
|
322
|
+
theme: f = "dark"
|
|
264
323
|
}) {
|
|
265
|
-
const [
|
|
266
|
-
|
|
267
|
-
const
|
|
268
|
-
return window.addEventListener("hashchange",
|
|
324
|
+
const [l, p] = b(() => location.hash);
|
|
325
|
+
k(() => {
|
|
326
|
+
const i = () => p(location.hash);
|
|
327
|
+
return window.addEventListener("hashchange", i), () => window.removeEventListener("hashchange", i);
|
|
269
328
|
}, []);
|
|
270
|
-
const
|
|
271
|
-
if (s[
|
|
272
|
-
for (const
|
|
273
|
-
if (
|
|
329
|
+
const n = new URLSearchParams(location.search).get("capture") === "1", { theme: u, toggle: r } = ge(f, n), m = l.replace(/^#\/?/, ""), v = M(() => {
|
|
330
|
+
if (s[m]) return s[m];
|
|
331
|
+
for (const i of Object.values(s))
|
|
332
|
+
if (i.sections.some((c) => X(i, c) === m)) return i;
|
|
274
333
|
return Object.values(s)[0];
|
|
275
|
-
}, [
|
|
276
|
-
|
|
277
|
-
if (
|
|
278
|
-
const
|
|
279
|
-
|
|
280
|
-
}, [
|
|
281
|
-
|
|
282
|
-
plan: () =>
|
|
283
|
-
slug:
|
|
284
|
-
course:
|
|
334
|
+
}, [m, s]), _ = M(() => D(v), [v]), w = M(() => Object.values(s).flatMap(D), [s]);
|
|
335
|
+
k(() => {
|
|
336
|
+
if (n || !s[m]) return;
|
|
337
|
+
const i = _[0];
|
|
338
|
+
i && (history.replaceState(null, "", `${location.pathname}${location.search}#/${i.slug}`), p(`#/${i.slug}`));
|
|
339
|
+
}, [n, m, _]), k(() => {
|
|
340
|
+
n && (window.__scene = {
|
|
341
|
+
plan: () => _.map(({ slug: i, section: c }) => ({
|
|
342
|
+
slug: i,
|
|
343
|
+
course: v.id,
|
|
285
344
|
// audio lives at audio/<course>/<id>.wav
|
|
286
|
-
id:
|
|
287
|
-
scene:
|
|
288
|
-
focus:
|
|
345
|
+
id: c.id,
|
|
346
|
+
scene: c.scene,
|
|
347
|
+
focus: c.focus ?? null
|
|
289
348
|
}))
|
|
290
349
|
});
|
|
291
|
-
}, [
|
|
292
|
-
const
|
|
293
|
-
(
|
|
294
|
-
const
|
|
295
|
-
if (
|
|
296
|
-
const
|
|
297
|
-
location.hash =
|
|
350
|
+
}, [n, _, v]);
|
|
351
|
+
const E = I(
|
|
352
|
+
(i) => {
|
|
353
|
+
const c = location.hash.replace(/^#\/?/, ""), N = w.findIndex(({ slug: x }) => x === c);
|
|
354
|
+
if (N !== -1) {
|
|
355
|
+
const x = w[N + i];
|
|
356
|
+
location.hash = x ? `#/${x.slug}` : "";
|
|
298
357
|
return;
|
|
299
358
|
}
|
|
300
|
-
if (
|
|
301
|
-
|
|
359
|
+
if (c === "") {
|
|
360
|
+
i === 1 && w[0] && (location.hash = `#/${w[0].slug}`);
|
|
302
361
|
return;
|
|
303
362
|
}
|
|
304
|
-
const
|
|
305
|
-
|
|
363
|
+
const L = i === 1 ? _[0] : _[_.length - 1];
|
|
364
|
+
L && (location.hash = `#/${L.slug}`);
|
|
306
365
|
},
|
|
307
|
-
[
|
|
308
|
-
)
|
|
309
|
-
N(() => {
|
|
310
|
-
const a = (i) => {
|
|
311
|
-
i.key !== "ArrowRight" && i.key !== "ArrowLeft" || (i.preventDefault(), b(i.key === "ArrowRight" ? 1 : -1));
|
|
312
|
-
};
|
|
313
|
-
return window.addEventListener("keydown", a), () => window.removeEventListener("keydown", a);
|
|
314
|
-
}, [b]);
|
|
315
|
-
const y = T(() => {
|
|
366
|
+
[_, w]
|
|
367
|
+
), S = I(() => {
|
|
316
368
|
location.hash ? location.hash = "" : location.pathname !== "/" && (location.href = "/");
|
|
317
369
|
}, []);
|
|
318
|
-
|
|
319
|
-
const
|
|
320
|
-
|
|
370
|
+
k(() => {
|
|
371
|
+
const i = (c) => {
|
|
372
|
+
c.key === "Escape" && S();
|
|
321
373
|
};
|
|
322
|
-
return window.addEventListener("keydown",
|
|
323
|
-
}, [
|
|
324
|
-
const
|
|
325
|
-
const
|
|
326
|
-
|
|
374
|
+
return window.addEventListener("keydown", i), () => window.removeEventListener("keydown", i);
|
|
375
|
+
}, [S]);
|
|
376
|
+
const $ = _.find(({ slug: i }) => i === m), V = $ ? `${d}audio/${v.id}/${$.section.id}.wav` : void 0, { playing: q, toggle: K, stop: W, audio: y } = ue(V, () => {
|
|
377
|
+
const i = location.hash.replace(/^#\/?/, ""), c = w.findIndex(({ slug: L }) => L === i), N = w[c + 1];
|
|
378
|
+
N ? location.hash = `#/${N.slug}` : W();
|
|
327
379
|
});
|
|
328
|
-
if (
|
|
329
|
-
const
|
|
330
|
-
if (
|
|
331
|
-
const
|
|
332
|
-
|
|
380
|
+
if (k(() => {
|
|
381
|
+
const i = (c) => {
|
|
382
|
+
if (c.key !== "ArrowRight" && c.key !== "ArrowLeft") return;
|
|
383
|
+
const N = c.target;
|
|
384
|
+
if (N && (N.tagName === "INPUT" || N.tagName === "TEXTAREA" || N.isContentEditable)) return;
|
|
385
|
+
const L = c.key === "ArrowRight" ? 1 : -1;
|
|
386
|
+
c.preventDefault();
|
|
387
|
+
const x = (y == null ? void 0 : y.duration) ?? 0;
|
|
388
|
+
if (y && !c.shiftKey && Number.isFinite(x) && x > 0) {
|
|
389
|
+
y.currentTime = Math.min(x, Math.max(0, y.currentTime + L * z));
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
392
|
+
E(L);
|
|
393
|
+
};
|
|
394
|
+
return window.addEventListener("keydown", i), () => window.removeEventListener("keydown", i);
|
|
395
|
+
}, [E, y]), k(() => {
|
|
396
|
+
const i = (c) => {
|
|
397
|
+
if (c.key !== " " && c.code !== "Space") return;
|
|
398
|
+
const N = c.target;
|
|
399
|
+
N && (N.tagName === "INPUT" || N.tagName === "TEXTAREA" || N.isContentEditable) || (c.preventDefault(), K());
|
|
333
400
|
};
|
|
334
|
-
return window.addEventListener("keydown",
|
|
335
|
-
}), !
|
|
336
|
-
return /* @__PURE__ */
|
|
337
|
-
|
|
401
|
+
return window.addEventListener("keydown", i), () => window.removeEventListener("keydown", i);
|
|
402
|
+
}), !m)
|
|
403
|
+
return /* @__PURE__ */ t(
|
|
404
|
+
he,
|
|
338
405
|
{
|
|
339
406
|
courses: Object.values(s),
|
|
340
|
-
subject:
|
|
341
|
-
kind:
|
|
342
|
-
actions:
|
|
407
|
+
subject: e,
|
|
408
|
+
kind: g,
|
|
409
|
+
actions: n ? null : /* @__PURE__ */ t(pe, { theme: u, onToggle: r })
|
|
343
410
|
}
|
|
344
411
|
);
|
|
345
|
-
let
|
|
346
|
-
if (
|
|
347
|
-
const
|
|
348
|
-
|
|
349
|
-
|
|
412
|
+
let C, j = null;
|
|
413
|
+
if ($) {
|
|
414
|
+
const i = _.findIndex(({ slug: c }) => c === m);
|
|
415
|
+
C = /* @__PURE__ */ t(
|
|
416
|
+
oe,
|
|
350
417
|
{
|
|
351
|
-
section:
|
|
418
|
+
section: $.section,
|
|
352
419
|
getScene: o,
|
|
353
|
-
capture:
|
|
354
|
-
eyebrow: `${
|
|
355
|
-
index:
|
|
356
|
-
total:
|
|
357
|
-
onHome:
|
|
358
|
-
onPrev: () =>
|
|
359
|
-
onNext: () =>
|
|
360
|
-
narrating:
|
|
361
|
-
onToggleNarration:
|
|
362
|
-
|
|
363
|
-
|
|
420
|
+
capture: n,
|
|
421
|
+
eyebrow: `${a ?? e.toUpperCase()} · ${v.id.toUpperCase()}`,
|
|
422
|
+
index: i,
|
|
423
|
+
total: _.length,
|
|
424
|
+
onHome: S,
|
|
425
|
+
onPrev: () => E(-1),
|
|
426
|
+
onNext: () => E(1),
|
|
427
|
+
narrating: q,
|
|
428
|
+
onToggleNarration: K,
|
|
429
|
+
narrationAudio: y,
|
|
430
|
+
theme: u,
|
|
431
|
+
onToggleTheme: n ? void 0 : r
|
|
364
432
|
}
|
|
365
433
|
);
|
|
366
434
|
} else {
|
|
367
|
-
const
|
|
368
|
-
|
|
435
|
+
const i = o(m);
|
|
436
|
+
C = i ? /* @__PURE__ */ t("div", { className: "stage", children: /* @__PURE__ */ t(R, { scene: i, theme: u }) }) : /* @__PURE__ */ h("div", { className: "stage stage--missing", children: [
|
|
369
437
|
"no scene or slug: ",
|
|
370
|
-
|
|
371
|
-
] }),
|
|
438
|
+
m
|
|
439
|
+
] }), j = n ? null : /* @__PURE__ */ t("button", { className: "brand-home", onClick: S, "aria-label": "Back to catalog (Esc)", title: "Back to catalog (Esc)", children: "GraphL" });
|
|
372
440
|
}
|
|
373
|
-
return /* @__PURE__ */
|
|
374
|
-
|
|
375
|
-
|
|
441
|
+
return /* @__PURE__ */ h(H, { children: [
|
|
442
|
+
j,
|
|
443
|
+
C
|
|
376
444
|
] });
|
|
377
445
|
}
|
|
378
446
|
export {
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
447
|
+
ye as ConceptApp,
|
|
448
|
+
de as SiteHeader,
|
|
449
|
+
D as allSections,
|
|
450
|
+
X as slugOf
|
|
383
451
|
};
|
|
384
452
|
//# sourceMappingURL=index.js.map
|