// @bun
var{defineProperty:GJ,getOwnPropertyNames:VZ,getOwnPropertyDescriptor:QZ}=Object,jZ=Object.prototype.hasOwnProperty;function _Z(J){return this[J]}var Y0=(J)=>{var Z=(AJ??=new WeakMap).get(J),$;if(Z)return Z;if(Z=GJ({},"__esModule",{value:!0}),J&&typeof J==="object"||typeof J==="function"){for(var X of VZ(J))if(!jZ.call(Z,X))GJ(Z,X,{get:_Z.bind(J,X),enumerable:!($=QZ(J,X))||$.enumerable})}return AJ.set(J,Z),Z},AJ;var WZ=(J)=>J;function UZ(J,Z){this[J]=WZ.bind(null,Z)}var zZ=(J,Z)=>{for(var $ in Z)GJ(J,$,{get:Z[$],enumerable:!0,configurable:!0,set:UZ.bind(Z,$)})};var S=(J,Z)=>()=>(J&&(Z=J(J=0)),Z);var HJ=import.meta.require;function EZ(J){if(t.set(J.name,J),J.client)qJ.set(J.name,J.client)}function B0(J){return t.get(J)}function G0(){return Array.from(t.values())}function H0(J){return qJ.delete(J),t.delete(J)}function R(J){return EZ(J),{name:J.name,hasEndTag:J.hasEndTag??!0,description:J.description,handler:async($,X,Y,B)=>{let K=LZ(X,J.defaults);if(J.validate){let H=J.validate(K);if(H!==!0){let M=typeof H==="string"?H:`Invalid parameters for @${J.name}`;throw Error(M)}}let G=$;if(J.transform)G=await J.transform($,K,Y,B);if(J.clientScript){let H=J.clientScript(K);G+=`<script>${H}</script>`}if(J.css){let H=J.css(K);G+=`<style>${H}</style>`}return G}}}function q0(J,Z){let $=typeof Z==="function"?{mounted:Z}:Z;return qJ.set(J,$),$}function LZ(J,Z){let $={...Z};for(let X of J){let Y=X.indexOf(":"),B=X.indexOf("="),K=Y>=0&&(B<0||Y<B)?Y:B;if(K>=0){let G=X.slice(0,K).trim(),H=X.slice(K+1).trim();if(H==="true")H=!0;else if(H==="false")H=!1;else if(H==="null")H=null;else if(!Number.isNaN(Number(H)))H=Number(H);else if(typeof H==="string"&&H.startsWith("{"))try{H=JSON.parse(H)}catch{}$[G]=H}else{let G=Object.keys($).filter((H)=>!Z||!(H in Z)).length;$[G===0?"value":`arg${G}`]=X}}return $}function M0(){return[R({name:"uppercase",description:"Convert content to uppercase",transform:(J)=>J.toUpperCase()}),R({name:"lowercase",description:"Convert content to lowercase",transform:(J)=>J.toLowerCase()}),R({name:"capitalize",description:"Capitalize first letter of content",transform:(J)=>J.charAt(0).toUpperCase()+J.slice(1)}),R({name:"trim",description:"Remove leading and trailing whitespace",transform:(J)=>J.trim()}),R({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}),R({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>`}),R({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>`}}),R({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>`}),R({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;
        }
      `}),R({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;
        }
      `}),R({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');
        });
      `}),R({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)}}),R({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)}}),R({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 O0(){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 N0(J){let Z=/v-(\w+)(?::(\w+))?(?:\.([\w.]+))?="([^"]*)"/g;return J.replace(Z,($,X,Y,B,K)=>{let H=(B?B.split("."):[]).reduce((M,V)=>{return M[V]=!0,M},{});return`data-stx-directive="${X}:${K}" data-stx-directive-arg="${Y||""}" data-stx-directive-modifiers='${JSON.stringify(H)}'`})}var t,qJ;var xJ=S(()=>{t=new Map,qJ=new Map});function o(J,Z=f,$={},X){return Z.sort((Y,B)=>Y-B).map((Y)=>{return`${y(J,{...$,w:Y,fm:X})} ${Y}w`}).join(", ")}function Q0(J,Z=320,$=2560,X=0.08,Y={},B){let K=wZ(Z,$,X);return o(J,K,Y,B)}function wZ(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 MJ(J,Z,$=IJ,X={},Y){return $.sort((B,K)=>B-K).map((B)=>{let K=Math.round(Z*B);return`${y(J,{...X,w:K,dpr:B,fm:Y})} ${B}x`}).join(", ")}function j0(J,Z,$=IJ,X=80,Y={},B){let K={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((G,H)=>G-H).map((G)=>{let H=Math.round(Z*G),M=K[G]||Math.round(X*Math.max(0.5,1-G*0.1));return`${y(J,{...Y,w:H,q:M,dpr:G,fm:B})} ${G}x`}).join(", ")}function OJ(J,Z="100vw"){if(!J||Object.keys(J).length===0)return Z;let X=Object.entries(J).map(([Y,B])=>{let K=/^\d+$/.test(Y)?`${Y}px`:Y;return{bp:K,size:B,numericBp:Number.parseInt(K)||0}}).sort((Y,B)=>Y.numericBp-B.numericBp).map(({bp:Y,size:B})=>`(max-width: ${Y}) ${B}`);return X.push(Z),X.join(", ")}function _0(J,Z="100vw"){if(!J||J.length===0)return Z;let X=[...J].sort((Y,B)=>(Y.maxWidth||0)-(B.maxWidth||0)).filter((Y)=>Y.maxWidth).map((Y)=>`(max-width: ${Y.maxWidth}px) ${Y.imageWidth}`);return X.push(Z),X.join(", ")}function y(J,Z={}){let $=Object.entries(Z).filter(([,B])=>B!==void 0&&B!==null).map(([B,K])=>{if(Array.isArray(K))return[B,K.join(",")];return[B,String(K)]});if($.length===0)return J;let X=$.map(([B,K])=>`${B}=${encodeURIComponent(K)}`).join("&"),Y=J.includes("?")?"&":"?";return`${J}${Y}${X}`}function U0(J){let[Z,$]=J.split("?"),X={};if($)new URLSearchParams($).forEach((B,K)=>{if(/^\d+$/.test(B))X[K]=Number.parseInt(B,10);else if(/^\d+\.\d+$/.test(B))X[K]=Number.parseFloat(B);else if(B==="true")X[K]=!0;else if(B==="false")X[K]=!1;else X[K]=B});return{src:Z,params:X}}function z0(J){let{src:Z,widths:$,dprValues:X,fixedWidth:Y,formats:B=m,baseUrl:K="",params:G={}}=J,H=[];for(let M of B){let V,N;if(Y!==void 0&&X)V=MJ(Z,Y,X,G,M),N=X.map((q)=>({path:"",url:y(Z,{...G,w:Math.round(Y*q),fm:M}),width:Math.round(Y*q),height:0,format:M,size:0,dpr:q}));else{let q=$||f;V=o(Z,q,G,M),N=q.map((U)=>({path:"",url:y(Z,{...G,w:U,fm:M}),width:U,height:0,format:M,size:0}))}H.push({srcset:V,format:M,mimeType:DJ[M],variants:N})}return H}function E0(J,Z="100vw"){return J.map(({srcset:$,mimeType:X})=>`<source type="${X}" srcset="${$}" sizes="${Z}" />`).join(`
`)}function L0(J,Z){if(J.length===0)return;let $=[...J].sort((Y,B)=>Y.width-B.width),X=$.find((Y)=>Y.width>=Z);if(X)return X;return $[$.length-1]}function R0(J,Z){let $=Z?J.filter((Y)=>Y.format===Z):J;if($.length===0){let Y=J.filter((K)=>K.format==="jpeg"),B=Y.length>0?Y:J;return B[Math.floor(B.length/2)]}let X=$.sort((Y,B)=>Y.width-B.width);return X[Math.floor(X.length/2)]}function w0(J){let Z=new Map;for(let $ of J){let X=Z.get($.format)||[];X.push($),Z.set($.format,X)}return Z}function NJ(J){return DJ[J]||"application/octet-stream"}function T0(J){return RZ[J]||J}function F0(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 f,IJ,m,DJ,RZ,W0;var VJ=S(()=>{f=[320,480,640,768,1024,1280,1536,1920,2560],IJ=[1,1.5,2,3],m=["avif","webp","jpeg"],DJ={avif:"image/avif",webp:"image/webp",jpeg:"image/jpeg",png:"image/png",gif:"image/gif"},RZ={avif:"avif",webp:"webp",jpeg:"jpg",png:"png",gif:"gif"};W0={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 jJ(){try{return await import("ts-images")}catch{return null}}async function bJ(J,Z={}){let $={...TZ,...Z},X=await jJ();if(X)try{return await FZ(J,$,X)}catch(Y){console.warn(`[stx-media] ts-images placeholder generation failed, using fallback: ${Y}`)}return vJ(J,$)}async function FZ(J,Z,$){let{generatePlaceholder:X,generateThumbHash:Y}=$,K={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 G=await X(J,{width:Z.width,height:Z.height,quality:Z.quality,blurLevel:Z.blurLevel,strategy:K,base64Encode:!0});return{dataURL:G.dataURL,width:G.width,height:G.height,aspectRatio:G.aspectRatio,originalWidth:G.originalWidth,originalHeight:G.originalHeight,strategy:Z.strategy,dominantColor:G.dominantColor,css:G.css}}function vJ(J,Z){let $=Z.width||20,X=Z.height||$,Y="#e5e7eb",B=`<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(B)}`,width:$,height:X,aspectRatio:$/X,originalWidth:0,originalHeight:0,strategy:Z.strategy,dominantColor:"#e5e7eb"}}async function S0(J){let Z=await jJ();if(Z)try{return(await Z.generateThumbHash(J)).dataUrl}catch{}return(await vJ(J,{strategy:"thumbhash",width:32,height:32})).dataURL}function C0(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,B=(Z>>18&31)/31,K=Z>>23!==0,G=J[3]|J[4]<<8,H=(G>>3&63)/63,M=(G>>9&63)/63,V=G>>15!==0,N=Math.max(3,V?K?5:7:K?5:7),q=Math.max(3,V?K?5:7:K?5:7),U=32,O=32,E=Math.max(0,Math.min(255,Math.round(($+X)*255))),Q=Math.max(0,Math.min(255,Math.round($*255))),z=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(${E},${Q},${z})" width="32" height="32"/>
  </svg>`;return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(j)}`}async function P0(J,Z=20,$=50){return bJ(J,{strategy:"blur",width:Z,quality:$,blurLevel:40})}async function A0(J){let Z=await jJ();if(Z)try{return(await Z.generatePlaceholder(J,{strategy:"dominant-color"})).dominantColor||"#e5e7eb"}catch{}return"#e5e7eb"}function x0(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 yJ(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 I0(J){return`background-image: url('${J.dataURL}'); background-size: cover; background-position: center;`}async function fJ(J,Z={}){let $=`${J}:${JSON.stringify(Z)}`;if(d.has($))return d.get($);let X=await bJ(J,Z);return d.set($,X),X}function D0(){d.clear()}function b0(){return{size:d.size,keys:Array.from(d.keys())}}var TZ,QJ,d;var gJ=S(()=>{TZ={strategy:"thumbhash",width:20,quality:50,blurLevel:40,transitionDuration:300,easing:"ease-out"},QJ=`
.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();d=new Map});import{createHash as _J}from"crypto";import{readFile as kZ,stat as hJ}from"fs/promises";async function l(J){try{let Z=await kZ(J);return _J("sha256").update(Z).digest("hex").slice(0,16)}catch{return""}}function g0(J){return _J("sha256").update(J).digest("hex").slice(0,16)}function uJ(J){return _J("sha256").update(J).digest("hex").slice(0,16)}function e(J,Z){let $=JSON.stringify(Z,Object.keys(Z).sort());return`${uJ(J)}-${uJ($)}`}async function WJ(J){try{return(await hJ(J)).mtimeMs}catch{return 0}}async function g(J){try{return await hJ(J),!0}catch{return!1}}var JJ=()=>{};import{mkdir as SZ,readFile as dJ,writeFile as CZ,readdir as lJ,rm as UJ,stat as PZ}from"fs/promises";import{join as c,dirname as AZ}from"path";async function xZ(J){try{await SZ(J,{recursive:!0})}catch{}}function cJ(J,Z,$){return c(J,$,`${Z}.json`)}async function mJ(J,Z,$){if((Date.now()-J.createdAt)/86400000>$)return!1;if(await WJ(Z)!==J.srcMtime)return!1;return!0}async function nJ(J,Z,$,X=n){if(!X.enabled)return null;let Y=e(J,Z),B=I.get(Y);if(B){if(await mJ(B,J,X.maxAge))return B.lastAccessedAt=Date.now(),B.data;I.delete(Y)}let K=cJ(X.directory,Y,$);if(await g(K))try{let G=await dJ(K,"utf-8"),H=JSON.parse(G);if(await mJ(H,J,X.maxAge))return H.lastAccessedAt=Date.now(),I.set(Y,H),H.data}catch{}return null}async function pJ(J,Z,$,X,Y=n){if(!Y.enabled)return;let B=e(J,Z),K=await l(J),G=await WJ(J),H={key:B,src:J,srcHash:K,srcMtime:G,optionsHash:e("",Z),data:$,createdAt:Date.now(),lastAccessedAt:Date.now()};I.set(B,H);let M=cJ(Y.directory,B,X);try{await xZ(AZ(M)),await CZ(M,JSON.stringify(H,null,2))}catch(V){console.warn(`[stx-media] Failed to write cache: ${V}`)}}async function l0(J,Z,$=n){for(let[X,Y]of I.entries())if(Y.src===J)I.delete(X)}async function iJ(J,Z=n){if(J==="all")I.clear();else I.clear();let $=J==="all"?["image","video"]:[J];for(let X of $){let Y=c(Z.directory,X);try{await UJ(Y,{recursive:!0,force:!0})}catch{}}}async function c0(J=n){let Z={memoryEntries:I.size,diskEntries:{image:0,video:0},totalSizeMB:0};for(let $ of["image","video"]){let X=c(J.directory,$);try{let Y=await lJ(X);Z.diskEntries[$]=Y.length;for(let B of Y){let K=c(X,B),G=await PZ(K);Z.totalSizeMB+=G.size/1048576}}catch{}}return Z}async function n0(J=n){let Z=0,$=J.maxAge*24*60*60*1000;for(let X of["image","video"]){let Y=c(J.directory,X);try{let B=await lJ(Y);for(let K of B){let G=c(Y,K);try{let H=await dJ(G,"utf-8"),M=JSON.parse(H);if(Date.now()-M.createdAt>$)await UJ(G),I.delete(M.key),Z++}catch{await UJ(G).catch(()=>{}),Z++}}}catch{}}return Z}var I,n;var oJ=S(()=>{JJ();I=new Map,n={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}});class $J{config;constructor(J={}){this.config={...IZ,...J}}async get(J,Z){return nJ(J,Z,"image",this.config)}async set(J,Z,$){return pJ(J,Z,$,"image",this.config)}async clear(){return iJ("image",this.config)}updateConfig(J){this.config={...this.config,...J}}}function zJ(J){if(!ZJ)ZJ=new $J(J);else if(J)ZJ.updateConfig(J);return ZJ}async function XJ(J,Z,$){let X=$?{directory:`${$.outputDir}/../.cache`}:{};return zJ(X).get(J,Z)}async function YJ(J,Z,$,X){let Y=X?{directory:`${X.outputDir}/../.cache`}:{};return zJ(Y).set(J,Z,$)}async function aJ(){return zJ().clear()}var IZ,ZJ=null;var EJ=S(()=>{oJ();IZ={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500,cacheVariants:!0,cachePlaceholders:!0}});import{resolve as DZ,basename as bZ,extname as vZ,join as yZ}from"path";import{mkdir as fZ}from"fs/promises";async function LJ(){try{return await import("ts-images")}catch{return null}}function rJ(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 gZ(J,Z){let $=Z?rJ(Z):rJ("web"),X=J.formatQuality||{};return{jpeg:{...$.jpeg,...X.jpeg},png:{...$.png,...X.png},webp:{...$.webp,...X.webp},avif:{...$.avif,...X.avif}}}async function sJ(J,Z,$){let X=await LJ();if(!X)return console.warn("[stx-media] ts-images not installed, skipping optimization"),{src:J,processed:!1};let Y=await XJ(J,Z,$);if(Y)return Y;try{let B=DZ(J);if(!await g(B))return{src:J,processed:!1,errors:[`Source file not found: ${J}`]};let K=gZ($,Z.preset),G=$.outputDir||"dist/images",H=$.baseUrl||"/images";await fZ(G,{recursive:!0});let M=await l(B),V=bZ(J,vZ(J)),N=Z.outputFormat?[Z.outputFormat]:$.defaultFormats||["avif","webp","jpeg"],q={src:J,processed:!0,variants:[],hash:M},U=null;if(Z.transformations&&Z.transformations.length>0)U=await RJ(B,Z.transformations,X);for(let O of N){let E=K[O]||{},Q=`${V}-${M}.${O}`,z=yZ(G,Q);try{let j=await X.optimizeImage({input:U||B,output:z,format:O,quality:E.quality,progressive:E.progressive});if(j){if(q.variants.push({path:z,url:`${H}/${Q}`,width:j.width||0,height:j.height||0,format:O,size:j.outputSize||0}),!q.originalWidth&&j.width)q.originalWidth=j.width,q.originalHeight=j.height}}catch(j){q.errors=q.errors||[],q.errors.push(`Failed to optimize ${O}: ${j}`)}}if(Z.embedThumbhash||Z.placeholder==="thumbhash")try{let O=await X.generateThumbHash(B);q.placeholder=O.dataUrl}catch(O){q.errors=q.errors||[],q.errors.push(`Failed to generate thumbhash: ${O}`)}if(Z.useDominantColor)try{let O=await X.generatePlaceholder(B,{strategy:"dominant-color"});q.dominantColor=O.dominantColor}catch(O){q.errors=q.errors||[],q.errors.push(`Failed to extract dominant color: ${O}`)}return await YJ(J,Z,q,$),q}catch(B){return{src:J,processed:!1,errors:[`Processing failed: ${B}`]}}}async function tJ(J,Z,$,X){let Y=await LJ();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(B){return{success:!1,error:String(B)}}}async function RJ(J,Z,$){let X=$||await LJ();if(!X)return console.warn("[stx-media] ts-images not installed, skipping transformations"),null;try{let Y=await X.decode(J);for(let B of Z){let K=B.options||{};switch(B.type){case"resize":if(K.width||K.height)Y=await X.resize(Y,{width:K.width,height:K.height,fit:K.fit});break;case"blur":if(K.sigma!==void 0)Y=await X.blur(Y,K.sigma);break;case"sharpen":if(K.amount!==void 0)Y=await X.sharpen(Y,K.amount);break;case"grayscale":Y=await X.grayscale(Y);break;case"rotate":if(K.angle!==void 0)Y=await X.rotate(Y,K.angle);break;case"flip":Y=await X.flip(Y);break;case"flop":Y=await X.flop(Y);break;case"brightness":if(K.value!==void 0)Y=await X.brightness(Y,K.value);break;case"contrast":if(K.value!==void 0)Y=await X.contrast(Y,K.value);break;case"saturation":if(K.value!==void 0)Y=await X.saturation(Y,K.value);break}}return await X.encode(Y,"png")}catch(Y){return console.error(`[stx-media] Transformation failed: ${Y}`),null}}var eJ=S(()=>{JJ();EJ()});import{resolve as uZ,basename as hZ,extname as mZ,join as dZ}from"path";import{mkdir as lZ}from"fs/promises";async function cZ(){try{return await import("ts-images")}catch{return null}}async function wJ(J,Z,$){let X=await cZ();if(!X)return console.warn("[stx-media] ts-images not installed, skipping responsive generation"),null;let Y=uZ(J);if(!await g(Y))return console.warn(`[stx-media] Source file not found: ${J}`),null;try{let B=Z.responsiveWidths||$.breakpoints||nZ,K=Z.formats||$.defaultFormats||["avif","webp","jpeg"],G=$.outputDir||"dist/images",H=$.baseUrl||"/images";await lZ(G,{recursive:!0});let M=await l(Y),V=hZ(J,mZ(J)),N=$.formatQuality||{jpeg:{quality:82},png:{quality:80},webp:{quality:82},avif:{quality:75}},q={src:J,byFormat:{},srcsets:{}};for(let O of K){q.byFormat[O]=[];let E=[];for(let Q of B){let z=`${V}-${Q}w-${M}.${O}`,j=dZ(G,z),L=`${H}/${z}`;try{let F=N[O]?.quality||80;if(await g(j)){q.byFormat[O].push({path:j,url:L,width:Q,height:0,format:O,size:0}),E.push(`${L} ${Q}w`);continue}let w=await X.processImage({input:Y,output:j,format:O,quality:F,resize:{width:Q}});if(w)q.byFormat[O].push({path:j,url:L,width:Q,height:w.height||Math.round(Q*(w.height||1)/(w.width||1)),format:O,size:w.outputSize||0}),E.push(`${L} ${Q}w`)}catch(F){console.warn(`[stx-media] Failed to generate ${O} at ${Q}w: ${F}`)}}q.srcsets[O]=E.join(", ")}let U=Z.placeholder||$.placeholderStrategy||"thumbhash";if(U!=="none")try{if(U==="thumbhash"){let O=await X.generateThumbHash(Y);q.placeholder={dataURL:O.dataUrl,width:O.width||32,height:O.height||32,strategy:"thumbhash"}}else{let O=await X.generatePlaceholder(Y,{strategy:U,width:20});q.placeholder={dataURL:O.dataURL,width:O.width,height:O.height,strategy:U}}}catch(O){console.warn(`[stx-media] Failed to generate placeholder: ${O}`)}return q.sizes=Z.sizes||pZ(B),q}catch(B){return console.error(`[stx-media] Responsive generation failed: ${B}`),null}}function pZ(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 JZ(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 K1(J,Z,$){let X=[];for(let Y of Z){let B=await wJ(Y.src,{responsiveWidths:Y.widths},$);if(B){for(let[K,G]of Object.entries(B.srcsets))if(G)X.push({media:Y.media,srcset:G,type:iZ(K)})}}return X}function iZ(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 nZ;var ZZ=S(()=>{JJ();nZ=[320,480,640,768,1024,1280,1536,1920]});var $Z={};zZ($Z,{setCachedImageResult:()=>YJ,processImage:()=>sJ,optimizeImage:()=>tJ,getCachedImageResult:()=>XJ,generateSrcset:()=>JZ,generateResponsiveVariants:()=>wJ,clearImageCache:()=>aJ,applyTransformations:()=>RJ,ImageProcessorCache:()=>$J});var XZ=S(()=>{eJ();ZZ();EJ()});async function oZ(){try{return await Promise.resolve().then(() => (XZ(),$Z))}catch(J){if(!YZ)console.warn("[stx-media] Image processor not available, some features disabled:",J),YZ=!0;return null}}async function a(J,Z={}){let $=Z,X=J;if(X.process&&!X.skipOptimization){if($.tsImagesConfig?.enabled&&!$.isDev)return eZ(X,$)}if($.processedResult?.processed)return SJ(J,$.processedResult,Z);if($.responsiveVariants)return HZ(J,$.responsiveVariants,Z);let{src:Y,alt:B,width:K,height:G,sizes:H,widths:M=f,dpr:V,formats:N=m,quality:q=TJ,params:U={},placeholder:O="none",placeholderOptions:E={},lazy:Q=!0,priority:z=!1,loading:j=z?"eager":BJ,decoding:L=KJ,fetchpriority:F,objectFit:w,objectPosition:u,crossorigin:_,referrerpolicy:b}=J,D=J.class,T=J.style,k=J.id,v=J.data||{},{isDev:P=!1,baseUrl:p=""}=Z;if(P&&!Z.optimize)return sZ(J);let A,W,x=k||`stx-img-${Math.random().toString(36).slice(2,8)}`;if(O!=="none"&&!z)try{A=await fJ(Y,{strategy:O,...E}),W=yJ(x,A,E)}catch{}let r=V!==void 0&&K!==void 0,h;if(r)h=rZ(J,x,A,Z);else h=await aZ(J,x,A,Z);let i;if(z){let PJ=N.includes("webp")?"webp":N[0],OZ=o(Y,M,{...U,q},PJ),NZ=typeof H==="object"?OJ(H):H||"100vw";i=`<link rel="preload" as="image" imagesrcset="${OZ}" imagesizes="${NZ}" />`}let s=[];if(!KZ&&O!=="none")s.push(QJ),KZ=!0;if(W)s.push(W);let MZ=Q?GZ(x):void 0;return{html:h,preloadLink:i,css:s.length>0?s.join(`
`):void 0,script:MZ}}async function aZ(J,Z,$,X){let{src:Y,alt:B,width:K,height:G,sizes:H,widths:M=f,formats:V=m,quality:N=TJ,params:q={},lazy:U=!0,priority:O=!1,loading:E=O?"eager":BJ,decoding:Q=KJ,fetchpriority:z,objectFit:j,objectPosition:L,crossorigin:F,referrerpolicy:w}=J,u=J.class,_=J.style,b=J.data||{},D=typeof H==="object"?OJ(H):H||"100vw",T=[];for(let P of V){let p=o(Y,M,{...q,q:N},P),A=NJ(P);if(U&&!O)T.push(`  <source type="${A}" data-srcset="${p}" data-sizes="${D}" />`);else T.push(`  <source type="${A}" srcset="${p}" sizes="${D}" />`)}let k=FJ({src:y(Y,{...q,q:N}),alt:B,width:K,height:G,loading:O?void 0:E,decoding:Q,fetchpriority:O?"high":z,objectFit:j,objectPosition:L,crossorigin:F,referrerpolicy:w,className:BZ(u,$),style:kJ(_,j,L,$),lazy:U&&!O,data:b}),v;if($){let P=`background-image: url('${$.dataURL}'); background-size: cover; background-position: center;`;v=`<div id="${Z}" class="stx-img-placeholder" style="${P}">
  <picture>
${T.join(`
`)}
    <img ${k} />
  </picture>
</div>`}else v=`<picture${Z?` id="${Z}"`:""}>
${T.join(`
`)}
  <img ${k} />
</picture>`;return v}function rZ(J,Z,$,X){let{src:Y,alt:B,width:K,height:G,dpr:H=[1,2,3],quality:M=TJ,params:V={},lazy:N=!0,priority:q=!1,loading:U=q?"eager":BJ,decoding:O=KJ,fetchpriority:E,objectFit:Q,objectPosition:z,crossorigin:j,referrerpolicy:L}=J,F=J.class,w=J.style,u=J.data||{},_=typeof K==="number"?K:Number.parseInt(String(K),10),b=MJ(Y,_,H,{...V,q:M}),D=FJ({src:y(Y,{...V,w:_,q:M}),alt:B,width:K,height:G,loading:q?void 0:U,decoding:O,fetchpriority:q?"high":E,objectFit:Q,objectPosition:z,crossorigin:j,referrerpolicy:L,className:BZ(F,$),style:kJ(w,Q,z,$),lazy:N&&!q,data:u}),T=N&&!q?`data-srcset="${b}"`:`srcset="${b}"`;if($){let k=`background-image: url('${$.dataURL}'); background-size: cover; background-position: center;`;return`<div id="${Z}" class="stx-img-placeholder" style="${k}">
  <img ${D} ${T} />
</div>`}return`<img ${Z?`id="${Z}" `:""}${D} ${T} />`}function sZ(J){let{src:Z,alt:$,width:X,height:Y,loading:B=BJ,decoding:K=KJ,fetchpriority:G,objectFit:H,objectPosition:M,crossorigin:V,referrerpolicy:N,priority:q=!1}=J,U=J.class,O=J.style,E=J.id,Q=J.data||{};return{html:`<img ${FJ({src:Z,alt:$,width:X,height:Y,loading:q?"eager":B,decoding:K,fetchpriority:q?"high":G,objectFit:H,objectPosition:M,crossorigin:V,referrerpolicy:N,className:U,style:kJ(O,H,M),id:E,data:Q})} />`}}function FJ(J){let Z=[];if(J.lazy)Z.push(`data-src="${C(J.src)}"`),Z.push('src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"');else Z.push(`src="${C(J.src)}"`);if(Z.push(`alt="${C(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="${C(J.className)}"`);if(J.style)Z.push(`style="${C(J.style)}"`);if(J.id)Z.push(`id="${C(J.id)}"`);if(J.data)for(let[$,X]of Object.entries(J.data))Z.push(`data-${$}="${C(X)}"`);if(J.lazy)Z.push("data-stx-lazy");return Z.join(" ")}function BZ(J,Z){let $=[];if(J)$.push(J);if(Z)$.push("stx-img-blur");return $.join(" ")||""}function kJ(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 C(J){return J.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#039;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function GZ(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 tZ(J){let Z=J.match(/<Img\s+([^>]*?)\/?>/);if(!Z)return null;let $=Z[1],X={},Y=/(:?)(\w+)(?:=(?:"([^"]*)"|'([^']*)'|\{([^}]+)\}))?/g,B;while((B=Y.exec($))!==null){let[,K,G,H,M,V]=B,N=H??M??V??!0;if(K===":"&&typeof N==="string")try{X[G]=JSON.parse(N)}catch{X[G]=N}else switch(G){case"src":X.src=String(N);break;case"alt":X.alt=String(N);break;case"width":X.width=Number(N)||N;break;case"height":X.height=Number(N)||N;break;case"sizes":X.sizes=String(N);break;case"quality":X.quality=Number(N);break;case"placeholder":X.placeholder=N;break;case"lazy":X.lazy=N===!0||N==="true";break;case"priority":X.priority=N===!0||N==="true";break;case"class":X.class=String(N);break;case"style":X.style=String(N);break;case"id":X.id=String(N);break;case"loading":X.loading=N;break;case"decoding":X.decoding=N;break;case"fetchpriority":X.fetchpriority=N;break;case"objectFit":X.objectFit=N;break;case"objectPosition":X.objectPosition=String(N);break;case"crossorigin":X.crossorigin=N;break}}if(!X.src||!X.alt)return null;return X}async function N1(J,Z={}){let $=/<Img\s+[^>]*?\/?>/g,X=[],Y=[],B=[],K=J,G=[],H;while((H=$.exec(J))!==null)G.push({match:H[0],index:H.index});for(let M=G.length-1;M>=0;M--){let{match:V}=G[M],N=tZ(V);if(N){let q=await a(N,Z);if(K=K.replace(V,q.html),q.preloadLink)X.push(q.preloadLink);if(q.css)Y.push(q.css);if(q.script)B.push(q.script)}}return{html:K,preloadLinks:X,styles:Y,scripts:B}}async function eZ(J,Z){let $=await oZ();if(!$)return a({...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 B=await $.generateResponsiveVariants(J.src,J,X);if(B)return HZ(J,B,Z)}else{let B=await $.processImage(J.src,J,X);if(B.processed)return SJ(J,B,Z)}return a({...J,process:!1},Z)}async function SJ(J,Z,$){let{alt:X,width:Y,height:B,lazy:K=!0,priority:G=!1,objectFit:H,objectPosition:M,crossorigin:V,referrerpolicy:N}=J,q=J.class,U=J.style,O=J.id||`stx-img-${Math.random().toString(36).slice(2,8)}`,E=J.data||{},Q=Z.variants||[],z=Q.find((W)=>W.format==="jpeg")||Q.find((W)=>W.format==="webp")||Q[0],j=z?.url||J.src,L=Q.filter((W)=>W.format===(z?.format||"jpeg")).map((W)=>`${W.url} ${W.width}w`).join(", "),F=new Map;for(let W of Q){if(!F.has(W.format))F.set(W.format,[]);F.get(W.format).push(W)}let w=[],u=["avif","webp","jpeg","png"];for(let W of u){let x=F.get(W);if(x&&x.length>0){let r=x.map((i)=>`${i.url} ${i.width}w`).join(", "),h=NJ(W);if(K&&!G)w.push(`  <source type="${h}" data-srcset="${r}" />`);else w.push(`  <source type="${h}" srcset="${r}" />`)}}let _=[];if(K&&!G){if(_.push(`data-src="${C(j)}"`),_.push('src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"'),L)_.push(`data-srcset="${L}"`)}else if(_.push(`src="${C(j)}"`),L)_.push(`srcset="${L}"`);_.push(`alt="${C(X)}"`);let b=Y||Z.originalWidth,D=B||Z.originalHeight;if(b)_.push(`width="${b}"`);if(D)_.push(`height="${D}"`);if(!G)_.push(`loading="${K?"lazy":"eager"}"`);if(_.push('decoding="async"'),G)_.push('fetchpriority="high"');if(V)_.push(`crossorigin="${V}"`);if(N)_.push(`referrerpolicy="${N}"`);let T=[];if(H)T.push(`object-fit: ${H}`);if(M)T.push(`object-position: ${M}`);if(Z.placeholder&&K)T.push("opacity: 0; transition: opacity 300ms ease-out");if(U)T.push(U);if(T.length>0)_.push(`style="${T.join("; ")}"`);let k=[];if(q)k.push(q);if(Z.placeholder)k.push("stx-img-blur");if(k.length>0)_.push(`class="${k.join(" ")}"`);if(K&&!G)_.push("data-stx-lazy");for(let[W,x]of Object.entries(E))_.push(`data-${W}="${C(x)}"`);let v;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};`;v=`<div id="${O}" class="stx-img-placeholder" style="${W}">
  <picture>
${w.join(`
`)}
    <img ${_.join(" ")} />
  </picture>
</div>`}else v=`<picture${O?` id="${O}"`:""}>
${w.join(`
`)}
  <img ${_.join(" ")} />
</picture>`;let P=[];if(Z.placeholder)P.push(QJ);let p=K?GZ(O):void 0,A;if(G&&L)A=`<link rel="preload" as="image" imagesrcset="${L}" />`;return{html:v,preloadLink:A,css:P.length>0?P.join(`
`):void 0,script:p}}async function HZ(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,B]of Object.entries(Z.byFormat))if(B)X.variants.push(...B);return SJ(J,X,$)}var YZ=!1,TJ=80,KJ="async",BJ="lazy",KZ=!1;var qZ=S(()=>{VJ();gJ()});function J0(){return R({name:"img",hasEndTag:!1,description:"Render an optimized responsive image with srcset and lazy loading",transform:async(J,Z,$,X)=>{let{src:Y,alt:B,options:K}=Z0(J,Z,$);if(!Y)return console.warn("@img directive: missing src argument"),"<!-- @img: missing src -->";let G={src:Y,alt:B||"",widths:K.widths||f,formats:K.formats||m,quality:K.quality,sizes:K.sizes,dpr:K.dpr,params:K.params,placeholder:K.placeholder,placeholderOptions:K.placeholderOptions,lazy:K.lazy!==!1,priority:K.priority||!1,loading:K.loading,decoding:K.decoding,fetchpriority:K.fetchpriority,objectFit:K.objectFit,objectPosition:K.objectPosition,class:K.class,style:K.style,id:K.id,width:K.width,height:K.height},H=$.__isDev||!1,M=await a(G,{isDev:H}),V=M.html;if(M.preloadLink)V=M.preloadLink+`
`+V;if(M.css)V+=`
<style>${M.css}</style>`;if(M.script)V+=`
<script>${M.script}</script>`;return V},defaults:{src:"",alt:"",options:{lazy:!0,placeholder:"none"}}})}function Z0(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=$0(X),B=CJ(Y[0],$)||"",K=CJ(Y[1],$)||"",G={};if(Y[2]){let H=CJ(Y[2],$);if(typeof H==="object"&&H!==null)G=H;else if(typeof Y[2]==="string")try{G=JSON.parse(Y[2])}catch{}}return{src:B,alt:K,options:G}}function $0(J){let Z=[],$="",X=!1,Y="",B=0,K=0;for(let G=0;G<J.length;G++){let H=J[G],M=G>0?J[G-1]:"";if((H==='"'||H==="'"||H==="`")&&M!=="\\"){if(!X)X=!0,Y=H;else if(H===Y)X=!1,Y="";else $+=H;continue}if(!X){if(H==="{")B++;if(H==="}")B--;if(H==="[")K++;if(H==="]")K--;if(H===","&&B===0&&K===0){Z.push($.trim()),$="";continue}}$+=H}if($.trim())Z.push($.trim());return Z}function CJ(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 W1;var X0=S(()=>{xJ();qZ();VJ();W1=J0()});X0();export{W1 as imgDirective,J0 as createImgDirective};
