@mechane-ai/elements 0.47.0 → 0.48.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.
Files changed (204) hide show
  1. package/README.md +288 -5
  2. package/bin/mechane-elements-catalog.mjs +104 -12
  3. package/dist/article-BXZr10QQ.js +1904 -0
  4. package/dist/article.js +1 -0
  5. package/dist/catalog.json +1389 -75
  6. package/dist/{categorical-values-DdfGIowV.js → categorical-values-BpVq8cFj.js} +1 -1
  7. package/dist/{cells--Bd1fQFR.js → cells-xVmnQ9oQ.js} +1 -1
  8. package/dist/charts/cartesian.js +1 -1
  9. package/dist/charts/cells.js +1 -1
  10. package/dist/charts/comparison.js +1 -1
  11. package/dist/charts/distribution.js +1 -1
  12. package/dist/charts/figure.js +12 -12
  13. package/dist/charts/graph.js +1 -1
  14. package/dist/charts/hierarchy.js +1 -1
  15. package/dist/charts/image.js +1 -1
  16. package/dist/charts/matrix.js +3 -2
  17. package/dist/charts/plot.js +4 -4
  18. package/dist/charts/relationship.js +1 -1
  19. package/dist/charts/text.js +1 -1
  20. package/dist/charts/timeline.js +1 -1
  21. package/dist/charts/trend.js +1 -1
  22. package/dist/charts.js +2 -2
  23. package/dist/clock-DSm5lkNE.js +16 -0
  24. package/dist/collections.js +1 -1
  25. package/dist/describe-lesson-BmREzDpt.js +175 -0
  26. package/dist/{dumbbell-plot-B2ZTgQaI.js → dumbbell-plot-DQdTxDeO.js} +6 -5
  27. package/dist/{embedding-map-CGM_k6lC.js → embedding-map-CF-J-8JW.js} +5 -5
  28. package/dist/{figure-frame-wRkIEAwe.js → figure-frame-BJ3REgTA.js} +1 -1
  29. package/dist/forms.js +1 -1
  30. package/dist/{image-grid-CVA4SOy_.js → image-grid-Dl2sjIMB.js} +3 -3
  31. package/dist/kits/evaluation.js +5 -5
  32. package/dist/kits/interpretability.js +9 -9
  33. package/dist/kits/operations.js +4 -4
  34. package/dist/kits/training.js +4 -4
  35. package/dist/lesson/agent.js +811 -0
  36. package/dist/lesson/spec.js +661 -0
  37. package/dist/lesson.js +5 -0
  38. package/dist/mdx.js +227 -0
  39. package/dist/packages/charts/src/matrix/index.d.ts +1 -0
  40. package/dist/packages/charts/src/plot/plot-marks.d.ts +7 -3
  41. package/dist/packages/teaching/src/agent/index.d.ts +11 -0
  42. package/dist/packages/teaching/src/agent/learner-trace.d.ts +84 -0
  43. package/dist/packages/teaching/src/agent/lesson-bridge.d.ts +59 -0
  44. package/dist/packages/teaching/src/agent/lesson-tour.d.ts +63 -0
  45. package/dist/packages/teaching/src/agent/tutor-tools.d.ts +86 -0
  46. package/dist/packages/teaching/src/article/article-checks.d.ts +9 -0
  47. package/dist/packages/teaching/src/article/article-context.d.ts +49 -0
  48. package/dist/packages/teaching/src/article/article-error.d.ts +12 -0
  49. package/dist/packages/teaching/src/article/article-labels.d.ts +54 -0
  50. package/dist/packages/teaching/src/article/article-layout.stylex.d.ts +14 -0
  51. package/dist/packages/teaching/src/article/article-outline.d.ts +9 -0
  52. package/dist/packages/teaching/src/article/article.d.ts +42 -0
  53. package/dist/packages/teaching/src/article/beat-steps.d.ts +18 -0
  54. package/dist/packages/teaching/src/article/beat.d.ts +16 -0
  55. package/dist/packages/teaching/src/article/challenge.d.ts +29 -0
  56. package/dist/packages/teaching/src/article/exercise-styles.d.ts +76 -0
  57. package/dist/packages/teaching/src/article/figure.d.ts +51 -0
  58. package/dist/packages/teaching/src/article/index.d.ts +31 -0
  59. package/dist/packages/teaching/src/article/lesson-values.d.ts +5 -0
  60. package/dist/packages/teaching/src/article/notes.d.ts +36 -0
  61. package/dist/packages/teaching/src/article/outline-types.d.ts +73 -0
  62. package/dist/packages/teaching/src/article/predict.d.ts +58 -0
  63. package/dist/packages/teaching/src/article/progress-store.d.ts +64 -0
  64. package/dist/packages/teaching/src/article/scrolly.d.ts +26 -0
  65. package/dist/packages/{kits/src/explainers → teaching/src/article}/term.d.ts +8 -2
  66. package/dist/packages/teaching/src/article/tex.d.ts +12 -0
  67. package/dist/packages/teaching/src/article/view-essay.d.ts +13 -0
  68. package/dist/packages/teaching/src/article/view-present.d.ts +8 -0
  69. package/dist/packages/teaching/src/article/view-sheet.d.ts +7 -0
  70. package/dist/packages/teaching/src/article/view-static.d.ts +7 -0
  71. package/dist/packages/teaching/src/article/walk.d.ts +34 -0
  72. package/dist/packages/teaching/src/lesson/define-lesson.d.ts +136 -0
  73. package/dist/packages/teaching/src/lesson/index.d.ts +24 -0
  74. package/dist/packages/teaching/src/lesson/inline-choice.d.ts +12 -0
  75. package/dist/packages/teaching/src/lesson/lesson-context.d.ts +18 -0
  76. package/dist/packages/teaching/src/lesson/lesson-error.d.ts +12 -0
  77. package/dist/packages/teaching/src/lesson/lesson-locale.d.ts +4 -0
  78. package/dist/packages/teaching/src/lesson/lesson-persistence.d.ts +17 -0
  79. package/dist/packages/teaching/src/lesson/lesson-player.d.ts +51 -0
  80. package/dist/packages/teaching/src/lesson/lesson-store.d.ts +84 -0
  81. package/dist/packages/teaching/src/lesson/lesson.d.ts +39 -0
  82. package/dist/packages/teaching/src/lesson/param-controls.d.ts +14 -0
  83. package/dist/packages/teaching/src/lesson/param.d.ts +34 -0
  84. package/dist/packages/teaching/src/lesson/playback.d.ts +42 -0
  85. package/dist/packages/teaching/src/lesson/transport.d.ts +19 -0
  86. package/dist/packages/teaching/src/lesson/use-lesson.d.ts +36 -0
  87. package/dist/packages/teaching/src/mdx/essay-components.d.ts +79 -0
  88. package/dist/packages/teaching/src/mdx/essay-markdown.d.ts +41 -0
  89. package/dist/packages/teaching/src/mdx/essay.d.ts +32 -0
  90. package/dist/packages/teaching/src/mdx/index.d.ts +9 -0
  91. package/dist/packages/teaching/src/mdx/requested-view.d.ts +6 -0
  92. package/dist/packages/teaching/src/scene/flow/flow-layout.d.ts +38 -0
  93. package/dist/packages/teaching/src/scene/flow/flow-pulse.d.ts +16 -0
  94. package/dist/packages/teaching/src/scene/flow/scene-flow.d.ts +81 -0
  95. package/dist/packages/teaching/src/scene/index.d.ts +77 -0
  96. package/dist/packages/teaching/src/scene/morph/morph-scope.d.ts +28 -0
  97. package/dist/packages/teaching/src/scene/plane/plane-hit.d.ts +22 -0
  98. package/dist/packages/teaching/src/scene/plane/plane-label.d.ts +23 -0
  99. package/dist/packages/teaching/src/scene/plane/plane-labels.d.ts +42 -0
  100. package/dist/packages/teaching/src/scene/plane/plane-math.d.ts +45 -0
  101. package/dist/packages/teaching/src/scene/plane/scene-axes.d.ts +30 -0
  102. package/dist/packages/teaching/src/scene/plane/scene-curve.d.ts +42 -0
  103. package/dist/packages/teaching/src/scene/plane/scene-point.d.ts +59 -0
  104. package/dist/packages/teaching/src/scene/plane/scene-projection.d.ts +27 -0
  105. package/dist/packages/teaching/src/scene/plane/scene-region.d.ts +38 -0
  106. package/dist/packages/teaching/src/scene/plane/scene-rule.d.ts +35 -0
  107. package/dist/packages/teaching/src/scene/plane/scene-vector.d.ts +39 -0
  108. package/dist/packages/teaching/src/scene/scene-bracket.d.ts +24 -0
  109. package/dist/packages/teaching/src/scene/scene-callout.d.ts +26 -0
  110. package/dist/packages/teaching/src/scene/scene-context.d.ts +179 -0
  111. package/dist/packages/teaching/src/scene/scene-custom.d.ts +31 -0
  112. package/dist/packages/teaching/src/scene/scene-geometry.d.ts +181 -0
  113. package/dist/packages/teaching/src/scene/scene-group.d.ts +28 -0
  114. package/dist/packages/teaching/src/scene/scene-highlight.d.ts +19 -0
  115. package/dist/packages/teaching/src/scene/scene-layer.d.ts +16 -0
  116. package/dist/packages/teaching/src/scene/scene-node.d.ts +67 -0
  117. package/dist/packages/teaching/src/scene/scene-obstacles.d.ts +27 -0
  118. package/dist/packages/teaching/src/scene/scene-registry.d.ts +79 -0
  119. package/dist/packages/teaching/src/scene/scene-stagger.d.ts +43 -0
  120. package/dist/packages/teaching/src/scene/scene-style.d.ts +14 -0
  121. package/dist/packages/teaching/src/scene/scene-validate.d.ts +65 -0
  122. package/dist/packages/teaching/src/scene/scene-wire.d.ts +45 -0
  123. package/dist/packages/teaching/src/scene/scene.d.ts +36 -0
  124. package/dist/packages/teaching/src/scene/shapes/cell-color.d.ts +11 -0
  125. package/dist/packages/teaching/src/scene/shapes/cell-grid.d.ts +69 -0
  126. package/dist/packages/teaching/src/scene/shapes/scene-card.d.ts +114 -0
  127. package/dist/packages/teaching/src/scene/shapes/scene-cells.d.ts +84 -0
  128. package/dist/packages/teaching/src/scene/shapes/scene-slot.d.ts +37 -0
  129. package/dist/packages/teaching/src/scene/shapes/scene-stack.d.ts +46 -0
  130. package/dist/packages/teaching/src/scene/shapes/scene-token.d.ts +63 -0
  131. package/dist/packages/teaching/src/scene/shapes/scene-tokens.d.ts +40 -0
  132. package/dist/packages/teaching/src/scene/shapes/stack-book.d.ts +35 -0
  133. package/dist/packages/teaching/src/scene/shapes/stack-layout.d.ts +63 -0
  134. package/dist/packages/teaching/src/scene/shapes/token-layout.d.ts +39 -0
  135. package/dist/packages/teaching/src/spec/advice.d.ts +23 -0
  136. package/dist/packages/teaching/src/spec/chart-names.d.ts +2 -0
  137. package/dist/packages/teaching/src/spec/describe-lesson.d.ts +85 -0
  138. package/dist/packages/teaching/src/spec/explainer-guide.d.ts +21 -0
  139. package/dist/packages/teaching/src/spec/findings.d.ts +39 -0
  140. package/dist/packages/teaching/src/spec/index.d.ts +14 -0
  141. package/dist/packages/teaching/src/spec/lesson-plan.d.ts +43 -0
  142. package/dist/packages/teaching/src/spec/validate-plan.d.ts +11 -0
  143. package/dist/packages/teaching/src/time/clock.d.ts +7 -0
  144. package/dist/packages/teaching/src/time/tween.d.ts +19 -0
  145. package/dist/packages/teaching/src/time/use-tween.d.ts +6 -0
  146. package/dist/param-CqKUTHaO.js +450 -0
  147. package/dist/{plot-layout-BEuoOHbs.js → plot-layout-CZVSJ-le.js} +2 -1
  148. package/dist/{plot-marks-A64v7aTw.js → plot-marks-uozcbOIX.js} +15 -12
  149. package/dist/{plot-surface-CJTIqtck.js → plot-surface-CbVBvgqZ.js} +1 -1
  150. package/dist/{reference-lines-CWA8VeUR.js → reference-lines-BDcttOp0.js} +2 -2
  151. package/dist/scene-0z2gbaDE.js +4938 -0
  152. package/dist/scene.js +1 -0
  153. package/dist/{slope-chart-DT22h_ym.js → slope-chart-BKVEAVCs.js} +5 -5
  154. package/dist/{src-1EHkSFS-.js → src-BD6xlvDt.js} +2 -2
  155. package/dist/{src-D5NXRJZe.js → src-Dcfq8vE4.js} +1 -1
  156. package/dist/styles2.css +475 -18
  157. package/dist/{time-series-IB3CB93O.js → time-series-BgzGNOk0.js} +12 -10
  158. package/dist/{token-heatmap-C00DnoNO.js → token-heatmap-BrW1OsKD.js} +2 -2
  159. package/dist/{token-predictions-Cxx29iDr.js → token-predictions-yerq_Oet.js} +4 -4
  160. package/dist/transport-BJweqDPj.js +715 -0
  161. package/dist/{tree-diagram-DsckNKaW.js → tree-diagram-D09BRqE-.js} +4 -4
  162. package/dist/{treemap-9_DpLCW9.js → treemap-CW4WsJNL.js} +4 -4
  163. package/dist/use-tween-5HZ55_9d.js +72 -0
  164. package/dist/{violin-plot-BhPHKXsN.js → violin-plot-DrtPZ1-T.js} +5 -4
  165. package/dist/{waterfall-CGksuTy5.js → waterfall-DYLSnGjm.js} +4 -4
  166. package/package.json +26 -5
  167. package/recipes/counting-cards.tsx +656 -0
  168. package/recipes/explorable-essay.tsx +172 -0
  169. package/skills/extend-elements/SKILL.md +21 -0
  170. package/skills/plan-lesson/SKILL.md +86 -0
  171. package/skills/plan-lesson/references/plan-format.md +114 -0
  172. package/skills/plan-lesson/references/worked-plan.md +171 -0
  173. package/skills/review-elements/SKILL.md +4 -2
  174. package/skills/review-explainer/SKILL.md +97 -0
  175. package/skills/upgrade-elements/references/releases.md +65 -0
  176. package/skills/use-elements/SKILL.md +18 -16
  177. package/skills/use-elements/references/kits.md +2 -20
  178. package/skills/use-elements/references/teaching.md +36 -0
  179. package/skills/write-explainer/SKILL.md +112 -0
  180. package/skills/write-explainer/references/article.md +164 -0
  181. package/skills/write-explainer/references/lesson.md +148 -0
  182. package/skills/write-explainer/references/mdx.md +78 -0
  183. package/skills/write-explainer/references/scene-parts.md +273 -0
  184. package/skills/write-explainer/references/scene.md +168 -0
  185. package/skills/write-explainer/references/tutor.md +104 -0
  186. package/skills/write-explainer/references/worked-essay.md +459 -0
  187. package/templates/essay/AGENTS.md +14 -0
  188. package/templates/essay/README.md +59 -0
  189. package/templates/essay/index.html +17 -0
  190. package/templates/essay/package.template.json +21 -0
  191. package/templates/essay/plan.json +96 -0
  192. package/templates/essay/src/essay.mdx +97 -0
  193. package/templates/essay/src/figures.tsx +92 -0
  194. package/templates/essay/src/lesson.ts +83 -0
  195. package/templates/essay/src/main.tsx +53 -0
  196. package/templates/essay/src/mdx.d.ts +7 -0
  197. package/templates/essay/tsconfig.template.json +15 -0
  198. package/templates/essay/vite.config.template.txt +8 -0
  199. package/dist/kits/explainers.js +0 -452
  200. package/dist/packages/kits/src/explainers/figures.d.ts +0 -31
  201. package/dist/packages/kits/src/explainers/index.d.ts +0 -8
  202. package/dist/packages/kits/src/explainers/story-steps.d.ts +0 -46
  203. /package/dist/packages/{kits/src/explainers → teaching/src/article}/linked-target.d.ts +0 -0
  204. /package/dist/packages/{kits/src/explainers → teaching/src/lesson}/bound-value.d.ts +0 -0
@@ -0,0 +1,450 @@
1
+ import { l as e, o as t } from "./src-BD6xlvDt.js";
2
+ import { r as n } from "./figure-format-B8kRZMlo.js";
3
+ import "@stylexjs/stylex";
4
+ import { createParts as r } from "@ui-sdk/react/primitive";
5
+ import { createContext as i, use as a, useEffect as o, useRef as s } from "react";
6
+ import { announce as c, bindDrag as l, createChange as u, definePrimitive as d, dragThreshold as f, isRTL as p } from "@ui-sdk/core";
7
+ import { jsx as m, jsxs as h } from "react/jsx-runtime";
8
+ import { Check as ee, ChevronDown as te } from "lucide-react";
9
+ import { SelectTrigger as g, SelectValue as ne } from "@ui-sdk/react/select";
10
+ import { clamp as re, fractionOf as _, scrubTo as v, stepBy as y, stepFromKey as b, stepValue as x, valueAt as S } from "@ui-sdk/core/number";
11
+ // packages/teaching/src/lesson/lesson-locale.ts
12
+ var C = i(null);
13
+ function ie() {
14
+ return a(C);
15
+ }
16
+ // packages/teaching/src/lesson/lesson-error.tsx
17
+ function w(e, t) {
18
+ throw Error(`Lesson "${e}": ${t}`);
19
+ }
20
+ function T(e) {
21
+ throw Error(`${e} must be rendered inside a <Lesson>. Wrap it in <Lesson lesson={…} locale="…">.`);
22
+ }
23
+ function E({ children: e }) {
24
+ return /* @__PURE__ */ m("span", {
25
+ role: "note",
26
+ className: "xr5kp14 x1b5ytql",
27
+ children: e
28
+ });
29
+ }
30
+ // packages/teaching/src/lesson/define-lesson.ts
31
+ function D({ name: e, param: t, value: n }) {
32
+ switch (t.kind) {
33
+ case "number": return typeof n == "number" && Number.isFinite(n) && n >= t.min && n <= t.max ? void 0 : `${e} takes a number from ${t.min} to ${t.max}, not ${String(n)}.`;
34
+ case "choice": return t.options.some((e) => e.id === n) ? void 0 : `${e} takes one of ${t.options.map((e) => e.id).join(", ")}, not ${String(n)}.`;
35
+ case "toggle": return typeof n == "boolean" ? void 0 : `${e} takes true or false, not ${String(n)}.`;
36
+ }
37
+ }
38
+ function O(e, t) {
39
+ return Number.isFinite(t.min) && Number.isFinite(t.max) && t.min < t.max ? t.step > 0 ? t.scale === "log" && t.min <= 0 ? `${e} is on a log scale, so its min must be above zero.` : void 0 : `${e} needs a step above zero.` : `${e} needs finite bounds with min below max.`;
40
+ }
41
+ function k(e, t) {
42
+ if (t.kind === "number") {
43
+ let n = O(e, t);
44
+ if (n !== void 0) return n;
45
+ }
46
+ if (t.kind === "choice") {
47
+ let n = t.options.map((e) => e.id);
48
+ if (new Set(n).size !== n.length || n.length === 0) return `${e} needs at least one option, each with its own id.`;
49
+ }
50
+ let n = D({
51
+ name: e,
52
+ param: t,
53
+ value: t.value
54
+ });
55
+ return n === void 0 ? void 0 : `the default of ${n}`;
56
+ }
57
+ function A(e) {
58
+ return e.find((t, n) => e.indexOf(t) !== n);
59
+ }
60
+ function j(e) {
61
+ let t = /* @__PURE__ */ new Set();
62
+ return {
63
+ view: new Proxy(e, { get(e, n, r) {
64
+ return typeof n == "string" && t.add(n), Reflect.get(e, n, r);
65
+ } }),
66
+ names: t
67
+ };
68
+ }
69
+ function M(e, t) {
70
+ let n = new Map(Object.entries(t));
71
+ return (e.states ?? []).flatMap((t) => Object.entries(t.values).flatMap(([r, i]) => {
72
+ let a = n.get(r), o = `state "${t.id}" of beat "${e.id}"`;
73
+ if (a === void 0) return [`${o} sets "${r}", which is not a param.`];
74
+ let s = D({
75
+ name: r,
76
+ param: a,
77
+ value: i
78
+ });
79
+ return s === void 0 ? [] : [`${o}: ${s}`];
80
+ }));
81
+ }
82
+ function N(e, t) {
83
+ let n = e.steps ?? 0, r = Number.isInteger(n) && n >= 0, i = A((e.states ?? []).map((e) => e.id));
84
+ return [
85
+ ...r ? [] : [`beat "${e.id}" needs a whole number of steps, not ${n}.`],
86
+ ...i === void 0 ? [] : [`beat "${e.id}" has two states with the id "${i}".`],
87
+ ...M(e, t)
88
+ ];
89
+ }
90
+ function P({ params: e, derivedNames: t, beats: n }) {
91
+ let r = new Set(Object.keys(e)), i = t.find((e) => r.has(e)), a = A(n.map((e) => e.id));
92
+ return [
93
+ ...Object.entries(e).flatMap(([e, t]) => k(e, t) ?? []),
94
+ ...i === void 0 ? [] : [`"${i}" is declared as both a param and a derived value.`],
95
+ ...a === void 0 ? [] : [`two beats share the id "${a}".`],
96
+ ...n.flatMap((t) => N(t, e))
97
+ ];
98
+ }
99
+ function F(e) {
100
+ let { id: t, title: n, params: r } = e, i = Object.entries(e.derived ?? {}), a = e.beats ?? [], o = Object.keys(r), s = i.map(([e]) => e), [c] = P({
101
+ params: r,
102
+ derivedNames: s,
103
+ beats: a
104
+ });
105
+ c !== void 0 && w(t, c);
106
+ let l = Object.fromEntries(Object.entries(r).map(([e, t]) => [e, t.value])), u = Object.fromEntries(s.map((e) => [e, NaN]));
107
+ function d(e) {
108
+ let n = {
109
+ known: {
110
+ ...e,
111
+ ...u
112
+ },
113
+ results: u
114
+ }, r = new Set(o), a = i.map(([e, i]) => {
115
+ let { view: a, names: o } = j(n.known), s = i.from(a), c = [...o].find((e) => !r.has(e));
116
+ return c !== void 0 && w(t, `derived "${e}" reads "${c}", which is not a param or a derived value declared before it.`), typeof s != "number" && w(t, `derived "${e}" must return a number.`), r.add(e), n.known = {
117
+ ...n.known,
118
+ [e]: s
119
+ }, n.results = {
120
+ ...n.results,
121
+ [e]: s
122
+ }, [e, [...o]];
123
+ });
124
+ return {
125
+ results: n.results,
126
+ reads: a
127
+ };
128
+ }
129
+ let f = d(l), p = a.flatMap((e) => (e.states ?? []).map((e) => d({
130
+ ...l,
131
+ ...e.values
132
+ }).reads)), m = Object.fromEntries(s.map((e) => [e, [...new Set([f.reads, ...p].flatMap((t) => t.filter(([t]) => t === e).flatMap(([, e]) => e)))]]));
133
+ return {
134
+ id: t,
135
+ title: n,
136
+ params: r,
137
+ derived: Object.fromEntries(i.map(([e, t]) => [e, {
138
+ label: t.label,
139
+ format: t.format
140
+ }])),
141
+ beats: a,
142
+ defaults: l,
143
+ initial: {
144
+ ...l,
145
+ ...f.results
146
+ },
147
+ compute: (e) => d(e).results,
148
+ reads: m
149
+ };
150
+ }
151
+ function I(e) {
152
+ return {
153
+ nodes: [...Object.entries(e.params).map(([e, t]) => ({
154
+ name: e,
155
+ kind: "param",
156
+ label: t.label
157
+ })), ...Object.entries(e.derived).map(([e, t]) => ({
158
+ name: e,
159
+ kind: "derived",
160
+ label: t.label
161
+ }))],
162
+ edges: Object.entries(e.reads).flatMap(([e, t]) => t.map((t) => ({
163
+ from: t,
164
+ to: e
165
+ })))
166
+ };
167
+ }
168
+ // packages/teaching/src/lesson/lesson-context.ts
169
+ var L = i(null);
170
+ function R(e) {
171
+ return a(L) ?? T(e);
172
+ }
173
+ function z(e, t) {
174
+ let n = { scope: e };
175
+ for (; n.scope !== null && n.scope.lesson !== t;) n.scope = n.scope.outer;
176
+ return n.scope;
177
+ }
178
+ // packages/teaching/src/lesson/bound-value.tsx
179
+ var B = 240, V = {
180
+ step: .01,
181
+ large: .1,
182
+ small: .001
183
+ }, H = [
184
+ "ArrowLeft",
185
+ "ArrowRight",
186
+ "ArrowUp",
187
+ "ArrowDown",
188
+ "PageUp",
189
+ "PageDown",
190
+ "Home",
191
+ "End"
192
+ ];
193
+ function U({ min: e, max: t, step: n }) {
194
+ return {
195
+ min: e,
196
+ max: t,
197
+ step: n
198
+ };
199
+ }
200
+ function W(e, t) {
201
+ let n = U(t);
202
+ return v(S(re(e, 0, 1), n, t.scale ?? "linear"), n).value;
203
+ }
204
+ function G(e, t, n) {
205
+ if (t.bound !== void 0) return t.bound === "min" ? n.min : n.max;
206
+ let r = U(n), i = W(_(e, r, "log") + t.direction * V[t.size], n);
207
+ return i === e ? x(e, t.direction, r) : i;
208
+ }
209
+ var K = d({
210
+ name: "bound-value",
211
+ options: {
212
+ value: "number",
213
+ defaultValue: "number",
214
+ onValueChange: "callback",
215
+ min: "number",
216
+ max: "number",
217
+ step: "number",
218
+ scale: "string",
219
+ describe: "value"
220
+ },
221
+ controlled: ["value"],
222
+ state: (e) => ({
223
+ value: e.value ?? e.defaultValue ?? e.min,
224
+ isDragging: !1
225
+ }),
226
+ sync: (e) => e.value === void 0 ? {} : { value: e.value },
227
+ api: (e) => {
228
+ let { store: t } = e, n = u(e), r = null;
229
+ e.onDestroy(() => r?.());
230
+ function i(e, r, i) {
231
+ return e !== t.get().value && n("value", e, i === void 0 ? { reason: r } : {
232
+ reason: r,
233
+ event: i
234
+ });
235
+ }
236
+ return {
237
+ describe: (t) => e.options().describe(t),
238
+ setValue(t) {
239
+ let { min: n, max: r } = e.options(), a = Number(t);
240
+ if (!Number.isFinite(a) || a < n || a > r) throw Error(`Give a number between ${n} and ${r}.`);
241
+ return i(v(a, U(e.options())).value, "imperative");
242
+ },
243
+ keydown(n, r) {
244
+ let a = b(n, { dir: p(r) ? "rtl" : "ltr" });
245
+ if (a === null || n.defaultPrevented) return;
246
+ n.preventDefault();
247
+ let o = e.options(), { value: s } = t.get();
248
+ i(o.scale === "log" ? G(s, a, o) : y(s, a, U(o)), "step-key", n);
249
+ },
250
+ pointerdown(n, a) {
251
+ if (n.button !== 0) return;
252
+ r?.();
253
+ let o = t.get().value, s = p(a) ? -1 : 1, c = _(o, U(e.options()), e.options().scale ?? "linear"), u = 0;
254
+ r = l(a, n, {
255
+ threshold: f,
256
+ cancelOnEscape: !0,
257
+ onStart: () => {
258
+ t.set({ isDragging: !0 });
259
+ },
260
+ onMove: ({ movementX: t, event: n }) => {
261
+ u += t * s, i(W(c + u / B, e.options()), "drag", n);
262
+ },
263
+ onEnd: (e, n) => {
264
+ t.set({ isDragging: !1 }), n && i(o, "drag", e);
265
+ }
266
+ });
267
+ }
268
+ };
269
+ },
270
+ slots: (e) => ({ root: e({
271
+ role: "slider",
272
+ focus: "tab-stop",
273
+ keys: [...H],
274
+ state: (e, { api: t }) => ({
275
+ text: t.describe(e.value),
276
+ isDragging: e.isDragging
277
+ }),
278
+ attrs: (e, { api: t }) => ({
279
+ tabindex: "0",
280
+ "aria-valuenow": String(e.value),
281
+ "aria-valuetext": t.describe(e.value),
282
+ "data-dragging": e.isDragging ? "" : void 0
283
+ }),
284
+ on: {
285
+ keydown: (e, { api: t, el: n }) => {
286
+ n !== void 0 && t.keydown(e, n);
287
+ },
288
+ pointerdown: (e, { api: t, el: n }) => {
289
+ n !== void 0 && t.pointerdown(e, n);
290
+ }
291
+ }
292
+ }) }),
293
+ agent: { actions: ["setValue"] }
294
+ }), q = r(K, { root: "span" }).Root;
295
+ function J({ min: e, max: t, step: n, scale: r, value: i }) {
296
+ if (!Number.isFinite(e) || !Number.isFinite(t) || e >= t) return "BoundValue needs finite bounds with min below max.";
297
+ if (!Number.isFinite(n) || n < 0) return "BoundValue needs a step of zero or more.";
298
+ if (r === "log" && e <= 0) return "A log BoundValue needs a min above zero.";
299
+ if (i !== void 0 && !(Number.isFinite(i) && i >= e && i <= t)) return `BoundValue ${i} lies outside ${e} to ${t}.`;
300
+ }
301
+ function Y({ label: e, locale: t, format: r, ...i }) {
302
+ let a = J(i);
303
+ return a === void 0 ? /* @__PURE__ */ m(q, {
304
+ ...i,
305
+ describe: (e) => n({
306
+ value: e,
307
+ locale: t,
308
+ format: r
309
+ }),
310
+ "aria-label": e,
311
+ "aria-valuemin": i.min,
312
+ "aria-valuemax": i.max,
313
+ "aria-orientation": "horizontal",
314
+ className: "xt0psk2 x1ok0vyi xbixft xss6m8b xk4h15q xuxw1ft x7eptgl x87ps6o xx69xxh xujl8zx xi2nhp4 xewurvo x11xz5oc x1jdncgf xif5pkx x81ozek xxxv2na x13qnu6 x9v5kkp x19rmrnh x7s97pk",
315
+ render: (e, { text: t }) => /* @__PURE__ */ m("span", {
316
+ ...e,
317
+ children: t
318
+ })
319
+ }) : /* @__PURE__ */ m("span", {
320
+ className: "xr5kp14 x1b5ytql",
321
+ children: a
322
+ });
323
+ }
324
+ // packages/teaching/src/lesson/inline-choice.tsx
325
+ var ae = 14;
326
+ function oe({ param: t, value: n, isDisabled: r, onChange: i }) {
327
+ let a = t.options.map((e) => ({
328
+ value: e.id,
329
+ label: e.label
330
+ }));
331
+ return /* @__PURE__ */ h(e.Root, {
332
+ value: n,
333
+ items: a,
334
+ disabled: r,
335
+ onValueChange: (e, t) => {
336
+ e !== null && i(e, t);
337
+ },
338
+ children: [/* @__PURE__ */ h(g, {
339
+ "aria-label": t.label,
340
+ disabled: r,
341
+ className: "x3nfvp2 x1pha0wt xfko13i x1717udv x1ghz6dp xc342km x1ok0vyi xjbqb8w xbixft xjb2p0i x1qlqyl8 x15bjb6t xk4h15q xuxw1ft x1ypdohk xujl8zx xi2nhp4 xewurvo x11xz5oc x1jdncgf xif5pkx x1m8qfh3 x47ym49 x13qnu6 x9v5kkp x19rmrnh x7s97pk",
342
+ children: [/* @__PURE__ */ m(ne, {}), !r && /* @__PURE__ */ m(te, {
343
+ size: ae,
344
+ "aria-hidden": !0,
345
+ className: "xamitd3 x153jb6y"
346
+ })]
347
+ }), /* @__PURE__ */ m(e.Popup, {
348
+ align: "start",
349
+ children: /* @__PURE__ */ m(e.List, { children: a.map((t) => /* @__PURE__ */ h(e.Item, {
350
+ value: t.value,
351
+ children: [/* @__PURE__ */ m(e.ItemText, { children: t.label }), /* @__PURE__ */ m(e.ItemIndicator, { children: /* @__PURE__ */ m(ee, {
352
+ size: 16,
353
+ "aria-hidden": !0
354
+ }) })]
355
+ }, t.value)) })
356
+ })]
357
+ });
358
+ }
359
+ // packages/teaching/src/lesson/param.tsx
360
+ var se = 700, X = {
361
+ on: "on",
362
+ off: "off"
363
+ };
364
+ function Z(e, t) {
365
+ let n = new Map(Object.entries(e.lesson.params)).get(t);
366
+ return n === void 0 ? { error: `Lesson "${e.lesson.id}" has no param "${t}". Its params: ${Object.keys(e.lesson.params).join(", ")}.` } : { param: n };
367
+ }
368
+ function Q({ param: e, value: t, locale: r, labels: i }) {
369
+ switch (e.kind) {
370
+ case "number": return n({
371
+ value: typeof t == "number" ? t : null,
372
+ locale: r,
373
+ format: e.format
374
+ });
375
+ case "choice": return e.options.find((e) => e.id === t)?.label ?? String(t);
376
+ case "toggle": return t === !0 ? i.on : i.off;
377
+ }
378
+ }
379
+ function ce({ name: e }) {
380
+ let n = R("Param"), r = Z(n, e);
381
+ if ("error" in r) return /* @__PURE__ */ m(E, { children: r.error });
382
+ let { param: i } = r, a = n.state.values[e], { isReadOnly: o } = n.state;
383
+ switch (i.kind) {
384
+ case "number": return o ? /* @__PURE__ */ m("span", {
385
+ className: "xss6m8b xk4h15q xuxw1ft xbixft",
386
+ children: Q({
387
+ param: i,
388
+ value: a,
389
+ locale: n.locale,
390
+ labels: X
391
+ })
392
+ }) : /* @__PURE__ */ m(Y, {
393
+ value: typeof a == "number" ? a : i.value,
394
+ onValueChange: (t, r) => n.api.apply(e, t, r),
395
+ min: i.min,
396
+ max: i.max,
397
+ step: i.step,
398
+ scale: i.scale,
399
+ locale: n.locale,
400
+ format: i.format,
401
+ label: i.label
402
+ });
403
+ case "choice": return /* @__PURE__ */ m(oe, {
404
+ param: i,
405
+ value: typeof a == "string" ? a : i.value,
406
+ isDisabled: o,
407
+ onChange: (t, r) => n.api.apply(e, t, r)
408
+ });
409
+ case "toggle": return /* @__PURE__ */ m("span", {
410
+ className: "x3nfvp2 xxymvpz",
411
+ children: /* @__PURE__ */ m(t.Root, {
412
+ checked: a === !0,
413
+ onCheckedChange: (t, r) => n.api.apply(e, t, r),
414
+ disabled: o,
415
+ "aria-label": i.label,
416
+ children: /* @__PURE__ */ m(t.Thumb, {})
417
+ })
418
+ });
419
+ }
420
+ }
421
+ function le(e, t) {
422
+ let n = s(e);
423
+ o(() => {
424
+ if (t || n.current === e) return;
425
+ let r = globalThis.setTimeout(() => {
426
+ n.current = e, c(e);
427
+ }, se);
428
+ return () => globalThis.clearTimeout(r);
429
+ }, [e, t]);
430
+ }
431
+ function $({ name: e, labels: t }) {
432
+ let r = R("Value"), i = new Map(Object.entries(r.lesson.derived)).get(e), a = i === void 0 ? Z(r, e) : void 0, o = r.values[e], s = i === void 0 ? a !== void 0 && "param" in a ? Q({
433
+ param: a.param,
434
+ value: o,
435
+ locale: r.locale,
436
+ labels: {
437
+ ...X,
438
+ ...t
439
+ }
440
+ }) : void 0 : n({
441
+ value: typeof o == "number" ? o : null,
442
+ locale: r.locale,
443
+ format: i.format
444
+ }), c = i?.label ?? (a !== void 0 && "param" in a ? a.param.label : e);
445
+ return le(s === void 0 ? "" : `${c}: ${s}`, r.state.playing !== null), s === void 0 ? /* @__PURE__ */ m(E, { children: `Lesson "${r.lesson.id}" has no param or derived value "${e}".` }) : /* @__PURE__ */ m("span", {
446
+ className: "xss6m8b xk4h15q xuxw1ft",
447
+ children: s
448
+ });
449
+ }
450
+ export { L as a, F as c, E as d, w as f, ie as h, Y as i, I as l, C as m, $ as n, z as o, T as p, Z as r, R as s, ce as t, D as u };
@@ -260,7 +260,8 @@ var j = y({
260
260
  }),
261
261
  attrs: (e, { key: t }) => ({
262
262
  "data-inspected": e.inspected === t ? "" : void 0,
263
- "data-selected": e.selected === t ? "" : void 0
263
+ "data-selected": e.selected === t ? "" : void 0,
264
+ "data-chart-mark": t
264
265
  }),
265
266
  selects: w({
266
267
  items: () => [],
@@ -115,26 +115,28 @@ function g({ d: e, tone: t, emphasis: n = "normal" }) {
115
115
  ...i.props(c.band, r.emphasis, d[n])
116
116
  });
117
117
  }
118
- function _({ x: t, y: n, tone: s, radius: l = o, isHollow: u = !1, emphasis: f = "normal", isInspected: m = !1, isSelected: h = !1 }) {
119
- let g = p(s, f);
118
+ function _({ x: t, y: n, tone: s, radius: l = o, isHollow: u = !1, emphasis: f = "normal", isInspected: m = !1, isSelected: h = !1, mark: g }) {
119
+ let _ = p(s, f);
120
120
  return /* @__PURE__ */ a("circle", {
121
+ "data-chart-mark": g,
121
122
  cx: t,
122
123
  cy: n,
123
124
  r: l,
124
- fill: g,
125
- stroke: u ? g : e[s],
125
+ fill: _,
126
+ stroke: u ? _ : e[s],
126
127
  ...i.props(r.outlined, r.emphasis, u && c.hollow, d[f], m && r.inspected, h && r.selected)
127
128
  });
128
129
  }
129
- function v({ x: t, y: n, width: o, height: s, tone: l, isHollow: u = !1, emphasis: f = "normal", isInspected: m = !1, isSelected: h = !1 }) {
130
- let g = p(l, f);
130
+ function v({ x: t, y: n, width: o, height: s, tone: l, isHollow: u = !1, emphasis: f = "normal", isInspected: m = !1, isSelected: h = !1, mark: g }) {
131
+ let _ = p(l, f);
131
132
  return /* @__PURE__ */ a("rect", {
133
+ "data-chart-mark": g,
132
134
  x: t,
133
135
  y: n,
134
136
  width: Math.max(0, o),
135
137
  height: Math.max(0, s),
136
- fill: g,
137
- stroke: u ? g : e[l],
138
+ fill: _,
139
+ stroke: u ? _ : e[l],
138
140
  ...i.props(r.outlined, r.emphasis, u && c.hollow, u && c.hollowBar, d[f], m && r.inspected, h && r.selected)
139
141
  });
140
142
  }
@@ -147,17 +149,18 @@ function b({ shape: e, x: t, y: n, radius: r }) {
147
149
  case "diamond": return `M${t},${n - i}L${t + i},${n}L${t},${n + i}L${t - i},${n}Z`;
148
150
  }
149
151
  }
150
- function x({ shape: t, x: n, y: s, tone: l, radius: u = o, isHollow: f = !1, emphasis: m = "normal", isInspected: h = !1, isSelected: g = !1 }) {
151
- let _ = p(l, m);
152
+ function x({ shape: t, x: n, y: s, tone: l, radius: u = o, isHollow: f = !1, emphasis: m = "normal", isInspected: h = !1, isSelected: g = !1, mark: _ }) {
153
+ let v = p(l, m);
152
154
  return /* @__PURE__ */ a("path", {
155
+ "data-chart-mark": _,
153
156
  d: b({
154
157
  shape: t,
155
158
  x: n,
156
159
  y: s,
157
160
  radius: u
158
161
  }),
159
- fill: _,
160
- stroke: f ? _ : e[l],
162
+ fill: v,
163
+ stroke: f ? v : e[l],
161
164
  ...i.props(r.outlined, r.emphasis, f && c.hollow, d[m], g ? r.selected : h && r.inspected)
162
165
  });
163
166
  }
@@ -1,5 +1,5 @@
1
1
  import { n as e, t } from "./plot-width-DcqtSgzb.js";
2
- import { E as n, c as r } from "./plot-layout-BEuoOHbs.js";
2
+ import { E as n, c as r } from "./plot-layout-CZVSJ-le.js";
3
3
  import * as i from "@stylexjs/stylex";
4
4
  import { useId as a } from "react";
5
5
  import { Fragment as o, jsx as s, jsxs as c } from "react/jsx-runtime";
@@ -1,7 +1,7 @@
1
- import { A as e } from "./plot-layout-BEuoOHbs.js";
1
+ import { A as e } from "./plot-layout-CZVSJ-le.js";
2
2
  import { t } from "./label-spacing-BncjePGb.js";
3
3
  import { n, t as r } from "./label-place-Z0fryBZb.js";
4
- import { c as i, f as a } from "./plot-marks-A64v7aTw.js";
4
+ import { c as i, f as a } from "./plot-marks-uozcbOIX.js";
5
5
  import { a as o } from "./scale-C2xgZyZN.js";
6
6
  import { jsx as s, jsxs as c } from "react/jsx-runtime";
7
7
  // packages/charts/src/cartesian/reference-lines.tsx