{"version":3,"file":"Outseta.pTOgGrdI.mjs","names":["user","useState"],"sources":["https:/framerusercontent.com/modules/P2V3LzxufipguDNkgo6B/THlOGv6j7zTUdUUZirRH/Outseta.js"],"sourcesContent":["/// VERSION 0.0.1\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useState}from\"react\";/////////////////// Button Overrides\nexport function withRegisterPopup(Component){return props=>/*#__PURE__*/_jsx(Component,{...props,\"data-o-anonymous\":\"1\",\"data-o-auth\":\"1\",\"data-mode\":\"popup\",\"data-widget-mode\":\"register\"});}export function asLoginPopupButton(Component){return props=>/*#__PURE__*/_jsx(Component,{...props,\"data-o-anonymous\":\"1\",\"data-o-auth\":\"1\",\"data-mode\":\"popup\",\"data-widget-mode\":\"login\"});}export function asProfilePopupButton(Component){return props=>/*#__PURE__*/_jsx(Component,{...props,\"data-o-authenticated\":\"1\",\"data-o-profile\":\"1\",\"data-mode\":\"popup\"});}export function asLogoutButton(Component){return props=>/*#__PURE__*/_jsx(Component,{...props,\"data-o-authenticated\":\"1\",\"data-o-logout-link\":\"1\"});}/////////////////// Autofill Input Overrides\nexport function autofillUserEmail(props){const user=useUser();if(user&&user.Email)props.value=user.Email;return props;}export function autofillUserFullName(props){const user=useUser();if(user&&user.FullName)props.value=user.FullName;return props;}export function autofillUserFirstName(props){const user=useUser();if(user&&user.FirstName)props.value=user.FirstName;return props;}export function autofillUserLastName(props){const user=useUser();if(user&&user.LastName)props.value=user.LastName;return props;}/////////////////// Visibility Overrides\nexport function showForAuthenticated(Component){return props=>/*#__PURE__*/_jsx(Component,{...props,\"data-o-authenticated\":\"1\"});}export function showForAnonymous(Component){return props=>/*#__PURE__*/_jsx(Component,{...props,\"data-o-anonymous\":\"1\"});}// Example plan and custom property visibility\nexport function showForSinglePlan_ExampleUser(Component){const validPlanUid=\"zWZJobWp\";return props=>{try{const user=useUser();const value=user&&user[\"Account.CurrentSubscription.Plan.Uid\"];if(value===validPlanUid)return /*#__PURE__*/_jsx(Component,{...props});return null;}catch(error){log(\"error in showForSinglePlan\",validPlanUid,error.message);return null;}};}// Example plan and custom property visibility\nexport function showForSinglePlan_Pro_S(Component){const validPlanUid=\"aWxOEV9V\";return props=>{try{const user=useUser();const value=user&&user[\"Account.CurrentSubscription.Plan.Uid\"];if(value===validPlanUid)return /*#__PURE__*/_jsx(Component,{...props});return null;}catch(error){log(\"error in showForSinglePlan\",validPlanUid,error.message);return null;}};}// Example plan and custom property visibility\nexport function showForSinglePlan_Pro_M(Component){const validPlanUid=\"yWoqZ7QD\";return props=>{try{const user=useUser();const value=user&&user[\"Account.CurrentSubscription.Plan.Uid\"];if(value===validPlanUid)return /*#__PURE__*/_jsx(Component,{...props});return null;}catch(error){log(\"error in showForSinglePlan\",validPlanUid,error.message);return null;}};}// Example plan and custom property visibility\nexport function showForSinglePlan_Pro_L(Component){const validPlanUid=\"DmwBZqW4\";return props=>{try{const user=useUser();const value=user&&user[\"Account.CurrentSubscription.Plan.Uid\"];if(value===validPlanUid)return /*#__PURE__*/_jsx(Component,{...props});return null;}catch(error){log(\"error in showForSinglePlan\",validPlanUid,error.message);return null;}};}export function showForSinglePlan_PortalUserBase(Component){const validPlanUid=\"XQYAOPQP\";return props=>{try{const user=useUser();const value=user&&user[\"Account.CurrentSubscription.Plan.Uid\"];if(value===validPlanUid)return /*#__PURE__*/_jsx(Component,{...props});return null;}catch(error){log(\"error in showForSinglePlan\",validPlanUid,error.message);return null;}};}// Example plan and custom property visibility\nexport function hideForSinglePlan_aWxOEV9V(Component){const validPlanUid=\"aWxOEV9V\";return props=>{try{const user=useUser();const value=user&&user[\"Account.CurrentSubscription.Plan.Uid\"];// Reversed the condition here:\nif(value===validPlanUid)return null;return /*#__PURE__*/_jsx(Component,{...props});}catch(error){log(\"error in hideForSinglePlan\",validPlanUid,error.message);return null;}};}// Example plan and custom property visibility\nexport function hideForSinglePlan_ExampleUser(Component){const validPlanUid=\"zWZJobWp\";return props=>{try{const user=useUser();const value=user&&user[\"Account.CurrentSubscription.Plan.Uid\"];// Reversed the condition here:\nif(value===validPlanUid)return null;return /*#__PURE__*/_jsx(Component,{...props});}catch(error){log(\"error in hideForSinglePlan\",validPlanUid,error.message);return null;}};}export function showForPartyAccounts(Component){const validPropertyValue=\"PARTY\";return props=>{try{const user=useUser();const value=user&&user[\"Account.MyCustomAccountProperty\"]?.toUpperCase();if(value===validPropertyValue)return /*#__PURE__*/_jsx(Component,{...props});return null;}catch(error){log(\"error in showForPartyPlan\",validPropertyValue,error.message);return null;}};}export function showForPartyPeople(Component){const validPropertyValue=\"PARTY\";return props=>{try{const user=useUser();const value=user&&user[\"MyCustomPersonProperty\"]?.toUpperCase();if(value===validPropertyValue)return /*#__PURE__*/_jsx(Component,{...props});return null;}catch(error){log(\"error in showForPartyPeople\",validPropertyValue,error.message);return null;}};}/////////////////// Text Overrides\nexport function withUserFirstName(Component){return withProperty(\"FirstName\",Component);}export function withUserLastName(Component){return withProperty(\"LastName\",Component);}export function withUserFullName(Component){return withProperty(\"FullName\",Component);}export function withUserEmail(Component){return withProperty(\"Email\",Component);}export function withAccountName(Component){return withProperty(\"Account.Name\",Component);}export function withAccountSubscriptionUid(Component){return withProperty(\"Account.CurrentSubscription.Plan.Uid\",Component);}export function withAccountSubscriptionName(Component){return withProperty(\"Account.CurrentSubscription.Plan.Name\",Component);}export function withAccountSubscriptionDescription(Component){return withProperty(\"Account.CurrentSubscription.Plan.Description\",Component);}/////////////////// Image Overrides\nexport function withUserAvatar(Component){return withImageProperty(\"ProfileImageS3Url\",Component);}let user=null;const listeners=new Set;const fetchUser=async event=>{try{log(\"fetch user\",event);const userObject=await getOutseta().getUser();user=flattenObject(userObject);log(\"fetch user fulfilled\",event,userObject,user);notifyListeners();}catch(error){log(\"fetch user failed\",error);}};const clearUser=event=>{user=null;log(\"cleared user\",event);notifyListeners();};const notifyListeners=()=>{listeners.forEach(listener=>listener(user));};export const subscribe=listener=>{listeners.add(listener);return()=>listeners.delete(listener);};export const getUser=()=>user||null;// Listen to global events\nconst outsetaFetchUserEvents=[\"accessToken.set\",\"profile.update\",\"account.update\"];outsetaFetchUserEvents.forEach(event=>{getOutseta()?.on(event,()=>fetchUser(event));});const outsetaClearUserEvents=[\"logout\"];outsetaClearUserEvents.forEach(event=>{getOutseta()?.on(event,()=>clearUser(event));});/////////////////// User Hook\nexport function useUser(){const[userState,setUserState]=useState(getUser());useEffect(()=>{const updateData=newData=>setUserState(newData);const unsubscribe=subscribe(updateData);return()=>unsubscribe();},[]);return userState;}function getOutseta(){if(typeof window!==\"undefined\"&&window[\"Outseta\"]){return window[\"Outseta\"];}else if(typeof window!==\"undefined\"){console.log(\"Outseta is missing, have you added the Outseta Script and Options to the head of the site?\");alert(`We're sorry, but it seems that Outseta is missing. Please reach out to the owner of ${window.location.hostname} to let them know. Thank you for your understanding 🙏`);}}/////////////////// Helpers\nfunction withProperty(property,Component){return props=>{const user=useUser();if(!user)return null;return /*#__PURE__*/_jsx(Component,{...props,text:user[property]});};}function withImageProperty(property,Component){return props=>{const user=useUser();if(!user)return null;const imageSrc=user[property];if(imageSrc){return /*#__PURE__*/_jsx(Component,{...props,background:{...props.background,src:imageSrc,srcSet:undefined}});}else if(props.background?.src){return /*#__PURE__*/_jsx(Component,{...props});}else{return null;}};}function log(...props){if(getOutseta())getOutseta()?.debug(\"outseta.framer.override.user\",...props);}function flattenObject(obj,parent=\"\",res={}){for(let key in obj){let propName=parent?`${parent}.${key}`:key;if(Array.isArray(obj[key])){obj[key].forEach((item,idx)=>flattenObject(item,`${propName}[${idx}]`,res));}else if(typeof obj[key]===\"object\"&&obj[key]!==null){flattenObject(obj[key],propName,res);}else{res[propName]=obj[key];}}return res;}\nexport const __FramerMetadata__ = {\"exports\":{\"withUserFirstName\":{\"type\":\"reactHoc\",\"name\":\"withUserFirstName\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withUserLastName\":{\"type\":\"reactHoc\",\"name\":\"withUserLastName\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withAccountSubscriptionUid\":{\"type\":\"reactHoc\",\"name\":\"withAccountSubscriptionUid\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withUserAvatar\":{\"type\":\"reactHoc\",\"name\":\"withUserAvatar\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withUserFullName\":{\"type\":\"reactHoc\",\"name\":\"withUserFullName\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"subscribe\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withRegisterPopup\":{\"type\":\"reactHoc\",\"name\":\"withRegisterPopup\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"useUser\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"showForAnonymous\":{\"type\":\"reactHoc\",\"name\":\"showForAnonymous\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"asProfilePopupButton\":{\"type\":\"reactHoc\",\"name\":\"asProfilePopupButton\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"showForSinglePlan_PortalUserBase\":{\"type\":\"reactHoc\",\"name\":\"showForSinglePlan_PortalUserBase\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"showForSinglePlan_ExampleUser\":{\"type\":\"reactHoc\",\"name\":\"showForSinglePlan_ExampleUser\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"autofillUserLastName\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"showForSinglePlan_Pro_L\":{\"type\":\"reactHoc\",\"name\":\"showForSinglePlan_Pro_L\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"asLogoutButton\":{\"type\":\"reactHoc\",\"name\":\"asLogoutButton\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"showForPartyAccounts\":{\"type\":\"reactHoc\",\"name\":\"showForPartyAccounts\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"autofillUserEmail\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"showForSinglePlan_Pro_M\":{\"type\":\"reactHoc\",\"name\":\"showForSinglePlan_Pro_M\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"getUser\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"showForSinglePlan_Pro_S\":{\"type\":\"reactHoc\",\"name\":\"showForSinglePlan_Pro_S\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"hideForSinglePlan_aWxOEV9V\":{\"type\":\"reactHoc\",\"name\":\"hideForSinglePlan_aWxOEV9V\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"showForAuthenticated\":{\"type\":\"reactHoc\",\"name\":\"showForAuthenticated\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"asLoginPopupButton\":{\"type\":\"reactHoc\",\"name\":\"asLoginPopupButton\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withAccountSubscriptionName\":{\"type\":\"reactHoc\",\"name\":\"withAccountSubscriptionName\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"autofillUserFullName\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withUserEmail\":{\"type\":\"reactHoc\",\"name\":\"withUserEmail\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"showForPartyPeople\":{\"type\":\"reactHoc\",\"name\":\"showForPartyPeople\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"autofillUserFirstName\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withAccountSubscriptionDescription\":{\"type\":\"reactHoc\",\"name\":\"withAccountSubscriptionDescription\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"hideForSinglePlan_ExampleUser\":{\"type\":\"reactHoc\",\"name\":\"hideForSinglePlan_ExampleUser\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withAccountName\":{\"type\":\"reactHoc\",\"name\":\"withAccountName\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Outseta.map"],"mappings":"kIAIA,SAAgB,EAAqB,EAAU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