@canonical/react-motion-control 0.0.0-stage → 0.47.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 (115) hide show
  1. package/README.md +124 -2
  2. package/dist/esm/MotionHint/MotionHint.js +19 -0
  3. package/dist/esm/MotionHint/MotionHint.js.map +1 -0
  4. package/dist/esm/MotionHint/index.js +2 -0
  5. package/dist/esm/MotionHint/index.js.map +1 -0
  6. package/dist/esm/MotionHint/types.js +2 -0
  7. package/dist/esm/MotionHint/types.js.map +1 -0
  8. package/dist/esm/MotionScene/Context.js +4 -0
  9. package/dist/esm/MotionScene/Context.js.map +1 -0
  10. package/dist/esm/MotionScene/MotionScene.js +76 -0
  11. package/dist/esm/MotionScene/MotionScene.js.map +1 -0
  12. package/dist/esm/MotionScene/common/Controls/Controls.js +38 -0
  13. package/dist/esm/MotionScene/common/Controls/Controls.js.map +1 -0
  14. package/dist/esm/MotionScene/common/Controls/index.js +2 -0
  15. package/dist/esm/MotionScene/common/Controls/index.js.map +1 -0
  16. package/dist/esm/MotionScene/common/Controls/types.js +2 -0
  17. package/dist/esm/MotionScene/common/Controls/types.js.map +1 -0
  18. package/dist/esm/MotionScene/common/ExportSlide/ExportSlide.js +55 -0
  19. package/dist/esm/MotionScene/common/ExportSlide/ExportSlide.js.map +1 -0
  20. package/dist/esm/MotionScene/common/ExportSlide/constants.js +11 -0
  21. package/dist/esm/MotionScene/common/ExportSlide/constants.js.map +1 -0
  22. package/dist/esm/MotionScene/common/ExportSlide/index.js +3 -0
  23. package/dist/esm/MotionScene/common/ExportSlide/index.js.map +1 -0
  24. package/dist/esm/MotionScene/common/ExportSlide/types.js +2 -0
  25. package/dist/esm/MotionScene/common/ExportSlide/types.js.map +1 -0
  26. package/dist/esm/MotionScene/common/Frame/Frame.js +19 -0
  27. package/dist/esm/MotionScene/common/Frame/Frame.js.map +1 -0
  28. package/dist/esm/MotionScene/common/Frame/index.js +2 -0
  29. package/dist/esm/MotionScene/common/Frame/index.js.map +1 -0
  30. package/dist/esm/MotionScene/common/Frame/types.js +2 -0
  31. package/dist/esm/MotionScene/common/Frame/types.js.map +1 -0
  32. package/dist/esm/MotionScene/common/Title/Title.js +27 -0
  33. package/dist/esm/MotionScene/common/Title/Title.js.map +1 -0
  34. package/dist/esm/MotionScene/common/Title/index.js +2 -0
  35. package/dist/esm/MotionScene/common/Title/index.js.map +1 -0
  36. package/dist/esm/MotionScene/common/Title/types.js +2 -0
  37. package/dist/esm/MotionScene/common/Title/types.js.map +1 -0
  38. package/dist/esm/MotionScene/common/index.js +5 -0
  39. package/dist/esm/MotionScene/common/index.js.map +1 -0
  40. package/dist/esm/MotionScene/index.js +2 -0
  41. package/dist/esm/MotionScene/index.js.map +1 -0
  42. package/dist/esm/MotionScene/types.js +2 -0
  43. package/dist/esm/MotionScene/types.js.map +1 -0
  44. package/dist/esm/MotionSlide/MotionSlide.js +42 -0
  45. package/dist/esm/MotionSlide/MotionSlide.js.map +1 -0
  46. package/dist/esm/MotionSlide/index.js +2 -0
  47. package/dist/esm/MotionSlide/index.js.map +1 -0
  48. package/dist/esm/MotionSlide/types.js +2 -0
  49. package/dist/esm/MotionSlide/types.js.map +1 -0
  50. package/dist/esm/hooks/index.js +2 -0
  51. package/dist/esm/hooks/index.js.map +1 -0
  52. package/dist/esm/hooks/types.js +2 -0
  53. package/dist/esm/hooks/types.js.map +1 -0
  54. package/dist/esm/hooks/useMotion.js +228 -0
  55. package/dist/esm/hooks/useMotion.js.map +1 -0
  56. package/dist/esm/index.js +17 -0
  57. package/dist/esm/index.js.map +1 -0
  58. package/dist/esm/styles.css +81 -0
  59. package/dist/types/MotionHint/MotionHint.d.ts +7 -0
  60. package/dist/types/MotionHint/MotionHint.d.ts.map +1 -0
  61. package/dist/types/MotionHint/index.d.ts +3 -0
  62. package/dist/types/MotionHint/index.d.ts.map +1 -0
  63. package/dist/types/MotionHint/types.d.ts +7 -0
  64. package/dist/types/MotionHint/types.d.ts.map +1 -0
  65. package/dist/types/MotionScene/Context.d.ts +4 -0
  66. package/dist/types/MotionScene/Context.d.ts.map +1 -0
  67. package/dist/types/MotionScene/MotionScene.d.ts +8 -0
  68. package/dist/types/MotionScene/MotionScene.d.ts.map +1 -0
  69. package/dist/types/MotionScene/common/Controls/Controls.d.ts +8 -0
  70. package/dist/types/MotionScene/common/Controls/Controls.d.ts.map +1 -0
  71. package/dist/types/MotionScene/common/Controls/index.d.ts +3 -0
  72. package/dist/types/MotionScene/common/Controls/index.d.ts.map +1 -0
  73. package/dist/types/MotionScene/common/Controls/types.d.ts +10 -0
  74. package/dist/types/MotionScene/common/Controls/types.d.ts.map +1 -0
  75. package/dist/types/MotionScene/common/ExportSlide/ExportSlide.d.ts +9 -0
  76. package/dist/types/MotionScene/common/ExportSlide/ExportSlide.d.ts.map +1 -0
  77. package/dist/types/MotionScene/common/ExportSlide/constants.d.ts +28 -0
  78. package/dist/types/MotionScene/common/ExportSlide/constants.d.ts.map +1 -0
  79. package/dist/types/MotionScene/common/ExportSlide/index.d.ts +4 -0
  80. package/dist/types/MotionScene/common/ExportSlide/index.d.ts.map +1 -0
  81. package/dist/types/MotionScene/common/ExportSlide/types.d.ts +23 -0
  82. package/dist/types/MotionScene/common/ExportSlide/types.d.ts.map +1 -0
  83. package/dist/types/MotionScene/common/Frame/Frame.d.ts +12 -0
  84. package/dist/types/MotionScene/common/Frame/Frame.d.ts.map +1 -0
  85. package/dist/types/MotionScene/common/Frame/index.d.ts +3 -0
  86. package/dist/types/MotionScene/common/Frame/index.d.ts.map +1 -0
  87. package/dist/types/MotionScene/common/Frame/types.d.ts +11 -0
  88. package/dist/types/MotionScene/common/Frame/types.d.ts.map +1 -0
  89. package/dist/types/MotionScene/common/Title/Title.d.ts +8 -0
  90. package/dist/types/MotionScene/common/Title/Title.d.ts.map +1 -0
  91. package/dist/types/MotionScene/common/Title/index.d.ts +3 -0
  92. package/dist/types/MotionScene/common/Title/index.d.ts.map +1 -0
  93. package/dist/types/MotionScene/common/Title/types.d.ts +18 -0
  94. package/dist/types/MotionScene/common/Title/types.d.ts.map +1 -0
  95. package/dist/types/MotionScene/common/index.d.ts +5 -0
  96. package/dist/types/MotionScene/common/index.d.ts.map +1 -0
  97. package/dist/types/MotionScene/index.d.ts +4 -0
  98. package/dist/types/MotionScene/index.d.ts.map +1 -0
  99. package/dist/types/MotionScene/types.d.ts +31 -0
  100. package/dist/types/MotionScene/types.d.ts.map +1 -0
  101. package/dist/types/MotionSlide/MotionSlide.d.ts +15 -0
  102. package/dist/types/MotionSlide/MotionSlide.d.ts.map +1 -0
  103. package/dist/types/MotionSlide/index.d.ts +3 -0
  104. package/dist/types/MotionSlide/index.d.ts.map +1 -0
  105. package/dist/types/MotionSlide/types.d.ts +26 -0
  106. package/dist/types/MotionSlide/types.d.ts.map +1 -0
  107. package/dist/types/hooks/index.d.ts +3 -0
  108. package/dist/types/hooks/index.d.ts.map +1 -0
  109. package/dist/types/hooks/types.d.ts +86 -0
  110. package/dist/types/hooks/types.d.ts.map +1 -0
  111. package/dist/types/hooks/useMotion.d.ts +16 -0
  112. package/dist/types/hooks/useMotion.d.ts.map +1 -0
  113. package/dist/types/index.d.ts +21 -0
  114. package/dist/types/index.d.ts.map +1 -0
  115. package/package.json +77 -4
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MotionSlide.js","sourceRoot":"","sources":["../../../src/MotionSlide/MotionSlide.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAc,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAsB,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC9E,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAGtD,MAAM,qBAAqB,GAAG,UAAU,CAAC;AAEzC,wGAAwG;AACxG,MAAM,MAAM,GAAU,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;A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AAS,CAAC;aAC9D,MAAM,CAAC,OAAO,CAAC;aACf,IAAI,CAAC,GAAG,CAAC,EACZ,KAAK,EACH;YACE,KAAK;YACL,MAAM;YACN,iBAAiB,EAAE,GAAG,IAAI,IAAI;YAC9B,GAAG,KAAK;SACQ,KAEhB,IAAI,aAEP,KAAK,IAAI,YAAG,SAAS,EAAC,gBAAgB,YAAE,KAAK,GAAK,EACnD,cAAK,SAAS,EAAC,gBAAgB,YAC7B,cACE,SAAS,EAAC,cAAc,EACxB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,EAAE,SAAS,EAAE,SAAS,KAAK,GAAG,EAAE,YAEvC,KAAC,WAAW,IACV,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,EACrC,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,YAEX,QAAQ,GACG,GACV,GACF,EACL,OAAO,IAAI,YAAG,SAAS,EAAC,kBAAkB,YAAE,OAAO,GAAK,IACrD,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { default as MotionSlide } from "./MotionSlide.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/MotionSlide/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/MotionSlide/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export { default as useMotion } from "./useMotion.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/hooks/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,228 @@
1
+ import { applyMoment, assertPresent, drawSprites, installStateRules, mergeProfile, PRACTICE_AT, readLayerBox, SPEEDS, } from "@canonical/motion-control/dom";
2
+ import { describeMoment, } from "@canonical/motion-control/moment";
3
+ import { advanceClock, buildTimeline, findKeyframe, stepKeyframe as findStep, locateTime, } from "@canonical/motion-control/timeline";
4
+ import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, } from "react";
5
+ /** Finds a frame among the children of the screen by its name. */
6
+ const findFrame = (screen, name) => Array.from(screen.children).find((child) => child instanceof HTMLElement && child.dataset.frame === name) ?? null;
7
+ /**
8
+ * Plays a scene over frames that are living parts of the page.
9
+ *
10
+ * The hook holds where the scene is and runs its clock. After every change of position it works out what the
11
+ * scene shows there, makes the frame in view show it, and draws the symbols over it; before the next change it
12
+ * takes everything it did to the frame back, because the frame is the application's own and is not drawn afresh.
13
+ *
14
+ * @param scene - The scene to play. Its first step must show a frame.
15
+ * @param options - The application's profile, the speeds, whether to wait for the reader at steps marked for
16
+ * practice, how keys are shown, whether to play while in view, and what to call when the step changes or the scene ends.
17
+ * @returns Refs for the screen and the layer, where the scene is, what it shows, and the ways to move it.
18
+ */
19
+ const useMotion = (...[scene, options = {}]) => {
20
+ const screenRef = useRef(null);
21
+ const layerRef = useRef(null);
22
+ const profile = useMemo(() => mergeProfile(options.profile), [options.profile]);
23
+ const speeds = useMemo(() => [...new Set([1, ...(options.speeds ?? SPEEDS)])].sort((one, other) => one - other), [options.speeds]);
24
+ const { keys, outline } = options;
25
+ const [timeline, setTimeline] = useState();
26
+ const [position, setPosition] = useState({ index: 0, progress: 0 });
27
+ const [moment, setMoment] = useState();
28
+ const [playing, setPlaying] = useState(false);
29
+ const [speed, setSpeed] = useState(1);
30
+ const [awaiting, setAwaiting] = useState();
31
+ // The reader's choice, once made, wins over the application's and the cast's.
32
+ const [chosen, setLoop] = useState();
33
+ const loop = chosen ?? options.loop ?? scene.loop !== false;
34
+ const looping = useRef(loop);
35
+ looping.current = loop;
36
+ // What the clock reads between renders: the time, the speed, and the steps the reader has done this round.
37
+ const clock = useRef(0);
38
+ const pace = useRef(1);
39
+ const practised = useRef(-1);
40
+ const callbacks = useRef(options);
41
+ callbacks.current = options;
42
+ // The frame in view is known from the scene alone, so the first paint already shows the right one.
43
+ // A scene starts with a frame, so every step has one before it.
44
+ const frame = useMemo(() => scene.steps
45
+ .slice(0, position.index + 1)
46
+ .findLast((step) => "frame" in step).frame, [scene, position.index]);
47
+ // How long typing lasts depends on the words a frame shows, and those are only on the page once it is drawn.
48
+ useLayoutEffect(() => {
49
+ const screen = assertPresent(screenRef.current, "the screen");
50
+ installStateRules(screen.ownerDocument);
51
+ setTimeline(buildTimeline(scene, (name) => {
52
+ const line = findFrame(screen, name)?.querySelector(profile.line);
53
+ return line ? profile.readLine(line) : "";
54
+ }));
55
+ clock.current = 0;
56
+ practised.current = -1;
57
+ setPosition({ index: 0, progress: 0 });
58
+ }, [scene, profile]);
59
+ // Draw the position: describe the moment, make the frame show it, draw the symbols. Undo it before the next.
60
+ useLayoutEffect(() => {
61
+ if (timeline === undefined)
62
+ return;
63
+ const screen = assertPresent(screenRef.current, "the screen");
64
+ const layer = assertPresent(layerRef.current, "the layer");
65
+ const { index, progress } = position;
66
+ const key = timeline.steps[findKeyframe(timeline, index)];
67
+ const shown = findFrame(screen, key.frame) ?? screen;
68
+ // Places are measured on the page and drawn in the layer, which a slide round the scene may scale.
69
+ const measure = (aim, fallback = [0.5, 0.5]) => {
70
+ const around = readLayerBox(layer);
71
+ const target = (aim.on ? shown.querySelector(aim.on) : null) ?? shown;
72
+ const box = target.getBoundingClientRect();
73
+ const [fx, fy] = aim.at ?? fallback;
74
+ return {
75
+ x: (box.left - around.left + box.width * fx) / around.scale,
76
+ y: (box.top - around.top + box.height * fy) / around.scale,
77
+ width: around.width,
78
+ height: around.height,
79
+ };
80
+ };
81
+ const described = describeMoment(index, progress, {
82
+ timeline,
83
+ measure,
84
+ rightToLeft: getComputedStyle(shown).direction === "rtl",
85
+ scroll: profile.scroll,
86
+ label: (name) => ({
87
+ code: findFrame(screen, name)?.dataset.code ?? "",
88
+ name,
89
+ }),
90
+ });
91
+ const applied = applyMoment(shown, described, profile, outline);
92
+ shown.style.opacity = String(described.fade);
93
+ drawSprites(layer, described.sprites, {
94
+ typing: applied.typing,
95
+ strokes: applied.strokes,
96
+ outlined: applied.outlined,
97
+ keys,
98
+ line: applied.line,
99
+ });
100
+ setMoment(described);
101
+ return () => {
102
+ applied.undo();
103
+ shown.style.opacity = "";
104
+ };
105
+ }, [position, timeline, profile, keys, outline]);
106
+ const step = position.index;
107
+ useEffect(() => {
108
+ callbacks.current.onStep?.(step);
109
+ }, [step]);
110
+ const show = useCallback((time) => {
111
+ const laid = assertPresent(timeline, "the scene's timeline");
112
+ const next = locateTime(laid, time);
113
+ clock.current =
114
+ laid.starts[next.index] +
115
+ next.progress * laid.durations[next.index];
116
+ setPosition(next);
117
+ }, [timeline]);
118
+ const pause = useCallback(() => setPlaying(false), []);
119
+ const play = useCallback(() => setPlaying(true), []);
120
+ const seek = useCallback((time) => {
121
+ setAwaiting(undefined);
122
+ show(time);
123
+ }, [show]);
124
+ // The clock: one tick per painted frame of the page, for as long as the scene plays.
125
+ useEffect(() => {
126
+ if (!playing || timeline === undefined)
127
+ return;
128
+ let last = performance.now();
129
+ let request = 0;
130
+ const tick = (now) => {
131
+ const ticked = advanceClock({ ...timeline, loop: looping.current }, clock.current, now - last, pace.current);
132
+ last = now;
133
+ if (ticked.ended || ticked.looped) {
134
+ practised.current = -1;
135
+ callbacks.current.onEnd?.();
136
+ }
137
+ if (ticked.ended) {
138
+ show(ticked.clock);
139
+ setPlaying(false);
140
+ return;
141
+ }
142
+ // A step marked for practice waits for the reader: the scene stops where the symbol shows what to do.
143
+ const { index } = locateTime(timeline, ticked.clock);
144
+ const waits = timeline.steps[index];
145
+ if (callbacks.current.practice &&
146
+ waits !== undefined &&
147
+ "do" in waits &&
148
+ waits.practice &&
149
+ index > practised.current) {
150
+ setAwaiting(index);
151
+ setPlaying(false);
152
+ clock.current =
153
+ timeline.starts[index] +
154
+ timeline.durations[index] * PRACTICE_AT;
155
+ setPosition({ index, progress: PRACTICE_AT });
156
+ return;
157
+ }
158
+ show(ticked.clock);
159
+ request = requestAnimationFrame(tick);
160
+ };
161
+ request = requestAnimationFrame(tick);
162
+ return () => cancelAnimationFrame(request);
163
+ }, [playing, timeline, show]);
164
+ // Play while in view, unless the reader asked for less motion or the application said not to.
165
+ const autoPlay = options.autoPlay;
166
+ useEffect(() => {
167
+ const screen = screenRef.current;
168
+ if (autoPlay === false ||
169
+ screen === null ||
170
+ typeof IntersectionObserver === "undefined" ||
171
+ matchMedia("(prefers-reduced-motion: reduce)").matches) {
172
+ return;
173
+ }
174
+ const watcher = new IntersectionObserver((entries) => setPlaying(entries.some((entry) => entry.isIntersecting)), { threshold: 0.3 });
175
+ watcher.observe(screen);
176
+ return () => watcher.disconnect();
177
+ }, [autoPlay]);
178
+ const stepKeyframe = useCallback((direction) => {
179
+ const laid = assertPresent(timeline, "the scene's timeline");
180
+ const index = findStep(laid, position.index, direction);
181
+ setPlaying(false);
182
+ setAwaiting(undefined);
183
+ clock.current =
184
+ laid.starts[index] +
185
+ laid.durations[index] * 0.999;
186
+ setPosition({ index, progress: 1 });
187
+ }, [timeline, position.index]);
188
+ const cycleSpeed = useCallback(() => {
189
+ const next = speeds[(speeds.indexOf(pace.current) + 1) % speeds.length];
190
+ pace.current = next;
191
+ setSpeed(pace.current);
192
+ }, [speeds]);
193
+ const press = useCallback((pressed) => {
194
+ if (awaiting === undefined)
195
+ return;
196
+ const laid = assertPresent(timeline, "the scene's timeline");
197
+ const waited = laid.steps[awaiting];
198
+ if (waited.on !== undefined && pressed.closest(waited.on) === null) {
199
+ return;
200
+ }
201
+ practised.current = awaiting;
202
+ setAwaiting(undefined);
203
+ setPlaying(true);
204
+ }, [awaiting, timeline]);
205
+ return {
206
+ screenRef,
207
+ layerRef,
208
+ frame,
209
+ timeline,
210
+ position,
211
+ moment,
212
+ profile,
213
+ playing,
214
+ speed,
215
+ speeds,
216
+ loop,
217
+ awaiting,
218
+ play,
219
+ pause,
220
+ seek,
221
+ stepKeyframe,
222
+ cycleSpeed,
223
+ setLoop,
224
+ press,
225
+ };
226
+ };
227
+ export default useMotion;
228
+ //# sourceMappingURL=useMotion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMotion.js","sourceRoot":"","sources":["../../../src/hooks/useMotion.ts"],"names":[],"mappings":"AACA,OAAO,EACL,WAAW,EACX,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,MAAM,GACP,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,cAAc,GAGf,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,YAAY,IAAI,QAAQ,EACxB,UAAU,GAGX,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,WAAW,EACX,SAAS,EACT,eAAe,EACf,OAAO,EACP,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AAGf,kEAAkE;AAClE,MAAM,SAAS,GAAG,CAAC,MAAmB,EAAE,IAAY,EAAsB,EAAE,CAC1E,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,QAA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AAC,QAAQ,EAAE,sBAAsB,CAAC,CAAC;QAC7D,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAoB,CAAC;QACvD,IAAI,MAAM,CAAC,EAAE,KAAK,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC;YACnE,OAAO;QACT,CAAC;QACD,SAAS,CAAC,OAAO,GAAG,QAAQ,CAAC;QAC7B,WAAW,CAAC,SAAS,CAAC,CAAC;QACvB,UAAU,CAAC,IAAI,CAAC,CAAC;IACnB,CAAC,EACD,CAAC,QAAQ,EAAE,QAAQ,CAAC,CACrB,CAAC;IAEF,OAAO;QACL,SAAS;QACT,QAAQ;QACR,KAAK;QACL,QAAQ;QACR,QAAQ;QACR,MAAM;QACN,OAAO;QACP,OAAO;QACP,KAAK;QACL,MAAM;QACN,IAAI;QACJ,QAAQ;QACR,IAAI;QACJ,KAAK;QACL,IAAI;QACJ,YAAY;QACZ,UAAU;QACV,OAAO;QACP,KAAK;KACN,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * React components that play motion scenes over an application's own components.
3
+ *
4
+ * `MotionScene` plays a scene in the page, `MotionHint` a small scene beside the thing it explains, and
5
+ * `MotionSlide` a scene on a slide of a deck, at the slide's full size. `useMotion` is what they are made of, for
6
+ * a figure of another shape. A scene's menu exports it on a slide, as a video or a GIF.
7
+ *
8
+ * The stylesheet of `@canonical/motion-control` and this package's own are needed once in the application:
9
+ * `import "@canonical/motion-control/style.css"; import "@canonical/react-motion-control/style.css";`
10
+ *
11
+ * @module
12
+ */
13
+ export { useMotion } from "./hooks/index.js";
14
+ export { MotionHint } from "./MotionHint/index.js";
15
+ export { MotionScene } from "./MotionScene/index.js";
16
+ export { MotionSlide } from "./MotionSlide/index.js";
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAOH,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC"}
@@ -0,0 +1,81 @@
1
+ /* The layer of symbols is laid over the stage, so the stage is what it is placed against. */
2
+ .mo-stage {
3
+ position: relative;
4
+ }
5
+
6
+ /* The frames of a scene are living parts of the page, all there at once and laid on top of each other, so the
7
+ screen is as tall as the tallest and nothing jumps between them. Only the frame in view shows. */
8
+ .mo-live {
9
+ display: grid;
10
+ }
11
+ /* A frame fills the screen, and so does what it holds, so a shorter state is not left short of the edge. */
12
+ .mo-frame-live {
13
+ grid-area: 1 / 1;
14
+ display: grid;
15
+ min-width: 0;
16
+ visibility: hidden;
17
+ }
18
+ .mo-frame-live[data-current] {
19
+ visibility: visible;
20
+ }
21
+ .mo-frame-live[hidden] {
22
+ display: none;
23
+ }
24
+
25
+ /* The form that exports a scene on a slide: over the figure, in the panel's colours. */
26
+ .mo-export {
27
+ position: fixed;
28
+ inset: 0;
29
+ z-index: 20;
30
+ margin: auto;
31
+ width: min(420px, calc(100vw - 32px));
32
+ height: max-content;
33
+ padding: 16px 20px;
34
+ border: 1px solid var(--mo-edge, var(--mo-bg, #111));
35
+ background: var(--mo-bg, #111);
36
+ color: var(--mo-fg, #f4f4f0);
37
+ font: inherit;
38
+ }
39
+ .mo-export fieldset {
40
+ display: grid;
41
+ grid-template-columns: auto minmax(0, 1fr);
42
+ gap: 8px 12px;
43
+ margin: 0;
44
+ padding: 0;
45
+ border: 0;
46
+ }
47
+ .mo-export legend {
48
+ margin-bottom: 12px;
49
+ font-weight: 600;
50
+ }
51
+ .mo-export label {
52
+ display: contents;
53
+ }
54
+ .mo-export input,
55
+ .mo-export select,
56
+ .mo-export button {
57
+ font: inherit;
58
+ min-width: 0;
59
+ }
60
+ .mo-export-state {
61
+ min-height: 1.45em;
62
+ margin: 12px 0 0;
63
+ opacity: 0.75;
64
+ }
65
+ .mo-export-actions {
66
+ display: flex;
67
+ justify-content: end;
68
+ gap: 12px;
69
+ margin-top: 8px;
70
+ }
71
+
72
+ /* A live slide: the same layout as a recorded one; a bare slide shows the screen with no figure round it. */
73
+ .mo-slide-bare .motion-figure {
74
+ border: 0;
75
+ background: none;
76
+ }
77
+
78
+ /* A hint: a scene with nothing beside its screen but the words of its caption. */
79
+ .mo-hint {
80
+ width: min(280px, 100%);
81
+ }
@@ -0,0 +1,7 @@
1
+ import type { MotionHintProps } from "./types.js";
2
+ declare function MotionHint({ className, ...rest }: MotionHintProps): import("react/jsx-runtime").JSX.Element;
3
+ declare namespace MotionHint {
4
+ var Frame: ({ name, code, className, children, ...rest }: import("../MotionScene/index.js").FrameProps) => import("react/jsx-runtime").JSX.Element;
5
+ }
6
+ export default MotionHint;
7
+ //# sourceMappingURL=MotionHint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MotionHint.d.ts","sourceRoot":"","sources":["../../../src/MotionHint/MotionHint.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;4BAiB9B,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,EAAE,eAAe;;;;eAU5C,UAAU"}
@@ -0,0 +1,3 @@
1
+ export { default as MotionHint } from "./MotionHint.js";
2
+ export type { MotionHintProps } from "./types.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/MotionHint/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACxD,YAAY,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { MotionSceneProps } from "../MotionScene/index.js";
2
+ /**
3
+ * Props for `MotionHint`: those of `MotionScene`, without the choice of what shows beside the screen, which a
4
+ * hint makes itself.
5
+ */
6
+ export type MotionHintProps = Omit<MotionSceneProps, "show" | "titlePlace">;
7
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/MotionHint/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,gBAAgB,EAAE,MAAM,GAAG,YAAY,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { SceneFrames } from "./types.js";
2
+ declare const Context: import("react").Context<SceneFrames>;
3
+ export default Context;
4
+ //# sourceMappingURL=Context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../../src/MotionScene/Context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,QAAA,MAAM,OAAO,sCAA+D,CAAC;eAE9D,OAAO"}
@@ -0,0 +1,8 @@
1
+ import { Frame } from "./common/index.js";
2
+ import type { MotionSceneProps } from "./types.js";
3
+ declare function MotionScene({ scene, titlePlace, show, profile, speeds, keys, outline, practice, loop, autoPlay, onStep, onEnd, className, children, ...rest }: MotionSceneProps): import("react/jsx-runtime").JSX.Element;
4
+ declare namespace MotionScene {
5
+ export { Frame };
6
+ }
7
+ export default MotionScene;
8
+ //# sourceMappingURL=MotionScene.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MotionScene.d.ts","sourceRoot":"","sources":["../../../src/MotionScene/MotionScene.tsx"],"names":[],"mappings":"AAYA,OAAO,EAGL,KAAK,EAGN,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;6BAa9B,EACnB,KAAK,EACL,UAAoB,EACpB,IAAI,EACJ,OAAO,EACP,MAAM,EACN,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,KAAK,EACL,SAAS,EACT,QAAQ,EACR,GAAG,IAAI,EACR,EAAE,gBAAgB;;;;eAqIJ,WAAW"}
@@ -0,0 +1,8 @@
1
+ import type { ControlsProps } from "./types.js";
2
+ /**
3
+ * The controls' row of a scene: back, play and forward; the bar, one segment per step, to press or drag to any
4
+ * moment; and what is read off the bar, the speed and the time.
5
+ */
6
+ declare const Controls: ({ motion, words }: ControlsProps) => import("react/jsx-runtime").JSX.Element;
7
+ export default Controls;
8
+ //# sourceMappingURL=Controls.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Controls.d.ts","sourceRoot":"","sources":["../../../../../src/MotionScene/common/Controls/Controls.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD;;;GAGG;AACH,QAAA,MAAM,QAAQ,sBAAuB,aAAa,4CAmGjD,CAAC;eAEa,QAAQ"}
@@ -0,0 +1,3 @@
1
+ export { default as Controls } from "./Controls.js";
2
+ export type { ControlsProps } from "./types.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/MotionScene/common/Controls/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC;AACpD,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { Words } from "@canonical/motion-control/dom";
2
+ import type { UseMotionResult } from "../../../hooks/index.js";
3
+ /** Props for the controls' row of a scene. */
4
+ export interface ControlsProps {
5
+ /** The scene as `useMotion` plays it. */
6
+ motion: UseMotionResult;
7
+ /** The words of the panel. */
8
+ words: Words;
9
+ }
10
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/MotionScene/common/Controls/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE/D,8CAA8C;AAC9C,MAAM,WAAW,aAAa;IAC5B,yCAAyC;IACzC,MAAM,EAAE,eAAe,CAAC;IACxB,8BAA8B;IAC9B,KAAK,EAAE,KAAK,CAAC;CACd"}
@@ -0,0 +1,9 @@
1
+ import type { ExportSlideProps } from "./types.js";
2
+ /**
3
+ * A form that exports a scene on a slide: the slide's size, typed in or chosen from the usual ones, whether it
4
+ * shows the whole figure or the screen alone, its title and caption, how fast the scene plays, and whether the
5
+ * file is a video or a GIF. While the scene records, the form says how far it is.
6
+ */
7
+ declare const ExportSlide: ({ scene, onClose, onExport }: ExportSlideProps) => import("react/jsx-runtime").JSX.Element;
8
+ export default ExportSlide;
9
+ //# sourceMappingURL=ExportSlide.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExportSlide.d.ts","sourceRoot":"","sources":["../../../../../src/MotionScene/common/ExportSlide/ExportSlide.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAe,MAAM,YAAY,CAAC;AAIhE;;;;GAIG;AACH,QAAA,MAAM,WAAW,iCAAkC,gBAAgB,4CAqKlE,CAAC;eAEa,WAAW"}
@@ -0,0 +1,28 @@
1
+ /** The sizes a slide is offered at first, by name; any other can be typed in. */
2
+ export declare const SLIDE_SIZES: readonly [{
3
+ readonly name: "4K 16:10";
4
+ readonly width: 3840;
5
+ readonly height: 2400;
6
+ }, {
7
+ readonly name: "4K 16:9";
8
+ readonly width: 3840;
9
+ readonly height: 2160;
10
+ }, {
11
+ readonly name: "1080p 16:9";
12
+ readonly width: 1920;
13
+ readonly height: 1080;
14
+ }, {
15
+ readonly name: "1080p 16:10";
16
+ readonly width: 1920;
17
+ readonly height: 1200;
18
+ }, {
19
+ readonly name: "Square";
20
+ readonly width: 2160;
21
+ readonly height: 2160;
22
+ }];
23
+ /** Pictures per second when the reader asks for none: smooth for a video, small for a GIF. */
24
+ export declare const DEFAULT_FPS: {
25
+ readonly mp4: 30;
26
+ readonly gif: 10;
27
+ };
28
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../src/MotionScene/common/ExportSlide/constants.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,eAAO,MAAM,WAAW;aACpB,IAAI,EAAE,UAAU;aAAE,KAAK,EAAE,IAAI;aAAE,MAAM,EAAE,IAAI;;aAC3C,IAAI,EAAE,SAAS;aAAE,KAAK,EAAE,IAAI;aAAE,MAAM,EAAE,IAAI;;aAC1C,IAAI,EAAE,YAAY;aAAE,KAAK,EAAE,IAAI;aAAE,MAAM,EAAE,IAAI;;aAC7C,IAAI,EAAE,aAAa;aAAE,KAAK,EAAE,IAAI;aAAE,MAAM,EAAE,IAAI;;aAC9C,IAAI,EAAE,QAAQ;aAAE,KAAK,EAAE,IAAI;aAAE,MAAM,EAAE,IAAI;EACnC,CAAC;AAEX,8FAA8F;AAC9F,eAAO,MAAM,WAAW;aAAK,GAAG,EAAE,EAAE;aAAE,GAAG,EAAE,EAAE;CAAW,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { DEFAULT_FPS, SLIDE_SIZES } from "./constants.js";
2
+ export { default as ExportSlide } from "./ExportSlide.js";
3
+ export type { ExportSlideProps, SlideExport } from "./types.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/MotionScene/common/ExportSlide/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC1D,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,23 @@
1
+ import type { Scene } from "@canonical/motion-control/cast";
2
+ import type { Slide } from "@canonical/motion-control/dom";
3
+ /** What a reader asks of an export: the slide, how fast the scene plays on it, and the file. */
4
+ export interface SlideExport {
5
+ /** The slide's size, what of the figure it shows, and its title and caption. */
6
+ slide: Slide;
7
+ /** How many times faster than written the scene plays in the file. */
8
+ speed: number;
9
+ /** The file: an MP4 video, or an animated GIF. */
10
+ format: "mp4" | "gif";
11
+ /** Pictures per second. */
12
+ fps: number;
13
+ }
14
+ /** Props for the form that exports a scene on a slide. */
15
+ export interface ExportSlideProps {
16
+ /** The scene, whose title the slide's title starts from. */
17
+ scene: Scene;
18
+ /** Called when the reader closes the form without exporting, or once the file is handed over. */
19
+ onClose: () => void;
20
+ /** Records the scene as asked and hands the reader the file. Gives how far it is, from 0 to 1. */
21
+ onExport: (asked: SlideExport, onProgress: (done: number) => void) => Promise<void>;
22
+ }
23
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/MotionScene/common/ExportSlide/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAC;AAE3D,gGAAgG;AAChG,MAAM,WAAW,WAAW;IAC1B,gFAAgF;IAChF,KAAK,EAAE,KAAK,CAAC;IACb,sEAAsE;IACtE,KAAK,EAAE,MAAM,CAAC;IACd,kDAAkD;IAClD,MAAM,EAAE,KAAK,GAAG,KAAK,CAAC;IACtB,2BAA2B;IAC3B,GAAG,EAAE,MAAM,CAAC;CACb;AAED,0DAA0D;AAC1D,MAAM,WAAW,gBAAgB;IAC/B,4DAA4D;IAC5D,KAAK,EAAE,KAAK,CAAC;IACb,iGAAiG;IACjG,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,kGAAkG;IAClG,QAAQ,EAAE,CACR,KAAK,EAAE,WAAW,EAClB,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,KAC/B,OAAO,CAAC,IAAI,CAAC,CAAC;CACpB"}
@@ -0,0 +1,12 @@
1
+ import type { FrameProps } from "./types.js";
2
+ /**
3
+ * One frame of a scene: the application's own components in one state, with a name the scene's steps call it
4
+ * by. Every frame a scene shows is on the page at once, so each has its data and its size from the start; only
5
+ * the frame in view shows and can be reached. A frame the scene never shows takes no room, so one set of
6
+ * frames can serve many scenes.
7
+ *
8
+ * `import { MotionScene } from "@canonical/react-motion-control";`
9
+ */
10
+ declare const Frame: ({ name, code, className, children, ...rest }: FrameProps) => import("react/jsx-runtime").JSX.Element;
11
+ export default Frame;
12
+ //# sourceMappingURL=Frame.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Frame.d.ts","sourceRoot":"","sources":["../../../../../src/MotionScene/common/Frame/Frame.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAI7C;;;;;;;GAOG;AACH,QAAA,MAAM,KAAK,iDAAkD,UAAU,4CAgBtE,CAAC;eAEa,KAAK"}
@@ -0,0 +1,3 @@
1
+ export { default as Frame } from "./Frame.js";
2
+ export type { FrameProps } from "./types.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/MotionScene/common/Frame/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,YAAY,CAAC;AAC9C,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { ComponentProps } from "react";
2
+ interface OwnProps {
3
+ /** The frame's name, as the scene's steps call it: `<view>.<state>`. */
4
+ name: string;
5
+ /** The short code the panel shows for the frame. */
6
+ code?: string;
7
+ }
8
+ /** Props for `MotionScene.Frame`: its own, and every attribute a native `<div>` accepts. */
9
+ export type FrameProps = OwnProps & Omit<ComponentProps<"div">, keyof OwnProps>;
10
+ export {};
11
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/MotionScene/common/Frame/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAE5C,UAAU,QAAQ;IAChB,wEAAwE;IACxE,IAAI,EAAE,MAAM,CAAC;IACb,oDAAoD;IACpD,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,4FAA4F;AAC5F,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,MAAM,QAAQ,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { TitleProps } from "./types.js";
2
+ /**
3
+ * The title's row of a scene: what it is, its title as a link to itself, what it is about, and three dots that
4
+ * open the menu of what else a reader can do with it.
5
+ */
6
+ declare const Title: ({ scene, words, onSave, onExportSlide, loop, onLoop, }: TitleProps) => import("react/jsx-runtime").JSX.Element;
7
+ export default Title;
8
+ //# sourceMappingURL=Title.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Title.d.ts","sourceRoot":"","sources":["../../../../../src/MotionScene/common/Title/Title.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C;;;GAGG;AACH,QAAA,MAAM,KAAK,2DAOR,UAAU,4CA+DZ,CAAC;eAEa,KAAK"}