import{d as Ue,o as Ye,O as kn,w as Nn,c as E,r as I,q as T,t as An,B as Y,a as g,E as Cn,J as ot,D as M,F as dt,P as St,G as L,h as $n,N as Qt,b as _e,g as be,H as ke,f as J,x as Mn,j as Et}from"./index-DnbYEqLr.js";import{u as Sn}from"./transport-B_E2RH1i.js";var En={value:()=>{}};function Ut(){for(var t=0,e=arguments.length,n={},r;t=0&&(r=n.slice(i+1),n=n.slice(0,i)),n&&!e.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}Ft.prototype=Ut.prototype={constructor:Ft,on:function(t,e){var n=this._,r=Tn(t+"",n),i,s=-1,o=r.length;if(arguments.length<2){for(;++s0)for(var n=new Array(i),r=0,i,s;r=0&&(e=t.slice(0,n))!=="xmlns"&&(t=t.slice(n+1)),Ae.hasOwnProperty(e)?{space:Ae[e],local:t}:t}function Dn(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===ee&&e.documentElement.namespaceURI===ee?e.createElement(t):e.createElementNS(n,t)}}function In(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function qe(t){var e=Yt(t);return(e.local?In:Dn)(e)}function Fn(){}function ue(t){return t==null?Fn:function(){return this.querySelector(t)}}function Bn(t){typeof t!="function"&&(t=ue(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i=x&&(x=_+1);!(A=y[x])&&++x=0;)(o=r[i])&&(s&&o.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(o,s),s=o);return this}function ar(t){t||(t=lr);function e(v,d){return v&&d?t(v.__data__,d.__data__):!v-!d}for(var n=this._groups,r=n.length,i=new Array(r),s=0;se?1:t>=e?0:NaN}function ur(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function cr(){return Array.from(this)}function fr(){for(var t=this._groups,e=0,n=t.length;e1?this.each((e==null?br:typeof e=="function"?Nr:kr)(t,e,n??"")):ut(this.node(),t)}function ut(t,e){return t.style.getPropertyValue(e)||Qe(t).getComputedStyle(t,null).getPropertyValue(e)}function Cr(t){return function(){delete this[t]}}function $r(t,e){return function(){this[t]=e}}function Mr(t,e){return function(){var n=e.apply(this,arguments);n==null?delete this[t]:this[t]=n}}function Sr(t,e){return arguments.length>1?this.each((e==null?Cr:typeof e=="function"?Mr:$r)(t,e)):this.node()[t]}function Ze(t){return t.trim().split(/^|\s+/)}function ce(t){return t.classList||new je(t)}function je(t){this._node=t,this._names=Ze(t.getAttribute("class")||"")}je.prototype={add:function(t){var e=this._names.indexOf(t);e<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var e=this._names.indexOf(t);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};function tn(t,e){for(var n=ce(t),r=-1,i=e.length;++r=0&&(n=e.slice(r+1),e=e.slice(0,r)),{type:e,name:n}})}function ri(t){return function(){var e=this.__on;if(e){for(var n=0,r=-1,i=e.length,s;n()=>t;function ne(t,{sourceEvent:e,subject:n,target:r,identifier:i,active:s,x:o,y:a,dx:u,dy:l,dispatch:c}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:s,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:u,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:c}})}ne.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function gi(t){return!t.ctrlKey&&!t.button}function vi(){return this.parentNode}function xi(t,e){return e??{x:t.x,y:t.y}}function yi(){return navigator.maxTouchPoints||"ontouchstart"in this}function wi(){var t=gi,e=vi,n=xi,r=yi,i={},s=Ut("start","drag","end"),o=0,a,u,l,c,v=0;function d(f){f.on("mousedown.drag",h).filter(r).on("touchstart.drag",y).on("touchmove.drag",m,hi).on("touchend.drag touchcancel.drag",_).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(f,A){if(!(c||!t.call(this,f,A))){var C=x(this,e.call(this,f,A),f,A,"mouse");C&&(yt(f.view).on("mousemove.drag",b,wt).on("mouseup.drag",w,wt),di(f.view),Zt(f),l=!1,a=f.clientX,u=f.clientY,C("start",f))}}function b(f){if(at(f),!l){var A=f.clientX-a,C=f.clientY-u;l=A*A+C*C>v}i.mouse("drag",f)}function w(f){yt(f.view).on("mousemove.drag mouseup.drag",null),pi(f.view,l),at(f),i.mouse("end",f)}function y(f,A){if(t.call(this,f,A)){var C=f.changedTouches,S=e.call(this,f,A),$=C.length,F,D;for(F=0;F<$;++F)(D=x(this,S,f,A,C[F].identifier,C[F]))&&(Zt(f),D("start",f,C[F]))}}function m(f){var A=f.changedTouches,C=A.length,S,$;for(S=0;S>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?Rt(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?Rt(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=_i.exec(t))?new X(e[1],e[2],e[3],1):(e=bi.exec(t))?new X(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=ki.exec(t))?Rt(e[1],e[2],e[3],e[4]):(e=Ni.exec(t))?Rt(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=Ai.exec(t))?De(e[1],e[2]/100,e[3]/100,1):(e=Ci.exec(t))?De(e[1],e[2]/100,e[3]/100,e[4]):$e.hasOwnProperty(t)?Ee($e[t]):t==="transparent"?new X(NaN,NaN,NaN,0):null}function Ee(t){return new X(t>>16&255,t>>8&255,t&255,1)}function Rt(t,e,n,r){return r<=0&&(t=e=n=NaN),new X(t,e,n,r)}function Si(t){return t instanceof At||(t=bt(t)),t?(t=t.rgb(),new X(t.r,t.g,t.b,t.opacity)):new X}function re(t,e,n,r){return arguments.length===1?Si(t):new X(t,e,n,r??1)}function X(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}fe(X,re,sn(At,{brighter(t){return t=t==null?zt:Math.pow(zt,t),new X(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?mt:Math.pow(mt,t),new X(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new X(nt(this.r),nt(this.g),nt(this.b),Lt(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Te,formatHex:Te,formatHex8:Ei,formatRgb:Re,toString:Re}));function Te(){return`#${et(this.r)}${et(this.g)}${et(this.b)}`}function Ei(){return`#${et(this.r)}${et(this.g)}${et(this.b)}${et((isNaN(this.opacity)?1:this.opacity)*255)}`}function Re(){const t=Lt(this.opacity);return`${t===1?"rgb(":"rgba("}${nt(this.r)}, ${nt(this.g)}, ${nt(this.b)}${t===1?")":`, ${t})`}`}function Lt(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function nt(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function et(t){return t=nt(t),(t<16?"0":"")+t.toString(16)}function De(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new V(t,e,n,r)}function on(t){if(t instanceof V)return new V(t.h,t.s,t.l,t.opacity);if(t instanceof At||(t=bt(t)),!t)return new V;if(t instanceof V)return t;t=t.rgb();var e=t.r/255,n=t.g/255,r=t.b/255,i=Math.min(e,n,r),s=Math.max(e,n,r),o=NaN,a=s-i,u=(s+i)/2;return a?(e===s?o=(n-r)/a+(n0&&u<1?0:o,new V(o,a,u,t.opacity)}function Ti(t,e,n,r){return arguments.length===1?on(t):new V(t,e,n,r??1)}function V(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}fe(V,Ti,sn(At,{brighter(t){return t=t==null?zt:Math.pow(zt,t),new V(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?mt:Math.pow(mt,t),new V(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*e,i=2*n-r;return new X(jt(t>=240?t-240:t+120,i,r),jt(t,i,r),jt(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new V(Ie(this.h),Dt(this.s),Dt(this.l),Lt(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const t=Lt(this.opacity);return`${t===1?"hsl(":"hsla("}${Ie(this.h)}, ${Dt(this.s)*100}%, ${Dt(this.l)*100}%${t===1?")":`, ${t})`}`}}));function Ie(t){return t=(t||0)%360,t<0?t+360:t}function Dt(t){return Math.max(0,Math.min(1,t||0))}function jt(t,e,n){return(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)*255}const an=t=>()=>t;function Ri(t,e){return function(n){return t+n*e}}function Di(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(r){return Math.pow(t+r*e,n)}}function Ii(t){return(t=+t)==1?ln:function(e,n){return n-e?Di(e,n,t):an(isNaN(e)?n:e)}}function ln(t,e){var n=e-t;return n?Ri(t,n):an(isNaN(t)?e:t)}const Fe=(function t(e){var n=Ii(e);function r(i,s){var o=n((i=re(i)).r,(s=re(s)).r),a=n(i.g,s.g),u=n(i.b,s.b),l=ln(i.opacity,s.opacity);return function(c){return i.r=o(c),i.g=a(c),i.b=u(c),i.opacity=l(c),i+""}}return r.gamma=t,r})(1);function Q(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}var ie=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,te=new RegExp(ie.source,"g");function Fi(t){return function(){return t}}function Bi(t){return function(e){return t(e)+""}}function Pi(t,e){var n=ie.lastIndex=te.lastIndex=0,r,i,s,o=-1,a=[],u=[];for(t=t+"",e=e+"";(r=ie.exec(t))&&(i=te.exec(e));)(s=i.index)>n&&(s=e.slice(n,s),a[o]?a[o]+=s:a[++o]=s),(r=r[0])===(i=i[0])?a[o]?a[o]+=i:a[++o]=i:(a[++o]=null,u.push({i:o,x:Q(r,i)})),n=te.lastIndex;return n180?c+=360:c-l>180&&(l+=360),d.push({i:v.push(i(v)+"rotate(",null,r)-2,x:Q(l,c)})):c&&v.push(i(v)+"rotate("+c+r)}function a(l,c,v,d){l!==c?d.push({i:v.push(i(v)+"skewX(",null,r)-2,x:Q(l,c)}):c&&v.push(i(v)+"skewX("+c+r)}function u(l,c,v,d,h,b){if(l!==v||c!==d){var w=h.push(i(h)+"scale(",null,",",null,")");b.push({i:w-4,x:Q(l,v)},{i:w-2,x:Q(c,d)})}else(v!==1||d!==1)&&h.push(i(h)+"scale("+v+","+d+")")}return function(l,c){var v=[],d=[];return l=t(l),c=t(c),s(l.translateX,l.translateY,c.translateX,c.translateY,v,d),o(l.rotate,c.rotate,v,d),a(l.skewX,c.skewX,v,d),u(l.scaleX,l.scaleY,c.scaleX,c.scaleY,v,d),l=c=null,function(h){for(var b=-1,w=d.length,y;++b=0&&t._call.call(void 0,e),t=t._next;--ct}function Pe(){it=(Ot=kt.now())+qt,ct=gt=0;try{Vi()}finally{ct=0,Yi(),it=0}}function Ui(){var t=kt.now(),e=t-Ot;e>fn&&(qt-=e,Ot=t)}function Yi(){for(var t,e=Xt,n,r=1/0;e;)e._call?(r>e._time&&(r=e._time),t=e,e=e._next):(n=e._next,e._next=null,e=t?t._next=n:Xt=n);vt=t,oe(r)}function oe(t){if(!ct){gt&&(gt=clearTimeout(gt));var e=t-it;e>24?(t<1/0&&(gt=setTimeout(Pe,t-kt.now()-qt)),pt&&(pt=clearInterval(pt))):(pt||(Ot=kt.now(),pt=setInterval(Ui,fn)),ct=1,hn(Pe))}}function He(t,e,n){var r=new Vt;return e=e==null?0:+e,r.restart(i=>{r.stop(),t(i+e)},e,n),r}var qi=Ut("start","end","cancel","interrupt"),Gi=[],dn=0,ze=1,ae=2,Bt=3,Le=4,le=5,Pt=6;function Gt(t,e,n,r,i,s){var o=t.__transition;if(!o)t.__transition={};else if(n in o)return;Ji(t,n,{name:e,index:r,group:i,on:qi,tween:Gi,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:dn})}function pe(t,e){var n=U(t,e);if(n.state>dn)throw new Error("too late; already scheduled");return n}function G(t,e){var n=U(t,e);if(n.state>Bt)throw new Error("too late; already running");return n}function U(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw new Error("transition not found");return n}function Ji(t,e,n){var r=t.__transition,i;r[e]=n,n.timer=de(s,0,n.time);function s(l){n.state=ze,n.timer.restart(o,n.delay,n.time),n.delay<=l&&o(l-n.delay)}function o(l){var c,v,d,h;if(n.state!==ze)return u();for(c in r)if(h=r[c],h.name===n.name){if(h.state===Bt)return He(o);h.state===Le?(h.state=Pt,h.timer.stop(),h.on.call("interrupt",t,t.__data__,h.index,h.group),delete r[c]):+cae&&r.state=0&&(e=e.slice(0,n)),!e||e==="start"})}function As(t,e,n){var r,i,s=Ns(e)?pe:G;return function(){var o=s(this,t),a=o.on;a!==r&&(i=(r=a).copy()).on(e,n),o.on=i}}function Cs(t,e){var n=this._id;return arguments.length<2?U(this.node(),n).on.on(t):this.each(As(n,t,e))}function $s(t){return function(){var e=this.parentNode;for(var n in this.__transition)if(+n!==t)return;e&&e.removeChild(this)}}function Ms(){return this.on("end.remove",$s(this._id))}function Ss(t){var e=this._name,n=this._id;typeof t!="function"&&(t=ue(t));for(var r=this._groups,i=r.length,s=new Array(i),o=0;o=(v=(a+l)/2))?a=v:l=v,(y=n>=(d=(u+c)/2))?u=d:c=d,i=s,!(s=s[m=y<<1|w]))return i[m]=o,t;if(h=+t._x.call(null,s.data),b=+t._y.call(null,s.data),e===h&&n===b)return o.next=s,i?i[m]=o:t._root=o,t;do i=i?i[m]=new Array(4):t._root=new Array(4),(w=e>=(v=(a+l)/2))?a=v:l=v,(y=n>=(d=(u+c)/2))?u=d:c=d;while((m=y<<1|w)===(_=(b>=d)<<1|h>=v));return i[_]=s,i[m]=o,t}function no(t){var e,n,r=t.length,i,s,o=new Array(r),a=new Array(r),u=1/0,l=1/0,c=-1/0,v=-1/0;for(n=0;nc&&(c=i),sv&&(v=s));if(u>c||l>v)return this;for(this.cover(u,l).cover(c,v),n=0;nt||t>=i||r>e||e>=s;)switch(l=(ec||(a=b.y0)>v||(u=b.x1)=m)<<1|t>=y)&&(b=d[d.length-1],d[d.length-1]=d[d.length-1-w],d[d.length-1-w]=b)}else{var _=t-+this._x.call(null,h.data),x=e-+this._y.call(null,h.data),f=_*_+x*x;if(f=(d=(o+u)/2))?o=d:u=d,(w=v>=(h=(a+l)/2))?a=h:l=h,e=n,!(n=n[y=w<<1|b]))return this;if(!n.length)break;(e[y+1&3]||e[y+2&3]||e[y+3&3])&&(r=e,m=y)}for(;n.data!==t;)if(i=n,!(n=n.next))return this;return(s=n.next)&&delete n.next,i?(s?i.next=s:delete i.next,this):e?(s?e[y]=s:delete e[y],(n=e[0]||e[1]||e[2]||e[3])&&n===(e[3]||e[2]||e[1]||e[0])&&!n.length&&(r?r[m]=n:this._root=n),this):(this._root=s,this)}function lo(t){for(var e=0,n=t.length;ed.index){var R=h-$.x-$.vx,B=b-$.y-$.vy,P=R*R+B*B;Ph+D||Cb+D||Sl.r&&(l.r=l[c].r)}function u(){if(e){var l,c=e.length,v;for(n=new Array(c),l=0;l[e(A,C,o),A])),f;for(y=0,a=new Array(m);y<_;++y)f=t[y],f.index=y,typeof f.source!="object"&&(f.source=Oe(x,f.source)),typeof f.target!="object"&&(f.target=Oe(x,f.target)),a[f.source.index]=(a[f.source.index]||0)+1,a[f.target.index]=(a[f.target.index]||0)+1;for(y=0,u=new Array(_);y<_;++y)f=t[y],u[y]=a[f.source.index]/(a[f.source.index]+a[f.target.index]);r=new Array(_),b(),s=new Array(_),w()}}function b(){if(o)for(var y=0,m=t.length;y(t=(ko*t+No)%Ve)/Ve}function Co(t){return t.x}function $o(t){return t.y}var Mo=10,So=Math.PI*(3-Math.sqrt(5));function Eo(t){var e,n=1,r=.001,i=1-Math.pow(r,1/300),s=0,o=.6,a=new Map,u=de(v),l=Ut("tick","end"),c=Ao();t==null&&(t=[]);function v(){d(),l.call("tick",e),n1?(y==null?a.delete(w):a.set(w,b(y)),e):a.get(w)},find:function(w,y,m){var _=0,x=t.length,f,A,C,S,$;for(m==null?m=1/0:m*=m,_=0;_1?(l.on(w,y),e):l.on(w)}}}function To(){var t,e,n,r,i=rt(-30),s,o=1,a=1/0,u=.81;function l(h){var b,w=t.length,y=ve(t,Co,$o).visitAfter(v);for(r=h,b=0;b=a)return;(h.data!==e||h.next)&&(m===0&&(m=Z(n),f+=m*m),_===0&&(_=Z(n),f+=_*_),f({...x})),b=e.links.map(x=>({...x})),w=h.find(x=>x.is_self);w&&(w.fx=v/2,w.fy=d/2),i=Eo(h).force("link",bo(b).id(x=>x.did).distance(120)).force("charge",To().strength(-300)).force("center",to(v/2,d/2)).force("collision",mo().radius(x=>a(x)+5));const y=l.append("g"),m=y.append("g").selectAll("line").data(b).join("line").attr("stroke",x=>{const f=typeof x.source=="object"?x.source:h.find(C=>C.did===x.source),A=typeof x.target=="object"?x.target:h.find(C=>C.did===x.target);return f?.online&&A?.online?"#4ade8060":"#6b728050"}).attr("stroke-width",2).attr("stroke-dasharray",x=>{const f=typeof x.source=="object"?x.source:h.find(C=>C.did===x.source),A=typeof x.target=="object"?x.target:h.find(C=>C.did===x.target);return f?.online&&A?.online?"none":"6 4"}),_=y.append("g").selectAll("g").data(h).join("g").attr("cursor","pointer").call(wi().on("start",(x,f)=>{x.active||i.alphaTarget(.3).restart(),f.fx=f.x,f.fy=f.y}).on("drag",(x,f)=>{f.fx=x.x,f.fy=x.y}).on("end",(x,f)=>{x.active||i.alphaTarget(0),f.is_self||(f.fx=null,f.fy=null)}));_.append("circle").attr("r",x=>a(x)).attr("fill",x=>o(x.trust_level)).attr("fill-opacity",x=>x.online?.8:.3).attr("stroke",x=>x.is_self?"#fb923c":o(x.trust_level)).attr("stroke-width",x=>x.is_self?3:1.5).attr("stroke-opacity",x=>x.online?1:.4),_.append("text").text(x=>x.label).attr("dy",x=>a(x)+14).attr("text-anchor","middle").attr("fill","rgba(255,255,255,0.7)").attr("font-size","11px").attr("font-family","'Avenir Next', sans-serif"),_.append("title").text(x=>`${x.did} Apps: ${x.app_count} ${x.online?"Online":"Offline"}`),i.on("tick",()=>{m.attr("x1",x=>x.source.x).attr("y1",x=>x.source.y).attr("x2",x=>x.target.x).attr("y2",x=>x.target.y),_.attr("transform",x=>`translate(${x.x},${x.y})`)})}return Ye(()=>{u(),s=new ResizeObserver(()=>u()),n.value&&s.observe(n.value)}),kn(()=>{i?.stop(),s?.disconnect()}),Nn(()=>[e.nodes,e.links],()=>u(),{deep:!0}),(l,c)=>(T(),E("div",{ref_key:"containerRef",ref:n,class:"network-map-container"},[(T(),E("svg",{ref_key:"svgRef",ref:r,class:"w-full h-full"},null,512))],512))}}),Do=An(Ro,[["__scopeId","data-v-0e9c18d1"]]),Io={class:"pb-6"},Fo={class:"mb-8"},Bo={class:"text-sm text-white/60 mt-2"},Po={key:0,class:"flex gap-1 mb-6 p-1 bg-black/20 rounded-lg w-fit"},Ho=["onClick"],zo={key:1,class:"mb-6"},Lo={class:"glass-card p-6 mb-6"},Xo={class:"grid grid-cols-1 sm:grid-cols-3 gap-4"},Oo={"data-controller-container":"",tabindex:"0",class:"flex flex-col gap-3 p-4 bg-white/5 rounded-lg min-w-0"},Vo=["disabled"],Uo={"data-controller-container":"",tabindex:"0",class:"flex flex-col gap-3 p-4 bg-white/5 rounded-lg min-w-0"},Yo={"data-controller-container":"",tabindex:"0",class:"flex flex-col gap-3 p-4 bg-white/5 rounded-lg min-w-0"},qo=["disabled"],Go={key:0,class:"glass-card p-6 mb-6"},Jo={class:"flex items-center justify-between mb-4"},Wo={class:"bg-black/30 rounded-lg p-4 font-mono text-xs text-orange-300 break-all select-all"},Ko={key:1,class:"glass-card p-6 mb-6"},Qo={class:"flex items-center justify-between mb-4"},Zo={class:"space-y-2"},jo={class:"text-sm text-white/80 font-mono truncate"},ta={key:0,class:"text-xs text-green-400"},ea={key:1,class:"text-xs text-red-400 truncate"},na={key:2,class:"glass-card p-4 mb-6 border-red-400/30"},ra={class:"text-sm text-red-400"},ia={class:"glass-card p-6 mb-6"},sa={key:0,class:"flex items-center gap-3 py-8 justify-center"},oa={key:1,class:"text-center py-12"},aa={key:2,class:"space-y-3"},la=["onClick"],ua={class:"flex items-center justify-between mb-2"},ca={class:"flex items-center gap-3 min-w-0"},fa={class:"text-sm font-medium text-white truncate"},ha=["title"],da={class:"grid grid-cols-2 sm:grid-cols-4 gap-2 text-xs text-white/50"},pa={class:"flex items-center gap-1"},ga={class:"glass-card p-6 w-full max-w-lg max-h-[80vh] overflow-y-auto"},va={class:"flex items-center justify-between mb-6"},xa={class:"space-y-4"},ya={class:"bg-white/5 rounded-lg p-3"},wa={class:"text-sm text-white/80 font-mono break-all"},ma={class:"bg-white/5 rounded-lg p-3"},_a={class:"text-sm text-white/80 font-mono break-all"},ba={class:"bg-white/5 rounded-lg p-3"},ka={class:"flex items-center gap-2 mt-1"},Na=["value"],Aa={class:"bg-white/5 rounded-lg p-3"},Ca={class:"text-sm text-white/80"},$a={key:0,class:"bg-white/5 rounded-lg p-3"},Ma={class:"grid grid-cols-2 gap-2 text-sm text-white/70"},Sa={key:1,class:"bg-white/5 rounded-lg p-3"},Ea={class:"text-xs text-white/40 mb-2"},Ta={class:"space-y-1"},Ra={class:"text-white/80"},Da={key:2,class:"bg-white/5 rounded-lg p-3"},Ia={class:"flex gap-2"},Fa=["disabled"],Ba={class:"bg-white/5 rounded-lg p-3"},Pa={class:"flex items-center justify-between mb-2"},Ha={class:"flex items-center gap-1.5"},za={class:"text-xs text-white/50"},La={class:"grid grid-cols-2 gap-2 text-sm text-white/70 mb-3"},Xa=["disabled"],Oa={key:3},Va={key:4,class:"mt-4 p-3 bg-red-400/10 rounded-lg border border-red-400/20"},Ua={class:"flex gap-3"},Ya={class:"glass-card p-6 w-full max-w-md"},qa={class:"flex items-center justify-between mb-6"},Ga={key:0,class:"mt-3 text-sm text-red-400"},Ja={key:1,class:"mt-3 text-sm text-green-400"},Wa={class:"flex gap-3 mt-4"},Ka=["disabled"],ja=Ue({__name:"Federation",setup(t){const e=Mn(),n=Sn(),r=I([]),i=I(!0),s=I(""),o=I(null),a=I(""),u=I(!1),l=I(!1),c=I(!1),v=I(""),d=I(!1),h=I(""),b=I(!1),w=I(!1),y=I([]),m=I(!1),_=I(""),x=I(!1),f=I(""),A=[{id:"list",label:"List View"},{id:"map",label:"Network Map"}],C=I(localStorage.getItem("federation-view")||(r.value.length>=3?"map":"list"));function S(k){C.value=k,localStorage.setItem("federation-view",k)}const $=I(""),F=Et(()=>{const k=[];$.value&&k.push({did:$.value,label:"This Node",trust_level:"trusted",online:!0,app_count:0,is_self:!0});for(const p of r.value)k.push({did:p.did,label:p.name||Wt(p.did),trust_level:p.trust_level,online:we(p),app_count:p.last_state?.apps?.length??0,is_self:!1});return k}),D=Et(()=>$.value?r.value.map(k=>({source:$.value,target:k.did})):[]),R=I(null),B=I(!1),P=Et(()=>{if(!R.value)return"bg-white/30";switch(R.value.sync_status){case"synced":return"bg-green-400";case"syncing":return"bg-yellow-400 animate-pulse";case"error":return"bg-red-400";default:return"bg-white/30"}}),st=Et(()=>{if(!R.value)return"Unknown";switch(R.value.sync_status){case"synced":return"Synced";case"syncing":return"Syncing...";case"error":return"Error";default:return R.value.sync_status}});async function j(){try{i.value=!0;const k=await Y.federationListNodes();r.value=k.nodes}catch(k){s.value=k instanceof Error?k.message:"Failed to load nodes"}finally{i.value=!1}}async function ft(){try{u.value=!0,s.value="";const k=await Y.federationInvite();a.value=k.code}catch(k){s.value=k instanceof Error?k.message:"Failed to generate invite"}finally{u.value=!1}}async function Ct(){try{await window.navigator.clipboard.writeText(a.value)}catch{const k=document.createElement("textarea");k.value=a.value,k.style.position="fixed",k.style.opacity="0",document.body.appendChild(k),k.select(),document.execCommand("copy"),document.body.removeChild(k)}l.value=!0,setTimeout(()=>{l.value=!1},2e3)}async function Jt(){try{d.value=!0,h.value="",b.value=!1,await Y.federationJoin(v.value.trim()),b.value=!0,v.value="",await j(),setTimeout(()=>{c.value=!1,b.value=!1},1500)}catch(k){h.value=k instanceof Error?k.message:"Failed to join"}finally{d.value=!1}}async function $t(){try{w.value=!0,s.value="";const k=await Y.federationSyncState();y.value=k.results,await j()}catch(k){s.value=k instanceof Error?k.message:"Sync failed"}finally{w.value=!1}}async function ht(k,p){try{await Y.federationSetTrust(k,p),await j(),o.value?.did===k&&(o.value=r.value.find(N=>N.did===k)??null)}catch(N){s.value=N instanceof Error?N.message:"Failed to update trust level"}}async function yn(k){try{await Y.federationRemoveNode(k),m.value=!1,o.value=null,await j()}catch(p){m.value=!1,s.value=p instanceof Error?p.message:"Failed to remove node"}}async function wn(k){try{x.value=!0,f.value="",await Y.federationDeployApp({did:k,appId:_.value.trim()}),f.value=`Successfully deployed ${_.value} to remote node`,_.value=""}catch(p){f.value=`Error: ${p instanceof Error?p.message:"Deploy failed"}`}finally{x.value=!1}}async function ye(){try{const k=await Y.call({method:"dwn.status"});R.value=k}catch{R.value=null}}async function mn(){try{B.value=!0,await Y.call({method:"dwn.sync",timeout:12e4}),await ye()}catch{}finally{B.value=!1}}function we(k){if(!k.last_seen)return!1;const p=new Date(k.last_seen).getTime(),N=Date.now()-600*1e3;return p>N}function Wt(k){return k.length<=24?k:k.slice(0,16)+"..."+k.slice(-8)}function me(k){const p=Math.floor((Date.now()-new Date(k).getTime())/1e3);return p<60?"just now":p<3600?Math.floor(p/60)+"m ago":p<86400?Math.floor(p/3600)+"h ago":Math.floor(p/86400)+"d ago"}function Mt(k){if(k==null||k===0)return"--";const p=["B","KB","MB","GB","TB"];let N=0,tt=k;for(;tt>=1024&&N0)return`${p}d ${N}h`;const tt=Math.floor(k%3600/60);return`${N}h ${tt}m`}function bn(k){switch(k){case"trusted":return"bg-green-400/20 text-green-400";case"observer":return"bg-blue-400/20 text-blue-400";case"untrusted":return"bg-white/10 text-white/50";default:return"bg-white/10 text-white/50"}}function Kt(k){const p=n.peers.find(N=>N.did===k);if(!p)return{icon:"?",color:"text-white/30",label:"unknown"};switch(p.preferred_transport){case"mesh":return{icon:"📡",color:"text-orange-400",label:"mesh"};case"lan":return{icon:"🌐",color:"text-green-400",label:"lan"};case"tor":return{icon:"🧅",color:"text-purple-400",label:"tor"};default:return{icon:"?",color:"text-white/30",label:"unknown"}}}return Ye(async()=>{j(),ye(),n.fetchPeers();try{const k=await Y.getNodeDid();$.value=k.did}catch{}}),(k,p)=>(T(),E("div",Io,[g("div",Fo,[g("button",{onClick:p[0]||(p[0]=N=>Cn(e).push("/dashboard/web5")),class:"flex items-center gap-2 text-white/50 hover:text-white/80 transition-colors text-sm mb-4"},[...p[16]||(p[16]=[g("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[g("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15 19l-7-7 7-7"})],-1),ot(" Back to Web5 ",-1)])]),p[17]||(p[17]=g("h1",{class:"text-3xl font-bold text-white mb-2"},"Federation",-1)),p[18]||(p[18]=g("p",{class:"text-white/70"},"Manage trusted node clusters and sync state across your network",-1)),g("p",Bo,M(r.value.length)+" federated node"+M(r.value.length!==1?"s":""),1)]),r.value.length>0?(T(),E("div",Po,[(T(),E(dt,null,St(A,N=>g("button",{key:N.id,class:J(["px-4 py-2 rounded text-sm font-medium transition-colors",C.value===N.id?"bg-white/10 text-white border-b-2 border-orange-400":"text-white/50 hover:text-white/70"]),onClick:tt=>S(N.id)},M(N.label),11,Ho)),64))])):L("",!0),C.value==="map"&&r.value.length>0?(T(),E("div",zo,[$n(Do,{nodes:F.value,links:D.value},null,8,["nodes","links"])])):L("",!0),C.value==="list"?(T(),E(dt,{key:2},[g("div",Lo,[g("div",Xo,[g("div",Oo,[p[19]||(p[19]=Qt('

Invite Node

Generate invite code

',1)),g("button",{onClick:ft,class:"w-fit px-3 py-1.5 glass-button glass-button-sm rounded text-xs font-medium text-white/90 hover:text-white transition-colors disabled:opacity-50",disabled:u.value},M(u.value?"Generating...":"Generate"),9,Vo)]),g("div",Uo,[p[20]||(p[20]=Qt('

Join

Accept an invite code

',1)),g("button",{onClick:p[1]||(p[1]=N=>c.value=!0),class:"w-fit px-3 py-1.5 glass-button glass-button-sm rounded text-xs font-medium text-white/90 hover:text-white transition-colors"}," Join ")]),g("div",Yo,[p[21]||(p[21]=Qt('

Sync

Refresh all node states

',1)),g("button",{onClick:$t,class:"w-fit px-3 py-1.5 glass-button glass-button-sm rounded text-xs font-medium text-white/90 hover:text-white transition-colors disabled:opacity-50",disabled:w.value},M(w.value?"Syncing...":"Sync Now"),9,qo)])])]),a.value?(T(),E("div",Go,[g("div",Jo,[p[22]||(p[22]=g("h2",{class:"text-lg font-semibold text-white"},"Invite Code",-1)),g("button",{onClick:p[2]||(p[2]=N=>a.value=""),class:"text-white/40 hover:text-white/70 transition-colors text-sm"},"Dismiss")]),p[23]||(p[23]=g("p",{class:"text-xs text-white/60 mb-3"},"Share this code with the node you want to federate with. It can only be used once.",-1)),g("div",Wo,M(a.value),1),g("button",{onClick:Ct,class:"mt-3 px-4 py-2 glass-button rounded text-sm text-white/90 hover:text-white transition-colors"},M(l.value?"Copied":"Copy to Clipboard"),1)])):L("",!0),y.value.length>0?(T(),E("div",Ko,[g("div",Qo,[p[24]||(p[24]=g("h2",{class:"text-lg font-semibold text-white"},"Sync Results",-1)),g("button",{onClick:p[3]||(p[3]=N=>y.value=[]),class:"text-white/40 hover:text-white/70 transition-colors text-sm"},"Dismiss")]),g("div",Zo,[(T(!0),E(dt,null,St(y.value,N=>(T(),E("div",{key:N.did,class:"flex items-center gap-3 p-3 bg-white/5 rounded-lg"},[g("div",{class:J(["w-2 h-2 rounded-full shrink-0",N.status==="ok"?"bg-green-400":"bg-red-400"])},null,2),g("span",jo,M(Wt(N.did)),1),N.status==="ok"?(T(),E("span",ta,M(N.apps)+" apps",1)):(T(),E("span",ea,M(N.error),1))]))),128))])])):L("",!0),s.value?(T(),E("div",na,[g("p",ra,M(s.value),1)])):L("",!0),g("div",ia,[p[31]||(p[31]=g("h2",{class:"text-lg font-semibold text-white mb-4"},"Federated Nodes",-1)),i.value?(T(),E("div",sa,[...p[25]||(p[25]=[g("div",{class:"w-5 h-5 border-2 border-white/20 border-t-orange-400 rounded-full animate-spin"},null,-1),g("span",{class:"text-white/60 text-sm"},"Loading nodes...",-1)])])):r.value.length===0?(T(),E("div",oa,[...p[26]||(p[26]=[g("svg",{class:"w-16 h-16 text-white/20 mx-auto mb-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[g("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1.5",d:"M21 12a9 9 0 01-9 9m9-9a9 9 0 00-9-9m9 9H3m9 9a9 9 0 01-9-9m9 9c1.657 0 3-4.03 3-9s-1.343-9-3-9m0 18c-1.657 0-3-4.03-3-9s1.343-9 3-9m-9 9a9 9 0 019-9"})],-1),g("p",{class:"text-white/50 text-sm mb-2"},"No federated nodes yet",-1),g("p",{class:"text-white/30 text-xs"},"Generate an invite code or join an existing federation",-1)])])):(T(),E("div",aa,[(T(!0),E(dt,null,St(r.value,N=>(T(),E("div",{key:N.did,class:"bg-black/20 rounded-xl border border-white/10 p-4 cursor-pointer hover:border-white/20 transition-colors",onClick:tt=>o.value=N},[g("div",ua,[g("div",ca,[g("div",{class:J(["w-2.5 h-2.5 rounded-full shrink-0",we(N)?"bg-green-400":"bg-white/30"])},null,2),g("span",fa,M(N.name||Wt(N.did)),1),g("span",{class:J(["text-xs shrink-0",Kt(N.did).color]),title:"Transport: "+Kt(N.did).label},M(Kt(N.did).icon),11,ha)]),g("span",{class:J(["text-xs px-2 py-0.5 rounded-full shrink-0",bn(N.trust_level)])},M(N.trust_level),3)]),g("div",da,[g("div",null,[p[27]||(p[27]=g("span",{class:"text-white/30"},"Apps:",-1)),ot(" "+M(N.last_state?.apps?.length??"--"),1)]),g("div",null,[p[28]||(p[28]=g("span",{class:"text-white/30"},"CPU:",-1)),ot(" "+M(N.last_state?.cpu_usage_percent!=null?N.last_state.cpu_usage_percent.toFixed(1)+"%":"--"),1)]),g("div",pa,[p[29]||(p[29]=g("span",{class:"text-white/30"},"DWN:",-1)),g("span",{class:J(["w-1.5 h-1.5 rounded-full",P.value])},null,2)]),g("div",null,[p[30]||(p[30]=g("span",{class:"text-white/30"},"Seen:",-1)),ot(" "+M(N.last_seen?me(N.last_seen):"never"),1)])])],8,la))),128))]))])],64)):L("",!0),o.value?(T(),E("div",{key:3,class:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/10 backdrop-blur-md",onClick:p[11]||(p[11]=_e(N=>{o.value=null,m.value=!1},["self"]))},[g("div",ga,[g("div",va,[p[33]||(p[33]=g("h2",{class:"text-xl font-semibold text-white"},"Node Details",-1)),g("button",{onClick:p[4]||(p[4]=N=>{o.value=null,m.value=!1}),class:"text-white/40 hover:text-white/70 transition-colors"},[...p[32]||(p[32]=[g("svg",{class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[g("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)])])]),g("div",xa,[g("div",ya,[p[34]||(p[34]=g("p",{class:"text-xs text-white/40 mb-1"},"DID",-1)),g("p",wa,M(o.value.did),1)]),g("div",ma,[p[35]||(p[35]=g("p",{class:"text-xs text-white/40 mb-1"},"Onion Address",-1)),g("p",_a,M(o.value.onion),1)]),g("div",ba,[p[37]||(p[37]=g("p",{class:"text-xs text-white/40 mb-1"},"Trust Level",-1)),g("div",ka,[g("select",{value:o.value.trust_level,onChange:p[5]||(p[5]=N=>ht(o.value.did,N.target.value)),class:"bg-black/30 text-white text-sm rounded px-2 py-1 border border-white/10"},[...p[36]||(p[36]=[g("option",{value:"trusted"},"Trusted",-1),g("option",{value:"observer"},"Observer",-1),g("option",{value:"untrusted"},"Untrusted",-1)])],40,Na)])]),g("div",Aa,[p[38]||(p[38]=g("p",{class:"text-xs text-white/40 mb-1"},"Added",-1)),g("p",Ca,M(o.value.added_at),1)]),o.value.last_state?(T(),E("div",$a,[p[39]||(p[39]=g("p",{class:"text-xs text-white/40 mb-2"},"Resource Usage",-1)),g("div",Ma,[g("div",null,"CPU: "+M(o.value.last_state.cpu_usage_percent?.toFixed(1)??"--")+"%",1),g("div",null,"Uptime: "+M(o.value.last_state.uptime_secs?_n(o.value.last_state.uptime_secs):"--"),1),g("div",null,"RAM: "+M(Mt(o.value.last_state.mem_used_bytes))+" / "+M(Mt(o.value.last_state.mem_total_bytes)),1),g("div",null,"Disk: "+M(Mt(o.value.last_state.disk_used_bytes))+" / "+M(Mt(o.value.last_state.disk_total_bytes)),1)])])):L("",!0),o.value.last_state?.apps?.length?(T(),E("div",Sa,[g("p",Ea,"Apps ("+M(o.value.last_state.apps.length)+")",1),g("div",Ta,[(T(!0),E(dt,null,St(o.value.last_state.apps,N=>(T(),E("div",{key:N.id,class:"flex items-center justify-between text-sm"},[g("span",Ra,M(N.id),1),g("span",{class:J(["text-xs",N.status==="running"?"text-green-400":"text-white/40"])},M(N.status),3)]))),128))])])):L("",!0),o.value.trust_level==="trusted"?(T(),E("div",Da,[p[40]||(p[40]=g("p",{class:"text-xs text-white/40 mb-2"},"Deploy App",-1)),g("div",Ia,[be(g("input",{"onUpdate:modelValue":p[6]||(p[6]=N=>_.value=N),placeholder:"App ID (e.g. bitcoin)",class:"flex-1 bg-black/30 text-white text-sm rounded px-2 py-1.5 border border-white/10 focus:border-orange-400/50 focus:outline-none"},null,512),[[ke,_.value]]),g("button",{onClick:p[7]||(p[7]=N=>wn(o.value.did)),class:"px-3 py-1.5 glass-button rounded text-xs text-white/90 font-medium disabled:opacity-50",disabled:x.value||!_.value.trim()},M(x.value?"Deploying...":"Deploy"),9,Fa)]),f.value?(T(),E("p",{key:0,class:J(["text-xs mt-2",f.value.startsWith("Error")?"text-red-400":"text-green-400"])},M(f.value),3)):L("",!0)])):L("",!0),g("div",Ba,[g("div",Pa,[p[41]||(p[41]=g("p",{class:"text-xs text-white/40"},"DWN Sync",-1)),g("div",Ha,[g("span",{class:J(["w-1.5 h-1.5 rounded-full",P.value])},null,2),g("span",za,M(st.value),1)])]),g("div",La,[g("div",null,[p[42]||(p[42]=g("span",{class:"text-white/30"},"Messages:",-1)),ot(" "+M(R.value?.message_count??"--"),1)]),g("div",null,[p[43]||(p[43]=g("span",{class:"text-white/30"},"Last sync:",-1)),ot(" "+M(R.value?.last_sync?me(R.value.last_sync):"never"),1)])]),g("button",{onClick:mn,class:"px-3 py-1.5 glass-button rounded text-xs text-white/90 font-medium disabled:opacity-50",disabled:B.value},M(B.value?"Syncing...":"Sync Now"),9,Xa)]),m.value?(T(),E("div",Va,[p[44]||(p[44]=g("p",{class:"text-sm text-red-400 mb-3"},"Are you sure? This node will be removed from your federation.",-1)),g("div",Ua,[g("button",{onClick:p[9]||(p[9]=N=>m.value=!1),class:"flex-1 px-3 py-1.5 glass-button rounded text-sm text-white/70"},"Cancel"),g("button",{onClick:p[10]||(p[10]=N=>yn(o.value.did)),class:"flex-1 px-3 py-1.5 rounded text-sm text-red-400 border border-red-400/30 hover:bg-red-400/10 transition-colors font-medium"},"Confirm Remove")])])):(T(),E("div",Oa,[g("button",{onClick:p[8]||(p[8]=N=>m.value=!0),class:"w-full mt-4 px-4 py-2 rounded text-sm text-red-400 border border-red-400/30 hover:bg-red-400/10 transition-colors"}," Remove from Federation ")]))])])])):L("",!0),c.value?(T(),E("div",{key:4,class:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/10 backdrop-blur-md",onClick:p[15]||(p[15]=_e(N=>c.value=!1,["self"]))},[g("div",Ya,[g("div",qa,[p[46]||(p[46]=g("h2",{class:"text-xl font-semibold text-white"},"Join Federation",-1)),g("button",{onClick:p[12]||(p[12]=N=>c.value=!1),class:"text-white/40 hover:text-white/70 transition-colors"},[...p[45]||(p[45]=[g("svg",{class:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[g("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)])])]),p[47]||(p[47]=g("p",{class:"text-sm text-white/60 mb-4"},"Paste the invite code from the node you want to federate with.",-1)),be(g("textarea",{"onUpdate:modelValue":p[13]||(p[13]=N=>v.value=N),placeholder:"fed1:...",rows:"3",class:"w-full bg-black/30 text-white text-sm rounded-lg p-3 border border-white/10 focus:border-orange-400/50 focus:outline-none font-mono resize-none"},null,512),[[ke,v.value]]),h.value?(T(),E("div",Ga,M(h.value),1)):L("",!0),b.value?(T(),E("div",Ja,"Successfully joined federation")):L("",!0),g("div",Wa,[g("button",{onClick:p[14]||(p[14]=N=>c.value=!1),class:"flex-1 px-4 py-2 glass-button rounded text-sm text-white/70"},"Cancel"),g("button",{onClick:Jt,class:"flex-1 px-4 py-2 glass-button rounded text-sm text-white font-medium disabled:opacity-50",disabled:d.value||!v.value.trim()},M(d.value?"Joining...":"Join"),9,Ka)])])])):L("",!0)]))}});export{ja as default};