od-support-chat 1.0.28 → 1.0.30

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.
@@ -1,4 +1,4 @@
1
- import{__toESM as e}from"../../_virtual/_rolldown/runtime.mjs";import{require_alert_sound as t}from"../../asset/alert-sound.mjs";import{require_ding_small as n}from"../../asset/ding-small.mjs";import r from"./info.guest.mjs";import{useEffect as i,useRef as a,useState as o}from"react";import s,{keyframes as c}from"styled-components";import{Fragment as l,jsx as u,jsxs as d}from"react/jsx-runtime";var f=e(t()),ee=e(n());const p=c`
1
+ import e from"./info.guest.mjs";import{useEffect as t,useRef as n,useState as r}from"react";import i,{keyframes as a}from"styled-components";import{Fragment as o,jsx as s,jsxs as c}from"react/jsx-runtime";const l=a`
2
2
  from {
3
3
  opacity: 0;
4
4
  transform: translateY(20px);
@@ -7,7 +7,7 @@ import{__toESM as e}from"../../_virtual/_rolldown/runtime.mjs";import{require_al
7
7
  opacity: 1;
8
8
  transform: translateY(0);
9
9
  }
10
- `,m=c`
10
+ `,u=a`
11
11
  from {
12
12
  opacity: 1;
13
13
  transform: translateY(0);
@@ -16,7 +16,7 @@ import{__toESM as e}from"../../_virtual/_rolldown/runtime.mjs";import{require_al
16
16
  opacity: 0;
17
17
  transform: translateY(20px);
18
18
  }
19
- `,h=s.div`
19
+ `,d=i.div`
20
20
  position: fixed;
21
21
  right: 0;
22
22
  top: 50%;
@@ -29,8 +29,8 @@ import{__toESM as e}from"../../_virtual/_rolldown/runtime.mjs";import{require_al
29
29
  transition: all 0.5s ease;
30
30
  overflow: hidden;
31
31
  z-index: 10000;
32
- animation: ${({displayChat:e})=>e?p:m} 0.3s ease-in-out forwards;
33
- `,g=s.div`
32
+ animation: ${({displayChat:e})=>e?l:u} 0.3s ease-in-out forwards;
33
+ `,f=i.div`
34
34
  position: fixed;
35
35
  right: 0;
36
36
  bottom: 10%;
@@ -41,8 +41,8 @@ import{__toESM as e}from"../../_virtual/_rolldown/runtime.mjs";import{require_al
41
41
  transition: all 0.5s ease;
42
42
  overflow: hidden;
43
43
  z-index: 10000;
44
- animation: ${({displayChat:e})=>e?m:p} 0.3s ease-in-out forwards;
45
- `,_=s.div`
44
+ animation: ${({displayChat:e})=>e?u:l} 0.3s ease-in-out forwards;
45
+ `,ee=i.div`
46
46
  position: absolute;
47
47
  top: 5;
48
48
  margin-left: 5px;
@@ -55,7 +55,7 @@ import{__toESM as e}from"../../_virtual/_rolldown/runtime.mjs";import{require_al
55
55
  font-size: 14px;
56
56
  color: rgb(78, 161, 211);
57
57
  padding: 5px;
58
- `,v=s.div`
58
+ `,te=i.div`
59
59
  display: flex;
60
60
  flex-direction: column;
61
61
  align-items: flex-start;
@@ -63,7 +63,7 @@ import{__toESM as e}from"../../_virtual/_rolldown/runtime.mjs";import{require_al
63
63
  font-weight: 600;
64
64
  font-size: 12px;
65
65
  color: rgb(78, 161, 211);
66
- `,y=s.div`
66
+ `,p=i.div`
67
67
  position: absolute;
68
68
  top: 0;
69
69
  right: 0;
@@ -75,7 +75,7 @@ import{__toESM as e}from"../../_virtual/_rolldown/runtime.mjs";import{require_al
75
75
  :hover {
76
76
  cursor: pointer;
77
77
  }
78
- `,te=s.div`
78
+ `,m=i.div`
79
79
  position: absolute;
80
80
  text-align: center;
81
81
  align-items: center;
@@ -93,7 +93,7 @@ import{__toESM as e}from"../../_virtual/_rolldown/runtime.mjs";import{require_al
93
93
  color: white;
94
94
  padding: 5px;
95
95
  background-color: rgb(78, 161, 211);
96
- `,b=s.div`
96
+ `,h=i.div`
97
97
  position: absolute;
98
98
  text-align: center;
99
99
  align-items: center;
@@ -110,7 +110,7 @@ import{__toESM as e}from"../../_virtual/_rolldown/runtime.mjs";import{require_al
110
110
  color: white;
111
111
  padding: 10px;
112
112
  background-color: rgb(78, 161, 211);
113
- `,x=s.div`
113
+ `,ne=i.div`
114
114
  position: absolute;
115
115
  top: 80px;
116
116
  margin-left: 5px;
@@ -120,13 +120,13 @@ import{__toESM as e}from"../../_virtual/_rolldown/runtime.mjs";import{require_al
120
120
  max-height: 83%;
121
121
  overflow-x: hidden;
122
122
  overflow-y: auto;
123
- `,ne=s.div`
123
+ `,re=i.div`
124
124
  display: flex;
125
125
  width: 100%;
126
126
  flex-direction: column;
127
127
  padding: 15px;
128
128
  color: #454552;
129
- `,S=s.div`
129
+ `,ie=i.div`
130
130
  width: 100%;
131
131
  display: flex;
132
132
  flex-direction: column;
@@ -152,7 +152,7 @@ import{__toESM as e}from"../../_virtual/_rolldown/runtime.mjs";import{require_al
152
152
  font-size: 12px;
153
153
  text-align: left;
154
154
  }
155
- `,C=s.div`
155
+ `,g=i.div`
156
156
  width: 100%;
157
157
  display: flex;
158
158
  flex-direction: column;
@@ -179,7 +179,7 @@ import{__toESM as e}from"../../_virtual/_rolldown/runtime.mjs";import{require_al
179
179
  text-align: left;
180
180
  background-color: #f5f5f5;
181
181
  }
182
- `,w=s.div`
182
+ `,_=i.div`
183
183
  position: absolute;
184
184
  display: flex;
185
185
  bottom: 10px;
@@ -189,7 +189,7 @@ import{__toESM as e}from"../../_virtual/_rolldown/runtime.mjs";import{require_al
189
189
  align-items: center;
190
190
  width: 100%;
191
191
  gap: 5px;
192
- `,re=s.input`
192
+ `,v=i.input`
193
193
  bottom: 0;
194
194
  width: 70%;
195
195
  height: 25px;
@@ -203,7 +203,7 @@ import{__toESM as e}from"../../_virtual/_rolldown/runtime.mjs";import{require_al
203
203
  :focus {
204
204
  outline: none;
205
205
  }
206
- `,ie=s.div`
206
+ `,y=i.div`
207
207
  height: 25px;
208
208
  outline: none;
209
209
  border: none;
@@ -219,7 +219,7 @@ import{__toESM as e}from"../../_virtual/_rolldown/runtime.mjs";import{require_al
219
219
  font-size: 1rem;
220
220
  font-weight: 500;
221
221
  cursor: pointer;
222
- `,T=s.div`
222
+ `,b=i.div`
223
223
  position: absolute;
224
224
  top: 80px;
225
225
  margin-left: 25px;
@@ -227,7 +227,7 @@ import{__toESM as e}from"../../_virtual/_rolldown/runtime.mjs";import{require_al
227
227
  height: 65%;
228
228
  width: 83%;
229
229
  margin-bottom: 25px;
230
- `,E=s.i`
230
+ `,x=i.i`
231
231
  width: 25px;
232
232
  font-size: calc(5px + 1vmin);
233
- `;var D,O,k;const A=`optimizetalk.com:8443`,j=e=>{let t=a(null),[n]=o(window.innerWidth<window.innerHeight&&window.innerWidth<=900),[s]=o(n?100:15),[c,p]=o([]),m=a(),[j,M]=o(!0),[N,P]=o(!1),[F,I]=o(!1),[L,R]=o(null),[z,B]=o(null),[V,H]=o(),[U,W]=o(),[G,K]=o(!1),[q,J]=o(``),ae=a(null),Y=a(null),oe=()=>{let e=1e4,t=Math.floor(Math.random()*(9e4-e+1))+e;return console.log(`Random number: `+t),t},se=(e,t)=>{D=new WebSocket(`wss://`+A+`/signal`),D.onopen=function(){console.log(`Websocket connection established`),fe(),le(e,t),$({from:{userName:e,audio:!0,video:!0},type:`text`,data:`ping from `+e}),O=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 `+q)}},ce=(e,t)=>{I(!0),R(t),console.log(`Params guestName:`+e+`, guestEmail:`+t);var n=z?e:`Guest-`+oe()+`: `+e;B(n),console.log(`Joining : `+n),se(n,t)};function X(){console.log(`Close the socket`),D!=null&&(console.log(`Send 'leave' message to server for session `+V+` accessToken: `+U),$({from:{userName:z,sessionKey:V,audio:!0,video:!0},accessToken:U,type:`leave`,data:e.meetingLinkKey}),D.close())}function le(e,t){D.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`),K(!0),k||ue(e,t)):r.data&&r.data===`valid`&&(clearInterval(k),console.log(`Session key `+r.referenceUsers[0].sessionKey),H(r.referenceUsers[0].sessionKey),console.log(`Session accessToken `+r.accessToken),W(r.accessToken),console.log(`Joined to room `+r.roomDetails.roomName),J(r.roomDetails.roomName));break;case`message`:console.log(`Chat message received from `+r.from.userName),console.log(`Chat message `+r.data),de(),p(e=>[...e,{sender:r.from.userName,msg:r.data}]),Q();break;case`session_expired`:console.log(`Chat session expired!`),I(!1),H(null),W(null),K(!1),X();break;default:console.log(`Room ignoring message type `+r.type)}}}let ue=(e,t)=>{k=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.meetingLinkKey},data:e.customerSupportKey}),console.log(`Meeting join request sent for guest `+t+`, meetingLinkKey: `+e.meetingLinkKey+`, customerSupportKey: `+e.customerSupportKey)},de=()=>{Y.current.play()};function fe(){D.addEventListener(`close`,e=>{console.log(`websocket connection closed: `,e),clearInterval(O)}),D.onerror=function(e){console.log(`Error: `+e)}}let Q=()=>{t.current?.scrollIntoView({behavior:`smooth`})},pe=e=>{if(e.key===`Enter`){let t=e.target.value;t&&(console.log(`Send 'message' message to server for session `+V+` accessToken: `+U),$({from:{userName:z,sessionKey:V,audio:!0,video:!0},accessToken:U,type:`message`,data:t}),console.log(`Chat message sent `+t),p(e=>[...e,{sender:z,msg:t}]),m.current.value=``)}},me=()=>{let e=m.current.value;e&&(console.log(`Send 'message' message to server for session `+V+` accessToken: `+U),$({from:{userName:z,sessionKey:V,audio:!0,video:!0},accessToken:U,type:`message`,data:e}),console.log(`Chat message sent `+e),p(t=>[...t,{sender:z,msg:e}]),m.current.value=``,Q())};function $(e){let t=JSON.stringify(e);D.send(t)}function he(){X(),M(!1),P(!0),H(null),W(null),K(!1)}function ge(){D=new WebSocket(`wss://`+A+`/signal`),H(null),W(null),M(!0),P(!1),I(!1),K(!1),R(null),B(null),p([])}return i(()=>{Q()},[c,V]),d(`div`,{children:[!N&&d(h,{displayChat:j,maxWidth:s,children:[d(_,{children:[u(v,{children:e.title}),u(y,{onClick:()=>he(),className:`text-gray-700`,children:u(`svg`,{width:`60%`,height:`60%`,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:u(`path`,{d:`M18 6L6 18M6 6L18 18`,stroke:`orange`,"stroke-width":`4`,"stroke-linecap":`round`,"stroke-linejoin":`round`})})})]}),!F&&!V&&!G&&u(r,{startGuestChat:ce,guestEmail:L}),F&&!V&&!G&&u(l,{children:d(T,{children:[u(`div`,{className:`text-center mt-5`,children:`Please wait, connecting`}),d(`div`,{className:`flex flex-col items-center `,children:[u(`div`,{children:u(`img`,{className:`mt-1`,src:`/connecting_customer_support.gif`,width:`80`})}),u(`div`,{className:`mt-5 text-center bottom-6 font-sm text-sky-400`,children:`contact us at`}),u(`div`,{className:`text-center bottom-0 font-sm text-sky-400`,children:e.supportEmail})]})]})}),F&&!V&&G&&u(l,{children:d(T,{children:[u(`div`,{className:`text-center text-sm`,children:`Our customer support team helping other customers, please wait.`}),u(`div`,{className:`text-center mt-5`,children:`connecting`}),d(`div`,{className:`flex flex-col items-center `,children:[u(`div`,{children:u(`img`,{className:`mt-1`,src:`/connecting_customer_support.gif`,width:`80`})}),u(`div`,{className:`mt-5 text-center bottom-6 font-sm text-sky-400`,children:`contact us at`}),u(`div`,{className:`text-center bottom-0 font-sm text-sky-400`,children:e.supportEmail})]})]})}),F&&V&&d(`div`,{children:[u(te,{children:`Live Chat`}),u(x,{children:d(ne,{children:[c&&c.length==0&&d(`div`,{className:`ml-2 text-sm`,children:[` You are connected to our customer support team, `,e.welcomeMessage,` `]}),c&&c.length>0&&d(`div`,{children:[c&&c.map(({sender:e,msg:t},n)=>e===z?d(C,{children:[u(`strong`,{children:z}),u(`p`,{children:t})]},n):d(S,{children:[u(`strong`,{children:e}),u(`p`,{children:t})]},n)),u(`div`,{style:{float:`left`,clear:`both`},ref:t})]})]})}),d(w,{children:[u(re,{ref:m,onKeyUp:pe,placeholder:`Enter your message`}),d(ie,{onClick:me,children:[u(E,{className:`fas fa-paper-plane`}),`Send`]})]})]}),u(`audio`,{ref:ae,src:f.default}),u(`audio`,{ref:Y,src:ee.default})]}),N&&u(g,{className:`cursor-pointer`,onClick:()=>ge(),displayChat:j,maxWidth:s,children:d(b,{children:[u(`i`,{className:`bx bx-chat`}),`Live Chat`]})})]})};export{j as default};
233
+ `,S=`/connecting_customer_support.gif`;var C,w,T;const E=`optimizetalk.com:8443`,D=i=>{let a=n(null),[l]=r(window.innerWidth<window.innerHeight&&window.innerWidth<=900),[u]=r(l?100:15),[D,O]=r([]),k=n(),[A,j]=r(!0),[M,N]=r(!1),[P,F]=r(!1),[ae,I]=r(null),[L,R]=r(null),[z,B]=r(),[V,H]=r(),[U,W]=r(!1),[G,K]=r(``),q=n(null),J=n(null),oe=()=>{let e=1e4,t=Math.floor(Math.random()*(9e4-e+1))+e;return console.log(`Random number: `+t),t},se=(e,t)=>{C=new WebSocket(`wss://`+E+`/signal`),C.onopen=function(){console.log(`Websocket connection established`),Z(),le(e,t),$({from:{userName:e,audio:!0,video:!0},type:`text`,data:`ping from `+e}),w=setInterval(()=>{$({from:{userName:e,audio:!0,video:!0},type:`text`,data:`ping from `+e})},45e3),X(e,t),console.log(`WebSocket connection opened to chat room `+G)}},ce=(e,t)=>{F(!0),I(t),console.log(`Params guestName:`+e+`, guestEmail:`+t);var n=L?e:`Guest-`+oe()+`: `+e;R(n),console.log(`Joining : `+n),se(n,t)};function Y(){console.log(`Close the socket`),C!=null&&(console.log(`Send 'leave' message to server for session `+z+` accessToken: `+V),$({from:{userName:L,sessionKey:z,audio:!0,video:!0},accessToken:V,type:`leave`,data:i.meetingLinkKey}),C.close())}function le(e,t){C.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`),W(!0),T||ue(e,t)):r.data&&r.data===`valid`&&(clearInterval(T),console.log(`Session key `+r.referenceUsers[0].sessionKey),B(r.referenceUsers[0].sessionKey),console.log(`Session accessToken `+r.accessToken),H(r.accessToken),console.log(`Joined to room `+r.roomDetails.roomName),K(r.roomDetails.roomName));break;case`message`:console.log(`Chat message received from `+r.from.userName),console.log(`Chat message `+r.data),de(),O(e=>[...e,{sender:r.from.userName,msg:r.data}]),Q();break;case`session_expired`:console.log(`Chat session expired!`),F(!1),B(null),H(null),W(!1),Y();break;default:console.log(`Room ignoring message type `+r.type)}}}let ue=(e,t)=>{T=setInterval(()=>{console.log(`Trying to connect customer support team ...`),X(e,t)},1e4)},X=(e,t)=>{$({from:{userName:e,email:t,audio:!1,video:!1},type:`join_meeting`,roomDetails:{roomLinkKey:i.meetingLinkKey},data:i.customerSupportKey}),console.log(`Meeting join request sent for guest `+e+`, meetingLinkKey: `+i.meetingLinkKey+`, customerSupportKey: `+i.customerSupportKey)},de=()=>{J.current.play()};function Z(){C.addEventListener(`close`,e=>{console.log(`websocket connection closed: `,e),clearInterval(w)}),C.onerror=function(e){console.log(`Error: `+e)}}let Q=()=>{a.current?.scrollIntoView({behavior:`smooth`})},fe=e=>{if(e.key===`Enter`){let t=e.target.value;t&&(console.log(`Send 'message' message to server for session `+z+` accessToken: `+V),$({from:{userName:L,sessionKey:z,audio:!0,video:!0},accessToken:V,type:`message`,data:t}),console.log(`Chat message sent `+t),O(e=>[...e,{sender:L,msg:t}]),k.current.value=``)}},pe=()=>{let e=k.current.value;e&&(console.log(`Send 'message' message to server for session `+z+` accessToken: `+V),$({from:{userName:L,sessionKey:z,audio:!0,video:!0},accessToken:V,type:`message`,data:e}),console.log(`Chat message sent `+e),O(t=>[...t,{sender:L,msg:e}]),k.current.value=``,Q())};function $(e){let t=JSON.stringify(e);C.send(t)}function me(){Y(),j(!1),N(!0),B(null),H(null),W(!1)}function he(){C=new WebSocket(`wss://`+E+`/signal`),B(null),H(null),j(!0),N(!1),F(!1),W(!1),I(null),R(null),O([])}return t(()=>{Q()},[D,z]),c(`div`,{children:[!M&&c(d,{displayChat:A,maxWidth:u,children:[c(ee,{children:[s(te,{children:i.title}),s(p,{onClick:()=>me(),className:`text-gray-700`,children:s(`svg`,{width:`60%`,height:`60%`,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:s(`path`,{d:`M18 6L6 18M6 6L18 18`,stroke:`orange`,"stroke-width":`4`,"stroke-linecap":`round`,"stroke-linejoin":`round`})})})]}),!P&&!z&&!U&&s(e,{startGuestChat:ce,guestEmail:ae}),P&&!z&&!U&&s(o,{children:c(b,{children:[s(`div`,{className:`text-center mt-5`,children:`Please wait, connecting`}),c(`div`,{className:`flex flex-col items-center `,children:[s(`div`,{children:s(`img`,{className:`mt-1`,src:S,width:`80`})}),s(`div`,{className:`mt-5 text-center bottom-6 font-sm text-sky-400`,children:`contact us at`}),s(`div`,{className:`text-center bottom-0 font-sm text-sky-400`,children:i.supportEmail})]})]})}),P&&!z&&U&&s(o,{children:c(b,{children:[s(`div`,{className:`text-center text-sm`,children:`Our customer support team helping other customers, please wait.`}),s(`div`,{className:`text-center mt-5`,children:`connecting`}),c(`div`,{className:`flex flex-col items-center `,children:[s(`div`,{children:s(`img`,{className:`mt-1`,src:S,width:`80`})}),s(`div`,{className:`mt-5 text-center bottom-6 font-sm text-sky-400`,children:`contact us at`}),s(`div`,{className:`text-center bottom-0 font-sm text-sky-400`,children:i.supportEmail})]})]})}),P&&z&&c(`div`,{children:[s(m,{children:`Live Chat`}),s(ne,{children:c(re,{children:[D&&D.length==0&&c(`div`,{className:`ml-2 text-sm`,children:[` You are connected to our customer support team, `,i.welcomeMessage,` `]}),D&&D.length>0&&c(`div`,{children:[D&&D.map(({sender:e,msg:t},n)=>e===L?c(g,{children:[s(`strong`,{children:L}),s(`p`,{children:t})]},n):c(ie,{children:[s(`strong`,{children:e}),s(`p`,{children:t})]},n)),s(`div`,{style:{float:`left`,clear:`both`},ref:a})]})]})}),c(_,{children:[s(v,{ref:k,onKeyUp:fe,placeholder:`Enter your message`}),c(y,{onClick:pe,children:[s(x,{className:`fas fa-paper-plane`}),`Send`]})]})]}),s(`audio`,{ref:q,src:`/alert-sound.mp3`}),s(`audio`,{ref:J,src:`/ding-small.mp3`})]}),M&&s(f,{className:`cursor-pointer`,onClick:()=>he(),displayChat:A,maxWidth:u,children:c(h,{children:[s(`i`,{className:`bx bx-chat`}),`Live Chat`]})})]})};export{D as default};
@@ -1,4 +1,4 @@
1
- import{__toESM as e}from"../../_virtual/_rolldown/runtime.mjs";import t from"./info.guestMobile.mjs";import{require_alert_sound as n}from"../../asset/alert-sound.mjs";import{require_ding_small as r}from"../../asset/ding-small.mjs";import{useEffect as i,useRef as a,useState as o}from"react";import s,{keyframes as c}from"styled-components";import{Fragment as l,jsx as u,jsxs as d}from"react/jsx-runtime";var f=e(n()),ee=e(r());const p=c`
1
+ import e from"./info.guestMobile.mjs";import{useEffect as t,useRef as n,useState as r}from"react";import i,{keyframes as a}from"styled-components";import{Fragment as o,jsx as s,jsxs as c}from"react/jsx-runtime";const l=a`
2
2
  from {
3
3
  opacity: 0;
4
4
  transform: translateY(20px);
@@ -7,7 +7,7 @@ import{__toESM as e}from"../../_virtual/_rolldown/runtime.mjs";import t from"./i
7
7
  opacity: 1;
8
8
  transform: translateY(0);
9
9
  }
10
- `,m=c`
10
+ `,u=a`
11
11
  from {
12
12
  opacity: 1;
13
13
  transform: translateY(0);
@@ -16,7 +16,7 @@ import{__toESM as e}from"../../_virtual/_rolldown/runtime.mjs";import t from"./i
16
16
  opacity: 0;
17
17
  transform: translateY(20px);
18
18
  }
19
- `,h=s.div`
19
+ `,d=i.div`
20
20
  position: fixed;
21
21
  left: 10%;
22
22
  top: 50%;
@@ -29,8 +29,8 @@ import{__toESM as e}from"../../_virtual/_rolldown/runtime.mjs";import t from"./i
29
29
  transition: all 0.5s ease;
30
30
  overflow: hidden;
31
31
  z-index: 10000;
32
- animation: ${({displayChat:e})=>e?p:m} 0.3s ease-in-out forwards;
33
- `,g=s.div`
32
+ animation: ${({displayChat:e})=>e?l:u} 0.3s ease-in-out forwards;
33
+ `,f=i.div`
34
34
  position: fixed;
35
35
  right: 0;
36
36
  bottom: 2%;
@@ -41,8 +41,8 @@ import{__toESM as e}from"../../_virtual/_rolldown/runtime.mjs";import t from"./i
41
41
  transition: all 0.5s ease;
42
42
  overflow: hidden;
43
43
  z-index: 10000;
44
- animation: ${({displayChat:e})=>e?m:p} 0.3s ease-in-out forwards;
45
- `,_=s.div`
44
+ animation: ${({displayChat:e})=>e?u:l} 0.3s ease-in-out forwards;
45
+ `,ee=i.div`
46
46
  position: absolute;
47
47
  top: 5;
48
48
  margin-left: 5px;
@@ -55,7 +55,7 @@ import{__toESM as e}from"../../_virtual/_rolldown/runtime.mjs";import t from"./i
55
55
  font-size: 14px;
56
56
  color: rgb(78, 161, 211);
57
57
  padding: 5px;
58
- `,v=s.div`
58
+ `,te=i.div`
59
59
  display: flex;
60
60
  flex-direction: column;
61
61
  align-items: flex-start;
@@ -63,7 +63,7 @@ import{__toESM as e}from"../../_virtual/_rolldown/runtime.mjs";import t from"./i
63
63
  font-weight: 600;
64
64
  font-size: 12px;
65
65
  color: rgb(78, 161, 211);
66
- `,y=s.div`
66
+ `,p=i.div`
67
67
  position: absolute;
68
68
  top: 0;
69
69
  right: 0;
@@ -75,7 +75,7 @@ import{__toESM as e}from"../../_virtual/_rolldown/runtime.mjs";import t from"./i
75
75
  :hover {
76
76
  cursor: pointer;
77
77
  }
78
- `,te=s.div`
78
+ `,m=i.div`
79
79
  position: absolute;
80
80
  text-align: center;
81
81
  align-items: center;
@@ -93,7 +93,7 @@ import{__toESM as e}from"../../_virtual/_rolldown/runtime.mjs";import t from"./i
93
93
  color: white;
94
94
  padding: 5px;
95
95
  background-color: rgb(78, 161, 211);
96
- `,b=s.div`
96
+ `,h=i.div`
97
97
  position: absolute;
98
98
  text-align: center;
99
99
  align-items: center;
@@ -110,7 +110,7 @@ import{__toESM as e}from"../../_virtual/_rolldown/runtime.mjs";import t from"./i
110
110
  color: white;
111
111
  padding: 10px;
112
112
  background-color: rgb(78, 161, 211);
113
- `,x=s.div`
113
+ `,ne=i.div`
114
114
  position: absolute;
115
115
  top: 80px;
116
116
  margin-left: 5px;
@@ -120,13 +120,13 @@ import{__toESM as e}from"../../_virtual/_rolldown/runtime.mjs";import t from"./i
120
120
  max-height: 83%;
121
121
  overflow-x: hidden;
122
122
  overflow-y: auto;
123
- `,ne=s.div`
123
+ `,re=i.div`
124
124
  display: flex;
125
125
  width: 100%;
126
126
  flex-direction: column;
127
127
  padding: 15px;
128
128
  color: #454552;
129
- `,S=s.div`
129
+ `,ie=i.div`
130
130
  width: 100%;
131
131
  display: flex;
132
132
  flex-direction: column;
@@ -152,7 +152,7 @@ import{__toESM as e}from"../../_virtual/_rolldown/runtime.mjs";import t from"./i
152
152
  font-size: 12px;
153
153
  text-align: left;
154
154
  }
155
- `,C=s.div`
155
+ `,g=i.div`
156
156
  width: 100%;
157
157
  display: flex;
158
158
  flex-direction: column;
@@ -179,7 +179,7 @@ import{__toESM as e}from"../../_virtual/_rolldown/runtime.mjs";import t from"./i
179
179
  text-align: left;
180
180
  background-color: #f5f5f5;
181
181
  }
182
- `,w=s.div`
182
+ `,_=i.div`
183
183
  position: absolute;
184
184
  display: flex;
185
185
  bottom: 10px;
@@ -189,7 +189,7 @@ import{__toESM as e}from"../../_virtual/_rolldown/runtime.mjs";import t from"./i
189
189
  align-items: center;
190
190
  width: 100%;
191
191
  gap: 5px;
192
- `,re=s.input`
192
+ `,v=i.input`
193
193
  bottom: 0;
194
194
  width: 70%;
195
195
  height: 25px;
@@ -203,7 +203,7 @@ import{__toESM as e}from"../../_virtual/_rolldown/runtime.mjs";import t from"./i
203
203
  :focus {
204
204
  outline: none;
205
205
  }
206
- `,ie=s.div`
206
+ `,y=i.div`
207
207
  height: 25px;
208
208
  outline: none;
209
209
  border: none;
@@ -219,7 +219,7 @@ import{__toESM as e}from"../../_virtual/_rolldown/runtime.mjs";import t from"./i
219
219
  font-size: 1rem;
220
220
  font-weight: 500;
221
221
  cursor: pointer;
222
- `,T=s.div`
222
+ `,b=i.div`
223
223
  position: absolute;
224
224
  top: 80px;
225
225
  margin-left: 25px;
@@ -227,7 +227,7 @@ import{__toESM as e}from"../../_virtual/_rolldown/runtime.mjs";import t from"./i
227
227
  height: 65%;
228
228
  width: 83%;
229
229
  margin-bottom: 25px;
230
- `,E=s.i`
230
+ `,x=i.i`
231
231
  width: 25px;
232
232
  font-size: calc(5px + 1vmin);
233
- `;var D,O,k;const A=`optimizetalk.com:8443`,j=e=>{let n=a(null),[r]=o(window.innerWidth<window.innerHeight&&window.innerWidth<=900),[s]=o(r?80:20),[c,p]=o([]),m=a(),[j,M]=o(!0),[N,P]=o(!1),[F,I]=o(!1),[L,R]=o(null),[z,B]=o(null),[V,H]=o(),[U,W]=o(),[G,K]=o(!1),[q,J]=o(``),ae=a(null),Y=a(null),oe=()=>{let e=1e4,t=Math.floor(Math.random()*(9e4-e+1))+e;return console.log(`Random number: `+t),t},se=(e,t)=>{D=new WebSocket(`wss://`+A+`/signal`),D.onopen=function(){console.log(`Websocket connection established`),fe(),le(e,t),$({from:{userName:e,audio:!0,video:!0},type:`text`,data:`ping from `+e}),O=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 `+q)}},ce=(e,t)=>{I(!0),R(t),console.log(`Params guestName:`+e+`, guestEmail:`+t);var n=z?e:`Guest-`+oe()+`: `+e;B(n),console.log(`Joining : `+n),se(n,t)};function X(){console.log(`Close the socket`),D!=null&&(console.log(`Send 'leave' message to server for session `+V+` accessToken: `+U),$({from:{userName:z,sessionKey:V,audio:!0,video:!0},accessToken:U,type:`leave`,data:e.meetingLinkKey}),D.close())}function le(e,t){D.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`),K(!0),k||ue(e,t)):r.data&&r.data===`valid`&&(clearInterval(k),console.log(`Session key `+r.referenceUsers[0].sessionKey),H(r.referenceUsers[0].sessionKey),console.log(`Session accessToken `+r.accessToken),W(r.accessToken),console.log(`Joined to room `+r.roomDetails.roomName),J(r.roomDetails.roomName));break;case`message`:console.log(`Chat message received from `+r.from.userName),console.log(`Chat message `+r.data),de(),p(e=>[...e,{sender:r.from.userName,msg:r.data}]),Q();break;case`session_expired`:console.log(`Chat session expired!`),I(!1),H(null),W(null),K(!1),X();break;default:console.log(`Room ignoring message type `+r.type)}}}let ue=(e,t)=>{k=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.meetingLinkKey},data:e.customerSupportKey}),console.log(`Meeting join request sent for guest `+t+`, meetingLinkKey: `+e.meetingLinkKey+`, customerSupportKey: `+e.customerSupportKey)},de=()=>{Y.current.play()};function fe(){D.addEventListener(`close`,e=>{console.log(`websocket connection closed: `,e),clearInterval(O)}),D.onerror=function(e){console.log(`Error: `+e)}}let Q=()=>{n.current?.scrollIntoView({behavior:`smooth`})},pe=e=>{if(e.key===`Enter`){let t=e.target.value;t&&(console.log(`Send 'message' message to server for session `+V+` accessToken: `+U),$({from:{userName:z,sessionKey:V,audio:!0,video:!0},accessToken:U,type:`message`,data:t}),console.log(`Chat message sent `+t),p(e=>[...e,{sender:z,msg:t}]),m.current.value=``)}},me=()=>{let e=m.current.value;e&&(console.log(`Send 'message' message to server for session `+V+` accessToken: `+U),$({from:{userName:z,sessionKey:V,audio:!0,video:!0},accessToken:U,type:`message`,data:e}),console.log(`Chat message sent `+e),p(t=>[...t,{sender:z,msg:e}]),m.current.value=``,Q())};function $(e){let t=JSON.stringify(e);D.send(t)}function he(){X(),M(!1),P(!0),H(null),W(null),K(!1)}function ge(){D=new WebSocket(`wss://`+A+`/signal`),H(null),W(null),M(!0),P(!1),I(!1),K(!1),R(null),B(null),p([])}return i(()=>{Q()},[c,V]),d(`div`,{children:[!N&&d(h,{displayChat:j,maxWidth:s,children:[d(_,{children:[u(v,{children:e.title}),u(y,{onClick:()=>he(),className:`text-gray-700`,children:u(`svg`,{width:`60%`,height:`60%`,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:u(`path`,{d:`M18 6L6 18M6 6L18 18`,stroke:`orange`,"stroke-width":`4`,"stroke-linecap":`round`,"stroke-linejoin":`round`})})})]}),!F&&!V&&!G&&u(t,{startGuestChat:ce,guestEmail:L}),F&&!V&&!G&&u(l,{children:d(T,{children:[u(`div`,{className:`text-center mt-5`,children:`Please wait, connecting`}),d(`div`,{className:`flex flex-col items-center `,children:[u(`div`,{children:u(`img`,{className:`mt-5`,src:`/connecting_customer_support.gif`,width:`80`})}),u(`div`,{className:`absolute text-center bottom-6 font-sx text-sky-400`,children:`contact us at`}),u(`div`,{className:`absolute text-center bottom-0 font-sx text-sky-400`,children:e.supportEmail})]})]})}),F&&!V&&G&&u(l,{children:d(T,{children:[u(`div`,{className:`text-center`,children:`Our customer support team helping other customers, please wait.`}),u(`div`,{className:`text-center mt-5`,children:`connecting`}),d(`div`,{className:`flex flex-col items-center `,children:[u(`div`,{children:u(`img`,{className:`mt-1`,src:`/connecting_customer_support.gif`,width:`80`})}),u(`div`,{className:`mt-5 text-center bottom-6 font-sx text-sky-400`,children:`contact us at`}),u(`div`,{className:`text-center bottom-0 font-sx text-sky-400`,children:e.supportEmail})]})]})}),F&&V&&d(`div`,{children:[u(te,{children:`Live Chat`}),u(x,{children:d(ne,{children:[c&&c.length==0&&d(`div`,{className:`ml-2`,children:[` You are connected to our customer support team, `,e.welcomeMessage,` `]}),c&&c.length>0&&d(`div`,{children:[c&&c.map(({sender:e,msg:t},n)=>e===z?d(C,{children:[u(`strong`,{children:z}),u(`p`,{children:t})]},n):d(S,{children:[u(`strong`,{children:e}),u(`p`,{children:t})]},n)),u(`div`,{style:{float:`left`,clear:`both`},ref:n})]})]})}),d(w,{children:[u(re,{ref:m,onKeyUp:pe,placeholder:`Enter your message`}),d(ie,{onClick:me,children:[u(E,{className:`fas fa-paper-plane`}),`Send`]})]})]}),u(`audio`,{ref:ae,src:f.default}),u(`audio`,{ref:Y,src:ee.default})]}),N&&u(g,{className:`cursor-pointer`,onClick:()=>ge(),displayChat:j,maxWidth:s,children:u(b,{children:u(`i`,{className:`bx bx-chat`})})})]})};export{j as default};
233
+ `,S=`/connecting_customer_support.gif`;var C,w,T;const E=`optimizetalk.com:8443`,D=i=>{let a=n(null),[l]=r(window.innerWidth<window.innerHeight&&window.innerWidth<=900),[u]=r(l?80:20),[D,O]=r([]),k=n(),[A,j]=r(!0),[M,N]=r(!1),[P,F]=r(!1),[ae,I]=r(null),[L,R]=r(null),[z,B]=r(),[V,H]=r(),[U,W]=r(!1),[G,K]=r(``),q=n(null),J=n(null),oe=()=>{let e=1e4,t=Math.floor(Math.random()*(9e4-e+1))+e;return console.log(`Random number: `+t),t},se=(e,t)=>{C=new WebSocket(`wss://`+E+`/signal`),C.onopen=function(){console.log(`Websocket connection established`),Z(),le(e,t),$({from:{userName:e,audio:!0,video:!0},type:`text`,data:`ping from `+e}),w=setInterval(()=>{$({from:{userName:e,audio:!0,video:!0},type:`text`,data:`ping from `+e})},45e3),X(e,t),console.log(`WebSocket connection opened to chat room `+G)}},ce=(e,t)=>{F(!0),I(t),console.log(`Params guestName:`+e+`, guestEmail:`+t);var n=L?e:`Guest-`+oe()+`: `+e;R(n),console.log(`Joining : `+n),se(n,t)};function Y(){console.log(`Close the socket`),C!=null&&(console.log(`Send 'leave' message to server for session `+z+` accessToken: `+V),$({from:{userName:L,sessionKey:z,audio:!0,video:!0},accessToken:V,type:`leave`,data:i.meetingLinkKey}),C.close())}function le(e,t){C.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`),W(!0),T||ue(e,t)):r.data&&r.data===`valid`&&(clearInterval(T),console.log(`Session key `+r.referenceUsers[0].sessionKey),B(r.referenceUsers[0].sessionKey),console.log(`Session accessToken `+r.accessToken),H(r.accessToken),console.log(`Joined to room `+r.roomDetails.roomName),K(r.roomDetails.roomName));break;case`message`:console.log(`Chat message received from `+r.from.userName),console.log(`Chat message `+r.data),de(),O(e=>[...e,{sender:r.from.userName,msg:r.data}]),Q();break;case`session_expired`:console.log(`Chat session expired!`),F(!1),B(null),H(null),W(!1),Y();break;default:console.log(`Room ignoring message type `+r.type)}}}let ue=(e,t)=>{T=setInterval(()=>{console.log(`Trying to connect customer support team ...`),X(e,t)},1e4)},X=(e,t)=>{$({from:{userName:e,email:t,audio:!1,video:!1},type:`join_meeting`,roomDetails:{roomLinkKey:i.meetingLinkKey},data:i.customerSupportKey}),console.log(`Meeting join request sent for guest `+e+`, meetingLinkKey: `+i.meetingLinkKey+`, customerSupportKey: `+i.customerSupportKey)},de=()=>{J.current.play()};function Z(){C.addEventListener(`close`,e=>{console.log(`websocket connection closed: `,e),clearInterval(w)}),C.onerror=function(e){console.log(`Error: `+e)}}let Q=()=>{a.current?.scrollIntoView({behavior:`smooth`})},fe=e=>{if(e.key===`Enter`){let t=e.target.value;t&&(console.log(`Send 'message' message to server for session `+z+` accessToken: `+V),$({from:{userName:L,sessionKey:z,audio:!0,video:!0},accessToken:V,type:`message`,data:t}),console.log(`Chat message sent `+t),O(e=>[...e,{sender:L,msg:t}]),k.current.value=``)}},pe=()=>{let e=k.current.value;e&&(console.log(`Send 'message' message to server for session `+z+` accessToken: `+V),$({from:{userName:L,sessionKey:z,audio:!0,video:!0},accessToken:V,type:`message`,data:e}),console.log(`Chat message sent `+e),O(t=>[...t,{sender:L,msg:e}]),k.current.value=``,Q())};function $(e){let t=JSON.stringify(e);C.send(t)}function me(){Y(),j(!1),N(!0),B(null),H(null),W(!1)}function he(){C=new WebSocket(`wss://`+E+`/signal`),B(null),H(null),j(!0),N(!1),F(!1),W(!1),I(null),R(null),O([])}return t(()=>{Q()},[D,z]),c(`div`,{children:[!M&&c(d,{displayChat:A,maxWidth:u,children:[c(ee,{children:[s(te,{children:i.title}),s(p,{onClick:()=>me(),className:`text-gray-700`,children:s(`svg`,{width:`60%`,height:`60%`,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:s(`path`,{d:`M18 6L6 18M6 6L18 18`,stroke:`orange`,"stroke-width":`4`,"stroke-linecap":`round`,"stroke-linejoin":`round`})})})]}),!P&&!z&&!U&&s(e,{startGuestChat:ce,guestEmail:ae}),P&&!z&&!U&&s(o,{children:c(b,{children:[s(`div`,{className:`text-center mt-5`,children:`Please wait, connecting`}),c(`div`,{className:`flex flex-col items-center `,children:[s(`div`,{children:s(`img`,{className:`mt-5`,src:S,width:`80`})}),s(`div`,{className:`absolute text-center bottom-6 font-sx text-sky-400`,children:`contact us at`}),s(`div`,{className:`absolute text-center bottom-0 font-sx text-sky-400`,children:i.supportEmail})]})]})}),P&&!z&&U&&s(o,{children:c(b,{children:[s(`div`,{className:`text-center`,children:`Our customer support team helping other customers, please wait.`}),s(`div`,{className:`text-center mt-5`,children:`connecting`}),c(`div`,{className:`flex flex-col items-center `,children:[s(`div`,{children:s(`img`,{className:`mt-1`,src:S,width:`80`})}),s(`div`,{className:`mt-5 text-center bottom-6 font-sx text-sky-400`,children:`contact us at`}),s(`div`,{className:`text-center bottom-0 font-sx text-sky-400`,children:i.supportEmail})]})]})}),P&&z&&c(`div`,{children:[s(m,{children:`Live Chat`}),s(ne,{children:c(re,{children:[D&&D.length==0&&c(`div`,{className:`ml-2`,children:[` You are connected to our customer support team, `,i.welcomeMessage,` `]}),D&&D.length>0&&c(`div`,{children:[D&&D.map(({sender:e,msg:t},n)=>e===L?c(g,{children:[s(`strong`,{children:L}),s(`p`,{children:t})]},n):c(ie,{children:[s(`strong`,{children:e}),s(`p`,{children:t})]},n)),s(`div`,{style:{float:`left`,clear:`both`},ref:a})]})]})}),c(_,{children:[s(v,{ref:k,onKeyUp:fe,placeholder:`Enter your message`}),c(y,{onClick:pe,children:[s(x,{className:`fas fa-paper-plane`}),`Send`]})]})]}),s(`audio`,{ref:q,src:`/alert-sound.mp3`}),s(`audio`,{ref:J,src:`/ding-small.mp3`})]}),M&&s(f,{className:`cursor-pointer`,onClick:()=>he(),displayChat:A,maxWidth:u,children:s(h,{children:s(`i`,{className:`bx bx-chat`})})})]})};export{D as default};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "od-support-chat",
3
3
  "private": false,
4
- "version": "1.0.28",
4
+ "version": "1.0.30",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.ts",
7
7
  "exports": {
@@ -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,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),s=(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},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));export{o as __commonJSMin,c as __toESM};
@@ -1 +0,0 @@
1
- import{__commonJSMin as e}from"../_virtual/_rolldown/runtime.mjs";var t=e(((e,t)=>{t.exports=`../assets/alert-sound-Ct1TbJlM.mp3`}));export default t();export{t as require_alert_sound};
@@ -1 +0,0 @@
1
- import{__commonJSMin as e}from"../_virtual/_rolldown/runtime.mjs";var t=e(((e,t)=>{t.exports=`../assets/ding-small-C-IgIGxc.mp3`}));export default t();export{t as require_ding_small};