1import{r as n,j as s}from"./vendor-three-BGGFfWe7.js";import{a as k,e as O,b as B,bx as E,as as P,cI as v,bq as R,bf as T,dM as $,aT as z,aM as D,aK as U}from"./index-zO3nSPIa.js";import{a as _,O as F}from"./HumanLivingRuntime-BMs2WQvV.js";import{d as V,c as q,u as J,a as K,L as W}from"./RemoteHumanInterpolation-ymIhcSxY.js";import"./minimize-2-Dxb4C87o.js";import"./maximize-2-BtQSNMu7.js";import"./navigation-DwkHdB6y.js";import"./hand-BZ37xoV_.js";import"./package-check-GVuODVMf.js";import"./user-round-check-BigIIWNZ.js";function ie(){const c=k(),I=n.useCallback(e=>c(e==="office"?"/office":e==="dev"?"/dev/living":"/living"),[c]),{user:i}=O(),[d,b]=n.useState(null),[m,u]=n.useState(null),[A,g]=n.useState([]),[x,f]=n.useState(""),[j,L]=n.useState({installations:[],audits:[]}),p=n.useCallback(async()=>{const e=await B.functions.invoke("livingOperationalSignals",{limit:100}).catch(()=>null),t=(e==null?void 0:e.data)||e||{};L({installations:t.installations||[],audits:t.audits||[]})},[]);n.useEffect(()=>{p();const e=window.setInterval(p,15e3);return()=>window.clearInterval(e)},[p]);const N=n.useMemo(()=>V(j),[j]),l=n.useMemo(()=>q({activityByAgentId:N,layer:"legal"}),[N]),r=n.useMemo(()=>_(i,{layer:"legal"}),[i]),{remoteActors:C,publishPosition:M}=J(i,{layer:"legal"}),w=K(C),h=n.useMemo(()=>[...r?[r]:[],...w,...l.agents],[r,w,l]),y=n.useMemo(()=>h.find(e=>e.actorType==="human"&&e.id===m)||null,[h,m]),a=n.useMemo(()=>l.agents.find(e=>e.id===d)||null,[l,d]),o=E({enabled:!!(a&&i),user:i,module:"Living",agentName:(a==null?void 0:a.agentName)||"beatriz",contextId:a?`living:${a.id}`:null}),H=async e=>{e.preventDefault();const t=x.trim();if(!(!t||o.loading)){f("");try{await o.send(t,{surface:"living",selected_agent_id:a==null?void 0:a.id})}catch{f(t)}}};return s.jsxs("main",{className:"space-y-4 p-3 sm:p-5","data-surface":"living",children:[s.jsxs("header",{className:"flex flex-wrap items-center justify-between gap-3 rounded-2xl border bg-card p-4",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(P,{className:"h-5 w-5"}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-lg font-semibold",children:"Living dos Agentes IA"}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Espaço imersivo dos agentes, conectado à atividade operacional real."})]})]}),s.jsx("div",{className:"flex flex-wrap gap-2",children:s.jsxs(v,{type:"button",variant:"outline",onClick:()=>c("/dashboard"),children:[s.jsx(R,{className:"mr-2 h-4 w-4"}),"Voltar ao portal"]})})]}),s.jsxs("section",{className:"overflow-hidden rounded-2xl border bg-card p-3",children:[s.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[s.jsx(T,{className:"h-4 w-4"}),l.agents.map(e=>s.jsxs($,{variant:e.status==="working"?"default":e.status==="error"?"destructive":"outline",children:[e.name,": ",e.status==="working"?"TRABALHANDO":e.status==="error"?"ERRO":"DISPONÃVEL"]},e.id))]}),s.jsxs("div",{className:"grid gap-3 lg:grid-cols-[minmax(0,1fr)_360px]",children:[s.jsx(F,{layer:"legal",agents:h,onLayerChange:I,onHumanPositionChange:M,onMedia:(e,t)=>{var S;e==="share"&&((S=t==null?void 0:t.target)!=null&&S.id)&&(u(t.target.id),g(t.items||[]))},selectedAgentId:d||m,onSelectAgent:e=>{String(e).startsWith("human:")?e!==(r==null?void 0:r.id)&&u(e):b(e)}}),a&&s.jsxs("aside",{className:"flex min-h-[360px] flex-col overflow-hidden rounded-xl border bg-background","aria-label":`Painel de ${a.name}`,children:[s.jsxs("div",{className:"flex items-start justify-between gap-3 border-b p-3",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(z,{className:"h-4 w-4"}),s.jsx("strong",{children:a.name})]}),s.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:a.subtitle})]}),s.jsx(v,{type:"button",size:"icon",variant:"ghost","aria-label":"Fechar painel",onClick:()=>b(null),children:s.jsx(D,{className:"h-4 w-4"})})]}),s.jsxs("div",{className:"flex-1 space-y-2 overflow-y-auto p-3",children:[!o.messages.length&&s.jsx("p",{className:"rounded-lg bg-muted p-3 text-sm text-muted-foreground",children:"Converse diretamente com este agente. A conversa usa o runtime real do Base44."}),o.messages.map((e,t)=>s.jsx("div",{className:`max-w-[90%] rounded-xl px-3 py-2 text-sm ${e.role==="user"?"ml-auto bg-primary text-primary-foreground":"bg-muted"}`,children:typeof e.content=="string"?e.content:JSON.stringify(e.content)},e.id||t))]}),s.jsxs("form",{className:"flex gap-2 border-t p-3",onSubmit:H,children:[s.jsx("input",{value:x,onChange:e=>f(e.target.value),placeholder:`Falar com ${a.name}â¦`,className:"min-w-0 flex-1 rounded-lg border bg-background px-3 py-2 text-sm outline-none focus:ring-2 focus:ring-ring","aria-label":`Mensagem para ${a.name}`}),s.jsx(v,{type:"submit",size:"icon",disabled:!x.trim()||o.loading,"aria-label":"Enviar mensagem",children:s.jsx(U,{className:"h-4 w-4"})})]})]})]})]}),y&&s.jsx(W,{currentUser:i,peer:y,sharedItems:A,onSharedItemsConsumed:()=>g([]),onClose:()=>{u(null),g([])}})]})}export{ie 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.