1import{k as o,l,m as n,j as e,H as S,o as C,a as s,b as L,r as h,g as j,t as d,L as K}from"./index-CnqIWqrO.js";import{S as T}from"./SubscriptionGate-NM8oqx_x.js";import{A as R}from"./arrow-left-BkgOf1Yh.js";import{L as q}from"./link-B71tin_I.js";import{F as A}from"./file-text-DTGRXQ5a.js";import{c as P}from"./createLucideIcon-CuyseJxD.js";import{T as F}from"./trash-2-DwjoGnnF.js";import"./useSubscription-DjQtXTs0.js";import"./sparkles-CiB5pjXW.js";const M=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],Q=P("refresh-cw",M),U=o({method:"GET"}).middleware([l]).handler(n("75e30ddeb83c547ac9f6d4d74a238f9555a46f1434907ca4a2d28ea468c66859")),_=o({method:"POST"}).middleware([l]).handler(n("efcbd0fac9e76fc937e59d21605d486ae92ba531405c55ca82cb07800943ba44")),E=o({method:"POST"}).middleware([l]).handler(n("c276e1100ec19f9168f7ab60bbc4a36849df280c2f2b25491ee53ab3835f030e")),I=o({method:"POST"}).middleware([l]).handler(n("9cbcfb744ef0f7866bea4d01df68c0234ec86b65668babc3c6680d3f928289a6")),O=o({method:"POST"}).middleware([l]).handler(n("9f5e7533a784c89a8d726ff2bd4f90933d2ed96ac35bdfedb6953f2c335111c9"));function B(){const{siteId:t}=S.useParams(),c=C(),N=s(U),y=s(_),v=s(E),w=s(I),k=s(O),{data:u=[]}=L({queryKey:["kb",t],queryFn:()=>N({data:{siteId:t}})}),[m,p]=h.useState(""),[a,i]=h.useState(""),[x,f]=h.useState(""),b=j({mutationFn:()=>y({data:{siteId:t,url:m,label:a||void 0}}),onSuccess:()=>{d.success("URL scrapée et ajoutée."),p(""),i(""),c.invalidateQueries({queryKey:["kb",t]})},onError:r=>d.error(r.message)}),g=j({mutationFn:()=>v({data:{siteId:t,label:a,text:x}}),onSuccess:()=>{d.success("Contenu ajouté."),i(""),f(""),c.invalidateQueries({queryKey:["kb",t]})},onError:r=>d.error(r.message)});return e.jsxs("main",{className:"mx-auto max-w-4xl px-6 py-10",children:[e.jsxs(K,{to:"/sites/$siteId/journal",params:{siteId:t},className:"inline-flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground",children:[e.jsx(R,{className:"h-4 w-4"})," Retour au journal"]}),e.jsx("h1",{className:"text-display mt-4 text-4xl",children:"Knowledge Base"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Alimente l'IA avec des sources qui guideront la rédaction des articles."}),e.jsxs("section",{className:"mt-8 grid gap-6 md:grid-cols-2",children:[e.jsxs("div",{className:"rounded-2xl border border-border bg-card p-6",children:[e.jsxs("h2",{className:"flex items-center gap-2 text-lg font-medium",children:[e.jsx(q,{className:"h-4 w-4"})," Ajouter une URL"]}),e.jsx("input",{value:m,onChange:r=>p(r.target.value),placeholder:"https://exemple.com/article",className:"mt-3 w-full rounded-xl border border-border bg-background p-3 text-sm"}),e.jsx("input",{value:a,onChange:r=>i(r.target.value),placeholder:"Libellé (optionnel)",className:"mt-2 w-full rounded-xl border border-border bg-background p-3 text-sm"}),e.jsx("button",{disabled:!m||b.isPending,onClick:()=>b.mutate(),className:"mt-3 w-full rounded-full bg-primary px-4 py-2 text-sm text-primary-foreground disabled:opacity-50",children:b.isPending?"Scrapingâ¦":"Scraper et ajouter"})]}),e.jsxs("div",{className:"rounded-2xl border border-border bg-card p-6",children:[e.jsxs("h2",{className:"flex items-center gap-2 text-lg font-medium",children:[e.jsx(A,{className:"h-4 w-4"})," Coller du texte"]}),e.jsx("input",{value:a,onChange:r=>i(r.target.value),placeholder:"Titre du document",className:"mt-3 w-full rounded-xl border border-border bg-background p-3 text-sm"}),e.jsx("textarea",{value:x,onChange:r=>f(r.target.value),rows:5,placeholder:"Contenu (markdown ou texte brut)â¦",className:"mt-2 w-full rounded-xl border border-border bg-background p-3 text-sm"}),e.jsx("button",{disabled:!a||x.length<20||g.isPending,onClick:()=>g.mutate(),className:"mt-3 w-full rounded-full bg-primary px-4 py-2 text-sm text-primary-foreground disabled:opacity-50",children:"Ajouter"})]})]}),e.jsxs("section",{className:"mt-10",children:[e.jsxs("h2",{className:"text-lg font-medium",children:["Sources (",u.length,")"]}),e.jsxs("ul",{className:"mt-4 space-y-2",children:[u.map(r=>e.jsxs("li",{className:"flex items-center justify-between rounded-xl border border-border bg-card p-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{className:"chip",children:r.kind}),r.last_refreshed_at&&e.jsxs("span",{children:["· refresh ",new Date(r.last_refreshed_at).toLocaleDateString("fr-FR")]})]}),e.jsx("p",{className:"mt-1 truncate text-sm",children:r.label}),r.url&&e.jsx("p",{className:"truncate text-xs text-muted-foreground",children:r.url})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[r.kind==="url"&&e.jsx("button",{onClick:async()=>{await w({data:{id:r.id}}),d.success("Re-scrapé."),c.invalidateQueries({queryKey:["kb",t]})},className:"rounded-full p-2 text-muted-foreground hover:bg-secondary",title:"Re-scraper",children:e.jsx(Q,{className:"h-4 w-4"})}),e.jsx("button",{onClick:async()=>{confirm("Supprimer ?")&&(await k({data:{id:r.id}}),c.invalidateQueries({queryKey:["kb",t]}))},className:"rounded-full p-2 text-muted-foreground hover:bg-secondary",children:e.jsx(F,{className:"h-4 w-4"})})]})]},r.id)),u.length===0&&e.jsx("li",{className:"rounded-2xl border border-dashed border-border p-10 text-center text-sm text-muted-foreground",children:"Aucune source. Ajoute une URL ou colle un document."})]})]})]})}const Y=()=>e.jsx(T,{feature:"Knowledge Base",children:e.jsx(B,{})});
1export{Y 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.