import{A as e,D as t,E as n,H as r,I as i,J as a,K as o,M as s,O as c,T as l,V as u,X as d,Y as f,at as p,d as m,et as h,k as g,lt as _,ot as v,ut as y,w as b,x}from"../chunks/DyGQ_VXC.js";import"../chunks/CQCxd1p9.js";import{a as S,r as C}from"../chunks/CEqOYim7.js";import"../chunks/CqF5Lomf.js";var w=e(`<meta name="robots" content="noindex"/>`),T=e(`<div class="error svelte-1p03kmz" role="alert"> </div>`),E=e(`<p class="muted svelte-1p03kmz">No service connections yet. Connect one with <code class="svelte-1p03kmz">cleo service connect &lt;provider&gt;</code> from the CLI.</p>`),D=e(`<h2 class="group-title svelte-1p03kmz"> <span class="muted svelte-1p03kmz"> </span></h2>`),O=e(`<span class="muted svelte-1p03kmz">—</span>`),k=e(`<span class="muted svelte-1p03kmz">none</span>`),A=e(`<span class="muted svelte-1p03kmz">no grants</span>`),j=e(`<span class="grant svelte-1p03kmz"><code class="svelte-1p03kmz"> </code> <!> <!></span>`),M=e(`<tr><td class="svelte-1p03kmz"><code class="svelte-1p03kmz"> </code></td><td class="svelte-1p03kmz"><!></td><td class="scopes svelte-1p03kmz"><!></td><td class="svelte-1p03kmz"> </td><td class="svelte-1p03kmz"><!></td><td class="grants svelte-1p03kmz"><!></td></tr>`),N=e(`<table class="conns svelte-1p03kmz"><thead><tr><th scope="col" class="svelte-1p03kmz">Label</th><th scope="col" class="svelte-1p03kmz">Status</th><th scope="col" class="svelte-1p03kmz">Scopes</th><th scope="col" class="svelte-1p03kmz">Expiry</th><th scope="col" class="svelte-1p03kmz">Credential</th><th scope="col" class="svelte-1p03kmz">Agent grants</th></tr></thead><tbody></tbody></table>`),P=e(`<h2 class="group-title svelte-1p03kmz">Orphan grants <span class="muted svelte-1p03kmz"> </span></h2>`),F=e(`<li><code class="svelte-1p03kmz"> </code> <!></li>`),I=e(`<ul class="orphans svelte-1p03kmz"></ul>`),L=e(`<div class="groups svelte-1p03kmz"></div> <!>`,1),R=e(`<section class="vault-page svelte-1p03kmz"><header class="page-header svelte-1p03kmz"><div><span class="eyebrow svelte-1p03kmz">SERVICE VAULT</span> <h1 class="svelte-1p03kmz">Connected services</h1> <p class="muted svelte-1p03kmz">Read-only view of the global service vault — connections + per-agent grants. Secrets never
        leave core; this dashboard shows identity, scopes, and status only. Manage connections via <code class="svelte-1p03kmz">cleo service connect</code> / <code class="svelte-1p03kmz">cleo service revoke</code>.</p></div></header> <!></section>`);function z(e,z){v(z,!0);let B=h(()=>{let e=new Map;for(let t of z.data.connections){let n=e.get(t.provider);n?n.push(t):e.set(t.provider,[t])}return Array.from(e.entries()).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>({provider:e,connections:t.slice().sort((e,t)=>e.label.localeCompare(t.label))}))}),V=h(()=>{let e=new Map;for(let t of z.data.grants){if(t.provider===null||t.label===null)continue;let n=`${t.provider}:${t.label}`,r=e.get(n);r?r.push(t):e.set(n,[t])}return e}),H=h(()=>z.data.grants.filter(e=>e.provider===null||e.label===null));function U(e){return e===`active`?`success`:e===`expired`?`warning`:e===`revoked`?`danger`:`neutral`}function W(e){if(e===null)return`never`;let t=Date.parse(e)-Date.now();if(!Number.isFinite(t))return e;if(t<0)return`expired`;let n=Math.round(t/36e5);return n<48?`${n}h`:`${Math.round(n/24)}d`}var G=R();x(`1p03kmz`,e=>{var t=w();u(()=>{o.title=`Service Vault — CLEO Studio`}),c(e,t)});var K=d(a(G),2),q=e=>{C(e,{padding:`cozy`,children:(e,n)=>{var i=T(),o=a(i);y(i),r(()=>t(o,`Failed to load the vault: ${z.data.error??``}`)),c(e,i)},$$slots:{default:!0}})},J=e=>{C(e,{padding:`cozy`,children:(e,t)=>{c(e,E())},$$slots:{default:!0}})},Y=e=>{var o=L(),u=f(o);b(u,21,()=>i(B),e=>e.provider,(e,o)=>{C(e,{padding:`cozy`,header:e=>{var n=D(),s=a(n),l=d(s),u=a(l);y(l),y(n),r(()=>{t(s,`${i(o).provider??``} `),t(u,`· ${i(o).connections.length??``}
                ${i(o).connections.length===1?`connection`:`connections`}`)}),c(e,n)},children:(e,l)=>{var u=N(),p=d(a(u));b(p,21,()=>i(o).connections,e=>e.label,(e,o)=>{let l=h(()=>i(V).get(`${i(o).provider}:${i(o).label}`)??[]);var u=M(),p=a(u),v=a(p),x=a(v,!0);y(v),y(p);var C=d(p),w=a(C);{let e=h(()=>U(i(o).status));S(w,{get tone(){return i(e)},size:`sm`,children:(e,n)=>{_();var a=s();r(()=>t(a,i(o).status)),c(e,a)},$$slots:{default:!0}})}y(C);var T=d(C),E=a(T),D=e=>{c(e,O())},N=e=>{var n=g();b(f(n),16,()=>i(o).scopes,e=>e,(e,n)=>{S(e,{tone:`neutral`,size:`sm`,children:(e,i)=>{_();var a=s();r(()=>t(a,n)),c(e,a)},$$slots:{default:!0}})}),c(e,n)};n(E,e=>{i(o).scopes.length===0?e(D):e(N,-1)}),y(T);var P=d(T),F=a(P,!0);y(P);var I=d(P),L=a(I),R=e=>{S(e,{tone:`info`,size:`sm`,children:(e,t)=>{_(),c(e,s(`stored`))},$$slots:{default:!0}})},z=e=>{c(e,k())};n(L,e=>{i(o).hasCredentials?e(R):e(z,-1)}),y(I);var B=d(I),H=a(B),G=e=>{c(e,A())},K=e=>{var o=g();b(f(o),17,()=>i(l),e=>e.agentId,(e,o)=>{var l=j(),u=a(l),f=a(u,!0);y(u);var p=d(u,2);{let e=h(()=>i(o).mode===`block`?`danger`:`success`);S(p,{get tone(){return i(e)},size:`sm`,children:(e,n)=>{_();var a=s();r(()=>t(a,i(o).mode)),c(e,a)},$$slots:{default:!0}})}var g=d(p,2),v=e=>{S(e,{tone:`warning`,size:`sm`,children:(e,t)=>{_(),c(e,s(`manual`))},$$slots:{default:!0}})};n(g,e=>{i(o).manualApproval&&e(v)}),y(l),r(()=>{m(l,`title`,`policy: ${i(o).mode}`),t(f,i(o).agentId)}),c(e,l)}),c(e,o)};n(H,e=>{i(l).length===0?e(G):e(K,-1)}),y(B),y(u),r(e=>{t(x,i(o).label),t(F,e)},[()=>W(i(o).expiresAt)]),c(e,u)}),y(p),y(u),c(e,u)},$$slots:{header:!0,default:!0}})}),y(u);var p=d(u,2),v=e=>{C(e,{padding:`cozy`,header:e=>{var n=P(),o=d(a(n)),s=a(o);y(o),y(n),r(()=>t(s,`· ${i(H).length??``} (connection deleted)`)),c(e,n)},children:(e,n)=>{var o=I();b(o,21,()=>i(H),l,(e,n)=>{var o=F(),l=a(o),u=a(l,!0);y(l);var f=d(l),p=d(f);{let e=h(()=>i(n).mode===`block`?`danger`:`neutral`);S(p,{get tone(){return i(e)},size:`sm`,children:(e,a)=>{_();var o=s();r(()=>t(o,i(n).mode)),c(e,o)},$$slots:{default:!0}})}y(o),r(()=>{t(u,i(n).agentId),t(f,` → connection #${i(n).provider===null?`(deleted)`:`${i(n).provider}:${i(n).label}`} `)}),c(e,o)}),y(o),c(e,o)},$$slots:{header:!0,default:!0}})};n(p,e=>{i(H).length>0&&e(v)}),c(e,o)};n(K,e=>{z.data.error?e(q):z.data.connections.length===0?e(J,1):e(Y,-1)}),y(G),c(e,G),p()}export{z as component};