'use client';
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import React from 'react';
import { cn } from '@/lib/utils';
export function ParamField({ path, name, type, required = false, deprecated = false, default: defaultValue, placeholder, children, className }) {
    const paramName = name || path?.split('.').pop() || 'param';
    const paramPath = path || name;
    return /*#__PURE__*/ _jsxs("div", {
        className: cn('py-4 border-b border-border last:border-0', deprecated && 'opacity-60', className),
        children: [
            /*#__PURE__*/ _jsxs("div", {
                className: "flex flex-wrap items-baseline gap-2 mb-1",
                children: [
                    /*#__PURE__*/ _jsx("code", {
                        className: "text-sm font-semibold text-foreground",
                        children: paramName
                    }),
                    type && /*#__PURE__*/ _jsx("span", {
                        className: "text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground font-mono",
                        children: type
                    }),
                    required && /*#__PURE__*/ _jsx("span", {
                        className: "text-xs px-1.5 py-0.5 rounded bg-red-500/10 text-red-600 dark:text-red-400 font-medium",
                        children: "required"
                    }),
                    deprecated && /*#__PURE__*/ _jsx("span", {
                        className: "text-xs px-1.5 py-0.5 rounded bg-amber-500/10 text-amber-600 dark:text-amber-400 font-medium",
                        children: "deprecated"
                    })
                ]
            }),
            paramPath && paramPath !== paramName && /*#__PURE__*/ _jsx("div", {
                className: "text-xs text-muted-foreground mb-2 font-mono",
                children: paramPath
            }),
            defaultValue && /*#__PURE__*/ _jsxs("div", {
                className: "text-xs text-muted-foreground mb-2",
                children: [
                    "Default: ",
                    /*#__PURE__*/ _jsx("code", {
                        className: "bg-muted px-1 py-0.5 rounded",
                        children: defaultValue
                    })
                ]
            }),
            placeholder && /*#__PURE__*/ _jsxs("div", {
                className: "text-xs text-muted-foreground mb-2",
                children: [
                    "Example: ",
                    /*#__PURE__*/ _jsx("code", {
                        className: "bg-muted px-1 py-0.5 rounded",
                        children: placeholder
                    })
                ]
            }),
            children && /*#__PURE__*/ _jsx("div", {
                className: "text-sm text-foreground/90 [&>p]:mb-2 [&>p:last-child]:mb-0",
                children: children
            })
        ]
    });
}
export function ResponseField({ name, type, required = false, children, className }) {
    return /*#__PURE__*/ _jsxs("div", {
        className: cn('py-4 border-b border-border last:border-0', className),
        children: [
            /*#__PURE__*/ _jsxs("div", {
                className: "flex flex-wrap items-baseline gap-2 mb-1",
                children: [
                    /*#__PURE__*/ _jsx("code", {
                        className: "text-sm font-semibold text-foreground",
                        children: name
                    }),
                    type && /*#__PURE__*/ _jsx("span", {
                        className: "text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground font-mono",
                        children: type
                    }),
                    required && /*#__PURE__*/ _jsx("span", {
                        className: "text-xs px-1.5 py-0.5 rounded bg-green-500/10 text-green-600 dark:text-green-400 font-medium",
                        children: "always present"
                    })
                ]
            }),
            children && /*#__PURE__*/ _jsx("div", {
                className: "text-sm text-foreground/90 [&>p]:mb-2 [&>p:last-child]:mb-0",
                children: children
            })
        ]
    });
}
export function Expandable({ title = 'Show child attributes', defaultOpen = false, children, className }) {
    const [isOpen, setIsOpen] = React.useState(defaultOpen);
    return /*#__PURE__*/ _jsxs("div", {
        className: cn('mt-2 ml-4 border-l-2 border-border', className),
        children: [
            /*#__PURE__*/ _jsxs("button", {
                type: "button",
                onClick: ()=>setIsOpen(!isOpen),
                className: "text-xs text-primary hover:text-primary/80 transition-colors pl-3 py-1",
                children: [
                    isOpen ? 'Hide' : 'Show',
                    " ",
                    title.replace('Show ', '').replace('Hide ', '')
                ]
            }),
            isOpen && /*#__PURE__*/ _jsx("div", {
                className: "pl-4 pt-2",
                children: children
            })
        ]
    });
}
