{"version":3,"file":"FileSpinVideo.CHznTYCa.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/q2Of2MzS9C2lljxxqrc4/2PTLbkQrWZ5tBD0nrx9t/FileSpinVideo.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useRef,useState}from\"react\";import{addPropertyControls,ControlType}from\"framer\";const FONT='\"Satoshi\", \"Satoshi Placeholder\", sans-serif';function posterUrl(base,width,aspect){if(!base)return\"\";const w=Math.min(2400,Math.max(400,Math.ceil(width/200)*200));const h=Math.round(w/aspect);return base.includes(\"?\")?base.replace(/resize=\\d+,\\d+/,`resize=${w},${h}`):`${base}?resize=${w},${h}`;}export default function FileSpinVideo(props){const{src,srcLarge,largeFrom=800,soundOnPlay=true,poster,title,aspect=16/9,preload=\"visible\",radius=16,dim=.35}=props;const box=useRef(null);const video=useRef(null);const[started,setStarted]=useState(false);const[posterSrc,setPosterSrc]=useState(posterUrl(poster,1280,aspect));const[file,setFile]=useState(\"\");// Poster at the rendered size (device pixels), measured once from this component's own box.\nuseEffect(()=>{if(typeof window===\"undefined\"||!box.current)return;const css=box.current.clientWidth;const w=css*(window.devicePixelRatio||1);if(w>0)setPosterSrc(posterUrl(poster,w,aspect));// Pick the file once, from the rendered width: 720p on desktop-size players, 480p below.\nsetFile(srcLarge&&css>=largeFrom?srcLarge:src);},[poster,aspect,src,srcLarge,largeFrom]);// \"visible\": start the background download once the player is within 300px of the viewport.\nuseEffect(()=>{if(preload!==\"visible\"||typeof window===\"undefined\"||!box.current||!(\"IntersectionObserver\"in window))return;const el=box.current;const io=new IntersectionObserver(entries=>{if(entries.some(e=>e.isIntersecting)&&video.current){video.current.preload=\"auto\";if(video.current.paused&&video.current.readyState<3)video.current.load();io.disconnect();}},{rootMargin:\"300px\"});io.observe(el);return()=>io.disconnect();},[preload]);const play=()=>{const v=video.current;if(!v)return;setStarted(true);v.muted=!soundOnPlay;// If a browser still refuses audible playback, start muted rather than not at all.\nv.play().catch(()=>{v.muted=true;v.play().catch(()=>setStarted(false));});};return /*#__PURE__*/_jsxs(\"div\",{ref:box,onContextMenu:e=>e.preventDefault(),style:{position:\"relative\",width:\"100%\",aspectRatio:String(aspect),borderRadius:radius,background:\"#0B1530\",transform:\"translateZ(0)\",isolation:\"isolate\",...props.style,height:\"auto\"},children:[/*#__PURE__*/_jsx(\"video\",{ref:video,src:file||undefined,poster:posterSrc,playsInline:true,controls:started,controlsList:\"nodownload noremoteplayback\",disableRemotePlayback:true,preload:preload===\"auto\"?\"auto\":\"metadata\",\"aria-label\":title,onPlay:()=>setStarted(true),style:{display:\"block\",width:\"100%\",height:\"100%\",objectFit:\"cover\",borderRadius:radius}}),!started&&/*#__PURE__*/_jsx(\"button\",{type:\"button\",onClick:play,\"aria-label\":`Play video: ${title}`,style:{position:\"absolute\",inset:0,display:\"flex\",alignItems:\"center\",justifyContent:\"center\",background:`rgba(11, 21, 48, ${dim})`,border:\"none\",borderRadius:radius,padding:0,cursor:\"pointer\"},children:/*#__PURE__*/_jsxs(\"span\",{style:{display:\"inline-flex\",alignItems:\"center\",gap:10,padding:\"16px 24px\",borderRadius:8,color:\"#fff\",font:`700 16px/1 ${FONT}`,background:\"linear-gradient(204deg, #29C5FF -25.4%, #1132E5 47.1%, #000C4B 82.7%)\",boxShadow:\"0px 10px 30px -16px #0633DE\"},children:[/*#__PURE__*/_jsx(\"svg\",{width:\"16\",height:\"16\",viewBox:\"0 0 16 16\",\"aria-hidden\":\"true\",children:/*#__PURE__*/_jsx(\"path\",{d:\"M4 2.5v11l9-5.5z\",fill:\"#fff\"})}),\"Watch how it works\"]})})]});}addPropertyControls(FileSpinVideo,{src:{type:ControlType.String,title:\"MP4 URL\",description:\"Small file (phones, tablets).\",defaultValue:\"https://cdn.filespin.io/api/v1/assets/67b1a9de24b143eb8e04aa71fd3a1214/transcodes/480p-video.mp4\"},srcLarge:{type:ControlType.String,title:\"Large MP4 URL\",description:\"Desktop-size file.\",defaultValue:\"https://cdn.filespin.io/api/v1/assets/67b1a9de24b143eb8e04aa71fd3a1214/transcodes/720p-video.mp4\"},largeFrom:{type:ControlType.Number,title:\"Large from\",unit:\"px\",defaultValue:800,min:320,max:2e3,step:10},soundOnPlay:{type:ControlType.Boolean,title:\"Sound on click\",defaultValue:true},poster:{type:ControlType.String,title:\"Poster URL\",description:\"FileSpin conversion URL; resize=W,H is set to the rendered size.\",defaultValue:\"https://cdn.filespin.io/api/v1/assets/67b1a9de24b143eb8e04aa71fd3a1214/conversions?resize=800,600\"},title:{type:ControlType.String,title:\"Title\",defaultValue:\"FileSpin product walkthrough\"},aspect:{type:ControlType.Number,title:\"Aspect\",defaultValue:16/9,min:.5,max:3,step:.01},preload:{type:ControlType.Enum,title:\"Preload\",options:[\"metadata\",\"visible\",\"auto\"],optionTitles:[\"Header only\",\"When near view\",\"On page load\"],defaultValue:\"visible\"},radius:{type:ControlType.Number,title:\"Radius\",defaultValue:16,min:0,max:40},dim:{type:ControlType.Number,title:\"Poster dim\",description:\"Dark tint over the poster until playback starts.\",defaultValue:.35,min:0,max:.8,step:.05}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"FileSpinVideo\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./FileSpinVideo.map"],"mappings":"uPAAoN,SAAS,EAAU,EAAK,EAAM,EAAO,CAAC,GAAG,CAAC,EAAK,MAAM,GAAG,IAAM,EAAE,KAAK,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,EAAM,GAAG,EAAE,GAAG,CAAC,EAAQ,EAAE,KAAK,MAAM,EAAE,CAAM,EAAE,OAAO,EAAK,SAAS,GAAG,EAAE,EAAK,QAAQ,iBAAiB,UAAU,EAAE,GAAG,GAAG,EAAE,GAAG,EAAK,UAAU,EAAE,GAAG,GAAI,CAAC,SAAwB,EAAc,EAAM,CAAC,GA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