PageSourceSearch

https://leonydas.ai/assets/app.dashboard.ai-assistant-DToo0L6N.js

js leonydas.ai collected 2026-10-05 14:53:56 UTC 4,394 bytes, 1 lines download raw bytes

1import{a2 as v,a3 as y,a4 as b,r as i,s as N,j as e,C as w,t as S}from"./index-pTF10v3b.js";import{u as C}from"./useServerFn-BBwoKgJP.js";import{u as I}from"./use-company-CrmoXTdj.js";import{B as E}from"./button-BdNloxPj.js";import{I as k}from"./input-Bpai2mtc.js";import{S as f}from"./sparkles-Ch4VYJzh.js";import{M as A}from"./index-Ck-QZOVE.js";import{U as M}from"./user-DFZDH97i.js";import{S as R}from"./send-BfTOJ38k.js";import"./index-DexvSvjY.js";import"./index-C8y9Pifk.js";import"./index-wAw2rTQC.js";import"./createLucideIcon-BFnnMaHU.js";const q=v({method:"POST"}).middleware([y]).handler(b("752f65877434fcdd6e45f891c73843f5fd88857a1a68bc0b33a7fec45033e747")),z=["Quali sono le 3 priorità di questa settimana?","Genera una mail per il mio tecnico IT","Quali documenti devo creare per primi?","Spiegami il rischio DMARC in parole semplici","Prepara un piano cyber per i prossimi 30 giorni"];function H(){const{loading:c,companyId:n}=I(),j=C(q),[d,l]=i.useState([]),[m,p]=i.useState(""),[o,u]=i.useState(!1),x=i.useRef(null);i.useEffect(()=>{if(!n)return;let s=!1;return(async()=>{const{data:t}=await N.from("ai_conversations").select("prompt, response").eq("company_id",n).order("created_at",{ascending:!0}).limit(20);if(s)return;const r=[];(t??[]).forEach(a=>{r.push({role:"user",content:a.prompt}),r.push({role:"assistant",content:a.response})}),l(r)})(),()=>{s=!0}},[n]),i.useEffect(()=>{x.current?.scrollIntoView({behavior:"smooth"})},[d]);const h=async s=>{const t=(s??m).trim();if(!(!t||!n||o)){p(""),u(!0),l(r=>[...r,{role:"user",content:t}]);try{const r=await j({data:{prompt:t,companyId:n}});l(a=>[...a,{role:"assistant",content:r.response}])}catch(r){S.error(r instanceof Error?r.message:"Errore AI"),l(a=>[...a,{role:"assistant",content:"Mi dispiace, c'è stato un errore. Riprova."}])}finally{u(!1)}}};return c?e.jsx(g,{children:e.jsx("div",{className:"text-muted-foreground",children:"Caricamento…"})}):e.jsxs(g,{children:[e.jsxs("div",{className:"mb-6 flex items-center gap-3",children:[e.jsx("div",{className:"grid place-items-center w-12 h-12 rounded-xl bg-primary text-primary-foreground",children:e.jsx(f,{className:"w-6 h-6"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-semibold tracking-tight",children:"Cyber Manager AI"}),e.jsx("p",{className:"text-muted-foreground mt-0.5",children:"Spiegazioni, email pronte e piani operativi contestualizzati alla tua azienda."})]})]}),e.jsxs(w,{className:"shadow-card flex flex-col h-[65vh]",children:[e.jsxs("div",{className:"flex-1 overflow-y-auto p-6 space-y-4",children:[d.length===0&&e.jsx("div",{className:"text-center text-muted-foreground text-sm mt-8",children:"Inizia chiedendo qualcosa o scegli un suggerimento qui sotto."}),d.map((s,t)=>e.jsxs("div",{className:`flex gap-3 ${s.role==="user"?"justify-end":""}`,children:[s.role==="assistant"&&e.jsx("div",{className:"w-8 h-8 rounded-full bg-primary/10 grid place-items-center shrink-0",children:e.jsx(f,{className:"w-4 h-4 text-primary"})}),e.jsx("div",{className:`max-w-[80%] rounded-2xl px-4 py-2.5 text-sm ${s.role==="user"?"bg-primary text-primary-foreground whitespace-pre-wrap":"bg-muted"}`,children:s.role==="assistant"?e.jsx("div",{className:"prose prose-sm max-w-none dark:prose-invert text-sm leading-relaxed [&>p]:my-1.5 [&>ul]:my-1.5 [&>ol]:my-1.5 [&>h1]:text-base [&>h2]:text-sm [&>h3]:text-sm [&>strong]:text-foreground",children:e.jsx(A,{children:s.content})}):s.content}),s.role==="user"&&e.jsx("div",{className:"w-8 h-8 rounded-full bg-muted grid place-items-center shrink-0",children:e.jsx(M,{className:"w-4 h-4"})})]},t)),o&&e.jsx("div",{className:"text-xs text-muted-foreground pl-11",children:"L'AI sta scrivendo…"}),e.jsx("div",{ref:x})]}),e.jsx("div",{className:"p-3 border-t flex flex-wrap gap-1.5",children:z.map(s=>e.jsx("button",{onClick:()=>h(s),disabled:o,className:"px-3 py-1.5 rounded-full text-xs bg-card border hover:border-primary/40 transition disabled:opacity-50",children:s},s))}),e.jsxs("form",{onSubmit:s=>{s.preventDefault(),h()},className:"p-3 border-t flex gap-2",children:[e.jsx(k,{value:m,onChange:s=>p(s.target.value),placeholder:"Scrivi una domanda…",disabled:o}),e.jsx(E,{type:"submit",disabled:o||!m.trim(),children:e.jsx(R,{className:"w-4 h-4"})})]})]})]})}function g({children:c}){return e.jsx("div",{className:"p-4 sm:p-6 lg:p-10 max-w-7xl mx-auto",children:c})}export{H as component};

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.