{"version":3,"file":"YouYube_Card.--ns95WF.mjs","names":["React.useState","React.useRef","_Fragment"],"sources":["https:/framerusercontent.com/modules/aVpJSmCI0pmApt3zmEnj/W7aoRXnVZt8ErWlhKOlS/YouYube_Card.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType}from\"framer\";function extractYouTubeId(url){if(!url)return null;const patterns=[/youtu\\.be\\/([a-zA-Z0-9_-]{6,})/,/youtube\\.com\\/watch\\?v=([a-zA-Z0-9_-]{6,})/,/youtube\\.com\\/embed\\/([a-zA-Z0-9_-]{6,})/,/youtube\\.com\\/shorts\\/([a-zA-Z0-9_-]{6,})/];for(const pattern of patterns){const match=url.match(pattern);if(match)return match[1];}return null;}function aspectRatioValue(option){return option===\"4:5\"?\"4 / 5\":\"9 / 16\";}export default function VideoBlock(props){const{youtubeUrl,caption,aspectRatio,autoplay,videoBackground,playButtonColor,playIconColor,captionColor,cornerRadius,style}=props;const[isPlaying,setIsPlaying]=React.useState(!!autoplay);const[isMuted,setIsMuted]=React.useState(false);const iframeRef=React.useRef(null);const videoId=extractYouTubeId(youtubeUrl);const ratio=aspectRatioValue(aspectRatio);// When autoplay is on, load the (muted) video immediately on mount\n// instead of waiting for a click — muted autoplay is allowed by\n// browsers without any user gesture, but once we gate it behind a\n// click the gesture can get \"lost\" by the time the iframe mounts,\n// which is what was blocking playback.\nReact.useEffect(()=>{setIsPlaying(!!autoplay);},[autoplay,youtubeUrl]);// Load Montserrat directly so the caption renders correctly even if\n// the host Framer project hasn't added it as a project font.\nReact.useEffect(()=>{const id=\"video-block-montserrat\";if(document.getElementById(id))return;const link=document.createElement(\"link\");link.id=id;link.rel=\"stylesheet\";link.href=\"https://fonts.googleapis.com/css2?family=Montserrat:wght@500;600&display=swap\";document.head.appendChild(link);},[]);const thumbnailUrl=videoId?`https://img.youtube.com/vi/${videoId}/maxresdefault.jpg`:null;// Browsers only allow autoplay-with-sound if it starts muted, so\n// when autoplay is on we start muted and let the person unmute\n// with a tap (see the unmute button below). enablejsapi lets us\n// send that unmute command without reloading the iframe.\nReact.useEffect(()=>{setIsMuted(!!autoplay);},[autoplay,youtubeUrl]);const embedSrc=videoId?`https://www.youtube.com/embed/${videoId}?autoplay=${autoplay?1:0}&rel=0&controls=1&cc_load_policy=1&modestbranding=1&playsinline=1&enablejsapi=1&mute=${autoplay?1:0}`:\"\";function unmute(){setIsMuted(false);iframeRef.current?.contentWindow?.postMessage(JSON.stringify({event:\"command\",func:\"unMute\",args:[]}),\"*\");}return /*#__PURE__*/_jsxs(\"div\",{style:{position:\"relative\",width:\"100%\",aspectRatio:ratio,borderRadius:cornerRadius,overflow:\"hidden\",backgroundColor:videoBackground,cursor:videoId&&!isPlaying&&!autoplay?\"pointer\":\"default\",...style},onClick:()=>{if(videoId&&!isPlaying&&!autoplay)setIsPlaying(true);},children:[!videoId&&/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",inset:0,display:\"flex\",alignItems:\"center\",justifyContent:\"center\",color:\"rgba(255,255,255,0.7)\",fontFamily:\"'Montserrat', sans-serif\",fontSize:13,textAlign:\"center\",padding:16},children:\"Paste a YouTube link in the property panel\"}),videoId&&!isPlaying&&/*#__PURE__*/_jsxs(_Fragment,{children:[thumbnailUrl&&/*#__PURE__*/_jsx(\"img\",{src:thumbnailUrl,alt:caption||\"Video thumbnail\",style:{position:\"absolute\",top:\"50%\",left:\"50%\",width:\"100%\",height:\"100%\",minWidth:\"100%\",minHeight:\"100%\",objectFit:\"cover\",transform:\"translate(-50%, -50%)\"},onError:e=>{const img=e.target;if(videoId&&!img.src.includes(\"hqdefault\")){img.src=`https://img.youtube.com/vi/${videoId}/hqdefault.jpg`;}}}),/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",top:\"50%\",left:\"50%\",transform:\"translate(-50%, -50%)\",width:64,height:64,borderRadius:\"50%\",backgroundColor:playButtonColor,display:\"flex\",alignItems:\"center\",justifyContent:\"center\",boxShadow:\"0 4px 14px rgba(0,0,0,0.25)\"},children:/*#__PURE__*/_jsx(\"svg\",{width:\"22\",height:\"22\",viewBox:\"0 0 20 20\",children:/*#__PURE__*/_jsx(\"path\",{d:\"M5 3 L17 10 L5 17 Z\",fill:\"none\",stroke:playIconColor,strokeWidth:2,strokeLinejoin:\"round\",strokeLinecap:\"round\"})})}),caption&&/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",bottom:20,left:20,right:20,color:captionColor,fontFamily:\"'Montserrat', sans-serif\",fontSize:13,fontWeight:500,lineHeight:1.4},children:caption})]}),videoId&&isPlaying&&/*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx(\"iframe\",{ref:iframeRef,src:embedSrc,title:caption||\"YouTube video\",allow:\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\",allowFullScreen:true,style:{position:\"absolute\",inset:0,width:\"100%\",height:\"100%\",border:\"none\"}}),isMuted&&/*#__PURE__*/_jsxs(\"button\",{onClick:e=>{e.stopPropagation();unmute();},style:{position:\"absolute\",bottom:16,right:16,display:\"flex\",alignItems:\"center\",gap:6,padding:\"8px 12px\",borderRadius:20,border:\"none\",backgroundColor:\"rgba(0,0,0,0.55)\",color:\"#fff\",fontFamily:\"'Montserrat', sans-serif\",fontSize:12,fontWeight:500,cursor:\"pointer\"},children:[/*#__PURE__*/_jsxs(\"svg\",{width:\"14\",height:\"14\",viewBox:\"0 0 24 24\",fill:\"none\",children:[/*#__PURE__*/_jsx(\"path\",{d:\"M4 9v6h4l5 5V4L8 9H4z\",fill:\"#fff\"}),/*#__PURE__*/_jsx(\"line\",{x1:\"16\",y1:\"9\",x2:\"22\",y2:\"15\",stroke:\"#fff\",strokeWidth:2}),/*#__PURE__*/_jsx(\"line\",{x1:\"22\",y1:\"9\",x2:\"16\",y2:\"15\",stroke:\"#fff\",strokeWidth:2})]}),\"Unmute\"]})]})]});}VideoBlock.defaultProps={youtubeUrl:\"\",caption:\"Meet the people behind our safety promise\",aspectRatio:\"9:16\",autoplay:true,videoBackground:\"#37471E\",playButtonColor:\"#EDF0E7\",playIconColor:\"#37471E\",captionColor:\"#EDF0E7\",cornerRadius:16};addPropertyControls(VideoBlock,{youtubeUrl:{type:ControlType.String,title:\"YouTube Link\",placeholder:\"https://youtube.com/watch?v=...\"},aspectRatio:{type:ControlType.Enum,title:\"Crop\",options:[\"9:16\",\"4:5\"],optionTitles:[\"Portrait 9:16\",\"Portrait 4:5\"],defaultValue:\"9:16\"},caption:{type:ControlType.String,title:\"Caption\",defaultValue:\"Meet the people behind our safety promise\"},autoplay:{type:ControlType.Boolean,title:\"Autoplay\",defaultValue:true},cornerRadius:{type:ControlType.Number,title:\"Radius\",min:0,max:64,defaultValue:16},videoBackground:{type:ControlType.Color,title:\"Video BG\",defaultValue:\"#37471E\"},playButtonColor:{type:ControlType.Color,title:\"Play BG\",defaultValue:\"#EDF0E7\"},playIconColor:{type:ControlType.Color,title:\"Play Icon\",defaultValue:\"#37471E\"},captionColor:{type:ControlType.Color,title:\"Caption Text\",defaultValue:\"#EDF0E7\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"VideoBlock\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./YouYube_Card.map"],"mappings":"kMAA+J,SAAS,EAAiB,EAAI,CAAC,GAAG,CAAC,EAAI,OAAO,KAA2L,IAAI,IAAM,IAAW,CAA3L,iCAAiC,6CAA6C,2CAA2C,2CAAyE,EAAE,CAAC,IAAM,EAAM,EAAI,MAAM,CAAO,EAAE,GAAG,EAAM,OAAO,EAAM,EAAG,CAAC,OAAO,IAAK,CAAC,SAAS,EAAiB,EAAO,CAAC,OAAO,IAAS,MAAM,QAAQ,QAAS,CAAC,SAAwB,EAAW,EAAM,CAAC,GAAK,CAAC,aAAW,UAAQ,cAAY,WAAS,k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