UNPKG

sandeep-react-chatbotify

Version:

A modern React library for creating flexible and extensible chatbots.

11 lines 93 kB
import"./style.css";import{jsx as u,jsxs as V,Fragment as re}from"react/jsx-runtime";import Dt from"react-dom";import*as B from"react";import{forwardRef as ne,createContext as Se,useContext as ve,Fragment as We,useRef as Q,useState as D,useCallback as P,useEffect as Y,isValidElement as ct,createElement as et,useMemo as fe}from"react";import Ot from"react-dom/server";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))n(s);new MutationObserver(s=>{for(const r of s)if(r.type==="childList")for(const i of r.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&n(i)}).observe(document,{childList:!0,subtree:!0});function o(s){const r={};return s.integrity&&(r.integrity=s.integrity),s.referrerPolicy&&(r.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?r.credentials="include":s.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function n(s){if(s.ep)return;s.ep=!0;const r=o(s);fetch(s.href,r)}})();var je={},tt=Dt;je.createRoot=tt.createRoot,je.hydrateRoot=tt.hydrateRoot;const Z={AUDIO_BUTTON:"audio-button",NOTIFICATION_BUTTON:"notification-button",CLOSE_CHAT_BUTTON:"close-chat-button",SEND_MESSAGE_BUTTON:"send-button",VOICE_MESSAGE_BUTTON:"voice-button",FILE_ATTACHMENT_BUTTON:"file-attachment-button",EMOJI_PICKER_BUTTON:"emoji-button"},Nt=(e,t)=>B.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:32,height:32,viewBox:"0 0 42 42",ref:t,...e},B.createElement("path",{style:{fill:"none",strokeWidth:2,strokeLinecap:"butt",strokeLinejoin:"miter",stroke:"#b00000",strokeOpacity:1,strokeMiterlimit:4},d:"M17 9a8 8 0 0 1-8 8 8 8 0 0 1-8-8 8 8 0 0 1 8-8 8 8 0 0 1 8 8Zm0 0",transform:"rotate(.086) scale(1.77778)"}),B.createElement("path",{style:{fill:"none",strokeWidth:2,strokeLinecap:"butt",strokeLinejoin:"miter",stroke:"#b00000",strokeOpacity:1,strokeMiterlimit:10},d:"M14.66 14.66 3.34 3.34",transform:"rotate(.086) scale(1.77778)"}));ne(Nt);const Pt="/assets/action_disabled_icon-d7e47c78.svg",Lt=(e,t)=>B.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",xmlSpace:"preserve",viewBox:"0 0 1000 1000",ref:t,...e},B.createElement("rect",{width:"100%",height:"100%",fill:"#fff"}),B.createElement("g",null,B.createElement("rect",{width:45,height:30,x:-22.5,y:-15,rx:1.5,ry:1.5,style:{stroke:"none",strokeWidth:1,strokeDasharray:"none",strokeLinecap:"butt",strokeDashoffset:0,strokeLinejoin:"miter",strokeMiterlimit:4,isCustomFont:"none",fontFileUrl:"none",fill:"#37547a",fillRule:"nonzero",opacity:1},transform:"rotate(90 -99 362) scale(3.4003)"}),B.createElement("path",{d:"M0 75q14 0 14 17 0 16-14 16Z",style:{stroke:"none",strokeWidth:1,strokeDasharray:"none",strokeLinecap:"butt",strokeDashoffset:0,strokeLinejoin:"miter",strokeMiterlimit:4,isCustomFont:"none",fontFileUrl:"none",fill:"#98b0ca",fillRule:"nonzero",opacity:1},transform:"rotate(180 106 386) scale(3.4003)"}),B.createElement("rect",{width:25,height:4,x:-12.5,y:-2,rx:.2,ry:.2,style:{stroke:"#46648c",strokeWidth:1,strokeDasharray:"none",strokeLinecap:"butt",strokeDashoffset:0,strokeLinejoin:"miter",strokeMiterlimit:4,isCustomFont:"none",fontFileUrl:"none",fill:"#46648c",fillRule:"nonzero",opacity:1},transform:"rotate(90 -46 282) scale(3.4003)"}),B.createElement("path",{d:"M19 65h4l5 4v1H14v-1Z",style:{stroke:"none",strokeWidth:1,strokeDasharray:"none",strokeLinecap:"butt",strokeDashoffset:0,strokeLinejoin:"miter",strokeMiterlimit:4,isCustomFont:"none",fontFileUrl:"none",fill:"#46648c",fillRule:"nonzero",opacity:1},transform:"translate(165 150) scale(3.4003)"}),B.createElement("rect",{width:25,height:2,x:-12.5,y:-1,rx:.1,ry:.1,style:{stroke:"#98b0ca",strokeWidth:1,strokeDasharray:"none",strokeLinecap:"butt",strokeDashoffset:0,strokeLinejoin:"miter",strokeMiterlimit:4,isCustomFont:"none",fontFileUrl:"none",fill:"#98b0ca",fillRule:"nonzero",opacity:1},transform:"rotate(90 -3 240) scale(3.4003)"}),B.createElement("circle",{r:7.5,style:{stroke:"none",strokeWidth:1,strokeDasharray:"none",strokeLinecap:"butt",strokeDashoffset:0,strokeLinejoin:"miter",strokeMiterlimit:4,isCustomFont:"none",fontFileUrl:"none",fill:"#a478fc",fillRule:"nonzero",opacity:1},transform:"translate(236 175) scale(3.4003)"}),B.createElement("rect",{width:45,height:30,x:-22.5,y:-15,rx:1.5,ry:1.5,style:{stroke:"none",strokeWidth:1,strokeDasharray:"none",strokeLinecap:"butt",strokeDashoffset:0,strokeLinejoin:"miter",strokeMiterlimit:4,isCustomFont:"none",fontFileUrl:"none",fill:"#37547a",fillRule:"nonzero",opacity:1},transform:"rotate(90 139 600) scale(3.4003)"}),B.createElement("path",{d:"M184 75q14 0 14 17 0 16-14 16Z",style:{stroke:"none",strokeWidth:1,strokeDasharray:"none",strokeLinecap:"butt",strokeDashoffset:0,strokeLinejoin:"miter",strokeMiterlimit:4,isCustomFont:"none",fontFileUrl:"none",fill:"#98b0ca",fillRule:"nonzero",opacity:1},transform:"translate(165 150) scale(3.4003)"}),B.createElement("rect",{width:25,height:4,x:-12.5,y:-2,rx:.2,ry:.2,style:{stroke:"#46648c",strokeWidth:1,strokeDasharray:"none",strokeLinecap:"butt",strokeDashoffset:0,strokeLinejoin:"miter",strokeMiterlimit:4,isCustomFont:"none",fontFileUrl:"none",fill:"#46648c",fillRule:"nonzero",opacity:1},transform:"rotate(90 219 548) scale(3.4003)"}),B.createElement("path",{d:"M175 65h4l5 4v1h-14v-1Z",style:{stroke:"none",strokeWidth:1,strokeDasharray:"none",strokeLinecap:"butt",strokeDashoffset:0,strokeLinejoin:"miter",strokeMiterlimit:4,isCustomFont:"none",fontFileUrl:"none",fill:"#46648c",fillRule:"nonzero",opacity:1},transform:"translate(165 150) scale(3.4003)"}),B.createElement("rect",{width:25,height:2,x:-12.5,y:-1,rx:.1,ry:.1,style:{stroke:"#98b0ca",strokeWidth:1,strokeDasharray:"none",strokeLinecap:"butt",strokeDashoffset:0,strokeLinejoin:"miter",strokeMiterlimit:4,isCustomFont:"none",fontFileUrl:"none",fill:"#98b0ca",fillRule:"nonzero",opacity:1},transform:"rotate(90 262 505) scale(3.4003)"}),B.createElement("circle",{r:7.5,style:{stroke:"none",strokeWidth:1,strokeDasharray:"none",strokeLinecap:"butt",strokeDashoffset:0,strokeLinejoin:"miter",strokeMiterlimit:4,isCustomFont:"none",fontFileUrl:"none",fill:"#a478fc",fillRule:"nonzero",opacity:1},transform:"translate(767 175) scale(3.4003)"}),B.createElement("rect",{width:116.7,height:70,x:-58.4,y:-35,rx:31.5,ry:31.5,style:{stroke:"none",strokeWidth:1,strokeDasharray:"none",strokeLinecap:"butt",strokeDashoffset:0,strokeLinejoin:"miter",strokeMiterlimit:4,isCustomFont:"none",fontFileUrl:"none",fill:"#71c9fc",fillRule:"nonzero",opacity:1},transform:"translate(502 877) scale(3.4003)"}),B.createElement("rect",{width:60,height:20,x:-30,y:-10,rx:3,ry:3,style:{stroke:"none",strokeWidth:1,strokeDasharray:"none",strokeLinecap:"butt",strokeDashoffset:0,strokeLinejoin:"miter",strokeMiterlimit:4,isCustomFont:"none",fontFileUrl:"none",fill:"#37547a",fillRule:"nonzero",opacity:1},transform:"translate(502 728) scale(3.4003)"}),B.createElement("circle",{r:75,style:{stroke:"none",strokeWidth:1,strokeDasharray:"none",strokeLinecap:"butt",strokeDashoffset:0,strokeLinejoin:"miter",strokeMiterlimit:4,isCustomFont:"none",fontFileUrl:"none",fill:"#71c9fc",fillRule:"nonzero",opacity:1},transform:"translate(502 473) scale(3.4003)"}),B.createElement("rect",{width:129.4,height:82.3,x:-64.7,y:-41.1,rx:37,ry:37,style:{stroke:"none",strokeWidth:1,strokeDasharray:"none",strokeLinecap:"butt",strokeDashoffset:0,strokeLinejoin:"miter",strokeMiterlimit:4,isCustomFont:"none",fontFileUrl:"none",fill:"#fff",fillRule:"nonzero",opacity:1},transform:"translate(502 464) scale(3.4003)"}),B.createElement("rect",{width:108,height:68.6,x:-54,y:-34.3,rx:30.9,ry:30.9,style:{stroke:"none",strokeWidth:1,strokeDasharray:"none",strokeLinecap:"butt",strokeDashoffset:0,strokeLinejoin:"miter",strokeMiterlimit:4,isCustomFont:"none",fontFileUrl:"none",fill:"#162334",fillRule:"nonzero",opacity:1},transform:"translate(502 464) scale(3.4003)"}),B.createElement("circle",{r:19.4,style:{stroke:"none",strokeWidth:1,strokeDasharray:"none",strokeLinecap:"butt",strokeDashoffset:0,strokeLinejoin:"miter",strokeMiterlimit:4,isCustomFont:"none",fontFileUrl:"none",fill:"#a478fc",fillRule:"nonzero",opacity:1},transform:"translate(415 464) scale(3.4003)"}),B.createElement("circle",{r:19.4,style:{stroke:"none",strokeWidth:1,strokeDasharray:"none",strokeLinecap:"butt",strokeDashoffset:0,strokeLinejoin:"miter",strokeMiterlimit:4,isCustomFont:"none",fontFileUrl:"none",fill:"#a478fc",fillRule:"nonzero",opacity:1},transform:"translate(591 464) scale(3.4003)"}),B.createElement("rect",{width:96,height:53.2,x:-48,y:-26.6,rx:23.9,ry:23.9,style:{stroke:"#162334",strokeWidth:1,strokeDasharray:"none",strokeLinecap:"butt",strokeDashoffset:0,strokeLinejoin:"miter",strokeMiterlimit:4,isCustomFont:"none",fontFileUrl:"none",fill:"#162334",fillRule:"nonzero",opacity:1},transform:"translate(503 875) scale(3.4003)"}),B.createElement("path",{strokeLinecap:"round",d:"m68 215 7-15M81 222l-7-22M81 222l7-14M101 208H87M114 219l-7-24M113 219l13-22M131 214l-5-17M148 214h-18M69 214H51M100 209l7-15",style:{stroke:"#a478fc",strokeWidth:3,strokeDasharray:"none",strokeLinecap:"butt",strokeDashoffset:0,strokeLinejoin:"miter",strokeMiterlimit:10,isCustomFont:"none",fontFileUrl:"none",fill:"none",fillRule:"nonzero",opacity:1},transform:"translate(165 150) scale(3.4003)"})));ne(Lt);const ot="/assets/bot_avatar-10de2bbb.svg",Rt=(e,t)=>B.createElement("svg",{width:140,height:140,xmlns:"http://www.w3.org/2000/svg",ref:t,...e},B.createElement("circle",{cy:60.044,cx:70,fill:"#5c5c5c",r:29}),B.createElement("path",{d:"m16.36 156.186-.01-30.5c-.005-16.844 24.168-30.507 53.991-30.516 29.823-.009 54.004 13.64 54.01 30.484l.008 30.5-108 .032z",fill:"#5c5c5c"}));ne(Rt);const Ht="/assets/user_avatar-6df4531d.svg",Ut=(e,t)=>B.createElement("svg",{viewBox:"0 0 637 637",ref:t,...e},B.createElement("path",{d:"m478 113-13 2-4 1h4l14-2c10-2 35-2 42-1l6 3 3 1c3 0-4-3-8-5-7-1-34-1-44 1m56 6 8 6c7 5 20 17 20 19s7 12 8 12l-3-6-4-6c0-3-15-17-25-24-5-3-8-4-4-1m-198 16-9 1a512 512 0 0 1 9-1m-180 30a412 412 0 0 0-23 4 167 167 0 0 0-32 8 439 439 0 0 1 46-9 304 304 0 0 1 11-2l6-1h-8m369 8 4 3-7-6c-1 0 0 2 3 3m-439 9c-7 3-18 13-18 15l6-5c5-5 9-8 14-10l6-4-8 4m442 12-10 11-7 6 7-6c7-5 14-14 13-16l-3 5M65 205l-1 11c0 9 0 10 4 17 5 10 7 12 22 11 10 0 15 0 38-5l5-1-6 1-16 2-21 2c-13 1-16-1-21-10-3-5-4-6-4-15l1-12c1-4 1-5-1-1m335 1c3 0 3 1 3 3l-2 6c-2 5-35 39-76 80-53 51-120 117-138 137-21 24-22 25-22 27 0 3 6 9 9 9 4 0 14-8 38-27a5073 5073 0 0 1 15-16 1421 1421 0 0 0-17 15l-31 25-6 2-4-3c-3-3-3-4-2-6 3-8 79-85 160-163 57-57 79-80 79-86 0-2-3-4-7-4-2 0-2 0 1 1m165 18c-9 17-25 32-57 53l-10 8 16-11 12-8c15-10 27-22 39-39 5-7 6-8 4-8l-4 5m-221 2a199 199 0 0 0-19 10 183 183 0 0 1 27-12c0-1-1-1-8 2m-34 16c-3 3-2 3 2 0l1-2-3 2m151 3-1 2 2-2c3-3 2-3-1 0m-16 12-11 10a281 281 0 0 0 11-10m-24 18-7 5-7 5-42 31c-10 7-24 19-22 19l7-6 16-12a343 343 0 0 0 35-25 573 573 0 0 0 20-17m-187 0-2 2 4-2 3-2-5 2m-14 6-3 2 4-1 4-3-5 2m-7 3-8 4-18 8 18-7 7-3 3-1c1-2 0-2-2-1m254 24a2672 2672 0 0 1-71 54 601 601 0 0 0 39-29 1352 1352 0 0 1 32-25m-291-8-2 2 4-2 3-2-5 2m-13 5-2 2h3c5-3 4-4-1-2m-19 9-7 3-13 6c-10 5-13 7-14 10-3 4-2 5 1 0 2-3 5-5 14-9l13-6 12-6-6 2m178 36c-17 12-21 16-21 17a390 390 0 0 1 20-17m-206 34 1 4 1 3 1 5 2 8 1 5v-6l-1-8-2-5-1-4-1-2c-1-2-1-2-1 0m222 23-9 7a683 683 0 0 0-56 44 261 261 0 0 0-26 20 1345 1345 0 0 0-46 34c-6 3-7 3-19 3-11 0-12 0-18-3-8-4-10-8-17-20l-5-10 4 10c5 10 12 18 19 22 4 2 6 2 17 2 13 0 14 0 21-3l26-19 42-33a2183 2183 0 0 0 43-34 643 643 0 0 1 24-20",fill:"#fff",fillRule:"evenodd"}),B.createElement("path",{d:"M478 114a620 620 0 0 1-39 6l-21 3a5481 5481 0 0 0-19 3 870 870 0 0 1-54 8l-1 1-6 1-12 2-13 2a992 992 0 0 0-76 12 400 400 0 0 1-45 8l-6 1-5 1h-3l-3 1-2 1-26 4-13 2-17 3c-23 5-33 9-43 19-7 8-9 13-9 27 0 8 1 9 4 14 5 9 8 11 21 10l21-2a1133 1133 0 0 1 23-4 659 659 0 0 0 74-14l3-1h3l3-1h3l2-1 2-1h3l2-1h2l24-5 38-7a2100 2100 0 0 1 93-18l3-1 10-1a2082 2082 0 0 1 120-17l2 1c2 0 8 5 8 7l1 2 1 6c0 4 0 6-3 10-2 4-16 16-18 16l-7 5-10 8a1070 1070 0 0 0-11 7 113 113 0 0 1-20 14l-2 2-3 2-2 2h-1a154 154 0 0 1-28 21l-5 4-5 4a573 573 0 0 1-50 37 175 175 0 0 0-24 18l-1 2-2 1-2 1-2 1-1 1-12 10a396 396 0 0 0-32 25l-8 6-6 5-9 7a326 326 0 0 1-25 20l-13 12a5073 5073 0 0 0-17 15c-24 20-34 27-39 27-2 0-8-6-8-9 0-2 1-3 22-27 18-20 85-86 138-137 41-41 74-75 76-80l2-6c0-2 0-3-2-3l-7 1a233 233 0 0 1-26 9l-1 1-1 1h-1l-1 1h-2l-3 2-1 1h-2l-3 2h-1l-5 2-22 10-9 4-4 2-5 2-10 4-2 1-2 1-2 1-13 6a334 334 0 0 1-38 17 75 75 0 0 0-14 6l-5 2-4 1-2 1-3 2-7 3-16 6a247 247 0 0 0-32 14l-1 1h-2l-1 1h-2l-1 1-12 6a103 103 0 0 0-27 15l-2 5-1 1v11l1 5 1 5 1 4c0 3 0 4 2 4v3l1 3 1 2 2 10 1 4 1 5 2 10 2 8 1 4 1 4c3 3 9 25 11 38l1 7v2l1 4v1l1 1v2l1 2 1 3v1l5 10c7 13 9 16 17 20 6 3 7 3 18 3 12 0 13 0 19-3 8-4 11-6 26-18a1345 1345 0 0 1 85-67 683 683 0 0 1 50-39l12-9a513 513 0 0 1 44-33 201 201 0 0 0 22-17 2270 2270 0 0 0 73-54 158 158 0 0 0 58-59c2 0 3-9 4-27l-1-19-1-4-1-6-1-3-4-6-4-6c0-2-6-8-13-14a77 77 0 0 0-28-18c-6-1-34-1-43 1"})),nt=ne(Ut),Ft=(e,t)=>B.createElement("svg",{viewBox:"0 -960 960 960",ref:t,...e},B.createElement("path",{d:"M765-321q0 117-84 196-83 80-200 80-118 0-200-80t-83-196v-392q0-85 61-144 61-58 146-58 86 0 147 58 61 59 61 144v374q0 54-39 92-39 37-93 37-55 0-93-37-38-38-38-92v-372h110v372q0 9 6 14t15 5q8 0 15-5t7-14v-374q0-39-29-66t-68-27q-40 0-69 27t-29 66v392q0 71 51 119t122 48q71 0 122-48t51-119v-426h111v426Z"})),st=ne(Ft),$t=(e,t)=>B.createElement("svg",{viewBox:"0 -960 960 960",ref:t,...e},B.createElement("path",{d:"M125-165v-113h77v-273q0-93 55-167 56-75 146-100v-19q0-32 22-55 23-23 55-23t55 23q22 23 22 55v19q90 25 146 99 56 73 56 168v273h77v113H125ZM480-32q-38 0-66-27-27-27-27-66h186q0 39-27 66t-66 27Z"})),jt=ne($t),Wt=(e,t)=>B.createElement("svg",{viewBox:"0 -960 960 960",ref:t,...e},B.createElement("path",{d:"M137-190v-113h78v-253q0-41 11-79 11-39 35-71l-9 150h10L17-802l74-74L873-92l-74 74-175-172H137Zm609-149L319-769q20-15 41-25t44-16v-28q0-32 22-54t54-22q32 0 55 22t22 54v28q85 23 137 94t52 160v217ZM481-47q-38 0-65-27t-27-65h184q0 38-27 65t-65 27Z"})),Vt=ne(Wt),qt=(e,t)=>B.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 100 100",ref:t,...e},B.createElement("g",{strokeLinecap:"round",strokeWidth:10},B.createElement("path",{d:"m19 19 61 61M80 19 19 80"}))),Gt=ne(qt),zt=(e,t)=>B.createElement("svg",{viewBox:"0 -960 960 960",ref:t,...e},B.createElement("path",{d:"M94-136v-255l351-93-351-92v-253l816 346L94-136Z"})),Zt=ne(zt),Kt=(e,t)=>B.createElement("svg",{viewBox:"0 -960 960 960",ref:t,...e},B.createElement("path",{d:"M480-372q-61 0-105-43-43-43-43-105v-240q0-61 43-105 43-43 105-43 61 0 105 43 43 44 43 105v240q0 62-43 105t-105 43ZM425-76v-122q-121-16-197-108t-76-214h109q0 91 64 154t155 63q91 0 155-63t64-154h109q0 122-77 214T534-198v122H425Z"})),Yt=ne(Kt),Xt=(e,t)=>B.createElement("svg",{viewBox:"0 -960 960 960",ref:t,...e},B.createElement("path",{d:"m763-343-80-79q8-20 13-44 5-23 5-54h109q0 49-11 95t-36 82ZM625-482 336-770v-2q3-56 45-96t101-40q62 0 105 43t43 105v249l-1 17q-1 7-4 12ZM427-76v-122q-120-16-196-108-77-92-77-214h109q0 91 64 154t155 63q43 0 80-14 37-15 67-41l78 79q-35 32-78 53t-93 28v122H427Zm362 27L41-796l75-75 748 748-75 74Z"})),Jt=ne(Xt),Qt=(e,t)=>B.createElement("svg",{viewBox:"0 -960 960 960",ref:t,...e},B.createElement("path",{d:"M625-511q29 0 50-21t20-50q0-29-20-50-21-20-50-20t-50 20-20 50q0 29 20 50 21 21 50 21Zm-290 0q29 0 50-21t20-49q0-30-20-50t-50-21q-29 0-50 20-20 21-20 50 0 30 20 50 21 21 50 21Zm145 268q75 0 137-43t85-115H258q24 72 85 115 62 43 137 43Zm0 198q-90 0-170-34-79-34-138-93T79-310q-34-80-34-170t34-170q34-79 93-138t138-93q80-34 170-34t170 34q79 34 138 93t93 138q34 80 34 170t-34 170q-34 79-93 138T650-79q-80 34-170 34Zm0-435Zm0 322q134 0 228-94t94-228q0-134-94-228t-228-94q-134 0-228 94t-94 228q0 134 94 228t228 94Z"})),rt=ne(Qt),eo=(e,t)=>B.createElement("svg",{viewBox:"0 -960 960 960",ref:t,...e},B.createElement("path",{d:"M553-64v-108q107-27 173-113 67-87 67-197 0-109-67-195T553-789v-108q152 26 249 144 97 117 97 271 0 155-97 273T553-64ZM61-335v-290h176l236-237v764L237-335H61Zm492 28v-346q51 23 82 70t31 103-31 103q-31 47-82 70Z"})),to=ne(eo),oo=(e,t)=>B.createElement("svg",{viewBox:"0 -960 960 960",ref:t,...e},B.createElement("path",{d:"M807-15 700-123q-33 21-71 37-38 15-80 22v-108q20-4 38-12l35-17-153-154v257L234-335H57v-290h144L10-818l74-75L882-90l-75 75Zm37-264-80-79q13-30 19-60 7-31 7-64 0-109-68-195-67-86-173-112v-108q152 26 249 144 98 117 98 271 0 55-14 107-13 51-38 96ZM661-462 549-575v-78q51 23 83 70 31 47 31 103l-1 9-1 9ZM469-655 366-759l103-103v207Z"})),no=ne(oo),so="/assets/notification_sound-3de350a3.wav",lt={general:{primaryColor:"#42b0c5",secondaryColor:"#491d8d",fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif",showHeader:!0,showFooter:!0,showInputRow:!0,actionDisabledIcon:Pt,embedded:!1,flowStartTrigger:"ON_LOAD"},tooltip:{mode:"CLOSE",text:"Talk to me! 😊"},chatButton:{icon:nt},header:{title:u("div",{style:{cursor:"pointer",margin:0,fontSize:20,fontWeight:"bold"},onClick:()=>window.open("https://github.com/tjtanjin/"),children:"Tan Jin"}),showAvatar:!0,avatar:ot,buttons:[Z.NOTIFICATION_BUTTON,Z.AUDIO_BUTTON,Z.CLOSE_CHAT_BUTTON],closeChatIcon:Gt},notification:{disabled:!1,defaultToggledOn:!0,volume:.2,icon:jt,iconDisabled:Vt,sound:so,showCount:!0},audio:{disabled:!0,defaultToggledOn:!1,language:"en-US",voiceNames:["Microsoft David - English (United States)","Alex (English - United States)"],rate:1,volume:1,icon:to,iconDisabled:no},chatHistory:{disabled:!1,maxEntries:30,storageKey:"rcb-history",storageType:"LOCAL_STORAGE",viewChatHistoryButtonText:"Load Chat History ⟳",chatHistoryLineBreakText:"----- Previous Chat History -----",autoLoad:!1},chatInput:{disabled:!1,allowNewline:!1,enabledPlaceholderText:"Type your message...",disabledPlaceholderText:"",showCharacterCount:!1,characterLimit:-1,botDelay:1e3,sendButtonIcon:Zt,blockSpam:!0,sendOptionOutput:!0,sendCheckboxOutput:!0,buttons:[Z.VOICE_MESSAGE_BUTTON,Z.SEND_MESSAGE_BUTTON]},chatWindow:{showScrollbar:!1,autoJumpToBottom:!1,showMessagePrompt:!0,messagePromptText:"New Messages ↓",messagePromptOffset:30,defaultOpen:!1},sensitiveInput:{maskInTextArea:!0,maskInUserBubble:!0,asterisksCount:10,hideInUserBubble:!1},userBubble:{animate:!0,showAvatar:!1,avatar:Ht,simStream:!1,streamSpeed:30,dangerouslySetInnerHtml:!1},botBubble:{animate:!0,showAvatar:!1,avatar:ot,simStream:!1,streamSpeed:30,dangerouslySetInnerHtml:!1},voice:{disabled:!0,defaultToggledOn:!1,language:"en-US",timeoutPeriod:1e4,autoSendDisabled:!1,autoSendPeriod:1e3,sendAsAudio:!1,icon:Yt,iconDisabled:Jt},footer:{text:V("div",{style:{cursor:"pointer",display:"flex",flexDirection:"row",alignItems:"center",columnGap:3},onClick:()=>window.open("https://react-chatbotify.com"),children:[u("span",{children:"Powered By "},0),u("div",{style:{borderRadius:"50%",width:14,height:14,display:"flex",justifyContent:"center",alignItems:"center",background:"linear-gradient(to right, #42b0c5, #491d8d)"},children:u(nt,{style:{width:"80%",height:"80%",fill:"#fff"}})},1),u("span",{style:{fontWeight:"bold"},children:" React ChatBotify"},2)]}),buttons:[Z.FILE_ATTACHMENT_BUTTON,Z.EMOJI_PICKER_BUTTON]},fileAttachment:{disabled:!1,multiple:!0,accept:".png",icon:st,iconDisabled:st,sendFileName:!0,showMediaDisplay:!1},emoji:{disabled:!1,icon:rt,iconDisabled:rt,list:["😀","😃","😄","😅","😊","😌","😇","🙃","🤣","😍","🥰","🥳","🎉","🎈","🚀","⭐️"]},toast:{maxCount:3,forbidOnMax:!1,dismissOnClick:!0},event:{rcbPreInjectMessage:!1,rcbPostInjectMessage:!1,rcbStartStreamMessage:!1,rcbChunkStreamMessage:!1,rcbStopStreamMessage:!1,rcbRemoveMessage:!1,rcbLoadChatHistory:!1,rcbToggleChatWindow:!1,rcbToggleAudio:!1,rcbToggleNotifications:!1,rcbToggleVoice:!1,rcbChangePath:!1,rcbShowToast:!1,rcbDismissToast:!1,rcbUserSubmitText:!1,rcbUserUploadFile:!1,rcbTextAreaChangeValue:!1,rcbPreLoadChatBot:!1,rcbPostLoadChatBot:!1},ariaLabel:{chatButton:"open chat",audioButton:"toggle audio",closeChatButton:"close chat",emojiButton:"emoji picker",fileAttachmentButton:"upload file",notificationButton:"toggle notifications",sendButton:"send message",voiceButton:"toggle voice",inputTextArea:"input text area"},device:{desktopEnabled:!0,mobileEnabled:!0,applyMobileOptimizations:!0}},ut=Se({settings:{},setSettings:()=>null}),R=()=>ve(ut),ro=({children:e,settings:t=lt,setSettings:o})=>u(ut.Provider,{value:{settings:t,setSettings:o},children:e}),dt={tooltipStyle:{},notificationBadgeStyle:{},chatWindowStyle:{},headerStyle:{},bodyStyle:{},chatInputContainerStyle:{},chatInputAreaStyle:{},chatInputAreaFocusedStyle:{},chatInputAreaDisabledStyle:{},userBubbleStyle:{},botBubbleStyle:{},botOptionStyle:{},botOptionHoveredStyle:{},botCheckboxRowStyle:{},botCheckboxNextStyle:{},botCheckMarkStyle:{},botCheckMarkSelectedStyle:{},characterLimitStyle:{},characterLimitReachedStyle:{},chatHistoryLineBreakStyle:{},chatMessagePromptStyle:{},chatMessagePromptHoveredStyle:{},footerStyle:{},loadingSpinnerStyle:{},mediaDisplayContainerStyle:{},chatButtonStyle:{},chatHistoryButtonStyle:{},chatHistoryButtonHoveredStyle:{},sendButtonStyle:{},sendButtonHoveredStyle:{},sendButtonDisabledStyle:{},audioButtonStyle:{},audioButtonDisabledStyle:{},closeChatButtonStyle:{},emojiButtonStyle:{},emojiButtonDisabledStyle:{},fileAttachmentButtonStyle:{},fileAttachmentButtonDisabledStyle:{},notificationButtonStyle:{},notificationButtonDisabledStyle:{},voiceButtonStyle:{},voiceButtonDisabledStyle:{},chatIconStyle:{},audioIconStyle:{},audioIconDisabledStyle:{},closeChatIconStyle:{},emojiIconStyle:{},emojiIconDisabledStyle:{},fileAttachmentIconStyle:{},fileAttachmentIconDisabledStyle:{},notificationIconStyle:{},notificationIconDisabledStyle:{},voiceIconStyle:{},voiceIconDisabledStyle:{},sendIconStyle:{},sendIconDisabledStyle:{},sendIconHoveredStyle:{},rcbTypingIndicatorContainerStyle:{},rcbTypingIndicatorDotStyle:{},toastPromptContainerStyle:{},toastPromptStyle:{},toastPromptHoveredStyle:{}},ht=Se({styles:{},setStyles:()=>null}),q=()=>ve(ht),ao=({children:e,styles:t=dt,setStyles:o})=>u(ht.Provider,{value:{styles:t,setStyles:o},children:e});const io=({buttons:e})=>{var s,r,i,a,c;const{settings:t}=R(),{styles:o}=q(),n={backgroundImage:`linear-gradient(to right, ${(s=t.general)==null?void 0:s.secondaryColor},
			${(r=t.general)==null?void 0:r.primaryColor})`,...o.headerStyle};return V("div",{style:n,className:"rcb-chat-header-container",children:[V("div",{className:"rcb-chat-header",children:[((i=t.header)==null?void 0:i.showAvatar)&&u("div",{style:{backgroundImage:`url(${(a=t.header)==null?void 0:a.avatar})`},className:"rcb-bot-avatar"}),(c=t.header)==null?void 0:c.title]}),u("div",{className:"rcb-chat-header",children:e==null?void 0:e.map((l,d)=>u(We,{children:l},d))})]})},ft=Se({}),te=()=>ve(ft),co=({children:e,botIdRef:t,flowRef:o})=>{const n=Q(null),s=Q(""),r=Q(new Map),i=Q(null),a=Q(""),c=Q(!1),l=Q(null),d=Q(null),h=Q(null);return u(ft.Provider,{value:{botIdRef:t,flowRef:o,inputRef:n,streamMessageMap:r,chatBodyRef:i,paramsInputRef:a,keepVoiceOnRef:c,audioContextRef:l,audioBufferRef:d,gainNodeRef:h,prevInputRef:s},children:e})},mt=Se({}),ee=()=>ve(mt),lo=({children:e,settings:t})=>{var j,U,G,X,z,K;const[o,n]=D(!1),[s,r]=D(((j=t==null?void 0:t.chatWindow)==null?void 0:j.defaultOpen)??!1),[i,a]=D(((U=t==null?void 0:t.audio)==null?void 0:U.defaultToggledOn)??!1),[c,l]=D(((G=t==null?void 0:t.voice)==null?void 0:G.defaultToggledOn)??!1),[d,h]=D(((X=t==null?void 0:t.notification)==null?void 0:X.defaultToggledOn)??!0),[v,f]=D(!1),[y,w]=D(!1),[S,b]=D(!0),[p,I]=D(!1),[k,m]=D(!1),[T,g]=D(!1),[C,A]=D(0),[M,x]=D(0),[O,E]=D(!1),[_,L]=D(null),[$,W]=D(((z=window.visualViewport)==null?void 0:z.height)??window.innerHeight),[F,H]=D(((K=window.visualViewport)==null?void 0:K.width)??window.innerWidth);return u(mt.Provider,{value:{isBotTyping:o,setIsBotTyping:n,isChatWindowOpen:s,setIsChatWindowOpen:r,audioToggledOn:i,setAudioToggledOn:a,voiceToggledOn:c,setVoiceToggledOn:l,notificationsToggledOn:d,setNotificationsToggledOn:h,isLoadingChatHistory:v,setIsLoadingChatHistory:f,isScrolling:y,setIsScrolling:w,textAreaDisabled:S,setTextAreaDisabled:b,textAreaSensitiveMode:p,setTextAreaSensitiveMode:I,hasInteractedPage:k,setHasInteractedPage:m,hasFlowStarted:T,setHasFlowStarted:g,unreadCount:C,setUnreadCount:A,inputLength:M,setInputLength:x,blockAllowsAttachment:O,setBlockAllowsAttachment:E,timeoutId:_,setTimeoutId:L,viewportHeight:$,setViewportHeight:W,viewportWidth:F,setViewportWidth:H},children:e})};const uo=()=>{var y,w,S;const{settings:e}=R(),{styles:t}=q(),{unreadCount:o,isScrolling:n,setIsScrolling:s}=ee(),{chatBodyRef:r}=te(),[i,a]=D(!1),c={color:(y=e.general)==null?void 0:y.primaryColor,borderColor:(w=e.general)==null?void 0:w.primaryColor,...t.chatMessagePromptHoveredStyle},l=()=>{a(!0)},d=()=>{a(!1)};function h(b){if(!r.current)return;const p=r.current.scrollTop,k=r.current.scrollHeight-r.current.clientHeight-p,m=20;let T=0;function g(){if(!r.current)return;T+=m;const C=v(T,p,k,b);r.current.scrollTop=C,T<b?requestAnimationFrame(g):s(!1)}g()}const v=(b,p,I,k)=>(b/=k/2,b<1?I/2*b*b+p:(b--,-I/2*(b*(b-2)-1)+p));return u("div",{className:`rcb-message-prompt-container ${(()=>{var p;return r.current&&((p=e.chatWindow)==null?void 0:p.showMessagePrompt)&&n&&o>0?"visible":"hidden"})()}`,children:u("div",{onMouseEnter:l,onMouseLeave:d,style:i?c:t.chatMessagePromptStyle,onMouseDown:b=>{b.preventDefault(),h(600)},className:"rcb-message-prompt-text",children:(S=e.chatWindow)==null?void 0:S.messagePromptText})})},N={TOGGLE_AUDIO:"rcb-toggle-audio",TOGGLE_NOTIFICATIONS:"rcb-toggle-notifications",TOGGLE_VOICE:"rcb-toggle-voice",TOGGLE_CHAT_WINDOW:"rcb-toggle-chat-window",PRE_INJECT_MESSAGE:"rcb-pre-inject-message",POST_INJECT_MESSAGE:"rcb-post-inject-message",START_STREAM_MESSAGE:"rcb-start-stream-message",CHUNK_STREAM_MESSAGE:"rcb-chunk-stream-message",STOP_STREAM_MESSAGE:"rcb-stop-stream-message",REMOVE_MESSAGE:"rcb-remove-message",LOAD_CHAT_HISTORY:"rcb-load-chat-history",CHANGE_PATH:"rcb-change-path",SHOW_TOAST:"rcb-show-toast",DISMISS_TOAST:"rcb-dismiss-toast",USER_SUBMIT_TEXT:"rcb-user-submit-text",USER_UPLOAD_FILE:"rcb-user-upload-file",TEXT_AREA_CHANGE_VALUE:"rcb-text-area-change-value",PRE_LOAD_CHATBOT:"rcb-pre-load-chatbot",POST_LOAD_CHATBOT:"rcb-post-load-chatbot"},ho={[N.TOGGLE_AUDIO]:!0,[N.TOGGLE_VOICE]:!0,[N.TOGGLE_NOTIFICATIONS]:!0,[N.TOGGLE_CHAT_WINDOW]:!0,[N.PRE_INJECT_MESSAGE]:!0,[N.POST_INJECT_MESSAGE]:!1,[N.PRE_LOAD_CHATBOT]:!0,[N.POST_LOAD_CHATBOT]:!1,[N.START_STREAM_MESSAGE]:!0,[N.CHUNK_STREAM_MESSAGE]:!0,[N.STOP_STREAM_MESSAGE]:!0,[N.LOAD_CHAT_HISTORY]:!0,[N.CHANGE_PATH]:!0,[N.SHOW_TOAST]:!0,[N.DISMISS_TOAST]:!0,[N.USER_SUBMIT_TEXT]:!0,[N.USER_UPLOAD_FILE]:!0,[N.TEXT_AREA_CHANGE_VALUE]:!0},Me=async(e,t,o)=>{const n=new CustomEvent(e,{detail:t,cancelable:ho[e]});return n.data=o,n.promises=[],window.dispatchEvent(n),await Promise.all(n.promises),n},pt=Se({paths:[],setPaths:()=>null}),Ve=()=>ve(pt),fo=({children:e})=>{const[t,o]=D([]);return u(pt.Provider,{value:{paths:t,setPaths:o},children:e})},Oe=()=>{const{settings:e}=R(),{paths:t,setPaths:o}=Ve(),{setIsBotTyping:n,setTextAreaDisabled:s,setTextAreaSensitiveMode:r,blockAllowsAttachment:i,setBlockAllowsAttachment:a}=ee(),{botIdRef:c}=te(),l=P(()=>t.length>0?t[t.length-1]:null,[t]),d=P(()=>t.length>1?t[t.length-2]:null,[t]),h=P(async f=>{var y,w;if((y=e.event)!=null&&y.rcbChangePath){const S=l(),b=d(),p={botId:c.current,currPath:S,prevPath:b};if(event=await Me(N.CHANGE_PATH,p,{currPath:S,prevPath:b,nextPath:f}),event.defaultPrevented)return!1}return n(!0),(w=e.chatInput)!=null&&w.blockSpam&&s(!0),r(!1),o(S=>[...S,f]),!0},[t,o,e]),v=P(f=>{o(f)},[]);return{getCurrPath:l,getPrevPath:d,goToPath:h,blockAllowsAttachment:i,setBlockAllowsAttachment:a,paths:t,replacePaths:v}},mo=()=>{const{getCurrPath:e,getPrevPath:t,goToPath:o,paths:n,replacePaths:s}=Oe();return{getCurrPath:e,getPrevPath:t,goToPath:o,paths:n,replacePaths:s}},de=()=>{const{getCurrPath:e,getPrevPath:t,paths:o}=mo(),{botIdRef:n}=te();return{callRcbEvent:P(async(r,i)=>{const a={botId:n.current,currPath:e(),prevPath:t()};return await Me(r,a,i)},[o])}},pe=()=>{const{settings:e}=R(),{isChatWindowOpen:t,setIsChatWindowOpen:o,viewportHeight:n,setViewportHeight:s,viewportWidth:r,setViewportWidth:i,setUnreadCount:a}=ee(),{callRcbEvent:c}=de(),[l,d]=D(0),h=P(async()=>{var f;(f=e.event)!=null&&f.rcbToggleChatWindow&&(await c(N.TOGGLE_CHAT_WINDOW,{currState:t,newState:!t})).defaultPrevented||o(y=>(y||a(0),!y))},[t]),v=P(async f=>{t!==f&&await h()},[t]);return{isChatWindowOpen:t,setIsChatWindowOpen:o,toggleChatWindow:h,openChat:v,chatScrollHeight:l,setChatScrollHeight:d,viewportHeight:n,setViewportHeight:s,viewportWidth:r,setViewportWidth:i}},yt=Se({messages:[],setMessages:()=>null}),qe=()=>ve(yt),po=({children:e})=>{const[t,o]=D([]);return u(yt.Provider,{value:{messages:t,setMessages:o},children:e})};const yo=({setChatScrollHeight:e})=>{var I,k,m,T,g,C,A,M,x,O;const{settings:t}=R(),{styles:o}=q(),{messages:n}=qe(),{isChatWindowOpen:s}=pe(),{isBotTyping:r,isScrolling:i,setIsScrolling:a,setUnreadCount:c}=ee(),{chatBodyRef:l}=te(),d={...o==null?void 0:o.bodyStyle,scrollbarWidth:(I=t.chatWindow)!=null&&I.showScrollbar?"auto":"none"},h={backgroundColor:(k=t.general)==null?void 0:k.primaryColor,color:"#fff",maxWidth:(m=t.userBubble)!=null&&m.showAvatar?"65%":"70%",...o.userBubbleStyle},v=(T=t.userBubble)!=null&&T.animate?"rcb-user-message-entry":"",f={backgroundColor:(g=t.general)==null?void 0:g.secondaryColor,color:"#fff",maxWidth:(C=t.botBubble)!=null&&C.showAvatar?"65%":"70%",...o.botBubbleStyle},y=(A=t.botBubble)!=null&&A.animate?"rcb-bot-message-entry":"";Y(()=>{l.current&&(e(l.current.scrollHeight),i||(l.current.scrollTop=l.current.scrollHeight))},[(M=l.current)==null?void 0:M.scrollHeight]);const w=()=>{var W,F;if(!l.current)return;e(l.current.scrollHeight);const{scrollTop:E,clientHeight:_,scrollHeight:L}=l.current,$=E+_<L-(((W=t.chatWindow)==null?void 0:W.messagePromptOffset)??30);a($),$||(E+_>=L-1&&(l.current.scrollTop=L-_-1),(s||(F=t.general)!=null&&F.embedded)&&c(0))},S=E=>E===0?!0:n[E].sender!==n[E-1].sender,b=(E,_)=>{var F,H,j,U;const L=S(_),$=((F=t.userBubble)==null?void 0:F.showAvatar)&&L;let W="rcb-user-message";return!L&&((H=t.userBubble)!=null&&H.showAvatar)&&(W+=" rcb-user-message-offset"),V("div",{className:"rcb-user-message-container",children:[typeof E.content=="string"?(j=t==null?void 0:t.userBubble)!=null&&j.dangerouslySetInnerHtml?u("div",{style:{...h,display:"inline"},className:`${W} ${v}`,dangerouslySetInnerHTML:{__html:E.content}}):u("div",{style:h,className:`${W} ${v}`,children:E.content}):E.content,$&&u("div",{style:{backgroundImage:`url(${(U=t.userBubble)==null?void 0:U.avatar})`},className:"rcb-message-user-avatar"})]})},p=(E,_)=>{var F,H,j,U;const L=S(_),$=((F=t.botBubble)==null?void 0:F.showAvatar)&&L;let W="rcb-bot-message";return!L&&((H=t.botBubble)!=null&&H.showAvatar)&&(W+=" rcb-bot-message-offset"),V("div",{className:"rcb-bot-message-container",children:[$&&u("div",{style:{backgroundImage:`url(${(j=t.botBubble)==null?void 0:j.avatar})`},className:"rcb-message-bot-avatar"}),typeof E.content=="string"?(U=t==null?void 0:t.botBubble)!=null&&U.dangerouslySetInnerHtml?u("div",{style:{...f,display:"inline"},className:`${W} ${y}`,dangerouslySetInnerHTML:{__html:E.content}}):u("div",{style:f,className:`${W} ${y}`,children:E.content}):E.content]})};return V("div",{style:d,className:"rcb-chat-body-container",ref:l,onScroll:w,children:[n.map((E,_)=>E.sender.toUpperCase()==="SYSTEM"?u("div",{children:E.content},_):u("div",{children:E.sender.toUpperCase()==="USER"?b(E,_):p(E,_)},_)),r&&V("div",{className:"rcb-bot-message-container",children:[((x=t.botBubble)==null?void 0:x.showAvatar)&&u("div",{style:{backgroundImage:`url(${(O=t.botBubble)==null?void 0:O.avatar})`},className:"rcb-message-bot-avatar"}),u("div",{onMouseDown:E=>{E.preventDefault()},className:`rcb-bot-message ${y}`,children:V("div",{className:"rcb-typing-indicator",style:{...o==null?void 0:o.rcbTypingIndicatorContainerStyle},children:[u("span",{className:"rcb-dot",style:{...o==null?void 0:o.rcbTypingIndicatorDotStyle}}),u("span",{className:"rcb-dot",style:{...o==null?void 0:o.rcbTypingIndicatorDotStyle}}),u("span",{className:"rcb-dot",style:{...o==null?void 0:o.rcbTypingIndicatorDotStyle}})]})})]}),u(uo,{})]})};const bo=({checkboxes:e,checkedItems:t,path:o})=>{var S,b,p,I,k,m,T,g,C,A,M;const{settings:n}=R(),{styles:s}=q(),{paths:r}=Ve(),{handleSubmitText:i}=Ie(),[a,c]=D(new Set),[l,d]=D(!1),h={cursor:l?`url(${(S=n.general)==null?void 0:S.actionDisabledIcon}), auto`:"pointer",color:(b=n.general)==null?void 0:b.primaryColor,borderColor:(p=n.general)==null?void 0:p.primaryColor,...s.botCheckboxRowStyle},v={cursor:l||a.size<e.min?`url(${(I=n.general)==null?void 0:I.actionDisabledIcon}), auto`:"pointer",color:(k=n.general)==null?void 0:k.primaryColor,borderColor:(m=n.general)==null?void 0:m.primaryColor,...s.botCheckboxNextStyle},f={cursor:l?`url(${(T=n.general)==null?void 0:T.actionDisabledIcon}), auto`:"pointer",color:"transparent",...s.botCheckMarkStyle},y={cursor:l?`url(${(g=n.general)==null?void 0:g.actionDisabledIcon}), auto`:"pointer",color:"#fff",borderColor:(C=n.general)==null?void 0:C.primaryColor,backgroundColor:(A=n.general)==null?void 0:A.primaryColor,...s.botCheckMarkSelectedStyle};Y(()=>{r.length>0&&r[r.length-1]!==o&&d(!e.reusable)},[r]);const w=x=>{l||c(O=>{const E=new Set(O);if(E.has(x))t.delete(x),E.delete(x);else{if(a.size==e.max)return O;t.add(x),E.add(x)}return E})};return V("div",{className:`rcb-checkbox-container ${(M=n.botBubble)!=null&&M.showAvatar?"rcb-checkbox-offset":""}`,children:[e.items.map(x=>u("div",{onMouseDown:O=>{O.preventDefault(),w(x)},style:h,className:"rcb-checkbox-row-container",children:V("div",{className:"rcb-checkbox-row",children:[u("div",{style:a.has(x)?y:f,className:"rcb-checkbox-mark"}),u("div",{className:"rcb-checkbox-label",children:x})]})},x)),u("div",{style:v,className:"rcb-checkbox-next-button",onMouseDown:x=>{var _;if(x.preventDefault(),l||a.size<e.min)return;const O=Array.from(t).join(", ");d(!e.reusable);let E;e.sendOutput!=null?E=e.sendOutput:E=((_=n.chatInput)==null?void 0:_.sendCheckboxOutput)??!0,i(O,E)}})]})},go=async(e,t,o,n)=>{const s=t.checkboxes;if(!s)return;let r;if(typeof s=="function"?(r=s(n),r instanceof Promise&&(r=await r)):r=s,Array.isArray(r)&&(r={items:r}),!("items"in r)||r.items.length==0)return;r.min==null&&(r.min=1),r.max==null&&(r.max=r.items.length),r.min>r.max&&(r.min=r.max),r.reusable==null&&(r.reusable=!1);const a=u(bo,{checkboxes:r,checkedItems:new Set,path:o});await n.injectMessage(a)},So=async(e,t)=>{const o=e.function;if(!o)return;const n=o(t);return n instanceof Promise?await n:n},vo=async(e,t)=>{const o=e.message;if(!o)return;if(typeof o=="string"){o.trim()!==""&&await t.injectMessage(o);return}let n=o(t);n instanceof Promise&&(n=await n),n&&n.trim()!==""&&await t.injectMessage(n)};const wo=({options:e,path:t})=>{var y,w,S,b,p,I;const{settings:o}=R(),{styles:n}=q(),{paths:s}=Ve(),{handleSubmitText:r}=Ie(),[i,a]=D([]),[c,l]=D(!1),d={cursor:c?`url(${(y=o.general)==null?void 0:y.actionDisabledIcon}), auto`:"pointer",color:(w=o.general)==null?void 0:w.primaryColor,borderColor:(S=o.general)==null?void 0:S.primaryColor,backgroundColor:"#fff",...n.botOptionStyle},h={color:"#fff",borderColor:(b=o.general)==null?void 0:b.primaryColor,backgroundColor:(p=o.general)==null?void 0:p.primaryColor,...n.botOptionHoveredStyle};Y(()=>{s.length>0&&s[s.length-1]!==t&&l(!e.reusable)},[s]);const v=k=>{a(m=>{const T=[...m];return T[k]=!0,T})},f=k=>{a(m=>{const T=[...m];return T[k]=!1,T})};return u("div",{className:`rcb-options-container ${(I=o.botBubble)!=null&&I.showAvatar?"rcb-options-offset":""}`,children:e.items.map((k,m)=>{const T=i[m]&&!c;return u("div",{className:"rcb-options",style:T?h:d,onMouseEnter:()=>v(m),onMouseLeave:()=>f(m),onMouseDown:g=>{var A;if(g.preventDefault(),c)return;l(!e.reusable);let C;e.sendOutput!=null?C=e.sendOutput:C=((A=o.chatInput)==null?void 0:A.sendOptionOutput)??!0,r(k,C)},children:k},k)})})},To=async(e,t,o,n)=>{const s=t.options;if(!s)return;let r;if(typeof s=="function"?(r=s(n),r instanceof Promise&&(r=await r)):r=s,Array.isArray(r)&&(r={items:r}),!("items"in r)||r.items.length==0)return;r.reusable==null&&(r.reusable=!1);const i=u(wo,{options:r,path:o});await n.injectMessage(i)},Co=async(e,t,o)=>{const n=e.path;if(!n)return!1;if(typeof n=="string")return o(n);let s=n(t);return s instanceof Promise&&(s=await s),s?o(s):!1},Io=async(e,t)=>{const o=e.component;if(o){if(typeof o=="function"){let n=o(t);if(n instanceof Promise&&(n=await n),!n)return;await t.injectMessage(n);return}await t.injectMessage(o)}},Eo=async(e,t,o,n,s)=>{const r=e[t];if(!r)throw new Error("block is not valid.");const i=r.transition;let a;if(typeof i=="function"?(a=i(o),a instanceof Promise&&(a=await a)):a=i,typeof a=="number"&&(a={duration:a}),!a||a instanceof Promise||a.duration==null||typeof a.duration!="number")return;a.interruptable==null&&(a.interruptable=!1);const c=setTimeout(async()=>{await gt(e,t,o,n)},a.duration);a.interruptable&&s(c)},ko=async(e,t,o)=>{const n=e.chatDisabled;if(n==null)return;let s;typeof n=="function"?(s=n(o),s instanceof Promise&&(s=await s)):s=n,t(s)},bt=async(e,t,o)=>{const n=e.isSensitive;if(!n){t(!1);return}let s;typeof n=="function"?(s=n(o),s instanceof Promise&&(s=await s)):s=n,t(s)},Ao=async(e,t,o,n,s,r,i)=>{const a=e[t];if(!a)throw new Error("Block is not valid.");for(const c of Object.keys(a))switch(c){case"message":await vo(a,o);break;case"options":await To(e,a,t,o);break;case"checkboxes":await go(e,a,t,o);break;case"component":await Io(a,o);break;case"chatDisabled":await ko(a,n,o);break;case"isSensitive":await bt(a,s,o);break;case"transition":await Eo(e,t,o,r,i)}},gt=async(e,t,o,n)=>{const s=e[t];if(!s)throw new Error("Block is not valid.");const r=Object.keys(s);for(const i of r)i==="function"&&await So(s,o);return r.includes("path")?await Co(s,o,n):!1},Bo=e=>{const t=[];let o="",n=!1;for(let s=0;s<e.length;s++){const r=e[s];r==="<"?n?(t.push(o),o=r):(n=!0,o=r):r===">"?(o+=r,t.push(o),o="",n=!1):n?o+=r:t.push(r)}return o!==""&&t.push(o),t},Mo=e=>typeof window.DOMParser<"u"?new DOMParser().parseFromString(e,"text/html").body.textContent||"":e.replace(/<\/?[^>]+(>|$)/g,""),xo=(e,t,o,n,s)=>{if(!window.SpeechSynthesisUtterance){console.info("Speech Synthesis API is not supported in this environment.");return}const r=new window.SpeechSynthesisUtterance;r.text=e,r.lang=t,r.rate=n,r.volume=s;let i=!1;for(const a of o)if(window.speechSynthesis.getVoices().find(c=>{if(c.name===a){r.voice=c,window.speechSynthesis.speak(r),i=!0;return}}),i)break;i||window.speechSynthesis.speak(r)},_o=(e,t,o,n,s)=>{var i,a,c,l,d,h;if((i=e.audio)!=null&&i.disabled||n.sender.toUpperCase()==="USER"||typeof n.content!="string"||!o&&!((a=e.general)!=null&&a.embedded)||!t||n.content.trim()==="")return;let r=n.content;s&&(r=Mo(n.content)),xo(r,(c=e.audio)==null?void 0:c.language,(l=e.audio)==null?void 0:l.voiceNames,(d=e.audio)==null?void 0:d.rate,(h=e.audio)==null?void 0:h.volume)};const Do=()=>{var o;const{settings:e}=R(),{styles:t}=q();return u("div",{className:"rcb-line-break-container",children:u("div",{style:t.chatHistoryLineBreakStyle,className:"rcb-line-break-text","data-testid":"chat-history-line-break-text",children:(o=e.chatHistory)==null?void 0:o.chatHistoryLineBreakText})})};const Oo=()=>{var n;const{settings:e}=R(),{styles:t}=q(),o={borderTop:`4px solid ${(n=e.general)==null?void 0:n.primaryColor}`,...t.loadingSpinnerStyle};return u("div",{className:"rcb-spinner-container",children:u("div",{style:o,className:"rcb-spinner"})})},xe=()=>{try{if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID();throw new Error("crypto.randomUUID not available")}catch{if(typeof crypto<"u"&&typeof crypto.getRandomValues=="function")return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){const o=crypto.getRandomValues(new Uint8Array(1))[0]%16;return(t==="x"?o:o&3|8).toString(16)});throw new Error("crypto.getRandomValues is also not available")}},be=(e,t)=>({id:xe(),content:e,sender:t,type:typeof e=="string"?"string":"object",timestamp:new Date().toUTCString()});let me,St=!1,_e="rcb-history",Ae=30,vt=!1,De=[];const He=async e=>{if(vt||!me)return;const t=[],o=St?De.length:0;for(let s=e.length-1;s>=o;s--){const r=e[s];if(r.sender.toUpperCase()==="SYSTEM"||(r.content!==""&&t.unshift(r),t.length===Ae))break}let n=t.map(Ho);if(n.length<Ae){const s=Ae-n.length;n=[...De.slice(-s),...n]}Po(n)},No=e=>{if(e!=null)try{return JSON.parse(e)}catch{return[]}return[]},wt=()=>De,Po=e=>{me&&me.setItem(_e,JSON.stringify(e))},Lo=()=>{me&&me.removeItem(_e)},Ro=e=>{var t,o,n,s,r;((o=(t=e.chatHistory)==null?void 0:t.storageType)==null?void 0:o.toUpperCase())==="SESSION_STORAGE"?me=sessionStorage:me=localStorage,_e=(n=e.chatHistory)==null?void 0:n.storageKey,Ae=(s=e.chatHistory)==null?void 0:s.maxEntries,vt=(r=e.chatHistory)==null?void 0:r.disabled,De=No(me.getItem(_e))},Ho=e=>ct(e.content)?structuredClone({id:e.id,content:Ot.renderToString(e.content),type:e.type,sender:e.sender.toUpperCase(),timestamp:e.timestamp}):e,Uo=(e,t,o,n,s,r,i)=>{var a;if(St=!0,o!=null)try{n(l=>{const d=be(u(Oo,{}),"SYSTEM");return l.shift(),[d,...l]});const c=o.map(l=>{if(l.type==="object"){const d=Tt(l.content,e,t);return{...l,content:d}}return l});setTimeout(()=>{n(l=>{var h;l.shift();let d;return(h=e.chatHistory)!=null&&h.autoLoad?d=be(u(re,{}),"SYSTEM"):d=be(u(Do,{}),"SYSTEM"),[...c,d,...l]})},500),setTimeout(()=>{if(!s.current)return;const{scrollHeight:l}=s.current,d=l-r;s.current.scrollTop=s.current.scrollTop+d,i(!1)},510)}catch{me.removeItem((a=e.chatHistory)==null?void 0:a.storageKey)}},Tt=(e,t,o)=>{const s=new DOMParser().parseFromString(e,"text/html");return Array.from(s.body.childNodes).map((a,c)=>{var l;if(a.nodeType===Node.TEXT_NODE)return a.textContent;{const d=a.tagName.toLowerCase();let h=Array.from(a.attributes).reduce((f,y)=>{const w=y.name.toLowerCase();if(w==="style"){const S=y.value.split(";").filter(p=>p.trim()!==""),b={};S.forEach(p=>{const[I,k]=p.split(":").map(T=>T.trim()),m=I.replace(/-([a-z])/g,(T,g)=>g.toUpperCase());b[m]=k}),f[w]=b}else(d==="audio"||d==="video")&&w==="controls"&&y.value===""?f[w]="true":f[w]=y.value;return f},{});if(Object.prototype.hasOwnProperty.call(h,"class")){const f=a.classList;h.className=f.toString(),delete h.class,(l=t.botBubble)!=null&&l.showAvatar&&(h=Fo(f,h)),h=$o(f,h,t,o),h=jo(f,h,t,o),h=Wo(f,h,t,o),h=Vo(f,h,t,o)}if(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"].includes(d))return et(d,{key:c,...h});{const f=Tt(a.innerHTML,t,o);return et(d,{key:c,...h},...f)}}})},Fo=(e,t)=>((e.contains("rcb-options-container")||e.contains("rcb-checkbox-container"))&&(t.className=`${e.toString()} rcb-options-offset`),t),$o=(e,t,o,n)=>{var s,r,i,a,c;return e.contains("rcb-options")&&(t.style={...t.style,color:((s=n.botOptionStyle)==null?void 0:s.color)??((r=o.general)==null?void 0:r.primaryColor),borderColor:((i=n.botOptionStyle)==null?void 0:i.color)??((a=o.general)==null?void 0:a.primaryColor),cursor:`url(${(c=o.general)==null?void 0:c.actionDisabledIcon}), auto`,...n.botOptionStyle}),t},jo=(e,t,o,n)=>{var s,r,i,a,c;return e.contains("rcb-checkbox-row-container")&&(t.style={...t.style,color:((s=n.botCheckboxRowStyle)==null?void 0:s.color)??((r=o.general)==null?void 0:r.primaryColor),borderColor:((i=n.botCheckboxRowStyle)==null?void 0:i.color)??((a=o.general)==null?void 0:a.primaryColor),cursor:`url(${(c=o.general)==null?void 0:c.actionDisabledIcon}), auto`,...n.botCheckboxRowStyle}),t},Wo=(e,t,o,n)=>{var s,r,i,a,c;return e.contains("rcb-checkbox-next-button")&&(t.style={...t.style,color:((s=n.botCheckboxNextStyle)==null?void 0:s.color)??((r=o.general)==null?void 0:r.primaryColor),borderColor:((i=n.botCheckboxNextStyle)==null?void 0:i.color)??((a=o.general)==null?void 0:a.primaryColor),cursor:`url(${(c=o.general)==null?void 0:c.actionDisabledIcon}), auto`,...n.botCheckboxNextStyle}),t},Vo=(e,t,o,n)=>{var s,r;return(e.contains("rcb-media-display-image-container")||e.contains("rcb-media-display-video-container"))&&(t.style={...t.style,backgroundColor:(s=o.general)==null?void 0:s.primaryColor,maxWidth:(r=o.userBubble)!=null&&r.showAvatar?"65%":"70%",...n.mediaDisplayContainerStyle}),t},Ct=e=>{if(!e)return!1;const t=e.getBoundingClientRect(),o=window.innerHeight??document.documentElement.clientHeight,n=window.innerWidth??document.documentElement.clientWidth;return t.top>=0&&t.left>=0&&t.bottom<=o&&t.right<=n},Ge=()=>{const{settings:e}=R(),{notificationsToggledOn:t,setNotificationsToggledOn:o,hasInteractedPage:n,unreadCount:s,setUnreadCount:r}=ee(),{audioBufferRef:i,audioContextRef:a,gainNodeRef:c}=te(),{callRcbEvent:l}=de(),d=P(async()=>{var S,b;const f=(S=e.notification)==null?void 0:S.sound;a.current=new AudioContext;const y=a.current.createGain();y.gain.value=((b=e.notification)==null?void 0:b.volume)??.2,c.current=y;let w;if(f!=null&&f.startsWith("data:audio")){const p=atob(f.split(",")[1]),I=new ArrayBuffer(p.length),k=new Uint8Array(I);for(let m=0;m<p.length;m++)k[m]=p.charCodeAt(m);w=I}else w=await(await fetch(f)).arrayBuffer();i.current=await a.current.decodeAudioData(w)},[e.notification]),h=P(()=>{var y;if((y=e.notification)!=null&&y.disabled||!t||!n||!a.current||!i.current)return;const f=a.current.createBufferSource();f.buffer=i.current,f.connect(c.current).connect(a.current.destination),f.start()},[e.notification,t,n,a,i,c]),v=P(async()=>{var f;(f=e.event)!=null&&f.rcbToggleNotifications&&(await l(N.TOGGLE_NOTIFICATIONS,{currState:t,newState:!t})).defaultPrevented||o(y=>!y)},[t]);return{unreadCount:s,setUnreadCount:r,notificationsToggledOn:t,toggleNotifications:v,playNotificationSound:h,setUpNotifications:d}},Ne=()=>{var I,k,m,T;const{settings:e}=R(),{messages:t,setMessages:o}=qe(),{audioToggledOn:n,isChatWindowOpen:s,isScrolling:r,setIsBotTyping:i,setUnreadCount:a}=ee(),{streamMessageMap:c,chatBodyRef:l}=te(),{callRcbEvent:d}=de(),{playNotificationSound:h}=Ge(),v=P(async(g,C,A)=>{g.sender=g.sender.toUpperCase(),i(!1);const M=be("",g.sender);o(L=>{const $=[...L,M];return b($),$});let x=g.content;A&&(x=Bo(x));let O=0;const E=x.length;await new Promise(L=>{const $=setInterval(()=>{if(O>=E){clearInterval($),L();return}o(W=>{const F=[...W];for(let H=F.length-1;H>=0;H--)if(F[H].id===M.id){const j=x[O];j&&(M.content+=j,F[H]=M),O++;break}return F})},C)}),He(t)},[t]),f=P(async(g,C="BOT")=>{var E,_,L,$,W,F,H,j;C=C.toUpperCase();let A=be(g,C);if((E=e.event)!=null&&E.rcbPreInjectMessage){const U=await d(N.PRE_INJECT_MESSAGE,{message:A});if(U.defaultPrevented)return null;A=U.data.message}let M=!1;C==="BOT"?M=(_=e.botBubble)==null?void 0:_.dangerouslySetInnerHtml:C==="USER"&&(M=(L=e.userBubble)==null?void 0:L.dangerouslySetInnerHtml),_o(e,n,s,A,M);const x=typeof A.content=="string"&&A.sender==="BOT"&&(($=e==null?void 0:e.botBubble)==null?void 0:$.simStream),O=typeof A.content=="string"&&A.sender==="USER"&&((W=e==null?void 0:e.userBubble)==null?void 0:W.simStream);if(a(U=>U+1),(F=e.event)!=null&&F.rcbPostInjectMessage&&await d(N.POST_INJECT_MESSAGE,{message:A}),x){const U=(H=e.botBubble)==null?void 0:H.streamSpeed;await v(A,U,M)}else if(O){const U=(j=e.userBubble)==null?void 0:j.streamSpeed;await v(A,U,M)}else o(U=>{const G=[...U,A];return b(G),G});return A.id},[e,n,s,d,v]),y=P(async g=>{var A;const C=t.find(M=>M.id===g);return!C||(A=e.event)!=null&&A.rcbRemoveMessage&&(await d(N.REMOVE_MESSAGE,{message:C})).defaultPrevented?null:(o(M=>{const x=M.filter(O=>O.id!==g);return b(x),x}),a(M=>Math.max(M-1,0)),g)},[d,t,(I=e.event)==null?void 0:I.rcbRemoveMessage]),w=P(async(g,C="BOT")=>{var M,x;if(C=C.toUpperCase(),!c.current.has(C)){const O=be(g,C);return(M=e.event)!=null&&M.rcbStartStreamMessage&&(await d(N.START_STREAM_MESSAGE,{message:O})).defaultPrevented?null:(i(!1),o(E=>{const _=[...E,O];return b(_),[...E,O]}),a(E=>E+1),c.current.set(C,O.id),O.id)}const A={...be(g,C),id:c.current.get(C)};return(x=e.event)!=null&&x.rcbChunkStreamMessage&&(await d(N.CHUNK_STREAM_MESSAGE,A)).defaultPrevented?null:(o(O=>{const E=[...O];for(let _=E.length-1;_>=0;_--)if(E[_].id===A.id){E[_]=A;break}return b(E),E}),c.current.get(C)??null)},[d,(k=e.event)==null?void 0:k.rcbChunkStreamMessage,(m=e.event)==null?void 0:m.rcbStartStreamMessage,c]),S=P(async(g="BOT")=>{var M;if(g=g.toUpperCase(),!c.current.has(g))return!0;const C=c.current.get(g),A=t.find(x=>x.id===C);return(M=e.event)!=null&&M.rcbStopStreamMessage&&(await d(N.STOP_STREAM_MESSAGE,{messageToEndStreamFor:A})).defaultPrevented?!1:(c.current.delete(g),He(t),!0)},[d,t,(T=e.event)==null?void 0:T.rcbStopStreamMessage,c]),b=g=>{var M,x;He(g);let C=!0;(g.length===0||s&&!r)&&(C=!1),(M=e.general)!=null&&M.embedded&&Ct(l.current)&&(C=!1);const A=g[g.length-1];(!A||A.sender.toUpperCase()==="USER")&&(C=!1),C&&h(),((x=e.chatWindow)!=null&&x.autoJumpToBottom||!r)&&setTimeout(()=>{l.current&&(l.current.scrollTop=l.current.scrollHeight)},1)},p=P(g=>{b(g),o(g)},[b]);return{endStreamMessage:S,injectMessage:f,removeMessage:y,streamMessage:w,messages:t,replaceMessages:p}};let Ue,le,Be,ge=!1,ce=null;const ze=()=>{if(!Ue){const e=window.SpeechRecognition||window.webkitSpeechRecognition;Ue=e!=null?new e:null}return Ue},qo=(e,t,o,n,s,r,i)=>{var a;(a=e.voice)!=null&&a.sendAsAudio?zo(o,r):Go(e,t,o,n,s,i)},Go=(e,t,o,n,s,r)=>{var l,d,h;const i=ze();if(!i)return;if(!ge)try{ge=!0,i.lang=(l=e.voice)==null?void 0:l.language,i.start()}catch{}const a=(d=e.voice)==null?void 0:d.timeoutPeriod,c=(h=e.voice)==null?void 0:h.autoSendPeriod;i.onresult=v=>{var y,w;clearTimeout(le),le=null,clearTimeout(Be);const f=v.results[v.results.length-1][0].transcript;if(r.current){const S=(y=e.chatInput)==null?void 0:y.characterLimit,b=r.current.value+f;S!=null&&S>=0&&b.length>S?n(b.slice(0,S)):n(b),s(r.current.value.length)}le=setTimeout(async()=>await Fe(t,r),a),(w=e.voice)!=null&&w.autoSendDisabled||(Be=setTimeout(o,c))},i.onend=()=>{ge?(i.start(),le||(le=setTimeout(async()=>await Fe(t,r),a))):(clearTimeout(le),le=null,clearTimeout(Be))},le=setTimeout(async()=>await Fe(t,r),a)},zo=(e,t)=>{navigator.mediaDevices.getUserMedia({audio:!0}).then(o=>{if(ce=new MediaRecorder(o),!ge)try{ge=!0,ce.start()}catch{}ce.ondataavailable=n=>{t.current&&t.current.push(n.data)},ce.onstop=()=>{e(),o.getTracks().forEach(n=>n.stop())}}).catch(o=>{console.error("Unable to use microphone:",o)})},Ze=()=>{const e=ze();e&&(ge=!1,e&&e.stop(),ce&&ce.state!=="inactive"&&(ce.stop(),ce=null),clearTimeout(le),le=null,clearTimeout(Be))},Zo=(e,t)=>{var n,s,r;const o=ze();(n=t.voice)!=null&&n.disabled||!((s=t.chatInput)!=null&&s.blockSpam)||!o||(e&&!ge?(ge=!0,(r=t.voice)!=null&&r.sendAsAudio?ce==null||ce.start():o.start()):e||Ze())},Fe=async(e,t)=>{var o;(o=t.current)!=null&&o.disabled||await e(),Ze()},Ke=()=>{const{settings:e}=R(),{voiceToggledOn:t,setVoiceToggledOn:o}=ee(),{callRcbEvent:n}=de(),s=P(async()=>{var i;(i=e.event)!=null&&i.rcbToggleVoice&&(await n(N.TOGGLE_VOICE,{currState:t,newState:!t})).defaultPrevented||o(a=>!a)},[t]),r=P(i=>{Zo(i,e)},[e]);return{voiceToggledOn:t,toggleVoice:s,syncVoice:r}},Ce=()=>{const{settings:e}=R(),{inputLength:t,setInputLength:o,textAreaDisabled:n,setTextAreaDisabled:s,textAreaSensitiveMode:r,setTextAreaSensitiveMode:i}=ee(),{inputRef:a,chatBodyRef:c,prevInputRef:l}=te(),{callRcbEvent:d}=de(),h=P(async p=>{var I,k,m;if(n&&a.current){a.current.value="";return}if(a.current&&l.current!==null){const T=(I=e.chatInput)==null?void 0:I.characterLimit,C=((k=e.chatInput)==null?void 0:k.allowNewline)?p:p.replace(/\n/g," ");if(T!=null&&T>=0&&C.length>T?a.current.value=C.slice(0,T):a.current.value=C,(m=e.event)!=null&&m.rcbTextAreaChangeValue&&(await d(N.TEXT_AREA_CHANGE_VALUE,{currValue:a.current.value,prevValue:l.current})).defaultPrevented){a.current.value=l.current;return}l.current=a.current.value}},[n,a,l,e,d]),v=P(p=>{var I;(I=a.current)!=null&&I.disabled||setTimeout(()=>{var k,m,T;(k=e.general)!=null&&k.embedded?Ct(c==null?void 0:c.current)&&((m=a.current)==null||m.focus()):p!=="start"&&((T=a.current)==null||T.focus())},100)},[]),f=P(()=>{!n&&a.current&&a.current.focus()},[n]),y=P(()=>{a.current&&a.current.blur()},[]),w=P(()=>a&&a.current?a.current.value:"",[]),S=P(()=>{s(p=>!p)},[]),b=P(()=>{i(p=>!p)},[]);return{textAreaDisabled:n,setTextAreaDisabled:s,textAreaSensitiveMode:r,setTextAreaSensitiveMode:i,inputLength:t,setInputLength:o,getTextAreaValue:w,setTextAreaValue:h,updateTextAreaFocus:v,focusTextArea:f,blurTextArea:y,toggleTextAreaDisabled:S,toggleTextAreaSensitiveMode:b}},It=Se({toasts:[],setToasts:()=>null}),Et=()=>ve(It),Ko=({children:e})=>{const[t,o]=D([]);return u(It.Provider,{value:{toasts:t,setToasts:o},children:e})},Pe=()=>{const{settings:e}=R(),{toasts:t,setToasts:o}=Et(),{callRcbEvent:n}=de(),s=Q(t);Y(()=>{s.current=t},[t]);const r=P(async(c,l)=>{var y,w,S,b;let d=null;if(s.current.length>=(((y=e.toast)==null?void 0:y.maxCount)??3)){if((w=e.toast)!=null&&w.forbidOnMax)return null;d=xe();let p={id:d,content:c,timeout:l};if((S=e.event)!=null&&S.rcbShowToast){const I=await n(N.SHOW_TOAST,{toast:p});if(I.defaultPrevented)return null;p=I.data.toast}return o(I=>[...I.slice(1),p]),d}d=xe();let f={id:d,content:c,timeout:l};if((b=e.event)!=null&&b.rcbShowToast){const p=await n(N.SHOW_TOAST,{toast:f});if(p.defaultPrevented)return null;f=p.data.toast}return o(p=>[...p,f]),d},[e,n,o]),i=P(async c=>{var d;const l=t.find(h=>h.id===c);return!l||(d=e.event)!=null&&d.rcbDismissToast&&(await n(N.DISMISS_TOAST,{toast:l})).defaultPrevented?null:(o(h=>h.filter(v=>v.id!==c)),c)},[n,o]),a=P(c=>{o(c)},[]);return{showToast:r,dismissToast:i,toasts:t,replaceToasts:a}},Ie=()=>{var _,L,$,W;const{settings:e}=R(),{endStreamMessage:t,injectMessage:o,removeMessage:n,streamMessage:s}=Ne(),{getCurrPath:r,getPrevPath:i,goToPath:a}=Oe(),{timeoutId:c,voiceToggledOn:l,setTextAreaSensitiveMode:d,textAreaSensitiveMode:h,setTextAreaDisabled:v,setIsBotTyping:f,setBlockAllowsAttachment:y,setInputLength:w}=ee(),{flowRef:S,chatBodyRef:b,inputRef:p,keepVoiceOnRef:I,paramsInputRef:k}=te(),{showToast:m,dismissToast:T}=Pe(),{callRcbEvent:g}=de(),{syncVoice:C}=Ke(),{setTextAreaValue:A}=Ce(),{openChat:M}=pe(),x=P(async F=>{var U,G,X;const H=r();if(!(!H||!S.current[H])){if(h){if((U=e==null?void 0:e.sensitiveInput)!=null&&U.hideInUserBubble)return;if((G=e==null?void 0:e.sensitiveInput)!=null&&G.maskInUserBubble){await o("*".repeat(((X=e.sensitiveInput)==null?void 0:X.asterisksCount)??10),"USER");return}}await o(F,"USER")}},[S,r,e,o,h]),O=P(async(F,H,j=!0)=>{var U,G;H=H.trim(),H!==""&&(j&&await x(H),c&&clearTimeout(c),k.current=H,b.current&&(b.current.scrollTop=b.current.scrollHeight),p.current&&(A(""),w(0)),(U=e.chatInput)!=null&&U.blockSpam&&v(!0),I.current=l,C(!1),setTimeout(()=>{f(!0)},400),d(!1),setTimeout(async()=>{var K;const X={prevPath:i(),currPath:r(),goToPath:a,setTextAreaValue:A,userInput:H,injectMessage:o,streamMessage:s,removeMessage:n,endStreamMessage:t,openChat:M,showToast:m,dismissToast:T};if(!await gt(S.current,F,X,a)){const Ee=r();if(!Ee)return;const we=S.current[Ee];if(!we)return;we.chatDisabled||v((K=e.chatInput)==null?void 0:K.disabled),bt(we,d,X),y(typeof we.file=="function"),C(I.current),f(!1)}},(G=e.chatInput)==null?void 0:G.botDelay))},[c,(_=e.chatInput)==null?void 0:_.blockSpam,(L=e.chatInput)==null?void 0:L.botDelay,($=e.chatInput)==null?void 0:$.disabled,I,l,C,x,i,r,a,o,s,n,t,M,m,T,S]);return{handleSubmitText:P(async(F,H=!0)=>{var U,G;if(F=F??((U=p.current)==null?void 0:U.value),(G=e.event)!=null&&G.rcbUserSubmitText&&(await g(N.USER_SUBMIT_TEXT,{inputText:F,sendInChat:H})).defaultPrevented)return;const j=r();j&&O(j,F,H)},[g,r,O,p,(W=e.event)==null?void 0:W.rcbUserSubmitText])}},Le=()=>{var o;const{settings:e}=R();return fe(()=>{var i;if(typeof window>"u"||!window.navigator)return!1;if(!((i=e.device)!=null&&i.applyMobileOptimizations))return!0;const n=navigator.userAgent,s=!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(n),r=window.innerWidth>=768;return s&&r},[(o=e.device)==null?void 0:o.applyMobileOptimizations])};const Yo=({buttons:e})=>{var E,_,L,$,W,F,H,j,U,G,X;const t=Le(),{settings:o}=R(),{styles:n}=q(),{textAreaDisabled:s,textAreaSensitiveMode:r,inputLength:i,hasFlowStarted:a,setHasFlowStarted:c,setInputLength:l}=ee(),{inputRef:d}=te(),[h,v]=D(!1),[f,y]=D(!1),{handleSubmitText:w}=Ie(),{setTextAreaValue:S}=Ce(),b={boxSizing:t?"content-box":"border-box",...n.chatInputAreaStyle},p={outline:s?"":"none",boxShadow:s?"":`0 0 5px ${(E=o.general)==null?void 0:E.primaryColor}`,boxSizing:t?"content-box":"border-box",...n.chatInputAreaStyle,...n.chatInputAreaFocusedStyle},I={cursor:`url(${(_=o.general)==null?void 0:_.actionDisabledIcon}), auto`,caretColor:"transparent",boxSizing:t?"content-box":"border-box",...n.chatInputAreaStyle,...n.chatInputAreaDisabledStyle},k={color:"#989898",...n.characterLimitStyle},m={color:"#ff0000",...n.characterLimitReachedStyle},T=s?(L=o.chatInput)==null?void 0:L.disabledPlaceholderText:($=o.chatInput)==null?void 0:$.enabledPlaceholderText,g=()=>{s||v(!0)},C=()=>{v(!1)},A=()=>{y(!0)},M=()=>{y(!1)},x=async z=>{var K;if(!f&&z.key==="Enter"){if(z.shiftKey){(K=o.chatInput)!=null&&K.allowNewline||z.preventDefault();return}z.preventDefault(),await w()}},O=z=>{d.current&&(S(z.target.value),l(d.current.value.length))};return V("div",{"aria-label":((W=o.ariaLabel)==null?void 0:W.inputTextArea)??"input text area",role:"textbox",onMouseDown:z=>{var K;z.stopPropagation(),!a&&((K=o.general)==null?void 0:K.flowStartTrigger)==="ON_CHATBOT_INTERACT"&&c(!0)},style:n.chatInputContainerStyle,className:"rcb-chat-input",children:[r&&((F=o.sensitiveInput)!=null&&F.maskInTextArea)?u("input",{ref:d,type:"password",className:"rcb-chat-input-textarea",style:s?I:h?p:b,placeholder:T,onChange:O,onKeyDown:x,onFocus:g,onBlur:C,onCompositionStart:A,onCompositionEnd:M}):u("textarea",{ref:d,style:s?I:h?p:b,rows:1,className:"rcb-chat-input-textarea",placeholder:T,onChange:O,onKeyDown:x,onFocus:g,onBlur:C,onCompositionStart:A,onCompositionEnd:M}),V("div",{className:"rcb-chat-input-button-container",children:[e==null?void 0:e.map((z,K)=>u(We,{children:z},K)),((H=o.chatInput)==null?void 0:H.showCharacterCount)&&((j=o.chatInput)==null?void 0:j.characterLimit)!=null&&((U=o.chatInput)==null?void 0:U.characterLimit)>0&&V("div",{className:"rcb-chat-input-char-counter",style:i>=((G=o.chatInput)==null?void 0:G.characterLimit)?m:k,children:[i,"/",(X=o.chatInput)==null?void 0:X.characterLimit]})]})]})};const Xo=({buttons:e})=>{var n;const{settings:t}=R(),{styles:o}=q();return V("div",{"data-testid":"chatbot-footer-container",style:o.footerStyle,className:"rcb-chat-footer-container",children:[u("div",{className:"rcb-chat-footer",children:e==null?void 0:e.map((s,r)=>u(We,{children:s},r))}),u("span",{children:(n=t.footer)==null?void 0:n.text})]})};const Jo=()=>{var c,l,d,h,v,f,y;const{settings:e}=R(),{styles:t}=q(),{unreadCount:o}=ee(),{isChatWindowOpen:n,toggleChatWindow:s}=pe(),r={backgroundImage:`linear-gradient(to right, ${(c=e.general)==null?void 0:c.secondaryColor},
			${(l=e.general)==null?void 0:l.primaryColor})`,...t.chatButtonStyle},i={backgroundImage:`url(${(d=e.chatButton)==null?void 0:d.icon})`,fill:"#fff",width:75,height:75,...t.chatIconStyle},a=()=>{var S;const w=(S=e.chatButton)==null?void 0:S.icon;return!w||typeof w=="string"?u("span",{className:"rcb-toggle-icon",style:i}):w&&u("span",{className:"rcb-toggle-icon",children:u(w,{style:i})})};return u(re,{children:!((h=e.general)!=null&&h.embedded)&&V("div",{"aria-label":((v=e.ariaLabel)==null?void 0:v.chatButton)??"open chat",role:"button",style:r,className:`rcb-toggle-button ${n?"rcb-button-hide":"rcb-button-show"}`,onClick:s,children:[a(),!((f=e.notification)!=null&&f.disabled)&&((y=e.notification)==null?void 0:y.showCount)&&u("span",{style:t.notificationBadgeStyle,className:"rcb-badge",children:o})]})})};const Qo=()=>{var f,y,w,S;const e=Le(),{settings:t}=R(),{styles:o}=q(),{isChatWindowOpen:n,openChat:s}=pe(),[r,i]=D(!1),[a,c]=D(!1),[l,d]=D(0);Y(()=>{var p,I,k;const b=(p=t.tooltip)==null?void 0:p.mode;if(b==="ALWAYS")if(e){let m;n?m=(((I=o.chatWindowStyle)==null?void 0:I.width)??375)-(((k=o.chatButtonStyle)==null?void 0:k.width)??75):m=0,d(m),i(!0)}else i(!n);else b==="NEVER"?i(!1):b==="START"?a?i(!1):(c(!0),i(!0)):b==="CLOSE"&&i(!n)},[n]);const h={transform:`translateX(-${l}px)`,right:(((f=o.chatButtonStyle)==null?void 0:f.width)??75)+40,bottom:30,backgroundColor:(y=t.general)==null?void 0:y.secondaryColor,color:"#fff",...o.tooltipStyle},v={borderColor:`transparent transparent transparent ${h.backgroundColor}`};return u(re,{children:!((w=t.general)!=null&&w.embedded)&&V("div",{"data-testid":"chat-tooltip",style:h,className:`rcb-chat-tooltip ${r?"rcb-tooltip-show":"rcb-tooltip-hide"}`,onClick:()=>s(!0),children:[u("span",{children:(S=t.tooltip)==null?void 0:S.text}),u("span",{className:"rcb-chat-tooltip-tail",style:v})]})})};const en=({id:e,content:t,timeout:o})=>{var v,f;const{settings:n}=R(),{styles:s}=q(),[r]=D({toastPromptStyle:{...s.toastPromptStyle},toastPromptHoveredStyle:{...s.toastPromptHoveredStyle}}),{dismissToast:i}=Pe(),[a,c]=D(!1),l={color:(v=n.general)==null?void 0:v.primaryColor,borderColor:(f=n.general)==null?void 0:f.primaryColor,...r.toastPromptHoveredStyle};return Y(()=>{if(o){const y=setTimeout(()=>{i(e)},o);return()=>clearTimeout(y)}},[e,i,o]),typeof t=="string"?u("div",{onMouseEnter:()=>{c(!0)},onMouseLeave:()=>{c(!1)},style:a?l:r.toastPromptStyle,onMouseDown:async y=>{var w;(w=n.toast)!=null&&w.dismissOnClick&&(y.preventDefault(),await i(e))},className:"rcb-toast-prompt",children:t}):u(re,{children:t})};const tn=()=>{var n,s,r,i;const{styles:e}=q(),{toasts:t}=Et(),o={bottom:(((n=e.footerStyle)==null?void 0:n.height)??50)+(((s=e.chatInputContainerStyle)==null?void 0:s.height)??70)+20,width:300,minWidth:(((r=e.chatWindowStyle)==null?void 0:r.width)??375)/2,maxWidth:(((i=e.chatWindowStyle)==null?void 0:i.width)??375)-50,...e.toastPromptContainerStyle};return u("div",{className:"rcb-toast-prompt-container",style:o,children:t.map(a=>u(en,{id:a.id,content:a.content,timeout:a.timeout},a.id))})};const kt=({file:e,fileType:t,fileUrl:o})=>{var i,a,c;const{settings:n}=R(),{styles:s}=q(),r={backgroundColor:(i=n.general)==null?void 0:i.primaryColor,maxWidth:(a=n.userBubble)!=null&&a.showAvatar?"65%":"70%",...s.mediaDisplayContainerStyle};return u(re,{children:o?V(re,{children:[t==="image"&&o&&u("div",{style:r,className:"rcb-media-display-image-container rcb-media-entry","data-testid":"media-display-image-container",children:u("img",{src:o,alt:"Image Display",className:"rcb-media-display-image"})}),t==="video"&&o&&u("div",{style:r,className:"rcb-media-display-video-container rcb-media-entry","data-testid":"media-display-video-container",children:V("video",{controls:!0,className:"rcb-media-display-video",children:[u("source",{src:o,type:e.type}),"Your browser does not support the video tag."]})}),t==="audio"&&o&&V("audio",{"data-testid":"media-display-audio-container",style:{maxWidth:(c=n.userBubble)!=null&&c.showAvatar?"65%":"70%"},controls:!0,className:"rcb-media-display-audio rcb-media-entry",children:[u("source",{src:o,type:e.type}),"Your browser does not support the audio tag."]})]}):u(re,{})})},At=async e=>{if(!e)return{fileType:null,fileUrl:null};const t=e.type.split("/")[0];if(!["image","video","audio"].includes(t))return{fileType:null,fileUrl:null};try{const o=await new Promise((n,s)=>{const r=new FileReader;r.onload=()=>n(r.result),r.onerror=()=>s(new Error("File reading failed")),r.readAsDataURL(e)});return{fileType:t,fileUrl:o}}catch{return{fileType:null,fileUrl:null}}};const on=()=>{var C,A,M,x,O,E;const{settings:e}=R(),{styles:t}=q(),{injectMessage:o,streamMessage:n,removeMessage:s,endStreamMessage:r}=Ne(),{getCurrPath:i,getPrevPath:a,goToPath:c,blockAllowsAttachment:l}=Oe(),{flowRef:d,inputRef:h}=te(),v=d.current,{showToast:f,dismissToast:y}=Pe(),{callRcbEvent:w}=de(),{openChat:S}=pe(),{setTextAreaValue:b}=Ce(),{handleSubmitText:p}=Ie(),I={cursor:`url(${(C=e.general)==null?void 0:C.actionDisabledIcon}), auto`,...t.fileAttachmentButtonStyle,...t.fileAttachmentButtonDisabledStyle},k={backgroundImage:`url(${(A=e.fileAttachment)==null?void 0:A.icon})`,fill:"#a6a6a6",...t.fileAttachmentIconStyle},m={backgroundImage:`url(${(M=e.fileAttachment)==null?void 0:M.icon})`,fill:"#a6a6a6",...t.fileAttachmentIconStyle,...t.fileAttachmentIconDisabledStyle},T=async _=>{var H,j,U,G;const L=_.target.files;if(!L||(H=e.event)!=null&&H.rcbUserUploadFile&&(await w(N.USER_UPLOAD_FILE,{files:L})).defaultPrevented)return;const $=i();if(!$)return;const W=v[$];if(!W)return;const F=W.file;if(F!=null){const X=[];for(let z=0;z<L.length;z++){if(X.push(L[z].name),!((j=e.fileAttachment)!=null&&j.showMediaDisplay))continue;const K=await At(L[z]);!K.fileType||!K.fileUrl||await o(u(kt,{file:L[z],fileType:K.fileType,fileUrl:K.fileUrl}),"USER")}await p("📄 "+X.join(", "),(U=e.fileAttachment)==null?void 0:U.sendFileName),await F({userInput:(G=h.current)==null?void 0:G.value,prevPath:a(),currPath:i(),goToPath:c,setTextAreaValue:b,injectMessage:o,streamMessage:n,removeMessage:s,endStreamMessage:r,openChat:S,showToast:f,dismissToast:y,files:L})}},g=()=>{var L,$;const _=l?(L=e.fileAttachment)==null?void 0:L.icon:($=e.fileAttachment)==null?void 0:$.iconDisabled;return!_||typeof _=="string"?u("span",{className:l?"rcb-attach-icon-enabled":"rcb-attach-icon-disabled",style:l?k:m}):_&&u("span",{className:l?"rcb-attach-icon-enabled":"rcb-attach-icon-disabled",children:u(_,{style:l?k:m})})};return V("label",{"aria-label":((x=e.ariaLabel)==null?void 0:x.fileAttachmentButton)??"upload file",role:"button",className:l?"rcb-attach-button-enabled":"rcb-attach-button-disabled",style:l?t.fileAttachmentButtonStyle:I,children:[u("input",{className:"rcb-attach-input",role:"file",type:"file",onChange:T,multiple:(O=e.fileAttachment)==null?void 0:O.multiple,accept:(E=e.fileAttachment)==null?void 0:E.accept,disabled:!l}),g()]})};const nn=()=>{var w,S,b,p,I,k;const{settings:e}=R(),{styles:t}=q(),{inputRef:o}=te(),{textAreaDisabled:n,setTextAreaValue:s}=Ce(),r=Q(null),i=Q(null),[a,c]=D(!1),l={cursor:`url(${(w=e.general)==null?void 0:w.actionDisabledIcon}), auto`,...t.emojiButtonStyle,...t.emojiButtonDisabledStyle},d={backgroundImage:`url(${(S=e.emoji)==null?void 0:S.icon})`,fill:"#a6a6a6",...t.emojiIconStyle},h={backgroundImage:`url(${(b=e.emoji)==null?void 0:b.icon})`,fill:"#a6a6a6",...t.emojiIconStyle,...t.emojiIconDisabledStyle};Y(()=>{const m=C=>{const A=C.composedPath();r.current&&!A.includes(r.current)&&i.current&&!A.includes(i.current)&&c(!1)},T=()=>{if(r.current&&i.current){const C=i.current.getBoundingClientRect(),A=r.current.offsetHeight,M=C.top-A-8;r.current.style.left=`${C.left}px`,r.current.style.top=`${M}px`}},g=()=>{T()};return document.addEventListener("mousedown",m),window.addEventListener("resize",g),()=>{document.removeEventListener("mousedown",m),window.removeEventListener("resize",g)}},[]);const v=(m,T)=>{m.preventDefault(),o.current&&(s(o.current.value+T),setTimeout(()=>{const g=o.current;if(g){g.focus();const C=g.value.length;g.setSelectionRange(C,C)}},50)),c(!1)},f=m=>{m.preventDefault(),c(n?!1:!a)},y=()=>{var T,g;const m=n?(T=e.emoji)==null?void 0:T.iconDisabled:(g=e.emoji)==null?void 0:g.icon;return!m||typeof m=="string"?u("span",{className:`${n?"rcb-emoji-icon-disabled":"rcb-emoji-icon-enabled"}`,style:n?h:d}):m&&u("span",{className:`${n?"rcb-emoji-icon-disabled":"rcb-emoji-icon-enabled"}`,children:u(m,{style:n?h:d})})};return V(re,{children:[u("div",{"aria-label":((p=e.ariaLabel)==null?void 0:p.emojiButton)??"emoji picker",role:"button",ref:i,className:`${n?"rcb-emoji-button-disabled":"rcb-emoji-button-enabled"}`,style:n?l:t.emojiButtonStyle,onMouseDown:f,children:y()}),a&&u("div",{className:"rcb-emoji-button-popup",ref:r,children:(k=(I=e.emoji)==null?void 0:I.list)==null?void 0:k.map((m,T)=>u("span",{className:"rcb-emoji",onMouseDown:g=>v(g,m),children:m},T))})]})},sn=()=>{const{settings:e}=R(),{audioToggledOn:t,setAudioToggledOn:o}=ee(),{callRcbEvent:n}=de(),s=P(async()=>{var r;(r=e.event)!=null&&r.rcbToggleAudio&&(await n(N.TOGGLE_AUDIO,{currState:t,newState:!t})).defaultPrevented||o(i=>!i)},[t]);return{audioToggledOn:t,toggleAudio:s}};const rn=()=>{var a,c,l;const{settings:e}=R(),{styles:t}=q(),{audioToggledOn:o,toggleAudio:n}=sn(),s={backgroundImage:`url(${(a=e.audio)==null?void 0:a.icon})`,fill:"#fcec3d",...t.audioIconStyle},r={backgroundImage:`url(${(c=e.audio)==null?void 0:c.iconDisabled})`,fill:"#e8eaed",...t.audioIconStyle,...t.audioIconDisabledStyle},i=()=>{var h,v;const d=o?(h=e.audio)==null?void 0:h.icon:(v=e.audio)==null?void 0:v.iconDisabled;return!d||typeof d=="string"?u("span",{className:"rcb-audio-icon","data-testid":"rcb-audio-icon",style:o?s:r}):d&&u("span",{className:"rcb-audio-icon","data-testid":"rcb-audio-icon",children:u(d,{style:o?s:r,"data-testid":"rcb-audio-icon-svg"})})};return u("div",{"aria-label":((l=e.ariaLabel)==null?void 0:l.audioButton)??"toggle audio",role:"button",onMouseDown:async d=>{d.preventDefault(),await n()},style:o?t.audioButtonStyle:{...t.audioButtonStyle,...t.audioButtonDisabledStyle},children:i()})};const an=()=>{var r,i;const{settings:e}=R(),{styles:t}=q(),{openChat:o}=pe(),n={backgroundImage:`url(${(r=e.header)==null?void 0:r.closeChatIcon})`,fill:"#e8eaed",stroke:"#e8eaed",...t.closeChatIconStyle},s=()=>{var c;const a=(c=e.header)==null?void 0:c.closeChatIcon;return!a||typeof a=="string"?u("span",{className:"rcb-close-chat-icon","data-testid":"rcb-close-chat-icon",style:n}):a&&u("span",{className:"rcb-close-chat-icon","data-testid":"rcb-close-chat-icon",children:u(a,{style:n})})};return u("div",{"aria-label":((i=e.ariaLabel)==null?void 0:i.closeChatButton)??"close chat",role:"button",onMouseDown:a=>{a.stopPropagation(),o(!1)},style:t.closeChatButtonStyle,children:s()})},cn=()=>{const{notificationsToggledOn:e,toggleNotifications:t,playNotificationSound:o}=Ge();return{notificationsToggledOn:e,toggleNotifications:t,playNotificationSound:o}};const ln=()=>{var a,c,l;const{settings:e}=R(),{styles:t}=q(),{notificationsToggledOn:o,toggleNotifications:n}=cn(),s={backgroundImage:`url(${(a=e.notification)==null?void 0:a.icon})`,fill:"#fcec3d",...t.notificationIconStyle},r={backgroundImage:`url(${(c=e.notification)==null?void 0:c.iconDisabled})`,fill:"#e8eaed",...t.notificationIconStyle,...t.notificationIconDisabledStyle},i=()=>{var h,v;const d=o?(h=e.notification)==null?void 0:h.icon:(v=e.notification)==null?void 0:v.iconDisabled;return!d||typeof d=="string"?u("span",{className:"rcb-notification-icon","data-testid":"rcb-notification-icon",style:o?s:r}):d&&u("span",{className:"rcb-notification-icon","data-testid":"rcb-notification-icon",children:u(d,{style:o?s:r,"data-testid":"rcb-notification-icon-svg"})})};return u("div",{"aria-label":((l=e.ariaLabel)==null?void 0:l.notificationButton)??"toggle notifications",role:"button",onMouseDown:async d=>{d.preventDefault(),await n()},style:o?t.notificationButtonStyle:{...t.notificationButtonStyle,...t.notificationButtonDisabledStyle},children:i()})};const un=()=>{var p,I,k;const{settings:e}=R(),{styles:t}=q(),{injectMessage:o}=Ne(),{inputRef:n}=te(),{voiceToggledOn:s,toggleVoice:r}=Ke(),{setInputLength:i,setTextAreaValue:a,textAreaDisabled:c}=Ce(),{handleSubmitText:l}=Ie(),d=Q([]),[h,v]=D(!1);Y(()=>{var m;(m=e.voice)!=null&&m.sendAsAudio?(S(),d.current=[]):l()},[h]),Y(()=>{s?qo(e,r,w,a,i,d,n):Ze()},[s]);const f={backgroundImage:`url(${(p=e.voice)==null?void 0:p.icon})`,fill:"#9aa0a6",...t.voiceIconStyle},y={backgroundImage:`url(${(I=e.voice)==null?void 0:I.iconDisabled})`,fill:"#9aa0a6",...t.voiceIconStyle,...t.voiceIconDisabledStyle},w=()=>{v(m=>!m)},S=async()=>{const m=new Blob(d.current,{type:"audio/wav"}),T=new File([m],"voice-input.wav",{type:"audio/wav"}),g=await At(T);!g.fileType||!g.fileUrl||await o(u(kt,{file:T,fileType:g.fileType,fileUrl:g.fileUrl}),"USER")},b=()=>{var T,g;const m=s?(T=e.voice)==null?void 0:T.icon:(g=e.voice)==null?void 0:g.iconDisabled;return!m||typeof m=="string"?u("span",{className:`rcb-voice-icon${s&&!c?"-on":""}`,"data-testid":"rcb-voice-icon",style:s&&!c?f:y}):m&&u("span",{className:`rcb-voice-icon ${s&&!c?"on":""}`,children:u(m,{style:s&&!c?f:y})})};return u("div",{"aria-label":((k=e.ariaLabel)==null?void 0:k.voiceButton)??"toggle voice",role:"button",onMouseDown:async m=>{m.preventDefault(),!c&&await r()},style:s&&!c?t.voiceButtonStyle:{...t.voiceButtonStyle,...t.voiceButtonDisabledStyle},className:s&&!c?"rcb-voice-button-enabled":"rcb-voice-button-disabled",children:b()})};const dn=()=>{var w,S,b,p,I,k,m,T;const{settings:e}=R(),{styles:t}=q(),{textAreaDisabled:o}=ee(),[n,s]=D(!1),{handleSubmitText:r}=Ie(),i={backgroundColor:(w=e.general)==null?void 0:w.primaryColor,...t.sendButtonStyle},a={cursor:`url(${(S=e.general)==null?void 0:S.actionDisabledIcon}), auto`,backgroundColor:(b=e.general)==null?void 0:b.primaryColor,...t.sendButtonStyle,...t.sendButtonDisabledStyle},c={backgroundColor:(p=e.general)==null?void 0:p.secondaryColor,...t.sendButtonStyle,...t.sendButtonHoveredStyle},l={backgroundImage:`url(${(I=e.chatInput)==null?void 0:I.sendButtonIcon})`,fill:"#fff",...t.sendIconStyle},d={backgroundImage:`url(${(k=e.chatInput)==null?void 0:k.sendButtonIcon})`,fill:"#fff",...t.sendIconStyle,...t.sendIconDisabledStyle},h={backgroundImage:`url(${(m=e.chatInput)==null?void 0:m.sendButtonIcon})`,fill:"#fff",...t.sendIconStyle,...t.sendIconHoveredStyle},v=()=>{s(!0)},f=()=>{s(!1)},y=()=>{var C;const g=(C=e.chatInput)==null?void 0:C.sendButtonIcon;return!g||typeof g=="string"?u("span",{className:"rcb-send-icon","data-testid":"rcb-send-icon",style:o?d:n?h:l}):g&&u("span",{className:"rcb-send-icon","data-testid":"rcb-send-icon",children:u(g,{style:o?d:n?h:l})})};return u("div",{"aria-label":((T=e.ariaLabel)==null?void 0:T.sendButton)??"send message",role:"button",onMouseEnter:v,onMouseLeave:f,onMouseDown:async g=>{g==null||g.preventDefault(),!o&&await r()},style:o?a:n?c:i,className:"rcb-send-button",children:y()})},hn=e=>Object.values(Z).includes(e),fn=(e,t)=>{var c,l,d,h,v,f,y,w,S;const o={[Z.AUDIO_BUTTON]:(c=e.audio)==null?void 0:c.disabled,[Z.CLOSE_CHAT_BUTTON]:(l=e.general)==null?void 0:l.embedded,[Z.EMOJI_PICKER_BUTTON]:(d=e.emoji)==null?void 0:d.disabled,[Z.FILE_ATTACHMENT_BUTTON]:(h=e.fileAttachment)==null?void 0:h.disabled,[Z.NOTIFICATION_BUTTON]:(v=e.notification)==null?void 0:v.disabled,[Z.SEND_MESSAGE_BUTTON]:!1,[Z.VOICE_MESSAGE_BUTTON]:(f=e.voice)==null?void 0:f.disabled},n={},s=b=>b?b.map(p=>{if(typeof p=="string"){if(hn(p)&&!o[p]){if(n[p])return n[p];const I=t[p];if(typeof I=="function"){const k=I();return n[p]=k,k}return null}return null}return p}).filter(p=>p!==null):[],r=s((y=e.header)==null?void 0:y.buttons),i=s((w=e.chatInput)==null?void 0:w.buttons),a=s((S=e.footer)==null?void 0:S.buttons);return{header:r,chatInput:i,footer:a}},mn=()=>u(rn,{}),pn=()=>u(ln,{}),yn=()=>u(an,{}),bn=()=>u(un,{}),gn=()=>u(dn,{}),Sn=()=>u(on,{}),vn=()=>u(nn,{}),wn=()=>{const{settings:e}=R(),t=fe(()=>({[Z.CLOSE_CHAT_BUTTON]:()=>yn(),[Z.AUDIO_BUTTON]:()=>mn(),[Z.NOTIFICATION_BUTTON]:()=>pn(),[Z.EMOJI_PICKER_BUTTON]:()=>vn(),[Z.FILE_ATTACHMENT_BUTTON]:()=>Sn(),[Z.SEND_MESSAGE_BUTTON]:()=>gn(),[Z.VOICE_MESSAGE_BUTTON]:()=>bn()}),[]),{header:o,chatInput:n,footer:s}=fe(()=>fn(e,t),[e,t]),r=fe(()=>o,[o]),i=fe(()=>n,[n]),a=fe(()=>s,[s]);return{headerButtons:r,chatInputButtons:i,footerButtons:a}},Bt=()=>{const{settings:e}=R(),{styles:t}=q(),{setMessages:o}=qe(),{isLoadingChatHistory:n,setIsLoadingChatHistory:s}=ee(),{chatBodyRef:r}=te(),{callRcbEvent:i}=de(),{chatScrollHeight:a}=pe(),c=P(async()=>{var d;const l=wt();l&&((d=e.event)!=null&&d.rcbLoadChatHistory&&(await i(N.LOAD_CHAT_HISTORY,{})).defaultPrevented||(s(!0),Uo(e,t,l,o,r,a,s)))},[e,t,o]);return{isLoadingChatHistory:n,setIsLoadingChatHistory:s,showChatHistory:c}};const Tn=()=>{var c,l,d;const{settings:e}=R(),{styles:t}=q(),{showChatHistory:o}=Bt(),[n,s]=D(!1),r={color:(c=e.general)==null?void 0:c.primaryColor,borderColor:(l=e.general)==null?void 0:l.primaryColor,...t.chatHistoryButtonStyle,...t.chatHistoryButtonHoveredStyle};return u("div",{className:"rcb-view-history-container",children:u("div",{onMouseEnter:()=>{s(!0)},onMouseLeave:()=>{s(!1)},style:n?r:t.chatHistoryButtonStyle,onMouseDown:h=>{h.preventDefault(),o()},className:"rcb-view-history-button",role:"button",tabIndex:0,children:u("p",{children:(d=e.chatHistory)==null?void 0:d.viewChatHistoryButtonText})})})},Cn=()=>{var i;const{settings:e}=R(),{hasInteractedPage:t,setHasInteractedPage:o,hasFlowStarted:n,setHasFlowStarted:s}=ee(),r=P(()=>{var c;if(o(!0),!n&&((c=e.general)==null?void 0:c.flowStartTrigger)==="ON_PAGE_INTERACT"&&s(!0),!window.SpeechSynthesisUtterance){console.info("Speech Synthesis API is not supported in this environment.");return}const a=new window.SpeechSynthesisUtterance;a.text="",a.onend=()=>{window.removeEventListener("click",r),window.removeEventListener("keydown",r),window.removeEventListener("touchstart",r)},window.speechSynthesis.speak(a)},[n,(i=e.general)==null?void 0:i.flowStartTrigger]);return{hasInteractedPage:t,handleFirstInteraction:r}},In=()=>{var Ee,we,Xe,Je;const e=Le(),{settings:t}=R(),{endStreamMessage:o,injectMessage:n,removeMessage:s,streamMessage:r,replaceMessages:i}=Ne(),{getCurrPath:a,getPrevPath:c,goToPath:l,paths:d}=Oe(),{showToast:h,dismissToast:v}=Pe(),{isBotTyping:f,isChatWindowOpen:y,isScrolling:w,hasFlowStarted:S,setIsChatWindowOpen:b,setTextAreaDisabled:p,setAudioToggledOn:I,setVoiceToggledOn:k,setIsBotTyping:m,setTextAreaSensitiveMode:T,setBlockAllowsAttachment:g,setTimeoutId:C}=ee(),{chatBodyRef:A,flowRef:M,streamMessageMap:x,paramsInputRef:O,keepVoiceOnRef:E}=te(),_=M.current,{viewportHeight:L,setViewportHeight:$,setViewportWidth:W,openChat:F}=pe(),{setUpNotifications:H}=Ge(),{handleFirstInteraction:j}=Cn(),{showChatHistory:U}=Bt(),{updateTextAreaFocus:G,setTextAreaValue:X}=Ce(),{syncVoice:z}=Ke(),K=Q(0);Y(()=>(window.addEventListener("click",j),window.addEventListener("keydown",j),window.addEventListener("touchstart",j),()=>{window.removeEventListener("click",j),window.removeEventListener("keydown",j),window.removeEventListener("touchstart",j)}),[]),Y(()=>{var J,oe,ae;H(),p((J=t.chatInput)==null?void 0:J.disabled),b((oe=t.chatWindow)==null?void 0:oe.defaultOpen),I((ae=t.audio)==null?void 0:ae.defaultToggledOn),setTimeout(()=>{var ie;k((ie=t.voice)==null?void 0:ie.defaultToggledOn)},1)},[]),Y(()=>{!w&&(A!=null&&A.current)&&(A.current.scrollTop=A.current.scrollHeight)},[f]),Y(()=>{var J,oe;if((J=t.chatHistory)!=null&&J.disabled)Lo();else if(Ro(t),wt().length>0){const ie=be(u(Tn,{}),"SYSTEM");i([ie]),(oe=t.chatHistory)!=null&&oe.autoLoad&&U()}},[(Ee=t.chatHistory)==null?void 0:Ee.storageKey,(we=t.chatHistory)==null?void 0:we.maxEntries,(Xe=t.chatHistory)==null?void 0:Xe.disabled]),Y(()=>{var J;e||(J=t.general)!=null&&J.embedded||!navigator.virtualKeyboard||(navigator.virtualKeyboard.overlaysContent=!0,navigator.virtualKeyboard.addEventListener("geometrychange",oe=>{if(!oe.target)return;const{x:ae,y:ie,width:Te,height:he}=oe.target.boundingRect;ae==0&&ie==0&&Te==0&&he==0?(setTimeout(()=>{var se;$((se=window.visualViewport)==null?void 0:se.height)},101),setTimeout(()=>{var se,ye;L!=((se=window.visualViewport)==null?void 0:se.height)&&$((ye=window.visualViewport)==null?void 0:ye.height)},1001)):setTimeout(()=>{var se;$(((se=window.visualViewport)==null?void 0:se.height)-he)},101)}))},[e]),Y(()=>{var Te,he,se,ye;if(e)return;y&&($((Te=window.visualViewport)==null?void 0:Te.height),W((he=window.visualViewport)==null?void 0:he.width));const J=()=>window.scrollTo({top:0,left:0,behavior:"auto"}),oe=()=>K.current=window.scrollY,ae=()=>{var ke,Qe;$((ke=window.visualViewport)==null?void 0:ke.height),W((Qe=window.visualViewport)==null?void 0:Qe.width)},ie=()=>{var ke;window.removeEventListener("scroll",J),window.removeEventListener("scroll",oe),(ke=window.visualViewport)==null||ke.removeEventListener("resize",ae)};return y?(ie(),document.body.style.position="fixed",window.addEventListener("scroll",J),(se=window.visualViewport)==null||se.addEventListener("resize",ae)):(document.body.style.position="static",ie(),window.scrollTo({top:K.current,left:0,behavior:"auto"}),window.addEventListener("scroll",oe),(ye=window.visualViewport)==null||ye.removeEventListener("resize",ae)),ie},[y,e]),Y(()=>{const J=a();if(!J)return;const oe=_[J];if(!oe){m(!1);return}const ae={prevPath:c(),currPath:a(),goToPath:l,setTextAreaValue:X,userInput:O.current,endStreamMessage:o,injectMessage:n,removeMessage:s,streamMessage:r,openChat:F,showToast:h,dismissToast:v};(async(Te,he,se)=>{var ye;await Ao(_,Te,se,p,T,l,C),m(!1),"chatDisabled"in he||p((ye=t.chatInput)==null?void 0:ye.disabled),g(typeof he.file=="function"),G(Te),z(E.current&&!he.chatDisabled),x.current.clear()})(J,oe,ae)},[d]),Y(()=>{var J;(S||((J=t.general)==null?void 0:J.flowStartTrigger)==="ON_LOAD")&&l("start")},[S,(Je=t.general)==null?void 0:Je.flowStartTrigger])},Ye={DEFAULT_URL:"https://cdn.jsdelivr.net/gh/tjtanjin/react-chatbotify-themes/themes",DEFAULT_EXPIRATION:"2592000",CACHE_KEY_PREFIX:"RCB_THEME_CACHE_DATA"},En=Ye.DEFAULT_URL,kn=Ye.DEFAULT_EXPIRATION,Mt=Ye.CACHE_KEY_PREFIX,An=(e,t,o)=>{const n=localStorage.getItem(`${Mt}_${e}_${t}`);if(!n)return null;try{const s=JSON.parse(n),r=new Date().getTime(),i=Math.floor(r/1e3);return s.cacheDate+o>=i?s:null}catch(s){return console.error(`Unable to fetch cache for ${e}`,s),null}},Bn=(e,t,o,n,s)=>{const r=new Date().getTime(),i=Math.floor(r/1e3),a={settings:o,inlineStyles:n,cssStylesText:s,cacheDate:i};localStorage.setItem(`${Mt}_${e}_${t}`,JSON.stringify(a))},Mn=async(e,t)=>{const o=`${t}/${e}/meta.json`;try{const n=await fetch(o);return n.ok?(await n.json()).version:(console.error(`Failed to fetch meta.json from ${o}`),null)}catch(n){return console.error(`Failed to fetch meta.json from ${o}`,n),null}},at=async(e,t)=>{const{id:o,version:n,baseUrl:s=En,cacheDuration:r=kn}=t,i=n||await Mn(o,s);if(!i)return console.error(`Unable to find version for theme: ${o}`),{settings:{},inlineStyles:{},cssStylesText:""};const a=An(o,i,r);if(a){const p=it(e,a.cssStylesText);return{settings:a.settings,inlineStyles:a.inlineStyles,cssStylesText:p}}const c=`${s}/${o}/${i}/styles.css`,l=`${s}/${o}/${i}/settings.json`,d=`${s}/${o}/${i}/styles.json`;let h="";const v=await fetch(c);v.ok?h=await v.text():console.info(`Could not fetch styles.css from ${c}`);const f=await fetch(l);let y={};f.ok?y=await f.json():console.info(`Could not fetch settings.json from ${l}`);const w=await fetch(d);let S={};w.ok?S=await w.json():console.info(`Could not fetch styles.json from ${d}`),Bn(o,i,y,S,h);const b=it(e,h);return{settings:y,inlineStyles:S,cssStylesText:b}},it=(e,t)=>t.split(new RegExp("(?<=})")).map(n=>{const s=n.trim();return s.startsWith("@import")||s.startsWith("@keyframes")||s.startsWith("@media")?s:s?`#${e} ${s}`:""}).join(`
`),xn=()=>Re(lt),_n=()=>Re(dt),Dn=async(e,t,o,n)=>{var a,c;let s=xn(),r=_n(),i="";if(n!=null)if(Array.isArray(n))for(const l of n){const d=await at(e,l);s=ue(d.settings,s),r=ue(d.inlineStyles,r),i+=d.cssStylesText}else{const l=await at(e,n);s=ue(l.settings,s),r=ue(l.inlineStyles,r),i+=l.cssStylesText}return t!=null&&(s=ue(t,s)),o!=null&&(r=ue(o,r)),((a=s.chatInput)==null?void 0:a.botDelay)!=null&&((c=s.chatInput)==null?void 0:c.botDelay)<500&&(s.chatInput.botDelay=500),{settings:s,inlineStyles:r,cssStylesText:i}},ue=(e,t)=>{const o=[{source:e,target:t}];for(;o.length;){const n=o.pop();if(n==null)continue;const{source:s,target:r}=n;for(const i of Object.keys(s)){const a=i;if(ct(s[a]))r[a]=s[a];else if(typeof s[a]=="object"&&s[a]!==null&&!Array.isArray(s[a]))(typeof r[a]!="object"||r[a]===null)&&(r[a]={}),o.push({source:s[a],target:r[a]});else try{r[a]=s[a]}catch{}}}return t},Re=e=>{if(e===null||typeof e!="object")return e;const t=Array.isArray(e)?[]:{},o=[{source:e,target:t}],n=new WeakMap;for(n.set(e,t);o.length;){const s=o.pop();if(s==null)continue;const{source:r,target:i}=s;for(const a in r)if(Object.prototype.hasOwnProperty.call(r,a)){const c=r[a];if(c&&typeof c=="object")if(n.has(c))i[a]=n.get(c);else{const l=Array.isArray(c)?[]:{};n.set(c,l),i[a]=l,o.push({source:c,target:l})}else i[a]=c}}return t},On=()=>{const{settings:e,setSettings:t}=R(),o=P(s=>{!s||Object.keys(s).length===0||t(Re(ue(s,e)))},[e]),n=P(s=>{t(s)},[]);return{settings:e,replaceSettings:n,updateSettings:o}},Nn=()=>{const{styles:e,setStyles:t}=q(),o=P(s=>{!s||Object.keys(s).length===0||t(Re(ue(s,e)))},[e]),n=P(s=>{t(s)},[]);return{styles:e,replaceStyles:n,updateStyles:o}},Pn=e=>{const{updateSettings:t}=On(),{updateStyles:o}=Nn(),n=e==null?void 0:e.map(s=>s());Y(()=>{let s={},r={};n==null||n.forEach(i=>{i!=null&&i.settings&&Object.keys(i==null?void 0:i.settings).length!==0&&(s=ue(i.settings,s)),i!=null&&i.styles&&Object.keys(i==null?void 0:i.styles).length!==0&&(r=ue(i.styles,r))}),t(s),o(r)},[e])};const Ln=({plugins:e})=>{var b,p,I,k;const t=Le(),{settings:o}=R(),{styles:n}=q(),{hasFlowStarted:s,setHasFlowStarted:r}=ee(),{inputRef:i}=te(),{setChatScrollHeight:a,viewportHeight:c,viewportWidth:l,isChatWindowOpen:d}=pe(),{headerButtons:h,chatInputButtons:v,footerButtons:f}=wn();In(),Pn(e);const y=fe(()=>{var T;const m="rcb-chatbot-global ";return(T=o.general)!=null&&T.embedded?m+"rcb-window-embedded":d?m+"rcb-window-open":m+"rcb-window-close"},[o,d]),w=()=>{var m,T;return!t&&!((m=o.general)!=null&&m.embedded)?{...n.chatWindowStyle,borderRadius:"0px",left:"0px",right:"auto",top:"0px",bottom:"auto",width:`${l}px`,height:`${c}px`,zIndex:1e4}:(T=o.general)!=null&&T.embedded?n.chatWindowStyle:{...n.chatWindowStyle,zIndex:1e4}};return u(re,{children:(()=>{var m,T;return t&&((m=o.device)==null?void 0:m.desktopEnabled)||!t&&((T=o.device)==null?void 0:T.mobileEnabled)})()&&V("div",{onMouseDown:m=>{var T,g;!s&&((T=o.general)==null?void 0:T.flowStartTrigger)==="ON_CHATBOT_INTERACT"&&r(!0),t?(g=i.current)==null||g.blur():m==null||m.preventDefault()},className:y,children:[u(Qo,{}),u(Jo,{}),d&&!t&&!((b=o.general)!=null&&b.embedded)&&V(re,{children:[u("style",{children:`
									html {
										overflow: hidden !important;
										touch-action: none !important;
										scroll-behavior: auto !important;
									}
								`}),u("div",{style:{position:"fixed",top:0,left:0,width:"100%",height:"100%",backgroundColor:"#fff",zIndex:9999}})]}),V("div",{style:w(),className:"rcb-chat-window",children:[((p=o.general)==null?void 0:p.showHeader)&&u(io,{buttons:h}),u(yo,{setChatScrollHeight:a}),u(tn,{}),((I=o.general)==null?void 0:I.showInputRow)&&u(Yo,{buttons:v}),((k=o.general)==null?void 0:k.showFooter)&&u(Xo,{buttons:f})]})]})})},xt=Se(void 0),_t=()=>ve(xt),Rn=({children:e})=>{var d;const t=Q(""),o=Q({}),[n,s]=D({}),[r,i]=D({}),[a,c]=D(!1);Y(()=>{c(!0)},[]);const l=async(h,v,f,y,w,S)=>{t.current=h,o.current=v;const b=await Dn(h,f,y,w);S.current&&(S.current.textContent=b.cssStylesText),s(b.settings),i(b.inlineStyles)};return a?u("div",{style:{fontFamily:(d=n.general)==null?void 0:d.fontFamily},children:u(xt.Provider,{value:{loadConfig:l},children:u(ro,{settings:n,setSettings:s,children:u(ao,{styles:r,setStyles:i,children:u(Ko,{children:u(co,{botIdRef:t,flowRef:o,children:u(fo,{children:u(lo,{settings:n,children:u(po,{children:e})})})})})})})})}):null},Hn=({id:e,flow:t,settings:o,styles:n,themes:s,plugins:r,setConfigLoaded:i,styleRootRef:a})=>{const c=fe(()=>e,[]),l=_t(),{flowRef:d}=te();d&&d.current!==t&&(d.current=t);const h=async()=>{var v,f;(v=o.event)!=null&&v.rcbPreLoadChatBot&&(await Me(N.PRE_LOAD_CHATBOT,{botId:c,currPath:null,prevPath:null},{flow:t,settings:o,styles:n,themes:s,plugins:r})).defaultPrevented||(l!=null&&l.loadConfig&&(await l.loadConfig(c,t,o,n,s,a),i(!0)),(f=o.event)!=null&&f.rcbPostLoadChatBot&&Me(N.POST_LOAD_CHATBOT,{botId:c,currPath:null,prevPath:null},{flow:t,settings:o,styles:n,themes:s,plugins:r}))};return Y(()=>{h()},[s]),null},$e=["Quickstart","API Docs","Examples","Github","Discord"],Un={start:{message:"Hello, I am Tan Jin 👋! Welcome to React ChatBotify, I'm excited that you are using our chatbot 😊!",transition:{duration:1e3},chatDisabled:!0,path:"show_options"},show_options:{message:"It looks like you have not set up a conversation flow yet. No worries! Here are a few helpful things you can check out to get started:",options:$e,path:"process_options"},prompt_again:{message:"Do you need any other help?",options:$e,path:"process_options"},unknown_input:{message:"Sorry, I do not understand your message 😢! If you require further assistance, you may click on the Github option and open an issue there or visit our discord.",options:$e,path:"process_options"},process_options:{transition:{duration:0},path:e=>{let t="";switch(e.userInput){case"Quickstart":t="https://react-chatbotify.com/docs/introduction/quickstart/";break;case"API Docs":t="https://react-chatbotify.com/docs/api/bot_options";break;case"Examples":t="https://react-chatbotify.com/docs/examples/basic_form";break;case"Github":t="https://github.com/tjtanjin/react-chatbotify/";break;case"Discord":t="https://discord.gg/6R4DK4G5Zh";break;default:return"unknown_input"}return e.injectMessage("Sit tight! I'll send you right there!"),setTimeout(()=>{window.open(t)},1e3),"repeat"}},repeat:{transition:{duration:3e3},path:"prompt_again"}},Fn=({id:e,flow:t,settings:o,styles:n,themes:s,plugins:r})=>{const i=fe(()=>e||"rcb-"+xe(),[]),a=!t||Object.keys(t).length===0?Un:t,c=o||{},l=n||{},d=r||[],[h,v]=D(!1),f=_t(),y=Q(null),[w,S]=D(s||[]);Y(()=>{s&&S(s)},[s]);const b=()=>V(re,{children:[u(Hn,{styleRootRef:y,id:i,flow:a,settings:c,styles:l,themes:w,plugins:d,setConfigLoaded:v}),h&&u(Ln,{plugins:r})]});return f==null?V(Rn,{children:[u("style",{ref:y}),u("div",{id:i,children:b()})]}):V(re,{children:[u("style",{ref:y}),u("div",{id:i,children:b()})]})};function $n(){const[e,t]=D("");return u("div",{className:"App",children:u("header",{className:"App-header",children:u("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",marginTop:"calc(20vh)"},children:u(Fn,{id:"chatbot-id",flow:{start:{message:"Hello! What is your name?",path:"show_name"},show_name:{message:n=>`Hey ${n.userInput}! Nice to meet you.`,function:n=>t(n.userInput),transition:{duration:1e3},path:"ask_token"},ask_token:{message:()=>"Before we proceed, we need to verify your profile id, Enter your 6 digit profile id",isSensitive:!0,path:n=>n.userInput.length!==6?"incorrect_answer":"ask_age_group"},ask_age_group:{message:()=>`Hey ${e}!, Your account got verified, May i know your age group?`,options:["child","teen","adult"],chatDisabled:!0,path:()=>"ask_math_question"},ask_math_question:{message:n=>{if(n.prevPath!="incorrect_answer")return`I see you're a ${n.userInput}. Let's do a quick test! What is 1 + 1?`},path:n=>n.userInput!="2"?"incorrect_answer":"ask_favourite_color"},ask_favourite_color:{message:"Great Job! What is your favourite color?",path:"ask_favourite_pet"},ask_favourite_pet:{message:"Interesting! Pick any 2 pets below.",checkboxes:{items:["Dog","Cat","Rabbit","Hamster"],min:2,max:2},function:n=>alert(`You picked: ${JSON.stringify(n.userInput)}!`),chatDisabled:!0,path:"ask_height"},ask_height:{message:"What is your height (cm)?",path:async n=>{if(isNaN(Number(n.userInput))){await n.injectMessage("Height needs to be a number!");return}return"ask_weather"}},ask_weather:{message:n=>{if(n.prevPath!="incorrect_answer")return"What's my favourite color? Click the button below to find out my answer!"},component:u("div",{style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"center",marginTop:10},children:u("button",{className:"secret-fav-color",onClick:()=>alert("black"),children:"Click me!"})}),path:async n=>n.userInput.toLowerCase()!="black"?"incorrect_answer":(await n.openChat(!1),"close_chat")},close_chat:{message:"I went into hiding but you found me! Ok tell me, <b class='bold'>what's your favourite food?</b>",path:"ask_image"},ask_image:{message:n=>`${n.userInput}? Interesting. Could you share an image of that?`,file:n=>console.log(n.files),function:n=>n.showToast("Image is uploaded successfully!"),path:"end"},end:{message:"Thank you for sharing! See you again!",path:"loop"},loop:{message:n=>{setTimeout(async()=>{await n.injectMessage("You have reached the end of the conversation!")},500)},path:"loop"},incorrect_answer:{message:"Your answer is incorrect, try again!",transition:{duration:0},path:n=>n.prevPath}},settings:{audio:{disabled:!1},chatInput:{botDelay:1e3},userBubble:{showAvatar:!0,dangerouslySetInnerHtml:!0},botBubble:{showAvatar:!0,dangerouslySetInnerHtml:!0},voice:{disabled:!1},sensitiveInput:{asterisksCount:6}}})})})})}const jn=je.createRoot(document.getElementById("root"));jn.render(u($n,{}));