{"version":3,"file":"Clip.BFDVGLfV.mjs","names":["useState","startTransition","useRef"],"sources":["https:/framerusercontent.com/modules/KHEeOgsNcGCtQWRWo18k/S99n3sWFdm0MGAhfsccs/Clip.js"],"sourcesContent":["// Clip: plays a looping product clip (animated WebP) in a phone frame, accessibly.\n// - Pause and play button (WCAG 2.2.2: auto-playing motion over 5 seconds must be pausable).\n// - Shows a still frame when the visitor's device asks for reduced motion.\n// - Plays only while on screen.\n// The still frame is the poster image if one is set, otherwise the clip's current frame.\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";import{useInView}from\"framer-motion\";import{useEffect,useRef,useState,startTransition}from\"react\";const INK=\"#22232B\";const FRAMES={// Matches the Phone component (Framed): 8px bezel, 38px outer and 26px screen corners\nphone:{outer:{background:INK,padding:8,borderRadius:38,boxShadow:\"0px 24px 48px 0px rgba(34,35,43,0.16)\"},inner:{borderRadius:26}},// Matches the feature page phones: 6px border, rounded top only, peeking into the panel\npeek:{outer:{border:`6px solid ${INK}`,borderRadius:\"30px 30px 0 0\",boxShadow:\"0px 16px 36px 0px rgba(34,35,43,0.16)\"},inner:{borderRadius:\"24px 24px 0 0\"}},none:{outer:{},inner:{}}};function usePrefersReducedMotion(){const[reduced,setReduced]=useState(false);useEffect(()=>{if(typeof window===\"undefined\"||!window.matchMedia)return;const mq=window.matchMedia(\"(prefers-reduced-motion: reduce)\");const update=()=>startTransition(()=>setReduced(mq.matches));update();mq.addEventListener(\"change\",update);return()=>mq.removeEventListener(\"change\",update);},[]);return reduced;}/**\n * Clip\n *\n * @framerIntrinsicWidth 280\n * @framerIntrinsicHeight 606\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight auto\n */export default function Clip(props){const{clip={src:\"\",alt:\"\"},poster,alt=\"\",frame=\"phone\",showControl=true,style}=props;const isStatic=useIsStaticRenderer();const reduced=usePrefersReducedMotion();const rootRef=useRef(null);const imgRef=useRef(null);const canvasRef=useRef(null);const inView=useInView(rootRef,{amount:.25});const[userPaused,setUserPaused]=useState(false);const[captured,setCaptured]=useState(false);const[playKey,setPlayKey]=useState(0);const paused=userPaused||reduced;const playing=!isStatic&&!paused&&inView;const posterSrc=poster?.src;const label=alt||clip.alt||\"\";// Freeze the current frame onto the canvas when there is no poster\nfunction capture(){const img=imgRef.current;const canvas=canvasRef.current;if(!img||!canvas||!img.complete||!img.naturalWidth)return;canvas.width=img.naturalWidth;canvas.height=img.naturalHeight;const ctx=canvas.getContext(\"2d\");if(!ctx)return;ctx.drawImage(img,0,0);startTransition(()=>setCaptured(true));}useEffect(()=>{if(!playing&&!posterSrc)capture();},[playing,posterSrc]);function toggle(){startTransition(()=>{if(userPaused)setPlayKey(k=>k+1)// restart from the first frame\n;setUserPaused(!userPaused);});}const f=FRAMES[frame]||FRAMES.phone;const mediaStyle={display:\"block\",width:\"100%\",height:\"auto\"};const showStill=!playing&&(posterSrc||captured);if(!clip.src){return /*#__PURE__*/_jsx(\"div\",{style:{...style,position:\"relative\",...f.outer},children:/*#__PURE__*/_jsx(\"div\",{style:{...f.inner,overflow:\"hidden\",background:\"#F2EDFE\",aspectRatio:\"390 / 844\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",color:INK,fontSize:14},children:\"Choose a clip\"})});}return /*#__PURE__*/_jsxs(\"div\",{ref:rootRef,style:{...style,position:\"relative\",height:\"auto\",...f.outer},children:[/*#__PURE__*/_jsxs(\"div\",{style:{position:\"relative\",overflow:\"hidden\",...f.inner},children:[/*#__PURE__*/_jsx(\"img\",{ref:imgRef,src:clip.src,alt:showStill?\"\":label,onLoad:()=>{if(!playing&&!posterSrc)capture();},style:{...mediaStyle,display:showStill?\"none\":\"block\"}},playKey),posterSrc&&/*#__PURE__*/_jsx(\"img\",{src:posterSrc,alt:showStill?label:\"\",style:{...mediaStyle,display:showStill?\"block\":\"none\"}}),!posterSrc&&/*#__PURE__*/_jsx(\"canvas\",{ref:canvasRef,role:\"img\",\"aria-label\":label,\"aria-hidden\":!showStill,style:{...mediaStyle,display:showStill?\"block\":\"none\"}})]}),showControl&&/*#__PURE__*/_jsx(\"button\",{type:\"button\",onClick:toggle,\"aria-label\":paused?\"Play animation\":\"Pause animation\",\"aria-pressed\":paused,style:{// Same place on every clip: the top-right corner of the frame, outside the screen\nposition:\"absolute\",top:frame===\"none\"?8:-16,right:frame===\"none\"?8:-16,zIndex:1,width:36,height:36,borderRadius:18,border:\"1px solid rgba(34,35,43,0.12)\",background:\"#FFFFFF\",color:INK,boxShadow:\"0px 4px 12px rgba(34,35,43,0.18)\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",cursor:\"pointer\",padding:0},children:paused?/*#__PURE__*/_jsx(\"svg\",{width:\"14\",height:\"14\",viewBox:\"0 0 14 14\",\"aria-hidden\":\"true\",children:/*#__PURE__*/_jsx(\"path\",{d:\"M3 1.5v11l9-5.5z\",fill:\"currentColor\"})}):/*#__PURE__*/_jsxs(\"svg\",{width:\"14\",height:\"14\",viewBox:\"0 0 14 14\",\"aria-hidden\":\"true\",children:[/*#__PURE__*/_jsx(\"rect\",{x:\"2.5\",y:\"1.5\",width:\"3\",height:\"11\",rx:\"1\",fill:\"currentColor\"}),/*#__PURE__*/_jsx(\"rect\",{x:\"8.5\",y:\"1.5\",width:\"3\",height:\"11\",rx:\"1\",fill:\"currentColor\"})]})})]});}addPropertyControls(Clip,{clip:{type:ControlType.ResponsiveImage,title:\"Clip (WebP)\"},poster:{type:ControlType.ResponsiveImage,title:\"Poster\"},alt:{type:ControlType.String,title:\"Alt text\",defaultValue:\"\",displayTextArea:true},frame:{type:ControlType.Enum,title:\"Frame\",options:[\"phone\",\"peek\",\"none\"],optionTitles:[\"Phone\",\"Peek\",\"None\"],defaultValue:\"phone\"},showControl:{type:ControlType.Boolean,title:\"Pause button\",defaultValue:true}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"Clip\",\"slots\":[],\"annotations\":{\"framerIntrinsicWidth\":\"280\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"auto\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerIntrinsicHeight\":\"606\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Clip.map"],"mappings":"wQAOuL,SAAS,GAAyB,CAAC,GAAK,CAAC,EAAQ,GAAYA,EAAS,EAAK,EAA6S,OAA3S,MAAc,CAAC,GAAU,IAAS,QAAa,CAAC,EAAO,WAAW,OAAO,IAAM,EAAG,EAAO,WAAW,kCAAkC,EAAQ,MAAWC,MAAoB,EAAW,EAAG,OAAO,CAAC,EAAgD,OAA9C,EAAO,EAAE,EAAG,iBAAiB,SAAS,CAAM,MAAY,EAAG,oBAAoB,SAAS,CAAM,CAAE,EAAE,CAAC,CAAC,EAAS,CAAQ,CAQ3jB,SAAwB,EAAK,EAAM,CAAC,GAAK,CAAC,OAAK,CAAC,IAAI,GAAG,IAAI,EAAE,EAAE,SAAO,MAAI,GAAG,QAAM,QAAQ,cAAY,GAAK,SAAO,EAAY,EAAS,EAAoB,EAAQ,EAAQ,EAAwB,EAAQ,EAAQC,EAAO,IAAI,EAAQ,EAAOA,EAAO,IAAI,EAAQ,EAAUA,EAAO,IAAI,EAAQ,EAAO,EAAU,EAAQ,CAAC,OAAO,GAAG,CAAC,EAAO,CAAC,EAAW,GAAeF,EAAS,EAAK,EAAO,CAAC,EAAS,GAAaA,EAAS,EAAK,EAAO,CAAC,EAAQ,GAAYA,EAAS,CAAC,EAAQ,EAAO,GAAY,EAAc,EAAQ,CAAC,GAAU,CAAC,GAAQ,EAAa,EAAU,GAAQ,IAAU,EAAM,GAAK,EAAK,KAAK,GAC3kB,SAAS,GAAS,CAAC,IAAM,EAAI,EAAO,QAAc,EAAO,EAAU,QAAQ,GAAG,CAAC,GAAK,CAAC,GAAQ,CAAC,EAAI,UAAU,CAAC,EAAI,aAAa,OAAO,EAAO,MAAM,E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