import{c as l}from"./chunk-AITLIL5K.js";import{Da as a,La as t,Lc as c,Pa as o,ma as s,sa as n}from"./chunk-QBQIXSUA.js";var u=class i{constructor(e,r,m,h){this.el=e;this.renderer=r;this.reportService=m;this.sanitizer=h}url;type;placeholder="https://placehold.co/64x64";ngOnChanges(e){this.loadImage()}loadImage(){if(!this.url){this.setImage(this.placeholder);return}this.reportService.get_image(this.getUrl()).subscribe({next:e=>{let r=URL.createObjectURL(e),m=this.sanitizer.bypassSecurityTrustUrl(r);this.setImage(r)},error:()=>this.setImage(this.placeholder)})}setImage(e){this.renderer.setAttribute(this.el.nativeElement,"src",e),this.renderer.setAttribute(this.el.nativeElement,"alt",this.url?.split("/")[1]||"placeholder")}getUrl(){switch(this.type){case 3:return`administrator/reports/users/images/${this.url}`;case 0:return`administrator/reports/vehicles/images/${this.url}`;case 2:return`administrator/reports/inform/images/${this.url}`;case 1:return`administrator/reports/images/${this.url}`;case 4:return`administrator/notices/banners/${this.url}`;case 5:return`administrator/user-profile/images/${this.url}`;case 6:return`/users/cross/images/${this.url}`;case 7:return`/users/cross/banner/${this.url}`;default:return""}}static \u0275fac=function(r){return new(r||i)(t(a),t(o),t(l),t(c))};static \u0275dir=s({type:i,selectors:[["","imgfromurl",""]],inputs:{url:"url",type:"type"},standalone:!0,features:[n]})};export{u as a};
