react-aichatbot-widget 2.0.0 → 2.0.2
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/dist/index.cjs +1 -1
- package/dist/index.js +209 -211
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=require("react/jsx-runtime"),x=require("react"),v=require("lucide-react"),E=({onMinimise:o,isOpen:t,theme:r,chatBotData:i})=>{const f=i.position==="left",d=f?"32px":"auto",p=f?"auto":"32px",u=localStorage.getItem("clone67ChatSessionId"),g={position:"fixed",bottom:"32px",left:d,right:p,background:`linear-gradient(135deg, ${r.primaryColor}, ${r.secondaryColor})`,color:r.fontColor,width:"64px",height:"64px",borderRadius:"50%",border:"none",boxShadow:"0 20px 25px -5px rgba(0,0,0,0.15), 0 10px 10px -5px rgba(0,0,0,0.1)",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",pointerEvents:"auto",transition:"all 300ms ease",outline:"none"},h={position:"absolute",top:"-4px",right:"-4px",width:"16px",height:"16px",backgroundColor:"#34d399",borderRadius:"50%",border:"4px solid white",animation:"pulse 2s infinite"};return e.jsxs("button",{onClick:o,style:g,children:[t?e.jsx(v.Minus,{size:20,strokeWidth:2.5}):e.jsx(v.MessageCircle,{size:20,strokeWidth:2.5}),!t&&u&&e.jsx("span",{style:h})]})},a=[];for(let o=0;o<256;++o)a.push((o+256).toString(16).slice(1));function T(o,t=0){return(a[o[t+0]]+a[o[t+1]]+a[o[t+2]]+a[o[t+3]]+"-"+a[o[t+4]]+a[o[t+5]]+"-"+a[o[t+6]]+a[o[t+7]]+"-"+a[o[t+8]]+a[o[t+9]]+"-"+a[o[t+10]]+a[o[t+11]]+a[o[t+12]]+a[o[t+13]]+a[o[t+14]]+a[o[t+15]]).toLowerCase()}let W;const M=new Uint8Array(16);function D(){if(!W){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");W=crypto.getRandomValues.bind(crypto)}return W(M)}const L=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),R={randomUUID:L};function $(o,t,r){o=o||{};const i=o.random??o.rng?.()??D();if(i.length<16)throw new Error("Random bytes length must be >= 16");return i[6]=i[6]&15|64,i[8]=i[8]&63|128,T(i)}function U(o,t,r){return R.randomUUID&&!o?R.randomUUID():$(o)}const B=({messages:o,chatBotData:t,theme:r,isLoading:i})=>{const[f,d]=x.useState([]),p=x.useRef(null),u=s=>{if(s==="")return null;try{return JSON.parse(s)}catch(y){return console.error("Error parsing message string to JSON:",y),null}},g=s=>new Date(s).toLocaleString(void 0,{hour:"2-digit",minute:"2-digit",hour12:!0});x.useEffect(()=>{const s=u(o);s&&d(y=>[...y,s])},[o]),x.useEffect(()=>{p.current?.scrollIntoView({behavior:"smooth"})},[f]);const h=f.flat(),S={height:"290px",overflowY:"auto",padding:"20px",background:r.backgroundColor,color:r.fontColor,borderTop:"1px solid rgba(255, 255, 255, 0.2)",display:"flex",flexDirection:"column",gap:"16px"},c=s=>({display:"flex",justifyContent:s==="user"?"flex-end":"flex-start",width:"100%"}),m={display:"flex",flexDirection:"column",maxWidth:"80%"},b=s=>({padding:"12px 16px",borderRadius:s==="user"?"16px 0 16px 16px":"0 16px 16px 16px",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.1)",fontSize:"14px",lineHeight:"1.5",background:s==="user"?r.primaryColor:"#f5f5f5",color:r.fontColor,wordWrap:"break-word"}),C={...b("bot"),animation:"fadeIn 0.3s ease-in-out, pulse 1.5s ease-in-out infinite",animationDelay:"0s, 0.3s"};return e.jsxs("div",{style:S,children:[h.map((s,y)=>e.jsx("div",{style:c(s.sender_type),children:e.jsxs("div",{style:m,children:[e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"4px",justifyContent:s.sender_type==="user"?"flex-end":"flex-start",marginRight:"4px",marginBottom:"2px"},children:e.jsx("span",{style:{fontSize:"10px",opacity:.55,color:r.fontColor},children:s.sender_type==="user"?"You":`${t.name}`})}),e.jsx("div",{style:s.sender_type==="user"?b("user"):b("ai"),children:s.message}),e.jsx("span",{style:{fontSize:"10px",opacity:.55,color:r.fontColor,alignSelf:s.sender_type==="user"?"flex-end":"flex-start",marginTop:"4px"},children:`${g(s.created_at)}`})]})},y)),i&&e.jsx("div",{style:C,children:"Typing..."}),e.jsx("div",{ref:p})]})},O=(o,t)=>({socket:new WebSocket(`wss://handle-chat-session.clone67.com?chatbotNamespace=${t}&sessionId=${o}`)}),F=({chatBotData:o,theme:t,onlineStatus:r})=>{const[i,f]=x.useState(null),[d,p]=x.useState(""),[u,g]=x.useState("Connecting to server..."),[h,S]=x.useState(""),[c,m]=x.useState(!1);x.useEffect(()=>{var n=localStorage.getItem("clone67ChatSessionId");n===null&&(n=U(),localStorage.setItem("clone67ChatSessionId",n));const{socket:l}=O(n,o.pineconeNamespace);f(l),l.onopen=()=>{g("Server connected"),setTimeout(()=>{g("")},2e3),r("online")},l.onmessage=async I=>{m(!0);try{const z=await I.data;S(z)}catch(z){console.error("Error handling server message:",z)}finally{m(!1)}},l.onerror=I=>{g("Server error occurred"),console.error("WebSocket error:",I),r("offline")},l.onclose=()=>{g("Server disconnected"),r("offline")}},[]);const b=async()=>{i&&i.readyState===WebSocket.OPEN&&i.send(JSON.stringify(d));const n={created_at:Date.now(),sender_type:"user",message:d};S(JSON.stringify(n)),p("")},C=n=>{n.key==="Enter"&&!n.shiftKey&&(n.preventDefault(),b())},s={flex:1,padding:"12px 16px",background:t.backgroundColor,color:t.fontColor,border:`1px solid ${t.fontColor}`,borderRadius:"12px",fontSize:"14px",outline:"none",transition:"all 0.2s ease",opacity:c?.5:1,cursor:c?"not-allowed":"text",boxShadow:"none"},y={padding:"12px 20px",borderRadius:"12px",background:`linear-gradient(135deg, ${t.primaryColor}, ${t.secondaryColor})`,color:t.fontColor,border:"none",cursor:c||!d.trim()?"not-allowed":"pointer",opacity:c||!d.trim()?.5:1,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",fontWeight:"600",fontSize:"14px",transition:"all 0.2s ease",minWidth:"48px"},k={padding:"16px",borderTop:"1px solid rgba(255, 255, 255, 0.2)",borderColor:t.fontColor,background:t.backgroundColor,flexShrink:0},w={display:"flex",gap:"12px",alignItems:"center"},j={textAlign:"center",padding:"2px",backgroundColor:u==="Server connected"||u==="online"?"#09BA00":u==="Connecting to server..."?"#DED000":"#FF3408",color:"#ffffff",fontSize:"10px"};return e.jsxs("div",{children:[u&&e.jsx("p",{style:j,children:u}),e.jsx(B,{messages:h,chatBotData:o,theme:t,isLoading:c}),e.jsx("div",{style:k,children:e.jsxs("form",{onSubmit:b,style:w,children:[e.jsx("input",{type:"text",placeholder:"Type a message...",value:d,onChange:n=>p(n.target.value),onKeyDown:C,disabled:c,style:s,onFocus:n=>{n.target.style.boxShadow="0 0 0 3px rgba(100, 150, 255, 0.3)",n.target.style.borderColor="#60a5fa"},onBlur:n=>{n.target.style.boxShadow="none",n.target.style.borderColor=t.fontColor}}),e.jsx("button",{onClick:b,disabled:c||!d.trim(),style:y,"aria-label":"Send message",onMouseEnter:n=>{!c&&d.trim()&&(n.currentTarget.style.transform="translateY(-2px)",n.currentTarget.style.boxShadow="0 8px 16px rgba(0,0,0,0.15)")},onMouseLeave:n=>{n.currentTarget.style.transform="translateY(0)",n.currentTarget.style.boxShadow="none"},children:e.jsx(v.Send,{size:18})})]})})]})},N=({onClose:o,theme:t,chatBotData:r})=>{const[i,f]=x.useState(!1),[d,p]=x.useState(!1),g={position:"fixed",bottom:"112px",[r.position==="left"?"left":"right"]:"32px",zIndex:50,width:i?"684px":"384px",height:i?"620px":"520px",background:`${t.backgroundColor}cc`,backdropFilter:"blur(16px)",WebkitBackdropFilter:"blur(16px)",borderRadius:"16px",border:"1px solid rgba(255, 255, 255, 0.3)",display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"system-ui, -apple-system, sans-serif",boxShadow:"0 10px 25px -3px rgba(0,0,0,0.1)"},h={padding:"16px 20px",background:`linear-gradient(135deg, ${t.primaryColor}, ${t.secondaryColor})`,color:t.fontColor,borderRadius:"16px 16px 0 0",display:"flex",alignItems:"center",justifyContent:"space-between",boxShadow:"0 4px 6px -1px rgba(0,0,0,0.1)"},S={position:"relative"},c={width:"44px",height:"44px",borderRadius:"50%",background:"rgba(255,255,255,0.2)",display:"flex",alignItems:"center",justifyContent:"center"},m={position:"absolute",bottom:0,right:0,width:"14px",height:"14px",backgroundColor:d?"#00BF49":"#F54927",borderRadius:"50%",border:"3px solid white"},b={fontSize:"18px",fontWeight:"600",margin:0,lineHeight:"1.2"},C={fontSize:"12px",opacity:.9,margin:0,lineHeight:"1.3"},s={padding:"8px",borderRadius:"50%",background:"transparent",border:"none",cursor:"pointer",transition:"background 0.2s"},y={padding:"12px 20px",borderTop:"1px solid rgba(255,255,255,0.2)",background:t.backgroundColor,textAlign:"center"},k={fontSize:"11px",color:t.fontColor,letterSpacing:"0.5px"},w={fontWeight:"600"},j=(l,I)=>{l.currentTarget.style.background=I?"rgba(255,255,255,0.2)":"transparent"},n=l=>{p(l==="online")};return e.jsxs("div",{style:g,children:[e.jsxs("div",{style:h,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[e.jsxs("div",{style:S,children:[e.jsx("div",{style:c,children:e.jsx(v.MessageCircle,{size:22})}),e.jsx("span",{style:m})]}),e.jsxs("div",{children:[e.jsx("h3",{style:b,children:r.name}),e.jsx("p",{style:C,children:r.subTitle})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"left"},children:[e.jsx("button",{onClick:()=>f(l=>!l),"aria-label":"expand chat",style:s,onMouseEnter:l=>j(l,!0),onMouseLeave:l=>j(l,!1),children:i?e.jsx(v.Minimize2,{size:20}):e.jsx(v.Maximize2,{size:20})}),e.jsx("button",{onClick:o,"aria-label":"close chat",style:s,onMouseEnter:l=>j(l,!0),onMouseLeave:l=>j(l,!1),children:e.jsx(v.X,{size:20})})]})]}),e.jsx(F,{chatBotData:r,theme:t,onlineStatus:n}),e.jsx("div",{style:y,children:e.jsxs("p",{style:k,children:["powered by ",e.jsx("span",{style:w,children:"clone67.com"})]})})]})},_=({pineconeNamespace:o,primaryColor:t="#3b82f6",secondaryColor:r="#8b5cf6",backgroundColor:i="#ffffff",fontColor:f="#1f2937",placeholderColor:d="#9ca3af",position:p="right",name:u="Assistant",subTitle:g="Typically replies instantly",welcomeText:h="Hi! How can I help you today?"})=>{const[S,c]=x.useState(!1),m=()=>{c(n=>!n),localStorage.removeItem("clone67ChatSessionId")},b=()=>c(n=>!n),C={primaryColor:t,secondaryColor:r,backgroundColor:i,fontColor:f,placeholderColor:d,inputBackgroundColor:i},s={name:u,subTitle:g,welcomeText:h,pineconeNamespace:o,position:p},y=p==="left",k="32px",w={position:"fixed",bottom:"104px",[y?"left":"right"]:k,zIndex:9999,pointerEvents:"auto"},j={position:"fixed",bottom:"32px",[y?"left":"right"]:k,zIndex:1e4,pointerEvents:"auto"};return e.jsxs(e.Fragment,{children:[S&&e.jsx("div",{style:w,children:e.jsx(N,{onClose:m,theme:C,chatBotData:s})}),e.jsx("div",{style:j,children:e.jsx(E,{onMinimise:b,isOpen:S,theme:C,chatBotData:s})})]})};module.exports=_;
|
|
1
|
+
"use strict";const t=require("react/jsx-runtime"),u=require("react"),k=require("lucide-react"),D=({onMinimise:o,isOpen:e,theme:s,chatBotData:i})=>{const c=i.position==="left",y=c?"32px":"auto",d=c?"auto":"32px",f=localStorage.getItem("clone67ChatSessionId"),p={position:"fixed",bottom:"32px",left:y,right:d,background:`linear-gradient(135deg, ${s.primaryColor}, ${s.secondaryColor})`,color:s.fontColor,width:"64px",height:"64px",borderRadius:"50%",border:"none",boxShadow:"0 20px 25px -5px rgba(0,0,0,0.15), 0 10px 10px -5px rgba(0,0,0,0.1)",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",pointerEvents:"auto",transition:"all 300ms ease",outline:"none"},g={position:"absolute",top:"-4px",right:"-4px",width:"16px",height:"16px",backgroundColor:"#34d399",borderRadius:"50%",border:"4px solid white",animation:"pulse 2s infinite"};return t.jsxs("button",{onClick:o,style:p,children:[e?t.jsx(k.Minus,{size:20,strokeWidth:2.5}):t.jsx(k.MessageCircle,{size:20,strokeWidth:2.5}),!e&&f&&t.jsx("span",{style:g})]})},a=[];for(let o=0;o<256;++o)a.push((o+256).toString(16).slice(1));function M(o,e=0){return(a[o[e+0]]+a[o[e+1]]+a[o[e+2]]+a[o[e+3]]+"-"+a[o[e+4]]+a[o[e+5]]+"-"+a[o[e+6]]+a[o[e+7]]+"-"+a[o[e+8]]+a[o[e+9]]+"-"+a[o[e+10]]+a[o[e+11]]+a[o[e+12]]+a[o[e+13]]+a[o[e+14]]+a[o[e+15]]).toLowerCase()}let E;const L=new Uint8Array(16);function T(){if(!E){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");E=crypto.getRandomValues.bind(crypto)}return E(L)}const U=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),$={randomUUID:U};function F(o,e,s){o=o||{};const i=o.random??o.rng?.()??T();if(i.length<16)throw new Error("Random bytes length must be >= 16");return i[6]=i[6]&15|64,i[8]=i[8]&63|128,M(i)}function O(o,e,s){return $.randomUUID&&!o?$.randomUUID():F(o)}const _=({messages:o,chatBotData:e,theme:s,isExpand:i})=>{const[c,y]=u.useState([]),d=u.useRef(null),f=n=>{if(n==="")return null;try{return JSON.parse(n)}catch(x){return console.error("Error parsing message string to JSON:",x),null}},p=n=>new Date(n).toLocaleString(void 0,{hour:"2-digit",minute:"2-digit",hour12:!0});u.useEffect(()=>{o===""&&y([{created_at:Date.now(),sender_type:"bot",message:e.aiInitialMessage,suggested_prompt:[]}]);const n=f(o);n&&y(x=>[...x,n])},[o]),u.useEffect(()=>{d.current?.scrollIntoView({behavior:"smooth"})},[c]);const g=c.flat(),S={height:i?"500px":"400px",overflowY:"auto",padding:"10px",background:s.backgroundColor,color:s.fontColor,borderTop:"1px solid rgba(255, 255, 255, 0.2)",display:"flex",flexDirection:"column"},b=n=>({display:"flex",justifyContent:n==="user"?"flex-end":"flex-start",width:"100%"}),m={display:"flex",flexDirection:"column",maxWidth:"80%"},h=n=>({padding:"10px",borderRadius:n==="user"?"12px 0 12px 12px":"0 12px 12px 12px",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.1)",fontSize:"14px",lineHeight:"1.5",background:n==="user"?s.primaryColor:"#f5f5f5",color:s.fontColor,wordWrap:"break-word"});return t.jsxs("div",{style:S,children:[g.map((n,x)=>t.jsx("div",{style:b(n.sender_type),children:t.jsxs("div",{style:m,children:[t.jsx("div",{style:n.sender_type==="user"?h("user"):h("ai"),children:n.message}),t.jsx("div",{style:{display:"flex",alignItems:"center",marginLeft:"4px",justifyContent:n.sender_type==="user"?"flex-end":"flex-start"},children:t.jsxs("span",{style:{fontSize:"10px",opacity:.55,color:s.fontColor},children:[n.sender_type==="user"?"You":`${e.name}`," • ",p(n.created_at)]})})]})},x)),t.jsx("div",{ref:d})]})},H=(o,e)=>({socket:new WebSocket(`wss://handle-chat-session.clone67.com?chatbotNamespace=${e}&sessionId=${o}`)}),A=({chatBotData:o,theme:e,onlineStatus:s,isExpand:i})=>{const[c,y]=u.useState(null),[d,f]=u.useState(""),[p,g]=u.useState("Connecting to server..."),[S,b]=u.useState(""),[m,h]=u.useState(!1);u.useEffect(()=>{var r=localStorage.getItem("clone67ChatSessionId");r===null&&(r=O(),localStorage.setItem("clone67ChatSessionId",r));const{socket:v}=H(r,o.pineconeNamespace);y(v),v.onopen=()=>{g("Server connected"),setTimeout(()=>{g("")},2e3),s("online")},v.onmessage=async W=>{try{const R=await W.data;b(R),h(!1)}catch(R){console.error("Error handling server message:",R)}},v.onerror=W=>{g("Server error occurred"),console.error("WebSocket error:",W),s("offline")},v.onclose=()=>{g("Server disconnected"),s("offline")}},[]);const n=async r=>{r.preventDefault(),c&&c.readyState===WebSocket.OPEN&&c.send(JSON.stringify(d)),h(!0);const v={created_at:Date.now(),sender_type:"user",message:d};b(JSON.stringify(v)),f("")},x=r=>{r.key==="Enter"&&!r.shiftKey&&(r.preventDefault(),n(r))},C={flex:1,padding:"12px 16px",background:e.backgroundColor,color:e.fontColor,border:`1px solid ${e.primaryColor}`,borderRadius:"12px",fontSize:"14px",outline:"none",transition:"all 0.2s ease",boxShadow:"none"},w={padding:"12px 20px",borderRadius:"12px",background:`linear-gradient(135deg, ${e.primaryColor}, ${e.secondaryColor})`,color:e.fontColor,border:"none",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",fontWeight:"600",fontSize:"14px",transition:"all 0.2s ease",minWidth:"48px"},I={padding:"10px",borderColor:e.fontColor,background:e.backgroundColor,flexShrink:0},j={display:"flex",gap:"12px",alignItems:"center"},z={textAlign:"center",padding:"2px",backgroundColor:p==="Server connected"||p==="online"?"#09BA00":p==="Connecting to server..."?"#DED000":"#FF3408",color:"#ffffff",fontSize:"10px"},l={padding:"8px",animation:"fadeIn 0.3s ease-in-out, pulse 1.5s ease-in-out infinite",animationDelay:"0s, 0.3s",fontSize:"10px",color:e.fontColor};return t.jsxs(t.Fragment,{children:[p&&t.jsx("p",{style:z,children:p}),t.jsx(_,{messages:S,chatBotData:o,theme:e,isExpand:i}),m&&t.jsx("div",{style:l,children:`${o.name} is typing...`}),t.jsx("div",{style:I,children:t.jsxs("form",{onSubmit:n,style:j,children:[t.jsx("input",{type:"text",placeholder:"Type a message...",value:d,onChange:r=>f(r.target.value),onKeyDown:x,style:C,onFocus:r=>{r.target.style.boxShadow=`0 0 0 1px ${e.primaryColor}`,r.target.style.borderColor=e.primaryColor},onBlur:r=>{r.target.style.boxShadow="none",r.target.style.borderColor=e.primaryColor}}),t.jsx("button",{onClick:n,style:w,"aria-label":"Send message",children:t.jsx(k.Send,{size:18})})]})})]})},N=({onClose:o,theme:e,chatBotData:s})=>{const[i,c]=u.useState(!1),[y,d]=u.useState(!1),p={position:"fixed",bottom:"112px",[s.position==="left"?"left":"right"]:"32px",zIndex:50,width:i?"684px":"384px",height:i?"620px":"520px",background:`${e.backgroundColor}cc`,backdropFilter:"blur(16px)",WebkitBackdropFilter:"blur(16px)",borderRadius:"16px",border:"1px solid rgba(255, 255, 255, 0.3)",display:"flex",flexDirection:"column",overflow:"hidden",fontFamily:"system-ui, -apple-system, sans-serif",boxShadow:"0 10px 25px -3px rgba(0,0,0,0.1)"},g={padding:"16px 20px",background:`linear-gradient(135deg, ${e.primaryColor}, ${e.secondaryColor})`,color:e.fontColor,borderRadius:"16px 16px 0 0",display:"flex",alignItems:"center",justifyContent:"space-between",boxShadow:"0 4px 6px -1px rgba(0,0,0,0.1)"},S={position:"relative"},b={width:"44px",height:"44px",borderRadius:"50%",background:"rgba(255,255,255,0.2)",display:"flex",alignItems:"center",justifyContent:"center"},m={position:"absolute",bottom:0,right:0,width:"14px",height:"14px",backgroundColor:y?"#00BF49":"#F54927",borderRadius:"50%",border:"3px solid white"},h={fontSize:"18px",fontWeight:"600",margin:0,lineHeight:"1.2"},n={fontSize:"12px",opacity:.9,margin:0,lineHeight:"1.3"},x={padding:"8px",borderRadius:"50%",background:"transparent",border:"none",cursor:"pointer",transition:"background 0.2s"},C={padding:"10px",borderTop:"1px solid rgba(255,255,255,0.2)",background:e.backgroundColor,textAlign:"center"},w={fontSize:"11px",color:e.fontColor,letterSpacing:"0.5px"},I={fontWeight:"600"},j=(l,r)=>{l.currentTarget.style.background=r?"rgba(255,255,255,0.2)":"transparent"},z=l=>{d(l==="online")};return t.jsxs("div",{style:p,children:[t.jsxs("div",{style:g,children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[t.jsxs("div",{style:S,children:[t.jsx("div",{style:b,children:t.jsx(k.MessageCircle,{size:22})}),t.jsx("span",{style:m})]}),t.jsxs("div",{children:[t.jsx("h3",{style:h,children:s.name}),t.jsx("p",{style:n,children:s.subTitle})]})]}),t.jsxs("div",{style:{display:"flex",alignItems:"left"},children:[t.jsx("button",{onClick:()=>c(l=>!l),"aria-label":"expand chat",style:x,onMouseEnter:l=>j(l,!0),onMouseLeave:l=>j(l,!1),children:i?t.jsx(k.Minimize2,{size:20}):t.jsx(k.Maximize2,{size:20})}),t.jsx("button",{onClick:o,"aria-label":"close chat",style:x,onMouseEnter:l=>j(l,!0),onMouseLeave:l=>j(l,!1),children:t.jsx(k.X,{size:20})})]})]}),t.jsx(A,{chatBotData:s,theme:e,onlineStatus:z,isExpand:i}),t.jsx("div",{style:C,children:t.jsxs("p",{style:w,children:["powered by ",t.jsx("span",{style:I,children:"clone67.com"})]})})]})},V=({pineconeNamespace:o,primaryColor:e="#3b82f6",secondaryColor:s="#8b5cf6",backgroundColor:i="#ffffff",fontColor:c="#1f2937",placeholderColor:y="#9ca3af",position:d="right",name:f="AI Assistant",subTitle:p="AI powered assistant",welcomeText:g="Hi! How can I help you today?",aiInitialMessage:S=""})=>{const[b,m]=u.useState(!1),h=()=>{m(l=>!l),localStorage.removeItem("clone67ChatSessionId")},n=()=>m(l=>!l),x={primaryColor:e,secondaryColor:s,backgroundColor:i,fontColor:c,placeholderColor:y,inputBackgroundColor:i},C={name:f,subTitle:p,welcomeText:g,pineconeNamespace:o,position:d,aiInitialMessage:S};S===""&&(C.aiInitialMessage=`Hello! I'm ${C.name}, your AI assistant. How can I help you today?`);const w=d==="left",I="32px",j={position:"fixed",bottom:"104px",[w?"left":"right"]:I,zIndex:9999,pointerEvents:"auto"},z={position:"fixed",bottom:"32px",[w?"left":"right"]:I,zIndex:1e4,pointerEvents:"auto"};return t.jsxs(t.Fragment,{children:[b&&t.jsx("div",{style:j,children:t.jsx(N,{onClose:h,theme:x,chatBotData:C})}),t.jsx("div",{style:z,children:t.jsx(D,{onMinimise:n,isOpen:b,theme:x,chatBotData:C})})]})};module.exports=V;
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as S, useRef as
|
|
3
|
-
import { Minus as
|
|
4
|
-
const
|
|
5
|
-
const
|
|
1
|
+
import { jsxs as c, jsx as o, Fragment as M } from "react/jsx-runtime";
|
|
2
|
+
import { useState as S, useRef as U, useEffect as D } from "react";
|
|
3
|
+
import { Minus as j, MessageCircle as T, Send as O, Minimize2 as _, Maximize2 as F, X as H } from "lucide-react";
|
|
4
|
+
const A = ({ onMinimise: t, isOpen: e, theme: r, chatBotData: i }) => {
|
|
5
|
+
const p = i.position === "left", y = p ? "32px" : "auto", d = p ? "auto" : "32px", f = localStorage.getItem("clone67ChatSessionId"), u = {
|
|
6
6
|
position: "fixed",
|
|
7
7
|
bottom: "32px",
|
|
8
|
-
left:
|
|
9
|
-
right:
|
|
10
|
-
background: `linear-gradient(135deg, ${
|
|
11
|
-
color:
|
|
8
|
+
left: y,
|
|
9
|
+
right: d,
|
|
10
|
+
background: `linear-gradient(135deg, ${r.primaryColor}, ${r.secondaryColor})`,
|
|
11
|
+
color: r.fontColor,
|
|
12
12
|
width: "64px",
|
|
13
13
|
height: "64px",
|
|
14
14
|
borderRadius: "50%",
|
|
@@ -22,14 +22,14 @@ const F = ({ onMinimise: t, isOpen: e, theme: s, chatBotData: i }) => {
|
|
|
22
22
|
transition: "all 300ms ease",
|
|
23
23
|
outline: "none"
|
|
24
24
|
};
|
|
25
|
-
return /* @__PURE__ */
|
|
25
|
+
return /* @__PURE__ */ c(
|
|
26
26
|
"button",
|
|
27
27
|
{
|
|
28
28
|
onClick: t,
|
|
29
|
-
style:
|
|
29
|
+
style: u,
|
|
30
30
|
children: [
|
|
31
|
-
e ? /* @__PURE__ */ o(
|
|
32
|
-
!e &&
|
|
31
|
+
e ? /* @__PURE__ */ o(j, { size: 20, strokeWidth: 2.5 }) : /* @__PURE__ */ o(T, { size: 20, strokeWidth: 2.5 }),
|
|
32
|
+
!e && f && /* @__PURE__ */ o("span", { style: {
|
|
33
33
|
position: "absolute",
|
|
34
34
|
top: "-4px",
|
|
35
35
|
right: "-4px",
|
|
@@ -49,151 +49,147 @@ for (let t = 0; t < 256; ++t)
|
|
|
49
49
|
function N(t, e = 0) {
|
|
50
50
|
return (a[t[e + 0]] + a[t[e + 1]] + a[t[e + 2]] + a[t[e + 3]] + "-" + a[t[e + 4]] + a[t[e + 5]] + "-" + a[t[e + 6]] + a[t[e + 7]] + "-" + a[t[e + 8]] + a[t[e + 9]] + "-" + a[t[e + 10]] + a[t[e + 11]] + a[t[e + 12]] + a[t[e + 13]] + a[t[e + 14]] + a[t[e + 15]]).toLowerCase();
|
|
51
51
|
}
|
|
52
|
-
let
|
|
53
|
-
const
|
|
54
|
-
function
|
|
55
|
-
if (
|
|
52
|
+
let $;
|
|
53
|
+
const V = new Uint8Array(16);
|
|
54
|
+
function B() {
|
|
55
|
+
if (!$) {
|
|
56
56
|
if (typeof crypto > "u" || !crypto.getRandomValues)
|
|
57
57
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
58
|
-
|
|
58
|
+
$ = crypto.getRandomValues.bind(crypto);
|
|
59
59
|
}
|
|
60
|
-
return
|
|
60
|
+
return $(V);
|
|
61
61
|
}
|
|
62
|
-
const
|
|
63
|
-
function
|
|
62
|
+
const J = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), L = { randomUUID: J };
|
|
63
|
+
function P(t, e, r) {
|
|
64
64
|
t = t || {};
|
|
65
|
-
const i = t.random ?? t.rng?.() ??
|
|
65
|
+
const i = t.random ?? t.rng?.() ?? B();
|
|
66
66
|
if (i.length < 16)
|
|
67
67
|
throw new Error("Random bytes length must be >= 16");
|
|
68
68
|
return i[6] = i[6] & 15 | 64, i[8] = i[8] & 63 | 128, N(i);
|
|
69
69
|
}
|
|
70
|
-
function
|
|
71
|
-
return
|
|
70
|
+
function K(t, e, r) {
|
|
71
|
+
return L.randomUUID && !t ? L.randomUUID() : P(t);
|
|
72
72
|
}
|
|
73
|
-
const
|
|
74
|
-
const [
|
|
75
|
-
if (
|
|
73
|
+
const Y = ({ messages: t, chatBotData: e, theme: r, isExpand: i }) => {
|
|
74
|
+
const [p, y] = S([]), d = U(null), f = (n) => {
|
|
75
|
+
if (n === "") return null;
|
|
76
76
|
try {
|
|
77
|
-
return JSON.parse(
|
|
78
|
-
} catch (
|
|
79
|
-
return console.error("Error parsing message string to JSON:",
|
|
77
|
+
return JSON.parse(n);
|
|
78
|
+
} catch (g) {
|
|
79
|
+
return console.error("Error parsing message string to JSON:", g), null;
|
|
80
80
|
}
|
|
81
|
-
},
|
|
81
|
+
}, u = (n) => new Date(n).toLocaleString(void 0, {
|
|
82
82
|
hour: "2-digit",
|
|
83
83
|
minute: "2-digit",
|
|
84
84
|
hour12: !0
|
|
85
85
|
});
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
86
|
+
D(() => {
|
|
87
|
+
t === "" && y([
|
|
88
|
+
{
|
|
89
|
+
created_at: Date.now(),
|
|
90
|
+
sender_type: "bot",
|
|
91
|
+
message: e.aiInitialMessage,
|
|
92
|
+
suggested_prompt: []
|
|
93
|
+
}
|
|
94
|
+
]);
|
|
95
|
+
const n = f(t);
|
|
96
|
+
n && y((g) => [...g, n]);
|
|
97
|
+
}, [t]), D(() => {
|
|
98
|
+
d.current?.scrollIntoView({ behavior: "smooth" });
|
|
99
|
+
}, [p]);
|
|
100
|
+
const x = p.flat(), m = {
|
|
101
|
+
height: i ? "500px" : "400px",
|
|
94
102
|
overflowY: "auto",
|
|
95
|
-
padding: "
|
|
96
|
-
background:
|
|
97
|
-
color:
|
|
103
|
+
padding: "10px",
|
|
104
|
+
background: r.backgroundColor,
|
|
105
|
+
color: r.fontColor,
|
|
98
106
|
borderTop: "1px solid rgba(255, 255, 255, 0.2)",
|
|
99
107
|
display: "flex",
|
|
100
|
-
flexDirection: "column"
|
|
101
|
-
|
|
102
|
-
}, c = (r) => ({
|
|
108
|
+
flexDirection: "column"
|
|
109
|
+
}, b = (n) => ({
|
|
103
110
|
display: "flex",
|
|
104
|
-
justifyContent:
|
|
111
|
+
justifyContent: n === "user" ? "flex-end" : "flex-start",
|
|
105
112
|
width: "100%"
|
|
106
113
|
}), C = {
|
|
107
114
|
display: "flex",
|
|
108
115
|
flexDirection: "column",
|
|
109
116
|
maxWidth: "80%"
|
|
110
|
-
},
|
|
111
|
-
padding: "
|
|
112
|
-
borderRadius:
|
|
117
|
+
}, h = (n) => ({
|
|
118
|
+
padding: "10px",
|
|
119
|
+
borderRadius: n === "user" ? "12px 0 12px 12px" : "0 12px 12px 12px",
|
|
113
120
|
boxShadow: "0 1px 3px rgba(0, 0, 0, 0.1)",
|
|
114
121
|
fontSize: "14px",
|
|
115
122
|
lineHeight: "1.5",
|
|
116
|
-
background:
|
|
117
|
-
color:
|
|
123
|
+
background: n === "user" ? r.primaryColor : "#f5f5f5",
|
|
124
|
+
color: r.fontColor,
|
|
118
125
|
wordWrap: "break-word"
|
|
119
|
-
})
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
};
|
|
124
|
-
return /* @__PURE__ */ u("div", { style: h, children: [
|
|
125
|
-
m.map((r, y) => /* @__PURE__ */ o("div", { style: c(r.sender_type), children: /* @__PURE__ */ u("div", { style: C, children: [
|
|
126
|
+
});
|
|
127
|
+
return /* @__PURE__ */ c("div", { style: m, children: [
|
|
128
|
+
x.map((n, g) => /* @__PURE__ */ o("div", { style: b(n.sender_type), children: /* @__PURE__ */ c("div", { style: C, children: [
|
|
129
|
+
/* @__PURE__ */ o("div", { style: n.sender_type === "user" ? h("user") : h("ai"), children: n.message }),
|
|
126
130
|
/* @__PURE__ */ o("div", { style: {
|
|
127
131
|
display: "flex",
|
|
128
132
|
alignItems: "center",
|
|
129
|
-
|
|
130
|
-
justifyContent:
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
] }) },
|
|
137
|
-
|
|
138
|
-
/* @__PURE__ */ o("div", { ref: p })
|
|
133
|
+
marginLeft: "4px",
|
|
134
|
+
justifyContent: n.sender_type === "user" ? "flex-end" : "flex-start"
|
|
135
|
+
}, children: /* @__PURE__ */ c("span", { style: { fontSize: "10px", opacity: 0.55, color: r.fontColor }, children: [
|
|
136
|
+
n.sender_type === "user" ? "You" : `${e.name}`,
|
|
137
|
+
" • ",
|
|
138
|
+
u(n.created_at)
|
|
139
|
+
] }) })
|
|
140
|
+
] }) }, g)),
|
|
141
|
+
/* @__PURE__ */ o("div", { ref: d })
|
|
139
142
|
] });
|
|
140
|
-
},
|
|
141
|
-
const [
|
|
142
|
-
|
|
143
|
-
var
|
|
144
|
-
|
|
145
|
-
const { socket:
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}, 2e3),
|
|
150
|
-
},
|
|
151
|
-
C(!0);
|
|
143
|
+
}, X = (t, e) => ({ socket: new WebSocket(`wss://handle-chat-session.clone67.com?chatbotNamespace=${e}&sessionId=${t}`) }), q = ({ chatBotData: t, theme: e, onlineStatus: r, isExpand: i }) => {
|
|
144
|
+
const [p, y] = S(null), [d, f] = S(""), [u, x] = S("Connecting to server..."), [m, b] = S(""), [C, h] = S(!1);
|
|
145
|
+
D(() => {
|
|
146
|
+
var s = localStorage.getItem("clone67ChatSessionId");
|
|
147
|
+
s === null && (s = K(), localStorage.setItem("clone67ChatSessionId", s));
|
|
148
|
+
const { socket: w } = X(s, t.pineconeNamespace);
|
|
149
|
+
y(w), w.onopen = () => {
|
|
150
|
+
x("Server connected"), setTimeout(() => {
|
|
151
|
+
x("");
|
|
152
|
+
}, 2e3), r("online");
|
|
153
|
+
}, w.onmessage = async (R) => {
|
|
152
154
|
try {
|
|
153
|
-
const
|
|
154
|
-
h(
|
|
155
|
-
} catch (
|
|
156
|
-
console.error("Error handling server message:",
|
|
157
|
-
} finally {
|
|
158
|
-
C(!1);
|
|
155
|
+
const E = await R.data;
|
|
156
|
+
b(E), h(!1);
|
|
157
|
+
} catch (E) {
|
|
158
|
+
console.error("Error handling server message:", E);
|
|
159
159
|
}
|
|
160
|
-
},
|
|
161
|
-
|
|
162
|
-
},
|
|
163
|
-
|
|
160
|
+
}, w.onerror = (R) => {
|
|
161
|
+
x("Server error occurred"), console.error("WebSocket error:", R), r("offline");
|
|
162
|
+
}, w.onclose = () => {
|
|
163
|
+
x("Server disconnected"), r("offline");
|
|
164
164
|
};
|
|
165
165
|
}, []);
|
|
166
|
-
const
|
|
167
|
-
|
|
168
|
-
const
|
|
166
|
+
const n = async (s) => {
|
|
167
|
+
s.preventDefault(), p && p.readyState === WebSocket.OPEN && p.send(JSON.stringify(d)), h(!0);
|
|
168
|
+
const w = {
|
|
169
169
|
created_at: Date.now(),
|
|
170
170
|
sender_type: "user",
|
|
171
171
|
message: d
|
|
172
172
|
};
|
|
173
|
-
|
|
174
|
-
},
|
|
175
|
-
|
|
176
|
-
},
|
|
173
|
+
b(JSON.stringify(w)), f("");
|
|
174
|
+
}, g = (s) => {
|
|
175
|
+
s.key === "Enter" && !s.shiftKey && (s.preventDefault(), n(s));
|
|
176
|
+
}, v = {
|
|
177
177
|
flex: 1,
|
|
178
178
|
padding: "12px 16px",
|
|
179
179
|
background: e.backgroundColor,
|
|
180
180
|
color: e.fontColor,
|
|
181
|
-
border: `1px solid ${e.
|
|
181
|
+
border: `1px solid ${e.primaryColor}`,
|
|
182
182
|
borderRadius: "12px",
|
|
183
183
|
fontSize: "14px",
|
|
184
184
|
outline: "none",
|
|
185
185
|
transition: "all 0.2s ease",
|
|
186
|
-
opacity: c ? 0.5 : 1,
|
|
187
|
-
cursor: c ? "not-allowed" : "text",
|
|
188
186
|
boxShadow: "none"
|
|
189
|
-
},
|
|
187
|
+
}, I = {
|
|
190
188
|
padding: "12px 20px",
|
|
191
189
|
borderRadius: "12px",
|
|
192
190
|
background: `linear-gradient(135deg, ${e.primaryColor}, ${e.secondaryColor})`,
|
|
193
191
|
color: e.fontColor,
|
|
194
192
|
border: "none",
|
|
195
|
-
cursor: c || !d.trim() ? "not-allowed" : "pointer",
|
|
196
|
-
opacity: c || !d.trim() ? 0.5 : 1,
|
|
197
193
|
display: "flex",
|
|
198
194
|
alignItems: "center",
|
|
199
195
|
justifyContent: "center",
|
|
@@ -202,68 +198,66 @@ const P = ({ messages: t, chatBotData: e, theme: s, isLoading: i }) => {
|
|
|
202
198
|
fontSize: "14px",
|
|
203
199
|
transition: "all 0.2s ease",
|
|
204
200
|
minWidth: "48px"
|
|
205
|
-
},
|
|
206
|
-
padding: "
|
|
207
|
-
borderTop: "1px solid rgba(255, 255, 255, 0.2)",
|
|
201
|
+
}, z = {
|
|
202
|
+
padding: "10px",
|
|
208
203
|
borderColor: e.fontColor,
|
|
209
204
|
background: e.backgroundColor,
|
|
210
205
|
flexShrink: 0
|
|
206
|
+
}, k = {
|
|
207
|
+
display: "flex",
|
|
208
|
+
gap: "12px",
|
|
209
|
+
alignItems: "center"
|
|
210
|
+
}, W = {
|
|
211
|
+
textAlign: "center",
|
|
212
|
+
padding: "2px",
|
|
213
|
+
backgroundColor: u === "Server connected" || u === "online" ? "#09BA00" : u === "Connecting to server..." ? "#DED000" : "#FF3408",
|
|
214
|
+
color: "#ffffff",
|
|
215
|
+
fontSize: "10px"
|
|
216
|
+
}, l = {
|
|
217
|
+
padding: "8px",
|
|
218
|
+
animation: "fadeIn 0.3s ease-in-out, pulse 1.5s ease-in-out infinite",
|
|
219
|
+
animationDelay: "0s, 0.3s",
|
|
220
|
+
fontSize: "10px",
|
|
221
|
+
color: e.fontColor
|
|
211
222
|
};
|
|
212
|
-
return /* @__PURE__ */
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
color: "#ffffff",
|
|
218
|
-
fontSize: "10px"
|
|
219
|
-
}, children: x }),
|
|
220
|
-
/* @__PURE__ */ o(P, { messages: m, chatBotData: t, theme: e, isLoading: c }),
|
|
221
|
-
/* @__PURE__ */ o("div", { style: k, children: /* @__PURE__ */ u("form", { onSubmit: b, style: {
|
|
222
|
-
display: "flex",
|
|
223
|
-
gap: "12px",
|
|
224
|
-
alignItems: "center"
|
|
225
|
-
}, children: [
|
|
223
|
+
return /* @__PURE__ */ c(M, { children: [
|
|
224
|
+
u && /* @__PURE__ */ o("p", { style: W, children: u }),
|
|
225
|
+
/* @__PURE__ */ o(Y, { messages: m, chatBotData: t, theme: e, isExpand: i }),
|
|
226
|
+
C && /* @__PURE__ */ o("div", { style: l, children: `${t.name} is typing...` }),
|
|
227
|
+
/* @__PURE__ */ o("div", { style: z, children: /* @__PURE__ */ c("form", { onSubmit: n, style: k, children: [
|
|
226
228
|
/* @__PURE__ */ o(
|
|
227
229
|
"input",
|
|
228
230
|
{
|
|
229
231
|
type: "text",
|
|
230
232
|
placeholder: "Type a message...",
|
|
231
233
|
value: d,
|
|
232
|
-
onChange: (
|
|
233
|
-
onKeyDown:
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
n.target.style.boxShadow = "0 0 0 3px rgba(100, 150, 255, 0.3)", n.target.style.borderColor = "#60a5fa";
|
|
234
|
+
onChange: (s) => f(s.target.value),
|
|
235
|
+
onKeyDown: g,
|
|
236
|
+
style: v,
|
|
237
|
+
onFocus: (s) => {
|
|
238
|
+
s.target.style.boxShadow = `0 0 0 1px ${e.primaryColor}`, s.target.style.borderColor = e.primaryColor;
|
|
238
239
|
},
|
|
239
|
-
onBlur: (
|
|
240
|
-
|
|
240
|
+
onBlur: (s) => {
|
|
241
|
+
s.target.style.boxShadow = "none", s.target.style.borderColor = e.primaryColor;
|
|
241
242
|
}
|
|
242
243
|
}
|
|
243
244
|
),
|
|
244
245
|
/* @__PURE__ */ o(
|
|
245
246
|
"button",
|
|
246
247
|
{
|
|
247
|
-
onClick:
|
|
248
|
-
|
|
249
|
-
style: y,
|
|
248
|
+
onClick: n,
|
|
249
|
+
style: I,
|
|
250
250
|
"aria-label": "Send message",
|
|
251
|
-
|
|
252
|
-
!c && d.trim() && (n.currentTarget.style.transform = "translateY(-2px)", n.currentTarget.style.boxShadow = "0 8px 16px rgba(0,0,0,0.15)");
|
|
253
|
-
},
|
|
254
|
-
onMouseLeave: (n) => {
|
|
255
|
-
n.currentTarget.style.transform = "translateY(0)", n.currentTarget.style.boxShadow = "none";
|
|
256
|
-
},
|
|
257
|
-
children: /* @__PURE__ */ o(U, { size: 18 })
|
|
251
|
+
children: /* @__PURE__ */ o(O, { size: 18 })
|
|
258
252
|
}
|
|
259
253
|
)
|
|
260
254
|
] }) })
|
|
261
255
|
] });
|
|
262
|
-
},
|
|
263
|
-
const [i,
|
|
256
|
+
}, G = ({ onClose: t, theme: e, chatBotData: r }) => {
|
|
257
|
+
const [i, p] = S(!1), [y, d] = S(!1), u = {
|
|
264
258
|
position: "fixed",
|
|
265
259
|
bottom: "112px",
|
|
266
|
-
[
|
|
260
|
+
[r.position === "left" ? "left" : "right"]: "32px",
|
|
267
261
|
zIndex: 50,
|
|
268
262
|
width: i ? "684px" : "384px",
|
|
269
263
|
height: i ? "620px" : "520px",
|
|
@@ -277,7 +271,7 @@ const P = ({ messages: t, chatBotData: e, theme: s, isLoading: i }) => {
|
|
|
277
271
|
overflow: "hidden",
|
|
278
272
|
fontFamily: "system-ui, -apple-system, sans-serif",
|
|
279
273
|
boxShadow: "0 10px 25px -3px rgba(0,0,0,0.1)"
|
|
280
|
-
},
|
|
274
|
+
}, x = {
|
|
281
275
|
padding: "16px 20px",
|
|
282
276
|
background: `linear-gradient(135deg, ${e.primaryColor}, ${e.secondaryColor})`,
|
|
283
277
|
color: e.fontColor,
|
|
@@ -286,9 +280,9 @@ const P = ({ messages: t, chatBotData: e, theme: s, isLoading: i }) => {
|
|
|
286
280
|
alignItems: "center",
|
|
287
281
|
justifyContent: "space-between",
|
|
288
282
|
boxShadow: "0 4px 6px -1px rgba(0,0,0,0.1)"
|
|
289
|
-
},
|
|
283
|
+
}, m = {
|
|
290
284
|
position: "relative"
|
|
291
|
-
},
|
|
285
|
+
}, b = {
|
|
292
286
|
width: "44px",
|
|
293
287
|
height: "44px",
|
|
294
288
|
borderRadius: "50%",
|
|
@@ -302,64 +296,64 @@ const P = ({ messages: t, chatBotData: e, theme: s, isLoading: i }) => {
|
|
|
302
296
|
right: 0,
|
|
303
297
|
width: "14px",
|
|
304
298
|
height: "14px",
|
|
305
|
-
backgroundColor:
|
|
299
|
+
backgroundColor: y ? "#00BF49" : "#F54927",
|
|
306
300
|
borderRadius: "50%",
|
|
307
301
|
border: "3px solid white"
|
|
308
|
-
},
|
|
302
|
+
}, h = {
|
|
309
303
|
fontSize: "18px",
|
|
310
304
|
fontWeight: "600",
|
|
311
305
|
margin: 0,
|
|
312
306
|
lineHeight: "1.2"
|
|
313
|
-
},
|
|
307
|
+
}, n = {
|
|
314
308
|
fontSize: "12px",
|
|
315
309
|
opacity: 0.9,
|
|
316
310
|
margin: 0,
|
|
317
311
|
lineHeight: "1.3"
|
|
318
|
-
},
|
|
312
|
+
}, g = {
|
|
319
313
|
padding: "8px",
|
|
320
314
|
borderRadius: "50%",
|
|
321
315
|
background: "transparent",
|
|
322
316
|
border: "none",
|
|
323
317
|
cursor: "pointer",
|
|
324
318
|
transition: "background 0.2s"
|
|
325
|
-
},
|
|
326
|
-
padding: "
|
|
319
|
+
}, v = {
|
|
320
|
+
padding: "10px",
|
|
327
321
|
borderTop: "1px solid rgba(255,255,255,0.2)",
|
|
328
322
|
background: e.backgroundColor,
|
|
329
323
|
textAlign: "center"
|
|
330
|
-
},
|
|
324
|
+
}, I = {
|
|
331
325
|
fontSize: "11px",
|
|
332
326
|
color: e.fontColor,
|
|
333
327
|
letterSpacing: "0.5px"
|
|
334
328
|
}, z = {
|
|
335
329
|
fontWeight: "600"
|
|
336
|
-
},
|
|
337
|
-
l.currentTarget.style.background =
|
|
338
|
-
},
|
|
339
|
-
|
|
330
|
+
}, k = (l, s) => {
|
|
331
|
+
l.currentTarget.style.background = s ? "rgba(255,255,255,0.2)" : "transparent";
|
|
332
|
+
}, W = (l) => {
|
|
333
|
+
d(l === "online");
|
|
340
334
|
};
|
|
341
|
-
return /* @__PURE__ */
|
|
342
|
-
/* @__PURE__ */
|
|
343
|
-
/* @__PURE__ */
|
|
344
|
-
/* @__PURE__ */
|
|
345
|
-
/* @__PURE__ */ o("div", { style:
|
|
335
|
+
return /* @__PURE__ */ c("div", { style: u, children: [
|
|
336
|
+
/* @__PURE__ */ c("div", { style: x, children: [
|
|
337
|
+
/* @__PURE__ */ c("div", { style: { display: "flex", alignItems: "center", gap: "12px" }, children: [
|
|
338
|
+
/* @__PURE__ */ c("div", { style: m, children: [
|
|
339
|
+
/* @__PURE__ */ o("div", { style: b, children: /* @__PURE__ */ o(T, { size: 22 }) }),
|
|
346
340
|
/* @__PURE__ */ o("span", { style: C })
|
|
347
341
|
] }),
|
|
348
|
-
/* @__PURE__ */
|
|
349
|
-
/* @__PURE__ */ o("h3", { style:
|
|
350
|
-
/* @__PURE__ */ o("p", { style:
|
|
342
|
+
/* @__PURE__ */ c("div", { children: [
|
|
343
|
+
/* @__PURE__ */ o("h3", { style: h, children: r.name }),
|
|
344
|
+
/* @__PURE__ */ o("p", { style: n, children: r.subTitle })
|
|
351
345
|
] })
|
|
352
346
|
] }),
|
|
353
|
-
/* @__PURE__ */
|
|
347
|
+
/* @__PURE__ */ c("div", { style: { display: "flex", alignItems: "left" }, children: [
|
|
354
348
|
/* @__PURE__ */ o(
|
|
355
349
|
"button",
|
|
356
350
|
{
|
|
357
|
-
onClick: () =>
|
|
351
|
+
onClick: () => p((l) => !l),
|
|
358
352
|
"aria-label": "expand chat",
|
|
359
|
-
style:
|
|
360
|
-
onMouseEnter: (l) =>
|
|
361
|
-
onMouseLeave: (l) =>
|
|
362
|
-
children: i ? /* @__PURE__ */ o(
|
|
353
|
+
style: g,
|
|
354
|
+
onMouseEnter: (l) => k(l, !0),
|
|
355
|
+
onMouseLeave: (l) => k(l, !1),
|
|
356
|
+
children: i ? /* @__PURE__ */ o(_, { size: 20 }) : /* @__PURE__ */ o(F, { size: 20 })
|
|
363
357
|
}
|
|
364
358
|
),
|
|
365
359
|
/* @__PURE__ */ o(
|
|
@@ -367,80 +361,84 @@ const P = ({ messages: t, chatBotData: e, theme: s, isLoading: i }) => {
|
|
|
367
361
|
{
|
|
368
362
|
onClick: t,
|
|
369
363
|
"aria-label": "close chat",
|
|
370
|
-
style:
|
|
371
|
-
onMouseEnter: (l) =>
|
|
372
|
-
onMouseLeave: (l) =>
|
|
373
|
-
children: /* @__PURE__ */ o(
|
|
364
|
+
style: g,
|
|
365
|
+
onMouseEnter: (l) => k(l, !0),
|
|
366
|
+
onMouseLeave: (l) => k(l, !1),
|
|
367
|
+
children: /* @__PURE__ */ o(H, { size: 20 })
|
|
374
368
|
}
|
|
375
369
|
)
|
|
376
370
|
] })
|
|
377
371
|
] }),
|
|
378
|
-
/* @__PURE__ */ o(
|
|
379
|
-
/* @__PURE__ */ o("div", { style:
|
|
372
|
+
/* @__PURE__ */ o(q, { chatBotData: r, theme: e, onlineStatus: W, isExpand: i }),
|
|
373
|
+
/* @__PURE__ */ o("div", { style: v, children: /* @__PURE__ */ c("p", { style: I, children: [
|
|
380
374
|
"powered by ",
|
|
381
375
|
/* @__PURE__ */ o("span", { style: z, children: "clone67.com" })
|
|
382
376
|
] }) })
|
|
383
377
|
] });
|
|
384
|
-
},
|
|
378
|
+
}, te = ({
|
|
385
379
|
pineconeNamespace: t,
|
|
386
380
|
primaryColor: e = "#3b82f6",
|
|
387
|
-
secondaryColor:
|
|
381
|
+
secondaryColor: r = "#8b5cf6",
|
|
388
382
|
backgroundColor: i = "#ffffff",
|
|
389
|
-
fontColor:
|
|
390
|
-
placeholderColor:
|
|
391
|
-
position:
|
|
392
|
-
name:
|
|
393
|
-
subTitle:
|
|
394
|
-
welcomeText:
|
|
383
|
+
fontColor: p = "#1f2937",
|
|
384
|
+
placeholderColor: y = "#9ca3af",
|
|
385
|
+
position: d = "right",
|
|
386
|
+
name: f = "AI Assistant",
|
|
387
|
+
subTitle: u = "AI powered assistant",
|
|
388
|
+
welcomeText: x = "Hi! How can I help you today?",
|
|
389
|
+
aiInitialMessage: m = ""
|
|
395
390
|
}) => {
|
|
396
|
-
const [
|
|
397
|
-
|
|
398
|
-
},
|
|
391
|
+
const [b, C] = S(!1), h = () => {
|
|
392
|
+
C((l) => !l), localStorage.removeItem("clone67ChatSessionId");
|
|
393
|
+
}, n = () => C((l) => !l), g = {
|
|
399
394
|
primaryColor: e,
|
|
400
|
-
secondaryColor:
|
|
395
|
+
secondaryColor: r,
|
|
401
396
|
backgroundColor: i,
|
|
402
|
-
fontColor:
|
|
403
|
-
placeholderColor:
|
|
397
|
+
fontColor: p,
|
|
398
|
+
placeholderColor: y,
|
|
404
399
|
inputBackgroundColor: i
|
|
405
|
-
},
|
|
406
|
-
name:
|
|
407
|
-
subTitle:
|
|
408
|
-
welcomeText:
|
|
400
|
+
}, v = {
|
|
401
|
+
name: f,
|
|
402
|
+
subTitle: u,
|
|
403
|
+
welcomeText: x,
|
|
409
404
|
pineconeNamespace: t,
|
|
410
|
-
position:
|
|
411
|
-
|
|
405
|
+
position: d,
|
|
406
|
+
aiInitialMessage: m
|
|
407
|
+
};
|
|
408
|
+
m === "" && (v.aiInitialMessage = `Hello! I'm ${v.name}, your AI assistant. How can I help you today?`);
|
|
409
|
+
const I = d === "left", z = "32px", k = {
|
|
412
410
|
position: "fixed",
|
|
413
411
|
bottom: "104px",
|
|
414
|
-
[
|
|
412
|
+
[I ? "left" : "right"]: z,
|
|
415
413
|
zIndex: 9999,
|
|
416
414
|
pointerEvents: "auto"
|
|
417
|
-
},
|
|
415
|
+
}, W = {
|
|
418
416
|
position: "fixed",
|
|
419
417
|
bottom: "32px",
|
|
420
|
-
[
|
|
418
|
+
[I ? "left" : "right"]: z,
|
|
421
419
|
zIndex: 1e4,
|
|
422
420
|
pointerEvents: "auto"
|
|
423
421
|
};
|
|
424
|
-
return /* @__PURE__ */
|
|
425
|
-
|
|
426
|
-
|
|
422
|
+
return /* @__PURE__ */ c(M, { children: [
|
|
423
|
+
b && /* @__PURE__ */ o("div", { style: k, children: /* @__PURE__ */ o(
|
|
424
|
+
G,
|
|
427
425
|
{
|
|
428
|
-
onClose:
|
|
429
|
-
theme:
|
|
430
|
-
chatBotData:
|
|
426
|
+
onClose: h,
|
|
427
|
+
theme: g,
|
|
428
|
+
chatBotData: v
|
|
431
429
|
}
|
|
432
430
|
) }),
|
|
433
|
-
/* @__PURE__ */ o("div", { style:
|
|
434
|
-
|
|
431
|
+
/* @__PURE__ */ o("div", { style: W, children: /* @__PURE__ */ o(
|
|
432
|
+
A,
|
|
435
433
|
{
|
|
436
|
-
onMinimise:
|
|
437
|
-
isOpen:
|
|
438
|
-
theme:
|
|
439
|
-
chatBotData:
|
|
434
|
+
onMinimise: n,
|
|
435
|
+
isOpen: b,
|
|
436
|
+
theme: g,
|
|
437
|
+
chatBotData: v
|
|
440
438
|
}
|
|
441
439
|
) })
|
|
442
440
|
] });
|
|
443
441
|
};
|
|
444
442
|
export {
|
|
445
|
-
|
|
443
|
+
te as default
|
|
446
444
|
};
|