@snf/access-qa-bot 3.3.9 → 3.3.10
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.
|
@@ -35,11 +35,11 @@
|
|
|
35
35
|
background-color: #0000001a !important;
|
|
36
36
|
opacity: 1 !important;
|
|
37
37
|
}
|
|
38
|
-
`),h.createElement("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"qa-bot-login-button ".concat(o?"qa-bot-header-login-button":""," ").concat(r),style:Object.assign(Object.assign({},A),n),onClick:()=>{a({type:"chatbot_login_clicked",loginUrl:t})}},"Log In"))},wl=()=>h.createElement("div",{className:"user-login-icon",style:{alignItems:"center",justifyContent:"center",width:"30px",height:"30px",borderRadius:"50%",backgroundColor:"var(--primaryColor, #1a5b6e)",marginRight:"5px",display:"flex"},role:"img","aria-label":"User logged in",title:"User logged in"},h.createElement("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false"},h.createElement("path",{d:"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"}),h.createElement("circle",{cx:"12",cy:"7",r:"4"}))),me=[];for(let e=0;e<256;++e)me.push((e+256).toString(16).slice(1));let sr;const xl=new Uint8Array(16);var Sa={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Da(e,t,r){var o;if(Sa.randomUUID&&!e)return Sa.randomUUID();const n=(e=e||{}).random??((o=e.rng)==null?void 0:o.call(e))??function(){if(!sr){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");sr=crypto.getRandomValues.bind(crypto)}return sr(xl)}();if(n.length<16)throw new Error("Random bytes length must be >= 16");return n[6]=15&n[6]|64,n[8]=63&n[8]|128,function(a,A=0){return(me[a[A+0]]+me[a[A+1]]+me[a[A+2]]+me[a[A+3]]+"-"+me[a[A+4]]+me[a[A+5]]+"-"+me[a[A+6]]+me[a[A+7]]+"-"+me[a[A+8]]+me[a[A+9]]+"-"+me[a[A+10]]+me[a[A+11]]+me[a[A+12]]+me[a[A+13]]+me[a[A+14]]+me[a[A+15]]).toLowerCase()}(n)}function an(){return typeof localStorage<"u"&&localStorage.getItem("QA_BOT_DEBUG")==="true"}const El="background: #1a5b6e; color: white; padding: 2px 6px; border-radius: 3px;",kl="background: #7c3aed; color: white; padding: 2px 6px; border-radius: 3px;",Cl="background: #059669; color: white; padding: 2px 6px; border-radius: 3px;",Pl="background: #f59e0b; color: #000; padding: 2px 6px; border-radius: 3px 0 0 3px; font-weight: bold;",Sl="background: #fbbf24; color: #000; padding: 2px 6px; border-radius: 0 3px 3px 0;",Dl=()=>{an()&&console.log("%c QA Bot Core %c v".concat("0.2.19"," "),Pl,Sl)},sn=function(e){if(an()){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];console.log("%c[Session]%c ".concat(e),El,"",...r)}},Ge=function(e){if(an()){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];console.log("%c[History]%c ".concat(e),kl,"",...r)}},Bl=(e,t)=>{an()&&console.log("%c[Message]%c ".concat(e),Cl,"",t)},Il=function(){console.warn(...arguments)},lt=function(){console.error(...arguments)},Ba="qa_bot_session_messages",Ia=()=>"qa_bot_session_".concat(Da()),Ot=()=>{try{const e=localStorage.getItem(Ba);return e?JSON.parse(e):{}}catch{return{}}},Tl=(e,t,r,n,o)=>{const a=Ot();if(!a[e]&&(a[e]={messages:[],startedAt:new Date().toISOString(),preview:""},Ge("NEW session created",{sessionId:e.slice(-12)})),a[e].messages.some(c=>c.id===t))return void Ge("DUPLICATE message skipped",{sessionId:e.slice(-12),messageId:t.slice(-8),sender:n});const A={id:t,content:r,sender:n,type:o,timestamp:Date.now()};a[e].messages.push(A),Ge("MESSAGE added",{sessionId:e.slice(-12),messageId:t.slice(-8),sender:n,totalInSession:a[e].messages.length});const s=a[e].messages,i=s.find(c=>{var l;return c.sender.toLowerCase()==="bot"&&((l=c.content)===null||l===void 0?void 0:l.trim())&&c.content.length>=100});if(i){const c=i.content;a[e].preview=c.slice(0,50)+(c.length>50?"...":"")}else{const c=s.find(l=>{var d;return l.sender.toLowerCase()==="user"&&((d=l.content)===null||d===void 0?void 0:d.trim())});if(c&&!a[e].preview){const l=c.content;a[e].preview=l.slice(0,50)+(l.length>50?"...":"")}}(c=>{var l;const d=()=>Object.values(c).reduce((u,p)=>u+p.messages.length,0);for(;d()>100&&Object.keys(c).length>1;){const u=(l=Object.entries(c).sort((p,f)=>{let[,y]=p,[,g]=f;return new Date(y.startedAt).getTime()-new Date(g.startedAt).getTime()})[0])===null||l===void 0?void 0:l[0];if(!u)break;delete c[u]}localStorage.setItem(Ba,JSON.stringify(c))})(a),Ge("STORAGE state",{ourSessions:Object.keys(a).length,ourTotalMessages:Object.values(a).reduce((c,l)=>c+l.messages.length,0)})},Ta=e=>{var t,r;return(r=(t=Ot()[e])===null||t===void 0?void 0:t.messages.length)!==null&&r!==void 0?r:0},Ql=e=>{const t=Ot()[e];return t!=null&&t.startedAt?Date.now()-new Date(t.startedAt).getTime():0},Qa=h.createContext(void 0),Ml=e=>{let{children:t,getSessionId:r,setSessionId:n,resetSession:o,clearResettingFlag:a}=e;return h.createElement(Qa.Provider,{value:{getSessionId:r,setSessionId:n,resetSession:o,clearResettingFlag:a}},t)},Ar=()=>{const e=h.useContext(Qa);if(!e)throw new Error("useSession must be used within a SessionProvider");return e},Ol=()=>{const[e,t]=h.useState(!1),[r,n]=h.useState([]),[o,a]=h.useState(null),[A,s]=h.useState(0),i=h.useRef(null),c=h.useRef(null),{replaceMessages:l}=Pt(),{toggleTextAreaDisabled:d}=Zr(),{setSessionId:u,getSessionId:p}=Ar();h.useEffect(()=>{var y,g;const v=m=>{i.current&&!i.current.contains(m.target)&&c.current&&!c.current.contains(m.target)&&t(!1)},x=(g=(y=i.current)===null||y===void 0?void 0:y.getRootNode())!==null&&g!==void 0?g:document;return e&&x.addEventListener("mousedown",v),()=>{x.removeEventListener("mousedown",v)}},[e]);const f=y=>{var g;const v=p();if(Ge("RESTORE requested",{targetSession:y.slice(-12),currentSession:v==null?void 0:v.slice(-12)}),y===v)return Ge("RESTORE skipped - already on this session"),void t(!1);const x=(P=>{var C;return((C=Ot()[P])===null||C===void 0?void 0:C.messages)||[]})(y).filter(P=>{var C;return(C=P.content)===null||C===void 0?void 0:C.trim()});Ge("Stored messages from our localStorage",{count:x.length,ids:x.map(P=>P.id.slice(-8))});const m=x.map(P=>({id:P.id,content:P.content,sender:P.sender.toUpperCase(),type:P.type||"string",timestamp:new Date(P.timestamp).toISOString()}));var E;u(y),Ge("Session ID updated",{newSession:y.slice(-12)}),l(m),Ge("replaceMessages called",{count:m.length}),E=(g=c.current)===null||g===void 0?void 0:g.getRootNode(),setTimeout(()=>{const P=(E||document).querySelector(".rcb-chat-body-container");P&&P.querySelectorAll(".rcb-bot-message").forEach(C=>{var S;let I=C.innerHTML,Q=!1;I.includes("](")&&(I=I.replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>'),Q=!0),I.includes("<a href=")&&(I=I.replace(/<a\s+href=["']([^"']+)["'][^&]*>([^&]+)<\/a>/gi,'<a href="$1" target="_blank" rel="noopener noreferrer">$2</a>'),Q=!0),(I.includes("<a ")||!((S=C.textContent)===null||S===void 0)&&S.includes("<a href="))&&(C.textContent||"").includes("<a href=")&&(I=I.replace(/<a\s+href="([^"]+)"[^&]*>([^&]+)<\/a>/gi,'<a href="$1" target="_blank" rel="noopener noreferrer">$2</a>'),Q=!0),Q&&(C.innerHTML=I)})},50),d(!1),Ge("Chat input enabled after restore"),t(!1)};return h.createElement("div",{style:{position:"relative"}},h.createElement("button",{ref:c,className:"history-button",onClick:()=>{if(!e&&(n((()=>{const y=Ot();return Object.entries(y).map(g=>{let[v,x]=g;return Object.assign({sessionId:v},x)}).sort((g,v)=>new Date(v.startedAt).getTime()-new Date(g.startedAt).getTime())})()),c.current)){const y=c.current.closest(".rcb-chat-window");if(y){const g=y.getBoundingClientRect(),v=c.current.getBoundingClientRect();a(g.width+3),s(g.right-v.right-18+4)}}t(!e)},style:{alignItems:"center",justifyContent:"center",width:"30px",height:"30px",borderRadius:"50%",backgroundColor:"var(--primaryColor, #1a5b6e)",marginRight:"18px",display:"flex",border:"none",cursor:"pointer",padding:0},"aria-label":"View chat history",title:"View chat history","aria-expanded":e,"aria-haspopup":"menu"},h.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false"},h.createElement("circle",{cx:"12",cy:"12",r:"10"}),h.createElement("polyline",{points:"12 6 12 12 16 14"}))),e&&h.createElement("div",{ref:i,role:"menu",style:{position:"absolute",right:A?"-".concat(A,"px"):"-18px",top:"100%",marginTop:"8px",width:o?"".concat(o,"px"):"550px",backgroundColor:"white",borderRadius:0,borderBottom:"3px solid var(--primaryColor, #1a5b6e)",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.1)",maxHeight:"250px",overflowY:"auto",zIndex:1e3}},r.length===0?h.createElement("div",{style:{padding:"12px 16px",color:"#666",fontSize:"14px",textAlign:"center"}},"No chat history"):r.map(y=>h.createElement("button",{key:y.sessionId,role:"menuitem",onClick:()=>f(y.sessionId),style:{width:"100%",padding:"10px 14px",border:"none",backgroundColor:"transparent",cursor:"pointer",textAlign:"left",display:"flex",flexDirection:"column",gap:"2px",borderBottom:"1px solid #eee"},onMouseEnter:g=>{g.currentTarget.style.backgroundColor="#f5f5f5"},onMouseLeave:g=>{g.currentTarget.style.backgroundColor="transparent"}},h.createElement("span",{style:{fontSize:"14px",color:"#333",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},y.preview||"New conversation"),h.createElement("span",{style:{fontSize:"12px",color:"#888"}},(g=>{const v=new Date(g),x=new Date().getTime()-v.getTime(),m=Math.floor(x/864e5);return m===0?v.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):m===1?"Yesterday":m<7?v.toLocaleDateString([],{weekday:"short"}):v.toLocaleDateString([],{month:"short",day:"numeric"})})(y.startedAt))))))};function lr(){return lr=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},lr.apply(null,arguments)}const Ma=({width:e=24,height:t=24,color:r="currentColor",children:n,...o})=>h.createElement("svg",lr({xmlns:"http://www.w3.org/2000/svg",width:e,height:t,viewBox:"0 0 24 24",fill:"none",stroke:r,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false"},o),n),_l=e=>h.createElement(Ma,e,h.createElement("path",{d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})),Ll=()=>{const{restartFlow:e}=Vt(),{setTextAreaValue:t}=Zr(),{messages:r}=Pt(),{getSessionId:n,resetSession:o,clearResettingFlag:a}=Ar(),{trackEvent:A}=Ca();return h.createElement("button",{onClick:async()=>{const s=n(),i=s?Ta(s):0;A({type:"chatbot_new_chat",previousMessageCount:i}),o(),await t(""),await e(),setTimeout(()=>{a()},100)},tabIndex:0,"aria-label":"New chat conversation",style:{backgroundColor:"var(--primaryColor, #107180)",border:"none",color:"#ffffff",fontSize:"14px",cursor:"pointer",padding:"8px 12px",borderRadius:"4px",transition:"all 0.2s ease",display:"flex",alignItems:"center",gap:"6px",fontWeight:"500"},onMouseEnter:s=>{s.target.style.backgroundColor="var(--secondaryColor, #0d5f6b)"},onMouseLeave:s=>{s.target.style.backgroundColor="var(--primaryColor, #107180)"}},h.createElement(_l,{width:16,height:16}),"New Chat")};function cr(e){if(typeof e=="string")return e;if(typeof e=="number")return String(e);if(!e)return"";if(Array.isArray(e))return e.map(cr).join("");if(typeof e=="object"&&e!==null&&"props"in e){const t=e.props;if(t&&"children"in t)return cr(t.children)}return""}const Nl=()=>{const{getSessionId:e}=Ar(),t=h.useCallback(r=>{var n;const o=(n=r.data)===null||n===void 0?void 0:n.message;if(!(o!=null&&o.id))return;const a=o.sender,A=o.type||"string";let s;if(s=typeof o.content=="string"?o.content:cr(o.content),Bl("TRACKED",{id:o.id,sender:a,content:s.substring(0,50)+(s.length>50?"...":"")}),s.includes("rcb-options-container")||!s.trim())return;const i=e();Tl(i,o.id,s,a,A)},[e]);return h.useEffect(()=>(window.addEventListener("rcb-pre-inject-message",t),()=>{window.removeEventListener("rcb-pre-inject-message",t)}),[t]),null},Hl=()=>(h.useEffect(()=>{const e=A=>{if(!["ArrowDown","ArrowUp","ArrowLeft","ArrowRight","Enter"," ","Home","End"].includes(A.key))return;const s=document.activeElement;if(s&&(s.tagName==="INPUT"||s.tagName==="TEXTAREA"||s.contentEditable==="true"||s.classList.contains("rcb-chat-input-textarea")))return;const i=document.querySelector(".rcb-chat-window");if(!i)return;const c=Array.from(i.querySelectorAll(".rcb-message-container, .rcb-bot-message-container, .rcb-user-message-container")).filter(u=>u.offsetParent!==null);if(c.length>0){const u=c[c.length-1].querySelector(".rcb-checkbox-container");if(u&&u.offsetParent!==null){const p=Array.from(u.querySelectorAll(".rcb-checkbox-row-container")),f=u.querySelector(".rcb-checkbox-next-button");if(p.length>0){const y=[...p];return f&&y.push(f),void((g,v)=>{g.preventDefault();let x=-1;for(let E=0;E<v.length;E++)if(v[E]===document.activeElement||v[E].contains(document.activeElement)){x=E;break}x===-1&&(x=0);let m=x;switch(g.key){case"ArrowDown":case"ArrowRight":m=x<v.length-1?x+1:0;break;case"ArrowUp":case"ArrowLeft":m=x>0?x-1:v.length-1;break;case"Home":m=0;break;case"End":m=v.length-1;break;case"Enter":case" ":{const E=v[x],P=new MouseEvent("mousedown",{bubbles:!0,cancelable:!0,view:window});return void E.dispatchEvent(P)}default:return}v[m].focus(),v[m].setAttribute("tabindex","0"),v[m].classList.add("keyboard-focused"),v.forEach((E,P)=>{P!==m&&(E.setAttribute("tabindex","-1"),E.classList.remove("keyboard-focused"))})})(A,y)}}}let l=[];if(c.length>0){const u=c[c.length-1],p=Array.from(u.querySelectorAll(".rcb-options-container")).filter(f=>f.offsetParent!==null);if(p.length>0){const f=p[p.length-1];l=Array.from(f.querySelectorAll(".rcb-options"))}}if(l.length===0)return;const d=l.findIndex(u=>u===document.activeElement);switch(A.key){case"ArrowDown":case"ArrowRight":{let u;A.preventDefault(),u=d<l.length-1?d+1:0,l[u].setAttribute("tabindex","0"),l.forEach((p,f)=>{f!==u&&(p.setAttribute("tabindex","-1"),p.classList.remove("keyboard-focused"))}),l[u].classList.add("keyboard-focused"),l[u].focus();break}case"ArrowUp":case"ArrowLeft":{let u;A.preventDefault(),u=d>0?d-1:l.length-1,l[u].setAttribute("tabindex","0"),l.forEach((p,f)=>{f!==u&&(p.setAttribute("tabindex","-1"),p.classList.remove("keyboard-focused"))}),l[u].classList.add("keyboard-focused"),l[u].focus();break}case"Enter":case" ":if(A.preventDefault(),document.activeElement&&l.includes(document.activeElement)){const u=document.activeElement;if(u.classList.contains("rcb-checkbox-row-container")||u.closest(".rcb-checkbox-row-container")){const p=new MouseEvent("mousedown",{bubbles:!0,cancelable:!0,view:window});u.dispatchEvent(p);const f=u.querySelector(".rcb-checkbox-label"),y=f?f.textContent:u.textContent||"checkbox",g=u.querySelector(".rcb-checkbox-mark"),v=g&&g.style.backgroundColor?"checked":"unchecked";t("".concat(y," ").concat(v))}else{const p=new MouseEvent("mousedown",{bubbles:!0,cancelable:!0,view:window});u.dispatchEvent(p);const f=u.textContent||u.innerText;t("Selected: ".concat(f))}}break;case"Home":A.preventDefault(),l.length>0&&(l[0].setAttribute("tabindex","0"),l.forEach((u,p)=>{p!==0&&(u.setAttribute("tabindex","-1"),u.classList.remove("keyboard-focused"))}),l[0].classList.add("keyboard-focused"),l[0].focus());break;case"End":if(A.preventDefault(),l.length>0){const u=l.length-1;l[u].setAttribute("tabindex","0"),l.forEach((p,f)=>{f!==u&&(p.setAttribute("tabindex","-1"),p.classList.remove("keyboard-focused"))}),l[u].classList.add("keyboard-focused"),l[u].focus()}}},t=A=>{const s=document.createElement("div");s.setAttribute("aria-live","assertive"),s.setAttribute("aria-atomic","true"),s.className="sr-only",s.textContent=A,document.body.appendChild(s),setTimeout(()=>{document.body.contains(s)&&document.body.removeChild(s)},1e3)},r=function(){let A=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null;if(A||(A=document.querySelector(".rcb-chat-window"),A||(A=document.querySelector('[class*="rcb-chat"]')),A||(A=document.querySelector(".qa-bot"))),!A)return;const s=A.closest(".embedded-qa-bot")!==null,i=Array.from(A.querySelectorAll(".rcb-message-container, .rcb-bot-message-container, .rcb-user-message-container")).filter(u=>u.offsetParent!==null);if(i.length===0)return;const c=i[i.length-1],l=Array.from(c.querySelectorAll(".rcb-options-container")).filter(u=>u.offsetParent!==null);let d=[];if(l.length>0){const u=l[l.length-1];d=Array.from(u.querySelectorAll(".rcb-options"))}if(d.length===0){let u=c.querySelector(".rcb-checkbox-container");if(!u&&A&&(u=A.querySelector(".rcb-checkbox-container")),u&&u.offsetParent!==null){const p=Array.from(u.querySelectorAll(".rcb-checkbox-row-container")).filter(f=>f.offsetParent!==null&&f.style.display!=="none");if(p.length>0){const f=u.querySelector(".rcb-checkbox-next-button"),y=[...p];if(f&&f.offsetParent!==null&&y.push(f),y.forEach((g,v)=>{g.setAttribute("tabindex",v===0?"0":"-1"),v===0?g.classList.add("keyboard-focused"):g.classList.remove("keyboard-focused")}),p.length>1){u.querySelectorAll(".keyboard-nav-hint").forEach(v=>v.remove());const g=document.createElement("div");g.className="keyboard-nav-hint",g.textContent="Use arrow keys ↕ to navigate, Enter to select/deselect, or click any option",g.style.cssText="font-size: 12px !important; color: #666 !important; margin-bottom: 8px !important; font-style: italic !important; display: block !important;",u.insertBefore(g,u.firstChild)}return void setTimeout(()=>{y[0]&&y[0].offsetParent!==null&&!s&&y[0].focus()},150)}}}if(d.length>0){if(d.forEach((u,p)=>{const f=p===0?"0":"-1";u.setAttribute("tabindex",f),u.setAttribute("role","option"),u.setAttribute("aria-posinset",p+1),u.setAttribute("aria-setsize",d.length),p===0?u.classList.add("keyboard-focused"):u.classList.remove("keyboard-focused")}),d.length>1){const u=l.length>0?l[l.length-1]:null;if(u){u.querySelectorAll(".keyboard-nav-hint").forEach(f=>f.remove());const p=document.createElement("div");p.className="keyboard-nav-hint",p.textContent="Use arrow keys ↕ to navigate, Enter to select, or click any option",p.style.cssText="font-size: 12px !important; color: #666 !important; margin-bottom: 8px !important; font-style: italic !important; display: block !important;",u.insertBefore(p,u.firstChild)}}else{const u=l.length>0?l[l.length-1]:null;u&&u.querySelectorAll(".keyboard-nav-hint").forEach(p=>p.remove())}setTimeout(()=>{d[0]&&d[0].offsetParent!==null&&!s&&(d[0].focus(),d.length>1&&t("".concat(d.length," options available. Use arrow keys to navigate.")))},200)}},n=A=>{const s=A.querySelectorAll(".rcb-options");s.forEach((i,c)=>{i.hasAttribute("role")||(i.setAttribute("role","button"),i.setAttribute("tabindex",c===0?"0":"-1"),i.setAttribute("aria-posinset",c+1),i.setAttribute("aria-setsize",s.length))}),A.querySelectorAll(".rcb-checkbox-row-container").forEach((i,c)=>{i.hasAttribute("role")||(i.setAttribute("role","checkbox"),i.setAttribute("tabindex",c===0?"0":"-1"))})},o=new MutationObserver(A=>{A.forEach(s=>{if(s.type==="childList"){const l=Array.from(s.addedNodes),d=l.some(p=>{var f,y,g,v;return p.nodeType===Node.ELEMENT_NODE&&(((f=p.classList)===null||f===void 0?void 0:f.contains("rcb-options-container"))||((y=p.classList)===null||y===void 0?void 0:y.contains("rcb-options"))||((g=p.querySelector)===null||g===void 0?void 0:g.call(p,".rcb-options-container"))||((v=p.querySelector)===null||v===void 0?void 0:v.call(p,".rcb-options")))}),u=l.some(p=>{var f,y;return p.nodeType===Node.ELEMENT_NODE&&(((f=p.classList)===null||f===void 0?void 0:f.contains("rcb-checkbox-container"))||((y=p.querySelector)===null||y===void 0?void 0:y.call(p,".rcb-checkbox-container")))});if(d||u){let p=s.target;for(;p&&((i=p.classList)===null||i===void 0||!i.contains("qa-bot"))&&((c=p.classList)===null||c===void 0||!c.contains("rcb-chat-window"));){var i,c;p=p.parentElement}const f=p||document;n(f),f.querySelectorAll(".rcb-options[tabindex], .rcb-checkbox-row-container[tabindex], .rcb-checkbox-next-button[tabindex]").forEach(y=>{y.setAttribute("tabindex","-1"),y.classList.remove("keyboard-focused")}),setTimeout(()=>r(p),100)}}})});o.observe(document.body,{childList:!0,subtree:!0}),document.addEventListener("keydown",e),n(document),r();const a=setInterval(()=>{document.querySelectorAll(".qa-bot").forEach(A=>{const s=A.querySelectorAll(".rcb-options-container .rcb-options").length>0,i=A.querySelectorAll(".rcb-checkbox-row-container").length>0;if(s){n(A);const c=A.querySelectorAll(".rcb-options[tabindex]").length;A.querySelectorAll(".rcb-options").length>c&&r(A)}if(i){n(A);const c=A.querySelectorAll(".rcb-checkbox-row-container[tabindex]").length;A.querySelectorAll(".rcb-checkbox-row-container").length>c&&r(A)}})},1e3);return()=>{document.removeEventListener("keydown",e),o.disconnect(),clearInterval(a)}},[]),null),Ul="#1a5b6e",Fl="#107180",zl="Arial, sans-serif",Oa="Q&A Bot",Rl="/chat-icon.svg",jl="Type your question here...",ql="Select an option to continue",Gl=!1,Yl="Ask me a question!",_a="/login",Wl={general:{showHeader:!0,showFooter:!0},tooltip:{mode:"CLOSE"},chatInput:{disabled:!1,characterLimit:1e3,showCharacterCount:!1,allowNewline:!0,blockSpam:!1},chatWindow:{defaultOpen:!1,showScrollbar:!1},botBubble:{simulateStream:!0,streamSpeed:10,showAvatar:!1},userBubble:{showAvatar:!1},notification:{disabled:!0,showCount:!1},audio:{disabled:!0},emoji:{disabled:!0},fileAttachment:{disabled:!0}},ur=h.forwardRef((e,t)=>{var r,n;const{apiKey:o,qaEndpoint:a,ratingEndpoint:A,welcomeMessage:s,open:i,onOpenChange:c,isLoggedIn:l,allowAnonAccess:d=!1,actingUser:u,primaryColor:p,secondaryColor:f,botName:y,logo:g,placeholder:v,errorMessage:x,embedded:m,footerText:E,footerLink:P,tooltipText:C,loginUrl:S,customFlow:I,onAnalyticsEvent:Q}=e,B=h.useRef("bot_".concat(Math.random().toString(36).substr(2,9)));h.useEffect(()=>{Dl()},[]);const O=h.useRef(null);O.current===null&&(O.current=Ia(),sn("CREATED",O.current));const D=h.useRef(!1),M=h.useRef({getSessionId:()=>O.current,isResetting:()=>D.current}),[U,L]=h.useState(l);h.useEffect(()=>{L(l)},[l]);const F=m!==void 0?m:Gl,_=h.useCallback(R=>{var z;Q&&Q(Object.assign(Object.assign({},R),{timestamp:Date.now(),sessionId:(z=O.current)!==null&&z!==void 0?z:void 0,pageUrl:typeof window<"u"?window.location.href:void 0,isEmbedded:F}))},[Q,F]),H=h.useMemo(()=>{const R=Object.assign({},Wl);R.general=Object.assign(Object.assign({},R.general),{primaryColor:p||Ul,secondaryColor:f||Fl,fontFamily:zl,embedded:F});const z=U===!1?[h.createElement(Pa,{key:"login-button",loginUrl:S||_a,isHeaderButton:!0})]:[h.createElement(Ol,{key:"history-button"}),h.createElement(wl,{key:"user-icon"})];R.header={title:h.createElement("span",{style:{fontSize:14,fontWeight:500}},y||Oa),showAvatar:!0,avatar:g||Rl,buttons:[...z,ue.CLOSE_CHAT_BUTTON]},R.chatInput=Object.assign(Object.assign({},R.chatInput),{disabled:!1,enabledPlaceholderText:v||jl,disabledPlaceholderText:x||ql}),R.tooltip=Object.assign(Object.assign({},R.tooltip),{text:C||Yl});const q=E?P?h.createElement("a",{href:P,target:"_blank",rel:"noopener noreferrer",key:"footer-link"},E):h.createElement("span",{key:"footer-text"},E):null;return R.footer={text:q,buttons:[h.createElement(Ll,{key:"new-chat-button"})]},R.chatWindow=Object.assign(Object.assign({},R.chatWindow),{defaultOpen:!!F}),R.event={rcbPreInjectMessage:!0,rcbPostInjectMessage:!0,rcbUserSubmitText:!0,rcbChangePath:!0,rcbToggleChatWindow:!0},R},[p,f,y,g,v,x,F,C,U,S,E,P]),b=h.useRef(null),X=function(R){let z=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return h.useMemo(()=>{const q=(Z,J)=>{if(R.current){const ae=getComputedStyle(R.current).getPropertyValue(Z);if(ae&&ae.trim()!=="")return ae.trim();if(R.current.parentElement){const re=getComputedStyle(R.current.parentElement).getPropertyValue(Z);if(re&&re.trim()!=="")return re.trim()}}return J};return{primaryColor:q("--primaryColor",z.primaryColor),secondaryColor:q("--secondaryColor",z.secondaryColor),fontFamily:q("--fontFamily",z.fontFamily)}},[R,z])}(b,H.general);((R,z)=>{h.useEffect(()=>{z.current&&(R?z.current.classList.add("bot-logged-in"):z.current.classList.remove("bot-logged-in"))},[R,z])})(U!==!1,b),(R=>{let{settings:z,themeColors:q}=R;h.useEffect(()=>{q&&(Object.entries(q).forEach(Z=>{let[J,ae]=Z;ae&&document.documentElement.style.setProperty("--".concat(J),ae)}),q.primaryColor&&document.documentElement.style.setProperty("--rcb-header-background",q.primaryColor),q.secondaryColor&&document.documentElement.style.setProperty("--rcb-header-background-hover",q.secondaryColor))},[q]),h.useEffect(()=>{var Z,J;!((Z=z.header)===null||Z===void 0)&&Z.title&&typeof z.header.title=="string"&&(z.header.title=h.createElement("div",{key:"header-title"},h.createElement("h1",{className:"sr-only"},z.header.title),h.createElement("span",{"aria-hidden":"true"},z.header.title))),z.device={desktopEnabled:!0,mobileEnabled:!0,applyMobileOptimizations:!1},z.chatHistory={disabled:!0},z.chatButton=Object.assign(Object.assign({},z.chatButton),{icon:(J=z.header)===null||J===void 0?void 0:J.avatar}),z.event=Object.assign(Object.assign({},z.event),{rcbToggleChatWindow:!0})},[z])})({settings:H,themeColors:X});const w=h.useMemo(()=>{const R=(q=>{let{endpoint:Z,ratingEndpoint:J,apiKey:ae,sessionId:re,isResetting:le=()=>!1,isLoggedIn:we,allowAnonAccess:Ye=!1,loginUrl:ut="/login",trackEvent:xe}=q;if(we===!1&&!Ye)return xe==null||xe({type:"chatbot_login_prompt_shown"}),{qa_loop:{message:"To ask questions, please log in first.",component:h.createElement(Pa,{loginUrl:ut}),chatDisabled:!0,path:"qa_loop"}};let Ne=null,xt=!1;if(!Z)throw new Error("Q&A endpoint is required");return{qa_loop:{message:async ot=>{const{userInput:We}=ot;if(le&&le()||!We||We.trim()==="")return null;if(We==="👍 Helpful"||We==="👎 Not helpful"){if(J&&Ne)try{const ge=We==="👍 Helpful",_e={"Content-Type":"application/json"};ae&&(_e["X-API-KEY"]=ae);const Ve=re();Ve&&(_e["X-Session-ID"]=Ve,_e["X-Query-ID"]=Ne),await fetch(J,{method:"POST",headers:_e,credentials:"include",body:JSON.stringify({sessionId:Ve,queryId:Ne,rating:ge?1:0})}),xe==null||xe({type:"chatbot_rating_sent",queryId:Ne,rating:ge?"helpful":"not_helpful"})}catch(ge){lt("Error sending feedback:",ge)}return"Thanks for the feedback! Feel free to ask another question."}try{const ge=Da();Ne=ge,xe==null||xe({type:"chatbot_question_sent",queryId:ge,questionLength:We.length});const _e={"Content-Type":"application/json"};ae&&(_e["X-API-KEY"]=ae);const Ve=re();Ve&&(_e["X-Session-ID"]=Ve,_e["X-Query-ID"]=ge);const dn={query:We,session_id:Ve,question_id:ge};sn("SENT to API",{session_id:Ve,question_id:ge});const pn=Date.now(),Nt=await fetch(Z,{method:"POST",headers:_e,credentials:"include",body:JSON.stringify(dn)}),yr=Date.now()-pn;if(!Nt.ok)throw new Error("API returned ".concat(Nt.status));const dt=await Nt.json(),Ht=dt.response||dt.answer||dt.text||dt.message;if(!Ht)throw new Error("Invalid response format from API");const fn=(Y=>{if(!Y||typeof Y!="string")return Y;let te=Y.replace(/\[(https?:\/\/[^\s]+?)\]/gi,"[$1]($1)");return te=te.replace(new RegExp(`(?<!\\]\\(|href=["']|\\[)https?:\\/\\/[^\\s[\\]()]+`,"gi"),ne=>{let de=ne,Ce="";const He=de.match(/([.,;:!?]+)$/);return He&&(Ce=He[1],de=de.slice(0,-Ce.length)),"[".concat(de,"](").concat(de,")").concat(Ce)}),te})(Ht),T=function(Y){const{confidence:te,tools_used:ne,metadata:de}=Y;if(!(te||ne&&ne.length!==0))return"";const Ce=[];return te&&Ce.push("• Confidence: ".concat(te)),ne&&ne.length>0&&Ce.push("• Tools used: ".concat(ne.join(", "))),de!=null&&de.agent&&Ce.push("• Agent: ".concat(de.agent)),`---
|
|
38
|
+
`),h.createElement("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"qa-bot-login-button ".concat(o?"qa-bot-header-login-button":""," ").concat(r),style:Object.assign(Object.assign({},A),n),onClick:()=>{a({type:"chatbot_login_clicked",loginUrl:t})}},"Log In"))},wl=()=>h.createElement("div",{className:"user-login-icon",style:{alignItems:"center",justifyContent:"center",width:"30px",height:"30px",borderRadius:"50%",backgroundColor:"var(--primaryColor, #1a5b6e)",marginRight:"5px",display:"flex"},role:"img","aria-label":"User logged in",title:"User logged in"},h.createElement("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false"},h.createElement("path",{d:"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"}),h.createElement("circle",{cx:"12",cy:"7",r:"4"}))),me=[];for(let e=0;e<256;++e)me.push((e+256).toString(16).slice(1));let sr;const xl=new Uint8Array(16);var Sa={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Da(e,t,r){var o;if(Sa.randomUUID&&!e)return Sa.randomUUID();const n=(e=e||{}).random??((o=e.rng)==null?void 0:o.call(e))??function(){if(!sr){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");sr=crypto.getRandomValues.bind(crypto)}return sr(xl)}();if(n.length<16)throw new Error("Random bytes length must be >= 16");return n[6]=15&n[6]|64,n[8]=63&n[8]|128,function(a,A=0){return(me[a[A+0]]+me[a[A+1]]+me[a[A+2]]+me[a[A+3]]+"-"+me[a[A+4]]+me[a[A+5]]+"-"+me[a[A+6]]+me[a[A+7]]+"-"+me[a[A+8]]+me[a[A+9]]+"-"+me[a[A+10]]+me[a[A+11]]+me[a[A+12]]+me[a[A+13]]+me[a[A+14]]+me[a[A+15]]).toLowerCase()}(n)}function an(){return typeof localStorage<"u"&&localStorage.getItem("QA_BOT_DEBUG")==="true"}const El="background: #1a5b6e; color: white; padding: 2px 6px; border-radius: 3px;",kl="background: #7c3aed; color: white; padding: 2px 6px; border-radius: 3px;",Cl="background: #059669; color: white; padding: 2px 6px; border-radius: 3px;",Pl="background: #f59e0b; color: #000; padding: 2px 6px; border-radius: 3px 0 0 3px; font-weight: bold;",Sl="background: #fbbf24; color: #000; padding: 2px 6px; border-radius: 0 3px 3px 0;",Dl=()=>{an()&&console.log("%c QA Bot Core %c v".concat("0.2.19"," "),Pl,Sl)},sn=function(e){if(an()){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];console.log("%c[Session]%c ".concat(e),El,"",...r)}},Ge=function(e){if(an()){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];console.log("%c[History]%c ".concat(e),kl,"",...r)}},Bl=(e,t)=>{an()&&console.log("%c[Message]%c ".concat(e),Cl,"",t)},Il=function(){console.warn(...arguments)},lt=function(){console.error(...arguments)},Ba="qa_bot_session_messages",Ia=()=>"qa_bot_session_".concat(Da()),Ot=()=>{try{const e=localStorage.getItem(Ba);return e?JSON.parse(e):{}}catch{return{}}},Tl=(e,t,r,n,o)=>{const a=Ot();if(!a[e]&&(a[e]={messages:[],startedAt:new Date().toISOString(),preview:""},Ge("NEW session created",{sessionId:e.slice(-12)})),a[e].messages.some(c=>c.id===t))return void Ge("DUPLICATE message skipped",{sessionId:e.slice(-12),messageId:t.slice(-8),sender:n});const A={id:t,content:r,sender:n,type:o,timestamp:Date.now()};a[e].messages.push(A),Ge("MESSAGE added",{sessionId:e.slice(-12),messageId:t.slice(-8),sender:n,totalInSession:a[e].messages.length});const s=a[e].messages,i=s.find(c=>{var l;return c.sender.toLowerCase()==="bot"&&((l=c.content)===null||l===void 0?void 0:l.trim())&&c.content.length>=100});if(i){const c=i.content;a[e].preview=c.slice(0,50)+(c.length>50?"...":"")}else{const c=s.find(l=>{var d;return l.sender.toLowerCase()==="user"&&((d=l.content)===null||d===void 0?void 0:d.trim())});if(c&&!a[e].preview){const l=c.content;a[e].preview=l.slice(0,50)+(l.length>50?"...":"")}}(c=>{var l;const d=()=>Object.values(c).reduce((u,p)=>u+p.messages.length,0);for(;d()>100&&Object.keys(c).length>1;){const u=(l=Object.entries(c).sort((p,f)=>{let[,y]=p,[,g]=f;return new Date(y.startedAt).getTime()-new Date(g.startedAt).getTime()})[0])===null||l===void 0?void 0:l[0];if(!u)break;delete c[u]}localStorage.setItem(Ba,JSON.stringify(c))})(a),Ge("STORAGE state",{ourSessions:Object.keys(a).length,ourTotalMessages:Object.values(a).reduce((c,l)=>c+l.messages.length,0)})},Ta=e=>{var t,r;return(r=(t=Ot()[e])===null||t===void 0?void 0:t.messages.length)!==null&&r!==void 0?r:0},Ql=e=>{const t=Ot()[e];return t!=null&&t.startedAt?Date.now()-new Date(t.startedAt).getTime():0},Qa=h.createContext(void 0),Ml=e=>{let{children:t,getSessionId:r,setSessionId:n,resetSession:o,clearResettingFlag:a}=e;return h.createElement(Qa.Provider,{value:{getSessionId:r,setSessionId:n,resetSession:o,clearResettingFlag:a}},t)},Ar=()=>{const e=h.useContext(Qa);if(!e)throw new Error("useSession must be used within a SessionProvider");return e},Ol=()=>{const[e,t]=h.useState(!1),[r,n]=h.useState([]),[o,a]=h.useState(null),[A,s]=h.useState(0),i=h.useRef(null),c=h.useRef(null),{replaceMessages:l}=Pt(),{toggleTextAreaDisabled:d}=Zr(),{setSessionId:u,getSessionId:p}=Ar();h.useEffect(()=>{var y,g;const v=m=>{i.current&&!i.current.contains(m.target)&&c.current&&!c.current.contains(m.target)&&t(!1)},x=(g=(y=i.current)===null||y===void 0?void 0:y.getRootNode())!==null&&g!==void 0?g:document;return e&&x.addEventListener("mousedown",v),()=>{x.removeEventListener("mousedown",v)}},[e]);const f=y=>{var g;const v=p();if(Ge("RESTORE requested",{targetSession:y.slice(-12),currentSession:v==null?void 0:v.slice(-12)}),y===v)return Ge("RESTORE skipped - already on this session"),void t(!1);const x=(P=>{var C;return((C=Ot()[P])===null||C===void 0?void 0:C.messages)||[]})(y).filter(P=>{var C;return(C=P.content)===null||C===void 0?void 0:C.trim()});Ge("Stored messages from our localStorage",{count:x.length,ids:x.map(P=>P.id.slice(-8))});const m=x.map(P=>({id:P.id,content:P.content,sender:P.sender.toUpperCase(),type:P.type||"string",timestamp:new Date(P.timestamp).toISOString()}));var E;u(y),Ge("Session ID updated",{newSession:y.slice(-12)}),l(m),Ge("replaceMessages called",{count:m.length}),E=(g=c.current)===null||g===void 0?void 0:g.getRootNode(),setTimeout(()=>{const P=(E||document).querySelector(".rcb-chat-body-container");P&&P.querySelectorAll(".rcb-bot-message").forEach(C=>{var S;let I=C.innerHTML,Q=!1;I.includes("](")&&(I=I.replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>'),Q=!0),I.includes("<a href=")&&(I=I.replace(/<a\s+href=["']([^"']+)["'][^&]*>([^&]+)<\/a>/gi,'<a href="$1" target="_blank" rel="noopener noreferrer">$2</a>'),Q=!0),(I.includes("<a ")||!((S=C.textContent)===null||S===void 0)&&S.includes("<a href="))&&(C.textContent||"").includes("<a href=")&&(I=I.replace(/<a\s+href="([^"]+)"[^&]*>([^&]+)<\/a>/gi,'<a href="$1" target="_blank" rel="noopener noreferrer">$2</a>'),Q=!0),Q&&(C.innerHTML=I)})},50),d(!1),Ge("Chat input enabled after restore"),t(!1)};return h.createElement("div",{style:{position:"relative"}},h.createElement("button",{ref:c,className:"history-button",onClick:()=>{if(!e&&(n((()=>{const y=Ot();return Object.entries(y).map(g=>{let[v,x]=g;return Object.assign({sessionId:v},x)}).sort((g,v)=>new Date(v.startedAt).getTime()-new Date(g.startedAt).getTime())})()),c.current)){const y=c.current.closest(".rcb-chat-window");if(y){const g=y.getBoundingClientRect(),v=c.current.getBoundingClientRect();a(g.width+3),s(g.right-v.right-18+4)}}t(!e)},style:{alignItems:"center",justifyContent:"center",width:"30px",height:"30px",borderRadius:"50%",backgroundColor:"var(--primaryColor, #1a5b6e)",marginRight:"18px",display:"flex",border:"none",cursor:"pointer",padding:0},"aria-label":"View chat history",title:"View chat history","aria-expanded":e,"aria-haspopup":"menu"},h.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false"},h.createElement("circle",{cx:"12",cy:"12",r:"10"}),h.createElement("polyline",{points:"12 6 12 12 16 14"}))),e&&h.createElement("div",{ref:i,role:"menu",style:{position:"absolute",right:A?"-".concat(A,"px"):"-18px",top:"100%",marginTop:"8px",width:o?"".concat(o,"px"):"550px",backgroundColor:"white",borderRadius:0,borderBottom:"3px solid var(--primaryColor, #1a5b6e)",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.1)",maxHeight:"250px",overflowY:"auto",zIndex:1e3}},r.length===0?h.createElement("div",{style:{padding:"12px 16px",color:"#666",fontSize:"14px",textAlign:"center"}},"No chat history"):r.map(y=>h.createElement("button",{key:y.sessionId,role:"menuitem",onClick:()=>f(y.sessionId),style:{width:"100%",padding:"10px 14px",border:"none",backgroundColor:"transparent",cursor:"pointer",textAlign:"left",display:"flex",flexDirection:"column",gap:"2px",borderBottom:"1px solid #eee"},onMouseEnter:g=>{g.currentTarget.style.backgroundColor="#f5f5f5"},onMouseLeave:g=>{g.currentTarget.style.backgroundColor="transparent"}},h.createElement("span",{style:{fontSize:"14px",color:"#333",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},y.preview||"New conversation"),h.createElement("span",{style:{fontSize:"12px",color:"#888"}},(g=>{const v=new Date(g),x=new Date().getTime()-v.getTime(),m=Math.floor(x/864e5);return m===0?v.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):m===1?"Yesterday":m<7?v.toLocaleDateString([],{weekday:"short"}):v.toLocaleDateString([],{month:"short",day:"numeric"})})(y.startedAt))))))};function lr(){return lr=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},lr.apply(null,arguments)}const Ma=({width:e=24,height:t=24,color:r="currentColor",children:n,...o})=>h.createElement("svg",lr({xmlns:"http://www.w3.org/2000/svg",width:e,height:t,viewBox:"0 0 24 24",fill:"none",stroke:r,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false"},o),n),_l=e=>h.createElement(Ma,e,h.createElement("path",{d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})),Ll=()=>{const{restartFlow:e}=Vt(),{setTextAreaValue:t}=Zr(),{messages:r}=Pt(),{getSessionId:n,resetSession:o,clearResettingFlag:a}=Ar(),{trackEvent:A}=Ca();return h.createElement("button",{onClick:async()=>{const s=n(),i=s?Ta(s):0;A({type:"chatbot_new_chat",previousMessageCount:i}),o(),await t(""),await e(),setTimeout(()=>{a()},100)},tabIndex:0,"aria-label":"New chat conversation",style:{backgroundColor:"var(--primaryColor, #107180)",border:"none",color:"#ffffff",fontSize:"14px",cursor:"pointer",padding:"8px 12px",borderRadius:"4px",transition:"all 0.2s ease",display:"flex",alignItems:"center",gap:"6px",fontWeight:"500"},onMouseEnter:s=>{s.target.style.backgroundColor="var(--secondaryColor, #0d5f6b)"},onMouseLeave:s=>{s.target.style.backgroundColor="var(--primaryColor, #107180)"}},h.createElement(_l,{width:16,height:16}),"New Chat")};function cr(e){if(typeof e=="string")return e;if(typeof e=="number")return String(e);if(!e)return"";if(Array.isArray(e))return e.map(cr).join("");if(typeof e=="object"&&e!==null&&"props"in e){const t=e.props;if(t&&"children"in t)return cr(t.children)}return""}const Nl=()=>{const{getSessionId:e}=Ar(),t=h.useCallback(r=>{var n;const o=(n=r.data)===null||n===void 0?void 0:n.message;if(!(o!=null&&o.id))return;const a=o.sender,A=o.type||"string";let s;if(s=typeof o.content=="string"?o.content:cr(o.content),Bl("TRACKED",{id:o.id,sender:a,content:s.substring(0,50)+(s.length>50?"...":"")}),s.includes("rcb-options-container")||!s.trim())return;const i=e();Tl(i,o.id,s,a,A)},[e]);return h.useEffect(()=>(window.addEventListener("rcb-pre-inject-message",t),()=>{window.removeEventListener("rcb-pre-inject-message",t)}),[t]),null},Hl=()=>(h.useEffect(()=>{const e=A=>{if(!["ArrowDown","ArrowUp","ArrowLeft","ArrowRight","Enter"," ","Home","End"].includes(A.key))return;const s=document.activeElement;if(s&&(s.tagName==="INPUT"||s.tagName==="TEXTAREA"||s.contentEditable==="true"||s.classList.contains("rcb-chat-input-textarea")))return;const i=document.querySelector(".rcb-chat-window");if(!i)return;const c=Array.from(i.querySelectorAll(".rcb-message-container, .rcb-bot-message-container, .rcb-user-message-container")).filter(u=>u.offsetParent!==null);if(c.length>0){const u=c[c.length-1].querySelector(".rcb-checkbox-container");if(u&&u.offsetParent!==null){const p=Array.from(u.querySelectorAll(".rcb-checkbox-row-container")),f=u.querySelector(".rcb-checkbox-next-button");if(p.length>0){const y=[...p];return f&&y.push(f),void((g,v)=>{g.preventDefault();let x=-1;for(let E=0;E<v.length;E++)if(v[E]===document.activeElement||v[E].contains(document.activeElement)){x=E;break}x===-1&&(x=0);let m=x;switch(g.key){case"ArrowDown":case"ArrowRight":m=x<v.length-1?x+1:0;break;case"ArrowUp":case"ArrowLeft":m=x>0?x-1:v.length-1;break;case"Home":m=0;break;case"End":m=v.length-1;break;case"Enter":case" ":{const E=v[x],P=new MouseEvent("mousedown",{bubbles:!0,cancelable:!0,view:window});return void E.dispatchEvent(P)}default:return}v[m].focus(),v[m].setAttribute("tabindex","0"),v[m].classList.add("keyboard-focused"),v.forEach((E,P)=>{P!==m&&(E.setAttribute("tabindex","-1"),E.classList.remove("keyboard-focused"))})})(A,y)}}}let l=[];if(c.length>0){const u=c[c.length-1],p=Array.from(u.querySelectorAll(".rcb-options-container")).filter(f=>f.offsetParent!==null);if(p.length>0){const f=p[p.length-1];l=Array.from(f.querySelectorAll(".rcb-options"))}}if(l.length===0)return;const d=l.findIndex(u=>u===document.activeElement);switch(A.key){case"ArrowDown":case"ArrowRight":{let u;A.preventDefault(),u=d<l.length-1?d+1:0,l[u].setAttribute("tabindex","0"),l.forEach((p,f)=>{f!==u&&(p.setAttribute("tabindex","-1"),p.classList.remove("keyboard-focused"))}),l[u].classList.add("keyboard-focused"),l[u].focus();break}case"ArrowUp":case"ArrowLeft":{let u;A.preventDefault(),u=d>0?d-1:l.length-1,l[u].setAttribute("tabindex","0"),l.forEach((p,f)=>{f!==u&&(p.setAttribute("tabindex","-1"),p.classList.remove("keyboard-focused"))}),l[u].classList.add("keyboard-focused"),l[u].focus();break}case"Enter":case" ":if(A.preventDefault(),document.activeElement&&l.includes(document.activeElement)){const u=document.activeElement;if(u.classList.contains("rcb-checkbox-row-container")||u.closest(".rcb-checkbox-row-container")){const p=new MouseEvent("mousedown",{bubbles:!0,cancelable:!0,view:window});u.dispatchEvent(p);const f=u.querySelector(".rcb-checkbox-label"),y=f?f.textContent:u.textContent||"checkbox",g=u.querySelector(".rcb-checkbox-mark"),v=g&&g.style.backgroundColor?"checked":"unchecked";t(`${y} ${v}`)}else{const p=new MouseEvent("mousedown",{bubbles:!0,cancelable:!0,view:window});u.dispatchEvent(p);const f=u.textContent||u.innerText;t(`Selected: ${f}`)}}break;case"Home":A.preventDefault(),l.length>0&&(l[0].setAttribute("tabindex","0"),l.forEach((u,p)=>{p!==0&&(u.setAttribute("tabindex","-1"),u.classList.remove("keyboard-focused"))}),l[0].classList.add("keyboard-focused"),l[0].focus());break;case"End":if(A.preventDefault(),l.length>0){const u=l.length-1;l[u].setAttribute("tabindex","0"),l.forEach((p,f)=>{f!==u&&(p.setAttribute("tabindex","-1"),p.classList.remove("keyboard-focused"))}),l[u].classList.add("keyboard-focused"),l[u].focus()}}},t=A=>{const s=document.createElement("div");s.setAttribute("aria-live","assertive"),s.setAttribute("aria-atomic","true"),s.className="sr-only",s.textContent=A,document.body.appendChild(s),setTimeout(()=>{document.body.contains(s)&&document.body.removeChild(s)},1e3)},r=(A=null)=>{let s=A;if(s||(s=document.querySelector(".rcb-chat-window"),s||(s=document.querySelector('[class*="rcb-chat"]')),s||(s=document.querySelector(".qa-bot"))),!s)return;const i=s.closest(".embedded-qa-bot")!==null,c=Array.from(s.querySelectorAll(".rcb-message-container, .rcb-bot-message-container, .rcb-user-message-container")).filter(p=>p.offsetParent!==null);if(c.length===0)return;const l=c[c.length-1],d=Array.from(l.querySelectorAll(".rcb-options-container")).filter(p=>p.offsetParent!==null);let u=[];if(d.length>0){const p=d[d.length-1];u=Array.from(p.querySelectorAll(".rcb-options"))}if(u.length===0){let p=l.querySelector(".rcb-checkbox-container");if(!p&&s&&(p=s.querySelector(".rcb-checkbox-container")),p&&p.offsetParent!==null){const f=Array.from(p.querySelectorAll(".rcb-checkbox-row-container")).filter(y=>y.offsetParent!==null&&y.style.display!=="none");if(f.length>0){const y=p.querySelector(".rcb-checkbox-next-button"),g=[...f];if(y&&y.offsetParent!==null&&g.push(y),g.forEach((v,x)=>{v.setAttribute("tabindex",x===0?"0":"-1"),x===0?v.classList.add("keyboard-focused"):v.classList.remove("keyboard-focused")}),f.length>1){p.querySelectorAll(".keyboard-nav-hint").forEach(x=>x.remove());const v=document.createElement("div");v.className="keyboard-nav-hint",v.textContent="Use arrow keys ↕ to navigate, Enter to select/deselect, or click any option",v.style.cssText="font-size: 12px !important; color: #666 !important; margin-bottom: 8px !important; font-style: italic !important; display: block !important;",p.insertBefore(v,p.firstChild)}return void setTimeout(()=>{g[0]&&g[0].offsetParent!==null&&!i&&g[0].focus()},150)}}}if(u.length>0){if(u.forEach((p,f)=>{const y=f===0?"0":"-1";p.setAttribute("tabindex",y),p.setAttribute("role","option"),p.setAttribute("aria-posinset",f+1),p.setAttribute("aria-setsize",u.length),f===0?p.classList.add("keyboard-focused"):p.classList.remove("keyboard-focused")}),u.length>1){const p=d.length>0?d[d.length-1]:null;if(p){p.querySelectorAll(".keyboard-nav-hint").forEach(y=>y.remove());const f=document.createElement("div");f.className="keyboard-nav-hint",f.textContent="Use arrow keys ↕ to navigate, Enter to select, or click any option",f.style.cssText="font-size: 12px !important; color: #666 !important; margin-bottom: 8px !important; font-style: italic !important; display: block !important;",p.insertBefore(f,p.firstChild)}}else{const p=d.length>0?d[d.length-1]:null;p&&p.querySelectorAll(".keyboard-nav-hint").forEach(f=>f.remove())}setTimeout(()=>{u[0]&&u[0].offsetParent!==null&&!i&&(u[0].focus(),u.length>1&&t(`${u.length} options available. Use arrow keys to navigate.`))},200)}},n=A=>{const s=A.querySelectorAll(".rcb-options");s.forEach((i,c)=>{i.hasAttribute("role")||(i.setAttribute("role","button"),i.setAttribute("tabindex",c===0?"0":"-1"),i.setAttribute("aria-posinset",c+1),i.setAttribute("aria-setsize",s.length))}),A.querySelectorAll(".rcb-checkbox-row-container").forEach((i,c)=>{i.hasAttribute("role")||(i.setAttribute("role","checkbox"),i.setAttribute("tabindex",c===0?"0":"-1"))})},o=new MutationObserver(A=>{A.forEach(s=>{var i,c;if(s.type==="childList"){const l=Array.from(s.addedNodes),d=l.some(p=>{var f,y,g,v;return p.nodeType===Node.ELEMENT_NODE&&(((f=p.classList)==null?void 0:f.contains("rcb-options-container"))||((y=p.classList)==null?void 0:y.contains("rcb-options"))||((g=p.querySelector)==null?void 0:g.call(p,".rcb-options-container"))||((v=p.querySelector)==null?void 0:v.call(p,".rcb-options")))}),u=l.some(p=>{var f,y;return p.nodeType===Node.ELEMENT_NODE&&(((f=p.classList)==null?void 0:f.contains("rcb-checkbox-container"))||((y=p.querySelector)==null?void 0:y.call(p,".rcb-checkbox-container")))});if(d||u){let p=s.target;for(;p&&!((i=p.classList)!=null&&i.contains("qa-bot"))&&!((c=p.classList)!=null&&c.contains("rcb-chat-window"));)p=p.parentElement;const f=p||document;n(f),f.querySelectorAll(".rcb-options[tabindex], .rcb-checkbox-row-container[tabindex], .rcb-checkbox-next-button[tabindex]").forEach(y=>{y.setAttribute("tabindex","-1"),y.classList.remove("keyboard-focused")}),setTimeout(()=>r(p),100)}}})});o.observe(document.body,{childList:!0,subtree:!0}),document.addEventListener("keydown",e),n(document),r();const a=setInterval(()=>{document.querySelectorAll(".qa-bot").forEach(A=>{const s=A.querySelectorAll(".rcb-options-container .rcb-options").length>0,i=A.querySelectorAll(".rcb-checkbox-row-container").length>0;if(s){n(A);const c=A.querySelectorAll(".rcb-options[tabindex]").length;A.querySelectorAll(".rcb-options").length>c&&r(A)}if(i){n(A);const c=A.querySelectorAll(".rcb-checkbox-row-container[tabindex]").length;A.querySelectorAll(".rcb-checkbox-row-container").length>c&&r(A)}})},1e3);return()=>{document.removeEventListener("keydown",e),o.disconnect(),clearInterval(a)}},[]),null),Ul="#1a5b6e",Fl="#107180",zl="Arial, sans-serif",Oa="Q&A Bot",Rl="/chat-icon.svg",jl="Type your question here...",ql="Select an option to continue",Gl=!1,Yl="Ask me a question!",_a="/login",Wl={general:{showHeader:!0,showFooter:!0},tooltip:{mode:"CLOSE"},chatInput:{disabled:!1,characterLimit:1e3,showCharacterCount:!1,allowNewline:!0,blockSpam:!1},chatWindow:{defaultOpen:!1,showScrollbar:!1},botBubble:{simulateStream:!0,streamSpeed:10,showAvatar:!1},userBubble:{showAvatar:!1},notification:{disabled:!0,showCount:!1},audio:{disabled:!0},emoji:{disabled:!0},fileAttachment:{disabled:!0}},ur=h.forwardRef((e,t)=>{var r,n;const{apiKey:o,qaEndpoint:a,ratingEndpoint:A,welcomeMessage:s,open:i,onOpenChange:c,isLoggedIn:l,allowAnonAccess:d=!1,actingUser:u,primaryColor:p,secondaryColor:f,botName:y,logo:g,placeholder:v,errorMessage:x,embedded:m,footerText:E,footerLink:P,tooltipText:C,loginUrl:S,customFlow:I,onAnalyticsEvent:Q}=e,B=h.useRef("bot_".concat(Math.random().toString(36).substr(2,9)));h.useEffect(()=>{Dl()},[]);const O=h.useRef(null);O.current===null&&(O.current=Ia(),sn("CREATED",O.current));const D=h.useRef(!1),M=h.useRef({getSessionId:()=>O.current,isResetting:()=>D.current}),[U,L]=h.useState(l);h.useEffect(()=>{L(l)},[l]);const F=m!==void 0?m:Gl,_=h.useCallback(R=>{var z;Q&&Q(Object.assign(Object.assign({},R),{timestamp:Date.now(),sessionId:(z=O.current)!==null&&z!==void 0?z:void 0,pageUrl:typeof window<"u"?window.location.href:void 0,isEmbedded:F}))},[Q,F]),H=h.useMemo(()=>{const R=Object.assign({},Wl);R.general=Object.assign(Object.assign({},R.general),{primaryColor:p||Ul,secondaryColor:f||Fl,fontFamily:zl,embedded:F});const z=U===!1?[h.createElement(Pa,{key:"login-button",loginUrl:S||_a,isHeaderButton:!0})]:[h.createElement(Ol,{key:"history-button"}),h.createElement(wl,{key:"user-icon"})];R.header={title:h.createElement("span",{style:{fontSize:14,fontWeight:500}},y||Oa),showAvatar:!0,avatar:g||Rl,buttons:[...z,ue.CLOSE_CHAT_BUTTON]},R.chatInput=Object.assign(Object.assign({},R.chatInput),{disabled:!1,enabledPlaceholderText:v||jl,disabledPlaceholderText:x||ql}),R.tooltip=Object.assign(Object.assign({},R.tooltip),{text:C||Yl});const q=E?P?h.createElement("a",{href:P,target:"_blank",rel:"noopener noreferrer",key:"footer-link"},E):h.createElement("span",{key:"footer-text"},E):null;return R.footer={text:q,buttons:[h.createElement(Ll,{key:"new-chat-button"})]},R.chatWindow=Object.assign(Object.assign({},R.chatWindow),{defaultOpen:!!F}),R.event={rcbPreInjectMessage:!0,rcbPostInjectMessage:!0,rcbUserSubmitText:!0,rcbChangePath:!0,rcbToggleChatWindow:!0},R},[p,f,y,g,v,x,F,C,U,S,E,P]),b=h.useRef(null),X=function(R){let z=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return h.useMemo(()=>{const q=(Z,J)=>{if(R.current){const ae=getComputedStyle(R.current).getPropertyValue(Z);if(ae&&ae.trim()!=="")return ae.trim();if(R.current.parentElement){const re=getComputedStyle(R.current.parentElement).getPropertyValue(Z);if(re&&re.trim()!=="")return re.trim()}}return J};return{primaryColor:q("--primaryColor",z.primaryColor),secondaryColor:q("--secondaryColor",z.secondaryColor),fontFamily:q("--fontFamily",z.fontFamily)}},[R,z])}(b,H.general);((R,z)=>{h.useEffect(()=>{z.current&&(R?z.current.classList.add("bot-logged-in"):z.current.classList.remove("bot-logged-in"))},[R,z])})(U!==!1,b),(R=>{let{settings:z,themeColors:q}=R;h.useEffect(()=>{q&&(Object.entries(q).forEach(Z=>{let[J,ae]=Z;ae&&document.documentElement.style.setProperty("--".concat(J),ae)}),q.primaryColor&&document.documentElement.style.setProperty("--rcb-header-background",q.primaryColor),q.secondaryColor&&document.documentElement.style.setProperty("--rcb-header-background-hover",q.secondaryColor))},[q]),h.useEffect(()=>{var Z,J;!((Z=z.header)===null||Z===void 0)&&Z.title&&typeof z.header.title=="string"&&(z.header.title=h.createElement("div",{key:"header-title"},h.createElement("h1",{className:"sr-only"},z.header.title),h.createElement("span",{"aria-hidden":"true"},z.header.title))),z.device={desktopEnabled:!0,mobileEnabled:!0,applyMobileOptimizations:!1},z.chatHistory={disabled:!0},z.chatButton=Object.assign(Object.assign({},z.chatButton),{icon:(J=z.header)===null||J===void 0?void 0:J.avatar}),z.event=Object.assign(Object.assign({},z.event),{rcbToggleChatWindow:!0})},[z])})({settings:H,themeColors:X});const w=h.useMemo(()=>{const R=(q=>{let{endpoint:Z,ratingEndpoint:J,apiKey:ae,sessionId:re,isResetting:le=()=>!1,isLoggedIn:we,allowAnonAccess:Ye=!1,loginUrl:ut="/login",trackEvent:xe}=q;if(we===!1&&!Ye)return xe==null||xe({type:"chatbot_login_prompt_shown"}),{qa_loop:{message:"To ask questions, please log in first.",component:h.createElement(Pa,{loginUrl:ut}),chatDisabled:!0,path:"qa_loop"}};let Ne=null,xt=!1;if(!Z)throw new Error("Q&A endpoint is required");return{qa_loop:{message:async ot=>{const{userInput:We}=ot;if(le&&le()||!We||We.trim()==="")return null;if(We==="👍 Helpful"||We==="👎 Not helpful"){if(J&&Ne)try{const ge=We==="👍 Helpful",_e={"Content-Type":"application/json"};ae&&(_e["X-API-KEY"]=ae);const Ve=re();Ve&&(_e["X-Session-ID"]=Ve,_e["X-Query-ID"]=Ne),await fetch(J,{method:"POST",headers:_e,credentials:"include",body:JSON.stringify({sessionId:Ve,queryId:Ne,rating:ge?1:0})}),xe==null||xe({type:"chatbot_rating_sent",queryId:Ne,rating:ge?"helpful":"not_helpful"})}catch(ge){lt("Error sending feedback:",ge)}return"Thanks for the feedback! Feel free to ask another question."}try{const ge=Da();Ne=ge,xe==null||xe({type:"chatbot_question_sent",queryId:ge,questionLength:We.length});const _e={"Content-Type":"application/json"};ae&&(_e["X-API-KEY"]=ae);const Ve=re();Ve&&(_e["X-Session-ID"]=Ve,_e["X-Query-ID"]=ge);const dn={query:We,session_id:Ve,question_id:ge};sn("SENT to API",{session_id:Ve,question_id:ge});const pn=Date.now(),Nt=await fetch(Z,{method:"POST",headers:_e,credentials:"include",body:JSON.stringify(dn)}),yr=Date.now()-pn;if(!Nt.ok)throw new Error("API returned ".concat(Nt.status));const dt=await Nt.json(),Ht=dt.response||dt.answer||dt.text||dt.message;if(!Ht)throw new Error("Invalid response format from API");const fn=(Y=>{if(!Y||typeof Y!="string")return Y;let te=Y.replace(/\[(https?:\/\/[^\s]+?)\]/gi,"[$1]($1)");return te=te.replace(new RegExp(`(?<!\\]\\(|href=["']|\\[)https?:\\/\\/[^\\s[\\]()]+`,"gi"),ne=>{let de=ne,Ce="";const He=de.match(/([.,;:!?]+)$/);return He&&(Ce=He[1],de=de.slice(0,-Ce.length)),"[".concat(de,"](").concat(de,")").concat(Ce)}),te})(Ht),T=function(Y){const{confidence:te,tools_used:ne,metadata:de}=Y;if(!(te||ne&&ne.length!==0))return"";const Ce=[];return te&&Ce.push("• Confidence: ".concat(te)),ne&&ne.length>0&&Ce.push("• Tools used: ".concat(ne.join(", "))),de!=null&&de.agent&&Ce.push("• Agent: ".concat(de.agent)),`---
|
|
39
39
|
`.concat(Ce.join(`
|
|
40
40
|
`))}(dt),G=T?"".concat(fn,`
|
|
41
41
|
|
|
42
|
-
`).concat(T):fn;return await ot.injectMessage(G),xe==null||xe({type:"chatbot_answer_received",queryId:ge,responseTimeMs:yr,success:!0,responseLength:Ht.length,hasMetadata:!!T}),xt=!0,setTimeout(async()=>{await ot.injectMessage("Feel free to ask another question.")},100),null}catch(ge){return lt("Error in Q&A flow:",ge),xe==null||xe({type:"chatbot_answer_error",queryId:Ne??void 0,errorType:ge instanceof Error?ge.message:"unknown"}),"I apologize, but I'm having trouble processing your question. Please try again later."}},options:ot=>le&&le()||ot.userInput==="👍 Helpful"||ot.userInput==="👎 Not helpful"?[]:J&&xt?["👍 Helpful","👎 Not helpful"]:[],renderMarkdown:["BOT"],chatDisabled:!1,path:"qa_loop"}}})({endpoint:a,ratingEndpoint:A,apiKey:o,sessionId:M.current.getSessionId,isResetting:M.current.isResetting,isLoggedIn:U,allowAnonAccess:d,loginUrl:S||_a,trackEvent:_});return Object.assign(Object.assign({start:{message:s,renderMarkdown:["BOT"],transition:{duration:0},path:"qa_loop"}},R),I||{})},[o,a,A,s,U,d,S,I,u,_]),K=h.useMemo(()=>{return[()=>ys(z),yl(),()=>bl(R)];var R,z},[]);return h.useEffect(()=>{const R=()=>{const q=document.querySelector(".rcb-chat-window");if(!q)return;const Z=q.querySelector(".rcb-send-button");Z&&(Z.hasAttribute("tabindex")||Z.setAttribute("tabindex","0"),Z.hasAttribute("data-keyboard-enabled")||(Z.setAttribute("data-keyboard-enabled","true"),Z.addEventListener("keydown",J=>{if(J.key==="Enter"||J.key===" "){J.preventDefault();const ae=Z&&Object.keys(Z).find(le=>le.startsWith("__reactProps"));if(ae){const le=Z[ae],we=le==null?void 0:le.onMouseDown;if(we&&typeof we=="function")return void we(J)}const re=new MouseEvent("mousedown",{bubbles:!0,cancelable:!0,view:window});Z.dispatchEvent(re)}})))},z=setInterval(R,1e3);return R(),()=>clearInterval(z)},[]),Hl(),h.useEffect(()=>{const R=b.current;if(!R)return;const z=q=>{var Z,J,ae;const re=(J=(Z=q.target).closest)===null||J===void 0?void 0:J.call(Z,"a");re&&re.closest(".rcb-chat-body-container")&&(re.classList.contains("qa-bot-login-button")||re.closest(".rcb-options-container")||_({type:"chatbot_link_clicked",linkUrl:re.href,linkText:((ae=re.textContent)===null||ae===void 0?void 0:ae.trim())||""}))};return R.addEventListener("click",z),()=>R.removeEventListener("click",z)},[_]),h.useEffect(()=>{if(!F){const R=z=>{const q=z.data.newState;c==null||c(q);const Z=O.current;_(q?{type:"chatbot_open"}:{type:"chatbot_close",messageCount:Z?Ta(Z):0,durationMs:Z?Ql(Z):0})};return window.addEventListener("rcb-toggle-chat-window",R),()=>{window.removeEventListener("rcb-toggle-chat-window",R)}}},[F,c,_]),h.createElement("div",{className:"qa-bot ".concat(!((r=H.general)===null||r===void 0)&&r.embedded?"embedded-qa-bot":""),ref:b,role:"region","aria-label":y||Oa},h.createElement(Ml,{getSessionId:()=>O.current,setSessionId:R=>{const z=O.current;O.current=R,sn("RESTORED","".concat(z==null?void 0:z.slice(-12)," -> ").concat(R.slice(-12)))},resetSession:()=>{const R=O.current;D.current=!0,O.current=Ia(),sn("RESET","".concat(R==null?void 0:R.slice(-12)," -> ").concat(O.current.slice(-12)))},clearResettingFlag:()=>{D.current=!1}},h.createElement(vl,{trackEvent:_},h.createElement(Kr,null,h.createElement("div",null,h.createElement(Nl,null),h.createElement(Ea,{ref:t,embedded:((n=H.general)===null||n===void 0?void 0:n.embedded)||!1,currentOpen:i||!1,enabled:U!==!1,onSetEnabled:R=>L(!!R&&void 0)}),h.createElement($i,{key:"chatbot-".concat(B.current,"-").concat(U),settings:H,flow:w,plugins:K}),h.createElement("div",{role:"status","aria-live":"polite","aria-label":"Bot response updates",className:"sr-only",id:"bot-live-region"}),h.createElement("div",{id:"chat-input-help",className:"sr-only"},"Type your message and press Enter to send. Use arrow keys to navigate through response options."))))))});ur.displayName="QABot",br('.rcb-chat-window{height:800px!important;max-height:80vh!important;max-width:100%;width:550px!important}.rcb-chat-window .rcb-chat-header{align-items:center;display:flex;flex-direction:row;font-weight:700}.rcb-chat-window a{color:#000;font-weight:700;text-decoration:underline}.rcb-chat-window a:hover{color:var(--primaryColor,#107180)}.rcb-chat-window .rcb-bot-message a,.rcb-chat-window .rcb-bot-message a:link,.rcb-chat-window .rcb-bot-message a:visited{color:#fff!important;text-decoration:underline!important}.rcb-chat-window .rcb-bot-message a:hover{opacity:.85;text-decoration:underline!important}.rcb-chat-window .rcb-chat-input-textarea{overflow-y:auto}.rcb-chat-window .rcb-chat-footer-container{font-size:10px}.qa-bot .history-button,.qa-bot .user-login-icon{display:none!important}.qa-bot.bot-logged-in .history-button,.qa-bot.bot-logged-in .user-login-icon{display:flex!important;transform:scale(1.3) translateY(-2px)}.qa-bot.bot-logged-in .history-button:hover{opacity:.8}.qa-bot.bot-logged-in .history-button:focus{outline:2px solid #fff;outline-offset:2px}.embedded-qa-bot .rcb-chat-window{max-width:100%;width:100%!important}.qa-bot.hidden{display:none}.embedded-qa-bot .rcb-bot-message,.embedded-qa-bot .rcb-user-message{max-width:90%!important;word-break:break-word}.embedded-qa-bot .rcb-chat-input-textarea{width:100%!important}.qa-bot-container{max-width:100%;width:100%}@keyframes phone-ring{0%{transform:translateX(0) translateY(0) rotate(0deg)}2%{transform:translateX(0) translateY(-8px) rotate(-2deg)}4%{transform:translateX(0) translateY(-6px) rotate(2deg)}6%{transform:translateX(0) translateY(-8px) rotate(-1deg)}8%{transform:translateX(0) translateY(-6px) rotate(1deg)}10%{transform:translateX(0) translateY(-8px) rotate(-2deg)}12%{transform:translateX(0) translateY(-6px) rotate(2deg)}20%{transform:translateX(0) translateY(0) rotate(0deg)}30%{transform:translateX(0) translateY(0) rotate(0deg)}40%{transform:translateX(0) translateY(0) rotate(0deg)}49%{transform:translateX(0) translateY(0) rotate(0deg)}50%{transform:translateX(0) translateY(-8px) rotate(-2deg)}52%{transform:translateX(0) translateY(-6px) rotate(2deg)}54%{transform:translateX(0) translateY(-8px) rotate(-1deg)}56%{transform:translateX(0) translateY(-6px) rotate(1deg)}58%{transform:translateX(0) translateY(-8px) rotate(-2deg)}60%{transform:translateX(0) translateY(-6px) rotate(2deg)}70%{transform:translateX(0) translateY(0) rotate(0deg)}to{transform:translateX(0) translateY(0) rotate(0deg)}}@media (max-width:768px){.rcb-chat-window{max-height:calc(100vh - 100px)!important;max-width:calc(100vw - 40px)!important;width:550px!important}.embedded-chat-container.open{height:400px}.embedded-chat-closed{font-size:14px;height:40px}.embedded-chat-open-btn{font-size:12px;padding:3px 10px}.rcb-bot-message,.rcb-user-message{max-width:85%!important}.rcb-chat-input-textarea{font-size:16px!important;min-height:44px!important}.rcb-chat-header{padding:12px 16px!important}}@media (max-width:480px){.rcb-chat-window{bottom:10px!important;left:10px!important;max-height:calc(100vh - 80px)!important;max-width:calc(100vw - 20px)!important;right:10px!important;width:calc(100vw - 20px)!important}.embedded-chat-container.open{height:350px}.rcb-bot-message,.rcb-user-message{margin-bottom:8px!important;max-width:90%!important}.rcb-chat-header{font-size:14px!important;padding:8px 12px!important}.rcb-chat-button{bottom:20px!important;height:50px!important;right:20px!important;width:50px!important}.rcb-chat-footer-container{font-size:9px!important;padding:8px 12px!important}}@media (max-width:360px){.rcb-chat-window{left:5px!important;max-width:calc(100vw - 10px)!important;right:5px!important;width:calc(100vw - 10px)!important}.rcb-chat-header{font-size:13px!important;padding:6px 8px!important}}.rcb-checkbox-container{display:flex!important;flex-wrap:wrap!important;gap:8px!important;margin-left:16px!important;max-width:100%!important;padding-top:12px!important}.rcb-checkbox-row-container{align-items:center!important;background-color:#fff!important;border:1px solid #d0d0d0!important;border-radius:6px!important;box-sizing:border-box!important;color:var(--primaryColor,#107180)!important;cursor:pointer!important;display:flex!important;flex:0 0 auto!important;font-size:14px!important;font-weight:400!important;margin:0!important;max-height:auto!important;min-height:auto!important;padding:8px 12px!important;text-align:center!important;transition:all .2s ease!important;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:auto!important}.rcb-checkbox-row-container:hover{background-color:#e8f4f8!important;border-color:var(--primaryColor,#107180)!important;box-shadow:0 2px 4px #10718033!important;transform:translateY(-1px)!important}.rcb-checkbox-row-container[data-checked=true]{background-color:var(--primaryColor,#107180)!important;border-color:var(--primaryColor,#107180)!important;color:#fff!important}.rcb-checkbox-row{margin-left:0!important}.rcb-checkbox-mark{height:14px!important;margin-right:6px!important;width:14px!important}.rcb-checkbox-label{font-size:13px!important;margin:0!important;white-space:nowrap!important}.rcb-checkbox-next-button{align-items:center!important;background-color:#fff!important;border:1px solid #d0d0d0!important;border-radius:6px!important;box-sizing:border-box!important;color:var(--secondaryColor,#107180)!important;cursor:pointer!important;display:flex!important;flex:0 0 auto!important;font-size:14px!important;font-weight:400!important;justify-content:center!important;line-height:24px!important;margin:0!important;max-height:auto!important;min-height:auto!important;padding:8px 12px!important;text-align:center!important;transition:all .2s ease!important;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:auto!important}.rcb-checkbox-next-button:hover{background-color:#e8f4f8!important;border-color:var(--secondaryColor,#107180)!important;box-shadow:0 2px 4px #10718033!important;transform:translateY(-1px)!important}.sr-only{clip:rect(0,0,0,0)!important;border:0!important;height:1px!important;margin:-1px!important;overflow:hidden!important;padding:0!important;position:absolute!important;white-space:nowrap!important;width:1px!important}.rcb-chat-input-send-button:focus,.rcb-chat-input-textarea:focus{outline:2px solid var(--primaryColor,#107180)!important;outline-offset:2px!important}.rcb-user-message{word-wrap:break-word!important;overflow:hidden!important;word-break:break-word!important}:focus-visible{outline:2px solid var(--primaryColor,#107180)!important;outline-offset:2px!important}.rcb-options-container{display:flex!important;flex-direction:row!important;flex-wrap:wrap!important;gap:8px!important;margin:16px!important;padding:0!important}.rcb-options{background-color:#fff!important;border:1px solid #d0d0d0!important;border-radius:6px!important;box-sizing:border-box!important;color:var(--secondaryColor,#107180)!important;cursor:pointer!important;flex:0 0 auto!important;font-size:14px!important;font-weight:400!important;outline:none!important;padding:8px 12px!important;text-align:center!important;transition:all .2s ease!important;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:auto!important}.rcb-options:hover{background-color:#e8f4f8!important;border-color:var(--secondaryColor,#107180)!important;box-shadow:0 2px 4px #10718033!important;transform:translateY(-1px)!important}.rcb-checkbox-next-button.keyboard-focused,.rcb-checkbox-next-button:focus,.rcb-checkbox-next-button:focus-visible,.rcb-checkbox-row-container.keyboard-focused,.rcb-checkbox-row-container:focus,.rcb-checkbox-row-container:focus-visible,.rcb-options.keyboard-focused,.rcb-options:focus,.rcb-options:focus-visible{background-color:#e8f4f8!important;border-color:var(--secondaryColor,#107180)!important;outline:none!important}.rcb-options:active{background-color:var(--secondaryColor,#107180)!important;border-color:var(--secondaryColor,#107180)!important;color:#fff!important;transform:translateY(0)!important}.keyboard-nav-hint{color:#666!important;font-size:12px!important;font-style:italic!important;margin-bottom:8px!important}@media (prefers-reduced-motion:reduce){.keyboard-nav-hint{display:none!important}}.rcb-options-container [role=button][tabindex="0"],.rcb-options-container button[tabindex="0"]{position:relative!important}.rcb-options-container [role=button][tabindex="0"]:after,.rcb-options-container button[tabindex="0"]:after{color:var(--secondaryColor,#107180)!important;content:"←"!important;font-size:16px!important;opacity:0!important;position:absolute!important;right:12px!important;top:50%!important;transform:translateY(-50%)!important;transition:opacity .2s ease!important}.rcb-options-container [role=button][tabindex="0"]:focus:after,.rcb-options-container button[tabindex="0"]:focus:after{opacity:1!important}.rcb-chat-input-send-button{cursor:pointer!important;opacity:1!important;pointer-events:auto!important;visibility:visible!important}.rcb-chat-input-send-button:not([tabindex]){-webkit-user-select:none;-moz-user-select:none;user-select:none}.rcb-chat-input-container [onclick],.rcb-chat-input-container [role=button],.rcb-chat-input-container div[style*=cursor],.rcb-chat-input-container svg:last-child,.rcb-chat-input-container>div:last-child{tabindex:0!important;cursor:pointer!important}.rcb-chat-footer{margin-top:4px!important;padding-top:0!important}.rcb-chat-footer-container{align-items:center!important;display:flex!important;margin-top:4px!important;padding-top:4px!important}.rcb-chat-footer-container button{order:1!important}.rcb-chat-footer-container a[href*=qa-bot-core]{tab-index:0!important;order:2!important}.rcb-chat-footer-container a[href*=feedback]{tab-index:0!important;order:3!important}@media (prefers-contrast:high){.rcb-chat-window a{background-color:#fff!important;border:1px solid #000!important;color:#000!important}}@media (prefers-reduced-motion:reduce){*{animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important}}.rcb-chat-input-textarea{user-select:text!important}.rcb-chat-body-container,.rcb-chat-input-textarea,.rcb-chat-window{touch-action:pan-y!important}.embedded-qa-bot,.rcb-chat-window{-webkit-overflow-scrolling:touch!important}.embedded-qa-bot .rcb-chat-input-textarea{touch-action:pan-y!important;user-select:text!important}.embedded-qa-bot .rcb-chat-body-container,.embedded-qa-bot .rcb-chat-window{touch-action:pan-y!important}.rcb-chat-header-container{background:var(--primaryColor,#1a5b6e)!important;background:linear-gradient(135deg,var(--primaryColor,#1a5b6e) 0,var(--secondaryColor,#107180) 100%)!important}.rcb-toggle-button{align-items:center!important;background:var(--primaryColor,#1a5b6e)!important;display:flex!important;justify-content:center!important}.rcb-toggle-button svg{stroke:#fff!important;color:#fff!important}.rcb-toggle-button *,.rcb-toggle-button img,.rcb-toggle-button svg,.rcb-toggle-button>*{box-sizing:border-box!important;height:50px!important;left:0!important;margin:0 auto!important;max-height:50px!important;max-width:50px!important;min-height:50px!important;min-width:50px!important;padding:2px!important;position:relative!important;top:0!important;width:50px!important}.rcb-send-button{background-color:var(--primaryColor,#1a5b6e)!important}',{insertAt:"top"});const Vl=()=>{const[e,t]=h.useState(!1),r=()=>typeof navigator<"u"&&navigator.mediaDevices!==void 0&&typeof navigator.mediaDevices.getDisplayMedia=="function";return{captureScreenshot:async()=>{if(!r())throw new Error("Screen capture is not available in this environment");try{t(!0);const n=await navigator.mediaDevices.getDisplayMedia({video:{displaySurface:"browser",cursor:"always",width:{ideal:1920},height:{ideal:1080}},audio:!1}),o=document.createElement("video");o.srcObject=n,await new Promise(l=>{o.onloadedmetadata=()=>{o.play(),l()}});const a=document.createElement("canvas");a.width=o.videoWidth,a.height=o.videoHeight;const A=a.getContext("2d");if(!A)throw new Error("Could not get canvas context");A.drawImage(o,0,0,a.width,a.height);const s=await new Promise(l=>a.toBlob(l,"image/png"));if(!s)throw new Error("Could not create image blob");const i=new Date().toISOString().replace(/[:.]/g,"-"),c=new File([s],"screenshot-".concat(i,".png"),{type:"image/png"});return n.getTracks().forEach(l=>l.stop()),t(!1),c}catch(n){throw lt("Error capturing screenshot:",n),t(!1),n}},isCapturing:e,isScreenCaptureAvailable:r()}},Xl=e=>h.createElement(Ma,e,h.createElement("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),h.createElement("polyline",{points:"17 8 12 3 7 8"}),h.createElement("line",{x1:"12",y1:"3",x2:"12",y2:"15"})),Kl=e=>new Promise((t,r)=>{const n=new FileReader;n.onload=()=>{if(typeof n.result!="string")return void r(new Error("Failed to read file ".concat(e.name)));const o=n.result.split(",")[1];t({fileName:e.name,contentType:e.type,size:e.size,fileData:o})},n.onerror=()=>r(new Error("Failed to read file ".concat(e.name))),n.readAsDataURL(e)}),Jl=e=>Promise.all(e.map(Kl)),Zl=e=>e<1024?"".concat(e," B"):e<1048576?"".concat((e/1024).toFixed(1)," KB"):"".concat((e/1048576).toFixed(1)," MB"),An=e=>{let{onFileUpload:t,maxSizeMB:r=10,acceptedTypes:n="image/*,application/pdf,text/*,.doc,.docx",enableScreenshot:o=!1,className:a}=e;const[A,s]=h.useState(!1),[i,c]=h.useState([]),[l,d]=h.useState(null),u=h.useRef(null),{captureScreenshot:p,isCapturing:f,isScreenCaptureAvailable:y}=Vl(),g=C=>{const S=document.createElement("div");S.setAttribute("aria-live","assertive"),S.setAttribute("aria-atomic","true"),S.className="sr-only",S.textContent=C,document.body.appendChild(S),setTimeout(()=>document.body.removeChild(S),1e3)},v=C=>{if(!C||C.length===0)return void Il("FileUploadComponent: No valid files provided to handleFiles");let S;try{S=Array.from(C)}catch(O){return lt("FileUploadComponent: Error converting files to array:",O),void g("Error processing selected files. Please try again.")}const I=[...i,...S];c(I);const Q=S.length,B=S.map(O=>O.name).join(", ");g("".concat(Q," file").concat(Q>1?"s":""," selected: ").concat(B)),setTimeout(()=>{const O=document.querySelector(".rcb-chat-content");O&&(O.scrollTop=O.scrollHeight)},100),t&&t(I)},x=C=>{C.preventDefault(),C.stopPropagation(),C.type==="dragenter"||C.type==="dragover"?s(!0):C.type==="dragleave"&&s(!1)},m=()=>{try{u.current&&u.current.click()}catch(C){lt("FileUploadComponent: Error in handleButtonClick:",C),g("Error opening file selection dialog. Please try again.")}},E=()=>{d(null)},P=o&&y;return h.createElement("div",{className:"file-upload-container ".concat(a||""),style:{padding:"16px",margin:"8px 0"}},P&&h.createElement("div",{style:{display:"flex",justifyContent:"center",marginBottom:"10px"}},h.createElement("button",{onClick:C=>{C.preventDefault(),(async()=>{try{const S=await p();v([S]),g("Screenshot captured successfully")}catch{g("Error capturing screenshot. Please try again.")}})()},disabled:f,"aria-describedby":"screenshot-help","aria-label":f?"Taking screenshot, please wait":"Take a screenshot to attach",style:{display:"flex",alignItems:"center",gap:"8px",backgroundColor:"#107180",color:"white",border:"none",borderRadius:"5px",padding:"8px 12px",cursor:f?"not-allowed":"pointer",fontSize:"14px",fontWeight:"500",boxShadow:"0 1px 3px rgba(0,0,0,0.2)"}},h.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},h.createElement("path",{d:"M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"}),h.createElement("circle",{cx:"12",cy:"13",r:"4"})),f?"Taking screenshot...":"Take screenshot..."),h.createElement("span",{id:"screenshot-help",className:"sr-only"},"Captures the current screen and adds it as an attachment")),h.createElement("div",{className:"file-upload-dropzone ".concat(A?"active":""),onDragEnter:x,onDragLeave:x,onDragOver:x,onDrop:C=>{var S;C.preventDefault(),C.stopPropagation(),s(!1);try{!((S=C.dataTransfer)===null||S===void 0)&&S.files&&C.dataTransfer.files.length>0&&v(C.dataTransfer.files)}catch(I){lt("FileUploadComponent: Error in handleDrop:",I),g("Error processing dropped files. Please try again.")}},role:"button",tabIndex:0,"aria-label":"File upload area. Click to select files or drag and drop files here.","aria-describedby":"upload-instructions",onKeyDown:C=>{C.key!=="Enter"&&C.key!==" "||(C.preventDefault(),m())},style:{padding:"20px",border:"2px dashed #ccc",borderRadius:"8px",backgroundColor:A?"#f0f8ff":"#fafafa",transition:"all 0.3s ease"}},h.createElement("input",{ref:u,type:"file",className:"file-input",onChange:C=>{var S;try{!((S=C.target)===null||S===void 0)&&S.files&&C.target.files.length>0&&v(C.target.files)}catch(I){lt("FileUploadComponent: Error in handleFileSelect:",I),g("Error processing selected files. Please try again.")}},multiple:!0,style:{display:"none"},"aria-label":"Select files to upload",accept:n}),h.createElement("div",{className:"upload-content",onClick:m,style:{cursor:"pointer",flexDirection:"column",alignItems:"center",display:"flex",textAlign:"center",padding:"12px"}},h.createElement("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"8px"}},h.createElement("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"}},h.createElement(Xl,null),h.createElement("p",{style:{margin:0,fontWeight:"bold"}},"Upload Files")),h.createElement("p",{id:"upload-instructions",style:{margin:0,fontSize:"14px",color:"#666"}},"Drag and drop files here or click to select. (Max ",r,"MB each)")),i.length>0&&h.createElement("div",{className:"selected-files",style:{display:"flex",flexWrap:"wrap",gap:"8px",marginTop:"12px",alignItems:"center"}},h.createElement("span",{style:{fontWeight:400,color:"#888",fontSize:"13px",marginRight:"8px",alignSelf:"center"}},"Selected files:"),i.map((C,S)=>h.createElement("span",{key:S,style:{background:"#fff",color:"#107180",borderRadius:"5px",padding:"4px 12px",fontSize:"14px",marginRight:"4px",marginBottom:"4px",border:"1px solid #ccc",display:"flex",alignItems:"center",gap:"6px",cursor:"pointer"},onClick:I=>{I.stopPropagation(),(Q=>{d(Q)})(C)}},h.createElement("span",{onClick:I=>{I.stopPropagation(),(Q=>{const B=i.filter((O,D)=>D!==Q);c(B),t&&t(B)})(S)},style:{cursor:"pointer",color:"#888",fontWeight:"bold",fontSize:"15px",marginRight:"4px",userSelect:"none",lineHeight:1},title:"Remove file","aria-label":"Remove ".concat(C.name)},"×"),C.name," (",Zl(C.size),")"))))),(()=>{if(!l)return null;const C=l.type.startsWith("image/"),S=l.type.startsWith("text/"),I=l.type==="application/pdf";return h.createElement("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.7)",display:"flex",justifyContent:"center",alignItems:"center",zIndex:1e3},onClick:E},h.createElement("div",{style:{backgroundColor:"white",padding:"20px",borderRadius:"8px",maxWidth:"90%",maxHeight:"90%",overflow:"auto",position:"relative"},onClick:Q=>Q.stopPropagation()},h.createElement("button",{onClick:E,style:{position:"absolute",top:"10px",right:"10px",background:"none",border:"none",fontSize:"24px",cursor:"pointer",color:"#666"}},"×"),h.createElement("h3",{style:{marginTop:0,marginBottom:"16px"}},l.name),C&&h.createElement("img",{src:URL.createObjectURL(l),alt:l.name,style:{maxWidth:"100%",maxHeight:"70vh"}}),S&&h.createElement("pre",{style:{whiteSpace:"pre-wrap",wordWrap:"break-word",maxHeight:"70vh",overflow:"auto",padding:"16px",backgroundColor:"#f5f5f5",borderRadius:"4px"}},URL.createObjectURL(l)),I&&h.createElement("iframe",{src:URL.createObjectURL(l),style:{width:"100%",height:"70vh",border:"none"},title:l.name}),!C&&!S&&!I&&h.createElement("div",{style:{padding:"20px",textAlign:"center"}},"Preview not available for this file type")))})())};function $l(e,t){if(!t||Object.keys(t).length===0)return e;const r={};for(const[n,o]of Object.entries(e)){let a=Object.assign({},o);if(a.chatDisabled===void 0){const A=!(!a.options&&!a.checkboxes);a.chatDisabled=A}r[n]=a}return r}function ln(e){return async t=>{const r=await e(t);await t.injectMessage(r)}}const ec=h.forwardRef((e,t)=>{const[r,n]=h.useState(e.defaultOpen||!1),o=h.useRef(null);return h.useImperativeHandle(t,()=>({addMessage:a=>{var A;(A=o.current)===null||A===void 0||A.addMessage(a)},setBotEnabled:a=>{var A;(A=o.current)===null||A===void 0||A.setBotEnabled(a)},openChat:()=>{var a;n(!0),(a=o.current)===null||a===void 0||a.openChat()},closeChat:()=>{var a;n(!1),(a=o.current)===null||a===void 0||a.closeChat()},toggleChat:()=>{var a;n(A=>!A),(a=o.current)===null||a===void 0||a.toggleChat()}}),[]),h.createElement(ur,{ref:o,apiKey:e.apiKey,qaEndpoint:e.qaEndpoint,ratingEndpoint:e.ratingEndpoint,welcomeMessage:e.welcomeMessage,primaryColor:e.primaryColor,secondaryColor:e.secondaryColor,botName:e.botName,logo:e.logo,placeholder:e.placeholder,errorMessage:e.errorMessage,embedded:e.embedded,isLoggedIn:e.isLoggedIn,allowAnonAccess:e.allowAnonAccess,open:r,onOpenChange:n,footerText:e.footerText,footerLink:e.footerLink,tooltipText:e.tooltipText,onAnalyticsEvent:e.onAnalyticsEvent})});ec.displayName="ProgrammaticQABot";const rt={QA_ENDPOINT:"https://access-ai-grace1-external.ccs.uky.edu/access/chat/api/",RATING_ENDPOINT:"https://access-ai-grace1-external.ccs.uky.edu/access/chat/rating/",METRICS_API_ENDPOINT:"https://access-ai-grace1-external.ccs.uky.edu/access/xdmod/chat/api/",METRICS_RATING_ENDPOINT:"https://access-ai-grace1-external.ccs.uky.edu/access/xdmod/chat/rating/",METRICS_QUESTIONS_URL:"https://metrics.access-ci.org/qa_bot_faq",NETLIFY_BASE_URL:"https://access-jsm-api.netlify.app",DEFAULT_API_KEY:"demo-key"},Ke={BOT_NAME:"ACCESS Q&A",LOGO:"https://support.access-ci.org/themes/contrib/asp-theme/images/icons/ACCESS-arrrow.svg",WELCOME_MESSAGE:"Hello! What can I help you with?",WELCOME_MESSAGE_LOGGED_OUT:"To ask questions, please log in.",LOGIN_URL:"/login",PRIMARY_COLOR:"#1a5b6e",SECONDARY_COLOR:"#107180",TOOLTIP:"Ask me about ACCESS! 😊"},La={SESSION_ID:"access-qa-bot-session-id"};function tc({welcome:e,setTicketForm:t,isLoggedIn:r,trackEvent:n}){return{start:{message:e,options:["Ask a question about ACCESS","Open a Help Ticket","Usage and performance of ACCESS resources (XDMoD)","Report a security issue"],path:o=>(n({type:"chatbot_menu_selected",selection:o.userInput}),o.userInput==="Ask a question about ACCESS"?r?"go_ahead_and_ask":"qa_loop":o.userInput==="Open a Help Ticket"?(t({}),"help_ticket"):o.userInput==="Usage and performance of ACCESS resources (XDMoD)"?"metrics_intro":o.userInput==="Report a security issue"?(t({}),n({type:"chatbot_security_started"}),"security_incident"):"start")},go_ahead_and_ask:{message:`Go ahead and ask your question! I'll do my best to help.
|
|
42
|
+
`).concat(T):fn;return await ot.injectMessage(G),xe==null||xe({type:"chatbot_answer_received",queryId:ge,responseTimeMs:yr,success:!0,responseLength:Ht.length,hasMetadata:!!T}),xt=!0,setTimeout(async()=>{await ot.injectMessage("Feel free to ask another question.")},100),null}catch(ge){return lt("Error in Q&A flow:",ge),xe==null||xe({type:"chatbot_answer_error",queryId:Ne??void 0,errorType:ge instanceof Error?ge.message:"unknown"}),"I apologize, but I'm having trouble processing your question. Please try again later."}},options:ot=>le&&le()||ot.userInput==="👍 Helpful"||ot.userInput==="👎 Not helpful"?[]:J&&xt?["👍 Helpful","👎 Not helpful"]:[],renderMarkdown:["BOT"],chatDisabled:!1,path:"qa_loop"}}})({endpoint:a,ratingEndpoint:A,apiKey:o,sessionId:M.current.getSessionId,isResetting:M.current.isResetting,isLoggedIn:U,allowAnonAccess:d,loginUrl:S||_a,trackEvent:_});return Object.assign(Object.assign({start:{message:s,renderMarkdown:["BOT"],transition:{duration:0},path:"qa_loop"}},R),I||{})},[o,a,A,s,U,d,S,I,u,_]),K=h.useMemo(()=>{return[()=>ys(z),yl(),()=>bl(R)];var R,z},[]);return h.useEffect(()=>{const R=()=>{const q=document.querySelector(".rcb-chat-window");if(!q)return;const Z=q.querySelector(".rcb-send-button");Z&&(Z.hasAttribute("tabindex")||Z.setAttribute("tabindex","0"),Z.hasAttribute("data-keyboard-enabled")||(Z.setAttribute("data-keyboard-enabled","true"),Z.addEventListener("keydown",J=>{if(J.key==="Enter"||J.key===" "){J.preventDefault();const ae=Z&&Object.keys(Z).find(le=>le.startsWith("__reactProps"));if(ae){const le=Z[ae],we=le==null?void 0:le.onMouseDown;if(we&&typeof we=="function")return void we(J)}const re=new MouseEvent("mousedown",{bubbles:!0,cancelable:!0,view:window});Z.dispatchEvent(re)}})))},z=setInterval(R,1e3);return R(),()=>clearInterval(z)},[]),Hl(),h.useEffect(()=>{const R=b.current;if(!R)return;const z=q=>{var Z,J,ae;const re=(J=(Z=q.target).closest)===null||J===void 0?void 0:J.call(Z,"a");re&&re.closest(".rcb-chat-body-container")&&(re.classList.contains("qa-bot-login-button")||re.closest(".rcb-options-container")||_({type:"chatbot_link_clicked",linkUrl:re.href,linkText:((ae=re.textContent)===null||ae===void 0?void 0:ae.trim())||""}))};return R.addEventListener("click",z),()=>R.removeEventListener("click",z)},[_]),h.useEffect(()=>{if(!F){const R=z=>{const q=z.data.newState;c==null||c(q);const Z=O.current;_(q?{type:"chatbot_open"}:{type:"chatbot_close",messageCount:Z?Ta(Z):0,durationMs:Z?Ql(Z):0})};return window.addEventListener("rcb-toggle-chat-window",R),()=>{window.removeEventListener("rcb-toggle-chat-window",R)}}},[F,c,_]),h.createElement("div",{className:"qa-bot ".concat(!((r=H.general)===null||r===void 0)&&r.embedded?"embedded-qa-bot":""),ref:b,role:"region","aria-label":y||Oa},h.createElement(Ml,{getSessionId:()=>O.current,setSessionId:R=>{const z=O.current;O.current=R,sn("RESTORED","".concat(z==null?void 0:z.slice(-12)," -> ").concat(R.slice(-12)))},resetSession:()=>{const R=O.current;D.current=!0,O.current=Ia(),sn("RESET","".concat(R==null?void 0:R.slice(-12)," -> ").concat(O.current.slice(-12)))},clearResettingFlag:()=>{D.current=!1}},h.createElement(vl,{trackEvent:_},h.createElement(Kr,null,h.createElement("div",null,h.createElement(Nl,null),h.createElement(Ea,{ref:t,embedded:((n=H.general)===null||n===void 0?void 0:n.embedded)||!1,currentOpen:i||!1,enabled:U!==!1,onSetEnabled:R=>L(!!R&&void 0)}),h.createElement($i,{key:"chatbot-".concat(B.current,"-").concat(U),settings:H,flow:w,plugins:K}),h.createElement("div",{role:"status","aria-live":"polite","aria-label":"Bot response updates",className:"sr-only",id:"bot-live-region",style:{position:"absolute",width:"1px",height:"1px",padding:0,margin:"-1px",overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0}}),h.createElement("div",{id:"chat-input-help",className:"sr-only",style:{position:"absolute",width:"1px",height:"1px",padding:0,margin:"-1px",overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0}},"Type your message and press Enter to send. Use arrow keys to navigate through response options."))))))});ur.displayName="QABot",br('.rcb-chat-window{height:800px!important;max-height:80vh!important;max-width:100%;width:550px!important}.rcb-chat-window .rcb-chat-header{align-items:center;display:flex;flex-direction:row;font-weight:700}.rcb-chat-window a{color:#000;font-weight:700;text-decoration:underline}.rcb-chat-window a:hover{color:var(--primaryColor,#107180)}.rcb-chat-window .rcb-bot-message a,.rcb-chat-window .rcb-bot-message a:link,.rcb-chat-window .rcb-bot-message a:visited{color:#fff!important;text-decoration:underline!important}.rcb-chat-window .rcb-bot-message a:hover{opacity:.85;text-decoration:underline!important}.rcb-chat-window .rcb-chat-input-textarea{overflow-y:auto}.rcb-chat-window .rcb-chat-footer-container{font-size:10px}.qa-bot .history-button,.qa-bot .user-login-icon{display:none!important}.qa-bot.bot-logged-in .history-button,.qa-bot.bot-logged-in .user-login-icon{display:flex!important;transform:scale(1.3) translateY(-2px)}.qa-bot.bot-logged-in .history-button:hover{opacity:.8}.qa-bot.bot-logged-in .history-button:focus{outline:2px solid #fff;outline-offset:2px}.embedded-qa-bot .rcb-chat-window{max-width:100%;width:100%!important}.qa-bot.hidden{display:none}.embedded-qa-bot .rcb-bot-message,.embedded-qa-bot .rcb-user-message{max-width:90%!important;word-break:break-word}.embedded-qa-bot .rcb-chat-input-textarea{width:100%!important}.qa-bot-container{max-width:100%;width:100%}@keyframes phone-ring{0%{transform:translateX(0) translateY(0) rotate(0deg)}2%{transform:translateX(0) translateY(-8px) rotate(-2deg)}4%{transform:translateX(0) translateY(-6px) rotate(2deg)}6%{transform:translateX(0) translateY(-8px) rotate(-1deg)}8%{transform:translateX(0) translateY(-6px) rotate(1deg)}10%{transform:translateX(0) translateY(-8px) rotate(-2deg)}12%{transform:translateX(0) translateY(-6px) rotate(2deg)}20%{transform:translateX(0) translateY(0) rotate(0deg)}30%{transform:translateX(0) translateY(0) rotate(0deg)}40%{transform:translateX(0) translateY(0) rotate(0deg)}49%{transform:translateX(0) translateY(0) rotate(0deg)}50%{transform:translateX(0) translateY(-8px) rotate(-2deg)}52%{transform:translateX(0) translateY(-6px) rotate(2deg)}54%{transform:translateX(0) translateY(-8px) rotate(-1deg)}56%{transform:translateX(0) translateY(-6px) rotate(1deg)}58%{transform:translateX(0) translateY(-8px) rotate(-2deg)}60%{transform:translateX(0) translateY(-6px) rotate(2deg)}70%{transform:translateX(0) translateY(0) rotate(0deg)}to{transform:translateX(0) translateY(0) rotate(0deg)}}@media (max-width:768px){.rcb-chat-window{max-height:calc(100vh - 100px)!important;max-width:calc(100vw - 40px)!important;width:550px!important}.embedded-chat-container.open{height:400px}.embedded-chat-closed{font-size:14px;height:40px}.embedded-chat-open-btn{font-size:12px;padding:3px 10px}.rcb-bot-message,.rcb-user-message{max-width:85%!important}.rcb-chat-input-textarea{font-size:16px!important;min-height:44px!important}.rcb-chat-header{padding:12px 16px!important}}@media (max-width:480px){.rcb-chat-window{bottom:10px!important;left:10px!important;max-height:calc(100vh - 80px)!important;max-width:calc(100vw - 20px)!important;right:10px!important;width:calc(100vw - 20px)!important}.embedded-chat-container.open{height:350px}.rcb-bot-message,.rcb-user-message{margin-bottom:8px!important;max-width:90%!important}.rcb-chat-header{font-size:14px!important;padding:8px 12px!important}.rcb-chat-button{bottom:20px!important;height:50px!important;right:20px!important;width:50px!important}.rcb-chat-footer-container{font-size:9px!important;padding:8px 12px!important}}@media (max-width:360px){.rcb-chat-window{left:5px!important;max-width:calc(100vw - 10px)!important;right:5px!important;width:calc(100vw - 10px)!important}.rcb-chat-header{font-size:13px!important;padding:6px 8px!important}}.rcb-checkbox-container{display:flex!important;flex-wrap:wrap!important;gap:8px!important;margin-left:16px!important;max-width:100%!important;padding-top:12px!important}.rcb-checkbox-row-container{align-items:center!important;background-color:#fff!important;border:1px solid #d0d0d0!important;border-radius:6px!important;box-sizing:border-box!important;color:var(--primaryColor,#107180)!important;cursor:pointer!important;display:flex!important;flex:0 0 auto!important;font-size:14px!important;font-weight:400!important;margin:0!important;max-height:auto!important;min-height:auto!important;padding:8px 12px!important;text-align:center!important;transition:all .2s ease!important;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:auto!important}.rcb-checkbox-row-container:hover{background-color:#e8f4f8!important;border-color:var(--primaryColor,#107180)!important;box-shadow:0 2px 4px #10718033!important;transform:translateY(-1px)!important}.rcb-checkbox-row-container[data-checked=true]{background-color:var(--primaryColor,#107180)!important;border-color:var(--primaryColor,#107180)!important;color:#fff!important}.rcb-checkbox-row{margin-left:0!important}.rcb-checkbox-mark{height:14px!important;margin-right:6px!important;width:14px!important}.rcb-checkbox-label{font-size:13px!important;margin:0!important;white-space:nowrap!important}.rcb-checkbox-next-button{align-items:center!important;background-color:#fff!important;border:1px solid #d0d0d0!important;border-radius:6px!important;box-sizing:border-box!important;color:var(--secondaryColor,#107180)!important;cursor:pointer!important;display:flex!important;flex:0 0 auto!important;font-size:14px!important;font-weight:400!important;justify-content:center!important;line-height:24px!important;margin:0!important;max-height:auto!important;min-height:auto!important;padding:8px 12px!important;text-align:center!important;transition:all .2s ease!important;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:auto!important}.rcb-checkbox-next-button:hover{background-color:#e8f4f8!important;border-color:var(--secondaryColor,#107180)!important;box-shadow:0 2px 4px #10718033!important;transform:translateY(-1px)!important}.sr-only{clip:rect(0,0,0,0)!important;border:0!important;height:1px!important;margin:-1px!important;overflow:hidden!important;padding:0!important;position:absolute!important;white-space:nowrap!important;width:1px!important}.rcb-chat-input-send-button:focus,.rcb-chat-input-textarea:focus{outline:2px solid var(--primaryColor,#107180)!important;outline-offset:2px!important}.rcb-user-message{word-wrap:break-word!important;overflow:hidden!important;word-break:break-word!important}:focus-visible{outline:2px solid var(--primaryColor,#107180)!important;outline-offset:2px!important}.rcb-options-container{display:flex!important;flex-direction:row!important;flex-wrap:wrap!important;gap:8px!important;margin:16px!important;padding:0!important}.rcb-options{background-color:#fff!important;border:1px solid #d0d0d0!important;border-radius:6px!important;box-sizing:border-box!important;color:var(--secondaryColor,#107180)!important;cursor:pointer!important;flex:0 0 auto!important;font-size:14px!important;font-weight:400!important;outline:none!important;padding:8px 12px!important;text-align:center!important;transition:all .2s ease!important;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:auto!important}.rcb-options:hover{background-color:#e8f4f8!important;border-color:var(--secondaryColor,#107180)!important;box-shadow:0 2px 4px #10718033!important;transform:translateY(-1px)!important}.rcb-checkbox-next-button.keyboard-focused,.rcb-checkbox-next-button:focus,.rcb-checkbox-next-button:focus-visible,.rcb-checkbox-row-container.keyboard-focused,.rcb-checkbox-row-container:focus,.rcb-checkbox-row-container:focus-visible,.rcb-options.keyboard-focused,.rcb-options:focus,.rcb-options:focus-visible{background-color:#e8f4f8!important;border-color:var(--secondaryColor,#107180)!important;outline:none!important}.rcb-options:active{background-color:var(--secondaryColor,#107180)!important;border-color:var(--secondaryColor,#107180)!important;color:#fff!important;transform:translateY(0)!important}.keyboard-nav-hint{color:#666!important;font-size:12px!important;font-style:italic!important;margin-bottom:8px!important}@media (prefers-reduced-motion:reduce){.keyboard-nav-hint{display:none!important}}.rcb-options-container [role=button][tabindex="0"],.rcb-options-container button[tabindex="0"]{position:relative!important}.rcb-options-container [role=button][tabindex="0"]:after,.rcb-options-container button[tabindex="0"]:after{color:var(--secondaryColor,#107180)!important;content:"←"!important;font-size:16px!important;opacity:0!important;position:absolute!important;right:12px!important;top:50%!important;transform:translateY(-50%)!important;transition:opacity .2s ease!important}.rcb-options-container [role=button][tabindex="0"]:focus:after,.rcb-options-container button[tabindex="0"]:focus:after{opacity:1!important}.rcb-chat-input-send-button{cursor:pointer!important;opacity:1!important;pointer-events:auto!important;visibility:visible!important}.rcb-chat-input-send-button:not([tabindex]){-webkit-user-select:none;-moz-user-select:none;user-select:none}.rcb-chat-input-container [onclick],.rcb-chat-input-container [role=button],.rcb-chat-input-container div[style*=cursor],.rcb-chat-input-container svg:last-child,.rcb-chat-input-container>div:last-child{tabindex:0!important;cursor:pointer!important}.rcb-chat-footer{margin-top:4px!important;padding-top:0!important}.rcb-chat-footer-container{align-items:center!important;display:flex!important;margin-top:4px!important;padding-top:4px!important}.rcb-chat-footer-container button{order:1!important}.rcb-chat-footer-container a[href*=qa-bot-core]{tab-index:0!important;order:2!important}.rcb-chat-footer-container a[href*=feedback]{tab-index:0!important;order:3!important}@media (prefers-contrast:high){.rcb-chat-window a{background-color:#fff!important;border:1px solid #000!important;color:#000!important}}@media (prefers-reduced-motion:reduce){*{animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important}}.rcb-chat-input-textarea{user-select:text!important}.rcb-chat-body-container,.rcb-chat-input-textarea,.rcb-chat-window{touch-action:pan-y!important}.embedded-qa-bot,.rcb-chat-window{-webkit-overflow-scrolling:touch!important}.embedded-qa-bot .rcb-chat-input-textarea{touch-action:pan-y!important;user-select:text!important}.embedded-qa-bot .rcb-chat-body-container,.embedded-qa-bot .rcb-chat-window{touch-action:pan-y!important}.rcb-chat-header-container{background:var(--primaryColor,#1a5b6e)!important;background:linear-gradient(135deg,var(--primaryColor,#1a5b6e) 0,var(--secondaryColor,#107180) 100%)!important}.rcb-toggle-button{align-items:center!important;background:var(--primaryColor,#1a5b6e)!important;display:flex!important;justify-content:center!important}.rcb-toggle-button svg{stroke:#fff!important;color:#fff!important}.rcb-toggle-button *,.rcb-toggle-button img,.rcb-toggle-button svg,.rcb-toggle-button>*{box-sizing:border-box!important;height:50px!important;left:0!important;margin:0 auto!important;max-height:50px!important;max-width:50px!important;min-height:50px!important;min-width:50px!important;padding:2px!important;position:relative!important;top:0!important;width:50px!important}.rcb-send-button{background-color:var(--primaryColor,#1a5b6e)!important}',{insertAt:"top"});const Vl=()=>{const[e,t]=h.useState(!1),r=()=>typeof navigator<"u"&&navigator.mediaDevices!==void 0&&typeof navigator.mediaDevices.getDisplayMedia=="function";return{captureScreenshot:async()=>{if(!r())throw new Error("Screen capture is not available in this environment");try{t(!0);const n=await navigator.mediaDevices.getDisplayMedia({video:{displaySurface:"browser",cursor:"always",width:{ideal:1920},height:{ideal:1080}},audio:!1}),o=document.createElement("video");o.srcObject=n,await new Promise(l=>{o.onloadedmetadata=()=>{o.play(),l()}});const a=document.createElement("canvas");a.width=o.videoWidth,a.height=o.videoHeight;const A=a.getContext("2d");if(!A)throw new Error("Could not get canvas context");A.drawImage(o,0,0,a.width,a.height);const s=await new Promise(l=>a.toBlob(l,"image/png"));if(!s)throw new Error("Could not create image blob");const i=new Date().toISOString().replace(/[:.]/g,"-"),c=new File([s],"screenshot-".concat(i,".png"),{type:"image/png"});return n.getTracks().forEach(l=>l.stop()),t(!1),c}catch(n){throw lt("Error capturing screenshot:",n),t(!1),n}},isCapturing:e,isScreenCaptureAvailable:r()}},Xl=e=>h.createElement(Ma,e,h.createElement("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),h.createElement("polyline",{points:"17 8 12 3 7 8"}),h.createElement("line",{x1:"12",y1:"3",x2:"12",y2:"15"})),Kl=e=>new Promise((t,r)=>{const n=new FileReader;n.onload=()=>{if(typeof n.result!="string")return void r(new Error("Failed to read file ".concat(e.name)));const o=n.result.split(",")[1];t({fileName:e.name,contentType:e.type,size:e.size,fileData:o})},n.onerror=()=>r(new Error("Failed to read file ".concat(e.name))),n.readAsDataURL(e)}),Jl=e=>Promise.all(e.map(Kl)),Zl=e=>e<1024?"".concat(e," B"):e<1048576?"".concat((e/1024).toFixed(1)," KB"):"".concat((e/1048576).toFixed(1)," MB"),An=e=>{let{onFileUpload:t,maxSizeMB:r=10,acceptedTypes:n="image/*,application/pdf,text/*,.doc,.docx",enableScreenshot:o=!1,className:a}=e;const[A,s]=h.useState(!1),[i,c]=h.useState([]),[l,d]=h.useState(null),u=h.useRef(null),{captureScreenshot:p,isCapturing:f,isScreenCaptureAvailable:y}=Vl(),g=C=>{const S=document.createElement("div");S.setAttribute("aria-live","assertive"),S.setAttribute("aria-atomic","true"),S.className="sr-only",S.textContent=C,document.body.appendChild(S),setTimeout(()=>document.body.removeChild(S),1e3)},v=C=>{if(!C||C.length===0)return void Il("FileUploadComponent: No valid files provided to handleFiles");let S;try{S=Array.from(C)}catch(O){return lt("FileUploadComponent: Error converting files to array:",O),void g("Error processing selected files. Please try again.")}const I=[...i,...S];c(I);const Q=S.length,B=S.map(O=>O.name).join(", ");g("".concat(Q," file").concat(Q>1?"s":""," selected: ").concat(B)),setTimeout(()=>{const O=document.querySelector(".rcb-chat-content");O&&(O.scrollTop=O.scrollHeight)},100),t&&t(I)},x=C=>{C.preventDefault(),C.stopPropagation(),C.type==="dragenter"||C.type==="dragover"?s(!0):C.type==="dragleave"&&s(!1)},m=()=>{try{u.current&&u.current.click()}catch(C){lt("FileUploadComponent: Error in handleButtonClick:",C),g("Error opening file selection dialog. Please try again.")}},E=()=>{d(null)},P=o&&y;return h.createElement("div",{className:"file-upload-container ".concat(a||""),style:{padding:"16px",margin:"8px 0"}},P&&h.createElement("div",{style:{display:"flex",justifyContent:"center",marginBottom:"10px"}},h.createElement("button",{onClick:C=>{C.preventDefault(),(async()=>{try{const S=await p();v([S]),g("Screenshot captured successfully")}catch{g("Error capturing screenshot. Please try again.")}})()},disabled:f,"aria-describedby":"screenshot-help","aria-label":f?"Taking screenshot, please wait":"Take a screenshot to attach",style:{display:"flex",alignItems:"center",gap:"8px",backgroundColor:"#107180",color:"white",border:"none",borderRadius:"5px",padding:"8px 12px",cursor:f?"not-allowed":"pointer",fontSize:"14px",fontWeight:"500",boxShadow:"0 1px 3px rgba(0,0,0,0.2)"}},h.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},h.createElement("path",{d:"M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"}),h.createElement("circle",{cx:"12",cy:"13",r:"4"})),f?"Taking screenshot...":"Take screenshot..."),h.createElement("span",{id:"screenshot-help",className:"sr-only"},"Captures the current screen and adds it as an attachment")),h.createElement("div",{className:"file-upload-dropzone ".concat(A?"active":""),onDragEnter:x,onDragLeave:x,onDragOver:x,onDrop:C=>{var S;C.preventDefault(),C.stopPropagation(),s(!1);try{!((S=C.dataTransfer)===null||S===void 0)&&S.files&&C.dataTransfer.files.length>0&&v(C.dataTransfer.files)}catch(I){lt("FileUploadComponent: Error in handleDrop:",I),g("Error processing dropped files. Please try again.")}},role:"button",tabIndex:0,"aria-label":"File upload area. Click to select files or drag and drop files here.","aria-describedby":"upload-instructions",onKeyDown:C=>{C.key!=="Enter"&&C.key!==" "||(C.preventDefault(),m())},style:{padding:"20px",border:"2px dashed #ccc",borderRadius:"8px",backgroundColor:A?"#f0f8ff":"#fafafa",transition:"all 0.3s ease"}},h.createElement("input",{ref:u,type:"file",className:"file-input",onChange:C=>{var S;try{!((S=C.target)===null||S===void 0)&&S.files&&C.target.files.length>0&&v(C.target.files)}catch(I){lt("FileUploadComponent: Error in handleFileSelect:",I),g("Error processing selected files. Please try again.")}},multiple:!0,style:{display:"none"},"aria-label":"Select files to upload",accept:n}),h.createElement("div",{className:"upload-content",onClick:m,style:{cursor:"pointer",flexDirection:"column",alignItems:"center",display:"flex",textAlign:"center",padding:"12px"}},h.createElement("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"8px"}},h.createElement("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"}},h.createElement(Xl,null),h.createElement("p",{style:{margin:0,fontWeight:"bold"}},"Upload Files")),h.createElement("p",{id:"upload-instructions",style:{margin:0,fontSize:"14px",color:"#666"}},"Drag and drop files here or click to select. (Max ",r,"MB each)")),i.length>0&&h.createElement("div",{className:"selected-files",style:{display:"flex",flexWrap:"wrap",gap:"8px",marginTop:"12px",alignItems:"center"}},h.createElement("span",{style:{fontWeight:400,color:"#888",fontSize:"13px",marginRight:"8px",alignSelf:"center"}},"Selected files:"),i.map((C,S)=>h.createElement("span",{key:S,style:{background:"#fff",color:"#107180",borderRadius:"5px",padding:"4px 12px",fontSize:"14px",marginRight:"4px",marginBottom:"4px",border:"1px solid #ccc",display:"flex",alignItems:"center",gap:"6px",cursor:"pointer"},onClick:I=>{I.stopPropagation(),(Q=>{d(Q)})(C)}},h.createElement("span",{onClick:I=>{I.stopPropagation(),(Q=>{const B=i.filter((O,D)=>D!==Q);c(B),t&&t(B)})(S)},style:{cursor:"pointer",color:"#888",fontWeight:"bold",fontSize:"15px",marginRight:"4px",userSelect:"none",lineHeight:1},title:"Remove file","aria-label":"Remove ".concat(C.name)},"×"),C.name," (",Zl(C.size),")"))))),(()=>{if(!l)return null;const C=l.type.startsWith("image/"),S=l.type.startsWith("text/"),I=l.type==="application/pdf";return h.createElement("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.7)",display:"flex",justifyContent:"center",alignItems:"center",zIndex:1e3},onClick:E},h.createElement("div",{style:{backgroundColor:"white",padding:"20px",borderRadius:"8px",maxWidth:"90%",maxHeight:"90%",overflow:"auto",position:"relative"},onClick:Q=>Q.stopPropagation()},h.createElement("button",{onClick:E,style:{position:"absolute",top:"10px",right:"10px",background:"none",border:"none",fontSize:"24px",cursor:"pointer",color:"#666"}},"×"),h.createElement("h3",{style:{marginTop:0,marginBottom:"16px"}},l.name),C&&h.createElement("img",{src:URL.createObjectURL(l),alt:l.name,style:{maxWidth:"100%",maxHeight:"70vh"}}),S&&h.createElement("pre",{style:{whiteSpace:"pre-wrap",wordWrap:"break-word",maxHeight:"70vh",overflow:"auto",padding:"16px",backgroundColor:"#f5f5f5",borderRadius:"4px"}},URL.createObjectURL(l)),I&&h.createElement("iframe",{src:URL.createObjectURL(l),style:{width:"100%",height:"70vh",border:"none"},title:l.name}),!C&&!S&&!I&&h.createElement("div",{style:{padding:"20px",textAlign:"center"}},"Preview not available for this file type")))})())};function $l(e,t){if(!t||Object.keys(t).length===0)return e;const r={};for(const[n,o]of Object.entries(e)){let a=Object.assign({},o);if(a.chatDisabled===void 0){const A=!(!a.options&&!a.checkboxes);a.chatDisabled=A}r[n]=a}return r}function ln(e){return async t=>{const r=await e(t);await t.injectMessage(r)}}const ec=h.forwardRef((e,t)=>{const[r,n]=h.useState(e.defaultOpen||!1),o=h.useRef(null);return h.useImperativeHandle(t,()=>({addMessage:a=>{var A;(A=o.current)===null||A===void 0||A.addMessage(a)},setBotEnabled:a=>{var A;(A=o.current)===null||A===void 0||A.setBotEnabled(a)},openChat:()=>{var a;n(!0),(a=o.current)===null||a===void 0||a.openChat()},closeChat:()=>{var a;n(!1),(a=o.current)===null||a===void 0||a.closeChat()},toggleChat:()=>{var a;n(A=>!A),(a=o.current)===null||a===void 0||a.toggleChat()}}),[]),h.createElement(ur,{ref:o,apiKey:e.apiKey,qaEndpoint:e.qaEndpoint,ratingEndpoint:e.ratingEndpoint,welcomeMessage:e.welcomeMessage,primaryColor:e.primaryColor,secondaryColor:e.secondaryColor,botName:e.botName,logo:e.logo,placeholder:e.placeholder,errorMessage:e.errorMessage,embedded:e.embedded,isLoggedIn:e.isLoggedIn,allowAnonAccess:e.allowAnonAccess,open:r,onOpenChange:n,footerText:e.footerText,footerLink:e.footerLink,tooltipText:e.tooltipText,onAnalyticsEvent:e.onAnalyticsEvent})});ec.displayName="ProgrammaticQABot";const rt={QA_ENDPOINT:"https://access-ai-grace1-external.ccs.uky.edu/access/chat/api/",RATING_ENDPOINT:"https://access-ai-grace1-external.ccs.uky.edu/access/chat/rating/",METRICS_API_ENDPOINT:"https://access-ai-grace1-external.ccs.uky.edu/access/xdmod/chat/api/",METRICS_RATING_ENDPOINT:"https://access-ai-grace1-external.ccs.uky.edu/access/xdmod/chat/rating/",METRICS_QUESTIONS_URL:"https://metrics.access-ci.org/qa_bot_faq",NETLIFY_BASE_URL:"https://access-jsm-api.netlify.app",DEFAULT_API_KEY:"demo-key"},Ke={BOT_NAME:"ACCESS Q&A",LOGO:"https://support.access-ci.org/themes/contrib/asp-theme/images/icons/ACCESS-arrrow.svg",WELCOME_MESSAGE:"Hello! What can I help you with?",WELCOME_MESSAGE_LOGGED_OUT:"To ask questions, please log in.",LOGIN_URL:"/login",PRIMARY_COLOR:"#1a5b6e",SECONDARY_COLOR:"#107180",TOOLTIP:"Ask me about ACCESS! 😊"},La={SESSION_ID:"access-qa-bot-session-id"};function tc({welcome:e,setTicketForm:t,isLoggedIn:r,trackEvent:n}){return{start:{message:e,options:["Ask a question about ACCESS","Open a Help Ticket","Usage and performance of ACCESS resources (XDMoD)","Report a security issue"],path:o=>(n({type:"chatbot_menu_selected",selection:o.userInput}),o.userInput==="Ask a question about ACCESS"?r?"go_ahead_and_ask":"qa_loop":o.userInput==="Open a Help Ticket"?(t({}),"help_ticket"):o.userInput==="Usage and performance of ACCESS resources (XDMoD)"?"metrics_intro":o.userInput==="Report a security issue"?(t({}),n({type:"chatbot_security_started"}),"security_incident"):"start")},go_ahead_and_ask:{message:`Go ahead and ask your question! I'll do my best to help.
|
|
43
43
|
|
|
44
44
|
<em>This assistant is powered by AI. Responses may not always be accurate. Do not share passwords or secrets.</em> <a href="https://support.access-ci.org/tools/access-qa-tool/privacy">Privacy Notice</a>`,renderHtml:["BOT"],path:"qa_loop"}}}let dr=null;function nc(e){dr=e}function W(){return dr?dr.ticketForm||{}:(console.warn("Form context not available, returning empty form"),{})}function ye(e={}){const t=W();return{...t,email:e.email||t.email,name:e.name||t.name,accessId:e.accessId||t.accessId}}function pr(e){return e&&e.length>0?`
|
|
45
45
|
Attachments: ${e.length} file(s) attached`:""}const wt={SUPPORT:17,LOGIN_ACCESS:30,LOGIN_PROVIDER:31,SECURITY:26};async function rc(e,t="support",r=[]){const o={support:wt.SUPPORT,general_help:wt.SUPPORT,loginAccess:wt.LOGIN_ACCESS,loginProvider:wt.LOGIN_PROVIDER,security:wt.SECURITY}[t]||wt.SUPPORT,A={serviceDeskId:t==="security"?3:2,requestTypeId:o,requestFieldValues:{...e}};return r.length>0&&(A.attachments=await Jl(r)),A}async function oc(e,t){var o,a;const n=`${rt.NETLIFY_BASE_URL}/api/v1/${t}`;try{const A=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!A.ok){let i="";try{const c=await A.text();try{const l=JSON.parse(c);i=l.message||l.error||c}catch{i=c}}catch{i=`HTTP ${A.status} ${A.statusText}`}return A.status===403?i="The ticket service is temporarily unavailable. Please try again later or contact support directly.":A.status===404?i="Ticket service not found. Please try again later.":A.status===500?i="Server error. Please try again later.":A.status===401&&(i="Authentication error with the ticket service. Please contact support."),{success:!1,status:A.status,error:i}}const s=await A.json();return{success:!0,ticketKey:(o=s.data)==null?void 0:o.ticketKey,ticketUrl:(a=s.data)==null?void 0:a.ticketUrl}}catch(A){return{success:!1,error:A instanceof Error?A.message:"Unknown error"}}}async function cn(e,t,r=[]){try{const n=await rc(e,t,r);return await oc(n,t==="security"?"security-incidents":"tickets")}catch(n){return{success:!1,error:n instanceof Error?n.message:"Unknown error"}}}function fr(e,t="ticket"){return e?e.success?e.ticketUrl&&e.ticketKey?`Your ${t} has been submitted successfully.
|