import{r as t,f as i,h as s,H as e,d as n}from"./p-23450e8b.js";import{b as r}from"./p-8538de1a.js";import{g as o}from"./p-1e77b5bd.js";const h=":host{display:block;object-fit:contain}img{display:block;width:100%;height:100%;object-fit:inherit;object-position:inherit}";const d=class{constructor(s){t(this,s);this.ionImgWillLoad=i(this,"ionImgWillLoad",7);this.ionImgDidLoad=i(this,"ionImgDidLoad",7);this.ionError=i(this,"ionError",7);this.inheritedAttributes={};this.onLoad=()=>{this.ionImgDidLoad.emit()};this.onError=()=>{this.ionError.emit()};this.loadSrc=undefined;this.loadError=undefined;this.alt=undefined;this.src=undefined}srcChanged(){this.addIO()}componentWillLoad(){this.inheritedAttributes=r(this.el,["draggable"])}componentDidLoad(){this.addIO()}addIO(){if(this.src===undefined){return}if(typeof window!=="undefined"&&"IntersectionObserver"in window&&"IntersectionObserverEntry"in window&&"isIntersecting"in window.IntersectionObserverEntry.prototype){this.removeIO();this.io=new IntersectionObserver((t=>{if(t[t.length-1].isIntersecting){this.load();this.removeIO()}}));this.io.observe(this.el)}else{setTimeout((()=>this.load()),200)}}load(){this.loadError=this.onError;this.loadSrc=this.src;this.ionImgWillLoad.emit()}removeIO(){if(this.io){this.io.disconnect();this.io=undefined}}render(){const{loadSrc:t,alt:i,onLoad:n,loadError:r,inheritedAttributes:h}=this;const{draggable:d}=h;return s(e,{class:o(this)},s("img",{decoding:"async",src:t,alt:i,onLoad:n,onError:r,part:"image",draggable:a(d)}))}get el(){return n(this)}static get watchers(){return{src:["srcChanged"]}}};const a=t=>{switch(t){case"true":return true;case"false":return false;default:return undefined}};d.style=h;export{d as ion_img};
//# sourceMappingURL=p-81fd194e.entry.js.map