// @bun
var{defineProperty:F,getOwnPropertyNames:x,getOwnPropertyDescriptor:w}=Object,h=Object.prototype.hasOwnProperty;function f(z){return this[z]}var u=(z)=>{var G=(S??=new WeakMap).get(z),H;if(G)return G;if(G=F({},"__esModule",{value:!0}),z&&typeof z==="object"||typeof z==="function"){for(var J of x(z))if(!h.call(G,J))F(G,J,{get:f.bind(z,J),enumerable:!(H=w(z,J))||H.enumerable})}return S.set(z,G),G},S;var k=(z)=>z;function I(z,G){this[z]=k.bind(null,G)}var l=(z,G)=>{for(var H in G)F(z,H,{get:G[H],enumerable:!0,configurable:!0,set:I.bind(G,H)})};var V=(z,G)=>()=>(z&&(G=z(z=0)),G);var s=import.meta.require;function v(){return`stx-${++m}-${Date.now().toString(36)}`}function y(z){let G={id:v(),element:z||null,mountHooks:[],destroyHooks:[],updateHooks:[],refs:new Map,watchers:[],isMounted:!1};return j.set(G.id,G),G}function D(z){P=z}function M(){return P}function Q(z){if(!P)return console.warn(`[stx] ${z} must be called within a component setup.`),null;return P}function A(z){let G=Q("onMount");if(G)G.mountHooks.push(z)}function _(z){let G=Q("onDestroy");if(G)G.destroyHooks.push(z)}function g(z){let G=Q("onUpdate");if(G)G.updateHooks.push(z)}function p(z=null){let G={value:z,get current(){return this.value}},H=M();if(H){let J=`ref-${H.refs.size}`;H.refs.set(J,G)}return G}function n(z,G=null){let H=p(G),J=M();if(J)J.refs.set(z,H);return H}function t(z,G,H={}){let J,X,Y=!0,Z=()=>{if(!Y)return;let K=z();if(J!==K||H.immediate){if(X)X();X=G(K,J),J=K}};if(H.immediate)Z();else J=z();let $=setInterval(Z,16),R=()=>{if(Y=!1,clearInterval($),X)X()},q=M();if(q)q.watchers.push({stop:R}),q.destroyHooks.push(R);return R}function e(z){let G,H=!0;return{get value(){if(H)G=z(),H=!1,queueMicrotask(()=>{H=!0});return G}}}function zz(z,G){let H=y(z);D(H);try{G()}finally{D(null)}return H}function Gz(z){if(z.isMounted)return;z.isMounted=!0;for(let G of z.mountHooks)try{let H=G();if(typeof H==="function")z.destroyHooks.push(H)}catch(H){console.error("[stx] Error in onMount hook:",H)}}function Hz(z){if(!z.isMounted)return;for(let G of z.updateHooks)try{let H=G();if(typeof H==="function")z.destroyHooks.push(H)}catch(H){console.error("[stx] Error in onUpdate hook:",H)}}function Jz(z){if(!z.isMounted)return;for(let G of z.watchers)G.stop();for(let G of z.destroyHooks)try{G()}catch(H){console.error("[stx] Error in onDestroy hook:",H)}for(let G of z.refs.values())G.value=null;z.isMounted=!1,j.delete(z.id)}function Xz(){return`
// STX Lifecycle Runtime
(function() {
  if (typeof window === 'undefined') return;

  const instances = new Map();
  let currentInstance = null;
  let idCounter = 0;

  function generateId() {
    return 'stx-' + (++idCounter) + '-' + Date.now().toString(36);
  }

  function createInstance(element) {
    const instance = {
      id: generateId(),
      element: element,
      mountHooks: [],
      destroyHooks: [],
      updateHooks: [],
      refs: new Map(),
      watchers: [],
      isMounted: false
    };
    instances.set(instance.id, instance);
    return instance;
  }

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

  // Lifecycle hooks
  window.STX.onMount = function(hook) {
    if (currentInstance) currentInstance.mountHooks.push(hook);
  };

  window.STX.onDestroy = function(hook) {
    if (currentInstance) currentInstance.destroyHooks.push(hook);
  };

  window.STX.onUpdate = function(hook) {
    if (currentInstance) currentInstance.updateHooks.push(hook);
  };

  // Aliases
  window.STX.onMounted = window.STX.onMount;
  window.STX.onUnmounted = window.STX.onDestroy;
  window.STX.onUpdated = window.STX.onUpdate;

  // Refs
  window.STX.ref = function(initialValue) {
    const r = { value: initialValue || null };
    Object.defineProperty(r, 'current', {
      get: function() { return this.value; }
    });
    if (currentInstance) {
      currentInstance.refs.set('ref-' + currentInstance.refs.size, r);
    }
    return r;
  };

  // Watch
  window.STX.watch = function(source, callback, options) {
    options = options || {};
    let oldValue;
    let cleanup;
    let isActive = true;

    function run() {
      if (!isActive) return;
      const newValue = source();
      if (oldValue !== newValue || options.immediate) {
        if (cleanup) cleanup();
        cleanup = callback(newValue, oldValue);
        oldValue = newValue;
      }
    }

    if (options.immediate) {
      run();
    }
else {
      oldValue = source();
    }

    const intervalId = setInterval(run, 16);

    function stop() {
      isActive = false;
      clearInterval(intervalId);
      if (cleanup) cleanup();
    }

    if (currentInstance) {
      currentInstance.watchers.push({ stop: stop });
      currentInstance.destroyHooks.push(stop);
    }

    return stop;
  };

  // Computed
  window.STX.computed = function(getter) {
    let cached;
    let dirty = true;
    return {
      get value() {
        if (dirty) {
          cached = getter();
          dirty = false;
          queueMicrotask(function() { dirty = true; });
        }
        return cached;
      }
    };
  };

  // Component management
  window.STX.setupComponent = function(element, setup) {
    const instance = createInstance(element);
    currentInstance = instance;
    try {
      setup();
    }
finally {
      currentInstance = null;
    }
    return instance;
  };

  window.STX.mountComponent = function(instance) {
    if (instance.isMounted) return;
    instance.isMounted = true;
    instance.mountHooks.forEach(function(hook) {
      try {
        const cleanup = hook();
        if (typeof cleanup === 'function') {
          instance.destroyHooks.push(cleanup);
        }
      }
catch (e) {
        console.error('[stx] onMount error:', e);
      }
    });
  };

  window.STX.destroyComponent = function(instance) {
    if (!instance.isMounted) return;
    instance.watchers.forEach(function(w) { w.stop(); });
    instance.destroyHooks.forEach(function(hook) {
      try { hook(); }
catch (e) { console.error('[stx] onDestroy error:', e); }
    });
    instance.refs.forEach(function(ref) { ref.value = null; });
    instance.isMounted = false;
    instances.delete(instance.id);
  };

  // ==========================================================================
  // Vue-Style Refs System - No document.** required!
  // ==========================================================================

  // Internal: Query for ref elements without exposing document API
  function queryRef(name, root) {
    return (root || document).querySelector('[data-stx-ref="' + name + '"], [data-ref="' + name + '"]');
  }

  function queryAllRefs(root) {
    return (root || document).querySelectorAll('[data-stx-ref], [data-ref]');
  }

  // Auto-bind refs from ref attributes (Vue-style)
  window.STX.bindRefs = function(root, refs) {
    if (!root) return;
    queryAllRefs(root).forEach(function(el) {
      var refName = el.getAttribute('data-stx-ref') || el.getAttribute('data-ref');
      if (refs[refName]) {
        refs[refName].value = el;
      }
    });
  };

  // Vue-style useRefs() - returns object with all refs as direct elements
  // Usage: const { input, button, container } = STX.useRefs()
  window.STX.useRefs = function(root) {
    var refs = {};
    queryAllRefs(root).forEach(function(el) {
      var refName = el.getAttribute('data-stx-ref') || el.getAttribute('data-ref');
      if (refName) {
        refs[refName] = el;
      }
    });
    return refs;
  };

  // Get a single ref by name - Vue's useTemplateRef equivalent
  // Usage: const input = STX.useRef('input')
  window.STX.useRef = function(name, root) {
    return queryRef(name, root);
  };

  // Two-way binding helper for form elements
  // Usage: STX.model(inputEl, state, 'username')
  window.STX.model = function(el, state, key) {
    if (!el || !state) return;

    var isCheckbox = el.type === 'checkbox';
    var isRadio = el.type === 'radio';
    var isSelect = el.tagName === 'SELECT';

    // Set initial value
    if (isCheckbox) {
      el.checked = !!state[key];
    }
else if (isRadio) {
      el.checked = el.value === state[key];
    }
else {
      el.value = state[key] || '';
    }

    // Listen for changes
    var eventType = isCheckbox || isRadio ? 'change' : 'input';
    el.addEventListener(eventType, function() {
      if (isCheckbox) {
        state[key] = el.checked;
      }
else if (isRadio) {
        if (el.checked) state[key] = el.value;
      }
else {
        state[key] = el.value;
      }
    });

    // Return cleanup function
    return function() {
      el.removeEventListener(eventType, arguments.callee);
    };
  };

  // Batch event binding helper - cleaner than manual addEventListener
  // Usage: STX.on({ click: [btn1, btn2], input: [textField] }, handler)
  window.STX.on = function(el, event, handler) {
    if (!el) return function() {};
    el.addEventListener(event, handler);
    return function() { el.removeEventListener(event, handler); };
  };

  // Bind multiple events at once
  // Usage: STX.events(refs.btn, { click: handleClick, mouseenter: handleHover })
  window.STX.events = function(el, eventMap) {
    if (!el) return function() {};
    var cleanups = [];
    Object.keys(eventMap).forEach(function(event) {
      el.addEventListener(event, eventMap[event]);
      cleanups.push(function() { el.removeEventListener(event, eventMap[event]); });
    });
    return function() { cleanups.forEach(function(c) { c(); }); };
  };

  // ==========================================================================
  // DOM Helpers - Eliminate document.* usage
  // ==========================================================================

  // Global keyboard event listener
  // Usage: STX.onKey('Escape', () => closeModal())
  window.STX.onKey = function(key, handler, options) {
    var listener = function(e) {
      if (e.key === key) {
        handler(e);
      }
    };
    document.addEventListener('keydown', listener, options);
    return function() { document.removeEventListener('keydown', listener, options); };
  };

  // Create element helper
  // Usage: STX.el('div', { class: 'foo' }, 'text content')
  window.STX.el = function(tag, attrs, content) {
    var el = document.createElement(tag);
    if (attrs) {
      Object.keys(attrs).forEach(function(key) {
        if (key === 'class') {
          el.className = attrs[key];
        }
else if (key.startsWith('on')) {
          el.addEventListener(key.slice(2).toLowerCase(), attrs[key]);
        }
else {
          el.setAttribute(key, attrs[key]);
        }
      });
    }
    if (content) {
      if (typeof content === 'string') {
        el.textContent = content;
      }
else if (Array.isArray(content)) {
        content.forEach(function(child) { el.appendChild(child); });
      }
else {
        el.appendChild(content);
      }
    }
    return el;
  };

  // Get currently focused element
  // Usage: const focused = STX.activeElement()
  window.STX.activeElement = function() {
    return document.activeElement;
  };

  // Escape HTML helper
  // Usage: const safe = STX.escapeHtml(userInput)
  window.STX.escapeHtml = function(text) {
    var div = document.createElement('div');
    div.textContent = text;
    return div.innerHTML;
  };

  // MutationObserver for automatic lifecycle management
  const observer = new MutationObserver(function(mutations) {
    mutations.forEach(function(mutation) {
      // Handle removed nodes
      mutation.removedNodes.forEach(function(node) {
        if (node.nodeType === 1 && node.__stx_instance__) {
          window.STX.destroyComponent(node.__stx_instance__);
        }
      });
    });
  });

  // Start observing when DOM is ready
  if (document.readyState === 'loading') {
    document.addEventListener('DOMContentLoaded', function() {
      observer.observe(document.body, { childList: true, subtree: true });
    });
  }
else {
    observer.observe(document.body, { childList: true, subtree: true });
  }

  console.log('[stx] Lifecycle runtime initialized');
})();
`}function T(z){return Symbol(z)}function Yz(z,G){(B.length>0?B[B.length-1]:E).set(z,G)}function Zz(z,G){for(let H=B.length-1;H>=0;H--){let J=B[H];if(J.has(z))return J.get(z)}if(E.has(z))return E.get(z);if(arguments.length>1)return G;console.warn(`[stx] Injection "${String(z)}" not found.`);return}function d(){B.push(new Map)}function c(){B.pop()}async function _z(z){d();try{return await z()}finally{c()}}function $z(){E.clear(),B.length=0}var P=null,j,m=0,o,i,a,E,B,Rz,qz,Bz;var b=V(()=>{j=new Map;o=A,i=_,a=g;E=new Map,B=[];Rz=T("theme"),qz=T("router"),Bz=T("i18n")});b();function U(z){return typeof z==="object"&&z!==null&&"value"in z?z.value:z}function Kz(z,G){let H=typeof window<"u"?window.localStorage:null;function J(){if(!H)return G;try{let Z=H.getItem(z);return Z?JSON.parse(Z):G}catch{return G}}function X(Z){if(!H)return;try{H.setItem(z,JSON.stringify(Z))}catch($){console.warn(`[useLocalStorage] Failed to save "${z}":`,$)}}let Y=J();return{get value(){return Y},set value(Z){Y=Z,X(Z)},remove(){H?.removeItem(z),Y=G}}}function Wz(z,G){let H=typeof window<"u"?window.sessionStorage:null;function J(){if(!H)return G;try{let Z=H.getItem(z);return Z?JSON.parse(Z):G}catch{return G}}function X(Z){if(!H)return;try{H.setItem(z,JSON.stringify(Z))}catch($){console.warn(`[useSessionStorage] Failed to save "${z}":`,$)}}let Y=J();return{get value(){return Y},set value(Z){Y=Z,X(Z)},remove(){H?.removeItem(z),Y=G}}}function W(...z){let G,H,J,X;if(typeof z[0]==="string")G=typeof window<"u"?window:null,H=z[0],J=z[1],X=z[2];else G=U(z[0]),H=z[1],J=z[2],X=z[3];let Y=()=>{G?.removeEventListener(H,J,X)};if(G)G.addEventListener(H,J,X),_(Y);return Y}function Oz(z,G){return W(document,"click",(J)=>{let X=U(z);if(!X||X.contains(J.target))return;G(J)})}function Pz(){let z=typeof window<"u"?window.innerWidth:0,G=typeof window<"u"?window.innerHeight:0;if(typeof window<"u")W("resize",()=>{z=window.innerWidth,G=window.innerHeight});return{width:{get value(){return z}},height:{get value(){return G}}}}function O(z){if(typeof window>"u")return{value:!1};let G=window.matchMedia(z),H=G.matches,J=(X)=>{H=X.matches};return G.addEventListener("change",J),_(()=>G.removeEventListener("change",J)),{get value(){return H}}}function Ez(){return{isMobile:O("(max-width: 639px)"),isTablet:O("(min-width: 640px) and (max-width: 1023px)"),isDesktop:O("(min-width: 1024px)"),isLargeDesktop:O("(min-width: 1280px)")}}function Az(){return O("(prefers-color-scheme: dark)")}function Fz(){let z=typeof navigator<"u"?navigator.onLine:!0;if(typeof window<"u")W("online",()=>{z=!0}),W("offline",()=>{z=!1});return{get value(){return z}}}function Mz(){let z=0,G=0;if(typeof window<"u")W("mousemove",(H)=>{z=H.clientX,G=H.clientY});return{x:{get value(){return z}},y:{get value(){return G}}}}function Qz(z){let G=0,H=0,J=!1,X=null,Y=z?U(z):typeof window<"u"?window:null;if(Y){let Z=()=>{if(Y===window)G=window.scrollX,H=window.scrollY;else if(Y instanceof HTMLElement)G=Y.scrollLeft,H=Y.scrollTop;if(J=!0,X)clearTimeout(X);X=setTimeout(()=>{J=!1},150)};if(Y===window)W("scroll",Z);else Y.addEventListener("scroll",Z),_(()=>Y.removeEventListener("scroll",Z))}return{x:{get value(){return G}},y:{get value(){return H}},isScrolling:{get value(){return J}}}}function Tz(z,G){let H=null,J=(...X)=>{if(H)clearTimeout(H);H=setTimeout(()=>z(...X),G)};return _(()=>{if(H)clearTimeout(H)}),J}function Lz(z,G){let H=z(),J=null,Y=setInterval(()=>{if(J)clearTimeout(J);J=setTimeout(()=>{H=z()},G)},16);return _(()=>{if(clearInterval(Y),J)clearTimeout(J)}),{get value(){return H}}}function Sz(z,G){let H=0,J=null,X=(...Y)=>{let Z=Date.now();if(Z-H>=G)H=Z,z(...Y);else{if(J)clearTimeout(J);J=setTimeout(()=>{H=Date.now(),z(...Y)},G-(Z-H))}};return _(()=>{if(J)clearTimeout(J)}),X}function Dz(z,G={}){let H=0,J=G.immediate!==!1,X=null,Y=()=>{if(X)return;X=setInterval(()=>{if(J)H++},z)},Z=()=>{J=!1},$=()=>{J=!0},R=()=>{H=0};if(typeof window<"u")Y(),_(()=>{if(X)clearInterval(X)});return{counter:{get value(){return H}},pause:Z,resume:$,reset:R}}function jz(z,G){let H=!1,J=null,X=()=>{Y(),H=!0,J=setTimeout(()=>{H=!1,z()},G)},Y=()=>{if(J)clearTimeout(J),J=null;H=!1};return _(Y),{isPending:{get value(){return H}},start:X,stop:Y}}function bz(z=!1){let G=z;return[{get value(){return G},set value(X){G=X}},()=>{G=!G},(X)=>{G=X}]}function Cz(z=0,G={}){let H=z,J=(X)=>{if(G.min!==void 0&&X<G.min)return G.min;if(G.max!==void 0&&X>G.max)return G.max;return X};return{count:{get value(){return H},set value(X){H=J(X)}},inc:(X=1)=>{H=J(H+X)},dec:(X=1)=>{H=J(H-X)},set:(X)=>{H=J(X)},reset:()=>{H=z}}}function xz(){let z="",G=!1,H=null,J=async(Y)=>{if(typeof navigator>"u"||!navigator.clipboard){console.warn("[useClipboard] Clipboard API not available");return}try{if(await navigator.clipboard.writeText(Y),z=Y,G=!0,H)clearTimeout(H);H=setTimeout(()=>{G=!1},1500)}catch(Z){console.error("[useClipboard] Failed to copy:",Z)}},X=async()=>{if(typeof navigator>"u"||!navigator.clipboard)return"";try{return z=await navigator.clipboard.readText(),z}catch{return""}};return _(()=>{if(H)clearTimeout(H)}),{text:{get value(){return z}},copied:{get value(){return G}},copy:J,read:X}}function wz(z){let G=typeof document<"u"?document.title:z||"";if(z&&typeof document<"u")document.title=z;return{get value(){return G},set value(H){if(G=H,typeof document<"u")document.title=H}}}function hz(z,G={}){let H=!1,J=null,X=()=>{if(J)J.disconnect(),J=null};return A(()=>{let Y=U(z);if(!Y||typeof IntersectionObserver>"u")return;J=new IntersectionObserver(([Z])=>{H=Z.isIntersecting},G),J.observe(Y)}),_(X),{isVisible:{get value(){return H}},stop:X}}function fz(z){let G=!1;return A(()=>{let H=U(z);if(!H)return;let J=()=>{G=!0},X=()=>{G=!1};H.addEventListener("focus",J),H.addEventListener("blur",X),_(()=>{H.removeEventListener("focus",J),H.removeEventListener("blur",X)})}),{isFocused:{get value(){return G}},focus:()=>U(z)?.focus(),blur:()=>U(z)?.blur()}}function kz(z,G={}){let{immediate:H=!0,initialData:J=null,refetch:X,...Y}=G,Z=J,$=null,R=!1,q=null,K=async()=>{let C=typeof z==="function"?z():z;q?.abort(),q=new AbortController,R=!0,$=null;try{let N=await fetch(C,{...Y,signal:q.signal});if(!N.ok)throw Error(`HTTP ${N.status}: ${N.statusText}`);Z=await N.json()}catch(N){if(N.name!=="AbortError")$=N}finally{R=!1}},L=()=>{q?.abort()};if(H&&typeof window<"u")K();return _(L),{data:{get value(){return Z}},error:{get value(){return $}},isLoading:{get value(){return R}},execute:K,abort:L}}function Iz(z,G={}){let H=null,J=!1,X=null,Y=async()=>{J=!0,X=null;try{return H=await z(),H}catch(Z){return X=Z,null}finally{J=!1}};if(G.immediate!==!1&&typeof window<"u")Y();return{state:{get value(){return H}},isLoading:{get value(){return J}},error:{get value(){return X}},execute:Y}}export{Pz as useWindowSize,bz as useToggle,wz as useTitle,jz as useTimeout,Sz as useThrottle,Wz as useSessionStorage,Qz as useScroll,Az as usePrefersDark,Fz as useOnline,Mz as useMouse,O as useMediaQuery,Kz as useLocalStorage,Dz as useInterval,hz as useIntersectionObserver,fz as useFocus,kz as useFetch,W as useEventListener,Lz as useDebouncedValue,Tz as useDebounce,Cz as useCounter,xz as useClipboard,Oz as useClickOutside,Ez as useBreakpoints,Iz as useAsync};
