'use client' import { type ComponentProps, createContext, useContext } from 'react' import { ChevronsUpDownIcon } from 'lucide-react' import { useTranslation } from 'react-i18next' import { cn } from '@/lib/utils' import { Button } from '@/components/ui/button' import { Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, } from '@/components/ui/card' import { Collapsible, CollapsibleContent, CollapsibleTrigger, } from '@/components/ui/collapsible' import { Shimmer } from './shimmer' type PlanContextValue = { isStreaming: boolean } const PlanContext = createContext(null) const usePlan = () => { const context = useContext(PlanContext) if (!context) { throw new Error('Plan components must be used within Plan') } return context } export type PlanProps = ComponentProps & { isStreaming?: boolean } export const Plan = ({ className, isStreaming = false, children, ...props }: PlanProps) => ( {children} ) export type PlanHeaderProps = ComponentProps export const PlanHeader = ({ className, ...props }: PlanHeaderProps) => ( ) export type PlanTitleProps = Omit< ComponentProps, 'children' > & { children: string } export const PlanTitle = ({ children, ...props }: PlanTitleProps) => { const { isStreaming } = usePlan() return ( {isStreaming ? {children} : children} ) } export type PlanDescriptionProps = Omit< ComponentProps, 'children' > & { children: string } export const PlanDescription = ({ className, children, ...props }: PlanDescriptionProps) => { const { isStreaming } = usePlan() return ( {isStreaming ? {children} : children} ) } export type PlanActionProps = ComponentProps export const PlanAction = (props: PlanActionProps) => ( ) export type PlanContentProps = ComponentProps export const PlanContent = (props: PlanContentProps) => ( ) export type PlanFooterProps = ComponentProps<'div'> export const PlanFooter = (props: PlanFooterProps) => ( ) export type PlanTriggerProps = ComponentProps export const PlanTrigger = ({ className, ...props }: PlanTriggerProps) => { const { t } = useTranslation() return ( ) }