// @bun
var __create = Object.create;
var __getProtoOf = Object.getPrototypeOf;
var __defProp = Object.defineProperty;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __hasOwnProp = Object.prototype.hasOwnProperty;
function __accessProp(key) {
  return this[key];
}
var __toESMCache_node;
var __toESMCache_esm;
var __toESM = (mod, isNodeMode, target) => {
  var canCache = mod != null && typeof mod === "object";
  if (canCache) {
    var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
    var cached = cache.get(mod);
    if (cached)
      return cached;
  }
  target = mod != null ? __create(__getProtoOf(mod)) : {};
  const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
  for (let key of __getOwnPropNames(mod))
    if (!__hasOwnProp.call(to, key))
      __defProp(to, key, {
        get: __accessProp.bind(mod, key),
        enumerable: true
      });
  if (canCache)
    cache.set(mod, to);
  return to;
};
var __toCommonJS = (from) => {
  var entry = (__moduleCache ??= new WeakMap).get(from), desc;
  if (entry)
    return entry;
  entry = __defProp({}, "__esModule", { value: true });
  if (from && typeof from === "object" || typeof from === "function") {
    for (var key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(entry, key))
        __defProp(entry, key, {
          get: __accessProp.bind(from, key),
          enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
        });
  }
  __moduleCache.set(from, entry);
  return entry;
};
var __moduleCache;
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
var __returnValue = (v) => v;
function __exportSetter(name, newValue) {
  this[name] = __returnValue.bind(null, newValue);
}
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, {
      get: all[name],
      enumerable: true,
      configurable: true,
      set: __exportSetter.bind(all, name)
    });
};
var __legacyDecorateClassTS = function(decorators, target, key, desc) {
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
    r = Reflect.decorate(decorators, target, key, desc);
  else
    for (var i = decorators.length - 1;i >= 0; i--)
      if (d = decorators[i])
        r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __legacyMetadataTS = (k, v) => {
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
    return Reflect.metadata(k, v);
};
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
var __require = import.meta.require;

// src/core/streamingSlotRegistrar.ts
var STREAMING_SLOT_REGISTRAR_KEY = Symbol.for("absolutejs.streamingSlotRegistrar");
var getRegistrarGlobal = () => globalThis;
var setStreamingSlotRegistrar = (nextRegistrar) => {
  getRegistrarGlobal()[STREAMING_SLOT_REGISTRAR_KEY] = nextRegistrar;
};
var registerStreamingSlot = (slot) => {
  getRegistrarGlobal()[STREAMING_SLOT_REGISTRAR_KEY]?.(slot);
};

// src/vue/components/Image.vue
var Image_default = "../../Image-0pe96k20.vue";
// src/vue/components/SuspenseSlot.ts
import {
  defineComponent,
  h
} from "vue";
var renderVueNodesToHtml = async (nodes) => {
  const { createSSRApp, h: createVNode } = await import("vue");
  const { renderToString } = await import("vue/server-renderer");
  const app = createSSRApp({
    render: () => createVNode("div", undefined, nodes ?? undefined)
  });
  const html = await renderToString(app);
  return html.replace(/^<div>|<\/div>$/g, "");
};
var hasFrameworkSlots = (defaultSlot, fallbackSlot, errorSlot, promise) => defaultSlot !== undefined || fallbackSlot !== undefined || errorSlot !== undefined || promise !== undefined;
var SuspenseSlot = defineComponent({
  name: "AbsoluteSuspenseSlot",
  props: {
    className: { default: undefined, type: String },
    errorHtml: { default: undefined, type: String },
    fallbackHtml: { default: "", type: String },
    id: { required: true, type: String },
    promise: {
      default: undefined,
      type: Object
    },
    resolve: {
      default: undefined,
      type: Function
    },
    timeoutMs: { default: undefined, type: Number }
  },
  setup(props, { slots }) {
    const usesFrameworkSlots = hasFrameworkSlots(slots.default, slots.fallback, slots.error, props.promise);
    if (typeof window === "undefined") {
      if (!usesFrameworkSlots && props.resolve) {
        registerStreamingSlot({
          errorHtml: props.errorHtml,
          fallbackHtml: props.fallbackHtml,
          id: props.id,
          resolve: props.resolve,
          timeoutMs: props.timeoutMs
        });
      } else {
        registerStreamingSlot({
          id: props.id,
          resolve: async () => {
            try {
              const value = props.resolve !== undefined ? await props.resolve() : props.promise !== undefined ? await props.promise : undefined;
              const nodes = slots.default?.({ value }) ?? [];
              return renderVueNodesToHtml(nodes);
            } catch (error) {
              const errorNodes = slots.error?.({ error });
              if (errorNodes !== undefined) {
                return renderVueNodesToHtml(errorNodes);
              }
              if (typeof props.errorHtml === "string") {
                return props.errorHtml;
              }
              throw error;
            }
          },
          timeoutMs: props.timeoutMs
        });
      }
    }
    return () => {
      if (!usesFrameworkSlots) {
        return h("div", {
          class: props.className,
          "data-absolute-slot": "true",
          id: `slot-${props.id}`,
          innerHTML: props.fallbackHtml
        });
      }
      return h("div", {
        class: props.className,
        "data-absolute-slot": "true",
        id: `slot-${props.id}`
      }, slots.fallback?.() ?? undefined);
    };
  }
});
// src/vue/components/StreamSlot.ts
import { defineComponent as defineComponent2, h as h2 } from "vue";
var StreamSlot = defineComponent2({
  name: "AbsoluteStreamSlot",
  props: {
    className: { default: undefined, type: String },
    errorHtml: { default: undefined, type: String },
    fallbackHtml: { default: "", type: String },
    id: { required: true, type: String },
    resolve: {
      required: true,
      type: Function
    },
    timeoutMs: { default: undefined, type: Number }
  },
  setup(props) {
    if (typeof window === "undefined") {
      registerStreamingSlot({
        errorHtml: props.errorHtml,
        fallbackHtml: props.fallbackHtml,
        id: props.id,
        resolve: props.resolve,
        timeoutMs: props.timeoutMs
      });
    }
    return () => h2("div", {
      class: props.className,
      "data-absolute-slot": "true",
      id: `slot-${props.id}`,
      innerHTML: props.fallbackHtml
    });
  }
});
export {
  SuspenseSlot,
  StreamSlot,
  Image_default as Image
};

//# debugId=A7B4FCB6CBD7CC9D64756E2164756E21
//# sourceMappingURL=index.js.map
