{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "site-github-card",
  "type": "registry:ui",
  "description": "Site github-card component",
  "files": [
    {
      "path": "packages/site/github-card.tsx",
      "content": "\"use client\";\n\nimport { useState } from \"react\";\nimport Head from \"next/head\";\nimport { Avatar, AvatarFallback, AvatarImage } from \"@/components/ui/avatar\";\nimport { Card } from \"@/components/ui/card\";\nimport { Input } from \"@/components/ui/input\";\nimport { Button } from \"@/components/ui/button\";\nimport { Icon } from \"@iconify/react\";\n\ninterface GitHubUser {\n    login: string;\n    name: string;\n    bio: string;\n    avatar_url: string;\n    followers: number;\n    following: number;\n    public_repos: number;\n    html_url: string;\n    email?: string;\n    twitter_username?: string;\n    blog?: string;\n}\n\ninterface ContributionDay {\n    date: string;\n    level: number;\n    count: number;\n}\n\nexport default function GitHubCard() {\n    const [username, setUsername] = useState(\"\");\n    const [userData, setUserData] = useState<GitHubUser | null>(null);\n    const [loading, setLoading] = useState(false);\n    const [error, setError] = useState<string | null>(null);\n\n    // Generate realistic contribution data with proper GitHub-like structure\n    const generateContributions = (): ContributionDay[] => {\n        const contributions: ContributionDay[] = [];\n        const today = new Date();\n        const startDate = new Date(\n            today.getFullYear() - 1,\n            today.getMonth(),\n            today.getDate(),\n        );\n\n        // Start from the Sunday of the week containing startDate\n        const startSunday = new Date(startDate);\n        startSunday.setDate(startDate.getDate() - startDate.getDay());\n\n        for (let i = 0; i < 371; i++) {\n            // ~53 weeks * 7 days\n            const date = new Date(startSunday);\n            date.setDate(startSunday.getDate() + i);\n\n            const dayOfWeek = date.getDay();\n            const isWeekend = dayOfWeek === 0 || dayOfWeek === 6;\n            const baseIntensity = isWeekend ? 0.2 : 0.6;\n            const randomFactor = Math.random();\n            const intensity = baseIntensity * randomFactor;\n\n            let level = 0;\n            let count = 0;\n            if (intensity > 0.7) {\n                level = 4;\n                count = Math.floor(Math.random() * 10) + 10;\n            } else if (intensity > 0.5) {\n                level = 3;\n                count = Math.floor(Math.random() * 8) + 5;\n            } else if (intensity > 0.3) {\n                level = 2;\n                count = Math.floor(Math.random() * 5) + 2;\n            } else if (intensity > 0.1) {\n                level = 1;\n                count = Math.floor(Math.random() * 3) + 1;\n            }\n\n            contributions.push({\n                date: date.toISOString().split(\"T\")[0],\n                level,\n                count,\n            });\n        }\n\n        return contributions;\n    };\n\n    const fetchGitHubUser = async (username: string) => {\n        setLoading(true);\n        setError(null);\n\n        try {\n            const response = await fetch(`https://api.github.com/users/${username}`);\n\n            if (!response.ok) {\n                if (response.status === 404) {\n                    throw new Error(\"User not found\");\n                } else if (response.status === 403) {\n                    throw new Error(\"API rate limit exceeded\");\n                } else {\n                    throw new Error(\"Failed to fetch user data\");\n                }\n            }\n\n            const data: GitHubUser = await response.json();\n            setUserData(data);\n        } catch (err) {\n            setError(err instanceof Error ? err.message : \"An error occurred\");\n            setUserData(null);\n        } finally {\n            setLoading(false);\n        }\n    };\n\n    const handleSearch = () => {\n        if (username.trim()) {\n            fetchGitHubUser(username.trim());\n        }\n    };\n\n    const handleKeyPress = (e: React.KeyboardEvent) => {\n        if (e.key === \"Enter\") {\n            handleSearch();\n        }\n    };\n\n    const contributions = generateContributions();\n\n    const getContributionColor = (level: number) => {\n        // Using CSS custom properties that work with dark mode\n        switch (level) {\n            case 0:\n                return \"rgb(235 237 240 / 1)\"; // light mode\n            case 1:\n                return \"rgb(155 233 168 / 1)\";\n            case 2:\n                return \"rgb(64 196 99 / 1)\";\n            case 3:\n                return \"rgb(48 161 78 / 1)\";\n            case 4:\n                return \"rgb(33 110 57 / 1)\";\n            default:\n                return \"rgb(235 237 240 / 1)\";\n        }\n    };\n\n    const getDarkContributionColor = (level: number) => {\n        switch (level) {\n            case 0:\n                return \"rgb(33 33 33 / 1)\"; // dark mode\n            case 1:\n                return \"rgb(64 64 64 / 1)\";\n            case 2:\n                return \"rgb(96 96 96 / 1)\";\n            case 3:\n                return \"rgb(128 128 128 / 1)\";\n            case 4:\n                return \"rgb(198 198 198 / 1)\";\n            default:\n                return \"rgb(33 33 33 / 1)\";\n        }\n    };\n\n    const formatNumber = (num: number) => {\n        if (num >= 1000) {\n            return (num / 1000).toFixed(1) + \"k\";\n        }\n        return num.toString();\n    };\n\n    const getMonthLabels = () => {\n        const months = [];\n        const today = new Date();\n        for (let i = 11; i >= 0; i--) {\n            const date = new Date(today.getFullYear(), today.getMonth() - i, 1);\n            months.push(date.toLocaleDateString(\"en-US\", { month: \"short\" }));\n        }\n        return months;\n    };\n\n    const organizeContributionsByWeek = () => {\n        const weeks: ContributionDay[][] = [];\n        let currentWeek: ContributionDay[] = [];\n\n        contributions.forEach((day, index) => {\n            currentWeek.push(day);\n            if (currentWeek.length === 7 || index === contributions.length - 1) {\n                weeks.push([...currentWeek]);\n                currentWeek = [];\n            }\n        });\n\n        return weeks;\n    };\n\n    const shareToTwitter = () => {\n        const text = `I have generated my GitHub card from DeDevs UI 🚀\\n\\nGenerate yours: ${window.location.href}\\n\\n#GitHub #DeDevsUI #Developer`;\n        const url = `https://x.com/intent/tweet?text=${encodeURIComponent(text)}`;\n        window.open(url, \"_blank\");\n    };\n\n    const shareToLinkedIn = () => {\n        const text = `I have generated my GitHub card from DeDevs UI — Check out this amazing tool to showcase your GitHub profile.`;\n        const url = `https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent(window.location.href)}&summary=${encodeURIComponent(text)}`;\n        window.open(url, \"_blank\");\n    };\n\n    const copyToClipboard = () => {\n        const text = `I have generated my GitHub card from DeDevs UI — Generate yours: ${window.location.href}`;\n        navigator.clipboard.writeText(text);\n        alert(\"Link copied to clipboard!\");\n    };\n\n    return (\n        <>\n            {/* Open Graph Meta Tags for Social Sharing */}\n            <Head>\n                <title>\n                    {userData\n                        ? `${userData.name || userData.login} - GitHub Profile Card`\n                        : \"GitHub Profile Card Generator\"}\n                </title>\n                <meta\n                    name=\"description\"\n                    content={\n                        userData\n                            ? `Check out ${userData.name || userData.login}'s GitHub profile card with ${userData.public_repos} repositories and ${userData.followers} followers.`\n                            : \"Generate beautiful GitHub profile cards to showcase your coding journey and contributions.\"\n                    }\n                />\n\n                {/* Open Graph Tags */}\n                <meta\n                    property=\"og:title\"\n                    content={\n                        userData\n                            ? `${userData.name || userData.login} - GitHub Profile Card`\n                            : \"GitHub Profile Card Generator\"\n                    }\n                />\n                <meta\n                    property=\"og:description\"\n                    content={\n                        userData\n                            ? `Check out ${userData.name || userData.login}'s GitHub profile card with ${userData.public_repos} repositories and ${userData.followers} followers.`\n                            : \"Generate beautiful GitHub profile cards to showcase your coding journey and contributions.\"\n                    }\n                />\n                <meta property=\"og:image\" content={userData?.avatar_url || \"/og.png\"} />\n                <meta\n                    property=\"og:url\"\n                    content={typeof window !== \"undefined\" ? window.location.href : \"\"}\n                />\n                <meta property=\"og:type\" content=\"website\" />\n                <meta\n                    property=\"og:site_name\"\n                    content=\"DeDevs UI - GitHub Profile Cards\"\n                />\n\n                {/* Twitter Card Tags */}\n                <meta name=\"twitter:card\" content=\"summary_large_image\" />\n                <meta\n                    name=\"twitter:title\"\n                    content={\n                        userData\n                            ? `${userData.name || userData.login} - GitHub Profile Card`\n                            : \"GitHub Profile Card Generator\"\n                    }\n                />\n                <meta\n                    name=\"twitter:description\"\n                    content={\n                        userData\n                            ? `Check out ${userData.name || userData.login}'s GitHub profile card with ${userData.public_repos} repositories and ${userData.followers} followers.`\n                            : \"Generate beautiful GitHub profile cards to showcase your coding journey and contributions.\"\n                    }\n                />\n                <meta\n                    name=\"twitter:image\"\n                    content={userData?.avatar_url || \"/og-image.png\"}\n                />\n\n                <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n                <link\n                    rel=\"canonical\"\n                    href={typeof window !== \"undefined\" ? window.location.href : \"\"}\n                />\n            </Head>\n\n            <div className=\"min-h-full flex flex-col items-center justify-center p-4 space-y-6\">\n                <div className=\"w-full max-w-md flex space-x-2\">\n                    <Input\n                        type=\"text\"\n                        placeholder=\"Enter GitHub username...\"\n                        value={username}\n                        onChange={(e) => setUsername(e.target.value)}\n                        onKeyDown={handleKeyPress}\n                        className=\"bg-background text-text rounded-xl\"\n                    />\n                    <Button\n                        onClick={handleSearch}\n                        disabled={loading || !username.trim()}\n                        className=\"bg-background text-text\"\n                    >\n                        {loading ? (\n                            <Icon icon=\"ri:loader-2-fill animate-spin\" className=\"w-4 h-4 animate-spin\" />\n                        ) : (\n                            <Icon icon=\"ri:search-line\" className=\"w-4 h-4 text-text\" />\n                        )}\n                    </Button>\n                </div>\n\n                {error && (\n                    <div className=\"w-full max-w-md p-4 bg-red-900/20 border border-red-500/30 rounded-lg text-red-400 text-center\">\n                        {error}\n                    </div>\n                )}\n\n                {userData && (\n                    <>\n                        <Card className=\"w-full max-w-md bg-background text-text rounded-3xl p-8 relative overflow-hidden\">\n                            <div className=\"absolute bottom-0 left-0 right-0 h-32 bg-gradient-to-t from-neutral-600/60 via-neutral-400/30 to-transparent dark:from-blue-600/30 dark:via-blue-600/10 dark:to-transparent  rounded-b-3xl\" />\n\n                            <div className=\"relative z-10 flex flex-col items-center space-y-6\">\n                                <Avatar className=\"w-20 h-20 border-2 border-neutral-200 dark:border-neutral-800\">\n                                    <AvatarImage\n                                        src={userData.avatar_url || \"/placeholder.svg\"}\n                                        alt={userData.name || userData.login}\n                                    />\n                                    <AvatarFallback className=\"bg-blue-500 text-white text-xl font-semibold\">\n                                        {(userData.name || userData.login).charAt(0).toUpperCase()}\n                                    </AvatarFallback>\n                                </Avatar>\n\n                                {/* Name and Bio */}\n                                <div className=\"text-center space-y-2\">\n                                    <h1 className=\"text-2xl font-bold text-text\">\n                                        {userData.name || userData.login}\n                                    </h1>\n                                    <p className=\"text-text text-sm max-w-xs\">\n                                        {userData.bio || \"GitHub Developer\"}\n                                    </p>\n                                </div>\n\n                                {/* Social Icons */}\n                                <div className=\"flex space-x-4\">\n                                    {userData.twitter_username && (\n                                        <a\n                                            href={`https://x.com/${userData.twitter_username}`}\n                                            target=\"_blank\"\n                                            rel=\"noopener noreferrer\"\n                                            className=\"p-2 hover:bg-background rounded-lg transition-colors\"\n                                        >\n                                            <Icon icon=\"ri:twitter-x-fill\" className=\"w-5 h-5 text-text hover:text-neutral-900 dark:hover:text-white\" />\n                                        </a>\n                                    )}\n                                    <a\n                                        href={userData.html_url}\n                                        target=\"_blank\"\n                                        rel=\"noopener noreferrer\"\n                                        className=\"p-2 hover:bg-background rounded-lg transition-colors\"\n                                    >\n                                        <Icon icon=\"ri:github-fill\" className=\"w-5 h-5 text-neutral-600 dark:text-neutral-400 hover:text-neutral-900 dark:hover:text-white\" />\n                                    </a>\n                                    {userData.blog && (\n                                        <a\n                                            href={\n                                                userData.blog.startsWith(\"http\")\n                                                    ? userData.blog\n                                                    : `https://${userData.blog}`\n                                            }\n                                            target=\"_blank\"\n                                            rel=\"noopener noreferrer\"\n                                            className=\"p-2 hover:bg-background rounded-lg transition-colors\"\n                                        >\n                                            <Icon icon=\"ri:link-fill\" className=\"w-5 h-5 text-text hover:text-neutral-900 dark:hover:text-white\" />\n                                        </a>    \n                                    )}\n                                    {userData.email && (\n                                        <a\n                                            href={`mailto:${userData.email}`}\n                                            className=\"p-2 hover:bg-background rounded-lg transition-colors\"\n                                        >\n                                            <Icon icon=\"ri:mail-fill\" className=\"w-5 h-5 text-text hover:text-neutral-900 dark:hover:text-white\" />\n                                        </a>\n                                    )}\n                                </div>\n\n                                {/* Stats */}\n                                <div className=\"flex w-full border border-neutral-200 dark:border-neutral-800 rounded-lg overflow-hidden\">\n                                    <div className=\"flex-1 text-center py-3 border-r border-neutral-200 dark:border-neutral-800\">\n                                        <div className=\"text-lg font-semibold text-text\">\n                                            {formatNumber(userData.followers)}\n                                        </div>\n                                        <div className=\"text-xs text-text\">\n                                            Followers\n                                        </div>\n                                    </div>\n                                    <div className=\"flex-1 text-center py-3 border-r border-neutral-200 dark:border-neutral-800\">\n                                        <div className=\"text-lg font-semibold text-text\">\n                                            {formatNumber(userData.following)}\n                                        </div>\n                                        <div className=\"text-xs text-text\">\n                                            Following\n                                        </div>\n                                    </div>\n                                    <div className=\"flex-1 text-center py-3\">\n                                        <div className=\"text-lg font-semibold text-text\">\n                                            {formatNumber(userData.public_repos)}\n                                        </div>\n                                        <div className=\"text-xs text-text\">\n                                            Repositories\n                                        </div>\n                                    </div>\n                                </div>\n\n                                {/* Contribution Graph */}\n                                <div className=\"w-full space-y-3\">\n                                    {/* Month labels */}\n                                    <div className=\"flex justify-between text-xs text-text px-3\">\n                                        {getMonthLabels().map((month, index) => (\n                                            <span\n                                                key={month}\n                                                className={\n                                                    index % 2 === 0 ? \"opacity-100\" : \"opacity-0\"\n                                                }\n                                            >\n                                                {month}\n                                            </span>\n                                        ))}\n                                    </div>\n\n                                    {/* Contribution grid - GitHub style */}\n                                    <div className=\"flex gap-1\">\n                                        {/* Day labels */}\n                                        <div className=\"flex flex-col justify-around text-xs text-text pr-2 h-20\">\n                                            <span>Mon</span>\n                                            <span>Wed</span>\n                                            <span>Fri</span>\n                                        </div>\n\n                                        {/* Grid container */}\n                                        <div className=\"flex gap-1 overflow-x-auto\">\n                                            {organizeContributionsByWeek().map((week, weekIndex) => (\n                                                <div key={weekIndex} className=\"flex flex-col gap-1\">\n                                                    {week.map((day, dayIndex) => (\n                                                        <div\n                                                            key={`${weekIndex}-${dayIndex}`}\n                                                            className=\"w-3 h-3 rounded-sm cursor-pointer hover:ring-1 hover:ring-text dark:hover:ring-text transition-all\"\n                                                            style={{\n                                                                backgroundColor: window.matchMedia(\n                                                                    \"(prefers-color-scheme: dark)\",\n                                                                ).matches\n                                                                    ? getDarkContributionColor(day.level)\n                                                                    : getContributionColor(day.level),\n                                                            }}\n                                                            title={`${day.count} contributions on ${day.date}`}\n                                                        />\n                                                    ))}\n                                                </div>\n                                            ))}\n                                        </div>\n                                    </div>\n\n                                    {/* Legend */}\n                                    <div className=\"flex items-center justify-between text-xs text-text px-3\">\n                                        <span>Learn how we count contributions</span>\n                                        <div className=\"flex items-center space-x-1\">\n                                            <span>Less</span>\n                                            <div className=\"flex space-x-1\">\n                                                {[0, 1, 2, 3, 4].map((level) => (\n                                                    <div\n                                                        key={level}\n                                                        className=\"w-3 h-3 rounded-sm\"\n                                                        style={{\n                                                            backgroundColor: window.matchMedia(\n                                                                \"(prefers-color-scheme: dark)\",\n                                                            ).matches\n                                                                ? getDarkContributionColor(level)\n                                                                : getContributionColor(level),\n                                                        }}\n                                                    />\n                                                ))}\n                                            </div>\n                                            <span>More</span>\n                                        </div>\n                                    </div>\n                                </div>\n                            </div>\n                        </Card>\n\n                        {/* Share Section */}\n                        <div className=\"w-full max-w-md bg-white dark:bg-black border border-text rounded-2xl p-6 space-y-4\">\n                            <div className=\"text-center space-y-2\">\n                                <h3 className=\"text-lg font-semibold text-text dark:text-white\">\n                                    Share GitHub Card\n                                </h3>\n                                <p className=\"text-sm text-text dark:text-neutral-400\">\n                                   Just generated my GitHub card from DeDevs UI — Generate yours and showcase your profile.\n                                </p>\n                            </div>\n\n                            <div className=\"flex space-x-3 justify-center gap-4 w-full\">\n                                <Button\n                                    onClick={shareToTwitter}\n                                    className=\"rounded-xl\"\n                                    size=\"sm\"\n                                >\n                                    <Icon icon=\"ri:twitter-x-fill\" className=\"w-4 h-4\" />\n                                </Button>\n\n                                <Button\n                                    onClick={shareToLinkedIn}\n                                    className=\"rounded-xl\"\n                                    size=\"sm\"\n                                >\n                                    <Icon icon=\"ri:linkedin-box-fill\" className=\"w-4 h-4\" />\n                                </Button>\n\n                                <Button\n                                    onClick={copyToClipboard}\n                                    className=\"rounded-xl\"\n                                    size=\"sm\"\n                                >\n                                    <Icon icon=\"ri:share-fill\" className=\"w-4 h-4\" />\n                                </Button>\n                            </div>\n                        </div>\n                    </>\n                )}\n\n                {/* Default state message */}\n                {!userData && !loading && !error && (\n                    <div className=\"text-text dark:text-neutral-400 text-center max-w-md\">\n                        <p className=\"text-lg mb-2\">\n                            Enter a GitHub username to view their profile card\n                        </p>\n                        <p className=\"text-sm\">\n                            Try searching for popular users like &quot;bunsdev&quot;,\n                            &quot;torvalds&quot;\n                        </p>\n                    </div>\n                )}\n            </div>\n        </>\n    );\n}\n",
      "type": "registry:component"
    }
  ]
}