// @bun
var{defineProperty:W,getOwnPropertyNames:w,getOwnPropertyDescriptor:A}=Object,H=Object.prototype.hasOwnProperty;function L(q){return this[q]}var V=(q)=>{var z=(X??=new WeakMap).get(q),B;if(z)return z;if(z=W({},"__esModule",{value:!0}),q&&typeof q==="object"||typeof q==="function"){for(var D of w(q))if(!H.call(z,D))W(z,D,{get:L.bind(q,D),enumerable:!(B=A(q,D))||B.enumerable})}return X.set(q,z),z},X;var M=(q)=>q;function O(q,z){this[q]=M.bind(null,z)}var b=(q,z)=>{for(var B in z)W(q,B,{get:z[B],enumerable:!0,configurable:!0,set:O.bind(z,B)})};var Y=(q,z)=>()=>(q&&(z=q(q=0)),z);var S=import.meta.require;function G(){return`stx-${++j}`}function P(q=null){return{scopeId:G(),parent:q,provides:new Map(q?.provides),exposed:null,refs:{},props:{},attrs:{},slots:{},emit:()=>{},el:null,errorCapturedHooks:[],isMounted:!1}}function x(q){if(q)Q.push(q);else if(Q.length>0)Q.pop();F=q||Q[Q.length-1]||null}function C(){return F}function I(){F=null,Q.length=0}function m(q,z){if(F)F.provides.set(q,z);else R.set(q,z)}function f(q,z){let B=F;while(B){if(B.provides.has(q))return B.provides.get(q);B=B.parent}if(R.has(q))return R.get(q);return z}function Z(q,z){R.set(q,z)}function v(q){let z=F,B=(D,...J)=>{if(typeof document>"u")return;if(z?.el)z.el.dispatchEvent(new CustomEvent(D,{detail:J.length===1?J[0]:J,bubbles:!0,cancelable:!0}))};if(z)z.emit=B;return B}function y(q){if(F)F.exposed=q}function g(q){let z=Promise.resolve();return q?z.then(q):z}function k(q){if(F)F.errorCapturedHooks.push(q)}function d(q,z,B){let D=z?.parent;while(D){for(let J of D.errorCapturedHooks)if(J(q,z,B)===!1)return;D=D.parent}}function u(){return F?.slots??{}}function l(){return F?.slots??{}}function p(){return F?.attrs??{}}function c(q){let z=q.__provides?new Map(Object.entries(q.__provides)):new Map;return{...q,__provides:z,__provide(B,D){z.set(B,D)},__inject(B,D){if(z.has(B))return z.get(B);if(q.__provides){let J=q.__provides instanceof Map?q.__provides:new Map(Object.entries(q.__provides));if(J.has(B))return J.get(B)}return D}}}function o(){return`
// STX Composition API Runtime
(function() {
  const _provides = new Map();
  const _scopes = window.__stx_scopes || (window.__stx_scopes = {});
  const _exposed = window.__stx_exposed || (window.__stx_exposed = {});

  // provide() stores values in the nearest scope's provide map
  window.__stx_provide = function(key, value) {
    _provides.set(key, value);
  };

  // inject() walks up DOM ancestors with data-stx-scope to find provided values
  window.__stx_inject = function(key, defaultValue, el) {
    // Walk up the DOM tree
    let current = el ? el.closest('[data-stx-scope]') : null;
    while (current) {
      const scopeId = current.getAttribute('data-stx-scope');
      const scope = _scopes[scopeId];
      if (scope && scope.__provided && scope.__provided.has(key)) {
        return scope.__provided.get(key);
      }
      current = current.parentElement ? current.parentElement.closest('[data-stx-scope]') : null;
    }
    // Check global provides
    if (_provides.has(key)) return _provides.get(key);
    return defaultValue;
  };

  // defineEmits() returns an emit function
  window.__stx_defineEmits = function(scopeId) {
    return function emit(event, ...args) {
      const el = document.querySelector('[data-stx-scope="' + scopeId + '"]');
      if (el) {
        el.dispatchEvent(new CustomEvent(event, {
          detail: args.length === 1 ? args[0] : args,
          bubbles: true,
          cancelable: true
        }));
      }
    };
  };

  // defineExpose() registers exposed properties
  window.__stx_defineExpose = function(scopeId, exposed) {
    _exposed[scopeId] = exposed;
  };

  // nextTick()
  window.__stx_nextTick = function(fn) {
    return Promise.resolve().then(fn);
  };

  // Template ref resolution
  window.__stx_resolveRefs = function(scopeId) {
    const scope = document.querySelector('[data-stx-scope="' + scopeId + '"]');
    if (!scope) return {};
    const refs = {};
    // eslint-disable-next-line pickier/no-unused-vars
    scope.querySelectorAll('[data-stx-ref]').forEach(function(el) {
      refs[el.getAttribute('data-stx-ref')] = el;
    });
    return refs;
  };
})();
`}var F=null,Q,j=0,R;var _=Y(()=>{Q=[];R=new Map});function i(q,z){let B=new Set,D=new Map,J=new Map,U={globalProperties:{},performance:!1,compilerOptions:{}},N={config:U,_components:D,_directives:J,_installedPlugins:B,use(E,...K){if(B.has(E))return N;if(B.add(E),typeof E==="function")E(N,...K);else if(typeof E.install==="function")E.install(N,...K);return N},provide(E,K){return Z(E,K),N},component(E,K){if(!K)return D.get(E);return D.set(E,K),N},directive(E,K){if(!K)return J.get(E);return J.set(E,K),N},mount(E){if(typeof document<"u"){let K=globalThis.__stx_globals||(globalThis.__stx_globals={});Object.assign(K,U.globalProperties),document.querySelectorAll("[v-cloak]").forEach(($)=>{$.removeAttribute("v-cloak")})}return N},unmount(){D.clear(),J.clear(),B.clear()}};return N}function a(q){return class extends HTMLElement{_component;_shadow;constructor(){super();this._shadow=this.attachShadow({mode:"open"}),this._component=q}connectedCallback(){if(this._component?.render){let z=this._component.render();if(typeof z==="string")this._shadow.innerHTML=z}else if(this._component?.template)this._shadow.innerHTML=this._component.template;else if(typeof this._component==="string")this._shadow.innerHTML=this._component}disconnectedCallback(){this._shadow.innerHTML=""}}}var T=Y(()=>{_()});T();export{a as defineCustomElement,i as createApp};
