/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/@nuclei-components/lazy-picture@0.3.3/dist/lazyPicture.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
!function(){"use strict";let t=document.createElement("template");t.innerHTML='<style>\n    :host{\n      display: flex;\n      --object-fit: var(--lazy-picture-object-fit, cover)\n    }\n    #content{\n      display: flex;\n      justify-content: center;\n      width: 100%;\n      height: 100%;\n    }\n    picture{\n      width: 100%;\n      height: auto;\n    }\n    img{\n      width: 100%;\n      height: 100%;\n      vertical-align: top;\n      float: left;\n      object-fit: var(--object-fit);\n    }\n    :host([fit=cover]){\n      --object-fit: cover;\n    }\n    :host([fit=contain]){\n      --object-fit: contain;\n    }\n    :host([fit=fill]) img{\n      --object-fit: fill;\n    }\n    :host([fit=none]) img{\n      --object-fit: none;\n    }\n    :host([fit=scale-down]) img{\n      --object-fit: scale-down;\n    }\n  </style>\n  <slot></slot>\n  <div id="content"></div>\n';class e extends HTMLElement{constructor(){super(),this._active=void 0,this._img=null,this._picture=null,this.src=null,this.alt=null,this._observer=null,this._threshold=0,this.offset="100px",this._content=null;let e=this.attachShadow({mode:"open"});"undefined"!=typeof ShadyCSS&&(ShadyCSS.prepareTemplate(t,"lazy-picture"),ShadyCSS.styleElement(this)),e.appendChild(document.importNode(t.content,!0)),this._content=e.querySelector("#content")}static get observedAttributes(){return["active","threshold","offset","src","alt"]}attributeChangedCallback(t,e,i){e!==i&&(this[t]=i)}connectedCallback(){this._initialize(),this._createObserver()}_initialize(){var t;this._picture=document.createElement("picture"),this._img=document.createElement("img"),this._img.setAttribute("alt",this.alt),t=()=>{Array.from(this.shadowRoot.querySelector("slot").assignedNodes()).filter((t=>"SOURCE"===t.nodeName)).forEach((t=>{this._picture.appendChild(t)})),this._img.addEventListener("load",(()=>{this.dispatchEvent(new CustomEvent("loaded",{detail:{src:this._img.currentSrc,width:this._img.naturalWidth,height:this._img.naturalHeight}}))})),this._picture.appendChild(this._img),this._content.appendChild(this._picture)},"loading"!==document.readyState?t():document.addEventListener("DOMContentLoaded",t)}_loadImage(){this._img.setAttribute("src",this.src),this._destroyObserver()}_createObserver(){void 0===this._active&&"function"==typeof IntersectionObserver&&(this._observer=new IntersectionObserver((t=>{t.forEach((t=>{t.isIntersecting&&t.target.setAttribute("active","true")}))}),{rootMargin:this.offset,threshold:this._threshold}),this._observer.observe(this))}_destroyObserver(){null!==this._observer&&this._observer.unobserve(this)}set active(t){t=("true"===t||!0===t).toString(),this._active!==t&&(this._active=t,this.setAttribute("active",this._active),this._loadImage())}set threshold(t){t=parseFloat(parseFloat(t+"").toFixed(2)),(isNaN(t)||t>1||t<0)&&(t=1),this._threshold!==t&&(this._threshold=t)}}window.customElements.define("lazy-picture",e)}();
//# sourceMappingURL=/sm/f3008e2d904a0ab564b8c3b5cc4361436eef07e858eba388168ffa0e263ca969.map