{"version":3,"file":"DescopeOverrides.DMULOSFu.mjs","names":["__legacyOverrideHOC_DataObserverContext","_jsx","useState","_Fragment","React"],"sources":["https:/framerusercontent.com/modules/JmUgGJf9dMzyJcKMMZhL/TdTLlpE5ROidJfY67unI/DescopeOverrides.js"],"sourcesContent":["\"use client\";import{jsx as _jsx,Fragment as _Fragment}from\"react/jsx-runtime\";import React,{useState,useEffect,useCallback}from\"react\";const projectId=\"P3HvAP7uQBYt62DYBJr1IJywVIAH\"// replace with your Descope Project ID\n;const redirectPage=\"https://lancerworldwide.com/\"// replace with your Redirect URL\n;const redirectPageAuth=\"https://lancerworldwide.com/\"// replace with your Redirect URL\n;const loadDescopeScripts=()=>{return new Promise((resolve,reject)=>{if(typeof window===\"undefined\")return reject(\"Window undefined\");if(document.getElementById(\"descope-webjs-sdk\")){resolve();return;}const webJsScript=document.createElement(\"script\");webJsScript.id=\"descope-webjs-sdk\";webJsScript.src=\"https://descopecdn.com/npm/@descope/web-js-sdk@1.16.0/dist/index.umd.js\";webJsScript.async=true;const webComponentScript=document.createElement(\"script\");webComponentScript.id=\"descope-web-component-sdk\";webComponentScript.src=\"https://descopecdn.com/npm/@descope/web-component@3.21.0/dist/index.js\";webComponentScript.async=true;webComponentScript.type=\"module\";webJsScript.onload=()=>{document.head.appendChild(webComponentScript);webComponentScript.onload=()=>resolve();webComponentScript.onerror=e=>reject(e);};webJsScript.onerror=e=>reject(e);document.head.appendChild(webJsScript);});};let sdkInstance=null;const initSDK=()=>{if(typeof window===\"undefined\")return null;if(!window.Descope)return null;if(!sdkInstance){sdkInstance=window.Descope({projectId,persistTokens:true,autoRefresh:true});}return sdkInstance;};const logout=async()=>{if(!sdkInstance)return;await sdkInstance.logoutAll();window.location.reload();};const ClientSideWrapper=({children})=>{const[isClient,setIsClient]=useState(false);useEffect(()=>{setIsClient(true);},[]);return isClient?/*#__PURE__*/_jsx(_Fragment,{children:children}):null;};const AuthWrapperContent=({Component,hidden,redirect,redirectURL,...props})=>{const[sdk,setSdk]=useState(null);const[isReady,setIsReady]=useState(false);const[isAuthenticated,setIsAuthenticated]=useState(false);useEffect(()=>{const init=async()=>{try{await loadDescopeScripts();const sdkInstance=initSDK();setSdk(sdkInstance);if(sdkInstance){const sessionToken=sdkInstance.getSessionToken();const isExpired=sessionToken?sdkInstance.isJwtExpired(sessionToken):true;if(!sessionToken||isExpired){try{await sdkInstance.refresh();}catch(e){console.warn(\"Token refresh failed\",e);setIsAuthenticated(false);setIsReady(true);return;}}const freshToken=sdkInstance.getSessionToken();const stillExpired=freshToken?sdkInstance.isJwtExpired(freshToken):true;setIsAuthenticated(!!freshToken&&!stillExpired);}else{setIsAuthenticated(false);}}catch(err){console.error(\"Descope init failed\",err);setIsAuthenticated(false);}finally{setIsReady(true);}};init();},[]);useEffect(()=>{if(!isReady)return;if(hidden&&!isAuthenticated&&redirect){window.location.href=redirectURL;}else if(!hidden&&isAuthenticated&&redirect){window.location.href=redirectURL;}},[isReady,isAuthenticated,hidden,redirect,redirectURL]);if(!isReady)return /*#__PURE__*/_jsx(\"div\",{children:\"Loading...\"});if(hidden){return isAuthenticated?/*#__PURE__*/_jsx(Component,{...props}):null;}else{return!isAuthenticated?/*#__PURE__*/_jsx(Component,{...props}):null;}};const LogoutButtonContent=({Component,...props})=>{const[isReady,setIsReady]=useState(false);useEffect(()=>{loadDescopeScripts().then(()=>{initSDK();setIsReady(true);}).catch(()=>{});},[]);const handleLogout=useCallback(()=>{logout();},[]);if(!isReady)return null;return /*#__PURE__*/_jsx(Component,{...props,onClick:handleLogout});};export const protectedComponent=Component=>{return props=>/*#__PURE__*/_jsx(ClientSideWrapper,{children:/*#__PURE__*/_jsx(React.StrictMode,{children:/*#__PURE__*/_jsx(AuthWrapperContent,{Component:Component,hidden:true,redirect:false,redirectURL:\"\",...props})})});};export const unprotectedComponent=Component=>{return props=>/*#__PURE__*/_jsx(ClientSideWrapper,{children:/*#__PURE__*/_jsx(React.StrictMode,{children:/*#__PURE__*/_jsx(AuthWrapperContent,{Component:Component,hidden:false,redirect:false,redirectURL:\"\",...props})})});};export const protectedPage=Component=>{return props=>/*#__PURE__*/_jsx(ClientSideWrapper,{children:/*#__PURE__*/_jsx(React.StrictMode,{children:/*#__PURE__*/_jsx(AuthWrapperContent,{Component:Component,hidden:true,redirect:true,redirectURL:redirectPage,...props})})});};export const unprotectedPage=Component=>{return props=>/*#__PURE__*/_jsx(ClientSideWrapper,{children:/*#__PURE__*/_jsx(React.StrictMode,{children:/*#__PURE__*/_jsx(AuthWrapperContent,{Component:Component,hidden:false,redirect:true,redirectURL:redirectPage,...props})})});};export const logoutButton=Component=>{return props=>/*#__PURE__*/_jsx(ClientSideWrapper,{children:/*#__PURE__*/_jsx(React.StrictMode,{children:/*#__PURE__*/_jsx(LogoutButtonContent,{Component:Component,...props})})});};export function RefreshSession(){initSDK()// Call this at the top of the page via the override\n;return{};}import{useContext as __legacyOverrideHOC_useContext}from\"react\";import{DataObserverContext as __legacyOverrideHOC_DataObserverContext}from\"framer\";export function withRefreshSession(C){return props=>{__legacyOverrideHOC_useContext(__legacyOverrideHOC_DataObserverContext);return _jsx(C,{...props,...RefreshSession(props)});};}withRefreshSession.displayName=\"RefreshSession\";\nexport const __FramerMetadata__ = {\"exports\":{\"unprotectedComponent\":{\"type\":\"reactHoc\",\"name\":\"unprotectedComponent\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"RefreshSession\":{\"type\":\"override\",\"name\":\"RefreshSession\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"logoutButton\":{\"type\":\"reactHoc\",\"name\":\"logoutButton\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"protectedPage\":{\"type\":\"reactHoc\",\"name\":\"protectedPage\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"protectedComponent\":{\"type\":\"reactHoc\",\"name\":\"protectedComponent\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"unprotectedPage\":{\"type\":\"reactHoc\",\"name\":\"unprotectedPage\",\"annotations\":{\"framerContractVersion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