import{a as r}from"./chunk-5TTXT2K2.js";import{a as f}from"./chunk-CAGDTHS6.js";import{Bc as h,J as n,Kd as d,La as a,Ld as v,db as p,eb as m,ga as l,k as o,kb as c,ra as i}from"./chunk-GJDGQISV.js";var E=class s{constructor(e){this.el=e;this.el.nativeElement.onerror=()=>{}}renderer=i(p);tooltip=i(r);httpClient=i(v);ngAfterViewInit(){let e=this.el.nativeElement;!e||!e.src||(e.onerror=()=>{this.setFallbackImage()},e.src.includes("cloudinary")?this.httpClient.get(e.src,{responseType:"blob"}).pipe(l(t=>{t.type.startsWith("image/")?this.addTooltip("Click to view image"):this.setFallbackImage()}),n(t=>(t instanceof d&&this.setFallbackImage(),o))).subscribe():this.addTooltip(""))}setFallbackImage(){this.renderer.setAttribute(this.el.nativeElement,"src",f.FALLBACK_PRODUCT_IMAGE_URL),this.renderer.setStyle(this.el.nativeElement,"border","1px solid #dee2e6"),this.renderer.setStyle(this.el.nativeElement,"border-radius","4px")}addTooltip(e){this.renderer.listen(this.el.nativeElement,"mouseenter",()=>{this.tooltip.message=e,this.tooltip.position="above",this.tooltip.show()}),this.renderer.listen(this.el.nativeElement,"mouseleave",()=>{this.tooltip.message="",this.tooltip.hide()})}static \u0275fac=function(t){return new(t||s)(m(a))};static \u0275dir=c({type:s,selectors:[["","appFallbackImage",""]],features:[h([r])]})};export{E as a};
