react-native-srschat 0.1.5 → 0.1.8

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 (61) hide show
  1. package/lib/commonjs/assets/heritage.png +0 -0
  2. package/lib/commonjs/components/header.js +105 -0
  3. package/lib/commonjs/components/header.js.map +1 -0
  4. package/lib/commonjs/components/testing.js +58 -0
  5. package/lib/commonjs/components/testing.js.map +1 -0
  6. package/lib/commonjs/contexts/AppContext.js +99 -0
  7. package/lib/commonjs/contexts/AppContext.js.map +1 -0
  8. package/lib/commonjs/hooks/Stream.js +202 -0
  9. package/lib/commonjs/hooks/Stream.js.map +1 -0
  10. package/lib/commonjs/index.js +14 -154
  11. package/lib/commonjs/index.js.map +1 -1
  12. package/lib/commonjs/layout/chatIcon.js +53 -0
  13. package/lib/commonjs/layout/chatIcon.js.map +1 -0
  14. package/lib/commonjs/layout/chatWindow.js +208 -0
  15. package/lib/commonjs/layout/chatWindow.js.map +1 -0
  16. package/lib/commonjs/layout/layout.js +35 -0
  17. package/lib/commonjs/layout/layout.js.map +1 -0
  18. package/lib/module/assets/heritage.png +0 -0
  19. package/lib/module/components/header.js +96 -0
  20. package/lib/module/components/header.js.map +1 -0
  21. package/lib/module/components/testing.js +50 -0
  22. package/lib/module/components/testing.js.map +1 -0
  23. package/lib/module/contexts/AppContext.js +90 -0
  24. package/lib/module/contexts/AppContext.js.map +1 -0
  25. package/lib/module/hooks/Stream.js +194 -0
  26. package/lib/module/hooks/Stream.js.map +1 -0
  27. package/lib/module/index.js +13 -154
  28. package/lib/module/index.js.map +1 -1
  29. package/lib/module/layout/chatIcon.js +44 -0
  30. package/lib/module/layout/chatIcon.js.map +1 -0
  31. package/lib/module/layout/chatWindow.js +199 -0
  32. package/lib/module/layout/chatWindow.js.map +1 -0
  33. package/lib/module/layout/layout.js +26 -0
  34. package/lib/module/layout/layout.js.map +1 -0
  35. package/lib/typescript/components/header.d.ts +3 -0
  36. package/lib/typescript/components/header.d.ts.map +1 -0
  37. package/lib/typescript/components/testing.d.ts +6 -0
  38. package/lib/typescript/components/testing.d.ts.map +1 -0
  39. package/lib/typescript/contexts/AppContext.d.ts +6 -0
  40. package/lib/typescript/contexts/AppContext.d.ts.map +1 -0
  41. package/lib/typescript/hooks/Stream.d.ts +2 -0
  42. package/lib/typescript/hooks/Stream.d.ts.map +1 -0
  43. package/lib/typescript/index.d.ts +5 -11
  44. package/lib/typescript/index.d.ts.map +1 -1
  45. package/lib/typescript/layout/chatIcon.d.ts +3 -0
  46. package/lib/typescript/layout/chatIcon.d.ts.map +1 -0
  47. package/lib/typescript/layout/chatWindow.d.ts +6 -0
  48. package/lib/typescript/layout/chatWindow.d.ts.map +1 -0
  49. package/lib/typescript/layout/layout.d.ts +6 -0
  50. package/lib/typescript/layout/layout.d.ts.map +1 -0
  51. package/package.json +5 -3
  52. package/src/assets/heritage.png +0 -0
  53. package/src/components/header.js +89 -0
  54. package/src/components/testing.js +47 -0
  55. package/src/contexts/AppContext.js +83 -0
  56. package/src/hooks/Stream.js +198 -0
  57. package/src/index.js +18 -0
  58. package/src/layout/chatIcon.js +38 -0
  59. package/src/layout/chatWindow.js +200 -0
  60. package/src/layout/layout.js +23 -0
  61. package/src/index.tsx +0 -194
@@ -0,0 +1,50 @@
1
+ import React from 'react';
2
+ import { View, Button, StyleSheet } from 'react-native';
3
+ export const Testing = ({
4
+ onProductCardClick,
5
+ onAddToCartClick
6
+ }) => {
7
+ const product = {
8
+ "part_number": "AEQO177",
9
+ "inventory_info": {
10
+ "default_uom": "EA",
11
+ "is_valid": true,
12
+ "info_by_uom": {
13
+ "EA": {
14
+ "gross_price": 7.83,
15
+ "net_price": 7.83,
16
+ "is_on_sale": false,
17
+ "quantity_available": 0,
18
+ "discounts": null
19
+ }
20
+ }
21
+ },
22
+ "product_details": {
23
+ "product_name": "Aladdin Hayward SPX1600S SuperPump Lid Gasket | O-177-2",
24
+ "part_number": "AEQO177",
25
+ "manufacturer_id": "O-177-2",
26
+ "heritage_link": "https://www.heritagepoolplus.com/aeqo177-aladdin-o-ring-o-177-o-177-2-o-177-2",
27
+ "image_url": "https://media.heritageplus.com/image/upload/v1668157956/image/AEQO177_0.jpg"
28
+ }
29
+ };
30
+ return /*#__PURE__*/React.createElement(View, {
31
+ style: styles.container
32
+ }, /*#__PURE__*/React.createElement(Button, {
33
+ title: "Product Card Click",
34
+ onPress: () => onProductCardClick(product)
35
+ }), /*#__PURE__*/React.createElement(Button, {
36
+ title: "Add to Cart",
37
+ onPress: () => onAddToCartClick(product)
38
+ }));
39
+ };
40
+ const styles = StyleSheet.create({
41
+ container: {
42
+ flexDirection: 'row',
43
+ justifyContent: 'space-evenly',
44
+ marginVertical: 10,
45
+ paddingHorizontal: 16,
46
+ borderTopWidth: 1,
47
+ borderTopColor: '#DDD'
48
+ }
49
+ });
50
+ //# sourceMappingURL=testing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","View","Button","StyleSheet","Testing","onProductCardClick","onAddToCartClick","product","createElement","style","styles","container","title","onPress","create","flexDirection","justifyContent","marginVertical","paddingHorizontal","borderTopWidth","borderTopColor"],"sourceRoot":"../../../src","sources":["components/testing.js"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,IAAI,EAAEC,MAAM,EAAEC,UAAU,QAAQ,cAAc;AAEvD,OAAO,MAAMC,OAAO,GAAGA,CAAC;EAAEC,kBAAkB;EAAEC;AAAiB,CAAC,KAAK;EAEnE,MAAMC,OAAO,GAAG;IACd,aAAa,EAAE,SAAS;IACxB,gBAAgB,EAAE;MAChB,aAAa,EAAE,IAAI;MACnB,UAAU,EAAE,IAAI;MAChB,aAAa,EAAE;QACb,IAAI,EAAE;UACJ,aAAa,EAAE,IAAI;UACnB,WAAW,EAAE,IAAI;UACjB,YAAY,EAAE,KAAK;UACnB,oBAAoB,EAAE,CAAC;UACvB,WAAW,EAAE;QACf;MACF;IACF,CAAC;IACD,iBAAiB,EAAE;MACjB,cAAc,EAAE,yDAAyD;MACzE,aAAa,EAAE,SAAS;MACxB,iBAAiB,EAAE,SAAS;MAC5B,eAAe,EAAE,+EAA+E;MAChG,WAAW,EAAE;IACf;EACF,CAAC;EAED,oBACEP,KAAA,CAAAQ,aAAA,CAACP,IAAI;IAACQ,KAAK,EAAEC,MAAM,CAACC;EAAU,gBAC5BX,KAAA,CAAAQ,aAAA,CAACN,MAAM;IAACU,KAAK,EAAC,oBAAoB;IAACC,OAAO,EAAEA,CAAA,KAAMR,kBAAkB,CAACE,OAAO;EAAE,CAAE,CAAC,eACjFP,KAAA,CAAAQ,aAAA,CAACN,MAAM;IAACU,KAAK,EAAC,aAAa;IAACC,OAAO,EAAEA,CAAA,KAAMP,gBAAgB,CAACC,OAAO;EAAE,CAAE,CACnE,CAAC;AAEX,CAAC;AAED,MAAMG,MAAM,GAAGP,UAAU,CAACW,MAAM,CAAC;EAC/BH,SAAS,EAAE;IACTI,aAAa,EAAE,KAAK;IACpBC,cAAc,EAAE,cAAc;IAC9BC,cAAc,EAAE,EAAE;IAClBC,iBAAiB,EAAE,EAAE;IACrBC,cAAc,EAAE,CAAC;IACjBC,cAAc,EAAE;EAClB;AACF,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,90 @@
1
+ import React, { createContext, useContext, useState, useEffect } from "react";
2
+ export const AppContext = /*#__PURE__*/createContext();
3
+ export const AppProvider = ({
4
+ children
5
+ }) => {
6
+ const [showModal, setShowModal] = useState("Icon");
7
+ const [input, setInput] = useState('');
8
+ const [messages, setMessages] = useState([{
9
+ type: "ai",
10
+ text: "Hi there 👋 I’m Poseidon, your Heritage Pool+ AI Agent. I can help you during your online visit with Product and Account information. How can I help you today?"
11
+ }, {
12
+ type: "user",
13
+ text: "Do you carry Hayward super pumps?"
14
+ }, {
15
+ type: "ai",
16
+ text: "Could you provide more details on the specific model or horsepower you are interested in for the Hayward Super Pump? We have various models with different features, such as variable speed settings and different horsepower ratings. Alternatively, I can offer you some recommendations right away to help you decide."
17
+ }]);
18
+ const handleSend = async () => {
19
+ if (!input.trim()) return;
20
+ const userMessage = input;
21
+ setInput('');
22
+
23
+ // Add user message to the list
24
+ setMessages(prev => [...prev, {
25
+ type: "user",
26
+ text: userMessage
27
+ }]);
28
+ try {
29
+ // Add placeholder for AI message
30
+ setMessages(prev => [...prev, {
31
+ type: "ai",
32
+ text: ''
33
+ }]);
34
+
35
+ // Simulate response with streaming
36
+ const response = await onSendMessage(userMessage, chunk => {
37
+ setMessages(prev => {
38
+ const newMessages = [...prev];
39
+ const lastMessage = newMessages[newMessages.length - 1];
40
+ if (lastMessage && lastMessage.type === "ai") {
41
+ lastMessage.text += chunk;
42
+ }
43
+ return newMessages;
44
+ });
45
+ });
46
+
47
+ // Finalize AI response
48
+ setMessages(prev => {
49
+ const newMessages = [...prev];
50
+ const lastMessage = newMessages[newMessages.length - 1];
51
+ if (lastMessage && lastMessage.type === "ai" && lastMessage.text !== response) {
52
+ lastMessage.text = response;
53
+ }
54
+ return newMessages;
55
+ });
56
+ } catch (error) {
57
+ console.error('Error sending message:', error);
58
+ }
59
+ };
60
+ const onSendMessage = async (message, onStream) => {
61
+ try {
62
+ if (onStream) {
63
+ const words = `You said: ${message}`.split(' ');
64
+ for (const word of words) {
65
+ await new Promise(resolve => setTimeout(resolve, 100));
66
+ onStream(word + ' ');
67
+ }
68
+ return `You said: ${message}`;
69
+ }
70
+ await new Promise(resolve => setTimeout(resolve, 1000));
71
+ return `You said: ${message}`;
72
+ } catch (error) {
73
+ console.error('Error handling message:', error);
74
+ return 'Error processing message';
75
+ }
76
+ };
77
+ return /*#__PURE__*/React.createElement(AppContext.Provider, {
78
+ value: {
79
+ showModal,
80
+ setShowModal,
81
+ messages,
82
+ setMessages,
83
+ handleSend,
84
+ onSendMessage,
85
+ input,
86
+ setInput
87
+ }
88
+ }, children);
89
+ };
90
+ //# sourceMappingURL=AppContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","createContext","useContext","useState","useEffect","AppContext","AppProvider","children","showModal","setShowModal","input","setInput","messages","setMessages","type","text","handleSend","trim","userMessage","prev","response","onSendMessage","chunk","newMessages","lastMessage","length","error","console","message","onStream","words","split","word","Promise","resolve","setTimeout","createElement","Provider","value"],"sourceRoot":"../../../src","sources":["contexts/AppContext.js"],"mappings":"AAAA,OAAOA,KAAK,IAAGC,aAAa,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,SAAS,QAAQ,OAAO;AAE5E,OAAO,MAAMC,UAAU,gBAAGJ,aAAa,CAAC,CAAC;AAEzC,OAAO,MAAMK,WAAW,GAAGA,CAAC;EAAEC;AAAS,CAAC,KAAK;EAE3C,MAAM,CAACC,SAAS,EAAEC,YAAY,CAAC,GAAGN,QAAQ,CAAC,MAAM,CAAC;EAElD,MAAM,CAACO,KAAK,EAAEC,QAAQ,CAAC,GAAGR,QAAQ,CAAC,EAAE,CAAC;EACtC,MAAM,CAACS,QAAQ,EAAEC,WAAW,CAAC,GAAGV,QAAQ,CAAC,CACvC;IAACW,IAAI,EAAE,IAAI;IAAEC,IAAI,EAAE;EAAiK,CAAC,EACrL;IAACD,IAAI,EAAE,MAAM;IAAEC,IAAI,EAAE;EAAmC,CAAC,EACzD;IAACD,IAAI,EAAE,IAAI;IAAEC,IAAI,EAAE;EAA2T,CAAC,CAChV,CAAC;EAEF,MAAMC,UAAU,GAAG,MAAAA,CAAA,KAAY;IAC7B,IAAI,CAACN,KAAK,CAACO,IAAI,CAAC,CAAC,EAAE;IAEnB,MAAMC,WAAW,GAAGR,KAAK;IACzBC,QAAQ,CAAC,EAAE,CAAC;;IAEZ;IACAE,WAAW,CAAEM,IAAI,IAAK,CAAC,GAAGA,IAAI,EAAE;MAAEL,IAAI,EAAE,MAAM;MAAEC,IAAI,EAAEG;IAAY,CAAC,CAAC,CAAC;IAErE,IAAI;MACF;MACAL,WAAW,CAAEM,IAAI,IAAK,CAAC,GAAGA,IAAI,EAAE;QAAEL,IAAI,EAAE,IAAI;QAAEC,IAAI,EAAE;MAAG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CAAC;QACtB;QACA,OAAO,aAAaJ,OAAO,EAAE;MAC/B;MAEA,MAAM,IAAIK,OAAO,CAAEC,OAAO,IAAKC,UAAU,CAACD,OAAO,EAAE,IAAI,CAAC,CAAC;MACzD,OAAO,aAAaN,OAAO,EAAE;IAC/B,CAAC,CAAC,OAAOF,KAAK,EAAE;MACdC,OAAO,CAACD,KAAK,CAAC,yBAAyB,EAAEA,KAAK,CAAC;MAC/C,OAAO,0BAA0B;IACnC;EACF,CAAC;EAGD,oBACE1B,KAAA,CAAAoC,aAAA,CAAC/B,UAAU,CAACgC,QAAQ;IAClBC,KAAK,EAAE;MAAE9B,SAAS;MAAEC,YAAY;MAAEG,QAAQ;MAAEC,WAAW;MAAEG,UAAU;MAAEK,aAAa;MAAEX,KAAK;MAAEC;IAC3F;EAAE,GAEDJ,QACkB,CAAC;AAE1B,CAAC","ignoreList":[]}
@@ -0,0 +1,194 @@
1
+ import React, { useState, useEffect, useRef, useContext } from 'react';
2
+ import { AppContext } from "../contexts/AppContext";
3
+ export function useWebSocketMessage() {
4
+ const {
5
+ setIsComplete,
6
+ startStreaming,
7
+ setMessages,
8
+ messages,
9
+ setGhostMessage,
10
+ isMobile,
11
+ setTypingIndicator,
12
+ setStartStreaming,
13
+ lastUserMessage,
14
+ stopActivated,
15
+ custEmail,
16
+ custName,
17
+ data,
18
+ setGhostCard,
19
+ BASE_URL,
20
+ setStopActivated,
21
+ setLastMessageId
22
+ } = useContext(AppContext);
23
+ const wsProtocol = window.location.protocol === 'https:' ? 'wss://' : 'ws://';
24
+ const wsUrl = BASE_URL.replace(/^http(s)?:\/\//, '');
25
+ const ENDPOINT = '/send/event';
26
+ const payload = {
27
+ ...data,
28
+ user_query: lastUserMessage,
29
+ customer_name: data.customer_name
30
+ };
31
+ const wsRef = useRef(null);
32
+ useEffect(() => {
33
+ if (startStreaming) {
34
+ console.log(payload);
35
+ const socketUrl = `${wsProtocol}${wsUrl}${ENDPOINT}`;
36
+ const ws = new WebSocket(socketUrl);
37
+ wsRef.current = ws;
38
+ ws.onopen = () => {
39
+ console.log("WebSocket connection established.");
40
+ ws.send(JSON.stringify(payload));
41
+ };
42
+ ws.onmessage = event => {
43
+ var _response$resource_de, _response$resource_de2;
44
+ const response = JSON.parse(event.data);
45
+ console.log(response);
46
+ switch (response.type) {
47
+ case 'middle_message':
48
+ const middleMessage = {
49
+ type: "middle",
50
+ text: response.message,
51
+ products: [],
52
+ product_cards: "False"
53
+ };
54
+ setMessages([...messages, middleMessage]);
55
+ break;
56
+ case 'message':
57
+ if (response.product_cards == "False" || response.product_cards == false) {
58
+ setGhostMessage(false);
59
+ setTypingIndicator(false);
60
+ } else {
61
+ setGhostMessage(false);
62
+ setGhostCard(true);
63
+ }
64
+ const newMessage = {
65
+ type: "ai",
66
+ message_id: response.message_id || '',
67
+ text: [response.message],
68
+ feedback: "True",
69
+ products: [],
70
+ product_cards: response.product_cards || "False",
71
+ resource: (response === null || response === void 0 || (_response$resource_de = response.resource_details) === null || _response$resource_de === void 0 || (_response$resource_de = _response$resource_de[0]) === null || _response$resource_de === void 0 ? void 0 : _response$resource_de.link) ?? "",
72
+ resource_type: (response === null || response === void 0 || (_response$resource_de2 = response.resource_details) === null || _response$resource_de2 === void 0 || (_response$resource_de2 = _response$resource_de2[0]) === null || _response$resource_de2 === void 0 ? void 0 : _response$resource_de2.type) ?? ""
73
+ };
74
+ setMessages(prevMessages => [...prevMessages, newMessage]);
75
+ setLastMessageId(response.message_id);
76
+ break;
77
+ case 'chunk':
78
+ const newContent = response.chunk;
79
+ const newMessageId = response.message_id;
80
+ setMessages(prevMessages => {
81
+ const lastMessageIndex = prevMessages.length - 1;
82
+ if (prevMessages[lastMessageIndex] && prevMessages[lastMessageIndex].type === "ai") {
83
+ const updatedLastMessage = {
84
+ ...prevMessages[lastMessageIndex],
85
+ text: [prevMessages[lastMessageIndex].text[0] + newContent],
86
+ message_id: newMessageId || prevMessages[lastMessageIndex].message_id,
87
+ feedback: "True"
88
+ };
89
+ return [...prevMessages.slice(0, lastMessageIndex), updatedLastMessage];
90
+ } else {
91
+ setGhostMessage(false);
92
+ return [...prevMessages, {
93
+ type: "ai",
94
+ text: [newContent],
95
+ message_id: newMessageId,
96
+ feedback: "True"
97
+ }];
98
+ }
99
+ });
100
+ if (newMessageId) {
101
+ setLastMessageId(newMessageId);
102
+ }
103
+ break;
104
+ case 'product_cards':
105
+ setMessages(prevMessages => {
106
+ const lastMessageIndex = prevMessages.length - 1;
107
+ if (prevMessages[lastMessageIndex] && prevMessages[lastMessageIndex].type === "ai") {
108
+ const updatedLastMessage = {
109
+ ...prevMessages[lastMessageIndex],
110
+ products: response.products || [],
111
+ product_cards: "True"
112
+ };
113
+ return [...prevMessages.slice(0, lastMessageIndex), updatedLastMessage];
114
+ }
115
+ });
116
+ setGhostMessage(false);
117
+ setTypingIndicator(false);
118
+ setGhostCard(false);
119
+ break;
120
+ case 'product_document':
121
+ setMessages(prevMessages => {
122
+ const lastMessageIndex = prevMessages.length - 1;
123
+ if (prevMessages[lastMessageIndex] && prevMessages[lastMessageIndex].type === "ai") {
124
+ var _response$resource_de3, _response$resource_de4;
125
+ const updatedLastMessage = {
126
+ ...prevMessages[lastMessageIndex],
127
+ resource: (response === null || response === void 0 || (_response$resource_de3 = response.resource_details) === null || _response$resource_de3 === void 0 || (_response$resource_de3 = _response$resource_de3[0]) === null || _response$resource_de3 === void 0 ? void 0 : _response$resource_de3.link) ?? "",
128
+ resource_type: (response === null || response === void 0 || (_response$resource_de4 = response.resource_details) === null || _response$resource_de4 === void 0 || (_response$resource_de4 = _response$resource_de4[0]) === null || _response$resource_de4 === void 0 ? void 0 : _response$resource_de4.type) ?? ""
129
+ };
130
+ return [...prevMessages.slice(0, lastMessageIndex), updatedLastMessage];
131
+ }
132
+ });
133
+ setGhostMessage(false);
134
+ setTypingIndicator(false);
135
+ setGhostCard(false);
136
+ break;
137
+ case 'suggested_questions':
138
+ /* const questions = {
139
+ type: "questions",
140
+ message_id: response.message_id || '',
141
+ suggested_questions: response.suggested_questions || [],
142
+ }; */
143
+ setMessages(prevMessages => {
144
+ const lastMessageIndex = prevMessages.length - 1;
145
+ if (prevMessages[lastMessageIndex] && prevMessages[lastMessageIndex].type === "ai") {
146
+ const updatedLastMessage = {
147
+ ...prevMessages[lastMessageIndex],
148
+ suggested_questions: true,
149
+ questions: response.suggested_questions
150
+ };
151
+ return [...prevMessages.slice(0, lastMessageIndex), updatedLastMessage];
152
+ }
153
+ });
154
+ //setMessages((prevMessages) => [...prevMessages, questions]);
155
+ break;
156
+ case 'setComplete':
157
+ setIsComplete(true);
158
+ setTypingIndicator(false);
159
+ setStartStreaming(false);
160
+ setGhostCard(false);
161
+ break;
162
+ }
163
+ };
164
+ ws.onerror = error => {
165
+ setStartStreaming(false);
166
+ setGhostMessage(false);
167
+ setTypingIndicator(false);
168
+ setGhostCard(false);
169
+ };
170
+ ws.onclose = event => {
171
+ console.log("WebSocket connection closed:", event.reason);
172
+ setStartStreaming(false);
173
+ setGhostMessage(false);
174
+ setTypingIndicator(false);
175
+ setGhostCard(false);
176
+ };
177
+ return () => {
178
+ ws.close();
179
+ };
180
+ }
181
+ ;
182
+ }, [startStreaming]);
183
+ useEffect(() => {
184
+ if (wsRef.current && wsRef.current.readyState === WebSocket.OPEN) {
185
+ wsRef.current.close();
186
+ setStartStreaming(false);
187
+ setGhostMessage(false);
188
+ setGhostCard(false);
189
+ setTypingIndicator(false);
190
+ setStopActivated(false);
191
+ }
192
+ }, [stopActivated, setStartStreaming]);
193
+ }
194
+ //# sourceMappingURL=Stream.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","useState","useEffect","useRef","useContext","AppContext","useWebSocketMessage","setIsComplete","startStreaming","setMessages","messages","setGhostMessage","isMobile","setTypingIndicator","setStartStreaming","lastUserMessage","stopActivated","custEmail","custName","data","setGhostCard","BASE_URL","setStopActivated","setLastMessageId","wsProtocol","window","location","protocol","wsUrl","replace","ENDPOINT","payload","user_query","customer_name","wsRef","console","log","socketUrl","ws","WebSocket","current","onopen","send","JSON","stringify","onmessage","event","_response$resource_de","_response$resource_de2","response","parse","type","middleMessage","text","message","products","product_cards","newMessage","message_id","feedback","resource","resource_details","link","resource_type","prevMessages","newContent","chunk","newMessageId","lastMessageIndex","length","updatedLastMessage","slice","_response$resource_de3","_response$resource_de4","suggested_questions","questions","onerror","error","onclose","reason","close","readyState","OPEN"],"sourceRoot":"../../../src","sources":["hooks/Stream.js"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,EAAEC,SAAS,EAAEC,MAAM,EAAEC,UAAU,QAAQ,OAAO;AACtE,SAASC,UAAU,QAAQ,wBAAwB;AAEnD,OAAO,SAASC,mBAAmBA,CAAA,EAAG;EAClC,MAAM;IAAEC,aAAa;IAAEC,cAAc;IAAEC,WAAW;IAAEC,QAAQ;IAAEC,eAAe;IAAEC,QAAQ;IACnFC,kBAAkB;IAAEC,iBAAiB;IAAEC,eAAe;IAAEC,aAAa;IAAEC,SAAS;IAAEC,QAAQ;IAAEC,IAAI;IAChGC,YAAY;IAAEC,QAAQ;IAAEC,gBAAgB;IAAEC;EAAiB,CAAC,GAAGnB,UAAU,CAACC,UAAU,CAAC;EAEzF,MAAMmB,UAAU,GAAGC,MAAM,CAACC,QAAQ,CAACC,QAAQ,KAAK,QAAQ,GAAG,QAAQ,GAAG,OAAO;EAC7E,MAAMC,KAAK,GAAGP,QAAQ,CAACQ,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC;EACpD,MAAMC,QAAQ,GAAG,aAAa;EAE9B,MAAMC,OAAO,GAAG;IACZ,GAAGZ,IAAI;IACPa,UAAU,EAAEjB,eAAe;IAC3BkB,aAAa,EAAEd,IAAI,CAACc;EACxB,CAAC;EAED,MAAMC,KAAK,GAAG/B,MAAM,CAAC,IAAI,CAAC;EAE1BD,SAAS,CAAC,MAAM;IACZ,IAAIM,cAAc,EAAE;MAChB2B,OAAO,CAACC,GAAG,CAACL,OAAO,CAAC;MACpB,MAAMM,SAAS,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AAC,CAAC;AAE1C","ignoreList":[]}
@@ -1,158 +1,17 @@
1
- import React from 'react';
2
- import { SafeAreaView, Text, StyleSheet, View, TextInput, ScrollView, KeyboardAvoidingView, Platform, Button } from 'react-native';
3
- const defaultTheme = {
4
- primaryColor: '#007AFF',
5
- backgroundColor: '#FFFFFF',
6
- textColor: '#000000'
7
- };
1
+ import React, { useState, useCallback } from 'react';
2
+ import { SafeAreaView, Text, StyleSheet, View, TextInput, ScrollView, KeyboardAvoidingView, Platform, TouchableOpacity, RefreshControl } from 'react-native';
3
+ import { Ionicons as Icon } from '@expo/vector-icons';
4
+ import { AppProvider } from './contexts/AppContext';
5
+ import { Layout } from './layout/layout';
8
6
  export const Chat = ({
9
- onSendMessage,
10
- theme = defaultTheme
7
+ data,
8
+ onProductCardClick,
9
+ onAddToCartClick
11
10
  }) => {
12
- const [message, setMessage] = React.useState('');
13
- const [messages, setMessages] = React.useState([]);
14
- const handleSend = async () => {
15
- if (!message.trim()) return;
16
- const userMessage = message;
17
- setMessage('');
18
- setMessages(prev => [...prev, {
19
- text: userMessage,
20
- isUser: true
21
- }]);
22
- try {
23
- const response = await onSendMessage(userMessage);
24
- setMessages(prev => [...prev, {
25
- text: response,
26
- isUser: false
27
- }]);
28
- } catch (error) {
29
- console.error('Error sending message:', error);
30
- }
31
- };
32
- const containerStyle = [styles.container, {
33
- backgroundColor: theme.backgroundColor
34
- }];
35
- const getMessageStyle = fromUser => [styles.messageBubble, fromUser ? styles.userMessage : styles.botMessage, {
36
- backgroundColor: fromUser ? theme.primaryColor : '#E8E8E8'
37
- }];
38
- const getTextStyle = fromUser => [styles.messageText, {
39
- color: fromUser ? '#fff' : theme.textColor
40
- }];
41
- return /*#__PURE__*/React.createElement(SafeAreaView, {
42
- style: containerStyle,
43
- testID: "chat-container"
44
- }, /*#__PURE__*/React.createElement(KeyboardAvoidingView, {
45
- behavior: Platform.OS === 'ios' ? 'padding' : 'height',
46
- style: styles.content
47
- }, /*#__PURE__*/React.createElement(ScrollView, {
48
- style: styles.messagesContainer
49
- }, messages.map((msg, i) => /*#__PURE__*/React.createElement(View, {
50
- key: i,
51
- style: getMessageStyle(msg.isUser)
52
- }, /*#__PURE__*/React.createElement(Text, {
53
- style: getTextStyle(msg.isUser)
54
- }, msg.text)))), /*#__PURE__*/React.createElement(View, {
55
- style: styles.inputContainer
56
- }, /*#__PURE__*/React.createElement(TextInput, {
57
- style: [styles.input, {
58
- color: theme.textColor
59
- }],
60
- value: message,
61
- onChangeText: setMessage,
62
- placeholder: "Type a message...",
63
- placeholderTextColor: "#999"
64
- }), /*#__PURE__*/React.createElement(Button, {
65
- title: "Send",
66
- onPress: handleSend,
67
- color: theme.primaryColor
68
- }))));
11
+ return /*#__PURE__*/React.createElement(AppProvider, null, /*#__PURE__*/React.createElement(Layout, {
12
+ onProductCardClick: onProductCardClick,
13
+ onAddToCartClick: onAddToCartClick
14
+ }));
69
15
  };
70
- const styles = StyleSheet.create({
71
- container: {
72
- flex: 1,
73
- backgroundColor: '#FFFFFF'
74
- },
75
- content: {
76
- flex: 1,
77
- backgroundColor: '#F8F9FA'
78
- },
79
- messagesContainer: {
80
- flex: 1,
81
- padding: 20,
82
- paddingTop: 30
83
- },
84
- messageBubble: {
85
- maxWidth: '85%',
86
- padding: 16,
87
- borderRadius: 20,
88
- marginBottom: 16,
89
- backgroundColor: '#FFFFFF',
90
- shadowColor: '#000',
91
- shadowOffset: {
92
- width: 0,
93
- height: 2
94
- },
95
- shadowOpacity: 0.05,
96
- shadowRadius: 8,
97
- elevation: 3
98
- },
99
- userMessage: {
100
- alignSelf: 'flex-end',
101
- backgroundColor: '#FFFFFF',
102
- borderWidth: 1,
103
- borderColor: 'rgba(0, 0, 0, 0.04)'
104
- },
105
- botMessage: {
106
- alignSelf: 'flex-start',
107
- backgroundColor: '#FFFFFF',
108
- borderWidth: 1,
109
- borderColor: 'rgba(0, 0, 0, 0.04)'
110
- },
111
- messageText: {
112
- fontSize: 15,
113
- lineHeight: 22,
114
- fontWeight: '400',
115
- color: '#2C2C2E',
116
- letterSpacing: 0.2
117
- },
118
- inputContainer: {
119
- flexDirection: 'row',
120
- alignItems: 'center',
121
- paddingHorizontal: 16,
122
- paddingVertical: 12,
123
- backgroundColor: '#FFFFFF',
124
- borderTopWidth: 1,
125
- borderTopColor: 'rgba(0, 0, 0, 0.06)',
126
- shadowColor: '#000',
127
- shadowOffset: {
128
- width: 0,
129
- height: -8
130
- },
131
- shadowOpacity: 0.04,
132
- shadowRadius: 12,
133
- elevation: 8,
134
- marginTop: 'auto'
135
- },
136
- input: {
137
- flex: 1,
138
- backgroundColor: '#F8F9FA',
139
- borderRadius: 16,
140
- borderWidth: 1,
141
- borderColor: 'rgba(0, 0, 0, 0.06)',
142
- paddingHorizontal: 20,
143
- paddingVertical: 12,
144
- marginRight: 12,
145
- fontSize: 15,
146
- maxHeight: 120,
147
- color: '#2C2C2E',
148
- shadowColor: '#000',
149
- shadowOffset: {
150
- width: 0,
151
- height: 1
152
- },
153
- shadowOpacity: 0.04,
154
- shadowRadius: 4,
155
- elevation: 2
156
- }
157
- });
16
+ const styles = StyleSheet.create({});
158
17
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","SafeAreaView","Text","StyleSheet","View","TextInput","ScrollView","KeyboardAvoidingView","Platform","Button","defaultTheme","primaryColor","backgroundColor","textColor","Chat","onSendMessage","theme","message","setMessage","useState","messages","setMessages","handleSend","trim","userMessage","prev","text","isUser","response","error","console","containerStyle","styles","container","getMessageStyle","fromUser","messageBubble","botMessage","getTextStyle","messageText","color","createElement","style","testID","behavior","OS","content","messagesContainer","map","msg","i","key","inputContainer","input","value","onChangeText","placeholder","placeholderTextColor","title","onPress","create","flex","padding","paddingTop","maxWidth","borderRadius","marginBottom","shadowColor","shadowOffset","width","height","shadowOpacity","shadowRadius","elevation","alignSelf","borderWidth","borderColor","fontSize","lineHeight","fontWeight","letterSpacing","flexDirection","alignItems","paddingHorizontal","paddingVertical","borderTopWidth","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,eAAe,EAAE,SAAS;IAC1B+D,WAAW,EAAE,CAAC;IACdC,WAAW,EAAE;EACf,CAAC;EACDrC,WAAW,EAAE;IACXsC,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE,EAAE;IACdC,UAAU,EAAE,KAAK;IACjBvC,KAAK,EAAE,SAAS;IAChBwC,aAAa,EAAE;EACjB,CAAC;EACD5B,cAAc,EAAE;IACd6B,aAAa,EAAE,KAAK;IACpBC,UAAU,EAAE,QAAQ;IACpBC,iBAAiB,EAAE,EAAE;IACrBC,eAAe,EAAE,EAAE;IACnBxE,eAAe,EAAE,SAAS;IAC1ByE,cAAc,EAAE,CAAC;IACjBC,cAAc,EAAE,qBAAqB;IACrCnB,WAAW,EAAE,MAAM;IACnBC,YAAY,EAAE;MACZC,KAAK,EAAE,CAAC;MACRC,MAAM,EAAE,CAAC;IACX,CAAC;IACDC,aAAa,EAAE,IAAI;IACnBC,YAAY,EAAE,EAAE;IAChBC,SAAS,EAAE,CAAC;IACZc,SAAS,EAAE;EACb,CAAC;EACDlC,KAAK,EAAE;IACLQ,IAAI,EAAE,CAAC;IACPjD,eAAe,EAAE,SAAS;IAC1BqD,YAAY,EAAE,EAAE;IAChBU,WAAW,EAAE,CAAC;IACdC,WAAW,EAAE,qBAAqB;IAClCO,iBAAiB,EAAE,EAAE;IACrBC,eAAe,EAAE,EAAE;IACnBI,WAAW,EAAE,EAAE;IACfX,QAAQ,EAAE,EAAE;IACZY,SAAS,EAAE,GAAG;IACdjD,KAAK,EAAE,SAAS;IAChB2B,WAAW,EAAE,MAAM;IACnBC,YAAY,EAAE;MACZC,KAAK,EAAE,CAAC;MACRC,MAAM,EAAE;IACV,CAAC;IACDC,aAAa,EAAE,IAAI;IACnBC,YAAY,EAAE,CAAC;IACfC,SAAS,EAAE;EACb;AACF,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["React","useState","useCallback","SafeAreaView","Text","StyleSheet","View","TextInput","ScrollView","KeyboardAvoidingView","Platform","TouchableOpacity","RefreshControl","Ionicons","Icon","AppProvider","Layout","Chat","data","onProductCardClick","onAddToCartClick","createElement","styles","create"],"sourceRoot":"../../src","sources":["index.js"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,EAAEC,WAAW,QAAQ,OAAO;AACpD,SAASC,YAAY,EAAEC,IAAI,EAAEC,UAAU,EAAEC,IAAI,EAAEC,SAAS,EAAEC,UAAU,EAAEC,oBAAoB,EACxFC,QAAQ,EAAEC,gBAAgB,EAAEC,cAAc,QAAS,cAAc;AACnE,SAASC,QAAQ,IAAIC,IAAI,QAAQ,oBAAoB;AACrD,SAASC,WAAW,QAAQ,uBAAuB;AACnD,SAASC,MAAM,QAAQ,iBAAiB;AAExC,OAAO,MAAMC,IAAI,GAAGA,CAAC;EAACC,IAAI;EAAEC,kBAAkB;EAAEC;AAAiB,CAAC,KAAK;EAErE,oBACEpB,KAAA,CAAAqB,aAAA,CAACN,WAAW,qBACVf,KAAA,CAAAqB,aAAA,CAACL,MAAM;IAACG,kBAAkB,EAAEA,kBAAmB;IAACC,gBAAgB,EAAEA;EAAiB,CAAC,CACzE,CAAC;AAElB,CAAC;AAED,MAAME,MAAM,GAAGjB,UAAU,CAACkB,MAAM,CAAC,CACjC,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,44 @@
1
+ import React, { useContext } from 'react';
2
+ import { TouchableOpacity, View, StyleSheet } from 'react-native';
3
+ import { Ionicons as Icon } from '@expo/vector-icons';
4
+ import { AppContext } from '../contexts/AppContext';
5
+ export const ChatIcon = () => {
6
+ const {
7
+ setShowModal
8
+ } = useContext(AppContext);
9
+ return /*#__PURE__*/React.createElement(TouchableOpacity, {
10
+ style: styles.iconContainer,
11
+ onPress: () => setShowModal("ChatWindow")
12
+ }, /*#__PURE__*/React.createElement(View, {
13
+ style: styles.icon
14
+ }, /*#__PURE__*/React.createElement(Icon, {
15
+ name: "chatbubble-ellipses",
16
+ size: 28,
17
+ color: "white"
18
+ })));
19
+ };
20
+ const styles = StyleSheet.create({
21
+ iconContainer: {
22
+ position: 'absolute',
23
+ bottom: 80,
24
+ right: 20,
25
+ zIndex: 10
26
+ },
27
+ icon: {
28
+ backgroundColor: '#FFA500',
29
+ width: 60,
30
+ height: 60,
31
+ borderRadius: 30,
32
+ alignItems: 'center',
33
+ justifyContent: 'center',
34
+ shadowColor: '#000',
35
+ shadowOffset: {
36
+ width: 0,
37
+ height: 2
38
+ },
39
+ shadowOpacity: 0.2,
40
+ shadowRadius: 3,
41
+ elevation: 5
42
+ }
43
+ });
44
+ //# sourceMappingURL=chatIcon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","useContext","TouchableOpacity","View","StyleSheet","Ionicons","Icon","AppContext","ChatIcon","setShowModal","createElement","style","styles","iconContainer","onPress","icon","name","size","color","create","position","bottom","right","zIndex","backgroundColor","width","height","borderRadius","alignItems","justifyContent","shadowColor","shadowOffset","shadowOpacity","shadowRadius","elevation"],"sourceRoot":"../../../src","sources":["layout/chatIcon.js"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,UAAU,QAAQ,OAAO;AACzC,SAASC,gBAAgB,EAAEC,IAAI,EAAEC,UAAU,QAAQ,cAAc;AACjE,SAASC,QAAQ,IAAIC,IAAI,QAAQ,oBAAoB;AACrD,SAASC,UAAU,QAAQ,wBAAwB;AAEnD,OAAO,MAAMC,QAAQ,GAAGA,CAAA,KAAM;EAC5B,MAAM;IAAEC;EAAa,CAAC,GAAGR,UAAU,CAACM,UAAU,CAAC;EAE/C,oBACEP,KAAA,CAAAU,aAAA,CAACR,gBAAgB;IAACS,KAAK,EAAEC,MAAM,CAACC,aAAc;IAACC,OAAO,EAAEA,CAAA,KAAML,YAAY,CAAC,YAAY;EAAE,gBACvFT,KAAA,CAAAU,aAAA,CAACP,IAAI;IAACQ,KAAK,EAAEC,MAAM,CAACG;EAAK,gBACvBf,KAAA,CAAAU,aAAA,CAACJ,IAAI;IAACU,IAAI,EAAC,qBAAqB;IAACC,IAAI,EAAE,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