@pinecall/dot 0.11.24 → 0.11.26
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 +135 -59
- package/dist/agent/index.d.ts +3 -2
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +2 -1
- package/dist/agent/index.js.map +1 -1
- package/dist/agent/tutor.d.ts +8 -10
- package/dist/agent/tutor.d.ts.map +1 -1
- package/dist/agent/tutor.js +71 -74
- package/dist/agent/tutor.js.map +1 -1
- package/dist/agent/walks.d.ts +19 -0
- package/dist/agent/walks.d.ts.map +1 -0
- package/dist/agent/walks.js +89 -0
- package/dist/agent/walks.js.map +1 -0
- package/dist/page/page.d.ts +2 -2
- package/dist/page/page.d.ts.map +1 -1
- package/dist/page/page.js +5 -5
- package/dist/page/page.js.map +1 -1
- package/dist/page/roles.d.ts +2 -0
- package/dist/page/roles.d.ts.map +1 -1
- package/dist/page/roles.js +21 -2
- package/dist/page/roles.js.map +1 -1
- package/dist/pointer/asking.d.ts +25 -0
- package/dist/pointer/asking.d.ts.map +1 -0
- package/dist/pointer/asking.js +82 -0
- package/dist/pointer/asking.js.map +1 -0
- package/dist/pointer/flight.d.ts +28 -0
- package/dist/pointer/flight.d.ts.map +1 -1
- package/dist/pointer/flight.js +93 -7
- package/dist/pointer/flight.js.map +1 -1
- package/dist/pointer/frames.d.ts +28 -0
- package/dist/pointer/frames.d.ts.map +1 -0
- package/dist/pointer/frames.js +66 -0
- package/dist/pointer/frames.js.map +1 -0
- package/dist/pointer/icons.d.ts +8 -0
- package/dist/pointer/icons.d.ts.map +1 -0
- package/dist/pointer/icons.js +15 -0
- package/dist/pointer/icons.js.map +1 -0
- package/dist/pointer/menu.d.ts +3 -0
- package/dist/pointer/menu.d.ts.map +1 -1
- package/dist/pointer/menu.js +26 -6
- package/dist/pointer/menu.js.map +1 -1
- package/dist/pointer/person.d.ts +13 -2
- package/dist/pointer/person.d.ts.map +1 -1
- package/dist/pointer/person.js +47 -41
- package/dist/pointer/person.js.map +1 -1
- package/dist/pointer/pressing.d.ts +6 -0
- package/dist/pointer/pressing.d.ts.map +1 -0
- package/dist/pointer/pressing.js +32 -0
- package/dist/pointer/pressing.js.map +1 -0
- package/dist/pointer/typing.d.ts +5 -3
- package/dist/pointer/typing.d.ts.map +1 -1
- package/dist/pointer/typing.js +46 -15
- package/dist/pointer/typing.js.map +1 -1
- package/dist/server/index.d.ts +34 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +108 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/questions.d.ts +30 -0
- package/dist/server/questions.d.ts.map +1 -0
- package/dist/server/questions.js +136 -0
- package/dist/server/questions.js.map +1 -0
- package/dist/server/saying.d.ts +31 -0
- package/dist/server/saying.d.ts.map +1 -0
- package/dist/server/saying.js +124 -0
- package/dist/server/saying.js.map +1 -0
- package/dist/tutor/acting.d.ts +42 -0
- package/dist/tutor/acting.d.ts.map +1 -0
- package/dist/tutor/acting.js +180 -0
- package/dist/tutor/acting.js.map +1 -0
- package/dist/tutor/aloud.d.ts +50 -0
- package/dist/tutor/aloud.d.ts.map +1 -0
- package/dist/tutor/aloud.js +288 -0
- package/dist/tutor/aloud.js.map +1 -0
- package/dist/tutor/ask.d.ts +49 -0
- package/dist/tutor/ask.d.ts.map +1 -0
- package/dist/tutor/ask.js +47 -0
- package/dist/tutor/ask.js.map +1 -0
- package/dist/tutor/listening.d.ts +17 -0
- package/dist/tutor/listening.d.ts.map +1 -0
- package/dist/tutor/listening.js +66 -0
- package/dist/tutor/listening.js.map +1 -0
- package/dist/tutor/options.d.ts +37 -1
- package/dist/tutor/options.d.ts.map +1 -1
- package/dist/tutor/options.js +1 -1
- package/dist/tutor/options.js.map +1 -1
- package/dist/tutor/reading.d.ts +58 -0
- package/dist/tutor/reading.d.ts.map +1 -0
- package/dist/tutor/reading.js +193 -0
- package/dist/tutor/reading.js.map +1 -0
- package/dist/tutor/text.d.ts +16 -0
- package/dist/tutor/text.d.ts.map +1 -0
- package/dist/tutor/text.js +119 -0
- package/dist/tutor/text.js.map +1 -0
- package/dist/tutor/tutor.d.ts +2 -9
- package/dist/tutor/tutor.d.ts.map +1 -1
- package/dist/tutor/tutor.js +109 -87
- package/dist/tutor/tutor.js.map +1 -1
- package/dist/tutor/walking.d.ts +20 -6
- package/dist/tutor/walking.d.ts.map +1 -1
- package/dist/tutor/walking.js +125 -25
- package/dist/tutor/walking.js.map +1 -1
- package/dist/tutor/walks.d.ts +33 -0
- package/dist/tutor/walks.d.ts.map +1 -1
- package/dist/tutor/walks.js +116 -10
- package/dist/tutor/walks.js.map +1 -1
- package/dist/wire/acts.d.ts +60 -0
- package/dist/wire/acts.d.ts.map +1 -0
- package/dist/wire/acts.js +120 -0
- package/dist/wire/acts.js.map +1 -0
- package/dist/wire/ask.d.ts +132 -0
- package/dist/wire/ask.d.ts.map +1 -0
- package/dist/wire/ask.js +102 -0
- package/dist/wire/ask.js.map +1 -0
- package/dist/wire/index.d.ts +26 -8
- package/dist/wire/index.d.ts.map +1 -1
- package/dist/wire/index.js +62 -11
- package/dist/wire/index.js.map +1 -1
- package/docs/macros.md +53 -3
- package/docs/write-a-tutor.md +26 -2
- package/package.json +8 -4
package/dist/tutor/walking.js
CHANGED
|
@@ -3,7 +3,10 @@
|
|
|
3
3
|
// One audio element plays every sentence in turn: Safari lets an element the visitor's click
|
|
4
4
|
// started go on to its next source, where a new element would need another click. Each frame
|
|
5
5
|
// reads where the audio is, so the words and the pointer follow the sound, whatever the network.
|
|
6
|
-
|
|
6
|
+
// A walk called with values fills its slots: a step that acts (fill, press, wait, read) is done by
|
|
7
|
+
// the page between two sentences, and a sentence with slots is recorded when it is reached. A step
|
|
8
|
+
// a slot of which nothing filled, or whose `if` or `unless` says so, is left out.
|
|
9
|
+
import { filled, isAct, taken, walksDocument, walksOf } from "../wire/index.js";
|
|
7
10
|
import { Player } from "./macro.js";
|
|
8
11
|
/** A document's walks, read with no key; null where it is not there or cannot be read. */
|
|
9
12
|
async function readWalks(url) {
|
|
@@ -32,26 +35,48 @@ export async function publishedWalks(url, path = "") {
|
|
|
32
35
|
}
|
|
33
36
|
return (await readWalks(url)) ?? [];
|
|
34
37
|
}
|
|
35
|
-
/** A walk's length, in ms. */
|
|
38
|
+
/** A walk's length, in ms: its recorded sentences'. */
|
|
36
39
|
export function lengthOf(walk) {
|
|
37
|
-
return walk.steps.reduce((total, step) => total + step.durationMs, 0);
|
|
40
|
+
return walk.steps.reduce((total, step) => total + ("durationMs" in step ? step.durationMs : 0), 0);
|
|
41
|
+
}
|
|
42
|
+
const NO_HOOKS = { act: async () => ({}), voice: async () => null };
|
|
43
|
+
// An audio element is the visitor's to start: one that played inside their click goes on playing
|
|
44
|
+
// sources after it, so a walk that starts after a wait (a door asked, a search) plays this first.
|
|
45
|
+
const SILENCE = "data:audio/wav;base64,UklGRiQAAABXQVZFZm10IBAAAAABAAEARKwAAIhYAQACABAAZGF0YQAAAAA=";
|
|
46
|
+
/** A step's beats with the slots of what they find filled: `["row", "{hit}"]`. A beat whose slot nothing filled is left out. */
|
|
47
|
+
function beatsFilled(beats, values) {
|
|
48
|
+
return beats.flatMap((beat) => {
|
|
49
|
+
if (beat.find === undefined)
|
|
50
|
+
return [beat];
|
|
51
|
+
const name = filled(beat.find[1], values);
|
|
52
|
+
return name === null ? [] : [{ ...beat, find: [beat.find[0], name] }];
|
|
53
|
+
});
|
|
38
54
|
}
|
|
39
55
|
export class Walking {
|
|
40
56
|
audio;
|
|
41
57
|
#ended;
|
|
42
58
|
#shows;
|
|
43
59
|
#player = new Player();
|
|
60
|
+
#hooks;
|
|
44
61
|
#walk = null;
|
|
45
62
|
#step = 0;
|
|
46
63
|
#paused = false;
|
|
64
|
+
#values = {};
|
|
65
|
+
/** The sentence playing; null while a step acts or is recorded. */
|
|
66
|
+
#current = null;
|
|
67
|
+
/** A sentence ready while the walk was paused, played on resume. */
|
|
68
|
+
#held = null;
|
|
69
|
+
/** Which run of the walk is on: a stop or a new start ends the one before, mid-act. */
|
|
70
|
+
#run = 0;
|
|
47
71
|
/**
|
|
48
72
|
* Play through `audio`; `ended` hears a walk that played to its end, or failed to play; `shows`
|
|
49
|
-
* hears each sentence as it starts, for what it shows beside the page, and null as the walk stops.
|
|
73
|
+
* hears each sentence as it starts (and which step it is), for what it shows beside the page, and null as the walk stops.
|
|
50
74
|
*/
|
|
51
|
-
constructor(audio, ended, shows = () => undefined) {
|
|
75
|
+
constructor(audio, ended, shows = () => undefined, hooks = NO_HOOKS) {
|
|
52
76
|
this.audio = audio;
|
|
53
77
|
this.#ended = ended;
|
|
54
78
|
this.#shows = shows;
|
|
79
|
+
this.#hooks = hooks;
|
|
55
80
|
// The ear reads the audio through Web Audio, which hears silence from a source fetched without CORS.
|
|
56
81
|
audio.crossOrigin = "anonymous";
|
|
57
82
|
audio.preload = "auto";
|
|
@@ -78,24 +103,64 @@ export class Walking {
|
|
|
78
103
|
if (this.#walk === null || !this.#paused)
|
|
79
104
|
return;
|
|
80
105
|
this.#paused = false;
|
|
81
|
-
|
|
106
|
+
const held = this.#held;
|
|
107
|
+
this.#held = null;
|
|
108
|
+
if (held !== null)
|
|
109
|
+
this.#play(held);
|
|
110
|
+
else if (this.#current !== null)
|
|
111
|
+
this.audio.play().catch(() => this.#finish(false));
|
|
82
112
|
}
|
|
83
|
-
/**
|
|
84
|
-
|
|
113
|
+
/**
|
|
114
|
+
* The next sentence, or the one before (`delta` 1 or -1): going on, a step that acts is done on the way;
|
|
115
|
+
* going back, it is passed over, never done twice. Call it from the visitor's click.
|
|
116
|
+
*/
|
|
117
|
+
skip(delta) {
|
|
118
|
+
const walk = this.#walk;
|
|
119
|
+
if (walk === null)
|
|
120
|
+
return;
|
|
121
|
+
let at = this.#step + delta;
|
|
122
|
+
const acts = (index) => {
|
|
123
|
+
const step = walk.steps[index];
|
|
124
|
+
return step !== undefined && isAct(step);
|
|
125
|
+
};
|
|
126
|
+
while (delta < 0 && at > 0 && acts(at))
|
|
127
|
+
at -= 1;
|
|
128
|
+
this.#step = Math.max(0, at);
|
|
129
|
+
this.#paused = false;
|
|
130
|
+
this.#held = null;
|
|
131
|
+
this.#current = null;
|
|
132
|
+
this.#player.drop();
|
|
133
|
+
this.audio.pause();
|
|
134
|
+
void this.#go();
|
|
135
|
+
}
|
|
136
|
+
/** Let this element play later, from the visitor's click: a walk that starts after a wait. */
|
|
137
|
+
unlock() {
|
|
138
|
+
if (this.#walk !== null)
|
|
139
|
+
return;
|
|
140
|
+
this.audio.src = SILENCE;
|
|
141
|
+
this.audio.play().catch(() => undefined);
|
|
142
|
+
}
|
|
143
|
+
/** Play a walk from its first sentence, its slots filled from `values`. Call it from the visitor's click, or after `unlock`. */
|
|
144
|
+
start(walk, values = {}) {
|
|
85
145
|
this.#walk = walk;
|
|
86
146
|
this.#step = 0;
|
|
87
|
-
this.#
|
|
147
|
+
this.#values = { ...values };
|
|
148
|
+
void this.#go();
|
|
88
149
|
}
|
|
89
150
|
/** Where the walk is now; null while none plays. */
|
|
90
151
|
frame() {
|
|
91
152
|
const walk = this.#walk;
|
|
92
|
-
|
|
93
|
-
if (walk === null || step === undefined)
|
|
153
|
+
if (walk === null)
|
|
94
154
|
return null;
|
|
155
|
+
const step = this.#current;
|
|
156
|
+
const before = walk.steps.slice(0, this.#step).reduce((total, one) => total + ("durationMs" in one ? one.durationMs : 0), 0);
|
|
157
|
+
const fraction = Math.min(1, before / Math.max(1, lengthOf(walk)));
|
|
158
|
+
// Between two sentences, a step acting or being recorded: no words, the bar where it stands.
|
|
159
|
+
if (step === null)
|
|
160
|
+
return { lit: "", coming: "", beats: [], fraction };
|
|
95
161
|
const now = this.audio.currentTime * 1000;
|
|
96
162
|
const lit = step.words.filter((word) => word.startMs <= now).map((word) => word.text).join(" ");
|
|
97
163
|
const rest = step.words.filter((word) => word.startMs > now).map((word) => word.text).join(" ");
|
|
98
|
-
const before = walk.steps.slice(0, this.#step).reduce((total, one) => total + one.durationMs, 0);
|
|
99
164
|
return {
|
|
100
165
|
lit,
|
|
101
166
|
coming: lit !== "" && rest !== "" ? ` ${rest}` : rest,
|
|
@@ -112,27 +177,58 @@ export class Walking {
|
|
|
112
177
|
this.#reset();
|
|
113
178
|
return walked;
|
|
114
179
|
}
|
|
115
|
-
|
|
180
|
+
/** From the step it stands on: acts done and sentences left out in turn, until a sentence plays or the walk ends. */
|
|
181
|
+
async #go() {
|
|
182
|
+
const walk = this.#walk;
|
|
183
|
+
const run = ++this.#run;
|
|
184
|
+
while (walk !== null && run === this.#run) {
|
|
185
|
+
const step = walk.steps[this.#step];
|
|
186
|
+
if (step === undefined)
|
|
187
|
+
return this.#finish(true);
|
|
188
|
+
if (!taken(step, this.#values)) {
|
|
189
|
+
this.#step += 1;
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
this.#current = null;
|
|
193
|
+
this.#player.drop();
|
|
194
|
+
if (isAct(step)) {
|
|
195
|
+
const read = await this.#hooks.act(step, this.#values, this.#step).catch(() => ({}));
|
|
196
|
+
if (run !== this.#run)
|
|
197
|
+
return;
|
|
198
|
+
Object.assign(this.#values, read);
|
|
199
|
+
this.#step += 1;
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
202
|
+
const recorded = "live" in step ? await this.#hooks.voice(walk, this.#step, this.#values).catch(() => null) : step;
|
|
203
|
+
if (run !== this.#run)
|
|
204
|
+
return;
|
|
205
|
+
if (recorded === null) {
|
|
206
|
+
this.#step += 1;
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
209
|
+
return this.#play({ ...recorded, beats: beatsFilled(recorded.beats, this.#values) });
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
#play(step) {
|
|
116
213
|
const walk = this.#walk;
|
|
117
|
-
|
|
118
|
-
if (walk === null || step === undefined)
|
|
214
|
+
if (walk === null)
|
|
119
215
|
return;
|
|
216
|
+
if (this.#paused) {
|
|
217
|
+
this.#held = step;
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
this.#current = step;
|
|
120
221
|
const asStep = { type: "macro.step", macro: walk.name, step: this.#step, say: step.say, beats: step.beats };
|
|
121
222
|
this.#player.arm(asStep, null);
|
|
122
|
-
this.#shows(step);
|
|
223
|
+
this.#shows(step, this.#step);
|
|
123
224
|
this.audio.src = step.audio;
|
|
124
225
|
this.audio.play().catch(() => this.#finish(false));
|
|
125
226
|
}
|
|
126
227
|
#next() {
|
|
127
|
-
|
|
128
|
-
if (walk === null)
|
|
129
|
-
return;
|
|
130
|
-
if (this.#step + 1 < walk.steps.length) {
|
|
131
|
-
this.#step += 1;
|
|
132
|
-
this.#play();
|
|
228
|
+
if (this.#walk === null || this.#current === null)
|
|
133
229
|
return;
|
|
134
|
-
|
|
135
|
-
this.#
|
|
230
|
+
this.#step += 1;
|
|
231
|
+
void this.#go();
|
|
136
232
|
}
|
|
137
233
|
#finish(done) {
|
|
138
234
|
const walk = this.#walk;
|
|
@@ -144,9 +240,13 @@ export class Walking {
|
|
|
144
240
|
}
|
|
145
241
|
#reset() {
|
|
146
242
|
this.#walk = null;
|
|
243
|
+
this.#run += 1;
|
|
244
|
+
this.#current = null;
|
|
245
|
+
this.#held = null;
|
|
246
|
+
this.#values = {};
|
|
147
247
|
this.#paused = false;
|
|
148
248
|
this.#player.drop();
|
|
149
|
-
this.#shows(null);
|
|
249
|
+
this.#shows(null, -1);
|
|
150
250
|
this.audio.pause();
|
|
151
251
|
}
|
|
152
252
|
// The player binds a step to a "speech": a sentence of the walk is its own.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"walking.js","sourceRoot":"","sources":["../../src/tutor/walking.ts"],"names":[],"mappings":"AAAA,8IAA8I;AAC9I,EAAE;AACF,6FAA6F;AAC7F,6FAA6F;AAC7F,iGAAiG;
|
|
1
|
+
{"version":3,"file":"walking.js","sourceRoot":"","sources":["../../src/tutor/walking.ts"],"names":[],"mappings":"AAAA,8IAA8I;AAC9I,EAAE;AACF,6FAA6F;AAC7F,6FAA6F;AAC7F,iGAAi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GAAG,KAAK,CAAC;QACrB,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QACpB,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QACtB,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;IAED,4EAA4E;IAC5E,OAAO,CAAC,IAAkB;QACxB,OAAO,QAAQ,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;IAC3C,CAAC;CACF"}
|
package/dist/tutor/walks.d.ts
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
import type { Face } from "../face/index.js";
|
|
3
3
|
import { CodeWindow } from "../pointer/code.js";
|
|
4
4
|
import type { Person } from "../pointer/person.js";
|
|
5
|
+
import type { AskRequest } from "../wire/ask.js";
|
|
6
|
+
import { type ActStep, type RecordedStep, type RecordedWalk, type Values, type WalkStep } from "../wire/index.js";
|
|
7
|
+
import { type ReadingOptions } from "./aloud.js";
|
|
5
8
|
import { type WalkFrame, type Walked } from "./walking.js";
|
|
6
9
|
export interface WalksOptions {
|
|
7
10
|
dock: "right" | "left";
|
|
@@ -21,6 +24,19 @@ export interface WalksOptions {
|
|
|
21
24
|
point: (element: Element) => void;
|
|
22
25
|
/** Reduced motion: the code is written in at once. */
|
|
23
26
|
still: boolean;
|
|
27
|
+
/** The field for what the visitor wants shown: its placeholder, and what was typed. None, no field. */
|
|
28
|
+
ask?: {
|
|
29
|
+
placeholder: string;
|
|
30
|
+
onAsk: (text: string) => void;
|
|
31
|
+
} | undefined;
|
|
32
|
+
/** A walk's act done on the page, with what the visitor typed: the values it read. */
|
|
33
|
+
act?: ((step: ActStep, values: Values, message: string) => Promise<Values>) | undefined;
|
|
34
|
+
/** A walk's sentence with slots, recorded now. */
|
|
35
|
+
voice?: ((walk: RecordedWalk, at: number, values: Values) => Promise<RecordedStep | null>) | undefined;
|
|
36
|
+
/** The page read aloud, first in the menu under `title`, where the site marks `data-pinecall-read`. None, it is not offered. */
|
|
37
|
+
reading?: ({
|
|
38
|
+
title: string;
|
|
39
|
+
} & ReadingOptions) | undefined;
|
|
24
40
|
}
|
|
25
41
|
export declare class Walks {
|
|
26
42
|
#private;
|
|
@@ -31,10 +47,25 @@ export declare class Walks {
|
|
|
31
47
|
frame(): WalkFrame | null;
|
|
32
48
|
get playing(): boolean;
|
|
33
49
|
get paused(): boolean;
|
|
50
|
+
/** The walk's next sentence, or the one before: the visitor's buttons. */
|
|
51
|
+
skip(delta: 1 | -1): void;
|
|
34
52
|
/** Hold the walk playing, or go on with it: the visitor's pause button. */
|
|
35
53
|
pause(): void;
|
|
36
54
|
/** The section scrolled to offers its walk, and the site's own buttons show, while no call is on and no walk plays. Called every frame. */
|
|
37
55
|
place(): void;
|
|
56
|
+
/** The walks of this page, as the field asks about them, with what each takes. */
|
|
57
|
+
listed(): AskRequest["walks"];
|
|
58
|
+
/** Play a walk of this page, by its name, called with `values`: from what the visitor typed (`message`). */
|
|
59
|
+
playNamed(name: string, values?: Values, message?: string): void;
|
|
60
|
+
/** Read the page aloud, as it is now: what it marks `data-pinecall-read`. Call it from the visitor's click. */
|
|
61
|
+
read(): void;
|
|
62
|
+
/** Let a walk play after a wait: from the visitor's submit, before the door answers. */
|
|
63
|
+
unlock(): void;
|
|
64
|
+
/** Open the menu with a line under the field about what was asked, and a button to take it on. */
|
|
65
|
+
offer(text: string, action?: {
|
|
66
|
+
label: string;
|
|
67
|
+
onClick: () => void;
|
|
68
|
+
}): void;
|
|
38
69
|
/** Stop the walk playing, if one is: the visitor clicked the face, or a call began. */
|
|
39
70
|
stop(): void;
|
|
40
71
|
/** Whether the button may show: not during a call, nor while a walk plays. */
|
|
@@ -43,4 +74,6 @@ export declare class Walks {
|
|
|
43
74
|
taken(): Walked | null;
|
|
44
75
|
close(): void;
|
|
45
76
|
}
|
|
77
|
+
/** Every part a reading says, asked of the door before it is read, `AHEAD_AT_ONCE` at a time; a part it fails is left for the reading. */
|
|
78
|
+
export declare function recordAhead(steps: readonly WalkStep[], record: (text: string) => Promise<unknown>): Promise<number>;
|
|
46
79
|
//# sourceMappingURL=walks.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"walks.d.ts","sourceRoot":"","sources":["../../src/tutor/walks.ts"],"names":[],"mappings":"AAAA,+JAA+J;AAE/J,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"walks.d.ts","sourceRoot":"","sources":["../../src/tutor/walks.ts"],"names":[],"mappings":"AAAA,+JAA+J;AAE/J,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGhD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAU,KAAK,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,YAAY,EAAE,KAAK,MAAM,EAAE,KAAK,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC1H,OAAO,EAAa,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5D,OAAO,EAAqC,KAAK,SAAS,EAAE,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAE9F,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC;IACvB,kCAAkC;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,sEAAsE;IACtE,IAAI,EAAE,MAAM,CAAC;IACb,oEAAoE;IACpE,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,+DAA+D;IAC/D,MAAM,EAAE,MAAM,OAAO,CAAC;IACtB,2EAA2E;IAC3E,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,4CAA4C;IAC5C,MAAM,CAAC,EAAE,CAAC,CAAC,MAAM,EAA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IAAI,CAGZ;IAED,2IAA2I;IAC3I,KAAK,IAAI,IAAI,CAEZ;IAED,kFAAkF;IAClF,MAAM,IAAI,UAAU,CAAC,OAAO,CAAC,CAO5B;IAED,4GAA4G;IAC5G,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,GAAE,MAAW,EAAE,OAAO,SAAK,GAAG,IAAI,CAE/D;IAED,+GAA+G;IAC/G,IAAI,IAAI,IAAI,CAWX;IAED,wFAAwF;IACxF,MAAM,IAAI,IAAI,CAEb;IAED,kGAAkG;IAClG,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,IAAI,CAAA;KAAE,GAAG,IAAI,CAGzE;IAED,uFAAuF;IACvF,IAAI,IAAI,IAAI,CAGX;IAED,8EAA8E;IAC9E,SAAS,CAAC,EAAE,EAAE,OAAO,GAAG,IAAI,CAE3B;IAED,6EAA6E;IAC7E,KAAK,IAAI,MAAM,GAAG,IAAI,CAIrB;IAED,KAAK,IAAI,IAAI,CAMZ;CA2BF;AAKD,0IAA0I;AAC1I,wBAAsB,WAAW,CAAC,KAAK,EAAE,SAAS,QAAQ,EAAE,EAAE,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAYzH"}
|
package/dist/tutor/walks.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
/** The walks beside the resting face, with no call: the button and its pills, the player, the code a step shows, and what the next call is told was played. */
|
|
2
|
+
import { Asking } from "../pointer/asking.js";
|
|
2
3
|
import { CodeWindow } from "../pointer/code.js";
|
|
3
4
|
import { Sections } from "../pointer/sections.js";
|
|
4
5
|
import { Menu } from "../pointer/menu.js";
|
|
5
6
|
import { onPage } from "../wire/index.js";
|
|
7
|
+
import { ReadAloud } from "./aloud.js";
|
|
8
|
+
import { fromHere, readingOf } from "./reading.js";
|
|
6
9
|
import { Walking, lengthOf, publishedWalks } from "./walking.js";
|
|
7
10
|
export class Walks {
|
|
8
11
|
/** The window of code a step opens; a call's macro steps open it too. */
|
|
@@ -10,41 +13,81 @@ export class Walks {
|
|
|
10
13
|
#walking;
|
|
11
14
|
#menu;
|
|
12
15
|
#sections;
|
|
16
|
+
#asking;
|
|
13
17
|
#drawn;
|
|
14
18
|
#person;
|
|
15
19
|
#options;
|
|
20
|
+
#document;
|
|
16
21
|
#list = [];
|
|
22
|
+
/** The walks the menu and the sections offer: those that take no params, which are asked for. */
|
|
23
|
+
#picked = [];
|
|
17
24
|
#played = null;
|
|
25
|
+
/** What the visitor typed for the walk playing; none for one picked. */
|
|
26
|
+
#message = "";
|
|
27
|
+
/** The page being read aloud, while it is. */
|
|
28
|
+
#aloud = null;
|
|
29
|
+
/** Whether the menu offers reading the page, first. */
|
|
30
|
+
#readable = false;
|
|
18
31
|
constructor(document, person, drawn, options) {
|
|
19
32
|
this.#person = person;
|
|
33
|
+
this.#document = document;
|
|
20
34
|
this.#drawn = drawn;
|
|
21
35
|
this.#options = options;
|
|
22
36
|
this.code = new CodeWindow(document, (part) => person.add(part), options.still);
|
|
23
|
-
this.#walking = new Walking(document.createElement("audio"), (walked) => this.#ended(walked), (step) => {
|
|
37
|
+
this.#walking = new Walking(document.createElement("audio"), (walked) => this.#ended(walked), (step, at) => {
|
|
38
|
+
if (this.#aloud !== null)
|
|
39
|
+
return this.#aloud.shows(step === null ? -1 : at);
|
|
24
40
|
// A step that names no code keeps the window as it is; the walk's end closes it.
|
|
25
41
|
if (step === null)
|
|
26
42
|
return this.code.hide();
|
|
27
43
|
const lit = this.code.show(step.code, step.lines);
|
|
28
44
|
if (lit !== null)
|
|
29
45
|
options.point(lit);
|
|
46
|
+
}, {
|
|
47
|
+
act: async (step, values, at) => {
|
|
48
|
+
if (this.#aloud !== null)
|
|
49
|
+
return this.#aloud.act(at).then(() => ({}));
|
|
50
|
+
return options.act?.(step, values, this.#message) ?? {};
|
|
51
|
+
},
|
|
52
|
+
voice: (walk, at, values) => (this.#aloud !== null ? this.#aloud.voice(at) : options.voice?.(walk, at, values) ?? Promise.resolve(null)),
|
|
53
|
+
});
|
|
54
|
+
const named = (name) => this.#picked.findIndex((walk) => walk.name === name);
|
|
55
|
+
// What was typed folds the menu away; a line about it opens it again (`offer`).
|
|
56
|
+
const ask = options.ask;
|
|
57
|
+
this.#asking = ask === undefined ? undefined : new Asking(document, (part) => person.add(part), {
|
|
58
|
+
placeholder: ask.placeholder,
|
|
59
|
+
onAsk: (text) => {
|
|
60
|
+
this.#menu.toggle(false);
|
|
61
|
+
ask.onAsk(text);
|
|
62
|
+
},
|
|
30
63
|
});
|
|
31
|
-
const named = (name) => this.#list.findIndex((walk) => walk.name === name);
|
|
32
64
|
this.#menu = new Menu(document, (part) => person.add(part), {
|
|
65
|
+
ask: this.#asking,
|
|
33
66
|
dock: options.dock,
|
|
34
67
|
label: options.label,
|
|
35
68
|
more: options.more,
|
|
36
69
|
face: () => ({ at: person.dock(), radius: person.radius }),
|
|
37
|
-
onPick: (index) => this.#play(index),
|
|
38
|
-
current: () =>
|
|
70
|
+
onPick: (index) => (this.#readable && index === 0 ? this.read() : this.#play(this.#picked[index - this.#offset])),
|
|
71
|
+
current: () => {
|
|
72
|
+
const at = named(this.#sections.current() ?? "");
|
|
73
|
+
return at === -1 ? -1 : at + this.#offset;
|
|
74
|
+
},
|
|
39
75
|
});
|
|
40
|
-
this.#sections = new Sections(document, { onPlay: (name) => this.#play(named(name)) });
|
|
76
|
+
this.#sections = new Sections(document, { onPlay: (name) => this.#play(this.#picked[named(name)]) });
|
|
41
77
|
const path = document.defaultView?.location.pathname ?? "";
|
|
42
78
|
void publishedWalks(options.url ?? "", path).then((all) => {
|
|
43
79
|
// Only the walks for the page the visitor is on: one that names other pages stays out of the menu.
|
|
44
80
|
const found = all.filter((walk) => onPage(walk.pages, path));
|
|
45
81
|
this.#list = found;
|
|
46
|
-
this.#
|
|
47
|
-
|
|
82
|
+
this.#picked = found.filter((walk) => walk.params === undefined);
|
|
83
|
+
const reading = options.reading;
|
|
84
|
+
const readable = reading === undefined ? null : readingOf(document, reading.title);
|
|
85
|
+
this.#readable = readable !== null;
|
|
86
|
+
// Every part recorded ahead, a few at a time: the door keeps each, so a reading started later starts at once.
|
|
87
|
+
if (readable !== null && reading !== undefined)
|
|
88
|
+
void recordAhead(readable.walk.steps, reading.record);
|
|
89
|
+
this.#menu.offer([...(this.#readable && reading !== undefined ? [{ title: reading.title, ms: 0 }] : []), ...this.#picked.map((walk) => ({ title: walk.title, ms: lengthOf(walk) }))]);
|
|
90
|
+
this.#sections.offer(this.#picked.map((walk) => walk.name));
|
|
48
91
|
this.#menu.available(!options.inCall());
|
|
49
92
|
});
|
|
50
93
|
}
|
|
@@ -58,6 +101,10 @@ export class Walks {
|
|
|
58
101
|
get paused() {
|
|
59
102
|
return this.#walking.paused;
|
|
60
103
|
}
|
|
104
|
+
/** The walk's next sentence, or the one before: the visitor's buttons. */
|
|
105
|
+
skip(delta) {
|
|
106
|
+
this.#walking.skip(delta);
|
|
107
|
+
}
|
|
61
108
|
/** Hold the walk playing, or go on with it: the visitor's pause button. */
|
|
62
109
|
pause() {
|
|
63
110
|
if (this.#walking.paused)
|
|
@@ -69,6 +116,42 @@ export class Walks {
|
|
|
69
116
|
place() {
|
|
70
117
|
this.#sections.place(!this.#options.inCall() && !this.playing);
|
|
71
118
|
}
|
|
119
|
+
/** The walks of this page, as the field asks about them, with what each takes. */
|
|
120
|
+
listed() {
|
|
121
|
+
return this.#list.map((walk) => ({
|
|
122
|
+
name: walk.name,
|
|
123
|
+
title: walk.title,
|
|
124
|
+
...(walk.when === undefined ? {} : { when: walk.when }),
|
|
125
|
+
...(walk.params === undefined ? {} : { params: walk.params }),
|
|
126
|
+
}));
|
|
127
|
+
}
|
|
128
|
+
/** Play a walk of this page, by its name, called with `values`: from what the visitor typed (`message`). */
|
|
129
|
+
playNamed(name, values = {}, message = "") {
|
|
130
|
+
this.#play(this.#list.find((walk) => walk.name === name), values, message);
|
|
131
|
+
}
|
|
132
|
+
/** Read the page aloud, as it is now: what it marks `data-pinecall-read`. Call it from the visitor's click. */
|
|
133
|
+
read() {
|
|
134
|
+
const reading = this.#options.reading;
|
|
135
|
+
const found = reading === undefined ? null : readingOf(this.#document, reading.title);
|
|
136
|
+
if (reading === undefined || found === null || this.#options.inCall())
|
|
137
|
+
return;
|
|
138
|
+
this.stop();
|
|
139
|
+
// Its first sentence comes from the door after this click: the audio is let play inside it.
|
|
140
|
+
this.#walking.unlock();
|
|
141
|
+
// From where the page is scrolled to: what was read, or scrolled past, is not read again.
|
|
142
|
+
const here = fromHere(found);
|
|
143
|
+
this.#aloud = new ReadAloud(here, reading);
|
|
144
|
+
this.#play(here.walk);
|
|
145
|
+
}
|
|
146
|
+
/** Let a walk play after a wait: from the visitor's submit, before the door answers. */
|
|
147
|
+
unlock() {
|
|
148
|
+
this.#walking.unlock();
|
|
149
|
+
}
|
|
150
|
+
/** Open the menu with a line under the field about what was asked, and a button to take it on. */
|
|
151
|
+
offer(text, action) {
|
|
152
|
+
this.#menu.toggle(true);
|
|
153
|
+
this.#asking?.hint(text, action);
|
|
154
|
+
}
|
|
72
155
|
/** Stop the walk playing, if one is: the visitor clicked the face, or a call began. */
|
|
73
156
|
stop() {
|
|
74
157
|
const walked = this.#walking.stop();
|
|
@@ -89,19 +172,25 @@ export class Walks {
|
|
|
89
172
|
this.#walking.stop();
|
|
90
173
|
this.#menu.close();
|
|
91
174
|
this.#sections.close();
|
|
175
|
+
this.#asking?.close();
|
|
92
176
|
this.code.close();
|
|
93
177
|
}
|
|
94
|
-
#play(
|
|
95
|
-
const walk = this.#list[index];
|
|
178
|
+
#play(walk, values = {}, message = "") {
|
|
96
179
|
if (walk === undefined || this.#options.inCall())
|
|
97
180
|
return;
|
|
181
|
+
this.#message = message;
|
|
98
182
|
this.#drawn.wake();
|
|
99
183
|
this.#drawn.listen(this.#walking.audio);
|
|
100
184
|
this.#menu.available(false);
|
|
101
|
-
this.#walking.start(walk);
|
|
185
|
+
this.#walking.start(walk, values);
|
|
102
186
|
this.#options.onWalk?.({ walk: walk.name, step: 1, of: walk.steps.length, done: false });
|
|
103
187
|
}
|
|
188
|
+
/** How many pills stand before the walks': the page read aloud, when it is offered. */
|
|
189
|
+
get #offset() {
|
|
190
|
+
return this.#readable ? 1 : 0;
|
|
191
|
+
}
|
|
104
192
|
#ended(walked) {
|
|
193
|
+
this.#aloud = null;
|
|
105
194
|
this.#played = walked;
|
|
106
195
|
this.#drawn.listen(null);
|
|
107
196
|
this.#person.progress(null);
|
|
@@ -111,4 +200,21 @@ export class Walks {
|
|
|
111
200
|
this.#options.onWalk?.(walked);
|
|
112
201
|
}
|
|
113
202
|
}
|
|
203
|
+
/** How many parts of a page are asked of the door at once while it is recorded ahead. */
|
|
204
|
+
const AHEAD_AT_ONCE = 3;
|
|
205
|
+
/** Every part a reading says, asked of the door before it is read, `AHEAD_AT_ONCE` at a time; a part it fails is left for the reading. */
|
|
206
|
+
export async function recordAhead(steps, record) {
|
|
207
|
+
const texts = [...new Set(steps.flatMap((step) => ("live" in step ? [step.say] : [])))];
|
|
208
|
+
let next = 0;
|
|
209
|
+
let done = 0;
|
|
210
|
+
const one = async () => {
|
|
211
|
+
while (next < texts.length) {
|
|
212
|
+
const text = texts[next++];
|
|
213
|
+
if ((await record(text).catch(() => null)) !== null)
|
|
214
|
+
done += 1;
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
await Promise.all(Array.from({ length: AHEAD_AT_ONCE }, one));
|
|
218
|
+
return done;
|
|
219
|
+
}
|
|
114
220
|
//# sourceMappingURL=walks.js.map
|
package/dist/tutor/walks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"walks.js","sourceRoot":"","sources":["../../src/tutor/walks.ts"],"names":[],"mappings":"AAAA,+JAA+J;AAG/J,OAAO,EAAE,UAAU,EAAE,MAAM,oBAA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,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IACxF,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,MAAM,GAAG,GAAG,KAAK,IAAmB,EAAE;QACpC,OAAO,IAAI,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;YAC3B,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,EAAE,CAAE,CAAC;YAC5B,IAAI,CAAC,MAAM,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,KAAK,IAAI;gBAAE,IAAI,IAAI,CAAC,CAAC;QACjE,CAAC;IACH,CAAC,CAAC;IACF,MAAM,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,aAAa,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC;IAC9D,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/** A macro as a function: the params it takes, the steps that act on the page (fill, press, wait, read), and the `{slots}` its words are filled from. */
|
|
2
|
+
/** What a walk is called with, or read on its way: each slot's text. */
|
|
3
|
+
export type Values = Record<string, string>;
|
|
4
|
+
/** One param of a walk: what it is, in the words the model reads, and the options it is one of; none, the visitor's own words. */
|
|
5
|
+
export interface Param {
|
|
6
|
+
about: string;
|
|
7
|
+
oneOf?: Record<string, string> | undefined;
|
|
8
|
+
}
|
|
9
|
+
/** Type the filled `with` into the field the screen names `fill`: the visitor's words, never a password or a card. */
|
|
10
|
+
export interface FillAct {
|
|
11
|
+
fill: string;
|
|
12
|
+
with: string;
|
|
13
|
+
}
|
|
14
|
+
/** Press the button the screen names `press`: one outside any form, or in a search form. Never a slot: the site names it. */
|
|
15
|
+
export interface PressAct {
|
|
16
|
+
press: string;
|
|
17
|
+
}
|
|
18
|
+
/** Wait for the page to change after a press, a search answered: `ms` at most, 8 seconds when not said. */
|
|
19
|
+
export interface WaitAct {
|
|
20
|
+
wait: string;
|
|
21
|
+
ms?: number | undefined;
|
|
22
|
+
}
|
|
23
|
+
/** Read the table the screen names `read`: one row, the first or the one that best answers the visitor, its cells as `{as.Column}`. */
|
|
24
|
+
export interface ReadAct {
|
|
25
|
+
read: string;
|
|
26
|
+
as: string;
|
|
27
|
+
row?: "first" | "best" | undefined;
|
|
28
|
+
}
|
|
29
|
+
export type Act = FillAct | PressAct | WaitAct | ReadAct;
|
|
30
|
+
/** When a step is taken: `if` a slot has a value, `unless` it has one. */
|
|
31
|
+
export interface Guarded {
|
|
32
|
+
if?: string | undefined;
|
|
33
|
+
unless?: string | undefined;
|
|
34
|
+
}
|
|
35
|
+
/** The longest a wait may be, in ms. */
|
|
36
|
+
export declare const LONGEST_WAIT = 20000;
|
|
37
|
+
/** The longest a value may be: a name, a phone, a cell. */
|
|
38
|
+
export declare const LONGEST_VALUE = 80;
|
|
39
|
+
/** The slots a text names, in order: `{name}`, `{hit.Time}`. */
|
|
40
|
+
export declare function slotsOf(text: string): string[];
|
|
41
|
+
/** `text` with its slots filled; null when one has no value. */
|
|
42
|
+
export declare function filled(text: string, values: Values): string | null;
|
|
43
|
+
/** Whether a step is taken, with these values. */
|
|
44
|
+
export declare function taken(step: Guarded, values: Values): boolean;
|
|
45
|
+
/** A value as it may fill a slot: one line, cut. */
|
|
46
|
+
export declare function valueOf(text: string): string;
|
|
47
|
+
/** Whether a step is an act rather than a sentence. */
|
|
48
|
+
export declare function isAct(step: object): step is Act;
|
|
49
|
+
/** An act as a file or a document says it, checked; null for one that is not. */
|
|
50
|
+
export declare function actOf(fields: Record<string, unknown>): Act | null;
|
|
51
|
+
/** A step's guards, checked; null when one is not a slot's name. */
|
|
52
|
+
export declare function guardsOf(fields: Record<string, unknown>): Guarded | null;
|
|
53
|
+
/** A walk's params, as its file or document says them (`one_of` for the options), checked; null for any that is not one. */
|
|
54
|
+
export declare function paramsOf(value: unknown): Record<string, Param> | null;
|
|
55
|
+
/** The values a walk is called with, checked against its params: a list's value one of its options, the rest the visitor's words, cut. */
|
|
56
|
+
export declare function valuesFor(params: Record<string, Param>, given: Record<string, unknown>): {
|
|
57
|
+
values: Values;
|
|
58
|
+
wrong: string[];
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=acts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acts.d.ts","sourceRoot":"","sources":["../../src/wire/acts.ts"],"names":[],"mappings":"AAAA,yJAAyJ;AASzJ,wEAAwE;AACxE,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAE5C,kIAAkI;AAClI,MAAM,WAAW,KAAK;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;CAC5C;AAED,sHAAsH;AACtH,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,6HAA6H;AAC7H,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,2GAA2G;AAC3G,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACzB;AAED,uIAAuI;AACvI,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;CACpC;AAED,MAAM,MAAM,GAAG,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,OAAO,CAAC;AAEzD,0EAA0E;AAC1E,MAAM,WAAW,OAAO;IACtB,EAAE,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,MAAM,CAA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