UNPKG

@fntio/infra-client

Version:

Self-hosted AWS access portal: credential vending, target-account trust, and grant-driven private networking as CDK stacks and constructs.

2 lines • 67.8 kB
import{a as gt}from"./chunk-KRQ75YR4.js";import{a as _t}from"./chunk-ONQGCLFI.js";import{a as rt,b as at,c as Ce,d as lt,e as ct,f as pt,g as ve}from"./chunk-HG4PBSMW.js";import{a as re}from"./chunk-64ITJKG6.js";import{a as et,l as ot}from"./chunk-K4OFWFQE.js";import{a as B}from"./chunk-7DUEGRIY.js";import{a as st}from"./chunk-QAZJZDEE.js";import{a as xe}from"./chunk-BG475WXG.js";import{a as X}from"./chunk-WM5A6BAU.js";import{a as dt,c as be,d as ut,e as mt}from"./chunk-JNANYFF2.js";import{a as A}from"./chunk-YMC4QOLO.js";import{b as $e,d as it}from"./chunk-6NTXC6VK.js";import{a as fe}from"./chunk-6HVGPPAG.js";import{a as ge}from"./chunk-IVXFG5AJ.js";import{a as tt,b as nt,d as he}from"./chunk-2SO4BVIT.js";import{a as se,b as le,e as ce,g as Ke,i as pe,j as de,k as ue,l as Je,m as Ze,n as me,o as _e,p as $}from"./chunk-T5HLFYHP.js";import{c as O}from"./chunk-KCJ5HNXP.js";import{a as ae}from"./chunk-3SC2PPSK.js";import{a as Q}from"./chunk-B67EMZ2H.js";import{b as q}from"./chunk-MID2IYAR.js";import{a as V}from"./chunk-7A4HO4AV.js";import{c as Y}from"./chunk-ZRDXKVPG.js";import{$a as Qe,Aa as i,Ba as r,Ca as y,Da as H,Ea as W,Eb as Xe,Fa as te,I as S,Ia as Ve,Ja as C,K as g,Ka as We,L as h,La as _,Ma as Re,Na as c,Oa as U,Pa as F,Q as ze,R as v,Ra as Ie,Sa as Ue,Ta as Oe,U as He,Ua as Ye,Va as T,Wa as ne,X as De,Xa as l,Ya as x,Za as w,_ as a,_a as D,g as je,ga as P,jb as qe,k as Fe,ka as J,m as Le,nb as Z,qb as f,rb as oe,s as Ge,sa as z,sb as N,ta as u,tb as b,ua as m,ub as Ae,wa as ee,wb as ie,xa as k,ya as M,za as d}from"./chunk-FYA6QUPZ.js";import{a as L,b as G,e as j}from"./chunk-WFIHWVQO.js";var wt=[[["","groupActions",""]],"*"],St=["[groupActions]","*"],ye=class n{title=b.required();count=b(0);noun=b("role");summary=b(null);open=ie(!1);static \u0275fac=function(e){return new(e||n)};static \u0275cmp=P({type:n,selectors:[["app-project-group"]],hostVars:2,hostBindings:function(e,o){e&2&&T("open",o.open())},inputs:{title:[1,"title"],count:[1,"count"],noun:[1,"noun"],summary:[1,"summary"],open:[1,"open"]},outputs:{open:"openChange"},ngContentSelectors:St,decls:12,vars:6,consts:[[1,"projhead"],["type","button",1,"toggle",3,"click"],["name","chevron-right",1,"chev"],[1,"projtitle"],[1,"projcount"],[1,"projbody"],[1,"grid-clip"],[1,"projbody-inner"]],template:function(e,o){e&1&&(U(wt),i(0,"div",0)(1,"button",1),_("click",function(){return o.open.set(!o.open())}),y(2,"app-icon",2),i(3,"span",3),l(4),r(),i(5,"span",4),l(6),r()(),F(7),r(),i(8,"div",5)(9,"div",6)(10,"div",7),F(11,1),r()()()),e&2&&(a(2),T("open",o.open()),a(2),x(o.title()),a(2),w("\xB7 ",o.summary()??o.count()+" "+o.noun()+(o.count()===1?"":"s")),a(2),T("open",o.open()))},dependencies:[q],styles:["[_nghost-%COMP%]{display:block;margin-left:-18px;margin-right:-18px;border:1px solid transparent;border-radius:calc(var(--radius) * 3);transition:border-color .22s ease,background-color .22s ease}.open[_nghost-%COMP%]{border-color:var(--border)}.projhead[_ngcontent-%COMP%]{display:flex;align-items:center;gap:10px;padding-right:18px}.toggle[_ngcontent-%COMP%]{flex:1;min-width:0;display:flex;align-items:center;gap:10px;padding:16px 18px;background:none;border:none;font:inherit;cursor:pointer;text-align:left}.projtitle[_ngcontent-%COMP%]{font-size:13px;font-weight:600;color:var(--surface-foreground)}.projcount[_ngcontent-%COMP%]{font-size:11px;font-weight:500;color:var(--text-secondary)}.chev[_ngcontent-%COMP%]{width:16px;height:16px;color:var(--muted-foreground);transform:rotate(90deg);transition:transform .22s ease;flex-shrink:0}.chev.open[_ngcontent-%COMP%]{transform:rotate(-90deg)}.projbody[_ngcontent-%COMP%]{display:grid;grid-template-rows:0fr;transition:grid-template-rows .26s ease}.projbody.open[_ngcontent-%COMP%]{grid-template-rows:1fr}.grid-clip[_ngcontent-%COMP%]{overflow:hidden;min-height:0}.projbody-inner[_ngcontent-%COMP%]{padding:4px 18px 18px}"]})};var kt=(n,t)=>t.label;function Mt(n,t){if(n&1&&(i(0,"div")(1,"span",9),l(2),r(),i(3,"div",10)(4,"div",11)(5,"code",12),l(6),r()(),i(7,"div",13),y(8,"app-copy-button",14),r()()()),n&2){let e=t.$implicit;a(2),x(e.label),a(4),x(e.value),a(2),d("text",e.value)}}function Pt(n,t){if(n&1&&(i(0,"p",3),l(1," This resource covers an address range with no single hostname, so there's no one command to connect \u2014 use a specific host inside "),i(2,"code",15),l(3),r(),l(4,". "),r()),n&2){let e=c();a(3),x(e.resource().cidr)}}function Tt(n,t){n&1&&l(0," (connect from the desktop app first) ")}function Nt(n,t){if(n&1&&(i(0,"div",5)(1,"app-banner",16),l(2),r()()),n&2){let e=t,o=c();a(),d("tone",e.ok?"success":"warning"),a(),x(o.probeText(e))}}function Et(n,t){if(n&1){let e=C();i(0,"app-button",17),_("click",function(){g(e);let s=c();return h(s.probe())}),l(1," Test connection "),r()}if(n&2){let e=c();d("loading",e.probing())}}var we=class n{bridge=S(Y);resource=b.required();closed=N();host=f(()=>{let t=this.resource();return t.dnsName?t.dnsName:t.cidr.endsWith("/32")?t.cidr.slice(0,-3):t.cidr});hasHost=f(()=>{let t=this.resource();return!!t.dnsName||t.cidr.endsWith("/32")});vars=f(()=>{let t=this.resource(),e=[{label:"Account ID",value:t.accountNumber},{label:this.hasHost()?"Host":"Address range",value:this.host()},{label:t.ports.length===1?"Port":"Ports",value:t.ports.join(", ")}];if(!this.hasHost())return e;switch(t.type){case"DATABASE":e.push({label:"psql command",value:`psql -h ${this.host()} -p ${t.ports[0]??5432}`});break;case"WEB":e.push({label:"URL",value:this.webUrl()});break;case"HOST":if(t.ports.includes(22)){let o=t.sshUser?`${t.sshUser}@${this.host()}`:this.host();e.push({label:"SSH command",value:`ssh ${o}`})}break}return e});webUrl=f(()=>{let t=this.resource();if(t.ports.includes(443)||t.ports.includes(8443))return`https://${this.host()}`;let e=t.ports.includes(80)?void 0:t.ports[0];return`http://${this.host()}${e?":"+e:""}`});probeTarget=f(()=>{let t=this.resource(),e=t.ports[0];return e===void 0?null:t.dnsName?{host:t.dnsName,port:e}:t.cidr.endsWith("/32")?{host:t.cidr.slice(0,-3),port:e}:null});canProbe=f(()=>this.bridge.isDesktop&&this.bridge.probeSupported&&this.probeTarget()!==null);probing=v(!1);probeResult=v(null);probe(){return j(this,null,function*(){let t=this.probeTarget();if(!t||this.probing())return;this.probing.set(!0),this.probeResult.set(null);let e=yield this.bridge.networkProbe(t.host,t.port).catch(()=>({ok:!1,reason:"timeout"}));this.probeResult.set(e),this.probing.set(!1)})}probeText(t){let e=this.probeTarget(),o=e?`${e.host}:${e.port}`:"";if(t.ok)return`Reached ${o} \u2014 the resource is answering.`;switch(t.reason){case"vpn-down":return"You\u2019re not connected to the VPN. Connect first, then test again.";case"refused":return`The host answered but refused port ${e?.port} \u2014 the resource itself may be down.`;case"busy":return"Another test is still running \u2014 try again in a moment.";case"bad-target":return"This resource\u2019s address can\u2019t be tested automatically.";default:return`No answer from ${o}. If you connected in the last few minutes, access rules may still be syncing \u2014 try again shortly.`}}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=P({type:n,selectors:[["app-resource-vars-dialog"]],inputs:{resource:[1,"resource"]},outputs:{closed:"closed"},decls:17,vars:5,consts:[["title","Connection details",3,"closed"],[1,"mb-3","text-sm","font-medium","text-surface-foreground"],[1,"space-y-3"],[1,"mt-3","text-xs","text-muted-foreground"],[1,"mt-4","text-xs","text-muted-foreground"],[1,"mt-4"],[1,"mt-5","flex","items-center","justify-between","gap-2"],["variant","outline",3,"loading"],["variant","outline",3,"click"],[1,"mb-1","block","text-sm","font-medium","text-surface-foreground"],[1,"relative"],[1,"overflow-x-auto","rounded-lg","bg-gray-900","p-3","pr-14","ring-1","ring-brand/20"],[1,"whitespace-nowrap","font-mono","text-xs","text-gray-100"],[1,"absolute","right-2","top-1/2","-translate-y-1/2"],["variant","icon",3,"text"],[1,"rounded","bg-muted","px-1"],[3,"tone"],["variant","outline",3,"click","loading"]],template:function(e,o){if(e&1&&(i(0,"app-dialog",0),_("closed",function(){return o.closed.emit()}),i(1,"p",1),l(2),r(),i(3,"div",2),k(4,Mt,9,3,"div",null,kt),r(),u(6,Pt,5,1,"p",3),i(7,"p",4),l(8," Reachable only while you're connected to the VPN "),u(9,Tt,1,0),l(10," \u2014 access changes take up to 5 minutes to reach the network. "),r(),u(11,Nt,3,2,"div",5),i(12,"div",6)(13,"div"),u(14,Et,2,1,"app-button",7),r(),i(15,"app-button",8),_("click",function(){return o.closed.emit()}),l(16,"Close"),r()()()),e&2){let s;a(2),x(o.resource().name),a(2),M(o.vars()),a(2),m(o.hasHost()?-1:6),a(3),m(o.bridge.isDesktop?-1:9),a(2),m((s=o.probeResult())?11:-1,s),a(3),m(o.canProbe()?14:-1)}},dependencies:[ae,V,Q,re],encapsulation:2})};function Dt(n,t){if(n&1){let e=C();i(0,"app-resource-vars-dialog",2),_("closed",function(){g(e);let s=c();return h(s.varsOpen.set(!1))}),r()}if(n&2){let e=c();d("resource",e.resource())}}var Vt={DATABASE:"resource-database",WEB:"resource-web",HOST:"resource-host"},Se=class n{resource=b.required();host=f(()=>{let t=this.resource();return t.dnsName?t.dnsName:t.cidr.endsWith("/32")?t.cidr.slice(0,-3):t.cidr});hasHost=f(()=>{let t=this.resource();return!!t.dnsName||t.cidr.endsWith("/32")});typeIcon=f(()=>Vt[this.resource().type]);typeLabel=f(()=>{let t=this.resource().type;return t==="DATABASE"?"Database":t==="WEB"?"Web":"Host"});grant=f(()=>{let t=this.resource().expiresAt;return t?`expires ${this.expiresIn(t)}`:""});grantTitle=f(()=>{let t=this.resource().expiresAt;return t?`Access ends ${this.exact(t)}`:""});webUrl=f(()=>{let t=this.resource();if(t.ports.includes(443)||t.ports.includes(8443))return`https://${this.host()}`;let e=t.ports.includes(80)?void 0:t.ports[0];return`http://${this.host()}${e?":"+e:""}`});varsOpen=v(!1);expiresIn(t){return he(t)}exact(t){let e=new Date(t);return Number.isNaN(e.getTime())?"":e.toLocaleString()}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=P({type:n,selectors:[["app-resource-card"]],inputs:{resource:[1,"resource"]},decls:2,vars:11,consts:[["kind","resource",3,"connectionDetails","icon","account","typeLabel","grant","grantTitle","accountName","accountId","rawAccountId","description","connectionUrl"],[3,"resource"],[3,"closed","resource"]],template:function(e,o){e&1&&(i(0,"app-role-card",0),_("connectionDetails",function(){return o.varsOpen.set(!0)}),r(),u(1,Dt,1,1,"app-resource-vars-dialog",1)),e&2&&(d("icon",o.typeIcon())("account",o.resource().name)("typeLabel",o.typeLabel())("grant",o.grant())("grantTitle",o.grantTitle())("accountName",o.resource().accountName||o.resource().accountNumber)("accountId",o.resource().accountNumber)("rawAccountId",o.resource().accountNumber)("description",o.resource().description||"")("connectionUrl",o.resource().type==="WEB"&&o.hasHost()?o.webUrl():void 0),a(),m(o.varsOpen()?1:-1))},dependencies:[_t,we],encapsulation:2})};function Rt(n,t){if(n&1){let e=C();H(0,"button",3),Re("click",function(){g(e);let s=c();return h(s.connect.emit())}),l(1,"Connect"),W()}if(n&2){let e=c();We("title",e.connectTitle())}}function It(n,t){if(n&1){let e=C();H(0,"button",4),Re("click",function(){g(e);let s=c();return h(s.connect.emit())}),l(1," Switch & connect "),W()}}function Ot(n,t){n&1&&(H(0,"span",2),te(1,"span",5),l(2," Connecting\u2026"),W())}function qt(n,t){n&1&&(H(0,"span",2),te(1,"span",6),l(2," Disconnecting\u2026"),W())}function At(n,t){if(n&1&&(H(0,"span",2),te(1,"span",8),l(2),W()),n&2){let e=c(2);T("ok",e.connectedTone()==="ok")("warn",e.connectedTone()==="warn"),a(2),w(" ",e.connectedLabel()," ")}}function $t(n,t){if(n&1&&u(0,At,3,5,"span",7),n&2){let e=c();m(e.connectedLabel()?0:-1)}}var K=class n{status=b("none");connectTitle=b("Connects the VPN to this network.");connectedLabel=b("");connectedTone=b("ok");connect=N();static \u0275fac=function(e){return new(e||n)};static \u0275cmp=P({type:n,selectors:[["app-vpn-control"]],inputs:{status:[1,"status"],connectTitle:[1,"connectTitle"],connectedLabel:[1,"connectedLabel"],connectedTone:[1,"connectedTone"]},outputs:{connect:"connect"},decls:5,vars:1,consts:[["type","button",1,"connectbtn",3,"title"],["type","button","title","Your VPN is connected to a different site \u2014 switching moves the whole connection over (one site at a time).",1,"connectbtn"],[1,"pill"],["type","button",1,"connectbtn",3,"click","title"],["type","button","title","Your VPN is connected to a different site \u2014 switching moves the whole connection over (one site at a time).",1,"connectbtn",3,"click"],[1,"dot","amber","pulse"],[1,"dot","pulse"],[1,"pill",3,"ok","warn"],[1,"dot"]],template:function(e,o){if(e&1&&u(0,Rt,2,1,"button",0)(1,It,2,0,"button",1)(2,Ot,3,0,"span",2)(3,qt,3,0,"span",2)(4,$t,1,1),e&2){let s;m((s=o.status())==="off"?0:s==="off-site"?1:s==="connecting"?2:s==="disconnecting"?3:s==="connected"?4:-1)}},styles:["[_nghost-%COMP%]{display:contents}.pill[_ngcontent-%COMP%]{flex-shrink:0;display:inline-flex;align-items:center;gap:6px;padding:3px 10px;border-radius:999px;font-size:11.5px;font-weight:600;white-space:nowrap;color:var(--muted-foreground);border:1px solid var(--border-strong)}.pill.ok[_ngcontent-%COMP%]{color:var(--success);background:var(--success-muted);border-color:color-mix(in oklab,var(--success) 30%,transparent)}.dot[_ngcontent-%COMP%]{width:7px;height:7px;border-radius:999px;flex-shrink:0;background:var(--placeholder, #9ca3af)}.pill.ok[_ngcontent-%COMP%]   .dot[_ngcontent-%COMP%]{background:var(--dot-active, #10b981)}.pill.warn[_ngcontent-%COMP%]{color:var(--warning);background:var(--warning-muted);border-color:color-mix(in oklab,var(--warning) 30%,transparent)}.pill.warn[_ngcontent-%COMP%]   .dot[_ngcontent-%COMP%], .dot.amber[_ngcontent-%COMP%]{background:var(--dot-expiring, #f59e0b)}.dot.pulse[_ngcontent-%COMP%]{animation:_ngcontent-%COMP%_vpnpulse 1.2s ease-in-out infinite}@keyframes _ngcontent-%COMP%_vpnpulse{50%{opacity:.35}}.connectbtn[_ngcontent-%COMP%]{flex-shrink:0;padding:4px 12px;border-radius:999px;font-size:12px;font-weight:600;cursor:pointer;color:var(--brand-text);background:none;border:1px solid color-mix(in oklab,var(--brand-text) 50%,transparent);transition:background-color .15s ease,border-color .15s ease}.connectbtn[_ngcontent-%COMP%]:hover{background:var(--brand-muted);border-color:var(--brand-text)}"]})};var Bt=["*"];function jt(n,t){if(n&1&&(i(0,"span",4),l(1),r()),n&2){let e=c();a(),w("\xB7 ",e.detail())}}function Ft(n,t){if(n&1&&(i(0,"span",5),l(1),r()),n&2){let e=c();a(),x(e.site())}}function Lt(n,t){n&1&&(i(0,"span",9),y(1,"span",11),l(2," No answer "),r())}function Gt(n,t){if(n&1&&(i(0,"span",10),y(1,"span",12),l(2," Reachable "),r()),n&2){let e=c(2);d("title",e.probe()==="checking"?"Checking that this VPC answers\u2026":"Reachable through your VPN connection."),a(),T("pulse",e.probe()==="checking")}}function zt(n,t){if(n&1&&u(0,Lt,3,0,"span",9)(1,Gt,3,3,"span",10),n&2){let e=c();m(e.probe()==="no-response"?0:1)}}function Ht(n,t){if(n&1){let e=C();i(0,"app-vpn-control",14),_("connect",function(){g(e);let s=c(2);return h(s.connect.emit())}),r()}if(n&2){let e=c(2);d("status",e.status())}}function Wt(n,t){if(n&1&&u(0,Ht,1,1,"app-vpn-control",13),n&2){let e=c();m(e.control()?0:-1)}}var ke=class n{label=b.required();detail=b(null);site=b(null);count=b.required();status=b("none");control=b(!0);probe=b(null);open=ie(!0);connect=N();static \u0275fac=function(e){return new(e||n)};static \u0275cmp=P({type:n,selectors:[["app-vpc-group"]],hostVars:2,hostBindings:function(e,o){e&2&&T("open",o.open())},inputs:{label:[1,"label"],detail:[1,"detail"],site:[1,"site"],count:[1,"count"],status:[1,"status"],control:[1,"control"],probe:[1,"probe"],open:[1,"open"]},outputs:{open:"openChange",connect:"connect"},ngContentSelectors:Bt,decls:15,vars:12,consts:[[1,"vpchead"],["type","button",1,"toggle",3,"click"],["name","chevron-right",1,"chev",3,"strokeWidth"],[1,"label"],[1,"count"],[1,"sitechip"],[1,"vpcbody"],[1,"grid-clip"],[1,"inner"],["title","Your VPN is up but this VPC didn't answer \u2014 if you connected in the last few minutes, access rules may still be syncing.",1,"pill","warn"],[1,"pill","ok",3,"title"],[1,"dot","warn"],[1,"dot","ok"],["connectTitle","Connects the VPN to this VPC's network.",3,"status"],["connectTitle","Connects the VPN to this VPC's network.",3,"connect","status"]],template:function(e,o){if(e&1&&(U(),i(0,"div",0)(1,"button",1),_("click",function(){return o.open.set(!o.open())}),y(2,"app-icon",2),i(3,"span",3),l(4),r(),u(5,jt,2,1,"span",4),i(6,"span",4),l(7),r(),u(8,Ft,2,1,"span",5),r(),u(9,zt,2,1)(10,Wt,1,1),r(),i(11,"div",6)(12,"div",7)(13,"div",8),F(14),r()()()),e&2){let s;a(),z("aria-expanded",o.open()),a(),T("open",o.open()),d("strokeWidth",2.2),a(2),x(o.label()),a(),m(o.detail()?5:-1),a(2),D("\xB7 ",o.count()," resource",o.count()===1?"":"s"),a(),m(o.site()?8:-1),a(),m((s=o.status())==="connected"?9:10),a(2),T("open",o.open())}},dependencies:[q,K],styles:["[_nghost-%COMP%]{display:block;overflow:hidden;border:1px solid var(--border);border-radius:var(--radius)}.vpchead[_ngcontent-%COMP%]{display:flex;align-items:center;gap:10px;padding-right:12px;background:var(--card-bg);transition:background-color .15s ease}.vpchead[_ngcontent-%COMP%]:hover{background:var(--state-hover)}.toggle[_ngcontent-%COMP%]{flex:1;min-width:0;display:flex;align-items:center;gap:8px;padding:8px 12px 8px 16px;background:none;border:none;font:inherit;cursor:pointer;text-align:left}.chev[_ngcontent-%COMP%]{width:10px;height:10px;color:var(--muted-foreground);transition:transform .2s ease;flex-shrink:0}.chev.open[_ngcontent-%COMP%]{transform:rotate(90deg)}.label[_ngcontent-%COMP%]{font-size:13px;font-weight:600;color:var(--surface-foreground);overflow-wrap:anywhere}.count[_ngcontent-%COMP%]{font-size:11px;font-weight:500;color:var(--text-secondary);white-space:nowrap}.pill[_ngcontent-%COMP%]{flex-shrink:0;display:inline-flex;align-items:center;gap:6px;padding:3px 10px;border-radius:999px;font-size:11.5px;font-weight:600;white-space:nowrap}.pill.ok[_ngcontent-%COMP%]{color:var(--success);background:var(--success-muted);border:1px solid color-mix(in oklab,var(--success) 30%,transparent)}.pill.warn[_ngcontent-%COMP%]{color:var(--warning);background:var(--warning-muted);border:1px solid color-mix(in oklab,var(--warning) 30%,transparent)}.dot[_ngcontent-%COMP%]{width:7px;height:7px;border-radius:999px;flex-shrink:0}.dot.ok[_ngcontent-%COMP%]{background:var(--dot-active, #10b981)}.dot.warn[_ngcontent-%COMP%]{background:var(--dot-expiring, #f59e0b)}.dot.pulse[_ngcontent-%COMP%]{animation:_ngcontent-%COMP%_vpcpulse 1.2s ease-in-out infinite}@keyframes _ngcontent-%COMP%_vpcpulse{50%{opacity:.35}}.vpcbody[_ngcontent-%COMP%]{display:grid;grid-template-rows:0fr;transition:grid-template-rows .2s ease-out}.vpcbody.open[_ngcontent-%COMP%]{grid-template-rows:1fr}.grid-clip[_ngcontent-%COMP%]{overflow:hidden;min-height:0}.inner[_ngcontent-%COMP%]{padding:12px}.sitechip[_ngcontent-%COMP%]{margin-left:4px;padding:1px 8px;border-radius:999px;background:var(--muted);font-size:11px;font-weight:500;color:var(--text-secondary)}"]})};var ht=(n,t)=>t.resourceId,Yt=(n,t)=>t.key;function Qt(n,t){n&1&&(i(0,"app-empty-state",0),l(1," You already have \u2014 or have already requested \u2014 every registered resource. "),r())}function Xt(n,t){if(n&1&&(i(0,"span",8),l(1),r()),n&2){let e=c().$implicit;a(),x(e.message)}}function Kt(n,t){if(n&1&&(i(0,"div",3)(1,"span"),l(2),r(),i(3,"span",6)(4,"span",7),l(5),r(),u(6,Xt,2,1,"span",8),r()()),n&2){let e=t.$implicit;a(),ne(e.ok?"text-success":"text-danger"),a(),x(e.ok?"\u2713":"\u2715"),a(3),x(e.name),a(),m(e.message?6:-1)}}function Jt(n,t){if(n&1){let e=C();i(0,"p",1),l(1),r(),i(2,"div",2),k(3,Kt,7,5,"div",3,ht),r(),i(5,"div",4)(6,"app-button",5),_("click",function(){g(e);let s=c(2);return h(s.closed.emit())}),l(7,"Done"),r()()}if(n&2){let e=t,o=c(2);a(),Qe(" ",o.sentCount()," of ",e.length," request",e.length===1?"":"s"," sent \u2014 you'll see decisions in the activity bell. "),a(2),M(e)}}function Zt(n,t){if(n&1&&u(0,Jt,8,3),n&2){let e,o=c();m((e=o.results())?0:-1,e)}}function en(n,t){n&1&&l(0),n&2&&w(" \xB7 ",t," ")}function tn(n,t){if(n&1&&(i(0,"span",28),l(1),r()),n&2){let e=c().$implicit;a(),x(e.description)}}function nn(n,t){if(n&1){let e=C();i(0,"label",23)(1,"input",24),_("change",function(){let s=g(e).$implicit,p=c(3);return h(p.toggle(s.resourceId))}),r(),i(2,"span",6)(3,"span",25)(4,"span",26),l(5),r(),i(6,"app-badge",27),l(7),r()(),u(8,tn,2,1,"span",28),r()()}if(n&2){let e=t.$implicit,o=c(3);a(),d("checked",o.picked().has(e.resourceId)),a(4),x(e.name),a(2),x(o.typeLabel(e.type)),a(),m(e.description?8:-1)}}function on(n,t){if(n&1&&(i(0,"div")(1,"p",21),l(2),u(3,en,1,1),r(),i(4,"div",22),k(5,nn,9,4,"label",23,ht),r()()),n&2){let e,o=t.$implicit,s=c(2);a(2),w(" ",s.titleOf(o)," "),a(),m((e=s.vpcLabels().get(o.key))?3:-1,e),a(2),M(o.resources)}}function rn(n,t){if(n&1&&(i(0,"p",11),l(1),r()),n&2){let e=c(2);a(),w('No available resources match "',e.query(),'".')}}function an(n,t){if(n&1&&(i(0,"option",15),l(1),r()),n&2){let e=t.$implicit,o=c(2);d("ngValue",e),a(),x(o.label(e))}}function sn(n,t){if(n&1){let e=C();i(0,"input",9),_("ngModelChange",function(s){g(e);let p=c();return h(p.query.set(s))}),r(),i(1,"div",10),k(2,on,7,2,"div",null,Yt,!1,rn,2,1,"p",11),r(),i(5,"div",12)(6,"app-field",13)(7,"select",14),_("ngModelChange",function(s){g(e);let p=c();return h(p.duration.set(s))}),k(8,an,2,2,"option",15,ee),i(10,"option",15),l(11,"Long-term (indefinite)"),r()()(),i(12,"app-field",16)(13,"textarea",17),_("ngModelChange",function(s){g(e);let p=c();return h(p.reason.set(s))}),r()()(),i(14,"div",18)(15,"app-button",19),_("click",function(){g(e);let s=c();return h(s.closed.emit())}),l(16,"Cancel"),r(),i(17,"app-button",20),_("click",function(){g(e);let s=c();return h(s.send())}),l(18),r()()}if(n&2){let e=c();d("ngModel",e.query()),a(2),M(e.filteredGroups()),a(5),d("ngModel",e.duration()),a(),M(e.PRESETS),a(2),d("ngValue","long"),a(2),d("error",e.error()),a(),d("maxlength",e.REASON_MAX)("ngModel",e.reason()),a(4),d("loading",e.busy())("disabled",e.picked().size===0),a(),D(" Request ",e.picked().size||""," resource",e.picked().size===1?"":"s"," ")}}var Me=class n{api=S(et);toast=S(O);notifications=S(ot);groups=b.required();vpcLabels=b(new Map);sentAny=N();closed=N();REASON_MAX=500;PRESETS=tt;query=v("");picked=v(new Set);duration=v("long");reason=v("");busy=v(!1);error=v("");results=v(null);filteredGroups=f(()=>{let t=this.query().trim().toLowerCase();return t?this.groups().map(e=>G(L({},e),{resources:e.resources.filter(o=>o.name.toLowerCase().includes(t)||(o.description??"").toLowerCase().includes(t)||this.titleOf(e).toLowerCase().includes(t))})).filter(e=>e.resources.length>0):this.groups()});sentCount=f(()=>(this.results()??[]).filter(t=>t.ok).length);titleOf(t){return t.accountName||t.accountNumber||"Unknown account"}typeLabel(t){return t==="DATABASE"?"Database":t==="WEB"?"Web":"Host"}label(t){return t==="long"?"long-term":nt(t)}toggle(t){this.picked.update(e=>{let o=new Set(e);return o.has(t)?o.delete(t):o.add(t),o})}resourceById(t){for(let e of this.groups()){let o=e.resources.find(s=>s.resourceId===t);if(o)return o}}send(){if(this.picked().size===0)return;this.error.set(""),this.busy.set(!0);let t=this.duration(),e=this.reason().trim()||void 0,o=[...this.picked()].map(s=>this.api.createResourceRequest(s,e,t==="long"?void 0:t).pipe(Fe(()=>({resourceId:s,name:this.resourceById(s)?.name??s,ok:!0})),Ge(p=>je({resourceId:s,name:this.resourceById(s)?.name??s,ok:!1,message:$(p,"Could not send the request")}))));Le(o).subscribe(s=>{this.busy.set(!1),this.results.set(s);let p=s.filter(E=>E.ok).length;p?(this.toast.success(`Sent ${p} request${p===1?"":"s"}`),this.notifications.load(),this.sentAny.emit()):this.toast.error("No requests were sent \u2014 see the details.")})}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=P({type:n,selectors:[["app-request-access-panel"]],inputs:{groups:[1,"groups"],vpcLabels:[1,"vpcLabels"]},outputs:{sentAny:"sentAny",closed:"closed"},decls:3,vars:1,consts:[["title","Nothing left to request"],[1,"mb-2","text-xs","text-muted-foreground"],[1,"max-h-72","overflow-y-auto","rounded-lg","border","border-border-strong"],[1,"flex","items-start","gap-2.5","border-b","border-border","px-3","py-2","text-sm","last:border-b-0"],[1,"mt-5","flex","justify-end"],[3,"click"],[1,"min-w-0","flex-1"],[1,"block","truncate","text-surface-foreground"],[1,"block","text-xs","text-danger"],["placeholder","Search available resources",1,"ui-input","mb-3",3,"ngModelChange","ngModel"],[1,"flex","flex-col","gap-4"],[1,"px-1","py-2","text-xs","text-muted-foreground"],[1,"mt-4","space-y-5"],["label","Access duration","hint","temporary access expires on its own; the admin has the final say"],[1,"ui-input",3,"ngModelChange","ngModel"],[3,"ngValue"],["label","Reason","hint","optional, sent with every request",3,"error"],["rows","3","placeholder","e.g. Need to query the staging database for the migration.",1,"ui-input",3,"ngModelChange","maxlength","ngModel"],[1,"mt-5","flex","justify-end","gap-2"],["variant","outline",3,"click"],[3,"click","loading","disabled"],[1,"ui-microlabel","mb-1","px-1","text-muted-foreground"],[1,"rounded-lg","border","border-border"],[1,"ui-check-row","border-b","border-border","text-sm","last:border-b-0"],["type","checkbox",1,"ui-checkbox",3,"change","checked"],[1,"flex","flex-wrap","items-center","gap-1.5"],[1,"min-w-0","truncate","font-medium","tracking-[0.015em]","text-surface-foreground"],["tone","gray"],[1,"mt-0.5","line-clamp-1","block","text-xs","text-muted-foreground"]],template:function(e,o){e&1&&u(0,Qt,2,0,"app-empty-state",0)(1,Zt,1,1)(2,sn,19,11),e&2&&m(o.groups().length===0?0:o.results()?1:2)},dependencies:[_e,de,ue,se,pe,le,me,ce,A,V,fe,ge],encapsulation:2})};var ln=["*"];function cn(n,t){if(n&1&&(i(0,"span",6),y(1,"span",7),l(2),r()),n&2){let e=c();T("ok",e.pillTone()==="ok")("warn",e.pillTone()==="warn"),a(2),w(" ",e.pill()," ")}}var Pe=class n{label=b.required();count=b.required();status=b("none");pill=b("");pillTone=b("quiet");connect=N();static \u0275fac=function(e){return new(e||n)};static \u0275cmp=P({type:n,selectors:[["app-share-box"]],inputs:{label:[1,"label"],count:[1,"count"],status:[1,"status"],pill:[1,"pill"],pillTone:[1,"pillTone"]},outputs:{connect:"connect"},ngContentSelectors:ln,decls:9,vars:5,consts:[[1,"head"],[1,"label"],[1,"count"],[1,"pill",3,"ok","warn"],[3,"connect","status"],[1,"inner"],[1,"pill"],[1,"dot"]],template:function(e,o){e&1&&(U(),i(0,"div",0)(1,"span",1),l(2),r(),i(3,"span",2),l(4),r(),u(5,cn,3,5,"span",3),i(6,"app-vpn-control",4),_("connect",function(){return o.connect.emit()}),r()(),i(7,"div",5),F(8),r()),e&2&&(a(2),x(o.label()),a(2),D("\xB7 ",o.count()," share",o.count()===1?"":"s"),a(),m(o.pill()&&(o.status()==="connected"||o.status()==="none")?5:-1),a(),d("status",o.status()))},dependencies:[K],styles:["[_nghost-%COMP%]{display:block;overflow:hidden;border:1px solid var(--border);border-radius:var(--radius)}.head[_ngcontent-%COMP%]{display:flex;align-items:center;gap:8px;padding:8px 12px 8px 16px;background:var(--card-bg)}.label[_ngcontent-%COMP%]{font-size:13px;font-weight:600;color:var(--surface-foreground)}.count[_ngcontent-%COMP%]{flex:1;font-size:11px;font-weight:500;color:var(--text-secondary);white-space:nowrap}.pill[_ngcontent-%COMP%]{flex-shrink:0;display:inline-flex;align-items:center;gap:6px;padding:3px 10px;border-radius:999px;font-size:11.5px;font-weight:600;white-space:nowrap;color:var(--muted-foreground);border:1px solid var(--border-strong)}.pill.ok[_ngcontent-%COMP%]{color:var(--success);background:var(--success-muted);border-color:color-mix(in oklab,var(--success) 30%,transparent)}.pill.warn[_ngcontent-%COMP%]{color:var(--warning);background:var(--warning-muted);border-color:color-mix(in oklab,var(--warning) 30%,transparent)}.dot[_ngcontent-%COMP%]{width:7px;height:7px;border-radius:999px;background:var(--placeholder, #9ca3af)}.pill.ok[_ngcontent-%COMP%]   .dot[_ngcontent-%COMP%]{background:var(--dot-active, #10b981)}.pill.warn[_ngcontent-%COMP%]   .dot[_ngcontent-%COMP%]{background:var(--dot-expiring, #f59e0b)}.inner[_ngcontent-%COMP%]{padding:12px}"]})};var pn=(n,t)=>t.kind+t.id;function dn(n,t){if(n&1&&(i(0,"app-chip",6),l(1),r()),n&2){let e=c();a(),x(e.siteName())}}function un(n,t){n&1&&(i(0,"app-chip",8),y(1,"span",17),l(2," Serving "),r())}function mn(n,t){n&1&&(i(0,"app-chip",6),y(1,"span",18),l(2," Starting\u2026 "),r())}function _n(n,t){n&1&&(i(0,"app-chip",9),y(1,"span",19),l(2," Not serving "),r())}function gn(n,t){n&1&&(i(0,"app-chip",6),y(1,"span",20),l(2," Paused "),r())}function hn(n,t){if(n&1&&(i(0,"app-badge",22),l(1),r()),n&2){let e=c().$implicit;a(),x(e.name)}}function fn(n,t){if(n&1&&(i(0,"span",23),l(1),r()),n&2){let e=c().$implicit;a(),x(e.name)}}function xn(n,t){if(n&1&&u(0,hn,2,1,"app-badge",22)(1,fn,2,1,"span",23),n&2){let e=t.$implicit;m(e.kind==="group"?0:1)}}function Cn(n,t){n&1&&(i(0,"span",12),l(1,"Device"),r(),i(2,"span",24),l(3),r()),n&2&&(a(3),x(t))}function vn(n,t){if(n&1&&(i(0,"span",12),l(1,"Shared with"),r(),i(2,"span",21),k(3,xn,2,1,null,null,pn),r(),u(5,Cn,4,1)),n&2){let e,o=c();a(3),M(o.owner().grantees),a(2),m((e=o.owner().device)?5:-1,e)}}function bn(n,t){if(n&1&&(i(0,"span",12),l(1,"From"),r(),i(2,"span",24),l(3),r()),n&2){let e=c();a(3),x(e.share().ownerName)}}function yn(n,t){if(n&1&&(i(0,"span",25),l(1),r(),y(2,"app-copy-button",26)),n&2){let e=t;a(),x(e),a(),d("text",e)}}function wn(n,t){n&1&&(i(0,"span",14),l(1,"address not reported yet"),r())}function Sn(n,t){if(n&1&&(i(0,"span",12),l(1,"Via"),r(),i(2,"span",27),l(3),r()),n&2){let e=c();a(3),x(e.guest().viaGroups.join(", "))}}function kn(n,t){if(n&1&&(i(0,"p",29),l(1),r()),n&2){let e=c(2);d("title",e.serveError()),a(),x(e.serveError())}}function Mn(n,t){if(n&1&&(i(0,"p",28),l(1," The relay isn't running on this device \u2014 teammates can still reach it if your dev server listens on all interfaces (0.0.0.0). "),r(),u(2,kn,2,2,"p",29)),n&2){let e=c();a(2),m(e.serveError()?2:-1)}}function Pn(n,t){if(n&1&&(i(0,"p",15),l(1),r()),n&2){let e=c();a(),w("Served while ",e.whereServed(),".")}}function Tn(n,t){n&1&&(i(0,"a",31),y(1,"app-icon",32),l(2," Open in browser "),r()),n&2&&d("href",t,De)}function Nn(n,t){if(n&1){let e=C();i(0,"button",30),_("click",function(){g(e);let s=c();return h(s.stop.emit())}),l(1," Stop sharing "),r(),u(2,Tn,3,1,"a",31)}if(n&2){let e,o=c();a(2),m((e=o.share().url)?2:-1,e)}}function En(n,t){n&1&&(i(0,"a",31),y(1,"app-icon",32),l(2," Open in browser "),r()),n&2&&d("href",t,De)}function Dn(n,t){if(n&1){let e=C();i(0,"button",33),_("click",function(){g(e);let s=c();return h(s.test.emit())}),l(1," Test connection "),r(),u(2,En,3,1,"a",31)}if(n&2){let e,o=c();T("border-r",!!o.share().url)("border-border",!!o.share().url),d("disabled",!o.canTest()||!o.onShareSite()),a(2),m((e=o.share().url)?2:-1,e)}}var Te=class n{network=S(B);share=b.required();mode=b.required();serveState=b(null);serveError=b("");canTest=b(!1);stop=N();test=N();owner=f(()=>this.mode()==="owner"?this.share():null);guest=f(()=>this.mode()==="guest"?this.share():null);expiresIn=f(()=>he(this.share().expiresAt));siteName=f(()=>this.network.siteName(this.share().siteId));whereServed=f(()=>this.network.sites().length>1?`you're connected to ${this.siteName()}`:"your VPN is connected");vpn=f(()=>ve(this.network.state(),this.network.activeSiteId(),this.network.pendingSiteId(),this.share().siteId));onShareSite=f(()=>this.vpn()==="connected");relay=f(()=>{if(this.mode()!=="owner")return null;switch(this.vpn()){case"connected":return this.serveState();case"off":case"off-site":return"paused";default:return null}});exact(t){let e=new Date(t);return Number.isNaN(e.getTime())?"":e.toLocaleString()}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=P({type:n,selectors:[["app-share-card"]],hostAttrs:[1,"flex","flex-col","overflow-hidden","rounded-2xl","border","border-border/70","bg-card-bg"],inputs:{share:[1,"share"],mode:[1,"mode"],serveState:[1,"serveState"],serveError:[1,"serveError"],canTest:[1,"canTest"]},outputs:{stop:"stop",test:"test"},decls:31,vars:13,consts:[[1,"flex","items-center","gap-4","px-5","pt-4"],[1,"grid","h-11","w-11","shrink-0","place-items-center","rounded-lg","bg-muted","text-muted-foreground"],["name","resource-host",1,"h-5","w-5"],[1,"min-w-0","flex-1"],[1,"truncate","text-base","font-semibold","tracking-[-0.01em]","text-surface-foreground"],[1,"mt-px","flex","flex-wrap","items-center","gap-2"],["tone","neutral"],["tone","warning",3,"title"],["tone","success"],["tone","warning"],[1,"px-5","py-4"],[1,"grid","items-baseline","gap-y-[7px]"],[1,"text-[12.5px]","text-text-secondary"],[1,"flex","min-w-0","items-start","gap-1"],[1,"text-[13.5px]","text-placeholder"],[1,"mt-2.5","text-xs","text-muted-foreground"],[1,"mt-auto","flex","border-t","border-border"],[1,"h-1.5","w-1.5","rounded-full","bg-[var(--dot-active,#10b981)]"],[1,"h-1.5","w-1.5","animate-pulse","rounded-full","bg-[var(--dot-expiring,#f59e0b)]"],[1,"h-1.5","w-1.5","rounded-full","bg-[var(--dot-expiring,#f59e0b)]"],[1,"h-1.5","w-1.5","rounded-full","bg-placeholder"],[1,"flex","min-w-0","flex-wrap","items-center","gap-1.5","text-[13.5px]","font-medium","text-surface-foreground"],["tone","gray","icon","users"],[1,"truncate"],[1,"truncate","text-[13.5px]","font-medium","text-surface-foreground"],[1,"font-mono","text-[13.5px]","leading-[18px]","text-muted-foreground","[overflow-wrap:anywhere]"],["variant","icon","label","Copy link",3,"text"],[1,"truncate","text-[13.5px]","text-muted-foreground"],[1,"mt-2.5","text-xs","text-warning"],[1,"mt-1","truncate","text-xs","text-muted-foreground",3,"title"],["type","button",1,"inline-flex","flex-1","items-center","justify-center","gap-1.5","border-r","border-border","px-2.5","py-3","text-[12.5px]","text-muted-foreground","transition-colors","hover:bg-muted",3,"click"],["target","_blank","rel","noopener",1,"inline-flex","flex-1","items-center","justify-center","gap-1.5","px-2.5","py-3","text-[12.5px]","text-brand-text","transition-colors","hover:bg-brand/12",3,"href"],["name","external-link",1,"h-[15px]","w-[15px]"],["type","button",1,"inline-flex","flex-1","items-center","justify-center","gap-1.5","px-2.5","py-3","text-[12.5px]","text-muted-foreground","transition-colors","hover:bg-muted","disabled:opacity-50",3,"click","disabled"]],template:function(e,o){if(e&1&&(i(0,"div",0)(1,"span",1),y(2,"app-icon",2),r(),i(3,"div",3)(4,"div",4),l(5),r(),i(6,"div",5)(7,"app-chip",6),l(8),r(),u(9,dn,2,1,"app-chip",6),i(10,"app-chip",7),l(11),r(),u(12,un,3,0,"app-chip",8)(13,mn,3,0,"app-chip",6)(14,_n,3,0,"app-chip",9)(15,gn,3,0,"app-chip",6),r()()(),i(16,"div",10)(17,"div",11),u(18,vn,6,1)(19,bn,4,1),i(20,"span",12),l(21,"URL"),r(),i(22,"span",13),u(23,yn,3,2)(24,wn,2,0,"span",14),r(),u(25,Sn,4,1),r(),u(26,Mn,3,1)(27,Pn,2,1,"p",15),r(),i(28,"div",16),u(29,Nn,3,1)(30,Dn,3,6),r()),e&2){let s,p,E,Be;a(5),w(" ",o.share().label," "),a(3),w("Port ",o.share().port),a(),m(o.network.sites().length>1?9:-1),a(),d("title","Ends "+o.exact(o.share().expiresAt)),a(),w("expires ",o.expiresIn()),a(),m((s=o.relay())==="serving"?12:s==="starting"?13:s==="failed"?14:s==="paused"?15:-1),a(5),Ye("grid-template-columns","76px minmax(0,1fr)"),a(),m(o.mode()==="owner"?18:19),a(5),m((p=o.share().url)?23:24,p),a(2),m(!((E=o.guest())==null||E.viaGroups==null)&&E.viaGroups.length?25:-1),a(),m((Be=o.relay())==="failed"?26:Be==="paused"?27:-1),a(3),m(o.mode()==="owner"?29:30)}},dependencies:[A,mt,re,q],encapsulation:2})};var Vn=(n,t)=>t.name,Rn=(n,t)=>t.userId,In=(n,t)=>t.groupId;function On(n,t){if(n&1){let e=C();i(0,"app-banner",0),l(1," Connect to the private network first (the Connect pill at the bottom of the sidebar) \u2014 a share is only reachable while you're on the site you share it on. "),r(),i(2,"div",1)(3,"app-button",2),_("click",function(){g(e);let s=c();return h(s.closed.emit())}),l(4,"Close"),r()()}}function qn(n,t){if(n&1&&(i(0,"option",14),l(1),r()),n&2){let e=t.$implicit;d("ngValue",e.name),a(),D("",e.name,"",e.online?"":" \xB7 offline")}}function An(n,t){if(n&1){let e=C();i(0,"div",8)(1,"app-field",21)(2,"select",13),_("ngModelChange",function(s){g(e);let p=c(2);return h(p.device.set(s))}),i(3,"option",14),l(4),r(),k(5,qn,2,3,"option",14,Vn),r()()()}if(n&2){let e=c(2);a(),d("hint","which of your devices on "+e.siteName()+" runs the dev server"),a(),d("ngModel",e.device()),a(),d("ngValue",""),a(),w("This device",e.selfName()?" \xB7 "+e.selfName():""),a(),M(e.otherDevices())}}function $n(n,t){n&1&&y(0,"app-skeleton",11)}function Bn(n,t){if(n&1){let e=C();i(0,"label",24)(1,"input",28),_("change",function(){let s=g(e).$implicit,p=c(4);return h(p.toggle("group#"+s.groupId))}),r(),i(2,"span",29)(3,"span",30),l(4),r(),i(5,"app-badge",31),l(6),r()()()}if(n&2){let e=t.$implicit,o=c(4);a(),d("checked",o.picked().has("group#"+e.groupId)),a(3),x(e.name),a(2),D("",e.members," member",e.members===1?"":"s")}}function jn(n,t){if(n&1){let e=C();i(0,"button",32),_("click",function(){g(e);let s=c(4);return h(s.groupsExpanded.set(!s.groupsExpanded()))}),i(1,"span",33),l(2,"\u25B8"),r(),l(3),r()}if(n&2){let e=c(4);a(),T("open",e.groupsExpanded()),a(2),w(" ",e.groupsExpanded()?"Show fewer":"Show "+e.hiddenGroups()+" more"," ")}}function Fn(n,t){if(n&1&&(i(0,"p",22),l(1,"Groups"),r(),i(2,"div",27),k(3,Bn,7,4,"label",24,In),u(5,jn,4,3,"button",26),r()),n&2){let e=c(3);a(3),M(e.visibleGroups()),a(2),m(!e.query().trim()&&(e.hiddenGroups()>0||e.groupsExpanded())?5:-1)}}function Ln(n,t){if(n&1){let e=C();i(0,"label",24)(1,"input",28),_("change",function(){let s=g(e).$implicit,p=c(3);return h(p.toggle("user#"+s.userId))}),r(),i(2,"span",34),l(3),r()()}if(n&2){let e=t.$implicit,o=c(3);a(),d("checked",o.picked().has("user#"+e.userId)),a(2),x(e.email)}}function Gn(n,t){if(n&1&&(i(0,"p",25),l(1),r()),n&2){let e=c(3);a(),w('No one matches "',e.query(),'".')}}function zn(n,t){if(n&1){let e=C();i(0,"button",32),_("click",function(){g(e);let s=c(3);return h(s.usersExpanded.set(!s.usersExpanded()))}),i(1,"span",33),l(2,"\u25B8"),r(),l(3),r()}if(n&2){let e=c(3);a(),T("open",e.usersExpanded()),a(2),w(" ",e.usersExpanded()?"Show fewer":"Show "+e.hiddenUsers()+" more"," ")}}function Hn(n,t){if(n&1&&(u(0,Fn,6,1),i(1,"p",22),l(2,"People"),r(),i(3,"div",23),k(4,Ln,4,2,"label",24,Rn,!1,Gn,2,1,"p",25),u(7,zn,4,3,"button",26),r()),n&2){let e=c(2);m(e.store.limits.allowGroupTargets&&e.groups().length?0:-1),a(4),M(e.visibleUsers()),a(3),m(!e.query().trim()&&(e.hiddenUsers()>0||e.usersExpanded())?7:-1)}}function Wn(n,t){if(n&1&&(i(0,"option",14),l(1),r()),n&2){let e=t.$implicit;d("ngValue",e),a(),D("",e," hour",e===1?"":"s")}}function Un(n,t){if(n&1&&(i(0,"p",18),l(1),r()),n&2){let e=c(2);a(),x(e.error())}}function Yn(n,t){if(n&1){let e=C();i(0,"div",3)(1,"app-field",4)(2,"input",5),_("ngModelChange",function(s){g(e);let p=c();return h(p.port.set(s))}),r()(),i(3,"app-field",6)(4,"input",7),_("ngModelChange",function(s){g(e);let p=c();return h(p.label.set(s))}),r()()(),u(5,An,7,4,"div",8),i(6,"div",8),y(7,"app-field",9),i(8,"input",10),_("ngModelChange",function(s){g(e);let p=c();return h(p.query.set(s))}),r(),u(9,$n,1,0,"app-skeleton",11)(10,Hn,8,3),r(),i(11,"div",8)(12,"app-field",12)(13,"select",13),_("ngModelChange",function(s){g(e);let p=c();return h(p.hours.set(s))}),k(14,Wn,2,3,"option",14,ee),r()()(),i(16,"div",15)(17,"app-banner",16),l(18," Teammates open "),i(19,"span",17),l(20),r(),l(21),r()(),u(22,Un,2,1,"p",18),i(23,"div",19)(24,"app-button",2),_("click",function(){g(e);let s=c();return h(s.closed.emit())}),l(25,"Cancel"),r(),i(26,"app-button",20),_("click",function(){g(e);let s=c();return h(s.submit())}),l(27,"Start sharing"),r()()}if(n&2){let e=c();a(2),d("ngModel",e.port()),a(2),d("ngModel",e.label()),a(),m(e.otherDevices().length?5:-1),a(2),d("hint","people or groups on "+e.siteName()+" \u2014 they need the desktop app connected too"),a(),d("ngModel",e.query()),a(),m(e.directory()===null?9:10),a(3),d("hint","the share ends on its own \u2014 "+e.store.limits.maxDurationHours+" hour"+(e.store.limits.maxDurationHours===1?"":"s")+" is the maximum your admin allows"),a(),d("ngModel",e.hours()),a(),M(e.hourOptions()),a(6),x(e.previewUrl()),a(),w(" while connected to ",e.siteName(),'. Plain http \u2014 encrypted by the VPN, but the browser may say "Not secure". '),a(),m(e.error()?22:-1),a(4),d("loading",e.busy())("disabled",!e.canSubmit())}}var Qn=[1,2,4,8,12,24,48,72],ft=3,Ne=class n{store=S(Ce);network=S(B);api=S(st);devicesApi=S(xe);toast=S(O);closed=N();port=v(null);label=v("");query=v("");picked=v(new Set);hours=v(Math.min(8,this.store.limits.maxDurationHours));busy=v(!1);error=v("");directory=v(null);selfHost=v(null);device=v("");devices=v([]);selfName=f(()=>{let t=this.selfHost();return t&&!/^\d{1,3}(\.\d{1,3}){3}$/.test(t)?t.split(".")[0].toLowerCase():null});otherDevices=f(()=>this.devices().filter(t=>t.siteId===this.siteId()&&t.name.toLowerCase()!==this.selfName()));hourOptions=f(()=>{let t=this.store.limits.maxDurationHours,e=Qn.filter(o=>o<=t);return e.includes(t)?e:[...e,t]});siteId=this.store.shareSiteId;siteName=this.store.shareSiteName;users=f(()=>{let t=this.query().trim().toLowerCase();return(this.directory()?.users??[]).filter(e=>!t||e.email.toLowerCase().includes(t))});groups=f(()=>{let t=this.query().trim().toLowerCase();return(this.directory()?.groups??[]).filter(e=>!t||e.name.toLowerCase().includes(t))});usersExpanded=v(!1);groupsExpanded=v(!1);visibleUsers=f(()=>this.query().trim()||this.usersExpanded()?this.users():this.users().filter((t,e)=>e<ft||this.picked().has("user#"+t.userId)));visibleGroups=f(()=>this.query().trim()||this.groupsExpanded()?this.groups():this.groups().filter((t,e)=>e<ft||this.picked().has("group#"+t.groupId)));hiddenUsers=f(()=>this.users().length-this.visibleUsers().length);hiddenGroups=f(()=>this.groups().length-this.visibleGroups().length);portValid=f(()=>{let t=Number(this.port());return Number.isInteger(t)&&t>=1&&t<=65535});canSubmit=f(()=>this.portValid()&&(this.picked().size>0||!!this.device())&&!!this.siteId());previewUrl=f(()=>`http://${this.device()?`${this.device()}.${this.siteId()}.tail.internal`:this.selfHost()??"<your-laptop>"}:${this.portValid()?this.port():"<port>"}`);constructor(){this.api.directory().subscribe({next:t=>this.directory.set(t),error:t=>{this.directory.set({users:[],groups:[]}),this.error.set($(t,"Could not load the directory."))}}),this.store.selfAddress().then(t=>this.selfHost.set(t.hostname??t.ip??null)),this.devicesApi.devices().subscribe({next:t=>this.devices.set(t.devices),error:()=>this.devices.set([])})}toggle(t){this.picked.update(e=>{let o=new Set(e);return o.has(t)?o.delete(t):o.add(t),o})}submit(){return j(this,null,function*(){if(!(!this.canSubmit()||this.busy())){this.busy.set(!0),this.error.set("");try{let t=this.device()?{device:this.device()}:yield this.store.selfAddress(),e=yield this.store.create(G(L({port:Number(this.port()),label:this.label().trim()||void 0,siteId:this.siteId(),durationHours:this.hours()},t),{grantees:[...this.picked()].map(o=>{let[s,p]=o.split("#");return{kind:s,id:p}})}));this.toast.success(`Sharing port ${e.port} as "${e.label}"`),this.closed.emit()}catch(t){this.error.set($(t,"Could not start the share."))}finally{this.busy.set(!1)}}})}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=P({type:n,selectors:[["app-share-port-panel"]],outputs:{closed:"closed"},decls:2,vars:1,consts:[["tone","warning"],[1,"mt-5","flex","justify-end"],["variant","outline",3,"click"],[1,"grid","grid-cols-[120px_minmax(0,1fr)]","gap-3"],["label","Local port","hint","dev server port"],["type","number","min","1","max","65535","placeholder","4200",1,"ui-input","font-mono",3,"ngModelChange","ngModel"],["label","Label","hint","what teammates see"],["maxlength","60","placeholder","e.g. Checkout redesign",1,"ui-input",3,"ngModelChange","ngModel"],[1,"mt-5"],["label","Share with",3,"hint"],["placeholder","Search users and groups",1,"ui-input","mb-3",3,"ngModelChange","ngModel"],["sizeClass","h-24 w-full"],["label","Duration",3,"hint"],[1,"ui-input",3,"ngModelChange","ngModel"],[3,"ngValue"],[1,"mt-4"],["tone","info"],[1,"font-mono","[overflow-wrap:anywhere]"],[1,"mt-3","text-xs","text-danger"],[1,"mt-5","flex","justify-end","gap-2"],[3,"click","loading","disabled"],["label","Serve from",3,"hint"],[1,"ui-microlabel","mb-1","px-1","text-muted-foreground"],[1,"rounded-lg","border","border-border"],[1,"ui-check-row","border-b","border-border","text-sm","last:border-b-0"],[1,"px-3","py-2","text-xs","text-muted-foreground"],["type","button",1,"morerow"],[1,"mb-3","rounded-lg","border","border-border"],["type","checkbox",1,"ui-checkbox",3,"change","checked"],[1,"flex","min-w-0","flex-1","items-center","gap-1.5"],[1,"min-w-0","truncate","font-medium","tracking-[0.015em]","text-surface-foreground"],["tone","gray"],["type","button",1,"morerow",3,"click"],[1,"chev"],[1,"min-w-0","flex-1","truncate","font-medium","tracking-[0.015em]","text-surface-foreground"]],template:function(e,o){e&1&&u(0,On,5,0)(1,Yn,28,13),e&2&&m(o.network.state()!=="connected"?0:1)},dependencies:[_e,de,ue,se,Ke,pe,le,me,Ze,Je,ce,A,Q,V,ge,X],styles:[".morerow[_ngcontent-%COMP%]{display:flex;align-items:center;gap:6px;width:100%;padding:7px 12px;border-top:1px solid var(--border);background:none;border-left:0;border-right:0;border-bottom:0;font:inherit;font-size:12px;color:var(--brand-text);cursor:pointer;text-align:left}.morerow[_ngcontent-%COMP%]:hover{background:var(--muted)}.chev[_ngcontent-%COMP%]{display:inline-block;font-size:10px;transition:transform .15s ease}.chev.open[_ngcontent-%COMP%]{transform:rotate(90deg)}"]})};var Xn=(n,t)=>t.siteId+"/"+t.name;function Kn(n,t){if(n&1&&(i(0,"p",5),l(1),r()),n&2){let e=c();a(),x(e.error())}}function Jn(n,t){n&1&&(i(0,"div",6),y(1,"app-skeleton",8),r())}function Zn(n,t){n&1&&(i(0,"p",5),l(1," No devices yet. Connecting this app to a site enrolls this computer; a remote machine joins with an access token that has the network scope (user menu \u2192 Access tokens). "),r())}function eo(n,t){if(n&1&&(i(0,"p",5),l(1),r()),n&2){let e=c(2);a(),x(e.unreachableNote())}}function to(n,t){n&1&&(i(0,"app-badge",15),l(1,"this device"),r())}function no(n,t){n&1&&(i(0,"app-badge",16),l(1,"ephemeral"),r())}function oo(n,t){if(n&1){let e=C();i(0,"div",9),y(1,"span",10),i(2,"div",11)(3,"div",12)(4,"span",13),l(5),r(),y(6,"app-info-tooltip",14),u(7,to,2,0,"app-badge",15),u(8,no,2,0,"app-badge",16),r(),i(9,"p",17),l(10),r()(),i(11,"code",18),l(12),r(),i(13,"app-button",19),_("click",function(){let s=g(e).$implicit,p=c(2);return h(p.confirming.set(s))}),l(14,"Remove"),r()()}if(n&2){let e=t.$implicit,o=c(2);a(),ne(e.online?"bg-success":"bg-muted-foreground/40"),z("aria-label",e.online?"online":"offline"),a(4),x(e.name),a(),d("text",o.rowTitle(e)),a(),m(o.isSelf(e)?7:-1),a(),m(e.ephemeral?8:-1),a(2),D(" ",o.siteName(e.siteId)," \xB7 ",e.online?"online":e.lastSeen?"last seen "+o.ago(e.lastSeen):"offline"," "),a(2),x(e.ips.join(", "))}}function io(n,t){if(n&1&&(u(0,eo,2,1,"p",5),i(1,"div"),k(2,oo,15,10,"div",9,Xn),r()),n&2){let e=c();m(e.unreachable().length?0:-1),a(2),M(e.devices())}}function ro(n,t){if(n&1){let e=C();i(0,"app-dialog",20),_("closed",function(){g(e);let s=c();return h(s.confirming.set(null))}),i(1,"p",21),l(2),r(),i(3,"div",22)(4,"app-button",23),_("click",function(){g(e);let s=c();return h(s.confirming.set(null))}),l(5,"Cancel"),r(),i(6,"app-button",24),_("click",function(){let s=g(e),p=c();return h(p.remove(s))}),l(7,"Remove device"),r()()()}if(n&2){let e=t,o=c();d("title","Remove "+e.name+"?"),a(2),w(" The device leaves ",o.siteName(e.siteId)," at once and loses its private-network connection. To use it again, enroll it again. "),a(4),d("loading",o.removing())}}var xt=n=>n.toLowerCase().replace(/[^a-z0-9]/g,""),Ee=class n{api=S(xe);toast=S(O);bridge=S(Y);network=S(B);devices=v(null);unreachable=v([]);error=v("");confirming=v(null);removing=v(!1);countChange=N();sites=v([]);siteNames=f(()=>new Map(this.sites().map(t=>[t.id,t.displayName||t.id])));unreachableNote=f(()=>{let t=this.unreachable().map(e=>this.siteName(e));return t.length===1?`${t[0]} did not answer \u2014 its devices are not listed.`:`${t.join(", ")} did not answer \u2014 their devices are not listed.`});selfName=v(null);constructor(){this.load(),this.api.info().subscribe({next:t=>this.sites.set(t.sites??[]),error:()=>{}}),this.bridge.isDesktop&&this.bridge.networkSupported&&this.bridge.networkStatus().then(t=>{let e=xt((t.self?.dnsName||t.self?.hostName||"").split(".")[0]);this.selfName.set(e||null)}).catch(()=>{}),oe(()=>{let t=this.devices();t&&this.countChange.emit(t.length)})}load(){this.api.devices().subscribe({next:t=>{this.error.set(""),this.unreachable.set(t.unreachable??[]),this.devices.set(t.devices)},error:t=>this.error.set($(t,"Could not load your devices."))})}siteName(t){return this.siteNames().get(t)??t}rowTitle(t){return[this.isSelf(t)?"The device this app is running on.":"",t.online?"Connected to the site now.":"Not connected now \u2014 kept until you remove it.",t.ephemeral?"Ephemeral: removed on its own 30 minutes after it goes offline.":""].filter(Boolean).join(" ")}isSelf(t){let e=this.selfName();if(!e||xt(t.name)!==e)return!1;let o=this.network.activeSiteId();return o===null||t.siteId===o}remove(t){this.removing.set(!0),this.api.removeDevice(t.siteId,t.name).subscribe({next:()=>{this.removing.set(!1),this.confirming.set(null),this.toast.success(`Removed ${t.name}`),this.devices.update(e=>(e??[]).filter(o=>!(o.siteId===t.siteId&&o.name===t.name)))},error:e=>{this.removing.set(!1),this.toast.error($(e,"Could not remove the device."))}})}ago(t){return gt(t)}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=P({type:n,selectors:[["app-my-devices"]],outputs:{countChange:"countChange"},decls:13,vars:4,consts:[["aria-label","My devices",1,"box"],[1,"head"],[1,"label"],[1,"count"],[1,"intro"],[1,"emptyrow"],[1,"p-3"],[3,"title"],["sizeClass","h-12 w-full"],["data-testid","device-row",1,"flex","items-center","gap-4","border-t","border-border","px-4","py-3","text-sm","first:border-t-0"],[1,"h-2","w-2","shrink-0","rounded-full"],[1,"min-w-0","flex-1"],[1,"flex","flex-wrap","items-center","gap-1.5"],[1,"min-w-0","truncate","font-medium","tracking-[0.015em]","text-surface-foreground"],[1,"shrink-0",3,"text"],["tone","brand"],["tone","gray"],[1,"mt-0.5","text-xs","text-muted-foreground"],[1,"hidden","shrink-0","font-mono","text-xs","text-muted-foreground","sm:block"],["variant","outline","size","sm",3,"click"],[3,"closed","title"],[1,"text-sm","text-muted-foreground"],[1,"mt-4","flex","justify-end","gap-2"],["variant","outline",3,"click"],["variant","danger",3,"click","loading"]],template:function(e,o){if(e&1&&(i(0,"section",0)(1,"div",1)(2,"span",2),l(3,"My devices"),r(),i(4,"span",3),l(5),r()(),i(6,"p",4),l(7," Every machine joined to the private network with your account \u2014 this app on this computer, and any remote dev box or VM enrolled with one of your access tokens. One machine is listed once per site it joined. Remove an entry you no longer use: a stale one keeps its name, so the same machine joining again gets a suffixed one. "),r(),u(8,Kn,2,1,"p",5)(9,Jn,2,0,"div",6)(10,Zn,2,0,"p",5)(11,io,4,1),r(),u(12,ro,8,3,"app-dialog",7)),e&2){let s,p;a(5),D("\xB7 ",((s=o.devices())==null?null:s.length)??0," device",((s=o.devices())==null?null:s.length)===1?"":"s"),a(3),m(o.error()?8:o.devices()===null?9:o.devices().length===0&&o.unreachable().length===0?10:11),a(4),m((p=o.confirming())?12:-1,p)}},dependencies:[A,V,ae,be,X],styles:[".box[_ngcontent-%COMP%]{display:block;overflow:hidden;border:1px solid var(--border);border-radius:var(--radius)}.head[_ngcontent-%COMP%]{display:flex;align-items:center;gap:8px;padding:10px 16px;background:var(--card-bg);border-bottom:1px solid var(--border)}.label[_ngcontent-%COMP%]{font-size:13px;font-weight:600;color:var(--surface-foreground)}.count[_ngcontent-%COMP%]{font-size:11px;font-weight:500;color:var(--text-secondary)}.emptyrow[_ngcontent-%COMP%]{margin:0;padding:12px 16px;font-size:12px;color:var(--muted-foreground)}.intro[_ngcontent-%COMP%]{margin:0;padding:10px 16px;border-bottom:1px solid var(--border);font-size:12px;line-height:1.5;color:var(--muted-foreground)}"]})};var ao=["panelTpl"],so=["sharePanelTpl"],bt=n=>({$implicit:n}),yt=(n,t)=>t.shareId,lo=(n,t)=>t.id,co=(n,t)=>t.accountNumber,po=(n,t)=>t.resourceId,Ct=(n,t)=>t.siteId;function uo(n,t){if(n&1){let e=C();i(0,"button",14),_("click",function(){g(e);let s=c();return h(s.network.setupOpen.set(!0))}),l(1," Setup guide "),r()}}function mo(n,t){if(n&1){let e=C();i(0,"app-button",15),_("click",function(){g(e);let s=c();return h(s.openShare())}),y(1,"app-icon",16),l(2," Share a local port "),r()}n&2&&(a(),d("strokeWidth",2))}function _o(n,t){n&1&&(i(0,"div",11)(1,"app-banner",17),l(2," Connecting to the private network requires the desktop app \u2014 this page shows what your VPN connection can reach once you're connected there. "),r()())}function go(n,t){if(n&1&&(i(0,"app-banner",12),l(1),r()),n&2){let e=c();a(),x(e.store.error())}}function ho(n,t){n&1&&(i(0,"div",13),y(1,"app-skeleton",18)(2,"app-skeleton",18)(3,"app-skeleton",18),r())}function fo(n,t){if(n&1){let e=C();i(0,"app-share-card",26),_("stop",function(){let s=g(e).$implicit,p=c(3);return h(p.stopShare(s))}),r()}if(n&2){let e=t.$implicit,o=c(3);d("share",e)("serveState",o.shares.serving().get(e.shareId)??null)("serveError",o.shares.serveErrors().get(e.shareId)??"")}}function xo(n,t){if(n&1){let e=C();i(0,"app-share-box",23),_("connect",function(){let s=g(e).$implicit,p=c(2);return h(p.connectSite(s.siteId))}),i(1,"div",24),k(2,fo,1,3,"app-share-card",25,yt),r()()}if(n&2){let e=t.$implicit,o=c(2);d("label",o.boxLabel("My shares",e.siteId))("count",e.shares.length)("status",o.boxStatus(e.siteId))("pill",e.relay.pill)("pillTone",e.relay.tone),a(2),M(e.shares)}}function Co(n,t){if(n&1){let e=C();i(0,"app-share-card",29),_("test",function(){let s=g(e).$implicit,p=c(3);return h(p.testShare(s))}),r()}if(n&2){let e=t.$implicit,o=c(3);d("share",e)("canTest",o.bridge.probeSupported)}}function vo(n,t){if(n&1){let e=C();i(0,"app-share-box",27),_("connect",function(){let s=g(e).$implicit,p=c(2);return h(p.connectSite(s.siteId))}),i(1,"div",24),k(2,Co,1,2,"app-share-card",28,yt),r()()}if(n&2){let e=t.$implicit,o=c(2);d("label",o.boxLabel("Shared with me",e.siteId))("count",e.shares.length)("status",o.boxStatus(e.siteId))("pill",o.boxStatus(e.siteId)==="connected"?"Connected":""),a(2),M(e.shares)}}function bo(n,t){if(n&1){let e=C();i(0,"button",31),_("click",function(){let s=g(e).$implicit,p=c(3);return h(p.jumpTo(s.id))}),l(1),i(2,"span",32),l(3),r()()}if(n&2){let e=t.$implicit;a(),w("",e.label," "),a(2),w("\xB7 ",e.count)}}function yo(n,t){if(n&1&&(i(0,"nav",19),k(1,bo,4,2,"button",30,lo),r()),n&2){let e=c(2);a(),M(e.jumps())}}function wo(n,t){n&1&&(i(0,"app-empty-state",33),l(1," Every address is blocked until an admin grants you a resource. You can stay connected or disconnect; it makes no difference to what you can reach. Pick something under "),i(2,"span",35),l(3,"Request access"),r(),l(4," (top right) to ask. "),r())}function So(n,t){n&1&&(i(0,"app-empty-state",34),l(1," You don't have network access to anything yet \u2014 pick something under "),i(2,"span",35),l(3,"Request access"),r(),l(4," (top right) and an admin will review it. "),r())}function ko(n,t){if(n&1&&u(0,wo,5,0,"app-empty-state",33)(1,So,5,0,"app-empty-state",34),n&2){let e=c(2);m(e.network.state()==="connected"?0:1)}}function Mo(n,t){if(n&1&&y(0,"app-resource-card",38),n&2){let e=t.$implicit;d("resource",e)}}function Po(n,t){if(n&1){let e=C();i(0,"app-vpc-group",37),_("openChange",function(s){let p=g(e).$implicit,E=c(3);return h(E.setOpen("vpc:"+p.accountNumber,s))})("connect",function(){let s=g(e).$implicit,p=c(3);return h(p.connectVpn(s))}),i(1,"div",24),k(2,Mo,1,1,"app-resource-card",38,po),r()()}if(n&2){let e=t.$implicit,o=c(3);d("label",e.vpc.domain??"Private network")("detail",o.accountTitle(e.accountName,e.accountNumber))("count",e.vpc.resources.length)("site",o.siteChip(e))("status",o.statusOf(e))("probe",o.probeOf(e))("open",o.isOpen("vpc:"+e.accountNumber,!0)),z("data-jump","vpc:"+e.accountNumber),a(2),M(e.vpc.resources)}}function To(n,t){if(n&1&&k(0,Po,4,8,"app-vpc-group",36,co),n&2){let e=c(2);M(e.reachableGroups())}}function No(n,t){if(n&1&&(i(0,"app-banner",12),l(1),r()),n&2){let e=c(3);a(),x(e.shares.error())}}function Eo(n,t){n&1&&Ve(0)}function Do(n,t){if(n&1&&J(0,Eo,1,0,"ng-container",43),n&2){let e=t.$implicit;c(2);let o=Oe(1);d("ngTemplateOutlet",o)("ngTemplateOutletContext",qe(2,bt,e))}}function Vo(n,t){if(n&1){let e=C();i(0,"app-share-box",41)(1,"p",44),l(2," You're not sharing anything right now \u2014 "),i(3,"button",45),_("click",function(){g(e);let s=c(3);return h(s.openShare())}),l(4," Share a local port"),r(),l(5," to let a teammate open something running on this laptop. "),r()()}n&2&&d("count",0)}function Ro(n,t){n&1&&Ve(0)}function Io(n,t){if(n&1&&J(0,Ro,1,0,"ng-container",43),n&2){let e=t.$implicit;c(2);let o=Oe(3);d("ngTemplateOutlet",o)("ngTemplateOutletContext",qe(2,bt,e))}}function Oo(n,t){n&1&&(i(0,"app-share-box",42)(1,"p",44),l(2,"No one has shared a port with you yet."),r()()),n&2&&d("count",0)}function qo(n,t){if(n&1){let e=C();i(0,"app-project-group",39),_("openChange",function(s){g(e);let p=c(2);return h(p.setOpen("shares",s))}),u(1,No,2,1,"app-banner",12),i(2,"div",40),k(3,Do,1,4,"ng-container",null,Ct,!1,Vo,6,1,"app-share-box",41),k(6,Io,1,4,"ng-container",null,Ct,!1,Oo,3,1,"app-share-box",42),r()()}if(n&2){let e=c(2);d("count",e.myShares().length+e.sharedWithMe().length)("open",e.isOpen("shares",!0)),a(),m(e.shares.error()?1:-1),a(2),M(e.ownerBoxes()),a(3),M(e.guestBoxes())}}function Ao(n,t){if(n&1){let e=C();J(0,xo,4,5,"ng-template",null,2,Z)(2,vo,4,4,"ng-template",null,3,Z),u(4,yo,3,0,"nav",19),i(5,"div",20),u(6,ko,2,1)(7,To,2,0),u(8,qo,9,5,"app-project-group",21),i(9,"app-my-devices",22),_("countChange",function(s){g(e);let p=c();return h(p.deviceCount.set(s))}),r()()}if(n&2){let e=c();a(4),m(e.jumps().length>1?4:-1),a(2),m(e.store.reachable().length===0?6:7),a(2),m(e.shares.enabled?8:-1)}}function $o(n,t){if(n&1){let e=C();i(0,"app-panel",46),_("closed",function(){g(e);let s=c();return h(s.requestOpen.set(!1))}),i(1,"app-request-access-panel",47),_("sentAny",function(){g(e);let s=c();return h(s.store.load())})("closed",function(){g(e);let s=c();return h(s.requestOpen.set(!1))}),r()()}if(n&2){let e=c();a(),d("groups",e.requestableGroups())("vpcLabels",e.requestableVpcLabels())}}function Bo(n,t){if(n&1){let e=C();i(0,"app-panel",48),_("closed",function(){g(e);let s=c();return h(s.shares.panelOpen.set(!1))}),i(1,"app-share-port-panel",49),_("closed",function(){g(e);let s=c();return h(s.shares.panelOpen.set(!1))}),r()()}}var vt=class n{store=S(at);shares=S(Ce);bridge=S(Y);network=S(B);vpcStatus=S(rt);toast=S(O);host=S(He);requestOpen=v(!1);panelTpl=Ae("panelTpl");sharePanelTpl=Ae("sharePanelTpl");myShares=f(()=>this.shares.mine()??[]);sharedWithMe=f(()=>this.shares.sharedWithMe()??[]);reachableGroups=f(()=>lt(this.store.reachable()??[]));ownerBoxes=f(()=>this.shareBoxes(this.myShares()).map(t=>G(L({},t),{relay:this.relaySummary(t.shares)})));guestBoxes=f(()=>this.shareBoxes(this.sharedWithMe()));deviceCount=v(0);jumps=f(()=>{let t=this.reachableGroups().map(e=>({id:"vpc:"+e.accountNumber,label:e.vpc.domain??this.accountTitle(e.accountName,e.accountNumber),count:e.vpc.resources.length}));return this.shares.enabled&&t.push({id:"shares",label:"Shares",count:this.myShares().length+this.sharedWithMe().length}),t.push({id:"devices",label:"My devices",count:this.deviceCount()}),t});jumpTo(t){this.host.nativeElement.querySelector(`[data-jump="${CSS.escape(t)}"]`)?.scrollIntoView({behavior:"smooth",block:"start"})}shareBoxes(t){let e=this.network.sites().map(p=>p.id),o=this.network.activeSiteId(),s=p=>{if(p===o)return-1;let E=e.indexOf(p);return E===-1?Number.MAX_SAFE_INTEGER:E};return[...ct(t,p=>p.siteId).bySite].map(([p,E])=>({siteId:p,shares:E})).sort((p,E)=>s(p.siteId)-s(E.siteId))}knownSite(t){return this.network.sites().some(e=>e.id===t)}boxStatus(t){return this.knownSite(t)?this.siteBarStatus(t):"none"}boxLabel(t,e){return this.knownSite(e)?this.network.sites().length>1?`${t} \xB7 ${this.network.siteName(e)}`:t:`${t} \xB7 ${e}`}siteChip(t){if(this.network.sites().length<2)return null;let e=this.network.siteOfAccount().get(t.accountNumber);return e?this.network.siteName(e):null}relaySummary(t){let e=t.map(o=>this.shares.serving().get(o.shareId)).filter(o=>o!==void 0);return e.includes("serving")?e.includes("failed")?{pill:"Partly serving",tone:"warn"}:{pill:"Serving",tone:"ok"}:e.includes("failed")?{pill:"Not serving",tone:"warn"}:e.includes("starting")?{pill:"Starting\u2026",tone:"quiet"}:{pill:"",tone:"quiet"}}requestableGroups=f(()=>pt(this.store.requestable()??[]));availableCount=f(()=>this.store.requestable()?.length??0);requestableVpcLabels=f(()=>{let t=new Map;for(let e of this.requestableGroups()){let o=this.reachableGroups().find(s=>s.accountNumber===e.accountNumber);o?.vpc.domain&&t.set(e.key,o.vpc.domain)}return t});openRequest(){this.requestOpen.set(!0)}openShare(){this.shares.panelOpen.set(!0)}stopShare(t){return j(this,null,function*(){try{yield this.shares.remove(t.shareId),this.toast.success(`Stopped sharing "${t.label}"`)}catch{this.toast.error(`Could not stop "${t.label}" \u2014 try again.`)}})}testShare(t){return j(this,null,function*(){if(!t.url)return;let e="",o=80;try{let p=new URL(t.url);e=p.hostname,o=Number(p.port||80)}catch{return}let s=yield this.bridge.networkProbe(e,o).catch(()=>({ok:!1,reason:void 0}));s.ok?this.toast.success(`${t.label} answers on port ${o}.`):s.reason==="vpn-down"?this.toast.error("Connect to the private network first."):this.toast.error(`${t.label} didn't answer \u2014 ask ${t.ownerName} whether it's still running, or wait a minute for access rules to sync.`)})}connectSite(t){if(this.network.state()==="setup"){this.network.setupOpen.set(!0);return}this.network.connect({siteId:t})}statusOf(t){return this.siteBarStatus(this.network.siteOfAccount().get(t.accountNumber)??null)}siteBarStatus(t){return ve(this.network.state(),this.network.activeSiteId(),this.network.pendingSiteId(),t)}openOverrides=v(new Map);constructor(){this.store.load(),this.shares.startPolling(S(ze)),$e(this.requestOpen,this.panelTpl,()=>this.requestOpen.set(!1)),$e(this.shares.panelOpen,this.sharePanelTpl,()=>this.shares.panelOpen.set(!1)),oe(()=>{let t=this.reachableGroups();this.network.activeSiteId(),this.network.state()==="connected"&&t.length>0&&this.vpcStatus.refresh(t)})}isOpen(t,e){return this.openOverrides().get(t)??e}setOpen(t,e){this.openOverrides.update(o=>new Map(o).set(t,e))}connectVpn(t){if(this.network.state()==="setup"){this.network.setupOpen.set(!0);return}let e=this.network.siteOfAccount().get(t.accountNumber);this.network.connect(e?{siteId:e}:void 0)}probeOf(t){return this.vpcStatus.byAccount().get(t.accountNumber)??null}accountTitle(t,e){return t||(e?this.formatId(e):"Unknown account")}formatId(t){return t.replace(/(\d{4})(?=\d)/g,"$1 ")}static \u0275fac=function(e){return new(e||n)};static \u0275cmp=P({type:n,selectors:[["app-resources-page"]],viewQuery:function(e,o){e&1&&(Ie(o.panelTpl,ao,5),Ie(o.sharePanelTpl,so,5)),e&2&&Ue(2)},hostAttrs:[1,"flex","min-h-0","flex-1","flex-col"],decls:19,vars:9,consts:[["panelTpl",""],["sharePanelTpl",""],["ownerBoxTpl",""],["guestBoxTpl",""],["pageHeader","","title","Network",3,"showHeaderSearch"],["headerSubtitle","",1,"mt-1","flex","items-start","gap-1.5","text-sm","text-muted-foreground"],[1,"shrink-0","underline","underline-offset-2","hover:text-surface-foreground"],[1,"mt-0.5","shrink-0",3,"text"],["headerActions","","variant","secondary","size","lg"],["headerActions","","size","lg",3,"click"],["name","plus",1,"h-4","w-4",3,"strokeWidth"],[1,"mt-3"],["tone","danger"],[1,"grid","gap-4","grid-cols-[repeat(auto-fill,minmax(300px,1fr))]"],[1,"shrink-0","underline","underline-offset-2","hover:text-surface-foreground",3,"click"],["headerActions","","variant","secondary","size","lg",3,"click"],["name","share",1,"h-4","w-4",3,"strokeWidth"],["tone","info"],["sizeClass","h-52 w-full"],["aria-label","Sections","data-testid","network-jumps",1,"jump"],[1,"groups"],["data-jump","shares","title","Shares","noun","share",3,"count","open"],["data-jump","devices",3,"countChange"],[3,"connect","label","count","status","pill","pillTone"],[1,"resgrid"],["mode","owner",3,"share","serveState","serveError"],["mode","owner",3,"stop","share","serveState","serveError"],["pillTone","ok",3,"connect","label","count","status","pill"],["mode","guest",3,"share","canTest"],["mode","guest",3,"test","share","canTest"],["type","button"],["type","button",3,"click"],[1,"cnt"],["title","You're connected, but nothing here is granted to you"],["title","No resources yet"],[1,"font-medium"],[3,"label","detail","count","site","status","probe","open"],[3,"openChange","connect","label","detail","count","site","status","probe","open"],[3,"resource"],["data-jump","shares","title","Shares","noun","share",3,"openChange","count","open"],[1,"flex","flex-col","gap-3"],["label","My shares",3,"count"],["label","Shared with me",3,"count"],[4,"ngTemplateOutlet","ngTemplateOutletContext"],[1,"emptyrow"],["type","button",1,"text-brand-text","underline","underline-offset-2",3,"click"],["title","Request access","contentKey","request",3,"closed"],[3,"sentAny","closed","groups","vpcLabels"],["title","Share a local port","contentKey","share",3,"closed"],[3,"closed"]],template:function(e,o){if(e&1){let s=C();i(0,"app-page")(1,"app-page-header",4)(2,"p",5)(3,"span"),l(4),r(),u(5,uo,2,0,"button",6),y(6,"app-info-tooltip",7),r(),u(7,mo,3,1,"app-button",8),i(8,"app-button",9),_("click",function(){return g(s),h(o.openRequest())}),y(9,"app-icon",10),l(10),r(),u(11,_o,3,0,"div",11),r(),u(12,go,2,1,"app-banner",12)(13,ho,4,0,"div",13)(14,Ao,10,3),r(),J(15,$o,2,2,"ng-template",null,0,Z)(17,Bo,2,0,"ng-template",null,1,Z)}e&2&&(a(),d("showHeaderSearch",!1),a(3),w(" Databases, internal sites, hosts",o.shares.enabled?", and teammates\u2019 laptops":""," your VPN connection can reach. "),a(),m(o.bridge.isDesktop&&o.network.state()!=="hidden"?5:-1),a(),d("text",o.bridge.isDesktop?"Connect first with the Connect pill at the bottom of the sidebar. Access changes take up to 5 minutes to apply.":"Access changes take up to 5 minutes to apply."),a(),m(o.shares.enabled?7:-1),a(2),d("strokeWidth",2),a(),w(" Request access",o.availableCount()?" \xB7 "+o.availableCount()+" available":""," "),a(),m(o.bridge.isDesktop?-1:11),a(),m(o.store.error()?12:o.store.reachable()===null?13:14))},dependencies:[Xe,Q,V,q,X,dt,ut,be,fe,ye,it,Se,ke,Me,Pe,Te,Ne,Ee],styles:[".groups[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:16px}.resgrid[_ngcontent-%COMP%]{display:grid;grid-template-columns:repeat(auto-fill,minmax(300px,1fr));gap:16px;grid-auto-rows:1fr}.emptyrow[_ngcontent-%COMP%]{margin:0;padding:0 4px;font-size:12px;color:var(--muted-foreground)}.jump[_ngcontent-%COMP%]{display:flex;flex-wrap:wrap;gap:4px 6px;margin:0 0 12px}.jump[_ngcontent-%COMP%]   button[_ngcontent-%COMP%]{font-size:11px;font-weight:600;letter-spacing:.04em;text-transform:uppercase;color:var(--text-secondary);padding:2px 8px;border-radius:999px;background:var(--muted)}.jump[_ngcontent-%COMP%]   button[_ngcontent-%COMP%]:hover{color:var(--surface-foreground)}.jump[_ngcontent-%COMP%]   button[_ngcontent-%COMP%]   .cnt[_ngcontent-%COMP%]{font-weight:500;letter-spacing:0}[data-jump][_ngcontent-%COMP%]{scroll-margin-top:12px}"]})};export{vt as a};