// @bun
var{defineProperty:Z,getOwnPropertyNames:S,getOwnPropertyDescriptor:T}=Object,D=Object.prototype.hasOwnProperty;function I(j){return this[j]}var m=(j)=>{var k=(R??=new WeakMap).get(j),z;if(k)return k;if(k=Z({},"__esModule",{value:!0}),j&&typeof j==="object"||typeof j==="function"){for(var J of S(j))if(!D.call(k,J))Z(k,J,{get:I.bind(j,J),enumerable:!(z=T(j,J))||z.enumerable})}return R.set(j,k),k},R;var _=(j)=>j;function A(j,k){this[j]=_.bind(null,k)}var n=(j,k)=>{for(var z in k)Z(j,z,{get:k[z],enumerable:!0,configurable:!0,set:A.bind(k,z)})};var L=(j,k)=>()=>(j&&(k=j(j=0)),k);var e=import.meta.require;function u(j,k={}){let z={...f,...k},J=j.closest(".stx-img-placeholder");if(!J){y(j,z);return}if(J.style.setProperty("--stx-img-transition-duration",`${z.duration}ms`),J.style.setProperty("--stx-img-transition-easing",z.easing),z.loadingClass)J.classList.add(z.loadingClass);if(j.complete&&j.naturalWidth>0)U(j,J,z);else j.addEventListener("load",()=>U(j,J,z),{once:!0}),j.addEventListener("error",()=>v(j,J,z),{once:!0})}function y(j,k){let z=()=>{j.style.transition=`opacity ${k.duration}ms ${k.easing}`,j.style.opacity="1",j.classList.remove(k.loadingClass),j.classList.add(k.loadedClass)};if(j.complete&&j.naturalWidth>0)z();else j.style.opacity="0",j.classList.add(k.loadingClass),j.addEventListener("load",z,{once:!0})}function U(j,k,z){if(z.loadingClass)k.classList.remove(z.loadingClass);if(z.loadedClass)k.classList.add(z.loadedClass);if(j.style.opacity="1",z.removePlaceholder)setTimeout(()=>{k.style.backgroundImage="none"},z.duration)}function v(j,k,z){if(z.loadingClass)k.classList.remove(z.loadingClass);k.classList.add("stx-img-error"),j.classList.add("stx-img-error")}function t(j,k){let z=q(j),J=k.getContext("2d");if(!J)return;k.width=z.w,k.height=z.h;let K=J.createImageData(z.w,z.h);K.data.set(z.rgba),J.putImageData(K,0,0)}function q(j){let k=j[0]|j[1]<<8|j[2]<<16,z=(k&63)/63,J=(k>>6&63)/31.5-1,K=(k>>12&63)/31.5-1,$=(k>>18&31)/31,Q=k>>23!==0,Y=j[3]|j[4]<<8,w=(Y>>3&63)/63,l=(Y>>9&63)/63,C=Y>>15!==0,c=Math.max(3,C?Q?5:7:Q?5:5),b=Math.max(3,C?Q?5:5:Q?5:7),d=32,h=32,M=new Uint8ClampedArray(4096);for(let V=0;V<32;V++)for(let W=0;W<32;W++){let X=(V*32+W)*4,F=W/31,N=V/31,P=z+(F-0.5)*$*0.5+(N-0.5)*$*0.5,B=J*(1-F*0.3),E=K*(1-N*0.3),H=P-0.6666666666666666*B,O=(3*P-H+E)/2,G=O-E;M[X]=Math.max(0,Math.min(255,Math.round(O*255))),M[X+1]=Math.max(0,Math.min(255,Math.round(G*255))),M[X+2]=Math.max(0,Math.min(255,Math.round(H*255))),M[X+3]=255}return{w:32,h:32,rgba:M}}function s(j){let k=q(j),z=document.createElement("canvas");z.width=k.w,z.height=k.h;let J=z.getContext("2d");if(!J)return"";let K=J.createImageData(k.w,k.h);return K.data.set(k.rgba),J.putImageData(K,0,0),z.toDataURL("image/png")}function r(j){let k=atob(j),z=new Uint8Array(k.length);for(let J=0;J<k.length;J++)z[J]=k.charCodeAt(J);return z}function p(j,k,z=300){return new Promise((J)=>{j.style.transition=`opacity ${z}ms ease-out`,k.style.transition=`opacity ${z}ms ease-out`,k.style.opacity="0",k.offsetWidth,j.style.opacity="0",k.style.opacity="1",setTimeout(J,z)})}function i(j={}){document.querySelectorAll("[data-stx-blur-up], .stx-img-placeholder img").forEach((z)=>{u(z,j)})}function o(){return`
(function() {
  'use strict';

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

  var defaultOptions = {
    duration: 300,
    easing: 'ease-out',
    loadedClass: 'stx-img-loaded'
  };

  function initBlurUp(img, options) {
    options = Object.assign({}, defaultOptions, options);
    var wrapper = img.closest('.stx-img-placeholder');

    if (!wrapper) {
      if (img.complete && img.naturalWidth > 0) {
        img.style.opacity = '1';
      }
else {
        img.style.opacity = '0';
        img.style.transition = 'opacity ' + options.duration + 'ms ' + options.easing;
        img.onload = function() { img.style.opacity = '1'; };
      }
      return;
    }

    wrapper.style.setProperty('--stx-img-transition-duration', options.duration + 'ms');
    wrapper.style.setProperty('--stx-img-transition-easing', options.easing);

    var onLoaded = function() {
      wrapper.classList.add(options.loadedClass);
      img.style.opacity = '1';
    };

    if (img.complete && img.naturalWidth > 0) {
      onLoaded();
    }
else {
      img.addEventListener('load', onLoaded, { once: true });
    }
  }

  function init() {
    var elements = document.querySelectorAll('.stx-img-placeholder img, [data-stx-blur-up]');
    elements.forEach(function(img) { initBlurUp(img); });
  }

  // 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.initBlurUp = initBlurUp;
  window.STX.initAllBlurUp = init;
})();
`.trim()}function a(){return`
.stx-img-placeholder {
  position: relative;
  overflow: hidden;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.stx-img-placeholder img {
  display: block;
  width: 100%;
  height: auto;
  opacity: 0;
  transition: opacity var(--stx-img-transition-duration, 300ms) var(--stx-img-transition-easing, ease-out);
}

.stx-img-placeholder.stx-img-loaded img {
  opacity: 1;
}

.stx-img-blur {
  filter: blur(20px);
  transform: scale(1.1);
  transition: filter var(--stx-img-transition-duration, 300ms) var(--stx-img-transition-easing, ease-out),
              transform var(--stx-img-transition-duration, 300ms) var(--stx-img-transition-easing, ease-out);
}

.stx-img-loaded .stx-img-blur,
.stx-img-blur.stx-img-loaded {
  filter: blur(0);
  transform: scale(1);
}

.stx-img-error {
  opacity: 0.5;
}
`.trim()}var f;var x=L(()=>{f={duration:300,easing:"ease-out",removePlaceholder:!1,loadedClass:"stx-img-loaded",loadingClass:"stx-img-loading"}});x();export{q as thumbHashToRGBA,s as thumbHashToDataURL,t as renderThumbhashToCanvas,r as parseThumbhashString,u as initBlurUp,i as initAllBlurUp,o as generateBlurUpRuntime,a as generateBlurUpCSS,p as crossfadeTransition};
