"use client";
import { useStigmer } from "../hooks";
import { useFetch } from "../internal/useFetch";
/**
 * Data hook that fetches an aggregated billing usage report for a date range.
 *
 * Returns total provider cost, total billable amount, execution and LLM
 * call counts, and a per-model breakdown with cost tier attribution.
 *
 * Pass `null` as `orgId` to skip fetching (stable no-op).
 *
 * @param orgId - Organization ID, or `null` to skip.
 * @param startTime - Start of the reporting period.
 * @param endTime - End of the reporting period.
 *
 * @example
 * ```tsx
 * const { report, isLoading } = useBillingUsageReport(
 *   orgId,
 *   new Date("2026-05-01"),
 *   new Date("2026-05-31"),
 * );
 *
 * if (isLoading) return <Skeleton />;
 * if (!report) return null;
 *
 * return <div>Total: {formatCreditBalance(report.totalBillableAmountMicros)}</div>;
 * ```
 */
export function useBillingUsageReport(orgId, startTime, endTime) {
    const stigmer = useStigmer();
    const startKey = startTime.toISOString();
    const endKey = endTime.toISOString();
    const { data: report, isLoading, isRefetching, error, refetch } = useFetch(orgId
        ? () => stigmer.billing.getBillingUsageReport({
            orgId,
            startTime,
            endTime,
        })
        : null, [orgId, startKey, endKey, stigmer], null);
    return { report, isLoading, isRefetching, error, refetch };
}
//# sourceMappingURL=useBillingUsageReport.js.map