@debales/ai 1.1.31 → 1.1.32

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.
@@ -2917,7 +2917,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
2917
2917
 
2918
2918
  `+je+`
2919
2919
 
2920
- => User Action: Klaviyo form closed`}return""},vt=Vt=>{Vt instanceof CustomEvent&&Re(Vt)};return window.addEventListener("klaviyoForms",vt),()=>{window.removeEventListener("klaviyoForms",vt)}},[ne,t,r]);const[qo,Mt]=Z.useState(!1),hi=J==="Highest"?"120px":J==="Higher"?"60px":"15px",Br=async()=>{try{const Re=await fetch(`${Di}/api/wordpress/support`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({chatid:rr()+e,nameSpace:e,userName:ot.name,userEmail:ot.email,userMessage:ot.message,tag:"support"})});if(Re.ok){const rt=`support-confirm-${Date.now()}`;m(vt=>[...vt,{text:"Thanks for reaching out! Our support team has received your request and will get back to you within 24 hours.<br>In the meantime, feel free to continue chatting with me - I'll do my best to help!",isBot:!0,leading_queries:Ut,conversationId:rt}]),d(rt),Ae(vt=>({...vt,leadingQueries:!0})),Qt([]),console.log("Connected to support with existing user info:",Po())}else{const rt=await Re.json();console.error("Failed to connect to support:",rt),m(vt=>[...vt,{text:"Sorry, we couldn't connect you to support at the moment.<br>Please try again later.",isBot:!0}])}}catch{m(rt=>[...rt,{text:"Sorry, we couldn't connect you to support at the moment.<br>Please try again later.",isBot:!0}])}},Ro=()=>{const Re=Po();let rt=[];const vt=h[h.length-1];vt!=null&&vt.leading_queries&&vt.leading_queries.length>0?rt=vt.leading_queries:h.length<=1&&(rt=or.flatMap(Vt=>Array.isArray(Vt)?Vt.map(lt=>lt.question):[Vt.question]).slice(0,4)),Qt(rt),Re&&Re.name&&Re.email&&ct({name:Re==null?void 0:Re.name,email:Re==null?void 0:Re.email,message:""}),m(Vt=>[...Vt,{text:"Please provide your name, email and message to connect with support.",isBot:!0}]),qe(!0)},Oo=async Re=>{Re.preventDefault();const rt={name:"",email:"",message:""};let vt=!0;const Vt=ot.name.trim(),lt=ot.message.trim();Vt||(rt.name="Name cannot be empty or just whitespace.",vt=!1),(!ot.email||!Pm.isEmail(ot.email))&&(rt.email="Please enter a valid email address.",vt=!1),lt||(rt.message="Message cannot be empty or just whitespace.",vt=!1),ie(rt),vt&&(of({name:Vt,email:ot.email}),qe(!1),m(je=>je.slice(0,-1)),await Br())};return Z.useEffect(()=>{if(h.length===1&&h[0].isBot){Ue(rt=>({...rt,leadingQueries:!0}));const Re=setTimeout(()=>{Ue(rt=>({...rt,leadingQueries:!1}))},2e3);return()=>clearTimeout(Re)}},[h]),console.debug("main render"),!t||t.show_bot===!1||a?null:M.jsxs(Zw,{theme:uE(t,e),children:[M.jsx("link",{rel:"preconnect",href:"https://fonts.googleapis.com"}),M.jsx("link",{rel:"preconnect",href:"https://fonts.gstatic.com",crossOrigin:"anonymous"}),M.jsx("link",{href:"https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap",rel:"stylesheet"}),M.jsx("link",{href:"https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,100;0,300;0,400;0,700;0,900;1,100;1,300;1,400;1,700;1,900&display=swap",rel:"stylesheet"}),M.jsx(qhe,{}),!re&&(Wr==null?void 0:Wr.length)!==0&&M.jsx(Hhe,{className:st?"visible":"",$botId:e,$iconSize:G,$removeLogoBackground:t.removeLogoBackground,topOffset:hi,style:{right:z?"auto":"24px",left:z?"24px":"auto",display:"flex",flexDirection:"column",alignItems:z?"flex-start":"flex-end"},children:Be.suggestions?M.jsx(Mi,{isBot:!0,children:M.jsx(Os,{loading:Be.suggestions})}):Wr.map((Re,rt)=>{if(Array.isArray(Re)){const vt=Re.map(Vt=>({question:Vt.question,isHighlighted:Vt.isHighlighted??!1})).filter(Vt=>!ue.has(Vt.question));return M.jsx(DP,{$index:rt,$totalCount:Wr.length,children:M.jsx(nde,{messages:vt,botId:e,uiData:t,onClick:Vt=>{const lt=Re.find(je=>je.question===Vt);Ee(!0,"suggested_question_clicked"),Te(je=>{const dn=new Set(je);return dn.add(Vt),dn}),window.DebalesChat.track(an.SUGGESTED_QUESTION_CLICKED,{suggested_question:lt}),!R&&lt?(ft(!1),Ot(!0),r({message:lt.Follow_up_Question??lt.question,answer:lt==null?void 0:lt.answer,products:lt==null?void 0:lt.products,fromKlaviyo:!1,leading_queries:lt==null?void 0:lt.leading_queries,followUpQuestion:lt==null?void 0:lt.Follow_up_Question,messType:"suggested_question"})):(ft(!1),Ot(!0),E(!0),O(lt))}})},rt)}else return M.jsx(DP,{$index:rt,$totalCount:Wr.length,children:M.jsx(ede,{value:`${Re.question}`,index:rt,botId:e,uiData:t,onClose:()=>{Te(vt=>{const Vt=new Set(vt);return Vt.add(Re.question),Vt})},onClick:()=>{Ee(!0,"suggested_question_clicked"),Te(vt=>{const Vt=new Set(vt);return Vt.add(Re.question),Vt}),window.DebalesChat.track(an.SUGGESTED_QUESTION_CLICKED,{suggested_question:Re}),R?(ft(!1),Ot(!0),E(!0),O(Re)):(ft(!1),Ot(!0),r({message:Re.question,answer:Re.answer,products:Re.products,leading_queries:Re.leading_queries,followUpQuestion:Re.Follow_up_Question,messType:"suggested_question"}))},isHighlighted:Re.isHighlighted??!1})},rt)})}),M.jsxs(Che,{$topOffset:hi,$removeLogoBackground:t.removeLogoBackground,style:{display:re?"none":"inline-flex",right:z?"auto":"24px",left:z?"24px":"auto"},children:[M.jsx(Ehe,{$showAnimation:t.enableChatButtonBackgroundAnimation??!1,$animationType:"Ping",$animationColor:t.chatButtonBackgroundAnimationColor||"#f48722",$backgroundColor:t.backgroundColor||"#fff",$removeLogoBackground:t.removeLogoBackground,$topOffset:hi,$iconSize:G}),M.jsx(Ahe,{$backgroundColor:t.removeLogoBackground?"transparent":t.backgroundColor||"#fff",$botId:e,$iconSize:G,$removeLogoBackground:t.removeLogoBackground,topOffset:hi,$showAnimation:t.enableChatButtonBackgroundAnimation,$animationType:"Ping",$animationColor:t.chatButtonBackgroundAnimationColor||"#f48722",id:"debales-chat-button","data-testid":"debales-chat-button",onClick:()=>{if(window.DebalesChat.track(an.CHAT_BUTTON_CLICKED),Ee(!re,"chat_button_clicked"),!re){const Re=_();Re.length>0?(m(Re),ft(!1),Ot(!0)):(ft(!0),Ot(!1),Ue(rt=>({...rt,initialMessage:!0,leadingQueries:!0})),Ae({text:!0,leadingQueries:!1,collections:!1,products:!1,variants:!1,cartSummary:!1,bulkItems:!1}),setTimeout(()=>{ft(!1),Ot(!0),Ue(vt=>({...vt,initialMessage:!1}));const rt={text:(t==null?void 0:t.initialMessage)||"Hi, I am an AI chatbot, how can I help you today?",isBot:!0};m([rt]),Ue(vt=>({...vt,leadingQueries:!0})),setTimeout(()=>{Ae(vt=>({...vt,leadingQueries:!0}))},Xt)},Xt))}},"aria-label":"Chat",style:{display:re?"none":"inline-flex",right:z?"auto":"24px",left:z?"24px":"auto"},children:M.jsx(khe,{$botId:e,$removeLogoBackground:t.removeLogoBackground,"aria-hidden":"true",src:t.bot_logo,alt:"Chat Bot Icon"})})]}),re&&hw.createPortal(M.jsx(M.Fragment,{children:M.jsxs(Dhe,{$backgroundColor:t.backgroundColor||"#fff",$fullScreenOnMobile:t.fullScreenOnMobile,$headerFontColor:t.headerFontColor||"#1C1C1C",$isLeft:z,$topOffset:hi,$mobileDisplayMode:t.mobileDisplayMode,$isVisible:fe,"data-testid":"debales-chat-container",children:[M.jsxs($he,{$backgroundColor:He(e)?t.backgroundColor:t.botBackgroundColor||"#fff",style:{color:t.headerFontColor},children:[M.jsx("div",{style:{flexGrow:.1,display:"flex",justifyContent:"center",alignItems:"center",overflow:"hidden",marginRight:"8px",gap:"10px"},children:He(e)?M.jsxs(M.Fragment,{children:[M.jsx(EP,{"aria-hidden":"true",src:t.bot_logo,alt:"Chat Bot Icon"}),M.jsxs(The,{$botNameColor:t.headerFontColor,children:[M.jsxs("div",{style:{fontWeight:"700",wordBreak:"break-word"},children:[t.chatbotName,e==="catch-org-ai"&&M.jsx(Ohe,{$backgroundColor:t.callToActionBackgroundColor,$fontColor:t.callToActionFontColor,children:"Beta"})]}),M.jsx(Rhe,{})]})]}):M.jsx(Mhe,{children:M.jsxs(Ihe,{children:[M.jsx(EP,{src:t.bot_logo,alt:"Chat Bot Icon"}),M.jsx("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",display:"inline-block",maxWidth:"22ch"},children:t.chatbotName})]})})}),M.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginLeft:"auto",flexShrink:0},children:[M.jsxs(Ghe,{children:[M.jsx(AP,{$iconBG:t.backgroundColor,onClick:Ro,"aria-label":"Support","data-testid":"debales-support-button",children:M.jsx(pk,{color:t.headerFontColor})}),M.jsx(MP,{children:"Click to chat with a Live Support Agent now."})]}),M.jsx(AP,{$iconBG:t.backgroundColor,onClick:()=>{se?_r(!0):Ee(!1,"close_button_clicked")},id:"debales-minimize-button","data-testid":"debales-minimize-button","aria-label":"Minimize",children:M.jsx(Hm,{botNameColor:t.headerFontColor})})]}),M.jsx(Xhe,{$backgroundColor:t.botBackgroundColor||"#fff",style:{opacity:rn?1:0}})]}),M.jsxs(Nhe,{$backgroundColor:t.botBackgroundColor||"#fff",$mobileDisplayMode:t.mobileDisplayMode,children:[qo&&((Go=(ar=t.pluginConfig)==null?void 0:ar.collectedUserInfo)==null?void 0:Go.discount)&&M.jsx(wk,{discount:t.pluginConfig.collectedUserInfo.discount,uiData:t,onClose:()=>{Mt(!1),window.DebalesChat.track(an.DISCOUNT_VIEWED,{discount:t.pluginConfig.collectedUserInfo.discount})}}),M.jsx(Rk,{uidata:t,product:ir,showModel:Wt,setShowModel:Gt,onVariantSelect:Re=>{console.debug("VariantSelectionModel : Adding item to cart:",Re),L(Re.id,1,{productId:(ir==null?void 0:ir.productId)||""}),ye(!0),window.DebalesChat.track(an.ADD_TO_CART_CLICKED,{product:Re.title,price:Number(Re.price),link:`https://${t.shopifyShopDomain}/variants/${Re.id}`,message:l,chatId:rr()+e})}}),fn&&M.jsx(Ck,{setShowExitModal:_r,handleCloseChatbot:on,chatId:rr()+e}),M.jsxs(Bhe,{id:"debales-conversation-group",$botBackgroundColor:t.botBackgroundColor||"#fff",ref:te,$mobileDisplayMode:t.mobileDisplayMode,"data-testid":"debales-conversation-group",children:[M.jsx(Khe,{$backgroundColor:t.botBackgroundColor||"#fff",style:{opacity:rn?1:0}}),M.jsxs(Lhe,{children:[Lt&&h.map((Re,rt)=>{const vt=Re.isBot,Vt=$p(Re.text);return Re.hideConfirmation?null:M.jsxs(Z.Fragment,{children:[vt&&M.jsxs(kP,{$fontColor:t.botFontColor||"#000",$botMessageColor:t.botBackgroundColor||"#fff","data-testid":"debales-ai-message-container",children:[M.jsx("img",{src:vt?t.bot_logo:t.userMessage_logo,alt:"Chat User Icon",style:{marginLeft:"8px"}}),M.jsxs(OP,{children:[Vt.map(lt=>M.jsx("div",{children:M.jsx(Mi,{isBot:vt,children:M.jsx(bd,{components:{a:({href:je,children:dn})=>{const dr=()=>{je!=null&&je.startsWith("https://shop.catch.org/")&&window.DebalesChat.track(an.SHOPIFY_LINK_CLICKED)};return M.jsx("a",{href:je,target:"_blank",onClick:dr,children:dn})}},remarkPlugins:[Tw,bE],children:lt})})})),Re.collections&&l===Re.conversationId&&ge.collections&&M.jsx(Sk,{message:Re,botId:e,uidata:t,onSendMessage:r,loading:p}),Re.products&&l===Re.conversationId&&ge.products&&M.jsx(Ak,{message:Re,botId:e,uidata:t,onSendMessage:r,loading:p,storeMetaData:n,platform:W,setShowVariantModel:Gt,setSelectedProduct:Kr,setCartVersion:j}),o&&M.jsx(p8,{children:M.jsx(Ix,{onClick:()=>{window._klOnsite&&(window._klOnsite.push(["openForm",Ce]),Ee(!1,"klaviyo_grab_deal_button"))},children:"🚀 Grab Deal Now!"})}),I&&I.itemCount>0&&l===Re.conversationId&&ge.cartSummary&&V&&M.jsx(yk,{onCheckout:po,onKeepShopping:()=>{ye(!1)}}),Je&&Je.length>0&&l===Re.conversationId&&ge.bulkItems&&M.jsx(fk,{onClick:()=>Dn(Re.conversationId),children:"Add Bulk Items to Cart"}),A&&h.indexOf(Re)===h.length-1&&M.jsx(M.Fragment,{children:M.jsx(kk,{setShowModel:lt=>{var dn,dr;const je=typeof lt=="function"?lt(A):lt;E(je),!je&&((dr=(dn=t.pluginConfig)==null?void 0:dn.collectedUserInfo)!=null&&dr.discount)&&Mt(!0)},inChat:!0,showFormInstructions:!1})}),Bt&&h.indexOf(Re)===h.length-1&&M.jsxs(Vhe,{onSubmit:Oo,noValidate:!0,"data-testid":"debales-support-form",children:[He(e)?M.jsxs(M.Fragment,{children:[M.jsx(eu,{label:"Name",name:"name",type:"text",value:ot.name,onChange:lt=>ct(je=>({...je,name:lt.target.value})),required:!0,error:ht.name,isCollectiveBot:!0}),M.jsx(eu,{label:"Email",name:"email",type:"email",value:ot.email,onChange:lt=>ct(je=>({...je,email:lt.target.value})),required:!0,error:ht.email,isCollectiveBot:!0}),M.jsx(Ek,{label:"Message",name:"message",value:ot.message,onChange:lt=>ct(je=>({...je,message:lt.target.value})),required:!0,error:ht.message,rows:4,isCollectiveBot:!0})]}):M.jsxs(M.Fragment,{children:[M.jsxs(g8,{children:[M.jsxs(m8,{children:["Name",M.jsx("span",{children:"*"})]}),M.jsx(IP,{type:"text",required:!0,value:ot.name,onChange:lt=>ct(je=>({...je,name:lt.target.value})),placeholder:"John"}),ht.name&&M.jsx("p",{style:{color:"red",fontSize:"12px",margin:"4px 0 0"},children:ht.name})]}),M.jsxs(g8,{children:[M.jsxs(m8,{children:["Email",M.jsx("span",{children:"*"})]}),M.jsx(IP,{type:"email",required:!0,value:ot.email,onChange:lt=>ct(je=>({...je,email:lt.target.value})),placeholder:"olivia@untitledui.com"}),ht.email&&M.jsx("p",{style:{color:"red",fontSize:"12px",margin:"4px 0 0"},children:ht.email})]}),M.jsxs(g8,{children:[M.jsxs(m8,{children:["Message",M.jsx("span",{children:"*"})]}),M.jsx(Yhe,{required:!0,value:ot.message,onChange:lt=>ct(je=>({...je,message:lt.target.value})),placeholder:"I need help with..."}),ht.message&&M.jsx("p",{style:{color:"red",fontSize:"12px",margin:"4px 0 0"},children:ht.message})]})]}),M.jsx(Qhe,{children:M.jsx(Zhe,{type:"submit",children:"Submit"})})]}),pt&&!p&&l===Re.conversationId&&M.jsx(Mi,{isBot:vt,children:M.jsx(Os,{loading:pt})})]})]}),!vt&&M.jsx(jhe,{$fontColor:t.userFontColor||"#000",$botMessageColor:t.botBackgroundColor||"#fff",children:M.jsx(Mi,{isBot:!!vt,children:M.jsx(bd,{children:Re.text})})}),h.length==1&&rt==0&&!A&&M.jsx(p8,{children:Be.leadingQueries?M.jsx(Mi,{isBot:vt??!0,children:M.jsx(Os,{loading:Be.leadingQueries})}):or.map(lt=>Array.isArray(lt)?lt[0]:lt).map((lt,je)=>M.jsxs(RP,{style:{backgroundColor:t.callToActionBackgroundColor,color:t.callToActionFontColor},onClick:()=>{R?(E(!0),O({question:lt.question,answer:lt.answer,products:lt.products,path:"/",nameSpace:window.DebalesChat.projectId})):(ft(!1),Ot(!0),r({message:lt.question,answer:lt.answer,products:lt.products,leading_queries:lt.leading_queries,followUpQuestion:lt.Follow_up_Question,messType:"leading_query"})),Te(dn=>{const dr=new Set(dn);return dr.add(lt.question),dr}),window.DebalesChat.track(an.INITIAL_LEADING_QUERY_SUGGESTED_QUESTION_CLICKED,{question:lt.question})},disabled:p,$disabled:p,children:[lt.question,M.jsx(TP,{color:t.callToActionFontColor})]},je))}),Re.leading_queries&&Re.leading_queries.length>0&&l===Re.conversationId&&ge.leadingQueries&&!o&&!A&&M.jsx(p8,{children:Re.leading_queries.map((lt,je)=>M.jsxs(RP,{style:{backgroundColor:t.callToActionBackgroundColor,color:t.callToActionFontColor},onClick:()=>{R?(E(!0),O({question:lt,path:"/",nameSpace:window.DebalesChat.projectId})):r({message:lt,messType:"leading_query"}),window.DebalesChat.track(an.LEADING_QUERY_CLICKED,{query:lt})},disabled:p,$disabled:p,children:[lt,M.jsx(TP,{color:t.callToActionFontColor})]},je))})]},rt)}),(p||Rt)&&M.jsxs(kP,{$fontColor:t.botFontColor||"#000",$botMessageColor:t.botBackgroundColor||"#fff",children:[M.jsx("img",{src:t.bot_logo,alt:"Chat User Icon"}),M.jsx(OP,{children:M.jsx(Mi,{isBot:!0,children:M.jsx("div",{style:{display:"flex",alignItems:"center",gap:"4px",animation:"fadeIn 0.3s ease-in-out"},children:M.jsx(Os,{loading:p||Rt})})})})]})]}),M.jsx(Whe,{$backgroundColor:t.botBackgroundColor||"#fff",style:{opacity:mn?1:0}})]}),M.jsxs("div",{className:"debales-footer-container",style:{width:"calc(100%-24px)",backgroundColor:t.botBackgroundColor||"#fff",color:t.fontColor||"#000"},children:[e==="catch-org-ai"&&M.jsx(Uhe,{children:M.jsx("span",{children:'"Catch org AI" can make mistakes.'})}),M.jsx("div",{children:M.jsx(Ok,{disabled:p,inputState:!1})}),(t.debales_branding??!0)&&M.jsxs(zhe,{href:"https://debales.ai/?open=true",target:"_blank",title:"debales-link",style:{color:t.fontColor?t.fontColor:"fff",marginTop:e==="catch-org-ai"?"0":"9px"},children:[M.jsx("p",{children:"Powered by"}),M.jsxs(Fhe,{children:[M.jsx("img",{src:`${Di}/images/debales_logo_d.png`,alt:"Debales logo"}),M.jsx("p",{children:"DEBALES"})]})]})]})]})]})}),Q.shadowRoot)]})},Jhe=ae.p`
2920
+ => User Action: Klaviyo form closed`}return""},vt=Vt=>{Vt instanceof CustomEvent&&Re(Vt)};return window.addEventListener("klaviyoForms",vt),()=>{window.removeEventListener("klaviyoForms",vt)}},[ne,t,r]);const[qo,Mt]=Z.useState(!1),hi=J==="Highest"?"120px":J==="Higher"?"60px":"15px",Br=async()=>{try{const Re=await fetch(`${Di}/api/wordpress/support`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({chatid:rr()+e,nameSpace:e,userName:ot.name,userEmail:ot.email,userMessage:ot.message,tag:"support"})});if(Re.ok){const rt=`support-confirm-${Date.now()}`;m(vt=>[...vt,{text:"Thanks for reaching out! Our support team has received your request and will get back to you within 24 hours.<br>In the meantime, feel free to continue chatting with me - I'll do my best to help!",isBot:!0,leading_queries:Ut,conversationId:rt}]),d(rt),Ae(vt=>({...vt,leadingQueries:!0})),Qt([]),console.log("Connected to support with existing user info:",Po())}else{const rt=await Re.json();console.error("Failed to connect to support:",rt),m(vt=>[...vt,{text:"Sorry, we couldn't connect you to support at the moment.<br>Please try again later.",isBot:!0}])}}catch{m(rt=>[...rt,{text:"Sorry, we couldn't connect you to support at the moment.<br>Please try again later.",isBot:!0}])}},Ro=()=>{const Re=Po();let rt=[];const vt=h[h.length-1];vt!=null&&vt.leading_queries&&vt.leading_queries.length>0?rt=vt.leading_queries:h.length<=1&&(rt=or.flatMap(Vt=>Array.isArray(Vt)?Vt.map(lt=>lt.question):[Vt.question]).slice(0,4)),Qt(rt),Re&&Re.name&&Re.email&&ct({name:Re==null?void 0:Re.name,email:Re==null?void 0:Re.email,message:""}),m(Vt=>[...Vt,{text:"Please provide your name, email and message to connect with support.",isBot:!0}]),qe(!0)},Oo=async Re=>{Re.preventDefault();const rt={name:"",email:"",message:""};let vt=!0;const Vt=ot.name.trim(),lt=ot.message.trim();Vt||(rt.name="Name cannot be empty or just whitespace.",vt=!1),(!ot.email||!Pm.isEmail(ot.email))&&(rt.email="Please enter a valid email address.",vt=!1),lt||(rt.message="Message cannot be empty or just whitespace.",vt=!1),ie(rt),vt&&(of({name:Vt,email:ot.email}),qe(!1),m(je=>je.slice(0,-1)),await Br())};return Z.useEffect(()=>{if(h.length===1&&h[0].isBot){Ue(rt=>({...rt,leadingQueries:!0}));const Re=setTimeout(()=>{Ue(rt=>({...rt,leadingQueries:!1}))},2e3);return()=>clearTimeout(Re)}},[h]),console.debug("main render"),!t||t.show_bot===!1||a?null:M.jsxs(Zw,{theme:uE(t,e),children:[M.jsx("link",{rel:"preconnect",href:"https://fonts.googleapis.com"}),M.jsx("link",{rel:"preconnect",href:"https://fonts.gstatic.com",crossOrigin:"anonymous"}),M.jsx("link",{href:"https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap",rel:"stylesheet"}),M.jsx("link",{href:"https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,100;0,300;0,400;0,700;0,900;1,100;1,300;1,400;1,700;1,900&display=swap",rel:"stylesheet"}),M.jsx(qhe,{}),!re&&(Wr==null?void 0:Wr.length)!==0&&M.jsx(Hhe,{className:st?"visible":"",$botId:e,$iconSize:G,$removeLogoBackground:t.removeLogoBackground,topOffset:hi,style:{right:z?"auto":"24px",left:z?"24px":"auto",display:"flex",flexDirection:"column",alignItems:z?"flex-start":"flex-end"},children:Be.suggestions?M.jsx(Mi,{isBot:!0,children:M.jsx(Os,{loading:Be.suggestions})}):Wr.map((Re,rt)=>{if(Array.isArray(Re)){const vt=Re.map(Vt=>({question:Vt.question,isHighlighted:Vt.isHighlighted??!1})).filter(Vt=>!ue.has(Vt.question));return M.jsx(DP,{$index:rt,$totalCount:Wr.length,children:M.jsx(nde,{messages:vt,botId:e,uiData:t,onClick:Vt=>{const lt=Re.find(je=>je.question===Vt);Ee(!0,"suggested_question_clicked"),Te(je=>{const dn=new Set(je);return dn.add(Vt),dn}),window.DebalesChat.track(an.SUGGESTED_QUESTION_CLICKED,{suggested_question:lt}),!R&&lt?(ft(!1),Ot(!0),r({message:lt.Follow_up_Question??lt.question,answer:lt==null?void 0:lt.answer,products:lt==null?void 0:lt.products,fromKlaviyo:!1,leading_queries:lt==null?void 0:lt.leading_queries,followUpQuestion:lt==null?void 0:lt.Follow_up_Question,messType:"suggested_question"})):(ft(!1),Ot(!0),E(!0),O(lt))}})},rt)}else return M.jsx(DP,{$index:rt,$totalCount:Wr.length,children:M.jsx(ede,{value:`${Re.question}`,index:rt,botId:e,uiData:t,onClose:()=>{Te(vt=>{const Vt=new Set(vt);return Vt.add(Re.question),Vt})},onClick:()=>{Ee(!0,"suggested_question_clicked"),Te(vt=>{const Vt=new Set(vt);return Vt.add(Re.question),Vt}),window.DebalesChat.track(an.SUGGESTED_QUESTION_CLICKED,{suggested_question:Re}),R?(ft(!1),Ot(!0),E(!0),O(Re)):(ft(!1),Ot(!0),r({message:Re.question,answer:Re.answer,products:Re.products,leading_queries:Re.leading_queries,followUpQuestion:Re.Follow_up_Question,messType:"suggested_question"}))},isHighlighted:Re.isHighlighted??!1})},rt)})}),M.jsxs(Che,{$topOffset:hi,$removeLogoBackground:t.removeLogoBackground,style:{display:re?"none":"inline-flex",right:z?"auto":"24px",left:z?"24px":"auto"},children:[M.jsx(Ehe,{$showAnimation:t.enableChatButtonBackgroundAnimation??!1,$animationType:"Ping",$animationColor:t.chatButtonBackgroundAnimationColor||"#f48722",$backgroundColor:t.backgroundColor||"#fff",$removeLogoBackground:t.removeLogoBackground,$topOffset:hi,$iconSize:G}),M.jsx(Ahe,{$backgroundColor:t.removeLogoBackground?"transparent":t.backgroundColor||"#fff",$botId:e,$iconSize:G,$removeLogoBackground:t.removeLogoBackground,topOffset:hi,$showAnimation:t.enableChatButtonBackgroundAnimation,$animationType:"Ping",$animationColor:t.chatButtonBackgroundAnimationColor||"#f48722",id:"debales-chat-button","data-testid":"debales-chat-button",onClick:()=>{if(window.DebalesChat.track(an.CHAT_BUTTON_CLICKED),Ee(!re,"chat_button_clicked"),!re){const Re=_();Re.length>0?(m(Re),ft(!1),Ot(!0)):(ft(!0),Ot(!1),Ue(rt=>({...rt,initialMessage:!0,leadingQueries:!0})),Ae({text:!0,leadingQueries:!1,collections:!1,products:!1,variants:!1,cartSummary:!1,bulkItems:!1}),setTimeout(()=>{ft(!1),Ot(!0),Ue(vt=>({...vt,initialMessage:!1}));const rt={text:(t==null?void 0:t.initialMessage)||"Hi, I am an AI chatbot, how can I help you today?",isBot:!0};m([rt]),Ue(vt=>({...vt,leadingQueries:!0})),setTimeout(()=>{Ae(vt=>({...vt,leadingQueries:!0}))},Xt)},Xt))}},"aria-label":"Chat",style:{display:re?"none":"inline-flex",right:z?"auto":"24px",left:z?"24px":"auto"},children:M.jsx(khe,{$botId:e,$removeLogoBackground:t.removeLogoBackground,"aria-hidden":"true",src:t.bot_logo,alt:"Chat Bot Icon"})})]}),re&&hw.createPortal(M.jsx(M.Fragment,{children:M.jsxs(Dhe,{$backgroundColor:t.backgroundColor||"#fff",$fullScreenOnMobile:t.fullScreenOnMobile,$headerFontColor:t.headerFontColor||"#1C1C1C",$isLeft:z,$topOffset:hi,$mobileDisplayMode:t.mobileDisplayMode,$isVisible:fe,"data-testid":"debales-chat-container",children:[M.jsxs($he,{$backgroundColor:He(e)?t.backgroundColor:t.botBackgroundColor||"#fff",style:{color:t.headerFontColor},children:[M.jsx("div",{style:{flexGrow:.1,display:"flex",justifyContent:"center",alignItems:"center",overflow:"hidden",marginRight:"8px",gap:"10px"},children:He(e)?M.jsxs(M.Fragment,{children:[M.jsx(EP,{"aria-hidden":"true",src:t.bot_logo,alt:"Chat Bot Icon"}),M.jsxs(The,{$botNameColor:t.headerFontColor,children:[M.jsxs("div",{style:{fontWeight:"700",wordBreak:"break-word"},children:[t.chatbotName,e==="catch-org-ai"&&M.jsx(Ohe,{$backgroundColor:t.callToActionBackgroundColor,$fontColor:t.callToActionFontColor,children:"Beta"})]}),M.jsx(Rhe,{})]})]}):M.jsx(Mhe,{children:M.jsxs(Ihe,{children:[M.jsx(EP,{src:t.bot_logo,alt:"Chat Bot Icon"}),M.jsx("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",display:"inline-block",maxWidth:"22ch"},children:t.chatbotName})]})})}),M.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginLeft:"auto",flexShrink:0},children:[M.jsxs(Ghe,{children:[M.jsx(AP,{$iconBG:t.backgroundColor,onClick:Ro,"aria-label":"Support","data-testid":"debales-support-button",children:M.jsx(pk,{color:t.headerFontColor})}),M.jsx(MP,{children:"Click to chat with a Live Support Agent now."})]}),M.jsx(AP,{$iconBG:t.backgroundColor,onClick:()=>{se?_r(!0):Ee(!1,"close_button_clicked")},id:"debales-minimize-button","data-testid":"debales-minimize-button","aria-label":"Minimize",children:M.jsx(Hm,{botNameColor:t.headerFontColor})})]}),M.jsx(Xhe,{$backgroundColor:t.botBackgroundColor||"#fff",style:{opacity:rn?1:0}})]}),M.jsxs(Nhe,{$backgroundColor:t.botBackgroundColor||"#fff",$mobileDisplayMode:t.mobileDisplayMode,children:[qo&&((Go=(ar=t.pluginConfig)==null?void 0:ar.collectedUserInfo)==null?void 0:Go.discount)&&M.jsx(wk,{discount:t.pluginConfig.collectedUserInfo.discount,uiData:t,onClose:()=>{Mt(!1),window.DebalesChat.track(an.DISCOUNT_VIEWED,{discount:t.pluginConfig.collectedUserInfo.discount})}}),M.jsx(Rk,{uidata:t,product:ir,showModel:Wt,setShowModel:Gt,onVariantSelect:Re=>{console.debug("VariantSelectionModel : Adding item to cart:",Re),L(Re.id,1,{productId:(ir==null?void 0:ir.productId)||""}),ye(!0),window.DebalesChat.track(an.ADD_TO_CART_CLICKED,{product:Re.title,price:Number(Re.price),link:`https://${t.shopifyShopDomain}/variants/${Re.id}`,message:l,chatId:rr()+e})}}),fn&&M.jsx(Ck,{setShowExitModal:_r,handleCloseChatbot:on,chatId:rr()+e}),M.jsxs(Bhe,{id:"debales-conversation-group",$botBackgroundColor:t.botBackgroundColor||"#fff",ref:te,$mobileDisplayMode:t.mobileDisplayMode,"data-testid":"debales-conversation-group",children:[M.jsx(Khe,{$backgroundColor:t.botBackgroundColor||"#fff",style:{opacity:rn?1:0}}),M.jsxs(Lhe,{children:[Lt&&h.map((Re,rt)=>{const vt=Re.isBot,Vt=$p(Re.text);return Re.hideConfirmation?null:M.jsxs(Z.Fragment,{children:[vt&&M.jsxs(kP,{$fontColor:t.botFontColor||"#000",$botMessageColor:t.botBackgroundColor||"#fff","data-testid":"debales-ai-message-container",children:[M.jsx("img",{src:vt?t.bot_logo:t.userMessage_logo,alt:"Chat User Icon",style:{marginLeft:"8px"}}),M.jsxs(OP,{children:[Vt.map(lt=>M.jsx("div",{children:M.jsx(Mi,{isBot:vt,children:M.jsx(bd,{components:{a:({href:je,children:dn})=>{const dr=()=>{je!=null&&je.startsWith("https://shop.catch.org/")&&window.DebalesChat.track(an.SHOPIFY_LINK_CLICKED)};return M.jsx("a",{href:je,target:"_blank",onClick:dr,children:dn})}},remarkPlugins:[Tw,bE],children:lt})})})),Re.collections&&l===Re.conversationId&&ge.collections&&M.jsx(Sk,{message:Re,botId:e,uidata:t,onSendMessage:r,loading:p}),Re.products&&l===Re.conversationId&&ge.products&&M.jsx(Ak,{message:Re,botId:e,uidata:t,onSendMessage:r,loading:p,storeMetaData:n,platform:W,setShowVariantModel:Gt,setSelectedProduct:Kr,setCartVersion:j}),o&&M.jsx(p8,{children:M.jsx(Ix,{onClick:()=>{window._klOnsite&&(window._klOnsite.push(["openForm",Ce]),Ee(!1,"klaviyo_grab_deal_button"))},children:"🚀 Grab Deal Now!"})}),I&&I.itemCount>0&&l===Re.conversationId&&ge.cartSummary&&V&&M.jsx(yk,{onCheckout:po,onKeepShopping:()=>{ye(!1)}}),Je&&Je.length>0&&l===Re.conversationId&&ge.bulkItems&&M.jsx(fk,{onClick:()=>Dn(Re.conversationId),children:"Add Bulk Items to Cart"}),A&&h.indexOf(Re)===h.length-1&&M.jsx(M.Fragment,{children:M.jsx(kk,{setShowModel:lt=>{var dn,dr;const je=typeof lt=="function"?lt(A):lt;E(je),!je&&((dr=(dn=t.pluginConfig)==null?void 0:dn.collectedUserInfo)!=null&&dr.discount)&&Mt(!0)},inChat:!0,showFormInstructions:!1})}),Bt&&h.indexOf(Re)===h.length-1&&M.jsxs(Vhe,{onSubmit:Oo,noValidate:!0,"data-testid":"debales-support-form",children:[He(e)?M.jsxs(M.Fragment,{children:[M.jsx(eu,{label:"Name",name:"name",type:"text",value:ot.name,onChange:lt=>ct(je=>({...je,name:lt.target.value})),required:!0,error:ht.name,isCollectiveBot:!0}),M.jsx(eu,{label:"Email",name:"email",type:"email",value:ot.email,onChange:lt=>ct(je=>({...je,email:lt.target.value})),required:!0,error:ht.email,isCollectiveBot:!0}),M.jsx(Ek,{label:"Message",name:"message",value:ot.message,onChange:lt=>ct(je=>({...je,message:lt.target.value})),required:!0,error:ht.message,rows:4,isCollectiveBot:!0})]}):M.jsxs(M.Fragment,{children:[M.jsxs(g8,{children:[M.jsxs(m8,{children:["Name",M.jsx("span",{children:"*"})]}),M.jsx(IP,{type:"text",required:!0,value:ot.name,onChange:lt=>ct(je=>({...je,name:lt.target.value})),placeholder:"John"}),ht.name&&M.jsx("p",{style:{color:"red",fontSize:"12px",margin:"4px 0 0"},children:ht.name})]}),M.jsxs(g8,{children:[M.jsxs(m8,{children:["Email",M.jsx("span",{children:"*"})]}),M.jsx(IP,{type:"email",required:!0,value:ot.email,onChange:lt=>ct(je=>({...je,email:lt.target.value})),placeholder:"olivia@untitledui.com"}),ht.email&&M.jsx("p",{style:{color:"red",fontSize:"12px",margin:"4px 0 0"},children:ht.email})]}),M.jsxs(g8,{children:[M.jsxs(m8,{children:["Message",M.jsx("span",{children:"*"})]}),M.jsx(Yhe,{required:!0,value:ot.message,onChange:lt=>ct(je=>({...je,message:lt.target.value})),placeholder:"I need help with..."}),ht.message&&M.jsx("p",{style:{color:"red",fontSize:"12px",margin:"4px 0 0"},children:ht.message})]})]}),M.jsx(Qhe,{children:M.jsx(Zhe,{type:"submit",children:"Submit"})})]}),pt&&!p&&l===Re.conversationId&&M.jsx(Mi,{isBot:vt,children:M.jsx(Os,{loading:pt})})]})]}),!vt&&M.jsx(jhe,{$fontColor:t.userFontColor||"#000",$botMessageColor:t.botBackgroundColor||"#fff",children:M.jsx(Mi,{isBot:!!vt,children:M.jsx(bd,{children:Re.text})})}),h.length==1&&rt==0&&!A&&M.jsx(p8,{children:Be.leadingQueries?M.jsx(Mi,{isBot:vt??!0,children:M.jsx(Os,{loading:Be.leadingQueries})}):or.map(lt=>Array.isArray(lt)?lt[0]:lt).map((lt,je)=>M.jsxs(RP,{style:{backgroundColor:t.callToActionBackgroundColor,color:t.callToActionFontColor},onClick:()=>{R?(E(!0),O({question:lt.question,answer:lt.answer,products:lt.products,path:"/",nameSpace:window.DebalesChat.projectId})):(ft(!1),Ot(!0),r({message:lt.question,answer:lt.answer,products:lt.products,leading_queries:lt.leading_queries,followUpQuestion:lt.Follow_up_Question,messType:"leading_query"})),Te(dn=>{const dr=new Set(dn);return dr.add(lt.question),dr}),window.DebalesChat.track(an.INITIAL_LEADING_QUERY_SUGGESTED_QUESTION_CLICKED,{question:lt.question})},disabled:p,$disabled:p,children:[lt.question,M.jsx(TP,{color:t.callToActionFontColor})]},je))}),Re.leading_queries&&Re.leading_queries.length>0&&l===Re.conversationId&&ge.leadingQueries&&!o&&!A&&M.jsx(p8,{children:Re.leading_queries.map((lt,je)=>M.jsxs(RP,{style:{backgroundColor:t.callToActionBackgroundColor,color:t.callToActionFontColor},onClick:()=>{R?(E(!0),O({question:lt,path:"/",nameSpace:window.DebalesChat.projectId})):r({message:lt,messType:"leading_query"}),window.DebalesChat.track(an.LEADING_QUERY_CLICKED,{query:lt})},disabled:p,$disabled:p,children:[lt,M.jsx(TP,{color:t.callToActionFontColor})]},je))})]},rt)}),(p||Rt)&&M.jsxs(kP,{$fontColor:t.botFontColor||"#000",$botMessageColor:t.botBackgroundColor||"#fff",children:[M.jsx("img",{src:t.bot_logo,alt:"Chat User Icon"}),M.jsx(OP,{children:M.jsx(Mi,{isBot:!0,children:M.jsx("div",{style:{display:"flex",alignItems:"center",gap:"4px",animation:"fadeIn 0.3s ease-in-out"},children:M.jsx(Os,{loading:p||Rt})})})})]})]}),M.jsx(Whe,{$backgroundColor:t.botBackgroundColor||"#fff",style:{opacity:mn?1:0}})]}),M.jsxs("div",{className:"debales-footer-container",style:{width:"calc(100%-24px)",backgroundColor:t.botBackgroundColor||"#fff",color:t.fontColor||"#000"},children:[(e==="catch-org-ai"||e==="letsgo-catch")&&M.jsx(Uhe,{children:M.jsx("span",{children:`"${t.chatbotName}" can make mistakes.`})}),M.jsx("div",{children:M.jsx(Ok,{disabled:p,inputState:!1})}),(t.debales_branding??!0)&&M.jsxs(zhe,{href:"https://debales.ai/?open=true",target:"_blank",title:"debales-link",style:{color:t.fontColor?t.fontColor:"fff",marginTop:e==="catch-org-ai"?"0":"9px"},children:[M.jsx("p",{children:"Powered by"}),M.jsxs(Fhe,{children:[M.jsx("img",{src:`${Di}/images/debales_logo_d.png`,alt:"Debales logo"}),M.jsx("p",{children:"DEBALES"})]})]})]})]})]})}),Q.shadowRoot)]})},Jhe=ae.p`
2921
2921
  margin: 0;
2922
2922
  font-size: 16px;
2923
2923
  text-align: left;
@@ -3679,7 +3679,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
3679
3679
 
3680
3680
  `+Xe+`
3681
3681
 
3682
- => User Action: Klaviyo form closed`}return""},ve=Oe=>{Oe instanceof CustomEvent&&Y(Oe)};return window.addEventListener("klaviyoForms",ve),()=>{window.removeEventListener("klaviyoForms",ve)}},[Ut,t,r]),Z.useEffect(()=>{const Y=ge.current;return Te&&Y?(Y.addEventListener("scroll",or),()=>{Y&&Y.removeEventListener("scroll",or)}):()=>{}},[Te,or]);const[Re,rt]=Z.useState(!1),vt=Q==="Highest"?"120px":Q==="Higher"?"60px":"15px",Vt=async()=>{try{const Y=await fetch(`${Di}/api/wordpress/support`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({chatid:rr()+e,nameSpace:e,userName:Ot.name,userEmail:Ot.email,userMessage:Ot.message,tag:"support"})});if(Y.ok){const ce=`support-confirm-${Date.now()}`;m(ve=>[...ve,{text:"Thanks for reaching out! Our support team has received your request and will get back to you within 24 hours.<br>In the meantime, feel free to continue chatting with me - I'll do my best to help!",isBot:!0,leading_queries:Jt,conversationId:ce}]),d(ce),ye(ve=>({...ve,leadingQueries:!0})),mn([]),console.log("Connected to support with existing user info:",Po())}else{const ce=await Y.json();console.error("Failed to connect to support:",ce),m(ve=>[...ve,{text:"Sorry, we couldn't connect you to support at the moment.<br>Please try again later.",isBot:!0}])}}catch{m(ce=>[...ce,{text:"Sorry, we couldn't connect you to support at the moment.<br>Please try again later.",isBot:!0}])}},lt=()=>{const Y=Po();let ce=[];const ve=h[h.length-1];ve!=null&&ve.leading_queries&&ve.leading_queries.length>0?ce=ve.leading_queries:h.length<=1&&(ce=j.flatMap(Oe=>Array.isArray(Oe)?Oe.map(we=>we.question):[Oe.question]).slice(0,4)),mn(ce),Y&&Y.name&&Y.email&&rn({name:Y==null?void 0:Y.name,email:Y==null?void 0:Y.email,message:""}),m(Oe=>[...Oe,{text:"Please provide your name, email and message to connect with support.",isBot:!0}]),Lt(!0)},je=async Y=>{Y.preventDefault();const ce={name:"",email:"",message:""};let ve=!0;const Oe=Ot.name.trim(),we=Ot.message.trim();Oe||(ce.name="Name cannot be empty or just whitespace.",ve=!1),(!Ot.email||!Pm.isEmail(Ot.email))&&(ce.email="Please enter a valid email address.",ve=!1),we||(ce.message="Message cannot be empty or just whitespace.",ve=!1),Xt(ce),ve&&(of({name:Oe,email:Ot.email}),Lt(!1),m(Xe=>Xe.slice(0,-1)),await Vt())},[dn,dr]=Z.useState({});return Z.useEffect(()=>{_r&&(h.forEach((Y,ce)=>{if(!Y.isBot)return;const ve=$p(Y.text);if(!(ce in dn)||dn[ce]<ve.length){let Oe;const we=Xe=>{Xe<ve.length&&(Oe=setTimeout(()=>{dr(zt=>({...zt,[ce]:Xe+1})),we(Xe+1)},po))};return ce in dn?we(dn[ce]):(dr(Xe=>({...Xe,[ce]:1})),we(1)),()=>clearTimeout(Oe)}}),dr(Y=>{const ce={};return h.forEach((ve,Oe)=>{Y[Oe]!==void 0&&(ce[Oe]=Y[Oe])}),ce}))},[h,_r]),!t||t.show_bot===!1||a?null:M.jsxs(Zw,{theme:uE(t,e),children:[M.jsx("link",{rel:"preconnect",href:"https://fonts.googleapis.com"}),M.jsx("link",{rel:"preconnect",href:"https://fonts.gstatic.com",crossOrigin:"anonymous"}),M.jsx("link",{href:"https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap",rel:"stylesheet"}),M.jsx("link",{href:"https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,100;0,300;0,400;0,700;0,900;1,100;1,300;1,400;1,700;1,900&display=swap",rel:"stylesheet"}),M.jsx(Ape,{}),M.jsxs(ipe,{$topOffset:vt,$isLeft:W,children:[!Te&&j.length>0&&j[U]&&ne&&M.jsx(Cpe,{className:Ce?"visible":"",$botId:e,$iconSize:H,$removeLogoBackground:t.removeLogoBackground,topOffset:vt,style:{display:"flex",flexDirection:W?"row":"row-reverse",alignItems:"center",marginLeft:ot?"60px":"85px",marginRight:ot?"60px":"85px",left:W?"24px":"auto",right:W?"auto":"24px",opacity:Ce?1:0,transition:"opacity 0.3s ease-in-out"},children:j.length>0&&j[U]&&(()=>{const Y=j[U];return M.jsx(Epe,{children:M.jsx(tpe,{messages:[{question:Y.question,isHighlighted:Y.isHighlighted??!1,show_for:(ee==null?void 0:ee.show_for)||4e3,hide_timing:(ee==null?void 0:ee.hide_timing)||4e3}],botId:e,uiData:t,onClose:()=>{Ue(ce=>{const ve=new Set(ce);return ve.add(Y.question),ve})},onClick:()=>{const ce=Y;pt(!0,"suggested_question_clicked"),Ue(ve=>{const Oe=new Set(ve);return Oe.add(ce.question),Oe}),window.DebalesChat.track(an.SUGGESTED_QUESTION_CLICKED,{suggested_question:ce}),E?(fn(!1),ir(!0),A(!0),R(ce)):(fn(!1),ir(!0),r({message:ce.Follow_up_Question??ce.question,answer:ce.answer,products:ce.products,fromKlaviyo:!1,leading_queries:ce.leading_queries,followUpQuestion:ce.Follow_up_Question,messType:"suggested_question"}))}})},Y.question)})()}),M.jsxs(ope,{$topOffset:vt,$removeLogoBackground:t.removeLogoBackground,$isLeft:W,style:{display:Te?"none":"inline-flex"},children:[M.jsx(ape,{$showAnimation:t.enableChatButtonBackgroundAnimation??!1,$animationType:"Ping",$animationColor:t.chatButtonBackgroundAnimationColor||"#f48722",$backgroundColor:t.backgroundColor||"#fff",$removeLogoBackground:t.removeLogoBackground,$topOffset:vt,$iconSize:H}),M.jsxs(spe,{$backgroundColor:t.removeLogoBackground?"transparent":t.backgroundColor||"#fff",$botId:e,$isLeft:W,$iconSize:H,$removeLogoBackground:t.removeLogoBackground,topOffset:vt,$showAnimation:t.enableChatButtonBackgroundAnimation,$animationType:"Ping",$animationColor:t.chatButtonBackgroundAnimationColor||"#f48722",id:"debales-chat-button","data-testid":"debales-chat-button",onClick:()=>{if(window.DebalesChat.track(an.CHAT_BUTTON_CLICKED),pt(!Te,"chat_button_clicked"),!Te){const Y=_();Y.length>0?(m(Y),fn(!1),ir(!0)):(fn(!0),ir(!1),setTimeout(()=>{fn(!1),ir(!0);const ce={text:(t==null?void 0:t.initialMessage)||"Hi, I am an AI chatbot, how can I help you today?",isBot:!0};m([ce])},(ee==null?void 0:ee.showing_delay)||2e3))}},"aria-label":"Chat",style:{display:Te?"none":"inline-flex"},children:[M.jsx(lpe,{$botId:e,$removeLogoBackground:t.removeLogoBackground,"aria-hidden":"true",src:t.bot_logo,alt:"Chat Bot Icon"}),(j==null?void 0:j.length)>0&&!Te&&fe&&M.jsx("div",{style:{position:"absolute",top:"-5px",right:"-5px",backgroundColor:"#f44336",color:"white",borderRadius:"50%",width:"20px",height:"20px",display:"flex",justifyContent:"center",alignItems:"center",fontSize:"12px",fontWeight:"bold",zIndex:2,opacity:fe?1:0,transition:"opacity 0.3s ease-in-out"},children:j.length})]})]})]}),Te&&hw.createPortal(M.jsx(M.Fragment,{children:M.jsxs(dpe,{$backgroundColor:t.backgroundColor||"#fff",$fullScreenOnMobile:t.fullScreenOnMobile,$headerFontColor:t.headerFontColor||"#1C1C1C",$isLeft:W,$topOffset:vt,$mobileDisplayMode:t.mobileDisplayMode,$isVisible:st,"data-testid":"debales-chat-container",children:[M.jsxs(gpe,{$backgroundColor:He(e)?t.backgroundColor:t.botBackgroundColor||"#fff",style:{color:t.headerFontColor},children:[M.jsx("div",{style:{flexGrow:.1,display:"flex",justifyContent:"center",alignItems:"center",overflow:"hidden",marginRight:"8px",gap:"10px"},children:He(e)?M.jsxs(M.Fragment,{children:[M.jsx(LP,{"aria-hidden":"true",src:t.bot_logo,alt:"Chat Bot Icon"}),M.jsxs(upe,{$botNameColor:t.headerFontColor,children:[M.jsxs("div",{style:{fontWeight:"700",wordBreak:"break-word"},children:[t.chatbotName,e==="catch-org-ai"&&M.jsx(fpe,{$backgroundColor:t.callToActionBackgroundColor,$fontColor:t.callToActionFontColor,children:"Beta"})]}),M.jsx(cpe,{})]})]}):M.jsx(hpe,{children:M.jsxs(ppe,{children:[M.jsx(LP,{src:t.bot_logo,alt:"Chat Bot Icon"}),M.jsx("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",display:"inline-block",maxWidth:"22ch"},children:t.chatbotName})]})})}),M.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginLeft:"auto",flexShrink:0},children:[M.jsxs(kpe,{children:[M.jsx(NP,{$iconBG:t.backgroundColor,onClick:lt,"aria-label":"Support","data-testid":"debales-support-button",children:M.jsx(pk,{color:t.headerFontColor})}),M.jsx(PP,{children:"Click to chat with a Live Support Agent now."})]}),M.jsx(NP,{$iconBG:t.backgroundColor,onClick:()=>{Ct?Mt(!0):pt(!1,"close_button_clicked")},id:"debales-minimize-button","data-testid":"debales-minimize-button","aria-label":"Minimize",children:M.jsx(Hm,{botNameColor:t.headerFontColor})})]}),M.jsx($pe,{$backgroundColor:t.botBackgroundColor||"#fff",style:{opacity:Kr?1:0}})]}),M.jsxs(ype,{$backgroundColor:t.botBackgroundColor||"#fff",$mobileDisplayMode:t.mobileDisplayMode,children:[Re&&((tt=(Se=t.pluginConfig)==null?void 0:Se.collectedUserInfo)==null?void 0:tt.discount)&&M.jsx(wk,{discount:t.pluginConfig.collectedUserInfo.discount,uiData:t,onClose:()=>{rt(!1),window.DebalesChat.track(an.DISCOUNT_VIEWED,{discount:t.pluginConfig.collectedUserInfo.discount})}}),M.jsx(Rk,{uidata:t,product:hi,showModel:us,setShowModel:Wr,onVariantSelect:Y=>{I(Y.id,1),be(!0),window.DebalesChat.track(an.ADD_TO_CART_CLICKED,{product:Y.title,price:Number(Y.price),link:`https://${t.shopifyShopDomain}/variants/${Y.id}`,message:l,chatId:rr()+e})}}),qo&&M.jsx(Ck,{setShowExitModal:Mt,handleCloseChatbot:Ro,chatId:rr()+e}),M.jsxs(mpe,{id:"debales-conversation-group",$botBackgroundColor:t.botBackgroundColor||"#fff",ref:ge,$mobileDisplayMode:t.mobileDisplayMode,children:[M.jsx(Mpe,{$backgroundColor:t.botBackgroundColor||"#fff",style:{opacity:Kr?1:0}}),M.jsxs(vpe,{children:[_r&&h.map((Y,ce)=>{const ve=Y.isBot,Oe=$p(Y.text);return Y.hideConfirmation?null:M.jsxs(Z.Fragment,{children:[ve&&M.jsxs(zP,{$fontColor:t.botFontColor||"#000",$botMessageColor:t.botBackgroundColor||"#fff","data-testid":"debales-ai-message-container",children:[M.jsx("img",{src:ve?t.bot_logo:t.userMessage_logo,alt:"Chat User Icon",style:{marginLeft:"8px"}}),M.jsxs(jP,{children:[Oe.slice(0,dn[ce]||0).map((we,Xe)=>M.jsx("div",{children:M.jsx(Mi,{isBot:ve,children:M.jsx(bd,{remarkPlugins:[Tw,bE],children:we})})},Xe)),Y.collections&&l===Y.conversationId&&V.collections&&M.jsx(Sk,{message:Y,botId:e,uidata:t,onSendMessage:r,loading:p}),Y.products&&l===Y.conversationId&&V.products&&M.jsx(Ak,{message:Y,botId:e,uidata:t,onSendMessage:r,loading:p,storeMetaData:n,platform:G,setShowVariantModel:Wr,setSelectedProduct:Br,setCartVersion:se}),o&&M.jsx(y8,{children:M.jsx(Ix,{onClick:()=>{window._klOnsite&&(window._klOnsite.push(["openForm",ht]),pt(!1,"klaviyo_grab_deal_button"))},children:"🚀 Grab Deal Now!"})}),O&&O.itemCount>0&&l===Y.conversationId&&V.cartSummary&&Et&&M.jsx(yk,{onCheckout:Go,onKeepShopping:()=>{be(!1)}}),Me&&Me.length>0&&l===Y.conversationId&&V.bulkItems&&M.jsx(fk,{onClick:()=>Oo(Y.conversationId),children:"Add Bulk Items to Cart"}),T&&h.indexOf(Y)===h.length-1&&M.jsx(M.Fragment,{children:M.jsx(kk,{setShowModel:we=>{var zt,hn;const Xe=typeof we=="function"?we(T):we;A(Xe),!Xe&&((hn=(zt=t.pluginConfig)==null?void 0:zt.collectedUserInfo)!=null&&hn.discount)&&rt(!0)},inChat:!0,showFormInstructions:!1})}),ft&&h.indexOf(Y)===h.length-1&&M.jsxs(Tpe,{onSubmit:je,noValidate:!0,"data-testid":"debales-support-form",children:[He(e)?M.jsxs(M.Fragment,{children:[M.jsx(eu,{label:"Name",name:"name",type:"text",value:Ot.name,onChange:we=>rn(Xe=>({...Xe,name:we.target.value})),required:!0,error:_t.name,isCollectiveBot:!0}),M.jsx(eu,{label:"Email",name:"email",type:"email",value:Ot.email,onChange:we=>rn(Xe=>({...Xe,email:we.target.value})),required:!0,error:_t.email,isCollectiveBot:!0}),M.jsx(Ek,{label:"Message",name:"message",value:Ot.message,onChange:we=>rn(Xe=>({...Xe,message:we.target.value})),required:!0,error:_t.message,rows:4,isCollectiveBot:!0})]}):M.jsxs(M.Fragment,{children:[M.jsxs(x8,{children:[M.jsxs(b8,{children:["Name",M.jsx("span",{children:"*"})]}),M.jsx(HP,{type:"text",required:!0,value:Ot.name,onChange:we=>rn(Xe=>({...Xe,name:we.target.value})),placeholder:"John"}),_t.name&&M.jsx("p",{style:{color:"red",fontSize:"12px",margin:"4px 0 0"},children:_t.name})]}),M.jsxs(x8,{children:[M.jsxs(b8,{children:["Email",M.jsx("span",{children:"*"})]}),M.jsx(HP,{type:"email",required:!0,value:Ot.email,onChange:we=>rn(Xe=>({...Xe,email:we.target.value})),placeholder:"olivia@untitledui.com"}),_t.email&&M.jsx("p",{style:{color:"red",fontSize:"12px",margin:"4px 0 0"},children:_t.email})]}),M.jsxs(x8,{children:[M.jsxs(b8,{children:["Message",M.jsx("span",{children:"*"})]}),M.jsx(Rpe,{required:!0,value:Ot.message,onChange:we=>rn(Xe=>({...Xe,message:we.target.value})),placeholder:"I need help with..."}),_t.message&&M.jsx("p",{style:{color:"red",fontSize:"12px",margin:"4px 0 0"},children:_t.message})]})]}),M.jsx(Dpe,{children:M.jsx(Ope,{type:"submit",children:"Submit"})})]}),St&&!p&&l===Y.conversationId&&M.jsx(Mi,{isBot:ve,children:M.jsx(Os,{loading:St})})]})]}),!ve&&M.jsx(Spe,{$fontColor:t.userFontColor||"#000",$botMessageColor:t.botBackgroundColor||"#fff",children:M.jsx(Mi,{isBot:!!ve,children:M.jsx(bd,{children:Y.text})})}),h.length==1&&ce==0&&!T&&M.jsx(y8,{children:at.leadingQueries?M.jsx(Mi,{isBot:!0,children:M.jsx(Os,{loading:at.leadingQueries})}):j.map((we,Xe)=>M.jsxs(UP,{style:{backgroundColor:t.callToActionBackgroundColor,color:t.callToActionFontColor,opacity:Be.has(we.question)?.5:1},onClick:()=>{E?(A(!0),R({question:we.question,answer:we.answer,products:we.products,path:"/",nameSpace:window.DebalesChat.projectId})):r({message:we.question,answer:we.answer,products:we.products,leading_queries:we.leading_queries,followUpQuestion:we.Follow_up_Question,messType:"leading_query"}),Ue(zt=>{const hn=new Set(zt);return hn.add(we.question),hn}),window.DebalesChat.track(an.INITIAL_LEADING_QUERY_SUGGESTED_QUESTION_CLICKED,{question:we.question})},disabled:p,$disabled:p,children:[we.question,M.jsx(FP,{color:t.callToActionFontColor})]},Xe))}),Y.leading_queries&&Y.leading_queries.length>0&&l===Y.conversationId&&V.leadingQueries&&!o&&!T&&M.jsx(y8,{children:Y.leading_queries.map((we,Xe)=>M.jsxs(UP,{style:{backgroundColor:t.callToActionBackgroundColor,color:t.callToActionFontColor},onClick:()=>{E?(A(!0),R({question:we,path:"/",nameSpace:window.DebalesChat.projectId})):r({message:we,messType:"leading_query"}),window.DebalesChat.track(an.LEADING_QUERY_CLICKED,{query:we})},disabled:p,$disabled:p,children:[we,M.jsx(FP,{color:t.callToActionFontColor})]},Xe))})]},ce)}),(p||Gt)&&M.jsxs(zP,{$fontColor:t.botFontColor||"#000",$botMessageColor:t.botBackgroundColor||"#fff",children:[M.jsx("img",{src:t.bot_logo,alt:"Chat User Icon"}),M.jsx(jP,{children:M.jsx(Mi,{isBot:!0,children:M.jsx("div",{style:{display:"flex",alignItems:"center",gap:"4px",animation:"fadeIn 0.3s ease-in-out"},children:M.jsx(Os,{loading:p||Gt})})})})]})]}),M.jsx(Ipe,{$backgroundColor:t.botBackgroundColor||"#fff",style:{opacity:Dn?1:0}})]}),M.jsxs("div",{className:"debales-footer-container",style:{width:"100%",backgroundColor:t.botBackgroundColor||"#fff",color:t.fontColor||"#000"},children:[e==="catch-org-ai"&&M.jsx(_pe,{children:M.jsx("span",{children:'"Catch org AI" can make mistakes.'})}),M.jsx("div",{children:M.jsx(Ok,{disabled:p,inputState:!1})}),(t.debales_branding??!0)&&M.jsxs(xpe,{href:"https://debales.ai/?open=true",target:"_blank",title:"debales-link",style:{color:t.fontColor?t.fontColor:"fff",marginTop:e==="catch-org-ai"?"0":"9px"},children:[M.jsx("p",{children:"Powered by"}),M.jsxs(bpe,{children:[M.jsx("img",{src:`${Di}/images/debales_logo_d.png`,alt:"Debales logo"}),M.jsx("p",{children:"DEBALES"})]})]})]})]})]})}),z.shadowRoot)]})},Lpe=ae.p`
3682
+ => User Action: Klaviyo form closed`}return""},ve=Oe=>{Oe instanceof CustomEvent&&Y(Oe)};return window.addEventListener("klaviyoForms",ve),()=>{window.removeEventListener("klaviyoForms",ve)}},[Ut,t,r]),Z.useEffect(()=>{const Y=ge.current;return Te&&Y?(Y.addEventListener("scroll",or),()=>{Y&&Y.removeEventListener("scroll",or)}):()=>{}},[Te,or]);const[Re,rt]=Z.useState(!1),vt=Q==="Highest"?"120px":Q==="Higher"?"60px":"15px",Vt=async()=>{try{const Y=await fetch(`${Di}/api/wordpress/support`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({chatid:rr()+e,nameSpace:e,userName:Ot.name,userEmail:Ot.email,userMessage:Ot.message,tag:"support"})});if(Y.ok){const ce=`support-confirm-${Date.now()}`;m(ve=>[...ve,{text:"Thanks for reaching out! Our support team has received your request and will get back to you within 24 hours.<br>In the meantime, feel free to continue chatting with me - I'll do my best to help!",isBot:!0,leading_queries:Jt,conversationId:ce}]),d(ce),ye(ve=>({...ve,leadingQueries:!0})),mn([]),console.log("Connected to support with existing user info:",Po())}else{const ce=await Y.json();console.error("Failed to connect to support:",ce),m(ve=>[...ve,{text:"Sorry, we couldn't connect you to support at the moment.<br>Please try again later.",isBot:!0}])}}catch{m(ce=>[...ce,{text:"Sorry, we couldn't connect you to support at the moment.<br>Please try again later.",isBot:!0}])}},lt=()=>{const Y=Po();let ce=[];const ve=h[h.length-1];ve!=null&&ve.leading_queries&&ve.leading_queries.length>0?ce=ve.leading_queries:h.length<=1&&(ce=j.flatMap(Oe=>Array.isArray(Oe)?Oe.map(we=>we.question):[Oe.question]).slice(0,4)),mn(ce),Y&&Y.name&&Y.email&&rn({name:Y==null?void 0:Y.name,email:Y==null?void 0:Y.email,message:""}),m(Oe=>[...Oe,{text:"Please provide your name, email and message to connect with support.",isBot:!0}]),Lt(!0)},je=async Y=>{Y.preventDefault();const ce={name:"",email:"",message:""};let ve=!0;const Oe=Ot.name.trim(),we=Ot.message.trim();Oe||(ce.name="Name cannot be empty or just whitespace.",ve=!1),(!Ot.email||!Pm.isEmail(Ot.email))&&(ce.email="Please enter a valid email address.",ve=!1),we||(ce.message="Message cannot be empty or just whitespace.",ve=!1),Xt(ce),ve&&(of({name:Oe,email:Ot.email}),Lt(!1),m(Xe=>Xe.slice(0,-1)),await Vt())},[dn,dr]=Z.useState({});return Z.useEffect(()=>{_r&&(h.forEach((Y,ce)=>{if(!Y.isBot)return;const ve=$p(Y.text);if(!(ce in dn)||dn[ce]<ve.length){let Oe;const we=Xe=>{Xe<ve.length&&(Oe=setTimeout(()=>{dr(zt=>({...zt,[ce]:Xe+1})),we(Xe+1)},po))};return ce in dn?we(dn[ce]):(dr(Xe=>({...Xe,[ce]:1})),we(1)),()=>clearTimeout(Oe)}}),dr(Y=>{const ce={};return h.forEach((ve,Oe)=>{Y[Oe]!==void 0&&(ce[Oe]=Y[Oe])}),ce}))},[h,_r]),!t||t.show_bot===!1||a?null:M.jsxs(Zw,{theme:uE(t,e),children:[M.jsx("link",{rel:"preconnect",href:"https://fonts.googleapis.com"}),M.jsx("link",{rel:"preconnect",href:"https://fonts.gstatic.com",crossOrigin:"anonymous"}),M.jsx("link",{href:"https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap",rel:"stylesheet"}),M.jsx("link",{href:"https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,100;0,300;0,400;0,700;0,900;1,100;1,300;1,400;1,700;1,900&display=swap",rel:"stylesheet"}),M.jsx(Ape,{}),M.jsxs(ipe,{$topOffset:vt,$isLeft:W,children:[!Te&&j.length>0&&j[U]&&ne&&M.jsx(Cpe,{className:Ce?"visible":"",$botId:e,$iconSize:H,$removeLogoBackground:t.removeLogoBackground,topOffset:vt,style:{display:"flex",flexDirection:W?"row":"row-reverse",alignItems:"center",marginLeft:ot?"60px":"85px",marginRight:ot?"60px":"85px",left:W?"24px":"auto",right:W?"auto":"24px",opacity:Ce?1:0,transition:"opacity 0.3s ease-in-out"},children:j.length>0&&j[U]&&(()=>{const Y=j[U];return M.jsx(Epe,{children:M.jsx(tpe,{messages:[{question:Y.question,isHighlighted:Y.isHighlighted??!1,show_for:(ee==null?void 0:ee.show_for)||4e3,hide_timing:(ee==null?void 0:ee.hide_timing)||4e3}],botId:e,uiData:t,onClose:()=>{Ue(ce=>{const ve=new Set(ce);return ve.add(Y.question),ve})},onClick:()=>{const ce=Y;pt(!0,"suggested_question_clicked"),Ue(ve=>{const Oe=new Set(ve);return Oe.add(ce.question),Oe}),window.DebalesChat.track(an.SUGGESTED_QUESTION_CLICKED,{suggested_question:ce}),E?(fn(!1),ir(!0),A(!0),R(ce)):(fn(!1),ir(!0),r({message:ce.Follow_up_Question??ce.question,answer:ce.answer,products:ce.products,fromKlaviyo:!1,leading_queries:ce.leading_queries,followUpQuestion:ce.Follow_up_Question,messType:"suggested_question"}))}})},Y.question)})()}),M.jsxs(ope,{$topOffset:vt,$removeLogoBackground:t.removeLogoBackground,$isLeft:W,style:{display:Te?"none":"inline-flex"},children:[M.jsx(ape,{$showAnimation:t.enableChatButtonBackgroundAnimation??!1,$animationType:"Ping",$animationColor:t.chatButtonBackgroundAnimationColor||"#f48722",$backgroundColor:t.backgroundColor||"#fff",$removeLogoBackground:t.removeLogoBackground,$topOffset:vt,$iconSize:H}),M.jsxs(spe,{$backgroundColor:t.removeLogoBackground?"transparent":t.backgroundColor||"#fff",$botId:e,$isLeft:W,$iconSize:H,$removeLogoBackground:t.removeLogoBackground,topOffset:vt,$showAnimation:t.enableChatButtonBackgroundAnimation,$animationType:"Ping",$animationColor:t.chatButtonBackgroundAnimationColor||"#f48722",id:"debales-chat-button","data-testid":"debales-chat-button",onClick:()=>{if(window.DebalesChat.track(an.CHAT_BUTTON_CLICKED),pt(!Te,"chat_button_clicked"),!Te){const Y=_();Y.length>0?(m(Y),fn(!1),ir(!0)):(fn(!0),ir(!1),setTimeout(()=>{fn(!1),ir(!0);const ce={text:(t==null?void 0:t.initialMessage)||"Hi, I am an AI chatbot, how can I help you today?",isBot:!0};m([ce])},(ee==null?void 0:ee.showing_delay)||2e3))}},"aria-label":"Chat",style:{display:Te?"none":"inline-flex"},children:[M.jsx(lpe,{$botId:e,$removeLogoBackground:t.removeLogoBackground,"aria-hidden":"true",src:t.bot_logo,alt:"Chat Bot Icon"}),(j==null?void 0:j.length)>0&&!Te&&fe&&M.jsx("div",{style:{position:"absolute",top:"-5px",right:"-5px",backgroundColor:"#f44336",color:"white",borderRadius:"50%",width:"20px",height:"20px",display:"flex",justifyContent:"center",alignItems:"center",fontSize:"12px",fontWeight:"bold",zIndex:2,opacity:fe?1:0,transition:"opacity 0.3s ease-in-out"},children:j.length})]})]})]}),Te&&hw.createPortal(M.jsx(M.Fragment,{children:M.jsxs(dpe,{$backgroundColor:t.backgroundColor||"#fff",$fullScreenOnMobile:t.fullScreenOnMobile,$headerFontColor:t.headerFontColor||"#1C1C1C",$isLeft:W,$topOffset:vt,$mobileDisplayMode:t.mobileDisplayMode,$isVisible:st,"data-testid":"debales-chat-container",children:[M.jsxs(gpe,{$backgroundColor:He(e)?t.backgroundColor:t.botBackgroundColor||"#fff",style:{color:t.headerFontColor},children:[M.jsx("div",{style:{flexGrow:.1,display:"flex",justifyContent:"center",alignItems:"center",overflow:"hidden",marginRight:"8px",gap:"10px"},children:He(e)?M.jsxs(M.Fragment,{children:[M.jsx(LP,{"aria-hidden":"true",src:t.bot_logo,alt:"Chat Bot Icon"}),M.jsxs(upe,{$botNameColor:t.headerFontColor,children:[M.jsxs("div",{style:{fontWeight:"700",wordBreak:"break-word"},children:[t.chatbotName,e==="catch-org-ai"&&M.jsx(fpe,{$backgroundColor:t.callToActionBackgroundColor,$fontColor:t.callToActionFontColor,children:"Beta"})]}),M.jsx(cpe,{})]})]}):M.jsx(hpe,{children:M.jsxs(ppe,{children:[M.jsx(LP,{src:t.bot_logo,alt:"Chat Bot Icon"}),M.jsx("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",display:"inline-block",maxWidth:"22ch"},children:t.chatbotName})]})})}),M.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginLeft:"auto",flexShrink:0},children:[M.jsxs(kpe,{children:[M.jsx(NP,{$iconBG:t.backgroundColor,onClick:lt,"aria-label":"Support","data-testid":"debales-support-button",children:M.jsx(pk,{color:t.headerFontColor})}),M.jsx(PP,{children:"Click to chat with a Live Support Agent now."})]}),M.jsx(NP,{$iconBG:t.backgroundColor,onClick:()=>{Ct?Mt(!0):pt(!1,"close_button_clicked")},id:"debales-minimize-button","data-testid":"debales-minimize-button","aria-label":"Minimize",children:M.jsx(Hm,{botNameColor:t.headerFontColor})})]}),M.jsx($pe,{$backgroundColor:t.botBackgroundColor||"#fff",style:{opacity:Kr?1:0}})]}),M.jsxs(ype,{$backgroundColor:t.botBackgroundColor||"#fff",$mobileDisplayMode:t.mobileDisplayMode,children:[Re&&((tt=(Se=t.pluginConfig)==null?void 0:Se.collectedUserInfo)==null?void 0:tt.discount)&&M.jsx(wk,{discount:t.pluginConfig.collectedUserInfo.discount,uiData:t,onClose:()=>{rt(!1),window.DebalesChat.track(an.DISCOUNT_VIEWED,{discount:t.pluginConfig.collectedUserInfo.discount})}}),M.jsx(Rk,{uidata:t,product:hi,showModel:us,setShowModel:Wr,onVariantSelect:Y=>{I(Y.id,1),be(!0),window.DebalesChat.track(an.ADD_TO_CART_CLICKED,{product:Y.title,price:Number(Y.price),link:`https://${t.shopifyShopDomain}/variants/${Y.id}`,message:l,chatId:rr()+e})}}),qo&&M.jsx(Ck,{setShowExitModal:Mt,handleCloseChatbot:Ro,chatId:rr()+e}),M.jsxs(mpe,{id:"debales-conversation-group",$botBackgroundColor:t.botBackgroundColor||"#fff",ref:ge,$mobileDisplayMode:t.mobileDisplayMode,children:[M.jsx(Mpe,{$backgroundColor:t.botBackgroundColor||"#fff",style:{opacity:Kr?1:0}}),M.jsxs(vpe,{children:[_r&&h.map((Y,ce)=>{const ve=Y.isBot,Oe=$p(Y.text);return Y.hideConfirmation?null:M.jsxs(Z.Fragment,{children:[ve&&M.jsxs(zP,{$fontColor:t.botFontColor||"#000",$botMessageColor:t.botBackgroundColor||"#fff","data-testid":"debales-ai-message-container",children:[M.jsx("img",{src:ve?t.bot_logo:t.userMessage_logo,alt:"Chat User Icon",style:{marginLeft:"8px"}}),M.jsxs(jP,{children:[Oe.slice(0,dn[ce]||0).map((we,Xe)=>M.jsx("div",{children:M.jsx(Mi,{isBot:ve,children:M.jsx(bd,{remarkPlugins:[Tw,bE],children:we})})},Xe)),Y.collections&&l===Y.conversationId&&V.collections&&M.jsx(Sk,{message:Y,botId:e,uidata:t,onSendMessage:r,loading:p}),Y.products&&l===Y.conversationId&&V.products&&M.jsx(Ak,{message:Y,botId:e,uidata:t,onSendMessage:r,loading:p,storeMetaData:n,platform:G,setShowVariantModel:Wr,setSelectedProduct:Br,setCartVersion:se}),o&&M.jsx(y8,{children:M.jsx(Ix,{onClick:()=>{window._klOnsite&&(window._klOnsite.push(["openForm",ht]),pt(!1,"klaviyo_grab_deal_button"))},children:"🚀 Grab Deal Now!"})}),O&&O.itemCount>0&&l===Y.conversationId&&V.cartSummary&&Et&&M.jsx(yk,{onCheckout:Go,onKeepShopping:()=>{be(!1)}}),Me&&Me.length>0&&l===Y.conversationId&&V.bulkItems&&M.jsx(fk,{onClick:()=>Oo(Y.conversationId),children:"Add Bulk Items to Cart"}),T&&h.indexOf(Y)===h.length-1&&M.jsx(M.Fragment,{children:M.jsx(kk,{setShowModel:we=>{var zt,hn;const Xe=typeof we=="function"?we(T):we;A(Xe),!Xe&&((hn=(zt=t.pluginConfig)==null?void 0:zt.collectedUserInfo)!=null&&hn.discount)&&rt(!0)},inChat:!0,showFormInstructions:!1})}),ft&&h.indexOf(Y)===h.length-1&&M.jsxs(Tpe,{onSubmit:je,noValidate:!0,"data-testid":"debales-support-form",children:[He(e)?M.jsxs(M.Fragment,{children:[M.jsx(eu,{label:"Name",name:"name",type:"text",value:Ot.name,onChange:we=>rn(Xe=>({...Xe,name:we.target.value})),required:!0,error:_t.name,isCollectiveBot:!0}),M.jsx(eu,{label:"Email",name:"email",type:"email",value:Ot.email,onChange:we=>rn(Xe=>({...Xe,email:we.target.value})),required:!0,error:_t.email,isCollectiveBot:!0}),M.jsx(Ek,{label:"Message",name:"message",value:Ot.message,onChange:we=>rn(Xe=>({...Xe,message:we.target.value})),required:!0,error:_t.message,rows:4,isCollectiveBot:!0})]}):M.jsxs(M.Fragment,{children:[M.jsxs(x8,{children:[M.jsxs(b8,{children:["Name",M.jsx("span",{children:"*"})]}),M.jsx(HP,{type:"text",required:!0,value:Ot.name,onChange:we=>rn(Xe=>({...Xe,name:we.target.value})),placeholder:"John"}),_t.name&&M.jsx("p",{style:{color:"red",fontSize:"12px",margin:"4px 0 0"},children:_t.name})]}),M.jsxs(x8,{children:[M.jsxs(b8,{children:["Email",M.jsx("span",{children:"*"})]}),M.jsx(HP,{type:"email",required:!0,value:Ot.email,onChange:we=>rn(Xe=>({...Xe,email:we.target.value})),placeholder:"olivia@untitledui.com"}),_t.email&&M.jsx("p",{style:{color:"red",fontSize:"12px",margin:"4px 0 0"},children:_t.email})]}),M.jsxs(x8,{children:[M.jsxs(b8,{children:["Message",M.jsx("span",{children:"*"})]}),M.jsx(Rpe,{required:!0,value:Ot.message,onChange:we=>rn(Xe=>({...Xe,message:we.target.value})),placeholder:"I need help with..."}),_t.message&&M.jsx("p",{style:{color:"red",fontSize:"12px",margin:"4px 0 0"},children:_t.message})]})]}),M.jsx(Dpe,{children:M.jsx(Ope,{type:"submit",children:"Submit"})})]}),St&&!p&&l===Y.conversationId&&M.jsx(Mi,{isBot:ve,children:M.jsx(Os,{loading:St})})]})]}),!ve&&M.jsx(Spe,{$fontColor:t.userFontColor||"#000",$botMessageColor:t.botBackgroundColor||"#fff",children:M.jsx(Mi,{isBot:!!ve,children:M.jsx(bd,{children:Y.text})})}),h.length==1&&ce==0&&!T&&M.jsx(y8,{children:at.leadingQueries?M.jsx(Mi,{isBot:!0,children:M.jsx(Os,{loading:at.leadingQueries})}):j.map((we,Xe)=>M.jsxs(UP,{style:{backgroundColor:t.callToActionBackgroundColor,color:t.callToActionFontColor,opacity:Be.has(we.question)?.5:1},onClick:()=>{E?(A(!0),R({question:we.question,answer:we.answer,products:we.products,path:"/",nameSpace:window.DebalesChat.projectId})):r({message:we.question,answer:we.answer,products:we.products,leading_queries:we.leading_queries,followUpQuestion:we.Follow_up_Question,messType:"leading_query"}),Ue(zt=>{const hn=new Set(zt);return hn.add(we.question),hn}),window.DebalesChat.track(an.INITIAL_LEADING_QUERY_SUGGESTED_QUESTION_CLICKED,{question:we.question})},disabled:p,$disabled:p,children:[we.question,M.jsx(FP,{color:t.callToActionFontColor})]},Xe))}),Y.leading_queries&&Y.leading_queries.length>0&&l===Y.conversationId&&V.leadingQueries&&!o&&!T&&M.jsx(y8,{children:Y.leading_queries.map((we,Xe)=>M.jsxs(UP,{style:{backgroundColor:t.callToActionBackgroundColor,color:t.callToActionFontColor},onClick:()=>{E?(A(!0),R({question:we,path:"/",nameSpace:window.DebalesChat.projectId})):r({message:we,messType:"leading_query"}),window.DebalesChat.track(an.LEADING_QUERY_CLICKED,{query:we})},disabled:p,$disabled:p,children:[we,M.jsx(FP,{color:t.callToActionFontColor})]},Xe))})]},ce)}),(p||Gt)&&M.jsxs(zP,{$fontColor:t.botFontColor||"#000",$botMessageColor:t.botBackgroundColor||"#fff",children:[M.jsx("img",{src:t.bot_logo,alt:"Chat User Icon"}),M.jsx(jP,{children:M.jsx(Mi,{isBot:!0,children:M.jsx("div",{style:{display:"flex",alignItems:"center",gap:"4px",animation:"fadeIn 0.3s ease-in-out"},children:M.jsx(Os,{loading:p||Gt})})})})]})]}),M.jsx(Ipe,{$backgroundColor:t.botBackgroundColor||"#fff",style:{opacity:Dn?1:0}})]}),M.jsxs("div",{className:"debales-footer-container",style:{width:"100%",backgroundColor:t.botBackgroundColor||"#fff",color:t.fontColor||"#000"},children:[(e==="catch-org-ai"||e==="letsgo-catch")&&M.jsx(_pe,{children:M.jsx("span",{children:`"${t.chatbotName}" can make mistakes.`})}),M.jsx("div",{children:M.jsx(Ok,{disabled:p,inputState:!1})}),(t.debales_branding??!0)&&M.jsxs(xpe,{href:"https://debales.ai/?open=true",target:"_blank",title:"debales-link",style:{color:t.fontColor?t.fontColor:"fff",marginTop:e==="catch-org-ai"?"0":"9px"},children:[M.jsx("p",{children:"Powered by"}),M.jsxs(bpe,{children:[M.jsx("img",{src:`${Di}/images/debales_logo_d.png`,alt:"Debales logo"}),M.jsx("p",{children:"DEBALES"})]})]})]})]})]})}),z.shadowRoot)]})},Lpe=ae.p`
3683
3683
  margin: 0;
3684
3684
  font-size: 16px;
3685
3685
  min-height: 24px;
@@ -4432,7 +4432,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
4432
4432
 
4433
4433
  `+Xe+`
4434
4434
 
4435
- => User Action: Klaviyo form closed`}return""},ve=Oe=>{Oe instanceof CustomEvent&&Y(Oe)};return window.addEventListener("klaviyoForms",ve),()=>{window.removeEventListener("klaviyoForms",ve)}},[ht,t,r]),Z.useEffect(()=>{const Y=Be.current;return Te&&Y?(Y.addEventListener("scroll",or),()=>{Y&&Y.removeEventListener("scroll",or)}):()=>{}},[Te,or]);const[Re,rt]=Z.useState(!1),vt=Q==="Highest"?"120px":Q==="Higher"?"60px":"15px",Vt=async()=>{try{const Y=await fetch(`${Di}/api/wordpress/support`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({chatid:rr()+e,nameSpace:e,userName:Ot.name,userEmail:Ot.email,userMessage:Ot.message,tag:"support"})});if(Y.ok){const ce=`support-confirm-${Date.now()}`;m(ve=>[...ve,{text:"Thanks for reaching out! Our support team has received your request and will get back to you within 24 hours.<br>In the meantime, feel free to continue chatting with me - I'll do my best to help!",isBot:!0,leading_queries:Jt,conversationId:ce}]),d(ce),ye(ve=>({...ve,leadingQueries:!0})),mn([]),console.log("Connected to support with existing user info:",Po())}else{const ce=await Y.json();console.error("Failed to connect to support:",ce),m(ve=>[...ve,{text:"Sorry, we couldn't connect you to support at the moment.<br>Please try again later.",isBot:!0}])}}catch{m(ce=>[...ce,{text:"Sorry, we couldn't connect you to support at the moment.<br>Please try again later.",isBot:!0}])}},lt=()=>{const Y=Po();let ce=[];const ve=h[h.length-1];ve!=null&&ve.leading_queries&&ve.leading_queries.length>0?ce=ve.leading_queries:h.length<=1&&(ce=j.flatMap(Oe=>Array.isArray(Oe)?Oe.map(we=>we.question):[Oe.question]).slice(0,4)),mn(ce),Y&&Y.name&&Y.email&&rn({name:Y==null?void 0:Y.name,email:Y==null?void 0:Y.email,message:""}),m(Oe=>[...Oe,{text:"Please provide your name, email and message to connect with support.",isBot:!0}]),Lt(!0)},je=async Y=>{Y.preventDefault();const ce={name:"",email:"",message:""};let ve=!0;const Oe=Ot.name.trim(),we=Ot.message.trim();Oe||(ce.name="Name cannot be empty or just whitespace.",ve=!1),(!Ot.email||!Pm.isEmail(Ot.email))&&(ce.email="Please enter a valid email address.",ve=!1),we||(ce.message="Message cannot be empty or just whitespace.",ve=!1),Xt(ce),ve&&(of({name:Oe,email:Ot.email}),Lt(!1),m(Xe=>Xe.slice(0,-1)),await Vt())},[dn,dr]=Z.useState({});return Z.useEffect(()=>{_r&&(h.forEach((Y,ce)=>{if(!Y.isBot)return;const ve=$p(Y.text);if(!(ce in dn)||dn[ce]<ve.length){let Oe;const we=Xe=>{Xe<ve.length&&(Oe=setTimeout(()=>{dr(zt=>({...zt,[ce]:Xe+1})),we(Xe+1)},po))};return ce in dn?we(dn[ce]):(dr(Xe=>({...Xe,[ce]:1})),we(1)),()=>clearTimeout(Oe)}}),dr(Y=>{const ce={};return h.forEach((ve,Oe)=>{Y[Oe]!==void 0&&(ce[Oe]=Y[Oe])}),ce}))},[h,_r]),!t||t.show_bot===!1||a?null:M.jsxs(Zw,{theme:uE(t,e),children:[M.jsx("link",{rel:"preconnect",href:"https://fonts.googleapis.com"}),M.jsx("link",{rel:"preconnect",href:"https://fonts.gstatic.com",crossOrigin:"anonymous"}),M.jsx("link",{href:"https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap",rel:"stylesheet"}),M.jsx("link",{href:"https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,100;0,300;0,400;0,700;0,900;1,100;1,300;1,400;1,700;1,900&display=swap",rel:"stylesheet"}),M.jsx(u0e,{}),M.jsx(jpe,{$topOffset:vt,$isLeft:W,children:M.jsxs(a0e,{$isLeft:W,$removeLogoBackground:t.removeLogoBackground,children:[!Te&&j.length>0&&j[U]&&ne&&M.jsx(s0e,{className:Ce?"visible":"",$botId:e,$iconSize:H,$removeLogoBackground:t.removeLogoBackground,topOffset:vt,$isLeft:W,style:{display:"flex",flexDirection:W?"row":"row-reverse",alignItems:"center",marginRight:W?"0px":Ut?"10px":"5px",marginTop:Ut?"0px":"10px",left:W?"24px":"auto",right:W?"auto":"24px",opacity:Ce?1:0,transition:"opacity 0.3s ease-in-out"},children:j.length>0&&j[U]&&(()=>{const Y=j[U];return M.jsx(l0e,{children:M.jsx(zpe,{messages:[{question:Y.question,isHighlighted:Y.isHighlighted??!1,show_for:(ee==null?void 0:ee.show_for)||4e3,hide_timing:(ee==null?void 0:ee.hide_timing)||4e3}],botId:e,uiData:t,isLeft:W,onClose:()=>{Et(ce=>{const ve=new Set(ce);return ve.add(Y.question),ve})},onClick:()=>{const ce=Y;be(!0,"suggested_question_clicked"),Et(ve=>{const Oe=new Set(ve);return Oe.add(ce.question),Oe}),window.DebalesChat.track(an.SUGGESTED_QUESTION_CLICKED,{suggested_question:ce}),E?(fn(!1),ir(!0),A(!0),R(ce)):(fn(!1),ir(!0),r({message:ce.Follow_up_Question??ce.question,answer:ce.answer,products:ce.products,fromKlaviyo:!1,leading_queries:ce.leading_queries,messType:"suggested_question"}))}})},Y.question)})()}),M.jsx(Ppe,{$topOffset:vt,$removeLogoBackground:t.removeLogoBackground,style:{display:Te?"none":"inline-flex"},children:M.jsxs(Hpe,{$backgroundColor:t.removeLogoBackground?"transparent":t.backgroundColor||"#fff",$botId:e,$iconSize:H,$removeLogoBackground:t.removeLogoBackground,topOffset:vt,$showAnimation:t.enableChatButtonBackgroundAnimation,$animationType:"Ping",$animationColor:t.chatButtonBackgroundAnimationColor||"#f48722",id:"debales-chat-button","data-testid":"debales-chat-button",onClick:()=>{if(window.DebalesChat.track(an.CHAT_BUTTON_CLICKED),be(!Te,"chat_button_clicked"),!Te){const Y=_();Y.length>0?(m(Y),fn(!1),ir(!0)):(fn(!0),ir(!1),setTimeout(()=>{fn(!1),ir(!0);const ce={text:(t==null?void 0:t.initialMessage)||"Hi, I am an AI chatbot, how can I help you today?",isBot:!0};m([ce])},(ee==null?void 0:ee.showing_delay)||2e3))}},"aria-label":"Chat",style:{display:Te?"none":"inline-flex"},children:[M.jsx(qpe,{$botId:e,$removeLogoBackground:t.removeLogoBackground,"aria-hidden":"true",src:t.bot_logo,alt:"Chat Bot Icon"}),(j==null?void 0:j.length)>0&&!Te&&fe&&!ne&&M.jsx("div",{style:{position:"absolute",top:"-5px",right:"-5px",backgroundColor:"#f44336",color:"white",borderRadius:"50%",width:"20px",height:"20px",display:"flex",justifyContent:"center",alignItems:"center",fontSize:"12px",fontWeight:"bold",zIndex:2,opacity:fe?1:0,transition:"opacity 0.3s ease-in-out"},children:j.length})]})})]})}),Te&&hw.createPortal(M.jsx(M.Fragment,{children:M.jsxs(Zpe,{$backgroundColor:t.backgroundColor||"#fff",$fullScreenOnMobile:t.fullScreenOnMobile,$headerFontColor:t.headerFontColor||"#1C1C1C",$isLeft:W,$topOffset:vt,$mobileDisplayMode:t.mobileDisplayMode,$isVisible:st,"data-testid":"debales-chat-container",children:[M.jsxs(Wpe,{$backgroundColor:He(e)?t.backgroundColor:t.botBackgroundColor||"#fff",style:{color:t.headerFontColor},children:[M.jsx("div",{style:{flexGrow:.1,display:"flex",justifyContent:"center",alignItems:"center",overflow:"hidden",marginRight:"8px",gap:"10px"},children:He(e)?M.jsxs(M.Fragment,{children:[M.jsx(qP,{"aria-hidden":"true",src:t.bot_logo,alt:"Chat Bot Icon"}),M.jsxs(Gpe,{$botNameColor:t.headerFontColor,children:[M.jsxs("div",{style:{fontWeight:"700",wordBreak:"break-word"},children:[t.chatbotName,e==="catch-org-ai"&&M.jsx(Ype,{$backgroundColor:t.callToActionBackgroundColor,$fontColor:t.callToActionFontColor,children:"Beta"})]}),M.jsx(Vpe,{})]})]}):M.jsx(Qpe,{children:M.jsxs(Kpe,{children:[M.jsx(qP,{src:t.bot_logo,alt:"Chat Bot Icon"}),M.jsx("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",display:"inline-block",maxWidth:"22ch"},children:t.chatbotName})]})})}),M.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginLeft:"auto",flexShrink:0},children:[M.jsxs(c0e,{children:[M.jsx(GP,{$iconBG:t.backgroundColor,onClick:lt,"aria-label":"Support","data-testid":"debales-support-button",children:M.jsx(pk,{color:t.headerFontColor})}),M.jsx(KP,{children:"Click to chat with a Live Support Agent now."})]}),M.jsx(GP,{$iconBG:t.backgroundColor,onClick:()=>{Ct?Mt(!0):be(!1,"close_button_clicked")},id:"debales-minimize-button","data-testid":"debales-minimize-button","aria-label":"Minimize",children:M.jsx(Hm,{botNameColor:t.headerFontColor})})]}),M.jsx(v0e,{$backgroundColor:t.botBackgroundColor||"#fff",style:{opacity:Kr?1:0}})]}),M.jsxs(e0e,{$backgroundColor:t.botBackgroundColor||"#fff",$mobileDisplayMode:t.mobileDisplayMode,children:[Re&&((tt=(Se=t.pluginConfig)==null?void 0:Se.collectedUserInfo)==null?void 0:tt.discount)&&M.jsx(wk,{discount:t.pluginConfig.collectedUserInfo.discount,uiData:t,onClose:()=>{rt(!1),window.DebalesChat.track(an.DISCOUNT_VIEWED,{discount:t.pluginConfig.collectedUserInfo.discount})}}),M.jsx(Rk,{uidata:t,product:hi,showModel:us,setShowModel:Wr,onVariantSelect:Y=>{I(Y.id,1),ct(!0),window.DebalesChat.track(an.ADD_TO_CART_CLICKED,{product:Y.title,price:Number(Y.price),link:`https://${t.shopifyShopDomain}/variants/${Y.id}`,message:l,chatId:rr()+e})}}),qo&&M.jsx(Ck,{setShowExitModal:Mt,handleCloseChatbot:Ro,chatId:rr()+e}),M.jsxs(Xpe,{id:"debales-conversation-group",$botBackgroundColor:t.botBackgroundColor||"#fff",ref:Be,$mobileDisplayMode:t.mobileDisplayMode,children:[M.jsx(g0e,{$backgroundColor:t.botBackgroundColor||"#fff",style:{opacity:Kr?1:0}}),M.jsxs(Jpe,{children:[_r&&h.map((Y,ce)=>{const ve=Y.isBot,Oe=$p(Y.text);return Y.hideConfirmation?null:M.jsxs(Z.Fragment,{children:[ve&&M.jsxs(VP,{$fontColor:t.botFontColor||"#000",$botMessageColor:t.botBackgroundColor||"#fff","data-testid":"debales-ai-message-container",children:[M.jsx("img",{src:ve?t.bot_logo:t.userMessage_logo,alt:"Chat User Icon",style:{marginLeft:"8px"}}),M.jsxs(QP,{children:[Oe.slice(0,dn[ce]||0).map((we,Xe)=>M.jsx("div",{children:M.jsx(Mi,{isBot:ve,children:M.jsx(bd,{remarkPlugins:[Tw,bE],children:we})})},Xe)),Y.collections&&l===Y.conversationId&&V.collections&&M.jsx(Sk,{message:Y,botId:e,uidata:t,onSendMessage:r,loading:p}),Y.products&&l===Y.conversationId&&V.products&&M.jsx(Ak,{message:Y,botId:e,uidata:t,onSendMessage:r,loading:p,storeMetaData:n,platform:G,setShowVariantModel:Wr,setSelectedProduct:Br,setCartVersion:Ae}),o&&M.jsx(S8,{children:M.jsx(Ix,{onClick:()=>{window._klOnsite&&(window._klOnsite.push(["openForm",se]),be(!1,"klaviyo_grab_deal_button"))},children:"🚀 Grab Deal Now!"})}),O&&O.itemCount>0&&l===Y.conversationId&&V.cartSummary&&ot&&M.jsx(yk,{onCheckout:Go,onKeepShopping:()=>{ct(!1)}}),Me&&Me.length>0&&l===Y.conversationId&&V.bulkItems&&M.jsx(fk,{onClick:()=>Oo(Y.conversationId),children:"Add Bulk Items to Cart"}),T&&h.indexOf(Y)===h.length-1&&M.jsx(M.Fragment,{children:M.jsx(kk,{setShowModel:we=>{var zt,hn;const Xe=typeof we=="function"?we(T):we;A(Xe),!Xe&&((hn=(zt=t.pluginConfig)==null?void 0:zt.collectedUserInfo)!=null&&hn.discount)&&rt(!0)},inChat:!0,showFormInstructions:!1})}),ft&&h.indexOf(Y)===h.length-1&&M.jsxs(f0e,{onSubmit:je,noValidate:!0,"data-testid":"debales-support-form",children:[He(e)?M.jsxs(M.Fragment,{children:[M.jsx(eu,{label:"Name",name:"name",type:"text",value:Ot.name,onChange:we=>rn(Xe=>({...Xe,name:we.target.value})),required:!0,error:_t.name,isCollectiveBot:!0}),M.jsx(eu,{label:"Email",name:"email",type:"email",value:Ot.email,onChange:we=>rn(Xe=>({...Xe,email:we.target.value})),required:!0,error:_t.email,isCollectiveBot:!0}),M.jsx(Ek,{label:"Message",name:"message",value:Ot.message,onChange:we=>rn(Xe=>({...Xe,message:we.target.value})),required:!0,error:_t.message,rows:4,isCollectiveBot:!0})]}):M.jsxs(M.Fragment,{children:[M.jsxs(w8,{children:[M.jsxs(C8,{children:["Name",M.jsx("span",{children:"*"})]}),M.jsx(WP,{type:"text",required:!0,value:Ot.name,onChange:we=>rn(Xe=>({...Xe,name:we.target.value})),placeholder:"John"}),_t.name&&M.jsx("p",{style:{color:"red",fontSize:"12px",margin:"4px 0 0"},children:_t.name})]}),M.jsxs(w8,{children:[M.jsxs(C8,{children:["Email",M.jsx("span",{children:"*"})]}),M.jsx(WP,{type:"email",required:!0,value:Ot.email,onChange:we=>rn(Xe=>({...Xe,email:we.target.value})),placeholder:"olivia@untitledui.com"}),_t.email&&M.jsx("p",{style:{color:"red",fontSize:"12px",margin:"4px 0 0"},children:_t.email})]}),M.jsxs(w8,{children:[M.jsxs(C8,{children:["Message",M.jsx("span",{children:"*"})]}),M.jsx(d0e,{required:!0,value:Ot.message,onChange:we=>rn(Xe=>({...Xe,message:we.target.value})),placeholder:"I need help with..."}),_t.message&&M.jsx("p",{style:{color:"red",fontSize:"12px",margin:"4px 0 0"},children:_t.message})]})]}),M.jsx(p0e,{children:M.jsx(h0e,{type:"submit",children:"Submit"})})]}),St&&!p&&l===Y.conversationId&&M.jsx(Mi,{isBot:ve,children:M.jsx(Os,{loading:St,loadingPhrases:["🎨 Loading","✨ Almost","🚀 Ready"]})})]})]}),!ve&&M.jsx(i0e,{$fontColor:t.userFontColor||"#000",$botMessageColor:t.botBackgroundColor||"#fff",children:M.jsx(Mi,{isBot:!!ve,children:M.jsx(bd,{children:Y.text})})}),h.length==1&&ce==0&&!T&&M.jsx(S8,{children:at.leadingQueries?M.jsx(Mi,{isBot:!0,children:M.jsx(Os,{loading:at.leadingQueries})}):j.map((we,Xe)=>M.jsxs(ZP,{style:{backgroundColor:t.callToActionBackgroundColor,color:t.callToActionFontColor,opacity:pt.has(we.question)?.5:1},onClick:()=>{E?(A(!0),R({question:we.question,answer:we.answer,products:we.products,path:"/",nameSpace:window.DebalesChat.projectId})):r({message:we.question,answer:we.answer,products:we.products,messType:"leading_query"}),Et(zt=>{const hn=new Set(zt);return hn.add(we.question),hn}),window.DebalesChat.track(an.INITIAL_LEADING_QUERY_SUGGESTED_QUESTION_CLICKED,{question:we.question})},disabled:p,$disabled:p,children:[we.question,M.jsx(YP,{color:t.callToActionFontColor})]},Xe))}),Y.leading_queries&&Y.leading_queries.length>0&&l===Y.conversationId&&V.leadingQueries&&!o&&!T&&M.jsx(S8,{children:Y.leading_queries.map((we,Xe)=>M.jsxs(ZP,{style:{backgroundColor:t.callToActionBackgroundColor,color:t.callToActionFontColor},onClick:()=>{E?(A(!0),R({question:we,path:"/",nameSpace:window.DebalesChat.projectId})):r({message:we,messType:"leading_query"}),window.DebalesChat.track(an.LEADING_QUERY_CLICKED,{query:we})},disabled:p,$disabled:p,children:[we,M.jsx(YP,{color:t.callToActionFontColor})]},Xe))})]},ce)}),(p||Gt)&&M.jsxs(VP,{$fontColor:t.botFontColor||"#000",$botMessageColor:t.botBackgroundColor||"#fff",children:[M.jsx("img",{src:t.bot_logo,alt:"Chat User Icon"}),M.jsx(QP,{children:M.jsx(Mi,{isBot:!0,children:M.jsx("div",{style:{display:"flex",alignItems:"center",gap:"4px",animation:"fadeIn 0.3s ease-in-out"},children:M.jsx(Os,{loading:p||Gt})})})})]})]}),M.jsx(m0e,{$backgroundColor:t.botBackgroundColor||"#fff",style:{opacity:Dn?1:0}})]}),M.jsxs("div",{className:"debales-footer-container",style:{width:"100%",backgroundColor:t.botBackgroundColor||"#fff",color:t.fontColor||"#000"},children:[e==="catch-org-ai"&&M.jsx(r0e,{children:M.jsx("span",{children:'"Catch org AI" can make mistakes.'})}),M.jsx("div",{children:M.jsx(Ok,{disabled:p,inputState:!1})}),(t.debales_branding??!0)&&M.jsxs(t0e,{href:"https://debales.ai/?open=true",target:"_blank",title:"debales-link",style:{color:t.fontColor?t.fontColor:"fff",marginTop:e==="catch-org-ai"?"0":"9px"},children:[M.jsx("p",{children:"Powered by"}),M.jsxs(n0e,{children:[M.jsx("img",{src:`${Di}/images/debales_logo_d.png`,alt:"Debales logo"}),M.jsx("p",{children:"DEBALES"})]})]})]})]})]})}),z.shadowRoot)]})},x0e=ae.p`
4435
+ => User Action: Klaviyo form closed`}return""},ve=Oe=>{Oe instanceof CustomEvent&&Y(Oe)};return window.addEventListener("klaviyoForms",ve),()=>{window.removeEventListener("klaviyoForms",ve)}},[ht,t,r]),Z.useEffect(()=>{const Y=Be.current;return Te&&Y?(Y.addEventListener("scroll",or),()=>{Y&&Y.removeEventListener("scroll",or)}):()=>{}},[Te,or]);const[Re,rt]=Z.useState(!1),vt=Q==="Highest"?"120px":Q==="Higher"?"60px":"15px",Vt=async()=>{try{const Y=await fetch(`${Di}/api/wordpress/support`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({chatid:rr()+e,nameSpace:e,userName:Ot.name,userEmail:Ot.email,userMessage:Ot.message,tag:"support"})});if(Y.ok){const ce=`support-confirm-${Date.now()}`;m(ve=>[...ve,{text:"Thanks for reaching out! Our support team has received your request and will get back to you within 24 hours.<br>In the meantime, feel free to continue chatting with me - I'll do my best to help!",isBot:!0,leading_queries:Jt,conversationId:ce}]),d(ce),ye(ve=>({...ve,leadingQueries:!0})),mn([]),console.log("Connected to support with existing user info:",Po())}else{const ce=await Y.json();console.error("Failed to connect to support:",ce),m(ve=>[...ve,{text:"Sorry, we couldn't connect you to support at the moment.<br>Please try again later.",isBot:!0}])}}catch{m(ce=>[...ce,{text:"Sorry, we couldn't connect you to support at the moment.<br>Please try again later.",isBot:!0}])}},lt=()=>{const Y=Po();let ce=[];const ve=h[h.length-1];ve!=null&&ve.leading_queries&&ve.leading_queries.length>0?ce=ve.leading_queries:h.length<=1&&(ce=j.flatMap(Oe=>Array.isArray(Oe)?Oe.map(we=>we.question):[Oe.question]).slice(0,4)),mn(ce),Y&&Y.name&&Y.email&&rn({name:Y==null?void 0:Y.name,email:Y==null?void 0:Y.email,message:""}),m(Oe=>[...Oe,{text:"Please provide your name, email and message to connect with support.",isBot:!0}]),Lt(!0)},je=async Y=>{Y.preventDefault();const ce={name:"",email:"",message:""};let ve=!0;const Oe=Ot.name.trim(),we=Ot.message.trim();Oe||(ce.name="Name cannot be empty or just whitespace.",ve=!1),(!Ot.email||!Pm.isEmail(Ot.email))&&(ce.email="Please enter a valid email address.",ve=!1),we||(ce.message="Message cannot be empty or just whitespace.",ve=!1),Xt(ce),ve&&(of({name:Oe,email:Ot.email}),Lt(!1),m(Xe=>Xe.slice(0,-1)),await Vt())},[dn,dr]=Z.useState({});return Z.useEffect(()=>{_r&&(h.forEach((Y,ce)=>{if(!Y.isBot)return;const ve=$p(Y.text);if(!(ce in dn)||dn[ce]<ve.length){let Oe;const we=Xe=>{Xe<ve.length&&(Oe=setTimeout(()=>{dr(zt=>({...zt,[ce]:Xe+1})),we(Xe+1)},po))};return ce in dn?we(dn[ce]):(dr(Xe=>({...Xe,[ce]:1})),we(1)),()=>clearTimeout(Oe)}}),dr(Y=>{const ce={};return h.forEach((ve,Oe)=>{Y[Oe]!==void 0&&(ce[Oe]=Y[Oe])}),ce}))},[h,_r]),!t||t.show_bot===!1||a?null:M.jsxs(Zw,{theme:uE(t,e),children:[M.jsx("link",{rel:"preconnect",href:"https://fonts.googleapis.com"}),M.jsx("link",{rel:"preconnect",href:"https://fonts.gstatic.com",crossOrigin:"anonymous"}),M.jsx("link",{href:"https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap",rel:"stylesheet"}),M.jsx("link",{href:"https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,100;0,300;0,400;0,700;0,900;1,100;1,300;1,400;1,700;1,900&display=swap",rel:"stylesheet"}),M.jsx(u0e,{}),M.jsx(jpe,{$topOffset:vt,$isLeft:W,children:M.jsxs(a0e,{$isLeft:W,$removeLogoBackground:t.removeLogoBackground,children:[!Te&&j.length>0&&j[U]&&ne&&M.jsx(s0e,{className:Ce?"visible":"",$botId:e,$iconSize:H,$removeLogoBackground:t.removeLogoBackground,topOffset:vt,$isLeft:W,style:{display:"flex",flexDirection:W?"row":"row-reverse",alignItems:"center",marginRight:W?"0px":Ut?"10px":"5px",marginTop:Ut?"0px":"10px",left:W?"24px":"auto",right:W?"auto":"24px",opacity:Ce?1:0,transition:"opacity 0.3s ease-in-out"},children:j.length>0&&j[U]&&(()=>{const Y=j[U];return M.jsx(l0e,{children:M.jsx(zpe,{messages:[{question:Y.question,isHighlighted:Y.isHighlighted??!1,show_for:(ee==null?void 0:ee.show_for)||4e3,hide_timing:(ee==null?void 0:ee.hide_timing)||4e3}],botId:e,uiData:t,isLeft:W,onClose:()=>{Et(ce=>{const ve=new Set(ce);return ve.add(Y.question),ve})},onClick:()=>{const ce=Y;be(!0,"suggested_question_clicked"),Et(ve=>{const Oe=new Set(ve);return Oe.add(ce.question),Oe}),window.DebalesChat.track(an.SUGGESTED_QUESTION_CLICKED,{suggested_question:ce}),E?(fn(!1),ir(!0),A(!0),R(ce)):(fn(!1),ir(!0),r({message:ce.Follow_up_Question??ce.question,answer:ce.answer,products:ce.products,fromKlaviyo:!1,leading_queries:ce.leading_queries,messType:"suggested_question"}))}})},Y.question)})()}),M.jsx(Ppe,{$topOffset:vt,$removeLogoBackground:t.removeLogoBackground,style:{display:Te?"none":"inline-flex"},children:M.jsxs(Hpe,{$backgroundColor:t.removeLogoBackground?"transparent":t.backgroundColor||"#fff",$botId:e,$iconSize:H,$removeLogoBackground:t.removeLogoBackground,topOffset:vt,$showAnimation:t.enableChatButtonBackgroundAnimation,$animationType:"Ping",$animationColor:t.chatButtonBackgroundAnimationColor||"#f48722",id:"debales-chat-button","data-testid":"debales-chat-button",onClick:()=>{if(window.DebalesChat.track(an.CHAT_BUTTON_CLICKED),be(!Te,"chat_button_clicked"),!Te){const Y=_();Y.length>0?(m(Y),fn(!1),ir(!0)):(fn(!0),ir(!1),setTimeout(()=>{fn(!1),ir(!0);const ce={text:(t==null?void 0:t.initialMessage)||"Hi, I am an AI chatbot, how can I help you today?",isBot:!0};m([ce])},(ee==null?void 0:ee.showing_delay)||2e3))}},"aria-label":"Chat",style:{display:Te?"none":"inline-flex"},children:[M.jsx(qpe,{$botId:e,$removeLogoBackground:t.removeLogoBackground,"aria-hidden":"true",src:t.bot_logo,alt:"Chat Bot Icon"}),(j==null?void 0:j.length)>0&&!Te&&fe&&!ne&&M.jsx("div",{style:{position:"absolute",top:"-5px",right:"-5px",backgroundColor:"#f44336",color:"white",borderRadius:"50%",width:"20px",height:"20px",display:"flex",justifyContent:"center",alignItems:"center",fontSize:"12px",fontWeight:"bold",zIndex:2,opacity:fe?1:0,transition:"opacity 0.3s ease-in-out"},children:j.length})]})})]})}),Te&&hw.createPortal(M.jsx(M.Fragment,{children:M.jsxs(Zpe,{$backgroundColor:t.backgroundColor||"#fff",$fullScreenOnMobile:t.fullScreenOnMobile,$headerFontColor:t.headerFontColor||"#1C1C1C",$isLeft:W,$topOffset:vt,$mobileDisplayMode:t.mobileDisplayMode,$isVisible:st,"data-testid":"debales-chat-container",children:[M.jsxs(Wpe,{$backgroundColor:He(e)?t.backgroundColor:t.botBackgroundColor||"#fff",style:{color:t.headerFontColor},children:[M.jsx("div",{style:{flexGrow:.1,display:"flex",justifyContent:"center",alignItems:"center",overflow:"hidden",marginRight:"8px",gap:"10px"},children:He(e)?M.jsxs(M.Fragment,{children:[M.jsx(qP,{"aria-hidden":"true",src:t.bot_logo,alt:"Chat Bot Icon"}),M.jsxs(Gpe,{$botNameColor:t.headerFontColor,children:[M.jsxs("div",{style:{fontWeight:"700",wordBreak:"break-word"},children:[t.chatbotName,e==="catch-org-ai"&&M.jsx(Ype,{$backgroundColor:t.callToActionBackgroundColor,$fontColor:t.callToActionFontColor,children:"Beta"})]}),M.jsx(Vpe,{})]})]}):M.jsx(Qpe,{children:M.jsxs(Kpe,{children:[M.jsx(qP,{src:t.bot_logo,alt:"Chat Bot Icon"}),M.jsx("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",display:"inline-block",maxWidth:"22ch"},children:t.chatbotName})]})})}),M.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginLeft:"auto",flexShrink:0},children:[M.jsxs(c0e,{children:[M.jsx(GP,{$iconBG:t.backgroundColor,onClick:lt,"aria-label":"Support","data-testid":"debales-support-button",children:M.jsx(pk,{color:t.headerFontColor})}),M.jsx(KP,{children:"Click to chat with a Live Support Agent now."})]}),M.jsx(GP,{$iconBG:t.backgroundColor,onClick:()=>{Ct?Mt(!0):be(!1,"close_button_clicked")},id:"debales-minimize-button","data-testid":"debales-minimize-button","aria-label":"Minimize",children:M.jsx(Hm,{botNameColor:t.headerFontColor})})]}),M.jsx(v0e,{$backgroundColor:t.botBackgroundColor||"#fff",style:{opacity:Kr?1:0}})]}),M.jsxs(e0e,{$backgroundColor:t.botBackgroundColor||"#fff",$mobileDisplayMode:t.mobileDisplayMode,children:[Re&&((tt=(Se=t.pluginConfig)==null?void 0:Se.collectedUserInfo)==null?void 0:tt.discount)&&M.jsx(wk,{discount:t.pluginConfig.collectedUserInfo.discount,uiData:t,onClose:()=>{rt(!1),window.DebalesChat.track(an.DISCOUNT_VIEWED,{discount:t.pluginConfig.collectedUserInfo.discount})}}),M.jsx(Rk,{uidata:t,product:hi,showModel:us,setShowModel:Wr,onVariantSelect:Y=>{I(Y.id,1),ct(!0),window.DebalesChat.track(an.ADD_TO_CART_CLICKED,{product:Y.title,price:Number(Y.price),link:`https://${t.shopifyShopDomain}/variants/${Y.id}`,message:l,chatId:rr()+e})}}),qo&&M.jsx(Ck,{setShowExitModal:Mt,handleCloseChatbot:Ro,chatId:rr()+e}),M.jsxs(Xpe,{id:"debales-conversation-group",$botBackgroundColor:t.botBackgroundColor||"#fff",ref:Be,$mobileDisplayMode:t.mobileDisplayMode,children:[M.jsx(g0e,{$backgroundColor:t.botBackgroundColor||"#fff",style:{opacity:Kr?1:0}}),M.jsxs(Jpe,{children:[_r&&h.map((Y,ce)=>{const ve=Y.isBot,Oe=$p(Y.text);return Y.hideConfirmation?null:M.jsxs(Z.Fragment,{children:[ve&&M.jsxs(VP,{$fontColor:t.botFontColor||"#000",$botMessageColor:t.botBackgroundColor||"#fff","data-testid":"debales-ai-message-container",children:[M.jsx("img",{src:ve?t.bot_logo:t.userMessage_logo,alt:"Chat User Icon",style:{marginLeft:"8px"}}),M.jsxs(QP,{children:[Oe.slice(0,dn[ce]||0).map((we,Xe)=>M.jsx("div",{children:M.jsx(Mi,{isBot:ve,children:M.jsx(bd,{remarkPlugins:[Tw,bE],children:we})})},Xe)),Y.collections&&l===Y.conversationId&&V.collections&&M.jsx(Sk,{message:Y,botId:e,uidata:t,onSendMessage:r,loading:p}),Y.products&&l===Y.conversationId&&V.products&&M.jsx(Ak,{message:Y,botId:e,uidata:t,onSendMessage:r,loading:p,storeMetaData:n,platform:G,setShowVariantModel:Wr,setSelectedProduct:Br,setCartVersion:Ae}),o&&M.jsx(S8,{children:M.jsx(Ix,{onClick:()=>{window._klOnsite&&(window._klOnsite.push(["openForm",se]),be(!1,"klaviyo_grab_deal_button"))},children:"🚀 Grab Deal Now!"})}),O&&O.itemCount>0&&l===Y.conversationId&&V.cartSummary&&ot&&M.jsx(yk,{onCheckout:Go,onKeepShopping:()=>{ct(!1)}}),Me&&Me.length>0&&l===Y.conversationId&&V.bulkItems&&M.jsx(fk,{onClick:()=>Oo(Y.conversationId),children:"Add Bulk Items to Cart"}),T&&h.indexOf(Y)===h.length-1&&M.jsx(M.Fragment,{children:M.jsx(kk,{setShowModel:we=>{var zt,hn;const Xe=typeof we=="function"?we(T):we;A(Xe),!Xe&&((hn=(zt=t.pluginConfig)==null?void 0:zt.collectedUserInfo)!=null&&hn.discount)&&rt(!0)},inChat:!0,showFormInstructions:!1})}),ft&&h.indexOf(Y)===h.length-1&&M.jsxs(f0e,{onSubmit:je,noValidate:!0,"data-testid":"debales-support-form",children:[He(e)?M.jsxs(M.Fragment,{children:[M.jsx(eu,{label:"Name",name:"name",type:"text",value:Ot.name,onChange:we=>rn(Xe=>({...Xe,name:we.target.value})),required:!0,error:_t.name,isCollectiveBot:!0}),M.jsx(eu,{label:"Email",name:"email",type:"email",value:Ot.email,onChange:we=>rn(Xe=>({...Xe,email:we.target.value})),required:!0,error:_t.email,isCollectiveBot:!0}),M.jsx(Ek,{label:"Message",name:"message",value:Ot.message,onChange:we=>rn(Xe=>({...Xe,message:we.target.value})),required:!0,error:_t.message,rows:4,isCollectiveBot:!0})]}):M.jsxs(M.Fragment,{children:[M.jsxs(w8,{children:[M.jsxs(C8,{children:["Name",M.jsx("span",{children:"*"})]}),M.jsx(WP,{type:"text",required:!0,value:Ot.name,onChange:we=>rn(Xe=>({...Xe,name:we.target.value})),placeholder:"John"}),_t.name&&M.jsx("p",{style:{color:"red",fontSize:"12px",margin:"4px 0 0"},children:_t.name})]}),M.jsxs(w8,{children:[M.jsxs(C8,{children:["Email",M.jsx("span",{children:"*"})]}),M.jsx(WP,{type:"email",required:!0,value:Ot.email,onChange:we=>rn(Xe=>({...Xe,email:we.target.value})),placeholder:"olivia@untitledui.com"}),_t.email&&M.jsx("p",{style:{color:"red",fontSize:"12px",margin:"4px 0 0"},children:_t.email})]}),M.jsxs(w8,{children:[M.jsxs(C8,{children:["Message",M.jsx("span",{children:"*"})]}),M.jsx(d0e,{required:!0,value:Ot.message,onChange:we=>rn(Xe=>({...Xe,message:we.target.value})),placeholder:"I need help with..."}),_t.message&&M.jsx("p",{style:{color:"red",fontSize:"12px",margin:"4px 0 0"},children:_t.message})]})]}),M.jsx(p0e,{children:M.jsx(h0e,{type:"submit",children:"Submit"})})]}),St&&!p&&l===Y.conversationId&&M.jsx(Mi,{isBot:ve,children:M.jsx(Os,{loading:St,loadingPhrases:["🎨 Loading","✨ Almost","🚀 Ready"]})})]})]}),!ve&&M.jsx(i0e,{$fontColor:t.userFontColor||"#000",$botMessageColor:t.botBackgroundColor||"#fff",children:M.jsx(Mi,{isBot:!!ve,children:M.jsx(bd,{children:Y.text})})}),h.length==1&&ce==0&&!T&&M.jsx(S8,{children:at.leadingQueries?M.jsx(Mi,{isBot:!0,children:M.jsx(Os,{loading:at.leadingQueries})}):j.map((we,Xe)=>M.jsxs(ZP,{style:{backgroundColor:t.callToActionBackgroundColor,color:t.callToActionFontColor,opacity:pt.has(we.question)?.5:1},onClick:()=>{E?(A(!0),R({question:we.question,answer:we.answer,products:we.products,path:"/",nameSpace:window.DebalesChat.projectId})):r({message:we.question,answer:we.answer,products:we.products,messType:"leading_query"}),Et(zt=>{const hn=new Set(zt);return hn.add(we.question),hn}),window.DebalesChat.track(an.INITIAL_LEADING_QUERY_SUGGESTED_QUESTION_CLICKED,{question:we.question})},disabled:p,$disabled:p,children:[we.question,M.jsx(YP,{color:t.callToActionFontColor})]},Xe))}),Y.leading_queries&&Y.leading_queries.length>0&&l===Y.conversationId&&V.leadingQueries&&!o&&!T&&M.jsx(S8,{children:Y.leading_queries.map((we,Xe)=>M.jsxs(ZP,{style:{backgroundColor:t.callToActionBackgroundColor,color:t.callToActionFontColor},onClick:()=>{E?(A(!0),R({question:we,path:"/",nameSpace:window.DebalesChat.projectId})):r({message:we,messType:"leading_query"}),window.DebalesChat.track(an.LEADING_QUERY_CLICKED,{query:we})},disabled:p,$disabled:p,children:[we,M.jsx(YP,{color:t.callToActionFontColor})]},Xe))})]},ce)}),(p||Gt)&&M.jsxs(VP,{$fontColor:t.botFontColor||"#000",$botMessageColor:t.botBackgroundColor||"#fff",children:[M.jsx("img",{src:t.bot_logo,alt:"Chat User Icon"}),M.jsx(QP,{children:M.jsx(Mi,{isBot:!0,children:M.jsx("div",{style:{display:"flex",alignItems:"center",gap:"4px",animation:"fadeIn 0.3s ease-in-out"},children:M.jsx(Os,{loading:p||Gt})})})})]})]}),M.jsx(m0e,{$backgroundColor:t.botBackgroundColor||"#fff",style:{opacity:Dn?1:0}})]}),M.jsxs("div",{className:"debales-footer-container",style:{width:"100%",backgroundColor:t.botBackgroundColor||"#fff",color:t.fontColor||"#000"},children:[(e==="catch-org-ai"||e==="letsgo-catch")&&M.jsx(r0e,{children:M.jsx("span",{children:`"${t.chatbotName}" can make mistakes.`})}),M.jsx("div",{children:M.jsx(Ok,{disabled:p,inputState:!1})}),(t.debales_branding??!0)&&M.jsxs(t0e,{href:"https://debales.ai/?open=true",target:"_blank",title:"debales-link",style:{color:t.fontColor?t.fontColor:"fff",marginTop:e==="catch-org-ai"?"0":"9px"},children:[M.jsx("p",{children:"Powered by"}),M.jsxs(n0e,{children:[M.jsx("img",{src:`${Di}/images/debales_logo_d.png`,alt:"Debales logo"}),M.jsx("p",{children:"DEBALES"})]})]})]})]})]})}),z.shadowRoot)]})},x0e=ae.p`
4436
4436
  margin: 0;
4437
4437
  font-size: 16px;
4438
4438
  text-align: left;
@@ -5198,7 +5198,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
5198
5198
 
5199
5199
  `+Oe+`
5200
5200
 
5201
- => User Action: Klaviyo form closed`}return""},Y=ce=>{ce instanceof CustomEvent&&Se(ce)};return window.addEventListener("klaviyoForms",Y),()=>{window.removeEventListener("klaviyoForms",Y)}},[ot,t,r]),Z.useEffect(()=>{const Se=ge.current;return Je&&Se?(Se.addEventListener("scroll",En),()=>{Se&&Se.removeEventListener("scroll",En)}):()=>{}},[Je,En]);const[ar,Go]=Z.useState(!1),Re=Q==="Highest"?"120px":Q==="Higher"?"60px":"15px",rt=async()=>{try{const Se=await fetch(`${Di}/api/wordpress/support`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({chatid:rr()+e,nameSpace:e,userName:ft.name,userEmail:ft.email,userMessage:ft.message,tag:"support"})});if(Se.ok){const tt=`support-confirm-${Date.now()}`;m(Y=>[...Y,{text:"Thanks for reaching out! Our support team has received your request and will get back to you within 24 hours.<br>In the meantime, feel free to continue chatting with me - I'll do my best to help!",isBot:!0,leading_queries:Ot,conversationId:tt}]),d(tt),Ct(Y=>({...Y,leadingQueries:!0})),rn([]),console.log("Connected to support with existing user info:",Po())}else{const tt=await Se.json();console.error("Failed to connect to support:",tt),m(Y=>[...Y,{text:"Sorry, we couldn't connect you to support at the moment.<br>Please try again later.",isBot:!0}])}}catch{m(tt=>[...tt,{text:"Sorry, we couldn't connect you to support at the moment.<br>Please try again later.",isBot:!0}])}},vt=()=>{const Se=Po();let tt=[];const Y=h[h.length-1];Y!=null&&Y.leading_queries&&Y.leading_queries.length>0?tt=Y.leading_queries:h.length<=1&&(tt=j.flatMap(ce=>Array.isArray(ce)?ce.map(ve=>ve.question):[ce.question]).slice(0,4)),rn(tt),Se&&Se.name&&Se.email&&Lt({name:Se==null?void 0:Se.name,email:Se==null?void 0:Se.email,message:""}),m(ce=>[...ce,{text:"Please provide your name, email and message to connect with support.",isBot:!0}]),Rt(!0)},Vt=async Se=>{Se.preventDefault();const tt={name:"",email:"",message:""};let Y=!0;const ce=ft.name.trim(),ve=ft.message.trim();ce||(tt.name="Name cannot be empty or just whitespace.",Y=!1),(!ft.email||!Pm.isEmail(ft.email))&&(tt.email="Please enter a valid email address.",Y=!1),ve||(tt.message="Message cannot be empty or just whitespace.",Y=!1),mn(tt),Y&&(of({name:ce,email:ft.email}),Rt(!1),m(Oe=>Oe.slice(0,-1)),await rt())},[lt,je]=Z.useState({});return Z.useEffect(()=>{Gt&&(h.forEach((Se,tt)=>{if(!Se.isBot)return;const Y=$p(Se.text);if(!(tt in lt)||lt[tt]<Y.length){let ce;const ve=Oe=>{Oe<Y.length&&(ce=setTimeout(()=>{je(we=>({...we,[tt]:Oe+1})),ve(Oe+1)},Dn))};return tt in lt?ve(lt[tt]):(je(Oe=>({...Oe,[tt]:1})),ve(1)),()=>clearTimeout(ce)}}),je(Se=>{const tt={};return h.forEach((Y,ce)=>{Se[ce]!==void 0&&(tt[ce]=Se[ce])}),tt}))},[h,Gt]),!t||t.show_bot===!1||a?null:M.jsxs(Zw,{theme:uE(t,e),children:[M.jsx("link",{rel:"preconnect",href:"https://fonts.googleapis.com"}),M.jsx("link",{rel:"preconnect",href:"https://fonts.gstatic.com",crossOrigin:"anonymous"}),M.jsx("link",{href:"https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap",rel:"stylesheet"}),M.jsx("link",{href:"https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,100;0,300;0,400;0,700;0,900;1,100;1,300;1,400;1,700;1,900&display=swap",rel:"stylesheet"}),M.jsx(V0e,{}),M.jsxs(C0e,{$topOffset:Re,$isLeft:W,children:[!Je&&j.length>0&&j[U]&&ne&&M.jsx(q0e,{className:Ce?"visible":"",$botId:e,$iconSize:H,$removeLogoBackground:t.removeLogoBackground,topOffset:Re,style:{display:"flex",flexDirection:"column",alignItems:"center",opacity:Ce?1:0,transition:"opacity 0.3s ease-in-out"},children:j.length>0&&j[U]&&M.jsx(G0e,{children:M.jsx(_0e,{messages:[{question:j[U].question,isHighlighted:j[U].isHighlighted??!1,show_for:(ee==null?void 0:ee.show_for)||4e3,hide_timing:(ee==null?void 0:ee.hide_timing)||4e3}],botId:e,uiData:t,onClose:()=>{Ue(Se=>{const tt=new Set(Se);return tt.add(j[U].question),tt})},onClick:()=>{const Se=j[U];pt(!0,"suggested_question_clicked"),Ue(tt=>{const Y=new Set(tt);return Y.add(Se.question),Y}),window.DebalesChat.track(an.SUGGESTED_QUESTION_CLICKED,{suggested_question:Se}),E?(Wt(!1),fn(!0),A(!0),R(Se)):(Wt(!1),fn(!0),r({message:Se.Follow_up_Question??Se.question,answer:Se.answer,products:Se.products,fromKlaviyo:!1,leading_queries:Se.leading_queries,followUpQuestion:Se.Follow_up_Question,messType:"suggested_question"}))}})},j[U].question)}),M.jsxs(E0e,{$topOffset:Re,$removeLogoBackground:t.removeLogoBackground,style:{display:Je||ne?"none":"flex"},children:[M.jsx(A0e,{$showAnimation:t.enableChatButtonBackgroundAnimation??!1,$animationType:"Ping",$animationColor:t.chatButtonBackgroundAnimationColor||"#f48722",$backgroundColor:t.backgroundColor||"#fff",$removeLogoBackground:t.removeLogoBackground,$topOffset:Re,$iconSize:H}),M.jsxs(k0e,{$backgroundColor:t.removeLogoBackground?"transparent":t.backgroundColor||"#fff",$botId:e,$iconSize:H,$removeLogoBackground:t.removeLogoBackground,topOffset:Re,$showAnimation:t.enableChatButtonBackgroundAnimation,$animationType:"Ping",$animationColor:t.chatButtonBackgroundAnimationColor||"#f48722",id:"debales-chat-button","data-testid":"debales-chat-button",onClick:()=>{if(window.DebalesChat.track(an.CHAT_BUTTON_CLICKED),pt(!Je,"chat_button_clicked"),!Je){const Se=_();Se.length>0?(m(Se),Wt(!1),fn(!0)):(Wt(!0),fn(!1),setTimeout(()=>{Wt(!1),fn(!0);const tt={text:(t==null?void 0:t.initialMessage)||"Hi, I am an AI chatbot, how can I help you today?",isBot:!0};m([tt])},(ee==null?void 0:ee.showing_delay)||2e3))}},"aria-label":"Chat",style:{display:Je||ne?"none":"flex"},children:[M.jsx(T0e,{$botId:e,$removeLogoBackground:t.removeLogoBackground,"aria-hidden":"true",src:t.bot_logo,alt:"Chat Bot Icon"}),(j==null?void 0:j.length)>0&&!Je&&fe&&M.jsx("div",{style:{position:"absolute",top:"0px",right:"0px",backgroundColor:"#f44336",color:"white",borderRadius:"50%",width:"20px",height:"20px",display:"flex",justifyContent:"center",alignItems:"center",fontSize:"12px",fontWeight:"bold",zIndex:2,opacity:fe?1:0,transition:"opacity 0.3s ease-in-out"},children:j.length})]})]})]}),Je&&hw.createPortal(M.jsx(M.Fragment,{children:M.jsxs(M0e,{$backgroundColor:t.backgroundColor||"#fff",$fullScreenOnMobile:t.fullScreenOnMobile,$headerFontColor:t.headerFontColor||"#1C1C1C",$isLeft:W,$topOffset:Re,$mobileDisplayMode:t.mobileDisplayMode,$isVisible:Bt,"data-testid":"debales-chat-container",children:[M.jsxs(B0e,{$backgroundColor:He(e)?t.backgroundColor:t.botBackgroundColor||"#fff",style:{color:t.headerFontColor},children:[M.jsx("div",{style:{flexGrow:.1,display:"flex",justifyContent:"center",alignItems:"center",overflow:"hidden",marginRight:"8px",gap:"10px"},children:He(e)?M.jsxs(M.Fragment,{children:[M.jsx(JP,{"aria-hidden":"true",src:t.bot_logo,alt:"Chat Bot Icon"}),M.jsxs(R0e,{$botNameColor:t.headerFontColor,children:[M.jsxs("div",{style:{fontWeight:"700",wordBreak:"break-word"},children:[t.chatbotName,e==="catch-org-ai"&&M.jsx(D0e,{$backgroundColor:t.callToActionBackgroundColor,$fontColor:t.callToActionFontColor,children:"Beta"})]}),M.jsx(O0e,{})]})]}):M.jsx(I0e,{children:M.jsxs($0e,{children:[M.jsx(JP,{src:t.bot_logo,alt:"Chat Bot Icon"}),M.jsx("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",display:"inline-block",maxWidth:"22ch"},children:t.chatbotName})]})})}),M.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginLeft:"auto",flexShrink:0},children:[M.jsxs(Y0e,{children:[M.jsx(eH,{$iconBG:t.backgroundColor,onClick:vt,"aria-label":"Support","data-testid":"debales-support-button",children:M.jsx(pk,{color:t.headerFontColor})}),M.jsx(oH,{children:"Click to chat with a Live Support Agent now."})]}),M.jsx(eH,{$iconBG:t.backgroundColor,onClick:()=>{_t?Wr(!0):pt(!1,"close_button_clicked")},id:"debales-minimize-button","data-testid":"debales-minimize-button","aria-label":"Minimize",children:M.jsx(Hm,{botNameColor:t.headerFontColor})})]}),M.jsx(ege,{$backgroundColor:t.botBackgroundColor||"#fff",style:{opacity:_r?1:0}})]}),M.jsxs(z0e,{$backgroundColor:t.botBackgroundColor||"#fff",$mobileDisplayMode:t.mobileDisplayMode,children:[ar&&((dr=(dn=t.pluginConfig)==null?void 0:dn.collectedUserInfo)==null?void 0:dr.discount)&&M.jsx(wk,{discount:t.pluginConfig.collectedUserInfo.discount,uiData:t,onClose:()=>{Go(!1),window.DebalesChat.track(an.DISCOUNT_VIEWED,{discount:t.pluginConfig.collectedUserInfo.discount})}}),M.jsx(Rk,{uidata:t,product:qo,showModel:po,setShowModel:or,onVariantSelect:Se=>{I(Se.id,1),se(!0),window.DebalesChat.track(an.ADD_TO_CART_CLICKED,{product:Se.title,price:Number(Se.price),link:`https://${t.shopifyShopDomain}/variants/${Se.id}`,message:l,chatId:rr()+e})}}),us&&M.jsx(Ck,{setShowExitModal:Wr,handleCloseChatbot:hi,chatId:rr()+e}),M.jsxs(L0e,{id:"debales-conversation-group",$botBackgroundColor:t.botBackgroundColor||"#fff",ref:ge,$mobileDisplayMode:t.mobileDisplayMode,children:[M.jsx(X0e,{$backgroundColor:t.botBackgroundColor||"#fff",style:{opacity:_r?1:0}}),M.jsxs(N0e,{children:[Gt&&h.map((Se,tt)=>{const Y=Se.isBot,ce=$p(Se.text);return Se.hideConfirmation?null:M.jsxs(Z.Fragment,{children:[Y&&M.jsxs(tH,{$fontColor:t.botFontColor||"#000",$botMessageColor:t.botBackgroundColor||"#fff","data-testid":"debales-ai-message-container",children:[M.jsx("img",{src:Y?t.bot_logo:t.userMessage_logo,alt:"Chat User Icon",style:{marginLeft:"8px"}}),M.jsxs(iH,{children:[ce.slice(0,lt[tt]||0).map((ve,Oe)=>M.jsx("div",{children:M.jsx(Mi,{isBot:Y,children:M.jsx(bd,{remarkPlugins:[Tw,bE],children:ve})})},Oe)),Se.collections&&l===Se.conversationId&&Xt.collections&&M.jsx(Sk,{message:Se,botId:e,uidata:t,onSendMessage:r,loading:p}),Se.products&&l===Se.conversationId&&Xt.products&&M.jsx(Ak,{message:Se,botId:e,uidata:t,onSendMessage:r,loading:p,storeMetaData:n,platform:G,setShowVariantModel:or,setSelectedProduct:Mt,setCartVersion:ht}),o&&M.jsx(A8,{children:M.jsx(Ix,{onClick:()=>{window._klOnsite&&(window._klOnsite.push(["openForm",Ut]),pt(!1,"klaviyo_grab_deal_button"))},children:"🚀 Grab Deal Now!"})}),O&&O.itemCount>0&&l===Se.conversationId&&Xt.cartSummary&&ie&&M.jsx(yk,{onCheckout:Oo,onKeepShopping:()=>{se(!1)}}),Et&&Et.length>0&&l===Se.conversationId&&Xt.bulkItems&&M.jsx(fk,{onClick:()=>Br(Se.conversationId),children:"Add Bulk Items to Cart"}),T&&h.indexOf(Se)===h.length-1&&M.jsx(M.Fragment,{children:M.jsx(kk,{setShowModel:ve=>{var we,Xe;const Oe=typeof ve=="function"?ve(T):ve;A(Oe),!Oe&&((Xe=(we=t.pluginConfig)==null?void 0:we.collectedUserInfo)!=null&&Xe.discount)&&Go(!0)},inChat:!0,showFormInstructions:!1})}),Me&&h.indexOf(Se)===h.length-1&&M.jsxs(Z0e,{onSubmit:Vt,noValidate:!0,"data-testid":"debales-support-form",children:[He(e)?M.jsxs(M.Fragment,{children:[M.jsx(eu,{label:"Name",name:"name",type:"text",value:ft.name,onChange:ve=>Lt(Oe=>({...Oe,name:ve.target.value})),required:!0,error:Jt.name,isCollectiveBot:!0}),M.jsx(eu,{label:"Email",name:"email",type:"email",value:ft.email,onChange:ve=>Lt(Oe=>({...Oe,email:ve.target.value})),required:!0,error:Jt.email,isCollectiveBot:!0}),M.jsx(Ek,{label:"Message",name:"message",value:ft.message,onChange:ve=>Lt(Oe=>({...Oe,message:ve.target.value})),required:!0,error:Jt.message,rows:4,isCollectiveBot:!0})]}):M.jsxs(M.Fragment,{children:[M.jsxs(k8,{children:[M.jsxs(T8,{children:["Name",M.jsx("span",{children:"*"})]}),M.jsx(aH,{type:"text",required:!0,value:ft.name,onChange:ve=>Lt(Oe=>({...Oe,name:ve.target.value})),placeholder:"John"}),Jt.name&&M.jsx("p",{style:{color:"red",fontSize:"12px",margin:"4px 0 0"},children:Jt.name})]}),M.jsxs(k8,{children:[M.jsxs(T8,{children:["Email",M.jsx("span",{children:"*"})]}),M.jsx(aH,{type:"email",required:!0,value:ft.email,onChange:ve=>Lt(Oe=>({...Oe,email:ve.target.value})),placeholder:"olivia@untitledui.com"}),Jt.email&&M.jsx("p",{style:{color:"red",fontSize:"12px",margin:"4px 0 0"},children:Jt.email})]}),M.jsxs(k8,{children:[M.jsxs(T8,{children:["Message",M.jsx("span",{children:"*"})]}),M.jsx(Q0e,{required:!0,value:ft.message,onChange:ve=>Lt(Oe=>({...Oe,message:ve.target.value})),placeholder:"I need help with..."}),Jt.message&&M.jsx("p",{style:{color:"red",fontSize:"12px",margin:"4px 0 0"},children:Jt.message})]})]}),M.jsx(W0e,{children:M.jsx(K0e,{type:"submit",children:"Submit"})})]}),at&&!p&&l===Se.conversationId&&M.jsx(Mi,{isBot:Y,children:M.jsx(Os,{loading:at,loadingPhrases:["🎨 Loading","✨ Almost","🚀 Ready"]})})]})]}),!Y&&M.jsx(P0e,{$fontColor:t.userFontColor||"#000",$botMessageColor:t.botBackgroundColor||"#fff",children:M.jsx(Mi,{isBot:!!Y,children:M.jsx(bd,{children:Se.text})})}),h.length==1&&tt==0&&!T&&M.jsx(A8,{children:V.leadingQueries?M.jsx(Mi,{isBot:!0,children:M.jsx(Os,{loading:V.leadingQueries})}):j.map((ve,Oe)=>M.jsxs(rH,{style:{backgroundColor:t.callToActionBackgroundColor,color:t.callToActionFontColor,opacity:Be.has(ve.question)?.5:1},onClick:()=>{E?(A(!0),R({question:ve.question,answer:ve.answer,products:ve.products,path:"/",nameSpace:window.DebalesChat.projectId})):r({message:ve.question,answer:ve.answer,products:ve.products,messType:"leading_query"}),Ue(we=>{const Xe=new Set(we);return Xe.add(ve.question),Xe}),window.DebalesChat.track(an.INITIAL_LEADING_QUERY_SUGGESTED_QUESTION_CLICKED,{question:ve.question})},disabled:p,$disabled:p,children:[ve.question,M.jsx(nH,{color:t.callToActionFontColor})]},Oe))}),Se.leading_queries&&Se.leading_queries.length>0&&l===Se.conversationId&&Xt.leadingQueries&&!o&&!T&&M.jsx(A8,{children:Se.leading_queries.map((ve,Oe)=>M.jsxs(rH,{style:{backgroundColor:t.callToActionBackgroundColor,color:t.callToActionFontColor},onClick:()=>{E?(A(!0),R({question:ve,path:"/",nameSpace:window.DebalesChat.projectId})):r({message:ve,messType:"leading_query"}),window.DebalesChat.track(an.LEADING_QUERY_CLICKED,{query:ve})},disabled:p,$disabled:p,children:[ve,M.jsx(nH,{color:t.callToActionFontColor})]},Oe))})]},tt)}),(p||Pt)&&M.jsxs(tH,{$fontColor:t.botFontColor||"#000",$botMessageColor:t.botBackgroundColor||"#fff",children:[M.jsx("img",{src:t.bot_logo,alt:"Chat User Icon"}),M.jsx(iH,{children:M.jsx(Mi,{isBot:!0,children:M.jsx("div",{style:{display:"flex",alignItems:"center",gap:"4px",animation:"fadeIn 0.3s ease-in-out"},children:M.jsx(Os,{loading:p||Pt})})})})]})]}),M.jsx(J0e,{$backgroundColor:t.botBackgroundColor||"#fff",style:{opacity:Kr?1:0}})]}),M.jsxs("div",{className:"debales-footer-container",style:{width:"calc(100%-24px)",backgroundColor:t.botBackgroundColor||"#fff",color:t.fontColor||"#000"},children:[e==="catch-org-ai"&&M.jsx(j0e,{children:M.jsx("span",{children:'"Catch org AI" can make mistakes.'})}),M.jsx("div",{children:M.jsx(Ok,{disabled:p,inputState:!1})}),(t.debales_branding??!0)&&M.jsxs(F0e,{href:"https://debales.ai/?open=true",target:"_blank",title:"debales-link",style:{color:t.fontColor?t.fontColor:"fff",marginTop:e==="catch-org-ai"?"0":"9px"},children:[M.jsx("p",{children:"Powered by"}),M.jsxs(U0e,{children:[M.jsx("img",{src:`${Di}/images/debales_logo_d.png`,alt:"Debales logo"}),M.jsx("p",{children:"DEBALES"})]})]})]})]})]})}),z.shadowRoot)]})},nge=({botId:e})=>{const t=OZ("new-suggested-question-design");let n;return t==="variant-1"?n=Bpe:t==="variant-2"?n=y0e:t==="variant-3"?n=tge:n=$P,M.jsx(n,{botId:e})},sH="debales-ai-assistant",lH="debales-chatbot-container",rge=Z.forwardRef(({children:e,globalStyles:t="",containerStyles:n={},onReady:r},o)=>{const a=Z.useRef(null),[l,d]=Z.useState(null),h=Z.useRef(null),p=Z.useRef(null),y=Z.useRef({get shadowRoot(){return h.current},get container(){return l},querySelector:m=>{var x;return((x=h.current)==null?void 0:x.querySelector(m))||null},querySelectorAll:m=>{var x;return((x=h.current)==null?void 0:x.querySelectorAll(m))||null}});return Z.useImperativeHandle(o,()=>y.current,[]),Z.useEffect(()=>{const m=document.getElementById(sH);if(m?a.current=m:a.current&&(a.current.id=sH),a.current&&(a.current.style.cssText="position: absolute; top: 0; left: 0; width: 0; height: 0;"),a.current){if(a.current.shadowRoot){h.current=a.current.shadowRoot;const w=h.current.querySelector(`#${lH}`);w&&d(w);return}const x=a.current.attachShadow({mode:"open"});if(h.current=x,t){const w=document.createElement("style");w.textContent=t,x.appendChild(w)}const _=document.createElement("div");_.id=lH,_.style.cssText="position: absolute; top: 0; left: 0; width: 0; height: 0;",x.appendChild(_),d(_),r&&r(x,_)}},[t,r]),Z.useEffect(()=>(l&&!p.current&&(p.current=k5.createRoot(l)),p.current&&l&&p.current.render(M.jsx(Gte,{target:l,children:M.jsx(Ij,{value:y.current,children:e})})),()=>{p.current&&p.current.unmount()}),[l,e]),M.jsx("div",{ref:a,style:n})});class Dk{isSupported(){return ff.detect()===this.platform}createSuccessResult(t,n){return{success:!0,data:t,message:n}}createErrorResult(t){return{success:!1,error:t}}}class ige extends Dk{constructor(){super(...arguments);Qi(this,"platform",_i.DEFAULT)}async fetchCart(){return console.log("DefaultCartAdapter: fetchCart called"),this.createSuccessResult({items:[],total:0,itemCount:0,currency:"USD",token:"default-token"},"Default cart fetched")}async addToCart(n,r=1,o){return console.log("DefaultCartAdapter: addToCart called",{variantId:n,quantity:r,properties:o}),this.createSuccessResult(void 0,"Item added to cart (mock)")}async removeFromCart(n){return console.log("DefaultCartAdapter: removeFromCart called",{itemId:n}),this.createSuccessResult(void 0,"Item removed from cart (mock)")}async updateQuantity(n){return console.log("DefaultCartAdapter: updateQuantity called",{cartItem:n}),this.createSuccessResult(void 0,"Item quantity updated (mock)")}async clearCart(){return console.log("DefaultCartAdapter: clearCart called"),this.createSuccessResult(void 0,"Cart cleared (mock)")}generateCartUrl(n){const r=n.replace(/^https?:\/\//,"");return console.log("DefaultCartAdapter: generateCartUrl called",{domain:n,sanitizedDomain:r}),`https://${r}/cart`}generateProductUrl(n,r){if(r.handle){const o=new URL(`https://${n}/products/${r.handle}`);return o.searchParams.append("variant",r.product_id),hf(o.toString())}else return hf(r.link)}async addCartAttributes(n={}){return console.log("MethodNotImplemented: addCartAttributes called",{attributes:n}),this.createSuccessResult(void 0,"Cart attributes added (mock)")}}class oge extends Dk{constructor(){var n,r;super();Qi(this,"platform",_i.SHOPIFY);Qi(this,"cartEndpoint");Qi(this,"localCartKey","debales_track_cart");this.cartEndpoint=((r=(n=window.Shopify)==null?void 0:n.routes)==null?void 0:r.root)||"/"}normalizeCartData(n){return{items:n.items.map(r=>({id:r.id,variant_id:r.variant_id,quantity:r.quantity,title:r.title,price:r.price,properties:r.properties})),total:n.total_price/100,itemCount:n.item_count,currency:n.currency,token:n.token.split("?")[0]}}generateProductUrl(n,r){const o=Tk(n);if(!o.isValid)return"";if(r.handle){const a=new URL(`/products/${r.handle}`,o.url);return a.searchParams.append("variant",r.product_id),hf(a.toString())}else return hf(r.link)}updateTrackCart({cartToken:n,sessionId:r=rr()}){localStorage.setItem(this.localCartKey,JSON.stringify({sessionId:r,cartToken:n}))}async fetchCart(){try{const n=await fetch(`${this.cartEndpoint}cart.js`),r=await n.json();if(!n.ok){const a=r;return this.createErrorResult(a.description||`Failed to fetch cart: ${n.status}`)}const o=r;return this.createSuccessResult(this.normalizeCartData(o),"Cart fetched successfully")}catch(n){return this.createErrorResult(n instanceof Error?`Error fetching cart: ${n.message}`:"Unknown error occurred while fetching cart")}}async addToCart(n,r=1,o){try{const a=await fetch(`${this.cartEndpoint}cart/add.js`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({items:[{id:n,quantity:r,properties:o}],attributes:{dbls_order_source:"direct_recommendation",dbls_session_id:rr(),dbls_method:"add_to_cart"}})}),l=await a.json();if(!a.ok){const d=l;return this.createErrorResult(d.description||`Failed to add item to cart: ${a.status}`)}return this.fetchCart().then(d=>{d.success&&this.updateTrackCart({cartToken:d==null?void 0:d.data.token})}),this.createSuccessResult(void 0,`Successfully added ${r} item(s) to cart`)}catch(a){return this.createErrorResult(a instanceof Error?`Error adding to cart: ${a.message}`:"Unknown error occurred while adding to cart")}}async removeFromCart(n){return this.updateQuantity({id:n,quantity:0})}async updateQuantity(n){try{const r=await fetch(`${this.cartEndpoint}cart/change.js`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:n.id,quantity:n.quantity})}),o=await r.json();if(!r.ok){const a=o;return this.createErrorResult(a.description||`Failed to update item quantity: ${r.status}`)}return this.fetchCart().then(a=>{a.success&&this.updateTrackCart({cartToken:a==null?void 0:a.data.token})}),this.createSuccessResult(void 0,n.quantity===0?"Item removed from cart":`Quantity updated to ${n.quantity}`)}catch(r){return this.createErrorResult(r instanceof Error?`Error updating quantity: ${r.message}`:"Unknown error occurred while updating quantity")}}async clearCart(){try{const n=await fetch(`${this.cartEndpoint}cart/clear.js`,{method:"POST"});if(!n.ok){const r=await n.json();return this.createErrorResult(r.description||`Failed to clear cart: ${n.status}`)}return this.createSuccessResult(void 0,"Cart cleared successfully")}catch(n){return this.createErrorResult(n instanceof Error?`Error clearing cart: ${n.message}`:"Unknown error occurred while clearing cart")}}async addCartAttributes(n={}){try{const r=await fetch(`${this.cartEndpoint}cart/update.js`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({attributes:{dbls_order_source:"direct_recommendation",dbls_session_id:rr(),...n}})});if(!r.ok){const o=await r.json();return this.createErrorResult(o.description||`Failed to update cart attributes: ${r.status}`)}return this.createSuccessResult(void 0,"Cart attributes updated successfully")}catch(r){return this.createErrorResult(r instanceof Error?`Error updating cart attributes: ${r.message}`:"Unknown error occurred while updating cart attributes")}}generateCartUrl(n){const r=Tk(n);if(!r.isValid)return"";const o=new URL("/cart",r.url);return o.searchParams.append("ref",`debales-ai-${new Date().toISOString()}`),o.searchParams.append("attributes[from]","debales-ai-chatbot"),o.searchParams.append("attributes[through]","add-to-cart"),o.searchParams.append("attributes[dbls_session_id]",rr()),o.searchParams.append("timestamp",Date.now().toString()),hf(o.toString())}}class age extends Dk{constructor(){var n,r;super();Qi(this,"platform",_i.MAGENTO);Qi(this,"checkoutEndpoint");Qi(this,"baseUrl");this.checkoutEndpoint=((n=window.checkout)==null?void 0:n.checkoutUrl)||"/",this.baseUrl=((r=window.checkout)==null?void 0:r.baseUrl)||"/"}normalizeCartData(n){return{items:n.items.map(r=>({id:parseInt(r.item_id),variant_id:parseInt(r.product_id),quantity:r.qty,title:r.product_name,price:r.product_price_value,properties:{name:r.product_name}})),total:parseFloat(n.subtotalAmount),itemCount:n.summary_count,currency:"USD",token:n.data_id.toString()}}async fetchCart(){try{const n=await fetch(`${this.baseUrl}customer/section/load/?sections=cart&update_section_id=false`),r=await n.json();if(!n.ok)return this.createErrorResult(`Failed to fetch cart: ${n.status}`);const o=r.cart;return this.createSuccessResult(this.normalizeCartData(o),"Cart fetched successfully")}catch(n){return this.createErrorResult(n instanceof Error?`Error fetching cart: ${n.message}`:"Unknown error occurred while fetching cart")}}async addToCart(n,r=1){var o;try{const a=(o=document.querySelector('input[name="form_key"]'))==null?void 0:o.value;if(!a)return this.createErrorResult("Form key not found");const l=await fetch(`${this.checkoutEndpoint}cart/add`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded","X-Requested-With":"XMLHttpRequest"},body:new URLSearchParams({product:n,qty:r.toString(),form_key:a})});if(!l.ok)return this.createErrorResult(`Failed to add item to cart: ${l.status}`);try{window.require(["Magento_Customer/js/customer-data"],d=>d.reload(["cart"],!0))}catch(d){console.warn("Failed to reload cart data:",d)}return this.createSuccessResult(void 0,`Successfully added ${r} item(s) to cart`)}catch(a){return this.createErrorResult(a instanceof Error?`Error adding to cart: ${a.message}`:"Unknown error occurred while adding to cart")}}async removeFromCart(n){return console.log("MethodNotImplemented: removeFromCart called",{itemId:n}),this.createSuccessResult(void 0,"Item removed from cart (mock)")}async updateQuantity(n){return console.log("MethodNotImplemented: updateQuantity called",{cartItem:n}),this.createSuccessResult(void 0,"Item quantity updated (mock)")}async clearCart(){return console.log("MethodNotImplemented: clearCart called"),this.createSuccessResult(void 0,"Cart cleared (mock)")}generateCartUrl(n){const r=new URL(`https://${n}/checkout/cart?ref=debales-ai-${new Date().toISOString()}&attributes[from]=debales-ai-chatbot&attributes[through]=add-to-cart`);return r.searchParams.append("timestamp",Date.now().toString()),r.toString()}generateProductUrl(n,r){const o=Tk(n);if(!o.isValid)return"";if(r.handle){const a=new URL(`/${r.handle}.html`,o.url);return hf(a.toString())}else return hf(r.link)}async addCartAttributes(n={}){return console.log("MethodNotImplemented: addCartAttributes called",{attributes:n}),this.createSuccessResult(void 0,"Cart attributes added (mock)")}}var Mk={exports:{}};function sge(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Ik={exports:{}};const lge=cV(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var uge=Ik.exports,uH;function Jn(){return uH||(uH=1,function(e,t){(function(n,r){e.exports=r()})(uge,function(){var n=n||function(r,o){var a;if(typeof window<"u"&&window.crypto&&(a=window.crypto),typeof self<"u"&&self.crypto&&(a=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(a=globalThis.crypto),!a&&typeof window<"u"&&window.msCrypto&&(a=window.msCrypto),!a&&typeof ql<"u"&&ql.crypto&&(a=ql.crypto),!a&&typeof sge=="function")try{a=lge}catch{}var l=function(){if(a){if(typeof a.getRandomValues=="function")try{return a.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof a.randomBytes=="function")try{return a.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},d=Object.create||function(){function R(){}return function(O){var I;return R.prototype=O,I=new R,R.prototype=null,I}}(),h={},p=h.lib={},y=p.Base=function(){return{extend:function(R){var O=d(this);return R&&O.mixIn(R),(!O.hasOwnProperty("init")||this.init===O.init)&&(O.init=function(){O.$super.init.apply(this,arguments)}),O.init.prototype=O,O.$super=this,O},create:function(){var R=this.extend();return R.init.apply(R,arguments),R},init:function(){},mixIn:function(R){for(var O in R)R.hasOwnProperty(O)&&(this[O]=R[O]);R.hasOwnProperty("toString")&&(this.toString=R.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),m=p.WordArray=y.extend({init:function(R,O){R=this.words=R||[],O!=o?this.sigBytes=O:this.sigBytes=R.length*4},toString:function(R){return(R||_).stringify(this)},concat:function(R){var O=this.words,I=R.words,L=this.sigBytes,B=R.sigBytes;if(this.clamp(),L%4)for(var H=0;H<B;H++){var G=I[H>>>2]>>>24-H%4*8&255;O[L+H>>>2]|=G<<24-(L+H)%4*8}else for(var W=0;W<B;W+=4)O[L+W>>>2]=I[W>>>2];return this.sigBytes+=B,this},clamp:function(){var R=this.words,O=this.sigBytes;R[O>>>2]&=4294967295<<32-O%4*8,R.length=r.ceil(O/4)},clone:function(){var R=y.clone.call(this);return R.words=this.words.slice(0),R},random:function(R){for(var O=[],I=0;I<R;I+=4)O.push(l());return new m.init(O,R)}}),x=h.enc={},_=x.Hex={stringify:function(R){for(var O=R.words,I=R.sigBytes,L=[],B=0;B<I;B++){var H=O[B>>>2]>>>24-B%4*8&255;L.push((H>>>4).toString(16)),L.push((H&15).toString(16))}return L.join("")},parse:function(R){for(var O=R.length,I=[],L=0;L<O;L+=2)I[L>>>3]|=parseInt(R.substr(L,2),16)<<24-L%8*4;return new m.init(I,O/2)}},w=x.Latin1={stringify:function(R){for(var O=R.words,I=R.sigBytes,L=[],B=0;B<I;B++){var H=O[B>>>2]>>>24-B%4*8&255;L.push(String.fromCharCode(H))}return L.join("")},parse:function(R){for(var O=R.length,I=[],L=0;L<O;L++)I[L>>>2]|=(R.charCodeAt(L)&255)<<24-L%4*8;return new m.init(I,O)}},T=x.Utf8={stringify:function(R){try{return decodeURIComponent(escape(w.stringify(R)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(R){return w.parse(unescape(encodeURIComponent(R)))}},A=p.BufferedBlockAlgorithm=y.extend({reset:function(){this._data=new m.init,this._nDataBytes=0},_append:function(R){typeof R=="string"&&(R=T.parse(R)),this._data.concat(R),this._nDataBytes+=R.sigBytes},_process:function(R){var O,I=this._data,L=I.words,B=I.sigBytes,H=this.blockSize,G=H*4,W=B/G;R?W=r.ceil(W):W=r.max((W|0)-this._minBufferSize,0);var z=W*H,Q=r.min(z*4,B);if(z){for(var J=0;J<z;J+=H)this._doProcessBlock(L,J);O=L.splice(0,z),I.sigBytes-=Q}return new m.init(O,Q)},clone:function(){var R=y.clone.call(this);return R._data=this._data.clone(),R},_minBufferSize:0});p.Hasher=A.extend({cfg:y.extend(),init:function(R){this.cfg=this.cfg.extend(R),this.reset()},reset:function(){A.reset.call(this),this._doReset()},update:function(R){return this._append(R),this._process(),this},finalize:function(R){R&&this._append(R);var O=this._doFinalize();return O},blockSize:16,_createHelper:function(R){return function(O,I){return new R.init(I).finalize(O)}},_createHmacHelper:function(R){return function(O,I){return new E.HMAC.init(R,I).finalize(O)}}});var E=h.algo={};return h}(Math);return n})}(Ik)),Ik.exports}var $k={exports:{}},cge=$k.exports,cH;function Bk(){return cH||(cH=1,function(e,t){(function(n,r){e.exports=r(Jn())})(cge,function(n){return function(r){var o=n,a=o.lib,l=a.Base,d=a.WordArray,h=o.x64={};h.Word=l.extend({init:function(p,y){this.high=p,this.low=y}}),h.WordArray=l.extend({init:function(p,y){p=this.words=p||[],y!=r?this.sigBytes=y:this.sigBytes=p.length*8},toX32:function(){for(var p=this.words,y=p.length,m=[],x=0;x<y;x++){var _=p[x];m.push(_.high),m.push(_.low)}return d.create(m,this.sigBytes)},clone:function(){for(var p=l.clone.call(this),y=p.words=this.words.slice(0),m=y.length,x=0;x<m;x++)y[x]=y[x].clone();return p}})}(),n})}($k)),$k.exports}var Lk={exports:{}},fge=Lk.exports,fH;function dge(){return fH||(fH=1,function(e,t){(function(n,r){e.exports=r(Jn())})(fge,function(n){return function(){if(typeof ArrayBuffer=="function"){var r=n,o=r.lib,a=o.WordArray,l=a.init,d=a.init=function(h){if(h instanceof ArrayBuffer&&(h=new Uint8Array(h)),(h instanceof Int8Array||typeof Uint8ClampedArray<"u"&&h instanceof Uint8ClampedArray||h instanceof Int16Array||h instanceof Uint16Array||h instanceof Int32Array||h instanceof Uint32Array||h instanceof Float32Array||h instanceof Float64Array)&&(h=new Uint8Array(h.buffer,h.byteOffset,h.byteLength)),h instanceof Uint8Array){for(var p=h.byteLength,y=[],m=0;m<p;m++)y[m>>>2]|=h[m]<<24-m%4*8;l.call(this,y,p)}else l.apply(this,arguments)};d.prototype=a}}(),n.lib.WordArray})}(Lk)),Lk.exports}var Nk={exports:{}},hge=Nk.exports,dH;function pge(){return dH||(dH=1,function(e,t){(function(n,r){e.exports=r(Jn())})(hge,function(n){return function(){var r=n,o=r.lib,a=o.WordArray,l=r.enc;l.Utf16=l.Utf16BE={stringify:function(h){for(var p=h.words,y=h.sigBytes,m=[],x=0;x<y;x+=2){var _=p[x>>>2]>>>16-x%4*8&65535;m.push(String.fromCharCode(_))}return m.join("")},parse:function(h){for(var p=h.length,y=[],m=0;m<p;m++)y[m>>>1]|=h.charCodeAt(m)<<16-m%2*16;return a.create(y,p*2)}},l.Utf16LE={stringify:function(h){for(var p=h.words,y=h.sigBytes,m=[],x=0;x<y;x+=2){var _=d(p[x>>>2]>>>16-x%4*8&65535);m.push(String.fromCharCode(_))}return m.join("")},parse:function(h){for(var p=h.length,y=[],m=0;m<p;m++)y[m>>>1]|=d(h.charCodeAt(m)<<16-m%2*16);return a.create(y,p*2)}};function d(h){return h<<8&4278255360|h>>>8&16711935}}(),n.enc.Utf16})}(Nk)),Nk.exports}var zk={exports:{}},gge=zk.exports,hH;function Up(){return hH||(hH=1,function(e,t){(function(n,r){e.exports=r(Jn())})(gge,function(n){return function(){var r=n,o=r.lib,a=o.WordArray,l=r.enc;l.Base64={stringify:function(h){var p=h.words,y=h.sigBytes,m=this._map;h.clamp();for(var x=[],_=0;_<y;_+=3)for(var w=p[_>>>2]>>>24-_%4*8&255,T=p[_+1>>>2]>>>24-(_+1)%4*8&255,A=p[_+2>>>2]>>>24-(_+2)%4*8&255,E=w<<16|T<<8|A,R=0;R<4&&_+R*.75<y;R++)x.push(m.charAt(E>>>6*(3-R)&63));var O=m.charAt(64);if(O)for(;x.length%4;)x.push(O);return x.join("")},parse:function(h){var p=h.length,y=this._map,m=this._reverseMap;if(!m){m=this._reverseMap=[];for(var x=0;x<y.length;x++)m[y.charCodeAt(x)]=x}var _=y.charAt(64);if(_){var w=h.indexOf(_);w!==-1&&(p=w)}return d(h,p,m)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="};function d(h,p,y){for(var m=[],x=0,_=0;_<p;_++)if(_%4){var w=y[h.charCodeAt(_-1)]<<_%4*2,T=y[h.charCodeAt(_)]>>>6-_%4*2,A=w|T;m[x>>>2]|=A<<24-x%4*8,x++}return a.create(m,x)}}(),n.enc.Base64})}(zk)),zk.exports}var Fk={exports:{}},mge=Fk.exports,pH;function vge(){return pH||(pH=1,function(e,t){(function(n,r){e.exports=r(Jn())})(mge,function(n){return function(){var r=n,o=r.lib,a=o.WordArray,l=r.enc;l.Base64url={stringify:function(h,p){p===void 0&&(p=!0);var y=h.words,m=h.sigBytes,x=p?this._safe_map:this._map;h.clamp();for(var _=[],w=0;w<m;w+=3)for(var T=y[w>>>2]>>>24-w%4*8&255,A=y[w+1>>>2]>>>24-(w+1)%4*8&255,E=y[w+2>>>2]>>>24-(w+2)%4*8&255,R=T<<16|A<<8|E,O=0;O<4&&w+O*.75<m;O++)_.push(x.charAt(R>>>6*(3-O)&63));var I=x.charAt(64);if(I)for(;_.length%4;)_.push(I);return _.join("")},parse:function(h,p){p===void 0&&(p=!0);var y=h.length,m=p?this._safe_map:this._map,x=this._reverseMap;if(!x){x=this._reverseMap=[];for(var _=0;_<m.length;_++)x[m.charCodeAt(_)]=_}var w=m.charAt(64);if(w){var T=h.indexOf(w);T!==-1&&(y=T)}return d(h,y,x)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",_safe_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"};function d(h,p,y){for(var m=[],x=0,_=0;_<p;_++)if(_%4){var w=y[h.charCodeAt(_-1)]<<_%4*2,T=y[h.charCodeAt(_)]>>>6-_%4*2,A=w|T;m[x>>>2]|=A<<24-x%4*8,x++}return a.create(m,x)}}(),n.enc.Base64url})}(Fk)),Fk.exports}var Uk={exports:{}},yge=Uk.exports,gH;function jp(){return gH||(gH=1,function(e,t){(function(n,r){e.exports=r(Jn())})(yge,function(n){return function(r){var o=n,a=o.lib,l=a.WordArray,d=a.Hasher,h=o.algo,p=[];(function(){for(var T=0;T<64;T++)p[T]=r.abs(r.sin(T+1))*4294967296|0})();var y=h.MD5=d.extend({_doReset:function(){this._hash=new l.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(T,A){for(var E=0;E<16;E++){var R=A+E,O=T[R];T[R]=(O<<8|O>>>24)&16711935|(O<<24|O>>>8)&4278255360}var I=this._hash.words,L=T[A+0],B=T[A+1],H=T[A+2],G=T[A+3],W=T[A+4],z=T[A+5],Q=T[A+6],J=T[A+7],re=T[A+8],ee=T[A+9],fe=T[A+10],le=T[A+11],ne=T[A+12],me=T[A+13],Ce=T[A+14],N=T[A+15],j=I[0],te=I[1],U=I[2],ue=I[3];j=m(j,te,U,ue,L,7,p[0]),ue=m(ue,j,te,U,B,12,p[1]),U=m(U,ue,j,te,H,17,p[2]),te=m(te,U,ue,j,G,22,p[3]),j=m(j,te,U,ue,W,7,p[4]),ue=m(ue,j,te,U,z,12,p[5]),U=m(U,ue,j,te,Q,17,p[6]),te=m(te,U,ue,j,J,22,p[7]),j=m(j,te,U,ue,re,7,p[8]),ue=m(ue,j,te,U,ee,12,p[9]),U=m(U,ue,j,te,fe,17,p[10]),te=m(te,U,ue,j,le,22,p[11]),j=m(j,te,U,ue,ne,7,p[12]),ue=m(ue,j,te,U,me,12,p[13]),U=m(U,ue,j,te,Ce,17,p[14]),te=m(te,U,ue,j,N,22,p[15]),j=x(j,te,U,ue,B,5,p[16]),ue=x(ue,j,te,U,Q,9,p[17]),U=x(U,ue,j,te,le,14,p[18]),te=x(te,U,ue,j,L,20,p[19]),j=x(j,te,U,ue,z,5,p[20]),ue=x(ue,j,te,U,fe,9,p[21]),U=x(U,ue,j,te,N,14,p[22]),te=x(te,U,ue,j,W,20,p[23]),j=x(j,te,U,ue,ee,5,p[24]),ue=x(ue,j,te,U,Ce,9,p[25]),U=x(U,ue,j,te,G,14,p[26]),te=x(te,U,ue,j,re,20,p[27]),j=x(j,te,U,ue,me,5,p[28]),ue=x(ue,j,te,U,H,9,p[29]),U=x(U,ue,j,te,J,14,p[30]),te=x(te,U,ue,j,ne,20,p[31]),j=_(j,te,U,ue,z,4,p[32]),ue=_(ue,j,te,U,re,11,p[33]),U=_(U,ue,j,te,le,16,p[34]),te=_(te,U,ue,j,Ce,23,p[35]),j=_(j,te,U,ue,B,4,p[36]),ue=_(ue,j,te,U,W,11,p[37]),U=_(U,ue,j,te,J,16,p[38]),te=_(te,U,ue,j,fe,23,p[39]),j=_(j,te,U,ue,me,4,p[40]),ue=_(ue,j,te,U,L,11,p[41]),U=_(U,ue,j,te,G,16,p[42]),te=_(te,U,ue,j,Q,23,p[43]),j=_(j,te,U,ue,ee,4,p[44]),ue=_(ue,j,te,U,ne,11,p[45]),U=_(U,ue,j,te,N,16,p[46]),te=_(te,U,ue,j,H,23,p[47]),j=w(j,te,U,ue,L,6,p[48]),ue=w(ue,j,te,U,J,10,p[49]),U=w(U,ue,j,te,Ce,15,p[50]),te=w(te,U,ue,j,z,21,p[51]),j=w(j,te,U,ue,ne,6,p[52]),ue=w(ue,j,te,U,G,10,p[53]),U=w(U,ue,j,te,fe,15,p[54]),te=w(te,U,ue,j,B,21,p[55]),j=w(j,te,U,ue,re,6,p[56]),ue=w(ue,j,te,U,N,10,p[57]),U=w(U,ue,j,te,Q,15,p[58]),te=w(te,U,ue,j,me,21,p[59]),j=w(j,te,U,ue,W,6,p[60]),ue=w(ue,j,te,U,le,10,p[61]),U=w(U,ue,j,te,H,15,p[62]),te=w(te,U,ue,j,ee,21,p[63]),I[0]=I[0]+j|0,I[1]=I[1]+te|0,I[2]=I[2]+U|0,I[3]=I[3]+ue|0},_doFinalize:function(){var T=this._data,A=T.words,E=this._nDataBytes*8,R=T.sigBytes*8;A[R>>>5]|=128<<24-R%32;var O=r.floor(E/4294967296),I=E;A[(R+64>>>9<<4)+15]=(O<<8|O>>>24)&16711935|(O<<24|O>>>8)&4278255360,A[(R+64>>>9<<4)+14]=(I<<8|I>>>24)&16711935|(I<<24|I>>>8)&4278255360,T.sigBytes=(A.length+1)*4,this._process();for(var L=this._hash,B=L.words,H=0;H<4;H++){var G=B[H];B[H]=(G<<8|G>>>24)&16711935|(G<<24|G>>>8)&4278255360}return L},clone:function(){var T=d.clone.call(this);return T._hash=this._hash.clone(),T}});function m(T,A,E,R,O,I,L){var B=T+(A&E|~A&R)+O+L;return(B<<I|B>>>32-I)+A}function x(T,A,E,R,O,I,L){var B=T+(A&R|E&~R)+O+L;return(B<<I|B>>>32-I)+A}function _(T,A,E,R,O,I,L){var B=T+(A^E^R)+O+L;return(B<<I|B>>>32-I)+A}function w(T,A,E,R,O,I,L){var B=T+(E^(A|~R))+O+L;return(B<<I|B>>>32-I)+A}o.MD5=d._createHelper(y),o.HmacMD5=d._createHmacHelper(y)}(Math),n.MD5})}(Uk)),Uk.exports}var jk={exports:{}},xge=jk.exports,mH;function vH(){return mH||(mH=1,function(e,t){(function(n,r){e.exports=r(Jn())})(xge,function(n){return function(){var r=n,o=r.lib,a=o.WordArray,l=o.Hasher,d=r.algo,h=[],p=d.SHA1=l.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(y,m){for(var x=this._hash.words,_=x[0],w=x[1],T=x[2],A=x[3],E=x[4],R=0;R<80;R++){if(R<16)h[R]=y[m+R]|0;else{var O=h[R-3]^h[R-8]^h[R-14]^h[R-16];h[R]=O<<1|O>>>31}var I=(_<<5|_>>>27)+E+h[R];R<20?I+=(w&T|~w&A)+1518500249:R<40?I+=(w^T^A)+1859775393:R<60?I+=(w&T|w&A|T&A)-1894007588:I+=(w^T^A)-899497514,E=A,A=T,T=w<<30|w>>>2,w=_,_=I}x[0]=x[0]+_|0,x[1]=x[1]+w|0,x[2]=x[2]+T|0,x[3]=x[3]+A|0,x[4]=x[4]+E|0},_doFinalize:function(){var y=this._data,m=y.words,x=this._nDataBytes*8,_=y.sigBytes*8;return m[_>>>5]|=128<<24-_%32,m[(_+64>>>9<<4)+14]=Math.floor(x/4294967296),m[(_+64>>>9<<4)+15]=x,y.sigBytes=m.length*4,this._process(),this._hash},clone:function(){var y=l.clone.call(this);return y._hash=this._hash.clone(),y}});r.SHA1=l._createHelper(p),r.HmacSHA1=l._createHmacHelper(p)}(),n.SHA1})}(jk)),jk.exports}var Pk={exports:{}},bge=Pk.exports,yH;function O8(){return yH||(yH=1,function(e,t){(function(n,r){e.exports=r(Jn())})(bge,function(n){return function(r){var o=n,a=o.lib,l=a.WordArray,d=a.Hasher,h=o.algo,p=[],y=[];(function(){function _(E){for(var R=r.sqrt(E),O=2;O<=R;O++)if(!(E%O))return!1;return!0}function w(E){return(E-(E|0))*4294967296|0}for(var T=2,A=0;A<64;)_(T)&&(A<8&&(p[A]=w(r.pow(T,.5))),y[A]=w(r.pow(T,.3333333333333333)),A++),T++})();var m=[],x=h.SHA256=d.extend({_doReset:function(){this._hash=new l.init(p.slice(0))},_doProcessBlock:function(_,w){for(var T=this._hash.words,A=T[0],E=T[1],R=T[2],O=T[3],I=T[4],L=T[5],B=T[6],H=T[7],G=0;G<64;G++){if(G<16)m[G]=_[w+G]|0;else{var W=m[G-15],z=(W<<25|W>>>7)^(W<<14|W>>>18)^W>>>3,Q=m[G-2],J=(Q<<15|Q>>>17)^(Q<<13|Q>>>19)^Q>>>10;m[G]=z+m[G-7]+J+m[G-16]}var re=I&L^~I&B,ee=A&E^A&R^E&R,fe=(A<<30|A>>>2)^(A<<19|A>>>13)^(A<<10|A>>>22),le=(I<<26|I>>>6)^(I<<21|I>>>11)^(I<<7|I>>>25),ne=H+le+re+y[G]+m[G],me=fe+ee;H=B,B=L,L=I,I=O+ne|0,O=R,R=E,E=A,A=ne+me|0}T[0]=T[0]+A|0,T[1]=T[1]+E|0,T[2]=T[2]+R|0,T[3]=T[3]+O|0,T[4]=T[4]+I|0,T[5]=T[5]+L|0,T[6]=T[6]+B|0,T[7]=T[7]+H|0},_doFinalize:function(){var _=this._data,w=_.words,T=this._nDataBytes*8,A=_.sigBytes*8;return w[A>>>5]|=128<<24-A%32,w[(A+64>>>9<<4)+14]=r.floor(T/4294967296),w[(A+64>>>9<<4)+15]=T,_.sigBytes=w.length*4,this._process(),this._hash},clone:function(){var _=d.clone.call(this);return _._hash=this._hash.clone(),_}});o.SHA256=d._createHelper(x),o.HmacSHA256=d._createHmacHelper(x)}(Math),n.SHA256})}(Pk)),Pk.exports}var Hk={exports:{}},_ge=Hk.exports,xH;function Sge(){return xH||(xH=1,function(e,t){(function(n,r,o){e.exports=r(Jn(),O8())})(_ge,function(n){return function(){var r=n,o=r.lib,a=o.WordArray,l=r.algo,d=l.SHA256,h=l.SHA224=d.extend({_doReset:function(){this._hash=new a.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var p=d._doFinalize.call(this);return p.sigBytes-=4,p}});r.SHA224=d._createHelper(h),r.HmacSHA224=d._createHmacHelper(h)}(),n.SHA224})}(Hk)),Hk.exports}var qk={exports:{}},wge=qk.exports,bH;function _H(){return bH||(bH=1,function(e,t){(function(n,r,o){e.exports=r(Jn(),Bk())})(wge,function(n){return function(){var r=n,o=r.lib,a=o.Hasher,l=r.x64,d=l.Word,h=l.WordArray,p=r.algo;function y(){return d.create.apply(d,arguments)}var m=[y(1116352408,3609767458),y(1899447441,602891725),y(3049323471,3964484399),y(3921009573,2173295548),y(961987163,4081628472),y(1508970993,3053834265),y(2453635748,2937671579),y(2870763221,3664609560),y(3624381080,2734883394),y(310598401,1164996542),y(607225278,1323610764),y(1426881987,3590304994),y(1925078388,4068182383),y(2162078206,991336113),y(2614888103,633803317),y(3248222580,3479774868),y(3835390401,2666613458),y(4022224774,944711139),y(264347078,2341262773),y(604807628,2007800933),y(770255983,1495990901),y(1249150122,1856431235),y(1555081692,3175218132),y(1996064986,2198950837),y(2554220882,3999719339),y(2821834349,766784016),y(2952996808,2566594879),y(3210313671,3203337956),y(3336571891,1034457026),y(3584528711,2466948901),y(113926993,3758326383),y(338241895,168717936),y(666307205,1188179964),y(773529912,1546045734),y(1294757372,1522805485),y(1396182291,2643833823),y(1695183700,2343527390),y(1986661051,1014477480),y(2177026350,1206759142),y(2456956037,344077627),y(2730485921,1290863460),y(2820302411,3158454273),y(3259730800,3505952657),y(3345764771,106217008),y(3516065817,3606008344),y(3600352804,1432725776),y(4094571909,1467031594),y(275423344,851169720),y(430227734,3100823752),y(506948616,1363258195),y(659060556,3750685593),y(883997877,3785050280),y(958139571,3318307427),y(1322822218,3812723403),y(1537002063,2003034995),y(1747873779,3602036899),y(1955562222,1575990012),y(2024104815,1125592928),y(2227730452,2716904306),y(2361852424,442776044),y(2428436474,593698344),y(2756734187,3733110249),y(3204031479,2999351573),y(3329325298,3815920427),y(3391569614,3928383900),y(3515267271,566280711),y(3940187606,3454069534),y(4118630271,4000239992),y(116418474,1914138554),y(174292421,2731055270),y(289380356,3203993006),y(460393269,320620315),y(685471733,587496836),y(852142971,1086792851),y(1017036298,365543100),y(1126000580,2618297676),y(1288033470,3409855158),y(1501505948,4234509866),y(1607167915,987167468),y(1816402316,1246189591)],x=[];(function(){for(var w=0;w<80;w++)x[w]=y()})();var _=p.SHA512=a.extend({_doReset:function(){this._hash=new h.init([new d.init(1779033703,4089235720),new d.init(3144134277,2227873595),new d.init(1013904242,4271175723),new d.init(2773480762,1595750129),new d.init(1359893119,2917565137),new d.init(2600822924,725511199),new d.init(528734635,4215389547),new d.init(1541459225,327033209)])},_doProcessBlock:function(w,T){for(var A=this._hash.words,E=A[0],R=A[1],O=A[2],I=A[3],L=A[4],B=A[5],H=A[6],G=A[7],W=E.high,z=E.low,Q=R.high,J=R.low,re=O.high,ee=O.low,fe=I.high,le=I.low,ne=L.high,me=L.low,Ce=B.high,N=B.low,j=H.high,te=H.low,U=G.high,ue=G.low,Te=W,Ee=z,st=Q,Ve=J,Je=re,Tt=ee,Bt=fe,qe=le,ot=ne,ct=me,Ut=Ce,Qt=N,ht=j,ie=te,se=U,ge=ue,Ae=0;Ae<80;Ae++){var Be,Ue,pt=x[Ae];if(Ae<16)Ue=pt.high=w[T+Ae*2]|0,Be=pt.low=w[T+Ae*2+1]|0;else{var Et=x[Ae-15],be=Et.high,Me=Et.low,Rt=(be>>>1|Me<<31)^(be>>>8|Me<<24)^be>>>7,ft=(Me>>>1|be<<31)^(Me>>>8|be<<24)^(Me>>>7|be<<25),Lt=x[Ae-2],Ot=Lt.high,rn=Lt.low,Jt=(Ot>>>19|rn<<13)^(Ot<<3|rn>>>29)^Ot>>>6,mn=(rn>>>19|Ot<<13)^(rn<<3|Ot>>>29)^(rn>>>6|Ot<<26),_t=x[Ae-7],Xt=_t.high,Ct=_t.low,V=x[Ae-16],ye=V.high,at=V.low;Be=ft+Ct,Ue=Rt+Xt+(Be>>>0<ft>>>0?1:0),Be=Be+mn,Ue=Ue+Jt+(Be>>>0<mn>>>0?1:0),Be=Be+at,Ue=Ue+ye+(Be>>>0<at>>>0?1:0),pt.high=Ue,pt.low=Be}var ut=ot&Ut^~ot&ht,St=ct&Qt^~ct&ie,Ht=Te&st^Te&Je^st&Je,Pt=Ee&Ve^Ee&Tt^Ve&Tt,Wt=(Te>>>28|Ee<<4)^(Te<<30|Ee>>>2)^(Te<<25|Ee>>>7),Gt=(Ee>>>28|Te<<4)^(Ee<<30|Te>>>2)^(Ee<<25|Te>>>7),fn=(ot>>>14|ct<<18)^(ot>>>18|ct<<14)^(ot<<23|ct>>>9),_r=(ct>>>14|ot<<18)^(ct>>>18|ot<<14)^(ct<<23|ot>>>9),ir=m[Ae],Kr=ir.high,on=ir.low,Dn=ge+_r,En=se+fn+(Dn>>>0<ge>>>0?1:0),Dn=Dn+St,En=En+ut+(Dn>>>0<St>>>0?1:0),Dn=Dn+on,En=En+Kr+(Dn>>>0<on>>>0?1:0),Dn=Dn+Be,En=En+Ue+(Dn>>>0<Be>>>0?1:0),po=Gt+Pt,or=Wt+Ht+(po>>>0<Gt>>>0?1:0);se=ht,ge=ie,ht=Ut,ie=Qt,Ut=ot,Qt=ct,ct=qe+Dn|0,ot=Bt+En+(ct>>>0<qe>>>0?1:0)|0,Bt=Je,qe=Tt,Je=st,Tt=Ve,st=Te,Ve=Ee,Ee=Dn+po|0,Te=En+or+(Ee>>>0<Dn>>>0?1:0)|0}z=E.low=z+Ee,E.high=W+Te+(z>>>0<Ee>>>0?1:0),J=R.low=J+Ve,R.high=Q+st+(J>>>0<Ve>>>0?1:0),ee=O.low=ee+Tt,O.high=re+Je+(ee>>>0<Tt>>>0?1:0),le=I.low=le+qe,I.high=fe+Bt+(le>>>0<qe>>>0?1:0),me=L.low=me+ct,L.high=ne+ot+(me>>>0<ct>>>0?1:0),N=B.low=N+Qt,B.high=Ce+Ut+(N>>>0<Qt>>>0?1:0),te=H.low=te+ie,H.high=j+ht+(te>>>0<ie>>>0?1:0),ue=G.low=ue+ge,G.high=U+se+(ue>>>0<ge>>>0?1:0)},_doFinalize:function(){var w=this._data,T=w.words,A=this._nDataBytes*8,E=w.sigBytes*8;T[E>>>5]|=128<<24-E%32,T[(E+128>>>10<<5)+30]=Math.floor(A/4294967296),T[(E+128>>>10<<5)+31]=A,w.sigBytes=T.length*4,this._process();var R=this._hash.toX32();return R},clone:function(){var w=a.clone.call(this);return w._hash=this._hash.clone(),w},blockSize:1024/32});r.SHA512=a._createHelper(_),r.HmacSHA512=a._createHmacHelper(_)}(),n.SHA512})}(qk)),qk.exports}var Gk={exports:{}},Cge=Gk.exports,SH;function Ege(){return SH||(SH=1,function(e,t){(function(n,r,o){e.exports=r(Jn(),Bk(),_H())})(Cge,function(n){return function(){var r=n,o=r.x64,a=o.Word,l=o.WordArray,d=r.algo,h=d.SHA512,p=d.SHA384=h.extend({_doReset:function(){this._hash=new l.init([new a.init(3418070365,3238371032),new a.init(1654270250,914150663),new a.init(2438529370,812702999),new a.init(355462360,4144912697),new a.init(1731405415,4290775857),new a.init(2394180231,1750603025),new a.init(3675008525,1694076839),new a.init(1203062813,3204075428)])},_doFinalize:function(){var y=h._doFinalize.call(this);return y.sigBytes-=16,y}});r.SHA384=h._createHelper(p),r.HmacSHA384=h._createHmacHelper(p)}(),n.SHA384})}(Gk)),Gk.exports}var Vk={exports:{}},Age=Vk.exports,wH;function kge(){return wH||(wH=1,function(e,t){(function(n,r,o){e.exports=r(Jn(),Bk())})(Age,function(n){return function(r){var o=n,a=o.lib,l=a.WordArray,d=a.Hasher,h=o.x64,p=h.Word,y=o.algo,m=[],x=[],_=[];(function(){for(var A=1,E=0,R=0;R<24;R++){m[A+5*E]=(R+1)*(R+2)/2%64;var O=E%5,I=(2*A+3*E)%5;A=O,E=I}for(var A=0;A<5;A++)for(var E=0;E<5;E++)x[A+5*E]=E+(2*A+3*E)%5*5;for(var L=1,B=0;B<24;B++){for(var H=0,G=0,W=0;W<7;W++){if(L&1){var z=(1<<W)-1;z<32?G^=1<<z:H^=1<<z-32}L&128?L=L<<1^113:L<<=1}_[B]=p.create(H,G)}})();var w=[];(function(){for(var A=0;A<25;A++)w[A]=p.create()})();var T=y.SHA3=d.extend({cfg:d.cfg.extend({outputLength:512}),_doReset:function(){for(var A=this._state=[],E=0;E<25;E++)A[E]=new p.init;this.blockSize=(1600-2*this.cfg.outputLength)/32},_doProcessBlock:function(A,E){for(var R=this._state,O=this.blockSize/2,I=0;I<O;I++){var L=A[E+2*I],B=A[E+2*I+1];L=(L<<8|L>>>24)&16711935|(L<<24|L>>>8)&4278255360,B=(B<<8|B>>>24)&16711935|(B<<24|B>>>8)&4278255360;var H=R[I];H.high^=B,H.low^=L}for(var G=0;G<24;G++){for(var W=0;W<5;W++){for(var z=0,Q=0,J=0;J<5;J++){var H=R[W+5*J];z^=H.high,Q^=H.low}var re=w[W];re.high=z,re.low=Q}for(var W=0;W<5;W++)for(var ee=w[(W+4)%5],fe=w[(W+1)%5],le=fe.high,ne=fe.low,z=ee.high^(le<<1|ne>>>31),Q=ee.low^(ne<<1|le>>>31),J=0;J<5;J++){var H=R[W+5*J];H.high^=z,H.low^=Q}for(var me=1;me<25;me++){var z,Q,H=R[me],Ce=H.high,N=H.low,j=m[me];j<32?(z=Ce<<j|N>>>32-j,Q=N<<j|Ce>>>32-j):(z=N<<j-32|Ce>>>64-j,Q=Ce<<j-32|N>>>64-j);var te=w[x[me]];te.high=z,te.low=Q}var U=w[0],ue=R[0];U.high=ue.high,U.low=ue.low;for(var W=0;W<5;W++)for(var J=0;J<5;J++){var me=W+5*J,H=R[me],Te=w[me],Ee=w[(W+1)%5+5*J],st=w[(W+2)%5+5*J];H.high=Te.high^~Ee.high&st.high,H.low=Te.low^~Ee.low&st.low}var H=R[0],Ve=_[G];H.high^=Ve.high,H.low^=Ve.low}},_doFinalize:function(){var A=this._data,E=A.words;this._nDataBytes*8;var R=A.sigBytes*8,O=this.blockSize*32;E[R>>>5]|=1<<24-R%32,E[(r.ceil((R+1)/O)*O>>>5)-1]|=128,A.sigBytes=E.length*4,this._process();for(var I=this._state,L=this.cfg.outputLength/8,B=L/8,H=[],G=0;G<B;G++){var W=I[G],z=W.high,Q=W.low;z=(z<<8|z>>>24)&16711935|(z<<24|z>>>8)&4278255360,Q=(Q<<8|Q>>>24)&16711935|(Q<<24|Q>>>8)&4278255360,H.push(Q),H.push(z)}return new l.init(H,L)},clone:function(){for(var A=d.clone.call(this),E=A._state=this._state.slice(0),R=0;R<25;R++)E[R]=E[R].clone();return A}});o.SHA3=d._createHelper(T),o.HmacSHA3=d._createHmacHelper(T)}(Math),n.SHA3})}(Vk)),Vk.exports}var Yk={exports:{}},Tge=Yk.exports,CH;function Rge(){return CH||(CH=1,function(e,t){(function(n,r){e.exports=r(Jn())})(Tge,function(n){/** @preserve
5201
+ => User Action: Klaviyo form closed`}return""},Y=ce=>{ce instanceof CustomEvent&&Se(ce)};return window.addEventListener("klaviyoForms",Y),()=>{window.removeEventListener("klaviyoForms",Y)}},[ot,t,r]),Z.useEffect(()=>{const Se=ge.current;return Je&&Se?(Se.addEventListener("scroll",En),()=>{Se&&Se.removeEventListener("scroll",En)}):()=>{}},[Je,En]);const[ar,Go]=Z.useState(!1),Re=Q==="Highest"?"120px":Q==="Higher"?"60px":"15px",rt=async()=>{try{const Se=await fetch(`${Di}/api/wordpress/support`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({chatid:rr()+e,nameSpace:e,userName:ft.name,userEmail:ft.email,userMessage:ft.message,tag:"support"})});if(Se.ok){const tt=`support-confirm-${Date.now()}`;m(Y=>[...Y,{text:"Thanks for reaching out! Our support team has received your request and will get back to you within 24 hours.<br>In the meantime, feel free to continue chatting with me - I'll do my best to help!",isBot:!0,leading_queries:Ot,conversationId:tt}]),d(tt),Ct(Y=>({...Y,leadingQueries:!0})),rn([]),console.log("Connected to support with existing user info:",Po())}else{const tt=await Se.json();console.error("Failed to connect to support:",tt),m(Y=>[...Y,{text:"Sorry, we couldn't connect you to support at the moment.<br>Please try again later.",isBot:!0}])}}catch{m(tt=>[...tt,{text:"Sorry, we couldn't connect you to support at the moment.<br>Please try again later.",isBot:!0}])}},vt=()=>{const Se=Po();let tt=[];const Y=h[h.length-1];Y!=null&&Y.leading_queries&&Y.leading_queries.length>0?tt=Y.leading_queries:h.length<=1&&(tt=j.flatMap(ce=>Array.isArray(ce)?ce.map(ve=>ve.question):[ce.question]).slice(0,4)),rn(tt),Se&&Se.name&&Se.email&&Lt({name:Se==null?void 0:Se.name,email:Se==null?void 0:Se.email,message:""}),m(ce=>[...ce,{text:"Please provide your name, email and message to connect with support.",isBot:!0}]),Rt(!0)},Vt=async Se=>{Se.preventDefault();const tt={name:"",email:"",message:""};let Y=!0;const ce=ft.name.trim(),ve=ft.message.trim();ce||(tt.name="Name cannot be empty or just whitespace.",Y=!1),(!ft.email||!Pm.isEmail(ft.email))&&(tt.email="Please enter a valid email address.",Y=!1),ve||(tt.message="Message cannot be empty or just whitespace.",Y=!1),mn(tt),Y&&(of({name:ce,email:ft.email}),Rt(!1),m(Oe=>Oe.slice(0,-1)),await rt())},[lt,je]=Z.useState({});return Z.useEffect(()=>{Gt&&(h.forEach((Se,tt)=>{if(!Se.isBot)return;const Y=$p(Se.text);if(!(tt in lt)||lt[tt]<Y.length){let ce;const ve=Oe=>{Oe<Y.length&&(ce=setTimeout(()=>{je(we=>({...we,[tt]:Oe+1})),ve(Oe+1)},Dn))};return tt in lt?ve(lt[tt]):(je(Oe=>({...Oe,[tt]:1})),ve(1)),()=>clearTimeout(ce)}}),je(Se=>{const tt={};return h.forEach((Y,ce)=>{Se[ce]!==void 0&&(tt[ce]=Se[ce])}),tt}))},[h,Gt]),!t||t.show_bot===!1||a?null:M.jsxs(Zw,{theme:uE(t,e),children:[M.jsx("link",{rel:"preconnect",href:"https://fonts.googleapis.com"}),M.jsx("link",{rel:"preconnect",href:"https://fonts.gstatic.com",crossOrigin:"anonymous"}),M.jsx("link",{href:"https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap",rel:"stylesheet"}),M.jsx("link",{href:"https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,100;0,300;0,400;0,700;0,900;1,100;1,300;1,400;1,700;1,900&display=swap",rel:"stylesheet"}),M.jsx(V0e,{}),M.jsxs(C0e,{$topOffset:Re,$isLeft:W,children:[!Je&&j.length>0&&j[U]&&ne&&M.jsx(q0e,{className:Ce?"visible":"",$botId:e,$iconSize:H,$removeLogoBackground:t.removeLogoBackground,topOffset:Re,style:{display:"flex",flexDirection:"column",alignItems:"center",opacity:Ce?1:0,transition:"opacity 0.3s ease-in-out"},children:j.length>0&&j[U]&&M.jsx(G0e,{children:M.jsx(_0e,{messages:[{question:j[U].question,isHighlighted:j[U].isHighlighted??!1,show_for:(ee==null?void 0:ee.show_for)||4e3,hide_timing:(ee==null?void 0:ee.hide_timing)||4e3}],botId:e,uiData:t,onClose:()=>{Ue(Se=>{const tt=new Set(Se);return tt.add(j[U].question),tt})},onClick:()=>{const Se=j[U];pt(!0,"suggested_question_clicked"),Ue(tt=>{const Y=new Set(tt);return Y.add(Se.question),Y}),window.DebalesChat.track(an.SUGGESTED_QUESTION_CLICKED,{suggested_question:Se}),E?(Wt(!1),fn(!0),A(!0),R(Se)):(Wt(!1),fn(!0),r({message:Se.Follow_up_Question??Se.question,answer:Se.answer,products:Se.products,fromKlaviyo:!1,leading_queries:Se.leading_queries,followUpQuestion:Se.Follow_up_Question,messType:"suggested_question"}))}})},j[U].question)}),M.jsxs(E0e,{$topOffset:Re,$removeLogoBackground:t.removeLogoBackground,style:{display:Je||ne?"none":"flex"},children:[M.jsx(A0e,{$showAnimation:t.enableChatButtonBackgroundAnimation??!1,$animationType:"Ping",$animationColor:t.chatButtonBackgroundAnimationColor||"#f48722",$backgroundColor:t.backgroundColor||"#fff",$removeLogoBackground:t.removeLogoBackground,$topOffset:Re,$iconSize:H}),M.jsxs(k0e,{$backgroundColor:t.removeLogoBackground?"transparent":t.backgroundColor||"#fff",$botId:e,$iconSize:H,$removeLogoBackground:t.removeLogoBackground,topOffset:Re,$showAnimation:t.enableChatButtonBackgroundAnimation,$animationType:"Ping",$animationColor:t.chatButtonBackgroundAnimationColor||"#f48722",id:"debales-chat-button","data-testid":"debales-chat-button",onClick:()=>{if(window.DebalesChat.track(an.CHAT_BUTTON_CLICKED),pt(!Je,"chat_button_clicked"),!Je){const Se=_();Se.length>0?(m(Se),Wt(!1),fn(!0)):(Wt(!0),fn(!1),setTimeout(()=>{Wt(!1),fn(!0);const tt={text:(t==null?void 0:t.initialMessage)||"Hi, I am an AI chatbot, how can I help you today?",isBot:!0};m([tt])},(ee==null?void 0:ee.showing_delay)||2e3))}},"aria-label":"Chat",style:{display:Je||ne?"none":"flex"},children:[M.jsx(T0e,{$botId:e,$removeLogoBackground:t.removeLogoBackground,"aria-hidden":"true",src:t.bot_logo,alt:"Chat Bot Icon"}),(j==null?void 0:j.length)>0&&!Je&&fe&&M.jsx("div",{style:{position:"absolute",top:"0px",right:"0px",backgroundColor:"#f44336",color:"white",borderRadius:"50%",width:"20px",height:"20px",display:"flex",justifyContent:"center",alignItems:"center",fontSize:"12px",fontWeight:"bold",zIndex:2,opacity:fe?1:0,transition:"opacity 0.3s ease-in-out"},children:j.length})]})]})]}),Je&&hw.createPortal(M.jsx(M.Fragment,{children:M.jsxs(M0e,{$backgroundColor:t.backgroundColor||"#fff",$fullScreenOnMobile:t.fullScreenOnMobile,$headerFontColor:t.headerFontColor||"#1C1C1C",$isLeft:W,$topOffset:Re,$mobileDisplayMode:t.mobileDisplayMode,$isVisible:Bt,"data-testid":"debales-chat-container",children:[M.jsxs(B0e,{$backgroundColor:He(e)?t.backgroundColor:t.botBackgroundColor||"#fff",style:{color:t.headerFontColor},children:[M.jsx("div",{style:{flexGrow:.1,display:"flex",justifyContent:"center",alignItems:"center",overflow:"hidden",marginRight:"8px",gap:"10px"},children:He(e)?M.jsxs(M.Fragment,{children:[M.jsx(JP,{"aria-hidden":"true",src:t.bot_logo,alt:"Chat Bot Icon"}),M.jsxs(R0e,{$botNameColor:t.headerFontColor,children:[M.jsxs("div",{style:{fontWeight:"700",wordBreak:"break-word"},children:[t.chatbotName,e==="catch-org-ai"&&M.jsx(D0e,{$backgroundColor:t.callToActionBackgroundColor,$fontColor:t.callToActionFontColor,children:"Beta"})]}),M.jsx(O0e,{})]})]}):M.jsx(I0e,{children:M.jsxs($0e,{children:[M.jsx(JP,{src:t.bot_logo,alt:"Chat Bot Icon"}),M.jsx("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",display:"inline-block",maxWidth:"22ch"},children:t.chatbotName})]})})}),M.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginLeft:"auto",flexShrink:0},children:[M.jsxs(Y0e,{children:[M.jsx(eH,{$iconBG:t.backgroundColor,onClick:vt,"aria-label":"Support","data-testid":"debales-support-button",children:M.jsx(pk,{color:t.headerFontColor})}),M.jsx(oH,{children:"Click to chat with a Live Support Agent now."})]}),M.jsx(eH,{$iconBG:t.backgroundColor,onClick:()=>{_t?Wr(!0):pt(!1,"close_button_clicked")},id:"debales-minimize-button","data-testid":"debales-minimize-button","aria-label":"Minimize",children:M.jsx(Hm,{botNameColor:t.headerFontColor})})]}),M.jsx(ege,{$backgroundColor:t.botBackgroundColor||"#fff",style:{opacity:_r?1:0}})]}),M.jsxs(z0e,{$backgroundColor:t.botBackgroundColor||"#fff",$mobileDisplayMode:t.mobileDisplayMode,children:[ar&&((dr=(dn=t.pluginConfig)==null?void 0:dn.collectedUserInfo)==null?void 0:dr.discount)&&M.jsx(wk,{discount:t.pluginConfig.collectedUserInfo.discount,uiData:t,onClose:()=>{Go(!1),window.DebalesChat.track(an.DISCOUNT_VIEWED,{discount:t.pluginConfig.collectedUserInfo.discount})}}),M.jsx(Rk,{uidata:t,product:qo,showModel:po,setShowModel:or,onVariantSelect:Se=>{I(Se.id,1),se(!0),window.DebalesChat.track(an.ADD_TO_CART_CLICKED,{product:Se.title,price:Number(Se.price),link:`https://${t.shopifyShopDomain}/variants/${Se.id}`,message:l,chatId:rr()+e})}}),us&&M.jsx(Ck,{setShowExitModal:Wr,handleCloseChatbot:hi,chatId:rr()+e}),M.jsxs(L0e,{id:"debales-conversation-group",$botBackgroundColor:t.botBackgroundColor||"#fff",ref:ge,$mobileDisplayMode:t.mobileDisplayMode,children:[M.jsx(X0e,{$backgroundColor:t.botBackgroundColor||"#fff",style:{opacity:_r?1:0}}),M.jsxs(N0e,{children:[Gt&&h.map((Se,tt)=>{const Y=Se.isBot,ce=$p(Se.text);return Se.hideConfirmation?null:M.jsxs(Z.Fragment,{children:[Y&&M.jsxs(tH,{$fontColor:t.botFontColor||"#000",$botMessageColor:t.botBackgroundColor||"#fff","data-testid":"debales-ai-message-container",children:[M.jsx("img",{src:Y?t.bot_logo:t.userMessage_logo,alt:"Chat User Icon",style:{marginLeft:"8px"}}),M.jsxs(iH,{children:[ce.slice(0,lt[tt]||0).map((ve,Oe)=>M.jsx("div",{children:M.jsx(Mi,{isBot:Y,children:M.jsx(bd,{remarkPlugins:[Tw,bE],children:ve})})},Oe)),Se.collections&&l===Se.conversationId&&Xt.collections&&M.jsx(Sk,{message:Se,botId:e,uidata:t,onSendMessage:r,loading:p}),Se.products&&l===Se.conversationId&&Xt.products&&M.jsx(Ak,{message:Se,botId:e,uidata:t,onSendMessage:r,loading:p,storeMetaData:n,platform:G,setShowVariantModel:or,setSelectedProduct:Mt,setCartVersion:ht}),o&&M.jsx(A8,{children:M.jsx(Ix,{onClick:()=>{window._klOnsite&&(window._klOnsite.push(["openForm",Ut]),pt(!1,"klaviyo_grab_deal_button"))},children:"🚀 Grab Deal Now!"})}),O&&O.itemCount>0&&l===Se.conversationId&&Xt.cartSummary&&ie&&M.jsx(yk,{onCheckout:Oo,onKeepShopping:()=>{se(!1)}}),Et&&Et.length>0&&l===Se.conversationId&&Xt.bulkItems&&M.jsx(fk,{onClick:()=>Br(Se.conversationId),children:"Add Bulk Items to Cart"}),T&&h.indexOf(Se)===h.length-1&&M.jsx(M.Fragment,{children:M.jsx(kk,{setShowModel:ve=>{var we,Xe;const Oe=typeof ve=="function"?ve(T):ve;A(Oe),!Oe&&((Xe=(we=t.pluginConfig)==null?void 0:we.collectedUserInfo)!=null&&Xe.discount)&&Go(!0)},inChat:!0,showFormInstructions:!1})}),Me&&h.indexOf(Se)===h.length-1&&M.jsxs(Z0e,{onSubmit:Vt,noValidate:!0,"data-testid":"debales-support-form",children:[He(e)?M.jsxs(M.Fragment,{children:[M.jsx(eu,{label:"Name",name:"name",type:"text",value:ft.name,onChange:ve=>Lt(Oe=>({...Oe,name:ve.target.value})),required:!0,error:Jt.name,isCollectiveBot:!0}),M.jsx(eu,{label:"Email",name:"email",type:"email",value:ft.email,onChange:ve=>Lt(Oe=>({...Oe,email:ve.target.value})),required:!0,error:Jt.email,isCollectiveBot:!0}),M.jsx(Ek,{label:"Message",name:"message",value:ft.message,onChange:ve=>Lt(Oe=>({...Oe,message:ve.target.value})),required:!0,error:Jt.message,rows:4,isCollectiveBot:!0})]}):M.jsxs(M.Fragment,{children:[M.jsxs(k8,{children:[M.jsxs(T8,{children:["Name",M.jsx("span",{children:"*"})]}),M.jsx(aH,{type:"text",required:!0,value:ft.name,onChange:ve=>Lt(Oe=>({...Oe,name:ve.target.value})),placeholder:"John"}),Jt.name&&M.jsx("p",{style:{color:"red",fontSize:"12px",margin:"4px 0 0"},children:Jt.name})]}),M.jsxs(k8,{children:[M.jsxs(T8,{children:["Email",M.jsx("span",{children:"*"})]}),M.jsx(aH,{type:"email",required:!0,value:ft.email,onChange:ve=>Lt(Oe=>({...Oe,email:ve.target.value})),placeholder:"olivia@untitledui.com"}),Jt.email&&M.jsx("p",{style:{color:"red",fontSize:"12px",margin:"4px 0 0"},children:Jt.email})]}),M.jsxs(k8,{children:[M.jsxs(T8,{children:["Message",M.jsx("span",{children:"*"})]}),M.jsx(Q0e,{required:!0,value:ft.message,onChange:ve=>Lt(Oe=>({...Oe,message:ve.target.value})),placeholder:"I need help with..."}),Jt.message&&M.jsx("p",{style:{color:"red",fontSize:"12px",margin:"4px 0 0"},children:Jt.message})]})]}),M.jsx(W0e,{children:M.jsx(K0e,{type:"submit",children:"Submit"})})]}),at&&!p&&l===Se.conversationId&&M.jsx(Mi,{isBot:Y,children:M.jsx(Os,{loading:at,loadingPhrases:["🎨 Loading","✨ Almost","🚀 Ready"]})})]})]}),!Y&&M.jsx(P0e,{$fontColor:t.userFontColor||"#000",$botMessageColor:t.botBackgroundColor||"#fff",children:M.jsx(Mi,{isBot:!!Y,children:M.jsx(bd,{children:Se.text})})}),h.length==1&&tt==0&&!T&&M.jsx(A8,{children:V.leadingQueries?M.jsx(Mi,{isBot:!0,children:M.jsx(Os,{loading:V.leadingQueries})}):j.map((ve,Oe)=>M.jsxs(rH,{style:{backgroundColor:t.callToActionBackgroundColor,color:t.callToActionFontColor,opacity:Be.has(ve.question)?.5:1},onClick:()=>{E?(A(!0),R({question:ve.question,answer:ve.answer,products:ve.products,path:"/",nameSpace:window.DebalesChat.projectId})):r({message:ve.question,answer:ve.answer,products:ve.products,messType:"leading_query"}),Ue(we=>{const Xe=new Set(we);return Xe.add(ve.question),Xe}),window.DebalesChat.track(an.INITIAL_LEADING_QUERY_SUGGESTED_QUESTION_CLICKED,{question:ve.question})},disabled:p,$disabled:p,children:[ve.question,M.jsx(nH,{color:t.callToActionFontColor})]},Oe))}),Se.leading_queries&&Se.leading_queries.length>0&&l===Se.conversationId&&Xt.leadingQueries&&!o&&!T&&M.jsx(A8,{children:Se.leading_queries.map((ve,Oe)=>M.jsxs(rH,{style:{backgroundColor:t.callToActionBackgroundColor,color:t.callToActionFontColor},onClick:()=>{E?(A(!0),R({question:ve,path:"/",nameSpace:window.DebalesChat.projectId})):r({message:ve,messType:"leading_query"}),window.DebalesChat.track(an.LEADING_QUERY_CLICKED,{query:ve})},disabled:p,$disabled:p,children:[ve,M.jsx(nH,{color:t.callToActionFontColor})]},Oe))})]},tt)}),(p||Pt)&&M.jsxs(tH,{$fontColor:t.botFontColor||"#000",$botMessageColor:t.botBackgroundColor||"#fff",children:[M.jsx("img",{src:t.bot_logo,alt:"Chat User Icon"}),M.jsx(iH,{children:M.jsx(Mi,{isBot:!0,children:M.jsx("div",{style:{display:"flex",alignItems:"center",gap:"4px",animation:"fadeIn 0.3s ease-in-out"},children:M.jsx(Os,{loading:p||Pt})})})})]})]}),M.jsx(J0e,{$backgroundColor:t.botBackgroundColor||"#fff",style:{opacity:Kr?1:0}})]}),M.jsxs("div",{className:"debales-footer-container",style:{width:"calc(100%-24px)",backgroundColor:t.botBackgroundColor||"#fff",color:t.fontColor||"#000"},children:[(e==="catch-org-ai"||e==="letsgo-catch")&&M.jsx(j0e,{children:M.jsx("span",{children:`"${t.chatbotName}" can make mistakes.`})}),M.jsx("div",{children:M.jsx(Ok,{disabled:p,inputState:!1})}),(t.debales_branding??!0)&&M.jsxs(F0e,{href:"https://debales.ai/?open=true",target:"_blank",title:"debales-link",style:{color:t.fontColor?t.fontColor:"fff",marginTop:e==="catch-org-ai"?"0":"9px"},children:[M.jsx("p",{children:"Powered by"}),M.jsxs(U0e,{children:[M.jsx("img",{src:`${Di}/images/debales_logo_d.png`,alt:"Debales logo"}),M.jsx("p",{children:"DEBALES"})]})]})]})]})]})}),z.shadowRoot)]})},nge=({botId:e})=>{const t=OZ("new-suggested-question-design");let n;return t==="variant-1"?n=Bpe:t==="variant-2"?n=y0e:t==="variant-3"?n=tge:n=$P,M.jsx(n,{botId:e})},sH="debales-ai-assistant",lH="debales-chatbot-container",rge=Z.forwardRef(({children:e,globalStyles:t="",containerStyles:n={},onReady:r},o)=>{const a=Z.useRef(null),[l,d]=Z.useState(null),h=Z.useRef(null),p=Z.useRef(null),y=Z.useRef({get shadowRoot(){return h.current},get container(){return l},querySelector:m=>{var x;return((x=h.current)==null?void 0:x.querySelector(m))||null},querySelectorAll:m=>{var x;return((x=h.current)==null?void 0:x.querySelectorAll(m))||null}});return Z.useImperativeHandle(o,()=>y.current,[]),Z.useEffect(()=>{const m=document.getElementById(sH);if(m?a.current=m:a.current&&(a.current.id=sH),a.current&&(a.current.style.cssText="position: absolute; top: 0; left: 0; width: 0; height: 0;"),a.current){if(a.current.shadowRoot){h.current=a.current.shadowRoot;const w=h.current.querySelector(`#${lH}`);w&&d(w);return}const x=a.current.attachShadow({mode:"open"});if(h.current=x,t){const w=document.createElement("style");w.textContent=t,x.appendChild(w)}const _=document.createElement("div");_.id=lH,_.style.cssText="position: absolute; top: 0; left: 0; width: 0; height: 0;",x.appendChild(_),d(_),r&&r(x,_)}},[t,r]),Z.useEffect(()=>(l&&!p.current&&(p.current=k5.createRoot(l)),p.current&&l&&p.current.render(M.jsx(Gte,{target:l,children:M.jsx(Ij,{value:y.current,children:e})})),()=>{p.current&&p.current.unmount()}),[l,e]),M.jsx("div",{ref:a,style:n})});class Dk{isSupported(){return ff.detect()===this.platform}createSuccessResult(t,n){return{success:!0,data:t,message:n}}createErrorResult(t){return{success:!1,error:t}}}class ige extends Dk{constructor(){super(...arguments);Qi(this,"platform",_i.DEFAULT)}async fetchCart(){return console.log("DefaultCartAdapter: fetchCart called"),this.createSuccessResult({items:[],total:0,itemCount:0,currency:"USD",token:"default-token"},"Default cart fetched")}async addToCart(n,r=1,o){return console.log("DefaultCartAdapter: addToCart called",{variantId:n,quantity:r,properties:o}),this.createSuccessResult(void 0,"Item added to cart (mock)")}async removeFromCart(n){return console.log("DefaultCartAdapter: removeFromCart called",{itemId:n}),this.createSuccessResult(void 0,"Item removed from cart (mock)")}async updateQuantity(n){return console.log("DefaultCartAdapter: updateQuantity called",{cartItem:n}),this.createSuccessResult(void 0,"Item quantity updated (mock)")}async clearCart(){return console.log("DefaultCartAdapter: clearCart called"),this.createSuccessResult(void 0,"Cart cleared (mock)")}generateCartUrl(n){const r=n.replace(/^https?:\/\//,"");return console.log("DefaultCartAdapter: generateCartUrl called",{domain:n,sanitizedDomain:r}),`https://${r}/cart`}generateProductUrl(n,r){if(r.handle){const o=new URL(`https://${n}/products/${r.handle}`);return o.searchParams.append("variant",r.product_id),hf(o.toString())}else return hf(r.link)}async addCartAttributes(n={}){return console.log("MethodNotImplemented: addCartAttributes called",{attributes:n}),this.createSuccessResult(void 0,"Cart attributes added (mock)")}}class oge extends Dk{constructor(){var n,r;super();Qi(this,"platform",_i.SHOPIFY);Qi(this,"cartEndpoint");Qi(this,"localCartKey","debales_track_cart");this.cartEndpoint=((r=(n=window.Shopify)==null?void 0:n.routes)==null?void 0:r.root)||"/"}normalizeCartData(n){return{items:n.items.map(r=>({id:r.id,variant_id:r.variant_id,quantity:r.quantity,title:r.title,price:r.price,properties:r.properties})),total:n.total_price/100,itemCount:n.item_count,currency:n.currency,token:n.token.split("?")[0]}}generateProductUrl(n,r){const o=Tk(n);if(!o.isValid)return"";if(r.handle){const a=new URL(`/products/${r.handle}`,o.url);return a.searchParams.append("variant",r.product_id),hf(a.toString())}else return hf(r.link)}updateTrackCart({cartToken:n,sessionId:r=rr()}){localStorage.setItem(this.localCartKey,JSON.stringify({sessionId:r,cartToken:n}))}async fetchCart(){try{const n=await fetch(`${this.cartEndpoint}cart.js`),r=await n.json();if(!n.ok){const a=r;return this.createErrorResult(a.description||`Failed to fetch cart: ${n.status}`)}const o=r;return this.createSuccessResult(this.normalizeCartData(o),"Cart fetched successfully")}catch(n){return this.createErrorResult(n instanceof Error?`Error fetching cart: ${n.message}`:"Unknown error occurred while fetching cart")}}async addToCart(n,r=1,o){try{const a=await fetch(`${this.cartEndpoint}cart/add.js`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({items:[{id:n,quantity:r,properties:o}],attributes:{dbls_order_source:"direct_recommendation",dbls_session_id:rr(),dbls_method:"add_to_cart"}})}),l=await a.json();if(!a.ok){const d=l;return this.createErrorResult(d.description||`Failed to add item to cart: ${a.status}`)}return this.fetchCart().then(d=>{d.success&&this.updateTrackCart({cartToken:d==null?void 0:d.data.token})}),this.createSuccessResult(void 0,`Successfully added ${r} item(s) to cart`)}catch(a){return this.createErrorResult(a instanceof Error?`Error adding to cart: ${a.message}`:"Unknown error occurred while adding to cart")}}async removeFromCart(n){return this.updateQuantity({id:n,quantity:0})}async updateQuantity(n){try{const r=await fetch(`${this.cartEndpoint}cart/change.js`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:n.id,quantity:n.quantity})}),o=await r.json();if(!r.ok){const a=o;return this.createErrorResult(a.description||`Failed to update item quantity: ${r.status}`)}return this.fetchCart().then(a=>{a.success&&this.updateTrackCart({cartToken:a==null?void 0:a.data.token})}),this.createSuccessResult(void 0,n.quantity===0?"Item removed from cart":`Quantity updated to ${n.quantity}`)}catch(r){return this.createErrorResult(r instanceof Error?`Error updating quantity: ${r.message}`:"Unknown error occurred while updating quantity")}}async clearCart(){try{const n=await fetch(`${this.cartEndpoint}cart/clear.js`,{method:"POST"});if(!n.ok){const r=await n.json();return this.createErrorResult(r.description||`Failed to clear cart: ${n.status}`)}return this.createSuccessResult(void 0,"Cart cleared successfully")}catch(n){return this.createErrorResult(n instanceof Error?`Error clearing cart: ${n.message}`:"Unknown error occurred while clearing cart")}}async addCartAttributes(n={}){try{const r=await fetch(`${this.cartEndpoint}cart/update.js`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({attributes:{dbls_order_source:"direct_recommendation",dbls_session_id:rr(),...n}})});if(!r.ok){const o=await r.json();return this.createErrorResult(o.description||`Failed to update cart attributes: ${r.status}`)}return this.createSuccessResult(void 0,"Cart attributes updated successfully")}catch(r){return this.createErrorResult(r instanceof Error?`Error updating cart attributes: ${r.message}`:"Unknown error occurred while updating cart attributes")}}generateCartUrl(n){const r=Tk(n);if(!r.isValid)return"";const o=new URL("/cart",r.url);return o.searchParams.append("ref",`debales-ai-${new Date().toISOString()}`),o.searchParams.append("attributes[from]","debales-ai-chatbot"),o.searchParams.append("attributes[through]","add-to-cart"),o.searchParams.append("attributes[dbls_session_id]",rr()),o.searchParams.append("timestamp",Date.now().toString()),hf(o.toString())}}class age extends Dk{constructor(){var n,r;super();Qi(this,"platform",_i.MAGENTO);Qi(this,"checkoutEndpoint");Qi(this,"baseUrl");this.checkoutEndpoint=((n=window.checkout)==null?void 0:n.checkoutUrl)||"/",this.baseUrl=((r=window.checkout)==null?void 0:r.baseUrl)||"/"}normalizeCartData(n){return{items:n.items.map(r=>({id:parseInt(r.item_id),variant_id:parseInt(r.product_id),quantity:r.qty,title:r.product_name,price:r.product_price_value,properties:{name:r.product_name}})),total:parseFloat(n.subtotalAmount),itemCount:n.summary_count,currency:"USD",token:n.data_id.toString()}}async fetchCart(){try{const n=await fetch(`${this.baseUrl}customer/section/load/?sections=cart&update_section_id=false`),r=await n.json();if(!n.ok)return this.createErrorResult(`Failed to fetch cart: ${n.status}`);const o=r.cart;return this.createSuccessResult(this.normalizeCartData(o),"Cart fetched successfully")}catch(n){return this.createErrorResult(n instanceof Error?`Error fetching cart: ${n.message}`:"Unknown error occurred while fetching cart")}}async addToCart(n,r=1){var o;try{const a=(o=document.querySelector('input[name="form_key"]'))==null?void 0:o.value;if(!a)return this.createErrorResult("Form key not found");const l=await fetch(`${this.checkoutEndpoint}cart/add`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded","X-Requested-With":"XMLHttpRequest"},body:new URLSearchParams({product:n,qty:r.toString(),form_key:a})});if(!l.ok)return this.createErrorResult(`Failed to add item to cart: ${l.status}`);try{window.require(["Magento_Customer/js/customer-data"],d=>d.reload(["cart"],!0))}catch(d){console.warn("Failed to reload cart data:",d)}return this.createSuccessResult(void 0,`Successfully added ${r} item(s) to cart`)}catch(a){return this.createErrorResult(a instanceof Error?`Error adding to cart: ${a.message}`:"Unknown error occurred while adding to cart")}}async removeFromCart(n){return console.log("MethodNotImplemented: removeFromCart called",{itemId:n}),this.createSuccessResult(void 0,"Item removed from cart (mock)")}async updateQuantity(n){return console.log("MethodNotImplemented: updateQuantity called",{cartItem:n}),this.createSuccessResult(void 0,"Item quantity updated (mock)")}async clearCart(){return console.log("MethodNotImplemented: clearCart called"),this.createSuccessResult(void 0,"Cart cleared (mock)")}generateCartUrl(n){const r=new URL(`https://${n}/checkout/cart?ref=debales-ai-${new Date().toISOString()}&attributes[from]=debales-ai-chatbot&attributes[through]=add-to-cart`);return r.searchParams.append("timestamp",Date.now().toString()),r.toString()}generateProductUrl(n,r){const o=Tk(n);if(!o.isValid)return"";if(r.handle){const a=new URL(`/${r.handle}.html`,o.url);return hf(a.toString())}else return hf(r.link)}async addCartAttributes(n={}){return console.log("MethodNotImplemented: addCartAttributes called",{attributes:n}),this.createSuccessResult(void 0,"Cart attributes added (mock)")}}var Mk={exports:{}};function sge(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Ik={exports:{}};const lge=cV(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var uge=Ik.exports,uH;function Jn(){return uH||(uH=1,function(e,t){(function(n,r){e.exports=r()})(uge,function(){var n=n||function(r,o){var a;if(typeof window<"u"&&window.crypto&&(a=window.crypto),typeof self<"u"&&self.crypto&&(a=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(a=globalThis.crypto),!a&&typeof window<"u"&&window.msCrypto&&(a=window.msCrypto),!a&&typeof ql<"u"&&ql.crypto&&(a=ql.crypto),!a&&typeof sge=="function")try{a=lge}catch{}var l=function(){if(a){if(typeof a.getRandomValues=="function")try{return a.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof a.randomBytes=="function")try{return a.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},d=Object.create||function(){function R(){}return function(O){var I;return R.prototype=O,I=new R,R.prototype=null,I}}(),h={},p=h.lib={},y=p.Base=function(){return{extend:function(R){var O=d(this);return R&&O.mixIn(R),(!O.hasOwnProperty("init")||this.init===O.init)&&(O.init=function(){O.$super.init.apply(this,arguments)}),O.init.prototype=O,O.$super=this,O},create:function(){var R=this.extend();return R.init.apply(R,arguments),R},init:function(){},mixIn:function(R){for(var O in R)R.hasOwnProperty(O)&&(this[O]=R[O]);R.hasOwnProperty("toString")&&(this.toString=R.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),m=p.WordArray=y.extend({init:function(R,O){R=this.words=R||[],O!=o?this.sigBytes=O:this.sigBytes=R.length*4},toString:function(R){return(R||_).stringify(this)},concat:function(R){var O=this.words,I=R.words,L=this.sigBytes,B=R.sigBytes;if(this.clamp(),L%4)for(var H=0;H<B;H++){var G=I[H>>>2]>>>24-H%4*8&255;O[L+H>>>2]|=G<<24-(L+H)%4*8}else for(var W=0;W<B;W+=4)O[L+W>>>2]=I[W>>>2];return this.sigBytes+=B,this},clamp:function(){var R=this.words,O=this.sigBytes;R[O>>>2]&=4294967295<<32-O%4*8,R.length=r.ceil(O/4)},clone:function(){var R=y.clone.call(this);return R.words=this.words.slice(0),R},random:function(R){for(var O=[],I=0;I<R;I+=4)O.push(l());return new m.init(O,R)}}),x=h.enc={},_=x.Hex={stringify:function(R){for(var O=R.words,I=R.sigBytes,L=[],B=0;B<I;B++){var H=O[B>>>2]>>>24-B%4*8&255;L.push((H>>>4).toString(16)),L.push((H&15).toString(16))}return L.join("")},parse:function(R){for(var O=R.length,I=[],L=0;L<O;L+=2)I[L>>>3]|=parseInt(R.substr(L,2),16)<<24-L%8*4;return new m.init(I,O/2)}},w=x.Latin1={stringify:function(R){for(var O=R.words,I=R.sigBytes,L=[],B=0;B<I;B++){var H=O[B>>>2]>>>24-B%4*8&255;L.push(String.fromCharCode(H))}return L.join("")},parse:function(R){for(var O=R.length,I=[],L=0;L<O;L++)I[L>>>2]|=(R.charCodeAt(L)&255)<<24-L%4*8;return new m.init(I,O)}},T=x.Utf8={stringify:function(R){try{return decodeURIComponent(escape(w.stringify(R)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(R){return w.parse(unescape(encodeURIComponent(R)))}},A=p.BufferedBlockAlgorithm=y.extend({reset:function(){this._data=new m.init,this._nDataBytes=0},_append:function(R){typeof R=="string"&&(R=T.parse(R)),this._data.concat(R),this._nDataBytes+=R.sigBytes},_process:function(R){var O,I=this._data,L=I.words,B=I.sigBytes,H=this.blockSize,G=H*4,W=B/G;R?W=r.ceil(W):W=r.max((W|0)-this._minBufferSize,0);var z=W*H,Q=r.min(z*4,B);if(z){for(var J=0;J<z;J+=H)this._doProcessBlock(L,J);O=L.splice(0,z),I.sigBytes-=Q}return new m.init(O,Q)},clone:function(){var R=y.clone.call(this);return R._data=this._data.clone(),R},_minBufferSize:0});p.Hasher=A.extend({cfg:y.extend(),init:function(R){this.cfg=this.cfg.extend(R),this.reset()},reset:function(){A.reset.call(this),this._doReset()},update:function(R){return this._append(R),this._process(),this},finalize:function(R){R&&this._append(R);var O=this._doFinalize();return O},blockSize:16,_createHelper:function(R){return function(O,I){return new R.init(I).finalize(O)}},_createHmacHelper:function(R){return function(O,I){return new E.HMAC.init(R,I).finalize(O)}}});var E=h.algo={};return h}(Math);return n})}(Ik)),Ik.exports}var $k={exports:{}},cge=$k.exports,cH;function Bk(){return cH||(cH=1,function(e,t){(function(n,r){e.exports=r(Jn())})(cge,function(n){return function(r){var o=n,a=o.lib,l=a.Base,d=a.WordArray,h=o.x64={};h.Word=l.extend({init:function(p,y){this.high=p,this.low=y}}),h.WordArray=l.extend({init:function(p,y){p=this.words=p||[],y!=r?this.sigBytes=y:this.sigBytes=p.length*8},toX32:function(){for(var p=this.words,y=p.length,m=[],x=0;x<y;x++){var _=p[x];m.push(_.high),m.push(_.low)}return d.create(m,this.sigBytes)},clone:function(){for(var p=l.clone.call(this),y=p.words=this.words.slice(0),m=y.length,x=0;x<m;x++)y[x]=y[x].clone();return p}})}(),n})}($k)),$k.exports}var Lk={exports:{}},fge=Lk.exports,fH;function dge(){return fH||(fH=1,function(e,t){(function(n,r){e.exports=r(Jn())})(fge,function(n){return function(){if(typeof ArrayBuffer=="function"){var r=n,o=r.lib,a=o.WordArray,l=a.init,d=a.init=function(h){if(h instanceof ArrayBuffer&&(h=new Uint8Array(h)),(h instanceof Int8Array||typeof Uint8ClampedArray<"u"&&h instanceof Uint8ClampedArray||h instanceof Int16Array||h instanceof Uint16Array||h instanceof Int32Array||h instanceof Uint32Array||h instanceof Float32Array||h instanceof Float64Array)&&(h=new Uint8Array(h.buffer,h.byteOffset,h.byteLength)),h instanceof Uint8Array){for(var p=h.byteLength,y=[],m=0;m<p;m++)y[m>>>2]|=h[m]<<24-m%4*8;l.call(this,y,p)}else l.apply(this,arguments)};d.prototype=a}}(),n.lib.WordArray})}(Lk)),Lk.exports}var Nk={exports:{}},hge=Nk.exports,dH;function pge(){return dH||(dH=1,function(e,t){(function(n,r){e.exports=r(Jn())})(hge,function(n){return function(){var r=n,o=r.lib,a=o.WordArray,l=r.enc;l.Utf16=l.Utf16BE={stringify:function(h){for(var p=h.words,y=h.sigBytes,m=[],x=0;x<y;x+=2){var _=p[x>>>2]>>>16-x%4*8&65535;m.push(String.fromCharCode(_))}return m.join("")},parse:function(h){for(var p=h.length,y=[],m=0;m<p;m++)y[m>>>1]|=h.charCodeAt(m)<<16-m%2*16;return a.create(y,p*2)}},l.Utf16LE={stringify:function(h){for(var p=h.words,y=h.sigBytes,m=[],x=0;x<y;x+=2){var _=d(p[x>>>2]>>>16-x%4*8&65535);m.push(String.fromCharCode(_))}return m.join("")},parse:function(h){for(var p=h.length,y=[],m=0;m<p;m++)y[m>>>1]|=d(h.charCodeAt(m)<<16-m%2*16);return a.create(y,p*2)}};function d(h){return h<<8&4278255360|h>>>8&16711935}}(),n.enc.Utf16})}(Nk)),Nk.exports}var zk={exports:{}},gge=zk.exports,hH;function Up(){return hH||(hH=1,function(e,t){(function(n,r){e.exports=r(Jn())})(gge,function(n){return function(){var r=n,o=r.lib,a=o.WordArray,l=r.enc;l.Base64={stringify:function(h){var p=h.words,y=h.sigBytes,m=this._map;h.clamp();for(var x=[],_=0;_<y;_+=3)for(var w=p[_>>>2]>>>24-_%4*8&255,T=p[_+1>>>2]>>>24-(_+1)%4*8&255,A=p[_+2>>>2]>>>24-(_+2)%4*8&255,E=w<<16|T<<8|A,R=0;R<4&&_+R*.75<y;R++)x.push(m.charAt(E>>>6*(3-R)&63));var O=m.charAt(64);if(O)for(;x.length%4;)x.push(O);return x.join("")},parse:function(h){var p=h.length,y=this._map,m=this._reverseMap;if(!m){m=this._reverseMap=[];for(var x=0;x<y.length;x++)m[y.charCodeAt(x)]=x}var _=y.charAt(64);if(_){var w=h.indexOf(_);w!==-1&&(p=w)}return d(h,p,m)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="};function d(h,p,y){for(var m=[],x=0,_=0;_<p;_++)if(_%4){var w=y[h.charCodeAt(_-1)]<<_%4*2,T=y[h.charCodeAt(_)]>>>6-_%4*2,A=w|T;m[x>>>2]|=A<<24-x%4*8,x++}return a.create(m,x)}}(),n.enc.Base64})}(zk)),zk.exports}var Fk={exports:{}},mge=Fk.exports,pH;function vge(){return pH||(pH=1,function(e,t){(function(n,r){e.exports=r(Jn())})(mge,function(n){return function(){var r=n,o=r.lib,a=o.WordArray,l=r.enc;l.Base64url={stringify:function(h,p){p===void 0&&(p=!0);var y=h.words,m=h.sigBytes,x=p?this._safe_map:this._map;h.clamp();for(var _=[],w=0;w<m;w+=3)for(var T=y[w>>>2]>>>24-w%4*8&255,A=y[w+1>>>2]>>>24-(w+1)%4*8&255,E=y[w+2>>>2]>>>24-(w+2)%4*8&255,R=T<<16|A<<8|E,O=0;O<4&&w+O*.75<m;O++)_.push(x.charAt(R>>>6*(3-O)&63));var I=x.charAt(64);if(I)for(;_.length%4;)_.push(I);return _.join("")},parse:function(h,p){p===void 0&&(p=!0);var y=h.length,m=p?this._safe_map:this._map,x=this._reverseMap;if(!x){x=this._reverseMap=[];for(var _=0;_<m.length;_++)x[m.charCodeAt(_)]=_}var w=m.charAt(64);if(w){var T=h.indexOf(w);T!==-1&&(y=T)}return d(h,y,x)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",_safe_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"};function d(h,p,y){for(var m=[],x=0,_=0;_<p;_++)if(_%4){var w=y[h.charCodeAt(_-1)]<<_%4*2,T=y[h.charCodeAt(_)]>>>6-_%4*2,A=w|T;m[x>>>2]|=A<<24-x%4*8,x++}return a.create(m,x)}}(),n.enc.Base64url})}(Fk)),Fk.exports}var Uk={exports:{}},yge=Uk.exports,gH;function jp(){return gH||(gH=1,function(e,t){(function(n,r){e.exports=r(Jn())})(yge,function(n){return function(r){var o=n,a=o.lib,l=a.WordArray,d=a.Hasher,h=o.algo,p=[];(function(){for(var T=0;T<64;T++)p[T]=r.abs(r.sin(T+1))*4294967296|0})();var y=h.MD5=d.extend({_doReset:function(){this._hash=new l.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(T,A){for(var E=0;E<16;E++){var R=A+E,O=T[R];T[R]=(O<<8|O>>>24)&16711935|(O<<24|O>>>8)&4278255360}var I=this._hash.words,L=T[A+0],B=T[A+1],H=T[A+2],G=T[A+3],W=T[A+4],z=T[A+5],Q=T[A+6],J=T[A+7],re=T[A+8],ee=T[A+9],fe=T[A+10],le=T[A+11],ne=T[A+12],me=T[A+13],Ce=T[A+14],N=T[A+15],j=I[0],te=I[1],U=I[2],ue=I[3];j=m(j,te,U,ue,L,7,p[0]),ue=m(ue,j,te,U,B,12,p[1]),U=m(U,ue,j,te,H,17,p[2]),te=m(te,U,ue,j,G,22,p[3]),j=m(j,te,U,ue,W,7,p[4]),ue=m(ue,j,te,U,z,12,p[5]),U=m(U,ue,j,te,Q,17,p[6]),te=m(te,U,ue,j,J,22,p[7]),j=m(j,te,U,ue,re,7,p[8]),ue=m(ue,j,te,U,ee,12,p[9]),U=m(U,ue,j,te,fe,17,p[10]),te=m(te,U,ue,j,le,22,p[11]),j=m(j,te,U,ue,ne,7,p[12]),ue=m(ue,j,te,U,me,12,p[13]),U=m(U,ue,j,te,Ce,17,p[14]),te=m(te,U,ue,j,N,22,p[15]),j=x(j,te,U,ue,B,5,p[16]),ue=x(ue,j,te,U,Q,9,p[17]),U=x(U,ue,j,te,le,14,p[18]),te=x(te,U,ue,j,L,20,p[19]),j=x(j,te,U,ue,z,5,p[20]),ue=x(ue,j,te,U,fe,9,p[21]),U=x(U,ue,j,te,N,14,p[22]),te=x(te,U,ue,j,W,20,p[23]),j=x(j,te,U,ue,ee,5,p[24]),ue=x(ue,j,te,U,Ce,9,p[25]),U=x(U,ue,j,te,G,14,p[26]),te=x(te,U,ue,j,re,20,p[27]),j=x(j,te,U,ue,me,5,p[28]),ue=x(ue,j,te,U,H,9,p[29]),U=x(U,ue,j,te,J,14,p[30]),te=x(te,U,ue,j,ne,20,p[31]),j=_(j,te,U,ue,z,4,p[32]),ue=_(ue,j,te,U,re,11,p[33]),U=_(U,ue,j,te,le,16,p[34]),te=_(te,U,ue,j,Ce,23,p[35]),j=_(j,te,U,ue,B,4,p[36]),ue=_(ue,j,te,U,W,11,p[37]),U=_(U,ue,j,te,J,16,p[38]),te=_(te,U,ue,j,fe,23,p[39]),j=_(j,te,U,ue,me,4,p[40]),ue=_(ue,j,te,U,L,11,p[41]),U=_(U,ue,j,te,G,16,p[42]),te=_(te,U,ue,j,Q,23,p[43]),j=_(j,te,U,ue,ee,4,p[44]),ue=_(ue,j,te,U,ne,11,p[45]),U=_(U,ue,j,te,N,16,p[46]),te=_(te,U,ue,j,H,23,p[47]),j=w(j,te,U,ue,L,6,p[48]),ue=w(ue,j,te,U,J,10,p[49]),U=w(U,ue,j,te,Ce,15,p[50]),te=w(te,U,ue,j,z,21,p[51]),j=w(j,te,U,ue,ne,6,p[52]),ue=w(ue,j,te,U,G,10,p[53]),U=w(U,ue,j,te,fe,15,p[54]),te=w(te,U,ue,j,B,21,p[55]),j=w(j,te,U,ue,re,6,p[56]),ue=w(ue,j,te,U,N,10,p[57]),U=w(U,ue,j,te,Q,15,p[58]),te=w(te,U,ue,j,me,21,p[59]),j=w(j,te,U,ue,W,6,p[60]),ue=w(ue,j,te,U,le,10,p[61]),U=w(U,ue,j,te,H,15,p[62]),te=w(te,U,ue,j,ee,21,p[63]),I[0]=I[0]+j|0,I[1]=I[1]+te|0,I[2]=I[2]+U|0,I[3]=I[3]+ue|0},_doFinalize:function(){var T=this._data,A=T.words,E=this._nDataBytes*8,R=T.sigBytes*8;A[R>>>5]|=128<<24-R%32;var O=r.floor(E/4294967296),I=E;A[(R+64>>>9<<4)+15]=(O<<8|O>>>24)&16711935|(O<<24|O>>>8)&4278255360,A[(R+64>>>9<<4)+14]=(I<<8|I>>>24)&16711935|(I<<24|I>>>8)&4278255360,T.sigBytes=(A.length+1)*4,this._process();for(var L=this._hash,B=L.words,H=0;H<4;H++){var G=B[H];B[H]=(G<<8|G>>>24)&16711935|(G<<24|G>>>8)&4278255360}return L},clone:function(){var T=d.clone.call(this);return T._hash=this._hash.clone(),T}});function m(T,A,E,R,O,I,L){var B=T+(A&E|~A&R)+O+L;return(B<<I|B>>>32-I)+A}function x(T,A,E,R,O,I,L){var B=T+(A&R|E&~R)+O+L;return(B<<I|B>>>32-I)+A}function _(T,A,E,R,O,I,L){var B=T+(A^E^R)+O+L;return(B<<I|B>>>32-I)+A}function w(T,A,E,R,O,I,L){var B=T+(E^(A|~R))+O+L;return(B<<I|B>>>32-I)+A}o.MD5=d._createHelper(y),o.HmacMD5=d._createHmacHelper(y)}(Math),n.MD5})}(Uk)),Uk.exports}var jk={exports:{}},xge=jk.exports,mH;function vH(){return mH||(mH=1,function(e,t){(function(n,r){e.exports=r(Jn())})(xge,function(n){return function(){var r=n,o=r.lib,a=o.WordArray,l=o.Hasher,d=r.algo,h=[],p=d.SHA1=l.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(y,m){for(var x=this._hash.words,_=x[0],w=x[1],T=x[2],A=x[3],E=x[4],R=0;R<80;R++){if(R<16)h[R]=y[m+R]|0;else{var O=h[R-3]^h[R-8]^h[R-14]^h[R-16];h[R]=O<<1|O>>>31}var I=(_<<5|_>>>27)+E+h[R];R<20?I+=(w&T|~w&A)+1518500249:R<40?I+=(w^T^A)+1859775393:R<60?I+=(w&T|w&A|T&A)-1894007588:I+=(w^T^A)-899497514,E=A,A=T,T=w<<30|w>>>2,w=_,_=I}x[0]=x[0]+_|0,x[1]=x[1]+w|0,x[2]=x[2]+T|0,x[3]=x[3]+A|0,x[4]=x[4]+E|0},_doFinalize:function(){var y=this._data,m=y.words,x=this._nDataBytes*8,_=y.sigBytes*8;return m[_>>>5]|=128<<24-_%32,m[(_+64>>>9<<4)+14]=Math.floor(x/4294967296),m[(_+64>>>9<<4)+15]=x,y.sigBytes=m.length*4,this._process(),this._hash},clone:function(){var y=l.clone.call(this);return y._hash=this._hash.clone(),y}});r.SHA1=l._createHelper(p),r.HmacSHA1=l._createHmacHelper(p)}(),n.SHA1})}(jk)),jk.exports}var Pk={exports:{}},bge=Pk.exports,yH;function O8(){return yH||(yH=1,function(e,t){(function(n,r){e.exports=r(Jn())})(bge,function(n){return function(r){var o=n,a=o.lib,l=a.WordArray,d=a.Hasher,h=o.algo,p=[],y=[];(function(){function _(E){for(var R=r.sqrt(E),O=2;O<=R;O++)if(!(E%O))return!1;return!0}function w(E){return(E-(E|0))*4294967296|0}for(var T=2,A=0;A<64;)_(T)&&(A<8&&(p[A]=w(r.pow(T,.5))),y[A]=w(r.pow(T,.3333333333333333)),A++),T++})();var m=[],x=h.SHA256=d.extend({_doReset:function(){this._hash=new l.init(p.slice(0))},_doProcessBlock:function(_,w){for(var T=this._hash.words,A=T[0],E=T[1],R=T[2],O=T[3],I=T[4],L=T[5],B=T[6],H=T[7],G=0;G<64;G++){if(G<16)m[G]=_[w+G]|0;else{var W=m[G-15],z=(W<<25|W>>>7)^(W<<14|W>>>18)^W>>>3,Q=m[G-2],J=(Q<<15|Q>>>17)^(Q<<13|Q>>>19)^Q>>>10;m[G]=z+m[G-7]+J+m[G-16]}var re=I&L^~I&B,ee=A&E^A&R^E&R,fe=(A<<30|A>>>2)^(A<<19|A>>>13)^(A<<10|A>>>22),le=(I<<26|I>>>6)^(I<<21|I>>>11)^(I<<7|I>>>25),ne=H+le+re+y[G]+m[G],me=fe+ee;H=B,B=L,L=I,I=O+ne|0,O=R,R=E,E=A,A=ne+me|0}T[0]=T[0]+A|0,T[1]=T[1]+E|0,T[2]=T[2]+R|0,T[3]=T[3]+O|0,T[4]=T[4]+I|0,T[5]=T[5]+L|0,T[6]=T[6]+B|0,T[7]=T[7]+H|0},_doFinalize:function(){var _=this._data,w=_.words,T=this._nDataBytes*8,A=_.sigBytes*8;return w[A>>>5]|=128<<24-A%32,w[(A+64>>>9<<4)+14]=r.floor(T/4294967296),w[(A+64>>>9<<4)+15]=T,_.sigBytes=w.length*4,this._process(),this._hash},clone:function(){var _=d.clone.call(this);return _._hash=this._hash.clone(),_}});o.SHA256=d._createHelper(x),o.HmacSHA256=d._createHmacHelper(x)}(Math),n.SHA256})}(Pk)),Pk.exports}var Hk={exports:{}},_ge=Hk.exports,xH;function Sge(){return xH||(xH=1,function(e,t){(function(n,r,o){e.exports=r(Jn(),O8())})(_ge,function(n){return function(){var r=n,o=r.lib,a=o.WordArray,l=r.algo,d=l.SHA256,h=l.SHA224=d.extend({_doReset:function(){this._hash=new a.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var p=d._doFinalize.call(this);return p.sigBytes-=4,p}});r.SHA224=d._createHelper(h),r.HmacSHA224=d._createHmacHelper(h)}(),n.SHA224})}(Hk)),Hk.exports}var qk={exports:{}},wge=qk.exports,bH;function _H(){return bH||(bH=1,function(e,t){(function(n,r,o){e.exports=r(Jn(),Bk())})(wge,function(n){return function(){var r=n,o=r.lib,a=o.Hasher,l=r.x64,d=l.Word,h=l.WordArray,p=r.algo;function y(){return d.create.apply(d,arguments)}var m=[y(1116352408,3609767458),y(1899447441,602891725),y(3049323471,3964484399),y(3921009573,2173295548),y(961987163,4081628472),y(1508970993,3053834265),y(2453635748,2937671579),y(2870763221,3664609560),y(3624381080,2734883394),y(310598401,1164996542),y(607225278,1323610764),y(1426881987,3590304994),y(1925078388,4068182383),y(2162078206,991336113),y(2614888103,633803317),y(3248222580,3479774868),y(3835390401,2666613458),y(4022224774,944711139),y(264347078,2341262773),y(604807628,2007800933),y(770255983,1495990901),y(1249150122,1856431235),y(1555081692,3175218132),y(1996064986,2198950837),y(2554220882,3999719339),y(2821834349,766784016),y(2952996808,2566594879),y(3210313671,3203337956),y(3336571891,1034457026),y(3584528711,2466948901),y(113926993,3758326383),y(338241895,168717936),y(666307205,1188179964),y(773529912,1546045734),y(1294757372,1522805485),y(1396182291,2643833823),y(1695183700,2343527390),y(1986661051,1014477480),y(2177026350,1206759142),y(2456956037,344077627),y(2730485921,1290863460),y(2820302411,3158454273),y(3259730800,3505952657),y(3345764771,106217008),y(3516065817,3606008344),y(3600352804,1432725776),y(4094571909,1467031594),y(275423344,851169720),y(430227734,3100823752),y(506948616,1363258195),y(659060556,3750685593),y(883997877,3785050280),y(958139571,3318307427),y(1322822218,3812723403),y(1537002063,2003034995),y(1747873779,3602036899),y(1955562222,1575990012),y(2024104815,1125592928),y(2227730452,2716904306),y(2361852424,442776044),y(2428436474,593698344),y(2756734187,3733110249),y(3204031479,2999351573),y(3329325298,3815920427),y(3391569614,3928383900),y(3515267271,566280711),y(3940187606,3454069534),y(4118630271,4000239992),y(116418474,1914138554),y(174292421,2731055270),y(289380356,3203993006),y(460393269,320620315),y(685471733,587496836),y(852142971,1086792851),y(1017036298,365543100),y(1126000580,2618297676),y(1288033470,3409855158),y(1501505948,4234509866),y(1607167915,987167468),y(1816402316,1246189591)],x=[];(function(){for(var w=0;w<80;w++)x[w]=y()})();var _=p.SHA512=a.extend({_doReset:function(){this._hash=new h.init([new d.init(1779033703,4089235720),new d.init(3144134277,2227873595),new d.init(1013904242,4271175723),new d.init(2773480762,1595750129),new d.init(1359893119,2917565137),new d.init(2600822924,725511199),new d.init(528734635,4215389547),new d.init(1541459225,327033209)])},_doProcessBlock:function(w,T){for(var A=this._hash.words,E=A[0],R=A[1],O=A[2],I=A[3],L=A[4],B=A[5],H=A[6],G=A[7],W=E.high,z=E.low,Q=R.high,J=R.low,re=O.high,ee=O.low,fe=I.high,le=I.low,ne=L.high,me=L.low,Ce=B.high,N=B.low,j=H.high,te=H.low,U=G.high,ue=G.low,Te=W,Ee=z,st=Q,Ve=J,Je=re,Tt=ee,Bt=fe,qe=le,ot=ne,ct=me,Ut=Ce,Qt=N,ht=j,ie=te,se=U,ge=ue,Ae=0;Ae<80;Ae++){var Be,Ue,pt=x[Ae];if(Ae<16)Ue=pt.high=w[T+Ae*2]|0,Be=pt.low=w[T+Ae*2+1]|0;else{var Et=x[Ae-15],be=Et.high,Me=Et.low,Rt=(be>>>1|Me<<31)^(be>>>8|Me<<24)^be>>>7,ft=(Me>>>1|be<<31)^(Me>>>8|be<<24)^(Me>>>7|be<<25),Lt=x[Ae-2],Ot=Lt.high,rn=Lt.low,Jt=(Ot>>>19|rn<<13)^(Ot<<3|rn>>>29)^Ot>>>6,mn=(rn>>>19|Ot<<13)^(rn<<3|Ot>>>29)^(rn>>>6|Ot<<26),_t=x[Ae-7],Xt=_t.high,Ct=_t.low,V=x[Ae-16],ye=V.high,at=V.low;Be=ft+Ct,Ue=Rt+Xt+(Be>>>0<ft>>>0?1:0),Be=Be+mn,Ue=Ue+Jt+(Be>>>0<mn>>>0?1:0),Be=Be+at,Ue=Ue+ye+(Be>>>0<at>>>0?1:0),pt.high=Ue,pt.low=Be}var ut=ot&Ut^~ot&ht,St=ct&Qt^~ct&ie,Ht=Te&st^Te&Je^st&Je,Pt=Ee&Ve^Ee&Tt^Ve&Tt,Wt=(Te>>>28|Ee<<4)^(Te<<30|Ee>>>2)^(Te<<25|Ee>>>7),Gt=(Ee>>>28|Te<<4)^(Ee<<30|Te>>>2)^(Ee<<25|Te>>>7),fn=(ot>>>14|ct<<18)^(ot>>>18|ct<<14)^(ot<<23|ct>>>9),_r=(ct>>>14|ot<<18)^(ct>>>18|ot<<14)^(ct<<23|ot>>>9),ir=m[Ae],Kr=ir.high,on=ir.low,Dn=ge+_r,En=se+fn+(Dn>>>0<ge>>>0?1:0),Dn=Dn+St,En=En+ut+(Dn>>>0<St>>>0?1:0),Dn=Dn+on,En=En+Kr+(Dn>>>0<on>>>0?1:0),Dn=Dn+Be,En=En+Ue+(Dn>>>0<Be>>>0?1:0),po=Gt+Pt,or=Wt+Ht+(po>>>0<Gt>>>0?1:0);se=ht,ge=ie,ht=Ut,ie=Qt,Ut=ot,Qt=ct,ct=qe+Dn|0,ot=Bt+En+(ct>>>0<qe>>>0?1:0)|0,Bt=Je,qe=Tt,Je=st,Tt=Ve,st=Te,Ve=Ee,Ee=Dn+po|0,Te=En+or+(Ee>>>0<Dn>>>0?1:0)|0}z=E.low=z+Ee,E.high=W+Te+(z>>>0<Ee>>>0?1:0),J=R.low=J+Ve,R.high=Q+st+(J>>>0<Ve>>>0?1:0),ee=O.low=ee+Tt,O.high=re+Je+(ee>>>0<Tt>>>0?1:0),le=I.low=le+qe,I.high=fe+Bt+(le>>>0<qe>>>0?1:0),me=L.low=me+ct,L.high=ne+ot+(me>>>0<ct>>>0?1:0),N=B.low=N+Qt,B.high=Ce+Ut+(N>>>0<Qt>>>0?1:0),te=H.low=te+ie,H.high=j+ht+(te>>>0<ie>>>0?1:0),ue=G.low=ue+ge,G.high=U+se+(ue>>>0<ge>>>0?1:0)},_doFinalize:function(){var w=this._data,T=w.words,A=this._nDataBytes*8,E=w.sigBytes*8;T[E>>>5]|=128<<24-E%32,T[(E+128>>>10<<5)+30]=Math.floor(A/4294967296),T[(E+128>>>10<<5)+31]=A,w.sigBytes=T.length*4,this._process();var R=this._hash.toX32();return R},clone:function(){var w=a.clone.call(this);return w._hash=this._hash.clone(),w},blockSize:1024/32});r.SHA512=a._createHelper(_),r.HmacSHA512=a._createHmacHelper(_)}(),n.SHA512})}(qk)),qk.exports}var Gk={exports:{}},Cge=Gk.exports,SH;function Ege(){return SH||(SH=1,function(e,t){(function(n,r,o){e.exports=r(Jn(),Bk(),_H())})(Cge,function(n){return function(){var r=n,o=r.x64,a=o.Word,l=o.WordArray,d=r.algo,h=d.SHA512,p=d.SHA384=h.extend({_doReset:function(){this._hash=new l.init([new a.init(3418070365,3238371032),new a.init(1654270250,914150663),new a.init(2438529370,812702999),new a.init(355462360,4144912697),new a.init(1731405415,4290775857),new a.init(2394180231,1750603025),new a.init(3675008525,1694076839),new a.init(1203062813,3204075428)])},_doFinalize:function(){var y=h._doFinalize.call(this);return y.sigBytes-=16,y}});r.SHA384=h._createHelper(p),r.HmacSHA384=h._createHmacHelper(p)}(),n.SHA384})}(Gk)),Gk.exports}var Vk={exports:{}},Age=Vk.exports,wH;function kge(){return wH||(wH=1,function(e,t){(function(n,r,o){e.exports=r(Jn(),Bk())})(Age,function(n){return function(r){var o=n,a=o.lib,l=a.WordArray,d=a.Hasher,h=o.x64,p=h.Word,y=o.algo,m=[],x=[],_=[];(function(){for(var A=1,E=0,R=0;R<24;R++){m[A+5*E]=(R+1)*(R+2)/2%64;var O=E%5,I=(2*A+3*E)%5;A=O,E=I}for(var A=0;A<5;A++)for(var E=0;E<5;E++)x[A+5*E]=E+(2*A+3*E)%5*5;for(var L=1,B=0;B<24;B++){for(var H=0,G=0,W=0;W<7;W++){if(L&1){var z=(1<<W)-1;z<32?G^=1<<z:H^=1<<z-32}L&128?L=L<<1^113:L<<=1}_[B]=p.create(H,G)}})();var w=[];(function(){for(var A=0;A<25;A++)w[A]=p.create()})();var T=y.SHA3=d.extend({cfg:d.cfg.extend({outputLength:512}),_doReset:function(){for(var A=this._state=[],E=0;E<25;E++)A[E]=new p.init;this.blockSize=(1600-2*this.cfg.outputLength)/32},_doProcessBlock:function(A,E){for(var R=this._state,O=this.blockSize/2,I=0;I<O;I++){var L=A[E+2*I],B=A[E+2*I+1];L=(L<<8|L>>>24)&16711935|(L<<24|L>>>8)&4278255360,B=(B<<8|B>>>24)&16711935|(B<<24|B>>>8)&4278255360;var H=R[I];H.high^=B,H.low^=L}for(var G=0;G<24;G++){for(var W=0;W<5;W++){for(var z=0,Q=0,J=0;J<5;J++){var H=R[W+5*J];z^=H.high,Q^=H.low}var re=w[W];re.high=z,re.low=Q}for(var W=0;W<5;W++)for(var ee=w[(W+4)%5],fe=w[(W+1)%5],le=fe.high,ne=fe.low,z=ee.high^(le<<1|ne>>>31),Q=ee.low^(ne<<1|le>>>31),J=0;J<5;J++){var H=R[W+5*J];H.high^=z,H.low^=Q}for(var me=1;me<25;me++){var z,Q,H=R[me],Ce=H.high,N=H.low,j=m[me];j<32?(z=Ce<<j|N>>>32-j,Q=N<<j|Ce>>>32-j):(z=N<<j-32|Ce>>>64-j,Q=Ce<<j-32|N>>>64-j);var te=w[x[me]];te.high=z,te.low=Q}var U=w[0],ue=R[0];U.high=ue.high,U.low=ue.low;for(var W=0;W<5;W++)for(var J=0;J<5;J++){var me=W+5*J,H=R[me],Te=w[me],Ee=w[(W+1)%5+5*J],st=w[(W+2)%5+5*J];H.high=Te.high^~Ee.high&st.high,H.low=Te.low^~Ee.low&st.low}var H=R[0],Ve=_[G];H.high^=Ve.high,H.low^=Ve.low}},_doFinalize:function(){var A=this._data,E=A.words;this._nDataBytes*8;var R=A.sigBytes*8,O=this.blockSize*32;E[R>>>5]|=1<<24-R%32,E[(r.ceil((R+1)/O)*O>>>5)-1]|=128,A.sigBytes=E.length*4,this._process();for(var I=this._state,L=this.cfg.outputLength/8,B=L/8,H=[],G=0;G<B;G++){var W=I[G],z=W.high,Q=W.low;z=(z<<8|z>>>24)&16711935|(z<<24|z>>>8)&4278255360,Q=(Q<<8|Q>>>24)&16711935|(Q<<24|Q>>>8)&4278255360,H.push(Q),H.push(z)}return new l.init(H,L)},clone:function(){for(var A=d.clone.call(this),E=A._state=this._state.slice(0),R=0;R<25;R++)E[R]=E[R].clone();return A}});o.SHA3=d._createHelper(T),o.HmacSHA3=d._createHmacHelper(T)}(Math),n.SHA3})}(Vk)),Vk.exports}var Yk={exports:{}},Tge=Yk.exports,CH;function Rge(){return CH||(CH=1,function(e,t){(function(n,r){e.exports=r(Jn())})(Tge,function(n){/** @preserve
5202
5202
  (c) 2012 by Cédric Mesnil. All rights reserved.
5203
5203
 
5204
5204
  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
package/dist/module/ai.js CHANGED
@@ -40125,7 +40125,7 @@ const lfe = ne.button`
40125
40125
  color: t.fontColor || "#000"
40126
40126
  },
40127
40127
  children: [
40128
- e === "catch-org-ai" && /* @__PURE__ */ M.jsx(Afe, { children: /* @__PURE__ */ M.jsx("span", { children: '"Catch org AI" can make mistakes.' }) }),
40128
+ (e === "catch-org-ai" || e === "letsgo-catch") && /* @__PURE__ */ M.jsx(Afe, { children: /* @__PURE__ */ M.jsx("span", { children: `"${t.chatbotName}" can make mistakes.` }) }),
40129
40129
  /* @__PURE__ */ M.jsx("div", { children: /* @__PURE__ */ M.jsx(
40130
40130
  o4,
40131
40131
  {
@@ -42535,7 +42535,7 @@ const lfe = ne.button`
42535
42535
  color: t.fontColor || "#000"
42536
42536
  },
42537
42537
  children: [
42538
- e === "catch-org-ai" && /* @__PURE__ */ M.jsx(sde, { children: /* @__PURE__ */ M.jsx("span", { children: '"Catch org AI" can make mistakes.' }) }),
42538
+ (e === "catch-org-ai" || e === "letsgo-catch") && /* @__PURE__ */ M.jsx(sde, { children: /* @__PURE__ */ M.jsx("span", { children: `"${t.chatbotName}" can make mistakes.` }) }),
42539
42539
  /* @__PURE__ */ M.jsx("div", { children: /* @__PURE__ */ M.jsx(
42540
42540
  o4,
42541
42541
  {
@@ -44913,7 +44913,7 @@ const lfe = ne.button`
44913
44913
  color: t.fontColor || "#000"
44914
44914
  },
44915
44915
  children: [
44916
- e === "catch-org-ai" && /* @__PURE__ */ M.jsx(qde, { children: /* @__PURE__ */ M.jsx("span", { children: '"Catch org AI" can make mistakes.' }) }),
44916
+ (e === "catch-org-ai" || e === "letsgo-catch") && /* @__PURE__ */ M.jsx(qde, { children: /* @__PURE__ */ M.jsx("span", { children: `"${t.chatbotName}" can make mistakes.` }) }),
44917
44917
  /* @__PURE__ */ M.jsx("div", { children: /* @__PURE__ */ M.jsx(
44918
44918
  o4,
44919
44919
  {
@@ -47292,7 +47292,7 @@ const lfe = ne.button`
47292
47292
  color: t.fontColor || "#000"
47293
47293
  },
47294
47294
  children: [
47295
- e === "catch-org-ai" && /* @__PURE__ */ M.jsx(khe, { children: /* @__PURE__ */ M.jsx("span", { children: '"Catch org AI" can make mistakes.' }) }),
47295
+ (e === "catch-org-ai" || e === "letsgo-catch") && /* @__PURE__ */ M.jsx(khe, { children: /* @__PURE__ */ M.jsx("span", { children: `"${t.chatbotName}" can make mistakes.` }) }),
47296
47296
  /* @__PURE__ */ M.jsx("div", { children: /* @__PURE__ */ M.jsx(
47297
47297
  o4,
47298
47298
  {
@@ -2561,7 +2561,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
2561
2561
 
2562
2562
  `+Ne+`
2563
2563
 
2564
- => User Action: Klaviyo form closed`}return""},ct=Ut=>{Ut instanceof CustomEvent&&Se(Ut)};return window.addEventListener("klaviyoForms",ct),()=>{window.removeEventListener("klaviyoForms",ct)}},[ae,t,r]);const[Tt,Ei]=re.useState(!1),ur=J==="Highest"?"120px":J==="Higher"?"60px":"15px",ao=async()=>{try{const Se=await fetch(`${wi}/api/wordpress/support`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({chatid:er()+e,nameSpace:e,userName:tt.name,userEmail:tt.email,userMessage:tt.message,tag:"support"})});if(Se.ok){const rt=`support-confirm-${Date.now()}`;m(ct=>[...ct,{text:"Thanks for reaching out! Our support team has received your request and will get back to you within 24 hours.<br>In the meantime, feel free to continue chatting with me - I'll do my best to help!",isBot:!0,leading_queries:Lt,conversationId:rt}]),d(rt),$e(ct=>({...ct,leadingQueries:!0})),zt([]),console.log("Connected to support with existing user info:",Bo())}else{const rt=await Se.json();console.error("Failed to connect to support:",rt),m(ct=>[...ct,{text:"Sorry, we couldn't connect you to support at the moment.<br>Please try again later.",isBot:!0}])}}catch{m(rt=>[...rt,{text:"Sorry, we couldn't connect you to support at the moment.<br>Please try again later.",isBot:!0}])}},Lo=()=>{const Se=Bo();let rt=[];const ct=h[h.length-1];ct!=null&&ct.leading_queries&&ct.leading_queries.length>0?rt=ct.leading_queries:h.length<=1&&(rt=rr.flatMap(Ut=>Array.isArray(Ut)?Ut.map(nt=>nt.question):[Ut.question]).slice(0,4)),zt(rt),Se&&Se.name&&Se.email&&ft({name:Se==null?void 0:Se.name,email:Se==null?void 0:Se.email,message:""}),m(Ut=>[...Ut,{text:"Please provide your name, email and message to connect with support.",isBot:!0}]),Ye(!0)},$i=async Se=>{Se.preventDefault();const rt={name:"",email:"",message:""};let ct=!0;const Ut=tt.name.trim(),nt=tt.message.trim();Ut||(rt.name="Name cannot be empty or just whitespace.",ct=!1),(!tt.email||!sm.isEmail(tt.email))&&(rt.email="Please enter a valid email address.",ct=!1),nt||(rt.message="Message cannot be empty or just whitespace.",ct=!1),ne(rt),ct&&(Nc({name:Ut,email:tt.email}),Ye(!1),m(Ne=>Ne.slice(0,-1)),await ao())};return it.useEffect(()=>{if(h.length===1&&h[0].isBot){Le(rt=>({...rt,leadingQueries:!0}));const Se=setTimeout(()=>{Le(rt=>({...rt,leadingQueries:!1}))},2e3);return()=>clearTimeout(Se)}},[h]),console.debug("main render"),!t||t.show_bot===!1||a?null:R.jsxs(K.ThemeProvider,{theme:tC(t,e),children:[R.jsx("link",{rel:"preconnect",href:"https://fonts.googleapis.com"}),R.jsx("link",{rel:"preconnect",href:"https://fonts.gstatic.com",crossOrigin:"anonymous"}),R.jsx("link",{href:"https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap",rel:"stylesheet"}),R.jsx("link",{href:"https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,100;0,300;0,400;0,700;0,900;1,100;1,300;1,400;1,700;1,900&display=swap",rel:"stylesheet"}),R.jsx(tce,{}),!ie&&(vi==null?void 0:vi.length)!==0&&R.jsx(ece,{className:Bt?"visible":"",$botId:e,$iconSize:G,$removeLogoBackground:t.removeLogoBackground,topOffset:ur,style:{right:z?"auto":"24px",left:z?"24px":"auto",display:"flex",flexDirection:"column",alignItems:z?"flex-start":"flex-end"},children:Re.suggestions?R.jsx(Ci,{isBot:!0,children:R.jsx(ms,{loading:Re.suggestions})}):vi.map((Se,rt)=>{if(Array.isArray(Se)){const ct=Se.map(Ut=>({question:Ut.question,isHighlighted:Ut.isHighlighted??!1})).filter(Ut=>!he.has(Ut.question));return R.jsx(XF,{$index:rt,$totalCount:vi.length,children:R.jsx(hle,{messages:ct,botId:e,uiData:t,onClick:Ut=>{const nt=Se.find(Ne=>Ne.question===Ut);Me(!0,"suggested_question_clicked"),Ue(Ne=>{const an=new Set(Ne);return an.add(Ut),an}),window.DebalesChat.track(Wt.SUGGESTED_QUESTION_CLICKED,{suggested_question:nt}),!D&&nt?(at(!1),Et(!0),r({message:nt.Follow_up_Question??nt.question,answer:nt==null?void 0:nt.answer,products:nt==null?void 0:nt.products,fromKlaviyo:!1,leading_queries:nt==null?void 0:nt.leading_queries,followUpQuestion:nt==null?void 0:nt.Follow_up_Question,messType:"suggested_question"})):(at(!1),Et(!0),E(!0),O(nt))}})},rt)}else return R.jsx(XF,{$index:rt,$totalCount:vi.length,children:R.jsx(fle,{value:`${Se.question}`,index:rt,botId:e,uiData:t,onClose:()=>{Ue(ct=>{const Ut=new Set(ct);return Ut.add(Se.question),Ut})},onClick:()=>{Me(!0,"suggested_question_clicked"),Ue(ct=>{const Ut=new Set(ct);return Ut.add(Se.question),Ut}),window.DebalesChat.track(Wt.SUGGESTED_QUESTION_CLICKED,{suggested_question:Se}),D?(at(!1),Et(!0),E(!0),O(Se)):(at(!1),Et(!0),r({message:Se.question,answer:Se.answer,products:Se.products,leading_queries:Se.leading_queries,followUpQuestion:Se.Follow_up_Question,messType:"suggested_question"}))},isHighlighted:Se.isHighlighted??!1})},rt)})}),R.jsxs($ue,{$topOffset:ur,$removeLogoBackground:t.removeLogoBackground,style:{display:ie?"none":"inline-flex",right:z?"auto":"24px",left:z?"24px":"auto"},children:[R.jsx(Lue,{$showAnimation:t.enableChatButtonBackgroundAnimation??!1,$animationType:"Ping",$animationColor:t.chatButtonBackgroundAnimationColor||"#f48722",$backgroundColor:t.backgroundColor||"#fff",$removeLogoBackground:t.removeLogoBackground,$topOffset:ur,$iconSize:G}),R.jsx(Nue,{$backgroundColor:t.removeLogoBackground?"transparent":t.backgroundColor||"#fff",$botId:e,$iconSize:G,$removeLogoBackground:t.removeLogoBackground,topOffset:ur,$showAnimation:t.enableChatButtonBackgroundAnimation,$animationType:"Ping",$animationColor:t.chatButtonBackgroundAnimationColor||"#f48722",id:"debales-chat-button","data-testid":"debales-chat-button",onClick:()=>{if(window.DebalesChat.track(Wt.CHAT_BUTTON_CLICKED),Me(!ie,"chat_button_clicked"),!ie){const Se=S();Se.length>0?(m(Se),at(!1),Et(!0)):(at(!0),Et(!1),Le(rt=>({...rt,initialMessage:!0,leadingQueries:!0})),$e({text:!0,leadingQueries:!1,collections:!1,products:!1,variants:!1,cartSummary:!1,bulkItems:!1}),setTimeout(()=>{at(!1),Et(!0),Le(ct=>({...ct,initialMessage:!1}));const rt={text:(t==null?void 0:t.initialMessage)||"Hi, I am an AI chatbot, how can I help you today?",isBot:!0};m([rt]),Le(ct=>({...ct,leadingQueries:!0})),setTimeout(()=>{$e(ct=>({...ct,leadingQueries:!0}))},Zt)},Zt))}},"aria-label":"Chat",style:{display:ie?"none":"inline-flex",right:z?"auto":"24px",left:z?"24px":"auto"},children:R.jsx(zue,{$botId:e,$removeLogoBackground:t.removeLogoBackground,"aria-hidden":"true",src:t.bot_logo,alt:"Chat Bot Icon"})})]}),ie&&bo.createPortal(R.jsx(R.Fragment,{children:R.jsxs(Hue,{$backgroundColor:t.backgroundColor||"#fff",$fullScreenOnMobile:t.fullScreenOnMobile,$headerFontColor:t.headerFontColor||"#1C1C1C",$isLeft:z,$topOffset:ur,$mobileDisplayMode:t.mobileDisplayMode,$isVisible:de,"data-testid":"debales-chat-container",children:[R.jsxs(Gue,{$backgroundColor:Fe(e)?t.backgroundColor:t.botBackgroundColor||"#fff",style:{color:t.headerFontColor},children:[R.jsx("div",{style:{flexGrow:.1,display:"flex",justifyContent:"center",alignItems:"center",overflow:"hidden",marginRight:"8px",gap:"10px"},children:Fe(e)?R.jsxs(R.Fragment,{children:[R.jsx(VF,{"aria-hidden":"true",src:t.bot_logo,alt:"Chat Bot Icon"}),R.jsxs(Fue,{$botNameColor:t.headerFontColor,children:[R.jsxs("div",{style:{fontWeight:"700",wordBreak:"break-word"},children:[t.chatbotName,e==="catch-org-ai"&&R.jsx(jue,{$backgroundColor:t.callToActionBackgroundColor,$fontColor:t.callToActionFontColor,children:"Beta"})]}),R.jsx(Uue,{})]})]}):R.jsx(que,{children:R.jsxs(Pue,{children:[R.jsx(VF,{src:t.bot_logo,alt:"Chat Bot Icon"}),R.jsx("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",display:"inline-block",maxWidth:"22ch"},children:t.chatbotName})]})})}),R.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginLeft:"auto",flexShrink:0},children:[R.jsxs(nce,{children:[R.jsx(YF,{$iconBG:t.backgroundColor,onClick:Lo,"aria-label":"Support","data-testid":"debales-support-button",children:R.jsx(a2,{color:t.headerFontColor})}),R.jsx(JF,{children:"Click to chat with a Live Support Agent now."})]}),R.jsx(YF,{$iconBG:t.backgroundColor,onClick:()=>{oe?mi(!0):Me(!1,"close_button_clicked")},id:"debales-minimize-button","data-testid":"debales-minimize-button","aria-label":"Minimize",children:R.jsx(lm,{botNameColor:t.headerFontColor})})]}),R.jsx(uce,{$backgroundColor:t.botBackgroundColor||"#fff",style:{opacity:Xt?1:0}})]}),R.jsxs(Zue,{$backgroundColor:t.botBackgroundColor||"#fff",$mobileDisplayMode:t.mobileDisplayMode,children:[Tt&&((so=(mr=t.pluginConfig)==null?void 0:mr.collectedUserInfo)==null?void 0:so.discount)&&R.jsx(g2,{discount:t.pluginConfig.collectedUserInfo.discount,uiData:t,onClose:()=>{Ei(!1),window.DebalesChat.track(Wt.DISCOUNT_VIEWED,{discount:t.pluginConfig.collectedUserInfo.discount})}}),R.jsx(_2,{uidata:t,product:gr,showModel:tr,setShowModel:nr,onVariantSelect:Se=>{console.debug("VariantSelectionModel : Adding item to cart:",Se),N(Se.id,1,{productId:(gr==null?void 0:gr.productId)||""}),Pn(!0),window.DebalesChat.track(Wt.ADD_TO_CART_CLICKED,{product:Se.title,price:Number(Se.price),link:`https://${t.shopifyShopDomain}/variants/${Se.id}`,message:l,chatId:er()+e})}}),pr&&R.jsx(m2,{setShowExitModal:mi,handleCloseChatbot:sn,chatId:er()+e}),R.jsxs(Vue,{id:"debales-conversation-group",$botBackgroundColor:t.botBackgroundColor||"#fff",ref:le,$mobileDisplayMode:t.mobileDisplayMode,"data-testid":"debales-conversation-group",children:[R.jsx(sce,{$backgroundColor:t.botBackgroundColor||"#fff",style:{opacity:Xt?1:0}}),R.jsxs(Yue,{children:[Ot&&h.map((Se,rt)=>{const ct=Se.isBot,Ut=sp(Se.text);return Se.hideConfirmation?null:R.jsxs(it.Fragment,{children:[ct&&R.jsxs(ZF,{$fontColor:t.botFontColor||"#000",$botMessageColor:t.botBackgroundColor||"#fff","data-testid":"debales-ai-message-container",children:[R.jsx("img",{src:ct?t.bot_logo:t.userMessage_logo,alt:"Chat User Icon",style:{marginLeft:"8px"}}),R.jsxs(WF,{children:[Ut.map(nt=>R.jsx("div",{children:R.jsx(Ci,{isBot:ct,children:R.jsx(od,{components:{a:({href:Ne,children:an})=>{const zn=()=>{Ne!=null&&Ne.startsWith("https://shop.catch.org/")&&window.DebalesChat.track(Wt.SHOPIFY_LINK_CLICKED)};return R.jsx("a",{href:Ne,target:"_blank",onClick:zn,children:an})}},remarkPlugins:[HS,dC],children:nt})})})),Se.collections&&l===Se.conversationId&&pe.collections&&R.jsx(p2,{message:Se,botId:e,uidata:t,onSendMessage:r,loading:p}),Se.products&&l===Se.conversationId&&pe.products&&R.jsx(y2,{message:Se,botId:e,uidata:t,onSendMessage:r,loading:p,storeMetaData:n,platform:V,setShowVariantModel:nr,setSelectedProduct:Kn,setCartVersion:te}),o&&R.jsx(FD,{children:R.jsx(K1,{onClick:()=>{window._klOnsite&&(window._klOnsite.push(["openForm",De]),Me(!1,"klaviyo_grab_deal_button"))},children:"🚀 Grab Deal Now!"})}),I&&I.itemCount>0&&l===Se.conversationId&&pe.cartSummary&&kt&&R.jsx(c2,{onCheckout:Qi,onKeepShopping:()=>{Pn(!1)}}),ot&&ot.length>0&&l===Se.conversationId&&pe.bulkItems&&R.jsx(r2,{onClick:()=>En(Se.conversationId),children:"Add Bulk Items to Cart"}),k&&h.indexOf(Se)===h.length-1&&R.jsx(R.Fragment,{children:R.jsx(x2,{setShowModel:nt=>{var an,zn;const Ne=typeof nt=="function"?nt(k):nt;E(Ne),!Ne&&((zn=(an=t.pluginConfig)==null?void 0:an.collectedUserInfo)!=null&&zn.discount)&&Ei(!0)},inChat:!0,showFormInstructions:!1})}),Pt&&h.indexOf(Se)===h.length-1&&R.jsxs(rce,{onSubmit:$i,noValidate:!0,"data-testid":"debales-support-form",children:[Fe(e)?R.jsxs(R.Fragment,{children:[R.jsx(ql,{label:"Name",name:"name",type:"text",value:tt.name,onChange:nt=>ft(Ne=>({...Ne,name:nt.target.value})),required:!0,error:bt.name,isCollectiveBot:!0}),R.jsx(ql,{label:"Email",name:"email",type:"email",value:tt.email,onChange:nt=>ft(Ne=>({...Ne,email:nt.target.value})),required:!0,error:bt.email,isCollectiveBot:!0}),R.jsx(v2,{label:"Message",name:"message",value:tt.message,onChange:nt=>ft(Ne=>({...Ne,message:nt.target.value})),required:!0,error:bt.message,rows:4,isCollectiveBot:!0})]}):R.jsxs(R.Fragment,{children:[R.jsxs(UD,{children:[R.jsxs(jD,{children:["Name",R.jsx("span",{children:"*"})]}),R.jsx(eU,{type:"text",required:!0,value:tt.name,onChange:nt=>ft(Ne=>({...Ne,name:nt.target.value})),placeholder:"John"}),bt.name&&R.jsx("p",{style:{color:"red",fontSize:"12px",margin:"4px 0 0"},children:bt.name})]}),R.jsxs(UD,{children:[R.jsxs(jD,{children:["Email",R.jsx("span",{children:"*"})]}),R.jsx(eU,{type:"email",required:!0,value:tt.email,onChange:nt=>ft(Ne=>({...Ne,email:nt.target.value})),placeholder:"olivia@untitledui.com"}),bt.email&&R.jsx("p",{style:{color:"red",fontSize:"12px",margin:"4px 0 0"},children:bt.email})]}),R.jsxs(UD,{children:[R.jsxs(jD,{children:["Message",R.jsx("span",{children:"*"})]}),R.jsx(ice,{required:!0,value:tt.message,onChange:nt=>ft(Ne=>({...Ne,message:nt.target.value})),placeholder:"I need help with..."}),bt.message&&R.jsx("p",{style:{color:"red",fontSize:"12px",margin:"4px 0 0"},children:bt.message})]})]}),R.jsx(ace,{children:R.jsx(oce,{type:"submit",children:"Submit"})})]}),ht&&!p&&l===Se.conversationId&&R.jsx(Ci,{isBot:ct,children:R.jsx(ms,{loading:ht})})]})]}),!ct&&R.jsx(Xue,{$fontColor:t.userFontColor||"#000",$botMessageColor:t.botBackgroundColor||"#fff",children:R.jsx(Ci,{isBot:!!ct,children:R.jsx(od,{children:Se.text})})}),h.length==1&&rt==0&&!k&&R.jsx(FD,{children:Re.leadingQueries?R.jsx(Ci,{isBot:ct??!0,children:R.jsx(ms,{loading:Re.leadingQueries})}):rr.map(nt=>Array.isArray(nt)?nt[0]:nt).map((nt,Ne)=>R.jsxs(KF,{style:{backgroundColor:t.callToActionBackgroundColor,color:t.callToActionFontColor},onClick:()=>{D?(E(!0),O({question:nt.question,answer:nt.answer,products:nt.products,path:"/",nameSpace:window.DebalesChat.projectId})):(at(!1),Et(!0),r({message:nt.question,answer:nt.answer,products:nt.products,leading_queries:nt.leading_queries,followUpQuestion:nt.Follow_up_Question,messType:"leading_query"})),Ue(an=>{const zn=new Set(an);return zn.add(nt.question),zn}),window.DebalesChat.track(Wt.INITIAL_LEADING_QUERY_SUGGESTED_QUESTION_CLICKED,{question:nt.question})},disabled:p,$disabled:p,children:[nt.question,R.jsx(QF,{color:t.callToActionFontColor})]},Ne))}),Se.leading_queries&&Se.leading_queries.length>0&&l===Se.conversationId&&pe.leadingQueries&&!o&&!k&&R.jsx(FD,{children:Se.leading_queries.map((nt,Ne)=>R.jsxs(KF,{style:{backgroundColor:t.callToActionBackgroundColor,color:t.callToActionFontColor},onClick:()=>{D?(E(!0),O({question:nt,path:"/",nameSpace:window.DebalesChat.projectId})):r({message:nt,messType:"leading_query"}),window.DebalesChat.track(Wt.LEADING_QUERY_CLICKED,{query:nt})},disabled:p,$disabled:p,children:[nt,R.jsx(QF,{color:t.callToActionFontColor})]},Ne))})]},rt)}),(p||Ct)&&R.jsxs(ZF,{$fontColor:t.botFontColor||"#000",$botMessageColor:t.botBackgroundColor||"#fff",children:[R.jsx("img",{src:t.bot_logo,alt:"Chat User Icon"}),R.jsx(WF,{children:R.jsx(Ci,{isBot:!0,children:R.jsx("div",{style:{display:"flex",alignItems:"center",gap:"4px",animation:"fadeIn 0.3s ease-in-out"},children:R.jsx(ms,{loading:p||Ct})})})})]})]}),R.jsx(lce,{$backgroundColor:t.botBackgroundColor||"#fff",style:{opacity:yn?1:0}})]}),R.jsxs("div",{className:"debales-footer-container",style:{width:"calc(100%-24px)",backgroundColor:t.botBackgroundColor||"#fff",color:t.fontColor||"#000"},children:[e==="catch-org-ai"&&R.jsx(Wue,{children:R.jsx("span",{children:'"Catch org AI" can make mistakes.'})}),R.jsx("div",{children:R.jsx(S2,{disabled:p,inputState:!1})}),(t.debales_branding??!0)&&R.jsxs(Que,{href:"https://debales.ai/?open=true",target:"_blank",title:"debales-link",style:{color:t.fontColor?t.fontColor:"fff",marginTop:e==="catch-org-ai"?"0":"9px"},children:[R.jsx("p",{children:"Powered by"}),R.jsxs(Kue,{children:[R.jsx("img",{src:`${wi}/images/debales_logo_d.png`,alt:"Debales logo"}),R.jsx("p",{children:"DEBALES"})]})]})]})]})]})}),Y.shadowRoot)]})},cce=K.p`
2564
+ => User Action: Klaviyo form closed`}return""},ct=Ut=>{Ut instanceof CustomEvent&&Se(Ut)};return window.addEventListener("klaviyoForms",ct),()=>{window.removeEventListener("klaviyoForms",ct)}},[ae,t,r]);const[Tt,Ei]=re.useState(!1),ur=J==="Highest"?"120px":J==="Higher"?"60px":"15px",ao=async()=>{try{const Se=await fetch(`${wi}/api/wordpress/support`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({chatid:er()+e,nameSpace:e,userName:tt.name,userEmail:tt.email,userMessage:tt.message,tag:"support"})});if(Se.ok){const rt=`support-confirm-${Date.now()}`;m(ct=>[...ct,{text:"Thanks for reaching out! Our support team has received your request and will get back to you within 24 hours.<br>In the meantime, feel free to continue chatting with me - I'll do my best to help!",isBot:!0,leading_queries:Lt,conversationId:rt}]),d(rt),$e(ct=>({...ct,leadingQueries:!0})),zt([]),console.log("Connected to support with existing user info:",Bo())}else{const rt=await Se.json();console.error("Failed to connect to support:",rt),m(ct=>[...ct,{text:"Sorry, we couldn't connect you to support at the moment.<br>Please try again later.",isBot:!0}])}}catch{m(rt=>[...rt,{text:"Sorry, we couldn't connect you to support at the moment.<br>Please try again later.",isBot:!0}])}},Lo=()=>{const Se=Bo();let rt=[];const ct=h[h.length-1];ct!=null&&ct.leading_queries&&ct.leading_queries.length>0?rt=ct.leading_queries:h.length<=1&&(rt=rr.flatMap(Ut=>Array.isArray(Ut)?Ut.map(nt=>nt.question):[Ut.question]).slice(0,4)),zt(rt),Se&&Se.name&&Se.email&&ft({name:Se==null?void 0:Se.name,email:Se==null?void 0:Se.email,message:""}),m(Ut=>[...Ut,{text:"Please provide your name, email and message to connect with support.",isBot:!0}]),Ye(!0)},$i=async Se=>{Se.preventDefault();const rt={name:"",email:"",message:""};let ct=!0;const Ut=tt.name.trim(),nt=tt.message.trim();Ut||(rt.name="Name cannot be empty or just whitespace.",ct=!1),(!tt.email||!sm.isEmail(tt.email))&&(rt.email="Please enter a valid email address.",ct=!1),nt||(rt.message="Message cannot be empty or just whitespace.",ct=!1),ne(rt),ct&&(Nc({name:Ut,email:tt.email}),Ye(!1),m(Ne=>Ne.slice(0,-1)),await ao())};return it.useEffect(()=>{if(h.length===1&&h[0].isBot){Le(rt=>({...rt,leadingQueries:!0}));const Se=setTimeout(()=>{Le(rt=>({...rt,leadingQueries:!1}))},2e3);return()=>clearTimeout(Se)}},[h]),console.debug("main render"),!t||t.show_bot===!1||a?null:R.jsxs(K.ThemeProvider,{theme:tC(t,e),children:[R.jsx("link",{rel:"preconnect",href:"https://fonts.googleapis.com"}),R.jsx("link",{rel:"preconnect",href:"https://fonts.gstatic.com",crossOrigin:"anonymous"}),R.jsx("link",{href:"https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap",rel:"stylesheet"}),R.jsx("link",{href:"https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,100;0,300;0,400;0,700;0,900;1,100;1,300;1,400;1,700;1,900&display=swap",rel:"stylesheet"}),R.jsx(tce,{}),!ie&&(vi==null?void 0:vi.length)!==0&&R.jsx(ece,{className:Bt?"visible":"",$botId:e,$iconSize:G,$removeLogoBackground:t.removeLogoBackground,topOffset:ur,style:{right:z?"auto":"24px",left:z?"24px":"auto",display:"flex",flexDirection:"column",alignItems:z?"flex-start":"flex-end"},children:Re.suggestions?R.jsx(Ci,{isBot:!0,children:R.jsx(ms,{loading:Re.suggestions})}):vi.map((Se,rt)=>{if(Array.isArray(Se)){const ct=Se.map(Ut=>({question:Ut.question,isHighlighted:Ut.isHighlighted??!1})).filter(Ut=>!he.has(Ut.question));return R.jsx(XF,{$index:rt,$totalCount:vi.length,children:R.jsx(hle,{messages:ct,botId:e,uiData:t,onClick:Ut=>{const nt=Se.find(Ne=>Ne.question===Ut);Me(!0,"suggested_question_clicked"),Ue(Ne=>{const an=new Set(Ne);return an.add(Ut),an}),window.DebalesChat.track(Wt.SUGGESTED_QUESTION_CLICKED,{suggested_question:nt}),!D&&nt?(at(!1),Et(!0),r({message:nt.Follow_up_Question??nt.question,answer:nt==null?void 0:nt.answer,products:nt==null?void 0:nt.products,fromKlaviyo:!1,leading_queries:nt==null?void 0:nt.leading_queries,followUpQuestion:nt==null?void 0:nt.Follow_up_Question,messType:"suggested_question"})):(at(!1),Et(!0),E(!0),O(nt))}})},rt)}else return R.jsx(XF,{$index:rt,$totalCount:vi.length,children:R.jsx(fle,{value:`${Se.question}`,index:rt,botId:e,uiData:t,onClose:()=>{Ue(ct=>{const Ut=new Set(ct);return Ut.add(Se.question),Ut})},onClick:()=>{Me(!0,"suggested_question_clicked"),Ue(ct=>{const Ut=new Set(ct);return Ut.add(Se.question),Ut}),window.DebalesChat.track(Wt.SUGGESTED_QUESTION_CLICKED,{suggested_question:Se}),D?(at(!1),Et(!0),E(!0),O(Se)):(at(!1),Et(!0),r({message:Se.question,answer:Se.answer,products:Se.products,leading_queries:Se.leading_queries,followUpQuestion:Se.Follow_up_Question,messType:"suggested_question"}))},isHighlighted:Se.isHighlighted??!1})},rt)})}),R.jsxs($ue,{$topOffset:ur,$removeLogoBackground:t.removeLogoBackground,style:{display:ie?"none":"inline-flex",right:z?"auto":"24px",left:z?"24px":"auto"},children:[R.jsx(Lue,{$showAnimation:t.enableChatButtonBackgroundAnimation??!1,$animationType:"Ping",$animationColor:t.chatButtonBackgroundAnimationColor||"#f48722",$backgroundColor:t.backgroundColor||"#fff",$removeLogoBackground:t.removeLogoBackground,$topOffset:ur,$iconSize:G}),R.jsx(Nue,{$backgroundColor:t.removeLogoBackground?"transparent":t.backgroundColor||"#fff",$botId:e,$iconSize:G,$removeLogoBackground:t.removeLogoBackground,topOffset:ur,$showAnimation:t.enableChatButtonBackgroundAnimation,$animationType:"Ping",$animationColor:t.chatButtonBackgroundAnimationColor||"#f48722",id:"debales-chat-button","data-testid":"debales-chat-button",onClick:()=>{if(window.DebalesChat.track(Wt.CHAT_BUTTON_CLICKED),Me(!ie,"chat_button_clicked"),!ie){const Se=S();Se.length>0?(m(Se),at(!1),Et(!0)):(at(!0),Et(!1),Le(rt=>({...rt,initialMessage:!0,leadingQueries:!0})),$e({text:!0,leadingQueries:!1,collections:!1,products:!1,variants:!1,cartSummary:!1,bulkItems:!1}),setTimeout(()=>{at(!1),Et(!0),Le(ct=>({...ct,initialMessage:!1}));const rt={text:(t==null?void 0:t.initialMessage)||"Hi, I am an AI chatbot, how can I help you today?",isBot:!0};m([rt]),Le(ct=>({...ct,leadingQueries:!0})),setTimeout(()=>{$e(ct=>({...ct,leadingQueries:!0}))},Zt)},Zt))}},"aria-label":"Chat",style:{display:ie?"none":"inline-flex",right:z?"auto":"24px",left:z?"24px":"auto"},children:R.jsx(zue,{$botId:e,$removeLogoBackground:t.removeLogoBackground,"aria-hidden":"true",src:t.bot_logo,alt:"Chat Bot Icon"})})]}),ie&&bo.createPortal(R.jsx(R.Fragment,{children:R.jsxs(Hue,{$backgroundColor:t.backgroundColor||"#fff",$fullScreenOnMobile:t.fullScreenOnMobile,$headerFontColor:t.headerFontColor||"#1C1C1C",$isLeft:z,$topOffset:ur,$mobileDisplayMode:t.mobileDisplayMode,$isVisible:de,"data-testid":"debales-chat-container",children:[R.jsxs(Gue,{$backgroundColor:Fe(e)?t.backgroundColor:t.botBackgroundColor||"#fff",style:{color:t.headerFontColor},children:[R.jsx("div",{style:{flexGrow:.1,display:"flex",justifyContent:"center",alignItems:"center",overflow:"hidden",marginRight:"8px",gap:"10px"},children:Fe(e)?R.jsxs(R.Fragment,{children:[R.jsx(VF,{"aria-hidden":"true",src:t.bot_logo,alt:"Chat Bot Icon"}),R.jsxs(Fue,{$botNameColor:t.headerFontColor,children:[R.jsxs("div",{style:{fontWeight:"700",wordBreak:"break-word"},children:[t.chatbotName,e==="catch-org-ai"&&R.jsx(jue,{$backgroundColor:t.callToActionBackgroundColor,$fontColor:t.callToActionFontColor,children:"Beta"})]}),R.jsx(Uue,{})]})]}):R.jsx(que,{children:R.jsxs(Pue,{children:[R.jsx(VF,{src:t.bot_logo,alt:"Chat Bot Icon"}),R.jsx("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",display:"inline-block",maxWidth:"22ch"},children:t.chatbotName})]})})}),R.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginLeft:"auto",flexShrink:0},children:[R.jsxs(nce,{children:[R.jsx(YF,{$iconBG:t.backgroundColor,onClick:Lo,"aria-label":"Support","data-testid":"debales-support-button",children:R.jsx(a2,{color:t.headerFontColor})}),R.jsx(JF,{children:"Click to chat with a Live Support Agent now."})]}),R.jsx(YF,{$iconBG:t.backgroundColor,onClick:()=>{oe?mi(!0):Me(!1,"close_button_clicked")},id:"debales-minimize-button","data-testid":"debales-minimize-button","aria-label":"Minimize",children:R.jsx(lm,{botNameColor:t.headerFontColor})})]}),R.jsx(uce,{$backgroundColor:t.botBackgroundColor||"#fff",style:{opacity:Xt?1:0}})]}),R.jsxs(Zue,{$backgroundColor:t.botBackgroundColor||"#fff",$mobileDisplayMode:t.mobileDisplayMode,children:[Tt&&((so=(mr=t.pluginConfig)==null?void 0:mr.collectedUserInfo)==null?void 0:so.discount)&&R.jsx(g2,{discount:t.pluginConfig.collectedUserInfo.discount,uiData:t,onClose:()=>{Ei(!1),window.DebalesChat.track(Wt.DISCOUNT_VIEWED,{discount:t.pluginConfig.collectedUserInfo.discount})}}),R.jsx(_2,{uidata:t,product:gr,showModel:tr,setShowModel:nr,onVariantSelect:Se=>{console.debug("VariantSelectionModel : Adding item to cart:",Se),N(Se.id,1,{productId:(gr==null?void 0:gr.productId)||""}),Pn(!0),window.DebalesChat.track(Wt.ADD_TO_CART_CLICKED,{product:Se.title,price:Number(Se.price),link:`https://${t.shopifyShopDomain}/variants/${Se.id}`,message:l,chatId:er()+e})}}),pr&&R.jsx(m2,{setShowExitModal:mi,handleCloseChatbot:sn,chatId:er()+e}),R.jsxs(Vue,{id:"debales-conversation-group",$botBackgroundColor:t.botBackgroundColor||"#fff",ref:le,$mobileDisplayMode:t.mobileDisplayMode,"data-testid":"debales-conversation-group",children:[R.jsx(sce,{$backgroundColor:t.botBackgroundColor||"#fff",style:{opacity:Xt?1:0}}),R.jsxs(Yue,{children:[Ot&&h.map((Se,rt)=>{const ct=Se.isBot,Ut=sp(Se.text);return Se.hideConfirmation?null:R.jsxs(it.Fragment,{children:[ct&&R.jsxs(ZF,{$fontColor:t.botFontColor||"#000",$botMessageColor:t.botBackgroundColor||"#fff","data-testid":"debales-ai-message-container",children:[R.jsx("img",{src:ct?t.bot_logo:t.userMessage_logo,alt:"Chat User Icon",style:{marginLeft:"8px"}}),R.jsxs(WF,{children:[Ut.map(nt=>R.jsx("div",{children:R.jsx(Ci,{isBot:ct,children:R.jsx(od,{components:{a:({href:Ne,children:an})=>{const zn=()=>{Ne!=null&&Ne.startsWith("https://shop.catch.org/")&&window.DebalesChat.track(Wt.SHOPIFY_LINK_CLICKED)};return R.jsx("a",{href:Ne,target:"_blank",onClick:zn,children:an})}},remarkPlugins:[HS,dC],children:nt})})})),Se.collections&&l===Se.conversationId&&pe.collections&&R.jsx(p2,{message:Se,botId:e,uidata:t,onSendMessage:r,loading:p}),Se.products&&l===Se.conversationId&&pe.products&&R.jsx(y2,{message:Se,botId:e,uidata:t,onSendMessage:r,loading:p,storeMetaData:n,platform:V,setShowVariantModel:nr,setSelectedProduct:Kn,setCartVersion:te}),o&&R.jsx(FD,{children:R.jsx(K1,{onClick:()=>{window._klOnsite&&(window._klOnsite.push(["openForm",De]),Me(!1,"klaviyo_grab_deal_button"))},children:"🚀 Grab Deal Now!"})}),I&&I.itemCount>0&&l===Se.conversationId&&pe.cartSummary&&kt&&R.jsx(c2,{onCheckout:Qi,onKeepShopping:()=>{Pn(!1)}}),ot&&ot.length>0&&l===Se.conversationId&&pe.bulkItems&&R.jsx(r2,{onClick:()=>En(Se.conversationId),children:"Add Bulk Items to Cart"}),k&&h.indexOf(Se)===h.length-1&&R.jsx(R.Fragment,{children:R.jsx(x2,{setShowModel:nt=>{var an,zn;const Ne=typeof nt=="function"?nt(k):nt;E(Ne),!Ne&&((zn=(an=t.pluginConfig)==null?void 0:an.collectedUserInfo)!=null&&zn.discount)&&Ei(!0)},inChat:!0,showFormInstructions:!1})}),Pt&&h.indexOf(Se)===h.length-1&&R.jsxs(rce,{onSubmit:$i,noValidate:!0,"data-testid":"debales-support-form",children:[Fe(e)?R.jsxs(R.Fragment,{children:[R.jsx(ql,{label:"Name",name:"name",type:"text",value:tt.name,onChange:nt=>ft(Ne=>({...Ne,name:nt.target.value})),required:!0,error:bt.name,isCollectiveBot:!0}),R.jsx(ql,{label:"Email",name:"email",type:"email",value:tt.email,onChange:nt=>ft(Ne=>({...Ne,email:nt.target.value})),required:!0,error:bt.email,isCollectiveBot:!0}),R.jsx(v2,{label:"Message",name:"message",value:tt.message,onChange:nt=>ft(Ne=>({...Ne,message:nt.target.value})),required:!0,error:bt.message,rows:4,isCollectiveBot:!0})]}):R.jsxs(R.Fragment,{children:[R.jsxs(UD,{children:[R.jsxs(jD,{children:["Name",R.jsx("span",{children:"*"})]}),R.jsx(eU,{type:"text",required:!0,value:tt.name,onChange:nt=>ft(Ne=>({...Ne,name:nt.target.value})),placeholder:"John"}),bt.name&&R.jsx("p",{style:{color:"red",fontSize:"12px",margin:"4px 0 0"},children:bt.name})]}),R.jsxs(UD,{children:[R.jsxs(jD,{children:["Email",R.jsx("span",{children:"*"})]}),R.jsx(eU,{type:"email",required:!0,value:tt.email,onChange:nt=>ft(Ne=>({...Ne,email:nt.target.value})),placeholder:"olivia@untitledui.com"}),bt.email&&R.jsx("p",{style:{color:"red",fontSize:"12px",margin:"4px 0 0"},children:bt.email})]}),R.jsxs(UD,{children:[R.jsxs(jD,{children:["Message",R.jsx("span",{children:"*"})]}),R.jsx(ice,{required:!0,value:tt.message,onChange:nt=>ft(Ne=>({...Ne,message:nt.target.value})),placeholder:"I need help with..."}),bt.message&&R.jsx("p",{style:{color:"red",fontSize:"12px",margin:"4px 0 0"},children:bt.message})]})]}),R.jsx(ace,{children:R.jsx(oce,{type:"submit",children:"Submit"})})]}),ht&&!p&&l===Se.conversationId&&R.jsx(Ci,{isBot:ct,children:R.jsx(ms,{loading:ht})})]})]}),!ct&&R.jsx(Xue,{$fontColor:t.userFontColor||"#000",$botMessageColor:t.botBackgroundColor||"#fff",children:R.jsx(Ci,{isBot:!!ct,children:R.jsx(od,{children:Se.text})})}),h.length==1&&rt==0&&!k&&R.jsx(FD,{children:Re.leadingQueries?R.jsx(Ci,{isBot:ct??!0,children:R.jsx(ms,{loading:Re.leadingQueries})}):rr.map(nt=>Array.isArray(nt)?nt[0]:nt).map((nt,Ne)=>R.jsxs(KF,{style:{backgroundColor:t.callToActionBackgroundColor,color:t.callToActionFontColor},onClick:()=>{D?(E(!0),O({question:nt.question,answer:nt.answer,products:nt.products,path:"/",nameSpace:window.DebalesChat.projectId})):(at(!1),Et(!0),r({message:nt.question,answer:nt.answer,products:nt.products,leading_queries:nt.leading_queries,followUpQuestion:nt.Follow_up_Question,messType:"leading_query"})),Ue(an=>{const zn=new Set(an);return zn.add(nt.question),zn}),window.DebalesChat.track(Wt.INITIAL_LEADING_QUERY_SUGGESTED_QUESTION_CLICKED,{question:nt.question})},disabled:p,$disabled:p,children:[nt.question,R.jsx(QF,{color:t.callToActionFontColor})]},Ne))}),Se.leading_queries&&Se.leading_queries.length>0&&l===Se.conversationId&&pe.leadingQueries&&!o&&!k&&R.jsx(FD,{children:Se.leading_queries.map((nt,Ne)=>R.jsxs(KF,{style:{backgroundColor:t.callToActionBackgroundColor,color:t.callToActionFontColor},onClick:()=>{D?(E(!0),O({question:nt,path:"/",nameSpace:window.DebalesChat.projectId})):r({message:nt,messType:"leading_query"}),window.DebalesChat.track(Wt.LEADING_QUERY_CLICKED,{query:nt})},disabled:p,$disabled:p,children:[nt,R.jsx(QF,{color:t.callToActionFontColor})]},Ne))})]},rt)}),(p||Ct)&&R.jsxs(ZF,{$fontColor:t.botFontColor||"#000",$botMessageColor:t.botBackgroundColor||"#fff",children:[R.jsx("img",{src:t.bot_logo,alt:"Chat User Icon"}),R.jsx(WF,{children:R.jsx(Ci,{isBot:!0,children:R.jsx("div",{style:{display:"flex",alignItems:"center",gap:"4px",animation:"fadeIn 0.3s ease-in-out"},children:R.jsx(ms,{loading:p||Ct})})})})]})]}),R.jsx(lce,{$backgroundColor:t.botBackgroundColor||"#fff",style:{opacity:yn?1:0}})]}),R.jsxs("div",{className:"debales-footer-container",style:{width:"calc(100%-24px)",backgroundColor:t.botBackgroundColor||"#fff",color:t.fontColor||"#000"},children:[(e==="catch-org-ai"||e==="letsgo-catch")&&R.jsx(Wue,{children:R.jsx("span",{children:`"${t.chatbotName}" can make mistakes.`})}),R.jsx("div",{children:R.jsx(S2,{disabled:p,inputState:!1})}),(t.debales_branding??!0)&&R.jsxs(Que,{href:"https://debales.ai/?open=true",target:"_blank",title:"debales-link",style:{color:t.fontColor?t.fontColor:"fff",marginTop:e==="catch-org-ai"?"0":"9px"},children:[R.jsx("p",{children:"Powered by"}),R.jsxs(Kue,{children:[R.jsx("img",{src:`${wi}/images/debales_logo_d.png`,alt:"Debales logo"}),R.jsx("p",{children:"DEBALES"})]})]})]})]})]})}),Y.shadowRoot)]})},cce=K.p`
2565
2565
  margin: 0;
2566
2566
  font-size: 16px;
2567
2567
  text-align: left;
@@ -3323,7 +3323,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
3323
3323
 
3324
3324
  `+Qe+`
3325
3325
 
3326
- => User Action: Klaviyo form closed`}return""},ge=we=>{we instanceof CustomEvent&&P(we)};return window.addEventListener("klaviyoForms",ge),()=>{window.removeEventListener("klaviyoForms",ge)}},[Lt,t,r]),it.useEffect(()=>{const P=pe.current;return Ue&&P?(P.addEventListener("scroll",rr),()=>{P&&P.removeEventListener("scroll",rr)}):()=>{}},[Ue,rr]);const[Se,rt]=re.useState(!1),ct=Y==="Highest"?"120px":Y==="Higher"?"60px":"15px",Ut=async()=>{try{const P=await fetch(`${wi}/api/wordpress/support`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({chatid:er()+e,nameSpace:e,userName:Et.name,userEmail:Et.email,userMessage:Et.message,tag:"support"})});if(P.ok){const se=`support-confirm-${Date.now()}`;m(ge=>[...ge,{text:"Thanks for reaching out! Our support team has received your request and will get back to you within 24 hours.<br>In the meantime, feel free to continue chatting with me - I'll do my best to help!",isBot:!0,leading_queries:Yt,conversationId:se}]),d(se),Pn(ge=>({...ge,leadingQueries:!0})),yn([]),console.log("Connected to support with existing user info:",Bo())}else{const se=await P.json();console.error("Failed to connect to support:",se),m(ge=>[...ge,{text:"Sorry, we couldn't connect you to support at the moment.<br>Please try again later.",isBot:!0}])}}catch{m(se=>[...se,{text:"Sorry, we couldn't connect you to support at the moment.<br>Please try again later.",isBot:!0}])}},nt=()=>{const P=Bo();let se=[];const ge=h[h.length-1];ge!=null&&ge.leading_queries&&ge.leading_queries.length>0?se=ge.leading_queries:h.length<=1&&(se=te.flatMap(we=>Array.isArray(we)?we.map(_e=>_e.question):[we.question]).slice(0,4)),yn(se),P&&P.name&&P.email&&Xt({name:P==null?void 0:P.name,email:P==null?void 0:P.email,message:""}),m(we=>[...we,{text:"Please provide your name, email and message to connect with support.",isBot:!0}]),Ot(!0)},Ne=async P=>{P.preventDefault();const se={name:"",email:"",message:""};let ge=!0;const we=Et.name.trim(),_e=Et.message.trim();we||(se.name="Name cannot be empty or just whitespace.",ge=!1),(!Et.email||!sm.isEmail(Et.email))&&(se.email="Please enter a valid email address.",ge=!1),_e||(se.message="Message cannot be empty or just whitespace.",ge=!1),Zt(se),ge&&(Nc({name:we,email:Et.email}),Ot(!1),m(Qe=>Qe.slice(0,-1)),await Ut())},[an,zn]=it.useState({});return it.useEffect(()=>{mi&&(h.forEach((P,se)=>{if(!P.isBot)return;const ge=sp(P.text);if(!(se in an)||an[se]<ge.length){let we;const _e=Qe=>{Qe<ge.length&&(we=setTimeout(()=>{zn(Ft=>({...Ft,[se]:Qe+1})),_e(Qe+1)},Qi))};return se in an?_e(an[se]):(zn(Qe=>({...Qe,[se]:1})),_e(1)),()=>clearTimeout(we)}}),zn(P=>{const se={};return h.forEach((ge,we)=>{P[we]!==void 0&&(se[we]=P[we])}),se}))},[h,mi]),!t||t.show_bot===!1||a?null:R.jsxs(K.ThemeProvider,{theme:tC(t,e),children:[R.jsx("link",{rel:"preconnect",href:"https://fonts.googleapis.com"}),R.jsx("link",{rel:"preconnect",href:"https://fonts.gstatic.com",crossOrigin:"anonymous"}),R.jsx("link",{href:"https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap",rel:"stylesheet"}),R.jsx("link",{href:"https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,100;0,300;0,400;0,700;0,900;1,100;1,300;1,400;1,700;1,900&display=swap",rel:"stylesheet"}),R.jsx(Nce,{}),R.jsxs(gce,{$topOffset:ct,$isLeft:V,children:[!Ue&&te.length>0&&te[q]&&ae&&R.jsx($ce,{className:De?"visible":"",$botId:e,$iconSize:H,$removeLogoBackground:t.removeLogoBackground,topOffset:ct,style:{display:"flex",flexDirection:V?"row":"row-reverse",alignItems:"center",marginLeft:tt?"60px":"85px",marginRight:tt?"60px":"85px",left:V?"24px":"auto",right:V?"auto":"24px",opacity:De?1:0,transition:"opacity 0.3s ease-in-out"},children:te.length>0&&te[q]&&(()=>{const P=te[q];return R.jsx(Lce,{children:R.jsx(dce,{messages:[{question:P.question,isHighlighted:P.isHighlighted??!1,show_for:(X==null?void 0:X.show_for)||4e3,hide_timing:(X==null?void 0:X.hide_timing)||4e3}],botId:e,uiData:t,onClose:()=>{Le(se=>{const ge=new Set(se);return ge.add(P.question),ge})},onClick:()=>{const se=P;ht(!0,"suggested_question_clicked"),Le(ge=>{const we=new Set(ge);return we.add(se.question),we}),window.DebalesChat.track(Wt.SUGGESTED_QUESTION_CLICKED,{suggested_question:se}),E?(pr(!1),gr(!0),k(!0),D(se)):(pr(!1),gr(!0),r({message:se.Follow_up_Question??se.question,answer:se.answer,products:se.products,fromKlaviyo:!1,leading_queries:se.leading_queries,followUpQuestion:se.Follow_up_Question,messType:"suggested_question"}))}})},P.question)})()}),R.jsxs(mce,{$topOffset:ct,$removeLogoBackground:t.removeLogoBackground,$isLeft:V,style:{display:Ue?"none":"inline-flex"},children:[R.jsx(vce,{$showAnimation:t.enableChatButtonBackgroundAnimation??!1,$animationType:"Ping",$animationColor:t.chatButtonBackgroundAnimationColor||"#f48722",$backgroundColor:t.backgroundColor||"#fff",$removeLogoBackground:t.removeLogoBackground,$topOffset:ct,$iconSize:H}),R.jsxs(yce,{$backgroundColor:t.removeLogoBackground?"transparent":t.backgroundColor||"#fff",$botId:e,$isLeft:V,$iconSize:H,$removeLogoBackground:t.removeLogoBackground,topOffset:ct,$showAnimation:t.enableChatButtonBackgroundAnimation,$animationType:"Ping",$animationColor:t.chatButtonBackgroundAnimationColor||"#f48722",id:"debales-chat-button","data-testid":"debales-chat-button",onClick:()=>{if(window.DebalesChat.track(Wt.CHAT_BUTTON_CLICKED),ht(!Ue,"chat_button_clicked"),!Ue){const P=S();P.length>0?(m(P),pr(!1),gr(!0)):(pr(!0),gr(!1),setTimeout(()=>{pr(!1),gr(!0);const se={text:(t==null?void 0:t.initialMessage)||"Hi, I am an AI chatbot, how can I help you today?",isBot:!0};m([se])},(X==null?void 0:X.showing_delay)||2e3))}},"aria-label":"Chat",style:{display:Ue?"none":"inline-flex"},children:[R.jsx(xce,{$botId:e,$removeLogoBackground:t.removeLogoBackground,"aria-hidden":"true",src:t.bot_logo,alt:"Chat Bot Icon"}),(te==null?void 0:te.length)>0&&!Ue&&de&&R.jsx("div",{style:{position:"absolute",top:"-5px",right:"-5px",backgroundColor:"#f44336",color:"white",borderRadius:"50%",width:"20px",height:"20px",display:"flex",justifyContent:"center",alignItems:"center",fontSize:"12px",fontWeight:"bold",zIndex:2,opacity:de?1:0,transition:"opacity 0.3s ease-in-out"},children:te.length})]})]})]}),Ue&&bo.createPortal(R.jsx(R.Fragment,{children:R.jsxs(wce,{$backgroundColor:t.backgroundColor||"#fff",$fullScreenOnMobile:t.fullScreenOnMobile,$headerFontColor:t.headerFontColor||"#1C1C1C",$isLeft:V,$topOffset:ct,$mobileDisplayMode:t.mobileDisplayMode,$isVisible:Bt,"data-testid":"debales-chat-container",children:[R.jsxs(Ace,{$backgroundColor:Fe(e)?t.backgroundColor:t.botBackgroundColor||"#fff",style:{color:t.headerFontColor},children:[R.jsx("div",{style:{flexGrow:.1,display:"flex",justifyContent:"center",alignItems:"center",overflow:"hidden",marginRight:"8px",gap:"10px"},children:Fe(e)?R.jsxs(R.Fragment,{children:[R.jsx(rU,{"aria-hidden":"true",src:t.bot_logo,alt:"Chat Bot Icon"}),R.jsxs(bce,{$botNameColor:t.headerFontColor,children:[R.jsxs("div",{style:{fontWeight:"700",wordBreak:"break-word"},children:[t.chatbotName,e==="catch-org-ai"&&R.jsx(Sce,{$backgroundColor:t.callToActionBackgroundColor,$fontColor:t.callToActionFontColor,children:"Beta"})]}),R.jsx(_ce,{})]})]}):R.jsx(Cce,{children:R.jsxs(Ece,{children:[R.jsx(rU,{src:t.bot_logo,alt:"Chat Bot Icon"}),R.jsx("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",display:"inline-block",maxWidth:"22ch"},children:t.chatbotName})]})})}),R.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginLeft:"auto",flexShrink:0},children:[R.jsxs(zce,{children:[R.jsx(iU,{$iconBG:t.backgroundColor,onClick:nt,"aria-label":"Support","data-testid":"debales-support-button",children:R.jsx(a2,{color:t.headerFontColor})}),R.jsx(uU,{children:"Click to chat with a Live Support Agent now."})]}),R.jsx(iU,{$iconBG:t.backgroundColor,onClick:()=>{yt?Ei(!0):ht(!1,"close_button_clicked")},id:"debales-minimize-button","data-testid":"debales-minimize-button","aria-label":"Minimize",children:R.jsx(lm,{botNameColor:t.headerFontColor})})]}),R.jsx(Gce,{$backgroundColor:t.botBackgroundColor||"#fff",style:{opacity:Kn?1:0}})]}),R.jsxs(Dce,{$backgroundColor:t.botBackgroundColor||"#fff",$mobileDisplayMode:t.mobileDisplayMode,children:[Se&&((Je=(be=t.pluginConfig)==null?void 0:be.collectedUserInfo)==null?void 0:Je.discount)&&R.jsx(g2,{discount:t.pluginConfig.collectedUserInfo.discount,uiData:t,onClose:()=>{rt(!1),window.DebalesChat.track(Wt.DISCOUNT_VIEWED,{discount:t.pluginConfig.collectedUserInfo.discount})}}),R.jsx(_2,{uidata:t,product:ur,showModel:ta,setShowModel:vi,onVariantSelect:P=>{I(P.id,1),xe(!0),window.DebalesChat.track(Wt.ADD_TO_CART_CLICKED,{product:P.title,price:Number(P.price),link:`https://${t.shopifyShopDomain}/variants/${P.id}`,message:l,chatId:er()+e})}}),Tt&&R.jsx(m2,{setShowExitModal:Ei,handleCloseChatbot:Lo,chatId:er()+e}),R.jsxs(kce,{id:"debales-conversation-group",$botBackgroundColor:t.botBackgroundColor||"#fff",ref:pe,$mobileDisplayMode:t.mobileDisplayMode,children:[R.jsx(qce,{$backgroundColor:t.botBackgroundColor||"#fff",style:{opacity:Kn?1:0}}),R.jsxs(Tce,{children:[mi&&h.map((P,se)=>{const ge=P.isBot,we=sp(P.text);return P.hideConfirmation?null:R.jsxs(it.Fragment,{children:[ge&&R.jsxs(oU,{$fontColor:t.botFontColor||"#000",$botMessageColor:t.botBackgroundColor||"#fff","data-testid":"debales-ai-message-container",children:[R.jsx("img",{src:ge?t.bot_logo:t.userMessage_logo,alt:"Chat User Icon",style:{marginLeft:"8px"}}),R.jsxs(lU,{children:[we.slice(0,an[se]||0).map((_e,Qe)=>R.jsx("div",{children:R.jsx(Ci,{isBot:ge,children:R.jsx(od,{remarkPlugins:[HS,dC],children:_e})})},Qe)),P.collections&&l===P.conversationId&&kt.collections&&R.jsx(p2,{message:P,botId:e,uidata:t,onSendMessage:r,loading:p}),P.products&&l===P.conversationId&&kt.products&&R.jsx(y2,{message:P,botId:e,uidata:t,onSendMessage:r,loading:p,storeMetaData:n,platform:G,setShowVariantModel:vi,setSelectedProduct:ao,setCartVersion:oe}),o&&R.jsx(qD,{children:R.jsx(K1,{onClick:()=>{window._klOnsite&&(window._klOnsite.push(["openForm",bt]),ht(!1,"klaviyo_grab_deal_button"))},children:"🚀 Grab Deal Now!"})}),O&&O.itemCount>0&&l===P.conversationId&&kt.cartSummary&&xt&&R.jsx(c2,{onCheckout:so,onKeepShopping:()=>{xe(!1)}}),Ae&&Ae.length>0&&l===P.conversationId&&kt.bulkItems&&R.jsx(r2,{onClick:()=>$i(P.conversationId),children:"Add Bulk Items to Cart"}),T&&h.indexOf(P)===h.length-1&&R.jsx(R.Fragment,{children:R.jsx(x2,{setShowModel:_e=>{var Ft,nn;const Qe=typeof _e=="function"?_e(T):_e;k(Qe),!Qe&&((nn=(Ft=t.pluginConfig)==null?void 0:Ft.collectedUserInfo)!=null&&nn.discount)&&rt(!0)},inChat:!0,showFormInstructions:!1})}),at&&h.indexOf(P)===h.length-1&&R.jsxs(Fce,{onSubmit:Ne,noValidate:!0,"data-testid":"debales-support-form",children:[Fe(e)?R.jsxs(R.Fragment,{children:[R.jsx(ql,{label:"Name",name:"name",type:"text",value:Et.name,onChange:_e=>Xt(Qe=>({...Qe,name:_e.target.value})),required:!0,error:vt.name,isCollectiveBot:!0}),R.jsx(ql,{label:"Email",name:"email",type:"email",value:Et.email,onChange:_e=>Xt(Qe=>({...Qe,email:_e.target.value})),required:!0,error:vt.email,isCollectiveBot:!0}),R.jsx(v2,{label:"Message",name:"message",value:Et.message,onChange:_e=>Xt(Qe=>({...Qe,message:_e.target.value})),required:!0,error:vt.message,rows:4,isCollectiveBot:!0})]}):R.jsxs(R.Fragment,{children:[R.jsxs(PD,{children:[R.jsxs(GD,{children:["Name",R.jsx("span",{children:"*"})]}),R.jsx(cU,{type:"text",required:!0,value:Et.name,onChange:_e=>Xt(Qe=>({...Qe,name:_e.target.value})),placeholder:"John"}),vt.name&&R.jsx("p",{style:{color:"red",fontSize:"12px",margin:"4px 0 0"},children:vt.name})]}),R.jsxs(PD,{children:[R.jsxs(GD,{children:["Email",R.jsx("span",{children:"*"})]}),R.jsx(cU,{type:"email",required:!0,value:Et.email,onChange:_e=>Xt(Qe=>({...Qe,email:_e.target.value})),placeholder:"olivia@untitledui.com"}),vt.email&&R.jsx("p",{style:{color:"red",fontSize:"12px",margin:"4px 0 0"},children:vt.email})]}),R.jsxs(PD,{children:[R.jsxs(GD,{children:["Message",R.jsx("span",{children:"*"})]}),R.jsx(Uce,{required:!0,value:Et.message,onChange:_e=>Xt(Qe=>({...Qe,message:_e.target.value})),placeholder:"I need help with..."}),vt.message&&R.jsx("p",{style:{color:"red",fontSize:"12px",margin:"4px 0 0"},children:vt.message})]})]}),R.jsx(Hce,{children:R.jsx(jce,{type:"submit",children:"Submit"})})]}),Qn&&!p&&l===P.conversationId&&R.jsx(Ci,{isBot:ge,children:R.jsx(ms,{loading:Qn})})]})]}),!ge&&R.jsx(Ice,{$fontColor:t.userFontColor||"#000",$botMessageColor:t.botBackgroundColor||"#fff",children:R.jsx(Ci,{isBot:!!ge,children:R.jsx(od,{children:P.text})})}),h.length==1&&se==0&&!T&&R.jsx(qD,{children:br.leadingQueries?R.jsx(Ci,{isBot:!0,children:R.jsx(ms,{loading:br.leadingQueries})}):te.map((_e,Qe)=>R.jsxs(sU,{style:{backgroundColor:t.callToActionBackgroundColor,color:t.callToActionFontColor,opacity:Re.has(_e.question)?.5:1},onClick:()=>{E?(k(!0),D({question:_e.question,answer:_e.answer,products:_e.products,path:"/",nameSpace:window.DebalesChat.projectId})):r({message:_e.question,answer:_e.answer,products:_e.products,leading_queries:_e.leading_queries,followUpQuestion:_e.Follow_up_Question,messType:"leading_query"}),Le(Ft=>{const nn=new Set(Ft);return nn.add(_e.question),nn}),window.DebalesChat.track(Wt.INITIAL_LEADING_QUERY_SUGGESTED_QUESTION_CLICKED,{question:_e.question})},disabled:p,$disabled:p,children:[_e.question,R.jsx(aU,{color:t.callToActionFontColor})]},Qe))}),P.leading_queries&&P.leading_queries.length>0&&l===P.conversationId&&kt.leadingQueries&&!o&&!T&&R.jsx(qD,{children:P.leading_queries.map((_e,Qe)=>R.jsxs(sU,{style:{backgroundColor:t.callToActionBackgroundColor,color:t.callToActionFontColor},onClick:()=>{E?(k(!0),D({question:_e,path:"/",nameSpace:window.DebalesChat.projectId})):r({message:_e,messType:"leading_query"}),window.DebalesChat.track(Wt.LEADING_QUERY_CLICKED,{query:_e})},disabled:p,$disabled:p,children:[_e,R.jsx(aU,{color:t.callToActionFontColor})]},Qe))})]},se)}),(p||nr)&&R.jsxs(oU,{$fontColor:t.botFontColor||"#000",$botMessageColor:t.botBackgroundColor||"#fff",children:[R.jsx("img",{src:t.bot_logo,alt:"Chat User Icon"}),R.jsx(lU,{children:R.jsx(Ci,{isBot:!0,children:R.jsx("div",{style:{display:"flex",alignItems:"center",gap:"4px",animation:"fadeIn 0.3s ease-in-out"},children:R.jsx(ms,{loading:p||nr})})})})]})]}),R.jsx(Pce,{$backgroundColor:t.botBackgroundColor||"#fff",style:{opacity:En?1:0}})]}),R.jsxs("div",{className:"debales-footer-container",style:{width:"100%",backgroundColor:t.botBackgroundColor||"#fff",color:t.fontColor||"#000"},children:[e==="catch-org-ai"&&R.jsx(Rce,{children:R.jsx("span",{children:'"Catch org AI" can make mistakes.'})}),R.jsx("div",{children:R.jsx(S2,{disabled:p,inputState:!1})}),(t.debales_branding??!0)&&R.jsxs(Oce,{href:"https://debales.ai/?open=true",target:"_blank",title:"debales-link",style:{color:t.fontColor?t.fontColor:"fff",marginTop:e==="catch-org-ai"?"0":"9px"},children:[R.jsx("p",{children:"Powered by"}),R.jsxs(Mce,{children:[R.jsx("img",{src:`${wi}/images/debales_logo_d.png`,alt:"Debales logo"}),R.jsx("p",{children:"DEBALES"})]})]})]})]})]})}),z.shadowRoot)]})},Yce=K.p`
3326
+ => User Action: Klaviyo form closed`}return""},ge=we=>{we instanceof CustomEvent&&P(we)};return window.addEventListener("klaviyoForms",ge),()=>{window.removeEventListener("klaviyoForms",ge)}},[Lt,t,r]),it.useEffect(()=>{const P=pe.current;return Ue&&P?(P.addEventListener("scroll",rr),()=>{P&&P.removeEventListener("scroll",rr)}):()=>{}},[Ue,rr]);const[Se,rt]=re.useState(!1),ct=Y==="Highest"?"120px":Y==="Higher"?"60px":"15px",Ut=async()=>{try{const P=await fetch(`${wi}/api/wordpress/support`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({chatid:er()+e,nameSpace:e,userName:Et.name,userEmail:Et.email,userMessage:Et.message,tag:"support"})});if(P.ok){const se=`support-confirm-${Date.now()}`;m(ge=>[...ge,{text:"Thanks for reaching out! Our support team has received your request and will get back to you within 24 hours.<br>In the meantime, feel free to continue chatting with me - I'll do my best to help!",isBot:!0,leading_queries:Yt,conversationId:se}]),d(se),Pn(ge=>({...ge,leadingQueries:!0})),yn([]),console.log("Connected to support with existing user info:",Bo())}else{const se=await P.json();console.error("Failed to connect to support:",se),m(ge=>[...ge,{text:"Sorry, we couldn't connect you to support at the moment.<br>Please try again later.",isBot:!0}])}}catch{m(se=>[...se,{text:"Sorry, we couldn't connect you to support at the moment.<br>Please try again later.",isBot:!0}])}},nt=()=>{const P=Bo();let se=[];const ge=h[h.length-1];ge!=null&&ge.leading_queries&&ge.leading_queries.length>0?se=ge.leading_queries:h.length<=1&&(se=te.flatMap(we=>Array.isArray(we)?we.map(_e=>_e.question):[we.question]).slice(0,4)),yn(se),P&&P.name&&P.email&&Xt({name:P==null?void 0:P.name,email:P==null?void 0:P.email,message:""}),m(we=>[...we,{text:"Please provide your name, email and message to connect with support.",isBot:!0}]),Ot(!0)},Ne=async P=>{P.preventDefault();const se={name:"",email:"",message:""};let ge=!0;const we=Et.name.trim(),_e=Et.message.trim();we||(se.name="Name cannot be empty or just whitespace.",ge=!1),(!Et.email||!sm.isEmail(Et.email))&&(se.email="Please enter a valid email address.",ge=!1),_e||(se.message="Message cannot be empty or just whitespace.",ge=!1),Zt(se),ge&&(Nc({name:we,email:Et.email}),Ot(!1),m(Qe=>Qe.slice(0,-1)),await Ut())},[an,zn]=it.useState({});return it.useEffect(()=>{mi&&(h.forEach((P,se)=>{if(!P.isBot)return;const ge=sp(P.text);if(!(se in an)||an[se]<ge.length){let we;const _e=Qe=>{Qe<ge.length&&(we=setTimeout(()=>{zn(Ft=>({...Ft,[se]:Qe+1})),_e(Qe+1)},Qi))};return se in an?_e(an[se]):(zn(Qe=>({...Qe,[se]:1})),_e(1)),()=>clearTimeout(we)}}),zn(P=>{const se={};return h.forEach((ge,we)=>{P[we]!==void 0&&(se[we]=P[we])}),se}))},[h,mi]),!t||t.show_bot===!1||a?null:R.jsxs(K.ThemeProvider,{theme:tC(t,e),children:[R.jsx("link",{rel:"preconnect",href:"https://fonts.googleapis.com"}),R.jsx("link",{rel:"preconnect",href:"https://fonts.gstatic.com",crossOrigin:"anonymous"}),R.jsx("link",{href:"https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap",rel:"stylesheet"}),R.jsx("link",{href:"https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,100;0,300;0,400;0,700;0,900;1,100;1,300;1,400;1,700;1,900&display=swap",rel:"stylesheet"}),R.jsx(Nce,{}),R.jsxs(gce,{$topOffset:ct,$isLeft:V,children:[!Ue&&te.length>0&&te[q]&&ae&&R.jsx($ce,{className:De?"visible":"",$botId:e,$iconSize:H,$removeLogoBackground:t.removeLogoBackground,topOffset:ct,style:{display:"flex",flexDirection:V?"row":"row-reverse",alignItems:"center",marginLeft:tt?"60px":"85px",marginRight:tt?"60px":"85px",left:V?"24px":"auto",right:V?"auto":"24px",opacity:De?1:0,transition:"opacity 0.3s ease-in-out"},children:te.length>0&&te[q]&&(()=>{const P=te[q];return R.jsx(Lce,{children:R.jsx(dce,{messages:[{question:P.question,isHighlighted:P.isHighlighted??!1,show_for:(X==null?void 0:X.show_for)||4e3,hide_timing:(X==null?void 0:X.hide_timing)||4e3}],botId:e,uiData:t,onClose:()=>{Le(se=>{const ge=new Set(se);return ge.add(P.question),ge})},onClick:()=>{const se=P;ht(!0,"suggested_question_clicked"),Le(ge=>{const we=new Set(ge);return we.add(se.question),we}),window.DebalesChat.track(Wt.SUGGESTED_QUESTION_CLICKED,{suggested_question:se}),E?(pr(!1),gr(!0),k(!0),D(se)):(pr(!1),gr(!0),r({message:se.Follow_up_Question??se.question,answer:se.answer,products:se.products,fromKlaviyo:!1,leading_queries:se.leading_queries,followUpQuestion:se.Follow_up_Question,messType:"suggested_question"}))}})},P.question)})()}),R.jsxs(mce,{$topOffset:ct,$removeLogoBackground:t.removeLogoBackground,$isLeft:V,style:{display:Ue?"none":"inline-flex"},children:[R.jsx(vce,{$showAnimation:t.enableChatButtonBackgroundAnimation??!1,$animationType:"Ping",$animationColor:t.chatButtonBackgroundAnimationColor||"#f48722",$backgroundColor:t.backgroundColor||"#fff",$removeLogoBackground:t.removeLogoBackground,$topOffset:ct,$iconSize:H}),R.jsxs(yce,{$backgroundColor:t.removeLogoBackground?"transparent":t.backgroundColor||"#fff",$botId:e,$isLeft:V,$iconSize:H,$removeLogoBackground:t.removeLogoBackground,topOffset:ct,$showAnimation:t.enableChatButtonBackgroundAnimation,$animationType:"Ping",$animationColor:t.chatButtonBackgroundAnimationColor||"#f48722",id:"debales-chat-button","data-testid":"debales-chat-button",onClick:()=>{if(window.DebalesChat.track(Wt.CHAT_BUTTON_CLICKED),ht(!Ue,"chat_button_clicked"),!Ue){const P=S();P.length>0?(m(P),pr(!1),gr(!0)):(pr(!0),gr(!1),setTimeout(()=>{pr(!1),gr(!0);const se={text:(t==null?void 0:t.initialMessage)||"Hi, I am an AI chatbot, how can I help you today?",isBot:!0};m([se])},(X==null?void 0:X.showing_delay)||2e3))}},"aria-label":"Chat",style:{display:Ue?"none":"inline-flex"},children:[R.jsx(xce,{$botId:e,$removeLogoBackground:t.removeLogoBackground,"aria-hidden":"true",src:t.bot_logo,alt:"Chat Bot Icon"}),(te==null?void 0:te.length)>0&&!Ue&&de&&R.jsx("div",{style:{position:"absolute",top:"-5px",right:"-5px",backgroundColor:"#f44336",color:"white",borderRadius:"50%",width:"20px",height:"20px",display:"flex",justifyContent:"center",alignItems:"center",fontSize:"12px",fontWeight:"bold",zIndex:2,opacity:de?1:0,transition:"opacity 0.3s ease-in-out"},children:te.length})]})]})]}),Ue&&bo.createPortal(R.jsx(R.Fragment,{children:R.jsxs(wce,{$backgroundColor:t.backgroundColor||"#fff",$fullScreenOnMobile:t.fullScreenOnMobile,$headerFontColor:t.headerFontColor||"#1C1C1C",$isLeft:V,$topOffset:ct,$mobileDisplayMode:t.mobileDisplayMode,$isVisible:Bt,"data-testid":"debales-chat-container",children:[R.jsxs(Ace,{$backgroundColor:Fe(e)?t.backgroundColor:t.botBackgroundColor||"#fff",style:{color:t.headerFontColor},children:[R.jsx("div",{style:{flexGrow:.1,display:"flex",justifyContent:"center",alignItems:"center",overflow:"hidden",marginRight:"8px",gap:"10px"},children:Fe(e)?R.jsxs(R.Fragment,{children:[R.jsx(rU,{"aria-hidden":"true",src:t.bot_logo,alt:"Chat Bot Icon"}),R.jsxs(bce,{$botNameColor:t.headerFontColor,children:[R.jsxs("div",{style:{fontWeight:"700",wordBreak:"break-word"},children:[t.chatbotName,e==="catch-org-ai"&&R.jsx(Sce,{$backgroundColor:t.callToActionBackgroundColor,$fontColor:t.callToActionFontColor,children:"Beta"})]}),R.jsx(_ce,{})]})]}):R.jsx(Cce,{children:R.jsxs(Ece,{children:[R.jsx(rU,{src:t.bot_logo,alt:"Chat Bot Icon"}),R.jsx("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",display:"inline-block",maxWidth:"22ch"},children:t.chatbotName})]})})}),R.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginLeft:"auto",flexShrink:0},children:[R.jsxs(zce,{children:[R.jsx(iU,{$iconBG:t.backgroundColor,onClick:nt,"aria-label":"Support","data-testid":"debales-support-button",children:R.jsx(a2,{color:t.headerFontColor})}),R.jsx(uU,{children:"Click to chat with a Live Support Agent now."})]}),R.jsx(iU,{$iconBG:t.backgroundColor,onClick:()=>{yt?Ei(!0):ht(!1,"close_button_clicked")},id:"debales-minimize-button","data-testid":"debales-minimize-button","aria-label":"Minimize",children:R.jsx(lm,{botNameColor:t.headerFontColor})})]}),R.jsx(Gce,{$backgroundColor:t.botBackgroundColor||"#fff",style:{opacity:Kn?1:0}})]}),R.jsxs(Dce,{$backgroundColor:t.botBackgroundColor||"#fff",$mobileDisplayMode:t.mobileDisplayMode,children:[Se&&((Je=(be=t.pluginConfig)==null?void 0:be.collectedUserInfo)==null?void 0:Je.discount)&&R.jsx(g2,{discount:t.pluginConfig.collectedUserInfo.discount,uiData:t,onClose:()=>{rt(!1),window.DebalesChat.track(Wt.DISCOUNT_VIEWED,{discount:t.pluginConfig.collectedUserInfo.discount})}}),R.jsx(_2,{uidata:t,product:ur,showModel:ta,setShowModel:vi,onVariantSelect:P=>{I(P.id,1),xe(!0),window.DebalesChat.track(Wt.ADD_TO_CART_CLICKED,{product:P.title,price:Number(P.price),link:`https://${t.shopifyShopDomain}/variants/${P.id}`,message:l,chatId:er()+e})}}),Tt&&R.jsx(m2,{setShowExitModal:Ei,handleCloseChatbot:Lo,chatId:er()+e}),R.jsxs(kce,{id:"debales-conversation-group",$botBackgroundColor:t.botBackgroundColor||"#fff",ref:pe,$mobileDisplayMode:t.mobileDisplayMode,children:[R.jsx(qce,{$backgroundColor:t.botBackgroundColor||"#fff",style:{opacity:Kn?1:0}}),R.jsxs(Tce,{children:[mi&&h.map((P,se)=>{const ge=P.isBot,we=sp(P.text);return P.hideConfirmation?null:R.jsxs(it.Fragment,{children:[ge&&R.jsxs(oU,{$fontColor:t.botFontColor||"#000",$botMessageColor:t.botBackgroundColor||"#fff","data-testid":"debales-ai-message-container",children:[R.jsx("img",{src:ge?t.bot_logo:t.userMessage_logo,alt:"Chat User Icon",style:{marginLeft:"8px"}}),R.jsxs(lU,{children:[we.slice(0,an[se]||0).map((_e,Qe)=>R.jsx("div",{children:R.jsx(Ci,{isBot:ge,children:R.jsx(od,{remarkPlugins:[HS,dC],children:_e})})},Qe)),P.collections&&l===P.conversationId&&kt.collections&&R.jsx(p2,{message:P,botId:e,uidata:t,onSendMessage:r,loading:p}),P.products&&l===P.conversationId&&kt.products&&R.jsx(y2,{message:P,botId:e,uidata:t,onSendMessage:r,loading:p,storeMetaData:n,platform:G,setShowVariantModel:vi,setSelectedProduct:ao,setCartVersion:oe}),o&&R.jsx(qD,{children:R.jsx(K1,{onClick:()=>{window._klOnsite&&(window._klOnsite.push(["openForm",bt]),ht(!1,"klaviyo_grab_deal_button"))},children:"🚀 Grab Deal Now!"})}),O&&O.itemCount>0&&l===P.conversationId&&kt.cartSummary&&xt&&R.jsx(c2,{onCheckout:so,onKeepShopping:()=>{xe(!1)}}),Ae&&Ae.length>0&&l===P.conversationId&&kt.bulkItems&&R.jsx(r2,{onClick:()=>$i(P.conversationId),children:"Add Bulk Items to Cart"}),T&&h.indexOf(P)===h.length-1&&R.jsx(R.Fragment,{children:R.jsx(x2,{setShowModel:_e=>{var Ft,nn;const Qe=typeof _e=="function"?_e(T):_e;k(Qe),!Qe&&((nn=(Ft=t.pluginConfig)==null?void 0:Ft.collectedUserInfo)!=null&&nn.discount)&&rt(!0)},inChat:!0,showFormInstructions:!1})}),at&&h.indexOf(P)===h.length-1&&R.jsxs(Fce,{onSubmit:Ne,noValidate:!0,"data-testid":"debales-support-form",children:[Fe(e)?R.jsxs(R.Fragment,{children:[R.jsx(ql,{label:"Name",name:"name",type:"text",value:Et.name,onChange:_e=>Xt(Qe=>({...Qe,name:_e.target.value})),required:!0,error:vt.name,isCollectiveBot:!0}),R.jsx(ql,{label:"Email",name:"email",type:"email",value:Et.email,onChange:_e=>Xt(Qe=>({...Qe,email:_e.target.value})),required:!0,error:vt.email,isCollectiveBot:!0}),R.jsx(v2,{label:"Message",name:"message",value:Et.message,onChange:_e=>Xt(Qe=>({...Qe,message:_e.target.value})),required:!0,error:vt.message,rows:4,isCollectiveBot:!0})]}):R.jsxs(R.Fragment,{children:[R.jsxs(PD,{children:[R.jsxs(GD,{children:["Name",R.jsx("span",{children:"*"})]}),R.jsx(cU,{type:"text",required:!0,value:Et.name,onChange:_e=>Xt(Qe=>({...Qe,name:_e.target.value})),placeholder:"John"}),vt.name&&R.jsx("p",{style:{color:"red",fontSize:"12px",margin:"4px 0 0"},children:vt.name})]}),R.jsxs(PD,{children:[R.jsxs(GD,{children:["Email",R.jsx("span",{children:"*"})]}),R.jsx(cU,{type:"email",required:!0,value:Et.email,onChange:_e=>Xt(Qe=>({...Qe,email:_e.target.value})),placeholder:"olivia@untitledui.com"}),vt.email&&R.jsx("p",{style:{color:"red",fontSize:"12px",margin:"4px 0 0"},children:vt.email})]}),R.jsxs(PD,{children:[R.jsxs(GD,{children:["Message",R.jsx("span",{children:"*"})]}),R.jsx(Uce,{required:!0,value:Et.message,onChange:_e=>Xt(Qe=>({...Qe,message:_e.target.value})),placeholder:"I need help with..."}),vt.message&&R.jsx("p",{style:{color:"red",fontSize:"12px",margin:"4px 0 0"},children:vt.message})]})]}),R.jsx(Hce,{children:R.jsx(jce,{type:"submit",children:"Submit"})})]}),Qn&&!p&&l===P.conversationId&&R.jsx(Ci,{isBot:ge,children:R.jsx(ms,{loading:Qn})})]})]}),!ge&&R.jsx(Ice,{$fontColor:t.userFontColor||"#000",$botMessageColor:t.botBackgroundColor||"#fff",children:R.jsx(Ci,{isBot:!!ge,children:R.jsx(od,{children:P.text})})}),h.length==1&&se==0&&!T&&R.jsx(qD,{children:br.leadingQueries?R.jsx(Ci,{isBot:!0,children:R.jsx(ms,{loading:br.leadingQueries})}):te.map((_e,Qe)=>R.jsxs(sU,{style:{backgroundColor:t.callToActionBackgroundColor,color:t.callToActionFontColor,opacity:Re.has(_e.question)?.5:1},onClick:()=>{E?(k(!0),D({question:_e.question,answer:_e.answer,products:_e.products,path:"/",nameSpace:window.DebalesChat.projectId})):r({message:_e.question,answer:_e.answer,products:_e.products,leading_queries:_e.leading_queries,followUpQuestion:_e.Follow_up_Question,messType:"leading_query"}),Le(Ft=>{const nn=new Set(Ft);return nn.add(_e.question),nn}),window.DebalesChat.track(Wt.INITIAL_LEADING_QUERY_SUGGESTED_QUESTION_CLICKED,{question:_e.question})},disabled:p,$disabled:p,children:[_e.question,R.jsx(aU,{color:t.callToActionFontColor})]},Qe))}),P.leading_queries&&P.leading_queries.length>0&&l===P.conversationId&&kt.leadingQueries&&!o&&!T&&R.jsx(qD,{children:P.leading_queries.map((_e,Qe)=>R.jsxs(sU,{style:{backgroundColor:t.callToActionBackgroundColor,color:t.callToActionFontColor},onClick:()=>{E?(k(!0),D({question:_e,path:"/",nameSpace:window.DebalesChat.projectId})):r({message:_e,messType:"leading_query"}),window.DebalesChat.track(Wt.LEADING_QUERY_CLICKED,{query:_e})},disabled:p,$disabled:p,children:[_e,R.jsx(aU,{color:t.callToActionFontColor})]},Qe))})]},se)}),(p||nr)&&R.jsxs(oU,{$fontColor:t.botFontColor||"#000",$botMessageColor:t.botBackgroundColor||"#fff",children:[R.jsx("img",{src:t.bot_logo,alt:"Chat User Icon"}),R.jsx(lU,{children:R.jsx(Ci,{isBot:!0,children:R.jsx("div",{style:{display:"flex",alignItems:"center",gap:"4px",animation:"fadeIn 0.3s ease-in-out"},children:R.jsx(ms,{loading:p||nr})})})})]})]}),R.jsx(Pce,{$backgroundColor:t.botBackgroundColor||"#fff",style:{opacity:En?1:0}})]}),R.jsxs("div",{className:"debales-footer-container",style:{width:"100%",backgroundColor:t.botBackgroundColor||"#fff",color:t.fontColor||"#000"},children:[(e==="catch-org-ai"||e==="letsgo-catch")&&R.jsx(Rce,{children:R.jsx("span",{children:`"${t.chatbotName}" can make mistakes.`})}),R.jsx("div",{children:R.jsx(S2,{disabled:p,inputState:!1})}),(t.debales_branding??!0)&&R.jsxs(Oce,{href:"https://debales.ai/?open=true",target:"_blank",title:"debales-link",style:{color:t.fontColor?t.fontColor:"fff",marginTop:e==="catch-org-ai"?"0":"9px"},children:[R.jsx("p",{children:"Powered by"}),R.jsxs(Mce,{children:[R.jsx("img",{src:`${wi}/images/debales_logo_d.png`,alt:"Debales logo"}),R.jsx("p",{children:"DEBALES"})]})]})]})]})]})}),z.shadowRoot)]})},Yce=K.p`
3327
3327
  margin: 0;
3328
3328
  font-size: 16px;
3329
3329
  min-height: 24px;
@@ -4076,7 +4076,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
4076
4076
 
4077
4077
  `+Qe+`
4078
4078
 
4079
- => User Action: Klaviyo form closed`}return""},ge=we=>{we instanceof CustomEvent&&P(we)};return window.addEventListener("klaviyoForms",ge),()=>{window.removeEventListener("klaviyoForms",ge)}},[bt,t,r]),it.useEffect(()=>{const P=Re.current;return Ue&&P?(P.addEventListener("scroll",rr),()=>{P&&P.removeEventListener("scroll",rr)}):()=>{}},[Ue,rr]);const[Se,rt]=re.useState(!1),ct=Y==="Highest"?"120px":Y==="Higher"?"60px":"15px",Ut=async()=>{try{const P=await fetch(`${wi}/api/wordpress/support`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({chatid:er()+e,nameSpace:e,userName:Et.name,userEmail:Et.email,userMessage:Et.message,tag:"support"})});if(P.ok){const se=`support-confirm-${Date.now()}`;m(ge=>[...ge,{text:"Thanks for reaching out! Our support team has received your request and will get back to you within 24 hours.<br>In the meantime, feel free to continue chatting with me - I'll do my best to help!",isBot:!0,leading_queries:Yt,conversationId:se}]),d(se),Pn(ge=>({...ge,leadingQueries:!0})),yn([]),console.log("Connected to support with existing user info:",Bo())}else{const se=await P.json();console.error("Failed to connect to support:",se),m(ge=>[...ge,{text:"Sorry, we couldn't connect you to support at the moment.<br>Please try again later.",isBot:!0}])}}catch{m(se=>[...se,{text:"Sorry, we couldn't connect you to support at the moment.<br>Please try again later.",isBot:!0}])}},nt=()=>{const P=Bo();let se=[];const ge=h[h.length-1];ge!=null&&ge.leading_queries&&ge.leading_queries.length>0?se=ge.leading_queries:h.length<=1&&(se=te.flatMap(we=>Array.isArray(we)?we.map(_e=>_e.question):[we.question]).slice(0,4)),yn(se),P&&P.name&&P.email&&Xt({name:P==null?void 0:P.name,email:P==null?void 0:P.email,message:""}),m(we=>[...we,{text:"Please provide your name, email and message to connect with support.",isBot:!0}]),Ot(!0)},Ne=async P=>{P.preventDefault();const se={name:"",email:"",message:""};let ge=!0;const we=Et.name.trim(),_e=Et.message.trim();we||(se.name="Name cannot be empty or just whitespace.",ge=!1),(!Et.email||!sm.isEmail(Et.email))&&(se.email="Please enter a valid email address.",ge=!1),_e||(se.message="Message cannot be empty or just whitespace.",ge=!1),Zt(se),ge&&(Nc({name:we,email:Et.email}),Ot(!1),m(Qe=>Qe.slice(0,-1)),await Ut())},[an,zn]=it.useState({});return it.useEffect(()=>{mi&&(h.forEach((P,se)=>{if(!P.isBot)return;const ge=sp(P.text);if(!(se in an)||an[se]<ge.length){let we;const _e=Qe=>{Qe<ge.length&&(we=setTimeout(()=>{zn(Ft=>({...Ft,[se]:Qe+1})),_e(Qe+1)},Qi))};return se in an?_e(an[se]):(zn(Qe=>({...Qe,[se]:1})),_e(1)),()=>clearTimeout(we)}}),zn(P=>{const se={};return h.forEach((ge,we)=>{P[we]!==void 0&&(se[we]=P[we])}),se}))},[h,mi]),!t||t.show_bot===!1||a?null:R.jsxs(K.ThemeProvider,{theme:tC(t,e),children:[R.jsx("link",{rel:"preconnect",href:"https://fonts.googleapis.com"}),R.jsx("link",{rel:"preconnect",href:"https://fonts.gstatic.com",crossOrigin:"anonymous"}),R.jsx("link",{href:"https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap",rel:"stylesheet"}),R.jsx("link",{href:"https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,100;0,300;0,400;0,700;0,900;1,100;1,300;1,400;1,700;1,900&display=swap",rel:"stylesheet"}),R.jsx(bfe,{}),R.jsx(Xce,{$topOffset:ct,$isLeft:V,children:R.jsxs(vfe,{$isLeft:V,$removeLogoBackground:t.removeLogoBackground,children:[!Ue&&te.length>0&&te[q]&&ae&&R.jsx(yfe,{className:De?"visible":"",$botId:e,$iconSize:H,$removeLogoBackground:t.removeLogoBackground,topOffset:ct,$isLeft:V,style:{display:"flex",flexDirection:V?"row":"row-reverse",alignItems:"center",marginRight:V?"0px":Lt?"10px":"5px",marginTop:Lt?"0px":"10px",left:V?"24px":"auto",right:V?"auto":"24px",opacity:De?1:0,transition:"opacity 0.3s ease-in-out"},children:te.length>0&&te[q]&&(()=>{const P=te[q];return R.jsx(xfe,{children:R.jsx(Qce,{messages:[{question:P.question,isHighlighted:P.isHighlighted??!1,show_for:(X==null?void 0:X.show_for)||4e3,hide_timing:(X==null?void 0:X.hide_timing)||4e3}],botId:e,uiData:t,isLeft:V,onClose:()=>{xt(se=>{const ge=new Set(se);return ge.add(P.question),ge})},onClick:()=>{const se=P;xe(!0,"suggested_question_clicked"),xt(ge=>{const we=new Set(ge);return we.add(se.question),we}),window.DebalesChat.track(Wt.SUGGESTED_QUESTION_CLICKED,{suggested_question:se}),E?(pr(!1),gr(!0),k(!0),D(se)):(pr(!1),gr(!0),r({message:se.Follow_up_Question??se.question,answer:se.answer,products:se.products,fromKlaviyo:!1,leading_queries:se.leading_queries,messType:"suggested_question"}))}})},P.question)})()}),R.jsx(Jce,{$topOffset:ct,$removeLogoBackground:t.removeLogoBackground,style:{display:Ue?"none":"inline-flex"},children:R.jsxs(efe,{$backgroundColor:t.removeLogoBackground?"transparent":t.backgroundColor||"#fff",$botId:e,$iconSize:H,$removeLogoBackground:t.removeLogoBackground,topOffset:ct,$showAnimation:t.enableChatButtonBackgroundAnimation,$animationType:"Ping",$animationColor:t.chatButtonBackgroundAnimationColor||"#f48722",id:"debales-chat-button","data-testid":"debales-chat-button",onClick:()=>{if(window.DebalesChat.track(Wt.CHAT_BUTTON_CLICKED),xe(!Ue,"chat_button_clicked"),!Ue){const P=S();P.length>0?(m(P),pr(!1),gr(!0)):(pr(!0),gr(!1),setTimeout(()=>{pr(!1),gr(!0);const se={text:(t==null?void 0:t.initialMessage)||"Hi, I am an AI chatbot, how can I help you today?",isBot:!0};m([se])},(X==null?void 0:X.showing_delay)||2e3))}},"aria-label":"Chat",style:{display:Ue?"none":"inline-flex"},children:[R.jsx(tfe,{$botId:e,$removeLogoBackground:t.removeLogoBackground,"aria-hidden":"true",src:t.bot_logo,alt:"Chat Bot Icon"}),(te==null?void 0:te.length)>0&&!Ue&&de&&!ae&&R.jsx("div",{style:{position:"absolute",top:"-5px",right:"-5px",backgroundColor:"#f44336",color:"white",borderRadius:"50%",width:"20px",height:"20px",display:"flex",justifyContent:"center",alignItems:"center",fontSize:"12px",fontWeight:"bold",zIndex:2,opacity:de?1:0,transition:"opacity 0.3s ease-in-out"},children:te.length})]})})]})}),Ue&&bo.createPortal(R.jsx(R.Fragment,{children:R.jsxs(ofe,{$backgroundColor:t.backgroundColor||"#fff",$fullScreenOnMobile:t.fullScreenOnMobile,$headerFontColor:t.headerFontColor||"#1C1C1C",$isLeft:V,$topOffset:ct,$mobileDisplayMode:t.mobileDisplayMode,$isVisible:Bt,"data-testid":"debales-chat-container",children:[R.jsxs(lfe,{$backgroundColor:Fe(e)?t.backgroundColor:t.botBackgroundColor||"#fff",style:{color:t.headerFontColor},children:[R.jsx("div",{style:{flexGrow:.1,display:"flex",justifyContent:"center",alignItems:"center",overflow:"hidden",marginRight:"8px",gap:"10px"},children:Fe(e)?R.jsxs(R.Fragment,{children:[R.jsx(fU,{"aria-hidden":"true",src:t.bot_logo,alt:"Chat Bot Icon"}),R.jsxs(nfe,{$botNameColor:t.headerFontColor,children:[R.jsxs("div",{style:{fontWeight:"700",wordBreak:"break-word"},children:[t.chatbotName,e==="catch-org-ai"&&R.jsx(ife,{$backgroundColor:t.callToActionBackgroundColor,$fontColor:t.callToActionFontColor,children:"Beta"})]}),R.jsx(rfe,{})]})]}):R.jsx(afe,{children:R.jsxs(sfe,{children:[R.jsx(fU,{src:t.bot_logo,alt:"Chat Bot Icon"}),R.jsx("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",display:"inline-block",maxWidth:"22ch"},children:t.chatbotName})]})})}),R.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginLeft:"auto",flexShrink:0},children:[R.jsxs(_fe,{children:[R.jsx(dU,{$iconBG:t.backgroundColor,onClick:nt,"aria-label":"Support","data-testid":"debales-support-button",children:R.jsx(a2,{color:t.headerFontColor})}),R.jsx(vU,{children:"Click to chat with a Live Support Agent now."})]}),R.jsx(dU,{$iconBG:t.backgroundColor,onClick:()=>{yt?Ei(!0):xe(!1,"close_button_clicked")},id:"debales-minimize-button","data-testid":"debales-minimize-button","aria-label":"Minimize",children:R.jsx(lm,{botNameColor:t.headerFontColor})})]}),R.jsx(Tfe,{$backgroundColor:t.botBackgroundColor||"#fff",style:{opacity:Kn?1:0}})]}),R.jsxs(ffe,{$backgroundColor:t.botBackgroundColor||"#fff",$mobileDisplayMode:t.mobileDisplayMode,children:[Se&&((Je=(be=t.pluginConfig)==null?void 0:be.collectedUserInfo)==null?void 0:Je.discount)&&R.jsx(g2,{discount:t.pluginConfig.collectedUserInfo.discount,uiData:t,onClose:()=>{rt(!1),window.DebalesChat.track(Wt.DISCOUNT_VIEWED,{discount:t.pluginConfig.collectedUserInfo.discount})}}),R.jsx(_2,{uidata:t,product:ur,showModel:ta,setShowModel:vi,onVariantSelect:P=>{I(P.id,1),ft(!0),window.DebalesChat.track(Wt.ADD_TO_CART_CLICKED,{product:P.title,price:Number(P.price),link:`https://${t.shopifyShopDomain}/variants/${P.id}`,message:l,chatId:er()+e})}}),Tt&&R.jsx(m2,{setShowExitModal:Ei,handleCloseChatbot:Lo,chatId:er()+e}),R.jsxs(ufe,{id:"debales-conversation-group",$botBackgroundColor:t.botBackgroundColor||"#fff",ref:Re,$mobileDisplayMode:t.mobileDisplayMode,children:[R.jsx(Afe,{$backgroundColor:t.botBackgroundColor||"#fff",style:{opacity:Kn?1:0}}),R.jsxs(cfe,{children:[mi&&h.map((P,se)=>{const ge=P.isBot,we=sp(P.text);return P.hideConfirmation?null:R.jsxs(it.Fragment,{children:[ge&&R.jsxs(hU,{$fontColor:t.botFontColor||"#000",$botMessageColor:t.botBackgroundColor||"#fff","data-testid":"debales-ai-message-container",children:[R.jsx("img",{src:ge?t.bot_logo:t.userMessage_logo,alt:"Chat User Icon",style:{marginLeft:"8px"}}),R.jsxs(mU,{children:[we.slice(0,an[se]||0).map((_e,Qe)=>R.jsx("div",{children:R.jsx(Ci,{isBot:ge,children:R.jsx(od,{remarkPlugins:[HS,dC],children:_e})})},Qe)),P.collections&&l===P.conversationId&&kt.collections&&R.jsx(p2,{message:P,botId:e,uidata:t,onSendMessage:r,loading:p}),P.products&&l===P.conversationId&&kt.products&&R.jsx(y2,{message:P,botId:e,uidata:t,onSendMessage:r,loading:p,storeMetaData:n,platform:G,setShowVariantModel:vi,setSelectedProduct:ao,setCartVersion:$e}),o&&R.jsx(YD,{children:R.jsx(K1,{onClick:()=>{window._klOnsite&&(window._klOnsite.push(["openForm",oe]),xe(!1,"klaviyo_grab_deal_button"))},children:"🚀 Grab Deal Now!"})}),O&&O.itemCount>0&&l===P.conversationId&&kt.cartSummary&&tt&&R.jsx(c2,{onCheckout:so,onKeepShopping:()=>{ft(!1)}}),Ae&&Ae.length>0&&l===P.conversationId&&kt.bulkItems&&R.jsx(r2,{onClick:()=>$i(P.conversationId),children:"Add Bulk Items to Cart"}),T&&h.indexOf(P)===h.length-1&&R.jsx(R.Fragment,{children:R.jsx(x2,{setShowModel:_e=>{var Ft,nn;const Qe=typeof _e=="function"?_e(T):_e;k(Qe),!Qe&&((nn=(Ft=t.pluginConfig)==null?void 0:Ft.collectedUserInfo)!=null&&nn.discount)&&rt(!0)},inChat:!0,showFormInstructions:!1})}),at&&h.indexOf(P)===h.length-1&&R.jsxs(Sfe,{onSubmit:Ne,noValidate:!0,"data-testid":"debales-support-form",children:[Fe(e)?R.jsxs(R.Fragment,{children:[R.jsx(ql,{label:"Name",name:"name",type:"text",value:Et.name,onChange:_e=>Xt(Qe=>({...Qe,name:_e.target.value})),required:!0,error:vt.name,isCollectiveBot:!0}),R.jsx(ql,{label:"Email",name:"email",type:"email",value:Et.email,onChange:_e=>Xt(Qe=>({...Qe,email:_e.target.value})),required:!0,error:vt.email,isCollectiveBot:!0}),R.jsx(v2,{label:"Message",name:"message",value:Et.message,onChange:_e=>Xt(Qe=>({...Qe,message:_e.target.value})),required:!0,error:vt.message,rows:4,isCollectiveBot:!0})]}):R.jsxs(R.Fragment,{children:[R.jsxs(ZD,{children:[R.jsxs(QD,{children:["Name",R.jsx("span",{children:"*"})]}),R.jsx(yU,{type:"text",required:!0,value:Et.name,onChange:_e=>Xt(Qe=>({...Qe,name:_e.target.value})),placeholder:"John"}),vt.name&&R.jsx("p",{style:{color:"red",fontSize:"12px",margin:"4px 0 0"},children:vt.name})]}),R.jsxs(ZD,{children:[R.jsxs(QD,{children:["Email",R.jsx("span",{children:"*"})]}),R.jsx(yU,{type:"email",required:!0,value:Et.email,onChange:_e=>Xt(Qe=>({...Qe,email:_e.target.value})),placeholder:"olivia@untitledui.com"}),vt.email&&R.jsx("p",{style:{color:"red",fontSize:"12px",margin:"4px 0 0"},children:vt.email})]}),R.jsxs(ZD,{children:[R.jsxs(QD,{children:["Message",R.jsx("span",{children:"*"})]}),R.jsx(wfe,{required:!0,value:Et.message,onChange:_e=>Xt(Qe=>({...Qe,message:_e.target.value})),placeholder:"I need help with..."}),vt.message&&R.jsx("p",{style:{color:"red",fontSize:"12px",margin:"4px 0 0"},children:vt.message})]})]}),R.jsx(Efe,{children:R.jsx(Cfe,{type:"submit",children:"Submit"})})]}),Qn&&!p&&l===P.conversationId&&R.jsx(Ci,{isBot:ge,children:R.jsx(ms,{loading:Qn,loadingPhrases:["🎨 Loading","✨ Almost","🚀 Ready"]})})]})]}),!ge&&R.jsx(gfe,{$fontColor:t.userFontColor||"#000",$botMessageColor:t.botBackgroundColor||"#fff",children:R.jsx(Ci,{isBot:!!ge,children:R.jsx(od,{children:P.text})})}),h.length==1&&se==0&&!T&&R.jsx(YD,{children:br.leadingQueries?R.jsx(Ci,{isBot:!0,children:R.jsx(ms,{loading:br.leadingQueries})}):te.map((_e,Qe)=>R.jsxs(gU,{style:{backgroundColor:t.callToActionBackgroundColor,color:t.callToActionFontColor,opacity:ht.has(_e.question)?.5:1},onClick:()=>{E?(k(!0),D({question:_e.question,answer:_e.answer,products:_e.products,path:"/",nameSpace:window.DebalesChat.projectId})):r({message:_e.question,answer:_e.answer,products:_e.products,messType:"leading_query"}),xt(Ft=>{const nn=new Set(Ft);return nn.add(_e.question),nn}),window.DebalesChat.track(Wt.INITIAL_LEADING_QUERY_SUGGESTED_QUESTION_CLICKED,{question:_e.question})},disabled:p,$disabled:p,children:[_e.question,R.jsx(pU,{color:t.callToActionFontColor})]},Qe))}),P.leading_queries&&P.leading_queries.length>0&&l===P.conversationId&&kt.leadingQueries&&!o&&!T&&R.jsx(YD,{children:P.leading_queries.map((_e,Qe)=>R.jsxs(gU,{style:{backgroundColor:t.callToActionBackgroundColor,color:t.callToActionFontColor},onClick:()=>{E?(k(!0),D({question:_e,path:"/",nameSpace:window.DebalesChat.projectId})):r({message:_e,messType:"leading_query"}),window.DebalesChat.track(Wt.LEADING_QUERY_CLICKED,{query:_e})},disabled:p,$disabled:p,children:[_e,R.jsx(pU,{color:t.callToActionFontColor})]},Qe))})]},se)}),(p||nr)&&R.jsxs(hU,{$fontColor:t.botFontColor||"#000",$botMessageColor:t.botBackgroundColor||"#fff",children:[R.jsx("img",{src:t.bot_logo,alt:"Chat User Icon"}),R.jsx(mU,{children:R.jsx(Ci,{isBot:!0,children:R.jsx("div",{style:{display:"flex",alignItems:"center",gap:"4px",animation:"fadeIn 0.3s ease-in-out"},children:R.jsx(ms,{loading:p||nr})})})})]})]}),R.jsx(kfe,{$backgroundColor:t.botBackgroundColor||"#fff",style:{opacity:En?1:0}})]}),R.jsxs("div",{className:"debales-footer-container",style:{width:"100%",backgroundColor:t.botBackgroundColor||"#fff",color:t.fontColor||"#000"},children:[e==="catch-org-ai"&&R.jsx(pfe,{children:R.jsx("span",{children:'"Catch org AI" can make mistakes.'})}),R.jsx("div",{children:R.jsx(S2,{disabled:p,inputState:!1})}),(t.debales_branding??!0)&&R.jsxs(dfe,{href:"https://debales.ai/?open=true",target:"_blank",title:"debales-link",style:{color:t.fontColor?t.fontColor:"fff",marginTop:e==="catch-org-ai"?"0":"9px"},children:[R.jsx("p",{children:"Powered by"}),R.jsxs(hfe,{children:[R.jsx("img",{src:`${wi}/images/debales_logo_d.png`,alt:"Debales logo"}),R.jsx("p",{children:"DEBALES"})]})]})]})]})]})}),z.shadowRoot)]})},Ofe=K.p`
4079
+ => User Action: Klaviyo form closed`}return""},ge=we=>{we instanceof CustomEvent&&P(we)};return window.addEventListener("klaviyoForms",ge),()=>{window.removeEventListener("klaviyoForms",ge)}},[bt,t,r]),it.useEffect(()=>{const P=Re.current;return Ue&&P?(P.addEventListener("scroll",rr),()=>{P&&P.removeEventListener("scroll",rr)}):()=>{}},[Ue,rr]);const[Se,rt]=re.useState(!1),ct=Y==="Highest"?"120px":Y==="Higher"?"60px":"15px",Ut=async()=>{try{const P=await fetch(`${wi}/api/wordpress/support`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({chatid:er()+e,nameSpace:e,userName:Et.name,userEmail:Et.email,userMessage:Et.message,tag:"support"})});if(P.ok){const se=`support-confirm-${Date.now()}`;m(ge=>[...ge,{text:"Thanks for reaching out! Our support team has received your request and will get back to you within 24 hours.<br>In the meantime, feel free to continue chatting with me - I'll do my best to help!",isBot:!0,leading_queries:Yt,conversationId:se}]),d(se),Pn(ge=>({...ge,leadingQueries:!0})),yn([]),console.log("Connected to support with existing user info:",Bo())}else{const se=await P.json();console.error("Failed to connect to support:",se),m(ge=>[...ge,{text:"Sorry, we couldn't connect you to support at the moment.<br>Please try again later.",isBot:!0}])}}catch{m(se=>[...se,{text:"Sorry, we couldn't connect you to support at the moment.<br>Please try again later.",isBot:!0}])}},nt=()=>{const P=Bo();let se=[];const ge=h[h.length-1];ge!=null&&ge.leading_queries&&ge.leading_queries.length>0?se=ge.leading_queries:h.length<=1&&(se=te.flatMap(we=>Array.isArray(we)?we.map(_e=>_e.question):[we.question]).slice(0,4)),yn(se),P&&P.name&&P.email&&Xt({name:P==null?void 0:P.name,email:P==null?void 0:P.email,message:""}),m(we=>[...we,{text:"Please provide your name, email and message to connect with support.",isBot:!0}]),Ot(!0)},Ne=async P=>{P.preventDefault();const se={name:"",email:"",message:""};let ge=!0;const we=Et.name.trim(),_e=Et.message.trim();we||(se.name="Name cannot be empty or just whitespace.",ge=!1),(!Et.email||!sm.isEmail(Et.email))&&(se.email="Please enter a valid email address.",ge=!1),_e||(se.message="Message cannot be empty or just whitespace.",ge=!1),Zt(se),ge&&(Nc({name:we,email:Et.email}),Ot(!1),m(Qe=>Qe.slice(0,-1)),await Ut())},[an,zn]=it.useState({});return it.useEffect(()=>{mi&&(h.forEach((P,se)=>{if(!P.isBot)return;const ge=sp(P.text);if(!(se in an)||an[se]<ge.length){let we;const _e=Qe=>{Qe<ge.length&&(we=setTimeout(()=>{zn(Ft=>({...Ft,[se]:Qe+1})),_e(Qe+1)},Qi))};return se in an?_e(an[se]):(zn(Qe=>({...Qe,[se]:1})),_e(1)),()=>clearTimeout(we)}}),zn(P=>{const se={};return h.forEach((ge,we)=>{P[we]!==void 0&&(se[we]=P[we])}),se}))},[h,mi]),!t||t.show_bot===!1||a?null:R.jsxs(K.ThemeProvider,{theme:tC(t,e),children:[R.jsx("link",{rel:"preconnect",href:"https://fonts.googleapis.com"}),R.jsx("link",{rel:"preconnect",href:"https://fonts.gstatic.com",crossOrigin:"anonymous"}),R.jsx("link",{href:"https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap",rel:"stylesheet"}),R.jsx("link",{href:"https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,100;0,300;0,400;0,700;0,900;1,100;1,300;1,400;1,700;1,900&display=swap",rel:"stylesheet"}),R.jsx(bfe,{}),R.jsx(Xce,{$topOffset:ct,$isLeft:V,children:R.jsxs(vfe,{$isLeft:V,$removeLogoBackground:t.removeLogoBackground,children:[!Ue&&te.length>0&&te[q]&&ae&&R.jsx(yfe,{className:De?"visible":"",$botId:e,$iconSize:H,$removeLogoBackground:t.removeLogoBackground,topOffset:ct,$isLeft:V,style:{display:"flex",flexDirection:V?"row":"row-reverse",alignItems:"center",marginRight:V?"0px":Lt?"10px":"5px",marginTop:Lt?"0px":"10px",left:V?"24px":"auto",right:V?"auto":"24px",opacity:De?1:0,transition:"opacity 0.3s ease-in-out"},children:te.length>0&&te[q]&&(()=>{const P=te[q];return R.jsx(xfe,{children:R.jsx(Qce,{messages:[{question:P.question,isHighlighted:P.isHighlighted??!1,show_for:(X==null?void 0:X.show_for)||4e3,hide_timing:(X==null?void 0:X.hide_timing)||4e3}],botId:e,uiData:t,isLeft:V,onClose:()=>{xt(se=>{const ge=new Set(se);return ge.add(P.question),ge})},onClick:()=>{const se=P;xe(!0,"suggested_question_clicked"),xt(ge=>{const we=new Set(ge);return we.add(se.question),we}),window.DebalesChat.track(Wt.SUGGESTED_QUESTION_CLICKED,{suggested_question:se}),E?(pr(!1),gr(!0),k(!0),D(se)):(pr(!1),gr(!0),r({message:se.Follow_up_Question??se.question,answer:se.answer,products:se.products,fromKlaviyo:!1,leading_queries:se.leading_queries,messType:"suggested_question"}))}})},P.question)})()}),R.jsx(Jce,{$topOffset:ct,$removeLogoBackground:t.removeLogoBackground,style:{display:Ue?"none":"inline-flex"},children:R.jsxs(efe,{$backgroundColor:t.removeLogoBackground?"transparent":t.backgroundColor||"#fff",$botId:e,$iconSize:H,$removeLogoBackground:t.removeLogoBackground,topOffset:ct,$showAnimation:t.enableChatButtonBackgroundAnimation,$animationType:"Ping",$animationColor:t.chatButtonBackgroundAnimationColor||"#f48722",id:"debales-chat-button","data-testid":"debales-chat-button",onClick:()=>{if(window.DebalesChat.track(Wt.CHAT_BUTTON_CLICKED),xe(!Ue,"chat_button_clicked"),!Ue){const P=S();P.length>0?(m(P),pr(!1),gr(!0)):(pr(!0),gr(!1),setTimeout(()=>{pr(!1),gr(!0);const se={text:(t==null?void 0:t.initialMessage)||"Hi, I am an AI chatbot, how can I help you today?",isBot:!0};m([se])},(X==null?void 0:X.showing_delay)||2e3))}},"aria-label":"Chat",style:{display:Ue?"none":"inline-flex"},children:[R.jsx(tfe,{$botId:e,$removeLogoBackground:t.removeLogoBackground,"aria-hidden":"true",src:t.bot_logo,alt:"Chat Bot Icon"}),(te==null?void 0:te.length)>0&&!Ue&&de&&!ae&&R.jsx("div",{style:{position:"absolute",top:"-5px",right:"-5px",backgroundColor:"#f44336",color:"white",borderRadius:"50%",width:"20px",height:"20px",display:"flex",justifyContent:"center",alignItems:"center",fontSize:"12px",fontWeight:"bold",zIndex:2,opacity:de?1:0,transition:"opacity 0.3s ease-in-out"},children:te.length})]})})]})}),Ue&&bo.createPortal(R.jsx(R.Fragment,{children:R.jsxs(ofe,{$backgroundColor:t.backgroundColor||"#fff",$fullScreenOnMobile:t.fullScreenOnMobile,$headerFontColor:t.headerFontColor||"#1C1C1C",$isLeft:V,$topOffset:ct,$mobileDisplayMode:t.mobileDisplayMode,$isVisible:Bt,"data-testid":"debales-chat-container",children:[R.jsxs(lfe,{$backgroundColor:Fe(e)?t.backgroundColor:t.botBackgroundColor||"#fff",style:{color:t.headerFontColor},children:[R.jsx("div",{style:{flexGrow:.1,display:"flex",justifyContent:"center",alignItems:"center",overflow:"hidden",marginRight:"8px",gap:"10px"},children:Fe(e)?R.jsxs(R.Fragment,{children:[R.jsx(fU,{"aria-hidden":"true",src:t.bot_logo,alt:"Chat Bot Icon"}),R.jsxs(nfe,{$botNameColor:t.headerFontColor,children:[R.jsxs("div",{style:{fontWeight:"700",wordBreak:"break-word"},children:[t.chatbotName,e==="catch-org-ai"&&R.jsx(ife,{$backgroundColor:t.callToActionBackgroundColor,$fontColor:t.callToActionFontColor,children:"Beta"})]}),R.jsx(rfe,{})]})]}):R.jsx(afe,{children:R.jsxs(sfe,{children:[R.jsx(fU,{src:t.bot_logo,alt:"Chat Bot Icon"}),R.jsx("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",display:"inline-block",maxWidth:"22ch"},children:t.chatbotName})]})})}),R.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginLeft:"auto",flexShrink:0},children:[R.jsxs(_fe,{children:[R.jsx(dU,{$iconBG:t.backgroundColor,onClick:nt,"aria-label":"Support","data-testid":"debales-support-button",children:R.jsx(a2,{color:t.headerFontColor})}),R.jsx(vU,{children:"Click to chat with a Live Support Agent now."})]}),R.jsx(dU,{$iconBG:t.backgroundColor,onClick:()=>{yt?Ei(!0):xe(!1,"close_button_clicked")},id:"debales-minimize-button","data-testid":"debales-minimize-button","aria-label":"Minimize",children:R.jsx(lm,{botNameColor:t.headerFontColor})})]}),R.jsx(Tfe,{$backgroundColor:t.botBackgroundColor||"#fff",style:{opacity:Kn?1:0}})]}),R.jsxs(ffe,{$backgroundColor:t.botBackgroundColor||"#fff",$mobileDisplayMode:t.mobileDisplayMode,children:[Se&&((Je=(be=t.pluginConfig)==null?void 0:be.collectedUserInfo)==null?void 0:Je.discount)&&R.jsx(g2,{discount:t.pluginConfig.collectedUserInfo.discount,uiData:t,onClose:()=>{rt(!1),window.DebalesChat.track(Wt.DISCOUNT_VIEWED,{discount:t.pluginConfig.collectedUserInfo.discount})}}),R.jsx(_2,{uidata:t,product:ur,showModel:ta,setShowModel:vi,onVariantSelect:P=>{I(P.id,1),ft(!0),window.DebalesChat.track(Wt.ADD_TO_CART_CLICKED,{product:P.title,price:Number(P.price),link:`https://${t.shopifyShopDomain}/variants/${P.id}`,message:l,chatId:er()+e})}}),Tt&&R.jsx(m2,{setShowExitModal:Ei,handleCloseChatbot:Lo,chatId:er()+e}),R.jsxs(ufe,{id:"debales-conversation-group",$botBackgroundColor:t.botBackgroundColor||"#fff",ref:Re,$mobileDisplayMode:t.mobileDisplayMode,children:[R.jsx(Afe,{$backgroundColor:t.botBackgroundColor||"#fff",style:{opacity:Kn?1:0}}),R.jsxs(cfe,{children:[mi&&h.map((P,se)=>{const ge=P.isBot,we=sp(P.text);return P.hideConfirmation?null:R.jsxs(it.Fragment,{children:[ge&&R.jsxs(hU,{$fontColor:t.botFontColor||"#000",$botMessageColor:t.botBackgroundColor||"#fff","data-testid":"debales-ai-message-container",children:[R.jsx("img",{src:ge?t.bot_logo:t.userMessage_logo,alt:"Chat User Icon",style:{marginLeft:"8px"}}),R.jsxs(mU,{children:[we.slice(0,an[se]||0).map((_e,Qe)=>R.jsx("div",{children:R.jsx(Ci,{isBot:ge,children:R.jsx(od,{remarkPlugins:[HS,dC],children:_e})})},Qe)),P.collections&&l===P.conversationId&&kt.collections&&R.jsx(p2,{message:P,botId:e,uidata:t,onSendMessage:r,loading:p}),P.products&&l===P.conversationId&&kt.products&&R.jsx(y2,{message:P,botId:e,uidata:t,onSendMessage:r,loading:p,storeMetaData:n,platform:G,setShowVariantModel:vi,setSelectedProduct:ao,setCartVersion:$e}),o&&R.jsx(YD,{children:R.jsx(K1,{onClick:()=>{window._klOnsite&&(window._klOnsite.push(["openForm",oe]),xe(!1,"klaviyo_grab_deal_button"))},children:"🚀 Grab Deal Now!"})}),O&&O.itemCount>0&&l===P.conversationId&&kt.cartSummary&&tt&&R.jsx(c2,{onCheckout:so,onKeepShopping:()=>{ft(!1)}}),Ae&&Ae.length>0&&l===P.conversationId&&kt.bulkItems&&R.jsx(r2,{onClick:()=>$i(P.conversationId),children:"Add Bulk Items to Cart"}),T&&h.indexOf(P)===h.length-1&&R.jsx(R.Fragment,{children:R.jsx(x2,{setShowModel:_e=>{var Ft,nn;const Qe=typeof _e=="function"?_e(T):_e;k(Qe),!Qe&&((nn=(Ft=t.pluginConfig)==null?void 0:Ft.collectedUserInfo)!=null&&nn.discount)&&rt(!0)},inChat:!0,showFormInstructions:!1})}),at&&h.indexOf(P)===h.length-1&&R.jsxs(Sfe,{onSubmit:Ne,noValidate:!0,"data-testid":"debales-support-form",children:[Fe(e)?R.jsxs(R.Fragment,{children:[R.jsx(ql,{label:"Name",name:"name",type:"text",value:Et.name,onChange:_e=>Xt(Qe=>({...Qe,name:_e.target.value})),required:!0,error:vt.name,isCollectiveBot:!0}),R.jsx(ql,{label:"Email",name:"email",type:"email",value:Et.email,onChange:_e=>Xt(Qe=>({...Qe,email:_e.target.value})),required:!0,error:vt.email,isCollectiveBot:!0}),R.jsx(v2,{label:"Message",name:"message",value:Et.message,onChange:_e=>Xt(Qe=>({...Qe,message:_e.target.value})),required:!0,error:vt.message,rows:4,isCollectiveBot:!0})]}):R.jsxs(R.Fragment,{children:[R.jsxs(ZD,{children:[R.jsxs(QD,{children:["Name",R.jsx("span",{children:"*"})]}),R.jsx(yU,{type:"text",required:!0,value:Et.name,onChange:_e=>Xt(Qe=>({...Qe,name:_e.target.value})),placeholder:"John"}),vt.name&&R.jsx("p",{style:{color:"red",fontSize:"12px",margin:"4px 0 0"},children:vt.name})]}),R.jsxs(ZD,{children:[R.jsxs(QD,{children:["Email",R.jsx("span",{children:"*"})]}),R.jsx(yU,{type:"email",required:!0,value:Et.email,onChange:_e=>Xt(Qe=>({...Qe,email:_e.target.value})),placeholder:"olivia@untitledui.com"}),vt.email&&R.jsx("p",{style:{color:"red",fontSize:"12px",margin:"4px 0 0"},children:vt.email})]}),R.jsxs(ZD,{children:[R.jsxs(QD,{children:["Message",R.jsx("span",{children:"*"})]}),R.jsx(wfe,{required:!0,value:Et.message,onChange:_e=>Xt(Qe=>({...Qe,message:_e.target.value})),placeholder:"I need help with..."}),vt.message&&R.jsx("p",{style:{color:"red",fontSize:"12px",margin:"4px 0 0"},children:vt.message})]})]}),R.jsx(Efe,{children:R.jsx(Cfe,{type:"submit",children:"Submit"})})]}),Qn&&!p&&l===P.conversationId&&R.jsx(Ci,{isBot:ge,children:R.jsx(ms,{loading:Qn,loadingPhrases:["🎨 Loading","✨ Almost","🚀 Ready"]})})]})]}),!ge&&R.jsx(gfe,{$fontColor:t.userFontColor||"#000",$botMessageColor:t.botBackgroundColor||"#fff",children:R.jsx(Ci,{isBot:!!ge,children:R.jsx(od,{children:P.text})})}),h.length==1&&se==0&&!T&&R.jsx(YD,{children:br.leadingQueries?R.jsx(Ci,{isBot:!0,children:R.jsx(ms,{loading:br.leadingQueries})}):te.map((_e,Qe)=>R.jsxs(gU,{style:{backgroundColor:t.callToActionBackgroundColor,color:t.callToActionFontColor,opacity:ht.has(_e.question)?.5:1},onClick:()=>{E?(k(!0),D({question:_e.question,answer:_e.answer,products:_e.products,path:"/",nameSpace:window.DebalesChat.projectId})):r({message:_e.question,answer:_e.answer,products:_e.products,messType:"leading_query"}),xt(Ft=>{const nn=new Set(Ft);return nn.add(_e.question),nn}),window.DebalesChat.track(Wt.INITIAL_LEADING_QUERY_SUGGESTED_QUESTION_CLICKED,{question:_e.question})},disabled:p,$disabled:p,children:[_e.question,R.jsx(pU,{color:t.callToActionFontColor})]},Qe))}),P.leading_queries&&P.leading_queries.length>0&&l===P.conversationId&&kt.leadingQueries&&!o&&!T&&R.jsx(YD,{children:P.leading_queries.map((_e,Qe)=>R.jsxs(gU,{style:{backgroundColor:t.callToActionBackgroundColor,color:t.callToActionFontColor},onClick:()=>{E?(k(!0),D({question:_e,path:"/",nameSpace:window.DebalesChat.projectId})):r({message:_e,messType:"leading_query"}),window.DebalesChat.track(Wt.LEADING_QUERY_CLICKED,{query:_e})},disabled:p,$disabled:p,children:[_e,R.jsx(pU,{color:t.callToActionFontColor})]},Qe))})]},se)}),(p||nr)&&R.jsxs(hU,{$fontColor:t.botFontColor||"#000",$botMessageColor:t.botBackgroundColor||"#fff",children:[R.jsx("img",{src:t.bot_logo,alt:"Chat User Icon"}),R.jsx(mU,{children:R.jsx(Ci,{isBot:!0,children:R.jsx("div",{style:{display:"flex",alignItems:"center",gap:"4px",animation:"fadeIn 0.3s ease-in-out"},children:R.jsx(ms,{loading:p||nr})})})})]})]}),R.jsx(kfe,{$backgroundColor:t.botBackgroundColor||"#fff",style:{opacity:En?1:0}})]}),R.jsxs("div",{className:"debales-footer-container",style:{width:"100%",backgroundColor:t.botBackgroundColor||"#fff",color:t.fontColor||"#000"},children:[(e==="catch-org-ai"||e==="letsgo-catch")&&R.jsx(pfe,{children:R.jsx("span",{children:`"${t.chatbotName}" can make mistakes.`})}),R.jsx("div",{children:R.jsx(S2,{disabled:p,inputState:!1})}),(t.debales_branding??!0)&&R.jsxs(dfe,{href:"https://debales.ai/?open=true",target:"_blank",title:"debales-link",style:{color:t.fontColor?t.fontColor:"fff",marginTop:e==="catch-org-ai"?"0":"9px"},children:[R.jsx("p",{children:"Powered by"}),R.jsxs(hfe,{children:[R.jsx("img",{src:`${wi}/images/debales_logo_d.png`,alt:"Debales logo"}),R.jsx("p",{children:"DEBALES"})]})]})]})]})]})}),z.shadowRoot)]})},Ofe=K.p`
4080
4080
  margin: 0;
4081
4081
  font-size: 16px;
4082
4082
  text-align: left;
@@ -4842,7 +4842,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
4842
4842
 
4843
4843
  `+we+`
4844
4844
 
4845
- => User Action: Klaviyo form closed`}return""},P=se=>{se instanceof CustomEvent&&be(se)};return window.addEventListener("klaviyoForms",P),()=>{window.removeEventListener("klaviyoForms",P)}},[tt,t,r]),it.useEffect(()=>{const be=pe.current;return ot&&be?(be.addEventListener("scroll",_n),()=>{be&&be.removeEventListener("scroll",_n)}):()=>{}},[ot,_n]);const[mr,so]=re.useState(!1),Se=Y==="Highest"?"120px":Y==="Higher"?"60px":"15px",rt=async()=>{try{const be=await fetch(`${wi}/api/wordpress/support`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({chatid:er()+e,nameSpace:e,userName:at.name,userEmail:at.email,userMessage:at.message,tag:"support"})});if(be.ok){const Je=`support-confirm-${Date.now()}`;m(P=>[...P,{text:"Thanks for reaching out! Our support team has received your request and will get back to you within 24 hours.<br>In the meantime, feel free to continue chatting with me - I'll do my best to help!",isBot:!0,leading_queries:Et,conversationId:Je}]),d(Je),yt(P=>({...P,leadingQueries:!0})),Xt([]),console.log("Connected to support with existing user info:",Bo())}else{const Je=await be.json();console.error("Failed to connect to support:",Je),m(P=>[...P,{text:"Sorry, we couldn't connect you to support at the moment.<br>Please try again later.",isBot:!0}])}}catch{m(Je=>[...Je,{text:"Sorry, we couldn't connect you to support at the moment.<br>Please try again later.",isBot:!0}])}},ct=()=>{const be=Bo();let Je=[];const P=h[h.length-1];P!=null&&P.leading_queries&&P.leading_queries.length>0?Je=P.leading_queries:h.length<=1&&(Je=te.flatMap(se=>Array.isArray(se)?se.map(ge=>ge.question):[se.question]).slice(0,4)),Xt(Je),be&&be.name&&be.email&&Ot({name:be==null?void 0:be.name,email:be==null?void 0:be.email,message:""}),m(se=>[...se,{text:"Please provide your name, email and message to connect with support.",isBot:!0}]),Ct(!0)},Ut=async be=>{be.preventDefault();const Je={name:"",email:"",message:""};let P=!0;const se=at.name.trim(),ge=at.message.trim();se||(Je.name="Name cannot be empty or just whitespace.",P=!1),(!at.email||!sm.isEmail(at.email))&&(Je.email="Please enter a valid email address.",P=!1),ge||(Je.message="Message cannot be empty or just whitespace.",P=!1),yn(Je),P&&(Nc({name:se,email:at.email}),Ct(!1),m(we=>we.slice(0,-1)),await rt())},[nt,Ne]=it.useState({});return it.useEffect(()=>{nr&&(h.forEach((be,Je)=>{if(!be.isBot)return;const P=sp(be.text);if(!(Je in nt)||nt[Je]<P.length){let se;const ge=we=>{we<P.length&&(se=setTimeout(()=>{Ne(_e=>({..._e,[Je]:we+1})),ge(we+1)},En))};return Je in nt?ge(nt[Je]):(Ne(we=>({...we,[Je]:1})),ge(1)),()=>clearTimeout(se)}}),Ne(be=>{const Je={};return h.forEach((P,se)=>{be[se]!==void 0&&(Je[se]=be[se])}),Je}))},[h,nr]),!t||t.show_bot===!1||a?null:R.jsxs(K.ThemeProvider,{theme:tC(t,e),children:[R.jsx("link",{rel:"preconnect",href:"https://fonts.googleapis.com"}),R.jsx("link",{rel:"preconnect",href:"https://fonts.gstatic.com",crossOrigin:"anonymous"}),R.jsx("link",{href:"https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap",rel:"stylesheet"}),R.jsx("link",{href:"https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,100;0,300;0,400;0,700;0,900;1,100;1,300;1,400;1,700;1,900&display=swap",rel:"stylesheet"}),R.jsx(rde,{}),R.jsxs($fe,{$topOffset:Se,$isLeft:V,children:[!ot&&te.length>0&&te[q]&&ae&&R.jsx(tde,{className:De?"visible":"",$botId:e,$iconSize:H,$removeLogoBackground:t.removeLogoBackground,topOffset:Se,style:{display:"flex",flexDirection:"column",alignItems:"center",opacity:De?1:0,transition:"opacity 0.3s ease-in-out"},children:te.length>0&&te[q]&&R.jsx(nde,{children:R.jsx(Rfe,{messages:[{question:te[q].question,isHighlighted:te[q].isHighlighted??!1,show_for:(X==null?void 0:X.show_for)||4e3,hide_timing:(X==null?void 0:X.hide_timing)||4e3}],botId:e,uiData:t,onClose:()=>{Le(be=>{const Je=new Set(be);return Je.add(te[q].question),Je})},onClick:()=>{const be=te[q];ht(!0,"suggested_question_clicked"),Le(Je=>{const P=new Set(Je);return P.add(be.question),P}),window.DebalesChat.track(Wt.SUGGESTED_QUESTION_CLICKED,{suggested_question:be}),E?(tr(!1),pr(!0),k(!0),D(be)):(tr(!1),pr(!0),r({message:be.Follow_up_Question??be.question,answer:be.answer,products:be.products,fromKlaviyo:!1,leading_queries:be.leading_queries,followUpQuestion:be.Follow_up_Question,messType:"suggested_question"}))}})},te[q].question)}),R.jsxs(Lfe,{$topOffset:Se,$removeLogoBackground:t.removeLogoBackground,style:{display:ot||ae?"none":"flex"},children:[R.jsx(Nfe,{$showAnimation:t.enableChatButtonBackgroundAnimation??!1,$animationType:"Ping",$animationColor:t.chatButtonBackgroundAnimationColor||"#f48722",$backgroundColor:t.backgroundColor||"#fff",$removeLogoBackground:t.removeLogoBackground,$topOffset:Se,$iconSize:H}),R.jsxs(zfe,{$backgroundColor:t.removeLogoBackground?"transparent":t.backgroundColor||"#fff",$botId:e,$iconSize:H,$removeLogoBackground:t.removeLogoBackground,topOffset:Se,$showAnimation:t.enableChatButtonBackgroundAnimation,$animationType:"Ping",$animationColor:t.chatButtonBackgroundAnimationColor||"#f48722",id:"debales-chat-button","data-testid":"debales-chat-button",onClick:()=>{if(window.DebalesChat.track(Wt.CHAT_BUTTON_CLICKED),ht(!ot,"chat_button_clicked"),!ot){const be=S();be.length>0?(m(be),tr(!1),pr(!0)):(tr(!0),pr(!1),setTimeout(()=>{tr(!1),pr(!0);const Je={text:(t==null?void 0:t.initialMessage)||"Hi, I am an AI chatbot, how can I help you today?",isBot:!0};m([Je])},(X==null?void 0:X.showing_delay)||2e3))}},"aria-label":"Chat",style:{display:ot||ae?"none":"flex"},children:[R.jsx(Ffe,{$botId:e,$removeLogoBackground:t.removeLogoBackground,"aria-hidden":"true",src:t.bot_logo,alt:"Chat Bot Icon"}),(te==null?void 0:te.length)>0&&!ot&&de&&R.jsx("div",{style:{position:"absolute",top:"0px",right:"0px",backgroundColor:"#f44336",color:"white",borderRadius:"50%",width:"20px",height:"20px",display:"flex",justifyContent:"center",alignItems:"center",fontSize:"12px",fontWeight:"bold",zIndex:2,opacity:de?1:0,transition:"opacity 0.3s ease-in-out"},children:te.length})]})]})]}),ot&&bo.createPortal(R.jsx(R.Fragment,{children:R.jsxs(qfe,{$backgroundColor:t.backgroundColor||"#fff",$fullScreenOnMobile:t.fullScreenOnMobile,$headerFontColor:t.headerFontColor||"#1C1C1C",$isLeft:V,$topOffset:Se,$mobileDisplayMode:t.mobileDisplayMode,$isVisible:Pt,"data-testid":"debales-chat-container",children:[R.jsxs(Vfe,{$backgroundColor:Fe(e)?t.backgroundColor:t.botBackgroundColor||"#fff",style:{color:t.headerFontColor},children:[R.jsx("div",{style:{flexGrow:.1,display:"flex",justifyContent:"center",alignItems:"center",overflow:"hidden",marginRight:"8px",gap:"10px"},children:Fe(e)?R.jsxs(R.Fragment,{children:[R.jsx(bU,{"aria-hidden":"true",src:t.bot_logo,alt:"Chat Bot Icon"}),R.jsxs(Ufe,{$botNameColor:t.headerFontColor,children:[R.jsxs("div",{style:{fontWeight:"700",wordBreak:"break-word"},children:[t.chatbotName,e==="catch-org-ai"&&R.jsx(Hfe,{$backgroundColor:t.callToActionBackgroundColor,$fontColor:t.callToActionFontColor,children:"Beta"})]}),R.jsx(jfe,{})]})]}):R.jsx(Pfe,{children:R.jsxs(Gfe,{children:[R.jsx(bU,{src:t.bot_logo,alt:"Chat Bot Icon"}),R.jsx("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",display:"inline-block",maxWidth:"22ch"},children:t.chatbotName})]})})}),R.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginLeft:"auto",flexShrink:0},children:[R.jsxs(ide,{children:[R.jsx(_U,{$iconBG:t.backgroundColor,onClick:ct,"aria-label":"Support","data-testid":"debales-support-button",children:R.jsx(a2,{color:t.headerFontColor})}),R.jsx(AU,{children:"Click to chat with a Live Support Agent now."})]}),R.jsx(_U,{$iconBG:t.backgroundColor,onClick:()=>{vt?vi(!0):ht(!1,"close_button_clicked")},id:"debales-minimize-button","data-testid":"debales-minimize-button","aria-label":"Minimize",children:R.jsx(lm,{botNameColor:t.headerFontColor})})]}),R.jsx(fde,{$backgroundColor:t.botBackgroundColor||"#fff",style:{opacity:mi?1:0}})]}),R.jsxs(Qfe,{$backgroundColor:t.botBackgroundColor||"#fff",$mobileDisplayMode:t.mobileDisplayMode,children:[mr&&((zn=(an=t.pluginConfig)==null?void 0:an.collectedUserInfo)==null?void 0:zn.discount)&&R.jsx(g2,{discount:t.pluginConfig.collectedUserInfo.discount,uiData:t,onClose:()=>{so(!1),window.DebalesChat.track(Wt.DISCOUNT_VIEWED,{discount:t.pluginConfig.collectedUserInfo.discount})}}),R.jsx(_2,{uidata:t,product:Tt,showModel:Qi,setShowModel:rr,onVariantSelect:be=>{I(be.id,1),oe(!0),window.DebalesChat.track(Wt.ADD_TO_CART_CLICKED,{product:be.title,price:Number(be.price),link:`https://${t.shopifyShopDomain}/variants/${be.id}`,message:l,chatId:er()+e})}}),ta&&R.jsx(m2,{setShowExitModal:vi,handleCloseChatbot:ur,chatId:er()+e}),R.jsxs(Yfe,{id:"debales-conversation-group",$botBackgroundColor:t.botBackgroundColor||"#fff",ref:pe,$mobileDisplayMode:t.mobileDisplayMode,children:[R.jsx(ude,{$backgroundColor:t.botBackgroundColor||"#fff",style:{opacity:mi?1:0}}),R.jsxs(Zfe,{children:[nr&&h.map((be,Je)=>{const P=be.isBot,se=sp(be.text);return be.hideConfirmation?null:R.jsxs(it.Fragment,{children:[P&&R.jsxs(SU,{$fontColor:t.botFontColor||"#000",$botMessageColor:t.botBackgroundColor||"#fff","data-testid":"debales-ai-message-container",children:[R.jsx("img",{src:P?t.bot_logo:t.userMessage_logo,alt:"Chat User Icon",style:{marginLeft:"8px"}}),R.jsxs(EU,{children:[se.slice(0,nt[Je]||0).map((ge,we)=>R.jsx("div",{children:R.jsx(Ci,{isBot:P,children:R.jsx(od,{remarkPlugins:[HS,dC],children:ge})})},we)),be.collections&&l===be.conversationId&&Zt.collections&&R.jsx(p2,{message:be,botId:e,uidata:t,onSendMessage:r,loading:p}),be.products&&l===be.conversationId&&Zt.products&&R.jsx(y2,{message:be,botId:e,uidata:t,onSendMessage:r,loading:p,storeMetaData:n,platform:G,setShowVariantModel:rr,setSelectedProduct:Ei,setCartVersion:bt}),o&&R.jsx(WD,{children:R.jsx(K1,{onClick:()=>{window._klOnsite&&(window._klOnsite.push(["openForm",Lt]),ht(!1,"klaviyo_grab_deal_button"))},children:"🚀 Grab Deal Now!"})}),O&&O.itemCount>0&&l===be.conversationId&&Zt.cartSummary&&ne&&R.jsx(c2,{onCheckout:$i,onKeepShopping:()=>{oe(!1)}}),xt&&xt.length>0&&l===be.conversationId&&Zt.bulkItems&&R.jsx(r2,{onClick:()=>ao(be.conversationId),children:"Add Bulk Items to Cart"}),T&&h.indexOf(be)===h.length-1&&R.jsx(R.Fragment,{children:R.jsx(x2,{setShowModel:ge=>{var _e,Qe;const we=typeof ge=="function"?ge(T):ge;k(we),!we&&((Qe=(_e=t.pluginConfig)==null?void 0:_e.collectedUserInfo)!=null&&Qe.discount)&&so(!0)},inChat:!0,showFormInstructions:!1})}),Ae&&h.indexOf(be)===h.length-1&&R.jsxs(ode,{onSubmit:Ut,noValidate:!0,"data-testid":"debales-support-form",children:[Fe(e)?R.jsxs(R.Fragment,{children:[R.jsx(ql,{label:"Name",name:"name",type:"text",value:at.name,onChange:ge=>Ot(we=>({...we,name:ge.target.value})),required:!0,error:Yt.name,isCollectiveBot:!0}),R.jsx(ql,{label:"Email",name:"email",type:"email",value:at.email,onChange:ge=>Ot(we=>({...we,email:ge.target.value})),required:!0,error:Yt.email,isCollectiveBot:!0}),R.jsx(v2,{label:"Message",name:"message",value:at.message,onChange:ge=>Ot(we=>({...we,message:ge.target.value})),required:!0,error:Yt.message,rows:4,isCollectiveBot:!0})]}):R.jsxs(R.Fragment,{children:[R.jsxs(XD,{children:[R.jsxs(JD,{children:["Name",R.jsx("span",{children:"*"})]}),R.jsx(kU,{type:"text",required:!0,value:at.name,onChange:ge=>Ot(we=>({...we,name:ge.target.value})),placeholder:"John"}),Yt.name&&R.jsx("p",{style:{color:"red",fontSize:"12px",margin:"4px 0 0"},children:Yt.name})]}),R.jsxs(XD,{children:[R.jsxs(JD,{children:["Email",R.jsx("span",{children:"*"})]}),R.jsx(kU,{type:"email",required:!0,value:at.email,onChange:ge=>Ot(we=>({...we,email:ge.target.value})),placeholder:"olivia@untitledui.com"}),Yt.email&&R.jsx("p",{style:{color:"red",fontSize:"12px",margin:"4px 0 0"},children:Yt.email})]}),R.jsxs(XD,{children:[R.jsxs(JD,{children:["Message",R.jsx("span",{children:"*"})]}),R.jsx(ade,{required:!0,value:at.message,onChange:ge=>Ot(we=>({...we,message:ge.target.value})),placeholder:"I need help with..."}),Yt.message&&R.jsx("p",{style:{color:"red",fontSize:"12px",margin:"4px 0 0"},children:Yt.message})]})]}),R.jsx(lde,{children:R.jsx(sde,{type:"submit",children:"Submit"})})]}),br&&!p&&l===be.conversationId&&R.jsx(Ci,{isBot:P,children:R.jsx(ms,{loading:br,loadingPhrases:["🎨 Loading","✨ Almost","🚀 Ready"]})})]})]}),!P&&R.jsx(Jfe,{$fontColor:t.userFontColor||"#000",$botMessageColor:t.botBackgroundColor||"#fff",children:R.jsx(Ci,{isBot:!!P,children:R.jsx(od,{children:be.text})})}),h.length==1&&Je==0&&!T&&R.jsx(WD,{children:kt.leadingQueries?R.jsx(Ci,{isBot:!0,children:R.jsx(ms,{loading:kt.leadingQueries})}):te.map((ge,we)=>R.jsxs(CU,{style:{backgroundColor:t.callToActionBackgroundColor,color:t.callToActionFontColor,opacity:Re.has(ge.question)?.5:1},onClick:()=>{E?(k(!0),D({question:ge.question,answer:ge.answer,products:ge.products,path:"/",nameSpace:window.DebalesChat.projectId})):r({message:ge.question,answer:ge.answer,products:ge.products,messType:"leading_query"}),Le(_e=>{const Qe=new Set(_e);return Qe.add(ge.question),Qe}),window.DebalesChat.track(Wt.INITIAL_LEADING_QUERY_SUGGESTED_QUESTION_CLICKED,{question:ge.question})},disabled:p,$disabled:p,children:[ge.question,R.jsx(wU,{color:t.callToActionFontColor})]},we))}),be.leading_queries&&be.leading_queries.length>0&&l===be.conversationId&&Zt.leadingQueries&&!o&&!T&&R.jsx(WD,{children:be.leading_queries.map((ge,we)=>R.jsxs(CU,{style:{backgroundColor:t.callToActionBackgroundColor,color:t.callToActionFontColor},onClick:()=>{E?(k(!0),D({question:ge,path:"/",nameSpace:window.DebalesChat.projectId})):r({message:ge,messType:"leading_query"}),window.DebalesChat.track(Wt.LEADING_QUERY_CLICKED,{query:ge})},disabled:p,$disabled:p,children:[ge,R.jsx(wU,{color:t.callToActionFontColor})]},we))})]},Je)}),(p||_r)&&R.jsxs(SU,{$fontColor:t.botFontColor||"#000",$botMessageColor:t.botBackgroundColor||"#fff",children:[R.jsx("img",{src:t.bot_logo,alt:"Chat User Icon"}),R.jsx(EU,{children:R.jsx(Ci,{isBot:!0,children:R.jsx("div",{style:{display:"flex",alignItems:"center",gap:"4px",animation:"fadeIn 0.3s ease-in-out"},children:R.jsx(ms,{loading:p||_r})})})})]})]}),R.jsx(cde,{$backgroundColor:t.botBackgroundColor||"#fff",style:{opacity:Kn?1:0}})]}),R.jsxs("div",{className:"debales-footer-container",style:{width:"calc(100%-24px)",backgroundColor:t.botBackgroundColor||"#fff",color:t.fontColor||"#000"},children:[e==="catch-org-ai"&&R.jsx(Xfe,{children:R.jsx("span",{children:'"Catch org AI" can make mistakes.'})}),R.jsx("div",{children:R.jsx(S2,{disabled:p,inputState:!1})}),(t.debales_branding??!0)&&R.jsxs(Kfe,{href:"https://debales.ai/?open=true",target:"_blank",title:"debales-link",style:{color:t.fontColor?t.fontColor:"fff",marginTop:e==="catch-org-ai"?"0":"9px"},children:[R.jsx("p",{children:"Powered by"}),R.jsxs(Wfe,{children:[R.jsx("img",{src:`${wi}/images/debales_logo_d.png`,alt:"Debales logo"}),R.jsx("p",{children:"DEBALES"})]})]})]})]})]})}),z.shadowRoot)]})},hde=({botId:e})=>{const t=QG("new-suggested-question-design");let n;return t==="variant-1"?n=Vce:t==="variant-2"?n=Dfe:t==="variant-3"?n=dde:n=tU,R.jsx(n,{botId:e})};var w2={exports:{}},ax={},C2={exports:{}},tO={};/**
4845
+ => User Action: Klaviyo form closed`}return""},P=se=>{se instanceof CustomEvent&&be(se)};return window.addEventListener("klaviyoForms",P),()=>{window.removeEventListener("klaviyoForms",P)}},[tt,t,r]),it.useEffect(()=>{const be=pe.current;return ot&&be?(be.addEventListener("scroll",_n),()=>{be&&be.removeEventListener("scroll",_n)}):()=>{}},[ot,_n]);const[mr,so]=re.useState(!1),Se=Y==="Highest"?"120px":Y==="Higher"?"60px":"15px",rt=async()=>{try{const be=await fetch(`${wi}/api/wordpress/support`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({chatid:er()+e,nameSpace:e,userName:at.name,userEmail:at.email,userMessage:at.message,tag:"support"})});if(be.ok){const Je=`support-confirm-${Date.now()}`;m(P=>[...P,{text:"Thanks for reaching out! Our support team has received your request and will get back to you within 24 hours.<br>In the meantime, feel free to continue chatting with me - I'll do my best to help!",isBot:!0,leading_queries:Et,conversationId:Je}]),d(Je),yt(P=>({...P,leadingQueries:!0})),Xt([]),console.log("Connected to support with existing user info:",Bo())}else{const Je=await be.json();console.error("Failed to connect to support:",Je),m(P=>[...P,{text:"Sorry, we couldn't connect you to support at the moment.<br>Please try again later.",isBot:!0}])}}catch{m(Je=>[...Je,{text:"Sorry, we couldn't connect you to support at the moment.<br>Please try again later.",isBot:!0}])}},ct=()=>{const be=Bo();let Je=[];const P=h[h.length-1];P!=null&&P.leading_queries&&P.leading_queries.length>0?Je=P.leading_queries:h.length<=1&&(Je=te.flatMap(se=>Array.isArray(se)?se.map(ge=>ge.question):[se.question]).slice(0,4)),Xt(Je),be&&be.name&&be.email&&Ot({name:be==null?void 0:be.name,email:be==null?void 0:be.email,message:""}),m(se=>[...se,{text:"Please provide your name, email and message to connect with support.",isBot:!0}]),Ct(!0)},Ut=async be=>{be.preventDefault();const Je={name:"",email:"",message:""};let P=!0;const se=at.name.trim(),ge=at.message.trim();se||(Je.name="Name cannot be empty or just whitespace.",P=!1),(!at.email||!sm.isEmail(at.email))&&(Je.email="Please enter a valid email address.",P=!1),ge||(Je.message="Message cannot be empty or just whitespace.",P=!1),yn(Je),P&&(Nc({name:se,email:at.email}),Ct(!1),m(we=>we.slice(0,-1)),await rt())},[nt,Ne]=it.useState({});return it.useEffect(()=>{nr&&(h.forEach((be,Je)=>{if(!be.isBot)return;const P=sp(be.text);if(!(Je in nt)||nt[Je]<P.length){let se;const ge=we=>{we<P.length&&(se=setTimeout(()=>{Ne(_e=>({..._e,[Je]:we+1})),ge(we+1)},En))};return Je in nt?ge(nt[Je]):(Ne(we=>({...we,[Je]:1})),ge(1)),()=>clearTimeout(se)}}),Ne(be=>{const Je={};return h.forEach((P,se)=>{be[se]!==void 0&&(Je[se]=be[se])}),Je}))},[h,nr]),!t||t.show_bot===!1||a?null:R.jsxs(K.ThemeProvider,{theme:tC(t,e),children:[R.jsx("link",{rel:"preconnect",href:"https://fonts.googleapis.com"}),R.jsx("link",{rel:"preconnect",href:"https://fonts.gstatic.com",crossOrigin:"anonymous"}),R.jsx("link",{href:"https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap",rel:"stylesheet"}),R.jsx("link",{href:"https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,100;0,300;0,400;0,700;0,900;1,100;1,300;1,400;1,700;1,900&display=swap",rel:"stylesheet"}),R.jsx(rde,{}),R.jsxs($fe,{$topOffset:Se,$isLeft:V,children:[!ot&&te.length>0&&te[q]&&ae&&R.jsx(tde,{className:De?"visible":"",$botId:e,$iconSize:H,$removeLogoBackground:t.removeLogoBackground,topOffset:Se,style:{display:"flex",flexDirection:"column",alignItems:"center",opacity:De?1:0,transition:"opacity 0.3s ease-in-out"},children:te.length>0&&te[q]&&R.jsx(nde,{children:R.jsx(Rfe,{messages:[{question:te[q].question,isHighlighted:te[q].isHighlighted??!1,show_for:(X==null?void 0:X.show_for)||4e3,hide_timing:(X==null?void 0:X.hide_timing)||4e3}],botId:e,uiData:t,onClose:()=>{Le(be=>{const Je=new Set(be);return Je.add(te[q].question),Je})},onClick:()=>{const be=te[q];ht(!0,"suggested_question_clicked"),Le(Je=>{const P=new Set(Je);return P.add(be.question),P}),window.DebalesChat.track(Wt.SUGGESTED_QUESTION_CLICKED,{suggested_question:be}),E?(tr(!1),pr(!0),k(!0),D(be)):(tr(!1),pr(!0),r({message:be.Follow_up_Question??be.question,answer:be.answer,products:be.products,fromKlaviyo:!1,leading_queries:be.leading_queries,followUpQuestion:be.Follow_up_Question,messType:"suggested_question"}))}})},te[q].question)}),R.jsxs(Lfe,{$topOffset:Se,$removeLogoBackground:t.removeLogoBackground,style:{display:ot||ae?"none":"flex"},children:[R.jsx(Nfe,{$showAnimation:t.enableChatButtonBackgroundAnimation??!1,$animationType:"Ping",$animationColor:t.chatButtonBackgroundAnimationColor||"#f48722",$backgroundColor:t.backgroundColor||"#fff",$removeLogoBackground:t.removeLogoBackground,$topOffset:Se,$iconSize:H}),R.jsxs(zfe,{$backgroundColor:t.removeLogoBackground?"transparent":t.backgroundColor||"#fff",$botId:e,$iconSize:H,$removeLogoBackground:t.removeLogoBackground,topOffset:Se,$showAnimation:t.enableChatButtonBackgroundAnimation,$animationType:"Ping",$animationColor:t.chatButtonBackgroundAnimationColor||"#f48722",id:"debales-chat-button","data-testid":"debales-chat-button",onClick:()=>{if(window.DebalesChat.track(Wt.CHAT_BUTTON_CLICKED),ht(!ot,"chat_button_clicked"),!ot){const be=S();be.length>0?(m(be),tr(!1),pr(!0)):(tr(!0),pr(!1),setTimeout(()=>{tr(!1),pr(!0);const Je={text:(t==null?void 0:t.initialMessage)||"Hi, I am an AI chatbot, how can I help you today?",isBot:!0};m([Je])},(X==null?void 0:X.showing_delay)||2e3))}},"aria-label":"Chat",style:{display:ot||ae?"none":"flex"},children:[R.jsx(Ffe,{$botId:e,$removeLogoBackground:t.removeLogoBackground,"aria-hidden":"true",src:t.bot_logo,alt:"Chat Bot Icon"}),(te==null?void 0:te.length)>0&&!ot&&de&&R.jsx("div",{style:{position:"absolute",top:"0px",right:"0px",backgroundColor:"#f44336",color:"white",borderRadius:"50%",width:"20px",height:"20px",display:"flex",justifyContent:"center",alignItems:"center",fontSize:"12px",fontWeight:"bold",zIndex:2,opacity:de?1:0,transition:"opacity 0.3s ease-in-out"},children:te.length})]})]})]}),ot&&bo.createPortal(R.jsx(R.Fragment,{children:R.jsxs(qfe,{$backgroundColor:t.backgroundColor||"#fff",$fullScreenOnMobile:t.fullScreenOnMobile,$headerFontColor:t.headerFontColor||"#1C1C1C",$isLeft:V,$topOffset:Se,$mobileDisplayMode:t.mobileDisplayMode,$isVisible:Pt,"data-testid":"debales-chat-container",children:[R.jsxs(Vfe,{$backgroundColor:Fe(e)?t.backgroundColor:t.botBackgroundColor||"#fff",style:{color:t.headerFontColor},children:[R.jsx("div",{style:{flexGrow:.1,display:"flex",justifyContent:"center",alignItems:"center",overflow:"hidden",marginRight:"8px",gap:"10px"},children:Fe(e)?R.jsxs(R.Fragment,{children:[R.jsx(bU,{"aria-hidden":"true",src:t.bot_logo,alt:"Chat Bot Icon"}),R.jsxs(Ufe,{$botNameColor:t.headerFontColor,children:[R.jsxs("div",{style:{fontWeight:"700",wordBreak:"break-word"},children:[t.chatbotName,e==="catch-org-ai"&&R.jsx(Hfe,{$backgroundColor:t.callToActionBackgroundColor,$fontColor:t.callToActionFontColor,children:"Beta"})]}),R.jsx(jfe,{})]})]}):R.jsx(Pfe,{children:R.jsxs(Gfe,{children:[R.jsx(bU,{src:t.bot_logo,alt:"Chat Bot Icon"}),R.jsx("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",display:"inline-block",maxWidth:"22ch"},children:t.chatbotName})]})})}),R.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginLeft:"auto",flexShrink:0},children:[R.jsxs(ide,{children:[R.jsx(_U,{$iconBG:t.backgroundColor,onClick:ct,"aria-label":"Support","data-testid":"debales-support-button",children:R.jsx(a2,{color:t.headerFontColor})}),R.jsx(AU,{children:"Click to chat with a Live Support Agent now."})]}),R.jsx(_U,{$iconBG:t.backgroundColor,onClick:()=>{vt?vi(!0):ht(!1,"close_button_clicked")},id:"debales-minimize-button","data-testid":"debales-minimize-button","aria-label":"Minimize",children:R.jsx(lm,{botNameColor:t.headerFontColor})})]}),R.jsx(fde,{$backgroundColor:t.botBackgroundColor||"#fff",style:{opacity:mi?1:0}})]}),R.jsxs(Qfe,{$backgroundColor:t.botBackgroundColor||"#fff",$mobileDisplayMode:t.mobileDisplayMode,children:[mr&&((zn=(an=t.pluginConfig)==null?void 0:an.collectedUserInfo)==null?void 0:zn.discount)&&R.jsx(g2,{discount:t.pluginConfig.collectedUserInfo.discount,uiData:t,onClose:()=>{so(!1),window.DebalesChat.track(Wt.DISCOUNT_VIEWED,{discount:t.pluginConfig.collectedUserInfo.discount})}}),R.jsx(_2,{uidata:t,product:Tt,showModel:Qi,setShowModel:rr,onVariantSelect:be=>{I(be.id,1),oe(!0),window.DebalesChat.track(Wt.ADD_TO_CART_CLICKED,{product:be.title,price:Number(be.price),link:`https://${t.shopifyShopDomain}/variants/${be.id}`,message:l,chatId:er()+e})}}),ta&&R.jsx(m2,{setShowExitModal:vi,handleCloseChatbot:ur,chatId:er()+e}),R.jsxs(Yfe,{id:"debales-conversation-group",$botBackgroundColor:t.botBackgroundColor||"#fff",ref:pe,$mobileDisplayMode:t.mobileDisplayMode,children:[R.jsx(ude,{$backgroundColor:t.botBackgroundColor||"#fff",style:{opacity:mi?1:0}}),R.jsxs(Zfe,{children:[nr&&h.map((be,Je)=>{const P=be.isBot,se=sp(be.text);return be.hideConfirmation?null:R.jsxs(it.Fragment,{children:[P&&R.jsxs(SU,{$fontColor:t.botFontColor||"#000",$botMessageColor:t.botBackgroundColor||"#fff","data-testid":"debales-ai-message-container",children:[R.jsx("img",{src:P?t.bot_logo:t.userMessage_logo,alt:"Chat User Icon",style:{marginLeft:"8px"}}),R.jsxs(EU,{children:[se.slice(0,nt[Je]||0).map((ge,we)=>R.jsx("div",{children:R.jsx(Ci,{isBot:P,children:R.jsx(od,{remarkPlugins:[HS,dC],children:ge})})},we)),be.collections&&l===be.conversationId&&Zt.collections&&R.jsx(p2,{message:be,botId:e,uidata:t,onSendMessage:r,loading:p}),be.products&&l===be.conversationId&&Zt.products&&R.jsx(y2,{message:be,botId:e,uidata:t,onSendMessage:r,loading:p,storeMetaData:n,platform:G,setShowVariantModel:rr,setSelectedProduct:Ei,setCartVersion:bt}),o&&R.jsx(WD,{children:R.jsx(K1,{onClick:()=>{window._klOnsite&&(window._klOnsite.push(["openForm",Lt]),ht(!1,"klaviyo_grab_deal_button"))},children:"🚀 Grab Deal Now!"})}),O&&O.itemCount>0&&l===be.conversationId&&Zt.cartSummary&&ne&&R.jsx(c2,{onCheckout:$i,onKeepShopping:()=>{oe(!1)}}),xt&&xt.length>0&&l===be.conversationId&&Zt.bulkItems&&R.jsx(r2,{onClick:()=>ao(be.conversationId),children:"Add Bulk Items to Cart"}),T&&h.indexOf(be)===h.length-1&&R.jsx(R.Fragment,{children:R.jsx(x2,{setShowModel:ge=>{var _e,Qe;const we=typeof ge=="function"?ge(T):ge;k(we),!we&&((Qe=(_e=t.pluginConfig)==null?void 0:_e.collectedUserInfo)!=null&&Qe.discount)&&so(!0)},inChat:!0,showFormInstructions:!1})}),Ae&&h.indexOf(be)===h.length-1&&R.jsxs(ode,{onSubmit:Ut,noValidate:!0,"data-testid":"debales-support-form",children:[Fe(e)?R.jsxs(R.Fragment,{children:[R.jsx(ql,{label:"Name",name:"name",type:"text",value:at.name,onChange:ge=>Ot(we=>({...we,name:ge.target.value})),required:!0,error:Yt.name,isCollectiveBot:!0}),R.jsx(ql,{label:"Email",name:"email",type:"email",value:at.email,onChange:ge=>Ot(we=>({...we,email:ge.target.value})),required:!0,error:Yt.email,isCollectiveBot:!0}),R.jsx(v2,{label:"Message",name:"message",value:at.message,onChange:ge=>Ot(we=>({...we,message:ge.target.value})),required:!0,error:Yt.message,rows:4,isCollectiveBot:!0})]}):R.jsxs(R.Fragment,{children:[R.jsxs(XD,{children:[R.jsxs(JD,{children:["Name",R.jsx("span",{children:"*"})]}),R.jsx(kU,{type:"text",required:!0,value:at.name,onChange:ge=>Ot(we=>({...we,name:ge.target.value})),placeholder:"John"}),Yt.name&&R.jsx("p",{style:{color:"red",fontSize:"12px",margin:"4px 0 0"},children:Yt.name})]}),R.jsxs(XD,{children:[R.jsxs(JD,{children:["Email",R.jsx("span",{children:"*"})]}),R.jsx(kU,{type:"email",required:!0,value:at.email,onChange:ge=>Ot(we=>({...we,email:ge.target.value})),placeholder:"olivia@untitledui.com"}),Yt.email&&R.jsx("p",{style:{color:"red",fontSize:"12px",margin:"4px 0 0"},children:Yt.email})]}),R.jsxs(XD,{children:[R.jsxs(JD,{children:["Message",R.jsx("span",{children:"*"})]}),R.jsx(ade,{required:!0,value:at.message,onChange:ge=>Ot(we=>({...we,message:ge.target.value})),placeholder:"I need help with..."}),Yt.message&&R.jsx("p",{style:{color:"red",fontSize:"12px",margin:"4px 0 0"},children:Yt.message})]})]}),R.jsx(lde,{children:R.jsx(sde,{type:"submit",children:"Submit"})})]}),br&&!p&&l===be.conversationId&&R.jsx(Ci,{isBot:P,children:R.jsx(ms,{loading:br,loadingPhrases:["🎨 Loading","✨ Almost","🚀 Ready"]})})]})]}),!P&&R.jsx(Jfe,{$fontColor:t.userFontColor||"#000",$botMessageColor:t.botBackgroundColor||"#fff",children:R.jsx(Ci,{isBot:!!P,children:R.jsx(od,{children:be.text})})}),h.length==1&&Je==0&&!T&&R.jsx(WD,{children:kt.leadingQueries?R.jsx(Ci,{isBot:!0,children:R.jsx(ms,{loading:kt.leadingQueries})}):te.map((ge,we)=>R.jsxs(CU,{style:{backgroundColor:t.callToActionBackgroundColor,color:t.callToActionFontColor,opacity:Re.has(ge.question)?.5:1},onClick:()=>{E?(k(!0),D({question:ge.question,answer:ge.answer,products:ge.products,path:"/",nameSpace:window.DebalesChat.projectId})):r({message:ge.question,answer:ge.answer,products:ge.products,messType:"leading_query"}),Le(_e=>{const Qe=new Set(_e);return Qe.add(ge.question),Qe}),window.DebalesChat.track(Wt.INITIAL_LEADING_QUERY_SUGGESTED_QUESTION_CLICKED,{question:ge.question})},disabled:p,$disabled:p,children:[ge.question,R.jsx(wU,{color:t.callToActionFontColor})]},we))}),be.leading_queries&&be.leading_queries.length>0&&l===be.conversationId&&Zt.leadingQueries&&!o&&!T&&R.jsx(WD,{children:be.leading_queries.map((ge,we)=>R.jsxs(CU,{style:{backgroundColor:t.callToActionBackgroundColor,color:t.callToActionFontColor},onClick:()=>{E?(k(!0),D({question:ge,path:"/",nameSpace:window.DebalesChat.projectId})):r({message:ge,messType:"leading_query"}),window.DebalesChat.track(Wt.LEADING_QUERY_CLICKED,{query:ge})},disabled:p,$disabled:p,children:[ge,R.jsx(wU,{color:t.callToActionFontColor})]},we))})]},Je)}),(p||_r)&&R.jsxs(SU,{$fontColor:t.botFontColor||"#000",$botMessageColor:t.botBackgroundColor||"#fff",children:[R.jsx("img",{src:t.bot_logo,alt:"Chat User Icon"}),R.jsx(EU,{children:R.jsx(Ci,{isBot:!0,children:R.jsx("div",{style:{display:"flex",alignItems:"center",gap:"4px",animation:"fadeIn 0.3s ease-in-out"},children:R.jsx(ms,{loading:p||_r})})})})]})]}),R.jsx(cde,{$backgroundColor:t.botBackgroundColor||"#fff",style:{opacity:Kn?1:0}})]}),R.jsxs("div",{className:"debales-footer-container",style:{width:"calc(100%-24px)",backgroundColor:t.botBackgroundColor||"#fff",color:t.fontColor||"#000"},children:[(e==="catch-org-ai"||e==="letsgo-catch")&&R.jsx(Xfe,{children:R.jsx("span",{children:`"${t.chatbotName}" can make mistakes.`})}),R.jsx("div",{children:R.jsx(S2,{disabled:p,inputState:!1})}),(t.debales_branding??!0)&&R.jsxs(Kfe,{href:"https://debales.ai/?open=true",target:"_blank",title:"debales-link",style:{color:t.fontColor?t.fontColor:"fff",marginTop:e==="catch-org-ai"?"0":"9px"},children:[R.jsx("p",{children:"Powered by"}),R.jsxs(Wfe,{children:[R.jsx("img",{src:`${wi}/images/debales_logo_d.png`,alt:"Debales logo"}),R.jsx("p",{children:"DEBALES"})]})]})]})]})]})}),z.shadowRoot)]})},hde=({botId:e})=>{const t=QG("new-suggested-question-design");let n;return t==="variant-1"?n=Vce:t==="variant-2"?n=Dfe:t==="variant-3"?n=dde:n=tU,R.jsx(n,{botId:e})};var w2={exports:{}},ax={},C2={exports:{}},tO={};/**
4846
4846
  * @license React
4847
4847
  * scheduler.production.js
4848
4848
  *
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@debales/ai",
3
3
  "private": false,
4
4
  "access": "public",
5
- "version": "1.1.31",
5
+ "version": "1.1.32",
6
6
  "type": "module",
7
7
  "main": "./dist/module/ai.js",
8
8
  "types": "./dist/module/index.d.ts",