{"version":3,"file":"CleanTube.CQLHobJW.mjs","names":["React.useRef","React.useState","React.useMemo"],"sources":["https:/framerusercontent.com/modules/FFSTi7JiXxltkiOdy6Dl/9EzgOyOl2UMfkCOqFFE5/CleanTube.js"],"sourcesContent":["// @ts-nocheck\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType}from\"framer\";const YOUTUBE_REGEX=/^.*(youtu.be\\/|v\\/|u\\/\\w\\/|embed\\/|watch\\?v=|&v=)([^#&?]*).*/;/**\n * @framerDisableUnlink\n * @framerIntrinsicWidth 200\n * @framerIntrinsicHeight 112\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fit\n */export default function CleanTube(props){const{sourceType,url,localVideoUrl,localVideoFile,posterImageUrl,posterImageFile,brandColor,backgroundColor,borderRadius,style}=props;const ref=React.useRef(null);const[PlyrComponent,setPlyrComponent]=React.useState(null);const[isVideoActive,setIsVideoActive]=React.useState(false);const[isMobile,setIsMobile]=React.useState(false);React.useEffect(()=>{if(typeof window===\"undefined\")return;const ua=navigator.userAgent||\"\";setIsMobile(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(ua)||navigator.maxTouchPoints>1&&/MacIntel/.test(navigator.platform));},[]);React.useEffect(()=>{let isMounted=true;import(\"https://esm.sh/plyr-react@3.2.1?external=react,react-dom&bundle\").then(module=>{if(isMounted)setPlyrComponent(()=>module.default||module);}).catch(console.error);return()=>{isMounted=false;};},[]);const currentVideoID=React.useMemo(()=>{if(!url)return\"\";const match=url.match(YOUTUBE_REGEX);return match&&match[2].length===11?match[2]:\"\";},[url]);const hasValidSource=sourceType===\"file\"?!!localVideoFile:sourceType===\"url\"?!!localVideoUrl:!!currentVideoID;React.useEffect(()=>{if(!PlyrComponent)return;const attachEvents=()=>{const player=ref.current?.plyr;if(!player)return;try{player.off(\"play\");player.off(\"ready\");player.on(\"play\",()=>{const isIOS=/iPad|iPhone|iPod/.test(navigator.platform)||navigator.maxTouchPoints>1&&/MacIntel/.test(navigator.platform);if(isIOS)player.fullscreen.enter();});player.on(\"ready\",()=>window.dispatchEvent(new Event(\"resize\")));player.on(\"ended\",()=>{setIsVideoActive(false);player.stop();});player.on(\"playing\",()=>setIsVideoActive(true));}catch(err){}};const checker=setInterval(()=>{if(ref.current?.plyr){attachEvents();clearInterval(checker);}},200);return()=>clearInterval(checker);},[PlyrComponent,currentVideoID,localVideoUrl,localVideoFile,sourceType]);const controlsList=React.useMemo(()=>{const controls=[\"play-large\",\"play\",\"progress\",\"current-time\",\"mute\"];if(!isMobile)controls.push(\"volume\");controls.push(\"settings\",\"fullscreen\");return controls;},[isMobile]);const plyrProps=React.useMemo(()=>{const isSelfHosted=sourceType===\"url\"||sourceType===\"file\";const src=sourceType===\"file\"?localVideoFile:localVideoUrl;const baseOptions={autoplay:false,resetOnEnd:true,clickToPlay:true,ratio:\"16:9\",fullscreen:{enabled:true,fallback:true,iosNative:true},controls:controlsList,settings:[\"captions\",\"quality\",\"speed\"],speed:{selected:1,options:[1,1.25,1.5,2]}};if(isSelfHosted){const currentPoster=sourceType===\"file\"?posterImageFile:posterImageUrl;return{source:{type:\"video\",sources:[{src:src||\"\"}],poster:currentPoster||\"\"},options:baseOptions};}return{source:{type:\"video\",sources:[{src:currentVideoID,provider:\"youtube\"}]},options:{...baseOptions,youtube:{noCookie:false,rel:0,showinfo:0,modestbranding:1,iv_load_policy:3,disablekb:1,playsinline:0,origin:typeof window!==\"undefined\"?window.location.origin:\"\"}}};},[currentVideoID,localVideoUrl,localVideoFile,posterImageUrl,posterImageFile,controlsList,sourceType]);return /*#__PURE__*/_jsxs(\"div\",{onContextMenu:e=>e.preventDefault(),style:{...style,position:\"relative\",overflow:\"hidden\",aspectRatio:\"16/9\",borderRadius:`${borderRadius}px`,backgroundColor,\"--plyr-color-main\":brandColor,\"--plyr-menu-background\":\"rgba(255, 255, 255, 0.95)\",\"--plyr-menu-color\":\"#4a5464\"},className:isVideoActive?\"is-active\":\"\",children:[/*#__PURE__*/_jsx(\"link\",{rel:\"stylesheet\",href:\"https://cdn.plyr.io/3.7.8/plyr.css\"}),/*#__PURE__*/_jsx(\"style\",{children:`\n                .plyr { height: 100%; width: 100%; font-family: sans-serif; display: flex; align-items: center; justify-content: center; position: absolute; top: 0; left: 0; }\n                .plyr__video-wrapper { padding-bottom: 0 !important; aspect-ratio: 16 / 9 !important; height: 100% !important; width: auto !important; max-width: 100% !important; max-height: 100% !important; margin: auto !important; }\n                .plyr__video-embed iframe { position: absolute; top: -50% !important; height: 200% !important; width: 100% !important; transform: none !important; pointer-events: none !important; opacity: 0; transition: opacity 0.3s ease; }\n                .plyr--fullscreen-active .plyr__video-embed iframe { top: 0 !important; height: 100% !important; width: 100% !important; transform: none !important; }\n                .plyr__poster { background-size: cover; background-position: center; }\n                .plyr__controls { z-index: 9999 !important; pointer-events: auto !important; }\n                .is-active .plyr__video-embed iframe { opacity: 1 !important; }\n                @media (max-width: 768px), (hover: none) and (pointer: coarse) {\n                    .plyr__volume { display: none !important; }\n                    .plyr__controls .plyr__control[data-plyr=\"mute\"] { margin-right: 0 !important; }\n                }\n            `}),/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",top:0,left:0,width:\"100%\",height:\"100%\"},children:PlyrComponent&&hasValidSource?/*#__PURE__*/_jsx(PlyrComponent,{ref:ref,...plyrProps}):/*#__PURE__*/_jsx(\"div\",{style:{color:brandColor||\"#ffffff\",fontSize:14,height:\"100%\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",textAlign:\"center\",padding:20},children:!PlyrComponent?null:sourceType===\"file\"?\"No Video Uploaded\":sourceType===\"url\"?\"No Video URL Provided\":\"No video found (enter URL)\"})})]});}addPropertyControls(CleanTube,{sourceType:{type:ControlType.Enum,title:\"Source\",options:[\"youtube\",\"url\",\"file\"],optionTitles:[\"YouTube Link\",\"Video URL\",\"Video File\"],defaultValue:\"youtube\"},url:{type:ControlType.String,title:\"YouTube Link\",defaultValue:\"https://www.youtube.com/watch?v=8AHPXm9Y6mI\",placeholder:\"https://youtube.com/watch?v=...\",hidden:props=>props.sourceType!==\"youtube\"},localVideoUrl:{type:ControlType.String,title:\"Video URL\",defaultValue:\"https://videos.pexels.com/video-files/4237250/4237250-uhd_2560_1440_30fps.mp4\",placeholder:\"https://.../video.mp4\",hidden:props=>props.sourceType!==\"url\"},localVideoFile:{type:ControlType.File,title:\"Video File\",allowedFileTypes:[\"mp4\",\"webm\",\"ogg\",\"mov\"],defaultValue:\"\",hidden:props=>props.sourceType!==\"file\"},posterImageUrl:{type:ControlType.Image,title:\"Cover Image\",defaultValue:\"\",hidden:props=>props.sourceType!==\"url\"},posterImageFile:{type:ControlType.Image,title:\"Cover Image\",defaultValue:\"\",hidden:props=>props.sourceType!==\"file\"},brandColor:{type:ControlType.Color,title:\"Brand Color\",defaultValue:\"#00b8ff\"},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#000000\"},borderRadius:{type:ControlType.Number,title:\"Radius\",defaultValue:0,min:0,max:50,step:1}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CleanTube\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"any-prefer-fit\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerIntrinsicHeight\":\"112\",\"framerContractVersion\":\"1\",\"framerDisableUnlink\":\"* @framerIntrinsicWidth 200\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CleanTube.map"],"mappings":"2NAOG,SAAwB,EAAU,EAAM,CAAC,GAAK,CAAC,aAAW,MAAI,gBAAc,iBAAe,iBAAe,kBAAgB,aAAW,kBAAgB,eAAa,SAAO,EAAY,EAAIA,EAAa,KAAK,CAAM,CAAC,EAAc,GAAkBC,EAAe,KAAK,CAAM,CAAC,EAAc,GAAkBA,EAAe,GAAM,CAAM,CAAC,EAAS,GAAaA,EA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