@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.
package/src/chat.js CHANGED
@@ -1,163 +1,225 @@
1
- /*!
2
- * @oryksa/react-native - the ORYKSA chat for React Native, with the look of the
3
- * ORYKSA website chat (name and photo of the AI come from the ORYKSA account).
4
- * License: MIT
5
- */
6
- "use strict";
7
-
8
- const React = require("react");
9
- const RN = require("react-native");
10
- const { pick } = require("./client");
11
-
12
- const h = React.createElement;
13
- const { View, Text, TextInput, Image, Pressable, FlatList, Modal, KeyboardAvoidingView, Platform, StyleSheet, SafeAreaView, useWindowDimensions } = RN;
14
-
15
- const TX = {
16
- en: { talk: "Talk to", ph: "Type your question", send: "Send", err: "Sorry, something went wrong. Try again." },
17
- pt: { talk: "Falar com", ph: "Escreve a tua pergunta", send: "Enviar", err: "Desculpa, algo correu mal. Tenta de novo." },
18
- br: { talk: "Falar com", ph: "Digite sua pergunta", send: "Enviar", err: "Desculpe, algo deu errado. Tente de novo." },
19
- es: { talk: "Hablar con", ph: "Escribe tu pregunta", send: "Enviar", err: "Lo siento, algo salió mal. Inténtalo de nuevo." },
20
- };
21
- const DEFAULT_THEME = { accent: "#5B57E0", ink: "#161B3D", soft: "#EEEBFB", background: "#FFFFFF", muted: "#6B7280" };
22
- const FALLBACK_AVATAR = "https://oryksa.com/assets/img/avatar_official_oryksa.png";
23
- const L = (lang) => (TX[lang] ? lang : "en");
24
-
25
- /** The chat panel: header with the photo and name of the AI, messages, suggestions and the input. */
26
- function OryksaChat(props) {
27
- const { client, lang = "en", theme, onClose } = props;
28
- const th = Object.assign({}, DEFAULT_THEME, theme || {});
29
- const tx = TX[L(lang)];
30
- const [agent, setAgent] = React.useState(null);
31
- const [msgs, setMsgs] = React.useState([]);
32
- const [sug, setSug] = React.useState([]);
33
- const [text, setText] = React.useState("");
34
- const [busy, setBusy] = React.useState(false);
35
- const listRef = React.useRef(null);
36
-
37
- React.useEffect(() => {
38
- let alive = true;
39
- (async () => {
40
- try {
41
- const a = await client.agent();
42
- const hist = await client.messages().catch(() => ({ messages: [] }));
43
- if (!alive) return;
44
- setAgent(a);
45
- const past = (hist && hist.messages) || [];
46
- if (past.length) {
47
- setMsgs(past.map((m, i) => ({ id: "h" + i, role: m.role === "user" ? "user" : "assistant", text: m.content })));
48
- } else {
49
- const g = pick(a.greeting, L(lang));
50
- if (g) setMsgs([{ id: "g", role: "assistant", text: g }]);
51
- setSug((pick(a.suggestions, L(lang)) || []).slice(0, 4));
52
- }
53
- } catch (_) {
54
- if (alive) setAgent({ name: "ORYKSA", avatar: FALLBACK_AVATAR });
55
- }
56
- })();
57
- return () => { alive = false; };
58
- }, [client, lang]);
59
-
60
- const send = React.useCallback(async (value) => {
61
- const q = String(value || "").trim();
62
- if (!q || busy) return;
63
- setBusy(true); setSug([]); setText("");
64
- const id = String(Date.now());
65
- setMsgs((m) => m.concat([{ id: id + "u", role: "user", text: q }, { id: id + "t", role: "typing", text: "..." }]));
66
- let reply = null;
67
- try { reply = await client.sendAndWait(q); } catch (_) { reply = null; }
68
- setMsgs((m) => m.filter((x) => x.role !== "typing").concat([{ id: id + "a", role: "assistant", text: reply || tx.err }]));
69
- setBusy(false);
70
- }, [busy, client, tx]);
71
-
72
- const name = (agent && agent.name) || "";
73
- const sub = agent ? (pick(agent.subtitle, L(lang)) || agent.business || "") : "";
74
-
75
- return h(View, { style: [s.panel, { backgroundColor: th.background }] },
76
- h(View, { style: s.hd },
77
- h(Image, { source: { uri: (agent && agent.avatar) || FALLBACK_AVATAR }, style: s.hdImg }),
78
- h(View, { style: { flex: 1 } },
79
- h(Text, { style: [s.hdName, { color: th.ink }], numberOfLines: 1 }, name.toUpperCase()),
80
- sub ? h(Text, { style: [s.hdSub, { color: th.muted }], numberOfLines: 1 }, sub) : null),
81
- onClose ? h(Pressable, { onPress: onClose, accessibilityRole: "button", accessibilityLabel: "close", hitSlop: 10 },
82
- h(Text, { style: [s.close, { color: th.muted }] }, "×")) : null),
83
- h(FlatList, {
84
- ref: listRef,
85
- data: msgs,
86
- keyExtractor: (m) => m.id,
87
- contentContainerStyle: { padding: 16 },
88
- onContentSizeChange: () => listRef.current && listRef.current.scrollToEnd({ animated: true }),
89
- renderItem: ({ item }) => {
90
- const mine = item.role === "user";
91
- return h(View, { style: [s.bubble, mine ? [s.me, { backgroundColor: th.accent }] : [s.ai, { backgroundColor: th.soft }], item.role === "typing" ? { opacity: 0.6 } : null] },
92
- h(Text, { selectable: true, style: { color: mine ? "#fff" : th.ink, fontSize: 14, lineHeight: 21 } }, item.text));
93
- },
94
- }),
95
- sug.length ? h(View, { style: s.sug }, sug.map((q) =>
96
- h(Pressable, { key: q, onPress: () => send(q), style: s.chip }, h(Text, { style: { color: th.accent, fontSize: 12.5 } }, q)))) : null,
97
- h(View, { style: s.form },
98
- h(TextInput, {
99
- value: text, onChangeText: setText, placeholder: tx.ph, placeholderTextColor: "#9CA3AF", maxLength: 2000,
100
- style: [s.input, { color: th.ink }], returnKeyType: "send", onSubmitEditing: () => send(text),
101
- }),
102
- h(Pressable, { onPress: () => send(text), disabled: busy, style: [s.sendBtn, { backgroundColor: th.accent, opacity: busy ? 0.6 : 1 }] },
103
- h(Text, { style: s.sendTxt }, tx.send.toUpperCase()))),
104
- h(Text, { style: s.pw }, "POWERED BY ", h(Text, { style: { color: th.accent, fontWeight: "800" } }, "ORYKSA")));
105
- }
106
-
107
- /** Full-screen (phone) or floating (tablet) modal with the chat. */
108
- function OryksaChatModal(props) {
109
- const { visible, onClose } = props;
110
- const { width } = useWindowDimensions();
111
- const wide = width >= 600;
112
- return h(Modal, { visible: !!visible, animationType: "slide", transparent: wide, onRequestClose: onClose },
113
- h(KeyboardAvoidingView, { style: wide ? s.wideWrap : { flex: 1 }, behavior: Platform.OS === "ios" ? "padding" : undefined },
114
- h(SafeAreaView, { style: wide ? s.wideCard : { flex: 1 } }, h(OryksaChat, Object.assign({}, props, { onClose })))));
115
- }
116
-
117
- /** Floating "Talk to name" button with the photo of the AI. Opens the chat. */
118
- function OryksaChatButton(props) {
119
- const { client, lang = "en", theme, position = "right", style } = props;
120
- const th = Object.assign({}, DEFAULT_THEME, theme || {});
121
- const [agent, setAgent] = React.useState(null);
122
- const [open, setOpen] = React.useState(false);
123
- React.useEffect(() => {
124
- let alive = true;
125
- client.agent().then((a) => { if (alive) setAgent(a); }).catch(() => {});
126
- return () => { alive = false; };
127
- }, [client]);
128
- const tx = TX[L(lang)];
129
- return h(React.Fragment, null,
130
- h(Pressable, {
131
- onPress: () => setOpen(true), accessibilityRole: "button",
132
- style: [s.fab, position === "left" ? { left: 18 } : { right: 18 }, { backgroundColor: th.accent }, style],
133
- },
134
- h(Image, { source: { uri: (agent && agent.avatar) || FALLBACK_AVATAR }, style: s.fabImg }),
135
- h(Text, { style: s.fabTxt }, (tx.talk + " " + ((agent && agent.name) || "ORYKSA")).toUpperCase())),
136
- h(OryksaChatModal, { client, lang, theme, visible: open, onClose: () => setOpen(false) }));
137
- }
138
-
139
- const s = StyleSheet.create({
140
- panel: { flex: 1 },
141
- hd: { flexDirection: "row", alignItems: "center", gap: 12, paddingHorizontal: 16, paddingVertical: 14, borderBottomWidth: 1, borderBottomColor: "#ECEEF6" },
142
- hdImg: { width: 46, height: 46, borderRadius: 23 },
143
- hdName: { fontSize: 14, fontWeight: "800", letterSpacing: 2 },
144
- hdSub: { fontSize: 12 },
145
- close: { fontSize: 26, paddingHorizontal: 6 },
146
- bubble: { maxWidth: "82%", paddingHorizontal: 14, paddingVertical: 10, borderRadius: 16, marginBottom: 10 },
147
- ai: { alignSelf: "flex-start", borderBottomLeftRadius: 6 },
148
- me: { alignSelf: "flex-end", borderBottomRightRadius: 6 },
149
- sug: { flexDirection: "row", flexWrap: "wrap", gap: 8, paddingHorizontal: 16, paddingBottom: 10 },
150
- chip: { borderWidth: 1, borderColor: "#DCDCF5", borderRadius: 999, paddingHorizontal: 12, paddingVertical: 7, backgroundColor: "#fff" },
151
- form: { flexDirection: "row", borderTopWidth: 1, borderTopColor: "#ECEEF6" },
152
- input: { flex: 1, paddingHorizontal: 16, paddingVertical: 14, fontSize: 14 },
153
- sendBtn: { justifyContent: "center", paddingHorizontal: 18 },
154
- sendTxt: { color: "#fff", fontWeight: "800", letterSpacing: 1.2 },
155
- pw: { textAlign: "center", fontSize: 10.5, letterSpacing: 1.3, color: "#9CA3AF", paddingTop: 6, paddingBottom: 8 },
156
- wideWrap: { flex: 1, alignItems: "flex-end", justifyContent: "flex-end", padding: 22, paddingBottom: 92 },
157
- wideCard: { width: 380, height: 560, borderRadius: 20, overflow: "hidden", backgroundColor: "#fff", elevation: 16, shadowColor: "#161B3D", shadowOpacity: 0.25, shadowRadius: 30, shadowOffset: { width: 0, height: 12 } },
158
- fab: { position: "absolute", bottom: 22, flexDirection: "row", alignItems: "center", gap: 10, borderRadius: 999, paddingLeft: 8, paddingRight: 18, paddingVertical: 8, elevation: 8, shadowColor: "#161B3D", shadowOpacity: 0.28, shadowRadius: 15, shadowOffset: { width: 0, height: 6 } },
159
- fabImg: { width: 42, height: 42, borderRadius: 21, borderWidth: 2, borderColor: "#fff" },
160
- fabTxt: { color: "#fff", fontWeight: "800", fontSize: 13, letterSpacing: 1 },
161
- });
162
-
163
- module.exports = { OryksaChat, OryksaChatModal, OryksaChatButton, DEFAULT_THEME };
1
+ /*!
2
+ * @oryksa/react-native - the ORYKSA chat for React Native: name and photo of the AI from
3
+ * the ORYKSA account, with voice (the same behaviour as the ORYKSA app).
4
+ * License: MIT
5
+ */
6
+ "use strict";
7
+
8
+ const React = require("react");
9
+ const RN = require("react-native");
10
+ const { pick } = require("./client");
11
+ const { OryksaVoiceScreen, MicIcon } = require("./voice-screen");
12
+ const { createDefaultAudio } = require("./voice");
13
+ const profanity = require("./profanity");
14
+
15
+ const h = React.createElement;
16
+ const { View, Text, TextInput, Image, Pressable, FlatList, Modal, KeyboardAvoidingView, Platform, StyleSheet, SafeAreaView, useWindowDimensions } = RN;
17
+
18
+ const TX = {
19
+ en: { talk: "Talk to", ph: "Type your question", send: "Send", err: "Sorry, something went wrong. Try again.", voice: "Talk by voice", copy: "Copy" },
20
+ pt: { talk: "Falar com", ph: "Escreve a tua pergunta", send: "Enviar", err: "Desculpa, algo correu mal. Tenta de novo.", voice: "Falar por voz", copy: "Copiar" },
21
+ br: { talk: "Falar com", ph: "Digite sua pergunta", send: "Enviar", err: "Desculpe, algo deu errado. Tente de novo.", voice: "Falar por voz", copy: "Copiar" },
22
+ es: { talk: "Hablar con", ph: "Escribe tu pregunta", send: "Enviar", err: "Lo siento, algo salió mal. Inténtalo de nuevo.", voice: "Hablar por voz", copy: "Copiar" },
23
+ };
24
+ const DEFAULT_THEME = { accent: "#5B57E0", ink: "#161B3D", soft: "#EEEBFB", background: "#FFFFFF", muted: "#6B7280" };
25
+ const FALLBACK_AVATAR = "https://oryksa.com/assets/img/avatar_official_oryksa.png";
26
+ const L = (lang) => (TX[lang] ? lang : "en");
27
+
28
+ /** Text with **bold** parts (the server marks them, the app only draws them). */
29
+ function bold(text, style) {
30
+ const parts = String(text).split("**");
31
+ if (parts.length < 3) return text;
32
+ return parts.map((p, i) => (p ? (i % 2 === 1 ? h(Text, { key: i, style: [style, { fontWeight: "700" }] }, p) : p) : null));
33
+ }
34
+
35
+ /**
36
+ * The chat panel: header with the photo and name of the AI, messages, suggestions, input and (when
37
+ * the plan has voice and an audio adapter is available) the microphone that opens the voice screen.
38
+ * Props: client, lang, theme, onClose, appContext (() => ({ screen, title, items })), voice (default
39
+ * true), audio (adapter; default: react-native-live-audio-stream + react-native-sound + react-native-fs).
40
+ */
41
+ function OryksaChat(props) {
42
+ const { client, lang = "en", theme, onClose, appContext, voice = true } = props;
43
+ const audio = React.useMemo(() => props.audio || createDefaultAudio(), [props.audio]);
44
+ const [voiceOpen, setVoiceOpen] = React.useState(false);
45
+ const th = Object.assign({}, DEFAULT_THEME, theme || {});
46
+ const tx = TX[L(lang)];
47
+ const [agent, setAgent] = React.useState(null);
48
+ const [msgs, setMsgs] = React.useState([]);
49
+ const [sug, setSug] = React.useState([]);
50
+ const [text, setText] = React.useState("");
51
+ const [busy, setBusy] = React.useState(false);
52
+ const listRef = React.useRef(null);
53
+
54
+ const [, setProfReady] = React.useState(0);
55
+ React.useEffect(() => {
56
+ // Swear words the customer types show as asterisks (one list for every ORYKSA chat).
57
+ profanity.load(L(lang)).then(() => setProfReady((n) => n + 1));
58
+ }, [lang]);
59
+
60
+ React.useEffect(() => {
61
+ let alive = true;
62
+ (async () => {
63
+ try {
64
+ const a = await client.agent();
65
+ const hist = await client.messages().catch(() => ({ messages: [] }));
66
+ if (!alive) return;
67
+ setAgent(a);
68
+ const past = (hist && hist.messages) || [];
69
+ if (past.length) {
70
+ setMsgs(past.map((m, i) => ({ id: "h" + i, role: m.role === "user" ? "user" : "assistant", text: m.content })));
71
+ } else {
72
+ const g = pick(a.greeting, L(lang));
73
+ if (g) setMsgs([{ id: "g", role: "assistant", text: g }]);
74
+ setSug((pick(a.suggestions, L(lang)) || []).slice(0, 4));
75
+ }
76
+ } catch (_) {
77
+ if (alive) setAgent({ name: "ORYKSA", avatar: FALLBACK_AVATAR });
78
+ }
79
+ })();
80
+ return () => { alive = false; };
81
+ }, [client, lang]);
82
+
83
+ const send = React.useCallback(async (value) => {
84
+ const q = String(value || "").trim();
85
+ if (!q || busy) return;
86
+ setBusy(true); setSug([]); setText("");
87
+ const id = String(Date.now());
88
+ setMsgs((m) => m.concat([{ id: id + "u", role: "user", text: q }, { id: id + "t", role: "typing", text: "..." }]));
89
+ let reply = null;
90
+ try { reply = await client.sendAndWait(q, { appContext: appContext ? appContext() : undefined }); } catch (_) { reply = null; }
91
+ setMsgs((m) => m.filter((x) => x.role !== "typing").concat([{ id: id + "a", role: "assistant", text: reply || tx.err }]));
92
+ setBusy(false);
93
+ }, [busy, client, tx]);
94
+
95
+ const name = (agent && agent.name) || "";
96
+ const sub = agent ? (pick(agent.subtitle, L(lang)) || agent.business || "") : "";
97
+
98
+ return h(View, { style: [s.panel, { backgroundColor: th.background }] },
99
+ h(View, { style: s.hd },
100
+ h(Image, { source: { uri: (agent && agent.avatar) || FALLBACK_AVATAR }, style: s.hdImg }),
101
+ h(View, { style: { flex: 1 } },
102
+ h(Text, { style: [s.hdName, { color: th.ink }], numberOfLines: 1 }, name.toUpperCase()),
103
+ sub ? h(Text, { style: [s.hdSub, { color: th.muted }], numberOfLines: 1 }, sub) : null),
104
+ onClose ? h(Pressable, { onPress: onClose, accessibilityRole: "button", accessibilityLabel: "close", hitSlop: 10 },
105
+ h(Text, { style: [s.close, { color: th.muted }] }, "×")) : null),
106
+ h(FlatList, {
107
+ ref: listRef,
108
+ data: msgs,
109
+ keyExtractor: (m) => m.id,
110
+ contentContainerStyle: { padding: 16 },
111
+ onContentSizeChange: () => listRef.current && listRef.current.scrollToEnd({ animated: true }),
112
+ renderItem: ({ item }) => {
113
+ const mine = item.role === "user";
114
+ const bubble = h(View, { style: [s.bubble, mine ? [s.me, { backgroundColor: th.accent }] : [s.ai, { backgroundColor: th.soft }], item.role === "typing" ? { opacity: 0.6 } : null] },
115
+ h(Text, { selectable: true, style: { color: mine ? "#fff" : th.ink, fontSize: 14, lineHeight: 21 } }, bold(mine ? profanity.mask(item.text, L(lang)) : item.text, { color: mine ? "#fff" : th.ink })));
116
+ if (mine || item.role === "typing" || !String(item.text || "").trim()) return bubble;
117
+ // Copy button under each reply of the AI (same as the ORYKSA apps and extension).
118
+ return h(View, null, bubble, h(CopyButton, { text: String(item.text).replace(/\*\*/g, ""), label: tx.copy, color: th.muted }));
119
+ },
120
+ }),
121
+ sug.length ? h(View, { style: s.sug }, sug.map((q) =>
122
+ h(Pressable, { key: q, onPress: () => send(q), style: s.chip }, h(Text, { style: { color: th.accent, fontSize: 12.5 } }, q)))) : null,
123
+ h(View, { style: s.form },
124
+ h(TextInput, {
125
+ value: text, onChangeText: setText, placeholder: tx.ph, placeholderTextColor: "#9CA3AF", maxLength: 2000,
126
+ style: [s.input, { color: th.ink }], returnKeyType: "send", onSubmitEditing: () => send(text),
127
+ }),
128
+ voice && audio && agent && agent.voice_replies && !text.trim()
129
+ ? h(Pressable, { onPress: () => setVoiceOpen(true), disabled: busy, accessibilityRole: "button", accessibilityLabel: tx.voice, style: s.micBtn },
130
+ h(MicIcon, { color: th.accent }))
131
+ : null,
132
+ h(Pressable, { onPress: () => send(text), disabled: busy, style: [s.sendBtn, { backgroundColor: th.accent, opacity: busy ? 0.6 : 1 }] },
133
+ h(Text, { style: s.sendTxt }, tx.send.toUpperCase()))),
134
+ h(Text, { style: s.pw }, "POWERED BY ", h(Text, { style: { color: th.accent, fontWeight: "800" } }, "ORYKSA")),
135
+ voiceOpen ? h(OryksaVoiceScreen, {
136
+ client, agent, visible: true, lang: L(lang), theme: th, appContext, audio,
137
+ onClose: () => setVoiceOpen(false),
138
+ onUserText: (t) => { setSug([]); setMsgs((m) => m.concat([{ id: "v" + Date.now() + "u", role: "user", text: t }])); },
139
+ onReply: (t) => setMsgs((m) => m.concat([{ id: "v" + Date.now() + "a", role: "assistant", text: t }])),
140
+ }) : null);
141
+ }
142
+
143
+ /** Full-screen (phone) or floating (tablet) modal with the chat. */
144
+ function OryksaChatModal(props) {
145
+ const { visible, onClose } = props;
146
+ const { width } = useWindowDimensions();
147
+ const wide = width >= 600;
148
+ return h(Modal, { visible: !!visible, animationType: "slide", transparent: wide, onRequestClose: onClose },
149
+ h(KeyboardAvoidingView, { style: wide ? s.wideWrap : { flex: 1 }, behavior: Platform.OS === "ios" ? "padding" : undefined },
150
+ h(SafeAreaView, { style: wide ? s.wideCard : { flex: 1 } }, h(OryksaChat, Object.assign({}, props, { onClose })))));
151
+ }
152
+
153
+ /** Floating "Talk to name" button with the photo of the AI. Opens the chat. */
154
+ function OryksaChatButton(props) {
155
+ const { client, lang = "en", theme, position = "right", style, appContext, voice, audio } = props;
156
+ const th = Object.assign({}, DEFAULT_THEME, theme || {});
157
+ const [agent, setAgent] = React.useState(null);
158
+ const [open, setOpen] = React.useState(false);
159
+ React.useEffect(() => {
160
+ let alive = true;
161
+ client.agent().then((a) => { if (alive) setAgent(a); }).catch(() => {});
162
+ return () => { alive = false; };
163
+ }, [client]);
164
+ const tx = TX[L(lang)];
165
+ return h(React.Fragment, null,
166
+ h(Pressable, {
167
+ onPress: () => setOpen(true), accessibilityRole: "button",
168
+ style: [s.fab, position === "left" ? { left: 18 } : { right: 18 }, { backgroundColor: th.accent }, style],
169
+ },
170
+ h(Image, { source: { uri: (agent && agent.avatar) || FALLBACK_AVATAR }, style: s.fabImg }),
171
+ h(Text, { style: s.fabTxt }, (tx.talk + " " + ((agent && agent.name) || "ORYKSA")).toUpperCase())),
172
+ h(OryksaChatModal, { client, lang, theme, appContext, voice, audio, visible: open, onClose: () => setOpen(false) }));
173
+ }
174
+
175
+ /** Copies text: @react-native-clipboard/clipboard when installed, else the Clipboard of older React Native. */
176
+ function copyText(t) {
177
+ try { const C = require("@react-native-clipboard/clipboard"); (C.default || C).setString(t); return true; } catch (e) {}
178
+ try { if (RN.Clipboard && RN.Clipboard.setString) { RN.Clipboard.setString(t); return true; } } catch (e) {}
179
+ return false;
180
+ }
181
+
182
+ /** Copy icon drawn with views (no icon font): two rounded squares; a check after copying. */
183
+ function CopyGlyph({ color, done }) {
184
+ if (done) return h(View, { style: { width: 14, height: 14, alignItems: "center", justifyContent: "center" } },
185
+ h(View, { style: { width: 11, height: 6, borderLeftWidth: 2, borderBottomWidth: 2, borderColor: color, transform: [{ rotate: "-45deg" }], marginTop: -3 } }));
186
+ return h(View, { style: { width: 14, height: 14 } },
187
+ h(View, { style: { position: "absolute", left: 0, top: 0, width: 9, height: 9, borderWidth: 1.6, borderColor: color, borderRadius: 2, borderRightWidth: 0, borderBottomWidth: 0 } }),
188
+ h(View, { style: { position: "absolute", left: 4, top: 4, width: 10, height: 10, borderWidth: 1.6, borderColor: color, borderRadius: 2 } }));
189
+ }
190
+
191
+ /** Small copy button under a reply: copies the text and shows a check for a moment. */
192
+ function CopyButton({ text, label, color }) {
193
+ const [done, setDone] = React.useState(false);
194
+ React.useEffect(() => { if (!done) return undefined; const t = setTimeout(() => setDone(false), 1200); return () => clearTimeout(t); }, [done]);
195
+ return h(Pressable, { onPress: () => { if (copyText(text)) setDone(true); }, accessibilityRole: "button", accessibilityLabel: label, hitSlop: 8, style: s.copy },
196
+ h(CopyGlyph, { color, done }));
197
+ }
198
+
199
+ const s = StyleSheet.create({
200
+ panel: { flex: 1 },
201
+ hd: { flexDirection: "row", alignItems: "center", gap: 12, paddingHorizontal: 16, paddingVertical: 14, borderBottomWidth: 1, borderBottomColor: "#ECEEF6" },
202
+ hdImg: { width: 46, height: 46, borderRadius: 23 },
203
+ hdName: { fontSize: 14, fontWeight: "800", letterSpacing: 2 },
204
+ hdSub: { fontSize: 12 },
205
+ close: { fontSize: 26, paddingHorizontal: 6 },
206
+ bubble: { maxWidth: "82%", paddingHorizontal: 14, paddingVertical: 10, borderRadius: 16, marginBottom: 10 },
207
+ copy: { alignSelf: "flex-start", padding: 6, marginTop: -6, marginBottom: 6, borderRadius: 7 },
208
+ ai: { alignSelf: "flex-start", borderBottomLeftRadius: 6 },
209
+ me: { alignSelf: "flex-end", borderBottomRightRadius: 6 },
210
+ sug: { flexDirection: "row", flexWrap: "wrap", gap: 8, paddingHorizontal: 16, paddingBottom: 10 },
211
+ chip: { borderWidth: 1, borderColor: "#DCDCF5", borderRadius: 999, paddingHorizontal: 12, paddingVertical: 7, backgroundColor: "#fff" },
212
+ form: { flexDirection: "row", borderTopWidth: 1, borderTopColor: "#ECEEF6" },
213
+ input: { flex: 1, paddingHorizontal: 16, paddingVertical: 14, fontSize: 14 },
214
+ sendBtn: { justifyContent: "center", paddingHorizontal: 18 },
215
+ sendTxt: { color: "#fff", fontWeight: "800", letterSpacing: 1.2 },
216
+ micBtn: { justifyContent: "center", paddingHorizontal: 12 },
217
+ pw: { textAlign: "center", fontSize: 10.5, letterSpacing: 1.3, color: "#9CA3AF", paddingTop: 6, paddingBottom: 8 },
218
+ wideWrap: { flex: 1, alignItems: "flex-end", justifyContent: "flex-end", padding: 22, paddingBottom: 92 },
219
+ wideCard: { width: 380, height: 560, borderRadius: 20, overflow: "hidden", backgroundColor: "#fff", elevation: 16, shadowColor: "#161B3D", shadowOpacity: 0.25, shadowRadius: 30, shadowOffset: { width: 0, height: 12 } },
220
+ fab: { position: "absolute", bottom: 22, flexDirection: "row", alignItems: "center", gap: 10, borderRadius: 999, paddingLeft: 8, paddingRight: 18, paddingVertical: 8, elevation: 8, shadowColor: "#161B3D", shadowOpacity: 0.28, shadowRadius: 15, shadowOffset: { width: 0, height: 6 } },
221
+ fabImg: { width: 42, height: 42, borderRadius: 21, borderWidth: 2, borderColor: "#fff" },
222
+ fabTxt: { color: "#fff", fontWeight: "800", fontSize: 13, letterSpacing: 1 },
223
+ });
224
+
225
+ module.exports = { OryksaChat, OryksaChatModal, OryksaChatButton, DEFAULT_THEME };