// @bun
var{defineProperty:qJ,getOwnPropertyNames:zZ,getOwnPropertyDescriptor:UZ}=Object,wZ=Object.prototype.hasOwnProperty;function kZ(J){return this[J]}var X1=(J)=>{var Z=(gJ??=new WeakMap).get(J),$;if(Z)return Z;if(Z=qJ({},"__esModule",{value:!0}),J&&typeof J==="object"||typeof J==="function"){for(var X of zZ(J))if(!wZ.call(Z,X))qJ(Z,X,{get:kZ.bind(J,X),enumerable:!($=UZ(J,X))||$.enumerable})}return gJ.set(J,Z),Z},gJ;var CZ=(J)=>J;function SZ(J,Z){this[J]=CZ.bind(null,Z)}var AZ=(J,Z)=>{for(var $ in Z)qJ(J,$,{get:Z[$],enumerable:!0,configurable:!0,set:SZ.bind(Z,$)})};var C=(J,Z)=>()=>(J&&(Z=J(J=0)),Z);var VJ=import.meta.require;function PZ(J){if(e.set(J.name,J),J.client)jJ.set(J.name,J.client)}function K1(J){return e.get(J)}function B1(){return Array.from(e.values())}function G1(J){return jJ.delete(J),e.delete(J)}function z(J){return PZ(J),{name:J.name,hasEndTag:J.hasEndTag??!0,description:J.description,handler:async($,X,Y,K)=>{let B=xZ(X,J.defaults);if(J.validate){let G=J.validate(B);if(G!==!0){let O=typeof G==="string"?G:`Invalid parameters for @${J.name}`;throw Error(O)}}let H=$;if(J.transform)H=await J.transform($,B,Y,K);if(J.clientScript){let G=J.clientScript(B);H+=`<script>${G}</script>`}if(J.css){let G=J.css(B);H+=`<style>${G}</style>`}return H}}}function H1(J,Z){let $=typeof Z==="function"?{mounted:Z}:Z;return jJ.set(J,$),$}function xZ(J,Z){let $={...Z};for(let X of J){let Y=X.indexOf(":"),K=X.indexOf("="),B=Y>=0&&(K<0||Y<K)?Y:K;if(B>=0){let H=X.slice(0,B).trim(),G=X.slice(B+1).trim();if(G==="true")G=!0;else if(G==="false")G=!1;else if(G==="null")G=null;else if(!Number.isNaN(Number(G)))G=Number(G);else if(typeof G==="string"&&G.startsWith("{"))try{G=JSON.parse(G)}catch{}$[H]=G}else{let H=Object.keys($).filter((G)=>!Z||!(G in Z)).length;$[H===0?"value":`arg${H}`]=X}}return $}function M1(){return[z({name:"uppercase",description:"Convert content to uppercase",transform:(J)=>J.toUpperCase()}),z({name:"lowercase",description:"Convert content to lowercase",transform:(J)=>J.toLowerCase()}),z({name:"capitalize",description:"Capitalize first letter of content",transform:(J)=>J.charAt(0).toUpperCase()+J.slice(1)}),z({name:"trim",description:"Remove leading and trailing whitespace",transform:(J)=>J.trim()}),z({name:"truncate",description:"Truncate content to specified length",defaults:{length:100,suffix:"..."},transform:(J,{length:Z,suffix:$})=>J.length>Z?J.slice(0,Z)+$:J}),z({name:"highlight",description:"Highlight content with background color",defaults:{color:"yellow"},transform:(J,{color:Z})=>`<mark style="background-color: ${Z}; padding: 0.1em 0.2em; border-radius: 0.2em;">${J}</mark>`}),z({name:"badge",description:"Create a badge/tag",defaults:{variant:"default",color:""},transform:(J,{variant:Z,color:$})=>{let X={default:"background: #e5e7eb; color: #374151;",primary:"background: #3b82f6; color: white;",success:"background: #10b981; color: white;",warning:"background: #f59e0b; color: white;",danger:"background: #ef4444; color: white;",info:"background: #06b6d4; color: white;"};return`<span style="${$?`background: ${$}; color: white;`:X[Z]||X.default} padding: 0.25em 0.5em; border-radius: 9999px; font-size: 0.875em; font-weight: 500;">${J}</span>`}}),z({name:"code",description:"Style content as inline code",transform:(J)=>`<code style="background: #f3f4f6; padding: 0.2em 0.4em; border-radius: 0.25em; font-family: ui-monospace, monospace; font-size: 0.875em;">${J}</code>`}),z({name:"tooltip",description:"Add a tooltip to content",defaults:{text:"",position:"top"},hasEndTag:!0,transform:(J,{text:Z,position:$})=>`<span class="stx-tooltip" data-tooltip="${Z}" data-tooltip-position="${$}" style="position: relative; cursor: help;">${J}</span>`,css:()=>`
        .stx-tooltip::after {
          content: attr(data-tooltip);
          position: absolute;
          bottom: 100%;
          left: 50%;
          transform: translateX(-50%);
          padding: 0.5em 0.75em;
          background: #1f2937;
          color: white;
          font-size: 0.75rem;
          border-radius: 0.25rem;
          white-space: nowrap;
          opacity: 0;
          visibility: hidden;
          transition: opacity 0.2s, visibility 0.2s;
          z-index: 1000;
          margin-bottom: 0.25rem;
        }
        .stx-tooltip:hover::after {
          opacity: 1;
          visibility: visible;
        }
      `}),z({name:"clipboard",description:"Add copy to clipboard functionality",defaults:{label:"Copy"},transform:(J,{label:Z})=>{let $=`clipboard-${Date.now()}-${Math.random().toString(36).slice(2)}`;return`
          <span class="stx-clipboard" data-clipboard-id="${$}">
            <span class="stx-clipboard-content">${J}</span>
            <button type="button" class="stx-clipboard-btn" onclick="navigator.clipboard.writeText(document.querySelector('[data-clipboard-id=\\'${$}\\'] .stx-clipboard-content').textContent).then(() => { this.textContent = 'Copied!'; setTimeout(() => this.textContent = '${Z}', 2000); })">${Z}</button>
          </span>
        `},css:()=>`
        .stx-clipboard {
          display: inline-flex;
          align-items: center;
          gap: 0.5em;
        }
        .stx-clipboard-btn {
          padding: 0.25em 0.5em;
          font-size: 0.75em;
          background: #e5e7eb;
          border: none;
          border-radius: 0.25em;
          cursor: pointer;
        }
        .stx-clipboard-btn:hover {
          background: #d1d5db;
        }
      `}),z({name:"time",description:"Display relative time",defaults:{date:""},hasEndTag:!1,transform:(J,{date:Z})=>{let $=Z?new Date(Z).getTime():Date.now();return`<time datetime="${new Date($).toISOString()}" data-stx-relative-time="${$}"></time>`},clientScript:()=>`
        document.querySelectorAll('[data-stx-relative-time]').forEach(el => {
          const timestamp = parseInt(el.dataset.stxRelativeTime);
          const rtf = new Intl.RelativeTimeFormat('en', { numeric: 'auto' });
          const diff = timestamp - Date.now();
          const seconds = Math.floor(diff / 1000);
          const minutes = Math.floor(seconds / 60);
          const hours = Math.floor(minutes / 60);
          const days = Math.floor(hours / 24);

          if (Math.abs(days) > 0) el.textContent = rtf.format(days, 'day');
          else if (Math.abs(hours) > 0) el.textContent = rtf.format(hours, 'hour');
          else if (Math.abs(minutes) > 0) el.textContent = rtf.format(minutes, 'minute');
          else el.textContent = rtf.format(seconds, 'second');
        });
      `}),z({name:"currency",description:"Format number as currency",defaults:{amount:0,currency:"USD",locale:"en-US"},hasEndTag:!1,transform:(J,{amount:Z,currency:$,locale:X})=>{return new Intl.NumberFormat(X,{style:"currency",currency:$}).format(Z)}}),z({name:"number",description:"Format number with locale",defaults:{value:0,decimals:2,locale:"en-US"},hasEndTag:!1,transform:(J,{value:Z,decimals:$,locale:X})=>{return new Intl.NumberFormat(X,{minimumFractionDigits:$,maximumFractionDigits:$}).format(Z)}}),z({name:"pluralize",description:"Pluralize text based on count",defaults:{count:0,singular:"",plural:""},hasEndTag:!1,transform:(J,{count:Z,singular:$,plural:X})=>{let Y=Z===1?$:X||$+"s";return`${Z} ${Y}`}})]}function O1(){return`
// STX Directive Runtime
(function() {
  if (typeof window === 'undefined') return;

  window.STX = window.STX || {};
  window.STX.directives = window.STX.directives || {};

  // Register a client-side directive
  window.STX.directive = function(name, definition) {
    if (typeof definition === 'function') {
      definition = { mounted: definition };
    }
    window.STX.directives[name] = definition;
  };

  // Apply directive to element
  window.STX.applyDirective = function(el, name, value, arg, modifiers) {
    const directive = window.STX.directives[name];
    if (!directive) {
      console.warn('[stx] Unknown directive:', name);
      return;
    }

    const binding = {
      value: value,
      arg: arg,
      modifiers: modifiers || {},
      dir: directive
    };

    // Store binding on element for updates
    el.__stx_directives__ = el.__stx_directives__ || {};
    el.__stx_directives__[name] = binding;

    // Call lifecycle hooks
    if (directive.created) directive.created(el, binding);
    if (directive.beforeMount) directive.beforeMount(el, binding);

    // Defer mounted until DOM is ready
    requestAnimationFrame(function() {
      if (directive.mounted) directive.mounted(el, binding);
    });
  };

  // Update directive on element
  window.STX.updateDirective = function(el, name, newValue) {
    const binding = el.__stx_directives__ && el.__stx_directives__[name];
    if (!binding) return;

    const directive = binding.dir;
    const oldValue = binding.value;
    binding.oldValue = oldValue;
    binding.value = newValue;

    if (directive.beforeUpdate) directive.beforeUpdate(el, binding);
    if (directive.updated) directive.updated(el, binding);
  };

  // Remove directive from element
  window.STX.removeDirective = function(el, name) {
    const binding = el.__stx_directives__ && el.__stx_directives__[name];
    if (!binding) return;

    const directive = binding.dir;
    if (directive.beforeUnmount) directive.beforeUnmount(el, binding);
    if (directive.unmounted) directive.unmounted(el, binding);

    delete el.__stx_directives__[name];
  };

  // Auto-apply directives on page load
  document.addEventListener('DOMContentLoaded', function() {
    document.querySelectorAll('[data-stx-directive]').forEach(function(el) {
      const directives = el.dataset.stxDirective.split(';');
      directives.forEach(function(d) {
        const [name, value] = d.split(':').map(s => s.trim());
        window.STX.applyDirective(el, name, value);
      });
    });
  });

  console.log('[stx] Directive runtime initialized');
})();
`}function N1(J){let Z=/v-(\w+)(?::(\w+))?(?:\.([\w.]+))?="([^"]*)"/g;return J.replace(Z,($,X,Y,K,B)=>{let G=(K?K.split("."):[]).reduce((O,q)=>{return O[q]=!0,O},{});return`data-stx-directive="${X}:${B}" data-stx-directive-arg="${Y||""}" data-stx-directive-modifiers='${JSON.stringify(G)}'`})}var e,jJ;var hJ=C(()=>{e=new Map,jJ=new Map});function l(J,Z=g,$={},X){return Z.sort((Y,K)=>Y-K).map((Y)=>{return`${v(J,{...$,w:Y,fm:X})} ${Y}w`}).join(", ")}function DZ(J,Z=320,$=2560,X=0.08,Y={},K){let B=mJ(Z,$,X);return l(J,B,Y,K)}function mJ(J,Z,$=0.08){let X=[],Y=J;while(Y<Z)X.push(Math.round(Y)),Y*=1+$*2;if(X[X.length-1]!==Z)X.push(Z);return X}function JJ(J,Z,$=_J,X={},Y){return $.sort((K,B)=>K-B).map((K)=>{let B=Math.round(Z*K);return`${v(J,{...X,w:B,dpr:K,fm:Y})} ${K}x`}).join(", ")}function IZ(J,Z,$=_J,X=80,Y={},K){let B={1:X,1.5:Math.round(X*0.9),2:Math.round(X*0.8),3:Math.round(X*0.7),4:Math.round(X*0.6),5:Math.round(X*0.5)};return $.sort((H,G)=>H-G).map((H)=>{let G=Math.round(Z*H),O=B[H]||Math.round(X*Math.max(0.5,1-H*0.1));return`${v(J,{...Y,w:G,q:O,dpr:H,fm:K})} ${H}x`}).join(", ")}function ZJ(J,Z="100vw"){if(!J||Object.keys(J).length===0)return Z;let X=Object.entries(J).map(([Y,K])=>{let B=/^\d+$/.test(Y)?`${Y}px`:Y;return{bp:B,size:K,numericBp:Number.parseInt(B)||0}}).sort((Y,K)=>Y.numericBp-K.numericBp).map(({bp:Y,size:K})=>`(max-width: ${Y}) ${K}`);return X.push(Z),X.join(", ")}function bZ(J,Z="100vw"){if(!J||J.length===0)return Z;let X=[...J].sort((Y,K)=>(Y.maxWidth||0)-(K.maxWidth||0)).filter((Y)=>Y.maxWidth).map((Y)=>`(max-width: ${Y.maxWidth}px) ${Y.imageWidth}`);return X.push(Z),X.join(", ")}function v(J,Z={}){let $=Object.entries(Z).filter(([,K])=>K!==void 0&&K!==null).map(([K,B])=>{if(Array.isArray(B))return[K,B.join(",")];return[K,String(B)]});if($.length===0)return J;let X=$.map(([K,B])=>`${K}=${encodeURIComponent(B)}`).join("&"),Y=J.includes("?")?"&":"?";return`${J}${Y}${X}`}function yZ(J){let[Z,$]=J.split("?"),X={};if($)new URLSearchParams($).forEach((K,B)=>{if(/^\d+$/.test(K))X[B]=Number.parseInt(K,10);else if(/^\d+\.\d+$/.test(K))X[B]=Number.parseFloat(K);else if(K==="true")X[B]=!0;else if(K==="false")X[B]=!1;else X[B]=K});return{src:Z,params:X}}function fZ(J){let{src:Z,widths:$,dprValues:X,fixedWidth:Y,formats:K=h,baseUrl:B="",params:H={}}=J,G=[];for(let O of K){let q,Q;if(Y!==void 0&&X)q=JJ(Z,Y,X,H,O),Q=X.map((M)=>({path:"",url:v(Z,{...H,w:Math.round(Y*M),fm:O}),width:Math.round(Y*M),height:0,format:O,size:0,dpr:M}));else{let M=$||g;q=l(Z,M,H,O),Q=M.map((L)=>({path:"",url:v(Z,{...H,w:L,fm:O}),width:L,height:0,format:O,size:0}))}G.push({srcset:q,format:O,mimeType:WJ[O],variants:Q})}return G}function gZ(J,Z="100vw"){return J.map(({srcset:$,mimeType:X})=>`<source type="${X}" srcset="${$}" sizes="${Z}" />`).join(`
`)}function hZ(J,Z){if(J.length===0)return;let $=[...J].sort((Y,K)=>Y.width-K.width),X=$.find((Y)=>Y.width>=Z);if(X)return X;return $[$.length-1]}function uZ(J,Z){let $=Z?J.filter((Y)=>Y.format===Z):J;if($.length===0){let Y=J.filter((B)=>B.format==="jpeg"),K=Y.length>0?Y:J;return K[Math.floor(K.length/2)]}let X=$.sort((Y,K)=>Y.width-K.width);return X[Math.floor(X.length/2)]}function mZ(J){let Z=new Map;for(let $ of J){let X=Z.get($.format)||[];X.push($),Z.set($.format,X)}return Z}function $J(J){return WJ[J]||"application/octet-stream"}function dZ(J){return uJ[J]||J}function lZ(J){switch(J.split(".").pop()?.toLowerCase()){case"jpg":case"jpeg":return"jpeg";case"png":return"png";case"webp":return"webp";case"avif":return"avif";case"gif":return"gif";default:return}}var g,_J,h,WJ,uJ,vZ;var XJ=C(()=>{g=[320,480,640,768,1024,1280,1536,1920,2560],_J=[1,1.5,2,3],h=["avif","webp","jpeg"],WJ={avif:"image/avif",webp:"image/webp",jpeg:"image/jpeg",png:"image/png",gif:"image/gif"},uJ={avif:"avif",webp:"webp",jpeg:"jpg",png:"png",gif:"gif"};vZ={fullWidth:"100vw",halfDesktop:"(max-width: 768px) 100vw, 50vw",thirdDesktop:"(max-width: 768px) 100vw, 33.33vw",quarterDesktop:"(max-width: 480px) 100vw, (max-width: 768px) 50vw, 25vw",contentWidth:"(max-width: 768px) 100vw, (max-width: 1200px) 80vw, 960px"}});async function EJ(){try{return await import("ts-images")}catch{return null}}async function LJ(J,Z={}){let $={...dJ,...Z},X=await EJ();if(X)try{return await cZ(J,$,X)}catch(Y){console.warn(`[stx-media] ts-images placeholder generation failed, using fallback: ${Y}`)}return lJ(J,$)}async function cZ(J,Z,$){let{generatePlaceholder:X,generateThumbHash:Y}=$,B={blur:"blur",thumbhash:"thumbhash",blurhash:"thumbhash",pixelate:"pixelate","dominant-color":"dominant-color",none:"blur"}[Z.strategy]||"blur";if(Z.strategy==="thumbhash")return{dataURL:(await Y(J)).dataUrl,width:32,height:32,aspectRatio:1,originalWidth:0,originalHeight:0,strategy:"thumbhash"};let H=await X(J,{width:Z.width,height:Z.height,quality:Z.quality,blurLevel:Z.blurLevel,strategy:B,base64Encode:!0});return{dataURL:H.dataURL,width:H.width,height:H.height,aspectRatio:H.aspectRatio,originalWidth:H.originalWidth,originalHeight:H.originalHeight,strategy:Z.strategy,dominantColor:H.dominantColor,css:H.css}}function lJ(J,Z){let $=Z.width||20,X=Z.height||$,Y="#e5e7eb",K=`<svg xmlns="http://www.w3.org/2000/svg" width="${$}" height="${X}" viewBox="0 0 ${$} ${X}"><rect fill="#e5e7eb" width="${$}" height="${X}"/></svg>`;return{dataURL:`data:image/svg+xml;charset=utf-8,${encodeURIComponent(K)}`,width:$,height:X,aspectRatio:$/X,originalWidth:0,originalHeight:0,strategy:Z.strategy,dominantColor:"#e5e7eb"}}async function nZ(J){let Z=await EJ();if(Z)try{return(await Z.generateThumbHash(J)).dataUrl}catch{}return(await lJ(J,{strategy:"thumbhash",width:32,height:32})).dataURL}function pZ(J){let Z=J[0]|J[1]<<8|J[2]<<16,$=(Z&63)/63,X=(Z>>6&63)/31.5-1,Y=(Z>>12&63)/31.5-1,K=(Z>>18&31)/31,B=Z>>23!==0,H=J[3]|J[4]<<8,G=(H>>3&63)/63,O=(H>>9&63)/63,q=H>>15!==0,Q=Math.max(3,q?B?5:7:B?5:7),M=Math.max(3,q?B?5:7:B?5:7),L=32,N=32,T=Math.max(0,Math.min(255,Math.round(($+X)*255))),V=Math.max(0,Math.min(255,Math.round($*255))),R=Math.max(0,Math.min(255,Math.round(($-X)*255))),j=`<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32">
    <rect fill="rgb(${T},${V},${R})" width="32" height="32"/>
  </svg>`;return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(j)}`}async function iZ(J,Z=20,$=50){return LJ(J,{strategy:"blur",width:Z,quality:$,blurLevel:40})}async function oZ(J){let Z=await EJ();if(Z)try{return(await Z.generatePlaceholder(J,{strategy:"dominant-color"})).dominantColor||"#e5e7eb"}catch{}return"#e5e7eb"}function aZ(J,Z=1,$=1){let X=`<svg xmlns="http://www.w3.org/2000/svg" width="${Z}" height="${$}"><rect fill="${J}" width="${Z}" height="${$}"/></svg>`;return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(X)}`}function RJ(J,Z,$={}){let X=$.transitionDuration||300,Y=$.easing||"ease-out";return`
#${J} {
  --stx-img-transition-duration: ${X}ms;
  --stx-img-transition-easing: ${Y};
  background-image: url('${Z.dataURL}');
  background-size: cover;
  background-position: center;
}

#${J} img {
  opacity: 0;
  transition: opacity var(--stx-img-transition-duration) var(--stx-img-transition-easing);
}

#${J}.stx-img-loaded img {
  opacity: 1;
}
`.trim()}function sZ(J){return`background-image: url('${J.dataURL}'); background-size: cover; background-position: center;`}async function TJ(J,Z={}){let $=`${J}:${JSON.stringify(Z)}`;if(c.has($))return c.get($);let X=await LJ(J,Z);return c.set($,X),X}function rZ(){c.clear()}function tZ(){return{size:c.size,keys:Array.from(c.keys())}}var dJ,YJ,c;var FJ=C(()=>{dJ={strategy:"thumbhash",width:20,quality:50,blurLevel:40,transitionDuration:300,easing:"ease-out"},YJ=`
.stx-img-placeholder {
  position: relative;
  overflow: hidden;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.stx-img-placeholder img {
  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 {
  filter: blur(0);
  transform: scale(1);
}
`.trim();c=new Map});import{createHash as zJ}from"crypto";import{readFile as eZ,stat as nJ}from"fs/promises";async function n(J){try{let Z=await eZ(J);return zJ("sha256").update(Z).digest("hex").slice(0,16)}catch{return""}}function W1(J){return zJ("sha256").update(J).digest("hex").slice(0,16)}function cJ(J){return zJ("sha256").update(J).digest("hex").slice(0,16)}function KJ(J,Z){let $=JSON.stringify(Z,Object.keys(Z).sort());return`${cJ(J)}-${cJ($)}`}async function UJ(J){try{return(await nJ(J)).mtimeMs}catch{return 0}}async function u(J){try{return await nJ(J),!0}catch{return!1}}var BJ=()=>{};import{mkdir as J0,readFile as iJ,writeFile as Z0,readdir as oJ,rm as wJ,stat as $0}from"fs/promises";import{join as p,dirname as X0}from"path";async function Y0(J){try{await J0(J,{recursive:!0})}catch{}}function aJ(J,Z,$){return p(J,$,`${Z}.json`)}async function pJ(J,Z,$){if((Date.now()-J.createdAt)/86400000>$)return!1;if(await UJ(Z)!==J.srcMtime)return!1;return!0}async function sJ(J,Z,$,X=i){if(!X.enabled)return null;let Y=KJ(J,Z),K=I.get(Y);if(K){if(await pJ(K,J,X.maxAge))return K.lastAccessedAt=Date.now(),K.data;I.delete(Y)}let B=aJ(X.directory,Y,$);if(await u(B))try{let H=await iJ(B,"utf-8"),G=JSON.parse(H);if(await pJ(G,J,X.maxAge))return G.lastAccessedAt=Date.now(),I.set(Y,G),G.data}catch{}return null}async function rJ(J,Z,$,X,Y=i){if(!Y.enabled)return;let K=KJ(J,Z),B=await n(J),H=await UJ(J),G={key:K,src:J,srcHash:B,srcMtime:H,optionsHash:KJ("",Z),data:$,createdAt:Date.now(),lastAccessedAt:Date.now()};I.set(K,G);let O=aJ(Y.directory,K,X);try{await Y0(X0(O)),await Z0(O,JSON.stringify(G,null,2))}catch(q){console.warn(`[stx-media] Failed to write cache: ${q}`)}}async function F1(J,Z,$=i){for(let[X,Y]of I.entries())if(Y.src===J)I.delete(X)}async function tJ(J,Z=i){if(J==="all")I.clear();else I.clear();let $=J==="all"?["image","video"]:[J];for(let X of $){let Y=p(Z.directory,X);try{await wJ(Y,{recursive:!0,force:!0})}catch{}}}async function z1(J=i){let Z={memoryEntries:I.size,diskEntries:{image:0,video:0},totalSizeMB:0};for(let $ of["image","video"]){let X=p(J.directory,$);try{let Y=await oJ(X);Z.diskEntries[$]=Y.length;for(let K of Y){let B=p(X,K),H=await $0(B);Z.totalSizeMB+=H.size/1048576}}catch{}}return Z}async function U1(J=i){let Z=0,$=J.maxAge*24*60*60*1000;for(let X of["image","video"]){let Y=p(J.directory,X);try{let K=await oJ(Y);for(let B of K){let H=p(Y,B);try{let G=await iJ(H,"utf-8"),O=JSON.parse(G);if(Date.now()-O.createdAt>$)await wJ(H),I.delete(O.key),Z++}catch{await wJ(H).catch(()=>{}),Z++}}}catch{}}return Z}var I,i;var eJ=C(()=>{BJ();I=new Map,i={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}});class HJ{config;constructor(J={}){this.config={...K0,...J}}async get(J,Z){return sJ(J,Z,"image",this.config)}async set(J,Z,$){return rJ(J,Z,$,"image",this.config)}async clear(){return tJ("image",this.config)}updateConfig(J){this.config={...this.config,...J}}}function kJ(J){if(!GJ)GJ=new HJ(J);else if(J)GJ.updateConfig(J);return GJ}async function MJ(J,Z,$){let X=$?{directory:`${$.outputDir}/../.cache`}:{};return kJ(X).get(J,Z)}async function OJ(J,Z,$,X){let Y=X?{directory:`${X.outputDir}/../.cache`}:{};return kJ(Y).set(J,Z,$)}async function JZ(){return kJ().clear()}var K0,GJ=null;var CJ=C(()=>{eJ();K0={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500,cacheVariants:!0,cachePlaceholders:!0}});import{resolve as B0,basename as G0,extname as H0,join as M0}from"path";import{mkdir as O0}from"fs/promises";async function SJ(){try{return await import("ts-images")}catch{return null}}function ZZ(J){switch(J){case"quality":return{jpeg:{quality:90,mozjpeg:!0,progressive:!0},png:{compressionLevel:6,palette:!1},webp:{quality:90,effort:6,smartSubsample:!0},avif:{quality:85,effort:6}};case"performance":return{jpeg:{quality:70,mozjpeg:!0,progressive:!0},png:{compressionLevel:9,palette:!0},webp:{quality:70,effort:4,smartSubsample:!0},avif:{quality:60,effort:2}};case"web":default:return{jpeg:{quality:82,mozjpeg:!0,progressive:!0},png:{compressionLevel:8,palette:!1},webp:{quality:82,effort:5,smartSubsample:!0},avif:{quality:75,effort:4}}}}function N0(J,Z){let $=Z?ZZ(Z):ZZ("web"),X=J.formatQuality||{};return{jpeg:{...$.jpeg,...X.jpeg},png:{...$.png,...X.png},webp:{...$.webp,...X.webp},avif:{...$.avif,...X.avif}}}async function $Z(J,Z,$){let X=await SJ();if(!X)return console.warn("[stx-media] ts-images not installed, skipping optimization"),{src:J,processed:!1};let Y=await MJ(J,Z,$);if(Y)return Y;try{let K=B0(J);if(!await u(K))return{src:J,processed:!1,errors:[`Source file not found: ${J}`]};let B=N0($,Z.preset),H=$.outputDir||"dist/images",G=$.baseUrl||"/images";await O0(H,{recursive:!0});let O=await n(K),q=G0(J,H0(J)),Q=Z.outputFormat?[Z.outputFormat]:$.defaultFormats||["avif","webp","jpeg"],M={src:J,processed:!0,variants:[],hash:O},L=null;if(Z.transformations&&Z.transformations.length>0)L=await AJ(K,Z.transformations,X);for(let N of Q){let T=B[N]||{},V=`${q}-${O}.${N}`,R=M0(H,V);try{let j=await X.optimizeImage({input:L||K,output:R,format:N,quality:T.quality,progressive:T.progressive});if(j){if(M.variants.push({path:R,url:`${G}/${V}`,width:j.width||0,height:j.height||0,format:N,size:j.outputSize||0}),!M.originalWidth&&j.width)M.originalWidth=j.width,M.originalHeight=j.height}}catch(j){M.errors=M.errors||[],M.errors.push(`Failed to optimize ${N}: ${j}`)}}if(Z.embedThumbhash||Z.placeholder==="thumbhash")try{let N=await X.generateThumbHash(K);M.placeholder=N.dataUrl}catch(N){M.errors=M.errors||[],M.errors.push(`Failed to generate thumbhash: ${N}`)}if(Z.useDominantColor)try{let N=await X.generatePlaceholder(K,{strategy:"dominant-color"});M.dominantColor=N.dominantColor}catch(N){M.errors=M.errors||[],M.errors.push(`Failed to extract dominant color: ${N}`)}return await OJ(J,Z,M,$),M}catch(K){return{src:J,processed:!1,errors:[`Processing failed: ${K}`]}}}async function XZ(J,Z,$,X){let Y=await SJ();if(!Y)return{success:!1,error:"ts-images not installed"};try{return{success:!0,size:(await Y.optimizeImage({input:J,output:X,format:Z,quality:$}))?.outputSize}}catch(K){return{success:!1,error:String(K)}}}async function AJ(J,Z,$){let X=$||await SJ();if(!X)return console.warn("[stx-media] ts-images not installed, skipping transformations"),null;try{let Y=await X.decode(J);for(let K of Z){let B=K.options||{};switch(K.type){case"resize":if(B.width||B.height)Y=await X.resize(Y,{width:B.width,height:B.height,fit:B.fit});break;case"blur":if(B.sigma!==void 0)Y=await X.blur(Y,B.sigma);break;case"sharpen":if(B.amount!==void 0)Y=await X.sharpen(Y,B.amount);break;case"grayscale":Y=await X.grayscale(Y);break;case"rotate":if(B.angle!==void 0)Y=await X.rotate(Y,B.angle);break;case"flip":Y=await X.flip(Y);break;case"flop":Y=await X.flop(Y);break;case"brightness":if(B.value!==void 0)Y=await X.brightness(Y,B.value);break;case"contrast":if(B.value!==void 0)Y=await X.contrast(Y,B.value);break;case"saturation":if(B.value!==void 0)Y=await X.saturation(Y,B.value);break}}return await X.encode(Y,"png")}catch(Y){return console.error(`[stx-media] Transformation failed: ${Y}`),null}}var YZ=C(()=>{BJ();CJ()});import{resolve as Q0,basename as q0,extname as V0,join as j0}from"path";import{mkdir as _0}from"fs/promises";async function W0(){try{return await import("ts-images")}catch{return null}}async function PJ(J,Z,$){let X=await W0();if(!X)return console.warn("[stx-media] ts-images not installed, skipping responsive generation"),null;let Y=Q0(J);if(!await u(Y))return console.warn(`[stx-media] Source file not found: ${J}`),null;try{let K=Z.responsiveWidths||$.breakpoints||E0,B=Z.formats||$.defaultFormats||["avif","webp","jpeg"],H=$.outputDir||"dist/images",G=$.baseUrl||"/images";await _0(H,{recursive:!0});let O=await n(Y),q=q0(J,V0(J)),Q=$.formatQuality||{jpeg:{quality:82},png:{quality:80},webp:{quality:82},avif:{quality:75}},M={src:J,byFormat:{},srcsets:{}};for(let N of B){M.byFormat[N]=[];let T=[];for(let V of K){let R=`${q}-${V}w-${O}.${N}`,j=j0(H,R),F=`${G}/${R}`;try{let k=Q[N]?.quality||80;if(await u(j)){M.byFormat[N].push({path:j,url:F,width:V,height:0,format:N,size:0}),T.push(`${F} ${V}w`);continue}let U=await X.processImage({input:Y,output:j,format:N,quality:k,resize:{width:V}});if(U)M.byFormat[N].push({path:j,url:F,width:V,height:U.height||Math.round(V*(U.height||1)/(U.width||1)),format:N,size:U.outputSize||0}),T.push(`${F} ${V}w`)}catch(k){console.warn(`[stx-media] Failed to generate ${N} at ${V}w: ${k}`)}}M.srcsets[N]=T.join(", ")}let L=Z.placeholder||$.placeholderStrategy||"thumbhash";if(L!=="none")try{if(L==="thumbhash"){let N=await X.generateThumbHash(Y);M.placeholder={dataURL:N.dataUrl,width:N.width||32,height:N.height||32,strategy:"thumbhash"}}else{let N=await X.generatePlaceholder(Y,{strategy:L,width:20});M.placeholder={dataURL:N.dataURL,width:N.width,height:N.height,strategy:L}}}catch(N){console.warn(`[stx-media] Failed to generate placeholder: ${N}`)}return M.sizes=Z.sizes||L0(K),M}catch(K){return console.error(`[stx-media] Responsive generation failed: ${K}`),null}}function L0(J){let Z=[...J].sort((X,Y)=>X-Y),$=[];for(let X=0;X<Z.length-1;X++){let Y=Z[X];$.push(`(max-width: ${Y}px) ${Y}px`)}return $.push(`${Z[Z.length-1]}px`),$.join(", ")}function KZ(J,Z="width"){if(!J||J.length===0)return"";if(Z==="dpr")return J.filter(($)=>$.dpr).map(($)=>`${$.url} ${$.dpr}x`).join(", ");return J.map(($)=>`${$.url} ${$.width}w`).join(", ")}async function g1(J,Z,$){let X=[];for(let Y of Z){let K=await PJ(Y.src,{responsiveWidths:Y.widths},$);if(K){for(let[B,H]of Object.entries(K.srcsets))if(H)X.push({media:Y.media,srcset:H,type:R0(B)})}}return X}function R0(J){switch(J){case"avif":return"image/avif";case"webp":return"image/webp";case"jpeg":return"image/jpeg";case"png":return"image/png";case"gif":return"image/gif";default:return"image/jpeg"}}var E0;var BZ=C(()=>{BJ();E0=[320,480,640,768,1024,1280,1536,1920]});var GZ={};AZ(GZ,{setCachedImageResult:()=>OJ,processImage:()=>$Z,optimizeImage:()=>XZ,getCachedImageResult:()=>MJ,generateSrcset:()=>KZ,generateResponsiveVariants:()=>PJ,clearImageCache:()=>JZ,applyTransformations:()=>AJ,ImageProcessorCache:()=>HJ});var HZ=C(()=>{YZ();BZ();CJ()});async function T0(){try{return await Promise.resolve().then(() => (HZ(),GZ))}catch(J){if(!MZ)console.warn("[stx-media] Image processor not available, some features disabled:",J),MZ=!0;return null}}async function o(J,Z={}){let $=Z,X=J;if(X.process&&!X.skipOptimization){if($.tsImagesConfig?.enabled&&!$.isDev)return k0(X,$)}if($.processedResult?.processed)return bJ(J,$.processedResult,Z);if($.responsiveVariants)return VZ(J,$.responsiveVariants,Z);let{src:Y,alt:K,width:B,height:H,sizes:G,widths:O=g,dpr:q,formats:Q=h,quality:M=xJ,params:L={},placeholder:N="none",placeholderOptions:T={},lazy:V=!0,priority:R=!1,loading:j=R?"eager":QJ,decoding:F=NJ,fetchpriority:k,objectFit:U,objectPosition:m,crossorigin:_,referrerpolicy:y}=J,b=J.class,w=J.style,S=J.id,f=J.data||{},{isDev:P=!1,baseUrl:a=""}=Z;if(P&&!Z.optimize)return U0(J);let x,W,D=S||`stx-img-${Math.random().toString(36).slice(2,8)}`;if(N!=="none"&&!R)try{x=await TJ(Y,{strategy:N,...T}),W=RJ(D,x,T)}catch{}let r=q!==void 0&&B!==void 0,d;if(r)d=z0(J,D,x,Z);else d=await F0(J,D,x,Z);let s;if(R){let fJ=Q.includes("webp")?"webp":Q[0],TZ=l(Y,O,{...L,q:M},fJ),FZ=typeof G==="object"?ZJ(G):G||"100vw";s=`<link rel="preload" as="image" imagesrcset="${TZ}" imagesizes="${FZ}" />`}let t=[];if(!OZ&&N!=="none")t.push(YJ),OZ=!0;if(W)t.push(W);let RZ=V?QZ(D):void 0;return{html:d,preloadLink:s,css:t.length>0?t.join(`
`):void 0,script:RZ}}async function F0(J,Z,$,X){let{src:Y,alt:K,width:B,height:H,sizes:G,widths:O=g,formats:q=h,quality:Q=xJ,params:M={},lazy:L=!0,priority:N=!1,loading:T=N?"eager":QJ,decoding:V=NJ,fetchpriority:R,objectFit:j,objectPosition:F,crossorigin:k,referrerpolicy:U}=J,m=J.class,_=J.style,y=J.data||{},b=typeof G==="object"?ZJ(G):G||"100vw",w=[];for(let P of q){let a=l(Y,O,{...M,q:Q},P),x=$J(P);if(L&&!N)w.push(`  <source type="${x}" data-srcset="${a}" data-sizes="${b}" />`);else w.push(`  <source type="${x}" srcset="${a}" sizes="${b}" />`)}let S=DJ({src:v(Y,{...M,q:Q}),alt:K,width:B,height:H,loading:N?void 0:T,decoding:V,fetchpriority:N?"high":R,objectFit:j,objectPosition:F,crossorigin:k,referrerpolicy:U,className:NZ(m,$),style:IJ(_,j,F,$),lazy:L&&!N,data:y}),f;if($){let P=`background-image: url('${$.dataURL}'); background-size: cover; background-position: center;`;f=`<div id="${Z}" class="stx-img-placeholder" style="${P}">
  <picture>
${w.join(`
`)}
    <img ${S} />
  </picture>
</div>`}else f=`<picture${Z?` id="${Z}"`:""}>
${w.join(`
`)}
  <img ${S} />
</picture>`;return f}function z0(J,Z,$,X){let{src:Y,alt:K,width:B,height:H,dpr:G=[1,2,3],quality:O=xJ,params:q={},lazy:Q=!0,priority:M=!1,loading:L=M?"eager":QJ,decoding:N=NJ,fetchpriority:T,objectFit:V,objectPosition:R,crossorigin:j,referrerpolicy:F}=J,k=J.class,U=J.style,m=J.data||{},_=typeof B==="number"?B:Number.parseInt(String(B),10),y=JJ(Y,_,G,{...q,q:O}),b=DJ({src:v(Y,{...q,w:_,q:O}),alt:K,width:B,height:H,loading:M?void 0:L,decoding:N,fetchpriority:M?"high":T,objectFit:V,objectPosition:R,crossorigin:j,referrerpolicy:F,className:NZ(k,$),style:IJ(U,V,R,$),lazy:Q&&!M,data:m}),w=Q&&!M?`data-srcset="${y}"`:`srcset="${y}"`;if($){let S=`background-image: url('${$.dataURL}'); background-size: cover; background-position: center;`;return`<div id="${Z}" class="stx-img-placeholder" style="${S}">
  <img ${b} ${w} />
</div>`}return`<img ${Z?`id="${Z}" `:""}${b} ${w} />`}function U0(J){let{src:Z,alt:$,width:X,height:Y,loading:K=QJ,decoding:B=NJ,fetchpriority:H,objectFit:G,objectPosition:O,crossorigin:q,referrerpolicy:Q,priority:M=!1}=J,L=J.class,N=J.style,T=J.id,V=J.data||{};return{html:`<img ${DJ({src:Z,alt:$,width:X,height:Y,loading:M?"eager":K,decoding:B,fetchpriority:M?"high":H,objectFit:G,objectPosition:O,crossorigin:q,referrerpolicy:Q,className:L,style:IJ(N,G,O),id:T,data:V})} />`}}function DJ(J){let Z=[];if(J.lazy)Z.push(`data-src="${A(J.src)}"`),Z.push('src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"');else Z.push(`src="${A(J.src)}"`);if(Z.push(`alt="${A(J.alt)}"`),J.width)Z.push(`width="${J.width}"`);if(J.height)Z.push(`height="${J.height}"`);if(J.loading)Z.push(`loading="${J.loading}"`);if(J.decoding)Z.push(`decoding="${J.decoding}"`);if(J.fetchpriority)Z.push(`fetchpriority="${J.fetchpriority}"`);if(J.crossorigin)Z.push(`crossorigin="${J.crossorigin}"`);if(J.referrerpolicy)Z.push(`referrerpolicy="${J.referrerpolicy}"`);if(J.className)Z.push(`class="${A(J.className)}"`);if(J.style)Z.push(`style="${A(J.style)}"`);if(J.id)Z.push(`id="${A(J.id)}"`);if(J.data)for(let[$,X]of Object.entries(J.data))Z.push(`data-${$}="${A(X)}"`);if(J.lazy)Z.push("data-stx-lazy");return Z.join(" ")}function NZ(J,Z){let $=[];if(J)$.push(J);if(Z)$.push("stx-img-blur");return $.join(" ")||""}function IJ(J,Z,$,X){let Y=[];if(Z)Y.push(`object-fit: ${Z}`);if($)Y.push(`object-position: ${$}`);if(X)Y.push("opacity: 0; transition: opacity 300ms ease-out");if(J)Y.push(J);return Y.join("; ")}function A(J){return J.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#039;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function QZ(J){return`
(function() {
  const container = document.getElementById('${J}');
  if (!container) return;

  const img = container.querySelector('img[data-stx-lazy]') || container;
  if (!img.dataset.src && !img.dataset.srcset) return;

  const observer = new IntersectionObserver((entries) => {
    entries.forEach(entry => {
      if (entry.isIntersecting) {
        // Load image
        if (img.dataset.src) img.src = img.dataset.src;
        if (img.dataset.srcset) img.srcset = img.dataset.srcset;

        // Load sources
        const sources = container.querySelectorAll('source[data-srcset]');
        sources.forEach(source => {
          if (source.dataset.srcset) source.srcset = source.dataset.srcset;
          if (source.dataset.sizes) source.sizes = source.dataset.sizes;
        });

        // Handle load completion
        img.onload = () => {
          img.style.opacity = '1';
          if (container.classList.contains('stx-img-placeholder')) {
            container.classList.add('stx-img-loaded');
          }
        };

        observer.disconnect();
      }
    });
  }, { rootMargin: '50px' });

  observer.observe(container);
})();
`.trim()}function qZ(J){let Z=J.match(/<Img\s+([^>]*?)\/?>/);if(!Z)return null;let $=Z[1],X={},Y=/(:?)(\w+)(?:=(?:"([^"]*)"|'([^']*)'|\{([^}]+)\}))?/g,K;while((K=Y.exec($))!==null){let[,B,H,G,O,q]=K,Q=G??O??q??!0;if(B===":"&&typeof Q==="string")try{X[H]=JSON.parse(Q)}catch{X[H]=Q}else switch(H){case"src":X.src=String(Q);break;case"alt":X.alt=String(Q);break;case"width":X.width=Number(Q)||Q;break;case"height":X.height=Number(Q)||Q;break;case"sizes":X.sizes=String(Q);break;case"quality":X.quality=Number(Q);break;case"placeholder":X.placeholder=Q;break;case"lazy":X.lazy=Q===!0||Q==="true";break;case"priority":X.priority=Q===!0||Q==="true";break;case"class":X.class=String(Q);break;case"style":X.style=String(Q);break;case"id":X.id=String(Q);break;case"loading":X.loading=Q;break;case"decoding":X.decoding=Q;break;case"fetchpriority":X.fetchpriority=Q;break;case"objectFit":X.objectFit=Q;break;case"objectPosition":X.objectPosition=String(Q);break;case"crossorigin":X.crossorigin=Q;break}}if(!X.src||!X.alt)return null;return X}async function w0(J,Z={}){let $=/<Img\s+[^>]*?\/?>/g,X=[],Y=[],K=[],B=J,H=[],G;while((G=$.exec(J))!==null)H.push({match:G[0],index:G.index});for(let O=H.length-1;O>=0;O--){let{match:q}=H[O],Q=qZ(q);if(Q){let M=await o(Q,Z);if(B=B.replace(q,M.html),M.preloadLink)X.push(M.preloadLink);if(M.css)Y.push(M.css);if(M.script)K.push(M.script)}}return{html:B,preloadLinks:X,styles:Y,scripts:K}}async function k0(J,Z){let $=await T0();if(!$)return o({...J,process:!1},Z);let X=Z.tsImagesConfig;if(J.responsiveWidths&&J.responsiveWidths.length>0||J.widths&&J.widths.length>0||!J.width&&!J.dpr){let K=await $.generateResponsiveVariants(J.src,J,X);if(K)return VZ(J,K,Z)}else{let K=await $.processImage(J.src,J,X);if(K.processed)return bJ(J,K,Z)}return o({...J,process:!1},Z)}async function bJ(J,Z,$){let{alt:X,width:Y,height:K,lazy:B=!0,priority:H=!1,objectFit:G,objectPosition:O,crossorigin:q,referrerpolicy:Q}=J,M=J.class,L=J.style,N=J.id||`stx-img-${Math.random().toString(36).slice(2,8)}`,T=J.data||{},V=Z.variants||[],R=V.find((W)=>W.format==="jpeg")||V.find((W)=>W.format==="webp")||V[0],j=R?.url||J.src,F=V.filter((W)=>W.format===(R?.format||"jpeg")).map((W)=>`${W.url} ${W.width}w`).join(", "),k=new Map;for(let W of V){if(!k.has(W.format))k.set(W.format,[]);k.get(W.format).push(W)}let U=[],m=["avif","webp","jpeg","png"];for(let W of m){let D=k.get(W);if(D&&D.length>0){let r=D.map((s)=>`${s.url} ${s.width}w`).join(", "),d=$J(W);if(B&&!H)U.push(`  <source type="${d}" data-srcset="${r}" />`);else U.push(`  <source type="${d}" srcset="${r}" />`)}}let _=[];if(B&&!H){if(_.push(`data-src="${A(j)}"`),_.push('src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"'),F)_.push(`data-srcset="${F}"`)}else if(_.push(`src="${A(j)}"`),F)_.push(`srcset="${F}"`);_.push(`alt="${A(X)}"`);let y=Y||Z.originalWidth,b=K||Z.originalHeight;if(y)_.push(`width="${y}"`);if(b)_.push(`height="${b}"`);if(!H)_.push(`loading="${B?"lazy":"eager"}"`);if(_.push('decoding="async"'),H)_.push('fetchpriority="high"');if(q)_.push(`crossorigin="${q}"`);if(Q)_.push(`referrerpolicy="${Q}"`);let w=[];if(G)w.push(`object-fit: ${G}`);if(O)w.push(`object-position: ${O}`);if(Z.placeholder&&B)w.push("opacity: 0; transition: opacity 300ms ease-out");if(L)w.push(L);if(w.length>0)_.push(`style="${w.join("; ")}"`);let S=[];if(M)S.push(M);if(Z.placeholder)S.push("stx-img-blur");if(S.length>0)_.push(`class="${S.join(" ")}"`);if(B&&!H)_.push("data-stx-lazy");for(let[W,D]of Object.entries(T))_.push(`data-${W}="${A(D)}"`);let f;if(Z.placeholder||Z.dominantColor&&J.useDominantColor){let W=Z.placeholder?`background-image: url('${Z.placeholder}'); background-size: cover; background-position: center;`:`background-color: ${Z.dominantColor};`;f=`<div id="${N}" class="stx-img-placeholder" style="${W}">
  <picture>
${U.join(`
`)}
    <img ${_.join(" ")} />
  </picture>
</div>`}else f=`<picture${N?` id="${N}"`:""}>
${U.join(`
`)}
  <img ${_.join(" ")} />
</picture>`;let P=[];if(Z.placeholder)P.push(YJ);let a=B?QZ(N):void 0,x;if(H&&F)x=`<link rel="preload" as="image" imagesrcset="${F}" />`;return{html:f,preloadLink:x,css:P.length>0?P.join(`
`):void 0,script:a}}async function VZ(J,Z,$){let X={src:Z.src,processed:!0,variants:[],placeholder:Z.placeholder?.dataURL,originalWidth:Z.placeholder?.width,originalHeight:Z.placeholder?.height};for(let[Y,K]of Object.entries(Z.byFormat))if(K)X.variants.push(...K);return bJ(J,X,$)}var MZ=!1,xJ=80,NJ="async",QJ="lazy",OZ=!1;var vJ=C(()=>{XJ();FJ()});function jZ(){return z({name:"img",hasEndTag:!1,description:"Render an optimized responsive image with srcset and lazy loading",transform:async(J,Z,$,X)=>{let{src:Y,alt:K,options:B}=C0(J,Z,$);if(!Y)return console.warn("@img directive: missing src argument"),"<!-- @img: missing src -->";let H={src:Y,alt:K||"",widths:B.widths||g,formats:B.formats||h,quality:B.quality,sizes:B.sizes,dpr:B.dpr,params:B.params,placeholder:B.placeholder,placeholderOptions:B.placeholderOptions,lazy:B.lazy!==!1,priority:B.priority||!1,loading:B.loading,decoding:B.decoding,fetchpriority:B.fetchpriority,objectFit:B.objectFit,objectPosition:B.objectPosition,class:B.class,style:B.style,id:B.id,width:B.width,height:B.height},G=$.__isDev||!1,O=await o(H,{isDev:G}),q=O.html;if(O.preloadLink)q=O.preloadLink+`
`+q;if(O.css)q+=`
<style>${O.css}</style>`;if(O.script)q+=`
<script>${O.script}</script>`;return q},defaults:{src:"",alt:"",options:{lazy:!0,placeholder:"none"}}})}function C0(J,Z,$){if(Z.src)return{src:String(Z.src),alt:String(Z.alt||""),options:Z.options||{}};let X=J.trim();if(X.startsWith("@img(")||X.startsWith("("))X=X.replace(/^@img\(/,"").replace(/^\(/,"").replace(/\)$/,"");let Y=S0(X),K=yJ(Y[0],$)||"",B=yJ(Y[1],$)||"",H={};if(Y[2]){let G=yJ(Y[2],$);if(typeof G==="object"&&G!==null)H=G;else if(typeof Y[2]==="string")try{H=JSON.parse(Y[2])}catch{}}return{src:K,alt:B,options:H}}function S0(J){let Z=[],$="",X=!1,Y="",K=0,B=0;for(let H=0;H<J.length;H++){let G=J[H],O=H>0?J[H-1]:"";if((G==='"'||G==="'"||G==="`")&&O!=="\\"){if(!X)X=!0,Y=G;else if(G===Y)X=!1,Y="";else $+=G;continue}if(!X){if(G==="{")K++;if(G==="}")K--;if(G==="[")B++;if(G==="]")B--;if(G===","&&K===0&&B===0){Z.push($.trim()),$="";continue}}$+=G}if($.trim())Z.push($.trim());return Z}function yJ(J,Z){if(typeof J!=="string")return J;let $=J.trim();if($.startsWith('"')&&$.endsWith('"')||$.startsWith("'")&&$.endsWith("'"))return $.slice(1,-1);if(!$.startsWith("/")&&!$.startsWith(".")&&!$.startsWith("http")&&!$.startsWith("{")){let X=Z[$];if(X!==void 0)return X}if($.startsWith("{")||$.startsWith("["))try{return JSON.parse($)}catch{}return $}var A0;var _Z=C(()=>{hJ();vJ();XJ();A0=jZ()});function E(J,Z={}){let $=[];for(let[Y,K]of Object.entries(Z)){if(K===void 0||K===null)continue;if(Array.isArray(K))$.push(`${Y}=${encodeURIComponent(K.join(","))}`);else if(typeof K==="boolean"){if(K)$.push(`${Y}=true`)}else $.push(`${Y}=${encodeURIComponent(String(K))}`)}if($.length===0)return J;let X=J.includes("?")?"&":"?";return`${J}${X}${$.join("&")}`}function P0(J){let Z=J.indexOf("?");if(Z===-1)return{src:J,params:{}};let $=J.slice(0,Z),X=J.slice(Z+1),Y={};for(let K of X.split("&")){let[B,H]=K.split("="),G=H?decodeURIComponent(H):"";if(G==="true")Y[B]=!0;else if(G==="false")Y[B]=!1;else if(/^-?\d+$/.test(G))Y[B]=Number.parseInt(G,10);else if(/^-?\d+\.\d+$/.test(G))Y[B]=Number.parseFloat(G);else if(G.includes(","))Y[B]=G.split(",");else Y[B]=G}return{src:$,params:Y}}function WZ(...J){let Z={};for(let $ of J)if($)Object.assign(Z,$);return Z}function x0(J,Z,$,X){let Y={w:Z};if($)Y.h=$;if(X)Y.fit=X;return E(J,Y)}function D0(J,Z,$,X="center"){return E(J,{w:Z,h:$,fit:"crop",crop:X})}function I0(J,Z,$="center"){return E(J,{w:Z,h:Z,fit:"crop",crop:$})}function b0(J,Z,$){return E(J,{w:Z,h:$,fit:"max"})}function v0(J,Z,$){return E(J,{w:Z,h:$,fit:"crop"})}function y0(J,Z){return E(J,{blur:Math.min(2000,Math.max(0,Z))})}function f0(J,Z){return E(J,{sharp:Math.min(100,Math.max(0,Z))})}function g0(J){return E(J,{sat:-100})}function h0(J,Z=100){return E(J,{sepia:Math.min(100,Math.max(0,Z))})}function u0(J){return E(J,{invert:!0})}function m0(J,Z){return E(J,{bri:Math.min(100,Math.max(-100,Z))})}function d0(J,Z){return E(J,{con:Math.min(100,Math.max(-100,Z))})}function l0(J,Z){return E(J,{sat:Math.min(100,Math.max(-100,Z))})}function c0(J,Z){return E(J,{rot:(Z%360+360)%360})}function n0(J){return E(J,{flip:"h"})}function p0(J){return E(J,{flip:"v"})}function i0(J,Z,$){let X={fm:Z};if($!==void 0)X.q=$;return E(J,X)}function o0(J,Z){return E(J,{q:Math.min(100,Math.max(1,Z))})}function a0(J,Z=["format","compress"]){return E(J,{auto:Z})}function s0(J,Z,$={}){return E(J,{mark:Z,markx:$.x,marky:$.y,markalpha:$.alpha,markscale:$.scale,markalign:$.align})}function r0(J,Z,$){return E(J,WZ(EZ[Z],$))}function t0(J,Z,$){return Z.map((X)=>E(J,{...$,w:X}))}function e0(J,Z,$=[1,2,3],X){return $.map((Y)=>E(J,{...X,w:Math.round(Z*Y),dpr:Y}))}function J1(J){let Z=[];if(J.w!==void 0&&(J.w<1||J.w>16383))Z.push("Width must be between 1 and 16383");if(J.h!==void 0&&(J.h<1||J.h>16383))Z.push("Height must be between 1 and 16383");if(J.q!==void 0&&(J.q<1||J.q>100))Z.push("Quality must be between 1 and 100");if(J.blur!==void 0&&(J.blur<0||J.blur>2000))Z.push("Blur must be between 0 and 2000");if(J.rot!==void 0&&(J.rot<0||J.rot>359))Z.push("Rotation must be between 0 and 359");if(J.dpr!==void 0&&(J.dpr<1||J.dpr>5))Z.push("DPR must be between 1 and 5");return{valid:Z.length===0,errors:Z}}function Z1(J){let Z={...J};if(Z.w!==void 0)Z.w=Math.min(16383,Math.max(1,Z.w));if(Z.h!==void 0)Z.h=Math.min(16383,Math.max(1,Z.h));if(Z.q!==void 0)Z.q=Math.min(100,Math.max(1,Z.q));if(Z.blur!==void 0)Z.blur=Math.min(2000,Math.max(0,Z.blur));if(Z.rot!==void 0)Z.rot=(Z.rot%360+360)%360;if(Z.dpr!==void 0)Z.dpr=Math.min(5,Math.max(1,Z.dpr));return Z}var EZ;var LZ=C(()=>{EZ={web:{fm:"webp",q:80,auto:["format","compress"]},highQuality:{q:95},thumb:{w:150,h:150,fit:"crop",crop:"center"},avatar:{w:200,h:200,fit:"crop",crop:"faces"},social:{w:1200,h:630,fit:"crop"},preview:{w:400,q:70},placeholder:{w:20,blur:200,q:20}}});var $1=C(()=>{vJ();_Z();XJ();FJ();LZ()});$1();export{s0 as watermark,J1 as validateParams,I0 as thumbnail,t0 as srcsetUrls,f0 as sharpen,h0 as sepia,l0 as saturation,Z1 as sanitizeParams,c0 as rotate,x0 as resize,o as renderImgComponent,o0 as quality,w0 as processImgComponents,P0 as parseUrl,qZ as parseImgComponent,yZ as parseImageUrl,WZ as mergeParams,u0 as invert,A0 as imgDirective,mZ as groupVariantsByFormat,g0 as grayscale,tZ as getPlaceholderCacheStats,$J as getMimeType,dZ as getFormatExtension,uZ as getFallbackVariant,TJ as getCachedPlaceholder,hZ as getBestVariant,l as generateWidthSrcset,nZ as generateThumbhashPlaceholder,fZ as generateSrcsetData,gZ as generateSourceTags,bZ as generateSizesFromBreakpoints,ZJ as generateSizesAttribute,sZ as generatePlaceholderStyle,RJ as generatePlaceholderCSS,LJ as generatePlaceholder,iZ as generateLQIP,IZ as generateDprSrcsetWithVariableQuality,JJ as generateDprSrcset,aZ as generateColorPlaceholder,DZ as generateAutoWidthSrcset,i0 as format,p0 as flipVertical,n0 as flipHorizontal,oZ as extractDominantColor,e0 as dprUrls,lZ as detectFormat,pZ as decodeThumbhash,D0 as crop,jZ as createImgDirective,v0 as cover,d0 as contrast,b0 as contain,rZ as clearPlaceholderCache,mJ as calculateOptimalWidths,E as buildUrl,v as buildImageUrl,m0 as brightness,y0 as blur,a0 as auto,r0 as applyPreset,EZ as PRESETS,WJ as MIME_TYPES,uJ as FORMAT_EXTENSIONS,g as DEFAULT_WIDTHS,dJ as DEFAULT_PLACEHOLDER_OPTIONS,h as DEFAULT_FORMATS,_J as DEFAULT_DPR_VALUES,vZ as COMMON_SIZES,YJ as BLUR_UP_CSS};
