{"version":3,"file":"YouTubeEmbed.CzAFQF7w.mjs","names":["useRef"],"sources":["https:/framerusercontent.com/modules/Jbiy4JcMdqJqzdz1QiR1/pqdav4s2g57ZWJvUoQ3b/YouTubeEmbed.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useRef}from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";function getVideoId(url){const match=(url||\"\").match(/(?:youtu\\.be\\/|v=|embed\\/|shorts\\/)([A-Za-z0-9_-]{11})/);return match?match[1]:\"\";}/**\n * YouTube video in a 16:9 frame. Autoplay is always muted, because browsers block autoplay with sound.\n *\n * @framerIntrinsicWidth 1000\n * @framerIntrinsicHeight 562\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight auto\n */export default function YouTubeEmbed(props){const{url=\"https://www.youtube.com/watch?v=fiT91d2Rpto\",autoplay=true,loop=true,showControls=true,hideCaptions=true,radius=16,title=\"About Cygrid\"}=props;const isStatic=useIsStaticRenderer();const id=getVideoId(url);const iframeRef=useRef(null);// YouTube can switch captions on by itself (viewer settings, muted playback, default tracks).\n// When playback starts, ask the player to drop the captions module. The CC button still works.\nuseEffect(()=>{if(!hideCaptions||isStatic)return;const send=(func,args=[])=>iframeRef.current?.contentWindow?.postMessage(JSON.stringify({event:\"command\",func,args}),\"*\");const onMessage=event=>{if(event.source!==iframeRef.current?.contentWindow)return;let data;try{data=typeof event.data===\"string\"?JSON.parse(event.data):event.data;}catch{return;}const state=data?.event===\"onStateChange\"?data.info:data?.info?.playerState;if(state===1){send(\"unloadModule\",[\"captions\"]);send(\"unloadModule\",[\"cc\"]);}};window.addEventListener(\"message\",onMessage);return()=>window.removeEventListener(\"message\",onMessage);},[hideCaptions,isStatic]);const startListening=()=>{iframeRef.current?.contentWindow?.postMessage(JSON.stringify({event:\"listening\",id:1,channel:\"widget\"}),\"*\");};const params=new URLSearchParams({rel:\"0\",modestbranding:\"1\",playsinline:\"1\",controls:showControls?\"1\":\"0\"});if(hideCaptions){params.set(\"cc_load_policy\",\"0\");params.set(\"enablejsapi\",\"1\");if(typeof window!==\"undefined\")params.set(\"origin\",window.location.origin);}if(autoplay){params.set(\"autoplay\",\"1\");params.set(\"mute\",\"1\");}if(loop){params.set(\"loop\",\"1\");params.set(\"playlist\",id);}const frame={...props.style,position:\"relative\",width:\"100%\",aspectRatio:\"16 / 9\",borderRadius:radius,overflow:\"hidden\",background:\"#0B0D16\",boxShadow:\"0px 40px 80px -40px rgba(11,16,38,0.55)\"};if(!id){return /*#__PURE__*/_jsx(\"div\",{style:{...frame,display:\"flex\",alignItems:\"center\",justifyContent:\"center\",color:\"#FFFFFF\",fontFamily:\"Inter, sans-serif\",fontSize:15},children:\"Add a YouTube link\"});}if(isStatic){return /*#__PURE__*/_jsx(\"div\",{style:frame,children:/*#__PURE__*/_jsx(\"img\",{src:`https://i.ytimg.com/vi/${id}/maxresdefault.jpg`,alt:title,style:{width:\"100%\",height:\"100%\",objectFit:\"cover\",display:\"block\"}})});}return /*#__PURE__*/_jsx(\"div\",{style:frame,children:/*#__PURE__*/_jsx(\"iframe\",{ref:iframeRef,onLoad:startListening,src:`https://www.youtube-nocookie.com/embed/${id}?${params.toString()}`,title:title,allow:\"autoplay; encrypted-media; picture-in-picture; fullscreen\",allowFullScreen:true,referrerPolicy:\"strict-origin-when-cross-origin\",style:{position:\"absolute\",inset:0,width:\"100%\",height:\"100%\",border:0}})});}addPropertyControls(YouTubeEmbed,{url:{type:ControlType.String,title:\"YouTube URL\",defaultValue:\"https://www.youtube.com/watch?v=fiT91d2Rpto\"},title:{type:ControlType.String,title:\"Title\",defaultValue:\"About Cygrid\"},autoplay:{type:ControlType.Boolean,title:\"Autoplay (muted)\",defaultValue:true},loop:{type:ControlType.Boolean,title:\"Loop\",defaultValue:true},showControls:{type:ControlType.Boolean,title:\"Controls\",defaultValue:true},hideCaptions:{type:ControlType.Boolean,title:\"Captions Off\",defaultValue:true},radius:{type:ControlType.Number,title:\"Radius\",defaultValue:16,min:0,max:48}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"YouTubeEmbed\",\"slots\":[],\"annotations\":{\"framerIntrinsicHeight\":\"562\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerSupportedLayoutHeight\":\"auto\",\"framerContractVersion\":\"1\",\"framerIntrinsicWidth\":\"1000\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./YouTubeEmbed.map"],"mappings":"uMAAuJ,SAAS,EAAW,EAAI,CAAC,IAAM,GAAO,GAAK,GAAA,CAAI,MAAM,wDAAwD,EAAE,OAAO,EAAM,EAAM,GAAG,EAAG,CAQ5R,SAAwB,EAAa,EAAM,CAAC,GAAK,CAAC,MAAI,8CAA8C,WAAS,GAAK,OAAK,GAAK,eAAa,GAAK,eAAa,GAAK,SAAO,GAAG,QAAM,gBAAgB,EAAY,EAAS,EAAoB,EAAQ,EAAG,EAAW,CAAG,EAAQ,EAAUA,EAAO,IAAI,EAElS,MAAc,CAAC,GAAG,CAAC,GAAc,EAAS,OAAO,IAAM,GAAM,EAAK,EAAK,CAAC,IAAI,EAAU,SAAS,eAAe,YAAY,KAAK,UAAU,CAAC,MAAM,UAAU,OAAK,MAAI,CAAC,EAAE,GAAG,EAAQ,EAAU,GAAO,CAAC,GAAG,EAAM,SAAS,EAAU,SAAS,cAAc,OAAO,IAAI,EAAK,GAAG,CAAC,EAAK,OAAO,EAAM,MAAO,SAAS,KAAK,MAAM,EAAM,IAAI,EAAE,EAAM,IAAK,MAAM,CAAC,MAAO,EAAa,GAAM,QAAQ,gBAAgB,EAAK,KAAK,GAAM,MAAM,eAAuB,IAAG,EAAK,eAAe,CAAC,UAAU,CAAC,EAAE,EAAK,eAAe,CAAC,IAAI,CAAC,EAAG,EAA+C,OAA7C,EAAO,iBAAiB,UAAU,CAAS,MAAY,EAAO,oBAAoB,UAAU,CAAS,CAAE,EAAE,CAAC,E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