// @bun
var{defineProperty:R,getOwnPropertyNames:w,getOwnPropertyDescriptor:z}=Object,A=Object.prototype.hasOwnProperty;function D(j){return this[j]}var O=(j)=>{var k=(Y??=new WeakMap).get(j),q;if(k)return k;if(k=R({},"__esModule",{value:!0}),j&&typeof j==="object"||typeof j==="function"){for(var B of w(j))if(!A.call(k,B))R(k,B,{get:D.bind(j,B),enumerable:!(q=z(j,B))||q.enumerable})}return Y.set(j,k),k},Y;var F=(j)=>j;function P(j,k){this[j]=F.bind(null,k)}var h=(j,k)=>{for(var q in k)R(j,q,{get:k[q],enumerable:!0,configurable:!0,set:P.bind(k,q)})};var U=(j,k)=>()=>(j&&(k=j(j=0)),k);var I=import.meta.require;function _(){return"loading"in HTMLImageElement.prototype}function N(){return"IntersectionObserver"in window}function y(j={}){let k={...G,...j},q=document.querySelectorAll(k.selector);if(q.length===0)return()=>{};if(k.useNative&&_())return q.forEach((x)=>{if(x.tagName==="IMG"||x.tagName==="IFRAME")M(x,k)}),()=>{};if(!N())return q.forEach((x)=>M(x,k)),()=>{};let B=new IntersectionObserver((x)=>{x.forEach((C)=>{if(C.isIntersecting){let J=C.target;M(J,k),B.unobserve(J)}})},{root:k.root,rootMargin:k.rootMargin,threshold:k.threshold});return q.forEach((x)=>B.observe(x)),()=>{B.disconnect()}}function M(j,k={}){let{onLoad:q,onLoaded:B,onError:x}=k;if(q)q(j);let C=j.tagName==="IMG",J=j.tagName==="VIDEO",K=j.tagName==="IFRAME";if(C)Z(j,B,x);else if(J)$(j,B,x);else if(K)V(j,B,x);else{let W=j.querySelector("img[data-src], img[data-srcset]"),X=j.querySelector("video[data-src]");if(W)Z(W,()=>{if(B)B(j)},(Q)=>{if(x)x(j,Q)});else if(X)$(X,()=>{if(B)B(j)},(Q)=>{if(x)x(j,Q)});j.querySelectorAll("source[data-srcset]").forEach((Q)=>{let H=Q;if(H.dataset.srcset)H.srcset=H.dataset.srcset,delete H.dataset.srcset;if(H.dataset.sizes)H.sizes=H.dataset.sizes,delete H.dataset.sizes})}}function Z(j,k,q){let B=()=>{j.classList.add("stx-img-loaded"),j.style.opacity="1";let C=j.closest(".stx-img-placeholder");if(C)C.classList.add("stx-img-loaded");if(k)k(j)},x=()=>{if(j.classList.add("stx-img-error"),q)q(j,Error(`Failed to load image: ${j.src}`))};if(j.addEventListener("load",B,{once:!0}),j.addEventListener("error",x,{once:!0}),j.dataset.srcset)j.srcset=j.dataset.srcset,delete j.dataset.srcset;if(j.dataset.src)j.src=j.dataset.src,delete j.dataset.src;if(j.dataset.sizes)j.sizes=j.dataset.sizes,delete j.dataset.sizes}function $(j,k,q){let B=()=>{if(j.classList.add("stx-video-loaded"),k)k(j)},x=()=>{if(j.classList.add("stx-video-error"),q)q(j,Error(`Failed to load video: ${j.src}`))};if(j.addEventListener("loadeddata",B,{once:!0}),j.addEventListener("error",x,{once:!0}),j.querySelectorAll("source[data-src]").forEach((J)=>{let K=J;if(K.dataset.src)K.src=K.dataset.src,delete K.dataset.src}),j.dataset.src)j.src=j.dataset.src,delete j.dataset.src;if(j.dataset.poster)j.poster=j.dataset.poster,delete j.dataset.poster;j.load()}function V(j,k,q){let B=()=>{if(j.classList.add("stx-iframe-loaded"),k)k(j)},x=()=>{if(j.classList.add("stx-iframe-error"),q)q(j,Error(`Failed to load iframe: ${j.src}`))};if(j.addEventListener("load",B,{once:!0}),j.addEventListener("error",x,{once:!0}),j.dataset.src)j.src=j.dataset.src,delete j.dataset.src}function u(j){M(j,{})}function c(j="[data-stx-lazy]"){document.querySelectorAll(j).forEach((q)=>M(q,{}))}function f(j={}){let k={...G,...j};return new IntersectionObserver((q,B)=>{q.forEach((x)=>{if(x.isIntersecting)M(x.target,k),B.unobserve(x.target)})},{root:k.root,rootMargin:k.rootMargin,threshold:k.threshold})}function p(j,k){j.observe(k)}function L(j){j.disconnect()}function E(){return`
(function() {
  'use strict';

  if (typeof window === 'undefined') return;

  var defaultOptions = {
    root: null,
    rootMargin: '50px 0px',
    threshold: 0
  };

  function isNativeLazySupported() {
    return 'loading' in HTMLImageElement.prototype;
  }

  function loadElement(el) {
    var img = el.tagName === 'IMG' ? el : el.querySelector('img[data-src], img[data-srcset]');
    var video = el.tagName === 'VIDEO' ? el : el.querySelector('video[data-src]');

    // Load sources in picture elements
    var sources = el.querySelectorAll('source[data-srcset]');
    sources.forEach(function(source) {
      if (source.dataset.srcset) {
        source.srcset = source.dataset.srcset;
        delete source.dataset.srcset;
      }
      if (source.dataset.sizes) {
        source.sizes = source.dataset.sizes;
        delete source.dataset.sizes;
      }
    });

    if (img) {
      img.onload = function() {
        img.style.opacity = '1';
        img.classList.add('stx-img-loaded');
        var wrapper = img.closest('.stx-img-placeholder');
        if (wrapper) wrapper.classList.add('stx-img-loaded');
      };
      if (img.dataset.srcset) { img.srcset = img.dataset.srcset; delete img.dataset.srcset; }
      if (img.dataset.src) { img.src = img.dataset.src; delete img.dataset.src; }
      if (img.dataset.sizes) { img.sizes = img.dataset.sizes; delete img.dataset.sizes; }
    }

    if (video) {
      var videoSources = video.querySelectorAll('source[data-src]');
      videoSources.forEach(function(source) {
        if (source.dataset.src) { source.src = source.dataset.src; delete source.dataset.src; }
      });
      if (video.dataset.src) { video.src = video.dataset.src; delete video.dataset.src; }
      if (video.dataset.poster) { video.poster = video.dataset.poster; delete video.dataset.poster; }
      video.load();
    }
  }

  function init() {
    var elements = document.querySelectorAll('[data-stx-lazy]');
    if (!elements.length) return;

    if (!('IntersectionObserver' in window)) {
      elements.forEach(loadElement);
      return;
    }

    var observer = new IntersectionObserver(function(entries) {
      entries.forEach(function(entry) {
        if (entry.isIntersecting) {
          loadElement(entry.target);
          observer.unobserve(entry.target);
        }
      });
    }, defaultOptions);

    elements.forEach(function(el) { observer.observe(el); });
  }

  // Initialize when DOM is ready
  if (document.readyState === 'loading') {
    document.addEventListener('DOMContentLoaded', init);
  }
else {
    init();
  }

  // Expose for manual use
  window.STX = window.STX || {};
  window.STX.lazyLoad = loadElement;
  window.STX.initLazyLoading = init;
})();
`.trim()}var G;var S=U(()=>{G={root:null,rootMargin:"50px 0px",threshold:0,useNative:!0,selector:"[data-stx-lazy]"}});S();export{p as observeElement,M as loadElement,c as lazyLoadAll,u as lazyLoad,_ as isNativeLazySupported,N as isIntersectionObserverSupported,y as initLazyLoading,E as generateLazyLoadRuntime,L as disconnectObserver,f as createLazyObserver};
