{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "post-embed",
  "type": "registry:block",
  "title": "Post Embed",
  "description": "A component for displaying embedded content from URLs like YouTube, Spotify, etc.",
  "files": [
    {
      "path": "src/components/deso/post-embed.tsx",
      "content": "import React from 'react';\nimport { cn } from '@/lib/utils/deso';\nimport { Tweet } from 'react-tweet';\nimport Image from 'next/image';\n\ninterface PostEmbedProps {\n  url: string;\n  className?: string;\n}\n\nconst getYouTubeVideoId = (url: string) => {\n  try {\n    const urlObj = new URL(url);\n    if (urlObj.hostname === 'youtu.be') {\n      return urlObj.pathname.slice(1);\n    }\n    if (\n      urlObj.hostname === 'www.youtube.com' ||\n      urlObj.hostname === 'youtube.com'\n    ) {\n      if (urlObj.pathname === '/watch') {\n        return urlObj.searchParams.get('v');\n      }\n      if (urlObj.pathname.startsWith('/embed/')) {\n        return urlObj.pathname.slice(7);\n      }\n    }\n  } catch (error) {\n    console.error('Invalid YouTube URL:', error);\n  }\n  return null;\n};\n\nconst getSpotifyEmbedUrl = (url: string) => {\n  try {\n    const urlObj = new URL(url);\n    if (urlObj.hostname === 'open.spotify.com') {\n      return `https://open.spotify.com/embed${urlObj.pathname}`;\n    }\n  } catch (error) {\n    console.error('Invalid Spotify URL:', error);\n  }\n  return null;\n};\n\nconst getTweetId = (url: string) => {\n  try {\n    const urlObj = new URL(url);\n    if (\n      urlObj.hostname === 'twitter.com' ||\n      urlObj.hostname === 'x.com'\n    ) {\n      const match = urlObj.pathname.match(/\\/status\\/(\\d+)/);\n      if (match) {\n        return match[1];\n      }\n    }\n  } catch (error) {\n    console.error('Invalid Twitter URL:', error);\n  }\n  return null;\n};\n\nexport const PostEmbed: React.FC<PostEmbedProps> = ({ url, className }) => {\n  const youtubeVideoId = getYouTubeVideoId(url);\n  if (youtubeVideoId) {\n    return (\n      <div className={cn('mt-2 rounded-lg overflow-hidden', className)}>\n        <iframe\n          width=\"100%\"\n          height=\"315\"\n          src={`https://www.youtube.com/embed/${youtubeVideoId}`}\n          title=\"YouTube video player\"\n          frameBorder=\"0\"\n          allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\"\n          allowFullScreen\n        ></iframe>\n      </div>\n    );\n  }\n\n  const spotifyEmbedUrl = getSpotifyEmbedUrl(url);\n  if (spotifyEmbedUrl) {\n    return (\n      <div className={cn('mt-2 rounded-[20px] overflow-hidden', className)}>\n        <iframe\n          src={spotifyEmbedUrl}\n          width=\"100%\"\n          height=\"152\"\n          frameBorder=\"0\"\n          allow=\"encrypted-media\"\n          className=\"rounded-[20px]\"\n        ></iframe>\n      </div>\n    );\n  }\n\n  const tweetId = getTweetId(url);\n  if (tweetId) {\n    return (\n      <div className={cn('mt-2 rounded-lg overflow-hidden', className)}>\n        <Tweet id={tweetId} />\n      </div>\n    );\n  }\n\n  if (url.includes('soundcloud.com')) {\n    return (\n      <div className={cn('mt-2 rounded-lg overflow-hidden', className)}>\n        <iframe\n          width=\"100%\"\n          height=\"166\"\n          scrolling=\"no\"\n          frameBorder=\"no\"\n          src={`https://w.soundcloud.com/player/?url=${url}&color=%23ff5500&auto_play=true&hide_related=false&show_comments=true&show_user=true&show_reposts=false&show_teaser=true`}\n        ></iframe>\n      </div>\n    );\n  }\n\n  return (\n    <div\n      className={cn(\n        'mt-2 rounded-lg border border-border bg-muted flex',\n        className\n      )}\n    >\n      <div className=\"rounded-tl-lg rounded-bl-lg overflow-hidden\">\n        <Image src=\"https://placehold.co/1200x800/dbd8e3/352f44\" alt=\"Website Embed\" width={150} height={100} />\n      </div>\n      <div className=\"flex-1 flex-col p-4 gap-0\">\n        <p className=\"font-bold m-0\">Website Embed</p>\n        <a\n          href={url}\n          target=\"_blank\"\n          rel=\"noopener noreferrer\"\n          className=\"text-primary hover:underline text-xs\"\n        >\n          {url}\n        </a>\n        <p className=\"text-sm text-muted-foreground\">\n          This is a placeholder for the OG meta tags.\n        </p>\n      </div>\n    </div>\n  );\n}; ",
      "type": "registry:component",
      "target": "src/components/deso-ui/post-embed.tsx"
    }
  ]
}