{"version":3,"file":"Media_URL_insert.DjGkhWOb.mjs","names":["React.useRef"],"sources":["https:/framerusercontent.com/modules/Url32iNpWRQzR7TeON9x/krsWhdSlxyeB45IyZCCk/Media_URL_insert.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";// Only for decorative muted autoplay video. Never take over a manually\n// controlled player or start video whose Autoplay control is disabled.\nfunction observeAutoplay(video){let inView=true;let disposed=false;let resumeDesired=true;let stoppedByManager=false;const visible=()=>inView&&!document.hidden;const update=()=>{if(disposed)return;if(!visible()){stoppedByManager=true;video.pause();}else if(resumeDesired&&video.paused){// Autoplay may be denied on mobile; do not surface an unhandled\n// rejection or retry on a timer.\nconst playing=video.play();playing?.then(()=>{if(!disposed&&!visible())video.pause();}).catch(()=>{});}};const onPlaying=()=>{if(!visible())update();else stoppedByManager=false;};const onPause=()=>{if(visible()&&!stoppedByManager)resumeDesired=false;};const observer=typeof IntersectionObserver===\"undefined\"?null:new IntersectionObserver(entries=>{const entry=entries.find(entry=>entry.target===video);if(!entry)return;inView=entry.isIntersecting;update();},{threshold:0});observer?.observe(video);document.addEventListener(\"visibilitychange\",update);video.addEventListener(\"playing\",onPlaying);video.addEventListener(\"pause\",onPause);update();return()=>{disposed=true;observer?.disconnect();document.removeEventListener(\"visibilitychange\",update);video.removeEventListener(\"playing\",onPlaying);video.removeEventListener(\"pause\",onPause);};}/**\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight fixed\n * @framerIntrinsicWidth 400\n * @framerIntrinsicHeight 300\n */export default function ResponsiveMedia(props){const{url,alt,mediaType,fit,position,borderRadius,border,backgroundColor,autoplay,loop,muted,controls}=props;const cleanUrl=url?.split(\"?\")[0]?.toLowerCase()||\"\";const looksLikeVideo=/\\.(mp4|mov|webm|m4v|ogg|ogv)$/i.test(cleanUrl);const isVideo=mediaType===\"video\"||mediaType===\"auto\"&&looksLikeVideo;const videoRef=React.useRef(null);React.useEffect(()=>{if(!isVideo||!autoplay||!muted||controls||!videoRef.current)return;return observeAutoplay(videoRef.current);},[url,isVideo,autoplay,muted,controls]);// borderStyle mặc định \"solid\" để width > 0 luôn hiện, kể cả khi\n// giá trị truyền vào thiếu key này.\nconst borderStyle=border?{borderStyle:\"solid\",...border}:{};const wrapperStyle={width:\"100%\",height:\"100%\",minWidth:0,minHeight:0,overflow:\"hidden\",borderRadius,...borderStyle,backgroundColor,position:\"relative\",boxSizing:\"border-box\"};const mediaStyle={width:\"100%\",height:\"100%\",display:\"block\",objectFit:fit,objectPosition:position,borderRadius:\"inherit\"};if(!url){// Chưa có URL: trên site thật chỉ để khung trống (giữ nền, viền, kích\n// thước), không in chữ nhắc cho khách thấy. Chữ nhắc chỉ hiện trong\n// Framer editor để người dựng trang biết ô này còn thiếu ảnh.\nconst showHint=RenderTarget.current()===RenderTarget.canvas;return /*#__PURE__*/_jsx(\"div\",{\"aria-hidden\":showHint?undefined:true,style:{...wrapperStyle,display:\"flex\",alignItems:\"center\",justifyContent:\"center\",color:\"rgba(0,0,0,0.45)\",fontSize:14,fontFamily:\"Inter, sans-serif\",textAlign:\"center\",padding:16},children:showHint?\"Nhập URL ảnh hoặc video\":null});}return /*#__PURE__*/_jsx(\"div\",{style:wrapperStyle,children:isVideo?/*#__PURE__*/_jsx(\"video\",{ref:videoRef,src:url,style:mediaStyle,autoPlay:autoplay,loop:loop,muted:muted,controls:controls,playsInline:true,preload:\"metadata\"}):/*#__PURE__*/_jsx(\"img\",{src:url,alt:alt||\"\",style:mediaStyle,loading:\"lazy\",draggable:false})});}ResponsiveMedia.defaultProps={url:\"\",alt:\"\",mediaType:\"auto\",fit:\"cover\",position:\"center center\",borderRadius:0,border:{borderWidth:0,borderStyle:\"solid\",borderColor:\"rgba(0, 0, 0, 0.1)\"},backgroundColor:\"#F5F5F5\",autoplay:true,loop:true,muted:true,controls:false};addPropertyControls(ResponsiveMedia,{url:{type:ControlType.String,title:\"Media URL\",placeholder:\"https://example.com/image.jpg hoặc video.mp4\"},alt:{type:ControlType.String,title:\"Alt\",placeholder:\"M\\xf4 tả ảnh cho Google v\\xe0 tr\\xecnh đọc m\\xe0n h\\xecnh\",description:\"Để trống với ảnh trang tr\\xed thuần tu\\xfd — đ\\xf3 l\\xe0 khuyến nghị của Google.\"},mediaType:{type:ControlType.Enum,title:\"Type\",options:[\"auto\",\"image\",\"video\"],optionTitles:[\"Auto\",\"Image\",\"Video\"],defaultValue:\"auto\"},fit:{type:ControlType.Enum,title:\"Fit\",options:[\"cover\",\"contain\",\"fill\",\"none\",\"scale-down\"],optionTitles:[\"Cover\",\"Contain\",\"Fill\",\"None\",\"Scale Down\"],defaultValue:\"cover\"},position:{type:ControlType.String,title:\"Position\",defaultValue:\"center center\",placeholder:\"center center\"},borderRadius:{type:ControlType.Number,title:\"Radius\",defaultValue:0,min:0,max:200,unit:\"px\"},border:{type:ControlType.Border,title:\"Border\",defaultValue:{borderWidth:0,borderStyle:\"solid\",borderColor:\"rgba(0, 0, 0, 0.1)\"}},backgroundColor:{type:ControlType.Color,title:\"Bg\",defaultValue:\"#FFFFFF\"},autoplay:{type:ControlType.Boolean,title:\"Autoplay\",defaultValue:true},loop:{type:ControlType.Boolean,title:\"Loop\",defaultValue:true},muted:{type:ControlType.Boolean,title:\"Muted\",defaultValue:true},controls:{type:ControlType.Boolean,title:\"Controls\",defaultValue:false}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ResponsiveMedia\",\"slots\":[],\"annotations\":{\"framerIntrinsicHeight\":\"300\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"fixed\",\"framerSupportedLayoutHeight\":\"fixed\",\"framerIntrinsicWidth\":\"400\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Media_URL_insert.map"],"mappings":"wLAEA,SAAS,EAAgB,EAAM,CAAC,IAAI,EAAO,GAAS,EAAS,GAAU,EAAc,GA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