@careshiphealth/widget 2.1.95 → 2.1.96

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -140,7 +140,7 @@ object-assign
140
140
  );
141
141
 
142
142
  }
143
- `})}),E.jsx("div",{className:"font_graphik",children:n.isError?null:e})]})},h0=()=>F.useContext(gU),lU=({color:e="black",size:A="90"})=>E.jsxs("svg",{className:"z-10",width:A,height:A,viewBox:"0 0 90 90",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[E.jsxs("g",{filter:"url(#filter0_d_14507_743)",children:[E.jsx("rect",{x:"8",y:"8",width:"74",height:"74",rx:"37",fill:"#7E22FF"}),E.jsx("rect",{x:"8.25",y:"8.25",width:"73.5",height:"73.5",rx:"36.75",stroke:"#C2C2C2","stroke-width":"0.5"})]}),E.jsx("path",{d:"M33.0264 50.6909C34.2841 49.9636 35.8716 50.3206 36.7041 51.4731L36.8604 51.7144C38.6734 54.8437 42.0381 56.9311 45.8965 56.9312C49.6341 56.9312 52.9149 54.9696 54.7588 52.0073L54.9326 51.7183V51.7173C55.6595 50.4583 57.2157 49.9756 58.5137 50.5601L58.7695 50.6919C60.027 51.4194 60.5092 52.9758 59.9258 54.2739L59.7949 54.5298C58.4741 56.8162 56.6109 58.7391 54.373 60.1304L53.9199 60.4009C51.4803 61.8085 48.7131 62.5492 45.8965 62.5483L45.3691 62.5405C42.9112 62.4596 40.5049 61.8138 38.3359 60.6548L37.875 60.3989C35.5885 59.0788 33.6652 57.2163 32.2734 54.979L32.002 54.5269V54.5259L31.8701 54.27C31.3246 53.0599 31.7086 51.6248 32.7852 50.8472L33.0264 50.6909ZM31.0068 31.9634H35.9697C37.5209 31.9634 38.7781 33.2208 38.7783 34.772C38.7783 36.3233 37.5211 37.5815 35.9697 37.5815H34.3154C33.1255 37.5815 32.1611 38.546 32.1611 39.7358C32.1611 40.3732 31.6442 40.8899 31.0068 40.8901H29.3516C27.8005 40.8899 26.5431 39.6326 26.543 38.0815V36.4272L26.5488 36.1968C26.6685 33.8386 28.6189 31.9634 31.0068 31.9634ZM57.4775 31.9634H62.4414C63.9926 31.9634 65.2498 33.2208 65.25 34.772C65.25 36.3233 63.9927 37.5815 62.4414 37.5815H60.7871C59.5972 37.5815 58.6328 38.546 58.6328 39.7358C58.6328 40.3734 58.1151 40.8901 57.4775 40.8901H55.8232C54.2721 40.89 53.0148 39.6327 53.0146 38.0815V36.4272C53.0146 33.9623 55.0126 31.9636 57.4775 31.9634Z",fill:"white",stroke:"#7E22FF"}),E.jsx("g",{filter:"url(#filter1_d_14507_743)",children:E.jsx("rect",{x:"8",y:"8",width:"74",height:"74",rx:"37",fill:"white"})}),E.jsx("path",{d:"M30.829 40.9597C30.3974 41.4284 30.1713 42.0491 30.0747 42.5589C29.9706 43.0942 29.6581 43.5662 29.2059 43.8711C28.7538 44.176 28.199 44.2888 27.6637 44.1847C27.1284 44.0806 26.6563 43.7681 26.3514 43.3159C26.0465 42.8638 25.9337 42.309 26.0378 41.7737C26.2208 40.8364 26.675 39.4038 27.8014 38.1788C28.9874 36.8859 30.7612 36 33.1948 36C35.6511 36 37.4331 36.9291 38.6129 38.224C39.7311 39.4511 40.1956 40.8796 40.36 41.8148C40.4533 42.352 40.3292 42.9043 40.0153 43.3501C39.7013 43.7959 39.2231 44.0987 38.6859 44.1919C38.1487 44.2851 37.5964 44.1611 37.1506 43.8471C36.7048 43.5332 36.402 43.055 36.3088 42.5178C36.2056 41.9523 35.9513 41.4253 35.573 40.9926C35.1886 40.5672 34.5144 40.1109 33.1948 40.1109C31.8526 40.1109 31.197 40.5569 30.829 40.9597ZM53.4408 40.9597C53.0091 41.4284 52.783 42.0491 52.6844 42.5589C52.5741 43.0879 52.2599 43.5522 51.8099 43.8513C51.3598 44.1504 50.81 44.2603 50.2796 44.157C49.7491 44.0538 49.2807 43.7458 48.9756 43.2998C48.6705 42.8537 48.5534 42.3055 48.6496 41.7737C48.8304 40.8364 49.2868 39.4038 50.4111 38.1788C51.5971 36.8859 53.3709 36 55.8045 36C58.2628 36 60.0428 36.9291 61.2226 38.224C62.3408 39.4511 62.8053 40.8796 62.9697 41.8148C63.0629 42.352 62.9389 42.9043 62.625 43.3501C62.311 43.7959 61.8328 44.0987 61.2956 44.1919C60.7584 44.2851 60.2061 44.1611 59.7603 43.8471C59.3145 43.5332 59.0117 43.055 58.9185 42.5178C58.8153 41.9523 58.561 41.4253 58.1826 40.9926C57.7983 40.5672 57.1241 40.1109 55.8045 40.1109C54.4623 40.1109 53.8087 40.5569 53.4408 40.9597ZM28.8784 48.7991C29.0944 48.6371 29.3401 48.5193 29.6016 48.4523C29.863 48.3853 30.1352 48.3705 30.4024 48.4086C30.6696 48.4468 30.9267 48.5372 31.1589 48.6748C31.3912 48.8123 31.5941 48.9942 31.756 49.2101C32.3685 50.0262 35.8504 53.5265 44.4997 53.5265C53.1489 53.5265 56.6308 50.0262 57.2433 49.2101C57.5704 48.774 58.0573 48.4857 58.597 48.4086C58.8642 48.3705 59.1363 48.3853 59.3978 48.4523C59.6592 48.5193 59.905 48.6371 60.1209 48.7991C60.3368 48.961 60.5188 49.1639 60.6563 49.3962C60.7938 49.6284 60.8842 49.8855 60.9224 50.1527C60.9606 50.4199 60.9458 50.692 60.8788 50.9535C60.8118 51.215 60.6939 51.4607 60.532 51.6767C59.0891 53.6005 54.3493 57.6374 44.4997 57.6374C34.6501 57.6374 29.9103 53.6005 28.4673 51.6767C28.3054 51.4607 28.1876 51.215 28.1206 50.9535C28.0536 50.692 28.0387 50.4199 28.0769 50.1527C28.1151 49.8855 28.2055 49.6284 28.343 49.3962C28.4806 49.1639 28.6625 48.961 28.8784 48.7991Z",fill:e}),E.jsxs("defs",{children:[E.jsxs("filter",{id:"filter0_d_14507_743",x:"4",y:"4",width:"82",height:"82",filterUnits:"userSpaceOnUse","color-interpolation-filters":"sRGB",children:[E.jsx("feFlood",{"flood-opacity":"0",result:"BackgroundImageFix"}),E.jsx("feColorMatrix",{in:"SourceAlpha",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),E.jsx("feOffset",{}),E.jsx("feGaussianBlur",{stdDeviation:"2"}),E.jsx("feComposite",{in2:"hardAlpha",operator:"out"}),E.jsx("feColorMatrix",{type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.1 0"}),E.jsx("feBlend",{mode:"normal",in2:"BackgroundImageFix",result:"effect1_dropShadow_14507_743"}),E.jsx("feBlend",{mode:"normal",in:"SourceGraphic",in2:"effect1_dropShadow_14507_743",result:"shape"})]}),E.jsxs("filter",{id:"filter1_d_14507_743",x:"0.780487",y:"0.780487",width:"88.439",height:"88.439",filterUnits:"userSpaceOnUse","color-interpolation-filters":"sRGB",children:[E.jsx("feFlood",{"flood-opacity":"0",result:"BackgroundImageFix"}),E.jsx("feColorMatrix",{in:"SourceAlpha",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),E.jsx("feOffset",{}),E.jsx("feGaussianBlur",{stdDeviation:"3.60976"}),E.jsx("feComposite",{in2:"hardAlpha",operator:"out"}),E.jsx("feColorMatrix",{type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"}),E.jsx("feBlend",{mode:"normal",in2:"BackgroundImageFix",result:"effect1_dropShadow_14507_743"}),E.jsx("feBlend",{mode:"normal",in:"SourceGraphic",in2:"effect1_dropShadow_14507_743",result:"shape"})]})]})]});function iL(){const{settings:e,shades:A,organization:t}=kB(),n=t?.members?.[0];return console.log({settings:e}),E.jsx("div",{style:{fontFamily:"Graphik",zIndex:9999999999},className:`text-sm fixed z-[99999999] flex items-end bottom-3 ${e.messenger_style==="modern"?"left-1/2 -translate-x-1/2":"right-3"} bg-no-repeat`,children:E.jsx("div",{className:" mx-3",children:E.jsx("div",{children:E.jsx("div",{className:"text-base flex items-center gap-2 relative w-full justify-center",children:E.jsxs(E.Fragment,{children:[E.jsx(wB.div,{className:`absolute -top-10 ${e.messenger_style=="modern"?"left-1/2 -translate-x-1/2":"right-0"} border border-white ela_branded_backdrop bg-white/70 rounded-full whitespace-nowrap px-2.5 py-0.5`,initial:{y:6,opacity:0},animate:{y:0,opacity:1},transition:{duration:.6,delay:.2},children:"I am here. Just in case"}),E.jsx(hh,{to:"/clarity-call",children:E.jsx("div",{className:`flex items-center justify-center border-[1px] relative size-[60px] rounded-full ela_branded_backdrop h-[60px] ${e.use_branding?"":"brand-gradient border-black"}`,style:e.use_branding?{border:`1px solid ${t.color}`}:void 0,children:E.jsx("div",{className:"cursor-pointer",children:E.jsx(k8,{color:"#000"})})})}),E.jsx("div",{className:`${e.use_branding?"":"brand-gradient border-black"} ela_branded_backdrop border-[1px] relative h-[60px] rounded-full`,style:e.use_branding?{border:`1px solid ${t.color}`}:void 0,children:E.jsx(hh,{to:"/home",children:E.jsxs("div",{className:"cursor-pointer text-black flex items-center justify-center relative z-10 h-full gap-1 pl-1 pr-5",children:[e.use_branding?E.jsx(lU,{color:e?.use_branding?t?.color:"black",size:"50"}):E.jsx("img",{src:Sl.AI_ASSISTANT_ICON_BW,alt:"Ela"}),E.jsxs("div",{children:[E.jsx("h1",{className:"text-sm font-bold font_uxum",children:"Hey"}),E.jsx("h1",{className:"text-lg font-bold leading-[1.2] font_uxum",children:`I'm ${n?.user?.first_name}`})]})]})})})]})})})})})}const cL=()=>E.jsx("svg",{width:"22",height:"22",viewBox:"0 0 19 19",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:E.jsx("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M9.5 0C4.25329 0 0 4.25329 0 9.5C0 14.7467 4.25329 19 9.5 19C14.7467 19 19 14.7467 19 9.5C19 4.25329 14.7467 0 9.5 0ZM13.9787 11.5133C14.2656 11.3924 14.3386 11.0193 14.1185 10.7991L11.7302 8.41144C11.5693 8.25059 11.5582 7.99342 11.7046 7.81926L14.2202 4.8261C14.5198 4.46964 14.1305 3.95362 13.7055 4.14375L5.38174 7.86713C5.10129 7.99258 5.03348 8.3601 5.25071 8.57738L7.63582 10.963C7.80187 11.1291 7.80756 11.3966 7.64872 11.5696L5.09976 14.3457C4.78128 14.6926 5.15901 15.2291 5.59297 15.0463L13.9787 11.5133Z",fill:"black"})});//! moment.js
143
+ `})}),E.jsx("div",{className:"font_graphik",children:n.isError?null:e})]})},h0=()=>F.useContext(gU),lU=({color:e="black",size:A="90"})=>E.jsxs("svg",{className:"z-10",width:A,height:A,viewBox:"0 0 90 90",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[E.jsxs("g",{filter:"url(#filter0_d_14507_743)",children:[E.jsx("rect",{x:"8",y:"8",width:"74",height:"74",rx:"37",fill:"#7E22FF"}),E.jsx("rect",{x:"8.25",y:"8.25",width:"73.5",height:"73.5",rx:"36.75",stroke:"#C2C2C2","stroke-width":"0.5"})]}),E.jsx("path",{d:"M33.0264 50.6909C34.2841 49.9636 35.8716 50.3206 36.7041 51.4731L36.8604 51.7144C38.6734 54.8437 42.0381 56.9311 45.8965 56.9312C49.6341 56.9312 52.9149 54.9696 54.7588 52.0073L54.9326 51.7183V51.7173C55.6595 50.4583 57.2157 49.9756 58.5137 50.5601L58.7695 50.6919C60.027 51.4194 60.5092 52.9758 59.9258 54.2739L59.7949 54.5298C58.4741 56.8162 56.6109 58.7391 54.373 60.1304L53.9199 60.4009C51.4803 61.8085 48.7131 62.5492 45.8965 62.5483L45.3691 62.5405C42.9112 62.4596 40.5049 61.8138 38.3359 60.6548L37.875 60.3989C35.5885 59.0788 33.6652 57.2163 32.2734 54.979L32.002 54.5269V54.5259L31.8701 54.27C31.3246 53.0599 31.7086 51.6248 32.7852 50.8472L33.0264 50.6909ZM31.0068 31.9634H35.9697C37.5209 31.9634 38.7781 33.2208 38.7783 34.772C38.7783 36.3233 37.5211 37.5815 35.9697 37.5815H34.3154C33.1255 37.5815 32.1611 38.546 32.1611 39.7358C32.1611 40.3732 31.6442 40.8899 31.0068 40.8901H29.3516C27.8005 40.8899 26.5431 39.6326 26.543 38.0815V36.4272L26.5488 36.1968C26.6685 33.8386 28.6189 31.9634 31.0068 31.9634ZM57.4775 31.9634H62.4414C63.9926 31.9634 65.2498 33.2208 65.25 34.772C65.25 36.3233 63.9927 37.5815 62.4414 37.5815H60.7871C59.5972 37.5815 58.6328 38.546 58.6328 39.7358C58.6328 40.3734 58.1151 40.8901 57.4775 40.8901H55.8232C54.2721 40.89 53.0148 39.6327 53.0146 38.0815V36.4272C53.0146 33.9623 55.0126 31.9636 57.4775 31.9634Z",fill:"white",stroke:"#7E22FF"}),E.jsx("g",{filter:"url(#filter1_d_14507_743)",children:E.jsx("rect",{x:"8",y:"8",width:"74",height:"74",rx:"37",fill:"white"})}),E.jsx("path",{d:"M30.829 40.9597C30.3974 41.4284 30.1713 42.0491 30.0747 42.5589C29.9706 43.0942 29.6581 43.5662 29.2059 43.8711C28.7538 44.176 28.199 44.2888 27.6637 44.1847C27.1284 44.0806 26.6563 43.7681 26.3514 43.3159C26.0465 42.8638 25.9337 42.309 26.0378 41.7737C26.2208 40.8364 26.675 39.4038 27.8014 38.1788C28.9874 36.8859 30.7612 36 33.1948 36C35.6511 36 37.4331 36.9291 38.6129 38.224C39.7311 39.4511 40.1956 40.8796 40.36 41.8148C40.4533 42.352 40.3292 42.9043 40.0153 43.3501C39.7013 43.7959 39.2231 44.0987 38.6859 44.1919C38.1487 44.2851 37.5964 44.1611 37.1506 43.8471C36.7048 43.5332 36.402 43.055 36.3088 42.5178C36.2056 41.9523 35.9513 41.4253 35.573 40.9926C35.1886 40.5672 34.5144 40.1109 33.1948 40.1109C31.8526 40.1109 31.197 40.5569 30.829 40.9597ZM53.4408 40.9597C53.0091 41.4284 52.783 42.0491 52.6844 42.5589C52.5741 43.0879 52.2599 43.5522 51.8099 43.8513C51.3598 44.1504 50.81 44.2603 50.2796 44.157C49.7491 44.0538 49.2807 43.7458 48.9756 43.2998C48.6705 42.8537 48.5534 42.3055 48.6496 41.7737C48.8304 40.8364 49.2868 39.4038 50.4111 38.1788C51.5971 36.8859 53.3709 36 55.8045 36C58.2628 36 60.0428 36.9291 61.2226 38.224C62.3408 39.4511 62.8053 40.8796 62.9697 41.8148C63.0629 42.352 62.9389 42.9043 62.625 43.3501C62.311 43.7959 61.8328 44.0987 61.2956 44.1919C60.7584 44.2851 60.2061 44.1611 59.7603 43.8471C59.3145 43.5332 59.0117 43.055 58.9185 42.5178C58.8153 41.9523 58.561 41.4253 58.1826 40.9926C57.7983 40.5672 57.1241 40.1109 55.8045 40.1109C54.4623 40.1109 53.8087 40.5569 53.4408 40.9597ZM28.8784 48.7991C29.0944 48.6371 29.3401 48.5193 29.6016 48.4523C29.863 48.3853 30.1352 48.3705 30.4024 48.4086C30.6696 48.4468 30.9267 48.5372 31.1589 48.6748C31.3912 48.8123 31.5941 48.9942 31.756 49.2101C32.3685 50.0262 35.8504 53.5265 44.4997 53.5265C53.1489 53.5265 56.6308 50.0262 57.2433 49.2101C57.5704 48.774 58.0573 48.4857 58.597 48.4086C58.8642 48.3705 59.1363 48.3853 59.3978 48.4523C59.6592 48.5193 59.905 48.6371 60.1209 48.7991C60.3368 48.961 60.5188 49.1639 60.6563 49.3962C60.7938 49.6284 60.8842 49.8855 60.9224 50.1527C60.9606 50.4199 60.9458 50.692 60.8788 50.9535C60.8118 51.215 60.6939 51.4607 60.532 51.6767C59.0891 53.6005 54.3493 57.6374 44.4997 57.6374C34.6501 57.6374 29.9103 53.6005 28.4673 51.6767C28.3054 51.4607 28.1876 51.215 28.1206 50.9535C28.0536 50.692 28.0387 50.4199 28.0769 50.1527C28.1151 49.8855 28.2055 49.6284 28.343 49.3962C28.4806 49.1639 28.6625 48.961 28.8784 48.7991Z",fill:e}),E.jsxs("defs",{children:[E.jsxs("filter",{id:"filter0_d_14507_743",x:"4",y:"4",width:"82",height:"82",filterUnits:"userSpaceOnUse","color-interpolation-filters":"sRGB",children:[E.jsx("feFlood",{"flood-opacity":"0",result:"BackgroundImageFix"}),E.jsx("feColorMatrix",{in:"SourceAlpha",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),E.jsx("feOffset",{}),E.jsx("feGaussianBlur",{stdDeviation:"2"}),E.jsx("feComposite",{in2:"hardAlpha",operator:"out"}),E.jsx("feColorMatrix",{type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.1 0"}),E.jsx("feBlend",{mode:"normal",in2:"BackgroundImageFix",result:"effect1_dropShadow_14507_743"}),E.jsx("feBlend",{mode:"normal",in:"SourceGraphic",in2:"effect1_dropShadow_14507_743",result:"shape"})]}),E.jsxs("filter",{id:"filter1_d_14507_743",x:"0.780487",y:"0.780487",width:"88.439",height:"88.439",filterUnits:"userSpaceOnUse","color-interpolation-filters":"sRGB",children:[E.jsx("feFlood",{"flood-opacity":"0",result:"BackgroundImageFix"}),E.jsx("feColorMatrix",{in:"SourceAlpha",type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0",result:"hardAlpha"}),E.jsx("feOffset",{}),E.jsx("feGaussianBlur",{stdDeviation:"3.60976"}),E.jsx("feComposite",{in2:"hardAlpha",operator:"out"}),E.jsx("feColorMatrix",{type:"matrix",values:"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"}),E.jsx("feBlend",{mode:"normal",in2:"BackgroundImageFix",result:"effect1_dropShadow_14507_743"}),E.jsx("feBlend",{mode:"normal",in:"SourceGraphic",in2:"effect1_dropShadow_14507_743",result:"shape"})]})]})]});function iL(){const{settings:e,shades:A,organization:t}=kB(),n=t?.members?.[0],[B,a]=O.useState(!1);return O.useEffect(()=>{window.localStorage.getItem("has_visited_before")||(a(!0),window.localStorage.setItem("has_visited_before","true"))},[]),E.jsx("div",{style:{fontFamily:"Graphik",zIndex:9999999999},className:`text-sm fixed z-[99999999] flex items-end bottom-3 ${e.messenger_style==="modern"?"left-1/2 -translate-x-1/2":"right-3"} bg-no-repeat`,children:E.jsx("div",{className:" mx-3",children:E.jsx("div",{children:E.jsx("div",{className:"text-base flex items-center gap-2 relative w-full justify-center",children:E.jsxs(E.Fragment,{children:[E.jsx(wB.div,{className:`absolute -top-10 ${e.messenger_style=="modern"?"left-1/2 -translate-x-1/2":"right-0"} border border-white ela_branded_backdrop bg-white/70 rounded-full whitespace-nowrap px-2.5 py-0.5`,initial:{y:6,opacity:0},animate:{y:0,opacity:1},transition:{duration:.6,delay:.2},children:"I am here. Just in case"}),E.jsx(hh,{to:"/clarity-call",children:E.jsx("div",{className:`flex items-center justify-center border-[1px] relative size-[60px] rounded-full ela_branded_backdrop h-[60px] ${e.use_branding?"":"brand-gradient border-black"}`,style:e.use_branding?{border:`1px solid ${t.color}`}:void 0,children:E.jsx("div",{className:"cursor-pointer",children:E.jsx(k8,{color:"#000"})})})}),E.jsx("div",{className:`${e.use_branding?"":"brand-gradient border-black"} ela_branded_backdrop border-[1px] relative h-[60px] rounded-full`,style:e.use_branding?{border:`1px solid ${t.color}`}:void 0,children:E.jsx(hh,{to:"/home",children:E.jsxs("div",{className:"cursor-pointer text-black flex items-center justify-center relative z-10 h-full gap-1 pl-1 pr-5",children:[e.use_branding?E.jsx(lU,{color:e?.use_branding?t?.color:"black",size:"50"}):E.jsx("img",{src:Sl.AI_ASSISTANT_ICON_BW,alt:"Ela"}),E.jsxs("div",{children:[E.jsx("h1",{className:"text-sm font-bold font_uxum",children:"Hey"}),E.jsx("h1",{className:"text-lg font-bold leading-[1.2] font_uxum",children:`I'm ${n?.user?.first_name}`})]})]})})})]})})})})})}const cL=()=>E.jsx("svg",{width:"22",height:"22",viewBox:"0 0 19 19",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:E.jsx("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M9.5 0C4.25329 0 0 4.25329 0 9.5C0 14.7467 4.25329 19 9.5 19C14.7467 19 19 14.7467 19 9.5C19 4.25329 14.7467 0 9.5 0ZM13.9787 11.5133C14.2656 11.3924 14.3386 11.0193 14.1185 10.7991L11.7302 8.41144C11.5693 8.25059 11.5582 7.99342 11.7046 7.81926L14.2202 4.8261C14.5198 4.46964 14.1305 3.95362 13.7055 4.14375L5.38174 7.86713C5.10129 7.99258 5.03348 8.3601 5.25071 8.57738L7.63582 10.963C7.80187 11.1291 7.80756 11.3966 7.64872 11.5696L5.09976 14.3457C4.78128 14.6926 5.15901 15.2291 5.59297 15.0463L13.9787 11.5133Z",fill:"black"})});//! moment.js
144
144
  //! version : 2.30.1
145
145
  //! authors : Tim Wood, Iskren Chernev, Moment.js contributors
146
146
  //! license : MIT
@@ -466,7 +466,7 @@ attempted value: ${s}
466
466
  Schedule Meet and Greet
467
467
  </button>`),A=A.replace(/\[\[get membership\]\]/gi,()=>`<button onclick="window.__getMembershipFromBolt && window.__getMembershipFromBolt()" style="text-decoration:underline;color:#7D2CFF">
468
468
  Get Membership
469
- </button>`),A=A.replace(/((https?:\/\/[^\s]+))/g,'<a href="$1" target="_blank" style="color:#7D2CFF;text-decoration:underline;">$1</a>'),A},pT=({name:e,index:A,message:t})=>E.jsx("div",{className:"flex justify-end",children:E.jsxs(wB.div,{initial:{y:3,opacity:0},animate:{y:0,opacity:1},transition:{duration:.6,delay:.1*(A||0)},children:[E.jsx("div",{className:"p-3 bg-[#EFEFEF] break-words",dangerouslySetInnerHTML:{__html:ET(t.content).trim()}}),E.jsxs("p",{className:"justify-self-end pt-1 text-[10px] text-supercare-grey-500",children:[XA(t.created_at).format("M/DD")," • ",XA(t.created_at).format("H:mm A")]})]})}),Qv=({name:e,avatar:A,children:t,index:n,message:B,loading:a})=>{const s="guest_sender"in(B||{})&&B.guest_sender==="assistant",i=!s&&B&&B.sender_participant&&B.sender_participant.member&&B.sender_participant?.member?.is_bot;return E.jsxs(wB.div,{className:"",initial:{y:3,opacity:0},animate:{y:0,opacity:1},transition:{duration:.6,delay:.1*(n||0)},children:[E.jsxs("div",{className:`relative p-3 max-w-[320px] ${s||i||a?"ai_response_bg bg-[#F9F6FF]":"border border-[#E4E4E4]"}`,children:[t?E.jsx(E.Fragment,{children:t}):E.jsx("div",{className:"break-words",dangerouslySetInnerHTML:{__html:ET(B?.content||"").trim()}}),E.jsx("div",{className:"absolute -bottom-2 -right-2"})]}),E.jsxs("p",{className:"justify-self-start pt-1 text-[10px]",children:[!(s||i)&&"sender"in(B||{})&&E.jsx("span",{className:"text-[13px] text-supercare-grey-500}",children:(B?.sender_participant?.member?.user?.email||"").length>20?B.sender_participant.member?.user.email.slice(0,20)+"... ":B.sender_participant.member?.user.email+" • "}),!a&&E.jsxs("span",{className:"text-supercare-grey-500",children:[XA(B?.created_at).format("M/DD")," • ",XA(B?.created_at).format("H:mm A")]})]})]})},_m=[`👋 Hey, I'm ${fI} !`,"I can clarify any questions you have regarding our services & memberships. How can I help you today?","In case the conversation discontinues, pls enter your email so that we can get back to you"],$lA=()=>{const e=bs(),{initialMessage:A}=Th(),[t,n]=F.useState([]),[B,a]=F.useState(A||""),[s,i]=F.useState(!1),[o,g]=F.useState(!1),[d,G]=F.useState(!1),{organization:f}=kB(),v=f?.members?.[0],{login:H,errMessage:y}=Pg(),Y=()=>{const x=B.trim();if(x==="")return;const V={id:`guest-msg-${Date.now()}-u`,content:x,guest_sender:"user",created_at:new Date};n(k=>[...k,V]),a(""),setTimeout(()=>{g(!0)},1e3),setTimeout(()=>{const k={id:`guest-msg-${Date.now()}-a`,content:_m[2],guest_sender:"assistant",created_at:new Date};n(S=>[...S,k]),g(!1)},1500),setTimeout(()=>{i(!0)},2500),Aa.setState(k=>({...k,chats:{...k.chats,initialMessage:x}}))},Z=()=>{if(B.trim()==="")return;const x={id:`guest-msg-${Date.now()}-u`,content:B.trim(),guest_sender:"user",created_at:new Date};H.mutate({email:B.trim(),initialMessages:[...t,x]}),a("")},P=E.jsx("button",{onClick:()=>{e("/home")},className:"rounded-full border border-black text-sm px-2",children:"End Chat"});return F.useEffect(()=>{let x=1e3;const V=[];if(t.length===0){const k=_m.slice(0,2);k.forEach((K,J)=>{const eA=window.setTimeout(()=>{n(sA=>[...sA,{id:`guest-msg-${J}`,content:K,guest_sender:"assistant",created_at:new Date}])},x+J*1e3);V.push(eA)}),V.push(window.setTimeout(()=>g(!0),500));const S=x+k.length*500;V.push(window.setTimeout(()=>{g(!1),G(!0)},S))}return()=>{V.forEach(k=>clearTimeout(k))}},[]),E.jsx(ro,{showMinMaxIcon:!0,title:`Chat with ${v?.user?.first_name}`,rightComponent:P,children:E.jsxs("div",{className:"flex flex-col justify-between h-full",children:[E.jsxs("div",{className:"pl-2 pr-6 text-sm flex flex-col gap-5 mt-3",children:[t.map((x,V)=>x.guest_sender==="user"?E.jsx(pT,{index:V,name:"You",message:x},V):E.jsxs(wB.div,{className:"flex items-start gap-2",initial:{y:3,opacity:0},animate:{y:0,opacity:1},transition:{duration:.6},children:[E.jsxs("div",{className:"flex flex-col gap-1 items-center",children:[E.jsx("img",{src:v?.user?.profile_picture?.url,alt:"Ela Icon",width:40}),E.jsx("p",{className:"text-xs tracking-[0.58px] ai_response_text",children:v?.user?.first_name})]}),E.jsx("div",{className:"flex flex-col items-start gap-1",children:E.jsx(Qv,{index:V,name:v?.user?.first_name||fI,message:x},V)})]})),s&&E.jsxs("div",{className:"",children:[E.jsxs("div",{className:"relative flex items-center -mt-3 ml-[50px]",children:[E.jsx("input",{autoFocus:s,className:"py-3.5 pl-3 pr-21 outline-none w-full border border-[#CECECE] text-sm",type:"text",placeholder:"Your email ID please",value:B,onChange:x=>a(x.target.value),onKeyUp:x=>{if(x.key=="Enter"){if(H.isPending)return;Z()}}})," ",E.jsx(wB.button,{whileTap:{scale:.95},whileHover:{scale:1},onClick:Z,disabled:H.isPending,className:"text-sm disabled:opacity-60 disabled:cursor-default absolute right-2 top-1/2 -translate-y-1/2 bg-black hover:shadow-md transition-shadow text-white py-1.5 px-4 hover:opacity-80 rounded-full text-center flex items-center gap-2",children:H.isPending?E.jsx(vg,{size:"sm",color:"white"}):"Send"})]}),E.jsx("p",{className:"text-red-500 pl-3 text-sm",children:y})]}),o&&E.jsxs("div",{className:"flex items-start gap-2",children:[E.jsxs("div",{className:"flex flex-col gap-1 items-center",children:[E.jsx("img",{src:v?.user?.profile_picture?.url,width:40,alt:`${v?.user?.first_name} Icon`}),E.jsx("p",{className:"text-xs ai_response_text",children:v?.user?.first_name})]}),E.jsx(Qv,{loading:!0,name:v?.user?.email||qy,children:E.jsx("div",{className:"flex items-center gap-1",children:[0,1,2].map(x=>E.jsx(wB.div,{transition:{y:{duration:.8,repeat:1/0,ease:"easeOut",delay:x*.1}},animate:{y:["-100%","0%"]},children:E.jsxs("svg",{width:"7",height:"7",viewBox:"0 0 7 7",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[E.jsx("circle",{cx:"3.5",cy:"3.5",r:"3",fill:"#F9F6FF",stroke:"url(#paint0_linear_11221_1318)"}),E.jsx("defs",{children:E.jsxs("linearGradient",{id:"paint0_linear_11221_1318",x1:"1.66591e-07",y1:"0.649091",x2:"10.9417",y2:"4.14756",gradientUnits:"userSpaceOnUse",children:[E.jsx("stop",{"stop-color":"#FF7FF2"}),E.jsx("stop",{offset:"0.305","stop-color":"#526FFF"}),E.jsx("stop",{offset:"0.615","stop-color":"#58D3FF"}),E.jsx("stop",{offset:"0.99","stop-color":"#FF9CC5"})]})})]})},x))})})]})]}),!s&&d&&E.jsx("div",{className:"px-3 sticky bottom-0 bg-white pt-2 z-10 pb-3",children:E.jsx(wB.div,{initial:{y:6,opacity:0},animate:{y:0,opacity:1},transition:{delay:.4},children:E.jsxs("div",{className:"relative flex items-center mt-2.5",children:[E.jsx("input",{autoFocus:!0,className:"py-3.5 pl-3 pr-21 outline-none w-full border border-[#CECECE] text-sm",type:"text",placeholder:"Ask AI",value:B,onChange:x=>a(x.target.value),onKeyUp:x=>{if(x.key=="Enter"){if(o)return;Y()}}}),E.jsx(wB.button,{whileTap:{scale:.95},whileHover:{scale:1},onClick:Y,disabled:o,className:"text-sm disabled:opacity-60 disabled:cursor-default absolute right-2 top-1/2 -translate-y-1/2 bg-black hover:shadow-md transition-shadow text-white py-1.5 px-4 hover:opacity-80 rounded-full text-center flex items-center gap-2",children:o?E.jsx(vg,{size:"sm",color:"white"}):"Send"})]})})})]})})},AdA=(e,A)=>(console.log({chatId:e}),La.get(`/chats/${e}/messages`,{params:A})),edA=e=>e.sender_participant?.member?.is_bot===!0,tdA=e=>!!e.sender_participant?.patientId,ndA=e=>!!(e.sender_participant?.member&&!e.sender_participant?.member?.is_bot),BdA=e=>edA(e)?fI:tdA(e)?"You":ndA(e)?e.sender_participant?.member?.user?.email||"Care Manager":"Guest",adA=e=>{const A={};if(!e||e.length===0)return A;let t=0,n=null;for(let B=0;B<e.length;B++){const a=e[B],s=BdA(a);s!==n&&(t+=1,n=s);const i=`${s}_${t}`;A[i]||(A[i]=[]),A[i].push(a)}return A},sdA=({messages:e,hasNextPage:A,isFetchingNextPage:t,onLoadMore:n,awaitingTeamReplyCountdown:B,loadingBotResponse:a})=>{const{organization:s}=kB(),i=F.useRef(null),o=F.useRef(e.length),g=F.useRef(!1),d=s?.members?.[0],{awaitingTeamReply:G}=Th(),f=F.useMemo(()=>adA(e),[e]);console.log({groupedMessages:f}),F.useEffect(()=>{g.current&&!t&&e.length>o.current&&i.current&&i.current.scrollTo({top:i.current.scrollHeight,behavior:"smooth"}),o.current=e.length,g.current=t||!1},[t,e.length]);const v=()=>{n&&n()},H=y=>y.split("_")[0];return E.jsxs("div",{ref:i,className:`flex-1 overflow-y-auto py-3 ${e.length<6&&"h-max"}`,children:[A&&E.jsx("div",{className:"flex justify-center",children:E.jsx("button",{onClick:v,disabled:t,className:"px-4 text-sm pb-3 text-gray-600 hover:text-gray-900 disabled:opacity-50 disabled:cursor-not-allowed",children:t?"Loading...":"Load older messages"})}),Object.keys(f).map((y,Y)=>H(y)=="You"||H(y)=="Guest"?f[y].filter((Z=>Z.type==="message")).map((Z,P)=>E.jsx(pT,{index:P,name:"You",message:Z},P)):E.jsxs("div",{className:"flex items-start gap-2",children:[E.jsxs("div",{className:"flex flex-col gap-1 items-center",children:[f[y][0].sender_participant?.member?.user?.profile_picture?.url?E.jsx("img",{src:f[y][0].sender_participant?.member?.user?.profile_picture?.url,alt:"Ela Icon",width:40}):E.jsx("div",{className:"w-[2.5rem] h-[2.5rem] leading-[2.5rem] text-[22px] bg-black text-white rounded-full text-center text-xs",children:E.jsx("span",{children:f[y][0].sender_participant?.member?.user?.email[0]})}),f[y][0].sender_participant?.member?.user?.email==d?.user?.email&&E.jsx("p",{className:"text-xs tracking-[0.58px] ai_response_text",children:H(y)})]}),E.jsx("div",{className:"flex flex-col items-start gap-1",children:f[y].filter((Z=>Z.type==="message")).map((Z,P)=>E.jsx(Qv,{index:P,name:Z.sender_participant?.member?.user?.email||"Ela",message:Z},P))})]})),G&&B>0&&B<60&&E.jsxs("div",{className:"text-supercare-grey-500 text-sm text-center my-5",children:[B,"s Awaiting on team"]}),a&&E.jsxs("div",{className:"flex items-start gap-2",children:[E.jsxs("div",{className:"flex flex-col gap-1 items-center",children:[E.jsx("img",{src:d?.user?.profile_picture?.url,alt:`${d?.user?.first_name} Icon`,width:40}),E.jsx("p",{className:"text-xs ai_response_text",children:d?.user?.first_name})]}),E.jsx(Qv,{loading:!0,index:0,name:d?.user?.email||qy,children:E.jsx("div",{className:"flex items-center gap-1",children:[0,1,2].map(y=>E.jsx(wB.div,{transition:{y:{duration:.8,repeat:1/0,ease:"easeOut",delay:y*.1}},animate:{y:["-100%","0%"]},children:E.jsxs("svg",{width:"7",height:"7",viewBox:"0 0 7 7",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[E.jsx("circle",{cx:"3.5",cy:"3.5",r:"3",fill:"#F9F6FF",stroke:"url(#paint0_linear_11221_1318)"}),E.jsx("defs",{children:E.jsxs("linearGradient",{id:"paint0_linear_11221_1318",x1:"1.66591e-07",y1:"0.649091",x2:"10.9417",y2:"4.14756",gradientUnits:"userSpaceOnUse",children:[E.jsx("stop",{"stop-color":"#FF7FF2"}),E.jsx("stop",{offset:"0.305","stop-color":"#526FFF"}),E.jsx("stop",{offset:"0.615","stop-color":"#58D3FF"}),E.jsx("stop",{offset:"0.99","stop-color":"#FF9CC5"})]})})]})},y))})})]})]})},bc=Object.create(null);bc.open="0",bc.close="1",bc.ping="2",bc.pong="3",bc.message="4",bc.upgrade="5",bc.noop="6";const wv=Object.create(null);Object.keys(bc).forEach(e=>{wv[bc[e]]=e});const $m={type:"error",data:"parser error"},mT=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",yT=typeof ArrayBuffer=="function",YT=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,A3=({type:e,data:A},t,n)=>mT&&A instanceof Blob?t?n(A):ZT(A,n):yT&&(A instanceof ArrayBuffer||YT(A))?t?n(A):ZT(new Blob([A]),n):n(bc[e]+(A||"")),ZT=(e,A)=>{const t=new FileReader;return t.onload=function(){const n=t.result.split(",")[1];A("b"+(n||""))},t.readAsDataURL(e)};function kT(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let e3;function rdA(e,A){if(mT&&e.data instanceof Blob)return e.data.arrayBuffer().then(kT).then(A);if(yT&&(e.data instanceof ArrayBuffer||YT(e.data)))return A(kT(e.data));A3(e,!1,t=>{e3||(e3=new TextEncoder),A(e3.encode(t))})}const UT="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Gf=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let e=0;e<UT.length;e++)Gf[UT.charCodeAt(e)]=e;const idA=e=>{let A=e.length*.75,t=e.length,n,B=0,a,s,i,o;e[e.length-1]==="="&&(A--,e[e.length-2]==="="&&A--);const g=new ArrayBuffer(A),d=new Uint8Array(g);for(n=0;n<t;n+=4)a=Gf[e.charCodeAt(n)],s=Gf[e.charCodeAt(n+1)],i=Gf[e.charCodeAt(n+2)],o=Gf[e.charCodeAt(n+3)],d[B++]=a<<2|s>>4,d[B++]=(s&15)<<4|i>>2,d[B++]=(i&3)<<6|o&63;return g},cdA=typeof ArrayBuffer=="function",t3=(e,A)=>{if(typeof e!="string")return{type:"message",data:DT(e,A)};const t=e.charAt(0);return t==="b"?{type:"message",data:odA(e.substring(1),A)}:wv[t]?e.length>1?{type:wv[t],data:e.substring(1)}:{type:wv[t]}:$m},odA=(e,A)=>{if(cdA){const t=idA(e);return DT(t,A)}else return{base64:!0,data:e}},DT=(e,A)=>{switch(A){case"blob":return e instanceof Blob?e:new Blob([e]);case"arraybuffer":default:return e instanceof ArrayBuffer?e:e.buffer}},FT="",gdA=(e,A)=>{const t=e.length,n=new Array(t);let B=0;e.forEach((a,s)=>{A3(a,!1,i=>{n[s]=i,++B===t&&A(n.join(FT))})})},ldA=(e,A)=>{const t=e.split(FT),n=[];for(let B=0;B<t.length;B++){const a=t3(t[B],A);if(n.push(a),a.type==="error")break}return n};function ddA(){return new TransformStream({transform(e,A){rdA(e,t=>{const n=t.length;let B;if(n<126)B=new Uint8Array(1),new DataView(B.buffer).setUint8(0,n);else if(n<65536){B=new Uint8Array(3);const a=new DataView(B.buffer);a.setUint8(0,126),a.setUint16(1,n)}else{B=new Uint8Array(9);const a=new DataView(B.buffer);a.setUint8(0,127),a.setBigUint64(1,BigInt(n))}e.data&&typeof e.data!="string"&&(B[0]|=128),A.enqueue(B),A.enqueue(t)})}})}let n3;function fv(e){return e.reduce((A,t)=>A+t.length,0)}function hv(e,A){if(e[0].length===A)return e.shift();const t=new Uint8Array(A);let n=0;for(let B=0;B<A;B++)t[B]=e[0][n++],n===e[0].length&&(e.shift(),n=0);return e.length&&n<e[0].length&&(e[0]=e[0].slice(n)),t}function udA(e,A){n3||(n3=new TextDecoder);const t=[];let n=0,B=-1,a=!1;return new TransformStream({transform(s,i){for(t.push(s);;){if(n===0){if(fv(t)<1)break;const o=hv(t,1);a=(o[0]&128)===128,B=o[0]&127,B<126?n=3:B===126?n=1:n=2}else if(n===1){if(fv(t)<2)break;const o=hv(t,2);B=new DataView(o.buffer,o.byteOffset,o.length).getUint16(0),n=3}else if(n===2){if(fv(t)<8)break;const o=hv(t,8),g=new DataView(o.buffer,o.byteOffset,o.length),d=g.getUint32(0);if(d>Math.pow(2,21)-1){i.enqueue($m);break}B=d*Math.pow(2,32)+g.getUint32(4),n=3}else{if(fv(t)<B)break;const o=hv(t,B);i.enqueue(t3(a?o:n3.decode(o),A)),n=0}if(B===0||B>e){i.enqueue($m);break}}}})}const PT=4;function eB(e){if(e)return GdA(e)}function GdA(e){for(var A in eB.prototype)e[A]=eB.prototype[A];return e}eB.prototype.on=eB.prototype.addEventListener=function(e,A){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(A),this},eB.prototype.once=function(e,A){function t(){this.off(e,t),A.apply(this,arguments)}return t.fn=A,this.on(e,t),this},eB.prototype.off=eB.prototype.removeListener=eB.prototype.removeAllListeners=eB.prototype.removeEventListener=function(e,A){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var t=this._callbacks["$"+e];if(!t)return this;if(arguments.length==1)return delete this._callbacks["$"+e],this;for(var n,B=0;B<t.length;B++)if(n=t[B],n===A||n.fn===A){t.splice(B,1);break}return t.length===0&&delete this._callbacks["$"+e],this},eB.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var A=new Array(arguments.length-1),t=this._callbacks["$"+e],n=1;n<arguments.length;n++)A[n-1]=arguments[n];if(t){t=t.slice(0);for(var n=0,B=t.length;n<B;++n)t[n].apply(this,A)}return this},eB.prototype.emitReserved=eB.prototype.emit,eB.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},eB.prototype.hasListeners=function(e){return!!this.listeners(e).length};const Cv=typeof Promise=="function"&&typeof Promise.resolve=="function"?A=>Promise.resolve().then(A):(A,t)=>t(A,0),vr=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),QdA="arraybuffer";function FQA(){}function MT(e,...A){return A.reduce((t,n)=>(e.hasOwnProperty(n)&&(t[n]=e[n]),t),{})}const wdA=vr.setTimeout,fdA=vr.clearTimeout;function bv(e,A){A.useNativeTimers?(e.setTimeoutFn=wdA.bind(vr),e.clearTimeoutFn=fdA.bind(vr)):(e.setTimeoutFn=vr.setTimeout.bind(vr),e.clearTimeoutFn=vr.clearTimeout.bind(vr))}const hdA=1.33;function CdA(e){return typeof e=="string"?bdA(e):Math.ceil((e.byteLength||e.size)*hdA)}function bdA(e){let A=0,t=0;for(let n=0,B=e.length;n<B;n++)A=e.charCodeAt(n),A<128?t+=1:A<2048?t+=2:A<55296||A>=57344?t+=3:(n++,t+=4);return t}function xT(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function vdA(e){let A="";for(let t in e)e.hasOwnProperty(t)&&(A.length&&(A+="&"),A+=encodeURIComponent(t)+"="+encodeURIComponent(e[t]));return A}function IdA(e){let A={},t=e.split("&");for(let n=0,B=t.length;n<B;n++){let a=t[n].split("=");A[decodeURIComponent(a[0])]=decodeURIComponent(a[1])}return A}class HdA extends Error{constructor(A,t,n){super(A),this.description=t,this.context=n,this.type="TransportError"}}class B3 extends eB{constructor(A){super(),this.writable=!1,bv(this,A),this.opts=A,this.query=A.query,this.socket=A.socket,this.supportsBinary=!A.forceBase64}onError(A,t,n){return super.emitReserved("error",new HdA(A,t,n)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(A){this.readyState==="open"&&this.write(A)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(A){const t=t3(A,this.socket.binaryType);this.onPacket(t)}onPacket(A){super.emitReserved("packet",A)}onClose(A){this.readyState="closed",super.emitReserved("close",A)}pause(A){}createUri(A,t={}){return A+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){const A=this.opts.hostname;return A.indexOf(":")===-1?A:"["+A+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(A){const t=vdA(A);return t.length?"?"+t:""}}class EdA extends B3{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(A){this.readyState="pausing";const t=()=>{this.readyState="paused",A()};if(this._polling||!this.writable){let n=0;this._polling&&(n++,this.once("pollComplete",function(){--n||t()})),this.writable||(n++,this.once("drain",function(){--n||t()}))}else t()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(A){const t=n=>{if(this.readyState==="opening"&&n.type==="open"&&this.onOpen(),n.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(n)};ldA(A,this.socket.binaryType).forEach(t),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const A=()=>{this.write([{type:"close"}])};this.readyState==="open"?A():this.once("open",A)}write(A){this.writable=!1,gdA(A,t=>{this.doWrite(t,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const A=this.opts.secure?"https":"http",t=this.query||{};return this.opts.timestampRequests!==!1&&(t[this.opts.timestampParam]=xT()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(A,t)}}let TT=!1;try{TT=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const pdA=TT;function mdA(){}class ydA extends EdA{constructor(A){if(super(A),typeof location<"u"){const t=location.protocol==="https:";let n=location.port;n||(n=t?"443":"80"),this.xd=typeof location<"u"&&A.hostname!==location.hostname||n!==A.port}}doWrite(A,t){const n=this.request({method:"POST",data:A});n.on("success",t),n.on("error",(B,a)=>{this.onError("xhr post error",B,a)})}doPoll(){const A=this.request();A.on("data",this.onData.bind(this)),A.on("error",(t,n)=>{this.onError("xhr poll error",t,n)}),this.pollXhr=A}}class vc extends eB{constructor(A,t,n){super(),this.createRequest=A,bv(this,n),this._opts=n,this._method=n.method||"GET",this._uri=t,this._data=n.data!==void 0?n.data:null,this._create()}_create(){var A;const t=MT(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this._opts.xd;const n=this._xhr=this.createRequest(t);try{n.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){n.setDisableHeaderCheck&&n.setDisableHeaderCheck(!0);for(let B in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(B)&&n.setRequestHeader(B,this._opts.extraHeaders[B])}}catch{}if(this._method==="POST")try{n.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{n.setRequestHeader("Accept","*/*")}catch{}(A=this._opts.cookieJar)===null||A===void 0||A.addCookies(n),"withCredentials"in n&&(n.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(n.timeout=this._opts.requestTimeout),n.onreadystatechange=()=>{var B;n.readyState===3&&((B=this._opts.cookieJar)===null||B===void 0||B.parseCookies(n.getResponseHeader("set-cookie"))),n.readyState===4&&(n.status===200||n.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof n.status=="number"?n.status:0)},0))},n.send(this._data)}catch(B){this.setTimeoutFn(()=>{this._onError(B)},0);return}typeof document<"u"&&(this._index=vc.requestsCount++,vc.requests[this._index]=this)}_onError(A){this.emitReserved("error",A,this._xhr),this._cleanup(!0)}_cleanup(A){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=mdA,A)try{this._xhr.abort()}catch{}typeof document<"u"&&delete vc.requests[this._index],this._xhr=null}}_onLoad(){const A=this._xhr.responseText;A!==null&&(this.emitReserved("data",A),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}if(vc.requestsCount=0,vc.requests={},typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",RT);else if(typeof addEventListener=="function"){const e="onpagehide"in vr?"pagehide":"unload";addEventListener(e,RT,!1)}}function RT(){for(let e in vc.requests)vc.requests.hasOwnProperty(e)&&vc.requests[e].abort()}const YdA=(function(){const e=VT({xdomain:!1});return e&&e.responseType!==null})();class ZdA extends ydA{constructor(A){super(A);const t=A&&A.forceBase64;this.supportsBinary=YdA&&!t}request(A={}){return Object.assign(A,{xd:this.xd},this.opts),new vc(VT,this.uri(),A)}}function VT(e){const A=e.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!A||pdA))return new XMLHttpRequest}catch{}if(!A)try{return new vr[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const ST=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class kdA extends B3{get name(){return"websocket"}doOpen(){const A=this.uri(),t=this.opts.protocols,n=ST?{}:MT(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(A,t,n)}catch(B){return this.emitReserved("error",B)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=A=>this.onClose({description:"websocket connection closed",context:A}),this.ws.onmessage=A=>this.onData(A.data),this.ws.onerror=A=>this.onError("websocket error",A)}write(A){this.writable=!1;for(let t=0;t<A.length;t++){const n=A[t],B=t===A.length-1;A3(n,this.supportsBinary,a=>{try{this.doWrite(n,a)}catch{}B&&Cv(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const A=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=xT()),this.supportsBinary||(t.b64=1),this.createUri(A,t)}}const a3=vr.WebSocket||vr.MozWebSocket;class UdA extends kdA{createSocket(A,t,n){return ST?new a3(A,t,n):t?new a3(A,t):new a3(A)}doWrite(A,t){this.ws.send(t)}}class DdA extends B3{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(A){return this.emitReserved("error",A)}this._transport.closed.then(()=>{this.onClose()}).catch(A=>{this.onError("webtransport error",A)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(A=>{const t=udA(Number.MAX_SAFE_INTEGER,this.socket.binaryType),n=A.readable.pipeThrough(t).getReader(),B=ddA();B.readable.pipeTo(A.writable),this._writer=B.writable.getWriter();const a=()=>{n.read().then(({done:i,value:o})=>{i||(this.onPacket(o),a())}).catch(i=>{})};a();const s={type:"open"};this.query.sid&&(s.data=`{"sid":"${this.query.sid}"}`),this._writer.write(s).then(()=>this.onOpen())})})}write(A){this.writable=!1;for(let t=0;t<A.length;t++){const n=A[t],B=t===A.length-1;this._writer.write(n).then(()=>{B&&Cv(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var A;(A=this._transport)===null||A===void 0||A.close()}}const FdA={websocket:UdA,webtransport:DdA,polling:ZdA},PdA=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,MdA=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function s3(e){if(e.length>8e3)throw"URI too long";const A=e,t=e.indexOf("["),n=e.indexOf("]");t!=-1&&n!=-1&&(e=e.substring(0,t)+e.substring(t,n).replace(/:/g,";")+e.substring(n,e.length));let B=PdA.exec(e||""),a={},s=14;for(;s--;)a[MdA[s]]=B[s]||"";return t!=-1&&n!=-1&&(a.source=A,a.host=a.host.substring(1,a.host.length-1).replace(/;/g,":"),a.authority=a.authority.replace("[","").replace("]","").replace(/;/g,":"),a.ipv6uri=!0),a.pathNames=xdA(a,a.path),a.queryKey=TdA(a,a.query),a}function xdA(e,A){const t=/\/{2,9}/g,n=A.replace(t,"/").split("/");return(A.slice(0,1)=="/"||A.length===0)&&n.splice(0,1),A.slice(-1)=="/"&&n.splice(n.length-1,1),n}function TdA(e,A){const t={};return A.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(n,B,a){B&&(t[B]=a)}),t}const r3=typeof addEventListener=="function"&&typeof removeEventListener=="function",vv=[];r3&&addEventListener("offline",()=>{vv.forEach(e=>e())},!1);class Og extends eB{constructor(A,t){if(super(),this.binaryType=QdA,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,A&&typeof A=="object"&&(t=A,A=null),A){const n=s3(A);t.hostname=n.host,t.secure=n.protocol==="https"||n.protocol==="wss",t.port=n.port,n.query&&(t.query=n.query)}else t.host&&(t.hostname=s3(t.host).host);bv(this,t),this.secure=t.secure!=null?t.secure:typeof location<"u"&&location.protocol==="https:",t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=t.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},t.transports.forEach(n=>{const B=n.prototype.name;this.transports.push(B),this._transportsByName[B]=n}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=IdA(this.opts.query)),r3&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},vv.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(A){const t=Object.assign({},this.opts.query);t.EIO=PT,t.transport=A,this.id&&(t.sid=this.id);const n=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[A]);return new this._transportsByName[A](n)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const A=this.opts.rememberUpgrade&&Og.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const t=this.createTransport(A);t.open(),this.setTransport(t)}setTransport(A){this.transport&&this.transport.removeAllListeners(),this.transport=A,A.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",t=>this._onClose("transport close",t))}onOpen(){this.readyState="open",Og.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(A){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",A),this.emitReserved("heartbeat"),A.type){case"open":this.onHandshake(JSON.parse(A.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const t=new Error("server error");t.code=A.data,this._onError(t);break;case"message":this.emitReserved("data",A.data),this.emitReserved("message",A.data);break}}onHandshake(A){this.emitReserved("handshake",A),this.id=A.sid,this.transport.query.sid=A.sid,this._pingInterval=A.pingInterval,this._pingTimeout=A.pingTimeout,this._maxPayload=A.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const A=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+A,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},A),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const A=this._getWritablePackets();this.transport.send(A),this._prevBufferLen=A.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let t=1;for(let n=0;n<this.writeBuffer.length;n++){const B=this.writeBuffer[n].data;if(B&&(t+=CdA(B)),n>0&&t>this._maxPayload)return this.writeBuffer.slice(0,n);t+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const A=Date.now()>this._pingTimeoutTime;return A&&(this._pingTimeoutTime=0,Cv(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),A}write(A,t,n){return this._sendPacket("message",A,t,n),this}send(A,t,n){return this._sendPacket("message",A,t,n),this}_sendPacket(A,t,n,B){if(typeof t=="function"&&(B=t,t=void 0),typeof n=="function"&&(B=n,n=null),this.readyState==="closing"||this.readyState==="closed")return;n=n||{},n.compress=n.compress!==!1;const a={type:A,data:t,options:n};this.emitReserved("packetCreate",a),this.writeBuffer.push(a),B&&this.once("flush",B),this.flush()}close(){const A=()=>{this._onClose("forced close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),A()},n=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?n():A()}):this.upgrading?n():A()),this}_onError(A){if(Og.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",A),this._onClose("transport error",A)}_onClose(A,t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),r3&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const n=vv.indexOf(this._offlineEventListener);n!==-1&&vv.splice(n,1)}this.readyState="closed",this.id=null,this.emitReserved("close",A,t),this.writeBuffer=[],this._prevBufferLen=0}}}Og.protocol=PT;class RdA extends Og{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let A=0;A<this._upgrades.length;A++)this._probe(this._upgrades[A])}_probe(A){let t=this.createTransport(A),n=!1;Og.priorWebsocketSuccess=!1;const B=()=>{n||(t.send([{type:"ping",data:"probe"}]),t.once("packet",G=>{if(!n)if(G.type==="pong"&&G.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;Og.priorWebsocketSuccess=t.name==="websocket",this.transport.pause(()=>{n||this.readyState!=="closed"&&(d(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{const f=new Error("probe error");f.transport=t.name,this.emitReserved("upgradeError",f)}}))};function a(){n||(n=!0,d(),t.close(),t=null)}const s=G=>{const f=new Error("probe error: "+G);f.transport=t.name,a(),this.emitReserved("upgradeError",f)};function i(){s("transport closed")}function o(){s("socket closed")}function g(G){t&&G.name!==t.name&&a()}const d=()=>{t.removeListener("open",B),t.removeListener("error",s),t.removeListener("close",i),this.off("close",o),this.off("upgrading",g)};t.once("open",B),t.once("error",s),t.once("close",i),this.once("close",o),this.once("upgrading",g),this._upgrades.indexOf("webtransport")!==-1&&A!=="webtransport"?this.setTimeoutFn(()=>{n||t.open()},200):t.open()}onHandshake(A){this._upgrades=this._filterUpgrades(A.upgrades),super.onHandshake(A)}_filterUpgrades(A){const t=[];for(let n=0;n<A.length;n++)~this.transports.indexOf(A[n])&&t.push(A[n]);return t}}let VdA=class extends RdA{constructor(A,t={}){const n=typeof A=="object"?A:t;(!n.transports||n.transports&&typeof n.transports[0]=="string")&&(n.transports=(n.transports||["polling","websocket","webtransport"]).map(B=>FdA[B]).filter(B=>!!B)),super(A,n)}};function SdA(e,A="",t){let n=e;t=t||typeof location<"u"&&location,e==null&&(e=t.protocol+"//"+t.host),typeof e=="string"&&(e.charAt(0)==="/"&&(e.charAt(1)==="/"?e=t.protocol+e:e=t.host+e),/^(https?|wss?):\/\//.test(e)||(typeof t<"u"?e=t.protocol+"//"+e:e="https://"+e),n=s3(e)),n.port||(/^(http|ws)$/.test(n.protocol)?n.port="80":/^(http|ws)s$/.test(n.protocol)&&(n.port="443")),n.path=n.path||"/";const a=n.host.indexOf(":")!==-1?"["+n.host+"]":n.host;return n.id=n.protocol+"://"+a+":"+n.port+A,n.href=n.protocol+"://"+a+(t&&t.port===n.port?"":":"+n.port),n}const WdA=typeof ArrayBuffer=="function",zdA=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,WT=Object.prototype.toString,NdA=typeof Blob=="function"||typeof Blob<"u"&&WT.call(Blob)==="[object BlobConstructor]",XdA=typeof File=="function"||typeof File<"u"&&WT.call(File)==="[object FileConstructor]";function i3(e){return WdA&&(e instanceof ArrayBuffer||zdA(e))||NdA&&e instanceof Blob||XdA&&e instanceof File}function Iv(e,A){if(!e||typeof e!="object")return!1;if(Array.isArray(e)){for(let t=0,n=e.length;t<n;t++)if(Iv(e[t]))return!0;return!1}if(i3(e))return!0;if(e.toJSON&&typeof e.toJSON=="function"&&arguments.length===1)return Iv(e.toJSON(),!0);for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&Iv(e[t]))return!0;return!1}function LdA(e){const A=[],t=e.data,n=e;return n.data=c3(t,A),n.attachments=A.length,{packet:n,buffers:A}}function c3(e,A){if(!e)return e;if(i3(e)){const t={_placeholder:!0,num:A.length};return A.push(e),t}else if(Array.isArray(e)){const t=new Array(e.length);for(let n=0;n<e.length;n++)t[n]=c3(e[n],A);return t}else if(typeof e=="object"&&!(e instanceof Date)){const t={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=c3(e[n],A));return t}return e}function OdA(e,A){return e.data=o3(e.data,A),delete e.attachments,e}function o3(e,A){if(!e)return e;if(e&&e._placeholder===!0){if(typeof e.num=="number"&&e.num>=0&&e.num<A.length)return A[e.num];throw new Error("illegal attachments")}else if(Array.isArray(e))for(let t=0;t<e.length;t++)e[t]=o3(e[t],A);else if(typeof e=="object")for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&(e[t]=o3(e[t],A));return e}const JdA=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],KdA=5;var Ke;(function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"})(Ke||(Ke={}));class jdA{constructor(A){this.replacer=A}encode(A){return(A.type===Ke.EVENT||A.type===Ke.ACK)&&Iv(A)?this.encodeAsBinary({type:A.type===Ke.EVENT?Ke.BINARY_EVENT:Ke.BINARY_ACK,nsp:A.nsp,data:A.data,id:A.id}):[this.encodeAsString(A)]}encodeAsString(A){let t=""+A.type;return(A.type===Ke.BINARY_EVENT||A.type===Ke.BINARY_ACK)&&(t+=A.attachments+"-"),A.nsp&&A.nsp!=="/"&&(t+=A.nsp+","),A.id!=null&&(t+=A.id),A.data!=null&&(t+=JSON.stringify(A.data,this.replacer)),t}encodeAsBinary(A){const t=LdA(A),n=this.encodeAsString(t.packet),B=t.buffers;return B.unshift(n),B}}function zT(e){return Object.prototype.toString.call(e)==="[object Object]"}class g3 extends eB{constructor(A){super(),this.reviver=A}add(A){let t;if(typeof A=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t=this.decodeString(A);const n=t.type===Ke.BINARY_EVENT;n||t.type===Ke.BINARY_ACK?(t.type=n?Ke.EVENT:Ke.ACK,this.reconstructor=new qdA(t),t.attachments===0&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else if(i3(A)||A.base64)if(this.reconstructor)t=this.reconstructor.takeBinaryData(A),t&&(this.reconstructor=null,super.emitReserved("decoded",t));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+A)}decodeString(A){let t=0;const n={type:Number(A.charAt(0))};if(Ke[n.type]===void 0)throw new Error("unknown packet type "+n.type);if(n.type===Ke.BINARY_EVENT||n.type===Ke.BINARY_ACK){const a=t+1;for(;A.charAt(++t)!=="-"&&t!=A.length;);const s=A.substring(a,t);if(s!=Number(s)||A.charAt(t)!=="-")throw new Error("Illegal attachments");n.attachments=Number(s)}if(A.charAt(t+1)==="/"){const a=t+1;for(;++t&&!(A.charAt(t)===","||t===A.length););n.nsp=A.substring(a,t)}else n.nsp="/";const B=A.charAt(t+1);if(B!==""&&Number(B)==B){const a=t+1;for(;++t;){const s=A.charAt(t);if(s==null||Number(s)!=s){--t;break}if(t===A.length)break}n.id=Number(A.substring(a,t+1))}if(A.charAt(++t)){const a=this.tryParse(A.substr(t));if(g3.isPayloadValid(n.type,a))n.data=a;else throw new Error("invalid payload")}return n}tryParse(A){try{return JSON.parse(A,this.reviver)}catch{return!1}}static isPayloadValid(A,t){switch(A){case Ke.CONNECT:return zT(t);case Ke.DISCONNECT:return t===void 0;case Ke.CONNECT_ERROR:return typeof t=="string"||zT(t);case Ke.EVENT:case Ke.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]=="number"||typeof t[0]=="string"&&JdA.indexOf(t[0])===-1);case Ke.ACK:case Ke.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class qdA{constructor(A){this.packet=A,this.buffers=[],this.reconPack=A}takeBinaryData(A){if(this.buffers.push(A),this.buffers.length===this.reconPack.attachments){const t=OdA(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const _dA=Object.freeze(Object.defineProperty({__proto__:null,Decoder:g3,Encoder:jdA,get PacketType(){return Ke},protocol:KdA},Symbol.toStringTag,{value:"Module"}));function si(e,A,t){return e.on(A,t),function(){e.off(A,t)}}const $dA=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class NT extends eB{constructor(A,t,n){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=A,this.nsp=t,n&&n.auth&&(this.auth=n.auth),this._opts=Object.assign({},n),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const A=this.io;this.subs=[si(A,"open",this.onopen.bind(this)),si(A,"packet",this.onpacket.bind(this)),si(A,"error",this.onerror.bind(this)),si(A,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...A){return A.unshift("message"),this.emit.apply(this,A),this}emit(A,...t){var n,B,a;if($dA.hasOwnProperty(A))throw new Error('"'+A.toString()+'" is a reserved event name');if(t.unshift(A),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;const s={type:Ke.EVENT,data:t};if(s.options={},s.options.compress=this.flags.compress!==!1,typeof t[t.length-1]=="function"){const d=this.ids++,G=t.pop();this._registerAckCallback(d,G),s.id=d}const i=(B=(n=this.io.engine)===null||n===void 0?void 0:n.transport)===null||B===void 0?void 0:B.writable,o=this.connected&&!(!((a=this.io.engine)===null||a===void 0)&&a._hasPingExpired());return this.flags.volatile&&!i||(o?(this.notifyOutgoingListeners(s),this.packet(s)):this.sendBuffer.push(s)),this.flags={},this}_registerAckCallback(A,t){var n;const B=(n=this.flags.timeout)!==null&&n!==void 0?n:this._opts.ackTimeout;if(B===void 0){this.acks[A]=t;return}const a=this.io.setTimeoutFn(()=>{delete this.acks[A];for(let i=0;i<this.sendBuffer.length;i++)this.sendBuffer[i].id===A&&this.sendBuffer.splice(i,1);t.call(this,new Error("operation has timed out"))},B),s=(...i)=>{this.io.clearTimeoutFn(a),t.apply(this,i)};s.withError=!0,this.acks[A]=s}emitWithAck(A,...t){return new Promise((n,B)=>{const a=(s,i)=>s?B(s):n(i);a.withError=!0,t.push(a),this.emit(A,...t)})}_addToQueue(A){let t;typeof A[A.length-1]=="function"&&(t=A.pop());const n={id:this._queueSeq++,tryCount:0,pending:!1,args:A,flags:Object.assign({fromQueue:!0},this.flags)};A.push((B,...a)=>(this._queue[0],B!==null?n.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(B)):(this._queue.shift(),t&&t(null,...a)),n.pending=!1,this._drainQueue())),this._queue.push(n),this._drainQueue()}_drainQueue(A=!1){if(!this.connected||this._queue.length===0)return;const t=this._queue[0];t.pending&&!A||(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.args))}packet(A){A.nsp=this.nsp,this.io._packet(A)}onopen(){typeof this.auth=="function"?this.auth(A=>{this._sendConnectPacket(A)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(A){this.packet({type:Ke.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},A):A})}onerror(A){this.connected||this.emitReserved("connect_error",A)}onclose(A,t){this.connected=!1,delete this.id,this.emitReserved("disconnect",A,t),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(A=>{if(!this.sendBuffer.some(n=>String(n.id)===A)){const n=this.acks[A];delete this.acks[A],n.withError&&n.call(this,new Error("socket has been disconnected"))}})}onpacket(A){if(A.nsp===this.nsp)switch(A.type){case Ke.CONNECT:A.data&&A.data.sid?this.onconnect(A.data.sid,A.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case Ke.EVENT:case Ke.BINARY_EVENT:this.onevent(A);break;case Ke.ACK:case Ke.BINARY_ACK:this.onack(A);break;case Ke.DISCONNECT:this.ondisconnect();break;case Ke.CONNECT_ERROR:this.destroy();const n=new Error(A.data.message);n.data=A.data.data,this.emitReserved("connect_error",n);break}}onevent(A){const t=A.data||[];A.id!=null&&t.push(this.ack(A.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(A){if(this._anyListeners&&this._anyListeners.length){const t=this._anyListeners.slice();for(const n of t)n.apply(this,A)}super.emit.apply(this,A),this._pid&&A.length&&typeof A[A.length-1]=="string"&&(this._lastOffset=A[A.length-1])}ack(A){const t=this;let n=!1;return function(...B){n||(n=!0,t.packet({type:Ke.ACK,id:A,data:B}))}}onack(A){const t=this.acks[A.id];typeof t=="function"&&(delete this.acks[A.id],t.withError&&A.data.unshift(null),t.apply(this,A.data))}onconnect(A,t){this.id=A,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(A=>this.emitEvent(A)),this.receiveBuffer=[],this.sendBuffer.forEach(A=>{this.notifyOutgoingListeners(A),this.packet(A)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(A=>A()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:Ke.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(A){return this.flags.compress=A,this}get volatile(){return this.flags.volatile=!0,this}timeout(A){return this.flags.timeout=A,this}onAny(A){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(A),this}prependAny(A){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(A),this}offAny(A){if(!this._anyListeners)return this;if(A){const t=this._anyListeners;for(let n=0;n<t.length;n++)if(A===t[n])return t.splice(n,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(A){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(A),this}prependAnyOutgoing(A){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(A),this}offAnyOutgoing(A){if(!this._anyOutgoingListeners)return this;if(A){const t=this._anyOutgoingListeners;for(let n=0;n<t.length;n++)if(A===t[n])return t.splice(n,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(A){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const t=this._anyOutgoingListeners.slice();for(const n of t)n.apply(this,A.data)}}}function kG(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}kG.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var A=Math.random(),t=Math.floor(A*this.jitter*e);e=(Math.floor(A*10)&1)==0?e-t:e+t}return Math.min(e,this.max)|0},kG.prototype.reset=function(){this.attempts=0},kG.prototype.setMin=function(e){this.ms=e},kG.prototype.setMax=function(e){this.max=e},kG.prototype.setJitter=function(e){this.jitter=e};class l3 extends eB{constructor(A,t){var n;super(),this.nsps={},this.subs=[],A&&typeof A=="object"&&(t=A,A=void 0),t=t||{},t.path=t.path||"/socket.io",this.opts=t,bv(this,t),this.reconnection(t.reconnection!==!1),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor((n=t.randomizationFactor)!==null&&n!==void 0?n:.5),this.backoff=new kG({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState="closed",this.uri=A;const B=t.parser||_dA;this.encoder=new B.Encoder,this.decoder=new B.Decoder,this._autoConnect=t.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(A){return arguments.length?(this._reconnection=!!A,A||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(A){return A===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=A,this)}reconnectionDelay(A){var t;return A===void 0?this._reconnectionDelay:(this._reconnectionDelay=A,(t=this.backoff)===null||t===void 0||t.setMin(A),this)}randomizationFactor(A){var t;return A===void 0?this._randomizationFactor:(this._randomizationFactor=A,(t=this.backoff)===null||t===void 0||t.setJitter(A),this)}reconnectionDelayMax(A){var t;return A===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=A,(t=this.backoff)===null||t===void 0||t.setMax(A),this)}timeout(A){return arguments.length?(this._timeout=A,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(A){if(~this._readyState.indexOf("open"))return this;this.engine=new VdA(this.uri,this.opts);const t=this.engine,n=this;this._readyState="opening",this.skipReconnect=!1;const B=si(t,"open",function(){n.onopen(),A&&A()}),a=i=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",i),A?A(i):this.maybeReconnectOnOpen()},s=si(t,"error",a);if(this._timeout!==!1){const i=this._timeout,o=this.setTimeoutFn(()=>{B(),a(new Error("timeout")),t.close()},i);this.opts.autoUnref&&o.unref(),this.subs.push(()=>{this.clearTimeoutFn(o)})}return this.subs.push(B),this.subs.push(s),this}connect(A){return this.open(A)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const A=this.engine;this.subs.push(si(A,"ping",this.onping.bind(this)),si(A,"data",this.ondata.bind(this)),si(A,"error",this.onerror.bind(this)),si(A,"close",this.onclose.bind(this)),si(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(A){try{this.decoder.add(A)}catch(t){this.onclose("parse error",t)}}ondecoded(A){Cv(()=>{this.emitReserved("packet",A)},this.setTimeoutFn)}onerror(A){this.emitReserved("error",A)}socket(A,t){let n=this.nsps[A];return n?this._autoConnect&&!n.active&&n.connect():(n=new NT(this,A,t),this.nsps[A]=n),n}_destroy(A){const t=Object.keys(this.nsps);for(const n of t)if(this.nsps[n].active)return;this._close()}_packet(A){const t=this.encoder.encode(A);for(let n=0;n<t.length;n++)this.engine.write(t[n],A.options)}cleanup(){this.subs.forEach(A=>A()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(A,t){var n;this.cleanup(),(n=this.engine)===null||n===void 0||n.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",A,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const A=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const t=this.backoff.duration();this._reconnecting=!0;const n=this.setTimeoutFn(()=>{A.skipReconnect||(this.emitReserved("reconnect_attempt",A.backoff.attempts),!A.skipReconnect&&A.open(B=>{B?(A._reconnecting=!1,A.reconnect(),this.emitReserved("reconnect_error",B)):A.onreconnect()}))},t);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}}onreconnect(){const A=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",A)}}const Qf={};function wf(e,A){typeof e=="object"&&(A=e,e=void 0),A=A||{};const t=SdA(e,A.path||"/socket.io"),n=t.source,B=t.id,a=t.path,s=Qf[B]&&a in Qf[B].nsps,i=A.forceNew||A["force new connection"]||A.multiplex===!1||s;let o;return i?o=new l3(n,A):(Qf[B]||(Qf[B]=new l3(n,A)),o=Qf[B]),t.query&&!A.query&&(A.query=t.queryKey),o.socket(t.path,A)}Object.assign(wf,{Manager:l3,Socket:NT,io:wf,connect:wf});const XT=F.createContext({io:null,isConnected:!1}),AuA=({children:e})=>{const[A,t]=F.useState(null),[n,B]=F.useState(!1),a=F.useRef(null),s=F.useRef(!1),{token:i}=XZ();return F.useEffect(()=>{if(a.current?.connected||s.current)return;const o="https://api.beta.careshiphealth.com",g=wg("psid")||i,d=wg("woid");if(!g||!d||!o)return;s.current=!0;const G=wf(`${o}/rt`,{withCredentials:!0,extraHeaders:{Authorization:`Bearer ${g}`,"x-org-id":d,"x-user-context":"lead"}});return a.current=G,t(G),G.on("connect",()=>{B(!0),s.current=!1}),G.on("disconnect",()=>{B(!1),s.current=!1}),G.on("error",f=>{console.error("Socket error:",f),s.current=!1}),()=>{G.connected&&G.disconnect(),a.current=null,t(null),B(!1),s.current=!1}},[i]),E.jsx(XT.Provider,{value:{io:A,isConnected:n},children:e})},euA=()=>F.useContext(XT),LT=F.createContext({io:null,isConnected:!1}),tuA=({children:e})=>{const[A,t]=F.useState(null),[n,B]=F.useState(!1),a=F.useRef(null),s=F.useRef(!1),{bot_token:i}=XZ();return F.useEffect(()=>{if(a.current?.connected||s.current)return;const o="https://api.beta.careshiphealth.com",g=wg("bot_psid")||i,d=wg("woid");if(!g||!d||!o)return;s.current=!0;const G=wf(`${o}/rt`,{withCredentials:!0,extraHeaders:{Authorization:`Bearer ${g}`,"x-org-id":d,"x-user-context":"user"}});return a.current=G,t(G),G.on("connect",()=>{B(!0),s.current=!1}),G.on("disconnect",()=>{B(!1),s.current=!1}),G.on("error",f=>{console.error("Socket error:",f),s.current=!1}),()=>{G.connected&&G.disconnect(),a.current=null,t(null),B(!1),s.current=!1}},[i]),E.jsx(LT.Provider,{value:{io:A,isConnected:n},children:e})},nuA=()=>F.useContext(LT);var Hv=(e=>(e.EXCELLENT="excellent",e.GOOD="good",e.POOR="poor",e))(Hv||{});const BuA=e=>La.post("/chat-feedback/submit",e),auA=e=>La.get(`/chat-feedback/check/${e}`),suA=({isOpen:e,onClose:A,chatId:t,onSubmitSuccess:n})=>{const[B,a]=F.useState(null),[s,i]=F.useState(""),[o,g]=F.useState(!1),[d,G]=F.useState(!1),f=[{value:Hv.EXCELLENT,label:"Excellent",emoji:"🤩",color:"#10B981"},{value:Hv.GOOD,label:"Good",emoji:"😊",color:"#F59E0B"},{value:Hv.POOR,label:"Poor",emoji:"☹️",color:"#EF4444"}],v=async()=>{if(B)try{g(!0),await BuA({chatId:t,rating:B,comment:s.trim()||void 0}),G(!0),setTimeout(()=>{n?.(),A()},1500)}catch(H){console.error("Failed to submit feedback:",H),alert("Failed to submit feedback. Please try again.")}finally{g(!1)}};return e?E.jsx(kS,{children:E.jsx(wB.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:A,children:E.jsx(wB.div,{initial:{scale:.9,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.9,opacity:0},transition:{type:"spring",duration:.3},className:"bg-white rounded-lg max-w-md w-full p-6 shadow-xl",onClick:H=>H.stopPropagation(),children:d?E.jsxs("div",{className:"text-center py-8",children:[E.jsx("div",{className:"text-6xl mb-4",children:"✅"}),E.jsx("h3",{className:"text-xl font-semibold text-gray-900 mb-2",children:"Thank you for your feedback!"}),E.jsx("p",{className:"text-gray-600 text-sm",children:"Your feedback helps us improve our service."})]}):E.jsxs(E.Fragment,{children:[E.jsx("h3",{className:"text-xl font-semibold text-gray-900 mb-2",children:"How was your experience?"}),E.jsx("p",{className:"text-gray-600 text-sm mb-6",children:"Please rate your conversation with our assistant"}),E.jsx("div",{className:"grid grid-cols-3 gap-3 mb-6",children:f.map(H=>E.jsxs("button",{onClick:()=>a(H.value),className:`p-4 rounded-lg border-2 transition-all hover:scale-105 ${B===H.value?"border-purple-500 bg-purple-50":"border-gray-200 hover:border-gray-300"}`,children:[E.jsx("div",{className:"text-4xl mb-2",children:H.emoji}),E.jsx("div",{className:"text-sm font-medium text-gray-700",children:H.label})]},H.value))}),E.jsxs("div",{className:"mb-6",children:[E.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Additional comments (optional)"}),E.jsx("textarea",{value:s,onChange:H=>i(H.target.value),placeholder:"Tell us more about your experience...",className:"w-full px-3 py-2 border border-gray-300 rounded-lg resize-none focus:outline-none focus:ring-2 focus:ring-purple-500",rows:3,maxLength:500}),E.jsxs("div",{className:"text-xs text-gray-500 mt-1 text-right",children:[s.length,"/500"]})]}),E.jsxs("div",{className:"flex gap-3",children:[E.jsx("button",{onClick:A,className:"flex-1 px-4 py-2 border border-gray-300 rounded-lg text-gray-700 hover:bg-gray-50 transition-colors",disabled:o,children:"Skip"}),E.jsx("button",{onClick:v,disabled:!B||o,className:"flex-1 px-4 py-2 bg-black text-white rounded-lg hover:bg-gray-800 transition-colors disabled:bg-gray-300 disabled:cursor-not-allowed",children:o?"Submitting...":"Submit"})]})]})})})}):null},ruA=()=>{const{token:e}=Pg(),{loginMutation:A}=Th(),t=xH(),n=bs(),{initialMessage:B}=Th(),[a,s]=F.useState(B||""),[i,o]=F.useState(!1),[g,d]=F.useState(!1),[G,f]=F.useState(60),{io:v,isConnected:H}=euA(),{io:y}=nuA(),Y=c0(),{patient:Z}=kB(),P=F.useMemo(()=>Aa.getState().organization,[]),x=F.useMemo(()=>P?.members?.[0],[P]),V=F.useRef(v),k=F.useRef(y),S=F.useMemo(()=>Aa.getState().patient?.id,[Z]),K=F.useRef(!1),J=F.useRef(null),eA=F.useRef(new Set),sA=F.useRef(!1),cA=F.useRef(null),[CA,ZA]=F.useState(!1),[UA,DA]=F.useState(!1),L=F.useRef(!1),j=F.useRef(0);F.useEffect(()=>{V.current=v},[v]),F.useEffect(()=>{k.current=y,console.log("bot scket changing"),console.log({botSocket:y})},[y]),F.useEffect(()=>{K.current=Aa.getState().chats.awaitingTeamReply??!1},[]);const q=Z?.chatMembers&&Z?.chatMembers.length>0?Z.chatMembers[0].chat?.id:null,WA=o0({queryKey:["feedback-status",q],queryFn:async()=>q?(await auA(q)).data.data:null,enabled:!!q&&!!e,refetchOnWindowFocus:!1}),z=mX({queryKey:["chat-messages",q],queryFn:async({pageParam:NA=1})=>q?(await AdA(q,{page:NA,limit:5})).data:null,enabled:!!q,refetchOnWindowFocus:!0,getNextPageParam:NA=>{if(NA?.meta)return NA.meta.totalPages>NA.meta.currentPage?Number(NA.meta.currentPage)+1:void 0},initialPageParam:1}),_=F.useMemo(()=>z.data?.pages?z.data.pages.flatMap(_A=>_A?.data||[]).reverse():[],[z.data]),kA=F.useCallback(()=>{J.current||(J.current=setInterval(()=>{f(NA=>NA<=1?(clearInterval(J.current),J.current=null,0):NA-1)},1e3))},[]),HA=F.useCallback(()=>{J.current!==null&&(clearInterval(J.current),J.current=null),f(60)},[]),vA=F.useCallback(NA=>{const _A=k.current;console.log({bot:_A}),!(!NA.trim()||!q||!_A||!x?.id)&&(K.current||_A.emit("chat:bot-message",{content:NA.trim(),chatId:q,type:"message",sender:x.id}))},[q,x?.id]),KA=F.useCallback(NA=>{const _A=V.current;console.log({sock:_A,conversationId:q,loadingBotResponse:i,currentPatientCur:S}),!(!NA.trim()||!q||!_A||i||!S)&&(s(""),_A.emit("chat:message",{content:NA.trim(),chatId:q,type:"message",sender:S}),vA(NA))},[q,i,vA]),JA=F.useCallback(()=>{kA(),setTimeout(async()=>{if(K.current){HA(),Aa.setState(Ae=>({chats:{...Ae.chats,awaitingTeamReply:!1}}));const NA=`I am sorry. Looks like everyone is busy at the moment or un-available to respond instantly. We will get back to you ${Z?.email?`on ${Z?.email}`:"through your email"}`,_A=k.current;_A&&x?.id&&_A.emit("chat:message",{content:NA,chatId:q,type:"message",sender:x?.id}),ZA(!0)}},6e4)},[kA,HA,Z?.email,q,x?.id]);F.useEffect(()=>{console.log({initialMessage:B,loginSuccess:A?.isSuccess,messagesQuerySuccess:z?.isSuccess}),A?.isSuccess&&z?.isSuccess&&B&&(console.log("inittt"),vA(B),o(!0),s(""))},[A?.isSuccess,z?.isSuccess,B,vA]);const Ge=NA=>{NA.chatId===q&&!eA.current.has(NA.id)&&(eA.current.add(NA.id),Y.invalidateQueries({queryKey:["chat-messages",q]}),NA.sender_participant?.patientId===S&&!CA&&(o(!0),sA.current=!0,cA.current&&clearTimeout(cA.current),cA.current=setTimeout(()=>{sA.current&&(console.warn("Bot response timeout - clearing loading state"),o(!1),sA.current=!1)},3e4)),ZA(!1),K.current&&NA.sender_participant?.member?.user.id!==x?.id&&!NA.sender_participant.patientId&&(Aa.setState(_A=>({chats:{..._A.chats,awaitingTeamReply:!1}})),K.current=!1))};F.useEffect(()=>{const NA=V.current;if(!(!NA||!q))return NA.emit("chat:join",{chatId:q}),NA.on("chat:messages",Ge),NA.on("error",_A=>{console.error("Socket error:",_A.message)}),()=>{const _A=V.current;k.current,_A&&(_A.emit("chat:leave",{chatId:q}),_A.off("chat:messages",Ge),_A.off("error"))}},[v,q,Y,x?.id]),F.useEffect(()=>{const NA=k.current;if(!NA||!q)return;NA.emit("chat:join",{chatId:q});const _A=Yn=>{console.log("Bot message received:",{message:Yn,conversationId:q}),Yn.chatId===q&&!eA.current.has(Yn.id)&&(cA.current&&(clearTimeout(cA.current),cA.current=null),o(!1),sA.current=!1,eA.current.add(Yn.id),Y.invalidateQueries({queryKey:["chat-messages",q]}),t.updateLoginMutation({}))},Ae=Yn=>{_A(Yn),Aa.setState(ra=>({chats:{...ra.chats,awaitingTeamReply:!0}})),JA()};return NA.on("chat:bot-messages",_A),NA.on("chat:bot-messages:unanswered_query",Ae),NA.on("chat:bot-messages:human_agent_request",Ae),NA.on("chat:bot-messages:book_appointment",Ge),NA.on("chat:bot-messages:schedule_meet_and_greet",Ge),NA.on("chat:bot-messages:get_subscription",Ge),NA.on("error",Yn=>{console.error("Bot socket error:",Yn.message)}),()=>{NA.off("chat:bot-messages",_A),NA.off("chat:bot-messages:unanswered_query",Ae),NA.off("chat:bot-messages:human_agent_request",Ae),NA.off("chat:bot-messages:book_appointment",Ge),NA.off("chat:bot-messages:schedule_meet_and_greet",Ge),NA.off("chat:bot-messages:get_subscription",Ge),NA.off("error"),cA.current&&(clearTimeout(cA.current),cA.current=null)}},[y,q,Y,x?.id,JA]),F.useEffect(()=>Aa.subscribe(_A=>{K.current=_A.chats.awaitingTeamReply??!1}),[]),F.useEffect(()=>{if(!WA.data||!q||L.current)return;const{shouldPromptFeedback:NA,currentMessageCount:_A}=WA.data;if(!(!g||_A<4)&&NA&&j.current!==_A&&(j.current=_A,!i&&!K.current)){const Ae=setTimeout(()=>{DA(!0),L.current=!0},2e3);return()=>clearTimeout(Ae)}},[WA.data,q,g,i,_.length]);const Te=()=>{WA.refetch(),L.current=!1},yn=E.jsx("button",{onClick:()=>{n("/home")},className:"rounded-full border border-black text-sm px-2",children:"End Chat"});return F.useEffect(()=>{if(z.isPending||g)return;if(_.length>0){d(!0);return}const NA=_m.slice(0,2),_A=[];let Ae=500;NA.forEach(ra=>{const ri=setTimeout(()=>{KA(ra)},Ae);_A.push(ri),Ae+=1500});const Yn=setTimeout(()=>{d(!0)},Ae+NA.length*1500);return _A.push(Yn),()=>{_A.forEach(ra=>clearTimeout(ra))}},[z.isPending,_.length,g,KA]),e?E.jsxs(ro,{showMinMaxIcon:!0,title:`Chat with ${x?.user?.first_name}`,rightComponent:yn,children:[E.jsxs("div",{className:"flex flex-col justify-between h-full",children:[E.jsx("div",{className:"pl-2 pr-6 text-sm flex flex-col gap-5 mt-3",children:z.isLoading?E.jsx("div",{className:"flex justify-center mt-10",children:E.jsx(vg,{})}):z.isError?E.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-3 flex items-center justify-center",children:E.jsx("div",{className:"flex flex-col items-center justify-center text-center",children:E.jsx("p",{className:"text-sm text-gray-500 mt-4 max-w-[150px] mx-auto",children:"Error loading chats"})})}):E.jsx(sdA,{messages:_,hasNextPage:z.hasNextPage||!1,isFetchingNextPage:z.isFetchingNextPage,onLoadMore:()=>{z.fetchNextPage()},awaitingTeamReplyCountdown:G,loadingBotResponse:i})}),g&&E.jsx("div",{className:"px-3 sticky bottom-0 bg-white pt-2 z-10 pb-3",children:E.jsx(wB.div,{initial:{y:6,opacity:0},animate:{y:0,opacity:1},transition:{delay:.1},children:E.jsxs("div",{className:"relative flex items-center mt-2.5",children:[E.jsx("input",{autoFocus:!0,className:"py-3.5 pl-3 pr-21 outline-none w-full border border-[#CECECE] text-sm",type:"text",placeholder:"Ask AI",value:a,onChange:NA=>s(NA.target.value),onKeyUp:NA=>{if(NA.key=="Enter"){if(i)return;KA(a)}}}),E.jsx(wB.button,{whileTap:{scale:.95},whileHover:{scale:1},onClick:()=>KA(a),disabled:i,className:"text-sm disabled:opacity-60 disabled:cursor-default absolute right-2 top-1/2 -translate-y-1/2 bg-black hover:shadow-md transition-shadow text-white py-1.5 px-4 hover:opacity-80 rounded-full text-center flex items-center gap-2",children:i?E.jsx(vg,{size:"sm",color:"white"}):"Send"})]})})})]}),q&&E.jsx(suA,{isOpen:UA,onClose:()=>DA(!1),chatId:q,onSubmitSuccess:Te})]}):E.jsx($lA,{})},iuA=()=>E.jsx(j1,{children:E.jsxs(_1,{children:[E.jsx(Ki,{path:"*",element:E.jsx(iL,{})}),E.jsx(Ki,{path:"/home",element:E.jsx(Jj,{})}),E.jsx(Ki,{path:"/chat",element:E.jsx(ruA,{})}),E.jsx(Ki,{path:"/call-back",element:E.jsx(_lA,{})}),E.jsx(Ki,{path:"/clarity-call",element:E.jsx(DAA,{})}),E.jsx(Ki,{path:"/custom-widget",element:E.jsx(FAA,{})}),E.jsx(Ki,{path:"/meet-and-greet",element:E.jsx(uaA,{})}),E.jsx(Ki,{path:"/appointment",element:E.jsx(GaA,{})}),E.jsx(Ki,{path:"/subscription",element:E.jsx(JaA,{})})]})}),cuA=new GX,ouA=e=>{const[A,t]=O.useState("");return F.useEffect(()=>{if(VH("wak"),VH("woid"),e?.orgId&&e?.apiKey)return Du("wak",e.apiKey),Du("woid",e.orgId),t(e.orgId);if(typeof window<"u"){const B=(()=>{const a=document.getElementById("supercare-09u2ekhbpo-script");if(a)return a;const s=document.currentScript||null;return s||document.querySelector("script[data-org-id],script[data-supercare-org-id]")})();if(B){let a=null,s=null;try{if(B.src){const f=new URL(B.src,window.location.href).searchParams;a=f.get("orgId")||f.get("orgID")||f.get("orgid"),s=f.get("apiKey")||f.get("apikey")||f.get("api_key")}}catch{}const i=B.getAttribute("data-org-id")||B.getAttribute("data-supercare-org-id")||B?.dataset?.orgId||null,o=B.getAttribute("data-api-key")||B.getAttribute("data-supercare-api-key")||B?.dataset?.apiKey||null,g=a||i,d=s||o;d&&Du("wak",d),g&&(Du("woid",g),t(g))}}},[e.orgId]),E.jsxs(i1.div,{id:"supercare-09u2ekhbpo-root",className:`${T7} relative !font_graphik`,children:[E.jsx("style",{type:"text/css",children:x7}),E.jsx("style",{type:"text/css",children:R7}),E.jsx(QX,{client:cuA,children:E.jsx(rL,{orgId:A,children:E.jsx(AuA,{children:E.jsx(tuA,{children:E.jsx(HAA,{children:E.jsx(iuA,{})})})})})})]})};var d3={exports:{}},ff={},u3={exports:{}},G3={};/**
469
+ </button>`),A=A.replace(/\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/g,'<a href="$2" target="_blank" style="color:#7D2CFF;text-decoration:underline;">$1</a>'),A=A.replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>"),A=A.replace(new RegExp('(?<!href=")(https?:\\/\\/[^\\s<]+)',"g"),'<a href="$1" target="_blank" style="color:#7D2CFF;text-decoration:underline;">$1</a>'),A},pT=({name:e,index:A,message:t})=>E.jsx("div",{className:"flex justify-end",children:E.jsxs(wB.div,{initial:{y:3,opacity:0},animate:{y:0,opacity:1},transition:{duration:.6,delay:.1*(A||0)},children:[E.jsx("div",{className:"p-3 bg-[#EFEFEF] break-words",dangerouslySetInnerHTML:{__html:ET(t.content).trim()}}),E.jsxs("p",{className:"justify-self-end pt-1 text-[10px] text-supercare-grey-500",children:[XA(t.created_at).format("M/DD")," • ",XA(t.created_at).format("H:mm A")]})]})}),Qv=({name:e,avatar:A,children:t,index:n,message:B,loading:a})=>{const s="guest_sender"in(B||{})&&B.guest_sender==="assistant",i=!s&&B&&B.sender_participant&&B.sender_participant.member&&B.sender_participant?.member?.is_bot;return E.jsxs(wB.div,{className:"",initial:{y:3,opacity:0},animate:{y:0,opacity:1},transition:{duration:.6,delay:.1*(n||0)},children:[E.jsxs("div",{className:`relative p-3 max-w-[320px] ${s||i||a?"ai_response_bg bg-[#F9F6FF]":"border border-[#E4E4E4]"}`,children:[t?E.jsx(E.Fragment,{children:t}):E.jsx("div",{className:"break-words",dangerouslySetInnerHTML:{__html:ET(B?.content||"").trim()}}),E.jsx("div",{className:"absolute -bottom-2 -right-2"})]}),E.jsxs("p",{className:"justify-self-start pt-1 text-[10px]",children:[!(s||i)&&"sender"in(B||{})&&E.jsx("span",{className:"text-[13px] text-supercare-grey-500}",children:(B?.sender_participant?.member?.user?.email||"").length>20?B.sender_participant.member?.user.email.slice(0,20)+"... ":B.sender_participant.member?.user.email+" • "}),!a&&E.jsxs("span",{className:"text-supercare-grey-500",children:[XA(B?.created_at).format("M/DD")," • ",XA(B?.created_at).format("H:mm A")]})]})]})},_m=[`👋 Hey, I'm ${fI} !`,"I can clarify any questions you have regarding our services & memberships. How can I help you today?","In case the conversation discontinues, pls enter your email so that we can get back to you"],$lA=()=>{const e=bs(),{initialMessage:A}=Th(),[t,n]=F.useState([]),[B,a]=F.useState(A||""),[s,i]=F.useState(!1),[o,g]=F.useState(!1),[d,G]=F.useState(!1),{organization:f}=kB(),v=f?.members?.[0],{login:H,errMessage:y}=Pg(),Y=()=>{const x=B.trim();if(x==="")return;const V={id:`guest-msg-${Date.now()}-u`,content:x,guest_sender:"user",created_at:new Date};n(k=>[...k,V]),a(""),setTimeout(()=>{g(!0)},1e3),setTimeout(()=>{const k={id:`guest-msg-${Date.now()}-a`,content:_m[2],guest_sender:"assistant",created_at:new Date};n(S=>[...S,k]),g(!1)},1500),setTimeout(()=>{i(!0)},2500),Aa.setState(k=>({...k,chats:{...k.chats,initialMessage:x}}))},Z=()=>{if(B.trim()==="")return;const x={id:`guest-msg-${Date.now()}-u`,content:B.trim(),guest_sender:"user",created_at:new Date};H.mutate({email:B.trim(),initialMessages:[...t,x]}),a("")},P=E.jsx("button",{onClick:()=>{e("/home")},className:"rounded-full border border-black text-sm px-2",children:"End Chat"});return F.useEffect(()=>{let x=1e3;const V=[];if(t.length===0){const k=_m.slice(0,2);k.forEach((K,J)=>{const eA=window.setTimeout(()=>{n(sA=>[...sA,{id:`guest-msg-${J}`,content:K,guest_sender:"assistant",created_at:new Date}])},x+J*1e3);V.push(eA)}),V.push(window.setTimeout(()=>g(!0),500));const S=x+k.length*500;V.push(window.setTimeout(()=>{g(!1),G(!0)},S))}return()=>{V.forEach(k=>clearTimeout(k))}},[]),E.jsx(ro,{showMinMaxIcon:!0,title:`Chat with ${v?.user?.first_name}`,rightComponent:P,children:E.jsxs("div",{className:"flex flex-col justify-between h-full",children:[E.jsxs("div",{className:"pl-2 pr-6 text-sm flex flex-col gap-5 mt-3",children:[t.map((x,V)=>x.guest_sender==="user"?E.jsx(pT,{index:V,name:"You",message:x},V):E.jsxs(wB.div,{className:"flex items-start gap-2",initial:{y:3,opacity:0},animate:{y:0,opacity:1},transition:{duration:.6},children:[E.jsxs("div",{className:"flex flex-col gap-1 items-center",children:[E.jsx("img",{src:v?.user?.profile_picture?.url,alt:"Ela Icon",width:40}),E.jsx("p",{className:"text-xs tracking-[0.58px] ai_response_text",children:v?.user?.first_name})]}),E.jsx("div",{className:"flex flex-col items-start gap-1",children:E.jsx(Qv,{index:V,name:v?.user?.first_name||fI,message:x},V)})]})),s&&E.jsxs("div",{className:"",children:[E.jsxs("div",{className:"relative flex items-center -mt-3 ml-[50px]",children:[E.jsx("input",{autoFocus:s,className:"py-3.5 pl-3 pr-21 outline-none w-full border border-[#CECECE] text-sm",type:"text",placeholder:"Your email ID please",value:B,onChange:x=>a(x.target.value),onKeyUp:x=>{if(x.key=="Enter"){if(H.isPending)return;Z()}}})," ",E.jsx(wB.button,{whileTap:{scale:.95},whileHover:{scale:1},onClick:Z,disabled:H.isPending,className:"text-sm disabled:opacity-60 disabled:cursor-default absolute right-2 top-1/2 -translate-y-1/2 bg-black hover:shadow-md transition-shadow text-white py-1.5 px-4 hover:opacity-80 rounded-full text-center flex items-center gap-2",children:H.isPending?E.jsx(vg,{size:"sm",color:"white"}):"Send"})]}),E.jsx("p",{className:"text-red-500 pl-3 text-sm",children:y})]}),o&&E.jsxs("div",{className:"flex items-start gap-2",children:[E.jsxs("div",{className:"flex flex-col gap-1 items-center",children:[E.jsx("img",{src:v?.user?.profile_picture?.url,width:40,alt:`${v?.user?.first_name} Icon`}),E.jsx("p",{className:"text-xs ai_response_text",children:v?.user?.first_name})]}),E.jsx(Qv,{loading:!0,name:v?.user?.email||qy,children:E.jsx("div",{className:"flex items-center gap-1",children:[0,1,2].map(x=>E.jsx(wB.div,{transition:{y:{duration:.8,repeat:1/0,ease:"easeOut",delay:x*.1}},animate:{y:["-100%","0%"]},children:E.jsxs("svg",{width:"7",height:"7",viewBox:"0 0 7 7",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[E.jsx("circle",{cx:"3.5",cy:"3.5",r:"3",fill:"#F9F6FF",stroke:"url(#paint0_linear_11221_1318)"}),E.jsx("defs",{children:E.jsxs("linearGradient",{id:"paint0_linear_11221_1318",x1:"1.66591e-07",y1:"0.649091",x2:"10.9417",y2:"4.14756",gradientUnits:"userSpaceOnUse",children:[E.jsx("stop",{"stop-color":"#FF7FF2"}),E.jsx("stop",{offset:"0.305","stop-color":"#526FFF"}),E.jsx("stop",{offset:"0.615","stop-color":"#58D3FF"}),E.jsx("stop",{offset:"0.99","stop-color":"#FF9CC5"})]})})]})},x))})})]})]}),!s&&d&&E.jsx("div",{className:"px-3 sticky bottom-0 bg-white pt-2 z-10 pb-3",children:E.jsx(wB.div,{initial:{y:6,opacity:0},animate:{y:0,opacity:1},transition:{delay:.4},children:E.jsxs("div",{className:"relative flex items-center mt-2.5",children:[E.jsx("input",{autoFocus:!0,className:"py-3.5 pl-3 pr-21 outline-none w-full border border-[#CECECE] text-sm",type:"text",placeholder:"Ask AI",value:B,onChange:x=>a(x.target.value),onKeyUp:x=>{if(x.key=="Enter"){if(o)return;Y()}}}),E.jsx(wB.button,{whileTap:{scale:.95},whileHover:{scale:1},onClick:Y,disabled:o,className:"text-sm disabled:opacity-60 disabled:cursor-default absolute right-2 top-1/2 -translate-y-1/2 bg-black hover:shadow-md transition-shadow text-white py-1.5 px-4 hover:opacity-80 rounded-full text-center flex items-center gap-2",children:o?E.jsx(vg,{size:"sm",color:"white"}):"Send"})]})})})]})})},AdA=(e,A)=>(console.log({chatId:e}),La.get(`/chats/${e}/messages`,{params:A})),edA=e=>e.sender_participant?.member?.is_bot===!0,tdA=e=>!!e.sender_participant?.patientId,ndA=e=>!!(e.sender_participant?.member&&!e.sender_participant?.member?.is_bot),BdA=e=>edA(e)?fI:tdA(e)?"You":ndA(e)?e.sender_participant?.member?.user?.email||"Care Manager":"Guest",adA=e=>{const A={};if(!e||e.length===0)return A;let t=0,n=null;for(let B=0;B<e.length;B++){const a=e[B],s=BdA(a);s!==n&&(t+=1,n=s);const i=`${s}_${t}`;A[i]||(A[i]=[]),A[i].push(a)}return A},sdA=({messages:e,hasNextPage:A,isFetchingNextPage:t,onLoadMore:n,awaitingTeamReplyCountdown:B,loadingBotResponse:a})=>{const{organization:s}=kB(),i=F.useRef(null),o=F.useRef(e.length),g=F.useRef(!1),d=s?.members?.[0],{awaitingTeamReply:G}=Th(),f=F.useMemo(()=>adA(e),[e]);console.log({groupedMessages:f}),F.useEffect(()=>{g.current&&!t&&e.length>o.current&&i.current&&i.current.scrollTo({top:i.current.scrollHeight,behavior:"smooth"}),o.current=e.length,g.current=t||!1},[t,e.length]);const v=()=>{n&&n()},H=y=>y.split("_")[0];return E.jsxs("div",{ref:i,className:`flex-1 overflow-y-auto py-3 ${e.length<6&&"h-max"}`,children:[A&&E.jsx("div",{className:"flex justify-center",children:E.jsx("button",{onClick:v,disabled:t,className:"px-4 text-sm pb-3 text-gray-600 hover:text-gray-900 disabled:opacity-50 disabled:cursor-not-allowed",children:t?"Loading...":"Load older messages"})}),Object.keys(f).map((y,Y)=>H(y)=="You"||H(y)=="Guest"?f[y].filter((Z=>Z.type==="message")).map((Z,P)=>E.jsx(pT,{index:P,name:"You",message:Z},P)):E.jsxs("div",{className:"flex items-start gap-2",children:[E.jsxs("div",{className:"flex flex-col gap-1 items-center",children:[f[y][0].sender_participant?.member?.user?.profile_picture?.url?E.jsx("img",{src:f[y][0].sender_participant?.member?.user?.profile_picture?.url,alt:"Ela Icon",width:40}):E.jsx("div",{className:"w-[2.5rem] h-[2.5rem] leading-[2.5rem] text-[22px] bg-black text-white rounded-full text-center text-xs",children:E.jsx("span",{children:f[y][0].sender_participant?.member?.user?.email[0]})}),f[y][0].sender_participant?.member?.user?.email==d?.user?.email&&E.jsx("p",{className:"text-xs tracking-[0.58px] ai_response_text",children:H(y)})]}),E.jsx("div",{className:"flex flex-col items-start gap-1",children:f[y].filter((Z=>Z.type==="message")).map((Z,P)=>E.jsx(Qv,{index:P,name:Z.sender_participant?.member?.user?.email||"Ela",message:Z},P))})]})),G&&B>0&&B<60&&E.jsxs("div",{className:"text-supercare-grey-500 text-sm text-center my-5",children:[B,"s Awaiting on team"]}),a&&E.jsxs("div",{className:"flex items-start gap-2",children:[E.jsxs("div",{className:"flex flex-col gap-1 items-center",children:[E.jsx("img",{src:d?.user?.profile_picture?.url,alt:`${d?.user?.first_name} Icon`,width:40}),E.jsx("p",{className:"text-xs ai_response_text",children:d?.user?.first_name})]}),E.jsx(Qv,{loading:!0,index:0,name:d?.user?.email||qy,children:E.jsx("div",{className:"flex items-center gap-1",children:[0,1,2].map(y=>E.jsx(wB.div,{transition:{y:{duration:.8,repeat:1/0,ease:"easeOut",delay:y*.1}},animate:{y:["-100%","0%"]},children:E.jsxs("svg",{width:"7",height:"7",viewBox:"0 0 7 7",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[E.jsx("circle",{cx:"3.5",cy:"3.5",r:"3",fill:"#F9F6FF",stroke:"url(#paint0_linear_11221_1318)"}),E.jsx("defs",{children:E.jsxs("linearGradient",{id:"paint0_linear_11221_1318",x1:"1.66591e-07",y1:"0.649091",x2:"10.9417",y2:"4.14756",gradientUnits:"userSpaceOnUse",children:[E.jsx("stop",{"stop-color":"#FF7FF2"}),E.jsx("stop",{offset:"0.305","stop-color":"#526FFF"}),E.jsx("stop",{offset:"0.615","stop-color":"#58D3FF"}),E.jsx("stop",{offset:"0.99","stop-color":"#FF9CC5"})]})})]})},y))})})]})]})},bc=Object.create(null);bc.open="0",bc.close="1",bc.ping="2",bc.pong="3",bc.message="4",bc.upgrade="5",bc.noop="6";const wv=Object.create(null);Object.keys(bc).forEach(e=>{wv[bc[e]]=e});const $m={type:"error",data:"parser error"},mT=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",yT=typeof ArrayBuffer=="function",YT=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,A3=({type:e,data:A},t,n)=>mT&&A instanceof Blob?t?n(A):ZT(A,n):yT&&(A instanceof ArrayBuffer||YT(A))?t?n(A):ZT(new Blob([A]),n):n(bc[e]+(A||"")),ZT=(e,A)=>{const t=new FileReader;return t.onload=function(){const n=t.result.split(",")[1];A("b"+(n||""))},t.readAsDataURL(e)};function kT(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let e3;function rdA(e,A){if(mT&&e.data instanceof Blob)return e.data.arrayBuffer().then(kT).then(A);if(yT&&(e.data instanceof ArrayBuffer||YT(e.data)))return A(kT(e.data));A3(e,!1,t=>{e3||(e3=new TextEncoder),A(e3.encode(t))})}const UT="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Gf=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let e=0;e<UT.length;e++)Gf[UT.charCodeAt(e)]=e;const idA=e=>{let A=e.length*.75,t=e.length,n,B=0,a,s,i,o;e[e.length-1]==="="&&(A--,e[e.length-2]==="="&&A--);const g=new ArrayBuffer(A),d=new Uint8Array(g);for(n=0;n<t;n+=4)a=Gf[e.charCodeAt(n)],s=Gf[e.charCodeAt(n+1)],i=Gf[e.charCodeAt(n+2)],o=Gf[e.charCodeAt(n+3)],d[B++]=a<<2|s>>4,d[B++]=(s&15)<<4|i>>2,d[B++]=(i&3)<<6|o&63;return g},cdA=typeof ArrayBuffer=="function",t3=(e,A)=>{if(typeof e!="string")return{type:"message",data:DT(e,A)};const t=e.charAt(0);return t==="b"?{type:"message",data:odA(e.substring(1),A)}:wv[t]?e.length>1?{type:wv[t],data:e.substring(1)}:{type:wv[t]}:$m},odA=(e,A)=>{if(cdA){const t=idA(e);return DT(t,A)}else return{base64:!0,data:e}},DT=(e,A)=>{switch(A){case"blob":return e instanceof Blob?e:new Blob([e]);case"arraybuffer":default:return e instanceof ArrayBuffer?e:e.buffer}},FT="",gdA=(e,A)=>{const t=e.length,n=new Array(t);let B=0;e.forEach((a,s)=>{A3(a,!1,i=>{n[s]=i,++B===t&&A(n.join(FT))})})},ldA=(e,A)=>{const t=e.split(FT),n=[];for(let B=0;B<t.length;B++){const a=t3(t[B],A);if(n.push(a),a.type==="error")break}return n};function ddA(){return new TransformStream({transform(e,A){rdA(e,t=>{const n=t.length;let B;if(n<126)B=new Uint8Array(1),new DataView(B.buffer).setUint8(0,n);else if(n<65536){B=new Uint8Array(3);const a=new DataView(B.buffer);a.setUint8(0,126),a.setUint16(1,n)}else{B=new Uint8Array(9);const a=new DataView(B.buffer);a.setUint8(0,127),a.setBigUint64(1,BigInt(n))}e.data&&typeof e.data!="string"&&(B[0]|=128),A.enqueue(B),A.enqueue(t)})}})}let n3;function fv(e){return e.reduce((A,t)=>A+t.length,0)}function hv(e,A){if(e[0].length===A)return e.shift();const t=new Uint8Array(A);let n=0;for(let B=0;B<A;B++)t[B]=e[0][n++],n===e[0].length&&(e.shift(),n=0);return e.length&&n<e[0].length&&(e[0]=e[0].slice(n)),t}function udA(e,A){n3||(n3=new TextDecoder);const t=[];let n=0,B=-1,a=!1;return new TransformStream({transform(s,i){for(t.push(s);;){if(n===0){if(fv(t)<1)break;const o=hv(t,1);a=(o[0]&128)===128,B=o[0]&127,B<126?n=3:B===126?n=1:n=2}else if(n===1){if(fv(t)<2)break;const o=hv(t,2);B=new DataView(o.buffer,o.byteOffset,o.length).getUint16(0),n=3}else if(n===2){if(fv(t)<8)break;const o=hv(t,8),g=new DataView(o.buffer,o.byteOffset,o.length),d=g.getUint32(0);if(d>Math.pow(2,21)-1){i.enqueue($m);break}B=d*Math.pow(2,32)+g.getUint32(4),n=3}else{if(fv(t)<B)break;const o=hv(t,B);i.enqueue(t3(a?o:n3.decode(o),A)),n=0}if(B===0||B>e){i.enqueue($m);break}}}})}const PT=4;function eB(e){if(e)return GdA(e)}function GdA(e){for(var A in eB.prototype)e[A]=eB.prototype[A];return e}eB.prototype.on=eB.prototype.addEventListener=function(e,A){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(A),this},eB.prototype.once=function(e,A){function t(){this.off(e,t),A.apply(this,arguments)}return t.fn=A,this.on(e,t),this},eB.prototype.off=eB.prototype.removeListener=eB.prototype.removeAllListeners=eB.prototype.removeEventListener=function(e,A){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var t=this._callbacks["$"+e];if(!t)return this;if(arguments.length==1)return delete this._callbacks["$"+e],this;for(var n,B=0;B<t.length;B++)if(n=t[B],n===A||n.fn===A){t.splice(B,1);break}return t.length===0&&delete this._callbacks["$"+e],this},eB.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var A=new Array(arguments.length-1),t=this._callbacks["$"+e],n=1;n<arguments.length;n++)A[n-1]=arguments[n];if(t){t=t.slice(0);for(var n=0,B=t.length;n<B;++n)t[n].apply(this,A)}return this},eB.prototype.emitReserved=eB.prototype.emit,eB.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},eB.prototype.hasListeners=function(e){return!!this.listeners(e).length};const Cv=typeof Promise=="function"&&typeof Promise.resolve=="function"?A=>Promise.resolve().then(A):(A,t)=>t(A,0),vr=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),QdA="arraybuffer";function FQA(){}function MT(e,...A){return A.reduce((t,n)=>(e.hasOwnProperty(n)&&(t[n]=e[n]),t),{})}const wdA=vr.setTimeout,fdA=vr.clearTimeout;function bv(e,A){A.useNativeTimers?(e.setTimeoutFn=wdA.bind(vr),e.clearTimeoutFn=fdA.bind(vr)):(e.setTimeoutFn=vr.setTimeout.bind(vr),e.clearTimeoutFn=vr.clearTimeout.bind(vr))}const hdA=1.33;function CdA(e){return typeof e=="string"?bdA(e):Math.ceil((e.byteLength||e.size)*hdA)}function bdA(e){let A=0,t=0;for(let n=0,B=e.length;n<B;n++)A=e.charCodeAt(n),A<128?t+=1:A<2048?t+=2:A<55296||A>=57344?t+=3:(n++,t+=4);return t}function xT(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function vdA(e){let A="";for(let t in e)e.hasOwnProperty(t)&&(A.length&&(A+="&"),A+=encodeURIComponent(t)+"="+encodeURIComponent(e[t]));return A}function IdA(e){let A={},t=e.split("&");for(let n=0,B=t.length;n<B;n++){let a=t[n].split("=");A[decodeURIComponent(a[0])]=decodeURIComponent(a[1])}return A}class HdA extends Error{constructor(A,t,n){super(A),this.description=t,this.context=n,this.type="TransportError"}}class B3 extends eB{constructor(A){super(),this.writable=!1,bv(this,A),this.opts=A,this.query=A.query,this.socket=A.socket,this.supportsBinary=!A.forceBase64}onError(A,t,n){return super.emitReserved("error",new HdA(A,t,n)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(A){this.readyState==="open"&&this.write(A)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(A){const t=t3(A,this.socket.binaryType);this.onPacket(t)}onPacket(A){super.emitReserved("packet",A)}onClose(A){this.readyState="closed",super.emitReserved("close",A)}pause(A){}createUri(A,t={}){return A+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){const A=this.opts.hostname;return A.indexOf(":")===-1?A:"["+A+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(A){const t=vdA(A);return t.length?"?"+t:""}}class EdA extends B3{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(A){this.readyState="pausing";const t=()=>{this.readyState="paused",A()};if(this._polling||!this.writable){let n=0;this._polling&&(n++,this.once("pollComplete",function(){--n||t()})),this.writable||(n++,this.once("drain",function(){--n||t()}))}else t()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(A){const t=n=>{if(this.readyState==="opening"&&n.type==="open"&&this.onOpen(),n.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(n)};ldA(A,this.socket.binaryType).forEach(t),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const A=()=>{this.write([{type:"close"}])};this.readyState==="open"?A():this.once("open",A)}write(A){this.writable=!1,gdA(A,t=>{this.doWrite(t,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const A=this.opts.secure?"https":"http",t=this.query||{};return this.opts.timestampRequests!==!1&&(t[this.opts.timestampParam]=xT()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(A,t)}}let TT=!1;try{TT=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const pdA=TT;function mdA(){}class ydA extends EdA{constructor(A){if(super(A),typeof location<"u"){const t=location.protocol==="https:";let n=location.port;n||(n=t?"443":"80"),this.xd=typeof location<"u"&&A.hostname!==location.hostname||n!==A.port}}doWrite(A,t){const n=this.request({method:"POST",data:A});n.on("success",t),n.on("error",(B,a)=>{this.onError("xhr post error",B,a)})}doPoll(){const A=this.request();A.on("data",this.onData.bind(this)),A.on("error",(t,n)=>{this.onError("xhr poll error",t,n)}),this.pollXhr=A}}class vc extends eB{constructor(A,t,n){super(),this.createRequest=A,bv(this,n),this._opts=n,this._method=n.method||"GET",this._uri=t,this._data=n.data!==void 0?n.data:null,this._create()}_create(){var A;const t=MT(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this._opts.xd;const n=this._xhr=this.createRequest(t);try{n.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){n.setDisableHeaderCheck&&n.setDisableHeaderCheck(!0);for(let B in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(B)&&n.setRequestHeader(B,this._opts.extraHeaders[B])}}catch{}if(this._method==="POST")try{n.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{n.setRequestHeader("Accept","*/*")}catch{}(A=this._opts.cookieJar)===null||A===void 0||A.addCookies(n),"withCredentials"in n&&(n.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(n.timeout=this._opts.requestTimeout),n.onreadystatechange=()=>{var B;n.readyState===3&&((B=this._opts.cookieJar)===null||B===void 0||B.parseCookies(n.getResponseHeader("set-cookie"))),n.readyState===4&&(n.status===200||n.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof n.status=="number"?n.status:0)},0))},n.send(this._data)}catch(B){this.setTimeoutFn(()=>{this._onError(B)},0);return}typeof document<"u"&&(this._index=vc.requestsCount++,vc.requests[this._index]=this)}_onError(A){this.emitReserved("error",A,this._xhr),this._cleanup(!0)}_cleanup(A){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=mdA,A)try{this._xhr.abort()}catch{}typeof document<"u"&&delete vc.requests[this._index],this._xhr=null}}_onLoad(){const A=this._xhr.responseText;A!==null&&(this.emitReserved("data",A),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}if(vc.requestsCount=0,vc.requests={},typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",RT);else if(typeof addEventListener=="function"){const e="onpagehide"in vr?"pagehide":"unload";addEventListener(e,RT,!1)}}function RT(){for(let e in vc.requests)vc.requests.hasOwnProperty(e)&&vc.requests[e].abort()}const YdA=(function(){const e=VT({xdomain:!1});return e&&e.responseType!==null})();class ZdA extends ydA{constructor(A){super(A);const t=A&&A.forceBase64;this.supportsBinary=YdA&&!t}request(A={}){return Object.assign(A,{xd:this.xd},this.opts),new vc(VT,this.uri(),A)}}function VT(e){const A=e.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!A||pdA))return new XMLHttpRequest}catch{}if(!A)try{return new vr[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const ST=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class kdA extends B3{get name(){return"websocket"}doOpen(){const A=this.uri(),t=this.opts.protocols,n=ST?{}:MT(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(A,t,n)}catch(B){return this.emitReserved("error",B)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=A=>this.onClose({description:"websocket connection closed",context:A}),this.ws.onmessage=A=>this.onData(A.data),this.ws.onerror=A=>this.onError("websocket error",A)}write(A){this.writable=!1;for(let t=0;t<A.length;t++){const n=A[t],B=t===A.length-1;A3(n,this.supportsBinary,a=>{try{this.doWrite(n,a)}catch{}B&&Cv(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const A=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=xT()),this.supportsBinary||(t.b64=1),this.createUri(A,t)}}const a3=vr.WebSocket||vr.MozWebSocket;class UdA extends kdA{createSocket(A,t,n){return ST?new a3(A,t,n):t?new a3(A,t):new a3(A)}doWrite(A,t){this.ws.send(t)}}class DdA extends B3{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(A){return this.emitReserved("error",A)}this._transport.closed.then(()=>{this.onClose()}).catch(A=>{this.onError("webtransport error",A)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(A=>{const t=udA(Number.MAX_SAFE_INTEGER,this.socket.binaryType),n=A.readable.pipeThrough(t).getReader(),B=ddA();B.readable.pipeTo(A.writable),this._writer=B.writable.getWriter();const a=()=>{n.read().then(({done:i,value:o})=>{i||(this.onPacket(o),a())}).catch(i=>{})};a();const s={type:"open"};this.query.sid&&(s.data=`{"sid":"${this.query.sid}"}`),this._writer.write(s).then(()=>this.onOpen())})})}write(A){this.writable=!1;for(let t=0;t<A.length;t++){const n=A[t],B=t===A.length-1;this._writer.write(n).then(()=>{B&&Cv(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var A;(A=this._transport)===null||A===void 0||A.close()}}const FdA={websocket:UdA,webtransport:DdA,polling:ZdA},PdA=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,MdA=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function s3(e){if(e.length>8e3)throw"URI too long";const A=e,t=e.indexOf("["),n=e.indexOf("]");t!=-1&&n!=-1&&(e=e.substring(0,t)+e.substring(t,n).replace(/:/g,";")+e.substring(n,e.length));let B=PdA.exec(e||""),a={},s=14;for(;s--;)a[MdA[s]]=B[s]||"";return t!=-1&&n!=-1&&(a.source=A,a.host=a.host.substring(1,a.host.length-1).replace(/;/g,":"),a.authority=a.authority.replace("[","").replace("]","").replace(/;/g,":"),a.ipv6uri=!0),a.pathNames=xdA(a,a.path),a.queryKey=TdA(a,a.query),a}function xdA(e,A){const t=/\/{2,9}/g,n=A.replace(t,"/").split("/");return(A.slice(0,1)=="/"||A.length===0)&&n.splice(0,1),A.slice(-1)=="/"&&n.splice(n.length-1,1),n}function TdA(e,A){const t={};return A.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(n,B,a){B&&(t[B]=a)}),t}const r3=typeof addEventListener=="function"&&typeof removeEventListener=="function",vv=[];r3&&addEventListener("offline",()=>{vv.forEach(e=>e())},!1);class Og extends eB{constructor(A,t){if(super(),this.binaryType=QdA,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,A&&typeof A=="object"&&(t=A,A=null),A){const n=s3(A);t.hostname=n.host,t.secure=n.protocol==="https"||n.protocol==="wss",t.port=n.port,n.query&&(t.query=n.query)}else t.host&&(t.hostname=s3(t.host).host);bv(this,t),this.secure=t.secure!=null?t.secure:typeof location<"u"&&location.protocol==="https:",t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=t.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},t.transports.forEach(n=>{const B=n.prototype.name;this.transports.push(B),this._transportsByName[B]=n}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=IdA(this.opts.query)),r3&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},vv.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(A){const t=Object.assign({},this.opts.query);t.EIO=PT,t.transport=A,this.id&&(t.sid=this.id);const n=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[A]);return new this._transportsByName[A](n)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const A=this.opts.rememberUpgrade&&Og.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const t=this.createTransport(A);t.open(),this.setTransport(t)}setTransport(A){this.transport&&this.transport.removeAllListeners(),this.transport=A,A.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",t=>this._onClose("transport close",t))}onOpen(){this.readyState="open",Og.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(A){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",A),this.emitReserved("heartbeat"),A.type){case"open":this.onHandshake(JSON.parse(A.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const t=new Error("server error");t.code=A.data,this._onError(t);break;case"message":this.emitReserved("data",A.data),this.emitReserved("message",A.data);break}}onHandshake(A){this.emitReserved("handshake",A),this.id=A.sid,this.transport.query.sid=A.sid,this._pingInterval=A.pingInterval,this._pingTimeout=A.pingTimeout,this._maxPayload=A.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const A=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+A,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},A),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const A=this._getWritablePackets();this.transport.send(A),this._prevBufferLen=A.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let t=1;for(let n=0;n<this.writeBuffer.length;n++){const B=this.writeBuffer[n].data;if(B&&(t+=CdA(B)),n>0&&t>this._maxPayload)return this.writeBuffer.slice(0,n);t+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const A=Date.now()>this._pingTimeoutTime;return A&&(this._pingTimeoutTime=0,Cv(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),A}write(A,t,n){return this._sendPacket("message",A,t,n),this}send(A,t,n){return this._sendPacket("message",A,t,n),this}_sendPacket(A,t,n,B){if(typeof t=="function"&&(B=t,t=void 0),typeof n=="function"&&(B=n,n=null),this.readyState==="closing"||this.readyState==="closed")return;n=n||{},n.compress=n.compress!==!1;const a={type:A,data:t,options:n};this.emitReserved("packetCreate",a),this.writeBuffer.push(a),B&&this.once("flush",B),this.flush()}close(){const A=()=>{this._onClose("forced close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),A()},n=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?n():A()}):this.upgrading?n():A()),this}_onError(A){if(Og.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",A),this._onClose("transport error",A)}_onClose(A,t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),r3&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const n=vv.indexOf(this._offlineEventListener);n!==-1&&vv.splice(n,1)}this.readyState="closed",this.id=null,this.emitReserved("close",A,t),this.writeBuffer=[],this._prevBufferLen=0}}}Og.protocol=PT;class RdA extends Og{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let A=0;A<this._upgrades.length;A++)this._probe(this._upgrades[A])}_probe(A){let t=this.createTransport(A),n=!1;Og.priorWebsocketSuccess=!1;const B=()=>{n||(t.send([{type:"ping",data:"probe"}]),t.once("packet",G=>{if(!n)if(G.type==="pong"&&G.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;Og.priorWebsocketSuccess=t.name==="websocket",this.transport.pause(()=>{n||this.readyState!=="closed"&&(d(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{const f=new Error("probe error");f.transport=t.name,this.emitReserved("upgradeError",f)}}))};function a(){n||(n=!0,d(),t.close(),t=null)}const s=G=>{const f=new Error("probe error: "+G);f.transport=t.name,a(),this.emitReserved("upgradeError",f)};function i(){s("transport closed")}function o(){s("socket closed")}function g(G){t&&G.name!==t.name&&a()}const d=()=>{t.removeListener("open",B),t.removeListener("error",s),t.removeListener("close",i),this.off("close",o),this.off("upgrading",g)};t.once("open",B),t.once("error",s),t.once("close",i),this.once("close",o),this.once("upgrading",g),this._upgrades.indexOf("webtransport")!==-1&&A!=="webtransport"?this.setTimeoutFn(()=>{n||t.open()},200):t.open()}onHandshake(A){this._upgrades=this._filterUpgrades(A.upgrades),super.onHandshake(A)}_filterUpgrades(A){const t=[];for(let n=0;n<A.length;n++)~this.transports.indexOf(A[n])&&t.push(A[n]);return t}}let VdA=class extends RdA{constructor(A,t={}){const n=typeof A=="object"?A:t;(!n.transports||n.transports&&typeof n.transports[0]=="string")&&(n.transports=(n.transports||["polling","websocket","webtransport"]).map(B=>FdA[B]).filter(B=>!!B)),super(A,n)}};function SdA(e,A="",t){let n=e;t=t||typeof location<"u"&&location,e==null&&(e=t.protocol+"//"+t.host),typeof e=="string"&&(e.charAt(0)==="/"&&(e.charAt(1)==="/"?e=t.protocol+e:e=t.host+e),/^(https?|wss?):\/\//.test(e)||(typeof t<"u"?e=t.protocol+"//"+e:e="https://"+e),n=s3(e)),n.port||(/^(http|ws)$/.test(n.protocol)?n.port="80":/^(http|ws)s$/.test(n.protocol)&&(n.port="443")),n.path=n.path||"/";const a=n.host.indexOf(":")!==-1?"["+n.host+"]":n.host;return n.id=n.protocol+"://"+a+":"+n.port+A,n.href=n.protocol+"://"+a+(t&&t.port===n.port?"":":"+n.port),n}const WdA=typeof ArrayBuffer=="function",zdA=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,WT=Object.prototype.toString,NdA=typeof Blob=="function"||typeof Blob<"u"&&WT.call(Blob)==="[object BlobConstructor]",XdA=typeof File=="function"||typeof File<"u"&&WT.call(File)==="[object FileConstructor]";function i3(e){return WdA&&(e instanceof ArrayBuffer||zdA(e))||NdA&&e instanceof Blob||XdA&&e instanceof File}function Iv(e,A){if(!e||typeof e!="object")return!1;if(Array.isArray(e)){for(let t=0,n=e.length;t<n;t++)if(Iv(e[t]))return!0;return!1}if(i3(e))return!0;if(e.toJSON&&typeof e.toJSON=="function"&&arguments.length===1)return Iv(e.toJSON(),!0);for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&Iv(e[t]))return!0;return!1}function LdA(e){const A=[],t=e.data,n=e;return n.data=c3(t,A),n.attachments=A.length,{packet:n,buffers:A}}function c3(e,A){if(!e)return e;if(i3(e)){const t={_placeholder:!0,num:A.length};return A.push(e),t}else if(Array.isArray(e)){const t=new Array(e.length);for(let n=0;n<e.length;n++)t[n]=c3(e[n],A);return t}else if(typeof e=="object"&&!(e instanceof Date)){const t={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=c3(e[n],A));return t}return e}function OdA(e,A){return e.data=o3(e.data,A),delete e.attachments,e}function o3(e,A){if(!e)return e;if(e&&e._placeholder===!0){if(typeof e.num=="number"&&e.num>=0&&e.num<A.length)return A[e.num];throw new Error("illegal attachments")}else if(Array.isArray(e))for(let t=0;t<e.length;t++)e[t]=o3(e[t],A);else if(typeof e=="object")for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&(e[t]=o3(e[t],A));return e}const JdA=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],KdA=5;var Ke;(function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"})(Ke||(Ke={}));class jdA{constructor(A){this.replacer=A}encode(A){return(A.type===Ke.EVENT||A.type===Ke.ACK)&&Iv(A)?this.encodeAsBinary({type:A.type===Ke.EVENT?Ke.BINARY_EVENT:Ke.BINARY_ACK,nsp:A.nsp,data:A.data,id:A.id}):[this.encodeAsString(A)]}encodeAsString(A){let t=""+A.type;return(A.type===Ke.BINARY_EVENT||A.type===Ke.BINARY_ACK)&&(t+=A.attachments+"-"),A.nsp&&A.nsp!=="/"&&(t+=A.nsp+","),A.id!=null&&(t+=A.id),A.data!=null&&(t+=JSON.stringify(A.data,this.replacer)),t}encodeAsBinary(A){const t=LdA(A),n=this.encodeAsString(t.packet),B=t.buffers;return B.unshift(n),B}}function zT(e){return Object.prototype.toString.call(e)==="[object Object]"}class g3 extends eB{constructor(A){super(),this.reviver=A}add(A){let t;if(typeof A=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t=this.decodeString(A);const n=t.type===Ke.BINARY_EVENT;n||t.type===Ke.BINARY_ACK?(t.type=n?Ke.EVENT:Ke.ACK,this.reconstructor=new qdA(t),t.attachments===0&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else if(i3(A)||A.base64)if(this.reconstructor)t=this.reconstructor.takeBinaryData(A),t&&(this.reconstructor=null,super.emitReserved("decoded",t));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+A)}decodeString(A){let t=0;const n={type:Number(A.charAt(0))};if(Ke[n.type]===void 0)throw new Error("unknown packet type "+n.type);if(n.type===Ke.BINARY_EVENT||n.type===Ke.BINARY_ACK){const a=t+1;for(;A.charAt(++t)!=="-"&&t!=A.length;);const s=A.substring(a,t);if(s!=Number(s)||A.charAt(t)!=="-")throw new Error("Illegal attachments");n.attachments=Number(s)}if(A.charAt(t+1)==="/"){const a=t+1;for(;++t&&!(A.charAt(t)===","||t===A.length););n.nsp=A.substring(a,t)}else n.nsp="/";const B=A.charAt(t+1);if(B!==""&&Number(B)==B){const a=t+1;for(;++t;){const s=A.charAt(t);if(s==null||Number(s)!=s){--t;break}if(t===A.length)break}n.id=Number(A.substring(a,t+1))}if(A.charAt(++t)){const a=this.tryParse(A.substr(t));if(g3.isPayloadValid(n.type,a))n.data=a;else throw new Error("invalid payload")}return n}tryParse(A){try{return JSON.parse(A,this.reviver)}catch{return!1}}static isPayloadValid(A,t){switch(A){case Ke.CONNECT:return zT(t);case Ke.DISCONNECT:return t===void 0;case Ke.CONNECT_ERROR:return typeof t=="string"||zT(t);case Ke.EVENT:case Ke.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]=="number"||typeof t[0]=="string"&&JdA.indexOf(t[0])===-1);case Ke.ACK:case Ke.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class qdA{constructor(A){this.packet=A,this.buffers=[],this.reconPack=A}takeBinaryData(A){if(this.buffers.push(A),this.buffers.length===this.reconPack.attachments){const t=OdA(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const _dA=Object.freeze(Object.defineProperty({__proto__:null,Decoder:g3,Encoder:jdA,get PacketType(){return Ke},protocol:KdA},Symbol.toStringTag,{value:"Module"}));function si(e,A,t){return e.on(A,t),function(){e.off(A,t)}}const $dA=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class NT extends eB{constructor(A,t,n){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=A,this.nsp=t,n&&n.auth&&(this.auth=n.auth),this._opts=Object.assign({},n),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const A=this.io;this.subs=[si(A,"open",this.onopen.bind(this)),si(A,"packet",this.onpacket.bind(this)),si(A,"error",this.onerror.bind(this)),si(A,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...A){return A.unshift("message"),this.emit.apply(this,A),this}emit(A,...t){var n,B,a;if($dA.hasOwnProperty(A))throw new Error('"'+A.toString()+'" is a reserved event name');if(t.unshift(A),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;const s={type:Ke.EVENT,data:t};if(s.options={},s.options.compress=this.flags.compress!==!1,typeof t[t.length-1]=="function"){const d=this.ids++,G=t.pop();this._registerAckCallback(d,G),s.id=d}const i=(B=(n=this.io.engine)===null||n===void 0?void 0:n.transport)===null||B===void 0?void 0:B.writable,o=this.connected&&!(!((a=this.io.engine)===null||a===void 0)&&a._hasPingExpired());return this.flags.volatile&&!i||(o?(this.notifyOutgoingListeners(s),this.packet(s)):this.sendBuffer.push(s)),this.flags={},this}_registerAckCallback(A,t){var n;const B=(n=this.flags.timeout)!==null&&n!==void 0?n:this._opts.ackTimeout;if(B===void 0){this.acks[A]=t;return}const a=this.io.setTimeoutFn(()=>{delete this.acks[A];for(let i=0;i<this.sendBuffer.length;i++)this.sendBuffer[i].id===A&&this.sendBuffer.splice(i,1);t.call(this,new Error("operation has timed out"))},B),s=(...i)=>{this.io.clearTimeoutFn(a),t.apply(this,i)};s.withError=!0,this.acks[A]=s}emitWithAck(A,...t){return new Promise((n,B)=>{const a=(s,i)=>s?B(s):n(i);a.withError=!0,t.push(a),this.emit(A,...t)})}_addToQueue(A){let t;typeof A[A.length-1]=="function"&&(t=A.pop());const n={id:this._queueSeq++,tryCount:0,pending:!1,args:A,flags:Object.assign({fromQueue:!0},this.flags)};A.push((B,...a)=>(this._queue[0],B!==null?n.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(B)):(this._queue.shift(),t&&t(null,...a)),n.pending=!1,this._drainQueue())),this._queue.push(n),this._drainQueue()}_drainQueue(A=!1){if(!this.connected||this._queue.length===0)return;const t=this._queue[0];t.pending&&!A||(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.args))}packet(A){A.nsp=this.nsp,this.io._packet(A)}onopen(){typeof this.auth=="function"?this.auth(A=>{this._sendConnectPacket(A)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(A){this.packet({type:Ke.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},A):A})}onerror(A){this.connected||this.emitReserved("connect_error",A)}onclose(A,t){this.connected=!1,delete this.id,this.emitReserved("disconnect",A,t),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(A=>{if(!this.sendBuffer.some(n=>String(n.id)===A)){const n=this.acks[A];delete this.acks[A],n.withError&&n.call(this,new Error("socket has been disconnected"))}})}onpacket(A){if(A.nsp===this.nsp)switch(A.type){case Ke.CONNECT:A.data&&A.data.sid?this.onconnect(A.data.sid,A.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case Ke.EVENT:case Ke.BINARY_EVENT:this.onevent(A);break;case Ke.ACK:case Ke.BINARY_ACK:this.onack(A);break;case Ke.DISCONNECT:this.ondisconnect();break;case Ke.CONNECT_ERROR:this.destroy();const n=new Error(A.data.message);n.data=A.data.data,this.emitReserved("connect_error",n);break}}onevent(A){const t=A.data||[];A.id!=null&&t.push(this.ack(A.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(A){if(this._anyListeners&&this._anyListeners.length){const t=this._anyListeners.slice();for(const n of t)n.apply(this,A)}super.emit.apply(this,A),this._pid&&A.length&&typeof A[A.length-1]=="string"&&(this._lastOffset=A[A.length-1])}ack(A){const t=this;let n=!1;return function(...B){n||(n=!0,t.packet({type:Ke.ACK,id:A,data:B}))}}onack(A){const t=this.acks[A.id];typeof t=="function"&&(delete this.acks[A.id],t.withError&&A.data.unshift(null),t.apply(this,A.data))}onconnect(A,t){this.id=A,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(A=>this.emitEvent(A)),this.receiveBuffer=[],this.sendBuffer.forEach(A=>{this.notifyOutgoingListeners(A),this.packet(A)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(A=>A()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:Ke.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(A){return this.flags.compress=A,this}get volatile(){return this.flags.volatile=!0,this}timeout(A){return this.flags.timeout=A,this}onAny(A){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(A),this}prependAny(A){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(A),this}offAny(A){if(!this._anyListeners)return this;if(A){const t=this._anyListeners;for(let n=0;n<t.length;n++)if(A===t[n])return t.splice(n,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(A){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(A),this}prependAnyOutgoing(A){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(A),this}offAnyOutgoing(A){if(!this._anyOutgoingListeners)return this;if(A){const t=this._anyOutgoingListeners;for(let n=0;n<t.length;n++)if(A===t[n])return t.splice(n,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(A){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const t=this._anyOutgoingListeners.slice();for(const n of t)n.apply(this,A.data)}}}function kG(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}kG.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var A=Math.random(),t=Math.floor(A*this.jitter*e);e=(Math.floor(A*10)&1)==0?e-t:e+t}return Math.min(e,this.max)|0},kG.prototype.reset=function(){this.attempts=0},kG.prototype.setMin=function(e){this.ms=e},kG.prototype.setMax=function(e){this.max=e},kG.prototype.setJitter=function(e){this.jitter=e};class l3 extends eB{constructor(A,t){var n;super(),this.nsps={},this.subs=[],A&&typeof A=="object"&&(t=A,A=void 0),t=t||{},t.path=t.path||"/socket.io",this.opts=t,bv(this,t),this.reconnection(t.reconnection!==!1),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor((n=t.randomizationFactor)!==null&&n!==void 0?n:.5),this.backoff=new kG({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState="closed",this.uri=A;const B=t.parser||_dA;this.encoder=new B.Encoder,this.decoder=new B.Decoder,this._autoConnect=t.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(A){return arguments.length?(this._reconnection=!!A,A||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(A){return A===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=A,this)}reconnectionDelay(A){var t;return A===void 0?this._reconnectionDelay:(this._reconnectionDelay=A,(t=this.backoff)===null||t===void 0||t.setMin(A),this)}randomizationFactor(A){var t;return A===void 0?this._randomizationFactor:(this._randomizationFactor=A,(t=this.backoff)===null||t===void 0||t.setJitter(A),this)}reconnectionDelayMax(A){var t;return A===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=A,(t=this.backoff)===null||t===void 0||t.setMax(A),this)}timeout(A){return arguments.length?(this._timeout=A,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(A){if(~this._readyState.indexOf("open"))return this;this.engine=new VdA(this.uri,this.opts);const t=this.engine,n=this;this._readyState="opening",this.skipReconnect=!1;const B=si(t,"open",function(){n.onopen(),A&&A()}),a=i=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",i),A?A(i):this.maybeReconnectOnOpen()},s=si(t,"error",a);if(this._timeout!==!1){const i=this._timeout,o=this.setTimeoutFn(()=>{B(),a(new Error("timeout")),t.close()},i);this.opts.autoUnref&&o.unref(),this.subs.push(()=>{this.clearTimeoutFn(o)})}return this.subs.push(B),this.subs.push(s),this}connect(A){return this.open(A)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const A=this.engine;this.subs.push(si(A,"ping",this.onping.bind(this)),si(A,"data",this.ondata.bind(this)),si(A,"error",this.onerror.bind(this)),si(A,"close",this.onclose.bind(this)),si(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(A){try{this.decoder.add(A)}catch(t){this.onclose("parse error",t)}}ondecoded(A){Cv(()=>{this.emitReserved("packet",A)},this.setTimeoutFn)}onerror(A){this.emitReserved("error",A)}socket(A,t){let n=this.nsps[A];return n?this._autoConnect&&!n.active&&n.connect():(n=new NT(this,A,t),this.nsps[A]=n),n}_destroy(A){const t=Object.keys(this.nsps);for(const n of t)if(this.nsps[n].active)return;this._close()}_packet(A){const t=this.encoder.encode(A);for(let n=0;n<t.length;n++)this.engine.write(t[n],A.options)}cleanup(){this.subs.forEach(A=>A()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(A,t){var n;this.cleanup(),(n=this.engine)===null||n===void 0||n.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",A,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const A=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const t=this.backoff.duration();this._reconnecting=!0;const n=this.setTimeoutFn(()=>{A.skipReconnect||(this.emitReserved("reconnect_attempt",A.backoff.attempts),!A.skipReconnect&&A.open(B=>{B?(A._reconnecting=!1,A.reconnect(),this.emitReserved("reconnect_error",B)):A.onreconnect()}))},t);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}}onreconnect(){const A=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",A)}}const Qf={};function wf(e,A){typeof e=="object"&&(A=e,e=void 0),A=A||{};const t=SdA(e,A.path||"/socket.io"),n=t.source,B=t.id,a=t.path,s=Qf[B]&&a in Qf[B].nsps,i=A.forceNew||A["force new connection"]||A.multiplex===!1||s;let o;return i?o=new l3(n,A):(Qf[B]||(Qf[B]=new l3(n,A)),o=Qf[B]),t.query&&!A.query&&(A.query=t.queryKey),o.socket(t.path,A)}Object.assign(wf,{Manager:l3,Socket:NT,io:wf,connect:wf});const XT=F.createContext({io:null,isConnected:!1}),AuA=({children:e})=>{const[A,t]=F.useState(null),[n,B]=F.useState(!1),a=F.useRef(null),s=F.useRef(!1),{token:i}=XZ();return F.useEffect(()=>{if(a.current?.connected||s.current)return;const o="https://api.beta.careshiphealth.com",g=wg("psid")||i,d=wg("woid");if(!g||!d||!o)return;s.current=!0;const G=wf(`${o}/rt`,{withCredentials:!0,extraHeaders:{Authorization:`Bearer ${g}`,"x-org-id":d,"x-user-context":"lead"}});return a.current=G,t(G),G.on("connect",()=>{B(!0),s.current=!1}),G.on("disconnect",()=>{B(!1),s.current=!1}),G.on("error",f=>{console.error("Socket error:",f),s.current=!1}),()=>{G.connected&&G.disconnect(),a.current=null,t(null),B(!1),s.current=!1}},[i]),E.jsx(XT.Provider,{value:{io:A,isConnected:n},children:e})},euA=()=>F.useContext(XT),LT=F.createContext({io:null,isConnected:!1}),tuA=({children:e})=>{const[A,t]=F.useState(null),[n,B]=F.useState(!1),a=F.useRef(null),s=F.useRef(!1),{bot_token:i}=XZ();return F.useEffect(()=>{if(a.current?.connected||s.current)return;const o="https://api.beta.careshiphealth.com",g=wg("bot_psid")||i,d=wg("woid");if(!g||!d||!o)return;s.current=!0;const G=wf(`${o}/rt`,{withCredentials:!0,extraHeaders:{Authorization:`Bearer ${g}`,"x-org-id":d,"x-user-context":"user"}});return a.current=G,t(G),G.on("connect",()=>{B(!0),s.current=!1}),G.on("disconnect",()=>{B(!1),s.current=!1}),G.on("error",f=>{console.error("Socket error:",f),s.current=!1}),()=>{G.connected&&G.disconnect(),a.current=null,t(null),B(!1),s.current=!1}},[i]),E.jsx(LT.Provider,{value:{io:A,isConnected:n},children:e})},nuA=()=>F.useContext(LT);var Hv=(e=>(e.EXCELLENT="excellent",e.GOOD="good",e.POOR="poor",e))(Hv||{});const BuA=e=>La.post("/chat-feedback/submit",e),auA=e=>La.get(`/chat-feedback/check/${e}`),suA=({isOpen:e,onClose:A,chatId:t,onSubmitSuccess:n})=>{const[B,a]=F.useState(null),[s,i]=F.useState(""),[o,g]=F.useState(!1),[d,G]=F.useState(!1),f=[{value:Hv.EXCELLENT,label:"Excellent",emoji:"🤩",color:"#10B981"},{value:Hv.GOOD,label:"Good",emoji:"😊",color:"#F59E0B"},{value:Hv.POOR,label:"Poor",emoji:"☹️",color:"#EF4444"}],v=async()=>{if(B)try{g(!0),await BuA({chatId:t,rating:B,comment:s.trim()||void 0}),G(!0),setTimeout(()=>{n?.(),A()},1500)}catch(H){console.error("Failed to submit feedback:",H),alert("Failed to submit feedback. Please try again.")}finally{g(!1)}};return e?E.jsx(kS,{children:E.jsx(wB.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:A,children:E.jsx(wB.div,{initial:{scale:.9,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.9,opacity:0},transition:{type:"spring",duration:.3},className:"bg-white rounded-lg max-w-md w-full p-6 shadow-xl",onClick:H=>H.stopPropagation(),children:d?E.jsxs("div",{className:"text-center py-8",children:[E.jsx("div",{className:"text-6xl mb-4",children:"✅"}),E.jsx("h3",{className:"text-xl font-semibold text-gray-900 mb-2",children:"Thank you for your feedback!"}),E.jsx("p",{className:"text-gray-600 text-sm",children:"Your feedback helps us improve our service."})]}):E.jsxs(E.Fragment,{children:[E.jsx("h3",{className:"text-xl font-semibold text-gray-900 mb-2",children:"How was your experience?"}),E.jsx("p",{className:"text-gray-600 text-sm mb-6",children:"Please rate your conversation with our assistant"}),E.jsx("div",{className:"grid grid-cols-3 gap-3 mb-6",children:f.map(H=>E.jsxs("button",{onClick:()=>a(H.value),className:`p-4 rounded-lg border-2 transition-all hover:scale-105 ${B===H.value?"border-purple-500 bg-purple-50":"border-gray-200 hover:border-gray-300"}`,children:[E.jsx("div",{className:"text-4xl mb-2",children:H.emoji}),E.jsx("div",{className:"text-sm font-medium text-gray-700",children:H.label})]},H.value))}),E.jsxs("div",{className:"mb-6",children:[E.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Additional comments (optional)"}),E.jsx("textarea",{value:s,onChange:H=>i(H.target.value),placeholder:"Tell us more about your experience...",className:"w-full px-3 py-2 border border-gray-300 rounded-lg resize-none focus:outline-none focus:ring-2 focus:ring-purple-500",rows:3,maxLength:500}),E.jsxs("div",{className:"text-xs text-gray-500 mt-1 text-right",children:[s.length,"/500"]})]}),E.jsxs("div",{className:"flex gap-3",children:[E.jsx("button",{onClick:A,className:"flex-1 px-4 py-2 border border-gray-300 rounded-lg text-gray-700 hover:bg-gray-50 transition-colors",disabled:o,children:"Skip"}),E.jsx("button",{onClick:v,disabled:!B||o,className:"flex-1 px-4 py-2 bg-black text-white rounded-lg hover:bg-gray-800 transition-colors disabled:bg-gray-300 disabled:cursor-not-allowed",children:o?"Submitting...":"Submit"})]})]})})})}):null},ruA=()=>{const{token:e}=Pg(),{loginMutation:A}=Th(),t=xH(),n=bs(),{initialMessage:B}=Th(),[a,s]=F.useState(B||""),[i,o]=F.useState(!1),[g,d]=F.useState(!1),[G,f]=F.useState(60),{io:v,isConnected:H}=euA(),{io:y}=nuA(),Y=c0(),{patient:Z}=kB(),P=F.useMemo(()=>Aa.getState().organization,[]),x=F.useMemo(()=>P?.members?.[0],[P]),V=F.useRef(v),k=F.useRef(y),S=F.useMemo(()=>Aa.getState().patient?.id,[Z]),K=F.useRef(!1),J=F.useRef(null),eA=F.useRef(new Set),sA=F.useRef(!1),cA=F.useRef(null),[CA,ZA]=F.useState(!1),[UA,DA]=F.useState(!1),L=F.useRef(!1),j=F.useRef(0);F.useEffect(()=>{V.current=v},[v]),F.useEffect(()=>{k.current=y,console.log("bot scket changing"),console.log({botSocket:y})},[y]),F.useEffect(()=>{K.current=Aa.getState().chats.awaitingTeamReply??!1},[]);const q=Z?.chatMembers&&Z?.chatMembers.length>0?Z.chatMembers[0].chat?.id:null,WA=o0({queryKey:["feedback-status",q],queryFn:async()=>q?(await auA(q)).data.data:null,enabled:!!q&&!!e,refetchOnWindowFocus:!1}),z=mX({queryKey:["chat-messages",q],queryFn:async({pageParam:NA=1})=>q?(await AdA(q,{page:NA,limit:5})).data:null,enabled:!!q,refetchOnWindowFocus:!0,getNextPageParam:NA=>{if(NA?.meta)return NA.meta.totalPages>NA.meta.currentPage?Number(NA.meta.currentPage)+1:void 0},initialPageParam:1}),_=F.useMemo(()=>z.data?.pages?z.data.pages.flatMap(_A=>_A?.data||[]).reverse():[],[z.data]),kA=F.useCallback(()=>{J.current||(J.current=setInterval(()=>{f(NA=>NA<=1?(clearInterval(J.current),J.current=null,0):NA-1)},1e3))},[]),HA=F.useCallback(()=>{J.current!==null&&(clearInterval(J.current),J.current=null),f(60)},[]),vA=F.useCallback(NA=>{const _A=k.current;console.log({bot:_A}),!(!NA.trim()||!q||!_A||!x?.id)&&(K.current||_A.emit("chat:bot-message",{content:NA.trim(),chatId:q,type:"message",sender:x.id}))},[q,x?.id]),KA=F.useCallback(NA=>{const _A=V.current;console.log({sock:_A,conversationId:q,loadingBotResponse:i,currentPatientCur:S}),!(!NA.trim()||!q||!_A||i||!S)&&(s(""),_A.emit("chat:message",{content:NA.trim(),chatId:q,type:"message",sender:S}),vA(NA))},[q,i,vA]),JA=F.useCallback(()=>{kA(),setTimeout(async()=>{if(K.current){HA(),Aa.setState(Ae=>({chats:{...Ae.chats,awaitingTeamReply:!1}}));const NA=`I am sorry. Looks like everyone is busy at the moment or un-available to respond instantly. We will get back to you ${Z?.email?`on ${Z?.email}`:"through your email"}`,_A=k.current;_A&&x?.id&&_A.emit("chat:message",{content:NA,chatId:q,type:"message",sender:x?.id}),ZA(!0)}},6e4)},[kA,HA,Z?.email,q,x?.id]);F.useEffect(()=>{console.log({initialMessage:B,loginSuccess:A?.isSuccess,messagesQuerySuccess:z?.isSuccess}),A?.isSuccess&&z?.isSuccess&&B&&(console.log("inittt"),vA(B),o(!0),s(""))},[A?.isSuccess,z?.isSuccess,B,vA]);const Ge=NA=>{NA.chatId===q&&!eA.current.has(NA.id)&&(eA.current.add(NA.id),Y.invalidateQueries({queryKey:["chat-messages",q]}),NA.sender_participant?.patientId===S&&!CA&&(o(!0),sA.current=!0,cA.current&&clearTimeout(cA.current),cA.current=setTimeout(()=>{sA.current&&(console.warn("Bot response timeout - clearing loading state"),o(!1),sA.current=!1)},3e4)),ZA(!1),K.current&&NA.sender_participant?.member?.user.id!==x?.id&&!NA.sender_participant.patientId&&(Aa.setState(_A=>({chats:{..._A.chats,awaitingTeamReply:!1}})),K.current=!1))};F.useEffect(()=>{const NA=V.current;if(!(!NA||!q))return NA.emit("chat:join",{chatId:q}),NA.on("chat:messages",Ge),NA.on("error",_A=>{console.error("Socket error:",_A.message)}),()=>{const _A=V.current;k.current,_A&&(_A.emit("chat:leave",{chatId:q}),_A.off("chat:messages",Ge),_A.off("error"))}},[v,q,Y,x?.id]),F.useEffect(()=>{const NA=k.current;if(!NA||!q)return;NA.emit("chat:join",{chatId:q});const _A=Yn=>{console.log("Bot message received:",{message:Yn,conversationId:q}),Yn.chatId===q&&!eA.current.has(Yn.id)&&(cA.current&&(clearTimeout(cA.current),cA.current=null),o(!1),sA.current=!1,eA.current.add(Yn.id),Y.invalidateQueries({queryKey:["chat-messages",q]}),t.updateLoginMutation({}))},Ae=Yn=>{_A(Yn),Aa.setState(ra=>({chats:{...ra.chats,awaitingTeamReply:!0}})),JA()};return NA.on("chat:bot-messages",_A),NA.on("chat:bot-messages:unanswered_query",Ae),NA.on("chat:bot-messages:human_agent_request",Ae),NA.on("chat:bot-messages:book_appointment",Ge),NA.on("chat:bot-messages:schedule_meet_and_greet",Ge),NA.on("chat:bot-messages:get_subscription",Ge),NA.on("error",Yn=>{console.error("Bot socket error:",Yn.message)}),()=>{NA.off("chat:bot-messages",_A),NA.off("chat:bot-messages:unanswered_query",Ae),NA.off("chat:bot-messages:human_agent_request",Ae),NA.off("chat:bot-messages:book_appointment",Ge),NA.off("chat:bot-messages:schedule_meet_and_greet",Ge),NA.off("chat:bot-messages:get_subscription",Ge),NA.off("error"),cA.current&&(clearTimeout(cA.current),cA.current=null)}},[y,q,Y,x?.id,JA]),F.useEffect(()=>Aa.subscribe(_A=>{K.current=_A.chats.awaitingTeamReply??!1}),[]),F.useEffect(()=>{if(!WA.data||!q||L.current)return;const{shouldPromptFeedback:NA,currentMessageCount:_A}=WA.data;if(!(!g||_A<4)&&NA&&j.current!==_A&&(j.current=_A,!i&&!K.current)){const Ae=setTimeout(()=>{DA(!0),L.current=!0},2e3);return()=>clearTimeout(Ae)}},[WA.data,q,g,i,_.length]);const Te=()=>{WA.refetch(),L.current=!1},yn=E.jsx("button",{onClick:()=>{n("/home")},className:"rounded-full border border-black text-sm px-2",children:"End Chat"});return F.useEffect(()=>{if(z.isPending||g)return;if(_.length>0){d(!0);return}const NA=_m.slice(0,2),_A=[];let Ae=500;NA.forEach(ra=>{const ri=setTimeout(()=>{KA(ra)},Ae);_A.push(ri),Ae+=1500});const Yn=setTimeout(()=>{d(!0)},Ae+NA.length*1500);return _A.push(Yn),()=>{_A.forEach(ra=>clearTimeout(ra))}},[z.isPending,_.length,g,KA]),e?E.jsxs(ro,{showMinMaxIcon:!0,title:`Chat with ${x?.user?.first_name}`,rightComponent:yn,children:[E.jsxs("div",{className:"flex flex-col justify-between h-full",children:[E.jsx("div",{className:"pl-2 pr-6 text-sm flex flex-col gap-5 mt-3",children:z.isLoading?E.jsx("div",{className:"flex justify-center mt-10",children:E.jsx(vg,{})}):z.isError?E.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-3 flex items-center justify-center",children:E.jsx("div",{className:"flex flex-col items-center justify-center text-center",children:E.jsx("p",{className:"text-sm text-gray-500 mt-4 max-w-[150px] mx-auto",children:"Error loading chats"})})}):E.jsx(sdA,{messages:_,hasNextPage:z.hasNextPage||!1,isFetchingNextPage:z.isFetchingNextPage,onLoadMore:()=>{z.fetchNextPage()},awaitingTeamReplyCountdown:G,loadingBotResponse:i})}),g&&E.jsx("div",{className:"px-3 sticky bottom-0 bg-white pt-2 z-10 pb-3",children:E.jsx(wB.div,{initial:{y:6,opacity:0},animate:{y:0,opacity:1},transition:{delay:.1},children:E.jsxs("div",{className:"relative flex items-center mt-2.5",children:[E.jsx("input",{autoFocus:!0,className:"py-3.5 pl-3 pr-21 outline-none w-full border border-[#CECECE] text-sm",type:"text",placeholder:"Ask AI",value:a,onChange:NA=>s(NA.target.value),onKeyUp:NA=>{if(NA.key=="Enter"){if(i)return;KA(a)}}}),E.jsx(wB.button,{whileTap:{scale:.95},whileHover:{scale:1},onClick:()=>KA(a),disabled:i,className:"text-sm disabled:opacity-60 disabled:cursor-default absolute right-2 top-1/2 -translate-y-1/2 bg-black hover:shadow-md transition-shadow text-white py-1.5 px-4 hover:opacity-80 rounded-full text-center flex items-center gap-2",children:i?E.jsx(vg,{size:"sm",color:"white"}):"Send"})]})})})]}),q&&E.jsx(suA,{isOpen:UA,onClose:()=>DA(!1),chatId:q,onSubmitSuccess:Te})]}):E.jsx($lA,{})},iuA=()=>E.jsx(j1,{children:E.jsxs(_1,{children:[E.jsx(Ki,{path:"*",element:E.jsx(iL,{})}),E.jsx(Ki,{path:"/home",element:E.jsx(Jj,{})}),E.jsx(Ki,{path:"/chat",element:E.jsx(ruA,{})}),E.jsx(Ki,{path:"/call-back",element:E.jsx(_lA,{})}),E.jsx(Ki,{path:"/clarity-call",element:E.jsx(DAA,{})}),E.jsx(Ki,{path:"/custom-widget",element:E.jsx(FAA,{})}),E.jsx(Ki,{path:"/meet-and-greet",element:E.jsx(uaA,{})}),E.jsx(Ki,{path:"/appointment",element:E.jsx(GaA,{})}),E.jsx(Ki,{path:"/subscription",element:E.jsx(JaA,{})})]})}),cuA=new GX,ouA=e=>{const[A,t]=O.useState("");return F.useEffect(()=>{if(VH("wak"),VH("woid"),e?.orgId&&e?.apiKey)return Du("wak",e.apiKey),Du("woid",e.orgId),t(e.orgId);if(typeof window<"u"){const B=(()=>{const a=document.getElementById("supercare-09u2ekhbpo-script");if(a)return a;const s=document.currentScript||null;return s||document.querySelector("script[data-org-id],script[data-supercare-org-id]")})();if(B){let a=null,s=null;try{if(B.src){const f=new URL(B.src,window.location.href).searchParams;a=f.get("orgId")||f.get("orgID")||f.get("orgid"),s=f.get("apiKey")||f.get("apikey")||f.get("api_key")}}catch{}const i=B.getAttribute("data-org-id")||B.getAttribute("data-supercare-org-id")||B?.dataset?.orgId||null,o=B.getAttribute("data-api-key")||B.getAttribute("data-supercare-api-key")||B?.dataset?.apiKey||null,g=a||i,d=s||o;d&&Du("wak",d),g&&(Du("woid",g),t(g))}}},[e.orgId]),E.jsxs(i1.div,{id:"supercare-09u2ekhbpo-root",className:`${T7} relative !font_graphik`,children:[E.jsx("style",{type:"text/css",children:x7}),E.jsx("style",{type:"text/css",children:R7}),E.jsx(QX,{client:cuA,children:E.jsx(rL,{orgId:A,children:E.jsx(AuA,{children:E.jsx(tuA,{children:E.jsx(HAA,{children:E.jsx(iuA,{})})})})})})]})};var d3={exports:{}},ff={},u3={exports:{}},G3={};/**
470
470
  * @license React
471
471
  * scheduler.production.js
472
472
  *
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@careshiphealth/widget",
3
3
  "private": false,
4
- "version": "2.1.95",
4
+ "version": "2.1.96",
5
5
  "type": "module",
6
6
  "module": "dist/widget.iife.js",
7
7
  "exports": {