{"version":3,"file":"LogoutButton_2.CsXLCxTO.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/R5KgfMLGgbDSx8YAes6l/4dVpDTpce0IpVRqIBQyJ/LogoutButton_2.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useState,useEffect}from\"react\";// NEW: Import hooks\nimport{createClient}from\"@supabase/supabase-js\";import{addPropertyControls,ControlType}from\"framer\";// Initialize Supabase client\nconst supabase=createClient(\"https://jukkjpryzugkchqinugn.supabase.co\",\"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Imp1a2tqcHJ5enVna2NocWludWduIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTQ1NzMyNTksImV4cCI6MjA3MDE0OTI1OX0.5nTNMR26m18B-qxt1U0MC_yO_f77_c6zTl7_FjcdzuA\");export default function LogoutButton(props){const{redirectTo,style}=props;// NEW: State to track if the user is logged in\nconst[isLoggedIn,setIsLoggedIn]=useState(false);const[isLoading,setIsLoading]=useState(true);// NEW: Check the user's auth status when the component loads\nuseEffect(()=>{const{data:{subscription}}=supabase.auth.onAuthStateChange((_event,session)=>{// !!session converts the session object or null into a true/false boolean\nsetIsLoggedIn(!!session);setIsLoading(false);});// Cleanup the listener when the component is removed\nreturn()=>subscription.unsubscribe();},[]);const handleLogout=async()=>{try{const{error}=await supabase.auth.signOut();if(error){console.error(\"Error logging out:\",error.message);}else{window.location.href=redirectTo;}}catch(error){console.error(\"Error logging out:\",error.message);}};// Don't show anything while checking the auth status\nif(isLoading){return null;}// NEW: Only render the button if the user is logged in\nreturn isLoggedIn?/*#__PURE__*/_jsx(\"button\",{onClick:handleLogout,style:{...buttonStyle,...style},children:\"Log Out\"}):null;}// --- Styles and Property Controls remain the same ---\nconst buttonStyle={padding:\"10px 20px\",fontSize:\"16px\",fontFamily:\"sans-serif\",color:\"white\",background:\"#333\",border:\"none\",borderRadius:\"8px\",cursor:\"pointer\"};addPropertyControls(LogoutButton,{redirectTo:{type:ControlType.String,title:\"Redirect To\",defaultValue:\"/login\",description:\"The page to redirect to after logging out.\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"LogoutButton\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./LogoutButton_2.map"],"mappings":"wXAE2R,SAAwB,EAAa,EAAM,CAAC,GAAK,CAAC,aAAW,SAAO,EAC1V,CAAC,EAAW,GAAeA,EAAS,GAAM,CAAM,CAAC,EAAU,GAAcA,EAAS,GAAK,CAK5F,OAJA,MAAc,CAAC,GAAK,CAAC,KAAK,CAAC,iBAAe,EAAS,KAAK,mBAAmB,EAAO,IAAU,CAC5F,EAAc,CAAC,CAAC,EAAQ,CAAC,EAAa,GAAM,EAAG,CAC/C,UAAU,EAAa,aAAa,EAAG,EAAE,CAAC,CACvC,EAAkB,KACd,EAAwB,EAAK,SAAS,CAAC,QAFgB,SAAS,CAAC,GAAG,CAAC,GAAK,CAAC,SAAO,MAAM,EAAS,KAAK,SAAS,CAAI,EAAO,QAAQ,MAAM,qBAAqB,EAAM,QAAQ,CAAO,EAAO,SAAS,KAAK,QAAmB,EAAM,CAAC,QAAQ,MAAM,qBAAqB,EAAM,QAAQ,GAEtN,MAAM,CAAC,GAAG,EAAY,GAAG,EAAM,CAAC,SAAS,UAAU,CAAC,CAAC,8BAR7E,IAAsC,IACjC,IAAoD,CAC9F,EAAS,EAAa,2CAA2C,mNAAmN,CAOpR,EAAY,CAAC,QAAQ,YAAY,SAAS,OAAO,WAAW,aAAa,MAAM,QAAQ,WAAW,OAAO,OAAO,OAAO,aAAa,MAAM,OAAO,UAAU,CAAC,EAAoB,EAAa,CAAC,WAAW,CAAC,KAAK,EAAY,OAAO,MAAM,cAAc,aAAa,SAAS,YAAY,6CAA6C,CAAC,CAAC"}