import{az as f,an as g,j as e,ap as v,Q as y,af as x,L as m,B as u,ar as n}from"./index-Dbk1Plmn.js";import{b as _,a as N,c as P}from"./use_peers-N5QIk_vW.js";import{P as p}from"./page_shell-C0CL85dt.js";import{C,a as w,b,c as R}from"./card-CfjWPSFY.js";import{s as k,a as S}from"./query_loading-BFETHugg.js";import{Q as I}from"./query_refresh_indicator-1_XqkpX1.js";import{C as M}from"./copy_id_button-GijI9po3.js";import"./check-C3ZzJelL.js";function $(){var o,l;const h=f(),{peerId:c}=g(),a=c?decodeURIComponent(c):"",r=_(a||void 0),d=N(),i=P(),s=(o=r.data)==null?void 0:o.peer;return a?e.jsx(p,{title:(s==null?void 0:s.peer_name)??"Peer",description:e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(m,{to:"/peers",className:"text-primary hover:underline",children:"← All peers"}),S(r)?e.jsx(I,{}):null]}),actions:s!=null&&s.active?e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(u,{variant:"outline",size:"sm",disabled:i.isPending,onClick:()=>i.mutate(a,{onSuccess:t=>{const j=t.message??"Sync acknowledged";n.success(j)},onError:t=>n.error(t.message)}),children:i.isPending?"Syncing…":"Manual sync"}),e.jsx(u,{variant:"destructive",size:"sm",disabled:d.isPending,onClick:()=>{window.confirm(`Remove peer ${s.peer_name}?`)&&d.mutate(a,{onSuccess:()=>{n.success("Peer removed"),h("/peers")},onError:t=>n.error(t.message)})},children:"Remove peer"})]}):void 0,children:k(r)?e.jsx(v,{}):r.error?e.jsx(y,{title:"Could not load peer",children:r.error.message}):s?e.jsxs("div",{className:"space-y-4",children:[e.jsxs(C,{children:[e.jsx(w,{children:e.jsxs(b,{className:"text-base flex flex-wrap items-center gap-2",children:["Configuration",e.jsx(x,{variant:s.active?"default":"destructive",children:s.active?"active":"inactive"}),e.jsx(x,{variant:"secondary",children:s.direction})]})}),e.jsxs(R,{className:"space-y-3 text-sm",children:[e.jsxs("div",{className:"flex flex-wrap gap-2 items-center",children:[e.jsx("span",{className:"text-muted-foreground",children:"peer_id"}),e.jsx("code",{className:"text-xs bg-muted px-1.5 py-0.5 rounded",children:s.peer_id}),e.jsx(M,{id:s.peer_id})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"entity_id"})," ",e.jsx(m,{className:"font-mono text-xs text-primary hover:underline",to:`/entities/${encodeURIComponent(s.entity_id)}`,children:s.entity_id})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"URL"}),e.jsx("p",{className:"font-mono text-xs break-all mt-1",children:s.peer_url})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Entity types"}),e.jsx("p",{className:"mt-1",children:((l=s.entity_types)==null?void 0:l.join(", "))||"—"})]}),e.jsxs("div",{className:"flex flex-wrap gap-4",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"sync_scope"}),e.jsx("p",{children:s.sync_scope})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"auth_method"}),e.jsx("p",{children:s.auth_method})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"conflict_strategy"}),e.jsx("p",{children:s.conflict_strategy})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-4 text-muted-foreground",children:[e.jsxs("span",{children:["last_sync_at: ",s.last_sync_at??"—"]}),e.jsxs("span",{children:["consecutive_failures: ",s.consecutive_failures??0]})]})]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Full batch ",e.jsx("code",{children:"sync_peer"})," and ",e.jsx("code",{children:"resolve_sync_conflict"})," may remain stubs; use"," ",e.jsx("code",{children:"correct"})," for manual conflict repair when needed."]})]}):e.jsx("p",{className:"text-muted-foreground",children:"Peer not found."})}):e.jsx(p,{title:"Peer",children:e.jsx("p",{className:"text-muted-foreground",children:"Missing peer id."})})}export{$ as default};
