{"version":3,"file":"Auth.CZGHd-Rq.mjs","names":[],"sources":["https:/framerusercontent.com/modules/mMN9DJv9UeuF8Q7b2y8M/LDEcaNNOhXvOECx6hADu/Auth.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{createStore}from\"https://framer.com/m/framer/store.js@^1.0.0\";import{useEffect}from\"react\";const noPermissions={hasEarlyAccess:false,hasExamples:false,hasPlus:false,hasStudio:false,isTeamAdmin:false,isMattPerry:false};const useStore=createStore({status:null,hasEarlyAccess:false,hasExamples:false,hasPlus:false,hasStudio:false,isTeamAdmin:false,isMattPerry:false});let isCheckingStatus=false;export function useUserStatus(){const[state,setState]=useStore();useEffect(()=>{if(state.status!==null||isCheckingStatus)return;isCheckingStatus=true;fetch(\"https://api.motion.dev/me/permissions\",{credentials:\"include\"}).then(res=>res.json()).then(status=>{setState({status:status.hasPlus,...status});}).catch(()=>{setState({status:\"LoggedOut\",...noPermissions});});},[state]);return state;}export function withLoggedOut(Component){return props=>{const{status}=useUserStatus();// if (status === null || (status !== null && )) return <Component {...props} />\nreturn null;};}export function withHasPlus(Component){return props=>{const{hasPlus}=useUserStatus();if(!hasPlus)return null;return /*#__PURE__*/_jsx(Component,{...props});};}export function withNotHasPlus(Component){return props=>{const{hasPlus}=useUserStatus();if(hasPlus)return null;return /*#__PURE__*/_jsx(Component,{...props});};}export function withSetVariant(Component){return props=>{const{status}=useUserStatus();let variant=\"Loading\";if(status===\"LoggedOut\"){variant=\"Paywall\";}else if(status===false){variant=\"Paywall\";}else if(status===true){variant=\"Sponsor\";}return /*#__PURE__*/_jsx(Component,{...props,variant:variant});};}export function withShowWhenPurchased(Component){return props=>{const{status}=useUserStatus();let variant=\"Loading\";if(status===\"LoggedOut\"){variant=\"Paywall\";}else if(status===false){variant=\"Paywall\";}else if(status===true){variant=\"Sponsor\";}const hasPurchased=variant===\"Sponsor\";return /*#__PURE__*/_jsx(Component,{...props,style:{...props.style,display:hasPurchased?\"flex\":\"none\"}});};}export function withLoginRedirect(Component){const addRedirect=e=>{e.preventDefault();window.location.assign(e.target.href+encodeURIComponent(window.location.href));};return props=>{return /*#__PURE__*/_jsx(Component,{...props,onClick:addRedirect});};}export function withReferral(Component){const addRedirect=e=>{e.preventDefault();window.location.assign(e.target.href+\"?referral=\"+encodeURIComponent(window.location.pathname));};return props=>{return /*#__PURE__*/_jsx(Component,{...props,onClick:addRedirect});};}\nexport const __FramerMetadata__ = {\"exports\":{\"withReferral\":{\"type\":\"reactHoc\",\"name\":\"withReferral\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withSetVariant\":{\"type\":\"reactHoc\",\"name\":\"withSetVariant\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withLoginRedirect\":{\"type\":\"reactHoc\",\"name\":\"withLoginRedirect\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withNotHasPlus\":{\"type\":\"reactHoc\",\"name\":\"withNotHasPlus\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withShowWhenPurchased\":{\"type\":\"reactHoc\",\"name\":\"withShowWhenPurchased\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"useUserStatus\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withHasPlus\":{\"type\":\"reactHoc\",\"name\":\"withHasPlus\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withLoggedOut\":{\"type\":\"reactHoc\",\"name\":\"withLoggedOut\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Auth.map"],"mappings":"wLAA0b,SAAgB,GAAe,CAAC,GAAK,CAAC,EAAM,GAAU,GAAU,CAAyT,OAAxT,MAAc,CAAI,EAAM,SAAS,MAAM,IAAwB,EAAiB,GAAK,MAAM,wCAAwC,CAAC,YAAY,UAAU,CAAC,CAAC,KAAK,GAAK,EAAI,MAAM,CAAC,CAAC,KAAK,GAAQ,CAAC,EAAS,CAAC,OAAO,EAAO,QAAQ,GAAG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