import{c as h,ap as b,r as i,j as e,L as g,aq as f,a2 as j,U as k,e as o,D as N,M as v,N as w,g as y}from"./index-DANBBpG0.js";import{B as S}from"./book-open-DNVRFqUG.js";import{C as z}from"./circle-x-YNgYnAPU.js";/** * @license lucide-react v0.460.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const u=h("CircleDot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]),D={selbst:{icon:k,cls:"text-emerald-300 bg-emerald-500/10 border-emerald-500/30",erklaerung:"Diese Skills hat sich die Box selbst geschrieben — niemand hat sie ihr installiert."},repo:{icon:j,cls:"text-primary bg-primary/10 border-primary/25",erklaerung:"Von uns gebaut und über das Repo installiert (deploy/skills)."},bundled:{icon:f,cls:"text-muted-foreground bg-background/40 border-border/50",erklaerung:"Kamen mit Hermes mit — Standard-Ausstattung."}},C={disabled:"abgeschaltet",deprecated:"veraltet",broken:"defekt",error:"Fehler"};function B(t){if(!t)return"—";const n=new Date(t);return isNaN(n.getTime())?"—":n.toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit",year:"2-digit"})}function T(){const{data:t,isLoading:n}=b(),d=i.useMemo(()=>{const s=[];for(const r of(t==null?void 0:t.skills)??[]){const a=s[s.length-1];a&&a.herkunft===r.herkunft?a.skills.push(r):s.push({herkunft:r.herkunft,label:r.herkunft_label,skills:[r]})}return s},[t]);return e.jsxs("div",{className:"space-y-7",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"bg-gradient-to-r from-foreground via-foreground to-primary bg-clip-text font-space text-2xl font-bold tracking-tight text-transparent",children:"Skills"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Die Fähigkeiten deiner Box — mit Herkunft, Nutzung und ob der Agent sie gerade laden kann (aktiv/inaktiv). Das ist derselbe Skill-Satz, mit dem Lucy spricht und die Nacht-Worker arbeiten. Darunter: was aus den Vorschlägen der Box wurde."})]}),n&&e.jsxs("div",{className:"flex items-center gap-2 rounded-2xl border border-border/60 bg-card/30 p-6 text-xs text-muted-foreground",children:[e.jsx(g,{className:"h-4 w-4 animate-spin"})," Wird geladen …"]}),t&&!t.available&&e.jsx("div",{className:"rounded-2xl border border-amber-500/30 bg-amber-500/5 p-4 text-xs text-amber-300",children:"Die Skills liegen auf der Box (~/.hermes/skills) — im lokalen Dev-Modus nicht verfügbar."}),(t==null?void 0:t.available)&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-4",children:[e.jsx(c,{label:"Skills gesamt",wert:t.skills.length}),e.jsx(c,{label:"davon selbst erstellt",wert:t.selbst_erstellt,betone:!0}),e.jsx(c,{label:"Vorschläge angenommen",wert:t.bilanz.angenommen}),e.jsx(c,{label:"Vorschläge abgelehnt",wert:t.bilanz.abgelehnt})]}),d.map(s=>{const r=D[s.herkunft],a=r.icon;return e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsxs("p",{className:o("inline-flex items-center gap-1.5 rounded-md border px-2 py-1 text-[11px] font-bold",r.cls),children:[e.jsx(a,{className:"h-3.5 w-3.5"})," ",s.label," · ",s.skills.length]}),e.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground/70",children:r.erklaerung})]}),e.jsx("div",{className:"grid gap-2 md:grid-cols-2",children:s.skills.map(l=>e.jsx(L,{skill:l},l.id))})]},s.herkunft)}),e.jsx(A,{eintraege:t.bilanz.eintraege})]})]})}function c({label:t,wert:n,betone:d}){return e.jsxs("div",{className:o("rounded-xl border p-3",d?"border-emerald-500/30 bg-emerald-500/5":"border-border/50 bg-card/40"),children:[e.jsx("p",{className:o("font-space text-xl font-bold",d?"text-emerald-300":"text-foreground"),children:n}),e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wide text-muted-foreground/70",children:t})]})}function L({skill:t}){const[n,d]=i.useState(!1),[s,r]=i.useState(null),[a,l]=i.useState(!1);async function x(){const m=!n;if(d(m),m&&s===null&&!a){l(!0);try{const p=await y(`/api/eigenleben/skill/${encodeURIComponent(t.id)}`);r(p.text)}catch{r("(Konnte den Skill-Text nicht laden.)")}finally{l(!1)}}}return e.jsxs("div",{className:"rounded-xl border border-border/50 bg-card/40 p-3 backdrop-blur-sm",children:[e.jsxs("button",{onClick:x,className:"flex w-full items-start gap-2 text-left cursor-pointer",children:[n?e.jsx(N,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground"}):e.jsx(v,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-sm font-semibold text-foreground",children:t.name}),t.aktiv===!0&&e.jsxs("span",{className:"flex items-center gap-1 rounded bg-emerald-500/10 px-1.5 py-0.5 text-[9px] font-bold text-emerald-300",title:"Der Agent kann diesen Skill laden und nutzen.",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-400"})," aktiv"]}),t.aktiv===!1&&e.jsxs("span",{className:"flex items-center gap-1 rounded bg-zinc-500/10 px-1.5 py-0.5 text-[9px] font-bold text-zinc-400",title:"Der Agent kann diesen Skill gerade NICHT laden — Plattform passt nicht (z. B. Apple-Skills auf Linux), Voraussetzungen fehlen oder per Config abgeschaltet.",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-zinc-500"})," inaktiv"]}),t.kategorie&&e.jsx("span",{className:"rounded bg-background/60 px-1.5 py-0.5 text-[9px] font-semibold text-muted-foreground/80",children:t.kategorie}),t.genutzt>0&&e.jsxs("span",{className:"rounded bg-primary/10 px-1.5 py-0.5 text-[9px] font-bold text-primary",title:`zuletzt: ${B(t.zuletzt_genutzt)}`,children:[t.genutzt,"× genutzt"]}),t.status!=="active"&&e.jsx("span",{className:"rounded bg-amber-500/10 px-1.5 py-0.5 text-[9px] font-bold text-amber-300",children:C[t.status]??t.status})]}),e.jsx("p",{className:o("mt-1 text-xs leading-relaxed text-foreground/75",!n&&"line-clamp-2"),children:t.beschreibung||"(keine Beschreibung im Skill hinterlegt)"})]})]}),n&&e.jsxs("div",{className:"mt-2 border-t border-border/40 pt-2",children:[e.jsxs("p",{className:"mb-1.5 flex items-center gap-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground/60",children:[e.jsx(S,{className:"h-3 w-3"})," So funktioniert er (SKILL.md)",t.autor?` · Autor: ${t.autor}`:""]}),a?e.jsx(g,{className:"h-4 w-4 animate-spin text-muted-foreground"}):e.jsx("pre",{className:"max-h-80 overflow-y-auto whitespace-pre-wrap rounded-lg bg-background/50 p-2.5 font-mono text-[10.5px] leading-relaxed text-foreground/80 scrollbar-thin",children:s??""})]})]})}function A({eintraege:t}){const[n,d]=i.useState(!1),s=n?t:t.slice(0,12);return e.jsxs("section",{className:"space-y-3",children:[e.jsxs("p",{className:"flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wider text-muted-foreground/60",children:[e.jsx(u,{className:"h-3.5 w-3.5"})," Vorschlags-Bilanz — was die Box vorschlug und was daraus wurde"]}),t.length===0&&e.jsx("div",{className:"rounded-2xl border border-dashed border-border/60 bg-card/20 p-6 text-center text-xs text-muted-foreground",children:"Noch keine Vorschläge verbucht. Sobald die Box etwas vorschlägt und du klickst, steht die Entscheidung hier."}),e.jsx("div",{className:"space-y-2",children:s.map((r,a)=>{const l=r.art==="angenommen",x=l?w:r.art==="abgelehnt"?z:u;return e.jsxs("div",{className:"flex items-start gap-2.5 rounded-xl border border-border/50 bg-card/40 p-3",children:[e.jsx(x,{className:o("mt-0.5 h-4 w-4 shrink-0",l?"text-emerald-400":r.art==="abgelehnt"?"text-red-400":"text-amber-300")}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"font-mono text-xs font-semibold text-foreground",children:r.titel}),e.jsx("span",{className:o("rounded px-1.5 py-0.5 text-[9px] font-bold uppercase",l?"bg-emerald-500/10 text-emerald-300":r.art==="abgelehnt"?"bg-red-500/10 text-red-300":"bg-amber-500/10 text-amber-300"),children:r.art}),e.jsx("span",{className:"ml-auto font-mono text-[10px] text-muted-foreground/60",children:r.ts?new Date(r.ts*1e3).toLocaleDateString("de-DE",{day:"2-digit",month:"2-digit"}):""})]}),r.detail&&e.jsx("p",{className:"mt-1 text-xs leading-relaxed text-foreground/70",children:r.detail})]})]},`${r.titel}-${r.ts}-${a}`)})}),!n&&t.length>12&&e.jsxs("button",{onClick:()=>d(!0),className:"text-[11px] text-muted-foreground underline hover:text-foreground cursor-pointer",children:["Alle ",t.length," Einträge anzeigen"]})]})}export{T as EigenlebenView};