@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 (1 loc) • 24.4 kB
JavaScript
import{a as re,l as de}from"./chunk-K4OFWFQE.js";import{a as N}from"./chunk-IKK5DQ3Z.js";import"./chunk-LEEL6MDA.js";import"./chunk-HUXCPIDO.js";import{a as se}from"./chunk-XPF5YBGU.js";import"./chunk-XUEIITMC.js";import"./chunk-Z2HQA5DO.js";import"./chunk-2DD7CZB4.js";import"./chunk-J7PZFXOE.js";import{a as fe}from"./chunk-YGAHR42T.js";import{a as ve}from"./chunk-3PQNISIL.js";import{a as he}from"./chunk-SH2F2DCQ.js";import{a as ce,b as pe}from"./chunk-TVCLJWZS.js";import{a as _e}from"./chunk-WM5A6BAU.js";import{a as ge,d as xe,e as Ce}from"./chunk-JNANYFF2.js";import{a as Z}from"./chunk-YMC4QOLO.js";import{a as me}from"./chunk-6HVGPPAG.js";import"./chunk-PU4UT4HF.js";import"./chunk-SYLZLLGS.js";import{a as ae}from"./chunk-IVXFG5AJ.js";import{a as le,b}from"./chunk-2SO4BVIT.js";import"./chunk-2BNLISUN.js";import{a as Q,b as X,e as Y,i as ee,j as te,k as ie,n as ne,o as oe,p as ue}from"./chunk-T5HLFYHP.js";import{c as z}from"./chunk-KCJ5HNXP.js";import{a as J}from"./chunk-3SC2PPSK.js";import{a as P}from"./chunk-B67EMZ2H.js";import"./chunk-MID2IYAR.js";import"./chunk-6GDWMGWO.js";import{a as T}from"./chunk-7A4HO4AV.js";import"./chunk-ZRDXKVPG.js";import{$a as I,Aa as s,Ba as r,Ca as U,F,I as R,Ja as q,K as h,L as v,La as C,Na as l,Oa as H,Pa as W,R as f,Wa as E,Xa as n,Ya as c,Za as g,_ as a,_a as S,bb as j,cb as B,db as K,ga as D,qb as x,sb as V,ta as p,tb as L,ua as m,wa as $,xa as y,ya as w,za as u}from"./chunk-FYA6QUPZ.js";import{a as O}from"./chunk-WFIHWVQO.js";var A=class t{api=R(re);toast=R(z);notifications=R(de);requests=f(null);error=f("");deciding=f(new Set);pending=x(()=>(this.requests()??[]).filter(i=>i.status==="PENDING"));decided=x(()=>(this.requests()??[]).filter(i=>i.status!=="PENDING"));load(){this.error.set(""),this.api.listAll(void 0,{usage:!0}).subscribe({next:i=>this.requests.set(i),error:()=>{this.requests.set([]),this.error.set("Could not load requests. Try reloading the page.")}})}approve(i,e,o){let{what:d,who:_}=Re(i);this.decide(i,this.api.approve(i.requestId,e,o),()=>this.toast.success(i.type!=="REAPPROVAL"?`Granted ${d} to ${_}`:i.kind==="GROUP"?`Kept group ${_}`:`Re-approved ${d} for ${_}`))}deny(i,e){let{what:o,who:d}=Re(i),_=i.type!=="REAPPROVAL"?`Denied ${o} for ${d}`:i.kind==="ADMIN"?`Removed admin status from ${d}`:i.kind==="SERVICE_USER"?`Deleted service user ${d}`:i.kind==="GROUP"?`Deleted group ${d}`:`Revoked ${o} for ${d}`;this.decide(i,this.api.deny(i.requestId,e),()=>this.toast.success(_))}decide(i,e,o){this.setDeciding(i.requestId,!0),e.subscribe({next:()=>{this.setDeciding(i.requestId,!1),o(),this.load(),this.notifications.load()},error:d=>{this.setDeciding(i.requestId,!1),this.toast.error(ue(d,"Could not record that decision.")),this.load(),this.notifications.load()}})}setDeciding(i,e){this.deciding.update(o=>{let d=new Set(o);return e?d.add(i):d.delete(i),d})}static \u0275fac=function(e){return new(e||t)};static \u0275prov=F({token:t,factory:t.\u0275fac,providedIn:"root"})};function Re(t){let i=t.group||t.serviceUser||t.email||"the user";return{what:t.kind==="ADMIN"?"admin status":t.kind==="SERVICE_USER"?"service-user access":t.kind==="GROUP"?"the whole bundle":t.kind==="RESOURCE"?t.resourceName||"the resource":t.kind==="PLUGIN"?`${t.pluginId} (${t.permission})`:t.roleName||"access",who:i}}var Ee=["*"],k=class t{static \u0275fac=function(e){return new(e||t)};static \u0275cmp=D({type:t,selectors:[["app-card"]],hostAttrs:[1,"block","rounded-2xl","border","border-border/70","bg-card-bg"],ngContentSelectors:Ee,decls:1,vars:0,template:function(e,o){e&1&&(H(),W(0))},encapsulation:2})};function ye(t,i){if(t&1&&(s(0,"strong"),n(1),r(),n(2," stays an admin \u2014 the next review is in 12 months. ")),t&2){let e=l(2);a(),c(e.who())}}function we(t,i){if(t&1&&(s(0,"strong"),n(1),r(),n(2," loses admin access to this app. Their roles and group memberships are unchanged. (Refused if they are the last admin.) ")),t&2){let e=l(2);a(),c(e.who())}}function Se(t,i){if(t&1&&p(0,ye,3,1)(1,we,3,1),t&2){let e=l();m(e.approving()?0:1)}}function Ie(t,i){if(t&1&&(s(0,"strong"),n(1),r(),n(2," stays registered \u2014 the next review is in 12 months. ")),t&2){let e=l(2);a(),c(e.who())}}function Te(t,i){if(t&1&&(s(0,"strong"),n(1),r(),n(2," will be "),s(3,"strong"),n(4,"deleted"),r(),n(5,": its secret stops working on its next call and all its role grants are removed. Automation still using it will start failing. ")),t&2){let e=l(2);a(),c(e.who())}}function Ne(t,i){if(t&1&&p(0,Ie,3,1)(1,Te,6,1),t&2){let e=l();m(e.approving()?0:1)}}function Pe(t,i){if(t&1&&(s(0,"strong"),n(1),r(),n(2," keeps its whole bundle \u2014 the next review is in 12 months. ")),t&2){let e=l(2);a(),c(e.request().group||"This group")}}function Ae(t,i){if(t&1&&(s(0,"strong"),n(1),r(),n(2," will be "),s(3,"strong"),n(4,"deleted"),r(),n(5,": every member loses the roles and resources it bundled (unless held another way) and is notified. ")),t&2){let e=l(2);a(),c(e.request().group||"This group")}}function ke(t,i){if(t&1&&p(0,Pe,3,1)(1,Ae,6,1),t&2){let e=l();m(e.approving()?0:1)}}function Me(t,i){if(t&1&&(s(0,"strong"),n(1),r(),n(2," keeps reaching "),s(3,"strong"),n(4),r(),n(5," over the VPN for another 12 months, then it comes up for review again. ")),t&2){let e=l(2);a(),c(e.who()),a(3),c(e.resourceLabel())}}function Ue(t,i){if(t&1&&(s(0,"strong"),n(1),r(),n(2," loses network access to "),s(3,"strong"),n(4),r(),n(5," \u2014 this standing access is revoked now (the network closes within about 5 minutes). ")),t&2){let e=l(2);a(),c(e.who()),a(3),c(e.resourceLabel())}}function Ve(t,i){if(t&1&&p(0,Me,6,2)(1,Ue,6,2),t&2){let e=l();m(e.approving()?0:1)}}function Le(t,i){t&1&&n(0," until you revoke the grant. The change reaches the network within about 5 minutes. ")}function Ge(t,i){if(t&1&&(n(0," for "),s(1,"strong"),n(2),r(),n(3," \u2014 after that the network closes on its own. Changes reach the network within about 5 minutes. ")),t&2){let e=l(3);a(2),c(e.label(e.duration()))}}function Oe(t,i){if(t&1&&(s(0,"strong"),n(1),r(),n(2," will be able to reach "),s(3,"strong"),n(4),r(),n(5," over the VPN, "),p(6,Le,1,0)(7,Ge,4,1)),t&2){let e=l(2);a(),c(e.who()),a(3),c(e.resourceLabel()),a(2),m(e.duration()==="long"?6:7)}}function Fe(t,i){if(t&1&&(s(0,"strong"),n(1),r(),n(2," will not be able to reach "),s(3,"strong"),n(4),r(),n(5,". Their existing access is unchanged, and they can ask again later. ")),t&2){let e=l(2);a(),c(e.who()),a(3),c(e.resourceLabel())}}function $e(t,i){if(t&1&&p(0,Oe,8,3)(1,Fe,6,2),t&2){let e=l();m(e.approving()?0:1)}}function He(t,i){if(t&1&&(s(0,"strong"),n(1),r(),n(2," keeps "),s(3,"strong"),n(4),r(),n(5," in account "),s(6,"strong"),n(7),r(),n(8," for another 12 months, then it comes up for review again. ")),t&2){let e=l(2);a(),c(e.who()),a(3),c(e.subject()),a(3),c(e.request().accountNumber)}}function We(t,i){if(t&1&&(s(0,"strong"),n(1),r(),n(2," will lose "),s(3,"strong"),n(4),r(),n(5," in "),s(6,"strong"),n(7),r(),n(8," \u2014 this standing access is revoked now. ")),t&2){let e=l(2);a(),c(e.who()),a(3),c(e.subject()),a(3),c(e.request().accountNumber)}}function je(t,i){if(t&1&&p(0,He,9,3)(1,We,9,3),t&2){let e=l();m(e.approving()?0:1)}}function Be(t,i){t&1&&n(0," and can vend credentials for it until you revoke the role. ")}function Ke(t,i){if(t&1&&(n(0," for "),s(1,"strong"),n(2),r(),n(3," \u2014 after that, vending denies on its own. ")),t&2){let e=l(2);a(2),c(e.label(e.duration()))}}function ze(t,i){if(t&1&&(s(0,"strong"),n(1),r(),n(2," will be able to assume "),s(3,"strong"),n(4),r(),n(5," in account "),s(6,"strong"),n(7),r(),n(8," straight away, "),p(9,Be,1,0)(10,Ke,4,1)),t&2){let e=l();a(),c(e.who()),a(3),c(e.request().roleName),a(3),c(e.request().accountNumber),a(2),m(e.duration()==="long"?9:10)}}function Ze(t,i){if(t&1&&(s(0,"strong"),n(1),r(),n(2," will not get "),s(3,"strong"),n(4),r(),n(5," in "),s(6,"strong"),n(7),r(),n(8,". Their existing access is unchanged, and they can ask again later. ")),t&2){let e=l();a(),c(e.who()),a(3),c(e.request().roleName),a(3),c(e.request().accountNumber)}}function Je(t,i){t&1&&n(0," If it is the group's last role or resource, the group itself is removed. ")}function Qe(t,i){if(t&1&&(n(0," This applies to "),s(1,"strong"),n(2,"every member"),r(),n(3," of the group. "),p(4,Je,1,0)),t&2){let e=l();a(4),m(e.approving()?-1:4)}}function Xe(t,i){t&1&&n(0," Never used in the last 12 months. ")}function Ye(t,i){if(t&1&&n(0),t&2){let e=l(),o=l();I(" Used ",e.count," ",e.count===1?"time":"times"," in the last 12 months",e.lastAt?" \u2014 last "+o.ago(e.lastAt):"",". ")}}function et(t,i){if(t&1&&(s(0,"p",10),p(1,Xe,1,0)(2,Ye,1,3),r()),t&2){let e=i;E(e.count===0?"font-medium text-amber-700 dark:text-amber-400":"text-muted-foreground"),a(),m(e.count===0?1:2)}}function tt(t,i){if(t&1&&(s(0,"div")(1,"p",11),n(2,"Their reason"),r(),s(3,"p",12),n(4),r()()),t&2){let e=l();a(4),g(' "',e.request().reason,'" ')}}function it(t,i){if(t&1&&(s(0,"option",14),n(1),r()),t&2){let e=i.$implicit,o=l(2);u("ngValue",e),a(),c(o.label(e))}}function nt(t,i){if(t&1){let e=q();s(0,"app-field",4)(1,"select",13),C("ngModelChange",function(d){h(e);let _=l();return v(_.duration.set(d))}),y(2,it,2,2,"option",14,$),s(4,"option",14),n(5,"Long-term (indefinite)"),r()()()}if(t&2){let e=l();u("hint",e.askedHint()),a(),u("ngModel",e.duration()),a(),w(e.PRESETS),a(2),u("ngValue","long")}}var M=class t{request=L.required();decision=L.required();confirmed=V();closed=V();PRESETS=le;label(i){return i==="long"?"long-term":b(i)}who(){let i=this.request();return i.group||i.serviceUser||i.email||"This user"}ago=N;note=f("");duration=f("long");approving=x(()=>this.decision()==="APPROVED");reapproval=x(()=>this.request().type==="REAPPROVAL");resource=x(()=>this.request().kind==="RESOURCE");subject=x(()=>this.request().kind==="PLUGIN"?`${this.request().pluginId} (${this.request().permission})`:this.request().roleName);resourceLabel=x(()=>this.request().resourceName||"(deleted resource)");title=x(()=>this.request().kind==="ADMIN"?this.approving()?"Keep this admin?":"Remove admin?":this.request().kind==="SERVICE_USER"?this.approving()?"Keep this service user?":"Delete this service user?":this.request().kind==="GROUP"?this.approving()?"Keep this group?":"Delete this group?":this.titleForAccess());titleForAccess=()=>this.resource()?this.reapproval()?this.approving()?"Reapprove this access?":"Revoke this access?":this.approving()?"Grant this resource?":"Deny this request?":this.reapproval()?this.approving()?"Reapprove this access?":"Revoke this access?":this.approving()?"Grant this role?":"Deny this request?";confirmLabel=x(()=>this.request().kind==="ADMIN"?this.approving()?"Keep admin":"Remove admin":this.request().kind==="SERVICE_USER"?this.approving()?"Keep service user":"Delete service user":this.request().kind==="GROUP"?this.approving()?"Keep group":"Delete group":this.confirmLabelForAccess());confirmLabelForAccess=()=>this.resource()?this.reapproval()?this.approving()?"Reapprove access":"Revoke access":this.approving()?"Grant access":"Deny request":this.reapproval()?this.approving()?"Reapprove access":"Revoke access":this.approving()?"Grant role":"Deny request";askedHint=x(()=>{let i=this.request().requestedDurationHours;return i?`\u2014 they asked for ${b(i)}`:"\u2014 they asked for long-term"});ngOnInit(){this.duration.set(this.request().requestedDurationHours??"long")}confirm(){let i=this.duration();this.confirmed.emit(O({note:this.note().trim()},this.approving()&&i!=="long"?{durationHours:i}:{}))}static \u0275fac=function(e){return new(e||t)};static \u0275cmp=D({type:t,selectors:[["app-request-decision-dialog"]],inputs:{request:[1,"request"],decision:[1,"decision"]},outputs:{confirmed:"confirmed",closed:"closed"},decls:22,vars:11,consts:[[3,"closed","title"],[1,"space-y-4"],[3,"tone"],[1,"text-sm",3,"class"],["label","Access duration",3,"hint"],["label","Note","hint","optional; shown to them with your decision"],["rows","2","maxlength","500",1,"ui-input",3,"ngModelChange","placeholder","ngModel"],[1,"mt-5","flex","justify-end","gap-2"],["variant","outline",3,"click"],[3,"click","variant"],[1,"text-sm"],[1,"mb-1","text-sm","font-medium","text-surface-foreground"],[1,"rounded-lg","bg-muted","p-3","text-sm","italic","text-surface-foreground","ring-1","ring-border"],[1,"ui-input",3,"ngModelChange","ngModel"],[3,"ngValue"]],template:function(e,o){if(e&1&&(s(0,"app-dialog",0),C("closed",function(){return o.closed.emit()}),s(1,"div",1)(2,"app-banner",2),p(3,Se,2,1)(4,Ne,2,1)(5,ke,2,1)(6,Ve,2,1)(7,$e,2,1)(8,je,2,1)(9,ze,11,4)(10,Ze,9,3),p(11,Qe,5,1),r(),p(12,et,3,3,"p",3),p(13,tt,5,1,"div"),p(14,nt,6,3,"app-field",4),s(15,"app-field",5)(16,"textarea",6),C("ngModelChange",function(_){return o.note.set(_)}),r()()(),s(17,"div",7)(18,"app-button",8),C("click",function(){return o.closed.emit()}),n(19,"Cancel"),r(),s(20,"app-button",9),C("click",function(){return o.confirm()}),n(21),r()()()),e&2){let d;u("title",o.title()),a(2),u("tone",o.approving()?"success":"warning"),a(),m(o.request().kind==="ADMIN"?3:o.request().kind==="SERVICE_USER"?4:o.request().kind==="GROUP"?5:o.resource()&&o.reapproval()?6:o.resource()?7:o.reapproval()?8:o.approving()?9:10),a(8),m(o.request().groupId?11:-1),a(),m((d=o.request().usage)?12:-1,d),a(),m(o.request().reason?13:-1),a(),m(o.approving()&&!o.reapproval()?14:-1),a(2),u("placeholder",o.approving()?"e.g. Approved for the migration \u2014 will review in a month.":"e.g. Use the read-only role instead; ping me if that blocks you.")("ngModel",o.note()),a(4),u("variant",o.approving()?"primary":"danger"),a(),g(" ",o.confirmLabel()," ")}},dependencies:[oe,te,ie,Q,ee,X,ne,Y,P,J,T,ae],encapsulation:2})};var ot=(t,i)=>i.requestId;function at(t,i){if(t&1&&(s(0,"span",4),n(1),r()),t&2){let e=l();a(),g(" ",e.store.pending().length," ")}}function rt(t,i){if(t&1&&(s(0,"app-banner",5),n(1),r()),t&2){let e=l();a(),c(e.store.error())}}function st(t,i){t&1&&(s(0,"div",6),U(1,"app-skeleton",8)(2,"app-skeleton",8)(3,"app-skeleton",8),r())}function lt(t,i){t&1&&(s(0,"app-empty-state",9),n(1," Every request has been decided. New ones appear here and in the activity bell. "),r())}function dt(t,i){t&1&&(s(0,"app-empty-state",10),n(1," Requests you've granted or denied will be listed here. "),r())}function ct(t,i){if(t&1&&p(0,lt,2,0,"app-empty-state",9)(1,dt,2,0,"app-empty-state",10),t&2){let e=l();m(e.tab()==="PENDING"?0:1)}}function pt(t,i){if(t&1&&(s(0,"app-empty-state",13),n(1),r()),t&2){let e=l(2);a(),g(' Nothing matches "',e.query(),'". Try a different email, role, or account. ')}}function mt(t,i){t&1&&(s(0,"app-badge",25),n(1,"group"),r())}function ut(t,i){t&1&&(s(0,"app-badge",25),n(1,"service"),r())}function _t(t,i){t&1&&(s(0,"app-chip")(1,"span",36),n(2,"admin status"),r()())}function gt(t,i){t&1&&(s(0,"app-chip")(1,"span",36),n(2,"service user \xB7 still needed?"),r()())}function xt(t,i){if(t&1&&(s(0,"app-chip")(1,"span",36),n(2),r()()),t&2){let e=l().$implicit;a(2),g("",e.group||"(deleted group)"," \xB7 whole group \xB7 still needed?")}}function Ct(t,i){if(t&1&&(s(0,"app-chip")(1,"span",36),n(2),r()()),t&2){let e=l().$implicit;a(2),g(" ",e.resourceName||"(deleted resource)"," \xB7 resource ")}}function ft(t,i){if(t&1&&(s(0,"app-chip")(1,"span",36),n(2),r()()),t&2){let e=l().$implicit,o=l(3);a(2),I(" ",e.pluginId," (",e.permission,") \xB7 ",o.names.label(e.accountNumber??"")," ")}}function ht(t,i){if(t&1&&(s(0,"app-chip")(1,"span",36),n(2),r()()),t&2){let e=l().$implicit,o=l(3);a(2),S(" ",e.roleName," \xB7 ",o.names.label(e.accountNumber??"")," ")}}function vt(t,i){t&1&&(s(0,"app-chip",28),n(1,"never used this year"),r())}function Rt(t,i){if(t&1&&(s(0,"app-chip"),n(1),r()),t&2){let e=l();a(),g("used ",e.count,"\xD7 this year")}}function qt(t,i){t&1&&p(0,vt,2,0,"app-chip",28)(1,Rt,2,1,"app-chip"),t&2&&m(i.count===0?0:1)}function Dt(t,i){if(t&1&&(s(0,"app-chip",37),n(1),r(),p(2,qt,2,1)),t&2){let e,o=l().$implicit;a(),c(o.kind==="ADMIN"||o.kind==="SERVICE_USER"||o.kind==="GROUP"?"12-month review":"12-month reapproval"),a(),m((e=o.usage)?2:-1,e)}}function bt(t,i){if(t&1&&(s(0,"app-chip",28),n(1),r()),t&2){let e=l().$implicit,o=l(3);a(),g("for ",o.dur(e.requestedDurationHours))}}function Et(t,i){t&1&&(s(0,"app-chip"),n(1,"long-term"),r())}function yt(t,i){if(t&1&&(s(0,"p",29),n(1),r()),t&2){let e=l().$implicit;u("title",e.reason),a(),g(' "',e.reason,'" ')}}function wt(t,i){if(t&1){let e=q();s(0,"app-button",38),C("click",function(){h(e);let d=l().$implicit,_=l(3);return v(_.ask(d,"DENIED"))}),n(1),r(),s(2,"app-button",39),C("click",function(){h(e);let d=l().$implicit,_=l(3);return v(_.ask(d,"APPROVED"))}),n(3),r()}if(t&2){let e=l().$implicit,o=l(3);u("disabled",o.isDeciding(e)),a(),g(" ",e.type==="REAPPROVAL"?"Revoke":"Deny"," "),a(),u("loading",o.isDeciding(e)),a(),g(" ",e.type==="REAPPROVAL"?"Reapprove":"Grant"," ")}}function St(t,i){if(t&1&&(s(0,"div",35)(1,"app-badge",40),n(2),r(),s(3,"p",41),n(4),r(),s(5,"p",42),n(6),r()()),t&2){let e=l().$implicit,o=l(3);u("title",o.exact(e.decidedAt)),a(),u("tone",e.status==="APPROVED"?"green":"red"),a(),g(" ",e.status==="APPROVED"?o.grantedLabel(e):"Denied"," "),a(2),S(" ",o.stampDate(e.decidedAt),", ",o.stampTime(e.decidedAt)," "),a(2),c(o.ago(e.decidedAt))}}function It(t,i){if(t&1&&(s(0,"app-card",20)(1,"div",23)(2,"p",24),n(3),p(4,mt,2,0,"app-badge",25)(5,ut,2,0,"app-badge",25),r()(),s(6,"div",26)(7,"div",27),p(8,_t,3,0,"app-chip")(9,gt,3,0,"app-chip")(10,xt,3,1,"app-chip")(11,Ct,3,1,"app-chip")(12,ft,3,3,"app-chip")(13,ht,3,2,"app-chip"),p(14,Dt,3,2)(15,bt,2,1,"app-chip",28)(16,Et,2,0,"app-chip"),r(),p(17,yt,2,2,"p",29),r(),s(18,"div",30)(19,"p",31)(20,"span",32),n(21,"Requested: "),r(),n(22),r(),s(23,"p",33),n(24),r()(),s(25,"div",34),p(26,wt,4,4)(27,St,7,6,"div",35),r()()),t&2){let e=i.$implicit,o=l(3);a(3),g(" ",e.group||e.serviceUser||e.email||"(deleted user)"," "),a(),m(e.group?4:e.serviceUser?5:-1),a(4),m(e.kind==="ADMIN"?8:e.kind==="SERVICE_USER"?9:e.kind==="GROUP"?10:e.kind==="RESOURCE"?11:e.kind==="PLUGIN"?12:13),a(6),m(e.type==="REAPPROVAL"?14:e.requestedDurationHours?15:16),a(3),m(e.reason?17:-1),a(),u("title",o.exact(e.createdAt)),a(4),g("",o.stampDate(e.createdAt)," "),a(2),S(" ",o.stampTime(e.createdAt)," \xB7 ",o.ago(e.createdAt)," "),a(2),m(e.status==="PENDING"?26:27)}}function Tt(t,i){if(t&1){let e=q();s(0,"app-load-more",43),C("reached",function(){h(e);let d=l(3);return v(d.window.loadMore())}),r()}}function Nt(t,i){if(t&1&&(s(0,"div",14)(1,"div",15)(2,"span",16),n(3,"User"),r(),s(4,"span",16),n(5,"Requesting"),r(),s(6,"span",17),n(7,"Requested"),r(),s(8,"span",18),n(9),r()(),s(10,"div",19)(11,"div",6),y(12,It,28,10,"app-card",20,ot),r(),p(14,Tt,1,0,"app-load-more",21),U(15,"app-result-count",22),r()()),t&2){let e=l(2);a(9),g(" ",e.tab()==="PENDING"?"Decision":"Outcome"," "),a(3),w(e.window.items()),a(2),m(e.window.hasMore()?14:-1),a(),u("shown",e.window.shown())("total",e.filtered().length)("noun",e.tab()==="PENDING"?"pending request":"decided request")}}function Pt(t,i){if(t&1){let e=q();s(0,"div",11)(1,"app-search-input",12),K("valueChange",function(d){h(e);let _=l();return B(_.query,d)||(_.query=d),v(d)}),r()(),p(2,pt,2,1,"app-empty-state",13)(3,Nt,16,5,"div",14)}if(t&2){let e=l();a(),j("value",e.query),a(),m(e.filtered().length===0?2:3)}}function At(t,i){if(t&1){let e=q();s(0,"app-request-decision-dialog",44),C("confirmed",function(d){let _=h(e),be=l();return v(be.decide(_.request,_.decision,d))})("closed",function(){h(e);let d=l();return v(d.confirming.set(null))}),r()}if(t&2){let e=i;u("request",e.request)("decision",e.decision)}}var De=class t{store=R(A);names=R(se);query=f("");tab=f("PENDING");confirming=f(null);activeTab="bg-brand text-brand-foreground";inactiveTab="text-muted-foreground hover:bg-muted";tabRows=x(()=>this.tab()==="PENDING"?this.store.pending():this.store.decided());filtered=x(()=>{let i=this.tabRows(),e=this.query().trim().toLowerCase();return e?i.filter(o=>o.email.toLowerCase().includes(e)||(o.serviceUser??"").toLowerCase().includes(e)||(o.group??"").toLowerCase().includes(e)||(o.roleName??"").toLowerCase().includes(e)||(o.accountNumber??"").toLowerCase().includes(e)||(o.resourceName??"").toLowerCase().includes(e)):i});window=ve(this.filtered,20);isDeciding(i){return this.store.deciding().has(i.requestId)}ask(i,e){this.confirming.set({request:i,decision:e})}decide(i,e,o){this.confirming.set(null);let d=o.note||void 0;e==="APPROVED"?this.store.approve(i,d,o.durationHours):this.store.deny(i,d)}dur(i){return b(i)}grantedLabel(i){return i.grantedDurationHours?`Granted ${b(i.grantedDurationHours)}`:"Granted"}ago=N;stampDate(i){let e=this.parse(i);return e?e.toLocaleDateString(void 0,{day:"2-digit",month:"short",year:"numeric"}):"\u2014"}stampTime(i){let e=this.parse(i);return e?e.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}):""}exact(i){let e=this.parse(i);return e?e.toLocaleString(void 0,{timeZoneName:"short"}):""}parse(i){if(!i)return null;let e=new Date(i);return Number.isNaN(e.getTime())?null:e}constructor(){this.store.load(),this.names.ensure()}static \u0275fac=function(e){return new(e||t)};static \u0275cmp=D({type:t,selectors:[["app-admin-requests-page"]],hostAttrs:[1,"flex","min-h-0","flex-1","flex-col"],decls:13,vars:9,consts:[[3,"fill"],["pageHeader","","title","Requests","subtitle","Roles people are asking for \u2014 decide each one.","subtitleInfo","Granting one gives them the role straight away; denying leaves their access untouched.",3,"showHeaderSearch"],["headerActions","",1,"inline-flex","rounded-lg","border","border-border-strong","bg-surface","p-0.5"],[1,"rounded-md","px-3","py-1.5","text-sm","font-medium","transition-colors",3,"click"],[1,"ml-1.5","inline-flex","h-5","min-w-5","items-center","justify-center","rounded-full","bg-warning-muted","px-1.5","text-[11px]","font-semibold","text-warning"],["tone","danger"],[1,"space-y-2"],[3,"request","decision"],["sizeClass","h-16 w-full"],["title","No pending requests"],["title","No decisions yet"],[1,"mb-3","flex","shrink-0","justify-end"],["compact","","placeholder","Search by email or account",1,"w-[260px]",3,"valueChange","value"],["title","No matches"],[1,"flex","min-h-0","flex-1","flex-col"],[1,"hidden","shrink-0","gap-4","px-4","py-2.5","md:flex"],[1,"flex-1","ui-microlabel","text-text-secondary"],[1,"w-44","ui-microlabel","text-text-secondary"],[1,"w-56","text-right","ui-microlabel","text-text-secondary"],[1,"min-h-0","flex-1","overflow-y-auto"],[1,"p-4","transition-shadow","duration-[180ms]","hover:shadow-card-hover","md:flex","md:items-center","md:gap-4"],["appInfiniteScroll",""],[3,"shown","total","noun"],[1,"min-w-0","flex-1","overflow-hidden"],[1,"ui-card-title","truncate"],["tone","gray",1,"ml-1.5","align-middle"],[1,"mt-3","min-w-0","flex-1","overflow-hidden","md:mt-0"],[1,"flex","flex-wrap","items-center","gap-1.5"],["tone","warning"],[1,"mt-1.5","line-clamp-2","text-xs","italic","text-muted-foreground",3,"title"],[1,"mt-3","w-full","shrink-0","md:mt-0","md:w-44",3,"title"],[1,"text-xs","font-medium","text-surface-foreground","tabular-nums"],[1,"md:hidden"],[1,"mt-0.5","text-xs","text-muted-foreground","tabular-nums"],[1,"mt-3","flex","w-full","shrink-0","items-center","justify-end","gap-2","md:mt-0","md:w-56"],[1,"text-right",3,"title"],[1,"min-w-0","truncate"],["tone","brand"],["variant","outline","size","sm",3,"click","disabled"],["size","sm",3,"click","loading"],[3,"tone"],[1,"mt-1","text-xs","text-surface-foreground","tabular-nums"],[1,"text-xs","text-muted-foreground"],["appInfiniteScroll","",3,"reached"],[3,"confirmed","closed","request","decision"]],template:function(e,o){if(e&1&&(s(0,"app-page",0)(1,"app-page-header",1)(2,"div",2)(3,"button",3),C("click",function(){return o.tab.set("PENDING")}),n(4," Pending "),p(5,at,2,1,"span",4),r(),s(6,"button",3),C("click",function(){return o.tab.set("DECIDED")}),n(7," Decided "),r()()(),p(8,rt,2,1,"app-banner",5)(9,st,4,0,"div",6)(10,ct,2,1)(11,Pt,4,2),r(),p(12,At,1,2,"app-request-decision-dialog",7)),e&2){let d;u("fill",!0),a(),u("showHeaderSearch",!1),a(2),E(o.tab()==="PENDING"?o.activeTab:o.inactiveTab),a(2),m(o.store.pending().length?5:-1),a(),E(o.tab()==="DECIDED"?o.activeTab:o.inactiveTab),a(2),m(o.store.error()?8:o.store.requests()===null?9:o.tabRows().length===0?10:11),a(4),m((d=o.confirming())?12:-1,d)}},dependencies:[Z,P,T,k,Ce,me,ce,he,_e,M,pe,ge,xe,fe],encapsulation:2})};export{De as AdminRequestsPageComponent};