// -- Implementation ---------------------------------------------------------
export function Prerender(handlerOrGetParams, handlerOrOptions, optionsOrId, maybeId) {
    // Resolve overloads:
    // 1 fn arg:  Prerender(handler, options?, __injectedId?)
    // 2 fn args: Prerender(getParams, handler, options?, __injectedId?)
    let handler;
    let getParams;
    let options;
    let id;
    if (typeof handlerOrOptions === "function") {
        // Two function args: getParams + handler
        getParams = handlerOrGetParams;
        handler = handlerOrOptions;
        if (typeof optionsOrId === "string") {
            id = optionsOrId;
        }
        else {
            options = optionsOrId;
            id = maybeId ?? "";
        }
    }
    else {
        // Single function arg: handler only
        handler = handlerOrGetParams;
        if (typeof handlerOrOptions === "object" && handlerOrOptions !== null) {
            options = handlerOrOptions;
        }
        if (typeof optionsOrId === "string") {
            id = optionsOrId;
        }
        else {
            id = maybeId ?? "";
        }
    }
    if (!id) {
        throw new Error("[rsc-router] Prerender: missing $$id. " +
            "Ensure the exposeInternalIds Vite plugin is configured.");
    }
    return {
        __brand: "prerenderHandler",
        $$id: id,
        handler,
        ...(getParams ? { getParams } : {}),
        ...(options ? { options } : {}),
    };
}
// -- Type guard -------------------------------------------------------------
/**
 * Type guard to check if a value is a PrerenderHandlerDefinition.
 */
export function isPrerenderHandler(value) {
    return (typeof value === "object" &&
        value !== null &&
        "__brand" in value &&
        value.__brand === "prerenderHandler");
}
//# sourceMappingURL=prerender.js.map