@mypatientspace/chatbot-widget 1.0.63 → 1.0.64
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.
|
@@ -14804,7 +14804,7 @@ const $l = () => {
|
|
|
14804
14804
|
/* @__PURE__ */ S.jsxs(g1, { fontFamily: s.fontFamily, children: [
|
|
14805
14805
|
M,
|
|
14806
14806
|
" v",
|
|
14807
|
-
"1.0.
|
|
14807
|
+
"1.0.64"
|
|
14808
14808
|
] })
|
|
14809
14809
|
] })
|
|
14810
14810
|
] }),
|
|
@@ -16506,7 +16506,7 @@ const Rp = U.div`
|
|
|
16506
16506
|
H(kt.target.value);
|
|
16507
16507
|
}, []), Rt = T.useCallback(() => {
|
|
16508
16508
|
P();
|
|
16509
|
-
}, [P]), Qt = u, L = u || !z.trim(), zt = s.disclaimerText ?? "AI can make mistakes. Verify important information.";
|
|
16509
|
+
}, [P]), Qt = u, L = u || !z.trim(), zt = s.disclaimerText ?? d?.chatUiConfig?.cautionaryMessageOnCompletions ?? "AI can make mistakes. Verify important information.";
|
|
16510
16510
|
T.useEffect(() => {
|
|
16511
16511
|
!M && !u && Q.current && Q.current.focus();
|
|
16512
16512
|
}, [M, u]);
|
|
@@ -730,9 +730,9 @@ Error generating stack: `+l.message+`
|
|
|
730
730
|
`):d=Y`
|
|
731
731
|
${ql.layout}
|
|
732
732
|
${ql.layoutPreviewOnly}
|
|
733
|
-
`,it("div",{className:"chatbot-demo-root",css:d,children:[k(pm,{styles:ql.global}),s&&k(Fm,{showJsonEditor:u.showJsonEditor!==!1,showDisplaySettings:u.showDisplaySettings!==!1,showApiSettings:u.showApiSettings!==!1,showAppearanceSettings:u.showAppearanceSettings!==!1,showThemeSettings:u.showThemeSettings!==!1,showContentSettings:u.showContentSettings!==!1,showQuickActions:u.showQuickActions!==!1}),r&&k(Im,{})]})}),Fs=T.memo(function({config:u}){const s=T.useCallback(()=>{},[]),r=T.useCallback(d=>{window.ChatbotWidget&&window.ChatbotWidget.update(d)},[]);return k(gm,{demoConfig:u,onReinitWidget:s,onUpdateWidget:r,children:k(Pm,{demoConfig:u})})}),
|
|
733
|
+
`,it("div",{className:"chatbot-demo-root",css:d,children:[k(pm,{styles:ql.global}),s&&k(Fm,{showJsonEditor:u.showJsonEditor!==!1,showDisplaySettings:u.showDisplaySettings!==!1,showApiSettings:u.showApiSettings!==!1,showAppearanceSettings:u.showAppearanceSettings!==!1,showThemeSettings:u.showThemeSettings!==!1,showContentSettings:u.showContentSettings!==!1,showQuickActions:u.showQuickActions!==!1}),r&&k(Im,{})]})}),Fs=T.memo(function({config:u}){const s=T.useCallback(()=>{},[]),r=T.useCallback(d=>{window.ChatbotWidget&&window.ChatbotWidget.update(d)},[]);return k(gm,{demoConfig:u,onReinitWidget:s,onUpdateWidget:r,children:k(Pm,{demoConfig:u})})}),ty={primary:"#00c2d1",primaryDark:"#017992",secondary:"#3c4d73",accent:"#33b1e6",accentLight:"#b8ebff",success:"#00dec4",info:"#30d7ed",background:"#ffffff",surface:"#fdfefe",text:"#3c4d73",textLight:"#6b7280",userBubble:"#00c2d1",userBubbleText:"#ffffff",botBubble:"#e0f7fa",botBubbleText:"#3c4d73",border:"#d1d5db",borderLight:"#e5e7eb",error:"#ef4444",errorBackground:"#fef2f2",white:"#ffffff",recording:"#ef4444",headerText:"#ffffff",scrollbarThumb:"rgba(60, 77, 115, 0.2)",scrollbarThumbHover:"rgba(60, 77, 115, 0.3)",surveyOptionBg:"#ffffff",surveyOptionBgHover:"#f8f9fa",surveyOptionBgSelected:"#e0f7fa",surveyOptionBorder:"#e5e7eb",surveyOptionBorderSelected:"#00c2d1",surveyNumberBg:"#3c4d73",surveyNumberText:"#ffffff",contentCardBg:"#ffffff",contentCardBorder:"#e5e7eb",contentCardText:"#3c4d73",contentCardTextLight:"#6b7280",contentCardOverlay:"rgba(0, 0, 0, 0.4)"},ey={primary:"#00d4e5",primaryDark:"#00a8b8",secondary:"#1e2b4a",accent:"#4fc3f7",accentLight:"#1a3a4a",success:"#00dec4",info:"#30d7ed",background:"#121820",surface:"#1a2330",text:"#e8eaed",textLight:"#9aa0a6",userBubble:"#00b8c9",userBubbleText:"#ffffff",botBubble:"#1e2b3a",botBubbleText:"#e8eaed",border:"#2d3a4a",borderLight:"#252f3f",error:"#f87171",errorBackground:"#2d1f1f",white:"#ffffff",recording:"#ef4444",headerText:"#ffffff",scrollbarThumb:"rgba(255, 255, 255, 0.2)",scrollbarThumbHover:"rgba(255, 255, 255, 0.3)",surveyOptionBg:"#1a2330",surveyOptionBgHover:"#252f3f",surveyOptionBgSelected:"#1a3a4a",surveyOptionBorder:"#2d3a4a",surveyOptionBorderSelected:"#00d4e5",surveyNumberBg:"#2d3a4a",surveyNumberText:"#e8eaed",contentCardBg:"#1a2330",contentCardBorder:"#2d3a4a",contentCardText:"#e8eaed",contentCardTextLight:"#9aa0a6",contentCardOverlay:"rgba(0, 0, 0, 0.6)"},Is={fontFamily:"system-ui, -apple-system, sans-serif",borderRadius:"12px"},ny=(a,u)=>{const s=a==="dark"?ey:ty,r=a==="dark"?"0 4px 24px rgba(0, 0, 0, 0.4)":"0 4px 24px rgba(60, 77, 115, 0.15)";return{colors:{...s,...u?.colors},fontFamily:u?.fontFamily||Is.fontFamily,borderRadius:u?.borderRadius||Is.borderRadius,shadow:u?.shadow||r}},ly=(a,u)=>{let{fullMessage:s}=u;const{callbacks:r}=u;return a.type==="content"?(s+=a.value,r.onChunk(a.value)):a.type==="status"?r.onStatus?.(a.value):a.type==="session_id"?r.onSessionId?.(a.value):a.type==="audio"?r.onAudio?.(a.value):a.type==="final"&&(r.onStatus?.("complete"),a.value&&r.onSessionId?.(a.value),a.content&&(s=a.content,r.onChunk(a.content)),a.askingQuestion&&a.questionInfo&&r.onSurveyQuestion?.(a.questionInfo,a.surveyProgress),a.citations&&a.citations.length>0&&r.onCitations?.(a.citations)),s},ju=a=>a.token,Ps=a=>a.replace(/\/patient\b/gi,"").replace(/\/?$/,""),ay=a=>{try{const u=new URL(a);return`${u.protocol}//${u.host}`}catch{return a.replace(/\/api\/.*$/,"")}},iy=async(a,u,s)=>{const{apiEndpoint:r}=u;if(!r){s.onError("No API endpoint configured");return}const d=ju(u),h=`${Ps(r)}/stream`,y={"Content-Type":"application/json",Accept:"text/event-stream"};d&&(y.Authorization=`Bearer ${d}`);const C={message:a};u.assistantId&&(C.assistantId=u.assistantId),u.contextPatientId&&(C.contextPatientId=u.contextPatientId),u.sessionId&&(C.sessionId=u.sessionId);try{const S=await fetch(h,{method:"POST",headers:y,body:JSON.stringify(C)});if(!S.ok)throw new Error(`HTTP error! status: ${S.status}`);const m=S.body?.getReader();if(!m)throw new Error("Response body is not readable");const M=new TextDecoder;let z="",U="",Q=!1;const W=G=>{const q=cy(G);if(q){if(q.type==="error")return Q=!0,s.onError(q.value),!0;z=ly(q,{fullMessage:z,callbacks:s})}return!1};for(;;){const{done:G,value:q}=await m.read();if(G){if(U.trim()&&!Q){const P=U.split(`
|
|
734
734
|
`);for(const X of P)if(W(X))break}Q||s.onComplete(z);break}U+=M.decode(q,{stream:!0});const J=U.split(`
|
|
735
|
-
`);U=J.pop()||"";for(const P of J)if(W(P))break;if(Q)break}}catch(S){const m=S instanceof Error?S.message:"Unknown error";s.onError(m)}},o0=a=>a.replace(/<[^>]*>/g,"").replace(/\s+/g," ").trim(),u0=(a,u)=>{if(u){const s=u.toUpperCase();if(s==="VIDEO")return"Video";if(s==="PDF")return"PDF";if(s==="AUDIO")return"Audio";if(s==="IMAGE")return"Article"}if(a&&a.toUpperCase()==="CONTENT_LIBRARY")return"Article"},r0=a=>({id:a.id,thumbnail:a.icon?.thumbnailURL||a.contents?.[0]?.thumbnailURL||a.icon?.contentURL||"",title:a.title||a.name||"",description:a.detailText?o0(a.detailText):"",content:a.contents?.[0]?.contentURL||a.icon?.contentURL||"",createdAt:a.createdOn?new Date(a.createdOn).toISOString():new Date().toISOString(),source:a.patientTypeText||void 0,contentType:u0(a.type,a.contents?.[0]?.format),contentFormat:a.contents?.[0]?.format?.toUpperCase()||void 0,audioRenditions:a.libraryRenditions?.map(u=>u.contentURL).filter(u=>!!u)||void 0,detailHtml:a.detailText||void 0}),c0=a=>{const u=a.trim();if(!u||u.startsWith(":"))return null;if(u.startsWith("data:")){const s=u.slice(5).trim();if(s==="[DONE]")return null;try{const r=JSON.parse(s);if(r.type)switch(r.type){case"token":return null;case"thinking":return{type:"status",value:"thinking"};case"reasoning":return{type:"status",value:"reasoning"};case"tool_start":case"tool_call":case"function_call":return{type:"status",value:"tool_start"};case"tool_end":case"tool_result":case"function_result":return{type:"status",value:"tool_end"};case"searching":case"search":return{type:"status",value:"searching"};case"reading":case"retrieving":return{type:"status",value:"reading"};case"generating":case"writing":return{type:"status",value:"generating"};case"summarizing":return{type:"status",value:"summarizing"};case"processing":return{type:"status",value:"processing"};case"audio":return r.audio?{type:"audio",value:r.audio}:null;case"canvas":return null;case"error":return{type:"error",value:r.message||r.error||"Unknown error"};case"final":return{type:"final",value:r.session_id||"",content:r.reply||"",askingQuestion:r.asking_question||!1,questionInfo:r.current_question_info,surveyProgress:r.survey_progress,citations:Array.isArray(r.citations)?r.citations.map(r0):void 0};case"close":case"message":case"response":case"complete":case"done":case"end":return null;default:return null}const d=r.delta?.content;return d?{type:"content",value:d}:null}catch{return{type:"content",value:s}}}return null},s0=async a=>{const{apiEndpoint:u}=a;if(!u)return{messages:[],error:"No API endpoint configured"};const s=ju(a),r=`${Ps(u)}/messages`,d=new URLSearchParams;a.assistantId&&d.append("assistantId",a.assistantId),a.contextPatientId&&d.append("contextPatientId",a.contextPatientId),d.append("limit","100");const h=`${r}?${d.toString()}`,y={};s&&(y.Authorization=`Bearer ${s}`);try{const C=await fetch(h,{method:"GET",headers:y});if(!C.ok){if(C.status===404)return{messages:[]};throw new Error(`HTTP error! status: ${C.status}`)}const S=await C.json(),m=S.messages||S.data||S;if(!Array.isArray(m))return{messages:[]};const M=m[0]?.sessionId;return{messages:m.map(U=>{const Q=U.role==="ai"?"bot":U.role==="human"?"user":U.sender||"bot";return{id:U.id||"",content:U.content,sender:Q,timestamp:U.createdOn?new Date(U.createdOn).toISOString():U.timestamp||new Date().toISOString(),status:U.status}}),sessionId:M}}catch(C){const S=C instanceof Error?C.message:"Unknown error";return{messages:[],error:S}}},f0=async a=>{const{apiEndpoint:u}=a;if(!u)return{assistants:[],error:"No API endpoint configured"};const s=ju(a),d=`${a0(u)}/api/patient/assistants/list`,h={};s&&(h.Authorization=`Bearer ${s}`);try{const y=await fetch(d,{method:"GET",headers:h});if(!y.ok)throw new Error(`HTTP error! status: ${y.status}`);const C=await y.json(),S=C.assistants||C.data||C;return Array.isArray(S)?{assistants:S.map(M=>({...M,id:M.id||"",name:M.name||""}))}:{assistants:[]}}catch(y){const C=y instanceof Error?y.message:"Unknown error";return{assistants:[],error:C}}},d0=a=>{const[u,s]=T.useState(()=>typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");return T.useEffect(()=>{if(a!=="system")return;const r=window.matchMedia("(prefers-color-scheme: dark)");s(r.matches?"dark":"light");const d=h=>{s(h.matches?"dark":"light")};return r.addEventListener("change",d),()=>r.removeEventListener("change",d)},[a]),a==="system"?u:a==="dark"?"dark":"light"},tf=T.createContext(null),dl=()=>`${Date.now()}-${Math.random().toString(36).substr(2,9)}`,h0=[{id:"1",thumbnail:"https://picsum.photos/seed/sleep1/300/200",title:"Coach Paul's Top Tips For Unwinding Before Bed",description:"Learn relaxation techniques for better sleep",content:"https://example.com/article/1",createdAt:new Date().toISOString(),source:"EXPERIENCE LIFE"},{id:"2",thumbnail:"https://picsum.photos/seed/sleep2/300/200",title:"4 Surprising Strategies To Maximize Quality Sleep",description:"Science-backed methods for deeper rest",content:"https://example.com/article/2",createdAt:new Date().toISOString(),source:"EXPERIENCE LIFE"},{id:"3",thumbnail:"https://picsum.photos/seed/health3/300/200",title:"Why Morning Routines Matter For Your Health",description:"Start your day right with these habits",content:"https://example.com/article/3",createdAt:new Date().toISOString(),source:"WELLNESS TIPS"},{id:"4",thumbnail:"https://picsum.photos/seed/exercise4/300/200",title:"Simple Exercises You Can Do At Home",description:"Stay active without a gym membership",content:"https://example.com/article/4",createdAt:new Date().toISOString(),source:"FITNESS TODAY"}],p0=({config:a,children:u,onConfigUpdate:s})=>{const[r,d]=T.useState(a),[h,y]=T.useState([]),[C,S]=T.useState(!(r.floatingMode??!1)),[m,M]=T.useState(!1),[z,U]=T.useState(!1),[Q,W]=T.useState(void 0),[G,q]=T.useState(!1),[J,P]=T.useState(!1),[X,ut]=T.useState(null),[j,ot]=T.useState(null),[Z,Rt]=T.useState(null),[Qt,L]=T.useState(null),[Mt,Lt]=T.useState(null),kt=d0(r.colorMode),ve=T.useMemo(()=>{const St=X?.chatUiConfig?.theme,xt=r.theme,Ot=n0(kt);return{colors:{...Ot.colors,...St?.colors,...xt?.colors},fontFamily:xt?.fontFamily||St?.fontFamily||Ot.fontFamily,borderRadius:xt?.borderRadius||St?.borderRadius||Ot.borderRadius,shadow:xt?.shadow||St?.shadow||Ot.shadow}},[r.theme,kt,X?.chatUiConfig?.theme]),Ce=T.useCallback(St=>{d(xt=>({...xt,...St}))},[]);T.useEffect(()=>{s?.(Ce)},[s,Ce]);const $=T.useRef(null),V=T.useRef(!1);T.useEffect(()=>{(async()=>{if(!(!C||J)){if(Rt(null),r.loadHistory===!1){P(!0);return}try{if(!r.token){P(!0);return}let xt=r.assistantId;if(!xt){const ht=await f0(r);if(ht.error){console.error("Failed to load assistants:",ht.error),Rt(ht.error),P(!0);return}const Nt=ht.assistants[0];if(!Nt){console.warn("No assistants found"),P(!0);return}ut(Nt),xt=Nt.id}const Ot={...r,assistantId:xt},Te=await s0(Ot);if(Te.error){console.error("Failed to load messages:",Te.error),Rt(Te.error),P(!0);return}if(Te.sessionId&&ot(Te.sessionId),Te.messages.length>0){const ht=Te.messages.map(Nt=>({id:Nt.id||dl(),content:Nt.content,sender:Nt.sender,timestamp:new Date(Nt.timestamp),status:Nt.status||"sent"}));y(ht),q(!0)}}catch(xt){console.error("Failed to load chat history:",xt)}P(!0)}})()},[C,J,r]),T.useEffect(()=>{if(C&&!G&&J){if(Z){const xt={id:dl(),content:`Unable to connect: ${Z}`,sender:"bot",timestamp:new Date,status:"error"};y([xt]),q(!0);return}const St=r.greeting||X?.chatUiConfig?.welcomeMessage||"Hello! Welcome to our healthcare support. How can I assist you today?";{const xt={id:dl(),content:St,sender:"bot",timestamp:new Date,status:"sent",citations:r.apiEndpoint?void 0:h0};y(Ot=>Ot.length===0?[xt]:Ot)}q(!0)}},[C,G,r.greeting,J,X,Z]);const lt=T.useCallback(()=>{S(!0),r.onOpen?.()},[r]),Ct=T.useCallback(()=>{S(!1),M(!1),r.onClose?.()},[r]),$t=T.useCallback(()=>{M(St=>!St)},[]),v=T.useCallback(()=>{C?Ct():lt()},[C,lt,Ct]),B=T.useCallback(async St=>{if(!St.trim())return;const xt={id:dl(),content:St.trim(),sender:"user",timestamp:new Date,status:"sending"};y(ht=>[...ht,{...xt,status:"sent"}]),r.onMessageSent?.(xt),U(!0),W("thinking");const Ot=dl();$.current=Ot,V.current=!1;const Te={...r,...X&&{assistantId:X.id},...j&&{sessionId:j}};await i0(St,Te,{onChunk:ht=>{if(V.current)y(Nt=>Nt.map(Zt=>Zt.id===Ot?{...Zt,content:Zt.content+ht}:Zt));else{V.current=!0,W(void 0);const Nt={id:Ot,content:ht,sender:"bot",timestamp:new Date,status:"sending"};y(Zt=>[...Zt,Nt])}r.onStreamChunk?.(ht)},onStatus:ht=>{ht==="complete"?(W(void 0),U(!1)):W(ht)},onSessionId:ht=>{ot(ht)},onAudio:ht=>{const Nt=`data:audio/mp3;base64,${ht}`;y(Zt=>Zt.map(Ee=>Ee.id===Ot?{...Ee,audioUrl:Nt}:Ee))},onComplete:ht=>{U(!1),W(void 0),$.current=null,V.current&&y(Nt=>{const Zt=Nt.map(hn=>hn.id===Ot?{...hn,content:ht,status:"sent"}:hn),Ee=Zt.find(hn=>hn.id===Ot);return Ee&&r.onMessageReceived?.(Ee),Zt})},onError:ht=>{U(!1),W(void 0),$.current=null,console.error("Stream error:",ht),y(Nt=>{const Zt=Nt.filter(hn=>hn.id!==Ot),Ee={id:Ot,content:`Error: ${ht}`,sender:"bot",timestamp:new Date,status:"error"};return[...Zt,Ee]})},onSurveyQuestion:(ht,Nt)=>{L(ht),Lt(Nt||null),y(Zt=>Zt.map(Ee=>Ee.id===Ot?{...Ee,askingQuestion:!0,questionInfo:ht,surveyProgress:Nt}:Ee))},onCitations:ht=>{y(Nt=>Nt.map(Zt=>Zt.id===Ot?{...Zt,citations:ht}:Zt))}})},[r,X,j]),K=T.useCallback(async St=>{if(!Qt)return;let xt;Array.isArray(St)?xt=St.join(", "):typeof St=="boolean"?xt=St?"Yes":"No":xt=String(St);const Ot=`Q: ${Qt.question}<br>A: ${xt}`;L(null),Lt(null),await B(Ot)},[Qt,B]),I=T.useCallback(async()=>{Qt&&(L(null),Lt(null),await B("Skip"))},[Qt,B]),ct=T.useCallback(()=>{y([]),ot(null),q(!1),L(null),Lt(null),U(!1),W(void 0),Rt(null),r.onNewChat?.()},[r]),dt=T.useCallback(async()=>{L(null),Lt(null),await B("Cancel survey")},[B]),vt=T.useCallback((St,xt)=>{const Ot={id:dl(),content:St.question,sender:"bot",timestamp:new Date,status:"sent",askingQuestion:!0,questionInfo:St,surveyProgress:xt};y(Te=>[...Te,Ot]),L(St),Lt(xt||null)},[]),oe=T.useCallback(St=>{const xt={id:dl(),content:"Here are some resources that might help you:",sender:"bot",timestamp:new Date,status:"sent",citations:St};y(Ot=>[...Ot,xt])},[]);T.useEffect(()=>{J&&r.onWidgetReady&&r.onWidgetReady({triggerSurveyQuestion:vt,triggerCitations:oe})},[J,r.onWidgetReady,vt,oe]);const Vt={messages:h,isOpen:C,isTyping:z,isLoading:!J,isExpanded:m,streamingStatus:Q,config:r,theme:ve,assistant:X,sendMessage:B,open:lt,close:Ct,toggle:v,toggleExpanded:$t,currentQuestion:Qt,surveyProgress:Mt,submitSurveyAnswer:K,skipSurveyQuestion:I,cancelSurvey:dt,triggerSurveyQuestion:vt,startNewChat:ct};return x.jsx(tf.Provider,{value:Vt,children:u})};var g0=/^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|disableRemotePlayback|download|draggable|encType|enterKeyHint|fetchpriority|fetchPriority|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|popover|popoverTarget|popoverTargetAction|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/,m0=Cs(function(a){return g0.test(a)||a.charCodeAt(0)===111&&a.charCodeAt(1)===110&&a.charCodeAt(2)<91}),y0=m0,b0=function(u){return u!=="theme"},ef=function(u){return typeof u=="string"&&u.charCodeAt(0)>96?y0:b0},nf=function(u,s,r){var d;if(s){var h=s.shouldForwardProp;d=u.__emotion_forwardProp&&h?function(y){return u.__emotion_forwardProp(y)&&h(y)}:h}return typeof d!="function"&&r&&(d=u.__emotion_forwardProp),d},v0=function(u){var s=u.cache,r=u.serialized,d=u.isStringTag;return Au(s,r,d),Ns(function(){return Mu(s,r,d)}),null},x0=function a(u,s){var r=u.__emotion_real===u,d=r&&u.__emotion_base||u,h,y;s!==void 0&&(h=s.label,y=s.target);var C=nf(u,s,r),S=C||ef(d),m=!S("as");return function(){var M=arguments,z=r&&u.__emotion_styles!==void 0?u.__emotion_styles.slice(0):[];if(h!==void 0&&z.push("label:"+h+";"),M[0]==null||M[0].raw===void 0)z.push.apply(z,M);else{var U=M[0];z.push(U[0]);for(var Q=M.length,W=1;W<Q;W++)z.push(M[W],U[W])}var G=Ou(function(q,J,P){var X=m&&q.as||d,ut="",j=[],ot=q;if(q.theme==null){ot={};for(var Z in q)ot[Z]=q[Z];ot.theme=T.useContext($u)}typeof q.className=="string"?ut=ws(J.registered,j,q.className):q.className!=null&&(ut=q.className+" ");var Rt=ki(z.concat(j),J.registered,ot);ut+=J.key+"-"+Rt.name,y!==void 0&&(ut+=" "+y);var Qt=m&&C===void 0?ef(X):S,L={};for(var Mt in q)m&&Mt==="as"||Qt(Mt)&&(L[Mt]=q[Mt]);return L.className=ut,P&&(L.ref=P),T.createElement(T.Fragment,null,T.createElement(v0,{cache:J,serialized:Rt,isStringTag:typeof X=="string"}),T.createElement(X,L))});return G.displayName=h!==void 0?h:"Styled("+(typeof d=="string"?d:d.displayName||d.name||"Component")+")",G.defaultProps=u.defaultProps,G.__emotion_real=G,G.__emotion_base=d,G.__emotion_styles=z,G.__emotion_forwardProp=C,Object.defineProperty(G,"toString",{value:function(){return"."+y}}),G.withComponent=function(q,J){var P=a(q,Tu({},s,J,{shouldForwardProp:nf(G,J,!0)}));return P.apply(void 0,z)},G}},S0=["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","marquee","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"],H=x0.bind(null);S0.forEach(function(a){H[a]=H(a)});const hl=()=>{const a=T.useContext(tf);if(!a)throw new Error("useChat must be used within a ChatProvider");return a},C0=H.div`
|
|
735
|
+
`);U=J.pop()||"";for(const P of J)if(W(P))break;if(Q)break}}catch(S){const m=S instanceof Error?S.message:"Unknown error";s.onError(m)}},oy=a=>a.replace(/<[^>]*>/g,"").replace(/\s+/g," ").trim(),uy=(a,u)=>{if(u){const s=u.toUpperCase();if(s==="VIDEO")return"Video";if(s==="PDF")return"PDF";if(s==="AUDIO")return"Audio";if(s==="IMAGE")return"Article"}if(a&&a.toUpperCase()==="CONTENT_LIBRARY")return"Article"},ry=a=>({id:a.id,thumbnail:a.icon?.thumbnailURL||a.contents?.[0]?.thumbnailURL||a.icon?.contentURL||"",title:a.title||a.name||"",description:a.detailText?oy(a.detailText):"",content:a.contents?.[0]?.contentURL||a.icon?.contentURL||"",createdAt:a.createdOn?new Date(a.createdOn).toISOString():new Date().toISOString(),source:a.patientTypeText||void 0,contentType:uy(a.type,a.contents?.[0]?.format),contentFormat:a.contents?.[0]?.format?.toUpperCase()||void 0,audioRenditions:a.libraryRenditions?.map(u=>u.contentURL).filter(u=>!!u)||void 0,detailHtml:a.detailText||void 0}),cy=a=>{const u=a.trim();if(!u||u.startsWith(":"))return null;if(u.startsWith("data:")){const s=u.slice(5).trim();if(s==="[DONE]")return null;try{const r=JSON.parse(s);if(r.type)switch(r.type){case"token":return null;case"thinking":return{type:"status",value:"thinking"};case"reasoning":return{type:"status",value:"reasoning"};case"tool_start":case"tool_call":case"function_call":return{type:"status",value:"tool_start"};case"tool_end":case"tool_result":case"function_result":return{type:"status",value:"tool_end"};case"searching":case"search":return{type:"status",value:"searching"};case"reading":case"retrieving":return{type:"status",value:"reading"};case"generating":case"writing":return{type:"status",value:"generating"};case"summarizing":return{type:"status",value:"summarizing"};case"processing":return{type:"status",value:"processing"};case"audio":return r.audio?{type:"audio",value:r.audio}:null;case"canvas":return null;case"error":return{type:"error",value:r.message||r.error||"Unknown error"};case"final":return{type:"final",value:r.session_id||"",content:r.reply||"",askingQuestion:r.asking_question||!1,questionInfo:r.current_question_info,surveyProgress:r.survey_progress,citations:Array.isArray(r.citations)?r.citations.map(ry):void 0};case"close":case"message":case"response":case"complete":case"done":case"end":return null;default:return null}const d=r.delta?.content;return d?{type:"content",value:d}:null}catch{return{type:"content",value:s}}}return null},sy=async a=>{const{apiEndpoint:u}=a;if(!u)return{messages:[],error:"No API endpoint configured"};const s=ju(a),r=`${Ps(u)}/messages`,d=new URLSearchParams;a.assistantId&&d.append("assistantId",a.assistantId),a.contextPatientId&&d.append("contextPatientId",a.contextPatientId),d.append("limit","100");const h=`${r}?${d.toString()}`,y={};s&&(y.Authorization=`Bearer ${s}`);try{const C=await fetch(h,{method:"GET",headers:y});if(!C.ok){if(C.status===404)return{messages:[]};throw new Error(`HTTP error! status: ${C.status}`)}const S=await C.json(),m=S.messages||S.data||S;if(!Array.isArray(m))return{messages:[]};const M=m[0]?.sessionId;return{messages:m.map(U=>{const Q=U.role==="ai"?"bot":U.role==="human"?"user":U.sender||"bot";return{id:U.id||"",content:U.content,sender:Q,timestamp:U.createdOn?new Date(U.createdOn).toISOString():U.timestamp||new Date().toISOString(),status:U.status}}),sessionId:M}}catch(C){const S=C instanceof Error?C.message:"Unknown error";return{messages:[],error:S}}},fy=async a=>{const{apiEndpoint:u}=a;if(!u)return{assistants:[],error:"No API endpoint configured"};const s=ju(a),d=`${ay(u)}/api/patient/assistants/list`,h={};s&&(h.Authorization=`Bearer ${s}`);try{const y=await fetch(d,{method:"GET",headers:h});if(!y.ok)throw new Error(`HTTP error! status: ${y.status}`);const C=await y.json(),S=C.assistants||C.data||C;return Array.isArray(S)?{assistants:S.map(M=>({...M,id:M.id||"",name:M.name||""}))}:{assistants:[]}}catch(y){const C=y instanceof Error?y.message:"Unknown error";return{assistants:[],error:C}}},dy=a=>{const[u,s]=T.useState(()=>typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");return T.useEffect(()=>{if(a!=="system")return;const r=window.matchMedia("(prefers-color-scheme: dark)");s(r.matches?"dark":"light");const d=h=>{s(h.matches?"dark":"light")};return r.addEventListener("change",d),()=>r.removeEventListener("change",d)},[a]),a==="system"?u:a==="dark"?"dark":"light"},tf=T.createContext(null),dl=()=>`${Date.now()}-${Math.random().toString(36).substr(2,9)}`,hy=[{id:"1",thumbnail:"https://picsum.photos/seed/sleep1/300/200",title:"Coach Paul's Top Tips For Unwinding Before Bed",description:"Learn relaxation techniques for better sleep",content:"https://example.com/article/1",createdAt:new Date().toISOString(),source:"EXPERIENCE LIFE"},{id:"2",thumbnail:"https://picsum.photos/seed/sleep2/300/200",title:"4 Surprising Strategies To Maximize Quality Sleep",description:"Science-backed methods for deeper rest",content:"https://example.com/article/2",createdAt:new Date().toISOString(),source:"EXPERIENCE LIFE"},{id:"3",thumbnail:"https://picsum.photos/seed/health3/300/200",title:"Why Morning Routines Matter For Your Health",description:"Start your day right with these habits",content:"https://example.com/article/3",createdAt:new Date().toISOString(),source:"WELLNESS TIPS"},{id:"4",thumbnail:"https://picsum.photos/seed/exercise4/300/200",title:"Simple Exercises You Can Do At Home",description:"Stay active without a gym membership",content:"https://example.com/article/4",createdAt:new Date().toISOString(),source:"FITNESS TODAY"}],py=({config:a,children:u,onConfigUpdate:s})=>{const[r,d]=T.useState(a),[h,y]=T.useState([]),[C,S]=T.useState(!(r.floatingMode??!1)),[m,M]=T.useState(!1),[z,U]=T.useState(!1),[Q,W]=T.useState(void 0),[G,q]=T.useState(!1),[J,P]=T.useState(!1),[X,ut]=T.useState(null),[j,ot]=T.useState(null),[Z,Rt]=T.useState(null),[Qt,L]=T.useState(null),[Mt,Lt]=T.useState(null),kt=dy(r.colorMode),ve=T.useMemo(()=>{const St=X?.chatUiConfig?.theme,xt=r.theme,Ot=ny(kt);return{colors:{...Ot.colors,...St?.colors,...xt?.colors},fontFamily:xt?.fontFamily||St?.fontFamily||Ot.fontFamily,borderRadius:xt?.borderRadius||St?.borderRadius||Ot.borderRadius,shadow:xt?.shadow||St?.shadow||Ot.shadow}},[r.theme,kt,X?.chatUiConfig?.theme]),Ce=T.useCallback(St=>{d(xt=>({...xt,...St}))},[]);T.useEffect(()=>{s?.(Ce)},[s,Ce]);const $=T.useRef(null),V=T.useRef(!1);T.useEffect(()=>{(async()=>{if(!(!C||J)){if(Rt(null),r.loadHistory===!1){P(!0);return}try{if(!r.token){P(!0);return}let xt=r.assistantId;if(!xt){const ht=await fy(r);if(ht.error){console.error("Failed to load assistants:",ht.error),Rt(ht.error),P(!0);return}const Nt=ht.assistants[0];if(!Nt){console.warn("No assistants found"),P(!0);return}ut(Nt),xt=Nt.id}const Ot={...r,assistantId:xt},Te=await sy(Ot);if(Te.error){console.error("Failed to load messages:",Te.error),Rt(Te.error),P(!0);return}if(Te.sessionId&&ot(Te.sessionId),Te.messages.length>0){const ht=Te.messages.map(Nt=>({id:Nt.id||dl(),content:Nt.content,sender:Nt.sender,timestamp:new Date(Nt.timestamp),status:Nt.status||"sent"}));y(ht),q(!0)}}catch(xt){console.error("Failed to load chat history:",xt)}P(!0)}})()},[C,J,r]),T.useEffect(()=>{if(C&&!G&&J){if(Z){const xt={id:dl(),content:`Unable to connect: ${Z}`,sender:"bot",timestamp:new Date,status:"error"};y([xt]),q(!0);return}const St=r.greeting||X?.chatUiConfig?.welcomeMessage||"Hello! Welcome to our healthcare support. How can I assist you today?";{const xt={id:dl(),content:St,sender:"bot",timestamp:new Date,status:"sent",citations:r.apiEndpoint?void 0:hy};y(Ot=>Ot.length===0?[xt]:Ot)}q(!0)}},[C,G,r.greeting,J,X,Z]);const lt=T.useCallback(()=>{S(!0),r.onOpen?.()},[r]),Ct=T.useCallback(()=>{S(!1),M(!1),r.onClose?.()},[r]),$t=T.useCallback(()=>{M(St=>!St)},[]),v=T.useCallback(()=>{C?Ct():lt()},[C,lt,Ct]),B=T.useCallback(async St=>{if(!St.trim())return;const xt={id:dl(),content:St.trim(),sender:"user",timestamp:new Date,status:"sending"};y(ht=>[...ht,{...xt,status:"sent"}]),r.onMessageSent?.(xt),U(!0),W("thinking");const Ot=dl();$.current=Ot,V.current=!1;const Te={...r,...X&&{assistantId:X.id},...j&&{sessionId:j}};await iy(St,Te,{onChunk:ht=>{if(V.current)y(Nt=>Nt.map(Zt=>Zt.id===Ot?{...Zt,content:Zt.content+ht}:Zt));else{V.current=!0,W(void 0);const Nt={id:Ot,content:ht,sender:"bot",timestamp:new Date,status:"sending"};y(Zt=>[...Zt,Nt])}r.onStreamChunk?.(ht)},onStatus:ht=>{ht==="complete"?(W(void 0),U(!1)):W(ht)},onSessionId:ht=>{ot(ht)},onAudio:ht=>{const Nt=`data:audio/mp3;base64,${ht}`;y(Zt=>Zt.map(Ee=>Ee.id===Ot?{...Ee,audioUrl:Nt}:Ee))},onComplete:ht=>{U(!1),W(void 0),$.current=null,V.current&&y(Nt=>{const Zt=Nt.map(hn=>hn.id===Ot?{...hn,content:ht,status:"sent"}:hn),Ee=Zt.find(hn=>hn.id===Ot);return Ee&&r.onMessageReceived?.(Ee),Zt})},onError:ht=>{U(!1),W(void 0),$.current=null,console.error("Stream error:",ht),y(Nt=>{const Zt=Nt.filter(hn=>hn.id!==Ot),Ee={id:Ot,content:`Error: ${ht}`,sender:"bot",timestamp:new Date,status:"error"};return[...Zt,Ee]})},onSurveyQuestion:(ht,Nt)=>{L(ht),Lt(Nt||null),y(Zt=>Zt.map(Ee=>Ee.id===Ot?{...Ee,askingQuestion:!0,questionInfo:ht,surveyProgress:Nt}:Ee))},onCitations:ht=>{y(Nt=>Nt.map(Zt=>Zt.id===Ot?{...Zt,citations:ht}:Zt))}})},[r,X,j]),K=T.useCallback(async St=>{if(!Qt)return;let xt;Array.isArray(St)?xt=St.join(", "):typeof St=="boolean"?xt=St?"Yes":"No":xt=String(St);const Ot=`Q: ${Qt.question}<br>A: ${xt}`;L(null),Lt(null),await B(Ot)},[Qt,B]),I=T.useCallback(async()=>{Qt&&(L(null),Lt(null),await B("Skip"))},[Qt,B]),ct=T.useCallback(()=>{y([]),ot(null),q(!1),L(null),Lt(null),U(!1),W(void 0),Rt(null),r.onNewChat?.()},[r]),dt=T.useCallback(async()=>{L(null),Lt(null),await B("Cancel survey")},[B]),vt=T.useCallback((St,xt)=>{const Ot={id:dl(),content:St.question,sender:"bot",timestamp:new Date,status:"sent",askingQuestion:!0,questionInfo:St,surveyProgress:xt};y(Te=>[...Te,Ot]),L(St),Lt(xt||null)},[]),oe=T.useCallback(St=>{const xt={id:dl(),content:"Here are some resources that might help you:",sender:"bot",timestamp:new Date,status:"sent",citations:St};y(Ot=>[...Ot,xt])},[]);T.useEffect(()=>{J&&r.onWidgetReady&&r.onWidgetReady({triggerSurveyQuestion:vt,triggerCitations:oe})},[J,r.onWidgetReady,vt,oe]);const Vt={messages:h,isOpen:C,isTyping:z,isLoading:!J,isExpanded:m,streamingStatus:Q,config:r,theme:ve,assistant:X,sendMessage:B,open:lt,close:Ct,toggle:v,toggleExpanded:$t,currentQuestion:Qt,surveyProgress:Mt,submitSurveyAnswer:K,skipSurveyQuestion:I,cancelSurvey:dt,triggerSurveyQuestion:vt,startNewChat:ct};return x.jsx(tf.Provider,{value:Vt,children:u})};var gy=/^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|disableRemotePlayback|download|draggable|encType|enterKeyHint|fetchpriority|fetchPriority|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|popover|popoverTarget|popoverTargetAction|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/,my=Cs(function(a){return gy.test(a)||a.charCodeAt(0)===111&&a.charCodeAt(1)===110&&a.charCodeAt(2)<91}),yy=my,by=function(u){return u!=="theme"},ef=function(u){return typeof u=="string"&&u.charCodeAt(0)>96?yy:by},nf=function(u,s,r){var d;if(s){var h=s.shouldForwardProp;d=u.__emotion_forwardProp&&h?function(y){return u.__emotion_forwardProp(y)&&h(y)}:h}return typeof d!="function"&&r&&(d=u.__emotion_forwardProp),d},vy=function(u){var s=u.cache,r=u.serialized,d=u.isStringTag;return Au(s,r,d),Ns(function(){return Mu(s,r,d)}),null},xy=function a(u,s){var r=u.__emotion_real===u,d=r&&u.__emotion_base||u,h,y;s!==void 0&&(h=s.label,y=s.target);var C=nf(u,s,r),S=C||ef(d),m=!S("as");return function(){var M=arguments,z=r&&u.__emotion_styles!==void 0?u.__emotion_styles.slice(0):[];if(h!==void 0&&z.push("label:"+h+";"),M[0]==null||M[0].raw===void 0)z.push.apply(z,M);else{var U=M[0];z.push(U[0]);for(var Q=M.length,W=1;W<Q;W++)z.push(M[W],U[W])}var G=Ou(function(q,J,P){var X=m&&q.as||d,ut="",j=[],ot=q;if(q.theme==null){ot={};for(var Z in q)ot[Z]=q[Z];ot.theme=T.useContext($u)}typeof q.className=="string"?ut=ws(J.registered,j,q.className):q.className!=null&&(ut=q.className+" ");var Rt=ki(z.concat(j),J.registered,ot);ut+=J.key+"-"+Rt.name,y!==void 0&&(ut+=" "+y);var Qt=m&&C===void 0?ef(X):S,L={};for(var Mt in q)m&&Mt==="as"||Qt(Mt)&&(L[Mt]=q[Mt]);return L.className=ut,P&&(L.ref=P),T.createElement(T.Fragment,null,T.createElement(vy,{cache:J,serialized:Rt,isStringTag:typeof X=="string"}),T.createElement(X,L))});return G.displayName=h!==void 0?h:"Styled("+(typeof d=="string"?d:d.displayName||d.name||"Component")+")",G.defaultProps=u.defaultProps,G.__emotion_real=G,G.__emotion_base=d,G.__emotion_styles=z,G.__emotion_forwardProp=C,Object.defineProperty(G,"toString",{value:function(){return"."+y}}),G.withComponent=function(q,J){var P=a(q,Tu({},s,J,{shouldForwardProp:nf(G,J,!0)}));return P.apply(void 0,z)},G}},Sy=["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","marquee","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"],H=xy.bind(null);Sy.forEach(function(a){H[a]=H(a)});const hl=()=>{const a=T.useContext(tf);if(!a)throw new Error("useChat must be used within a ChatProvider");return a},Cy=H.div`
|
|
736
736
|
display: flex;
|
|
737
737
|
align-items: center;
|
|
738
738
|
justify-content: space-between;
|
|
@@ -740,11 +740,11 @@ Error generating stack: `+l.message+`
|
|
|
740
740
|
background-color: ${({theme:a})=>a.colors.secondary};
|
|
741
741
|
color: ${({theme:a})=>a.colors.headerText};
|
|
742
742
|
border-radius: ${({theme:a})=>a.borderRadius} ${({theme:a})=>a.borderRadius} 0 0;
|
|
743
|
-
`,
|
|
743
|
+
`,Ty=H.div`
|
|
744
744
|
display: flex;
|
|
745
745
|
align-items: center;
|
|
746
746
|
gap: 12px;
|
|
747
|
-
`,
|
|
747
|
+
`,Ey=H.div`
|
|
748
748
|
display: flex;
|
|
749
749
|
align-items: center;
|
|
750
750
|
justify-content: center;
|
|
@@ -752,27 +752,27 @@ Error generating stack: `+l.message+`
|
|
|
752
752
|
height: 40px;
|
|
753
753
|
border-radius: ${({hasCustomIcon:a})=>a?"0":"50%"};
|
|
754
754
|
background-color: ${({hasCustomIcon:a,theme:u})=>a?"transparent":`${u.colors.headerText}33`};
|
|
755
|
-
`,
|
|
755
|
+
`,zy=H.img`
|
|
756
756
|
width: 100%;
|
|
757
757
|
height: 100%;
|
|
758
758
|
object-fit: contain;
|
|
759
|
-
`,
|
|
759
|
+
`,Ay=H.div`
|
|
760
760
|
display: flex;
|
|
761
761
|
flex-direction: column;
|
|
762
|
-
`,
|
|
762
|
+
`,My=H.h2`
|
|
763
763
|
margin: 0;
|
|
764
764
|
font-size: 16px;
|
|
765
765
|
font-weight: 600;
|
|
766
766
|
font-family: ${({fontFamily:a})=>a};
|
|
767
767
|
line-height: 1.2;
|
|
768
|
-
`,
|
|
768
|
+
`,_y=H.span`
|
|
769
769
|
margin: 0;
|
|
770
770
|
font-size: 12px;
|
|
771
771
|
font-weight: 400;
|
|
772
772
|
font-family: ${({fontFamily:a})=>a};
|
|
773
773
|
opacity: 0.9;
|
|
774
774
|
line-height: 1.2;
|
|
775
|
-
`,
|
|
775
|
+
`,wy=H.div`
|
|
776
776
|
display: flex;
|
|
777
777
|
align-items: center;
|
|
778
778
|
gap: 4px;
|
|
@@ -802,11 +802,11 @@ Error generating stack: `+l.message+`
|
|
|
802
802
|
&:active {
|
|
803
803
|
background-color: ${({theme:a})=>`${a.colors.headerText}66`};
|
|
804
804
|
}
|
|
805
|
-
`,
|
|
805
|
+
`,Oy=H.div`
|
|
806
806
|
display: flex;
|
|
807
807
|
align-items: center;
|
|
808
808
|
gap: 6px;
|
|
809
|
-
`,$
|
|
809
|
+
`,$y=()=>{const{close:a,config:u,theme:s,assistant:r,isExpanded:d,toggleExpanded:h,startNewChat:y}=hl(),C=u.headerTitle||r?.chatUiConfig?.avatarTitle||"AI Doctor",S=u.headerIcon||r?.chatUiConfig?.avatarImage?.iconURL||r?.chatUiConfig?.avatarImage?.thumbnailURL||"https://web.mypatientspace.com/img/logo-symbol.png",m=u.headerSubtitle||r?.chatUiConfig?.headerSubtitle,M=u.brandingText||r?.chatUiConfig?.brandingText||"Developed by myPatientSpace";return x.jsxs(Cy,{theme:s,children:[x.jsxs(Ty,{children:[x.jsx(Ey,{theme:s,hasCustomIcon:!0,children:x.jsx(zy,{src:S,alt:""})}),x.jsxs(Ay,{children:[x.jsx(My,{fontFamily:s.fontFamily,children:C}),m&&x.jsx(_y,{fontFamily:s.fontFamily,children:m}),x.jsxs(wy,{fontFamily:s.fontFamily,children:[M," v","1.0.64"]})]})]}),x.jsxs(Oy,{children:[x.jsx(Hu,{theme:s,onClick:y,"aria-label":"Start new chat",children:x.jsx(wm,{size:16})}),x.jsx(Hu,{theme:s,onClick:h,"aria-label":d?"Collapse chat":"Expand chat",children:d?x.jsx(Xs,{size:16}):x.jsx(Gs,{size:16})}),u.floatingMode&&x.jsx(Hu,{theme:s,onClick:a,"aria-label":"Minimize chat",children:x.jsx(Ys,{size:16})})]})]})},Dy=H.div`
|
|
810
810
|
position: relative;
|
|
811
811
|
background-color: ${({theme:a})=>a.colors.background};
|
|
812
812
|
border-bottom: 1px solid ${({theme:a})=>a.colors.borderLight};
|
|
@@ -814,7 +814,7 @@ Error generating stack: `+l.message+`
|
|
|
814
814
|
&:hover .close-button {
|
|
815
815
|
opacity: 1;
|
|
816
816
|
}
|
|
817
|
-
`,
|
|
817
|
+
`,By=H.button`
|
|
818
818
|
position: absolute;
|
|
819
819
|
top: 0;
|
|
820
820
|
right: 0;
|
|
@@ -837,7 +837,7 @@ Error generating stack: `+l.message+`
|
|
|
837
837
|
color: ${({theme:a})=>a.colors.text};
|
|
838
838
|
background-color: ${({theme:a})=>a.colors.border};
|
|
839
839
|
}
|
|
840
|
-
`,
|
|
840
|
+
`,Ry=H.div`
|
|
841
841
|
display: flex;
|
|
842
842
|
gap: 6px;
|
|
843
843
|
padding: 16px 12px 8px;
|
|
@@ -849,7 +849,7 @@ Error generating stack: `+l.message+`
|
|
|
849
849
|
&::-webkit-scrollbar {
|
|
850
850
|
display: none;
|
|
851
851
|
}
|
|
852
|
-
`,
|
|
852
|
+
`,Ny=H.button`
|
|
853
853
|
display: flex;
|
|
854
854
|
align-items: center;
|
|
855
855
|
gap: 4px;
|
|
@@ -880,7 +880,7 @@ Error generating stack: `+l.message+`
|
|
|
880
880
|
cursor: not-allowed;
|
|
881
881
|
transform: none;
|
|
882
882
|
}
|
|
883
|
-
`,
|
|
883
|
+
`,jy=()=>{const{config:a,theme:u,sendMessage:s,assistant:r,isTyping:d}=hl(),h=T.useRef(null),[y,C]=T.useState(!1),S=a.quickActions?.length?a.quickActions:r?.chatUiConfig?.initialPrompts||[];if(S.length===0||y)return null;const m=z=>{a.onQuickAction?.(z),s(z)},M=z=>{h.current&&z.deltaY!==0&&(z.preventDefault(),h.current.scrollLeft+=z.deltaY)};return x.jsxs(Dy,{theme:u,children:[x.jsx(By,{className:"close-button",theme:u,onClick:()=>C(!0),"aria-label":"Dismiss quick actions",children:x.jsx(qi,{size:10})}),x.jsx(Ry,{ref:h,onWheel:M,children:S.map((z,U)=>x.jsx(Ny,{theme:u,onClick:()=>m(z),disabled:d,"aria-label":z,children:z},U))})]})},Hy=H.div`
|
|
884
884
|
display: flex;
|
|
885
885
|
gap: 12px;
|
|
886
886
|
padding: 12px 0;
|
|
@@ -892,7 +892,7 @@ Error generating stack: `+l.message+`
|
|
|
892
892
|
&::-webkit-scrollbar {
|
|
893
893
|
display: none;
|
|
894
894
|
}
|
|
895
|
-
`,
|
|
895
|
+
`,Uy=H.button`
|
|
896
896
|
flex-shrink: 0;
|
|
897
897
|
width: 160px;
|
|
898
898
|
padding: 0;
|
|
@@ -914,17 +914,17 @@ Error generating stack: `+l.message+`
|
|
|
914
914
|
&:active {
|
|
915
915
|
transform: translateY(0);
|
|
916
916
|
}
|
|
917
|
-
`,
|
|
917
|
+
`,ky=H.div`
|
|
918
918
|
position: relative;
|
|
919
919
|
width: 100%;
|
|
920
920
|
height: 100px;
|
|
921
921
|
background-color: ${({theme:a})=>a.colors.surface};
|
|
922
922
|
overflow: hidden;
|
|
923
|
-
`,
|
|
923
|
+
`,qy=H.img`
|
|
924
924
|
width: 100%;
|
|
925
925
|
height: 100%;
|
|
926
926
|
object-fit: cover;
|
|
927
|
-
`,
|
|
927
|
+
`,Ly=H.div`
|
|
928
928
|
width: 100%;
|
|
929
929
|
height: 100%;
|
|
930
930
|
display: flex;
|
|
@@ -933,10 +933,10 @@ Error generating stack: `+l.message+`
|
|
|
933
933
|
background-color: ${({theme:a})=>a.colors.surface};
|
|
934
934
|
color: ${({theme:a})=>a.colors.contentCardTextLight};
|
|
935
935
|
font-size: 12px;
|
|
936
|
-
`,
|
|
936
|
+
`,Yy=H.div`
|
|
937
937
|
padding: 10px 12px;
|
|
938
938
|
flex: 1;
|
|
939
|
-
`,
|
|
939
|
+
`,Gy=H.h4`
|
|
940
940
|
margin: 0 0 4px 0;
|
|
941
941
|
font-family: ${({theme:a})=>a.fontFamily};
|
|
942
942
|
font-size: 13px;
|
|
@@ -948,7 +948,7 @@ Error generating stack: `+l.message+`
|
|
|
948
948
|
-webkit-box-orient: vertical;
|
|
949
949
|
overflow: hidden;
|
|
950
950
|
text-overflow: ellipsis;
|
|
951
|
-
`,
|
|
951
|
+
`,Qy=H.span`
|
|
952
952
|
position: absolute;
|
|
953
953
|
top: 8px;
|
|
954
954
|
left: 8px;
|
|
@@ -961,7 +961,7 @@ Error generating stack: `+l.message+`
|
|
|
961
961
|
background-color: rgba(0, 0, 0, 0.5);
|
|
962
962
|
border-radius: 6px;
|
|
963
963
|
backdrop-filter: blur(4px);
|
|
964
|
-
`,
|
|
964
|
+
`,Xy=T.memo(function({citation:u,theme:s,onClick:r}){return x.jsxs(Uy,{theme:s,onClick:r,"aria-label":u.title,children:[x.jsxs(ky,{theme:s,children:[u.thumbnail?x.jsx(qy,{src:u.thumbnail,alt:u.title,loading:"lazy",onError:d=>{d.target.style.display="none"}}):x.jsx(Ly,{theme:s,children:"No image"}),u.contentType&&x.jsx(Qy,{theme:s,children:u.contentType})]}),x.jsx(Yy,{theme:s,children:x.jsx(Gy,{theme:s,children:u.title})})]})}),Vy=T.memo(function({citations:u,theme:s,onCitationClick:r,onCardExpand:d}){const h=T.useRef(null);if(!u||u.length===0)return null;const y=S=>{r?.(S),d?d(S):S.content&&window.open(S.content,"_blank","noopener,noreferrer")},C=S=>{h.current&&S.deltaY!==0&&(S.preventDefault(),h.current.scrollLeft+=S.deltaY)};return x.jsx(Hy,{ref:h,onWheel:C,children:u.map(S=>x.jsx(Xy,{citation:S,theme:s,onClick:()=>y(S)},S.id))})}),Zy=sn`
|
|
965
965
|
from {
|
|
966
966
|
opacity: 0;
|
|
967
967
|
transform: translateY(8px);
|
|
@@ -970,17 +970,17 @@ Error generating stack: `+l.message+`
|
|
|
970
970
|
opacity: 1;
|
|
971
971
|
transform: translateY(0);
|
|
972
972
|
}
|
|
973
|
-
`,
|
|
973
|
+
`,Ky=H.div`
|
|
974
974
|
display: flex;
|
|
975
975
|
flex-direction: column;
|
|
976
976
|
align-items: ${({isUser:a})=>a?"flex-end":"flex-start"};
|
|
977
977
|
margin-bottom: 12px;
|
|
978
|
-
animation: ${
|
|
978
|
+
animation: ${Zy} 0.3s ease-out;
|
|
979
979
|
|
|
980
980
|
@media (prefers-reduced-motion: reduce) {
|
|
981
981
|
animation: none;
|
|
982
982
|
}
|
|
983
|
-
`,
|
|
983
|
+
`,Jy=H.div`
|
|
984
984
|
max-width: ${({isUser:a})=>a?"80%":"100%"};
|
|
985
985
|
padding: ${({isUser:a})=>a?"12px 16px":"0"};
|
|
986
986
|
border-radius: ${({isUser:a})=>a?"16px":"0"};
|
|
@@ -1023,16 +1023,16 @@ Error generating stack: `+l.message+`
|
|
|
1023
1023
|
font-family: monospace;
|
|
1024
1024
|
font-size: 13px;
|
|
1025
1025
|
}
|
|
1026
|
-
`,
|
|
1026
|
+
`,Wy=H.span`
|
|
1027
1027
|
font-size: 11px;
|
|
1028
1028
|
color: ${({theme:a})=>a.colors.textLight};
|
|
1029
1029
|
margin-top: 4px;
|
|
1030
1030
|
font-family: ${({theme:a})=>a.fontFamily};
|
|
1031
|
-
`,
|
|
1031
|
+
`,Fy=H.span`
|
|
1032
1032
|
font-size: 11px;
|
|
1033
1033
|
margin-left: 6px;
|
|
1034
1034
|
color: ${({status:a,theme:u})=>{switch(a){case"sending":return u.colors.textLight;case"error":return u.colors.error;default:return u.colors.textLight}}};
|
|
1035
|
-
`,
|
|
1035
|
+
`,Iy=H.button`
|
|
1036
1036
|
display: flex;
|
|
1037
1037
|
align-items: center;
|
|
1038
1038
|
justify-content: center;
|
|
@@ -1050,7 +1050,7 @@ Error generating stack: `+l.message+`
|
|
|
1050
1050
|
background-color: ${({theme:a})=>a.colors.primary};
|
|
1051
1051
|
color: ${({theme:a})=>a.colors.white};
|
|
1052
1052
|
}
|
|
1053
|
-
`,
|
|
1053
|
+
`,Py=a=>a.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),t0=T.memo(({message:a,theme:u,onCitationClick:s,onCardExpand:r})=>{const d=a.sender==="user",[h,y]=T.useState(!1),C=T.useRef(null),S=()=>{C.current&&(h?(C.current.pause(),C.current.currentTime=0,y(!1)):(C.current.play(),y(!0)))},m=()=>{y(!1)};return x.jsxs(Ky,{isUser:d,children:[x.jsx(Jy,{isUser:d,isError:a.status==="error",theme:u,dangerouslySetInnerHTML:{__html:a.content.replace(/\n/g,"<br>")}}),!d&&a.citations&&a.citations.length>0&&x.jsx(Vy,{citations:a.citations,theme:u,onCitationClick:s,onCardExpand:r}),a.audioUrl&&x.jsxs(x.Fragment,{children:[x.jsx("audio",{ref:C,src:a.audioUrl,onEnded:m,style:{display:"none"}}),x.jsx(Iy,{theme:u,isPlaying:h,onClick:S,"aria-label":h?"Stop audio":"Play audio",title:h?"Stop audio":"Play audio",children:h?x.jsx(Dm,{size:16}):x.jsx($m,{size:16})})]}),d&&x.jsxs(Wy,{theme:u,children:[Py(a.timestamp),a.status!=="sent"&&x.jsx(Fy,{status:a.status,theme:u,children:a.status==="sending"?"Sending...":"Failed"})]})]})}),e0=sn`
|
|
1054
1054
|
from {
|
|
1055
1055
|
opacity: 0;
|
|
1056
1056
|
transform: translateY(4px);
|
|
@@ -1059,25 +1059,25 @@ Error generating stack: `+l.message+`
|
|
|
1059
1059
|
opacity: 1;
|
|
1060
1060
|
transform: translateY(0);
|
|
1061
1061
|
}
|
|
1062
|
-
`,
|
|
1062
|
+
`,n0=sn`
|
|
1063
1063
|
0%, 60%, 100% {
|
|
1064
1064
|
transform: translateY(0);
|
|
1065
1065
|
}
|
|
1066
1066
|
30% {
|
|
1067
1067
|
transform: translateY(-4px);
|
|
1068
1068
|
}
|
|
1069
|
-
`,
|
|
1069
|
+
`,l0=H.div`
|
|
1070
1070
|
display: flex;
|
|
1071
1071
|
align-items: center;
|
|
1072
1072
|
gap: 8px;
|
|
1073
1073
|
padding: 8px 4px;
|
|
1074
|
-
animation: ${
|
|
1075
|
-
`,
|
|
1074
|
+
animation: ${e0} 0.2s ease-out;
|
|
1075
|
+
`,a0=H.span`
|
|
1076
1076
|
font-size: 13px;
|
|
1077
1077
|
font-family: ${({theme:a})=>a.fontFamily};
|
|
1078
1078
|
color: ${({theme:a})=>a.colors.textLight};
|
|
1079
1079
|
font-style: italic;
|
|
1080
|
-
`,
|
|
1080
|
+
`,i0=H.span`
|
|
1081
1081
|
display: inline-flex;
|
|
1082
1082
|
align-items: center;
|
|
1083
1083
|
gap: 3px;
|
|
@@ -1087,14 +1087,14 @@ Error generating stack: `+l.message+`
|
|
|
1087
1087
|
height: 5px;
|
|
1088
1088
|
border-radius: 50%;
|
|
1089
1089
|
background-color: ${({theme:a})=>a.colors.primary};
|
|
1090
|
-
animation: ${
|
|
1090
|
+
animation: ${n0} 1s infinite ease-in-out;
|
|
1091
1091
|
animation-delay: ${({delay:a})=>a}ms;
|
|
1092
1092
|
|
|
1093
1093
|
@media (prefers-reduced-motion: reduce) {
|
|
1094
1094
|
animation: none;
|
|
1095
1095
|
opacity: 0.6;
|
|
1096
1096
|
}
|
|
1097
|
-
`,
|
|
1097
|
+
`,o0=a=>{switch(a){case"thinking":return"Thinking";case"reasoning":return"Reasoning";case"tool_start":return"Using tools";case"tool_end":return"Processing results";case"searching":return"Searching";case"reading":return"Reading information";case"generating":return"Generating response";case"summarizing":return"Summarizing";case"processing":return"Processing";default:return"Thinking"}},u0=({theme:a,status:u})=>{const s=o0(u),[r,d]=T.useState(""),[h,y]=T.useState(!1),C=T.useRef(s),S=T.useRef(null);return T.useEffect(()=>{S.current&&clearTimeout(S.current),(s!==C.current||r==="")&&(C.current=s,d(""),y(!0))},[s]),T.useEffect(()=>{if(!h)return;const m=C.current;return r.length<m.length?S.current=setTimeout(()=>{d(m.slice(0,r.length+1))},25):y(!1),()=>{S.current&&clearTimeout(S.current)}},[r,h]),x.jsxs(l0,{children:[x.jsx(a0,{theme:a,children:r}),x.jsxs(i0,{children:[x.jsx(Uu,{delay:0,theme:a}),x.jsx(Uu,{delay:150,theme:a}),x.jsx(Uu,{delay:300,theme:a})]})]})},r0=H.div`
|
|
1098
1098
|
flex: 1;
|
|
1099
1099
|
overflow-y: auto;
|
|
1100
1100
|
padding: 16px;
|
|
@@ -1122,7 +1122,7 @@ Error generating stack: `+l.message+`
|
|
|
1122
1122
|
&::-webkit-scrollbar-thumb:hover {
|
|
1123
1123
|
background-color: ${({scrollbarThumbHover:a})=>a};
|
|
1124
1124
|
}
|
|
1125
|
-
`,
|
|
1125
|
+
`,c0=H.div`
|
|
1126
1126
|
display: flex;
|
|
1127
1127
|
flex: 1;
|
|
1128
1128
|
align-items: center;
|
|
@@ -1131,7 +1131,7 @@ Error generating stack: `+l.message+`
|
|
|
1131
1131
|
font-size: 14px;
|
|
1132
1132
|
text-align: center;
|
|
1133
1133
|
padding: 20px;
|
|
1134
|
-
`,
|
|
1134
|
+
`,s0=H.div`
|
|
1135
1135
|
display: flex;
|
|
1136
1136
|
flex: 1;
|
|
1137
1137
|
flex-direction: column;
|
|
@@ -1140,7 +1140,7 @@ Error generating stack: `+l.message+`
|
|
|
1140
1140
|
gap: 12px;
|
|
1141
1141
|
color: ${({color:a})=>a};
|
|
1142
1142
|
font-size: 14px;
|
|
1143
|
-
`,
|
|
1143
|
+
`,f0=H.div`
|
|
1144
1144
|
width: 32px;
|
|
1145
1145
|
height: 32px;
|
|
1146
1146
|
border: 3px solid ${({color:a})=>a}20;
|
|
@@ -1153,34 +1153,34 @@ Error generating stack: `+l.message+`
|
|
|
1153
1153
|
transform: rotate(360deg);
|
|
1154
1154
|
}
|
|
1155
1155
|
}
|
|
1156
|
-
`,
|
|
1156
|
+
`,d0=({onCardExpand:a})=>{const{messages:u,isTyping:s,isLoading:r,streamingStatus:d,theme:h,config:y}=hl(),C=T.useRef(null);return T.useEffect(()=>{C.current&&(C.current.scrollTop=C.current.scrollHeight)},[u,s]),x.jsx(r0,{ref:C,fontFamily:h.fontFamily,scrollbarThumb:h.colors.scrollbarThumb,scrollbarThumbHover:h.colors.scrollbarThumbHover,background:h.colors.background,children:r?x.jsxs(s0,{color:h.colors.textLight,children:[x.jsx(f0,{color:h.colors.primary}),"Loading..."]}):u.length===0&&!s?x.jsx(c0,{color:h.colors.textLight,children:"Send a message to start the conversation"}):x.jsxs(x.Fragment,{children:[u.map(S=>x.jsx(t0,{message:S,theme:h,onCitationClick:y.onCitationClick,onCardExpand:a},S.id)),s&&x.jsx(u0,{theme:h,status:d})]})})},lf=(a={})=>{const{onTranscript:u,onError:s,language:r="en-US"}=a,[d,h]=T.useState(!1),[y,C]=T.useState(""),[S,m]=T.useState(!1),M=T.useRef(null);T.useEffect(()=>{const G=window.SpeechRecognition||window.webkitSpeechRecognition;return G&&(m(!0),M.current=new G,M.current.continuous=!0,M.current.interimResults=!0,M.current.lang=r),()=>{M.current&&M.current.abort()}},[r]);const z=T.useCallback(()=>{if(!(!M.current||d)){C(""),M.current.onstart=()=>{h(!0)},M.current.onresult=G=>{let q="",J="";for(let X=G.resultIndex;X<G.results.length;X++){const ut=G.results[X];ut.isFinal?q+=ut[0].transcript:J+=ut[0].transcript}C(q||J),q&&u&&u(q)},M.current.onerror=G=>{h(!1),s&&s(G.error)},M.current.onend=()=>{h(!1)};try{M.current.start()}catch{s&&s("Failed to start recording")}}},[d,u,s]),U=T.useCallback(()=>{M.current&&d&&(M.current.stop(),h(!1))},[d]),Q=T.useCallback(()=>{d?U():z()},[d,z,U]),W=T.useCallback(()=>{C("")},[]);return{isRecording:d,isSupported:S,transcript:y,startRecording:z,stopRecording:U,toggleRecording:Q,clearTranscript:W}},h0=H.div`
|
|
1157
1157
|
display: flex;
|
|
1158
1158
|
flex-direction: column;
|
|
1159
1159
|
gap: 4px;
|
|
1160
1160
|
padding: 10px 12px;
|
|
1161
|
-
`,
|
|
1161
|
+
`,p0=H.div`
|
|
1162
1162
|
display: flex;
|
|
1163
1163
|
align-items: center;
|
|
1164
1164
|
justify-content: space-between;
|
|
1165
1165
|
gap: 8px;
|
|
1166
|
-
`,
|
|
1166
|
+
`,g0=H.span`
|
|
1167
1167
|
font-family: ${({theme:a})=>a.fontFamily};
|
|
1168
1168
|
font-size: 11px;
|
|
1169
1169
|
color: ${({theme:a})=>a.colors.textLight};
|
|
1170
1170
|
flex-shrink: 0;
|
|
1171
|
-
`,
|
|
1171
|
+
`,m0=H.span`
|
|
1172
1172
|
flex: 1;
|
|
1173
1173
|
font-family: ${({theme:a})=>a.fontFamily};
|
|
1174
1174
|
font-size: 14px;
|
|
1175
1175
|
font-weight: 600;
|
|
1176
1176
|
color: ${({theme:a})=>a.colors.text};
|
|
1177
1177
|
line-height: 1.3;
|
|
1178
|
-
`,
|
|
1178
|
+
`,y0=H.div`
|
|
1179
1179
|
display: flex;
|
|
1180
1180
|
align-items: center;
|
|
1181
1181
|
gap: 4px;
|
|
1182
1182
|
flex-shrink: 0;
|
|
1183
|
-
`,
|
|
1183
|
+
`,b0=H.button`
|
|
1184
1184
|
padding: 4px 8px;
|
|
1185
1185
|
border: none;
|
|
1186
1186
|
border-radius: 6px;
|
|
@@ -1196,7 +1196,7 @@ Error generating stack: `+l.message+`
|
|
|
1196
1196
|
background-color: ${({theme:a})=>a.colors.surface};
|
|
1197
1197
|
color: ${({theme:a})=>a.colors.text};
|
|
1198
1198
|
}
|
|
1199
|
-
`,
|
|
1199
|
+
`,v0=H.button`
|
|
1200
1200
|
display: flex;
|
|
1201
1201
|
align-items: center;
|
|
1202
1202
|
justify-content: center;
|
|
@@ -1214,7 +1214,7 @@ Error generating stack: `+l.message+`
|
|
|
1214
1214
|
background-color: ${({theme:a})=>a.colors.surface};
|
|
1215
1215
|
color: ${({theme:a})=>a.colors.text};
|
|
1216
1216
|
}
|
|
1217
|
-
`,af=T.memo(({question:a,progress:u,onCancel:s,onSkip:r,theme:d})=>x.jsx(
|
|
1217
|
+
`,af=T.memo(({question:a,progress:u,onCancel:s,onSkip:r,theme:d})=>x.jsx(h0,{children:x.jsxs(p0,{children:[u&&x.jsxs(g0,{theme:d,children:[u.currentIndex+1,"/",u.totalQuestions]}),x.jsx(m0,{theme:d,children:a}),x.jsxs(y0,{children:[r&&x.jsx(b0,{theme:d,onClick:r,type:"button",children:"Skip"}),x.jsx(v0,{theme:d,onClick:s,"aria-label":"Cancel survey",children:x.jsx(qi,{size:16})})]})]})}));af.displayName="SurveyHeader";const x0=H.button`
|
|
1218
1218
|
display: flex;
|
|
1219
1219
|
align-items: center;
|
|
1220
1220
|
gap: 8px;
|
|
@@ -1239,7 +1239,7 @@ Error generating stack: `+l.message+`
|
|
|
1239
1239
|
&:active {
|
|
1240
1240
|
transform: scale(0.99);
|
|
1241
1241
|
}
|
|
1242
|
-
`,
|
|
1242
|
+
`,S0=H.span`
|
|
1243
1243
|
display: flex;
|
|
1244
1244
|
align-items: center;
|
|
1245
1245
|
justify-content: center;
|
|
@@ -1252,22 +1252,22 @@ Error generating stack: `+l.message+`
|
|
|
1252
1252
|
font-family: ${({theme:a})=>a.fontFamily};
|
|
1253
1253
|
font-size: 11px;
|
|
1254
1254
|
font-weight: 600;
|
|
1255
|
-
`,
|
|
1255
|
+
`,C0=H.span`
|
|
1256
1256
|
flex: 1;
|
|
1257
1257
|
font-family: ${({theme:a})=>a.fontFamily};
|
|
1258
1258
|
font-size: 13px;
|
|
1259
1259
|
color: ${({theme:a})=>a.colors.text};
|
|
1260
|
-
`,
|
|
1260
|
+
`,T0=H.span`
|
|
1261
1261
|
display: flex;
|
|
1262
1262
|
align-items: center;
|
|
1263
1263
|
color: ${({theme:a})=>a.colors.textLight};
|
|
1264
1264
|
opacity: ${({isVisible:a})=>a?1:0};
|
|
1265
1265
|
transition: opacity 0.2s ease;
|
|
1266
|
-
`,of=T.memo(({label:a,index:u,isSelected:s,onSelect:r,theme:d})=>x.jsxs(
|
|
1266
|
+
`,of=T.memo(({label:a,index:u,isSelected:s,onSelect:r,theme:d})=>x.jsxs(x0,{theme:d,isSelected:s,onClick:r,type:"button",children:[x.jsx(S0,{theme:d,isSelected:s,children:u+1}),x.jsx(C0,{theme:d,children:a}),x.jsx(T0,{theme:d,isVisible:s,className:"choice-arrow",children:x.jsx(Tm,{size:16})})]}));of.displayName="ChoiceOption";const E0=H.div`
|
|
1267
1267
|
display: flex;
|
|
1268
1268
|
flex-direction: column;
|
|
1269
1269
|
gap: 6px;
|
|
1270
|
-
`,
|
|
1270
|
+
`,z0=H.button`
|
|
1271
1271
|
display: flex;
|
|
1272
1272
|
align-items: center;
|
|
1273
1273
|
gap: 8px;
|
|
@@ -1283,7 +1283,7 @@ Error generating stack: `+l.message+`
|
|
|
1283
1283
|
&:hover {
|
|
1284
1284
|
background-color: ${({theme:a})=>a.colors.surveyOptionBgHover};
|
|
1285
1285
|
}
|
|
1286
|
-
`,
|
|
1286
|
+
`,A0=H.span`
|
|
1287
1287
|
display: flex;
|
|
1288
1288
|
align-items: center;
|
|
1289
1289
|
justify-content: center;
|
|
@@ -1293,16 +1293,16 @@ Error generating stack: `+l.message+`
|
|
|
1293
1293
|
border-radius: 5px;
|
|
1294
1294
|
background-color: ${({theme:a})=>a.colors.surveyNumberBg};
|
|
1295
1295
|
color: ${({theme:a})=>a.colors.surveyNumberText};
|
|
1296
|
-
`,
|
|
1296
|
+
`,M0=H.span`
|
|
1297
1297
|
flex: 1;
|
|
1298
1298
|
font-family: ${({theme:a})=>a.fontFamily};
|
|
1299
1299
|
font-size: 13px;
|
|
1300
1300
|
color: ${({theme:a})=>a.colors.textLight};
|
|
1301
|
-
`,
|
|
1301
|
+
`,_0=H.div`
|
|
1302
1302
|
display: flex;
|
|
1303
1303
|
gap: 8px;
|
|
1304
1304
|
align-items: center;
|
|
1305
|
-
`,
|
|
1305
|
+
`,w0=H.input`
|
|
1306
1306
|
flex: 1;
|
|
1307
1307
|
padding: 8px 12px;
|
|
1308
1308
|
border: 1px solid ${({theme:a})=>a.colors.border};
|
|
@@ -1321,7 +1321,7 @@ Error generating stack: `+l.message+`
|
|
|
1321
1321
|
&::placeholder {
|
|
1322
1322
|
color: ${({theme:a})=>a.colors.textLight};
|
|
1323
1323
|
}
|
|
1324
|
-
`,
|
|
1324
|
+
`,O0=H.button`
|
|
1325
1325
|
display: flex;
|
|
1326
1326
|
align-items: center;
|
|
1327
1327
|
justify-content: center;
|
|
@@ -1341,24 +1341,24 @@ Error generating stack: `+l.message+`
|
|
|
1341
1341
|
&:active:not(:disabled) {
|
|
1342
1342
|
transform: scale(0.95);
|
|
1343
1343
|
}
|
|
1344
|
-
`,uf=T.memo(({onSubmit:a,theme:u,placeholder:s="Type your answer..."})=>{const[r,d]=T.useState(!1),[h,y]=T.useState(""),C=()=>{h.trim()&&a(h.trim())},S=m=>{m.key==="Enter"&&!m.shiftKey&&(m.preventDefault(),C())};return r?x.jsx(
|
|
1344
|
+
`,uf=T.memo(({onSubmit:a,theme:u,placeholder:s="Type your answer..."})=>{const[r,d]=T.useState(!1),[h,y]=T.useState(""),C=()=>{h.trim()&&a(h.trim())},S=m=>{m.key==="Enter"&&!m.shiftKey&&(m.preventDefault(),C())};return r?x.jsx(E0,{children:x.jsxs(_0,{theme:u,children:[x.jsx(w0,{theme:u,value:h,onChange:m=>y(m.target.value),onKeyDown:S,placeholder:s,autoFocus:!0}),x.jsx(O0,{theme:u,onClick:C,disabled:!h.trim(),type:"button",children:x.jsx(Nl,{size:18})})]})}):x.jsxs(z0,{theme:u,isActive:!1,onClick:()=>d(!0),type:"button",children:[x.jsx(A0,{theme:u,children:x.jsx(Am,{size:12})}),x.jsx(M0,{theme:u,children:"Something else"})]})});uf.displayName="OtherOption";const $0=H.div`
|
|
1345
1345
|
display: flex;
|
|
1346
1346
|
flex-direction: column;
|
|
1347
1347
|
gap: 4px;
|
|
1348
|
-
`,Yi=T.memo(({options:a,allowMultiple:u=!1,allowOther:s=!1,onSelect:r,theme:d})=>{const[h,y]=T.useState(new Set),C=m=>{if(u){const M=new Set(h);M.has(m)?M.delete(m):M.add(m),y(M);const z=Array.from(M).map(U=>a[U]);r(z)}else y(new Set([m])),r(a[m])},S=m=>{r(m)};return x.jsxs($
|
|
1348
|
+
`,Yi=T.memo(({options:a,allowMultiple:u=!1,allowOther:s=!1,onSelect:r,theme:d})=>{const[h,y]=T.useState(new Set),C=m=>{if(u){const M=new Set(h);M.has(m)?M.delete(m):M.add(m),y(M);const z=Array.from(M).map(U=>a[U]);r(z)}else y(new Set([m])),r(a[m])},S=m=>{r(m)};return x.jsxs($0,{children:[a.map((m,M)=>x.jsx(of,{label:m,index:M,isSelected:h.has(M),onSelect:()=>C(M),theme:d},M)),s&&x.jsx(uf,{onSubmit:S,theme:d})]})});Yi.displayName="ChoiceOptions";const D0=H.div`
|
|
1349
1349
|
display: flex;
|
|
1350
1350
|
flex-direction: column;
|
|
1351
1351
|
gap: 8px;
|
|
1352
|
-
`,
|
|
1352
|
+
`,B0=H.div`
|
|
1353
1353
|
display: flex;
|
|
1354
1354
|
flex-direction: column;
|
|
1355
1355
|
gap: 4px;
|
|
1356
|
-
`,
|
|
1356
|
+
`,R0=H.div`
|
|
1357
1357
|
position: relative;
|
|
1358
1358
|
height: 8px;
|
|
1359
1359
|
border-radius: 4px;
|
|
1360
1360
|
background-color: ${({theme:a})=>a.colors.borderLight};
|
|
1361
|
-
`,
|
|
1361
|
+
`,N0=H.div`
|
|
1362
1362
|
position: absolute;
|
|
1363
1363
|
left: 0;
|
|
1364
1364
|
top: 0;
|
|
@@ -1367,7 +1367,7 @@ Error generating stack: `+l.message+`
|
|
|
1367
1367
|
border-radius: 4px;
|
|
1368
1368
|
background-color: ${({theme:a})=>a.colors.primary};
|
|
1369
1369
|
transition: width 0.1s ease;
|
|
1370
|
-
`,
|
|
1370
|
+
`,j0=H.input`
|
|
1371
1371
|
position: absolute;
|
|
1372
1372
|
top: -6px;
|
|
1373
1373
|
left: 0;
|
|
@@ -1376,9 +1376,9 @@ Error generating stack: `+l.message+`
|
|
|
1376
1376
|
margin: 0;
|
|
1377
1377
|
opacity: 0;
|
|
1378
1378
|
cursor: pointer;
|
|
1379
|
-
`,
|
|
1379
|
+
`,H0=H.div`
|
|
1380
1380
|
position: relative;
|
|
1381
|
-
`,
|
|
1381
|
+
`,U0=H.div`
|
|
1382
1382
|
display: flex;
|
|
1383
1383
|
align-items: center;
|
|
1384
1384
|
justify-content: center;
|
|
@@ -1389,18 +1389,18 @@ Error generating stack: `+l.message+`
|
|
|
1389
1389
|
font-size: 18px;
|
|
1390
1390
|
font-weight: 600;
|
|
1391
1391
|
color: ${({theme:a})=>a.colors.primary};
|
|
1392
|
-
`,
|
|
1392
|
+
`,k0=H.div`
|
|
1393
1393
|
display: flex;
|
|
1394
1394
|
justify-content: space-between;
|
|
1395
1395
|
`,rf=H.span`
|
|
1396
1396
|
font-family: ${({theme:a})=>a.fontFamily};
|
|
1397
1397
|
font-size: 11px;
|
|
1398
1398
|
color: ${({theme:a})=>a.colors.textLight};
|
|
1399
|
-
`,
|
|
1399
|
+
`,q0=H.div`
|
|
1400
1400
|
display: flex;
|
|
1401
1401
|
justify-content: space-between;
|
|
1402
1402
|
align-items: center;
|
|
1403
|
-
`,
|
|
1403
|
+
`,L0=H.button`
|
|
1404
1404
|
display: flex;
|
|
1405
1405
|
align-items: center;
|
|
1406
1406
|
justify-content: center;
|
|
@@ -1420,7 +1420,7 @@ Error generating stack: `+l.message+`
|
|
|
1420
1420
|
&:active {
|
|
1421
1421
|
transform: scale(0.95);
|
|
1422
1422
|
}
|
|
1423
|
-
`,cf=T.memo(({scale:a,onSubmit:u,theme:s})=>{const{min:r,max:d,minLabel:h,maxLabel:y}=a,[C,S]=T.useState(Math.floor((r+d)/2)),m=(C-r)/(d-r)*100,M=z=>{S(parseInt(z.target.value,10))};return x.jsxs(
|
|
1423
|
+
`,cf=T.memo(({scale:a,onSubmit:u,theme:s})=>{const{min:r,max:d,minLabel:h,maxLabel:y}=a,[C,S]=T.useState(Math.floor((r+d)/2)),m=(C-r)/(d-r)*100,M=z=>{S(parseInt(z.target.value,10))};return x.jsxs(D0,{children:[x.jsxs(B0,{children:[x.jsxs(H0,{children:[x.jsx(R0,{theme:s,children:x.jsx(N0,{theme:s,percentage:m})}),x.jsx(j0,{theme:s,type:"range",min:r,max:d,value:C,onChange:M})]}),x.jsxs(k0,{children:[x.jsx(rf,{theme:s,children:h||r}),x.jsx(rf,{theme:s,children:y||d})]})]}),x.jsxs(q0,{children:[x.jsx(U0,{theme:s,children:C}),x.jsx(L0,{theme:s,onClick:()=>u(C),type:"button",children:x.jsx(Nl,{size:18})})]})]})});cf.displayName="ScaleInput";const Y0=H.div`
|
|
1424
1424
|
display: flex;
|
|
1425
1425
|
flex-direction: column;
|
|
1426
1426
|
border: 1.5px solid ${({theme:a})=>a.colors.border};
|
|
@@ -1432,7 +1432,7 @@ Error generating stack: `+l.message+`
|
|
|
1432
1432
|
border-color: ${({theme:a})=>a.colors.primary};
|
|
1433
1433
|
box-shadow: 0 0 0 3px ${({theme:a})=>a.colors.accentLight};
|
|
1434
1434
|
}
|
|
1435
|
-
`,
|
|
1435
|
+
`,G0=H.textarea`
|
|
1436
1436
|
flex: 1;
|
|
1437
1437
|
padding: 12px 16px 8px;
|
|
1438
1438
|
border: none;
|
|
@@ -1450,13 +1450,13 @@ Error generating stack: `+l.message+`
|
|
|
1450
1450
|
&::placeholder {
|
|
1451
1451
|
color: ${({theme:a})=>a.colors.textLight};
|
|
1452
1452
|
}
|
|
1453
|
-
`,
|
|
1453
|
+
`,Q0=H.div`
|
|
1454
1454
|
display: flex;
|
|
1455
1455
|
justify-content: flex-end;
|
|
1456
1456
|
align-items: center;
|
|
1457
1457
|
gap: 8px;
|
|
1458
1458
|
padding: 4px 12px 8px;
|
|
1459
|
-
`,
|
|
1459
|
+
`,X0=H.button`
|
|
1460
1460
|
display: flex;
|
|
1461
1461
|
align-items: center;
|
|
1462
1462
|
justify-content: center;
|
|
@@ -1476,7 +1476,7 @@ Error generating stack: `+l.message+`
|
|
|
1476
1476
|
&:active:not(:disabled) {
|
|
1477
1477
|
transform: scale(0.95);
|
|
1478
1478
|
}
|
|
1479
|
-
`,
|
|
1479
|
+
`,V0=a=>sn`
|
|
1480
1480
|
0% {
|
|
1481
1481
|
box-shadow: 0 0 0 0 ${a}66;
|
|
1482
1482
|
}
|
|
@@ -1486,7 +1486,7 @@ Error generating stack: `+l.message+`
|
|
|
1486
1486
|
100% {
|
|
1487
1487
|
box-shadow: 0 0 0 0 ${a}00;
|
|
1488
1488
|
}
|
|
1489
|
-
`,
|
|
1489
|
+
`,Z0=H.button`
|
|
1490
1490
|
display: flex;
|
|
1491
1491
|
align-items: center;
|
|
1492
1492
|
justify-content: center;
|
|
@@ -1498,7 +1498,7 @@ Error generating stack: `+l.message+`
|
|
|
1498
1498
|
color: ${({theme:a,isRecording:u})=>u?a.colors.white:a.colors.textLight};
|
|
1499
1499
|
cursor: pointer;
|
|
1500
1500
|
transition: background-color 0.2s ease, transform 0.1s ease, color 0.2s ease;
|
|
1501
|
-
animation: ${({isRecording:a,theme:u})=>a?
|
|
1501
|
+
animation: ${({isRecording:a,theme:u})=>a?V0(u.colors.recording):"none"} 1.5s infinite;
|
|
1502
1502
|
|
|
1503
1503
|
&:hover {
|
|
1504
1504
|
background-color: ${({theme:a,isRecording:u})=>u?a.colors.recording:a.colors.border};
|
|
@@ -1508,15 +1508,15 @@ Error generating stack: `+l.message+`
|
|
|
1508
1508
|
&:active {
|
|
1509
1509
|
transform: scale(0.95);
|
|
1510
1510
|
}
|
|
1511
|
-
`,ku=T.memo(({onSubmit:a,theme:u,placeholder:s="Type your answer..."})=>{const[r,d]=T.useState(""),{isRecording:h,isSupported:y,transcript:C,toggleRecording:S,clearTranscript:m}=lf({onError:Q=>{console.error("Voice recording error:",Q)}});T.useEffect(()=>{C&&d(C)},[C]);const M=()=>{r.trim()&&(a(r.trim()),m())},z=Q=>{Q.key==="Enter"&&!Q.shiftKey&&(Q.preventDefault(),M())},U=()=>h?"Listening...":s;return x.jsxs(
|
|
1511
|
+
`,ku=T.memo(({onSubmit:a,theme:u,placeholder:s="Type your answer..."})=>{const[r,d]=T.useState(""),{isRecording:h,isSupported:y,transcript:C,toggleRecording:S,clearTranscript:m}=lf({onError:Q=>{console.error("Voice recording error:",Q)}});T.useEffect(()=>{C&&d(C)},[C]);const M=()=>{r.trim()&&(a(r.trim()),m())},z=Q=>{Q.key==="Enter"&&!Q.shiftKey&&(Q.preventDefault(),M())},U=()=>h?"Listening...":s;return x.jsxs(Y0,{theme:u,children:[x.jsx(G0,{theme:u,value:r,onChange:Q=>d(Q.target.value),onKeyDown:z,placeholder:U(),rows:1}),x.jsxs(Q0,{children:[y&&x.jsx(Z0,{theme:u,onClick:S,isRecording:h,"aria-label":h?"Stop recording":"Start voice recording",title:h?"Stop recording":"Start voice recording",type:"button",children:x.jsx(Qs,{size:18})}),x.jsx(X0,{theme:u,onClick:M,disabled:!r.trim(),type:"button",children:x.jsx(Nl,{size:18})})]})]})});ku.displayName="TextInput";const K0=H.div`
|
|
1512
1512
|
display: flex;
|
|
1513
1513
|
flex-direction: column;
|
|
1514
1514
|
gap: 8px;
|
|
1515
|
-
`,
|
|
1515
|
+
`,J0=H.div`
|
|
1516
1516
|
display: flex;
|
|
1517
1517
|
gap: 8px;
|
|
1518
1518
|
align-items: center;
|
|
1519
|
-
`,
|
|
1519
|
+
`,W0=H.input`
|
|
1520
1520
|
flex: 1;
|
|
1521
1521
|
padding: 10px 12px;
|
|
1522
1522
|
border: 1px solid ${({theme:a})=>a.colors.border};
|
|
@@ -1543,7 +1543,7 @@ Error generating stack: `+l.message+`
|
|
|
1543
1543
|
margin: 0;
|
|
1544
1544
|
}
|
|
1545
1545
|
-moz-appearance: textfield;
|
|
1546
|
-
`,
|
|
1546
|
+
`,F0=H.button`
|
|
1547
1547
|
display: flex;
|
|
1548
1548
|
align-items: center;
|
|
1549
1549
|
justify-content: center;
|
|
@@ -1563,7 +1563,7 @@ Error generating stack: `+l.message+`
|
|
|
1563
1563
|
&:active:not(:disabled) {
|
|
1564
1564
|
transform: scale(0.95);
|
|
1565
1565
|
}
|
|
1566
|
-
`,qu=T.memo(({onSubmit:a,theme:u,placeholder:s="Enter a number...",allowDecimal:r=!1,min:d,max:h})=>{const[y,C]=T.useState(""),S=U=>{const Q=U.target.value;if(Q===""||Q==="-"){C(Q);return}(r?/^-?\d*\.?\d*$/:/^-?\d*$/).test(Q)&&C(Q)},m=()=>{const U=r?parseFloat(y):parseInt(y,10);isNaN(U)||d!==void 0&&U<d||h!==void 0&&U>h||a(U)},M=U=>{U.key==="Enter"&&(U.preventDefault(),m())},z=()=>{if(y===""||y==="-")return!1;const U=r?parseFloat(y):parseInt(y,10);return!(isNaN(U)||d!==void 0&&U<d||h!==void 0&&U>h)};return x.jsx(
|
|
1566
|
+
`,qu=T.memo(({onSubmit:a,theme:u,placeholder:s="Enter a number...",allowDecimal:r=!1,min:d,max:h})=>{const[y,C]=T.useState(""),S=U=>{const Q=U.target.value;if(Q===""||Q==="-"){C(Q);return}(r?/^-?\d*\.?\d*$/:/^-?\d*$/).test(Q)&&C(Q)},m=()=>{const U=r?parseFloat(y):parseInt(y,10);isNaN(U)||d!==void 0&&U<d||h!==void 0&&U>h||a(U)},M=U=>{U.key==="Enter"&&(U.preventDefault(),m())},z=()=>{if(y===""||y==="-")return!1;const U=r?parseFloat(y):parseInt(y,10);return!(isNaN(U)||d!==void 0&&U<d||h!==void 0&&U>h)};return x.jsx(K0,{children:x.jsxs(J0,{children:[x.jsx(W0,{theme:u,type:"text",inputMode:r?"decimal":"numeric",value:y,onChange:S,onKeyDown:M,placeholder:s}),x.jsx(F0,{theme:u,onClick:m,disabled:!z(),type:"button",children:x.jsx(Nl,{size:18})})]})})});qu.displayName="NumberInput";const I0=H.div`
|
|
1567
1567
|
display: flex;
|
|
1568
1568
|
gap: 8px;
|
|
1569
1569
|
`,sf=H.button`
|
|
@@ -1591,7 +1591,7 @@ Error generating stack: `+l.message+`
|
|
|
1591
1591
|
&:active {
|
|
1592
1592
|
transform: scale(0.98);
|
|
1593
1593
|
}
|
|
1594
|
-
`,ff=T.memo(({onSubmit:a,theme:u,yesLabel:s="Yes",noLabel:r="No"})=>x.jsxs(
|
|
1594
|
+
`,ff=T.memo(({onSubmit:a,theme:u,yesLabel:s="Yes",noLabel:r="No"})=>x.jsxs(I0,{children:[x.jsx(sf,{theme:u,variant:"yes",onClick:()=>a(!0),type:"button",children:s}),x.jsx(sf,{theme:u,variant:"no",onClick:()=>a(!1),type:"button",children:r})]}));ff.displayName="BooleanInput";const P0=H.div`
|
|
1595
1595
|
display: flex;
|
|
1596
1596
|
flex-direction: column;
|
|
1597
1597
|
gap: 8px;
|
|
@@ -1645,7 +1645,7 @@ Error generating stack: `+l.message+`
|
|
|
1645
1645
|
&:active:not(:disabled) {
|
|
1646
1646
|
transform: scale(0.95);
|
|
1647
1647
|
}
|
|
1648
|
-
`,Lu=T.memo(({onSubmit:a,theme:u,includeTime:s=!1})=>{const[r,d]=T.useState(""),h=()=>{r&&a(r)},y=C=>{C.key==="Enter"&&(C.preventDefault(),h())};return x.jsx(
|
|
1648
|
+
`,Lu=T.memo(({onSubmit:a,theme:u,includeTime:s=!1})=>{const[r,d]=T.useState(""),h=()=>{r&&a(r)},y=C=>{C.key==="Enter"&&(C.preventDefault(),h())};return x.jsx(P0,{children:x.jsxs(tb,{children:[x.jsx(eb,{theme:u,type:s?"datetime-local":"date",value:r,onChange:C=>d(C.target.value),onKeyDown:y}),x.jsx(nb,{theme:u,onClick:h,disabled:!r,type:"button",children:x.jsx(Nl,{size:18})})]})})});Lu.displayName="DateInput";const lb=H.div`
|
|
1649
1649
|
display: flex;
|
|
1650
1650
|
flex-direction: column;
|
|
1651
1651
|
margin: 12px 16px 6px;
|
|
@@ -1759,7 +1759,7 @@ Error generating stack: `+l.message+`
|
|
|
1759
1759
|
&:active {
|
|
1760
1760
|
transform: scale(0.95);
|
|
1761
1761
|
}
|
|
1762
|
-
`,fb=()=>{const{sendMessage:a,isTyping:u,config:s,theme:r,assistant:d,currentQuestion:h,surveyProgress:y,submitSurveyAnswer:C,skipSurveyQuestion:S,cancelSurvey:m}=hl(),M=h!==null,[z,U]=T.useState(""),Q=T.useRef(null),W=s.placeholder||d?.chatUiConfig?.placeholder||"Type a message...",{isRecording:G,isSupported:q,transcript:J,toggleRecording:P,clearTranscript:X}=lf({onError:kt=>{console.error("Voice recording error:",kt)}});T.useEffect(()=>{J&&U(J)},[J]);const ut=T.useCallback(()=>{const kt=Q.current;kt&&(kt.style.height="auto",kt.style.height=`${Math.min(kt.scrollHeight,150)}px`)},[]);T.useEffect(()=>{ut()},[z,ut]);const j=T.useCallback(()=>{z.trim()&&!u&&(a(z),U(""),X(),Q.current&&(Q.current.style.height="auto",Q.current.focus()))},[z,u,a,X]),ot=T.useCallback(kt=>{kt.key==="Enter"&&!kt.shiftKey&&(kt.preventDefault(),j())},[j]),Z=T.useCallback(kt=>{U(kt.target.value)},[]),Rt=T.useCallback(()=>{P()},[P]),Qt=u,L=u||!z.trim(),Mt=s.disclaimerText??"AI can make mistakes. Verify important information.";T.useEffect(()=>{!M&&!u&&Q.current&&Q.current.focus()},[M,u]);const Lt=()=>G?"Listening...":W;return M&&h?x.jsxs(hf,{theme:r,children:[x.jsx(df,{questionInfo:h,progress:y,onAnswer:C,onSkip:S,onCancel:m,theme:r}),Mt&&x.jsx(pf,{theme:r,children:Mt})]}):x.jsxs(hf,{theme:r,children:[x.jsxs(ib,{theme:r,disabled:Qt,children:[x.jsx(ob,{ref:Q,theme:r,value:z,onChange:Z,onKeyDown:ot,placeholder:Lt(),disabled:Qt,"aria-label":"Message input",rows:1}),x.jsxs(ub,{children:[q&&x.jsx(sb,{theme:r,onClick:Rt,isRecording:G,"aria-label":G?"Stop recording":"Start voice recording",title:G?"Stop recording":"Start voice recording",children:x.jsx(Qs,{size:18})}),x.jsx(rb,{theme:r,onClick:j,disabled:L,"aria-label":"Send message",children:x.jsx(Nl,{size:18})})]})]}),Mt&&x.jsx(pf,{theme:r,children:Mt})]})},db=sn`
|
|
1762
|
+
`,fb=()=>{const{sendMessage:a,isTyping:u,config:s,theme:r,assistant:d,currentQuestion:h,surveyProgress:y,submitSurveyAnswer:C,skipSurveyQuestion:S,cancelSurvey:m}=hl(),M=h!==null,[z,U]=T.useState(""),Q=T.useRef(null),W=s.placeholder||d?.chatUiConfig?.placeholder||"Type a message...",{isRecording:G,isSupported:q,transcript:J,toggleRecording:P,clearTranscript:X}=lf({onError:kt=>{console.error("Voice recording error:",kt)}});T.useEffect(()=>{J&&U(J)},[J]);const ut=T.useCallback(()=>{const kt=Q.current;kt&&(kt.style.height="auto",kt.style.height=`${Math.min(kt.scrollHeight,150)}px`)},[]);T.useEffect(()=>{ut()},[z,ut]);const j=T.useCallback(()=>{z.trim()&&!u&&(a(z),U(""),X(),Q.current&&(Q.current.style.height="auto",Q.current.focus()))},[z,u,a,X]),ot=T.useCallback(kt=>{kt.key==="Enter"&&!kt.shiftKey&&(kt.preventDefault(),j())},[j]),Z=T.useCallback(kt=>{U(kt.target.value)},[]),Rt=T.useCallback(()=>{P()},[P]),Qt=u,L=u||!z.trim(),Mt=s.disclaimerText??d?.chatUiConfig?.cautionaryMessageOnCompletions??"AI can make mistakes. Verify important information.";T.useEffect(()=>{!M&&!u&&Q.current&&Q.current.focus()},[M,u]);const Lt=()=>G?"Listening...":W;return M&&h?x.jsxs(hf,{theme:r,children:[x.jsx(df,{questionInfo:h,progress:y,onAnswer:C,onSkip:S,onCancel:m,theme:r}),Mt&&x.jsx(pf,{theme:r,children:Mt})]}):x.jsxs(hf,{theme:r,children:[x.jsxs(ib,{theme:r,disabled:Qt,children:[x.jsx(ob,{ref:Q,theme:r,value:z,onChange:Z,onKeyDown:ot,placeholder:Lt(),disabled:Qt,"aria-label":"Message input",rows:1}),x.jsxs(ub,{children:[q&&x.jsx(sb,{theme:r,onClick:Rt,isRecording:G,"aria-label":G?"Stop recording":"Start voice recording",title:G?"Stop recording":"Start voice recording",children:x.jsx(Qs,{size:18})}),x.jsx(rb,{theme:r,onClick:j,disabled:L,"aria-label":"Send message",children:x.jsx(Nl,{size:18})})]})]}),Mt&&x.jsx(pf,{theme:r,children:Mt})]})},db=sn`
|
|
1763
1763
|
from { opacity: 0; }
|
|
1764
1764
|
to { opacity: 1; }
|
|
1765
1765
|
`,hb=sn`
|
|
@@ -2093,4 +2093,4 @@ Error generating stack: `+l.message+`
|
|
|
2093
2093
|
max-height: 600px;
|
|
2094
2094
|
`}
|
|
2095
2095
|
}
|
|
2096
|
-
`,Rb=()=>{const{isOpen:a,toggle:u,config:s,theme:r,assistant:d,isExpanded:h}=hl(),y=s.floatingMode??!1,[C,S]=T.useState(null),m=T.useCallback(U=>{S(U)},[]),M=T.useCallback(()=>{S(null)},[]),z=s.fabIcon||d?.chatUiConfig?.fabIcon||"https://web.mypatientspace.com/img/logo-symbol.png";return x.jsxs(x.Fragment,{children:[x.jsx(wb,{isVisible:h}),x.jsxs(Ob,{position:s.position||"bottom-right",floatingMode:y,useAbsolutePositioning:s.useAbsolutePositioning,isExpanded:h,children:[y&&x.jsx($b,{theme:r,isOpen:a,hasCustomIcon:!0,onClick:u,"aria-label":"Open chat","aria-expanded":a,children:x.jsx(Db,{src:z,alt:"Chat"})}),x.jsxs(Bb,{theme:r,isOpen:a,isClosing:!1,floatingMode:y,isExpanded:h,useAbsolutePositioning:s.useAbsolutePositioning,children:[x.jsx($
|
|
2096
|
+
`,Rb=()=>{const{isOpen:a,toggle:u,config:s,theme:r,assistant:d,isExpanded:h}=hl(),y=s.floatingMode??!1,[C,S]=T.useState(null),m=T.useCallback(U=>{S(U)},[]),M=T.useCallback(()=>{S(null)},[]),z=s.fabIcon||d?.chatUiConfig?.fabIcon||"https://web.mypatientspace.com/img/logo-symbol.png";return x.jsxs(x.Fragment,{children:[x.jsx(wb,{isVisible:h}),x.jsxs(Ob,{position:s.position||"bottom-right",floatingMode:y,useAbsolutePositioning:s.useAbsolutePositioning,isExpanded:h,children:[y&&x.jsx($b,{theme:r,isOpen:a,hasCustomIcon:!0,onClick:u,"aria-label":"Open chat","aria-expanded":a,children:x.jsx(Db,{src:z,alt:"Chat"})}),x.jsxs(Bb,{theme:r,isOpen:a,isClosing:!1,floatingMode:y,isExpanded:h,useAbsolutePositioning:s.useAbsolutePositioning,children:[x.jsx($y,{}),x.jsx(jy,{}),x.jsx(d0,{onCardExpand:m}),x.jsx(fb,{}),C&&x.jsx(zb,{citation:C,theme:r,onClose:M})]})]})]})},Nb={position:"bottom-right",colorMode:"light"};let Ll=null,ie=null,Gi=null;const be={open:()=>{console.warn("ChatbotWidget: Widget not initialized. Call init() first.")},close:()=>{console.warn("ChatbotWidget: Widget not initialized. Call init() first.")},toggle:()=>{console.warn("ChatbotWidget: Widget not initialized. Call init() first.")},updateConfig:a=>{console.warn("ChatbotWidget: Widget not initialized. Call init() first.")},startNewChat:()=>{console.warn("ChatbotWidget: Widget not initialized. Call init() first.")}},jb=({config:a,onMount:u})=>{const s=T.useRef(null),r=T.useCallback(d=>{s.current=d},[]);return x.jsx(py,{config:a,onConfigUpdate:r,children:x.jsx(Hb,{onMount:u,updateConfigRef:s})})},Hb=({onMount:a,updateConfigRef:u})=>{const{open:s,close:r,toggle:d,startNewChat:h}=hl();return T.useEffect(()=>{a({open:s,close:r,toggle:d,updateConfig:y=>{u.current?.(y)},startNewChat:h})},[s,r,d,h,a,u]),x.jsx(Rb,{})},Ub={init:a=>{if(Ll){console.warn("ChatbotWidget: Already initialized. Call destroy() first to reinitialize.");return}const u={...Nb,...a,floatingMode:a.floatingMode??!1};if(a.containerElement)ie=document.createElement("div"),ie.style.cssText="width: 100%; height: 100%; border-radius: inherit; overflow: hidden;",a.containerElement.appendChild(ie);else if(u.floatingMode)ie=document.createElement("div"),ie.id="chatbot-widget-root",document.body.appendChild(ie);else if(a.containerSelector){const d=document.querySelector(a.containerSelector);if(!d){console.error(`ChatbotWidget: Container not found for selector "${a.containerSelector}".`);return}ie=document.createElement("div"),ie.style.cssText="width: 100%; height: 100%; border-radius: inherit; overflow: hidden;",d.appendChild(ie)}else ie=document.createElement("div"),ie.id="chatbot-widget-root",document.body.appendChild(ie);Gi=ie.attachShadow({mode:"open"});const s=document.createElement("div");s.style.cssText="width: 100%; height: 100%; border-radius: inherit; overflow: hidden;",Gi.appendChild(s);const r=Cu({key:"mps-chatbot",container:Gi});Ll=hs.createRoot(s),Ll.render(x.jsx(wu,{value:r,children:x.jsx(jb,{config:u,onMount:d=>{be.open=d.open,be.close=d.close,be.toggle=d.toggle,be.updateConfig=d.updateConfig,be.startNewChat=d.startNewChat}})})),console.log("ChatbotWidget: Initialized successfully.")},destroy:()=>{Ll&&(Ll.unmount(),Ll=null),ie&&ie.parentNode&&ie.parentNode.removeChild(ie),ie=null,Gi=null,be.open=()=>{console.warn("ChatbotWidget: Widget not initialized. Call init() first.")},be.close=()=>{console.warn("ChatbotWidget: Widget not initialized. Call init() first.")},be.toggle=()=>{console.warn("ChatbotWidget: Widget not initialized. Call init() first.")},be.updateConfig=()=>{console.warn("ChatbotWidget: Widget not initialized. Call init() first.")},be.startNewChat=()=>{console.warn("ChatbotWidget: Widget not initialized. Call init() first.")},console.log("ChatbotWidget: Destroyed successfully.")},open:()=>be.open(),close:()=>be.close(),toggle:()=>be.toggle(),update:a=>be.updateConfig(a),startNewChat:()=>be.startNewChat()};window.ChatbotWidget=Ub;let Un=null,dn=null,Qi=null,Ua=null,Yl=null,Xi=!1;const vf={init:a=>{if(Un){console.warn("ChatbotWidgetDemo: Already initialized. Call destroy() first to reinitialize.");return}if(a.containerSelector){const s=document.querySelector(a.containerSelector);if(!s){console.error(`ChatbotWidgetDemo: Container not found for selector "${a.containerSelector}".`);return}dn=s,Xi=!0}else dn=document.createElement("div"),dn.id="chatbot-demo-root",document.body.appendChild(dn),Xi=!1;Qi=dn.attachShadow({mode:"open"});const u=document.createElement("div");u.style.cssText="width: 100%; height: 100%;",Qi.appendChild(u),Ua=Cu({key:"mps-demo",container:Qi}),Yl=a,Un=hs.createRoot(u),Un.render(x.jsx(wu,{value:Ua,children:x.jsx(Fs,{config:a})})),console.log("ChatbotWidgetDemo: Initialized successfully.")},destroy:()=>{Un&&(Un.unmount(),Un=null),window.ChatbotWidget&&window.ChatbotWidget.destroy(),dn&&!Xi&&dn.parentNode&&dn.parentNode.removeChild(dn),dn=null,Qi=null,Ua=null,Xi=!1,Yl=null,console.log("ChatbotWidgetDemo: Destroyed successfully.")},update:a=>{if(!Un||!Yl||!Ua){console.warn("ChatbotWidgetDemo: Not initialized. Call init() first.");return}Yl={...Yl,...a},Un.render(x.jsx(wu,{value:Ua,children:x.jsx(Fs,{config:Yl})}))},getConfig:()=>window.ChatbotWidget?{}:(console.warn("ChatbotWidgetDemo: Widget not available."),{})};return window.ChatbotWidgetDemo=vf,vf}));
|
|
@@ -12697,7 +12697,7 @@ const Xg = [
|
|
|
12697
12697
|
/* @__PURE__ */ v.jsxs(Ig, { fontFamily: s.fontFamily, children: [
|
|
12698
12698
|
_,
|
|
12699
12699
|
" v",
|
|
12700
|
-
"1.0.
|
|
12700
|
+
"1.0.64"
|
|
12701
12701
|
] })
|
|
12702
12702
|
] })
|
|
12703
12703
|
] }),
|
|
@@ -14399,7 +14399,7 @@ const V0 = H.div`
|
|
|
14399
14399
|
B(wt.target.value);
|
|
14400
14400
|
}, []), Rt = j.useCallback(() => {
|
|
14401
14401
|
F();
|
|
14402
|
-
}, [F]), Lt = c, Zt = c || !O.trim(), $t = s.disclaimerText ?? "AI can make mistakes. Verify important information.";
|
|
14402
|
+
}, [F]), Lt = c, Zt = c || !O.trim(), $t = s.disclaimerText ?? d?.chatUiConfig?.cautionaryMessageOnCompletions ?? "AI can make mistakes. Verify important information.";
|
|
14403
14403
|
j.useEffect(() => {
|
|
14404
14404
|
!_ && !c && G.current && G.current.focus();
|
|
14405
14405
|
}, [_, c]);
|
|
@@ -82,7 +82,7 @@ Error generating stack: `+a.message+`
|
|
|
82
82
|
display: flex;
|
|
83
83
|
align-items: center;
|
|
84
84
|
gap: 6px;
|
|
85
|
-
`,xm=()=>{const{close:n,config:c,theme:s,assistant:r,isExpanded:d,toggleExpanded:y,startNewChat:S}=Jl(),A=c.headerTitle||r?.chatUiConfig?.avatarTitle||"AI Doctor",x=c.headerIcon||r?.chatUiConfig?.avatarImage?.iconURL||r?.chatUiConfig?.avatarImage?.thumbnailURL||"https://web.mypatientspace.com/img/logo-symbol.png",p=c.headerSubtitle||r?.chatUiConfig?.headerSubtitle,O=c.brandingText||r?.chatUiConfig?.brandingText||"Developed by myPatientSpace";return v.jsxs(fm,{theme:s,children:[v.jsxs(dm,{children:[v.jsx(hm,{theme:s,hasCustomIcon:!0,children:v.jsx(ym,{src:x,alt:""})}),v.jsxs(mm,{children:[v.jsx(pm,{fontFamily:s.fontFamily,children:A}),p&&v.jsx(gm,{fontFamily:s.fontFamily,children:p}),v.jsxs(vm,{fontFamily:s.fontFamily,children:[O," v","1.0.
|
|
85
|
+
`,xm=()=>{const{close:n,config:c,theme:s,assistant:r,isExpanded:d,toggleExpanded:y,startNewChat:S}=Jl(),A=c.headerTitle||r?.chatUiConfig?.avatarTitle||"AI Doctor",x=c.headerIcon||r?.chatUiConfig?.avatarImage?.iconURL||r?.chatUiConfig?.avatarImage?.thumbnailURL||"https://web.mypatientspace.com/img/logo-symbol.png",p=c.headerSubtitle||r?.chatUiConfig?.headerSubtitle,O=c.brandingText||r?.chatUiConfig?.brandingText||"Developed by myPatientSpace";return v.jsxs(fm,{theme:s,children:[v.jsxs(dm,{children:[v.jsx(hm,{theme:s,hasCustomIcon:!0,children:v.jsx(ym,{src:x,alt:""})}),v.jsxs(mm,{children:[v.jsx(pm,{fontFamily:s.fontFamily,children:A}),p&&v.jsx(gm,{fontFamily:s.fontFamily,children:p}),v.jsxs(vm,{fontFamily:s.fontFamily,children:[O," v","1.0.64"]})]})]}),v.jsxs(bm,{children:[v.jsx(ec,{theme:s,onClick:S,"aria-label":"Start new chat",children:v.jsx(om,{size:16})}),v.jsx(ec,{theme:s,onClick:y,"aria-label":d?"Collapse chat":"Expand chat",children:d?v.jsx(ys,{size:16}):v.jsx(ds,{size:16})}),c.floatingMode&&v.jsx(ec,{theme:s,onClick:n,"aria-label":"Minimize chat",children:v.jsx(nm,{size:16})})]})]})},Sm=H.div`
|
|
86
86
|
position: relative;
|
|
87
87
|
background-color: ${({theme:n})=>n.colors.background};
|
|
88
88
|
border-bottom: 1px solid ${({theme:n})=>n.colors.borderLight};
|
|
@@ -1035,7 +1035,7 @@ Error generating stack: `+a.message+`
|
|
|
1035
1035
|
&:active {
|
|
1036
1036
|
transform: scale(0.95);
|
|
1037
1037
|
}
|
|
1038
|
-
`,tg=()=>{const{sendMessage:n,isTyping:c,config:s,theme:r,assistant:d,currentQuestion:y,surveyProgress:S,submitSurveyAnswer:A,skipSurveyQuestion:x,cancelSurvey:p}=Jl(),O=y!==null,[_,B]=j.useState(""),G=j.useRef(null),K=s.placeholder||d?.chatUiConfig?.placeholder||"Type a message...",{isRecording:q,isSupported:Z,transcript:Q,toggleRecording:F,clearTranscript:X}=ms({onError:wt=>{console.error("Voice recording error:",wt)}});j.useEffect(()=>{Q&&B(Q)},[Q]);const it=j.useCallback(()=>{const wt=G.current;wt&&(wt.style.height="auto",wt.style.height=`${Math.min(wt.scrollHeight,150)}px`)},[]);j.useEffect(()=>{it()},[_,it]);const w=j.useCallback(()=>{_.trim()&&!c&&(n(_),B(""),X(),G.current&&(G.current.style.height="auto",G.current.focus()))},[_,c,n,X]),tt=j.useCallback(wt=>{wt.key==="Enter"&&!wt.shiftKey&&(wt.preventDefault(),w())},[w]),L=j.useCallback(wt=>{B(wt.target.value)},[]),Rt=j.useCallback(()=>{F()},[F]),$t=c,Vt=c||!_.trim(),Lt=s.disclaimerText??"AI can make mistakes. Verify important information.";j.useEffect(()=>{!O&&!c&&G.current&&G.current.focus()},[O,c]);const Bt=()=>q?"Listening...":K;return O&&y?v.jsxs(zs,{theme:r,children:[v.jsx(Es,{questionInfo:y,progress:S,onAnswer:A,onSkip:x,onCancel:p,theme:r}),Lt&&v.jsx(As,{theme:r,children:Lt})]}):v.jsxs(zs,{theme:r,children:[v.jsxs(Kp,{theme:r,disabled:$t,children:[v.jsx(Jp,{ref:G,theme:r,value:_,onChange:L,onKeyDown:tt,placeholder:Bt(),disabled:$t,"aria-label":"Message input",rows:1}),v.jsxs(Wp,{children:[Z&&v.jsx(Pp,{theme:r,onClick:Rt,isRecording:q,"aria-label":q?"Stop recording":"Start voice recording",title:q?"Stop recording":"Start voice recording",children:v.jsx(hs,{size:18})}),v.jsx(Fp,{theme:r,onClick:w,disabled:Vt,"aria-label":"Send message",children:v.jsx(ga,{size:18})})]})]}),Lt&&v.jsx(As,{theme:r,children:Lt})]})},eg=Pe`
|
|
1038
|
+
`,tg=()=>{const{sendMessage:n,isTyping:c,config:s,theme:r,assistant:d,currentQuestion:y,surveyProgress:S,submitSurveyAnswer:A,skipSurveyQuestion:x,cancelSurvey:p}=Jl(),O=y!==null,[_,B]=j.useState(""),G=j.useRef(null),K=s.placeholder||d?.chatUiConfig?.placeholder||"Type a message...",{isRecording:q,isSupported:Z,transcript:Q,toggleRecording:F,clearTranscript:X}=ms({onError:wt=>{console.error("Voice recording error:",wt)}});j.useEffect(()=>{Q&&B(Q)},[Q]);const it=j.useCallback(()=>{const wt=G.current;wt&&(wt.style.height="auto",wt.style.height=`${Math.min(wt.scrollHeight,150)}px`)},[]);j.useEffect(()=>{it()},[_,it]);const w=j.useCallback(()=>{_.trim()&&!c&&(n(_),B(""),X(),G.current&&(G.current.style.height="auto",G.current.focus()))},[_,c,n,X]),tt=j.useCallback(wt=>{wt.key==="Enter"&&!wt.shiftKey&&(wt.preventDefault(),w())},[w]),L=j.useCallback(wt=>{B(wt.target.value)},[]),Rt=j.useCallback(()=>{F()},[F]),$t=c,Vt=c||!_.trim(),Lt=s.disclaimerText??d?.chatUiConfig?.cautionaryMessageOnCompletions??"AI can make mistakes. Verify important information.";j.useEffect(()=>{!O&&!c&&G.current&&G.current.focus()},[O,c]);const Bt=()=>q?"Listening...":K;return O&&y?v.jsxs(zs,{theme:r,children:[v.jsx(Es,{questionInfo:y,progress:S,onAnswer:A,onSkip:x,onCancel:p,theme:r}),Lt&&v.jsx(As,{theme:r,children:Lt})]}):v.jsxs(zs,{theme:r,children:[v.jsxs(Kp,{theme:r,disabled:$t,children:[v.jsx(Jp,{ref:G,theme:r,value:_,onChange:L,onKeyDown:tt,placeholder:Bt(),disabled:$t,"aria-label":"Message input",rows:1}),v.jsxs(Wp,{children:[Z&&v.jsx(Pp,{theme:r,onClick:Rt,isRecording:q,"aria-label":q?"Stop recording":"Start voice recording",title:q?"Stop recording":"Start voice recording",children:v.jsx(hs,{size:18})}),v.jsx(Fp,{theme:r,onClick:w,disabled:Vt,"aria-label":"Send message",children:v.jsx(ga,{size:18})})]})]}),Lt&&v.jsx(As,{theme:r,children:Lt})]})},eg=Pe`
|
|
1039
1039
|
from { opacity: 0; }
|
|
1040
1040
|
to { opacity: 1; }
|
|
1041
1041
|
`,lg=Pe`
|
package/package.json
CHANGED