{"version":3,"file":"YouTubeVideoWidget.B7lbVEgV.mjs","names":["useState","__esmMin","te","init_npm_react_18_3_1","window","_e","p","ce","init_ssg_sandbox_shims","init_framer_CKT6jEEQ","addPropertyControls","ControlType","YouTubeVideoWidget","props","video","setVideo","loading","setLoading","error","setError","errorMessage","setErrorMessage","fetchVideoData","videoUrl","videoId","extractVideoId","oEmbedResponse","oEmbedData","err","pattern","match","url","handleClick","isFixedWidth","isFixedHeight","textColor","titleFont","accentColor","showViewCount","ctaFont","ctaText","init_YouTubeVideoWidget","init_jsx_runtime"],"sources":["https:/framerusercontent.com/modules/iHiroyLfB8FtpZtYgMtQ/hSfktYZjYOdpHTAE1yVM/YouTubeVideoWidget.js"],"sourcesContent":["// YouTube Latest Video Widget - Shows the latest video from @DesignXstream channel\n// Displays video thumbnail, title, and view count as a nudge to watch\n// YouTube Video Widget - Display a specific YouTube video\n// Paste any YouTube video URL to showcase it\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useState,startTransition}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function YouTubeVideoWidget(props){const{videoUrl,backgroundColor,textColor,accentColor,borderRadius,showViewCount,ctaText,titleFont,ctaFont}=props;const[video,setVideo]=useState(null);const[loading,setLoading]=useState(true);const[error,setError]=useState(false);const[errorMessage,setErrorMessage]=useState(\"\");useEffect(()=>{if(typeof window===\"undefined\")return;async function fetchVideoData(){try{if(!videoUrl){startTransition(()=>{setErrorMessage(\"Please add a YouTube video URL\");setError(true);setLoading(false);});return;}// Extract video ID from URL\nconst videoId=extractVideoId(videoUrl);if(!videoId){throw new Error(\"Invalid YouTube URL\");}// Use oEmbed API (no API key required)\nconst oEmbedResponse=await fetch(`https://www.youtube.com/oembed?url=https://www.youtube.com/watch?v=${videoId}&format=json`);if(!oEmbedResponse.ok){throw new Error(\"Video not found\");}const oEmbedData=await oEmbedResponse.json();startTransition(()=>{setVideo({title:oEmbedData.title,thumbnail:oEmbedData.thumbnail_url,videoId,viewCount:\"\",publishedAt:\"\",authorName:oEmbedData.author_name});setLoading(false);setError(false);});}catch(err){startTransition(()=>{setErrorMessage(err instanceof Error?err.message:\"Unable to load video\");setError(true);setLoading(false);});}}fetchVideoData();},[videoUrl]);function extractVideoId(url){// Handle various YouTube URL formats\nconst patterns=[/(?:youtube\\.com\\/watch\\?v=|youtu\\.be\\/|youtube\\.com\\/embed\\/)([^&\\n?#]+)/,/^([a-zA-Z0-9_-]{11})$/];for(const pattern of patterns){const match=url.match(pattern);if(match)return match[1];}return null;}function formatViewCount(views){const num=parseInt(views);if(num>=1e6){return`${(num/1e6).toFixed(1)}M views`;}else if(num>=1e3){return`${(num/1e3).toFixed(1)}K views`;}return`${num} views`;}function handleClick(){if(video&&typeof window!==\"undefined\"){window.open(`https://www.youtube.com/watch?v=${video.videoId}`,\"_blank\");}}const isFixedWidth=props?.style&&props.style.width===\"100%\";const isFixedHeight=props?.style&&props.style.height===\"100%\";if(loading){return /*#__PURE__*/_jsx(\"div\",{style:{...props.style,position:\"relative\",...isFixedWidth?{}:{minWidth:\"max-content\"},...isFixedHeight?{}:{minHeight:\"max-content\"},backgroundColor,borderRadius,padding:20,display:\"flex\",alignItems:\"center\",justifyContent:\"center\"},children:/*#__PURE__*/_jsx(\"span\",{style:{color:textColor,...titleFont},children:\"Loading latest video...\"})});}if(error||!video){return /*#__PURE__*/_jsxs(\"div\",{style:{...props.style,position:\"relative\",...isFixedWidth?{}:{minWidth:\"max-content\"},...isFixedHeight?{}:{minHeight:\"max-content\"},backgroundColor,borderRadius,padding:20,display:\"flex\",flexDirection:\"column\",alignItems:\"center\",justifyContent:\"center\",gap:8},children:[/*#__PURE__*/_jsx(\"span\",{style:{color:textColor,...titleFont},children:errorMessage||\"Unable to load video\"}),!videoUrl&&/*#__PURE__*/_jsx(\"span\",{style:{color:textColor,opacity:.7,fontSize:\"12px\",textAlign:\"center\"},children:\"Paste a YouTube video URL\"})]});}return /*#__PURE__*/_jsxs(\"div\",{style:{...props.style,position:\"relative\",...isFixedWidth?{}:{minWidth:\"max-content\"},...isFixedHeight?{}:{minHeight:\"max-content\"},backgroundColor,borderRadius,overflow:\"hidden\",cursor:\"pointer\",boxShadow:\"0 4px 12px rgba(0,0,0,0.1)\",transition:\"transform 0.2s ease, box-shadow 0.2s ease\"},onClick:handleClick,onMouseEnter:e=>{e.currentTarget.style.transform=\"translateY(-2px)\";e.currentTarget.style.boxShadow=\"0 6px 16px rgba(0,0,0,0.15)\";},onMouseLeave:e=>{e.currentTarget.style.transform=\"translateY(0)\";e.currentTarget.style.boxShadow=\"0 4px 12px rgba(0,0,0,0.1)\";},children:[/*#__PURE__*/_jsxs(\"div\",{style:{position:\"relative\",width:\"100%\",paddingBottom:\"56.25%\",backgroundColor:\"#000\"},children:[/*#__PURE__*/_jsx(\"img\",{src:video.thumbnail,alt:video.title,style:{position:\"absolute\",top:0,left:0,width:\"100%\",height:\"100%\",objectFit:\"cover\"}}),/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",top:\"50%\",left:\"50%\",transform:\"translate(-50%, -50%)\",width:60,height:60,backgroundColor:accentColor,borderRadius:\"50%\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",opacity:.9},children:/*#__PURE__*/_jsx(\"svg\",{width:\"24\",height:\"24\",viewBox:\"0 0 24 24\",fill:\"none\",style:{marginLeft:2},children:/*#__PURE__*/_jsx(\"path\",{d:\"M8 5v14l11-7z\",fill:\"#fff\"})})})]}),/*#__PURE__*/_jsxs(\"div\",{style:{padding:20},children:[/*#__PURE__*/_jsx(\"h3\",{style:{margin:0,marginBottom:8,color:textColor,...titleFont,display:\"-webkit-box\",WebkitLineClamp:2,WebkitBoxOrient:\"vertical\",overflow:\"hidden\"},children:video.title}),showViewCount&&/*#__PURE__*/_jsx(\"p\",{style:{margin:0,marginBottom:12,color:textColor,opacity:.7,...ctaFont},children:video.viewCount}),showViewCount&&video.authorName&&/*#__PURE__*/_jsx(\"p\",{style:{margin:0,marginBottom:12,color:textColor,opacity:.7,...ctaFont},children:video.authorName}),/*#__PURE__*/_jsx(\"div\",{style:{display:\"inline-block\",padding:\"10px 20px\",backgroundColor:accentColor,color:\"#fff\",borderRadius:6,...ctaFont},children:ctaText})]})]});}addPropertyControls(YouTubeVideoWidget,{videoUrl:{type:ControlType.String,title:\"Video URL\",defaultValue:\"https://www.youtube.com/watch?v=dQw4w9WgXcQ\",placeholder:\"Paste YouTube video URL\",displayTextArea:true},ctaText:{type:ControlType.String,title:\"CTA Text\",defaultValue:\"Watch Now\"},showViewCount:{type:ControlType.Boolean,title:\"Show Channel\",defaultValue:true,enabledTitle:\"Show\",disabledTitle:\"Hide\"},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#1a1a1a\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#FFFFFF\"},accentColor:{type:ControlType.Color,title:\"Accent Color\",defaultValue:\"#FF0000\"},borderRadius:{type:ControlType.Number,title:\"Radius\",defaultValue:12,min:0,max:32,step:1},titleFont:{type:ControlType.Font,title:\"Title Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"18px\",variant:\"Semibold\",letterSpacing:\"-0.01em\",lineHeight:\"1.3em\"}},ctaFont:{type:ControlType.Font,title:\"CTA Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"14px\",variant:\"Semibold\",letterSpacing:\"-0.01em\",lineHeight:\"1em\"}}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"YouTubeVideoWidget\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./YouTubeVideoWidget.map"],"mappings":"A,mMAO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