@oryksa/react-native 1.0.0 → 1.1.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.
@@ -0,0 +1,60 @@
1
+ /*!
2
+ * @oryksa/react-native - swear words the customer types show as asterisks (owner rule: every ORYKSA
3
+ * chat). One list for all ORYKSA clients: GET https://app.oryksa.com/widget/profanity.json?lang=
4
+ * (kept 24 hours). The AI's replies already come filtered from the server. License: MIT
5
+ */
6
+ "use strict";
7
+
8
+ const URL_BASE = "https://app.oryksa.com/widget/profanity.json";
9
+ const DAY = 24 * 3600 * 1000;
10
+ const RE = {};
11
+ const AT = {};
12
+
13
+ /** Language key of the list: pt, br, en or es. */
14
+ function key(lang) {
15
+ const l = String(lang || "en");
16
+ return l.indexOf("br") >= 0 ? "br" : l.slice(0, 2);
17
+ }
18
+
19
+ /**
20
+ * Builds the regex. Some JavaScript engines do not know \p{L} / \p{N}: then the same pattern runs with
21
+ * explicit letter ranges (Latin, accents, Greek, Cyrillic) and without the u flag.
22
+ */
23
+ function compile(pattern, flags) {
24
+ try {
25
+ return new RegExp(pattern, flags || "giu");
26
+ } catch (_) {
27
+ const p = pattern.replace(/\\p\{L\}/g, "A-Za-z\\u00C0-\\u024F\\u0370-\\u03FF\\u0400-\\u04FF").replace(/\\p\{N\}/g, "0-9");
28
+ try { return new RegExp(p, String(flags || "gi").replace("u", "")); } catch (_e) { return null; }
29
+ }
30
+ }
31
+
32
+ /** Uses a pattern directly (tests, or your own copy of the list). */
33
+ function use(lang, pattern, flags) {
34
+ const k = key(lang);
35
+ RE[k] = compile(pattern, flags);
36
+ AT[k] = Date.now();
37
+ }
38
+
39
+ /** Loads (or refreshes after 24 h) the list for lang. Never throws. */
40
+ async function load(lang, fetchImpl) {
41
+ const k = key(lang);
42
+ if (AT[k] && Date.now() - AT[k] < DAY) return;
43
+ try {
44
+ const f = fetchImpl || globalThis.fetch;
45
+ const r = await f(URL_BASE + "?lang=" + encodeURIComponent(k));
46
+ if (!r.ok) return;
47
+ const d = await r.json();
48
+ if (d && d.pattern) use(k, d.pattern, d.flags);
49
+ } catch (_) { /* the chat works without it */ }
50
+ }
51
+
52
+ /** text with the swear words replaced by asterisks (at least 3). Unchanged when the list is not loaded. */
53
+ function mask(text, lang) {
54
+ const re = RE[key(lang)];
55
+ if (!re || !text) return text;
56
+ re.lastIndex = 0;
57
+ return String(text).replace(re, (m, pre) => (pre || "") + "*".repeat(Math.max(3, m.slice((pre || "").length).replace(/\s/g, "").length)));
58
+ }
59
+
60
+ module.exports = { load, use, mask, key };
package/src/vad.js ADDED
@@ -0,0 +1,264 @@
1
+ /*!
2
+ * @oryksa/react-native - the ORYKSA voice engine.
3
+ * Decides WHEN someone started and stopped speaking, and whether a sound while she speaks is a human
4
+ * voice that cuts her off. Line by line port of lib/vad.dart of the ORYKSA app (the one engine of the
5
+ * whole ecosystem): every number is the same and has the same reason. Do not change one without running
6
+ * test/vad.test.js with new real recordings.
7
+ * Input: PCM16 little-endian mono chunks (Uint8Array) at 16 kHz. License: MIT
8
+ */
9
+ "use strict";
10
+
11
+ function sample(b, index) {
12
+ const v = b[index * 2] | (b[index * 2 + 1] << 8);
13
+ return v >= 0x8000 ? v - 0x10000 : v;
14
+ }
15
+
16
+ class VadStep {
17
+ constructor(o) {
18
+ this.isCapturing = !!o.isCapturing;
19
+ this.isDone = !!o.isDone;
20
+ this.isBargeIn = !!o.isBargeIn;
21
+ this.spokeMs = o.spokeMs || 0;
22
+ /** Spoke enough to be worth sending? */
23
+ this.enough = !!o.enough;
24
+ /** Not a voice: endless background noise. The reference silence went up. */
25
+ this.isNoise = !!o.isNoise;
26
+ /** Average level of what was recorded. */
27
+ this.level = o.level || 0;
28
+ }
29
+ static done(spokeMs, enough, isNoise, level) {
30
+ return new VadStep({ isDone: true, spokeMs, enough, isNoise: !!isNoise, level: level || 0 });
31
+ }
32
+ }
33
+ VadStep.IDLE = new VadStep({});
34
+ VadStep.CAPTURING = new VadStep({ isCapturing: true });
35
+ VadStep.BARGE_IN = new VadStep({ isBargeIn: true });
36
+
37
+ class Vad {
38
+ constructor(sampleRate) {
39
+ this.sampleRate = sampleRate || 16000;
40
+ this._corrida = 0;
41
+ this._maiorCorrida = 0;
42
+ this._vozHaMs = 99999;
43
+ /** Levels heard in the interruption attempt (for diagnosis). */
44
+ this.perfil = [];
45
+ /** Peak and pitch of the sentence just recorded (whisper detection and quality report). */
46
+ this.picoDaFrase = 0;
47
+ this.tomDaFrase = 0;
48
+ /** Loudest sound while she spoke, and the highest pitch in the interruption attempt. */
49
+ this.maxEnquantoFala = 0;
50
+ this.tomDaInterrupcao = 0;
51
+ this.base = 0;
52
+ this.frames = 0;
53
+ this.speechMs = 0;
54
+ this.quietMs = 0;
55
+ this.capturing = false;
56
+ this._sum = 0;
57
+ this._min = 1;
58
+ this._max = 0;
59
+ this._n = 0;
60
+ }
61
+
62
+ /** A whisper: voice without vocal folds, low and almost without pitch. Contract: peak < 0.09 and pitch < 0.45. */
63
+ get foiSussurro() { return this.picoDaFrase > 0 && this.picoDaFrase < 0.09 && this.tomDaFrase < 0.45; }
64
+
65
+ /**
66
+ * Is this a human VOICE or a noise? Voice is periodic (vocal folds at 70 to 350 Hz); a key, a clap,
67
+ * a door are clicks with no repetition. Normalised autocorrelation at 8 kHz (every other sample),
68
+ * lags 23 (350 Hz) to 114 (70 Hz).
69
+ */
70
+ static periodicidade(chunk) {
71
+ const n = chunk.length >> 1;
72
+ if (n < 512) return 0;
73
+ const m = n >> 1;
74
+ const x = new Float64Array(m);
75
+ let media = 0;
76
+ for (let i = 0; i < m; i++) {
77
+ x[i] = sample(chunk, i * 2) / 32768;
78
+ media += x[i];
79
+ }
80
+ media /= m;
81
+ let energia = 0;
82
+ for (let i = 0; i < m; i++) {
83
+ x[i] -= media;
84
+ energia += x[i] * x[i];
85
+ }
86
+ if (energia <= 0) return 0;
87
+ const lagMin = 23;
88
+ const lagMax = 114;
89
+ let melhor = 0;
90
+ for (let lag = lagMin; lag <= lagMax && lag < m; lag++) {
91
+ let soma = 0;
92
+ for (let i = 0; i + lag < m; i++) soma += x[i] * x[i + lag];
93
+ const r = soma / energia;
94
+ if (r > melhor) melhor = r;
95
+ }
96
+ return melhor;
97
+ }
98
+
99
+ /** Level of this chunk (0 to 1). */
100
+ static rmsOf(chunk) {
101
+ const n = chunk.length >> 1;
102
+ if (n === 0) return 0;
103
+ let sum = 0;
104
+ for (let k = 0; k < n; k++) {
105
+ const v = sample(chunk, k) / 32768;
106
+ sum += v * v;
107
+ }
108
+ return Math.sqrt(sum / n);
109
+ }
110
+
111
+ _noise() {
112
+ const nivel = this._n > 0 ? this._sum / this._n : this.base;
113
+ this.base = Math.min(Math.max(this.base, nivel), Vad.maxNoiseBase);
114
+ return VadStep.done(this.speechMs, false, true, nivel);
115
+ }
116
+
117
+ /** Start from zero, forgetting the learnt silence. Only when a voice session starts. */
118
+ reset() {
119
+ this.base = 0;
120
+ this.frames = 0;
121
+ this.newTurn();
122
+ }
123
+
124
+ /** Ready for the next sentence, KEEPING the learnt silence (the room does not change between sentences). */
125
+ newTurn() {
126
+ this._corrida = 0;
127
+ this._maiorCorrida = 0;
128
+ this._vozHaMs = 99999;
129
+ this.picoDaFrase = 0;
130
+ this.tomDaFrase = 0;
131
+ this.tomDaInterrupcao = 0;
132
+ this.maxEnquantoFala = 0;
133
+ this.perfil.length = 0;
134
+ this.speechMs = 0;
135
+ this.quietMs = 0;
136
+ this.capturing = false;
137
+ this._sum = 0;
138
+ this._min = 1;
139
+ this._max = 0;
140
+ this._n = 0;
141
+ }
142
+
143
+ /** Feeds one chunk (Uint8Array, PCM16 LE). Returns what to do next. */
144
+ feed(chunk, speaking) {
145
+ speaking = !!speaking;
146
+ const n = chunk.length >> 1;
147
+ if (n === 0) return VadStep.IDLE;
148
+ const rms = Vad.rmsOf(chunk);
149
+ const ms = Math.floor((n * 1000) / this.sampleRate);
150
+ this.frames++;
151
+
152
+ // First chunks: learn this place's silence, never above maxBase.
153
+ if (this.frames <= 3 && !speaking) {
154
+ this.base = this.base === 0 ? Math.min(rms, Vad.maxBase) : Math.min(this.base, rms);
155
+ }
156
+ // THE TWO THRESHOLDS, different on purpose. CUTTING: the measured floor, not the room noise.
157
+ // LISTENING: follows the noise, WITH a ceiling (0.10), or she is deaf in a cafe.
158
+ const speakThr = speaking
159
+ ? Math.max(this.base * 2.0, Vad.bargeFloor)
160
+ : Math.min(Math.max(this.base * 3.2, 0.014), Vad.tetoOuvir);
161
+ const quietThr = Math.max(this.base * 1.8, 0.008);
162
+
163
+ // Room noise: goes down fast, up slowly, never learns from a voice-level sound.
164
+ if (!this.capturing && !speaking) {
165
+ if (rms < this.base) this.base = this.base * 0.8 + rms * 0.2;
166
+ else if (rms < speakThr) this.base = this.base * 0.98 + rms * 0.02;
167
+ }
168
+
169
+ if (speaking) {
170
+ const thr = speakThr;
171
+ if (this.perfil.length < 40) this.perfil.push(rms);
172
+ // Only VOICE interrupts. A key click is loud but has no pitch.
173
+ const alto = rms > thr;
174
+ if (rms > this.maxEnquantoFala) this.maxEnquantoFala = rms;
175
+ const tom = alto ? Vad.periodicidade(chunk) : 0;
176
+ if (tom > this.tomDaInterrupcao) this.tomDaInterrupcao = tom;
177
+ if (tom >= Vad.bargeVozMin) this._vozHaMs = 0;
178
+ else this._vozHaMs += ms;
179
+ const ehVoz = alto && this._vozHaMs <= Vad.vozValeMs;
180
+ if (ehVoz) {
181
+ this.speechMs += ms;
182
+ this.quietMs = 0;
183
+ this._corrida += ms;
184
+ if (this._corrida > this._maiorCorrida) this._maiorCorrida = this._corrida;
185
+ if (this.speechMs >= Vad.bargeMs && this._maiorCorrida >= Vad.bargeRunMs) return VadStep.BARGE_IN;
186
+ } else {
187
+ this._corrida = 0;
188
+ this.quietMs += ms;
189
+ if (this.quietMs > Vad.bargeGapMs) {
190
+ this.speechMs = 0;
191
+ this.quietMs = 0;
192
+ this._maiorCorrida = 0;
193
+ }
194
+ }
195
+ return VadStep.IDLE;
196
+ }
197
+
198
+ if (rms > speakThr) {
199
+ this.capturing = true;
200
+ this.speechMs += ms;
201
+ this.quietMs = 0;
202
+ if (rms > this.picoDaFrase) this.picoDaFrase = rms;
203
+ const tf = Vad.periodicidade(chunk);
204
+ if (tf > this.tomDaFrase) this.tomDaFrase = tf;
205
+ } else if (this.capturing) {
206
+ if (rms < quietThr) this.quietMs += ms;
207
+ }
208
+ if (this.capturing) {
209
+ this._sum += rms;
210
+ if (rms < this._min) this._min = rms;
211
+ if (rms > this._max) this._max = rms;
212
+ this._n++;
213
+ }
214
+
215
+ if (!this.capturing) return VadStep.IDLE;
216
+
217
+ // Background noise caught early: seconds without a pause AND always at the same level.
218
+ const plano = this._min > 0 && this._max < this._min * Vad.flatRatio;
219
+ if (this.speechMs > Vad.noiseAfterMs && this.quietMs === 0 && plano) return this._noise();
220
+
221
+ if (this.quietMs <= Vad.quietToCloseMs && this.speechMs <= Vad.maxSpeechMs) return VadStep.CAPTURING;
222
+
223
+ const spoke = this.speechMs;
224
+ const nivel = this._n > 0 ? this._sum / this._n : 0;
225
+
226
+ // Fifteen seconds without ONE pause is not a person: it is constant noise.
227
+ if (spoke > Vad.maxSpeechMs && this.quietMs < 200) return this._noise();
228
+
229
+ return VadStep.done(spoke, spoke >= Vad.minSpeechMs, false, nivel);
230
+ }
231
+ }
232
+
233
+ /** Silence that closes a sentence (450 cut sentences, 900 was too slow; 700 is proven by the tests). */
234
+ Vad.quietToCloseMs = 700;
235
+ /** Minimum speech worth sending. Below this it is a cough or a door. */
236
+ Vad.minSpeechMs = 500;
237
+ /** Minimum recorded audio for the server to have something to hear. */
238
+ Vad.minAudioMs = 700;
239
+ /** Closes the sentence after this, even if the person goes on. */
240
+ Vad.maxSpeechMs = 15000;
241
+ /** VOICE time over her speech needed to silence her (two voiced slices). The pitch test does the heavy work. */
242
+ Vad.bargeMs = 130;
243
+ /** A pause long enough to give up an interruption (typing is ~5 keys a second: 200 ms apart). */
244
+ Vad.bargeGapMs = 130;
245
+ /** Continuous sound, without a single gap, so a loose slice does not count. */
246
+ Vad.bargeRunMs = 64;
247
+ /** How periodic a sound must be to count as voice (keyboard <= 0.20, human voice 0.50 to 0.93). */
248
+ Vad.bargeVozMin = 0.35;
249
+ /** How long the confidence lasts after the last voiced slice (the rest of the word counts). */
250
+ Vad.vozValeMs = 300;
251
+ /** Minimum level to count as an interruption, MEASURED LIVE (her echo 0.05, the person 0.12 to 0.25). Fixed. */
252
+ Vad.bargeFloor = 0.09;
253
+ /** Highest the LISTEN threshold can go, however noisy (without it she is deaf in a cafe). */
254
+ Vad.tetoOuvir = 0.1;
255
+ /** Highest level that can be taken as the room's silence. */
256
+ Vad.maxBase = 0.015;
257
+ /** Recording time without a pause after which we suspect it is noise. */
258
+ Vad.noiseAfterMs = 4000;
259
+ /** Voice goes up and down much more than this between chunks; background noise does not. */
260
+ Vad.flatRatio = 2.5;
261
+ /** Ceiling of the reference silence. */
262
+ Vad.maxNoiseBase = 0.12;
263
+
264
+ module.exports = { Vad, VadStep };
@@ -0,0 +1,140 @@
1
+ /*!
2
+ * @oryksa/react-native - the voice screen, the same as the ORYKSA app: the photo of the AI with a
3
+ * halo, "I'm listening" / her answer, Mute and Close. License: MIT
4
+ */
5
+ "use strict";
6
+
7
+ const React = require("react");
8
+ const RN = require("react-native");
9
+ const { OryksaVoiceController } = require("./voice");
10
+
11
+ const h = React.createElement;
12
+ const { View, Text, Image, Pressable, Modal, SafeAreaView, StyleSheet, Animated, Easing } = RN;
13
+
14
+ const VX = {
15
+ en: { listening: "I'm listening", listeningSub: "Speak to me. You can cut me off any time.", hearing: "Go on, I am listening.",
16
+ thinking: "One moment...", muted: "Paused", mutedSub: "Tap the mic to talk again.",
17
+ micError: "Microphone unavailable", micErrorSub: "Allow microphone access, or close other apps using it.",
18
+ noisy: "Too much background noise", noisySub: "I cannot tell your voice from the noise. Move somewhere quieter, or type to me.",
19
+ notUnderstood: "I could not understand", notUnderstoodSub: "Say it again, please.",
20
+ tapToSend: "Tap the picture to send what you said.", mute: "Mute", unmute: "Unmute", close: "Close" },
21
+ pt: { listening: "Estou a ouvir", listeningSub: "Fala comigo. Podes interromper-me quando quiseres.", hearing: "Continua, estou a ouvir.",
22
+ thinking: "Um momento...", muted: "Em pausa", mutedSub: "Toca no microfone para voltar a falar.",
23
+ micError: "Microfone indisponível", micErrorSub: "Permite o acesso ao microfone, ou fecha outras apps que o estejam a usar.",
24
+ noisy: "Demasiado barulho", noisySub: "Não consigo distinguir a tua voz do barulho. Vai para um sítio mais calmo, ou escreve-me.",
25
+ notUnderstood: "Não percebi", notUnderstoodSub: "Diz outra vez, por favor.",
26
+ tapToSend: "Toca na imagem para enviar o que disseste.", mute: "Silenciar", unmute: "Ativar som", close: "Fechar" },
27
+ br: { listening: "Estou ouvindo", listeningSub: "Fale comigo. Você pode me interromper quando quiser.", hearing: "Continue, estou ouvindo.",
28
+ thinking: "Um momento...", muted: "Em pausa", mutedSub: "Toque no microfone para voltar a falar.",
29
+ micError: "Microfone indisponível", micErrorSub: "Permita o acesso ao microfone, ou feche outros apps que estejam usando.",
30
+ noisy: "Barulho demais", noisySub: "Não consigo separar sua voz do barulho. Vá para um lugar mais calmo, ou digite para mim.",
31
+ notUnderstood: "Não entendi", notUnderstoodSub: "Fale de novo, por favor.",
32
+ tapToSend: "Toque na imagem para enviar o que você disse.", mute: "Silenciar", unmute: "Ativar som", close: "Fechar" },
33
+ es: { listening: "Te escucho", listeningSub: "Háblame. Puedes interrumpirme cuando quieras.", hearing: "Sigue, te escucho.",
34
+ thinking: "Un momento...", muted: "En pausa", mutedSub: "Toca el micrófono para volver a hablar.",
35
+ micError: "Micrófono no disponible", micErrorSub: "Permite el acceso al micrófono, o cierra otras apps que lo estén usando.",
36
+ noisy: "Demasiado ruido", noisySub: "No distingo tu voz del ruido. Ve a un sitio más tranquilo, o escríbeme.",
37
+ notUnderstood: "No te entendí", notUnderstoodSub: "Dilo otra vez, por favor.",
38
+ tapToSend: "Toca la imagen para enviar lo que dijiste.", mute: "Silenciar", unmute: "Activar sonido", close: "Cerrar" },
39
+ };
40
+
41
+ const FALLBACK_AVATAR = "https://oryksa.com/assets/img/avatar_official_oryksa.png";
42
+
43
+ /**
44
+ * Full-screen voice conversation. Props: client, agent ({ name, avatar, business }), visible, onClose,
45
+ * lang, theme, appContext (() => ({ screen, title, items })), onUserText, onReply, audio (adapter).
46
+ */
47
+ function OryksaVoiceScreen(props) {
48
+ const { client, agent, visible, onClose, lang = "en", theme, appContext, onUserText, onReply, audio } = props;
49
+ const th = Object.assign({ accent: "#5B57E0", ink: "#161B3D", soft: "#EEEBFB", background: "#FFFFFF", muted: "#6B7280" }, theme || {});
50
+ const t = VX[lang] || VX.en;
51
+ const [phase, setPhase] = React.useState("starting");
52
+ const ctlRef = React.useRef(null);
53
+ const pulse = React.useRef(new Animated.Value(1)).current;
54
+
55
+ React.useEffect(() => {
56
+ if (!visible) return undefined;
57
+ const ctl = new OryksaVoiceController({ client, audio, appContext, onUserText, onReply, onPhase: (p) => setPhase(p) });
58
+ ctlRef.current = ctl;
59
+ ctl.start();
60
+ const loop = Animated.loop(Animated.sequence([
61
+ Animated.timing(pulse, { toValue: 1.07, duration: 1000, easing: Easing.inOut(Easing.ease), useNativeDriver: true }),
62
+ Animated.timing(pulse, { toValue: 1, duration: 1000, easing: Easing.inOut(Easing.ease), useNativeDriver: true }),
63
+ ]));
64
+ loop.start();
65
+ return () => { loop.stop(); ctl.close(); ctlRef.current = null; };
66
+ }, [visible, client]);
67
+
68
+ const ctl = ctlRef.current;
69
+ const pick = {
70
+ starting: [t.listening, t.listeningSub], listening: [t.listening, t.listeningSub], hearing: [t.listening, t.hearing],
71
+ thinking: [(ctl && ctl.lastHeard) || "...", t.thinking], speaking: [(agent && agent.name) || "ORYKSA", (ctl && ctl.lastReply) || ""],
72
+ muted: [t.muted, t.mutedSub], micError: [t.micError, t.micErrorSub], noisy: [t.noisy, t.noisySub],
73
+ notUnderstood: [t.notUnderstood, t.notUnderstoodSub],
74
+ }[phase] || [t.listening, t.listeningSub];
75
+ const active = phase === "hearing" || phase === "speaking";
76
+ const photo = (agent && agent.avatar) || FALLBACK_AVATAR;
77
+ const close = () => { if (ctlRef.current) ctlRef.current.close(); if (onClose) onClose(); };
78
+ const ring = (size, alpha) => h(Animated.View, {
79
+ key: size, style: [st.ring, { width: size, height: size, borderRadius: size / 2, backgroundColor: th.accent, opacity: alpha,
80
+ transform: [{ scale: active ? pulse : 1 }] }] });
81
+
82
+ return h(Modal, { visible: !!visible, animationType: "slide", onRequestClose: close },
83
+ h(SafeAreaView, { style: [st.screen, { backgroundColor: th.background }] },
84
+ h(View, { style: st.hd },
85
+ h(Image, { source: { uri: photo }, style: st.hdImg }),
86
+ h(View, { style: { flex: 1 } },
87
+ h(Text, { style: [st.hdName, { color: th.ink }] }, (agent && agent.name) || "ORYKSA"),
88
+ agent && agent.business ? h(Text, { style: { fontSize: 11, color: th.muted }, numberOfLines: 1 }, agent.business) : null),
89
+ h(Pressable, { onPress: close, accessibilityRole: "button", accessibilityLabel: t.close, hitSlop: 10 },
90
+ h(Text, { style: { fontSize: 26, color: th.muted, paddingHorizontal: 6 } }, "×"))),
91
+ h(View, { style: st.center },
92
+ h(Pressable, { onPress: () => ctlRef.current && ctlRef.current.sendNow(), style: st.halo },
93
+ ring(236, 0.06), ring(184, 0.09), ring(136, 0.13),
94
+ h(Image, { source: { uri: photo }, style: st.photo })),
95
+ h(Text, { style: [st.title, { color: th.ink }] }, pick[0]),
96
+ h(Text, { style: [st.sub, { color: th.muted }] }, pick[1]),
97
+ phase === "hearing" ? h(Text, { style: st.tap }, t.tapToSend) : null,
98
+ h(View, { style: st.row },
99
+ btn(h(MicIcon, { color: th.muted, crossed: phase === "muted" }), phase === "muted" ? t.unmute : t.mute, false, () => ctlRef.current && ctlRef.current.toggleMute(), th),
100
+ btn("×", t.close, true, close, th))),
101
+ h(Text, { style: st.pw }, "POWERED BY ", h(Text, { style: { color: th.accent, fontWeight: "800" } }, "ORYKSA"))));
102
+ }
103
+
104
+ /** A microphone drawn with views (no emoji or icon font needed); crossed = muted. */
105
+ function MicIcon(props) {
106
+ const c = props.color || "#6B7280";
107
+ const k = (props.size || 22) / 22;
108
+ return h(View, { style: { width: 22 * k, height: 22 * k, alignItems: "center" } },
109
+ h(View, { style: { width: 8 * k, height: 12 * k, borderRadius: 4 * k, borderWidth: 2 * k, borderColor: c } }),
110
+ h(View, { style: { width: 14 * k, height: 7 * k, marginTop: -4 * k, borderBottomLeftRadius: 7 * k, borderBottomRightRadius: 7 * k, borderWidth: 2 * k, borderTopWidth: 0, borderColor: c } }),
111
+ h(View, { style: { width: 2 * k, height: 3 * k, backgroundColor: c } }),
112
+ props.crossed ? h(View, { style: { position: "absolute", top: 10 * k, left: -1 * k, width: 24 * k, height: 2 * k, backgroundColor: c, transform: [{ rotate: "45deg" }] } }) : null);
113
+ }
114
+
115
+ function btn(icon, label, cancel, onPress, th) {
116
+ const red = "#E05A52";
117
+ return h(Pressable, { onPress, accessibilityRole: "button", accessibilityLabel: label, style: { alignItems: "center" } },
118
+ h(View, { style: [st.cbtn, { backgroundColor: cancel ? "#FDF0EF" : th.background, borderColor: cancel ? "#F3C0BE" : "#ECECF6" }] },
119
+ typeof icon === "string" ? h(Text, { style: { fontSize: 22, color: cancel ? red : th.muted } }, icon) : icon),
120
+ h(Text, { style: { marginTop: 8, fontSize: 12, color: cancel ? red : th.muted } }, label));
121
+ }
122
+
123
+ const st = StyleSheet.create({
124
+ screen: { flex: 1 },
125
+ hd: { flexDirection: "row", alignItems: "center", gap: 10, paddingHorizontal: 16, paddingTop: 12 },
126
+ hdImg: { width: 38, height: 38, borderRadius: 19 },
127
+ hdName: { fontSize: 14.5, fontWeight: "700" },
128
+ center: { flex: 1, alignItems: "center", justifyContent: "center", paddingHorizontal: 30 },
129
+ halo: { width: 250, height: 250, alignItems: "center", justifyContent: "center" },
130
+ ring: { position: "absolute" },
131
+ photo: { width: 124, height: 124, borderRadius: 62 },
132
+ title: { marginTop: 14, fontSize: 22, fontWeight: "700", textAlign: "center" },
133
+ sub: { marginTop: 8, fontSize: 13.5, lineHeight: 20, textAlign: "center" },
134
+ tap: { marginTop: 10, fontSize: 11.5, color: "#AAB0CC" },
135
+ row: { flexDirection: "row", gap: 46, marginTop: 20 },
136
+ cbtn: { width: 58, height: 58, borderRadius: 29, borderWidth: 1.5, alignItems: "center", justifyContent: "center" },
137
+ pw: { textAlign: "center", fontSize: 10.5, letterSpacing: 1.3, color: "#9CA3AF", paddingBottom: 22 },
138
+ });
139
+
140
+ module.exports = { OryksaVoiceScreen, MicIcon, VOICE_TEXTS: VX };