od-support-chat 1.0.46 → 1.0.48

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/README.md CHANGED
@@ -4,7 +4,7 @@ od-support-chat is a lightweight, embeddable customer support chat tool built fo
4
4
 
5
5
  ## Key Points
6
6
  ### Purpose:
7
- Enables live chat between customers and support teams directly within a website or platform.
7
+ This widget will allow live chat between your customers and your support teams directly within your website or platform.
8
8
 
9
9
  ### Core Value:
10
10
  * Improves customer trust
@@ -20,9 +20,11 @@ Manufacturing companies and businesses using the Origin Detector (OD) platform
20
20
  * Considered a complimentary add-on, not a standalone product
21
21
 
22
22
  ### Positioning:
23
- * Not sold independently
23
+ * Not sold independently, it is a complimentary chat widget with Origin Detector that our customer can use for their website.
24
24
  * Acts as an extra support feature within the OD ecosystem
25
25
 
26
+ [![Watch the video](https://origindetector.com/awareness/customer-support-free-tool.webp)](https://www.youtube.com/watch?v=izE81ShGlLI)
27
+
26
28
  ### Alternative Mentioned:
27
29
 
28
30
  The od-support-chat is a simple, embeddable customer support chat designed for the Origin Detector (OD) platform. It
@@ -230,4 +230,4 @@ import e from"./info.guest.mjs";import{useEffect as t,useRef as n,useState as r}
230
230
  `,ie=i.i`
231
231
  width: 25px;
232
232
  font-size: calc(5px + 1vmin);
233
- `;var C,w,T;const E=`optimizetalk.com:8443`,D=i=>{let a=n(null),[u]=r(window.innerWidth<window.innerHeight&&window.innerWidth<=900),[d]=r(u?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(f,{displayChat:A,maxWidth:d,children:[c(te,{children:[s(p,{children:i.title}),s(m,{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(S,{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:l,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(S,{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:l,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(ne,{children:`Live Chat`}),s(h,{children:c(g,{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(v,{children:[s(`strong`,{children:L}),s(`p`,{children:t})]},n):c(_,{children:[s(`strong`,{children:e}),s(`p`,{children:t})]},n)),s(`div`,{style:{float:`left`,clear:`both`},ref:a})]})]})}),c(y,{children:[s(b,{ref:k,onKeyUp:fe,placeholder:`Enter your message`}),c(x,{onClick:pe,children:[s(ie,{className:`fas fa-paper-plane`}),`Send`]})]})]}),s(`audio`,{ref:q,src:`/alert-sound.mp3`}),s(`audio`,{ref:J,src:`/ding-small.mp3`})]}),M&&s(ee,{className:`cursor-pointer`,onClick:()=>he(),displayChat:A,maxWidth:d,children:c(re,{children:[s(`i`,{className:`bx bx-chat`}),`Live Chat`]})})]})};export{D as default};
233
+ `;var C,w,T;const E=`optimizetalk.com:8443`,D=i=>{let a=n(null),[u]=r(window.innerWidth<window.innerHeight&&window.innerWidth<=900),[d]=r(u?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:!1,video:!1},type:`text`,data:`ping from `+e}),w=setInterval(()=>{$({from:{userName:e,audio:!1,video:!1},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:!1,video:!1},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:!1,video:!1},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:!1,video:!1},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(f,{displayChat:A,maxWidth:d,children:[c(te,{children:[s(p,{children:i.title}),s(m,{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(S,{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:l,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(S,{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:l,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(ne,{children:`Live Chat`}),s(h,{children:c(g,{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(v,{children:[s(`strong`,{children:L}),s(`p`,{children:t})]},n):c(_,{children:[s(`strong`,{children:e}),s(`p`,{children:t})]},n)),s(`div`,{style:{float:`left`,clear:`both`},ref:a})]})]})}),c(y,{children:[s(b,{ref:k,onKeyUp:fe,placeholder:`Enter your message`}),c(x,{onClick:pe,children:[s(ie,{className:`fas fa-paper-plane`}),`Send`]})]})]}),s(`audio`,{ref:q,src:`/alert-sound.mp3`}),s(`audio`,{ref:J,src:`/ding-small.mp3`})]}),M&&s(ee,{className:`cursor-pointer`,onClick:()=>he(),displayChat:A,maxWidth:d,children:c(re,{children:[s(`i`,{className:`bx bx-chat`}),`Live Chat`]})})]})};export{D as default};
@@ -230,4 +230,4 @@ import e from"./info.guestMobile.mjs";import{useEffect as t,useRef as n,useState
230
230
  `,ie=i.i`
231
231
  width: 25px;
232
232
  font-size: calc(5px + 1vmin);
233
- `;var C,w,T;const E=`optimizetalk.com:8443`,D=i=>{let a=n(null),[u]=r(window.innerWidth<window.innerHeight&&window.innerWidth<=900),[d]=r(u?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(f,{displayChat:A,maxWidth:d,children:[c(te,{children:[s(p,{children:i.title}),s(m,{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(S,{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:l,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(S,{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:l,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(ne,{children:`Live Chat`}),s(h,{children:c(g,{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(v,{children:[s(`strong`,{children:L}),s(`p`,{children:t})]},n):c(_,{children:[s(`strong`,{children:e}),s(`p`,{children:t})]},n)),s(`div`,{style:{float:`left`,clear:`both`},ref:a})]})]})}),c(y,{children:[s(b,{ref:k,onKeyUp:fe,placeholder:`Enter your message`}),c(x,{onClick:pe,children:[s(ie,{className:`fas fa-paper-plane`}),`Send`]})]})]}),s(`audio`,{ref:q,src:`/alert-sound.mp3`}),s(`audio`,{ref:J,src:`/ding-small.mp3`})]}),M&&s(ee,{className:`cursor-pointer`,onClick:()=>he(),displayChat:A,maxWidth:d,children:s(re,{children:s(`i`,{className:`bx bx-chat`})})})]})};export{D as default};
233
+ `;var C,w,T;const E=`optimizetalk.com:8443`,D=i=>{let a=n(null),[u]=r(window.innerWidth<window.innerHeight&&window.innerWidth<=900),[d]=r(u?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:!1,video:!1},type:`text`,data:`ping from `+e}),w=setInterval(()=>{$({from:{userName:e,audio:!1,video:!1},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:!1,video:!1},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:!1,video:!1},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:!1,video:!1},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(f,{displayChat:A,maxWidth:d,children:[c(te,{children:[s(p,{children:i.title}),s(m,{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(S,{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:l,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(S,{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:l,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(ne,{children:`Live Chat`}),s(h,{children:c(g,{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(v,{children:[s(`strong`,{children:L}),s(`p`,{children:t})]},n):c(_,{children:[s(`strong`,{children:e}),s(`p`,{children:t})]},n)),s(`div`,{style:{float:`left`,clear:`both`},ref:a})]})]})}),c(y,{children:[s(b,{ref:k,onKeyUp:fe,placeholder:`Enter your message`}),c(x,{onClick:pe,children:[s(ie,{className:`fas fa-paper-plane`}),`Send`]})]})]}),s(`audio`,{ref:q,src:`/alert-sound.mp3`}),s(`audio`,{ref:J,src:`/ding-small.mp3`})]}),M&&s(ee,{className:`cursor-pointer`,onClick:()=>he(),displayChat:A,maxWidth:d,children:s(re,{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.46",
4
+ "version": "1.0.48",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.ts",
7
7
  "exports": {