od-support-chat 1.0.9 → 1.0.10

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/package.json CHANGED
@@ -1,20 +1,16 @@
1
1
  {
2
2
  "name": "od-support-chat",
3
3
  "private": false,
4
- "version": "1.0.9",
4
+ "version": "1.0.10",
5
5
  "type": "module",
6
- "main": "./dist/index.cjs",
7
- "module": "./dist/index.js",
8
6
  "types": "./dist/index.d.ts",
7
+ "exports": {
8
+ ".": "./dist/index.mjs",
9
+ "./package.json": "./package.json"
10
+ },
9
11
  "scripts": {
10
12
  "build": "tsdown"
11
13
  },
12
- "exports": {
13
- ".": {
14
- "import": "./dist/index.js",
15
- "require": "./dist/index.cjs"
16
- }
17
- },
18
14
  "peerDependencies": {
19
15
  "@types/react": "^18.0.17",
20
16
  "@types/react-dom": "^18.0.6",
@@ -35,6 +31,7 @@
35
31
  "typescript": "^6.0.2",
36
32
  "vite": "^3.1.0"
37
33
  },
38
-
39
- "files": ["dist"]
34
+ "files": [
35
+ "dist"
36
+ ]
40
37
  }
@@ -1 +0,0 @@
1
- var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));exports.__toESM=s;
@@ -1,233 +0,0 @@
1
- const e=require(`../../_virtual/_rolldown/runtime.cjs`),t=require(`./info.guest.cjs`);let n=require(`react`);n=e.__toESM(n);let r=require(`styled-components`);r=e.__toESM(r);const i=r.keyframes`
2
- from {
3
- opacity: 0;
4
- transform: translateY(20px);
5
- }
6
- to {
7
- opacity: 1;
8
- transform: translateY(0);
9
- }
10
- `,a=r.keyframes`
11
- from {
12
- opacity: 1;
13
- transform: translateY(0);
14
- }
15
- to {
16
- opacity: 0;
17
- transform: translateY(20px);
18
- }
19
- `,o=r.default.div`
20
- position: fixed;
21
- right: 0;
22
- top: 50%;
23
- height: 35%;
24
- width: ${e=>e.maxWidth}%;
25
- display: flex;
26
- flex-direction: column;
27
- background-color: white;
28
- box-shadow: -2px 0 5px rgba(0, 0, 0, 0.5);
29
- transition: all 0.5s ease;
30
- overflow: hidden;
31
- z-index: 10000;
32
- animation: ${({displayChat:e})=>e?i:a} 0.3s ease-in-out forwards;
33
- `,ee=r.default.div`
34
- position: fixed;
35
- right: 0;
36
- bottom: 10%;
37
- height: 15%;
38
- width: ${e=>e.maxWidth/2.5}%;
39
- display: flex;
40
- flex-direction: column;
41
- transition: all 0.5s ease;
42
- overflow: hidden;
43
- z-index: 10000;
44
- animation: ${({displayChat:e})=>e?a:i} 0.3s ease-in-out forwards;
45
- `,s=r.default.div`
46
- position: absolute;
47
- top: 5;
48
- margin-left: 5px;
49
- margin-top: 5px;
50
- height: 30px;
51
- border: 1px solid rgb(78, 161, 211, 0.3);
52
- width: 96%;
53
-
54
- font-weight: 600;
55
- font-size: 14px;
56
- color: rgb(78, 161, 211);
57
- padding: 5px;
58
- `,c=r.default.div`
59
- display: flex;
60
- flex-direction: column;
61
- align-items: flex-start;
62
- width: 100%;
63
- font-weight: 600;
64
- font-size: 12px;
65
- color: rgb(78, 161, 211);
66
- `,l=r.default.div`
67
- position: absolute;
68
- top: 0;
69
- right: 0;
70
- padding-top: 5px;
71
- width: 30px;
72
- font-size: calc(10px + 1vmin);
73
- color: white;
74
-
75
- :hover {
76
- cursor: pointer;
77
- }
78
- `,u=r.default.div`
79
- position: absolute;
80
- text-align: center;
81
- align-items: center;
82
- top: 38px;
83
- margin-left: 5px;
84
- margin-top: 5px;
85
- border: 1px solid rgb(78, 161, 211, 0.3);
86
- border-radius: 15px;
87
- width: 96%;
88
-
89
- margin-left: 5px;
90
- margin-top: 2px;
91
- font-weight: 600;
92
- font-size: 12px;
93
- color: white;
94
- padding: 5px;
95
- background-color: rgb(78, 161, 211);
96
- `,d=r.default.div`
97
- position: absolute;
98
- text-align: center;
99
- align-items: center;
100
- display: flex;
101
- gap: 5px;
102
- border: 1px solid rgb(78, 161, 211, 0.3);
103
- border-radius: 15px;
104
- width: 100%;
105
-
106
- margin-left: 10px;
107
- margin-top: 2px;
108
- font-weight: 600;
109
- font-size: 12px;
110
- color: white;
111
- padding: 10px;
112
- background-color: rgb(78, 161, 211);
113
- `,te=r.default.div`
114
- position: absolute;
115
- top: 80px;
116
- margin-left: 5px;
117
- margin-top: 5px;
118
- width: 100%;
119
- height: 65%;
120
- max-height: 83%;
121
- overflow-x: hidden;
122
- overflow-y: auto;
123
- `,ne=r.default.div`
124
- display: flex;
125
- width: 100%;
126
- flex-direction: column;
127
- padding: 15px;
128
- color: #454552;
129
- `,f=r.default.div`
130
- width: 100%;
131
- display: flex;
132
- flex-direction: column;
133
- align-items: flex-start;
134
- font-size: 12px;
135
- margin-top: 5px;
136
- margin-left: 5px;
137
- text-align: left;
138
-
139
- > strong {
140
- margin-left: 3px;
141
- color: rgb(78, 161, 211)
142
- }
143
-
144
- > p {
145
- max-width: 95%;
146
- width: auto;
147
- padding: 5px;
148
- margin-top: 5px;
149
- border: 1px solid rgb(78, 161, 211, 0.3);
150
- border-radius: 15px;
151
- color: black;
152
- font-size: 12px;
153
- text-align: left;
154
- }
155
- `,p=r.default.div`
156
- width: 100%;
157
- display: flex;
158
- flex-direction: column;
159
- align-items: flex-start;
160
- font-size: 12px;
161
- margin-top: 5px;
162
- margin-left: 5px;
163
- text-align: left;
164
-
165
- > strong {
166
- margin-right: 35px;
167
- color: rgb(215, 61, 71)
168
- }
169
-
170
- > p {
171
- max-width: 95%;
172
- width: auto;
173
- padding: 5px;
174
- margin-top: 5px;
175
- border: 1px solid rgb(78, 161, 211, 0.3);
176
- border-radius: 15px;
177
- color: black;
178
- font-size: 12px;
179
- text-align: left;
180
- background-color: #f5f5f5;
181
- }
182
- `,m=r.default.div`
183
- position: absolute;
184
- display: flex;
185
- bottom: 10px;
186
- margin-left: 5px;
187
- margin-top: 5px;
188
- flex-direction: row;
189
- align-items: center;
190
- width: 100%;
191
- gap: 5px;
192
- `,h=r.default.input`
193
- bottom: 0;
194
- width: 70%;
195
- height: 25px;
196
- margin-left: 5px;
197
- border: 2px solid rgb(69, 69, 82, 0.25);
198
- box-sizing: border-box;
199
- font-size: 14px;
200
- padding-left: 5px;
201
- opacity: 0.7;
202
-
203
- :focus {
204
- outline: none;
205
- }
206
- `,g=r.default.div`
207
- height: 25px;
208
- outline: none;
209
- border: none;
210
- display: flex;
211
- align-items: center;
212
- justify-content: flex-end;
213
- border-radius: 10px;
214
- padding-left: 5px;
215
- padding-right: 10px;
216
- margin-right: 10px;
217
- color: black;
218
- background-color: #bed0f8;
219
- font-size: 1rem;
220
- font-weight: 500;
221
- cursor: pointer;
222
- `,_=r.default.div`
223
- position: absolute;
224
- top: 80px;
225
- margin-left: 25px;
226
- width: 100%;
227
- height: 65%;
228
- width: 83%;
229
- margin-bottom: 25px;
230
- `,v=r.default.i`
231
- width: 25px;
232
- font-size: calc(5px + 1vmin);
233
- `;var y,b,x;const S=`optimizetalk.com:8443`,C=({meetingLinkKey:e,customerSupportKey:r})=>{let i=(0,n.useRef)(null),[a]=(0,n.useState)(window.innerWidth<window.innerHeight&&window.innerWidth<=900),[C]=(0,n.useState)(a?100:15),[w,T]=(0,n.useState)([]),E=(0,n.useRef)(),[D,O]=(0,n.useState)(!0),[k,A]=(0,n.useState)(!1),[j,M]=(0,n.useState)(!1),[N,P]=(0,n.useState)(null),[F,I]=(0,n.useState)(null),[L,R]=(0,n.useState)(),[z,B]=(0,n.useState)(),[V,H]=(0,n.useState)(!1),[U,W]=(0,n.useState)(``),G=(0,n.useRef)(null),K=(0,n.useRef)(null),q=()=>{let e=1e4,t=Math.floor(Math.random()*(9e4-e+1))+e;return console.log(`Random number: `+t),t},J=(e,t)=>{y=new WebSocket(`wss://`+S+`/signal`),y.onopen=function(){console.log(`Websocket connection established`),oe(),re(e,t),$({from:{userName:e,audio:!0,video:!0},type:`text`,data:`ping from `+e}),b=setInterval(()=>{$({from:{userName:e,audio:!0,video:!0},type:`text`,data:`ping from `+e})},45e3),Z(e,t),console.log(`WebSocket connection opened to chat room `+U)}},Y=(e,t)=>{M(!0),P(t),console.log(`Params guestName:`+e+`, guestEmail:`+t);var n=F?e:`Guest-`+q()+`: `+e;I(n),console.log(`Joining : `+n),J(n,t)};function X(){console.log(`Close the socket`),y!=null&&(console.log(`Send 'leave' message to server for session `+L+` accessToken: `+z),$({from:{userName:F,sessionKey:L,audio:!0,video:!0},accessToken:z,type:`leave`,data:e}),y.close())}function re(e,t){y.onmessage=function(n){let r=JSON.parse(n.data);switch(console.log(`Room received type: `+r.type),r.type){case`text`:console.log(`Text message from `+r.from.userName+` received: `+r.data);break;case`join_meeting`:console.log(`Main message `+r.data),r.data&&r.data===`busy`?(console.log(`Customer support is busy`),H(!0),x||ie(e,t)):r.data&&r.data===`valid`&&(clearInterval(x),console.log(`Session key `+r.referenceUsers[0].sessionKey),R(r.referenceUsers[0].sessionKey),console.log(`Session accessToken `+r.accessToken),B(r.accessToken),console.log(`Joined to room `+r.roomDetails.roomName),W(r.roomDetails.roomName));break;case`message`:console.log(`Chat message received from `+r.from.userName),console.log(`Chat message `+r.data),ae(),T(e=>[...e,{sender:r.from.userName,msg:r.data}]),Q();break;case`session_expired`:console.log(`Chat session expired!`),M(!1),R(null),B(null),H(!1),X();break;default:console.log(`Room ignoring message type `+r.type)}}}let ie=(e,t)=>{x=setInterval(()=>{console.log(`Trying to connect customer support team ...`),Z(e,t)},1e4)},Z=(t,n)=>{$({from:{userName:t,email:n,audio:!1,video:!1},type:`join_meeting`,roomDetails:{roomLinkKey:e},data:r}),console.log(`Meeting join request sent for guest `+t)},ae=()=>{K.current.play()};function oe(){y.addEventListener(`close`,e=>{console.log(`websocket connection closed: `,e),clearInterval(b)}),y.onerror=function(e){console.log(`Error: `+e)}}let Q=()=>{i.current?.scrollIntoView({behavior:`smooth`})},se=e=>{if(e.key===`Enter`){let t=e.target.value;t&&(console.log(`Send 'message' message to server for session `+L+` accessToken: `+z),$({from:{userName:F,sessionKey:L,audio:!0,video:!0},accessToken:z,type:`message`,data:t}),console.log(`Chat message sent `+t),T(e=>[...e,{sender:F,msg:t}]),E.current.value=``)}},ce=()=>{let e=E.current.value;e&&(console.log(`Send 'message' message to server for session `+L+` accessToken: `+z),$({from:{userName:F,sessionKey:L,audio:!0,video:!0},accessToken:z,type:`message`,data:e}),console.log(`Chat message sent `+e),T(t=>[...t,{sender:F,msg:e}]),E.current.value=``,Q())};function $(e){let t=JSON.stringify(e);y.send(t)}function le(){X(),O(!1),A(!0),R(null),B(null),H(!1)}function ue(){y=new WebSocket(`wss://`+S+`/signal`),R(null),B(null),O(!0),A(!1),M(!1),H(!1),P(null),I(null),T([])}return(0,n.useEffect)(()=>{Q()},[w,L]),n.default.createElement(`div`,null,!k&&n.default.createElement(o,{displayChat:D,maxWidth:C},n.default.createElement(s,null,n.default.createElement(c,null,`OD Customer Support`),n.default.createElement(l,{onClick:()=>le(),className:`text-gray-700`},n.default.createElement(`svg`,{width:`60%`,height:`60%`,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`},n.default.createElement(`path`,{d:`M18 6L6 18M6 6L18 18`,stroke:`orange`,"stroke-width":`4`,"stroke-linecap":`round`,"stroke-linejoin":`round`})))),!j&&!L&&!V&&n.default.createElement(t.default,{startGuestChat:Y,guestEmail:N}),j&&!L&&!V&&n.default.createElement(n.default.Fragment,null,n.default.createElement(_,null,n.default.createElement(`div`,{className:`text-center mt-5`},`Please wait, connecting`),n.default.createElement(`div`,{className:`flex flex-col items-center `},n.default.createElement(`div`,null,n.default.createElement(`img`,{className:`mt-5`,src:`/connecting_customer_support.gif`,width:`80`})),n.default.createElement(`div`,{className:`absolute text-center bottom-6 font-sm text-sky-400`},`contact us at`),n.default.createElement(`div`,{className:`absolute text-center bottom-0 font-sm text-sky-400`},`support@origindetector.com.`)))),j&&!L&&V&&n.default.createElement(n.default.Fragment,null,n.default.createElement(_,null,n.default.createElement(`div`,{className:`text-center text-sm`},`Our customer support team helping other customers, please wait.`),n.default.createElement(`div`,{className:`text-center mt-5`},`connecting`),n.default.createElement(`div`,{className:`flex flex-col items-center `},n.default.createElement(`div`,null,n.default.createElement(`img`,{className:`mt-5`,src:`/connecting_customer_support.gif`,width:`80`})),n.default.createElement(`div`,{className:`absolute text-center bottom-6 font-sm text-sky-400`},`contact us at`),n.default.createElement(`div`,{className:`absolute text-center bottom-0 font-sm text-sky-400`},`support@origindetector.com`)))),j&&L&&n.default.createElement(`div`,null,n.default.createElement(u,null,`Live Chat`),n.default.createElement(te,null,n.default.createElement(ne,null,w&&w.length==0&&n.default.createElement(`div`,{className:`ml-2 text-sm`},` You are connected to our customer support team, how can we help you today? `),w&&w.length>0&&n.default.createElement(`div`,null,w&&w.map(({sender:e,msg:t},r)=>e===F?n.default.createElement(p,{key:r},n.default.createElement(`strong`,null,F),n.default.createElement(`p`,null,t)):n.default.createElement(f,{key:r},n.default.createElement(`strong`,null,e),n.default.createElement(`p`,null,t))),n.default.createElement(`div`,{style:{float:`left`,clear:`both`},ref:i})))),n.default.createElement(m,null,n.default.createElement(h,{ref:E,onKeyUp:se,placeholder:`Enter your message`}),n.default.createElement(g,{onClick:ce},n.default.createElement(v,{className:`fas fa-paper-plane`}),`Send`))),n.default.createElement(`audio`,{ref:G,src:`../../alert-sound.mp3`}),n.default.createElement(`audio`,{ref:K,src:`../../ding-small.mp3`})),k&&n.default.createElement(ee,{className:`cursor-pointer`,onClick:()=>ue(),displayChat:D,maxWidth:C},n.default.createElement(d,null,n.default.createElement(`i`,{className:`bx bx-chat`}),`Live Chat`)))};exports.default=C;
@@ -1,10 +0,0 @@
1
- import { FC } from "react";
2
-
3
- //#region src/components/chat/chat.d.ts
4
- interface ChatProps {
5
- meetingLinkKey: string;
6
- customerSupportKey: string;
7
- }
8
- declare const Chat: FC<ChatProps>;
9
- //#endregion
10
- export { Chat };
@@ -1,233 +0,0 @@
1
- const e=require(`../../_virtual/_rolldown/runtime.cjs`),t=require(`./info.guestMobile.cjs`);let n=require(`react`);n=e.__toESM(n);let r=require(`styled-components`);r=e.__toESM(r);const i=r.keyframes`
2
- from {
3
- opacity: 0;
4
- transform: translateY(20px);
5
- }
6
- to {
7
- opacity: 1;
8
- transform: translateY(0);
9
- }
10
- `,a=r.keyframes`
11
- from {
12
- opacity: 1;
13
- transform: translateY(0);
14
- }
15
- to {
16
- opacity: 0;
17
- transform: translateY(20px);
18
- }
19
- `,o=r.default.div`
20
- position: fixed;
21
- left: 10%;
22
- top: 50%;
23
- height: 45%;
24
- width: ${e=>e.maxWidth}%;
25
- display: flex;
26
- flex-direction: column;
27
- background-color: white;
28
- box-shadow: -2px 0 5px rgba(0, 0, 0, 0.5);
29
- transition: all 0.5s ease;
30
- overflow: hidden;
31
- z-index: 10000;
32
- animation: ${({displayChat:e})=>e?i:a} 0.3s ease-in-out forwards;
33
- `,ee=r.default.div`
34
- position: fixed;
35
- right: 0;
36
- bottom: 2%;
37
- height: 15%;
38
- width: ${e=>e.maxWidth/7}%;
39
- display: flex;
40
- flex-direction: column;
41
- transition: all 0.5s ease;
42
- overflow: hidden;
43
- z-index: 10000;
44
- animation: ${({displayChat:e})=>e?a:i} 0.3s ease-in-out forwards;
45
- `,s=r.default.div`
46
- position: absolute;
47
- top: 5;
48
- margin-left: 5px;
49
- margin-top: 5px;
50
- height: 30px;
51
- border: 1px solid rgb(78, 161, 211, 0.3);
52
- width: 96%;
53
-
54
- font-weight: 600;
55
- font-size: 14px;
56
- color: rgb(78, 161, 211);
57
- padding: 5px;
58
- `,c=r.default.div`
59
- display: flex;
60
- flex-direction: column;
61
- align-items: flex-start;
62
- width: 100%;
63
- font-weight: 600;
64
- font-size: 12px;
65
- color: rgb(78, 161, 211);
66
- `,l=r.default.div`
67
- position: absolute;
68
- top: 0;
69
- right: 0;
70
- padding-top: 5px;
71
- width: 30px;
72
- font-size: calc(10px + 1vmin);
73
- color: white;
74
-
75
- :hover {
76
- cursor: pointer;
77
- }
78
- `,u=r.default.div`
79
- position: absolute;
80
- text-align: center;
81
- align-items: center;
82
- top: 38px;
83
- margin-left: 5px;
84
- margin-top: 5px;
85
- border: 1px solid rgb(78, 161, 211, 0.3);
86
- border-radius: 15px;
87
- width: 96%;
88
-
89
- margin-left: 5px;
90
- margin-top: 2px;
91
- font-weight: 600;
92
- font-size: 14px;
93
- color: white;
94
- padding: 5px;
95
- background-color: rgb(78, 161, 211);
96
- `,d=r.default.div`
97
- position: absolute;
98
- text-align: center;
99
- align-items: center;
100
- display: flex;
101
- gap: 5px;
102
- border: 1px solid rgb(78, 161, 211, 0.3);
103
- border-radius: 15px;
104
- width: 100%;
105
-
106
- margin-left: 10px;
107
- margin-top: 2px;
108
- font-weight: 600;
109
- font-size: 14px;
110
- color: white;
111
- padding: 10px;
112
- background-color: rgb(78, 161, 211);
113
- `,te=r.default.div`
114
- position: absolute;
115
- top: 80px;
116
- margin-left: 5px;
117
- margin-top: 5px;
118
- width: 100%;
119
- height: 65%;
120
- max-height: 83%;
121
- overflow-x: hidden;
122
- overflow-y: auto;
123
- `,ne=r.default.div`
124
- display: flex;
125
- width: 100%;
126
- flex-direction: column;
127
- padding: 15px;
128
- color: #454552;
129
- `,f=r.default.div`
130
- width: 100%;
131
- display: flex;
132
- flex-direction: column;
133
- align-items: flex-start;
134
- font-size: 12px;
135
- margin-top: 5px;
136
- margin-left: 5px;
137
- text-align: left;
138
-
139
- > strong {
140
- margin-left: 3px;
141
- color: rgb(78, 161, 211)
142
- }
143
-
144
- > p {
145
- max-width: 95%;
146
- width: auto;
147
- padding: 5px;
148
- margin-top: 5px;
149
- border: 1px solid rgb(78, 161, 211, 0.3);
150
- border-radius: 15px;
151
- color: black;
152
- font-size: 12px;
153
- text-align: left;
154
- }
155
- `,p=r.default.div`
156
- width: 100%;
157
- display: flex;
158
- flex-direction: column;
159
- align-items: flex-start;
160
- font-size: 12px;
161
- margin-top: 5px;
162
- margin-left: 5px;
163
- text-align: left;
164
-
165
- > strong {
166
- margin-right: 35px;
167
- color: rgb(215, 61, 71)
168
- }
169
-
170
- > p {
171
- max-width: 95%;
172
- width: auto;
173
- padding: 5px;
174
- margin-top: 5px;
175
- border: 1px solid rgb(78, 161, 211, 0.3);
176
- border-radius: 15px;
177
- color: black;
178
- font-size: 12px;
179
- text-align: left;
180
- background-color: #f5f5f5;
181
- }
182
- `,m=r.default.div`
183
- position: absolute;
184
- display: flex;
185
- bottom: 10px;
186
- margin-left: 5px;
187
- margin-top: 5px;
188
- flex-direction: row;
189
- align-items: center;
190
- width: 100%;
191
- gap: 5px;
192
- `,h=r.default.input`
193
- bottom: 0;
194
- width: 70%;
195
- height: 25px;
196
- margin-left: 5px;
197
- border: 2px solid rgb(69, 69, 82, 0.25);
198
- box-sizing: border-box;
199
- font-size: 14px;
200
- padding-left: 5px;
201
- opacity: 0.7;
202
-
203
- :focus {
204
- outline: none;
205
- }
206
- `,g=r.default.div`
207
- height: 25px;
208
- outline: none;
209
- border: none;
210
- display: flex;
211
- align-items: center;
212
- justify-content: flex-end;
213
- border-radius: 10px;
214
- padding-left: 5px;
215
- padding-right: 10px;
216
- margin-right: 10px;
217
- color: black;
218
- background-color: #bed0f8;
219
- font-size: 1rem;
220
- font-weight: 500;
221
- cursor: pointer;
222
- `,_=r.default.div`
223
- position: absolute;
224
- top: 80px;
225
- margin-left: 25px;
226
- width: 100%;
227
- height: 65%;
228
- width: 83%;
229
- margin-bottom: 25px;
230
- `,v=r.default.i`
231
- width: 25px;
232
- font-size: calc(5px + 1vmin);
233
- `;var y,b,x;const S=`optimizetalk.com:8443`,C=({meetingLinkKey:e,customerSupportKey:r})=>{let i=(0,n.useRef)(null),[a]=(0,n.useState)(window.innerWidth<window.innerHeight&&window.innerWidth<=900),[C]=(0,n.useState)(a?80:20),[w,T]=(0,n.useState)([]),E=(0,n.useRef)(),[D,O]=(0,n.useState)(!0),[k,A]=(0,n.useState)(!1),[j,M]=(0,n.useState)(!1),[N,P]=(0,n.useState)(null),[F,I]=(0,n.useState)(null),[L,R]=(0,n.useState)(),[z,B]=(0,n.useState)(),[V,H]=(0,n.useState)(!1),[U,W]=(0,n.useState)(``),G=(0,n.useRef)(null),K=(0,n.useRef)(null),q=()=>{let e=1e4,t=Math.floor(Math.random()*(9e4-e+1))+e;return console.log(`Random number: `+t),t},J=(e,t)=>{y=new WebSocket(`wss://`+S+`/signal`),y.onopen=function(){console.log(`Websocket connection established`),oe(),re(e,t),$({from:{userName:e,audio:!0,video:!0},type:`text`,data:`ping from `+e}),b=setInterval(()=>{$({from:{userName:e,audio:!0,video:!0},type:`text`,data:`ping from `+e})},45e3),Z(e,t),console.log(`WebSocket connection opened to chat room `+U)}},Y=(e,t)=>{M(!0),P(t),console.log(`Params guestName:`+e+`, guestEmail:`+t);var n=F?e:`Guest-`+q()+`: `+e;I(n),console.log(`Joining : `+n),J(n,t)};function X(){console.log(`Close the socket`),y!=null&&(console.log(`Send 'leave' message to server for session `+L+` accessToken: `+z),$({from:{userName:F,sessionKey:L,audio:!0,video:!0},accessToken:z,type:`leave`,data:e}),y.close())}function re(e,t){y.onmessage=function(n){let r=JSON.parse(n.data);switch(console.log(`Room received type: `+r.type),r.type){case`text`:console.log(`Text message from `+r.from.userName+` received: `+r.data);break;case`join_meeting`:console.log(`Main message `+r.data),r.data&&r.data===`busy`?(console.log(`Customer support is busy`),H(!0),x||ie(e,t)):r.data&&r.data===`valid`&&(clearInterval(x),console.log(`Session key `+r.referenceUsers[0].sessionKey),R(r.referenceUsers[0].sessionKey),console.log(`Session accessToken `+r.accessToken),B(r.accessToken),console.log(`Joined to room `+r.roomDetails.roomName),W(r.roomDetails.roomName));break;case`message`:console.log(`Chat message received from `+r.from.userName),console.log(`Chat message `+r.data),ae(),T(e=>[...e,{sender:r.from.userName,msg:r.data}]),Q();break;case`session_expired`:console.log(`Chat session expired!`),M(!1),R(null),B(null),H(!1),X();break;default:console.log(`Room ignoring message type `+r.type)}}}let ie=(e,t)=>{x=setInterval(()=>{console.log(`Trying to connect customer support team ...`),Z(e,t)},1e4)},Z=(t,n)=>{$({from:{userName:t,email:n,audio:!1,video:!1},type:`join_meeting`,roomDetails:{roomLinkKey:e},data:r}),console.log(`Meeting join request sent for guest `+t)},ae=()=>{K.current.play()};function oe(){y.addEventListener(`close`,e=>{console.log(`websocket connection closed: `,e),clearInterval(b)}),y.onerror=function(e){console.log(`Error: `+e)}}let Q=()=>{i.current?.scrollIntoView({behavior:`smooth`})},se=e=>{if(e.key===`Enter`){let t=e.target.value;t&&(console.log(`Send 'message' message to server for session `+L+` accessToken: `+z),$({from:{userName:F,sessionKey:L,audio:!0,video:!0},accessToken:z,type:`message`,data:t}),console.log(`Chat message sent `+t),T(e=>[...e,{sender:F,msg:t}]),E.current.value=``)}},ce=()=>{let e=E.current.value;e&&(console.log(`Send 'message' message to server for session `+L+` accessToken: `+z),$({from:{userName:F,sessionKey:L,audio:!0,video:!0},accessToken:z,type:`message`,data:e}),console.log(`Chat message sent `+e),T(t=>[...t,{sender:F,msg:e}]),E.current.value=``,Q())};function $(e){let t=JSON.stringify(e);y.send(t)}function le(){X(),O(!1),A(!0),R(null),B(null),H(!1)}function ue(){y=new WebSocket(`wss://`+S+`/signal`),R(null),B(null),O(!0),A(!1),M(!1),H(!1),P(null),I(null),T([])}return(0,n.useEffect)(()=>{Q()},[w,L]),n.default.createElement(`div`,null,!k&&n.default.createElement(o,{displayChat:D,maxWidth:C},n.default.createElement(s,null,n.default.createElement(c,null,`OD Customer Support`),n.default.createElement(l,{onClick:()=>le(),className:`text-gray-700`},n.default.createElement(`svg`,{width:`60%`,height:`60%`,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`},n.default.createElement(`path`,{d:`M18 6L6 18M6 6L18 18`,stroke:`orange`,"stroke-width":`4`,"stroke-linecap":`round`,"stroke-linejoin":`round`})))),!j&&!L&&!V&&n.default.createElement(t.default,{startGuestChat:Y,guestEmail:N}),j&&!L&&!V&&n.default.createElement(n.default.Fragment,null,n.default.createElement(_,null,n.default.createElement(`div`,{className:`text-center mt-5`},`Please wait, connecting`),n.default.createElement(`div`,{className:`flex flex-col items-center `},n.default.createElement(`div`,null,n.default.createElement(`img`,{className:`mt-5`,src:`/connecting_customer_support.gif`,width:`80`})),n.default.createElement(`div`,{className:`absolute text-center bottom-6 font-sx text-sky-400`},`contact us at`),n.default.createElement(`div`,{className:`absolute text-center bottom-0 font-sx text-sky-400`},`support@origindetector.com.`)))),j&&!L&&V&&n.default.createElement(n.default.Fragment,null,n.default.createElement(_,null,n.default.createElement(`div`,{className:`text-center`},`Our customer support team helping other customers, please wait.`),n.default.createElement(`div`,{className:`text-center mt-5`},`connecting`),n.default.createElement(`div`,{className:`flex flex-col items-center `},n.default.createElement(`div`,null,n.default.createElement(`img`,{className:`mt-5`,src:`/connecting_customer_support.gif`,width:`80`})),n.default.createElement(`div`,{className:`absolute text-center bottom-6 font-sx text-sky-400`},`contact us at`),n.default.createElement(`div`,{className:`absolute text-center bottom-0 font-sx text-sky-400`},`support@origindetector.com.`)))),j&&L&&n.default.createElement(`div`,null,n.default.createElement(u,null,`Live Chat`),n.default.createElement(te,null,n.default.createElement(ne,null,w&&w.length==0&&n.default.createElement(`div`,{className:`ml-2`},` You are connected to our customer support team, how can we help you today? `),w&&w.length>0&&n.default.createElement(`div`,null,w&&w.map(({sender:e,msg:t},r)=>e===F?n.default.createElement(p,{key:r},n.default.createElement(`strong`,null,F),n.default.createElement(`p`,null,t)):n.default.createElement(f,{key:r},n.default.createElement(`strong`,null,e),n.default.createElement(`p`,null,t))),n.default.createElement(`div`,{style:{float:`left`,clear:`both`},ref:i})))),n.default.createElement(m,null,n.default.createElement(h,{ref:E,onKeyUp:se,placeholder:`Enter your message`}),n.default.createElement(g,{onClick:ce},n.default.createElement(v,{className:`fas fa-paper-plane`}),`Send`))),n.default.createElement(`audio`,{ref:G,src:`../../alert-sound.mp3`}),n.default.createElement(`audio`,{ref:K,src:`../../ding-small.mp3`})),k&&n.default.createElement(ee,{className:`cursor-pointer`,onClick:()=>ue(),displayChat:D,maxWidth:C},n.default.createElement(d,null,n.default.createElement(`i`,{className:`bx bx-chat`}))))};exports.default=C;
@@ -1,10 +0,0 @@
1
- import { FC } from "react";
2
-
3
- //#region src/components/chat/chatMobile.d.ts
4
- interface ChatMobileProps {
5
- meetingLinkKey: string;
6
- customerSupportKey: string;
7
- }
8
- declare const ChatMobile: FC<ChatMobileProps>;
9
- //#endregion
10
- export { ChatMobile };
@@ -1,27 +0,0 @@
1
- const e=require(`../../_virtual/_rolldown/runtime.cjs`);let t=require(`react`),n=require(`styled-components`);n=e.__toESM(n);let r=require(`react-hook-form`),i=require(`tailwind-merge`),a=require(`zod`),o=require(`@hookform/resolvers/zod`);const s=n.default.div`
2
- position: relative;
3
- text-align: center;
4
- align-items: center;
5
- top: 5px;
6
- margin-left: 5px;
7
- margin-top: 2px;
8
- margin-bottom: 30px;
9
- border: 1px solid rgb(78, 161, 211, 0.3);
10
- border-radius: 15px;
11
- width: 92%;
12
- font-weight: 600;
13
- font-size: 14px;
14
- color: white;
15
- padding: 5px;
16
- background-color: rgb(78, 161, 211);
17
- `,c=n.default.div`
18
- position: absolute;
19
- top: 40px;
20
- margin-left: 5px;
21
- margin-top: 5px;
22
- width: 100%;
23
- height: 100%;
24
- max-height: 100%;
25
- overflow-x: hidden;
26
- overflow-y: auto;
27
- `,l=(0,a.object)({name:(0,a.string)().min(1,`Name is required`),email:(0,a.string)().min(1,`Email is required`).email(`Invalid email address`)}),u=({startGuestChat:e,guestEmail:n})=>{let[a,u]=(0,t.useState)(),d=(0,r.useForm)({resolver:(0,o.zodResolver)(l)}),{handleSubmit:f,formState:{errors:p}}=d;return React.createElement(c,null,React.createElement(s,null,`Live Chat`),!!n&&React.createElement(`div`,{className:`flex items-center justify-center gap-5 `},React.createElement(`button`,{onClick:()=>e(n),className:`inline-block rounded bg-green-700 px-6 pb-2 pt-2.5 text-xs font-medium leading-normal text-white shadow-[0_4px_9px_-4px_#3b71ca] transition duration-150 ease-in-out hover:bg-primary-600 hover:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.3),0_4px_18px_0_rgba(59,113,202,0.2)] focus:bg-primary-600 focus:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.3),0_4px_18px_0_rgba(59,113,202,0.2)] focus:outline-none focus:ring-0 active:bg-primary-700 active:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.3),0_4px_18px_0_rgba(59,113,202,0.2)] dark:shadow-[0_4px_9px_-4px_rgba(59,113,202,0.5)] dark:hover:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.2),0_4px_18px_0_rgba(59,113,202,0.1)] dark:focus:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.2),0_4px_18px_0_rgba(59,113,202,0.1)] dark:active:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.2),0_4px_18px_0_rgba(59,113,202,0.1)]`},`Start Chat`)),!n&&React.createElement(`form`,{className:`w-full`,onSubmit:f(async t=>{console.log(`Guest: `+t.name),console.log(`Guest Email: `+t.email),e(t.name,t.email)})},React.createElement(`div`,{className:`flex flex-col items-left`},React.createElement(`div`,{className:`max-w-1xl bg-white`},React.createElement(`div`,{className:`relative border-slate-300 flex flex-col items-center`},React.createElement(`div`,null,React.createElement(`label`,{className:`block text-gray-700 text-sm mb-1`,htmlFor:`title`},`Name`),React.createElement(`input`,{className:(0,i.twMerge)(`appearance-none border border-gray-400 rounded w-40 px-1 py-1 text-sm text-gray-700 mb-1 leading-tight focus:outline-none`,`${p.name&&`border-red-500`}`),...d.register(`name`)}),React.createElement(`p`,{className:(0,i.twMerge)(`text-red-500 text-xs italic mb-2 invisible`,`${p.name&&`visible`}`)},p.name?.message)),React.createElement(`div`,null,React.createElement(`label`,{className:`block text-gray-700 text-sm mb-1`,htmlFor:`title`},`Email`),React.createElement(`input`,{type:`email`,className:(0,i.twMerge)(`appearance-none border border-gray-400 rounded w-40 px-1 py-1 text-sm text-gray-700 mb-2 leading-tight focus:outline-none`,`${p.email&&`border-red-500`}`),...d.register(`email`)}),React.createElement(`p`,{className:(0,i.twMerge)(`text-red-500 text-xs italic mb-2 invisible`,`${p.email&&`visible`}`)},p.email?.message))))),React.createElement(`div`,{className:`mb-2 text-gray-600 `},React.createElement(`h2`,{className:`text-sm text-red-600 font-normal`},a)),React.createElement(`div`,{className:`flex items-center justify-center gap-5 `},React.createElement(`button`,{className:`inline-block rounded bg-green-700 px-6 pb-2 pt-2.5 text-xs font-medium leading-normal text-white shadow-[0_4px_9px_-4px_#3b71ca] transition duration-150 ease-in-out hover:bg-primary-600 hover:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.3),0_4px_18px_0_rgba(59,113,202,0.2)] focus:bg-primary-600 focus:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.3),0_4px_18px_0_rgba(59,113,202,0.2)] focus:outline-none focus:ring-0 active:bg-primary-700 active:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.3),0_4px_18px_0_rgba(59,113,202,0.2)] dark:shadow-[0_4px_9px_-4px_rgba(59,113,202,0.5)] dark:hover:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.2),0_4px_18px_0_rgba(59,113,202,0.1)] dark:focus:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.2),0_4px_18px_0_rgba(59,113,202,0.1)] dark:active:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.2),0_4px_18px_0_rgba(59,113,202,0.1)]`},`Start Chat`))))};exports.default=u;
@@ -1,27 +0,0 @@
1
- const e=require(`../../_virtual/_rolldown/runtime.cjs`);let t=require(`react`),n=require(`styled-components`);n=e.__toESM(n);let r=require(`react-hook-form`),i=require(`tailwind-merge`),a=require(`zod`),o=require(`@hookform/resolvers/zod`);const s=n.default.div`
2
- position: relative;
3
- text-align: center;
4
- align-items: center;
5
- top: 5px;
6
- margin-left: 5px;
7
- margin-top: 2px;
8
- margin-bottom: 10px;
9
- border: 1px solid rgb(78, 161, 211, 0.3);
10
- border-radius: 15px;
11
- width: 92%;
12
- font-weight: 600;
13
- font-size: 14px;
14
- color: white;
15
- padding: 5px;
16
- background-color: rgb(78, 161, 211);
17
- `,c=n.default.div`
18
- position: absolute;
19
- top: 40px;
20
- margin-left: 5px;
21
- margin-top: 5px;
22
- width: 100%;
23
- height: 80%;
24
- font-size: 14px;
25
- overflow-x: hidden;
26
- overflow-y: auto;
27
- `,l=(0,a.object)({name:(0,a.string)().min(1,`Name is required`),email:(0,a.string)().min(1,`Email is required`).email(`Invalid email address`)}),u=({startGuestChat:e,guestEmail:n})=>{let[a,u]=(0,t.useState)(),d=(0,r.useForm)({resolver:(0,o.zodResolver)(l)}),{handleSubmit:f,formState:{errors:p}}=d;return React.createElement(c,null,React.createElement(s,null,`Live Chat`),!!n&&React.createElement(`div`,{className:`flex items-center justify-center gap-5 `},React.createElement(`button`,{onClick:()=>e(n),className:`inline-block rounded bg-green-700 px-6 pb-2 pt-2.5 text-xs font-medium leading-normal text-white shadow-[0_4px_9px_-4px_#3b71ca] transition duration-150 ease-in-out hover:bg-primary-600 hover:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.3),0_4px_18px_0_rgba(59,113,202,0.2)] focus:bg-primary-600 focus:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.3),0_4px_18px_0_rgba(59,113,202,0.2)] focus:outline-none focus:ring-0 active:bg-primary-700 active:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.3),0_4px_18px_0_rgba(59,113,202,0.2)] dark:shadow-[0_4px_9px_-4px_rgba(59,113,202,0.5)] dark:hover:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.2),0_4px_18px_0_rgba(59,113,202,0.1)] dark:focus:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.2),0_4px_18px_0_rgba(59,113,202,0.1)] dark:active:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.2),0_4px_18px_0_rgba(59,113,202,0.1)]`},`Start Chat`)),!n&&React.createElement(`form`,{className:`w-full`,onSubmit:f(async t=>{console.log(`Guest: `+t.name),console.log(`Guest Email: `+t.email),e(t.name,t.email)})},React.createElement(`div`,{className:`flex flex-col items-left`},React.createElement(`div`,{className:`max-w-1xl bg-white`},React.createElement(`div`,{className:`relative border-slate-300 flex flex-col items-center`},React.createElement(`div`,null,React.createElement(`label`,{className:`block text-gray-700 text-normal mb-1`,htmlFor:`title`},`Name`),React.createElement(`input`,{className:(0,i.twMerge)(`appearance-none border border-gray-400 rounded w-full text-gray-700 mb-1 px-1 py-1 leading-tight focus:outline-none`,`${p.name&&`border-red-500`}`),...d.register(`name`)}),React.createElement(`p`,{className:(0,i.twMerge)(`text-red-500 text-xs italic invisible`,`${p.name&&`visible`}`)},p.name?.message)),React.createElement(`div`,null,React.createElement(`label`,{className:`block text-gray-700 text-normal mb-1`,htmlFor:`title`},`Email`),React.createElement(`input`,{type:`email`,className:(0,i.twMerge)(`appearance-none border border-gray-400 rounded w-full text-gray-700 mb-1 px-1 py-1 leading-tight focus:outline-none`,`${p.email&&`border-red-500`}`),...d.register(`email`)}),React.createElement(`p`,{className:(0,i.twMerge)(`text-red-500 text-xs italic mb-2 invisible`,`${p.email&&`visible`}`)},p.email?.message))))),React.createElement(`div`,{className:`mb-2 text-gray-600 `},React.createElement(`h2`,{className:`text-sm text-red-600 font-normal`},a)),React.createElement(`div`,{className:`flex items-center justify-center gap-5 `},React.createElement(`button`,{className:`inline-block rounded bg-green-700 px-6 pb-2 pt-2.5 text-xs font-medium leading-normal text-white shadow-[0_4px_9px_-4px_#3b71ca] transition duration-150 ease-in-out hover:bg-primary-600 hover:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.3),0_4px_18px_0_rgba(59,113,202,0.2)] focus:bg-primary-600 focus:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.3),0_4px_18px_0_rgba(59,113,202,0.2)] focus:outline-none focus:ring-0 active:bg-primary-700 active:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.3),0_4px_18px_0_rgba(59,113,202,0.2)] dark:shadow-[0_4px_9px_-4px_rgba(59,113,202,0.5)] dark:hover:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.2),0_4px_18px_0_rgba(59,113,202,0.1)] dark:focus:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.2),0_4px_18px_0_rgba(59,113,202,0.1)] dark:active:shadow-[0_8px_9px_-4px_rgba(59,113,202,0.2),0_4px_18px_0_rgba(59,113,202,0.1)]`},`Start Chat`))))};exports.default=u;
package/dist/index.cjs DELETED
@@ -1 +0,0 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./components/chat/chatMobile.cjs`),t=require(`./components/chat/chat.cjs`);exports.Chat=t,exports.ChatMobile=e;
package/dist/index.d.cts DELETED
@@ -1,3 +0,0 @@
1
- import { ChatMobile } from "./components/chat/chatMobile.cjs";
2
- import { Chat } from "./components/chat/chat.cjs";
3
- export { Chat, ChatMobile };