{"version":3,"file":"BackToTop.BOFec718.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/O17SY33c7Z5Eh9aWkFwX/pEOVO9HMBxTjuymELr0B/BackToTop.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";import{useState,useEffect}from\"react\";/**\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any\n *\n * BackToTop — bouton flottant \"remonter en haut\".\n *\n * Effet \"couleurs négatives\" identique au menu (BottomNav) :\n * on reprend EXACTEMENT sa structure qui fonctionne —\n *   conteneur fixe avec `mixBlendMode: \"difference\"`\n *   > bouton enfant en blanc / fond transparent / liseré blanc.\n * Le blend est porté par le CONTENEUR (pas par l'élément-feuille) ;\n * c'est cette différence qui faisait échouer le rendu auparavant.\n *\n * Couleurs blanc/noir codées en dur (comme `dC`/`dIC` du menu desktop),\n * pour que l'effet ne dépende pas des réglages de couleur de l'instance.\n *\n * Apparition après `showAfter` px de défilement (détection robuste :\n * lit le scroll window/document/conteneur interne + écoute en capture).\n *\n * Butée sur le footer : le bouton est par défaut à `bottomOffset` px du\n * bas de la fenêtre. Dès que le footer (repéré via [data-site-footer])\n * remonte dans la vue, le bouton remonte avec lui en gardant un écart\n * constant `footerGap` au-dessus de son bord supérieur, au lieu de passer\n * par-dessus. Formule : bottom = max(bottomOffset, innerHeight - footerTop + footerGap).\n */export default function BackToTop(props){const{label=\"Back to top\",fontSize=12,showArrow=true,showAfter=400,bottomOffset=96,footerGap=24}=props;// Comme le menu desktop : blanc sur transparent, le blend fait l'inversion.\nconst dC=\"white\";const dIC=\"black\";// Sur le canvas Framer, on garde le bouton visible pour rester éditable.\nconst onCanvas=RenderTarget.current()===RenderTarget.canvas;const[hover,setHover]=useState(false);const[visible,setVisible]=useState(onCanvas);const[bottom,setBottom]=useState(bottomOffset);useEffect(()=>{if(onCanvas){setVisible(true);setBottom(bottomOffset);return;}if(typeof window===\"undefined\")return;const getScrollTop=()=>window.scrollY||window.pageYOffset||document.scrollingElement?.scrollTop||document.documentElement?.scrollTop||document.body?.scrollTop||0;// Calcule la position basse du bouton :\n// - repos = bottomOffset\n// - si le footer est en vue, on remonte pour rester footerGap px au-dessus.\nconst computeBottom=()=>{const footer=document.querySelector(\"[data-site-footer]\");if(!footer)return bottomOffset;const footerTop=footer.getBoundingClientRect().top;const lifted=window.innerHeight-footerTop+footerGap;return Math.max(bottomOffset,lifted);};const update=()=>{setVisible(getScrollTop()>showAfter);setBottom(computeBottom());};update();window.addEventListener(\"scroll\",update,{passive:true,capture:true});window.addEventListener(\"resize\",update,{passive:true});return()=>{window.removeEventListener(\"scroll\",update,true);window.removeEventListener(\"resize\",update);};},[onCanvas,showAfter,bottomOffset,footerGap]);const scrollToTop=()=>{if(typeof window===\"undefined\")return;window.scrollTo({top:0,behavior:\"smooth\"});const candidates=[document.scrollingElement,document.documentElement,document.body].filter(Boolean);candidates.forEach(el=>{if(el.scrollTop>0&&typeof el.scrollTo===\"function\"){el.scrollTo({top:0,behavior:\"smooth\"});}});};// Style du bouton enfant : repos = transparent + texte/liseré blancs ;\n// survol = pastille blanche + texte noir (le blend du conteneur inverse).\nconst btn={display:\"inline-flex\",alignItems:\"center\",gap:\"8px\",// Mêmes marges de cadre que le menu (btnBase: 3px 20px)\npadding:\"3px 20px\",background:hover?dC:\"transparent\",border:`1px solid ${dC}`,borderRadius:\"0px\",color:hover?dIC:dC,cursor:\"pointer\",fontFamily:\"'IBM Plex Mono', monospace\",fontSize:`${fontSize}px`,fontWeight:400,letterSpacing:\"0.08em\",textTransform:\"uppercase\",whiteSpace:\"nowrap\",userSelect:\"none\",WebkitTapHighlightColor:\"transparent\",transition:\"background 0.25s ease, color 0.25s ease\"};return(// CONTENEUR fixe qui porte le blend (comme le menu)\n/*#__PURE__*/_jsx(\"div\",{style:{position:\"fixed\",left:\"50%\",bottom:`${bottom}px`,zIndex:90,mixBlendMode:\"difference\",opacity:visible?1:0,transform:visible?\"translateX(-50%) translateY(0px)\":\"translateX(-50%) translateY(12px)\",transition:\"opacity 0.35s ease, transform 0.35s ease, bottom 0.15s linear\",pointerEvents:visible?\"auto\":\"none\"},children:/*#__PURE__*/_jsxs(\"div\",{role:\"button\",tabIndex:0,onClick:scrollToTop,onKeyDown:e=>{if(e.key===\"Enter\"||e.key===\" \")scrollToTop();},onMouseEnter:()=>setHover(true),onMouseLeave:()=>setHover(false),style:btn,children:[showArrow&&/*#__PURE__*/_jsx(\"span\",{style:{fontSize:`${fontSize+2}px`,lineHeight:1},children:\"↑\"}),/*#__PURE__*/_jsx(\"span\",{children:label})]})}));}addPropertyControls(BackToTop,{label:{type:ControlType.String,title:\"Label\",defaultValue:\"Back to top\"},fontSize:{type:ControlType.Number,title:\"Font size\",defaultValue:12,min:8,max:32,step:1,unit:\"px\"},showArrow:{type:ControlType.Boolean,title:\"Arrow\",defaultValue:true},showAfter:{type:ControlType.Number,title:\"Show after\",defaultValue:400,min:0,max:2e3,step:50,unit:\"px\"},bottomOffset:{type:ControlType.Number,title:\"Bottom offset\",defaultValue:96,min:0,max:300,step:4,unit:\"px\"},footerGap:{type:ControlType.Number,title:\"Footer gap\",defaultValue:24,min:0,max:120,step:4,unit:\"px\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"BackToTop\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerSupportedLayoutHeight\":\"any\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./BackToTop.map"],"mappings":"6MAwBG,SAAwB,EAAU,EAAM,CAAC,GAAK,CAAC,QAAM,cAAc,WAAS,GAAG,YAAU,GAAK,YAAU,IAAI,eAAa,GAAG,YAAU,IAAI,EACvI,EAAG,QACH,EAAS,EAAa,SAAS,GAAG,EAAa,OAAY,CAAC,EAAM,GAAUA,EAAS,GAAM,CAAM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