import { Resource } from "../resource.js";
import { DockerApi } from "./api.js";
/**
 * Create or reference a Docker Remote Image
 *
 * @example
 * // Pull the nginx image
 * const nginxImage = await RemoteImage("nginx", {
 *   name: "nginx",
 *   tag: "latest"
 * });
 *
 */
export const RemoteImage = Resource("docker::RemoteImage", async function (_id, props) {
    // Initialize Docker API client
    const api = new DockerApi();
    if (this.phase === "delete") {
        // No action needed for delete as Docker images aren't automatically removed
        // This is intentional as other resources might depend on the same image
        return this.destroy();
    }
    else {
        // Normalize properties
        const tag = props.tag || "latest";
        const imageRef = `${props.name}:${tag}`;
        // Pull image
        await api.pullImage(imageRef);
        return {
            kind: "RemoteImage",
            ...props,
            imageRef,
            tag,
            createdAt: Date.now(),
        };
    }
});
//# sourceMappingURL=remote-image.js.map