{"version":3,"file":"ClickToLoadVideo.BotdF0NE.mjs","names":["useState","useRef","useMemo","useCallback","__esmMin","ce","pe","ne","te","init_jsx_runtime","init_npm_react_18_3_1","de","_e","addPropertyControls","ControlType","init_framer_BL70qLPA","ClickToLoadVideo","props","activated","setActivated","errorMessage","setErrorMessage","videoRef","normalizedVideoUrl","videoUrl","hasVideo","mergedTextStyle","textFont","el","playPromise","onActivate","onVideoError","rootStyle","cornerRadius","textColor","style","backgroundColor","poster","accessibleLabel","accentColor","init_ClickToLoadVideo"],"sources":["https:/framerusercontent.com/modules/4vDrsHKhhhs6ZogNlaXP/SCcjM79floM1R2D6NlKe/ClickToLoadVideo.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useCallback,useEffect,useMemo,useRef,useState,startTransition}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight fixed\n */export default function ClickToLoadVideo(props){const{videoUrl,poster={},accessibleLabel=\"Lire la vid\\xe9o t\\xe9moignage\",backgroundColor=\"rgb(20,26,24)\",accentColor=\"rgb(29,205,159)\",textColor=\"rgb(254,254,254)\",cornerRadius=\"16px\",textFont,style}=props;const[activated,setActivated]=useState(false);const[errorMessage,setErrorMessage]=useState(\"\");const videoRef=useRef(null);const normalizedVideoUrl=useMemo(()=>typeof videoUrl===\"string\"?videoUrl:\"\",[videoUrl]);const hasVideo=useMemo(()=>normalizedVideoUrl.trim().length>0,[normalizedVideoUrl]);const mergedTextStyle=useMemo(()=>({fontFamily:textFont?.fontFamily??\"Inter, sans-serif\",fontSize:textFont?.fontSize??\"15px\",lineHeight:textFont?.lineHeight??\"1.3em\",letterSpacing:textFont?.letterSpacing??\"-0.01em\",fontWeight:textFont?.fontWeight??500,fontStyle:textFont?.fontStyle??\"normal\",textAlign:textFont?.textAlign??\"center\"}),[textFont]);useEffect(()=>{if(!activated||!hasVideo)return;const el=videoRef.current;if(!el)return;const playPromise=el.play();if(playPromise&&typeof playPromise.then===\"function\"){playPromise.catch(()=>{startTransition(()=>{setErrorMessage(\"Lecture bloqu\\xe9e. Appuyez sur lecture dans les contr\\xf4les.\");});});}},[activated,hasVideo]);const onActivate=useCallback(()=>{if(!hasVideo)return;startTransition(()=>{setErrorMessage(\"\");setActivated(true);});},[hasVideo]);const onVideoError=useCallback(()=>{startTransition(()=>{setErrorMessage(\"Erreur de chargement vid\\xe9o. V\\xe9rifiez l’URL du fichier.\");});},[]);const rootStyle=useMemo(()=>({position:\"relative\",width:\"100%\",height:\"100%\",aspectRatio:\"9 / 16\",backgroundColor,borderRadius:cornerRadius,overflow:\"hidden\",color:textColor,display:\"flex\",alignItems:\"center\",justifyContent:\"center\",...style}),[backgroundColor,cornerRadius,textColor,style]);return /*#__PURE__*/_jsxs(\"div\",{style:rootStyle,children:[!activated?/*#__PURE__*/_jsxs(\"div\",{style:{position:\"relative\",width:\"100%\",height:\"100%\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",backgroundColor},children:[poster?.src?/*#__PURE__*/_jsx(\"img\",{src:poster.src,srcSet:poster.srcSet,alt:poster.alt||\"\",style:{position:\"absolute\",inset:0,width:\"100%\",height:\"100%\",objectFit:\"cover\"}}):null,/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",inset:0,background:\"linear-gradient(180deg, rgba(0,0,0,0.05) 0%, rgba(0,0,0,0.55) 100%)\"}}),hasVideo?/*#__PURE__*/_jsx(\"button\",{type:\"button\",\"aria-label\":accessibleLabel,onClick:onActivate,style:{position:\"relative\",zIndex:2,width:76,height:76,borderRadius:999,border:`2px solid ${accentColor}`,backgroundColor:\"rgba(0,0,0,0.45)\",color:accentColor,display:\"flex\",alignItems:\"center\",justifyContent:\"center\",cursor:\"pointer\",outlineOffset:4},children:/*#__PURE__*/_jsx(\"svg\",{width:\"28\",height:\"28\",viewBox:\"0 0 24 24\",\"aria-hidden\":\"true\",focusable:\"false\",fill:\"currentColor\",children:/*#__PURE__*/_jsx(\"path\",{d:\"M8 5.14v13.72c0 .77.84 1.25 1.5.86l10.5-6.86a1 1 0 0 0 0-1.72L9.5 4.28A1 1 0 0 0 8 5.14Z\"})})}):/*#__PURE__*/_jsx(\"div\",{style:{position:\"relative\",zIndex:2,padding:\"10px 14px\",borderRadius:999,border:`1px solid ${accentColor}`,color:textColor,backgroundColor:\"rgba(0,0,0,0.35)\",...mergedTextStyle},children:\"Vid\\xe9o \\xe0 ajouter\"})]}):/*#__PURE__*/_jsx(\"video\",{ref:videoRef,src:normalizedVideoUrl,controls:true,playsInline:true,preload:\"metadata\",onError:onVideoError,style:{width:\"100%\",height:\"100%\",objectFit:\"cover\",backgroundColor}}),errorMessage?/*#__PURE__*/_jsx(\"div\",{role:\"status\",\"aria-live\":\"polite\",style:{position:\"absolute\",left:10,right:10,bottom:10,zIndex:3,padding:\"10px 12px\",borderRadius:10,backgroundColor:\"rgba(0,0,0,0.7)\",color:textColor,border:`1px solid ${accentColor}`,...mergedTextStyle},children:errorMessage}):null]});}addPropertyControls(ClickToLoadVideo,{videoUrl:{type:ControlType.File,title:\"Vid\\xe9o\",allowedFileTypes:[\"mp4\",\"webm\",\"mov\"]},poster:{type:ControlType.ResponsiveImage,title:\"Vignette\"},accessibleLabel:{type:ControlType.String,title:\"A11y Label\",defaultValue:\"Lire la vid\\xe9o t\\xe9moignage\"},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"rgb(20,26,24)\"},accentColor:{type:ControlType.Color,title:\"Accent\",defaultValue:\"rgb(29,205,159)\"},textColor:{type:ControlType.Color,title:\"Text\",defaultValue:\"rgb(254,254,254)\"},cornerRadius:{type:ControlType.BorderRadius,title:\"Radius\",defaultValue:\"16px\"},textFont:{type:ControlType.Font,title:\"Text Font\",defaultValue:{fontSize:\"15px\",variant:\"Medium\",letterSpacing:\"-0.01em\",lineHeight:\"1.3em\"},controls:\"extended\",defaultFontType:\"sans-serif\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ClickToLoadVideo\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"fixed\",\"framerSupportedLayoutHeight\":\"fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ClickToLoadVideo.map"],"mappings":"A,oNAGG,SAAwBgB,EAAiB,EAAM,CAAC,GAAK,CAAC,WAAS,SAAO,CAAC,EAAE,kBAAgB,2BAAiC,kBAAgB,gBAAgB,cAAY,kBAAkB,YAAU,mBAAmB,eAAa,OAAO,WAAS,SAAOC,EAAW,CAACC,EAAUC,GAAcnB,EAAS,EAAK,EAAO,CAACoB,EAAaC,GAAiBrB,EAAS,EAAE,EAAQsB,EAASrB,EAAO,IAAI,EAAQsB,EAAmBrB,MAAY,OAAOsB,GAAW,SAASA,EAAS,GAAG,CAACA,CAAQ,CAAC,EAAQC,EAASvB,MAAYqB,EAAmB,KAAK,CAAC,CAAC,OAAO,EAAE,CAACA,CAAkB,CAAC,EAAQG,EAAgBxB,OAAa,CAAC,WAAWyB,GAAU,YAAY,oBAAoB,SAASA,GAAU,UAAU,OAAO,WAAWA,GAAU,YAAY,QAAQ,cAAcA,GAAU,eAAe,UAAU,WAAWA,GAAU,YAAY,IAAI,UAAUA,GAAU,WAAW,SAAS,UAAUA,GAAU,WAAW,QAAQ,GAAG,CAACA,CAAQ,CAAC,EAAEtB,MAAc,CAAC,GAAG,CAACa,GAAW,CAACO,EAAS,OAAO,IAAMG,EAAGN,EAAS,QAAQ,GAAG,CAACM,EAAG,OAAO,IAAMC,EAAYD,EAAG,KAAK,EAAKC,GAAa,OAAOA,EAAY,MAAO,YAAYA,EAAY,UAAU,CAACrB,MAAoB,CAACa,EAAgB,0DAAgE,CAAE,CAAC,CAAE,CAAC,CAAG,EAAE,CAACH,EAAUO,CAAQ,CAAC,EAAE,IAAMK,EAAW3B,MAAgB,CAAKsB,GAAgBjB,MAAoB,CAACa,EAAgB,EAAE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