// @bun
var{defineProperty:B,getOwnPropertyNames:F,getOwnPropertyDescriptor:G}=Object,H=Object.prototype.hasOwnProperty;function I(j){return this[j]}var O=(j)=>{var q=(D??=new WeakMap).get(j),w;if(q)return q;if(q=B({},"__esModule",{value:!0}),j&&typeof j==="object"||typeof j==="function"){for(var y of F(j))if(!H.call(q,y))B(q,y,{get:I.bind(j,y),enumerable:!(w=G(j,y))||w.enumerable})}return D.set(j,q),q},D;var J=(j)=>j;function K(j,q){this[j]=J.bind(null,q)}var Q=(j,q)=>{for(var w in q)B(j,w,{get:q[w],enumerable:!0,configurable:!0,set:K.bind(q,w)})};var S=(j,q)=>()=>(j&&(q=j(j=0)),q);var T=import.meta.require;function V(){return`<script data-stx-hydration-runtime>
(function() {
  'use strict';

  var stxIslands = window.__stxIslands = window.__stxIslands || {
    _registry: {},
    _hydrated: new Set(),

    register: function(name, loader) {
      this._registry[name] = loader;
    },

    hydrateIsland: function(el) {
      var id = el.getAttribute('data-island');
      if (!id || this._hydrated.has(id)) return Promise.resolve();
      this._hydrated.add(id);

      var componentName = el.getAttribute('data-component');
      var propsScript = el.querySelector('script[data-island-props="' + id + '"]');
      var props = {};
      if (propsScript) {
        try { props = JSON.parse(propsScript.textContent || '{}'); }
catch (e) {}
      }

      var loader = componentName ? this._registry[componentName] : null;

      if (loader) {
        return Promise.resolve(typeof loader === 'function' ? loader() : loader)
          .then(function(mod) {
            var comp = mod && mod.default ? mod.default : mod;
            if (comp && comp.hydrate) {
              return comp.hydrate(el, props);
            }
else if (comp && comp.mount) {
              return comp.mount(el, props);
            }
          })
          .then(function() {
            el.classList.add('hydrated');
            el.dispatchEvent(new CustomEvent('stx:hydrated', { bubbles: true }));
          })
          .catch(function(err) {
            console.error('[stx] Hydration failed for island:', id, err);
            el.classList.add('hydrated');
            el.dispatchEvent(new CustomEvent('stx:hydrated', { bubbles: true }));
          });
      }

      // No loader registered \u2014 just mark as hydrated (CSS-only island)
      el.classList.add('hydrated');
      el.dispatchEvent(new CustomEvent('stx:hydrated', { bubbles: true }));
      return Promise.resolve();
    },

    _setupStrategy: function(el) {
      var self = this;
      var strategy = el.getAttribute('data-strategy') || 'load';

      switch (strategy) {
        case 'load':
          self.hydrateIsland(el);
          break;

        case 'idle':
          if ('requestIdleCallback' in window) {
            requestIdleCallback(function() { self.hydrateIsland(el); }, { timeout: 2000 });
          }
else {
            setTimeout(function() { self.hydrateIsland(el); }, 200);
          }
          break;

        case 'visible':
          if ('IntersectionObserver' in window) {
            var rootMargin = el.getAttribute('data-root-margin') || '0px';
            var threshold = parseFloat(el.getAttribute('data-threshold') || '0') || 0;
            var obs = new IntersectionObserver(function(entries) {
              entries.forEach(function(entry) {
                if (entry.isIntersecting) {
                  obs.disconnect();
                  self.hydrateIsland(el);
                }
              });
            }, { rootMargin: rootMargin, threshold: threshold });
            obs.observe(el);
          }
else {
            self.hydrateIsland(el);
          }
          break;

        case 'media':
          var mediaQuery = el.getAttribute('data-media') || '(min-width: 768px)';
          var mq = window.matchMedia(mediaQuery);
          if (mq.matches) {
            self.hydrateIsland(el);
          }
else {
            var handler = function(e) {
              if (e.matches) {
                mq.removeEventListener('change', handler);
                self.hydrateIsland(el);
              }
            };
            mq.addEventListener('change', handler);
          }
          break;

        case 'hover':
          var events = ['mouseenter', 'focusin', 'touchstart'];
          var hoverHandler = function() {
            events.forEach(function(e) { el.removeEventListener(e, hoverHandler); });
            self.hydrateIsland(el);
          };
          events.forEach(function(e) {
            el.addEventListener(e, hoverHandler, { once: true, passive: true });
          });
          break;

        case 'event':
          var eventName = el.getAttribute('data-event') || 'stx:activate';
          window.addEventListener(eventName, function evtHandler(e) {
            if (!e.detail || e.detail.id === el.getAttribute('data-island') || e.detail.id === '*') {
              window.removeEventListener(eventName, evtHandler);
              self.hydrateIsland(el);
            }
          });
          break;

        case 'only':
          var tmpl = el.querySelector('template[data-client-content]');
          if (tmpl) {
            el.innerHTML = tmpl.innerHTML;
          }
          el.classList.add('hydrated');
          break;

        default:
          self.hydrateIsland(el);
      }
    },

    initIslands: function() {
      var self = this;
      var islands = document.querySelectorAll('.stx-island:not(.hydrated)');
      islands.forEach(function(el) {
        self._setupStrategy(el);
      });
    }
  };

  // Auto-init on DOMContentLoaded
  if (document.readyState === 'loading') {
    document.addEventListener('DOMContentLoaded', function() { stxIslands.initIslands(); });
  }
else {
    stxIslands.initIslands();
  }
})();
</script>`}function W(j){if(j.size===0)return"";return`<script data-stx-island-manifest>
(function() {
  if (!window.__stxIslands) return;
${Array.from(j.entries()).map(([w,y])=>`  window.__stxIslands.register('${w}', function() { return import('${y}'); });`).join(`
`)}
})();
</script>`}function X(j){let q=j.match(/<([A-Z][a-zA-Z0-9]+)[\s/>]/);if(q)return q[1];let w=j.match(/<([a-z][a-z0-9]*-[a-z0-9-]+)[\s/>]/);if(w)return w[1];return null}function Y(j,q){let w={},y=/:([a-zA-Z_][\w-]*)\s*=\s*"([^"]+)"/g,z;while((z=y.exec(j))!==null){let C=z[1],A=z[2];if(A in q)w[C]=q[A];else w[C]=A}return w}export{V as generateHydrationBootstrap,W as generateComponentManifest,X as extractComponentName,Y as extractBoundProps};
