"use client";
import { useMemo } from "react";
import { useWorkflow } from "./useWorkflow.js";
import { serializeWorkflowYaml } from "./serialize-workflow-yaml.js";
/**
 * Data hook that fetches a Workflow and returns its YAML representation.
 *
 * Composes {@link useWorkflow} with {@link serializeWorkflowYaml} to
 * provide a memoized YAML string ready for editor rendering.
 *
 * @param org - Organization slug, or `null` to skip fetching.
 * @param slug - Workflow slug, or `null` to skip fetching.
 *
 * @since T10 (YAML Editor with Graph Preview)
 */
export function useWorkflowYaml(org, slug) {
    const { workflow, isLoading, error, refetch } = useWorkflow(org, slug);
    const yaml = useMemo(() => {
        if (!workflow)
            return null;
        return serializeWorkflowYaml(workflow);
    }, [workflow]);
    const workflowId = workflow?.metadata?.id ?? null;
    return useMemo(() => ({ yaml, isLoading, error, workflowId, refetch }), [yaml, isLoading, error, workflowId, refetch]);
}
//# sourceMappingURL=useWorkflowYaml.js.map