import{c as P,d as j}from"./chunk-LGDTZDAH.js";import{a as I,b as $}from"./chunk-IGDIZLCB.js";import{Cc as F,Ci as w,Dc as G,Di as W,ic as g,jc as N,wc as u,xc as V}from"./chunk-2GUKPKKM.js";import{a as A,b as D}from"./chunk-3AUKOF45.js";import{Bb as n,Ic as r,Ja as d,Lc as M,Oa as C,Rb as y,Sd as _,Vb as b,Xb as S,ia as m,lc as c,nc as l,oa as U,pc as v,qc as T,sc as s,wb as f,xc as x,yc as B,za as h,zc as a}from"./chunk-XJKQ67XR.js";import{e as O}from"./chunk-SZAW6ZBW.js";function k(t,p){if(t&1&&a(0,"i"),t&2){let e=r();l(e.iconStyle),T("di dvl-icon-",e.imageIcon==null?null:e.imageIcon.icon," text-base ",e.iconClass,""),c("color",e.item!=null&&e.item.isTemplate&&(e.imageIcon==null?null:e.imageIcon.color)===e.defaultColor?"":e.imageIcon==null?null:e.imageIcon.color)}}function z(t,p){if(t&1&&a(0,"img",4),t&2){let e=r();l(e.imageStyle),v("text-base ",e.imageClass,""),M("src",e.customImage,f)}}function E(t,p){t&1&&a(0,"i",3)}var oe,H=O(()=>{_();D();$();j();U();N();G();V();W();_();oe=(()=>{class t extends A{constructor(){super(...arguments),this.imageClass="",this.iconClass="",this.hasShortcut=!1,this.isFavorite=!1,this.customImageService=h(P)}ngOnInit(){this.item&&(this.updateImage(),this.subscribeToImageChanged())}ngOnChanges(e){this.updateImage()}updateImage(){this.globalImageId?this.getGlobalImage():this.customImageBytes?this.getCustomImage():this.getImageIcon()}getImageIcon(){if(!this.item)return;let e=this.item.type??this.item.connectionType;if(this.defaultColor=I.getFromTypes(e,this.item.connectionSubType,this.getSpecificSubType(e,this.item)).color,this.customImage=null,this.item?.imageIcon)this.imageIcon=this.item.imageIcon;else{let i=I.getFromConnection(this.item);this.imageIcon=i.icon&&i.color?i:null}}getSpecificSubType(e,i){switch(e){case g.VPN:return F[i.vpnApplication??i.data?.vpn?.application];case g.PAM:switch(u[i.connectionSubType]){case u.AWSIAMUser:return w[i.awsCredentialMode??i.data?.awsPamCredentialSettings?.credentialMode]}}}getGlobalImage(){this.customImageService.getById(this.globalImageId).pipe(m(this.destroyed$)).subscribe(e=>{e?this.customImage=this.customImageService.customImageToViewModel(e).imageUrl:this.customImageBytes?this.getCustomImage():this.getImageIcon()})}getCustomImage(){return this.customImage=this.customImageBytes,this.customImageBytes&&this.customImageBytes.indexOf("data:image/png;base64")<0&&(this.customImage="data:image/png;base64,"+this.customImageBytes),this.customImageBytes}subscribeToImageChanged(){this.customImageService.iconChanged.pipe(m(this.destroyed$)).subscribe(()=>this.updateImage())}static{this.\u0275fac=(()=>{let e;return function(o){return(e||(e=C(t)))(o||t)}})()}static{this.\u0275cmp=y({type:t,selectors:[["dvls-connection-icon-and-custom-image-component"]],inputs:{item:"item",globalImageId:"globalImageId",customImageBytes:"customImageBytes",imageStyle:"imageStyle",iconStyle:"iconStyle",imageClass:"imageClass",iconClass:"iconClass",hasShortcut:"hasShortcut",isFavorite:"isFavorite"},features:[b,d],decls:4,vars:5,consts:[[1,"relative"],[3,"color","style","class"],[3,"class","style","src"],["aria-hidden","true",1,"shortcut-icon","di","dvl-icon-shortcut","absolute","right-0","bottom-0","text-[6px]","text-white","border","border-white","bg-[var(--icon-color)]"],[3,"src"]],template:function(i,o){i&1&&(x(0,"div",0),S(1,k,1,8,"i",1)(2,z,1,6,"img",2)(3,E,1,0,"i",3),B()),i&2&&(c("--icon-color",o.imageIcon==null?null:o.imageIcon.color),n(),s(!o.customImage&&o.imageIcon?1:-1),n(),s(o.customImage?2:-1),n(),s(o.hasShortcut?3:-1))},encapsulation:2})}}return t})()});export{oe as a,H as b};
