{"version":3,"file":"AuthGuard.Dc2S--T1.mjs","names":["React.useState","React.useMemo"],"sources":["https:/framerusercontent.com/modules/oHvaToiMjNsIImYzvzrr/5WmU3andA3IKxAlFmBDq/AuthGuard.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";import{createClient}from\"@supabase/supabase-js\";export default function AuthGuard(props){const{supabaseUrl,supabaseAnonKey,loginPath,showCheckingText,checkingText}=props;const[checking,setChecking]=React.useState(true);const supabase=React.useMemo(()=>{if(!supabaseUrl||!supabaseAnonKey)return null;return createClient(supabaseUrl,supabaseAnonKey);},[supabaseUrl,supabaseAnonKey]);React.useEffect(()=>{let isMounted=true;async function checkAuth(){const currentTarget=RenderTarget.current();if(currentTarget===RenderTarget.canvas){if(isMounted)setChecking(false);return;}if(!supabase){redirectToLogin();return;}const timeout=new Promise(resolve=>{window.setTimeout(()=>resolve({timedOut:true}),4e3);});const sessionCheck=supabase.auth.getSession().then(result=>({result})).catch(error=>({error}));const response=await Promise.race([sessionCheck,timeout]);if(!isMounted)return;if(response?.result?.data?.session){setChecking(false);return;}redirectToLogin();}checkAuth();return()=>{isMounted=false;};},[supabase,loginPath]);function redirectToLogin(){if(typeof window===\"undefined\")return;const currentPath=window.location.pathname+window.location.search;const path=loginPath||\"/giris-yap\";const separator=path.includes(\"?\")?\"&\":\"?\";window.location.href=`${path}${separator}redirect=${encodeURIComponent(currentPath)}`;}if(!showCheckingText){return null;}return checking?/*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",fontFamily:\"Open Runde, sans-serif\",fontSize:14,fontWeight:700,color:\"#6E7894\"},children:checkingText||\"Giriş kontrol ediliyor...\"}):null;}AuthGuard.defaultProps={loginPath:\"/giris-yap\",showCheckingText:false,checkingText:\"Giriş kontrol ediliyor...\"};addPropertyControls(AuthGuard,{supabaseUrl:{type:ControlType.String,title:\"Supabase URL\"},supabaseAnonKey:{type:ControlType.String,title:\"Anon Key\"},loginPath:{type:ControlType.String,title:\"Giriş Sayfası\",defaultValue:\"/giris-yap\"},showCheckingText:{type:ControlType.Boolean,title:\"Yazı G\\xf6ster\",defaultValue:false},checkingText:{type:ControlType.String,title:\"Kontrol Yazısı\",defaultValue:\"Giriş kontrol ediliyor...\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"AuthGuard\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./AuthGuard.map"],"mappings":"8PAAwL,SAAwB,EAAU,EAAM,CAAC,GAAK,CAAC,cAAY,kBAAgB,YAAU,mBAAiB,gBAAc,EAAW,CAAC,EAAS,GAAaA,EAAe,GAAK,CAAO,EAASC,MAAsB,CAAC,GAAa,CAAC,EAAuB,KAAY,EAAa,EAAY,EAAgB,CAAG,CAAC,EAAY,EAAgB,CAAC,CAAC,MAAoB,CAAC,IAAI,EAAU,GAAK,eAAe,GAAW,CAA4C,GAAvB,EAAa,SAAS,GAAoB,EAAa,OAAO,CAAI,GAAU,EAAY,GAAM,CAAC,OAAQ,GAAG,CAAC,EAAS,CAAC,GAAiB,CAAC,OAAQ,IAAM,EAAQ,IAAI,QAAQ,GAAS,CAAC,EAAO,eAAe,EAAQ,CAAC,SAAS,GAAK,CAAC,CAAC,IAAI,EAAG,CAAO,EAAa,EAAS,KAAK,YAAY,CAAC,KAAK,IAAS,CAAC,SAAO,EAAE,CAAC,MAAM,IAAQ,CAAC,QAAM,EAAE,CAAO,EAAS,MAAM,QAAQ,KAAK,CAAC,EAAa,EAAQ,CAAC,CAAK,KAAiB,IAAG,GAAU,QAAQ,MAAM,QAAQ,CAAC,EAAY,GAAM,CAAC,OAAQ,GAAiB,EAAc,OAAZ,GAAW,KAAW,CAAC,EAAU,KAAU,CAAC,EAAS,EAAU,CAAC,CAAC,SAAS,GAAiB,CAAC,GAAU,IAAS,OAAY,OAAO,IA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