1import{d as E,r as i,j as e,w as C,ey as N,B as y,O as v,aP as H,x as A,y as k,z as w,C as D,F as b,G as I,H as T,eB as M,s as o,a9 as S,dV as P,h8 as F,h9 as U,al as W}from"./index-B3NVYGCC.js";import{S as u}from"./SupportModeContext-BKbjDrpg.js";import{b as z,c as G,C as L}from"./ChatWindow-dmNSTV6-.js";import{P as p}from"./PortalLayout-t8GviEb-.js";import"./collapsible-CkRLSYGw.js";import"./index-D58zaZou.js";import"./EventDialog-DFErBGZe.js";import"./calendar-CzVz0sie.js";import"./isAfter-pflE20E5.js";import"./useClientPackages-DAHCs-P1.js";import"./useTechnicians-C38mJhkm.js";import"./useTeams-gOd9-Vzm.js";import"./usePortalBranding-CVcrVZq7.js";import"./useCompanySettings-DGH-Dn__.js";import"./alert-DT_1DSKX.js";function V({onRequestTransfer:t,isLoading:a,className:d,variant:x="default"}){const{t:s}=E("messages"),[c,l]=i.useState(!1),r=async()=>{await t(),l(!1)};return x==="compact"?e.jsxs(C,{open:c,onOpenChange:l,children:[e.jsx(N,{asChild:!0,children:e.jsxs(y,{variant:"ghost",size:"sm",className:v("gap-1.5 text-xs text-muted-foreground hover:text-foreground",d),children:[e.jsx(H,{className:"h-3.5 w-3.5"}),s("talk_human_compact")]})}),e.jsxs(A,{children:[e.jsxs(k,{children:[e.jsx(w,{children:s("talk_human_title_compact")}),e.jsx(D,{children:s("talk_human_desc_compact")})]}),e.jsxs(b,{children:[e.jsx(I,{children:s("talk_human_stay_ai")}),e.jsx(T,{onClick:r,disabled:a,children:s(a?"talk_human_in_progress":"talk_human_confirm")})]})]})]}):e.jsxs(C,{open:c,onOpenChange:l,children:[e.jsx(N,{asChild:!0,children:e.jsxs(y,{variant:"outline",className:v("gap-2",d),children:[e.jsx(M,{className:"h-4 w-4"}),s("talk_human_button")]})}),e.jsxs(A,{children:[e.jsxs(k,{children:[e.jsx(w,{children:s("talk_human_title")}),e.jsx(D,{children:s("talk_human_desc")})]}),e.jsxs(b,{children:[e.jsx(I,{children:s("talk_human_cancel")}),e.jsx(T,{onClick:r,disabled:a,children:s(a?"talk_human_in_progress":"talk_human_confirm")})]})]})]})}function ce(){const{t}=E("messages"),[a,d]=i.useState(null),[x,s]=i.useState(!0),[c,l]=i.useState(!1),{aiConfig:r,isAIEnabled:m,isAITyping:B,sendToAI:j,requestHumanTransfer:O}=z({clientId:(a==null?void 0:a.id)??null,companyId:(a==null?void 0:a.company_id)??null}),R=i.useCallback((f,h)=>{h!=="text"||!m||j(f).catch(n=>{console.error("Réponse de l'assistant IA indisponible:",n)})},[m,j]);if(i.useEffect(()=>{(async()=>{const{data:{user:n}}=await o.auth.getUser();if(!n)return;const{data:_}=await o.from("client_portal_access").select("client_id").eq("user_id",n.id).eq("is_active",!0).maybeSingle();if(_){const{data:g}=await o.from("clients").select("*").eq("id",_.client_id).single();g&&d(g)}s(!1)})();const h=o.channel("realtime-status-portal");return h.subscribe(n=>{n==="SUBSCRIBED"?l(!0):(n==="CHANNEL_ERROR"||n==="TIMED_OUT"||n==="CLOSED")&&l(!1)}),()=>{o.removeChannel(h)}},[]),x)return e.jsx(u,{children:e.jsx(p,{children:e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsx("p",{className:"text-muted-foreground",children:t("chat_loading")})})})});if(!a)return e.jsx(u,{children:e.jsx(p,{children:e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsx("p",{className:"text-muted-foreground",children:t("portal_load_error")})})})});const q=async()=>{await O("Demande du client via le portail")};return e.jsx(u,{children:e.jsx(p,{children:e.jsxs("div",{className:"max-w-6xl mx-auto space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-3xl font-bold",children:t("title")}),m&&r&&e.jsxs(S,{variant:"secondary",className:"gap-1.5 bg-primary/10 text-primary",children:[e.jsx(P,{className:"h-3.5 w-3.5"}),r.agent_name||t("ai_assistant_default")]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[m&&e.jsx(V,{onRequestTransfer:q,variant:"compact"}),e.jsx(S,{variant:c?"default":"secondary",className:"gap-2",children:c?e.jsxs(e.Fragment,{children:[e.jsx(F,{className:"h-3 w-3"}),e.jsx("span",{children:t("portal_connected")})]}):e.jsxs(e.Fragment,{children:[e.jsx(U,{className:"h-3 w-3"}),e.jsx("span",{children:t("portal_disconnected")})]})})]})]}),B&&e.jsx(G,{agentName:r==null?void 0:r.agent_name}),e.jsx(W,{className:"h-[calc(100vh-400px)] min-h-[600px] overflow-hidden",children:e.jsx(L,{clientId:a.id,clientName:t("portal_company_default"),onMessageSent:R})})]})})})}export{ce as default};
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.