1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[974],{489:()=>{},578:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>r_});var r=s(5155),n=s(5959),a=s(9863);let i={queryCount:0,resetTime:0,limit:0,lastResetCheck:Date.now(),isSyncing:!1},o=(e,t)=>{if(void 0===e)return t;let s=parseInt(e,10);return Number.isFinite(s)?s:t},l=(0,n.v)()((0,a.Zr)((e,t)=>({...i,incrementQueryCount:()=>{e(e=>({queryCount:e.queryCount+1}))},setFromHeaders:t=>{let s=o(t["x-ratelimit-limit"]||t["X-RateLimit-Limit"],5),r=o(t["x-ratelimit-remaining"]||t["X-RateLimit-Remaining"],0),n=o(t["x-ratelimit-reset"]||t["X-RateLimit-Reset"],0);e({limit:s,queryCount:Math.max(0,s-r),resetTime:n>1e12?n:1e3*n,lastResetCheck:Date.now(),isSyncing:!1})},reset:()=>{e({queryCount:0,resetTime:0,limit:0,lastResetCheck:Date.now(),isSyncing:!1})},getRemainingQueries:()=>{let e=t();return e.resetTime>0&&Date.now()>=e.resetTime?e.limit:Math.max(0,e.limit-e.queryCount)},isLimitReached:()=>{let e=t();return!(e.limit<=0||e.resetTime>0&&Date.now()>=e.resetTime)&&e.queryCount>=e.limit},getTimeUntilReset:()=>(e=>{let t=e-Date.now();if(t<=0)return"0m";let s=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4);return s>0&&r>0?"".concat(s,"h").concat(r,"m"):s>0?"".concat(s,"h"):"".concat(r,"m")})(t().resetTime)}),{name:"synapse-rate-limit-store",storage:(0,a.KU)(()=>localStorage),partialize:e=>({queryCount:e.queryCount,limit:e.limit,resetTime:e.resetTime,lastResetCheck:e.lastResetCheck}),onRehydrateStorage:()=>e=>{e&&(e.isSyncing=!1,e.resetTime>0&&Date.now()>=e.resetTime&&(e.queryCount=0,e.resetTime=0))}}));var c=s(6489),d=s(2115);let u=()=>{let{data:e,status:t}=(0,c.useSession)(),s="authenticated"===t,r=(0,d.useRef)(t),n=l(e=>e.reset);return(0,d.useEffect)(()=>{"authenticated"!==r.current&&"authenticated"===t&&n(),r.current=t},[t,n]),{session:e,status:t,isAuthenticated:s}};var m=s(5704);let p="__featureFlagOverrides";var x=s(5704);let h=()=>{var e;let t=(e=>{if("true"===m.env.FF_PANEL_ENABLED)return(()=>{let e=globalThis;return e[p]||(e[p]=new Map),e[p]})().get(e)})("disableRateLimiting");return void 0!==t?t:null!=(e=(e=>{if(null==e)return;let t=e.trim().toLowerCase();return"true"===t||"1"===t||"yes"===t||"on"===t||"false"!==t&&"0"!==t&&"no"!==t&&"off"!==t&&void 0})(x.env.FF_DISABLE_RATE_LIMITING))&&e},f=()=>{let e=l();return{limit:e.limit,isLimitReached:!h()&&e.isLimitReached(),questionCount:e.queryCount,remainingQueries:h()?1/0:e.getRemainingQueries(),timeUntilReset:e.getTimeUntilReset(),isSyncing:e.isSyncing,incrementQueryCount:e.incrementQueryCount,reset:e.reset}};var g=s(1494);let b={name:null,email:null,image:null,access_token:null},v=(0,n.v)()((e,t)=>({...b,setUser:t=>{e(e=>({...e,...t}))},setAccessToken:t=>{e({access_token:t})},clearUser:()=>{e(b)},isAuthenticated:()=>{let e=t();return!!e.access_token&&!!e.email},getUser:()=>{let e=t();return{name:e.name,email:e.email,image:e.image,access_token:e.access_token}},getUserName:()=>t().name,getUserEmail:()=>t().email,getUserImage:()=>t().image,getAccessToken:()=>t().access_token}));try{window.localStorage.removeItem("synapse-user-store")}catch(e){}var j=s(6600);let y=["RefreshTokenExpiredError","RefreshAccessTokenError","SessionDeletedError"],w=null,N=null,k=e=>{N=e},C=e=>!!((null==e?void 0:e.error)&&y.includes(e.error)),_=()=>(null!=w||(w=Promise.resolve((0,c.getSession)()).then(e=>(C(e)&&Promise.resolve().then(()=>null==N?void 0:N()).catch(()=>null),e)).finally(()=>{w=null})),w),S=e=>(e&&e!==v.getState().access_token&&v.getState().setAccessToken(e),e),R=async()=>{var e;let t=await _().catch(()=>null);return!t||C(t)?null:S(null!=(e=t.accessToken)?e:null)},E=async()=>{let e=v.getState().access_token;if(e&&!(e=>{try{let{exp:t}=(0,j.s)(e);if(!t)return!0;return t-Math.floor(Date.now()/1e3)<=120}catch(e){return!0}})(e))return{token:e,sessionExpired:!1};let t=await _().catch(()=>null);if(t){var s;let e=C(t)?null:S(null!=(s=t.accessToken)?s:null);return e?{token:e,sessionExpired:!1}:{token:null,sessionExpired:!0}}return e?(e=>{try{let{exp:t}=(0,j.s)(e);return!t||t<=Math.floor(Date.now()/1e3)}catch(e){return!0}})(e)?{token:null,sessionExpired:!0}:{token:e,sessionExpired:!1}
1:{token:null,sessionExpired:!1}};class A extends Error{constructor(e,t,s){super(t),this.type=e,this.message=t,this.cause=s}}let I={RATE_LIMIT_ERROR:"RateLimitError",API_ERROR:"InternalServerError",CHAT_ERROR:"LLMProcessingError",AUTHENTICATION_ERROR:"AuthenticationError",NOT_FOUND_ERROR:"NotFoundError",VALIDATION_ERROR:"InvalidRequestError",SERVICE_UNAVAILABLE_ERROR:"ServiceUnavailableError"},L={401:"AUTHENTICATION_ERROR",404:"NOT_FOUND_ERROR",422:"VALIDATION_ERROR",503:"SERVICE_UNAVAILABLE_ERROR"},D=e=>{var t;let s=null!=(t=I[e.error_code])?t:"InternalServerError",r={};return e.recovery_suggestion&&(r.recovery_suggestion=e.recovery_suggestion),e.details&&(r.details=e.details),new A(s,e.message,Object.keys(r).length>0?r:void 0)},T=(e,t)=>{var s;return D({event_type:"error",error_code:null!=(s=L[e])?s:"API_ERROR",message:null!=t?t:"HTTP ".concat(e)})},F=()=>{let{url:e,endpoint:t}=g.J.getState().getApi();return"".concat(e).concat(t,"/conversations")},q=e=>({"Content-Type":"application/json",...e?{Authorization:"Bearer ".concat(e)}:{}}),M=async(e,t,s)=>{let{method:r,signal:n}=t,a=new AbortController,i=setTimeout(()=>a.abort(),3e4),o=()=>a.abort();n&&(n.aborted?a.abort():n.addEventListener("abort",o));try{return await fetch("".concat(F()).concat(e),{method:r,headers:q(s),signal:a.signal})}catch(e){throw new A("ServiceUnavailableError",e instanceof Error?e.message:"Network error")}finally{clearTimeout(i),n&&n.removeEventListener("abort",o)}},z=async(e,t)=>{let{expectBody:s=!0,treat404AsSuccess:r=!1}=t;if(!e.ok){if(r&&404===e.status)return;throw T(e.status,"HTTP ".concat(e.status,": ").concat(e.statusText))}if(s)return await e.json()},O=async(e,t)=>{let{token:s,sessionExpired:r}=await E();if(r)throw T(401,"Session expired");let n=await M(e,t,s);if(401===n.status&&s){let s=await R();if(s)return z(await M(e,t,s),t)}return z(n,t)},P=function(){let{limit:e=20,offset:t=0}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},s=new URLSearchParams({limit:String(e),offset:String(t)});return O("?".concat(s.toString()),{method:"GET"})},H=0,U=()=>{let e=g.J.getState().getFeatureFlag("enableConversationHistory"),t=!!v.getState().access_token;return e&&t},B={conversations:[],searchResults:[],searchInputValue:"",searchQuery:"",searchId:null,pendingSearchTracking:null,activeConversationId:null,isLoading:!1,isSearching:!1,isLoadingMore:!1,total:0,fetchedIds:new Set,error:null,deletionError:null,pendingDeletions:[],committingDeletions:[]},V=e=>e instanceof A?e:new A("InternalServerError","Unexpected error"),G=e=>{let t=new Set;return e.filter(e=>!t.has(e.id)&&(t.add(e.id),!0))},W=(e,t)=>{let s=new Set(t.map(e=>e.id));return G(e.filter(e=>!s.has(e.id)))},Q=e=>[...e.pendingDeletions,...e.committingDeletions],J=(e,t)=>{let s=[...e],r=Math.min(Math.max(t.index,0),s.length);return s.splice(r,0,t.summary),G(s).slice(0,1e3)},Z=(e,t)=>{if(!t.searchResult||e.some(e=>e.id===t.id))return e;let s=[...e],r=Math.min(Math.max(t.searchIndex,0),s.length);return s.splice(r,0,t.searchResult),s.slice(0,1e3)},K=(0,n.v)()((e,t)=>({...B,fetchConversations:async s=>{if(U()&&!t().isLoading){e({isLoading:!0,error:null});try{let t=await P(s);e(e=>({conversations:W(t.conversations,Q(e)).slice(0,1e3),total:t.total,fetchedIds:new Set(t.conversations.map(e=>e.id)),isLoading:!1}))}catch(t){e({error:V(t),isLoading:!1})}}},loadMoreConversations:async s=>{if(!U())return;let{conversations:r,fetchedIds:n,total:a,isLoading:i,isLoadingMore:o}=t();if(!i&&!o&&!(r.length>=1e3)&&!(n.size>=a)){e({isLoadingMore:!0,error:null});try{let t=await P({offset:n.size,limit:null==s?void 0:s.limit});e(e=>({conversations:W([...e.conversations,...t.conversations],Q(e)).slice(0,1e3),total:t.total,fetchedIds:new Set([...e.fetchedIds,...t.conversations.map(e=>e.id)]),isLoadingMore:!1}))}catch(t){e({error:V(t),isLoadingMore:!1})}}},search:async(t,s)=>{if(U()){e({searchQuery:t,isSearching:!0,error:null});try{let r=await (e=>{let{q:t,limit:s=20,offset:r=0}=e,n=new URLSearchParams({q:t,limit:String(s),offset:String(r)});return O("/search?".concat(n.toString()),{method:"GET"})})({q:t,...s});e({searchResults:r.results.slice(0,1e3),isSearching:!1})}catch(t){e({error:V(t),isSearching:!1})}}},setSearchInputValue:t=>e({searchInputValue:t}),clearSearch:()=>
1e({searchQuery:"",searchId:null,searchResults:[],isSearching:!1,error:null}),startOrUpdateSearchIntention:t=>e(e=>({pendingSearchTracking:e.pendingSearchTracking?{...e.pendingSearchTracking,searchText:t}:{searchId:crypto.randomUUID(),searchText:t,hasReachedBackend:!1}})),markSearchIntentionSubmitted:()=>{let s=t().pendingSearchTracking;s&&e({pendingSearchTracking:{...s,hasReachedBackend:!0},searchId:s.searchId})},consumeSearchTrackingIntention:()=>{let s=t().pendingSearchTracking;return s&&s.hasReachedBackend?(e({pendingSearchTracking:null}),{searchId:s.searchId,searchText:s.searchText}):null},requestDeletion:(s,r)=>{if(!U())return;let{conversations:n,searchResults:a,activeConversationId:i}=t(),o=n.findIndex(e=>e.id===s),l=a.findIndex(e=>e.id===s),c=l>=0?a[l]:null,d=o>=0?n[o]:(()=>{if(!c)return null;let{id:e,title:t,created_at:s,updated_at:r,message_count:n}=c;return{id:e,title:t,created_at:s,updated_at:r,message_count:n}})();if(!d)return;let u={toastId:"deletion-".concat(++H),id:s,title:r,summary:d,index:o,wasActive:i===s,searchResult:c,searchIndex:l};e(e=>({conversations:e.conversations.filter(e=>e.id!==s),searchResults:e.searchResults.filter(e=>e.id!==s),activeConversationId:e.activeConversationId===s?null:e.activeConversationId,pendingDeletions:[...e.pendingDeletions,u],total:Math.max(0,e.total-1),error:null,deletionError:null}))},restoreDeletion:s=>{let r=t().pendingDeletions.find(e=>e.toastId===s);r&&e(e=>({conversations:J(e.conversations,r),searchResults:Z(e.searchResults,r),activeConversationId:r.wasActive?r.id:e.activeConversationId,pendingDeletions:e.pendingDeletions.filter(e=>e.toastId!==s),total:e.total+1}))},commitDeletion:async s=>{let r=t().pendingDeletions.find(e=>e.toastId===s);if(!r)return;let n=e=>({pendingDeletions:e.pendingDeletions.filter(e=>e.toastId!==s),committingDeletions:e.committingDeletions.filter(e=>e.toastId!==s)});if(!U())return void e(n);e(e=>({pendingDeletions:e.pendingDeletions.filter(e=>e.toastId!==s),committingDeletions:[...e.committingDeletions,r]}));try{let t;await (t=r.id,O("/".concat(encodeURIComponent(t)),{method:"DELETE",expectBody:!1,treat404AsSuccess:!0})),e(e=>({...n(e),fetchedIds:((e,t)=>{if(!e.has(t))return e;let s=new Set(e);return s.delete(t),s})(e.fetchedIds,r.id)}))}catch(t){e(e=>({...n(e),conversations:J(e.conversations,r),searchResults:Z(e.searchResults,r),activeConversationId:r.wasActive?r.id:e.activeConversationId,total:e.total+1,deletionError:V(t)}))}},flushPendingDeletions:()=>{let s=Q(t());0!==s.length&&(s.forEach(e=>(e=>{try{fetch("".concat(F(),"/").concat(encodeURIComponent(e)),{method:"DELETE",headers:q(v.getState().access_token),keepalive:!0})}catch(e){}})(e.id)),e({pendingDeletions:[],committingDeletions:[]}))},upsertConversation:t=>e(e=>{var s;if(Q(e).some(e=>e.id===t.id))return{};let r=e.conversations.find(e=>e.id===t.id),n=e.conversations.filter(e=>e.id!==t.id);return{conversations:G([r?{...r,title:null!=(s=t.title)?s:r.title,updated_at:t.updated_at}:t,...n]).slice(0,1e3)}}),setActiveConversationId:t=>e({activeConversationId:t}),clearError:()=>e({error:null,deletionError:null}),reset:()=>e({...B})}));var $=s(7909),X=s(4269);function Y(e){let{children:t,position:s="bottom",spacing:n="medium",showBackdrop:a=!0,zIndex:i=50,maxWidth:o="max-w-4xl",background:l="card",border:c="default",shadow:d="xl",className:u}=e;return(0,r.jsxs)("div",{className:(0,X.cn)("relative z-50 px-3 sm:px-8 bottom-4","z-".concat(i)),children:[a&&(0,r.jsx)("div",{className:(0,X.cn)("absolute left-0 right-0 h-full backdrop-blur-sm pointer-events-none -top-4","bottom"===s?"bg-gradient-to-t from-background/20 via-background/10 to-transparent":"-top-10 bg-gradient-to-b from-background/20 via-background/10 to-transparent")}),(0,r.jsx)("div",{className:(0,X.cn)("mx-auto relative",o),children:(0,r.jsx)("div",{className:(0,X.cn)("backdrop-blur-md rounded-2xl",{card:"bg-card/95",muted:"bg-muted/95",transparent:"bg-transparent"}[l],{default:"border border-border/50",subtle:"border border-border/20",none:""}[c],{none:"",sm:"shadow-sm",md:"shadow-md",lg:"shadow-lg",xl:"shadow-xl"}[d],u),children:t})})]})}let ee={MAX_CHARACTERS:2500,WARNING_THRESHOLD:2250},et={MOBILE:768},es="https://app.medgpt.fr",er={ios:"".concat(es,"/app/ios"),android:"".concat(es,"/app/android")},en=d.useLayoutEffect,ea=()=>{let[e,t]=(0,d.useState)(!1),[s,r]=(0,d.useState)(!1);return en(()=>{let e;r(/Mobile|Android|iPhone/i.test(navigator.userAgent));let s=()=>{t(window.innerWidth<et.MOBILE)};s();let n=()=>{e&&clearTimeout(e),e=setTimeout(s,150)};
1return window.addEventListener("resize",n),()=>{e&&clearTimeout(e),window.removeEventListener("resize",n)}},[]),{isMobileScreen:e,isMobileUserAgent:s}};var ei=s(3896);let eo=(0,n.v)()((0,a.Zr)((e,t)=>({pendingAction:null,dontWarnAgain:!1,requestLeave:(s,r)=>{if(r&&!t().dontWarnAgain)return void e({pendingAction:s});e({pendingAction:null}),s()},confirmLeave:s=>{s&&e({dontWarnAgain:!0}),t().resolvePendingAction()},cancelLeave:()=>e({pendingAction:null}),resolvePendingAction:()=>{let{pendingAction:s}=t();s&&(e({pendingAction:null}),s())}}),{name:"synapse-leave-conversation-guard",storage:(0,a.KU)(()=>localStorage),partialize:e=>({dontWarnAgain:e.dontWarnAgain})})),el=(0,n.v)()(e=>({isOpen:!0,open:()=>e({isOpen:!0}),close:()=>e({isOpen:!1})}));var ec=s(5239),ed=s(3693),eu=s.n(ed);let em=(0,n.v)()((0,a.Zr)(e=>({isModalOpen:!1,isDismissed:!1,specialty:"",detail:"",openModal:()=>e({isModalOpen:!0}),closeModal:()=>e({isModalOpen:!1}),dismissBanner:()=>e({isDismissed:!0}),setQualification:(t,s)=>e({specialty:t,detail:s})}),{name:"synapse-specialty-qualification",storage:(0,a.KU)(()=>localStorage),partialize:e=>({specialty:e.specialty,detail:e.detail})})),ep=[],ex=()=>{let{isTrackingDisabled:e,getSessionId:t}=(0,g.J)(),s=(0,d.useCallback)(async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!ep.length)return;let t=ep.splice(0,ep.length);try{let s=await fetch("/api/public/track",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({events:t}),...e&&{keepalive:e}});if(!s.ok)throw Error("Track: ".concat(s.status,": ").concat(s.statusText))}catch(e){}},[]),r=(0,d.useRef)(eu()(s,2e3));return{track:(0,d.useCallback)((n,a,i)=>{var o,l;if(e())return;let{specialty:c,detail:d}=em.getState(),u={event_type:n,event_properties:{...a},user_properties:{user_agent:null!=(o=(0,X.VK)().user_agent)?o:"",session_id:null!=(l=t())?l:void 0,...""!==c&&{user_type:c,user_sub_type:d},...i}};ep.push(u),ep.length>200?s():r.current()},[s,e,t]),flush:(0,d.useCallback)(()=>{r.current.cancel(),s(!0)},[s])}};var eh=s(5229);let ef=e=>{let{size:t=16,className:s}=e;return(0,r.jsx)("svg",{width:t,height:t,viewBox:"0 0 16.4937 16.4937",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:s,"aria-hidden":"true",children:(0,r.jsx)("path",{d:"M5.75004 6.99374H10.75M5.75004 9.49374H10.75M1.79912 12.0717C0.8673 10.5009 0.540967 8.6439 0.881404 6.84948C1.22184 5.05507 2.20563 3.44666 3.64804 2.32627C5.09044 1.20587 6.89224 0.650576 8.7151 0.764645C10.538 0.878715 12.2565 1.6543 13.5479 2.94578C14.8394 4.23725 15.615 5.95576 15.7291 7.77861C15.8432 9.60147 15.2879 11.4033 14.1675 12.8457C13.0471 14.2881 11.4387 15.2719 9.6443 15.6123C7.84988 15.9528 5.99291 15.6265 4.42207 14.6946L1.83173 15.4347C1.72456 15.4653 1.61115 15.4667 1.50326 15.4387C1.39536 15.4108 1.2969 15.3545 1.21809 15.2757C1.13927 15.1968 1.08297 15.0984 1.05501 14.9905C1.02705 14.8826 1.02846 14.7692 1.05908 14.662L1.79912 12.0717Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})};var eg=s(562);let eb=e=>{let{onSkip:t}=e,s=(0,ei.s)();return(0,r.jsx)("button",{type:"button","data-testid":"clarification-skip-button",onClick:t,className:"h-10 shrink-0 cursor-pointer rounded-[12px] border border-[#e6e6e6] bg-white px-4 text-base font-semibold leading-[1.35] text-[#333333] transition-colors hover:bg-grey-0 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand-purple-light",children:s("chat.clarification.skip")})},ev=e=>{let{isEnabled:t,onSubmit:s}=e,n=(0,ei.s)();return(0,r.jsx)("button",{type:"button","data-testid":"clarification-submit-button","aria-label":n("common.send"),disabled:!t,onClick:s,className:(0,X.cn)("flex size-10 shrink-0 items-center justify-center rounded-[12px] transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand-purple-light",t?"cursor-pointer bg-[#333333] text-white":"bg-[#d9d9d9] text-[#f5f5f5]"),children:(0,r.jsx)(eg.A,{className:"size-4",strokeWidth:1.5})})};var ej=s(2987),ey=s(5917);let ew=e=>{let{size:t=16,className:s}=e;return(0,r.jsx)("svg",{width:t,height:t,viewBox:"0 0 12.7929 12.7929",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:s,"aria-hidden":"true",children:(0,r.jsx)("path",{d:"M6.75 2.54289L10.25 6.04289M4.21806 12.011L0.781804 8.57471M4.04289 12.0429H1.25C1.11739 12.0429 0.990215 11.9902 0.896447 11.8964C0.802679 11.8027 0.75 11.6755 0.75 11.5429V8.75C0.75 8.68434 0.762933 8.61932 0.78806 8.55866C0.813188 8.498 0.850018 8.44288 0.896447 8.39645L8.39645 0.896446C8.49022 0.802678 8.61739 0.75 8.75 0.75C8.88261 0.75 9.00979 0.802678 9.10355 0.896446L11.8964 3.68934C11.9902 3.78311 12.0429 3.91028 12.0429 4.04289C12.0429 4.1755 11.9902 4.30268 11.8964 4.39645L4.39645 11.8964C4.35002 11.9429 4.2949 11.9797 4.23424 12.0048C4.17357 12.03 4.10855 12.0429 4.04289 12.0429Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})},eN="flex min-h-[52px] w-full items-start rounded-[12px] pr-4 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand-purple-light",ek="flex min-h-[52px] w-full items-center rounded-[12px] bg-grey-0 py-1.5
1sm:pr-2",eC="flex size-10 shrink-0 items-center justify-center rounded-[12px] bg-[#ededed] text-sm font-semibold leading-[1.35] transition-colors",e_="flex size-[18px] shrink-0 items-center justify-center rounded-[6px] border transition-colors",eS="wrap-break-word min-w-0 flex-1 text-sm leading-[1.35]",eR=e=>{let{option:t,value:s,onChange:n,onSubmit:a,onCancel:i}=e,o=(0,ei.s)();return(0,r.jsx)("input",{autoFocus:!0,type:"text","data-testid":"clarification-free-text-input","aria-label":t.text,placeholder:o("chat.clarification.free-text-placeholder"),value:s,onChange:e=>n(e.target.value),onKeyDown:e=>{if("Escape"===e.key){e.stopPropagation(),i();return}"Enter"===e.key&&(e.preventDefault(),e.stopPropagation(),s.trim()&&a())},className:"min-w-0 flex-1 bg-transparent text-base leading-[1.35] text-[#333333] outline-none placeholder:text-[#737373] sm:text-sm"})},eE=e=>{let{option:t,index:s,isDimmed:n,onSelect:a}=e;return(0,r.jsxs)("button",{type:"button","data-testid":"clarification-option","data-option-index":s,"data-option-id":t.id,disabled:n,onClick:a,className:(0,X.cn)(eN,"group gap-4 py-1.5 pl-1",n?"pointer-events-none":"cursor-pointer hover:bg-grey-0 focus-visible:bg-grey-0"),children:[(0,r.jsx)("span",{"aria-hidden":!0,"data-testid":"clarification-option-badge","data-badge":t.free_text?"pencil":"letter",className:(0,X.cn)(eC,n?"text-[#bfbfbf]":"text-[#737373] group-hover:text-[#1a1a1a] group-focus-visible:text-[#1a1a1a]"),children:t.free_text?(0,r.jsx)(ew,{}):String.fromCharCode(65+s)}),(0,r.jsxs)("span",{className:"flex min-h-10 min-w-0 flex-1 items-center justify-between gap-4",children:[(0,r.jsx)("span",{className:(0,X.cn)(eS,n?"text-[#bfbfbf]":"text-[#333333]"),children:t.text}),!t.free_text&&(0,r.jsx)(ej.A,{"aria-hidden":!0,"data-testid":"clarification-option-arrow",className:"hidden size-5 shrink-0 text-[#737373] group-hover:block group-focus-visible:block",strokeWidth:1.5})]})]})},eA=e=>{let{option:t,index:s,value:n,onChange:a,onSubmit:i,onCancel:o,onSkip:l}=e;return(0,r.jsxs)("div",{"data-testid":"clarification-free-text-row","data-option-index":s,"data-option-id":t.id,className:(0,X.cn)(ek,"gap-4 pl-1"),children:[(0,r.jsx)("span",{"aria-hidden":!0,"data-testid":"clarification-free-text-badge",className:(0,X.cn)(eC,"text-[#1a1a1a]"),children:(0,r.jsx)(ew,{})}),(0,r.jsx)(eR,{option:t,value:n,onChange:a,onSubmit:i,onCancel:o}),n.trim()?(0,r.jsx)(ev,{isEnabled:!0,onSubmit:i}):(0,r.jsx)(eb,{onSkip:l})]})},eI=e=>{let{option:t,index:s,isSelected:n,onToggle:a}=e;return(0,r.jsxs)("button",{type:"button",role:"checkbox","aria-checked":n,"data-state":n?"checked":"unchecked","data-testid":"clarification-option","data-option-index":s,"data-option-id":t.id,onClick:a,className:(0,X.cn)(eN,"cursor-pointer gap-2 py-4 pl-3",n?"bg-grey-0":"hover:bg-grey-0 focus-visible:bg-grey-0"),children:[(0,r.jsx)("span",{"aria-hidden":!0,"data-testid":"clarification-option-checkbox",className:(0,X.cn)(e_,n?"border-[#333333] bg-[#333333] text-white":"border-[#bfbfbf] bg-white"),children:n&&(0,r.jsx)(ey.A,{className:"size-4",strokeWidth:1.5})}),(0,r.jsx)("span",{className:(0,X.cn)(eS,t.free_text?"text-[#737373]":"text-[#333333]"),children:t.text})]})},eL=e=>{let{option:t,index:s,value:n,onChange:a,onSubmit:i,onUncheck:o,onCancel:l}=e;return(0,r.jsxs)("div",{"data-testid":"clarification-free-text-row","data-option-index":s,"data-option-id":t.id,className:(0,X.cn)(ek,"gap-2 pl-3"),children:[(0,r.jsx)("button",{type:"button",role:"checkbox","aria-checked":!0,"data-state":"checked","data-testid":"clarification-option","data-option-index":s,"data-option-id":t.id,"aria-label":t.text,onClick:o,className:"-m-1 shrink-0 cursor-pointer rounded-[10px] p-1 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand-purple-light",children:(0,r.jsx)("span",{"aria-hidden":!0,"data-testid":"clarification-option-checkbox",className:(0,X.cn)(e_,"border-[#333333] bg-[#333333] text-white"),children:(0,r.jsx)(ey.A,{className:"size-4",strokeWidth:1.5})})}),(0,r.jsx)(eR,{option:t,value:n,onChange:a,onSubmit:i,onCancel:l})]})},eD="mx-4 h-px bg-[#e6e6e6] sm:mx-2",eT=e=>{let{questions:t,queryId:s,onSkip:n,onComplete:a}=e,i=(0,ei.s)(),{track:o}=ex(),l=(0,d.useId)(),c=(0,d.useRef)(null),[u,m]=(0,d.useState)(0),[p,x]=(0,d.useState)([]),[h,f]=(0,d.useState)([]),[g,b]=(0,d.useState)(""),v=(0,d.useRef)(!1),j=e=>{v.current||(v.current=!0,e())},y=()=>j(()=>n(p)),w=t[u],N=(0,d.useRef)("");if((0,d.useEffect)(()=>
1{if(!s||N.current===s)return;let[e,...r]=t.flatMap((e,t)=>{let[s,...r]=e.options.map((e,t)=>({option_id:String(e.id),option_index:t,option_text:e.text,free_text:e.free_text}));return s?[{question_index:t,question_text:e.question,selection_mode:e.selection_mode,options:[s,...r]}]:[]});e&&(N.current=s,o("trackOnCompanionClarificationsAsked",{query_id:s,questions:[e,...r]}))},[s,t,o]),!w)return null;let k=u===t.length-1,C="cumulative"===w.selection_mode,_=g.trim(),S=_.length>0,R=w.options.filter(e=>{let{id:t}=e;return h.includes(t)}),E=R.some(e=>!e.free_text||S),A=R.some(e=>e.free_text),I=e=>w.options.some(t=>t.id===e),L=e=>{if(k)return void j(()=>a(e));x(e),f([]),b(""),m(u+1)},D=e=>{let t={question:w.question,questionIndex:u,optionIds:e};w.options.some(t=>t.free_text&&e.includes(t.id))&&S&&(t.freeText=_),L([...p,t])},T=()=>L(p),F=e=>{e.free_text&&h.includes(e.id)&&b(""),f(t=>t.includes(e.id)?t.filter(t=>t!==e.id):[...t,e.id])},q=e=>{var t;F(e),null==(t=c.current)||t.focus()},M=()=>D(h.filter(I));return(0,r.jsxs)("div",{ref:c,role:"group",tabIndex:-1,"aria-labelledby":l,"data-testid":"clarification-card",onKeyDown:e=>{"Escape"===e.key&&y()},className:(0,X.cn)("rounded-[16px] border border-brand-purple-light bg-white pt-4 shadow-[0_4px_6px_0_var(--brand-light-tertiary)] focus:outline-none",C?"pb-4":"pb-4 sm:pb-2"),children:[(0,r.jsxs)("div",{"data-testid":"clarification-header",className:"flex items-center gap-4 px-4",children:[(0,r.jsx)("span",{"aria-hidden":!0,"data-testid":"clarification-header-icon",className:"flex size-10 shrink-0 items-center justify-center rounded-[12px] bg-brand-light-tertiary text-brand-main-tertiary",children:(0,r.jsx)(ef,{size:20})}),(0,r.jsxs)("div",{"data-testid":"clarification-title-block",className:"flex min-w-0 flex-1 flex-col gap-1 sm:flex-row sm:items-center sm:gap-2",children:[(0,r.jsx)("h3",{id:l,"data-testid":"clarification-question",className:"wrap-break-word text-base font-semibold leading-[1.35] text-[#333333]",children:w.question}),(0,r.jsxs)("span",{"data-testid":"clarification-progress",className:"shrink-0 text-sm leading-[1.35] text-[#737373]",children:[u+1,"/",t.length]})]}),(0,r.jsx)("button",{type:"button","data-testid":"clarification-close-button","aria-label":i("ui.close"),onClick:y,className:"-mt-2 -mr-2 flex size-10 shrink-0 cursor-pointer items-center justify-center self-start rounded-[12px] text-[#333333] transition-colors hover:bg-grey-0 focus-visible:bg-grey-0 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand-purple-light sm:mt-0 sm:mr-0 sm:self-auto",children:(0,r.jsx)(eh.A,{className:"size-5",strokeWidth:2})})]}),(0,r.jsx)("div",{"data-testid":"clarification-separator",className:(0,X.cn)(eD,"mt-3 sm:mt-4")}),(0,r.jsx)("div",{"data-testid":"clarification-options",className:(0,X.cn)("mt-3 flex flex-col gap-1 px-4 sm:mt-2 sm:px-2",A&&"max-h-[86px] overflow-y-auto sm:max-h-none sm:overflow-visible"),children:w.options.map((e,t)=>{let s=h.includes(e.id);return C?e.free_text&&s?(0,r.jsx)(eL,{option:e,index:t,value:g,onChange:b,onSubmit:M,onUncheck:()=>F(e),onCancel:()=>q(e)},e.id):(0,r.jsx)(eI,{option:e,index:t,isSelected:s,onToggle:()=>F(e)},e.id):e.free_text&&s?(0,r.jsx)(eA,{option:e,index:t,value:g,onChange:b,onSubmit:()=>D([e.id]),onCancel:()=>q(e),onSkip:T},e.id):(0,r.jsx)(eE,{option:e,index:t,isDimmed:S,onSelect:()=>e.free_text?f([e.id]):D([e.id])},e.id)})}),C&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{"data-testid":"clarification-footer-separator",className:(0,X.cn)(eD,"mt-3 sm:mt-1.5")}),(0,r.jsxs)("div",{"data-testid":"clarification-footer",className:"mt-3 flex items-center justify-between gap-3 px-4",children:[(0,r.jsx)("span",{"data-testid":"clarification-counter",className:"text-sm leading-[1.35] text-[#737373]",children:i("chat.clarification.selected-count",{count:h.length})}),(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)(eb,{onSkip:T}),(0,r.jsx)(ev,{isEnabled:E,onSubmit:M})]})]})]})]})};var eF=s(2056);let eq=()=>{let e=(0,ei.s)();return(0,g.J)(e=>e.getFeatureFlag("enableDegradedServiceBanner"))?(0,r.jsxs)("div",{"data-testid":"degraded-service-banner",role:"status",className:"flex items-center gap-2 bg-[#fffbeb] text-xs px-2 py-2 sm:px-3 rounded-[12px] mb-2 border border-[#fcd34d]",children:[(0,r.jsx)(eF.A,{size:16,className:"shrink-0 text-[#b45309]"}),(0,r.jsx)("span",{className:"text-grey-100",children:e("degraded-service.message")})]}):null};var eM=s(3998);function ez(e){let{className:t,...s}=e;return(0,r.jsx)("textarea",{"data-slot":"textarea",className:(0,X.cn)("flex field-sizing-content min-h-16 w-full bg-transparent px-3 py-2 text-base transition-[color,box-shadow] outline-none disabled:cursor-not-allowed disabled:opacity-50",t),...s})}var eO=s(9e3),eP=s(8392),eH=s(6132);function eU(e){let{className:t,...s}=e;return(0,r.jsx)("div",{"data-slot":"card",className:(0,X.cn)("bg-card text-card-foreground flex flex-col rounded-xl border py-6 shadow-sm",t),...s})}let eB=["AuthenticationError"],eV=["LLMProcessingError","DocumentRetrievalError","InternalServerError"],eG={error:"border-alert-100 bg-alert-100-light",warning:"border-alert-50 bg-alert-50-light"}
1,eW={error:"bg-alert-100",warning:"bg-alert-50"},eQ={error:(0,r.jsx)(eP.A,{color:"white",size:16}),warning:(0,r.jsx)(eH.A,{color:"white",size:16})},eJ=e=>{let{type:t,errorType:s,className:n,onRetry:a,onConnect:i}=e,o=(0,ei.s)();return(0,r.jsx)("div",{className:(0,X.cn)("mb-2",n),"data-testid":"error-message",children:(0,r.jsxs)(eU,{className:(0,X.cn)("p-2 rounded-md flex items-center justify-between flex-row",eG[t]),children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("div",{className:(0,X.cn)("flex items-center justify-center p-1 rounded-sm",eW[t]),children:eQ[t]}),(0,r.jsx)("div",{className:"text-sm text-grey-100 font-semibold",children:o("errors.".concat(s))})]}),eV.includes(s)&&a&&(0,r.jsx)("button",{type:"button",className:"text-sm text-grey-100 underline cursor-pointer",onClick:a,children:o("common.send-again")}),eB.includes(s)&&i&&(0,r.jsx)("button",{type:"button",className:"text-sm text-grey-100 underline cursor-pointer",onClick:i,children:o("auth.sign-in")})]})})};var eZ=s(2467);let eK=(0,s(3101).F)("inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function e$(e){let{className:t,variant:s,asChild:n=!1,...a}=e,i=n?eZ.DX:"span";return(0,r.jsx)(i,{"data-slot":"badge",className:(0,X.cn)(eK({variant:s}),t),...a})}let eX=e=>{let{count:t,max:s,isOverLimit:n}=e;return(0,r.jsx)(e$,{"data-testid":"character-counter",variant:"outline",className:"rounded-sm",children:(0,r.jsxs)("p",{className:"text-grey-75 font-semibold text-[10px] leading-[125%]",children:[(0,r.jsx)("span",{className:(0,X.cn)(n&&"text-alert-100"),children:t}),"/",s]})})},eY=JSON.parse('{"hq":"https://medgpt.fr/blog","hU":"https://www.synapse-medicine.com/fr/medgpt-contact/","t1":"https://www.notion.so/synapse-medicine/FAQ-MedGPT-fr-Utilisateurs-2ef6bc097a95808ab33ccde17926abbc","rm":"https://medgpt.eu"}');var e0=s(3327);let e1={sm:"h-[27px]",default:"h-[40px]"},e2=e=>{let{className:t,onClick:s,size:n="default"}=e,a=(0,ei.s)(),{getSessionId:i}=(0,g.J)(),o=async()=>{(0,c.signIn)("keycloak",void 0,{sessionId:i(),prompt:"create"}),s&&s()};return(0,r.jsx)("button",{"data-testid":"register-button",onClick:o,className:(0,X.cn)("cursor-pointer font-semibold px-3 flex items-center rounded-md border border-brand-main-primary text-sm text-white bg-brand-main-primary hover:border-[#1a1a1a] hover:bg-[#1a1a1a]",t,e1[n]),children:a("auth.register")})},e3=()=>{let e=(0,ei.s)(),t=v(e=>e.isAuthenticated());return(0,r.jsxs)("div",{"data-testid":"rate-limit-notice",className:"flex items-center sm:flex-row flex-col gap-2 bg-white text-xs px-2 py-2 sm:px-3 rounded-[12px] mb-2 shadow-[0_4px_12px_0_var(--brand-light-tertiary)] border border-brand-purple-light",children:[(0,r.jsx)("div",{className:"flex-1",children:(0,r.jsxs)("p",{"data-testid":"rate-limit-description",className:"flex gap-2",children:[(0,r.jsx)(e0.A,{size:16,color:"var(--color-grey-75)"}),(0,r.jsx)("span",{className:"text-grey-100",children:t?(0,r.jsxs)(r.Fragment,{children:[e("limit-notice.description-registered")," ",(0,r.jsx)("a",{href:eY.t1,target:"_blank",rel:"noopener noreferrer",className:"underline",children:e("common.faq")})]}):e("limit-notice.description")})]})}),!t&&(0,r.jsx)(e2,{size:"sm"})]})},e5=()=>{let e=(0,ei.s)(),t=em(e=>e.openModal),s=em(e=>e.dismissBanner);return(0,r.jsxs)("div",{"data-testid":"specialty-qualification-banner",className:"flex items-center justify-between gap-6 bg-[#fafafa] px-3 py-3 rounded-[12px] mb-2 border border-grey-25",children:[(0,r.jsxs)("p",{className:"flex flex-1 flex-wrap items-baseline gap-1",children:[(0,r.jsx)("span",{className:"text-sm font-semibold leading-[1.35] text-brand-main-primary",children:e("specialty-qualification.title")}),(0,r.jsx)("span",{className:"text-xs leading-[1.25] text-[#737373]",children:e("specialty-qualification.subtitle")})]}),(0,r.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[(0,r.jsx)(eM.$,{"data-testid":"specialty-qualification-cta",type:"button",variant:"outline",size:"sm",onClick:t,children:e("specialty-qualification.cta")}),(0,r.jsx)(eM.$,{"data-testid":"specialty-qualification-close",type:"button",variant:"ghost",size:"icon","aria-label":e("specialty-qualification.modal.close"),className:"size-6 text-brand-main-primary hover:bg-[#ededed] [&_svg]:size-4",onClick:s,children:(0,r.jsx)(eh.A,{size:16})})]})]})};var e4=s(6767);let e7=(0,n.v)()(e=>({scientificPublications:!1,setScientificPublications:t=>e({scientificPublications:t}),toggleScientificPublications:()=>e(e=>({scientificPublications:!e.scientificPublications})),reset:()=>e({scientificPublications:!1})})),e6=()=>{let e=(0,ei.s)(),t=(0,d.useId)(),s=e7(e=>e.scientificPublications),n=e7(e=>e.setScientificPublications);return(0,r.jsxs)(e4.m_,{children:[(0,r.jsx)(e4.k$,{asChild:!0,children:(0,r.jsxs)("button",{type:"button",role:"checkbox","aria-checked":s,"aria-labelledby":t,"data-testid":"scientific-publications-toggle","data-state":s?"checked":"unchecked",onClick:()=>n(!s),className:(0,X.cn)("flex cursor-pointer items-center gap-2 rounded-lg border border-[#e6e6e6] bg-white px-2 py-1.5","transition-colors hover:bg-grey-0","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand-purple-light"),children:[(0,r.jsx)("span",{"aria-hidden":!0,
1className:(0,X.cn)("flex size-4 shrink-0 items-center justify-center rounded-[4px] border transition-colors",s?"border-[#333333] bg-[#333333] text-white":"border-[#bfbfbf] bg-white"),children:s&&(0,r.jsx)(ey.A,{className:"size-3",strokeWidth:3})}),(0,r.jsxs)("span",{id:t,className:"select-none text-left",children:[(0,r.jsx)("span",{className:"text-sm text-[#333333] whitespace-nowrap min-[430px]:hidden",children:e("sources.search.scientific-publications-label-short")}),(0,r.jsx)("span",{className:"hidden text-sm text-[#333333] min-[430px]:inline",children:e("sources.search.scientific-publications-label")})]}),(0,r.jsx)(e0.A,{size:16,className:"text-[#737373]","aria-hidden":!0})]})}),(0,r.jsxs)(e4.ZI,{side:"top",align:"start",className:"relative max-w-xs overflow-visible mb-2",children:[e("sources.search.scientific-publications-tooltip"),(0,r.jsx)("span",{"aria-hidden":!0,className:"absolute -bottom-1 left-[13px] size-2 rotate-45 bg-primary"})]})]})};s(8738);let e8=["InvalidRequestError","RateLimitError","NoRelevantDocumentError","MaliciousContentError","LLMProcessingError","DocumentRetrievalError","InternalServerError"],e9=e=>{let{onSend:t,onStop:s,retrySearch:n,isLoading:a=!1,placeholder:i,className:o="",error:l,hideBanners:m=!1}=e,p=(0,d.useRef)(null),{status:x}=(0,c.useSession)(),[h,b]=(0,d.useState)(""),[v,j]=(0,d.useState)(!1),[y,w]=(0,d.useState)(0),N=(0,ei.s)(),{isLimitReached:k,isSyncing:C,remainingQueries:_,limit:S}=f(),{isAuthenticated:R,status:E}=u(),{getSessionId:A}=(0,g.J)(),I=(0,g.J)(e=>e.getFeatureFlag("enableSpecialtyQualification")),L=(0,g.J)(e=>e.getFeatureFlag("enableScientificPublications")),D=em(e=>""!==e.specialty),T=em(e=>e.isDismissed),F=h.length>ee.MAX_CHARACTERS,q=k&&!C||F,{isMobileScreen:M,isMobileUserAgent:z}=ea(),O=z&&M,P=e=>{if(e.preventDefault(),!q){if(a)null==s||s();else if(h.trim().length>0){var r;O&&(null==(r=p.current)||r.blur()),t(h),b("")}}},H=()=>{let e=p.current;e&&j(e.scrollTop>1)},U=(null==l?void 0:l.type)&&!e8.includes(l.type),B=!m&&"loading"!==x&&k&&!C,V=!m&&I&&!R&&"loading"!==E&&!D&&!T;return(0,r.jsxs)("div",{"data-testid":"message-input-container",className:"w-full ".concat(o),children:[U&&(0,r.jsx)(eJ,{type:"error",errorType:null==l?void 0:l.type,onRetry:()=>{null==n||n()},onConnect:()=>{(0,c.signIn)("keycloak",void 0,{sessionId:A()})}}),(0,r.jsx)(eq,{}),B&&(0,r.jsx)(e3,{}),V&&(0,r.jsx)(e5,{}),(0,r.jsxs)("form",{"data-testid":"message-form",onSubmit:P,className:"flex flex-col gap-2 bg-white px-3 py-3 sm:px-4 roun
1ded-[12px] focus-within:shadow-[0_4px_12px_0_var(--brand-light-tertiary)] border border-grey-25 focus-within:border-brand-purple-light",children:[(0,r.jsxs)("div",{className:"message-input-textarea-container",children:[(0,r.jsx)("div",{className:(0,X.cn)("message-input-textarea-container-gradient transition-opacity duration-100 ease-in-out opacity-0",v&&"opacity-100"),style:{marginRight:"".concat(y,"px")}}),(0,r.jsx)(ez,{onScroll:H,"data-testid":"message-textarea",ref:p,style:{resize:"none"},disabled:k&&!C,value:h,onChange:e=>{b(e.target.value),H(),(()=>{var e;let t=document.createElement("div");t.style.visibility="hidden",t.style.overflow="scroll",t.style.width="100px",document.body.appendChild(t);let s=document.createElement("div");t.appendChild(s);let r=t.offsetWidth-s.offsetWidth;null==(e=t.parentNode)||e.removeChild(t),w(r)})()},onKeyDown:e=>{O||"Enter"!==e.key||e.shiftKey||(e.preventDefault(),P(e))},onPaste:e=>{e.preventDefault();let t=e.clipboardData.getData("text").replace(/\n{3,}/g,"\n\n").trim(),s=e.currentTarget,r=s.selectionStart,n=s.selectionEnd;b(h.slice(0,r)+t+h.slice(n)),setTimeout(()=>{s.selectionStart=s.selectionEnd=r+t.length},0)},placeholder:a?"":i||N("welcome.type-placeholder"),className:"p-0 border-none bg-transparent focus-visible:ring-0 focus-visible:ring-offset-0 resize-none placeholder-grey-50 text-grey-100 message-input-textarea",rows:2,autoFocus:!O})]}),(0,r.jsxs)("div",{className:"flex justify-between items-end",children:[(0,r.jsx)("div",{children:L&&(0,r.jsx)(e6,{})}),(0,r.jsxs)("div",{className:"flex items-end gap-2 sm:gap-3",children:[(null==h?void 0:h.length)>=ee.WARNING_THRESHOLD&&(0,r.jsx)(eX,{count:null==h?void 0:h.length,max:ee.MAX_CHARACTERS,isOverLimit:F}),(0,r.jsx)(eM.$,{"data-testid":"send-button",type:"submit",size:"sm",disabled:!a&&0===h.length||q,className:"message-input-send-button bg-brand-main-primary disabled:opacity-30 hover:cursor-pointer transition-none",variant:a?"secondary":"default",children:a?(0,r.jsx)(eO.A,{"data-testid":"stop-icon",size:20,color:"white"}):(0,r.jsx)(eg.A,{"data-testid":"send-icon",size:20,color:"white"})})]})]})]}),"loading"!==E&&(0,r.jsxs)("div",{"data-testid":"legal-notice",className:"mx-auto text-center text-xs text-grey-50 mt-3 px-2 sm:px-0 sm:w-[80%] w-[95%]",children:[N("common.personal-data-warning"),!R&&(0,r.jsxs)(r.Fragment,{children:[" | ".concat(N("common.personal-data-warning1")),(0,r.jsx)("a",{"data-testid":"usage-conditions-link",href:"/documents/cgu.pdf",target:"_blank",className:"underline cursor-pointer hover:text-grey-75 transition-colors",children:N("common.usage-conditions")}),N("common.personal-data-warning2"),(0,r.jsx)("a",{"data-testid":"privacy-policy-link",href:"/privacy",target:"_blank",className:"underline cursor-pointer hover:text-grey-75 transition-colors",children:N("common.privacy-policy")}),"."]})]})]})};function te(e){let{message:t,description:s,icon:n,action:a,size:i="medium",className:o}=e;return(0,r.jsxs)("div",{className:(0,X.cn)("text-center text-muted-foreground space-y-3",{small:"py-4 text-sm",medium:"py-8 text-base",large:"py-12 text-lg"}[i],o),children:[n&&(0,r.jsx)("div",{className:"flex justify-center",children:(0,r.jsx)(n,{className:(0,X.cn)("opacity-50",{small:"w-8 h-8",medium:"w-12 h-12",large:"w-16 h-16"}[i])})}),(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("p",{className:"font-medium",children:t}),s&&(0,r.jsx)("p",{className:"text-sm opacity-75",children:s})]}),a&&(0,r.jsx)("div",{className:"pt-2",children:(0,r.jsx)(eM.$,{variant:a.variant||"outline",size:"sm",onClick:a.onClick,children:a.label})})]})}function tt(e){let{label:t,isActive:s,onClick:n,badge:a,showIndicator:i=!0,fontWeight:o="medium",className:l}=e;return(0,r.jsxs)("button",{onClick:n,className:(0,X.cn)("select-none flex items-center gap-2 text-sm cursor-pointer px-2 py-1 rounded transition-colors relative","medium"===o?"font-medium":"font-normal",s?"text-foreground":"text-muted-foreground hover:text-foreground",l),children:[t,void 0!==a&&(0,r.jsx)("span",{className:"inline-flex items-center justify-center bg-muted text-foreground text-xs font-semibold rounded px-1.5 py-0.5 min-w-[16px] h-[24px]",children:a}),s&&i&&(0,r.jsx)("div",{className:"absolute -bottom-2 left-0 right-0 h-0.5 bg-brand-purple roun
1ded-full"})]})}var ts=s(5667);function tr(e){let{className:t,...s}=e;return(0,r.jsx)(ts.bL,{"data-slot":"tabs",className:(0,X.cn)("flex flex-col gap-2",t),...s})}function tn(e){let{className:t,...s}=e;return(0,r.jsx)(ts.UC,{"data-slot":"tabs-content",className:(0,X.cn)("flex-1 outline-none",t),...s})}let ta=e=>{try{return new URL(e.url).hostname.replace(/^www\./,"")}catch(t){return e.url}},ti=new Set,to=(e,t)=>{let s;if(!e)return!1;try{s=new URL(e,window.location.origin).href}catch(t){s=e}let r=!(e=>{try{let t=new URL(e);return"https:"===t.protocol||"http:"===t.protocol}catch(e){return!1}})(s);return r&&!ti.has(t)&&(ti.add(t),console.warn("[openExternalUrl] Rejected unsafe URL for source",t)),r},tl=(e,t,s)=>{if(!(!e||to(e,t))){if(void 0===s)return void window.open(e,"_blank");window.open(e,"_blank",s)}},tc=(e,t)=>{var s,r;return(null!=(r=null==(s=t[e.questionIndex])?void 0:s.options)?r:[]).filter(t=>{let{id:s}=t;return e.optionIds.includes(s)}).map(t=>t.free_text&&e.freeText?e.freeText:t.text).join(", ")},td=e=>{let{originalQuestion:t,questions:s,answers:r,skipped:n,t:a}=e,i=[],o=r.map(e=>({question:e.question,text:tc(e,s)})).filter(e=>{let{text:t}=e;return t.length>0}).map(e=>{let{question:t,text:s}=e;return"- ".concat(t," : ").concat(s)});return o.length>0&&i.push([a("chat.clarification.precisions-label"),...o].join("\n")),n&&i.push(a("chat.clarification.skip-instruction")),[t,...i].join("\n\n")};var tu=s(9715);let tm=e=>{let{size:t=30,color:s="#1f1f1f",className:n=""}=e;return(0,r.jsx)("div",{className:"bg-transparent rounded-lg ".concat(n),style:{width:t-8,height:t+8},children:(0,r.jsx)("svg",{width:t,height:t,viewBox:"0 0 10 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,r.jsxs)("g",{opacity:"0.9",children:[(0,r.jsx)("rect",{width:"1.23074",height:"1.23074",transform:"matrix(-1 0 0 1 5.61523 4.69238)",fill:s}),(0,r.jsx)("rect",{width:"1.23074",height:"1.23074",transform:"matrix(-1 0 0 1 5.61523 3.46167)",fill:s}),(0,r.jsx)("rect",{width:"1.23074",height:"1.23074",transform:"matrix(-1 0 0 1 5.61523 5.9231)",fill:s}),(0,r.jsx)("rect",{width:"1.23074",height:"1.23074",transform:"matrix(-1 0 0 1 5.61523 7.15381)",fill:s}),(0,r.jsx)("rect",{width:"1.23074",height:"1.23074",transform:"matrix(-1 0 0 1 5.61523 8.38452)",fill:s}),(0,r.jsx)("rect",{width:"1.23074",height:"1.23074",transform:"matrix(-1 0 0 1 6.8457 8.38452)",fill:s}),(0,r.jsx)("rect",{width:"1.23074",height:"1.23074",transform:"matrix(-1 0 0 1 4.38428 8.38452)",fill:s}),(0,r.jsx)("rect",{width:"1.23074",height:"1.23074",transform:"matrix(-1 0 0 1 5.61523 9.61523)",fill:s}),(0,r.jsx)("rect",{width:"1.23074",height:"1.23074",transform:"matrix(-1 0 0 1 5.61523 10.8459)",fill:s}),(0,r.jsx)("rect",{width:"1.23074",height:"1.23074",transform:"matrix(-1 0 0 1 5.61523 12.0767)",fill:s}),(0,r.jsx)("rect",{width:"1.23074",height:"1.23074",transform:"matrix(-1 0 0 1 5.61523 13.3074)",fill:s}),(0,r.jsx)("rect",{width:"1.23074",height:"1.23074",transform:"matrix(-1 0 0 1 4.38281 2.23071)",fill:s}),(0,r.jsx)("rect",{width:"1.23074",height:"1.23074",transform:"matrix(-1 0 0 1 3.15283 1)",fill:s}),(0,r.jsx)("rect",{width:"1.23074",height:"1.23074",transform:"matrix(-1 0 0 1 1.92285 1)",fill:s}),(0,r.jsx)("rect",{width:"1.23074",height:"1.23074",transform:"matrix(-1 0 0 1 6.84473 2.23071)",fill:s}),(0,r.jsx)("rect",{width:"1.23074",height:"1.23074",transform:"matrix(-1 0 0 1 8.0752 1)",fill:s}),(0,r.jsx)("rect",{width:"1.23074",height:"1.23074",transform:"matrix(-1 0 0 1 9.30713 1)",fill:s}),(0,r.jsx)("rect",{width:"1.23074",height:"1.23074",transform:"matrix(1 -8.74228e-08 -8.74228e-08 -1 5.6167 15.7693)",fill:s}),(0,r.jsx)("rect",{width:"1.23074",height:"1.23074",transform:"matrix(1 -8.74228e-08 -8.74228e-08 -1 6.84668 17)",fill:s}),(0,r.jsx)("rect",{width:"1.23074",height:"1.23074",transform:"matrix(1 -8.74228e-08 -8.74228e-08 -1 8.07666 17)",fill:s}),(0,r.jsx)("rect",{width:"1.23074",height:"1.23074",transform:"matrix(1 -8.74228e-08 -8.74228e-08 -1 3.15479 15.7693)",fill:s}),(0,r.jsx)("rect",{width:"1.23074",height:"1.23074",transform:"matrix(1 -8.74228e-08 -8.74228e-08 -1 1.92432 17)",fill:s}
1),(0,r.jsx)("rect",{width:"1.23074",height:"1.23074",transform:"matrix(1 -8.74228e-08 -8.74228e-08 -1 0.691895 17)",fill:s})]})})})};var tp=s(5805);let tx=new Set,th=new Map,tf=new Map,tg=(e,t)=>{let s=tf.get(e);if(s)return s;let r=Array.from({length:t},()=>(0,tp.Ak)());return tf.set(e,r),r},tb=e=>{let{questions:t,responseId:s,isRestored:n,onSelect:a}=e,i=(0,ei.s)(),{track:o}=ex(),l=(0,d.useMemo)(()=>t.map(e=>e.trim()).filter(Boolean).slice(0,3),[t]);return((0,d.useEffect)(()=>{if(!s||0===l.length||tx.has(s))return;let e=tg(s,l.length);tx.add(s),n||(th.set(s,Date.now()),o("trackOnCompanionFollowupQuestionsSuggested",{response_id:s,followup_questions:l.map((t,s)=>({followup_question_id:e[s],followup_question_text:t}))}))},[l,s,n,o]),0===l.length)?null:(0,r.jsxs)("div",{"data-testid":"follow-up-questions",className:"mt-6 flex flex-col gap-3",children:[(0,r.jsx)("p",{className:"text-grey-75 text-[10px] uppercase font-semibold tracking-wide",children:i("chat.follow-up-title")}),(0,r.jsx)("div",{className:"flex flex-wrap gap-3",children:l.map((e,t)=>(0,r.jsx)("button",{type:"button","data-testid":"follow-up-chip",onClick:()=>((e,t)=>{if(!s)return void a(e);let r=th.get(s),n=tg(s,l.length);o("trackOnCompanionFollowupQuestionsClicked",{response_id:s,followup_question_id:n[t],followup_question_text:e,time_to_submit_ms:void 0!==r?Date.now()-r:0}),a(e,n[t])})(e,t),className:"cursor-pointer rounded-[12px] border border-brand-light-tertiary bg-brand-additionnal-tertiary px-3 py-2 text-left text-sm leading-[1.35] text-brand-main-tertiary transition-colors [word-break:break-word] hover:bg-brand-light-tertiary",children:e},"".concat(t,"-").concat(e)))})]})},tv=/(\[\d+\])+/g,tj=/\[(\d+)\]/g;var ty=s(6504),tw=s(4514),tN=s(4604);function tk(e){let{...t}=e;return(0,r.jsx)(tN.bL,{"data-slot":"hover-card",...t})}function tC(e){let{...t}=e;return(0,r.jsx)(tN.l9,{"data-slot":"hover-card-trigger",...t})}function t_(e){let{className:t,align:s="center",sideOffset:n=4,...a}=e;return(0,r.jsx)(tN.ZL,{"data-slot":"hover-card-portal",children:(0,r.jsx)(tN.UC,{"data-slot":"hover-card-content",align:s,sideOffset:n,className:(0,X.cn)("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-64 origin-(--radix-hover-card-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",t),...a})})}let tS=[{domain:"aao.org",alias:"AAO"},{domain:"orthoguidelines.org",alias:"AAOS"},{domain:"aasm.org",alias:"AASM"},{domain:"agence-biomedecine.fr",alias:"ABM"},{domain:"academie-medecine.fr",alias:"Acad\xe9mie nationale de m\xe9decine"},{domain:"addictions-france.org",alias:"Addictions France"},{domain:"afero.fr",alias:"AFERO"},{domain:"afis.org",alias:"AFIS"},{domain:"afop.fr",alias:"AFOP"},{domain:"afpa.org",alias:"AFPA"},{domain:"urofrance.org",alias:"AFU"},{domain:"allergolyon.fr",alias:"AllergoLyon"},{domain:"anses.fr",alias:"ANSES"},{domain:"ansm.sante.fr",alias:"ANSM"},{domain:"ascopubs.org",alias:"ASCO"},{domain:"ameli.fr",alias:"Assurance Maladie"},{domain:"base-donnees-publique.medicaments.gouv.fr",alias:"BDPM"},{domain:"labovialle.com",alias:"Biologie Vialle"},{domain:"cambridge.org",alias:"BJPsych"},{domain:"bsped.org.uk",alias:"BSPED"},{domain:"cen-neurologie.fr",alias:"CEN"},{domain:"chronoreco.sfdermato.org",alias:"Chronoreco SFD"},{domain:"cismef.org",alias:"CISMEF"},{domain:"cmg.fr",alias:"CMG"},{domain:"infectiologie.com",alias:"CMIT / SPILF"},{domain:"cngof.fr",alias:"CNGOF"},{domain:"conseil-national.medecin.fr",alias:"CNOM"},{domain:"pharmacomedicale.org",alias:"CNPM"},{domain:"pedia-univ.fr",alias:"CNPU"},{domain:"lecofer.org",alias:"COFER"},{domain:"couf.fr",alias:"COUF"},{domain:"lecrat.fr",alias:"CRAT"},{domain:"cregg.org",alias:"CREGG"},{domain:"manuel4.cuen.fr",alias:"CUEN"},{domain:"dermatoclic.com",alias:"Dermatoclic"},{domain:"dermatologiepediatrique.wordpress.com",alias:"DermatoKid"},{domain:"sante.gouv.fr",alias:"DGS"},{domain:"drees.solidarites-sante.gouv.fr",alias:"Drees"},{domain:"e-cardiogram.com",alias:"e-cardiogram"},{domain:"e-pansement.fr",alias:"e-pansement"},{domain:"eacs.sanfordguide.com",alias:"EACS"},{domain:"easd.org",alias:"EASD"},{domain:"uroweb.org",alias:"EAU"},{domain:"europeanherniasociety.eu",alias:"EHS"},{domain:"ema.europa.eu",alias:"EMA"},{domain:"europsy.net",alias:"EPA"},{domain:"publications.ersnet.org",alias:"ERS"},{domain:"escardio.org",alias:"ESC"},{domain:"espen.org",alias:"ESPEN"},{domain:"espghan.org",alias:"ESPGHAN"},{domain:"eular.org",alias:"EULAR"},{domain:"eurocytology.eu",alias:"eurocytology"},{domain:"fai2r.org",alias:"Fai2r"},{domain:"portail-sla.fr",alias:"Filslan"},{domain:"fmcgastro.org",alias:"FMC-HGE"},{domain:"fnes.fr",alias:"FNES"},{domain:"vascularites.org",alias:"GFEV"},{domain:"gpip.fr",alias:"GPIP"},{domain:"has-sante.fr",alias:"HAS"},{domain:"hcsp.fr",alias:"HCSP"},{domain:"igas.gouv.fr",alias:"IGAS"},{domain:"cancer.fr",alias:"INCa"},{domain:"infovac.fr",alias:"Infovac"},{domain:"inserm.fr",alias:"Inserm"},{domain:"osteoporosis.foundation",alias:"IOF"},{domain:"kdigo.org",alias:"KDIGO"},{domain:"mpedia.fr",alias:"Mpedia"},{domain:"nice.org.uk",alias:"NICE"},{domain:"omniprat.org",alias:"OMNIPRAT"},{domain:"oncologik.fr",alias:"ONCOLOGIK"},{domain:"orpha.net",alias:"Orphanet"},{domain:"pap-pediatrie.fr",alias:"PAP P\xe9diatrie"},{domain:"pasteur.fr",alias:"Pasteur"},{domain:"pediadoc.fr",alias:"Pediadoc"},{domain:"pediadol.org",alias:"Pediadol"},{domain:"recomedicales.fr",alias:"RecoM\xe9dicales"},{domain:"redactionmedicale.fr",alias:"R\xe9daction M\xe9dicale et Scientifique"},{domain:"vasculaire.com",alias:"SCVE"},{domain:"sfa.lesallergies.fr",alias:"SFA"},{domain:"sfalcoologie.fr",alias:"SFA"},{domain:"sfap.org",alias:"SFAP"},{domain:"sfar.org",alias:"SFAR"},{domain:"sfcardio.fr",alias:"SFC"},{domain:"sfchirurgiedigestive.fr",alias:"SFCD"},{domain:"societechirorale.com",alias:"SFCO"},{domain:"sfdermato.org",alias:"SFD"},{domain:"reco.sfdermato.org",alias:"SFD Reco"},{domain:"sfendocrino.org",alias:"SFE"},{domain:"sfed.org",alias:"SFED"},{domain:"sfetd-douleur.org",alias:"SFETD"},{domain:"sfgg.org",alias:"SFGG"},{domain:"sfhta.eu",alias:"SFHTA"},{domain:"sfmg.fr",alias:"SFMG"},{domain:"cnp-mn.fr",alias:"SFMN"},{domain:"sfmu.org",alias:"SFMU"},{domain:"societe-francaise-neonatalogie.com",alias:"SFN"},{domain:"sfndt.org",alias:"SFNDT"},{domain:"societe-francaise-neurovasculaire.fr",alias:"SFNV"},{domain:"sfo-online.fr",alias:"SFO"},{domain:"sforl.org",alias:"SFORL"},{domain:"sf-phlebologie.org",alias:"SFP"},{domain:"pharmacologie.sfpeada.fr",alias:"SFPEADA PHARMACOLOGIE"},{domain:"sfpt-fr.org",alias:"SFPT"},{domain:"sfr.larhumatologie.fr",alias:"SFR"},{domain:"sfrms-sommeil.org",alias:"SFRMS"},{domain:"sfro.fr",alias:"SFRO"},{domain:"sft.meditup.fr",alias:"SFT"},{domain:"medecine-voyages.fr",alias:"SMV"},{domain:"snfge.org",alias:"SNFGE"},{domain:"snfmi.org",alias:"SNFMI"},{domain:"sofcot.fr",alias:"SOFCOT"},{domain:"santepubliquefrance.fr",alias:"SPF"},{domain:"splf.fr",alias:"SPLF"},{domain:"professionnels.vaccination-info-service.fr",alias:"Vaccination Info Service"}],tR=new Map(tS.map(e=>[e.domain,e.alias])),tE=new Map(tS.map(e=>[new RegExp("^([^.]+\\.)*".concat(e.domain.replace(/\./g,"\\."),"$")),e.domain])),tA=e=>{if(!e)return e;let t=(e=>{try{let t=e.replace(/^https?:\/\//,"").split("/")[0].split(":")[0];for(let[e,s]of tE)if(e.test(t))return s;return t}catch(t){return e}})(e);return tR.get(t)||t};
1var tI=s(5880);let tL=e=>{let{onClick:t,children:s,"data-testid":n,className:a,title:i=""}=e;return(0,r.jsx)("button",{className:(0,X.cn)("inline-block bg-grey-0 text-primary font-medium text-xs px-1 py-0.5 rounded transition-opacity duration-200 ease-in-out align-middle whitespace-nowrap no-underline border-none outline-none mx-px relative hover:bg-grey-25 focus:outline-2 focus:outline-primary focus:outline-offset-2",t&&"cursor-pointer",a),onClick:t,onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),t&&t({preventDefault:()=>{},stopPropagation:()=>{}}))},"data-testid":n,title:i,children:s})},tD=e=>{var t,s;let{citations:n,onClick:a}=e,i=(0,ei.s)();if(!n.length)return null;let o=tA((null==(t=n[0].sourceInfo)?void 0:t.url)||""),l=n.length-1,c=e=>{var t;return to(null==(t=e.sourceInfo)?void 0:t.url,e.sourceDocumentId)};return(0,r.jsxs)(tk,{openDelay:200,closeDelay:100,children:[(0,r.jsx)(tC,{asChild:!0,children:(0,r.jsx)("span",{className:"ms-1",children:(0,r.jsxs)(tL,{onClick:n.some(e=>!c(e))?e=>{e.preventDefault(),e.stopPropagation(),n.forEach(e=>{var t;
1tl(null==(t=e.sourceInfo)?void 0:t.url,e.sourceDocumentId,"noopener,noreferrer")}),a&&a(n)}:void 0,"data-testid":n.length>1?"citation-badge-group":"citation-badge",title:n.length>1?"".concat(n.length," citations: ").concat(n.map(e=>e.sourceTitle).join(", ")):n[0].sourceTitle||(null==(s=n[0].sourceInfo)?void 0:s.title)||n[0].domain||"Document",children:[(0,r.jsx)("span",{children:o}),l>0&&(0,r.jsxs)("span",{className:"text-xs font-semibold text-primary/80",children:["+",l]})]})})}),(0,r.jsx)(t_,{className:"w-80 p-0 bg-card/98 backdrop-blur-sm border border-border shadow-sm",side:"top",sideOffset:5,children:(0,r.jsxs)("div",{className:"px-2 py-3 space-y-2","data-testid":n.length>1?"citation-tooltip-group":"citation-tooltip-content",children:[n.length>1&&(0,r.jsx)("div",{className:"text-muted-foreground font-semibold uppercase tracking-wide text-xs px-2",children:i("citations.tooltips.sources",{count:n.length})}),(0,r.jsx)("div",{className:"space-y-2",children:n.map((e,t)=>{var s,i;let o=c(e);return(0,r.jsx)("button",{type:"button",onClick:o?void 0:t=>{t.preventDefault(),t.stopPropagation(),(e=>{var t;
1tl(null==(t=e.sourceInfo)?void 0:t.url,e.sourceDocumentId,"noopener,noreferrer"),a&&a(n)})(e)},"data-testid":"citation-tooltip-item-".concat(e.id,"-").concat(t),className:(0,X.cn)("relative w-full text-left hover:bg-grey-0 rounded-sm group-[citation-tooltip-group]:last:border-b-0 group",n.length>1?"py-2 px-4":"px-2 py-3",!o&&"hover:cursor-pointer"),children:(0,r.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,r.jsxs)("div",{className:"flex-1 mr-2",children:[(0,r.jsx)("div",{className:"flex items-start gap-2 ".concat(n.length>1?"mb-1":"mb-2"),children:(0,r.jsx)("h4",{className:"font-semibold text-sm text-foreground ".concat(1===n.length?"leading-[1.3]":"leading-tight"),children:e.sourceTitle||(null==(s=e.sourceInfo)?void 0:s.title)||e.domain||"Document"})}),e.sourceInfo&&(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,r.jsx)("span",{className:"font-medium text-foreground/80 inline-flex items-center bg-grey-0 px-1 py-0.5 rounded h-[18px] whitespace-nowrap",children:tA(e.sourceInfo.url||e.sourceInfo.source||"")}),e.sourceInfo.publicationDate&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"w-px h-2.5 bg-border","data-testid":"citation-year-separator"}),(0,r.jsx)("span",{"data-testid":"citation-year",children:(0,X.B)(e.sourceInfo.publicationDate)})]})]})]}),(null==(i=e.sourceInfo)?void 0:i.url)&&!o&&(0,r.jsx)("div",{className:"absolute right-2 top-2","data-testid":"citation-external-link-".concat(e.id,"-").concat(t),children:(0,r.jsx)(tI.A,{className:"w-3 h-3 text-foreground group-hover:block hidden"})})]})},"".concat(e.id,"-").concat(e.sourceDocumentId,"-").concat(t))})})]})})]})},tT=[{name:"Purple",background:"#D453FF",blur:"rgba(212, 83, 255, 0.3)",border:"rgba(212, 83, 255, 0.2)"},{name:"Turquoise",background:"#0DB1ED",blur:"rgba(13, 177, 237, 0.3)",border:"rgba(13, 177, 237, 0.2)"},{name:"Blue",background:"#2768FF",blur:"rgba(39, 104, 255, 0.3)",border:"rgba(39, 104, 255, 0.2)"},{name:"Green",background:"#00DE12",blur:"rgba(0, 222, 18, 0.3)",border:"rgba(0, 222, 18, 0.2)"}],tF=e=>{let{documentSources:t,onDocumentClick:s}=e;return t&&0!==t.length?(0,r.jsx)("div",{className:"w-full",children:(0,r.jsx)("div",{className:"flex gap-2 overflow-x-auto pb-2 scrollbar-none",children:t.map((e,t)=>{let n=tT[t%tT.length],a=to(e.url,e.id);return(0,r.jsxs)("div",{"data-testid":"document-card-".concat(e.id),className:(0,X.cn)("flex-shrink-0 w-56 rounded-lg p-3 relative overflow-hidden transition-all duration-300 ease-out animate-in fade-in-0 slide-in-from-right-4",!a&&"cursor-pointer hover:shadow-lg hover:scale-[1.02]"),onClick:a?void 0:()=>null==s?void 0:s(e),style:{backgroundColor:"#E1E1E1",minHeight:"200px",animationDelay:"".concat(150*t,"ms"),animationFillMode:"backwards"},children:[(0,r.jsxs)("div",{className:"absolute inset-0 pointer-events-none overflow-hidden rounded-lg",children:[(0,r.jsx)("div",{className:"absolute -top-20 -left-16 w-96 h-72 rounded-2xl transform rotate-12",style:{background:n.background,filter:"blur(40px)",opacity:.3}}),(0,r.jsx)("div",{className:"absolute -top-10 -left-8 w-80 h-56 rounded-xl transform -rotate-6",style:{background:n.background,opacity:.6}}),(0,r.jsx)("div",{className:"absolute inset-0",style:{background:"linear-gradient(135deg, ".concat(n.blur," 0%, transparent 50%, ").concat(n.background,"20 100%)")}})]}),(0,r.jsxs)("div",{className:"relative z-10 flex flex-col justify-between h-full min-h-[180px]",children:[(0,r.jsx)("div",{className:"flex justify-end mb-2",children:!a&&(0,r.jsx)(eM.$,{variant:"ghost",size:"sm","data-testid":"external-link-".concat(e.id),className:"p-1 h-auto hover:bg-black/10 transition-colors",onClick:t=>{t.stopPropagation(),tl(e.url,e.id)},children:(0,r.jsx)(tI.A,{className:"w-3 h-3 text-black"})})}),(0,r.jsxs)("div",{className:"bg-white/98 rounded-lg p-3 backdrop-blur-sm border border-white/20 shadow-sm",children:[(0,r.jsx)("div",{className:"mb-3",children:(0,r.jsxs)("span",{className:"inline-block bg-gray-100/80 text-gray-700 text-xs font-semibold px-2.5 py-1 rounded-full border border-gray-200/50",children:[Math.round(100*e.score),"% pertinent"]})}),(0,r.jsx)("h3",{className:"font-semibold text-sm text-gray-900 mb-3 line-clamp-2 leading-[1.3]",children:e.title}),(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-gray-500",children:[(0,r.jsx)("span",{className:"font-medium text-gray-700",children:tA((null==e?void 0:e.url)||"")}),e.published_date&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"w-px h-2.5 bg-gray-300"}),(0,r.jsx)("span",{children:e.published_date})]})]})]})]})]},e.id)})})}):null},tq=e=>{let{active:t=!1}=e;return t?(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[(0,r.jsx)("path",{opacity:"0.2",d:"M6 12H2V4H6V12Z",fill:"#9835E6"}),(0,r.jsx)("path",{d:"M6.25 3.75H2.5C2.33424 3.75 2.17527 3.81585 2.05806 3.93306C1.94085 4.05027 1.875 4.20924 1.875 4.375V11.25C1.875 11.4158 1.94085 11.5747 2.05806 11.6919C2.17527 11.8092 2.33424 11.875 2.5 11.875H6.25M6.25 3.75V11.875M6.25 3.75H15.9375C16.2419 3.75009 16.5358 3.86124 16.7641 4.06262C16.9923 4.26399 17.1393 4.54174 17.1773 4.84375L18.1148 12.3438C18.137 12.5197 18.1215 12.6983 18.0693 12.8678C18.0172 13.0372 17.9295 13.1937 17.8123 13.3267C17.695 13.4597 17.5508 13.5662 17.3892 13.6392C17.2276 13.7122 17.0523 13.75 16.875 13.75H11.875V15.625C11.875 16.288 11.6116 16.9239 11.1428 17.3928C10.6739 17.8616 10.038 18.125 9.375 18.125L6.25 11.875",stroke:"url
1(#paint0_linear_6891_197)",strokeWidth:"1.75",strokeLinejoin:"round"}),(0,r.jsx)("defs",{children:(0,r.jsxs)("linearGradient",{id:"paint0_linear_6891_197",x1:"5",y1:"15",x2:"17.1257",y2:"2.17349",gradientUnits:"userSpaceOnUse",children:[(0,r.jsx)("stop",{stopColor:"#FF0099"}),(0,r.jsx)("stop",{offset:"0.33",stopColor:"#AB55FF"}),(0,r.jsx)("stop",{offset:"0.66",stopColor:"#2A66FF"}),(0,r.jsx)("stop",{offset:"1",stopColor:"#03A1FF"})]})})]}):(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:(0,r.jsx)("path",{d:"M6.25 3.75H2.5C2.33424 3.75 2.17527 3.81585 2.05806 3.93306C1.94085 4.05027 1.875 4.20924 1.875 4.375V11.25C1.875 11.4158 1.94085 11.5747 2.05806 11.6919C2.17527 11.8092 2.33424 11.875 2.5 11.875H6.25M6.25 3.75V11.875M6.25 3.75H15.9375C16.2419 3.75009 16.5358 3.86124 16.7641 4.06262C16.9923 4.26399 17.1393 4.54174 17.1773 4.84375L18.1148 12.3438C18.137 12.5197 18.1215 12.6983 18.0693 12.8678C18.0172 13.0372 17.9295 13.1937 17.8123 13.3267C17.695 13.4597 17.5508 13.5662 17.3892 13.6392C17.2276 13.7122 17.0523 13.75 16.875 13.75H11.875V15.625C11.875 16.288 11.6116 16.9239 11.1428 17.3928C10.6739 17.8616 10.038 18.125 9.375 18.125L6.25 11.875",stroke:"#737373",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"})})},tM=e=>{let{active:t=!1}=e;return t?(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[(0,r.jsx)("path",{opacity:"0.2",d:"M6 16H2V8H6V16Z",fill:"#9835E6"}),(0,r.jsx)("path",{d:"M6.25 8.125H2.5C2.33424 8.125 2.17527 8.19085 2.05806 8.30806C1.94085 8.42527 1.875 8.58424 1.875 8.75V15.625C1.875 15.7908 1.94085 15.9497 2.05806 16.0669C2.17527 16.1842 2.33424 16.25 2.5 16.25H6.25M6.25 8.125V16.25M6.25 8.125L9.375 1.875C10.038 1.875 10.6739 2.13839 11.1428 2.60723C11.6116 3.07607 11.875 3.71196 11.875 4.375V6.25H16.875C17.0523 6.25005 17.2276 6.28782 17.3892 6.36081C17.5508 6.4338 17.695 6.54033 17.8123 6.67334C17.9295 6.80634 18.0172 6.96277 18.0693 7.13223C18.1215 7.3017 18.137 7.48033 18.1148 7.65625L17.1773 15.1562C17.1393 15.4583 16.9923 15.736 16.7641 15.9374C16.5358 16.1388 16.2419 16.2499 15.9375 16.25H6.25",stroke:"url(#paint0_linear_6891_1142)",strokeWidth:"1.75",strokeLinejoin:"round"}),(0,r.jsx)("defs",{children:(0,r.jsxs)("linearGradient",{id:"paint0_linear_6891_1142",x1:"2.47713",y1:"16.2499",x2:"16.9923",y2:"4.04798",gradientUnits:"userSpaceOnUse",children:[(0,r.jsx)("stop",{stopColor:"#FF0099"}),(0,r.jsx)("stop",{offset:"0.33",stopColor:"#AB55FF"}),(0,r.jsx)("stop",{offset:"0.66",stopColor:"#2A66FF"}),(0,r.jsx)("stop",{offset:"1",stopColor:"#03A1FF"})]})})]}):(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:(0,r.jsx)("path",{d:"M6.25 8.125H2.5C2.33424 8.125 2.17527 8.19085 2.05806 8.30806C1.94085 8.42527 1.875 8.58424 1.875 8.75V15.625C1.875 15.7908 1.94085 15.9497 2.05806 16.0669C2.17527 16.1842 2.33424 16.25 2.5 16.25H6.25M6.25 8.125V16.25M6.25 8.125L9.375 1.875C10.038 1.875 10.6739 2.13839 11.1428 2.60723C11.6116 3.07607 11.875 3.71196 11.875 4.375V6.25H16.875C17.0523 6.25005 17.2276 6.28782 17.3892 6.36081C17.5508 6.4338 17.695 6.54033 17.8123 6.67334C17.9295 6.80634 18.0172 6.96277 18.0693 7.13223C18.1215 7.3017 18.137 7.48033 18.1148 7.65625L17.1773 15.1562C17.1393 15.4583 16.9923 15.736 16.7641 15.9374C16.5358 16.1388 16.2419 16.2499 15.9375 16.25H6.25",stroke:"#737373",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"})})},tz=e=>{let{onFeedback:t,className:s="",disabled:n=!1}=e,a=(0,ei.s)(),[i,o]=(0,d.useState)(null),l=e=>{if(n||!e)return;let s=i===e?null:e;o(s),null==t||t(s)},c="flex items-center justify-center gap-2 px-3 py-1 bg-white border border-border rounded-lg text-sm font-semibold text-[#737373] transition-colors hover:bg-[#f2f2f2] ".concat(n?"cursor-not-allowed opacity-50":"cursor-pointer");return(0,r.jsxs)("div",{className:"flex flex-col gap-2 ".concat(s),children:[(0,r.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,r.jsx)("p",{className:"text-sm font-semibold",children:a("feedback.actions.question")}),(0,r.jsx)("p",{className:"text-sm text-grey-75",children:a("feedback.actions.help")})]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsxs)("button",{"data-testid":"feedback-positive-button",onClick:()=>l("positive"),disabled:n,className:c,"aria-label":String(a("feedback.actions.label-useful")),"aria-pressed":"positive"===i,children:[(0,r.jsx)("div",{className:"w-5 h-4 flex items-center justify-center",children:(0,r.jsx)(tM,{active:"positive"===i})}),a("feedback.actions.yes")]}),(0,r.jsxs)("button",{"data-testid":"feedback-negative-button",onClick:()=>l("negative"),disabled:n,className:c,"aria-label":String(a("feedback.actions.label-not-useful")),"aria-pressed":"negative"===i,children:[(0,r.jsx)("div",{className:"flex items-center justify-center h-4 w-5",children:(0,r.jsx)(tq,{active:"negative"===i})}),a("feedback.actions.no")]})]})]})},tO=e=>{let{children:t,isSelected:s,onClick:n}=e;return(0,r.jsxs)("button",{"data-testid":"tag",type:"button",className:(0,X.cn)("flex items-center gap-1 text-sm font-semibold cursor-pointer hover:bg-[#fafafa] border-[1.5px] border-grey-25 rounded-4xl px-4 py-1",s?"px-2 border-brand-purple-light shadow-[0_1px_2px_0_rgba(34,45,57,0.08)]":""),onClick:n,children:[s?(0,r.jsx)(ey.A,{className:"w-4 h-4 text-brand-main-tertiary",strokeWidth:2}):null,t]}
1)},tP={positive:{title:"feedback.form.positive.title",tags:["precise","up_to_date","adapted_format","fast","relevant_sources"]},negative:{title:"feedback.form.negative.title",tags:["incorrect","incomplete","slow","outdated","irrelevant_sources"]}},tH=e=>{let{feedbackType:t,isSubmitted:s,onFeedbackSubmit:n,onClose:a}=e,i=(0,ei.s)(),[o,l]=(0,d.useState)([]),[c,u]=(0,d.useState)(""),[m,p]=(0,d.useState)(1),[x,h]=(0,d.useState)(s),f=(0,d.useRef)(null);if((0,d.useEffect)(()=>{h(s)},[s]),(0,d.useEffect)(()=>{h(!1),l([]),u(""),p(1)},[t]),(0,d.useEffect)(()=>{if(f.current){f.current.style.height="auto",f.current.rows=1;let e=f.current.scrollHeight,t=parseFloat(getComputedStyle(f.current).lineHeight)||20,s=Math.min(Math.max(Math.ceil((e-(parseFloat(getComputedStyle(f.current).paddingTop)+parseFloat(getComputedStyle(f.current).paddingBottom)))/t),1),5);p(s),f.current.rows=s}},[c]),!t)return null;let g=s||x;return(0,r.jsxs)("form",{"data-testid":"feedback-form",onSubmit:e=>{e.preventDefault(),n({type:t,comment:c,tags:o})},className:"bg-card border border-border rounded-lg shadow-sm relative",children:[(0,r.jsx)("div",{className:"absolute z-[1] top-0 ".concat("positive"===t?"left-4":"left-25"," rounded-[2px] w-3 h-3 transform rotate-45 translate-y-[-50%] border-t border-l bg-white")}),(0,r.jsxs)("div",{className:"p-3",children:[(0,r.jsxs)("header",{"data-testid":"feedback-form-header",className:"flex items-start justify-between gap-2",children:[g?(0,r.jsxs)("div",{"data-testid":"feedback-form-submitted",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(ey.A,{className:"w-4 h-4 text-success",strokeWidth:2}),(0,r.jsx)("span",{"data-testid":"feedback-form-thank-you",className:"text-sm font-semibold",children:i("feedback.form.thank-you")})]}),"negative"===t&&(0,r.jsx)("div",{"data-testid":"feedback-form-help-us-improve",className:"text-sm font-normal",children:i("feedback.form.help-us-improve")})]}):(0,r.jsxs)("div",{children:[(0,r.jsxs)("span",{"data-testid":"feedback-form-title",className:"text-base font-semibold",children:[i(tP[t].title),"\xa0"]}),(0,r.jsx)("span",{"data-testid":"feedback-form-optional",className:"text-sm font-normal",children:i("common.optional")})]}),(0,r.jsx)("button",{"data-testid":"feedback-form-close-button",type:"button",className:"hover:cursor-pointer flex items-center justify-center mt-1",onClick:()=>{if(s){l([]),u(""),p(1),h(!1),a();return}if(!x)return void h(!0);l([]),u(""),p(1),h(!1),a()},children:(0,r.jsx)(eh.A,{className:"w-4 h-4 text-grey-75 hover:cursor-pointer"})})]}),!g&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("main",{"data-testid":"feedback-form-main",className:"my-4 flex flex-col gap-6",children:[(0,r.jsx)("div",{"data-testid":"feedback-form-tags",className:"flex flex-wrap gap-3",children:tP[t].tags.map(e=>(0,r.jsx)("div",{children:(0,r.jsx)(tO,{isSelected:o.includes(e),onClick:()=>(e=>{o.includes(e)?l(t=>t.filter(t=>t!==e)):l(t=>[...t,e])})(e),children:i("feedback.tags.".concat(e))})},e))}),(0,r.jsx)("textarea",{ref:f,"data-testid":"feedback-form-comment",value:c,onChange:e=>u(e.target.value),placeholder:i("feedback.form.placeholder"),className:"w-full p-2 border-[1.5px] border-border rounded-md active:outline-none focus:outline-none active:border-brand-purple-light focus:border-brand-purple-light resize-none overflow-y-auto",name:"comment",maxLength:2e3,rows:m})]}),(0,r.jsx)("footer",{"data-testid":"feedback-form-footer",className:"flex justify-end",children:(0,r.jsxs)("button",{"data-testid":"feedback-form-submit",type:"submit",className:"flex items-center gap-2 bg-brand-main-primary text-white px-3 py-1 rounded-md font-semibold hover:cursor-pointer disabled:opacity-30 disabled:cursor-default",disabled:0===c.length&&0===o.length,children:[i("common.send"),(0,r.jsx)(ej.A,{className:"w-4 h-4"})]})})]})]})]})},tU=e=>{let{status:t,sourceCount:s=0,className:n="","data-testid":a}=e,i=((e,t)=>{switch(e){case"thinking":return{text:"Analyse de la question...",icon:null,showCard:!1,cardClass:"",textClass:"text-muted-foreground font-semibold uppercase tracking-wide"};case"searching":return{text:"Recherche m\xe9dicale...",icon:null,showCard:!1,cardClass:"",textClass:"text-muted-foreground font-semibold uppercase tracking-wide"};case"sources_found":return{text:"Sources trouv\xe9es (".concat(t,")"),icon:null,showCard:!1,cardClass:"",textClass:"text-muted-foreground font-semibold uppercase tracking-wide"};case"generating":return{text:"G\xe9n\xe9ration de la r\xe9ponse...",icon:null,showCard:!1,cardClass:"",textClass:"text-muted-foreground font-semibold uppercase tracking-wide"};case"complete":return{text:"R\xe9ponse m\xe9dicale",icon:null,showCard:!1,cardClass:"",textClass:"text-muted-foreground font-semibold uppercase tracking-wide"};default:return{text:"",icon:null,showCard:!1,cardClass:"",textClass:""}}})(t,s);return i.text?i.showCard?(0,r.jsx)("div",{"data-testid":a,className:"transition-all duration-300 ease-in-out p-4 animate-in fade-in-0 slide-in-from-left-2 ".concat(i.cardClass," ").concat(n),children:(0,r.jsxs)("div",{"data-testid":"status-card-content",className:"flex items-center gap-3",children:[i.icon&&(0,r.jsx)("div",{"data-testid":"status-icon",children:i.icon}),(0,r.jsx)("span",{"data-testid":"status-text",className:"text-sm ".concat(i.textClass),children:i.text})]})}):(0,r.jsx)("div",{"data-testid":a,className:"flex items-center mb-3 animate-in fade-in-0 slide-in-from-left-2 duration-300 ".concat(n),children:(0,r.jsx)("h3",{"data-testid":"status-text",className:"text-xs ".concat(i.textClass),children:i.text})}):null}
1,tB=e=>{if(e)try{return new URL(e).hostname.replace(/^www\./,"")}catch(e){return}},tV=(e,t,s)=>{let n;if(Array.isArray(e))return e.map((e,n)=>(0,r.jsx)(d.Fragment,{children:tV(e,t,s)},n));if("string"!=typeof e)return e;let a=/(\[(\d+)\](\[(\d+)\])*)/g,i=[],o=0;for(;null!==(n=a.exec(e));){let[a]=n,l=e.slice(o,n.index);l&&i.push(l);let c=a.match(/\[(\d+)\]/g);if(c){let e=c.map(e=>parseInt(e.match(/\d+/)[0])).map(e=>t.find(t=>t.citationNumber===e)).filter(e=>void 0!==e);e.length>0&&i.push((0,r.jsx)(tD,{citations:e,onClick:e=>{e.forEach(e=>null==s?void 0:s(e))}},"citations-".concat(n.index)))}o=n.index+a.length}return o<e.length&&i.push(e.slice(o)),i.length>1?i:e},tG=e=>{var t;let{message:s,citations:n=[],documentSources:a=[],error:i}=e,{track:o}=ex(),l=(0,ei.s)(),c=(0,g.J)(e=>e.isFeedbackActionsEnabled()),[u,m]=(0,d.useState)(null),[p,x]=(0,d.useState)(!1),[h,f]=(0,d.useState)(!1),[b,v]=(0,d.useState)(null);(0,d.useEffect)(()=>{b&&s.responseId&&o("trackOnCompanionFeedbackSubmitted",{response_id:s.responseId,feedback_type:b.type,feedback_text:b.comment,feedback_tags:b.tags})},[b,s.responseId,o]),(0,d.useEffect)(()=>{p&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{let e=document.getElementById("feedback-form-".concat(s.responseId));e&&e.scrollIntoView({behavior:"smooth"})})})},[p,s.responseId]);let j=e=>{if(!s.responseId)return;let t=null==a?void 0:a.find(t=>t.id===e.sourceDocumentId);if(t){var r;o("trackOnCompanionDocumentClicked",{response_id:s.responseId,document_id:t.id,document_url:null!=(r=t.url)?r:null,element:"response"})}},{processedContent:y,detectedCitations:w}=(0,d.useMemo)(()=>{var e;if(!s.content)return{processedContent:"",detectedCitations:[]};let t=s.content.replace("â",""),r=((e,t)=>{if(!e||0===t.length)return[];let s=((e,t)=>{if(!e)return[];let s=[],r=0;for(let n of e.matchAll(tv)){let a=n.index;a>r&&s.push({type:"text",content:e.slice(r,a)});let i=[],o=[];for(let e of n[0].matchAll(tj)){let s=parseInt(e[1],10);i.push(s),o.push(t[s-1])}s.push({type:"citation-group",indices:i,sources:o}),r=a+n[0].length}return r<e.length&&s.push({type:"text",content:e.slice(r)}),s})(e,t),r=[],n=new Set;for(let e of s)if("citation-group"===e.type)for(let s of e.indices){var a,i;if(n.has(s))continue;let e=t[s-1];e&&(n.add(s),r.push({id:s,sourceDocumentId:e.id,sourceTitle:e.title,relevanceScore:e.score,textSpan:[0,0],citationNumber:s,domain:null!=(a=tB(e.url))?a:ta(e),sourceInfo:{title:e.title,section:"",source:ta(e),relevance:e.score,publicationDate:null!=(i=e.published_date)?i:"",url:e.url}}))}return r.sort((e,t)=>{var s,r;return(null!=(s=e.citationNumber)?s:0)-(null!=(r=t.citationNumber)?r:0)}),r})(t,a.length>0?a:null!=(e=s.documentSources)?e:[]);if(n.length>0)for(let e of[...n].sort((e,t)=>t.textSpan[0]-e.textSpan[0])){let[s,r]=e.textSpan;if(s>=0&&r>s&&r<=t.length){let n=t.slice(0,s),a=t.slice(s,r),i=t.slice(r),o=e.highlightClass||"medical-citation citation-high-relevance";t="".concat(n,'<span class="').concat(o,'" data-citation-id="').concat(e.id,'" style="background-color: hsl(var(--primary) / 0.15); border-bottom: 2px solid hsl(var(--primary)); cursor: pointer; padding: 2px 0;">').concat(a,"</span>").concat(i)}}return{processedContent:t,detectedCitations:r}},[s.content,n,a,s.documentSources]);if("user"===s.role)return(0,r.jsxs)("div",{"data-testid":"user-message",className:"mb-4 flex flex-col items-center gap-3 w-full",children:[(0,r.jsx)("div",{className:"w-full text-left",children:(0,r.jsx)("div",{"data-testid":"user-message-content",className:"font-medium text-xl leading-[1.35] text-[#222D39] whitespace-pre-wrap",children:s.content})}),(0,r.jsx)("div",{className:"w-full h-px bg-border"})]});let N=(()=>{var e,t,r,n;if("search-status"===s.messageType){if(null==(e=s.content)?void 0:e.includes("Recherche"))return"searching";if(null==(t=s.content)?void 0:t.includes("Sources trouv\xe9es"))return"sources_found"}if("response-status"===s.messageType){if(null==(r=s.content)?void 0:r.includes("G\xe9n\xe9ration"))return"generating";if(null==(n=s.content)?void 0:n.includes("R\xe9ponse m\xe9dicale"))return"complete"}return"response-content"===s.messageType?"complete":null})(),k=(null==(t=s.documentSources)?void 0:t.length)||0,C=c&&"med"===s.context&&!i,_="complete"===s.status;return"search-status"===s.messageType?(0,r.jsxs)("div",{"data-testid":"search-status-message",className:"space-y-3",children:[N&&(0,r.jsx)(tU,{status:N,sourceCount:k}),s.documentSources&&s.documentSources.length>0&&(0,r.jsx)("div",{className:"animate-in fade-in-0 slide-in-from-bottom-2 duration-300",children:(0,r.jsx)(tF,{documentSources:s.documentSources,onDocumentClick:e=>{if(s.responseId){var t;o("trackOnCompanionDocumentClicked",{response_id:s.responseId,document_id:e.id,document_url:null!=(t=e.url)?t:null,element:"response"})}tl(e.url,e.id)}})})]}):"response-status"===s.messageType?(0,r.jsx)("div",{"data-testid":"response-status-message",className:"space-y-3",children:N&&(0,r.jsx)(tU,{status:N,sourceCount:k})}):"response-content"===s.messageType?(0,r.jsx)("div",{"data-testid":"response-content-message",className:"space-y-3",children:(0,r.jsxs)(eU,{className:"transition-all duration-200 ease-in-out border-none shadow-none py-1 bg-transparent",children:[(0,r.jsx)("div",{className:"min-h-[2rem]",children:(0,r.jsxs)("div",{className:"leading-relaxed relative",children:[(0,r.jsx)(ty.oz,{remarkPlugins:[tw.A],components:{p:e=>{let{children:t}=e;return(0,r.jsx)("p",{className:"mb-2.5 last:mb-0 text-base leading-[1.35] text-foreground font-normal",children:tV(t,[...n,...w],j)})},ul:e=>{let{children:t}=e;return(0,r.jsx)("ul",{className:"mb-2.5 list-disc space-y-1 pl-4",children:t})},li:e=>{let{children:t}=e;return(0,r.jsx)("li",{className:"text-base leading-[1.35] text-foreground",children:tV(t,[...n,...w],j)})},ol:e=>{let{children:t}=e;return(0,r.jsx)("ol",{className:"mb-2.5 list-decimal space-y-1 pl-5",children:t})},strong:e=>{let{children:t}=e;return(0,r.jsx)("strong",{className:"font-semibold",children:t})},em:e=>{let{children:t}=e;return(0,r.jsx)("em",{className:"italic",children:t})},h1:e=>{let{children:t}=e;return(0,r.jsx)("h1",{className:"text-xl font-bold mb-3 mt-4 first:mt-0 text-foreground",children:t})},h2:e=>{let{children:t}=e;return(0,r.jsx)("h2",{className:"text-lg font-semibold mb-2.5 mt-4 first:mt-0 text-foreground",children:t})},h3:e=>{let{children:t}=e;return(0,r.jsx)("h3",{className:"text-base font-semibold mb-2 mt-3 first:mt-0 text-foreground",children:t})},h4:e=>{let{children:t}=e;return(0,r.jsx)("h4",{className:"text-base font-semibold mb-2 mt-3 first:mt-0 text-foreground",children:t})},h5:e=>{let{children:t}=e;return(0,r.jsx)("h5",{className:"text-sm font-semibold mb-1.5 mt-2 first:mt-0 text-foreground",children:t})},h6:e=>{let{children:t}=e;return(0,r.jsx)("h6",{className:"text-sm font-semibold mb-1.5 mt-2 first:mt-0 text-foreground",children:t})},blockquote:e=>{let{children:t}=e;return(0,r.jsx)("blockquote",{className:"border-l-4 border-border pl-4 italic text-muted-foreground my-3",children:t})},hr:()=>(0,r.jsx)("hr",{className:"my-4 border-border"}),pre:e=>{let{children:t}=e;return(0,r.jsx)("pre",{className:"bg-muted rounded-md p-3 my-3 overflow-x-auto text-sm",children:t})},code:e=>{let{children:t}=e;return(0,r.jsx)("code",{className:"bg-muted px-1 py-0.5 rounded text-xs",children:t})},table:e=>{let{children:t}=e;return(0,r.jsx)("div",{className:"my-4 overflow-x-auto",children:(0,r.jsx)("table",{className:"min-w-full border border-border rounded-lg bg-card",children:t})})},thead:e=>{let{children:t}=e;return(0,r.jsx)("thead",{className:"bg-muted/50",children:t})},tbody:e=>{let{children:t}=e;return(0,r.jsx)("tbody",{className:"divide-y divide-border",children:t})},tr:e=>{let{children:t}=e;return(0,r.jsx)("tr",{className:"hover:bg-muted/30 transition-colors",children:t})},th:e=>{let{children:t}=e;return(0,r.jsx)("th",{className:"px-3 py-2 text-left text-xs font-medium text-muted-foreground uppercase tracking-wide border-r border-border last:border-r-0",children:tV(t,[...n,...w],j)})},td:e=>{let{children:t}=e;return(0,r.jsx)("td",{className:"px-3 py-2 text-sm text-foreground border-r border-border last:border-r-0",children:tV(t,[...n,...w],j)})},a:e=>{let{href:t,children:s}=e,a=String(s);if(a.match(/^(\[(\d+)\](\[(\d+)\])*)+$/)){let e=a.match(/\[(\d+)\]/g);if(e){let t=e.map(e=>parseInt(e.match(/\d+/)[0])),s=[...n,...w],a=t.map(e=>s.find(t=>t.citationNumber===e)).filter(e=>void 0!==e);if(a.length>0)return(0,r.jsx)(tD,{citations:a,onClick:e=>
1{e.forEach(e=>j(e))}})}}let i=a.match(/^\[(\d+)\]$/);if(i){let e=parseInt(i[1]),t=[...n,...w].find(t=>t.citationNumber===e);if(t)return(0,r.jsx)(tD,{citations:[t],onClick:()=>j(t)})}return(0,r.jsx)("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:text-primary/80 underline underline-offset-2",children:s})},span:e=>{let{className:t,children:s,...n}=e,a=n["data-citation-id"];return a&&(null==t?void 0:t.includes("medical-citation"))?(0,r.jsx)("span",{className:t,onMouseEnter:()=>m(parseInt(a)),onMouseLeave:()=>m(null),onClick:()=>{},...n,children:s}):(0,r.jsx)("span",{className:t,...n,children:s})}},children:y}),s.content&&s.content.endsWith("â")&&(0,r.jsx)("span",{"data-testid":"typing-indicator",className:"animate-pulse ml-1 inline-block w-2 h-5 bg-foreground/60 align-baseline"}),u&&(0,r.jsx)("div",{"data-testid":"citation-tooltip",className:"absolute z-10 p-2 bg-popover border rounded-md shadow-md text-xs max-w-xs",children:(()=>{let e=[...n,...w].find(e=>e.id===u);return e?(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"font-medium",children:e.sourceTitle}),e.sourceInfo&&(0,r.jsxs)("div",{className:"text-muted-foreground mt-1",children:[e.sourceInfo.source," ⢠",(0,X.B)(e.sourceInfo.publicationDate)]}),(0,r.jsxs)("div",{className:"text-xs mt-1",children:["Pertinence: ",(100*e.relevanceScore).toFixed(0),"%"]})]}):null})()})]})}),_&&(0,r.jsxs)("div",{className:"flex flex-col gap-3 px-1 py-2",children:[(0,r.jsx)("div",{className:"w-full mt-8 mb-3 h-px bg-border"}),(0,r.jsxs)("div",{className:"flex items-start gap-3 animate-in fade-in-0 slide-in-from-bottom-2 duration-300 ".concat(C?"justify-between":"justify-end"),children:[C&&(0,r.jsx)(tz,{onFeedback:e=>{if(f(!1),!e){x(!1),v(null);return}v({type:e,comment:"",tags:[]}),x(!0)}}),(0,r.jsx)("p",{"data-testid":"mistake-warning",className:"mt-[3px] text-grey-75 text-xs text-right",children:l("chat.tabs.mistake-warning")})]}),C&&p&&!!(null==b?void 0:b.type)&&(0,r.jsx)("div",{id:"feedback-form-".concat(s.responseId),children:(0,r.jsx)(tH,{feedbackType:b.type,isSubmitted:h,onFeedbackSubmit:e=>{v(e),f(!0)},onClose:()=>x(!1)})})]})]})}):(0,r.jsxs)("div",{"data-testid":"default-message",className:"mb-4 flex flex-col items-center gap-3 w-full",children:[(0,r.jsx)("div",{className:"w-full text-left",children:(0,r.jsx)("div",{"data-testid":"default-message-content",className:"font-normal text-[28px] leading-[1.35] text-[#222D39] whitespace-pre-wrap",children:s.content})}),(0,r.jsx)("div",{className:"w-full h-px bg-border"})]})},tW=()=>(0,r.jsx)("div",{className:"border-r border-gray-200 h-4"}),tQ="flex flex-1 items-center gap-2",tJ=e=>{let{documents:t,onDocumentClick:s,onTabChange:n,"data-testid":a}=e,i=(0,ei.s)(),o=(0,d.useMemo)(()=>{let e={},s={},r={};return t.forEach(t=>{let n=tA(ta(t));e[n]=(e[n]||0)+1,s[n]||(s[n]=[]),s[n].push(t),"academic"===t.source_category&&(r[n]=!0)}),Object.keys(s).map(e=>s[e].reduce((e,t)=>ta(t).length<ta(e).length?t:e)).sort((t,s)=>{let n=tA(ta(t)),a=tA(ta(s)),i=Number(!!r[a])-Number(!!r[n]);return 0!==i?i:e[a]-e[n]})},[t]),{containerRef:l,visibleTags:c,hiddenTags:u}=((e,t)=>{let s=(0,d.useRef)(null),[r,n]=(0,d.useState)(()=>e),[a,i]=(0,d.useState)([]),o=(0,d.useRef)(JSON.stringify(e)),l=(0,d.useCallback)(()=>{if(!s.current)return;let r=s.current.offsetWidth,a=document.createElement("div");a.style.visibility="hidden",a.style.position="absolute",a.className=(null==t?void 0:t.containerClassName)||"",document.body.appendChild(a);let o=0,l=[],c=[];e.forEach((s,n)=>{let i=document.createElement("div");i.className=(null==t?void 0:t.tagClassName)||"",i.textContent=String(s),a.appendChild(i);let d=i.offsetWidth;o+d+50*(n<e.length-1)<=r?(o+=d,l.push(s)):c.push(s),a.removeChild(i)}),document.body.removeChild(a),n(l),i(c)},[e,null==t?void 0:t.containerClassName,null==t?void 0:t.tagClassName]),c=(0,d.useRef)(void 0);return c.current||(c.current=eu()(l,200)),(0,d.useEffect)(()=>{var e;null==(e=c.current)||e.cancel(),c.current=eu()(l,200)},[l]),(0,d.useEffect)(()=>{let t=JSON.stringify(e);o.current!==t&&(o.current=t,n(e),i([]),setTimeout(()=>{var e;null==(e=c.current)||e.call(c)},0))},[e]),(0,d.useEffect)(()=>
1{let e=c.current;if(!e)return;let t=new ResizeObserver(()=>{e()});return s.current&&t.observe(s.current),()=>{t.disconnect(),e.cancel()}},[]),{containerRef:s,visibleTags:r,hiddenTags:a}})(o,{containerClassName:tQ});return(0,r.jsx)("div",{"data-testid":a||"source-tags-container",className:"mt-6 mb-8",children:(0,r.jsxs)("div",{className:"flex items-center gap-2 mb-4 text-gray-500 text-xs font-bold",children:[(0,r.jsx)("div",{className:"whitespace-nowrap",children:i("sources.sources-asked",{count:o.length})}),(0,r.jsx)("div",{className:"flex flex-1 items-center gap-2 overflow-hidden",children:(0,r.jsxs)("div",{ref:l,className:tQ,children:[c.map((e,t)=>{let n=tA(ta(e)),a=to(e.url,e.id);return(0,r.jsxs)(d.Fragment,{children:[(0,r.jsx)(tL,{"data-testId":"source-badge",onClick:a?void 0:()=>(e=>{let t=new URL(e.url||"").origin;s({...e,url:t})})(e),children:n},n),t<c.length-1&&(0,r.jsx)(tW,{})]},n)}),u.length>0&&(0,r.jsxs)(r.Fragment,{children:[c.length>0&&(0,r.jsx)(tW,{}),(0,r.jsxs)(tL,{"data-testId":"overflow-badge",onClick:()=>n("sources"),children:["+",u.length]})]})]})})]})})},tZ=e=>{let t=new Map;for(let s of e){let e=s.query||"";t.has(e)||t.set(e,[]),t.get(e).push(s)}return Array.from(t.entries()).map(e=>{let[t,s]=e;return{query:t,sources:s}})};function tK(e){let{source:t,date:s,url:n,showDividers:a=!0,urlMaxWidth:i="max-w-full",size:o="xs",className:l}=e,c=()=>a?(0,r.jsx)("div",{className:"w-px h-3 bg-[#E1E1E1] flex-shrink-0"}):null,d=(0,X.B)(s);return(0,r.jsxs)("div",{className:(0,X.cn)("flex items-center gap-2",{xs:"text-xs",sm:"text-sm",base:"text-base"}[o],l),children:[(0,r.jsx)("div",{className:"inline-flex items-center bg-[#F5F5F5] px-1 py-0.5 rounded h-[18px] whitespace-nowrap",children:(0,r.jsx)("span",{className:"font-semibold text-xs text-[#222D39] leading-none",children:t})}),s&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(c,{}),(0,r.jsx)("span",{className:"font-normal text-xs text-[#6E7881]",children:d})]}),n&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(c,{}),(0,r.jsx)("span",{className:(0,X.cn)("font-normal text-xs text-[#6E7881] truncate",i),children:n})]})]})}var t$=s(2118);let tX=e=>{let{document:t,onDocumentClick:s,"data-testid":n}=e,{isMobileScreen:a}=ea(),i=to(t.url,t.id),o=e=>{e.preventDefault(),e.stopPropagation(),s(t)},l=(0,d.useMemo)(()=>{let e=ta(t);return tA(e)||e},[t]);return(0,r.jsx)("div",{"data-testid":n,onClick:i?void 0:o,className:(0,X.cn)("w-full px-1 py-2 group rounded transition-colors",!i&&"cursor-pointer"),children:(0,r.jsxs)("div",{className:"flex items-start gap-2",children:[(0,r.jsxs)("div",{"data-testid":"document-card-content",className:"flex flex-col gap-1 px-0 min-w-0 flex-1",children:[(0,r.jsx)("h3",{"data-testid":"document-title",className:"font-semibold text-sm text-brand-dark-text leading-[1.35] line-clamp-2 group-hover:text-brand-purple-dark",children:t.title}),(0,r.jsx)(tK,{"data-testid":"document-metadata",source:l,date:t.published_date||"2025",url:t.url,size:"xs"})]}),a&&!i&&(0,r.jsx)("button",{"data-testid":"document-card-open-icon",className:"py-2 h-auto shrink-0 hover:bg-black/10 transition-colors",onClick:o,children:(0,r.jsx)(t$.A,{size:16})})]})})},tY=e=>{let{queryGroups:t,responseId:s}=e,{track:n}=ex(),{isMobileScreen:a}=ea(),i=(0,ei.s)();if(!t||0===t.length)return(0,r.jsx)(te,{"data-testid":"empty-sources-state",message:"Aucune source trouv\xe9e pour cette conversation",description:"Les sources appara\xeetront ici lors des recherches m\xe9dicales",icon:tu.A,size:"medium"});let o=e=>{if(s){var t;n("trackOnCompanionDocumentClicked",{response_id:s,document_id:e.id,document_url:null!=(t=e.url)?t:null,element:"document_list"})}tl(e.url,e.id)};return(0,r.jsx)("div",{"data-testid":"sources-tab-container",className:"space-y-8",children:t.map((e,t)=>{let s=[...e.sources].sort((e,t)=>Number("academic"===t.source_category)-Number("academic"===e.source_category));return(0,r.jsxs)("div",{"data-testid":"query-group-".concat(t),className:"space-y-2 rounded-sm border border-grey-25 p-3",children:[(0,r.jsxs)("div",{"data-testid":"query-group-header-".concat(t),className:"flex items-center justify-between gap-2",children:[(0,r.jsxs)("h3",{"data-testid":"query-title-".concat(t),className:"italic bg-brand-additionnal-tertiary p-2 pr-3 rounded-md text-sm tracking-tight font-normal text-brand-purple-dark flex items-center gap-2",children:[(0,r.jsx)(tm,{"data-testid":"copilot-icon-".concat(t),size:16,className:"mr-2 py-1",color:"var(--brand-purple-dark)"}),e.query]}),!a&&(0,r.jsxs)("span",{"data-testid":"source-count-".concat(t),className:"text-sm text-grey-80 font-normal",children:["(",e.sources.length," ",i("common.document",{count:e.sources.length}),")"]})]}),(0,r.jsx)("div",{"data-testid":"sources-list-".concat(t),className:"flex flex-col",children:s.map((e,t)=>(0,r.jsxs)(d.Fragment,{children:[(0,r.jsx)(tX,{"data-testid":"document-card-".concat(e.id),document:e,onDocumentClick:o}),t<s.length-1&&(0,r.jsx)("div",{"data-testid":"divider-".concat(e.id),className:"h-px bg-muted-foreground
1/10 mx-0 my-1"})]},e.id))})]},"".concat(e.query,"-").concat(t))})})};s(7906);let t0=()=>(0,r.jsxs)("div",{className:"medgpt-content-skeleton","data-testid":"medgpt-content-skeleton","aria-hidden":"true",children:[(0,r.jsx)("div",{className:"medgpt-content-skeleton__line"}),(0,r.jsx)("div",{className:"medgpt-content-skeleton__line"}),(0,r.jsx)("div",{className:"medgpt-content-skeleton__line"})]});s(3122);let t1=()=>(0,r.jsxs)("div",{className:"medgpt-status-loader","data-testid":"medgpt-status-loader","aria-hidden":"true",children:[(0,r.jsx)("div",{className:"medgpt-status-loader__dot medgpt-status-loader__dot--top"}),(0,r.jsx)("div",{className:"medgpt-status-loader__dot medgpt-status-loader__dot--right"}),(0,r.jsx)("div",{className:"medgpt-status-loader__dot medgpt-status-loader__dot--bottom"}),(0,r.jsx)("div",{className:"medgpt-status-loader__dot medgpt-status-loader__dot--left"})]}),t2=e=>{let t,s,{chatStatus:n="thinking",searchingRound:a=1}=e,i=(0,ei.s)();return"idle"===n||"streaming"===n||"error"===n?null:("searching"===n?(t=(e=>e<=1?"chat.status.searching":2===e?"chat.status.searching-2":"chat.status.searching-3")(a),s="chat.status.searching"):s=t="generating"===n?"chat.status.generating":"chat.status.thinking",(0,r.jsxs)("div",{className:"medgpt-status-indicator py-2","data-testid":"medgpt-status-indicator",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,r.jsx)(t1,{}),(0,r.jsx)("span",{"aria-hidden":"true",children:i(t)})]}),(0,r.jsx)("span",{className:"sr-only",role:"status","data-testid":"medgpt-status-indicator-live",children:i(s)}),"generating"===n&&(0,r.jsx)(t0,{})]}))},t3=e=>{var t,s,n,a;let{section:i,onTabChange:o,"data-testid":l,error:c,isLastSection:u,onFollowUpClick:m}=e,{track:p}=ex(),x=(0,ei.s)(),{isMobileScreen:h}=ea(),{isLimitReached:b}=f(),v=(0,g.J)(e=>e.isFollowUpEnabled()),{response:j,sources:y,activeTab:w,chatStatus:N,searchingRound:k}=i,C=v&&!!u&&"complete"===j.status&&(null!=(s=null==(t=i.followUpQuestions)?void 0:t.length)?s:0)>0&&!b,_=y.totalCount,S=!!i.clarification||!!i.isClarificationRoundTwo,R=S?((e,t)=>{if(0===e.length)return"";let s=t("chat.clarification.recap-question-label"),r=t("chat.clarification.recap-answer-label"),n=t("chat.clarification.recap-no-preference-answer"),a=e.map(e=>{let{question:t,answerText:a}=e;return["".concat(s," ").concat(t),"".concat(r," ").concat(a||n)].join("\n")});return[t("chat.clarification.recap-intro"),a.join("\n\n")].join("\n")})(null!=(n=i.clarificationAnswerPairs)?n:[],e=>x(e)):"",E=(0,d.useMemo)(()=>y.queryGroups.flatMap(e=>e.sources),[y.queryGroups]),A={id:"response-".concat(i.id),responseId:j.id,role:"assistant",content:j.content,timestamp:i.timestamp,status:"complete"===j.status?"complete":"loading",messageType:"response-content",documentSources:E,context:i.context},I=(e,t)=>{if(j.id){var s;p("trackOnCompanionDocumentClicked",{response_id:j.id,document_id:e.id,document_url:null!=(s=e.url)?s:null,element:t})}tl(e.url,e.id)},L="".concat(x("chat.tabs.sources")," ").concat(_>0?" (".concat(_,")"):"");return(0,r.jsxs)("div",{"data-testid":l,className:"w-full",children:[S&&(0,r.jsxs)("div",{"data-testid":"clarification-summary",className:"mb-6 text-base text-primary leading-[1.35]",children:[(0,r.jsx)("p",{"data-testid":"clarification-framing-text",children:x("chat.clarification.framing-text")}),!!R&&(0,r.jsx)("p",{"data-testid":"clarification-recap",className:"mt-[1.35em] whitespace-pre-wrap",children:R})]}),(0,r.jsxs)(tr,{"data-testid":"tabs-container",value:w,onValueChange:e=>o(e),className:"w-full",children:["med"===i.context&&(0,r.jsxs)("div",{"data-testid":"tab-buttons-container",className:"flex items-end gap-6 pb-2 relative border-b border-grey-25",children:[(0,r.jsx)(tt,{"data-testid":"response-tab-button",label:(0,r.jsxs)(r.Fragment,{children:[!h&&(0,r.jsx)(tm,{size:16,className:"mr-2 p-1"}),x("chat.tabs.response")]}),isActive:"response"===w,onClick:()=>o("response"),fontWeight:"medium"}),(0,r.jsx)(tt,{"data-testid":"sources-tab-button",label:L,isActive:"sources"===w,onClick:()=>o("sources"),fontWeight:"medium"})]}),(0,r.jsx)(tn,{"data-testid":"response-tab-content",value:"response",children:j.content?(0,r.jsxs)(r.Fragment,{children:[!!(null==E?void 0:E.length)&&(0,r.jsx)(tJ,{"data-testid":"response-source-tags",documents:E,onDocumentClick:e=>I(e,"response"),onTabChange:o}),(0,r.jsx)("div",{"data-testid":"message-content",children:(0,r.jsx)(tG,{message:A,documentSources:E,error:c})}),"complete"!==j.status&&(0,r.jsx)(t2,{chatStatus:N,searchingRound:k}),C&&(0,r.jsx)(tb,{questions:null!=(a=i.followUpQuestions)?a:[],responseId:j.id,isRestored:j.isRestored,onSelect:m})]}):"loading"===j.status?(0,r.jsx)(t2,{chatStatus:N,searchingRound:k}):!S&&(0,r.jsx)(te,{"data-testid":"response-empty-state",message:x("chat.tabs.waiting-response"),description:x("chat.tabs.waiting-response-description"),size:"small"})}),(0,r.jsxs)(tn,{"data-testid":"sources-tab-content",value:"sources",children:[!!(null==E?void 0:E.length)&&(0,r.jsx)(tJ,{"data-testid":"sources-source-tags",documents:E,onDocumentClick:e=>I(e,"sources"),onTabChange:o}),y.totalCount>0?(0,r.jsx)("div",{"data-testid":"sources-content",children:(0,r.jsx)(tY,{queryGroups:y.queryGroups,responseId:j.id})}):(0,r.jsx)(te,{"data-testid":"sources-empty-state",message:x("chat.tabs.no-sources"),description:x("chat.tabs.no-sources-description"),icon:tu.A,size:"small"})]})]})]})},t5=["LLMProcessingError","DocumentRetrievalError","InternalServerError"],t4=e=>{let{title:t,body:s}=e;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("p",{"data-testid":"terminal-state-message",className:"text-base font-semibold text-primary leading-[1.35]",children:t}),(0,r.jsx)("p",{className:"text-base text-primary leading-[1.35] mt-1",children:s})]})},t7=e=>{let{section:t,onTabChange:s,isLastSection:n,error:a,onRetry:i,onFollowUpClick:o}=e,{track:l}=ex(),c=(0,ei.s)(),{userQuery:d}=t,u=!!a&&t5.includes(a.type),m=t.isBlocked||t.isOffTopic||t.isNoReliableSources||u;return(0,r.jsx)("div",{"data-testid":"section-container",className:"w-full ".concat(n?"min-h-[calc(100vh-360px)]":""),id:t.id,children:(0,r.jsxs)("div",{className:"overflow-hidden",children:[(0,r.jsx)("div",{className:"px-3 py-3 sm:px-8 sm:py-4",children:(0,r.jsx)("p",{"data-testid":"user-query",className:"text-primary text-lg sm:text-xl font-semibold leading-tight",children:d})}),m?(0,r.jsx)("div",{"data-testid":"terminal-state",className:"px-3 py-3 sm:px-8 sm:py-4",children:t.isNoReliableSources?(0,r.jsx)(t4,{title:c("chat.no-reliable-sources-message"),body:c("chat.no-reliable-sources-suggestion")}):t.isOffTopic?(0,r.jsx)(t4,{title:c("chat.off-topic-message"),body:(0,r.jsxs)(r.Fragment,{children:[c("chat.off-topic-suggestion")," ",(0,r.jsx)("a",{href:c("chat.off-topic-link-url"),target:"_blank",rel:"noopener noreferrer",className:"underline hover:text-grey-75",children:c("chat.off-topic-link-text")})]})}):u?(0,r.jsx)(t4,{title:c("chat.technical-error-message"),body:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{type:"button","data-testid":"terminal-state-retry",className:"underline hover:text-grey-75 curs
1or-pointer",onClick:i,children:c("chat.technical-error-retry")}),c("chat.technical-error-suggestion-suffix")]})}):(0,r.jsx)(t4,{title:c("chat.guard-blocked-message"),body:c("chat.guard-blocked-suggestion")})}):a&&"NoRelevantDocumentError"!==a.type&&"MaliciousContentError"!==a.type?(0,r.jsx)("div",{"data-testid":"error-divider",className:"mb-4 h-px w-full bg-grey-25"}):(0,r.jsx)("div",{"data-testid":"tabs-container-wrapper",className:"px-3 py-3 sm:px-8 sm:py-4",children:(0,r.jsx)(t3,{section:t,onTabChange:e=>{s(t.id,e),t.response.id&&l("trackOnCompanionResponseTabOpened",{response_id:t.response.id,tab_name:e})},error:a,isLastSection:n,onFollowUpClick:o})}),(null==a?void 0:a.type)==="InvalidRequestError"&&(0,r.jsx)(eJ,{type:"warning",errorType:"InvalidRequestError"})]})})},t6=e=>{var t;let{conversationState:s,sendMessage:n,stopGeneration:a,setActiveTab:i,resetConversation:o,retrySearch:l,submitClarificationAnswers:c,skipClarification:u,scrollRef:m,loadedConversationNonce:p=0}=e,{sections:x,isLoading:h,error:f}=s,b=(0,ei.s)(),{isMobileScreen:v}=ea(),j=(0,g.J)(e=>e.getFeatureFlag("enableConversationHistory")),y=el(e=>e.isOpen)&&j,w=eo(e=>e.requestLeave),{scrollViewportRef:N}=((e,t)=>{let s=(0,d.useRef)(null);return(0,d.useEffect)(()=>{e&&(()=>{let e=s.current;if(!e)return;let r=document.getElementById(t);if(!r)return;let n=r.getBoundingClientRect().top-e.getBoundingClientRect().top;e.scrollTo({top:e.scrollTop+n,behavior:"smooth"})})()},[e,t]),{scrollViewportRef:s}})(h,(null==x?void 0:x.length)>0?x[x.length-1].id:"");((e,t)=>{(0,d.useEffect)(()=>{if(t<=0)return;let s=e.current;if(!s)return;s.scrollTop=0;let r=requestAnimationFrame(()=>{s.scrollTo({top:s.scrollHeight,behavior:"smooth"})});return()=>cancelAnimationFrame(r)},[t,e])})(N,p);let k=(0,d.useCallback)(e=>{N.current=e,null==m||m(e)},[N,m]),C=(e,t)=>{n(e,{followupQuestionId:t})},_=()=>{l&&x.length>0&&l(x[x.length-1].id)},S=x.length>0?x[x.length-1]:void 0,R=(null==S||null==(t=S.clarification)?void 0:t.questions.length)?(0,r.jsx)("div",{className:"mb-4",children:(0,r.jsx)(eT,{questions:S.clarification.questions,queryId:S.id,onSkip:e=>u(S.id,e),onComplete:e=>c(S.id,e)},S.id)}):null,E=(0,r.jsx)("div",{className:"space-y-4",children:x.map(e=>(0,r.jsx)(t7,{section:e,onTabChange:i,isLastSection:e.id===x[x.length-1].id,error:f,onRetry:_,onFollowUpClick:C},e.id))});return(0,r.jsxs)("div",{className:"relative flex flex-col h-full w-full",children:[!v&&!y&&(0,r.jsx)("div",{className:"absolute flex items-start gap-2 left-6 top-7",children:(0,r.jsx)("button",{onClick:()=>w(o,h),className:"hover:opacity-80 transition-opacity cursor-pointer",children:(0,r.jsx)(ec.default,{src:"/images/medgpt.svg",alt:"MedGPT Logo",width:75,height:20})})}),(0,r.jsx)("div",{ref:k,className:"flex-1 overflow-y-auto mt-14 sm:mt-18",children:(0,r.jsx)("div",{className:"flex justify-center pb-16 px-0 sm:px-8",children:(0,r.jsx)("div",{className:"w-full max-w-4xl",children:E})})}),(0,r.jsxs)(Y,{position:"bottom",spacing:"medium",background:"card",border:"none",shadow:"none",zIndex:40,showBackdrop:!1,children:[v&&R&&(0,r.jsx)(eq,{}),R,!(v&&R)&&(0,r.jsx)(e9,{onSend:n,onStop:a,isLoading:h,placeholder:b("common.new-question"),error:f,retrySearch:_,hideBanners:!!R})]})]})},t8=e=>{let{testId:t,title:s,description:n,onRetry:a,retryLabel:i,retryTestId:o,role:l,className:c}=e;return(0,r.jsxs)("div",{"data-testid":t,role:l,className:(0,X.cn)("flex flex-col items-center gap-1 px-4 py-6 text-center",c),children:[(0,r.jsx)("p",{className:"text-base font-semibold text-[#333333]",children:s}),(0,r.jsx)("p",{className:"text-base text-[#737373] md:text-sm",children:n}),a&&i&&(0,r.jsx)("button",{type:"button","data-testid":o,onClick:a,className:"mt-3 flex h-10 cursor-pointer items-center rounded-[12px] bg-[#1a1a1a] px-4 text-sm font-semibold text-white transition-colors hover:bg-[#333333]",children:i})]})},t9=e=>{let{error:t,onRetry:s}=e,n=(0,ei.s)(),a="NotFoundError"===t.type,i=n(a?"chat.conversation-not-found-title":"chat.conversation-load-error-title"),o=n(a?"chat.conversation-not-found-description":"chat.conversation-load-error-description");return(0,r.jsx)(t8,{testId:"conversation-load-error",role:"alert",className:"h-full w-full flex-1 justify-center",title:i,description:o,onRetry:a?void 0:s,retryLabel:n("common.retry"),retryTestId:"conversation-load-error-retry"})};var se=s(2348);let st=()=>{let e=(0,ei.s)();return(0,r.jsxs)("div",{"data-testid":"conversation-loader",role:"status","aria-live":"polite",className:"flex h-full w-full flex-1 flex-col items-center justify-center gap-3",children:[(0,r.jsx)(se.A,{size:24,className:"animate-spin text-[#737373]"}),(0,r.jsx)("p",{className:"text-sm text-[#737373]",children:e("chat.conversation-loading")})]})},ss=d.useLayoutEffect,sr=()=>{let[e,t]=(0,d.useState)({platform:null,isResolved:!1});return ss(()=>{t({platform:(e=>/iPhone|iPod/i.test(e)?"ios":/Android/i.test(e)&&/Mobile/i.test(e)?"android":null)(navigator.userAgent),isResolved:!0})},[]),e},sn=[1728e5,6048e5],sa={dismissCount:0,dismissedAt:null},si=(0,n.v)()((0,a.Zr)((e,t)=>({...sa,isDismissed:!1,dismiss:()=>{try{e(e=>({isDismissed:!0,dismissCount:e.dismissCount+1,dismissedAt:Date.now()}))}catch(e){}},isHidden:()=>{let{isDismissed:e,dismissCount:s,dismissedAt:r}=t();if(e)return!0;
1if(0===s||null===r)return!1;let n=sn[s-1];return void 0===n||Date.now()-r<=n}}),{name:"synapse-app-banner",storage:(0,a.KU)(()=>localStorage),partialize:e=>({dismissCount:e.dismissCount,dismissedAt:e.dismissedAt}),onRehydrateStorage:()=>e=>{!e||(e=>{let{dismissCount:t,dismissedAt:s}=e;return!!Number.isInteger(t)&&!(t<0)&&(0===t||"number"==typeof s&&!!Number.isInteger(s)&&s>0&&s<=Date.now())})(e)||(e.dismissCount=sa.dismissCount,e.dismissedAt=sa.dismissedAt)}})),so=(0,n.v)()(e=>({hasTrackedDisplay:!1,markDisplayTracked:()=>e({hasTrackedDisplay:!0})})),sl=["Comment diagnostiquer la maladie de Lyme ?","Quelle antibioth\xe9rapie pour une diarrh\xe9e bact\xe9rienne aigu\xeb chez l'enfant ?","Quelles sont les nouvelles recommandations pour la prise en charge de l'ob\xe9sit\xe9 ?"].map((e,t)=>({id:(e=>{let t=0xdeadbeef,s=0x41c6ce57;for(let r=0;r<e.length;r++){let n=e.charCodeAt(r);t=Math.imul(t^n,0x9e3779b1),s=Math.imul(s^n,0x5f356495)}return t=Math.imul(t^t>>>16,0x85ebca6b)^Math.imul(s^s>>>13,0xc2b2ae35),(0x100000000*(2097151&(s=Math.imul(s^s>>>16,0x85ebca6b)^Math.imul(t^t>>>13,0xc2b2ae35)))+(t>>>0)).toString(36)})(e),text:e,order:t+1}));var sc=s(4033);let sd=e=>{let{size:t=16,className:s}=e;return(0,r.jsx)("svg",{width:t,height:t,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:s,"aria-hidden":"true",children:(0,r.jsx)("path",{d:"M5.50008 14.4995H10.5001M8.50008 3.49951C9.75008 3.71014 10.7882 4.74951 11.0001 5.99951M4.91883 10.437C4.32444 9.97268 3.84299 9.37969 3.51067 8.70259C3.17834 8.02549 3.00377 7.28189 3.00008 6.52764C2.98508 3.81764 5.17008 1.56201 7.87945 1.49951C8.92946 1.47408 9.96081 1.77995 10.8272 2.37373C11.6935 2.9675 12.3509 3.81903 12.7061 4.80748C13.0612 5.79594 13.096 6.87113 12.8056 7.8805C12.5152 8.88987 11.9143 9.78216 11.0882 10.4308C10.906 10.572 10.7583 10.753 10.6564 10.9598C10.5545 11.1666 10.5011 11.3939 10.5001 11.6245V11.9995C10.5001 12.1321 10.4474 12.2593 10.3536 12.3531C10.2599 12.4468 10.1327 12.4995 10.0001 12.4995H6.00008C5.86747 12.4995 5.74029 12.4468 5.64652 12.3531C5.55276 12.2593 5.50008 12.1321 5.50008 11.9995V11.6245C5.49984 11.3954 5.44736 11.1694 5.34664 10.9636C5.24592 10.7578 5.09961 10.5777 4.91883 10.437Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})},su=e=>{let{onSelect:t,isExpanded:s,onToggle:n,scrollable:a=!0,className:i}=e,o=(0,ei.s)(),{track:l}=ex(),[c,u]=(0,d.useState)(!1),m=(0,d.useRef)(!1);return(0,d.useEffect)(()=>{m.current||(m.current=!0,l("trackOnCompanionOnboardingQuestionsDisplayed",{onboarding_questions:sl.map(e=>{let{id:t,text:s}=e;return{onboarding_question_id:t,onboarding_question_text:s}})}))},[l]),(0,r.jsxs)("section",{"data-testid":"sample-questions",className:(0,X.cn)("flex w-full flex-col mt-2",a&&"min-h-0",i),children:[(0,r.jsxs)("button",{type:"button","data-testid":"sample-questions-toggle","aria-expanded":s,onClick:()=>{u(!0),n()},className:"flex w-full shrink-0 cursor-pointer items-center justify-between gap-4 rounded-[12px] p-3 text-left",children:[(0,r.jsx)("span",{className:"text-sm font-semibold leading-[1.35] text-brand-main-primary",children:o("welcome.sample-questions-title")}),(0,r.jsx)(sc.A,{size:16,className:(0,X.cn)("shrink-0 text-grey-75",c&&"transition-transform ".concat(X.Lx," motion-reduce:transition-none"),s&&"rotate-180")})]}),(0,r.jsx)("div",{className:(0,X.cn)("grid",s?"grid-rows-[1fr]":"grid-rows-[0fr]",a&&"min-h-0",c&&"transition-[grid-template-rows] ".concat(X.Lx," motion-reduce:transition-none")),children:(0,r.jsx)("ul",{"data-testid":"sample-questions-list",inert:!s,className:(0,X.cn)("min-h-0 overflow-hidden",a&&s&&"overflow-y-auto"),children:sl.map((e,s)=>{let{id:n,text:a,order:i}=e;return(0,r.jsxs)("li",{children:[(0,r.jsxs)("button",{type:"button","data-testid":"sample-question",onClick:()=>((e,s,r)=>{l("trackOnCompanionOnboardingQuestionsClicked",{onboarding_question_id:e,onboarding_question_text:s,onboarding_question_order:r}),t(s,e)})(n,a,i),className:"flex w-full cursor-pointer items-center gap-2 rounded-[12px] p-3 pl-4 text-left transition-colors hover:bg-brand-light-tertiary",children:[(0,r.jsx)(sd,{size:16,className:"shrink-0 text-brand-main-tertiary"}),(0,r.jsx)("span",{className:"text-sm leading-[1.35] text-grey-100 [word-break:break-word]",children:a})]}),s<sl.length-1&&(0,r.jsx)("div",{className:"mx-3 border-b border-[#ededed]"})]},n)})})})]})},sm=e=>{let{onFirstMessage:t,onOpenLegalNotice:s,isLoading:n}=e,a=(0,ei.s)(),{isMobileScreen:i}=ea(),o=(0,g.J)(e=>e.isSampleQuestionsDisabled()),l=(0,g.J)(e=>e.isConfigLoaded),{isResolved:u}=sr(),{status:m}=(0,c.useSession)(),p=si(e=>e.isDismissed),x=(0,d.useRef)(p),h=(0,d.useRef)(null),f=(0,d.useRef)(null),[b,v]=(0,d.useState)(null),[j,y]=(0,d.useState)(0),[w,N]=(0,d.useState)(!0),k=l&&u&&"loading"!==m;(0,d.useLayoutEffect)(()=>
1{if(b||!i||!k)return;let e=f.current;if(!e)return;let t=!o&&e.scrollHeight>e.clientHeight;v({height:e.clientHeight,isSampleQuestionsCollapsed:t}),t&&N(!1)},[b,i,k,o]),(0,d.useLayoutEffect)(()=>{if(x.current===p)return;x.current=p;let e=h.current;if(!i||!b||!e)return;let t=e.clientHeight-52-b.height;t<=0||(v({...b,height:b.height+t}),y(t))},[p,i,b]),(0,d.useLayoutEffect)(()=>{var e;j&&(null==(e=f.current)||e.getBoundingClientRect(),y(0))},[j]);let C=i?{top:52,height:null==b?void 0:b.height,paddingTop:j}:void 0,_=!i||(null==b?void 0:b.isSampleQuestionsCollapsed)===!0;return(0,r.jsxs)("div",{ref:h,"data-testid":"welcome-screen",className:"relative h-full w-full bg-bottom bg-no-repeat",children:[(0,r.jsxs)("div",{"data-testid":"welcome-content",className:"flex flex-col items-center justify-start h-full w-full p-3 sm:p-8 bg-repeat",style:{backgroundImage:"url(/images/bg-overlay.svg)",backgroundPosition:"-12px -9px"},children:[(0,r.jsx)("div",{"data-testid":"background-filter",className:"absolute bottom-0 left-0 right-0 h-full bg-cover bg-bottom bg-no-repeat",style:{backgroundImage:"url(/images/filter.svg) "}}),(0,r.jsxs)("div",{ref:f,"data-testid":"main-content",style:C,className:(0,X.cn)("absolute flex flex-col items-center w-full sm:max-w-3xl",i?"bottom-0 px-3 pb-3":"top-2/9 bottom-[88px] justify-start p-3 sm:p-0 space-y-8 sm:space-y-10",i&&!j&&"transition-[padding-top] ".concat(X.Lx," motion-reduce:transition-none")),children:[(0,r.jsx)("div",{"data-testid":"hero-section",style:i?{minHeight:63}:void 0,className:(0,X.cn)("flex flex-col items-center space-y-2",i?"flex-1 justify-center":"shrink-0"),children:(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center gap-4",children:[(0,r.jsx)("div",{"data-testid":"logo-section",className:"flex items-start space-x-2",children:(0,r.jsx)("div",{className:"flex items-center gap-2",children:(0,r.jsx)(ec.default,{"data-testid":"medgpt-logo",src:"/images/logo.svg",alt:"MedGPT",width:146,height:31})})}),(0,r.jsx)("h2",{"data-testid":"hero-title",className:"[@media(max-height:499px)_or_(max-width:767px)]:hidden flex text-[28px] sm:text-3xl leading-[1.35] text-center text-grey-80 font-instrument-serif",children:a("welcome.hero")})]})}),(0,r.jsxs)("div",{"data-testid":"message-input-section",className:"w-full max-w-full sm:max-w-3xl flex flex-col-reverse sm:flex-col ".concat(_?"min-h-0":""),children:[(0,r.jsx)(e9,{onSend:t,isLoading:n,placeholder:a("welcome.type-placeholder"),className:"w-full shrink-0"}),!o&&(0,r.jsx)(su,{onSelect:(e,s)=>t(e,{onboardingQuestionId:s}),isExpanded:w,onToggle:()=>N(e=>!e),scrollable:_,className:(0,X.cn)(!b&&"max-md:invisible")})]})]})]}),!i&&(0,r.jsx)("div",{"data-testid":"footer",className:"flex absolute bottom-[32px] px-6 left-0 right-0 items-center justify-center",children:(0,r.jsxs)("p",{"data-testid":"footer-text",className:"whitespace-nowrap rounded-[12px] border border-[#ededed] bg-[#fafafa] px-3 py-1.5 text-sm leading-[1.25] text-[#737373]",children:[a("common.footer-brand-1"),(0,r.jsx)("a",{"data-testid":"synapse-link",href:"https://synapse-medicine.com/fr",target:"_blank",className:"hover:text-grey-75 transition-colors",children:a("common.brand")}),a("common.footer-brand-2")]})})]})},sp=(0,$.default)(()=>s.e(359).then(s.bind(s,2740)).then(e=>({default:e.DevFeatureFlagPanel})),{loadableGenerated:{webpack:()=>[2740]},ssr:!1}),sx=e=>{let{conversation:t,onOpenLegalNotice:s,scrollRef:n}=e,{conversationState:a,isLoadingConversation:i,loadedConversationNonce:o,sendMessage:l,setActiveTab:c,stopGeneration:m,retrySearch:p,submitClarificationAnswers:x,skipClarification:h,hasConversation:b,resetConversation:v,loadConversation:j}=t,{setFeatureFlags:y,setGtm:w,setApi:N}=(0,g.J)(),k=K(e=>e.activeConversationId),C=(0,g.J)(e=>{var t;return null!=(t=e.featureFlags.enableFeatureFlagPanel)&&t}),{isAuthenticated:_}=u(),{limit:S,isLimitReached:R,isSyncing:E}=f(),[A,I]=(0,d.useState)(!1);(0,d.useEffect)(()=>{(async()=>{try{let e=await fetch("/api/public/config",{cache:"no-store"});if(!e.ok)return void console.error("[ConversationInterface] /api/public/config returned",e.status);let t=await e.json();y(t.featureFlags),t.gtm&&w(t.gtm),t.api&&N(t.api)}catch(e){console.error("[ConversationInterface] Failed to fetch /api/public/config",e)}})()},[y,w,N]),(0,d.useEffect)(()=>{S&&R&&!E&&!A&&b&&!_&&I(!0)},[R,E]);let L=b||i?void 0:a.error;return(0,r.jsxs)(r.Fragment,{children:[i?(0,r.jsx)(st,{}):b?(0,r.jsx)(t6,{conversationState:a,sendMessage:l,stopGeneration:m,setActiveTab:c,retrySearch:p,submitClarificationAnswers:x,skipClarification:h,resetConversation:v,scrollRef:n,loadedConversationNonce:o}):L?(0,r.jsx)(t9,{error:L,onRetry:()=>{k&&j(k)}}):(0,r.jsx)(sm,{onFirstMessage:l,isLoading:a.isLoading,onOpenLegalNotice:s}),C&&(0,r.jsx)(sp,{})]})},sh={sm:"h-[27px]",default:"h-[40px]"},sf={default:"bg-grey-0 hover:bg-grey-25 hover:border-grey-25",secondary:"bg-grey-100 hover:bg-black text-white"},sg=e=>{let{size:t="default",variant:s="default",hasRegister:n,className:a,onClick:i}=e,{isAuthenticated:o}
1=u(),l=(0,ei.s)(),{getSessionId:d}=(0,g.J)(),m=async()=>{o?(0,c.signOut)():(0,c.signIn)("keycloak",void 0,{sessionId:d()}),i&&i()},p=l(o?"auth.sign-out":n?"auth.sign-in-register":"auth.sign-in");return(0,r.jsx)("div",{className:"flex items-center gap-2","data-testid":"sign-in-out-button-wrapper",children:(0,r.jsx)("button",{"data-testid":"sign-in-out-button",onClick:m,className:(0,X.cn)("h-[40px] cursor-pointer font-semibold px-3 flex items-center rounded-md border border-grey-0 text-sm bg-grey-0 hover:bg-grey-25 hover:border-grey-25",sf[s],sh[t],a),children:p})})},sb=e=>{let{className:t}=e;return(0,r.jsxs)("div",{"data-testid":"auth-buttons-group",className:(0,X.cn)(t,"flex items-center gap-2"),children:[(0,r.jsx)(sg,{className:"hidden sm:block"}),(0,r.jsx)(e2,{})]})},sv=e=>{let{children:t,className:s,style:n,closeLabel:a,onClose:i,backdropClassName:o}=e;return(0,r.jsxs)("div",{"data-testid":"modal-overlay",className:"fixed inset-0 w-dvw h-dvh z-50 overflow-hidden",children:[(0,r.jsx)("div",{"data-testid":"modal-backdrop",className:(0,X.cn)("w-full h-full bg-white/70 backdrop-blur-xs",o)}),(0,r.jsxs)("div",{"data-testid":"modal-container",className:(0,X.cn)("absolute flex bg-white top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[90vw] max-w-3xl max-h-[90vh] bg-repeat bg-center rounded-lg sm:rounded-xl",s),style:n,children:[(0,r.jsx)("div",{"data-testid":"modal-close-button-container",className:"absolute top-3 right-3 sm:top-6 sm:right-6 flex justify-center z-10 max-w-dvw max-h-dvh",children:(0,r.jsxs)("button",{"data-testid":"modal-close-button",className:"flex items-center gap-2 font-semibold cursor-pointer text-sm bg-white/80 backdrop-blur-sm rounded-full p-2 hover:bg-white/90 transition-colors",onClick:i,children:[a?(0,r.jsx)("span",{className:"hidden sm:inline",children:a}):null,(0,r.jsx)(eh.A,{size:16})]})}),(0,r.jsx)("div",{"data-testid":"modal-content",className:"overflow-y-auto p-4 sm:p-6 w-full",children:t})]})]})};function sj(e){let{className:t,type:s="text",...n}=e;return(0,r.jsx)("input",{type:s,"data-slot":"input",className:(0,X.cn)("border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex h-10 w-full rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),...n})}var sy=s(2799),sw=s(2108);function sN(e){let{...t}=e;return(0,r.jsx)(sy.bL,{"data-slot":"select",...t})}function sk(e){let{className:t,size:s="default",children:n,...a}=e;return(0,r.jsxs)(sy.l9,{"data-slot":"select-trigger","data-size":s,className:(0,X.cn)("border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...a,children:[n,(0,r.jsx)(sy.In,{asChild:!0,children:(0,r.jsx)(sc.A,{className:"size-4 opacity-50"})})]})}function sC(e){let{className:t,children:s,position:n="popper",...a}=e;return(0,r.jsx)(sy.ZL,{children:(0,r.jsxs)(sy.UC,{"data-slot":"select-content",className:(0,X.cn)("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md","popper"===n&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:n,...a,children:[(0,r.jsx)(sS,{}),(0,r.jsx)(sy.LM,{className:(0,X.cn)("p-1","popper"===n&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:s}),(0,r.jsx)(sR,{})]})})}function s_(e){let{className:t,children:s,...n}=e;return(0,r.jsxs)(sy.q7,{"data-slot":"select-item",className:(0,X.cn)("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",t),...n,children:[(0,r.jsx)("span",{className:"absolute left-2 flex size-3.5 items-center justify-center",children:(0,r.jsx)(sy.VF,{children:(0,r.jsx)(ey.A,{className:"size-4"})})}),(0,r.jsx)(sy.p4,{children:s})]})}function sS(e){let{className:t,...s}=e;return(0,r.jsx)(sy.PP,{"data-slot":"select-scroll-up-button",className:(0,X.cn)("flex cursor-default items-center justify-center py-1",t),...s,children:(0,r.jsx)(sw.A,{className:"size-4"})})}function sR(e){let{className:t,...s}=e;return(0,r.jsx)(sy.wn,{"data-slot":"select-scroll-down-button",className:(0,X.cn)("flex cursor-default items-center justify-center py-1",t),...s,children:(0,r.jsx)(sc.A,{className:"size-4"})})}let sE=["general_practitioner","specialised_practitioner","pharmacist","dentist","nurse","midwife","physiotherapist","other_healthcare_professional","healthcare_student","industry_professional","other"],sA=["specialised_practitioner","other_healthcare_professional","other"],sI="none",sL=e=>{let{onClose:t}=e,s=(0,ei.s)(),{track:n}=ex(),a=em(e=>e.setQualification),[i,o]=(0,d.useState)(()=>em.getState().specialty),[l,c]=(0,d.useState)(()=>em.getState().detail),[u,m]=(0,d.useState)(!1),p=sA.includes(i);return(0,r.jsx)(sv,{closeLabel:s("specialty-qualification.modal.close"),onClose:t,backdropClassName:"bg-black/30 backdrop-blur-none",className:"max-w-2xl shadow-[0_12px_24px_0_rgba(34,45,57,0.06)]",children:(0,r.jsxs)("div",{"data-testid":"specialty-qualification-modal",className:"flex flex-col items-center gap-8 px-2 pb-4 pt-10 text-center sm:gap-10 sm:px-6 sm:pb-8 sm:pt-12",children:[(0,r.jsxs)("div",{className:"flex flex-col items-center gap-3",children:[(0,r.jsx)("h2",{className:"font-instrument-serif text-4xl leading-tight text-grey-100 sm:text-5xl",children:s("specialty-qualification.modal.title")}),(0,r.jsx)("p",{className:"max-w-md text-base leading-[1.35] text-grey-75",children:s("specialty-qualification.modal.subtitle")})]}),(0,r.jsxs)("form",{onSubmit:e=>{if(e.preventDefault(),p&&""===l.trim())return void m(!0);m(!1);let s=p?l.trim():"";if(a(i,s),""!==i){let e={user_type:i,user_sub_type:s};n("trackOnCompanionUserTypeSelected",e),""!==s&&n("trackOnCompanionUserSubTypeSelected",e)}t()},noValidate:!0,className:"flex w-full max-w-md flex-col gap-4",children:[(0,r.jsxs)(sN,{value:i||sI,onValueChange:e=>{o(e===sI?"":e),c(""),m(!1)},children:[(0,r.jsx)(sk,{"data-testid":"specialty-qualification-select",className:"h-10 w-full border-grey-25 [&_svg]:transition-transform data-[state=open]:[&_svg]:rotate-180",children:""===i?(0,r.jsx)("span",{className:"text-grey-50",children:s("specialty-qualification.modal.specialty-placeholder")}):(0,r.jsx)("span",{className:"text-grey-100",children:s("specialties.".concat(i))})}),(0,r.jsxs)(sC,{children:[(0,r.jsx)(s_,{value:sI,children:s("specialty-qualification.modal.none")}),sE.map(e=>(0,r.jsx)(s_,{value:e,children:s("specialties.".concat(e))},e))]})]}),p&&(0,r.jsxs)("div",{className:"flex flex-col gap-1 text-left",children:[(0,r.jsx)(sj,{"data-testid":"specialty-qualification-detail",required:!0,value:l,onCh
1ange:e=>{c(e.target.value),u&&m(!1)},placeholder:s("specialty-qualification.modal.detail-placeholder"),className:"border-grey-25","aria-describedby":u?"specialty-qualification-detail-error":void 0}),u&&(0,r.jsx)("p",{id:"specialty-qualification-detail-error","data-testid":"specialty-qualification-detail-error",className:"text-sm text-destructive",children:s("specialty-qualification.modal.detail-required")})]}),(0,r.jsxs)(eM.$,{"data-testid":"specialty-qualification-submit",type:"submit",className:"h-10 w-full",children:[s("specialty-qualification.modal.submit"),(0,r.jsx)(ej.A,{size:16})]})]})]})})},sD=e=>{let{isGenerating:t}=e,s=(0,ei.s)(),n=(0,d.useId)(),a=(0,d.useId)(),i=(0,d.useRef)(null),o=(0,d.useRef)(null),[l,c]=(0,d.useState)(!1),u=eo(e=>e.confirmLeave),m=eo(e=>e.cancelLeave),p=eo(e=>e.resolvePendingAction);return(e=>{let{containerRef:t,initialFocusRef:s,onEscape:r}=e;(0,d.useEffect)(()=>{var e;let t=document.activeElement;return null==(e=s.current)||e.focus(),()=>{t instanceof HTMLElement&&t.focus()}},[s]),(0,d.useEffect)(()=>{let e=e=>{var s;if("Escape"===e.key)return void r();if("Tab"!==e.key)return;let n=null==(s=t.current)?void 0:s.querySelectorAll('a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])');if(!(null==n?void 0:n.length))return;let a=n[0],i=n[n.length-1];if(e.shiftKey&&document.activeElement===a){e.preventDefault(),i.focus();return}e.shiftKey||document.activeElement!==i||(e.preventDefault(),a.focus())};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[t,r])})({containerRef:i,initialFocusRef:o,onEscape:m}),(0,d.useEffect)(()=>{t||p()},[t,p]),(0,r.jsxs)("div",{"data-testid":"leave-conversation-modal-overlay",className:"fixed inset-0 z-50 flex h-dvh w-dvw items-center justify-center overflow-hidden p-4",children:[(0,r.jsx)("div",{"data-testid":"leave-conversation-modal-backdrop",className:"absolute inset-0 bg-[#cfcfcf]/55 backdrop-blur-[2px]"}),(0,r.jsxs)("div",{ref:i,role:"dialog","aria-modal":"true","aria-labelledby":n,"data-testid":"leave-conversation-modal",className:"relative flex max-h-[90vh] w-full max-w-[600px] flex-col overflow-y-auto rounded-[16px] bg-white shadow-[0_12px_24px_0_rgba(34,45,57,0.06)]",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-6 p-6",children:[(0,r.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,r.jsx)("h2",{id:n,className:"text-xl font-semibold leading-[1.25] text-[#333333]",children:s("leave-conversation-modal.title")}),(0,r.jsx)("button",{type:"button","data-testid":"leave-conversation-modal-close-button","aria-label":s("ui.close"),onClick:m,className:"shrink-0 cursor-pointer rounded-[4px] p-1 text-[#333333] transition-colors hover:bg-[#f2f2f2] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand-purple-light",children:(0,r.jsx)(eh.A,{size:20})})]}),(0,r.jsx)("p",{className:"text-base leading-[1.35] text-[#333333]",children:s("leave-conversation-modal.body")})]}),(0,r.jsxs)("div",{"data-testid":"leave-conversation-modal-footer",className:"flex flex-col gap-4 border-t border-[#e6e6e6] px-6 py-4 md:flex-row md:items-center md:justify-between",children:[(0,r.jsxs)("button",{type:"button",role:"checkbox","aria-checked":l,"aria-labelledby":a,"data-testid":"leave-conversation-modal-checkbox","data-state":l?"checked":"unchecked",onClick:()=>c(!l),className:"flex cursor-pointer items-center gap-2 self-start rounded-[4px] md:self-center focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand-purple-light",children:[(0,r.jsx)("span",{"aria-hidden":!0,className:(0,X.cn)("flex size-[18px] shrink-0 items-center justify-center rounded-[6px] border transition-colors",l?"border-[#333333] bg-[#333333] text-white":"border-[#bfbfbf] bg-white"),children:l&&(0,r.jsx)(ey.A,{className:"size-3",strokeWidth:3})}),(0,r.jsx)("span",{id:a,className:"select-none text-base leading-[1.35] text-[#333333]",children:s("leave-conversation-modal.checkbox-label")})]}),(0,r.jsxs)("div",{className:"flex flex-col gap-4 md:flex-row",children:[(0,r.jsx)("button",{type:"button",ref:o,"data-testid":"leave-conversation-modal-wait-button",onClick:m,className:"h-10 w-full cursor-pointer rounded-[12px] bg-[#f2f2f2] px-4 text-base font-semibold leading-[1.35] text-[#333333] transition-colors hover:bg-[#e6e6e6] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand-purple-light md:w-auto",children:s("leave-conversation-modal.wait-button")}),(0,r.jsx)("button",{type:"button","data-testid":"leave-conversation-modal-leave-button",onClick:()=>u(l),className:"h-10 w-full cursor-pointer rounded-[12px] bg-[#333333] px-4 text-base font-semibold leading-[1.35] text-white transition-colors hover:bg-[#1a1a1a] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand-purple-light md:w-auto",children:s("leave-conversation-modal.leave-button")})]})]})]})]})},sT=e=>{let{onClose:t}=e,s=(0,ei.s)();return(0,r.jsxs)(sv,{className:"modal-shadow",onClose:t,children:[(0,r.jsx)("h2",{className:"text-xl font-semibold",children:s("legal-notice.title")}),(0,r.jsx)("p",{className:"text-lg mt-1 text-grey-75",children:s("legal-notice.subtitle")}),(0,r.jsx)("div",{className:"mt-4",children:(0,r.jsx)("p",{className:"text-lg",children:s("legal-notice.content")})})]})},sF=e=>{let{platform:t}=e,s=(0,ei.s)(),n=si(e=>e.dismiss),{track:a,flush:i}=ex(),o=(0,d.useRef)(0),l=(0,d.useRef)(!1);return(0,d.useEffect)(()=>{let{hasTrackedDisplay:e,markDisplayTracked:s}=so.getState();e||(s(),a("trackOnCompanionAppDownloadBannerDisplayed",{banner_platform:t,dismiss_count:si.getState().dism
1issCount}))},[t,a]),(0,r.jsxs)("div",{"data-testid":"mobile-app-banner",className:"mx-2 my-5 flex h-[38px] items-center justify-between sm:mx-0",children:[(0,r.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,r.jsx)("button",{type:"button","data-testid":"mobile-app-banner-close","aria-label":s("mobile-app-banner.close"),onClick:()=>{l.current||(l.current=!0,a("trackOnCompanionAppDownloadBannerDismissed",{banner_platform:t,dismiss_count:si.getState().dismissCount})),n()},className:"group -mx-[9px] flex size-[38px] shrink-0 cursor-pointer items-center justify-center outline-none",children:(0,r.jsx)(ec.default,{src:"/images/icons/icn-cross.svg",alt:"",width:20,height:20,className:"rounded-[6px] group-focus-visible:ring-[3px] group-focus-visible:ring-ring/50"})}),(0,r.jsx)(ec.default,{"data-testid":"mobile-app-banner-icon",src:"/images/medgpt-app-icon.png",alt:"",width:38,height:38,className:"size-[38px] shrink-0 object-cover drop-shadow-[0_4px_8px_#222d3914]"}),(0,r.jsxs)("div",{className:"flex min-w-0 flex-col items-start",children:[(0,r.jsx)("span",{"data-testid":"mobile-app-banner-title",className:"text-base font-semibold leading-[1.35] text-[#333333]",children:s("common.app-name")}),(0,r.jsx)("span",{"data-testid":"mobile-app-banner-baseline",className:"max-w-full truncate text-xs leading-[1.35] text-[#737373]",children:s("mobile-app-banner.baseline")})]})]}),(0,r.jsx)("a",{"data-testid":"mobile-app-banner-cta",href:er[t],onClick:()=>{let e=Date.now();e-o.current<500||(o.current=e,a("trackOnCompanionAppDownloadBannerClicked",{banner_platform:t,dismiss_count:si.getState().dismissCount}),i())},className:"ml-2 inline-flex h-[27px] shrink-0 items-center rounded-[8px] bg-[#333333] px-3 py-1 text-xs font-semibold leading-[1.25] text-white outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50",children:s("mobile-app-banner.cta")})]})},sq=()=>{let e=K(e=>e.searchInputValue),t=K(e=>e.setSearchInputValue),s=K(e=>e.searchQuery),r=K(e=>e.search),n=K(e=>e.clearSearch),a=K(e=>e.startOrUpdateSearchIntention),i=K(e=>e.markSearchIntentionSubmitted),o=K(e=>e.consumeSearchTrackingIntention),{track:l}=ex(),c=(0,d.useRef)(!1),u=(0,d.useRef)(s);u.current=s;let m=()=>{let e=o();e&&l("trackOnCompanionHistorySearchSubmitted",{search_id:e.searchId,search_text:e.searchText})},p=(0,d.useRef)(m);return p.current=m,(0,d.useEffect)(()=>{let t=e.trim();if(t.length<3&&!c.current)return;t.length>=3&&a(t);let s=setTimeout(()=>{t.length>=3?(c.current=!0,u.current!==t&&(i(),r(t))):(c.current=!1,n())},300);return()=>clearTimeout(s)},[e,r,n,a,i]),(0,d.useEffect)(()=>{let e=setTimeout(()=>p.current(),1500);return()=>clearTimeout(e)},[e]),(0,d.useEffect)(()=>()=>{p.current(),n()},[n]),{value:e,onChange:e=>t(e.target.value),clear:()=>{t(""),c.current=!1,m(),n()}}},sM=()=>{let[e,t]=(0,d.useState)(null),[s,r]=(0,d.useState)(!1),n=(0,d.useCallback)(e=>{t(e)},[]);return(0,d.useEffect)(()=>{if(!e)return;let t=()=>{r(e.scrollTop>10)};return e.addEventListener("scroll",t,{passive:!0}),()=>e.removeEventListener("scroll",t)},[e]),{scrollRef:n,hasScrolled:s}};var sz=s(6651),sO=s(1360);function sP(e){let{className:t,...s}=e;return(0,r.jsx)("div",{"data-slot":"skeleton",className:(0,X.cn)("bg-accent animate-pulse rounded-md",t),...s})}let sH=()=>(0,r.jsx)("div",{"data-testid":"sidebar-history-skeleton",className:"flex flex-col gap-1 px-1","aria-hidden":"true",children:Array.from({length:7}).map((e,t)=>(0,r.jsx)("div",{className:"flex h-9 items-center px-3",children:(0,r.jsx)(sP,{className:"h-4 w-full"})},t))}),sU=e=>{let{testId:t,label:s}=e;return(0,r.jsxs)("div",{"data-testid":t,role:"status","aria-live":"polite",className:"flex items-center justify-center gap-2 py-3 text-xs text-[#737373]",children:[(0,r.jsx)(se.A,{size:16,className:"animate-spin"}),(0,r.jsx)("span",{children:s})]})},sB=e=>{let{id:t,label:s,isActive:n,isHovered:a,onHover:i,onSelect:o,onDelete:l,alwaysShowDelete:c}=e,d=(0,ei.s)();return(0,r.jsxs)("li",{className:"relative",onMouseEnter:()=>i(t),onMouseLeave:()=>i(null),children:[(0,r.jsxs)(e4.m_,{children:[(0,r.jsx)(e4.k$,{asChild:!0,children:(0,r.jsx)("button",{type:"button","data-testid":"sidebar-history-item","data-active":n,onClick:()=>o(t),className:(0,X.cn)("flex h-9 w-full cursor-pointer items-center rounded-[8px] px-3 text-base text-[#333333] transition-colors md:text-sm",l&&"pr-9",n?"bg-[#ededed]":a&&"bg-[#f2f2f2]"),children:(0,r.jsx)("span",{className:"min-w-0 flex-1 truncate text-left",children:s})})}),(0,r.jsxs)(e4.ZI,{side:"right",children:[(0,r.jsx)(e4.PR,{}),s]})]}),l&&(0,r.jsx)(e4.TooltipProvider,{delayDuration:1e3,skipDelayDuration:0,disableHoverableContent:!0,children:(0,r.jsxs)(e4.m_,{children:[(0,r.jsx)(e4.k$,{asChild:!0,children:(0,r.jsx)("button",{type:"button","data-testid":"sidebar-history-item-delete","aria-label":d("common.delete-conversation"),onClick:e=>{e.stopPropagation(),l(t,s)},className:(0,X.cn)("group/trash absolute top-1/2 right-1.5 flex h-6 w-6 -translate-y-1/2 cursor-pointer items-center justify-center rounded-[8px] text-[#737373] transition-[opacity,color] hover:text-[#eb4343] focus-visible:opacity-100",a||c?"opacity-100":"opacity-0 pointer-coarse:opacity-100"),children:(0,r.jsx)(sO.A,{size:16,className:"overflow-visible [&>path:nth-child(n+4)]:origin-[3px_6px] [&>path:nth-child(n+4)]:transition-transform [&>path:nth-child(n+4)]:duration-200 group-hover/trash:[&>path:nth-child(n+4)]:-translate-y-[2.8px] group-hover/trash:[&>path:nth-child(n+4)]:rotate-[-5deg]"})})}),(0,r.jsxs)(e4.ZI,{side:"right",sideOffset:10,children:[(0,r.jsx)(e4.PR,{}),d("common.delete-conversation-tooltip")]})]})})]})},sV=e=>{let{className:t,scrollRef:s,onActiveConversationDeleted:n,onConversationSelect:a,al
1waysShowDelete:i=!1,isGenerating:o}=e,l=(0,ei.s)(),{track:c}=ex(),u=K(e=>e.conversations),m=K(e=>e.searchQuery),p=K(e=>e.searchId),x=K(e=>e.searchResults),h=K(e=>e.isSearching),f=K(e=>e.activeConversationId),g=K(e=>e.isLoading),b=K(e=>e.isLoadingMore),j=K(e=>e.total),y=K(e=>e.fetchedIds.size),w=K(e=>e.error),N=K(e=>e.fetchConversations),k=K(e=>e.search),C=K(e=>e.loadMoreConversations),_=K(e=>e.setActiveConversationId),S=K(e=>e.requestDeletion),R=K(e=>e.consumeSearchTrackingIntention),E=eo(e=>e.requestLeave),A=v(e=>e.access_token),[I,L]=(0,d.useState)(null),D=(0,d.useMemo)(()=>[m,...x.map(e=>e.id),...u.map(e=>e.id)].join("|"),[m,x,u]);(0,d.useEffect)(()=>{L(null)},[D]);let T=(0,d.useCallback)(e=>{if(null==a||a(e),e===f)return void _(e);E(()=>_(e),o)},[f,o,a,E,_]),F=(0,d.useCallback)((e,t)=>{let s=R();s&&c("trackOnCompanionHistorySearchSubmitted",{search_id:s.searchId,search_text:s.searchText}),p&&c("trackOnCompanionHistorySearchResultClicked",{search_id:p,conversation_id:e,result_rank:t,result_count:x.length}),T(e)},[c,T,p,x.length,R]),q=(0,d.useCallback)((e,t)=>{let s=e===f,r=()=>{S(e,t),s&&(null==n||n())};if(!s)return void r();E(r,o)},[f,o,S,n,E]),M=(0,d.useRef)(null),z=(0,d.useRef)(null),[O,P]=(0,d.useState)(!1),H=(0,d.useRef)(null),U=(0,d.useRef)(20),B=(0,d.useCallback)(e=>{M.current=e,H.current=e,null==s||s(e)},[s]),V=(0,d.useCallback)(e=>{H.current=e},[]),G=(0,d.useRef)(!1);(0,d.useEffect)(()=>{var e,t;if(G.current||!A)return;G.current=!0;let s=(e=>e<=0?20:Math.max(3,Math.floor(Math.max(0,e-16)/40)+1))(null!=(t=null==(e=H.current)?void 0:e.clientHeight)?t:0);U.current=s,N({limit:s})},[N,A]);let W=m.trim().length>=3,Q=y<Math.min(j,1e3),J=(0,d.useRef)(Q),Z=(0,d.useRef)(b);if(J.current=Q,Z.current=b,(0,d.useEffect)(()=>{let e=M.current,t=z.current;if(!e||!t)return;let s=new IntersectionObserver(e=>P(e.some(e=>e.isIntersecting)),{root:e});return s.observe(t),()=>s.disconnect()},[W,g,w,u.length]),(0,d.useEffect)(()=>{O&&J.current&&!Z.current&&C({limit:U.current})},[O,C]),W){if(h&&0===x.length)return(0,r.jsx)("div",{className:t,children:(0,r.jsx)(sH,{})});if(w&&0===x.length)return(0,r.jsx)("div",{className:t,children:(0,r.jsx)(t8,{testId:"sidebar-history-state",title:l("common.history-error-title"),description:l("common.history-error-description"),onRetry:()=>k(m),retryLabel:l("common.retry"),retryTestId:"sidebar-history-retry"})});if(0===x.length)return(0,r.jsx)("div",{className:t,children:(0,r.jsx)(t8,{testId:"sidebar-history-state",title:l("common.history-search-empty-title"),description:l("common.history-search-empty-description")})});let e=l("common.untitled-conversation");return(0,r.jsx)("div",{"data-testid":"sidebar-search-results",className:(0,X.cn)("overflow-y-auto",t),children:(0,r.jsx)("ul",{className:"flex flex-col gap-2 px-1 md:gap-1",children:x.map((t,s)=>{var n;return(0,r.jsx)(sB,{id:t.id,label:null!=(n=t.title)?n:e,isActive:t.id===f,isHovered:t.id===I,onHover:L,onSelect:e=>F(e,s+1),onDelete:q,alwaysShowDelete:i},t.id)})})})}if(g&&0===u.length)return(0,r.jsx)("div",{ref:V,className:t,children:(0,r.jsx)(sU,{testId:"sidebar-history-loading",label:l("common.history-loading-more")})});if(w&&0===u.length)return(0,r.jsx)("div",{ref:V,className:t,children:(0,r.jsx)(t8,{testId:"sidebar-history-state",title:l("common.history-error-title"),description:l("common.history-error-description"),onRetry:()=>N({limit:U.current}),retryLabel:l("common.retry"),retryTestId:"sidebar-history-retry"})});if(0===u.length)return(0,r.jsx)("div",{ref:V,className:t,children:(0,r.jsx)(t8,{testId:"sidebar-history-state",title:l("common.history-empty-title"),description:l("common.history-empty-description")})});let $=l("common.untitled-conversation");return(0,r.jsxs)("div",{ref:B,"data-testid":"sidebar-history-list",className:(0,X.cn)("overflow-y-auto",t),children:[(0,r.jsxs)("ul",{className:"flex flex-col gap-2 px-1 md:gap-1",children:[u.map(e=>{var t;return(0,r.jsx)(sB,{id:e.id,label:null!=(t=e.title)?t:$,isActive:e.id===f,isHovered:e.id===I,onHover:L,onSelect:T,onDelete:q,alwaysShowDelete:i},e.id)}),(0,r.jsx)("li",{ref:z,"data-testid":"sidebar-history-sentinel","aria-hidden":"true",className:"h-px w-full"})]}),b&&(0,r.jsx)(sU,{testId:"sidebar-history-loading-more",label:l("common.history-loading-more")})]})};var sG=s(4005),sW=s(908),sQ=s(4926),sJ=s(9265),sZ=s(5870);s(489);let sK=e=>{let{onSettingsClick:t}=e,{data:s}=(0,c.useSession)(),{user:n}=null!=s?s:{},{name:a,email:i,image:o}=null!=n?n:{};return(0,r.jsxs)("div",{"data-testid":"user-label",className:"flex items-center gap-2 w-full",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 pr-4 w-full",children:[(0,r.jsx)("div",{"data-testid":"user-avatar",children:o?(0,r.jsx)(ec.default,{src:o,alt:"User",width:32,height:32,"data-testid":"user-avatar-image"}):(0,r.jsx)("div",{className:"user-image-placeholder rounded-full p-2","data-testid":"user-avatar-placeholder",children:(0,r.jsx)(sJ.A,{size:20,color:"white"})})}),(0,r.jsxs)("div",{className:"flex flex-col","data-testid":"user-info",children:[a&&(0,r.jsx)("div",{className:"text-base font-medium md:text-sm","data-testid":"user-name",children:a}),i&&(0,r.jsx)("div",{className:"text-sm text-grey-75 md:text-xs","data-testid":"user-email",children:i})]})]}),(0,r.jsx)("div",{children:t&&(0,r.jsx)(sZ.A,{size:20,className:"cursor-pointer",onClick:t,"data-testid":"settings-icon"})})]})},s$=e=>{let{open:t,isAuthenticated:s,onOpenLegalNotice:n,onClose:a}=e,i=(0,ei.s)(),o=e=>{e.preventDefault(),a(),tl(eY.t1,"faq-url","noopener,noreferrer")},l=e=>{e.preventDefault(),a(),tl(eY.hq,"blog-url","noopener,noreferrer")},d=e=>{e.preventDefault(),a(),tl(eY.hU,"contact-medgpt-url","noopener,noreferrer")},u=e=>{e.preventDefault(),a(),tl("/documents/cgu.pdf","cgu","noopener,noreferrer")},m=e=>
1{e.preventDefault(),a(),tl("/privacy","privacy","noopener,noreferrer")},p=e=>{e.preventDefault(),a(),(0,X.Dz)()},x=e=>{e.preventDefault(),a(),n()},h=(0,g.J)(e=>e.getFeatureFlag("enableBlogLink"));return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{"data-testid":"user-menu-backdrop","aria-hidden":"true",onClick:a,className:"fixed inset-0 z-40 ".concat(t?"":"pointer-events-none")}),(0,r.jsxs)("div",{"data-testid":"user-menu-content",role:"dialog",className:"fixed bottom-[76px] left-4 right-4 z-50 max-h-[85vh] overflow-y-auto rounded-[12px] border border-brand-purple-light bg-white p-4 text-grey-100 shadow-[0_2px_10px_0_var(--brand-light-tertiary)] transition-all ".concat(X.Lx," ").concat(t?"translate-y-0 opacity-100":"pointer-events-none translate-y-2 opacity-0"),children:[s&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{"data-testid":"user-menu-label",className:"px-2 py-1.5 font-medium",children:(0,r.jsx)(sK,{})}),(0,r.jsx)("div",{className:"bg-border -mx-4 h-px my-2"})]}),(0,r.jsxs)("div",{"data-testid":"contact-medgpt-team",className:"focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 outline-none select-none py-2",onClick:d,role:"button",tabIndex:0,onKeyDown:e=>{"Enter"===e.key&&d(e)},children:[(0,r.jsx)(sG.A,{size:16,color:"var(--grey-100)"}),i("common.contact-medgpt-team")]}),(0,r.jsx)("div",{className:"bg-border -mx-4 h-px my-2"}),(0,r.jsxs)("div",{"data-testid":"faq-link",className:"focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 outline-none select-none py-2",onClick:o,role:"button",tabIndex:0,onKeyDown:e=>{"Enter"===e.key&&o(e)},children:[(0,r.jsx)(sW.A,{size:16,color:"var(--grey-100)"}),i("common.faq-link")]}),h&&(0,r.jsxs)("div",{"data-testid":"blog-link",className:"focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 outline-none select-none py-2",onClick:l,role:"button",tabIndex:0,onKeyDown:e=>{"Enter"===e.key&&l(e)},children:[(0,r.jsx)(ec.default,{src:"/images/icons/icn-book.svg",alt:"Blog",width:16,height:16,"data-testid":"blog-icon"}),i("common.blog-link")]}),(0,r.jsx)("div",{className:"bg-border -mx-4 h-px my-2"}),(0,r.jsx)("div",{"data-testid":"legal-notice",className:"focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 outline-none select-none py-2",onClick:x,role:"button",tabIndex:0,onKeyDown:e=>{"Enter"===e.key&&x(e)},children:i("common.legal-notice")}),(0,r.jsx)("div",{"data-testid":"usage-conditions",className:"mt-2 focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 outline-hidden select-none py-2",onClick:u,role:"button",tabIndex:0,onKeyDown:e=>{"Enter"===e.key&&u(e)},children:i("common.menu-usage-conditions")}),(0,r.jsx)("div",{"data-testid":"privacy-policy",className:"mt-2 focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 outline-hidden select-none py-2",onClick:m,role:"button",tabIndex:0,onKeyDown:e=>{"Enter"===e.key&&m(e)},children:i("common.menu-privacy-policy")}),(0,r.jsx)("div",{"data-testid":"cookies-preferences",className:"mt-2 focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 outline-hidden select-none py-2",onClick:p,role:"button",tabIndex:0,onKeyDown:e=>{"Enter"===e.key&&p(e)},children:i("common.cookies-preferences")}),(0,r.jsx)("div",{className:"bg-border -mx-4 h-px my-2"}),s?(0,r.jsxs)("div",{"data-testid":"sign-out",className:"focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 outline-hidden select-none py-2",onClick:()=>(0,c.signOut)(),role:"button",tabIndex:0,onKeyDown:e=>"Enter"===e.key&&(0,c.signOut)(),children:[(0,r.jsx)(sQ.A,{size:16,color:"var(--grey-100)"}),i("auth.sign-out")]}):(0,r.jsxs)("div",{"data-testid":"sign-in-out-button-wrapper",className:"flex flex-col gap-2 px-2 py-1.5",children:[(0,r.jsx)(sg,{className:"w-full justify-center"}),(0,r.jsx)(e2,{className:"w-full justify-center"})]})]})]})};var sX=s(6191);let sY=(0,d.forwardRef)((e,t)=>{let{className:s,onNewConversationClick:n,onClick:a,label:i,...o}=e;return(0,r.jsxs)("button",{ref:t,"data-testid":"new-conversation-button",...o,className:(0,X.cn)("group flex h-10 cursor-pointer items-center rounded-[12px] bg-[#ededed] transition-colors duration-300 hover:bg-[#e0e0e0]",i?"w-full justify-start gap-2 overflow-hidden px-4 whitespace-nowrap":"w-10 justify-center",s
1),onClick:e=>{null==a||a(e),n()},children:[(0,r.jsx)(sX.A,{className:"shrink-0 transition-transform duration-300 ease-in-out group-hover:scale-[1.15]",size:16,strokeWidth:2.25,color:"#333333"}),i&&(0,r.jsx)("span",{className:"text-base font-semibold text-[#333333] md:text-sm",children:i})]})});sY.displayName="NewConversationButton";let s0=()=>{let e=(0,ei.s)();return(0,r.jsxs)("div",{"data-testid":"sign-in-promo-card",className:"flex w-full flex-col gap-6 rounded-[24px] border border-[#eaceff] bg-white p-6 shadow-[0px_2px_5px_0px_#f6ebff]",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,r.jsx)("h2",{className:"font-instrument-serif text-[28px] leading-[1.1] text-balance text-[#333333]",children:e("common.sign-in-promo-title")}),(0,r.jsx)("p",{className:"text-base leading-[1.35] text-[#737373]",children:e("common.sign-in-promo-description")})]}),(0,r.jsx)(sg,{hasRegister:!0,className:"w-full justify-center rounded-[12px]"})]})};s(3160);let s1=e=>{let{className:t}=e;return(0,r.jsxs)("div",{"data-testid":"user-menu-icon",className:(0,X.cn)("relative flex size-8 shrink-0 items-center justify-center overflow-hidden rounded-full bg-white",t),children:[(0,r.jsx)("div",{className:"absolute left-[-115px] top-[-35px] flex h-[84px] w-[148.945px] items-center justify-center",children:(0,r.jsx)("div",{className:"-rotate-90",children:(0,r.jsx)("div",{className:"relative h-[148.945px] w-[84px] opacity-50",children:(0,r.jsx)(ec.default,{src:"/images/avatar-grain.jpg",alt:"",fill:!0,sizes:"149px",className:"pointer-events-none max-w-none object-cover mix-blend-soft-light"})})})}),(0,r.jsx)("div",{className:"absolute left-[-29px] top-[-40px] flex h-[110.738px] w-[100.036px] items-center justify-center",children:(0,r.jsx)("div",{className:"rotate-[115.16deg]",children:(0,r.jsx)("div",{className:"relative h-[68.071px] w-[90.371px] blur-[4px]",children:(0,r.jsx)(ec.default,{src:"/images/avatar-gradient.png",alt:"",fill:!0,sizes:"90px",className:"pointer-events-none max-w-none object-cover"})})})}),(0,r.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 15.9002 14.0686",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"relative z-10 overflow-visible",children:[(0,r.jsx)("path",{d:"M0.75008 13.3184C1.48006 12.2239 2.52969 11.315 3.79352 10.6831C5.05736 10.0512 6.49075 9.71855 7.94998 9.71857C9.4092 9.71858 10.8429 10.0513 12.1067 10.6832C13.3705 11.3151 14.4201 12.224 15.1501 13.3186",stroke:"white",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),(0,r.jsx)("path",{className:"profile-icon-head",d:"M7.9493 9.75C10.4346 9.75 12.4493 7.73528 12.4493 5.25C12.4493 2.76472 10.4346 0.75 7.9493 0.75C5.46402 0.75 3.4493 2.76472 3.4493 5.25C3.4493 7.73528 5.46402 9.75 7.9493 9.75Z",stroke:"white",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})]})},s2=()=>(0,r.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",className:"shrink-0",children:(0,r.jsx)("path",{d:"M8 14.5C8 13.9696 7.78929 13.4609 7.41421 13.0858C7.03914 12.7107 6.53043 12.5 6 12.5H1.5V3.5H6C6.53043 3.5 7.03914 3.71071 7.41421 4.08579C7.78929 4.46086 8 4.96957 8 5.5C8 4.96957 8.21071 4.46086 8.58579 4.08579C8.96086 3.71071 9.46957 3.5 10 3.5H14.5V12.5H10C9.46957 12.5 8.96086 12.7107 8.58579 13.0858C8.21071 13.4609 8 13.9696 8 14.5ZM8 5.5V14.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),s3=e=>{let{open:t,isAuthenticated:s,conversation:n,onOpenLegalNotice:a,onClose:i}=e,o=(0,ei.s)(),{resetConversation:l}=n,c=eo(e=>e.requestLeave),u=n.conversationState.isLoading,m=v(e=>e.name),p=v(e=>e.email),{value:x,onChange:h,clear:f}=sq(),{scrollRef:g,hasScrolled:b}=sM(),[j,y]=(0,d.useState)(!0),[w,N]=(0,d.useState)(!1),{isMobileScreen:k}=ea(),[C,_]=(0,d.useState)(!1);(0,d.useEffect)(()=>{t&&_(!0)},[t]),(0,d.useEffect)(()=>{if(!t||!k)return;let e=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=e}},[t,k]);let S=()=>{i(),c(l,u)};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{"data-testid":"mobile-history-backdrop","aria-hidden":"true",onClick:i,className:(0,X.cn)("fixed inset-0 z-30 bg-black/40 transition-opacity ".concat(X.Lx),t?"opacity-100":"pointer-events-none opacity-0")}),(0,r.jsxs)("div",{"data-testid":"mobile-history-drawer",role:"dialog","aria-hidden":!t,className:(0,X.cn)("fixed top-0 left-0 right-0 bottom-0 z-40 flex h-dvh w-screen flex-col bg-white p-4 text-grey-100 transition-transform ".concat(X.Lx),t?"translate-x-0":"-translate-x-full"),children:[(0,r.jsxs)("div",{"data-testid":"mobile-history-drawer-header",className:"flex items-center justify-between px-2 py-1.5",children:[(0,r.jsx)("button",{type:"button",className:"py-3 pr-3 transition-opacity hover:opacity-80 curs
1or-pointer",onClick:S,children:(0,r.jsx)(ec.default,{src:"/images/menu-logo.svg",alt:"MedGPT",width:98,height:20})}),(0,r.jsx)("button",{type:"button",onClick:i,"aria-label":"Close menu","data-testid":"mobile-history-drawer-close",className:"cursor-pointer",children:(0,r.jsx)(eh.A,{size:20,color:"var(--grey-50)"})})]}),(0,r.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col gap-4 pt-4",children:[(0,r.jsx)(sY,{onNewConversationClick:S,label:o("common.new-conversation")}),(0,r.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col gap-2",children:[(0,r.jsxs)("button",{type:"button","data-testid":"mobile-history-toggle",disabled:!s,"aria-expanded":s&&j,onClick:()=>y(e=>!e),className:(0,X.cn)("flex h-10 items-center gap-2 rounded-[12px] px-4",s?"cursor-pointer text-[#333333]":"cursor-default text-[#bfbfbf]"),children:[(0,r.jsx)(s2,{}),(0,r.jsx)("span",{className:"flex-1 text-left text-base font-semibold",children:o("common.history")}),(0,r.jsx)(sc.A,{size:16,className:(0,X.cn)("shrink-0 transition-transform",s&&j&&"rotate-180")})]}),s&&j&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:(0,X.cn)("-mx-4 border-b px-4 pb-2 transition-colors",b?"border-[#e6e6e6]":"border-transparent"),children:(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)(sz.A,{size:16,className:"absolute top-1/2 left-3 -translate-y-1/2 text-[#737373]"}),(0,r.jsx)(sj,{"data-testid":"mobile-history-search-input",value:x,onChange:h,placeholder:o("common.search-conversation-placeholder"),className:"h-10 rounded-[12px] border-[#ededed] bg-white pr-9 pl-9 focus-visible:border-brand-purple-light focus-visible:shadow-[0_4px_12px_0_var(--brand-light-tertiary)] focus-visible:ring-0"}),x.length>0&&(0,r.jsx)("button",{type:"button","data-testid":"mobile-history-search-clear",onClick:f,"aria-label":o("common.clear-search"),className:"absolute top-1/2 right-3 flex h-5 w-5 -translate-y-1/2 cursor-pointer items-center justify-center rounded-full text-[#737373] transition-colors hover:bg-[#f2f2f2]",children:(0,r.jsx)(eh.A,{size:16})})]})}),C&&(0,r.jsx)(sV,{className:"min-h-0 flex-1 pb-2",scrollRef:g,isGenerating:u,onActiveConversationDeleted:()=>{l(),i()},onConversationSelect:i,alwaysShowDelete:!0})]})]})]}),(0,r.jsx)("div",{className:(0,X.cn)("-mx-4 mt-auto px-4 pt-3",s&&"border-t border-[#e6e6e6]"),children:s?(0,r.jsxs)("button",{type:"button","data-testid":"mobile-history-profile-row",onClick:()=>N(!0),className:(0,X.cn)("flex w-full cursor-pointer items-center gap-2 rounded-[12px] p-2 transition-colors",w?"bg-[#ededed]":"hover:bg-[#f2f2f2]"),children:[(0,r.jsx)(s1,{}),(0,r.jsxs)("div",{className:"flex min-w-0 flex-col items-start text-left",children:[m&&(0,r.jsx)("span",{className:"w-full truncate text-sm font-semibold text-[#333333]",children:m}),p&&(0,r.jsx)("span",{className:"w-full truncate text-xs text-[#737373]",children:p})]})]}):(0,r.jsx)(s0,{})}),(0,r.jsx)(s$,{open:w,isAuthenticated:s,onOpenLegalNotice:a,onClose:()=>N(!1)})]})]})},s5=d.forwardRef((e,t)=>{let{className:s,...n}=e;return(0,r.jsx)("button",{ref:t,...n,"data-testid":"user-menu-trigger",type:"button",className:(0,X.cn)("bg-white/60 rounded-lg cursor-pointer flex items-center justify-center",s),children:(0,r.jsx)(ec.default,{src:"/images/icons/icn-menu.svg",alt:"Menu",width:30,height:30,"data-testid":"user-menu-icon"})})});s5.displayName="BurgerIconTrigger";let s4=e=>{let{id:t,title:s,onRestore:n,onClose:a,duration:i=5e3}=e,o=(0,ei.s)(),l=(0,d.useRef)(a);l.current=a;let[c,u]=(0,d.useState)(!1);(0,d.useEffect)(()=>{if(i<=0||c)return;let e=setTimeout(()=>u(!0),i);return()=>clearTimeout(e)},[i,c]),(0,d.useEffect)(()=>{if(!c)return;let e=setTimeout(()=>l.current(),200);return()=>clearTimeout(e)},[c]);let[m="",p=""]=o("common.conversation-deleted-body").split("{title}");return(0,r.jsxs)("div",{"data-testid":"deletion-toast","data-toast-id":t,role:"status","aria-live":"polite",className:(0,X.cn)("pointer-events-auto flex w-[360px] max-w-[calc(100vw-2rem)] overflow-hidden rounded-[12px] border border-[#e6e6e6] bg-white shadow-[0_4px_8px_0_#222d3914] duration-200",c?"animate-out fade-out-0 slide-out-to-bottom-2":"animate-in fade-in-0 slide-in-from-bottom-2"),children:[(0,r.jsx)("span",{"aria-hidden":"true",className:"w-1 shrink-0 self-stretch bg-[#5abe8b]"}),(0,r.jsxs)("div",{className:"flex flex-1 gap-2 p-4",children:[(0,r.jsx)(ey.A,{size:20,strokeWidth:2.25,className:"mt-0.5 shrink-0 text-[#5abe8b]","aria-hidden":"true"}),(0,r.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col gap-2",children:[(0,r.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,r.jsx)("p",{"data-testid":"deletion-toast-title",className:"text-base font-semibold leading-[1.35] text-[#333333] md:text-xs",children:o("common.conversation-deleted-title")}),(0,r.jsx)("button",{type:"button","data-testid":"deletion-toast-close",onClick:()=>u(!0),"aria-label":o("common.conversation-deleted-close"),className:"-mr-1 -mt-1 flex h-6 w-6 shrink-0 cursor-pointer items-center justify-center rounded-[2px] text-[#737373] transition-colors hover:bg-[#f2f2f2]",children:(0,r.jsx)(eh.A,{size:16})})]}),(0,r.jsxs)("p",{className:"text-base leading-[1.35] text-[#333333] md:text-xs",children:[m,(0,r.jsxs)("strong",{"data-testid":"deletion-toast-body-title",className:"font-semibold italic",children:["â",(e=>e.length>100?"".concat(e.slice(0,100),"â¦"):e)(s),"â"]}
1),p]}),(0,r.jsx)("div",{className:"mt-1",children:(0,r.jsx)("button",{type:"button","data-testid":"deletion-toast-restore",onClick:n,className:"inline-flex h-[38px] cursor-pointer items-center rounded-[8px] border border-[#e6e6e6] bg-white px-4 text-sm font-semibold uppercase leading-none text-[#333333] transition-colors hover:bg-[#f2f2f2] md:h-6 md:text-xs",children:o("common.conversation-deleted-restore")})})]})]})]})},s7=e=>{let{id:t,content:s,onClick:n,duration:a=3e3}=e;return(0,d.useEffect)(()=>{let e=null;return void 0!==a&&a>0&&n&&(e=setTimeout(()=>{n()},a)),()=>{e&&clearTimeout(e)}},[n]),(0,r.jsx)("div",{"data-testid":"notification",className:"mb-2 px-4 py-2 rounded-lg bg-white text-grey-100 shadow-lg animate-in fade-in-0 slide-in-from-bottom-2 duration-200 border border-gray-300",children:(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsx)("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5","data-slot":"icon","aria-hidden":"true",className:"text-green-400",width:"24",height:"24",children:(0,r.jsx)("path",{d:"M9 12.75 11.25 15 15 9.75M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z",strokeLinecap:"round",strokeLinejoin:"round"})}),(0,r.jsx)("div",{"data-testid":"notification-content",children:s}),(0,r.jsx)("button",{"data-testid":"notification-close-button",onClick:n,className:"text-sm focus:outline-none cursor-pointer hover:bg-gray-100 rounded-sm p-1",children:(0,r.jsx)("svg",{viewBox:"0 0 20 20",fill:"currentColor","data-slot":"icon","aria-hidden":"true",width:"20",height:"20",children:(0,r.jsx)("path",{d:"M6.28 5.22a.75.75 0 0 0-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 1 0 1.06 1.06L10 11.06l3.72 3.72a.75.75 0 1 0 1.06-1.06L11.06 10l3.72-3.72a.75.75 0 0 0-1.06-1.06L10 8.94 6.28 5.22Z"})})})]})},t)},s6=Array.from({length:12},(e,t)=>{let s=Math.PI/180*(-90+30*t);return((e,t)=>{let s=[];for(let r=0;r<10;r++){let n=r%2==0?1.7:.68,a=Math.PI/180*(-90+36*r);s.push("".concat((e+n*Math.cos(a)).toFixed(2),",").concat((t+n*Math.sin(a)).toFixed(2)))}return"M".concat(s.join("L"),"Z")})(12+7.2*Math.cos(s),12+7.2*Math.sin(s))}).join(" "),s8=e=>{let{size:t=20,className:s=""}=e,n=(0,d.useId)();return(0,r.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:s,role:"presentation","aria-hidden":"true",children:[(0,r.jsx)("defs",{children:(0,r.jsx)("clipPath",{id:n,children:(0,r.jsx)("circle",{cx:"12",cy:"12",r:"12"})})}),(0,r.jsxs)("g",{clipPath:"url(#".concat(n,")"),children:[(0,r.jsx)("rect",{x:"0",y:"0",width:"24",height:"24",fill:"#003399"}),(0,r.jsx)("path",{d:s6,fill:"#FFCC00"})]})]})},s9=e=>{let{size:t=20,className:s=""}=e,n=(0,d.useId)();return(0,r.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:s,role:"presentation","aria-hidden":"true",children:[(0,r.jsx)("defs",{children:(0,r.jsx)("clipPath",{id:n,children:(0,r.jsx)("circle",{cx:"12",cy:"12",r:"12"})})}),(0,r.jsxs)("g",{clipPath:"url(#".concat(n,")"),children:[(0,r.jsx)("rect",{x:"0",y:"0",width:"8",height:"24",fill:"#0055A4"}),(0,r.jsx)("rect",{x:"8",y:"0",width:"8",height:"24",fill:"#FFFFFF"}),(0,r.jsx)("rect",{x:"16",y:"0",width:"8",height:"24",fill:"#EF4135"})]})]})};var re=s(7738);function rt(e){let{...t}=e;return(0,r.jsx)(re.bL,{"data-slot":"dropdown-menu",...t})}function rs(e){let{...t}=e;return(0,r.jsx)(re.l9,{"data-slot":"dropdown-menu-trigger",...t})}function rr(e){let{className:t,sideOffset:s=4,...n}=e;return(0,r.jsx)(re.ZL,{children:(0,r.jsx)(re.UC,{"data-slot":"dropdown-menu-content",sideOffset:s,className:(0,X.cn)("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md",t),...n})})}function rn(e){let{className:t,inset:s,variant:n="default",...a}=e;return(0,r.jsx)(re.q7,{"data-slot":"dropdown-menu-item","data-inset":s,"data-variant":n,className:(0,X.cn)("focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...a})}function ra(e){let{className:t,inset:s,...n}=e;return(0,r.jsx)(re.JU,{"data-slot":"dropdown-menu-label","data-inset":s,className:(0,X.cn)("px-2 py-1.5 text-sm font-medium data-[inset]:pl-8",t),...n})}function ri(e){let{className:t,...s}=e;return(0,r.jsx)(re.wv,{"data-slot":"dropdown-menu-separator",className:(0,X.cn)("bg-border -mx-1 my-1 h-px",t),...s})}let ro=e=>{let{className:t,separatorBefore:s}=e,n=(0,ei.s)();return(0,g.J)(e=>e.getFeatureFlag("enableRegionSelector"))?(0,r.jsxs)(r.Fragment,{children:[s&&(0,r.jsx)("div",{"data-testid":"region-separator",className:"mx-2 hidden h-[40p
1x] w-px shrink-0 bg-[#e6e6e6] sm:block","aria-hidden":"true"}),(0,r.jsxs)(rt,{children:[(0,r.jsxs)(rs,{"data-testid":"region-selector-trigger","aria-label":n("common.region-selector-label"),className:"group flex h-[40px] cursor-pointer items-center gap-1.5 rounded-[10px] border border-[#e6e6e6] bg-white px-2.5 transition-all hover:bg-[#f5f5f5] focus-visible:outline-none data-[state=open]:border-[#eaceff] data-[state=open]:shadow-[0_2px_10px_rgba(234,206,255,0.7)] ".concat(null!=t?t:""),children:[(0,r.jsx)(s9,{className:"size-5 shrink-0"}),(0,r.jsx)(sc.A,{size:16,className:"text-[#6e7881] transition-transform duration-200 group-data-[state=open]:rotate-180"})]}),(0,r.jsxs)(rr,{"data-testid":"region-selector-content",align:"end",className:"min-w-[172px] rounded-xl border-[#eaceff] p-1.5 text-grey-100 shadow-[0_8px_24px_rgba(34,45,57,0.12)]",children:[(0,r.jsxs)(rn,{"data-testid":"region-france",className:"cursor-pointer","aria-current":"true",children:[(0,r.jsx)(s9,{className:"size-5 shrink-0"}),n("common.region-france"),(0,r.jsx)("span",{className:"sr-only",children:n("common.region-selected")}),(0,r.jsx)(ey.A,{size:16,className:"ml-auto text-[#9835e6]","aria-hidden":"true"})]}),(0,r.jsxs)(rn,{"data-testid":"region-europe",className:"cursor-pointer",onSelect:()=>{tl(eY.rm,"medgpt-eu-url","noopener")},children:[(0,r.jsx)(s8,{className:"size-5 shrink-0"}),n("common.region-europe")]})]})]})]}):null};var rl=s(7931);let rc=(0,d.forwardRef)((e,t)=>{let{className:s,...n}=e;return(0,r.jsx)("button",{ref:t,"data-testid":"sidebar-history-button",...n,className:(0,X.cn)("group flex h-10 w-10 cursor-pointer items-center justify-center rounded-[12px] bg-transparent text-[#1a1a1a] transition-colors duration-300 hover:bg-[#f2f2f2] disabled:cursor-not-allowed disabled:bg-transparent disabled:text-[#d9d9d9] disabled:pointer-events-none",s),children:(0,r.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","data-testid":"sidebar-history-icon","aria-hidden":"true",className:"transition-transform duration-200 ease-in-out group-hover:scale-x-[1.14]",children:(0,r.jsx)("path",{d:"M8 14.5C8 13.9696 7.78929 13.4609 7.41421 13.0858C7.03914 12.7107 6.53043 12.5 6 12.5H1.5V3.5H6C6.53043 3.5 7.03914 3.71071 7.41421 4.08579C7.78929 4.46086 8 4.96957 8 5.5C8 4.96957 8.21071 4.46086 8.58579 4.08579C8.96086 3.71071 9.46957 3.5 10 3.5H14.5V12.5H10C9.46957 12.5 8.96086 12.7107 8.58579 13.0858C8.21071 13.4609 8 13.9696 8 14.5ZM8 5.5V14.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})});rc.displayName="ConversationHistoryButton";let rd=(0,d.forwardRef)((e,t)=>{let{className:s,isAuthenticated:n=!1,isMenuOpen:a=!1,...i}=e;return n?(0,r.jsx)("div",{ref:t,...i,"data-testid":"user-menu-trigger","data-menu-open":a,className:(0,X.cn)("group flex cursor-pointer items-center justify-center rounded-[12px] p-2 transition-colors duration-300 hover:bg-[#ededed] data-[menu-open=true]:bg-[#ededed]",s),children:(0,r.jsx)(s1,{})}):(0,r.jsx)("div",{ref:t,...i,"data-testid":"user-menu-trigger","data-menu-open":a,className:(0,X.cn)("group hover:bg-[#d9d9d9] data-[menu-open=true]:bg-[#d9d9d9] rounded-lg p-3 cursor-pointer w-[48px] h-[40px] flex items-center justify-center transition-background-color duration-300",s),children:(0,r.jsxs)("svg",{width:"17",height:"17",viewBox:"0 0 17 17",fill:"none",xmlns:"http://www.w3.org/2000/svg","data-testid":"user-menu-icon",children:[(0,r.jsx)("path",{className:"profile-icon-body",d:"M1 15.2999C1.72998 14.2054 2.77961 13.2965 4.04344 12.6646C5.30728 12.0327 6.74067 11.7001 8.1999 11.7001C9.65912 11.7001 11.0928 12.0328 12.3566 12.6647C13.6204 13.2966 14.67 14.2055 15.4 15.3001",stroke:"#333333",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),(0,r.jsx)("path",{className:"profile-icon-head",d:"M8.19922 11.7315C10.6845 11.7315 12.6992 9.71679 12.6992 7.23151C12.6992 4.74622 10.6845 2.73151 8.19922 2.73151C5.71394 2.73151 3.69922 4.74622 3.69922 7.23151C3.69922 9.71679 5.71394 11.7315 8.19922 11.7315Z",stroke:"#333333",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})})});rd.displayName="ProfileIconTrigger";let ru=e=>{let{isAuthenticated:t,onOpenLegalNotice:s,expanded:n=!1}
1=e,a=v(e=>e.name),i=v(e=>e.email),o=(0,ei.s)(),l=(0,g.J)(e=>e.getFeatureFlag("enableBlogLink")),[u,m]=(0,d.useState)(!1),p=(0,d.useRef)(!1),x=()=>{p.current=!0};return(0,r.jsxs)(rt,{onOpenChange:m,children:[n?(0,r.jsx)(rs,{className:"w-full",children:(0,r.jsxs)("div",{"data-testid":"user-menu-trigger-expanded",className:(0,X.cn)("group flex w-full cursor-pointer items-center gap-2 rounded-[12px] p-2 transition-colors hover:bg-[#f2f2f2]",u&&"bg-[#f2f2f2]"),children:[(0,r.jsx)(s1,{}),(0,r.jsxs)("div",{className:"sidebar-content-reveal flex min-w-0 flex-col items-start text-left",children:[a&&(0,r.jsx)("span",{className:"w-full truncate text-sm font-semibold text-[#333333]",children:a}),i&&(0,r.jsx)("span",{className:"w-full truncate text-xs text-[#737373]",children:i})]})]})}):(0,r.jsxs)(e4.m_,{children:[(0,r.jsx)(e4.k$,{asChild:!0,children:(0,r.jsx)(rs,{"aria-label":o("common.profile"),children:(0,r.jsx)(rd,{isAuthenticated:t,isMenuOpen:u})})}),(0,r.jsxs)(e4.ZI,{side:"right",children:[(0,r.jsx)(e4.PR,{}),o("common.profile")]})]}),(0,r.jsxs)(rr,{"data-testid":"user-menu-content",align:"start",onPointerDown:x,onPointerDownOutside:x,onCloseAutoFocus:e=>{p.current&&e.preventDefault(),p.current=!1},className:"rounded-[12px] border border-brand-purple-light text-grey-100 shadow-[0_2px_10px_0_var(--brand-light-tertiary)]",children:[t&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(ra,{"data-testid":"user-menu-label",className:"cursor-pointer rounded-sm transition-colors hover:bg-accent",onClick:()=>{tl("/api/profile","profile")},children:(0,r.jsx)(sK,{})}),(0,r.jsx)(ri,{})]}),(0,r.jsxs)(rn,{"data-testid":"contact-medgpt-team",className:"cursor-pointer",onClick:e=>{e.preventDefault(),tl(eY.hU,"contact-medgpt-url")},children:[(0,r.jsx)(sG.A,{size:16,color:"var(--grey-100)"}),o("common.contact-medgpt-team")]}),(0,r.jsx)(ri,{}),(0,r.jsxs)(rn,{"data-testid":"faq-link",className:"cursor-pointer",onClick:e=>{e.preventDefault(),tl(eY.t1,"faq-url")},children:[(0,r.jsx)(sW.A,{size:16,color:"var(--grey-100)"}),o("common.faq-link")]}),l&&(0,r.jsxs)(rn,{"data-testid":"blog-link",className:"cursor-pointer",onClick:e=>{e.preventDefault(),tl(eY.hq,"blog-url")},children:[(0,r.jsx)(ec.default,{src:"/images/icons/icn-book.svg",alt:"Blog",width:16,height:16,"data-testid":"blog-icon"}),o("common.blog-link")]}),(0,r.jsx)(ri,{}),(0,r.jsx)(rn,{"data-testid":"legal-notice",className:"cursor-pointer",onClick:s,children:o("common.legal-notice")}),(0,r.jsx)(rn,{"data-testid":"usage-conditions",className:"cursor-pointer",onClick:e=>{e.preventDefault(),tl("/documents/cgu.pdf","cgu")},children:o("common.menu-usage-conditions")}),(0,r.jsx)(rn,{"data-testid":"privacy-policy",className:"cursor-pointer",onClick:e=>{e.preventDefault(),tl("/privacy","privacy","noopener,noreferrer")},children:o("common.menu-privacy-policy")}),(0,r.jsx)(rn,{"data-testid":"cookies-preferences",className:"cursor-pointer",onClick:e=>{e.preventDefault(),(0,X.Dz)()},children:o("common.cookies-preferences")}),(0,r.jsx)(ri,{}),t?(0,r.jsxs)(rn,{"data-testid":"sign-out",className:"cursor-pointer",onClick:()=>(0,c.signOut)(),children:[(0,r.jsx)(sQ.A,{size:16,color:"var(--grey-100)"}),o("auth.sign-out")]}):(0,r.jsx)("div",{"data-testid":"sign-in-out-button-wrapper",className:"flex flex-col gap-2 px-2 py-1.5",children:(0,r.jsx)(sg,{hasRegister:!0,className:"w-full justify-center"})})]})]})};s(3741);let rm=()=>(0,r.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",className:"shrink-0 transition-transform duration-200 ease-in-out group-hover/history:scale-x-[1.14]",children:(0,r.jsx)("path",{d:"M8 14.5C8 13.9696 7.78929 13.4609 7.41421 13.0858C7.03914 12.7107 6.53043 12.5 6 12.5H1.5V3.5H6C6.53043 3.5 7.03914 3.71071 7.41421 4.08579C7.78929 4.46086 8 4.96957 8 5.5C8 4.96957 8.21071 4.46086 8.58579 4.08579C8.96086 3.71071 9.46957 3.5 10 3.5H14.5V12.5H10C9.46957 12.5 8.96086 12.7107 8.58579 13.0858C8.21071 13.4609 8 13.9696 8 14.5ZM8 5.5V14.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),rp=e=>{let{isAuthenticated:t,conversation:s,onOpenLegalNotice:n}=e,a=(0,ei.s)(),i=(0,g.J)(e=>e.getFeatureFlag("enableConversationHistory")),o=el(e=>e.isOpen),l=el(e=>e.open),c=el(e=>e.close),{scrollRef:u,hasScrolled:m}=sM(),{isMobileScreen:p}=ea(),{value:x,onChange:h,clear:f}=sq(),[b,v]=(0,d.useState)(!0),j=eo(e=>e.requestLeave),y=s.conversationState.isLoading,w=()=>s.resetConversation(),N=()=>j(w,y),k=e=>e.stopPropagation();return o&&i?(0,r.jsx)("aside",{"data-testid":"sidebar","data-state":"exp
1anded",className:(0,X.cn)("boto-dp-0 mr-2 flex w-[300px] flex-col rounded-[12px] bg-white px-3 pt-4 pb-3 transition-[width] ".concat(X.Lx," sm:mr-3")),children:(0,r.jsxs)("div",{"data-testid":"sidebar-content",className:"flex min-h-0 flex-1 flex-col",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-8",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)(e4.m_,{children:[(0,r.jsx)(e4.k$,{asChild:!0,children:(0,r.jsx)("button",{onClick:N,"aria-label":a("chat.new-conversation-tooltip"),className:"cursor-pointer",children:(0,r.jsx)(ec.default,{src:"/images/logo.svg",alt:"MedGPT",width:99,height:21})})}),(0,r.jsxs)(e4.ZI,{side:"bottom",children:[(0,r.jsx)(e4.PR,{}),a("chat.new-conversation-tooltip")]})]}),(0,r.jsxs)(e4.m_,{children:[(0,r.jsx)(e4.k$,{asChild:!0,children:(0,r.jsx)("button",{"data-testid":"sidebar-toggle",onClick:c,"aria-label":a("common.toggle-sidebar"),className:"group/toggle flex h-10 w-10 cursor-pointer items-center justify-center rounded-[12px] text-[#333333] transition-colors hover:bg-[#f2f2f2]",children:(0,r.jsx)(rl.A,{size:16,strokeWidth:2.25,className:"[&>path]:transition-transform [&>path]:duration-200 group-hover/toggle:[&>path]:translate-x-[3px]"})})}),(0,r.jsxs)(e4.ZI,{side:"right",children:[(0,r.jsx)(e4.PR,{}),a("common.toggle-sidebar")]})]})]}),(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,r.jsx)(sY,{onNewConversationClick:N,label:a("common.new-conversation")}),(0,r.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,r.jsxs)("button",{type:"button","data-testid":"sidebar-history-header",disabled:!t,"aria-expanded":t&&b,onClick:()=>v(e=>!e),className:(0,X.cn)("group/history flex h-10 items-center gap-2 rounded-[12px] px-4",t?"cursor-pointer text-[#333333]":"cursor-default text-[#bfbfbf]"),children:[(0,r.jsx)(rm,{}),(0,r.jsx)("span",{className:"flex-1 text-left text-sm font-semibold",children:a("common.history")}),(0,r.jsx)(sc.A,{size:16,className:(0,X.cn)("shrink-0 transition-transform",t&&b&&"rotate-180")})]}),t&&b&&(0,r.jsx)("div",{className:(0,X.cn)("-mx-3 border-b px-3 pb-2 transition-colors",m?"border-[#e6e6e6]":"border-transparent"),children:(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)(sz.A,{size:16,className:"absolute top-1/2 left-3 -translate-y-1/2 text-[#737373]"}),(0,r.jsx)(sj,{"data-testid":"sidebar-search-input",value:x,onChange:h,placeholder:a("common.search-conversation-placeholder"),className:"h-10 rounded-[12px] border-[#ededed] bg-white pr-9 pl-9 focus-visible:border-brand-purple-light focus-visible:shadow-[0_4px_12px_0_var(--brand-light-tertiary)] focus-visible:ring-0"}),x.length>0&&(0,r.jsxs)(e4.m_,{children:[(0,r.jsx)(e4.k$,{asChild:!0,children:(0,r.jsx)("button",{type:"button","data-testid":"sidebar-search-clear",onClick:f,"aria-label":a("common.clear-search"),className:"absolute top-1/2 right-3 flex h-5 w-5 -translate-y-1/2 cursor-pointer items-center justify-center rounded-full text-[#737373] transition-colors hover:bg-[#f2f2f2]",children:(0,r.jsx)(eh.A,{size:16})})}),(0,r.jsxs)(e4.ZI,{side:"right",children:[(0,r.jsx)(e4.PR,{}),a("common.clear-search")]})]})]})})]})]})]}),t&&b&&!p&&(0,r.jsx)(sV,{className:"-mr-3 min-h-0 flex-1 pr-3 pb-4",scrollRef:u,isGenerating:y,onActiveConversationDeleted:w}),(0,r.jsx)("div",{className:(0,X.cn)("-mx-3 mt-auto border-t px-3 pt-3 transition-colors",m?"border-[#e6e6e6]":"border-transparent"),children:t?(0,r.jsx)(ru,{expanded:!0,isAuthenticated:!0,onOpenLegalNotice:n}):(0,r.jsx)("div",{className:"sidebar-content-reveal w-full",children:(0,r.jsx)(s0,{})})})]})}):(0,r.jsxs)("aside",{"data-testid":"sidebar","data-state":"collapsed",onClick:i?l:void 0,className:(0,X.cn)("boto-dp-0 group/rail mr-2 flex w-[72px] flex-col items-start justify-between rounded-[12px] bg-white px-3 pt-4 pb-3 transition-[width] ".concat(X.Lx," sm:mr-3"),i&&"cursor-pointer"),children:[(0,r.jsxs)("div",{onClick:k,className:"flex w-12 flex-col items-center gap-8",children:[(0,r.jsxs)(e4.m_,{children:[(0,r.jsx)(e4.k$,{asChild:!0,children:(0,r.jsxs)("button",{onClick:i?l:N,"aria-label":a(i?"common.toggle-sidebar":"chat.new-conversation-tooltip"),className:"group/toggle grid h-10 w-10 cursor-pointer place-items-center rounded-[12px] transition-colors hover:bg-[#f2f2f2]",children:[(0,r.jsx)(ec.default,{src:"/images/sidebar_logo.svg",alt:"MedGPT",width:11,height:20,className:(0,X.cn)("col-start-1 row-start-1 transition-opacity duration-200",i&&"group-hover/rail:opacity-0")}),i&&(0,r.jsx)(rl.A,{size:16,strokeWidth:2.25,"aria-hidden":"true",className:"col-start-1 row-start-1 text-[#333333] opacity-0 transition-opacity duration-200 group-hover/rail:opacity-100 [&>path]:transition-transform [&>path]:duration-200 group-hover/toggle:[&>path]:translate-x-[3px]"})]})}),(0,r.jsxs)(e4.ZI,{side:"right",children:[(0,r.jsx)(e4.PR,{}),a(i?"common.toggle-sidebar":"chat.new-conversation-tooltip")]})]}),(0,r.jsxs)("div",{className:"flex flex-col items-center gap-4",children:[(0,r.jsxs)(e4.m_,{children:[(0,r.jsx)(e4.k$,{asChild:!0,children:(0,r.jsx)(sY,{onNewConversationClick:N,"aria-label":a("common.new-conversation")})}),(0,r.jsxs)(e4.ZI,{side:"right",children:[(0,r.jsx)(e4.PR,{}),a("common.new-conversation")]})]}),i&&(0,r.jsxs)(e4.m_,{children:[(0,r.jsx)(e4.k$,{asChild:!0,children:(0,r.jsx)(rc,{onClick:l,disabled:!t,"aria-label":a("common.history-tooltip")})}),(0,r.jsxs)(e4.ZI,{side:"right",children:[(0,r.jsx)(e4.PR,{}),a("common.history-tooltip")]})]})]})]}),(0,r.jsx)("div",{onClick:k,children:(0,r.jsx)(ru,{isAuthenticated:t,onOpenLegalNotice:n})})]})},rx=e=>{let t=[],s=e.endsWith("\n"),r=e.split("\n"),n=s?"":r.pop(),a="",i="";for(let e of r)if(e.startsWith("event:"))a=e.slice(6).trim();else if(e.startsWith("data:"))i=e.slice(5).trim();else if(""===e.trim()&&a&&i){try{t.push({event:a,data:JSON.parse(i)})}catch(e){}a="",i=""}return{events:t,remaining:[a&&"event:".concat(a),i&&"data:".concat(i),n].filter(
1Boolean).join("\n")}},rh=new Set(["metadata","thinking","guard_blocked","off_topic","no_reliable_sources","sub_queries","source_found","search_results","assistant_message_chunk","conversation_title","follow_up_questions","user_message","clarification","done","error"]),rf=(e,t)=>{var s,r,n;if(rh.has(e.event)){if("error"===e.event){null==(r=t.onError)||r.call(t,e.data);return}if("done"===e.event){null==(n=t.onComplete)||n.call(t,e.data.response_id,!0);return}null==(s=t.onEvent)||s.call(t,e)}},rg=e=>e.citation_indexes.length>0?Math.min(...e.citation_indexes):1/0,rb=e=>{var t,s;return{id:e.id,title:e.title,url:e.url,source_type:"internal"===e.source_type?"internal":"web",source_alias:e.source_alias,published_date:null!=(t=e.published_date)?t:"",score:e.score,rank:e.rank,query:null!=(s=e.query)?s:""}},rv=e=>({id:e.id,userQuery:e.content,timestamp:new Date(e.created_at),context:null,response:{content:"",status:"complete"},sources:{queryGroups:[],totalCount:0},activeTab:"response"}),rj=(e,t,s)=>{var r,n,a;let{metadata:i}=t,o=[...null!=(r=i.cited_sources)?r:[]].sort((e,t)=>rg(e)-rg(t)).map(rb),l=tZ(o);return{...e,context:o.length>0?"med":null,response:{id:null!=(n=i.response_id)?n:void 0,content:t.content,status:"complete",isRestored:!0},sources:{queryGroups:l,totalCount:o.length},followUpQuestions:null!=(a=i.follow_up_questions)?a:[],conversationTitle:null!=s?s:void 0}},ry=(e,t)=>"user"===t.role&&t.content.startsWith(e.userQuery+"\n\n"),rw=(e,t)=>({...e,isClarificationRoundTwo:!0,clarificationAnswerPairs:t.content.slice(e.userQuery.length).split("\n").map(e=>(e=>{if(!e.startsWith("- "))return null;let t=e.slice(2),s=t.indexOf(" : ");if(-1===s)return null;let r=t.slice(0,s).trim();return r?{question:r,answerText:t.slice(s+3).trim()}:null})(e.trim())).filter(e=>null!==e)}),rN=(e,t,s)=>({id:e,userQuery:t,timestamp:s,context:null,response:{content:"",status:"loading"},sources:{queryGroups:[],totalCount:0},chatStatus:"thinking",activeTab:"response"}),rk=["thinking","searching","generating"],rC=()=>{let e=g.J.getState().getFeatureFlag("enableConversationHistory"),t=!!v.getState().access_token;return e&&t},r_=()=>{let e=(0,ei.s)(),{scrollRef:t,hasScrolled:s}=sM(),n=(()=>{let{track:e}=ex(),t=(0,ei.s)(),[s,r]=(0,d.useState)({sections:[],isLoading:!1,error:void 0}),[n,a]=(0,d.useState)(!1),[i,o]=(0,d.useState)(0),c=K(e=>e.activeConversationId),u=(0,d.useRef)(null),m=(0,d.useRef)(null),p=(0,d.useRef)(null),x=(0,d.useRef)(!1),h=(0,d.useRef)(null),f=(0,d.useRef)(""),b=(0,d.useRef)(""),v=(0,d.useRef)(null),j=(0,d.useRef)(!1),y=(0,d.useRef)(!1),w=(0,d.useRef)(null),N=(0,d.useRef)(!1),k=(0,d.useRef)([]),C=(0,d.useRef)(!1),_=(0,d.useRef)(null),S=(0,d.useRef)(null),R=(0,d.useRef)(0),I=(0,d.useRef)(null),L=(0,d.useRef)(!1),T=(0,d.useRef)(0);(0,d.useEffect)(()=>{L.current||(L.current=!0,e("trackOnCompanionSessionStarted",{}))},[e]);let F=()=>(h.current||(h.current=crypto.randomUUID()),h.current),q=()=>rC()?{conversation_id:F()}:{},M=e=>{if(!rC())return;let t=h.current;if(!t)return;let s=new Date().toISOString();K.getState().upsertConversation({id:t,title:e,created_at:s,updated_at:s,message_count:2});let r=K.getState();r.activeConversationId!==t&&r.conversations.some(e=>e.id===t)&&r.setActiveConversationId(t)},z=()=>{f.current="",v.current=null,j.current=!1,y.current=!1,N.current=!1,w.current=null,_.current=null,S.current=null,k.current=[],I.current=null,T.current=0},P=async(s,n)=>{_.current=s;let a=Symbol("chat-stream");S.current=a,R.current=Date.now();let i=F(),o=void 0!==n.conversation_id,c=t=>{if(S.current!==a)return;console.warn("[useConversation] chat error",{error_code:t.error_code,message:t.message,recovery_suggestion:t.recovery_suggestion,details:t.details});let n=D(t);e("trackOnCompanionResponseError",{query_id:s,error_code:n.type}),r(e=>({...e,sections:e.sections.map(e=>e.id===s?{...e,response:{...e.response,status:"error"},chatStatus:"error"}:e),error:n,isLoading:!1})),C.current=!1,u.current=null},d=!1;u.current={abort:()=>{d=!0}};let{token:m,sessionExpired:A}=await E();if(d)return;if(A)return void c({event_type:"error",error_code:"AUTHENTICATION_ERROR",message:"Session expired before the query could be sent"});let{url:L,endpoint:q}=g.J.getState().getApi();u.current=((e,t,s)=>{var r,n;let a=new AbortController,i="".concat(null!=(r=null==s?void 0:s.apiUrl)?r:"").concat(null!=(n=null==s?void 0:s.apiEndpoint)?n:"","/chat"),o={"Content-Type":"application/json",Accept:"text/event-stream",...(null==s?void 0:s.token)?{Authorization:"Bearer ".concat(s.token)}:{}},c=setTimeout(()=>{var e;a.abort(),null==(e=t.onError)||e.call(t,{event_type:"error",message:"Request timeout",error_code:"CHAT_ERROR",recovery_suggestion:"The request took too long. Please try again."})},3e4);return fetch(i,{method:"POST",headers:o,body:JSON.stringify(e),signal:a.signal}).then(e=>{var s,r,n,a;if(clearTimeout(c),(e=>{let t={};e.forEach((e,s)=>{s.toLowerCase().startsWith("x-ratelimit-")&&(t[s]=e)}),Object.keys(t).length>0&&l.getState().setFromHeaders(t)})(e.headers),429===e.status){null==(r=t.onError)||r.call(t,{event_type:"error",message:"Rate limit exceeded",error_code:"RATE_LIMIT_ERROR",recovery_suggestion:"Please wait and try again later."});return}if(!e.ok){null==(n=t.onError)||n.call(t,{event_type:"error",message:"HTTP ".concat(e.status,": ").concat(e.statusText),error_code:"API_ERROR",recovery_suggestion:"An unexpected error occurred. Please retry."});return}let i=null==(s=e.body)?void 0:s.getReader();if(!i){null==(a=t.onError)||a.call(t,{event_type:"error",message:"Response body is not readable",error_code:"CHAT_ERROR",recovery_suggestion:"An unexpected error occurred. Please retry."});return}let o=new TextDecoder("utf-8"),d="",u=!1,m=()=>{i.read().then(e=>{let{done:s,value:r}=e;if(s){if(d){let{events:e}=rx(d+"\n");for(let s of e)rf(s,t),"done"===s.event&&(u=!0)}if(!u){var n;null==(n=t.onComplete)||n.call(t,"",!1)}return}let{events:a,remaining:i}=rx(d+=o.decode(r,{stream:!0}));for(let e of(d=i,a))rf(e,t),"done"===e.event&&(u=!0);m()}).catch(e=>{var s,r;"AbortError"!==e.name&&(null==(s=t.onError)||s.call(t,{event_type:"error",message:null!=(r=e.message)?r:"Stream read error",error_code:"CHAT_ERROR",recovery_suggestion:"Please check your connection and try again."}))})};m()}).catch(e=>{var s,r;clearTimeout(c),"AbortError"!==e.name&&(null==(s=t.onError)||s.call(t,{event_type:"error",message:null!=(r=e.message)?r:"Network error",error_code:"CHAT_ERROR",recovery_suggestion:"Please check your connection and try again."}))}),{abort:()=>{clearTimeout(c),a.abort()}}})(n,{onEvent:e=>{S.current===a&&((e,s,n)=>{if("done"!==e.event&&"error"!==e.event){let t=e.data.response_id;t&&r(e=>{let r=e.sections.find(e=>e.id===s);return!r||r.response.id?e:{...e,sections:e.sections.map(e=>e.id===s?{...e,response:{...e.response,id:t}}:e)}})}switch(e.event){case"metadata":n&&(h.current=e.data.conversation_id);return;case"thinking":{let{phase:t}=e.data;if(!rk.includes(t))return;r(e=>({...e,sections:e.sections.map(e=>e.id===s?{...e,chatStatus:t}:e)}));return}case"sub_queries":{T.current+=1;let e=T.current;r(t=>({...t,sections:t.sections.map(t=>
1t.id===s?{...t,searchingRound:e}:t)}));return}case"source_found":{let t={...e.data.source,query:e.data.query};k.current=[...k.current,t];let n=tZ(k.current),a=k.current.length;r(e=>({...e,sections:e.sections.map(e=>e.id===s?{...e,context:"med",sources:{queryGroups:n,totalCount:a}}:e)}));return}case"search_results":case"done":case"error":default:return;case"assistant_message_chunk":{null===I.current&&(I.current=Date.now()),f.current+=e.data.content;let t=f.current;r(e=>({...e,sections:e.sections.map(e=>e.id===s?{...e,response:{...e.response,content:t,status:"streaming"},chatStatus:"streaming"}:e)}));return}case"guard_blocked":{var a;let t=null!=(a=e.data.explanation)?a:"";f.current=t,j.current=!0,r(e=>({...e,sections:e.sections.map(e=>e.id===s?{...e,response:{...e.response,content:t,status:"complete"},isBlocked:!0}:e),isLoading:!1}));return}case"off_topic":{let t=e.data.message;f.current=t,j.current=!0,r(e=>({...e,sections:e.sections.map(e=>e.id===s?{...e,response:{...e.response,content:t,status:"complete"},isOffTopic:!0}:e),isLoading:!1}));return}case"no_reliable_sources":{let t=e.data.message;f.current=t,j.current=!0,r(e=>({...e,sections:e.sections.map(e=>e.id===s?{...e,response:{...e.response,content:t,status:"complete"},isNoReliableSources:!0}:e),isLoading:!1}));return}case"follow_up_questions":{let t=e.data.questions;r(e=>({...e,sections:e.sections.map(e=>e.id===s?{...e,followUpQuestions:t}:e)}));return}case"conversation_title":{let t=e.data.title;r(e=>({...e,sections:e.sections.map(e=>e.id===s?{...e,conversationTitle:t}:e)})),v.current=t;return}case"user_message":{if(N.current)return;let t=e.data.content;r(e=>({...e,sections:e.sections.map(e=>e.id===s?{...e,userQuery:t}:e)}));return}case"clarification":{if(y.current=!0,j.current=!0,w.current=e.data.response_id||null,g.J.getState().isQuestionClarificationDisabled())return U(s,b.current,td({originalQuestion:b.current,questions:[],answers:[],skipped:!0,t:e=>t(e)}),[],{silent:!0});let n=e.data;if(!Array.isArray(n.questions)||0===n.questions.length||n.questions.some(e=>!Array.isArray(null==e?void 0:e.options)))return;r(e=>({...e,sections:e.sections.map(e=>e.id===s?{...e,clarification:n}:e)}));return}}})(e,s,o)},onComplete:(t,n)=>{if(S.current!==a)return;if(t&&!y.current&&(p.current=t),n&&!j.current){let e=!x.current;x.current=!0,(e=>{var t;let s=e?b.current.trim():null;M(null!=(t=v.current)?t:s)})(e)}let o=null!==I.current?I.current-R.current:Date.now()-R.current;if(t){let r=k.current.map((e,t)=>{let s=tA(ta(e))||"unknown";return{date:e.published_date||null,index:t,source:s,title:e.title||null,url:e.url||null}});e("trackOnCompanionResponseGenerated",{response_id:t,query_id:s,conversation_id:i,response_time_ms:o,response_text:f.current,documents_list:r,context:{is_medical:!!r.length}})}r(e=>({...e,sections:e.sections.map(e=>e.id===s?{...e,response:{...e.response,status:"complete",id:t||e.response.id},chatStatus:"idle"}:e),isLoading:!1})),C.current=!1,u.current=null},onError:c},{token:null!=m?m:void 0,apiUrl:L,apiEndpoint:q})},H=async function(t){var s;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!t.trim()||C.current)return;if(g.J.getState().getFeatureFlag("enableClarificationTestTrigger")&&"/test-clarification"===t.trim().toLowerCase())return void(e=>{let t=rN((0,tp.Ak)(),e,new Date);y.current=!0,j.current=!0,w.current=null,r(e=>({...e,sections:[...e.sections,{...t,clarification:{questions:[{question:"Quel aspect souhaitez-vous aborder en priorit\xe9 ?",selection_mode:"exclusive",options:[{id:1,text:"Diagnostique",free_text:!1},{id:2,text:"Prise en charge de fond",free_text:!1},{id:3,text:"Autre (pr\xe9cisez)",free_text:!0}]},{question:"Quels \xe9l\xe9ments souhaitez-vous voir abord\xe9s ?",selection_mode:"cumulative",options:[{id:1,text:"Posologie",free_text:!1},{id:2,text:"Contre-indications",free_text:!1},{id:3,text:"Interactions",free_text:!1},{id:4,text:"Autre (pr\xe9cisez)",free_text:!0}]}],response_id:"test-trigger"},response:{...t.response,status:"complete"},chatStatus:"idle"}],isLoading:!1,error:void 0}))})(t);let{onboardingQuestionId:a,followupQuestionId:i}=n;C.current=!0,z();let o=(0,tp.Ak)(),l=rN(o,t,new Date);r(e=>({...e,sections:[...e.sections,l],isLoading:!0,error:void 0}));let c=g.J.getState().getFeatureFlag("enableScientificPublications"),d=e7.getState().scientificPublications;e("trackOnCompanionQuerySubmitted",{query_id:o,query_text:t,conversation_id:F(),...a&&{onboarding_question_id:a},...i&&{followup_question_id:i},...c&&{scientific_publications_enabled:d}});let u={messages:[{role:"user",content:t}],previous_response_id:null!=(s=p.current)?s:void 0,...q(),...c&&{search_parameters:{scientific_publications:d}}};b.current=t.trim(),(()=>{let e=h.current;e&&K.getState().conversations.some(t=>t.id===e)&&M(null)})(),await P(o,u)},U=function(e,t,s,n){var a,i,o;let{silent:l=!1}=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};null==(a=u.current)||a.abort(),f.current="",v.current=null,j.current=!1,y.current=!1,N.current=!0,k.current=[],I.current=null,T.current=0,b.current=t.trim(),r(t=>({...t,sections:t.sections.map(t=>
1t.id===e?{...t,clarification:void 0,pendingClarificationMessage:s,isClarificationRoundTwo:!l,clarificationAnswerPairs:n,context:null,response:{content:"",status:"loading"},sources:{queryGroups:[],totalCount:0},chatStatus:"thinking",searchingRound:void 0,isBlocked:!1,isOffTopic:!1,isNoReliableSources:!1,isCancelled:!1}:t),isLoading:!0,error:void 0}));let c=g.J.getState().getFeatureFlag("enableScientificPublications"),d=e7.getState().scientificPublications;P(e,{messages:[{role:"user",content:s}],previous_response_id:null!=(o=null!=(i=w.current)?i:p.current)?o:void 0,...q(),...c&&{search_parameters:{scientific_publications:d}}})},B=(r,n,a)=>{let i=s.sections.find(e=>e.id===r);if(!(null==i?void 0:i.clarification))return;C.current=!0;let o=a||n.length<i.clarification.questions.length,l=td({originalQuestion:i.userQuery,questions:i.clarification.questions,answers:n,skipped:o,t:e=>t(e)});U(i.id,i.userQuery,l,((e,t)=>e.map((s,r)=>{let{question:n}=s,a=t.find(e=>e.questionIndex===r);return{question:n,answerText:a?tc(a,e):""}}))(i.clarification.questions,n)),((t,s,r)=>{let n,{clarification:a}=t;if(!a)return;let[i,...o]=(n=a.questions,s.flatMap(e=>{let t=n[e.questionIndex];if(!t)return[];let[s,...r]=e.optionIds.flatMap(e=>t.options.filter(t=>{let{id:s}=t;return s===e})).map((e,t)=>({option_id:String(e.id),option_rank:t+1,free_text:e.free_text}));return s?[{question_index:e.questionIndex,selected_options:[s,...r]}]:[]}));i&&e("trackOnCompanionClarificationsSubmitted",{query_id:t.id,answers:[i,...o]}),(r||!i)&&e("trackOnCompanionClarificationsSkipped",{query_id:t.id})})(i,n,a)},V=async e=>{var t,n;if(C.current)return;let a=s.sections.find(t=>t.id===e);if(!a)return;if(C.current=!0,a.pendingClarificationMessage)return void U(a.id,a.userQuery,a.pendingClarificationMessage,null!=(t=a.clarificationAnswerPairs)?t:[],{silent:!a.isClarificationRoundTwo});z(),r(t=>({...t,sections:t.sections.map(t=>t.id===e?{...t,context:null,response:{content:"",status:"loading"},sources:{queryGroups:[],totalCount:0},chatStatus:"thinking",searchingRound:void 0,isBlocked:!1,isOffTopic:!1,isNoReliableSources:!1,isCancelled:!1}:t),isLoading:!0,error:void 0}));let i=g.J.getState().getFeatureFlag("enableScientificPublications"),o=e7.getState().scientificPublications,l={messages:[{role:"user",content:a.userQuery}],previous_response_id:null!=(n=p.current)?n:void 0,...q(),...i&&{search_parameters:{scientific_publications:o}}};b.current=a.userQuery.trim(),await P(e,l)},G=async t=>{var s;null==(s=u.current)||s.abort(),C.current=!1,z();let n=new AbortController;u.current={abort:()=>n.abort()};let i=Symbol("conversation-load");m.current=i,r({sections:[],isLoading:!1,error:void 0}),a(!0);try{let s,l=await (s=n.signal,O("/".concat(encodeURIComponent(t)),{method:"GET",signal:s}));if(m.current!==i)return;h.current=l.id,p.current=(e=>{let t=[...e.messages].filter(e=>"assistant"===e.role).sort((e,t)=>e.sequence-t.sequence);for(let e=t.length-1;e>=0;e-=1){let s=t[e].metadata.response_id;if(s)return s}return null})(l),x.current=!0,r({sections:(e=>{let t=[...e.messages].sort((e,t)=>e.sequence-t.sequence),s=[],r=null;for(let n=0;n<t.length;n+=1){let a=t[n];if("user"===a.role){if(r&&ry(r,a)){r=rw(r,a);continue}r&&s.push(r),r=rv(a);continue}if(!r)continue;let i=t[n+1];0===a.content.length&&i&&ry(r,i)||(s.push(rj(r,a,e.title)),r=null)}return r&&s.push(r),s})(l),isLoading:!1,error:void 0}),a(!1),o(e=>e+1),(e=>{if(!rC())return;let t=K.getState();t.conversations.some(t=>t.id===e.id)||t.upsertConversation({id:e.id,title:e.title,created_at:e.created_at,updated_at:new Date().toISOString(),message_count:e.messages.length})})(l),e("trackOnCompanionConversationReopened",{conversation_id:l.id}),u.current=null}catch(e){if(m.current!==i)return;r({sections:[],isLoading:!1,error:(e=>e instanceof A?e:new A("InternalServerError","Unexpected error"))(e)}),a(!1),u.current=null}};(0,d.useEffect)(()=>{c&&h.current!==c&&G(c)},[c]);let W=s.sections.length>0;return{conversationState:s,isLoadingConversation:n,loadedConversationNonce:i,sendMessage:H,setActiveTab:(e,t)=>{r(s=>({...s,sections:s.sections.map(s=>s.id===e?{...s,activeTab:t}:s)}))},stopGeneration:()=>{var e;null==(e=u.current)||e.abort(),u.current=null;let t=_.current;r(e=>({...e,sections:e.sections.map(e=>e.id===t?{...e,response:{...e.response,status:"complete"},chatStatus:"idle",isCancelled:!0}:e),isLoading:!1})),C.current=!1},resetConversation:()=>{var e;null==(e=u.current)||e.abort(),u.current=null,m.current=null,a(!1),K.getState().setA
1ctiveConversationId(null),z(),p.current=null,x.current=!1,h.current=null,C.current=!1,r({sections:[],isLoading:!1,error:void 0})},retrySearch:V,submitClarificationAnswers:(e,t)=>B(e,t,!1),skipClarification:(e,t)=>B(e,t,!0),loadConversation:G,hasConversation:W}})(),{status:a,data:i,update:o}=(0,c.useSession)(),{setUser:u,setAccessToken:m,clearUser:p}=v(),x="authenticated"===a,[h,f]=(0,d.useState)(!1),[b,j]=(0,d.useState)(!1),[y,w]=(0,d.useState)(!1),N=(0,g.J)(e=>e.getFeatureFlag("enableConversationHistory")),C=em(e=>e.isModalOpen),_=em(e=>e.closeModal),S=eo(e=>e.requestLeave),R=eo(e=>null!==e.pendingAction),I=n.conversationState.isLoading,{platform:L,isResolved:T}=sr(),F=si(e=>e.isHidden()),q=(0,g.J)(e=>e.isConfigLoaded),M=(0,g.J)(e=>e.isAppDownloadBannerDisabled()),z=!n.isLoadingConversation&&!n.hasConversation&&!n.conversationState.error,P=T&&q&&!M&&z&&!F?L:null,[H,U]=(0,d.useState)([]),B=K(e=>e.pendingDeletions),V=K(e=>e.restoreDeletion),G=K(e=>e.commitDeletion),W=K(e=>e.flushPendingDeletions);(0,d.useEffect)(()=>{let e=()=>W();return window.addEventListener("beforeunload",e),()=>window.removeEventListener("beforeunload",e)},[W]);let Q=(0,d.useCallback)(t=>{let s=Date.now().toString();U(r=>[...r,{id:s,content:e("auth.account-deleted"),onClick:()=>U(e=>e.filter(e=>e.id!==s)),duration:t}])},[e]);return(0,d.useEffect)(()=>(k(o),()=>k(null)),[o]),(0,d.useEffect)(()=>{if((null==i?void 0:i.error)&&["RefreshTokenExpiredError","RefreshAccessTokenError","SessionDeletedError"].includes(null==i?void 0:i.error)){console.warn("Session expired, clearing user"),(0,c.signOut)({redirect:!1}),p(),(null==i?void 0:i.error)==="SessionDeletedError"&&Q();return}if(x){var e;u(null!=(e=null==i?void 0:i.user)?e:{}),m(null==i?void 0:i.accessToken)}else p()},[x,i,u,m,p]),(0,d.useEffect)(()=>{x&&(window.dataLayer=window.dataLayer||[],window.dataLayer.push({event:"login"}))},[x]),(0,r.jsxs)("div",{className:"flex flex-col h-dvh w-screen bg-[#f8f9f9] p-2 sm:p-4 fixed",children:[(0,r.jsx)("h1",{className:"hidden",children:e("common.app-name")}),P&&(0,r.jsx)(sF,{platform:P}),(0,r.jsxs)("div",{className:"flex min-h-0 flex-1",children:[(0,r.jsx)("div",{className:"hidden md:contents",children:(0,r.jsx)(rp,{isAuthenticated:x,conversation:n,onOpenLegalNotice:()=>f(!0)})}),(0,r.jsxs)("main",{className:"relative flex flex-1 rounded-[12px] bg-white overflow-hidden boto-dp-0",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between absolute left-0 pl-3 sm:pl-4 top-3 right-0 pr-3 sm:pr-4 sm:top-4 z-20 pb-3 transition-all duration-200 pointer-events-none",children:[(0,r.jsx)("div",{className:"flex items-center justify-start pointer-events-auto md:hidden",children:(0,r.jsx)(s5,{onClick:()=>N?w(!0):j(!0)})}),(0,r.jsxs)("div",{className:"ml-auto flex items-center gap-2 pointer-events-auto",children:[x&&(0,r.jsx)(sY,{className:"md:hidden",onNewConversationClick:()=>S(()=>n.resetConversation(),I)}),!x&&(0,r.jsx)(sb,{}),(0,r.jsx)(ro,{separatorBefore:!x})]})]}),(0,r.jsx)(sx,{conversation:n,onOpenLegalNotice:()=>f(!0),scrollRef:t})]})]}),(0,r.jsx)("div",{className:"md:hidden",children:N?(0,r.jsx)(s3,{open:y,isAuthenticated:x,conversation:n,onOpenLegalNotice:()=>f(!0),onClose:()=>w(!1)}):(0,r.jsx)(s$,{open:b,isAuthenticated:x,onOpenLegalNotice:()=>f(!0),onClose:()=>j(!1)})}),h&&(0,r.jsx)(sT,{onClose:()=>f(!1)}),C&&(0,r.jsx)(sL,{onClose:_}),R&&(0,r.jsx)(sD,{isGenerating:I}),H.length>0&&(0,r.jsx)("div",{className:"fixed top-4 right-4 transform z-50",children:H.map(e=>(0,r.jsx)(s7,{id:e.id,content:e.content,onClick:e.onClick,duration:e.duration},e.id))}),B.length>0&&(0,r.jsx)("div",{"data-testid":"deletion-toasts",className:"fixed bottom-[92px] left-1/2 z-50 flex -translate-x-1/2 flex-col items-center gap-2 pointer-events-none md:top-4 md:right-4 md:bottom-auto md:left-auto md:translate-x-0 md:items-stretch",children:B.map(e=>(0,r.jsx)(s4,{id:e.toastId,title:e.title,onRestore:()=>V(e.toastId),onClose:()=>G(e.toastId)},e.toastId))})]})}},3122:()=>{},3160:()=>{},3741:()=>{},3998:(e,t,s)=>{"use strict";s.d(t,{$:()=>l});var r=s(5155);s(2115);var n=s(2467),a=s(3101),i=s(4269);let o=(0,a.F)("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium cursor-pointer transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",destructive:"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}});function l(e){let{className:t,variant:s,size:a,asChild:l=!1,...c}=e,d=l?n.DX:"button";return(0,r.jsx)(d,{"data-slot":"button",className:(0,i.cn)(o({variant:s,size:a,className:t})),...c})}},4356:(e,t,s)=>{Promise.resolve().then(s.bind(s,578))},7906:()=>{},8738:()=>{}},e=>{e.O(0,[709,268,489,189,239,994,669,441,255,358],()=>e(e.s=4356)),_N_E=e.O()}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.