import { createCloudflareApi } from "./api.js";
import { findVpcServiceByName, getService, } from "./vpc-service.js";
/**
 * Reference an existing [VPC Service](https://developers.cloudflare.com/workers-vpc/configuration/vpc-services/) without managing its lifecycle.
 *
 * @example
 * ```ts
 * // Reference by ID
 * const vpcService = await VpcServiceRef({
 *   serviceId: "123e4567-e89b-12d3-a456-426614174000",
 * });
 * ```
 *
 * @example
 * ```ts
 * // Reference by name
 * const vpcService = await VpcServiceRef({
 *   name: "my-vpc-service",
 * });
 * ```
 */
export async function VpcServiceRef(props) {
    const api = await createCloudflareApi(props);
    if ("name" in props) {
        const service = await findVpcServiceByName(api, props.name);
        if (!service) {
            throw new Error(`VPC service "${props.name}" not found`);
        }
        return service;
    }
    return await getService(api, props.serviceId);
}
//# sourceMappingURL=vpc-service-ref.js.map