{"version":3,"file":"CalendlyAuto.CLWHt2jN.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/5FZm1GyvOeoLHC8FDQoz/6c6vMC1BEmOOYR2durPf/CalendlyAuto.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useEffect,useRef,useState}from\"react\";const UTM_KEYS=[\"utm_source\",\"utm_medium\",\"utm_campaign\",\"utm_content\",\"utm_term\"];const ANCRE=\"prendre-rendez-vous\";// Ouvre la connexion vers Calendly en avance (DNS + TLS), sans rien charger d'autre\nfunction preconnecter(){if(typeof document===\"undefined\")return;for(const href of[\"https://calendly.com\",\"https://assets.calendly.com\"]){if(document.head.querySelector(`link[rel=\"preconnect\"][href=\"${href}\"]`))continue;const link=document.createElement(\"link\");link.rel=\"preconnect\";link.href=href;link.crossOrigin=\"anonymous\";document.head.appendChild(link);}}/**\n * Agenda Calendly qui prend toujours sa vraie hauteur : ni scroll interne, ni blanc en dessous.\n * Chargement : tout de suite si l'adresse contient #prendre-rendez-vous, sinon au premier geste\n * du visiteur (scroll, toucher, souris, clavier) ou quand il approche de l'agenda.\n * Rien ne se charge sans geste : la vitesse mesurée par PageSpeed ne bouge pas.\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight auto\n */export default function CalendlyAuto(props){const{calendar=\"baptisteh/appel-decouverte\",minHeight=700,hideDetails=true}=props;const frameRef=useRef(null);const[height,setHeight]=useState(minHeight);const[src,setSrc]=useState(\"\");const[pret,setPret]=useState(false);const boxRef=useRef(null);const[proche,setProche]=useState(false);// 1) Arrivée directe par le lien /#prendre-rendez-vous : on charge sans attendre\n// 2) Premier geste du visiteur : on charge en arrière-plan, l'agenda est prêt quand il arrive en bas\n// 3) Secours : le visiteur approche de l'agenda\nuseEffect(()=>{if(typeof window===\"undefined\"||proche)return;const charger=()=>setProche(true);if(window.location.hash===`#${ANCRE}`){charger();return;}const onHash=()=>{if(window.location.hash===`#${ANCRE}`)charger();};const gestes=[\"scroll\",\"pointerdown\",\"pointermove\",\"touchstart\",\"keydown\",\"wheel\"];let timer;const onGeste=()=>{preconnecter();if(timer)return;timer=setTimeout(charger,400);};gestes.forEach(g=>window.addEventListener(g,onGeste,{passive:true,once:true}));window.addEventListener(\"hashchange\",onHash);let io;const el=boxRef.current;if(el&&\"IntersectionObserver\"in window){io=new IntersectionObserver(entries=>{if(entries.some(e=>e.isIntersecting))charger();},{rootMargin:\"1200px 0px 1200px 0px\"});io.observe(el);}else{charger();}return()=>{gestes.forEach(g=>window.removeEventListener(g,onGeste));window.removeEventListener(\"hashchange\",onHash);if(timer)clearTimeout(timer);io?.disconnect();};},[proche]);useEffect(()=>{if(typeof window===\"undefined\"||!proche)return;preconnecter();const params=new URLSearchParams;params.set(\"embed_domain\",window.location.hostname||\"the-retention.io\");params.set(\"embed_type\",\"Inline\");params.set(\"hide_gdpr_banner\",\"1\");if(hideDetails)params.set(\"hide_landing_page_details\",\"1\");const current=new URLSearchParams(window.location.search);for(const key of UTM_KEYS){const value=current.get(key);if(value)params.set(key,value);}setSrc(`https://calendly.com/${calendar}?${params.toString()}`);function onMessage(event){if(!String(event.origin).includes(\"calendly.com\"))return;if(frameRef.current&&event.source!==frameRef.current.contentWindow)return;const data=event.data;if(!data||data.event!==\"calendly.page_height\"||!data.payload)return;const next=parseInt(String(data.payload.height),10);if(!Number.isFinite(next)||next<300)return;setPret(true);setHeight(prev=>prev===next?prev:next);}window.addEventListener(\"message\",onMessage);return()=>window.removeEventListener(\"message\",onMessage);},[calendar,hideDetails,proche]);return /*#__PURE__*/_jsxs(\"div\",{ref:boxRef,style:{...props.style,position:\"relative\",width:\"100%\",height},children:[!pret?/*#__PURE__*/_jsxs(\"div\",{\"aria-hidden\":\"true\",style:{position:\"absolute\",inset:0,display:\"flex\",flexDirection:\"column\",alignItems:\"center\",justifyContent:\"center\",gap:14,borderRadius:12,background:\"rgba(255, 255, 255, 0.04)\",border:\"1px solid rgba(46, 226, 3, 0.18)\",color:\"rgba(255, 255, 255, 0.7)\",fontSize:15,fontFamily:\"inherit\"},children:[/*#__PURE__*/_jsx(\"style\",{children:`@keyframes calendlyAutoTourne{to{transform:rotate(360deg)}}`}),/*#__PURE__*/_jsx(\"div\",{style:{width:28,height:28,borderRadius:\"50%\",border:\"3px solid rgba(46, 226, 3, 0.25)\",borderTopColor:\"rgb(46, 226, 3)\",animation:\"calendlyAutoTourne 0.9s linear infinite\"}}),\"Chargement de l’agenda…\"]}):null,src?/*#__PURE__*/_jsx(\"iframe\",{ref:frameRef,src:src,title:\"R\\xe9server un cr\\xe9neau\",onLoad:()=>setTimeout(()=>setPret(true),600),style:{position:\"relative\",width:\"100%\",height:\"100%\",border:0,display:\"block\",opacity:pret?1:0,transition:\"opacity 0.25s ease\"}}):null]});}addPropertyControls(CalendlyAuto,{calendar:{type:ControlType.String,title:\"Calendrier\",defaultValue:\"baptisteh/appel-decouverte\"},minHeight:{type:ControlType.Number,title:\"Hauteur de d\\xe9part\",defaultValue:700,min:300,max:1600,step:10,unit:\"px\"},hideDetails:{type:ControlType.Boolean,title:\"Cacher les d\\xe9tails\",defaultValue:true}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CalendlyAuto\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CalendlyAuto.map"],"mappings":"mMACA,SAAS,GAAc,CAAI,YAAO,SAAW,KAAmB,IAAI,IAAM,IAAO,CAAC,uBAAuB,6BAA6B,EAAE,CAAC,GAAG,SAAS,KAAK,cAAc,gCAAgC,EAAK,GAAG,EAAE,SAAS,IAAM,EAAK,SAAS,cAAc,MAAM,EAAE,EAAK,IAAI,aAAa,EAAK,KAAK,EAAK,EAAK,YAAY,YAAY,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